@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
|
@@ -211,6 +211,11 @@ export interface OpenSessionIndexOptions {
|
|
|
211
211
|
readonly path?: string
|
|
212
212
|
/** `auto` (the default) uses SQLite when `node:sqlite` loads, the scan index otherwise. */
|
|
213
213
|
readonly backend?: 'auto' | 'sqlite' | 'scan'
|
|
214
|
+
/**
|
|
215
|
+
* SQLite only: return once the index is open and current in version, and
|
|
216
|
+
* catch up with the logs in the background; every read waits for it.
|
|
217
|
+
*/
|
|
218
|
+
readonly syncInBackground?: boolean
|
|
214
219
|
}
|
|
215
220
|
|
|
216
221
|
/**
|
|
@@ -225,7 +230,11 @@ export async function openSessionIndex(
|
|
|
225
230
|
if (backend === 'scan' || (backend === 'auto' && !sqliteAvailable())) {
|
|
226
231
|
return ScanSessionIndex.load(home)
|
|
227
232
|
}
|
|
228
|
-
return SqliteSessionIndex.open({
|
|
233
|
+
return SqliteSessionIndex.open({
|
|
234
|
+
home,
|
|
235
|
+
path: options.path ?? join(home, 'index.sqlite'),
|
|
236
|
+
...(options.syncInBackground === true ? { syncInBackground: true } : {}),
|
|
237
|
+
})
|
|
229
238
|
}
|
|
230
239
|
|
|
231
240
|
export { EvidenceQueryError, evidenceMatcher, evidenceTexts, ftsMatchExpression } from './fts.js'
|
|
@@ -204,7 +204,46 @@ export async function discoverSessionLogs(home: string): Promise<SessionLogLocat
|
|
|
204
204
|
await collectLogs(join(projects, entry.name), entry.name, found, 0)
|
|
205
205
|
}
|
|
206
206
|
found.sort((a, b) => (a.logPath < b.logPath ? -1 : a.logPath > b.logPath ? 1 : 0))
|
|
207
|
-
return found
|
|
207
|
+
return await onePerSession(found)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The index keys a row by session id, so two logs with one id (a session
|
|
212
|
+
* folder copied into another project) would each overwrite the other's row on
|
|
213
|
+
* every sync and never settle. One log speaks for an id: the one written last,
|
|
214
|
+
* the first by path on a tie. A pure function of the files, so a rebuild and an
|
|
215
|
+
* incremental sync agree and a second sync of an unchanged home reads nothing;
|
|
216
|
+
* the copy that is written to next becomes the one listed.
|
|
217
|
+
*/
|
|
218
|
+
async function onePerSession(found: SessionLogLocation[]): Promise<SessionLogLocation[]> {
|
|
219
|
+
const byId = new Map<string, SessionLogLocation[]>()
|
|
220
|
+
for (const log of found) {
|
|
221
|
+
const group = byId.get(log.sessionId)
|
|
222
|
+
if (group === undefined) byId.set(log.sessionId, [log])
|
|
223
|
+
else group.push(log)
|
|
224
|
+
}
|
|
225
|
+
if (byId.size === found.length) return found
|
|
226
|
+
const chosen = new Set<SessionLogLocation>()
|
|
227
|
+
for (const group of byId.values()) {
|
|
228
|
+
let best = group[0] as SessionLogLocation
|
|
229
|
+
if (group.length > 1) {
|
|
230
|
+
let bestWritten = -1
|
|
231
|
+
for (const log of group) {
|
|
232
|
+
let written = -1
|
|
233
|
+
try {
|
|
234
|
+
written = (await stat(log.logPath)).mtimeMs
|
|
235
|
+
} catch {
|
|
236
|
+
// Gone since the walk; it loses to any log that is still there.
|
|
237
|
+
}
|
|
238
|
+
if (written > bestWritten) {
|
|
239
|
+
best = log
|
|
240
|
+
bestWritten = written
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
chosen.add(best)
|
|
245
|
+
}
|
|
246
|
+
return found.filter((log) => chosen.has(log))
|
|
208
247
|
}
|
|
209
248
|
|
|
210
249
|
// ─── rows ──────────────────────────────────────────────────────────────────
|
|
@@ -701,12 +740,37 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
701
740
|
abstract searchEvidence(options: EvidenceSearchOptions): Promise<EvidenceHit[]>
|
|
702
741
|
abstract close(): void
|
|
703
742
|
|
|
743
|
+
/** Resolves once the index reflects the logs. A backend that syncs after opening overrides it. */
|
|
744
|
+
protected settled(): Promise<void> {
|
|
745
|
+
return Promise.resolve()
|
|
746
|
+
}
|
|
747
|
+
|
|
704
748
|
async getSession(sessionId: SessionId): Promise<IndexedSession | undefined> {
|
|
749
|
+
await this.settled()
|
|
750
|
+
return this.sessionNow(sessionId)
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* {@link getSession} without waiting for the catch-up. Anything the catch-up
|
|
755
|
+
* itself calls must read this way: waiting there would wait on itself.
|
|
756
|
+
*/
|
|
757
|
+
protected sessionNow(sessionId: SessionId): IndexedSession | undefined {
|
|
705
758
|
const row = this.readSession(sessionId)
|
|
706
759
|
return row === undefined ? undefined : sessionView(row)
|
|
707
760
|
}
|
|
708
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Writes wait for a background catch-up as reads do: a catch-up that reads a
|
|
764
|
+
* log while its first record is being written finds no intact record and
|
|
765
|
+
* clears the row, so a write that ran beside it could be undone.
|
|
766
|
+
*/
|
|
709
767
|
async indexSession(input: SessionLogInput): Promise<IndexedSession | undefined> {
|
|
768
|
+
await this.settled()
|
|
769
|
+
return this.indexSessionNow(input)
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/** {@link indexSession} without waiting for the catch-up; the catch-up's own path. */
|
|
773
|
+
protected async indexSessionNow(input: SessionLogInput): Promise<IndexedSession | undefined> {
|
|
710
774
|
const location = { slug: input.slug, logPath: input.logPath }
|
|
711
775
|
let batch: IndexableRecord[] = []
|
|
712
776
|
let first = true
|
|
@@ -789,12 +853,12 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
789
853
|
batch.push(item)
|
|
790
854
|
if (batch.length >= RECORDS_PER_TRANSACTION && !flush()) {
|
|
791
855
|
// Another writer advanced this session past us; its rows are the same records'.
|
|
792
|
-
return this.
|
|
856
|
+
return this.sessionNow(sessionId)
|
|
793
857
|
}
|
|
794
858
|
}
|
|
795
859
|
// A final batch that stands down leaves the other writer's rows, which are the answer.
|
|
796
860
|
flush()
|
|
797
|
-
return sessionId === undefined ? undefined : this.
|
|
861
|
+
return sessionId === undefined ? undefined : this.sessionNow(sessionId)
|
|
798
862
|
}
|
|
799
863
|
|
|
800
864
|
async staleness(location: SessionLogLocation): Promise<SessionStaleness> {
|
|
@@ -818,6 +882,12 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
818
882
|
}
|
|
819
883
|
|
|
820
884
|
async refresh(location: SessionLogLocation): Promise<SessionStaleness> {
|
|
885
|
+
await this.settled()
|
|
886
|
+
return this.refreshNow(location)
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/** {@link refresh} without waiting for the catch-up; the catch-up's own path. */
|
|
890
|
+
protected async refreshNow(location: SessionLogLocation): Promise<SessionStaleness> {
|
|
821
891
|
const state = await this.staleness(location)
|
|
822
892
|
if (state === 'fresh') return state
|
|
823
893
|
if (state === 'missing') {
|
|
@@ -829,7 +899,7 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
829
899
|
row === undefined
|
|
830
900
|
? undefined
|
|
831
901
|
: { offset: row.logBytes, seq: row.headSeq, sha256: row.headSha256 }
|
|
832
|
-
const indexed = await this.
|
|
902
|
+
const indexed = await this.indexSessionNow({
|
|
833
903
|
slug: location.slug,
|
|
834
904
|
logPath: location.logPath,
|
|
835
905
|
records: readIndexableRecords(location.logPath, from),
|
|
@@ -842,11 +912,17 @@ export abstract class SessionIndexBase implements SessionIndex {
|
|
|
842
912
|
}
|
|
843
913
|
|
|
844
914
|
async sync(home: string): Promise<void> {
|
|
915
|
+
await this.settled()
|
|
916
|
+
return this.syncNow(home)
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/** {@link sync} without waiting for the catch-up; the catch-up itself. */
|
|
920
|
+
protected async syncNow(home: string): Promise<void> {
|
|
845
921
|
const logs = await discoverSessionLogs(home)
|
|
846
922
|
const present = new Set<string>()
|
|
847
923
|
for (const log of logs) {
|
|
848
924
|
present.add(log.sessionId)
|
|
849
|
-
await this.
|
|
925
|
+
await this.refreshNow(log)
|
|
850
926
|
}
|
|
851
927
|
const gone = this.indexedSessionIds().filter((id) => !present.has(id))
|
|
852
928
|
if (gone.length > 0) {
|
|
@@ -470,6 +470,13 @@ export interface SqliteSessionIndexOptions {
|
|
|
470
470
|
readonly path: string
|
|
471
471
|
/** The home whose logs the index describes. */
|
|
472
472
|
readonly home: string
|
|
473
|
+
/**
|
|
474
|
+
* Return once the index is open and its version is current, and catch up
|
|
475
|
+
* with the logs in the background. Every read waits for that catch-up, so
|
|
476
|
+
* a listing, a search or a lookup still sees the synced index; opening no
|
|
477
|
+
* longer waits on a home with thousands of logs.
|
|
478
|
+
*/
|
|
479
|
+
readonly syncInBackground?: boolean
|
|
473
480
|
}
|
|
474
481
|
|
|
475
482
|
export interface RebuildSqliteSessionIndexOptions extends SqliteSessionIndexOptions {
|
|
@@ -513,6 +520,19 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
513
520
|
readonly #sink: IndexSink
|
|
514
521
|
readonly #statements = new Map<string, StatementSync>()
|
|
515
522
|
#open = true
|
|
523
|
+
/** The catch-up started by `syncInBackground`; reads wait on it. */
|
|
524
|
+
#catchUp: Promise<void> | undefined
|
|
525
|
+
|
|
526
|
+
#startBackgroundSync(home: string): void {
|
|
527
|
+
this.#catchUp = this.syncNow(home).catch(() => {
|
|
528
|
+
// A failed catch-up (the index closed, a log vanished mid-read) leaves the
|
|
529
|
+
// rows the last sync wrote; the next open syncs again.
|
|
530
|
+
})
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
protected override async settled(): Promise<void> {
|
|
534
|
+
await this.#catchUp
|
|
535
|
+
}
|
|
516
536
|
|
|
517
537
|
/** Wraps an open database whose schema is current. Use {@link SqliteSessionIndex.open}. */
|
|
518
538
|
private constructor(db: DatabaseSync, path?: string) {
|
|
@@ -760,7 +780,8 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
760
780
|
throw error
|
|
761
781
|
}
|
|
762
782
|
const index = new SqliteSessionIndex(db, options.path)
|
|
763
|
-
|
|
783
|
+
if (options.syncInBackground === true) index.#startBackgroundSync(options.home)
|
|
784
|
+
else await index.sync(options.home)
|
|
764
785
|
return index
|
|
765
786
|
}
|
|
766
787
|
|
|
@@ -848,6 +869,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
848
869
|
}
|
|
849
870
|
|
|
850
871
|
async listSessions(options: ListSessionsOptions = {}): Promise<IndexedSession[]> {
|
|
872
|
+
await this.settled()
|
|
851
873
|
const where: string[] = []
|
|
852
874
|
const values: SQLInputValue[] = []
|
|
853
875
|
if (options.slug !== undefined) {
|
|
@@ -863,6 +885,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
863
885
|
}
|
|
864
886
|
|
|
865
887
|
async listTurns(sessionId: SessionId): Promise<IndexedTurn[]> {
|
|
888
|
+
await this.settled()
|
|
866
889
|
return this.#all(
|
|
867
890
|
'SELECT * FROM turns WHERE session_id = ? ORDER BY started_at, id',
|
|
868
891
|
sessionId,
|
|
@@ -870,6 +893,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
870
893
|
}
|
|
871
894
|
|
|
872
895
|
async listChildren(sessionId: SessionId): Promise<ChildSessionSummary[]> {
|
|
896
|
+
await this.settled()
|
|
873
897
|
return this.#all(
|
|
874
898
|
'SELECT * FROM children WHERE session_id = ? ORDER BY spawned_at, child_id',
|
|
875
899
|
sessionId,
|
|
@@ -882,6 +906,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
882
906
|
async listPendingDecisions(
|
|
883
907
|
options: { sessionId?: SessionId } = {},
|
|
884
908
|
): Promise<IndexedPendingDecision[]> {
|
|
909
|
+
await this.settled()
|
|
885
910
|
const rows =
|
|
886
911
|
options.sessionId === undefined
|
|
887
912
|
? this.#all('SELECT * FROM pending_decisions ORDER BY session_id, decision_id')
|
|
@@ -897,6 +922,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
897
922
|
kind: ExternalRefKind,
|
|
898
923
|
externalId: string,
|
|
899
924
|
): Promise<ExternalRefTarget | undefined> {
|
|
925
|
+
await this.settled()
|
|
900
926
|
this.#reopenIfReplaced()
|
|
901
927
|
const row = this.#db
|
|
902
928
|
.prepare(
|
|
@@ -908,6 +934,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
908
934
|
}
|
|
909
935
|
|
|
910
936
|
async listExternalRefs(sessionId: SessionId): Promise<ExternalRefTarget[]> {
|
|
937
|
+
await this.settled()
|
|
911
938
|
return this.#all(
|
|
912
939
|
'SELECT * FROM external_refs WHERE session_id = ? ORDER BY protocol, kind, external_id',
|
|
913
940
|
sessionId,
|
|
@@ -915,6 +942,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
915
942
|
}
|
|
916
943
|
|
|
917
944
|
async batches(options: { sessionId?: SessionId } = {}): Promise<IndexedBatch[]> {
|
|
945
|
+
await this.settled()
|
|
918
946
|
const rows =
|
|
919
947
|
options.sessionId === undefined
|
|
920
948
|
? this.#all('SELECT * FROM batches ORDER BY session_id, batch_id')
|
|
@@ -926,6 +954,7 @@ export class SqliteSessionIndex extends SessionIndexBase {
|
|
|
926
954
|
}
|
|
927
955
|
|
|
928
956
|
async searchEvidence(options: EvidenceSearchOptions): Promise<EvidenceHit[]> {
|
|
957
|
+
await this.settled()
|
|
929
958
|
const match = evidenceMatcher(options)
|
|
930
959
|
const narrowing = ftsMatchExpression(options)
|
|
931
960
|
const limit = options.limit ?? 100
|
|
@@ -19,6 +19,7 @@ import { randomUUID } from 'node:crypto'
|
|
|
19
19
|
import { realpathSync, statSync } from 'node:fs'
|
|
20
20
|
import { rm } from 'node:fs/promises'
|
|
21
21
|
|
|
22
|
+
import { forgetAllShellSessions } from '../../authorization/shell-session-state.js'
|
|
22
23
|
import { tempFilePath } from '../../utils/temp.js'
|
|
23
24
|
import { type CommandShell, hostCommandShell } from '../command-shell.js'
|
|
24
25
|
import { pathOutsideRoots, toolRoots } from '../paths.js'
|
|
@@ -152,6 +153,7 @@ function sameFolder(a: string, b: string): boolean {
|
|
|
152
153
|
/** For tests: forget every session. */
|
|
153
154
|
export function forgetCarriedDirectories(): void {
|
|
154
155
|
carried.clear()
|
|
156
|
+
forgetAllShellSessions()
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
// Enumerable symbol crosses the executor's context copies, never the model's
|
|
@@ -2,7 +2,9 @@ import { rm } from 'node:fs/promises'
|
|
|
2
2
|
import { z } from 'zod'
|
|
3
3
|
import { findDangerousCommand } from '../../authorization/dangerous-commands.js'
|
|
4
4
|
import { isReadOnlyCommandLine } from '../../authorization/readonly-commands.js'
|
|
5
|
+
import { recordShellCommand } from '../../authorization/shell-session.js'
|
|
5
6
|
import { SANDBOX_KILL_GRACE_MS } from '../../constants/sandbox/index.js'
|
|
7
|
+
import { appendDirsToPath } from '../../plugin/bin-path.js'
|
|
6
8
|
import { killTree } from '../../process/kill-tree.js'
|
|
7
9
|
import { genericLabel } from '../../registry/tool/presentation.js'
|
|
8
10
|
import { cancelCauseOf } from '../../types/session/cancel-cause.js'
|
|
@@ -24,6 +26,7 @@ import {
|
|
|
24
26
|
} from '../command-shell.js'
|
|
25
27
|
import { defineTool } from '../defineTool.js'
|
|
26
28
|
import { scrubInheritedEnv, withheldEnvNoticeText } from '../env-scrub.js'
|
|
29
|
+
import { withSafeGitConfig } from '../git-config-env.js'
|
|
27
30
|
import { createHostOutputDecoder } from '../host-output.js'
|
|
28
31
|
import { looksBinary, windowText } from '../text-window.js'
|
|
29
32
|
import {
|
|
@@ -32,10 +35,16 @@ import {
|
|
|
32
35
|
recordDirectory,
|
|
33
36
|
withCwdCapture,
|
|
34
37
|
} from './bash-cwd.js'
|
|
35
|
-
import { commandNotFoundHint, judgeExit } from './exit-semantics.js'
|
|
38
|
+
import { bareRepositoryHint, commandNotFoundHint, judgeExit } from './exit-semantics.js'
|
|
36
39
|
import { jsonStringEscapes } from './json-string-hint.js'
|
|
37
40
|
import { creditShellReads } from './shell-read-credit.js'
|
|
38
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
cappedSignIn,
|
|
43
|
+
cappedSignInRefusal,
|
|
44
|
+
chainedSleeps,
|
|
45
|
+
leadingLongSleep,
|
|
46
|
+
longSleepRefusal,
|
|
47
|
+
} from './sleep-guard.js'
|
|
39
48
|
|
|
40
49
|
// Namzu owns its own bash timeout knob — `NAMZU_BASH_TIMEOUT_MS` — and
|
|
41
50
|
// reads no consumer's env name. A consumer that wants one knob aliases
|
|
@@ -152,7 +161,7 @@ const inputSchema = z.object({
|
|
|
152
161
|
.transform((ms) => Math.min(ms, MAX_BASH_TIMEOUT_MS)),
|
|
153
162
|
)
|
|
154
163
|
.describe(
|
|
155
|
-
`Command timeout in milliseconds. Default: ${DEFAULT_BASH_TIMEOUT_MS}, maximum: ${MAX_BASH_TIMEOUT_MS}. For work that legitimately runs longer than the maximum, set run_in_background and
|
|
164
|
+
`Command timeout in milliseconds. Default: ${DEFAULT_BASH_TIMEOUT_MS}, maximum: ${MAX_BASH_TIMEOUT_MS}. For work that legitimately runs longer than the maximum, set run_in_background and end your turn; you are told when it exits. A foreground command still running when the timeout elapses is moved to a background job (and reported as such) instead of being stopped, where the host has background jobs.`,
|
|
156
165
|
),
|
|
157
166
|
description: z
|
|
158
167
|
.string()
|
|
@@ -165,7 +174,7 @@ const inputSchema = z.object({
|
|
|
165
174
|
.boolean()
|
|
166
175
|
.optional()
|
|
167
176
|
.describe(
|
|
168
|
-
'Start the command as a background job and return its id
|
|
177
|
+
'Start the command as a background job and return its id at once. You are told when it exits: end your turn or keep working, and do not poll or wait for it. A command that waits for a person (it prints a sign-in URL) goes here too, with no `timeout` wrapper: tell them the step and end your turn. For a persistent server, `wait_for_job` with output_contains observes its readiness marker; verify health separately. Use `job` action "read" for output. Background a command with this parameter, since `cmd &` is not a registered job: strict execution ownership can retire the allocation when the launcher exits with live descendants. An interactive application may belong to a dedicated computer only when that computer explicitly supports application lifetime; its launch result is not a registered job or proof the application has finished.',
|
|
169
178
|
),
|
|
170
179
|
dangerously_disable_sandbox: z
|
|
171
180
|
.boolean()
|
|
@@ -194,10 +203,49 @@ function bashInputIsReadOnly(input: BashInput | undefined): boolean {
|
|
|
194
203
|
|
|
195
204
|
const MAX_SHELL_PROGRESS_CHARS = 160
|
|
196
205
|
|
|
206
|
+
/**
|
|
207
|
+
* The last `max` characters of `text`, moved back to the start of an escape
|
|
208
|
+
* sequence the cut would land inside: a progress line is shown as text, and the
|
|
209
|
+
* tail of `ESC [ 38;2;255;106;0 m` is not a colour but `;2;255;106;0m`.
|
|
210
|
+
*/
|
|
211
|
+
function tailWhole(text: string, max: number): string {
|
|
212
|
+
if (text.length <= max) return text
|
|
213
|
+
let from = text.length - max
|
|
214
|
+
const esc = text.lastIndexOf('\u001b', from)
|
|
215
|
+
if (esc >= 0 && from - esc <= 64) {
|
|
216
|
+
const kind = text.charCodeAt(esc + 1)
|
|
217
|
+
let open = false
|
|
218
|
+
if (kind === 0x5b) {
|
|
219
|
+
// CSI: parameter and intermediate bytes (0x20-0x3f), then a final byte.
|
|
220
|
+
open = true
|
|
221
|
+
for (let i = esc + 2; i < from; i++) {
|
|
222
|
+
const code = text.charCodeAt(i)
|
|
223
|
+
if (code < 0x20 || code > 0x3f) {
|
|
224
|
+
open = false
|
|
225
|
+
break
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} else if (kind === 0x5d) {
|
|
229
|
+
// OSC: open until BEL or ST.
|
|
230
|
+
open = true
|
|
231
|
+
for (let i = esc + 2; i < from; i++) {
|
|
232
|
+
const code = text.charCodeAt(i)
|
|
233
|
+
if (code === 0x07 || code === 0x9c || (code === 0x1b && text.charCodeAt(i + 1) === 0x5c)) {
|
|
234
|
+
open = false
|
|
235
|
+
break
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (open) from = esc
|
|
240
|
+
}
|
|
241
|
+
return text.slice(from)
|
|
242
|
+
}
|
|
243
|
+
|
|
197
244
|
/** Keep a bounded tail even when a process never writes a newline. */
|
|
198
245
|
function appendProgressTail(previous: string, chunk: string, start: number, end: number): string {
|
|
199
|
-
return (
|
|
200
|
-
|
|
246
|
+
return tailWhole(
|
|
247
|
+
previous + tailWhole(chunk.slice(start, end), MAX_SHELL_PROGRESS_CHARS),
|
|
248
|
+
MAX_SHELL_PROGRESS_CHARS,
|
|
201
249
|
)
|
|
202
250
|
}
|
|
203
251
|
|
|
@@ -600,11 +648,15 @@ const BashToolBase = defineTool({
|
|
|
600
648
|
// ways to wait. The same answer is given here, before a person is asked to
|
|
601
649
|
// approve a command that would be blocked the moment they said yes.
|
|
602
650
|
refuseBeforeReview: async (input: BashInput, context) => {
|
|
603
|
-
if (
|
|
604
|
-
|
|
651
|
+
if (!context.backgroundJobs || backgroundTasksDisabled()) return undefined
|
|
652
|
+
if (input.run_in_background) {
|
|
653
|
+
const cappedBg = cappedSignIn(input.command)
|
|
654
|
+
return cappedBg === null ? undefined : { error: cappedSignInRefusal(cappedBg, true) }
|
|
605
655
|
}
|
|
606
|
-
const longSleep = leadingLongSleep(input.command)
|
|
607
|
-
|
|
656
|
+
const longSleep = leadingLongSleep(input.command) ?? chainedSleeps(input.command)
|
|
657
|
+
if (longSleep !== null) return { error: longSleepRefusal(longSleep) }
|
|
658
|
+
const capped = cappedSignIn(input.command)
|
|
659
|
+
return capped === null ? undefined : { error: cappedSignInRefusal(capped) }
|
|
608
660
|
},
|
|
609
661
|
permissions: ['shell_execute'],
|
|
610
662
|
// A line made only of vetted read-only commands (`ls`, `cat`, `git status`,
|
|
@@ -633,6 +685,12 @@ const BashToolBase = defineTool({
|
|
|
633
685
|
|
|
634
686
|
async execute(input, context) {
|
|
635
687
|
const startDirectory = bashWorkingDirectoryForExecution(context)
|
|
688
|
+
// Names this line gives the integer attribute to are remembered for the
|
|
689
|
+
// session: a later line that stores a subscript into one is arithmetic.
|
|
690
|
+
recordShellCommand(
|
|
691
|
+
typeof context.sessionId === 'string' ? context.sessionId : undefined,
|
|
692
|
+
input.command,
|
|
693
|
+
)
|
|
636
694
|
const refused = dangerousCommandReason(input.command)
|
|
637
695
|
if (refused !== undefined) {
|
|
638
696
|
return {
|
|
@@ -648,13 +706,24 @@ const BashToolBase = defineTool({
|
|
|
648
706
|
}
|
|
649
707
|
}
|
|
650
708
|
|
|
709
|
+
if (input.run_in_background && context.backgroundJobs && !backgroundTasksDisabled()) {
|
|
710
|
+
const cappedBg = cappedSignIn(input.command)
|
|
711
|
+
if (cappedBg !== null) {
|
|
712
|
+
return { success: false, output: '', error: cappedSignInRefusal(cappedBg, true) }
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
651
716
|
// Where a job registry exists to wait on, a long leading sleep only
|
|
652
717
|
// holds the turn; it is refused with the better ways to wait.
|
|
653
718
|
if (!input.run_in_background && context.backgroundJobs && !backgroundTasksDisabled()) {
|
|
654
|
-
const longSleep = leadingLongSleep(input.command)
|
|
719
|
+
const longSleep = leadingLongSleep(input.command) ?? chainedSleeps(input.command)
|
|
655
720
|
if (longSleep !== null) {
|
|
656
721
|
return { success: false, output: '', error: longSleepRefusal(longSleep) }
|
|
657
722
|
}
|
|
723
|
+
const capped = cappedSignIn(input.command)
|
|
724
|
+
if (capped !== null) {
|
|
725
|
+
return { success: false, output: '', error: cappedSignInRefusal(capped) }
|
|
726
|
+
}
|
|
658
727
|
}
|
|
659
728
|
|
|
660
729
|
// Asked to leave the sandbox. Honoured only on the executor's word that
|
|
@@ -739,7 +808,7 @@ const BashToolBase = defineTool({
|
|
|
739
808
|
output: `Started background job ${job.id}; state: running.${
|
|
740
809
|
job.outputFile === undefined
|
|
741
810
|
? ''
|
|
742
|
-
: ` Its output is saved to ${job.outputFile}; do not redirect it into a file of your own.
|
|
811
|
+
: ` Its output is saved to ${job.outputFile}; do not redirect it into a file of your own. You will be notified when it exits: end your turn or keep working, do not poll or wait for it. Read it with job.`
|
|
743
812
|
}`,
|
|
744
813
|
data: {
|
|
745
814
|
jobId: job.id,
|
|
@@ -747,6 +816,8 @@ const BashToolBase = defineTool({
|
|
|
747
816
|
...(job.outputFile === undefined ? {} : { outputFile: job.outputFile }),
|
|
748
817
|
},
|
|
749
818
|
facts: { kind: 'command', command: input.command, background: true, jobId: job.id },
|
|
819
|
+
// Only started: what the job does is told by its own exit notice.
|
|
820
|
+
launched: true,
|
|
750
821
|
}
|
|
751
822
|
} catch (err) {
|
|
752
823
|
// The per-owner cap, most likely. A refusal that names the limit
|
|
@@ -814,6 +885,7 @@ const BashToolBase = defineTool({
|
|
|
814
885
|
: '',
|
|
815
886
|
result.attribution ? `[${result.attribution.message}]` : '',
|
|
816
887
|
commandNotFoundHint(result.exitCode, result.stderr) ?? '',
|
|
888
|
+
bareRepositoryHint(result.stderr) ?? '',
|
|
817
889
|
]
|
|
818
890
|
.filter(Boolean)
|
|
819
891
|
.join('\n\n')
|
|
@@ -911,7 +983,14 @@ const BashToolBase = defineTool({
|
|
|
911
983
|
{
|
|
912
984
|
cwd: startDirectory,
|
|
913
985
|
timeout: input.timeout,
|
|
914
|
-
|
|
986
|
+
// Last: a folder the model wrote that looks like a repository must not
|
|
987
|
+
// get git to run the program its config names (see git-config-env.ts).
|
|
988
|
+
env: withSafeGitConfig(
|
|
989
|
+
appendDirsToPath(
|
|
990
|
+
withNodeOnPath({ ...inherited.env, ...context.env }),
|
|
991
|
+
context.pluginBinDirs?.() ?? [],
|
|
992
|
+
),
|
|
993
|
+
),
|
|
915
994
|
maxBuffer: DEFAULT_BASH_MAX_BUFFER_BYTES,
|
|
916
995
|
signal: context.abortSignal,
|
|
917
996
|
onOutput,
|
|
@@ -1027,6 +1106,7 @@ const BashToolBase = defineTool({
|
|
|
1027
1106
|
? `[${clipped.join(' and ')} ${clipped.length === 1 ? 'was' : 'were'} truncated by the host output cap. The omitted output is unavailable in this result.]`
|
|
1028
1107
|
: '',
|
|
1029
1108
|
commandNotFoundHint(exitCode, failure.stderr ?? '') ?? '',
|
|
1109
|
+
bareRepositoryHint(failure.stderr ?? '') ?? '',
|
|
1030
1110
|
]
|
|
1031
1111
|
.filter(Boolean)
|
|
1032
1112
|
.join('\n\n')
|
|
@@ -219,3 +219,13 @@ export function commandNotFoundHint(
|
|
|
219
219
|
}
|
|
220
220
|
return undefined
|
|
221
221
|
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* What to tell the model when git refused to read the folder it ran in as a
|
|
225
|
+
* repository because the folder only looks like a bare one (every command a
|
|
226
|
+
* session starts carries `safe.bareRepository=explicit`).
|
|
227
|
+
*/
|
|
228
|
+
export function bareRepositoryHint(stderr: string): string | undefined {
|
|
229
|
+
if (!/safe\.bareRepository is 'explicit'/.test(stderr)) return undefined
|
|
230
|
+
return '[git did not treat this folder as a repository: it only looks like a bare one (HEAD, objects and refs outside a .git folder), and git here reads a bare repository only when it is named. For a real bare repository, name it: git --git-dir=. <command>. For a normal checkout, run git from inside the working tree.]'
|
|
231
|
+
}
|