@qmediat.io/gemini-code-context-mcp 1.24.0 → 1.25.1
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 +110 -1
- package/README.md +1 -1
- package/dist/cache/cache-manager.d.ts +23 -34
- package/dist/cache/cache-manager.d.ts.map +1 -1
- package/dist/cache/cache-manager.js +324 -272
- package/dist/cache/cache-manager.js.map +1 -1
- package/dist/cache/caching-mode.d.ts +5 -3
- package/dist/cache/caching-mode.d.ts.map +1 -1
- package/dist/cache/caching-mode.js +6 -4
- package/dist/cache/caching-mode.js.map +1 -1
- package/dist/cache/ttl-watcher.d.ts.map +1 -1
- package/dist/cache/ttl-watcher.js +7 -1
- package/dist/cache/ttl-watcher.js.map +1 -1
- package/dist/cache/ttl.d.ts +8 -0
- package/dist/cache/ttl.d.ts.map +1 -0
- package/dist/cache/ttl.js +10 -0
- package/dist/cache/ttl.js.map +1 -0
- package/dist/manifest/db.d.ts.map +1 -1
- package/dist/manifest/db.js +2 -1
- package/dist/manifest/db.js.map +1 -1
- package/dist/tools/agentic/dispatch.d.ts +68 -0
- package/dist/tools/agentic/dispatch.d.ts.map +1 -0
- package/dist/tools/agentic/dispatch.js +167 -0
- package/dist/tools/agentic/dispatch.js.map +1 -0
- package/dist/tools/agentic/input.d.ts +28 -0
- package/dist/tools/agentic/input.d.ts.map +1 -0
- package/dist/tools/agentic/input.js +66 -0
- package/dist/tools/agentic/input.js.map +1 -0
- package/dist/tools/agentic/instructions.d.ts +46 -0
- package/dist/tools/agentic/instructions.d.ts.map +1 -0
- package/dist/tools/agentic/instructions.js +170 -0
- package/dist/tools/agentic/instructions.js.map +1 -0
- package/dist/tools/agentic/iteration.d.ts +81 -0
- package/dist/tools/agentic/iteration.d.ts.map +1 -0
- package/dist/tools/agentic/iteration.js +317 -0
- package/dist/tools/agentic/iteration.js.map +1 -0
- package/dist/tools/agentic/ledger.d.ts +64 -0
- package/dist/tools/agentic/ledger.d.ts.map +1 -0
- package/dist/tools/agentic/ledger.js +110 -0
- package/dist/tools/agentic/ledger.js.map +1 -0
- package/dist/tools/agentic/loop.d.ts +10 -0
- package/dist/tools/agentic/loop.d.ts.map +1 -0
- package/dist/tools/agentic/loop.js +179 -0
- package/dist/tools/agentic/loop.js.map +1 -0
- package/dist/tools/agentic/no-progress.d.ts +90 -0
- package/dist/tools/agentic/no-progress.d.ts.map +1 -0
- package/dist/tools/agentic/no-progress.js +107 -0
- package/dist/tools/agentic/no-progress.js.map +1 -0
- package/dist/tools/agentic/pass-clock.d.ts +85 -0
- package/dist/tools/agentic/pass-clock.d.ts.map +1 -0
- package/dist/tools/agentic/pass-clock.js +162 -0
- package/dist/tools/agentic/pass-clock.js.map +1 -0
- package/dist/tools/agentic/phase-defaults.d.ts +29 -0
- package/dist/tools/agentic/phase-defaults.d.ts.map +1 -0
- package/dist/tools/agentic/phase-defaults.js +23 -0
- package/dist/tools/agentic/phase-defaults.js.map +1 -0
- package/dist/tools/agentic/rescue.d.ts +69 -0
- package/dist/tools/agentic/rescue.d.ts.map +1 -0
- package/dist/tools/agentic/rescue.js +203 -0
- package/dist/tools/agentic/rescue.js.map +1 -0
- package/dist/tools/agentic/response.d.ts +16 -0
- package/dist/tools/agentic/response.d.ts.map +1 -0
- package/dist/tools/agentic/response.js +25 -0
- package/dist/tools/agentic/response.js.map +1 -0
- package/dist/tools/agentic/results.d.ts +76 -0
- package/dist/tools/agentic/results.d.ts.map +1 -0
- package/dist/tools/agentic/results.js +228 -0
- package/dist/tools/agentic/results.js.map +1 -0
- package/dist/tools/agentic/run.d.ts +130 -0
- package/dist/tools/agentic/run.d.ts.map +1 -0
- package/dist/tools/agentic/run.js +128 -0
- package/dist/tools/agentic/run.js.map +1 -0
- package/dist/tools/agentic/sandbox.d.ts +13 -2
- package/dist/tools/agentic/sandbox.d.ts.map +1 -1
- package/dist/tools/agentic/sandbox.js +127 -111
- package/dist/tools/agentic/sandbox.js.map +1 -1
- package/dist/tools/agentic/workspace-tools.d.ts +30 -27
- package/dist/tools/agentic/workspace-tools.d.ts.map +1 -1
- package/dist/tools/agentic/workspace-tools.js +324 -385
- package/dist/tools/agentic/workspace-tools.js.map +1 -1
- package/dist/tools/ask/answer.d.ts +9 -0
- package/dist/tools/ask/answer.d.ts.map +1 -0
- package/dist/tools/ask/answer.js +28 -0
- package/dist/tools/ask/answer.js.map +1 -0
- package/dist/tools/ask/attachments.d.ts +25 -0
- package/dist/tools/ask/attachments.d.ts.map +1 -0
- package/dist/tools/ask/attachments.js +85 -0
- package/dist/tools/ask/attachments.js.map +1 -0
- package/dist/tools/ask/call.d.ts +61 -0
- package/dist/tools/ask/call.d.ts.map +1 -0
- package/dist/tools/ask/call.js +6 -0
- package/dist/tools/ask/call.js.map +1 -0
- package/dist/tools/ask/guard.d.ts +24 -0
- package/dist/tools/ask/guard.d.ts.map +1 -0
- package/dist/tools/ask/guard.js +79 -0
- package/dist/tools/ask/guard.js.map +1 -0
- package/dist/tools/ask/input.d.ts +45 -0
- package/dist/tools/ask/input.d.ts.map +1 -0
- package/dist/tools/ask/input.js +93 -0
- package/dist/tools/ask/input.js.map +1 -0
- package/dist/tools/ask/instruction.d.ts +8 -0
- package/dist/tools/ask/instruction.d.ts.map +1 -0
- package/dist/tools/ask/instruction.js +13 -0
- package/dist/tools/ask/instruction.js.map +1 -0
- package/dist/tools/ask/request.d.ts +14 -0
- package/dist/tools/ask/request.d.ts.map +1 -0
- package/dist/tools/ask/request.js +38 -0
- package/dist/tools/ask/request.js.map +1 -0
- package/dist/tools/ask/results.d.ts +23 -0
- package/dist/tools/ask/results.d.ts.map +1 -0
- package/dist/tools/ask/results.js +107 -0
- package/dist/tools/ask/results.js.map +1 -0
- package/dist/tools/ask/setup.d.ts +22 -0
- package/dist/tools/ask/setup.d.ts.map +1 -0
- package/dist/tools/ask/setup.js +57 -0
- package/dist/tools/ask/setup.js.map +1 -0
- package/dist/tools/ask/sizing.d.ts +10 -0
- package/dist/tools/ask/sizing.d.ts.map +1 -0
- package/dist/tools/ask/sizing.js +33 -0
- package/dist/tools/ask/sizing.js.map +1 -0
- package/dist/tools/ask/thinking.d.ts +54 -0
- package/dist/tools/ask/thinking.d.ts.map +1 -0
- package/dist/tools/ask/thinking.js +69 -0
- package/dist/tools/ask/thinking.js.map +1 -0
- package/dist/tools/ask-agentic-fallback.d.ts +33 -0
- package/dist/tools/ask-agentic-fallback.d.ts.map +1 -0
- package/dist/tools/ask-agentic-fallback.js +113 -0
- package/dist/tools/ask-agentic-fallback.js.map +1 -0
- package/dist/tools/ask-agentic.tool.d.ts +11 -44
- package/dist/tools/ask-agentic.tool.d.ts.map +1 -1
- package/dist/tools/ask-agentic.tool.js +139 -1618
- package/dist/tools/ask-agentic.tool.js.map +1 -1
- package/dist/tools/ask.tool.d.ts +3 -41
- package/dist/tools/ask.tool.d.ts.map +1 -1
- package/dist/tools/ask.tool.js +46 -944
- package/dist/tools/ask.tool.js.map +1 -1
- package/dist/tools/code.tool.d.ts.map +1 -1
- package/dist/tools/code.tool.js +376 -514
- package/dist/tools/code.tool.js.map +1 -1
- package/dist/tools/reindex.tool.d.ts.map +1 -1
- package/dist/tools/reindex.tool.js +19 -22
- package/dist/tools/reindex.tool.js.map +1 -1
- package/dist/tools/shared/abort-timeout.d.ts +43 -5
- package/dist/tools/shared/abort-timeout.d.ts.map +1 -1
- package/dist/tools/shared/abort-timeout.js +111 -102
- package/dist/tools/shared/abort-timeout.js.map +1 -1
- package/dist/tools/shared/call-ledger.d.ts +27 -12
- package/dist/tools/shared/call-ledger.d.ts.map +1 -1
- package/dist/tools/shared/call-ledger.js +57 -39
- package/dist/tools/shared/call-ledger.js.map +1 -1
- package/dist/tools/shared/continuation.d.ts +1 -1
- package/dist/tools/shared/continuation.d.ts.map +1 -1
- package/dist/tools/shared/eager-answer.d.ts +78 -0
- package/dist/tools/shared/eager-answer.d.ts.map +1 -0
- package/dist/tools/shared/eager-answer.js +130 -0
- package/dist/tools/shared/eager-answer.js.map +1 -0
- package/dist/tools/shared/eager-call.d.ts +114 -0
- package/dist/tools/shared/eager-call.d.ts.map +1 -0
- package/dist/tools/shared/eager-call.js +95 -0
- package/dist/tools/shared/eager-call.js.map +1 -0
- package/dist/tools/shared/eager-steps.d.ts +114 -0
- package/dist/tools/shared/eager-steps.d.ts.map +1 -0
- package/dist/tools/shared/eager-steps.js +152 -0
- package/dist/tools/shared/eager-steps.js.map +1 -0
- package/dist/tools/shared/question-fields.d.ts +10 -0
- package/dist/tools/shared/question-fields.d.ts.map +1 -0
- package/dist/tools/shared/question-fields.js +13 -0
- package/dist/tools/shared/question-fields.js.map +1 -0
- package/dist/tools/shared/service-tier.d.ts +9 -0
- package/dist/tools/shared/service-tier.d.ts.map +1 -1
- package/dist/tools/shared/service-tier.js +15 -0
- package/dist/tools/shared/service-tier.js.map +1 -1
- package/dist/tools/shared/settle-call.d.ts +11 -6
- package/dist/tools/shared/settle-call.d.ts.map +1 -1
- package/dist/tools/shared/settle-call.js +14 -10
- package/dist/tools/shared/settle-call.js.map +1 -1
- package/dist/tools/shared/thinking.d.ts +9 -0
- package/dist/tools/shared/thinking.d.ts.map +1 -1
- package/dist/tools/shared/thinking.js +10 -0
- package/dist/tools/shared/thinking.js.map +1 -1
- package/dist/tools/shared/throttle.d.ts +7 -0
- package/dist/tools/shared/throttle.d.ts.map +1 -1
- package/dist/tools/shared/throttle.js +18 -0
- package/dist/tools/shared/throttle.js.map +1 -1
- package/dist/tools/shared/workspace-refusal.d.ts +13 -0
- package/dist/tools/shared/workspace-refusal.d.ts.map +1 -0
- package/dist/tools/shared/workspace-refusal.js +23 -0
- package/dist/tools/shared/workspace-refusal.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pass-clock.js","sourceRoot":"","sources":["../../../src/tools/agentic/pass-clock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEL,cAAc,EACd,aAAa,EACb,UAAU,GACX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,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IACzE,CAAC;IAEO,eAAe;QACrB,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI;YAAE,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;IACzB,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI;YAAE,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;CACF;AAED,yGAAyG;AACzG,MAAM,UAAU,eAAe,CAC7B,KAAmB,EACnB,QAAQ,GAAkB,cAAc;IAExC,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAgB,EAAE,GAAY;IAC1D,IAAI,KAAK,CAAC,QAAQ,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC,QAAQ,CAAC;IACnD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,IAAI,OAAO;QACpC,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;KAC1D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bound of each phase of an `ask_agentic` pass that no knob bounds (`docs/DESIGN-agentic-time-bounds.md`):
|
|
3
|
+
* `iterationTimeoutMs` bounds every phase of a pass, `stallMs` the gaps of a stream, and a default applies only where
|
|
4
|
+
* neither does. The tests replace this module with bounds of milliseconds.
|
|
5
|
+
*/
|
|
6
|
+
export interface PhaseDefaults {
|
|
7
|
+
/** A request's opening, until its first chunk. */
|
|
8
|
+
readonly openingMs: number;
|
|
9
|
+
/** A gap between two chunks of a stream (reported as a `stall`). */
|
|
10
|
+
readonly streamGapMs: number;
|
|
11
|
+
/** The silence of an iteration's tools phase (path resolution and the tool batch): how long it may go without
|
|
12
|
+
* executor progress (`PassClock.recordProgress`). */
|
|
13
|
+
readonly toolsIdleMs: number;
|
|
14
|
+
/** The forced-finalization pass's call. */
|
|
15
|
+
readonly finalizationMs: number;
|
|
16
|
+
/** How long, after the tools bound fired, the executors still running are given to settle. */
|
|
17
|
+
readonly toolSettleGraceMs: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Silence longer than the longest stall watchdog a caller may set (`stallMs` ≤ 600 000 ms) is a hang, not a slow
|
|
21
|
+
* model: each request's opening, a stream gap and each request of the forced pass end there. The tools phase is bounded
|
|
22
|
+
* by silence too, never by its length: the executors bound what they return (200 KB per read, 100 grep matches, 200
|
|
23
|
+
* entries, a walk depth of 20), not how long they run, and a healthy batch of `grep` calls over a large workspace runs
|
|
24
|
+
* for minutes (ten in parallel over 80 000 files: 32 s; forty: 133 s) while it reports progress at every directory and
|
|
25
|
+
* file — 120 000 ms without any ends a batch that hangs. An executor that reads the abort signal settles in well under
|
|
26
|
+
* the 1 000 ms grace.
|
|
27
|
+
*/
|
|
28
|
+
export declare const PHASE_DEFAULTS: PhaseDefaults;
|
|
29
|
+
//# sourceMappingURL=phase-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-defaults.d.ts","sourceRoot":"","sources":["../../../src/tools/agentic/phase-defaults.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,aAAa;IAC5B,kDAAkD;IAClD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B;yDACqD;IACrD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,8FAA8F;IAC9F,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,EAAE,aAM3B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bound of each phase of an `ask_agentic` pass that no knob bounds (`docs/DESIGN-agentic-time-bounds.md`):
|
|
3
|
+
* `iterationTimeoutMs` bounds every phase of a pass, `stallMs` the gaps of a stream, and a default applies only where
|
|
4
|
+
* neither does. The tests replace this module with bounds of milliseconds.
|
|
5
|
+
*/
|
|
6
|
+
import { STALL_ABSOLUTE_MAX_MS } from '../shared/abort-timeout.js';
|
|
7
|
+
/**
|
|
8
|
+
* Silence longer than the longest stall watchdog a caller may set (`stallMs` ≤ 600 000 ms) is a hang, not a slow
|
|
9
|
+
* model: each request's opening, a stream gap and each request of the forced pass end there. The tools phase is bounded
|
|
10
|
+
* by silence too, never by its length: the executors bound what they return (200 KB per read, 100 grep matches, 200
|
|
11
|
+
* entries, a walk depth of 20), not how long they run, and a healthy batch of `grep` calls over a large workspace runs
|
|
12
|
+
* for minutes (ten in parallel over 80 000 files: 32 s; forty: 133 s) while it reports progress at every directory and
|
|
13
|
+
* file — 120 000 ms without any ends a batch that hangs. An executor that reads the abort signal settles in well under
|
|
14
|
+
* the 1 000 ms grace.
|
|
15
|
+
*/
|
|
16
|
+
export const PHASE_DEFAULTS = Object.freeze({
|
|
17
|
+
openingMs: STALL_ABSOLUTE_MAX_MS,
|
|
18
|
+
streamGapMs: STALL_ABSOLUTE_MAX_MS,
|
|
19
|
+
toolsIdleMs: 120_000,
|
|
20
|
+
finalizationMs: STALL_ABSOLUTE_MAX_MS,
|
|
21
|
+
toolSettleGraceMs: 1_000,
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=phase-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phase-defaults.js","sourceRoot":"","sources":["../../../src/tools/agentic/phase-defaults.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAgBnE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,cAAc,GAAkB,MAAM,CAAC,MAAM,CAAC;IACzD,SAAS,EAAE,qBAAqB;IAChC,WAAW,EAAE,qBAAqB;IAClC,WAAW,EAAE,OAAO;IACpB,cAAc,EAAE,qBAAqB;IACrC,iBAAiB,EAAE,KAAK;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The forced-finalization rescue: the loop exhausted `maxIterations` without an organic final-text turn, so ONE more
|
|
3
|
+
* `generateContent` runs with `toolConfig.functionCallingConfig.mode = NONE` — the model is prohibited from emitting
|
|
4
|
+
* more function calls (Gemini API spec: NONE = "equivalent to sending a request without any function declarations")
|
|
5
|
+
* and must answer in text using the conversation it has already accumulated. This converts what was previously an
|
|
6
|
+
* opaque error into a synthesized text answer derived from the tool responses gathered so far. If the forced call
|
|
7
|
+
* itself fails (timeout, network, budget exhausted, empty text), the caller still gets a structured failure signal.
|
|
8
|
+
*
|
|
9
|
+
* v1.14.2: the rescue pass is NOT gated on `maxTotalInputTokens`. It is the documented exit path for "loop ran out
|
|
10
|
+
* of iterations without final text" and blocking it on rescue's own potential overshoot defeats the v1.14.1 feature —
|
|
11
|
+
* an operator running near the cap would never get the synthesised answer the rescue is designed to produce. Rescue
|
|
12
|
+
* cost remains bounded by the `dailyBudgetUsd` reservation, wall-clock by `iterationTimeoutMs` — else by the
|
|
13
|
+
* finalization default (`phase-defaults.ts`). Cap-overshoot is signalled via `overBudget: true` on the result so
|
|
14
|
+
* callers can detect the trade.
|
|
15
|
+
*
|
|
16
|
+
* The rescue calls `generateContent`, not the stream: its pass clock has the phases `tpm-wait` and `finalization` —
|
|
17
|
+
* entered by each request and by a retry's announcement, so each request, its backoff included, gets the whole default
|
|
18
|
+
* — and no stream gap to watch. Its call is marked completed the moment `generateContent` returned (`completeCall`, the
|
|
19
|
+
* idiom of the loop iteration), before the response is read.
|
|
20
|
+
*/
|
|
21
|
+
import type { BilledFields } from '../shared/call-ledger.js';
|
|
22
|
+
import { type PassTimeout } from './pass-clock.js';
|
|
23
|
+
import { type UsageCounts } from './response.js';
|
|
24
|
+
import { type AgenticRun, type LoopState } from './run.js';
|
|
25
|
+
/**
|
|
26
|
+
* P4 (v1.15.0): caller-visible rescue failure-class signal, surfaced as
|
|
27
|
+
* `structuredContent.rescueErrorCode` so wrappers can branch retry behaviour
|
|
28
|
+
* without log scraping. Strict union — extend here when adding new error
|
|
29
|
+
* classes.
|
|
30
|
+
*
|
|
31
|
+
* - 'TIMEOUT' — iterationTimeoutMs, else the finalization default, fired (isTimeoutAbort)
|
|
32
|
+
* - 'RATE_LIMIT' — Google 429 (isGemini429: ApiError + status===429)
|
|
33
|
+
* - 'INTERNAL' — the call completed (await returned), but reading its
|
|
34
|
+
* response threw — the pass is booked, but the caller
|
|
35
|
+
* sees a structured failure. Distinguishes "API ok, our
|
|
36
|
+
* code bug" from "API failure" so wrappers don't blindly
|
|
37
|
+
* retry our parse bugs.
|
|
38
|
+
* - 'API_ERROR' — `instanceof ApiError` with status≠429 (4xx other
|
|
39
|
+
* than 429, or 5xx). Wrapper should NOT retry 4xx
|
|
40
|
+
* (fix the payload) but MAY retry 5xx with backoff.
|
|
41
|
+
* - 'NETWORK' — fetch-layer / DNS / TCP / pre-dispatch SDK error.
|
|
42
|
+
* Real transient connectivity case; safe to retry.
|
|
43
|
+
* - 'EMPTY_TEXT' — set in success path: API returned, but extracted
|
|
44
|
+
* text was empty after .trim(). Budget IS finalized.
|
|
45
|
+
*/
|
|
46
|
+
export type RescueErrorCode = 'TIMEOUT' | 'RATE_LIMIT' | 'INTERNAL' | 'API_ERROR' | 'NETWORK' | 'EMPTY_TEXT';
|
|
47
|
+
/** What the finalization pass produced. */
|
|
48
|
+
export interface RescueOutcome {
|
|
49
|
+
/** The answer, trimmed; empty when the pass produced none. */
|
|
50
|
+
text: string;
|
|
51
|
+
usage: UsageCounts;
|
|
52
|
+
thinkingSummary: string | null;
|
|
53
|
+
/** Whether the finalization `generateContent` call was dispatched (regardless of outcome) — `apiCalls`
|
|
54
|
+
* counts it even when a mid-flight timeout or a pre-response network failure left the usage at 0. */
|
|
55
|
+
attempted: boolean;
|
|
56
|
+
/** `null` when the rescue produced text (the answer then carries `convergenceForced: true`) or was skipped. */
|
|
57
|
+
errorCode: RescueErrorCode | null;
|
|
58
|
+
/** The failure's message, cut to 500 characters; `null` unless the call threw. */
|
|
59
|
+
errorMessage: string | null;
|
|
60
|
+
/** v1.14.2 Fix 5: WHY the rescue pass was skipped — 'daily-budget' when `reserveBudget` rejected. */
|
|
61
|
+
skipReason: 'daily-budget' | null;
|
|
62
|
+
/** The pass's billed fields when its call completed and it was booked; `null` when it was skipped or cancelled. */
|
|
63
|
+
billed: BilledFields | null;
|
|
64
|
+
/** What ended the pass when it timed out (`errorCode: 'TIMEOUT'`), read from its clock; `null` otherwise. */
|
|
65
|
+
timeout: PassTimeout | null;
|
|
66
|
+
}
|
|
67
|
+
/** Run the forced-finalization pass after the loop exhausted `maxIterations`. */
|
|
68
|
+
export declare function runRescue(run: AgenticRun, state: LoopState): Promise<RescueOutcome>;
|
|
69
|
+
//# sourceMappingURL=rescue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rescue.d.ts","sourceRoot":"","sources":["../../../src/tools/agentic/rescue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAa7D,OAAO,EAAkB,KAAK,WAAW,EAAkC,MAAM,iBAAiB,CAAC;AACnG,OAAO,EAAE,KAAK,WAAW,EAAqB,MAAM,eAAe,CAAC;AACpE,OAAO,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EAGf,MAAM,UAAU,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,YAAY,GACZ,UAAU,GACV,WAAW,GACX,SAAS,GACT,YAAY,CAAC;AAEjB,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,WAAW,CAAC;IACnB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B;yGACqG;IACrG,SAAS,EAAE,OAAO,CAAC;IACnB,+GAA+G;IAC/G,SAAS,EAAE,eAAe,GAAG,IAAI,CAAC;IAClC,kFAAkF;IAClF,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qGAAqG;IACrG,UAAU,EAAE,cAAc,GAAG,IAAI,CAAC;IAClC,mHAAmH;IACnH,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,6GAA6G;IAC7G,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;CAC7B;AAoND,iFAAiF;AACjF,wBAAsB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAqBzF"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The forced-finalization rescue: the loop exhausted `maxIterations` without an organic final-text turn, so ONE more
|
|
3
|
+
* `generateContent` runs with `toolConfig.functionCallingConfig.mode = NONE` — the model is prohibited from emitting
|
|
4
|
+
* more function calls (Gemini API spec: NONE = "equivalent to sending a request without any function declarations")
|
|
5
|
+
* and must answer in text using the conversation it has already accumulated. This converts what was previously an
|
|
6
|
+
* opaque error into a synthesized text answer derived from the tool responses gathered so far. If the forced call
|
|
7
|
+
* itself fails (timeout, network, budget exhausted, empty text), the caller still gets a structured failure signal.
|
|
8
|
+
*
|
|
9
|
+
* v1.14.2: the rescue pass is NOT gated on `maxTotalInputTokens`. It is the documented exit path for "loop ran out
|
|
10
|
+
* of iterations without final text" and blocking it on rescue's own potential overshoot defeats the v1.14.1 feature —
|
|
11
|
+
* an operator running near the cap would never get the synthesised answer the rescue is designed to produce. Rescue
|
|
12
|
+
* cost remains bounded by the `dailyBudgetUsd` reservation, wall-clock by `iterationTimeoutMs` — else by the
|
|
13
|
+
* finalization default (`phase-defaults.ts`). Cap-overshoot is signalled via `overBudget: true` on the result so
|
|
14
|
+
* callers can detect the trade.
|
|
15
|
+
*
|
|
16
|
+
* The rescue calls `generateContent`, not the stream: its pass clock has the phases `tpm-wait` and `finalization` —
|
|
17
|
+
* entered by each request and by a retry's announcement, so each request, its backoff included, gets the whole default
|
|
18
|
+
* — and no stream gap to watch. Its call is marked completed the moment `generateContent` returned (`completeCall`, the
|
|
19
|
+
* idiom of the loop iteration), before the response is read.
|
|
20
|
+
*/
|
|
21
|
+
import { ApiError, FunctionCallingConfigMode } from '@google/genai';
|
|
22
|
+
import { withNetworkRetry } from '../../gemini/retry.js';
|
|
23
|
+
import { logger } from '../../utils/logger.js';
|
|
24
|
+
import { isTimeoutAbort } from '../shared/abort-timeout.js';
|
|
25
|
+
import { isGemini429, seedRetryHint } from '../shared/throttle.js';
|
|
26
|
+
import { SYSTEM_INSTRUCTION_FINALIZATION } from './instructions.js';
|
|
27
|
+
import { NO_THROTTLE_RESERVATION, callNotMade, closePass, completeCall, reservePass, waitForTpm, } from './ledger.js';
|
|
28
|
+
import { createPassClock, passTimeoutOf } from './pass-clock.js';
|
|
29
|
+
import { thinkingSummaryOf } from './response.js';
|
|
30
|
+
import { PER_ITERATION_INPUT_TOKENS, passReservationUsd, } from './run.js';
|
|
31
|
+
const errorText = (err) => (err instanceof Error ? err.message : String(err));
|
|
32
|
+
/**
|
|
33
|
+
* v1.14.2: dynamic estimate for the rescue pass — the actual size of the last observed iteration
|
|
34
|
+
* (+5k margin for SYSTEM_INSTRUCTION_FINALIZATION + thinking-config overhead) instead of the static
|
|
35
|
+
* `PER_ITERATION_INPUT_TOKENS` baseline. Used by BOTH the daily-budget reservation AND the
|
|
36
|
+
* TPM-throttle reservation so cost and rate-limit gates stay symmetric (the reservation covers the
|
|
37
|
+
* replayed conversation). Fallback to the static estimate when the loop produced no usage record.
|
|
38
|
+
*
|
|
39
|
+
* v1.15.0 (P5): also folds in `lastToolResponseTokens` — the tool-response Parts appended to
|
|
40
|
+
* `conversation` AFTER the last iteration's `generateContent` returned. The rescue's prompt replays
|
|
41
|
+
* the entire accumulated conversation, so its actual size ≈ last-iter prompt + the tool responses
|
|
42
|
+
* appended after; without them a final iteration that read several large files concurrently could
|
|
43
|
+
* under-reserve TPM by 100k+ tokens and 429 mid-flight.
|
|
44
|
+
*/
|
|
45
|
+
function finalizationEstimateOf(state) {
|
|
46
|
+
return state.lastIterationPromptTokens > 0
|
|
47
|
+
? state.lastIterationPromptTokens + state.lastToolResponseTokens + 5_000
|
|
48
|
+
: PER_ITERATION_INPUT_TOKENS;
|
|
49
|
+
}
|
|
50
|
+
/** The pass's budget reservation id, or `null` — not enforced, or refused (then `outcome.skipReason`). */
|
|
51
|
+
function reserveRescue(run, costUsd, outcome) {
|
|
52
|
+
if (!run.budget.dailyBudgetEnforced)
|
|
53
|
+
return null;
|
|
54
|
+
const reserve = reservePass(run, costUsd);
|
|
55
|
+
if (!('rejected' in reserve))
|
|
56
|
+
return reserve.id;
|
|
57
|
+
const spent = (reserve.spentMicros / 1_000_000).toFixed(4);
|
|
58
|
+
run.emitter.emit(`skipping forced-finalization pass — daily budget cap reached (spent $${spent})`);
|
|
59
|
+
logger.warn(`ask_agentic: skipping forced-finalization pass — daily budget cap reached (spent $${spent})`);
|
|
60
|
+
outcome.skipReason = 'daily-budget';
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The finalization call. G2 fix: `tools` (function declarations) are omitted — per Gemini API spec,
|
|
65
|
+
* `mode: NONE` is "equivalent to sending a request without any function declarations"; sending the
|
|
66
|
+
* declarations alongside NONE wastes ~150-300 input tokens and contradicts the spec we depend on.
|
|
67
|
+
*/
|
|
68
|
+
function callFinalization(run, state, baseConfigNoTools, clock) {
|
|
69
|
+
const model = run.resolved.resolved;
|
|
70
|
+
const { signal } = clock;
|
|
71
|
+
return withNetworkRetry(() => {
|
|
72
|
+
clock.enter('finalization');
|
|
73
|
+
return run.ctx.client.models.generateContent({
|
|
74
|
+
model,
|
|
75
|
+
contents: state.conversation,
|
|
76
|
+
config: {
|
|
77
|
+
...baseConfigNoTools,
|
|
78
|
+
systemInstruction: SYSTEM_INSTRUCTION_FINALIZATION,
|
|
79
|
+
toolConfig: {
|
|
80
|
+
functionCallingConfig: { mode: FunctionCallingConfigMode.NONE },
|
|
81
|
+
},
|
|
82
|
+
abortSignal: signal,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}, {
|
|
86
|
+
signal,
|
|
87
|
+
onRetry: (attempt, retryErr) => {
|
|
88
|
+
clock.enter('finalization');
|
|
89
|
+
logger.warn(`ask_agentic finalization: retry attempt ${attempt}: ${errorText(retryErr)}`);
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/** Read the returned response. An empty text is a rescue failure mode (model dispatched, returned a
|
|
94
|
+
* candidate with no extractable text) — distinct from timeouts / 429s / network errors. */
|
|
95
|
+
function readFinalization(response, usage, outcome) {
|
|
96
|
+
outcome.usage = usage;
|
|
97
|
+
const parts = response.candidates?.[0]?.content?.parts ?? [];
|
|
98
|
+
outcome.text = (response.text ?? parts.map((p) => p.text ?? '').join('')).trim();
|
|
99
|
+
outcome.thinkingSummary = thinkingSummaryOf(parts);
|
|
100
|
+
if (outcome.text.length === 0) {
|
|
101
|
+
outcome.errorCode = 'EMPTY_TEXT';
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Classify a rescue failure for caller-facing telemetry. Order matters — earlier branches signal the
|
|
106
|
+
* most user-actionable remediation:
|
|
107
|
+
* 1. TIMEOUT — checked first because a 429 surfaced via an aborted-fetch can race the timeout signal.
|
|
108
|
+
* 2. RATE_LIMIT — wait the retry-hint window then retry (429).
|
|
109
|
+
* 3. INTERNAL — a completed call means the await returned cleanly; any throw past that point is
|
|
110
|
+
* processing logic our side, not Gemini's API — investigate, do not retry blindly.
|
|
111
|
+
* 4. API_ERROR — Gemini returned a non-429 4xx/5xx; distinct from NETWORK so wrappers don't retry
|
|
112
|
+
* 400 INVALID_ARGUMENT forever.
|
|
113
|
+
* 5. NETWORK — fetch-layer / DNS / TCP / SDK pre-dispatch; safe to retry.
|
|
114
|
+
*/
|
|
115
|
+
function rescueFailureCode(finalErr, retryDelayMs, callCompleted) {
|
|
116
|
+
if (isTimeoutAbort(finalErr)) {
|
|
117
|
+
logger.warn('ask_agentic finalization: timed out after maxIterations exhaustion');
|
|
118
|
+
return 'TIMEOUT';
|
|
119
|
+
}
|
|
120
|
+
if (isGemini429(finalErr)) {
|
|
121
|
+
logger.warn(`ask_agentic finalization: 429 rate-limit (retryDelay=${retryDelayMs ?? 'unknown'}ms)`);
|
|
122
|
+
return 'RATE_LIMIT';
|
|
123
|
+
}
|
|
124
|
+
if (callCompleted) {
|
|
125
|
+
logger.warn(`ask_agentic finalization: post-await processing failed: ${errorText(finalErr)}`);
|
|
126
|
+
return 'INTERNAL';
|
|
127
|
+
}
|
|
128
|
+
if (finalErr instanceof ApiError) {
|
|
129
|
+
logger.warn(`ask_agentic finalization: Gemini API returned ${finalErr.status ?? 'unknown'}: ${finalErr.message.slice(0, 200)}`);
|
|
130
|
+
return 'API_ERROR';
|
|
131
|
+
}
|
|
132
|
+
logger.warn(`ask_agentic finalization: network failure: ${errorText(finalErr)}`);
|
|
133
|
+
return 'NETWORK';
|
|
134
|
+
}
|
|
135
|
+
/** The rescue's generateContent can also 429 — its retry hint seeds the throttle cache for future
|
|
136
|
+
* ask_agentic / ask / code calls, the same way the per-iteration catch does. A timeout records what fired. */
|
|
137
|
+
function recordRescueFailure(run, finalErr, clock, callCompleted, outcome) {
|
|
138
|
+
const finalRetryDelayMs = seedRetryHint(run.ctx.throttle, run.resolved.resolved, finalErr);
|
|
139
|
+
outcome.errorCode = rescueFailureCode(finalErr, finalRetryDelayMs, callCompleted);
|
|
140
|
+
if (outcome.errorCode === 'TIMEOUT')
|
|
141
|
+
outcome.timeout = passTimeoutOf(clock, finalErr);
|
|
142
|
+
outcome.errorMessage =
|
|
143
|
+
finalErr instanceof Error ? finalErr.message.slice(0, 500) : String(finalErr).slice(0, 500);
|
|
144
|
+
}
|
|
145
|
+
/** Dispatch the finalization call and read its answer. The API attempt is marked before dispatch (after
|
|
146
|
+
* the throttle wait, so a throttle-wait abort doesn't count it). */
|
|
147
|
+
async function dispatchRescue(run, state, flight, clock, outcome) {
|
|
148
|
+
if (run.budget.tpmEnforced) {
|
|
149
|
+
// The dynamic estimate, the same value and margin as the daily-budget reserve: over-reserve =
|
|
150
|
+
// transient throttle wait (harmless); under-reserve = 429 risk; the bias is intentional.
|
|
151
|
+
await waitForTpm(run, flight, flight.estimate, clock.signal, (seconds) => `finalization throttle: waiting ${seconds}s for TPM window…`);
|
|
152
|
+
}
|
|
153
|
+
const { tools: _unusedTools, ...baseConfigNoTools } = run.baseConfig;
|
|
154
|
+
outcome.attempted = true;
|
|
155
|
+
const response = await callFinalization(run, state, baseConfigNoTools, clock);
|
|
156
|
+
const usage = completeCall(flight.call, response);
|
|
157
|
+
readFinalization(response, usage, outcome);
|
|
158
|
+
}
|
|
159
|
+
/** Run the pass under its own clock; close it by its call (`closePass`): booked when the call completed, both
|
|
160
|
+
* reservations cancelled when it did not. */
|
|
161
|
+
async function attemptRescue(run, state, reservationId, estimate, outcome) {
|
|
162
|
+
run.emitter.emit('running forced-finalization pass (tools disabled)');
|
|
163
|
+
const clock = createPassClock(run.knobs);
|
|
164
|
+
const flight = {
|
|
165
|
+
reservationId,
|
|
166
|
+
throttleReservationId: NO_THROTTLE_RESERVATION,
|
|
167
|
+
estimate,
|
|
168
|
+
startedAt: Date.now(),
|
|
169
|
+
call: callNotMade(),
|
|
170
|
+
};
|
|
171
|
+
try {
|
|
172
|
+
await dispatchRescue(run, state, flight, clock, outcome);
|
|
173
|
+
}
|
|
174
|
+
catch (finalErr) {
|
|
175
|
+
recordRescueFailure(run, finalErr, clock, flight.call.completed, outcome);
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
outcome.billed = closePass(run, flight, flight.call, 'ask_agentic finalization');
|
|
179
|
+
clock.dispose();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** Run the forced-finalization pass after the loop exhausted `maxIterations`. */
|
|
183
|
+
export async function runRescue(run, state) {
|
|
184
|
+
run.emitter.emit(`maxIterations (${run.limits.maxIterations}) reached — running forced-finalization pass`);
|
|
185
|
+
const outcome = {
|
|
186
|
+
text: '',
|
|
187
|
+
usage: { promptTokenCount: 0, candidatesTokenCount: 0, thoughtsTokenCount: 0 },
|
|
188
|
+
thinkingSummary: null,
|
|
189
|
+
attempted: false,
|
|
190
|
+
errorCode: null,
|
|
191
|
+
errorMessage: null,
|
|
192
|
+
skipReason: null,
|
|
193
|
+
billed: null,
|
|
194
|
+
timeout: null,
|
|
195
|
+
};
|
|
196
|
+
const estimate = finalizationEstimateOf(state);
|
|
197
|
+
const reservationId = reserveRescue(run, passReservationUsd(run, estimate), outcome);
|
|
198
|
+
if (reservationId !== null || !run.budget.dailyBudgetEnforced) {
|
|
199
|
+
await attemptRescue(run, state, reservationId, estimate, outcome);
|
|
200
|
+
}
|
|
201
|
+
return outcome;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=rescue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rescue.js","sourceRoot":"","sources":["../../../src/tools/agentic/rescue.ts"],"names":[],"mappings":"AAAA;;;;;;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OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,0BAA0B,CAAC,CAAC;QACjF,KAAK,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAe,EAAE,KAAgB;IAC/D,GAAG,CAAC,OAAO,CAAC,IAAI,CACd,kBAAkB,GAAG,CAAC,MAAM,CAAC,aAAa,8CAA8C,CACzF,CAAC;IACF,MAAM,OAAO,GAAkB;QAC7B,IAAI,EAAE,EAAE;QACR,KAAK,EAAE,EAAE,gBAAgB,EAAE,CAAC,EAAE,oBAAoB,EAAE,CAAC,EAAE,kBAAkB,EAAE,CAAC,EAAE;QAC9E,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAAI;QACf,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,IAAI;QAChB,MAAM,EAAE,IAAI;QACZ,OAAO,EAAE,IAAI;KACd,CAAC;IACF,MAAM,QAAQ,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,aAAa,CAAC,GAAG,EAAE,kBAAkB,CAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IACrF,IAAI,aAAa,KAAK,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,EAAE,CAAC;QAC9D,MAAM,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `ask_agentic` reads from a model response, the same way for a loop iteration and for the forced-finalization
|
|
3
|
+
* pass: the token counts (0 where the response reported none) and the thought summary.
|
|
4
|
+
*/
|
|
5
|
+
import type { GenerateContentResponse, Part } from '@google/genai';
|
|
6
|
+
/** The token counts of one model call. */
|
|
7
|
+
export interface UsageCounts {
|
|
8
|
+
promptTokenCount: number;
|
|
9
|
+
candidatesTokenCount: number;
|
|
10
|
+
thoughtsTokenCount: number;
|
|
11
|
+
}
|
|
12
|
+
/** A response's token counts, each 0 when its `usageMetadata` does not carry it as a number. */
|
|
13
|
+
export declare function usageCounts(usage: GenerateContentResponse['usageMetadata']): UsageCounts;
|
|
14
|
+
/** The thought parts' text joined by newlines and cut to 1200 characters, or `null` when there is none. */
|
|
15
|
+
export declare function thinkingSummaryOf(parts: Part[]): string | null;
|
|
16
|
+
//# sourceMappingURL=response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../../src/tools/agentic/response.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEnE,0CAA0C;AAC1C,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAOD,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,KAAK,EAAE,uBAAuB,CAAC,eAAe,CAAC,GAAG,WAAW,CAMxF;AAED,2GAA2G;AAC3G,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,GAAG,IAAI,CAO9D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What `ask_agentic` reads from a model response, the same way for a loop iteration and for the forced-finalization
|
|
3
|
+
* pass: the token counts (0 where the response reported none) and the thought summary.
|
|
4
|
+
*/
|
|
5
|
+
/** The longest thought summary a result carries. */
|
|
6
|
+
const THINKING_SUMMARY_MAX_CHARS = 1200;
|
|
7
|
+
const countOf = (value) => (typeof value === 'number' ? value : 0);
|
|
8
|
+
/** A response's token counts, each 0 when its `usageMetadata` does not carry it as a number. */
|
|
9
|
+
export function usageCounts(usage) {
|
|
10
|
+
return {
|
|
11
|
+
promptTokenCount: countOf(usage?.promptTokenCount),
|
|
12
|
+
candidatesTokenCount: countOf(usage?.candidatesTokenCount),
|
|
13
|
+
thoughtsTokenCount: countOf(usage?.thoughtsTokenCount),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** The thought parts' text joined by newlines and cut to 1200 characters, or `null` when there is none. */
|
|
17
|
+
export function thinkingSummaryOf(parts) {
|
|
18
|
+
const thoughtTexts = parts
|
|
19
|
+
.filter((p) => p.thought === true && typeof p.text === 'string')
|
|
20
|
+
.map((p) => p.text);
|
|
21
|
+
return thoughtTexts.length > 0
|
|
22
|
+
? thoughtTexts.join('\n').slice(0, THINKING_SUMMARY_MAX_CHARS)
|
|
23
|
+
: null;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../src/tools/agentic/response.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWH,oDAAoD;AACpD,MAAM,0BAA0B,GAAG,IAAI,CAAC;AAExC,MAAM,OAAO,GAAG,CAAC,KAAyB,EAAU,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE/F,gGAAgG;AAChG,MAAM,UAAU,WAAW,CAAC,KAA+C;IACzE,OAAO;QACL,gBAAgB,EAAE,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC;QAClD,oBAAoB,EAAE,OAAO,CAAC,KAAK,EAAE,oBAAoB,CAAC;QAC1D,kBAAkB,EAAE,OAAO,CAAC,KAAK,EAAE,kBAAkB,CAAC;KACvD,CAAC;AACJ,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,MAAM,YAAY,GAAG,KAAK;SACvB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,KAAK,IAAI,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;SAC/D,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAc,CAAC,CAAC;IAChC,OAAO,YAAY,CAAC,MAAM,GAAG,CAAC;QAC5B,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,0BAA0B,CAAC;QAC9D,CAAC,CAAC,IAAI,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The results `ask_agentic` returns once the loop has started: the answer (organic or forced), and every error that
|
|
3
|
+
* ends the loop. `apiCalls` is the authoritative total `generateContent` count on every one of them.
|
|
4
|
+
*/
|
|
5
|
+
import { type TextToolResult } from '../registry.js';
|
|
6
|
+
import type { BilledFields } from '../shared/call-ledger.js';
|
|
7
|
+
import type { NoProgress } from './no-progress.js';
|
|
8
|
+
import type { PassTimeout } from './pass-clock.js';
|
|
9
|
+
import type { RescueOutcome } from './rescue.js';
|
|
10
|
+
import type { AgenticRun, KnobNames, LoopState } from './run.js';
|
|
11
|
+
/** Organic final-text path: no forced-finalization pass ran, so total `generateContent` calls equals loop iterations. */
|
|
12
|
+
export declare function organicAnswer(run: AgenticRun, state: LoopState, finalText: string, thinkingSummary: string | null): TextToolResult;
|
|
13
|
+
/**
|
|
14
|
+
* The daily budget refused an iteration's reservation. BUDGET_REJECT is pre-dispatch — `iterations`
|
|
15
|
+
* was incremented at the top of the loop body, but this iteration's `generateContent` never fired.
|
|
16
|
+
* Subtract 1 to match the schema contract that `apiCalls` is the AUTHORITATIVE total
|
|
17
|
+
* generateContent count. `Math.max(0, ...)` guards the first-iteration-rejection edge (iter 1 +
|
|
18
|
+
* reject → 0 calls).
|
|
19
|
+
*/
|
|
20
|
+
export declare function budgetRejected(run: AgenticRun, state: LoopState, spentMicros: number, estimateUsd: number): TextToolResult;
|
|
21
|
+
/** How an iteration timed out: what fired, the knobs, and how far the pass had got. */
|
|
22
|
+
export interface IterationTimeout {
|
|
23
|
+
timeout: PassTimeout;
|
|
24
|
+
/** The configured knobs (`null` when unset), reported whichever fired. */
|
|
25
|
+
timeoutMs: number | null;
|
|
26
|
+
stallMs: number | null;
|
|
27
|
+
/** The knob names the message gives: the caller's. */
|
|
28
|
+
knobNames: KnobNames;
|
|
29
|
+
dispatched: boolean;
|
|
30
|
+
/** The iteration's billed fields when its model call had completed and it was booked; `null` when it was not. */
|
|
31
|
+
billed: BilledFields | null;
|
|
32
|
+
/** The work of its tools phase still running after the grace; 0 outside the tools phase. */
|
|
33
|
+
toolCallsRunning: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What a timeout message tells the caller to change: the knob that fired, the default of the phase and its knob, or —
|
|
37
|
+
* for an `external` timeout — that none of this call's bounds fired.
|
|
38
|
+
*/
|
|
39
|
+
export declare function timeoutHint(timeout: PassTimeout, names: KnobNames): string;
|
|
40
|
+
/**
|
|
41
|
+
* The whole agentic call fails on an iteration timeout — the failed iteration's function-call results never came back,
|
|
42
|
+
* so the conversation is structurally incomplete.
|
|
43
|
+
*
|
|
44
|
+
* `timeoutMs` / `stallMs` report the configured knobs (as `ask` / `code` do); `timeoutKind` says which kind fired
|
|
45
|
+
* (`stall` for a stream's gap only), `timeoutPhase` where, `timeoutSource` which bound. `dispatched` false means the
|
|
46
|
+
* bound fired in the TPM wait and this iteration never reached the API: `apiCalls` leaves it out. An iteration booked
|
|
47
|
+
* before it timed out (the bound fired in its tools phase) reports its billed fields and its message says so; the abort
|
|
48
|
+
* note is for an iteration whose call was cancelled (`billed: null`). A TIMEOUT is retryable unless tool calls of the
|
|
49
|
+
* iteration still run (`toolCallsRunning`): a retry would stack file-system work on the same thread pool.
|
|
50
|
+
*/
|
|
51
|
+
export declare function iterationTimedOut(iterations: number, t: IterationTimeout): TextToolResult;
|
|
52
|
+
/** The budget guard fires AFTER the iteration's generateContent completed — the call IS counted in apiCalls. */
|
|
53
|
+
export declare function inputBudgetExceeded(run: AgenticRun, state: LoopState): TextToolResult;
|
|
54
|
+
/**
|
|
55
|
+
* R2 message enrichment (v1.16.1 — /6step PARTIAL TP): some MCP consumers (notably Claude Code's
|
|
56
|
+
* tool-result rendering) collapse isError responses to the message string only and don't surface
|
|
57
|
+
* `structuredContent` — wire format includes both per CallToolResultSchema (independent optional
|
|
58
|
+
* fields) but rendering is consumer-side. Operator-actionable fields (iterations, filesRead) are
|
|
59
|
+
* mirrored into the message string so they're visible regardless of consumer rendering. Dedupe fires
|
|
60
|
+
* AFTER the iteration's generateContent completed — the call IS counted in apiCalls.
|
|
61
|
+
*/
|
|
62
|
+
export declare function noProgressDetected(state: LoopState, stuck: NoProgress): TextToolResult;
|
|
63
|
+
/**
|
|
64
|
+
* The end of a loop that exhausted `maxIterations`: the forced answer when the finalization pass
|
|
65
|
+
* produced text, else `AGENTIC_MAX_ITERATIONS`.
|
|
66
|
+
*
|
|
67
|
+
* Token totals are after the finalization pass. When the pass succeeded at the API level its tokens
|
|
68
|
+
* ARE billed even if its text came back empty, so both results report the post-pass totals.
|
|
69
|
+
* `apiCalls` counts the pass from its explicit `attempted` flag (set IMMEDIATELY BEFORE the dispatch)
|
|
70
|
+
* rather than from its usage — timeouts and pre-response network failures leave usageMetadata empty
|
|
71
|
+
* even though the request was sent. Skipped paths
|
|
72
|
+
* (daily-budget reject) leave `attempted` false so they report `apiCalls = iterations`. Operators can
|
|
73
|
+
* branch on `apiCalls > iterations` to detect the forced pass without parsing `convergenceForced`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function maxIterationsResult(run: AgenticRun, state: LoopState, rescue: RescueOutcome): TextToolResult;
|
|
76
|
+
//# sourceMappingURL=results.d.ts.map
|
|
@@ -0,0 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