@botbotgo/agent-harness 0.0.75 → 0.0.76
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/dist/api.d.ts +2 -1
- package/dist/api.js +3 -0
- package/dist/benchmark/checkpoint-resume-cost-benchmark.d.ts +33 -0
- package/dist/benchmark/checkpoint-resume-cost-benchmark.js +55 -0
- package/dist/benchmark/deepagent-local-model-benchmark.d.ts +27 -0
- package/dist/benchmark/deepagent-local-model-benchmark.js +35 -0
- package/dist/config/agents/direct.yaml +1 -1
- package/dist/config/agents/orchestra.yaml +1 -2
- package/dist/config/workspace.yaml +31 -0
- package/dist/contracts/types.d.ts +38 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/package-version.d.ts +1 -1
- package/dist/package-version.js +1 -1
- package/dist/persistence/file-store.d.ts +3 -40
- package/dist/persistence/file-store.js +5 -2
- package/dist/persistence/sqlite-store.d.ts +68 -0
- package/dist/persistence/sqlite-store.js +569 -0
- package/dist/persistence/types.d.ts +83 -0
- package/dist/persistence/types.js +1 -0
- package/dist/runtime/agent-runtime-adapter.d.ts +3 -0
- package/dist/runtime/agent-runtime-adapter.js +58 -2
- package/dist/runtime/checkpoint-maintenance.d.ts +11 -2
- package/dist/runtime/checkpoint-maintenance.js +41 -5
- package/dist/runtime/harness.d.ts +5 -1
- package/dist/runtime/harness.js +45 -3
- package/dist/runtime/health-monitor.d.ts +81 -0
- package/dist/runtime/health-monitor.js +448 -0
- package/dist/runtime/runtime-record-maintenance.d.ts +43 -0
- package/dist/runtime/runtime-record-maintenance.js +169 -0
- package/dist/runtime/store.d.ts +2 -0
- package/dist/runtime/store.js +38 -20
- package/dist/runtime/support/embedding-models.js +57 -1
- package/dist/runtime/thread-memory-sync.d.ts +3 -2
- package/dist/runtime/thread-memory-sync.js +7 -1
- package/dist/workspace/agent-binding-compiler.js +3 -1
- package/dist/workspace/support/workspace-ref-utils.d.ts +9 -0
- package/dist/workspace/support/workspace-ref-utils.js +38 -0
- package/package.json +2 -2
package/dist/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApprovalRecord, RunRecord, RunOptions, RunSummary, ResumeOptions, RuntimeAdapterOptions, ThreadSummary, ThreadRecord, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
1
|
+
import type { ApprovalRecord, RunRecord, RunOptions, RunSummary, ResumeOptions, RuntimeHealthSnapshot, RuntimeAdapterOptions, ThreadSummary, ThreadRecord, WorkspaceLoadOptions } from "./contracts/types.js";
|
|
2
2
|
import { AgentHarnessRuntime } from "./runtime/harness.js";
|
|
3
3
|
import type { InventoryAgentRecord, InventorySkillRecord } from "./runtime/inventory.js";
|
|
4
4
|
import type { RequirementAssessmentOptions } from "./runtime/skill-requirements.js";
|
|
@@ -23,6 +23,7 @@ export declare function getRun(runtime: AgentHarnessRuntime, runId: string): Pro
|
|
|
23
23
|
export declare function deleteThread(runtime: AgentHarnessRuntime, threadId: string): Promise<boolean>;
|
|
24
24
|
export declare function listApprovals(runtime: AgentHarnessRuntime, filter?: Parameters<AgentHarnessRuntime["listApprovals"]>[0]): Promise<ApprovalRecord[]>;
|
|
25
25
|
export declare function getApproval(runtime: AgentHarnessRuntime, approvalId: string): Promise<ApprovalRecord | null>;
|
|
26
|
+
export declare function getHealth(runtime: AgentHarnessRuntime): Promise<RuntimeHealthSnapshot>;
|
|
26
27
|
export declare function listAgentSkills(runtime: AgentHarnessRuntime, agentId: string, options?: RequirementAssessmentOptions): InventorySkillRecord[];
|
|
27
28
|
export declare function describeInventory(runtime: AgentHarnessRuntime, options?: RequirementAssessmentOptions): {
|
|
28
29
|
workspaceRoot: string;
|
package/dist/api.js
CHANGED
|
@@ -34,6 +34,9 @@ export async function listApprovals(runtime, filter) {
|
|
|
34
34
|
export async function getApproval(runtime, approvalId) {
|
|
35
35
|
return runtime.getApproval(approvalId);
|
|
36
36
|
}
|
|
37
|
+
export async function getHealth(runtime) {
|
|
38
|
+
return runtime.getHealth();
|
|
39
|
+
}
|
|
37
40
|
export function listAgentSkills(runtime, agentId, options) {
|
|
38
41
|
return runtime.listAgentSkills(agentId, options);
|
|
39
42
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type CheckpointerMode = "memory" | "sqlite";
|
|
2
|
+
export type ResumeCostRunSummary = {
|
|
3
|
+
model: string;
|
|
4
|
+
checkpointerKind: CheckpointerMode;
|
|
5
|
+
runNumber: number;
|
|
6
|
+
status: "completed" | "failed";
|
|
7
|
+
initialApprovalMs: number;
|
|
8
|
+
sameProcessResumeMs: number;
|
|
9
|
+
crossRestartResumeMs: number | null;
|
|
10
|
+
totalMeasuredMs: number;
|
|
11
|
+
approvalPassCount: number;
|
|
12
|
+
crossRestartSupported: boolean;
|
|
13
|
+
errorMessage?: string;
|
|
14
|
+
};
|
|
15
|
+
export type ResumeCostAggregateSummary = {
|
|
16
|
+
model: string;
|
|
17
|
+
checkpointerKind: CheckpointerMode;
|
|
18
|
+
repetitions: number;
|
|
19
|
+
successCount: number;
|
|
20
|
+
failureCount: number;
|
|
21
|
+
avgInitialApprovalMs: number | null;
|
|
22
|
+
avgSameProcessResumeMs: number | null;
|
|
23
|
+
avgCrossRestartResumeMs: number | null;
|
|
24
|
+
avgTotalMeasuredMs: number | null;
|
|
25
|
+
avgApprovalPassCount: number | null;
|
|
26
|
+
crossRestartSuccessCount: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS: readonly CheckpointerMode[];
|
|
29
|
+
export declare const DEFAULT_RESUME_COST_INFRA_RETRIES = 2;
|
|
30
|
+
export declare function resolveCheckpointResumeCheckpointers(rawValue?: string): readonly CheckpointerMode[];
|
|
31
|
+
export declare function resolveResumeCostInfraRetries(rawValue?: string): number;
|
|
32
|
+
export declare function isRetryableResumeCostError(message?: string): boolean;
|
|
33
|
+
export declare function aggregateCheckpointResumeRuns(model: string, checkpointerKind: CheckpointerMode, runs: ResumeCostRunSummary[]): ResumeCostAggregateSummary;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export const DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS = Object.freeze(["memory", "sqlite"]);
|
|
2
|
+
export const DEFAULT_RESUME_COST_INFRA_RETRIES = 2;
|
|
3
|
+
function average(values) {
|
|
4
|
+
return Number((values.reduce((sum, value) => sum + value, 0) / values.length).toFixed(2));
|
|
5
|
+
}
|
|
6
|
+
function averageOrNull(values) {
|
|
7
|
+
return values.length > 0 ? average(values) : null;
|
|
8
|
+
}
|
|
9
|
+
export function resolveCheckpointResumeCheckpointers(rawValue) {
|
|
10
|
+
if (!rawValue) {
|
|
11
|
+
return [...DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS];
|
|
12
|
+
}
|
|
13
|
+
const parsed = rawValue
|
|
14
|
+
.split(",")
|
|
15
|
+
.map((value) => value.trim().toLowerCase())
|
|
16
|
+
.filter((value) => value === "memory" || value === "sqlite");
|
|
17
|
+
return parsed.length > 0 ? parsed : [...DEFAULT_CHECKPOINT_RESUME_CHECKPOINTERS];
|
|
18
|
+
}
|
|
19
|
+
export function resolveResumeCostInfraRetries(rawValue) {
|
|
20
|
+
if (!rawValue) {
|
|
21
|
+
return DEFAULT_RESUME_COST_INFRA_RETRIES;
|
|
22
|
+
}
|
|
23
|
+
const parsed = Number(rawValue);
|
|
24
|
+
return Number.isInteger(parsed) && parsed >= 0 ? parsed : DEFAULT_RESUME_COST_INFRA_RETRIES;
|
|
25
|
+
}
|
|
26
|
+
export function isRetryableResumeCostError(message) {
|
|
27
|
+
if (!message) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const normalized = message.toLowerCase();
|
|
31
|
+
return (normalized.includes("connection error") ||
|
|
32
|
+
normalized.includes("network error") ||
|
|
33
|
+
normalized.includes("fetch failed") ||
|
|
34
|
+
normalized.includes("socket hang up") ||
|
|
35
|
+
normalized.includes("econnreset") ||
|
|
36
|
+
normalized.includes("timed out"));
|
|
37
|
+
}
|
|
38
|
+
export function aggregateCheckpointResumeRuns(model, checkpointerKind, runs) {
|
|
39
|
+
const successfulRuns = runs.filter((run) => run.status === "completed");
|
|
40
|
+
return {
|
|
41
|
+
model,
|
|
42
|
+
checkpointerKind,
|
|
43
|
+
repetitions: runs.length,
|
|
44
|
+
successCount: successfulRuns.length,
|
|
45
|
+
failureCount: runs.length - successfulRuns.length,
|
|
46
|
+
avgInitialApprovalMs: averageOrNull(successfulRuns.map((run) => run.initialApprovalMs)),
|
|
47
|
+
avgSameProcessResumeMs: averageOrNull(successfulRuns.map((run) => run.sameProcessResumeMs)),
|
|
48
|
+
avgCrossRestartResumeMs: averageOrNull(successfulRuns
|
|
49
|
+
.map((run) => run.crossRestartResumeMs)
|
|
50
|
+
.filter((value) => value !== null)),
|
|
51
|
+
avgTotalMeasuredMs: averageOrNull(successfulRuns.map((run) => run.totalMeasuredMs)),
|
|
52
|
+
avgApprovalPassCount: averageOrNull(successfulRuns.map((run) => run.approvalPassCount)),
|
|
53
|
+
crossRestartSuccessCount: successfulRuns.filter((run) => run.crossRestartSupported).length,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const DEFAULT_SERIAL_BENCHMARK_MODELS: readonly string[];
|
|
2
|
+
export type WarmupRequestPayload = {
|
|
3
|
+
model: string;
|
|
4
|
+
temperature: number;
|
|
5
|
+
max_tokens: number;
|
|
6
|
+
messages: Array<{
|
|
7
|
+
role: "user";
|
|
8
|
+
content: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
export type WarmupResponsePayload = {
|
|
12
|
+
choices?: Array<{
|
|
13
|
+
message?: {
|
|
14
|
+
content?: string;
|
|
15
|
+
reasoning?: string;
|
|
16
|
+
};
|
|
17
|
+
}>;
|
|
18
|
+
usage?: {
|
|
19
|
+
completion_tokens?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare function resolveSerialBenchmarkModels(rawValue?: string): readonly string[];
|
|
23
|
+
export declare function buildWarmupRequestPayload(model: string, token: string): WarmupRequestPayload;
|
|
24
|
+
export declare function extractWarmupOutput(payload: WarmupResponsePayload): {
|
|
25
|
+
output: string;
|
|
26
|
+
completionTokens: number;
|
|
27
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const DEFAULT_SERIAL_BENCHMARK_MODELS = Object.freeze([
|
|
2
|
+
"qwen3.5:0.8b",
|
|
3
|
+
"qwen3.5:2b",
|
|
4
|
+
"qwen3.5:4b",
|
|
5
|
+
"qwen3.5:9b",
|
|
6
|
+
"gpt-oss",
|
|
7
|
+
]);
|
|
8
|
+
export function resolveSerialBenchmarkModels(rawValue) {
|
|
9
|
+
if (!rawValue) {
|
|
10
|
+
return [...DEFAULT_SERIAL_BENCHMARK_MODELS];
|
|
11
|
+
}
|
|
12
|
+
const parsed = rawValue.split(",").map((value) => value.trim()).filter(Boolean);
|
|
13
|
+
return parsed.length > 0 ? parsed : [...DEFAULT_SERIAL_BENCHMARK_MODELS];
|
|
14
|
+
}
|
|
15
|
+
export function buildWarmupRequestPayload(model, token) {
|
|
16
|
+
return {
|
|
17
|
+
model,
|
|
18
|
+
temperature: 0,
|
|
19
|
+
max_tokens: 32,
|
|
20
|
+
messages: [
|
|
21
|
+
{
|
|
22
|
+
role: "user",
|
|
23
|
+
content: `Reply with exactly: WARMUP_OK ${token}`,
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export function extractWarmupOutput(payload) {
|
|
29
|
+
const content = payload.choices?.[0]?.message?.content ?? "";
|
|
30
|
+
const reasoning = payload.choices?.[0]?.message?.reasoning ?? "";
|
|
31
|
+
return {
|
|
32
|
+
output: `${content}\n${reasoning}`.trim(),
|
|
33
|
+
completionTokens: payload.usage?.completion_tokens ?? 0,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -39,7 +39,7 @@ spec:
|
|
|
39
39
|
# Available `kind` options in this harness: `FileCheckpointer`, `MemorySaver`, `SqliteSaver`.
|
|
40
40
|
# `path` is only used by `FileCheckpointer` and `SqliteSaver`; omit it for `MemorySaver`.
|
|
41
41
|
checkpointer:
|
|
42
|
-
ref: checkpointer/
|
|
42
|
+
ref: checkpointer/sqlite
|
|
43
43
|
# Upstream execution feature: LangGraph store available to middleware and runtime context hooks.
|
|
44
44
|
# The default direct host keeps this enabled so middleware can use the same durable store surface as other hosts.
|
|
45
45
|
store:
|
|
@@ -46,8 +46,7 @@ spec:
|
|
|
46
46
|
# Available `kind` options in this harness: `FileCheckpointer`, `MemorySaver`, `SqliteSaver`.
|
|
47
47
|
# `path` is only used by `FileCheckpointer` and `SqliteSaver`; omit it for `MemorySaver`.
|
|
48
48
|
checkpointer:
|
|
49
|
-
|
|
50
|
-
ref: checkpointer/default
|
|
49
|
+
ref: checkpointer/sqlite
|
|
51
50
|
# Upstream execution feature: store config passed into the selected backend adapter.
|
|
52
51
|
# In the default deepagent adapter this is the LangGraph store used by `StoreBackend` routes.
|
|
53
52
|
# Built-in kinds in this harness today: `FileStore`, `InMemoryStore`.
|
|
@@ -92,6 +92,7 @@ spec:
|
|
|
92
92
|
#
|
|
93
93
|
# Current support:
|
|
94
94
|
# - checkpoint cleanup for `SqliteSaver` checkpointers only
|
|
95
|
+
# - terminal runtime-record cleanup for structured thread/run metadata in `runtime.sqlite`
|
|
95
96
|
# - oldest-first deletion by time policy and/or size policy
|
|
96
97
|
# - background scheduling inside the harness lifecycle
|
|
97
98
|
#
|
|
@@ -106,6 +107,16 @@ spec:
|
|
|
106
107
|
sqlite:
|
|
107
108
|
sweepBatchSize: 200
|
|
108
109
|
vacuum: false
|
|
110
|
+
records:
|
|
111
|
+
enabled: false
|
|
112
|
+
schedule:
|
|
113
|
+
intervalSeconds: 3600
|
|
114
|
+
runOnStartup: true
|
|
115
|
+
policies:
|
|
116
|
+
maxAgeSeconds: 2592000
|
|
117
|
+
sqlite:
|
|
118
|
+
sweepBatchSize: 100
|
|
119
|
+
vacuum: false
|
|
109
120
|
|
|
110
121
|
# agent-harness feature: runtime-managed recovery policy for interrupted runs.
|
|
111
122
|
# This keeps checkpoint resume as an internal lifecycle concern instead of a primary user-facing API concept.
|
|
@@ -119,3 +130,23 @@ spec:
|
|
|
119
130
|
enabled: true
|
|
120
131
|
resumeResumingRunsOnStartup: true
|
|
121
132
|
maxRecoveryAttempts: 3
|
|
133
|
+
|
|
134
|
+
# agent-harness feature: runtime-managed resilience policy for transient provider failures.
|
|
135
|
+
# This applies to provider/model invocation boundaries, not to benchmark-only loops.
|
|
136
|
+
#
|
|
137
|
+
# Current support:
|
|
138
|
+
# - bounded retries for transient provider invocation failures
|
|
139
|
+
# - simple fixed backoff between attempts
|
|
140
|
+
# - message-pattern classification for retryable infrastructure errors
|
|
141
|
+
#
|
|
142
|
+
resilience:
|
|
143
|
+
providerRetries:
|
|
144
|
+
maxAttempts: 2
|
|
145
|
+
backoffMs: 1000
|
|
146
|
+
retryableMessages:
|
|
147
|
+
- connection error
|
|
148
|
+
- network error
|
|
149
|
+
- fetch failed
|
|
150
|
+
- socket hang up
|
|
151
|
+
- econnreset
|
|
152
|
+
- timed out
|
|
@@ -202,6 +202,7 @@ export type CompiledAgentBinding = {
|
|
|
202
202
|
workspaceRoot?: string;
|
|
203
203
|
hostFacing: boolean;
|
|
204
204
|
capabilities?: RuntimeCapabilities;
|
|
205
|
+
resilience?: Record<string, unknown>;
|
|
205
206
|
checkpointer?: Record<string, unknown> | boolean;
|
|
206
207
|
store?: Record<string, unknown>;
|
|
207
208
|
runtimeMemory?: Record<string, unknown>;
|
|
@@ -238,7 +239,7 @@ export type ThreadSummary = {
|
|
|
238
239
|
status: RunState;
|
|
239
240
|
};
|
|
240
241
|
export type SessionRecord = ThreadSummary;
|
|
241
|
-
export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "reasoning.delta" | "runtime.synthetic_fallback";
|
|
242
|
+
export type KnownHarnessEventType = "run.created" | "run.queued" | "run.dequeued" | "run.state.changed" | "run.resumed" | "approval.requested" | "approval.resolved" | "artifact.created" | "output.delta" | "reasoning.delta" | "runtime.health.changed" | "runtime.synthetic_fallback";
|
|
242
243
|
export type HarnessEventType = KnownHarnessEventType | (string & {});
|
|
243
244
|
export type HarnessEvent = {
|
|
244
245
|
eventId: string;
|
|
@@ -261,6 +262,42 @@ export type RuntimeEventSink = {
|
|
|
261
262
|
subscribe: (listener: HarnessEventListener) => () => void;
|
|
262
263
|
registerProjection: (projection: HarnessEventProjection) => () => void;
|
|
263
264
|
};
|
|
265
|
+
export type HealthStatus = "healthy" | "degraded" | "unhealthy";
|
|
266
|
+
export type RuntimeHealthCheck = {
|
|
267
|
+
status: HealthStatus;
|
|
268
|
+
updatedAt: string;
|
|
269
|
+
reason?: string;
|
|
270
|
+
};
|
|
271
|
+
export type RuntimeHealthSymptom = {
|
|
272
|
+
code: string;
|
|
273
|
+
severity: "info" | "warn" | "error";
|
|
274
|
+
message: string;
|
|
275
|
+
firstSeenAt: string;
|
|
276
|
+
lastSeenAt: string;
|
|
277
|
+
};
|
|
278
|
+
export type RuntimeHealthSnapshot = {
|
|
279
|
+
status: HealthStatus;
|
|
280
|
+
updatedAt: string;
|
|
281
|
+
checks: {
|
|
282
|
+
runtime: RuntimeHealthCheck;
|
|
283
|
+
llm: RuntimeHealthCheck;
|
|
284
|
+
persistence: RuntimeHealthCheck;
|
|
285
|
+
capacity: RuntimeHealthCheck;
|
|
286
|
+
workload: RuntimeHealthCheck;
|
|
287
|
+
};
|
|
288
|
+
symptoms: RuntimeHealthSymptom[];
|
|
289
|
+
stats: {
|
|
290
|
+
activeRunSlots: number;
|
|
291
|
+
pendingRunSlots: number;
|
|
292
|
+
pendingApprovals: number;
|
|
293
|
+
stuckRuns: number;
|
|
294
|
+
checkpointBytes?: number;
|
|
295
|
+
runtimeDbBytes?: number;
|
|
296
|
+
artifactBytes?: number;
|
|
297
|
+
llmSuccessRate1m?: number;
|
|
298
|
+
llmP95LatencyMs1m?: number;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
264
301
|
export type RunResult = {
|
|
265
302
|
threadId: string;
|
|
266
303
|
runId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getHealth, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
2
2
|
export type { ToolMcpServerOptions } from "./mcp.js";
|
|
3
3
|
export { tool } from "./tools.js";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { AgentHarnessRuntime, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
1
|
+
export { AgentHarnessRuntime, createAgentHarness, createToolMcpServer, deleteThread, describeInventory, getApproval, getHealth, getRun, getThread, listAgentSkills, listApprovals, listRuns, listThreads, resolveApproval, run, serveToolsOverStdio, subscribe, stop, } from "./api.js";
|
|
2
2
|
export { tool } from "./tools.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export declare const AGENT_HARNESS_VERSION = "0.0.75";
|
package/dist/package-version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const AGENT_HARNESS_VERSION = "0.0.
|
|
1
|
+
export const AGENT_HARNESS_VERSION = "0.0.75";
|
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
import type { ArtifactListing, ArtifactRecord, DelegationRecord, HarnessEvent, InternalApprovalRecord,
|
|
2
|
-
type ThreadMeta
|
|
3
|
-
threadId: string;
|
|
4
|
-
workspaceId: string;
|
|
5
|
-
entryAgentId: string;
|
|
6
|
-
createdAt: string;
|
|
7
|
-
updatedAt: string;
|
|
8
|
-
status: RunState;
|
|
9
|
-
latestRunId: string;
|
|
10
|
-
};
|
|
11
|
-
type RunMeta = {
|
|
12
|
-
runId: string;
|
|
13
|
-
threadId: string;
|
|
14
|
-
agentId: string;
|
|
15
|
-
executionMode: string;
|
|
16
|
-
adapterKind?: string;
|
|
17
|
-
createdAt: string;
|
|
18
|
-
updatedAt: string;
|
|
19
|
-
};
|
|
20
|
-
type Lifecycle = {
|
|
21
|
-
state: RunState;
|
|
22
|
-
previousState: RunState | null;
|
|
23
|
-
stateEnteredAt: string;
|
|
24
|
-
lastTransitionAt: string;
|
|
25
|
-
resumable: boolean;
|
|
26
|
-
checkpointRef: string | null;
|
|
27
|
-
};
|
|
1
|
+
import type { ArtifactListing, ArtifactRecord, DelegationRecord, HarnessEvent, InternalApprovalRecord, RunSummary, RunState, ThreadSummary, ThreadRunRecord, TranscriptMessage } from "../contracts/types.js";
|
|
2
|
+
import type { PersistedRunRequest, PersistenceLifecycle as Lifecycle, RuntimePersistence, RecoveryIntent, PersistenceRunMeta as RunMeta, PersistenceThreadMeta as ThreadMeta } from "./types.js";
|
|
28
3
|
type RunIndexRecord = {
|
|
29
4
|
runId: string;
|
|
30
5
|
threadId: string;
|
|
@@ -32,19 +7,7 @@ type RunIndexRecord = {
|
|
|
32
7
|
resumable: boolean;
|
|
33
8
|
updatedAt: string;
|
|
34
9
|
};
|
|
35
|
-
|
|
36
|
-
kind: "approval-decision";
|
|
37
|
-
savedAt: string;
|
|
38
|
-
checkpointRef: string | null;
|
|
39
|
-
resumePayload: unknown;
|
|
40
|
-
attempts: number;
|
|
41
|
-
};
|
|
42
|
-
type PersistedRunRequest = {
|
|
43
|
-
input: MessageContent;
|
|
44
|
-
invocation?: InvocationEnvelope;
|
|
45
|
-
savedAt: string;
|
|
46
|
-
};
|
|
47
|
-
export declare class FilePersistence {
|
|
10
|
+
export declare class FilePersistence implements RuntimePersistence {
|
|
48
11
|
private readonly runRoot;
|
|
49
12
|
constructor(runRoot: string);
|
|
50
13
|
private threadIndexPath;
|
|
@@ -2,6 +2,9 @@ import path from "node:path";
|
|
|
2
2
|
import { rm } from "node:fs/promises";
|
|
3
3
|
import { readdir } from "node:fs/promises";
|
|
4
4
|
import { ensureDir, fileExists, readJson, writeJson } from "../utils/fs.js";
|
|
5
|
+
function nowIso() {
|
|
6
|
+
return new Date(Date.now()).toISOString();
|
|
7
|
+
}
|
|
5
8
|
export class FilePersistence {
|
|
6
9
|
runRoot;
|
|
7
10
|
constructor(runRoot) {
|
|
@@ -113,7 +116,7 @@ export class FilePersistence {
|
|
|
113
116
|
readJson(lifecyclePath),
|
|
114
117
|
readJson(runMetaPath),
|
|
115
118
|
]);
|
|
116
|
-
const now =
|
|
119
|
+
const now = nowIso();
|
|
117
120
|
const next = {
|
|
118
121
|
state,
|
|
119
122
|
previousState: lifecycle.state,
|
|
@@ -355,7 +358,7 @@ export class FilePersistence {
|
|
|
355
358
|
const updated = {
|
|
356
359
|
...current,
|
|
357
360
|
status,
|
|
358
|
-
resolvedAt:
|
|
361
|
+
resolvedAt: nowIso(),
|
|
359
362
|
};
|
|
360
363
|
await Promise.all([
|
|
361
364
|
writeJson(approvalPath, updated),
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { ArtifactListing, ArtifactRecord, HarnessEvent, InternalApprovalRecord, RunState, RunSummary, ThreadRunRecord, ThreadSummary, TranscriptMessage } from "../contracts/types.js";
|
|
2
|
+
import type { PersistedRunRequest, PersistenceLifecycle, PersistenceRunMeta, PersistenceThreadMeta, RecoveryIntent, RuntimePersistence } from "./types.js";
|
|
3
|
+
export declare function listProtectedCheckpointThreadIds(dbPath: string): Promise<Set<string>>;
|
|
4
|
+
export declare class SqlitePersistence implements RuntimePersistence {
|
|
5
|
+
private readonly runRoot;
|
|
6
|
+
private readonly dbPath;
|
|
7
|
+
private client;
|
|
8
|
+
private initialized;
|
|
9
|
+
private initialization;
|
|
10
|
+
constructor(runRoot: string, dbFile?: string);
|
|
11
|
+
private getClient;
|
|
12
|
+
private rawExecute;
|
|
13
|
+
private rawSelectAll;
|
|
14
|
+
private ensureInitialized;
|
|
15
|
+
private threadDir;
|
|
16
|
+
private runDir;
|
|
17
|
+
private execute;
|
|
18
|
+
private selectOne;
|
|
19
|
+
private selectAll;
|
|
20
|
+
private mapThreadSummary;
|
|
21
|
+
private mapRunSummary;
|
|
22
|
+
private mapApproval;
|
|
23
|
+
initialize(): Promise<void>;
|
|
24
|
+
private ensureSchemaMetadata;
|
|
25
|
+
createThread(input: {
|
|
26
|
+
threadId: string;
|
|
27
|
+
agentId: string;
|
|
28
|
+
runId: string;
|
|
29
|
+
status: RunState;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
createRun(input: {
|
|
33
|
+
threadId: string;
|
|
34
|
+
runId: string;
|
|
35
|
+
agentId: string;
|
|
36
|
+
executionMode: string;
|
|
37
|
+
adapterKind?: string;
|
|
38
|
+
createdAt: string;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
setRunState(threadId: string, runId: string, state: RunState, checkpointRef?: string | null): Promise<void>;
|
|
41
|
+
appendEvent(event: HarnessEvent): Promise<void>;
|
|
42
|
+
listSessions(): Promise<ThreadSummary[]>;
|
|
43
|
+
listRuns(): Promise<RunSummary[]>;
|
|
44
|
+
getRun(runId: string): Promise<RunSummary | null>;
|
|
45
|
+
getSession(threadId: string): Promise<ThreadSummary | null>;
|
|
46
|
+
getThreadMeta(threadId: string): Promise<PersistenceThreadMeta | null>;
|
|
47
|
+
listThreadRuns(threadId: string): Promise<ThreadRunRecord[]>;
|
|
48
|
+
listRunEvents(threadId: string, runId: string): Promise<HarnessEvent[]>;
|
|
49
|
+
listApprovals(): Promise<InternalApprovalRecord[]>;
|
|
50
|
+
getApproval(approvalId: string): Promise<InternalApprovalRecord | null>;
|
|
51
|
+
getRunApprovals(threadId: string, runId: string): Promise<InternalApprovalRecord[]>;
|
|
52
|
+
getRunMeta(threadId: string, runId: string): Promise<PersistenceRunMeta>;
|
|
53
|
+
getRunLifecycle(threadId: string, runId: string): Promise<PersistenceLifecycle>;
|
|
54
|
+
deleteThread(threadId: string): Promise<boolean>;
|
|
55
|
+
saveRunRequest(threadId: string, runId: string, request: PersistedRunRequest): Promise<void>;
|
|
56
|
+
getRunRequest(threadId: string, runId: string): Promise<PersistedRunRequest | null>;
|
|
57
|
+
clearRunRequest(threadId: string, runId: string): Promise<void>;
|
|
58
|
+
createApproval(record: InternalApprovalRecord): Promise<void>;
|
|
59
|
+
resolveApproval(threadId: string, runId: string, approvalId: string, status: InternalApprovalRecord["status"]): Promise<InternalApprovalRecord>;
|
|
60
|
+
createArtifact(threadId: string, runId: string, artifact: ArtifactRecord, content: unknown): Promise<ArtifactRecord>;
|
|
61
|
+
listArtifacts(threadId: string, runId: string): Promise<ArtifactListing>;
|
|
62
|
+
appendThreadMessage(threadId: string, message: TranscriptMessage): Promise<void>;
|
|
63
|
+
listThreadMessages(threadId: string, limit?: number): Promise<TranscriptMessage[]>;
|
|
64
|
+
saveRecoveryIntent(threadId: string, runId: string, intent: RecoveryIntent): Promise<void>;
|
|
65
|
+
getRecoveryIntent(threadId: string, runId: string): Promise<RecoveryIntent | null>;
|
|
66
|
+
clearRecoveryIntent(threadId: string, runId: string): Promise<void>;
|
|
67
|
+
readArtifact(threadId: string, runId: string, artifactPath: string): Promise<unknown>;
|
|
68
|
+
}
|