berry-agent 0.1.0-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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/.api-emit.stamp +1 -0
- package/dist/.build-meta.json +6 -0
- package/dist/agent/events.js +1 -0
- package/dist/agent/index.js +2 -0
- package/dist/agent/loop.js +139 -0
- package/dist/agent/queue.js +119 -0
- package/dist/agent/stream.js +62 -0
- package/dist/agent/tools-batch.js +221 -0
- package/dist/agent/types.js +8 -0
- package/dist/api/berry-agent-llm.d.ts +18 -0
- package/dist/api/berry-agent.d.ts +9 -0
- package/dist/api/surface.json +1632 -0
- package/dist/api/tsconfig.paths.json +12 -0
- package/dist/api/typebox-compile.d.ts +2 -0
- package/dist/api/typebox-value.d.ts +2 -0
- package/dist/api/typebox.d.ts +2 -0
- package/dist/browser/cdp.js +256 -0
- package/dist/browser/codes.js +31 -0
- package/dist/browser/discover.js +107 -0
- package/dist/browser/engine.js +169 -0
- package/dist/browser/index.js +17 -0
- package/dist/browser/install.js +342 -0
- package/dist/browser/page.js +321 -0
- package/dist/browser/service.js +158 -0
- package/dist/browser/tools.js +198 -0
- package/dist/browser/types.js +81 -0
- package/dist/channels/ask-queue.js +82 -0
- package/dist/channels/commands.js +129 -0
- package/dist/channels/engine/cell.js +143 -0
- package/dist/channels/engine/diff.js +143 -0
- package/dist/channels/engine/engine.js +416 -0
- package/dist/channels/engine/index.js +8 -0
- package/dist/channels/engine/input-keys.js +86 -0
- package/dist/channels/engine/input.js +596 -0
- package/dist/channels/engine/memory-io.js +71 -0
- package/dist/channels/engine/process-io.js +38 -0
- package/dist/channels/engine/types.js +17 -0
- package/dist/channels/engine/width.js +122 -0
- package/dist/channels/index.js +15 -0
- package/dist/channels/registry.js +56 -0
- package/dist/channels/sdk/admit.js +29 -0
- package/dist/channels/sdk/backend.js +102 -0
- package/dist/channels/sdk/cursor.js +56 -0
- package/dist/channels/sdk/index.js +20 -0
- package/dist/channels/sdk/jsonl.js +208 -0
- package/dist/channels/sdk/protocol.js +24 -0
- package/dist/channels/sdk/schema.js +91 -0
- package/dist/channels/sdk/wire-core.js +446 -0
- package/dist/channels/service.js +169 -0
- package/dist/channels/tui/autocomplete/autocomplete.js +42 -0
- package/dist/channels/tui/autocomplete/file-mentions.js +106 -0
- package/dist/channels/tui/autocomplete/popup.js +148 -0
- package/dist/channels/tui/autocomplete/provider.js +7 -0
- package/dist/channels/tui/autocomplete/token.js +68 -0
- package/dist/channels/tui/backend/ansi-rows.js +211 -0
- package/dist/channels/tui/backend/main-screen.js +207 -0
- package/dist/channels/tui/backend/osc.js +91 -0
- package/dist/channels/tui/backend/transcript.js +230 -0
- package/dist/channels/tui/backend/tui-backend.js +915 -0
- package/dist/channels/tui/editor/editor-model.js +543 -0
- package/dist/channels/tui/editor/editor-view.js +140 -0
- package/dist/channels/tui/editor/editor.js +275 -0
- package/dist/channels/tui/editor/undo-stack.js +35 -0
- package/dist/channels/tui/editor/visual-lines.js +126 -0
- package/dist/channels/tui/editor/word-nav.js +106 -0
- package/dist/channels/tui/history/history-viewer.js +403 -0
- package/dist/channels/tui/index.js +3 -0
- package/dist/channels/tui/layout.js +167 -0
- package/dist/channels/tui/markdown/blocks.js +111 -0
- package/dist/channels/tui/markdown/inline.js +75 -0
- package/dist/channels/tui/markdown/markdown.js +182 -0
- package/dist/channels/tui/memory/memory-viewer.js +540 -0
- package/dist/channels/tui/overlay/alt-screen.js +105 -0
- package/dist/channels/tui/overlay/overlay.js +57 -0
- package/dist/channels/tui/overlay/select-confirm.js +156 -0
- package/dist/channels/tui/panels/todo-panel.js +54 -0
- package/dist/channels/tui/panels/tool-progress-panel.js +93 -0
- package/dist/channels/tui/scroll/scroll-view.js +254 -0
- package/dist/channels/tui/status/status-line.js +76 -0
- package/dist/channels/tui/text.js +38 -0
- package/dist/channels/tui/theme.js +41 -0
- package/dist/channels/types.js +11 -0
- package/dist/channels/ui-core.js +209 -0
- package/dist/checkpoint/capture.js +45 -0
- package/dist/checkpoint/codes.js +33 -0
- package/dist/checkpoint/command.js +82 -0
- package/dist/checkpoint/gate.js +48 -0
- package/dist/checkpoint/index.js +20 -0
- package/dist/checkpoint/restore.js +172 -0
- package/dist/checkpoint/store.js +247 -0
- package/dist/checkpoint/types.js +4 -0
- package/dist/checkpoint/walk.js +146 -0
- package/dist/compaction/ccr-tools.js +112 -0
- package/dist/compaction/ccr.js +84 -0
- package/dist/compaction/codes.js +21 -0
- package/dist/compaction/index.js +18 -0
- package/dist/compaction/policy.js +200 -0
- package/dist/compaction/service.js +422 -0
- package/dist/compaction/slots.js +121 -0
- package/dist/compaction/types.js +10 -0
- package/dist/context/codes.js +40 -0
- package/dist/context/events.js +160 -0
- package/dist/context/index.js +13 -0
- package/dist/context/logger.js +136 -0
- package/dist/context/scope.js +182 -0
- package/dist/context/workspace.js +104 -0
- package/dist/contracts/agent-events.d.ts +73 -0
- package/dist/contracts/agent-events.js +16 -0
- package/dist/contracts/api.d.ts +249 -0
- package/dist/contracts/api.js +299 -0
- package/dist/contracts/approval.d.ts +37 -0
- package/dist/contracts/approval.js +9 -0
- package/dist/contracts/env-ref.d.ts +41 -0
- package/dist/contracts/env-ref.js +32 -0
- package/dist/contracts/errors.d.ts +56 -0
- package/dist/contracts/errors.js +266 -0
- package/dist/contracts/events.d.ts +70 -0
- package/dist/contracts/events.js +329 -0
- package/dist/contracts/index.d.ts +32 -0
- package/dist/contracts/index.js +26 -0
- package/dist/contracts/llm.d.ts +275 -0
- package/dist/contracts/llm.js +12 -0
- package/dist/contracts/messages.d.ts +63 -0
- package/dist/contracts/messages.js +65 -0
- package/dist/contracts/redact.d.ts +46 -0
- package/dist/contracts/redact.js +223 -0
- package/dist/contracts/tools.d.ts +197 -0
- package/dist/contracts/tools.js +33 -0
- package/dist/contracts/types.d.ts +302 -0
- package/dist/contracts/types.js +50 -0
- package/dist/contracts/ui.d.ts +122 -0
- package/dist/contracts/ui.js +15 -0
- package/dist/conversation/agent-service.js +61 -0
- package/dist/conversation/approval-wiring.js +82 -0
- package/dist/conversation/backoff.js +38 -0
- package/dist/conversation/codes.js +47 -0
- package/dist/conversation/control-tools.js +102 -0
- package/dist/conversation/control.js +210 -0
- package/dist/conversation/driver.js +922 -0
- package/dist/conversation/index.js +12 -0
- package/dist/conversation/model-visible.js +169 -0
- package/dist/conversation/open-tools.js +126 -0
- package/dist/conversation/reseed.js +132 -0
- package/dist/conversation/sessions.js +215 -0
- package/dist/conversation/todo.js +203 -0
- package/dist/conversation/types.js +35 -0
- package/dist/conversation/wiring.js +204 -0
- package/dist/credentials/codes.js +59 -0
- package/dist/credentials/commands.js +186 -0
- package/dist/credentials/env-ref.js +34 -0
- package/dist/credentials/index.js +28 -0
- package/dist/credentials/migration.js +18 -0
- package/dist/credentials/oauth.js +266 -0
- package/dist/credentials/refresh.js +152 -0
- package/dist/credentials/secrets.js +118 -0
- package/dist/credentials/types.js +30 -0
- package/dist/exec/bash.js +279 -0
- package/dist/exec/codes.js +37 -0
- package/dist/exec/env.js +99 -0
- package/dist/exec/environment.js +39 -0
- package/dist/exec/git-guard.js +623 -0
- package/dist/exec/index.js +24 -0
- package/dist/exec/registry.js +120 -0
- package/dist/exec/spawn.js +281 -0
- package/dist/exec/tail.js +77 -0
- package/dist/exec/types.js +5 -0
- package/dist/goal/codes.js +33 -0
- package/dist/goal/command.js +175 -0
- package/dist/goal/fold.js +121 -0
- package/dist/goal/gates.js +122 -0
- package/dist/goal/index.js +22 -0
- package/dist/goal/migration.js +48 -0
- package/dist/goal/service.js +501 -0
- package/dist/goal/todo-tool.js +174 -0
- package/dist/goal/types.js +1 -0
- package/dist/goal/update-tool.js +46 -0
- package/dist/host/approval-cmd.js +276 -0
- package/dist/host/assembly.js +1146 -0
- package/dist/host/boot-failures.js +104 -0
- package/dist/host/budget-advisory.js +74 -0
- package/dist/host/budget-broadcast.js +50 -0
- package/dist/host/builtins.js +54 -0
- package/dist/host/cli.js +544 -0
- package/dist/host/codes.js +120 -0
- package/dist/host/config-schema.js +195 -0
- package/dist/host/conversation-stack.js +654 -0
- package/dist/host/core-plugins.js +1685 -0
- package/dist/host/credentials-cmd.js +42 -0
- package/dist/host/disclosure.js +30 -0
- package/dist/host/dispatch.js +105 -0
- package/dist/host/doors-cmd.js +154 -0
- package/dist/host/dump-config.js +44 -0
- package/dist/host/hook-dispatch-guard.js +27 -0
- package/dist/host/import-gate.js +153 -0
- package/dist/host/index.js +54 -0
- package/dist/host/issue-session.js +241 -0
- package/dist/host/loader.js +372 -0
- package/dist/host/main.js +161 -0
- package/dist/host/manifest.js +381 -0
- package/dist/host/mcp-entry.js +53 -0
- package/dist/host/plugin-boot.js +952 -0
- package/dist/host/plugin-context.js +672 -0
- package/dist/host/plugin-install.js +480 -0
- package/dist/host/plugin-reload.js +124 -0
- package/dist/host/plugin-store.js +462 -0
- package/dist/host/plugin-tools.js +359 -0
- package/dist/host/plugin-uninstall.js +257 -0
- package/dist/host/plugins-cmd.js +302 -0
- package/dist/host/plugins-command.js +130 -0
- package/dist/host/plugins-config.js +195 -0
- package/dist/host/prompt-sections.js +133 -0
- package/dist/host/run-entry.js +544 -0
- package/dist/host/runtime.js +209 -0
- package/dist/host/scheduler-tick.js +294 -0
- package/dist/host/serve-daemon.js +501 -0
- package/dist/host/serve-entry.js +279 -0
- package/dist/host/session-anchor.js +41 -0
- package/dist/host/sessions-cmd.js +219 -0
- package/dist/host/sessions-face.js +47 -0
- package/dist/host/settings-store.js +112 -0
- package/dist/host/signals.js +69 -0
- package/dist/host/single-instance.js +105 -0
- package/dist/host/subagent-factory.js +291 -0
- package/dist/host/testkit/harness.js +283 -0
- package/dist/host/testkit/index.js +14 -0
- package/dist/host/testkit/matrix.js +302 -0
- package/dist/host/tool-policy-store.js +177 -0
- package/dist/host/triggers.js +212 -0
- package/dist/host/tui-entry.js +216 -0
- package/dist/host/webui-bridge.js +165 -0
- package/dist/issue/codes.js +38 -0
- package/dist/issue/filter.js +146 -0
- package/dist/issue/github.js +116 -0
- package/dist/issue/index.js +17 -0
- package/dist/issue/mount.js +70 -0
- package/dist/issue/poll.js +58 -0
- package/dist/issue/service.js +341 -0
- package/dist/issue/tools.js +70 -0
- package/dist/issue/types.js +34 -0
- package/dist/issue/webhook.js +126 -0
- package/dist/llm/codes.js +77 -0
- package/dist/llm/complete.js +196 -0
- package/dist/llm/events.js +15 -0
- package/dist/llm/index.js +24 -0
- package/dist/llm/inflight.js +65 -0
- package/dist/llm/model-id.js +58 -0
- package/dist/llm/provider-face.d.ts +32 -0
- package/dist/llm/provider-face.js +34 -0
- package/dist/llm/recovery.js +146 -0
- package/dist/llm/runtime.js +46 -0
- package/dist/llm/stream-fn.js +147 -0
- package/dist/lsp/codes.js +31 -0
- package/dist/lsp/connection.js +147 -0
- package/dist/lsp/frame.js +110 -0
- package/dist/lsp/index.js +16 -0
- package/dist/lsp/inject.js +58 -0
- package/dist/lsp/instance.js +264 -0
- package/dist/lsp/service.js +522 -0
- package/dist/lsp/tools.js +53 -0
- package/dist/lsp/types.js +201 -0
- package/dist/mcp/bridge.js +222 -0
- package/dist/mcp/codes.js +21 -0
- package/dist/mcp/index.js +19 -0
- package/dist/mcp/jsonrpc.js +230 -0
- package/dist/mcp/service.js +125 -0
- package/dist/mcp/tools.js +145 -0
- package/dist/mcp/types.js +108 -0
- package/dist/memory/cite.js +131 -0
- package/dist/memory/codes.js +50 -0
- package/dist/memory/command.js +71 -0
- package/dist/memory/consolidate.js +219 -0
- package/dist/memory/cycle.js +109 -0
- package/dist/memory/dao.js +878 -0
- package/dist/memory/diff.js +238 -0
- package/dist/memory/extract.js +181 -0
- package/dist/memory/fts.js +58 -0
- package/dist/memory/index.js +42 -0
- package/dist/memory/inject.js +354 -0
- package/dist/memory/merge.js +178 -0
- package/dist/memory/migration.js +132 -0
- package/dist/memory/pollution.js +59 -0
- package/dist/memory/port.js +385 -0
- package/dist/memory/review.js +201 -0
- package/dist/memory/scan.js +89 -0
- package/dist/memory/tools.js +508 -0
- package/dist/memory/types.js +140 -0
- package/dist/obs/codes.js +38 -0
- package/dist/obs/db.js +115 -0
- package/dist/obs/index.js +20 -0
- package/dist/obs/rollup.js +61 -0
- package/dist/obs/service.js +363 -0
- package/dist/obs/session-tools.js +282 -0
- package/dist/obs/session-view.js +225 -0
- package/dist/obs/tool.js +97 -0
- package/dist/obs/types.js +1 -0
- package/dist/persist/audit.js +63 -0
- package/dist/persist/aux.js +39 -0
- package/dist/persist/codes.js +35 -0
- package/dist/persist/index.js +30 -0
- package/dist/persist/load-history.js +50 -0
- package/dist/persist/migrations.js +37 -0
- package/dist/persist/paths.js +108 -0
- package/dist/persist/persistence.js +229 -0
- package/dist/persist/schema.js +99 -0
- package/dist/persist/secret-box.js +95 -0
- package/dist/persist/store.js +706 -0
- package/dist/persist/write-behind.js +238 -0
- package/dist/safety/approval.js +171 -0
- package/dist/safety/bwrap.js +123 -0
- package/dist/safety/codes.js +57 -0
- package/dist/safety/danger.js +505 -0
- package/dist/safety/gate.js +226 -0
- package/dist/safety/index.js +24 -0
- package/dist/safety/presets.js +73 -0
- package/dist/safety/roots.js +139 -0
- package/dist/safety/sandbox.js +214 -0
- package/dist/safety/seatbelt.js +88 -0
- package/dist/safety/sensitive.js +34 -0
- package/dist/safety/tool-policy.js +203 -0
- package/dist/safety/types.js +13 -0
- package/dist/scheduler/codes.js +54 -0
- package/dist/scheduler/cron-backend.js +135 -0
- package/dist/scheduler/engine.js +280 -0
- package/dist/scheduler/gates.js +60 -0
- package/dist/scheduler/index.js +25 -0
- package/dist/scheduler/migration.js +22 -0
- package/dist/scheduler/runner.js +171 -0
- package/dist/scheduler/schedule.js +193 -0
- package/dist/scheduler/service.js +283 -0
- package/dist/scheduler/tick.js +139 -0
- package/dist/scheduler/types.js +1 -0
- package/dist/sdk/http.js +865 -0
- package/dist/sdk/index.js +22 -0
- package/dist/sdk/mcp.js +289 -0
- package/dist/sdk/plugin-route-registry.js +126 -0
- package/dist/sdk/plugin-routes.js +149 -0
- package/dist/sdk/security.js +116 -0
- package/dist/sdk/types.js +32 -0
- package/dist/session/budget.js +159 -0
- package/dist/session/codes.js +40 -0
- package/dist/session/derive.js +180 -0
- package/dist/session/event-data.js +1 -0
- package/dist/session/fork.js +72 -0
- package/dist/session/import-gates.js +148 -0
- package/dist/session/index.js +18 -0
- package/dist/session/recover.js +103 -0
- package/dist/session/session.js +279 -0
- package/dist/session/snapshot.js +107 -0
- package/dist/skills/agents.js +242 -0
- package/dist/skills/codes.js +51 -0
- package/dist/skills/discovery.js +266 -0
- package/dist/skills/frontmatter.js +215 -0
- package/dist/skills/index.js +28 -0
- package/dist/skills/load.js +118 -0
- package/dist/skills/manage.js +201 -0
- package/dist/skills/registry.js +138 -0
- package/dist/skills/render.js +124 -0
- package/dist/skills/sections.js +171 -0
- package/dist/skills/types.js +21 -0
- package/dist/subagent/codes.js +50 -0
- package/dist/subagent/declarative.js +55 -0
- package/dist/subagent/index.js +19 -0
- package/dist/subagent/notify.js +51 -0
- package/dist/subagent/provide.js +7 -0
- package/dist/subagent/registry.js +149 -0
- package/dist/subagent/service.js +338 -0
- package/dist/subagent/surface.js +44 -0
- package/dist/subagent/tool.js +153 -0
- package/dist/subagent/types.js +25 -0
- package/dist/tools/apply-patch.js +164 -0
- package/dist/tools/codes.js +109 -0
- package/dist/tools/fs.js +501 -0
- package/dist/tools/index.js +17 -0
- package/dist/tools/observed.js +99 -0
- package/dist/tools/pipeline.js +176 -0
- package/dist/tools/protected-read.js +54 -0
- package/dist/tools/registry.js +250 -0
- package/dist/tools/search.js +451 -0
- package/dist/tools/worktree.js +327 -0
- package/dist/web/codes.js +37 -0
- package/dist/web/gate.js +43 -0
- package/dist/web/hygiene.js +195 -0
- package/dist/web/index.js +16 -0
- package/dist/web/service.js +207 -0
- package/dist/web/ssrf-guard.js +44 -0
- package/dist/web/tool.js +76 -0
- package/dist/web/types.js +10 -0
- package/dist/webui/assets/index-B-t2O8gh.js +22 -0
- package/dist/webui/assets/index-DOlgSZ9Q.css +2 -0
- package/dist/webui/index.html +14 -0
- package/dist/webui/index.js +14 -0
- package/dist/webui/server.js +549 -0
- package/dist/webui/types.js +38 -0
- package/examples/README.md +26 -0
- package/examples/minimal-code-plugin/entry.js +43 -0
- package/examples/minimal-code-plugin/package.json +12 -0
- package/examples/pure-skill-pack/package.json +14 -0
- package/examples/pure-skill-pack/skills/markdown-table/SKILL.md +32 -0
- package/package.json +86 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 委派工具族(04 §10 委派面 = 静态绑定):通用委派工具 `agent`(缺省路由
|
|
3
|
+
* 'in-process')+ 声明式子代理静态工具 `agent_<name>`(闭包绑定 def——
|
|
4
|
+
* 发现/信任/frontmatter 基建镜像技能,06 §11.6)。
|
|
5
|
+
*
|
|
6
|
+
* effect 面:委派工具本身 'read'(子代理的工具面自带各自 effect 与审批
|
|
7
|
+
* 路由——审批型升权走父会话审批面,不因委派而放大父侧效果面)。
|
|
8
|
+
*/
|
|
9
|
+
import { BaseError } from '../contracts/index.js';
|
|
10
|
+
import { Type } from 'typebox';
|
|
11
|
+
import { AGENT_TOOL_NAME, AGENT_TOOL_PREFIX } from './types.js';
|
|
12
|
+
/**
|
|
13
|
+
* 执行时语境解析(两装载形合流单源):parentSessionId = 执行会话(boot 形)
|
|
14
|
+
* ?? 静态闭包位;深度/工具面 = sessionContext 产物 ?? 静态位。两源俱缺席 =
|
|
15
|
+
* 语境不可路由(诚实拒——isError 回执不伪装起跑)。
|
|
16
|
+
*/
|
|
17
|
+
function resolveToolContext(deps, toolCtx) {
|
|
18
|
+
const sessionId = toolCtx?.sessionId;
|
|
19
|
+
const fromSession = sessionId !== undefined ? deps.sessionContext?.(sessionId) : undefined;
|
|
20
|
+
const parentSessionId = sessionId ?? deps.parentSessionId;
|
|
21
|
+
const depth = fromSession?.depth ?? deps.depth ?? 1;
|
|
22
|
+
const availableTools = fromSession?.availableTools ?? (deps.availableTools !== undefined ? deps.availableTools() : undefined);
|
|
23
|
+
return {
|
|
24
|
+
...(parentSessionId !== undefined ? { parentSessionId } : {}),
|
|
25
|
+
depth,
|
|
26
|
+
...(availableTools !== undefined ? { availableTools } : {}),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** 委派回执渲染(one-shot 结果 / background Job 身份——模型面统一文案) */
|
|
30
|
+
function renderOutcome(outcome) {
|
|
31
|
+
if (outcome.mode === 'background') {
|
|
32
|
+
return {
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: 'text',
|
|
36
|
+
text: `子代理「${outcome.jobName}」已后台起跑(Job ${outcome.jobId})——终态时将注入结算通知。`,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const { result } = outcome;
|
|
42
|
+
const isError = result.stopReason !== 'stop';
|
|
43
|
+
const lines = [result.output];
|
|
44
|
+
if (result.diagnostic !== undefined && result.diagnostic !== '')
|
|
45
|
+
lines.push(`诊断:${result.diagnostic}`);
|
|
46
|
+
return {
|
|
47
|
+
content: [{ type: 'text', text: lines.filter((line) => line !== '').join('\n') || '(空输出)' }],
|
|
48
|
+
...(isError ? { isError: true } : {}),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 通用委派工具 `agent`:schema 只暴露 prompt/background(provider 路由、
|
|
53
|
+
* 白名单、深度均机器位——模型不可见动态选择器)。
|
|
54
|
+
*/
|
|
55
|
+
export function createAgentTool(deps) {
|
|
56
|
+
return {
|
|
57
|
+
name: AGENT_TOOL_NAME,
|
|
58
|
+
description: '委派一个子代理执行任务(黑盒——只见结果不见过程;缺省同步等待,background=true 后台起跑终态注入结算通知)',
|
|
59
|
+
effect: 'read',
|
|
60
|
+
parameters: Type.Object({
|
|
61
|
+
prompt: Type.String({ description: '委派目标提示(子代理的唯一任务输入)' }),
|
|
62
|
+
background: Type.Optional(Type.Boolean({ description: '后台收场(缺省 false = 父同步等结果)' })),
|
|
63
|
+
name: Type.Optional(Type.String({ description: '诊断名(Job 名与通知文案显示位)' })),
|
|
64
|
+
}),
|
|
65
|
+
async execute(args, toolCtx) {
|
|
66
|
+
// 执行时语境解析(两装载形合流——boot 形 toolCtx.sessionId 胜出)
|
|
67
|
+
const ctx = resolveToolContext(deps, toolCtx);
|
|
68
|
+
if (ctx.parentSessionId === undefined) {
|
|
69
|
+
return {
|
|
70
|
+
content: [
|
|
71
|
+
{ type: 'text', text: 'SUBAGENT_CONTEXT_MISSING:委派语境不可路由(无父会话 id——工具须经会话驱动执行)' },
|
|
72
|
+
],
|
|
73
|
+
isError: true,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const outcome = await deps.service.run({
|
|
78
|
+
prompt: String(args.prompt ?? ''),
|
|
79
|
+
...(args.background === true ? { background: true } : {}),
|
|
80
|
+
...(typeof args.name === 'string' && args.name !== '' ? { name: args.name } : {}),
|
|
81
|
+
parentSessionId: ctx.parentSessionId,
|
|
82
|
+
depth: ctx.depth,
|
|
83
|
+
...(ctx.availableTools !== undefined ? { availableTools: ctx.availableTools } : {}),
|
|
84
|
+
});
|
|
85
|
+
return renderOutcome(outcome);
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
// 机器面拒(深度帽/预检闸/路由)→ isError 数据面回执(码 + 人读)
|
|
89
|
+
if (err instanceof BaseError) {
|
|
90
|
+
return { content: [{ type: 'text', text: `${err.code}:${err.message}` }], isError: true };
|
|
91
|
+
}
|
|
92
|
+
throw err;
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* 声明式子代理静态工具 `agent_<name>`(闭包绑定 def——工具面 = 装配期
|
|
99
|
+
* 物化,06 §11.6 模型面静态多工具律)。description = 文件 description
|
|
100
|
+
* (披露段清单行 = 模型选择依据);def 字段(tools/requires/model/
|
|
101
|
+
* systemPrompt)全部闭包绑定——模型只出 prompt。def 形 = 声明式与程序化
|
|
102
|
+
* 两腿共享(filePath 位非工具构造消费——Omit 宽形两腿同构,D 批 D-2)。
|
|
103
|
+
*/
|
|
104
|
+
export function createDeclarativeAgentTool(def, deps) {
|
|
105
|
+
return {
|
|
106
|
+
name: `${AGENT_TOOL_PREFIX}${def.name}`,
|
|
107
|
+
description: def.description,
|
|
108
|
+
effect: 'read',
|
|
109
|
+
parameters: Type.Object({
|
|
110
|
+
prompt: Type.String({ description: '委派目标提示' }),
|
|
111
|
+
background: Type.Optional(Type.Boolean({ description: '后台收场(缺省 false = 父同步等结果)' })),
|
|
112
|
+
}),
|
|
113
|
+
async execute(args, toolCtx) {
|
|
114
|
+
// 执行时语境解析(两装载形合流——boot 形 toolCtx.sessionId 胜出)
|
|
115
|
+
const ctx = resolveToolContext(deps, toolCtx);
|
|
116
|
+
if (ctx.parentSessionId === undefined) {
|
|
117
|
+
return {
|
|
118
|
+
content: [
|
|
119
|
+
{ type: 'text', text: 'SUBAGENT_CONTEXT_MISSING:委派语境不可路由(无父会话 id——工具须经会话驱动执行)' },
|
|
120
|
+
],
|
|
121
|
+
isError: true,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const outcome = await deps.service.run({
|
|
126
|
+
providerName: def.name,
|
|
127
|
+
prompt: String(args.prompt ?? ''),
|
|
128
|
+
...(args.background === true ? { background: true } : {}),
|
|
129
|
+
...(def.tools !== undefined ? { tools: def.tools } : {}),
|
|
130
|
+
...(def.requires !== undefined ? { requiresTools: def.requires } : {}),
|
|
131
|
+
...(def.model !== undefined ? { model: def.model } : {}),
|
|
132
|
+
systemPrompt: def.systemPrompt,
|
|
133
|
+
name: def.name,
|
|
134
|
+
parentSessionId: ctx.parentSessionId,
|
|
135
|
+
depth: ctx.depth,
|
|
136
|
+
...(ctx.availableTools !== undefined ? { availableTools: ctx.availableTools } : {}),
|
|
137
|
+
});
|
|
138
|
+
return renderOutcome(outcome);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (err instanceof BaseError) {
|
|
142
|
+
return { content: [{ type: 'text', text: `${err.code}:${err.message}` }], isError: true };
|
|
143
|
+
}
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// 程序化注册位的消费腿已改动词层即时物化(遗漏审计批 G——03 §2.2 行 109
|
|
150
|
+
// 「注册即派生」):ctx.agent.registerSubagentProvider 内 service 位落册后
|
|
151
|
+
// 经装配链注入的物化回调单条派生(createDeclarativeAgentTool 单源)入 boot
|
|
152
|
+
// 全局层;原批量快照物化函数(createProgrammaticTools)随之退役删除——
|
|
153
|
+
// programmaticProviders() 读面保留作注册册标准读面。
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** 通用委派工具名(04 §10 委派面静态绑定——缺省路由 'in-process') */
|
|
2
|
+
export const AGENT_TOOL_NAME = 'agent';
|
|
3
|
+
/**
|
|
4
|
+
* named provider 派生工具名前缀(**保留字段**——03 §2.7 行 254):`agent_<name>`
|
|
5
|
+
* 段专属 named provider 派生工具,插件经 ctx.tools.register 携此前缀即拒
|
|
6
|
+
* TOOL_NAME_CONFLICT(保留字在注册面执法——先占位即反锁后续 named provider
|
|
7
|
+
* 注册;执法位在 host ctx.tools.register 包装道,机器侧放行 host 物化腿)。
|
|
8
|
+
*/
|
|
9
|
+
export const AGENT_TOOL_PREFIX = 'agent_';
|
|
10
|
+
/** 缺省委派路由(通用 agent 工具的 providerName 缺省值) */
|
|
11
|
+
export const DEFAULT_SUBAGENT_PROVIDER = 'in-process';
|
|
12
|
+
/**
|
|
13
|
+
* 派生工具面结构性排除五名(04 §10):fs read/write/edit/ls + bash。
|
|
14
|
+
* - fs 四名:子自建 fs 族(驱动层注册——结构性不入派生集);
|
|
15
|
+
* - bash:永不升格总则下的特例条款(子管道无人在场应答 def 内部升权)。
|
|
16
|
+
*/
|
|
17
|
+
export const EXCLUDED_FROM_DERIVED_SURFACE = ['read', 'write', 'edit', 'ls', 'bash'];
|
|
18
|
+
/** in-process 子代理的能力面(真工厂独立装配全套——五布尔恒真) */
|
|
19
|
+
export const IN_PROCESS_CAPABILITIES = {
|
|
20
|
+
tools: true,
|
|
21
|
+
streaming: true,
|
|
22
|
+
cancel: true,
|
|
23
|
+
background: true,
|
|
24
|
+
structuredOutput: true,
|
|
25
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* L2 tools — apply_patch 补丁格式(codex 原创;04 §7 fs 族 edit 段拍板采纳
|
|
3
|
+
* 为本仓 edit 工具格式,in-process 应用——码面按协议新写)。
|
|
4
|
+
*
|
|
5
|
+
* 支持的最小子集(M1):
|
|
6
|
+
*
|
|
7
|
+
* *** Begin Patch
|
|
8
|
+
* *** Update File: path/to/file
|
|
9
|
+
* context 行(定位锚,原样保留进新内容)
|
|
10
|
+
* -被删除的行
|
|
11
|
+
* +替换后的新行
|
|
12
|
+
* *** Add File: new.txt
|
|
13
|
+
* +整文件内容逐行
|
|
14
|
+
* *** Delete File: old.txt
|
|
15
|
+
* *** End Patch
|
|
16
|
+
*
|
|
17
|
+
* 语义声明(照实文档化,非缺陷):跨文件顺序应用、**非原子**、无回滚——中
|
|
18
|
+
* 途失败停在失败处(已应用文件保留)。fs 工具族在应用前**全部文件先过
|
|
19
|
+
* CAS + fence 校验、全部补丁先解析算内容**,把「半途而废」窗口压到最小
|
|
20
|
+
* (两阶段:校验段全过 → 顺序应用段——04 §7 edit 细则)。
|
|
21
|
+
*/
|
|
22
|
+
import { BaseError } from '../contracts/index.js';
|
|
23
|
+
/** 补丁解析/应用失败统一形态(message 细说行号与原因) */
|
|
24
|
+
function patchError(message) {
|
|
25
|
+
return new BaseError('FS_PATCH_FAILED', `[FS_PATCH_FAILED] ${message}`);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 解析 apply_patch 文本 → 操作列表。
|
|
29
|
+
* 行首标记:`*** ` 段指令;`+` 新增;`-` 删除;空格前缀(或裸空行,宽容收)
|
|
30
|
+
* = 上下文行。首尾必须恰是 Begin/End Patch;空补丁(零文件操作段)拒绝。
|
|
31
|
+
*/
|
|
32
|
+
export function parseApplyPatch(text) {
|
|
33
|
+
const lines = text.split('\n');
|
|
34
|
+
// split 的尾部换行产物(空串尾巴)先剥——其余空行是合法的空上下文行
|
|
35
|
+
if (lines.length > 0 && lines[lines.length - 1] === '')
|
|
36
|
+
lines.pop();
|
|
37
|
+
const first = lines[0];
|
|
38
|
+
if (first === undefined || first.trim() !== '*** Begin Patch') {
|
|
39
|
+
throw patchError(`补丁必须以 "*** Begin Patch" 开头(实际首行:${JSON.stringify(first ?? '')})`);
|
|
40
|
+
}
|
|
41
|
+
const last = lines[lines.length - 1];
|
|
42
|
+
if (last === undefined || last.trim() !== '*** End Patch') {
|
|
43
|
+
throw patchError(`补丁必须以 "*** End Patch" 结尾(实际末行:${JSON.stringify(last ?? '')})`);
|
|
44
|
+
}
|
|
45
|
+
const ops = [];
|
|
46
|
+
/** 当前段累积器(Update/Add 的行流;Delete 无行流) */
|
|
47
|
+
let current;
|
|
48
|
+
/** 至少出现过一个文件操作段(空补丁拒绝) */
|
|
49
|
+
let sawOperation = false;
|
|
50
|
+
/** 收束当前段入列(空行流校验在收束点——段完整性最末判定) */
|
|
51
|
+
const finishCurrent = () => {
|
|
52
|
+
if (current === undefined)
|
|
53
|
+
return;
|
|
54
|
+
if (current.kind === 'add' && current.lines.length === 0) {
|
|
55
|
+
throw patchError(`*** Add File: ${current.path} 无内容行(新增文件至少一行 "+")`);
|
|
56
|
+
}
|
|
57
|
+
if (current.kind === 'update' && current.lines.length === 0) {
|
|
58
|
+
throw patchError(`*** Update File: ${current.path} 无行(更新至少一行上下文/增删)`);
|
|
59
|
+
}
|
|
60
|
+
ops.push(current);
|
|
61
|
+
current = undefined;
|
|
62
|
+
};
|
|
63
|
+
// 首尾行已校验,循环体只走中间行
|
|
64
|
+
for (let i = 1; i < lines.length - 1; i++) {
|
|
65
|
+
const raw = lines[i];
|
|
66
|
+
if (raw.startsWith('*** ')) {
|
|
67
|
+
// 段指令:收束上一段、开新段
|
|
68
|
+
finishCurrent();
|
|
69
|
+
const directive = raw.slice(4).trim();
|
|
70
|
+
if (directive.startsWith('Update File:')) {
|
|
71
|
+
current = { kind: 'update', path: directive.slice('Update File:'.length).trim(), lines: [] };
|
|
72
|
+
}
|
|
73
|
+
else if (directive.startsWith('Add File:')) {
|
|
74
|
+
current = { kind: 'add', path: directive.slice('Add File:'.length).trim(), lines: [] };
|
|
75
|
+
}
|
|
76
|
+
else if (directive.startsWith('Delete File:')) {
|
|
77
|
+
current = { kind: 'delete', path: directive.slice('Delete File:'.length).trim() };
|
|
78
|
+
}
|
|
79
|
+
else if (directive.startsWith('End Patch')) {
|
|
80
|
+
// 末行已保证 End Patch;中途出现 = 多余段指令
|
|
81
|
+
throw patchError(`第 ${i + 1} 行出现多余的 "*** End Patch"`);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw patchError(`第 ${i + 1} 行未知段指令:${JSON.stringify(directive)}(M1 仅支持 Update File / Add File / Delete File)`);
|
|
85
|
+
}
|
|
86
|
+
sawOperation = true;
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (current === undefined) {
|
|
90
|
+
throw patchError(`第 ${i + 1} 行出现在任何 *** 段指令之前:${JSON.stringify(raw)}`);
|
|
91
|
+
}
|
|
92
|
+
if (current.kind === 'delete') {
|
|
93
|
+
throw patchError(`*** Delete File: ${current.path} 之后不允许行内容(第 ${i + 1} 行)`);
|
|
94
|
+
}
|
|
95
|
+
if (raw.startsWith('+')) {
|
|
96
|
+
current.lines.push({ tag: 'added', text: raw.slice(1) });
|
|
97
|
+
}
|
|
98
|
+
else if (raw.startsWith('-')) {
|
|
99
|
+
if (current.kind === 'add') {
|
|
100
|
+
throw patchError(`*** Add File: ${current.path} 段内不允许 "-" 删除行(第 ${i + 1} 行)`);
|
|
101
|
+
}
|
|
102
|
+
current.lines.push({ tag: 'removed', text: raw.slice(1) });
|
|
103
|
+
}
|
|
104
|
+
else if (raw.startsWith(' ')) {
|
|
105
|
+
current.lines.push({ tag: 'context', text: raw.slice(1) });
|
|
106
|
+
}
|
|
107
|
+
else if (raw === '') {
|
|
108
|
+
// 裸空行按空上下文行收(codex 格式规范形是 " ",裸空行更常见——宽容)
|
|
109
|
+
current.lines.push({ tag: 'context', text: '' });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw patchError(`第 ${i + 1} 行无行首标记(应为 "+" / "-" / " " 之一):${JSON.stringify(raw)}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
finishCurrent();
|
|
116
|
+
if (!sawOperation) {
|
|
117
|
+
throw patchError('补丁不含任何文件操作段(Update File / Add File / Delete File)');
|
|
118
|
+
}
|
|
119
|
+
return ops;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* 对单文件内容应用 Update 行流:在原行序列中滑窗找**首个**完全匹配点,替
|
|
123
|
+
* 换后返回新内容。匹配 = 行流中 context/removed 行与原文连续片段逐行全等
|
|
124
|
+
* (added 行不参与匹配);无匹配点 = 补丁基于过时内容,FS_PATCH_FAILED 拒。
|
|
125
|
+
*/
|
|
126
|
+
export function applyUpdateLines(path, source, patchLines) {
|
|
127
|
+
const original = source.split('\n');
|
|
128
|
+
// 尾换行剥除记号:原文以 \n 收尾时 split 产空尾,应用后按原样补回
|
|
129
|
+
const hadTrailingNewline = source.endsWith('\n');
|
|
130
|
+
if (hadTrailingNewline)
|
|
131
|
+
original.pop();
|
|
132
|
+
/** 参与匹配的行(context+removed 按序——added 不参与定位) */
|
|
133
|
+
const matchSeq = patchLines.filter((line) => line.tag !== 'added');
|
|
134
|
+
if (matchSeq.length === 0) {
|
|
135
|
+
throw patchError(`${path}:hunk 无 context/- 行,无法定位(至少一行定位锚)`);
|
|
136
|
+
}
|
|
137
|
+
// 滑窗找首个匹配点(贪心首匹配——多个匹配取最先出现处)
|
|
138
|
+
let matchAt = -1;
|
|
139
|
+
outer: for (let start = 0; start + matchSeq.length <= original.length; start++) {
|
|
140
|
+
for (let j = 0; j < matchSeq.length; j++) {
|
|
141
|
+
if (original[start + j] !== matchSeq[j].text)
|
|
142
|
+
continue outer;
|
|
143
|
+
}
|
|
144
|
+
matchAt = start;
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (matchAt < 0) {
|
|
148
|
+
throw patchError(`${path}:hunk 定位失败——补丁 context/- 行在文件中无连续匹配(期望片段首行:${JSON.stringify(matchSeq[0].text)})。文件在读取后可能已被修改`);
|
|
149
|
+
}
|
|
150
|
+
// 重组:匹配点之前 + 行流展开(context/added 落为新内容,removed 丢弃)+ 匹配窗口之后
|
|
151
|
+
const replacement = [];
|
|
152
|
+
for (const line of patchLines) {
|
|
153
|
+
if (line.tag === 'removed')
|
|
154
|
+
continue;
|
|
155
|
+
replacement.push(line.text);
|
|
156
|
+
}
|
|
157
|
+
const merged = [...original.slice(0, matchAt), ...replacement, ...original.slice(matchAt + matchSeq.length)];
|
|
158
|
+
return merged.length === 0 ? '' : `${merged.join('\n')}${hadTrailingNewline ? '\n' : ''}`;
|
|
159
|
+
}
|
|
160
|
+
/** Add 行流 → 文件内容(全 added;context 行在 Add 语义下也按内容收——宽容) */
|
|
161
|
+
export function addLinesToContent(lines) {
|
|
162
|
+
const texts = lines.map((line) => line.text);
|
|
163
|
+
return texts.length === 0 ? '' : `${texts.join('\n')}\n`;
|
|
164
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tools 域错误码注册(04 §7 三段管道 + 注册面 + fs 工具族——TOOL_/FS_ 前缀族首批)。
|
|
3
|
+
*
|
|
4
|
+
* 前缀族明列见 contracts/errors.ts ERROR_CODE_PREFIXES(02 §5.3 #1);码名清
|
|
5
|
+
* 单与语义真源 = 02 篇 §5.3 TOOL_/FS_ 族明列段(2026-09-06 tools 纵切批)。
|
|
6
|
+
* 本文件由模块公开面 index.ts 引入(注册纪律:写入点文件必须实际 import 本
|
|
7
|
+
* 文件注册才发生——与 llm/session/persist 的 codes.ts 同款)。
|
|
8
|
+
*/
|
|
9
|
+
import { registerErrorCodes } from '../contracts/index.js';
|
|
10
|
+
registerErrorCodes([
|
|
11
|
+
// ---- TOOL_ 族(管道与注册面)----
|
|
12
|
+
{
|
|
13
|
+
code: 'TOOL_INVALID_ARGS',
|
|
14
|
+
module: 'tools',
|
|
15
|
+
description: 'schema 段参数校验拒(04 §7 段 1)——模型拿到的可纠正错误回执',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
code: 'TOOL_BLOCKED',
|
|
19
|
+
module: 'tools',
|
|
20
|
+
description: '守门段 block 短路(04 §7 段 2)——拒绝原因随码入结果,模型可见可自纠',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
code: 'TOOL_GATE_FAILED',
|
|
24
|
+
module: 'tools',
|
|
25
|
+
description: '守门监听器自身抛错——fail-closed 视同 block(先落 gate/decision 再拒)',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
code: 'TOOL_TIMEOUT',
|
|
29
|
+
module: 'tools',
|
|
30
|
+
description: '执行段单工具预算超时(def.timeoutMs 或缺省 60s)——竞速先到即拒',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
code: 'TOOL_NAME_CONFLICT',
|
|
34
|
+
module: 'tools',
|
|
35
|
+
description: '注册撞名拒绝式(03 §2.7——碰撞域内双向对称:宿主内建/官方件/兄弟插件)',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
code: 'TOOL_DESCRIPTION_REJECTED',
|
|
39
|
+
module: 'tools',
|
|
40
|
+
description: '描述注入模式扫描命中拒注册(03 §2.8——任何来源同一防线,官方件同受管)',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
code: 'TOOL_REGISTRY_CAPACITY',
|
|
44
|
+
module: 'tools',
|
|
45
|
+
description: '注册表两层合计达 10^3 总量帽(03 §3.4 双帽之一)——超限拒新注册',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
code: 'TOOL_CHANGE_RATE_LIMITED',
|
|
49
|
+
module: 'tools',
|
|
50
|
+
description: 'register/unregister 令牌桶空拒(03 §3.4 双帽之二——容量 240、回填 600/分钟)',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
code: 'TOOL_SCHEMA_INVALID',
|
|
54
|
+
module: 'tools',
|
|
55
|
+
description: 'parameters 根节点非 object——注册即拒(provider 声明契约只认根 object)',
|
|
56
|
+
},
|
|
57
|
+
// ---- FS_ 族(fs 工具族)----
|
|
58
|
+
{
|
|
59
|
+
code: 'FS_NOT_OBSERVED',
|
|
60
|
+
module: 'tools',
|
|
61
|
+
description: '未观察径直写拒(04 §7 CAS 观察态)——先读后写是结构纪律',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
code: 'FS_VERSION_CONFLICT',
|
|
65
|
+
module: 'tools',
|
|
66
|
+
description: '观察指纹不符/读后他方并发创建/读后删除——丢失更新守卫,重新 read 再写',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
code: 'FS_OUTSIDE_WRITABLE_ROOTS',
|
|
70
|
+
module: 'tools',
|
|
71
|
+
description: '写目标 canonical 化后不在任何可写根内(04 §7 fence)',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
code: 'FS_WRITE_TARGET_DRIFTED',
|
|
75
|
+
module: 'tools',
|
|
76
|
+
description: '写串行链段内写目标漂移(符号链被换/目录被移)——重验不过拒落盘',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
code: 'FS_NOT_FOUND',
|
|
80
|
+
module: 'tools',
|
|
81
|
+
description: 'read/ls 目标不存在(read 仍登记 absent 观察——「这里没有文件」也是观察)',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
code: 'FS_DECODE_NON_UTF8',
|
|
85
|
+
module: 'tools',
|
|
86
|
+
description: '文本读 UTF-8 严格解码 lossy 拒(04 §7 编码纪律——防 mojibake 静默进上下文)',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
code: 'FS_PATCH_FAILED',
|
|
90
|
+
module: 'tools',
|
|
91
|
+
description: 'apply_patch 补丁格式解析失败或 update 定位失败(context 行锚不在场即拒)',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
code: 'FS_READ_PROTECTED',
|
|
95
|
+
module: 'tools',
|
|
96
|
+
description: '读目标命中敏感件保护面硬拒(04 §7 读侧 carve-out)——密钥与免问面恒不可读,fail-closed 无审批出路',
|
|
97
|
+
},
|
|
98
|
+
// ---- FS_ 族 worktree 三码(04 §7 worktree 条——批 16 worktree 工具族)----
|
|
99
|
+
{
|
|
100
|
+
code: 'FS_WORKTREE_EXISTS',
|
|
101
|
+
module: 'tools',
|
|
102
|
+
description: 'worktree/同名分支已存在拒建(名字即分支名——双域撞名同码)',
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
code: 'FS_WORKTREE_DIRTY',
|
|
106
|
+
module: 'tools',
|
|
107
|
+
description: 'worktree 有未提交变更拒拆(防误清宁拒勿删——force 形显式覆盖)',
|
|
108
|
+
},
|
|
109
|
+
]);
|