@deepseek-ai/dsh-workflow 0.2.2-rc.5 → 0.2.3-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
@@ -42,8 +42,8 @@
42
42
  en: 95b074d816b52323
43
43
  zh: dfa070a1531651f9
44
44
  /deepseek-ai-dsh-workflow/understand-the-implementation/failure-discipline:
45
- en: e2c2a6e2876457e8
46
- zh: 764cba9eede4bb79
45
+ en: aea4d2fb4510cbc7
46
+ zh: ae330837b06c23bb
47
47
  /deepseek-ai-dsh-workflow/further-exploration:
48
48
  en: 6b3752bee67372c3
49
49
  zh: 92492c01c4d786d3
package/README.md CHANGED
@@ -86,7 +86,7 @@ A run is holder-owned: engine-plugin unload prevents new starts but does not rev
86
86
 
87
87
  ### Failure discipline
88
88
 
89
- `WorkflowError` carries a machine-routable code and a `fatal` flag; every code is fatal, and `parallel()` and `pipeline()` re-throw fatal errors instead of mapping the item to `null` — a typo'd option must kill the script loudly. Codes cover start failures, contract violations, exceeded caps, provider and result faults, unserializable values, and cancellation; the exact set and meanings live in [`src/index.ts`](src/index.ts).
89
+ `WorkflowError` carries a machine-routable code and a `fatal` flag; every code is fatal, and `parallel()` and `pipeline()` re-throw fatal errors instead of mapping the item to `null` — a typo'd option must kill the script loudly. Codes cover start failures, contract violations, exceeded caps, provider and result faults, unserializable values, and cancellation; the code that ended a run is reported as `WorkflowResult.errorCode`, and `RUN_FAILED` classifies an `error` run without one; the exact set and meanings live in [`src/index.ts`](src/index.ts).
90
90
 
91
91
  The per-item `null` is reserved for child-run failures and ordinary in-stage script errors, so a child that resolves normally with a non-completed stop reason is not an infrastructure exception: `agent()` returns `null`, letting the script handle an ordinary child failure.
92
92
 
package/README.zh.md CHANGED
@@ -86,7 +86,7 @@ return { reviewed: reviews.length }
86
86
 
87
87
  ### 失败纪律
88
88
 
89
- `WorkflowError` 携带机器可路由的 code 与 `fatal` 标志;每个 code 都是致命的,`parallel()` 与 `pipeline()` 会重新抛出致命错误,而不是把条目映射为 `null`——拼错的选项必须明确终止脚本。code 覆盖启动失败、约定违规、超出上限、提供方与结果故障、不可序列化值与取消;完整集合与含义见 [`src/index.ts`](src/index.ts)。
89
+ `WorkflowError` 携带机器可路由的 code 与 `fatal` 标志;每个 code 都是致命的,`parallel()` 与 `pipeline()` 会重新抛出致命错误,而不是把条目映射为 `null`——拼错的选项必须明确终止脚本。code 覆盖启动失败、约定违规、超出上限、提供方与结果故障、不可序列化值、取消;结束运行的 code 报告为 `WorkflowResult.errorCode`,没有该 code 的 `error` 运行归为 `RUN_FAILED`;完整集合与含义见 [`src/index.ts`](src/index.ts)。
90
90
 
91
91
  逐项 `null` 只保留给子运行失败与阶段内普通脚本错误,因此以非完成结束原因正常结算的子 agent 不属于基础设施异常:`agent()` 返回 `null`,让脚本处理普通子 agent 失败。
92
92
 
package/lib/index.js CHANGED
@@ -33,11 +33,13 @@ function WorkflowRunId(id) {
33
33
  * distinction is explicit at every catch site rather than implied.
34
34
  */
35
35
  var WorkflowError = class extends HarnessError {
36
+ code;
36
37
  /** Whether combinators must propagate this error instead of nulling the item. */
37
38
  fatal;
38
39
  constructor(message, code, options) {
39
40
  super(message, code, options);
40
41
  this.name = "WorkflowError";
42
+ this.code = code;
41
43
  this.fatal = options?.fatal ?? true;
42
44
  }
43
45
  };
@@ -73,12 +73,15 @@ declare module '@deepseek-ai/cordis' {
73
73
  /** The full set of `workflow/*` event names {@link WorkflowEngine.emitWorkflowEvent} dispatches. */
74
74
  export type WorkflowEventName = 'workflow/start' | 'workflow/phase' | 'workflow/log' | 'workflow/agent-start' | 'workflow/agent-end' | 'workflow/end';
75
75
  /**
76
- * Machine-routable fatal workflow failures: parse/meta/argument/schema errors,
77
- * resource caps, subagent infrastructure failures, unserializable boundary
78
- * values, and cancellation. An ordinary child failure resolves its item to
79
- * `null` and is not one of these fatal codes.
76
+ * Machine-routable workflow failures. Hooks throw the fatal codes:
77
+ * parse/meta/argument/schema errors, resource caps, subagent infrastructure
78
+ * failures, unserializable boundary values, and cancellation; an engine
79
+ * reports the one that ended a run as {@link WorkflowResult.errorCode}.
80
+ * `RUN_FAILED` classifies an `error` run without such a code: the script's own
81
+ * exception or an engine runtime failure. An ordinary child failure resolves
82
+ * its item to `null` and is not one of these codes.
80
83
  */
81
- export type WorkflowErrorCode = 'SCRIPT_PARSE' | 'META_INVALID' | 'INVALID_ARGUMENT' | 'UNSUPPORTED_OPTION' | 'UNSUPPORTED_SCHEMA' | 'AGENT_CAP' | 'ITEM_CAP' | 'AGENT_START' | 'AGENT_RESULT' | 'RESULT_UNSERIALIZABLE' | 'CANCELLED';
84
+ export type WorkflowErrorCode = 'SCRIPT_PARSE' | 'META_INVALID' | 'INVALID_ARGUMENT' | 'UNSUPPORTED_OPTION' | 'UNSUPPORTED_SCHEMA' | 'AGENT_CAP' | 'ITEM_CAP' | 'AGENT_START' | 'AGENT_RESULT' | 'RESULT_UNSERIALIZABLE' | 'CANCELLED' | 'RUN_FAILED';
82
85
  /**
83
86
  * Typed error for workflow-seam failures. Extends {@link HarnessError}, so the
84
87
  * `code` is machine-routable taxonomy. `fatal` drives the combinator
@@ -89,6 +92,7 @@ export type WorkflowErrorCode = 'SCRIPT_PARSE' | 'META_INVALID' | 'INVALID_ARGUM
89
92
  * distinction is explicit at every catch site rather than implied.
90
93
  */
91
94
  export declare class WorkflowError extends HarnessError {
95
+ readonly code: WorkflowErrorCode;
92
96
  /** Whether combinators must propagate this error instead of nulling the item. */
93
97
  readonly fatal: boolean;
94
98
  constructor(message: string, code: WorkflowErrorCode, options?: ErrorOptions & {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK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hB;;;;;;;;GAQG;AACH,qBAAa,aAAc,SAAQ,YAAY;IAC7C,SAAkB,IAAI,EAAE,iBAAiB,CAAA;IACzC,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;gBAEX,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAMnG;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED;;;;;;GAMG;AACH,8BAAsB,cAAe,SAAQ,OAAO;gBACtC,GAAG,EAAE,OAAO;IAIxB;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,oBAAoB,GAAG,WAAW;IAE1D;;;;OAIG;IACH,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI;CAY/E;AAgBD,eAAe,cAAc,CAAA"}
@@ -16,11 +16,13 @@ export { WorkflowRunId } from "./types.js";
16
16
  * distinction is explicit at every catch site rather than implied.
17
17
  */
18
18
  export class WorkflowError extends HarnessError {
19
+ code;
19
20
  /** Whether combinators must propagate this error instead of nulling the item. */
20
21
  fatal;
21
22
  constructor(message, code, options) {
22
23
  super(message, code, options);
23
24
  this.name = 'WorkflowError';
25
+ this.code = code;
24
26
  this.fatal = options?.fatal ?? true;
25
27
  }
26
28
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAW,OAAO,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AASnD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAwG1C;;;;;;;;GAQG;AACH,MAAM,OAAO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IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC;YACzE,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAa,QAA+C,CAAC,GAAG,IAAI,CAAC,CAAA;gBACnF,KAAK,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;oBACtD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,uBAAuB,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;gBAC5F,CAAC,CAAC,CAAA;YACJ,CAAC;YAAC,OAAO,KAAc,EAAE,CAAC;gBACxB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,IAAI,oBAAoB,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACzF,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,mBAAmB,CAAC,KAAc;IACzC,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,oCAAoC;QACpC,OAAO,6BAA6B,CAAA;IACtC,CAAC;AACH,CAAC;AAED,eAAe,cAAc,CAAA"}
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import type { Branded } from '@deepseek-ai/dsh-brand';
9
9
  import type { SessionId } from '@deepseek-ai/dsh-session/types';
10
+ import type { WorkflowErrorCode } from './index.ts';
10
11
  /** Identifies one workflow run. */
11
12
  export type WorkflowRunId = Branded<'WorkflowRunId'>;
12
13
  /**
@@ -67,6 +68,11 @@ export interface WorkflowResult {
67
68
  stopReason: WorkflowStopReason;
68
69
  /** The failure message (present iff `stopReason` is not `completed`). */
69
70
  error?: string;
71
+ /**
72
+ * The code of the fatal {@link WorkflowError} that ended an `error` run;
73
+ * absent when the script's own exception or the engine runtime ended it.
74
+ */
75
+ errorCode?: WorkflowErrorCode;
70
76
  /**
71
77
  * How many `agent()` calls the run accepted over its whole lifetime. On a
72
78
  * graceful settlement this is the script-side count (calls still queued for
@@ -112,6 +118,8 @@ export interface WorkflowResultInfo {
112
118
  stopReason: WorkflowStopReason;
113
119
  /** The failure message (present iff `stopReason` is not `completed`). */
114
120
  error?: string;
121
+ /** The fatal code that ended an `error` run (see {@link WorkflowResult.errorCode}). */
122
+ errorCode?: WorkflowErrorCode;
115
123
  /** How many `agent()` calls the run accepted (see {@link WorkflowResult.agentsStarted}). */
116
124
  agentsStarted: number;
117
125
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE/D,mCAAmC;AACnC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAEvD;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAA;IACb,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAA;IACnB,2EAA2E;IAC3E,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8DAA8D;IAC9D,MAAM,CAAC,EAAE,aAA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ACtC,IAAI,EAAE,YAAY,CAAA;CACnB;AAED,uFAAuF;AACvF,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAA;IACX,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAA;IACb,8FAA8F;IAC9F,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,OAAO,EAAE,SAAS,CAAA;CACnB;AAED,6GAA6G;AAC7G,MAAM,MAAM,oBAAoB,GAAG,WAAW,GAAG,QAAQ,GAAG,WAAW,CAAA;AAEvE,0EAA0E;AAC1E,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,4BAA4B;IAC5B,OAAO,EAAE,oBAAoB,CAAA;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,2BAA2B;IAC3B,UAAU,EAAE,kBAAkB,CAAA;IAC9B,yEAAyE;IACzE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,uFAAuF;IACvF,SAAS,CAAC,EAAE,iBAAiB,CAAA;IAC7B,4FAA4F;IAC5F,aAAa,EAAE,MAAM,CAAA;CACtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,EAAmB,CAAA;AAC5B,CAAC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AASH;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,EAAmB,CAAA;AAC5B,CAAC"}
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.2-rc.5",
4
+ "version": "0.2.3-alpha.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -35,17 +35,16 @@
35
35
  ],
36
36
  "license": "MIT",
37
37
  "peerDependencies": {
38
- "@deepseek-ai/dsh-agent": "0.2.2-rc.5",
39
- "@deepseek-ai/dsh-brand": "0.2.2-rc.5",
40
- "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
41
- "@deepseek-ai/dsh-session": "0.2.2-rc.5",
38
+ "@deepseek-ai/dsh-agent": "0.2.3-alpha.1",
39
+ "@deepseek-ai/dsh-llm": "0.2.3-alpha.1",
40
+ "@deepseek-ai/dsh-session": "0.2.3-alpha.1",
42
41
  "@deepseek-ai/cordis": "~4.1.0"
43
42
  },
44
43
  "devDependencies": {
45
- "@deepseek-ai/dsh-agent": "0.2.2-rc.5",
46
- "@deepseek-ai/dsh-brand": "0.2.2-rc.5",
47
- "@deepseek-ai/dsh-llm": "0.2.2-rc.5",
48
- "@deepseek-ai/dsh-session": "0.2.2-rc.5",
44
+ "@deepseek-ai/dsh-agent": "0.2.3-alpha.1",
45
+ "@deepseek-ai/dsh-brand": "0.2.3-alpha.1",
46
+ "@deepseek-ai/dsh-llm": "0.2.3-alpha.1",
47
+ "@deepseek-ai/dsh-session": "0.2.3-alpha.1",
49
48
  "@deepseek-ai/cordis": "~4.1.0"
50
49
  }
51
50
  }
package/src/index.ts CHANGED
@@ -100,10 +100,13 @@ export type WorkflowEventName =
100
100
  | 'workflow/end'
101
101
 
102
102
  /**
103
- * Machine-routable fatal workflow failures: parse/meta/argument/schema errors,
104
- * resource caps, subagent infrastructure failures, unserializable boundary
105
- * values, and cancellation. An ordinary child failure resolves its item to
106
- * `null` and is not one of these fatal codes.
103
+ * Machine-routable workflow failures. Hooks throw the fatal codes:
104
+ * parse/meta/argument/schema errors, resource caps, subagent infrastructure
105
+ * failures, unserializable boundary values, and cancellation; an engine
106
+ * reports the one that ended a run as {@link WorkflowResult.errorCode}.
107
+ * `RUN_FAILED` classifies an `error` run without such a code: the script's own
108
+ * exception or an engine runtime failure. An ordinary child failure resolves
109
+ * its item to `null` and is not one of these codes.
107
110
  */
108
111
  export type WorkflowErrorCode =
109
112
  | 'SCRIPT_PARSE'
@@ -117,6 +120,7 @@ export type WorkflowErrorCode =
117
120
  | 'AGENT_RESULT'
118
121
  | 'RESULT_UNSERIALIZABLE'
119
122
  | 'CANCELLED'
123
+ | 'RUN_FAILED'
120
124
 
121
125
  /**
122
126
  * Typed error for workflow-seam failures. Extends {@link HarnessError}, so the
@@ -128,12 +132,14 @@ export type WorkflowErrorCode =
128
132
  * distinction is explicit at every catch site rather than implied.
129
133
  */
130
134
  export class WorkflowError extends HarnessError {
135
+ override readonly code: WorkflowErrorCode
131
136
  /** Whether combinators must propagate this error instead of nulling the item. */
132
137
  readonly fatal: boolean
133
138
 
134
139
  constructor(message: string, code: WorkflowErrorCode, options?: ErrorOptions & { fatal?: boolean }) {
135
140
  super(message, code, options)
136
141
  this.name = 'WorkflowError'
142
+ this.code = code
137
143
  this.fatal = options?.fatal ?? true
138
144
  }
139
145
  }
package/src/types.ts CHANGED
@@ -8,6 +8,7 @@
8
8
 
9
9
  import type { Branded } from '@deepseek-ai/dsh-brand'
10
10
  import type { SessionId } from '@deepseek-ai/dsh-session/types'
11
+ import type { WorkflowErrorCode } from './index.ts'
11
12
 
12
13
  /** Identifies one workflow run. */
13
14
  export type WorkflowRunId = Branded<'WorkflowRunId'>
@@ -76,6 +77,11 @@ export interface WorkflowResult {
76
77
  stopReason: WorkflowStopReason
77
78
  /** The failure message (present iff `stopReason` is not `completed`). */
78
79
  error?: string
80
+ /**
81
+ * The code of the fatal {@link WorkflowError} that ended an `error` run;
82
+ * absent when the script's own exception or the engine runtime ended it.
83
+ */
84
+ errorCode?: WorkflowErrorCode
79
85
  /**
80
86
  * How many `agent()` calls the run accepted over its whole lifetime. On a
81
87
  * graceful settlement this is the script-side count (calls still queued for
@@ -126,6 +132,8 @@ export interface WorkflowResultInfo {
126
132
  stopReason: WorkflowStopReason
127
133
  /** The failure message (present iff `stopReason` is not `completed`). */
128
134
  error?: string
135
+ /** The fatal code that ended an `error` run (see {@link WorkflowResult.errorCode}). */
136
+ errorCode?: WorkflowErrorCode
129
137
  /** How many `agent()` calls the run accepted (see {@link WorkflowResult.agentsStarted}). */
130
138
  agentsStarted: number
131
139
  }