@qmediat.io/gemini-code-context-mcp 1.5.2 → 1.7.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 +92 -0
- package/README.md +7 -4
- package/dist/gemini/retry.d.ts +28 -0
- package/dist/gemini/retry.d.ts.map +1 -1
- package/dist/gemini/retry.js +71 -1
- package/dist/gemini/retry.js.map +1 -1
- package/dist/manifest/db.d.ts +25 -1
- package/dist/manifest/db.d.ts.map +1 -1
- package/dist/manifest/db.js +37 -3
- package/dist/manifest/db.js.map +1 -1
- package/dist/tools/ask-agentic.tool.d.ts +5 -0
- package/dist/tools/ask-agentic.tool.d.ts.map +1 -1
- package/dist/tools/ask-agentic.tool.js +67 -12
- package/dist/tools/ask-agentic.tool.js.map +1 -1
- package/dist/tools/ask.tool.d.ts +5 -0
- package/dist/tools/ask.tool.d.ts.map +1 -1
- package/dist/tools/ask.tool.js +80 -27
- package/dist/tools/ask.tool.js.map +1 -1
- package/dist/tools/code.tool.d.ts +18 -0
- package/dist/tools/code.tool.d.ts.map +1 -1
- package/dist/tools/code.tool.js +67 -21
- package/dist/tools/code.tool.js.map +1 -1
- package/dist/tools/shared/abort-timeout.d.ts +64 -0
- package/dist/tools/shared/abort-timeout.d.ts.map +1 -0
- package/dist/tools/shared/abort-timeout.js +117 -0
- package/dist/tools/shared/abort-timeout.js.map +1 -0
- package/dist/tools/shared/stream-collector.d.ts +89 -0
- package/dist/tools/shared/stream-collector.d.ts.map +1 -0
- package/dist/tools/shared/stream-collector.js +194 -0
- package/dist/tools/shared/stream-collector.js.map +1 -0
- package/dist/tools/status.tool.d.ts.map +1 -1
- package/dist/tools/status.tool.js +29 -3
- package/dist/tools/status.tool.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,98 @@ All notable changes to `@qmediat.io/gemini-code-context-mcp` will be documented
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.0] - 2026-04-25
|
|
9
|
+
|
|
10
|
+
### Added — T20 streaming heartbeat for `ask` / `code`
|
|
11
|
+
|
|
12
|
+
- **`ask` and `code` now use `generateContentStream` instead of `generateContent`**. Stream chunks accumulate into a `CollectedResponse` (same shape as the old return) via the new `src/tools/shared/stream-collector.ts` helper. Downstream parsing (`parseEdits`, `parseCodeBlocks`, etc.) is unchanged.
|
|
13
|
+
- **Live thinking heartbeat.** When the model emits thought-flagged parts (`includeThoughts: true`), `collectStream` extracts them and forwards via `onThoughtChunk` to the MCP progress emitter as `"thinking: <truncated>…"` notifications. Throttled at ~1500 ms by default to avoid flooding the MCP host. Visible in Claude Code's UI during long HIGH-thinking calls — no more silent 60-180 s pauses.
|
|
14
|
+
- **`stream-collector.ts` semantics** (verified by 20 unit tests):
|
|
15
|
+
- Text concat across all chunks
|
|
16
|
+
- `usageMetadata` last-write-wins (Gemini sends only on the final chunk)
|
|
17
|
+
- `candidates` last-non-empty-wins (finish reasons + safety ratings authoritative on final chunk only)
|
|
18
|
+
- `thoughtsSummary` joined and capped at 1200 chars (matches existing post-call extraction)
|
|
19
|
+
- Abort propagation: pre-flight check + mid-stream check; closes the generator and rethrows the signal's reason
|
|
20
|
+
- Mid-stream errors propagate verbatim; abort wins over generic SDK errors
|
|
21
|
+
- `onThoughtChunk` callback errors are swallowed (logged) so emitter bugs don't kill the stream
|
|
22
|
+
|
|
23
|
+
### Added — D#7 (closes the visibility symptom of T18)
|
|
24
|
+
|
|
25
|
+
- **`status` now separates settled cost from in-flight reserved cost.** New fields on the structured response:
|
|
26
|
+
- `spentTodaySettledUsd` — cost from finalised calls only (today, UTC)
|
|
27
|
+
- `inFlightReservedTodayUsd` — sum of in-flight reservation rows (today, UTC)
|
|
28
|
+
- `usage.settledCostUsd` — workspace-scoped equivalent
|
|
29
|
+
- `usage.inFlightReservedUsd` — workspace-scoped in-flight slice
|
|
30
|
+
- **Human-readable output adds parenthetical breakdown** when in-flight is non-zero: `"(today: $4.1360 (settled $3.5360 + $0.6000 in-flight reserved))"`. Hidden when no calls are in flight to avoid noise on the common path.
|
|
31
|
+
- **Backward-compatible.** `spentTodayUsd` and `usage.totalCostUsd` keep their existing semantics (settled + in-flight) so daily-budget enforcement stays a true upper bound; the new fields are pure additions for visibility. Streaming made the in-flight window much more observable (60-180 s on HIGH thinking) — D#7 closes that perception gap.
|
|
32
|
+
- **New `ManifestDb` methods**: `todaysInFlightReservedMicros(nowMs)` and `inFlightReservedMicros` field on `workspaceStats()` return.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **`ask.tool.ts` and `code.tool.ts` post-call thought extraction now reuses `response.thoughtsSummary`** from the collector instead of re-iterating `response.candidates` for thought parts. Eliminates the risk of drift between live thought-emit and post-call summary.
|
|
37
|
+
- **`withNetworkRetry` wraps the OPENING of the stream**, not individual chunks. A pre-response failure → retry opens a fresh full stream. A mid-stream failure cannot be retried (Gemini's `generateContentStream` doesn't support resume) → propagates verbatim. The same applies to stale-cache retry: a stale-cache error mid-stream invalidates the cache and opens a brand-new full stream (discards partial response).
|
|
38
|
+
|
|
39
|
+
### Deferred
|
|
40
|
+
|
|
41
|
+
- **T18 ("precise budget accounting on stale-cache retry") cancel+re-reserve fix is NOT shipped.** Re-analysis showed the proposed fix is a no-op from the budget-accounting perspective: in the stale-cache retry path, the new estimate is identical to the original (same prompt, same workspace, same expected output), so cancel+re-reserve would just rotate the row id without changing the reserved amount. The user-visible symptom T18 was meant to address — concurrent callers seeing inflated daily totals during the retry window — is fully closed by D#7 above. T18 stays open in `docs/FOLLOW-UP-PRS.md` for the day a high-concurrency user genuinely needs a "downsize reservation" DB primitive (would be a separate ticket; v1.8+ if triggered).
|
|
42
|
+
|
|
43
|
+
### Fixed — `ask_agentic` iteration-timeout during throttle wait (v1.6.0 regression)
|
|
44
|
+
|
|
45
|
+
- **`ask_agentic`: a TPM-throttle wait that aborts on the per-iteration timeout now correctly maps to `errorCode: 'TIMEOUT'` AND releases both the budget and throttle reservations.** The v1.6.0 implementation wrapped only the `runAgenticIteration` call in the per-iteration try/catch; an abort firing inside `abortableSleep` during the pre-call throttle wait escaped to the outer catch with `errorCode: 'UNKNOWN'`, and both the in-flight budget reservation (over-counts daily spend) and TPM bucket entry (`releaseId`) leaked. Throttle wait moved INSIDE the per-iteration try (`src/tools/ask-agentic.tool.ts:537-560`); existing cancel/finalise/`isTimeoutAbort` mapping path now covers this branch. Surfaced by the new F3 unit test (`test/unit/ask-agentic.test.ts`). Pre-release fix — affects only users running the v1.6.0 branch under a tight `iterationTimeoutMs` AND a non-zero `tpmThrottleLimit` AND a throttle wait long enough to overrun the deadline.
|
|
46
|
+
|
|
47
|
+
### Caveat carry-over from v1.6.0
|
|
48
|
+
|
|
49
|
+
The streaming refactor preserves v1.6.0's T19 timeout caveat: `AbortSignal` is client-only — Gemini may still finish server-side and bill for completed work. When timeout aborts mid-stream, our client drops the response stream; the request server-side finishes normally.
|
|
50
|
+
|
|
51
|
+
### Tests — 38 new cases (524 → 562)
|
|
52
|
+
|
|
53
|
+
- `stream-collector.test.ts` (20): text concat, usageMetadata last-write-wins, candidates last-non-empty-wins, thoughtsSummary aggregation + 1200-char cap, throttled `onThoughtChunk` (default 1500 ms + custom 0 ms), callback error swallowing, abort propagation (pre-flight, mid-stream, abort-wins-over-generic), mid-stream error verbatim, timing metadata
|
|
54
|
+
- `manifest-db.test.ts` extended (3): `todaysInFlightReservedMicros` isolation, `workspaceStats.inFlightReservedMicros` slice, all-settled = 0 case
|
|
55
|
+
- `ask-throttle-integration.test.ts`, `code-throttle-integration.test.ts`, `preflight-guard.test.ts`, `ask-timeout-integration.test.ts` updated to mock `generateContentStream` (wraps existing `generateContent` mock as a single-chunk stream — preserves all assertions)
|
|
56
|
+
- `test/helpers/stream-mock.ts` (new): `singleChunkStream`, `chunkedStream`, `rejectingStream`, `midStreamFailure` helpers for future stream-shape tests
|
|
57
|
+
- `ask-agentic.test.ts` extended (6): T19 `iterationTimeoutMs` coverage — error-mapping with iteration metadata + reservation cancel/finalise pinning (incrementing reservation IDs), wrapped `error.cause` `TimeoutError` detection, `AbortError` ≠ `TIMEOUT` distinction, F2 abort-during-tool-execution (`vi.mock` partial replacement of `grepExecutor` with opt-in latency), F3 abort-during-throttle-wait (drove discovery of the v1.6.0 regression fixed above), end-to-end real-timer-fire on a hung `generateContent`
|
|
58
|
+
|
|
59
|
+
## [1.6.0] - 2026-04-25
|
|
60
|
+
|
|
61
|
+
### Added — T19 wall-clock timeout for `ask` / `code` / `ask_agentic`
|
|
62
|
+
|
|
63
|
+
- **New per-call schema parameter `timeoutMs`** on `ask`, `code` (1s–30min, integer). Aborts the in-flight `generateContent` request via `AbortController` if Gemini exceeds the deadline. Default disabled (zero behaviour change for existing users).
|
|
64
|
+
- **New per-iteration parameter `iterationTimeoutMs`** on `ask_agentic`. Bounds each loop iteration; a single slow iteration aborts the whole agentic call with `errorCode: "TIMEOUT"` (continuing with partial state would leave the conversation structurally incomplete).
|
|
65
|
+
- **Three new env vars** for default values: `GEMINI_CODE_CONTEXT_ASK_TIMEOUT_MS`, `GEMINI_CODE_CONTEXT_CODE_TIMEOUT_MS`, `GEMINI_CODE_CONTEXT_AGENTIC_ITERATION_TIMEOUT_MS`. Resolution: per-call > env var > disabled.
|
|
66
|
+
- **New error code `TIMEOUT`** in `structuredContent.errorCode` with `timeoutMs` and `retryable: true` fields. Distinguishable from other failures (`UNKNOWN`, `BUDGET_REJECT`, `WORKSPACE_TOO_LARGE`, `BUDGET_EXCEEDED`).
|
|
67
|
+
- **New module `src/tools/shared/abort-timeout.ts`** — `createTimeoutController(perCallMs, envVarName)` returns a controller with bounded clamping (1s minimum, 30min maximum) and an `unref()`'d timer that doesn't pin the event loop. `isTimeoutAbort(err)` distinguishes timeout-driven aborts (DOMException `TimeoutError`) from user/SDK aborts (`AbortError`).
|
|
68
|
+
- **`withNetworkRetry` now accepts an optional `signal: AbortSignal`** in `NetworkRetryOptions`. Pre-flight check throws if pre-aborted; mid-loop check short-circuits before retry; backoff sleep is interruptible via `abortableSleep` so a 9s wait doesn't defeat a 5s timeout.
|
|
69
|
+
- **22 new test cases** — `abort-timeout.test.ts` (17: env-var fallback, per-call override, clamping, abort semantics, dispose hygiene, never-firing disabled, `isTimeoutAbort` helper); `gemini-retry.test.ts` extended (5: pre-aborted signal, abort during backoff, abort after first attempt, signal-without-firing, signal-without-reason); `ask-timeout-integration.test.ts` (4: TIMEOUT errorCode mapping for `ask` and `code` including `error.cause` nesting); schema bound tests added to `ask-tool.test.ts` and `code-tool.test.ts` (10 cases). Total suite: 478 → 514.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
|
|
73
|
+
- **SDK `abortSignal` is now wired into `config.abortSignal`** (verified empirically against `node_modules/@google/genai/dist/genai.d.ts:1841`) on every `generateContent` call in `ask`, `code`, and `ask_agentic`. Threading is unconditional even when timeout is disabled — the no-op controller's signal never fires, so existing behaviour is preserved.
|
|
74
|
+
|
|
75
|
+
### Caveat — server-side cancellation is impossible
|
|
76
|
+
|
|
77
|
+
Per Google's SDK comment in `genai.d.ts:1837-1840`: *"AbortSignal is a client-only operation. Using it to cancel an operation will not cancel the request in the service. You will still be charged usage for any applicable operations."* — when timeout fires, our client drops the response stream, but Gemini may still finish generating server-side and bill for the completed work. The TIMEOUT error message and CHANGELOG both surface this fact so callers don't expect cost savings from aborting slow calls.
|
|
78
|
+
|
|
79
|
+
### Rationale
|
|
80
|
+
|
|
81
|
+
`withNetworkRetry` (v1.5.1) only catches PRE-response transient failures. Once Gemini accepts a response stream, a server that takes 10 minutes to think — or hangs on cached-content recall — is observable as a silent stall. The MCP host's progress notifications keep the connection alive, but there was no upper bound on total wall-clock time. T19 closes that gap. Combined with v1.5.1's transient-failure retry and v1.7.0's planned streaming heartbeat (T20), `ask` and `code` will have a fully closed reliability loop: pre-response retry, in-flight liveness signal, bounded wall-clock cap.
|
|
82
|
+
|
|
83
|
+
## [1.5.3] - 2026-04-25
|
|
84
|
+
|
|
85
|
+
### Added
|
|
86
|
+
|
|
87
|
+
- **48 unit test cases for previously integration-only modules** — `cache-manager` (cache HIT/MISS/REBUILD branches, in-process mutex coalescing under microtask pump, mismatch-triggered rebuild for filesHash/model/systemPromptHash, cache-build failure → inline fallback), `files-uploader` (hash-based dedup with reuse-path identity preservation, safety-margin re-upload when expiry < 2 h, in-batch dedup for same-content files, per-upload failure capture in `failures[]`, parallel-pool concurrency cap), `ttl-watcher` (refresh inside `REFRESH_IF_EXPIRES_WITHIN_MS`, skip when plenty of TTL left, cold-workspace eviction, manifest-mismatch eviction, 404/NOT_FOUND eviction with manifest cacheId null-out, transient-error retain-and-retry, re-entrancy guard for overlapping ticks, lifecycle idempotence), `profile-loader` (Tier-1/2/3 resolution order, GOOGLE_CLOUD_LOCATION override, vertex-from-file profile shape, all-missing actionable error). Total suite: 410 → 477.
|
|
88
|
+
- **19 unit test cases for `code.tool.ts` parsers** (`parseEdits` + `parseCodeBlocks`) — minimal OLD/NEW edits, insertion path (NEW-only), multi-file edits, Unicode filenames, paths with spaces and dots, multi-line OLD/NEW preservation, language-tag variants (`c++`, `x86_64`, `foo-bar`, `foo_bar`), NEW-first regression-pin documenting the regex contract for arbitrary text following `NEW:`, malformed inputs (no fence, no marker, incomplete fences). Locks parser surface in advance of v1.7.0's stream-collector refactor (T20).
|
|
89
|
+
|
|
90
|
+
### Changed
|
|
91
|
+
|
|
92
|
+
- **`parseEdits` and `parseCodeBlocks` are now exported** from `src/tools/code.tool.ts`. Pure functions with no side effects; promotion is purely for testability — runtime behaviour unchanged.
|
|
93
|
+
- **`docs/FOLLOW-UP-PRS.md`** — T1, T2, T21 marked SHIPPED with empirical evidence pointers; T21's "open question" (where `THINKING_LEVEL_RESERVE` lives) resolved in favour of the shared module path. Added v1.5.3 row to the release-sequencing table; v1.7.0 row updated to reflect bundling of T18 + D#7 with T20.
|
|
94
|
+
- **`CONTRIBUTING.md`** — clarified that `gemini-code-context-dev` and `gemini-code-context` can coexist as separate MCP entries; documented the `XDG_STATE_HOME` isolation pattern so dev branches don't share prod's manifest DB at `~/.qmediat/gemini-code-context-mcp/manifest.db`.
|
|
95
|
+
|
|
96
|
+
### Rationale
|
|
97
|
+
|
|
98
|
+
This is a **test-coverage + docs hygiene patch**. **Zero runtime behaviour change** — the only diff to production code is the addition of an `export` keyword (and `/** @internal */` JSDoc marker) on two pure parser functions in `src/tools/code.tool.ts` (`parseEdits`, `parseCodeBlocks`). No execution path was modified, no module's runtime side effects changed. The `@internal` markers explicitly carve these exports out of the public API surface — they exist for unit testability only, not for downstream consumption. Sole purpose: lock invariants in place before the v1.6.0 (`AbortController` timeout) and v1.7.0 (streaming refactor) PRs, so any regression in the cache-decision graph, files-API plumbing, TTL refresh, auth resolution, or response parsers breaks the build instead of silently shipping.
|
|
99
|
+
|
|
8
100
|
## [1.5.2] - 2026-04-22
|
|
9
101
|
|
|
10
102
|
### Added
|
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ An MCP (Model Context Protocol) server that wraps Google's Gemini API with **per
|
|
|
25
25
|
| Cost control | — | Daily budget cap in USD (`GEMINI_DAILY_BUDGET_USD`) |
|
|
26
26
|
| Dead deps | 5 unused packages (`ai`, `chalk`, `d3-shape`, `inquirer`, `prismjs`) | Zero dead deps |
|
|
27
27
|
|
|
28
|
-
> *Comparison points reference `jamubc/gemini-mcp-tool` as seen on its GitHub `main` branch (
|
|
28
|
+
> *Comparison points reference `jamubc/gemini-mcp-tool` as seen on its GitHub `main` branch (last commit `ef11fab`, 2025-07-23) and `gemini-mcp-tool@1.1.4` on npm (published 2025-07-22) — both ~9 months stale at time of writing (2026-04-23). The `main` branch and the npm tarball carry the same `gemini-2.5-pro` default (see `src/constants.ts`). One code-level difference: the npm tarball ships `dist/contribute.js` which still imports `chalk` and `inquirer` (so v1.1.4 has 3 genuinely dead deps — `ai`, `d3-shape`, `prismjs`), whereas `main` removed the `contribute` path and leaves `chalk` + `inquirer` declared-but-unimported — 5 dead deps. Structural claims (hardcoded model, no caching, `gemini` CLI subprocess backend, no npm publish since 2025-07) hold for both.*
|
|
29
29
|
|
|
30
30
|
## Quick start
|
|
31
31
|
|
|
@@ -56,10 +56,10 @@ See [`docs/getting-started.md`](./docs/getting-started.md) for a 3-minute walkth
|
|
|
56
56
|
|
|
57
57
|
| Tool | What it does |
|
|
58
58
|
|---|---|
|
|
59
|
-
| **`ask`** | Q&A and long-context analysis against your workspace. **Eager** — uploads the whole repo to Gemini Context Cache. Best for repeat queries on a repo ≤ ~900 k tokens. |
|
|
59
|
+
| **`ask`** | Q&A and long-context analysis against your workspace. **Eager** — uploads the whole repo to Gemini Context Cache. Best for repeat queries on a repo ≤ ~900 k tokens. *(v1.7.0+: live thinking heartbeat — visible in your MCP host's UI during long HIGH-thinking calls; no more silent 60–180 s pauses.)* |
|
|
60
60
|
| **`ask_agentic`** *(v1.5.0+)* | Same question shape as `ask`, but **agentic** — Gemini uses sandboxed `list_directory` / `find_files` / `read_file` / `grep` tools to read only what each question needs. Scales to arbitrarily large repos; no eager upload. Use when your workspace would exceed the model's input-token limit. |
|
|
61
|
-
| **`code`** | Delegate a coding task to Gemini with native thinking budget (16 k default) and optional sandboxed code execution. Returns structured OLD/NEW diffs Claude Code can apply directly. (Eager — same scale constraint as `ask`.) |
|
|
62
|
-
| **`status`** | Inspect the cache state, available models, TTL remaining, cumulative cost. |
|
|
61
|
+
| **`code`** | Delegate a coding task to Gemini with native thinking budget (16 k default) and optional sandboxed code execution. Returns structured OLD/NEW diffs Claude Code can apply directly. (Eager — same scale constraint as `ask`.) *(v1.7.0+: same live thinking heartbeat as `ask`.)* |
|
|
62
|
+
| **`status`** | Inspect the cache state, available models, TTL remaining, cumulative cost. *(v1.7.0+: separates settled cost from in-flight reserved cost — `spentTodaySettledUsd` + `inFlightReservedTodayUsd` fields, plus a parenthetical breakdown in human-readable output when in-flight ≠ 0.)* |
|
|
63
63
|
| **`reindex`** | Force a fresh cache rebuild for this workspace. |
|
|
64
64
|
| **`clear`** | Delete the cache and manifest for this workspace. |
|
|
65
65
|
|
|
@@ -159,6 +159,9 @@ Every env var, auth tier, and per-call override lives in [`docs/configuration.md
|
|
|
159
159
|
| `GEMINI_CODE_CONTEXT_WORKSPACE_GUARD_RATIO` *(v1.5.0+)* | `0.9` | Fraction of `model.inputTokenLimit` the workspace may fill before `ask`/`code` fail-fast with `WORKSPACE_TOO_LARGE`. Clamped to `[0.5, 0.98]`. Raise toward `0.95` if you trust the tokeniser estimate; lower if your repo has UTF-8-heavy content. |
|
|
160
160
|
| `GEMINI_CODE_CONTEXT_TPM_THROTTLE_LIMIT` | `80_000` | Client-side tokens-per-minute ceiling per resolved model. `0` disables the throttle. |
|
|
161
161
|
| `GEMINI_CODE_CONTEXT_FORCE_MAX_OUTPUT` | `false` | Force every call to send `maxOutputTokens = model.outputTokenLimit` (auto otherwise). |
|
|
162
|
+
| `GEMINI_CODE_CONTEXT_ASK_TIMEOUT_MS` *(v1.6.0+)* | disabled | Wall-clock timeout in ms for `ask` (1s–30min). Aborts via `AbortController` when Gemini exceeds the deadline. Returns `errorCode: "TIMEOUT"`. Per-call `ask({ timeoutMs })` overrides. **Note:** `AbortSignal` is client-only — Gemini may still finish server-side and bill for completed work. |
|
|
163
|
+
| `GEMINI_CODE_CONTEXT_CODE_TIMEOUT_MS` *(v1.6.0+)* | disabled | Same as above, applied to the `code` tool. Per-call override: `code({ timeoutMs })`. |
|
|
164
|
+
| `GEMINI_CODE_CONTEXT_AGENTIC_ITERATION_TIMEOUT_MS` *(v1.6.0+)* | disabled | Per-iteration wall-clock cap for `ask_agentic`. A single hung iteration aborts the whole agentic call (continuing with partial state would leave the conversation structurally incomplete). Per-call override: `ask_agentic({ iterationTimeoutMs })`. |
|
|
162
165
|
|
|
163
166
|
## Migrating from `gemini-mcp-tool`
|
|
164
167
|
|
package/dist/gemini/retry.d.ts
CHANGED
|
@@ -39,6 +39,18 @@ export interface NetworkRetryOptions {
|
|
|
39
39
|
readonly baseMs?: number;
|
|
40
40
|
/** Called before each retry with the 1-indexed attempt number that just failed. */
|
|
41
41
|
readonly onRetry?: (attempt: number, err: unknown) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Optional abort signal (T19, v1.6.0). When the signal fires:
|
|
44
|
+
* 1. The currently-pending `fn()` is left to throw `AbortError` on its own
|
|
45
|
+
* (the SDK propagates `signal.aborted` through `config.abortSignal`).
|
|
46
|
+
* 2. The retry loop short-circuits — no further attempts, no backoff sleep.
|
|
47
|
+
* 3. The signal's reason (or a synthesised AbortError) is thrown.
|
|
48
|
+
*
|
|
49
|
+
* Pre-attempt check: if `signal.aborted` is set BEFORE the first try, we
|
|
50
|
+
* throw immediately rather than dispatching a doomed call. Saves the cost
|
|
51
|
+
* of the first abortive request.
|
|
52
|
+
*/
|
|
53
|
+
readonly signal?: AbortSignal;
|
|
42
54
|
}
|
|
43
55
|
/**
|
|
44
56
|
* Decide whether an error is worth retrying at the application layer.
|
|
@@ -60,4 +72,20 @@ export declare function isTransientNetworkError(err: unknown): boolean;
|
|
|
60
72
|
* error shape they would have seen without retry wrapping.
|
|
61
73
|
*/
|
|
62
74
|
export declare function withNetworkRetry<T>(fn: () => Promise<T>, options?: NetworkRetryOptions): Promise<T>;
|
|
75
|
+
/**
|
|
76
|
+
* `setTimeout(resolve, ms)` that also rejects with the abort reason when
|
|
77
|
+
* `signal` fires. Without abort awareness, a 9s backoff sleep — or worse, a
|
|
78
|
+
* 60s TPM-throttle wait — would block T19's wall-clock cap. Exported so tool
|
|
79
|
+
* call sites can reuse it for the throttle/reservation sleep without
|
|
80
|
+
* duplicating the listener+timer dance.
|
|
81
|
+
*
|
|
82
|
+
* Race-safety:
|
|
83
|
+
* - Pre-flight check throws synchronously when signal is already aborted.
|
|
84
|
+
* - Listener uses `{ once: true }` → auto-removes on fire (no leak).
|
|
85
|
+
* - Timer-first path explicitly removes the listener before `resolve()` so
|
|
86
|
+
* a same-tick abort that would re-fire is impossible.
|
|
87
|
+
* - Abort-first path clears the timer before `reject()`.
|
|
88
|
+
* - Single-threaded JS means no read-resolve-then-write-reject window.
|
|
89
|
+
*/
|
|
90
|
+
export declare function abortableSleep(ms: number, signal: AbortSignal | undefined): Promise<void>;
|
|
63
91
|
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/gemini/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/gemini/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3D;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAUD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAuB7D;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC,CAsCZ;AAaD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBzF"}
|
package/dist/gemini/retry.js
CHANGED
|
@@ -80,6 +80,10 @@ export function isTransientNetworkError(err) {
|
|
|
80
80
|
export async function withNetworkRetry(fn, options = {}) {
|
|
81
81
|
const attempts = Math.max(1, Math.min(10, options.attempts ?? 3));
|
|
82
82
|
const baseMs = Math.max(0, options.baseMs ?? 1000);
|
|
83
|
+
const signal = options.signal;
|
|
84
|
+
// Pre-flight abort check — never dispatch when the caller has already
|
|
85
|
+
// signalled they don't want the work done.
|
|
86
|
+
throwIfAborted(signal);
|
|
83
87
|
let lastErr;
|
|
84
88
|
for (let attempt = 1; attempt <= attempts; attempt++) {
|
|
85
89
|
try {
|
|
@@ -87,17 +91,83 @@ export async function withNetworkRetry(fn, options = {}) {
|
|
|
87
91
|
}
|
|
88
92
|
catch (err) {
|
|
89
93
|
lastErr = err;
|
|
94
|
+
// Abort short-circuits everything — the signal's reason wins over any
|
|
95
|
+
// SDK error that happened to surface concurrently. (E.g. SDK throws
|
|
96
|
+
// generic "fetch failed" because abort tore down the socket; we want
|
|
97
|
+
// the timeout-driven AbortError, not the generic transient error.)
|
|
98
|
+
// Checked TWICE: once before classifying the error (catches the common
|
|
99
|
+
// case), once on the final-attempt throw (closes the narrow window
|
|
100
|
+
// where abort flips between the first check and the terminal throw).
|
|
101
|
+
if (signal?.aborted) {
|
|
102
|
+
throwAbortReason(signal);
|
|
103
|
+
}
|
|
90
104
|
if (!isTransientNetworkError(err) || attempt === attempts) {
|
|
105
|
+
if (signal?.aborted)
|
|
106
|
+
throwAbortReason(signal);
|
|
91
107
|
throw err;
|
|
92
108
|
}
|
|
93
109
|
options.onRetry?.(attempt, err);
|
|
94
110
|
const delayMs = baseMs * 3 ** (attempt - 1);
|
|
95
111
|
if (delayMs > 0) {
|
|
96
|
-
await
|
|
112
|
+
await abortableSleep(delayMs, signal);
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
115
|
}
|
|
100
116
|
// Unreachable: the loop either returns or throws on the final attempt.
|
|
101
117
|
throw lastErr;
|
|
102
118
|
}
|
|
119
|
+
/** Throws the signal's reason (or synthesised AbortError) if aborted. */
|
|
120
|
+
function throwIfAborted(signal) {
|
|
121
|
+
if (signal?.aborted)
|
|
122
|
+
throwAbortReason(signal);
|
|
123
|
+
}
|
|
124
|
+
function throwAbortReason(signal) {
|
|
125
|
+
const reason = signal.reason;
|
|
126
|
+
if (reason instanceof Error)
|
|
127
|
+
throw reason;
|
|
128
|
+
throw new DOMException('Operation aborted', 'AbortError');
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* `setTimeout(resolve, ms)` that also rejects with the abort reason when
|
|
132
|
+
* `signal` fires. Without abort awareness, a 9s backoff sleep — or worse, a
|
|
133
|
+
* 60s TPM-throttle wait — would block T19's wall-clock cap. Exported so tool
|
|
134
|
+
* call sites can reuse it for the throttle/reservation sleep without
|
|
135
|
+
* duplicating the listener+timer dance.
|
|
136
|
+
*
|
|
137
|
+
* Race-safety:
|
|
138
|
+
* - Pre-flight check throws synchronously when signal is already aborted.
|
|
139
|
+
* - Listener uses `{ once: true }` → auto-removes on fire (no leak).
|
|
140
|
+
* - Timer-first path explicitly removes the listener before `resolve()` so
|
|
141
|
+
* a same-tick abort that would re-fire is impossible.
|
|
142
|
+
* - Abort-first path clears the timer before `reject()`.
|
|
143
|
+
* - Single-threaded JS means no read-resolve-then-write-reject window.
|
|
144
|
+
*/
|
|
145
|
+
export function abortableSleep(ms, signal) {
|
|
146
|
+
return new Promise((resolve, reject) => {
|
|
147
|
+
if (signal?.aborted) {
|
|
148
|
+
try {
|
|
149
|
+
throwAbortReason(signal);
|
|
150
|
+
}
|
|
151
|
+
catch (err) {
|
|
152
|
+
reject(err);
|
|
153
|
+
}
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const timer = setTimeout(() => {
|
|
157
|
+
signal?.removeEventListener('abort', onAbort);
|
|
158
|
+
resolve();
|
|
159
|
+
}, ms);
|
|
160
|
+
const onAbort = () => {
|
|
161
|
+
clearTimeout(timer);
|
|
162
|
+
try {
|
|
163
|
+
if (signal)
|
|
164
|
+
throwAbortReason(signal);
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
reject(err);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
171
|
+
});
|
|
172
|
+
}
|
|
103
173
|
//# sourceMappingURL=retry.js.map
|
package/dist/gemini/retry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/gemini/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../../src/gemini/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAuBH;;;;GAIG;AACH,MAAM,kBAAkB,GACtB,8IAA8I,CAAC;AAEjJ;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAY;IAClD,IAAI,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE1C,sCAAsC;IACtC,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,KAAK,CAAC;IAE5C,0EAA0E;IAC1E,wEAAwE;IACxE,yCAAyC;IACzC,IAAI,OAAQ,GAA4B,CAAC,MAAM,K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IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC;gBACH,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,CAAC;gBACH,IAAI,MAAM;oBAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;QACH,CAAC,CAAC;QACF,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/manifest/db.d.ts
CHANGED
|
@@ -74,14 +74,38 @@ export declare class ManifestDb {
|
|
|
74
74
|
* billable output. Idempotent — calling with an unknown id is a no-op.
|
|
75
75
|
*/
|
|
76
76
|
cancelBudgetReservation(reservationId: number): void;
|
|
77
|
-
/** Sum costs spent today (UTC) in USD micros.
|
|
77
|
+
/** Sum costs spent today (UTC) in USD micros. Includes both settled
|
|
78
|
+
* (`duration_ms > 0`) and in-flight reserved (`duration_ms = 0`) rows —
|
|
79
|
+
* conservative for the purpose of budget-cap enforcement, where the
|
|
80
|
+
* reservation MUST count against headroom until the call finalises. */
|
|
78
81
|
todaysCostMicros(nowMs: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Sum of TODAY's in-flight reservations (rows where `duration_ms = 0` —
|
|
84
|
+
* reserved but not yet finalised). Subset of `todaysCostMicros`. Used by
|
|
85
|
+
* `status` (D#7, v1.7.0) to show users the breakdown of "this is what
|
|
86
|
+
* has actually settled" vs "this is provisional and may shrink when the
|
|
87
|
+
* call completes". The reservation IS counted against the daily cap (so
|
|
88
|
+
* cap enforcement stays safe), but surfacing the split lets users
|
|
89
|
+
* understand why `status` looks higher than expected during a long
|
|
90
|
+
* in-flight call (especially under streaming, where calls can be in
|
|
91
|
+
* flight for 60-180s on HIGH thinking levels).
|
|
92
|
+
*/
|
|
93
|
+
todaysInFlightReservedMicros(nowMs: number): number;
|
|
79
94
|
/** Aggregate stats for a workspace — powers the `status` tool. */
|
|
80
95
|
workspaceStats(workspaceRoot: string): {
|
|
81
96
|
callCount: number;
|
|
82
97
|
totalCachedTokens: number;
|
|
83
98
|
totalUncachedTokens: number;
|
|
84
99
|
totalCostMicros: number;
|
|
100
|
+
/**
|
|
101
|
+
* Subset of `totalCostMicros` representing in-flight reservations
|
|
102
|
+
* (D#7, v1.7.0). Settled cost = `totalCostMicros - inFlightReservedMicros`.
|
|
103
|
+
* Reservation rows are written with `duration_ms = 0` and updated to
|
|
104
|
+
* the real duration when the call finalises; this slice surfaces the
|
|
105
|
+
* provisional portion so users running `status` mid-call understand
|
|
106
|
+
* why the cost looks higher than the calls that have actually completed.
|
|
107
|
+
*/
|
|
108
|
+
inFlightReservedMicros: number;
|
|
85
109
|
last24hCostMicros: number;
|
|
86
110
|
};
|
|
87
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/manifest/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA6FzE,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAe;gBAEtB,YAAY,CAAC,EAAE,M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iB,EAAE,MAAM,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;KACf,GACG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GACd;QAAE,QAAQ,EAAE,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAE;IAyCtF;;;OAGG;IACH,yBAAyB,CACvB,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;KACpB,GACA,IAAI;IA0BP;;;OAGG;IACH,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAIpD;;;2EAGuE;IACvE,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAWvC;;;;;;;;;;OAUG;IACH,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAWnD,kEAAkE;IAClE,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG;QACrC,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,eAAe,EAAE,MAAM,CAAC;QACxB;;;;;;;WAOG;QACH,sBAAsB,EAAE,MAAM,CAAC;QAC/B,iBAAiB,EAAE,MAAM,CAAC;KAC3B;CAmCF"}
|
package/dist/manifest/db.js
CHANGED
|
@@ -248,11 +248,21 @@ export class ManifestDb {
|
|
|
248
248
|
* cost and token counts after a tool call completes successfully.
|
|
249
249
|
*/
|
|
250
250
|
finalizeBudgetReservation(reservationId, data) {
|
|
251
|
+
// D#7 (v1.7.0) belt-and-suspenders: D#7's settled-vs-in-flight split
|
|
252
|
+
// uses `WHERE duration_ms = 0` as the in-flight sentinel. A real
|
|
253
|
+
// network round-trip cannot complete in 0 ms (verified empirically
|
|
254
|
+
// and reasoned about — `Date.now()` resolution is 1 ms and the
|
|
255
|
+
// smallest realistic Gemini call takes 10+ ms wall-clock), but if a
|
|
256
|
+
// future code path ever managed to call `finalize` with `durationMs = 0`
|
|
257
|
+
// (clock skew, NTP backwards jump, instrumented mock test), that row
|
|
258
|
+
// would stay misclassified as in-flight forever. Floor to 1 ms to make
|
|
259
|
+
// the sentinel deterministic regardless of upstream weirdness.
|
|
260
|
+
const safeDurationMs = Math.max(1, data.durationMs);
|
|
251
261
|
this.db
|
|
252
262
|
.prepare(`UPDATE usage_metrics
|
|
253
263
|
SET cached_tokens = ?, uncached_tokens = ?, cost_usd_micro = ?, duration_ms = ?
|
|
254
264
|
WHERE id = ?`)
|
|
255
|
-
.run(data.cachedTokens, data.uncachedTokens, data.costUsdMicro,
|
|
265
|
+
.run(data.cachedTokens, data.uncachedTokens, data.costUsdMicro, safeDurationMs, reservationId);
|
|
256
266
|
}
|
|
257
267
|
/**
|
|
258
268
|
* Drop a reservation row when the tool call failed before producing any
|
|
@@ -261,7 +271,10 @@ export class ManifestDb {
|
|
|
261
271
|
cancelBudgetReservation(reservationId) {
|
|
262
272
|
this.db.prepare('DELETE FROM usage_metrics WHERE id = ?').run(reservationId);
|
|
263
273
|
}
|
|
264
|
-
/** Sum costs spent today (UTC) in USD micros.
|
|
274
|
+
/** Sum costs spent today (UTC) in USD micros. Includes both settled
|
|
275
|
+
* (`duration_ms > 0`) and in-flight reserved (`duration_ms = 0`) rows —
|
|
276
|
+
* conservative for the purpose of budget-cap enforcement, where the
|
|
277
|
+
* reservation MUST count against headroom until the call finalises. */
|
|
265
278
|
todaysCostMicros(nowMs) {
|
|
266
279
|
const startOfUtcDay = new Date(nowMs);
|
|
267
280
|
startOfUtcDay.setUTCHours(0, 0, 0, 0);
|
|
@@ -270,6 +283,25 @@ export class ManifestDb {
|
|
|
270
283
|
.get(startOfUtcDay.getTime());
|
|
271
284
|
return row.total ?? 0;
|
|
272
285
|
}
|
|
286
|
+
/**
|
|
287
|
+
* Sum of TODAY's in-flight reservations (rows where `duration_ms = 0` —
|
|
288
|
+
* reserved but not yet finalised). Subset of `todaysCostMicros`. Used by
|
|
289
|
+
* `status` (D#7, v1.7.0) to show users the breakdown of "this is what
|
|
290
|
+
* has actually settled" vs "this is provisional and may shrink when the
|
|
291
|
+
* call completes". The reservation IS counted against the daily cap (so
|
|
292
|
+
* cap enforcement stays safe), but surfacing the split lets users
|
|
293
|
+
* understand why `status` looks higher than expected during a long
|
|
294
|
+
* in-flight call (especially under streaming, where calls can be in
|
|
295
|
+
* flight for 60-180s on HIGH thinking levels).
|
|
296
|
+
*/
|
|
297
|
+
todaysInFlightReservedMicros(nowMs) {
|
|
298
|
+
const startOfUtcDay = new Date(nowMs);
|
|
299
|
+
startOfUtcDay.setUTCHours(0, 0, 0, 0);
|
|
300
|
+
const row = this.db
|
|
301
|
+
.prepare('SELECT COALESCE(SUM(cost_usd_micro), 0) AS total FROM usage_metrics WHERE occurred_at >= ? AND duration_ms = 0')
|
|
302
|
+
.get(startOfUtcDay.getTime());
|
|
303
|
+
return row.total ?? 0;
|
|
304
|
+
}
|
|
273
305
|
/** Aggregate stats for a workspace — powers the `status` tool. */
|
|
274
306
|
workspaceStats(workspaceRoot) {
|
|
275
307
|
const row = this.db
|
|
@@ -277,7 +309,8 @@ export class ManifestDb {
|
|
|
277
309
|
COUNT(*) AS call_count,
|
|
278
310
|
COALESCE(SUM(cached_tokens), 0) AS total_cached,
|
|
279
311
|
COALESCE(SUM(uncached_tokens), 0) AS total_uncached,
|
|
280
|
-
COALESCE(SUM(cost_usd_micro), 0) AS total_cost
|
|
312
|
+
COALESCE(SUM(cost_usd_micro), 0) AS total_cost,
|
|
313
|
+
COALESCE(SUM(CASE WHEN duration_ms = 0 THEN cost_usd_micro ELSE 0 END), 0) AS in_flight
|
|
281
314
|
FROM usage_metrics WHERE workspace_root = ?`)
|
|
282
315
|
.get(workspaceRoot);
|
|
283
316
|
const last24h = this.db
|
|
@@ -289,6 +322,7 @@ export class ManifestDb {
|
|
|
289
322
|
totalCachedTokens: row.total_cached,
|
|
290
323
|
totalUncachedTokens: row.total_uncached,
|
|
291
324
|
totalCostMicros: row.total_cost,
|
|
325
|
+
inFlightReservedMicros: row.in_flight,
|
|
292
326
|
last24hCostMicros: last24h.total,
|
|
293
327
|
};
|
|
294
328
|
}
|
package/dist/manifest/db.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/manifest/db.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,QAA2C,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpE,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,6GAA6G;AAC7G,MAAM,UAAU,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6ClB,CAAC;AAEF,SAAS,cAAc,CAAC,GAA4B;IAClD,MAAM,UAAU,GAAG,OAAO,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1E,IAAI,OAAO,GAAa,EAAE,CAAC;IAC3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QAC/C,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;IAChG,CAAC;IAAC,OAAO,GAAG,EA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aAAqB;QAgBlC,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE;aAChB,OAAO,CACN;;;;;;qDAM6C,CAC9C;aACA,GAAG,CAAC,aAAa,CAMnB,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE;aACpB,OAAO,CACN;uDAC+C,CAChD;aACA,GAAG,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAsB,CAAC;QAE1E,OAAO;YACL,SAAS,EAAE,GAAG,CAAC,UAAU;YACzB,iBAAiB,EAAE,GAAG,CAAC,YAAY;YACnC,mBAAmB,EAAE,GAAG,CAAC,cAAc;YACvC,eAAe,EAAE,GAAG,CAAC,UAAU;YAC/B,sBAAsB,EAAE,GAAG,CAAC,SAAS;YACrC,iBAAiB,EAAE,OAAO,CAAC,KAAK;SACjC,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -39,6 +39,7 @@ export declare const askAgenticInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
39
39
|
maxIterations: z.ZodOptional<z.ZodNumber>;
|
|
40
40
|
maxTotalInputTokens: z.ZodOptional<z.ZodNumber>;
|
|
41
41
|
maxFilesRead: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
iterationTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
42
43
|
}, "strip", z.ZodTypeAny, {
|
|
43
44
|
prompt: string;
|
|
44
45
|
model?: string | undefined;
|
|
@@ -49,6 +50,7 @@ export declare const askAgenticInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
49
50
|
maxIterations?: number | undefined;
|
|
50
51
|
maxTotalInputTokens?: number | undefined;
|
|
51
52
|
maxFilesRead?: number | undefined;
|
|
53
|
+
iterationTimeoutMs?: number | undefined;
|
|
52
54
|
}, {
|
|
53
55
|
prompt: string;
|
|
54
56
|
model?: string | undefined;
|
|
@@ -59,6 +61,7 @@ export declare const askAgenticInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
59
61
|
maxIterations?: number | undefined;
|
|
60
62
|
maxTotalInputTokens?: number | undefined;
|
|
61
63
|
maxFilesRead?: number | undefined;
|
|
64
|
+
iterationTimeoutMs?: number | undefined;
|
|
62
65
|
}>, {
|
|
63
66
|
prompt: string;
|
|
64
67
|
model?: string | undefined;
|
|
@@ -69,6 +72,7 @@ export declare const askAgenticInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
69
72
|
maxIterations?: number | undefined;
|
|
70
73
|
maxTotalInputTokens?: number | undefined;
|
|
71
74
|
maxFilesRead?: number | undefined;
|
|
75
|
+
iterationTimeoutMs?: number | undefined;
|
|
72
76
|
}, {
|
|
73
77
|
prompt: string;
|
|
74
78
|
model?: string | undefined;
|
|
@@ -79,6 +83,7 @@ export declare const askAgenticInputSchema: z.ZodEffects<z.ZodObject<{
|
|
|
79
83
|
maxIterations?: number | undefined;
|
|
80
84
|
maxTotalInputTokens?: number | undefined;
|
|
81
85
|
maxFilesRead?: number | undefined;
|
|
86
|
+
iterationTimeoutMs?: number | undefined;
|
|
82
87
|
}>;
|
|
83
88
|
export type AskAgenticInput = z.infer<typeof askAgenticInputSchema>;
|
|
84
89
|
export declare const askAgenticTool: ToolDefinition<AskAgenticInput>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ask-agentic.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask-agentic.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAaH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,OAAO,EAAE,KAAK,cAAc,EAA2B,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ask-agentic.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask-agentic.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAaH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiBxB,OAAO,EAAE,KAAK,cAAc,EAA2B,MAAM,eAAe,CAAC;AAQ7E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwD9B,CAAC;AAEL,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAsPpE,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,eAAe,CAa1D,CAAC"}
|