@theoremjs/agents 0.3.4-next.693.g4ab1526 → 0.3.4-next.715.geef22fd
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 +3 -2
- package/esm/mod.js +1 -1
- package/esm/src/guardrails/labels.d.ts +1 -1
- package/esm/src/guardrails/labels.js +6 -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 +1 -1
- package/esm/src/interface/mod.js +1 -1
- 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 +11 -1
- package/esm/src/interface/tool-invoke.js +13 -1
- package/esm/src/interface/types.d.ts +1 -1
- package/esm/src/kernel/api-catalog.js +12 -0
- 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/gates.js +4 -3
- 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 +5 -0
- package/esm/src/kernel/engine/session/mod.d.ts +2 -0
- package/esm/src/kernel/engine/session/mod.js +19 -2
- package/esm/src/kernel/mod.d.ts +3 -2
- package/esm/src/kernel/mod.js +1 -1
- package/esm/src/kernel/schema.js +12 -0
- 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 +3 -1
- package/esm/src/kernel/tools/call-order.js +10 -6
- 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 +20 -1
- package/esm/src/kernel/tools/resolve.d.ts +4 -2
- package/esm/src/kernel/tools/resolve.js +23 -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 +2 -0
- package/esm/src/kernel/tools/stage-run.js +1 -0
- package/esm/src/kernel/tools/types.d.ts +7 -0
- package/esm/src/kernel/turn-events.d.ts +10 -1
- package/esm/src/kernel/turn-events.js +3 -0
- package/esm/src/kernel/types.d.ts +13 -0
- package/esm/src/providers/open-ai/protocol.js +8 -4
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import type { ProviderCheckpoint, ProviderContinuationPolicy } from './checkpoin
|
|
|
2
2
|
import type { JsonObject } from './json.js';
|
|
3
3
|
import type { CacheMode, CacheTtl, CompactionMeter, CompactionOutcome, CompactionTiming, ContextSender, ContinueStopKind, FieldMeta, KeySlot, KeyVault, LiveActivityHandling, LiveEndSensitivity, LiveStartSensitivity, MediaInputKind, ProfileType, SpeechAudioFormat, StreamMode, SummaryMode, ThinkingLevel, ToolLoadTier, TurnStage, TurnStopKind } from './schema.js';
|
|
4
4
|
import type { StageHandler } from './stages.js';
|
|
5
|
+
import type { ToolBackgroundService } from './tools/background.js';
|
|
5
6
|
import type { GateDecision } from './tools/gate-answer.js';
|
|
6
7
|
import type { PageToolExecution, ToolExecutionCoordinator } from './tools/operation.js';
|
|
7
8
|
import type { AgentCall, AgentCallHook, AgentCallRequest, AgentToolDef, AgentToolInput, AgentToolOutput, HostProfileToolsSpec, InvokeToolRequest, InvokeToolResume, InvokeToolStepCall, InvokeToolStepRequest, LiveProfileToolsSpec, ModelToolResult, PageAnswer, ProfileToolsSpec, RegisteredTool, ToolCallEvent, ToolFailure, ToolGate, ToolLoadContext, ToolPolicy, TurnToolSnapshot, WireFunctionTool } from './tools/types.js';
|
|
@@ -759,6 +760,7 @@ export interface TurnTraceLink {
|
|
|
759
760
|
/** A request to `runTurn`: the profile, the input, and the host's hooks and keys. */
|
|
760
761
|
export interface TurnRequest {
|
|
761
762
|
execution?: ToolExecutionCoordinator;
|
|
763
|
+
background?: ToolBackgroundService;
|
|
762
764
|
pageExecution?: PageToolExecution;
|
|
763
765
|
providerState?: ProviderCheckpoint;
|
|
764
766
|
profile: ProfileId;
|
|
@@ -820,6 +822,17 @@ export interface TurnRequest {
|
|
|
820
822
|
* Compared to `profile.turnBehaviour.resumption.maxContinues` when that cap is set.
|
|
821
823
|
*/
|
|
822
824
|
continuation?: number;
|
|
825
|
+
/**
|
|
826
|
+
* Tools this reply already had when an earlier run of it paused. The turn opens with them on its
|
|
827
|
+
* list, so an answered call does not take back what the model loaded. An id `tools.allow` or the
|
|
828
|
+
* path does not grant is left out, as for `tools.t1Policy`.
|
|
829
|
+
*/
|
|
830
|
+
promoted?: ToolId[];
|
|
831
|
+
/**
|
|
832
|
+
* Steps this reply already took when an earlier run of it paused. They count against `maxSteps`,
|
|
833
|
+
* so an answered call does not give the reply its steps back. Read `done.steps`.
|
|
834
|
+
*/
|
|
835
|
+
stepsTaken?: number;
|
|
823
836
|
input?: TurnInput;
|
|
824
837
|
/** Credentials for authenticated HTTP / MCP tools, read by auth slot when a tool needs one. */
|
|
825
838
|
credentials?: ToolCredentialSource;
|
|
@@ -36,13 +36,17 @@ function requestBody(context, request) {
|
|
|
36
36
|
};
|
|
37
37
|
return JSON.parse(JSON.stringify(body));
|
|
38
38
|
}
|
|
39
|
-
/**
|
|
40
|
-
|
|
39
|
+
/**
|
|
40
|
+
* An error row inside a 200 reply: thrown, so a quota refusal before any output can still fall back.
|
|
41
|
+
* why: a reply the provider already began was accepted, so a 4xx in it is the stream breaking, not a refusal.
|
|
42
|
+
*/
|
|
43
|
+
function errorRow(row, reply) {
|
|
41
44
|
const error = asRecord(row.error);
|
|
42
45
|
if (!error)
|
|
43
46
|
return;
|
|
44
47
|
const status = typeof error.code === 'number' ? error.code : 502;
|
|
45
|
-
|
|
48
|
+
const kind = kindOfHttpStatus(status);
|
|
49
|
+
throw new TheoremError(reply.response && kind === 'unsupported' ? 'unavailable' : kind, statedError(row) ?? JSON.stringify(error));
|
|
46
50
|
}
|
|
47
51
|
function citations(part, reply) {
|
|
48
52
|
const sources = (Array.isArray(part.annotations) ? part.annotations : []).flatMap((item) => {
|
|
@@ -87,7 +91,7 @@ function partEvents(part, reply, request) {
|
|
|
87
91
|
return events;
|
|
88
92
|
}
|
|
89
93
|
function rowEvents(row, reply, request, stream) {
|
|
90
|
-
errorRow(row);
|
|
94
|
+
errorRow(row, reply);
|
|
91
95
|
const events = [];
|
|
92
96
|
const identity = foldResponse(reply.response, openAiResponse(row));
|
|
93
97
|
reply.response = identity.known;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theoremjs/agents",
|
|
3
|
-
"version": "0.3.4-next.
|
|
3
|
+
"version": "0.3.4-next.715.geef22fd",
|
|
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",
|