@namzu/sdk 69.4.0 → 71.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +161 -0
- package/dist/authorization/bare-repository.d.ts +21 -0
- package/dist/authorization/bare-repository.d.ts.map +1 -0
- package/dist/authorization/bare-repository.js +62 -0
- package/dist/authorization/bare-repository.js.map +1 -0
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +10 -3
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +7 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +4 -0
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +24 -6
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +83 -10
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +17 -5
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +77 -6
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/readonly-flags.d.ts.map +1 -1
- package/dist/authorization/readonly-flags.js +98 -0
- package/dist/authorization/readonly-flags.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +15 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +370 -2
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/authorization/shell-paths.d.ts.map +1 -1
- package/dist/authorization/shell-paths.js +276 -0
- package/dist/authorization/shell-paths.js.map +1 -1
- package/dist/authorization/shell-session-state.d.ts +47 -0
- package/dist/authorization/shell-session-state.d.ts.map +1 -0
- package/dist/authorization/shell-session-state.js +70 -0
- package/dist/authorization/shell-session-state.js.map +1 -0
- package/dist/authorization/shell-session.d.ts +9 -0
- package/dist/authorization/shell-session.d.ts.map +1 -0
- package/dist/authorization/shell-session.js +19 -0
- package/dist/authorization/shell-session.js.map +1 -0
- package/dist/authorization/skill-grant.d.ts.map +1 -1
- package/dist/authorization/skill-grant.js +1 -0
- package/dist/authorization/skill-grant.js.map +1 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +2 -0
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/hooks.d.ts +16 -0
- package/dist/compaction/hooks.d.ts.map +1 -1
- package/dist/compaction/hooks.js +26 -1
- package/dist/compaction/hooks.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +6 -1
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/restore.d.ts.map +1 -1
- package/dist/compaction/restore.js +3 -2
- package/dist/compaction/restore.js.map +1 -1
- package/dist/config/runtime.d.ts +2 -0
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +7 -0
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +7 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +54 -4
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/web/guarded-fetch.d.ts +30 -0
- package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
- package/dist/connector/web/guarded-fetch.js +85 -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/index.js +1 -1
- package/dist/connector/web/index.js.map +1 -1
- package/dist/connector/web/types.d.ts +8 -0
- package/dist/connector/web/types.d.ts.map +1 -1
- package/dist/constants/compaction/index.d.ts.map +1 -1
- package/dist/constants/compaction/index.js +1 -1
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/execution/code-runtime/worker-program.d.ts +1 -1
- package/dist/execution/code-runtime/worker-program.d.ts.map +1 -1
- package/dist/execution/code-runtime/worker-program.js +9 -5
- package/dist/execution/code-runtime/worker-program.js.map +1 -1
- package/dist/execution/local.d.ts.map +1 -1
- package/dist/execution/local.js +6 -1
- package/dist/execution/local.js.map +1 -1
- package/dist/peers/index.d.ts +2 -2
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +1 -1
- package/dist/peers/index.js.map +1 -1
- package/dist/peers/record.d.ts +74 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +41 -1
- package/dist/peers/record.js.map +1 -1
- package/dist/peers/registry.d.ts.map +1 -1
- package/dist/peers/registry.js +20 -3
- package/dist/peers/registry.js.map +1 -1
- package/dist/plugin/bin-path.d.ts +41 -0
- package/dist/plugin/bin-path.d.ts.map +1 -0
- package/dist/plugin/bin-path.js +146 -0
- package/dist/plugin/bin-path.js.map +1 -0
- package/dist/plugin/common-layout/read.js +3 -3
- package/dist/plugin/common-layout/read.js.map +1 -1
- package/dist/plugin/common-layout-names.d.ts.map +1 -1
- package/dist/plugin/common-layout-names.js +0 -1
- package/dist/plugin/common-layout-names.js.map +1 -1
- package/dist/plugin/hook-module/capabilities.d.ts +12 -0
- package/dist/plugin/hook-module/capabilities.d.ts.map +1 -1
- package/dist/plugin/hook-module/capabilities.js +82 -10
- package/dist/plugin/hook-module/capabilities.js.map +1 -1
- package/dist/plugin/hook-module/consent.d.ts +11 -0
- package/dist/plugin/hook-module/consent.d.ts.map +1 -1
- package/dist/plugin/hook-module/consent.js +31 -0
- package/dist/plugin/hook-module/consent.js.map +1 -1
- package/dist/plugin/hook-module/host.d.ts.map +1 -1
- package/dist/plugin/hook-module/host.js +69 -23
- package/dist/plugin/hook-module/host.js.map +1 -1
- package/dist/plugin/hook-module/index.d.ts +1 -1
- package/dist/plugin/hook-module/index.d.ts.map +1 -1
- package/dist/plugin/hook-module/index.js +1 -1
- package/dist/plugin/hook-module/index.js.map +1 -1
- package/dist/plugin/hook-module/scan.d.ts +16 -0
- package/dist/plugin/hook-module/scan.d.ts.map +1 -1
- package/dist/plugin/hook-module/scan.js +68 -3
- package/dist/plugin/hook-module/scan.js.map +1 -1
- package/dist/plugin/hook-module/worker-source.d.ts +5 -4
- package/dist/plugin/hook-module/worker-source.d.ts.map +1 -1
- package/dist/plugin/hook-module/worker-source.js +254 -28
- package/dist/plugin/hook-module/worker-source.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +21 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +64 -0
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
- package/dist/plugin/shell-hook-tool-names.js +1 -0
- package/dist/plugin/shell-hook-tool-names.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +1 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +22 -4
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/public-runtime.d.ts +11 -9
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +11 -8
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +7 -3
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +7 -3
- package/dist/public-tools.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/monitor-stream.d.ts +9 -1
- package/dist/runtime/jobs/monitor-stream.d.ts.map +1 -1
- package/dist/runtime/jobs/monitor-stream.js +13 -4
- package/dist/runtime/jobs/monitor-stream.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +4 -0
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +12 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/git-status.js +3 -2
- package/dist/runtime/query/auto-review/git-status.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +16 -6
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +135 -15
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +2 -2
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.js +14 -4
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +11 -1
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +19 -8
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/path-escalation.d.ts +6 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -1
- package/dist/runtime/query/path-escalation.js +58 -4
- package/dist/runtime/query/path-escalation.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +21 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +39 -21
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +11 -2
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +18 -4
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +3 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/schedules/describe.d.ts.map +1 -1
- package/dist/schedules/describe.js +2 -0
- package/dist/schedules/describe.js.map +1 -1
- package/dist/schedules/evaluate.d.ts +4 -0
- package/dist/schedules/evaluate.d.ts.map +1 -1
- package/dist/schedules/evaluate.js +26 -1
- package/dist/schedules/evaluate.js.map +1 -1
- package/dist/schedules/index.d.ts +3 -1
- package/dist/schedules/index.d.ts.map +1 -1
- package/dist/schedules/index.js +2 -1
- package/dist/schedules/index.js.map +1 -1
- package/dist/schedules/next-fire.d.ts.map +1 -1
- package/dist/schedules/next-fire.js +10 -0
- package/dist/schedules/next-fire.js.map +1 -1
- package/dist/schedules/spec.d.ts +9 -0
- package/dist/schedules/spec.d.ts.map +1 -1
- package/dist/schedules/spec.js +33 -0
- package/dist/schedules/spec.js.map +1 -1
- package/dist/schedules/types.d.ts +32 -4
- package/dist/schedules/types.d.ts.map +1 -1
- package/dist/schedules/types.js +3 -2
- package/dist/schedules/types.js.map +1 -1
- package/dist/schedules/watch.d.ts +23 -0
- package/dist/schedules/watch.d.ts.map +1 -0
- package/dist/schedules/watch.js +46 -0
- package/dist/schedules/watch.js.map +1 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +2 -1
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/skills/arguments.d.ts +58 -0
- package/dist/skills/arguments.d.ts.map +1 -0
- package/dist/skills/arguments.js +208 -0
- package/dist/skills/arguments.js.map +1 -0
- package/dist/skills/index.d.ts +3 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/inline-shell-host.d.ts +6 -0
- package/dist/skills/inline-shell-host.d.ts.map +1 -1
- package/dist/skills/inline-shell-host.js +8 -0
- package/dist/skills/inline-shell-host.js.map +1 -1
- package/dist/skills/inline-shell.d.ts +26 -1
- package/dist/skills/inline-shell.d.ts.map +1 -1
- package/dist/skills/inline-shell.js +1308 -22
- package/dist/skills/inline-shell.js.map +1 -1
- package/dist/tools/builtins/bash-cwd.d.ts.map +1 -1
- package/dist/tools/builtins/bash-cwd.js +2 -0
- package/dist/tools/builtins/bash-cwd.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +79 -11
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/exit-semantics.d.ts +6 -0
- package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
- package/dist/tools/builtins/exit-semantics.js +10 -0
- package/dist/tools/builtins/exit-semantics.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +68 -13
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +37 -12
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +11 -0
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +14 -0
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/job.js +1 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +4 -2
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/notebook-cells.d.ts +31 -0
- package/dist/tools/builtins/notebook-cells.d.ts.map +1 -0
- package/dist/tools/builtins/notebook-cells.js +160 -0
- package/dist/tools/builtins/notebook-cells.js.map +1 -0
- package/dist/tools/builtins/notebook-edit.d.ts +8 -0
- package/dist/tools/builtins/notebook-edit.d.ts.map +1 -0
- package/dist/tools/builtins/notebook-edit.js +249 -0
- package/dist/tools/builtins/notebook-edit.js.map +1 -0
- package/dist/tools/builtins/notebook-guard.d.ts.map +1 -1
- package/dist/tools/builtins/notebook-guard.js +2 -1
- package/dist/tools/builtins/notebook-guard.js.map +1 -1
- package/dist/tools/builtins/push-notification.d.ts +49 -0
- package/dist/tools/builtins/push-notification.d.ts.map +1 -0
- package/dist/tools/builtins/push-notification.js +107 -0
- package/dist/tools/builtins/push-notification.js.map +1 -0
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +8 -3
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/read-media.d.ts.map +1 -1
- package/dist/tools/builtins/read-media.js +2 -1
- package/dist/tools/builtins/read-media.js.map +1 -1
- package/dist/tools/builtins/read-render.d.ts.map +1 -1
- package/dist/tools/builtins/read-render.js +5 -3
- package/dist/tools/builtins/read-render.js.map +1 -1
- package/dist/tools/builtins/search-support.d.ts +6 -4
- package/dist/tools/builtins/search-support.d.ts.map +1 -1
- package/dist/tools/builtins/search-support.js +15 -3
- package/dist/tools/builtins/search-support.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +30 -8
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/builtins/sleep-guard.d.ts +20 -0
- package/dist/tools/builtins/sleep-guard.d.ts.map +1 -1
- package/dist/tools/builtins/sleep-guard.js +125 -1
- package/dist/tools/builtins/sleep-guard.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +1 -1
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web.d.ts +2 -0
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +97 -3
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/command-shell.d.ts +50 -0
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +145 -0
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/env-scrub.d.ts +2 -0
- package/dist/tools/env-scrub.d.ts.map +1 -1
- package/dist/tools/env-scrub.js +15 -1
- package/dist/tools/env-scrub.js.map +1 -1
- package/dist/tools/git-config-env.d.ts +55 -0
- package/dist/tools/git-config-env.d.ts.map +1 -0
- package/dist/tools/git-config-env.js +130 -0
- package/dist/tools/git-config-env.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts +7 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +72 -3
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +38 -2
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/types/connector/mcp.d.ts +24 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/message/index.d.ts +21 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +37 -2
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +11 -2
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +12 -2
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +10 -2
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +13 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/plain-terminal-text.d.ts +21 -0
- package/dist/utils/plain-terminal-text.d.ts.map +1 -0
- package/dist/utils/plain-terminal-text.js +156 -0
- package/dist/utils/plain-terminal-text.js.map +1 -0
- package/package.json +1 -1
- package/src/authorization/bare-repository.ts +70 -0
- package/src/authorization/command-line.ts +18 -4
- package/src/authorization/gate.ts +11 -0
- package/src/authorization/protected-paths.ts +89 -10
- package/src/authorization/readonly-commands.ts +75 -6
- package/src/authorization/readonly-flags.ts +103 -0
- package/src/authorization/shell-lexer.ts +367 -2
- package/src/authorization/shell-paths.ts +386 -0
- package/src/authorization/shell-session-state.ts +97 -0
- package/src/authorization/shell-session.ts +23 -0
- package/src/authorization/skill-grant.ts +1 -0
- package/src/compaction/extractor.ts +1 -0
- package/src/compaction/hooks.ts +43 -1
- package/src/compaction/manual.ts +6 -0
- package/src/compaction/restore.ts +3 -2
- package/src/config/runtime.ts +7 -0
- package/src/connector/mcp/client.ts +61 -4
- package/src/connector/web/guarded-fetch.ts +92 -0
- package/src/connector/web/index.ts +6 -1
- package/src/connector/web/types.ts +8 -0
- package/src/constants/compaction/index.ts +1 -1
- package/src/execution/code-runtime/worker-program.ts +9 -5
- package/src/execution/local.ts +6 -1
- package/src/peers/index.ts +8 -2
- package/src/peers/record.ts +45 -1
- package/src/peers/registry.ts +21 -5
- package/src/plugin/bin-path.ts +149 -0
- package/src/plugin/common-layout/read.ts +3 -3
- package/src/plugin/common-layout-names.ts +0 -1
- package/src/plugin/hook-module/capabilities.ts +94 -10
- package/src/plugin/hook-module/consent.ts +36 -0
- package/src/plugin/hook-module/host.ts +72 -21
- package/src/plugin/hook-module/index.ts +2 -0
- package/src/plugin/hook-module/scan.ts +76 -4
- package/src/plugin/hook-module/worker-source.ts +255 -28
- package/src/plugin/lifecycle.ts +67 -0
- package/src/plugin/shell-hook-tool-names.ts +1 -0
- package/src/plugin/shell-hook.ts +23 -4
- package/src/public-runtime.ts +27 -0
- package/src/public-tools.ts +36 -2
- package/src/public-types.ts +3 -1
- package/src/runtime/jobs/monitor-stream.ts +18 -4
- package/src/runtime/jobs/registry.ts +22 -2
- package/src/runtime/query/auto-review/git-status.ts +3 -2
- package/src/runtime/query/executor.ts +153 -12
- package/src/runtime/query/index.ts +5 -2
- package/src/runtime/query/iteration/outstanding-work.ts +22 -4
- package/src/runtime/query/iteration/phases/compaction.ts +14 -1
- package/src/runtime/query/iteration/phases/tool-review.ts +24 -7
- package/src/runtime/query/path-escalation.ts +52 -4
- package/src/runtime/query/review-policy.ts +47 -15
- package/src/runtime/query/steering.ts +32 -4
- package/src/sandbox/provider/local.ts +3 -1
- package/src/schedules/describe.ts +2 -0
- package/src/schedules/evaluate.ts +29 -1
- package/src/schedules/index.ts +9 -1
- package/src/schedules/next-fire.ts +9 -0
- package/src/schedules/spec.ts +42 -0
- package/src/schedules/types.ts +33 -3
- package/src/schedules/watch.ts +71 -0
- package/src/session/workspace/git-worktree.ts +3 -1
- package/src/skills/arguments.ts +250 -0
- package/src/skills/index.ts +10 -0
- package/src/skills/inline-shell-host.ts +16 -0
- package/src/skills/inline-shell.ts +1358 -22
- package/src/tools/builtins/bash-cwd.ts +2 -0
- package/src/tools/builtins/bash.ts +93 -13
- package/src/tools/builtins/exit-semantics.ts +10 -0
- package/src/tools/builtins/glob.ts +79 -15
- package/src/tools/builtins/grep.ts +37 -10
- package/src/tools/builtins/index.ts +15 -0
- package/src/tools/builtins/job.ts +1 -1
- package/src/tools/builtins/monitor.ts +4 -2
- package/src/tools/builtins/notebook-cells.ts +196 -0
- package/src/tools/builtins/notebook-edit.ts +280 -0
- package/src/tools/builtins/notebook-guard.ts +2 -1
- package/src/tools/builtins/push-notification.ts +138 -0
- package/src/tools/builtins/read-file.ts +9 -3
- package/src/tools/builtins/read-media.ts +2 -1
- package/src/tools/builtins/read-render.ts +5 -3
- package/src/tools/builtins/search-support.ts +17 -3
- package/src/tools/builtins/skill.ts +29 -7
- package/src/tools/builtins/sleep-guard.ts +128 -1
- package/src/tools/builtins/wait-for-job.ts +1 -1
- package/src/tools/builtins/web.ts +100 -3
- package/src/tools/command-shell.ts +166 -0
- package/src/tools/env-scrub.ts +13 -1
- package/src/tools/git-config-env.ts +143 -0
- package/src/tools/schedules/schedule-tool.ts +79 -3
- package/src/tools/schedules/types.ts +47 -9
- package/src/types/connector/mcp.ts +25 -0
- package/src/types/message/index.ts +53 -1
- package/src/types/permission/index.ts +20 -3
- package/src/types/plugin/index.ts +10 -2
- package/src/types/tool/index.ts +13 -0
- package/src/utils/plain-terminal-text.ts +142 -0
package/src/public-tools.ts
CHANGED
|
@@ -50,7 +50,7 @@ export type { UntrustedEnvelope, WrapUntrustedOptions } from './tools/untrusted-
|
|
|
50
50
|
export { UnsafeWritePathError, atomicWriteFile } from './tools/builtins/atomic-write-file.js'
|
|
51
51
|
export type { AtomicWriteOptions } from './tools/builtins/atomic-write-file.js'
|
|
52
52
|
|
|
53
|
-
export { getBuiltinTools } from './tools/builtins/index.js'
|
|
53
|
+
export { getBuiltinTools, getNotebookTools } from './tools/builtins/index.js'
|
|
54
54
|
// A host compiling operator permissions has a tool name and needs an argument
|
|
55
55
|
// to attach a pattern to. Without one it can only match against the serialised
|
|
56
56
|
// input, which is how an `allow` for `git status*` came to approve
|
|
@@ -63,11 +63,19 @@ export { builtinCommandArguments, commandArgumentOf } from './tools/command-argu
|
|
|
63
63
|
export {
|
|
64
64
|
type CommandShell,
|
|
65
65
|
type CommandShellProbe,
|
|
66
|
+
type ScriptShellName,
|
|
66
67
|
WINDOWS_BASH_GUIDANCE,
|
|
67
68
|
WINDOWS_CMD_FALLBACK_NOTICE,
|
|
68
69
|
findCommandShell,
|
|
69
70
|
findCommandShellForDialect,
|
|
70
71
|
findGitBash,
|
|
72
|
+
findScriptShell,
|
|
73
|
+
defaultScriptShellName,
|
|
74
|
+
hostDefaultScriptShellName,
|
|
75
|
+
installedScriptShell,
|
|
76
|
+
powershellArgs,
|
|
77
|
+
POWERSHELL_MAX_SCRIPT_CHARS,
|
|
78
|
+
windowsShellOverrideProblem,
|
|
71
79
|
hostCommandShell,
|
|
72
80
|
isWindowsBash,
|
|
73
81
|
rewriteWindowsNullRedirect,
|
|
@@ -78,9 +86,21 @@ export {
|
|
|
78
86
|
spawnHostShell,
|
|
79
87
|
withoutBashStartup,
|
|
80
88
|
} from './tools/command-shell.js'
|
|
89
|
+
// The settings every git a session starts carries, so a host that runs git itself uses the same ones.
|
|
90
|
+
export {
|
|
91
|
+
type GitConfigEntry,
|
|
92
|
+
SAFE_GIT_CONFIG,
|
|
93
|
+
hostGitConfig,
|
|
94
|
+
hostGitEnv,
|
|
95
|
+
isGitProgram,
|
|
96
|
+
withGitConfig,
|
|
97
|
+
withHostGitConfig,
|
|
98
|
+
withSafeGitConfig,
|
|
99
|
+
} from './tools/git-config-env.js'
|
|
81
100
|
export { ReadFileTool } from './tools/builtins/read-file.js'
|
|
82
101
|
export { WriteFileTool } from './tools/builtins/write-file.js'
|
|
83
102
|
export { EditTool, dryRunEdit } from './tools/builtins/edit.js'
|
|
103
|
+
export { NotebookEditTool } from './tools/builtins/notebook-edit.js'
|
|
84
104
|
export {
|
|
85
105
|
BashTool,
|
|
86
106
|
type ExecHostShellProgress,
|
|
@@ -89,7 +109,10 @@ export {
|
|
|
89
109
|
execHostShell,
|
|
90
110
|
} from './tools/builtins/bash.js'
|
|
91
111
|
// Authorization and execution must agree after a session carries its shell cwd.
|
|
92
|
-
export {
|
|
112
|
+
export {
|
|
113
|
+
effectiveBashWorkingDirectory,
|
|
114
|
+
pinBashWorkingDirectory,
|
|
115
|
+
} from './tools/builtins/bash-cwd.js'
|
|
93
116
|
// The same reach questions the executor asks of a nested shell call, for a host that runs one without a turn.
|
|
94
117
|
export {
|
|
95
118
|
type ShellLineEscalationContext,
|
|
@@ -180,6 +203,17 @@ export type { RunCodeToolOptions } from './tools/builtins/run-code.js'
|
|
|
180
203
|
export { LsTool } from './tools/builtins/ls.js'
|
|
181
204
|
export { SearchToolsTool } from './tools/builtins/search-tools.js'
|
|
182
205
|
export { PresentFileTool } from './tools/builtins/present-file.js'
|
|
206
|
+
export {
|
|
207
|
+
createPushNotificationTool,
|
|
208
|
+
PUSH_NOTIFICATION_MAX_CHARS,
|
|
209
|
+
PUSH_NOTIFICATION_MIN_INTERVAL_MS,
|
|
210
|
+
PUSH_NOTIFICATION_TOOL_NAME,
|
|
211
|
+
pushNotificationLine,
|
|
212
|
+
} from './tools/builtins/push-notification.js'
|
|
213
|
+
export type {
|
|
214
|
+
PushNotificationOutcome,
|
|
215
|
+
PushNotificationToolOptions,
|
|
216
|
+
} from './tools/builtins/push-notification.js'
|
|
183
217
|
export { VerifyOutputsTool } from './tools/builtins/verify-outputs.js'
|
|
184
218
|
export {
|
|
185
219
|
ViewImageTool,
|
package/src/public-types.ts
CHANGED
|
@@ -708,6 +708,7 @@ export type {
|
|
|
708
708
|
DescribeScheduleOptions,
|
|
709
709
|
OccurrenceCount,
|
|
710
710
|
ParseScheduleOptions,
|
|
711
|
+
ParseWatchOptions,
|
|
711
712
|
ScheduleAtSpec,
|
|
712
713
|
ScheduleCronSpec,
|
|
713
714
|
ScheduleDecision,
|
|
@@ -721,6 +722,7 @@ export type {
|
|
|
721
722
|
ScheduleObservedGap,
|
|
722
723
|
ScheduleSkipReason,
|
|
723
724
|
ScheduleSpec,
|
|
725
|
+
ScheduleWatchSpec,
|
|
724
726
|
} from './schedules/index.js'
|
|
725
727
|
export type {
|
|
726
728
|
ScheduleBrowserGrant,
|
|
@@ -760,7 +762,7 @@ export type {
|
|
|
760
762
|
PeerRuntimeDir,
|
|
761
763
|
ResolvePeerRuntimeDirOptions,
|
|
762
764
|
} from './peers/dir.js'
|
|
763
|
-
export type { PeerExchange, PeerRecord } from './peers/record.js'
|
|
765
|
+
export type { PeerAgentNode, PeerExchange, PeerRecord } from './peers/record.js'
|
|
764
766
|
export type { RemoteOrigin } from './peers/protocol.js'
|
|
765
767
|
export type { RoleContextInput } from './peers/envelope.js'
|
|
766
768
|
export type {
|
|
@@ -68,10 +68,24 @@ export function tooMuchOutputNotice(count: number, overMs: number): string {
|
|
|
68
68
|
return `[Monitor stopped — too much output (${count} events suppressed over ${formatMonitorDuration(overMs)}). Restart it with a more selective command.]`
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
/**
|
|
72
|
+
* `stderrJobId` is set when the command wrote to stderr (which is never an
|
|
73
|
+
* event) and no event was delivered: silence with diagnostics usually means
|
|
74
|
+
* the command failed, so the notice says where to read them.
|
|
75
|
+
*/
|
|
76
|
+
export function expiryNotice(
|
|
77
|
+
ms: number,
|
|
78
|
+
delivered: number,
|
|
79
|
+
options: { readonly stderrJobId?: string; readonly outputFile?: string } = {},
|
|
80
|
+
): string {
|
|
81
|
+
if (delivered > 0) {
|
|
82
|
+
return `[Monitor expired after ${formatMonitorDuration(ms)} with ${delivered} events delivered. Start it again if you still need the watch.]`
|
|
83
|
+
}
|
|
84
|
+
const stderr =
|
|
85
|
+
options.stderrJobId !== undefined
|
|
86
|
+
? ` Its command wrote to stderr, which is not delivered as events and may mean it failed: read it with job {"action":"read","id":"${options.stderrJobId}"}${options.outputFile !== undefined ? ` or see ${options.outputFile}` : ''}.`
|
|
87
|
+
: ''
|
|
88
|
+
return `[Monitor expired after ${formatMonitorDuration(ms)} with no events delivered.${stderr} Start it again if you still need the watch — and widen the filter if silence was unexpected.]`
|
|
75
89
|
}
|
|
76
90
|
|
|
77
91
|
export interface MonitorStreamStats {
|
|
@@ -3,9 +3,11 @@ import { closeSync, mkdirSync, openSync, writeSync } from 'node:fs'
|
|
|
3
3
|
import { join as joinPath } from 'node:path'
|
|
4
4
|
|
|
5
5
|
import { SANDBOX_KILL_GRACE_MS } from '../../constants/sandbox/index.js'
|
|
6
|
+
import { appendDirsToPath } from '../../plugin/bin-path.js'
|
|
6
7
|
import { isSignalablePid, killTree } from '../../process/kill-tree.js'
|
|
7
8
|
import { describeSpawnFailure, spawnHostShell } from '../../tools/command-shell.js'
|
|
8
9
|
import { scrubInheritedEnv } from '../../tools/env-scrub.js'
|
|
10
|
+
import { withSafeGitConfig } from '../../tools/git-config-env.js'
|
|
9
11
|
import { createHostOutputDecoder } from '../../tools/host-output.js'
|
|
10
12
|
import type {
|
|
11
13
|
BackgroundJobOutputWaitOptions,
|
|
@@ -222,6 +224,8 @@ export interface StartJobParams {
|
|
|
222
224
|
readonly description?: string
|
|
223
225
|
readonly workingDirectory: string
|
|
224
226
|
readonly env?: Readonly<Record<string, string>>
|
|
227
|
+
/** Folders added to the END of the host shell's PATH (a plugin's `bin/`). Ignored when `spawn` is given. */
|
|
228
|
+
readonly pathDirs?: readonly string[]
|
|
225
229
|
/**
|
|
226
230
|
* Start the process yourself — a sandbox does, so the job runs inside
|
|
227
231
|
* its boundary. Absent, the registry runs it on the
|
|
@@ -370,6 +374,8 @@ interface MonitorState {
|
|
|
370
374
|
readonly description: string
|
|
371
375
|
readonly timeoutMs: number
|
|
372
376
|
seq: number
|
|
377
|
+
/** The command wrote to stderr, which is never an event. */
|
|
378
|
+
stderrWrote?: boolean
|
|
373
379
|
expiryTimer?: ReturnType<typeof setTimeout>
|
|
374
380
|
/** A terminal notice went out: nothing more is delivered, from the source or from anywhere. */
|
|
375
381
|
sealed?: boolean
|
|
@@ -732,7 +738,14 @@ export class BackgroundJobRegistry {
|
|
|
732
738
|
: {
|
|
733
739
|
child: spawnHostShell(params.command, {
|
|
734
740
|
cwd: params.workingDirectory,
|
|
735
|
-
|
|
741
|
+
// A background job and a monitor are git-capable shells like `bash`: the
|
|
742
|
+
// same settings, so a planted folder cannot get git to run its program.
|
|
743
|
+
env: withSafeGitConfig(
|
|
744
|
+
appendDirsToPath(
|
|
745
|
+
withNodeOnPath({ ...inherited.env, ...params.env }),
|
|
746
|
+
params.pathDirs ?? [],
|
|
747
|
+
),
|
|
748
|
+
),
|
|
736
749
|
// `detached` makes the child the leader of its own process group
|
|
737
750
|
// off Windows, which is what `killTree` needs to reach the command
|
|
738
751
|
// and everything it forks rather than only the wrapping shell. See
|
|
@@ -953,6 +966,7 @@ export class BackgroundJobRegistry {
|
|
|
953
966
|
// where a watcher's diagnostics belong: a model told about every
|
|
954
967
|
// warning line would stop reading the events that matter.
|
|
955
968
|
if (stream === 'stdout') entry.monitor?.stream.push(text)
|
|
969
|
+
else if (entry.monitor) entry.monitor.stderrWrote = true
|
|
956
970
|
const retainedStart = entry.produced - Buffer.byteLength(entry.buffer)
|
|
957
971
|
while (
|
|
958
972
|
entry.outputChunks.length > MAX_CHANNEL_CHUNKS ||
|
|
@@ -1003,7 +1017,10 @@ export class BackgroundJobRegistry {
|
|
|
1003
1017
|
this.announceMonitorEvent(
|
|
1004
1018
|
entry,
|
|
1005
1019
|
'notice',
|
|
1006
|
-
expiryNotice(monitor.timeoutMs, monitor.stream.stats().eventsDelivered
|
|
1020
|
+
expiryNotice(monitor.timeoutMs, monitor.stream.stats().eventsDelivered, {
|
|
1021
|
+
...(monitor.stderrWrote ? { stderrJobId: entry.record.id } : {}),
|
|
1022
|
+
...(entry.record.outputFile !== undefined ? { outputFile: entry.record.outputFile } : {}),
|
|
1023
|
+
}),
|
|
1007
1024
|
)
|
|
1008
1025
|
// Nothing follows a terminal notice. A command that ignores SIGTERM keeps
|
|
1009
1026
|
// printing until the SIGKILL, and those lines would reach the model after
|
|
@@ -1403,6 +1420,8 @@ export function bindOwner(
|
|
|
1403
1420
|
defaults: {
|
|
1404
1421
|
readonly workingDirectory?: string
|
|
1405
1422
|
readonly env?: Record<string, string>
|
|
1423
|
+
/** Read per job start; see `StartJobParams.pathDirs`. */
|
|
1424
|
+
readonly pathDirs?: () => readonly string[]
|
|
1406
1425
|
/** See `StartJobParams.spawn`; given the resolved command, directory and env. */
|
|
1407
1426
|
readonly spawn?: (params: {
|
|
1408
1427
|
readonly command: string
|
|
@@ -1469,6 +1488,7 @@ export function bindOwner(
|
|
|
1469
1488
|
...(!monitor && params.description !== undefined ? { description: params.description } : {}),
|
|
1470
1489
|
...(jobsFolder !== undefined ? { outputDirectory: jobsFolder } : {}),
|
|
1471
1490
|
...(defaults.env ? { env: defaults.env } : {}),
|
|
1491
|
+
...(!spawnHost && defaults.pathDirs ? { pathDirs: defaults.pathDirs() } : {}),
|
|
1472
1492
|
...(spawnHost
|
|
1473
1493
|
? {
|
|
1474
1494
|
spawn: () =>
|
|
@@ -22,6 +22,7 @@ import { join, resolve } from 'node:path'
|
|
|
22
22
|
|
|
23
23
|
import { basename, commandSpan, lexShellCommandLine } from '../../../authorization/shell-lexer.js'
|
|
24
24
|
import type { ShellCommand, ShellWord } from '../../../authorization/shell-lexer.js'
|
|
25
|
+
import { hostGitEnv } from '../../../tools/git-config-env.js'
|
|
25
26
|
import type { ShellDialect } from '../../../types/tool/index.js'
|
|
26
27
|
|
|
27
28
|
/** How long git may take to answer. */
|
|
@@ -365,13 +366,13 @@ export function gitStatusRunner(timeoutMs: number = GIT_STATUS_TIMEOUT_MS): GitS
|
|
|
365
366
|
windowsHide: true,
|
|
366
367
|
encoding: 'utf8',
|
|
367
368
|
// A partial clone would fetch missing objects over the network.
|
|
368
|
-
env: {
|
|
369
|
+
env: hostGitEnv({
|
|
369
370
|
...process.env,
|
|
370
371
|
GIT_OPTIONAL_LOCKS: '0',
|
|
371
372
|
GIT_TERMINAL_PROMPT: '0',
|
|
372
373
|
GIT_NO_LAZY_FETCH: '1',
|
|
373
374
|
LC_ALL: 'C',
|
|
374
|
-
},
|
|
375
|
+
}),
|
|
375
376
|
...(signal ? { signal } : {}),
|
|
376
377
|
},
|
|
377
378
|
(error, stdout) => (error ? fail(error) : done(stdout)),
|
|
@@ -3,6 +3,7 @@ import { isAbsolute, join, resolve } from 'node:path'
|
|
|
3
3
|
import type { Span } from '@opentelemetry/api'
|
|
4
4
|
import type { AuthorizationGate } from '../../authorization/gate.js'
|
|
5
5
|
import { unknownProgramInLine } from '../../authorization/program.js'
|
|
6
|
+
import { withShellSession } from '../../authorization/shell-session-state.js'
|
|
6
7
|
import { type SkillGrantSet, compileSkillGrant } from '../../authorization/skill-grant.js'
|
|
7
8
|
import { extractFromToolCall, extractFromToolResult } from '../../compaction/extractor.js'
|
|
8
9
|
import type { WorkingStateManager } from '../../compaction/manager.js'
|
|
@@ -115,8 +116,9 @@ import {
|
|
|
115
116
|
} from './file-evidence-context.js'
|
|
116
117
|
import { seedObservationLedger } from './file-evidence-seed.js'
|
|
117
118
|
import { DEFAULT_TOOL_RESULT_GUARDRAILS } from './guardrail-presets.js'
|
|
118
|
-
import { declaredWriteEscalation, shellEscalations } from './path-escalation.js'
|
|
119
|
+
import { declaredWriteEscalation, protectedRoots, shellEscalations } from './path-escalation.js'
|
|
119
120
|
import type { ToolResultObservation } from './project-instructions.js'
|
|
121
|
+
import { CLASSIFY_NESTED_REFUSAL, allowedCallTooWide } from './review-policy.js'
|
|
120
122
|
import { savedPresentation } from './saved-presentation.js'
|
|
121
123
|
import { ToolCallBudget, assertMaxToolCalls } from './tool-call-budget.js'
|
|
122
124
|
import {
|
|
@@ -832,6 +834,9 @@ export function deniedToolOutput(toolName: string, reason: string): string {
|
|
|
832
834
|
return `Error: Tool "${toolName}" was not executed. ${reason}`
|
|
833
835
|
}
|
|
834
836
|
|
|
837
|
+
/** Added directories already warned about in this process. */
|
|
838
|
+
const warnedProtectedDirectories = new Set<string>()
|
|
839
|
+
|
|
835
840
|
export class ToolExecutor {
|
|
836
841
|
/** The recovery routes this turn actually has, so a pointer never names a missing tool. */
|
|
837
842
|
private recoveryRoutes(): RetainedOutputRoutes {
|
|
@@ -904,6 +909,20 @@ export class ToolExecutor {
|
|
|
904
909
|
this.emitEvent = emitEvent
|
|
905
910
|
this.log = log
|
|
906
911
|
this.probes = probes
|
|
912
|
+
this.warnProtectedAddedDirectories()
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/** Tell the operator once per folder that an added directory is itself protected. */
|
|
916
|
+
private warnProtectedAddedDirectories(): void {
|
|
917
|
+
const added = this.config.additionalDirectories
|
|
918
|
+
if (added === undefined || added.length === 0) return
|
|
919
|
+
for (const directory of protectedRoots(added)) {
|
|
920
|
+
if (warnedProtectedDirectories.has(directory)) continue
|
|
921
|
+
warnedProtectedDirectories.add(directory)
|
|
922
|
+
this.log.warn('An added directory is a protected folder, so writes in it are asked about', {
|
|
923
|
+
'namzu.runtime.added_directory': directory,
|
|
924
|
+
})
|
|
925
|
+
}
|
|
907
926
|
}
|
|
908
927
|
|
|
909
928
|
setWorkingStateManager(manager: WorkingStateManager): void {
|
|
@@ -1330,13 +1349,63 @@ export class ToolExecutor {
|
|
|
1330
1349
|
}
|
|
1331
1350
|
}
|
|
1332
1351
|
|
|
1352
|
+
/**
|
|
1353
|
+
* The host folder this session's next shell command starts in, for the
|
|
1354
|
+
* read-only decision on a git line. Undefined inside a sandbox, whose files
|
|
1355
|
+
* are not this host's.
|
|
1356
|
+
*/
|
|
1357
|
+
private shellDirectory(): string | undefined {
|
|
1358
|
+
if (this.sandboxed) return undefined
|
|
1359
|
+
try {
|
|
1360
|
+
return effectiveBashWorkingDirectory(this.config.sessionId, this.config.workingDirectory, {
|
|
1361
|
+
sandboxed: false,
|
|
1362
|
+
})
|
|
1363
|
+
} catch {
|
|
1364
|
+
return undefined
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1333
1368
|
private resolvePermissionMode(): PermissionMode {
|
|
1334
1369
|
const configured = this.config.permissionMode
|
|
1335
1370
|
return typeof configured === 'function' ? configured() : configured
|
|
1336
1371
|
}
|
|
1337
1372
|
|
|
1338
|
-
|
|
1373
|
+
// Every line a call reads, to decide on it or to run it, is read with what
|
|
1374
|
+
// earlier lines of this session declared: see `shell-session-state.ts`.
|
|
1339
1375
|
evaluatePreparedAuthorization(toolName: string, input: unknown) {
|
|
1376
|
+
return withShellSession(
|
|
1377
|
+
this.config.sessionId,
|
|
1378
|
+
() => this.evaluatePreparedAuthorizationIn(toolName, input),
|
|
1379
|
+
this.shellDirectory(),
|
|
1380
|
+
)
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
prepareBatchForReview(...args: Parameters<ToolExecutor['prepareBatchForReviewIn']>) {
|
|
1384
|
+
return withShellSession(
|
|
1385
|
+
this.config.sessionId,
|
|
1386
|
+
() => this.prepareBatchForReviewIn(...args),
|
|
1387
|
+
this.shellDirectory(),
|
|
1388
|
+
)
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
reprepareBatchForReview(...args: Parameters<ToolExecutor['reprepareBatchForReviewIn']>) {
|
|
1392
|
+
return withShellSession(
|
|
1393
|
+
this.config.sessionId,
|
|
1394
|
+
() => this.reprepareBatchForReviewIn(...args),
|
|
1395
|
+
this.shellDirectory(),
|
|
1396
|
+
)
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
executeBatch(...args: Parameters<ToolExecutor['executeBatchIn']>) {
|
|
1400
|
+
return withShellSession(
|
|
1401
|
+
this.config.sessionId,
|
|
1402
|
+
() => this.executeBatchIn(...args),
|
|
1403
|
+
this.shellDirectory(),
|
|
1404
|
+
)
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
/** Evaluate the turn's operator policy against one already-prepared value. */
|
|
1408
|
+
private evaluatePreparedAuthorizationIn(toolName: string, input: unknown) {
|
|
1340
1409
|
return this.config.authorizationGate?.evaluate({
|
|
1341
1410
|
toolName,
|
|
1342
1411
|
toolInput: input,
|
|
@@ -1376,7 +1445,7 @@ export class ToolExecutor {
|
|
|
1376
1445
|
* The returned projection is what policy and a human review; execution later
|
|
1377
1446
|
* consumes the registry-owned preparations rather than parsing again.
|
|
1378
1447
|
*/
|
|
1379
|
-
async
|
|
1448
|
+
private async prepareBatchForReviewIn(
|
|
1380
1449
|
response: ChatCompletionResponse,
|
|
1381
1450
|
hostModifiedCallIds?: ReadonlySet<string>,
|
|
1382
1451
|
): Promise<PreparedToolBatch> {
|
|
@@ -1678,7 +1747,7 @@ export class ToolExecutor {
|
|
|
1678
1747
|
}
|
|
1679
1748
|
|
|
1680
1749
|
/** Re-prepare only calls whose raw input a reviewer actually changed. */
|
|
1681
|
-
async
|
|
1750
|
+
private async reprepareBatchForReviewIn(
|
|
1682
1751
|
response: ChatCompletionResponse,
|
|
1683
1752
|
previous: PreparedToolBatch,
|
|
1684
1753
|
changedCallIds: ReadonlySet<string>,
|
|
@@ -1746,7 +1815,7 @@ export class ToolExecutor {
|
|
|
1746
1815
|
return batch
|
|
1747
1816
|
}
|
|
1748
1817
|
|
|
1749
|
-
async
|
|
1818
|
+
private async executeBatchIn(
|
|
1750
1819
|
response: ChatCompletionResponse,
|
|
1751
1820
|
denials?: ToolCallDenials,
|
|
1752
1821
|
prior?: PriorToolResults,
|
|
@@ -2375,14 +2444,34 @@ export class ToolExecutor {
|
|
|
2375
2444
|
// The mode the turn is decided under answers a nested call as it answers the same
|
|
2376
2445
|
// call made directly: the tool that made this one reads, so the policy never saw it.
|
|
2377
2446
|
// Asked only when there is a mode to answer to: with none, the call is decided as before.
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2447
|
+
// Asked again right before the call starts (below), because a hook or the person can
|
|
2448
|
+
// change the mode while the earlier steps wait.
|
|
2449
|
+
const askMode = (): string | undefined => {
|
|
2450
|
+
const mode = this.config.reviewMode?.()
|
|
2451
|
+
return mode === undefined
|
|
2381
2452
|
? undefined
|
|
2382
|
-
: nestedCallModeRefusal(
|
|
2453
|
+
: nestedCallModeRefusal(mode, {
|
|
2383
2454
|
readOnly: isTrustedReadOnly(nestedTool, preparedInput, this.toolSource(name)),
|
|
2384
2455
|
allowedByRule: gateResult?.decision === 'allow' && gateResult.matchedRule !== null,
|
|
2456
|
+
ruleTooWide:
|
|
2457
|
+
gateResult?.decision === 'allow' &&
|
|
2458
|
+
allowedCallTooWide({
|
|
2459
|
+
name,
|
|
2460
|
+
tool: nestedTool,
|
|
2461
|
+
input: preparedInput,
|
|
2462
|
+
allowRule: gateResult.matchedRule,
|
|
2463
|
+
}),
|
|
2385
2464
|
})
|
|
2465
|
+
}
|
|
2466
|
+
const modeRefusal = askMode()
|
|
2467
|
+
// A model loaded the text that made this call, and auto mode would have sent the call
|
|
2468
|
+
// to its reviewer: it is not run and not a failure. The model is asked to make the call
|
|
2469
|
+
// itself (see `ToolDispatchOptions.handOff`), where the reviewer does see it. A rule's
|
|
2470
|
+
// deny still fails the load, and so does every other mode's refusal.
|
|
2471
|
+
const handedOff =
|
|
2472
|
+
options?.handOff === true &&
|
|
2473
|
+
modeRefusal === CLASSIFY_NESTED_REFUSAL &&
|
|
2474
|
+
gateResult?.decision !== 'deny'
|
|
2386
2475
|
const runGranted =
|
|
2387
2476
|
modeRefusal === undefined &&
|
|
2388
2477
|
gateResult?.decision === 'review' &&
|
|
@@ -2394,8 +2483,20 @@ export class ToolExecutor {
|
|
|
2394
2483
|
modeRefusal !== undefined ||
|
|
2395
2484
|
(gateResult && gateResult.decision !== 'allow' && !runGranted)
|
|
2396
2485
|
) {
|
|
2486
|
+
// A hand-off still asks the caller's last word first: a guard that refuses the
|
|
2487
|
+
// command at load must not lose to the model's own call, which the classifier
|
|
2488
|
+
// decides without that guard. A refusal is the answer, and nothing is handed off.
|
|
2489
|
+
if (handedOff && options?.beforeRun) {
|
|
2490
|
+
const refusal = await options.beforeRun({ name, input: preparedInput, toolUseId: nestedId })
|
|
2491
|
+
signal.throwIfAborted()
|
|
2492
|
+
if (refusal !== undefined) {
|
|
2493
|
+
await progress.close()
|
|
2494
|
+
return { success: false, output: '', error: refusal }
|
|
2495
|
+
}
|
|
2496
|
+
}
|
|
2397
2497
|
const reason =
|
|
2398
|
-
modeRefusal !== undefined
|
|
2498
|
+
modeRefusal !== undefined &&
|
|
2499
|
+
!(modeRefusal === CLASSIFY_NESTED_REFUSAL && gateResult?.decision === 'deny')
|
|
2399
2500
|
? `Blocked: ${modeRefusal}.`
|
|
2400
2501
|
: nestedEscalation
|
|
2401
2502
|
? 'Blocked: this nested call reaches a protected path, removal floor, outside-root boundary or another safety escalation. Call it directly so it can be reviewed.'
|
|
@@ -2403,7 +2504,9 @@ export class ToolExecutor {
|
|
|
2403
2504
|
? `Blocked: "${name}" requires the person's approval for every call, and an approval cannot be requested from inside another tool. Call it directly.`
|
|
2404
2505
|
: gateResult?.decision === 'deny'
|
|
2405
2506
|
? `Blocked by the authorization gate: ${gateResult.reason}`
|
|
2406
|
-
:
|
|
2507
|
+
: gateResult?.matchedRule === null
|
|
2508
|
+
? `Blocked by the authorization gate: this nested call requires an explicit allow rule because an operator review cannot be opened from inside another tool. ${gateResult.reason}`
|
|
2509
|
+
: `Blocked by the authorization gate: a rule or safety check asked for this call, an operator review cannot be opened from inside another tool, and no allow rule lifts that: call it directly so a person can review it. ${gateResult?.reason}`
|
|
2407
2510
|
const output = deniedToolOutput(name, reason)
|
|
2408
2511
|
// Same fail-closed durability rule as a direct gate denial: if the
|
|
2409
2512
|
// configured session log cannot record the refusal, do not quietly carry
|
|
@@ -2438,7 +2541,12 @@ export class ToolExecutor {
|
|
|
2438
2541
|
outputLength: output.length,
|
|
2439
2542
|
...(via ? { via } : {}),
|
|
2440
2543
|
})
|
|
2441
|
-
return {
|
|
2544
|
+
return {
|
|
2545
|
+
success: false,
|
|
2546
|
+
output: '',
|
|
2547
|
+
error: reason,
|
|
2548
|
+
...(handedOff ? { data: { handedOff: true } } : {}),
|
|
2549
|
+
}
|
|
2442
2550
|
}
|
|
2443
2551
|
|
|
2444
2552
|
// A review approved the PARENT's escalation, as the parent's input
|
|
@@ -2532,6 +2640,33 @@ export class ToolExecutor {
|
|
|
2532
2640
|
return { success: false, output: '', error: message }
|
|
2533
2641
|
}
|
|
2534
2642
|
|
|
2643
|
+
// The mode is read once more, after the hooks and the veto had their time: a switch
|
|
2644
|
+
// to a stricter one in that window must still stop this call before it starts.
|
|
2645
|
+
const lateRefusal = askMode()
|
|
2646
|
+
if (lateRefusal !== undefined) {
|
|
2647
|
+
const message = `Blocked: ${lateRefusal}.`
|
|
2648
|
+
if (this.config.recordAudit) {
|
|
2649
|
+
await this.config.recordAudit({
|
|
2650
|
+
what: { action: 'tool_call', tool: name },
|
|
2651
|
+
outcome: 'refused',
|
|
2652
|
+
reason: message,
|
|
2653
|
+
})
|
|
2654
|
+
}
|
|
2655
|
+
await progress.close()
|
|
2656
|
+
await this.emitEvent({
|
|
2657
|
+
type: 'tool_completed',
|
|
2658
|
+
turnId: this.config.turnId,
|
|
2659
|
+
toolUseId: nestedId,
|
|
2660
|
+
toolName: name,
|
|
2661
|
+
result: deniedToolOutput(name, message),
|
|
2662
|
+
isError: true,
|
|
2663
|
+
durationMs: Date.now() - startedAt,
|
|
2664
|
+
outputLength: message.length,
|
|
2665
|
+
...(via ? { via } : {}),
|
|
2666
|
+
})
|
|
2667
|
+
return { success: false, output: '', error: message }
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2535
2670
|
let result: ToolResult
|
|
2536
2671
|
try {
|
|
2537
2672
|
// Use the same deadline layer as a model-issued call. Calling the
|
|
@@ -2668,6 +2803,9 @@ export class ToolExecutor {
|
|
|
2668
2803
|
: {}),
|
|
2669
2804
|
abortSignal: this.config.abortSignal,
|
|
2670
2805
|
env: this.config.env,
|
|
2806
|
+
...(this.config.pluginManager && !this.config.sandbox
|
|
2807
|
+
? { pluginBinDirs: () => this.config.pluginManager?.enabledBinDirs() ?? [] }
|
|
2808
|
+
: {}),
|
|
2671
2809
|
log: (level, message) => this.log[level](message),
|
|
2672
2810
|
permissionContext: {
|
|
2673
2811
|
mode: this.batchMode ?? this.resolvePermissionMode(),
|
|
@@ -2746,6 +2884,9 @@ export class ToolExecutor {
|
|
|
2746
2884
|
: {}),
|
|
2747
2885
|
workingDirectory: this.config.workingDirectory,
|
|
2748
2886
|
env: this.config.env,
|
|
2887
|
+
...(this.config.pluginManager && !this.config.sandbox
|
|
2888
|
+
? { pathDirs: () => this.config.pluginManager?.enabledBinDirs() ?? [] }
|
|
2889
|
+
: {}),
|
|
2749
2890
|
...(this.config.sandbox?.spawnDetached
|
|
2750
2891
|
? {
|
|
2751
2892
|
spawn: (job: {
|
|
@@ -1828,7 +1828,10 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1828
1828
|
// A monitor's end is told in the monitor's own words (the same
|
|
1829
1829
|
// `describeMonitorEnd` the transcript and a single-shot run use) and
|
|
1830
1830
|
// in the same envelope as its events, rather than as a generic exit.
|
|
1831
|
-
monitorNotices?.steer(
|
|
1831
|
+
monitorNotices?.steer(
|
|
1832
|
+
formatMonitorEnd(job, params.backgroundJobs.monitorStats(job.id)),
|
|
1833
|
+
job.id,
|
|
1834
|
+
)
|
|
1832
1835
|
pendingMonitorEndIds.add(job.id)
|
|
1833
1836
|
void eventTranslator
|
|
1834
1837
|
.emitEvent({
|
|
@@ -1878,7 +1881,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1878
1881
|
} catch {
|
|
1879
1882
|
// The record is gone; the event still stands without its command.
|
|
1880
1883
|
}
|
|
1881
|
-
monitorNotices?.steer(formatMonitorEvent(event, command))
|
|
1884
|
+
monitorNotices?.steer(formatMonitorEvent(event, command), event.jobId)
|
|
1882
1885
|
pendingMonitorEventIds.add(event.id)
|
|
1883
1886
|
void eventTranslator
|
|
1884
1887
|
.emitEvent({
|
|
@@ -283,7 +283,11 @@ export function deliverAwaitedJobExits(ctx: IterationContext): boolean {
|
|
|
283
283
|
[NAMZU.TURN_ID]: ctx.recorder.turnId,
|
|
284
284
|
'namzu.runtime.jobs': delivered.exits.map((job) => job.id),
|
|
285
285
|
})
|
|
286
|
-
ctx.recorder.pushMessage(
|
|
286
|
+
ctx.recorder.pushMessage(
|
|
287
|
+
createRuntimeContextMessage(formatJobNote(delivered.text), 'job-exit', [
|
|
288
|
+
{ kind: 'job-exit', jobIds: delivered.exits.map((job) => job.id) },
|
|
289
|
+
]),
|
|
290
|
+
)
|
|
287
291
|
ctx.onJobNoticeDelivered?.()
|
|
288
292
|
return true
|
|
289
293
|
}
|
|
@@ -303,13 +307,18 @@ export function deliverAwaitedJobExits(ctx: IterationContext): boolean {
|
|
|
303
307
|
*/
|
|
304
308
|
export function deliverMonitorNotices(ctx: IterationContext): boolean {
|
|
305
309
|
if (!ctx.monitorNotices) return false
|
|
310
|
+
const jobIds = ctx.monitorNotices.keys?.() ?? []
|
|
306
311
|
const text = ctx.awaitedJobs?.takeMonitorDelivery(() => ctx.monitorNotices?.drain())
|
|
307
312
|
if (text === undefined) return false
|
|
308
313
|
|
|
309
314
|
ctx.log.info('Delivering monitor events the turn held itself open for', {
|
|
310
315
|
[NAMZU.TURN_ID]: ctx.recorder.turnId,
|
|
311
316
|
})
|
|
312
|
-
ctx.recorder.pushMessage(
|
|
317
|
+
ctx.recorder.pushMessage(
|
|
318
|
+
createRuntimeContextMessage(formatMonitorNote(text), 'job-exit', [
|
|
319
|
+
{ kind: 'job-event', jobIds },
|
|
320
|
+
]),
|
|
321
|
+
)
|
|
313
322
|
ctx.onMonitorNoticeDelivered?.()
|
|
314
323
|
return true
|
|
315
324
|
}
|
|
@@ -485,7 +494,11 @@ export function deliverArrivedJobExits(ctx: IterationContext): void {
|
|
|
485
494
|
[NAMZU.TURN_ID]: ctx.recorder.turnId,
|
|
486
495
|
'namzu.runtime.jobs': delivered.exits.map((job) => job.id),
|
|
487
496
|
})
|
|
488
|
-
ctx.recorder.pushMessage(
|
|
497
|
+
ctx.recorder.pushMessage(
|
|
498
|
+
createRuntimeContextMessage(formatJobNote(delivered.text), 'job-exit', [
|
|
499
|
+
{ kind: 'job-exit', jobIds: delivered.exits.map((job) => job.id) },
|
|
500
|
+
]),
|
|
501
|
+
)
|
|
489
502
|
ctx.onJobNoticeDelivered?.()
|
|
490
503
|
}
|
|
491
504
|
|
|
@@ -497,6 +510,7 @@ export function deliverArrivedJobExits(ctx: IterationContext): void {
|
|
|
497
510
|
*/
|
|
498
511
|
function deliverArrivedMonitorNotices(ctx: IterationContext): void {
|
|
499
512
|
if (!ctx.monitorNotices) return
|
|
513
|
+
const jobIds = ctx.monitorNotices.keys?.() ?? []
|
|
500
514
|
const text = ctx.awaitedJobs?.takeMonitorDelivery(() => ctx.monitorNotices?.drain())
|
|
501
515
|
if (text === undefined) return
|
|
502
516
|
|
|
@@ -508,6 +522,10 @@ function deliverArrivedMonitorNotices(ctx: IterationContext): void {
|
|
|
508
522
|
ctx.log.info('Delivering monitor events the turn would have settled over', {
|
|
509
523
|
[NAMZU.TURN_ID]: ctx.recorder.turnId,
|
|
510
524
|
})
|
|
511
|
-
ctx.recorder.pushMessage(
|
|
525
|
+
ctx.recorder.pushMessage(
|
|
526
|
+
createRuntimeContextMessage(formatMonitorNote(text), 'job-exit', [
|
|
527
|
+
{ kind: 'job-event', jobIds },
|
|
528
|
+
]),
|
|
529
|
+
)
|
|
512
530
|
ctx.onMonitorNoticeDelivered?.()
|
|
513
531
|
}
|
|
@@ -4,7 +4,11 @@ import {
|
|
|
4
4
|
resolveTriggerThreshold,
|
|
5
5
|
} from '../../../../compaction/context-window.js'
|
|
6
6
|
import { findDanglingMessages } from '../../../../compaction/dangling.js'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
askPreCompact,
|
|
9
|
+
postCompactSummary,
|
|
10
|
+
startAfterCompaction,
|
|
11
|
+
} from '../../../../compaction/hooks.js'
|
|
8
12
|
import {
|
|
9
13
|
LOADED_SKILLS_ENTRY_KEY,
|
|
10
14
|
type RenderedSkills,
|
|
@@ -829,6 +833,13 @@ export async function runCompactionCheck(
|
|
|
829
833
|
ctx.emitEvent,
|
|
830
834
|
)
|
|
831
835
|
applyLifecycleHookResults('post_compact', results)
|
|
836
|
+
await startAfterCompaction(ctx.pluginManager, {
|
|
837
|
+
sessionId: ctx.recorder.sessionId,
|
|
838
|
+
turnId: ctx.recorder.turnId,
|
|
839
|
+
iteration: ctx.recorder.currentIteration,
|
|
840
|
+
signal: ctx.abortController.signal,
|
|
841
|
+
emitEvent: ctx.emitEvent,
|
|
842
|
+
})
|
|
832
843
|
}
|
|
833
844
|
}
|
|
834
845
|
}
|
|
@@ -841,6 +852,8 @@ async function runCompactionCheckInner(
|
|
|
841
852
|
const configured = ctx.compactionConfig
|
|
842
853
|
if (!configured) return
|
|
843
854
|
if (configured.strategy === 'disabled') return
|
|
855
|
+
// Automatic compaction off: only a pass the provider forced (an overflow) runs.
|
|
856
|
+
if (configured.autoCompact === false && !options?.force) return
|
|
844
857
|
const deepened = options?.deeper ? deepenConfig(configured, ctx.recorder.messages) : configured
|
|
845
858
|
|
|
846
859
|
const measured = measureContext(ctx)
|