@deepseek-ai/dsh-workflow 0.0.1-rc.1 → 0.0.1-rc.2
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/README.i18n.yaml +2 -2
- package/README.md +3 -1
- package/README.zh.md +2 -0
- package/lib/types/index.d.ts +4 -2
- package/lib/types/index.js +80 -0
- package/lib/types/invariant.js +118 -0
- package/lib/types/runtime-types.d.ts +45 -0
- package/lib/types/runtime-types.js +9 -0
- package/lib/types/types.d.ts +2 -50
- package/lib/types/types.js +16 -0
- package/package.json +17 -12
package/README.i18n.yaml
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
# side as of the last confirmed-consistent state. Both languages carry equal authority;
|
|
3
3
|
# after editing either side, bring the other along and re-record with:
|
|
4
4
|
# pnpm run verify-translation-pairing --write packages/workflow/workflow/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: af61308b99bffb290fe2a11cb6c3ccd228cbfaf6
|
|
6
|
+
README.zh.md: 6d85c3b7e847b8c6176d4c1938805c22c543678b
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ The workflow seam (`ctx.workflows`) executes a model-written orchestration scrip
|
|
|
6
6
|
|
|
7
7
|
`@deepseek-ai/dsh-workflow-workerthread` is the current engine and `@deepseek-ai/dsh-tool-workflow` is the model-facing consumer. A future process or sandbox engine can replace the implementation without changing the tool.
|
|
8
8
|
|
|
9
|
+
The package root is the Host face. The browser-safe `@deepseek-ai/dsh-workflow/types` subpath contains run identities, metadata, results, and observe-only lifecycle payloads without importing `Agent`, Cordis services, or Host context declarations; Host-only `WorkflowStartRequest` and `WorkflowRun` live behind the package root.
|
|
10
|
+
|
|
9
11
|
## Service and run contract
|
|
10
12
|
|
|
11
13
|
`WorkflowService.start(request): WorkflowRun` validates enough synchronously to reject a malformed meta block, unparseable script, unavailable provider route, or unsupported per-run limit before a run exists. Once returned, `WorkflowRun.result` never rejects: execution failures resolve with `stopReason: 'error'`, and cancellation resolves with `cancelled` within the engine's bounded grace.
|
|
@@ -56,4 +58,4 @@ No direct invalidation; the named consumer owns any request-prefix changes.
|
|
|
56
58
|
- **No token-budget vocabulary** — engines cap concurrency, items, and children, but neither the request nor result accounts for model tokens across children.
|
|
57
59
|
- **Runs are holder-owned, not service-tracked** — unloading the engine does not discover independent live handles; every consumer must dispose the run it started.
|
|
58
60
|
|
|
59
|
-
See the [dynamic-workflows Agent Note](../../../.agents/notes/implemented/feature/2026-07-05-dynamic-workflows.md) for the deferred workflow
|
|
61
|
+
See the [dynamic-workflows Agent Note](../../../.agents/notes/implemented/feature/2026-07-05-dynamic-workflows.md) for the deferred workflow API.
|
package/README.zh.md
CHANGED
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
`@deepseek-ai/dsh-workflow-workerthread` 是当前引擎,`@deepseek-ai/dsh-tool-workflow` 是面向模型的消费方。未来的进程或沙箱引擎可以替换实现,而无需更改工具。
|
|
8
8
|
|
|
9
|
+
包根是 Host face。浏览器安全的 `@deepseek-ai/dsh-workflow/types` 子路径包含运行身份、元数据、结果和仅供观察的生命周期 payload,不导入 `Agent`、Cordis service 或 Host Context 声明;Host 专用的 `WorkflowStartRequest` 与 `WorkflowRun` 只从包根提供。
|
|
10
|
+
|
|
9
11
|
## 服务与运行约定
|
|
10
12
|
|
|
11
13
|
`WorkflowService.start(request): WorkflowRun` 会同步完成足够多的校验,在运行创建前拒绝格式错误的 meta 块、无法解析的脚本、不可用的提供方路由或不受支持的单次运行限制。返回后,`WorkflowRun.result` 绝不拒绝:执行失败以 `stopReason: 'error'` 兑现,取消则在引擎有限的宽限时间内以 `cancelled` 兑现。
|
package/lib/types/index.d.ts
CHANGED
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Context, Service } from '@deepseek-ai/cordis';
|
|
7
7
|
import { HarnessError } from '@deepseek-ai/dsh-llm';
|
|
8
|
-
import type { WorkflowAgentEndInfo, WorkflowAgentInfo, WorkflowResultInfo,
|
|
8
|
+
import type { WorkflowAgentEndInfo, WorkflowAgentInfo, WorkflowResultInfo, WorkflowRunInfo } from './types.ts';
|
|
9
|
+
import type { WorkflowRun, WorkflowStartRequest } from './runtime-types.ts';
|
|
9
10
|
export { WorkflowRunId } from './types.ts';
|
|
10
|
-
export type { WorkflowAgentEndInfo, WorkflowAgentInfo, WorkflowAgentOutcome, WorkflowMeta, WorkflowPhase, WorkflowResult, WorkflowResultInfo,
|
|
11
|
+
export type { WorkflowAgentEndInfo, WorkflowAgentInfo, WorkflowAgentOutcome, WorkflowMeta, WorkflowPhase, WorkflowResult, WorkflowResultInfo, WorkflowRunInfo, WorkflowStopReason, } from './types.ts';
|
|
12
|
+
export type { WorkflowRun, WorkflowStartRequest } from './runtime-types.ts';
|
|
11
13
|
declare module '@deepseek-ai/cordis' {
|
|
12
14
|
interface Context {
|
|
13
15
|
workflows: WorkflowService;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Definition for the workflow capability seam. Service providers execute orchestration scripts;
|
|
3
|
+
* observe-only lifecycle events never expose run control.
|
|
4
|
+
* @module @deepseek-ai/dsh-workflow
|
|
5
|
+
*/
|
|
6
|
+
import { Service } from '@deepseek-ai/cordis';
|
|
7
|
+
import { HarnessError } from '@deepseek-ai/dsh-llm';
|
|
8
|
+
export { WorkflowRunId } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Typed error for workflow-seam failures. Extends {@link HarnessError}, so the
|
|
11
|
+
* `code` is machine-routable taxonomy. `fatal` drives the combinator
|
|
12
|
+
* discipline: `parallel()`/`pipeline()` re-throw a fatal error (a typo'd
|
|
13
|
+
* option or a tripped cap must kill the script loudly), and reserve the
|
|
14
|
+
* per-item `null` for child-run failures and ordinary in-stage script errors.
|
|
15
|
+
* Every {@link WorkflowErrorCode} is fatal; the flag exists so the
|
|
16
|
+
* distinction is explicit at every catch site rather than implied.
|
|
17
|
+
*/
|
|
18
|
+
export class WorkflowError extends HarnessError {
|
|
19
|
+
/** Whether combinators must propagate this error instead of nulling the item. */
|
|
20
|
+
fatal;
|
|
21
|
+
constructor(message, code, options) {
|
|
22
|
+
super(message, code, options);
|
|
23
|
+
this.name = 'WorkflowError';
|
|
24
|
+
this.fatal = options?.fatal ?? true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether combinators must re-throw `error` instead of mapping the item to `null`.
|
|
29
|
+
* @param error - any thrown value; fatality is host `instanceof` (unforgeable from a script realm).
|
|
30
|
+
* @returns true iff `error` is a {@link WorkflowError} whose `fatal` flag is set.
|
|
31
|
+
*/
|
|
32
|
+
export function isFatalWorkflowError(error) {
|
|
33
|
+
return error instanceof WorkflowError && error.fatal;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Workflow Service Definition contract. Invalid requests throw before publication; a live
|
|
37
|
+
* run is holder-owned, its result never rejects, cancellation and disposal are
|
|
38
|
+
* bounded, and disposal waits for child cleanup within that bound. Lifecycle
|
|
39
|
+
* listener failures are contained, and `workflow/end` fires exactly once as the
|
|
40
|
+
* result settles.
|
|
41
|
+
*/
|
|
42
|
+
export class WorkflowService extends Service {
|
|
43
|
+
constructor(ctx) {
|
|
44
|
+
super(ctx, 'workflows');
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Emit a lifecycle event while containing and logging each listener failure.
|
|
48
|
+
* @param name - the `workflow/*` event to dispatch.
|
|
49
|
+
* @param args - the event's payload, matching its declared signature.
|
|
50
|
+
*/
|
|
51
|
+
emitWorkflowEvent(name, ...args) {
|
|
52
|
+
for (const callback of this.ctx.events.dispatch('emit', [name, ...args])) {
|
|
53
|
+
try {
|
|
54
|
+
const returned = callback(...args);
|
|
55
|
+
void Promise.resolve(returned).catch((error) => {
|
|
56
|
+
this.ctx.logger.warn(`workflow: ${name} listener rejected: ${renderListenerError(error)}`);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
this.ctx.logger.warn(`workflow: ${name} listener threw: ${renderListenerError(error)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Render any thrown value without violating listener containment.
|
|
67
|
+
* @param error - any thrown value.
|
|
68
|
+
* @returns `String(error)`, or a fixed label when even coercion throws.
|
|
69
|
+
*/
|
|
70
|
+
function renderListenerError(error) {
|
|
71
|
+
try {
|
|
72
|
+
return String(error);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// String coercion itself may throw.
|
|
76
|
+
return '[unrenderable thrown value]';
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export default WorkflowService;
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** Package-owned workflow lifecycle invariants. @module @deepseek-ai/dsh-workflow/invariant */
|
|
2
|
+
const PACKAGE_NAME = '@deepseek-ai/dsh-workflow';
|
|
3
|
+
/** Cordis companion plugin name. */
|
|
4
|
+
export const name = 'workflow-invariant';
|
|
5
|
+
/** Service required before the companion can reserve package ownership. */
|
|
6
|
+
export const inject = ['invariants'];
|
|
7
|
+
/** Require every event for a run to retain its validated identity snapshot. */
|
|
8
|
+
function traceFor(traces, info, fail) {
|
|
9
|
+
const trace = traces.get(info.id);
|
|
10
|
+
if (trace === undefined)
|
|
11
|
+
fail(`workflow event has no matching workflow/start for run ${JSON.stringify(info.id)}`);
|
|
12
|
+
if (trace.meta !== JSON.stringify(info.meta)) {
|
|
13
|
+
fail(`workflow event meta diverges from workflow/start for run ${JSON.stringify(info.id)}`);
|
|
14
|
+
}
|
|
15
|
+
return trace;
|
|
16
|
+
}
|
|
17
|
+
/** Assert the immutable identity fields shared by an agent pair. */
|
|
18
|
+
function validateAgentEnd(start, end, fail) {
|
|
19
|
+
if (start.label !== end.label || start.phase !== end.phase || start.childId !== end.childId) {
|
|
20
|
+
fail(`workflow/agent-end identity diverges from workflow/agent-start for seq ${end.seq}`);
|
|
21
|
+
}
|
|
22
|
+
const outcome = end.outcome;
|
|
23
|
+
if (outcome !== 'completed' && outcome !== 'failed' && outcome !== 'cancelled') {
|
|
24
|
+
fail(`workflow/agent-end carries unknown outcome ${JSON.stringify(outcome)}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Validate a terminal result against the accumulated run trace. */
|
|
28
|
+
function validateWorkflowEnd(trace, result, fail) {
|
|
29
|
+
if (trace.agents.size > 0)
|
|
30
|
+
fail(`workflow/end has ${trace.agents.size} agent call(s) without workflow/agent-end`);
|
|
31
|
+
if (!Number.isSafeInteger(result.agentsStarted) || result.agentsStarted < trace.starts) {
|
|
32
|
+
fail('workflow/end agentsStarted must be a safe integer covering every observed agent start');
|
|
33
|
+
}
|
|
34
|
+
if (result.stopReason === 'completed' ? result.error !== undefined : typeof result.error !== 'string') {
|
|
35
|
+
fail('workflow/end error must be absent exactly for completed runs');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Install workflow start/end and child-call pairing checks. */
|
|
39
|
+
const install = (ctx, fail) => {
|
|
40
|
+
const traces = new Map();
|
|
41
|
+
const stagedStarts = new WeakSet();
|
|
42
|
+
const stagedAgentStarts = new WeakSet();
|
|
43
|
+
const stagedAgentEnds = new WeakSet();
|
|
44
|
+
const stagedEnds = new WeakSet();
|
|
45
|
+
ctx.on('internal/dispatch', (_mode, eventName, args) => {
|
|
46
|
+
if (eventName === 'workflow/start') {
|
|
47
|
+
const info = args[0];
|
|
48
|
+
if (String(info.id).length === 0 || info.meta.name.length === 0 || info.meta.description.length === 0) {
|
|
49
|
+
fail('workflow/start id, meta.name, and meta.description must be non-empty');
|
|
50
|
+
}
|
|
51
|
+
if (traces.has(info.id))
|
|
52
|
+
fail(`workflow/start repeated run id ${JSON.stringify(info.id)}`);
|
|
53
|
+
stagedStarts.add(info);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (!eventName.startsWith('workflow/'))
|
|
57
|
+
return;
|
|
58
|
+
const info = args[0];
|
|
59
|
+
const trace = traceFor(traces, info, fail);
|
|
60
|
+
if (eventName === 'workflow/agent-start') {
|
|
61
|
+
const agent = args[1];
|
|
62
|
+
if (!Number.isSafeInteger(agent.seq) || agent.seq < 1 || String(agent.childId).length === 0) {
|
|
63
|
+
fail('workflow/agent-start seq must be positive and childId must be non-empty');
|
|
64
|
+
}
|
|
65
|
+
if (trace.agents.has(agent.seq))
|
|
66
|
+
fail(`workflow/agent-start repeated seq ${agent.seq}`);
|
|
67
|
+
stagedAgentStarts.add(agent);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (eventName === 'workflow/agent-end') {
|
|
71
|
+
const agent = args[1];
|
|
72
|
+
const start = trace.agents.get(agent.seq);
|
|
73
|
+
if (start === undefined)
|
|
74
|
+
return fail(`workflow/agent-end has no matching start for seq ${agent.seq}`);
|
|
75
|
+
validateAgentEnd(start, agent, fail);
|
|
76
|
+
stagedAgentEnds.add(agent);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (eventName === 'workflow/end') {
|
|
80
|
+
const result = args[1];
|
|
81
|
+
validateWorkflowEnd(trace, result, fail);
|
|
82
|
+
stagedEnds.add(result);
|
|
83
|
+
}
|
|
84
|
+
}, { global: true });
|
|
85
|
+
ctx.on('workflow/start', (info) => {
|
|
86
|
+
/* v8 ignore next -- internal/dispatch stages the same run-info object */
|
|
87
|
+
if (!stagedStarts.delete(info))
|
|
88
|
+
return;
|
|
89
|
+
traces.set(info.id, { meta: JSON.stringify(info.meta), agents: new Map(), starts: 0 });
|
|
90
|
+
}, { global: true });
|
|
91
|
+
ctx.on('workflow/agent-start', (info, agent) => {
|
|
92
|
+
/* v8 ignore next -- internal/dispatch stages the same agent object */
|
|
93
|
+
if (!stagedAgentStarts.delete(agent))
|
|
94
|
+
return;
|
|
95
|
+
const trace = traceFor(traces, info, fail);
|
|
96
|
+
trace.agents.set(agent.seq, agent);
|
|
97
|
+
trace.starts += 1;
|
|
98
|
+
}, { global: true });
|
|
99
|
+
ctx.on('workflow/agent-end', (info, agent) => {
|
|
100
|
+
/* v8 ignore next -- internal/dispatch stages the same agent object */
|
|
101
|
+
if (!stagedAgentEnds.delete(agent))
|
|
102
|
+
return;
|
|
103
|
+
traceFor(traces, info, fail).agents.delete(agent.seq);
|
|
104
|
+
}, { global: true });
|
|
105
|
+
ctx.on('workflow/end', (info, result) => {
|
|
106
|
+
/* v8 ignore next -- internal/dispatch stages the same result object */
|
|
107
|
+
if (!stagedEnds.delete(result))
|
|
108
|
+
return;
|
|
109
|
+
traces.delete(info.id);
|
|
110
|
+
}, { global: true });
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Register the workflow invariant companion.
|
|
114
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
115
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
116
|
+
*/
|
|
117
|
+
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
118
|
+
//# sourceMappingURL=invariant.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only workflow request and live-run handles. The browser-safe durable
|
|
3
|
+
* vocabulary remains in `./types` so Client programs never import Agent or
|
|
4
|
+
* host Cordis context declarations.
|
|
5
|
+
*
|
|
6
|
+
* @module @deepseek-ai/dsh-workflow
|
|
7
|
+
*/
|
|
8
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
9
|
+
import type { WorkflowMeta, WorkflowResult, WorkflowRunId } from './types.ts';
|
|
10
|
+
/**
|
|
11
|
+
* What a caller asks for when starting a workflow run. `meta` and `args` are
|
|
12
|
+
* plain JSON data by the seam contract. `parent` is required because every
|
|
13
|
+
* `agent()` spawned by the script is attributed to that live Agent.
|
|
14
|
+
*/
|
|
15
|
+
export interface WorkflowStartRequest {
|
|
16
|
+
/** The plain-JS script body (top-level await allowed; ends with `return <json-value>`). */
|
|
17
|
+
script: string;
|
|
18
|
+
/** The workflow's identity block, as plain JSON data (shape-validated by the engine). */
|
|
19
|
+
meta: WorkflowMeta;
|
|
20
|
+
/** Optional input exposed verbatim to the script as the `args` global. */
|
|
21
|
+
args?: unknown;
|
|
22
|
+
/** Optional engine-wide child-provider override for this run. */
|
|
23
|
+
subagentProvider?: string;
|
|
24
|
+
/** Optional per-run total-child ceiling. */
|
|
25
|
+
maxTotalAgents?: number;
|
|
26
|
+
/** The agent on whose behalf the run executes (parent of every child). */
|
|
27
|
+
parent: Agent;
|
|
28
|
+
/** Cancels the run when aborted. */
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Holder-owned live workflow. `result` never rejects; consumers may cancel
|
|
33
|
+
* and must call idempotent `dispose()` to await script and child quiescence.
|
|
34
|
+
*/
|
|
35
|
+
export interface WorkflowRun {
|
|
36
|
+
readonly id: WorkflowRunId;
|
|
37
|
+
/** The validated meta block available before the script body runs. */
|
|
38
|
+
readonly meta: WorkflowMeta;
|
|
39
|
+
readonly result: Promise<WorkflowResult>;
|
|
40
|
+
/** Cancel the run and its children. */
|
|
41
|
+
cancel(reason?: string): void;
|
|
42
|
+
/** Cancel if needed and await bounded settlement and cleanup. */
|
|
43
|
+
dispose(): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=runtime-types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Host-only workflow request and live-run handles. The browser-safe durable
|
|
3
|
+
* vocabulary remains in `./types` so Client programs never import Agent or
|
|
4
|
+
* host Cordis context declarations.
|
|
5
|
+
*
|
|
6
|
+
* @module @deepseek-ai/dsh-workflow
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=runtime-types.js.map
|
package/lib/types/types.d.ts
CHANGED
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
* @module @deepseek-ai/dsh-workflow/types
|
|
7
7
|
*/
|
|
8
8
|
import type { Branded } from '@deepseek-ai/dsh-brand';
|
|
9
|
-
import type {
|
|
10
|
-
import type { SessionId } from '@deepseek-ai/dsh-session';
|
|
9
|
+
import type { SessionId } from '@deepseek-ai/dsh-session/types';
|
|
11
10
|
/** Identifies one workflow run. */
|
|
12
11
|
export type WorkflowRunId = Branded<'WorkflowRunId'>;
|
|
13
12
|
/**
|
|
@@ -47,37 +46,6 @@ export interface WorkflowMeta {
|
|
|
47
46
|
/** Optional phase declarations matched by `phase()` calls. */
|
|
48
47
|
phases?: WorkflowPhase[];
|
|
49
48
|
}
|
|
50
|
-
/**
|
|
51
|
-
* What a caller asks for when starting a workflow run. `meta` and `args` are
|
|
52
|
-
* plain JSON DATA by the seam contract (the tool builds both from the model's schema-validated call;
|
|
53
|
-
* the engine validates `meta` against its schema and rejects loud
|
|
54
|
-
* before anything runs) — an engine never evaluates script text to obtain
|
|
55
|
-
* them. `parent` is REQUIRED — every `agent()` the script spawns is
|
|
56
|
-
* attributed to it (cwd, lineage, depth flow through the subagent seam).
|
|
57
|
-
*/
|
|
58
|
-
export interface WorkflowStartRequest {
|
|
59
|
-
/** The plain-JS script body (top-level await allowed; ends with `return <json-value>`). */
|
|
60
|
-
script: string;
|
|
61
|
-
/** The workflow's identity fields as plain JSON data, validated by the engine. */
|
|
62
|
-
meta: WorkflowMeta;
|
|
63
|
-
/** Optional input exposed verbatim to the script as the `args` global. */
|
|
64
|
-
args?: unknown;
|
|
65
|
-
/**
|
|
66
|
-
* Optional engine-wide child-provider override for this run. The workflow
|
|
67
|
-
* script cannot observe or replace it; omission uses the engine's configured
|
|
68
|
-
* provider.
|
|
69
|
-
*/
|
|
70
|
-
subagentProvider?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Optional per-run total-child ceiling. Implementations reject values above
|
|
73
|
-
* their deployment ceiling before publishing the run.
|
|
74
|
-
*/
|
|
75
|
-
maxTotalAgents?: number;
|
|
76
|
-
/** The agent on whose behalf the run executes (parent of every child). */
|
|
77
|
-
parent: Agent;
|
|
78
|
-
/** Cancels the run when aborted (the tool's `exec.signal`). */
|
|
79
|
-
signal?: AbortSignal;
|
|
80
|
-
}
|
|
81
49
|
/**
|
|
82
50
|
* Why a run settled. CLOSED union (engine-owned, consumers may exhaust):
|
|
83
51
|
* `completed` = the script ran to its final `return`; `cancelled` = the run
|
|
@@ -86,7 +54,7 @@ export interface WorkflowStartRequest {
|
|
|
86
54
|
*/
|
|
87
55
|
export type WorkflowStopReason = 'completed' | 'cancelled' | 'error';
|
|
88
56
|
/**
|
|
89
|
-
* The outcome
|
|
57
|
+
* The outcome resolved by a live workflow run. `value` is
|
|
90
58
|
* the script's materialized return value (plain host-realm JSON data; `null`
|
|
91
59
|
* when the script returned `undefined`) — meaningful only for `completed`.
|
|
92
60
|
* A non-`completed` reason carries the failure in `error`; the consumer maps
|
|
@@ -108,22 +76,6 @@ export interface WorkflowResult {
|
|
|
108
76
|
*/
|
|
109
77
|
agentsStarted: number;
|
|
110
78
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Holder-owned live workflow. `result` never rejects and settles within the
|
|
113
|
-
* engine's cancellation grace; failures resolve through `stopReason`. Consumers
|
|
114
|
-
* may cancel and must call idempotent `dispose()` on every path to await bounded
|
|
115
|
-
* script settlement and child quiescence.
|
|
116
|
-
*/
|
|
117
|
-
export interface WorkflowRun {
|
|
118
|
-
readonly id: WorkflowRunId;
|
|
119
|
-
/** The validated meta block (available before the body runs). */
|
|
120
|
-
readonly meta: WorkflowMeta;
|
|
121
|
-
readonly result: Promise<WorkflowResult>;
|
|
122
|
-
/** Cancel the run: children abort, pending hooks reject, the script dies at its next await (or is force-settled at the grace). */
|
|
123
|
-
cancel(reason?: string): void;
|
|
124
|
-
/** Cancel + bounded-grace settle; safe to call on every path (idempotent). */
|
|
125
|
-
dispose(): Promise<void>;
|
|
126
|
-
}
|
|
127
79
|
/** Identifying detail for a run, carried by every `workflow/*` event as borrowed immutable data, never the live run. */
|
|
128
80
|
export interface WorkflowRunInfo {
|
|
129
81
|
/** The run's id. */
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow seam vocabulary: the request/run/result types a workflow engine
|
|
3
|
+
* consumes and produces, plus the fields in the `workflow/*` event payloads.
|
|
4
|
+
* Types only (plus the id-brand factory), per the package convention.
|
|
5
|
+
*
|
|
6
|
+
* @module @deepseek-ai/dsh-workflow/types
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Brand a string as a {@link WorkflowRunId}.
|
|
10
|
+
* @param id - the raw id string (the engine mints UUIDs; tests may pass fixtures).
|
|
11
|
+
* @returns the same string, branded.
|
|
12
|
+
*/
|
|
13
|
+
export function WorkflowRunId(id) {
|
|
14
|
+
return id;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-workflow",
|
|
3
3
|
"description": "Workflow capability seam: ctx.workflows service, run vocabulary, and workflow/* events",
|
|
4
|
-
"version": "0.0.1-rc.
|
|
4
|
+
"version": "0.0.1-rc.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "restricted"
|
|
7
7
|
},
|
|
@@ -22,29 +22,34 @@
|
|
|
22
22
|
"types": "./lib/types/invariant.d.ts",
|
|
23
23
|
"default": "./lib/invariant.js"
|
|
24
24
|
},
|
|
25
|
+
"./types": {
|
|
26
|
+
"types": "./lib/types/types.d.ts",
|
|
27
|
+
"default": "./lib/types/types.js"
|
|
28
|
+
},
|
|
25
29
|
"./src/*": "./src/*",
|
|
26
30
|
"./package.json": "./package.json"
|
|
27
31
|
},
|
|
28
32
|
"files": [
|
|
29
33
|
"lib/index.js",
|
|
30
34
|
"lib/invariant.js",
|
|
35
|
+
"lib/types/**/*.js",
|
|
31
36
|
"lib/types/**/*.d.ts"
|
|
32
37
|
],
|
|
33
38
|
"license": "BSD-3-Clause",
|
|
34
39
|
"peerDependencies": {
|
|
35
|
-
"@deepseek-ai/dsh-agent": "^0.0.1-rc.
|
|
36
|
-
"@deepseek-ai/dsh-brand": "^0.0.1-rc.
|
|
37
|
-
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.
|
|
38
|
-
"@deepseek-ai/dsh-llm": "^0.0.1-rc.
|
|
39
|
-
"@deepseek-ai/dsh-session": "^0.0.1-rc.
|
|
40
|
+
"@deepseek-ai/dsh-agent": "^0.0.1-rc.2",
|
|
41
|
+
"@deepseek-ai/dsh-brand": "^0.0.1-rc.2",
|
|
42
|
+
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.2",
|
|
43
|
+
"@deepseek-ai/dsh-llm": "^0.0.1-rc.2",
|
|
44
|
+
"@deepseek-ai/dsh-session": "^0.0.1-rc.2",
|
|
40
45
|
"@deepseek-ai/cordis": "^4.0.1-rc.1"
|
|
41
46
|
},
|
|
42
47
|
"devDependencies": {
|
|
43
|
-
"@deepseek-ai/dsh-
|
|
44
|
-
"@deepseek-ai/dsh-
|
|
45
|
-
"@deepseek-ai/dsh-
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/
|
|
48
|
-
"@deepseek-ai/
|
|
48
|
+
"@deepseek-ai/dsh-brand": "^0.0.1-rc.2",
|
|
49
|
+
"@deepseek-ai/dsh-agent": "^0.0.1-rc.2",
|
|
50
|
+
"@deepseek-ai/dsh-invariants": "^0.0.1-rc.2",
|
|
51
|
+
"@deepseek-ai/dsh-llm": "^0.0.1-rc.2",
|
|
52
|
+
"@deepseek-ai/dsh-session": "^0.0.1-rc.2",
|
|
53
|
+
"@deepseek-ai/cordis": "^4.0.1-rc.1"
|
|
49
54
|
}
|
|
50
55
|
}
|