runwork 0.13.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundled-types/core-endpoints.d.ts +16 -4
- package/dist/__tests__/install-scripts.test.js +33 -0
- package/dist/agents/__tests__/chatgpt-registry.test.d.ts +1 -0
- package/dist/agents/__tests__/chatgpt-registry.test.js +61 -0
- package/dist/agents/__tests__/detection.test.js +3 -0
- package/dist/agents/claude-desktop-plugin-tree.js +23 -8
- package/dist/agents/claude-desktop.js +6 -3
- package/dist/agents/codex.js +15 -7
- package/dist/agents/detection.js +3 -0
- package/dist/agents/intro-skill.js +5 -3
- package/dist/agents/registry-data.d.ts +59 -2
- package/dist/agents/registry-data.js +176 -0
- package/dist/api/client.d.ts +5 -0
- package/dist/api/client.js +8 -0
- package/dist/commands/__tests__/clone-args.test.js +8 -1
- package/dist/commands/__tests__/clone-source-result.test.d.ts +1 -0
- package/dist/commands/__tests__/clone-source-result.test.js +45 -0
- package/dist/commands/__tests__/mcp-entries.test.d.ts +1 -0
- package/dist/commands/__tests__/mcp-entries.test.js +48 -0
- package/dist/commands/clone.d.ts +33 -0
- package/dist/commands/clone.js +105 -10
- package/dist/commands/deploy.js +128 -11
- package/dist/commands/dev.js +72 -32
- package/dist/commands/doctor.js +64 -3
- package/dist/commands/info.d.ts +3 -0
- package/dist/commands/info.js +11 -0
- package/dist/commands/mcp-entries.d.ts +13 -0
- package/dist/commands/mcp-entries.js +26 -0
- package/dist/commands/sync.js +20 -11
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.js +89 -0
- package/dist/deploy/__tests__/deploy-state.test.d.ts +1 -0
- package/dist/deploy/__tests__/deploy-state.test.js +80 -0
- package/dist/deploy/__tests__/deploy-status.test.d.ts +1 -0
- package/dist/deploy/__tests__/deploy-status.test.js +41 -0
- package/dist/deploy/__tests__/detach-args.test.d.ts +1 -0
- package/dist/deploy/__tests__/detach-args.test.js +30 -0
- package/dist/deploy/deploy-state.d.ts +36 -0
- package/dist/deploy/deploy-state.js +63 -0
- package/dist/deploy/deploy-status.d.ts +21 -0
- package/dist/deploy/deploy-status.js +36 -0
- package/dist/deploy/detach.d.ts +32 -0
- package/dist/deploy/detach.js +71 -0
- package/dist/dev/__tests__/session.test.js +39 -0
- package/dist/dev/__tests__/startup-sync.test.d.ts +1 -0
- package/dist/dev/__tests__/startup-sync.test.js +32 -0
- package/dist/dev/session.d.ts +9 -0
- package/dist/dev/session.js +4 -1
- package/dist/dev/startup-sync.d.ts +23 -0
- package/dist/dev/startup-sync.js +14 -0
- package/dist/generated/bundled-types.js +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/git/__tests__/classify-sync-error.test.d.ts +1 -0
- package/dist/git/__tests__/classify-sync-error.test.js +57 -0
- package/dist/git/__tests__/ensure-git-credential-helper.test.d.ts +1 -0
- package/dist/git/__tests__/ensure-git-credential-helper.test.js +133 -0
- package/dist/git/__tests__/ensure-runwork-remote.test.d.ts +1 -0
- package/dist/git/__tests__/ensure-runwork-remote.test.js +109 -0
- package/dist/git/__tests__/repo-config.test.d.ts +1 -0
- package/dist/git/__tests__/repo-config.test.js +26 -0
- package/dist/git/classify-sync-error.d.ts +21 -0
- package/dist/git/classify-sync-error.js +111 -0
- package/dist/git/credentials.d.ts +43 -0
- package/dist/git/credentials.js +67 -0
- package/dist/git/remote.d.ts +37 -0
- package/dist/git/remote.js +75 -0
- package/dist/git/repo-config.d.ts +8 -0
- package/dist/git/repo-config.js +29 -0
- package/dist/health/__tests__/checks.test.js +2 -2
- package/dist/health/__tests__/fix.test.d.ts +1 -0
- package/dist/health/__tests__/fix.test.js +72 -0
- package/dist/health/__tests__/runner-filter.test.d.ts +1 -0
- package/dist/health/__tests__/runner-filter.test.js +61 -0
- package/dist/health/checks.d.ts +7 -0
- package/dist/health/checks.js +50 -36
- package/dist/health/fix.d.ts +22 -0
- package/dist/health/fix.js +62 -0
- package/dist/health/runner.d.ts +7 -1
- package/dist/health/runner.js +40 -27
- package/dist/index.js +2 -0
- package/dist/tools/types.d.ts +5 -0
- package/dist/types.d.ts +3 -0
- package/dist/utils/__tests__/help-json.test.d.ts +1 -0
- package/dist/utils/__tests__/help-json.test.js +39 -0
- package/dist/utils/__tests__/ignore-matcher.test.js +18 -1
- package/dist/utils/help-json.d.ts +14 -0
- package/dist/utils/help-json.js +4 -1
- package/dist/validate/__tests__/validate.test.d.ts +1 -0
- package/dist/validate/__tests__/validate.test.js +42 -0
- package/dist/validate/freshness.d.ts +28 -0
- package/dist/validate/freshness.js +48 -0
- package/dist/validate/preview.d.ts +21 -0
- package/dist/validate/preview.js +39 -0
- package/package.json +1 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
vi.mock('fs', () => ({
|
|
3
|
+
existsSync: vi.fn(),
|
|
4
|
+
mkdirSync: vi.fn(),
|
|
5
|
+
readFileSync: vi.fn(),
|
|
6
|
+
writeFileSync: vi.fn(),
|
|
7
|
+
}));
|
|
8
|
+
const fs = await import('fs');
|
|
9
|
+
const { writeDeployStatus, readDeployStatus, deployLogPath } = await import('../deploy-status.js');
|
|
10
|
+
describe('deploy/deploy-status', () => {
|
|
11
|
+
beforeEach(() => vi.clearAllMocks());
|
|
12
|
+
it('writes status JSON, creating .runwork when missing', () => {
|
|
13
|
+
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
14
|
+
writeDeployStatus('/repo', { state: 'in-progress', startedAt: '2026-06-05T00:00:00Z', pid: 123 });
|
|
15
|
+
expect(fs.mkdirSync).toHaveBeenCalled();
|
|
16
|
+
const written = vi.mocked(fs.writeFileSync).mock.calls[0][1];
|
|
17
|
+
expect(JSON.parse(written)).toEqual({ state: 'in-progress', startedAt: '2026-06-05T00:00:00Z', pid: 123 });
|
|
18
|
+
});
|
|
19
|
+
it('reads back a valid status', () => {
|
|
20
|
+
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
21
|
+
vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify({ state: 'succeeded', startedAt: 't', finishedAt: 'u', url: 'https://app', sha: 'abc' }));
|
|
22
|
+
expect(readDeployStatus('/repo')).toMatchObject({ state: 'succeeded', url: 'https://app', sha: 'abc' });
|
|
23
|
+
});
|
|
24
|
+
it('returns null when the file is missing', () => {
|
|
25
|
+
vi.mocked(fs.existsSync).mockReturnValue(false);
|
|
26
|
+
expect(readDeployStatus('/repo')).toBeNull();
|
|
27
|
+
});
|
|
28
|
+
it('rejects a malformed state', () => {
|
|
29
|
+
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
30
|
+
vi.mocked(fs.readFileSync).mockReturnValue(JSON.stringify({ state: 'weird', startedAt: 't' }));
|
|
31
|
+
expect(readDeployStatus('/repo')).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
it('rejects invalid JSON', () => {
|
|
34
|
+
vi.mocked(fs.existsSync).mockReturnValue(true);
|
|
35
|
+
vi.mocked(fs.readFileSync).mockReturnValue('{ not json');
|
|
36
|
+
expect(readDeployStatus('/repo')).toBeNull();
|
|
37
|
+
});
|
|
38
|
+
it('deployLogPath points at .runwork/deploy-stdout.log', () => {
|
|
39
|
+
expect(deployLogPath('/repo')).toContain('deploy-stdout.log');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { buildDeployChildArgs, isInternalDeployChild, DEPLOY_DETACHED_CHILD_FLAG, } from '../detach.js';
|
|
3
|
+
describe('deploy/detach arg handling', () => {
|
|
4
|
+
describe('buildDeployChildArgs()', () => {
|
|
5
|
+
it('drops --detach and appends exactly one child marker', () => {
|
|
6
|
+
const out = buildDeployChildArgs(['node', '/p/runwork', 'deploy', '--detach']);
|
|
7
|
+
expect(out).toEqual(['/p/runwork', 'deploy', DEPLOY_DETACHED_CHILD_FLAG]);
|
|
8
|
+
});
|
|
9
|
+
it('preserves other flags like --json', () => {
|
|
10
|
+
const out = buildDeployChildArgs(['node', '/p/runwork', 'deploy', '--detach', '--json']);
|
|
11
|
+
expect(out).toEqual(['/p/runwork', 'deploy', '--json', DEPLOY_DETACHED_CHILD_FLAG]);
|
|
12
|
+
});
|
|
13
|
+
it('does not duplicate the marker when already present', () => {
|
|
14
|
+
const out = buildDeployChildArgs(['node', '/p/runwork', 'deploy', DEPLOY_DETACHED_CHILD_FLAG]);
|
|
15
|
+
expect(out.filter(a => a === DEPLOY_DETACHED_CHILD_FLAG)).toHaveLength(1);
|
|
16
|
+
});
|
|
17
|
+
it('skips a Bun-on-Windows virtual-FS argv[1]', () => {
|
|
18
|
+
const out = buildDeployChildArgs(['runwork.exe', 'B:/~BUN/root/runwork-windows-x64.exe', 'deploy', '--detach']);
|
|
19
|
+
expect(out).toEqual(['deploy', DEPLOY_DETACHED_CHILD_FLAG]);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('isInternalDeployChild()', () => {
|
|
23
|
+
it('detects the marker', () => {
|
|
24
|
+
expect(isInternalDeployChild(['node', 'runwork', 'deploy', DEPLOY_DETACHED_CHILD_FLAG])).toBe(true);
|
|
25
|
+
});
|
|
26
|
+
it('is false without the marker', () => {
|
|
27
|
+
expect(isInternalDeployChild(['node', 'runwork', 'deploy'])).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Record of the last deploy triggered from this machine, persisted to
|
|
3
|
+
* `.runwork/last-deploy.json`. `sha` is the commit that was pushed and
|
|
4
|
+
* deployed (local HEAD at deploy time), so comparing it to the current HEAD
|
|
5
|
+
* cheaply answers "is what I have locally what's deployed?" without scraping
|
|
6
|
+
* the production bundle (friction log #8).
|
|
7
|
+
*
|
|
8
|
+
* NOTE: this reflects deploys from THIS machine. A teammate deploying
|
|
9
|
+
* elsewhere won't update this file -- an authoritative production-build SHA
|
|
10
|
+
* would require the deploy API to return it (tracked as a follow-up).
|
|
11
|
+
*/
|
|
12
|
+
export interface DeployState {
|
|
13
|
+
sha: string;
|
|
14
|
+
deployedAt: string;
|
|
15
|
+
url: string;
|
|
16
|
+
}
|
|
17
|
+
export interface DeploySummary {
|
|
18
|
+
deployedSha: string | null;
|
|
19
|
+
deployedShortSha: string | null;
|
|
20
|
+
deployedAt: string | null;
|
|
21
|
+
url: string | null;
|
|
22
|
+
localSha: string | null;
|
|
23
|
+
localShortSha: string | null;
|
|
24
|
+
/** true/false when both SHAs are known; null when undeterminable. */
|
|
25
|
+
inSync: boolean | null;
|
|
26
|
+
}
|
|
27
|
+
/** Current git HEAD commit SHA, or null if not a repo / no commits. */
|
|
28
|
+
export declare function getHeadSha(cwd: string): string | null;
|
|
29
|
+
/** Persist the deploy state for `cwd`. Creates `.runwork/` if needed. */
|
|
30
|
+
export declare function writeDeployState(cwd: string, state: DeployState): void;
|
|
31
|
+
/** Read the recorded deploy state for `cwd`, or null if none/unreadable. */
|
|
32
|
+
export declare function readDeployState(cwd: string): DeployState | null;
|
|
33
|
+
/** Compare the local HEAD against a recorded deploy. Pure (no IO). */
|
|
34
|
+
export declare function summarizeDeploy(localSha: string | null, state: DeployState | null): DeploySummary;
|
|
35
|
+
/** Convenience: read git HEAD + recorded deploy and summarize the comparison. */
|
|
36
|
+
export declare function getDeploySummary(cwd: string): DeploySummary;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { execFileSync } from '../utils/subprocess.js';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
3
|
+
import { dirname, join } from 'path';
|
|
4
|
+
function deployStatePath(cwd) {
|
|
5
|
+
return join(cwd, '.runwork', 'last-deploy.json');
|
|
6
|
+
}
|
|
7
|
+
/** Current git HEAD commit SHA, or null if not a repo / no commits. */
|
|
8
|
+
export function getHeadSha(cwd) {
|
|
9
|
+
try {
|
|
10
|
+
return execFileSync('git', ['rev-parse', 'HEAD'], { cwd, stdio: ['ignore', 'pipe', 'ignore'] })
|
|
11
|
+
.toString()
|
|
12
|
+
.trim() || null;
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** Persist the deploy state for `cwd`. Creates `.runwork/` if needed. */
|
|
19
|
+
export function writeDeployState(cwd, state) {
|
|
20
|
+
const path = deployStatePath(cwd);
|
|
21
|
+
try {
|
|
22
|
+
if (!existsSync(dirname(path)))
|
|
23
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
24
|
+
writeFileSync(path, JSON.stringify(state, null, 2));
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// Best-effort: a failure to record state must never fail a deploy.
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Read the recorded deploy state for `cwd`, or null if none/unreadable. */
|
|
31
|
+
export function readDeployState(cwd) {
|
|
32
|
+
const path = deployStatePath(cwd);
|
|
33
|
+
if (!existsSync(path))
|
|
34
|
+
return null;
|
|
35
|
+
try {
|
|
36
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
37
|
+
if (typeof parsed.sha === 'string' && typeof parsed.deployedAt === 'string') {
|
|
38
|
+
return { sha: parsed.sha, deployedAt: parsed.deployedAt, url: parsed.url ?? '' };
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** Compare the local HEAD against a recorded deploy. Pure (no IO). */
|
|
47
|
+
export function summarizeDeploy(localSha, state) {
|
|
48
|
+
const deployedSha = state?.sha ?? null;
|
|
49
|
+
const inSync = deployedSha && localSha ? deployedSha === localSha : null;
|
|
50
|
+
return {
|
|
51
|
+
deployedSha,
|
|
52
|
+
deployedShortSha: deployedSha ? deployedSha.slice(0, 7) : null,
|
|
53
|
+
deployedAt: state?.deployedAt ?? null,
|
|
54
|
+
url: state?.url ?? null,
|
|
55
|
+
localSha,
|
|
56
|
+
localShortSha: localSha ? localSha.slice(0, 7) : null,
|
|
57
|
+
inSync,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Convenience: read git HEAD + recorded deploy and summarize the comparison. */
|
|
61
|
+
export function getDeploySummary(cwd) {
|
|
62
|
+
return summarizeDeploy(getHeadSha(cwd), readDeployState(cwd));
|
|
63
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Lifecycle state of a (possibly detached) deploy run. */
|
|
2
|
+
export type DeployRunState = 'in-progress' | 'succeeded' | 'failed';
|
|
3
|
+
/**
|
|
4
|
+
* Status of the most recent deploy started from this machine, persisted to
|
|
5
|
+
* `.runwork/deploy-status.json`. Lets `runwork deploy --status` report
|
|
6
|
+
* progress/outcome of a `--detach`ed deploy that outlived the shell that
|
|
7
|
+
* launched it (friction log #7).
|
|
8
|
+
*/
|
|
9
|
+
export interface DeployStatus {
|
|
10
|
+
state: DeployRunState;
|
|
11
|
+
startedAt: string;
|
|
12
|
+
finishedAt?: string;
|
|
13
|
+
url?: string;
|
|
14
|
+
sha?: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
pid?: number;
|
|
17
|
+
}
|
|
18
|
+
/** Path of the detached deploy's stdout log (mirrors dev's log convention). */
|
|
19
|
+
export declare function deployLogPath(cwd: string): string;
|
|
20
|
+
export declare function writeDeployStatus(cwd: string, status: DeployStatus): void;
|
|
21
|
+
export declare function readDeployStatus(cwd: string): DeployStatus | null;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
2
|
+
import { dirname, join } from 'path';
|
|
3
|
+
function statusPath(cwd) {
|
|
4
|
+
return join(cwd, '.runwork', 'deploy-status.json');
|
|
5
|
+
}
|
|
6
|
+
/** Path of the detached deploy's stdout log (mirrors dev's log convention). */
|
|
7
|
+
export function deployLogPath(cwd) {
|
|
8
|
+
return join(cwd, '.runwork', 'deploy-stdout.log');
|
|
9
|
+
}
|
|
10
|
+
export function writeDeployStatus(cwd, status) {
|
|
11
|
+
const path = statusPath(cwd);
|
|
12
|
+
try {
|
|
13
|
+
if (!existsSync(dirname(path)))
|
|
14
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
15
|
+
writeFileSync(path, JSON.stringify(status, null, 2));
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
// Best-effort: status recording must never fail a deploy.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function readDeployStatus(cwd) {
|
|
22
|
+
const path = statusPath(cwd);
|
|
23
|
+
if (!existsSync(path))
|
|
24
|
+
return null;
|
|
25
|
+
try {
|
|
26
|
+
const parsed = JSON.parse(readFileSync(path, 'utf-8'));
|
|
27
|
+
if ((parsed.state === 'in-progress' || parsed.state === 'succeeded' || parsed.state === 'failed') &&
|
|
28
|
+
typeof parsed.startedAt === 'string') {
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `runwork deploy --detach` orchestration.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `runwork dev --detach`, a deploy has no "ready" rendezvous to wait
|
|
5
|
+
* for -- it's fire-and-forget-then-poll. So the parent simply spawns a
|
|
6
|
+
* detached child (whose stdout/stderr go to `.runwork/deploy-*.log`), records
|
|
7
|
+
* an `in-progress` status, prints a poll hint, and exits. The child runs the
|
|
8
|
+
* real deploy and finalizes the status file to `succeeded`/`failed`.
|
|
9
|
+
*
|
|
10
|
+
* This exists so agents whose shell tool times out (~45s) can launch a deploy
|
|
11
|
+
* that survives, then poll `runwork deploy --status` (friction log #7).
|
|
12
|
+
*/
|
|
13
|
+
/** Hidden marker passed to the spawned child. Not shown in --help. */
|
|
14
|
+
export declare const DEPLOY_DETACHED_CHILD_FLAG = "--internal-detached-deploy-child";
|
|
15
|
+
/** Whether this invocation is the detached deploy child. */
|
|
16
|
+
export declare function isInternalDeployChild(argv?: readonly string[]): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Build the args for the spawned child so it re-runs the same deploy in the
|
|
19
|
+
* foreground (the child must NOT re-detach). Drops `--detach`, any stale
|
|
20
|
+
* marker, and a Bun-on-Windows virtual-FS path; re-adds exactly one marker.
|
|
21
|
+
* Pure for testability.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildDeployChildArgs(parentArgv: readonly string[]): string[];
|
|
24
|
+
export interface SpawnedDeployHandle {
|
|
25
|
+
pid: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Spawn the detached deploy child with stdout/stderr routed to
|
|
29
|
+
* `.runwork/deploy-{stdout,stderr}.log`. Cross-platform: uses
|
|
30
|
+
* `process.execPath` so it never depends on PATH (Bun-standalone-safe).
|
|
31
|
+
*/
|
|
32
|
+
export declare function spawnDetachedDeploy(childArgs: string[], cwd: string): SpawnedDeployHandle;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `runwork deploy --detach` orchestration.
|
|
3
|
+
*
|
|
4
|
+
* Unlike `runwork dev --detach`, a deploy has no "ready" rendezvous to wait
|
|
5
|
+
* for -- it's fire-and-forget-then-poll. So the parent simply spawns a
|
|
6
|
+
* detached child (whose stdout/stderr go to `.runwork/deploy-*.log`), records
|
|
7
|
+
* an `in-progress` status, prints a poll hint, and exits. The child runs the
|
|
8
|
+
* real deploy and finalizes the status file to `succeeded`/`failed`.
|
|
9
|
+
*
|
|
10
|
+
* This exists so agents whose shell tool times out (~45s) can launch a deploy
|
|
11
|
+
* that survives, then poll `runwork deploy --status` (friction log #7).
|
|
12
|
+
*/
|
|
13
|
+
import * as fs from 'fs';
|
|
14
|
+
import * as child_process from 'child_process';
|
|
15
|
+
import { join } from 'path';
|
|
16
|
+
import { looksLikeBunStandaloneArtifact } from '../dev/detach.js';
|
|
17
|
+
/** Hidden marker passed to the spawned child. Not shown in --help. */
|
|
18
|
+
export const DEPLOY_DETACHED_CHILD_FLAG = '--internal-detached-deploy-child';
|
|
19
|
+
/** Whether this invocation is the detached deploy child. */
|
|
20
|
+
export function isInternalDeployChild(argv = process.argv) {
|
|
21
|
+
return argv.includes(DEPLOY_DETACHED_CHILD_FLAG);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build the args for the spawned child so it re-runs the same deploy in the
|
|
25
|
+
* foreground (the child must NOT re-detach). Drops `--detach`, any stale
|
|
26
|
+
* marker, and a Bun-on-Windows virtual-FS path; re-adds exactly one marker.
|
|
27
|
+
* Pure for testability.
|
|
28
|
+
*/
|
|
29
|
+
export function buildDeployChildArgs(parentArgv) {
|
|
30
|
+
const rest = [];
|
|
31
|
+
for (let i = 1; i < parentArgv.length; i++) {
|
|
32
|
+
if (i === 1 && looksLikeBunStandaloneArtifact(parentArgv[i]))
|
|
33
|
+
continue;
|
|
34
|
+
rest.push(parentArgv[i]);
|
|
35
|
+
}
|
|
36
|
+
const filtered = rest.filter((a) => a !== DEPLOY_DETACHED_CHILD_FLAG && a !== '--detach');
|
|
37
|
+
return [...filtered, DEPLOY_DETACHED_CHILD_FLAG];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Spawn the detached deploy child with stdout/stderr routed to
|
|
41
|
+
* `.runwork/deploy-{stdout,stderr}.log`. Cross-platform: uses
|
|
42
|
+
* `process.execPath` so it never depends on PATH (Bun-standalone-safe).
|
|
43
|
+
*/
|
|
44
|
+
export function spawnDetachedDeploy(childArgs, cwd) {
|
|
45
|
+
const dir = join(cwd, '.runwork');
|
|
46
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
47
|
+
const stdoutFd = fs.openSync(join(dir, 'deploy-stdout.log'), 'w');
|
|
48
|
+
const stderrFd = fs.openSync(join(dir, 'deploy-stderr.log'), 'w');
|
|
49
|
+
try {
|
|
50
|
+
const proc = child_process.spawn(process.execPath, childArgs, {
|
|
51
|
+
cwd,
|
|
52
|
+
env: process.env,
|
|
53
|
+
detached: true,
|
|
54
|
+
stdio: ['ignore', stdoutFd, stderrFd],
|
|
55
|
+
windowsHide: true,
|
|
56
|
+
});
|
|
57
|
+
if (proc.pid !== undefined)
|
|
58
|
+
proc.unref();
|
|
59
|
+
return { pid: proc.pid ?? 0 };
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
try {
|
|
63
|
+
fs.closeSync(stdoutFd);
|
|
64
|
+
}
|
|
65
|
+
catch { /* ignore */ }
|
|
66
|
+
try {
|
|
67
|
+
fs.closeSync(stderrFd);
|
|
68
|
+
}
|
|
69
|
+
catch { /* ignore */ }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -368,6 +368,45 @@ describe('session lifecycle primitives', () => {
|
|
|
368
368
|
});
|
|
369
369
|
expect(file.noSync).toBe(true);
|
|
370
370
|
});
|
|
371
|
+
it('omits startupSync when not provided, includes it when provided', () => {
|
|
372
|
+
const base = {
|
|
373
|
+
pid: 1, sessionId: 's', appId: 'a', previewUrl: '', cliVersion: '0.0.0',
|
|
374
|
+
mode: 'detached', deps: { bootTime: () => 0 },
|
|
375
|
+
};
|
|
376
|
+
expect(buildSessionFile(base).startupSync).toBeUndefined();
|
|
377
|
+
const withSync = buildSessionFile({
|
|
378
|
+
...base,
|
|
379
|
+
startupSync: { syncStatus: 'sync-failed', syncFailed: true, staleCode: true },
|
|
380
|
+
});
|
|
381
|
+
expect(withSync.startupSync).toEqual({ syncStatus: 'sync-failed', syncFailed: true, staleCode: true });
|
|
382
|
+
});
|
|
383
|
+
});
|
|
384
|
+
describe('startupSync field back-compat', () => {
|
|
385
|
+
it('round-trips startupSync through write/read', () => {
|
|
386
|
+
const file = buildSessionFile({
|
|
387
|
+
pid: process.pid,
|
|
388
|
+
sessionId: 's',
|
|
389
|
+
appId: 'a',
|
|
390
|
+
previewUrl: 'https://x',
|
|
391
|
+
cliVersion: '0.0.0',
|
|
392
|
+
mode: 'detached',
|
|
393
|
+
startupSync: { syncStatus: 'sync-failed', syncFailed: true, staleCode: true },
|
|
394
|
+
deps: { bootTime: () => 0 },
|
|
395
|
+
});
|
|
396
|
+
writeSessionFile(appDir, file);
|
|
397
|
+
const read = readSessionFile(appDir);
|
|
398
|
+
expect(read?.startupSync).toEqual({ syncStatus: 'sync-failed', syncFailed: true, staleCode: true });
|
|
399
|
+
});
|
|
400
|
+
it('accepts an older session file with no startupSync field', () => {
|
|
401
|
+
const file = buildSessionFile({
|
|
402
|
+
pid: process.pid, sessionId: 's', appId: 'a', previewUrl: 'https://x',
|
|
403
|
+
cliVersion: '0.0.0', mode: 'detached', deps: { bootTime: () => 0 },
|
|
404
|
+
});
|
|
405
|
+
writeSessionFile(appDir, file);
|
|
406
|
+
const read = readSessionFile(appDir);
|
|
407
|
+
expect(read).not.toBeNull();
|
|
408
|
+
expect(read?.startupSync).toBeUndefined();
|
|
409
|
+
});
|
|
371
410
|
});
|
|
372
411
|
describe('noSync field back-compat', () => {
|
|
373
412
|
it('round-trips noSync through write/read', () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { buildStartupSyncSummary } from '../startup-sync.js';
|
|
3
|
+
describe('dev/startup-sync', () => {
|
|
4
|
+
it('reports no-sync mode as neither failed nor stale', () => {
|
|
5
|
+
expect(buildStartupSyncSummary({ noSync: true })).toEqual({
|
|
6
|
+
syncStatus: 'no-sync',
|
|
7
|
+
syncFailed: false,
|
|
8
|
+
staleCode: false,
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
it('flags a failed startup sync as stale (preview serving old code)', () => {
|
|
12
|
+
expect(buildStartupSyncSummary({ noSync: false, status: 'sync-failed' })).toEqual({
|
|
13
|
+
syncStatus: 'sync-failed',
|
|
14
|
+
syncFailed: true,
|
|
15
|
+
staleCode: true,
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
it.each(['synced', 'merged', 'skipped'])('treats a %s startup sync as live (not stale)', (status) => {
|
|
19
|
+
expect(buildStartupSyncSummary({ noSync: false, status })).toEqual({
|
|
20
|
+
syncStatus: status,
|
|
21
|
+
syncFailed: false,
|
|
22
|
+
staleCode: false,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
it('defaults to skipped when no status is provided', () => {
|
|
26
|
+
expect(buildStartupSyncSummary({ noSync: false })).toEqual({
|
|
27
|
+
syncStatus: 'skipped',
|
|
28
|
+
syncFailed: false,
|
|
29
|
+
staleCode: false,
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
package/dist/dev/session.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* See `docs/plans/2026-05-06-runwork-dev-lifecycle-design.md` for the full
|
|
15
15
|
* lifecycle contract.
|
|
16
16
|
*/
|
|
17
|
+
import type { StartupSyncSummary } from './startup-sync.js';
|
|
17
18
|
export declare const SESSION_FILE_SCHEMA_VERSION = 1;
|
|
18
19
|
/**
|
|
19
20
|
* Tolerance (ms) when comparing the stored bootTime to the currently
|
|
@@ -40,6 +41,13 @@ export interface SessionFile {
|
|
|
40
41
|
* treated as `false`.
|
|
41
42
|
*/
|
|
42
43
|
noSync?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Startup sync outcome, so a detached parent can relay stale-code warnings
|
|
46
|
+
* to the caller instead of those signals only living in the child's log
|
|
47
|
+
* (friction log #2). Optional for back-compat with session files that
|
|
48
|
+
* predate the field.
|
|
49
|
+
*/
|
|
50
|
+
startupSync?: StartupSyncSummary;
|
|
43
51
|
}
|
|
44
52
|
export type SessionStaleReason = 'malformed' | 'version-mismatch' | 'app-id-mismatch' | 'boot-time-mismatch' | 'pid-dead';
|
|
45
53
|
export type SessionState = {
|
|
@@ -161,6 +169,7 @@ export declare function buildSessionFile(input: {
|
|
|
161
169
|
cliVersion: string;
|
|
162
170
|
mode: SessionMode;
|
|
163
171
|
noSync?: boolean;
|
|
172
|
+
startupSync?: StartupSyncSummary;
|
|
164
173
|
startedAt?: number;
|
|
165
174
|
deps?: SessionDeps;
|
|
166
175
|
}): SessionFile;
|
package/dist/dev/session.js
CHANGED
|
@@ -113,7 +113,9 @@ function validateSessionFile(raw) {
|
|
|
113
113
|
typeof r.cliVersion === 'string' &&
|
|
114
114
|
(r.mode === 'foreground' || r.mode === 'detached') &&
|
|
115
115
|
// Optional for back-compat: v1 files lack the field. Accept absent or boolean.
|
|
116
|
-
(r.noSync === undefined || typeof r.noSync === 'boolean')
|
|
116
|
+
(r.noSync === undefined || typeof r.noSync === 'boolean') &&
|
|
117
|
+
// Optional: absent on older files; otherwise an object (shape from buildStartupSyncSummary).
|
|
118
|
+
(r.startupSync === undefined || (typeof r.startupSync === 'object' && r.startupSync !== null)));
|
|
117
119
|
}
|
|
118
120
|
/**
|
|
119
121
|
* Read and parse the session file. Returns `null` for a missing file or
|
|
@@ -251,5 +253,6 @@ export function buildSessionFile(input) {
|
|
|
251
253
|
cliVersion: input.cliVersion,
|
|
252
254
|
mode: input.mode,
|
|
253
255
|
noSync: input.noSync ?? false,
|
|
256
|
+
...(input.startupSync ? { startupSync: input.startupSync } : {}),
|
|
254
257
|
};
|
|
255
258
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SyncResult } from '../git/sync.js';
|
|
2
|
+
/**
|
|
3
|
+
* Summary of the startup sync outcome, surfaced on the `session_started`
|
|
4
|
+
* event so agents can tell whether the preview reflects their latest edits.
|
|
5
|
+
* `staleCode` is the key signal: when true, the initial sync failed and the
|
|
6
|
+
* preview is serving the last good state, NOT the current working tree
|
|
7
|
+
* (friction log #2).
|
|
8
|
+
*/
|
|
9
|
+
export interface StartupSyncSummary {
|
|
10
|
+
syncStatus: SyncResult['status'] | 'no-sync';
|
|
11
|
+
syncFailed: boolean;
|
|
12
|
+
staleCode: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Derive the startup sync summary from how dev started:
|
|
16
|
+
* - no-sync mode never mutates the tree, so it's neither failed nor stale.
|
|
17
|
+
* - otherwise it mirrors the syncWithRemote() status; a `sync-failed` status
|
|
18
|
+
* means the preview is stale.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildStartupSyncSummary(input: {
|
|
21
|
+
noSync: boolean;
|
|
22
|
+
status?: SyncResult['status'];
|
|
23
|
+
}): StartupSyncSummary;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Derive the startup sync summary from how dev started:
|
|
3
|
+
* - no-sync mode never mutates the tree, so it's neither failed nor stale.
|
|
4
|
+
* - otherwise it mirrors the syncWithRemote() status; a `sync-failed` status
|
|
5
|
+
* means the preview is stale.
|
|
6
|
+
*/
|
|
7
|
+
export function buildStartupSyncSummary(input) {
|
|
8
|
+
if (input.noSync) {
|
|
9
|
+
return { syncStatus: 'no-sync', syncFailed: false, staleCode: false };
|
|
10
|
+
}
|
|
11
|
+
const status = input.status ?? 'skipped';
|
|
12
|
+
const failed = status === 'sync-failed';
|
|
13
|
+
return { syncStatus: status, syncFailed: failed, staleCode: failed };
|
|
14
|
+
}
|
|
@@ -37,7 +37,7 @@ export const BUNDLED_TYPES = {
|
|
|
37
37
|
"core-types.d.ts": "/**\n * This file defines default types provided by the platform.\n * DO NOT EDIT THIS FILE. You can define your own types in `shared/types.ts` file.\n */\nexport interface ApiResponse<T = unknown> {\n success: boolean;\n data?: T;\n error?: string;\n}\n/**\n * Response from a Nango action or sync trigger\n */\nexport interface NangoActionResponse<T = unknown> {\n success: boolean;\n data?: T;\n error?: string;\n /** True if error is due to missing integration connection (user hasn't connected yet) */\n isConnectionError?: boolean;\n /** True if error is due to insufficient permissions/scopes (401/403 from external API) */\n isPermissionError?: boolean;\n /** HTTP status code from the external API (if available) */\n statusCode?: number;\n}\n/**\n * Nango proxy request options - used for direct API calls through Nango\n */\nexport interface NangoProxyOptions {\n method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n endpoint: string;\n providerConfigKey: string;\n data?: Record<string, unknown>;\n headers?: Record<string, string>;\n params?: Record<string, string>;\n retries?: number;\n}\n/**\n * Metadata for a stored file\n */\nexport interface FileMetadata {\n id: string;\n key: string;\n name: string;\n size: number;\n contentType: string;\n uploadedAt: number;\n uploadedBy?: string;\n customMetadata?: Record<string, string>;\n}\n/**\n * Options for uploading a file\n */\nexport interface UploadOptions {\n key?: string;\n name?: string;\n contentType?: string;\n uploadedBy?: string;\n customMetadata?: Record<string, string>;\n}\n/**\n * Options for downloading a file\n */\nexport interface DownloadOptions {\n range?: {\n offset?: number;\n length?: number;\n };\n}\n/**\n * Options for listing files\n */\nexport interface ListFilesOptions {\n prefix?: string;\n limit?: number;\n cursor?: string;\n delimiter?: string;\n}\n/**\n * Result of listing files\n */\nexport interface ListFilesResult {\n files: FileMetadata[];\n cursor?: string;\n truncated: boolean;\n}\n/**\n * Request for generating a presigned URL\n */\nexport interface PresignedUrlRequest {\n appId: string;\n key: string;\n action: 'read' | 'write';\n contentType?: string;\n expiresIn?: number;\n}\n/**\n * Response containing a presigned URL\n */\nexport interface PresignedUrlResponse {\n url: string;\n expiresAt: number;\n}\n",
|
|
38
38
|
"core-workflow-types.d.ts": "/**\n * Workflow Types - Shared types for native workflow engine\n * DO NOT MODIFY THIS FILE - You may break the project functionality\n */\nimport type { Env } from './core-utils';\nimport type { IntegrationClient } from './core-integrations';\nexport type NativeWorkflowStatus = 'pending' | 'running' | 'sleeping' | 'waiting' | 'paused' | 'completed' | 'failed' | 'cancelled' | 'timedOut';\nexport type NativeStepStatus = 'pending' | 'running' | 'completed' | 'failed' | 'skipped';\nexport type NativeStepType = 'do' | 'sleep' | 'sleepUntil' | 'waitEvent';\nexport interface NativeWorkflowError {\n code: string;\n message: string;\n stack?: string;\n retryable: boolean;\n}\nexport interface NativeStepAttempt {\n attemptNumber: number;\n startedAt: number;\n completedAt?: number;\n error?: NativeWorkflowError;\n}\nexport interface NativeStepExecution {\n id: string;\n name: string;\n type: NativeStepType;\n status: NativeStepStatus;\n input?: unknown;\n output?: unknown;\n error?: NativeWorkflowError;\n attempts: NativeStepAttempt[];\n maxRetries: number;\n startedAt?: number;\n completedAt?: number;\n timeoutMs?: number;\n sleepUntil?: number;\n eventType?: string;\n eventTimeoutAt?: number;\n}\nexport interface NativeWorkflowInstance {\n id: string;\n workflowName: string;\n status: NativeWorkflowStatus;\n input: unknown;\n output?: unknown;\n error?: NativeWorkflowError;\n createdAt: number;\n startedAt?: number;\n completedAt?: number;\n steps: NativeStepExecution[];\n currentStepId?: string;\n config: NativeWorkflowConfig;\n metadata?: Record<string, unknown>;\n}\nexport interface NativeWorkflowConfig {\n maxRetries: number;\n retryBackoffMs: number;\n stepTimeoutMs: number;\n workflowTimeoutMs: number;\n}\nexport declare const DEFAULT_WORKFLOW_CONFIG: NativeWorkflowConfig;\nexport interface NativeStepContext {\n /** Unique instance ID for this workflow execution */\n instanceId: string;\n /** Input passed when workflow was started */\n workflowInput: unknown;\n /** Results from previous steps */\n previousSteps: Record<string, {\n output: unknown;\n status: NativeStepStatus;\n }>;\n}\nexport interface WorkflowIndexEntry {\n instanceId: string;\n workflowName: string;\n status: NativeWorkflowStatus;\n createdAt: number;\n completedAt?: number;\n}\nexport interface ListWorkflowsOptions {\n workflowName?: string;\n status?: NativeWorkflowStatus;\n limit?: number;\n offset?: number;\n}\nexport interface ExecuteStepRequest {\n instanceId: string;\n stepId: string;\n stepName: string;\n workflowName: string;\n workflowInput: unknown;\n previousSteps: Record<string, {\n output: unknown;\n status: NativeStepStatus;\n }>;\n}\nexport interface ExecuteStepResponse {\n success: boolean;\n output?: unknown;\n error?: NativeWorkflowError;\n}\nexport interface PendingEvent {\n instanceId: string;\n stepId: string;\n eventType: string;\n waitingSince: number;\n timeoutAt?: number;\n}\nexport interface ReceivedEvent {\n type: string;\n payload: unknown;\n timestamp: number;\n}\n/**\n * Result returned by a workflow execution\n */\nexport interface WorkflowResult {\n success: boolean;\n [key: string]: unknown;\n}\n/**\n * Possible states of a workflow instance\n */\nexport type WorkflowStatus = 'queued' | 'running' | 'paused' | 'errored' | 'terminated' | 'complete' | 'waiting';\n/**\n * Information about a workflow instance\n */\nexport interface WorkflowInstanceInfo {\n id: string;\n workflowName: string;\n status: WorkflowStatus;\n params?: Record<string, unknown>;\n createdAt: number;\n startedAt?: number;\n completedAt?: number;\n error?: string;\n result?: WorkflowResult;\n}\n/**\n * Interface for WorkflowInstance DO stub methods\n * Used to type the DurableObjectStub without importing the class\n */\nexport interface WorkflowInstanceStub {\n create(workflowName: string, params: Record<string, unknown>, instanceId: string, config?: Partial<NativeWorkflowConfig>, metadata?: Record<string, unknown>): Promise<void>;\n getStatus(): Promise<NativeWorkflowInstance | null>;\n signal(eventType: string, payload: unknown): Promise<void>;\n pause(): Promise<void>;\n resume(): Promise<void>;\n cancel(): Promise<void>;\n}\n/**\n * Interface for WorkflowCoordinator DO stub methods\n * Used to type the DurableObjectStub without importing the class\n */\nexport interface WorkflowCoordinatorStub {\n create(workflowName: string, params: Record<string, unknown>, config?: Partial<NativeWorkflowConfig>, metadata?: Record<string, unknown>): Promise<string>;\n signal(instanceId: string, eventType: string, payload: unknown): Promise<void>;\n getInstanceInfo(instanceId: string): Promise<WorkflowInstanceInfo | null>;\n listInstances(options?: ListWorkflowsOptions): Promise<WorkflowInstanceInfo[]>;\n updateIndex(instanceId: string, workflowName: string, status: NativeWorkflowStatus): Promise<void>;\n pause(instanceId: string): Promise<void>;\n resume(instanceId: string): Promise<void>;\n cancel(instanceId: string): Promise<void>;\n}\n/**\n * Definition for a workflow handler\n */\nexport interface WorkflowDefinition<TParams = unknown, TResult = unknown> {\n /** Unique name for this workflow (kebab-case, e.g., \"order-fulfillment\") */\n name: string;\n /** Human-readable description of what this workflow does */\n description?: string;\n /** The workflow handler function */\n handler: (ctx: WorkflowContext<TParams>) => Promise<TResult>;\n /** Whether the workflow is enabled (default: true) */\n enabled?: boolean;\n}\n/**\n * Context passed to workflow handlers\n */\nexport interface WorkflowContext<TParams = unknown> {\n /** Environment bindings */\n env: Env;\n /** Unique instance ID for this workflow execution */\n instanceId: string;\n /** Parameters passed when workflow was started */\n params: TParams;\n /** Step utilities for durable execution */\n step: WorkflowStepUtilities;\n /** Integration client for external service calls */\n integrations: IntegrationClient;\n /** Logger for structured workflow logging */\n logger: WorkflowLogger;\n}\n/**\n * Step utilities for durable workflow execution\n */\nexport interface WorkflowStepUtilities {\n /** Execute a step with automatic retry and persistence */\n do<T>(name: string, fn: () => Promise<T>): Promise<T>;\n do<T>(name: string, options: StepOptions, fn: () => Promise<T>): Promise<T>;\n /** Sleep for a duration (e.g., '5 minutes', '1 hour', '24 hours') */\n sleep(name: string, duration: string): Promise<void>;\n /** Sleep until a specific timestamp */\n sleepUntil(name: string, timestamp: Date): Promise<void>;\n /** Wait for an external event */\n waitForEvent<T = unknown>(name: string, options?: WaitEventOptions): Promise<T>;\n}\n/**\n * Options for step execution\n */\nexport interface StepOptions {\n retries?: {\n limit: number;\n delay: string;\n backoff?: 'constant' | 'linear' | 'exponential';\n };\n timeout?: string;\n}\n/**\n * Options for waitForEvent\n */\nexport interface WaitEventOptions {\n type?: string;\n timeout?: string;\n}\n/**\n * Logger interface for workflow execution\n */\nexport interface WorkflowLogger {\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n error(message: string, data?: Record<string, unknown>): void;\n}\n/**\n * State of a registered workflow\n */\nexport interface WorkflowState {\n name: string;\n description?: string;\n enabled: boolean;\n activeInstances: number;\n totalRuns: number;\n lastRun: number | null;\n lastError?: string;\n}\n/**\n * Response from workflow status API\n */\nexport interface WorkflowStatusResponse {\n workflows: WorkflowState[];\n}\n",
|
|
39
39
|
"workflows.d.ts": "import type { WorkflowDefinition } from './core-workflow-types';\n/**\n * APP_WORKFLOWS - runtime accessor for registered workflow definitions.\n * Used by internal dynamic imports in core-workflow-cloudflare and core-workflow-instance.\n * This is a getter-backed constant so it always reflects the current registry state.\n */\nexport declare const APP_WORKFLOWS: WorkflowDefinition[];\nexport { triggerWorkflow, sendWorkflowEvent, getWorkflowStatus, workflowRoutes, } from './core-workflows';\nexport type { WorkflowResult, WorkflowStatus, WorkflowInstanceInfo, WorkflowDefinition, WorkflowContext, WorkflowStepUtilities, StepOptions, WaitEventOptions, WorkflowLogger, WorkflowState, WorkflowStatusResponse, } from './core-workflows';\nexport type { NativeWorkflowStatus, NativeStepStatus, NativeStepType, NativeWorkflowError, NativeStepAttempt, NativeStepExecution, NativeWorkflowInstance, NativeWorkflowConfig, NativeStepContext, WorkflowIndexEntry, ListWorkflowsOptions, ExecuteStepRequest, ExecuteStepResponse, PendingEvent, ReceivedEvent, WorkflowInstanceStub, WorkflowCoordinatorStub, } from './core-workflow-types';\nexport { DEFAULT_WORKFLOW_CONFIG } from './core-workflow-types';\nexport { WORKFLOW_INFRA_MODE } from './core-workflow-config';\nexport { WorkflowInstanceDO } from './core-workflow-instance';\nexport { WorkflowCoordinator } from './core-workflow-coordinator';\nexport { WorkflowPausedError, isWorkflowControlSignal } from './core-workflow-instance';\n",
|
|
40
|
-
"core-endpoints.d.ts": "/**\n * Core Public Endpoints Framework\n * DO NOT MODIFY THIS FILE - You may break the project functionality\n *\n * This module provides the infrastructure for exposing public API endpoints\n * that external systems can consume with API key authentication or public access.\n */\nimport { type Env } from './core-utils';\nimport { z } from 'zod';\nimport type { Hono } from 'hono';\ntype ZodSchema = z.ZodType<any, any, any>;\n/**\n * Authentication
|
|
40
|
+
"core-endpoints.d.ts": "/**\n * Core Public Endpoints Framework\n * DO NOT MODIFY THIS FILE - You may break the project functionality\n *\n * This module provides the infrastructure for exposing public API endpoints\n * that external systems can consume with API key authentication or public access.\n */\nimport { type Env } from './core-utils';\nimport { z } from 'zod';\nimport type { Hono } from 'hono';\ntype ZodSchema = z.ZodType<any, any, any>;\n/**\n * Authentication requirement declared by an endpoint definition.\n */\nexport type EndpointAuthType = 'apiKey' | 'public';\n/**\n * Caller principal type resolved by the platform and passed via the\n * `X-Public-Endpoint-Auth-Type` header. `user` and `workspace_key` are\n * authenticated principals the platform has already authorized; `api_key`\n * additionally carries a validated key id; `none` is unauthenticated.\n */\nexport type EndpointPrincipalType = 'none' | 'api_key' | 'workspace_key' | 'user';\n/**\n * HTTP methods supported by endpoints\n */\nexport type EndpointMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';\n/**\n * Schema definition for endpoint validation\n */\nexport interface EndpointSchema<TQuery = unknown, TBody = unknown, TResponse = unknown> {\n /** Query parameters schema */\n query?: ZodSchema;\n /** Request body schema (for POST/PUT/PATCH) */\n body?: ZodSchema;\n /** Response schema for documentation */\n response?: ZodSchema;\n}\n/**\n * Context provided to endpoint handlers\n */\nexport interface EndpointContext<TQuery = Record<string, unknown>, TBody = unknown> {\n /** Environment bindings */\n env: Env;\n /** Original request object */\n request: Request;\n /** Validated query parameters */\n query: TQuery;\n /** Validated request body (null for GET/DELETE) */\n body: TBody | null;\n /** Path parameters extracted from URL */\n params: Record<string, string>;\n /** Authentication information */\n auth: EndpointAuthInfo;\n /** Request headers */\n headers: Headers;\n /** Logger for endpoint operations */\n logger: EndpointLogger;\n}\n/**\n * Authentication information passed to handlers\n */\nexport interface EndpointAuthInfo {\n /** Authentication requirement declared by the endpoint */\n type: EndpointAuthType;\n /** Resolved caller principal type (api_key, workspace_key, user, none) */\n principalType?: EndpointPrincipalType;\n /** API key ID (if authenticated with an API key) */\n apiKeyId?: string;\n /** User ID (if authenticated as a workspace member) */\n userId?: string;\n /** Scopes granted to the API key */\n scopes?: string[];\n /** Whether request is authenticated */\n authenticated: boolean;\n}\n/**\n * Logger for endpoint operations\n */\nexport interface EndpointLogger {\n info(message: string, data?: Record<string, unknown>): void;\n warn(message: string, data?: Record<string, unknown>): void;\n error(message: string, data?: Record<string, unknown>): void;\n}\n/**\n * Metadata for endpoint documentation\n */\nexport interface EndpointMeta {\n /** Human-readable description */\n description?: string;\n /** Tags for grouping in documentation */\n tags?: string[];\n /** Deprecated flag */\n deprecated?: boolean;\n /** Deprecation message */\n deprecationMessage?: string;\n}\n/**\n * Public endpoint definition\n */\nexport interface EndpointDefinition<TQuery = Record<string, unknown>, TBody = unknown, TResponse = unknown> {\n /** URL path (e.g., '/v1/todos', '/users/:id') */\n path: string;\n /** HTTP method */\n method: EndpointMethod;\n /** Authentication requirement */\n auth: EndpointAuthType;\n /** Validation schemas */\n schema?: EndpointSchema<TQuery, TBody, TResponse>;\n /** Request handler */\n handler: EndpointHandler<TQuery, TBody, TResponse>;\n /** Endpoint metadata for documentation */\n meta?: EndpointMeta;\n}\n/**\n * Endpoint handler function type\n */\nexport type EndpointHandler<TQuery = Record<string, unknown>, TBody = unknown, TResponse = unknown> = (ctx: EndpointContext<TQuery, TBody>) => Promise<TResponse>;\n/** Type guard to distinguish EndpointDefinition from function-based route registrars */\nexport declare function isEndpointDefinition(entry: unknown): entry is EndpointDefinition;\n/**\n * Internal: Parsed endpoint info from request headers\n */\nexport interface ParsedEndpointRequest {\n endpointId: string;\n appId: string;\n authType: EndpointPrincipalType;\n apiKeyId?: string;\n userId?: string;\n scopes?: string[];\n}\n/**\n * Create a JSON response\n */\nexport declare function jsonResponse<T>(data: T, status?: number): Response;\n/**\n * Create an error response\n */\nexport declare function errorResponse(message: string, status?: number, code?: string): Response;\n/**\n * Convert Zod schema to JSON Schema for documentation\n * This is a simplified conversion that handles common cases\n */\nexport declare function zodToJsonSchema(schema: ZodSchema | undefined): Record<string, unknown> | undefined;\n/**\n * Endpoint router that matches requests to handlers\n */\nexport declare class EndpointRouter {\n private endpoints;\n /**\n * Register endpoints\n */\n register(endpoints: EndpointDefinition<unknown, unknown, unknown>[]): void;\n /**\n * Find endpoint matching the request\n */\n findEndpoint(method: string, path: string): {\n endpoint: EndpointDefinition<unknown, unknown, unknown>;\n params: Record<string, string>;\n } | null;\n /**\n * Get all registered endpoints for documentation\n */\n getAllEndpoints(): EndpointDefinition<unknown, unknown, unknown>[];\n}\n/**\n * Mount an EndpointDefinition as a native Hono route.\n *\n * Registers the endpoint at its natural path using the correct HTTP method,\n * with Zod validation for query/body schemas and full EndpointContext support.\n * This allows EndpointDefinition entries in APP_ROUTES to work as first-class\n * Hono routes with middleware, streaming, and WebSocket support intact.\n */\nexport declare function mountEndpointAsHonoRoute(app: Hono<{\n Bindings: Env;\n}>, endpoint: EndpointDefinition): void;\n/**\n * Handle an incoming public endpoint request.\n * Called by the platform when routing requests to the app.\n */\nexport declare function handleEndpointRequest<TQuery = unknown, TBody = unknown, TResponse = unknown>(request: Request, env: Env, endpoints: EndpointDefinition<TQuery, TBody, TResponse>[]): Promise<Response>;\n/**\n * Custom error for endpoint handlers\n * Use this to return specific HTTP status codes\n */\nexport declare class EndpointError extends Error {\n status: number;\n code?: string | undefined;\n constructor(message: string, status?: number, code?: string | undefined);\n static badRequest(message: string): EndpointError;\n static unauthorized(message?: string): EndpointError;\n static forbidden(message?: string): EndpointError;\n static notFound(message?: string): EndpointError;\n static conflict(message: string): EndpointError;\n}\n/**\n * Convert endpoint definition to registration data for workspace\n */\nexport declare function endpointToRegistration<TQuery = unknown, TBody = unknown, TResponse = unknown>(endpoint: EndpointDefinition<TQuery, TBody, TResponse>): {\n path: string;\n method: EndpointMethod;\n auth: EndpointAuthType;\n description?: string;\n tags?: string[];\n schema?: {\n query?: Record<string, unknown>;\n body?: Record<string, unknown>;\n response?: Record<string, unknown>;\n };\n};\nexport {};\n",
|
|
41
41
|
"core-utils.d.ts": "/**\n * Core Utilities\n * DO NOT MODIFY THIS FILE - You may break the project functionality\n *\n * This module provides:\n * - Env type: Environment bindings for Cloudflare Workers\n * - API helpers: Response utilities for Hono routes\n *\n * Entity System: See core-entities.ts\n * Workspace Context: See core-workspace.ts\n * Scheduler: See core-scheduler.ts\n */\nimport type { Context } from 'hono';\nimport type { EntityDO } from './core-entity-do';\nimport type { SchedulerDO } from './core-scheduler';\nimport type { BaseAgent } from './core-base-agent';\n/**\n * Environment bindings for Cloudflare Workers\n */\nexport interface Env {\n EntityDO: DurableObjectNamespace<EntityDO>;\n SchedulerDO: DurableObjectNamespace<SchedulerDO>;\n BaseAgent?: DurableObjectNamespace<BaseAgent>;\n WorkspaceObject?: DurableObjectNamespace;\n WorkflowInstance: DurableObjectNamespace;\n WorkflowCoordinator: DurableObjectNamespace;\n BUCKET?: R2Bucket;\n WORKSPACE_ID?: string;\n APP_ID?: string;\n APP_NAME?: string;\n WORKSPACE_API_URL?: string;\n WORKSPACE_API_BASE_URL?: string;\n WORKSPACE_API_KEY?: string;\n DEPLOYMENT_MODE?: 'preview' | 'production';\n VITE_DEPLOYMENT_MODE?: 'preview' | 'production';\n RUNWORK_AI_PROXY_URL?: string;\n RUNWORK_PROXY_TOKEN?: string;\n INTEGRATIONS_PROXY_URL?: string;\n ALLOWED_ORIGINS?: string;\n}\n/**\n * Return a successful JSON response.\n * Returns the data directly as the response body with 200 status.\n */\nexport declare const ok: <T>(c: Context, data: T) => Response & import(\"hono\").TypedResponse<{\n [x: string]: import(\"hono/utils/types\").JSONValue;\n}, import(\"hono/utils/http-status\").ContentfulStatusCode, \"json\">;\n/**\n * Return a 400 Bad Request response\n * Automatically logs the error for debugging in production logs\n */\nexport declare const bad: (c: Context, error: string) => Response & import(\"hono\").TypedResponse<{\n error: string;\n}, 400, \"json\">;\n/**\n * Return a 404 Not Found response\n * Automatically logs the error for debugging in production logs\n */\nexport declare const notFound: (c: Context, error?: string) => Response & import(\"hono\").TypedResponse<{\n error: string;\n}, 404, \"json\">;\n/**\n * Type guard for non-empty strings\n */\nexport declare const isStr: (s: unknown) => s is string;\n/**\n * Safely clone a value for Durable Object storage.\n * Strips non-serializable references (R2Bucket, D1Database, DO stubs, etc.)\n * that would cause structured clone to fail in ctx.storage.put().\n */\nexport declare function safeClone<T>(value: T, fallback?: T): T;\nexport declare function platformFetch(env: Env, url: string | URL, init?: RequestInit): Promise<Response>;\n/**\n * Workspace API fetch - routes workspace service requests through WorkspaceObject DO\n * for production WfP workers, avoiding 522 recursive invocation errors.\n *\n * Workers for Platforms workers cannot HTTP-fetch back to their dispatcher domain.\n * This routes through the WorkspaceObject DO binding in production, and falls back\n * to standard HTTP with x-workspace-key auth header in preview/sandbox.\n *\n * @param env - Environment with workspace bindings\n * @param path - Workspace API sub-path (e.g., '/ingest-event')\n * @param init - Standard fetch options\n */\nexport declare function workspaceApiFetch(env: Pick<Env, 'WORKSPACE_API_URL' | 'WORKSPACE_API_KEY' | 'WORKSPACE_ID' | 'DEPLOYMENT_MODE' | 'WorkspaceObject'>, path: string, init?: RequestInit): Promise<Response>;\n",
|
|
42
42
|
"vite.d.ts": "import { defineConfig, type Plugin } from \"vite\";\nexport interface RunworkPluginOptions {\n /**\n * Override the detected mode. By default, the plugin detects sandbox mode\n * when DEPLOYMENT_MODE or WORKSPACE_ID environment variables are present.\n */\n mode?: \"sandbox\" | \"local\";\n /**\n * Root directory of the project. Defaults to process.cwd().\n */\n root?: string;\n /**\n * Path aliases to configure. Defaults to { \"@\": \"./src\", \"@shared\": \"./shared\" }.\n */\n aliases?: Record<string, string>;\n /**\n * Whether to use JSON logging (pino) in sandbox mode.\n * Defaults to true when VITE_LOGGER_TYPE=json.\n */\n jsonLogger?: boolean;\n}\nexport declare function runwork(options?: RunworkPluginOptions): ReturnType<typeof defineConfig>;\nexport type { Plugin };\n",
|
|
43
43
|
"core-channels.d.ts": "/**\n * Core Channels\n * DO NOT MODIFY THIS FILE - You may break the project functionality\n *\n * This module provides:\n * - postToChannel(): Post rich markdown messages to workspace channels\n *\n * Channels are auto-created if they don't exist, with automatic app event filtering.\n * When running outside a workspace (standalone mode), calls are silently skipped.\n */\nexport interface PostToChannelParams {\n /** Channel name (e.g., \"#inventory-alerts\" or \"inventory-alerts\"). Auto-normalized: # stripped, lowercased, trimmed. */\n channel: string;\n /** Markdown message content */\n content: string;\n /** Optional structured metadata attached to the message */\n metadata?: Record<string, unknown>;\n}\ninterface ChannelEnv {\n WORKSPACE_API_URL?: string;\n WORKSPACE_API_KEY?: string;\n WORKSPACE_ID?: string;\n APP_ID?: string;\n APP_NAME?: string;\n DEPLOYMENT_MODE?: 'preview' | 'production';\n WorkspaceObject?: DurableObjectNamespace;\n}\n/**\n * Any context that supports waitUntil - compatible with both\n * ExecutionContext (Hono route handlers) and DurableObjectState (DOs).\n */\ntype WaitUntilContext = Pick<ExecutionContext, 'waitUntil'>;\n/**\n * Post a rich markdown message to a workspace channel.\n * Fire-and-forget: uses ctx.waitUntil so it doesn't block the response.\n * Silently skips if workspace env vars are not configured (standalone mode).\n *\n * Channels are auto-created on first use. The channel will automatically\n * include this app's system events via filter projection.\n */\nexport declare function postToChannel(ctx: WaitUntilContext, env: ChannelEnv, params: PostToChannelParams): void;\nexport {};\n",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.15.0";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Auto-generated by scripts/embed-types.ts -- do not edit
|
|
2
|
-
export const VERSION = "0.
|
|
2
|
+
export const VERSION = "0.15.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|