strands-darwin 0.0.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/README.md +140 -0
- package/README.zh-CN.md +140 -0
- package/dist/patches/@strands-agents+sdk+1.16.0.patch +1443 -0
- package/dist/src/agent/background-delegation.d.ts +67 -0
- package/dist/src/agent/background-delegation.js +159 -0
- package/dist/src/agent/background-delegation.js.map +1 -0
- package/dist/src/agent/call-stats.d.ts +118 -0
- package/dist/src/agent/call-stats.js +128 -0
- package/dist/src/agent/call-stats.js.map +1 -0
- package/dist/src/agent/compact.d.ts +108 -0
- package/dist/src/agent/compact.js +192 -0
- package/dist/src/agent/compact.js.map +1 -0
- package/dist/src/agent/context-anchor.d.ts +64 -0
- package/dist/src/agent/context-anchor.js +43 -0
- package/dist/src/agent/context-anchor.js.map +1 -0
- package/dist/src/agent/cost.d.ts +56 -0
- package/dist/src/agent/cost.js +44 -0
- package/dist/src/agent/cost.js.map +1 -0
- package/dist/src/agent/diagnostics.d.ts +212 -0
- package/dist/src/agent/diagnostics.js +374 -0
- package/dist/src/agent/diagnostics.js.map +1 -0
- package/dist/src/agent/instructions.d.ts +54 -0
- package/dist/src/agent/instructions.js +118 -0
- package/dist/src/agent/instructions.js.map +1 -0
- package/dist/src/agent/max-tokens-recovery.d.ts +17 -0
- package/dist/src/agent/max-tokens-recovery.js +65 -0
- package/dist/src/agent/max-tokens-recovery.js.map +1 -0
- package/dist/src/agent/model-call-budget.d.ts +8 -0
- package/dist/src/agent/model-call-budget.js +24 -0
- package/dist/src/agent/model-call-budget.js.map +1 -0
- package/dist/src/agent/model-retry.d.ts +134 -0
- package/dist/src/agent/model-retry.js +256 -0
- package/dist/src/agent/model-retry.js.map +1 -0
- package/dist/src/agent/permission-rules.d.ts +47 -0
- package/dist/src/agent/permission-rules.js +260 -0
- package/dist/src/agent/permission-rules.js.map +1 -0
- package/dist/src/agent/permission.d.ts +361 -0
- package/dist/src/agent/permission.js +797 -0
- package/dist/src/agent/permission.js.map +1 -0
- package/dist/src/agent/prompt-cache.d.ts +66 -0
- package/dist/src/agent/prompt-cache.js +194 -0
- package/dist/src/agent/prompt-cache.js.map +1 -0
- package/dist/src/agent/refusal.d.ts +20 -0
- package/dist/src/agent/refusal.js +23 -0
- package/dist/src/agent/refusal.js.map +1 -0
- package/dist/src/agent/retry-guard.d.ts +26 -0
- package/dist/src/agent/retry-guard.js +193 -0
- package/dist/src/agent/retry-guard.js.map +1 -0
- package/dist/src/agent/rewind.d.ts +29 -0
- package/dist/src/agent/rewind.js +118 -0
- package/dist/src/agent/rewind.js.map +1 -0
- package/dist/src/agent/runtime.d.ts +814 -0
- package/dist/src/agent/runtime.js +1596 -0
- package/dist/src/agent/runtime.js.map +1 -0
- package/dist/src/agent/safety-classifier.d.ts +11 -0
- package/dist/src/agent/safety-classifier.js +0 -0
- package/dist/src/agent/safety-classifier.js.map +1 -0
- package/dist/src/agent/sdk-logging.d.ts +49 -0
- package/dist/src/agent/sdk-logging.js +110 -0
- package/dist/src/agent/sdk-logging.js.map +1 -0
- package/dist/src/agent/session.d.ts +102 -0
- package/dist/src/agent/session.js +244 -0
- package/dist/src/agent/session.js.map +1 -0
- package/dist/src/agent/stream-resumption.d.ts +16 -0
- package/dist/src/agent/stream-resumption.js +33 -0
- package/dist/src/agent/stream-resumption.js.map +1 -0
- package/dist/src/agent/system-prompt.d.ts +50 -0
- package/dist/src/agent/system-prompt.js +161 -0
- package/dist/src/agent/system-prompt.js.map +1 -0
- package/dist/src/agent/thinking.d.ts +99 -0
- package/dist/src/agent/thinking.js +145 -0
- package/dist/src/agent/thinking.js.map +1 -0
- package/dist/src/agent/usage.d.ts +132 -0
- package/dist/src/agent/usage.js +233 -0
- package/dist/src/agent/usage.js.map +1 -0
- package/dist/src/agent/working-context.d.ts +51 -0
- package/dist/src/agent/working-context.js +160 -0
- package/dist/src/agent/working-context.js.map +1 -0
- package/dist/src/agents/child-recipe.d.ts +33 -0
- package/dist/src/agents/child-recipe.js +98 -0
- package/dist/src/agents/child-recipe.js.map +1 -0
- package/dist/src/agents/concurrency-limit.d.ts +25 -0
- package/dist/src/agents/concurrency-limit.js +43 -0
- package/dist/src/agents/concurrency-limit.js.map +1 -0
- package/dist/src/agents/dispatch-registry.d.ts +180 -0
- package/dist/src/agents/dispatch-registry.js +289 -0
- package/dist/src/agents/dispatch-registry.js.map +1 -0
- package/dist/src/agents/failed-child-text.d.ts +44 -0
- package/dist/src/agents/failed-child-text.js +69 -0
- package/dist/src/agents/failed-child-text.js.map +1 -0
- package/dist/src/agents/loader.d.ts +26 -0
- package/dist/src/agents/loader.js +134 -0
- package/dist/src/agents/loader.js.map +1 -0
- package/dist/src/agents/report-projection.d.ts +31 -0
- package/dist/src/agents/report-projection.js +125 -0
- package/dist/src/agents/report-projection.js.map +1 -0
- package/dist/src/agents/subagent-tool.d.ts +61 -0
- package/dist/src/agents/subagent-tool.js +180 -0
- package/dist/src/agents/subagent-tool.js.map +1 -0
- package/dist/src/agents/workflow-tool.d.ts +85 -0
- package/dist/src/agents/workflow-tool.js +530 -0
- package/dist/src/agents/workflow-tool.js.map +1 -0
- package/dist/src/cli-args.d.ts +39 -0
- package/dist/src/cli-args.js +198 -0
- package/dist/src/cli-args.js.map +1 -0
- package/dist/src/cli-doctor.d.ts +26 -0
- package/dist/src/cli-doctor.js +398 -0
- package/dist/src/cli-doctor.js.map +1 -0
- package/dist/src/cli-main.d.ts +1 -0
- package/dist/src/cli-main.js +279 -0
- package/dist/src/cli-main.js.map +1 -0
- package/dist/src/cli-sessions.d.ts +17 -0
- package/dist/src/cli-sessions.js +136 -0
- package/dist/src/cli-sessions.js.map +1 -0
- package/dist/src/cli-trajectory.d.ts +37 -0
- package/dist/src/cli-trajectory.js +303 -0
- package/dist/src/cli-trajectory.js.map +1 -0
- package/dist/src/cli-usage.d.ts +18 -0
- package/dist/src/cli-usage.js +53 -0
- package/dist/src/cli-usage.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +29 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/commands/custom-commands.d.ts +43 -0
- package/dist/src/commands/custom-commands.js +155 -0
- package/dist/src/commands/custom-commands.js.map +1 -0
- package/dist/src/commands/workflow-command.d.ts +26 -0
- package/dist/src/commands/workflow-command.js +56 -0
- package/dist/src/commands/workflow-command.js.map +1 -0
- package/dist/src/config.d.ts +463 -0
- package/dist/src/config.js +1457 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/context-overflow-error.d.ts +7 -0
- package/dist/src/context-overflow-error.js +26 -0
- package/dist/src/context-overflow-error.js.map +1 -0
- package/dist/src/dev-repl.d.ts +1 -0
- package/dist/src/dev-repl.js +365 -0
- package/dist/src/dev-repl.js.map +1 -0
- package/dist/src/headless-protocol.d.ts +147 -0
- package/dist/src/headless-protocol.js +359 -0
- package/dist/src/headless-protocol.js.map +1 -0
- package/dist/src/headless-runner.d.ts +30 -0
- package/dist/src/headless-runner.js +405 -0
- package/dist/src/headless-runner.js.map +1 -0
- package/dist/src/headless-stdin.d.ts +28 -0
- package/dist/src/headless-stdin.js +78 -0
- package/dist/src/headless-stdin.js.map +1 -0
- package/dist/src/headless.d.ts +106 -0
- package/dist/src/headless.js +229 -0
- package/dist/src/headless.js.map +1 -0
- package/dist/src/hooks/codex-hook-runner.d.ts +92 -0
- package/dist/src/hooks/codex-hook-runner.js +446 -0
- package/dist/src/hooks/codex-hook-runner.js.map +1 -0
- package/dist/src/hooks/codex-hooks.d.ts +23 -0
- package/dist/src/hooks/codex-hooks.js +152 -0
- package/dist/src/hooks/codex-hooks.js.map +1 -0
- package/dist/src/hooks/hook-process.d.ts +23 -0
- package/dist/src/hooks/hook-process.js +241 -0
- package/dist/src/hooks/hook-process.js.map +1 -0
- package/dist/src/hooks/lifecycle-hooks.d.ts +37 -0
- package/dist/src/hooks/lifecycle-hooks.js +153 -0
- package/dist/src/hooks/lifecycle-hooks.js.map +1 -0
- package/dist/src/hooks/tool-hooks.d.ts +63 -0
- package/dist/src/hooks/tool-hooks.js +350 -0
- package/dist/src/hooks/tool-hooks.js.map +1 -0
- package/dist/src/mcp/codegraph-preflight.d.ts +29 -0
- package/dist/src/mcp/codegraph-preflight.js +232 -0
- package/dist/src/mcp/codegraph-preflight.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +133 -0
- package/dist/src/mcp/registry.js +209 -0
- package/dist/src/mcp/registry.js.map +1 -0
- package/dist/src/mcp/web-search-empty-results.d.ts +14 -0
- package/dist/src/mcp/web-search-empty-results.js +94 -0
- package/dist/src/mcp/web-search-empty-results.js.map +1 -0
- package/dist/src/memory/command.d.ts +11 -0
- package/dist/src/memory/command.js +253 -0
- package/dist/src/memory/command.js.map +1 -0
- package/dist/src/memory/controller.d.ts +51 -0
- package/dist/src/memory/controller.js +316 -0
- package/dist/src/memory/controller.js.map +1 -0
- package/dist/src/memory/prompt.d.ts +4 -0
- package/dist/src/memory/prompt.js +22 -0
- package/dist/src/memory/prompt.js.map +1 -0
- package/dist/src/memory/scheduler.d.ts +33 -0
- package/dist/src/memory/scheduler.js +134 -0
- package/dist/src/memory/scheduler.js.map +1 -0
- package/dist/src/memory/state.d.ts +112 -0
- package/dist/src/memory/state.js +355 -0
- package/dist/src/memory/state.js.map +1 -0
- package/dist/src/memory/store.d.ts +19 -0
- package/dist/src/memory/store.js +130 -0
- package/dist/src/memory/store.js.map +1 -0
- package/dist/src/memory/tools.d.ts +29 -0
- package/dist/src/memory/tools.js +22 -0
- package/dist/src/memory/tools.js.map +1 -0
- package/dist/src/memory/validation.d.ts +33 -0
- package/dist/src/memory/validation.js +159 -0
- package/dist/src/memory/validation.js.map +1 -0
- package/dist/src/npm-package/generate-patch.d.ts +23 -0
- package/dist/src/npm-package/generate-patch.js +88 -0
- package/dist/src/npm-package/generate-patch.js.map +1 -0
- package/dist/src/npm-package/patch-package-format.d.ts +43 -0
- package/dist/src/npm-package/patch-package-format.js +66 -0
- package/dist/src/npm-package/patch-package-format.js.map +1 -0
- package/dist/src/paths.d.ts +39 -0
- package/dist/src/paths.js +105 -0
- package/dist/src/paths.js.map +1 -0
- package/dist/src/pricing/cost.d.ts +182 -0
- package/dist/src/pricing/cost.js +215 -0
- package/dist/src/pricing/cost.js.map +1 -0
- package/dist/src/pricing/model-prices.d.ts +112 -0
- package/dist/src/pricing/model-prices.js +320 -0
- package/dist/src/pricing/model-prices.js.map +1 -0
- package/dist/src/sdk-patch-preflight.d.ts +23 -0
- package/dist/src/sdk-patch-preflight.js +71 -0
- package/dist/src/sdk-patch-preflight.js.map +1 -0
- package/dist/src/skills/builtin/commit-message/SKILL.md +45 -0
- package/dist/src/skills/builtin/commit-message/references/types.md +8 -0
- package/dist/src/skills/builtin/developer/SKILL.md +107 -0
- package/dist/src/skills/builtin/self-evolution-research/SKILL.md +150 -0
- package/dist/src/skills/builtin/self-evolution-research/scripts/roll-research-path.mjs +208 -0
- package/dist/src/skills/builtin/self-reflection/SKILL.md +172 -0
- package/dist/src/skills/builtin/self-reflection/references/reflection-template.md +90 -0
- package/dist/src/skills/builtin/self-reflection/scripts/locate-trajectory.mjs +175 -0
- package/dist/src/skills/loader.d.ts +26 -0
- package/dist/src/skills/loader.js +186 -0
- package/dist/src/skills/loader.js.map +1 -0
- package/dist/src/skills/plugin.d.ts +34 -0
- package/dist/src/skills/plugin.js +137 -0
- package/dist/src/skills/plugin.js.map +1 -0
- package/dist/src/skills/prompt.d.ts +8 -0
- package/dist/src/skills/prompt.js +214 -0
- package/dist/src/skills/prompt.js.map +1 -0
- package/dist/src/skills/resource-safety.d.ts +15 -0
- package/dist/src/skills/resource-safety.js +149 -0
- package/dist/src/skills/resource-safety.js.map +1 -0
- package/dist/src/tools/background-bash.d.ts +95 -0
- package/dist/src/tools/background-bash.js +639 -0
- package/dist/src/tools/background-bash.js.map +1 -0
- package/dist/src/tools/background-tail.d.ts +28 -0
- package/dist/src/tools/background-tail.js +75 -0
- package/dist/src/tools/background-tail.js.map +1 -0
- package/dist/src/tools/background-wait-contract.d.ts +4 -0
- package/dist/src/tools/background-wait-contract.js +7 -0
- package/dist/src/tools/background-wait-contract.js.map +1 -0
- package/dist/src/tools/file-editor-serial.d.ts +24 -0
- package/dist/src/tools/file-editor-serial.js +99 -0
- package/dist/src/tools/file-editor-serial.js.map +1 -0
- package/dist/src/tools/image-viewer.d.ts +43 -0
- package/dist/src/tools/image-viewer.js +256 -0
- package/dist/src/tools/image-viewer.js.map +1 -0
- package/dist/src/tools/update-plan.d.ts +30 -0
- package/dist/src/tools/update-plan.js +65 -0
- package/dist/src/tools/update-plan.js.map +1 -0
- package/dist/src/tools/web-fetch.d.ts +70 -0
- package/dist/src/tools/web-fetch.js +667 -0
- package/dist/src/tools/web-fetch.js.map +1 -0
- package/dist/src/trajectory/export.d.ts +31 -0
- package/dist/src/trajectory/export.js +116 -0
- package/dist/src/trajectory/export.js.map +1 -0
- package/dist/src/trajectory/fork.d.ts +19 -0
- package/dist/src/trajectory/fork.js +110 -0
- package/dist/src/trajectory/fork.js.map +1 -0
- package/dist/src/trajectory/memory-tool.d.ts +20 -0
- package/dist/src/trajectory/memory-tool.js +98 -0
- package/dist/src/trajectory/memory-tool.js.map +1 -0
- package/dist/src/trajectory/prompt-history.d.ts +62 -0
- package/dist/src/trajectory/prompt-history.js +256 -0
- package/dist/src/trajectory/prompt-history.js.map +1 -0
- package/dist/src/trajectory/reader.d.ts +21 -0
- package/dist/src/trajectory/reader.js +62 -0
- package/dist/src/trajectory/reader.js.map +1 -0
- package/dist/src/trajectory/record.d.ts +417 -0
- package/dist/src/trajectory/record.js +394 -0
- package/dist/src/trajectory/record.js.map +1 -0
- package/dist/src/trajectory/replay.d.ts +74 -0
- package/dist/src/trajectory/replay.js +285 -0
- package/dist/src/trajectory/replay.js.map +1 -0
- package/dist/src/trajectory/resume-recap.d.ts +43 -0
- package/dist/src/trajectory/resume-recap.js +68 -0
- package/dist/src/trajectory/resume-recap.js.map +1 -0
- package/dist/src/trajectory/search.d.ts +40 -0
- package/dist/src/trajectory/search.js +127 -0
- package/dist/src/trajectory/search.js.map +1 -0
- package/dist/src/trajectory/spend.d.ts +157 -0
- package/dist/src/trajectory/spend.js +264 -0
- package/dist/src/trajectory/spend.js.map +1 -0
- package/dist/src/trajectory/stream.d.ts +30 -0
- package/dist/src/trajectory/stream.js +30 -0
- package/dist/src/trajectory/stream.js.map +1 -0
- package/dist/src/trajectory/writer.d.ts +310 -0
- package/dist/src/trajectory/writer.js +636 -0
- package/dist/src/trajectory/writer.js.map +1 -0
- package/dist/src/tui/App.d.ts +109 -0
- package/dist/src/tui/App.js +2660 -0
- package/dist/src/tui/App.js.map +1 -0
- package/dist/src/tui/InputBox.d.ts +90 -0
- package/dist/src/tui/InputBox.js +129 -0
- package/dist/src/tui/InputBox.js.map +1 -0
- package/dist/src/tui/MarkdownText.d.ts +16 -0
- package/dist/src/tui/MarkdownText.js +117 -0
- package/dist/src/tui/MarkdownText.js.map +1 -0
- package/dist/src/tui/MessageList.d.ts +27 -0
- package/dist/src/tui/MessageList.js +61 -0
- package/dist/src/tui/MessageList.js.map +1 -0
- package/dist/src/tui/PermissionPrompt.d.ts +18 -0
- package/dist/src/tui/PermissionPrompt.js +114 -0
- package/dist/src/tui/PermissionPrompt.js.map +1 -0
- package/dist/src/tui/PlanChecklist.d.ts +7 -0
- package/dist/src/tui/PlanChecklist.js +12 -0
- package/dist/src/tui/PlanChecklist.js.map +1 -0
- package/dist/src/tui/QueuedMessages.d.ts +8 -0
- package/dist/src/tui/QueuedMessages.js +24 -0
- package/dist/src/tui/QueuedMessages.js.map +1 -0
- package/dist/src/tui/StartupScreen.d.ts +25 -0
- package/dist/src/tui/StartupScreen.js +51 -0
- package/dist/src/tui/StartupScreen.js.map +1 -0
- package/dist/src/tui/ToolCallPanel.d.ts +33 -0
- package/dist/src/tui/ToolCallPanel.js +112 -0
- package/dist/src/tui/ToolCallPanel.js.map +1 -0
- package/dist/src/tui/WelcomeHeader.d.ts +30 -0
- package/dist/src/tui/WelcomeHeader.js +69 -0
- package/dist/src/tui/WelcomeHeader.js.map +1 -0
- package/dist/src/tui/background-tool-presentation.d.ts +22 -0
- package/dist/src/tui/background-tool-presentation.js +209 -0
- package/dist/src/tui/background-tool-presentation.js.map +1 -0
- package/dist/src/tui/busy-suffix.d.ts +37 -0
- package/dist/src/tui/busy-suffix.js +39 -0
- package/dist/src/tui/busy-suffix.js.map +1 -0
- package/dist/src/tui/clipboard-image.d.ts +18 -0
- package/dist/src/tui/clipboard-image.js +109 -0
- package/dist/src/tui/clipboard-image.js.map +1 -0
- package/dist/src/tui/context-format.d.ts +43 -0
- package/dist/src/tui/context-format.js +71 -0
- package/dist/src/tui/context-format.js.map +1 -0
- package/dist/src/tui/copy-command.d.ts +68 -0
- package/dist/src/tui/copy-command.js +182 -0
- package/dist/src/tui/copy-command.js.map +1 -0
- package/dist/src/tui/edit-diff.d.ts +135 -0
- package/dist/src/tui/edit-diff.js +356 -0
- package/dist/src/tui/edit-diff.js.map +1 -0
- package/dist/src/tui/frame-budget.d.ts +351 -0
- package/dist/src/tui/frame-budget.js +446 -0
- package/dist/src/tui/frame-budget.js.map +1 -0
- package/dist/src/tui/help-format.d.ts +17 -0
- package/dist/src/tui/help-format.js +38 -0
- package/dist/src/tui/help-format.js.map +1 -0
- package/dist/src/tui/live-text.d.ts +51 -0
- package/dist/src/tui/live-text.js +154 -0
- package/dist/src/tui/live-text.js.map +1 -0
- package/dist/src/tui/markdown.d.ts +62 -0
- package/dist/src/tui/markdown.js +244 -0
- package/dist/src/tui/markdown.js.map +1 -0
- package/dist/src/tui/mcp-format.d.ts +28 -0
- package/dist/src/tui/mcp-format.js +67 -0
- package/dist/src/tui/mcp-format.js.map +1 -0
- package/dist/src/tui/path-completion.d.ts +119 -0
- package/dist/src/tui/path-completion.js +305 -0
- package/dist/src/tui/path-completion.js.map +1 -0
- package/dist/src/tui/permission-queue.d.ts +61 -0
- package/dist/src/tui/permission-queue.js +129 -0
- package/dist/src/tui/permission-queue.js.map +1 -0
- package/dist/src/tui/plan-format.d.ts +9 -0
- package/dist/src/tui/plan-format.js +30 -0
- package/dist/src/tui/plan-format.js.map +1 -0
- package/dist/src/tui/prompt-completion.d.ts +22 -0
- package/dist/src/tui/prompt-completion.js +46 -0
- package/dist/src/tui/prompt-completion.js.map +1 -0
- package/dist/src/tui/prompt-editor.d.ts +102 -0
- package/dist/src/tui/prompt-editor.js +379 -0
- package/dist/src/tui/prompt-editor.js.map +1 -0
- package/dist/src/tui/prompt-history-search.d.ts +53 -0
- package/dist/src/tui/prompt-history-search.js +123 -0
- package/dist/src/tui/prompt-history-search.js.map +1 -0
- package/dist/src/tui/prompt-queue.d.ts +58 -0
- package/dist/src/tui/prompt-queue.js +74 -0
- package/dist/src/tui/prompt-queue.js.map +1 -0
- package/dist/src/tui/prompt-recall.d.ts +74 -0
- package/dist/src/tui/prompt-recall.js +90 -0
- package/dist/src/tui/prompt-recall.js.map +1 -0
- package/dist/src/tui/react-environment.d.ts +11 -0
- package/dist/src/tui/react-environment.js +24 -0
- package/dist/src/tui/react-environment.js.map +1 -0
- package/dist/src/tui/rewind-search.d.ts +34 -0
- package/dist/src/tui/rewind-search.js +68 -0
- package/dist/src/tui/rewind-search.js.map +1 -0
- package/dist/src/tui/shell-command.d.ts +114 -0
- package/dist/src/tui/shell-command.js +310 -0
- package/dist/src/tui/shell-command.js.map +1 -0
- package/dist/src/tui/spend-advisory.d.ts +52 -0
- package/dist/src/tui/spend-advisory.js +64 -0
- package/dist/src/tui/spend-advisory.js.map +1 -0
- package/dist/src/tui/status-format.d.ts +120 -0
- package/dist/src/tui/status-format.js +192 -0
- package/dist/src/tui/status-format.js.map +1 -0
- package/dist/src/tui/subagent-format.d.ts +49 -0
- package/dist/src/tui/subagent-format.js +146 -0
- package/dist/src/tui/subagent-format.js.map +1 -0
- package/dist/src/tui/task-format.d.ts +29 -0
- package/dist/src/tui/task-format.js +87 -0
- package/dist/src/tui/task-format.js.map +1 -0
- package/dist/src/tui/terminal-bell.d.ts +20 -0
- package/dist/src/tui/terminal-bell.js +33 -0
- package/dist/src/tui/terminal-bell.js.map +1 -0
- package/dist/src/tui/tool-detail-presentation.d.ts +60 -0
- package/dist/src/tui/tool-detail-presentation.js +206 -0
- package/dist/src/tui/tool-detail-presentation.js.map +1 -0
- package/dist/src/tui/turn-state.d.ts +195 -0
- package/dist/src/tui/turn-state.js +548 -0
- package/dist/src/tui/turn-state.js.map +1 -0
- package/dist/src/tui/visual-language.d.ts +45 -0
- package/dist/src/tui/visual-language.js +57 -0
- package/dist/src/tui/visual-language.js.map +1 -0
- package/dist/src/version.d.ts +7 -0
- package/dist/src/version.js +38 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { CODEX_CONTEXT_MAX_BYTES, matchesCodexHook, } from './codex-hooks.js';
|
|
2
|
+
import { HOOK_PAYLOAD_MAX_BYTES, HookProcessManager } from './hook-process.js';
|
|
3
|
+
const FIELD_MAX_CODE_POINTS = 8_000;
|
|
4
|
+
const REASON_MAX_CODE_POINTS = 1_000;
|
|
5
|
+
const MAX_PENDING_PROBLEMS = 16;
|
|
6
|
+
const PARENT_CONTEXT_MAX_BYTES = 128 * 1024;
|
|
7
|
+
export class CodexHookRunner {
|
|
8
|
+
options;
|
|
9
|
+
processes;
|
|
10
|
+
config;
|
|
11
|
+
pendingParentContext = [];
|
|
12
|
+
problems = [];
|
|
13
|
+
droppedProblems = 0;
|
|
14
|
+
observations = new Set();
|
|
15
|
+
sessionEnded = false;
|
|
16
|
+
closed = false;
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.processes = options.processManager ?? new HookProcessManager(options.projectRoot);
|
|
20
|
+
this.config = options.config;
|
|
21
|
+
}
|
|
22
|
+
/** Child lifecycle commands need independent cancellation without duplicating policy. */
|
|
23
|
+
fork() {
|
|
24
|
+
return new CodexHookRunner({ ...this.options, config: this.config });
|
|
25
|
+
}
|
|
26
|
+
/** A live `/model` switch changes truthful payload metadata for later events. */
|
|
27
|
+
updateConfig(config) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
}
|
|
30
|
+
async sessionStart(source) {
|
|
31
|
+
const contexts = await this.contextEvent('SessionStart', [source], { source }, true);
|
|
32
|
+
this.stageParent(contexts);
|
|
33
|
+
}
|
|
34
|
+
async userPromptSubmit(prompt) {
|
|
35
|
+
const pending = this.takePendingParentContext();
|
|
36
|
+
const outcome = await this.controllingContextEvent('UserPromptSubmit', [], { prompt: field(prompt) }, true);
|
|
37
|
+
if (!outcome.allowed) {
|
|
38
|
+
this.stageParent(pending);
|
|
39
|
+
return outcome;
|
|
40
|
+
}
|
|
41
|
+
const context = combineContext([...pending, ...(outcome.context === undefined ? [] : [outcome.context])]);
|
|
42
|
+
return { allowed: true, ...(context === undefined ? {} : { context }) };
|
|
43
|
+
}
|
|
44
|
+
async preToolUse(event, groups) {
|
|
45
|
+
let input = event.toolInput;
|
|
46
|
+
for (const { group, hook } of this.matching('PreToolUse', toolAliases(event.toolName, input), groups)) {
|
|
47
|
+
const result = await this.run(hook, this.payload('PreToolUse', {
|
|
48
|
+
tool_name: event.toolName,
|
|
49
|
+
tool_use_id: field(event.toolUseId),
|
|
50
|
+
tool_input: boundedJson(input),
|
|
51
|
+
}), event.signal);
|
|
52
|
+
if (result.cancelled)
|
|
53
|
+
return { allowed: false, input, reason: 'Tool call cancelled during PreToolUse hook.' };
|
|
54
|
+
if (result.timedOut || result.error !== undefined || result.stdoutTruncated || result.stderrTruncated || (result.exitCode !== 0 && result.exitCode !== 2)) {
|
|
55
|
+
return { allowed: false, input, reason: runtimeFailure(hook, result) };
|
|
56
|
+
}
|
|
57
|
+
if (result.exitCode === 2)
|
|
58
|
+
return { allowed: false, input, reason: reason(result.stderr, 'Blocked by PreToolUse hook.') };
|
|
59
|
+
const decoded = decodeOutput(result.stdout, hook, this.problemSink);
|
|
60
|
+
const control = preToolControl(decoded, hook, this.problemSink);
|
|
61
|
+
if (!control.allowed)
|
|
62
|
+
return {
|
|
63
|
+
allowed: false,
|
|
64
|
+
input,
|
|
65
|
+
...(control.reason === undefined ? {} : { reason: control.reason }),
|
|
66
|
+
};
|
|
67
|
+
if (control.input !== undefined)
|
|
68
|
+
input = control.input;
|
|
69
|
+
// Keep TypeScript aware that source/group identity is intentionally retained by matching().
|
|
70
|
+
void group;
|
|
71
|
+
}
|
|
72
|
+
return { allowed: true, input };
|
|
73
|
+
}
|
|
74
|
+
async postToolUse(event, groups) {
|
|
75
|
+
await this.observe('PostToolUse', toolAliases(event.toolName, event.toolInput), {
|
|
76
|
+
tool_name: event.toolName,
|
|
77
|
+
tool_use_id: field(event.toolUseId),
|
|
78
|
+
tool_input: boundedJson(event.toolInput),
|
|
79
|
+
tool_response: boundedJson(event.toolResponse),
|
|
80
|
+
}, true, groups);
|
|
81
|
+
}
|
|
82
|
+
permissionRequest(event, groups) {
|
|
83
|
+
void this.observe('PermissionRequest', toolAliases(event.toolName, event.toolInput), {
|
|
84
|
+
source: field(event.source),
|
|
85
|
+
tool_name: event.toolName,
|
|
86
|
+
tool_input: boundedJson(event.toolInput),
|
|
87
|
+
}, false, groups);
|
|
88
|
+
}
|
|
89
|
+
async preCompact(trigger) {
|
|
90
|
+
const outcome = await this.controllingContextEvent('PreCompact', [trigger], { trigger }, false);
|
|
91
|
+
return outcome.allowed ? { allowed: true } : { allowed: false, ...(outcome.reason === undefined ? {} : { reason: outcome.reason }) };
|
|
92
|
+
}
|
|
93
|
+
async postCompact(trigger) {
|
|
94
|
+
const contexts = await this.contextEvent('PostCompact', [trigger], { trigger }, false);
|
|
95
|
+
this.stageParent(contexts);
|
|
96
|
+
}
|
|
97
|
+
async subagentStart(agent) {
|
|
98
|
+
const contexts = await this.contextEvent('SubagentStart', [agent.name], {
|
|
99
|
+
agent_id: field(agent.id),
|
|
100
|
+
agent_type: field(agent.name),
|
|
101
|
+
}, true);
|
|
102
|
+
return combineContext(contexts);
|
|
103
|
+
}
|
|
104
|
+
subagentStop(agent) {
|
|
105
|
+
return this.observe('SubagentStop', [agent.name], {
|
|
106
|
+
agent_id: field(agent.id),
|
|
107
|
+
agent_type: field(agent.name),
|
|
108
|
+
outcome: field(agent.outcome),
|
|
109
|
+
stop_hook_active: false,
|
|
110
|
+
}, false);
|
|
111
|
+
}
|
|
112
|
+
stop(outcome) {
|
|
113
|
+
void this.observe('Stop', [], { outcome, stop_hook_active: false }, false);
|
|
114
|
+
}
|
|
115
|
+
async sessionEnd(reason = 'other') {
|
|
116
|
+
if (this.sessionEnded)
|
|
117
|
+
return;
|
|
118
|
+
this.sessionEnded = true;
|
|
119
|
+
await this.observe('SessionEnd', [reason], { reason }, true);
|
|
120
|
+
}
|
|
121
|
+
takePendingParentContext() {
|
|
122
|
+
const pending = this.pendingParentContext;
|
|
123
|
+
this.pendingParentContext = [];
|
|
124
|
+
return pending;
|
|
125
|
+
}
|
|
126
|
+
cancel() { this.processes.cancel(); }
|
|
127
|
+
async close() {
|
|
128
|
+
if (this.closed)
|
|
129
|
+
return;
|
|
130
|
+
this.closed = true;
|
|
131
|
+
await this.processes.close();
|
|
132
|
+
await Promise.allSettled([...this.observations]);
|
|
133
|
+
}
|
|
134
|
+
takeProblems() {
|
|
135
|
+
const problems = this.problems;
|
|
136
|
+
this.problems = [];
|
|
137
|
+
if (this.droppedProblems > 0) {
|
|
138
|
+
problems.push(`${this.droppedProblems} additional hook problem(s) were omitted.`);
|
|
139
|
+
this.droppedProblems = 0;
|
|
140
|
+
}
|
|
141
|
+
return problems;
|
|
142
|
+
}
|
|
143
|
+
async controllingContextEvent(event, targets, fields, plainContext) {
|
|
144
|
+
const contexts = [];
|
|
145
|
+
for (const { hook } of this.matching(event, targets)) {
|
|
146
|
+
const payload = this.payload(event, fields);
|
|
147
|
+
if (!payloadFits(payload)) {
|
|
148
|
+
if (event === 'UserPromptSubmit') {
|
|
149
|
+
return { allowed: false, reason: `${event} hook input exceeds the bounded payload limit.` };
|
|
150
|
+
}
|
|
151
|
+
this.problem(`${event} hook input exceeds the bounded payload limit; matching hooks were skipped.`);
|
|
152
|
+
return { allowed: true };
|
|
153
|
+
}
|
|
154
|
+
const result = await this.run(hook, payload);
|
|
155
|
+
if (result.cancelled)
|
|
156
|
+
return { allowed: false, reason: `${event} hook was cancelled.` };
|
|
157
|
+
if (result.stdoutTruncated || result.stderrTruncated) {
|
|
158
|
+
if (event === 'UserPromptSubmit')
|
|
159
|
+
return { allowed: false, reason: `${event} hook output exceeded the bounded capture limit.` };
|
|
160
|
+
this.problem(`${event} hook output exceeded the bounded capture limit; output was ignored.`);
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (result.exitCode === 2)
|
|
164
|
+
return { allowed: false, reason: reason(result.stderr, `${event} hook blocked the operation.`) };
|
|
165
|
+
if (result.timedOut || result.error !== undefined || result.exitCode !== 0) {
|
|
166
|
+
this.problem(runtimeFailure(hook, result));
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const decoded = decodeOutput(result.stdout, hook, this.problemSink);
|
|
170
|
+
if (isBlock(decoded))
|
|
171
|
+
return { allowed: false, reason: outputReason(decoded, `${event} hook blocked the operation.`) };
|
|
172
|
+
if (event === 'UserPromptSubmit' && decoded !== undefined && hasUnsupportedPromptControl(decoded)) {
|
|
173
|
+
return { allowed: false, reason: `${hook.field} returned unsupported UserPromptSubmit result control.` };
|
|
174
|
+
}
|
|
175
|
+
reportUnsupportedControls(event, decoded, hook, this.problemSink);
|
|
176
|
+
const context = outputContext(result.stdout, decoded, hook.additionalContextBytes, plainContext);
|
|
177
|
+
if (context !== undefined)
|
|
178
|
+
contexts.push(context);
|
|
179
|
+
}
|
|
180
|
+
const context = combineContext(contexts);
|
|
181
|
+
return { allowed: true, ...(context === undefined ? {} : { context }) };
|
|
182
|
+
}
|
|
183
|
+
contextEvent(event, targets, fields, plainContext) {
|
|
184
|
+
return this.collect(event, targets, fields, plainContext);
|
|
185
|
+
}
|
|
186
|
+
async collect(event, targets, fields, plainContext) {
|
|
187
|
+
const contexts = [];
|
|
188
|
+
for (const { hook } of this.matching(event, targets)) {
|
|
189
|
+
const result = await this.run(hook, this.payload(event, fields));
|
|
190
|
+
if (result.stdoutTruncated || result.stderrTruncated) {
|
|
191
|
+
this.problem(`${event} hook output exceeded the bounded capture limit; context was ignored.`);
|
|
192
|
+
continue;
|
|
193
|
+
}
|
|
194
|
+
if (result.timedOut || result.error !== undefined || result.exitCode !== 0) {
|
|
195
|
+
this.problem(runtimeFailure(hook, result));
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
const decoded = decodeOutput(result.stdout, hook, this.problemSink);
|
|
199
|
+
reportUnsupportedControls(event, decoded, hook, this.problemSink);
|
|
200
|
+
const context = outputContext(result.stdout, decoded, hook.additionalContextBytes, plainContext);
|
|
201
|
+
if (context !== undefined)
|
|
202
|
+
contexts.push(context);
|
|
203
|
+
}
|
|
204
|
+
return contexts;
|
|
205
|
+
}
|
|
206
|
+
async observe(event, targets, fields, awaitCompletion, groups) {
|
|
207
|
+
const operation = async () => {
|
|
208
|
+
for (const { hook } of this.matching(event, targets, groups)) {
|
|
209
|
+
const result = await this.run(hook, this.payload(event, fields));
|
|
210
|
+
if (result.stdoutTruncated || result.stderrTruncated) {
|
|
211
|
+
this.problem(`${event} hook output exceeded the bounded capture limit; output was ignored.`);
|
|
212
|
+
}
|
|
213
|
+
else if (result.timedOut || result.error !== undefined || result.exitCode !== 0) {
|
|
214
|
+
this.problem(runtimeFailure(hook, result));
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
reportUnsupportedControls(event, decodeOutput(result.stdout, hook, this.problemSink), hook, this.problemSink);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
if (awaitCompletion)
|
|
222
|
+
await operation();
|
|
223
|
+
else {
|
|
224
|
+
const observation = operation().finally(() => this.observations.delete(observation));
|
|
225
|
+
this.observations.add(observation);
|
|
226
|
+
void observation.catch(() => undefined);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
matching(event, targets, groups = this.options.hooks[event] ?? []) {
|
|
230
|
+
const ignoreMatcher = event === 'UserPromptSubmit' || event === 'Stop';
|
|
231
|
+
return groups.flatMap((group) => (ignoreMatcher || matchesCodexHook(group, targets))
|
|
232
|
+
? group.hooks.map((hook) => ({ group, hook }))
|
|
233
|
+
: []);
|
|
234
|
+
}
|
|
235
|
+
payload(event, fields) {
|
|
236
|
+
const permissionMode = codexPermissionMode(this.options.permissionMode());
|
|
237
|
+
return {
|
|
238
|
+
session_id: this.options.sessionId,
|
|
239
|
+
cwd: this.options.projectRoot,
|
|
240
|
+
hook_event_name: event,
|
|
241
|
+
model: this.config.model,
|
|
242
|
+
...(permissionMode === undefined ? {} : { permission_mode: permissionMode }),
|
|
243
|
+
...fields,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
run(hook, payload, signal) {
|
|
247
|
+
return this.processes.run(hook.command, hook.commandWindows, payload, hook.timeoutSeconds * 1000, signal);
|
|
248
|
+
}
|
|
249
|
+
stageParent(contexts) {
|
|
250
|
+
for (const context of contexts) {
|
|
251
|
+
const combined = combineContext([...this.pendingParentContext, context], PARENT_CONTEXT_MAX_BYTES);
|
|
252
|
+
this.pendingParentContext = combined === undefined ? [] : [combined];
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
problemSink = (message) => this.problem(message);
|
|
256
|
+
problem(message) {
|
|
257
|
+
if (this.closed)
|
|
258
|
+
return;
|
|
259
|
+
const bounded = reason(message, 'Hook problem.');
|
|
260
|
+
// Runtime hook failures are advisory diagnostics. They must never bypass
|
|
261
|
+
// Ink or the structured-headless protocol through raw process stderr.
|
|
262
|
+
if (this.problems.length < MAX_PENDING_PROBLEMS)
|
|
263
|
+
this.problems.push(bounded);
|
|
264
|
+
else
|
|
265
|
+
this.droppedProblems += 1;
|
|
266
|
+
this.options.problem?.(bounded);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
export function injectCodexContext(text, context) {
|
|
270
|
+
if (context === undefined || context.trim() === '')
|
|
271
|
+
return text;
|
|
272
|
+
return `<hook-context>\n${context}\n</hook-context>\n\n${text}`;
|
|
273
|
+
}
|
|
274
|
+
function outputContext(stdout, decoded, limit, plain) {
|
|
275
|
+
let context;
|
|
276
|
+
if (decoded === undefined)
|
|
277
|
+
context = plain && !looksLikeJson(stdout) ? stdout.trim() : undefined;
|
|
278
|
+
else {
|
|
279
|
+
const specific = object(decoded['hookSpecificOutput']);
|
|
280
|
+
context = specific?.['additionalContext'] ?? decoded['additionalContext'];
|
|
281
|
+
}
|
|
282
|
+
if (typeof context !== 'string' || context.trim() === '')
|
|
283
|
+
return undefined;
|
|
284
|
+
return truncateUtf8(context.trim(), Math.min(limit, CODEX_CONTEXT_MAX_BYTES));
|
|
285
|
+
}
|
|
286
|
+
function preToolControl(output, hook, problem) {
|
|
287
|
+
if (output === undefined)
|
|
288
|
+
return { allowed: true };
|
|
289
|
+
const specific = object(output['hookSpecificOutput']);
|
|
290
|
+
const legacyDecision = output['decision'];
|
|
291
|
+
const decision = specific?.['permissionDecision'];
|
|
292
|
+
if (output['continue'] === false || output['stopReason'] !== undefined || output['suppressOutput'] !== undefined) {
|
|
293
|
+
return { allowed: false, reason: `${hook.field} returned unsupported PreToolUse result control.` };
|
|
294
|
+
}
|
|
295
|
+
if (legacyDecision === 'block' || decision === 'deny') {
|
|
296
|
+
return { allowed: false, reason: outputReason(output, 'Blocked by PreToolUse hook.') };
|
|
297
|
+
}
|
|
298
|
+
if (legacyDecision !== undefined || (decision !== undefined && decision !== 'allow')) {
|
|
299
|
+
return { allowed: false, reason: `${hook.field} returned an unsupported PreToolUse decision.` };
|
|
300
|
+
}
|
|
301
|
+
const updatedInput = specific?.['updatedInput'];
|
|
302
|
+
if (decision === 'allow' && updatedInput === undefined) {
|
|
303
|
+
return { allowed: false, reason: `${hook.field} returned permissionDecision "allow" without updatedInput; Darwin hooks cannot auto-approve tools.` };
|
|
304
|
+
}
|
|
305
|
+
if (updatedInput !== undefined) {
|
|
306
|
+
if (decision !== 'allow' || object(updatedInput) === undefined) {
|
|
307
|
+
return { allowed: false, reason: `${hook.field} returned invalid updatedInput; it requires permissionDecision "allow" and an object.` };
|
|
308
|
+
}
|
|
309
|
+
return { allowed: true, input: updatedInput };
|
|
310
|
+
}
|
|
311
|
+
reportUnsupportedControls('PreToolUse', output, hook, problem);
|
|
312
|
+
return { allowed: true };
|
|
313
|
+
}
|
|
314
|
+
function reportUnsupportedControls(event, output, hook, problem) {
|
|
315
|
+
if (output === undefined)
|
|
316
|
+
return;
|
|
317
|
+
const specific = object(output['hookSpecificOutput']);
|
|
318
|
+
const controlling = output['decision'] !== undefined || output['continue'] === false || output['stopReason'] !== undefined ||
|
|
319
|
+
output['suppressOutput'] !== undefined || specific?.['decision'] !== undefined || specific?.['updatedMCPToolOutput'] !== undefined ||
|
|
320
|
+
specific?.['permissionDecision'] !== undefined || specific?.['updatedInput'] !== undefined;
|
|
321
|
+
if (controlling && !['UserPromptSubmit', 'PreCompact', 'PreToolUse'].includes(event)) {
|
|
322
|
+
problem?.(`${hook.field} requested unsupported ${event} result control; Darwin kept the owning result/permission/outcome unchanged.`);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function decodeOutput(stdout, hook, problem) {
|
|
326
|
+
const trimmed = stdout.trim();
|
|
327
|
+
if (trimmed === '' || (!trimmed.startsWith('{') && !trimmed.startsWith('[')))
|
|
328
|
+
return undefined;
|
|
329
|
+
try {
|
|
330
|
+
const parsed = JSON.parse(trimmed);
|
|
331
|
+
const decoded = object(parsed);
|
|
332
|
+
if (decoded === undefined)
|
|
333
|
+
problem?.(`${hook.field} returned JSON that was not an object; output was ignored.`);
|
|
334
|
+
return decoded;
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
problem?.(`${hook.field} returned invalid JSON; output was ignored: ${error instanceof Error ? error.message : String(error)}.`);
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function looksLikeJson(value) {
|
|
342
|
+
const trimmed = value.trim();
|
|
343
|
+
return trimmed.startsWith('{') || trimmed.startsWith('[');
|
|
344
|
+
}
|
|
345
|
+
function isBlock(output) {
|
|
346
|
+
return output?.['decision'] === 'block' || output?.['continue'] === false;
|
|
347
|
+
}
|
|
348
|
+
function hasUnsupportedPromptControl(output) {
|
|
349
|
+
return output['decision'] !== undefined || output['stopReason'] !== undefined || output['suppressOutput'] !== undefined;
|
|
350
|
+
}
|
|
351
|
+
function outputReason(output, fallback) {
|
|
352
|
+
const specific = object(output['hookSpecificOutput']);
|
|
353
|
+
const value = specific?.['permissionDecisionReason'] ?? output['reason'] ?? output['stopReason'];
|
|
354
|
+
return typeof value === 'string' && value.trim() !== '' ? reason(value, fallback) : fallback;
|
|
355
|
+
}
|
|
356
|
+
function runtimeFailure(hook, result) {
|
|
357
|
+
if (result.cancelled)
|
|
358
|
+
return `${hook.field} was cancelled.`;
|
|
359
|
+
if (result.stdoutTruncated || result.stderrTruncated)
|
|
360
|
+
return `${hook.field} output exceeded the bounded capture limit.`;
|
|
361
|
+
if (result.timedOut)
|
|
362
|
+
return `${hook.field} timed out after ${hook.timeoutSeconds} seconds.`;
|
|
363
|
+
if (result.error !== undefined)
|
|
364
|
+
return `${hook.field} could not launch: ${result.error.message}.`;
|
|
365
|
+
const detail = result.stderr.trim();
|
|
366
|
+
return `${hook.field} failed with exit code ${String(result.exitCode)}${detail === '' ? '.' : `: ${reason(detail, 'hook failure')}`}`;
|
|
367
|
+
}
|
|
368
|
+
function toolAliases(toolName, input) {
|
|
369
|
+
const aliases = [toolName];
|
|
370
|
+
if (toolName === 'bash')
|
|
371
|
+
aliases.push('Bash');
|
|
372
|
+
if (toolName === 'fileEditor') {
|
|
373
|
+
const command = object(input)?.['command'];
|
|
374
|
+
if (command === 'create' || command === 'str_replace' || command === 'insert')
|
|
375
|
+
aliases.push('apply_patch', 'Edit', 'Write');
|
|
376
|
+
}
|
|
377
|
+
if (toolName === 'subagent')
|
|
378
|
+
aliases.push('Agent');
|
|
379
|
+
return aliases;
|
|
380
|
+
}
|
|
381
|
+
function boundedJson(value) {
|
|
382
|
+
try {
|
|
383
|
+
const text = JSON.stringify(value);
|
|
384
|
+
if (text.length <= FIELD_MAX_CODE_POINTS)
|
|
385
|
+
return value;
|
|
386
|
+
return { truncated: true, preview: field(text) };
|
|
387
|
+
}
|
|
388
|
+
catch {
|
|
389
|
+
return { unavailable: true };
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function field(value) {
|
|
393
|
+
const points = [...value];
|
|
394
|
+
return points.length <= FIELD_MAX_CODE_POINTS ? value : `${points.slice(0, FIELD_MAX_CODE_POINTS - 1).join('')}…`;
|
|
395
|
+
}
|
|
396
|
+
function reason(value, fallback) {
|
|
397
|
+
const normalized = value.trim().replace(/\s+/g, ' ');
|
|
398
|
+
if (normalized === '')
|
|
399
|
+
return fallback;
|
|
400
|
+
const points = [...normalized];
|
|
401
|
+
return points.length <= REASON_MAX_CODE_POINTS ? normalized : `${points.slice(0, REASON_MAX_CODE_POINTS - 1).join('')}…`;
|
|
402
|
+
}
|
|
403
|
+
function combineContext(contexts, maximum = PARENT_CONTEXT_MAX_BYTES) {
|
|
404
|
+
const clean = contexts.map((value) => value.trim()).filter(Boolean);
|
|
405
|
+
if (clean.length === 0)
|
|
406
|
+
return undefined;
|
|
407
|
+
return truncateUtf8(clean.join('\n\n'), maximum);
|
|
408
|
+
}
|
|
409
|
+
function truncateUtf8(value, maximum) {
|
|
410
|
+
const bytes = Buffer.byteLength(value, 'utf8');
|
|
411
|
+
if (bytes <= maximum)
|
|
412
|
+
return value;
|
|
413
|
+
const notice = `\n… hook context truncated from ${bytes} bytes`;
|
|
414
|
+
const budget = Math.max(0, maximum - Buffer.byteLength(notice, 'utf8'));
|
|
415
|
+
let result = '';
|
|
416
|
+
let used = 0;
|
|
417
|
+
for (const point of value) {
|
|
418
|
+
const size = Buffer.byteLength(point, 'utf8');
|
|
419
|
+
if (used + size > budget)
|
|
420
|
+
break;
|
|
421
|
+
result += point;
|
|
422
|
+
used += size;
|
|
423
|
+
}
|
|
424
|
+
return `${result}${notice}`;
|
|
425
|
+
}
|
|
426
|
+
function payloadFits(payload) {
|
|
427
|
+
try {
|
|
428
|
+
return Buffer.byteLength(`${JSON.stringify(payload)}\n`, 'utf8') <= HOOK_PAYLOAD_MAX_BYTES;
|
|
429
|
+
}
|
|
430
|
+
catch {
|
|
431
|
+
return false;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function object(value) {
|
|
435
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
436
|
+
? value
|
|
437
|
+
: undefined;
|
|
438
|
+
}
|
|
439
|
+
function codexPermissionMode(mode) {
|
|
440
|
+
if (mode === 'default' || mode === 'plan')
|
|
441
|
+
return mode;
|
|
442
|
+
if (mode === 'yolo')
|
|
443
|
+
return 'bypassPermissions';
|
|
444
|
+
return undefined;
|
|
445
|
+
}
|
|
446
|
+
//# sourceMappingURL=codex-hook-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-hook-runner.js","sourceRoot":"","sources":["../../../src/hooks/codex-hook-runner.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,uBAAuB,EACvB,gBAAgB,GAKjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAA0B,MAAM,mBAAmB,CAAC;AAEvG,MAAM,qBAAqB,GAAG,KAAK,CAAC;AACpC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,wBAAwB,GAAG,GAAG,GAAG,IAAI,CAAC;AAgC5C,MAAM,OAAO,eAAe;IAUG,OAAO;IATnB,SAAS,CAAqB;IACvC,MAAM,CAAY;IAClB,oBAAoB,GAAa,EAAE,CAAC;IACpC,QAAQ,GAAa,EAAE,CAAC;IACxB,eAAe,GAAG,CAAC,CAA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act', 'SubagentStart', 'SubagentStop', 'Stop'];
|
|
2
|
+
export type CodexHookEventName = (typeof CODEX_HOOK_EVENTS)[number];
|
|
3
|
+
export interface CodexHookCommand {
|
|
4
|
+
readonly type: 'command';
|
|
5
|
+
readonly command: string;
|
|
6
|
+
readonly commandWindows?: string;
|
|
7
|
+
readonly timeoutSeconds: number;
|
|
8
|
+
readonly additionalContextBytes: number;
|
|
9
|
+
readonly source: string;
|
|
10
|
+
readonly field: string;
|
|
11
|
+
}
|
|
12
|
+
export interface CodexHookGroup {
|
|
13
|
+
readonly matcher: RegExp | undefined;
|
|
14
|
+
readonly matcherText: string;
|
|
15
|
+
readonly hooks: readonly CodexHookCommand[];
|
|
16
|
+
readonly source: string;
|
|
17
|
+
}
|
|
18
|
+
export type CodexHooksConfig = Partial<Record<CodexHookEventName, readonly CodexHookGroup[]>>;
|
|
19
|
+
export declare const CODEX_HOOK_TIMEOUT_MAX_SECONDS = 600;
|
|
20
|
+
export declare const CODEX_SESSION_END_TIMEOUT_MAX_SECONDS = 3;
|
|
21
|
+
export declare const CODEX_CONTEXT_MAX_BYTES: number;
|
|
22
|
+
export declare function decodeCodexHooks(value: unknown, source: string): CodexHooksConfig;
|
|
23
|
+
export declare function matchesCodexHook(group: CodexHookGroup, values: readonly string[]): boolean;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
export const CODEX_HOOK_EVENTS = [
|
|
2
|
+
'SessionStart',
|
|
3
|
+
'SessionEnd',
|
|
4
|
+
'UserPromptSubmit',
|
|
5
|
+
'PreToolUse',
|
|
6
|
+
'PermissionRequest',
|
|
7
|
+
'PostToolUse',
|
|
8
|
+
'PreCompact',
|
|
9
|
+
'PostCompact',
|
|
10
|
+
'SubagentStart',
|
|
11
|
+
'SubagentStop',
|
|
12
|
+
'Stop',
|
|
13
|
+
];
|
|
14
|
+
const DEFAULT_TIMEOUT_SECONDS = 600;
|
|
15
|
+
const SESSION_END_DEFAULT_TIMEOUT_SECONDS = 1;
|
|
16
|
+
export const CODEX_HOOK_TIMEOUT_MAX_SECONDS = 600;
|
|
17
|
+
export const CODEX_SESSION_END_TIMEOUT_MAX_SECONDS = 3;
|
|
18
|
+
export const CODEX_CONTEXT_MAX_BYTES = 64 * 1024;
|
|
19
|
+
const DEFAULT_CONTEXT_BYTES = 10_000;
|
|
20
|
+
export function decodeCodexHooks(value, source) {
|
|
21
|
+
const root = record(value, source);
|
|
22
|
+
only(root, ['description', 'hooks'], source);
|
|
23
|
+
if (root['description'] !== undefined && typeof root['description'] !== 'string') {
|
|
24
|
+
fail(`${source}.description`, 'must be a string.');
|
|
25
|
+
}
|
|
26
|
+
const hooks = record(root['hooks'], `${source}.hooks`);
|
|
27
|
+
for (const event of Object.keys(hooks)) {
|
|
28
|
+
if (!CODEX_HOOK_EVENTS.includes(event)) {
|
|
29
|
+
fail(`${source}.hooks.${event}`, `is not supported. Expected ${CODEX_HOOK_EVENTS.join(', ')}.`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const event of CODEX_HOOK_EVENTS) {
|
|
34
|
+
const rawGroups = hooks[event];
|
|
35
|
+
if (rawGroups === undefined)
|
|
36
|
+
continue;
|
|
37
|
+
if (!Array.isArray(rawGroups))
|
|
38
|
+
fail(`${source}.hooks.${event}`, 'must be an array of matcher groups.');
|
|
39
|
+
result[event] = rawGroups.map((rawGroup, groupIndex) => {
|
|
40
|
+
const where = `${source}.hooks.${event}[${groupIndex}]`;
|
|
41
|
+
const group = record(rawGroup, where);
|
|
42
|
+
only(group, ['matcher', 'hooks', 'description'], where);
|
|
43
|
+
if (group['description'] !== undefined && typeof group['description'] !== 'string') {
|
|
44
|
+
fail(`${where}.description`, 'must be a string.');
|
|
45
|
+
}
|
|
46
|
+
const matcherValue = group['matcher'];
|
|
47
|
+
if (matcherValue !== undefined && typeof matcherValue !== 'string') {
|
|
48
|
+
fail(`${where}.matcher`, 'must be a string when present.');
|
|
49
|
+
}
|
|
50
|
+
const matcherText = typeof matcherValue === 'string' ? matcherValue : '';
|
|
51
|
+
let matcher;
|
|
52
|
+
if (matcherText !== '' && matcherText !== '*') {
|
|
53
|
+
try {
|
|
54
|
+
matcher = new RegExp(matcherText);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
fail(`${where}.matcher`, `is not a valid regular expression: ${message(error)}.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const rawHandlers = group['hooks'];
|
|
61
|
+
if (!Array.isArray(rawHandlers) || rawHandlers.length === 0) {
|
|
62
|
+
fail(`${where}.hooks`, 'must be a nonempty array of command hooks.');
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
matcher,
|
|
66
|
+
matcherText,
|
|
67
|
+
source,
|
|
68
|
+
hooks: rawHandlers.map((rawHandler, handlerIndex) => decodeCommand(rawHandler, event, source, `${where}.hooks[${handlerIndex}]`)),
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
function decodeCommand(value, event, source, where) {
|
|
75
|
+
const handler = record(value, where);
|
|
76
|
+
only(handler, [
|
|
77
|
+
'type', 'command', 'commandWindows', 'timeout', 'statusMessage',
|
|
78
|
+
'additionalContextLimit', 'async', 'description',
|
|
79
|
+
], where);
|
|
80
|
+
if (handler['type'] !== 'command') {
|
|
81
|
+
fail(`${where}.type`, 'must be "command"; mcp_tool, prompt, and agent handlers are unsupported.');
|
|
82
|
+
}
|
|
83
|
+
const command = handler['command'];
|
|
84
|
+
if (typeof command !== 'string' || command.trim() === '')
|
|
85
|
+
fail(`${where}.command`, 'must be a nonblank string.');
|
|
86
|
+
const commandWindows = handler['commandWindows'];
|
|
87
|
+
if (commandWindows !== undefined && (typeof commandWindows !== 'string' || commandWindows.trim() === '')) {
|
|
88
|
+
fail(`${where}.commandWindows`, 'must be a nonblank string when present.');
|
|
89
|
+
}
|
|
90
|
+
if (handler['async'] !== undefined && typeof handler['async'] !== 'boolean') {
|
|
91
|
+
fail(`${where}.async`, 'must be a boolean.');
|
|
92
|
+
}
|
|
93
|
+
if (handler['async'] === true)
|
|
94
|
+
fail(`${where}.async`, 'background hooks are unsupported; use false or omit it.');
|
|
95
|
+
for (const field of ['statusMessage', 'description']) {
|
|
96
|
+
if (handler[field] !== undefined && typeof handler[field] !== 'string')
|
|
97
|
+
fail(`${where}.${field}`, 'must be a string.');
|
|
98
|
+
}
|
|
99
|
+
const maximum = event === 'SessionEnd' ? CODEX_SESSION_END_TIMEOUT_MAX_SECONDS : CODEX_HOOK_TIMEOUT_MAX_SECONDS;
|
|
100
|
+
const defaultTimeout = event === 'SessionEnd' ? SESSION_END_DEFAULT_TIMEOUT_SECONDS : DEFAULT_TIMEOUT_SECONDS;
|
|
101
|
+
const timeout = handler['timeout'] ?? defaultTimeout;
|
|
102
|
+
if (typeof timeout !== 'number' || !Number.isFinite(timeout) || timeout <= 0 || timeout > maximum) {
|
|
103
|
+
fail(`${where}.timeout`, `must be a finite number greater than 0 and at most ${maximum} seconds.`);
|
|
104
|
+
}
|
|
105
|
+
const contextLimit = handler['additionalContextLimit'];
|
|
106
|
+
if (contextLimit !== undefined && (typeof contextLimit !== 'number' || !Number.isInteger(contextLimit) || contextLimit < 0)) {
|
|
107
|
+
fail(`${where}.additionalContextLimit`, 'must be a non-negative integer token limit.');
|
|
108
|
+
}
|
|
109
|
+
const additionalContextBytes = contextLimit === undefined
|
|
110
|
+
? DEFAULT_CONTEXT_BYTES
|
|
111
|
+
: contextLimit === 0
|
|
112
|
+
? CODEX_CONTEXT_MAX_BYTES
|
|
113
|
+
: Math.min(CODEX_CONTEXT_MAX_BYTES, safeTokenBytes(contextLimit));
|
|
114
|
+
return {
|
|
115
|
+
type: 'command',
|
|
116
|
+
command,
|
|
117
|
+
...(typeof commandWindows === 'string' ? { commandWindows } : {}),
|
|
118
|
+
timeoutSeconds: timeout,
|
|
119
|
+
additionalContextBytes,
|
|
120
|
+
source,
|
|
121
|
+
field: where,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
export function matchesCodexHook(group, values) {
|
|
125
|
+
return group.matcher === undefined || values.some((value) => {
|
|
126
|
+
group.matcher.lastIndex = 0;
|
|
127
|
+
return group.matcher.test(value);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function record(value, where) {
|
|
131
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
132
|
+
fail(where, 'must be an object.');
|
|
133
|
+
return value;
|
|
134
|
+
}
|
|
135
|
+
function only(value, allowed, where) {
|
|
136
|
+
for (const key of Object.keys(value)) {
|
|
137
|
+
if (!allowed.includes(key))
|
|
138
|
+
fail(`${where}.${key}`, `is not supported. Expected ${allowed.join(', ')}.`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function safeTokenBytes(tokens) {
|
|
142
|
+
if (tokens >= Math.ceil(CODEX_CONTEXT_MAX_BYTES / 4))
|
|
143
|
+
return CODEX_CONTEXT_MAX_BYTES;
|
|
144
|
+
return tokens * 4;
|
|
145
|
+
}
|
|
146
|
+
function fail(where, reason) {
|
|
147
|
+
throw new Error(`${where} ${reason}`);
|
|
148
|
+
}
|
|
149
|
+
function message(error) {
|
|
150
|
+
return error instanceof Error ? error.message : String(error);
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=codex-hooks.js.map
|