@theoremjs/agents 0.3.5-next.966.g19b460d → 0.3.5-next.967.gd19ced6
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 +1 -1
- package/esm/mod.d.ts +2 -2
- package/esm/src/kernel/default-scope.d.ts +6 -3
- package/esm/src/kernel/default-scope.js +4 -1
- package/esm/src/kernel/mod.d.ts +2 -1
- package/esm/src/kernel/scope.d.ts +2 -2
- package/esm/src/kernel/scope.js +1 -1
- package/esm/src/kernel/tools/run.d.ts +18 -2
- package/esm/src/kernel/tools/run.js +6 -2
- package/esm/src/kernel/tools/types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -465,7 +465,7 @@ Named exports from the root barrel (same symbols hosts get from `@theoremjs/agen
|
|
|
465
465
|
| 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` |
|
|
466
466
|
| Scope | `KernelScope`, `createKernelScope`, `defaultKernelScope`, `KernelRegistry`, `createKernelRegistry` |
|
|
467
467
|
| 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` |
|
|
468
|
-
| 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`, `formatToolFailureForModel`, `prepareTurnToolSnapshot`, `buildHttpToolTarget`, `executeHttpTool`, `executeMcpTool`, `parseMcpRpcResponse`, `isUnsupportedMcpProtocolError`, `MCP_PROTOCOL_VERSIONS`, `mcpRequestMeta`, `McpProtocolVersion`, `resolveToolAuth`, `credentialPlacement`, `withCredentialQuery`, `CredentialQuery`, `uncheckedOutput`, `UncheckedOutput`, `ToolFailed`, `StatedToolFailure`, `McpRpcResponse`, `ModelToolResult`, `PageAnswer`, `ToolMediaEntry` (one entry of an HTTP or MCP tool's media hook) |
|
|
468
|
+
| Tools | `ToolContext`, `GateReference`, `gateReferenceSchema`, `ToolRegistry`, `assertToolSettings`, `createToolRegistry`, `registerTool`, `registerTools`, `invokeTool`, `invokeToolStep`, `runTool`, `runToolStep`, `RunToolStepRequest`, `SettledToolCall`, `ToolCallResult`, `ToolStepCallResult`, `GATE_DECISIONS`, `GateDecision`, `askUserTool`, `registerHarnessTools`, `getTool`, `hasTool`, `requireTool`, `listTools`, `resetTools`, `formatToolResult`, `formatToolFailureForModel`, `prepareTurnToolSnapshot`, `buildHttpToolTarget`, `executeHttpTool`, `executeMcpTool`, `parseMcpRpcResponse`, `isUnsupportedMcpProtocolError`, `MCP_PROTOCOL_VERSIONS`, `mcpRequestMeta`, `McpProtocolVersion`, `resolveToolAuth`, `credentialPlacement`, `withCredentialQuery`, `CredentialQuery`, `uncheckedOutput`, `UncheckedOutput`, `ToolFailed`, `StatedToolFailure`, `McpRpcResponse`, `ModelToolResult`, `ToolStreamEvent`, `PageAnswer`, `ToolMediaEntry` (one entry of an HTTP or MCP tool's media hook) |
|
|
469
469
|
| 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` |
|
|
470
470
|
| Structured | `SchemaRegistry`, `createSchemaRegistry`, `getStructured`, `registerStructured` |
|
|
471
471
|
| 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` |
|
package/esm/mod.d.ts
CHANGED
|
@@ -76,8 +76,8 @@ export type { CredentialQuery, McpProtocolVersion, McpRpcResponse, ToolRegistry,
|
|
|
76
76
|
export { askUserTool, assertToolSettings, buildHttpToolTarget, createToolRegistry, credentialPlacement, executeHttpTool, executeMcpTool, formatToolFailureForModel, formatToolResult, isUnsupportedMcpProtocolError, MCP_PROTOCOL_VERSIONS, mcpRequestMeta, parseMcpRpcResponse, prepareTurnToolSnapshot, registerHarnessTools, resolveToolAuth, toolOutputPartSchema, UncheckedOutput, uncheckedOutput, withCredentialQuery, } from './src/kernel/tools/mod.js';
|
|
77
77
|
export type { BackgroundToolEvent, BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationReply, ToolOperationUncertainty, } from './src/kernel/tools/operation.js';
|
|
78
78
|
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './src/kernel/tools/operation.js';
|
|
79
|
-
export type { SettledToolCall, ToolCallResult, ToolStepCallResult, } from './src/kernel/tools/run.js';
|
|
80
|
-
export type { ModelToolResult, PageAnswer, ToolContext, ToolMediaEntry, } from './src/kernel/tools/types.js';
|
|
79
|
+
export type { RunToolStepRequest, SettledToolCall, ToolCallResult, ToolStepCallResult, } from './src/kernel/tools/run.js';
|
|
80
|
+
export type { ModelToolResult, PageAnswer, ToolContext, ToolMediaEntry, ToolStreamEvent, } from './src/kernel/tools/types.js';
|
|
81
81
|
export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, type ToolOutputPart, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './src/kernel/turn-events.js';
|
|
82
82
|
export type * from './src/kernel/types.js';
|
|
83
83
|
export type { OtlpAnyValue, OtlpKeyValue, OtlpSpan, OtlpTraceRequest, ProfileObservabilitySpec, ResolvedObservabilityPolicy, ResolvedScrubSwitch, ResolvedTraceInclude, ResolvedTraceScrub, ScrubSwitch, SpanHandle, SpanLinkInput, SpanOptions, TraceAttributeGroup, TraceAttributeMeta, TraceAttributes, TraceAttributeValue, TraceBytes, TraceClock, TraceContent, TraceEventMeta, TraceIncludeSpec, TraceJson, TraceOptionMeta, TraceRecord, TraceScrubSpec, TraceSink, TraceSpan, TraceSpanEvent, TraceSpanKind, TraceSpanLink, TraceSpanMeta, TraceSpanStatus, TraceSpanType, TraceTree, TraceValueFormat, TraceWriteContext, } from './src/observability/mod.js';
|
|
@@ -7,7 +7,7 @@ import type { Provider, RegisteredProvider, Registration } from './protocols/pro
|
|
|
7
7
|
import type { ProviderHostOptions } from './protocols/runtime.js';
|
|
8
8
|
import type { ProfileDefinition } from './registry/profiles.js';
|
|
9
9
|
import { defaultKernelScope as scope } from './scope.js';
|
|
10
|
-
import type { ToolCallResult, ToolStepCallResult } from './tools/run.js';
|
|
10
|
+
import type { RunToolStepRequest, ToolCallResult, ToolStepCallResult } from './tools/run.js';
|
|
11
11
|
import type { InvokeToolRequest, InvokeToolStepRequest, RegisteredTool, ToolDefinitionInput } from './tools/types.js';
|
|
12
12
|
import type { CompactHistoryRequest, CompactionResult, DecisionRequest, DecisionResult, EmbeddingRequest, EmbeddingResult, LiveSession, Profile, ProjectedProfile, SessionRequest, StructuredSpec, TurnEvent, TurnRequest } from './types.js';
|
|
13
13
|
/**
|
|
@@ -86,8 +86,11 @@ declare function invokeToolStep(request: InvokeToolStepRequest, sinkOverride?: T
|
|
|
86
86
|
* emitted.
|
|
87
87
|
*/
|
|
88
88
|
declare function runTool(request: InvokeToolRequest, sinkOverride?: TraceSink): Promise<ToolCallResult>;
|
|
89
|
-
/**
|
|
90
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Run the host's calls as one step in the default scope, giving each call's end as it settles;
|
|
91
|
+
* `onEvent` hears each event as it arrives.
|
|
92
|
+
*/
|
|
93
|
+
declare function runToolStep(request: RunToolStepRequest, sinkOverride?: TraceSink): AsyncGenerator<ToolStepCallResult>;
|
|
91
94
|
/** Resolve a turn request in the default scope: its profile, model, and generation settings. */
|
|
92
95
|
declare function resolveTurn(req: TurnRequest): ReturnType<typeof scope.resolveTurn>;
|
|
93
96
|
/** Each model of profile `id` in the default scope that cannot run a plain turn on its provider, and why. */
|
|
@@ -117,7 +117,10 @@ function invokeToolStep(request, sinkOverride) {
|
|
|
117
117
|
function runTool(request, sinkOverride) {
|
|
118
118
|
return scope.runTool(request, sinkOverride);
|
|
119
119
|
}
|
|
120
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Run the host's calls as one step in the default scope, giving each call's end as it settles;
|
|
122
|
+
* `onEvent` hears each event as it arrives.
|
|
123
|
+
*/
|
|
121
124
|
function runToolStep(request, sinkOverride) {
|
|
122
125
|
return scope.runToolStep(request, sinkOverride);
|
|
123
126
|
}
|
package/esm/src/kernel/mod.d.ts
CHANGED
|
@@ -76,9 +76,10 @@ export { askUserTool, assertToolSettings, authorizeToolReplay, createToolRegistr
|
|
|
76
76
|
export type { BackgroundToolEvent, BeginToolOperationResult, PageToolDispatch, PageToolExecution, SavedToolInvocation, TerminalToolEvent, ToolExecutionCoordinator, ToolOperationClaim, ToolOperationIdentity, ToolOperationOutcome, ToolOperationReply, ToolOperationUncertainty, } from './tools/operation.js';
|
|
77
77
|
export { savedToolInvocationSchema, toolInvocationHash, toolOperationOutcomeSchema, toolOperationReplySchema, } from './tools/operation.js';
|
|
78
78
|
export { toolAuthForCall } from './tools/registry.js';
|
|
79
|
+
export type { RunToolStepRequest, SettledToolCall, ToolCallResult, ToolStepCallResult, } from './tools/run.js';
|
|
79
80
|
export { jsonSchemaFromZod } from './tools/schema.js';
|
|
80
81
|
export { CredentialRefusedError } from './tools/signed-in-fetch.js';
|
|
81
|
-
export type { ModelToolResult, PageAnswer, ToolAuthConfig, ToolAuthFor, ToolContext, ToolLabels, ToolMediaEntry, } from './tools/types.js';
|
|
82
|
+
export type { ModelToolResult, PageAnswer, ToolAuthConfig, ToolAuthFor, ToolContext, ToolLabels, ToolMediaEntry, ToolStreamEvent, } from './tools/types.js';
|
|
82
83
|
export { awaitingUserInputSchema, type GateReference, gateReferenceSchema, isAwaitingUserInput, keptReply, reasoningPartSchema, type ToolOutputPart, TURN_EVENT_SCHEMAS, toolGateSchema, turnDoneOf, turnEventSchema, turnHistoryMessageSchema, turnToolSnapshotSchema, } from './turn-events.js';
|
|
83
84
|
export type * from './types.js';
|
|
84
85
|
export { base64ToBytes, bytesToBase64 } from './util/base64.js';
|
|
@@ -5,7 +5,7 @@ import { type RunSessionOptions } from './engine/session/mod.js';
|
|
|
5
5
|
import type { ProviderHostOptions } from './protocols/runtime.js';
|
|
6
6
|
import { type KernelRegistry } from './registry/kernel-registry.js';
|
|
7
7
|
import { resolveTurnInRegistry } from './registry/resolve.js';
|
|
8
|
-
import { type ToolCallResult, type ToolStepCallResult } from './tools/run.js';
|
|
8
|
+
import { type RunToolStepRequest, type ToolCallResult, type ToolStepCallResult } from './tools/run.js';
|
|
9
9
|
import type { InvokeToolRequest, InvokeToolStepRequest } from './tools/types.js';
|
|
10
10
|
import type { CompactHistoryRequest, CompactionResult, DecisionRequest, DecisionResult, EmbeddingRequest, EmbeddingResult, LiveSession, ProjectedProfile, SessionRequest, TurnEvent, TurnRequest } from './types.js';
|
|
11
11
|
/** A kernel scope: its registries and the operations that run against them (turns, live sessions, history compaction, tool invocation, turn resolution, profile projection, and decisions). */
|
|
@@ -16,7 +16,7 @@ interface KernelScope extends KernelRegistry {
|
|
|
16
16
|
invokeTool(request: InvokeToolRequest, sinkOverride?: TraceSink): AsyncGenerator<TurnEvent>;
|
|
17
17
|
invokeToolStep(request: InvokeToolStepRequest, sinkOverride?: TraceSink): AsyncGenerator<TurnEvent>;
|
|
18
18
|
runTool(request: InvokeToolRequest, sinkOverride?: TraceSink): Promise<ToolCallResult>;
|
|
19
|
-
runToolStep(request:
|
|
19
|
+
runToolStep(request: RunToolStepRequest, sinkOverride?: TraceSink): AsyncGenerator<ToolStepCallResult>;
|
|
20
20
|
resolveTurn(req: TurnRequest): ReturnType<typeof resolveTurnInRegistry>;
|
|
21
21
|
projectProfile(id: string): ProjectedProfile;
|
|
22
22
|
runDecision(request: DecisionRequest, options: RunDecisionOptions): Promise<DecisionResult>;
|
package/esm/src/kernel/scope.js
CHANGED
|
@@ -33,7 +33,7 @@ function createKernelScope() {
|
|
|
33
33
|
invokeTool: (request, sinkOverride) => invokeTool(registry, request, sinkOverride),
|
|
34
34
|
invokeToolStep: (request, sinkOverride) => invokeToolStep(registry, request, sinkOverride),
|
|
35
35
|
runTool: (request, sinkOverride) => settledCall(startInvoke(registry, request, sinkOverride)),
|
|
36
|
-
runToolStep: (request, sinkOverride) => settledCalls(startInvokeStep(registry, request, sinkOverride)),
|
|
36
|
+
runToolStep: ({ onEvent, ...request }, sinkOverride) => settledCalls(startInvokeStep(registry, request, sinkOverride), onEvent),
|
|
37
37
|
resolveTurn: (req) => resolveTurnInRegistry(registry, req),
|
|
38
38
|
projectProfile: (id) => projectProfileInRegistry(registry, id),
|
|
39
39
|
runDecision: (request, options) => runDecisionInRegistry(registry, request, options),
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ToolPhaseEvent, TurnEvent } from '../turn-events.js';
|
|
7
7
|
import type { StartedInvoke, StartedStep } from './invoke.js';
|
|
8
|
+
import type { InvokeToolStepRequest } from './types.js';
|
|
8
9
|
/** The phase a call ends on: it completed, a gate held it, it failed, or it went on in the background. */
|
|
9
10
|
export type SettledToolCall = Extract<ToolPhaseEvent, {
|
|
10
11
|
phase: 'complete' | 'gate' | 'error' | 'background';
|
|
@@ -21,8 +22,23 @@ export type ToolCallResult = SettledToolCall & {
|
|
|
21
22
|
export type ToolStepCallResult = ToolCallResult & {
|
|
22
23
|
index: number;
|
|
23
24
|
};
|
|
25
|
+
/** A step `runToolStep` runs, and what the host hears while it runs. */
|
|
26
|
+
export interface RunToolStepRequest extends InvokeToolStepRequest {
|
|
27
|
+
/**
|
|
28
|
+
* Your function that is given each of the step's events as it arrives, before the call it
|
|
29
|
+
* belongs to settles, such as a call's progress. Left out, you get only each call's end. A throw
|
|
30
|
+
* fails the step, as a throw from the invoke does.
|
|
31
|
+
*
|
|
32
|
+
* @remarks Called for every event the step emits, in order, before `runToolStep` yields the
|
|
33
|
+
* call that event settles.
|
|
34
|
+
*/
|
|
35
|
+
onEvent?: (event: TurnEvent) => void;
|
|
36
|
+
}
|
|
24
37
|
/** Run one call to its end. */
|
|
25
38
|
declare function settledCall(started: StartedInvoke): Promise<ToolCallResult>;
|
|
26
|
-
/**
|
|
27
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Run a step's calls, yielding each one's result as it settles; a call the step never settled comes
|
|
41
|
+
* last. `onEvent` hears each event first.
|
|
42
|
+
*/
|
|
43
|
+
declare function settledCalls(started: StartedStep, onEvent?: (event: TurnEvent) => void): AsyncGenerator<ToolStepCallResult>;
|
|
28
44
|
export { settledCall, settledCalls };
|
|
@@ -55,8 +55,11 @@ async function settledCall(started) {
|
|
|
55
55
|
}
|
|
56
56
|
return settle(fold, invokeError);
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Run a step's calls, yielding each one's result as it settles; a call the step never settled comes
|
|
60
|
+
* last. `onEvent` hears each event first.
|
|
61
|
+
*/
|
|
62
|
+
async function* settledCalls(started, onEvent) {
|
|
60
63
|
const folds = started.calls.map(({ name, callId }) => ({
|
|
61
64
|
name,
|
|
62
65
|
callId,
|
|
@@ -66,6 +69,7 @@ async function* settledCalls(started) {
|
|
|
66
69
|
const yielded = new Set();
|
|
67
70
|
let invokeError;
|
|
68
71
|
for await (const event of started.events) {
|
|
72
|
+
onEvent?.(event);
|
|
69
73
|
if (event.type === 'error')
|
|
70
74
|
invokeError = event;
|
|
71
75
|
if (event.type !== 'tool')
|
|
@@ -166,6 +166,7 @@ export type SignedInRequest = {
|
|
|
166
166
|
* throws; the kernel turns it into a new sign-in or `sign_in.out_of_scope`.
|
|
167
167
|
*/
|
|
168
168
|
export type SignedInFetch = (url: string | URL, request?: SignedInRequest) => Promise<Response>;
|
|
169
|
+
/** What a streaming handler (an async generator function) yields; only `complete` is its output. */
|
|
169
170
|
export type ToolStreamEvent<TOut = unknown> = {
|
|
170
171
|
kind: 'progress';
|
|
171
172
|
data: unknown;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/agents",
|
|
3
|
-
"version": "0.3.5-next.
|
|
3
|
+
"version": "0.3.5-next.967.gd19ced6",
|
|
4
4
|
"description": "A flat TypeScript agent kernel for typed profiles, deterministic turn execution, registered tools, provider adapters, guardrails, and host-injected traces.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|