@qmediat.io/gemini-code-context-mcp 1.25.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 +21 -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/run.d.ts.map +1 -1
- package/dist/tools/agentic/run.js +3 -6
- package/dist/tools/agentic/run.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 +1 -1
- package/dist/tools/ask-agentic-fallback.d.ts.map +1 -1
- package/dist/tools/ask-agentic.tool.d.ts.map +1 -1
- package/dist/tools/ask-agentic.tool.js +4 -10
- 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 -795
- 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 +375 -502
- 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/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/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/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/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,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machinery of one `ask` / `code` call and its failure path — the one place both tools open, settle on a failure
|
|
3
|
+
* and close a call.
|
|
4
|
+
*
|
|
5
|
+
* - Opened before the call's first await: the progress emitter, then the timeout controller (its total timer arms at
|
|
6
|
+
* once, its stall timer at the first chunk), then the per-request TPM throttle on the controller's signal.
|
|
7
|
+
* - One tracking object, one completed-request accumulator, one dispatch throttle and one failure trail live through
|
|
8
|
+
* the whole call: every step writes into them the moment it has a value, the failure path reads them.
|
|
9
|
+
* - A failure is settled first (the error line, a 429's retry hint, the ledger, the TPM reservation dropped), then
|
|
10
|
+
* classified (a timeout's progress line); each tool builds its result from the classification, in its own order.
|
|
11
|
+
*/
|
|
12
|
+
import { logger, safeForLog } from '../../utils/logger.js';
|
|
13
|
+
import { createProgressEmitter } from '../../utils/progress.js';
|
|
14
|
+
import { isTimeoutAbort, timedOutCall, toolTimeoutController, } from './abort-timeout.js';
|
|
15
|
+
import { CompletedRequests } from './continuation.js';
|
|
16
|
+
import { DispatchThrottle } from './dispatch-throttle.js';
|
|
17
|
+
import { statusOf, tierErrorMeta, } from './service-tier.js';
|
|
18
|
+
import { settleFailure } from './settle-call.js';
|
|
19
|
+
/** Open a call: synchronous, so the controller exists before the call's first await. */
|
|
20
|
+
export function openEagerCall(request, ctx) {
|
|
21
|
+
const completed = new CompletedRequests();
|
|
22
|
+
const tracking = { ledgerEntry: null, streamOpened: false };
|
|
23
|
+
const emitter = createProgressEmitter(ctx.server, ctx.progressToken);
|
|
24
|
+
const timeout = toolTimeoutController(request.tool, request.knobs);
|
|
25
|
+
// Each request of the decode holds its own TPM reservation; a failure drops the one held.
|
|
26
|
+
const dispatch = new DispatchThrottle({
|
|
27
|
+
throttle: ctx.throttle,
|
|
28
|
+
enabled: ctx.config.tpmThrottleLimit > 0,
|
|
29
|
+
signal: timeout.signal,
|
|
30
|
+
emit: (message) => emitter.emit(message),
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
tool: request.tool,
|
|
34
|
+
workspaceRoot: request.workspaceRoot,
|
|
35
|
+
started: request.started,
|
|
36
|
+
requestedTier: request.requestedTier,
|
|
37
|
+
emitter,
|
|
38
|
+
timeout,
|
|
39
|
+
dispatch,
|
|
40
|
+
completed,
|
|
41
|
+
tracking,
|
|
42
|
+
trail: { reservationId: null, model: null },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Settle a failed call, then classify it. A 429's retry hint seeds the throttle once the model resolved; the ledger
|
|
47
|
+
* keeps what the completed requests billed and releases the rest of the reservation (all of it when none completed);
|
|
48
|
+
* the TPM reservation held is dropped. A timeout's progress line follows the settlement.
|
|
49
|
+
*/
|
|
50
|
+
export function settleFailedEager(call, ctx, err) {
|
|
51
|
+
logger.error(`${call.tool} failed: ${safeForLog(err)}`);
|
|
52
|
+
const usage = settleFailure({
|
|
53
|
+
manifest: ctx.manifest,
|
|
54
|
+
failed: {
|
|
55
|
+
toolName: call.tool,
|
|
56
|
+
reservationId: call.trail.reservationId,
|
|
57
|
+
entry: call.tracking.ledgerEntry,
|
|
58
|
+
completed: call.completed,
|
|
59
|
+
durationMs: Date.now() - call.started,
|
|
60
|
+
},
|
|
61
|
+
err,
|
|
62
|
+
model: call.trail.model?.resolvedModel ?? null,
|
|
63
|
+
throttle: ctx.throttle,
|
|
64
|
+
dispatch: call.dispatch,
|
|
65
|
+
});
|
|
66
|
+
call.trail.reservationId = null;
|
|
67
|
+
const common = { usage, model: call.trail.model, requestedTier: call.requestedTier };
|
|
68
|
+
if (isTimeoutAbort(err))
|
|
69
|
+
return timedOutFailure(call, err, common);
|
|
70
|
+
return {
|
|
71
|
+
kind: 'error',
|
|
72
|
+
...common,
|
|
73
|
+
message: `${call.tool} failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
74
|
+
tierMeta: tierErrorMeta(err, call.tracking.streamOpened),
|
|
75
|
+
httpStatus: statusOf(err),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** The timeout of a call: the limit that fired, said on the progress channel, and both knobs of its controller. */
|
|
79
|
+
function timedOutFailure(call, err, common) {
|
|
80
|
+
const timedOut = timedOutCall(call.tool, err, call.timeout);
|
|
81
|
+
call.emitter.emit(`${call.tool}: aborted after ${timedOut.limitMs ?? '?'}ms ${timedOut.kind}`);
|
|
82
|
+
return {
|
|
83
|
+
kind: 'timeout',
|
|
84
|
+
...common,
|
|
85
|
+
timedOut,
|
|
86
|
+
timeoutMs: call.timeout.timeoutMs,
|
|
87
|
+
stallMs: call.timeout.stallMs,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** Close a call, on every path: the controller disposed, then the emitter stopped. */
|
|
91
|
+
export function closeEagerCall(call) {
|
|
92
|
+
call.timeout.dispose();
|
|
93
|
+
call.emitter.stop();
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=eager-call.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eager-call.js","sourceRoot":"","sources":["../../../src/tools/shared/eager-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAwB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEtF,OAAO,EAKL,cAAc,EACd,YAAY,EACZ,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAGL,QAAQ,EACR,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AA4FjD,wFAAwF;AACxF,MAAM,UAAU,aAAa,CAC3B,OAAyB,EACzB,GAAgB;IAEhB,MAAM,SAAS,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAC1C,MAAM,QAAQ,GAAmB,EAAE,WAAW,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IAC5E,MAAM,OAAO,GAAG,qBAAqB,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IACrE,MAAM,OAAO,GAAG,qBAAqB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACnE,0FAA0F;IAC1F,MAAM,QAAQ,GAAG,IAAI,gBAAgB,CAAC;QACpC,QAAQ,EA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AE,CAAC;IACvB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The steps of an `ask` / `code` call before its context that both tools run the same way. Each returns values or a
|
|
3
|
+
* refusal for its tool to report; every result keeps its tool's own fields and their order.
|
|
4
|
+
*/
|
|
5
|
+
import { type BoundedOutputCap, type OutputCap, type PreflightMode } from '../../gemini/long-decode.js';
|
|
6
|
+
import { type PreflightTokenResult } from '../../gemini/token-counter.js';
|
|
7
|
+
import { type ScanResult } from '../../indexer/workspace-scanner.js';
|
|
8
|
+
import type { ResolvedModel } from '../../types.js';
|
|
9
|
+
import type { ToolContext } from '../registry.js';
|
|
10
|
+
import type { EagerMachinery } from './eager-call.js';
|
|
11
|
+
import type { ServiceTierName } from './service-tier.js';
|
|
12
|
+
/** The caller's narrowing of the workspace scan: the knobs of both tools' input, read from it as it is. */
|
|
13
|
+
export interface ScanFilters {
|
|
14
|
+
readonly includeGlobs?: readonly string[] | undefined;
|
|
15
|
+
readonly excludeGlobs?: readonly string[] | undefined;
|
|
16
|
+
readonly forceRescan?: boolean | undefined;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Scan the call's workspace. The scan memo, built from the stored file rows, lets the scanner skip re-hashing a file
|
|
20
|
+
* whose mtime and size are unchanged (a new workspace has none: every file hashes); `forceRescan` per call or by the
|
|
21
|
+
* operator bypasses it.
|
|
22
|
+
*/
|
|
23
|
+
export declare function scanForCall(call: EagerMachinery, ctx: ToolContext, filters: ScanFilters): Promise<ScanResult>;
|
|
24
|
+
/**
|
|
25
|
+
* The output cap, in three layers (`resolveOutputCap`): the caller's `maxOutputTokens` (clamped to the model's
|
|
26
|
+
* per-request limit, or on a long-decode model to its long-decode total), else the operator's `forceMaxOutputTokens`
|
|
27
|
+
* (the per-request limit on every call), else none on the wire — one request at the model's own default. A caller's
|
|
28
|
+
* `thinkingBudget` is checked against this cap; the clamp and the reservation use the cap that runs (`capThatRuns`).
|
|
29
|
+
*/
|
|
30
|
+
export declare function eagerOutputCap(requested: number | undefined, ctx: ToolContext, resolved: ResolvedModel): OutputCap;
|
|
31
|
+
/** The call's input as the budget and the TPM throttle estimate it, before any count. */
|
|
32
|
+
export interface InputEstimate {
|
|
33
|
+
readonly workspaceBytes: number;
|
|
34
|
+
/** bytes/4 of the workspace and the prompt, plus the extra tokens: what the TPM reservation holds. */
|
|
35
|
+
readonly tokens: number;
|
|
36
|
+
}
|
|
37
|
+
/** One estimate for both the budget reservation and the TPM reservation, so the two never drift apart. */
|
|
38
|
+
export declare function estimateInput(scan: ScanResult, prompt: string, extraTokens: number): InputEstimate;
|
|
39
|
+
/** What the preflight counts. */
|
|
40
|
+
export interface PreflightRequest {
|
|
41
|
+
readonly scan: ScanResult;
|
|
42
|
+
readonly prompt: string;
|
|
43
|
+
readonly resolved: ResolvedModel;
|
|
44
|
+
readonly mode: PreflightMode | undefined;
|
|
45
|
+
/** The cap asked for: a cap that may take more than one request takes the exact count (`preflightModeFor`). */
|
|
46
|
+
readonly cap: OutputCap;
|
|
47
|
+
/** Tokens beyond the files and the prompt, counted by Gemini (`ask`'s attachments; 0 for `code`). */
|
|
48
|
+
readonly extraTokens: number;
|
|
49
|
+
}
|
|
50
|
+
/** The preflight's count and the window it is held against. */
|
|
51
|
+
export interface PreflightCount {
|
|
52
|
+
/** The count, the extra tokens included: the window must hold them whichever way the count was made. */
|
|
53
|
+
readonly preflight: PreflightTokenResult;
|
|
54
|
+
readonly contextWindow: number;
|
|
55
|
+
/** `contextWindow × workspaceGuardRatio`: a count above it is too large for the eager path. */
|
|
56
|
+
readonly threshold: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Count the call's input against the model's advertised input limit (`countForPreflight`: the bytes/4 heuristic well
|
|
60
|
+
* under the limit, Gemini's `countTokens` near it, under the call's signal so a timeout ends the count). `null` when
|
|
61
|
+
* the model advertises no limit: the guard is skipped with a warning, and the request may fail downstream.
|
|
62
|
+
*/
|
|
63
|
+
export declare function countPreflight(call: EagerMachinery, ctx: ToolContext, req: PreflightRequest): Promise<PreflightCount | null>;
|
|
64
|
+
/**
|
|
65
|
+
* The count's provenance as both tools' answers report it: which path produced the count (`heuristic`, `exact`,
|
|
66
|
+
* `fallback`), whether the cache saved an API round-trip, and the raw count before the system-instruction reserve was
|
|
67
|
+
* applied — so an orchestrator can see how the guard decided. Nothing when the model advertises no input limit (the
|
|
68
|
+
* count did not run).
|
|
69
|
+
*/
|
|
70
|
+
export declare function preflightFields(count: PreflightCount | null): Record<string, unknown>;
|
|
71
|
+
/** A count over the window: the workspace is too large for the eager path. */
|
|
72
|
+
export interface OverWindow {
|
|
73
|
+
/** The count, the extra tokens included. */
|
|
74
|
+
readonly counted: PreflightTokenResult;
|
|
75
|
+
readonly contextWindow: number;
|
|
76
|
+
readonly threshold: number;
|
|
77
|
+
/** `workspaceGuardRatio` as a whole percent, as the refusal says it. */
|
|
78
|
+
readonly pctDisplay: number;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The guard's verdict on the count: the values a refusal reports when the count passed the threshold, else `null` —
|
|
82
|
+
* the count fits, or the model advertises no input limit (the guard did not run). Each tool composes its own refusal.
|
|
83
|
+
*/
|
|
84
|
+
export declare function overWindow(count: PreflightCount | null, ctx: ToolContext): OverWindow | null;
|
|
85
|
+
/**
|
|
86
|
+
* What a call runs under once it is sized, built once per call: the budget reservation, the decode and the
|
|
87
|
+
* settlement read the same values.
|
|
88
|
+
*/
|
|
89
|
+
export interface SizedCall {
|
|
90
|
+
readonly resolved: ResolvedModel;
|
|
91
|
+
readonly serviceTier: ServiceTierName;
|
|
92
|
+
readonly estimate: InputEstimate;
|
|
93
|
+
/** The preflight's count; `null` when the model advertises no input limit (the count did not run). */
|
|
94
|
+
readonly count: PreflightCount | null;
|
|
95
|
+
/** The cap that runs — after the input window's cut — and the cut. Its value bounds what a completed request bills;
|
|
96
|
+
* above the per-request limit (a long decode) every continuation request bills the input again. */
|
|
97
|
+
readonly bounded: BoundedOutputCap;
|
|
98
|
+
}
|
|
99
|
+
/** What the daily-budget reservation adds to the sized call. */
|
|
100
|
+
export interface ReservationRequest {
|
|
101
|
+
readonly promptChars: number;
|
|
102
|
+
/** Input tokens beyond the files and the prompt (`ask`'s attachments; 0 for `code`). */
|
|
103
|
+
readonly extraInputTokens: number;
|
|
104
|
+
readonly thinkingTokens: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Reserve the call's worst case against the daily budget: after the scan (the estimate needs it), before anything
|
|
108
|
+
* billable. `reserveBudget` checks and inserts in one `BEGIN IMMEDIATE` transaction, so concurrent calls cannot all
|
|
109
|
+
* pass the check and overshoot the cap together. The id goes into the call's trail at once: no statement comes
|
|
110
|
+
* between a reservation and its owner. Returns the refusal's message when the cap would be exceeded (nothing is
|
|
111
|
+
* reserved; the message is the same for both tools), or null when the call may go on (no daily cap, or reserved).
|
|
112
|
+
*/
|
|
113
|
+
export declare function reserveCallBudget(call: EagerMachinery, ctx: ToolContext, sized: SizedCall, req: ReservationRequest): string | null;
|
|
114
|
+
//# sourceMappingURL=eager-steps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eager-steps.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/eager-steps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,aAAa,EAGnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,KAAK,oBAAoB,EAAqB,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAE,KAAK,UAAU,EAAgC,MAAM,oCAAoC,CAAC;AACnG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAA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AAC,WAAW,EAAE,MAAM,CAAC;IAC7B,wFAAwF;IACxF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,cAAc,EACpB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,SAAS,EAChB,GAAG,EAAE,kBAAkB,GACtB,MAAM,GAAG,IAAI,CA+Bf"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The steps of an `ask` / `code` call before its context that both tools run the same way. Each returns values or a
|
|
3
|
+
* refusal for its tool to report; every result keeps its tool's own fields and their order.
|
|
4
|
+
*/
|
|
5
|
+
import { preflightModeFor, resolveOutputCap, } from '../../gemini/long-decode.js';
|
|
6
|
+
import { countForPreflight } from '../../gemini/token-counter.js';
|
|
7
|
+
import { buildScanMemo, scanWorkspace } from '../../indexer/workspace-scanner.js';
|
|
8
|
+
import { estimatePreCallCostUsd, toMicrosUsd } from '../../utils/cost-estimator.js';
|
|
9
|
+
import { logger, safeForLog } from '../../utils/logger.js';
|
|
10
|
+
/**
|
|
11
|
+
* Scan the call's workspace. The scan memo, built from the stored file rows, lets the scanner skip re-hashing a file
|
|
12
|
+
* whose mtime and size are unchanged (a new workspace has none: every file hashes); `forceRescan` per call or by the
|
|
13
|
+
* operator bypasses it.
|
|
14
|
+
*/
|
|
15
|
+
export function scanForCall(call, ctx, filters) {
|
|
16
|
+
call.emitter.emit(`scanning workspace ${call.workspaceRoot}…`);
|
|
17
|
+
const scanMemo = buildScanMemo(ctx.manifest.getFiles(call.workspaceRoot));
|
|
18
|
+
return scanWorkspace(call.workspaceRoot, {
|
|
19
|
+
...(filters.includeGlobs !== undefined ? { includeGlobs: filters.includeGlobs } : {}),
|
|
20
|
+
...(filters.excludeGlobs !== undefined ? { excludeGlobs: filters.excludeGlobs } : {}),
|
|
21
|
+
maxFiles: ctx.config.maxFilesPerWorkspace,
|
|
22
|
+
maxFileSizeBytes: ctx.config.maxFileSizeBytes,
|
|
23
|
+
manifestMemo: scanMemo,
|
|
24
|
+
forceRescan: filters.forceRescan === true || ctx.config.forceRescan === true,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** The output cap of a model that advertises no `outputTokenLimit`: the pro-tier ceiling, the model's full capacity. */
|
|
28
|
+
const EAGER_OUTPUT_FALLBACK_TOKENS = 65_536;
|
|
29
|
+
/**
|
|
30
|
+
* The output cap, in three layers (`resolveOutputCap`): the caller's `maxOutputTokens` (clamped to the model's
|
|
31
|
+
* per-request limit, or on a long-decode model to its long-decode total), else the operator's `forceMaxOutputTokens`
|
|
32
|
+
* (the per-request limit on every call), else none on the wire — one request at the model's own default. A caller's
|
|
33
|
+
* `thinkingBudget` is checked against this cap; the clamp and the reservation use the cap that runs (`capThatRuns`).
|
|
34
|
+
*/
|
|
35
|
+
export function eagerOutputCap(requested, ctx, resolved) {
|
|
36
|
+
return resolveOutputCap({
|
|
37
|
+
requested,
|
|
38
|
+
forceMax: ctx.config.forceMaxOutputTokens,
|
|
39
|
+
outputTokenLimit: resolved.outputTokenLimit,
|
|
40
|
+
longDecodeTokenLimit: resolved.longDecodeTokenLimit,
|
|
41
|
+
fallbackLimit: EAGER_OUTPUT_FALLBACK_TOKENS,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** One estimate for both the budget reservation and the TPM reservation, so the two never drift apart. */
|
|
45
|
+
export function estimateInput(scan, prompt, extraTokens) {
|
|
46
|
+
const workspaceBytes = scan.files.reduce((sum, f) => sum + f.size, 0);
|
|
47
|
+
return {
|
|
48
|
+
workspaceBytes,
|
|
49
|
+
tokens: Math.ceil(workspaceBytes / 4) + Math.ceil(prompt.length / 4) + extraTokens,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Count the call's input against the model's advertised input limit (`countForPreflight`: the bytes/4 heuristic well
|
|
54
|
+
* under the limit, Gemini's `countTokens` near it, under the call's signal so a timeout ends the count). `null` when
|
|
55
|
+
* the model advertises no limit: the guard is skipped with a warning, and the request may fail downstream.
|
|
56
|
+
*/
|
|
57
|
+
export async function countPreflight(call, ctx, req) {
|
|
58
|
+
const contextWindow = req.resolved.inputTokenLimit;
|
|
59
|
+
const preflightMode = preflightModeFor(req.mode, req.cap);
|
|
60
|
+
if (typeof contextWindow !== 'number' || contextWindow <= 0) {
|
|
61
|
+
logger.warn(`${call.tool}: resolved model ${safeForLog(req.resolved.resolved)} has no advertised inputTokenLimit — workspace size guard skipped. Request may fail downstream if the workspace exceeds the model's context window.`);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
const counted = await countForPreflight(ctx.client, {
|
|
65
|
+
files: req.scan.files,
|
|
66
|
+
prompt: req.prompt,
|
|
67
|
+
model: req.resolved.resolved,
|
|
68
|
+
// post-glob-filter: the hash already encodes the caller's include / exclude globs
|
|
69
|
+
filesHash: req.scan.filesHash,
|
|
70
|
+
...(preflightMode !== undefined ? { preflightMode } : {}),
|
|
71
|
+
inputTokenLimit: contextWindow,
|
|
72
|
+
extraTokens: req.extraTokens, // weighs on the heuristic-vs-exact decision, added to the count below
|
|
73
|
+
signal: call.timeout.signal,
|
|
74
|
+
});
|
|
75
|
+
return {
|
|
76
|
+
preflight: { ...counted, effectiveTokens: counted.effectiveTokens + req.extraTokens },
|
|
77
|
+
contextWindow,
|
|
78
|
+
threshold: Math.floor(contextWindow * ctx.config.workspaceGuardRatio),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The count's provenance as both tools' answers report it: which path produced the count (`heuristic`, `exact`,
|
|
83
|
+
* `fallback`), whether the cache saved an API round-trip, and the raw count before the system-instruction reserve was
|
|
84
|
+
* applied — so an orchestrator can see how the guard decided. Nothing when the model advertises no input limit (the
|
|
85
|
+
* count did not run).
|
|
86
|
+
*/
|
|
87
|
+
export function preflightFields(count) {
|
|
88
|
+
const preflight = count?.preflight;
|
|
89
|
+
if (preflight === undefined)
|
|
90
|
+
return {};
|
|
91
|
+
return {
|
|
92
|
+
tokenCountMethod: preflight.method,
|
|
93
|
+
rawTokenCount: preflight.rawTokens,
|
|
94
|
+
tokenCountCacheHit: preflight.cacheHit,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The guard's verdict on the count: the values a refusal reports when the count passed the threshold, else `null` —
|
|
99
|
+
* the count fits, or the model advertises no input limit (the guard did not run). Each tool composes its own refusal.
|
|
100
|
+
*/
|
|
101
|
+
export function overWindow(count, ctx) {
|
|
102
|
+
if (count !== null && count.preflight.effectiveTokens > count.threshold) {
|
|
103
|
+
return {
|
|
104
|
+
counted: count.preflight,
|
|
105
|
+
contextWindow: count.contextWindow,
|
|
106
|
+
threshold: count.threshold,
|
|
107
|
+
pctDisplay: Math.round(ctx.config.workspaceGuardRatio * 100),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Reserve the call's worst case against the daily budget: after the scan (the estimate needs it), before anything
|
|
114
|
+
* billable. `reserveBudget` checks and inserts in one `BEGIN IMMEDIATE` transaction, so concurrent calls cannot all
|
|
115
|
+
* pass the check and overshoot the cap together. The id goes into the call's trail at once: no statement comes
|
|
116
|
+
* between a reservation and its owner. Returns the refusal's message when the cap would be exceeded (nothing is
|
|
117
|
+
* reserved; the message is the same for both tools), or null when the call may go on (no daily cap, or reserved).
|
|
118
|
+
*/
|
|
119
|
+
export function reserveCallBudget(call, ctx, sized, req) {
|
|
120
|
+
const dailyBudgetUsd = ctx.config.dailyBudgetUsd;
|
|
121
|
+
if (!Number.isFinite(dailyBudgetUsd))
|
|
122
|
+
return null;
|
|
123
|
+
const cap = sized.bounded.cap;
|
|
124
|
+
const estimateUsd = estimatePreCallCostUsd({
|
|
125
|
+
model: sized.resolved.resolved,
|
|
126
|
+
serviceTier: sized.serviceTier,
|
|
127
|
+
extraInputTokens: req.extraInputTokens,
|
|
128
|
+
workspaceBytes: sized.estimate.workspaceBytes,
|
|
129
|
+
promptChars: req.promptChars,
|
|
130
|
+
expectedOutputTokens: cap.effective,
|
|
131
|
+
perRequestOutputTokens: cap.perRequest,
|
|
132
|
+
// the larger of the preflight's count and the bytes/4 heuristic is reserved
|
|
133
|
+
countedInputTokens: sized.count?.preflight.effectiveTokens,
|
|
134
|
+
thinkingTokens: req.thinkingTokens,
|
|
135
|
+
coverMs: call.timeout.timeoutMs,
|
|
136
|
+
});
|
|
137
|
+
const reserve = ctx.manifest.reserveBudget({
|
|
138
|
+
workspaceRoot: call.workspaceRoot,
|
|
139
|
+
toolName: call.tool,
|
|
140
|
+
model: sized.resolved.resolved,
|
|
141
|
+
estimatedCostMicros: toMicrosUsd(estimateUsd),
|
|
142
|
+
dailyBudgetMicros: toMicrosUsd(dailyBudgetUsd),
|
|
143
|
+
nowMs: Date.now(),
|
|
144
|
+
});
|
|
145
|
+
if ('rejected' in reserve) {
|
|
146
|
+
const spentUsd = reserve.spentMicros / 1_000_000;
|
|
147
|
+
return `Daily budget cap would be exceeded: spent $${spentUsd.toFixed(4)} + estimate $${estimateUsd.toFixed(4)} > cap $${dailyBudgetUsd.toFixed(2)}. Retry after UTC midnight, or raise \`GEMINI_DAILY_BUDGET_USD\`.`;
|
|
148
|
+
}
|
|
149
|
+
call.trail.reservationId = reserve.id;
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=eager-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eager-steps.js","sourceRoot":"","sources":["../../../src/tools/shared/eager-steps.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAIL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAA6B,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAC7F,OAAO,EAAmB,aAAa,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GAAG,EAAE;KAClB,CAAC,CAAC;IACH,IAAI,UAAU,IAAI,OAAO,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;QACjD,OAAO,8CAA8C,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,WAAW,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,mEAAmE,CAAC;IACxN,CAAC;IACD,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,OAAO,CAAC,EAAE,CAAC;IACtC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -15,6 +15,15 @@ export declare class ServiceTierError extends Error {
|
|
|
15
15
|
}
|
|
16
16
|
/** The tier of a call: the per-call value wins; on Vertex a per-call `flex` is refused, a default `flex` is standard. */
|
|
17
17
|
export declare function resolveServiceTier(perCall: ServiceTierName | undefined, operatorDefault: ServiceTierName, vertex?: boolean): ServiceTierName;
|
|
18
|
+
/**
|
|
19
|
+
* The tier of an `ask` / `code` call from the per-call value and the operator's configuration, or its refusal as a
|
|
20
|
+
* value: each tool reports a `ServiceTierError` with its own fields. Any other error is thrown, to the call's failure
|
|
21
|
+
* path.
|
|
22
|
+
*/
|
|
23
|
+
export declare function serviceTierOrRefusal(perCall: ServiceTierName | undefined, config: {
|
|
24
|
+
readonly serviceTier: ServiceTierName;
|
|
25
|
+
readonly vertex: boolean;
|
|
26
|
+
}): ServiceTierName | ServiceTierError;
|
|
18
27
|
/** What goes into `GenerateContentConfig`: nothing on standard, the enum on flex. */
|
|
19
28
|
export declare function serviceTierConfig(tier: ServiceTierName): Pick<GenerateContentConfig, 'serviceTier'>;
|
|
20
29
|
/** On flex every send is billed and a queued stream may outlive Node's 300 s header wait: the server never re-sends
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-tier.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/service-tier.ts"],"names":[],"mappings":"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
|
|
|
27
27
|
}
|
|
28
28
|
return 'standard';
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The tier of an `ask` / `code` call from the per-call value and the operator's configuration, or its refusal as a
|
|
32
|
+
* value: each tool reports a `ServiceTierError` with its own fields. Any other error is thrown, to the call's failure
|
|
33
|
+
* path.
|
|
34
|
+
*/
|
|
35
|
+
export function serviceTierOrRefusal(perCall, config) {
|
|
36
|
+
try {
|
|
37
|
+
return resolveServiceTier(perCall, config.serviceTier, config.vertex);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err instanceof ServiceTierError)
|
|
41
|
+
return err;
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
30
45
|
/** What goes into `GenerateContentConfig`: nothing on standard, the enum on flex. */
|
|
31
46
|
export function serviceTierConfig(tier) {
|
|
32
47
|
return tier === 'flex' ? { serviceTier: ServiceTier.FLEX } : {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-tier.js","sourceRoot":"","sources":["../../../src/tools/shared/service-tier.ts"],"names":[],"mappings":"AAAA;;;;;;sGAMsG;AACtG,OAAO,EAA8B,WAAW,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAI/D,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GACnC,ymBAAymB,CAAC;AAE5mB,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,GAAG,0BAA0B,CAAC;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,yHAAyH;AACzH,MAAM,UAAU,kBAAkB,CAChC,OAAoC,EACpC,eAAgC,EAChC,MAAM,GAAG,KAAK;IA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CAAC,CAAC,uCAAuC;QAC9G,OAAO;YACL,SAAS,EAAE,YAAY;YACvB,SAAS,EAAE,IAAI;YACf,GAAG,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACjD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,GAAG;QAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACxE,gHAAgH;IAChH,kDAAkD;IAClD,IAAI,uBAAuB,CAAC,GAAG,CAAC;QAC9B,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,SAAS,EAAE,CAAC,aAAa,EAAE,CAAC;IACnE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* token budgets or ships a new level, one edit here propagates to both
|
|
9
9
|
* call sites (and any future reasoning-capable tool we add).
|
|
10
10
|
*/
|
|
11
|
+
import type { ThinkingConfig } from '@google/genai';
|
|
11
12
|
import { z } from 'zod';
|
|
12
13
|
import { type InputWindowCut } from '../../gemini/long-decode.js';
|
|
13
14
|
/**
|
|
@@ -47,6 +48,14 @@ export declare const THINKING_LEVEL_FIELD: z.ZodOptional<z.ZodEnum<{
|
|
|
47
48
|
* one place.
|
|
48
49
|
*/
|
|
49
50
|
export type ThinkingLevelLiteral = (typeof THINKING_LEVELS)[number];
|
|
51
|
+
/**
|
|
52
|
+
* The `thinkingConfig` of a request driven by a `thinkingLevel` (`ask`, `code`, `ask_agentic`). The level is cast to
|
|
53
|
+
* `ThinkingLevel` rather than looked up in the runtime enum object: for a string enum the value IS the member name, so
|
|
54
|
+
* the cast is the same at runtime — and after an SDK rename the literal reaches Gemini, which answers 400 with a clear
|
|
55
|
+
* message, instead of silently becoming `undefined` at the lookup. `includeThoughts: true` always, so the answer
|
|
56
|
+
* carries Gemini's reasoning digest.
|
|
57
|
+
*/
|
|
58
|
+
export declare function levelThinkingConfig(level: ThinkingLevelLiteral): ThinkingConfig;
|
|
50
59
|
/**
|
|
51
60
|
* Conservative per-tier thinking-token reservations for cost estimation.
|
|
52
61
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/thinking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,eAAe,YAAI,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAMtF,sHAAsH;AACtH,eAAO,MAAM,oBAAoB;;;;;;GAGM,CAAC;AAExC;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAM9E,CAAC;AAEF,yGAAyG;AACzG,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE3E;AAED,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAKlD,wDAAwD;AACxD,UAAU,gBAAgB;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;CACzE;AAED,qHAAqH;AACrH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,C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ACf,GAAG,EAAE,cAAc,GAAG,IAAI,GACzB,MAAM,GAAG,IAAI,CAIf"}
|
|
@@ -40,6 +40,16 @@ export const THINKING_LEVEL_FIELD = z
|
|
|
40
40
|
.enum(THINKING_LEVELS)
|
|
41
41
|
.optional()
|
|
42
42
|
.describe(THINKING_LEVEL_DESCRIPTION);
|
|
43
|
+
/**
|
|
44
|
+
* The `thinkingConfig` of a request driven by a `thinkingLevel` (`ask`, `code`, `ask_agentic`). The level is cast to
|
|
45
|
+
* `ThinkingLevel` rather than looked up in the runtime enum object: for a string enum the value IS the member name, so
|
|
46
|
+
* the cast is the same at runtime — and after an SDK rename the literal reaches Gemini, which answers 400 with a clear
|
|
47
|
+
* message, instead of silently becoming `undefined` at the lookup. `includeThoughts: true` always, so the answer
|
|
48
|
+
* carries Gemini's reasoning digest.
|
|
49
|
+
*/
|
|
50
|
+
export function levelThinkingConfig(level) {
|
|
51
|
+
return { thinkingLevel: level, includeThoughts: true };
|
|
52
|
+
}
|
|
43
53
|
/**
|
|
44
54
|
* Conservative per-tier thinking-token reservations for cost estimation.
|
|
45
55
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thinking.js","sourceRoot":"","sources":["../../../src/tools/shared/thinking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"thinking.js","sourceRoot":"","sources":["../../../src/tools/shared/thinking.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAuB,MAAM,6BAA6B,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC;AAEtF,kFAAkF;AAClF,MAAM,0BAA0B,GAC9B,kqBAAkqB,CAAC;AAErqB,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AI,GAAG,CAAC,SAAS,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC;QACrC,OAAO,qCAAqC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,sEAAsE,kBAAkB,GAAG,CAAC;IACtM,CAAC;IACD,OAAO,mCAAmC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,kBAAkB,GAAG,CAAC;AACtI,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,QAA0B,EAC1B,cAAsB,EACtB,GAAe,EACf,GAA0B;IAE1B,MAAM,OAAO,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC;IACvD,IAAI,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5E,OAAO,+EAA+E,UAAU,CAAC,cAAc,CAAC,wCAAwC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC;AAChL,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The refusal of a workspace path the validation rejects: the first step of every tool that validates its workspace
|
|
3
|
+
* (`ask`, `code`, `ask_agentic`, `reindex`), one text for all of them.
|
|
4
|
+
*/
|
|
5
|
+
import { type TextToolResult } from '../registry.js';
|
|
6
|
+
/** The tools that validate their workspace before anything else. */
|
|
7
|
+
export type WorkspaceTool = 'ask' | 'code' | 'ask_agentic' | 'reindex';
|
|
8
|
+
/**
|
|
9
|
+
* The refusal of a workspace path the validation rejects (`<tool>: <message>`, no fields), else `null`. Called inside
|
|
10
|
+
* the tool's `try`: any other error of the validation reaches the tool's failure path.
|
|
11
|
+
*/
|
|
12
|
+
export declare function workspaceRefusal(tool: WorkspaceTool, workspaceRoot: string): TextToolResult | null;
|
|
13
|
+
//# sourceMappingURL=workspace-refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-refusal.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/workspace-refusal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,KAAK,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAElE,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;AAEvE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,MAAM,GACpB,cAAc,GAAG,IAAI,CAUvB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The refusal of a workspace path the validation rejects: the first step of every tool that validates its workspace
|
|
3
|
+
* (`ask`, `code`, `ask_agentic`, `reindex`), one text for all of them.
|
|
4
|
+
*/
|
|
5
|
+
import { WorkspaceValidationError, validateWorkspacePath, } from '../../indexer/workspace-validation.js';
|
|
6
|
+
import { errorResult } from '../registry.js';
|
|
7
|
+
/**
|
|
8
|
+
* The refusal of a workspace path the validation rejects (`<tool>: <message>`, no fields), else `null`. Called inside
|
|
9
|
+
* the tool's `try`: any other error of the validation reaches the tool's failure path.
|
|
10
|
+
*/
|
|
11
|
+
export function workspaceRefusal(tool, workspaceRoot) {
|
|
12
|
+
try {
|
|
13
|
+
validateWorkspacePath(workspaceRoot);
|
|
14
|
+
}
|
|
15
|
+
catch (err) {
|
|
16
|
+
if (err instanceof WorkspaceValidationError) {
|
|
17
|
+
return errorResult(`${tool}: ${err.message}`);
|
|
18
|
+
}
|
|
19
|
+
throw err;
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=workspace-refusal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-refusal.js","sourceRoot":"","sources":["../../../src/tools/shared/workspace-refusal.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAuB,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAKlE;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAmB,EACnB,aAAqB;IAErB,IAAI,CAAC;QACH,qBAAqB,CAAC,aAAa,CAAC,CAAC;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,GAAG,YAAY,wBAAwB,EAAE,CAAC;YAC5C,OAAO,WAAW,CAAC,GAAG,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qmediat.io/gemini-code-context-mcp",
|
|
3
|
-
"version": "1.25.
|
|
3
|
+
"version": "1.25.1",
|
|
4
4
|
"mcpName": "io.github.qmediat/gemini-code-context-mcp",
|
|
5
5
|
"description": "MCP server that gives Claude Code and other MCP hosts long-context memory of a codebase through Gemini's 1M-token window: `ask`/`code` send the scanned workspace with implicit caching by default or an explicit Context Cache on request; `ask_agentic` reads files on demand for repos beyond the limit.",
|
|
6
6
|
"keywords": [
|