@namzu/sdk 73.0.0 → 74.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 +38 -0
- package/README.md +34 -34
- package/dist/authorization/protected-paths.d.ts +7 -0
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +7 -0
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +23 -0
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +89 -3
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/shell-paths.d.ts +8 -0
- package/dist/authorization/shell-paths.d.ts.map +1 -1
- package/dist/authorization/shell-paths.js +125 -2
- package/dist/authorization/shell-paths.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +6 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +21 -3
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +11 -0
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +15 -8
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/plan.d.ts +2 -1
- package/dist/compaction/plan.d.ts.map +1 -1
- package/dist/compaction/plan.js +6 -5
- package/dist/compaction/plan.js.map +1 -1
- package/dist/compaction/retained-images.d.ts +16 -0
- package/dist/compaction/retained-images.d.ts.map +1 -0
- package/dist/compaction/retained-images.js +113 -0
- package/dist/compaction/retained-images.js.map +1 -0
- package/dist/compaction/token-estimate.d.ts +8 -3
- package/dist/compaction/token-estimate.d.ts.map +1 -1
- package/dist/compaction/token-estimate.js +76 -8
- package/dist/compaction/token-estimate.js.map +1 -1
- package/dist/compaction/tool-result-editing.d.ts.map +1 -1
- package/dist/compaction/tool-result-editing.js +15 -8
- package/dist/compaction/tool-result-editing.js.map +1 -1
- package/dist/constants/acp/index.d.ts +2 -0
- package/dist/constants/acp/index.d.ts.map +1 -1
- package/dist/constants/acp/index.js +2 -0
- package/dist/constants/acp/index.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +178 -1
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/provider/attribution.js +1 -1
- package/dist/provider/attribution.js.map +1 -1
- package/dist/public-runtime.d.ts +4 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +7 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/rag/embedding.d.ts +5 -1
- package/dist/rag/embedding.d.ts.map +1 -1
- package/dist/rag/embedding.js +22 -7
- package/dist/rag/embedding.js.map +1 -1
- package/dist/runtime/query/abandon-turn.d.ts.map +1 -1
- package/dist/runtime/query/abandon-turn.js +9 -0
- package/dist/runtime/query/abandon-turn.js.map +1 -1
- package/dist/runtime/query/compact-session.d.ts +10 -3
- package/dist/runtime/query/compact-session.d.ts.map +1 -1
- package/dist/runtime/query/compact-session.js +24 -14
- package/dist/runtime/query/compact-session.js.map +1 -1
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1 -0
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +14 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +60 -5
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +2 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +1 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/request-prefix.d.ts +21 -0
- package/dist/runtime/query/iteration/request-prefix.d.ts.map +1 -0
- package/dist/runtime/query/iteration/request-prefix.js +111 -0
- package/dist/runtime/query/iteration/request-prefix.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +11 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +54 -3
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/sandbox/exec-stdin.d.ts +21 -0
- package/dist/sandbox/exec-stdin.d.ts.map +1 -0
- package/dist/sandbox/exec-stdin.js +40 -0
- package/dist/sandbox/exec-stdin.js.map +1 -0
- package/dist/sandbox/file-walk.d.ts +12 -7
- package/dist/sandbox/file-walk.d.ts.map +1 -1
- package/dist/sandbox/file-walk.js +13 -4
- package/dist/sandbox/file-walk.js.map +1 -1
- package/dist/sandbox/ignore-matcher.d.ts +1 -0
- package/dist/sandbox/ignore-matcher.d.ts.map +1 -1
- package/dist/sandbox/ignore-matcher.js.map +1 -1
- package/dist/sandbox/ignore-source.js +1 -1
- package/dist/sandbox/index.d.ts +3 -2
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +2 -1
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +2 -0
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/session/paths.d.ts +6 -0
- package/dist/session/paths.d.ts.map +1 -1
- package/dist/session/paths.js +7 -0
- package/dist/session/paths.js.map +1 -1
- package/dist/session-query/index.d.ts +1 -0
- package/dist/session-query/index.d.ts.map +1 -1
- package/dist/session-query/index.js +26 -15
- package/dist/session-query/index.js.map +1 -1
- package/dist/store/evidence/disk.js +3 -1
- package/dist/store/evidence/disk.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +1 -0
- package/dist/store/evidence/index-page.d.ts.map +1 -1
- package/dist/store/evidence/index-page.js +8 -0
- package/dist/store/evidence/index-page.js.map +1 -1
- package/dist/store/memory/operation-lock.d.ts.map +1 -1
- package/dist/store/memory/operation-lock.js +15 -1
- package/dist/store/memory/operation-lock.js.map +1 -1
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +23 -0
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/tools/builtins/computer-use-image.d.ts +9 -0
- package/dist/tools/builtins/computer-use-image.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use-image.js +21 -0
- package/dist/tools/builtins/computer-use-image.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +1 -9
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +2 -22
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/toolsets/manager.d.ts +7 -3
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +7 -3
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/types/common/index.d.ts +20 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +4 -1
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +11 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/rag/embedding.d.ts +4 -0
- package/dist/types/rag/embedding.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +19 -0
- 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 +48 -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 +2 -0
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +9 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/utils/cost.d.ts +15 -0
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +24 -1
- package/dist/utils/cost.js.map +1 -1
- package/package.json +2 -2
- package/src/authorization/protected-paths.ts +7 -0
- package/src/authorization/readonly-commands.ts +85 -3
- package/src/authorization/shell-paths.ts +141 -3
- package/src/bridge/acp/permission.ts +6 -0
- package/src/bridge/acp/server.ts +20 -1
- package/src/compaction/context-window.ts +11 -0
- package/src/compaction/manual.ts +23 -8
- package/src/compaction/plan.ts +11 -5
- package/src/compaction/retained-images.ts +130 -0
- package/src/compaction/token-estimate.ts +86 -8
- package/src/compaction/tool-result-editing.ts +20 -8
- package/src/constants/acp/index.ts +2 -0
- package/src/pricing/catalogue.generated.ts +178 -1
- package/src/pricing/rates.source.json +155 -2
- package/src/provider/attribution.ts +1 -1
- package/src/public-runtime.ts +21 -0
- package/src/rag/embedding.ts +23 -7
- package/src/runtime/query/abandon-turn.ts +9 -0
- package/src/runtime/query/compact-session.ts +50 -15
- package/src/runtime/query/index.ts +1 -0
- package/src/runtime/query/iteration/index.ts +14 -0
- package/src/runtime/query/iteration/phases/compaction.ts +77 -5
- package/src/runtime/query/iteration/phases/context.ts +3 -0
- package/src/runtime/query/iteration/request-prefix.ts +161 -0
- package/src/runtime/query/review-policy.ts +79 -11
- package/src/sandbox/exec-stdin.ts +54 -0
- package/src/sandbox/file-walk.ts +25 -18
- package/src/sandbox/ignore-matcher.ts +1 -0
- package/src/sandbox/ignore-source.ts +1 -1
- package/src/sandbox/index.ts +8 -2
- package/src/sandbox/provider/local.ts +2 -0
- package/src/session/paths.ts +9 -0
- package/src/session-query/index.ts +23 -14
- package/src/store/evidence/disk.ts +3 -1
- package/src/store/evidence/index-page.ts +11 -0
- package/src/store/memory/operation-lock.ts +19 -1
- package/src/store/session-log/core.ts +26 -0
- package/src/tools/builtins/computer-use-image.ts +20 -0
- package/src/tools/builtins/computer-use.ts +1 -20
- package/src/toolsets/manager.ts +7 -3
- package/src/types/common/index.ts +26 -1
- package/src/types/hitl/index.ts +11 -0
- package/src/types/rag/embedding.ts +7 -0
- package/src/types/sandbox/index.ts +19 -0
- package/src/types/session/events.ts +49 -0
- package/src/types/session/records.ts +14 -0
- package/src/utils/cost.ts +44 -1
package/src/sandbox/file-walk.ts
CHANGED
|
@@ -183,13 +183,24 @@ function directoryMatcher(plan: WalkPlan): (relative: string) => boolean {
|
|
|
183
183
|
})
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/** Host-only extensions for a walk inside an already authorized filesystem root. */
|
|
187
|
+
export interface LocalFileWalkOptions extends SandboxWalkFilesOptions {
|
|
188
|
+
/** Skip the per-file size read when the caller will open and check the file. */
|
|
189
|
+
readonly withoutSizes?: boolean
|
|
190
|
+
/** Read .gitignore even in a folder with no repository metadata. */
|
|
191
|
+
readonly gitignoreOutsideRepo?: boolean
|
|
192
|
+
/** Prune entries before descent, in addition to the ignore files. */
|
|
193
|
+
readonly skipEntry?: (absolutePath: string, isDirectory: boolean) => boolean
|
|
194
|
+
/** Called for each directory opened by the walk. */
|
|
195
|
+
readonly onDirectory?: (absolutePath: string) => void
|
|
196
|
+
}
|
|
197
|
+
|
|
186
198
|
/** Local traversal uses the same compiled matching/pruning plan as the guest. */
|
|
187
199
|
async function* executeWalk(
|
|
188
200
|
plan: WalkPlan,
|
|
189
|
-
|
|
190
|
-
onSummary?: (summary: SandboxWalkSummary) => void,
|
|
191
|
-
withoutSizes = false,
|
|
201
|
+
options: LocalFileWalkOptions,
|
|
192
202
|
): AsyncGenerator<SandboxFileEntry> {
|
|
203
|
+
const { signal, onSummary, withoutSizes = false } = options
|
|
193
204
|
const fs = await import('node:fs/promises')
|
|
194
205
|
const path = await import('node:path')
|
|
195
206
|
const { EventEmitter } = await import('node:events')
|
|
@@ -206,7 +217,12 @@ async function* executeWalk(
|
|
|
206
217
|
let ignoredDirectories = 0
|
|
207
218
|
let stopped: SandboxWalkSummary['stopped']
|
|
208
219
|
const ignore = plan.respectIgnore
|
|
209
|
-
? createIgnoreStack({
|
|
220
|
+
? createIgnoreStack({
|
|
221
|
+
fs,
|
|
222
|
+
path,
|
|
223
|
+
extraFiles: globalIgnoreFiles(),
|
|
224
|
+
gitignoreOutsideRepo: options.gitignoreOutsideRepo === true,
|
|
225
|
+
})
|
|
210
226
|
: undefined
|
|
211
227
|
const matchers = plan.expressions.map(({ source, flags }) => new RegExp(source, `${flags}s`))
|
|
212
228
|
const canDescend = directoryMatcher(plan)
|
|
@@ -324,6 +340,7 @@ async function* executeWalk(
|
|
|
324
340
|
})
|
|
325
341
|
if (layered) await ignore?.enter(absolute)
|
|
326
342
|
open.push({ dir, relative, depth, layered })
|
|
343
|
+
options.onDirectory?.(absolute)
|
|
327
344
|
} catch (error) {
|
|
328
345
|
if (!missing(error)) throw error
|
|
329
346
|
}
|
|
@@ -358,6 +375,7 @@ async function* executeWalk(
|
|
|
358
375
|
if (VCS_NAMES.has(entry.name)) continue
|
|
359
376
|
const relative = frame.relative ? `${frame.relative}/${entry.name}` : entry.name
|
|
360
377
|
const absolute = path.join(plan.root, relative)
|
|
378
|
+
if (options.skipEntry?.(absolute, entry.isDirectory())) continue
|
|
361
379
|
const depth = frame.depth + 1
|
|
362
380
|
if (entry.isDirectory()) {
|
|
363
381
|
if (depth >= maxDepth || !canDescend(relative)) continue
|
|
@@ -407,24 +425,13 @@ function globalIgnoreFiles(): string[] {
|
|
|
407
425
|
return base ? [join(base, 'git', 'ignore')] : []
|
|
408
426
|
}
|
|
409
427
|
|
|
410
|
-
/**
|
|
428
|
+
/** Enumerate files under an authorized, canonical host filesystem root. */
|
|
411
429
|
export async function* walkFilesLocally(
|
|
412
430
|
rootPath: string,
|
|
413
|
-
options:
|
|
414
|
-
/**
|
|
415
|
-
* Skip the per-file size read: entries carry `size: 0`. For a caller that
|
|
416
|
-
* opens every file itself and takes the size from the handle.
|
|
417
|
-
*/
|
|
418
|
-
readonly withoutSizes?: boolean
|
|
419
|
-
},
|
|
431
|
+
options: LocalFileWalkOptions,
|
|
420
432
|
): AsyncGenerator<SandboxFileEntry> {
|
|
421
433
|
options.signal?.throwIfAborted()
|
|
422
|
-
yield* executeWalk(
|
|
423
|
-
planWalk(rootPath, options),
|
|
424
|
-
options.signal,
|
|
425
|
-
options.onSummary,
|
|
426
|
-
options.withoutSizes === true,
|
|
427
|
-
)
|
|
434
|
+
yield* executeWalk(planWalk(rootPath, options), options)
|
|
428
435
|
}
|
|
429
436
|
|
|
430
437
|
/** The existing sandbox execution seam; no separate worker protocol is needed. */
|
|
@@ -152,7 +152,7 @@ function ignCreate(deps) {
|
|
|
152
152
|
};
|
|
153
153
|
const loadDirectory = async (directory, inRepo) => {
|
|
154
154
|
const rules = [];
|
|
155
|
-
if (inRepo) rules.push(...await load(path.join(directory, '.gitignore')));
|
|
155
|
+
if (inRepo || deps.gitignoreOutsideRepo) rules.push(...await load(path.join(directory, '.gitignore')));
|
|
156
156
|
rules.push(...await load(path.join(directory, '.ignore')));
|
|
157
157
|
return rules;
|
|
158
158
|
};
|
package/src/sandbox/index.ts
CHANGED
|
@@ -2,5 +2,11 @@ export { LocalSandboxProvider } from './provider/local.js'
|
|
|
2
2
|
export type { LocalSandboxProviderOptions } from './provider/local.js'
|
|
3
3
|
export { SandboxProviderFactory } from './factory.js'
|
|
4
4
|
export { assertIsolation, describeIsolation, isolationOf, missingIsolation } from './isolation.js'
|
|
5
|
-
export { walkFilesViaExec } from './file-walk.js'
|
|
6
|
-
export type { SandboxFileWalkExec } from './file-walk.js'
|
|
5
|
+
export { walkFilesLocally, walkFilesViaExec } from './file-walk.js'
|
|
6
|
+
export type { LocalFileWalkOptions, SandboxFileWalkExec } from './file-walk.js'
|
|
7
|
+
export {
|
|
8
|
+
execStdinOf,
|
|
9
|
+
refuseExecStdin,
|
|
10
|
+
SANDBOX_EXEC_STDIN_MAX_BYTES,
|
|
11
|
+
SandboxExecStdinError,
|
|
12
|
+
} from './exec-stdin.js'
|
|
@@ -58,6 +58,7 @@ import {
|
|
|
58
58
|
setEnvironmentEntry,
|
|
59
59
|
} from '../../utils/process-environment.js'
|
|
60
60
|
import { createTempDir, resolveTempBase } from '../../utils/temp.js'
|
|
61
|
+
import { refuseExecStdin } from '../exec-stdin.js'
|
|
61
62
|
import { walkFilesLocally } from '../file-walk.js'
|
|
62
63
|
import { assertIsolation, describeIsolation } from '../isolation.js'
|
|
63
64
|
import type { PtyLoader } from '../terminal.js'
|
|
@@ -690,6 +691,7 @@ class LocalSandbox implements Sandbox {
|
|
|
690
691
|
if (this._status === 'destroyed') {
|
|
691
692
|
throw new Error(`Sandbox ${this.id} is destroyed`)
|
|
692
693
|
}
|
|
694
|
+
refuseExecStdin(opts, 'local')
|
|
693
695
|
|
|
694
696
|
this._status = 'busy'
|
|
695
697
|
const startTime = Date.now()
|
package/src/session/paths.ts
CHANGED
|
@@ -34,6 +34,7 @@ import { uuidv7 } from '../utils/uuidv7.js'
|
|
|
34
34
|
* subagents/<child-id>.jsonl, <child-id>.meta.json, <child-id>/subagents/…
|
|
35
35
|
* tool-results/ checkpoints/ budgets/ tasks/ plans/ feedback/ goals/
|
|
36
36
|
* file-history/ lease.json
|
|
37
|
+
* memory/ scratch-<date>-<hex>/ (a conversation without a project only)
|
|
37
38
|
* $TMPDIR/namzu-<user>/<slug>/<session-id>/scratchpad/
|
|
38
39
|
* ```
|
|
39
40
|
*
|
|
@@ -326,6 +327,14 @@ export class SessionPaths {
|
|
|
326
327
|
return join(this.#logParent(locator), checkId(locator.sessionId, 'session'))
|
|
327
328
|
}
|
|
328
329
|
|
|
330
|
+
/**
|
|
331
|
+
* `<session-dir>/memory`: stored memory that belongs to one conversation alone, for a
|
|
332
|
+
* conversation that has no project. A project's own memory stays at {@link memoryDir}.
|
|
333
|
+
*/
|
|
334
|
+
sessionMemoryDir(locator: SessionLocator): string {
|
|
335
|
+
return join(this.sessionDir(locator), 'memory')
|
|
336
|
+
}
|
|
337
|
+
|
|
329
338
|
#child(parent: SessionLocator, childId: SessionId): SessionLocator {
|
|
330
339
|
return { sessionId: childId, ancestors: [...(parent.ancestors ?? []), parent.sessionId] }
|
|
331
340
|
}
|
|
@@ -86,7 +86,7 @@ export class SessionQuery {
|
|
|
86
86
|
|
|
87
87
|
/** Every message compaction removed, one entry per pass, oldest first. */
|
|
88
88
|
async shedHistory(): Promise<readonly ShedPass[]> {
|
|
89
|
-
return shedPassesFrom(await this.records())
|
|
89
|
+
return this.shedPassesFrom(await this.records())
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
@@ -98,7 +98,7 @@ export class SessionQuery {
|
|
|
98
98
|
*/
|
|
99
99
|
async fullTranscript(messages?: readonly Message[]): Promise<readonly Message[]> {
|
|
100
100
|
const records = await this.records()
|
|
101
|
-
const shed = shedPassesFrom(records)
|
|
101
|
+
const shed = await this.shedPassesFrom(records)
|
|
102
102
|
let surviving: readonly Message[]
|
|
103
103
|
if (messages !== undefined) {
|
|
104
104
|
surviving = messages
|
|
@@ -135,18 +135,27 @@ export class SessionQuery {
|
|
|
135
135
|
registry.replay(await this.records())
|
|
136
136
|
return registry.get<SessionStatusState>(SESSION_STATUS_READ_MODEL_ID)
|
|
137
137
|
}
|
|
138
|
-
}
|
|
139
138
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
private async shedPassesFrom(records: readonly SessionRecord[]): Promise<ShedPass[]> {
|
|
140
|
+
const passes: ShedPass[] = []
|
|
141
|
+
for (const record of records) {
|
|
142
|
+
if (record.type !== 'compaction_shed') continue
|
|
143
|
+
let messages = record.messages
|
|
144
|
+
if (record.messagesSpill !== undefined) {
|
|
145
|
+
try {
|
|
146
|
+
const body: unknown = JSON.parse(await this.options.log.readSpill(record.messagesSpill))
|
|
147
|
+
if (!Array.isArray(body)) throw new Error('A shed message spill must hold an array.')
|
|
148
|
+
messages = body
|
|
149
|
+
} catch (cause) {
|
|
150
|
+
throw new SessionTranscriptUnavailableError({
|
|
151
|
+
reason: 'spill-unavailable',
|
|
152
|
+
throughSeq: record.seq,
|
|
153
|
+
cause,
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
passes.push({ iteration: record.iteration, reason: record.reason, messages, seq: record.seq })
|
|
158
|
+
}
|
|
159
|
+
return passes
|
|
150
160
|
}
|
|
151
|
-
return passes
|
|
152
161
|
}
|
|
@@ -449,7 +449,9 @@ function createSource(
|
|
|
449
449
|
}
|
|
450
450
|
const { page, cacheHit } = indexed
|
|
451
451
|
const matches: SessionTextEvidenceMatch[] = []
|
|
452
|
-
const unavailable
|
|
452
|
+
const unavailable = page.unavailableShedSeqs
|
|
453
|
+
.filter((seq) => input.seq === undefined || input.seq === seq)
|
|
454
|
+
.map((seq) => `Text record ${seq} is available only in the full transcript.`)
|
|
453
455
|
let partial = false
|
|
454
456
|
let excludedToolResults = 0
|
|
455
457
|
let excludedSummaries = 0
|
|
@@ -45,6 +45,7 @@ export type IndexPosition = z.infer<typeof positionSchema>
|
|
|
45
45
|
export interface IndexPage {
|
|
46
46
|
start: IndexPosition
|
|
47
47
|
entries: IndexEntry[]
|
|
48
|
+
unavailableShedSeqs: number[]
|
|
48
49
|
next: IndexPosition | null
|
|
49
50
|
records: number
|
|
50
51
|
}
|
|
@@ -154,6 +155,7 @@ export async function indexPage(
|
|
|
154
155
|
let buffered = Buffer.alloc(0)
|
|
155
156
|
let readOffset = offset
|
|
156
157
|
const entries: IndexEntry[] = []
|
|
158
|
+
const unavailableShedSeqs: number[] = []
|
|
157
159
|
while (offset < size && records < 64 && entries.length < 64) {
|
|
158
160
|
budget.signal?.throwIfAborted()
|
|
159
161
|
let newline = buffered.indexOf(10)
|
|
@@ -176,6 +178,14 @@ export async function indexPage(
|
|
|
176
178
|
(offset === 0 && record.type !== 'session_started')
|
|
177
179
|
)
|
|
178
180
|
throw new Error('Session log identity or record sequence is invalid.')
|
|
181
|
+
if (
|
|
182
|
+
record.type === 'compaction_shed' &&
|
|
183
|
+
record.messagesSpill !== undefined &&
|
|
184
|
+
Array.isArray(record.messages) &&
|
|
185
|
+
record.messages.length === 0
|
|
186
|
+
) {
|
|
187
|
+
unavailableShedSeqs.push(seq + 1)
|
|
188
|
+
}
|
|
179
189
|
const parts = recordTexts(record)
|
|
180
190
|
if (textIndex > parts.length) throw new Error('Invalid textual part position.')
|
|
181
191
|
const hash = digest(raw)
|
|
@@ -212,6 +222,7 @@ export async function indexPage(
|
|
|
212
222
|
const page: IndexPage = {
|
|
213
223
|
start,
|
|
214
224
|
entries,
|
|
225
|
+
unavailableShedSeqs,
|
|
215
226
|
records,
|
|
216
227
|
next: offset < size ? { offset, seq, textIndex } : null,
|
|
217
228
|
}
|
|
@@ -122,11 +122,16 @@ async function inspect(path: string, env: Resolved): Promise<Inspection | undefi
|
|
|
122
122
|
return { stats: before, content: '', pid: undefined, staleReason: undefined }
|
|
123
123
|
const content = await readFile(path, 'utf8').catch((error: NodeJS.ErrnoException) => {
|
|
124
124
|
if (error.code === 'ENOENT') return undefined
|
|
125
|
+
// Windows can deny reads while another handle still holds the lock file.
|
|
126
|
+
// Treat an unreadable owner as unverifiable, so it cannot be broken.
|
|
127
|
+
if (error.code === 'EACCES' || error.code === 'EPERM' || error.code === 'EBUSY') return null
|
|
125
128
|
throw error
|
|
126
129
|
})
|
|
127
130
|
if (content === undefined) return undefined
|
|
128
131
|
const after = await lstat(path).catch(() => undefined)
|
|
129
132
|
if (!after || after.dev !== before.dev || after.ino !== before.ino) return undefined
|
|
133
|
+
if (content === null)
|
|
134
|
+
return { stats: before, content: '', pid: undefined, staleReason: undefined }
|
|
130
135
|
|
|
131
136
|
const owner = parseOwner(content)
|
|
132
137
|
if (owner) {
|
|
@@ -167,7 +172,20 @@ async function createOwned(
|
|
|
167
172
|
try {
|
|
168
173
|
handle = await open(path, 'wx', 0o600)
|
|
169
174
|
} catch (error) {
|
|
170
|
-
|
|
175
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
176
|
+
if (code === 'EEXIST') return undefined
|
|
177
|
+
// Windows reports an exclusive create over a file another process still
|
|
178
|
+
// holds open (or is deleting) as a sharing error, not EEXIST. When the
|
|
179
|
+
// path is there, it is occupied; otherwise the error is real.
|
|
180
|
+
if (code === 'EACCES' || code === 'EPERM' || code === 'EBUSY') {
|
|
181
|
+
if (
|
|
182
|
+
await lstat(path).then(
|
|
183
|
+
() => true,
|
|
184
|
+
() => false,
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
return undefined
|
|
188
|
+
}
|
|
171
189
|
throw error
|
|
172
190
|
}
|
|
173
191
|
const owner = `${JSON.stringify({
|
|
@@ -976,6 +976,7 @@ export class SessionLogCore implements SessionLog {
|
|
|
976
976
|
type !== 'message_replaced' &&
|
|
977
977
|
type !== 'message_edited' &&
|
|
978
978
|
type !== 'compaction' &&
|
|
979
|
+
type !== 'compaction_shed' &&
|
|
979
980
|
type !== 'turn_completed'
|
|
980
981
|
)
|
|
981
982
|
return candidate
|
|
@@ -984,6 +985,31 @@ export class SessionLogCore implements SessionLog {
|
|
|
984
985
|
// single large one never sits inline and bloats the log.
|
|
985
986
|
const spillAbove = type === 'compaction' ? this.#compactionSpillAbove : this.#spillAbove
|
|
986
987
|
if (size <= spillAbove) return candidate
|
|
988
|
+
if (type === 'compaction_shed') {
|
|
989
|
+
if (!Array.isArray(candidate.messages) || candidate.messagesSpill !== undefined)
|
|
990
|
+
return candidate
|
|
991
|
+
const messages = candidate.messages as Message[]
|
|
992
|
+
const messagesSpill = await this.#spills.write(
|
|
993
|
+
`shed:${String(candidate.id)}`,
|
|
994
|
+
'messages',
|
|
995
|
+
JSON.stringify(messages),
|
|
996
|
+
)
|
|
997
|
+
// Keep the exact searchable text and tool pairing inline when they fit.
|
|
998
|
+
const projected = messages.map((message) => {
|
|
999
|
+
if (message.role === 'tool' && Array.isArray(message.content)) {
|
|
1000
|
+
return {
|
|
1001
|
+
...message,
|
|
1002
|
+
content: message.content.filter((block) => block.type === 'text'),
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
if (message.role === 'user') return { ...message, attachments: undefined }
|
|
1006
|
+
return message
|
|
1007
|
+
})
|
|
1008
|
+
const record = { ...candidate, messages: projected, messagesSpill }
|
|
1009
|
+
return Buffer.byteLength(`${JSON.stringify(record)}\n`, 'utf8') <= this.#spillAbove
|
|
1010
|
+
? record
|
|
1011
|
+
: { ...record, messages: [] }
|
|
1012
|
+
}
|
|
987
1013
|
if (type === 'turn_completed') {
|
|
988
1014
|
if (typeof candidate.result !== 'string') return candidate
|
|
989
1015
|
const ref = await this.#spillOrLose(
|
|
@@ -52,6 +52,26 @@ export const HIGH_RES_SCREENSHOT_LIMITS: ScreenshotLimits = Object.freeze({
|
|
|
52
52
|
maxTiles: 4784,
|
|
53
53
|
})
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The limits to fit a screenshot to for `model`: the high-resolution tier for
|
|
57
|
+
* a model known to read it (the 4.7 and later models of the vendor behind that
|
|
58
|
+
* tier, with or without a vendor prefix or a dated suffix), the standard tier for every
|
|
59
|
+
* other model, including one the table does not know. A wrong "high" costs a
|
|
60
|
+
* rejected tool result; a wrong "standard" only costs detail, so an unknown
|
|
61
|
+
* model gets the standard tier.
|
|
62
|
+
*/
|
|
63
|
+
export function screenshotLimitsForModel(model: string | undefined): ScreenshotLimits {
|
|
64
|
+
if (model === undefined) return STANDARD_SCREENSHOT_LIMITS
|
|
65
|
+
const match = /claude-(?:opus|sonnet|haiku|fable)-(\d+)(?:[-.](\d{1,2})(?!\d))?/i.exec(model)
|
|
66
|
+
if (!match) return STANDARD_SCREENSHOT_LIMITS
|
|
67
|
+
const major = Number(match[1])
|
|
68
|
+
const minor = match[2] === undefined ? 0 : Number(match[2])
|
|
69
|
+
// A dated id such as `claude-sonnet-4-20250514` has no minor: the date is not one.
|
|
70
|
+
return major > 4 || (major === 4 && minor >= 7)
|
|
71
|
+
? HIGH_RES_SCREENSHOT_LIMITS
|
|
72
|
+
: STANDARD_SCREENSHOT_LIMITS
|
|
73
|
+
}
|
|
74
|
+
|
|
55
75
|
export interface ImageSize {
|
|
56
76
|
readonly width: number
|
|
57
77
|
readonly height: number
|
|
@@ -39,7 +39,6 @@ import {
|
|
|
39
39
|
} from './computer-use-coordinates.js'
|
|
40
40
|
import {
|
|
41
41
|
type FittedImage,
|
|
42
|
-
HIGH_RES_SCREENSHOT_LIMITS,
|
|
43
42
|
STANDARD_SCREENSHOT_LIMITS,
|
|
44
43
|
type ScreenshotLimits,
|
|
45
44
|
cropAndFitPng,
|
|
@@ -55,25 +54,7 @@ export {
|
|
|
55
54
|
} from './computer-use-image.js'
|
|
56
55
|
export type { ImageSize, ScreenshotLimits } from './computer-use-image.js'
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
* The limits to fit a screenshot to for `model`: the high-resolution tier for
|
|
60
|
-
* a model known to read it (the 4.7 and later models of the vendor behind that
|
|
61
|
-
* tier, with or without a vendor prefix or a dated suffix), the standard tier for every
|
|
62
|
-
* other model, including one the table does not know. A wrong "high" costs a
|
|
63
|
-
* rejected tool result; a wrong "standard" only costs detail, so an unknown
|
|
64
|
-
* model gets the standard tier.
|
|
65
|
-
*/
|
|
66
|
-
export function screenshotLimitsForModel(model: string | undefined): ScreenshotLimits {
|
|
67
|
-
if (model === undefined) return STANDARD_SCREENSHOT_LIMITS
|
|
68
|
-
const match = /claude-(?:opus|sonnet|haiku|fable)-(\d+)(?:[-.](\d{1,2})(?!\d))?/i.exec(model)
|
|
69
|
-
if (!match) return STANDARD_SCREENSHOT_LIMITS
|
|
70
|
-
const major = Number(match[1])
|
|
71
|
-
const minor = match[2] === undefined ? 0 : Number(match[2])
|
|
72
|
-
// A dated id such as `claude-sonnet-4-20250514` has no minor: the date is not one.
|
|
73
|
-
return major > 4 || (major === 4 && minor >= 7)
|
|
74
|
-
? HIGH_RES_SCREENSHOT_LIMITS
|
|
75
|
-
: STANDARD_SCREENSHOT_LIMITS
|
|
76
|
-
}
|
|
57
|
+
export { screenshotLimitsForModel } from './computer-use-image.js'
|
|
77
58
|
|
|
78
59
|
export const COMPUTER_USE_TOOL_NAME = 'computer_use' as const
|
|
79
60
|
|
package/src/toolsets/manager.ts
CHANGED
|
@@ -540,9 +540,13 @@ export class ToolManager {
|
|
|
540
540
|
/**
|
|
541
541
|
* Put the tools that were loaded on request after the ones that are loaded
|
|
542
542
|
* from the start, in the order they were loaded. A load then extends the
|
|
543
|
-
* tools array of the previous request instead of reshaping it, so the
|
|
544
|
-
*
|
|
545
|
-
*
|
|
543
|
+
* tools array of the previous request instead of reshaping it, so the tools
|
|
544
|
+
* the request already had keep their place. It is still a change to the
|
|
545
|
+
* tools block, which a provider reads before the system prompt and the
|
|
546
|
+
* messages: the request that carries a new tool re-reads those once, and
|
|
547
|
+
* only the unchanged start of the tools block is kept. The order comes
|
|
548
|
+
* from the receipts in the history, so a compaction or a resume gives the
|
|
549
|
+
* same one.
|
|
546
550
|
*/
|
|
547
551
|
private loadedLast(tools: ToolDefinition[]): ToolDefinition[] {
|
|
548
552
|
const order = this.revealOrder()
|
|
@@ -107,6 +107,28 @@ export interface TokenUsage {
|
|
|
107
107
|
* provider reported nothing, a pending answer, or a hit.
|
|
108
108
|
*/
|
|
109
109
|
cacheMiss?: CacheMiss
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The request shape the driver actually put on the wire for this call, when
|
|
113
|
+
* it can say: a driver that drops a field after the backend refused it
|
|
114
|
+
* reports what remained. Per call, never summed. Absent means the driver
|
|
115
|
+
* does not report it, not that nothing was sent.
|
|
116
|
+
*/
|
|
117
|
+
requestShape?: RequestWireShape
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** What a driver sent for one call, as far as the prompt cache is concerned. See {@link TokenUsage.requestShape}. */
|
|
121
|
+
export interface RequestWireShape {
|
|
122
|
+
/** A cache key naming the conversation was sent. */
|
|
123
|
+
cacheKey: boolean
|
|
124
|
+
/** A session header naming the conversation was sent. */
|
|
125
|
+
sessionHeader: boolean
|
|
126
|
+
/**
|
|
127
|
+
* True while the backend's refusal of the `developer` role is in force for the driver
|
|
128
|
+
* (it is process-wide), so it is true on every request made under it, whether or not
|
|
129
|
+
* that request had guidance to send. Absent or false otherwise.
|
|
130
|
+
*/
|
|
131
|
+
developerRefused?: boolean
|
|
110
132
|
}
|
|
111
133
|
|
|
112
134
|
/** A prompt-cache miss as the provider explains it. See {@link TokenUsage.cacheMiss}. */
|
|
@@ -147,7 +169,7 @@ export function accumulateTokenUsage(current: TokenUsage, addition: TokenUsage):
|
|
|
147
169
|
? { reportedCostUsd: (current.reportedCostUsd ?? 0) + (addition.reportedCostUsd ?? 0) }
|
|
148
170
|
: {}),
|
|
149
171
|
// `fullPromptTokens`, `cacheTtlMs`, `cacheWriteTtlTokens`, `speed`, `serviceTier`,
|
|
150
|
-
// `inferenceGeo` and `
|
|
172
|
+
// `inferenceGeo`, `cacheMiss` and `requestShape` are per-call facts and are deliberately
|
|
151
173
|
// not carried into a sum.
|
|
152
174
|
}
|
|
153
175
|
}
|
|
@@ -212,6 +234,9 @@ export function mergeTokenUsage(current: TokenUsage, next: TokenUsage): TokenUsa
|
|
|
212
234
|
...(next.cacheMiss !== undefined || current.cacheMiss !== undefined
|
|
213
235
|
? { cacheMiss: next.cacheMiss ?? current.cacheMiss }
|
|
214
236
|
: {}),
|
|
237
|
+
...(next.requestShape !== undefined || current.requestShape !== undefined
|
|
238
|
+
? { requestShape: next.requestShape ?? current.requestShape }
|
|
239
|
+
: {}),
|
|
215
240
|
}
|
|
216
241
|
}
|
|
217
242
|
|
package/src/types/hitl/index.ts
CHANGED
|
@@ -188,6 +188,17 @@ export interface ResumeContext {
|
|
|
188
188
|
readonly transcript: () => readonly Message[]
|
|
189
189
|
/** The turn's cancellation signal, when it has one. */
|
|
190
190
|
readonly signal?: AbortSignal
|
|
191
|
+
/**
|
|
192
|
+
* Resolves when the person wrote a message to this turn, and for no other
|
|
193
|
+
* reason; the supplied signal ends the wait and releases its listener. Present
|
|
194
|
+
* only when the host has a live message box for the turn.
|
|
195
|
+
*
|
|
196
|
+
* A handler that puts a question to a person reads it: a message that arrives
|
|
197
|
+
* while the question is open (or was already waiting when it would be asked)
|
|
198
|
+
* closes the question, so the turn never carries on beside a request nobody
|
|
199
|
+
* will answer. The message itself is delivered in the turn's usual way.
|
|
200
|
+
*/
|
|
201
|
+
readonly waitForOperator?: (signal: AbortSignal) => Promise<void>
|
|
191
202
|
/**
|
|
192
203
|
* The script files a shell line launches that the agent wrote, or that came
|
|
193
204
|
* into being during the session, read now. Absent when the host keeps no
|
|
@@ -31,6 +31,13 @@ export interface EmbeddingConfig {
|
|
|
31
31
|
* loud.
|
|
32
32
|
*/
|
|
33
33
|
export interface HttpEmbeddingConfig extends EmbeddingConfig {
|
|
34
|
+
/** Let the server choose the vector width and omit dimensions from the request. */
|
|
35
|
+
useModelDimensions?: boolean
|
|
36
|
+
/** Override the HTTP transport, for example to connect directly to a local server. */
|
|
37
|
+
fetch?: (
|
|
38
|
+
url: string,
|
|
39
|
+
init: RequestInit,
|
|
40
|
+
) => Promise<Pick<Response, 'ok' | 'status' | 'text' | 'json'>>
|
|
34
41
|
apiKey: string
|
|
35
42
|
/** Root of an embeddings API; `/embeddings` is appended. */
|
|
36
43
|
baseUrl: string
|
|
@@ -178,6 +178,25 @@ export interface SandboxExecOptions {
|
|
|
178
178
|
* returns an explicit unsupported error before running the command.
|
|
179
179
|
*/
|
|
180
180
|
readonly signal?: AbortSignal
|
|
181
|
+
/**
|
|
182
|
+
* Text to give the command on its standard input; stdin is closed once it
|
|
183
|
+
* has been written, so a program that reads to the end sees end-of-file.
|
|
184
|
+
*
|
|
185
|
+
* **Who honours it.** The agent-backed backends in `@namzu/sandbox`
|
|
186
|
+
* (Firecracker microVMs and Kubernetes pods) carry it on the wire request
|
|
187
|
+
* the guest agent already accepts, under the same abort, timeout and
|
|
188
|
+
* output rules as the rest of `exec`. A backend without a guest agent (the
|
|
189
|
+
* in-process local sandbox, the Docker and ACI HTTP workers, the local
|
|
190
|
+
* virtual computer) **refuses** a call that carries it, before anything
|
|
191
|
+
* runs, with a {@link SandboxExecStdinError}; it never drops the input and
|
|
192
|
+
* runs the command on an empty stdin. A detached Kubernetes exec refuses
|
|
193
|
+
* it too.
|
|
194
|
+
*
|
|
195
|
+
* Bounded: the UTF-8 encoding may be at most
|
|
196
|
+
* {@link SANDBOX_EXEC_STDIN_MAX_BYTES} bytes. Larger input is refused
|
|
197
|
+
* before it is sent; stage a big document with `writeFile` instead.
|
|
198
|
+
*/
|
|
199
|
+
readonly stdin?: string
|
|
181
200
|
}
|
|
182
201
|
|
|
183
202
|
// ---------------------------------------------------------------------------
|
|
@@ -26,6 +26,49 @@ import type { MessageStopReason, StopReason } from './stop-reason.js'
|
|
|
26
26
|
import type { SubSessionKind } from './sub-session.js'
|
|
27
27
|
import type { LiveTurnSettlement, Origin, TurnBudgetBinding, TurnConfigSnapshot } from './turn.js'
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Where a request's start differs from the previous request of its
|
|
31
|
+
* conversation, without any of its content. A provider cache reads a request
|
|
32
|
+
* from its start (model, tools, system text, then each message), so the first
|
|
33
|
+
* thing that moved is where the cache can no longer be read.
|
|
34
|
+
*
|
|
35
|
+
* Every field is a hash; none can be turned back into text.
|
|
36
|
+
*/
|
|
37
|
+
export interface RequestPrefixDigest {
|
|
38
|
+
/** Hash of the model name. */
|
|
39
|
+
model: string
|
|
40
|
+
/** Hash of the tools as sent, in order. */
|
|
41
|
+
tools: string
|
|
42
|
+
/** Hash of the leading system messages. */
|
|
43
|
+
system: string
|
|
44
|
+
/** Hash of the settings that are not part of the start but can still move a cache (effort, speed, tool choice). */
|
|
45
|
+
params: string
|
|
46
|
+
/** One 6-character hash per message after the leading system run, in order, concatenated. */
|
|
47
|
+
items: string
|
|
48
|
+
/**
|
|
49
|
+
* What the driver reports it sent after the backend's refusals, when it reports it:
|
|
50
|
+
* whether a cache key and a session header named the conversation, and whether the
|
|
51
|
+
* backend's refusal of the `developer` role is in force (true on every request made
|
|
52
|
+
* under it, whether or not that request had guidance). Absent for a driver that does
|
|
53
|
+
* not say; never assumed from what was asked for.
|
|
54
|
+
*/
|
|
55
|
+
cacheKey?: boolean
|
|
56
|
+
sessionHeader?: boolean
|
|
57
|
+
developerRefused?: boolean
|
|
58
|
+
/**
|
|
59
|
+
* Which of the above moved since the previous request of this conversation in this
|
|
60
|
+
* process (`wire` is the three reported fields together). Absent for the first request
|
|
61
|
+
* of the process, including the first after a restart or resume: there is nothing to compare with.
|
|
62
|
+
*/
|
|
63
|
+
changed?: ('model' | 'tools' | 'system' | 'params' | 'wire')[]
|
|
64
|
+
/**
|
|
65
|
+
* The index of the first earlier message that this request does not repeat in place
|
|
66
|
+
* (the previous request's own request-only notes, which no request repeats, do not count).
|
|
67
|
+
* Absent when every earlier message is still where it was.
|
|
68
|
+
*/
|
|
69
|
+
firstChangedItem?: number
|
|
70
|
+
}
|
|
71
|
+
|
|
29
72
|
/**
|
|
30
73
|
* Live events of a session: the stream a host listens to while a turn runs.
|
|
31
74
|
*
|
|
@@ -963,6 +1006,12 @@ type CoreSessionEvent =
|
|
|
963
1006
|
* shows it should do so quietly; a miss after an edit is ordinary.
|
|
964
1007
|
*/
|
|
965
1008
|
cacheMiss?: { reason: string; missedTokens?: number }
|
|
1009
|
+
/**
|
|
1010
|
+
* What this request's start was, as hashes, and what moved since the
|
|
1011
|
+
* request before it: the record that says where a fall in the cached
|
|
1012
|
+
* share began. Optional; an older reader ignores it.
|
|
1013
|
+
*/
|
|
1014
|
+
requestPrefix?: RequestPrefixDigest
|
|
966
1015
|
/**
|
|
967
1016
|
* How large the CONTEXT is right now, and how large it may get.
|
|
968
1017
|
*
|
|
@@ -999,6 +999,17 @@ export const SessionRecordSchema = z
|
|
|
999
999
|
message: `${r.type} happens only inside a turn and must carry turnId`,
|
|
1000
1000
|
})
|
|
1001
1001
|
}
|
|
1002
|
+
if (
|
|
1003
|
+
r.type === 'compaction_shed' &&
|
|
1004
|
+
r.messagesSpill !== undefined &&
|
|
1005
|
+
(!Array.isArray(r.messages) || !spill.safeParse(r.messagesSpill).success)
|
|
1006
|
+
) {
|
|
1007
|
+
context.addIssue({
|
|
1008
|
+
code: z.ZodIssueCode.custom,
|
|
1009
|
+
path: ['messagesSpill'],
|
|
1010
|
+
message: 'Invalid shed message spill or inline projection.',
|
|
1011
|
+
})
|
|
1012
|
+
}
|
|
1002
1013
|
if (
|
|
1003
1014
|
r.type === 'tool_completed' &&
|
|
1004
1015
|
r.inputFailure !== undefined &&
|
|
@@ -1163,6 +1174,9 @@ export type SessionEventRecord<T extends PersistedSessionEventType = PersistedSe
|
|
|
1163
1174
|
readonly structuredOutputSpill?: z.infer<typeof structuredResultSpill>
|
|
1164
1175
|
}
|
|
1165
1176
|
: unknown) &
|
|
1177
|
+
(T extends 'compaction_shed'
|
|
1178
|
+
? { readonly messagesSpill?: z.infer<typeof spill> }
|
|
1179
|
+
: unknown) &
|
|
1166
1180
|
(T extends TurnBoundSessionEventType ? { readonly turnId: TurnId } : unknown)
|
|
1167
1181
|
: never
|
|
1168
1182
|
|