@genesislcap/foundation-ai 14.454.2-GENC-1321.1 → 14.455.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.
@@ -5,10 +5,9 @@ export { GeminiProvider } from './providers/gemini-provider';
5
5
  export { AnthropicTransport } from './transports/anthropic-transport';
6
6
  export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
7
7
  export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
8
- export { ChatTemperature } from './utils/temperature';
9
8
  export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS } from './types';
10
9
  export type { AIConfig, AIStatus, AIProviderType, AnthropicAIConfig, AnthropicModelId, ChromeAIConfig, ChromeAvailability, GeminiAIConfig, GeminiModelId, ServerAIConfig, } from './types';
11
- export type { AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatDriverResult, ChatInputDuringExecutionMode, ChatMessage, ChatInteraction, ChatRequestOptions, ChatResponseMeta, ChatRole, ChatStreamChunk, ChatToolCall, ChatToolCallUnknown, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, ChatSuggestionsConfig, InteractionRequestOptions, InteractionResult, SubAgentFailureReason, SubAgentRequestOptions, } from './types/chat.types';
10
+ export type { AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatDriverResult, ChatInputDuringExecutionMode, ChatMessage, ChatInteraction, ChatRequestOptions, ChatRole, ChatStreamChunk, ChatToolCall, ChatToolCallUnknown, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, ChatSuggestionsConfig, InteractionRequestOptions, InteractionResult, SubAgentFailureReason, SubAgentRequestOptions, } from './types/chat.types';
12
11
  export { isChatToolCallUnknown } from './types/chat.types';
13
12
  export type { ChatTransport } from './types/chat-transport.types';
14
13
  export type { CostReportingTransport } from './types/transports.types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AACpF,YAAY,EACV,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,gBAAgB,EAChB,4BAA4B,EAC5B,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAA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d,UAAU,EACV,gBAAgB,EAChB,4BAA4B,EAC5B,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,EACzB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAClE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AACvE,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC1E,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/anthropic-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAEV,WAAW,EACX,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAqE7B,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;I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,MAAM,GAAE,wBAA6B;IAmBjD,SAAS,IAAI;QAAE,QAAQ,EAAE,WAAW,CAAC;QAAC,KAAK,EAAE,gBAAgB,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE;IAQrF,iGAAiG;IACjG,eAAe,IAAI,MAAM;IAIzB,oFAAoF;IACpF,iBAAiB,IAAI,IAAI;IAMnB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC;IAgDvE,eAAe,CACnB,OAAO,EAAE,WAAW,EAAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAiCvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IACvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IAEhD;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA0BrB;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAkE3B,OAAO,CAAC,qBAAqB;IAkD7B,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAK;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAO;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAIxC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAQ;YAEjC,IAAI;CA8DnB"}
@@ -74,16 +74,6 @@ export declare class GeminiTransport implements AITransport, ChatTransport, Cost
74
74
  private logTokenUsage;
75
75
  private toGeminiContents;
76
76
  private fromGeminiResponse;
77
- /**
78
- * Log the full shape of a blank or non-STOP response so its cause is legible
79
- * without re-deriving it: a thinking-only STOP (substantial `thoughtsTokenCount`,
80
- * ~0 `candidatesTokenCount`) vs a content block (`SAFETY` / `RECITATION`) vs a
81
- * token cap (`MAX_TOKENS`) vs a prompt-level block (top-level
82
- * `promptFeedback.blockReason`). On 2.5 Pro — which always thinks — a blank
83
- * STOP carrying substantial thought tokens is the "thought, then stopped
84
- * without answering" signature.
85
- */
86
- private logAbnormalResponse;
87
77
  private buildEndpoint;
88
78
  private static readonly MAX_RETRIES;
89
79
  private static readonly RATE_LIMIT_STATUS;
@@ -1 +1 @@
1
- {"version":3,"file":"gemini-transport.d.ts","sourceRoot":"","sources":["../../../src/transports/gemini-transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC7B,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAEV,WAAW,EACX,kBAAkB,EAInB,MAAM,qBAAqB,CAAC;AA8D7B,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAUD;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACvC,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM;gBAAtB,aAAa,CAAC,EAAE,MAAM;CAI5C;AAED;;;;;;;;GAQG;AACH,qBAAa,eAAgB,YAAW,WAAW,EAAE,aAAa,EAAE,sBAAsB;IACxF,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,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AAE,EACtB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAsCvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IACvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IAEhD;;;;OAIG;IACH,OAAO,CAAC,aAAa;IA0BrB,OAAO,CAAC,gBAAgB;IAwDxB,OAAO,CAAC,kBAAkB;IA0E1B,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAK;IACxC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAO;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAO;IACzD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAGxC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAQ;YAEjC,IAAI;IA+DlB,OAAO,CAAC,eAAe;CAexB"}
@@ -150,44 +150,6 @@ export interface ChatMessage {
150
150
  * cost without re-deriving rates.
151
151
  */
152
152
  cost?: number;
153
- /**
154
- * Provider diagnostic for the request that produced this message — the raw
155
- * finish reason plus, where the provider reports them, the reasoning-token
156
- * count and a parts breakdown. Set by transports that expose it (Gemini); the
157
- * driver folds it into the debug-log meta events (e.g. an empty-response
158
- * `turn.retry`/`turn.error`) so a blank or truncated turn's cause is legible.
159
- * Not shown to the user.
160
- */
161
- responseMeta?: ChatResponseMeta;
162
- }
163
- /**
164
- * Provider-reported diagnostic for a single chat response, surfaced so the
165
- * driver can attribute a blank/abnormal turn without re-deriving it. All fields
166
- * are optional — a transport sets only what its provider reports.
167
- *
168
- * @beta
169
- */
170
- export interface ChatResponseMeta {
171
- /**
172
- * Raw provider finish reason for the turn, verbatim — e.g. Gemini `'STOP'` |
173
- * `'MAX_TOKENS'` | `'SAFETY'` | `'RECITATION'`. The key signal when triaging a
174
- * blank or truncated turn.
175
- */
176
- finishReason?: string;
177
- /**
178
- * Reasoning ("thinking") tokens billed for this turn, when the provider
179
- * reports them (Gemini 2.5). A high count alongside ~0 output tokens and a
180
- * `'STOP'` finish is the "thought, then stopped without answering" signature.
181
- */
182
- thoughtsTokens?: number;
183
- /** Count of response parts by kind — distinguishes a truly empty turn from a thinking-only one. */
184
- parts?: {
185
- functionCall: number;
186
- thought: number;
187
- text: number;
188
- };
189
- /** Provider block reason when the prompt/response was blocked rather than generated. */
190
- blockReason?: string;
191
153
  }
192
154
  /**
193
155
  * JSON Schema-based tool definition for function calling.
@@ -328,36 +290,6 @@ export type ChatToolHandlers<TSubAgent extends {
328
290
  */
329
291
  releaseAgent?: () => void;
330
292
  }) => Promise<unknown>>;
331
- /**
332
- * Controls whether (and how) the model may call a tool on a given turn. Maps to
333
- * each provider's "tool choice" / "function calling mode" control:
334
- *
335
- * - `'auto'` (the default when omitted) — the model decides whether to call a
336
- * tool or answer with text. Anthropic leaves `tool_choice` unset; Gemini
337
- * leaves `functionCallingConfig` unset (`AUTO`).
338
- * - `'required'` — the model MUST call one of the available tools. Maps to
339
- * Anthropic `tool_choice: { type: 'any' }` and Gemini
340
- * `functionCallingConfig.mode: 'ANY'`.
341
- * - `'none'` — the model MUST NOT call a tool (text answer only). Maps to
342
- * Anthropic `tool_choice: { type: 'none' }` and Gemini
343
- * `functionCallingConfig.mode: 'NONE'`.
344
- * - `{ tool: name }` — the model MUST call exactly the named tool. Maps to
345
- * Anthropic `tool_choice: { type: 'tool', name }` and Gemini
346
- * `functionCallingConfig.mode: 'ANY', allowedFunctionNames: [name]`. Use this
347
- * for surgical forcing at a single-tool juncture (e.g. force a classifier
348
- * tool in an intake step) while leaving `'auto'` everywhere multi-step work
349
- * happens.
350
- *
351
- * Forcing (`'required'` / `{ tool }`) is a no-op when no tools are advertised.
352
- *
353
- * NOTE: forcing is incompatible with Anthropic extended/adaptive thinking — a
354
- * request must not enable both.
355
- *
356
- * @beta
357
- */
358
- export type ChatToolChoice = 'auto' | 'required' | 'none' | {
359
- tool: string;
360
- };
361
293
  /**
362
294
  * Options for a chat request.
363
295
  *
@@ -369,29 +301,19 @@ export interface ChatRequestOptions {
369
301
  attachments?: ChatAttachment[];
370
302
  signal?: AbortSignal;
371
303
  /**
372
- * Whether (and how) the model may call a tool this turn. Defaults to `'auto'`
373
- * when omitted. Used by sub-agent loops (which force `'required'` so a turn
374
- * can only end via a tool call) and configurable per agent / per agent state.
375
- * See {@link ChatToolChoice}.
304
+ * Whether the model MAY call a tool (`'auto'`, the default when omitted) or
305
+ * MUST call one (`'required'`). `'required'` maps to Anthropic
306
+ * `tool_choice: { type: 'any' }` and Gemini
307
+ * `functionCallingConfig.mode: 'ANY'`. Used by sub-agent loops so a sub-agent
308
+ * can only end a turn by calling a tool (e.g. its completion tool), never by
309
+ * emitting a free-text answer.
376
310
  *
377
- * @beta
378
- */
379
- toolChoice?: ChatToolChoice;
380
- /**
381
- * Provider-agnostic sampling temperature, normalized to `0`–`1` and anchored
382
- * on each provider's own default: `0` is fully deterministic, `0.5` is the
383
- * provider's default, and `1` is the most random it allows. So `< 0.5` is
384
- * "more focused than default" and `> 0.5` is "more random than default" on
385
- * every provider, even though their native ranges differ (Anthropic
386
- * `temperature` `0`–`1`, Gemini `generationConfig.temperature` `0`–`2`). Where
387
- * a provider's default equals its max (Anthropic), the upper half is flat.
388
- * Values outside `0`–`1` are clamped. Omit to use the provider/model default
389
- * (equivalent to `0.5`). Prefer the `ChatTemperature` presets for common
390
- * intents.
311
+ * NOTE: `'required'` is incompatible with Anthropic extended/adaptive
312
+ * thinking — a request must not enable both.
391
313
  *
392
314
  * @beta
393
315
  */
394
- temperature?: number;
316
+ toolChoice?: 'auto' | 'required';
395
317
  }
396
318
  /**
397
319
  * The result returned by a driver after processing a user turn.
@@ -1 +1 @@
1
- {"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../../../src/types/chat.types.ts"],"names":[],"mapp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E,eAAe,CAAC;IACxB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,qBAAqB,CAAC;IACpC,gEAAgE;IAChE,MAAM,CAAC,EAAE,qBAAqB,CAAC;CAChC;AAED;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAC7B;IACE,gCAAgC;IAChC,QAAQ,EAAE,OAAO,CAAC;IAClB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,+CAA+C;IAC/C,MAAM,CAAC,EAAE,KAAK,CAAC;CAChB,GACD;IACE;;;OAGG;IACH,QAAQ,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -4,7 +4,6 @@ export { GeminiProvider } from './providers/gemini-provider';
4
4
  export { AnthropicTransport } from './transports/anthropic-transport';
5
5
  export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
6
6
  export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
7
- export { ChatTemperature } from './utils/temperature';
8
7
  export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS } from './types';
9
8
  export { isChatToolCallUnknown } from './types/chat.types';
10
9
  export { isSpeechRecognitionAvailable, startSpeechRecognition } from './utils/speech-to-text';
@@ -2,28 +2,11 @@ import { __awaiter } from "tslib";
2
2
  import { SUPPORTED_ANTHROPIC_MODEL_IDS, } from '../types';
3
3
  import { combineSignals } from '../utils/combine-signals';
4
4
  import { logger } from '../utils/logger';
5
- import { scaleTemperature } from '../utils/temperature';
6
5
  const ANTHROPIC_DIRECT_URL = 'https://api.anthropic.com/v1/messages';
7
6
  const ANTHROPIC_API_VERSION = '2023-06-01';
8
7
  const DEFAULT_MODEL = 'claude-haiku-4-5-20251001';
9
8
  const DEFAULT_TIMEOUT = 180000; // 3 minutes
10
9
  const DEFAULT_MAX_TOKENS = 4096;
11
- /** Anthropic's native default + ceiling temperature — https://docs.claude.com/en/api/messages */
12
- const ANTHROPIC_DEFAULT_TEMPERATURE = 1;
13
- const ANTHROPIC_MAX_TEMPERATURE = 1;
14
- /**
15
- * Map a provider-agnostic {@link ChatToolChoice} to Anthropic's `tool_choice`.
16
- * Returns undefined for the default (`'auto'`) so the request omits the field.
17
- */
18
- function toAnthropicToolChoice(choice) {
19
- if (!choice || choice === 'auto')
20
- return undefined;
21
- if (choice === 'required')
22
- return { type: 'any' };
23
- if (choice === 'none')
24
- return { type: 'none' };
25
- return { type: 'tool', name: choice.tool };
26
- }
27
10
  /**
28
11
  * Maximum input context window (tokens) per supported Claude model.
29
12
  * Source: https://docs.claude.com/en/docs/about-claude/models/overview
@@ -166,24 +149,14 @@ export class AnthropicTransport {
166
149
  input_schema: t.parameters,
167
150
  }));
168
151
  }
169
- // Map the requested tool-call mode to Anthropic's tool_choice only
170
- // meaningful when tools exist. `'required'`/`{ tool }` force a tool call so
171
- // a turn can only end via one (e.g. a sub-agent's completion tool).
152
+ // `toolChoice: 'required'` forces the model to call one of the provided
153
+ // tools instead of answering with text used by sub-agent loops so the
154
+ // turn can only end via a tool call. Only meaningful when tools exist.
172
155
  // NOTE: Anthropic rejects forced tool use when extended/adaptive thinking
173
156
  // is enabled; this transport never sets `thinking` on the chat path, so the
174
157
  // two never collide. Keep that invariant if `thinking` is ever added here.
175
- if ((_b = body.tools) === null || _b === void 0 ? void 0 : _b.length) {
176
- const toolChoice = toAnthropicToolChoice(options === null || options === void 0 ? void 0 : options.toolChoice);
177
- if (toolChoice)
178
- body.tool_choice = toolChoice;
179
- }
180
- // Normalized [0,1] temperature → Anthropic's native range, anchored so 0.5
181
- // maps to its default. (Default == max here, so the upper half is flat.)
182
- if ((options === null || options === void 0 ? void 0 : options.temperature) != null) {
183
- body.temperature = scaleTemperature(options.temperature, {
184
- defaultTemp: ANTHROPIC_DEFAULT_TEMPERATURE,
185
- maxTemp: ANTHROPIC_MAX_TEMPERATURE,
186
- });
158
+ if ((options === null || options === void 0 ? void 0 : options.toolChoice) === 'required' && ((_b = body.tools) === null || _b === void 0 ? void 0 : _b.length)) {
159
+ body.tool_choice = { type: 'any' };
187
160
  }
188
161
  const response = yield this.post(body, options === null || options === void 0 ? void 0 : options.signal);
189
162
  return this.fromAnthropicResponse(response);
@@ -2,8 +2,6 @@ import { __awaiter } from "tslib";
2
2
  import { SUPPORTED_GEMINI_MODEL_IDS, } from '../types';
3
3
  import { combineSignals } from '../utils/combine-signals';
4
4
  import { logger } from '../utils/logger';
5
- import { scaleTemperature } from '../utils/temperature';
6
- import { repairMalformedFunctionCall } from './gemini-malformed-call';
7
5
  const GEMINI_DIRECT_URL = (model) => `https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`;
8
6
  const DEFAULT_MODEL = 'gemini-2.5-flash-lite';
9
7
  const DEFAULT_TIMEOUT = 180000; // 3 minutes
@@ -16,22 +14,6 @@ const GEMINI_CONTEXT_LIMITS = {
16
14
  'gemini-2.5-flash': 1048576,
17
15
  'gemini-2.5-flash-lite': 1048576,
18
16
  };
19
- /** Gemini's native default + ceiling temperature — https://ai.google.dev/gemini-api/docs */
20
- const GEMINI_DEFAULT_TEMPERATURE = 1;
21
- const GEMINI_MAX_TEMPERATURE = 2;
22
- /**
23
- * Map a provider-agnostic {@link ChatToolChoice} to Gemini's `toolConfig`.
24
- * Returns undefined for the default (`'auto'`) so the request omits the field.
25
- */
26
- function toGeminiToolConfig(choice) {
27
- if (!choice || choice === 'auto')
28
- return undefined;
29
- if (choice === 'required')
30
- return { functionCallingConfig: { mode: 'ANY' } };
31
- if (choice === 'none')
32
- return { functionCallingConfig: { mode: 'NONE' } };
33
- return { functionCallingConfig: { mode: 'ANY', allowedFunctionNames: [choice.tool] } };
34
- }
35
17
  function assertSupportedGeminiModel(model) {
36
18
  if (!SUPPORTED_GEMINI_MODEL_IDS.includes(model)) {
37
19
  throw new Error(`GeminiTransport: unsupported model "${model}". Use one of: ${SUPPORTED_GEMINI_MODEL_IDS.join(', ')}.`);
@@ -128,7 +110,7 @@ export class GeminiTransport {
128
110
  // ── ChatTransport (multi-turn chat) ────────────────────────────────────
129
111
  sendChatMessage(history, userMessage, options) {
130
112
  return __awaiter(this, void 0, void 0, function* () {
131
- var _a, _b;
113
+ var _a;
132
114
  const contents = this.toGeminiContents(history, userMessage, options === null || options === void 0 ? void 0 : options.attachments);
133
115
  const tools = ((_a = options === null || options === void 0 ? void 0 : options.tools) === null || _a === void 0 ? void 0 : _a.length)
134
116
  ? [
@@ -144,32 +126,16 @@ export class GeminiTransport {
144
126
  const systemInstruction = (options === null || options === void 0 ? void 0 : options.systemPrompt)
145
127
  ? { role: 'system', parts: [{ text: options.systemPrompt }] }
146
128
  : undefined;
147
- // Map the requested tool-call mode to Gemini's toolConfig — only meaningful
148
- // when functions are declared. NOTE: forcing (`ANY` / allowedFunctionNames)
149
- // can make the model batch calls in Python-ish syntax
150
- // `MALFORMED_FUNCTION_CALL`, which `fromGeminiResponse` repairs in place when
151
- // it can confidently parse the call (see `repairMalformedFunctionCall`),
152
- // falling back to the caller's retry otherwise.
153
- const toolConfig = tools ? toGeminiToolConfig(options === null || options === void 0 ? void 0 : options.toolChoice) : undefined;
154
- // Request thought summaries so the model's official reasoning is returned
155
- // (and a thinking-only turn surfaces *something* rather than going silently
156
- // blank). Gemini 2.5 Pro always thinks regardless, so this only changes what
157
- // is RETURNED, not what is billed — see `logTokenUsage` for the thinking-token
158
- // accounting it lets us finally capture.
159
- const generationConfig = { thinkingConfig: { includeThoughts: true } };
160
- // Normalized [0,1] temperature → Gemini's native range, anchored so 0.5
161
- // maps to its default (native 1) and 1 to its ceiling (native 2).
162
- if ((options === null || options === void 0 ? void 0 : options.temperature) != null) {
163
- generationConfig.temperature = scaleTemperature(options.temperature, {
164
- defaultTemp: GEMINI_DEFAULT_TEMPERATURE,
165
- maxTemp: GEMINI_MAX_TEMPERATURE,
166
- });
167
- }
168
- // Names of the tools offered this turn — used to validate a repaired
169
- // malformed call against the real tool surface before accepting it.
170
- const offeredToolNames = new Set(((_b = options === null || options === void 0 ? void 0 : options.tools) !== null && _b !== void 0 ? _b : []).map((t) => t.name));
171
- const response = yield this.post({ model: this.model, contents, tools, systemInstruction, toolConfig, generationConfig }, options === null || options === void 0 ? void 0 : options.signal);
172
- return this.fromGeminiResponse(response, offeredToolNames);
129
+ // `toolChoice: 'required'` forces a function call (`mode: 'ANY'`) instead of
130
+ // a text answer used by sub-agent loops so the turn can only end via a
131
+ // tool call. Only meaningful when functions are declared. Forcing ANY can
132
+ // make the model batch calls in Python-ish syntax → `MALFORMED_FUNCTION_CALL`,
133
+ // which `fromGeminiResponse` already detects and the caller retries.
134
+ const toolConfig = (options === null || options === void 0 ? void 0 : options.toolChoice) === 'required' && tools
135
+ ? { functionCallingConfig: { mode: 'ANY' } }
136
+ : undefined;
137
+ const response = yield this.post({ model: this.model, contents, tools, systemInstruction, toolConfig }, options === null || options === void 0 ? void 0 : options.signal);
138
+ return this.fromGeminiResponse(response);
173
139
  });
174
140
  }
175
141
  /**
@@ -177,19 +143,15 @@ export class GeminiTransport {
177
143
  * and returns the per-call total so the caller can attach it to the response
178
144
  * message.
179
145
  */
180
- logTokenUsage(promptTokens, candidateTokens, thoughtTokens) {
146
+ logTokenUsage(promptTokens, candidateTokens) {
181
147
  const { promptPerMillion, candidatePerMillion } = estimatedGeminiPaidRatesUsdPerMillion(this.model);
182
148
  const promptCost = (promptTokens / GeminiTransport.TOKENS_PER_MILLION) * promptPerMillion;
183
- // Thinking tokens are billed at the output (candidate) rate. They are
184
- // incurred whenever the model thinks (always, on 2.5 Pro) — counting them
185
- // here corrects a long-standing undercount, it does not raise the bill.
186
- const candidateCost = ((candidateTokens + thoughtTokens) / GeminiTransport.TOKENS_PER_MILLION) *
187
- candidatePerMillion;
149
+ const candidateCost = (candidateTokens / GeminiTransport.TOKENS_PER_MILLION) * candidatePerMillion;
188
150
  const totalCost = promptCost + candidateCost;
189
151
  this.lifetimeCostUsd += totalCost;
190
152
  console.log(`--- Gemini Token Usage (${this.model}) ---`);
191
153
  console.log(`Prompt Tokens: ${promptTokens} ($${promptCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)})`);
192
- console.log(`Candidate Tokens: ${candidateTokens} (+${thoughtTokens} thinking) ($${candidateCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)})`);
154
+ console.log(`Candidate Tokens: ${candidateTokens} ($${candidateCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)})`);
193
155
  console.log(`Total Cost: $${totalCost.toFixed(GeminiTransport.COST_DECIMAL_PLACES)}`);
194
156
  console.log(`Lifetime Cost: $${this.lifetimeCostUsd.toFixed(GeminiTransport.COST_DECIMAL_PLACES)}`);
195
157
  console.log('--------------------------');
@@ -248,32 +210,27 @@ export class GeminiTransport {
248
210
  }
249
211
  return contents;
250
212
  }
251
- fromGeminiResponse(response, offeredToolNames = new Set()) {
252
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
213
+ fromGeminiResponse(response) {
214
+ var _a, _b, _c, _d, _e;
253
215
  let inputTokens;
254
216
  let outputTokens;
255
- let thoughtsTokens;
256
217
  let cost;
257
218
  if (response.usageMetadata) {
258
219
  const usage = response.usageMetadata;
259
- cost = this.logTokenUsage((_a = usage.promptTokenCount) !== null && _a !== void 0 ? _a : 0, (_b = usage.candidatesTokenCount) !== null && _b !== void 0 ? _b : 0, (_c = usage.thoughtsTokenCount) !== null && _c !== void 0 ? _c : 0);
220
+ cost = this.logTokenUsage((_a = usage.promptTokenCount) !== null && _a !== void 0 ? _a : 0, (_b = usage.candidatesTokenCount) !== null && _b !== void 0 ? _b : 0);
260
221
  if (usage.promptTokenCount != null) {
261
222
  inputTokens = usage.promptTokenCount;
262
223
  }
263
- if (usage.thoughtsTokenCount != null) {
264
- thoughtsTokens = usage.thoughtsTokenCount;
265
- }
266
- if (usage.candidatesTokenCount != null || usage.thoughtsTokenCount != null) {
267
- // Thinking tokens are generated output, billed at the candidate rate, but
268
- // reported in a field disjoint from `candidatesTokenCount`. Fold them into
269
- // the provider-agnostic `outputTokens` so it reflects the true generated
270
- // total — matching Anthropic, whose `output_tokens` already includes them.
271
- outputTokens = ((_d = usage.candidatesTokenCount) !== null && _d !== void 0 ? _d : 0) + ((_e = usage.thoughtsTokenCount) !== null && _e !== void 0 ? _e : 0);
224
+ if (usage.candidatesTokenCount != null) {
225
+ outputTokens = usage.candidatesTokenCount;
272
226
  }
273
227
  }
274
228
  const candidates = response === null || response === void 0 ? void 0 : response.candidates;
275
229
  const firstCandidate = candidates === null || candidates === void 0 ? void 0 : candidates[0];
276
- const parts = (_g = (_f = firstCandidate === null || firstCandidate === void 0 ? void 0 : firstCandidate.content) === null || _f === void 0 ? void 0 : _f.parts) !== null && _g !== void 0 ? _g : [];
230
+ if ((firstCandidate === null || firstCandidate === void 0 ? void 0 : firstCandidate.finishReason) === 'MALFORMED_FUNCTION_CALL') {
231
+ throw new MalformedFunctionCallError(firstCandidate.finishMessage);
232
+ }
233
+ const parts = (_d = (_c = firstCandidate === null || firstCandidate === void 0 ? void 0 : firstCandidate.content) === null || _c === void 0 ? void 0 : _c.parts) !== null && _d !== void 0 ? _d : [];
277
234
  const toolCalls = [];
278
235
  const thoughtParts = [];
279
236
  const textParts = [];
@@ -282,7 +239,7 @@ export class GeminiTransport {
282
239
  toolCalls.push({
283
240
  id: crypto.randomUUID(),
284
241
  name: part.functionCall.name,
285
- args: (_h = part.functionCall.args) !== null && _h !== void 0 ? _h : {},
242
+ args: (_e = part.functionCall.args) !== null && _e !== void 0 ? _e : {},
286
243
  });
287
244
  }
288
245
  else if (part.thought && part.text) {
@@ -292,108 +249,26 @@ export class GeminiTransport {
292
249
  textParts.push(part.text);
293
250
  }
294
251
  }
295
- // Gemini sometimes flags MALFORMED_FUNCTION_CALL when it produced a complete
296
- // tool call but serialised it as a Python statement. Recover it in place
297
- // when we can parse it with full confidence (its `parts` are empty in this
298
- // case, so the repaired call flows through the normal token/cost handling
299
- // below); otherwise throw so the ChatDriver retry takes over.
300
- if ((firstCandidate === null || firstCandidate === void 0 ? void 0 : firstCandidate.finishReason) === 'MALFORMED_FUNCTION_CALL') {
301
- const repaired = repairMalformedFunctionCall(firstCandidate.finishMessage, offeredToolNames);
302
- if (!repaired) {
303
- throw new MalformedFunctionCallError(firstCandidate.finishMessage);
304
- }
305
- toolCalls.push({ id: crypto.randomUUID(), name: repaired.name, args: repaired.args });
306
- }
307
- // The model's official thinking (thought-summary parts, returned because we
308
- // set `thinkingConfig.includeThoughts`) is surfaced through the SAME channel
309
- // as its tool-call narration: both go in `content`, which the driver tags as
310
- // a toggleable "thinking" block. We combine them so neither is dropped.
311
- // NOTE: for now real thinking and narration share one block; if the real
312
- // thinking proves too verbose we may want to split it into its own channel.
313
- // Final answers surface only the answer text — thought summaries are
314
- // deliberately not promoted to be the answer.
315
- const thinking = thoughtParts.join('');
316
- const narration = textParts.join('');
252
+ // For tool-call responses, surface thought parts as `content` so the UI can
253
+ // render them as a collapsible thinking block. Fall back to text narration
254
+ // (textParts) for models that don't emit native thought parts (e.g. some Flash models)
255
+ // but do narrate alongside tool calls when prompted to do so.
256
+ // For final answers, surface only the response text.
317
257
  const base = toolCalls.length > 0
318
258
  ? {
319
259
  role: 'assistant',
320
- content: [thinking, narration].filter(Boolean).join('\n\n'),
260
+ content: thoughtParts.join('') || textParts.join(''),
321
261
  toolCalls,
322
262
  }
323
- : { role: 'assistant', content: narration };
324
- // Blank / non-STOP finishes are the recurring failure mode (especially empty
325
- // STOP on 2.5 Pro). Log the full shape so the cause is legible from the
326
- // breakdown rather than inferred. MALFORMED is excluded — it has its own
327
- // repair/throw path above.
328
- const finishReason = firstCandidate === null || firstCandidate === void 0 ? void 0 : firstCandidate.finishReason;
329
- const isBlank = toolCalls.length === 0 && !thinking && !narration;
330
- if (isBlank ||
331
- (finishReason && finishReason !== 'STOP' && finishReason !== 'MALFORMED_FUNCTION_CALL')) {
332
- this.logAbnormalResponse(response, {
333
- finishReason,
334
- functionCallParts: toolCalls.length,
335
- thoughtParts: thoughtParts.length,
336
- textParts: textParts.length,
337
- });
338
- }
263
+ : { role: 'assistant', content: textParts.join('') };
339
264
  if (inputTokens != null)
340
265
  base.inputTokens = inputTokens;
341
266
  if (outputTokens != null)
342
267
  base.outputTokens = outputTokens;
343
268
  if (cost != null)
344
269
  base.cost = cost;
345
- // Surface the provider diagnostic on the message so the driver can fold it
346
- // into the debug-log meta events (the console log above is dev-only). Only
347
- // when there's signal — a finish reason, thinking tokens, or a block reason.
348
- const blockReason = (_j = response.promptFeedback) === null || _j === void 0 ? void 0 : _j.blockReason;
349
- if (finishReason != null || thoughtsTokens != null || blockReason != null) {
350
- base.responseMeta = {
351
- finishReason,
352
- thoughtsTokens,
353
- parts: {
354
- functionCall: toolCalls.length,
355
- thought: thoughtParts.length,
356
- text: textParts.length,
357
- },
358
- blockReason,
359
- };
360
- }
361
270
  return base;
362
271
  }
363
- /**
364
- * Log the full shape of a blank or non-STOP response so its cause is legible
365
- * without re-deriving it: a thinking-only STOP (substantial `thoughtsTokenCount`,
366
- * ~0 `candidatesTokenCount`) vs a content block (`SAFETY` / `RECITATION`) vs a
367
- * token cap (`MAX_TOKENS`) vs a prompt-level block (top-level
368
- * `promptFeedback.blockReason`). On 2.5 Pro — which always thinks — a blank
369
- * STOP carrying substantial thought tokens is the "thought, then stopped
370
- * without answering" signature.
371
- */
372
- logAbnormalResponse(response, parsed) {
373
- var _a, _b, _c;
374
- const usage = ((_a = response.usageMetadata) !== null && _a !== void 0 ? _a : {});
375
- const candidate = (_c = (_b = response.candidates) === null || _b === void 0 ? void 0 : _b[0]) !== null && _c !== void 0 ? _c : {};
376
- logger.warn('GeminiTransport: blank/non-STOP response', {
377
- model: this.model,
378
- finishReason: parsed.finishReason,
379
- finishMessage: candidate.finishMessage,
380
- parts: {
381
- total: parsed.functionCallParts + parsed.thoughtParts + parsed.textParts,
382
- functionCall: parsed.functionCallParts,
383
- thought: parsed.thoughtParts,
384
- text: parsed.textParts,
385
- },
386
- usage: {
387
- promptTokenCount: usage.promptTokenCount,
388
- candidatesTokenCount: usage.candidatesTokenCount,
389
- thoughtsTokenCount: usage.thoughtsTokenCount,
390
- totalTokenCount: usage.totalTokenCount,
391
- },
392
- promptFeedback: response.promptFeedback,
393
- safetyRatings: candidate.safetyRatings,
394
- citationMetadata: candidate.citationMetadata,
395
- });
396
- }
397
272
  buildEndpoint(body) {
398
273
  if (this.apiKey) {
399
274
  return {