@namzu/sdk 51.1.0 → 52.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +119 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +2 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/examples/SupervisorAgent.d.ts +42 -0
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/examples/SupervisorAgent.js +80 -4
- package/dist/agents/examples/SupervisorAgent.js.map +1 -1
- package/dist/agents/index.d.ts +1 -1
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +36 -0
- package/dist/authorization/protected-paths.d.ts.map +1 -0
- package/dist/authorization/protected-paths.js +107 -0
- package/dist/authorization/protected-paths.js.map +1 -0
- package/dist/authorization/readonly-commands.d.ts +39 -0
- package/dist/authorization/readonly-commands.d.ts.map +1 -0
- package/dist/authorization/readonly-commands.js +797 -0
- package/dist/authorization/readonly-commands.js.map +1 -0
- package/dist/authorization/readonly-flags.d.ts +19 -0
- package/dist/authorization/readonly-flags.d.ts.map +1 -0
- package/dist/authorization/readonly-flags.js +178 -0
- package/dist/authorization/readonly-flags.js.map +1 -0
- package/dist/authorization/removal.d.ts +52 -0
- package/dist/authorization/removal.d.ts.map +1 -0
- package/dist/authorization/removal.js +283 -0
- package/dist/authorization/removal.js.map +1 -0
- package/dist/authorization/shell-paths.d.ts +66 -0
- package/dist/authorization/shell-paths.d.ts.map +1 -0
- package/dist/authorization/shell-paths.js +697 -0
- package/dist/authorization/shell-paths.js.map +1 -0
- package/dist/bridge/acp/update.d.ts.map +1 -1
- package/dist/bridge/acp/update.js +1 -0
- package/dist/bridge/acp/update.js.map +1 -1
- package/dist/compaction/context-window.d.ts +24 -0
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +34 -0
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +10 -2
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/plan.d.ts +4 -0
- package/dist/compaction/plan.d.ts.map +1 -1
- package/dist/compaction/plan.js +6 -2
- package/dist/compaction/plan.js.map +1 -1
- package/dist/compaction/verifier.d.ts +11 -1
- package/dist/compaction/verifier.d.ts.map +1 -1
- package/dist/compaction/verifier.js +75 -23
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/config/runtime.d.ts +55 -7
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +23 -2
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
- package/dist/connector/web/guarded-fetch.js +24 -0
- package/dist/connector/web/guarded-fetch.js.map +1 -1
- package/dist/connector/web/index.d.ts +1 -1
- package/dist/connector/web/index.d.ts.map +1 -1
- package/dist/connector/web/page.d.ts +59 -0
- package/dist/connector/web/page.d.ts.map +1 -0
- package/dist/connector/web/page.js +112 -0
- package/dist/connector/web/page.js.map +1 -0
- package/dist/connector/web/types.d.ts +47 -0
- package/dist/connector/web/types.d.ts.map +1 -1
- package/dist/connector/web/types.js.map +1 -1
- package/dist/constants/continuation.d.ts +8 -0
- package/dist/constants/continuation.d.ts.map +1 -1
- package/dist/constants/continuation.js +8 -0
- package/dist/constants/continuation.js.map +1 -1
- package/dist/constants/plugin/index.d.ts +1 -1
- package/dist/constants/plugin/index.d.ts.map +1 -1
- package/dist/constants/plugin/index.js +1 -1
- package/dist/constants/plugin/index.js.map +1 -1
- package/dist/contracts/a2a.d.ts +2 -2
- package/dist/manager/agent/lifecycle.d.ts +7 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +11 -2
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +4 -2
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +6 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +98 -114
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +90 -22
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +434 -41
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/provider/capabilities.d.ts +9 -0
- package/dist/provider/capabilities.d.ts.map +1 -1
- package/dist/provider/capabilities.js +15 -0
- package/dist/provider/capabilities.js.map +1 -1
- package/dist/provider/errors.d.ts.map +1 -1
- package/dist/provider/errors.js +13 -0
- package/dist/provider/errors.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +10 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/image-input-refusal.d.ts +9 -0
- package/dist/provider/image-input-refusal.d.ts.map +1 -0
- package/dist/provider/image-input-refusal.js +54 -0
- package/dist/provider/image-input-refusal.js.map +1 -0
- package/dist/provider/index.d.ts +2 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +2 -1
- package/dist/provider/index.js.map +1 -1
- package/dist/provider/retry.d.ts +7 -2
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +38 -4
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +5 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +5 -2
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +2 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +21 -0
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +15 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/deferred-sandbox.d.ts +54 -0
- package/dist/runtime/query/deferred-sandbox.d.ts.map +1 -0
- package/dist/runtime/query/deferred-sandbox.js +75 -0
- package/dist/runtime/query/deferred-sandbox.js.map +1 -0
- package/dist/runtime/query/executor/tool-call-admission.d.ts +10 -0
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +74 -13
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +51 -2
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +214 -9
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/finalize-turn.d.ts +6 -0
- package/dist/runtime/query/finalize-turn.d.ts.map +1 -1
- package/dist/runtime/query/finalize-turn.js +1 -1
- package/dist/runtime/query/finalize-turn.js.map +1 -1
- package/dist/runtime/query/index.d.ts +29 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +108 -28
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +57 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +380 -28
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction-breaker.d.ts +61 -0
- package/dist/runtime/query/iteration/phases/compaction-breaker.d.ts.map +1 -0
- package/dist/runtime/query/iteration/phases/compaction-breaker.js +94 -0
- package/dist/runtime/query/iteration/phases/compaction-breaker.js.map +1 -0
- package/dist/runtime/query/iteration/phases/compaction.d.ts +42 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +203 -23
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +10 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +165 -2
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts +21 -1
- package/dist/runtime/query/iteration/provider-rejected-image.d.ts.map +1 -1
- package/dist/runtime/query/iteration/provider-rejected-image.js +53 -7
- package/dist/runtime/query/iteration/provider-rejected-image.js.map +1 -1
- package/dist/runtime/query/iteration/request-repair.d.ts +108 -0
- package/dist/runtime/query/iteration/request-repair.d.ts.map +1 -0
- package/dist/runtime/query/iteration/request-repair.js +593 -0
- package/dist/runtime/query/iteration/request-repair.js.map +1 -0
- package/dist/runtime/query/iteration/stream-turn.d.ts +6 -0
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +2 -2
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/path-escalation.d.ts +36 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -0
- package/dist/runtime/query/path-escalation.js +184 -0
- package/dist/runtime/query/path-escalation.js.map +1 -0
- package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +8 -0
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/reminders.d.ts +35 -0
- package/dist/runtime/query/reminders.d.ts.map +1 -0
- package/dist/runtime/query/reminders.js +7 -0
- package/dist/runtime/query/reminders.js.map +1 -0
- package/dist/runtime/query/request-rich-content.d.ts +5 -1
- package/dist/runtime/query/request-rich-content.d.ts.map +1 -1
- package/dist/runtime/query/request-rich-content.js +67 -25
- package/dist/runtime/query/request-rich-content.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +26 -0
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +26 -0
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +79 -5
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tool-output-budget.d.ts +46 -0
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-output-budget.js +85 -1
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +1 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +5 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/session/paths.d.ts +5 -1
- package/dist/session/paths.d.ts.map +1 -1
- package/dist/session/paths.js +8 -0
- package/dist/session/paths.js.map +1 -1
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +2 -2
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/memory/markdown.d.ts.map +1 -1
- package/dist/store/memory/markdown.js +2 -2
- package/dist/store/memory/markdown.js.map +1 -1
- package/dist/store/memory/naming.d.ts +9 -0
- package/dist/store/memory/naming.d.ts.map +1 -1
- package/dist/store/memory/naming.js +12 -0
- package/dist/store/memory/naming.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +30 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +170 -26
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +1 -1
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +12 -5
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +2 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +4 -0
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +60 -18
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts +8 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +152 -33
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts +1 -0
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +44 -5
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/read-render.d.ts +52 -0
- package/dist/tools/builtins/read-render.d.ts.map +1 -1
- package/dist/tools/builtins/read-render.js +143 -0
- package/dist/tools/builtins/read-render.js.map +1 -1
- package/dist/tools/builtins/web.d.ts +13 -2
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +225 -32
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts +2 -0
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +256 -92
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/question-options.d.ts +1 -0
- package/dist/tools/coordinator/question-options.d.ts.map +1 -1
- package/dist/tools/coordinator/question-options.js +6 -1
- package/dist/tools/coordinator/question-options.js.map +1 -1
- package/dist/tools/defineTool.d.ts +4 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +6 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/paths.d.ts +6 -0
- package/dist/tools/paths.d.ts.map +1 -1
- package/dist/tools/paths.js +1 -1
- package/dist/tools/paths.js.map +1 -1
- package/dist/types/agent/query.d.ts +3 -0
- package/dist/types/agent/query.d.ts.map +1 -1
- package/dist/types/errors/catalog.js +1 -1
- package/dist/types/errors/catalog.js.map +1 -1
- package/dist/types/hitl/index.d.ts +104 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +1 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +2 -0
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +93 -19
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +3 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/errors.d.ts +19 -0
- package/dist/types/provider/errors.d.ts.map +1 -1
- package/dist/types/provider/errors.js +54 -5
- package/dist/types/provider/errors.js.map +1 -1
- package/dist/types/provider/interface.d.ts +12 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +1 -1
- package/dist/types/session/config.d.ts +14 -0
- package/dist/types/session/config.d.ts.map +1 -1
- package/dist/types/session/events.d.ts +27 -4
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/records.d.ts +9 -9
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +1 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/session/stop-reason.d.ts +5 -0
- package/dist/types/session/stop-reason.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +52 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/package.json +4 -2
- package/src/agents/QueryAgent.ts +5 -1
- package/src/agents/SupervisorAgent.ts +1 -1
- package/src/agents/examples/SupervisorAgent.ts +217 -106
- package/src/agents/index.ts +1 -1
- package/src/authorization/protected-paths.ts +110 -0
- package/src/authorization/readonly-commands.ts +771 -0
- package/src/authorization/readonly-flags.ts +196 -0
- package/src/authorization/removal.ts +326 -0
- package/src/authorization/shell-paths.ts +927 -0
- package/src/bridge/acp/update.ts +1 -0
- package/src/compaction/context-window.ts +41 -0
- package/src/compaction/manual.ts +10 -2
- package/src/compaction/plan.ts +11 -2
- package/src/compaction/verifier.ts +84 -22
- package/src/config/runtime.ts +23 -2
- package/src/connector/web/guarded-fetch.ts +26 -0
- package/src/connector/web/index.ts +3 -0
- package/src/connector/web/page.ts +130 -0
- package/src/connector/web/types.ts +47 -0
- package/src/constants/continuation.ts +10 -0
- package/src/constants/plugin/index.ts +1 -1
- package/src/manager/agent/lifecycle.ts +12 -4
- package/src/manager/session/turn-recorder.ts +10 -2
- package/src/plugin/index.ts +1 -0
- package/src/plugin/lifecycle.ts +107 -119
- package/src/plugin/shell-hook.ts +477 -43
- package/src/provider/capabilities.ts +17 -0
- package/src/provider/errors.ts +13 -0
- package/src/provider/fallback.ts +10 -0
- package/src/provider/idle-timeout.ts +5 -0
- package/src/provider/image-input-refusal.ts +54 -0
- package/src/provider/index.ts +2 -0
- package/src/provider/retry.ts +42 -4
- package/src/public-runtime.ts +11 -0
- package/src/public-types.ts +4 -0
- package/src/runtime/jobs/registry.ts +39 -2
- package/src/runtime/query/deferred-sandbox.ts +110 -0
- package/src/runtime/query/executor/tool-call-admission.ts +79 -13
- package/src/runtime/query/executor.ts +267 -11
- package/src/runtime/query/finalize-turn.ts +7 -1
- package/src/runtime/query/index.ts +169 -52
- package/src/runtime/query/iteration/index.ts +439 -35
- package/src/runtime/query/iteration/phases/compaction-breaker.ts +108 -0
- package/src/runtime/query/iteration/phases/compaction.ts +241 -38
- package/src/runtime/query/iteration/phases/context.ts +11 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +177 -2
- package/src/runtime/query/iteration/provider-rejected-image.ts +71 -5
- package/src/runtime/query/iteration/request-repair.ts +743 -0
- package/src/runtime/query/iteration/stream-turn.ts +11 -1
- package/src/runtime/query/path-escalation.ts +204 -0
- package/src/runtime/query/plugin-hooks.ts +8 -0
- package/src/runtime/query/reminders.ts +45 -0
- package/src/runtime/query/request-rich-content.ts +77 -27
- package/src/runtime/query/resume-pending.ts +27 -0
- package/src/runtime/query/review-policy.ts +106 -5
- package/src/runtime/query/tool-output-budget.ts +115 -1
- package/src/runtime/query/tooling.ts +6 -0
- package/src/session/paths.ts +11 -1
- package/src/store/memory/disk.ts +2 -1
- package/src/store/memory/markdown.ts +2 -1
- package/src/store/memory/naming.ts +13 -0
- package/src/tools/builtins/bash.ts +203 -34
- package/src/tools/builtins/computer-use.ts +13 -4
- package/src/tools/builtins/content-fingerprint.ts +5 -0
- package/src/tools/builtins/edit.ts +69 -19
- package/src/tools/builtins/grep.ts +159 -38
- package/src/tools/builtins/read-file.ts +48 -5
- package/src/tools/builtins/read-render.ts +193 -0
- package/src/tools/builtins/web.ts +258 -33
- package/src/tools/coordinator/ask-user-question.ts +309 -103
- package/src/tools/coordinator/question-options.ts +8 -1
- package/src/tools/defineTool.ts +11 -2
- package/src/tools/paths.ts +1 -1
- package/src/types/agent/query.ts +3 -0
- package/src/types/errors/catalog.ts +1 -1
- package/src/types/hitl/index.ts +104 -0
- package/src/types/message/index.ts +2 -0
- package/src/types/plugin/index.ts +101 -18
- package/src/types/provider/errors.ts +66 -5
- package/src/types/provider/interface.ts +13 -0
- package/src/types/provider/stream.ts +1 -1
- package/src/types/session/config.ts +14 -0
- package/src/types/session/events.ts +32 -4
- package/src/types/session/records.ts +1 -0
- package/src/types/session/stop-reason.ts +5 -0
- package/src/types/tool/index.ts +53 -2
package/src/plugin/index.ts
CHANGED
package/src/plugin/lifecycle.ts
CHANGED
|
@@ -262,6 +262,7 @@ export class PluginLifecycleManager {
|
|
|
262
262
|
handler: (context: PluginHookContext) => Promise<PluginHookResult>
|
|
263
263
|
priority: number
|
|
264
264
|
seq: number
|
|
265
|
+
statusMessage?: string
|
|
265
266
|
}>
|
|
266
267
|
> = new Map()
|
|
267
268
|
private pluginContributions: Map<PluginId, PluginContributionRecord> = new Map()
|
|
@@ -417,6 +418,7 @@ export class PluginLifecycleManager {
|
|
|
417
418
|
pluginId,
|
|
418
419
|
handler: hook.handler,
|
|
419
420
|
priority: hook.priority ?? DEFAULT_HOOK_PRIORITY,
|
|
421
|
+
...(hook.statusMessage !== undefined ? { statusMessage: hook.statusMessage } : {}),
|
|
420
422
|
// Registration index, so the sort has something stable to fall
|
|
421
423
|
// back on when priorities are equal.
|
|
422
424
|
seq: handlers.length,
|
|
@@ -1066,115 +1068,42 @@ export class PluginLifecycleManager {
|
|
|
1066
1068
|
return []
|
|
1067
1069
|
}
|
|
1068
1070
|
|
|
1069
|
-
|
|
1070
|
-
//
|
|
1071
|
-
//
|
|
1072
|
-
//
|
|
1073
|
-
//
|
|
1074
|
-
//
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
// Track input overlay so chained `modify` actions compose: each subsequent
|
|
1093
|
-
// hook sees the input produced by the previous hook's modify.
|
|
1094
|
-
let toolInputOverlay = context.toolInput
|
|
1095
|
-
|
|
1096
|
-
for (const idx of indicesToProcess) {
|
|
1097
|
-
const hookEntry = handlers[idx]
|
|
1098
|
-
if (!hookEntry) continue
|
|
1099
|
-
const { pluginId, handler: handlerFn } = hookEntry
|
|
1100
|
-
const hookContext: PluginHookContext = {
|
|
1101
|
-
...context,
|
|
1102
|
-
toolInput: toolInputOverlay,
|
|
1103
|
-
pluginId,
|
|
1104
|
-
event,
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1107
|
-
if (emitSessionEvent) {
|
|
1108
|
-
await emitSessionEvent({
|
|
1109
|
-
type: 'plugin_hook_executing',
|
|
1110
|
-
sessionId: context.sessionId,
|
|
1111
|
-
...(context.turnId !== undefined ? { turnId: context.turnId } : {}),
|
|
1112
|
-
pluginId,
|
|
1113
|
-
hookEvent: event,
|
|
1114
|
-
})
|
|
1115
|
-
callerSignal?.throwIfAborted()
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
const start = performance.now()
|
|
1119
|
-
let result: PluginHookResult
|
|
1120
|
-
|
|
1121
|
-
// The deadline timer is captured and cleared in `finally`.
|
|
1122
|
-
// Without that it stayed armed after the hook resolved, and an
|
|
1123
|
-
// armed timer keeps the Node event loop alive: hooks fire on
|
|
1124
|
-
// every tool call and every model call, so a turn of twenty tool
|
|
1125
|
-
// calls left twenty live timers and the process could not exit
|
|
1126
|
-
// until the last one expired. Nothing failed — it just hung, for
|
|
1127
|
-
// up to the timeout, every time.
|
|
1128
|
-
const deadline = new AbortController()
|
|
1129
|
-
const hookSignal = callerSignal
|
|
1130
|
-
? AbortSignal.any([callerSignal, deadline.signal])
|
|
1131
|
-
: deadline.signal
|
|
1132
|
-
let timer: ReturnType<typeof setTimeout> | undefined
|
|
1133
|
-
let onCallerAbort: (() => void) | undefined
|
|
1134
|
-
|
|
1135
|
-
try {
|
|
1136
|
-
const races: Promise<PluginHookResult>[] = [
|
|
1137
|
-
Promise.resolve().then(() => handlerFn({ ...hookContext, signal: hookSignal })),
|
|
1138
|
-
new Promise<PluginHookResult>((_, reject) => {
|
|
1139
|
-
timer = setTimeout(() => {
|
|
1140
|
-
// Told, not just abandoned: a hook holding a socket
|
|
1141
|
-
// open can close it.
|
|
1142
|
-
deadline.abort()
|
|
1143
|
-
reject(new Error('Hook timeout'))
|
|
1144
|
-
}, this.hookTimeoutMs)
|
|
1145
|
-
}),
|
|
1146
|
-
]
|
|
1147
|
-
if (callerSignal) {
|
|
1148
|
-
races.push(
|
|
1149
|
-
new Promise<PluginHookResult>((_, reject) => {
|
|
1150
|
-
onCallerAbort = () => reject(callerSignal.reason)
|
|
1151
|
-
callerSignal.addEventListener('abort', onCallerAbort, {
|
|
1152
|
-
once: true,
|
|
1153
|
-
})
|
|
1154
|
-
if (callerSignal.aborted) onCallerAbort()
|
|
1155
|
-
}),
|
|
1156
|
-
)
|
|
1157
|
-
}
|
|
1158
|
-
result = await Promise.race(races)
|
|
1159
|
-
callerSignal?.throwIfAborted()
|
|
1160
|
-
} catch (err) {
|
|
1161
|
-
// Cancellation belongs to the turn, not to the plugin. Turning it
|
|
1162
|
-
// into a hook error would let the query continue after its caller
|
|
1163
|
-
// withdrew authority and would report Stop as a plugin failure.
|
|
1164
|
-
if (callerSignal?.aborted) throw callerSignal.reason
|
|
1165
|
-
const message = toErrorMessage(err)
|
|
1166
|
-
result = { action: 'error', message }
|
|
1167
|
-
} finally {
|
|
1168
|
-
if (timer !== undefined) clearTimeout(timer)
|
|
1169
|
-
if (onCallerAbort) callerSignal?.removeEventListener('abort', onCallerAbort)
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1071
|
+
// Every matching hook starts at once, on the context the event carried,
|
|
1072
|
+
// and the answers come back in registration (priority) order. Nothing
|
|
1073
|
+
// short-circuits: a hook that refuses does not stop its siblings from
|
|
1074
|
+
// running, and the caller decides how the answers combine (a refusal
|
|
1075
|
+
// outranks an `ask`, which outranks an `allow`; of several rewrites the
|
|
1076
|
+
// last in order wins; contexts are joined). The old chain ran them one
|
|
1077
|
+
// by one, `post_*` in reverse, each seeing the previous hook's `modify`.
|
|
1078
|
+
const entries = handlers.map((hookEntry) => ({
|
|
1079
|
+
hookEntry,
|
|
1080
|
+
hookContext: { ...context, pluginId: hookEntry.pluginId, event } as PluginHookContext,
|
|
1081
|
+
}))
|
|
1082
|
+
for (const { hookEntry } of entries) {
|
|
1083
|
+
if (!emitSessionEvent) break
|
|
1084
|
+
await emitSessionEvent({
|
|
1085
|
+
type: 'plugin_hook_executing',
|
|
1086
|
+
sessionId: context.sessionId,
|
|
1087
|
+
...(context.turnId !== undefined ? { turnId: context.turnId } : {}),
|
|
1088
|
+
pluginId: hookEntry.pluginId,
|
|
1089
|
+
hookEvent: event,
|
|
1090
|
+
...(hookEntry.statusMessage !== undefined
|
|
1091
|
+
? { statusMessage: hookEntry.statusMessage }
|
|
1092
|
+
: {}),
|
|
1093
|
+
})
|
|
1172
1094
|
callerSignal?.throwIfAborted()
|
|
1173
|
-
|
|
1174
|
-
|
|
1095
|
+
}
|
|
1096
|
+
const settled = await Promise.all(
|
|
1097
|
+
entries.map(({ hookEntry, hookContext }) =>
|
|
1098
|
+
this.runOneHook(hookEntry, hookContext, callerSignal),
|
|
1099
|
+
),
|
|
1100
|
+
)
|
|
1101
|
+
callerSignal?.throwIfAborted()
|
|
1102
|
+
const results: PluginHookResult[] = []
|
|
1103
|
+
for (const { hookEntry, result, durationMs } of settled) {
|
|
1175
1104
|
this.emit({
|
|
1176
1105
|
type: 'plugin_hook_executed',
|
|
1177
|
-
pluginId,
|
|
1106
|
+
pluginId: hookEntry.pluginId,
|
|
1178
1107
|
hookEvent: event,
|
|
1179
1108
|
durationMs,
|
|
1180
1109
|
})
|
|
@@ -1185,30 +1114,89 @@ export class PluginLifecycleManager {
|
|
|
1185
1114
|
type: 'plugin_hook_completed',
|
|
1186
1115
|
sessionId: context.sessionId,
|
|
1187
1116
|
...(context.turnId !== undefined ? { turnId: context.turnId } : {}),
|
|
1188
|
-
pluginId,
|
|
1117
|
+
pluginId: hookEntry.pluginId,
|
|
1189
1118
|
hookEvent: event,
|
|
1190
1119
|
result,
|
|
1191
1120
|
})
|
|
1192
1121
|
callerSignal?.throwIfAborted()
|
|
1193
1122
|
}
|
|
1194
|
-
|
|
1195
1123
|
results.push(result)
|
|
1124
|
+
}
|
|
1125
|
+
return results
|
|
1126
|
+
}
|
|
1196
1127
|
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1128
|
+
/**
|
|
1129
|
+
* Run one hook to its answer: bounded by the manager's deadline and the
|
|
1130
|
+
* turn's own cancellation. A throw or a timeout is an `error` answer; the
|
|
1131
|
+
* turn's cancellation is rethrown, because it belongs to the turn.
|
|
1132
|
+
*/
|
|
1133
|
+
private async runOneHook(
|
|
1134
|
+
hookEntry: {
|
|
1135
|
+
pluginId: PluginId
|
|
1136
|
+
handler: (context: PluginHookContext) => Promise<PluginHookResult>
|
|
1137
|
+
},
|
|
1138
|
+
hookContext: PluginHookContext,
|
|
1139
|
+
callerSignal: AbortSignal | undefined,
|
|
1140
|
+
): Promise<{ hookEntry: typeof hookEntry; result: PluginHookResult; durationMs: number }> {
|
|
1141
|
+
const { handler: handlerFn } = hookEntry
|
|
1142
|
+
const start = performance.now()
|
|
1143
|
+
let result: PluginHookResult
|
|
1144
|
+
|
|
1145
|
+
// The deadline timer is captured and cleared in `finally`.
|
|
1146
|
+
// Without that it stayed armed after the hook resolved, and an
|
|
1147
|
+
// armed timer keeps the Node event loop alive: hooks fire on
|
|
1148
|
+
// every tool call and every model call, so a turn of twenty tool
|
|
1149
|
+
// calls left twenty live timers and the process could not exit
|
|
1150
|
+
// until the last one expired. Nothing failed — it just hung, for
|
|
1151
|
+
// up to the timeout, every time.
|
|
1152
|
+
const deadline = new AbortController()
|
|
1153
|
+
const hookSignal = callerSignal
|
|
1154
|
+
? AbortSignal.any([callerSignal, deadline.signal])
|
|
1155
|
+
: deadline.signal
|
|
1156
|
+
let timer: ReturnType<typeof setTimeout> | undefined
|
|
1157
|
+
let onCallerAbort: (() => void) | undefined
|
|
1200
1158
|
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1159
|
+
try {
|
|
1160
|
+
const races: Promise<PluginHookResult>[] = [
|
|
1161
|
+
Promise.resolve().then(() => handlerFn({ ...hookContext, signal: hookSignal })),
|
|
1162
|
+
new Promise<PluginHookResult>((_, reject) => {
|
|
1163
|
+
timer = setTimeout(() => {
|
|
1164
|
+
// Told, not just abandoned: a hook holding a socket
|
|
1165
|
+
// open can close it.
|
|
1166
|
+
deadline.abort()
|
|
1167
|
+
reject(new Error('Hook timeout'))
|
|
1168
|
+
}, this.hookTimeoutMs)
|
|
1169
|
+
}),
|
|
1170
|
+
]
|
|
1171
|
+
if (callerSignal) {
|
|
1172
|
+
races.push(
|
|
1173
|
+
new Promise<PluginHookResult>((_, reject) => {
|
|
1174
|
+
onCallerAbort = () => reject(callerSignal.reason)
|
|
1175
|
+
callerSignal.addEventListener('abort', onCallerAbort, {
|
|
1176
|
+
once: true,
|
|
1177
|
+
})
|
|
1178
|
+
if (callerSignal.aborted) onCallerAbort()
|
|
1179
|
+
}),
|
|
1180
|
+
)
|
|
1208
1181
|
}
|
|
1182
|
+
result = await Promise.race(races)
|
|
1183
|
+
callerSignal?.throwIfAborted()
|
|
1184
|
+
} catch (err) {
|
|
1185
|
+
// Cancellation belongs to the turn, not to the plugin. Turning it
|
|
1186
|
+
// into a hook error would let the query continue after its caller
|
|
1187
|
+
// withdrew authority and would report Stop as a plugin failure.
|
|
1188
|
+
if (callerSignal?.aborted) throw callerSignal.reason
|
|
1189
|
+
const message = toErrorMessage(err)
|
|
1190
|
+
result = { action: 'error', message }
|
|
1191
|
+
} finally {
|
|
1192
|
+
if (timer !== undefined) clearTimeout(timer)
|
|
1193
|
+
if (onCallerAbort) callerSignal?.removeEventListener('abort', onCallerAbort)
|
|
1209
1194
|
}
|
|
1210
1195
|
|
|
1211
|
-
|
|
1196
|
+
callerSignal?.throwIfAborted()
|
|
1197
|
+
const durationMs = Math.round(performance.now() - start)
|
|
1198
|
+
|
|
1199
|
+
return { hookEntry, result, durationMs }
|
|
1212
1200
|
}
|
|
1213
1201
|
|
|
1214
1202
|
private emit(event: PluginLifecycleEvent): void {
|