@theoremjs/agents 0.3.5-next.904.g8358918 → 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 (54) 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/host/mod.d.ts +2 -1
  6. package/esm/src/host/mod.js +2 -1
  7. package/esm/src/interface/history.js +2 -2
  8. package/esm/src/kernel/auth/types.d.ts +2 -2
  9. package/esm/src/kernel/engine/runner/steps.js +1 -5
  10. package/esm/src/kernel/engine/session/mod.js +1 -0
  11. package/esm/src/kernel/engine/usage.d.ts +1 -1
  12. package/esm/src/kernel/engine/usage.js +1 -1
  13. package/esm/src/kernel/field-docs.js +6 -6
  14. package/esm/src/kernel/interaction-parts.d.ts +0 -2
  15. package/esm/src/kernel/interaction-parts.js +0 -10
  16. package/esm/src/kernel/mod.d.ts +5 -4
  17. package/esm/src/kernel/mod.js +4 -4
  18. package/esm/src/kernel/profile-presence.js +1 -1
  19. package/esm/src/kernel/protocols/binding.d.ts +6 -6
  20. package/esm/src/kernel/protocols/binding.js +1 -1
  21. package/esm/src/kernel/schema.d.ts +2 -12
  22. package/esm/src/kernel/schema.js +3 -9
  23. package/esm/src/kernel/stages.d.ts +6 -0
  24. package/esm/src/kernel/stop.d.ts +0 -4
  25. package/esm/src/kernel/stop.js +0 -50
  26. package/esm/src/kernel/system-lines.d.ts +12 -0
  27. package/esm/src/kernel/system-lines.js +25 -0
  28. package/esm/src/kernel/tools/events.d.ts +1 -0
  29. package/esm/src/kernel/tools/events.js +9 -1
  30. package/esm/src/kernel/tools/execute.d.ts +2 -0
  31. package/esm/src/kernel/tools/execute.js +52 -16
  32. package/esm/src/kernel/tools/model-view.d.ts +12 -2
  33. package/esm/src/kernel/tools/model-view.js +68 -11
  34. package/esm/src/kernel/tools/project.js +4 -2
  35. package/esm/src/kernel/tools/resolve.js +2 -1
  36. package/esm/src/kernel/tools/stage-run.d.ts +2 -0
  37. package/esm/src/kernel/tools/stage-run.js +3 -1
  38. package/esm/src/kernel/turn-events.d.ts +8 -10
  39. package/esm/src/kernel/types.d.ts +10 -26
  40. package/esm/src/observability/trace-catalog.js +6 -9
  41. package/esm/src/providers/built-in.d.ts +2 -0
  42. package/esm/src/providers/built-in.js +11 -0
  43. package/esm/src/providers/google/interactions/framing.d.ts +1 -0
  44. package/esm/src/providers/google/interactions/framing.js +9 -2
  45. package/esm/src/providers/google/interactions/status.d.ts +3 -0
  46. package/esm/src/providers/google/interactions/status.js +23 -0
  47. package/esm/src/providers/google/interactions/steps.js +1 -1
  48. package/esm/src/providers/open-ai/finish-reason.d.ts +3 -0
  49. package/esm/src/providers/open-ai/finish-reason.js +27 -0
  50. package/esm/src/providers/open-ai/protocol.js +1 -1
  51. package/esm/src/providers/openrouter/images-protocol.js +1 -1
  52. package/esm/src/providers/openrouter/protocol.d.ts +20 -1
  53. package/esm/src/providers/openrouter/protocol.js +5 -1
  54. 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
  });
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Optional host-application helpers, not part of the turn kernel: HTTP reply status, cutout-trace
3
- * flush, and live structured-output preview.
3
+ * flush, live structured-output preview, and a tool's input as a model reads it.
4
4
  *
5
5
  * @module
6
6
  */
7
7
  import "../../_dnt.polyfills.js";
8
+ export { inputSchemaForModel, markedFieldsIn } from '../kernel/tools/model-view.js';
8
9
  export type { ClientError, ClientTurnOptions } from './client-turn.js';
9
10
  export { clientError, forClient, forClientEvents } from './client-turn.js';
10
11
  export type { CutoutTape } from './mint-trace.js';
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Optional host-application helpers, not part of the turn kernel: HTTP reply status, cutout-trace
3
- * flush, and live structured-output preview.
3
+ * flush, live structured-output preview, and a tool's input as a model reads it.
4
4
  *
5
5
  * @module
6
6
  */
7
7
  import "../../_dnt.polyfills.js";
8
+ export { inputSchemaForModel, markedFieldsIn } from '../kernel/tools/model-view.js';
8
9
  export { clientError, forClient, forClientEvents } from './client-turn.js';
9
10
  export { flushMintTrace } from './mint-trace.js';
10
11
  export { readStreamingJsonStringField } from './readStreamingJsonStringField.js';
@@ -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));
@@ -580,6 +575,7 @@ async function* handleModelCalls(outcome, generation, profile, state, system, {
580
575
  name: call.name,
581
576
  input: call.arguments,
582
577
  callId: call.callId,
578
+ fromModel: true,
583
579
  ctx: {
584
580
  operationId: call.operationId,
585
581
  pageExecution: generation.pageExecution,
@@ -818,6 +818,7 @@ function buildLiveSession(args) {
818
818
  name: held.name,
819
819
  input,
820
820
  callId,
821
+ fromModel: resume === undefined,
821
822
  ctx: {
822
823
  operationId: held.operationId,
823
824
  sessionPermissions,
@@ -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,12 +220,12 @@ 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.',
227
- 'models.*.apiId': "The model's id as the provider lists it, such as gemini-2.5-flash; sent on every call. The name this model has in the profile is its key in models.",
228
- 'models.*.builtInTools': "The provider's own tools, such as Google Search, this model may use; each must be registered as a builtin tool and declared by the provider's adapter.",
227
+ 'models.*.apiId': "The model's id as the provider lists it; sent on every call. The name this model has in the profile is its key in models.",
228
+ 'models.*.builtInTools': "The provider's own tools, such as its web search, this model may use; each must be registered as a builtin tool and declared by the provider's adapter.",
229
229
  'models.*.compaction': 'Summarises history past a threshold. A text agent can write the summary. Other types name a compaction profile.',
230
230
  'models.*.compaction.compactAt': 'The fraction of maxTokens, between 0 and 1, at which compaction starts, unless trigger decides.',
231
231
  'models.*.compaction.maxTokens': 'The token budget compactAt is a fraction of.',
@@ -252,7 +252,7 @@ export const FIELD_DOCS = {
252
252
  'models.*.maxOutputTokens': 'The token limit for one reply. Some providers never send it for speech, or for image without includeText.',
253
253
  'models.*.options': "Settings only this model's protocol has, such as a task type or vector size. Each is checked when the profile loads. Any left out keep the provider's default.",
254
254
  'models.*.protocol': 'The API shape this model is spoken to in.',
255
- 'models.*.provider': 'The service that runs the model or routes requests to one, such as Gemini or OpenRouter. Its registration supplies the endpoint and authentication.',
255
+ 'models.*.provider': 'The service that runs the model or routes requests to one. Its registration supplies the endpoint and authentication.',
256
256
  'models.*.summaries': 'Asks the model for summaries of its thinking, which not every model sends; with some providers, off only hides thoughts, and others ignore it.',
257
257
  'models.*.temperature': "How varied the model's wording is; higher is more random. Some providers never send it for speech, or for image without includeText.",
258
258
  'models.*.timeoutMs': 'How long a decision waits for its provider, in milliseconds. Omit for no timeout.',
@@ -393,7 +393,7 @@ export const FIELD_DOCS = {
393
393
  'runTurn.promoted': 'Tools this reply already had when an earlier run of it paused; the turn opens with them on its list.',
394
394
  'runTurn.providerState': 'Native provider state saved alongside portable history.',
395
395
  'runTurn.resolveHost': 'Resolves the host name of a remote tool before each request; a name that resolves to a private address is refused.',
396
- 'runTurn.sessionId': 'A session key that OpenRouter uses for routing and caching.',
396
+ 'runTurn.sessionId': "A session key a provider may use to route and cache this session's calls together.",
397
397
  'runTurn.sessionPermissions': 'The tools the user has already approved for this session.',
398
398
  'runTurn.signal': 'Stops the run when it aborts, and cancels its provider call where the provider can.',
399
399
  'runTurn.speech': "This turn's voice, style, and speed; each one given replaces the profile's speech field of that name. Refused on a profile that is not speech.",
@@ -591,7 +591,7 @@ export const OPTION_DOCS = {
591
591
  always_confirm: 'Asks every time.',
592
592
  },
593
593
  TOOL_TYPES: {
594
- builtin: "The provider's own tool, such as Google Search, run by the provider.",
594
+ builtin: "The provider's own tool, such as its web search, run by the provider.",
595
595
  function: 'Your handler runs it.',
596
596
  http: 'The kernel calls your HTTP endpoint.',
597
597
  mcp: 'The kernel calls a tool on a remote MCP server.',
@@ -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,14 +52,15 @@ 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';
62
- export { systemLinesProblem } from './system-lines.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
+ export type { SystemReadingLine } from './system-lines.js';
63
+ export { systemLinesProblem, systemReading } from './system-lines.js';
63
64
  export { systemPromptProblem } from './system-parts.js';
64
65
  export { activityLabelProblem } from './tools/activity-label.js';
65
66
  export { agentToolInputFor, agentToolOutput } from './tools/agent.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,11 +31,11 @@ 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';
38
- export { systemLinesProblem } from './system-lines.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
+ export { systemLinesProblem, systemReading } from './system-lines.js';
39
39
  export { systemPromptProblem } from './system-parts.js';
40
40
  export { activityLabelProblem } from './tools/activity-label.js';
41
41
  export { agentToolInputFor, agentToolOutput } from './tools/agent.js';
@@ -134,7 +134,7 @@ export const PROFILE_FIELD_PRESENCE = {
134
134
  'image.outputCompression': { unset: 'Provider default' },
135
135
  'image.references': { unset: 'None' },
136
136
  'image.includeText': { unset: 'Off', value: false },
137
- 'speech.voice': { unset: "The turn's speech.voice; Gemini refuses speech without one" },
137
+ 'speech.voice': { unset: "The turn's speech.voice, else the provider's own, if it has one" },
138
138
  'speech.style': { unset: "The turn's speech.style, else no direction" },
139
139
  'speech.speed': { unset: "The turn's speech.speed, else the voice's own pace" },
140
140
  'speech.format': { unset: 'Provider default' },
@@ -43,8 +43,8 @@ export declare const commonModelSettingsSchema: z.ZodObject<{
43
43
  */
44
44
  summaries: z.ZodOptional<z.ZodBoolean>;
45
45
  /**
46
- * The provider's own tools, such as Google Search, this model may use; each must be registered as
47
- * a builtin tool and declared by the provider's adapter.
46
+ * The provider's own tools, such as its web search, this model may use; each must be registered
47
+ * as a builtin tool and declared by the provider's adapter.
48
48
  */
49
49
  builtInTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
50
50
  /**
@@ -58,13 +58,13 @@ export interface ModelBinding extends z.infer<typeof commonModelSettingsSchema>
58
58
  /** The API shape this model is spoken to in. */
59
59
  protocol: string;
60
60
  /**
61
- * The service that runs the model or routes requests to one, such as Gemini or OpenRouter. Its
62
- * registration supplies the endpoint and authentication.
61
+ * The service that runs the model or routes requests to one. Its registration supplies the
62
+ * endpoint and authentication.
63
63
  */
64
64
  provider: string;
65
65
  /**
66
- * The model's id as the provider lists it, such as gemini-2.5-flash; sent on every call. The name
67
- * this model has in the profile is its key in models.
66
+ * The model's id as the provider lists it; sent on every call. The name this model has in the
67
+ * profile is its key in models.
68
68
  */
69
69
  apiId: string;
70
70
  /**
@@ -27,7 +27,7 @@ const modelBinding = z.strictObject({
27
27
  protocol: z.string().min(1).describe('The API shape this model is spoken to in.'),
28
28
  provider: z.string().min(1).describe(
29
29
  // labels-exempt: builder field description, read by the studio and docs
30
- 'The service that runs the model or routes requests to one, such as Gemini or OpenRouter. Its registration supplies the endpoint and authentication.'),
30
+ 'The service that runs the model or routes requests to one. Its registration supplies the endpoint and authentication.'),
31
31
  // labels-exempt: builder field description, read by the studio and docs
32
32
  apiId: z.string().min(1).describe('The id the provider knows the model by.'),
33
33
  maxOutputTokens: shared.maxOutputTokens.describe(
@@ -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. */
@@ -268,7 +264,7 @@ export const AUTH_UNAUTHENTICATED_POLICIES = [
268
264
  ];
269
265
  /** The kinds of tool a profile can list. */
270
266
  export const TOOL_TYPES = [
271
- /** The provider's own tool, such as Google Search, run by the provider. */
267
+ /** The provider's own tool, such as its web search, run by the provider. */
272
268
  'builtin',
273
269
  /** Your handler runs it. */
274
270
  'function',
@@ -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 = {
@@ -33,6 +33,12 @@ export type StageCallBag = {
33
33
  approved?: true;
34
34
  callNotStarted?: boolean;
35
35
  outputRaw?: unknown;
36
+ /**
37
+ * `post_tool`: the output as the model reads it, before it becomes text: `outputRaw` without
38
+ * the fields its schema marks `exposeToModel: false`. Absent when the call failed or the tool
39
+ * is hidden from the model.
40
+ */
41
+ outputForModel?: unknown;
36
42
  outputModel?: ModelToolResult;
37
43
  /** `post_tool`: the tool's past activity label, filled from the input and `outputRaw`. */
38
44
  activityPast?: string;
@@ -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)
@@ -1,3 +1,4 @@
1
+ import { type Line } from './tools/activity-label.js';
1
2
  import type { ProfileOptions, ProfileSystem, SystemPiece } from './types.js';
2
3
  /** What is wrong with a prompt's options and lines, or undefined. */
3
4
  export declare function systemLinesProblem(prompt: ProfileSystem, code: ProfileOptions | undefined, person: ProfileOptions | undefined): string | undefined;
@@ -11,6 +12,17 @@ export type KeptSystemLine = {
11
12
  * line dropped on this turn never changes the marks of one that stayed.
12
13
  */
13
14
  export declare function pickSystemLines(prompt: ProfileSystem, facts: Record<string, string>, fill: (text: string) => string | undefined): KeptSystemLine[];
15
+ /** One line of a prompt as the kernel reads it: the turns it fits, and its pieces. */
16
+ export type SystemReadingLine = {
17
+ when: Line['when'];
18
+ pieces: SystemPiece[];
19
+ };
20
+ /**
21
+ * A prompt as the kernel reads it: each line's `when`, and its pieces, plain text marked the way
22
+ * the whole prompt settles it, with pieces of one mark side by side joined and empty ones left
23
+ * out. Two prompts with the same reading send the same words, with the same marks, on every turn.
24
+ */
25
+ export declare function systemReading(prompt: ProfileSystem): SystemReadingLine[];
14
26
  /** `where` names the prompt in the error. A bare `{ private }` must sit inside a line's own list. */
15
27
  export declare function assertSystemLines(prompt: unknown, where: string): asserts prompt is ProfileSystem;
16
28
  /** The first tool in `tools` with a path `options.path` does not list, as a sentence. */
@@ -87,6 +87,31 @@ export function pickSystemLines(prompt, facts, fill) {
87
87
  }
88
88
  return kept;
89
89
  }
90
+ /**
91
+ * A prompt as the kernel reads it: each line's `when`, and its pieces, plain text marked the way
92
+ * the whole prompt settles it, with pieces of one mark side by side joined and empty ones left
93
+ * out. Two prompts with the same reading send the same words, with the same marks, on every turn.
94
+ */
95
+ export function systemReading(prompt) {
96
+ const lines = linesOf(prompt);
97
+ const marked = lines.flat().some((part) => typeof part !== 'string');
98
+ return lines.map((parts) => {
99
+ const line = headOf(parts);
100
+ const pieces = [];
101
+ parts.forEach((part, at) => {
102
+ const text = at === 0 ? line.text : textOf(part);
103
+ if (!text)
104
+ return;
105
+ const isPrivate = typeof part === 'string' ? !marked : true;
106
+ const last = pieces.at(-1);
107
+ if (last?.private === isPrivate)
108
+ last.text += text;
109
+ else
110
+ pieces.push({ text, private: isPrivate });
111
+ });
112
+ return { when: line.when, pieces };
113
+ });
114
+ }
90
115
  /** `where` names the prompt in the error. A bare `{ private }` must sit inside a line's own list. */
91
116
  export function assertSystemLines(prompt, where) {
92
117
  if (typeof prompt === 'string')
@@ -42,6 +42,7 @@ export declare class HandOff {
42
42
  }
43
43
  export declare function dispatchToolBody(tool: {
44
44
  labels?: ToolLabels;
45
+ inputSchema?: Record<string, unknown>;
45
46
  }, input: unknown, ctx: ToolContext, base: ToolCallBase, beginBody?: (preparedInput: unknown) => Promise<ToolOperationClaim | undefined>): AsyncGenerator<TurnEvent, HandOff>;
46
47
  export declare function startToolExecution<T>(tool: {
47
48
  input: z.ZodType<T>;
@@ -8,6 +8,7 @@ import { sourceSchema } from '../turn-events.js';
8
8
  import { isRecord } from '../util/record.js';
9
9
  import { fillActivityLabel, toolNameInWords } from './activity-label.js';
10
10
  import { formatToolFailureForModel, formatToolResult } from './model-text.js';
11
+ import { inputForModel } from './model-view.js';
11
12
  export function toolEvent(base, patch) {
12
13
  return {
13
14
  type: 'tool',
@@ -107,7 +108,14 @@ function toolRunningEvent(tool, rawInput, ctx, base) {
107
108
  const activity = fillActivityLabel(tool.labels?.activity, { input: rawInput });
108
109
  return toolEvent(base, {
109
110
  phase: 'running',
110
- ...(edited ? { edited: { from: edited.from, to: toolCallArguments(rawInput) } } : {}),
111
+ ...(edited
112
+ ? {
113
+ edited: {
114
+ from: edited.from,
115
+ to: toolCallArguments(inputForModel(tool.inputSchema ?? {}, rawInput)),
116
+ },
117
+ }
118
+ : {}),
111
119
  ...(activity ? { activity } : {}),
112
120
  });
113
121
  }
@@ -86,6 +86,8 @@ interface RegisteredToolCall {
86
86
  agents?: AgentCaller;
87
87
  /** The canary and system instruction of the turn the model called from, read for in the arguments. */
88
88
  scope?: DetectScope;
89
+ /** The model made the call: a field its input schema keeps from the model is refused. */
90
+ fromModel?: boolean;
89
91
  }
90
92
  /**
91
93
  * A gate nobody answered: a sign-in for `expiredService` whose link expired, or any other gate