@assemblyline-agents/runtime 0.1.0
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/LICENSE +21 -0
- package/README.md +19 -0
- package/dist/agent-harness.d.ts +108 -0
- package/dist/agent-harness.d.ts.map +1 -0
- package/dist/agent-harness.js +2 -0
- package/dist/agent-harness.js.map +1 -0
- package/dist/attachments-legacy.d.ts +17 -0
- package/dist/attachments-legacy.d.ts.map +1 -0
- package/dist/attachments-legacy.js +273 -0
- package/dist/attachments-legacy.js.map +1 -0
- package/dist/attachments.d.ts +49 -0
- package/dist/attachments.d.ts.map +1 -0
- package/dist/attachments.js +832 -0
- package/dist/attachments.js.map +1 -0
- package/dist/builtin-tool-executors.d.ts +96 -0
- package/dist/builtin-tool-executors.d.ts.map +1 -0
- package/dist/builtin-tool-executors.js +501 -0
- package/dist/builtin-tool-executors.js.map +1 -0
- package/dist/builtin-tools.d.ts +30 -0
- package/dist/builtin-tools.d.ts.map +1 -0
- package/dist/builtin-tools.js +690 -0
- package/dist/builtin-tools.js.map +1 -0
- package/dist/capability-catalog.d.ts +27 -0
- package/dist/capability-catalog.d.ts.map +1 -0
- package/dist/capability-catalog.js +193 -0
- package/dist/capability-catalog.js.map +1 -0
- package/dist/channel-http-util.d.ts +34 -0
- package/dist/channel-http-util.d.ts.map +1 -0
- package/dist/channel-http-util.js +93 -0
- package/dist/channel-http-util.js.map +1 -0
- package/dist/channel-ingress.d.ts +56 -0
- package/dist/channel-ingress.d.ts.map +1 -0
- package/dist/channel-ingress.js +273 -0
- package/dist/channel-ingress.js.map +1 -0
- package/dist/channel.d.ts +146 -0
- package/dist/channel.d.ts.map +1 -0
- package/dist/channel.js +2 -0
- package/dist/channel.js.map +1 -0
- package/dist/checkpoints.d.ts +34 -0
- package/dist/checkpoints.d.ts.map +1 -0
- package/dist/checkpoints.js +86 -0
- package/dist/checkpoints.js.map +1 -0
- package/dist/code-mode.d.ts +20 -0
- package/dist/code-mode.d.ts.map +1 -0
- package/dist/code-mode.js +658 -0
- package/dist/code-mode.js.map +1 -0
- package/dist/computer-relay-protocol.d.ts +36 -0
- package/dist/computer-relay-protocol.d.ts.map +1 -0
- package/dist/computer-relay-protocol.js +127 -0
- package/dist/computer-relay-protocol.js.map +1 -0
- package/dist/concurrency.d.ts +68 -0
- package/dist/concurrency.d.ts.map +1 -0
- package/dist/concurrency.js +193 -0
- package/dist/concurrency.js.map +1 -0
- package/dist/connection-auth-util.d.ts +56 -0
- package/dist/connection-auth-util.d.ts.map +1 -0
- package/dist/connection-auth-util.js +154 -0
- package/dist/connection-auth-util.js.map +1 -0
- package/dist/connection-clients.d.ts +50 -0
- package/dist/connection-clients.d.ts.map +1 -0
- package/dist/connection-clients.js +402 -0
- package/dist/connection-clients.js.map +1 -0
- package/dist/connection-stores.d.ts +108 -0
- package/dist/connection-stores.d.ts.map +1 -0
- package/dist/connection-stores.js +127 -0
- package/dist/connection-stores.js.map +1 -0
- package/dist/connection-util.d.ts +27 -0
- package/dist/connection-util.d.ts.map +1 -0
- package/dist/connection-util.js +118 -0
- package/dist/connection-util.js.map +1 -0
- package/dist/connections.d.ts +152 -0
- package/dist/connections.d.ts.map +1 -0
- package/dist/connections.js +838 -0
- package/dist/connections.js.map +1 -0
- package/dist/content-capture.d.ts +32 -0
- package/dist/content-capture.d.ts.map +1 -0
- package/dist/content-capture.js +77 -0
- package/dist/content-capture.js.map +1 -0
- package/dist/context-policy-util.d.ts +45 -0
- package/dist/context-policy-util.d.ts.map +1 -0
- package/dist/context-policy-util.js +120 -0
- package/dist/context-policy-util.js.map +1 -0
- package/dist/conversation-context.d.ts +55 -0
- package/dist/conversation-context.d.ts.map +1 -0
- package/dist/conversation-context.js +179 -0
- package/dist/conversation-context.js.map +1 -0
- package/dist/conversation-transcript.d.ts +49 -0
- package/dist/conversation-transcript.d.ts.map +1 -0
- package/dist/conversation-transcript.js +77 -0
- package/dist/conversation-transcript.js.map +1 -0
- package/dist/conversation-turn-dispatch.d.ts +46 -0
- package/dist/conversation-turn-dispatch.d.ts.map +1 -0
- package/dist/conversation-turn-dispatch.js +201 -0
- package/dist/conversation-turn-dispatch.js.map +1 -0
- package/dist/delivery-queue.d.ts +89 -0
- package/dist/delivery-queue.d.ts.map +1 -0
- package/dist/delivery-queue.js +244 -0
- package/dist/delivery-queue.js.map +1 -0
- package/dist/delivery-send.d.ts +44 -0
- package/dist/delivery-send.d.ts.map +1 -0
- package/dist/delivery-send.js +494 -0
- package/dist/delivery-send.js.map +1 -0
- package/dist/env-config.d.ts +6 -0
- package/dist/env-config.d.ts.map +1 -0
- package/dist/env-config.js +27 -0
- package/dist/env-config.js.map +1 -0
- package/dist/eval-run-options.d.ts +37 -0
- package/dist/eval-run-options.d.ts.map +1 -0
- package/dist/eval-run-options.js +106 -0
- package/dist/eval-run-options.js.map +1 -0
- package/dist/harness-continuation.d.ts +54 -0
- package/dist/harness-continuation.d.ts.map +1 -0
- package/dist/harness-continuation.js +58 -0
- package/dist/harness-continuation.js.map +1 -0
- package/dist/harness-loop.d.ts +110 -0
- package/dist/harness-loop.d.ts.map +1 -0
- package/dist/harness-loop.js +575 -0
- package/dist/harness-loop.js.map +1 -0
- package/dist/hook-dispatch.d.ts +19 -0
- package/dist/hook-dispatch.d.ts.map +1 -0
- package/dist/hook-dispatch.js +37 -0
- package/dist/hook-dispatch.js.map +1 -0
- package/dist/http.d.ts +26 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +114 -0
- package/dist/http.js.map +1 -0
- package/dist/in-memory-conversation-turn-store.d.ts +29 -0
- package/dist/in-memory-conversation-turn-store.d.ts.map +1 -0
- package/dist/in-memory-conversation-turn-store.js +166 -0
- package/dist/in-memory-conversation-turn-store.js.map +1 -0
- package/dist/in-memory-run-store.d.ts +39 -0
- package/dist/in-memory-run-store.d.ts.map +1 -0
- package/dist/in-memory-run-store.js +332 -0
- package/dist/in-memory-run-store.js.map +1 -0
- package/dist/in-memory-sandbox-session-store.d.ts +33 -0
- package/dist/in-memory-sandbox-session-store.d.ts.map +1 -0
- package/dist/in-memory-sandbox-session-store.js +186 -0
- package/dist/in-memory-sandbox-session-store.js.map +1 -0
- package/dist/in-memory-small-stores.d.ts +117 -0
- package/dist/in-memory-small-stores.d.ts.map +1 -0
- package/dist/in-memory-small-stores.js +340 -0
- package/dist/in-memory-small-stores.js.map +1 -0
- package/dist/in-memory-usage-store.d.ts +15 -0
- package/dist/in-memory-usage-store.d.ts.map +1 -0
- package/dist/in-memory-usage-store.js +49 -0
- package/dist/in-memory-usage-store.js.map +1 -0
- package/dist/index.d.ts +467 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2046 -0
- package/dist/index.js.map +1 -0
- package/dist/json-util.d.ts +19 -0
- package/dist/json-util.d.ts.map +1 -0
- package/dist/json-util.js +59 -0
- package/dist/json-util.js.map +1 -0
- package/dist/local-sandbox.d.ts +16 -0
- package/dist/local-sandbox.d.ts.map +1 -0
- package/dist/local-sandbox.js +327 -0
- package/dist/local-sandbox.js.map +1 -0
- package/dist/logging.d.ts +16 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +41 -0
- package/dist/logging.js.map +1 -0
- package/dist/mcp-client.d.ts +27 -0
- package/dist/mcp-client.d.ts.map +1 -0
- package/dist/mcp-client.js +169 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/model-harnesses.d.ts +4 -0
- package/dist/model-harnesses.d.ts.map +1 -0
- package/dist/model-harnesses.js +6 -0
- package/dist/model-harnesses.js.map +1 -0
- package/dist/model-media.d.ts +36 -0
- package/dist/model-media.d.ts.map +1 -0
- package/dist/model-media.js +234 -0
- package/dist/model-media.js.map +1 -0
- package/dist/operator-controls.d.ts +31 -0
- package/dist/operator-controls.d.ts.map +1 -0
- package/dist/operator-controls.js +71 -0
- package/dist/operator-controls.js.map +1 -0
- package/dist/pi-agent-harness.d.ts +40 -0
- package/dist/pi-agent-harness.d.ts.map +1 -0
- package/dist/pi-agent-harness.js +222 -0
- package/dist/pi-agent-harness.js.map +1 -0
- package/dist/pi-harness.d.ts +42 -0
- package/dist/pi-harness.d.ts.map +1 -0
- package/dist/pi-harness.js +142 -0
- package/dist/pi-harness.js.map +1 -0
- package/dist/relay-mcp-client.d.ts +17 -0
- package/dist/relay-mcp-client.d.ts.map +1 -0
- package/dist/relay-mcp-client.js +119 -0
- package/dist/relay-mcp-client.js.map +1 -0
- package/dist/replay-resume.d.ts +107 -0
- package/dist/replay-resume.d.ts.map +1 -0
- package/dist/replay-resume.js +495 -0
- package/dist/replay-resume.js.map +1 -0
- package/dist/resource-projection-util.d.ts +58 -0
- package/dist/resource-projection-util.d.ts.map +1 -0
- package/dist/resource-projection-util.js +298 -0
- package/dist/resource-projection-util.js.map +1 -0
- package/dist/resource-projection.d.ts +45 -0
- package/dist/resource-projection.d.ts.map +1 -0
- package/dist/resource-projection.js +481 -0
- package/dist/resource-projection.js.map +1 -0
- package/dist/run-heartbeat.d.ts +34 -0
- package/dist/run-heartbeat.d.ts.map +1 -0
- package/dist/run-heartbeat.js +62 -0
- package/dist/run-heartbeat.js.map +1 -0
- package/dist/run-outcome.d.ts +47 -0
- package/dist/run-outcome.d.ts.map +1 -0
- package/dist/run-outcome.js +92 -0
- package/dist/run-outcome.js.map +1 -0
- package/dist/run-recovery.d.ts +117 -0
- package/dist/run-recovery.d.ts.map +1 -0
- package/dist/run-recovery.js +466 -0
- package/dist/run-recovery.js.map +1 -0
- package/dist/run-resolver.d.ts +35 -0
- package/dist/run-resolver.d.ts.map +1 -0
- package/dist/run-resolver.js +84 -0
- package/dist/run-resolver.js.map +1 -0
- package/dist/run-stream.d.ts +37 -0
- package/dist/run-stream.d.ts.map +1 -0
- package/dist/run-stream.js +78 -0
- package/dist/run-stream.js.map +1 -0
- package/dist/runs-query.d.ts +29 -0
- package/dist/runs-query.d.ts.map +1 -0
- package/dist/runs-query.js +142 -0
- package/dist/runs-query.js.map +1 -0
- package/dist/runtime-bundle.d.ts +3 -0
- package/dist/runtime-bundle.d.ts.map +1 -0
- package/dist/runtime-bundle.js +18 -0
- package/dist/runtime-bundle.js.map +1 -0
- package/dist/runtime-types.d.ts +397 -0
- package/dist/runtime-types.d.ts.map +1 -0
- package/dist/runtime-types.js +2 -0
- package/dist/runtime-types.js.map +1 -0
- package/dist/runtime-util.d.ts +45 -0
- package/dist/runtime-util.d.ts.map +1 -0
- package/dist/runtime-util.js +116 -0
- package/dist/runtime-util.js.map +1 -0
- package/dist/sandbox-cli-client.d.ts +20 -0
- package/dist/sandbox-cli-client.d.ts.map +1 -0
- package/dist/sandbox-cli-client.js +97 -0
- package/dist/sandbox-cli-client.js.map +1 -0
- package/dist/sandbox-fs.d.ts +56 -0
- package/dist/sandbox-fs.d.ts.map +1 -0
- package/dist/sandbox-fs.js +276 -0
- package/dist/sandbox-fs.js.map +1 -0
- package/dist/sandbox-session-key.d.ts +8 -0
- package/dist/sandbox-session-key.d.ts.map +1 -0
- package/dist/sandbox-session-key.js +32 -0
- package/dist/sandbox-session-key.js.map +1 -0
- package/dist/sandbox-snapshot-policy.d.ts +27 -0
- package/dist/sandbox-snapshot-policy.d.ts.map +1 -0
- package/dist/sandbox-snapshot-policy.js +94 -0
- package/dist/sandbox-snapshot-policy.js.map +1 -0
- package/dist/sandbox-sync-worker.d.ts +63 -0
- package/dist/sandbox-sync-worker.d.ts.map +1 -0
- package/dist/sandbox-sync-worker.js +448 -0
- package/dist/sandbox-sync-worker.js.map +1 -0
- package/dist/schedule-execution.d.ts +59 -0
- package/dist/schedule-execution.d.ts.map +1 -0
- package/dist/schedule-execution.js +951 -0
- package/dist/schedule-execution.js.map +1 -0
- package/dist/scheduler.d.ts +19 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +38 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/security.d.ts +20 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +145 -0
- package/dist/security.js.map +1 -0
- package/dist/self-improvement.d.ts +245 -0
- package/dist/self-improvement.d.ts.map +1 -0
- package/dist/self-improvement.js +554 -0
- package/dist/self-improvement.js.map +1 -0
- package/dist/source-loader.d.ts +19 -0
- package/dist/source-loader.d.ts.map +1 -0
- package/dist/source-loader.js +160 -0
- package/dist/source-loader.js.map +1 -0
- package/dist/state-store-helpers.d.ts +28 -0
- package/dist/state-store-helpers.d.ts.map +1 -0
- package/dist/state-store-helpers.js +164 -0
- package/dist/state-store-helpers.js.map +1 -0
- package/dist/state-stores.d.ts +25 -0
- package/dist/state-stores.d.ts.map +1 -0
- package/dist/state-stores.js +157 -0
- package/dist/state-stores.js.map +1 -0
- package/dist/state.d.ts +736 -0
- package/dist/state.d.ts.map +1 -0
- package/dist/state.js +46 -0
- package/dist/state.js.map +1 -0
- package/dist/storage.d.ts +188 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +752 -0
- package/dist/storage.js.map +1 -0
- package/dist/subagent-execution.d.ts +80 -0
- package/dist/subagent-execution.d.ts.map +1 -0
- package/dist/subagent-execution.js +135 -0
- package/dist/subagent-execution.js.map +1 -0
- package/dist/telemetry.d.ts +49 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +60 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/tool-apis.d.ts +22 -0
- package/dist/tool-apis.d.ts.map +1 -0
- package/dist/tool-apis.js +344 -0
- package/dist/tool-apis.js.map +1 -0
- package/dist/tool-execution.d.ts +143 -0
- package/dist/tool-execution.d.ts.map +1 -0
- package/dist/tool-execution.js +573 -0
- package/dist/tool-execution.js.map +1 -0
- package/dist/trusted-attachments.d.ts +20 -0
- package/dist/trusted-attachments.d.ts.map +1 -0
- package/dist/trusted-attachments.js +276 -0
- package/dist/trusted-attachments.js.map +1 -0
- package/dist/usage-accounting.d.ts +37 -0
- package/dist/usage-accounting.d.ts.map +1 -0
- package/dist/usage-accounting.js +181 -0
- package/dist/usage-accounting.js.map +1 -0
- package/dist/usage-budget.d.ts +29 -0
- package/dist/usage-budget.d.ts.map +1 -0
- package/dist/usage-budget.js +145 -0
- package/dist/usage-budget.js.map +1 -0
- package/dist/usage-reconciliation.d.ts +76 -0
- package/dist/usage-reconciliation.d.ts.map +1 -0
- package/dist/usage-reconciliation.js +463 -0
- package/dist/usage-reconciliation.js.map +1 -0
- package/dist/usage-records.d.ts +24 -0
- package/dist/usage-records.d.ts.map +1 -0
- package/dist/usage-records.js +445 -0
- package/dist/usage-records.js.map +1 -0
- package/package.json +51 -0
package/dist/state.d.ts
ADDED
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue, MemoryListInput, MemorySearchInput } from "@assemblyline-agents/core";
|
|
2
|
+
import type { DeliveryFailureInput, DeliveryLeaseOptions, DeliveryObligationInput, DeliveryObligationPatch } from "./delivery-queue.js";
|
|
3
|
+
/**
|
|
4
|
+
* Durable state contracts for the OpenEve runtime.
|
|
5
|
+
*
|
|
6
|
+
* The historical monolithic `StateAdapter` is decomposed into capability
|
|
7
|
+
* interfaces: `RunStore` is required, everything else is optional. The
|
|
8
|
+
* `StateAdapter` type stays the intersection of every facet so existing
|
|
9
|
+
* adapters (Postgres/File/InMemory) keep compiling without edits, while
|
|
10
|
+
* `StateStores` lets embedders bring only the facets they can persist.
|
|
11
|
+
*/
|
|
12
|
+
export type RunStatus = "created" | "running" | "waiting_for_approval" | "waiting_for_input" | "waiting_for_connection" | "suspended" | "completed" | "failed" | "cancelled";
|
|
13
|
+
export type RunEventType = "run.accepted" | "context.bundle_built" | "sandbox.acquired" | "sandbox.snapshot_created" | "sandbox.snapshot_failed" | "sandbox.snapshot_skipped" | "sandbox.command_completed" | "sandbox.file_written" | "sandbox.file_read" | "harness.started" | "model.request_started" | "model.response_completed" | "tool.call_requested" | "tool.approval_requested" | "tool.approval_auto_resolved" | "eval.judged" | "tool.execution_started" | "tool.execution_completed" | "tool.execution_failed" | "human_input.requested" | "memory.sync_completed" | "delivery.obligation_created" | "delivery.sent" | "run.completed" | "run.failed" | "run.execution_error" | "run.max_duration_exceeded" | "model.request_retried" | "run.suspend_requested" | "run.suspended" | "run.resumed" | "run.cancel_requested" | "run.cancelled" | "agent.disabled" | "agent.enabled" | string;
|
|
14
|
+
export interface RunRecord {
|
|
15
|
+
id: string;
|
|
16
|
+
agentRevision: string;
|
|
17
|
+
status: RunStatus;
|
|
18
|
+
input: JsonObject;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
contextBundleId?: string;
|
|
22
|
+
sandboxId?: string;
|
|
23
|
+
sandboxSnapshotId?: string;
|
|
24
|
+
memoryRevision?: string;
|
|
25
|
+
/** Explicit undefined is accepted by update patches to clear a pending intent. */
|
|
26
|
+
controlIntent?: RunControlIntent | undefined;
|
|
27
|
+
/** Machine-readable failure reason, set when the run reaches `failed`. Null for successes. */
|
|
28
|
+
terminalReason?: string;
|
|
29
|
+
/** Human-readable failure message, set alongside `terminalReason`. */
|
|
30
|
+
terminalError?: string;
|
|
31
|
+
}
|
|
32
|
+
export type RunControlIntent = "suspend" | "cancel";
|
|
33
|
+
export interface RuntimeSettingRecord {
|
|
34
|
+
scope: string;
|
|
35
|
+
key: string;
|
|
36
|
+
value: JsonValue;
|
|
37
|
+
updatedAt: string;
|
|
38
|
+
}
|
|
39
|
+
export interface RuntimeControlEvent {
|
|
40
|
+
id: string;
|
|
41
|
+
scope: string;
|
|
42
|
+
type: string;
|
|
43
|
+
timestamp: string;
|
|
44
|
+
data: JsonObject;
|
|
45
|
+
}
|
|
46
|
+
export interface RunEvent {
|
|
47
|
+
id: string;
|
|
48
|
+
runId: string;
|
|
49
|
+
sequence: number;
|
|
50
|
+
type: RunEventType;
|
|
51
|
+
timestamp: string;
|
|
52
|
+
data: JsonObject;
|
|
53
|
+
}
|
|
54
|
+
export interface ToolCallRecord {
|
|
55
|
+
id: string;
|
|
56
|
+
runId: string;
|
|
57
|
+
toolName: string;
|
|
58
|
+
status: "requested" | "waiting_for_approval" | "running" | "completed" | "failed" | "cancelled" | "timeout";
|
|
59
|
+
input: unknown;
|
|
60
|
+
result?: unknown;
|
|
61
|
+
modelOutput?: unknown;
|
|
62
|
+
error?: string;
|
|
63
|
+
idempotencyKey: string;
|
|
64
|
+
createdAt: string;
|
|
65
|
+
updatedAt: string;
|
|
66
|
+
}
|
|
67
|
+
export interface CheckpointRecord {
|
|
68
|
+
id: string;
|
|
69
|
+
runId: string;
|
|
70
|
+
name: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
data: JsonObject;
|
|
73
|
+
}
|
|
74
|
+
export type CheckpointRetentionReason = "active_compaction" | "terminal_ttl";
|
|
75
|
+
export interface CheckpointRetentionOptions {
|
|
76
|
+
/** Report candidate rows/bytes without deleting anything. */
|
|
77
|
+
dryRun?: boolean;
|
|
78
|
+
/** Restrict maintenance to one run. */
|
|
79
|
+
runId?: string;
|
|
80
|
+
/** Restrict active compaction to these checkpoint names. Terminal TTL still applies to all names. */
|
|
81
|
+
activeNames?: string[] | undefined;
|
|
82
|
+
/** Clock used for TTL cutoffs. Defaults to the adapter/runtime clock. */
|
|
83
|
+
now?: Date | string | undefined;
|
|
84
|
+
/** Active/waiting runs keep only this many latest checkpoints per (run_id, name). */
|
|
85
|
+
maxActivePerRunName?: number | undefined;
|
|
86
|
+
/** Completed/cancelled terminal runs lose checkpoints after this age. */
|
|
87
|
+
terminalTtlMs?: number | undefined;
|
|
88
|
+
/** Failed terminal runs lose checkpoints after this age. */
|
|
89
|
+
failedRunTtlMs?: number | undefined;
|
|
90
|
+
/** Scheduled terminal runs can use a shorter checkpoint TTL. */
|
|
91
|
+
scheduledRunTtlMs?: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
export interface CheckpointRetentionResult {
|
|
94
|
+
dryRun: boolean;
|
|
95
|
+
candidateRows: number;
|
|
96
|
+
candidateBytes: number;
|
|
97
|
+
prunedRows: number;
|
|
98
|
+
prunedBytes: number;
|
|
99
|
+
byReason: Record<CheckpointRetentionReason, {
|
|
100
|
+
rows: number;
|
|
101
|
+
bytes: number;
|
|
102
|
+
}>;
|
|
103
|
+
}
|
|
104
|
+
export interface DeliveryObligation {
|
|
105
|
+
id: string;
|
|
106
|
+
runId: string;
|
|
107
|
+
channel: string;
|
|
108
|
+
payload: JsonObject;
|
|
109
|
+
idempotencyKey: string;
|
|
110
|
+
status: "pending" | "sending" | "sent" | "failed";
|
|
111
|
+
attemptCount: number;
|
|
112
|
+
maxAttempts: number;
|
|
113
|
+
nextAttemptAt: string;
|
|
114
|
+
leaseToken?: string;
|
|
115
|
+
leaseExpiresAt?: string;
|
|
116
|
+
lastError?: string;
|
|
117
|
+
sentAt?: string;
|
|
118
|
+
failedAt?: string;
|
|
119
|
+
createdAt: string;
|
|
120
|
+
updatedAt: string;
|
|
121
|
+
}
|
|
122
|
+
export interface ConversationRecord {
|
|
123
|
+
id: string;
|
|
124
|
+
/** Stable logical agent identity. Unlike agentRevision, this survives deploys. */
|
|
125
|
+
agentScope?: string;
|
|
126
|
+
agentRevision: string;
|
|
127
|
+
channel: string;
|
|
128
|
+
subject?: string;
|
|
129
|
+
title?: string;
|
|
130
|
+
archivedAt?: string;
|
|
131
|
+
metadata: JsonObject;
|
|
132
|
+
createdAt: string;
|
|
133
|
+
updatedAt: string;
|
|
134
|
+
}
|
|
135
|
+
export interface ConversationCursor {
|
|
136
|
+
updatedAt: string;
|
|
137
|
+
id: string;
|
|
138
|
+
}
|
|
139
|
+
export interface MessageCursor {
|
|
140
|
+
createdAt: string;
|
|
141
|
+
id: string;
|
|
142
|
+
}
|
|
143
|
+
export interface MessageRecord {
|
|
144
|
+
id: string;
|
|
145
|
+
conversationId: string;
|
|
146
|
+
runId?: string;
|
|
147
|
+
role: "user" | "assistant" | "tool" | "system";
|
|
148
|
+
content: JsonObject;
|
|
149
|
+
createdAt: string;
|
|
150
|
+
}
|
|
151
|
+
export type ConversationTurnStatus = "pending" | "running" | "blocked" | "completed" | "failed" | "cancelled";
|
|
152
|
+
/**
|
|
153
|
+
* Durable ingress mailbox row. A conversation may have at most one
|
|
154
|
+
* `running`/`blocked` row; later turns remain `pending` in provider order.
|
|
155
|
+
*/
|
|
156
|
+
export interface ConversationTurnRecord {
|
|
157
|
+
id: string;
|
|
158
|
+
agentScope: string;
|
|
159
|
+
conversationId: string;
|
|
160
|
+
channel: string;
|
|
161
|
+
eventId: string;
|
|
162
|
+
payload: JsonObject;
|
|
163
|
+
idempotencyScope: string;
|
|
164
|
+
idempotencyKey: string;
|
|
165
|
+
status: ConversationTurnStatus;
|
|
166
|
+
runId?: string;
|
|
167
|
+
attemptCount: number;
|
|
168
|
+
maxAttempts: number;
|
|
169
|
+
nextAttemptAt: string;
|
|
170
|
+
leaseToken?: string;
|
|
171
|
+
leaseExpiresAt?: string;
|
|
172
|
+
lastError?: string;
|
|
173
|
+
createdAt: string;
|
|
174
|
+
updatedAt: string;
|
|
175
|
+
}
|
|
176
|
+
export interface ScheduleRecord {
|
|
177
|
+
id: string;
|
|
178
|
+
name: string;
|
|
179
|
+
cron: string;
|
|
180
|
+
timezone?: string;
|
|
181
|
+
metadata: JsonObject;
|
|
182
|
+
createdAt: string;
|
|
183
|
+
updatedAt: string;
|
|
184
|
+
}
|
|
185
|
+
export interface ScheduleRunRecord {
|
|
186
|
+
id: string;
|
|
187
|
+
scheduleId: string;
|
|
188
|
+
runId?: string;
|
|
189
|
+
status: string;
|
|
190
|
+
runAt: string;
|
|
191
|
+
idempotencyKey: string;
|
|
192
|
+
createdAt: string;
|
|
193
|
+
updatedAt: string;
|
|
194
|
+
}
|
|
195
|
+
export interface FileIndexRecord {
|
|
196
|
+
id: string;
|
|
197
|
+
runId?: string;
|
|
198
|
+
path: string;
|
|
199
|
+
kind: "memory" | "artifact" | "file";
|
|
200
|
+
blobKey: string;
|
|
201
|
+
sha256: string;
|
|
202
|
+
sizeBytes: number;
|
|
203
|
+
metadata: JsonObject;
|
|
204
|
+
createdAt: string;
|
|
205
|
+
}
|
|
206
|
+
export type UsageBillingMode = "api_key" | "chatgpt" | "byok" | "subscription" | "unknown";
|
|
207
|
+
export type UsageTokenSource = "provider_reported" | "provider_reconciled" | "unavailable";
|
|
208
|
+
export type UsageCostSource = "provider_reported" | "provider_reconciled" | "unavailable";
|
|
209
|
+
export type UsageRecordKind = "transaction" | "control_total" | "adjustment";
|
|
210
|
+
export interface UsageRecordInput {
|
|
211
|
+
idempotencyKey?: string;
|
|
212
|
+
runId?: string;
|
|
213
|
+
parentRunId?: string;
|
|
214
|
+
agentId?: string;
|
|
215
|
+
agentRevision?: string;
|
|
216
|
+
subagent?: string;
|
|
217
|
+
turnId?: string;
|
|
218
|
+
iteration?: number;
|
|
219
|
+
provider?: string;
|
|
220
|
+
providerRequestId?: string;
|
|
221
|
+
model?: string;
|
|
222
|
+
responseModel?: string;
|
|
223
|
+
billingMode?: UsageBillingMode;
|
|
224
|
+
recordKind?: UsageRecordKind;
|
|
225
|
+
/** Total provider input including cached input. */
|
|
226
|
+
inputTokens?: number;
|
|
227
|
+
outputTokens?: number;
|
|
228
|
+
/** Subset of inputTokens served from cache. */
|
|
229
|
+
cachedTokens?: number;
|
|
230
|
+
/** Subset of inputTokens written to an explicit provider cache. */
|
|
231
|
+
cacheWriteTokens?: number;
|
|
232
|
+
/** Subset of outputTokens consumed by reasoning. */
|
|
233
|
+
reasoningTokens?: number;
|
|
234
|
+
/** Actual provider-reported/reconciled USD. Never use for estimates. */
|
|
235
|
+
costUsd?: number | null;
|
|
236
|
+
upstreamCostUsd?: number | null;
|
|
237
|
+
currency?: string;
|
|
238
|
+
tokenSource?: UsageTokenSource;
|
|
239
|
+
costSource?: UsageCostSource;
|
|
240
|
+
providerReceipt?: JsonObject;
|
|
241
|
+
receiptSha256?: string;
|
|
242
|
+
metadata?: JsonObject;
|
|
243
|
+
occurredAt?: string;
|
|
244
|
+
}
|
|
245
|
+
export interface UsageRecord {
|
|
246
|
+
id: string;
|
|
247
|
+
idempotencyKey: string;
|
|
248
|
+
runId?: string;
|
|
249
|
+
parentRunId?: string;
|
|
250
|
+
agentId?: string;
|
|
251
|
+
agentRevision?: string;
|
|
252
|
+
subagent?: string;
|
|
253
|
+
turnId?: string;
|
|
254
|
+
iteration?: number;
|
|
255
|
+
provider?: string;
|
|
256
|
+
providerRequestId?: string;
|
|
257
|
+
model?: string;
|
|
258
|
+
responseModel?: string;
|
|
259
|
+
billingMode: UsageBillingMode;
|
|
260
|
+
recordKind: UsageRecordKind;
|
|
261
|
+
inputTokens: number;
|
|
262
|
+
outputTokens: number;
|
|
263
|
+
cachedTokens: number;
|
|
264
|
+
cacheWriteTokens: number;
|
|
265
|
+
reasoningTokens: number;
|
|
266
|
+
/** Exact integer micro-dollars serialized as a decimal string. */
|
|
267
|
+
costMicros: string | null;
|
|
268
|
+
upstreamCostMicros: string | null;
|
|
269
|
+
/** Convenience projections; exact accounting uses the micro-dollar fields. */
|
|
270
|
+
costUsd: number | null;
|
|
271
|
+
upstreamCostUsd: number | null;
|
|
272
|
+
currency: string;
|
|
273
|
+
tokenSource: UsageTokenSource;
|
|
274
|
+
costSource: UsageCostSource;
|
|
275
|
+
providerReceipt: JsonObject;
|
|
276
|
+
receiptSha256?: string;
|
|
277
|
+
metadata: JsonObject;
|
|
278
|
+
occurredAt: string;
|
|
279
|
+
createdAt: string;
|
|
280
|
+
}
|
|
281
|
+
export type UsageGroupBy = "agentId" | "agentRevision" | "runId" | "parentRunId" | "subagent" | "provider" | "model" | "responseModel" | "billingMode" | "currency" | "tokenSource" | "costSource" | "recordKind" | "day" | "month";
|
|
282
|
+
export interface UsageQuery {
|
|
283
|
+
runId?: string;
|
|
284
|
+
parentRunId?: string;
|
|
285
|
+
agentId?: string;
|
|
286
|
+
agentRevision?: string;
|
|
287
|
+
subagent?: string;
|
|
288
|
+
provider?: string;
|
|
289
|
+
model?: string;
|
|
290
|
+
responseModel?: string;
|
|
291
|
+
billingMode?: UsageBillingMode;
|
|
292
|
+
currency?: string;
|
|
293
|
+
tokenSource?: UsageTokenSource;
|
|
294
|
+
costSource?: UsageCostSource;
|
|
295
|
+
recordKind?: UsageRecordKind;
|
|
296
|
+
from?: string;
|
|
297
|
+
to?: string;
|
|
298
|
+
before?: {
|
|
299
|
+
occurredAt: string;
|
|
300
|
+
id: string;
|
|
301
|
+
};
|
|
302
|
+
limit?: number;
|
|
303
|
+
}
|
|
304
|
+
export interface UsageSummaryQuery extends Omit<UsageQuery, "before" | "limit"> {
|
|
305
|
+
groupBy?: UsageGroupBy[];
|
|
306
|
+
}
|
|
307
|
+
export interface UsageAggregate {
|
|
308
|
+
dimensions: JsonObject;
|
|
309
|
+
recordCount: string;
|
|
310
|
+
inputTokens: string;
|
|
311
|
+
outputTokens: string;
|
|
312
|
+
cachedTokens: string;
|
|
313
|
+
cacheWriteTokens: string;
|
|
314
|
+
reasoningTokens: string;
|
|
315
|
+
actualCostMicros: string;
|
|
316
|
+
upstreamCostMicros: string;
|
|
317
|
+
currency: string;
|
|
318
|
+
unavailableCostRecords: string;
|
|
319
|
+
unreconciledTokenRecords: string;
|
|
320
|
+
/** Records without provider-reported/reconciled cash. */
|
|
321
|
+
unreconciledRecords: string;
|
|
322
|
+
}
|
|
323
|
+
export interface SandboxSnapshotRecord {
|
|
324
|
+
id: string;
|
|
325
|
+
runId: string;
|
|
326
|
+
sandboxId: string;
|
|
327
|
+
snapshotId: string;
|
|
328
|
+
metadata: JsonObject;
|
|
329
|
+
createdAt: string;
|
|
330
|
+
}
|
|
331
|
+
export interface SandboxSyncJobRecord {
|
|
332
|
+
id: string;
|
|
333
|
+
runId: string;
|
|
334
|
+
sandboxId: string;
|
|
335
|
+
status: "pending" | "running" | "completed" | "failed" | "blocked_requires_operator";
|
|
336
|
+
idempotencyKey: string;
|
|
337
|
+
reason: string;
|
|
338
|
+
manifest: JsonObject;
|
|
339
|
+
error?: string;
|
|
340
|
+
attemptCount: number;
|
|
341
|
+
maxAttempts: number;
|
|
342
|
+
nextAttemptAt: string;
|
|
343
|
+
leaseToken?: string;
|
|
344
|
+
leaseExpiresAt?: string;
|
|
345
|
+
completedAt?: string;
|
|
346
|
+
failedAt?: string;
|
|
347
|
+
lastError?: string;
|
|
348
|
+
metadata: JsonObject;
|
|
349
|
+
createdAt: string;
|
|
350
|
+
updatedAt: string;
|
|
351
|
+
}
|
|
352
|
+
export interface SandboxSessionRecord {
|
|
353
|
+
id: string;
|
|
354
|
+
sessionKey: string;
|
|
355
|
+
provider: string;
|
|
356
|
+
sandboxId: string;
|
|
357
|
+
runId?: string;
|
|
358
|
+
state: "live" | "warm" | "dirty" | "clean" | "blocked_requires_operator";
|
|
359
|
+
dirty: boolean;
|
|
360
|
+
lastSeenAt: string;
|
|
361
|
+
lastSyncedAt?: string;
|
|
362
|
+
snapshotId?: string;
|
|
363
|
+
syncJobId?: string;
|
|
364
|
+
manifest: JsonObject;
|
|
365
|
+
createdAt: string;
|
|
366
|
+
updatedAt: string;
|
|
367
|
+
}
|
|
368
|
+
export type SandboxSessionInput = Omit<SandboxSessionRecord, "id" | "createdAt" | "updatedAt"> & {
|
|
369
|
+
id?: string;
|
|
370
|
+
createdAt?: string;
|
|
371
|
+
updatedAt?: string;
|
|
372
|
+
};
|
|
373
|
+
export type SandboxSessionPatch = {
|
|
374
|
+
[K in keyof Omit<SandboxSessionRecord, "id" | "createdAt" | "sessionKey">]?: Omit<SandboxSessionRecord, "id" | "createdAt" | "sessionKey">[K] | undefined;
|
|
375
|
+
};
|
|
376
|
+
export type SandboxSyncJobInput = Omit<SandboxSyncJobRecord, "id" | "createdAt" | "updatedAt" | "attemptCount" | "maxAttempts" | "nextAttemptAt" | "metadata"> & {
|
|
377
|
+
attemptCount?: number;
|
|
378
|
+
maxAttempts?: number;
|
|
379
|
+
nextAttemptAt?: string;
|
|
380
|
+
metadata?: JsonObject;
|
|
381
|
+
};
|
|
382
|
+
export interface SandboxSyncLeaseOptions {
|
|
383
|
+
now?: Date;
|
|
384
|
+
limit?: number;
|
|
385
|
+
leaseForMs?: number;
|
|
386
|
+
}
|
|
387
|
+
export interface SandboxSyncFailureInput {
|
|
388
|
+
error: string;
|
|
389
|
+
now?: Date;
|
|
390
|
+
retryDelayMs?: number;
|
|
391
|
+
}
|
|
392
|
+
export interface SandboxSyncExecutionResult {
|
|
393
|
+
jobId: string;
|
|
394
|
+
status: "completed" | "retrying" | "failed";
|
|
395
|
+
run?: RunRecord;
|
|
396
|
+
error?: string;
|
|
397
|
+
}
|
|
398
|
+
export interface SandboxSyncDiagnostics {
|
|
399
|
+
total: number;
|
|
400
|
+
byStatus: Record<string, number>;
|
|
401
|
+
due: number;
|
|
402
|
+
leased: number;
|
|
403
|
+
expiredLeases: number;
|
|
404
|
+
failed: number;
|
|
405
|
+
blockedRequiresOperator: number;
|
|
406
|
+
}
|
|
407
|
+
export interface SandboxSyncJobInspection {
|
|
408
|
+
job: SandboxSyncJobRecord;
|
|
409
|
+
due: boolean;
|
|
410
|
+
leaseExpired: boolean;
|
|
411
|
+
}
|
|
412
|
+
export type SandboxSyncJobPatch = {
|
|
413
|
+
[Key in keyof Omit<SandboxSyncJobRecord, "id" | "createdAt">]?: Omit<SandboxSyncJobRecord, "id" | "createdAt">[Key] | undefined;
|
|
414
|
+
};
|
|
415
|
+
export interface MemoryScope {
|
|
416
|
+
agentScope: string;
|
|
417
|
+
userId?: string;
|
|
418
|
+
conversationId?: string;
|
|
419
|
+
projectId?: string;
|
|
420
|
+
}
|
|
421
|
+
export interface MemoryDocument {
|
|
422
|
+
scope: MemoryScope;
|
|
423
|
+
path: string;
|
|
424
|
+
body: string | {
|
|
425
|
+
blobKey: string;
|
|
426
|
+
};
|
|
427
|
+
contentType: "text/markdown" | "application/json" | "text/plain";
|
|
428
|
+
title?: string;
|
|
429
|
+
summary?: string;
|
|
430
|
+
tags: string[];
|
|
431
|
+
confidence?: "low" | "medium" | "high";
|
|
432
|
+
sourceRefs?: string[];
|
|
433
|
+
tokenEstimate: number;
|
|
434
|
+
sha256: string;
|
|
435
|
+
revision: string;
|
|
436
|
+
createdAt: string;
|
|
437
|
+
updatedAt: string;
|
|
438
|
+
}
|
|
439
|
+
export interface MemorySearchResult {
|
|
440
|
+
path: string;
|
|
441
|
+
title?: string;
|
|
442
|
+
summary?: string;
|
|
443
|
+
snippet: string;
|
|
444
|
+
revision: string;
|
|
445
|
+
tags: string[];
|
|
446
|
+
updatedAt: string;
|
|
447
|
+
rankReason: string;
|
|
448
|
+
}
|
|
449
|
+
export interface MemoryEmbeddingProvider {
|
|
450
|
+
model: string;
|
|
451
|
+
dimensions?: number;
|
|
452
|
+
maxInputTokens?: number;
|
|
453
|
+
embed(input: {
|
|
454
|
+
text: string;
|
|
455
|
+
purpose: "query" | "document";
|
|
456
|
+
model?: string;
|
|
457
|
+
metadata?: JsonObject;
|
|
458
|
+
}): Promise<{
|
|
459
|
+
embedding: number[];
|
|
460
|
+
model?: string;
|
|
461
|
+
dimensions?: number;
|
|
462
|
+
}> | {
|
|
463
|
+
embedding: number[];
|
|
464
|
+
model?: string;
|
|
465
|
+
dimensions?: number;
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
export interface MemoryEmbeddingRecord {
|
|
469
|
+
id: string;
|
|
470
|
+
scope: MemoryScope;
|
|
471
|
+
path: string;
|
|
472
|
+
model: string;
|
|
473
|
+
dimensions: number;
|
|
474
|
+
contentSha256: string;
|
|
475
|
+
embedding: number[];
|
|
476
|
+
stale: boolean;
|
|
477
|
+
metadata: JsonObject;
|
|
478
|
+
createdAt: string;
|
|
479
|
+
updatedAt: string;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Required facet: runs, events, tool calls, checkpoints, deliveries
|
|
483
|
+
* (including the durable delivery queue), and idempotency reservations.
|
|
484
|
+
*/
|
|
485
|
+
export interface RunStore {
|
|
486
|
+
createRun(input: Omit<RunRecord, "id" | "createdAt" | "updatedAt">): Promise<RunRecord>;
|
|
487
|
+
updateRun(id: string, patch: Partial<Omit<RunRecord, "id" | "createdAt">>): Promise<RunRecord>;
|
|
488
|
+
/**
|
|
489
|
+
* Heartbeat: bump `updatedAt` only, and only while the run is still
|
|
490
|
+
* `created`/`running`. Unlike `updateRun`, this must never write any other
|
|
491
|
+
* column, so a heartbeat racing a status transition cannot clobber it.
|
|
492
|
+
*/
|
|
493
|
+
touchRun?(id: string): Promise<void>;
|
|
494
|
+
/** Atomically request suspend/cancel with cancel precedence across replicas. */
|
|
495
|
+
requestRunControl?(id: string, intent: RunControlIntent): Promise<RunRecord>;
|
|
496
|
+
/** Atomically apply the latest pending control intent and clear it. */
|
|
497
|
+
settleRunControl?(id: string): Promise<RunRecord>;
|
|
498
|
+
getRun(id: string): Promise<RunRecord | undefined>;
|
|
499
|
+
listRuns(): Promise<RunRecord[]>;
|
|
500
|
+
appendEvent(runId: string, type: RunEventType, data?: JsonObject): Promise<RunEvent>;
|
|
501
|
+
listEvents(runId: string): Promise<RunEvent[]>;
|
|
502
|
+
createToolCall(input: Omit<ToolCallRecord, "id" | "createdAt" | "updatedAt">): Promise<ToolCallRecord>;
|
|
503
|
+
updateToolCall(id: string, patch: Partial<Omit<ToolCallRecord, "id" | "createdAt">>): Promise<ToolCallRecord>;
|
|
504
|
+
listToolCalls(runId: string): Promise<ToolCallRecord[]>;
|
|
505
|
+
createCheckpoint(input: Omit<CheckpointRecord, "id" | "createdAt">): Promise<CheckpointRecord>;
|
|
506
|
+
listCheckpoints(runId: string): Promise<CheckpointRecord[]>;
|
|
507
|
+
compactCheckpoints?(options?: CheckpointRetentionOptions): Promise<CheckpointRetentionResult>;
|
|
508
|
+
createDelivery(input: DeliveryObligationInput): Promise<DeliveryObligation>;
|
|
509
|
+
updateDelivery(id: string, patch: DeliveryObligationPatch): Promise<DeliveryObligation>;
|
|
510
|
+
listDeliveries(runId: string): Promise<DeliveryObligation[]>;
|
|
511
|
+
leaseDueDeliveries?(options?: DeliveryLeaseOptions): Promise<DeliveryObligation[]>;
|
|
512
|
+
completeDeliverySend?(id: string, leaseToken: string, patch?: {
|
|
513
|
+
payload?: JsonObject;
|
|
514
|
+
}): Promise<DeliveryObligation>;
|
|
515
|
+
failDeliverySend?(id: string, leaseToken: string, failure: DeliveryFailureInput): Promise<DeliveryObligation>;
|
|
516
|
+
recoverExpiredDeliveries?(now?: Date): Promise<DeliveryObligation[]>;
|
|
517
|
+
listRunsByStatus?(statuses: RunStatus[], options?: {
|
|
518
|
+
updatedBefore?: string;
|
|
519
|
+
limit?: number;
|
|
520
|
+
}): Promise<RunRecord[]>;
|
|
521
|
+
reserveIdempotencyKey(scope: string, key: string, ownerId?: string): Promise<boolean>;
|
|
522
|
+
/** Release owned connections/resources; called once during graceful shutdown. */
|
|
523
|
+
close?(): Promise<void> | void;
|
|
524
|
+
}
|
|
525
|
+
/** Optional facet: conversations and message history. */
|
|
526
|
+
export interface ConversationStore {
|
|
527
|
+
upsertConversation(input: {
|
|
528
|
+
id: string;
|
|
529
|
+
agentScope?: string;
|
|
530
|
+
agentRevision: string;
|
|
531
|
+
channel: string;
|
|
532
|
+
subject?: string;
|
|
533
|
+
title?: string;
|
|
534
|
+
metadata?: JsonObject;
|
|
535
|
+
}): Promise<ConversationRecord>;
|
|
536
|
+
getConversation(id: string): Promise<ConversationRecord | undefined>;
|
|
537
|
+
listConversations?(input: {
|
|
538
|
+
agentScope: string;
|
|
539
|
+
channel?: string;
|
|
540
|
+
subject?: string;
|
|
541
|
+
archived?: boolean;
|
|
542
|
+
before?: ConversationCursor;
|
|
543
|
+
limit?: number;
|
|
544
|
+
}): Promise<ConversationRecord[]>;
|
|
545
|
+
updateConversation?(id: string, patch: {
|
|
546
|
+
title?: string | null;
|
|
547
|
+
archivedAt?: string | null;
|
|
548
|
+
metadata?: JsonObject;
|
|
549
|
+
}): Promise<ConversationRecord | undefined>;
|
|
550
|
+
listRecentConversationsBySubject?(input: {
|
|
551
|
+
channel: string;
|
|
552
|
+
subject: string;
|
|
553
|
+
since?: string;
|
|
554
|
+
limit?: number;
|
|
555
|
+
excludeId?: string;
|
|
556
|
+
}): Promise<ConversationRecord[]>;
|
|
557
|
+
appendMessage(input: {
|
|
558
|
+
conversationId: string;
|
|
559
|
+
runId?: string;
|
|
560
|
+
role: MessageRecord["role"];
|
|
561
|
+
content: JsonObject;
|
|
562
|
+
}): Promise<MessageRecord>;
|
|
563
|
+
listRecentMessages(conversationId: string, limit?: number): Promise<MessageRecord[]>;
|
|
564
|
+
listMessages?(input: {
|
|
565
|
+
conversationId: string;
|
|
566
|
+
before?: MessageCursor;
|
|
567
|
+
limit?: number;
|
|
568
|
+
}): Promise<MessageRecord[]>;
|
|
569
|
+
}
|
|
570
|
+
/** Optional facet: durable, per-conversation FIFO ingress mailbox. */
|
|
571
|
+
export interface ConversationTurnStore {
|
|
572
|
+
enqueueConversationTurn(input: {
|
|
573
|
+
agentScope: string;
|
|
574
|
+
conversationId: string;
|
|
575
|
+
channel: string;
|
|
576
|
+
eventId: string;
|
|
577
|
+
payload: JsonObject;
|
|
578
|
+
idempotencyScope: string;
|
|
579
|
+
idempotencyKey: string;
|
|
580
|
+
maxAttempts?: number;
|
|
581
|
+
}): Promise<{
|
|
582
|
+
turn: ConversationTurnRecord;
|
|
583
|
+
inserted: boolean;
|
|
584
|
+
}>;
|
|
585
|
+
leaseNextConversationTurn(options: {
|
|
586
|
+
agentScope: string;
|
|
587
|
+
leaseForMs: number;
|
|
588
|
+
now?: Date;
|
|
589
|
+
}): Promise<ConversationTurnRecord | undefined>;
|
|
590
|
+
attachConversationTurnRun(id: string, leaseToken: string, runId: string): Promise<ConversationTurnRecord>;
|
|
591
|
+
settleConversationTurn(id: string, leaseToken: string, status: "blocked" | "completed" | "failed" | "cancelled", options?: {
|
|
592
|
+
runId?: string;
|
|
593
|
+
error?: string;
|
|
594
|
+
}): Promise<ConversationTurnRecord>;
|
|
595
|
+
settleConversationTurnByRunId(runId: string, status: "blocked" | "completed" | "failed" | "cancelled", options?: {
|
|
596
|
+
error?: string;
|
|
597
|
+
}): Promise<ConversationTurnRecord | undefined>;
|
|
598
|
+
retryConversationTurn(id: string, leaseToken: string, error: string): Promise<ConversationTurnRecord>;
|
|
599
|
+
recoverExpiredConversationTurns(now?: Date): Promise<ConversationTurnRecord[]>;
|
|
600
|
+
listConversationTurns(options?: {
|
|
601
|
+
agentScope?: string;
|
|
602
|
+
conversationId?: string;
|
|
603
|
+
status?: ConversationTurnStatus;
|
|
604
|
+
}): Promise<ConversationTurnRecord[]>;
|
|
605
|
+
}
|
|
606
|
+
/** Optional facet: schedule registrations and dedupe of schedule runs. */
|
|
607
|
+
export interface ScheduleStateStore {
|
|
608
|
+
registerSchedule(input: {
|
|
609
|
+
id: string;
|
|
610
|
+
name: string;
|
|
611
|
+
cron: string;
|
|
612
|
+
timezone?: string;
|
|
613
|
+
metadata?: JsonObject;
|
|
614
|
+
}): Promise<ScheduleRecord>;
|
|
615
|
+
recordScheduleRun(input: {
|
|
616
|
+
scheduleId: string;
|
|
617
|
+
runId?: string;
|
|
618
|
+
runAt: string;
|
|
619
|
+
idempotencyKey: string;
|
|
620
|
+
status?: string;
|
|
621
|
+
}): Promise<ScheduleRunRecord>;
|
|
622
|
+
}
|
|
623
|
+
/** Optional facet: index of memory/artifact/file blobs written by runs. */
|
|
624
|
+
export interface FileIndexStore {
|
|
625
|
+
recordFileIndex(input: {
|
|
626
|
+
runId?: string;
|
|
627
|
+
path: string;
|
|
628
|
+
kind: FileIndexRecord["kind"];
|
|
629
|
+
blobKey: string;
|
|
630
|
+
sha256: string;
|
|
631
|
+
sizeBytes: number;
|
|
632
|
+
metadata?: JsonObject;
|
|
633
|
+
}): Promise<FileIndexRecord>;
|
|
634
|
+
listFileIndexes?(runId?: string): Promise<FileIndexRecord[]>;
|
|
635
|
+
}
|
|
636
|
+
/** Optional facet: source-backed model usage observability. */
|
|
637
|
+
export interface UsageStore {
|
|
638
|
+
recordUsage(input: UsageRecordInput): Promise<UsageRecord>;
|
|
639
|
+
listUsage(runId?: string): Promise<UsageRecord[]>;
|
|
640
|
+
queryUsage?(query: UsageQuery): Promise<UsageRecord[]>;
|
|
641
|
+
summarizeUsage?(query: UsageSummaryQuery): Promise<UsageAggregate[]>;
|
|
642
|
+
}
|
|
643
|
+
/** Optional facet: sandbox sessions, snapshots, and the sandbox-sync queue. */
|
|
644
|
+
export interface SandboxSessionStore {
|
|
645
|
+
recordSandboxSnapshot(input: {
|
|
646
|
+
runId: string;
|
|
647
|
+
sandboxId: string;
|
|
648
|
+
snapshotId: string;
|
|
649
|
+
metadata?: JsonObject;
|
|
650
|
+
}): Promise<SandboxSnapshotRecord>;
|
|
651
|
+
upsertSandboxSession(input: SandboxSessionInput): Promise<SandboxSessionRecord>;
|
|
652
|
+
getSandboxSession(sessionKey: string): Promise<SandboxSessionRecord | undefined>;
|
|
653
|
+
listSandboxSessions?(options?: {
|
|
654
|
+
dirty?: boolean;
|
|
655
|
+
}): Promise<SandboxSessionRecord[]>;
|
|
656
|
+
updateSandboxSession(sessionKey: string, patch: SandboxSessionPatch): Promise<SandboxSessionRecord>;
|
|
657
|
+
createSandboxSyncJob(input: SandboxSyncJobInput): Promise<SandboxSyncJobRecord>;
|
|
658
|
+
updateSandboxSyncJob(id: string, patch: SandboxSyncJobPatch): Promise<SandboxSyncJobRecord>;
|
|
659
|
+
listSandboxSyncJobs(runId?: string): Promise<SandboxSyncJobRecord[]>;
|
|
660
|
+
enqueueSandboxSyncJob(input: SandboxSyncJobInput): Promise<SandboxSyncJobRecord>;
|
|
661
|
+
leaseSandboxSyncJobs(options?: SandboxSyncLeaseOptions): Promise<SandboxSyncJobRecord[]>;
|
|
662
|
+
completeSandboxSyncJob(id: string, leaseToken: string, patch?: {
|
|
663
|
+
manifest?: JsonObject;
|
|
664
|
+
metadata?: JsonObject;
|
|
665
|
+
}): Promise<SandboxSyncJobRecord>;
|
|
666
|
+
failSandboxSyncJob(id: string, leaseToken: string, failure: SandboxSyncFailureInput): Promise<SandboxSyncJobRecord>;
|
|
667
|
+
recoverExpiredSandboxSyncJobs(now?: Date): Promise<SandboxSyncJobRecord[]>;
|
|
668
|
+
}
|
|
669
|
+
/** Optional facet: durable memory documents and embeddings. */
|
|
670
|
+
export interface MemoryStateStore {
|
|
671
|
+
/**
|
|
672
|
+
* Reports whether the durable store can persist and query vector
|
|
673
|
+
* embeddings. Omitted means supported for compatibility with existing
|
|
674
|
+
* adapters; stores with an optional vector backend must return false until
|
|
675
|
+
* that backend is configured.
|
|
676
|
+
*/
|
|
677
|
+
supportsMemoryEmbeddings?(): boolean;
|
|
678
|
+
listMemoryDocuments(scope: MemoryScope, input?: MemoryListInput): Promise<MemoryDocument[]>;
|
|
679
|
+
searchMemoryDocuments?(scope: MemoryScope, input: MemorySearchInput): Promise<MemorySearchResult[]>;
|
|
680
|
+
getMemoryDocument(scope: MemoryScope, path: string): Promise<MemoryDocument | undefined>;
|
|
681
|
+
upsertMemoryDocument(document: MemoryDocument): Promise<MemoryDocument>;
|
|
682
|
+
deleteMemoryDocument(scope: MemoryScope, path: string): Promise<void>;
|
|
683
|
+
listMemoryDocumentsNeedingEmbeddings(scope: MemoryScope, options: {
|
|
684
|
+
model: string;
|
|
685
|
+
limit?: number;
|
|
686
|
+
}): Promise<MemoryDocument[]>;
|
|
687
|
+
upsertMemoryEmbedding(input: Omit<MemoryEmbeddingRecord, "id" | "createdAt" | "updatedAt">): Promise<MemoryEmbeddingRecord>;
|
|
688
|
+
searchMemoryEmbeddings(scope: MemoryScope, input: MemorySearchInput, embedding: number[], options: {
|
|
689
|
+
model: string;
|
|
690
|
+
limit?: number;
|
|
691
|
+
}): Promise<MemorySearchResult[]>;
|
|
692
|
+
markMemoryEmbeddingsStale(scope: MemoryScope, path: string, currentSha256: string): Promise<void>;
|
|
693
|
+
}
|
|
694
|
+
/** Optional durable runtime settings and non-run control-plane audit log. */
|
|
695
|
+
export interface RuntimeSettingsStore {
|
|
696
|
+
getSetting(scope: string, key: string): Promise<RuntimeSettingRecord | undefined>;
|
|
697
|
+
setSetting(scope: string, key: string, value: RuntimeSettingRecord["value"]): Promise<RuntimeSettingRecord>;
|
|
698
|
+
appendRuntimeControlEvent(scope: string, type: string, data?: JsonObject): Promise<RuntimeControlEvent>;
|
|
699
|
+
listRuntimeControlEvents(scope: string): Promise<RuntimeControlEvent[]>;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* The historical monolithic state contract. Runtime settings remain outside
|
|
703
|
+
* this public intersection so existing third-party adapters keep compiling;
|
|
704
|
+
* the runtime adds an in-memory settings fallback during normalization.
|
|
705
|
+
*/
|
|
706
|
+
export type StateAdapter = RunStore & ConversationStore & ScheduleStateStore & FileIndexStore & UsageStore & SandboxSessionStore & MemoryStateStore;
|
|
707
|
+
/** Internal normalized state contract after optional facets are filled. */
|
|
708
|
+
export type ResolvedStateAdapter = StateAdapter & RuntimeSettingsStore & ConversationTurnStore;
|
|
709
|
+
/**
|
|
710
|
+
* Facet-shaped state configuration for `RuntimeOptions.state`. Only `runs`
|
|
711
|
+
* is required; missing optional facets fall back to non-durable in-memory
|
|
712
|
+
* implementations (the runtime logs one `state.degraded` warning at boot).
|
|
713
|
+
*/
|
|
714
|
+
export interface StateStores {
|
|
715
|
+
runs: RunStore;
|
|
716
|
+
conversations?: ConversationStore;
|
|
717
|
+
conversationTurns?: ConversationTurnStore;
|
|
718
|
+
schedules?: ScheduleStateStore;
|
|
719
|
+
files?: FileIndexStore;
|
|
720
|
+
usage?: UsageStore;
|
|
721
|
+
sandboxSessions?: SandboxSessionStore;
|
|
722
|
+
memory?: MemoryStateStore;
|
|
723
|
+
settings?: RuntimeSettingsStore;
|
|
724
|
+
}
|
|
725
|
+
export declare function isRunStore(value: unknown): value is RunStore;
|
|
726
|
+
export declare function isConversationStore(value: unknown): value is ConversationStore;
|
|
727
|
+
export declare function isScheduleStateStore(value: unknown): value is ScheduleStateStore;
|
|
728
|
+
export declare function isFileIndexStore(value: unknown): value is FileIndexStore;
|
|
729
|
+
export declare function isUsageStore(value: unknown): value is UsageStore;
|
|
730
|
+
export declare function isSandboxSessionStore(value: unknown): value is SandboxSessionStore;
|
|
731
|
+
export declare function isMemoryStateStore(value: unknown): value is MemoryStateStore;
|
|
732
|
+
export declare function isRuntimeSettingsStore(value: unknown): value is RuntimeSettingsStore;
|
|
733
|
+
export declare function isConversationTurnStore(value: unknown): value is ConversationTurnStore;
|
|
734
|
+
/** Detects a monolithic StateAdapter (vs a facet-shaped `StateStores`). */
|
|
735
|
+
export declare function isStateAdapter(value: unknown): value is StateAdapter;
|
|
736
|
+
//# sourceMappingURL=state.d.ts.map
|