@thincoder/core 0.11.1 → 0.11.3
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/CHANGELOG.md +64 -2
- package/advisor/compaction.mjs +7 -5
- package/advisor/convergence.mjs +34 -3
- package/advisor/history.mjs +24 -11
- package/advisor/loop.mjs +49 -12
- package/advisor/messages.mjs +114 -33
- package/advisor/project-context.mjs +171 -42
- package/advisor/run.mjs +24 -10
- package/advisor.mjs +36 -46
- package/agent/batch-attribution.mjs +87 -0
- package/agent/batch-changed-surface.mjs +129 -0
- package/agent/chat-call.mjs +14 -9
- package/agent/completion.mjs +70 -41
- package/agent/continue-decision.mjs +14 -8
- package/agent/digest-account.mjs +133 -59
- package/agent/dispatch-gates.mjs +6 -0
- package/agent/dispatch-run.mjs +1 -1
- package/agent/dispatch.mjs +10 -4
- package/agent/family-tools.mjs +37 -23
- package/agent/helpers.mjs +139 -73
- package/agent/image-heal.mjs +18 -4
- package/agent/offload.mjs +25 -29
- package/agent/post-turn.mjs +36 -35
- package/agent/record-results.mjs +39 -7
- package/agent/run-stages.mjs +132 -52
- package/agent/run-start.mjs +150 -78
- package/agent/setup-reminders.mjs +194 -91
- package/agent/setup.mjs +219 -140
- package/agent/spawn-child.mjs +40 -3
- package/agent/suspension.mjs +43 -15
- package/agent/timers.mjs +9 -4
- package/agent/turn-domain-text.mjs +105 -0
- package/agent/turn-loop.mjs +84 -27
- package/agent/turn-projection.mjs +286 -0
- package/agent/turn-task-state.mjs +274 -0
- package/agent/turn-tool-process.mjs +163 -0
- package/agent/write-gate-ledger.mjs +569 -0
- package/agent/write-gate.mjs +29 -352
- package/agent-tools/advisor-async.mjs +35 -172
- package/agent-tools/advisor-launch.mjs +178 -0
- package/agent-tools/advisor-settle.mjs +28 -1
- package/agent-tools/advisor.mjs +37 -48
- package/agent-tools/async-discard.mjs +7 -2
- package/agent-tools/async-settle.mjs +18 -12
- package/agent-tools/audit-block.mjs +6 -6
- package/agent-tools/bash-async.mjs +5 -2
- package/agent-tools/batch-closeout.mjs +223 -35
- package/agent-tools/batch-gate.mjs +142 -342
- package/agent-tools/batch-ledger-bind.mjs +240 -20
- package/agent-tools/batch-ledger-view.mjs +109 -0
- package/agent-tools/batch-lifecycle.mjs +197 -48
- package/agent-tools/batch-paths.mjs +29 -8
- package/agent-tools/batch-read.mjs +151 -4
- package/agent-tools/batch-record-write.mjs +417 -0
- package/agent-tools/batch-regions.mjs +215 -0
- package/agent-tools/batch-reopen.mjs +23 -11
- package/agent-tools/batch-segment-vocab.mjs +459 -0
- package/agent-tools/batch-skeleton.mjs +196 -239
- package/agent-tools/batch-supersede.mjs +232 -0
- package/agent-tools/batch-tier-gate.mjs +214 -0
- package/agent-tools/batch.mjs +192 -439
- package/agent-tools/browser-async.mjs +5 -2
- package/agent-tools/consult.mjs +17 -11
- package/agent-tools/context.mjs +76 -33
- package/agent-tools/design-review-record.mjs +225 -0
- package/agent-tools/design-slots.mjs +1 -1
- package/agent-tools/design-token.mjs +279 -81
- package/agent-tools/digest-budget.mjs +10 -9
- package/agent-tools/doc-check.mjs +43 -33
- package/agent-tools/doc-graph.mjs +140 -0
- package/agent-tools/eng.mjs +12 -12
- package/agent-tools/escalate-async.mjs +5 -5
- package/agent-tools/goal.mjs +5 -2
- package/agent-tools/judge-domain.mjs +347 -0
- package/agent-tools/manifest.mjs +34 -18
- package/agent-tools/parent-channel.mjs +6 -3
- package/agent-tools/plan.mjs +11 -10
- package/agent-tools/read-history.mjs +112 -11
- package/agent-tools/review-facts.mjs +19 -6
- package/agent-tools/settings.mjs +23 -2
- package/agent-tools/skill.mjs +7 -8
- package/agent-tools/spawn-gates.mjs +14 -24
- package/agent-tools/ssh-session.mjs +8 -5
- package/agent-tools/ssh-text.mjs +155 -0
- package/agent-tools/ssh-transfer.mjs +1 -1
- package/agent-tools/ssh-transport.mjs +19 -148
- package/agent-tools/subagent-actions-query.mjs +10 -6
- package/agent-tools/subagent-actions.mjs +2 -2
- package/agent-tools/subagent-async.mjs +19 -17
- package/agent-tools/subagent-brief.mjs +76 -0
- package/agent-tools/subagent-design-token.mjs +168 -0
- package/agent-tools/subagent-run.mjs +1 -1
- package/agent-tools/subagent-scheduler.mjs +13 -13
- package/agent-tools/subagent-spawn.mjs +92 -112
- package/agent-tools/subagent.mjs +16 -28
- package/agent-tools/task.mjs +0 -8
- package/agent-tools/taskbook-block.mjs +94 -0
- package/agent-tools/timer.mjs +12 -8
- package/agent-tools/verify.mjs +13 -4
- package/agent-tools.mjs +7 -3
- package/agent.mjs +26 -7
- package/attachments.mjs +3 -3
- package/auto-think.mjs +5 -2
- package/browser/actions.mjs +9 -3
- package/browser/cdp.mjs +45 -17
- package/browser/launch.mjs +25 -43
- package/browser/pool.mjs +299 -0
- package/browser/queue.mjs +2 -0
- package/browser/session-state.mjs +450 -0
- package/browser/session.mjs +127 -151
- package/browser/snapshot.mjs +89 -0
- package/client-identity.mjs +1 -1
- package/compaction-work-state.mjs +230 -0
- package/compress-form.mjs +41 -6
- package/config-defaults.mjs +7 -3
- package/config-migrate.mjs +40 -0
- package/config-normalize.mjs +28 -2
- package/config-reload.mjs +59 -0
- package/config.mjs +110 -110
- package/context-degrade.mjs +93 -34
- package/context-echo.mjs +6 -15
- package/context-push.mjs +328 -31
- package/context.mjs +298 -170
- package/conventions.mjs +11 -9
- package/declaration.mjs +126 -22
- package/declared-repos.mjs +94 -0
- package/doc-check/doc-names.mjs +73 -0
- package/doc-check/doc-tokens.mjs +110 -0
- package/doc-check/existence.mjs +160 -0
- package/doc-check/index.mjs +309 -213
- package/doc-check/line-refs.mjs +27 -101
- package/doc-check/paragraph.mjs +218 -102
- package/doc-graph/anchors.mjs +474 -0
- package/doc-graph/doc-batch-face.mjs +59 -0
- package/doc-graph/doc-suffix.mjs +27 -0
- package/doc-graph/graph-tokens.mjs +160 -0
- package/doc-graph.mjs +778 -0
- package/escape.mjs +6 -5
- package/explore-distill.mjs +41 -8
- package/generate-title.mjs +10 -1
- package/i18n.mjs +1 -1
- package/instance-inbox-watch.mjs +272 -0
- package/instance-inbox.mjs +218 -0
- package/instance-registry.mjs +179 -0
- package/knowledge/README.md +3 -0
- package/knowledge/prompt-resources.md +10 -0
- package/ledger-close-proof.mjs +100 -49
- package/ledger-close.mjs +188 -0
- package/ledger-cmd.mjs +47 -91
- package/ledger-consistency.mjs +113 -0
- package/ledger-db.mjs +47 -15
- package/ledger-executors.mjs +1 -1
- package/ledger-tools.mjs +121 -62
- package/ledger-write-ops.mjs +162 -46
- package/ledger.mjs +1 -1
- package/manifest-discovery.mjs +3 -1
- package/manifest-schema.mjs +27 -5
- package/memory/docs.mjs +51 -15
- package/memory/file-list.mjs +6 -0
- package/memory/schema.mjs +2 -2
- package/model-specs.mjs +87 -21
- package/origin-guard.mjs +190 -0
- package/package.json +3 -1
- package/path-resolve.mjs +338 -57
- package/prompt-files.mjs +114 -2
- package/prompt-overlays.mjs +21 -11
- package/prompts/advisor-design.md +96 -36
- package/prompts/advisor-round1.md +48 -4
- package/prompts/advisor-round2.md +54 -10
- package/prompts/advisor-round3.md +53 -9
- package/prompts/common.md +99 -434
- package/prompts/consult-base.md +7 -4
- package/prompts/discipline-engineering.md +504 -295
- package/prompts/discipline-normal.md +106 -281
- package/prompts/knowledge/business-gates.md +30 -0
- package/prompts/knowledge/decision-quality.md +21 -0
- package/prompts/knowledge/doc-lookup.md +30 -0
- package/prompts/knowledge/document-writing.md +33 -0
- package/prompts/knowledge/documentation-evaluation.md +48 -0
- package/prompts/knowledge/evidence-discipline.md +38 -0
- package/prompts/knowledge/normal-coding-workflow.md +110 -0
- package/prompts/knowledge/normal-delivery-collaboration.md +124 -0
- package/prompts/knowledge/normal-work-management.md +60 -0
- package/prompts/knowledge/product-security.md +28 -0
- package/prompts/knowledge/project-records.md +73 -0
- package/prompts/knowledge/tool-advisor.md +29 -0
- package/prompts/knowledge/tool-apply-patch.md +17 -0
- package/prompts/knowledge/tool-bash.md +48 -0
- package/prompts/knowledge/tool-batch-eng-coder.md +19 -0
- package/prompts/knowledge/tool-batch-eng-designer.md +20 -0
- package/prompts/knowledge/tool-batch-review.md +18 -0
- package/prompts/knowledge/tool-batch.md +94 -0
- package/prompts/knowledge/tool-browser.md +68 -0
- package/prompts/knowledge/tool-code-search.md +4 -0
- package/prompts/knowledge/tool-consult-start.md +12 -0
- package/prompts/knowledge/tool-consult-stop.md +6 -0
- package/prompts/knowledge/tool-context.md +6 -0
- package/prompts/knowledge/tool-delete.md +21 -0
- package/prompts/knowledge/tool-doc-check.md +71 -0
- package/prompts/knowledge/tool-doc-graph-read.md +20 -0
- package/prompts/knowledge/tool-doc-graph.md +49 -0
- package/prompts/knowledge/tool-doc-search.md +6 -0
- package/prompts/knowledge/tool-edit.md +41 -0
- package/prompts/knowledge/tool-eng.md +2 -0
- package/prompts/knowledge/tool-execute.md +21 -0
- package/prompts/knowledge/tool-fetch.md +18 -0
- package/prompts/knowledge/tool-file-ops.md +21 -0
- package/prompts/knowledge/tool-get-current-time.md +7 -0
- package/prompts/knowledge/tool-git-read.md +21 -0
- package/prompts/knowledge/tool-git.md +29 -0
- package/prompts/knowledge/tool-glob.md +17 -0
- package/prompts/knowledge/tool-goal.md +8 -0
- package/prompts/knowledge/tool-grep.md +21 -0
- package/prompts/knowledge/tool-hashline-edit.md +16 -0
- package/prompts/knowledge/tool-insert-after.md +17 -0
- package/prompts/knowledge/tool-instance-list.md +6 -0
- package/prompts/knowledge/tool-instance-send.md +10 -0
- package/prompts/knowledge/tool-knowledge.md +18 -0
- package/prompts/knowledge/tool-ledger-read.md +28 -0
- package/prompts/knowledge/tool-ledger.md +46 -0
- package/prompts/knowledge/tool-lint.md +16 -0
- package/prompts/knowledge/tool-ls.md +15 -0
- package/prompts/knowledge/tool-lsp.md +11 -0
- package/prompts/knowledge/tool-main-history.md +2 -0
- package/prompts/knowledge/tool-manifest-read.md +14 -0
- package/prompts/knowledge/tool-manifest.md +34 -0
- package/prompts/knowledge/tool-memory-read.md +20 -0
- package/prompts/knowledge/tool-memory.md +19 -0
- package/prompts/knowledge/tool-notify-parent.md +12 -0
- package/prompts/knowledge/tool-operations.md +102 -0
- package/prompts/knowledge/tool-peer-instances.md +2 -0
- package/prompts/knowledge/tool-plan.md +5 -0
- package/prompts/knowledge/tool-process-read.md +13 -0
- package/prompts/knowledge/tool-process.md +15 -0
- package/prompts/knowledge/tool-question.md +16 -0
- package/prompts/knowledge/tool-read-history-batch.md +22 -0
- package/prompts/knowledge/tool-read-history.md +35 -0
- package/prompts/knowledge/tool-read-image.md +11 -0
- package/prompts/knowledge/tool-read.md +22 -0
- package/prompts/knowledge/tool-recent-changes.md +6 -0
- package/prompts/knowledge/tool-repo-outline.md +4 -0
- package/prompts/knowledge/tool-settings-read.md +12 -0
- package/prompts/knowledge/tool-settings.md +17 -0
- package/prompts/knowledge/tool-skill.md +6 -0
- package/prompts/knowledge/tool-ssh.md +74 -0
- package/prompts/knowledge/tool-subagent.md +57 -0
- package/prompts/knowledge/tool-task.md +14 -0
- package/prompts/knowledge/tool-team-ledger-read.md +11 -0
- package/prompts/knowledge/tool-team-ledger.md +15 -0
- package/prompts/knowledge/tool-timer.md +23 -0
- package/prompts/knowledge/tool-tree.md +16 -0
- package/prompts/knowledge/tool-verify.md +19 -0
- package/prompts/knowledge/tool-wait-for.md +25 -0
- package/prompts/knowledge/tool-websearch.md +19 -0
- package/prompts/knowledge/tool-write.md +12 -0
- package/prompts/knowledge/upstream-protocol.md +45 -0
- package/prompts/persona-coder.md +1 -3
- package/prompts/persona-eng-coder.md +24 -6
- package/prompts/persona-eng-designer.md +150 -171
- package/prompts/persona-engineering.md +531 -442
- package/prompts/persona-explore.md +1 -3
- package/prompts/persona-normal.md +17 -9
- package/prompts/persona-plan.md +5 -3
- package/prompts/persona-tester.md +0 -2
- package/prompts/subagent-base.md +2 -2
- package/provider/anthropic.mjs +10 -6
- package/provider/core.mjs +8 -5
- package/provider/errors.mjs +63 -4
- package/provider/google.mjs +29 -10
- package/provider/reasoning-echo.mjs +16 -0
- package/provider/responses.mjs +7 -3
- package/provider/sse.mjs +11 -6
- package/provider-flows.mjs +2 -2
- package/rules.mjs +11 -10
- package/session-index-build.mjs +1 -1
- package/session-index-pass.mjs +1 -1
- package/session-index-query.mjs +1 -1
- package/session-index.mjs +1 -1
- package/session-lifecycle.mjs +131 -42
- package/session-slot-write.mjs +38 -6
- package/session.mjs +30 -11
- package/shell-identity.mjs +129 -22
- package/skip-dirs.mjs +26 -2
- package/team-ledger.mjs +34 -30
- package/text-budget.mjs +1 -1
- package/think-off.mjs +27 -0
- package/token-ttl.mjs +74 -5
- package/token-window.mjs +371 -47
- package/tool-docs/advisor.md +2 -27
- package/tool-docs/apply_patch.md +1 -15
- package/tool-docs/bash.md +2 -43
- package/tool-docs/batch-eng-coder.md +3 -0
- package/tool-docs/batch-eng-designer.md +3 -0
- package/tool-docs/batch-review.md +3 -0
- package/tool-docs/batch.md +2 -84
- package/tool-docs/browser.md +2 -49
- package/tool-docs/code_search.md +2 -2
- package/tool-docs/consult_start.md +2 -8
- package/tool-docs/consult_stop.md +2 -4
- package/tool-docs/context.md +1 -5
- package/tool-docs/delete.md +2 -17
- package/tool-docs/doc_check.md +2 -107
- package/tool-docs/doc_graph-read.md +3 -0
- package/tool-docs/doc_graph.md +3 -0
- package/tool-docs/doc_search.md +2 -4
- package/tool-docs/edit.md +1 -38
- package/tool-docs/eng.md +3 -1
- package/tool-docs/execute.md +2 -18
- package/tool-docs/fetch.md +2 -14
- package/tool-docs/file_ops.md +2 -18
- package/tool-docs/get_current_time.md +1 -6
- package/tool-docs/git-read.md +3 -0
- package/tool-docs/git.md +2 -35
- package/tool-docs/glob.md +2 -10
- package/tool-docs/goal.md +1 -6
- package/tool-docs/grep.md +2 -18
- package/tool-docs/hashline_edit.md +2 -15
- package/tool-docs/insert_after.md +2 -16
- package/tool-docs/instance_list.md +3 -0
- package/tool-docs/instance_send.md +3 -0
- package/tool-docs/knowledge.md +3 -0
- package/tool-docs/ledger-read.md +3 -0
- package/tool-docs/ledger.md +3 -8
- package/tool-docs/lint.md +2 -10
- package/tool-docs/ls.md +2 -11
- package/tool-docs/lsp.md +2 -9
- package/tool-docs/main_history.md +3 -1
- package/tool-docs/manifest-read.md +2 -8
- package/tool-docs/manifest.md +2 -35
- package/tool-docs/memory-read.md +3 -0
- package/tool-docs/memory.md +2 -20
- package/tool-docs/notify_parent.md +2 -13
- package/tool-docs/peer_instances.md +3 -1
- package/tool-docs/plan.md +1 -5
- package/tool-docs/process-read.md +3 -0
- package/tool-docs/process.md +2 -13
- package/tool-docs/question.md +3 -17
- package/tool-docs/read.md +2 -19
- package/tool-docs/read_history-batch.md +3 -0
- package/tool-docs/read_history.md +2 -18
- package/tool-docs/read_image.md +2 -9
- package/tool-docs/recent_changes.md +2 -2
- package/tool-docs/repo_outline.md +2 -2
- package/tool-docs/settings-read.md +3 -0
- package/tool-docs/settings.md +1 -12
- package/tool-docs/skill.md +2 -6
- package/tool-docs/ssh.md +1 -62
- package/tool-docs/subagent.md +2 -100
- package/tool-docs/task.md +1 -7
- package/tool-docs/team_ledger-read.md +3 -0
- package/tool-docs/team_ledger.md +3 -9
- package/tool-docs/timer.md +2 -19
- package/tool-docs/tree.md +2 -13
- package/tool-docs/verify.md +2 -12
- package/tool-docs/wait_for.md +2 -32
- package/tool-docs/websearch.md +2 -19
- package/tool-docs/write.md +2 -12
- package/tools/browser.mjs +54 -9
- package/tools/doc-write-gate.mjs +73 -0
- package/tools/edit-batch.mjs +170 -92
- package/tools/edit-diff.mjs +78 -62
- package/tools/edit-receipt.mjs +39 -0
- package/tools/execute.mjs +3 -3
- package/tools/file.mjs +28 -14
- package/tools/git.mjs +36 -21
- package/tools/index.mjs +6 -0
- package/tools/knowledge.mjs +143 -0
- package/tools/linter.mjs +3 -3
- package/tools/ops.mjs +5 -3
- package/tools/patch.mjs +124 -44
- package/tools/process-doc-mark.mjs +33 -4
- package/tools/repomap.mjs +25 -3
- package/tools/search.mjs +74 -26
- package/tools/shared.mjs +29 -27
- package/tools/ssh.mjs +5 -5
- package/tools/tree.mjs +32 -10
- package/tools/web-deepseek.mjs +1 -1
- package/tools/web.mjs +2 -2
- package/tools/write-gate-params.mjs +31 -0
- package/tools/write-path.mjs +16 -4
- package/window-policy.mjs +243 -0
- package/doc-check/anchors.mjs +0 -235
|
@@ -40,7 +40,7 @@ export function drainInjectedQueue(entry, agent) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* Async branch (AGENT-LOOP-SUBAGENT.md §6.7.3
|
|
43
|
+
* Async branch (AGENT-LOOP-SUBAGENT.md §6.7.3): spawn without waiting.
|
|
44
44
|
* The child runs the EXACT blocking pipeline (runChildPipeline — relay /
|
|
45
45
|
* turn-cap / permission / MIN_REPORT_CHARS / mergeChildMutations all unchanged),
|
|
46
46
|
* but the parent does not await it: the promise is parked in _asyncSubagents and
|
|
@@ -16,9 +16,9 @@ import { existsSync, statSync } from "node:fs"
|
|
|
16
16
|
import { logEvent } from "../log.mjs"
|
|
17
17
|
// M5 F6(ENGINEERING-MODE-V2-MODULE-DELEGATION §2.3):files 声明面拦截谓词本体落
|
|
18
18
|
// spawn-gates.mjs(纯谓词零依赖——本处只加 import 调用,无环)。
|
|
19
|
-
import {
|
|
20
|
-
// `files` 落点单源 = 统一解析层(`docs/core/design/PATH-RESOLUTION.md` §2.5
|
|
21
|
-
// `order:"near-first"` ⇒ 恒解析出、只做调度、不校验存在性)。门判(目录声明 /
|
|
19
|
+
import { rejectParentOwnedPaths } from "./spawn-gates.mjs"
|
|
20
|
+
// `files` 落点单源 = 统一解析层(`docs/core/design/PATH-RESOLUTION.md` §2.5 的「子代理 `files`(spawn 门)」行:`kind:"none"` /
|
|
21
|
+
// `order:"near-first"` ⇒ 恒解析出、只做调度、不校验存在性)。门判(目录声明 / 项目状态档)
|
|
22
22
|
// 仍吃**原始声明形状**——判据在转绝对之前跑,顺序零改。
|
|
23
23
|
import { resolvePathTarget } from "../path-resolve.mjs"
|
|
24
24
|
import { poolLimitsFor, runningPoolCount, ASYNC_POOL_LIMITS } from "./subagent-async.mjs"
|
|
@@ -45,10 +45,10 @@ import { carrierField, getAsyncPool, tombstoneOf } from "./async-settle.mjs"
|
|
|
45
45
|
* 调用方(subagent.mjs spawn 入口)catch → 错误即工具结果(模型可见——无静默)。
|
|
46
46
|
* 已知限制(评审 #4):不存在的目录声明(无尾斜杠 + 目录未创建)仍通过——不处理。
|
|
47
47
|
* R26(2026-09-07):父侧维护文件黑名单——归一化后 basename 全名匹配 +
|
|
48
|
-
*
|
|
48
|
+
* 大小写不敏感(路径任意层含 docs/、根、.thincoder/)——
|
|
49
49
|
* 命中 → throw(fail-closed——先于调度器准入——无排队残留——错误即工具结果);
|
|
50
50
|
* 提示列出全部违规条目——英文模板逐字定稿(AGENT-LOOP-SUBAGENT.md §6.9「父侧文件拦截(R26)」)。
|
|
51
|
-
* M5 F6(2026-09-17——2026-10-15 口径随正):黑名单随同迁入 spawn-gates.mjs(族 =
|
|
51
|
+
* M5 F6(2026-09-17——2026-10-15 口径随正):黑名单随同迁入 spawn-gates.mjs(族 = 项目状态档(PROJECT-MANIFEST.json))——本函数只留调用(错误文案逐字保留)。 */
|
|
52
52
|
export function normalizeFileList(files, cwd) {
|
|
53
53
|
const out = []
|
|
54
54
|
for (const f of Array.isArray(files) ? files : []) {
|
|
@@ -64,11 +64,11 @@ export function normalizeFileList(files, cwd) {
|
|
|
64
64
|
}
|
|
65
65
|
if (!out.includes(abs)) out.push(abs)
|
|
66
66
|
}
|
|
67
|
-
// M5 F6(ENGINEERING-MODE-V2-MODULE-DELEGATION §2.2——2026-10-15
|
|
67
|
+
// M5 F6(ENGINEERING-MODE-V2-MODULE-DELEGATION §2.2——2026-10-15 口径随正):项目状态档拦截——
|
|
68
68
|
// 谓词本体落 spawn-gates.mjs(收集全部违规 + 抛合并错误);
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
if (files !== undefined && files !== null)
|
|
69
|
+
// 循环内目录声明先行(错误序不变——目录错误先于谓词错误)。
|
|
70
|
+
// 错误文案逐字保留。
|
|
71
|
+
if (files !== undefined && files !== null) rejectParentOwnedPaths(files)
|
|
72
72
|
return out
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -151,7 +151,7 @@ export function describeBlockers(parent, entry) {
|
|
|
151
151
|
if (info.state === "pending" || info.state === "unknown") {
|
|
152
152
|
wait.push(`${info.role ?? "sub"}#${depId}(依赖未完成)`)
|
|
153
153
|
} else if (info.state === "cancelled" || info.state === "failed") {
|
|
154
|
-
if (parent.autoApprove) continue // AUTO 档自动启动(D-SD5
|
|
154
|
+
if (parent.autoApprove) continue // AUTO 档自动启动(D-SD5——审批已放行:批准档决定问不问用户,与轮型无关)
|
|
155
155
|
depc.push(`${info.role ?? "sub"}#${depId}`)
|
|
156
156
|
}
|
|
157
157
|
}
|
|
@@ -191,7 +191,7 @@ export function describeBlockers(parent, entry) {
|
|
|
191
191
|
* 三条判据各防一个具体的错:① 池**经访问器读**(`getAsyncPool`,读法同 `depInfo`)——
|
|
192
192
|
* 裸读 `parent._asyncSubagents` 在只携 `history` 的合成 parent 上读到空池 ⇒ 护栏不报错、
|
|
193
193
|
* 不生效、没人知道;② **按 status 过滤**(`done` / `cancelled` 皆假)——正常 settle 的条目
|
|
194
|
-
* 留在池里(`async-settle.mjs
|
|
194
|
+
* 留在池里(`async-settle.mjs` 的「留池 done-in-pool」段)⇒ 只看「池里有同档条目」会把单席顺序交接全部误拒;
|
|
195
195
|
* ③ **占用判据只认 `_batchDoc`、不分角色**(普通面 coder 携档也算),而被检面只有工程角色的
|
|
196
196
|
* spawn、sync spawn 不入池也不是占用者(同档 §6.58.7 第 7 条)——**这个不对称勿「顺手统一」**。
|
|
197
197
|
* 入参 = 已解析的绝对路径(唯一消费方 `buildSpawnChild` 的工程分支,路径由 `resolveBatchReadPath`
|
|
@@ -374,7 +374,7 @@ export function dependentLabels(parent, depId) {
|
|
|
374
374
|
/** §6.9 D-SD3b 排队态面板刷新(⟦ev⟧queued 事件族——TUI routeSubToken 消费):对全部
|
|
375
375
|
* queued 条目重算等待态并发射变化(去重 sig——kind/position/detail 全变才发)——
|
|
376
376
|
* 调用点 = 一切队列突变与等待态变迁(spawn 入队 / settle 后补位与依赖转移 / cancel
|
|
377
|
-
* 出队 / 自动通道消费)。position =
|
|
377
|
+
* 出队 / 自动通道消费)。position = 队列序(§6.7.3 既有——cancel 前移同源)。
|
|
378
378
|
* P1 禁静默(zero-block 批 §6.8.3.2②):relay 异常不再静默——留痕一条
|
|
379
379
|
* `ev:queued-paint-failed`(**池状态不被破坏**语义不变——catch 不重抛)。 */
|
|
380
380
|
export function refreshQueuedTokens(parent, onToken) {
|
|
@@ -396,7 +396,7 @@ export function refreshQueuedTokens(parent, onToken) {
|
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
/**
|
|
399
|
-
* Slot-queue refill (AGENT-LOOP-SUBAGENT.md §6.7.3
|
|
399
|
+
* Slot-queue refill (AGENT-LOOP-SUBAGENT.md §6.7.3 + §6.9 D-SD4 + AGENT-LOOP-ASYNC-POOL.md §6.10 D-24a/R14 分域):
|
|
400
400
|
* start queue heads while a running slot is free — called from every settle
|
|
401
401
|
* (completion frees a slot) and from the turn-end collection's refill loop. 队列现可混合 waiting-deps 与 slot-queued——扫描选"依赖全满足 + 域无冲突"的最早
|
|
402
402
|
* 条目启动(waiting 越行不阻塞槽位;多任务同时解除按 queued 序逐个启动)。
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* subagent-spawn.mjs — spawn 路径装配(2026-09-05 module-split:subagent.mjs 726
|
|
3
|
-
* > 500 硬限——spawn 前置 helpers(effectiveSubagentModel
|
|
4
|
-
* 构造器 2026-09-22 起另立 ./audit-block.mjs)+ AGENT-LOOP-SUBAGENT.md §6.9 调度参数准入(prepareScheduling)+ child 装配
|
|
3
|
+
* > 500 硬限——spawn 前置 helpers(effectiveSubagentModel)+ AGENT-LOOP-SUBAGENT.md §6.9 调度参数准入(prepareScheduling)+ child 装配
|
|
5
4
|
* (buildSpawnChild)verbatim 迁入(仅闭包变量参数化),语义零变;executeAsyncSpawn
|
|
6
5
|
* 另在 subagent-run.mjs。subagent.mjs execute 经本文件 import 调用。
|
|
6
|
+
* **本轮(档位 500 设计器硬线)再切两族**:任务书与 system 固块拼装 → `./subagent-brief.mjs`、
|
|
7
|
+
* 设计令牌门 → `./subagent-design-token.mjs`(落点 = `docs/core/design/PATH-RESOLUTION.md` §3 末条)。
|
|
8
|
+
* **两族的对外面各不相同、各自守住**:设计令牌族**原样再导出**(`subagent.mjs` 的再导出行与用例的 import 行零改);
|
|
9
|
+
* 任务书族由本档直接 import 消费,不对外导出(今天没有任何调用点从本档取它)。
|
|
7
10
|
* 2026-09-07:executeConsumeDesignAction 消费执行器(token 链终消费制——与 spawn 侧
|
|
8
11
|
* slot 族同域——ENGINEERING-MODE.md §2.6 F1——removeDesignTokenSlot 自 token-ttl.mjs)。
|
|
9
12
|
* 2026-09-22(台账 #23 · AGENT-LOOP-SUBAGENT.md §6.26):审计块构造器外提 `./audit-block.mjs`;
|
|
10
13
|
* spawn 级固定机制性指令改走 system 固块(`child._spawnSystemBlock` 单点绑定——消费点 = 核
|
|
11
14
|
* `prepareRun`),`input` 只留任务书。2026-10-24(§6.22):工程角色 `input` = 一行机械任务书行
|
|
12
|
-
* (批档绝对路径 +
|
|
15
|
+
* (批档绝对路径 + 按角色的指向句),任务书本体由子代理从批档读(§8.1 切片)。
|
|
13
16
|
*/
|
|
14
17
|
|
|
18
|
+
// 2026-11-15(AGENT-LOOP-SUBAGENT.md §8.1):工程角色的任务书正文随 system 固块下发——spawn 当刻读一次
|
|
19
|
+
// 批档并冻结(`readFileSync` 在本档,切段与拼块的本体住 `./taskbook-block.mjs`)。
|
|
20
|
+
import { readFileSync } from "node:fs"
|
|
15
21
|
import {
|
|
16
22
|
createAgent,
|
|
17
23
|
readonlyToolNames, escapeXml, excludeSubagentTools,
|
|
18
24
|
} from "../agent.mjs"
|
|
19
|
-
import { allocRelay, wrapChildCallbacks, relayPrefixOf } from "../agent/spawn-child.mjs"
|
|
20
|
-
//
|
|
25
|
+
import { allocRelay, wrapChildCallbacks, relayPrefixOf, chargeDesignerSurveySpawn, rootAgentOf } from "../agent/spawn-child.mjs"
|
|
26
|
+
// B8(TOOLS.md §6.29 ④):eng 两角色的受限父历史(同名 `read_history`,只在 extraTools 注入)
|
|
27
|
+
import { makeBatchHistoryTool, recordBatchHistoryStart } from "./read-history.mjs"
|
|
28
|
+
// B4(TOOLS.md §6.29 ①):只读角色的 action 级变体派生(构造器单源 = `agent/helpers.mjs`,
|
|
29
|
+
// 判据单源 = `agent/dispatch-gates.mjs` 的 `readonlyActionOf`)。
|
|
30
|
+
import { deriveReadonlyTools } from "../agent/helpers.mjs"
|
|
31
|
+
import { readonlyActionTest } from "../agent/dispatch-gates.mjs"
|
|
32
|
+
// TUI-OOM-ROOTCAUSE(AGENT-LOOP.md §9.2):子代理人读线窗口常量单源(store 零依赖)。
|
|
21
33
|
import { RECORD_WINDOW_MESSAGES } from "../session-store.mjs"
|
|
22
|
-
|
|
23
|
-
import {
|
|
34
|
+
// 设计令牌门(七态拒句 ∥ 槽解析 ∥ 令牌判定)本体落 `./subagent-design-token.mjs`;本档只吃判定。
|
|
35
|
+
import { gateDesignToken } from "./subagent-design-token.mjs"
|
|
24
36
|
import { resolveChildProvider, buildChildRunOpts, enqueueAsk } from "./subagent-async.mjs"
|
|
25
37
|
import { nextSubagentId } from "./subagent-scheduler.mjs"
|
|
26
38
|
import {
|
|
@@ -29,12 +41,16 @@ import {
|
|
|
29
41
|
// M5 F2(ENGINEERING-MODE-V2-MODULE-DELEGATION §2.3):任务书 round 枚举 + 五项结构化参数校验/拼装本体落
|
|
30
42
|
// spawn-gates.mjs(纯谓词零依赖)——本处只加 import 调用。
|
|
31
43
|
import {
|
|
32
|
-
validateRoundParam, validateTaskBookParams,
|
|
44
|
+
validateRoundParam, validateTaskBookParams,
|
|
33
45
|
isEngineeringRole, rejectEngFreeTextParams,
|
|
34
46
|
} from "./spawn-gates.mjs"
|
|
47
|
+
// 任务书与 system 固块拼装(任务书播报 ∥ 写域行 S4 ∥ 文档坐标行 S5)落 `./subagent-brief.mjs`。
|
|
48
|
+
import { docsCoordinatesBlockOf, filesBlockOf, taskBriefOf } from "./subagent-brief.mjs"
|
|
35
49
|
// 台账 #23(AGENT-LOOP-SUBAGENT.md §6.26 · D23-3):审计块构造器外提(`buildAuditBlock` 纯函数)
|
|
36
50
|
// ——spawn 档只做「收集 + 绑定」;块文本逐字搬移(D23-4)。
|
|
37
51
|
import { buildAuditBlock } from "./audit-block.mjs"
|
|
52
|
+
// 任务书正文块(`AGENT-LOOP-SUBAGENT.md` §8.1 载体 ∥ 切片 ∥ 快照 ∥ 失效即拒)——纯函数外提,同审计块先例。
|
|
53
|
+
import { buildTaskBookBlock, taskBookPointerLine } from "./taskbook-block.mjs"
|
|
38
54
|
// 批次档路径解析单源(BATCH-RECORD.md §4.15 · 台账 #287):门内解析改经叶档(读面非抛形),
|
|
39
55
|
// 与 append / create 同源——门判据仍「参数在 + 路径可读」,错误文案逐字零变。
|
|
40
56
|
import { resolveBatchReadPath, resolveBatchReadResult } from "./batch-paths.mjs"
|
|
@@ -53,14 +69,6 @@ function unreadableHint(cwd, given) {
|
|
|
53
69
|
return ""
|
|
54
70
|
}
|
|
55
71
|
|
|
56
|
-
/** 任务书播报文本:该角色名集拼装 + 可选 task 自由文本(拼装空 ⇒ 原 task 逐字——旧形零变)。 */
|
|
57
|
-
function taskBriefOf(args, role) {
|
|
58
|
-
const composed = composeTaskBookBrief(args, role)
|
|
59
|
-
if (!composed) return args.task
|
|
60
|
-
const extra = typeof args.task === "string" ? args.task.trim() : ""
|
|
61
|
-
return extra ? `${composed}\n\n${extra}` : composed
|
|
62
|
-
}
|
|
63
|
-
|
|
64
72
|
/** 原 #309 任务书 token 观测(`child:batchdoc-ref`)已废止——2026-10-24 用户裁定
|
|
65
73
|
* 「不允许跨批引用」后,工程角色 input 只剩一行机械文本,扫描对象失效;无场景分支不留
|
|
66
74
|
* (AGENT-LOOP-SUBAGENT.md §6.29.3)。 */
|
|
@@ -83,47 +91,6 @@ export function effectiveSubagentModel(parent, role, modelArg) {
|
|
|
83
91
|
return cfg.subagentModels?.[role] ?? cfg.subagentModel ?? null
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
/**
|
|
87
|
-
* Resolve the design-token slot for an eng-coder spawn (2026-09-01 multi-design, FR3):
|
|
88
|
-
* - designId given → exact slot lookup (no match = explicit error, never a fuzzy guess)
|
|
89
|
-
* - designId omitted → exactly ONE slot must exist (single-design compatibility); with
|
|
90
|
-
* multiple slots we refuse rather than pick one (T16: never silently aim the wrong design)
|
|
91
|
-
* Returns { token } on success; throws with a parent-actionable message otherwise.
|
|
92
|
-
* R16 (2026-09-06): the slot Map is the authority; the format/TTL check itself stays in
|
|
93
|
-
* validateDesignToken (2026-09-06: HMAC 防伪层已删——token 为无签名流程凭证——见
|
|
94
|
-
* ENGINEERING-MODE.md 2026-09-06 段)。
|
|
95
|
-
* DESIGN-TOKEN-SETTLEMENT D2(2026-09-08):内存 Map miss(指定 designId 不在 / 空 Map)
|
|
96
|
-
* 时回读槽文件权威台账 reconcile + 判定(reconcileEngTokensFromSlot——与 dispatch 写门
|
|
97
|
-
* D3 同源)——覆盖"进程重启后槽有但 Map 未及回填/缓存与槽不一致"(槽文件 = 权威台账)。
|
|
98
|
-
* TTL 过滤保留(reconcile 只并入未过期项)。单值镜像 `_engDesignToken` 已随 D3 退役——
|
|
99
|
-
* 本门禁不再读镜像(AC3 零命中)。
|
|
100
|
-
*/
|
|
101
|
-
export function resolveDesignSlot(parent, designIdArg) {
|
|
102
|
-
let slots = parent._engDesignTokens
|
|
103
|
-
const hasSlots = slots instanceof Map && slots.size > 0
|
|
104
|
-
// D2:内存 miss(指定 designId 不在 或 空 Map)→ 权威槽回读 reconcile + 判定
|
|
105
|
-
if (designIdArg ? !(hasSlots && slots.has(designIdArg)) : !hasSlots) {
|
|
106
|
-
const rec = reconcileEngTokensFromSlot(parent)
|
|
107
|
-
if (rec && rec !== slots) slots = rec
|
|
108
|
-
}
|
|
109
|
-
// F2d: both refusal branches carry the HELD id list — after a
|
|
110
|
-
// persistence restore the parent has no digest to look the id up in; the error
|
|
111
|
-
// list is the only discovery path (ids are not credentials — the token is).
|
|
112
|
-
const size = slots instanceof Map ? slots.size : 0
|
|
113
|
-
const heldIds = size > 0 ? [...slots.keys()].join(", ") : "(none)"
|
|
114
|
-
if (designIdArg) {
|
|
115
|
-
if (!(slots instanceof Map) || !slots.has(designIdArg)) {
|
|
116
|
-
throw new Error(`designId not found — no approved design review holds this id. Run advisor with type='design' again and pass the designId echoed with the token. (session holds ${size} approved design slot(s); held design ids: ${heldIds})`)
|
|
117
|
-
}
|
|
118
|
-
return { token: slots.get(designIdArg) }
|
|
119
|
-
}
|
|
120
|
-
if (size > 1) {
|
|
121
|
-
throw new Error(`Multiple approved designs in this session (${size}) — pass the designId parameter (echoed with each token) to choose which design this eng-coder spawn belongs to. Held design ids: ${heldIds}`)
|
|
122
|
-
}
|
|
123
|
-
if (size === 1) return { token: [...slots.values()][0] }
|
|
124
|
-
throw designTokenRefusal("missing")
|
|
125
|
-
}
|
|
126
|
-
|
|
127
94
|
/**
|
|
128
95
|
* consume-design 动作执行器(2026-09-07 token 链终消费制——ENGINEERING-MODE.md §2.6 F1):
|
|
129
96
|
* 父侧验收核销时显式调用——读槽值 → removeDesignTokenSlot(移除该 designId 槽)→ 消费后同
|
|
@@ -181,16 +148,6 @@ export function prepareScheduling(parent, filesRaw, dependsRaw, wantAsync) {
|
|
|
181
148
|
return { files, dependsOn, errorJson: null }
|
|
182
149
|
}
|
|
183
150
|
|
|
184
|
-
/** S4 写域行(AGENT-LOOP-SUBAGENT.md §6.26「写域行(S4)」):表头 + 逐条绝对路径 + 两句语义——
|
|
185
|
-
* 本档局部纯函数(D23-9:不外提模块)。两句不可省:缺① 子代理读成「我只能写这些」⇒ 该写的漏掉;
|
|
186
|
-
* 缺② 仍把任务书 §2 全文当成自己的改动面(本块的病因)。清单不截断——截断正是本块要消除的
|
|
187
|
-
* 「看不见」。返回块文本(块间分隔由装配侧 `join("\n\n")` 施加)。 */
|
|
188
|
-
function filesBlockOf(files) {
|
|
189
|
-
return `Files declared for this spawn (the write domain this task declares, for scheduling):\n` +
|
|
190
|
-
files.map((f) => `- ${f}`).join("\n") +
|
|
191
|
-
`\n\nThis list is not an authorization boundary: touching a file outside it is allowed — report every out-of-list file you changed, with its reason. It is also not the whole change surface: other spawns on this task declare their own files, and what is listed here is your share only.`
|
|
192
|
-
}
|
|
193
|
-
|
|
194
151
|
/**
|
|
195
152
|
* AGENT-LOOP-SUBAGENT.md §6.9 准入通过后的 child 装配(2026-09-05 module-split——自 execute 参数化提取,
|
|
196
153
|
* 原 318-488 段 verbatim——语义零变)。副作用保留:relay 取号(sync 支 allocRelay——
|
|
@@ -201,7 +158,7 @@ function filesBlockOf(files) {
|
|
|
201
158
|
export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, dependsOn, engAuditAttempt) {
|
|
202
159
|
// Provider/model override: tool `model` arg > subagentModels[role] > subagentModel > parent provider
|
|
203
160
|
const childProvider = resolveChildProvider(parent, effectiveSubagentModel(parent, role, args.model))
|
|
204
|
-
// 工程角色(任务书 =
|
|
161
|
+
// 工程角色(任务书 = 绑定批档,按角色切片(§8.1);零任务书文本参数)——AGENT-LOOP-SUBAGENT.md §6.22.1。
|
|
205
162
|
const engineeringRole = isEngineeringRole(role)
|
|
206
163
|
|
|
207
164
|
// ── batchDoc gate(ENGINEERING-MODE.md §2.12 + §2.15 D1——FR20 #9 机械面)────────
|
|
@@ -264,17 +221,54 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
264
221
|
validateTaskBookParams(args, role)
|
|
265
222
|
}
|
|
266
223
|
|
|
267
|
-
//
|
|
268
|
-
//
|
|
224
|
+
// AGENT-LOOP-SUBAGENT.md §8.1:任务书**正文**进 system 固块(§8.2 收集序首块)——spawn 当刻读一次批档
|
|
225
|
+
// 并冻结,此后改动不回流(快照语义);切片与块文本住 `./taskbook-block.mjs`,本处只做「读 + 收集」。
|
|
226
|
+
// 失效即拒:段切不出来(无对应段头)⇒ 拒发并点名路径与缺失段(拒文由构造器给出)——
|
|
227
|
+
// 退回只发指向句会让 §8.1 的承诺落空而无人知道。读不到走同一条拒因:batchDoc 门已判过可读,
|
|
228
|
+
// 这里只剩「读的那一刻文件不在了」,那不是可降级情形。
|
|
229
|
+
// 落点 = 任务书参数门之后、token 门之前(门序 §3.3:既有门的先后不变)。
|
|
230
|
+
let taskBookBlock = null
|
|
231
|
+
if (engineeringRole) {
|
|
232
|
+
let recordText
|
|
233
|
+
try {
|
|
234
|
+
recordText = readFileSync(batchDocAbs, "utf8")
|
|
235
|
+
} catch (e) {
|
|
236
|
+
throw new Error(`Task book unavailable — spawn refused: the batch record at ${batchDocAbs} could not be read at spawn time (${e?.message ?? e}); the ${role} task book is cut from it, so this spawn would have no authorized text. Restore the file and spawn again.`)
|
|
237
|
+
}
|
|
238
|
+
taskBookBlock = buildTaskBookBlock({ role, record: { path: batchDocAbs, text: recordText } })
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// eng-coder token gate(TOOLS.md §6.25 ④⑤⑥):判定本体 = `./subagent-design-token.mjs` 的 `gateDesignToken`——
|
|
242
|
+
// missing / mismatch / expired / invalid / batch-mismatch / seal-mismatch / seal-unreadable 七态各出互异拒句;
|
|
243
|
+
// 前四态的拒绝集合与旧三条件合取全等。第三参 = 本函数上方 batchDoc 门已解析好的绝对路径
|
|
244
|
+
// (§10.1 的比较对象;本门不二次解析 `args.batchDoc`)。
|
|
269
245
|
// 返回值 = 槽内令牌,必须落回 issuedToken:下方 `child._engDesignId` 回写依赖它。
|
|
270
246
|
let issuedToken
|
|
271
|
-
if (role === "eng-coder") issuedToken = gateDesignToken(parent, args)
|
|
247
|
+
if (role === "eng-coder") issuedToken = gateDesignToken(parent, args, { batchDocAbs })
|
|
248
|
+
|
|
249
|
+
// ── B7(TOOLS.md §6.29 B7):eng-designer 的勘察预算计数 ──────────────────────────
|
|
250
|
+
// 计的是**设计席发起的勘察**(`parent._role === "eng-designer"` 且本 spawn 的 role = explore),
|
|
251
|
+
// 不是设计师自己的被派次数——模型面承诺的是「≤6 explore spawns per batch」。
|
|
252
|
+
// 判据序(设计档原话「先完成角色、同步方式与 batchDoc 准入再计数」):角色/同步两道门在
|
|
253
|
+
// `gateEngCoderSpawn`(调用方,本函数之前已过);本角色的 batchDoc 绑定在设计师自己那一次 spawn
|
|
254
|
+
// 就过完了门(`parent._batchDoc`);任务书门在本函数上方 ⇒ 到此处仍未拒的 spawn 才占额度。
|
|
255
|
+
// 载体 = depth-0 根 agent 的独立 Map(K5:挂一次性 designer child 上会在 fix respawn 归零)。
|
|
256
|
+
if (role === "explore" && parent?._role === "eng-designer" && parent._batchDoc) {
|
|
257
|
+
chargeDesignerSurveySpawn(rootAgentOf(parent), parent._batchDoc)
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ── B8(TOOLS.md §6.29 ④):eng 两角色的限量父历史 ────────────────────────────────
|
|
261
|
+
// 绑定的是**父会话**(depth-0 根 agent)与**本批起点**;未绑定角色(explore/plan/coder/tester/consult)
|
|
262
|
+
// 一个新历史工具都拿不到(K7:新工具解决不了「没有 _batchDoc 时范围怎么定」)。
|
|
263
|
+
if (engineeringRole) recordBatchHistoryStart(rootAgentOf(parent), batchDocAbs, Date.now())
|
|
272
264
|
|
|
273
265
|
// Filter tool set by role: explore/plan are read-only (plan is a planning agent, its deliverable is the plan itself)
|
|
274
266
|
let tools
|
|
275
267
|
if (role === "explore" || role === "plan") {
|
|
276
|
-
|
|
277
|
-
|
|
268
|
+
// B4(TOOLS.md §6.29):整把只读集 ∪ action 级只读变体——旧形只认 `t.readonly`,`git` / `memory` /
|
|
269
|
+
// `settings` / `process` 整把不是只读,于是它们的只读动作在只读角色里一起消失(需求 B4 的直接病因)。
|
|
270
|
+
// 判据单源 = 运行期 `readonlyActionOf`(经 `readonlyActionTest` 适配)——不另写一份只读动作名单。
|
|
271
|
+
tools = deriveReadonlyTools(parent.tools, readonlyActionTest)
|
|
278
272
|
} else if (role === "tester") {
|
|
279
273
|
// tester = the THIRD tool face (AGENT-LOOP-SUBAGENT.md §6.59.2 ④): read-only set ∪ {execute, bash},
|
|
280
274
|
// minus {verify, advisor}.
|
|
@@ -330,7 +324,7 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
330
324
|
// 场景映射落到 assemblePrompt("eng-coder"/"eng-designer")(persona-{role} + common +
|
|
331
325
|
// discipline-engineering);designer 也必须 engineering=true 才能装配工程纪律槽。
|
|
332
326
|
const childConfig = engineeringRole
|
|
333
|
-
? { ...parent.config, agent: { ...parent.config.agent, engineering: true } }
|
|
327
|
+
? { ...parent.config, agent: { ...parent.config.agent, mode: "engineering", engineering: true } }
|
|
334
328
|
: parent.config
|
|
335
329
|
|
|
336
330
|
const child = createAgent({
|
|
@@ -342,7 +336,7 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
342
336
|
overlay,
|
|
343
337
|
role,
|
|
344
338
|
})
|
|
345
|
-
// TUI-OOM-ROOTCAUSE(AGENT-LOOP.md §
|
|
339
|
+
// TUI-OOM-ROOTCAUSE(AGENT-LOOP.md §9.2):子代理人读线窗口置位(常量单源
|
|
346
340
|
// session-store.mjs)——机制复用主 agent 同路径(context.mjs pushReal 驱逐);
|
|
347
341
|
// 每个 child 原先各自一份永不压缩的 _fullHistory(勘察 C2 乘数面)。
|
|
348
342
|
child._historyWindow = RECORD_WINDOW_MESSAGES
|
|
@@ -377,21 +371,24 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
377
371
|
// 审计/探索("status 里这个文件算不算超清单?")。注入分支整体删除(B 方案
|
|
378
372
|
// git 只读变体亦随裁定废弃——D-AG5)。顶层主 agent 注入保留(§3 prepareRun——
|
|
379
373
|
// setup.mjs depth===0——D-AG7 范围边界)。
|
|
380
|
-
// §6.22.2 子代理任务输入:工程角色 `input` = 一行机械任务书行(批档绝对路径 +
|
|
381
|
-
//
|
|
374
|
+
// §6.22.2 子代理任务输入:工程角色 `input` = 一行机械任务书行(批档绝对路径 + 按角色的指向句);
|
|
375
|
+
// 任务书**正文**在 system 固块(§8.1),本行只指路(指向句文本住 `./taskbook-block.mjs`);
|
|
382
376
|
// 非工程角色 = 既有拼装(context 前缀 + 任务书参数 + 可选 task——零变)。
|
|
383
377
|
const input = engineeringRole
|
|
384
|
-
?
|
|
378
|
+
? taskBookPointerLine(role, batchDocAbs)
|
|
385
379
|
: (args.context ? `Context:\n${args.context}\n\nTask:\n${taskBriefOf(args, role)}` : taskBriefOf(args, role))
|
|
386
380
|
// 台账 #23(AGENT-LOOP-SUBAGENT.md §6.26 · D23-1):**spawn 级固定机制性指令改走 system 固块**——
|
|
387
381
|
// 两处(批次档路径行 + 审计模板块)原随 user 首条下发,压缩把首条并入摘要即丢(长任务中后期
|
|
388
382
|
// 既看不到批次档路径、也看不到审计模板 ⇒ 过度勘察的真病根);固块值在 child 生命周期内恒定
|
|
389
383
|
// ⇒ run 内 system 前缀逐字节稳定(前缀缓存不破),且不在 `agent.history` 内 ⇒ 压缩结构上吞不掉。
|
|
390
|
-
// 收集序 = 批次档行 → 审计块 → 写域行(S4
|
|
391
|
-
//
|
|
384
|
+
// 收集序 = 任务书正文(§8.2)→ 批次档行 → 审计块 → 写域行(S4,见下)→ 文档坐标行(S5,见下);
|
|
385
|
+
// 空数组 ⇒ 不绑定(depth-0 不进本函数、system 逐字节同改前——§6.26 缓存契约兼容证明)。
|
|
386
|
+
// S5 与角色无关 ⇒ explore ∥ plan 的子代理也会带上它;它随本项目 manifest 声明而定、与 spawn 参数无关,同一 child 终身不变。
|
|
392
387
|
const spawnBlocks = []
|
|
388
|
+
// §8.1 任务书正文(§8.2 收集序首块):仅工程角色携带,已按角色切片(eng-coder = §2、eng-designer = §1 + §2)。
|
|
389
|
+
if (taskBookBlock) spawnBlocks.push(taskBookBlock)
|
|
393
390
|
// §2.11 第 1 点(FR16 载体 + FR17 铁律 #5 的机械面):批次档**绝对路径**下发给工程角色
|
|
394
|
-
// (eng-coder 实现 / eng-designer
|
|
391
|
+
// (eng-coder 实现 / eng-designer 写稿)——任务书正文就在上方那块;本行让子代理“拿到本档路径”(改写前回读磁盘用)。
|
|
395
392
|
// 工程角色恒注入;携绑定 coder(§4.16)随绑定注入(绑定 coder 要能读到本档)。
|
|
396
393
|
if (batchBound) spawnBlocks.push(`Batch record (batchDoc): ${batchDocAbs}`)
|
|
397
394
|
// AGENT-LOOP-SUBAGENT.md §6.7.6 D-E2 ③ + §6.22 KD-SC6:审计 spawn 的范围证据 = 机械跟踪的
|
|
@@ -401,8 +398,13 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
401
398
|
// §6.26「写域行(S4)」:`files`(本 spawn 的预期写域,`prepareScheduling` 已归一化)非空 ⇒ 追加
|
|
402
399
|
// 一格——写域此前只有调度器知道,子代理只能猜自己的改动面;空 / 未传 ⇒ 不推块,system 逐字节同改前。
|
|
403
400
|
if (files.length > 0) spawnBlocks.push(filesBlockOf(files))
|
|
401
|
+
// §6.61「子代理文档坐标行(S5)」:本项目声明的三层文档坐标一行随 system 面下发。子代理此前也读得到
|
|
402
|
+
// `docRoot`(`manifestReadTool` 按需主动读),但那得先想到坐标记在 manifest 里、再知道键名——本行把
|
|
403
|
+
// 答案在 spawn 时就放进 system 面,省掉的只是那一趟(出口零新解析)。读不出 ⇒ 不推块。
|
|
404
|
+
const docsBlock = docsCoordinatesBlockOf(parent.cwd)
|
|
405
|
+
if (docsBlock) spawnBlocks.push(docsBlock)
|
|
404
406
|
// The child's own task input rides the child object: D23-6 —— `_engTaskInput` 语义 = **一行机械
|
|
405
|
-
// 任务书行**(批档绝对路径 +
|
|
407
|
+
// 任务书行**(批档绝对路径 + 按角色的指向句;不含固块——正文在 system 面)。
|
|
406
408
|
if (engineeringRole) child._engTaskInput = input
|
|
407
409
|
// spawn 固块单点绑定(sync / async 同点——buildSpawnChild 唯一调用点):此后只读 ⇒ 同一
|
|
408
410
|
// child 的任意 run(resume 续跑 / 报告追问重跑)逐字节恒定;消费点 = 核 `prepareRun`。
|
|
@@ -412,7 +414,7 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
412
414
|
// pipeline (AGENT-LOOP-SUBAGENT.md §6.7.2 D3). Prefix includes a unique id: parallel child agents
|
|
413
415
|
// with the same role stay independent and don't overwrite each other.
|
|
414
416
|
// Format: role#id/ → onToken("coder#2/writing..."), onToolCall("coder#2/read", args)
|
|
415
|
-
// Async id allocation (AGENT-LOOP-SUBAGENT.md §6.7.3
|
|
417
|
+
// Async id allocation (AGENT-LOOP-SUBAGENT.md §6.7.3): reserve the relay counter at
|
|
416
418
|
// spawn time — the returned id must be stable while the item sits in the queue.
|
|
417
419
|
// The [model] token (TUI block creation) is DEFERRED to actual start so queued
|
|
418
420
|
// children don't paint an empty panel block ("queued 态不显示").
|
|
@@ -441,34 +443,12 @@ export function buildSpawnChild(parent, ctx, args, role, wantAsync, files, depen
|
|
|
441
443
|
...wrapChildCallbacks(relayPrefix, ctx.callbacks),
|
|
442
444
|
}
|
|
443
445
|
const childRunOpts = buildChildRunOpts(ctx)
|
|
446
|
+
// B8(TOOLS.md §6.29 ④):eng 两角色各挂一枚**本批窗口**的受限 `read_history`(同名工具、
|
|
447
|
+
// 经 extraTools 注入——装配面在 `agent/setup.mjs` 的 `extraTools` 段)。未绑定角色不挂(K7)。
|
|
448
|
+
if (engineeringRole) childRunOpts.extraTools = [makeBatchHistoryTool(rootAgentOf(parent), batchDocAbs)]
|
|
444
449
|
return { child, input, childOpts, childRunOpts, relayPrefix, childProvider }
|
|
445
450
|
}
|
|
446
|
-
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* mismatch 可携 designId(非凭证);四句均零令牌值回显。 */
|
|
451
|
-
export function designTokenRefusal(kind, designId) {
|
|
452
|
-
if (kind === "missing") return new Error("designToken missing — the eng-coder spawn is refused: no usable token for an approved design slot came with this spawn. Pass the designToken parameter with the exact value from the subagent action:'design-slots' row (the text after designToken=), copied verbatim; if that list is empty, no design review has been approved in this session yet — run advisor with type='design' first. No token value is echoed here.")
|
|
453
|
-
if (kind === "mismatch") return new Error("designToken mismatch — the eng-coder spawn is refused: the value passed does not equal the token held for this design slot. Re-read the subagent action:'design-slots' row and pass the value after designToken= verbatim, unchanged. No token value is echoed here." + (designId ? ` (designId: ${designId})` : ""))
|
|
454
|
-
if (kind === "expired") return new Error("designToken expired — the eng-coder spawn is refused: the token matches this design slot but is past its TTL. The expired slot has been removed; run advisor with type='design' again on the current design and pass the newly issued token — an expired authorization cannot be retried. No token value is echoed here.")
|
|
455
|
-
return new Error("designToken invalid — the eng-coder spawn is refused: the value passed equals this design slot's stored token, but that stored value is not a well-formed token, so no expiry can be judged and the slot was left in place. Run advisor with type='design' to issue a fresh token for this design; a malformed record never passes the gate. No token value is echoed here.")
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
/** eng-coder spawn 的令牌门(TOOLS.md §6.25 ④):resolveDesignSlot 的既有两条 designId
|
|
459
|
-
* 诊断零改 → 参数在场 → 值相等 → 值有效。槽删除只在 tokenExpired(given) 成立时发生
|
|
460
|
-
* (D-R16c ③);mismatch / invalid 不删槽(T-R16d)。返回槽内令牌(调用方回写 designId
|
|
461
|
-
* 依赖它);sync / async 两路共经 buildSpawnChild——一处判定双路生效。 */
|
|
462
|
-
export function gateDesignToken(parent, args) {
|
|
463
|
-
const issuedToken = resolveDesignSlot(parent, args?.designId).token
|
|
464
|
-
// 非字符串 ⇒ 空串 ⇒ missing(本意——T9 锁定)
|
|
465
|
-
const given = typeof args?.designToken === "string" ? args.designToken : ""
|
|
466
|
-
if (!issuedToken || !given.trim()) throw designTokenRefusal("missing")
|
|
467
|
-
if (given !== issuedToken) throw designTokenRefusal("mismatch", args?.designId)
|
|
468
|
-
if (!validateDesignToken(given)) {
|
|
469
|
-
const expired = tokenExpired(given)
|
|
470
|
-
if (expired) removeDesignTokenSlot(parent, args?.designId, given)
|
|
471
|
-
throw designTokenRefusal(expired ? "expired" : "invalid")
|
|
472
|
-
}
|
|
473
|
-
return issuedToken
|
|
474
|
-
}
|
|
451
|
+
// 设计令牌门(七态拒句 ∥ eng-coder spawn 的令牌判定)已搬 `./subagent-design-token.mjs`(分拆落点 =
|
|
452
|
+
// `docs/core/design/PATH-RESOLUTION.md` §3 末条);本档**原样再导出**其导出面 ⇒ `subagent.mjs` 的再导出行与
|
|
453
|
+
// 用例的 import 行零改。
|
|
454
|
+
export { designTokenRefusal, gateDesignToken, resolveDesignSlot } from "./subagent-design-token.mjs"
|
package/agent-tools/subagent.mjs
CHANGED
|
@@ -108,9 +108,9 @@ export function buildSyncStoppedReport(role, capturedOutput, designId) {
|
|
|
108
108
|
/**
|
|
109
109
|
* subagent tool — ONE tool, NINE actions (AGENT-LOOP-SUBAGENT.md §6.7 +
|
|
110
110
|
* SUBAGENT-OBSERVE-SEND): spawn (default) / status (non-blocking pool query) / observe
|
|
111
|
-
* (inspect a running/queued/done async child's recent activity + current tool —
|
|
111
|
+
* (inspect a running/queued/done async child's recent activity + current tool — AGENT-LOOP-SUBAGENT.md §2.2 observe/send) /
|
|
112
112
|
* send (inject a direction into a RUNNING async child — consumed at its next turn
|
|
113
|
-
* boundary as an ordinary instruction — §
|
|
113
|
+
* boundary as an ordinary instruction — AGENT-LOOP-SUBAGENT.md §2.2 observe/send) / escalate (飞刀 — hand implementation to
|
|
114
114
|
* a stronger model) / cancel (stop ONE background subagent — AGENT-LOOP-SUBAGENT.md §6.7.2) / panel (view + fix
|
|
115
115
|
* the live subagent panel — AGENT-LOOP-SUBAGENT.md §6.7.2) / consume-design (parent-side chain-terminal token
|
|
116
116
|
* consumption — ENGINEERING-MODE.md §2.6, 2026-09-07; selectors designId / designIds / expired /
|
|
@@ -138,7 +138,7 @@ export const subagentTool = {
|
|
|
138
138
|
parameters: {
|
|
139
139
|
type: "object",
|
|
140
140
|
properties: {
|
|
141
|
-
action: { type: "string", enum: ["spawn", "status", "escalate", "cancel", "panel", "consume-design", "observe", "send", "design-slots"], description: "Which action
|
|
141
|
+
action: { type: "string", enum: ["spawn", "status", "escalate", "cancel", "panel", "consume-design", "observe", "send", "design-slots"], description: "Which action to run; `spawn` is the default. Semantics per action in the tool description." },
|
|
142
142
|
view: { type: "boolean", description: "action:'panel' only: true (default) = the live panel blocks as the user sees them; false without freeze = error. Mutually exclusive with freeze (freeze wins)." },
|
|
143
143
|
freeze: { type: "string", description: "action:'panel' only: block key of a digested-stuck block — reclaims it into the conversation; refused for running/done/unknown blocks or a still-pending report; works on the CLI TUI panel and on the desktop renderer panel (live readback of the blocks as the user sees them)." },
|
|
144
144
|
task: { type: "string", description: "For action:'spawn': non-engineering roles (explore / plan / coder / tester) — OPTIONAL free-text supplement; the brief itself is the four core parameters (goal / knownFacts / acceptance / reportFormat) + scope. Engineering roles (eng-coder / eng-designer) take NO task-book text parameters — their task book is batch record §2 (batchDoc), read by the child itself. For action:'escalate': the brief (goal, constraints, entry files, acceptance criteria)." },
|
|
@@ -157,12 +157,12 @@ export const subagentTool = {
|
|
|
157
157
|
scope: { type: "string", description: "REQUIRED for role='explore'/'plan'/'coder'/'tester' (non-engineering task book, the fifth parameter): scope & forbidden scope — what to read / search and what not to touch." },
|
|
158
158
|
acceptance: { type: "string", description: "REQUIRED for role='explore'/'plan'/'coder'/'tester' (non-engineering task book): acceptance criteria — machine-verifiable (commands / thresholds / assertion counts)." },
|
|
159
159
|
reportFormat: { type: "string", description: "REQUIRED for role='explore'/'plan'/'coder'/'tester' (non-engineering task book): the delivery-report format the child must produce." },
|
|
160
|
-
async: { type: "boolean", description: "
|
|
160
|
+
async: { type: "boolean", description: "Required: `true` = async spawn (report via the auto channel); `false` = blocking; omitting it is refused. At depth>0 every spawn is synchronous — an explicit `async: true` there is refused. action:'escalate' keeps its own form: omission there still means the async flight, and `false` asks for the blocking one." },
|
|
161
161
|
files: { type: "array", items: { type: "string" }, description: "action:'spawn' only: the file write-domain this task declares — file-level paths only (cwd-relative or absolute; directories rejected — they bypass the conflict detector). Overlapping-file tasks serialize automatically. Omit = no conflict detection." },
|
|
162
162
|
dependsOn: { type: "array", items: { type: "string" }, description: "action:'spawn' only: ids from prior async returns whose outcome this task needs — queues until every dependency settles, then starts. Consumed ids count as satisfied; a cancelled/failed dependency stays queued marked 'dependency cancelled' until you decide (AUTO sessions auto-start). Unknown ids error." },
|
|
163
163
|
id: { type: "string", description: "action:'status'/'observe'/'send'/'cancel': the subagent id from the spawn return. status: omit = pool overview; observe/send/cancel: REQUIRED." },
|
|
164
164
|
message: { type: "string", description: "action:'send' only (REQUIRED there): the direction to inject — consumed by the running child at its next turn boundary as an ordinary instruction (non-interrupting)." },
|
|
165
|
-
recent: { type: "integer", description: "action:'observe'
|
|
165
|
+
recent: { type: "integer", description: "Required for action:'observe': how many recent-turn summaries (1..20)" },
|
|
166
166
|
},
|
|
167
167
|
required: [],
|
|
168
168
|
},
|
|
@@ -183,13 +183,6 @@ export const subagentTool = {
|
|
|
183
183
|
if ((ctx.depth ?? 0) > 0 && (ctx.agent?._role === "eng-coder" || ctx.agent?._role === "eng-designer")) {
|
|
184
184
|
throw new Error(`only action:'spawn' (sync explore children) is available inside an ${ctx.agent._role} — escalate/status/cancel/panel/consume-design/design-slots/observe/send are not`)
|
|
185
185
|
}
|
|
186
|
-
// AGENT-LOOP-ASYNC-POOL.md §6.8 N3/D-S6 spawn gate (manual tier): auto-turn digests may not spawn —
|
|
187
|
-
// async OR blocking — the digest must stay organize-only. The escalate
|
|
188
|
-
// action spawns a write child too, so the same mechanical refusal applies
|
|
189
|
-
// (AUTO tier exempt — user authorized unattended continuation).
|
|
190
|
-
if (action === "escalate" && ctx.agent?._inAutoTurn && !ctx.agent?.autoApprove) {
|
|
191
|
-
return JSON.stringify({ status: "error", error: "cannot spawn subagents from a manual auto-turn — wait for user input" })
|
|
192
|
-
}
|
|
193
186
|
if (action === "status") return executeStatusAction(args, ctx)
|
|
194
187
|
if (action === "escalate") return await executeEscalateAction(args, ctx)
|
|
195
188
|
// AGENT-LOOP-SUBAGENT.md §6.7.2 控制类动作:digest 内放行(D-S7 分类——控制/自省;dispatch 控制类
|
|
@@ -224,17 +217,18 @@ export const subagentTool = {
|
|
|
224
217
|
// schema), so the mechanical check lives here: an absent task would otherwise
|
|
225
218
|
// flow downstream as `content: undefined` and surface as an obscure error.
|
|
226
219
|
// 载体判据:**非工程角色** = 结构化参数(拼装后非空)——task 只作补充;两者皆缺 ⇒ 此处先拒。
|
|
227
|
-
// 工程角色 = 无任务书文本参数(任务书 =
|
|
220
|
+
// 工程角色 = 无任务书文本参数(任务书 = 绑定批档,按角色切片(§8.1)):此处不判——自由文本键由
|
|
228
221
|
// buildSpawnChild 的任务书门键在场即拒并点名(空集拼装不得误报「缺任务书」)。
|
|
229
222
|
if (!isEngineeringRole(args.role) && !composeTaskBookBrief(args, args.role) && (typeof args.task !== "string" || !args.task.trim())) {
|
|
230
|
-
throw new Error("subagent action:'spawn' requires the structured task-book parameters for non-engineering roles (explore / plan / coder / tester) (four core: goal / knownFacts / acceptance / reportFormat + scope) — a free-text task alone is not the brief. Engineering roles take no task-book text parameters: their task book is batch record
|
|
223
|
+
throw new Error("subagent action:'spawn' requires the structured task-book parameters for non-engineering roles (explore / plan / coder / tester) (four core: goal / knownFacts / acceptance / reportFormat + scope) — a free-text task alone is not the brief. Engineering roles take no task-book text parameters: their task book is the bound batch record (batchDoc), sliced per role into the spawn system block.")
|
|
224
|
+
}
|
|
225
|
+
// §18 D-E1a(必填化——2026-11-07 批 tool-param-zero-defaults):`recent` ∥ `async` 皆必填;
|
|
226
|
+
// depth 不再替调用方选(旧形 `args.async ?? depth === 0` 已撤)。depth>0 无异步——显式
|
|
227
|
+
// `async:true` 下游拒(`async spawn only available at the top level`);`async:false` 仍是阻塞飞行的显式形。
|
|
228
|
+
if (args.async !== true && args.async !== false) {
|
|
229
|
+
throw new Error("subagent: async is required — pass true for an async spawn or false for a blocking flight")
|
|
231
230
|
}
|
|
232
|
-
|
|
233
|
-
// default to async for EVERY role (the old role-level default — eng-coder only —
|
|
234
|
-
// is superseded); depth>0 spawns default to sync (子代理内部强制同步现状保留).
|
|
235
|
-
// async:false remains the explicit escape hatch; async:true at depth>0 is
|
|
236
|
-
// refused downstream (executeAsyncSpawn top-level gate).
|
|
237
|
-
const wantAsync = args.async ?? ((ctx.depth ?? 0) === 0)
|
|
231
|
+
const wantAsync = args.async
|
|
238
232
|
|
|
239
233
|
// Role normalization + whitelist (2026-08-25, coder-leak fix): exact-string gates let
|
|
240
234
|
// variant roles ("Coder", " coder") bypass BOTH mode gates and fall through to
|
|
@@ -268,14 +262,8 @@ export const subagentTool = {
|
|
|
268
262
|
throw new Error("Engineering mode is not active — role='eng-designer' is engineering-mode only (it writes the requirements/design documents inside the engineering workflow); use role='explore' or role='plan' for read-only work.")
|
|
269
263
|
}
|
|
270
264
|
|
|
271
|
-
// AGENT-LOOP-ASYNC-POOL.md §
|
|
272
|
-
//
|
|
273
|
-
// exempt (推进型 — user authorized unattended continuation). Mechanical refusal
|
|
274
|
-
// so the digest never pops a permission panel or chains new background work.
|
|
275
|
-
// (escalate 动作的同类拒绝在 action 分流处——本检查只管 spawn 路径。)
|
|
276
|
-
if (parent._inAutoTurn && !parent.autoApprove) {
|
|
277
|
-
return JSON.stringify({ status: "error", error: "cannot spawn subagents from a manual auto-turn — wait for user input" })
|
|
278
|
-
}
|
|
265
|
+
// AGENT-LOOP-ASYNC-POOL.md §8.7「工具面与审批呈递不按轮型改变」:派活只受工具自身准入约束——
|
|
266
|
+
// `_inAutoTurn` 是显示与轨迹标记,不参与准入(两径无轮型门)。
|
|
279
267
|
|
|
280
268
|
// §20 准入(2026-09-05 module-split——prepareScheduling verbatim 迁
|
|
281
269
|
// subagent-spawn.mjs:参数形态/unknown id/依赖环/阻塞 sync 判定;files 目录声明
|
package/agent-tools/task.mjs
CHANGED
|
@@ -51,13 +51,6 @@ export const taskTool = {
|
|
|
51
51
|
},
|
|
52
52
|
readonly: true,
|
|
53
53
|
async execute(args, ctx) {
|
|
54
|
-
// F10(工程模式机械停用——双层门的 **execute 层兜底**;先例 = escalate `subagent-actions.mjs` 的 `executeEscalateAction`):
|
|
55
|
-
// 前置位 = 本行以下全部副作用之前(alias 归一 / `_taskPushbacks` 归零 / `_onTaskUpdate` / 轻推)
|
|
56
|
-
// ⇒ 零副作用(列表不变);装配层已摘(`agent/family-tools.mjs` 工程分支不入表,KD8)。
|
|
57
|
-
// 普通模式(engineering 非真)逐字走原路径。
|
|
58
|
-
if (ctx?.agent?.config?.agent?.engineering) {
|
|
59
|
-
return "Error: engineering mode is ON — task is unavailable (the batch record + the ledger are the tracking authority in engineering mode). Update progress in the batch record (§5/§6) or the ledger (`/ledger`); task lists go stale in this mode's parallel structure."
|
|
60
|
-
}
|
|
61
54
|
// Keep only non-done items + the 3 most recently completed (for context reference), max 20 to prevent accumulation
|
|
62
55
|
const warnings = []
|
|
63
56
|
const raw = (args.items ?? []).map((it) => {
|
|
@@ -80,7 +73,6 @@ export const taskTool = {
|
|
|
80
73
|
const recentDone = raw.filter((t) => t.status === "done").slice(-3)
|
|
81
74
|
const items = [...pending, ...recentDone].slice(0, 20)
|
|
82
75
|
ctx.agent.tasks = items
|
|
83
|
-
ctx.agent._taskPushbacks = 0 // task list changed — the completion gate earns a fresh reminder
|
|
84
76
|
ctx.agent._onTaskUpdate?.(items)
|
|
85
77
|
if (ctx.depth === 0) pushContextNudge(ctx.agent) // F-CC4 轻推(§6.16.5——depth-0 门:子代理拿不到 context 工具)
|
|
86
78
|
const done = items.filter((i) => i.status === "done").length
|