@namzu/sdk 70.0.0 → 71.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +123 -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.map +1 -1
- package/dist/authorization/protected-paths.js +46 -1
- 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 +108 -3
- 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/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 +1 -1
- 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/scan.d.ts +16 -0
- package/dist/plugin/hook-module/scan.d.ts.map +1 -1
- package/dist/plugin/hook-module/scan.js +67 -2
- package/dist/plugin/hook-module/scan.js.map +1 -1
- package/dist/plugin/hook-module/worker-source.d.ts.map +1 -1
- package/dist/plugin/hook-module/worker-source.js +56 -0
- 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 +8 -6
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +8 -5
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +6 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +6 -2
- 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 +60 -5
- 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.map +1 -1
- package/dist/runtime/query/review-policy.js +4 -2
- 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.d.ts +17 -0
- package/dist/skills/inline-shell.d.ts.map +1 -1
- package/dist/skills/inline-shell.js +1232 -14
- package/dist/skills/inline-shell.js.map +1 -1
- package/dist/store/session-index/index.d.ts +5 -0
- package/dist/store/session-index/index.d.ts.map +1 -1
- package/dist/store/session-index/index.js +5 -1
- package/dist/store/session-index/index.js.map +1 -1
- package/dist/store/session-index/rebuild.d.ts +18 -0
- package/dist/store/session-index/rebuild.d.ts.map +1 -1
- package/dist/store/session-index/rebuild.js +79 -5
- package/dist/store/session-index/rebuild.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts +8 -0
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +23 -1
- package/dist/store/session-index/sqlite.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 +28 -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/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 +6 -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 +45 -1
- package/src/authorization/readonly-commands.ts +75 -6
- package/src/authorization/readonly-flags.ts +103 -0
- package/src/authorization/shell-lexer.ts +126 -3
- 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/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 +1 -1
- package/src/plugin/common-layout-names.ts +0 -1
- package/src/plugin/hook-module/scan.ts +74 -2
- package/src/plugin/hook-module/worker-source.ts +56 -0
- 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 +21 -0
- package/src/public-tools.ts +32 -1
- 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 +79 -5
- 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 +5 -2
- 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.ts +1268 -14
- package/src/store/session-index/index.ts +10 -1
- package/src/store/session-index/rebuild.ts +81 -5
- package/src/store/session-index/sqlite.ts +30 -1
- 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 +27 -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/plugin/index.ts +10 -2
- package/src/types/tool/index.ts +6 -0
- package/src/utils/plain-terminal-text.ts +142 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { existsSync, lstatSync, readdirSync, realpathSync } from 'node:fs'
|
|
2
|
+
import { delimiter, isAbsolute, join, relative } from 'node:path'
|
|
3
|
+
import { readEnvironmentEntry, setEnvironmentEntry } from '../utils/process-environment.js'
|
|
4
|
+
|
|
5
|
+
/** What a plugin's `bin/` folder came to: a folder to put on PATH, or the reason it is not. */
|
|
6
|
+
export type PluginBinResolution =
|
|
7
|
+
| { readonly dir: string }
|
|
8
|
+
| { readonly dir?: undefined; readonly refused: string }
|
|
9
|
+
|
|
10
|
+
function inside(root: string, candidate: string): boolean {
|
|
11
|
+
const rel = relative(root, candidate)
|
|
12
|
+
return rel !== '' && !rel.startsWith('..') && !isAbsolute(rel)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// A folder whose name could be read by a shell as more than a path is left off.
|
|
16
|
+
const UNSAFE_PATH_CHARACTERS = /[:"'$`\\\n\r;]/u
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* The folder of a plugin's programs, when it is safe to put on a shell's PATH.
|
|
20
|
+
*
|
|
21
|
+
* Nothing here reads a file's contents. A plugin without a `bin/` folder is
|
|
22
|
+
* simply absent (undefined). A `bin/` that is a link leaving the plugin, or
|
|
23
|
+
* that holds a link leaving the plugin, is refused whole: PATH lookup follows
|
|
24
|
+
* links, so one such entry would run a program the install never listed.
|
|
25
|
+
*/
|
|
26
|
+
export function resolvePluginBinDirectory(rootDir: string): PluginBinResolution | undefined {
|
|
27
|
+
let realRoot: string
|
|
28
|
+
let bin: string
|
|
29
|
+
try {
|
|
30
|
+
realRoot = realpathSync(rootDir)
|
|
31
|
+
const lexical = join(realRoot, 'bin')
|
|
32
|
+
try {
|
|
33
|
+
lstatSync(lexical)
|
|
34
|
+
} catch {
|
|
35
|
+
return undefined
|
|
36
|
+
}
|
|
37
|
+
bin = realpathSync(lexical)
|
|
38
|
+
} catch {
|
|
39
|
+
return undefined
|
|
40
|
+
}
|
|
41
|
+
if (!inside(realRoot, bin)) return { refused: 'bin/ resolves outside the plugin folder' }
|
|
42
|
+
try {
|
|
43
|
+
if (!lstatSync(bin).isDirectory()) return undefined
|
|
44
|
+
} catch {
|
|
45
|
+
return undefined
|
|
46
|
+
}
|
|
47
|
+
if (UNSAFE_PATH_CHARACTERS.test(bin) || bin.includes(delimiter)) {
|
|
48
|
+
return { refused: 'the folder name holds a character a shell could read as more than a path' }
|
|
49
|
+
}
|
|
50
|
+
let entries: import('node:fs').Dirent[]
|
|
51
|
+
try {
|
|
52
|
+
entries = readdirSync(bin, { withFileTypes: true })
|
|
53
|
+
} catch {
|
|
54
|
+
return undefined
|
|
55
|
+
}
|
|
56
|
+
for (const entry of entries) {
|
|
57
|
+
if (!entry.isSymbolicLink()) continue
|
|
58
|
+
let target: string
|
|
59
|
+
try {
|
|
60
|
+
target = realpathSync(join(bin, entry.name))
|
|
61
|
+
} catch {
|
|
62
|
+
// A dangling link runs nothing now; refusing it keeps the rule simple.
|
|
63
|
+
return { refused: `bin/${entry.name} is a link that does not resolve` }
|
|
64
|
+
}
|
|
65
|
+
if (!inside(realRoot, target)) {
|
|
66
|
+
return { refused: `bin/${entry.name} is a link that leaves the plugin folder` }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { dir: bin }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Add folders to the END of an environment's PATH, so a program already on
|
|
74
|
+
* PATH (a system command a permission rule or the read-only list names) always
|
|
75
|
+
* wins over a plugin's program of the same name. Folders already on PATH are
|
|
76
|
+
* not added twice. An environment without PATH is returned unchanged.
|
|
77
|
+
*/
|
|
78
|
+
export function appendDirsToPath(
|
|
79
|
+
env: Record<string, string>,
|
|
80
|
+
dirs: readonly string[],
|
|
81
|
+
platform: NodeJS.Platform = process.platform,
|
|
82
|
+
): Record<string, string> {
|
|
83
|
+
if (dirs.length === 0) return env
|
|
84
|
+
const entry = readEnvironmentEntry(env, 'PATH', platform)
|
|
85
|
+
if (!entry) return env
|
|
86
|
+
const [name, value] = entry
|
|
87
|
+
const sep = platform === 'win32' ? ';' : ':'
|
|
88
|
+
const present = new Set(value.split(sep))
|
|
89
|
+
const added = dirs.filter((dir) => !dir.includes(sep) && !present.has(dir))
|
|
90
|
+
if (added.length === 0) return env
|
|
91
|
+
setEnvironmentEntry(env, name, [value, ...added].filter(Boolean).join(sep), platform)
|
|
92
|
+
return env
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
type BinSource = { enabledBinDirs(): readonly string[] }
|
|
96
|
+
const binSources = new Set<WeakRef<BinSource>>()
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Record where the enabled plugins' bin folders come from, so a check that has
|
|
100
|
+
* no turn context (the read-only command list) can ask whether a plugin
|
|
101
|
+
* supplies a program. Held weakly: a manager that is dropped drops out.
|
|
102
|
+
*/
|
|
103
|
+
export function registerPluginBinSource(source: BinSource): void {
|
|
104
|
+
binSources.add(new WeakRef(source))
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Whether an enabled plugin's bin folder holds a program called `name`. The
|
|
109
|
+
* folders sit at the end of PATH, so on a machine that lacks a command the
|
|
110
|
+
* read-only list names (`rg`, `tree`, `jq`) the plugin's file is what runs;
|
|
111
|
+
* such a name must not be treated as read-only.
|
|
112
|
+
*/
|
|
113
|
+
export function pluginSuppliesProgram(
|
|
114
|
+
name: string,
|
|
115
|
+
platform: NodeJS.Platform = process.platform,
|
|
116
|
+
): boolean {
|
|
117
|
+
if (binSources.size === 0) return false
|
|
118
|
+
for (const ref of [...binSources]) {
|
|
119
|
+
const source = ref.deref()
|
|
120
|
+
if (source === undefined) {
|
|
121
|
+
binSources.delete(ref)
|
|
122
|
+
continue
|
|
123
|
+
}
|
|
124
|
+
let dirs: readonly string[]
|
|
125
|
+
try {
|
|
126
|
+
dirs = source.enabledBinDirs()
|
|
127
|
+
} catch {
|
|
128
|
+
// A source that cannot say is not trusted to say "none".
|
|
129
|
+
return true
|
|
130
|
+
}
|
|
131
|
+
for (const dir of dirs) {
|
|
132
|
+
try {
|
|
133
|
+
if (platform === 'win32') {
|
|
134
|
+
const want = name.toLowerCase()
|
|
135
|
+
for (const file of readdirSync(dir)) {
|
|
136
|
+
const lower = file.toLowerCase()
|
|
137
|
+
const dot = lower.lastIndexOf('.')
|
|
138
|
+
if (lower === want || (dot > 0 && lower.slice(0, dot) === want)) return true
|
|
139
|
+
}
|
|
140
|
+
} else if (existsSync(join(dir, name))) {
|
|
141
|
+
return true
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
return true
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return false
|
|
149
|
+
}
|
|
@@ -1080,7 +1080,7 @@ async function readMerged(
|
|
|
1080
1080
|
code: 'component-unsupported',
|
|
1081
1081
|
field: dir,
|
|
1082
1082
|
path: dir,
|
|
1083
|
-
message: `${dir}/ (${count}) is not used by Namzu
|
|
1083
|
+
message: `${dir}/ (${count}) is not used by Namzu.`,
|
|
1084
1084
|
})
|
|
1085
1085
|
}
|
|
1086
1086
|
}
|
|
@@ -831,6 +831,66 @@ interface Edit {
|
|
|
831
831
|
* file's neighbours, exports become assignments, and nothing else changes, so a
|
|
832
832
|
* line number in an error is the line in the author's file.
|
|
833
833
|
*/
|
|
834
|
+
/** The wrapper the worker compiles around a file's text, character for character. */
|
|
835
|
+
export const WORKER_WRAPPER_HEAD = '(function (__exports, __import) {"use strict";'
|
|
836
|
+
export const WORKER_WRAPPER_TAIL = '\n})'
|
|
837
|
+
|
|
838
|
+
type Spans = { type: string; start: number; end: number }[]
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* The tokens the parser itself consumed, not the standalone tokenizer's: the
|
|
842
|
+
* tokenizer guesses whether `/` opens a regular expression from the token
|
|
843
|
+
* before it, and the parser reads it again where the grammar says an expression
|
|
844
|
+
* starts, so the two disagree after `)`, `}` and a few keywords. Throws when the
|
|
845
|
+
* text does not parse as the given kind.
|
|
846
|
+
*/
|
|
847
|
+
function tokenSpans(text: string, sourceType: 'module' | 'script'): Spans {
|
|
848
|
+
const spans: Spans = []
|
|
849
|
+
acorn.parse(text, {
|
|
850
|
+
ecmaVersion: 'latest',
|
|
851
|
+
sourceType,
|
|
852
|
+
onToken: (token) => {
|
|
853
|
+
spans.push({ type: token.type.label, start: token.start, end: token.end })
|
|
854
|
+
},
|
|
855
|
+
})
|
|
856
|
+
return spans
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* The scan parses a module; the worker compiles a script, and a script reads
|
|
861
|
+
* `<!--` and a line-start `-->` as comments. Read the exact text the worker
|
|
862
|
+
* compiles both ways: where the two token lists differ, something is code to
|
|
863
|
+
* one reader and a comment to the other. Returns the line of the first
|
|
864
|
+
* difference, 0 for none, and -1 when the text cannot be tokenized.
|
|
865
|
+
*/
|
|
866
|
+
export function htmlCommentDivergence(source: string): number {
|
|
867
|
+
const text = WORKER_WRAPPER_HEAD + source + WORKER_WRAPPER_TAIL
|
|
868
|
+
let asModule: Spans
|
|
869
|
+
let asScript: Spans
|
|
870
|
+
try {
|
|
871
|
+
asModule = tokenSpans(text, 'module')
|
|
872
|
+
asScript = tokenSpans(text, 'script')
|
|
873
|
+
} catch {
|
|
874
|
+
return -1
|
|
875
|
+
}
|
|
876
|
+
const length = Math.min(asModule.length, asScript.length)
|
|
877
|
+
let at = -1
|
|
878
|
+
for (let i = 0; i < length; i++) {
|
|
879
|
+
const a = asModule[i] as Spans[number]
|
|
880
|
+
const b = asScript[i] as Spans[number]
|
|
881
|
+
if (a.type !== b.type || a.start !== b.start || a.end !== b.end) {
|
|
882
|
+
at = Math.min(a.start, b.start)
|
|
883
|
+
break
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
if (at === -1 && asModule.length === asScript.length) return 0
|
|
887
|
+
if (at === -1) {
|
|
888
|
+
const longer = asModule.length > asScript.length ? asModule : asScript
|
|
889
|
+
at = (longer[length] as Spans[number]).start
|
|
890
|
+
}
|
|
891
|
+
return text.slice(0, at).split('\n').length
|
|
892
|
+
}
|
|
893
|
+
|
|
834
894
|
function rewrite(code: string, ast: AnyNode, resolved: ReadonlyMap<string, string>): string {
|
|
835
895
|
const edits: Edit[] = []
|
|
836
896
|
const prelude: string[] = []
|
|
@@ -979,9 +1039,21 @@ export function scanHookModule(root: string, entry: string): HookModuleScan {
|
|
|
979
1039
|
const target = resolveImport(state, rel, item.specifier)
|
|
980
1040
|
if (target !== undefined) resolved.set(item.specifier, target)
|
|
981
1041
|
}
|
|
982
|
-
|
|
1042
|
+
const text = rewrite(analysis.code, analysis.ast, resolved)
|
|
1043
|
+
const divergence = htmlCommentDivergence(text)
|
|
1044
|
+
if (divergence !== 0) {
|
|
1045
|
+
refuse(
|
|
1046
|
+
state,
|
|
1047
|
+
rel,
|
|
1048
|
+
Math.max(divergence, 1),
|
|
1049
|
+
divergence < 0
|
|
1050
|
+
? `${rel}: the text cannot be read the way it will run.`
|
|
1051
|
+
: `${rel}: a <!-- or --> that the module reads as code and the runtime reads as a comment (line ${divergence}).`,
|
|
1052
|
+
)
|
|
1053
|
+
}
|
|
1054
|
+
files[rel] = text
|
|
983
1055
|
}
|
|
984
|
-
program = { entry: entryRel, files }
|
|
1056
|
+
if (state.refusals.length === 0) program = { entry: entryRel, files }
|
|
985
1057
|
}
|
|
986
1058
|
const calls = state.calls.map((call, index) => {
|
|
987
1059
|
const at = state.callStarts[index]
|
|
@@ -603,6 +603,54 @@ for (const key of ['prepareStackTrace', 'stackTraceLimit']) {
|
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
|
|
606
|
+
// A rejected import() hands the module an error the engine made in the worker's realm. The scan refuses
|
|
607
|
+
// import() in a module, so it is a second line of defence: freeze that realm's shared prototypes, so
|
|
608
|
+
// nothing set on an error's chain reaches the next dispatch.
|
|
609
|
+
{
|
|
610
|
+
const shared = [
|
|
611
|
+
Object,
|
|
612
|
+
Function,
|
|
613
|
+
Array,
|
|
614
|
+
Error,
|
|
615
|
+
TypeError,
|
|
616
|
+
RangeError,
|
|
617
|
+
SyntaxError,
|
|
618
|
+
ReferenceError,
|
|
619
|
+
EvalError,
|
|
620
|
+
URIError,
|
|
621
|
+
Promise,
|
|
622
|
+
Symbol,
|
|
623
|
+
Object.getPrototypeOf(Uint8Array),
|
|
624
|
+
]
|
|
625
|
+
for (const item of shared) {
|
|
626
|
+
for (const target of [item, item.prototype]) {
|
|
627
|
+
try {
|
|
628
|
+
if (target !== undefined && target !== null) Object.freeze(target)
|
|
629
|
+
} catch (error) {
|
|
630
|
+
// Already fixed, or not ours to fix: nothing more to do.
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// The error the engine makes for a refused import() has a class prototype of its own, below the ones above.
|
|
637
|
+
// Make one in a throwaway context and freeze its whole chain; the rejection settles before any message.
|
|
638
|
+
{
|
|
639
|
+
const scratch = vm.createContext(Object.create(null))
|
|
640
|
+
new vm.Script('import("node:fs")').runInContext(scratch).then(
|
|
641
|
+
() => {},
|
|
642
|
+
(error) => {
|
|
643
|
+
for (let at = error; at !== null && at !== undefined; at = Object.getPrototypeOf(at)) {
|
|
644
|
+
try {
|
|
645
|
+
Object.freeze(at)
|
|
646
|
+
} catch (inner) {
|
|
647
|
+
// Not ours to fix: nothing more to do.
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
)
|
|
652
|
+
}
|
|
653
|
+
|
|
606
654
|
const send = (json) => {
|
|
607
655
|
try {
|
|
608
656
|
parentPort.postMessage(JSON.parse(json))
|
|
@@ -618,10 +666,13 @@ const messageOf = (error) =>
|
|
|
618
666
|
|
|
619
667
|
// Source text in, a function of the context out; a failure comes back as its message, never as an object.
|
|
620
668
|
let context
|
|
669
|
+
let refuseImport
|
|
621
670
|
const evaluate = (rel, source) => {
|
|
622
671
|
try {
|
|
623
672
|
const script = new vm.Script('(function (__exports, __import) {"use strict";' + source + '\n})', {
|
|
624
673
|
filename: 'plugin:' + rel,
|
|
674
|
+
// Made inside the context, so what an import() would call is not a worker-realm function.
|
|
675
|
+
importModuleDynamically: refuseImport,
|
|
625
676
|
})
|
|
626
677
|
return script.runInContext(context)
|
|
627
678
|
} catch (error) {
|
|
@@ -648,6 +699,11 @@ function start() {
|
|
|
648
699
|
codeGeneration: { strings: false, wasm: false },
|
|
649
700
|
})
|
|
650
701
|
prepareContext()
|
|
702
|
+
refuseImport = vm.runInContext(
|
|
703
|
+
"'use strict'; (function () { throw new Error('import() is not available in a hooks module') })",
|
|
704
|
+
context,
|
|
705
|
+
{ filename: 'plugin:import' },
|
|
706
|
+
)
|
|
651
707
|
receive = vm.runInContext(BOOTSTRAP, context, { filename: 'plugin:bootstrap' })(send, evaluate)
|
|
652
708
|
freezeIntrinsics()
|
|
653
709
|
}
|
package/src/plugin/lifecycle.ts
CHANGED
|
@@ -45,6 +45,7 @@ import { toErrorMessage } from '../utils/error.js'
|
|
|
45
45
|
import { generatePluginId } from '../utils/id.js'
|
|
46
46
|
import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
|
|
47
47
|
import type { Logger } from '../utils/logger.js'
|
|
48
|
+
import { registerPluginBinSource, resolvePluginBinDirectory } from './bin-path.js'
|
|
48
49
|
import type { LayoutFinding } from './common-layout/types.js'
|
|
49
50
|
import { type DefinedPlugin, definePlugin } from './define.js'
|
|
50
51
|
import { assertEnableable, loadPluginManifestWithFindings } from './loader.js'
|
|
@@ -75,6 +76,8 @@ interface PluginAdmission {
|
|
|
75
76
|
|
|
76
77
|
const DEFAULT_PLUGIN_MCP_CONNECT_TIMEOUT_MS = 10_000
|
|
77
78
|
const PLUGIN_MCP_CLOSE_TIMEOUT_MS = 5_000
|
|
79
|
+
/** Sessions whose post-compaction hook text is kept at once; older ones are let go. */
|
|
80
|
+
const MAX_COMPACTION_CONTEXT_SESSIONS = 16
|
|
78
81
|
|
|
79
82
|
/** One deadline across handshake and all initial discovery requests. */
|
|
80
83
|
async function beforePluginMcpDeadline<T>(
|
|
@@ -403,6 +406,7 @@ export class PluginLifecycleManager {
|
|
|
403
406
|
private readonly skillRegistry: SkillRegistry | undefined
|
|
404
407
|
|
|
405
408
|
constructor(config: PluginLifecycleManagerConfig) {
|
|
409
|
+
registerPluginBinSource(this)
|
|
406
410
|
this.pluginRegistry = config.pluginRegistry
|
|
407
411
|
this.skillRegistry = config.skillRegistry
|
|
408
412
|
this.scopeRoots = Object.freeze({ ...config.scopeRoots })
|
|
@@ -604,6 +608,39 @@ export class PluginLifecycleManager {
|
|
|
604
608
|
}
|
|
605
609
|
}
|
|
606
610
|
|
|
611
|
+
private readonly compactionContext = new Map<string, string>()
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Keep what the `session_start` hooks said after a compaction pass (source
|
|
615
|
+
* `compact`) of one session, for the host to put in front of the model on
|
|
616
|
+
* that session's next turn. Keyed by session, so a sub-agent that shares
|
|
617
|
+
* this manager and compacts does not hand its text to its parent. A later
|
|
618
|
+
* pass of the same session replaces it.
|
|
619
|
+
*/
|
|
620
|
+
noteCompactionContext(sessionId: string, text: string): void {
|
|
621
|
+
// Only the host's own session ever takes its text; a child session's entry
|
|
622
|
+
// is never taken, so the map is bounded and the oldest entry leaves first.
|
|
623
|
+
this.compactionContext.delete(sessionId)
|
|
624
|
+
this.compactionContext.set(sessionId, text)
|
|
625
|
+
while (this.compactionContext.size > MAX_COMPACTION_CONTEXT_SESSIONS) {
|
|
626
|
+
const oldest = this.compactionContext.keys().next().value
|
|
627
|
+
if (oldest === undefined) break
|
|
628
|
+
this.compactionContext.delete(oldest)
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/** The text {@link noteCompactionContext} kept for a session, handed over once. */
|
|
633
|
+
takeCompactionContext(sessionId: string): string | undefined {
|
|
634
|
+
const text = this.compactionContext.get(sessionId)
|
|
635
|
+
this.compactionContext.delete(sessionId)
|
|
636
|
+
return text
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
/** Drop what a session kept, for a conversation that ended before its next turn. */
|
|
640
|
+
dropCompactionContext(sessionId: string): void {
|
|
641
|
+
this.compactionContext.delete(sessionId)
|
|
642
|
+
}
|
|
643
|
+
|
|
607
644
|
private notifyHooksChanged(): void {
|
|
608
645
|
for (const listener of [...this.hooksChangedListeners]) {
|
|
609
646
|
try {
|
|
@@ -1295,6 +1332,36 @@ export class PluginLifecycleManager {
|
|
|
1295
1332
|
}
|
|
1296
1333
|
}
|
|
1297
1334
|
|
|
1335
|
+
/**
|
|
1336
|
+
* The `bin/` folders of the plugins that are enabled right now, for the end
|
|
1337
|
+
* of a shell command's PATH. Read each call, so turning a plugin off takes
|
|
1338
|
+
* its programs off the next command. A folder that is not safe (see
|
|
1339
|
+
* {@link resolvePluginBinDirectory}) is left out and said once per plugin.
|
|
1340
|
+
*/
|
|
1341
|
+
enabledBinDirs(): readonly string[] {
|
|
1342
|
+
const dirs: string[] = []
|
|
1343
|
+
for (const pluginId of this.pluginContributions.keys()) {
|
|
1344
|
+
const admission = this.pluginAdmissions.get(pluginId)
|
|
1345
|
+
if (!admission || admission.inCode) continue
|
|
1346
|
+
const found = resolvePluginBinDirectory(admission.rootDir)
|
|
1347
|
+
if (found === undefined) continue
|
|
1348
|
+
if (found.dir === undefined) {
|
|
1349
|
+
if (!this.binRefusalsSaid.has(pluginId)) {
|
|
1350
|
+
this.binRefusalsSaid.add(pluginId)
|
|
1351
|
+
this.log.warn('Plugin bin/ left off PATH', {
|
|
1352
|
+
'namzu.plugin.name': admission.manifest.name,
|
|
1353
|
+
'exception.message': found.refused,
|
|
1354
|
+
})
|
|
1355
|
+
}
|
|
1356
|
+
continue
|
|
1357
|
+
}
|
|
1358
|
+
dirs.push(found.dir)
|
|
1359
|
+
}
|
|
1360
|
+
return dirs
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
private readonly binRefusalsSaid = new Set<PluginId>()
|
|
1364
|
+
|
|
1298
1365
|
disable(pluginId: PluginId): Promise<void> {
|
|
1299
1366
|
return this.serializeLifecycle(pluginId, () => this.disableOwned(pluginId))
|
|
1300
1367
|
}
|
package/src/plugin/shell-hook.ts
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* same facts as `NAMZU_HOOK_EVENT`, `NAMZU_SESSION_ID`, `NAMZU_TURN_ID`,
|
|
25
25
|
* `NAMZU_TOOL_NAME` and, when the input names a file, `NAMZU_TOOL_PATH`;
|
|
26
26
|
* `NAMZU_PROJECT_DIR` is the folder the session was started for.
|
|
27
|
-
* `session_start` also sends `source` (`startup`, `resume` or `
|
|
27
|
+
* `session_start` also sends `source` (`startup`, `resume`, `clear`, `fork` or `compact`) and
|
|
28
28
|
* `session_end` `reason` (`exit`, `replaced` or `clear`).
|
|
29
29
|
*
|
|
30
30
|
* `session_start` and `session_end` run outside any turn, so they carry no
|
|
@@ -121,6 +121,7 @@ import {
|
|
|
121
121
|
} from '../authorization/skill-grant.js'
|
|
122
122
|
import { withSessionChildMarker } from '../process/session-child.js'
|
|
123
123
|
import { spawnHostShell } from '../tools/command-shell.js'
|
|
124
|
+
import { withSafeGitConfig } from '../tools/git-config-env.js'
|
|
124
125
|
import type { PluginId } from '../types/ids/index.js'
|
|
125
126
|
import type {
|
|
126
127
|
PluginCompactionInfo,
|
|
@@ -376,6 +377,7 @@ const WRITTEN_TOOL_NAMES: Readonly<Record<string, string>> = Object.freeze({
|
|
|
376
377
|
write: 'Write',
|
|
377
378
|
edit: 'Edit',
|
|
378
379
|
multiedit: 'MultiEdit',
|
|
380
|
+
notebookedit: 'NotebookEdit',
|
|
379
381
|
bash: 'Bash',
|
|
380
382
|
grep: 'Grep',
|
|
381
383
|
glob: 'Glob',
|
|
@@ -1087,13 +1089,14 @@ export function runShellHook(
|
|
|
1087
1089
|
? // The exec form: no shell reads `command` or any argument.
|
|
1088
1090
|
spawn(placed.command, [...placed.args], {
|
|
1089
1091
|
cwd: input.cwd,
|
|
1090
|
-
env: withSessionChildMarker(env),
|
|
1092
|
+
env: withSessionChildMarker(withSafeGitConfig(env)),
|
|
1091
1093
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1092
1094
|
detached,
|
|
1093
1095
|
})
|
|
1094
1096
|
: spawnHostShell(placed.command, {
|
|
1095
1097
|
cwd: input.cwd,
|
|
1096
|
-
|
|
1098
|
+
// A hook's own `git status` in a planted folder must not run its program.
|
|
1099
|
+
env: withSafeGitConfig(env),
|
|
1097
1100
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1098
1101
|
detached,
|
|
1099
1102
|
// A hook has always run under `sh`, whatever shell the `bash` tool
|
|
@@ -1262,7 +1265,7 @@ function readRewrittenInput(
|
|
|
1262
1265
|
function pathOf(toolInput: unknown): string | undefined {
|
|
1263
1266
|
if (toolInput === null || typeof toolInput !== 'object') return undefined
|
|
1264
1267
|
const record = toolInput as Record<string, unknown>
|
|
1265
|
-
for (const key of ['path', 'file_path', 'filePath']) {
|
|
1268
|
+
for (const key of ['path', 'file_path', 'filePath', 'notebook_path']) {
|
|
1266
1269
|
const value = record[key]
|
|
1267
1270
|
if (typeof value === 'string' && value.length > 0) return value
|
|
1268
1271
|
}
|
|
@@ -1323,6 +1326,8 @@ interface ShellHookReading {
|
|
|
1323
1326
|
watchPaths?: readonly string[]
|
|
1324
1327
|
/** On `elicitation` and `elicitation_result`: the answer the hook gave. */
|
|
1325
1328
|
elicitation?: PluginElicitationAnswer
|
|
1329
|
+
/** On `permission_denied`: the hook said the call may be tried again. */
|
|
1330
|
+
retry?: boolean
|
|
1326
1331
|
/** Why the JSON was set aside, when it was. */
|
|
1327
1332
|
invalid?: string
|
|
1328
1333
|
}
|
|
@@ -1495,6 +1500,12 @@ function readShellHookJson(
|
|
|
1495
1500
|
}
|
|
1496
1501
|
const additional = optionalString('additionalContext', specific)
|
|
1497
1502
|
if (additional && additional.trim().length > 0) reading.context = additional.trim()
|
|
1503
|
+
if (event === 'permission_denied' && specific.retry !== undefined) {
|
|
1504
|
+
if (typeof specific.retry !== 'boolean') {
|
|
1505
|
+
return { invalid: 'hookSpecificOutput: `retry` must be true or false' }
|
|
1506
|
+
}
|
|
1507
|
+
if (specific.retry) reading.retry = true
|
|
1508
|
+
}
|
|
1498
1509
|
|
|
1499
1510
|
if (event === 'elicitation' || event === 'elicitation_result') {
|
|
1500
1511
|
const action = specific.action
|
|
@@ -1997,6 +2008,14 @@ export function shellHookVerdict(
|
|
|
1997
2008
|
...(reading.permission ? { permission: reading.permission } : {}),
|
|
1998
2009
|
}
|
|
1999
2010
|
}
|
|
2011
|
+
case 'permission_denied':
|
|
2012
|
+
// The refusal stands; the hook can only say the call may be tried again.
|
|
2013
|
+
return {
|
|
2014
|
+
action: 'continue',
|
|
2015
|
+
...(reading.retry ? { retryable: true } : {}),
|
|
2016
|
+
...(reading.halt ? { halt: reading.halt } : {}),
|
|
2017
|
+
...(reading.notice ? { notice: reading.notice } : {}),
|
|
2018
|
+
}
|
|
2000
2019
|
default:
|
|
2001
2020
|
// Nothing here can be changed by a verdict, but a stop request still
|
|
2002
2021
|
// can end the turn, and a warning still reaches the operator.
|
package/src/public-runtime.ts
CHANGED
|
@@ -257,6 +257,8 @@ export {
|
|
|
257
257
|
// can assert its variables are ones the host-bash scrub will withhold —
|
|
258
258
|
// the check that stops the two tables drifting apart.
|
|
259
259
|
export { isCredentialEnvKey } from './constants/credential-env-keys.js'
|
|
260
|
+
// Names the host wrote on purpose (the user's settings `env` block): the host-bash scrub keeps them.
|
|
261
|
+
export { setDeliberateEnvKeys } from './tools/env-scrub.js'
|
|
260
262
|
|
|
261
263
|
export {
|
|
262
264
|
createToolPresenter,
|
|
@@ -309,6 +311,7 @@ export {
|
|
|
309
311
|
} from './utils/shell-compress.js'
|
|
310
312
|
export { createChildAbortController } from './utils/abort.js'
|
|
311
313
|
export { memoizeAsync } from './utils/memoize.js'
|
|
314
|
+
export { plainTerminalText } from './utils/plain-terminal-text.js'
|
|
312
315
|
export {
|
|
313
316
|
NAMZU_TMPDIR_ENV,
|
|
314
317
|
type PrivateTempRootOptions,
|
|
@@ -407,6 +410,7 @@ export {
|
|
|
407
410
|
SteeringBinding,
|
|
408
411
|
attachSteering,
|
|
409
412
|
capMonitorNotifications,
|
|
413
|
+
formatJobExitNotice,
|
|
410
414
|
formatMonitorEnd,
|
|
411
415
|
formatMonitorEvent,
|
|
412
416
|
formatSteeringNote,
|
|
@@ -590,6 +594,11 @@ export {
|
|
|
590
594
|
shapeShellOutput,
|
|
591
595
|
splitShellToolOutput,
|
|
592
596
|
substituteEscaped,
|
|
597
|
+
SKILL_ARGUMENTS_LINE_LABEL,
|
|
598
|
+
SKILL_ARGUMENTS_SHELL_READ_MAX_CHARS,
|
|
599
|
+
fillArguments,
|
|
600
|
+
splitSkillArguments,
|
|
601
|
+
takesSkillArguments,
|
|
593
602
|
PRE_SKILL_SHELL_COMMAND_EVENT,
|
|
594
603
|
SKILL_SHELL_TOOL_NAME,
|
|
595
604
|
createPreToolUseShellHook,
|
|
@@ -607,6 +616,9 @@ export type {
|
|
|
607
616
|
InlineShellMarker,
|
|
608
617
|
InlineShellOptions,
|
|
609
618
|
InlineShellOutcome,
|
|
619
|
+
FillArgumentsOptions,
|
|
620
|
+
PlaceholderRead,
|
|
621
|
+
PlaceholderReader,
|
|
610
622
|
PreToolUseShellHookOptions,
|
|
611
623
|
SkillShellHookOptions,
|
|
612
624
|
ToolSkillShellHostOptions,
|
|
@@ -952,10 +964,16 @@ export {
|
|
|
952
964
|
nextFireTime,
|
|
953
965
|
parseCronExpression,
|
|
954
966
|
parseDuration,
|
|
967
|
+
parseScheduleExpiry,
|
|
955
968
|
parseScheduleSpec,
|
|
969
|
+
parseWatchSpec,
|
|
956
970
|
previousFireTime,
|
|
957
971
|
SCHEDULE_CATCH_UP_WINDOW_MS,
|
|
958
972
|
SCHEDULE_LATE_GRACE_MS,
|
|
973
|
+
SCHEDULE_WATCH_DEFAULT_INTERVAL_MS,
|
|
974
|
+
SCHEDULE_WATCH_DEFAULT_MAX_EVENTS_PER_HOUR,
|
|
975
|
+
SCHEDULE_WATCH_MAX_EVENTS_PER_HOUR,
|
|
976
|
+
SCHEDULE_WATCH_MIN_INTERVAL_MS,
|
|
959
977
|
ScheduleValidationError,
|
|
960
978
|
upcomingFireTimes,
|
|
961
979
|
validateTimeZone,
|
|
@@ -1503,6 +1521,8 @@ export {
|
|
|
1503
1521
|
createUserMessage,
|
|
1504
1522
|
isProjectInstructionMessageSource,
|
|
1505
1523
|
isRuntimeContextMessageSource,
|
|
1524
|
+
isRuntimeContextOrigin,
|
|
1525
|
+
RUNTIME_CONTEXT_ORIGIN_KINDS,
|
|
1506
1526
|
isModelContentOmission,
|
|
1507
1527
|
MAX_PROJECT_INSTRUCTION_SOURCE_FILES,
|
|
1508
1528
|
RUNTIME_CONTEXT_MESSAGE_KINDS,
|
|
@@ -2181,6 +2201,7 @@ export {
|
|
|
2181
2201
|
OUTSTANDING_EXPIRY_MS,
|
|
2182
2202
|
PEER_PROTOCOL_VERSION,
|
|
2183
2203
|
PEER_RECORD_VERSION,
|
|
2204
|
+
PEER_AGENTS_MAX,
|
|
2184
2205
|
PEER_TRAIL_MAX,
|
|
2185
2206
|
PeerAddressError,
|
|
2186
2207
|
PeerClient,
|
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,
|
|
@@ -183,6 +203,17 @@ export type { RunCodeToolOptions } from './tools/builtins/run-code.js'
|
|
|
183
203
|
export { LsTool } from './tools/builtins/ls.js'
|
|
184
204
|
export { SearchToolsTool } from './tools/builtins/search-tools.js'
|
|
185
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'
|
|
186
217
|
export { VerifyOutputsTool } from './tools/builtins/verify-outputs.js'
|
|
187
218
|
export {
|
|
188
219
|
ViewImageTool,
|