@deepseek-ai/dsh-workflow 0.2.0-rc.1 → 0.2.1-alpha.1

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 CHANGED
@@ -36,8 +36,8 @@
36
36
  en: 274b3de2f7b713ec
37
37
  zh: e3953c1ae1f59442
38
38
  /deepseek-ai-dsh-workflow/understand-the-implementation/source-map:
39
- en: 67240e519a3e725f
40
- zh: 495f806856054230
39
+ en: 4980d54aca90b591
40
+ zh: 73a828842b6c6f6a
41
41
  /deepseek-ai-dsh-workflow/understand-the-implementation/lifecycle-and-ownership:
42
42
  en: 95b074d816b52323
43
43
  zh: dfa070a1531651f9
@@ -45,8 +45,8 @@
45
45
  en: e2c2a6e2876457e8
46
46
  zh: 764cba9eede4bb79
47
47
  /deepseek-ai-dsh-workflow/further-exploration:
48
- en: 727ba336da235497
49
- zh: 4562f0653af6b975
48
+ en: 6b3752bee67372c3
49
+ zh: 92492c01c4d786d3
50
50
  /deepseek-ai-dsh-workflow/model-experience:
51
51
  en: e8bb1d12900a4025
52
52
  zh: b8936a40dc5867d6
package/README.md CHANGED
@@ -77,7 +77,6 @@ The package separates the script, run, result, and event contracts from executio
77
77
  | [`src/index.ts`](src/index.ts) | Service definition, `workflow/*` event declarations, `WorkflowError` and its fatal flag |
78
78
  | [`src/types.ts`](src/types.ts) | Browser-safe vocabulary: `WorkflowMeta`, `WorkflowResult`, run and agent event info |
79
79
  | [`src/runtime-types.ts`](src/runtime-types.ts) | Host-only `WorkflowStartRequest` and `WorkflowRun` handles |
80
- | [`src/invariant.ts`](src/invariant.ts) | Invariant companion: event pairing and identity checks |
81
80
 
82
81
  ### Lifecycle and ownership
83
82
 
@@ -104,7 +103,7 @@ Read these pages when the package-level contract is not enough. They move from t
104
103
  - [Group map](../README.md) — the workflow capability family and its packages.
105
104
  - [workflow tool](../tool-workflow/README.md) — the model-facing consumer that owns the call schema and result envelope.
106
105
  - [PTC workflow engine](../workflow-ptc/README.md) — the current execution engine and its isolation boundary.
107
- - [Dynamic workflows Agent Note](../../../.agents/notes/implemented/feature/2026-07-05-dynamic-workflows.md) — the seam design and its decisions.
106
+ - [historical Dynamic workflows Agent Note](../../../.agents/notes/archived/feature/2026-07-05-dynamic-workflows.md) — the seam design and its decisions.
108
107
 
109
108
  -----
110
109
 
package/README.zh.md CHANGED
@@ -77,7 +77,6 @@ return { reviewed: reviews.length }
77
77
  | [`src/index.ts`](src/index.ts) | 服务定义、`workflow/*` 事件声明、`WorkflowError` 及其 fatal 标志 |
78
78
  | [`src/types.ts`](src/types.ts) | 浏览器安全词汇:`WorkflowMeta`、`WorkflowResult`、运行与 agent 事件信息 |
79
79
  | [`src/runtime-types.ts`](src/runtime-types.ts) | 仅宿主的 `WorkflowStartRequest` 与 `WorkflowRun` 句柄 |
80
- | [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件:事件配对与身份校验 |
81
80
 
82
81
  ### 生命周期与归属
83
82
 
@@ -104,7 +103,7 @@ return { reviewed: reviews.length }
104
103
  - [组地图](../README.zh.md)——工作流能力家族及其包。
105
104
  - [workflow 工具](../tool-workflow/README.zh.md)——拥有调用 schema 与结果包络的模型侧消费方。
106
105
  - [PTC 工作流引擎](../workflow-ptc/README.zh.md)——当前执行引擎及其隔离边界。
107
- - [动态工作流 Agent Note](../../../.agents/notes/implemented/feature/2026-07-05-dynamic-workflows.zh.md)——seam 设计及其决策。
106
+ - [历史动态工作流 Agent Note](../../../.agents/notes/archived/feature/2026-07-05-dynamic-workflows.md)——seam 设计及其决策。
108
107
 
109
108
  -----
110
109
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-workflow",
3
3
  "description": "Workflow capability seam: ctx.workflowEngine service, run vocabulary, and workflow/* events",
4
- "version": "0.2.0-rc.1",
4
+ "version": "0.2.1-alpha.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -18,10 +18,6 @@
18
18
  "types": "./lib/types/index.d.ts",
19
19
  "default": "./lib/index.js"
20
20
  },
21
- "./invariant": {
22
- "types": "./lib/types/invariant.d.ts",
23
- "default": "./lib/invariant.js"
24
- },
25
21
  "./types": {
26
22
  "types": "./lib/types/types.d.ts",
27
23
  "default": "./lib/types/types.js"
@@ -31,25 +27,22 @@
31
27
  },
32
28
  "files": [
33
29
  "lib/index.js",
34
- "lib/invariant.js",
35
30
  "lib/types/**/*.js",
36
31
  "lib/types/**/*.d.ts"
37
32
  ],
38
33
  "license": "MIT",
39
34
  "peerDependencies": {
40
- "@deepseek-ai/dsh-agent": "0.2.0-rc.1",
41
- "@deepseek-ai/dsh-invariants": "0.2.0-rc.1",
42
- "@deepseek-ai/dsh-brand": "0.2.0-rc.1",
43
- "@deepseek-ai/dsh-llm": "0.2.0-rc.1",
44
- "@deepseek-ai/dsh-session": "0.2.0-rc.1",
45
- "@deepseek-ai/cordis": "~4.0.4"
35
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
36
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
37
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.1",
38
+ "@deepseek-ai/cordis": "~4.0.5-alpha.1",
39
+ "@deepseek-ai/dsh-brand": "0.2.1-alpha.1"
46
40
  },
47
41
  "devDependencies": {
48
- "@deepseek-ai/dsh-agent": "0.2.0-rc.1",
49
- "@deepseek-ai/dsh-brand": "0.2.0-rc.1",
50
- "@deepseek-ai/dsh-invariants": "0.2.0-rc.1",
51
- "@deepseek-ai/dsh-llm": "0.2.0-rc.1",
52
- "@deepseek-ai/dsh-session": "0.2.0-rc.1",
53
- "@deepseek-ai/cordis": "~4.0.4"
42
+ "@deepseek-ai/dsh-agent": "0.2.1-alpha.1",
43
+ "@deepseek-ai/dsh-brand": "0.2.1-alpha.1",
44
+ "@deepseek-ai/dsh-llm": "0.2.1-alpha.1",
45
+ "@deepseek-ai/cordis": "~4.0.5-alpha.1",
46
+ "@deepseek-ai/dsh-session": "0.2.1-alpha.1"
54
47
  }
55
48
  }
package/lib/invariant.js DELETED
@@ -1,100 +0,0 @@
1
- //#region lib/types/invariant.js
2
- /** Package-owned workflow lifecycle invariants. @module @deepseek-ai/dsh-workflow/invariant */
3
- const PACKAGE_NAME = "@deepseek-ai/dsh-workflow";
4
- /** Cordis companion plugin name. */
5
- const name = "workflow-invariant";
6
- /** Service required before the companion can reserve package ownership. */
7
- const inject = ["invariants"];
8
- /** Require every event for a run to retain its validated identity snapshot. */
9
- function traceFor(traces, info, fail) {
10
- const trace = traces.get(info.id);
11
- if (trace === void 0) fail(`workflow event has no matching workflow/start for run ${JSON.stringify(info.id)}`);
12
- if (trace.meta !== JSON.stringify(info.meta)) fail(`workflow event meta diverges from workflow/start for run ${JSON.stringify(info.id)}`);
13
- return trace;
14
- }
15
- /** Assert the immutable identity fields shared by an agent pair. */
16
- function validateAgentEnd(start, end, fail) {
17
- if (start.label !== end.label || start.phase !== end.phase || start.childId !== end.childId) fail(`workflow/agent-end identity diverges from workflow/agent-start for seq ${end.seq}`);
18
- const outcome = end.outcome;
19
- if (outcome !== "completed" && outcome !== "failed" && outcome !== "cancelled") fail(`workflow/agent-end carries unknown outcome ${JSON.stringify(outcome)}`);
20
- }
21
- /** Validate a terminal result against the accumulated run trace. */
22
- function validateWorkflowEnd(trace, result, fail) {
23
- if (trace.agents.size > 0) fail(`workflow/end has ${trace.agents.size} agent call(s) without workflow/agent-end`);
24
- if (!Number.isSafeInteger(result.agentsStarted) || result.agentsStarted < trace.starts) fail("workflow/end agentsStarted must be a safe integer covering every observed agent start");
25
- if (result.stopReason === "completed" ? result.error !== void 0 : typeof result.error !== "string") fail("workflow/end error must be absent exactly for completed runs");
26
- }
27
- /** Install workflow start/end and child-call pairing checks. */
28
- const install = (ctx, fail) => {
29
- const traces = /* @__PURE__ */ new Map();
30
- const stagedStarts = /* @__PURE__ */ new WeakSet();
31
- const stagedAgentStarts = /* @__PURE__ */ new WeakSet();
32
- const stagedAgentEnds = /* @__PURE__ */ new WeakSet();
33
- const stagedEnds = /* @__PURE__ */ new WeakSet();
34
- ctx.on("internal/dispatch", (_mode, eventName, args) => {
35
- if (eventName === "workflow/start") {
36
- const info = args[0];
37
- if (String(info.id).length === 0 || info.meta.name.length === 0 || info.meta.description.length === 0) fail("workflow/start id, meta.name, and meta.description must be non-empty");
38
- if (traces.has(info.id)) fail(`workflow/start repeated run id ${JSON.stringify(info.id)}`);
39
- stagedStarts.add(info);
40
- return;
41
- }
42
- if (!eventName.startsWith("workflow/")) return;
43
- const info = args[0];
44
- const trace = traceFor(traces, info, fail);
45
- if (eventName === "workflow/agent-start") {
46
- const agent = args[1];
47
- if (!Number.isSafeInteger(agent.seq) || agent.seq < 1 || String(agent.childId).length === 0) fail("workflow/agent-start seq must be positive and childId must be non-empty");
48
- if (trace.agents.has(agent.seq)) fail(`workflow/agent-start repeated seq ${agent.seq}`);
49
- stagedAgentStarts.add(agent);
50
- return;
51
- }
52
- if (eventName === "workflow/agent-end") {
53
- const agent = args[1];
54
- const start = trace.agents.get(agent.seq);
55
- if (start === void 0) return fail(`workflow/agent-end has no matching start for seq ${agent.seq}`);
56
- validateAgentEnd(start, agent, fail);
57
- stagedAgentEnds.add(agent);
58
- return;
59
- }
60
- if (eventName === "workflow/end") {
61
- const result = args[1];
62
- validateWorkflowEnd(trace, result, fail);
63
- stagedEnds.add(result);
64
- }
65
- }, { global: true });
66
- ctx.on("workflow/start", (info) => {
67
- /* v8 ignore next -- internal/dispatch stages the same run-info object */
68
- if (!stagedStarts.delete(info)) return;
69
- traces.set(info.id, {
70
- meta: JSON.stringify(info.meta),
71
- agents: /* @__PURE__ */ new Map(),
72
- starts: 0
73
- });
74
- }, { global: true });
75
- ctx.on("workflow/agent-start", (info, agent) => {
76
- /* v8 ignore next -- internal/dispatch stages the same agent object */
77
- if (!stagedAgentStarts.delete(agent)) return;
78
- const trace = traceFor(traces, info, fail);
79
- trace.agents.set(agent.seq, agent);
80
- trace.starts += 1;
81
- }, { global: true });
82
- ctx.on("workflow/agent-end", (info, agent) => {
83
- /* v8 ignore next -- internal/dispatch stages the same agent object */
84
- if (!stagedAgentEnds.delete(agent)) return;
85
- traceFor(traces, info, fail).agents.delete(agent.seq);
86
- }, { global: true });
87
- ctx.on("workflow/end", (info, result) => {
88
- /* v8 ignore next -- internal/dispatch stages the same result object */
89
- if (!stagedEnds.delete(result)) return;
90
- traces.delete(info.id);
91
- }, { global: true });
92
- };
93
- /**
94
- * Register the workflow invariant companion.
95
- * @param ctx - Cordis context carrying the invariant service.
96
- * @returns the installed registration's disposer after setup succeeds.
97
- */
98
- const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
99
- //#endregion
100
- export { apply, inject, name };
@@ -1,13 +0,0 @@
1
- /** Package-owned workflow lifecycle invariants. @module @deepseek-ai/dsh-workflow/invariant */
2
- import type { Context } from '@deepseek-ai/cordis';
3
- /** Cordis companion plugin name. */
4
- export declare const name = "workflow-invariant";
5
- /** Service required before the companion can reserve package ownership. */
6
- export declare const inject: string[];
7
- /**
8
- * Register the workflow invariant companion.
9
- * @param ctx - Cordis context carrying the invariant service.
10
- * @returns the installed registration's disposer after setup succeeds.
11
- */
12
- export declare const apply: (ctx: Context) => Promise<() => void>;
13
- //# sourceMappingURL=invariant.d.ts.map
@@ -1,118 +0,0 @@
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