@namzu/sdk 74.0.0 → 74.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/config/runtime.d.ts +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +1 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +31 -7
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +176 -21
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -0
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +1 -0
- package/dist/public-runtime.js.map +1 -1
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +12 -2
- package/dist/runtime/query/guard.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 +3 -0
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +32 -11
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +2 -2
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +1 -1
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/sandbox/file-walk-program.js +1 -1
- package/dist/sandbox/ignore-matcher.d.ts +2 -0
- package/dist/sandbox/ignore-matcher.d.ts.map +1 -1
- package/dist/sandbox/ignore-matcher.js +8 -2
- package/dist/sandbox/ignore-matcher.js.map +1 -1
- package/dist/sandbox/ignore-source.d.ts.map +1 -1
- package/dist/sandbox/ignore-source.js +51 -7
- package/dist/sandbox/ignore-source.js.map +1 -1
- package/dist/sandbox/limit-error.d.ts +7 -0
- package/dist/sandbox/limit-error.d.ts.map +1 -0
- package/dist/sandbox/limit-error.js +13 -0
- package/dist/sandbox/limit-error.js.map +1 -0
- package/dist/sandbox/provider/local.d.ts +1 -0
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +50 -13
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/store/budget/ledger.d.ts +15 -1
- package/dist/store/budget/ledger.d.ts.map +1 -1
- package/dist/store/budget/ledger.js +80 -1
- package/dist/store/budget/ledger.js.map +1 -1
- package/dist/store/evidence/source-text.d.ts +1 -1
- package/dist/tools/builtins/atomic-write-file.d.ts +2 -0
- package/dist/tools/builtins/atomic-write-file.d.ts.map +1 -1
- package/dist/tools/builtins/atomic-write-file.js +37 -8
- package/dist/tools/builtins/atomic-write-file.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +20 -12
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +4 -3
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/tool-is-available.d.ts +4 -0
- package/dist/tools/tool-is-available.d.ts.map +1 -0
- package/dist/tools/tool-is-available.js +8 -0
- package/dist/tools/tool-is-available.js.map +1 -0
- package/dist/types/common/index.d.ts +6 -0
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +13 -0
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +13 -2
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/checkpoint.d.ts +4 -0
- package/dist/types/session/checkpoint.d.ts.map +1 -1
- package/dist/types/session/checkpoint.js +2 -0
- package/dist/types/session/checkpoint.js.map +1 -1
- package/dist/types/session/events.d.ts +1 -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 +42 -6
- package/dist/types/session/records.d.ts.map +1 -1
- package/dist/types/session/records.js +1 -0
- package/dist/types/session/records.js.map +1 -1
- package/dist/utils/cost.d.ts +17 -0
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +78 -8
- package/dist/utils/cost.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/manager/session/turn-recorder.ts +31 -7
- package/src/pricing/catalogue.generated.ts +176 -21
- package/src/pricing/rates.source.json +108 -33
- package/src/public-runtime.ts +1 -0
- package/src/runtime/query/guard.ts +13 -2
- package/src/runtime/query/index.ts +1 -0
- package/src/runtime/query/iteration/index.ts +32 -11
- package/src/runtime/query/iteration/phases/advisory.ts +2 -2
- package/src/runtime/query/prepare-turn.ts +2 -1
- package/src/sandbox/file-walk-program.ts +1 -1
- package/src/sandbox/ignore-matcher.ts +12 -3
- package/src/sandbox/ignore-source.ts +51 -7
- package/src/sandbox/limit-error.ts +10 -0
- package/src/sandbox/provider/local.ts +54 -23
- package/src/store/budget/ledger.ts +93 -2
- package/src/tools/builtins/atomic-write-file.ts +49 -7
- package/src/tools/builtins/read-file.ts +34 -12
- package/src/tools/defineTool.ts +4 -3
- package/src/tools/tool-is-available.ts +11 -0
- package/src/types/common/index.ts +24 -0
- package/src/types/sandbox/index.ts +12 -1
- package/src/types/session/checkpoint.ts +2 -0
- package/src/types/session/events.ts +1 -0
- package/src/types/session/records.ts +1 -0
- package/src/utils/cost.ts +101 -8
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"promptIncludesCacheReads": false,
|
|
72
72
|
"reportsCacheWrites": true,
|
|
73
73
|
"webSearchPer1000": 10,
|
|
74
|
-
"note": "The last two rows exist because the driver's own offline catalogue offers those models and this table did not price them — a lookup-key gap that reads as `cost unknown` and is invisible to the generator's own check, which only proves the module matches this file. `providers/anthropic` asserts the two lists agree. Vendor list prices, every row checked against its pricing page on the `verified` date. Cache read is the vendor's published 0.1x of the input rate, except on the six models it prices differently: 0.05x on claude-opus-5-5 and claude-sonnet-5-5 and 0.025x on claude-fable-5-1, claude-mythos-5-1, claude-fable-5-2 and claude-mythos-5-2, entered at the published rate rather than derived. The claude-haiku-5-5 tiers were checked on 2026-12-04 at https://platform.claude.com/docs/en/about-claude/pricing. The higher rates apply to the whole request above 100,000 prompt tokens, including cache reads and writes in the threshold count. Cache write is its published 1.25x for the five-minute entry, which is the default TTL and the one the driver's `cacheControl: { type: 'auto' }` asks for. claude-sonnet-5 launched at an introductory $2/$10 with $3/$15 scheduled from 2026-09-01, and this table recorded the scheduled rate; the vendor has since made $2/$10 the standard price and cancelled the increase. The table has no time dimension, so a future promotional window is still recorded at the list rate and over-reported rather than mis-modelled.",
|
|
74
|
+
"note": "The last two rows exist because the driver's own offline catalogue offers those models and this table did not price them — a lookup-key gap that reads as `cost unknown` and is invisible to the generator's own check, which only proves the module matches this file. `providers/anthropic` asserts the two lists agree. Vendor list prices, every row checked against its pricing page on the `verified` date. Cache read is the vendor's published 0.1x of the input rate, except on the six models it prices differently: 0.05x on claude-opus-5-5 and claude-sonnet-5-5 and 0.025x on claude-fable-5-1, claude-mythos-5-1, claude-fable-5-2 and claude-mythos-5-2, entered at the published rate rather than derived. The claude-haiku-5-5 tiers were checked on 2026-12-04 at https://platform.claude.com/docs/en/about-claude/pricing. The higher rates apply to the whole request above 100,000 prompt tokens, including cache reads and writes in the threshold count. Cache write is its published 1.25x for the five-minute entry, which is the default TTL and the one the driver's `cacheControl: { type: 'auto' }` asks for. The one-hour rate is 2x input. The direct API applies a 1.1x US-only surcharge on eligible models. claude-sonnet-5 launched at an introductory $2/$10 with $3/$15 scheduled from 2026-09-01, and this table recorded the scheduled rate; the vendor has since made $2/$10 the standard price and cancelled the increase. The table has no time dimension, so a future promotional window is still recorded at the list rate and over-reported rather than mis-modelled.",
|
|
75
75
|
"models": [
|
|
76
76
|
{
|
|
77
77
|
"id": "claude-fable-5-2",
|
|
@@ -79,7 +79,9 @@
|
|
|
79
79
|
"outputPer1M": 40,
|
|
80
80
|
"cacheReadPer1M": 0.2,
|
|
81
81
|
"cacheWritePer1M": 10,
|
|
82
|
-
"fastMultiplier": 2
|
|
82
|
+
"fastMultiplier": 2,
|
|
83
|
+
"cacheWrite1hPer1M": 16,
|
|
84
|
+
"usMultiplier": 1.1
|
|
83
85
|
},
|
|
84
86
|
{
|
|
85
87
|
"id": "claude-mythos-5-2",
|
|
@@ -87,21 +89,27 @@
|
|
|
87
89
|
"outputPer1M": 40,
|
|
88
90
|
"cacheReadPer1M": 0.2,
|
|
89
91
|
"cacheWritePer1M": 10,
|
|
90
|
-
"fastMultiplier": 2
|
|
92
|
+
"fastMultiplier": 2,
|
|
93
|
+
"cacheWrite1hPer1M": 16,
|
|
94
|
+
"usMultiplier": 1.1
|
|
91
95
|
},
|
|
92
96
|
{
|
|
93
97
|
"id": "claude-fable-5-1",
|
|
94
98
|
"inputPer1M": 10,
|
|
95
99
|
"outputPer1M": 50,
|
|
96
100
|
"cacheReadPer1M": 0.25,
|
|
97
|
-
"cacheWritePer1M": 12.5
|
|
101
|
+
"cacheWritePer1M": 12.5,
|
|
102
|
+
"cacheWrite1hPer1M": 20,
|
|
103
|
+
"usMultiplier": 1.1
|
|
98
104
|
},
|
|
99
105
|
{
|
|
100
106
|
"id": "claude-mythos-5-1",
|
|
101
107
|
"inputPer1M": 10,
|
|
102
108
|
"outputPer1M": 50,
|
|
103
109
|
"cacheReadPer1M": 0.25,
|
|
104
|
-
"cacheWritePer1M": 12.5
|
|
110
|
+
"cacheWritePer1M": 12.5,
|
|
111
|
+
"cacheWrite1hPer1M": 20,
|
|
112
|
+
"usMultiplier": 1.1
|
|
105
113
|
},
|
|
106
114
|
{
|
|
107
115
|
"id": "claude-opus-5-5",
|
|
@@ -109,28 +117,36 @@
|
|
|
109
117
|
"outputPer1M": 20,
|
|
110
118
|
"cacheReadPer1M": 0.2,
|
|
111
119
|
"cacheWritePer1M": 5,
|
|
112
|
-
"fastMultiplier": 2
|
|
120
|
+
"fastMultiplier": 2,
|
|
121
|
+
"cacheWrite1hPer1M": 8,
|
|
122
|
+
"usMultiplier": 1.1
|
|
113
123
|
},
|
|
114
124
|
{
|
|
115
125
|
"id": "claude-sonnet-5-5",
|
|
116
126
|
"inputPer1M": 2,
|
|
117
127
|
"outputPer1M": 10,
|
|
118
128
|
"cacheReadPer1M": 0.1,
|
|
119
|
-
"cacheWritePer1M": 2.5
|
|
129
|
+
"cacheWritePer1M": 2.5,
|
|
130
|
+
"cacheWrite1hPer1M": 4,
|
|
131
|
+
"usMultiplier": 1.1
|
|
120
132
|
},
|
|
121
133
|
{
|
|
122
134
|
"id": "claude-fable-5",
|
|
123
135
|
"inputPer1M": 10,
|
|
124
136
|
"outputPer1M": 50,
|
|
125
137
|
"cacheReadPer1M": 1,
|
|
126
|
-
"cacheWritePer1M": 12.5
|
|
138
|
+
"cacheWritePer1M": 12.5,
|
|
139
|
+
"cacheWrite1hPer1M": 20,
|
|
140
|
+
"usMultiplier": 1.1
|
|
127
141
|
},
|
|
128
142
|
{
|
|
129
143
|
"id": "claude-mythos-5",
|
|
130
144
|
"inputPer1M": 10,
|
|
131
145
|
"outputPer1M": 50,
|
|
132
146
|
"cacheReadPer1M": 1,
|
|
133
|
-
"cacheWritePer1M": 12.5
|
|
147
|
+
"cacheWritePer1M": 12.5,
|
|
148
|
+
"cacheWrite1hPer1M": 20,
|
|
149
|
+
"usMultiplier": 1.1
|
|
134
150
|
},
|
|
135
151
|
{
|
|
136
152
|
"id": "claude-opus-5",
|
|
@@ -138,7 +154,9 @@
|
|
|
138
154
|
"outputPer1M": 25,
|
|
139
155
|
"cacheReadPer1M": 0.5,
|
|
140
156
|
"cacheWritePer1M": 6.25,
|
|
141
|
-
"fastMultiplier": 2
|
|
157
|
+
"fastMultiplier": 2,
|
|
158
|
+
"cacheWrite1hPer1M": 10,
|
|
159
|
+
"usMultiplier": 1.1
|
|
142
160
|
},
|
|
143
161
|
{
|
|
144
162
|
"id": "claude-opus-4-8",
|
|
@@ -146,35 +164,44 @@
|
|
|
146
164
|
"outputPer1M": 25,
|
|
147
165
|
"cacheReadPer1M": 0.5,
|
|
148
166
|
"cacheWritePer1M": 6.25,
|
|
149
|
-
"
|
|
167
|
+
"cacheWrite1hPer1M": 10,
|
|
168
|
+
"usMultiplier": 1.1
|
|
150
169
|
},
|
|
151
170
|
{
|
|
152
171
|
"id": "claude-opus-4-7",
|
|
153
172
|
"inputPer1M": 5,
|
|
154
173
|
"outputPer1M": 25,
|
|
155
174
|
"cacheReadPer1M": 0.5,
|
|
156
|
-
"cacheWritePer1M": 6.25
|
|
175
|
+
"cacheWritePer1M": 6.25,
|
|
176
|
+
"cacheWrite1hPer1M": 10,
|
|
177
|
+
"usMultiplier": 1.1
|
|
157
178
|
},
|
|
158
179
|
{
|
|
159
180
|
"id": "claude-opus-4-6",
|
|
160
181
|
"inputPer1M": 5,
|
|
161
182
|
"outputPer1M": 25,
|
|
162
183
|
"cacheReadPer1M": 0.5,
|
|
163
|
-
"cacheWritePer1M": 6.25
|
|
184
|
+
"cacheWritePer1M": 6.25,
|
|
185
|
+
"cacheWrite1hPer1M": 10,
|
|
186
|
+
"usMultiplier": 1.1
|
|
164
187
|
},
|
|
165
188
|
{
|
|
166
189
|
"id": "claude-sonnet-5",
|
|
167
190
|
"inputPer1M": 2,
|
|
168
191
|
"outputPer1M": 10,
|
|
169
192
|
"cacheReadPer1M": 0.2,
|
|
170
|
-
"cacheWritePer1M": 2.5
|
|
193
|
+
"cacheWritePer1M": 2.5,
|
|
194
|
+
"cacheWrite1hPer1M": 4,
|
|
195
|
+
"usMultiplier": 1.1
|
|
171
196
|
},
|
|
172
197
|
{
|
|
173
198
|
"id": "claude-sonnet-4-6",
|
|
174
199
|
"inputPer1M": 3,
|
|
175
200
|
"outputPer1M": 15,
|
|
176
201
|
"cacheReadPer1M": 0.3,
|
|
177
|
-
"cacheWritePer1M": 3.75
|
|
202
|
+
"cacheWritePer1M": 3.75,
|
|
203
|
+
"cacheWrite1hPer1M": 6,
|
|
204
|
+
"usMultiplier": 1.1
|
|
178
205
|
},
|
|
179
206
|
{
|
|
180
207
|
"id": "claude-haiku-5-5",
|
|
@@ -182,12 +209,15 @@
|
|
|
182
209
|
"outputPer1M": 0.5,
|
|
183
210
|
"cacheReadPer1M": 0.01,
|
|
184
211
|
"cacheWritePer1M": 0.125,
|
|
212
|
+
"cacheWrite1hPer1M": 0.2,
|
|
213
|
+
"usMultiplier": 1.1,
|
|
185
214
|
"longContext": {
|
|
186
215
|
"aboveInputTokens": 100000,
|
|
187
216
|
"inputPer1M": 0.5,
|
|
188
217
|
"outputPer1M": 2.5,
|
|
189
218
|
"cacheReadPer1M": 0.05,
|
|
190
|
-
"cacheWritePer1M": 0.625
|
|
219
|
+
"cacheWritePer1M": 0.625,
|
|
220
|
+
"cacheWrite1hPer1M": 1
|
|
191
221
|
}
|
|
192
222
|
},
|
|
193
223
|
{
|
|
@@ -195,35 +225,40 @@
|
|
|
195
225
|
"inputPer1M": 1,
|
|
196
226
|
"outputPer1M": 5,
|
|
197
227
|
"cacheReadPer1M": 0.1,
|
|
198
|
-
"cacheWritePer1M": 1.25
|
|
228
|
+
"cacheWritePer1M": 1.25,
|
|
229
|
+
"cacheWrite1hPer1M": 2
|
|
199
230
|
},
|
|
200
231
|
{
|
|
201
232
|
"id": "claude-sonnet-4",
|
|
202
233
|
"inputPer1M": 3,
|
|
203
234
|
"outputPer1M": 15,
|
|
204
235
|
"cacheReadPer1M": 0.3,
|
|
205
|
-
"cacheWritePer1M": 3.75
|
|
236
|
+
"cacheWritePer1M": 3.75,
|
|
237
|
+
"cacheWrite1hPer1M": 6
|
|
206
238
|
},
|
|
207
239
|
{
|
|
208
240
|
"id": "claude-sonnet-4-5",
|
|
209
241
|
"inputPer1M": 3,
|
|
210
242
|
"outputPer1M": 15,
|
|
211
243
|
"cacheReadPer1M": 0.3,
|
|
212
|
-
"cacheWritePer1M": 3.75
|
|
244
|
+
"cacheWritePer1M": 3.75,
|
|
245
|
+
"cacheWrite1hPer1M": 6
|
|
213
246
|
},
|
|
214
247
|
{
|
|
215
248
|
"id": "claude-opus-4",
|
|
216
249
|
"inputPer1M": 15,
|
|
217
250
|
"outputPer1M": 75,
|
|
218
251
|
"cacheReadPer1M": 1.5,
|
|
219
|
-
"cacheWritePer1M": 18.75
|
|
252
|
+
"cacheWritePer1M": 18.75,
|
|
253
|
+
"cacheWrite1hPer1M": 30
|
|
220
254
|
},
|
|
221
255
|
{
|
|
222
256
|
"id": "claude-opus-4-1",
|
|
223
257
|
"inputPer1M": 15,
|
|
224
258
|
"outputPer1M": 75,
|
|
225
259
|
"cacheReadPer1M": 1.5,
|
|
226
|
-
"cacheWritePer1M": 18.75
|
|
260
|
+
"cacheWritePer1M": 18.75,
|
|
261
|
+
"cacheWrite1hPer1M": 30
|
|
227
262
|
}
|
|
228
263
|
]
|
|
229
264
|
},
|
|
@@ -245,7 +280,8 @@
|
|
|
245
280
|
"aboveInputTokens": 272000,
|
|
246
281
|
"inputPer1M": 16,
|
|
247
282
|
"outputPer1M": 60,
|
|
248
|
-
"cacheReadPer1M": 0.8
|
|
283
|
+
"cacheReadPer1M": 0.8,
|
|
284
|
+
"fastMultiplier": 2
|
|
249
285
|
}
|
|
250
286
|
},
|
|
251
287
|
{
|
|
@@ -270,7 +306,8 @@
|
|
|
270
306
|
"aboveInputTokens": 272000,
|
|
271
307
|
"inputPer1M": 4,
|
|
272
308
|
"outputPer1M": 15,
|
|
273
|
-
"cacheReadPer1M": 0.2
|
|
309
|
+
"cacheReadPer1M": 0.2,
|
|
310
|
+
"fastMultiplier": 2
|
|
274
311
|
}
|
|
275
312
|
},
|
|
276
313
|
{
|
|
@@ -295,7 +332,8 @@
|
|
|
295
332
|
"aboveInputTokens": 272000,
|
|
296
333
|
"inputPer1M": 4,
|
|
297
334
|
"outputPer1M": 15,
|
|
298
|
-
"cacheReadPer1M": 0.2
|
|
335
|
+
"cacheReadPer1M": 0.2,
|
|
336
|
+
"fastMultiplier": 2
|
|
299
337
|
}
|
|
300
338
|
},
|
|
301
339
|
{
|
|
@@ -320,7 +358,8 @@
|
|
|
320
358
|
"aboveInputTokens": 272000,
|
|
321
359
|
"inputPer1M": 2,
|
|
322
360
|
"outputPer1M": 7.5,
|
|
323
|
-
"cacheReadPer1M": 0.1
|
|
361
|
+
"cacheReadPer1M": 0.1,
|
|
362
|
+
"fastMultiplier": 2
|
|
324
363
|
}
|
|
325
364
|
},
|
|
326
365
|
{
|
|
@@ -333,7 +372,8 @@
|
|
|
333
372
|
"aboveInputTokens": 272000,
|
|
334
373
|
"inputPer1M": 20,
|
|
335
374
|
"outputPer1M": 75,
|
|
336
|
-
"cacheReadPer1M": 2
|
|
375
|
+
"cacheReadPer1M": 2,
|
|
376
|
+
"fastMultiplier": 2
|
|
337
377
|
}
|
|
338
378
|
},
|
|
339
379
|
{
|
|
@@ -358,7 +398,8 @@
|
|
|
358
398
|
"aboveInputTokens": 272000,
|
|
359
399
|
"inputPer1M": 0.2,
|
|
360
400
|
"outputPer1M": 0.75,
|
|
361
|
-
"cacheReadPer1M": 0.02
|
|
401
|
+
"cacheReadPer1M": 0.02,
|
|
402
|
+
"fastMultiplier": 2
|
|
362
403
|
}
|
|
363
404
|
},
|
|
364
405
|
{
|
|
@@ -371,7 +412,8 @@
|
|
|
371
412
|
"aboveInputTokens": 272000,
|
|
372
413
|
"inputPer1M": 4,
|
|
373
414
|
"outputPer1M": 15,
|
|
374
|
-
"cacheReadPer1M": 0.4
|
|
415
|
+
"cacheReadPer1M": 0.4,
|
|
416
|
+
"fastMultiplier": 2
|
|
375
417
|
}
|
|
376
418
|
},
|
|
377
419
|
{
|
|
@@ -379,35 +421,68 @@
|
|
|
379
421
|
"inputPer1M": 5,
|
|
380
422
|
"outputPer1M": 30,
|
|
381
423
|
"cacheReadPer1M": 0.5,
|
|
382
|
-
"fastMultiplier": 2
|
|
424
|
+
"fastMultiplier": 2,
|
|
425
|
+
"longContext": {
|
|
426
|
+
"aboveInputTokens": 272000,
|
|
427
|
+
"inputPer1M": 10,
|
|
428
|
+
"outputPer1M": 45,
|
|
429
|
+
"cacheReadPer1M": 1,
|
|
430
|
+
"fastMultiplier": 2
|
|
431
|
+
}
|
|
383
432
|
},
|
|
384
433
|
{
|
|
385
434
|
"id": "gpt-5.6-terra",
|
|
386
435
|
"inputPer1M": 2,
|
|
387
436
|
"outputPer1M": 12,
|
|
388
437
|
"cacheReadPer1M": 0.2,
|
|
389
|
-
"fastMultiplier": 2
|
|
438
|
+
"fastMultiplier": 2,
|
|
439
|
+
"longContext": {
|
|
440
|
+
"aboveInputTokens": 272000,
|
|
441
|
+
"inputPer1M": 4,
|
|
442
|
+
"outputPer1M": 18,
|
|
443
|
+
"cacheReadPer1M": 0.4,
|
|
444
|
+
"fastMultiplier": 2
|
|
445
|
+
}
|
|
390
446
|
},
|
|
391
447
|
{
|
|
392
448
|
"id": "gpt-5.6-luna",
|
|
393
449
|
"inputPer1M": 0.2,
|
|
394
450
|
"outputPer1M": 1.2,
|
|
395
451
|
"cacheReadPer1M": 0.02,
|
|
396
|
-
"fastMultiplier": 2
|
|
452
|
+
"fastMultiplier": 2,
|
|
453
|
+
"longContext": {
|
|
454
|
+
"aboveInputTokens": 272000,
|
|
455
|
+
"inputPer1M": 0.4,
|
|
456
|
+
"outputPer1M": 1.8,
|
|
457
|
+
"cacheReadPer1M": 0.04,
|
|
458
|
+
"fastMultiplier": 2
|
|
459
|
+
}
|
|
397
460
|
},
|
|
398
461
|
{
|
|
399
462
|
"id": "gpt-5.5",
|
|
400
463
|
"inputPer1M": 5,
|
|
401
464
|
"outputPer1M": 30,
|
|
402
465
|
"cacheReadPer1M": 0.5,
|
|
403
|
-
"fastMultiplier": 2.5
|
|
466
|
+
"fastMultiplier": 2.5,
|
|
467
|
+
"longContext": {
|
|
468
|
+
"aboveInputTokens": 272000,
|
|
469
|
+
"inputPer1M": 10,
|
|
470
|
+
"outputPer1M": 45,
|
|
471
|
+
"cacheReadPer1M": 1
|
|
472
|
+
}
|
|
404
473
|
},
|
|
405
474
|
{
|
|
406
475
|
"id": "gpt-5.4",
|
|
407
476
|
"inputPer1M": 2.5,
|
|
408
477
|
"outputPer1M": 15,
|
|
409
478
|
"cacheReadPer1M": 0.25,
|
|
410
|
-
"fastMultiplier": 2
|
|
479
|
+
"fastMultiplier": 2,
|
|
480
|
+
"longContext": {
|
|
481
|
+
"aboveInputTokens": 272000,
|
|
482
|
+
"inputPer1M": 5,
|
|
483
|
+
"outputPer1M": 22.5,
|
|
484
|
+
"cacheReadPer1M": 0.5
|
|
485
|
+
}
|
|
411
486
|
},
|
|
412
487
|
{
|
|
413
488
|
"id": "gpt-5.4-mini",
|
package/src/public-runtime.ts
CHANGED
|
@@ -1073,6 +1073,7 @@ export type {
|
|
|
1073
1073
|
LocalSandboxProviderOptions,
|
|
1074
1074
|
SandboxFileWalkExec,
|
|
1075
1075
|
} from './sandbox/index.js'
|
|
1076
|
+
export { SandboxLimitError } from './sandbox/limit-error.js'
|
|
1076
1077
|
|
|
1077
1078
|
// The classified provider-failure surface: a driver states what went wrong
|
|
1078
1079
|
// first-hand, and the turn boundary reads it to choose between a pause and a
|
|
@@ -124,11 +124,12 @@ export class GuardCoordinator {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
beforeIteration(recorder: TurnRecorder, abortSignal: AbortSignal): GuardCheckResult {
|
|
127
|
+
const cost = recorder.treeCostInfo ?? recorder.costInfo
|
|
127
128
|
const limitState = {
|
|
128
129
|
aborted: abortSignal.aborted,
|
|
129
130
|
totalTokens: recorder.tokenUsage.totalTokens,
|
|
130
|
-
totalCost:
|
|
131
|
-
unpricedTokens:
|
|
131
|
+
totalCost: cost.totalCost,
|
|
132
|
+
unpricedTokens: cost.unpricedTokens,
|
|
132
133
|
currentIteration: recorder.currentIteration,
|
|
133
134
|
startTime: this.startTime,
|
|
134
135
|
}
|
|
@@ -152,6 +153,16 @@ export class GuardCoordinator {
|
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
|
|
156
|
+
const ancestorStop = recorder.budget?.ancestorCostStop()
|
|
157
|
+
if (ancestorStop) {
|
|
158
|
+
return {
|
|
159
|
+
shouldStop: true,
|
|
160
|
+
forceFinalize: false,
|
|
161
|
+
stopReason: ancestorStop,
|
|
162
|
+
isCancelled: false,
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
155
166
|
if (limitResult.type === 'warning') {
|
|
156
167
|
return {
|
|
157
168
|
shouldStop: false,
|
|
@@ -1952,6 +1952,7 @@ export async function* query(params: QueryParams): AsyncGenerator<SessionEvent,
|
|
|
1952
1952
|
contributions: promptContributions,
|
|
1953
1953
|
})
|
|
1954
1954
|
|
|
1955
|
+
ctx.recorder.budget?.setCostLimit(turnConfig.costLimitUsd)
|
|
1955
1956
|
const guard = new GuardCoordinator({
|
|
1956
1957
|
tokenBudget: turnConfig.tokenBudget,
|
|
1957
1958
|
timeoutMs: turnConfig.timeoutMs,
|
|
@@ -389,6 +389,7 @@ export class IterationOrchestrator {
|
|
|
389
389
|
private stopHookActive = false
|
|
390
390
|
/** End-of-turn refusals honoured since the last tool call. */
|
|
391
391
|
private consecutiveHookRefusals = 0
|
|
392
|
+
private readonly schemaFailures = new Map<string, number>()
|
|
392
393
|
/** The cap was reached and its notice recorded; refusals are ignored for the rest of the turn. */
|
|
393
394
|
private hookRefusalCapReached = false
|
|
394
395
|
get turnEndHooksFired(): boolean {
|
|
@@ -1509,6 +1510,7 @@ export class IterationOrchestrator {
|
|
|
1509
1510
|
usage: recorder.tokenUsage,
|
|
1510
1511
|
budget: recorder.budget?.summary(),
|
|
1511
1512
|
cost: recorder.costInfo,
|
|
1513
|
+
...(response.usage.billingRoute ? { billingRoute: response.usage.billingRoute } : {}),
|
|
1512
1514
|
...(response.usage.cacheTtlMs !== undefined
|
|
1513
1515
|
? {
|
|
1514
1516
|
cache: {
|
|
@@ -2250,18 +2252,19 @@ export class IterationOrchestrator {
|
|
|
2250
2252
|
return
|
|
2251
2253
|
}
|
|
2252
2254
|
|
|
2253
|
-
//
|
|
2254
|
-
// answered. Every `tool_use` has its `tool_result` by now, so the
|
|
2255
|
-
// transcript is whole; what is left is to end the turn and say why.
|
|
2255
|
+
// End only after the batch has answered every tool call.
|
|
2256
2256
|
const hookHalt = this.ctx.toolExecutor.takeHalt?.()
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2257
|
+
const validationHalt = this.repeatedValidationFailure(reviewOutcome.results)
|
|
2258
|
+
if (hookHalt !== undefined || validationHalt !== undefined) {
|
|
2259
|
+
if (hookHalt !== undefined) {
|
|
2260
|
+
this.ctx.log.info('A hook stopped the turn', {
|
|
2261
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
2262
|
+
[NAMZU.ITERATION]: iterationNum,
|
|
2263
|
+
'namzu.hook.reason': hookHalt,
|
|
2264
|
+
})
|
|
2265
|
+
recorder.setLastError(`Stopped by a hook: ${hookHalt}`)
|
|
2266
|
+
recorder.setStopReason('stop_condition')
|
|
2267
|
+
}
|
|
2265
2268
|
await this.ctx.emitEvent({
|
|
2266
2269
|
type: 'iteration_completed',
|
|
2267
2270
|
turnId: recorder.turnId,
|
|
@@ -2269,6 +2272,9 @@ export class IterationOrchestrator {
|
|
|
2269
2272
|
hasToolCalls: true,
|
|
2270
2273
|
})
|
|
2271
2274
|
yield* this.ctx.drainPending()
|
|
2275
|
+
if (hookHalt === undefined && validationHalt !== undefined) {
|
|
2276
|
+
throw new Error(validationHalt)
|
|
2277
|
+
}
|
|
2272
2278
|
break
|
|
2273
2279
|
}
|
|
2274
2280
|
|
|
@@ -2977,6 +2983,21 @@ export class IterationOrchestrator {
|
|
|
2977
2983
|
return true
|
|
2978
2984
|
}
|
|
2979
2985
|
|
|
2986
|
+
/** Admission failures have no execution receipt for the repeat-call advisory. */
|
|
2987
|
+
private repeatedValidationFailure(results: readonly ToolCallOutcome[]): string | undefined {
|
|
2988
|
+
for (const { toolName, inputFailure, output } of results) {
|
|
2989
|
+
// Structured output has a separate, configurable correction allowance.
|
|
2990
|
+
if (inputFailure !== 'schema_validation' || toolName === STRUCTURED_OUTPUT_TOOL_NAME) continue
|
|
2991
|
+
const key = JSON.stringify([toolName, output])
|
|
2992
|
+
const count = (this.schemaFailures.get(key) ?? 0) + 1
|
|
2993
|
+
this.schemaFailures.set(key, count)
|
|
2994
|
+
if (count === 4) {
|
|
2995
|
+
return `Stopped after ${count} identical validation failures for "${toolName}" in this turn. ${output}`
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
return undefined
|
|
2999
|
+
}
|
|
3000
|
+
|
|
2980
3001
|
private async recordToolStructuredFailure(
|
|
2981
3002
|
results: readonly ToolCallOutcome[],
|
|
2982
3003
|
iteration: number,
|
|
@@ -27,7 +27,7 @@ function estimateContextWindowPercent(ctx: IterationContext): number {
|
|
|
27
27
|
function computeCostBudgetPercent(ctx: IterationContext): number | undefined {
|
|
28
28
|
const limit = ctx.turnConfig.costLimitUsd
|
|
29
29
|
if (limit === undefined || limit <= 0) return undefined
|
|
30
|
-
return (ctx.recorder.costInfo.totalCost / limit) * 100
|
|
30
|
+
return ((ctx.recorder.treeCostInfo ?? ctx.recorder.costInfo).totalCost / limit) * 100
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function extractLastToolCategory(
|
|
@@ -67,7 +67,7 @@ export async function runAdvisoryPhase(
|
|
|
67
67
|
totalToolCalls: countToolCalls(ctx),
|
|
68
68
|
totalTokens: ctx.recorder.tokenUsage.totalTokens,
|
|
69
69
|
contextWindowPercent: estimateContextWindowPercent(ctx),
|
|
70
|
-
totalCostUsd: ctx.recorder.costInfo.totalCost,
|
|
70
|
+
totalCostUsd: (ctx.recorder.treeCostInfo ?? ctx.recorder.costInfo).totalCost,
|
|
71
71
|
costBudgetPercent: computeCostBudgetPercent(ctx),
|
|
72
72
|
lastError: extractCurrentToolErrors(ctx, response),
|
|
73
73
|
lastToolCategory: extractLastToolCategory(ctx, response),
|
|
@@ -192,7 +192,8 @@ function assertBudgetIsMeasurable(params: QueryParams): void {
|
|
|
192
192
|
// brought one has answered the question themselves.
|
|
193
193
|
if (params.pricing !== undefined) return
|
|
194
194
|
// A driver that reports each call's billed cost measures the limit itself.
|
|
195
|
-
if (params.provider.capabilities?.reportsRequestCost === true)
|
|
195
|
+
if (params.provider.capabilities?.reportsRequestCost === true || params.provider.id === 'codex')
|
|
196
|
+
return
|
|
196
197
|
const model = params.turnConfig.model
|
|
197
198
|
if (resolveModelPricing(params.provider.id, model) !== undefined) return
|
|
198
199
|
|
|
@@ -50,7 +50,7 @@ async function run() {
|
|
|
50
50
|
let emitted = 0;
|
|
51
51
|
const matchers = plan.expressions.map(({source, flags}) => new RegExp(source, flags + 's'));
|
|
52
52
|
const maxDepth = plan.maxDepth === null ? Infinity : plan.maxDepth;
|
|
53
|
-
const ignore = plan.respectIgnore ? ignCreate({fs, path, extraFiles: []}) : null;
|
|
53
|
+
const ignore = plan.respectIgnore ? ignCreate({fs, syncFs: require('node:fs'), path, extraFiles: []}) : null;
|
|
54
54
|
const open = async (absolute, relative, depth, layered) => {
|
|
55
55
|
try {
|
|
56
56
|
const dir = await fs.opendir(absolute);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as fs from 'node:fs'
|
|
2
|
+
import * as path from 'node:path'
|
|
1
3
|
import { IGNORE_SOURCE } from './ignore-source.js'
|
|
2
4
|
|
|
3
5
|
/** One compiled ignore rule. */
|
|
@@ -29,19 +31,26 @@ export interface IgnoreDeps {
|
|
|
29
31
|
interface IgnoreModule {
|
|
30
32
|
parse(text: string): IgnoreRule[]
|
|
31
33
|
decide(rules: readonly IgnoreRule[], relative: string, isDirectory: boolean): 0 | 1 | 2
|
|
32
|
-
create(deps: IgnoreDeps): IgnoreStack
|
|
34
|
+
create(deps: IgnoreDeps & { syncFs: typeof fs }): IgnoreStack
|
|
35
|
+
gitDirectory(directory: string, syncFs: typeof fs, paths: typeof path): string | null
|
|
33
36
|
vcs: readonly string[]
|
|
34
37
|
}
|
|
35
38
|
|
|
36
39
|
// The same text is embedded in the guest program, so both walks share it.
|
|
37
40
|
const module_ = new Function(
|
|
38
|
-
`${IGNORE_SOURCE}\nreturn { parse: ignParse, decide: ignDecide, create: ignCreate, vcs: IGN_VCS }`,
|
|
41
|
+
`${IGNORE_SOURCE}\nreturn { parse: ignParse, decide: ignDecide, create: ignCreate, gitDirectory, vcs: IGN_VCS }`,
|
|
39
42
|
)() as IgnoreModule
|
|
40
43
|
|
|
41
44
|
/** Parse the text of one ignore file into rules; a line it cannot read is dropped. */
|
|
42
45
|
export const parseIgnoreRules = module_.parse
|
|
43
46
|
/** 0: no rule matches, 1: ignored, 2: re-included. The last matching rule wins. */
|
|
44
47
|
export const decideIgnore = module_.decide
|
|
45
|
-
export const createIgnoreStack =
|
|
48
|
+
export const createIgnoreStack = (deps: IgnoreDeps): IgnoreStack =>
|
|
49
|
+
module_.create({ ...deps, syncFs: fs })
|
|
50
|
+
|
|
51
|
+
/** @internal Check whether this directory itself has a valid checkout marker. */
|
|
52
|
+
export function hasGitCheckoutMarker(directory: string): boolean {
|
|
53
|
+
return module_.gitDirectory(directory, fs, path) !== null
|
|
54
|
+
}
|
|
46
55
|
/** Version-control directories that no walk ever descends into. */
|
|
47
56
|
export const VCS_NAMES: ReadonlySet<string> = new Set(module_.vcs)
|
|
@@ -132,10 +132,50 @@ function ignDecide(rules, relative, isDirectory) {
|
|
|
132
132
|
}
|
|
133
133
|
return 0;
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Resolve a checkout marker. A linked worktree uses its own HEAD and the
|
|
137
|
+
* objects and refs from its common directory.
|
|
138
|
+
*/
|
|
139
|
+
function gitDirectory(directory, fs, path) {
|
|
140
|
+
try {
|
|
141
|
+
const marker = path.join(directory, '.git');
|
|
142
|
+
const info = fs.statSync(marker);
|
|
143
|
+
let gitDir = marker;
|
|
144
|
+
if (info.isFile()) {
|
|
145
|
+
if (info.size > 4096) return null;
|
|
146
|
+
const pointer = /^gitdir: ([^\r\n\0]+)(?:\r?\n)?$/.exec(fs.readFileSync(marker, 'utf8'));
|
|
147
|
+
if (!pointer) return null;
|
|
148
|
+
gitDir = path.resolve(directory, pointer[1]);
|
|
149
|
+
if (!fs.statSync(gitDir).isDirectory()) return null;
|
|
150
|
+
} else if (!info.isDirectory()) {
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
const head = path.join(gitDir, 'HEAD');
|
|
154
|
+
const headInfo = fs.statSync(head);
|
|
155
|
+
if (!headInfo.isFile() || headInfo.size > 4096) return null;
|
|
156
|
+
const headText = fs.readFileSync(head, 'utf8');
|
|
157
|
+
if (!/^(?:ref:[ \t]*refs\/[^\r\n]+|[0-9a-f]{40}(?:[0-9a-f]{24})?)(?:\r?\n)?$/.test(headText)) return null;
|
|
158
|
+
const common = path.join(gitDir, 'commondir');
|
|
159
|
+
const commonInfo = fs.statSync(common, { throwIfNoEntry: false });
|
|
160
|
+
let storage = gitDir;
|
|
161
|
+
if (commonInfo) {
|
|
162
|
+
if (!commonInfo.isFile() || commonInfo.size > 4096) return null;
|
|
163
|
+
const target = fs.readFileSync(common, 'utf8').replace(/[\r\n]+$/, '');
|
|
164
|
+
if (!target) return null;
|
|
165
|
+
storage = path.resolve(gitDir, target);
|
|
166
|
+
}
|
|
167
|
+
if (!fs.statSync(path.join(storage, 'objects')).isDirectory() ||
|
|
168
|
+
!fs.statSync(path.join(storage, 'refs')).isDirectory()) return null;
|
|
169
|
+
return gitDir;
|
|
170
|
+
} catch (error) {
|
|
171
|
+
return null;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
135
175
|
/**
|
|
136
176
|
* The layered rules for one walk. The caller enters a directory before it
|
|
137
177
|
* reads it and leaves it after, so the layers follow the depth-first stack.
|
|
138
|
-
* deps: fs (promises), path, extraFiles (
|
|
178
|
+
* deps: fs (promises), syncFs (marker validation), path, extraFiles (host excludes).
|
|
139
179
|
*/
|
|
140
180
|
function ignCreate(deps) {
|
|
141
181
|
const fs = deps.fs;
|
|
@@ -145,6 +185,10 @@ function ignCreate(deps) {
|
|
|
145
185
|
let ancestorsInRepo = false;
|
|
146
186
|
const posix = value => path.sep === '/' ? value : value.split(path.sep).join('/');
|
|
147
187
|
const lstat = async file => { try { return await fs.lstat(file); } catch (error) { return null; } };
|
|
188
|
+
const findGitDirectory = async directory => {
|
|
189
|
+
if (!await lstat(path.join(directory, '.git'))) return null;
|
|
190
|
+
return gitDirectory(directory, deps.syncFs, path);
|
|
191
|
+
};
|
|
148
192
|
const load = async file => {
|
|
149
193
|
const info = await lstat(file);
|
|
150
194
|
if (!info || !info.isFile() || info.size > IGN_MAX_BYTES * 4) return [];
|
|
@@ -165,8 +209,8 @@ function ignCreate(deps) {
|
|
|
165
209
|
let directory = root;
|
|
166
210
|
let repo = null;
|
|
167
211
|
for (;;) {
|
|
168
|
-
const
|
|
169
|
-
if (
|
|
212
|
+
const gitDir = await findGitDirectory(directory);
|
|
213
|
+
if (gitDir) { repo = { directory, gitDir }; break; }
|
|
170
214
|
const parent = path.dirname(directory);
|
|
171
215
|
if (parent === directory) break;
|
|
172
216
|
directory = parent;
|
|
@@ -182,7 +226,7 @@ function ignCreate(deps) {
|
|
|
182
226
|
const rules = [];
|
|
183
227
|
if (index === 0) {
|
|
184
228
|
for (const file of deps.extraFiles || []) rules.push(...await load(file));
|
|
185
|
-
if (repo.
|
|
229
|
+
if (repo.gitDir === path.join(directory, '.git')) rules.push(...await load(path.join(repo.gitDir, 'info', 'exclude')));
|
|
186
230
|
}
|
|
187
231
|
rules.push(...await loadDirectory(directory, true));
|
|
188
232
|
push(directory, rules);
|
|
@@ -193,11 +237,11 @@ function ignCreate(deps) {
|
|
|
193
237
|
let inRepo = parentInRepo;
|
|
194
238
|
const rules = [];
|
|
195
239
|
if (!parentInRepo) {
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
240
|
+
const gitDir = await findGitDirectory(directory);
|
|
241
|
+
if (gitDir) {
|
|
198
242
|
inRepo = true;
|
|
199
243
|
for (const file of deps.extraFiles || []) rules.push(...await load(file));
|
|
200
|
-
if (
|
|
244
|
+
if (gitDir === path.join(directory, '.git')) rules.push(...await load(path.join(gitDir, 'info', 'exclude')));
|
|
201
245
|
}
|
|
202
246
|
}
|
|
203
247
|
rules.push(...await loadDirectory(directory, inRepo));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export class SandboxLimitError extends Error {
|
|
2
|
+
constructor(
|
|
3
|
+
readonly kind: 'receive-frame' | 'receive-buffer' | 'exec-output' | 'read-file',
|
|
4
|
+
readonly limit: number,
|
|
5
|
+
readonly actual: number,
|
|
6
|
+
) {
|
|
7
|
+
super(`Sandbox ${kind} exceeded the ${limit} byte limit (got ${actual} bytes)`)
|
|
8
|
+
this.name = 'SandboxLimitError'
|
|
9
|
+
}
|
|
10
|
+
}
|