@namzu/sdk 69.4.0 → 71.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +161 -0
- package/dist/authorization/bare-repository.d.ts +21 -0
- package/dist/authorization/bare-repository.d.ts.map +1 -0
- package/dist/authorization/bare-repository.js +62 -0
- package/dist/authorization/bare-repository.js.map +1 -0
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +10 -3
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +7 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +4 -0
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +24 -6
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +83 -10
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +17 -5
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +77 -6
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/readonly-flags.d.ts.map +1 -1
- package/dist/authorization/readonly-flags.js +98 -0
- package/dist/authorization/readonly-flags.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +15 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +370 -2
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/authorization/shell-paths.d.ts.map +1 -1
- package/dist/authorization/shell-paths.js +276 -0
- package/dist/authorization/shell-paths.js.map +1 -1
- package/dist/authorization/shell-session-state.d.ts +47 -0
- package/dist/authorization/shell-session-state.d.ts.map +1 -0
- package/dist/authorization/shell-session-state.js +70 -0
- package/dist/authorization/shell-session-state.js.map +1 -0
- package/dist/authorization/shell-session.d.ts +9 -0
- package/dist/authorization/shell-session.d.ts.map +1 -0
- package/dist/authorization/shell-session.js +19 -0
- package/dist/authorization/shell-session.js.map +1 -0
- package/dist/authorization/skill-grant.d.ts.map +1 -1
- package/dist/authorization/skill-grant.js +1 -0
- package/dist/authorization/skill-grant.js.map +1 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +2 -0
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/hooks.d.ts +16 -0
- package/dist/compaction/hooks.d.ts.map +1 -1
- package/dist/compaction/hooks.js +26 -1
- package/dist/compaction/hooks.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +6 -1
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/restore.d.ts.map +1 -1
- package/dist/compaction/restore.js +3 -2
- package/dist/compaction/restore.js.map +1 -1
- package/dist/config/runtime.d.ts +2 -0
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +7 -0
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +7 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +54 -4
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/web/guarded-fetch.d.ts +30 -0
- package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
- package/dist/connector/web/guarded-fetch.js +85 -0
- package/dist/connector/web/guarded-fetch.js.map +1 -1
- package/dist/connector/web/index.d.ts +1 -1
- package/dist/connector/web/index.d.ts.map +1 -1
- package/dist/connector/web/index.js +1 -1
- package/dist/connector/web/index.js.map +1 -1
- package/dist/connector/web/types.d.ts +8 -0
- package/dist/connector/web/types.d.ts.map +1 -1
- package/dist/constants/compaction/index.d.ts.map +1 -1
- package/dist/constants/compaction/index.js +1 -1
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/execution/code-runtime/worker-program.d.ts +1 -1
- package/dist/execution/code-runtime/worker-program.d.ts.map +1 -1
- package/dist/execution/code-runtime/worker-program.js +9 -5
- package/dist/execution/code-runtime/worker-program.js.map +1 -1
- package/dist/execution/local.d.ts.map +1 -1
- package/dist/execution/local.js +6 -1
- package/dist/execution/local.js.map +1 -1
- package/dist/peers/index.d.ts +2 -2
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +1 -1
- package/dist/peers/index.js.map +1 -1
- package/dist/peers/record.d.ts +74 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +41 -1
- package/dist/peers/record.js.map +1 -1
- package/dist/peers/registry.d.ts.map +1 -1
- package/dist/peers/registry.js +20 -3
- package/dist/peers/registry.js.map +1 -1
- package/dist/plugin/bin-path.d.ts +41 -0
- package/dist/plugin/bin-path.d.ts.map +1 -0
- package/dist/plugin/bin-path.js +146 -0
- package/dist/plugin/bin-path.js.map +1 -0
- package/dist/plugin/common-layout/read.js +3 -3
- package/dist/plugin/common-layout/read.js.map +1 -1
- package/dist/plugin/common-layout-names.d.ts.map +1 -1
- package/dist/plugin/common-layout-names.js +0 -1
- package/dist/plugin/common-layout-names.js.map +1 -1
- package/dist/plugin/hook-module/capabilities.d.ts +12 -0
- package/dist/plugin/hook-module/capabilities.d.ts.map +1 -1
- package/dist/plugin/hook-module/capabilities.js +82 -10
- package/dist/plugin/hook-module/capabilities.js.map +1 -1
- package/dist/plugin/hook-module/consent.d.ts +11 -0
- package/dist/plugin/hook-module/consent.d.ts.map +1 -1
- package/dist/plugin/hook-module/consent.js +31 -0
- package/dist/plugin/hook-module/consent.js.map +1 -1
- package/dist/plugin/hook-module/host.d.ts.map +1 -1
- package/dist/plugin/hook-module/host.js +69 -23
- package/dist/plugin/hook-module/host.js.map +1 -1
- package/dist/plugin/hook-module/index.d.ts +1 -1
- package/dist/plugin/hook-module/index.d.ts.map +1 -1
- package/dist/plugin/hook-module/index.js +1 -1
- package/dist/plugin/hook-module/index.js.map +1 -1
- package/dist/plugin/hook-module/scan.d.ts +16 -0
- package/dist/plugin/hook-module/scan.d.ts.map +1 -1
- package/dist/plugin/hook-module/scan.js +68 -3
- package/dist/plugin/hook-module/scan.js.map +1 -1
- package/dist/plugin/hook-module/worker-source.d.ts +5 -4
- package/dist/plugin/hook-module/worker-source.d.ts.map +1 -1
- package/dist/plugin/hook-module/worker-source.js +254 -28
- package/dist/plugin/hook-module/worker-source.js.map +1 -1
- package/dist/plugin/lifecycle.d.ts +21 -0
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +64 -0
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
- package/dist/plugin/shell-hook-tool-names.js +1 -0
- package/dist/plugin/shell-hook-tool-names.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +1 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +22 -4
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/public-runtime.d.ts +11 -9
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +11 -8
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +7 -3
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +7 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +2 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/runtime/jobs/monitor-stream.d.ts +9 -1
- package/dist/runtime/jobs/monitor-stream.d.ts.map +1 -1
- package/dist/runtime/jobs/monitor-stream.js +13 -4
- package/dist/runtime/jobs/monitor-stream.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +4 -0
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +12 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/git-status.js +3 -2
- package/dist/runtime/query/auto-review/git-status.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +16 -6
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +135 -15
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +2 -2
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.js +14 -4
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +11 -1
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +19 -8
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/path-escalation.d.ts +6 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -1
- package/dist/runtime/query/path-escalation.js +58 -4
- package/dist/runtime/query/path-escalation.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +21 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +39 -21
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +11 -2
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +18 -4
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +3 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/schedules/describe.d.ts.map +1 -1
- package/dist/schedules/describe.js +2 -0
- package/dist/schedules/describe.js.map +1 -1
- package/dist/schedules/evaluate.d.ts +4 -0
- package/dist/schedules/evaluate.d.ts.map +1 -1
- package/dist/schedules/evaluate.js +26 -1
- package/dist/schedules/evaluate.js.map +1 -1
- package/dist/schedules/index.d.ts +3 -1
- package/dist/schedules/index.d.ts.map +1 -1
- package/dist/schedules/index.js +2 -1
- package/dist/schedules/index.js.map +1 -1
- package/dist/schedules/next-fire.d.ts.map +1 -1
- package/dist/schedules/next-fire.js +10 -0
- package/dist/schedules/next-fire.js.map +1 -1
- package/dist/schedules/spec.d.ts +9 -0
- package/dist/schedules/spec.d.ts.map +1 -1
- package/dist/schedules/spec.js +33 -0
- package/dist/schedules/spec.js.map +1 -1
- package/dist/schedules/types.d.ts +32 -4
- package/dist/schedules/types.d.ts.map +1 -1
- package/dist/schedules/types.js +3 -2
- package/dist/schedules/types.js.map +1 -1
- package/dist/schedules/watch.d.ts +23 -0
- package/dist/schedules/watch.d.ts.map +1 -0
- package/dist/schedules/watch.js +46 -0
- package/dist/schedules/watch.js.map +1 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +2 -1
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/skills/arguments.d.ts +58 -0
- package/dist/skills/arguments.d.ts.map +1 -0
- package/dist/skills/arguments.js +208 -0
- package/dist/skills/arguments.js.map +1 -0
- package/dist/skills/index.d.ts +3 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/inline-shell-host.d.ts +6 -0
- package/dist/skills/inline-shell-host.d.ts.map +1 -1
- package/dist/skills/inline-shell-host.js +8 -0
- package/dist/skills/inline-shell-host.js.map +1 -1
- package/dist/skills/inline-shell.d.ts +26 -1
- package/dist/skills/inline-shell.d.ts.map +1 -1
- package/dist/skills/inline-shell.js +1308 -22
- package/dist/skills/inline-shell.js.map +1 -1
- package/dist/tools/builtins/bash-cwd.d.ts.map +1 -1
- package/dist/tools/builtins/bash-cwd.js +2 -0
- package/dist/tools/builtins/bash-cwd.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +79 -11
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/exit-semantics.d.ts +6 -0
- package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
- package/dist/tools/builtins/exit-semantics.js +10 -0
- package/dist/tools/builtins/exit-semantics.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +68 -13
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +37 -12
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +11 -0
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +14 -0
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/job.js +1 -1
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +4 -2
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/notebook-cells.d.ts +31 -0
- package/dist/tools/builtins/notebook-cells.d.ts.map +1 -0
- package/dist/tools/builtins/notebook-cells.js +160 -0
- package/dist/tools/builtins/notebook-cells.js.map +1 -0
- package/dist/tools/builtins/notebook-edit.d.ts +8 -0
- package/dist/tools/builtins/notebook-edit.d.ts.map +1 -0
- package/dist/tools/builtins/notebook-edit.js +249 -0
- package/dist/tools/builtins/notebook-edit.js.map +1 -0
- package/dist/tools/builtins/notebook-guard.d.ts.map +1 -1
- package/dist/tools/builtins/notebook-guard.js +2 -1
- package/dist/tools/builtins/notebook-guard.js.map +1 -1
- package/dist/tools/builtins/push-notification.d.ts +49 -0
- package/dist/tools/builtins/push-notification.d.ts.map +1 -0
- package/dist/tools/builtins/push-notification.js +107 -0
- package/dist/tools/builtins/push-notification.js.map +1 -0
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +8 -3
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/read-media.d.ts.map +1 -1
- package/dist/tools/builtins/read-media.js +2 -1
- package/dist/tools/builtins/read-media.js.map +1 -1
- package/dist/tools/builtins/read-render.d.ts.map +1 -1
- package/dist/tools/builtins/read-render.js +5 -3
- package/dist/tools/builtins/read-render.js.map +1 -1
- package/dist/tools/builtins/search-support.d.ts +6 -4
- package/dist/tools/builtins/search-support.d.ts.map +1 -1
- package/dist/tools/builtins/search-support.js +15 -3
- package/dist/tools/builtins/search-support.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +30 -8
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/builtins/sleep-guard.d.ts +20 -0
- package/dist/tools/builtins/sleep-guard.d.ts.map +1 -1
- package/dist/tools/builtins/sleep-guard.js +125 -1
- package/dist/tools/builtins/sleep-guard.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +1 -1
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web.d.ts +2 -0
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +97 -3
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/command-shell.d.ts +50 -0
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +145 -0
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/env-scrub.d.ts +2 -0
- package/dist/tools/env-scrub.d.ts.map +1 -1
- package/dist/tools/env-scrub.js +15 -1
- package/dist/tools/env-scrub.js.map +1 -1
- package/dist/tools/git-config-env.d.ts +55 -0
- package/dist/tools/git-config-env.d.ts.map +1 -0
- package/dist/tools/git-config-env.js +130 -0
- package/dist/tools/git-config-env.js.map +1 -0
- package/dist/tools/schedules/schedule-tool.d.ts +7 -0
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +72 -3
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +38 -2
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/types/connector/mcp.d.ts +24 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/message/index.d.ts +21 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +37 -2
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +11 -2
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +12 -2
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +10 -2
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +13 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/plain-terminal-text.d.ts +21 -0
- package/dist/utils/plain-terminal-text.d.ts.map +1 -0
- package/dist/utils/plain-terminal-text.js +156 -0
- package/dist/utils/plain-terminal-text.js.map +1 -0
- package/package.json +1 -1
- package/src/authorization/bare-repository.ts +70 -0
- package/src/authorization/command-line.ts +18 -4
- package/src/authorization/gate.ts +11 -0
- package/src/authorization/protected-paths.ts +89 -10
- package/src/authorization/readonly-commands.ts +75 -6
- package/src/authorization/readonly-flags.ts +103 -0
- package/src/authorization/shell-lexer.ts +367 -2
- package/src/authorization/shell-paths.ts +386 -0
- package/src/authorization/shell-session-state.ts +97 -0
- package/src/authorization/shell-session.ts +23 -0
- package/src/authorization/skill-grant.ts +1 -0
- package/src/compaction/extractor.ts +1 -0
- package/src/compaction/hooks.ts +43 -1
- package/src/compaction/manual.ts +6 -0
- package/src/compaction/restore.ts +3 -2
- package/src/config/runtime.ts +7 -0
- package/src/connector/mcp/client.ts +61 -4
- package/src/connector/web/guarded-fetch.ts +92 -0
- package/src/connector/web/index.ts +6 -1
- package/src/connector/web/types.ts +8 -0
- package/src/constants/compaction/index.ts +1 -1
- package/src/execution/code-runtime/worker-program.ts +9 -5
- package/src/execution/local.ts +6 -1
- package/src/peers/index.ts +8 -2
- package/src/peers/record.ts +45 -1
- package/src/peers/registry.ts +21 -5
- package/src/plugin/bin-path.ts +149 -0
- package/src/plugin/common-layout/read.ts +3 -3
- package/src/plugin/common-layout-names.ts +0 -1
- package/src/plugin/hook-module/capabilities.ts +94 -10
- package/src/plugin/hook-module/consent.ts +36 -0
- package/src/plugin/hook-module/host.ts +72 -21
- package/src/plugin/hook-module/index.ts +2 -0
- package/src/plugin/hook-module/scan.ts +76 -4
- package/src/plugin/hook-module/worker-source.ts +255 -28
- package/src/plugin/lifecycle.ts +67 -0
- package/src/plugin/shell-hook-tool-names.ts +1 -0
- package/src/plugin/shell-hook.ts +23 -4
- package/src/public-runtime.ts +27 -0
- package/src/public-tools.ts +36 -2
- package/src/public-types.ts +3 -1
- package/src/runtime/jobs/monitor-stream.ts +18 -4
- package/src/runtime/jobs/registry.ts +22 -2
- package/src/runtime/query/auto-review/git-status.ts +3 -2
- package/src/runtime/query/executor.ts +153 -12
- package/src/runtime/query/index.ts +5 -2
- package/src/runtime/query/iteration/outstanding-work.ts +22 -4
- package/src/runtime/query/iteration/phases/compaction.ts +14 -1
- package/src/runtime/query/iteration/phases/tool-review.ts +24 -7
- package/src/runtime/query/path-escalation.ts +52 -4
- package/src/runtime/query/review-policy.ts +47 -15
- package/src/runtime/query/steering.ts +32 -4
- package/src/sandbox/provider/local.ts +3 -1
- package/src/schedules/describe.ts +2 -0
- package/src/schedules/evaluate.ts +29 -1
- package/src/schedules/index.ts +9 -1
- package/src/schedules/next-fire.ts +9 -0
- package/src/schedules/spec.ts +42 -0
- package/src/schedules/types.ts +33 -3
- package/src/schedules/watch.ts +71 -0
- package/src/session/workspace/git-worktree.ts +3 -1
- package/src/skills/arguments.ts +250 -0
- package/src/skills/index.ts +10 -0
- package/src/skills/inline-shell-host.ts +16 -0
- package/src/skills/inline-shell.ts +1358 -22
- package/src/tools/builtins/bash-cwd.ts +2 -0
- package/src/tools/builtins/bash.ts +93 -13
- package/src/tools/builtins/exit-semantics.ts +10 -0
- package/src/tools/builtins/glob.ts +79 -15
- package/src/tools/builtins/grep.ts +37 -10
- package/src/tools/builtins/index.ts +15 -0
- package/src/tools/builtins/job.ts +1 -1
- package/src/tools/builtins/monitor.ts +4 -2
- package/src/tools/builtins/notebook-cells.ts +196 -0
- package/src/tools/builtins/notebook-edit.ts +280 -0
- package/src/tools/builtins/notebook-guard.ts +2 -1
- package/src/tools/builtins/push-notification.ts +138 -0
- package/src/tools/builtins/read-file.ts +9 -3
- package/src/tools/builtins/read-media.ts +2 -1
- package/src/tools/builtins/read-render.ts +5 -3
- package/src/tools/builtins/search-support.ts +17 -3
- package/src/tools/builtins/skill.ts +29 -7
- package/src/tools/builtins/sleep-guard.ts +128 -1
- package/src/tools/builtins/wait-for-job.ts +1 -1
- package/src/tools/builtins/web.ts +100 -3
- package/src/tools/command-shell.ts +166 -0
- package/src/tools/env-scrub.ts +13 -1
- package/src/tools/git-config-env.ts +143 -0
- package/src/tools/schedules/schedule-tool.ts +79 -3
- package/src/tools/schedules/types.ts +47 -9
- package/src/types/connector/mcp.ts +25 -0
- package/src/types/message/index.ts +53 -1
- package/src/types/permission/index.ts +20 -3
- package/src/types/plugin/index.ts +10 -2
- package/src/types/tool/index.ts +13 -0
- package/src/utils/plain-terminal-text.ts +142 -0
|
@@ -146,6 +146,15 @@ export interface ShellLexResult {
|
|
|
146
146
|
readonly complete: boolean
|
|
147
147
|
/** Why the line is opaque, for diagnostics. Empty when it is not. */
|
|
148
148
|
readonly reasons: readonly string[]
|
|
149
|
+
/**
|
|
150
|
+
* Names the line gives the integer (or name-reference) attribute to, with
|
|
151
|
+
* `declare`, `typeset` or `local`: a later value stored into one is
|
|
152
|
+
* evaluated as arithmetic. A host that keeps a shell session records them
|
|
153
|
+
* (see `shell-session.ts`).
|
|
154
|
+
*/
|
|
155
|
+
readonly integerNames: readonly string[]
|
|
156
|
+
/** The line gives the attribute to names it does not spell out, or may do so through `eval` or `source`. */
|
|
157
|
+
readonly integerNamesUnknown: boolean
|
|
149
158
|
}
|
|
150
159
|
|
|
151
160
|
/**
|
|
@@ -232,12 +241,18 @@ import {
|
|
|
232
241
|
shellInvocation,
|
|
233
242
|
unwrapReexecChain,
|
|
234
243
|
} from './reexec-wrapper.js'
|
|
244
|
+
import { type ShellAttributes, currentShellAttributes } from './shell-session-state.js'
|
|
235
245
|
|
|
236
246
|
export type { ShellDialect }
|
|
237
247
|
|
|
238
248
|
export interface ShellLexOptions {
|
|
239
249
|
/** Default `bash`. */
|
|
240
250
|
readonly dialect?: ShellDialect
|
|
251
|
+
/**
|
|
252
|
+
* What earlier lines of the same shell session gave the integer attribute
|
|
253
|
+
* to. Default: the session the caller runs in (`withShellSession`), if any.
|
|
254
|
+
*/
|
|
255
|
+
readonly attributes?: ShellAttributes
|
|
241
256
|
}
|
|
242
257
|
|
|
243
258
|
export function lexShellCommandLine(line: string, options: ShellLexOptions = {}): ShellLexResult {
|
|
@@ -251,9 +266,11 @@ export function lexShellCommandLine(line: string, options: ShellLexOptions = {})
|
|
|
251
266
|
opaque: true,
|
|
252
267
|
complete: false,
|
|
253
268
|
reasons: ['native CMD command parsing is unavailable'],
|
|
269
|
+
integerNames: [],
|
|
270
|
+
integerNamesUnknown: false,
|
|
254
271
|
}
|
|
255
272
|
}
|
|
256
|
-
const context = new Context(line.length)
|
|
273
|
+
const context = new Context(line.length, options.attributes ?? currentShellAttributes())
|
|
257
274
|
context.setDialect(line, options.dialect ?? 'bash')
|
|
258
275
|
try {
|
|
259
276
|
lexInto(line, context, 'line', 0)
|
|
@@ -270,6 +287,8 @@ export function lexShellCommandLine(line: string, options: ShellLexOptions = {})
|
|
|
270
287
|
opaque: context.reasons.size > 0,
|
|
271
288
|
complete: context.complete,
|
|
272
289
|
reasons: [...context.reasons],
|
|
290
|
+
integerNames: [...context.declaredNames],
|
|
291
|
+
integerNamesUnknown: context.declaredUnknown,
|
|
273
292
|
}
|
|
274
293
|
}
|
|
275
294
|
|
|
@@ -286,14 +305,57 @@ class Context {
|
|
|
286
305
|
*/
|
|
287
306
|
private rescans: number
|
|
288
307
|
|
|
289
|
-
constructor(
|
|
308
|
+
constructor(
|
|
309
|
+
length: number,
|
|
310
|
+
private readonly prior: ShellAttributes | undefined = undefined,
|
|
311
|
+
) {
|
|
290
312
|
this.rescans = 4 * length + 4096
|
|
291
313
|
}
|
|
292
314
|
|
|
315
|
+
/** Names this line gives the integer attribute to, and whether it may give it to more. */
|
|
316
|
+
readonly declaredNames = new Set<string>()
|
|
317
|
+
declaredUnknown = false
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* A value that may hold a subscript or an expansion is stored into `name`.
|
|
321
|
+
* If an earlier line of the session gave `name` the integer attribute, or
|
|
322
|
+
* may have given it to any name, bash evaluates the value as arithmetic.
|
|
323
|
+
* `undefined` is a name the lexer cannot read.
|
|
324
|
+
*/
|
|
325
|
+
storedInto(name: string | undefined): void {
|
|
326
|
+
if (this.prior === undefined) return
|
|
327
|
+
if (this.prior.unknown || name === undefined || this.prior.integers.has(name))
|
|
328
|
+
this.opaque('arithmetic')
|
|
329
|
+
}
|
|
330
|
+
|
|
293
331
|
opaque(reason: string): void {
|
|
294
332
|
this.reasons.add(reason)
|
|
295
333
|
}
|
|
296
334
|
|
|
335
|
+
/**
|
|
336
|
+
* A name declared `-i` or `-n` evaluates what is later assigned to it as
|
|
337
|
+
* arithmetic, and an assigned value that holds a subscript runs the
|
|
338
|
+
* command inside it. The lexer keeps no variables, so when one line does
|
|
339
|
+
* both, in either order, it is opaque.
|
|
340
|
+
*/
|
|
341
|
+
private integerDeclared = false
|
|
342
|
+
private bracketSeen = false
|
|
343
|
+
|
|
344
|
+
declaredArithmetic(): void {
|
|
345
|
+
this.integerDeclared = true
|
|
346
|
+
if (this.bracketSeen) this.opaque('arithmetic')
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A value that may hold a subscript was stored: a literal one, an
|
|
351
|
+
* expanding one, or one a `read`, `mapfile`, `printf -v`, `getopts` or
|
|
352
|
+
* loop variable stores. The lexer cannot see what they hold.
|
|
353
|
+
*/
|
|
354
|
+
bracketAssigned(): void {
|
|
355
|
+
this.bracketSeen = true
|
|
356
|
+
if (this.integerDeclared) this.opaque('arithmetic')
|
|
357
|
+
}
|
|
358
|
+
|
|
297
359
|
private readonly dialects = new Map<string, ShellDialect>()
|
|
298
360
|
|
|
299
361
|
/** The dialect a string is read in. A string read two ways gets the stricter. */
|
|
@@ -447,6 +509,43 @@ const COMPOUND_AFTER = /^(?:\(|(?:\{|if|while|until|for|select|case|\[\[)(?=[\s;
|
|
|
447
509
|
/** Builtins whose arguments may be array assignments. */
|
|
448
510
|
const ASSIGNMENT_BUILTINS = new Set(['declare', 'typeset', 'local', 'export', 'readonly'])
|
|
449
511
|
|
|
512
|
+
/** A `let` argument that evaluates nothing but numbers and an assignment of one. */
|
|
513
|
+
const PLAIN_ARITHMETIC = /^(?:[A-Za-z_][A-Za-z0-9_]*=)?[0-9\s+\-*/%()<>=!&|^~?:,]*$/
|
|
514
|
+
/** A `declare -i` argument: a bare name, or a name given a plain number. */
|
|
515
|
+
/** A name word that carries a subscript, or one that expands into something that might. */
|
|
516
|
+
function subscriptOrExpands(word: ShellWord): boolean {
|
|
517
|
+
return word.value.includes('[') || word.expands
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/** A subscript beside something that expands, quoted or not: `a[$(cmd)]`. */
|
|
521
|
+
function subscriptWithExpansion(word: ShellWord): boolean {
|
|
522
|
+
return word.value.includes('[') && (word.expands || /[$`]/.test(word.value))
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** The variable a `NAME`, `NAME[sub]` or `NAME+` operand stores into; undefined when it is not a plain name. */
|
|
526
|
+
function plainName(text: string): string | undefined {
|
|
527
|
+
const match = /^([A-Za-z_][A-Za-z0-9_]*)(?:\[.*\])?\+?$/s.exec(text)
|
|
528
|
+
return match === null ? undefined : (match[1] as string)
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* Text with a letter or underscore in it. Stored into an integer name, a bare
|
|
533
|
+
* word like that is read as a variable and its value evaluated again, so
|
|
534
|
+
* `x=y` runs what an earlier call stored in `y`.
|
|
535
|
+
*/
|
|
536
|
+
const NAMES_A_VARIABLE = /[A-Za-z_]/
|
|
537
|
+
|
|
538
|
+
/** `NAME=`, `NAME+=` or `NAME[sub]=` at the start of a word. */
|
|
539
|
+
const ASSIGNMENT_NAME = /^([A-Za-z_][A-Za-z0-9_]*)(?:\[[^\]]*\])?\+?=/
|
|
540
|
+
|
|
541
|
+
/** A parameter expansion that assigns: `${NAME:=word}`, `${NAME=word}`. */
|
|
542
|
+
const ASSIGNING_EXPANSION = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?:\[[^\]]*\])?:?=/g
|
|
543
|
+
|
|
544
|
+
/** Text that hands a name the integer or name-reference attribute when read as a line. */
|
|
545
|
+
const DECLARES_INTEGER = /\b(?:declare|typeset|local)\b[^;&|\n]*\s-[A-Za-z]*[in]/
|
|
546
|
+
|
|
547
|
+
const PLAIN_INTEGER_ARGUMENT = /^[A-Za-z_][A-Za-z0-9_]*(?:=[0-9\s+\-*/%()<>=!&|^~?:,]*)?$/
|
|
548
|
+
|
|
450
549
|
const WORD_BREAK = new Set([' ', '\t', '\n', ';', '&', '|', '(', ')', '<', '>'])
|
|
451
550
|
|
|
452
551
|
const NAME_START = /[A-Za-z_]/
|
|
@@ -906,6 +1005,9 @@ class Parser {
|
|
|
906
1005
|
const name = this.takePlainWord()
|
|
907
1006
|
if (name.kind !== 'word') throw this.unexpected(name)
|
|
908
1007
|
this.context.compoundWords.push(name.word)
|
|
1008
|
+
// The loop variable takes whatever the list holds.
|
|
1009
|
+
this.context.bracketAssigned()
|
|
1010
|
+
let listHoldsBracket = false
|
|
909
1011
|
this.newlines()
|
|
910
1012
|
token = this.peek()
|
|
911
1013
|
if (token.kind === 'word' && !token.word.quoted && token.word.value === 'in') {
|
|
@@ -925,6 +1027,12 @@ class Parser {
|
|
|
925
1027
|
token = this.takePlainWord()
|
|
926
1028
|
if (token.kind === 'word') {
|
|
927
1029
|
this.context.compoundWords.push(token.word)
|
|
1030
|
+
if (
|
|
1031
|
+
token.word.value.includes('[') ||
|
|
1032
|
+
token.word.expands ||
|
|
1033
|
+
NAMES_A_VARIABLE.test(token.word.value)
|
|
1034
|
+
)
|
|
1035
|
+
listHoldsBracket = true
|
|
928
1036
|
continue
|
|
929
1037
|
}
|
|
930
1038
|
if (token.kind === 'newline' || (token.kind === 'op' && token.op === ';')) break
|
|
@@ -935,6 +1043,7 @@ class Parser {
|
|
|
935
1043
|
this.take()
|
|
936
1044
|
this.newlines()
|
|
937
1045
|
}
|
|
1046
|
+
if (listHoldsBracket) this.context.storedInto(plainName(name.word.value))
|
|
938
1047
|
this.loopBody()
|
|
939
1048
|
}
|
|
940
1049
|
|
|
@@ -1284,6 +1393,7 @@ class Parser {
|
|
|
1284
1393
|
this.context.opaque('parser setting')
|
|
1285
1394
|
}
|
|
1286
1395
|
}
|
|
1396
|
+
this.inspectArithmeticBuiltin(command)
|
|
1287
1397
|
const head = command.words[command.assignments]
|
|
1288
1398
|
if (head === undefined || head.expands) return
|
|
1289
1399
|
const name = basename(head.value)
|
|
@@ -1324,6 +1434,261 @@ class Parser {
|
|
|
1324
1434
|
this.nestedShell(nested.shell, nested.payload)
|
|
1325
1435
|
}
|
|
1326
1436
|
|
|
1437
|
+
/**
|
|
1438
|
+
* `unset` evaluates a subscript in a name operand, `unset 'a[$(cmd)]'`,
|
|
1439
|
+
* and runs `cmd`. `--` and the options `-v`, `-n` and `-f` (also
|
|
1440
|
+
* clustered, `-fv`) are read; the last of `-f` and `-v` decides, and with
|
|
1441
|
+
* `-f` the operands are function names, which evaluate nothing. Any other
|
|
1442
|
+
* word that holds a `[` or expands, a fused `-v'a[$(cmd)]'` included, is
|
|
1443
|
+
* opaque.
|
|
1444
|
+
*/
|
|
1445
|
+
private inspectUnset(args: ShellWord[]): void {
|
|
1446
|
+
let functions = false
|
|
1447
|
+
let options = true
|
|
1448
|
+
for (const word of args) {
|
|
1449
|
+
if (options && !word.expands && word.value === '--') {
|
|
1450
|
+
options = false
|
|
1451
|
+
continue
|
|
1452
|
+
}
|
|
1453
|
+
if (options && !word.expands && /^-[fvn]+$/.test(word.value)) {
|
|
1454
|
+
const last = word.value.replace(/[^fv]/g, '').slice(-1)
|
|
1455
|
+
if (last === 'f') functions = true
|
|
1456
|
+
else if (last === 'v') functions = false
|
|
1457
|
+
continue
|
|
1458
|
+
}
|
|
1459
|
+
if (functions && !word.expands) continue
|
|
1460
|
+
if (subscriptOrExpands(word)) {
|
|
1461
|
+
this.context.opaque('arithmetic')
|
|
1462
|
+
return
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/**
|
|
1468
|
+
* Bash evaluates a name that carries a subscript, `a[$(cmd)]`, as
|
|
1469
|
+
* arithmetic and runs `cmd`, quoted or not. Where that happens: each
|
|
1470
|
+
* `let` argument; `declare -i` (also `typeset`, `local`, clustered flags
|
|
1471
|
+
* such as `-ia`) for each `NAME=value`; the name given to `declare`,
|
|
1472
|
+
* `typeset` or `local` with any flags, to `printf -v` and to `read`; the
|
|
1473
|
+
* operand of `-v` or `-R` in `test` and `[`; and a later plain assignment
|
|
1474
|
+
* to a name declared `-i` or `-n` in the same line. A word that is not
|
|
1475
|
+
* plainly safe is opaque: the line asks instead of showing a command with
|
|
1476
|
+
* no inner one.
|
|
1477
|
+
*/
|
|
1478
|
+
private inspectArithmeticBuiltin(command: ShellCommand): void {
|
|
1479
|
+
for (let i = 0; i < command.assignments; i += 1) this.noteBracketAssignment(command.words[i])
|
|
1480
|
+
for (const word of command.words) {
|
|
1481
|
+
for (const match of word.value.matchAll(ASSIGNING_EXPANSION))
|
|
1482
|
+
this.context.storedInto(match[1])
|
|
1483
|
+
}
|
|
1484
|
+
let at = command.assignments
|
|
1485
|
+
for (;;) {
|
|
1486
|
+
const word = command.words[at]
|
|
1487
|
+
if (word === undefined) return
|
|
1488
|
+
if (word.expands) {
|
|
1489
|
+
// The head may name any builtin: with a subscript that expands in a
|
|
1490
|
+
// later word, the line asks.
|
|
1491
|
+
if (command.words.slice(at + 1).some(subscriptWithExpansion))
|
|
1492
|
+
this.context.opaque('arithmetic')
|
|
1493
|
+
// A command name held in a variable may be `declare`: flags that
|
|
1494
|
+
// give the integer or name-reference attribute then name a name the
|
|
1495
|
+
// lexer cannot read.
|
|
1496
|
+
if (
|
|
1497
|
+
command.words
|
|
1498
|
+
.slice(at + 1)
|
|
1499
|
+
.some((arg) => !arg.expands && /^-[A-Za-z]*[in]/.test(arg.value))
|
|
1500
|
+
) {
|
|
1501
|
+
this.context.declaredUnknown = true
|
|
1502
|
+
this.context.declaredArithmetic()
|
|
1503
|
+
}
|
|
1504
|
+
return
|
|
1505
|
+
}
|
|
1506
|
+
if ((word.value === 'builtin' || word.value === 'command') && command.words[at + 1]) {
|
|
1507
|
+
let next = at + 1
|
|
1508
|
+
// `--` and `-p` only step over; `-v` and `-V` run nothing; any
|
|
1509
|
+
// other option is not understood, so the line asks.
|
|
1510
|
+
for (;;) {
|
|
1511
|
+
const option = command.words[next]
|
|
1512
|
+
if (option === undefined || option.expands || !option.value.startsWith('-')) break
|
|
1513
|
+
if (option.value === '--') {
|
|
1514
|
+
next += 1
|
|
1515
|
+
break
|
|
1516
|
+
}
|
|
1517
|
+
if (option.value === '-p') {
|
|
1518
|
+
next += 1
|
|
1519
|
+
continue
|
|
1520
|
+
}
|
|
1521
|
+
if (word.value === 'command' && (option.value === '-v' || option.value === '-V')) return
|
|
1522
|
+
this.context.opaque('arithmetic')
|
|
1523
|
+
return
|
|
1524
|
+
}
|
|
1525
|
+
const target = command.words[next]
|
|
1526
|
+
if (target === undefined || target.expands) return
|
|
1527
|
+
at = next
|
|
1528
|
+
continue
|
|
1529
|
+
}
|
|
1530
|
+
break
|
|
1531
|
+
}
|
|
1532
|
+
const name = (command.words[at] as ShellWord).value
|
|
1533
|
+
const args = command.words.slice(at + 1)
|
|
1534
|
+
if (name === 'eval') {
|
|
1535
|
+
// eval reads its words as a line again, where a name with a subscript
|
|
1536
|
+
// and an expansion can reach `unset` or `declare -i`.
|
|
1537
|
+
if (args.some(subscriptWithExpansion)) this.context.opaque('arithmetic')
|
|
1538
|
+
// What it runs may give the attribute to any name.
|
|
1539
|
+
if (args.some((word) => word.expands || DECLARES_INTEGER.test(word.value)))
|
|
1540
|
+
this.context.declaredUnknown = true
|
|
1541
|
+
return
|
|
1542
|
+
}
|
|
1543
|
+
if (name === 'source' || name === '.') {
|
|
1544
|
+
// A file read into the shell may declare anything.
|
|
1545
|
+
this.context.declaredUnknown = true
|
|
1546
|
+
return
|
|
1547
|
+
}
|
|
1548
|
+
if (name === 'let') {
|
|
1549
|
+
if (args.some((word) => !PLAIN_ARITHMETIC.test(word.value))) this.context.opaque('arithmetic')
|
|
1550
|
+
return
|
|
1551
|
+
}
|
|
1552
|
+
if (name === 'printf') {
|
|
1553
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
1554
|
+
const value = (args[i] as ShellWord).value
|
|
1555
|
+
if (value === '--') break
|
|
1556
|
+
if (!value.startsWith('-')) break
|
|
1557
|
+
// The last -v wins, so every leading option is read.
|
|
1558
|
+
if (value === '-v') {
|
|
1559
|
+
this.context.bracketAssigned()
|
|
1560
|
+
const target = args[i + 1]
|
|
1561
|
+
if (target !== undefined && subscriptOrExpands(target)) this.context.opaque('arithmetic')
|
|
1562
|
+
// The formatted text is stored: whatever its arguments hold.
|
|
1563
|
+
this.context.storedInto(target === undefined ? undefined : plainName(target.value))
|
|
1564
|
+
i += 1
|
|
1565
|
+
continue
|
|
1566
|
+
}
|
|
1567
|
+
if (value.startsWith('-v')) {
|
|
1568
|
+
this.context.bracketAssigned()
|
|
1569
|
+
if (subscriptOrExpands(args[i] as ShellWord)) this.context.opaque('arithmetic')
|
|
1570
|
+
this.context.storedInto(plainName(value.slice(2)))
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
return
|
|
1574
|
+
}
|
|
1575
|
+
if (name === 'read') {
|
|
1576
|
+
this.context.bracketAssigned()
|
|
1577
|
+
this.inspectRead(args)
|
|
1578
|
+
return
|
|
1579
|
+
}
|
|
1580
|
+
if (name === 'unset') {
|
|
1581
|
+
this.inspectUnset(args)
|
|
1582
|
+
return
|
|
1583
|
+
}
|
|
1584
|
+
if (name === 'mapfile' || name === 'readarray' || name === 'getopts') {
|
|
1585
|
+
this.context.bracketAssigned()
|
|
1586
|
+
if (args.some((word) => subscriptOrExpands(word))) this.context.opaque('arithmetic')
|
|
1587
|
+
// Input stores into the named array (default MAPFILE); getopts into its name.
|
|
1588
|
+
const operands = args.filter((word) => !word.value.startsWith('-'))
|
|
1589
|
+
if (name !== 'getopts' && operands.length === 0) this.context.storedInto('MAPFILE')
|
|
1590
|
+
for (const word of operands) this.context.storedInto(plainName(word.value))
|
|
1591
|
+
return
|
|
1592
|
+
}
|
|
1593
|
+
if (name === 'test' || name === '[') {
|
|
1594
|
+
for (let i = 0; i < args.length - 1; i += 1) {
|
|
1595
|
+
const value = (args[i] as ShellWord).value
|
|
1596
|
+
if ((value === '-v' || value === '-R') && subscriptOrExpands(args[i + 1] as ShellWord))
|
|
1597
|
+
this.context.opaque('arithmetic')
|
|
1598
|
+
}
|
|
1599
|
+
return
|
|
1600
|
+
}
|
|
1601
|
+
if (name === 'export' || name === 'readonly') {
|
|
1602
|
+
for (const word of args) this.noteBracketAssignment(word)
|
|
1603
|
+
return
|
|
1604
|
+
}
|
|
1605
|
+
if (name !== 'declare' && name !== 'typeset' && name !== 'local') return
|
|
1606
|
+
let integer = false
|
|
1607
|
+
let nameref = false
|
|
1608
|
+
let flags = true
|
|
1609
|
+
for (const word of args) {
|
|
1610
|
+
if (flags && word.value === '--') flags = false
|
|
1611
|
+
else if (flags && /^-[A-Za-z]*i/.test(word.value)) integer = true
|
|
1612
|
+
// A word that expands may be the flag itself.
|
|
1613
|
+
else if (flags && word.expands && !word.value.includes('=')) integer = true
|
|
1614
|
+
if (flags && /^-[A-Za-z]*n/.test(word.value)) nameref = true
|
|
1615
|
+
}
|
|
1616
|
+
if (integer || nameref) this.context.declaredArithmetic()
|
|
1617
|
+
flags = true
|
|
1618
|
+
for (const word of args) {
|
|
1619
|
+
if (flags && word.value === '--') {
|
|
1620
|
+
flags = false
|
|
1621
|
+
continue
|
|
1622
|
+
}
|
|
1623
|
+
if (flags && word.value.startsWith('-') && !word.expands) continue
|
|
1624
|
+
const equals = word.value.indexOf('=')
|
|
1625
|
+
const nameFor = equals < 0 ? word.value : word.value.slice(0, equals)
|
|
1626
|
+
if (integer || nameref) {
|
|
1627
|
+
const declared = plainName(nameFor)
|
|
1628
|
+
if (declared === undefined) this.context.declaredUnknown = true
|
|
1629
|
+
else this.context.declaredNames.add(declared)
|
|
1630
|
+
}
|
|
1631
|
+
if (nameFor.includes('[') || (word.expands && /[$`]/.test(nameFor)))
|
|
1632
|
+
this.context.opaque('arithmetic')
|
|
1633
|
+
else if (nameref && word.value.slice(equals + 1).includes('[') && equals >= 0)
|
|
1634
|
+
this.context.opaque('arithmetic')
|
|
1635
|
+
else if (integer && !PLAIN_INTEGER_ARGUMENT.test(word.value))
|
|
1636
|
+
this.context.opaque('arithmetic')
|
|
1637
|
+
else this.noteBracketAssignment(word)
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
/** The names `read` stores into, minus the arguments of its options. */
|
|
1642
|
+
private inspectRead(args: ShellWord[]): void {
|
|
1643
|
+
let options = true
|
|
1644
|
+
let targets = 0
|
|
1645
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
1646
|
+
const value = (args[i] as ShellWord).value
|
|
1647
|
+
if (options && value === '--') {
|
|
1648
|
+
options = false
|
|
1649
|
+
continue
|
|
1650
|
+
}
|
|
1651
|
+
if (options && value.startsWith('-') && value.length > 1) {
|
|
1652
|
+
for (let k = 1; k < value.length; k += 1) {
|
|
1653
|
+
const letter = value[k] as string
|
|
1654
|
+
if ('dinNptu'.includes(letter) || letter === 'a') {
|
|
1655
|
+
const rest = value.slice(k + 1)
|
|
1656
|
+
const operand = rest.length > 0 ? rest : (args[i + 1]?.value ?? '')
|
|
1657
|
+
if (rest.length === 0) i += 1
|
|
1658
|
+
if (letter === 'a' && operand.includes('[')) this.context.opaque('arithmetic')
|
|
1659
|
+
if (letter === 'a') {
|
|
1660
|
+
this.context.storedInto(plainName(operand))
|
|
1661
|
+
targets += 1
|
|
1662
|
+
}
|
|
1663
|
+
break
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
continue
|
|
1667
|
+
}
|
|
1668
|
+
if (subscriptOrExpands(args[i] as ShellWord)) this.context.opaque('arithmetic')
|
|
1669
|
+
this.context.storedInto(plainName(value))
|
|
1670
|
+
targets += 1
|
|
1671
|
+
}
|
|
1672
|
+
if (targets === 0) this.context.storedInto('REPLY')
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
/** A plain `NAME=value` whose value holds a subscript: dangerous once NAME is `-i` or `-n`. */
|
|
1676
|
+
private noteBracketAssignment(word: ShellWord | undefined): void {
|
|
1677
|
+
if (word === undefined) return
|
|
1678
|
+
const equals = word.value.indexOf('=')
|
|
1679
|
+
if (equals <= 0) return
|
|
1680
|
+
const value = word.value.slice(equals + 1)
|
|
1681
|
+
if (value.includes('[') || (word.expands && /[$`]/.test(value))) {
|
|
1682
|
+
this.context.bracketAssigned()
|
|
1683
|
+
const named = ASSIGNMENT_NAME.exec(word.value)
|
|
1684
|
+
this.context.storedInto(named === null ? undefined : named[1])
|
|
1685
|
+
} else if (NAMES_A_VARIABLE.test(value)) {
|
|
1686
|
+
// A name holds whatever an earlier call stored in it.
|
|
1687
|
+
const named = ASSIGNMENT_NAME.exec(word.value)
|
|
1688
|
+
this.context.storedInto(named === null ? undefined : named[1])
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1327
1692
|
/** Read the payload of `bash -c payload` as a command line of its own. */
|
|
1328
1693
|
private nestedShell(shell: string, payload: ShellWord): void {
|
|
1329
1694
|
if (this.depth + 1 >= MAX_SHELL_DEPTH) {
|