dsh-plugin-prompt-tool 2.1.0 → 3.0.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/README.md +100 -233
- package/engine/actions/append-context.mjs +3 -24
- package/engine/actions/assembly.mjs +70 -94
- package/engine/actions/catalog.mjs +65 -28
- package/engine/actions/content.mjs +8 -152
- package/engine/actions/examples.mjs +8 -4
- package/engine/actions/inbox-prepend.mjs +4 -5
- package/engine/actions/index.mjs +17 -9
- package/engine/actions/inject-text.mjs +24 -4
- package/engine/actions/pre-step-filter.mjs +3 -4
- package/engine/actions/registration.mjs +20 -28
- package/engine/actions/request-params.mjs +21 -1
- package/engine/actions/shared.mjs +22 -13
- package/engine/actions/stream-output.mjs +26 -0
- package/engine/actions/tool-gate.mjs +31 -0
- package/engine/actions/tool-result.mjs +36 -0
- package/engine/actions/tool-visibility.mjs +248 -0
- package/engine/agent-capability.mjs +67 -0
- package/engine/anchor-match.mjs +14 -21
- package/engine/audience.d.mts +2 -0
- package/engine/audience.mjs +102 -0
- package/engine/branch.d.mts +4 -0
- package/engine/branch.mjs +61 -18
- package/engine/compaction-epoch.d.mts +25 -0
- package/engine/compaction-epoch.mjs +27 -4
- package/engine/compositions/source/local/filesystem-editor.yml +3 -3
- package/engine/compositions/source/local/instruction-hint.yml +2 -4
- package/engine/compositions/source/local/module-file-tools.yml +2 -0
- package/engine/compositions/source/local/module-import-tools.yml +4 -0
- package/engine/compositions/source/local/module-manifest-tools.yml +2 -0
- package/engine/compositions/source/local/module-rule-tools.yml +5 -0
- package/engine/compositions/source/local/module-variable-tools.yml +5 -0
- package/engine/compositions/source/local/present-as.yml +26 -0
- package/engine/compositions/source/local/tool-config-engine.yml +2 -3
- package/engine/compositions/source/local/tool-search.yml +11 -0
- package/engine/condition-facts.mjs +84 -0
- package/engine/conditions/anchor.mjs +63 -23
- package/engine/conditions/availability.mjs +1 -1
- package/engine/conditions/composite.mjs +3 -3
- package/engine/conditions/count.mjs +42 -11
- package/engine/conditions/evaluation.mjs +74 -19
- package/engine/conditions/examples.mjs +2 -1
- package/engine/conditions/index.d.mts +15 -0
- package/engine/conditions/index.mjs +23 -9
- package/engine/conditions/operators.mjs +4 -0
- package/engine/conditions/phase.mjs +9 -3
- package/engine/conditions/preset.mjs +1 -1
- package/engine/conditions/session.mjs +8 -2
- package/engine/conditions/subject.mjs +144 -65
- package/engine/conditions/text.mjs +26 -8
- package/engine/conditions/variable.mjs +83 -0
- package/engine/context-activation.d.mts +11 -0
- package/engine/{st-world-book.mjs → context-activation.mjs} +104 -64
- package/engine/delivery.d.mts +2 -0
- package/engine/delivery.mjs +93 -0
- package/engine/discovery.d.mts +38 -0
- package/engine/discovery.mjs +146 -0
- package/engine/env-safety.mjs +14 -0
- package/engine/executor.d.mts +28 -0
- package/engine/executor.mjs +290 -205
- package/engine/fillers.mjs +39 -8
- package/engine/fixed-registration.mjs +12 -0
- package/engine/history.mjs +71 -0
- package/engine/instruction-blocks.d.mts +13 -0
- package/engine/instruction-blocks.mjs +21 -0
- package/engine/instruction-files.d.mts +5 -0
- package/engine/instruction-files.mjs +97 -0
- package/engine/instruction-hint.mjs +69 -103
- package/engine/interpolate.d.mts +7 -0
- package/engine/interpolate.mjs +44 -13
- package/engine/layers.mjs +163 -227
- package/engine/machine-paths.mjs +40 -0
- package/engine/module-file-tools.mjs +8 -0
- package/engine/module-import-tools.mjs +10 -0
- package/engine/module-manifest-tools.mjs +8 -0
- package/engine/module-rule-tools.mjs +10 -0
- package/engine/module-variable-tools.mjs +10 -0
- package/engine/order.d.mts +14 -0
- package/engine/order.mjs +0 -3
- package/engine/path-safety.d.mts +2 -0
- package/engine/path-safety.mjs +58 -0
- package/engine/pre-step-source.d.mts +69 -0
- package/engine/pre-step-source.mjs +103 -0
- package/engine/present-as.mjs +77 -0
- package/engine/promotion-pool.d.mts +9 -0
- package/engine/promotion-pool.mjs +69 -0
- package/engine/record.mjs +2 -0
- package/engine/rule-engine.mjs +3 -2
- package/engine/rule-facts.d.mts +11 -0
- package/engine/rule-facts.mjs +60 -0
- package/engine/rule-runtime.d.mts +46 -0
- package/engine/rule-runtime.mjs +98 -13
- package/engine/rule-spec.d.mts +106 -0
- package/engine/rule-spec.mjs +301 -27
- package/engine/run-code-env.mjs +73 -19
- package/engine/schema.mjs +165 -243
- package/engine/sdk-strip.mjs +2 -2
- package/engine/service-names.d.mts +10 -0
- package/engine/service-names.mjs +10 -0
- package/engine/shared.d.mts +21 -0
- package/engine/shared.mjs +46 -13
- package/engine/skill-search.mjs +125 -53
- package/engine/source-kind.d.mts +9 -0
- package/engine/source-kind.mjs +16 -0
- package/engine/strategy-ids.mjs +5 -0
- package/engine/template-evaluation.d.mts +16 -0
- package/engine/template-evaluation.mjs +178 -0
- package/engine/template-frame.d.mts +16 -0
- package/engine/template-frame.mjs +69 -0
- package/engine/tool-config-engine.mjs +38 -34
- package/engine/tool-definition.d.mts +4 -0
- package/engine/tool-definition.mjs +5 -1
- package/engine/tool-git-bash.mjs +5 -1
- package/engine/tool-scope.mjs +22 -0
- package/engine/{dev-tool-search.mjs → tool-search.mjs} +63 -65
- package/engine/trigger.mjs +15 -270
- package/engine/vendor/yaml/dist/compose/resolve-flow-scalar.js +19 -18
- package/engine/vendor/yaml/dist/nodes/Alias.js +25 -23
- package/engine/vendor/yaml/package.json +1 -1
- package/lib/client.js +8312 -6724
- package/lib/client.js.map +1 -1
- package/lib/index.d.mts +16 -2120
- package/lib/index.mjs +26914 -5816
- package/modules/ponytail/module.yml +83 -203
- package/modules/ptc-mode/module.yml +45 -0
- package/modules/soul/assets/core-hard.md +6 -0
- package/modules/soul/assets/criteria.md +12 -0
- package/modules/soul/assets/echo.md +12 -0
- package/modules/soul/assets/layers.md +11 -0
- package/modules/soul/assets/ledger.md +9 -0
- package/modules/soul/assets/manifest.yml +20 -0
- package/modules/soul/assets/reference/00-layers.md +27 -0
- package/modules/soul/assets/reference/01-criteria.md +32 -0
- package/modules/soul/assets/reference/02-echo.md +158 -0
- package/modules/soul/assets/reference/03-vital.md +183 -0
- package/modules/soul/assets/reference/04-manifest.json +106 -0
- package/modules/soul/assets/reference/05-doctor.md +67 -0
- package/modules/soul/assets/reference/06-reference.md +189 -0
- package/modules/soul/assets/reference/07-bundle.json +431 -0
- package/modules/soul/assets/reference/08-/350/270/251/345/235/221/345/256/236/345/275/225.md +59 -0
- package/modules/soul/assets/reference/09-dev-workflow.md +109 -0
- package/modules/soul/assets/reference/10-echo-anatomy.md +100 -0
- package/modules/soul/assets/reference/11-self.md +80 -0
- package/modules/soul/assets/reference/12-ledger.md +159 -0
- package/modules/soul/assets/reference/README.md +10 -0
- package/modules/soul/assets/templates/agents-template.md +6 -0
- package/modules/soul/assets/vital.md +9 -0
- package/modules/soul/module.yml +311 -0
- package/modules/superpowers/module.yml +122 -0
- package/modules/tool-surface/module.yml +51 -47
- package/package.json +37 -40
- package/skills/dsh-module/SKILL.md +67 -147
- package/skills/dsh-module/reference.md +113 -86
- package/templates/10-pre-step.yml +2 -3
- package/templates/14-first-turn-anchor.yml +10 -14
- package/templates/15-guide-auto.yml +32 -28
- package/templates/16-custom-fallback.yml +33 -21
- package/templates/20-system-section.yml +1 -4
- package/templates/50-llm-stream.yml +4 -10
- package/templates/60-tool-pipeline.yml +12 -10
- package/templates/63-append-context.yml +4 -6
- package/templates/65-turn-stop.yml +2 -2
- package/templates/67-inbox-prepend.yml +2 -2
- package/templates/70-subagent-maintenance.yml +9 -10
- package/templates/75-subagent-end.yml +2 -2
- package/templates/80-tool-surface.yml +41 -57
- package/templates/tools/40-delegate-module-import.yml +22 -0
- package/templates/tools/50-delegate-module-rules.yml +14 -0
- package/templates/tools/60-delegate-module-variables.yml +17 -0
- package/templates/tools/70-delegate-module-rules-edit.yml +31 -0
- package/engine/actions/decision.mjs +0 -54
- package/engine/actions/guard.mjs +0 -80
- package/engine/actions/sdk-strip.mjs +0 -30
- package/engine/character-tools.mjs +0 -8
- package/engine/classify-task.mjs +0 -53
- package/engine/compositions/source/local/character-tools.yml +0 -5
- package/engine/compositions/source/local/dev-tool-search.yml +0 -11
- package/engine/compositions/source/local/session-var-tools.yml +0 -5
- package/engine/compositions/source/local/subagent-tool-policy.yml +0 -21
- package/engine/compositions/source/local/world-book-tools.yml +0 -5
- package/engine/condition.mjs +0 -96
- package/engine/declared-triggers.mjs +0 -93
- package/engine/session-var-tools.mjs +0 -8
- package/engine/session-vars.mjs +0 -54
- package/engine/st-macros.d.mts +0 -22
- package/engine/st-macros.mjs +0 -208
- package/engine/st-render.mjs +0 -109
- package/engine/st-world-book.d.mts +0 -10
- package/engine/subagent-tool-policy-core.mjs +0 -400
- package/engine/subagent-tool-policy.mjs +0 -352
- package/engine/trigger-spec.mjs +0 -173
- package/engine/world-book-tools.mjs +0 -8
- package/lib/migrate-rules.d.mts +0 -1
- package/lib/migrate-rules.mjs +0 -610
- package/lib/module-package-DqJZaE71.mjs +0 -2
- package/lib/module-package-q2gDRu9H.mjs +0 -2869
- package/lib/rule-builder-DMrJten6.mjs +0 -14767
- package/templates/61-deny-tools-presentation.yml +0 -27
- package/templates/62-guard-deny-tools.yml +0 -20
- package/templates/policies/legacy-defaults.yml +0 -34
- package/templates/tools/40-delegate-character.yml +0 -15
- package/templates/tools/50-delegate-worldbook.yml +0 -15
- package/templates/tools/60-delegate-session-var.yml +0 -15
- package/templates/tools/70-delegate-worldbook-upsert.yml +0 -36
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
而 `engine/`、`modules/`、`templates/` 在插件包里。包名 `dsh-plugin-prompt-tool`,定位用环境变量
|
|
11
11
|
`$env:DSH_PROFILE_DIR`(bash 里读 `$DSH_PROFILE_DIR`)——包就在它的 `node_modules/` 下。读包内文件用
|
|
12
12
|
**文件读取工具**:Desktop 部署下包可能落在 `app.asar` 里,shell、glob、grep、node 都打不开它。
|
|
13
|
-
|
|
13
|
+
找不到包时用本摘要说明边界;需要确认未列出的能力时读取实际安装契约,不猜测支持。
|
|
14
14
|
|
|
15
15
|
## 一、条件谓词(`if` 里能写什么)
|
|
16
16
|
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
|
|
21
21
|
| 谓词 | 字段 | 语义与边界 |
|
|
22
22
|
|---|---|---|
|
|
23
|
-
| `text` | `keys` / `secondaryKeys`
|
|
23
|
+
| `text` | `keys` / `secondaryKeys`,或单独 `minChars` / `maxChars`(含端点的非负安全整数);`logic`(any/all/not/notAny);`mode`(scan/prefix);`caseSensitive`;`wholeWords`;`useRegex`;`wordBoundary`;`subject` | 关键词与长度同时声明时取交集,minChars 不得大于 maxChars;userMessage 读取本批全部真实用户文本。动作级条件必须声明本通道可用的 subject;缺事实不执行 |
|
|
24
24
|
| `phase` | `promoted`(缺省 `true`=只匹配已晋升;`false`;`'ignore'` 必须同时写 `compacted`);`compacted`;`promoteOn`(`either`/`tool-call`/`assistant-message`);`includeSubagents`(缺省 false=子代理视为已晋升);`promoteGate` + `reasoningPattern`/`reasoningNegativePattern`/`reasoningFlags`;`maxPromoteSteps`;`promoteAfterFirstResponse` | 晋升相位。**单个节点表达不了「两个相位都命中」**,用 `any` 拼 `{promoted: true}` 与 `{compacted: true, promoted: false}` |
|
|
25
25
|
| `source` | `kind` / `plugin`(字符串或字符串数组,两个都写是**合取**);`caseSensitive`(缺省 true);`match`(`exact` 缺省 / `prefix`) | 消息来源。列举多值要析取时用 `any` 显式写两支 |
|
|
26
|
-
| `count` | `of`(`tool-call`/`tool-result`/`assistant-message`/`assistant-chars`/`user-message`/`turn`);`per`(`session` 缺省 / `turn`);`min` / `max` / `every`(**至少写一个**,否则恒真);`includeCurrent`;`delegated` |
|
|
26
|
+
| `count` | `of`(`tool-call`/`tool-result`/`assistant-message`/`assistant-chars`/`user-message`/`turn`);`per`(`session` 缺省 / `turn`);`min` / `max` / `every`(**至少写一个**,否则恒真);`includeCurrent`;`delegated` | 消息类信号按可见历史;tool-call/turn 按完整日志,冷启动按相同视图重建 |
|
|
27
27
|
| `names` | `allow` / `deny`;`caseSensitive`(缺省 true) | 名称名单:工具名(工具通道)、子代理 provider(`subagent/start`、`subagent/end`) |
|
|
28
28
|
| `session` | `type`(事件类型,如 `user/message`);`present`(缺省 `false`=该事件还没有);`delegated` | 会话态。判「首轮」用 `{type: user/message, present: false}` |
|
|
29
29
|
| `preset` | `presetId` | 当前**挂载**的官方会话预设;取不到时返回 `UNAVAILABLE`(不乐观放行) |
|
|
30
30
|
| `scope` | `audience`(`main`/`subagent`);`modelScope`(`all` 缺省 / `pro` / `flash`) | 受众与模型范围。这是**唯一**该写这些门的地方 |
|
|
31
|
-
| `anchor` | `keys
|
|
31
|
+
| `anchor` | `subject`(userMessage/assistantReasoning/assistantText/toolResult,缺省 assistantReasoning);`keys`;scan 模式可选既有匹配选项;`after: { action: seed }`;可选正整数 `fallbackAfter` | 当前可见已结算消息确认;缺省 prefix 只按 keys 作 ASCII 忽略大小写的字面前缀匹配,显式 secondaryKeys/caseSensitive/wholeWords/useRegex/logic/wordBoundary 一律拒绝,需这些选项时用 scan。关联只看同规则动作实际投递后的输出;第 N 个含所选内容块的完整输出仍未命中时兜底,中断模型消息不计,省略持续等待 |
|
|
32
32
|
|
|
33
33
|
拿不到必要事实时谓词返回 `UNAVAILABLE`:只有严格 `true` 才执行;`any` 遇已知 `true`、`all` 遇已知
|
|
34
34
|
`false` 仍可决断。
|
|
@@ -36,123 +36,150 @@
|
|
|
36
36
|
## 二、动作(`then` / `else` 里能写什么)
|
|
37
37
|
|
|
38
38
|
`then` 是非空数组;每个动作要有唯一非空 `id` 与合法 `kind`。动作级分支写成 `{ if, then, else }`
|
|
39
|
-
|
|
39
|
+
节点嵌在数组里,可嵌套。else 必须有对应 if;必要事实未知时两支都不执行。
|
|
40
40
|
|
|
41
41
|
| 动作 | 执行点 | 主要字段 | 失败时 |
|
|
42
42
|
|---|---|---|---|
|
|
43
|
-
| `inject-text` | 由
|
|
44
|
-
| `assembly` | `system-prompt/assemble` 下游 | `target.
|
|
45
|
-
| `
|
|
46
|
-
| `
|
|
47
|
-
| `
|
|
48
|
-
| `
|
|
43
|
+
| `inject-text` | 由 config.layer 决定(**六层可注入**,agent-request/llm-stream/tool-pipeline 只作展示归属) | layer、strategy(static/placeholder/context-activation)、position、dedupe、mergeMode、role、order、text/texts、params、templateFile、configKind | 空正文不生成投递;变量赋值模板另按显式求值事务处理 |
|
|
44
|
+
| `assembly` | `system-prompt/assemble` 下游 | `target.sections`(`add`/`remove` **或** `keep`)、`target.contexts`(`add`/`remove` **或** `clear`,二者互斥——并存编译期拒绝);`target.tools` 已移除 | 返回未改动的装配 |
|
|
45
|
+
| `tool-visibility` | system-prompt/assemble 下游 | allow 与/或 deny(先保留再剔除)、requireMatch(仅 allow)、discovery({ kind };tool/key 可选,只作断言);受众归 scope,提示归普通注入动作 | 呈现面失败保留原装配;执行闸失败留痕,不静默放行 |
|
|
46
|
+
| `tool-gate` | tools/pre-execute | decision(allow/deny/ask)、reason;工具名归 names 条件 | 一律放行——裁决 bug 不卡死调用 |
|
|
47
|
+
| `tool-result` | tools/post-execute | action(accept/replace/block)、text(仅 replace/block);工具名归 names 条件 | 一律接受——结果处理 bug 不把调用变成失败 |
|
|
48
|
+
| `append-context` | tools/post-execute | text;续跑用 inject-text 的 turn-stop 层 | 保持原结果 |
|
|
49
49
|
| `request-params` | `agent/request` 下游 | `patch`(浅合并)、`unset`(`{键: 期望值}`)、`replace`(整体替换) | 保持原请求配置 |
|
|
50
|
+
| `stream-output` | llm/stream | mode(pass 缺省 / replace)、text(替代正文) | 保持原流 |
|
|
50
51
|
| `inbox-prepend` | `agent/inbox/inserted`(emit,无 next) | `target`(`next-turn` 缺省 / `next-step`)、`text` | 不命中即什么都不做 |
|
|
51
52
|
| `pre-step-filter` | `agent/pre-step` 下游 | `sources` **或** `keepKinds`(互斥,未声明即不过滤)、`blockPlugins`(正交,空=关闭) | 异常时保留全部消息 |
|
|
52
53
|
|
|
53
54
|
通用规则:
|
|
54
55
|
|
|
55
|
-
-
|
|
56
|
-
- `allow` 与 `deny`
|
|
57
|
-
- `maxPerTurn`(正整数)用在 `assembly` / `
|
|
58
|
-
`
|
|
56
|
+
- 名单类参数(allow/deny/sources)写成逗号分隔字符串或字符串数组都接受。
|
|
57
|
+
- 工具可见面的 `allow` 与 `deny` 可以同时给:对齐官方 `ToolRestriction`,先按 `allow` 保留、再按 `deny` 剔除。
|
|
58
|
+
- `maxPerTurn`(正整数)用在 `assembly` / `tool-gate` / `tool-result` / `append-context` / `request-params` /
|
|
59
|
+
`inbox-prepend` / `pre-step-filter` 上;它数的是「本动作本轮生效几次」,
|
|
59
60
|
与 `count` 谓词(数持久事件)是两回事。
|
|
60
|
-
- `
|
|
61
|
+
- `complete` 与 `suppressRuntimeContext` 是**固定注册效果**:所在规则不带 `if`(注册期即生效)。
|
|
61
62
|
|
|
62
63
|
### 禁用或收窄某个工具
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
| 层次 | 动作 | 效果 |
|
|
67
|
-
|---|---|---|
|
|
68
|
-
| 呈现 | `assembly` + `target.tools.deny` | 本次请求的工具目录里没有它 |
|
|
69
|
-
| 文本 | `sdk-strip` + `mask.deny` | `tools:sdk` 段里的声明正文消失 |
|
|
70
|
-
| 执行 | `guard` + `mask.deny` | 真正调不动——经 `run_code` 的子调用同样被拒 |
|
|
65
|
+
工具的装配面由**会话原有预设**与各模块共同决定,所以「禁用」必须同时落到呈现与执行两层——只做一层会留下可见痕迹:
|
|
71
66
|
|
|
72
67
|
```yaml
|
|
73
68
|
rules:
|
|
74
|
-
- id: no-web
|
|
75
|
-
then:
|
|
76
|
-
- id: drop-from-assembly
|
|
77
|
-
kind: assembly
|
|
78
|
-
target: { tools: { deny: [web_search, web_fetch] } }
|
|
79
|
-
- id: strip-sdk-text
|
|
80
|
-
kind: sdk-strip
|
|
81
|
-
mask: { deny: [web_search, web_fetch] }
|
|
82
|
-
- id: no-web-execution # 固定注册效果:自成一条不带 if 的规则
|
|
69
|
+
- id: no-web
|
|
83
70
|
then:
|
|
84
|
-
- id:
|
|
85
|
-
kind:
|
|
86
|
-
|
|
71
|
+
- id: hide-web
|
|
72
|
+
kind: tool-visibility
|
|
73
|
+
deny: [web_search, web_fetch]
|
|
87
74
|
reason: 本模块不开放联网工具
|
|
88
75
|
```
|
|
89
76
|
|
|
90
|
-
|
|
77
|
+
一份 deny 名单同时裁装配目录、tools:sdk 正文,并在 agent scope 注册执行闸——会话原有预设装的行也归它裁决,经 run_code 的子调用同样被拒。要让禁用只作用于子代理,在规则或分支写 if.scope.audience: subagent;不设受众条件则两者都执行。
|
|
78
|
+
|
|
79
|
+
要收窄,用同一动作的 allow 白名单(范例见 modules/tool-surface/module.yml),并按需声明 discovery:
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
- id: narrow
|
|
83
|
+
kind: tool-visibility
|
|
84
|
+
allow: [pwsh, read, write, edit, glob, grep, todo_write, skill_search, skill_load, tool_search, bash]
|
|
85
|
+
discovery: { kind: tools }
|
|
86
|
+
requireMatch: true
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
声明 discovery 的模块必须在 modules 里列出对应适配器行(tools → tool-search),缺行在装配准备期失败。discovery 在首次装配时按 agent 解析适配器,并从持久 tool/call 与 PTC tool/ptc-dispatch 参数回收解锁名(只做加法、跨压缩保留);工具由适配器行注册,discovery.tool/key 可选、只作断言。提示用同规则普通 inject-text 组合 count(user-message,max: 1)与 session 去重,采用 strategy: placeholder、fill: tool-catalog、params: { action: narrow }。只读 RESIDENT_TOOLS 是引用动作 allow 去 deny 后的逗号名单,DISCOVERY_TOOL 是当前 Agent 的发现适配器工具名;模块 text 控制提示正文,保留自动名单而不复制声明。requireMatch 在任一常驻工具缺失时放弃裁剪、暴露完整目录(fail-open),声明名单不等同实时工具面。allow 的执行面由 guard 兜底,不调用 restrict——restrict 的 allow 只收继承面名字,而全局 schemas 视图会漏预设/祖先层工具,局部 allow 反而会把它们裁掉;deny 才用 restrict + guard。PTC 下 tools 数组只有保留传输 `run_code`,实际可见面是 `tools:sdk` 正文;`run_code` 不写进 allow 也保留,且不参与 requireMatch,因此原生收窄声明可以直接与 PTC 共存。
|
|
90
|
+
|
|
91
|
+
tool-catalog 引用目标必须有 allow;仅支持普通只读插值,`templateEvaluation: true` 拒绝。未知动作引用保存前拒绝,发现适配器不可用则跳过提示并告警。
|
|
91
92
|
|
|
92
93
|
## 三、九层与字段
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
|
100
|
-
|
|
101
|
-
| `
|
|
102
|
-
| `
|
|
103
|
-
| `
|
|
104
|
-
| `
|
|
105
|
-
| `
|
|
106
|
-
| `
|
|
107
|
-
| `
|
|
95
|
+
层是官方扩展点,彼此独立,没有跨层运行顺序。规则顶层 layer 是动作未声明 config.layer 时的缺省及展示归属;
|
|
96
|
+
动作显式声明 config.layer 时优先使用动作值(工具、装配、请求类动作自带执行点)。
|
|
97
|
+
|
|
98
|
+
层字段矩阵(`position` / `dedupe` / `promotion` / `audience` / `modelScope` / `merge` / `order` / `role` / `placeholder`;config 里写 `mergeMode`)由 `/meta` 的 `layerFieldPolicies` 下发,根 `module.yml` 也由同一份 `engine/schema.mjs` 生成;本文不再抄写,避免第三份副本漂移。
|
|
99
|
+
|
|
100
|
+
| 层 | 官方入口 | 可用策略 | 层内 `params` |
|
|
101
|
+
|---|---|---|---|
|
|
102
|
+
| `pre-step` | `agent/pre-step` 消息批 | static/placeholder/context-activation | — |
|
|
103
|
+
| `system-section` | `ctx.systemPrompt.section` | `static` | `sectionName` `complete` `suppressRuntimeContext` |
|
|
104
|
+
| `runtime-context` | `ctx.systemPrompt.context` | `static` `placeholder` | `contextName` |
|
|
105
|
+
| `agent-request` | `agent/request` | — | request-params 动作的 patch/unset/replace |
|
|
106
|
+
| `llm-stream` | `llm/stream` | — | stream-output 动作的 mode/text |
|
|
107
|
+
| `tool-pipeline` | 仅展示归属(**无注入通道**) | — | 工具链的裁决 / 结果处理 / 追加上下文改用 `tool-gate` / `tool-result` / `append-context` 动作 |
|
|
108
|
+
| `turn-stop` | `agent/turn-stopping` | `static` | — |
|
|
109
|
+
| `subagent-start` | `subagent/start` | `static` | — |
|
|
110
|
+
| `subagent-end` | `subagent/end` | `static` | `action`(`observe`/`inject-main`) |
|
|
108
111
|
|
|
109
112
|
三条边界:
|
|
110
113
|
|
|
111
|
-
1.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
时机的层。`complete` 是「唯一 system 段」(同一 scope 一个)。
|
|
114
|
+
1. 层字段以 `/meta` 的 `layerFieldPolicies` 为准:`position`/`role`/`promotion` 在 `pre-step`,`dedupe` 另支持 `turn-stop` 的 none/session。
|
|
115
|
+
2. 声明式 `config.subject`/`config.match` 已删除;live 条件在规则 `if` 里写 `text.subject` / `anchor.subject`,
|
|
116
|
+
可选值见 `/meta` 的 `subjects`。按任务内容分档放在 `pre-step`——`subagent/start` 的事件里只有
|
|
117
|
+
provider 与 id,没有任务文本。
|
|
118
|
+
3. system-section、runtime-context 的普通文本贡献支持规则级 if 和嵌套 `{ if, then, else }`,
|
|
119
|
+
每次 assembly 在条件文本贡献通道按当前事实求值,不动态重注册段;if.scope.audience 是常见写法。
|
|
120
|
+
complete / suppressRuntimeContext 属固定注册效果,仍拒绝动态条件分支;complete 表示同 scope 唯一 system 段。
|
|
119
121
|
|
|
120
|
-
策略 ×
|
|
121
|
-
|
|
122
|
+
策略 × 层:static 在六个可注入层;placeholder 在 pre-step、runtime-context;
|
|
123
|
+
context-activation 在 pre-step。分类与正文用通用条件和分支组合(模板15),动态内容策略使用既有 resolver。
|
|
122
124
|
|
|
123
|
-
|
|
125
|
+
### 确认后注入
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
先用普通 `inject-text` 动作投递自定义锚句,再在嵌套分支写 `if: { anchor: { keys: [已确认], after: { action: seed } } }`,then 使用另一个普通注入动作声明正文与位置。完整示例见包内 `templates/16-custom-fallback.yml`,运行边界见 [引擎指南](../../docs/engine-reuse.md#字词句确认与动作关联)。不要把等待条件放在锚句动作的父级,否则锚句也无法投递。
|
|
126
128
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
`after.action` 仅引用同规则 separate 模式的 pre-step/runtime-context/turn-stop 注入动作;缺引用、自引用、循环、投递身份歧义、system-section 与 merged 目标在编译时拒绝。未实际接纳或已不再可见的起点返回 UNAVAILABLE,旧输出和 fork 继承不算当前会话的新投递。当前可见上下文变化后重判;默认等下次正常请求,显式 turn-stop 续跑仍受预算和取消信号约束。
|
|
130
|
+
|
|
131
|
+
直接匹配当前 pre-step 用户消息用 `text.subject: userMessage`(模板14);`anchor.subject: userMessage` 看已接纳历史。确认词只写条件,正文只写动作;source.summary 是用户元数据,不生成动态确认/兜底说明。旧 first-turn-anchor、anchor-notice 策略与专属参数已移除,不保留兼容入口,也不自动修改用户模块。
|
|
132
|
+
|
|
133
|
+
## 四、能力、参数与数据所有权
|
|
134
|
+
|
|
135
|
+
能力目录以包内 engine/compositions/source/local 的实际文件为准;模块工具统一为 module-file-tools、module-import-tools、module-manifest-tools、module-rule-tools、module-variable-tools。
|
|
136
|
+
|
|
137
|
+
**模块装配清单**(固定 `assets/manifest.yml`,由 `module_manifest` 解释,工具不认业务字段):
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
dirs:
|
|
141
|
+
- data/10-宪章
|
|
142
|
+
files:
|
|
143
|
+
- from: assets/templates/agents-template.md
|
|
144
|
+
to: data/AGENTS.md
|
|
145
|
+
checks:
|
|
146
|
+
- path: data/02-墨.jsonl
|
|
147
|
+
kind: jsonl
|
|
148
|
+
maxBytes: 8388608
|
|
131
149
|
```
|
|
132
150
|
|
|
133
|
-
|
|
134
|
-
|
|
151
|
+
- `dirs` / `files.to` / `checks.path` 只允许 `data/`;`files.from` 只允许 `assets/`(必须存在,单文件 ≤ 1 MiB)。
|
|
152
|
+
- `checks.kind` ∈ `file`/`text`/`json`/`jsonl`;`maxBytes` 缺省 1 MiB。
|
|
153
|
+
- `action`:`next` 返回第一条缺失(`ok` = 是否已完成),`check` 返回全部检查结果(`ok` = 是否全部通过),`apply` 建目录并只落缺失文件(不覆盖、不删除)。
|
|
154
|
+
- 未知键、未知 kind、越界路径与链接都 fail loud。官方工具、规划、压缩与普通委派由会话原有预设提供,空模块不自动获得这些能力。
|
|
135
155
|
|
|
136
|
-
|
|
156
|
+
共享参数由 `ENGINE_PARAM_DEFINITIONS` 唯一登记,`storageLayer` 决定磁盘路径:主/子模型各有路由与采样键,另含 PTC 呈现(presentAsEnabled、ptcMainMode、ptcSubagentMode)、run_code 环境(runCodeEnvEnabled、runCodeEnvKeys)、Git Bash(toolGitBashEnabled、路径、超时、输出上限)、指令提示(instructionHint 及 promoteOn/includeSubagents/模板)和工具批准(customToolRequireApproval);完整键、options 与默认值以源码为准,不在摘要抄数量。模型卡在装配期合成 request-params 规则;未配置继承宿主。子代理递归深度归官方 `subagent.maxDepth`,插件不提供。
|
|
137
157
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
158
|
+
- persona.main/subagent:各模块保存 prefix/suffix/complete/includeRuntimeContext,省略继承、空文本清空、false 明确值;rules/_settings.yml 只作校验投影。
|
|
159
|
+
- config.yml.personaSources:main/subagent 各单选官方默认或一个模块 ID,不存正文、不自动启用 rules。只读取所选受众字段,不跨模块逐字段合并;有效官方人设与启用规则的 complete 仍预检,配装失败保留旧状态。
|
|
160
|
+
- variables:模块持久值,覆盖同安装 global;空串保留,删键才回落。普通规则手动建立变量,ST 导入自动登记缺失裸引用为空占位。
|
|
161
|
+
- customTools:shell/http/delegate/fs/ask-user,定义见包内 templates/tools。delegate 走官方工具管线。
|
|
162
|
+
- subagentToolPolicy:授权上限、工具档、角色绑定、任务规则与受控扩权;缺省官方委派。
|
|
163
|
+
- moduleConfigs:已声明共享参数优先于行级配置,不能绕过工具批准。
|
|
164
|
+
- configOrder:模块内规则id→非负序号,排序不修改正文和启停。
|
|
165
|
+
|
|
166
|
+
## 五、上下文激活与模板
|
|
167
|
+
|
|
168
|
+
`context-activation` 只在 pre-step 使用。`params.activation.scan` 必须为 batch 或 history;历史只扫描模型可见的真实对话,排除插件/指令/工具回执。`scanDepth:0` 不扫描聊天、变量和递归正文,常驻例外。
|
|
169
|
+
|
|
170
|
+
匹配共有字段:keys、secondaryKeys、constant、caseSensitive、wholeWords、useRegex、wordBoundary、selectiveLogic。词边界 unicode 为原生字母数字边界,ascii-token 为 ST 单词 ASCII/多词子串规则。副键先开启 activation.selective;P=主键命中数,S=副键命中数,N=原副键项数:
|
|
171
|
+
|
|
172
|
+
| 具名逻辑 | 条件 |
|
|
173
|
+
|---|---|
|
|
174
|
+
| AND_ANY | P>0 且 S>0 |
|
|
175
|
+
| NOT_ALL | P>0 且 S<N |
|
|
176
|
+
| NOT_ANY | P>0 且 S=0 |
|
|
177
|
+
| AND_ALL | P>0 且 S=N |
|
|
144
178
|
|
|
145
|
-
|
|
179
|
+
未开 selective 或无副键只要求 P>0;空主键不自动常驻。求值为空的副键仍占一项。activation 还拥有 scanVariables、概率、selectionGroup、评分、sticky/cooldown/delay、递归排除与延迟层级;它的候选组与规则 group/exclusive 不同。模块递归用 contextActivationRecursive,默认 false,池跨模块共享。
|
|
146
180
|
|
|
147
|
-
|
|
181
|
+
原生模板显式设置 params.templateEvaluation:true。module/global 的 set/get/add/inc/dec 在暂存变更集求值;同卡读到先前写入,单卡只写一个域,所有读取域都参与 CAS。扫描/预览只读。真实执行提交后跨出口和重挂不重放;跨进程崩溃不保证 exactly-once。
|
|
148
182
|
|
|
149
|
-
|
|
150
|
-
- `variables`:`{{键}}` 插值源;空字符串是合法占位(不按空值删键处理)。
|
|
151
|
-
- `customTools`:模型工具定义,执行器五种;结构见仓库 `templates/tools/*.yml`。
|
|
152
|
-
- `subagentToolPolicy`:`ceiling` / `defaultProfile` / `profiles` / `characterBindings` /
|
|
153
|
-
`taskRules` / `modelExpansion`;缺省时子代理走官方委派行为。
|
|
154
|
-
- `moduleConfigs`:行级 config 直写(优先级低于已声明的共享参数),给参数桥没覆盖的键用。
|
|
155
|
-
- `configOrder`:规则 id → 序号;缺省按声明序 ×10。切片里落在 `rules/_settings.yml`。
|
|
183
|
+
## 六、退役输入的显式转换
|
|
156
184
|
|
|
157
|
-
|
|
158
|
-
`rules/variables.yml` 是插件从它物化的切片。
|
|
185
|
+
旧 world-book/stWorldBook/stWorldBookRecursive/stMacros/stSource、动作 config.variables、扁平 persona 和旧工具能力不作为运行兼容面。重新导入标准 ST 或按 SKILL.md 的转换步骤改写;保留原件和私有记忆,不能靠删来源标记绕过分享保护。旧 API 别名不等于新工具授权。
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
# - configKind=anchor → 固定锚点序,按模块文件相对顺序排所有 ordered 之前(原 13-anchor)
|
|
5
5
|
# 接入:复制本文件到 模块规则模板目录,或把对象写入 module.yml.rules 数组。
|
|
6
6
|
# 保存前可 POST /api/prompt-tool/settings/rules 做权威校验。
|
|
7
|
-
# audience
|
|
7
|
+
# 受众写在规则 if.scope.audience(main/subagent);不设置即公用。
|
|
8
|
+
# 如需 {{WHO}},先在工作台的模块变量卡手动建立 WHO;本模板不自动登记变量。
|
|
8
9
|
id: example-pre-step
|
|
9
10
|
name: 示例:消息批注入
|
|
10
11
|
enabled: false
|
|
@@ -30,6 +31,4 @@ then:
|
|
|
30
31
|
value: example-pre-step
|
|
31
32
|
text: |
|
|
32
33
|
|
|
33
|
-
variables:
|
|
34
|
-
WHO: ''
|
|
35
34
|
params: {}
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# 纯净模板:参数全部留空,由用户自定义;锚句与分类正则由模板或用户配置提供,引擎不提供默认正文。
|
|
4
|
-
# 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
|
|
1
|
+
# 直接匹配真实用户消息,再以普通动作注入自定义正文。
|
|
2
|
+
# 确认词与正文由用户填写;复制分支可表达不同任务的注入规则。
|
|
5
3
|
id: example-first-turn-anchor
|
|
6
|
-
name:
|
|
4
|
+
name: 示例:匹配后注入
|
|
7
5
|
enabled: false
|
|
8
6
|
layer: pre-step
|
|
7
|
+
if:
|
|
8
|
+
text:
|
|
9
|
+
subject: userMessage
|
|
10
|
+
keys: [自定义触发词]
|
|
9
11
|
then:
|
|
10
12
|
- id: inject
|
|
11
13
|
kind: inject-text
|
|
12
14
|
config:
|
|
13
15
|
id: example-first-turn-anchor
|
|
14
16
|
layer: pre-step
|
|
15
|
-
strategy:
|
|
17
|
+
strategy: static
|
|
16
18
|
position: after-user
|
|
17
19
|
dedupe: session
|
|
18
20
|
configKind: ordered
|
|
19
21
|
order: 0
|
|
20
22
|
role: user
|
|
21
23
|
mergeMode: separate
|
|
22
|
-
sourceKind:
|
|
24
|
+
sourceKind: plugin
|
|
23
25
|
form: notice
|
|
24
26
|
params:
|
|
25
|
-
|
|
26
|
-
text: "" # 自定义锚文本(useCustom=true 时固定注入)
|
|
27
|
-
buildPattern: "" # 构建任务正则;留空 = 该分类不生效
|
|
28
|
-
complexPattern: "" # 复杂任务正则;留空 = 该分类不生效
|
|
29
|
-
firstTurnBuild: "" # 构建任务锚句(留空 = 不注入该类别锚句)
|
|
30
|
-
firstTurnInspect: "" # 排查任务锚句(留空 = 不注入该类别锚句)
|
|
31
|
-
firstTurnDeep: "" # 复杂设计锚句(留空 = 不注入该类别锚句)
|
|
27
|
+
text: "" # 自定义正文
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# 复杂任务自动引导句(留空 = 不注入该类别引导)
|
|
4
|
-
|
|
5
|
-
# 模板:每轮引导(strategy=guide-auto)
|
|
6
|
-
# 晋升后每轮用户消息后按复杂度注入弱/深度引导;modelScope=flash 表示仅 flash 模型会话注入。
|
|
7
|
-
# 纯净模板:参数全部留空,由用户自定义;引导句由模板或用户配置提供,留空不注入。
|
|
8
|
-
# 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
|
|
1
|
+
# 模板:按当前批次全部真实用户文本选择引导;正文留空,由用户填写后启用。
|
|
2
|
+
# minChars/maxChars 含端点;复杂度由正则或长度分支表达,无专用策略参数。
|
|
9
3
|
id: example-guide-auto
|
|
10
4
|
name: 示例:每轮引导
|
|
11
5
|
enabled: false
|
|
@@ -17,24 +11,34 @@ if:
|
|
|
17
11
|
- phase:
|
|
18
12
|
promoted: true
|
|
19
13
|
includeSubagents: false
|
|
14
|
+
- text:
|
|
15
|
+
subject: userMessage
|
|
16
|
+
minChars: 1
|
|
20
17
|
then:
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
- if:
|
|
19
|
+
any:
|
|
20
|
+
- text:
|
|
21
|
+
subject: userMessage
|
|
22
|
+
keys: ['复杂|重构|排查'] # 按需替换分类表达式
|
|
23
|
+
useRegex: true
|
|
24
|
+
- text:
|
|
25
|
+
subject: userMessage
|
|
26
|
+
minChars: 121
|
|
27
|
+
then:
|
|
28
|
+
- id: deep-guide
|
|
29
|
+
kind: inject-text
|
|
30
|
+
config:
|
|
31
|
+
layer: pre-step
|
|
32
|
+
strategy: static
|
|
33
|
+
position: after-user
|
|
34
|
+
dedupe: batch
|
|
35
|
+
text: "" # 复杂任务引导
|
|
36
|
+
else:
|
|
37
|
+
- id: weak-guide
|
|
38
|
+
kind: inject-text
|
|
39
|
+
config:
|
|
40
|
+
layer: pre-step
|
|
41
|
+
strategy: static
|
|
42
|
+
position: after-user
|
|
43
|
+
dedupe: batch
|
|
44
|
+
text: "" # 简单任务引导
|
|
@@ -1,35 +1,47 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# 两者都为空 = 不做词确认,只走未命中兜底注入(引擎不内置确认词)。
|
|
5
|
-
# 提示:把本文件放入 模块规则模板目录,或把对象写入 module.yml.rules 数组。
|
|
1
|
+
# 先投递锚句,仅确认该次投递后的模型推理,再注入正文。
|
|
2
|
+
# 默认持续等待;需要兜底时在 anchor 下显式添加 fallbackAfter: N。
|
|
3
|
+
# 默认等待下一次正常请求;续跑通过既有 turn-stop 规则显式配置。
|
|
6
4
|
id: example-custom-fallback
|
|
7
|
-
name:
|
|
5
|
+
name: 示例:锚句确认后注入
|
|
8
6
|
enabled: false
|
|
9
7
|
layer: pre-step
|
|
10
|
-
if:
|
|
11
|
-
all:
|
|
12
|
-
- phase:
|
|
13
|
-
promoted: true
|
|
14
|
-
includeSubagents: false
|
|
15
|
-
- anchor:
|
|
16
|
-
keys: []
|
|
17
|
-
fallbackAfter: 1
|
|
18
8
|
then:
|
|
19
|
-
- id:
|
|
9
|
+
- id: seed
|
|
20
10
|
kind: inject-text
|
|
21
11
|
config:
|
|
22
|
-
id: example-custom-fallback
|
|
12
|
+
id: example-custom-fallback-seed
|
|
23
13
|
layer: pre-step
|
|
24
|
-
strategy:
|
|
25
|
-
position:
|
|
14
|
+
strategy: static
|
|
15
|
+
position: after-user
|
|
26
16
|
dedupe: session
|
|
27
17
|
configKind: ordered
|
|
28
|
-
order:
|
|
18
|
+
order: 0
|
|
29
19
|
role: user
|
|
30
20
|
mergeMode: separate
|
|
31
21
|
sourceKind: plugin
|
|
32
22
|
form: notice
|
|
33
23
|
params:
|
|
34
|
-
text: "" #
|
|
35
|
-
|
|
24
|
+
text: "" # 自定义锚句,要求模型输出约定确认词
|
|
25
|
+
- if:
|
|
26
|
+
anchor:
|
|
27
|
+
subject: assistantReasoning
|
|
28
|
+
keys: [自定义确认词]
|
|
29
|
+
after:
|
|
30
|
+
action: seed
|
|
31
|
+
then:
|
|
32
|
+
- id: body
|
|
33
|
+
kind: inject-text
|
|
34
|
+
config:
|
|
35
|
+
id: example-custom-fallback-body
|
|
36
|
+
layer: pre-step
|
|
37
|
+
strategy: static
|
|
38
|
+
position: before-all
|
|
39
|
+
dedupe: session
|
|
40
|
+
configKind: ordered
|
|
41
|
+
order: 20
|
|
42
|
+
role: user
|
|
43
|
+
mergeMode: separate
|
|
44
|
+
sourceKind: plugin
|
|
45
|
+
form: notice
|
|
46
|
+
params:
|
|
47
|
+
text: "" # 自定义正文
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# 模板:system-section 静态 system 段(缓存友好,静态内容优先放这里)
|
|
2
2
|
# order 参考:-100 身份 / 0 persona-prefix / 100-199 工具引导 / 10200 persona-suffix。
|
|
3
|
-
#
|
|
4
|
-
# deployment:persona-suffix(第一方指导之后)时注册为人设段
|
|
5
|
-
# (同名 shadow 全局 persona,模块列表显示「人设」徽标;子代理经 scope 链继承)。
|
|
3
|
+
# 自定义系统段使用自己的 sectionName;官方人设覆盖由独立 persona.main/subagent 卡管理。
|
|
6
4
|
# - complete: true 让本段成为唯一的 system prompt 段(身份注入、人设后缀、工具指南等
|
|
7
5
|
# 其余 system 段全部被抑制;工具链、运行时上下文与变量仍保留)。同一模块只能有一个,
|
|
8
6
|
# 且与顶层人设的「独占」互斥:写盘前由 bridge 拒绝(400),装配前另有一道兜底校验,
|
|
@@ -22,7 +20,6 @@ then:
|
|
|
22
20
|
mergeMode: merged
|
|
23
21
|
text: |
|
|
24
22
|
|
|
25
|
-
variables: {}
|
|
26
23
|
params:
|
|
27
24
|
complete: false
|
|
28
25
|
suppressRuntimeContext: false
|
|
@@ -5,13 +5,7 @@ if:
|
|
|
5
5
|
scope:
|
|
6
6
|
modelScope: flash
|
|
7
7
|
then:
|
|
8
|
-
- id:
|
|
9
|
-
kind:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
layer: llm-stream
|
|
13
|
-
strategy: static
|
|
14
|
-
order: 0
|
|
15
|
-
text: "" # mode=replace 时替代整个模型流的文本
|
|
16
|
-
params:
|
|
17
|
-
mode: pass
|
|
8
|
+
- id: output
|
|
9
|
+
kind: stream-output
|
|
10
|
+
mode: pass
|
|
11
|
+
text: "" # mode=replace 时替代整个模型流的文本
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
#
|
|
1
|
+
# 模板:tool-pipeline 工具行为策略
|
|
2
|
+
#
|
|
3
|
+
# 工具链拆成两个动作、两个执行点:
|
|
4
|
+
# - `tool-gate`(tools/pre-execute):allow / deny / ask,只读 decision / reason;
|
|
5
|
+
# - `tool-result`(tools/post-execute):accept / replace / block,只读 action / text。
|
|
6
|
+
# 工具名只在共享 names 条件声明。
|
|
7
|
+
# 写错相位的字段在编译期就是未知字段,不会静默失效。
|
|
5
8
|
id: example-tool-pipeline
|
|
6
9
|
layer: tool-pipeline
|
|
10
|
+
if:
|
|
11
|
+
names:
|
|
12
|
+
allow: [bash, run_code]
|
|
7
13
|
then:
|
|
8
14
|
- id: before
|
|
9
|
-
kind:
|
|
10
|
-
phase: pre
|
|
15
|
+
kind: tool-gate
|
|
11
16
|
decision: allow
|
|
12
|
-
toolNames: bash,run_code
|
|
13
17
|
reason: 该工具被提示词配置禁用
|
|
14
18
|
- id: after
|
|
15
|
-
kind:
|
|
16
|
-
phase: post
|
|
19
|
+
kind: tool-result
|
|
17
20
|
action: accept
|
|
18
|
-
toolNames: bash,run_code
|
|
19
21
|
text: ""
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
# 模板:工具结果之后追加一条 durable user 通知。
|
|
2
2
|
#
|
|
3
|
-
# 与 `
|
|
3
|
+
# 与 `tool-result` 的分工:`tool-result` 改写的是**工具结果本身**(replace / block),
|
|
4
4
|
# `append-context` 不动结果,只在结果之后追加一条 user 角色通知。
|
|
5
|
-
#
|
|
6
|
-
#
|
|
5
|
+
# 需要模型**再做一步**时使用 `inject-text` 的 `turn-stop` 层(模板65),
|
|
6
|
+
# 每个来源(模块)每轮 1 次 / 每会话 3 次的上限由引擎内置,不能配置关闭(失控的续跑会把会话卡住)。
|
|
7
7
|
#
|
|
8
|
-
#
|
|
9
|
-
# 后者是动作自己的名单,前者决定这条规则要不要跑。
|
|
8
|
+
# 工具名条件统一用规则级或分支级 `if.names`(取自 exec.name)。
|
|
10
9
|
id: example-append-context
|
|
11
10
|
name: 工具结果后追加上下文
|
|
12
11
|
enabled: false
|
|
@@ -18,5 +17,4 @@ if:
|
|
|
18
17
|
then:
|
|
19
18
|
- id: note-after-tool
|
|
20
19
|
kind: append-context
|
|
21
|
-
mode: context
|
|
22
20
|
text: 网络结果可能已过期;引用它时说明来源与抓取时间。
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 模板:turn-stop 轮次停止层(命中条件时阻止本轮停止,强制模型续跑一步)
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# 接入:条件写在规则 if(本模板用 text);turn-stop 不再有 config.subject/match。
|
|
3
|
+
# 续跑上限固定在引擎内——每个来源(模块)每轮 1 次 / 每会话 3 次,配置关不掉。
|
|
4
4
|
id: example-turn-stop
|
|
5
5
|
name: 未完成时强制续跑
|
|
6
6
|
layer: turn-stop
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
# 不命中什么都不做。缺省 `target: next-turn`,也可写 `next-step`。
|
|
5
5
|
# 插件来源的消息(含本动作自己插入的那条)永不再次前置,防自触发插队。
|
|
6
6
|
#
|
|
7
|
-
# 判「首轮」用 `session: { type: user/message, present: false }
|
|
8
|
-
# user/message
|
|
7
|
+
# 判「首轮」用 `session: { type: user/message, present: false }`——模型**当前可见**
|
|
8
|
+
# 的上下文里还没有 user/message 事件(判据按可见上下文,压缩遮蔽的历史不算数)。注意 `agent/inbox/inserted` 拿不到任务文本本身,所以别在这里
|
|
9
9
|
# 用 `text` 谓词筛任务内容(那是 `pre-step` 层的事,见 70-subagent-maintenance.yml)。
|
|
10
10
|
id: example-inbox-prepend
|
|
11
11
|
name: 首轮前置一条消息
|