@namzu/sdk 58.1.1 → 60.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 +124 -0
- package/dist/account/binding.d.ts +20 -0
- package/dist/account/binding.d.ts.map +1 -0
- package/dist/account/binding.js +27 -0
- package/dist/account/binding.js.map +1 -0
- package/dist/account/index.d.ts +9 -0
- package/dist/account/index.d.ts.map +1 -0
- package/dist/account/index.js +5 -0
- package/dist/account/index.js.map +1 -0
- package/dist/account/lock.d.ts +33 -0
- package/dist/account/lock.d.ts.map +1 -0
- package/dist/account/lock.js +170 -0
- package/dist/account/lock.js.map +1 -0
- package/dist/account/registry.d.ts +21 -0
- package/dist/account/registry.d.ts.map +1 -0
- package/dist/account/registry.js +340 -0
- package/dist/account/registry.js.map +1 -0
- package/dist/account/types.d.ts +124 -0
- package/dist/account/types.d.ts.map +1 -0
- package/dist/account/types.js +35 -0
- package/dist/account/types.js.map +1 -0
- 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/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/pals/communication/ingress-schema.d.ts +38 -38
- package/dist/peers/record.d.ts +98 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +17 -0
- package/dist/peers/record.js.map +1 -1
- package/dist/peers/registry.d.ts.map +1 -1
- package/dist/peers/registry.js +2 -2
- package/dist/peers/registry.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/errors.d.ts.map +1 -1
- package/dist/provider/errors.js +25 -2
- package/dist/provider/errors.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 +77 -0
- package/dist/provider/model-window-suffix.js.map +1 -0
- package/dist/provider/token-budget.d.ts.map +1 -1
- package/dist/provider/token-budget.js +9 -1
- package/dist/provider/token-budget.js.map +1 -1
- package/dist/public-runtime.d.ts +6 -3
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +6 -4
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-types.d.ts +3 -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 +11 -3
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +100 -8
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +20 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +31 -5
- 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 +11 -3
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +7 -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/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/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/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/errors/catalog.d.ts.map +1 -1
- package/dist/types/errors/catalog.js +6 -0
- package/dist/types/errors/catalog.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/errors.d.ts +7 -0
- package/dist/types/provider/errors.d.ts.map +1 -1
- package/dist/types/provider/errors.js +27 -3
- package/dist/types/provider/errors.js.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/records.d.ts +479 -1
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +45 -1
- package/dist/types/session/records.js.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/account/binding.ts +43 -0
- package/src/account/index.ts +32 -0
- package/src/account/lock.ts +184 -0
- package/src/account/registry.ts +413 -0
- package/src/account/types.ts +137 -0
- package/src/compaction/context-window.ts +163 -2
- 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/peers/record.ts +18 -0
- package/src/peers/registry.ts +2 -2
- 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/errors.ts +27 -1
- package/src/provider/model-window-suffix.ts +84 -0
- package/src/provider/token-budget.ts +9 -3
- package/src/public-runtime.ts +38 -2
- package/src/public-types.ts +16 -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 +102 -12
- package/src/runtime/query/index.ts +50 -7
- package/src/runtime/query/iteration/outstanding-work.ts +12 -3
- package/src/runtime/query/iteration/phases/context.ts +7 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +73 -8
- 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/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/types/computer-use/index.ts +157 -15
- package/src/types/errors/catalog.ts +6 -0
- package/src/types/plugin/index.ts +8 -0
- package/src/types/provider/errors.ts +40 -3
- package/src/types/sandbox/index.ts +40 -1
- package/src/types/session/records.ts +52 -2
- package/src/types/tool/index.ts +30 -0
- package/src/types/tool/presentation.ts +8 -0
|
@@ -29,6 +29,94 @@
|
|
|
29
29
|
* accumulates every release. Until a driver does that, an entry here is
|
|
30
30
|
* only ever as fresh as the day someone checked it.
|
|
31
31
|
*/
|
|
32
|
+
/** The window an id declares with the `[1m]` suffix, and the ceiling `NAMZU_AUTO_COMPACT_WINDOW` accepts. */
|
|
33
|
+
export const ONE_MILLION_WINDOW_TOKENS = 1_000_000;
|
|
34
|
+
/** The window a model is held to when `NAMZU_DISABLE_1M_CONTEXT` is on. */
|
|
35
|
+
export const DISABLED_ONE_MILLION_WINDOW_CAP_TOKENS = 200_000;
|
|
36
|
+
const WINDOW_SUFFIX = /\[1m\]$/i;
|
|
37
|
+
/**
|
|
38
|
+
* A model id may end in `[1m]` (any case) to declare a one-million-token
|
|
39
|
+
* window, whether or not the id is recognised. The suffix is a marker for
|
|
40
|
+
* Namzu, never part of the vendor's name: strip it with this before an id
|
|
41
|
+
* reaches a driver or a wire.
|
|
42
|
+
*/
|
|
43
|
+
export function splitModelWindowSuffix(model) {
|
|
44
|
+
const match = WINDOW_SUFFIX.exec(model);
|
|
45
|
+
if (!match)
|
|
46
|
+
return { model, declaresOneMillion: false };
|
|
47
|
+
return { model: model.slice(0, match.index), declaresOneMillion: true };
|
|
48
|
+
}
|
|
49
|
+
/** The id with any `[1m]` suffix removed. */
|
|
50
|
+
export function stripModelWindowSuffix(model) {
|
|
51
|
+
return splitModelWindowSuffix(model).model;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `NAMZU_DISABLE_1M_CONTEXT` (1, true, yes or on): the suffix is still
|
|
55
|
+
* stripped but declares nothing, and no window above 200,000 tokens is
|
|
56
|
+
* assumed for a model whose window comes from a driver or the table.
|
|
57
|
+
*/
|
|
58
|
+
export function oneMillionWindowDisabled(env = process.env) {
|
|
59
|
+
const value = env.NAMZU_DISABLE_1M_CONTEXT?.trim().toLowerCase();
|
|
60
|
+
return value === '1' || value === 'true' || value === 'yes' || value === 'on';
|
|
61
|
+
}
|
|
62
|
+
/** Smallest and largest window `NAMZU_AUTO_COMPACT_WINDOW` can name. */
|
|
63
|
+
export const AUTO_COMPACT_WINDOW_MIN_TOKENS = 100_000;
|
|
64
|
+
export const AUTO_COMPACT_WINDOW_MAX_TOKENS = ONE_MILLION_WINDOW_TOKENS;
|
|
65
|
+
/**
|
|
66
|
+
* Read an automatic-summary window the way people write one: a plain number
|
|
67
|
+
* (`200000`) or one with a `k` or `m` suffix (`786k`, `1m`, `1.5m`). Anything
|
|
68
|
+
* under 100,000 is `below_minimum`, over 1,000,000 `above_maximum`, and
|
|
69
|
+
* something that is not a size at all `unusable`.
|
|
70
|
+
*/
|
|
71
|
+
export function parseAutoCompactWindow(raw) {
|
|
72
|
+
const text = raw.trim();
|
|
73
|
+
const last = text.slice(-1).toLowerCase();
|
|
74
|
+
const scale = last === 'm' ? 1_000_000 : last === 'k' ? 1_000 : undefined;
|
|
75
|
+
const digits = scale === undefined ? text : text.slice(0, -1);
|
|
76
|
+
const valid = scale === undefined ? /^\+?\d+$/ : /^\+?\d+(\.\d+)?$/;
|
|
77
|
+
const value = valid.test(digits) ? Number(digits) * (scale ?? 1) : Number.NaN;
|
|
78
|
+
if (Number.isNaN(value) || value < 1)
|
|
79
|
+
return { kind: 'unusable' };
|
|
80
|
+
if (value < AUTO_COMPACT_WINDOW_MIN_TOKENS)
|
|
81
|
+
return {
|
|
82
|
+
kind: 'below_minimum',
|
|
83
|
+
tokens: Math.min(AUTO_COMPACT_WINDOW_MIN_TOKENS - 1, Math.round(value)),
|
|
84
|
+
};
|
|
85
|
+
if (value > AUTO_COMPACT_WINDOW_MAX_TOKENS)
|
|
86
|
+
return { kind: 'above_maximum' };
|
|
87
|
+
return { kind: 'in_range', tokens: Math.round(value) };
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The window to use for a written size, and a one-line warning when what was
|
|
91
|
+
* written had to be changed: below 100,000 reads as 100,000, above 1,000,000
|
|
92
|
+
* as 1,000,000, and a non-size is ignored (`tokens` undefined). `source`
|
|
93
|
+
* names where it was written, e.g. `NAMZU_AUTO_COMPACT_WINDOW`.
|
|
94
|
+
*/
|
|
95
|
+
export function resolveAutoCompactWindowSetting(raw, source) {
|
|
96
|
+
const text = String(raw);
|
|
97
|
+
const parsed = parseAutoCompactWindow(text);
|
|
98
|
+
const shown = `${source}="${text.slice(0, 32).replace(/[^\w.,+ $%{}=;-]+/g, '?')}${text.length > 32 ? '\u2026' : ''}"`;
|
|
99
|
+
const advice = 'Set it to a size from 100k to 1M, such as 200k or 200000, or unset it.';
|
|
100
|
+
switch (parsed.kind) {
|
|
101
|
+
case 'in_range':
|
|
102
|
+
return { tokens: parsed.tokens };
|
|
103
|
+
case 'below_minimum':
|
|
104
|
+
return {
|
|
105
|
+
tokens: AUTO_COMPACT_WINDOW_MIN_TOKENS,
|
|
106
|
+
warning: `${shown} reads as ${parsed.tokens.toLocaleString('en-US')} tokens, so Namzu treats it as the 100k minimum. ${advice}`,
|
|
107
|
+
};
|
|
108
|
+
case 'above_maximum':
|
|
109
|
+
return {
|
|
110
|
+
tokens: AUTO_COMPACT_WINDOW_MAX_TOKENS,
|
|
111
|
+
warning: `${shown} is too large, so Namzu treats it as the 1M maximum. ${advice}`,
|
|
112
|
+
};
|
|
113
|
+
case 'unusable':
|
|
114
|
+
return {
|
|
115
|
+
tokens: undefined,
|
|
116
|
+
warning: `${shown} isn't a usable size, so Namzu ignores it. ${advice}`,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
32
120
|
/**
|
|
33
121
|
* Conservative default for a model we do not recognise.
|
|
34
122
|
*
|
|
@@ -83,8 +171,29 @@ const WINDOWS = [
|
|
|
83
171
|
['qwen', 32_768],
|
|
84
172
|
['mistral-large', 128_000],
|
|
85
173
|
['mixtral', 32_768],
|
|
174
|
+
// The current DeepSeek models document a 1M window
|
|
175
|
+
// (https://api-docs.deepseek.com/quick_start/pricing), listed per id: a
|
|
176
|
+
// gateway can serve a derivative under a name that merely starts like one
|
|
177
|
+
// (a fine-tune, a distill), and nothing says it keeps the parent's window.
|
|
178
|
+
// Over-estimating ends a turn on a provider rejection; under-estimating
|
|
179
|
+
// costs a summary. So an id not named here falls to the bare `deepseek`
|
|
180
|
+
// row below, the 64k the older ids (chat, reasoner, R1 distills) had. The
|
|
181
|
+
// three ids are matched whole (see `DEEPSEEK_ONE_MILLION_IDS`), never by
|
|
182
|
+
// substring.
|
|
86
183
|
['deepseek', 64_000],
|
|
87
184
|
];
|
|
185
|
+
/** DeepSeek ids documented at a 1M window; matched exactly, not by substring. */
|
|
186
|
+
const DEEPSEEK_ONE_MILLION_IDS = new Set([
|
|
187
|
+
'deepseek-v4-flash',
|
|
188
|
+
'deepseek-v4-pro',
|
|
189
|
+
'deepseek-flash',
|
|
190
|
+
]);
|
|
191
|
+
/** The id with a gateway prefix (`deepseek/`) and a `:tag` (`:free`) removed. */
|
|
192
|
+
function bareModelName(id) {
|
|
193
|
+
const afterSlash = id.slice(id.lastIndexOf('/') + 1);
|
|
194
|
+
const colon = afterSlash.indexOf(':');
|
|
195
|
+
return colon === -1 ? afterSlash : afterSlash.slice(0, colon);
|
|
196
|
+
}
|
|
88
197
|
const SORTED = [...WINDOWS].sort((a, b) => b[0].length - a[0].length);
|
|
89
198
|
/**
|
|
90
199
|
* Best-effort context window for a model id, or `undefined` when the id is
|
|
@@ -95,7 +204,20 @@ const SORTED = [...WINDOWS].sort((a, b) => b[0].length - a[0].length);
|
|
|
95
204
|
export function lookupContextWindow(model) {
|
|
96
205
|
if (!model)
|
|
97
206
|
return undefined;
|
|
98
|
-
const
|
|
207
|
+
const { declaresOneMillion } = splitModelWindowSuffix(model);
|
|
208
|
+
const known = lookupBareContextWindow(model);
|
|
209
|
+
if (declaresOneMillion && !oneMillionWindowDisabled()) {
|
|
210
|
+
return Math.max(known ?? 0, ONE_MILLION_WINDOW_TOKENS);
|
|
211
|
+
}
|
|
212
|
+
return known;
|
|
213
|
+
}
|
|
214
|
+
/** The table's answer for an id with any `[1m]` suffix ignored. */
|
|
215
|
+
function lookupBareContextWindow(model) {
|
|
216
|
+
if (!model)
|
|
217
|
+
return undefined;
|
|
218
|
+
const id = stripModelWindowSuffix(model).toLowerCase();
|
|
219
|
+
if (DEEPSEEK_ONE_MILLION_IDS.has(bareModelName(id)))
|
|
220
|
+
return ONE_MILLION_WINDOW_TOKENS;
|
|
99
221
|
for (const [prefix, tokens] of SORTED) {
|
|
100
222
|
if (id.includes(prefix))
|
|
101
223
|
return tokens;
|
|
@@ -162,13 +284,30 @@ providerReported) {
|
|
|
162
284
|
if (configured !== undefined && configured > 0) {
|
|
163
285
|
return { tokens: configured, source: 'config' };
|
|
164
286
|
}
|
|
287
|
+
const { declaresOneMillion } = splitModelWindowSuffix(model ?? '');
|
|
288
|
+
const disabled = oneMillionWindowDisabled();
|
|
289
|
+
const base = resolveUndeclaredWindow(model, providerReported);
|
|
290
|
+
// `[1m]` raises the window to at least a million (reported as 'model-table':
|
|
291
|
+
// the id itself is the fact), never lowers one a
|
|
292
|
+
// driver or the table already puts higher.
|
|
293
|
+
if (declaresOneMillion && !disabled && base.tokens < ONE_MILLION_WINDOW_TOKENS) {
|
|
294
|
+
return { tokens: ONE_MILLION_WINDOW_TOKENS, source: 'model-table' };
|
|
295
|
+
}
|
|
296
|
+
// With the million-token window switched off, nothing assumed or reported
|
|
297
|
+
// for a model counts for more than 200,000.
|
|
298
|
+
if (disabled && base.tokens > DISABLED_ONE_MILLION_WINDOW_CAP_TOKENS) {
|
|
299
|
+
return { tokens: DISABLED_ONE_MILLION_WINDOW_CAP_TOKENS, source: base.source };
|
|
300
|
+
}
|
|
301
|
+
return base;
|
|
302
|
+
}
|
|
303
|
+
function resolveUndeclaredWindow(model, providerReported) {
|
|
165
304
|
if (providerReported !== undefined && providerReported > 0) {
|
|
166
305
|
return { tokens: providerReported, source: 'provider' };
|
|
167
306
|
}
|
|
168
307
|
// A driver that resolved `undefined` falls through to HERE, not to the
|
|
169
308
|
// default. "I asked and it does not know" leaves the table exactly as
|
|
170
309
|
// authoritative as it was before anyone asked.
|
|
171
|
-
const known =
|
|
310
|
+
const known = lookupBareContextWindow(model);
|
|
172
311
|
if (known !== undefined) {
|
|
173
312
|
return { tokens: known, source: 'model-table' };
|
|
174
313
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-window.js","sourceRoot":"","sources":["../../src/compaction/context-window.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAA;AAErD;;;;;GAKG;AACH,MAAM,OAAO,GAA6D;IACzE,CAAC,gBAAgB,EAAE,SAAS,CAAC;IAC7B,CAAC,eAAe,EAAE,SAAS,CAAC;IAC5B,CAAC,eAAe,EAAE,SAAS,CAAC;I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
|
export { WorkflowScriptError } from './errors.js';
|
|
2
2
|
export { FileWorkflowJournal } from './journal.js';
|
|
3
3
|
export { parseWorkflowMeta } from './meta.js';
|
|
4
|
+
export { formatWorkflowJournalLine, loadWorkflowResume, readWorkflowJournalChecked, workflowCallKey, workflowJournalLineHash, workflowJournalSeed, } from './resume.js';
|
|
5
|
+
export type { WorkflowCallIdentity } from './resume.js';
|
|
4
6
|
export { summarizeWorkflowPhases } from './phases.js';
|
|
5
7
|
export type { PhaseAgentView, PhaseRecord } from './phases.js';
|
|
6
|
-
export { resolveWorkflowLimits, WORKFLOW_HOST_CALL, WorkflowRuntime } from './runtime.js';
|
|
8
|
+
export { resolveWorkflowLimits, WORKFLOW_HOST_CALL, WorkflowRuntime, } from './runtime.js';
|
|
7
9
|
export type { WorkflowRuntimeOptions } from './runtime.js';
|
|
8
10
|
export type * from './types.js';
|
|
9
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EACN,yBAAyB,EACzB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,uBAAuB,EACvB,mBAAmB,GACnB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EACN,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GACf,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC1D,mBAAmB,YAAY,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { WorkflowScriptError } from './errors.js';
|
|
2
2
|
export { FileWorkflowJournal } from './journal.js';
|
|
3
3
|
export { parseWorkflowMeta } from './meta.js';
|
|
4
|
+
export { formatWorkflowJournalLine, loadWorkflowResume, readWorkflowJournalChecked, workflowCallKey, workflowJournalLineHash, workflowJournalSeed, } from './resume.js';
|
|
4
5
|
export { summarizeWorkflowPhases } from './phases.js';
|
|
5
|
-
export { resolveWorkflowLimits, WORKFLOW_HOST_CALL, WorkflowRuntime } from './runtime.js';
|
|
6
|
+
export { resolveWorkflowLimits, WORKFLOW_HOST_CALL, WorkflowRuntime, } from './runtime.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/execution/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/execution/workflow/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EACN,yBAAyB,EACzB,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,EACf,uBAAuB,EACvB,mBAAmB,GACnB,MAAM,aAAa,CAAA;AAEpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAErD,OAAO,EACN,qBAAqB,EACrB,kBAAkB,EAClB,eAAe,GACf,MAAM,cAAc,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { WorkflowJournal, WorkflowJournalRecord } from './types.js';
|
|
1
|
+
import type { CheckedWorkflowJournal, WorkflowJournal, WorkflowJournalReader, WorkflowJournalRecord } from './types.js';
|
|
2
2
|
export declare function sha256(text: string): string;
|
|
3
3
|
/** The first `max` UTF-16 units of `text`, never ending inside a surrogate pair. */
|
|
4
4
|
export declare function preview(text: string, max?: number): string;
|
|
@@ -6,13 +6,33 @@ export declare function preview(text: string, max?: number): string;
|
|
|
6
6
|
* A journal in a directory: `script.js` (the exact script text, mode 0600)
|
|
7
7
|
* and `journal.jsonl` (one JSON record per line, append-only). The caller
|
|
8
8
|
* chooses the directory, normally `<session>/runs/<runId>/workflow/`.
|
|
9
|
+
*
|
|
10
|
+
* Every line carries `seq` and `prev` (the hash of the line before it, the
|
|
11
|
+
* first chaining from a seed bound to the run id), so a line that was edited,
|
|
12
|
+
* removed or cut short is found when the journal is read back. One writer per
|
|
13
|
+
* file serves the whole process: a resumed pass and a late agent of the pass
|
|
14
|
+
* before it append through the same queue and the same chain, and nothing is
|
|
15
|
+
* appended after a pass's `run_finished` until the next pass starts. This
|
|
16
|
+
* assumes one process writes the file at a time, which the session lease
|
|
17
|
+
* already guarantees. A chain proves the file was not damaged or edited by
|
|
18
|
+
* accident; someone who can rewrite the whole file can rewrite the chain too.
|
|
9
19
|
*/
|
|
10
|
-
export declare class FileWorkflowJournal implements WorkflowJournal {
|
|
20
|
+
export declare class FileWorkflowJournal implements WorkflowJournal, WorkflowJournalReader {
|
|
11
21
|
private readonly dir;
|
|
22
|
+
private readonly options;
|
|
12
23
|
private ready;
|
|
13
|
-
|
|
24
|
+
private readonly file;
|
|
25
|
+
constructor(dir: string, options?: {
|
|
26
|
+
readonly runId?: string;
|
|
27
|
+
/** A secret that signs every line; see `readWorkflowJournalChecked`. */
|
|
28
|
+
readonly key?: string | Uint8Array;
|
|
29
|
+
});
|
|
14
30
|
private ensure;
|
|
15
|
-
|
|
31
|
+
/** The run id of the file's first line, learned from the file or from the first `run_started` written. */
|
|
32
|
+
private learned;
|
|
33
|
+
private runId;
|
|
34
|
+
writeScript(source: string, _sha256?: string, pass?: number): Promise<void>;
|
|
35
|
+
read(): Promise<CheckedWorkflowJournal>;
|
|
16
36
|
append(record: WorkflowJournalRecord): Promise<void>;
|
|
17
37
|
}
|
|
18
38
|
//# sourceMappingURL=journal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/journal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"journal.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/journal.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACX,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,MAAM,YAAY,CAAA;AAEnB,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAM,GAAG,MAAM,CAMvD;AA2BD;;;;;;;;;;;;;;GAcG;AACH,qBAAa,mBAAoB,YAAW,eAAe,EAAE,qBAAqB;IAKhF,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IALzB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAQ;gBAGX,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;QACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;QACvB,wEAAwE;QACxE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;KAC7B;IAKP,OAAO,CAAC,MAAM;IAKd,0GAA0G;IAC1G,OAAO,CAAC,OAAO,CAAoB;IAEnC,OAAO,CAAC,KAAK;IAmBP,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtE,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAa7C,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAgEpD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
3
|
-
import { join } from 'node:path';
|
|
2
|
+
import { mkdir, open, readFile, stat, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { basename, dirname, join, resolve } from 'node:path';
|
|
4
|
+
import { formatWorkflowJournalLine, readWorkflowJournalChecked, workflowJournalLineHash, workflowJournalSeed, } from './resume.js';
|
|
4
5
|
export function sha256(text) {
|
|
5
6
|
return createHash('sha256').update(text).digest('hex');
|
|
6
7
|
}
|
|
@@ -14,30 +15,151 @@ export function preview(text, max = 500) {
|
|
|
14
15
|
end--;
|
|
15
16
|
return `${text.slice(0, end)}…`;
|
|
16
17
|
}
|
|
18
|
+
const chains = new Map();
|
|
19
|
+
/** Records after which a crash must not lose the line: a saved result, the end of a pass, the start of one. */
|
|
20
|
+
function mustSurviveCrash(record) {
|
|
21
|
+
return (record.type === 'run_finished' ||
|
|
22
|
+
record.type === 'run_started' ||
|
|
23
|
+
(record.type === 'agent_outcome' && Object.hasOwn(record, 'result')));
|
|
24
|
+
}
|
|
17
25
|
/**
|
|
18
26
|
* A journal in a directory: `script.js` (the exact script text, mode 0600)
|
|
19
27
|
* and `journal.jsonl` (one JSON record per line, append-only). The caller
|
|
20
28
|
* chooses the directory, normally `<session>/runs/<runId>/workflow/`.
|
|
29
|
+
*
|
|
30
|
+
* Every line carries `seq` and `prev` (the hash of the line before it, the
|
|
31
|
+
* first chaining from a seed bound to the run id), so a line that was edited,
|
|
32
|
+
* removed or cut short is found when the journal is read back. One writer per
|
|
33
|
+
* file serves the whole process: a resumed pass and a late agent of the pass
|
|
34
|
+
* before it append through the same queue and the same chain, and nothing is
|
|
35
|
+
* appended after a pass's `run_finished` until the next pass starts. This
|
|
36
|
+
* assumes one process writes the file at a time, which the session lease
|
|
37
|
+
* already guarantees. A chain proves the file was not damaged or edited by
|
|
38
|
+
* accident; someone who can rewrite the whole file can rewrite the chain too.
|
|
21
39
|
*/
|
|
22
40
|
export class FileWorkflowJournal {
|
|
23
41
|
dir;
|
|
42
|
+
options;
|
|
24
43
|
ready;
|
|
25
|
-
|
|
44
|
+
file;
|
|
45
|
+
constructor(dir, options = {}) {
|
|
26
46
|
this.dir = dir;
|
|
47
|
+
this.options = options;
|
|
48
|
+
this.file = resolve(dir, 'journal.jsonl');
|
|
27
49
|
}
|
|
28
50
|
ensure() {
|
|
29
51
|
this.ready ??= mkdir(this.dir, { recursive: true, mode: 0o700 }).then(() => undefined);
|
|
30
52
|
return this.ready;
|
|
31
53
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
54
|
+
/** The run id of the file's first line, learned from the file or from the first `run_started` written. */
|
|
55
|
+
learned;
|
|
56
|
+
runId(record, text) {
|
|
57
|
+
if (this.options.runId !== undefined)
|
|
58
|
+
return this.options.runId;
|
|
59
|
+
if (record?.type === 'run_started')
|
|
60
|
+
this.learned = record.runId;
|
|
61
|
+
if (this.learned !== undefined)
|
|
62
|
+
return this.learned;
|
|
63
|
+
const first = text?.slice(0, text.indexOf('\n') < 0 ? undefined : text.indexOf('\n'));
|
|
64
|
+
if (first) {
|
|
65
|
+
try {
|
|
66
|
+
const parsed = JSON.parse(first);
|
|
67
|
+
if (parsed.type === 'run_started' && typeof parsed.runId === 'string') {
|
|
68
|
+
this.learned = parsed.runId;
|
|
69
|
+
return parsed.runId;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
// Not a record: fall back to the folder name below.
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return basename(dirname(resolve(this.dir)));
|
|
35
77
|
}
|
|
36
|
-
async
|
|
78
|
+
async writeScript(source, _sha256, pass = 1) {
|
|
37
79
|
await this.ensure();
|
|
38
|
-
|
|
39
|
-
|
|
80
|
+
const name = pass <= 1 ? 'script.js' : `script.${pass}.js`;
|
|
81
|
+
await writeFile(join(this.dir, name), source, { mode: 0o600 });
|
|
82
|
+
}
|
|
83
|
+
async read() {
|
|
84
|
+
let text;
|
|
85
|
+
try {
|
|
86
|
+
text = await readFile(this.file, 'utf8');
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error.code !== 'ENOENT')
|
|
90
|
+
throw error;
|
|
91
|
+
text = '';
|
|
92
|
+
}
|
|
93
|
+
return readWorkflowJournalChecked(text, this.runId(undefined, text), {
|
|
94
|
+
...(this.options.key !== undefined ? { key: this.options.key } : {}),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
append(record) {
|
|
98
|
+
let state = chains.get(this.file);
|
|
99
|
+
if (state === undefined) {
|
|
100
|
+
state = {
|
|
101
|
+
queue: Promise.resolve(),
|
|
102
|
+
loaded: false,
|
|
103
|
+
seq: 0,
|
|
104
|
+
prev: '',
|
|
105
|
+
needsNewline: false,
|
|
106
|
+
finished: false,
|
|
107
|
+
size: 0,
|
|
108
|
+
pending: 0,
|
|
109
|
+
};
|
|
110
|
+
chains.set(this.file, state);
|
|
111
|
+
}
|
|
112
|
+
const chain = state;
|
|
113
|
+
chain.pending++;
|
|
114
|
+
const run = chain.queue.then(async () => {
|
|
115
|
+
await this.ensure();
|
|
116
|
+
const onDisk = await stat(this.file).then((info) => info.size, () => 0);
|
|
117
|
+
if (!chain.loaded || onDisk !== chain.size) {
|
|
118
|
+
const checked = await this.read();
|
|
119
|
+
chain.seq = checked.lastSeq;
|
|
120
|
+
chain.prev = checked.lastHash;
|
|
121
|
+
chain.needsNewline = !checked.endsWithNewline;
|
|
122
|
+
chain.finished = checked.records.at(-1)?.type === 'run_finished';
|
|
123
|
+
chain.loaded = true;
|
|
124
|
+
chain.size = onDisk;
|
|
125
|
+
}
|
|
126
|
+
if (record.type === 'run_started')
|
|
127
|
+
chain.finished = false;
|
|
128
|
+
// Nothing belongs after the pass's end; a late agent of that pass is dropped here.
|
|
129
|
+
else if (chain.finished)
|
|
130
|
+
return;
|
|
131
|
+
if (chain.seq === 0)
|
|
132
|
+
chain.prev = workflowJournalSeed(this.runId(record));
|
|
133
|
+
const seq = chain.seq + 1;
|
|
134
|
+
const line = formatWorkflowJournalLine(record, seq, chain.prev, this.options.key);
|
|
135
|
+
const handle = await open(this.file, 'a', 0o600);
|
|
136
|
+
try {
|
|
137
|
+
const text = `${chain.needsNewline ? '\n' : ''}${line}\n`;
|
|
138
|
+
await handle.appendFile(text);
|
|
139
|
+
chain.size += Buffer.byteLength(text);
|
|
140
|
+
if (mustSurviveCrash(record))
|
|
141
|
+
await handle.datasync();
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
await handle.close();
|
|
145
|
+
}
|
|
146
|
+
chain.needsNewline = false;
|
|
147
|
+
chain.seq = seq;
|
|
148
|
+
chain.prev = workflowJournalLineHash(line);
|
|
149
|
+
if (record.type === 'run_finished')
|
|
150
|
+
chain.finished = true;
|
|
151
|
+
});
|
|
152
|
+
chain.queue = run
|
|
153
|
+
.catch(() => undefined)
|
|
154
|
+
.then(() => {
|
|
155
|
+
chain.pending--;
|
|
156
|
+
// A finished run keeps no state: the next append reads the file again, and
|
|
157
|
+
// what it finds (a last `run_finished`) is the same thing the state held.
|
|
158
|
+
if (chain.pending === 0 && chain.finished && chains.get(this.file) === chain) {
|
|
159
|
+
chains.delete(this.file);
|
|
160
|
+
}
|
|
40
161
|
});
|
|
162
|
+
return run;
|
|
41
163
|
}
|
|
42
164
|
}
|
|
43
165
|
//# sourceMappingURL=journal.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"journal.js","sourceRoot":"","sources":["../../../src/execution/workflow/journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"journal.js","sourceRoot":"","sources":["../../../src/execution/workflow/journal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACzE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5D,OAAO,EACN,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,mBAAmB,GACnB,MAAM,aAAa,CAAA;AAQpB,MAAM,UAAU,MAAM,CAAC,IAAY;IAClC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;AACvD,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,GAAG,GAAG,GAAG;IAC9C,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAA;IACnC,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,MAAM,IAAI,GAAG,IA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@@
|
|
|
6
6
|
export declare function preludeLineCount(config: {
|
|
7
7
|
args: unknown;
|
|
8
8
|
tokenLimit: number | null;
|
|
9
|
+
deterministic?: boolean;
|
|
9
10
|
}): number;
|
|
10
11
|
/** Source that installs the workflow globals, ready to prepend to a script body. */
|
|
11
12
|
export declare function buildPrelude(config: {
|
|
12
13
|
args: unknown;
|
|
13
14
|
tokenLimit: number | null;
|
|
15
|
+
deterministic?: boolean;
|
|
14
16
|
}): string;
|
|
15
17
|
//# sourceMappingURL=prelude.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prelude.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/prelude.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prelude.d.ts","sourceRoot":"","sources":["../../../src/execution/workflow/prelude.ts"],"names":[],"mappings":"AA0LA;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACxC,IAAI,EAAE,OAAO,CAAA;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,MAAM,CAET;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,MAAM,EAAE;IACpC,IAAI,EAAE,OAAO,CAAA;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAA;CACvB,GAAG,MAAM,CAOT"}
|
|
@@ -28,7 +28,7 @@ const PRELUDE_SOURCE = String.raw `(function (config) {
|
|
|
28
28
|
}
|
|
29
29
|
function phase(title) {
|
|
30
30
|
var t = clean(title, 120);
|
|
31
|
-
if (!t) throw
|
|
31
|
+
if (!t) throw misuse('phase() needs a non-empty title.');
|
|
32
32
|
cursor = t;
|
|
33
33
|
emit({ k: 'phase', title: t });
|
|
34
34
|
}
|
|
@@ -53,13 +53,26 @@ const PRELUDE_SOURCE = String.raw `(function (config) {
|
|
|
53
53
|
return e;
|
|
54
54
|
}
|
|
55
55
|
function isBudgetError(e) { return !!e && e.name === 'WorkflowBudgetExceededError'; }
|
|
56
|
+
function misuse(message) {
|
|
57
|
+
var e = new TypeError(message);
|
|
58
|
+
e.workflowMisuse = true;
|
|
59
|
+
return e;
|
|
60
|
+
}
|
|
61
|
+
function isMisuse(e) { return !!e && e.workflowMisuse === true; }
|
|
62
|
+
var optionNames = ['label', 'phase', 'schema', 'agentType', 'model', 'effort'];
|
|
56
63
|
async function agent(prompt, opts) {
|
|
57
64
|
if (typeof prompt !== 'string' || prompt.length === 0) {
|
|
58
|
-
throw
|
|
65
|
+
throw misuse('agent(prompt, options?): the prompt must be a non-empty string, got ' + kind(prompt));
|
|
59
66
|
}
|
|
60
67
|
var o = opts == null ? {} : opts;
|
|
61
68
|
if (typeof o !== 'object' || Array.isArray(o)) {
|
|
62
|
-
throw
|
|
69
|
+
throw misuse('agent(prompt, options?): options must be an object, got ' + kind(o));
|
|
70
|
+
}
|
|
71
|
+
var unknown = Object.keys(o).filter(function (k) { return optionNames.indexOf(k) < 0; });
|
|
72
|
+
if (unknown.length > 0) {
|
|
73
|
+
// Ignored, as it always was, but no longer silently: a saved script that
|
|
74
|
+
// misspells an option keeps running and the line says why it had no effect.
|
|
75
|
+
log('agent(prompt, options?): ignoring unknown option "' + unknown[0] + '"; the options are ' + optionNames.join(', ') + '.');
|
|
63
76
|
}
|
|
64
77
|
if (overBudget()) throw budgetError();
|
|
65
78
|
var request = { prompt: prompt, cursor: cursor };
|
|
@@ -69,23 +82,32 @@ const PRELUDE_SOURCE = String.raw `(function (config) {
|
|
|
69
82
|
if (o.agentType != null) request.agentType = clean(o.agentType, 120);
|
|
70
83
|
if (o.model != null) request.model = clean(o.model, 120);
|
|
71
84
|
if (o.effort != null) request.effort = clean(o.effort, 32);
|
|
72
|
-
var reply
|
|
85
|
+
var reply;
|
|
86
|
+
try {
|
|
87
|
+
reply = await rawCall('agent', request);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
// The host rejects a malformed request with an "agent(): ..." message;
|
|
90
|
+
// that is the script's mistake, not a failed child.
|
|
91
|
+
if (e && typeof e.message === 'string' && e.message.indexOf('agent(): ') === 0) throw misuse(e.message);
|
|
92
|
+
throw e;
|
|
93
|
+
}
|
|
73
94
|
spent.tokensUsed = reply.t;
|
|
74
95
|
return reply.v;
|
|
75
96
|
}
|
|
76
97
|
async function parallel(thunks) {
|
|
77
98
|
if (!Array.isArray(thunks)) {
|
|
78
|
-
throw
|
|
99
|
+
throw misuse('parallel(thunks): the argument must be an array of functions, got ' + kind(thunks));
|
|
79
100
|
}
|
|
80
101
|
for (var p = 0; p < thunks.length; p++) {
|
|
81
102
|
if (typeof thunks[p] !== 'function') {
|
|
82
|
-
throw
|
|
103
|
+
throw misuse('parallel(thunks): item ' + (p + 1) + ' must be a function (wrap the work as () => agent(...)), got ' + kind(thunks[p]));
|
|
83
104
|
}
|
|
84
105
|
}
|
|
85
106
|
var dropped = 0;
|
|
86
107
|
var results = await Promise.all(thunks.map(function (t, n) {
|
|
87
108
|
return Promise.resolve().then(t).catch(function (e) {
|
|
88
109
|
if (isBudgetError(e)) { dropped++; return null; }
|
|
110
|
+
if (isMisuse(e)) throw e;
|
|
89
111
|
log('Step ' + (n + 1) + ' stopped: ' + clean(e && e.message ? e.message : e, 300));
|
|
90
112
|
return null;
|
|
91
113
|
});
|
|
@@ -95,12 +117,12 @@ const PRELUDE_SOURCE = String.raw `(function (config) {
|
|
|
95
117
|
}
|
|
96
118
|
async function pipeline(items) {
|
|
97
119
|
if (!Array.isArray(items)) {
|
|
98
|
-
throw
|
|
120
|
+
throw misuse('pipeline(items, ...stages): the first argument must be an array, got ' + kind(items));
|
|
99
121
|
}
|
|
100
122
|
var stages = Array.prototype.slice.call(arguments, 1);
|
|
101
123
|
for (var s = 0; s < stages.length; s++) {
|
|
102
124
|
if (typeof stages[s] !== 'function') {
|
|
103
|
-
throw
|
|
125
|
+
throw misuse('pipeline(items, ...stages): stage ' + (s + 1) + ' must be a function, got ' + kind(stages[s]));
|
|
104
126
|
}
|
|
105
127
|
}
|
|
106
128
|
if (items.length > 0 && overBudget()) throw budgetError();
|
|
@@ -112,6 +134,7 @@ const PRELUDE_SOURCE = String.raw `(function (config) {
|
|
|
112
134
|
value = await stages[i](value, item, index);
|
|
113
135
|
} catch (e) {
|
|
114
136
|
if (isBudgetError(e)) { dropped++; return null; }
|
|
137
|
+
if (isMisuse(e)) throw e;
|
|
115
138
|
log('Item ' + (index + 1) + ' stopped at step ' + (i + 1) + ': ' + clean(e && e.message ? e.message : e, 300));
|
|
116
139
|
return null;
|
|
117
140
|
}
|
|
@@ -141,6 +164,24 @@ const PRELUDE_SOURCE = String.raw `(function (config) {
|
|
|
141
164
|
install('log', log);
|
|
142
165
|
install('budget', budget);
|
|
143
166
|
install('args', config.args);
|
|
167
|
+
if (config.deterministic) {
|
|
168
|
+
var RealDate = Date;
|
|
169
|
+
var clockMessage = 'Date.now() / new Date() are unavailable in workflow scripts (breaks resume). Stamp results after the workflow returns, or pass timestamps through args.';
|
|
170
|
+
var randomMessage = 'Math.random() is unavailable in workflow scripts (breaks resume). For N independent samples, include the index in the agent label or prompt.';
|
|
171
|
+
var ShimDate = function Date(a, b, c, d, e, f, g) {
|
|
172
|
+
if (!new.target || arguments.length === 0) throw new Error(clockMessage);
|
|
173
|
+
return Reflect.construct(RealDate, Array.prototype.slice.call(arguments), new.target === ShimDate ? RealDate : new.target);
|
|
174
|
+
};
|
|
175
|
+
Object.defineProperty(ShimDate, 'prototype', { value: RealDate.prototype, writable: false, configurable: false });
|
|
176
|
+
Object.defineProperty(ShimDate, 'now', { value: function now() { throw new Error(clockMessage); }, writable: false, configurable: false });
|
|
177
|
+
Object.defineProperty(ShimDate, 'parse', { value: RealDate.parse, writable: false, configurable: false });
|
|
178
|
+
Object.defineProperty(ShimDate, 'UTC', { value: RealDate.UTC, writable: false, configurable: false });
|
|
179
|
+
Object.defineProperty(RealDate.prototype, 'constructor', { value: ShimDate, writable: false, configurable: false });
|
|
180
|
+
Object.defineProperty(globalThis, 'Date', { value: ShimDate, writable: false, configurable: false, enumerable: false });
|
|
181
|
+
Object.defineProperty(Math, 'random', { value: function random() { throw new Error(randomMessage); }, writable: false, configurable: false });
|
|
182
|
+
try { delete globalThis.eval; } catch (ignored) {}
|
|
183
|
+
Object.freeze(RealDate);
|
|
184
|
+
}
|
|
144
185
|
})`;
|
|
145
186
|
/**
|
|
146
187
|
* Lines the prelude occupies in the interpreter source, plus the newline that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../../src/execution/workflow/prelude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"prelude.js","sourceRoot":"","sources":["../../../src/execution/workflow/prelude.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyK9B,CAAA;AAEH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAIhC;IACA,OAAO,YAAY,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAA;AAC/C,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,YAAY,CAAC,MAI5B;IACA,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;SACpC,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;SAClC,IAAI,CAAC,SAAS,CAAC;SACf,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;SAClC,IAAI,CAAC,SAAS,CAAC,CAAA;IACjB,OAAO,GAAG,cAAc,IAAI,OAAO,IAAI,CAAA;AACxC,CAAC"}
|