@namzu/sdk 53.2.1 → 54.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 +30 -0
- package/dist/compaction/context-breakdown.d.ts +85 -0
- package/dist/compaction/context-breakdown.d.ts.map +1 -0
- package/dist/compaction/context-breakdown.js +149 -0
- package/dist/compaction/context-breakdown.js.map +1 -0
- package/dist/compaction/token-estimate.d.ts +2 -0
- package/dist/compaction/token-estimate.d.ts.map +1 -1
- package/dist/compaction/token-estimate.js +4 -0
- package/dist/compaction/token-estimate.js.map +1 -1
- package/dist/public-runtime.d.ts +7 -2
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +6 -1
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/cache-clock.d.ts +39 -0
- package/dist/runtime/cache-clock.d.ts.map +1 -0
- package/dist/runtime/cache-clock.js +48 -0
- package/dist/runtime/cache-clock.js.map +1 -0
- package/dist/runtime/query/compact-session.d.ts +37 -2
- package/dist/runtime/query/compact-session.d.ts.map +1 -1
- package/dist/runtime/query/compact-session.js +77 -3
- package/dist/runtime/query/compact-session.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +3 -0
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +8 -0
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/store/budget/disk.js +4 -1
- package/dist/store/budget/disk.js.map +1 -1
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +6 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +23 -9
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser.js +1 -1
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use.js +2 -2
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/edit-apply.d.ts +7 -4
- package/dist/tools/builtins/edit-apply.d.ts.map +1 -1
- package/dist/tools/builtins/edit-apply.js +3 -0
- package/dist/tools/builtins/edit-apply.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +27 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/exit-semantics.d.ts +31 -0
- package/dist/tools/builtins/exit-semantics.d.ts.map +1 -0
- package/dist/tools/builtins/exit-semantics.js +198 -0
- package/dist/tools/builtins/exit-semantics.js.map +1 -0
- package/dist/tools/builtins/write-file.js +7 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +1 -1
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/index.js +2 -2
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/memory/delete.js +1 -1
- package/dist/tools/memory/delete.js.map +1 -1
- package/dist/tools/memory/fields.js +1 -1
- package/dist/tools/memory/fields.js.map +1 -1
- package/dist/tools/memory/read.js +1 -1
- package/dist/tools/memory/read.js.map +1 -1
- package/dist/tools/memory/save.d.ts.map +1 -1
- package/dist/tools/memory/save.js +4 -3
- package/dist/tools/memory/save.js.map +1 -1
- package/dist/tools/memory/search.js +1 -1
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.js +1 -1
- package/dist/tools/memory/update.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +3 -3
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +6 -1
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/types/common/index.d.ts +19 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +9 -0
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +8 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +6 -0
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/session/checkpoint.d.ts +52 -0
- package/dist/types/session/checkpoint.d.ts.map +1 -1
- package/dist/types/session/checkpoint.js +5 -0
- package/dist/types/session/checkpoint.js.map +1 -1
- package/dist/types/session/events.d.ts +9 -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 +181 -6
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +1 -1
- package/dist/types/session/records.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +17 -1
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/compaction/context-breakdown.ts +228 -0
- package/src/compaction/token-estimate.ts +5 -0
- package/src/public-runtime.ts +23 -2
- package/src/runtime/cache-clock.ts +67 -0
- package/src/runtime/query/compact-session.ts +101 -3
- package/src/runtime/query/executor/tool-call-admission.ts +3 -0
- package/src/runtime/query/iteration/index.ts +8 -0
- package/src/store/budget/disk.ts +4 -1
- package/src/tools/admit-facts.ts +6 -0
- package/src/tools/builtins/bash.ts +25 -9
- package/src/tools/builtins/browser.ts +1 -1
- package/src/tools/builtins/computer-use.ts +2 -2
- package/src/tools/builtins/edit-apply.ts +12 -2
- package/src/tools/builtins/edit.ts +34 -8
- package/src/tools/builtins/exit-semantics.ts +198 -0
- package/src/tools/builtins/write-file.ts +7 -2
- package/src/tools/coordinator/ask-user-question.ts +1 -1
- package/src/tools/coordinator/index.ts +2 -2
- package/src/tools/memory/delete.ts +1 -1
- package/src/tools/memory/fields.ts +1 -1
- package/src/tools/memory/read.ts +1 -1
- package/src/tools/memory/save.ts +4 -3
- package/src/tools/memory/search.ts +1 -1
- package/src/tools/memory/update.ts +1 -1
- package/src/tools/schedules/schedule-tool.ts +3 -3
- package/src/toolsets/manager.ts +6 -1
- package/src/types/common/index.ts +27 -0
- package/src/types/provider/chat.ts +8 -0
- package/src/types/provider/config.ts +6 -0
- package/src/types/session/checkpoint.ts +5 -0
- package/src/types/session/events.ts +6 -0
- package/src/types/session/records.ts +1 -1
- package/src/types/tool/presentation.ts +16 -0
|
@@ -24,6 +24,24 @@ export interface TokenUsage {
|
|
|
24
24
|
* not zero.
|
|
25
25
|
*/
|
|
26
26
|
reasoningTokens?: number
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* How long the provider keeps the prompt cache this call used, in
|
|
30
|
+
* milliseconds, as the call itself reported or requested it.
|
|
31
|
+
*
|
|
32
|
+
* A fact about ONE model call, so it is never summed: {@link accumulateTokenUsage}
|
|
33
|
+
* drops it, and {@link mergeTokenUsage} (frames of one streamed call) keeps the
|
|
34
|
+
* latest value. Absent means the driver does not report a lifetime (or does
|
|
35
|
+
* not cache); a host must not guess one.
|
|
36
|
+
*/
|
|
37
|
+
cacheTtlMs?: number
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Cache-write tokens split by the lifetime they were written with. Present
|
|
41
|
+
* only when the provider breaks its write count down. Per call, like
|
|
42
|
+
* {@link TokenUsage.cacheTtlMs}.
|
|
43
|
+
*/
|
|
44
|
+
cacheWriteTtlTokens?: { fiveMin?: number; oneHour?: number }
|
|
27
45
|
}
|
|
28
46
|
|
|
29
47
|
export function accumulateTokenUsage(current: TokenUsage, addition: TokenUsage): TokenUsage {
|
|
@@ -40,6 +58,8 @@ export function accumulateTokenUsage(current: TokenUsage, addition: TokenUsage):
|
|
|
40
58
|
...(current.reasoningTokens !== undefined || addition.reasoningTokens !== undefined
|
|
41
59
|
? { reasoningTokens: (current.reasoningTokens ?? 0) + (addition.reasoningTokens ?? 0) }
|
|
42
60
|
: {}),
|
|
61
|
+
// `cacheTtlMs` and `cacheWriteTtlTokens` are per-call facts and are
|
|
62
|
+
// deliberately not carried into a sum.
|
|
43
63
|
}
|
|
44
64
|
}
|
|
45
65
|
|
|
@@ -74,6 +94,13 @@ export function mergeTokenUsage(current: TokenUsage, next: TokenUsage): TokenUsa
|
|
|
74
94
|
...(current.reasoningTokens !== undefined || next.reasoningTokens !== undefined
|
|
75
95
|
? { reasoningTokens: Math.max(current.reasoningTokens ?? 0, next.reasoningTokens ?? 0) }
|
|
76
96
|
: {}),
|
|
97
|
+
// Frames of one call describe the same cache: the latest report wins.
|
|
98
|
+
...(next.cacheTtlMs !== undefined || current.cacheTtlMs !== undefined
|
|
99
|
+
? { cacheTtlMs: next.cacheTtlMs ?? current.cacheTtlMs }
|
|
100
|
+
: {}),
|
|
101
|
+
...(next.cacheWriteTtlTokens !== undefined || current.cacheWriteTtlTokens !== undefined
|
|
102
|
+
? { cacheWriteTtlTokens: next.cacheWriteTtlTokens ?? current.cacheWriteTtlTokens }
|
|
103
|
+
: {}),
|
|
77
104
|
}
|
|
78
105
|
}
|
|
79
106
|
|
|
@@ -21,6 +21,14 @@ export type ResponseFormat =
|
|
|
21
21
|
|
|
22
22
|
export interface CacheControl {
|
|
23
23
|
type: 'auto' | 'ephemeral'
|
|
24
|
+
/**
|
|
25
|
+
* How long the provider should keep this prefix cached: `'5m'` (the
|
|
26
|
+
* default every provider uses when this is absent) or `'1h'`. Honoured only
|
|
27
|
+
* by a driver that has an extended lifetime; others ignore it. The longer
|
|
28
|
+
* lifetime is priced higher for the cache write, so asking for it is a cost
|
|
29
|
+
* decision, not a translation.
|
|
30
|
+
*/
|
|
31
|
+
ttl?: '5m' | '1h'
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
export interface ChatCompletionParams {
|
|
@@ -157,6 +157,12 @@ export interface ProviderCapabilities {
|
|
|
157
157
|
/** Whether the driver maps document blocks returned by tools onto its result wire. */
|
|
158
158
|
supportsToolResultDocuments?: boolean
|
|
159
159
|
maxOutputTokens?: number
|
|
160
|
+
/**
|
|
161
|
+
* Prompt-cache lifetimes the driver can be asked for through
|
|
162
|
+
* `cacheControl.ttl`. Absent means the driver offers none (it has no cache,
|
|
163
|
+
* or the lifetime is the provider's own and cannot be chosen or read).
|
|
164
|
+
*/
|
|
165
|
+
cacheTtl?: readonly ('5m' | '1h')[]
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
export interface ProviderFactoryResult {
|
|
@@ -79,6 +79,11 @@ export const TokenUsageSchema = z
|
|
|
79
79
|
cachedTokens: count,
|
|
80
80
|
cacheWriteTokens: count,
|
|
81
81
|
reasoningTokens: count.optional(),
|
|
82
|
+
cacheTtlMs: count.optional(),
|
|
83
|
+
cacheWriteTtlTokens: z
|
|
84
|
+
.object({ fiveMin: count.optional(), oneHour: count.optional() })
|
|
85
|
+
.strict()
|
|
86
|
+
.optional(),
|
|
82
87
|
})
|
|
83
88
|
.strict()
|
|
84
89
|
|
|
@@ -811,6 +811,12 @@ type CoreSessionEvent =
|
|
|
811
811
|
turnId: TurnId
|
|
812
812
|
usage: TokenUsage
|
|
813
813
|
cost: CostInfo
|
|
814
|
+
/**
|
|
815
|
+
* The prompt cache after the latest model call alone (not the turn
|
|
816
|
+
* total above). Present only when the driver reports a lifetime;
|
|
817
|
+
* absent means unknown, and a host must not assume one.
|
|
818
|
+
*/
|
|
819
|
+
cache?: { ttlMs: number; touched: boolean }
|
|
814
820
|
/**
|
|
815
821
|
* How large the CONTEXT is right now, and how large it may get.
|
|
816
822
|
*
|
|
@@ -494,7 +494,7 @@ export const DecisionExpiredRecordSchema = inTurn('decision_expired', {
|
|
|
494
494
|
export const CompactionRecordSchema = recordSchema('compaction', {
|
|
495
495
|
compactionId: text.min(1),
|
|
496
496
|
strategy: text.min(1),
|
|
497
|
-
trigger: z.enum(['auto', 'manual']),
|
|
497
|
+
trigger: z.enum(['auto', 'manual', 'idle']),
|
|
498
498
|
replacesSeqRange: z.tuple([positive, positive]),
|
|
499
499
|
summary: z.union([z.array(messageBody), spill]),
|
|
500
500
|
keptMessageIds: z.array(messageId),
|
|
@@ -106,6 +106,16 @@ export type ToolFailureReason =
|
|
|
106
106
|
| 'unknown_tool'
|
|
107
107
|
| 'timed_out'
|
|
108
108
|
| 'invalid_input'
|
|
109
|
+
/** An edit or write on a file the conversation never read. */
|
|
110
|
+
| 'not_read'
|
|
111
|
+
/** An edit or write based on a copy that has since changed on disk. */
|
|
112
|
+
| 'changed_on_disk'
|
|
113
|
+
/** An edit whose text is not in the file. */
|
|
114
|
+
| 'text_not_found'
|
|
115
|
+
/** An edit whose text appears more than once. */
|
|
116
|
+
| 'not_unique'
|
|
117
|
+
/** The call's arguments did not fit the tool's input schema, so the tool never ran. */
|
|
118
|
+
| 'invalid_arguments'
|
|
109
119
|
|
|
110
120
|
/**
|
|
111
121
|
* What a call was about and what came of it, as typed fields.
|
|
@@ -126,6 +136,12 @@ export type ToolFacts =
|
|
|
126
136
|
/** The command line, on the call. */
|
|
127
137
|
readonly command?: string
|
|
128
138
|
readonly exitCode?: number
|
|
139
|
+
/**
|
|
140
|
+
* A non-zero `exitCode` that is the command's answer and not a failure
|
|
141
|
+
* (`grep` found nothing, `diff` found a difference): a short plain
|
|
142
|
+
* sentence. A host draws the call as having succeeded.
|
|
143
|
+
*/
|
|
144
|
+
readonly exitNote?: string
|
|
129
145
|
readonly timedOut?: boolean
|
|
130
146
|
/** The signal that ended it, when one did. */
|
|
131
147
|
readonly signal?: string
|