@genesislcap/foundation-ai 14.469.0 → 14.470.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/dist/dts/index.d.ts +2 -2
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/transports/anthropic-transport.d.ts +67 -1
- package/dist/dts/transports/anthropic-transport.d.ts.map +1 -1
- package/dist/dts/transports/gemini-transport.d.ts +9 -1
- package/dist/dts/transports/gemini-transport.d.ts.map +1 -1
- package/dist/dts/types/chat.types.d.ts +92 -1
- package/dist/dts/types/chat.types.d.ts.map +1 -1
- package/dist/dts/types/transports.types.d.ts +6 -1
- package/dist/dts/types/transports.types.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/transports/anthropic-transport.js +190 -16
- package/dist/esm/transports/gemini-transport.js +58 -16
- package/dist/foundation-ai.api.json +411 -8
- package/dist/foundation-ai.d.ts +176 -4
- package/package.json +11 -11
package/dist/dts/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ export { AIProviderRegistry, createAIProvider, isObservableAIProviderRegistry, M
|
|
|
2
2
|
export type { AIProvider, AIProviderRegistryStatusEntry, ObservableAIProviderRegistry, RegisterAIProvidersOptions, } from './ai-provider';
|
|
3
3
|
export { AnthropicProvider } from './providers/anthropic-provider';
|
|
4
4
|
export { GeminiProvider } from './providers/gemini-provider';
|
|
5
|
-
export { AnthropicTransport } from './transports/anthropic-transport';
|
|
5
|
+
export { AnthropicTransport, ResponseTruncatedError } 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
8
|
export { ChatTemperature } from './utils/temperature';
|
|
9
9
|
export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS } from './types';
|
|
10
10
|
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, CondensePolicy, CondenseResult, CondenseTrigger, ChatSuggestionsConfig, InteractionPresentation, InteractionRequestOptions, InteractionResult, SubAgentFailureReason, SubAgentRequestOptions, } from './types/chat.types';
|
|
11
|
+
export type { AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatDriverResult, ChatInputDuringExecutionMode, CachePolicy, ChatMessage, ChatInteraction, ChatRequestOptions, ChatResponseMeta, ChatRole, ChatStreamChunk, ChatToolCall, ChatToolCallUnknown, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, CondensePolicy, CondenseResult, CondenseTrigger, ChatSuggestionsConfig, InteractionPresentation, InteractionRequestOptions, InteractionResult, SubAgentFailureReason, SubAgentRequestOptions, } from './types/chat.types';
|
|
12
12
|
export { isChatToolCallUnknown } from './types/chat.types';
|
|
13
13
|
export type { ChatTransport } from './types/chat-transport.types';
|
|
14
14
|
export type { CostReportingTransport } from './types/transports.types';
|
package/dist/dts/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,8BAA8B,EAC9B,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,EACnB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV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B,WAAW,EACX,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,cAAc,EACd,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,uBAAuB,EACvB,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"}
|
|
@@ -27,6 +27,41 @@ export interface AnthropicTransportConfig {
|
|
|
27
27
|
*/
|
|
28
28
|
maxTokens?: number;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Thrown when a response stops at `stop_reason: 'max_tokens'` while it still
|
|
32
|
+
* carries tool calls. The model ran out of its output-token budget mid-stream,
|
|
33
|
+
* so the truncated tool call's argument JSON was cut off before it closed — the
|
|
34
|
+
* arguments are incomplete and the call is unusable (e.g. a `vfs_write` whose
|
|
35
|
+
* `content` never finished serializing). Rather than hand a corrupt tool call to
|
|
36
|
+
* the caller — which silently runs with missing args and tends to be retried into
|
|
37
|
+
* an identical wall — the transport raises this so the failure is loud and
|
|
38
|
+
* diagnosable.
|
|
39
|
+
*
|
|
40
|
+
* It is deterministic: re-issuing the same request hits the same cap. The remedy
|
|
41
|
+
* is to raise the provider's `maxTokens` (see {@link AnthropicAIConfig.maxTokens})
|
|
42
|
+
* or to split the work into smaller outputs — not to retry verbatim.
|
|
43
|
+
*
|
|
44
|
+
* @beta
|
|
45
|
+
*/
|
|
46
|
+
export declare class ResponseTruncatedError extends Error {
|
|
47
|
+
/** The model that produced the truncated response. */
|
|
48
|
+
readonly model: string;
|
|
49
|
+
/** The `max_tokens` cap the request was sent with. */
|
|
50
|
+
readonly maxTokens: number;
|
|
51
|
+
/** Output tokens generated before truncation, when the usage block is present. */
|
|
52
|
+
readonly outputTokens: number | undefined;
|
|
53
|
+
/** Names of the tool call(s) on the truncated turn (the last is the cut-off one). */
|
|
54
|
+
readonly toolNames: string[];
|
|
55
|
+
constructor(
|
|
56
|
+
/** The model that produced the truncated response. */
|
|
57
|
+
model: string,
|
|
58
|
+
/** The `max_tokens` cap the request was sent with. */
|
|
59
|
+
maxTokens: number,
|
|
60
|
+
/** Output tokens generated before truncation, when the usage block is present. */
|
|
61
|
+
outputTokens: number | undefined,
|
|
62
|
+
/** Names of the tool call(s) on the truncated turn (the last is the cut-off one). */
|
|
63
|
+
toolNames: string[]);
|
|
64
|
+
}
|
|
30
65
|
/**
|
|
31
66
|
* Transport for Anthropic Claude. Calls the Messages API directly when `apiKey`
|
|
32
67
|
* is provided, otherwise falls back to a server-proxy endpoint (if `serverEndpoint`
|
|
@@ -50,6 +85,12 @@ export declare class AnthropicTransport implements AITransport, ChatTransport, C
|
|
|
50
85
|
* fields instead so its session total stays attributed to chat turns only.
|
|
51
86
|
*/
|
|
52
87
|
private lifetimeCostUsd;
|
|
88
|
+
/**
|
|
89
|
+
* Estimated USD saved by prompt caching vs paying full input price, accumulated across
|
|
90
|
+
* every request. Net of cache-write premiums, so it can be briefly negative before reads
|
|
91
|
+
* accrue. Surfaced alongside `getLifetimeCost`.
|
|
92
|
+
*/
|
|
93
|
+
private lifetimeSavingsUsd;
|
|
53
94
|
constructor(config?: AnthropicTransportConfig);
|
|
54
95
|
getConfig(): {
|
|
55
96
|
provider: 'anthropic';
|
|
@@ -58,10 +99,35 @@ export declare class AnthropicTransport implements AITransport, ChatTransport, C
|
|
|
58
99
|
};
|
|
59
100
|
/** Estimated USD cost accumulated across every successful request on this transport instance. */
|
|
60
101
|
getLifetimeCost(): number;
|
|
61
|
-
/**
|
|
102
|
+
/** Estimated USD saved by prompt caching (net of write premiums) across this instance. */
|
|
103
|
+
getLifetimeSavings(): number;
|
|
104
|
+
/** Reset the lifetime cost + savings counters. Intended for chat-clear / new-session flows. */
|
|
62
105
|
resetLifetimeCost(): void;
|
|
63
106
|
sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
|
|
64
107
|
sendChatMessage(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
108
|
+
/**
|
|
109
|
+
* Place prompt-cache breakpoints on the outgoing request per the resolved {@link CachePolicy}.
|
|
110
|
+
* A breakpoint is `cache_control: {type:'ephemeral'}` on a content block / tool / system block;
|
|
111
|
+
* the API caches the byte-exact prefix up to it. Below a model's minimum cacheable prefix the
|
|
112
|
+
* marker is silently ignored (no error), so placing one is always safe.
|
|
113
|
+
*
|
|
114
|
+
* Render order is tools → system → messages, so a breakpoint's cached prefix covers everything
|
|
115
|
+
* before it:
|
|
116
|
+
* - `'tools'` — last tool (caches the tool block; survives a later system-prompt change).
|
|
117
|
+
* - `'prompt'` — system block (caches tools + system); falls back to the last tool when there
|
|
118
|
+
* is no system prompt.
|
|
119
|
+
* - `'history'` — last stored message block (caches tools + system + the whole stored history),
|
|
120
|
+
* keeping the system-tier breakpoint as a cheaper fallback. The injected, never-stored tail
|
|
121
|
+
* context (if any) sits after this and is intentionally left uncached.
|
|
122
|
+
*/
|
|
123
|
+
private applyCacheControl;
|
|
124
|
+
/**
|
|
125
|
+
* Append never-stored tail context (already framed by the caller) as the final block of the
|
|
126
|
+
* outbound messages. Called AFTER `applyCacheControl`, so any `'history'` breakpoint sits
|
|
127
|
+
* on the last *stored* block and this per-turn volatile block stays outside the cached prefix.
|
|
128
|
+
* At a model-call the last message is user-role; if not (defensive), start a fresh user turn.
|
|
129
|
+
*/
|
|
130
|
+
private appendTailContext;
|
|
65
131
|
private static readonly TOKENS_PER_MILLION;
|
|
66
132
|
private static readonly COST_DECIMAL_PLACES;
|
|
67
133
|
/**
|
|
@@ -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,
|
|
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,EAGV,WAAW,EACX,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAiF7B,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;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA2FD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;IAE7C,sDAAsD;I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kBAAkB,GAC3B,OAAO,CAAC,WAAW,CAAC;IAmDvB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,iBAAiB;IA6BzB;;;;;OAKG;IACH,OAAO,CAAC,iBAAiB;IAYzB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAa;IACvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAK;IAEhD;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAqDrB;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAwE3B,OAAO,CAAC,qBAAqB;IAuF7B,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"}
|
|
@@ -52,6 +52,12 @@ export declare class GeminiTransport implements AITransport, ChatTransport, Cost
|
|
|
52
52
|
* fields instead so its session total stays attributed to chat turns only.
|
|
53
53
|
*/
|
|
54
54
|
private lifetimeCostUsd;
|
|
55
|
+
/**
|
|
56
|
+
* Estimated USD saved by context caching vs paying full input price, accumulated across
|
|
57
|
+
* every request. Gemini implicit caching has no write premium, so this is always ≥ 0.
|
|
58
|
+
* Surfaced alongside `getLifetimeCost`.
|
|
59
|
+
*/
|
|
60
|
+
private lifetimeSavingsUsd;
|
|
55
61
|
constructor(config?: GeminiTransportConfig);
|
|
56
62
|
getConfig(): {
|
|
57
63
|
provider: 'gemini';
|
|
@@ -60,7 +66,9 @@ export declare class GeminiTransport implements AITransport, ChatTransport, Cost
|
|
|
60
66
|
};
|
|
61
67
|
/** Estimated USD cost accumulated across every successful request on this transport instance. */
|
|
62
68
|
getLifetimeCost(): number;
|
|
63
|
-
/**
|
|
69
|
+
/** Estimated USD saved by context caching across this instance (implicit caching → always ≥ 0). */
|
|
70
|
+
getLifetimeSavings(): number;
|
|
71
|
+
/** Reset the lifetime cost + savings counters. Intended for chat-clear / new-session flows. */
|
|
64
72
|
resetLifetimeCost(): void;
|
|
65
73
|
sendStructuredPrompt(options: StructuredPromptOptions): Promise<string>;
|
|
66
74
|
sendChatMessage(history: ChatMessage[], userMessage: string, options?: ChatRequestOptions): Promise<ChatMessage>;
|
|
@@ -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;
|
|
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;AAyI7B,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,MA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;IAiFxB,OAAO,CAAC,kBAAkB;IA0J1B;;;;;;;;OAQG;IACH,OAAO,CAAC,mBAAmB;IAkC3B,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"}
|
|
@@ -384,10 +384,12 @@ export interface InteractionRequestOptions {
|
|
|
384
384
|
* available to it.
|
|
385
385
|
* - `timeout` — the sub-agent did not finish within
|
|
386
386
|
* {@link SubAgentRequestOptions.timeoutMs}; its run was aborted.
|
|
387
|
+
* - `response_truncated` — a turn stopped at the provider's output-token cap with
|
|
388
|
+
* an incomplete tool call; deterministic, so it is not retried.
|
|
387
389
|
*
|
|
388
390
|
* @beta
|
|
389
391
|
*/
|
|
390
|
-
export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | 'empty_response' | 'unknown_tool_limit' | 'timeout';
|
|
392
|
+
export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | 'empty_response' | 'unknown_tool_limit' | 'timeout' | 'response_truncated';
|
|
391
393
|
/**
|
|
392
394
|
* When a tool call's declared payload(s) become stale and should be condensed
|
|
393
395
|
* out of the to-model history. The kinds form a spectrum of widening staleness
|
|
@@ -421,6 +423,17 @@ export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | '
|
|
|
421
423
|
* re-selects the same agent on the next turn it is treated as the same
|
|
422
424
|
* activation, so use `turnEnd` (not `agentEnd`) when you want per-request
|
|
423
425
|
* collapse on a non-stateful agent.
|
|
426
|
+
* - `phaseEnd` — collapse once the agent declares the current *phase* finished by
|
|
427
|
+
* calling `endPhase()` from a tool handler. A phase is an app-defined span
|
|
428
|
+
* *within* one activation — narrower than `agentEnd` (which only fires at whole-
|
|
429
|
+
* agent disposal) and phase-aware in a way `age:N` is not. The intended use is a
|
|
430
|
+
* long, multi-phase stateful flow (e.g. a bootstrap journey) that wants to trim
|
|
431
|
+
* each phase's grounding reads as it moves on, without waiting for the whole
|
|
432
|
+
* agent to end. It is NOT tied to any state-machine library: the author fires
|
|
433
|
+
* `endPhase()` from whichever tool handlers advance their own notion of state,
|
|
434
|
+
* exactly as `condenseWhen` is itself called from tool handlers. If `endPhase()`
|
|
435
|
+
* is never called, the payload still collapses at `agentEnd` — so `phaseEnd`
|
|
436
|
+
* degrades to `agentEnd` rather than never firing.
|
|
424
437
|
*
|
|
425
438
|
* @beta
|
|
426
439
|
*/
|
|
@@ -434,6 +447,8 @@ export type CondenseTrigger = {
|
|
|
434
447
|
kind: 'turnEnd';
|
|
435
448
|
} | {
|
|
436
449
|
kind: 'agentEnd';
|
|
450
|
+
} | {
|
|
451
|
+
kind: 'phaseEnd';
|
|
437
452
|
};
|
|
438
453
|
/**
|
|
439
454
|
* How a stale payload is replaced in the to-model slice.
|
|
@@ -535,6 +550,20 @@ export type ChatToolHandlers<TSubAgent extends {
|
|
|
535
550
|
* guards the flow can release.
|
|
536
551
|
*/
|
|
537
552
|
releaseAgent?: () => void;
|
|
553
|
+
/**
|
|
554
|
+
* Mark the agent's current *phase* as finished, collapsing every payload
|
|
555
|
+
* registered with `condenseWhen({ on: { kind: 'phaseEnd' } })` during that
|
|
556
|
+
* phase out of the to-model history (stored history is untouched). Advances
|
|
557
|
+
* an app-controlled phase epoch — repeatable, with no terminal effect
|
|
558
|
+
* (unlike `releaseAgent` / `completeSubAgent`): call it at each phase
|
|
559
|
+
* boundary and the next phase's reads accumulate against a fresh epoch.
|
|
560
|
+
*
|
|
561
|
+
* Intended for long multi-phase stateful flows that want to trim a phase's
|
|
562
|
+
* grounding reads (entity dumps, validations) as they advance, without
|
|
563
|
+
* ending the agent. Deliberately decoupled from any state-machine library:
|
|
564
|
+
* call it from whichever tool handlers advance the agent's own state.
|
|
565
|
+
*/
|
|
566
|
+
endPhase?: () => void;
|
|
538
567
|
/**
|
|
539
568
|
* Declare how THIS tool call's payload(s) should be condensed out of the
|
|
540
569
|
* history sent to the model once they go stale (see {@link CondensePolicy}).
|
|
@@ -581,6 +610,49 @@ export type ChatToolHandlers<TSubAgent extends {
|
|
|
581
610
|
export type ChatToolChoice = 'auto' | 'required' | 'none' | {
|
|
582
611
|
tool: string;
|
|
583
612
|
};
|
|
613
|
+
/**
|
|
614
|
+
* Prompt-cache policy for a chat request, resolved per turn. **Provider-neutral intent,
|
|
615
|
+
* provider-specific effect** — read this carefully, the two providers differ sharply:
|
|
616
|
+
*
|
|
617
|
+
* - **Anthropic** — `scope` controls where explicit `cache_control` breakpoints are placed
|
|
618
|
+
* (see each variant). This is the *only* way Anthropic caches; no scope → no caching.
|
|
619
|
+
* - **Gemini** — `scope` is effectively a **no-op**. Gemini 2.5+ does *implicit* caching
|
|
620
|
+
* automatically and always-on, caching as much of the stable prefix as it can (everything up
|
|
621
|
+
* to the volatile tail) on every request — regardless of `scope`, **including under
|
|
622
|
+
* `'default'`**. We issue no explicit `cachedContent`, so nothing here changes the Gemini
|
|
623
|
+
* request. Do NOT expect `'tools'`/`'prompt'` to *limit* Gemini caching, nor `'default'` to
|
|
624
|
+
* *disable* it; the most you control on Gemini is keeping the prefix byte-stable so implicit
|
|
625
|
+
* caching can engage.
|
|
626
|
+
*
|
|
627
|
+
* Omit, or use `{ scope: 'default' }`, to add no breakpoints of our own.
|
|
628
|
+
*
|
|
629
|
+
* @beta
|
|
630
|
+
*/
|
|
631
|
+
export type CachePolicy = {
|
|
632
|
+
/**
|
|
633
|
+
* No breakpoints from us — you get the provider's own default behaviour (Anthropic: no
|
|
634
|
+
* caching; Gemini: automatic implicit caching). Equivalent to omitting `cachePolicy`.
|
|
635
|
+
*/
|
|
636
|
+
scope: 'default';
|
|
637
|
+
} | {
|
|
638
|
+
/**
|
|
639
|
+
* How far up the request the (Anthropic) cache prefix extends — slide it to the last
|
|
640
|
+
* point that is byte-stable turn-to-turn:
|
|
641
|
+
* - `'tools'` — cache the tool definitions only. Use when the system prompt is *volatile*
|
|
642
|
+
* but tools are stable; tools render first, so this cache survives a system change.
|
|
643
|
+
* - `'prompt'` — cache tools + system prompt. For agents whose system prompt is stable.
|
|
644
|
+
* - `'history'` — cache tools + system + the full *stored* conversation. The breakpoint
|
|
645
|
+
* sits on the last stored message block, so it caches as much as possible without
|
|
646
|
+
* busting on the volatile tail; only the injected, never-stored tail context is left
|
|
647
|
+
* uncached. Needs an append-only, byte-stable history to actually hit.
|
|
648
|
+
*/
|
|
649
|
+
scope: 'tools' | 'prompt' | 'history';
|
|
650
|
+
/**
|
|
651
|
+
* Cache time-to-live (Anthropic only). `'5m'` (default) suits back-to-back turns; `'1h'`
|
|
652
|
+
* keeps the entry warm across longer gaps at a higher write cost. Ignored on Gemini.
|
|
653
|
+
*/
|
|
654
|
+
ttl?: '5m' | '1h';
|
|
655
|
+
};
|
|
584
656
|
/**
|
|
585
657
|
* Options for a chat request.
|
|
586
658
|
*
|
|
@@ -615,6 +687,25 @@ export interface ChatRequestOptions {
|
|
|
615
687
|
* @beta
|
|
616
688
|
*/
|
|
617
689
|
temperature?: number;
|
|
690
|
+
/**
|
|
691
|
+
* Prompt-cache policy for this turn. See {@link CachePolicy} — Anthropic places explicit
|
|
692
|
+
* `cache_control` breakpoints per `scope`; Gemini caches implicitly regardless. Omit to add
|
|
693
|
+
* no breakpoints of our own.
|
|
694
|
+
*
|
|
695
|
+
* @beta
|
|
696
|
+
*/
|
|
697
|
+
cachePolicy?: CachePolicy;
|
|
698
|
+
/**
|
|
699
|
+
* Operator/volatile context to inject at the **very tail** of the outbound messages — after the
|
|
700
|
+
* stored history *and* after any cache breakpoint — so the model sees it every turn without
|
|
701
|
+
* invalidating the cached prefix. **Never persisted to stored history**; it is re-supplied per
|
|
702
|
+
* request. Anthropic appends it as a text block on the final user turn; Gemini as a trailing
|
|
703
|
+
* `user` content. The caller is responsible for any framing (e.g. a `<system-reminder>` /
|
|
704
|
+
* `<current_context>` marker) so the model reads it as ambient context, not user input.
|
|
705
|
+
*
|
|
706
|
+
* @beta
|
|
707
|
+
*/
|
|
708
|
+
tailContext?: string;
|
|
618
709
|
}
|
|
619
710
|
/**
|
|
620
711
|
* 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":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,gBAAgB,CAAC;AAEpG;;;;GAIG;AACH,KAAK,gBAAgB,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB;;;;OAIG;IACH,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;CAC/B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG;IACnD,OAAO,EAAE,IAAI,CAAC;IACd,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,gBAAgB,GAA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IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -37,7 +37,12 @@ export interface AITransport {
|
|
|
37
37
|
export interface CostReportingTransport {
|
|
38
38
|
/** Estimated USD cost accumulated across every successful request on this transport instance. */
|
|
39
39
|
getLifetimeCost(): number;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Estimated USD saved by prompt caching vs paying full input price, accumulated across this
|
|
42
|
+
* instance. Net of cache-write premiums, so it can be briefly negative before reads accrue.
|
|
43
|
+
*/
|
|
44
|
+
getLifetimeSavings(): number;
|
|
45
|
+
/** Reset the lifetime cost + savings counters. Intended for chat-clear / new-session flows. */
|
|
41
46
|
resetLifetimeCost(): void;
|
|
42
47
|
}
|
|
43
48
|
//# sourceMappingURL=transports.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transports.types.d.ts","sourceRoot":"","sources":["../../../src/types/transports.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,sBAAsB;IACrC,iGAAiG;IACjG,eAAe,IAAI,MAAM,CAAC;IAC1B,
|
|
1
|
+
{"version":3,"file":"transports.types.d.ts","sourceRoot":"","sources":["../../../src/types/transports.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE,WAAW,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,sBAAsB;IACrC,iGAAiG;IACjG,eAAe,IAAI,MAAM,CAAC;IAC1B;;;OAGG;IACH,kBAAkB,IAAI,MAAM,CAAC;IAC7B,+FAA+F;IAC/F,iBAAiB,IAAI,IAAI,CAAC;CAC3B"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AIProviderRegistry, createAIProvider, isObservableAIProviderRegistry, MutableAIProviderRegistry, registerAIProviderRegistry, registerAIProviders, resolveAIConfig, } from './ai-provider';
|
|
2
2
|
export { AnthropicProvider } from './providers/anthropic-provider';
|
|
3
3
|
export { GeminiProvider } from './providers/gemini-provider';
|
|
4
|
-
export { AnthropicTransport } from './transports/anthropic-transport';
|
|
4
|
+
export { AnthropicTransport, ResponseTruncatedError } 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
7
|
export { ChatTemperature } from './utils/temperature';
|