Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .changeset/twenty-forks-grab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@workflow/world-postgres": patch
"@workflow/world-testing": patch
"@workflow/world-local": patch
"@workflow/core": patch
"@workflow/next": patch
"@workflow/cli": patch
"@workflow/web": patch
---

Rename leftover references to "embedded world" to be "local world"
2 changes: 1 addition & 1 deletion packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@
### Patch Changes

- 66332f2: Rename vercel-static builder to standalone
- dbf2207: Fix --backend flag not finding world when using embedded world package name explicitly
- dbf2207: Fix --backend flag not finding world when using local world package name explicitly
- Updated dependencies [dbf2207]
- Updated dependencies [eadf588]
- @workflow/[email protected]
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/lib/inspect/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const getEnvVars = (): Record<string, string> => {
WORKFLOW_VERCEL_PROXY_URL: env.WORKFLOW_VERCEL_PROXY_URL || '',
WORKFLOW_LOCAL_UI: env.WORKFLOW_LOCAL_UI || '',
PORT: env.PORT || '',
WORKFLOW_EMBEDDED_DATA_DIR: env.WORKFLOW_EMBEDDED_DATA_DIR || '',
WORKFLOW_LOCAL_DATA_DIR: env.WORKFLOW_LOCAL_DATA_DIR || '',
};
};

Expand Down Expand Up @@ -75,10 +75,10 @@ async function findWorkflowDataDir(cwd: string) {
}

/**
* Overwrites process.env variables related to embedded world configuration,
* Overwrites process.env variables related to local world configuration,
* if relevant environment variables aren't set already.
*/
export const inferEmbeddedWorldEnvVars = async () => {
export const inferLocalWorldEnvVars = async () => {
const envVars = getEnvVars();
if (!envVars.PORT) {
logger.warn(
Expand All @@ -89,12 +89,12 @@ export const inferEmbeddedWorldEnvVars = async () => {
}

// Paths to check, in order of preference
if (!envVars.WORKFLOW_EMBEDDED_DATA_DIR) {
if (!envVars.WORKFLOW_LOCAL_DATA_DIR) {
const cwd = getWorkflowConfig().workingDir;

const localPath = await findWorkflowDataDir(cwd);
if (localPath) {
envVars.WORKFLOW_EMBEDDED_DATA_DIR = localPath;
envVars.WORKFLOW_LOCAL_DATA_DIR = localPath;
writeEnvVars(envVars);
return;
}
Expand All @@ -104,7 +104,7 @@ export const inferEmbeddedWorldEnvVars = async () => {
if (repoRoot) {
const repoPath = await findWorkflowDataDir(repoRoot);
if (repoPath) {
envVars.WORKFLOW_EMBEDDED_DATA_DIR = repoPath;
envVars.WORKFLOW_LOCAL_DATA_DIR = repoPath;
writeEnvVars(envVars);
return;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/lib/inspect/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ export const cliFlags = {
description: 'backend to inspect',
required: false,
char: 'b',
default: 'embedded',
default: 'local',
env: 'WORKFLOW_TARGET_WORLD',
helpGroup: 'Target',
helpLabel: '-b, --backend',
helpValue: ['embedded', 'vercel', '<your-package-name>'],
defaultHelp: 'embedded',
helpValue: ['local', 'vercel', '<your-package-name>'],
defaultHelp: 'local',
}),
authToken: Flags.string({
description:
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/lib/inspect/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import chalk from 'chalk';
import terminalLink from 'terminal-link';
import { logger, setJsonMode, setVerboseMode } from '../config/log.js';
import {
inferEmbeddedWorldEnvVars,
inferLocalWorldEnvVars,
inferVercelEnvVars,
writeEnvVars,
} from './env.js';
Expand Down Expand Up @@ -52,10 +52,10 @@ export const setupCliWorld = async (
) {
await inferVercelEnvVars();
} else if (
flags.backend === 'embedded' ||
flags.backend === 'local' ||
flags.backend === '@workflow/world-local'
) {
await inferEmbeddedWorldEnvVars();
await inferLocalWorldEnvVars();
}

logger.debug('Initializing world');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/inspect/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function envToQueryParams(
WORKFLOW_VERCEL_PROJECT: 'project',
WORKFLOW_VERCEL_TEAM: 'team',
PORT: 'port',
WORKFLOW_EMBEDDED_DATA_DIR: 'dataDir',
WORKFLOW_LOCAL_DATA_DIR: 'dataDir',
};

for (const [envName, paramName] of Object.entries(envToQueryParamMappings)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"build": "tsc",
"dev": "tsc --watch",
"clean": "tsc --build --clean && rm -r dist ||:",
"test": "cross-env WORKFLOW_TARGET_WORLD=embedded vitest run src",
"test": "cross-env WORKFLOW_TARGET_WORLD=local vitest run src",
"test:e2e": "vitest run e2e",
"typecheck": "tsc --noEmit"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/runtime/world.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRequire } from 'node:module';
import { join } from 'node:path';
import type { World } from '@workflow/world';
import { createEmbeddedWorld } from '@workflow/world-local';
import { createLocalWorld } from '@workflow/world-local';
import { createVercelWorld } from '@workflow/world-vercel';

const require = createRequire(join(process.cwd(), 'index.js'));
Expand All @@ -14,12 +14,12 @@ const globalSymbols: typeof globalThis & {
[StubbedWorldCache]?: World;
} = globalThis;

function defaultWorld(): 'vercel' | 'embedded' {
function defaultWorld(): 'vercel' | 'local' {
if (process.env.VERCEL_DEPLOYMENT_ID) {
return 'vercel';
}

return 'embedded';
return 'local';
}

/**
Expand All @@ -42,9 +42,9 @@ export const createWorld = (): World => {
});
}

if (targetWorld === 'embedded') {
return createEmbeddedWorld({
dataDir: process.env.WORKFLOW_EMBEDDED_DATA_DIR,
if (targetWorld === 'local') {
return createLocalWorld({
dataDir: process.env.WORKFLOW_LOCAL_DATA_DIR,
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as nanoid from 'nanoid';
import { monotonicFactory } from 'ulid';
import { EventConsumerResult, EventsConsumer } from './events-consumer.js';
import { ENOTSUP } from './global.js';
import { parseWorkflowName } from './parse-name.js';
import type { WorkflowOrchestratorContext } from './private.js';
import {
dehydrateWorkflowReturnValue,
Expand All @@ -28,7 +29,6 @@ import type { WorkflowMetadata } from './workflow/get-workflow-metadata.js';
import { WORKFLOW_CONTEXT_SYMBOL } from './workflow/get-workflow-metadata.js';
import { createCreateHook } from './workflow/hook.js';
import { createSleep } from './workflow/sleep.js';
import { parseWorkflowName } from './parse-name.js';

export async function runWorkflow(
workflowCode: string,
Expand Down Expand Up @@ -104,7 +104,7 @@ export async function runWorkflow(
getWorkflowRunStreamId(workflowRun.runId, namespace);

// TODO: there should be a getUrl method on the world interface itself. This
// solution only works for vercel + embedded worlds.
// solution only works for vercel + local worlds.
const url = process.env.VERCEL_URL
? `https://${process.env.VERCEL_URL}`
: `http://localhost:${port ?? 3000}`;
Expand Down
8 changes: 4 additions & 4 deletions packages/next/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export function withWorkflow(
workflows,
}: {
workflows?: {
embedded?: {
local?: {
port?: number;
dataDir?: string;
};
Expand All @@ -22,10 +22,10 @@ export function withWorkflow(
) {
if (!process.env.VERCEL_DEPLOYMENT_ID) {
if (!process.env.WORKFLOW_TARGET_WORLD) {
process.env.WORKFLOW_TARGET_WORLD = 'embedded';
process.env.WORKFLOW_EMBEDDED_DATA_DIR = '.next/workflow-data';
process.env.WORKFLOW_TARGET_WORLD = 'local';
process.env.WORKFLOW_LOCAL_DATA_DIR = '.next/workflow-data';
}
const maybePort = workflows?.embedded?.port;
const maybePort = workflows?.local?.port;
if (maybePort) {
process.env.PORT = maybePort.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ const getConnectionInfo = (
return { provider: 'Vercel', parts };
}

if (backend === 'embedded') {
// Embedded backend
if (backend === 'local') {
// Local backend
const parts: string[] = [];
if (config.dataDir) {
parts.push(`dir: ${config.dataDir}`);
}
if (config.port) parts.push(`port: ${config.port}`);

return { provider: 'Embedded', parts };
return { provider: 'Local', parts };
}

return { provider: config.backend || 'unknown', parts: [] };
};

export function ConnectionStatus({ config }: ConnectionStatusProps) {
const backend = config.backend || 'embedded';
const backend = config.backend || 'local';
const { provider, parts } = getConnectionInfo(backend, config);

return (
Expand Down
12 changes: 6 additions & 6 deletions packages/web/src/components/settings-sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export function SettingsSidebar() {
const [errors, setErrors] = useState<ValidationError[]>([]);
const [isValidating, setIsValidating] = useState(false);

const backend = localConfig.backend || 'embedded';
const isEmbedded = backend === 'embedded';
const backend = localConfig.backend || 'local';
const isLocal = backend === 'local';

// Update local config when query params change
useEffect(() => {
Expand Down Expand Up @@ -112,7 +112,7 @@ export function SettingsSidebar() {
<div className="space-y-2">
<Label htmlFor="backend">Backend</Label>
<Select
value={localConfig.backend || 'embedded'}
value={localConfig.backend || 'local'}
onValueChange={(value) =>
handleInputChange('backend', value)
}
Expand All @@ -121,13 +121,13 @@ export function SettingsSidebar() {
<SelectValue placeholder="Select backend" />
</SelectTrigger>
<SelectContent>
<SelectItem value="embedded">Embedded</SelectItem>
<SelectItem value="local">Local</SelectItem>
<SelectItem value="vercel">Vercel</SelectItem>
</SelectContent>
</Select>
</div>

{isEmbedded && (
{isLocal && (
<>
<div className="space-y-2">
<Label htmlFor="port">Port</Label>
Expand Down Expand Up @@ -175,7 +175,7 @@ export function SettingsSidebar() {
</>
)}

{!isEmbedded && (
{!isLocal && (
<>
<div className="space-y-2">
<Label htmlFor="env">Environment</Label>
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/lib/config-world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ export async function validateWorldConfig(
config: WorldConfig
): Promise<ValidationError[]> {
const errors: ValidationError[] = [];
const backend = config.backend || 'embedded';
const backend = config.backend || 'local';

if (backend === 'embedded') {
if (backend === 'local') {
// Check if data directory exists
if (config.dataDir) {
const resolvedPath = resolve(config.dataDir);
Expand Down
4 changes: 2 additions & 2 deletions packages/web/src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type { WorldConfig } from '@/lib/config-world';

// Default configuration
const DEFAULT_CONFIG: WorldConfig = {
backend: 'embedded',
backend: 'local',
dataDir: './.next/workflow-data',
port: '3000',
env: 'production',
Expand Down Expand Up @@ -139,6 +139,6 @@ export const worldConfigToEnvMap = (config: WorldConfig): EnvMap => {
WORKFLOW_VERCEL_PROJECT: config.project,
WORKFLOW_VERCEL_TEAM: config.team,
PORT: config.port,
WORKFLOW_EMBEDDED_DATA_DIR: config.dataDir,
WORKFLOW_LOCAL_DATA_DIR: config.dataDir,
};
};
6 changes: 3 additions & 3 deletions packages/world-local/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@

### Major Changes

- aa015af: BREAKING: Change `createEmbeddedWorld` API signature from positional parameters to config object. Add baseUrl configuration support.
- aa015af: BREAKING: Change `createLocalWorld` API signature from positional parameters to config object. Add baseUrl configuration support.

**Breaking change:**

- `createEmbeddedWorld(dataDir?, port?)` → `createEmbeddedWorld(args?: Partial<Config>)`
- `createLocalWorld(dataDir?, port?)` → `createLocalWorld(args?: Partial<Config>)`

**New features:**

- Add `baseUrl` config option for HTTPS and custom hostnames (via config or `WORKFLOW_EMBEDDED_BASE_URL` env var)
- Add `baseUrl` config option for HTTPS and custom hostnames (via config or `WORKFLOW_LOCAL_BASE_URL` env var)
- Support for port 0 (OS-assigned port)

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/world-local/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { getPort } from '@workflow/utils/get-port';
import { once } from './util.js';

const getDataDirFromEnv = () => {
return process.env.WORKFLOW_EMBEDDED_DATA_DIR || '.workflow-data';
return process.env.WORKFLOW_LOCAL_DATA_DIR || '.workflow-data';
};

export const DEFAULT_RESOLVE_DATA_OPTION = 'all';

const getBaseUrlFromEnv = () => {
return process.env.WORKFLOW_EMBEDDED_BASE_URL;
return process.env.WORKFLOW_LOCAL_BASE_URL;
};

export type Config = {
Expand All @@ -26,7 +26,7 @@ export const config = once<Config>(() => {

/**
* Resolves the base URL for queue requests following the priority order:
* 1. config.baseUrl (highest priority - full override from args or WORKFLOW_EMBEDDED_BASE_URL env var)
* 1. config.baseUrl (highest priority - full override from args or WORKFLOW_LOCAL_BASE_URL env var)
* 2. config.port (explicit port override from args)
* 3. PORT env var (explicit configuration)
* 4. Auto-detected port via getPort (detect actual listening port)
Expand Down
4 changes: 2 additions & 2 deletions packages/world-local/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { createStorage } from './storage.js';
import { createStreamer } from './streamer.js';

/**
* Creates an embedded world instance that combines queue, storage, and streamer functionalities.
* Creates a local world instance that combines queue, storage, and streamer functionalities.
*
* @param args - Optional configuration object
* @param args.dataDir - Directory for storing workflow data (default: `.workflow-data/`)
* @param args.port - Port override for queue transport (default: auto-detected)
* @param args.baseUrl - Full base URL override for queue transport (default: `http://localhost:{port}`)
*/
export function createEmbeddedWorld(args?: Partial<Config>): World {
export function createLocalWorld(args?: Partial<Config>): World {
const definedArgs = args
? Object.fromEntries(
Object.entries(args).filter(([, value]) => value !== undefined)
Expand Down
Loading
Loading