@xneog/dsh-tool-workflow 0.1.0 → 0.1.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 +2 -2
- package/README.md +103 -14
- package/README.zh.md +112 -23
- package/lib/index.js +1 -1
- package/lib/invariant.js +1 -1
- package/lib/types/index.js +1 -1
- package/lib/types/invariant.js +1 -1
- package/package.json +21 -20
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/tool-workflow/README.md
|
|
5
|
-
README.md:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 62581d92df9a1d1dfff5d14bcd183332b3c757cb
|
|
6
|
+
README.zh.md: fc474ed76d3dcd77263daa085322c2d41e64d6f2
|
package/README.md
CHANGED
|
@@ -1,32 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "The model-facing workflow tool: run a JavaScript orchestration script that fans out subagents, for users and maintainers choosing or configuring model-driven orchestration."
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @xneog/dsh-tool-workflow
|
|
2
7
|
|
|
3
8
|
English | [中文](README.zh.md)
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
`dsh-tool-workflow` gives the model the `workflow` tool: call it with a JavaScript orchestration script, an identity block, and optional arguments, and it runs the script over `ctx.workflowEngine`, fanning work out across subagents until the script's final value returns. The tool owns the model-facing schema, the usage guidance in the system prompt, and the result envelope; script parsing, execution, caps, and cancellation live behind the engine. Execution is foreground: the parent turn blocks until the whole workflow settles, and a non-clean finish is an error, never partial output. Choose it when the user explicitly asks for workflow-style or large multi-agent orchestration; prefer plain subagent calls for one or two delegations.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
8
22
|
|
|
9
|
-
|
|
23
|
+
-----
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
The `workflow` tool runs a model-authored orchestration script that fans work out across many subagents and returns the script's final JSON value. Use it only when the user explicitly asks for a workflow or for large multi-agent orchestration — an audit over many files, a migration, multi-angle research; for one or two delegations, prefer plain subagent calls.
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
### Calling the tool
|
|
16
31
|
|
|
17
|
-
The
|
|
32
|
+
The model submits three parameters: `meta` (required identity data: `name`, `description`, and optional `whenToUse` and `phases`), `script` (required plain JavaScript body — no `export const meta` statement; the tool description carries the complete authoring contract), and `args` (optional JSON object exposed to the script as the `args` global; wrap a bare list in a field so the wire schema stays honest).
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
Success returns the canonical envelope `{ runId, agentsStarted, result }`, rendered to the model as `workflow "<name>" completed (<count> agent<optional-s>).` followed by `Return value:` and the pretty-printed JSON. A workflow that cannot start — a script parse or meta validation failure — returns an error the model can correct from. Cancellation and execution failures return `Error: workflow run was cancelled` or `Error: workflow run failed: <error>`; partial output is never reported as success.
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
### What to expect during a run
|
|
22
37
|
|
|
23
|
-
|
|
38
|
+
While the script runs, the parent turn waits: the tool starts the run, awaits its result, and always disposes it, so the script and its children reach quiescence on every path — including cancellation, which is bridged from the parent step's abort signal. The model sees one final outcome, never intermediate child messages; the children's own work stays out of the parent conversation.
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
### Config
|
|
41
|
+
|
|
42
|
+
| Field | Default | Meaning |
|
|
26
43
|
|---|---|---|
|
|
27
44
|
| `toolName` | `workflow` | The model-facing tool name to register. |
|
|
28
45
|
| `maxResultChars` | `50000` | Rendered-result ceiling; longer JSON is truncated with a notice. |
|
|
29
46
|
|
|
47
|
+
The generated [configuration catalog](../../../docs/config-catalog.md#xneogdsh-tool-workflow) is the exhaustive source for every accepted field.
|
|
48
|
+
|
|
49
|
+
-----
|
|
50
|
+
|
|
51
|
+
<a id="understand-the-implementation"></a>
|
|
52
|
+
## Understand the implementation
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>Implementation internals — click to expand</summary>
|
|
56
|
+
|
|
57
|
+
This section explains how the consumer is split from the engine and how the run lifecycle and records work; observable behavior is fully covered in [Use this package](#use-this-package).
|
|
58
|
+
|
|
59
|
+
### Design concept
|
|
60
|
+
|
|
61
|
+
The consumer owns the model-facing schema, the `tool:<toolName>` system-prompt guidance, and the result envelope; script parsing, execution, caps, and cancellation live behind `ctx.workflowEngine`, so a hardened engine swaps in without changing what the model sees. Usage guidance ships with the tool plugin as a prompt section, never in the deployment persona.
|
|
62
|
+
|
|
63
|
+
### Run lifecycle
|
|
64
|
+
|
|
65
|
+
`execute` starts the run and awaits `run.result` inside a `try/finally` that always disposes the run. `exec.signal` is bridged to `run.cancel()`, including the already-aborted-before-start case. A non-`completed` stop reason maps to an `isError` result reporting the reason; completion renders `{ runId, agentsStarted, result }`, with the Native renderer truncating only that projection at `maxResultChars`.
|
|
66
|
+
|
|
67
|
+
### Durable session records
|
|
68
|
+
|
|
69
|
+
For a root transport execution (`exec.parent` absent), the tool projects the run into the calling Agent's Session with four log-only events: run-start after `start()` returns, member starts and endings filtered by `run.id`, then run-end only after the result is available and disposal reaches quiescence. Nested transport calls execute normally but write no record. The first failed Session append disables later recording for that run with one warning, leaving either no record or a legal continuous prefix without changing the tool result or cleanup. The package invariant rejects duplicate starts, unpaired members, terminal events with open members, and updates after run-end on both cold load and live append, while accepting missing terminal suffixes.
|
|
70
|
+
|
|
71
|
+
### Render intent
|
|
72
|
+
|
|
73
|
+
Decided up front per the [render-intent Agent Note](../../../.agents/notes/implemented/architecture/2026-07-02-tool-render-intent-union.md): a `generic` card titled `workflow: <meta.name>`, read directly from `args.meta.name` — presentation is a pure function of args — with the script text carried as `rawInput`. The result keeps the generic card.
|
|
74
|
+
|
|
75
|
+
### Source map
|
|
76
|
+
|
|
77
|
+
| File | Role |
|
|
78
|
+
|---|---|
|
|
79
|
+
| [`src/index.ts`](src/index.ts) | Plugin entry: tool registration, run lifecycle, recorder wiring |
|
|
80
|
+
| [`src/types.ts`](src/types.ts) | The four log-only record event payloads and their `SessionEventMap` declaration |
|
|
81
|
+
| [`src/invariant.ts`](src/invariant.ts) | Invariant companion: durable workflow-record protocol validation |
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
-----
|
|
86
|
+
|
|
87
|
+
<a id="further-exploration"></a>
|
|
88
|
+
## Further Exploration
|
|
89
|
+
|
|
90
|
+
Read these pages when the tool-level contract is not enough. They move from the shared workflow model to the engine and the comparable delegation tool.
|
|
91
|
+
|
|
92
|
+
- [Workflow subsystem](../../../docs/subsystems/workflow.md) — the seam contract, start request, and event payloads.
|
|
93
|
+
- [Workflow seam](../workflow/README.md) — the run and result vocabulary behind the tool.
|
|
94
|
+
- [Worker-thread engine](../workflow-worker-thread/README.md) — the engine that executes the scripts.
|
|
95
|
+
- [subagent tool](../../subagent/tool-subagent/README.md) — the plain-delegation alternative for one or two children.
|
|
96
|
+
- [Group map](../README.md) — the workflow capability family and its packages.
|
|
97
|
+
- [Dynamic workflows Agent Note](../../../.agents/notes/implemented/feature/2026-07-05-dynamic-workflows.md) — the seam design and its decisions.
|
|
98
|
+
|
|
99
|
+
-----
|
|
100
|
+
|
|
101
|
+
<a id="model-experience"></a>
|
|
30
102
|
## Model Experience
|
|
31
103
|
|
|
32
104
|
### System prompt
|
|
@@ -53,7 +125,7 @@ Prefix-stable while the plugin scope and guidance text are unchanged. Activation
|
|
|
53
125
|
|
|
54
126
|
#### What the model sees
|
|
55
127
|
|
|
56
|
-
When visible, the generated default [`workflow` schema](../../../docs/tool-catalog.md#
|
|
128
|
+
When visible, the generated default [`workflow` schema](../../../docs/tool-catalog.md#xneogdsh-tool-workflow) carries the complete JavaScript hook and metadata contract; `toolName` can rename the definition, and the model submits script, metadata, and optional args.
|
|
57
129
|
|
|
58
130
|
#### Token effect
|
|
59
131
|
|
|
@@ -79,7 +151,24 @@ Append-only; newly visible content follows the reusable request prefix and does
|
|
|
79
151
|
|
|
80
152
|
## Known Limitations and Deferred Work
|
|
81
153
|
|
|
154
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
These limits define what the tool does not yet support. They are current constraints, not a task backlog.
|
|
158
|
+
|
|
82
159
|
- **The parent turn blocks until the whole workflow settles** — there is no background start/poll API, and cancellation discards partial output as an error.
|
|
83
|
-
- **`args` must be an object and Native result text is bounded** — callers wrap top-level arrays
|
|
160
|
+
- **`args` must be an object and Native result text is bounded** — callers wrap top-level arrays and scalars in a field; the canonical workflow result stays complete, while JSON beyond `maxResultChars` is truncated in the model-facing projection rather than stored behind a retrieval handle.
|
|
84
161
|
- **Workflow policy is fixed per tool registration** — provider selection, caps, and tool name are deployment config, not model-call arguments.
|
|
85
|
-
- **Durable records are top-level and observational** — nested
|
|
162
|
+
- **Durable records are top-level and observational** — nested PTC mode dispatches are not recorded, and a recording failure intentionally degrades to an incomplete prefix rather than changing execution.
|
|
163
|
+
|
|
164
|
+
<a id="dev-note"></a>
|
|
165
|
+
### Dev Note
|
|
166
|
+
|
|
167
|
+
<details>
|
|
168
|
+
<summary>Working context for maintainers — click to expand</summary>
|
|
169
|
+
|
|
170
|
+
This Dev Note is working context for maintainers: open directions that are not decided. It is explicitly non-authoritative — shipped behavior, limits, and accepted rationale live in the sections above, the package code, and the linked Agent Notes.
|
|
171
|
+
|
|
172
|
+
Open directions: a background start/poll route so the parent turn does not block; storing truncated JSON behind a retrieval handle instead of clipping the projection; recording nested dispatches beyond the top level.
|
|
173
|
+
|
|
174
|
+
</details>
|
package/README.zh.md
CHANGED
|
@@ -1,37 +1,109 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "面向模型的 workflow 工具:运行扇出 subagent 的 JavaScript 编排脚本,供选择或配置模型驱动编排的用户与维护者阅读。"
|
|
3
|
+
kind: "package-reference"
|
|
4
|
+
---
|
|
5
|
+
|
|
1
6
|
# @xneog/dsh-tool-workflow
|
|
2
7
|
|
|
3
8
|
[English](README.md) | 中文
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
`dsh-tool-workflow` 把 `workflow` 工具交给模型:以 JavaScript 编排脚本、身份块与可选参数调用它,它会在 `ctx.workflowEngine` 上运行脚本,把工作扇出到多个 subagent,直到脚本的最终值返回。该工具拥有模型侧 schema、系统提示词中的使用指导与结果包络;脚本解析、执行、上限与取消位于引擎之后。执行为前台:父级轮次会阻塞到整个工作流结算,非正常结束是错误,绝不是部分输出。仅当用户明确要求工作流式或大型多 agent 编排时选择它;一两项委派时优先使用普通 subagent 调用。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与延期工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
8
22
|
|
|
9
|
-
|
|
23
|
+
-----
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
`workflow` 工具运行由模型编写的编排脚本,把工作扇出到多个 subagent,并返回脚本的最终 JSON 值。仅当用户明确要求工作流或大型多 agent 编排时使用——例如跨多个文件的审计、一次迁移、多角度研究;一两项委派时优先使用普通 subagent 调用。
|
|
14
29
|
|
|
15
|
-
|
|
30
|
+
### 调用工具
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
模型提交三个参数:`meta`(必需的身份数据:`name`、`description`,以及可选的 `whenToUse` 与 `phases`)、`script`(必需的纯 JavaScript 脚本体——不含 `export const meta` 语句;工具描述携带完整的编写约定)与 `args`(可选 JSON 对象,作为全局变量 `args` 向脚本公开;裸列表应包装到字段中,使协议 schema 如实表达形态)。
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
成功返回规范包络 `{ runId, agentsStarted, result }`,向模型渲染为 `workflow "<name>" completed (<count> agent<optional-s>).`,后接 `Return value:` 与美化打印的 JSON。无法启动的工作流——脚本解析或 meta 校验失败——返回模型可以修正的错误。取消与执行失败返回 `Error: workflow run was cancelled` 或 `Error: workflow run failed: <error>`;部分输出绝不会被报告为成功。
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
### 运行期间的预期
|
|
22
37
|
|
|
23
|
-
|
|
38
|
+
脚本运行期间,父级轮次会等待:工具启动运行、等待其结果,并始终 dispose(资源释放)它,因此脚本及其子 agent 在每条路径上完全停稳——包括从父级步骤中止信号桥接而来的取消。模型只看到最终结果,永远不会看到中间子 agent 消息;子 agent 自己的工作不会进入父级对话。
|
|
24
39
|
|
|
25
|
-
|
|
40
|
+
### 配置
|
|
41
|
+
|
|
42
|
+
| 字段 | 默认值 | 含义 |
|
|
26
43
|
|---|---|---|
|
|
27
44
|
| `toolName` | `workflow` | 要注册的面向模型工具名称。 |
|
|
28
45
|
| `maxResultChars` | `50000` | 渲染结果上限;更长的 JSON 会被截断并附上提示。 |
|
|
29
46
|
|
|
47
|
+
生成的[配置目录](../../../docs/config-catalog.zh.md#xneogdsh-tool-workflow)是每个受支持字段的穷尽式真源。
|
|
48
|
+
|
|
49
|
+
-----
|
|
50
|
+
|
|
51
|
+
<a id="understand-the-implementation"></a>
|
|
52
|
+
## 理解实现
|
|
53
|
+
|
|
54
|
+
<details>
|
|
55
|
+
<summary>实现细节——点击展开</summary>
|
|
56
|
+
|
|
57
|
+
本节解释消费方如何与引擎拆分、运行生命周期与记录如何工作;可观察行为已在[使用本包](#use-this-package)中完整说明。
|
|
58
|
+
|
|
59
|
+
### 设计理念
|
|
60
|
+
|
|
61
|
+
消费方拥有模型侧 schema、`tool:<toolName>` 系统提示词指导与结果包络;脚本解析、执行、上限与取消位于 `ctx.workflowEngine` 之后,因此更坚固的引擎可以无缝替换,而不改变模型看到的内容。使用指导以提示词段的形式随工具插件交付,绝不放入部署 persona。
|
|
62
|
+
|
|
63
|
+
### 运行生命周期
|
|
64
|
+
|
|
65
|
+
`execute` 启动运行,并在 `try/finally` 内等待 `run.result`;该结构总会 dispose 运行。`exec.signal` 会桥接到 `run.cancel()`,包括启动前已经中止的情况。非 `completed` 结束原因会映射为报告原因的 `isError` 结果;完成时渲染 `{ runId, agentsStarted, result }`,Native 渲染器只会在 `maxResultChars` 处截断该投影。
|
|
66
|
+
|
|
67
|
+
### 持久会话记录
|
|
68
|
+
|
|
69
|
+
对于根 transport 执行(`exec.parent` 缺省),工具会用四个 log-only 事件把运行投影到调用 Agent 的 Session:`start()` 返回后写 run-start,只记录 `run.id` 匹配的成员开始与结束,并且只在结果可用且 dispose 完全停稳后写 run-end。嵌套 transport 调用照常执行,但不写任何记录。任一次 Session append 首次失败后,本运行会停止后续记录并只告警一次,留下空记录或合法连续前缀,同时不改变工具结果和清理。包 invariant 会在冷加载与实时追加时拒绝重复 start、未配对成员、仍有开放成员的终点与 run-end 后更新,同时允许缺失终态后缀的连续前缀。
|
|
70
|
+
|
|
71
|
+
### 渲染意图
|
|
72
|
+
|
|
73
|
+
按[渲染意图 Agent Note](../../../.agents/notes/implemented/architecture/2026-07-02-tool-render-intent-union.zh.md)预先确定:使用 `generic` 卡片,标题为 `workflow: <meta.name>`,直接从 `args.meta.name` 读取——呈现是参数的纯函数——脚本文本作为 `rawInput` 携带。结果继续使用 generic 卡片。
|
|
74
|
+
|
|
75
|
+
### 源码地图
|
|
76
|
+
|
|
77
|
+
| 文件 | 职责 |
|
|
78
|
+
|---|---|
|
|
79
|
+
| [`src/index.ts`](src/index.ts) | 插件入口:工具注册、运行生命周期、记录器接线 |
|
|
80
|
+
| [`src/types.ts`](src/types.ts) | 四个 log-only 记录事件 payload 及其 `SessionEventMap` 声明 |
|
|
81
|
+
| [`src/invariant.ts`](src/invariant.ts) | 不变式伴生插件:持久工作流记录协议校验 |
|
|
82
|
+
|
|
83
|
+
</details>
|
|
84
|
+
|
|
85
|
+
-----
|
|
86
|
+
|
|
87
|
+
<a id="further-exploration"></a>
|
|
88
|
+
## 进一步探索
|
|
89
|
+
|
|
90
|
+
当工具级契约不够用时阅读以下页面。它们从共享工作流模型逐步进入引擎与可比的委派工具。
|
|
91
|
+
|
|
92
|
+
- [工作流子系统](../../../docs/subsystems/workflow.zh.md)——seam 契约、启动请求与事件载荷。
|
|
93
|
+
- [工作流 seam](../workflow/README.zh.md)——工具背后的运行与结果词汇。
|
|
94
|
+
- [worker-thread 引擎](../workflow-worker-thread/README.zh.md)——执行脚本的引擎。
|
|
95
|
+
- [subagent 工具](../../subagent/tool-subagent/README.zh.md)——一两项委派时的普通委派替代方案。
|
|
96
|
+
- [组地图](../README.zh.md)——工作流能力家族及其包。
|
|
97
|
+
- [动态工作流 Agent Note](../../../.agents/notes/implemented/feature/2026-07-05-dynamic-workflows.zh.md)——seam 设计及其决策。
|
|
98
|
+
|
|
99
|
+
-----
|
|
100
|
+
|
|
101
|
+
<a id="model-experience"></a>
|
|
30
102
|
## 模型体验
|
|
31
103
|
|
|
32
104
|
### 系统提示词
|
|
33
105
|
|
|
34
|
-
####
|
|
106
|
+
#### 模型看到什么
|
|
35
107
|
|
|
36
108
|
在该插件的注册作用域内,每个父级请求都会收到下方的工作流指导。作用域工具限制可以隐藏 schema,而不移除这段独立注册的指导。
|
|
37
109
|
|
|
@@ -47,13 +119,13 @@ Use the <toolName> tool ONLY when the user explicitly asks for a workflow or for
|
|
|
47
119
|
|
|
48
120
|
#### KV Cache 影响
|
|
49
121
|
|
|
50
|
-
|
|
122
|
+
只要插件作用域与指导文本不变,前缀就保持稳定。启用或 dispose(资源释放)可能会使从该提示词段起的缓存复用失效。
|
|
51
123
|
|
|
52
124
|
### 工具 schema
|
|
53
125
|
|
|
54
|
-
####
|
|
126
|
+
#### 模型看到什么
|
|
55
127
|
|
|
56
|
-
工具可见时,已生成的默认 [`workflow` schema](../../../docs/tool-catalog.md#
|
|
128
|
+
工具可见时,已生成的默认 [`workflow` schema](../../../docs/tool-catalog.zh.md#xneogdsh-tool-workflow) 包含完整的 JavaScript 钩子与元数据约定;`toolName` 可以重命名该定义,模型会提交脚本、元数据与可选 args。
|
|
57
129
|
|
|
58
130
|
#### Token 影响
|
|
59
131
|
|
|
@@ -61,13 +133,13 @@ Use the <toolName> tool ONLY when the user explicitly asks for a workflow or for
|
|
|
61
133
|
|
|
62
134
|
#### KV Cache 影响
|
|
63
135
|
|
|
64
|
-
只要 `toolName
|
|
136
|
+
只要 `toolName`、定义与可见性不变,前缀就保持稳定。重命名、插件生命周期或作用域限制可能会使从该 schema 起的缓存复用失效。
|
|
65
137
|
|
|
66
138
|
### 工具调用历史与结果
|
|
67
139
|
|
|
68
|
-
####
|
|
140
|
+
#### 模型看到什么
|
|
69
141
|
|
|
70
|
-
|
|
142
|
+
由模型编写的完整脚本、元数据与 args 会保留在 assistant 工具调用中。成功结果精确为 `workflow "<name>" completed (<count> agent<optional-s>).`、换行、`Return value:`、换行,以及美化打印且依赖数据的 JSON;达到上限时,会在新行添加 `… [truncated: <omitted> more characters]`。失败结果精确为 `Error: workflow run was cancelled`(可以追加后缀 ` (<error>)`)、`Error: workflow run failed: <error-or-unknown error>` 或防御性的 `Error: workflow run ended abnormally (<reason>)`;没有所属 agent 的调用变为 `Error: workflow tool requires a calling agent (exec.agent was undefined)`。中间子 agent 消息会被省略。
|
|
71
143
|
|
|
72
144
|
#### Token 影响
|
|
73
145
|
|
|
@@ -77,9 +149,26 @@ Use the <toolName> tool ONLY when the user explicitly asks for a workflow or for
|
|
|
77
149
|
|
|
78
150
|
仅追加;新增可见内容位于可复用请求前缀之后,不会使现有 KV Cache 条目失效。
|
|
79
151
|
|
|
80
|
-
##
|
|
152
|
+
## 已知限制与延期工作
|
|
153
|
+
|
|
154
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
这些限制说明该工具尚未支持什么。它们是当前约束,不是任务积压。
|
|
158
|
+
|
|
159
|
+
- **父级轮次会阻塞到整个工作流结算**——没有后台启动/轮询接口,取消会丢弃局部输出并返回错误。
|
|
160
|
+
- **`args` 必须是对象,Native 结果文本有界**——调用方把顶层数组/标量包装到字段中;规范工作流结果保持完整,超过 `maxResultChars` 的 JSON 会在面向模型的投影中截断,而不是存储在检索句柄背后。
|
|
161
|
+
- **每次工具注册的工作流策略固定**——提供方选择、上限与工具名称属于部署配置,不是模型调用参数。
|
|
162
|
+
- **持久记录只覆盖顶层且只供观察**——嵌套 PTC mode dispatch 不记录;记录故障会刻意退化为不完整前缀,而不改变执行。
|
|
163
|
+
|
|
164
|
+
<a id="dev-note"></a>
|
|
165
|
+
### 开发备注
|
|
166
|
+
|
|
167
|
+
<details>
|
|
168
|
+
<summary>维护者的工作上下文——点击展开</summary>
|
|
169
|
+
|
|
170
|
+
本开发备注是维护者的工作上下文:尚未决定的开放方向。它明确不具权威性——已交付的行为、限制与既定理由以上文、包代码与相关 Agent Note 为准。
|
|
171
|
+
|
|
172
|
+
开放方向:让父级轮次不再阻塞的后台启动/轮询路径;把截断的 JSON 存储在检索句柄背后,而不是剪裁投影;记录超出顶层的嵌套 dispatch。
|
|
81
173
|
|
|
82
|
-
|
|
83
|
-
- **`args` 必须是对象,Native 结果文本有界**:调用方把顶层数组/标量包装到字段中;规范工作流结果保持完整,超过 `maxResultChars` 的 JSON 会在面向模型的投影中截断,而不是存储在检索句柄背后。
|
|
84
|
-
- **每次工具注册的工作流策略固定**:提供方选择、上限和工具名称属于部署配置,不是模型调用参数。
|
|
85
|
-
- **持久记录只覆盖顶层且只供观察**:嵌套 Code Mode dispatch 不记录;记录故障会刻意退化为不完整前缀,而不改变执行。
|
|
174
|
+
</details>
|
package/lib/index.js
CHANGED
|
@@ -137,7 +137,7 @@ function apply(ctx, config) {
|
|
|
137
137
|
const recorder = createWorkflowRecorder(ctx);
|
|
138
138
|
ctx.systemPrompt.section({
|
|
139
139
|
name: `tool:${toolName}`,
|
|
140
|
-
order:
|
|
140
|
+
order: ctx.systemPrompt.getSectionOrder("TOOL_WORKFLOW"),
|
|
141
141
|
text: `Use the ${toolName} tool ONLY when the user explicitly asks for a workflow or for large multi-agent orchestration: you write a JavaScript script (the tool description documents the exact format) that fans work out across many subagents with phases and structured results. For one or two delegations, prefer plain subagent calls.`
|
|
142
142
|
});
|
|
143
143
|
ctx.tools.register(defineTool({
|
package/lib/invariant.js
CHANGED
|
@@ -95,7 +95,7 @@ const install = Object.assign((ctx, fail) => {
|
|
|
95
95
|
const staged = /* @__PURE__ */ new WeakMap();
|
|
96
96
|
const seed = (session) => {
|
|
97
97
|
const trace = /* @__PURE__ */ new Map();
|
|
98
|
-
for (const event of session.
|
|
98
|
+
for (const event of session.snapshotEvents().filter(isWorkflowRecordEvent)) applyEvent(trace, event, fail);
|
|
99
99
|
traces.set(session, trace);
|
|
100
100
|
return trace;
|
|
101
101
|
};
|
package/lib/types/index.js
CHANGED
|
@@ -151,7 +151,7 @@ export function apply(ctx, config) {
|
|
|
151
151
|
// lives in tool plugins as prompt sections, not in the deployment persona).
|
|
152
152
|
ctx.systemPrompt.section({
|
|
153
153
|
name: `tool:${toolName}`,
|
|
154
|
-
order:
|
|
154
|
+
order: ctx.systemPrompt.getSectionOrder('TOOL_WORKFLOW'),
|
|
155
155
|
text: `Use the ${toolName} tool ONLY when the user explicitly asks for a workflow or for large multi-agent orchestration: you write a JavaScript script (the tool description documents the exact format) that fans work out across many subagents with phases and structured results. For one or two delegations, prefer plain subagent calls.`,
|
|
156
156
|
});
|
|
157
157
|
ctx.tools.register(defineTool({
|
package/lib/types/invariant.js
CHANGED
|
@@ -116,7 +116,7 @@ const install = Object.assign((ctx, fail) => {
|
|
|
116
116
|
const staged = new WeakMap();
|
|
117
117
|
const seed = (session) => {
|
|
118
118
|
const trace = new Map();
|
|
119
|
-
for (const event of session.
|
|
119
|
+
for (const event of session.snapshotEvents().filter(isWorkflowRecordEvent))
|
|
120
120
|
applyEvent(trace, event, fail);
|
|
121
121
|
traces.set(session, trace);
|
|
122
122
|
return trace;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xneog/dsh-tool-workflow",
|
|
3
3
|
"description": "Model-facing workflow tool: run a JavaScript orchestration script over ctx.workflowEngine",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.3-alpha.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -37,28 +37,29 @@
|
|
|
37
37
|
],
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@xneog/dsh-agent": "0.1.
|
|
41
|
-
"@xneog/dsh-
|
|
42
|
-
"@xneog/dsh-
|
|
43
|
-
"@xneog/dsh-
|
|
44
|
-
"@xneog/
|
|
45
|
-
"@xneog/dsh-
|
|
46
|
-
"@xneog/dsh-
|
|
47
|
-
"@xneog/
|
|
40
|
+
"@xneog/dsh-agent": "^0.1.3-alpha.1",
|
|
41
|
+
"@xneog/dsh-llm": "^0.1.3-alpha.1",
|
|
42
|
+
"@xneog/dsh-invariants": "^0.1.3-alpha.1",
|
|
43
|
+
"@xneog/dsh-system-prompt": "^0.1.3-alpha.1",
|
|
44
|
+
"@xneog/cordis": "^4.0.2",
|
|
45
|
+
"@xneog/dsh-workflow": "^0.1.3-alpha.1",
|
|
46
|
+
"@xneog/dsh-tools": "^0.1.3-alpha.1",
|
|
47
|
+
"@xneog/dsh-session": "^0.1.3-alpha.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@xneog/schemastery": "
|
|
50
|
+
"@xneog/schemastery": "^3.18.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@xneog/dsh-
|
|
54
|
-
"@xneog/dsh-
|
|
55
|
-
"@xneog/dsh-
|
|
56
|
-
"@xneog/dsh-
|
|
57
|
-
"@xneog/dsh-
|
|
58
|
-
"@xneog/dsh-
|
|
59
|
-
"@xneog/
|
|
60
|
-
"@xneog/dsh-
|
|
61
|
-
"@xneog/dsh-
|
|
62
|
-
"@xneog/
|
|
53
|
+
"@xneog/dsh-session": "^0.1.3-alpha.1",
|
|
54
|
+
"@xneog/dsh-llm": "^0.1.3-alpha.1",
|
|
55
|
+
"@xneog/dsh-agent": "^0.1.3-alpha.1",
|
|
56
|
+
"@xneog/dsh-invariants": "^0.1.3-alpha.1",
|
|
57
|
+
"@xneog/dsh-system-prompt": "^0.1.3-alpha.1",
|
|
58
|
+
"@xneog/dsh-workflow": "^0.1.3-alpha.1",
|
|
59
|
+
"@xneog/cordis": "^4.0.2",
|
|
60
|
+
"@xneog/dsh-subagent": "^0.1.3-alpha.1",
|
|
61
|
+
"@xneog/dsh-tools": "^0.1.3-alpha.1",
|
|
62
|
+
"@xneog/dsh-workflow-worker-thread": "^0.1.3-alpha.1",
|
|
63
|
+
"@xneog/dsh-session-projection": "^0.1.3-alpha.1"
|
|
63
64
|
}
|
|
64
65
|
}
|