@theoremjs/agents 0.3.4-next.679.gcdf1a3a → 0.3.4-next.711.g78e504a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/esm/mod.d.ts +6 -3
- package/esm/mod.js +3 -1
- package/esm/src/cli/commands/bench.js +4 -10
- package/esm/src/cli/commands/profile.js +4 -1
- package/esm/src/guardrails/labels.d.ts +1 -1
- package/esm/src/guardrails/labels.js +9 -0
- package/esm/src/interface/blocks.js +19 -0
- package/esm/src/interface/from-profile.d.ts +2 -2
- package/esm/src/interface/from-profile.js +7 -0
- package/esm/src/interface/history.d.ts +2 -2
- package/esm/src/interface/history.js +7 -4
- package/esm/src/interface/mod.d.ts +2 -2
- package/esm/src/interface/mod.js +1 -1
- package/esm/src/interface/profile-interface.js +14 -4
- package/esm/src/interface/tool-calls.d.ts +3 -3
- package/esm/src/interface/tool-calls.js +5 -8
- package/esm/src/interface/tool-invoke.d.ts +3 -1
- package/esm/src/interface/tool-invoke.js +6 -1
- package/esm/src/interface/types.d.ts +7 -5
- package/esm/src/kernel/api-catalog.js +13 -5
- package/esm/src/kernel/auth/oauth.js +3 -1
- package/esm/src/kernel/engine/background.d.ts +7 -0
- package/esm/src/kernel/engine/background.js +18 -0
- package/esm/src/kernel/engine/runner/mod.js +24 -1
- package/esm/src/kernel/engine/runner/state.d.ts +4 -0
- package/esm/src/kernel/engine/runner/state.js +1 -0
- package/esm/src/kernel/engine/runner/step-order.d.ts +8 -0
- package/esm/src/kernel/engine/runner/step-order.js +1 -1
- package/esm/src/kernel/engine/runner/steps.js +1 -0
- package/esm/src/kernel/engine/session/mod.d.ts +2 -0
- package/esm/src/kernel/engine/session/mod.js +20 -2
- package/esm/src/kernel/engine/session/session-trace.js +1 -0
- package/esm/src/kernel/mod.d.ts +6 -3
- package/esm/src/kernel/mod.js +3 -1
- package/esm/src/kernel/profile-presence.js +1 -0
- package/esm/src/kernel/profile-scope.js +23 -21
- package/esm/src/kernel/protocols/protocol.d.ts +1 -1
- package/esm/src/kernel/protocols/protocol.js +1 -0
- package/esm/src/kernel/registry/catalog.js +4 -1
- package/esm/src/kernel/registry/ingress.d.ts +3 -1
- package/esm/src/kernel/registry/ingress.js +12 -1
- package/esm/src/kernel/registry/profile-outputs.js +2 -1
- package/esm/src/kernel/registry/profiles.d.ts +12 -2
- package/esm/src/kernel/registry/profiles.js +37 -7
- package/esm/src/kernel/registry/resolve.js +9 -5
- package/esm/src/kernel/registry/system-prompt.d.ts +6 -1
- package/esm/src/kernel/registry/system-prompt.js +20 -13
- package/esm/src/kernel/schema.d.ts +1 -1
- package/esm/src/kernel/schema.js +24 -8
- package/esm/src/kernel/system-lines.d.ts +22 -0
- package/esm/src/kernel/system-lines.js +162 -0
- package/esm/src/kernel/tools/activity-label.d.ts +15 -0
- package/esm/src/kernel/tools/activity-label.js +12 -7
- package/esm/src/kernel/tools/agent.js +1 -1
- package/esm/src/kernel/tools/background.d.ts +81 -0
- package/esm/src/kernel/tools/background.js +70 -0
- package/esm/src/kernel/tools/call-order.d.ts +18 -0
- package/esm/src/kernel/tools/call-order.js +52 -0
- package/esm/src/kernel/tools/coordinate.d.ts +8 -1
- package/esm/src/kernel/tools/coordinate.js +274 -34
- package/esm/src/kernel/tools/execute.d.ts +2 -0
- package/esm/src/kernel/tools/execute.js +17 -4
- package/esm/src/kernel/tools/invoke.js +40 -13
- package/esm/src/kernel/tools/memory-execution.js +10 -1
- package/esm/src/kernel/tools/operation.d.ts +21 -0
- package/esm/src/kernel/tools/operation.js +19 -10
- package/esm/src/kernel/tools/registry.js +28 -6
- package/esm/src/kernel/tools/resolve.d.ts +4 -2
- package/esm/src/kernel/tools/resolve.js +34 -7
- package/esm/src/kernel/tools/run.d.ts +2 -2
- package/esm/src/kernel/tools/run.js +4 -1
- package/esm/src/kernel/tools/stage-run.d.ts +3 -1
- package/esm/src/kernel/tools/stage-run.js +58 -55
- package/esm/src/kernel/tools/types.d.ts +10 -0
- package/esm/src/kernel/turn-events.d.ts +8 -1
- package/esm/src/kernel/turn-events.js +2 -0
- package/esm/src/kernel/types.d.ts +39 -4
- package/esm/src/observability/trace-catalog.js +3 -0
- package/esm/src/providers/google/interactions/steps.js +14 -3
- package/esm/src/providers/mod.d.ts +2 -0
- package/esm/src/providers/mod.js +1 -0
- package/esm/src/providers/open-ai/protocol.js +8 -4
- package/esm/src/providers/openrouter/protocol.d.ts +26 -0
- package/esm/src/providers/openrouter/protocol.js +58 -2
- package/esm/src/providers/openrouter/provider.d.ts +1 -1
- package/esm/src/providers/openrouter/provider.js +3 -1
- package/esm/src/providers/openrouter/transcriptions-protocol.d.ts +10 -0
- package/esm/src/providers/openrouter/transcriptions-protocol.js +87 -0
- package/package.json +1 -1
- package/esm/src/kernel/registry/system-role.d.ts +0 -3
- package/esm/src/kernel/registry/system-role.js +0 -9
package/README.md
CHANGED
|
@@ -188,6 +188,7 @@ Use the `type` field to choose what the agent does. The type sets the shape of t
|
|
|
188
188
|
| `text` | `runTurn` | text, attachments, voice notes, slots, history | text, thoughts, validated JSON, tool calls | `geminiInteractions`, `openRouterOpenAi`, `openAi` |
|
|
189
189
|
| `image` | `runTurn` | prompt + reference images | images, optionally with interleaved text | `geminiInteractions`, `openRouterImages` |
|
|
190
190
|
| `speech` | `runTurn` | text | audio (WAV, or MP3 on OpenRouter) | `geminiInteractions`, `openRouterOpenAi`, `openAi` |
|
|
191
|
+
| `transcription` | `runTurn` | one voice clip | the words in the clip, as text | `openRouterTranscriptions` |
|
|
191
192
|
| `live` | `runSession` | realtime mic audio, camera frames, typed text | streamed audio, transcripts, tool calls | `geminiLive` |
|
|
192
193
|
| `host` | `invokeTool`, `invokeToolStep`, `runTool`, `runToolStep` | tool calls from your own code, one at a time or as a step; the `run` pair gives how each call ended | guarded tool results | none; it never calls a model |
|
|
193
194
|
| `decision` | `runDecision` | non-null JSON state plus declared questions | typed choices, probabilities, scores, boxes, or `noul` | `systemOne`, `openRouterDecisions` |
|
|
@@ -317,7 +318,7 @@ The binding under `models` names the protocol, the registered provider ID, and t
|
|
|
317
318
|
| Provider | ID | Protocols |
|
|
318
319
|
| :--- | :--- | :--- |
|
|
319
320
|
| `geminiProvider` | `gemini` | `geminiInteractions` (text, image, speech), `geminiLive` (live), `geminiEmbeddings` (embedding) |
|
|
320
|
-
| `openRouterProvider` | `openrouter` | `openRouterOpenAi` (text, speech), `openRouterImages` (image), `openRouterDecisions` (decision), `openRouterEmbeddings` (embedding) |
|
|
321
|
+
| `openRouterProvider` | `openrouter` | `openRouterOpenAi` (text, speech), `openRouterImages` (image), `openRouterTranscriptions` (transcription), `openRouterDecisions` (decision), `openRouterEmbeddings` (embedding) |
|
|
321
322
|
| `typesafeProvider` | `typesafe` | `systemOne` (decision) |
|
|
322
323
|
| `localProvider` | `local` | `openAi` (text, speech), `ollamaEmbeddings` (embedding), for a server such as Ollama |
|
|
323
324
|
|
|
@@ -461,9 +462,9 @@ Named exports from the root barrel (same symbols hosts get from `@theoremjs/agen
|
|
|
461
462
|
| Catalog | `clampThinkingLevel`, `clampThinkingLevelForApiId`, `mediaChannelForMime`, `MediaInputChannel`, `mediaKindForMime`, `mimeAllowed`, `mimeEssence`, `modelEntryByApiId`, `requireModelBinding` |
|
|
462
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
464
|
| Scope | `KernelScope`, `createKernelScope`, `defaultKernelScope`, `KernelRegistry`, `createKernelRegistry` |
|
|
464
|
-
| Profiles | `ProfileDefinition`, `ProfileDefinitionBase`, `TextProfileDefinition`, `ImageProfileDefinition`, `SpeechProfileDefinition`, `LiveProfileDefinition`, `HostProfileDefinition`, `DecisionProfileDefinition`, `EmbeddingProfileDefinition`, `ProfileRegistry`, `createProfileRegistry`, `clearProfiles`, `defineProfile`, `getProfile`, `hasProfile`, `listProfiles`, `registerProfile`, `registerProfiles`, `projectProfile`, `resolveTurn`, `pickModel` |
|
|
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` |
|
|
465
466
|
| Tools | `ToolContext`, `GateReference`, `gateReferenceSchema`, `ToolRegistry`, `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` |
|
|
466
|
-
| Tool execution | `ToolExecutionCoordinator`, `createMemoryToolExecution`, `MemoryToolExecutionOptions`, `authorizeToolReplay`, `BeginToolOperationResult`, `ToolOperationClaim`, `ToolOperationIdentity`, `ToolOperationOutcome`, `ToolOperationUncertainty`, `toolOperationOutcomeSchema`, `SavedToolInvocation`, `savedToolInvocationSchema`, `toolInvocationHash`, `TerminalToolEvent`, `PageToolDispatch`, `PageToolExecution` |
|
|
467
|
+
| Tool execution | `ToolBackground`, `ToolBackgroundCall`, `ToolBackgroundHandle`, `ToolBackgroundService`, `ToolOperationReply`, `toolOperationReplySchema`, `BackgroundToolEvent`, `ToolExecutionCoordinator`, `createMemoryToolExecution`, `MemoryToolExecutionOptions`, `authorizeToolReplay`, `BeginToolOperationResult`, `ToolOperationClaim`, `ToolOperationIdentity`, `ToolOperationOutcome`, `ToolOperationUncertainty`, `toolOperationOutcomeSchema`, `SavedToolInvocation`, `savedToolInvocationSchema`, `toolInvocationHash`, `TerminalToolEvent`, `PageToolDispatch`, `PageToolExecution` |
|
|
467
468
|
| Structured | `SchemaRegistry`, `createSchemaRegistry`, `getStructured`, `registerStructured` |
|
|
468
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
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,7 +472,7 @@ Named exports from the root barrel (same symbols hosts get from `@theoremjs/agen
|
|
|
471
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`) |
|
|
472
473
|
| Providers | `registerProvider`, `getProvider`, `listProviders`, `listProtocols`, `createProviderRegistry`, `defineProvider`, `Provider`, `ProviderDefinition`, `Registration`, `RegisteredProvider`, `ProviderRegistry`, `geminiProvider`, `openRouterProvider`, `typesafeProvider`, `localProvider` |
|
|
473
474
|
| Provider sign-in | `bearer`, `header`, `query`, `Authorize`, `Signer`, `Outgoing`, `Serve`, `endpointUrlSchema` |
|
|
474
|
-
| Protocols | `defineProtocol`, `extendProtocol`, `carriesTo`, `modelOptions`, `geminiInteractions`, `geminiLive`, `geminiEmbeddings`, `openAi`, `openRouterOpenAi`, `openRouterImages`, `openRouterDecisions`, `openRouterEmbeddings`, `ollamaEmbeddings`, `systemOne`, `Protocol`, `ProtocolDefinition`, `ProtocolExtension`, `ExtensionBodyAt`, `ExtensionReader`, `ModelProfileType` |
|
|
475
|
+
| Protocols | `defineProtocol`, `extendProtocol`, `carriesTo`, `modelOptions`, `geminiInteractions`, `geminiLive`, `geminiEmbeddings`, `openAi`, `openRouterOpenAi`, `openRouterImages`, `openRouterTranscriptions`, `openRouterDecisions`, `openRouterEmbeddings`, `ollamaEmbeddings`, `systemOne`, `Protocol`, `ProtocolDefinition`, `ProtocolExtension`, `ExtensionBodyAt`, `ExtensionReader`, `ModelProfileType` |
|
|
475
476
|
| Protocol operations | `ProtocolContext`, `ProtocolOperations`, `ProtocolRequest`, `ProtocolSession`, `ProtocolSocket`, `ProtocolEvent`, `ProtocolContentEvent`, `SendInit`, `UpstreamFailure`, `Continuation`, `DecisionCall`, `EmbeddingCall`, `LiveToolResult`, `callProtocol`, `ProtocolCall`, `CallSetup` |
|
|
476
477
|
| Model bindings | `ModelBinding`, `DecisionModelBinding`, `modelBindingSchema`, `decisionModelBindingSchema`, `commonModelSettingsSchema`, `keySlotSchema`, `checkBinding`, `keySlotsOf`, `RuntimeAbilities` |
|
|
477
478
|
| Provider data | `JsonValue`, `JsonObject`, `jsonValueSchema`, `jsonObjectSchema`, `PriceTable`, `ModelPrice`, `Rates` |
|
package/esm/mod.d.ts
CHANGED
|
@@ -50,11 +50,12 @@ export type { EmbeddingRules } from './src/kernel/registry/embedding-rules.js';
|
|
|
50
50
|
export { embeddingMediaIssues, embeddingRules } from './src/kernel/registry/embedding-rules.js';
|
|
51
51
|
export type { KernelRegistry } from './src/kernel/registry/kernel-registry.js';
|
|
52
52
|
export { createKernelRegistry } from './src/kernel/registry/kernel-registry.js';
|
|
53
|
-
export type { EmbeddingProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, } from './src/kernel/registry/profiles.js';
|
|
53
|
+
export type { EmbeddingProfileDefinition, ImageProfileDefinition, LiveProfileDefinition, ProfileDefinition, ProfileDefinitionBase, ProfileRegistry, SpeechProfileDefinition, TextProfileDefinition, TranscriptionProfileDefinition, } from './src/kernel/registry/profiles.js';
|
|
54
54
|
export { createProfileRegistry, defineProfile } from './src/kernel/registry/profiles.js';
|
|
55
55
|
export { pickModel } from './src/kernel/registry/resolve.js';
|
|
56
56
|
export type { SchemaRegistry } from './src/kernel/registry/schemas.js';
|
|
57
57
|
export { createSchemaRegistry } from './src/kernel/registry/schemas.js';
|
|
58
|
+
export { resolveTurnSystemPrompt } from './src/kernel/registry/system-prompt.js';
|
|
58
59
|
export type { AuthUnauthenticatedPolicy, ContinueStopKind, CustomToolType, HttpMethod, StepLimitMode, StudioAuthType, ToolAccess, ToolAuthType, ToolPermission, ToolType, TurnStopKind, } from './src/kernel/schema.js';
|
|
59
60
|
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';
|
|
60
61
|
export type { KernelScope } from './src/kernel/scope.js';
|
|
@@ -63,14 +64,16 @@ export type { AwaitingUserInput, StageAffordance, StageApplyInput, StageApplyOut
|
|
|
63
64
|
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './src/kernel/stages.js';
|
|
64
65
|
export type { MediaTurnBehaviourSpec, ProfileTurnBehaviourSpec, ProfileTurnResumptionSpec, TurnContinueFrom, TurnStop, } from './src/kernel/stop.js';
|
|
65
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';
|
|
67
|
+
export { systemLinesProblem } from './src/kernel/system-lines.js';
|
|
68
|
+
export type { ToolBackground, ToolBackgroundCall, ToolBackgroundHandle, ToolBackgroundService, } from './src/kernel/tools/background.js';
|
|
66
69
|
export { authorizeToolReplay } from './src/kernel/tools/execute.js';
|
|
67
70
|
export { GATE_DECISIONS, type GateDecision } from './src/kernel/tools/gate-answer.js';
|
|
68
71
|
export type { MemoryToolExecutionOptions } from './src/kernel/tools/memory-execution.js';
|
|
69
72
|
export { createMemoryToolExecution } from './src/kernel/tools/memory-execution.js';
|
|
70
73
|
export type { CredentialQuery, McpProtocolVersion, McpRpcResponse, ToolRegistry, } from './src/kernel/tools/mod.js';
|
|
71
74
|
export { askUserTool, buildHttpToolTarget, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, formatToolResult, isUnsupportedMcpProtocolError, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, registerHarnessTools, resolveToolAuth, UncheckedOutput, uncheckedOutput, withCredentialQuery, } from './src/kernel/tools/mod.js';
|
|
72
|
-
export type { BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationUncertainty, } from './src/kernel/tools/operation.js';
|
|
73
|
-
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './src/kernel/tools/operation.js';
|
|
75
|
+
export type { BackgroundToolEvent, BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationReply, ToolOperationUncertainty, } from './src/kernel/tools/operation.js';
|
|
76
|
+
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './src/kernel/tools/operation.js';
|
|
74
77
|
export type { SettledToolCall, ToolCallResult, ToolStepCallResult, } from './src/kernel/tools/run.js';
|
|
75
78
|
export type { ModelToolResult, PageAnswer, ToolContext } from './src/kernel/tools/types.js';
|
|
76
79
|
export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './src/kernel/turn-events.js';
|
package/esm/mod.js
CHANGED
|
@@ -35,15 +35,17 @@ export { createKernelRegistry } from './src/kernel/registry/kernel-registry.js';
|
|
|
35
35
|
export { createProfileRegistry, defineProfile } from './src/kernel/registry/profiles.js';
|
|
36
36
|
export { pickModel } from './src/kernel/registry/resolve.js';
|
|
37
37
|
export { createSchemaRegistry } from './src/kernel/registry/schemas.js';
|
|
38
|
+
export { resolveTurnSystemPrompt } from './src/kernel/registry/system-prompt.js';
|
|
38
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';
|
|
39
40
|
export { createKernelScope, defaultKernelScope } from './src/kernel/scope.js';
|
|
40
41
|
export { applyStageResult, STAGE_AFFORDANCE_MATRIX, STAGE_AFFORDANCES, stageAllowsAffordance, stageEventFields, } from './src/kernel/stages.js';
|
|
41
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';
|
|
43
|
+
export { systemLinesProblem } from './src/kernel/system-lines.js';
|
|
42
44
|
export { authorizeToolReplay } from './src/kernel/tools/execute.js';
|
|
43
45
|
export { GATE_DECISIONS } from './src/kernel/tools/gate-answer.js';
|
|
44
46
|
export { createMemoryToolExecution } from './src/kernel/tools/memory-execution.js';
|
|
45
47
|
export { askUserTool, buildHttpToolTarget, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, formatToolResult, isUnsupportedMcpProtocolError, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, registerHarnessTools, resolveToolAuth, UncheckedOutput, uncheckedOutput, withCredentialQuery, } from './src/kernel/tools/mod.js';
|
|
46
|
-
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, } from './src/kernel/tools/operation.js';
|
|
48
|
+
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './src/kernel/tools/operation.js';
|
|
47
49
|
export { awaitingUserInputSchema, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './src/kernel/turn-events.js';
|
|
48
50
|
export { buildRecord, clearTraceDestinations, contentOf, getTraceDestination, inlineContent, isTraceSink, listTraceDestinationIds, memorySink, noopSink, readTraceparent, registerTraceDestination, requireTraceDestination, resolveObservabilityPolicy, resolveTraceWriter, startTrace, TRACE_ATTRIBUTE_GROUPS, TRACE_FIELDS, TRACE_SPAN_TYPES, TRACE_STATUS, toOtlpJson, traceAttributeMeta, traceBytes, traceContent, traceEventAttributeMeta, traceEventMeta, traceJson, traceRecordSchema, traceSpanMeta, writeTrace, } from './src/observability/mod.js';
|
|
49
51
|
export * from './src/providers/mod.js';
|
|
@@ -8,7 +8,6 @@ import { sanitizeTurnRequest } from '../../guardrails/sanitize.js';
|
|
|
8
8
|
import { clearProfiles, getProfile, getProvider, registerProfile, registerProvider, resolveTurn, runTurn, } from '../../kernel/default-scope.js';
|
|
9
9
|
import { startCallUsage } from '../../kernel/engine/runner/usage.js';
|
|
10
10
|
import { startCallTrace } from '../../kernel/engine/turn-trace.js';
|
|
11
|
-
import { pickSystemRole } from '../../kernel/registry/system-role.js';
|
|
12
11
|
import { bindSystem } from '../../kernel/system-parts.js';
|
|
13
12
|
import { resolveObservabilityPolicy } from '../../observability/resolve-policy.js';
|
|
14
13
|
import { buildRecord } from '../../observability/trace-record.js';
|
|
@@ -247,18 +246,15 @@ function measureSetupPhases() {
|
|
|
247
246
|
const t0 = performance.now();
|
|
248
247
|
const safe = sanitizeTurnRequest(req, getProfile(req.profile));
|
|
249
248
|
const t1 = performance.now();
|
|
250
|
-
const {
|
|
249
|
+
const { generation } = resolveTurn(safe);
|
|
251
250
|
const t2 = performance.now();
|
|
252
|
-
pickSystemRole(profile, safe.input?.role);
|
|
253
|
-
const t3 = performance.now();
|
|
254
251
|
bindSystem(generation.resolvedSystem, [canaryNote(generation.canary)]);
|
|
255
|
-
const
|
|
252
|
+
const t3 = performance.now();
|
|
256
253
|
return {
|
|
257
254
|
sanitizeMs: t1 - t0,
|
|
258
255
|
resolveMs: t2 - t1,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
totalSetupMs: t4 - t0,
|
|
256
|
+
canaryMs: t3 - t2,
|
|
257
|
+
totalSetupMs: t3 - t0,
|
|
262
258
|
};
|
|
263
259
|
}
|
|
264
260
|
function printPhaseBreakdown(iterations) {
|
|
@@ -272,14 +268,12 @@ function printPhaseBreakdown(iterations) {
|
|
|
272
268
|
};
|
|
273
269
|
const sanitize = median(results.map((r) => r.sanitizeMs));
|
|
274
270
|
const resolve = median(results.map((r) => r.resolveMs));
|
|
275
|
-
const system = median(results.map((r) => r.systemMs));
|
|
276
271
|
const canary = median(results.map((r) => r.canaryMs));
|
|
277
272
|
const total = median(results.map((r) => r.totalSetupMs));
|
|
278
273
|
console.log('\nSetup Phase Breakdown (median)');
|
|
279
274
|
console.log('─'.repeat(72));
|
|
280
275
|
console.log(` sanitizeTurnRequest ${fmtMs(sanitize).padStart(10)}`);
|
|
281
276
|
console.log(` resolveTurn ${fmtMs(resolve).padStart(10)}`);
|
|
282
|
-
console.log(` pickSystemRole ${fmtMs(system).padStart(10)}`);
|
|
283
277
|
console.log(` bindSystem ${fmtMs(canary).padStart(10)}`);
|
|
284
278
|
console.log(` ─────────────────────────────`);
|
|
285
279
|
console.log(` Total setup ${fmtMs(total).padStart(10)}`);
|
|
@@ -7,6 +7,9 @@ function formatProfileInputs(p) {
|
|
|
7
7
|
if (p.type === 'live') {
|
|
8
8
|
return 'audio/video (live)';
|
|
9
9
|
}
|
|
10
|
+
if (p.type === 'transcription') {
|
|
11
|
+
return 'voice';
|
|
12
|
+
}
|
|
10
13
|
const inputs = [];
|
|
11
14
|
const { inputs: spec } = p;
|
|
12
15
|
if (!spec) {
|
|
@@ -41,7 +44,7 @@ function printProfileCard(p) {
|
|
|
41
44
|
return;
|
|
42
45
|
}
|
|
43
46
|
const models = Object.keys(p.models).join(', ') || 'default';
|
|
44
|
-
const structured = p.type === 'live' || p.type === 'speech' || p.type === 'embedding'
|
|
47
|
+
const structured = p.type === 'live' || p.type === 'speech' || p.type === 'transcription' || p.type === 'embedding'
|
|
45
48
|
? undefined
|
|
46
49
|
: p.outputs?.structured;
|
|
47
50
|
const structuredLabel = typeof structured === 'string' ? structured : structured ? 'custom' : 'none';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Values that fill a label template's `{param}` placeholders. */
|
|
2
2
|
export type LabelParams = Record<string, string | number>;
|
|
3
3
|
/** Keys are stable API. */
|
|
4
|
-
export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
|
|
4
|
+
export declare const LABEL_KEYS: readonly ["provider.decision_failed", "provider.decision_unavailable", "provider.decision_model_missing", "provider.decision_ended", "provider.decision_images_off", "provider.decision_box_model", "provider.budget_exhausted", "provider.adapter_version", "provider.adapter_methods", "provider.adapter_schemas", "provider.fallback_slot", "provider.model_fallback_slot", "provider.host_model", "provider.turn_profile", "provider.model_binding_missing", "provider.session_closed", "provider.settled_call", "provider.session_unavailable", "provider.live_input", "provider.tool_cancel_missing", "provider.kernel_gate", "provider.event_invalid", "provider.response_identity", "provider.credential_resolution", "provider.credential_shape", "provider.stored_continuation", "provider.continuation_mismatch", "provider.continuation_contract", "provider.stateless_history", "provider.events_after_completion", "provider.duplicate_call", "provider.tool_cancel_live", "provider.complete_unavailable", "provider.parallel_tools", "provider.binding_identity", "provider.profile_type", "provider.event_type", "provider.feature", "provider.input_kind", "provider.output_kind", "provider.builtin", "provider.credential_missing", "provider.profile_configuration", "continue.instruction", "canary.bind_note", "user_data.note", "context.note", "taint.blocked", "taint.reason_steered", "taint.reason_tainted", "taint.destination_blocked", "taint.destination_confirm", "advisory.notice_elevated", "advisory.notice_high", "advisory.guidance", "attachments.too_many_files", "attachments.too_many_of_kind", "attachments.file_too_large", "attachments.turn_too_large", "attachments.not_accepted", "attachments.mime_not_allowed", "attachments.limits_unconfigured", "quota.exhausted", "quota.busy", "error.config", "error.request", "error.conflict", "error.not_found", "error.input", "error.action", "error.auth", "error.rate_limit", "error.busy", "error.unsupported", "error.unavailable", "error.bad_response", "error.network", "error.timeout", "error.safety", "error.blocked", "error.declined", "error.failed", "error.cancelled", "error.internal", "repair.default_guidance", "repair.items_guidance", "repair.prompt_header", "repair.prompt_intro", "repair.prompt_instructions", "repair.history_heading", "repair.section_previous_output", "repair.section_validator_rejection", "repair.section_repair_guidance", "repair.section_instructions", "structured.answer_tool", "structured.answer_missing", "structured.cut_off", "structured.not_json", "compaction.request", "compaction.tool_call", "compaction.tool_result", "compaction.tool_files", "decision.box_image", "detect.blocked", "detect.call_blocked", "detect.output_blocked", "detect.shown_blocked", "detect.hint.ids", "detect.hint.financial", "detect.hint.network", "detect.hint.credentials", "detect.hint.injection", "detect.hint.tool_instructions", "detect.hint.canary_leak", "detect.hint.prompt_leak", "detect.hint.marker_leak", "detect.hint.ungiven_images", "detect.hint.ungiven_links", "detect.hint.tool_leak", "detect.hint.own", "egress.default_repair_guidance", "egress.refusal", "egress.refusal_cut", "egress.rejection", "egress.rejection_found", "egress.hint_unscannable", "egress.hint_provider_tool_leak", "thought.omitted_image", "thought.omitted_link", "thought.omitted_instructions", "session.abandon_gated", "session.tool_denied", "session.tool_aborted", "session.sign_in", "sign_in.link", "sign_in.pending", "sign_in.done", "sign_in.declined", "sign_in.expired", "sign_in.out_of_scope", "session.gate_expired", "session.provider_state_unowned", "session.conversation_unknown", "session.full", "session.busy", "session.turn_ended", "session.gate_pending", "session.part_skipped", "live.session_ended", "voice.unsupported", "voice.permission", "voice.unavailable", "voice.failed", "voice.empty", "stop.cancelled", "stop.interrupted", "stop.length", "stop.filtered", "stop.provider_error", "stop.stream_incomplete", "stop.step_limit", "composer.model", "composer.effort", "tool.awaiting_user", "tool.completed_hidden", "tool.t2_loader_needs_snapshot", "tool.t2_loader_shape", "tool.t2_loader_output_invalid", "tool.execution_uncertain", "tool.input_invalid", "tool.input_invalid_after_mutate", "tool.output_invalid_after_mutate", "tool.handler_no_output", "tool.did_not_run", "tool.page_no_answer", "tool.page_timed_out", "tool.output_invalid", "tool.not_loaded_t2", "tool.wait_unknown", "tool.wait_cycle", "tool.after_field", "tool.background_field", "tool.background_started", "tool.not_visible", "tool.builtin_not_enabled", "tool.provider_native", "tool.not_registered", "tool.builtin_needs_snapshot", "tool.not_allowed", "tool.not_eligible", "tool.unsupported_type", "tool.agent_call_limit", "tool.agent_failed", "tool.activity_failed", "protocol.not_served", "protocol.profile_type", "protocol.options", "protocol.option_clash", "protocol.base_options", "protocol.id_clash", "protocol.ws_headers", "protocol.builtin_unwritten", "protocol.provider_missing", "protocol.connection", "protocol.part_schema", "protocol.part_invalid", "protocol.key_invalid", "protocol.no_key", "protocol.reply_shape", "protocol.endpoint_url", "protocol.endpoint_host", "protocol.http", "protocol.no_operation", "protocol.definition", "protocol.provider_id_clash", "protocol.history_needed"];
|
|
5
5
|
/** One of {@linkcode LABEL_KEYS}. */
|
|
6
6
|
export type LabelKey = (typeof LABEL_KEYS)[number];
|
|
7
7
|
/**
|
|
@@ -183,6 +183,9 @@ export const LABEL_KEYS = [
|
|
|
183
183
|
'tool.not_loaded_t2',
|
|
184
184
|
'tool.wait_unknown',
|
|
185
185
|
'tool.wait_cycle',
|
|
186
|
+
'tool.after_field',
|
|
187
|
+
'tool.background_field',
|
|
188
|
+
'tool.background_started',
|
|
186
189
|
'tool.not_visible',
|
|
187
190
|
'tool.builtin_not_enabled',
|
|
188
191
|
'tool.provider_native',
|
|
@@ -516,6 +519,9 @@ const DEFAULTS = {
|
|
|
516
519
|
'tool.not_loaded_t2': "Tool '{tool}' is not loaded — call {loader} to load it first",
|
|
517
520
|
'tool.wait_unknown': "Tool '{tool}' waits for calls that are not in this step: {calls}",
|
|
518
521
|
'tool.wait_cycle': "Tool '{tool}' waits for calls that cannot finish before it: {calls}",
|
|
522
|
+
'tool.background_field': 'Set to true to get a reply now and let this call finish after the turn. Leave out to wait for its result.',
|
|
523
|
+
'tool.background_started': '{tool} has started and is still running. You do not have its result, so do not state or guess one, and do not call {tool} again. Tell the person it is under way and that the result comes later.',
|
|
524
|
+
'tool.after_field': 'Tools you are calling in this same step that must finish before this call starts. Leave out to set no order.',
|
|
519
525
|
'tool.not_visible': "Tool '{tool}' is not visible this turn",
|
|
520
526
|
'tool.builtin_not_enabled': "Builtin '{tool}' is not enabled this turn",
|
|
521
527
|
'tool.provider_native': "Tool '{tool}' is a provider builtin — execution is handled by the model provider, not the kernel",
|
|
@@ -735,6 +741,9 @@ export const LABEL_NOTES = {
|
|
|
735
741
|
'tool.not_loaded_t2': 'Told to the model when it calls a T2 tool the T2 loader has not loaded yet. Takes {tool} and {loader}, the loader tool.',
|
|
736
742
|
'tool.wait_unknown': "Told to the model when a call's pre_tool waitFor names calls that are not in its step. Takes {tool} and {calls}.",
|
|
737
743
|
'tool.wait_cycle': "Told to the model when a call's pre_tool waitFor names calls that cannot settle before it, because they wait for it or run after it. Takes {tool} and {calls}.",
|
|
744
|
+
'tool.background_field': "What the model reads on the background field of a tool that sets registerTool.background to ask. Read when the tool registers, so a profile's labels do not change it.",
|
|
745
|
+
'tool.background_started': 'Told to the model when a call goes on after its reply: the call runs in the background and its result comes later.',
|
|
746
|
+
'tool.after_field': "What the model reads on the after field of a tool that sets registerTool.after. Read when the tool registers, so a profile's labels do not change it.",
|
|
738
747
|
'tool.not_visible': 'Told to the model when it calls a tool it cannot see this turn. Takes {tool}.',
|
|
739
748
|
'tool.builtin_not_enabled': 'Told to the model when it calls a provider builtin not turned on this turn. Takes {tool}.',
|
|
740
749
|
'tool.provider_native': 'Told to the model when the kernel is asked to run a provider builtin, which the provider runs itself. Takes {tool}.',
|
|
@@ -248,6 +248,24 @@ function standaloneBlock(event, idPrefix) {
|
|
|
248
248
|
return undefined;
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
|
+
/**
|
|
252
|
+
* The media a tool returned beside its output, where the call stands in the reply.
|
|
253
|
+
* why: a tool sends a picture when it runs, so the picture comes before what the model says next.
|
|
254
|
+
*/
|
|
255
|
+
function appendToolParts(blocks, tool, idPrefix) {
|
|
256
|
+
if (tool.phase !== 'complete')
|
|
257
|
+
return;
|
|
258
|
+
for (const part of tool.parts ?? []) {
|
|
259
|
+
if (part.type === 'text')
|
|
260
|
+
continue;
|
|
261
|
+
blocks.push({
|
|
262
|
+
id: nextBlockId(idPrefix),
|
|
263
|
+
kind: 'media',
|
|
264
|
+
mimeType: part.mimeType,
|
|
265
|
+
...('data' in part ? { data: part.data } : { url: part.uri }),
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
251
269
|
/** Resets only the turn id sequence, so streaming refolds keep stable `turn-*` keys. */
|
|
252
270
|
function foldTurnEvents(events, options = {}) {
|
|
253
271
|
const idPrefix = options.idPrefix ?? 'turn';
|
|
@@ -273,6 +291,7 @@ function foldTurnEvents(events, options = {}) {
|
|
|
273
291
|
case 'tool':
|
|
274
292
|
upsertToolBlock(blocks, event.tool);
|
|
275
293
|
appendPromotedToolMedia(blocks, event.tool, idPrefix, promotedMediaUrls);
|
|
294
|
+
appendToolParts(blocks, event.tool, idPrefix);
|
|
276
295
|
break;
|
|
277
296
|
case 'structured_draft':
|
|
278
297
|
upsertStructuredDraft(blocks, event.text, idPrefix);
|
|
@@ -13,8 +13,8 @@ declare function interfaceFromProfile(input: Profile, tools: ToolRegistry): Prof
|
|
|
13
13
|
/** The interface for a profile the host has already projected, without resolving its tools again. */
|
|
14
14
|
declare function interfaceFromProjected(projected: ProjectedProfile): ProfileInterface;
|
|
15
15
|
/**
|
|
16
|
-
* The interface a browser may read: {@linkcode interfaceFromProfile} without `identity.system
|
|
17
|
-
*
|
|
16
|
+
* The interface a browser may read: {@linkcode interfaceFromProfile} without `identity.system`, which
|
|
17
|
+
* stays on the server. Labels, turn behaviour, guardrails, and observability are kept.
|
|
18
18
|
*/
|
|
19
19
|
declare function clientProfileInterface(input: LiveProfile, tools: ToolRegistry): LiveProfileInterface;
|
|
20
20
|
/** The client-safe interface for a profile that is not live. */
|
|
@@ -147,6 +147,13 @@ function enrich(projected, profile) {
|
|
|
147
147
|
turnBehaviour: profile?.type === 'speech' ? profile.turnBehaviour : undefined,
|
|
148
148
|
canStop: true,
|
|
149
149
|
});
|
|
150
|
+
case 'transcription':
|
|
151
|
+
return profileInterfaceSchema.parse({
|
|
152
|
+
...shared,
|
|
153
|
+
type: 'transcription',
|
|
154
|
+
inputs,
|
|
155
|
+
canStop: true,
|
|
156
|
+
});
|
|
150
157
|
case 'live':
|
|
151
158
|
return profileInterfaceSchema.parse({
|
|
152
159
|
...shared,
|
|
@@ -3,8 +3,8 @@ import { type ToolCallRequest } from '../kernel/turn-events.js';
|
|
|
3
3
|
import type { TurnBlob, TurnEvent, TurnHistoryMessage } from '../kernel/types.js';
|
|
4
4
|
import type { ToolCall, TranscriptBlock, UserTurnDraft } from './types.js';
|
|
5
5
|
/**
|
|
6
|
-
* The kernel sets `readBack` on every `complete` and `
|
|
7
|
-
* come from a run and has no text the model read.
|
|
6
|
+
* The kernel sets `readBack` on every `complete`, `error` and `background` event, so a call without
|
|
7
|
+
* it did not come from a run and has no text the model read.
|
|
8
8
|
*/
|
|
9
9
|
declare function toolReadBack(call: ToolCall): string;
|
|
10
10
|
/** The files a user turn adds to the history beside its text. */
|
|
@@ -7,12 +7,13 @@ import { formatToolFailureForModel, formatToolResult } from '../kernel/tools/mod
|
|
|
7
7
|
import { keptReply } from '../kernel/turn-events.js';
|
|
8
8
|
import { applyToolEvent, toolCallRanWith } from './tool-calls.js';
|
|
9
9
|
/**
|
|
10
|
-
* The kernel sets `readBack` on every `complete` and `
|
|
11
|
-
* come from a run and has no text the model read.
|
|
10
|
+
* The kernel sets `readBack` on every `complete`, `error` and `background` event, so a call without
|
|
11
|
+
* it did not come from a run and has no text the model read.
|
|
12
12
|
*/
|
|
13
13
|
function toolReadBack(call) {
|
|
14
14
|
const state = call.state;
|
|
15
|
-
if ((state?.phase !== 'complete' && state?.phase !== 'error'
|
|
15
|
+
if ((state?.phase !== 'complete' && state?.phase !== 'error' && state?.phase !== 'background') ||
|
|
16
|
+
state.readBack === undefined) {
|
|
16
17
|
throw new TheoremError('request', `Tool call '${call.name}' has no readBack: only a settled call from a run carries one.`);
|
|
17
18
|
}
|
|
18
19
|
return state.readBack;
|
|
@@ -102,7 +103,9 @@ function appendToolDenialToHistory(history, tool, labels) {
|
|
|
102
103
|
/** `undefined` while the call is open. */
|
|
103
104
|
function settledToolContent(call) {
|
|
104
105
|
const phase = call.state?.phase;
|
|
105
|
-
return phase === 'complete' || phase === 'error'
|
|
106
|
+
return phase === 'complete' || phase === 'error' || phase === 'background'
|
|
107
|
+
? toolReadBack(call)
|
|
108
|
+
: undefined;
|
|
106
109
|
}
|
|
107
110
|
/**
|
|
108
111
|
* One model step's settled calls: a single assistant message holding every call
|
|
@@ -26,8 +26,8 @@ export type { WordedStopKind } from './stop.js';
|
|
|
26
26
|
export { stopText, WORDED_STOP_KINDS } from './stop.js';
|
|
27
27
|
export type { SettledToolCallEvent } from './tool-calls.js';
|
|
28
28
|
export { argumentsSoFar, settlesToolCall, toolCallRanWith, toolCallsOf } from './tool-calls.js';
|
|
29
|
-
export { promotedToolIdsFromEvents, toolSnapshotFromEvents } from './tool-invoke.js';
|
|
29
|
+
export { promotedToolIdsFromEvents, replyToolIdsFromEvents, toolSnapshotFromEvents, } from './tool-invoke.js';
|
|
30
30
|
export type { PromotedToolMedia } from './tool-media.js';
|
|
31
31
|
export { collectPromotedMediaFromToolOutput, promotedMediaFromUrlString, } from './tool-media.js';
|
|
32
|
-
export type { AttachmentValidationResult, ComposerInterfaceFields, ComposerProfileInterface, FoldTurnEventsOptions, ImageProfileInterface, LiveProfileInterface, ModelBindingView, PendingAttachment, ProfileGuardrailsView, ProfileInputsInterface, ProfileInterface, ProfileObservabilityView, ProfileOutputsView, ProfileToolsView, SpeechProfileInterface, TextProfileInterface, TranscriptBlock, TranscriptBlockKind, UserTurnDraft, } from './types.js';
|
|
32
|
+
export type { AttachmentValidationResult, ComposerInterfaceFields, ComposerProfileInterface, FoldTurnEventsOptions, ImageProfileInterface, LiveProfileInterface, ModelBindingView, PendingAttachment, ProfileGuardrailsView, ProfileInputsInterface, ProfileInterface, ProfileObservabilityView, ProfileOutputsView, ProfileToolsView, SpeechProfileInterface, TextProfileInterface, TranscriptBlock, TranscriptBlockKind, TranscriptionProfileInterface, UserTurnDraft, } from './types.js';
|
|
33
33
|
export { streamThoughtsEnabled } from './types.js';
|
package/esm/src/interface/mod.js
CHANGED
|
@@ -17,6 +17,6 @@ export { profileInterfaceSchema } from './profile-interface.js';
|
|
|
17
17
|
export { applyTurnEventsToSession, awaitingFromEvents, branchInterfaceTurnSession, emptyInterfaceTurnSession, gatedToolFromEvents, gatedToolsFromEvents, } from './session.js';
|
|
18
18
|
export { stopText, WORDED_STOP_KINDS } from './stop.js';
|
|
19
19
|
export { argumentsSoFar, settlesToolCall, toolCallRanWith, toolCallsOf } from './tool-calls.js';
|
|
20
|
-
export { promotedToolIdsFromEvents, toolSnapshotFromEvents } from './tool-invoke.js';
|
|
20
|
+
export { promotedToolIdsFromEvents, replyToolIdsFromEvents, toolSnapshotFromEvents, } from './tool-invoke.js';
|
|
21
21
|
export { collectPromotedMediaFromToolOutput, promotedMediaFromUrlString, } from './tool-media.js';
|
|
22
22
|
export { streamThoughtsEnabled } from './types.js';
|
|
@@ -143,17 +143,18 @@ const common = {
|
|
|
143
143
|
guardrails: guardrails.optional(),
|
|
144
144
|
observability: observability.optional(),
|
|
145
145
|
};
|
|
146
|
-
const
|
|
146
|
+
const systemPart = z.union([z.string(), z.strictObject({ private: z.string().min(1) })]);
|
|
147
|
+
const profileSystem = z.union([
|
|
147
148
|
z.string(),
|
|
148
149
|
z
|
|
149
|
-
.array(z.union([z.string(), z.
|
|
150
|
+
.array(z.union([z.string(), z.array(systemPart).readonly()]))
|
|
150
151
|
.min(1)
|
|
151
152
|
.readonly(),
|
|
152
153
|
]);
|
|
153
154
|
const identity = z.object({
|
|
154
155
|
handle: z.string(),
|
|
155
|
-
|
|
156
|
-
|
|
156
|
+
conditions: z.record(z.string(), z.array(z.string()).readonly()).readonly().optional(),
|
|
157
|
+
system: profileSystem.optional(),
|
|
157
158
|
});
|
|
158
159
|
const profileInterface = z.discriminatedUnion('type', [
|
|
159
160
|
z.object({
|
|
@@ -200,6 +201,15 @@ const profileInterface = z.discriminatedUnion('type', [
|
|
|
200
201
|
turnBehaviour: mediaTurnBehaviour.optional(),
|
|
201
202
|
canStop: z.literal(true),
|
|
202
203
|
}),
|
|
204
|
+
z.object({
|
|
205
|
+
...common,
|
|
206
|
+
type: z.literal('transcription'),
|
|
207
|
+
identity: z.object({ handle: z.string() }),
|
|
208
|
+
maxSteps: z.undefined().optional(),
|
|
209
|
+
outputs: outputs.optional(),
|
|
210
|
+
inputs,
|
|
211
|
+
canStop: z.literal(true),
|
|
212
|
+
}),
|
|
203
213
|
z.object({
|
|
204
214
|
...common,
|
|
205
215
|
type: z.literal('speech'),
|
|
@@ -14,13 +14,13 @@ declare function applyToolDraft(call: ToolCall | undefined, draft: TurnEventOf<'
|
|
|
14
14
|
declare function toolCallsOf(events: readonly TurnEvent[]): ToolCall[];
|
|
15
15
|
/** The arguments shown for approval, or the user's edit, or the model's original call. */
|
|
16
16
|
declare function toolCallRanWith(call: ToolCall): Record<string, unknown>;
|
|
17
|
-
/** A tool event that settles its call: the call completed or
|
|
17
|
+
/** A tool event that settles its call for the turn: the call completed, failed or went on in the background. */
|
|
18
18
|
type SettledToolCallEvent = TurnEventOf<'tool'> & {
|
|
19
19
|
tool: Extract<ToolCallEvent, {
|
|
20
|
-
phase: 'complete' | 'error';
|
|
20
|
+
phase: 'complete' | 'error' | 'background';
|
|
21
21
|
}>;
|
|
22
22
|
};
|
|
23
|
-
/** True when the event
|
|
23
|
+
/** True when the event settles the tool call with this id for its turn: it ended, or the model has its reply and the call goes on. */
|
|
24
24
|
declare function settlesToolCall(event: TurnEvent, callId: string): event is SettledToolCallEvent;
|
|
25
25
|
/**
|
|
26
26
|
* A call's arguments as far as the model has written them: the whole arguments once the call has
|
|
@@ -39,12 +39,6 @@ function applyToolEvent(call, tool) {
|
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
case 'complete':
|
|
42
|
-
return {
|
|
43
|
-
...settled(call),
|
|
44
|
-
state: tool,
|
|
45
|
-
endedAt: tool.at,
|
|
46
|
-
...(tool.activityPast ? { activityPast: tool.activityPast } : {}),
|
|
47
|
-
};
|
|
48
42
|
case 'error':
|
|
49
43
|
return {
|
|
50
44
|
...settled(call),
|
|
@@ -54,6 +48,7 @@ function applyToolEvent(call, tool) {
|
|
|
54
48
|
};
|
|
55
49
|
case 'cancel':
|
|
56
50
|
case 'gate':
|
|
51
|
+
case 'background':
|
|
57
52
|
return { ...settled(call), state: tool, endedAt: tool.at };
|
|
58
53
|
case 'draft':
|
|
59
54
|
return { ...call, outputDraft: (call.outputDraft ?? '') + tool.text };
|
|
@@ -150,11 +145,13 @@ function toolCallRanWith(call) {
|
|
|
150
145
|
call.edited?.to ??
|
|
151
146
|
call.arguments);
|
|
152
147
|
}
|
|
153
|
-
/** True when the event
|
|
148
|
+
/** True when the event settles the tool call with this id for its turn: it ended, or the model has its reply and the call goes on. */
|
|
154
149
|
function settlesToolCall(event, callId) {
|
|
155
150
|
if (event.type !== 'tool' || event.tool.callId !== callId)
|
|
156
151
|
return false;
|
|
157
|
-
return event.tool.phase === 'complete' ||
|
|
152
|
+
return (event.tool.phase === 'complete' ||
|
|
153
|
+
event.tool.phase === 'error' ||
|
|
154
|
+
event.tool.phase === 'background');
|
|
158
155
|
}
|
|
159
156
|
/**
|
|
160
157
|
* A call's arguments as far as the model has written them: the whole arguments once the call has
|
|
@@ -3,4 +3,6 @@ import type { ToolId, TurnEvent, TurnToolSnapshot } from '../kernel/types.js';
|
|
|
3
3
|
declare function promotedToolIdsFromEvents(events: readonly TurnEvent[]): ToolId[];
|
|
4
4
|
/** The tool snapshot on the last `done` event that carries one, which only a turn stopped on a tool or gate does. */
|
|
5
5
|
declare function toolSnapshotFromEvents(events: readonly TurnEvent[]): TurnToolSnapshot | undefined;
|
|
6
|
-
|
|
6
|
+
/** The tools a paused reply holds: those on the list it paused with, and those a call has loaded since. */
|
|
7
|
+
declare function replyToolIdsFromEvents(events: readonly TurnEvent[]): ToolId[];
|
|
8
|
+
export { promotedToolIdsFromEvents, replyToolIdsFromEvents, toolSnapshotFromEvents };
|
|
@@ -19,4 +19,9 @@ function toolSnapshotFromEvents(events) {
|
|
|
19
19
|
const done = findLast(events, (event) => event.type === 'done' && event.tools !== undefined);
|
|
20
20
|
return done?.type === 'done' ? done.tools : undefined;
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
/** The tools a paused reply holds: those on the list it paused with, and those a call has loaded since. */
|
|
23
|
+
function replyToolIdsFromEvents(events) {
|
|
24
|
+
const visible = toolSnapshotFromEvents(events)?.visible ?? [];
|
|
25
|
+
return [...new Set([...visible, ...promotedToolIdsFromEvents(events)])];
|
|
26
|
+
}
|
|
27
|
+
export { promotedToolIdsFromEvents, replyToolIdsFromEvents, toolSnapshotFromEvents };
|
|
@@ -5,7 +5,7 @@ import type { LabelOverrides } from '../guardrails/labels.js';
|
|
|
5
5
|
import type { ResolvedGuardrailPolicy } from '../guardrails/types.js';
|
|
6
6
|
import type { ProfileToolsSpec, ToolCallEdit, ToolPhaseEvent } from '../kernel/tools/types.js';
|
|
7
7
|
import type { ReasoningPart } from '../kernel/turn-events.js';
|
|
8
|
-
import type { AttachmentValidationIssue, CompactionSpec, GroundingEvent, ImageProfile, LiveProfile, ModelBinding, ModelId, ProfileContextSpec, ProfileOutputsSpec, ProviderEvidence, SlotDecl, Source, SpeechProfile, TextProfile, TurnStop, TurnTokens } from '../kernel/types.js';
|
|
8
|
+
import type { AttachmentValidationIssue, CompactionSpec, GroundingEvent, ImageProfile, LiveProfile, ModelBinding, ModelId, ProfileContextSpec, ProfileOutputsSpec, ProviderEvidence, SlotDecl, Source, SpeechProfile, TextProfile, TranscriptionProfile, TurnStop, TurnTokens } from '../kernel/types.js';
|
|
9
9
|
import type { ResolvedObservabilityPolicy } from '../observability/types.js';
|
|
10
10
|
/** What a URL detector lets through besides the given URLs, with its defaults applied. */
|
|
11
11
|
export interface UrlAllowView {
|
|
@@ -103,6 +103,8 @@ export type ImageProfileInterface = Omit<ImageProfile, 'inputs' | 'tools' | 'gua
|
|
|
103
103
|
};
|
|
104
104
|
/** A speech profile as a client sees it, without its server-only fields. */
|
|
105
105
|
export type SpeechProfileInterface = Omit<SpeechProfile, 'guardrails' | 'observability' | 'labels' | 'models' | 'outputs'> & ComposerInterfaceFields;
|
|
106
|
+
/** A transcription profile as a client sees it, without its server-only fields. */
|
|
107
|
+
export type TranscriptionProfileInterface = Omit<TranscriptionProfile, 'guardrails' | 'observability' | 'labels' | 'models' | 'outputs' | 'inputs'> & ComposerInterfaceFields;
|
|
106
108
|
/** A live profile as a client sees it, without its server-only fields. */
|
|
107
109
|
export type LiveProfileInterface = Omit<LiveProfile, 'tools' | 'guardrails' | 'observability' | 'labels' | 'models' | 'live'> & {
|
|
108
110
|
/** Without `greeting` and `resumed`: the prompts stay on the host. */
|
|
@@ -115,7 +117,7 @@ export type LiveProfileInterface = Omit<LiveProfile, 'tools' | 'guardrails' | 'o
|
|
|
115
117
|
observability?: ProfileObservabilityView;
|
|
116
118
|
};
|
|
117
119
|
/** Any profile as a client sees it. */
|
|
118
|
-
export type ProfileInterface = TextProfileInterface | ImageProfileInterface | SpeechProfileInterface | LiveProfileInterface;
|
|
120
|
+
export type ProfileInterface = TextProfileInterface | ImageProfileInterface | SpeechProfileInterface | TranscriptionProfileInterface | LiveProfileInterface;
|
|
119
121
|
/** Turn/chat composer profiles — excludes live (realtime streams, no turn inputs block). */
|
|
120
122
|
export type ComposerProfileInterface = Exclude<ProfileInterface, LiveProfileInterface>;
|
|
121
123
|
/** The kinds of block a transcript holds. */
|
|
@@ -146,7 +148,7 @@ export interface TextBlock extends TranscriptBlockBase {
|
|
|
146
148
|
}
|
|
147
149
|
/** Where a call stands: the latest phase that changes its status. */
|
|
148
150
|
export type ToolCallState = Extract<ToolPhaseEvent, {
|
|
149
|
-
phase: 'running' | 'gate' | 'complete' | 'error' | 'cancel';
|
|
151
|
+
phase: 'running' | 'gate' | 'background' | 'complete' | 'error' | 'cancel';
|
|
150
152
|
}>;
|
|
151
153
|
/** invariant: An issued operation joins its request and phases; historical calls use callId. */
|
|
152
154
|
export interface ToolCall {
|
|
@@ -202,9 +204,9 @@ export interface StructuredBlock extends TranscriptBlockBase {
|
|
|
202
204
|
export interface MediaBlock extends TranscriptBlockBase {
|
|
203
205
|
kind: 'media';
|
|
204
206
|
mimeType: string;
|
|
205
|
-
/** Base64 for model
|
|
207
|
+
/** Base64 for media a model generated, a tool returned or a person attached. Absent when `url` is set. */
|
|
206
208
|
data?: string;
|
|
207
|
-
/** Remote
|
|
209
|
+
/** Remote URL from completed tool output or a tool's media part. Absent when `data` is set. */
|
|
208
210
|
url?: string;
|
|
209
211
|
/** A smaller copy of `url` for previews, when the tool output offered one. */
|
|
210
212
|
previewUrl?: string;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** labels-exempt-file: authoring request-field and export meta — not runtime user or model copy (P2) */
|
|
2
2
|
/** The catalog of the fields a `runTurn` request takes, keyed `runTurn.<field>`. */
|
|
3
3
|
export const REQUEST_FIELDS = {
|
|
4
|
+
'runTurn.background': {
|
|
5
|
+
type: 'ToolBackgroundService',
|
|
6
|
+
doc: 'Host-issued service for tool calls that go on after their reply. It needs a coordinator with detach. Without it every tool runs inline.',
|
|
7
|
+
},
|
|
4
8
|
'runTurn.pageExecution': {
|
|
5
9
|
type: 'PageToolExecution',
|
|
6
10
|
doc: 'Host-issued browser dispatch with a claimed operation and correlated result.',
|
|
@@ -20,11 +24,6 @@ export const REQUEST_FIELDS = {
|
|
|
20
24
|
},
|
|
21
25
|
'runTurn.input': { type: 'TurnInput', doc: 'What the user sent for the turn.' },
|
|
22
26
|
'runTurn.input.text': { type: 'string', doc: "The user's message." },
|
|
23
|
-
'runTurn.input.role': {
|
|
24
|
-
type: 'string',
|
|
25
|
-
doc: 'Picks the instruction of that name from identity.systemByRole.',
|
|
26
|
-
unset: 'The profile instruction',
|
|
27
|
-
},
|
|
28
27
|
'runTurn.input.slots': {
|
|
29
28
|
type: 'Record<string, string>',
|
|
30
29
|
doc: 'The choice the turn makes for each slot the profile declares in inputs.slots; a slot or a value the profile does not declare is refused.',
|
|
@@ -79,6 +78,11 @@ export const REQUEST_FIELDS = {
|
|
|
79
78
|
type: 'SystemPrompt',
|
|
80
79
|
doc: "An instruction for this request only, added to the profile's own.",
|
|
81
80
|
},
|
|
81
|
+
'runTurn.conditions': {
|
|
82
|
+
type: 'Record<string, string>',
|
|
83
|
+
doc: "This turn's facts, one value for each of identity.conditions but path.",
|
|
84
|
+
unset: 'The profile declares none',
|
|
85
|
+
},
|
|
82
86
|
'runTurn.path': {
|
|
83
87
|
type: 'string',
|
|
84
88
|
doc: 'The channel the turn comes from; only tools whose paths name it, or *, are offered.',
|
|
@@ -133,6 +137,10 @@ export const REQUEST_FIELDS = {
|
|
|
133
137
|
type: 'number',
|
|
134
138
|
doc: 'Which continue attempt this is, from 1; checked against the maxContinues of the profile.',
|
|
135
139
|
},
|
|
140
|
+
'runTurn.promoted': {
|
|
141
|
+
type: 'ToolId[]',
|
|
142
|
+
doc: 'Tools this reply already had when an earlier run of it paused; the turn opens with them on its list.',
|
|
143
|
+
},
|
|
136
144
|
'runTurn.speech': {
|
|
137
145
|
type: 'TurnSpeech',
|
|
138
146
|
doc: "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.",
|
|
@@ -342,7 +342,9 @@ function scopeTokens(scope) {
|
|
|
342
342
|
function assertGrantWithin(granted, requested, tokenEndpoint) {
|
|
343
343
|
if (requested.length === 0)
|
|
344
344
|
return;
|
|
345
|
-
|
|
345
|
+
// why: Some servers join scopes with commas. A comma may also sit inside a scope, so a token
|
|
346
|
+
// that was asked for stands, and only an unknown one is read as a list, part by part.
|
|
347
|
+
const beyond = scopeTokens(granted).flatMap((scope) => requested.includes(scope) ? [] : scope.split(',').filter((part) => !requested.includes(part)));
|
|
346
348
|
if (beyond.length > 0) {
|
|
347
349
|
throw new Error(`Token response from ${tokenEndpoint} grants scopes that were not asked for: ${beyond.join(', ')}`);
|
|
348
350
|
}
|