@namzu/sdk 59.0.0 → 60.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +120 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +1 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +16 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/acp/update.d.ts.map +1 -1
- package/dist/bridge/acp/update.js +1 -0
- package/dist/bridge/acp/update.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +12 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/compaction/context-window.d.ts +53 -0
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +141 -2
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/constants/continuation.d.ts +9 -0
- package/dist/constants/continuation.d.ts.map +1 -1
- package/dist/constants/continuation.js +9 -0
- package/dist/constants/continuation.js.map +1 -1
- package/dist/contracts/session/api.d.ts +7 -1
- package/dist/contracts/session/api.d.ts.map +1 -1
- package/dist/execution/workflow/index.d.ts +3 -1
- package/dist/execution/workflow/index.d.ts.map +1 -1
- package/dist/execution/workflow/index.js +2 -1
- package/dist/execution/workflow/index.js.map +1 -1
- package/dist/execution/workflow/journal.d.ts +24 -4
- package/dist/execution/workflow/journal.d.ts.map +1 -1
- package/dist/execution/workflow/journal.js +131 -9
- package/dist/execution/workflow/journal.js.map +1 -1
- package/dist/execution/workflow/prelude.d.ts +2 -0
- package/dist/execution/workflow/prelude.d.ts.map +1 -1
- package/dist/execution/workflow/prelude.js +49 -8
- package/dist/execution/workflow/prelude.js.map +1 -1
- package/dist/execution/workflow/resume.d.ts +59 -0
- package/dist/execution/workflow/resume.d.ts.map +1 -0
- package/dist/execution/workflow/resume.js +273 -0
- package/dist/execution/workflow/resume.js.map +1 -0
- package/dist/execution/workflow/runtime.d.ts.map +1 -1
- package/dist/execution/workflow/runtime.js +112 -8
- package/dist/execution/workflow/runtime.js.map +1 -1
- package/dist/execution/workflow/types.d.ts +105 -1
- package/dist/execution/workflow/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +1 -0
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/plugin/compat.d.ts +24 -0
- package/dist/plugin/compat.d.ts.map +1 -0
- package/dist/plugin/compat.js +149 -0
- package/dist/plugin/compat.js.map +1 -0
- package/dist/plugin/loader.d.ts +2 -1
- package/dist/plugin/loader.d.ts.map +1 -1
- package/dist/plugin/loader.js +6 -0
- package/dist/plugin/loader.js.map +1 -1
- package/dist/pricing/index.d.ts.map +1 -1
- package/dist/pricing/index.js +2 -1
- package/dist/pricing/index.js.map +1 -1
- package/dist/process/kill-tree.d.ts +44 -0
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js +102 -4
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +9 -1
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +4 -0
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +11 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/mock.d.ts +2 -0
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +16 -8
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts +18 -0
- package/dist/provider/model-window-suffix.d.ts.map +1 -0
- package/dist/provider/model-window-suffix.js +78 -0
- package/dist/provider/model-window-suffix.js.map +1 -0
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +5 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +5 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +1 -0
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +1 -4
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +0 -28
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.d.ts +6 -0
- package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.js +11 -0
- package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
- package/dist/runtime/jobs/host-exit-finalizer.d.ts +20 -0
- package/dist/runtime/jobs/host-exit-finalizer.d.ts.map +1 -0
- package/dist/runtime/jobs/host-exit-finalizer.js +57 -0
- package/dist/runtime/jobs/host-exit-finalizer.js.map +1 -0
- package/dist/runtime/jobs/liveness.d.ts +67 -0
- package/dist/runtime/jobs/liveness.d.ts.map +1 -0
- package/dist/runtime/jobs/liveness.js +94 -0
- package/dist/runtime/jobs/liveness.js.map +1 -0
- package/dist/runtime/jobs/registry.d.ts +21 -0
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +104 -2
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/jobs/wake-budget.d.ts +35 -0
- package/dist/runtime/jobs/wake-budget.d.ts.map +1 -0
- package/dist/runtime/jobs/wake-budget.js +48 -0
- package/dist/runtime/jobs/wake-budget.js.map +1 -0
- package/dist/runtime/query/detached-calls.d.ts +65 -0
- package/dist/runtime/query/detached-calls.d.ts.map +1 -0
- package/dist/runtime/query/detached-calls.js +116 -0
- package/dist/runtime/query/detached-calls.js.map +1 -0
- package/dist/runtime/query/executor.d.ts +4 -1
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +90 -6
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +34 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +32 -5
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/effort-clamp.d.ts +13 -0
- package/dist/runtime/query/iteration/effort-clamp.d.ts.map +1 -0
- package/dist/runtime/query/iteration/effort-clamp.js +42 -0
- package/dist/runtime/query/iteration/effort-clamp.js.map +1 -0
- package/dist/runtime/query/iteration/index.d.ts +34 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +199 -6
- package/dist/runtime/query/iteration/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 +11 -3
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +9 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +63 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +6 -0
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/session-storage.d.ts.map +1 -1
- package/dist/runtime/query/session-storage.js +8 -3
- package/dist/runtime/query/session-storage.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +29 -3
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +58 -3
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +1 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +1 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/system-events.d.ts +5 -0
- package/dist/runtime/system-events.d.ts.map +1 -1
- package/dist/runtime/system-events.js +7 -1
- package/dist/runtime/system-events.js.map +1 -1
- package/dist/sandbox/denial.d.ts +11 -0
- package/dist/sandbox/denial.d.ts.map +1 -0
- package/dist/sandbox/denial.js +61 -0
- package/dist/sandbox/denial.js.map +1 -0
- package/dist/sandbox/file-walk-program.d.ts.map +1 -1
- package/dist/sandbox/file-walk-program.js +31 -13
- package/dist/sandbox/file-walk-program.js.map +1 -1
- package/dist/sandbox/file-walk.d.ts +2 -0
- package/dist/sandbox/file-walk.d.ts.map +1 -1
- package/dist/sandbox/file-walk.js +64 -13
- package/dist/sandbox/file-walk.js.map +1 -1
- package/dist/sandbox/ignore-matcher.d.ts +30 -0
- package/dist/sandbox/ignore-matcher.d.ts.map +1 -0
- package/dist/sandbox/ignore-matcher.js +11 -0
- package/dist/sandbox/ignore-matcher.js.map +1 -0
- package/dist/sandbox/ignore-source.d.ts +26 -0
- package/dist/sandbox/ignore-source.d.ts.map +1 -0
- package/dist/sandbox/ignore-source.js +221 -0
- package/dist/sandbox/ignore-source.js.map +1 -0
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +11 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +1 -0
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/session/log-hash.d.ts.map +1 -1
- package/dist/session/log-hash.js +18 -1
- package/dist/session/log-hash.js.map +1 -1
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +1 -1
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/memory/markdown.d.ts.map +1 -1
- package/dist/store/memory/markdown.js +1 -1
- package/dist/store/memory/markdown.js.map +1 -1
- package/dist/store/memory/operation-lock.d.ts +20 -4
- package/dist/store/memory/operation-lock.d.ts.map +1 -1
- package/dist/store/memory/operation-lock.js +235 -58
- package/dist/store/memory/operation-lock.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +169 -16
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +10 -4
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +35 -0
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +512 -67
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts +1 -0
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +65 -28
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts +2 -0
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +94 -40
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.d.ts +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +34 -7
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/search-support.d.ts +44 -0
- package/dist/tools/builtins/search-support.d.ts.map +1 -0
- package/dist/tools/builtins/search-support.js +89 -0
- package/dist/tools/builtins/search-support.js.map +1 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts +2 -0
- package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job-bounds.js +3 -1
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +13 -2
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +14 -5
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/turn/reporter.d.ts.map +1 -1
- package/dist/turn/reporter.js +11 -0
- package/dist/turn/reporter.js.map +1 -1
- package/dist/types/agent/query.d.ts +2 -0
- package/dist/types/agent/query.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +129 -13
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/message/index.d.ts +1 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +1 -0
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +24 -0
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +4 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +19 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +7 -0
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -1
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +15 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +6 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +38 -1
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/events.d.ts +34 -0
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/records.d.ts +298 -34
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +35 -1
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/session/stop-reason.d.ts +11 -0
- package/dist/types/session/stop-reason.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +30 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +8 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +1 -0
- package/src/bridge/a2a/mapper.ts +19 -0
- package/src/bridge/acp/update.ts +6 -1
- package/src/bridge/sse/mapper.ts +13 -0
- package/src/compaction/context-window.ts +163 -2
- package/src/constants/continuation.ts +13 -0
- package/src/contracts/session/api.ts +6 -0
- package/src/execution/workflow/index.ts +14 -1
- package/src/execution/workflow/journal.ts +161 -11
- package/src/execution/workflow/prelude.ts +51 -8
- package/src/execution/workflow/resume.ts +313 -0
- package/src/execution/workflow/runtime.ts +127 -9
- package/src/execution/workflow/types.ts +109 -1
- package/src/index.ts +17 -0
- package/src/manager/session/turn-recorder.ts +1 -0
- package/src/plugin/compat.ts +173 -0
- package/src/plugin/loader.ts +7 -1
- package/src/pricing/index.ts +2 -1
- package/src/process/kill-tree.ts +106 -4
- package/src/prompt/coding-agent-doctrine.ts +9 -1
- package/src/provider/collect-chat-completion.ts +3 -0
- package/src/provider/fallback.ts +17 -0
- package/src/provider/idle-timeout.ts +9 -0
- package/src/provider/mock.ts +19 -9
- package/src/provider/model-window-suffix.ts +85 -0
- package/src/provider/retry.ts +9 -0
- package/src/public-runtime.ts +21 -2
- package/src/public-types.ts +1 -0
- package/src/registry/command/kernel-commands.ts +1 -32
- package/src/runtime/jobs/awaited-jobs.ts +11 -0
- package/src/runtime/jobs/host-exit-finalizer.ts +67 -0
- package/src/runtime/jobs/liveness.ts +144 -0
- package/src/runtime/jobs/registry.ts +114 -2
- package/src/runtime/jobs/wake-budget.ts +55 -0
- package/src/runtime/query/detached-calls.ts +135 -0
- package/src/runtime/query/executor.ts +92 -10
- package/src/runtime/query/index.ts +65 -7
- package/src/runtime/query/iteration/effort-clamp.ts +46 -0
- package/src/runtime/query/iteration/index.ts +260 -6
- package/src/runtime/query/iteration/outstanding-work.ts +12 -3
- package/src/runtime/query/iteration/phases/context.ts +9 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +73 -8
- package/src/runtime/query/iteration/stream-turn.ts +5 -0
- package/src/runtime/query/session-storage.ts +8 -3
- package/src/runtime/query/steering.ts +77 -6
- package/src/runtime/query/tooling.ts +2 -0
- package/src/runtime/system-events.ts +12 -1
- package/src/sandbox/denial.ts +79 -0
- package/src/sandbox/file-walk-program.ts +32 -13
- package/src/sandbox/file-walk.ts +75 -12
- package/src/sandbox/ignore-matcher.ts +46 -0
- package/src/sandbox/ignore-source.ts +220 -0
- package/src/sandbox/provider/local.ts +11 -1
- package/src/scheduler/completion-inbox.ts +1 -0
- package/src/session/log-hash.ts +21 -0
- package/src/store/memory/disk.ts +1 -0
- package/src/store/memory/markdown.ts +1 -0
- package/src/store/memory/operation-lock.ts +288 -57
- package/src/store/session-index/sqlite.ts +171 -16
- package/src/tools/builtins/bash.ts +11 -4
- package/src/tools/builtins/computer-use.ts +593 -68
- package/src/tools/builtins/glob.ts +79 -32
- package/src/tools/builtins/grep.ts +107 -43
- package/src/tools/builtins/job.ts +42 -12
- package/src/tools/builtins/search-support.ts +107 -0
- package/src/tools/builtins/wait-for-job-bounds.ts +5 -1
- package/src/tools/builtins/wait-for-job.ts +14 -2
- package/src/tools/command-shell.ts +13 -5
- package/src/turn/reporter.ts +12 -0
- package/src/types/agent/query.ts +2 -0
- package/src/types/computer-use/index.ts +157 -15
- package/src/types/message/index.ts +5 -3
- package/src/types/plugin/index.ts +8 -0
- package/src/types/provider/chat.ts +20 -0
- package/src/types/provider/config.ts +7 -0
- package/src/types/provider/index.ts +1 -0
- package/src/types/provider/interface.ts +20 -0
- package/src/types/provider/stream.ts +6 -0
- package/src/types/sandbox/index.ts +40 -1
- package/src/types/session/events.ts +65 -5
- package/src/types/session/records.ts +39 -2
- package/src/types/session/stop-reason.ts +11 -0
- package/src/types/tool/index.ts +30 -0
- package/src/types/tool/presentation.ts +8 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The ignore-file matcher, as plain JavaScript source text.
|
|
3
|
+
*
|
|
4
|
+
* One implementation serves two runtimes. The host walker evaluates this text
|
|
5
|
+
* once (see `ignore-matcher.ts`); the guest program (`file-walk-program.ts`)
|
|
6
|
+
* embeds the same text, because that program travels as a single `node -e`
|
|
7
|
+
* argument with stdin closed and cannot import a package. Keeping it as
|
|
8
|
+
* source text, not a serialised function, means a host bundler cannot rewrite
|
|
9
|
+
* it, and the two walks cannot drift apart.
|
|
10
|
+
*
|
|
11
|
+
* Rules follow the gitignore format: `#` comments, `\#` and `\!` escapes,
|
|
12
|
+
* unescaped trailing spaces dropped, `!` negation, a leading or inner `/`
|
|
13
|
+
* anchors a rule to the file that holds it, a trailing `/` matches
|
|
14
|
+
* directories only, and `*`, `?`, `[...]`, `**` as git defines them. A deeper
|
|
15
|
+
* file beats a shallower one, `.ignore` beats `.gitignore` in the same
|
|
16
|
+
* directory, and the last matching line of a file wins. A rule this matcher
|
|
17
|
+
* does not understand is dropped (an unclosed `[`, or more than three
|
|
18
|
+
* separate `*` in one rule, which could backtrack for seconds), so a visible
|
|
19
|
+
* file is never hidden by one.
|
|
20
|
+
*
|
|
21
|
+
* Nothing here is allowed to contain a backtick or a `${`: it lives inside a
|
|
22
|
+
* template literal. Every helper is prefixed `ign` so that, inlined into the
|
|
23
|
+
* guest program, it cannot collide with that program's own names.
|
|
24
|
+
*/
|
|
25
|
+
export const IGNORE_SOURCE = String.raw`
|
|
26
|
+
const IGN_MAX_BYTES = 262144;
|
|
27
|
+
const IGN_MAX_RULES = 10000;
|
|
28
|
+
const IGN_MAX_PATTERN = 1024;
|
|
29
|
+
const IGN_MAX_STARS = 3;
|
|
30
|
+
const IGN_VCS = ['.git', '.svn', '.hg', '.bzr', '.jj', '.sl'];
|
|
31
|
+
const IGN_POSIX_CLASSES = {
|
|
32
|
+
alpha: 'a-zA-Z', digit: '0-9', alnum: 'a-zA-Z0-9', upper: 'A-Z', lower: 'a-z',
|
|
33
|
+
space: ' \\t\\n\\r\\f\\v', punct: '!-\\/:-@\\[-\`{-~', xdigit: '0-9A-Fa-f',
|
|
34
|
+
};
|
|
35
|
+
function ignEscape(c) { return /[\\^$.*+?()[\]{}|\/-]/.test(c) ? '\\' + c : c; }
|
|
36
|
+
function ignClass(body) {
|
|
37
|
+
let negate = false;
|
|
38
|
+
if (body[0] === '!' || body[0] === '^') { negate = true; body = body.slice(1); }
|
|
39
|
+
let out = '';
|
|
40
|
+
for (let i = 0; i < body.length; i++) {
|
|
41
|
+
const c = body[i];
|
|
42
|
+
if (c === '[' && body[i + 1] === ':') {
|
|
43
|
+
const end = body.indexOf(':]', i + 2);
|
|
44
|
+
const name = end < 0 ? '' : body.slice(i + 2, end);
|
|
45
|
+
if (IGN_POSIX_CLASSES[name]) { out += IGN_POSIX_CLASSES[name]; i = end + 1; continue; }
|
|
46
|
+
}
|
|
47
|
+
if (c === '\\') { i++; if (i < body.length) out += ignEscape(body[i]); continue; }
|
|
48
|
+
if (c === '-') { out += (out === '' || i === body.length - 1) ? '\\-' : '-'; continue; }
|
|
49
|
+
out += (c === '[' || c === ']' || c === '^') ? '\\' + c : c;
|
|
50
|
+
}
|
|
51
|
+
if (out === '') return null;
|
|
52
|
+
return '[' + (negate ? '^/' : '') + out + ']';
|
|
53
|
+
}
|
|
54
|
+
function ignTranslate(p) {
|
|
55
|
+
let out = '';
|
|
56
|
+
let i = 0;
|
|
57
|
+
let stars = 0;
|
|
58
|
+
while (i < p.length) {
|
|
59
|
+
const c = p[i];
|
|
60
|
+
if (c === '\\') {
|
|
61
|
+
if (i + 1 >= p.length) return null;
|
|
62
|
+
out += ignEscape(p[i + 1]); i += 2; continue;
|
|
63
|
+
}
|
|
64
|
+
if (c === '*') {
|
|
65
|
+
let j = i;
|
|
66
|
+
while (p[j] === '*') j++;
|
|
67
|
+
if (j - i >= 2 && (i === 0 || p[i - 1] === '/') && (j === p.length || p[j] === '/')) {
|
|
68
|
+
if (j === p.length) out += '.*';
|
|
69
|
+
else { out += '(?:.*/)?'; j++; }
|
|
70
|
+
i = j; continue;
|
|
71
|
+
}
|
|
72
|
+
stars++;
|
|
73
|
+
out += '[^/]*'; i = j; continue;
|
|
74
|
+
}
|
|
75
|
+
if (c === '?') { out += '[^/]'; i++; continue; }
|
|
76
|
+
if (c === '[') {
|
|
77
|
+
let j = i + 1;
|
|
78
|
+
if (p[j] === '!' || p[j] === '^') j++;
|
|
79
|
+
if (p[j] === ']') j++;
|
|
80
|
+
while (j < p.length && p[j] !== ']') { if (p[j] === '\\') j++; j++; }
|
|
81
|
+
if (j >= p.length) return null;
|
|
82
|
+
const cls = ignClass(p.slice(i + 1, j));
|
|
83
|
+
if (cls === null) return null;
|
|
84
|
+
out += cls; i = j + 1; continue;
|
|
85
|
+
}
|
|
86
|
+
out += ignEscape(c); i++;
|
|
87
|
+
}
|
|
88
|
+
// Each separate star can backtrack against the others: a rule with many of
|
|
89
|
+
// them takes time exponential in their number on one long name. Real rules
|
|
90
|
+
// use one or two; a rule past the cap is dropped, like any rule not understood.
|
|
91
|
+
if (stars > IGN_MAX_STARS) return null;
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
/** One line to one rule, or null when the line holds none. */
|
|
95
|
+
function ignRule(raw) {
|
|
96
|
+
let line = raw.endsWith('\r') ? raw.slice(0, -1) : raw;
|
|
97
|
+
while (line.endsWith(' ') && !line.endsWith('\\ ')) line = line.slice(0, -1);
|
|
98
|
+
if (line === '' || line[0] === '#' || line.length > IGN_MAX_PATTERN) return null;
|
|
99
|
+
let negate = false;
|
|
100
|
+
if (line[0] === '!') { negate = true; line = line.slice(1); }
|
|
101
|
+
let dirOnly = false;
|
|
102
|
+
while (line.length > 1 && line.endsWith('/')) { dirOnly = true; line = line.slice(0, -1); }
|
|
103
|
+
if (line === '/' || line === '') return null;
|
|
104
|
+
const anchored = line.indexOf('/') >= 0;
|
|
105
|
+
if (line[0] === '/') line = line.slice(1);
|
|
106
|
+
line = line.replace(/(\*\*\/)+/g, '**/');
|
|
107
|
+
if ((line.match(/\*\*/g) || []).length > 4) return null;
|
|
108
|
+
let body;
|
|
109
|
+
try { body = ignTranslate(line); } catch (error) { return null; }
|
|
110
|
+
if (body === null) return null;
|
|
111
|
+
try {
|
|
112
|
+
return { negate, dirOnly, re: new RegExp((anchored ? '^' : '^(?:.*/)?') + body + '$') };
|
|
113
|
+
} catch (error) { return null; }
|
|
114
|
+
}
|
|
115
|
+
function ignParse(text) {
|
|
116
|
+
if (text.charCodeAt(0) === 0xFEFF) text = text.slice(1);
|
|
117
|
+
if (text.length > IGN_MAX_BYTES) text = text.slice(0, text.lastIndexOf('\n', IGN_MAX_BYTES) + 1);
|
|
118
|
+
const rules = [];
|
|
119
|
+
for (const line of text.split('\n')) {
|
|
120
|
+
const rule = ignRule(line);
|
|
121
|
+
if (rule) rules.push(rule);
|
|
122
|
+
if (rules.length >= IGN_MAX_RULES) break;
|
|
123
|
+
}
|
|
124
|
+
return rules;
|
|
125
|
+
}
|
|
126
|
+
/** 0: no rule matches. 1: ignored. 2: re-included. The last matching rule wins. */
|
|
127
|
+
function ignDecide(rules, relative, isDirectory) {
|
|
128
|
+
for (let i = rules.length - 1; i >= 0; i--) {
|
|
129
|
+
const rule = rules[i];
|
|
130
|
+
if (rule.dirOnly && !isDirectory) continue;
|
|
131
|
+
if (rule.re.test(relative)) return rule.negate ? 2 : 1;
|
|
132
|
+
}
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The layered rules for one walk. The caller enters a directory before it
|
|
137
|
+
* reads it and leaves it after, so the layers follow the depth-first stack.
|
|
138
|
+
* deps: fs (promises), path, extraFiles (global exclude files, host only).
|
|
139
|
+
*/
|
|
140
|
+
function ignCreate(deps) {
|
|
141
|
+
const fs = deps.fs;
|
|
142
|
+
const path = deps.path;
|
|
143
|
+
const layers = [];
|
|
144
|
+
const frames = [];
|
|
145
|
+
let ancestorsInRepo = false;
|
|
146
|
+
const posix = value => path.sep === '/' ? value : value.split(path.sep).join('/');
|
|
147
|
+
const lstat = async file => { try { return await fs.lstat(file); } catch (error) { return null; } };
|
|
148
|
+
const load = async file => {
|
|
149
|
+
const info = await lstat(file);
|
|
150
|
+
if (!info || !info.isFile() || info.size > IGN_MAX_BYTES * 4) return [];
|
|
151
|
+
try { return ignParse(await fs.readFile(file, 'utf8')); } catch (error) { return []; }
|
|
152
|
+
};
|
|
153
|
+
const loadDirectory = async (directory, inRepo) => {
|
|
154
|
+
const rules = [];
|
|
155
|
+
if (inRepo) rules.push(...await load(path.join(directory, '.gitignore')));
|
|
156
|
+
rules.push(...await load(path.join(directory, '.ignore')));
|
|
157
|
+
return rules;
|
|
158
|
+
};
|
|
159
|
+
const push = (directory, rules) => {
|
|
160
|
+
layers.push({ base: posix(directory).replace(/\/$/, ''), rules });
|
|
161
|
+
};
|
|
162
|
+
return {
|
|
163
|
+
/** Find the enclosing repository and load the layers above the root. */
|
|
164
|
+
async init(root) {
|
|
165
|
+
let directory = root;
|
|
166
|
+
let repo = null;
|
|
167
|
+
for (;;) {
|
|
168
|
+
const info = await lstat(path.join(directory, '.git'));
|
|
169
|
+
if (info) { repo = { directory, isDirectory: info.isDirectory() }; break; }
|
|
170
|
+
const parent = path.dirname(directory);
|
|
171
|
+
if (parent === directory) break;
|
|
172
|
+
directory = parent;
|
|
173
|
+
}
|
|
174
|
+
if (!repo || repo.directory === root) return;
|
|
175
|
+
ancestorsInRepo = true;
|
|
176
|
+
const chain = [];
|
|
177
|
+
for (let up = path.dirname(root); ; up = path.dirname(up)) {
|
|
178
|
+
chain.unshift(up);
|
|
179
|
+
if (up === repo.directory || path.dirname(up) === up) break;
|
|
180
|
+
}
|
|
181
|
+
for (const [index, directory] of chain.entries()) {
|
|
182
|
+
const rules = [];
|
|
183
|
+
if (index === 0) {
|
|
184
|
+
for (const file of deps.extraFiles || []) rules.push(...await load(file));
|
|
185
|
+
if (repo.isDirectory) rules.push(...await load(path.join(directory, '.git', 'info', 'exclude')));
|
|
186
|
+
}
|
|
187
|
+
rules.push(...await loadDirectory(directory, true));
|
|
188
|
+
push(directory, rules);
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
async enter(directory) {
|
|
192
|
+
const parentInRepo = frames.length ? frames[frames.length - 1] : ancestorsInRepo;
|
|
193
|
+
let inRepo = parentInRepo;
|
|
194
|
+
const rules = [];
|
|
195
|
+
if (!parentInRepo) {
|
|
196
|
+
const info = await lstat(path.join(directory, '.git'));
|
|
197
|
+
if (info) {
|
|
198
|
+
inRepo = true;
|
|
199
|
+
for (const file of deps.extraFiles || []) rules.push(...await load(file));
|
|
200
|
+
if (info.isDirectory()) rules.push(...await load(path.join(directory, '.git', 'info', 'exclude')));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
rules.push(...await loadDirectory(directory, inRepo));
|
|
204
|
+
frames.push(inRepo);
|
|
205
|
+
push(directory, rules);
|
|
206
|
+
},
|
|
207
|
+
leave() { frames.pop(); layers.pop(); },
|
|
208
|
+
isIgnored(absolute, isDirectory) {
|
|
209
|
+
const target = posix(absolute);
|
|
210
|
+
for (let i = layers.length - 1; i >= 0; i--) {
|
|
211
|
+
const layer = layers[i];
|
|
212
|
+
if (layer.rules.length === 0 || !target.startsWith(layer.base + '/')) continue;
|
|
213
|
+
const decision = ignDecide(layer.rules, target.slice(layer.base.length + 1), isDirectory);
|
|
214
|
+
if (decision) return decision === 1;
|
|
215
|
+
}
|
|
216
|
+
return false;
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
`
|
|
@@ -14,6 +14,7 @@ import { tmpdir } from 'node:os'
|
|
|
14
14
|
import { dirname, isAbsolute, join, parse, resolve } from 'node:path'
|
|
15
15
|
import { NAMZU } from '../../constants/telemetry/index.js'
|
|
16
16
|
import { SCOPE_ATTRIBUTE } from '../../utils/log/types.js'
|
|
17
|
+
import { attributeSandboxFailure } from '../denial.js'
|
|
17
18
|
|
|
18
19
|
import {
|
|
19
20
|
SANDBOX_DEFAULT_TIMEOUT_MS,
|
|
@@ -1084,8 +1085,16 @@ class LocalSandbox implements Sandbox {
|
|
|
1084
1085
|
terminate('SIGKILL')
|
|
1085
1086
|
}
|
|
1086
1087
|
const timedOut = cancellation === 'deadline'
|
|
1088
|
+
const exitCode = code ?? (timedOut ? 124 : 1)
|
|
1089
|
+
const attribution = attributeSandboxFailure({
|
|
1090
|
+
environment: this.environment,
|
|
1091
|
+
exitCode,
|
|
1092
|
+
stderr: stderr.text,
|
|
1093
|
+
timedOut,
|
|
1094
|
+
allowedRoots: [...this.roots, tmpdir(), '/tmp', '/var/tmp', '/dev'],
|
|
1095
|
+
})
|
|
1087
1096
|
resolvePromise({
|
|
1088
|
-
exitCode
|
|
1097
|
+
exitCode,
|
|
1089
1098
|
stdout: stdout.text,
|
|
1090
1099
|
stderr: stderr.text,
|
|
1091
1100
|
signal: signal ?? undefined,
|
|
@@ -1096,6 +1105,7 @@ class LocalSandbox implements Sandbox {
|
|
|
1096
1105
|
// gone. The tool layer already renders the flag.
|
|
1097
1106
|
stdoutTruncated: stdout.truncated,
|
|
1098
1107
|
stderrTruncated: stderr.truncated,
|
|
1108
|
+
...(attribution !== undefined ? { attribution } : {}),
|
|
1099
1109
|
})
|
|
1100
1110
|
})
|
|
1101
1111
|
|
|
@@ -789,6 +789,7 @@ export function formatCompletionNotification(handles: readonly TaskHandle[]): st
|
|
|
789
789
|
: []),
|
|
790
790
|
...(handle.result?.stopReason ? [`stop_reason: ${handle.result.stopReason}`] : []),
|
|
791
791
|
...(durationMs !== undefined ? [`duration_ms: ${durationMs}`] : []),
|
|
792
|
+
...(handle.completedAt ? [`finished_at: ${new Date(handle.completedAt).toISOString()}`] : []),
|
|
792
793
|
'',
|
|
793
794
|
body,
|
|
794
795
|
// Outside the envelope, deliberately: this sentence is an
|
package/src/session/log-hash.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import {
|
|
3
|
+
IgnorableRecordSchema,
|
|
3
4
|
SESSION_RECORD_MAX_BYTES,
|
|
4
5
|
type SessionRecord,
|
|
5
6
|
SessionRecordSchema,
|
|
@@ -99,6 +100,18 @@ export function parseSessionLogLine(line: string | Uint8Array): ParsedSessionLog
|
|
|
99
100
|
)
|
|
100
101
|
}
|
|
101
102
|
const parsed = SessionRecordSchema.safeParse(value)
|
|
103
|
+
if (!parsed.success && isFlaggedIgnorable(value)) {
|
|
104
|
+
const ignorable = IgnorableRecordSchema.safeParse(value)
|
|
105
|
+
if (ignorable.success) {
|
|
106
|
+
// Typed as a record so the chain can carry it; its `type` is one no
|
|
107
|
+
// consumer matches, so it never moves a fold.
|
|
108
|
+
return {
|
|
109
|
+
record: ignorable.data as unknown as SessionRecord,
|
|
110
|
+
length: bytes.byteLength,
|
|
111
|
+
sha256: recordSha256(bytes),
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
102
115
|
if (!parsed.success) {
|
|
103
116
|
throw new SessionLogLineError(
|
|
104
117
|
'not-a-record',
|
|
@@ -113,3 +126,11 @@ export function parseSessionLogLine(line: string | Uint8Array): ParsedSessionLog
|
|
|
113
126
|
sha256: recordSha256(bytes),
|
|
114
127
|
}
|
|
115
128
|
}
|
|
129
|
+
|
|
130
|
+
function isFlaggedIgnorable(value: unknown): boolean {
|
|
131
|
+
return (
|
|
132
|
+
typeof value === 'object' &&
|
|
133
|
+
value !== null &&
|
|
134
|
+
(value as { ignorable?: unknown }).ignorable === true
|
|
135
|
+
)
|
|
136
|
+
}
|
package/src/store/memory/disk.ts
CHANGED
|
@@ -261,6 +261,7 @@ export class DiskMemoryStore implements ConditionalMemoryStore {
|
|
|
261
261
|
const release = await acquireMemoryOperationLock(
|
|
262
262
|
join(dirname(location.indexPath), 'operation.lock'),
|
|
263
263
|
this.lockTimeoutMs,
|
|
264
|
+
{ logger: this.log },
|
|
264
265
|
)
|
|
265
266
|
try {
|
|
266
267
|
await this.reloadIndex(location)
|
|
@@ -418,6 +418,7 @@ export class MarkdownMemoryStore implements ConditionalMemoryStore {
|
|
|
418
418
|
const release = await acquireMemoryOperationLock(
|
|
419
419
|
join(dir, 'operation.lock'),
|
|
420
420
|
this.lockTimeoutMs,
|
|
421
|
+
{ logger: this.log },
|
|
421
422
|
)
|
|
422
423
|
try {
|
|
423
424
|
const { loaded, superseded } = await this.load(dir, mode.importing ?? false)
|