@theoremjs/agents 0.3.5-next.906.g6f050f4 → 0.3.5-next.907.g49f9ef9

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.
Files changed (35) hide show
  1. package/README.md +2 -2
  2. package/esm/mod.d.ts +1 -1
  3. package/esm/mod.js +1 -1
  4. package/esm/src/guardrails/sanitize.js +1 -1
  5. package/esm/src/interface/history.js +2 -2
  6. package/esm/src/kernel/auth/types.d.ts +2 -2
  7. package/esm/src/kernel/engine/runner/steps.js +0 -5
  8. package/esm/src/kernel/engine/usage.d.ts +1 -1
  9. package/esm/src/kernel/engine/usage.js +1 -1
  10. package/esm/src/kernel/field-docs.js +1 -1
  11. package/esm/src/kernel/interaction-parts.d.ts +0 -2
  12. package/esm/src/kernel/interaction-parts.js +0 -10
  13. package/esm/src/kernel/mod.d.ts +3 -3
  14. package/esm/src/kernel/mod.js +3 -3
  15. package/esm/src/kernel/schema.d.ts +2 -12
  16. package/esm/src/kernel/schema.js +2 -8
  17. package/esm/src/kernel/stop.d.ts +0 -4
  18. package/esm/src/kernel/stop.js +0 -50
  19. package/esm/src/kernel/turn-events.d.ts +8 -10
  20. package/esm/src/kernel/types.d.ts +7 -22
  21. package/esm/src/observability/trace-catalog.js +6 -9
  22. package/esm/src/providers/built-in.d.ts +2 -0
  23. package/esm/src/providers/built-in.js +11 -0
  24. package/esm/src/providers/google/interactions/framing.d.ts +1 -0
  25. package/esm/src/providers/google/interactions/framing.js +9 -2
  26. package/esm/src/providers/google/interactions/status.d.ts +3 -0
  27. package/esm/src/providers/google/interactions/status.js +23 -0
  28. package/esm/src/providers/google/interactions/steps.js +1 -1
  29. package/esm/src/providers/open-ai/finish-reason.d.ts +3 -0
  30. package/esm/src/providers/open-ai/finish-reason.js +27 -0
  31. package/esm/src/providers/open-ai/protocol.js +1 -1
  32. package/esm/src/providers/openrouter/images-protocol.js +1 -1
  33. package/esm/src/providers/openrouter/protocol.d.ts +20 -1
  34. package/esm/src/providers/openrouter/protocol.js +4 -1
  35. package/package.json +1 -1
package/README.md CHANGED
@@ -460,13 +460,13 @@ Named exports from the root barrel (same symbols hosts get from `@theoremjs/agen
460
460
  | Runner | `runTurn`, `runSession`, `runDecision`, `runEmbedding`, `validateDecisionRequest`, `RunSessionOptions`, `SignInGatePolicy`, `LiveLines`, `LiveLine`, `LiveLineRole`, `RunDecisionOptions`, `DecisionError`, `prepareLiveInboundText`, `liveIngressEnabled`, `liveIngressEnabledFromSpec`, `liveIngressChannelDefault`, `hasAnyLiveIngress`, `assertLiveIngress`, `assertLiveIngressConfigured`, `LiveIngressChannel` |
461
461
  | Attachments | `attachmentIssues`, `attachmentIssueCopy`, `attachmentIssueText`, `attachmentsRefused`, `assertTurnAttachments`, `base64Bytes`, `maxBytesForMime`, `requireMediaLimits`, `resolveMediaLimits`, `sanitizeCsvText`, `sanitizeTurnBlobs`, `embeddingMediaIssues`, `embeddingRules`, `AttachmentFacts`, `AttachmentRules`, `EmbeddingRules` |
462
462
  | Catalog | `clampThinkingLevel`, `clampThinkingLevelForApiId`, `mediaChannelForMime`, `MediaInputChannel`, `mediaKindForMime`, `mimeAllowed`, `mimeEssence`, `modelEntryByApiId`, `requireModelBinding` |
463
- | Schema | `PROFILE_FIELDS`, `PROFILE_GRAPH`, `PROFILE_TYPES`, `PROFILE_ID_MAX_CHARS`, `PROFILE_HANDLE_MAX_CHARS`, `EXTRA_FIELDS`, `REQUEST_FIELDS`, `API_EXPORTS`, `fieldMeta`, `catalogPathFor`, `DYNAMIC_FIELD_PARENTS`, `spineFacetsForProfileType`, `profileGraphFacet`, `ProfileGraphFacet`, `ProfileGraphFacetId`, `ProfileGraphEditor`, `ProfileGraphRole`, `THINKING_LEVELS`, `KEY_SLOT_NAME`, `isKeySlotName`, `MEDIA_INPUT_KINDS`, `MEDIA_INPUT_KIND_VALUES`, `MEDIA_WILDCARDS`, `ATTACHMENT_ACCEPT_MIMES`, `IMAGE_ATTACHMENT_ACCEPT_MIMES`, `VOICE_ACCEPT_MIMES`, `SUMMARY_MODES`, `STREAM_MODES`, `SPEECH_AUDIO_FORMATS`, `COMPACTION_METERS`, `COMPACTION_OUTCOMES`, `COMPACTION_TIMINGS`, `CACHE_MODES`, `CACHE_TTLS`, `TURN_STAGES`, `TURN_INJECT_STAGES`, `TURN_STOP_KINDS`, `CONTINUE_STOP_KINDS`, `TOOL_GATE_KINDS`, `AWAITING_USER_INPUT_KINDS`, `AWAITING_USER_INPUT_STATUS`, `TOOL_LOAD_TIERS`, `TOOL_ACCESS`, `TOOL_PERMISSION`, `TOOL_TYPES`, `AUTH_UNAUTHENTICATED_POLICIES`, `HTTP_METHODS`, `STUDIO_AUTH_TYPES`, `TOOL_AUTH_TYPES`, `AuthUnauthenticatedPolicy`, `CustomToolType`, `HttpMethod`, `StudioAuthType`, `ToolAccess`, `ToolAuthType`, `ToolPermission`, `ToolType`, `LIVE_ACTIVITY_HANDLINGS`, `LIVE_START_SENSITIVITIES`, `LIVE_END_SENSITIVITIES` |
463
+ | Schema | `PROFILE_FIELDS`, `PROFILE_GRAPH`, `PROFILE_TYPES`, `PROFILE_ID_MAX_CHARS`, `PROFILE_HANDLE_MAX_CHARS`, `EXTRA_FIELDS`, `REQUEST_FIELDS`, `API_EXPORTS`, `fieldMeta`, `catalogPathFor`, `DYNAMIC_FIELD_PARENTS`, `spineFacetsForProfileType`, `profileGraphFacet`, `ProfileGraphFacet`, `ProfileGraphFacetId`, `ProfileGraphEditor`, `ProfileGraphRole`, `THINKING_LEVELS`, `KEY_SLOT_NAME`, `isKeySlotName`, `MEDIA_INPUT_KINDS`, `MEDIA_INPUT_KIND_VALUES`, `MEDIA_WILDCARDS`, `ATTACHMENT_ACCEPT_MIMES`, `IMAGE_ATTACHMENT_ACCEPT_MIMES`, `VOICE_ACCEPT_MIMES`, `SUMMARY_MODES`, `STREAM_MODES`, `SPEECH_AUDIO_FORMATS`, `COMPACTION_METERS`, `COMPACTION_OUTCOMES`, `COMPACTION_TIMINGS`, `TURN_STAGES`, `TURN_INJECT_STAGES`, `TURN_STOP_KINDS`, `CONTINUE_STOP_KINDS`, `TOOL_GATE_KINDS`, `AWAITING_USER_INPUT_KINDS`, `AWAITING_USER_INPUT_STATUS`, `TOOL_LOAD_TIERS`, `TOOL_ACCESS`, `TOOL_PERMISSION`, `TOOL_TYPES`, `AUTH_UNAUTHENTICATED_POLICIES`, `HTTP_METHODS`, `STUDIO_AUTH_TYPES`, `TOOL_AUTH_TYPES`, `AuthUnauthenticatedPolicy`, `CustomToolType`, `HttpMethod`, `StudioAuthType`, `ToolAccess`, `ToolAuthType`, `ToolPermission`, `ToolType`, `LIVE_ACTIVITY_HANDLINGS`, `LIVE_START_SENSITIVITIES`, `LIVE_END_SENSITIVITIES` |
464
464
  | Scope | `KernelScope`, `createKernelScope`, `defaultKernelScope`, `KernelRegistry`, `createKernelRegistry` |
465
465
  | Profiles | `ProfileDefinition`, `ProfileDefinitionBase`, `TextProfileDefinition`, `ImageProfileDefinition`, `SpeechProfileDefinition`, `TranscriptionProfileDefinition`, `LiveProfileDefinition`, `HostProfileDefinition`, `DecisionProfileDefinition`, `EmbeddingProfileDefinition`, `ProfileRegistry`, `createProfileRegistry`, `clearProfiles`, `defineProfile`, `getProfile`, `hasProfile`, `listProfiles`, `registerProfile`, `registerProfiles`, `projectProfile`, `resolveTurn`, `pickModel`, `resolveTurnSystemPrompt`, `systemLinesProblem` |
466
466
  | Tools | `ToolContext`, `GateReference`, `gateReferenceSchema`, `ToolRegistry`, `assertToolSettings`, `createToolRegistry`, `registerTool`, `registerTools`, `invokeTool`, `invokeToolStep`, `runTool`, `runToolStep`, `SettledToolCall`, `ToolCallResult`, `ToolStepCallResult`, `GATE_DECISIONS`, `GateDecision`, `askUserTool`, `registerHarnessTools`, `getTool`, `hasTool`, `requireTool`, `listTools`, `resetTools`, `formatToolResult`, `prepareTurnToolSnapshot`, `buildHttpToolTarget`, `executeHttpTool`, `executeMcpTool`, `parseMcpRpcResponse`, `isUnsupportedMcpProtocolError`, `MCP_PROTOCOL_VERSIONS`, `mcpRequestMeta`, `McpProtocolVersion`, `resolveToolAuth`, `credentialPlacement`, `withCredentialQuery`, `CredentialQuery`, `uncheckedOutput`, `UncheckedOutput`, `McpRpcResponse`, `ModelToolResult`, `PageAnswer` |
467
467
  | Tool execution | `ToolBackground`, `ToolBackgroundCall`, `ToolBackgroundHandle`, `ToolBackgroundService`, `ToolBackgroundSettled`, `ToolSteerReceipt`, `ToolSteerRefusal`, `ToolOperationReply`, `toolOperationReplySchema`, `BackgroundToolEvent`, `ToolExecutionCoordinator`, `createMemoryToolExecution`, `MemoryToolExecutionOptions`, `authorizeToolReplay`, `BeginToolOperationResult`, `ToolOperationClaim`, `ToolOperationIdentity`, `ToolOperationOutcome`, `ToolOperationUncertainty`, `toolOperationOutcomeSchema`, `SavedToolInvocation`, `savedToolInvocationSchema`, `toolInvocationHash`, `TerminalToolEvent`, `PageToolDispatch`, `PageToolExecution` |
468
468
  | Structured | `SchemaRegistry`, `createSchemaRegistry`, `getStructured`, `registerStructured` |
469
- | Stop / resume | `ProfileTurnBehaviourSpec`, `MediaTurnBehaviourSpec`, `ProfileTurnResumptionSpec`, `TurnContinueFrom`, `TurnStop`, `TurnStopKind`, `ContinueStopKind`, `StepLimitMode`, `CONTINUE_STOP_KINDS`, `AUTO_CONTINUE_DELAY_MS`, `DEFAULT_ALLOW_CONTINUE`, `DEFAULT_AUTO_CONTINUE`, `GenerationStopError`, `isContinueStopKind`, `isGenerationStopError`, `isResumeableStop`, `isUserCancelledStop`, `profileAllowsSteering`, `profileAllowsInject`, `profileTurnResumption`, `shouldAutoContinue`, `turnStopFromClientStreamEnd`, `turnStopFromInteractionStatus`, `turnStopFromOpenAiFinishReason` |
469
+ | Stop / resume | `ProfileTurnBehaviourSpec`, `MediaTurnBehaviourSpec`, `ProfileTurnResumptionSpec`, `TurnContinueFrom`, `TurnStop`, `TurnStopKind`, `ContinueStopKind`, `StepLimitMode`, `CONTINUE_STOP_KINDS`, `AUTO_CONTINUE_DELAY_MS`, `DEFAULT_ALLOW_CONTINUE`, `DEFAULT_AUTO_CONTINUE`, `GenerationStopError`, `isContinueStopKind`, `isGenerationStopError`, `isResumeableStop`, `isUserCancelledStop`, `profileAllowsSteering`, `profileAllowsInject`, `profileTurnResumption`, `shouldAutoContinue`, `turnStopFromClientStreamEnd` |
470
470
  | Stages (target foundation) | `TURN_STAGES`, `TURN_INJECT_STAGES`, `STAGE_AFFORDANCES`, `STAGE_AFFORDANCE_MATRIX`, `TOOL_GATE_KINDS`, `AWAITING_USER_INPUT_KINDS`, `AWAITING_USER_INPUT_STATUS`, `applyStageResult`, `awaitingUserInputSchema`, `toolGateSchema`, `isTurnStage`, `isTurnInjectStage`, `isToolGateKind`, `isAwaitingUserInput`, `stageAllowsAffordance`, `stageEventFields`, `profileAllowsInject`, `StageAffordance`, `StageContext`, `StageResult`, `StageMutate`, `StageHandler`, `StageApplyInput`, `StageApplyOutput`, `StageApplyWarning`, `StageApplyWarningCode`, `StageEventExtra`, `AwaitingUserInput`, `ToolGate` — contract [`docs/contracts/stages.md`](https://github.com/masudl-hub/theoremai/blob/main/docs/contracts/stages.md) |
471
471
  | Turn events | `TURN_EVENT_SCHEMAS` (each kind's schema, for a wire parser), `turnEventSchema`, `turnHistoryMessageSchema`, `turnToolSnapshotSchema`, `reasoningPartSchema`, `historyHash`, `turnDoneOf`, `keptReply` (a turn's events without the replies a retry threw away), `z` (the zod these schemas are built with; compose them with it, since two copies of zod do not mix) — the event types themselves come through `export type *` from `src/kernel/types.ts` |
472
472
  | Observability | `memorySink`, `noopSink`, `readTraceparent`, `writeTrace`, `buildRecord`, `traceRecordSchema`, `contentOf`, `inlineContent`, `toOtlpJson`, `startTrace`, `traceContent`, `traceBytes`, `traceJson`, `registerTraceDestination`, `requireTraceDestination`, `getTraceDestination`, `listTraceDestinationIds`, `clearTraceDestinations`, `isTraceSink`, `resolveTraceWriter`, `resolveObservabilityPolicy`, `traceSpanMeta`, `traceAttributeMeta`, `traceEventMeta`, `traceEventAttributeMeta`, `TRACE_ATTRIBUTE_GROUPS`, `TRACE_STATUS`, `TRACE_FIELDS`, `TRACE_SPAN_TYPES`, `TraceSpanMeta`, `TraceSpanType`, `TraceAttributeMeta`, `TraceEventMeta`, `TraceOptionMeta`, `TraceAttributeGroup`, `TraceValueFormat`, `TraceRecord`, `TraceSink`, `TraceWriteContext`, `TraceSpan`, `TraceSpanEvent`, `TraceSpanKind`, `TraceSpanLink`, `TraceSpanStatus`, `TraceAttributes`, `TraceAttributeValue`, `TraceContent`, `TraceBytes`, `TraceJson`, `TraceTree`, `SpanHandle`, `SpanOptions`, `SpanLinkInput`, `TraceClock`, `ProfileObservabilitySpec`, `ResolvedObservabilityPolicy`, `ResolvedTraceInclude`, `ResolvedTraceScrub`, `TraceIncludeSpec`, `TraceScrubSpec`, `ScrubSwitch`, `ResolvedScrubSwitch`, `OtlpTraceRequest`, `OtlpSpan`, `OtlpKeyValue`, `OtlpAnyValue` (file sink: `@theoremjs/agents/observability/jsonl` → `jsonlSink`, `JsonlSinkOptions`) |
package/esm/mod.d.ts CHANGED
@@ -63,7 +63,7 @@ export { createKernelScope, defaultKernelScope } from './src/kernel/scope.js';
63
63
  export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOutput, StageApplyWarning, StageApplyWarningCode, StageContext, StageEventExtra, StageHandler, StageMutate, StageResult, } from './src/kernel/stages.js';
64
64
  export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './src/kernel/stages.js';
65
65
  export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './src/kernel/stop.js';
66
- export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './src/kernel/stop.js';
66
+ export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, } from './src/kernel/stop.js';
67
67
  export { systemLinesProblem } from './src/kernel/system-lines.js';
68
68
  export type { ToolBackground, ToolBackgroundCall, ToolBackgroundHandle, ToolBackgroundService, ToolBackgroundSettled, ToolSteerReceipt, ToolSteerRefusal, } from './src/kernel/tools/background.js';
69
69
  export { authorizeToolReplay } from './src/kernel/tools/execute.js';
package/esm/mod.js CHANGED
@@ -39,7 +39,7 @@ export { resolveTurnSystemPrompt } from './src/kernel/registry/system-prompt.js'
39
39
  export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, DYNAMIC_FIELD_PARENTS, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, LIVE_ACTIVITY_HANDLINGS, LIVE_END_SENSITIVITIES, LIVE_START_SENSITIVITIES, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './src/kernel/schema.js';
40
40
  export { createKernelScope, defaultKernelScope } from './src/kernel/scope.js';
41
41
  export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './src/kernel/stages.js';
42
- export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './src/kernel/stop.js';
42
+ export { AUTO_CONTINUE_DELAY_MS, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, } from './src/kernel/stop.js';
43
43
  export { systemLinesProblem } from './src/kernel/system-lines.js';
44
44
  export { authorizeToolReplay } from './src/kernel/tools/execute.js';
45
45
  export { GATE_DECISIONS } from './src/kernel/tools/gate-answer.js';
@@ -93,7 +93,7 @@ function sanitizeHistory(history, reader) {
93
93
  ...(m.tool_call_id ? { tool_call_id: m.tool_call_id } : {}),
94
94
  ...(m.name ? { name: m.name } : {}),
95
95
  ...(m.metadata ? { metadata: m.metadata } : {}),
96
- // why: Google refuses a call from the current turn replayed without its thought signature, so a reply resumed after a gate needs it.
96
+ // why: a provider may refuse a call from the current turn replayed without its signed reasoning, so a reply resumed after a gate needs it.
97
97
  ...(m.reasoning ? { reasoning: m.reasoning } : {}),
98
98
  };
99
99
  });
@@ -109,8 +109,8 @@ function settledToolContent(call) {
109
109
  }
110
110
  /**
111
111
  * One model step's settled calls: a single assistant message holding every call
112
- * the step made, with the reasoning written before them, then each result. Google replays a
113
- * step's calls only this way. With `gated: 'open'`, a
112
+ * the step made, with the reasoning written before them, then each result, as a provider
113
+ * reads a step's calls back. With `gated: 'open'`, a
114
114
  * call waiting on its gate joins the message too, left without a result.
115
115
  */
116
116
  function appendToolStepToHistory(history, calls, gated = 'omit') {
@@ -106,8 +106,8 @@ export interface CreatePkceFlowOptions extends OAuthTransportOptions {
106
106
  /** Skips discovery. */
107
107
  preResolved?: OAuthEndpoints;
108
108
  /**
109
- * Parameters a provider reads beyond the standard ones (e.g. Google's
110
- * `access_type: 'offline'`, without which it issues no refresh token). A name the
109
+ * Parameters an authorization server reads beyond the standard ones, such as one it needs
110
+ * before it issues a refresh token. A name the
111
111
  * flow sets itself is refused.
112
112
  */
113
113
  authorizationParams?: Readonly<Record<string, string>>;
@@ -423,11 +423,6 @@ function toolResultMessage(call, result) {
423
423
  ...(result.parts && result.parts.length > 0 ? { parts: result.parts } : {}),
424
424
  };
425
425
  }
426
- /**
427
- * One step's calls as one assistant message, the way the model made them.
428
- * Providers read a step's calls together, then their results: Google rejects
429
- * a call replayed after an earlier call's result (probe 25/09/2026).
430
- */
431
426
  /** Record the approved read-back in portable history. */
432
427
  function recordToolModelResult(state, call, modelResult) {
433
428
  state.currentHistory.push(toolResultMessage(call, modelResult));
@@ -31,6 +31,6 @@ export declare function sumEventTokens(events: readonly TurnEvent[]): TurnTokens
31
31
  export declare function sumTurnTokens(events: readonly TurnEvent[]): TurnTokens | undefined;
32
32
  /**
33
33
  * A side is `estimated` when any call estimated it. Cost is `partial` when some call reported none;
34
- * a missing `upstreamUsd` is not missing data (OpenRouter reports it only for BYOK).
34
+ * a missing `upstreamUsd` is not missing data, since a provider may report it for some calls only.
35
35
  */
36
36
  export declare function sumTokens(calls: TurnTokens[]): TurnTokens | undefined;
@@ -111,7 +111,7 @@ export function sumTurnTokens(events) {
111
111
  }
112
112
  /**
113
113
  * A side is `estimated` when any call estimated it. Cost is `partial` when some call reported none;
114
- * a missing `upstreamUsd` is not missing data (OpenRouter reports it only for BYOK).
114
+ * a missing `upstreamUsd` is not missing data, since a provider may report it for some calls only.
115
115
  */
116
116
  export function sumTokens(calls) {
117
117
  if (calls.length === 0)
@@ -220,7 +220,7 @@ export const FIELD_DOCS = {
220
220
  'live.vad.silenceDurationMs': "How long a silence, in milliseconds, ends the user's speech.",
221
221
  'live.vad.startSensitivity': 'How readily the session decides the user has started speaking.',
222
222
  'live.voice': 'The voice the model speaks in.',
223
- 'local.baseUrl': 'Where your local model server listens, such as Ollama, llama.cpp or vLLM. The browser calls it directly.',
223
+ 'local.baseUrl': 'Where your local model server listens. The browser calls it directly.',
224
224
  models: 'The trained AI systems that turn input into results. Each entry binds a local name to an upstream model and its call settings.',
225
225
  'models.*': 'One model: how to reach it and the settings sent with it.',
226
226
  'models.*.allowEffortSelect': 'Lets a turn pick an effort; needs two or more efforts.',
@@ -1,6 +1,4 @@
1
1
  import type { InteractionMediaRefPart, InteractionPart, TurnHistoryMessage } from './types.js';
2
- /** `toGoogleValue` snake-cases `mimeType` to the documented Interactions `mime_type`. */
3
- export declare function wireInteractionPart(part: InteractionPart): Record<string, string>;
4
2
  /** True for a part that is media referenced by `uri` rather than carried as data. */
5
3
  export declare function isMediaRefPart(part: InteractionPart): part is InteractionMediaRefPart;
6
4
  /**
@@ -1,13 +1,3 @@
1
- /** `toGoogleValue` snake-cases `mimeType` to the documented Interactions `mime_type`. */
2
- export function wireInteractionPart(part) {
3
- if (part.type === 'text') {
4
- return { type: 'text', text: part.text };
5
- }
6
- if ('uri' in part) {
7
- return { type: part.type, mimeType: part.mimeType, uri: part.uri };
8
- }
9
- return { type: part.type, mimeType: part.mimeType, data: part.data };
10
- }
11
1
  /** True for a part that is media referenced by `uri` rather than carried as data. */
12
2
  export function isMediaRefPart(part) {
13
3
  return part.type !== 'text' && 'uri' in part;
@@ -20,7 +20,7 @@ export type { LiveLine, LiveLineRole, LiveLines, RunSessionOptions, SignInGatePo
20
20
  export type { TokenCount, TokenEstimator } from './engine/token-estimate.js';
21
21
  export { loadTokenEstimator, TOKEN_TEXT_ENCODING, } from './engine/token-estimate.js';
22
22
  export { sumTokens } from './engine/usage.js';
23
- export { isMediaRefPart, wireInteractionPart } from './interaction-parts.js';
23
+ export { isMediaRefPart } from './interaction-parts.js';
24
24
  export type { JsonObject, JsonValue } from './json.js';
25
25
  export { jsonObjectSchema, jsonValueSchema } from './json.js';
26
26
  export type { ProfileGraphEditor, ProfileGraphFacet, ProfileGraphFacetId, ProfileGraphRole, } from './profile-graph.js';
@@ -52,13 +52,13 @@ export { createSchemaRegistry } from './registry/schemas.js';
52
52
  export { resolveTurnSystemPrompt } from './registry/system-prompt.js';
53
53
  export type { CredentialContext, CredentialResolver, KeyCredential } from './registry/vault.js';
54
54
  export type { AuthUnauthenticatedPolicy, CustomToolType, HttpMethod, StudioAuthType, ToolAccess, ToolAuthType, ToolPermission, ToolType, } from './schema.js';
55
- export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
55
+ export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
56
56
  export type { KernelScope } from './scope.js';
57
57
  export { createKernelScope, defaultKernelScope } from './scope.js';
58
58
  export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOutput, StageApplyWarning, StageApplyWarningCode, StageContext, StageEventExtra, StageHandler, StageMutate, StageResult, } from './stages.js';
59
59
  export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './stages.js';
60
60
  export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './stop.js';
61
- export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
61
+ export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, } from './stop.js';
62
62
  export type { SystemReadingLine } from './system-lines.js';
63
63
  export { systemLinesProblem, systemReading } from './system-lines.js';
64
64
  export { systemPromptProblem } from './system-parts.js';
@@ -13,7 +13,7 @@ export { DecisionError, validateDecisionRequest } from './engine/decision.js';
13
13
  export { assertLiveIngress, assertLiveIngressConfigured, hasAnyLiveIngress, liveIngressChannelDefault, liveIngressEnabled, liveIngressEnabledFromSpec, } from './engine/live-ingress.js';
14
14
  export { loadTokenEstimator, TOKEN_TEXT_ENCODING, } from './engine/token-estimate.js';
15
15
  export { sumTokens } from './engine/usage.js';
16
- export { isMediaRefPart, wireInteractionPart } from './interaction-parts.js';
16
+ export { isMediaRefPart } from './interaction-parts.js';
17
17
  export { jsonObjectSchema, jsonValueSchema } from './json.js';
18
18
  export { PROFILE_GRAPH, profileGraphFacet, spineFacetsForProfileType, } from './profile-graph.js';
19
19
  export { unsetValue } from './profile-presence.js';
@@ -31,10 +31,10 @@ export { createProfileRegistry, defineProfile } from './registry/profiles.js';
31
31
  export { projectProfileObject, requireModelProfile } from './registry/resolve.js';
32
32
  export { createSchemaRegistry } from './registry/schemas.js';
33
33
  export { resolveTurnSystemPrompt } from './registry/system-prompt.js';
34
- export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, CACHE_MODES, CACHE_TTLS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
34
+ export { API_EXPORTS, ATTACHMENT_ACCEPT_MIMES, AUTH_UNAUTHENTICATED_POLICIES, AWAITING_USER_INPUT_KINDS, AWAITING_USER_INPUT_STATUS, COMPACTION_METERS, COMPACTION_OUTCOMES, COMPACTION_TIMINGS, CONTINUE_STOP_KINDS, catalogPathFor, EXTRA_FIELDS, fieldMeta, HTTP_METHODS, IMAGE_ATTACHMENT_ACCEPT_MIMES, isKeySlotName, isToolGateKind, isTurnInjectStage, isTurnStage, KEY_SLOT_NAME, MEDIA_INPUT_KIND_VALUES, MEDIA_INPUT_KINDS, MEDIA_WILDCARDS, PROFILE_FIELDS, PROFILE_HANDLE_MAX_CHARS, PROFILE_ID_MAX_CHARS, PROFILE_TYPES, REQUEST_FIELDS, SPEECH_AUDIO_FORMATS, STREAM_MODES, STUDIO_AUTH_TYPES, SUMMARY_MODES, THINKING_LEVELS, TOOL_ACCESS, TOOL_AUTH_TYPES, TOOL_GATE_KINDS, TOOL_LOAD_TIERS, TOOL_PERMISSION, TOOL_TYPES, TURN_INJECT_STAGES, TURN_STAGES, TURN_STOP_KINDS, VOICE_ACCEPT_MIMES, } from './schema.js';
35
35
  export { createKernelScope, defaultKernelScope } from './scope.js';
36
36
  export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './stages.js';
37
- export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, turnStopFromInteractionStatus, turnStopFromOpenAiFinishReason, } from './stop.js';
37
+ export { AUTO_CONTINUE_DELAY_MS, CONTINUE_INSTRUCTION_TYPES, DEFAULT_ALLOW_CONTINUE, DEFAULT_AUTO_CONTINUE, GenerationStopError, isContinueStopKind, isGenerationStopError, isResumeableStop, isUserCancelledStop, profileAllowsInject, profileAllowsSteering, profileTurnResumption, shouldAutoContinue, turnStopFromClientStreamEnd, } from './stop.js';
38
38
  export { systemLinesProblem, systemReading } from './system-lines.js';
39
39
  export { systemPromptProblem } from './system-parts.js';
40
40
  export { activityLabelProblem } from './tools/activity-label.js';
@@ -73,14 +73,6 @@ export type CompactionTiming = (typeof COMPACTION_TIMINGS)[number];
73
73
  export declare const COMPACTION_OUTCOMES: readonly ["compacted", "deferred", "dropped"];
74
74
  /** One of {@linkcode COMPACTION_OUTCOMES}. */
75
75
  export type CompactionOutcome = (typeof COMPACTION_OUTCOMES)[number];
76
- /** Which part of the prompt is cached: the whole request (`automatic`) or the system instruction only (`system`). */
77
- export declare const CACHE_MODES: readonly ["automatic", "system"];
78
- /** One of {@linkcode CACHE_MODES}. */
79
- export type CacheMode = (typeof CACHE_MODES)[number];
80
- /** How long a provider keeps a cached prompt. */
81
- export declare const CACHE_TTLS: readonly ["5m", "1h"];
82
- /** One of {@linkcode CACHE_TTLS}. */
83
- export type CacheTtl = (typeof CACHE_TTLS)[number];
84
76
  /** Why a turn stopped, as `done.stop.kind` reports it. */
85
77
  export declare const TURN_STOP_KINDS: readonly ["completed", "length", "tool", "gate", "filtered", "provider_error", "cancelled", "stream_incomplete", "step_limit", "answer_missing", "interrupted", "generation_complete"];
86
78
  /** One of {@linkcode TURN_STOP_KINDS}. */
@@ -163,10 +155,8 @@ export type ToolType = (typeof TOOL_TYPES)[number];
163
155
  export type CustomToolType = Exclude<ToolType, 'builtin'>;
164
156
  /**
165
157
  * The package's complete media-input vocabulary: `assertMediaMime` refuses any MIME not
166
- * here, so hosts keep no second table. Rows follow Google Interactions / Live's documented
167
- * lists (verified 2026-09-12), the widest provider; TypeScript, `application/xml` and
168
- * `application/rtf` are not on Google's list. OpenAI-compat adapters forward the MIME
169
- * verbatim and add no rows. Provider alias essences (`image/jpg`, `video/mov`, …) are rows;
158
+ * here, so hosts keep no second table. Rows follow the widest provider's documented
159
+ * lists (verified 2026-09-12), plus TypeScript, `application/xml` and `application/rtf`. Provider alias essences (`image/jpg`, `video/mov`, …) are rows;
170
160
  * `resolveInputParts` canonicalizes `image/jpg` to `image/jpeg` on the wire.
171
161
  */
172
162
  export declare const MEDIA_INPUT_KINDS: Record<string, MediaInputKind>;
@@ -130,10 +130,6 @@ export const COMPACTION_OUTCOMES = [
130
130
  /** The compactor failed over `maxTokens`, so the compacted messages were dropped. */
131
131
  'dropped',
132
132
  ];
133
- /** Which part of the prompt is cached: the whole request (`automatic`) or the system instruction only (`system`). */
134
- export const CACHE_MODES = ['automatic', 'system'];
135
- /** How long a provider keeps a cached prompt. */
136
- export const CACHE_TTLS = ['5m', '1h'];
137
133
  /** Why a turn stopped, as `done.stop.kind` reports it. */
138
134
  export const TURN_STOP_KINDS = [
139
135
  /** The model finished its reply. */
@@ -336,10 +332,8 @@ export const STUDIO_AUTH_TYPES = [
336
332
  ];
337
333
  /**
338
334
  * The package's complete media-input vocabulary: `assertMediaMime` refuses any MIME not
339
- * here, so hosts keep no second table. Rows follow Google Interactions / Live's documented
340
- * lists (verified 2026-09-12), the widest provider; TypeScript, `application/xml` and
341
- * `application/rtf` are not on Google's list. OpenAI-compat adapters forward the MIME
342
- * verbatim and add no rows. Provider alias essences (`image/jpg`, `video/mov`, …) are rows;
335
+ * here, so hosts keep no second table. Rows follow the widest provider's documented
336
+ * lists (verified 2026-09-12), plus TypeScript, `application/xml` and `application/rtf`. Provider alias essences (`image/jpg`, `video/mov`, …) are rows;
343
337
  * `resolveInputParts` canonicalizes `image/jpg` to `image/jpeg` on the wire.
344
338
  */
345
339
  export const MEDIA_INPUT_KINDS = {
@@ -126,10 +126,6 @@ export declare function profileAllowsInject(profile: {
126
126
  type: string;
127
127
  turnBehaviour?: ProfileTurnBehaviourSpec;
128
128
  }): boolean;
129
- /** OpenAI-compatible normalized `finish_reason` (+ optional `native_finish_reason`). */
130
- export declare function turnStopFromOpenAiFinishReason(finishReason: string | null | undefined, nativeFinishReason?: string | null): TurnStop;
131
- /** Gemini Interactions terminal `status`. */
132
- export declare function turnStopFromInteractionStatus(status: string | null | undefined): TurnStop;
133
129
  /** `null` when `sawTerminal`, so the host keeps the provider's stop. */
134
130
  export declare function turnStopFromClientStreamEnd(opts: {
135
131
  abortedByUser: boolean;
@@ -87,56 +87,6 @@ export function profileAllowsInject(profile) {
87
87
  }
88
88
  return false;
89
89
  }
90
- /** OpenAI-compatible normalized `finish_reason` (+ optional `native_finish_reason`). */
91
- export function turnStopFromOpenAiFinishReason(finishReason, nativeFinishReason) {
92
- const native = nativeFinishReason?.trim() || finishReason?.trim() || undefined;
93
- const effective = (nativeFinishReason || finishReason || '').toLowerCase();
94
- if (!effective)
95
- return { kind: 'stream_incomplete', native };
96
- if (effective === 'network_error' || effective.includes('network')) {
97
- return { kind: 'provider_error', native };
98
- }
99
- return openAiFinishKind((finishReason || '').toLowerCase(), effective, native);
100
- }
101
- function openAiFinishKind(finish, effective, native) {
102
- if (finish === 'stop') {
103
- return /error|fail/.test(effective)
104
- ? { kind: 'provider_error', native }
105
- : { kind: 'completed', native };
106
- }
107
- // probed 2026-11-04: OpenRouter ends a call the output limit cut off with `tool_calls`; only the upstream's own reason says `length`.
108
- if (finish === 'length' || effective === 'length')
109
- return { kind: 'length', native };
110
- if (finish === 'tool_calls' || finish === 'tool-calls')
111
- return { kind: 'tool', native };
112
- if (finish === 'content_filter' || finish === 'content-filter') {
113
- return { kind: 'filtered', native };
114
- }
115
- return { kind: 'provider_error', native };
116
- }
117
- /** Gemini Interactions terminal `status`. */
118
- export function turnStopFromInteractionStatus(status) {
119
- const s = (status || '').toLowerCase();
120
- const native = status || undefined;
121
- switch (s) {
122
- case 'completed':
123
- return { kind: 'completed', native };
124
- case 'incomplete':
125
- case 'budget_exceeded':
126
- return { kind: 'length', native };
127
- case 'requires_action':
128
- return { kind: 'tool', native };
129
- case 'cancelled':
130
- return { kind: 'cancelled', native };
131
- case 'failed':
132
- return { kind: 'provider_error', native };
133
- case 'in_progress':
134
- case 'queued':
135
- return { kind: 'stream_incomplete', native };
136
- default:
137
- return { kind: 'stream_incomplete', native };
138
- }
139
- }
140
90
  /** `null` when `sawTerminal`, so the host keeps the provider's stop. */
141
91
  export function turnStopFromClientStreamEnd(opts) {
142
92
  if (opts.sawTerminal)
@@ -33,8 +33,7 @@ export interface ReasoningOrigin {
33
33
  apiId?: string;
34
34
  }
35
35
  /**
36
- * Signed reasoning a model wrote, kept word for word: Gemini's thought signatures, OpenRouter's
37
- * `reasoning_details`. It goes back only to the protocol that wrote it, or one extended from it;
36
+ * Signed reasoning a model wrote, kept word for word. It goes back only to the protocol that wrote it, or one extended from it;
38
37
  * `data` is that protocol's own shape, checked against its `reasoning` schema.
39
38
  */
40
39
  export interface ReasoningPart {
@@ -105,7 +104,7 @@ export type TurnTokenSide = (typeof TURN_TOKEN_SIDES)[number];
105
104
  export interface TurnCost {
106
105
  /** What the provider charged, in US dollars. */
107
106
  usd: number;
108
- /** What the upstream model vendor charged the provider, when reported (OpenRouter). */
107
+ /** What the upstream model vendor charged the provider, when the provider reports it. */
109
108
  upstreamUsd?: number;
110
109
  /**
111
110
  * Set on a sum (`sumTokens`) when some summed calls reported a cost and
@@ -134,7 +133,7 @@ export interface TurnTokens {
134
133
  output: number;
135
134
  /** Reasoning share of `output`. */
136
135
  thinking?: number;
137
- /** Provider tool-use share of `input` (Google code execution / URL context results). */
136
+ /** Share of `input` that the provider's own tools added, such as their results. */
138
137
  toolUse?: number;
139
138
  /** Share of `input` read from provider cache (cache hit). */
140
139
  cached?: number;
@@ -169,7 +168,7 @@ export interface TurnTokens {
169
168
  }
170
169
  /** A provider response's identity, as the wire sent it. Live sends neither field. */
171
170
  export interface TurnResponse {
172
- /** Provider response id (OpenAI-compatible `id`, Interactions `id`). */
171
+ /** The provider's id for the response. */
173
172
  id?: string;
174
173
  model?: string;
175
174
  }
@@ -180,11 +179,11 @@ export interface Source {
180
179
  title: string;
181
180
  uri: string;
182
181
  type: SourceType;
183
- /** Google Place id when the source is a Maps place / place_citation. */
182
+ /** The place's id, when the source is a place on a map. */
184
183
  placeId?: string;
185
184
  }
186
185
  export declare const sourceSchema: z.ZodType<Source>;
187
- /** Google grounding search metadata. Sources travel as `citation` events. */
186
+ /** Search metadata a provider grounded its answer on. Sources travel as `citation` events. */
188
187
  export interface GroundingEvent {
189
188
  metadata?: Record<string, unknown>;
190
189
  chunks?: unknown[];
@@ -228,7 +227,7 @@ export type ProviderEvidence = (EvidenceBase & {
228
227
  resumable: boolean;
229
228
  }) | (EvidenceBase & {
230
229
  kind: 'provider_step';
231
- /** The provider's own step type, e.g. `google_search_call`. */
230
+ /** The provider's own name for the step type. */
232
231
  step: string;
233
232
  });
234
233
  /** A session the provider ended after warning it would. */
@@ -401,8 +400,7 @@ export interface ToolCallRequest extends ToolEventBase {
401
400
  */
402
401
  arguments: Record<string, unknown>;
403
402
  /**
404
- * On a step's first call: the signed reasoning the model wrote before the step's calls (a Gemini
405
- * thought signature, OpenRouter's `reasoning_details`). It goes back on the assistant message
403
+ * On a step's first call: the signed reasoning the model wrote before the step's calls. It goes back on the assistant message
406
404
  * holding the step's calls, word for word; a host keeping its own history keeps it there.
407
405
  */
408
406
  reasoning?: ReasoningPart[];
@@ -1,13 +1,13 @@
1
1
  import type { ProviderCheckpoint, ProviderContinuationPolicy } from './checkpoint.js';
2
2
  import type { JsonObject } from './json.js';
3
- import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContextSender, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
3
+ import type { CompactionMeter, CompactionOutcome, CompactionTiming, ContextSender, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
4
4
  import type { StageHandler } from './stages.js';
5
5
  import type { ToolBackgroundService } from './tools/background.js';
6
6
  import type { GateDecision } from './tools/gate-answer.js';
7
7
  import type { PageToolExecution, ToolExecutionCoordinator, ToolOperationOutcome } from './tools/operation.js';
8
8
  import type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, LiveProfileToolsSpec, ModelToolResult, PageAnswer, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
9
9
  import type { AttemptReason, CallDone, CompactionFailure, CompactionResult, CompactionSignal, DoneFields, GroundingEvent, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, ModelEvent, ProviderEvidence, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnTokenSide, TurnTokens } from './turn-events.js';
10
- export type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, AttemptReason, CacheMode, CacheTtl, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ModelEvent, ProfileToolsSpec, ProfileType, ProviderEvidence, RegisteredTool, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
10
+ export type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, AttemptReason, CallDone, CompactionFailure, CompactionMeter, CompactionOutcome, CompactionResult, CompactionSignal, CompactionTiming, ContinueStopKind, DoneFields, FieldMeta, GroundingEvent, HostProfileToolsSpec, InjectedMessages, InteractionMediaPart, InteractionMediaRefPart, InteractionPart, InteractionTextPart, InvalidField, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveProfileToolsSpec, LiveStartSensitivity, MediaInputKind, ModelEvent, ProfileToolsSpec, ProfileType, ProviderEvidence, RegisteredTool, RemovedItem, SessionEnded, SessionEvent, SessionEventKind, SessionEventOf, Source, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolLoadTier, ToolPolicy, TurnCost, TurnEvent, TurnEventOf, TurnEventType, TurnGroundingCount, TurnHistoryMessage, TurnResponse, TurnStage, TurnStopKind, TurnTokenSide, TurnTokens, TurnToolSnapshot, WireFunctionTool, };
11
11
  /** A host-chosen key naming one model binding in a profile's `models`. */
12
12
  export type ModelId = string;
13
13
  /** The id of a provider-side tool such as web search. */
@@ -67,26 +67,12 @@ export interface ProfileImageSpec {
67
67
  /**
68
68
  * Whether the model may write text alongside its images; with some providers this also sends the
69
69
  * system instruction and history.
70
- *
71
- * @remarks Also request interleaved text with the images (Google: text + image
72
- * `response_format`).
73
70
  */
74
71
  includeText?: boolean;
75
72
  }
76
73
  import type { DecisionModelBinding, ModelBinding } from './protocols/binding.js';
77
74
  import type { ProviderHostOptions } from './protocols/runtime.js';
78
75
  export type { DecisionModelBinding, ModelBinding };
79
- /**
80
- * OpenRouter prompt-cache policy (`models.*.options.cache`).
81
- *
82
- * - `automatic` — top-level `cache_control`; breakpoint advances with the conversation.
83
- * - `system` — explicit breakpoint on the system instruction only.
84
- */
85
- export interface CacheSpec {
86
- mode: CacheMode;
87
- /** Ephemeral TTL. Omit → provider default (typically 5m on Anthropic). */
88
- ttl?: CacheTtl;
89
- }
90
76
  /** What a compaction trigger sees when it decides whether to compact. */
91
77
  export interface CompactionTriggerContext {
92
78
  tokens: number;
@@ -384,21 +370,20 @@ export interface LiveVadSpec {
384
370
  }
385
371
  /**
386
372
  * Context window compression for a live session: once the context reaches the
387
- * trigger, the mechanism shrinks it. Without it, Gemini ends audio sessions at
388
- * 15 minutes and audio-video sessions at 2.
373
+ * trigger, the mechanism shrinks it. Without it, a provider may end a long session.
389
374
  */
390
375
  export interface LiveContextCompressionSpec {
391
376
  /**
392
377
  * The context size, in tokens, that starts trimming.
393
378
  *
394
379
  * @remarks Context tokens, counted before a turn, that start compression. A whole number above 0.
395
- * Omit → provider default (Gemini: 80% of the model's context window).
380
+ * Omit → the provider's default.
396
381
  */
397
382
  triggerTokens?: number;
398
383
  /**
399
384
  * Trims by dropping the oldest turns; the system instruction stays.
400
385
  *
401
- * @remarks Drops the oldest turns; the system instruction stays. Gemini's only mechanism.
386
+ * @remarks Drops the oldest turns; the system instruction stays.
402
387
  */
403
388
  slidingWindow: LiveSlidingWindowSpec;
404
389
  }
@@ -408,7 +393,7 @@ export interface LiveSlidingWindowSpec {
408
393
  * The context size, in tokens, to trim down to; below the trigger.
409
394
  *
410
395
  * @remarks Tokens to keep after compressing. A whole number above 0, below `triggerTokens`. Omit
411
- * → provider default (Gemini: half of `triggerTokens`).
396
+ * → the provider's default.
412
397
  */
413
398
  targetTokens?: number;
414
399
  }
@@ -984,7 +969,7 @@ export interface ImageResponseFormat {
984
969
  type: 'image';
985
970
  mimeType?: string;
986
971
  aspectRatio?: string;
987
- /** Adapters map it to the provider wire key (Google `imageSize`, OpenRouter `resolution`). */
972
+ /** Each protocol sends it under its provider's own name for it. */
988
973
  resolution?: string;
989
974
  quality?: string;
990
975
  background?: string;
@@ -1,9 +1,6 @@
1
1
  // invariant: A key with no entry is still a real attribute: viewers show it under its raw name.
2
2
  import { OPTION_DOCS } from '../kernel/field-docs.js';
3
- import { geminiProvider } from '../providers/gemini/provider.js';
4
- import { localProvider } from '../providers/local/provider.js';
5
- import { openRouterProvider } from '../providers/openrouter/provider.js';
6
- import { typesafeProvider } from '../providers/typesafe/provider.js';
3
+ import { BUILT_IN_PROVIDERS } from '../providers/built-in.js';
7
4
  /** Labels and descriptions for each attribute group. */
8
5
  const TRACE_ATTRIBUTE_GROUPS = {
9
6
  agent: { label: 'Agent', doc: 'Which agent ran, for which conversation, and how it ended.' },
@@ -166,7 +163,7 @@ const OPERATIONS = {
166
163
  chat: { label: 'Chat', doc: 'A model call to a chat-completions endpoint.' },
167
164
  generate_content: {
168
165
  label: 'Generate content',
169
- doc: 'A model call that generates content other than over chat completions: Gemini, speech, or images.',
166
+ doc: 'A model call that generates content other than over chat completions, such as speech or images.',
170
167
  },
171
168
  transcribe: { label: 'Transcribe', doc: 'One transcription call: a voice clip in, text out.' },
172
169
  execute_tool: { label: 'Run tool', doc: 'A tool call theorem ran.' },
@@ -182,7 +179,7 @@ const OUTPUT_TYPES = {
182
179
  image: { label: 'Image', doc: 'The model answers with an image.' },
183
180
  speech: { label: 'Speech', doc: 'The model answers in audio.' },
184
181
  };
185
- const PROVIDERS = Object.fromEntries([geminiProvider, localProvider, openRouterProvider, typesafeProvider].map((provider) => [
182
+ const PROVIDERS = Object.fromEntries(BUILT_IN_PROVIDERS.map((provider) => [
186
183
  provider.traceName ?? provider.id,
187
184
  { label: provider.name, doc: provider.description },
188
185
  ]));
@@ -529,7 +526,7 @@ const SPAN_ATTRIBUTES = {
529
526
  'gen_ai.usage.reasoning.output_tokens': attr('usage', 'Thinking tokens', 'tokens', 'Output tokens spent thinking.'),
530
527
  'gen_ai.usage.cache_read.input_tokens': attr('usage', 'Cached input tokens', 'tokens', 'Input tokens read from the prompt cache.'),
531
528
  'gen_ai.usage.cache_write.input_tokens': attr('usage', 'Cache write tokens', 'tokens', 'Input tokens written to the prompt cache.'),
532
- 'theorem.usage.tool_use.input_tokens': attr('usage', 'Tool-use input tokens', 'tokens', 'Input tokens Google counts for tool use; already inside input tokens.'),
529
+ 'theorem.usage.tool_use.input_tokens': attr('usage', 'Tool-use input tokens', 'tokens', 'Input tokens the provider counts for its own tools; already inside input tokens.'),
533
530
  'theorem.usage.grounding': fields('usage', 'Grounding', 'Grounding tool uses, per tool.', {
534
531
  type: attr('usage', 'Tool', 'id', "The provider's name for the tool."),
535
532
  count: attr('usage', 'Uses', 'number', 'Times the tool ran.'),
@@ -756,7 +753,7 @@ const TRACE_EVENTS = {
756
753
  attributes: {
757
754
  provider: attr('response', 'Provider', 'id', 'Who supplied the evidence.'),
758
755
  sources: attr('response', 'Sources', 'json', 'The sources.'),
759
- search_html: attr('response', 'Search suggestions', 'content', "Google's search widget."),
756
+ search_html: attr('response', 'Search suggestions', 'content', "The provider's search suggestions, as HTML."),
760
757
  raw: attr('response', 'Raw', 'json', "The provider's raw grounding payload."),
761
758
  },
762
759
  },
@@ -830,7 +827,7 @@ const TRACE_EVENTS = {
830
827
  doc: "One case's pass or fail after its trials, by the suite's pass rule. Every case is here, zeros included.",
831
828
  attributes: {
832
829
  case: attr('evaluation', 'Case', 'id', 'The case judged.'),
833
- kind: attr('evaluation', 'Kind', 'text', "Anthropic's split of cases.", CASE_KINDS),
830
+ kind: attr('evaluation', 'Kind', 'text', 'Whether the case asks for something new or guards something that works.', CASE_KINDS),
834
831
  difficulty: attr('evaluation', 'Difficulty', 'number', 'The case’s 1–5 difficulty, when the suite set one.'),
835
832
  passed: attr('evaluation', 'Passed', 'boolean', 'The pass rule was met.'),
836
833
  trials: attr('evaluation', 'Trials', 'number', 'Trials run.'),
@@ -0,0 +1,2 @@
1
+ /** The providers this package ships, for code that lists or labels them without naming one. */
2
+ export declare const BUILT_IN_PROVIDERS: readonly [Readonly<import("./mod.js").ProviderDefinition<import("./gemini/provider.js").GeminiConnection, string>>, Readonly<import("./mod.js").ProviderDefinition<import("./local/provider.js").LocalConnection, string>>, Readonly<import("./mod.js").ProviderDefinition<import("./openrouter/provider.js").OpenRouterConnection, string>>, Readonly<import("./mod.js").ProviderDefinition<import("./typesafe/provider.js").TypesafeConnection, string>>];
@@ -0,0 +1,11 @@
1
+ import { geminiProvider } from './gemini/provider.js';
2
+ import { localProvider } from './local/provider.js';
3
+ import { openRouterProvider } from './openrouter/provider.js';
4
+ import { typesafeProvider } from './typesafe/provider.js';
5
+ /** The providers this package ships, for code that lists or labels them without naming one. */
6
+ export const BUILT_IN_PROVIDERS = [
7
+ geminiProvider,
8
+ localProvider,
9
+ openRouterProvider,
10
+ typesafeProvider,
11
+ ];
@@ -9,6 +9,7 @@ export type InteractionsRequest = ModelRequest & {
9
9
  };
10
10
  export declare function camelToSnake(key: string): string;
11
11
  export declare function toGoogleValue(value: unknown): unknown;
12
+ /** A part in camel case; `toGoogleValue` snake-cases `mimeType` to the documented `mime_type`. */
12
13
  export declare function wirePart(part: InteractionPart): Record<string, string>;
13
14
  export declare function userInputStep(parts: InteractionPart[]): Record<string, unknown>;
14
15
  /** A thought's signature, for the tool call at `call` in the same assistant message. */
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { TheoremError } from '../../../guardrails/error.js';
3
- import { historyMessageParts, wireInteractionPart } from '../../../kernel/interaction-parts.js';
3
+ import { historyMessageParts } from '../../../kernel/interaction-parts.js';
4
4
  import { withCarriedToolFiles } from '../../shared/carried-tool-files.js';
5
5
  import { historyToolArguments, historyToolIdentity } from '../../shared/tool-args.js';
6
6
  import { interactionsBuiltinTool } from '../builtins.js';
@@ -27,8 +27,15 @@ export function toGoogleValue(value) {
27
27
  }
28
28
  return value;
29
29
  }
30
+ /** A part in camel case; `toGoogleValue` snake-cases `mimeType` to the documented `mime_type`. */
30
31
  export function wirePart(part) {
31
- return wireInteractionPart(part);
32
+ if (part.type === 'text') {
33
+ return { type: 'text', text: part.text };
34
+ }
35
+ if ('uri' in part) {
36
+ return { type: part.type, mimeType: part.mimeType, uri: part.uri };
37
+ }
38
+ return { type: part.type, mimeType: part.mimeType, data: part.data };
32
39
  }
33
40
  const USER_INPUT = 'user_input';
34
41
  export function userInputStep(parts) {
@@ -0,0 +1,3 @@
1
+ import type { TurnStop } from '../../../kernel/turn-events.js';
2
+ /** The stop an Interactions `status` reports when the call ends. */
3
+ export declare function turnStopFromInteractionStatus(status: string | null | undefined): TurnStop;
@@ -0,0 +1,23 @@
1
+ /** The stop an Interactions `status` reports when the call ends. */
2
+ export function turnStopFromInteractionStatus(status) {
3
+ const s = (status || '').toLowerCase();
4
+ const native = status || undefined;
5
+ switch (s) {
6
+ case 'completed':
7
+ return { kind: 'completed', native };
8
+ case 'incomplete':
9
+ case 'budget_exceeded':
10
+ return { kind: 'length', native };
11
+ case 'requires_action':
12
+ return { kind: 'tool', native };
13
+ case 'cancelled':
14
+ return { kind: 'cancelled', native };
15
+ case 'failed':
16
+ return { kind: 'provider_error', native };
17
+ case 'in_progress':
18
+ case 'queued':
19
+ return { kind: 'stream_incomplete', native };
20
+ default:
21
+ return { kind: 'stream_incomplete', native };
22
+ }
23
+ }
@@ -1,8 +1,8 @@
1
1
  import { asRecord, nonEmptyString } from '../../../kernel/engine/record.js';
2
2
  import { reportedTokens, usageCount } from '../../../kernel/engine/usage.js';
3
- import { turnStopFromInteractionStatus } from '../../../kernel/stop.js';
4
3
  import { groundingFromSteps } from '../grounding.js';
5
4
  import { byModality, groundingCounts, modalityCounts } from '../usage.js';
5
+ import { turnStopFromInteractionStatus } from './status.js';
6
6
  /* probed 2026-09-23:
7
7
  * Interactions steps and deltas read only the shapes recorded from the wire
8
8
  * (probes 23/09/2026, gemini-3.8-flash, gemini-3.1-pro-preview, image, and TTS
@@ -0,0 +1,3 @@
1
+ import type { TurnStop } from '../../kernel/turn-events.js';
2
+ /** OpenAI-compatible normalized `finish_reason` (+ optional `native_finish_reason`). */
3
+ export declare function turnStopFromOpenAiFinishReason(finishReason: string | null | undefined, nativeFinishReason?: string | null): TurnStop;
@@ -0,0 +1,27 @@
1
+ /** OpenAI-compatible normalized `finish_reason` (+ optional `native_finish_reason`). */
2
+ export function turnStopFromOpenAiFinishReason(finishReason, nativeFinishReason) {
3
+ const native = nativeFinishReason?.trim() || finishReason?.trim() || undefined;
4
+ const effective = (nativeFinishReason || finishReason || '').toLowerCase();
5
+ if (!effective)
6
+ return { kind: 'stream_incomplete', native };
7
+ if (effective === 'network_error' || effective.includes('network')) {
8
+ return { kind: 'provider_error', native };
9
+ }
10
+ return openAiFinishKind((finishReason || '').toLowerCase(), effective, native);
11
+ }
12
+ function openAiFinishKind(finish, effective, native) {
13
+ if (finish === 'stop') {
14
+ return /error|fail/.test(effective)
15
+ ? { kind: 'provider_error', native }
16
+ : { kind: 'completed', native };
17
+ }
18
+ // probed 2026-11-04: OpenRouter ends a call the output limit cut off with `tool_calls`; only the upstream's own reason says `length`.
19
+ if (finish === 'length' || effective === 'length')
20
+ return { kind: 'length', native };
21
+ if (finish === 'tool_calls' || finish === 'tool-calls')
22
+ return { kind: 'tool', native };
23
+ if (finish === 'content_filter' || finish === 'content-filter') {
24
+ return { kind: 'filtered', native };
25
+ }
26
+ return { kind: 'provider_error', native };
27
+ }
@@ -2,7 +2,6 @@ import { z } from 'zod';
2
2
  import { kindOfHttpStatus, TheoremError } from '../../guardrails/error.js';
3
3
  import { asRecord } from '../../kernel/engine/record.js';
4
4
  import { defineProtocol, } from '../../kernel/protocols/mod.js';
5
- import { turnStopFromOpenAiFinishReason } from '../../kernel/stop.js';
6
5
  import { base64ToBytes, bytesToBase64 } from '../../kernel/util/base64.js';
7
6
  import { mimeEssence } from '../../kernel/util/mime.js';
8
7
  import { buildChatMessages, httpError, resolveResponseFormat, statedError, wireTools, } from '../openrouter/openai/compat.js';
@@ -13,6 +12,7 @@ import { foldResponse } from '../shared/response-identity.js';
13
12
  import { structuredEvent } from '../shared/structured-output.js';
14
13
  import { toolCallEvents } from '../shared/tool-args.js';
15
14
  import { toolDraftEvents } from '../shared/tool-draft.js';
15
+ import { turnStopFromOpenAiFinishReason } from './finish-reason.js';
16
16
  /** Old-shape events from the shared helpers, as protocol events. */
17
17
  function asProtocolEvents(events) {
18
18
  return events.flatMap((event) => asProtocolEvent(event) ?? []);
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { TheoremError } from '../../guardrails/error.js';
3
3
  import { asRecord, nonEmptyString } from '../../kernel/engine/record.js';
4
4
  import { defineProtocol, } from '../../kernel/protocols/mod.js';
5
- import { turnStopFromOpenAiFinishReason } from '../../kernel/stop.js';
5
+ import { turnStopFromOpenAiFinishReason } from '../open-ai/finish-reason.js';
6
6
  import { imagesFromChatMessage, imagesFromImagesBody, OPENROUTER_IMAGE_TOOL } from './image.js';
7
7
  import { buildChatMessages } from './openai/compat.js';
8
8
  import { buildImagesPayload, extractPromptText, imageToolParameters, } from './openai/image-payload.js';
@@ -1,6 +1,24 @@
1
1
  import { type JsonObject } from '../../kernel/json.js';
2
2
  import { type Protocol } from '../../kernel/protocols/mod.js';
3
- import type { CacheSpec } from '../../kernel/types.js';
3
+ /** What is cached: the whole request (`automatic`) or the system instruction only (`system`). */
4
+ declare const CACHE_MODES: readonly ["automatic", "system"];
5
+ /** One of {@linkcode CACHE_MODES}. */
6
+ export type CacheMode = (typeof CACHE_MODES)[number];
7
+ /** How long OpenRouter's upstream keeps a cached prompt. */
8
+ declare const CACHE_TTLS: readonly ["5m", "1h"];
9
+ /** One of {@linkcode CACHE_TTLS}. */
10
+ export type CacheTtl = (typeof CACHE_TTLS)[number];
11
+ /**
12
+ * Prompt-cache policy (`models.*.options.cache`).
13
+ *
14
+ * - `automatic` — top-level `cache_control`; breakpoint advances with the conversation.
15
+ * - `system` — explicit breakpoint on the system instruction only.
16
+ */
17
+ export interface CacheSpec {
18
+ mode: CacheMode;
19
+ /** How long the cache lives. Omit → the upstream's default, typically 5 minutes on Anthropic. */
20
+ ttl?: CacheTtl;
21
+ }
4
22
  /** What an `openRouterOpenAi` binding sets in `options`. */
5
23
  export interface OpenRouterOptions {
6
24
  cache?: CacheSpec;
@@ -32,3 +50,4 @@ export interface OpenRouterRouting {
32
50
  }
33
51
  /** Chat Completions with OpenRouter's caching, routing, web search, citations, and reasoning. */
34
52
  export declare const openRouterOpenAi: Protocol<OpenRouterOptions>;
53
+ export {};
@@ -2,9 +2,12 @@ import { z } from 'zod';
2
2
  import { asRecord } from '../../kernel/engine/record.js';
3
3
  import { jsonObjectSchema } from '../../kernel/json.js';
4
4
  import { extendProtocol } from '../../kernel/protocols/mod.js';
5
- import { CACHE_MODES, CACHE_TTLS } from '../../kernel/schema.js';
6
5
  import { openAi } from '../open-ai/protocol.js';
7
6
  import { collectReasoning } from './openai/reasoning-state.js';
7
+ /** What is cached: the whole request (`automatic`) or the system instruction only (`system`). */
8
+ const CACHE_MODES = ['automatic', 'system'];
9
+ /** How long OpenRouter's upstream keeps a cached prompt. */
10
+ const CACHE_TTLS = ['5m', '1h'];
8
11
  // labels-exempt: builder field description, read by the studio and docs
9
12
  const cache = z
10
13
  .strictObject({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/agents",
3
- "version": "0.3.5-next.906.g6f050f4",
3
+ "version": "0.3.5-next.907.g49f9ef9",
4
4
  "description": "A flat TypeScript agent kernel for typed profiles, deterministic turn execution, registered tools, provider adapters, guardrails, and host-injected traces.",
5
5
  "keywords": [
6
6
  "agent",