Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
da210ba
feat: add getPort method for detecting pid port
adriandlam Nov 5, 2025
54b47f3
lockfile
adriandlam Nov 5, 2025
36c5cf2
update tests and fix getPort usage
adriandlam Nov 6, 2025
20f009b
changeset
adriandlam Nov 6, 2025
b4a7604
docs: update sveltekit getting started
adriandlam Nov 6, 2025
9d8d329
fix: use pid-port
adriandlam Nov 6, 2025
54e4019
fix: not using config port env
adriandlam Nov 6, 2025
cab43ef
fix: remove unused getPort from world core
adriandlam Nov 6, 2025
a914cd2
remove unused stuff
adriandlam Nov 6, 2025
8eca292
fix: world local config returning port 3000 as fallback
adriandlam Nov 6, 2025
c39e144
changeset
adriandlam Nov 6, 2025
93862a6
fix: rebase conflicts
adriandlam Nov 6, 2025
b706b52
fix: util test missing http import
adriandlam Nov 6, 2025
6c2e7a2
changeset
adriandlam Nov 6, 2025
757fa0c
fix: wrong import for getPort in core runtime
adriandlam Nov 6, 2025
62e1123
fix: getPort in @workflow/utils being imported into workflow runtime
adriandlam Nov 6, 2025
53d9038
test: simplify sveltekit test
adriandlam Nov 6, 2025
5563d52
fix missing import in test
adriandlam Nov 7, 2025
9072175
fix: async await stuff with getPort
adriandlam Nov 7, 2025
27a12f4
feat(utils,core,world-local): add port detection and baseUrl support
aryasaatvik Nov 7, 2025
34039c3
docs: document port detection and baseUrl features
aryasaatvik Nov 7, 2025
deccc27
DCO Remediation Commit for Saatvik Arya <aryasaatvik@gmail.com>
aryasaatvik Nov 7, 2025
aead6c9
test(world-local,utils,core): add comprehensive tests for port detect…
aryasaatvik Nov 7, 2025
6c377ff
Merge branch 'main' into feat/world-local-config
aryasaatvik Nov 8, 2025
195a7ae
rm utils/node
aryasaatvik Nov 8, 2025
414aa4c
add changeset
aryasaatvik Nov 8, 2025
7b81781
Update config tests to mock getPort from the correct module '@workflo…
aryasaatvik Nov 8, 2025
30a5e06
DCO Remediation Commit for Saatvik Arya <aryasaatvik@gmail.com>
aryasaatvik Nov 8, 2025
4d5d253
fix(world-local): handle port 0 and null correctly in config
aryasaatvik Nov 8, 2025
2c75931
chore: update changeset to major for breaking API change
aryasaatvik Nov 8, 2025
2e363cb
chore: remove bug fixes section from changeset
aryasaatvik Nov 8, 2025
2397c01
chore: remove auto port detection from new features
aryasaatvik Nov 8, 2025
94d5e51
refactor(world-local): improve argument handling in createEmbeddedWorld
aryasaatvik Nov 13, 2025
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
12 changes: 12 additions & 0 deletions .changeset/chilly-yaks-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@workflow/world-local": major
---

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

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

**New features:**
- Add `baseUrl` config option for HTTPS and custom hostnames (via config or `WORKFLOW_EMBEDDED_BASE_URL` env var)
- Support for port 0 (OS-assigned port)
87 changes: 74 additions & 13 deletions docs/content/docs/deploying/world/local-world.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,63 @@ export WORKFLOW_EMBEDDED_DATA_DIR=./custom-workflow-data
```typescript
import { createEmbeddedWorld } from '@workflow/world-local';

const world = createEmbeddedWorld('./custom-workflow-data');
const world = createEmbeddedWorld({ dataDir: './custom-workflow-data' });
```

### Port

The local world automatically detects your server port from the `PORT` environment variable:
By default, the embedded world **automatically detects** which port your application is listening on using process introspection. This works seamlessly with frameworks like SvelteKit, Vite, and others that use non-standard ports.

```bash
export PORT=3000
**Auto-detection example** (recommended):

npm run dev
```typescript
import { createEmbeddedWorld } from '@workflow/world-local';

// Port is automatically detected - no configuration needed!
const world = createEmbeddedWorld();
```

You can also specify it explicitly when creating the world programmatically:
If auto-detection fails, the world will fall back to the `PORT` environment variable, then to port `3000`.

**Manual port override** (when needed):

You can override the auto-detected port by specifying it explicitly:

```typescript
import { createEmbeddedWorld } from '@workflow/world-local';

const world = createEmbeddedWorld(undefined, 3000);
const world = createEmbeddedWorld({ port: 3000 });
```

### Base URL

For advanced use cases like HTTPS or custom hostnames, you can override the entire base URL. When set, this takes precedence over all port detection and configuration.

**Use cases:**
- HTTPS dev servers (e.g., `next dev --experimental-https`)
- Custom hostnames (e.g., `local.example.com`)
- Non-localhost development

**Environment variable:**

```bash
export WORKFLOW_EMBEDDED_BASE_URL=https://local.example.com:3000
```

**Programmatically:**

```typescript
import { createEmbeddedWorld } from '@workflow/world-local';

// HTTPS
const world = createEmbeddedWorld({
baseUrl: 'https://localhost:3000'
});

// Custom hostname
const world = createEmbeddedWorld({
baseUrl: 'https://local.example.com:3000'
});
```

## Usage
Expand Down Expand Up @@ -172,26 +210,49 @@ Creates a local world instance:

```typescript
function createEmbeddedWorld(
dataDir?: string,
port?: number
args?: Partial<{
dataDir: string;
port: number;
baseUrl: string;
}>
): World
```

**Parameters:**

- `dataDir` - Directory for storing workflow data (default: `.workflow-data/`)
- `port` - Server port for queue transport (default: from `PORT` env var)
- `args` - Optional configuration object:
- `dataDir` - Directory for storing workflow data (default: `.workflow-data/` or `WORKFLOW_EMBEDDED_DATA_DIR` env var)
- `port` - Port override for queue transport (default: auto-detected → `PORT` env var → `3000`)
- `baseUrl` - Full base URL override for queue transport (default: `http://localhost:{port}` or `WORKFLOW_EMBEDDED_BASE_URL` env var)

**Returns:**

- `World` - A world instance implementing the World interface

**Example:**
**Examples:**

```typescript
import { createEmbeddedWorld } from '@workflow/world-local';

const world = createEmbeddedWorld('./my-data', 3000);
// Use all defaults (recommended - auto-detects port)
const world = createEmbeddedWorld();

// Custom data directory
const world = createEmbeddedWorld({ dataDir: './my-data' });

// Override port
const world = createEmbeddedWorld({ port: 3000 });

// HTTPS with custom hostname
const world = createEmbeddedWorld({
baseUrl: 'https://local.example.com:3000'
});

// Multiple options
const world = createEmbeddedWorld({
dataDir: './my-data',
baseUrl: 'https://localhost:3000'
});
```

## Learn More
Expand Down
Loading
Loading