@genesislcap/foundation-ai 15.19.6 → 15.20.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 -1
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/transports/context-overflow-error.d.ts +86 -0
- package/dist/dts/transports/context-overflow-error.d.ts.map +1 -0
- package/dist/dts/transports/post-with-retry.d.ts.map +1 -1
- package/dist/dts/types/chat.types.d.ts +86 -2
- package/dist/dts/types/chat.types.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/transports/context-overflow-error.js +161 -0
- package/dist/esm/transports/post-with-retry.js +20 -4
- package/dist/foundation-ai.api.json +520 -2
- package/dist/foundation-ai.d.ts +147 -2
- package/package.json +10 -10
package/dist/dts/index.d.ts
CHANGED
|
@@ -9,13 +9,14 @@ export { BUDGETED_VENDORS, BudgetExhaustedError, DEFAULT_BUDGET_EXHAUSTED_MESSAG
|
|
|
9
9
|
export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini-transport';
|
|
10
10
|
export { DEFAULT_PROVIDER_REFUSED_MESSAGE, PROVIDER_REFUSED_CODE, ProviderRefusedError, } from './transports/provider-refused';
|
|
11
11
|
export type { ProviderRefusalKind } from './transports/provider-refused';
|
|
12
|
+
export { ContextOverflowError, contextOverflowOf, DEFAULT_CONTEXT_OVERFLOW_MESSAGE, } from './transports/context-overflow-error';
|
|
12
13
|
export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
|
|
13
14
|
export { ChatTemperature } from './utils/temperature';
|
|
14
15
|
export { ANTHROPIC_CACHE_READ_MULTIPLIER, ANTHROPIC_CACHE_WRITE_1H_MULTIPLIER, ANTHROPIC_CACHE_WRITE_5M_MULTIPLIER, anthropicRatesFor, anthropicTokenCost, GEMINI_CACHED_INPUT_MULTIPLIER, GEMINI_LONG_CONTEXT_THRESHOLD, geminiRatesFor, geminiTokenCost, } from './utils/token-cost';
|
|
15
16
|
export type { AnthropicUsageRecord, GeminiUsageRecord, TokenCost, TokenCostBreakdown, TokenRates, } from './utils/token-cost';
|
|
16
17
|
export { SUPPORTED_ANTHROPIC_MODEL_IDS, SUPPORTED_GEMINI_MODEL_IDS, vendorOfModel } from './types';
|
|
17
18
|
export type { AIConfig, AIStatus, AIProviderType, AnthropicAIConfig, AnthropicModelId, ChromeAIConfig, ChromeAvailability, GeminiAIConfig, GeminiModelId, ServerAIConfig, } from './types';
|
|
18
|
-
export type { AggregateUsage, AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatCostHistoryConfig, ChatDriverResult, ChatFallback, ChatImageAttachment, ChatInputDuringExecutionMode, CachePolicy, ChatMessage, ChatInteraction, ChatRequestOptions, ChatResponseMeta, ChatRole, ChatStreamChunk, ChatTextAttachment, ChatThinkingLevel, ChatThinkingPolicy, ChatToolCall, ChatToolCallUnknown, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, CondensePolicy, CondenseResult, CondenseTrigger, ChatSuggestionsConfig, InteractionPresentation, InteractionRequestOptions, InteractionResult, MessageCompaction, ModelTagAppearance, SubAgentFailureReason, SubAgentRequestOptions, TurnFailureReason, } from './types/chat.types';
|
|
19
|
+
export type { AggregateUsage, AgentPickerMode, ChatAgentConfig, ChatAgentPickerConfig, ChatAnimationsConfig, ChatAttachment, ChatConfig, ChatContextConfig, ChatCostHistoryConfig, ChatDriverResult, ChatFallback, ChatImageAttachment, ChatInputDuringExecutionMode, CachePolicy, ChatMessage, ChatInteraction, ChatRequestOptions, ChatResponseMeta, ChatRole, ChatStreamChunk, ChatTextAttachment, ChatThinkingLevel, ChatThinkingPolicy, ChatToolCall, ChatToolCallUnknown, ChatToolChoice, ChatToolDefinition, ChatToolHandlers, ChatToolResult, ChatUiConfig, CondensePolicy, CondenseResult, CondenseTrigger, ChatSuggestionsConfig, InteractionPresentation, InteractionRequestOptions, InteractionResult, MessageCompaction, ModelTagAppearance, SubAgentFailureReason, SubAgentRequestOptions, TurnFailureReason, } from './types/chat.types';
|
|
19
20
|
export { isChatToolCallUnknown } from './types/chat.types';
|
|
20
21
|
export type { ChatTransport } from './types/chat-transport.types';
|
|
21
22
|
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,gBAAgB,EAChB,8BAA8B,EAC9B,yBAAyB,EACzB,eAAe,GAChB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,6BAA6B,EAC7B,4BAA4B,GAC7B,MAAM,eAAe,CAAC;AAKvB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC9F,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,gCAAgC,EAChC,gBAAgB,EAChB,aAAa,EACb,iBAAiB,GAClB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAK5F,OAAO,EACL,gCAAgC,EAChC,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,+BAA+B,CAAC;AACvC,YAAY,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB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B,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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The REQUEST wall (GENC-1567) — the prompt itself being larger than the model
|
|
3
|
+
* will accept, as opposed to anything about the account.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT a third {@link ProviderRefusalKind}. That module's two kinds
|
|
6
|
+
* are both account-state failures, which is what lets them share one cause-free
|
|
7
|
+
* user message asserting the problem "isn't related to your account or your
|
|
8
|
+
* usage" and "needs no action from you". Every clause of that is false here: this
|
|
9
|
+
* IS about the user's own conversation, it IS their usage, and they are the only
|
|
10
|
+
* one who can fix it — by compacting. Folding it in would have made that sentence
|
|
11
|
+
* lie in exactly the case where clear advice matters most.
|
|
12
|
+
*
|
|
13
|
+
* Lives beside its siblings for the same structural reason: it is raised from
|
|
14
|
+
* `post-with-retry.ts`, which both transports import, so homing it in a transport
|
|
15
|
+
* would close an import cycle the repo's `circular` check rejects.
|
|
16
|
+
*
|
|
17
|
+
* ## Scope
|
|
18
|
+
*
|
|
19
|
+
* This is a **backstop**, not the primary defence. The assistant reserves
|
|
20
|
+
* headroom and stops a running tool loop at the edge of the window, so a
|
|
21
|
+
* well-configured host should rarely reach here. It matters for the cases that
|
|
22
|
+
* escape those: a provider reporting no context window (nothing to measure
|
|
23
|
+
* against, so the guard is inert), an estimate that ran under, or a single
|
|
24
|
+
* request that was already too large.
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
import type { AIProviderType } from '../types/config.types';
|
|
29
|
+
/**
|
|
30
|
+
* The single sentence shown to a user whose request overran the context window.
|
|
31
|
+
*
|
|
32
|
+
* Unlike {@link DEFAULT_PROVIDER_REFUSED_MESSAGE} this one deliberately DOES name
|
|
33
|
+
* a cause and an action, because both are true and both are the user's: they can
|
|
34
|
+
* see the conversation that caused it, and compacting fixes it. Telling them it
|
|
35
|
+
* "needs no action from you" would be the wrong advice as well as the wrong fact.
|
|
36
|
+
*
|
|
37
|
+
* @beta
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_CONTEXT_OVERFLOW_MESSAGE: string;
|
|
40
|
+
/**
|
|
41
|
+
* Thrown when the provider rejects a request because the prompt exceeds the
|
|
42
|
+
* model's context window.
|
|
43
|
+
*
|
|
44
|
+
* Terminal for the attempt in the same sense as its siblings — retrying the same
|
|
45
|
+
* request cannot clear it — but unlike them it is terminal only until the user
|
|
46
|
+
* acts. Compaction genuinely resolves it, which is why the copy says so.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
50
|
+
export declare class ContextOverflowError extends Error {
|
|
51
|
+
/** Vendor label of the transport that refused (e.g. `'Anthropic'`). */
|
|
52
|
+
readonly vendorLabel: string;
|
|
53
|
+
/** Prompt size the provider reported, when its message stated one. */
|
|
54
|
+
readonly promptTokens?: number;
|
|
55
|
+
/** Window size the provider reported, when its message stated one. */
|
|
56
|
+
readonly limitTokens?: number;
|
|
57
|
+
/** The provider's human-readable message, verbatim, for the log. Never shown to the user. */
|
|
58
|
+
readonly detail?: string;
|
|
59
|
+
constructor(
|
|
60
|
+
/** Vendor label of the transport that refused (e.g. `'Anthropic'`). */
|
|
61
|
+
vendorLabel: string,
|
|
62
|
+
/** Prompt size the provider reported, when its message stated one. */
|
|
63
|
+
promptTokens?: number,
|
|
64
|
+
/** Window size the provider reported, when its message stated one. */
|
|
65
|
+
limitTokens?: number,
|
|
66
|
+
/** The provider's human-readable message, verbatim, for the log. Never shown to the user. */
|
|
67
|
+
detail?: string);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Classify a rejection as a context overflow, returning the reported figures
|
|
71
|
+
* when the provider stated them, or `undefined` when it is something else.
|
|
72
|
+
*
|
|
73
|
+
* Vendor-agnostic, unlike `providerRefusalOf`: the failure is a property of
|
|
74
|
+
* the request rather than of a vendor's account model, both observed shapes are
|
|
75
|
+
* a `400` with a phrase, and — critically — a false positive here cannot break a
|
|
76
|
+
* retry ladder, so the caution that scopes the spend classifier to Anthropic does
|
|
77
|
+
* not apply.
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export declare function contextOverflowOf(_vendor: AIProviderType | undefined, status: number | undefined, payload: unknown): {
|
|
82
|
+
promptTokens?: number;
|
|
83
|
+
limitTokens?: number;
|
|
84
|
+
message?: string;
|
|
85
|
+
} | undefined;
|
|
86
|
+
//# sourceMappingURL=context-overflow-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-overflow-error.d.ts","sourceRoot":"","sources":["../../../src/transports/context-overflow-error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA6C5D;;;;;;;;;GASG;AACH,eAAO,MAAM,gCAAgC,QAEE,CAAC;AAEhD;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAE3C,uEAAuE;IACvE,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM;;IAPxB,uEAAuE;IAC9D,WAAW,EAAE,MAAM;IAC5B,sEAAsE;IAC7D,YAAY,CAAC,EAAE,MAAM;IAC9B,sEAAsE;IAC7D,WAAW,CAAC,EAAE,MAAM;IAC7B,6FAA6F;IACpF,MAAM,CAAC,EAAE,MAAM;CAU3B;AAwBD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,OAAO,EAAE,OAAO,GACf;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAY/E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-with-retry.d.ts","sourceRoot":"","sources":["../../../src/transports/post-with-retry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"post-with-retry.d.ts","sourceRoot":"","sources":["../../../src/transports/post-with-retry.ts"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,kBAAkB,CAAC;IAChC,uFAAuF;IACvF,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,YAAY,EAAE,MAAM,CAAC;IACrB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAID;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC,OAAO,CAAC,CAkSnF"}
|
|
@@ -696,7 +696,15 @@ export type SubAgentFailureReason = 'max_iterations' | 'malformed_tool_call' | '
|
|
|
696
696
|
* because the very next call hits the same wall. N batched sub-agent calls would otherwise cost N
|
|
697
697
|
* doomed children AND a doomed parent call.
|
|
698
698
|
*/
|
|
699
|
-
| 'provider_refused'
|
|
699
|
+
| 'provider_refused'
|
|
700
|
+
/**
|
|
701
|
+
* The sub-agent was stopped because continuing would have overrun the context
|
|
702
|
+
* window (GENC-1567). **Terminal for the PARENT turn too**, on the same
|
|
703
|
+
* reasoning as `budget_exhausted` and `provider_refused`: the parent shares the
|
|
704
|
+
* conversation whose size caused it, so calling the model again hits the same
|
|
705
|
+
* wall.
|
|
706
|
+
*/
|
|
707
|
+
| 'context_exhausted';
|
|
700
708
|
/**
|
|
701
709
|
* When a tool call's declared payload(s) become stale and should be condensed
|
|
702
710
|
* out of the to-model history. The kinds form a spectrum of widening staleness
|
|
@@ -1172,7 +1180,14 @@ export interface ChatFallback {
|
|
|
1172
1180
|
*
|
|
1173
1181
|
* @beta
|
|
1174
1182
|
*/
|
|
1175
|
-
export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated' | 'refusal' | 'budget-exhausted' | 'provider-refused'
|
|
1183
|
+
export type TurnFailureReason = 'exception' | 'malformed-function-call' | 'empty-response' | 'unknown-tool-limit' | 'max-iterations' | 'response-truncated' | 'refusal' | 'budget-exhausted' | 'provider-refused'
|
|
1184
|
+
/**
|
|
1185
|
+
* The turn was stopped because continuing it would have overrun the model's
|
|
1186
|
+
* context window (GENC-1567). Pre-emptive: the driver ends the tool loop at
|
|
1187
|
+
* the edge rather than issuing a request the provider would reject, so the
|
|
1188
|
+
* transcript stays intact and compaction is still possible.
|
|
1189
|
+
*/
|
|
1190
|
+
| 'context-exhausted';
|
|
1176
1191
|
/**
|
|
1177
1192
|
* The result returned by a driver after processing a user turn.
|
|
1178
1193
|
*
|
|
@@ -1554,6 +1569,8 @@ export interface ChatCostHistoryConfig {
|
|
|
1554
1569
|
export interface ChatConfig {
|
|
1555
1570
|
/** UI display settings — toggles, file upload, animations, etc. */
|
|
1556
1571
|
ui?: ChatUiConfig;
|
|
1572
|
+
/** Context-window headroom and the compaction gate. */
|
|
1573
|
+
context?: ChatContextConfig;
|
|
1557
1574
|
/** Cost tab display and opt-in build-history persistence. */
|
|
1558
1575
|
costHistory?: ChatCostHistoryConfig;
|
|
1559
1576
|
/** Agent engine settings — iteration limits, handoff caps, classifier tuning. */
|
|
@@ -1563,6 +1580,73 @@ export interface ChatConfig {
|
|
|
1563
1580
|
/** Agent picker configuration — mode + optional default pin. */
|
|
1564
1581
|
picker?: ChatAgentPickerConfig;
|
|
1565
1582
|
}
|
|
1583
|
+
/**
|
|
1584
|
+
* Context-window management for the chat assistant (GENC-1567).
|
|
1585
|
+
*
|
|
1586
|
+
* The assistant reserves headroom rather than letting the conversation run to
|
|
1587
|
+
* the edge of the model's window and compacting automatically at the last
|
|
1588
|
+
* moment. The reason is that a turn is not atomic in cost: a send allowed just
|
|
1589
|
+
* under a threshold can run a long tool loop and add a large amount on its own,
|
|
1590
|
+
* so a threshold set as a fraction of the window bounds only the size at the
|
|
1591
|
+
* START of a turn. What has to be bounded is the growth of one whole turn — and
|
|
1592
|
+
* that is a number of tokens, not a percentage.
|
|
1593
|
+
*
|
|
1594
|
+
* It is also why compaction here is user-initiated rather than automatic:
|
|
1595
|
+
* machine state for a stateful flow lives outside the transcript, so rewriting
|
|
1596
|
+
* the transcript underneath a mid-flow agent is a judgement the user should
|
|
1597
|
+
* make, at a moment of their choosing, rather than something that happens to
|
|
1598
|
+
* them mid-journey.
|
|
1599
|
+
*
|
|
1600
|
+
* @beta
|
|
1601
|
+
*/
|
|
1602
|
+
export interface ChatContextConfig {
|
|
1603
|
+
/**
|
|
1604
|
+
* Whether the context gate is active at all.
|
|
1605
|
+
* - `true` or `undefined` (default) — warn, then block, as the window fills
|
|
1606
|
+
* - `false` — no warning and no block; the context indicator still shows
|
|
1607
|
+
*
|
|
1608
|
+
* An escape hatch for a host that would rather take the provider error than
|
|
1609
|
+
* ever have its composer disabled.
|
|
1610
|
+
*/
|
|
1611
|
+
enabled?: boolean;
|
|
1612
|
+
/**
|
|
1613
|
+
* Tokens kept free for a single turn to complete in. The assistant blocks new
|
|
1614
|
+
* sends once the conversation would leave less than this much headroom.
|
|
1615
|
+
*
|
|
1616
|
+
* Deliberately a token count and not a percentage of the window: the reserve
|
|
1617
|
+
* needs to cover the worst-case growth of one agentic turn, which does not
|
|
1618
|
+
* scale with the model's context size. A percentage gives a 1M-token model a
|
|
1619
|
+
* reserve far larger than any turn needs while potentially starving a
|
|
1620
|
+
* 200k-token one. Default: `25000`.
|
|
1621
|
+
*/
|
|
1622
|
+
reserveTokens?: number;
|
|
1623
|
+
/**
|
|
1624
|
+
* How many reserves ahead of the block the warning appears, as a multiple of
|
|
1625
|
+
* {@link ChatContextConfig.reserveTokens}. At the default `2` the warning
|
|
1626
|
+
* arrives one full reserve before the block, leaving room to compact at a
|
|
1627
|
+
* convenient moment rather than at the wall. Default: `2`.
|
|
1628
|
+
*/
|
|
1629
|
+
warnMultiplier?: number;
|
|
1630
|
+
/**
|
|
1631
|
+
* Context window to assume when the active provider reports none.
|
|
1632
|
+
*
|
|
1633
|
+
* Without a limit there is no percentage and so no gate, which is the right
|
|
1634
|
+
* default — guessing a window and blocking against the guess would be worse
|
|
1635
|
+
* than not blocking. Set this when you know the window but your provider
|
|
1636
|
+
* does not report it.
|
|
1637
|
+
*/
|
|
1638
|
+
fallbackContextLimit?: number;
|
|
1639
|
+
/**
|
|
1640
|
+
* Smallest reclaim, in tokens, for compaction to be worth running and to be
|
|
1641
|
+
* offered as the way past a block.
|
|
1642
|
+
*
|
|
1643
|
+
* A compaction spends a summarizer call on most of the conversation, so a
|
|
1644
|
+
* plan that frees less than this costs more than it buys — and, when the
|
|
1645
|
+
* composer is blocked, would be an escape that does not actually clear the
|
|
1646
|
+
* block. Default: `5000`.
|
|
1647
|
+
*/
|
|
1648
|
+
minReclaimTokens?: number;
|
|
1649
|
+
}
|
|
1566
1650
|
/**
|
|
1567
1651
|
* Configuration for the chat suggestions feature.
|
|
1568
1652
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.types.d.ts","sourceRoot":"","sources":["../../../src/types/chat.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,MAAM,GACN,cAAc,GACd,gBAAgB,GAChB,mBAAmB,CAAC;AAExB;;;;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,GAAG,mBAAmB,CAAC;AAElE;;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W,iBAAiB;IAChC;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;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
|
@@ -14,6 +14,7 @@ export { GeminiTransport, MalformedFunctionCallError } from './transports/gemini
|
|
|
14
14
|
// SAME sentence as the browser driver: the copy is provisional and a second copy would drift on the
|
|
15
15
|
// first reword.
|
|
16
16
|
export { DEFAULT_PROVIDER_REFUSED_MESSAGE, PROVIDER_REFUSED_CODE, ProviderRefusedError, } from './transports/provider-refused';
|
|
17
|
+
export { ContextOverflowError, contextOverflowOf, DEFAULT_CONTEXT_OVERFLOW_MESSAGE, } from './transports/context-overflow-error';
|
|
17
18
|
export { AI_FEATURE_FLAG, isAIFeatureEnabled } from './utils/feature-flags';
|
|
18
19
|
export { ChatTemperature } from './utils/temperature';
|
|
19
20
|
// Request pricing. Exported so a host that prices its own calls — a server proxy, a usage ledger,
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The REQUEST wall (GENC-1567) — the prompt itself being larger than the model
|
|
3
|
+
* will accept, as opposed to anything about the account.
|
|
4
|
+
*
|
|
5
|
+
* Deliberately NOT a third {@link ProviderRefusalKind}. That module's two kinds
|
|
6
|
+
* are both account-state failures, which is what lets them share one cause-free
|
|
7
|
+
* user message asserting the problem "isn't related to your account or your
|
|
8
|
+
* usage" and "needs no action from you". Every clause of that is false here: this
|
|
9
|
+
* IS about the user's own conversation, it IS their usage, and they are the only
|
|
10
|
+
* one who can fix it — by compacting. Folding it in would have made that sentence
|
|
11
|
+
* lie in exactly the case where clear advice matters most.
|
|
12
|
+
*
|
|
13
|
+
* Lives beside its siblings for the same structural reason: it is raised from
|
|
14
|
+
* `post-with-retry.ts`, which both transports import, so homing it in a transport
|
|
15
|
+
* would close an import cycle the repo's `circular` check rejects.
|
|
16
|
+
*
|
|
17
|
+
* ## Scope
|
|
18
|
+
*
|
|
19
|
+
* This is a **backstop**, not the primary defence. The assistant reserves
|
|
20
|
+
* headroom and stops a running tool loop at the edge of the window, so a
|
|
21
|
+
* well-configured host should rarely reach here. It matters for the cases that
|
|
22
|
+
* escape those: a provider reporting no context window (nothing to measure
|
|
23
|
+
* against, so the guard is inert), an estimate that ran under, or a single
|
|
24
|
+
* request that was already too large.
|
|
25
|
+
*
|
|
26
|
+
* @packageDocumentation
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Phrases identifying a context-overflow inside a vendor's generic
|
|
30
|
+
* invalid-request bucket.
|
|
31
|
+
*
|
|
32
|
+
* Prose matching, for the same reason `ANTHROPIC_SPEND_PHRASES` resorts to it:
|
|
33
|
+
* neither vendor gives this family its own `error.type`. Unlike that list,
|
|
34
|
+
* though, the blast radius of a false positive here is small — the user is told
|
|
35
|
+
* their conversation is too long and offered compaction, rather than having
|
|
36
|
+
* their composer locked and being sent to an administrator.
|
|
37
|
+
*
|
|
38
|
+
* **Only ever consulted on a 400.** That is what keeps this away from the retry
|
|
39
|
+
* ladder: `400` is absent from every `RETRYABLE_STATUSES`, so a phrase matching
|
|
40
|
+
* here can never convert a retryable failure into a terminal one — the inverse
|
|
41
|
+
* of the hazard that keeps Gemini out of the spend classifier.
|
|
42
|
+
*
|
|
43
|
+
* Documented shapes, not captures. Anthropic returns `prompt is too long:
|
|
44
|
+
* N tokens > M maximum`; Gemini returns `The input token count (N) exceeds the
|
|
45
|
+
* maximum number of tokens allowed (M)`; OpenAI-compatible endpoints use the
|
|
46
|
+
* structural code `context_length_exceeded`, handled separately below. Revisit
|
|
47
|
+
* against a real capture when one is available.
|
|
48
|
+
*/
|
|
49
|
+
const CONTEXT_OVERFLOW_PHRASES = Object.freeze([
|
|
50
|
+
/prompt is too long/i,
|
|
51
|
+
/input token count .* exceeds/i,
|
|
52
|
+
/maximum context length/i,
|
|
53
|
+
/context[_ ]length[_ ]exceeded/i,
|
|
54
|
+
/too many (input )?tokens/i,
|
|
55
|
+
]);
|
|
56
|
+
/**
|
|
57
|
+
* Pulls the reported figures out of a message, when it states them.
|
|
58
|
+
*
|
|
59
|
+
* Both documented forms put arbitrary non-digit text between the two numbers and
|
|
60
|
+
* the comparison — Anthropic's `215534 tokens > 200000 maximum`, Gemini's
|
|
61
|
+
* `(1100000) exceeds the maximum number of tokens allowed (1048576)` — so the
|
|
62
|
+
* separators are bounded non-digit runs rather than fixed words. Bounded, not
|
|
63
|
+
* open-ended, so a pathological message cannot make this backtrack expensively.
|
|
64
|
+
*/
|
|
65
|
+
const TOKEN_FIGURES = /(\d[\d,]{2,})\D{0,40}?(?:>|exceeds)\D{0,80}?(\d[\d,]{2,})/i;
|
|
66
|
+
/** HTTP status a context overflow arrives as. Never a retryable status — see above. */
|
|
67
|
+
const OVERFLOW_STATUS = 400;
|
|
68
|
+
/**
|
|
69
|
+
* The single sentence shown to a user whose request overran the context window.
|
|
70
|
+
*
|
|
71
|
+
* Unlike {@link DEFAULT_PROVIDER_REFUSED_MESSAGE} this one deliberately DOES name
|
|
72
|
+
* a cause and an action, because both are true and both are the user's: they can
|
|
73
|
+
* see the conversation that caused it, and compacting fixes it. Telling them it
|
|
74
|
+
* "needs no action from you" would be the wrong advice as well as the wrong fact.
|
|
75
|
+
*
|
|
76
|
+
* @beta
|
|
77
|
+
*/
|
|
78
|
+
export const DEFAULT_CONTEXT_OVERFLOW_MESSAGE = 'This conversation has grown larger than the model can accept in one request. ' +
|
|
79
|
+
'Compact it to free up room, then try again.';
|
|
80
|
+
/**
|
|
81
|
+
* Thrown when the provider rejects a request because the prompt exceeds the
|
|
82
|
+
* model's context window.
|
|
83
|
+
*
|
|
84
|
+
* Terminal for the attempt in the same sense as its siblings — retrying the same
|
|
85
|
+
* request cannot clear it — but unlike them it is terminal only until the user
|
|
86
|
+
* acts. Compaction genuinely resolves it, which is why the copy says so.
|
|
87
|
+
*
|
|
88
|
+
* @beta
|
|
89
|
+
*/
|
|
90
|
+
export class ContextOverflowError extends Error {
|
|
91
|
+
constructor(
|
|
92
|
+
/** Vendor label of the transport that refused (e.g. `'Anthropic'`). */
|
|
93
|
+
vendorLabel,
|
|
94
|
+
/** Prompt size the provider reported, when its message stated one. */
|
|
95
|
+
promptTokens,
|
|
96
|
+
/** Window size the provider reported, when its message stated one. */
|
|
97
|
+
limitTokens,
|
|
98
|
+
/** The provider's human-readable message, verbatim, for the log. Never shown to the user. */
|
|
99
|
+
detail) {
|
|
100
|
+
super(`${vendorLabel} rejected the request — the prompt exceeds the model context window` +
|
|
101
|
+
(promptTokens != null && limitTokens != null ? ` (${promptTokens} > ${limitTokens})` : '') +
|
|
102
|
+
(detail ? `: ${detail}` : '') +
|
|
103
|
+
'. Retrying will not clear this — the conversation must be compacted.');
|
|
104
|
+
this.vendorLabel = vendorLabel;
|
|
105
|
+
this.promptTokens = promptTokens;
|
|
106
|
+
this.limitTokens = limitTokens;
|
|
107
|
+
this.detail = detail;
|
|
108
|
+
this.name = 'ContextOverflowError';
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* How deep to walk an error envelope looking for the provider's message. The two
|
|
113
|
+
* wire shapes nest it at most three levels down (`details.error.message`), so
|
|
114
|
+
* this is one level of tolerance rather than an open-ended crawl.
|
|
115
|
+
*/
|
|
116
|
+
const MAX_ENVELOPE_DEPTH = 4;
|
|
117
|
+
/** Any string field on an error envelope that might carry the provider's message. */
|
|
118
|
+
function messagesIn(payload) {
|
|
119
|
+
if (!payload || typeof payload !== 'object')
|
|
120
|
+
return [];
|
|
121
|
+
const found = [];
|
|
122
|
+
const visit = (node, depth) => {
|
|
123
|
+
if (depth > MAX_ENVELOPE_DEPTH || !node || typeof node !== 'object')
|
|
124
|
+
return;
|
|
125
|
+
for (const value of Object.values(node)) {
|
|
126
|
+
if (typeof value === 'string')
|
|
127
|
+
found.push(value);
|
|
128
|
+
else if (typeof value === 'object')
|
|
129
|
+
visit(value, depth + 1);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
visit(payload, 0);
|
|
133
|
+
return found;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Classify a rejection as a context overflow, returning the reported figures
|
|
137
|
+
* when the provider stated them, or `undefined` when it is something else.
|
|
138
|
+
*
|
|
139
|
+
* Vendor-agnostic, unlike `providerRefusalOf`: the failure is a property of
|
|
140
|
+
* the request rather than of a vendor's account model, both observed shapes are
|
|
141
|
+
* a `400` with a phrase, and — critically — a false positive here cannot break a
|
|
142
|
+
* retry ladder, so the caution that scopes the spend classifier to Anthropic does
|
|
143
|
+
* not apply.
|
|
144
|
+
*
|
|
145
|
+
* @beta
|
|
146
|
+
*/
|
|
147
|
+
export function contextOverflowOf(_vendor, status, payload) {
|
|
148
|
+
if (status !== OVERFLOW_STATUS)
|
|
149
|
+
return undefined;
|
|
150
|
+
for (const message of messagesIn(payload)) {
|
|
151
|
+
if (!CONTEXT_OVERFLOW_PHRASES.some((phrase) => phrase.test(message)))
|
|
152
|
+
continue;
|
|
153
|
+
const figures = TOKEN_FIGURES.exec(message);
|
|
154
|
+
return {
|
|
155
|
+
promptTokens: figures ? Number(figures[1].replace(/,/g, '')) : undefined,
|
|
156
|
+
limitTokens: figures ? Number(figures[2].replace(/,/g, '')) : undefined,
|
|
157
|
+
message,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
@@ -4,6 +4,7 @@ import { abortableDelay } from '../utils/abortable-delay';
|
|
|
4
4
|
import { combineSignals } from '../utils/combine-signals';
|
|
5
5
|
import { logger } from '../utils/logger';
|
|
6
6
|
import { budgetExhaustedFrom, codeOf, isBudgetRejection, parseJsonOrUndefined, } from './budget-exhausted-error';
|
|
7
|
+
import { ContextOverflowError, contextOverflowOf } from './context-overflow-error';
|
|
7
8
|
import { readFramedBody } from './ndjson-frames';
|
|
8
9
|
import { providerRefusalOf, providerRefusedFrom, vendorOfTransportLabel } from './provider-refused';
|
|
9
10
|
import { MAX_TOTAL_SERVER_REQUESTED_BACKOFF_MS, resolveBackoffMs, retryAfterMs, retryInfoMs, serverBackoffSpentMs, shouldNotRetry, } from './retry-hints';
|
|
@@ -18,7 +19,7 @@ const MAX_RETRIES = 5;
|
|
|
18
19
|
*/
|
|
19
20
|
export function postWithRetry(options) {
|
|
20
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
23
|
const { url, headers, body, credentials, vendorLabel, retryableStatuses, timeout, stallTimeout, backoffBaseMs, signal, } = options;
|
|
23
24
|
// The vendor behind this transport's label, resolved once — the refusal classifier dispatches on
|
|
24
25
|
// it, and it is the only vendor knowledge this envelope needs (GENC-1506).
|
|
@@ -140,6 +141,17 @@ export function postWithRetry(options) {
|
|
|
140
141
|
if (refusal) {
|
|
141
142
|
throw providerRefusedFrom(vendorLabel, refusal, response.status, parsed, errText || undefined);
|
|
142
143
|
}
|
|
144
|
+
// The REQUEST wall (GENC-1567), classified after the account walls above
|
|
145
|
+
// and before the ladder. Order against them does not actually matter —
|
|
146
|
+
// the signals are disjoint — but it is checked before the ladder for the
|
|
147
|
+
// same reason they are: a 400 is not retryable today, and a proxy that
|
|
148
|
+
// remapped it onto one would otherwise cost a full backoff cycle before
|
|
149
|
+
// an opaque error. Gated on the 400 status inside `contextOverflowOf`, so
|
|
150
|
+
// this can never reclassify a genuinely retryable failure.
|
|
151
|
+
const overflow = contextOverflowOf(vendor, response.status, parsed);
|
|
152
|
+
if (overflow) {
|
|
153
|
+
throw new ContextOverflowError(vendorLabel, overflow.promptTokens, overflow.limitTokens, (_d = overflow.message) !== null && _d !== void 0 ? _d : (errText || undefined));
|
|
154
|
+
}
|
|
143
155
|
// The budget wall (GENC-1464) wins over ANY status-based retry — the same
|
|
144
156
|
// rule the framed branch below applies, now symmetric. It must be
|
|
145
157
|
// classified BEFORE the ladder, not after it: 402 is absent from every
|
|
@@ -170,7 +182,7 @@ export function postWithRetry(options) {
|
|
|
170
182
|
// The proxy streams NDJSON heartbeat frames when it supports them; an old
|
|
171
183
|
// proxy ignores our Accept header and returns plain JSON, so branch on
|
|
172
184
|
// what actually came back.
|
|
173
|
-
if (((
|
|
185
|
+
if (((_f = (_e = response.headers) === null || _e === void 0 ? void 0 : _e.get('content-type')) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes('application/x-ndjson')) &&
|
|
174
186
|
response.body) {
|
|
175
187
|
rearmStallTimer();
|
|
176
188
|
const frame = yield readFramedBody(response.body, rearmStallTimer, vendorLabel, stallTimeout);
|
|
@@ -182,7 +194,7 @@ export function postWithRetry(options) {
|
|
|
182
194
|
if (frame.code === 'UPSTREAM_STALLED') {
|
|
183
195
|
// The proxy watchdog saw no upstream data — same tagged shape as a
|
|
184
196
|
// local stall, so the driver's TimeoutError branch handles both.
|
|
185
|
-
throw new DOMException(`${vendorLabel} request stalled: ${(
|
|
197
|
+
throw new DOMException(`${vendorLabel} request stalled: ${(_g = frame.error) !== null && _g !== void 0 ? _g : 'no upstream data'}`, 'TimeoutError');
|
|
186
198
|
}
|
|
187
199
|
// The budget wall, framed (GENC-1464) — the in-band twin of the 402 above,
|
|
188
200
|
// through the same predicate, keyed on status OR code. Classified before
|
|
@@ -200,6 +212,10 @@ export function postWithRetry(options) {
|
|
|
200
212
|
if (framedRefusal) {
|
|
201
213
|
throw providerRefusedFrom(vendorLabel, framedRefusal, frame.status, frame, frame.error);
|
|
202
214
|
}
|
|
215
|
+
const framedOverflow = contextOverflowOf(vendor, frame.status, frame);
|
|
216
|
+
if (framedOverflow) {
|
|
217
|
+
throw new ContextOverflowError(vendorLabel, framedOverflow.promptTokens, framedOverflow.limitTokens, (_h = framedOverflow.message) !== null && _h !== void 0 ? _h : frame.error);
|
|
218
|
+
}
|
|
203
219
|
if (isBudgetRejection(frame.status, frame.code)) {
|
|
204
220
|
throw budgetExhaustedFrom(vendorLabel, frame);
|
|
205
221
|
}
|
|
@@ -213,7 +229,7 @@ export function postWithRetry(options) {
|
|
|
213
229
|
yield backoff(attempt, retryInfoMs(frame));
|
|
214
230
|
continue;
|
|
215
231
|
}
|
|
216
|
-
throw new Error(`${vendorLabel} request error ${frame.status}: ${(
|
|
232
|
+
throw new Error(`${vendorLabel} request error ${frame.status}: ${(_j = frame.error) !== null && _j !== void 0 ? _j : JSON.stringify(frame.details)}`);
|
|
217
233
|
}
|
|
218
234
|
return (yield response.json());
|
|
219
235
|
}
|