@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/runtime/query/iteration/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,IAAI,EAAkB,MAAM,oBAAoB,CAAA;AAmD9D,OAAO,KAAK,EAAE,sBAAsB,EAAm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,CAAC,iBAAiB;IAczB,+EAA+E;IAC/E,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoB;IAElD;;;;OAIG;IACH,OAAO,CAAC,SAAS;YASH,oBAAoB;CA6LlC"}
|
|
@@ -260,6 +260,7 @@ export class IterationOrchestrator {
|
|
|
260
260
|
stopHookActive = false;
|
|
261
261
|
/** End-of-turn refusals honoured since the last tool call. */
|
|
262
262
|
consecutiveHookRefusals = 0;
|
|
263
|
+
schemaFailures = new Map();
|
|
263
264
|
/** The cap was reached and its notice recorded; refusals are ignored for the rest of the turn. */
|
|
264
265
|
hookRefusalCapReached = false;
|
|
265
266
|
get turnEndHooksFired() {
|
|
@@ -1231,6 +1232,7 @@ export class IterationOrchestrator {
|
|
|
1231
1232
|
usage: recorder.tokenUsage,
|
|
1232
1233
|
budget: recorder.budget?.summary(),
|
|
1233
1234
|
cost: recorder.costInfo,
|
|
1235
|
+
...(response.usage.billingRoute ? { billingRoute: response.usage.billingRoute } : {}),
|
|
1234
1236
|
...(response.usage.cacheTtlMs !== undefined
|
|
1235
1237
|
? {
|
|
1236
1238
|
cache: {
|
|
@@ -1860,18 +1862,19 @@ export class IterationOrchestrator {
|
|
|
1860
1862
|
if ((yield* runHandoffPause(this.ctx, iterationNum, reviewOutcome.results)) === 'stop') {
|
|
1861
1863
|
return;
|
|
1862
1864
|
}
|
|
1863
|
-
//
|
|
1864
|
-
// answered. Every `tool_use` has its `tool_result` by now, so the
|
|
1865
|
-
// transcript is whole; what is left is to end the turn and say why.
|
|
1865
|
+
// End only after the batch has answered every tool call.
|
|
1866
1866
|
const hookHalt = this.ctx.toolExecutor.takeHalt?.();
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1867
|
+
const validationHalt = this.repeatedValidationFailure(reviewOutcome.results);
|
|
1868
|
+
if (hookHalt !== undefined || validationHalt !== undefined) {
|
|
1869
|
+
if (hookHalt !== undefined) {
|
|
1870
|
+
this.ctx.log.info('A hook stopped the turn', {
|
|
1871
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1872
|
+
[NAMZU.ITERATION]: iterationNum,
|
|
1873
|
+
'namzu.hook.reason': hookHalt,
|
|
1874
|
+
});
|
|
1875
|
+
recorder.setLastError(`Stopped by a hook: ${hookHalt}`);
|
|
1876
|
+
recorder.setStopReason('stop_condition');
|
|
1877
|
+
}
|
|
1875
1878
|
await this.ctx.emitEvent({
|
|
1876
1879
|
type: 'iteration_completed',
|
|
1877
1880
|
turnId: recorder.turnId,
|
|
@@ -1879,6 +1882,9 @@ export class IterationOrchestrator {
|
|
|
1879
1882
|
hasToolCalls: true,
|
|
1880
1883
|
});
|
|
1881
1884
|
yield* this.ctx.drainPending();
|
|
1885
|
+
if (hookHalt === undefined && validationHalt !== undefined) {
|
|
1886
|
+
throw new Error(validationHalt);
|
|
1887
|
+
}
|
|
1882
1888
|
break;
|
|
1883
1889
|
}
|
|
1884
1890
|
if (reviewOutcome.decision === 'rejected') {
|
|
@@ -2511,6 +2517,21 @@ export class IterationOrchestrator {
|
|
|
2511
2517
|
this.ctx.recorder.setStopReason('error');
|
|
2512
2518
|
return true;
|
|
2513
2519
|
}
|
|
2520
|
+
/** Admission failures have no execution receipt for the repeat-call advisory. */
|
|
2521
|
+
repeatedValidationFailure(results) {
|
|
2522
|
+
for (const { toolName, inputFailure, output } of results) {
|
|
2523
|
+
// Structured output has a separate, configurable correction allowance.
|
|
2524
|
+
if (inputFailure !== 'schema_validation' || toolName === STRUCTURED_OUTPUT_TOOL_NAME)
|
|
2525
|
+
continue;
|
|
2526
|
+
const key = JSON.stringify([toolName, output]);
|
|
2527
|
+
const count = (this.schemaFailures.get(key) ?? 0) + 1;
|
|
2528
|
+
this.schemaFailures.set(key, count);
|
|
2529
|
+
if (count === 4) {
|
|
2530
|
+
return `Stopped after ${count} identical validation failures for "${toolName}" in this turn. ${output}`;
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
return undefined;
|
|
2534
|
+
}
|
|
2514
2535
|
async recordToolStructuredFailure(results, iteration) {
|
|
2515
2536
|
if (!this.needsStructuredOutput() ||
|
|
2516
2537
|
this.ctx.structuredOutput?.mode === 'native' ||
|