stable-harness 0.0.1
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 +32 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +2 -0
- package/dist/compat/agent-harness.d.ts +24 -0
- package/dist/compat/agent-harness.js +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +1 -0
- package/dist/runtime/compat/agent-harness-compat-runner.d.ts +2 -0
- package/dist/runtime/compat/agent-harness-compat-runner.js +1 -0
- package/dist/runtime/compat/json.d.ts +3 -0
- package/dist/runtime/compat/json.js +1 -0
- package/dist/runtime/compat/presentation.d.ts +1 -0
- package/dist/runtime/compat/presentation.js +1 -0
- package/dist/runtime/compat/prompts.d.ts +24 -0
- package/dist/runtime/compat/prompts.js +1 -0
- package/dist/runtime/compat/tool-registry.d.ts +3 -0
- package/dist/runtime/compat/tool-registry.js +1 -0
- package/dist/runtime/compat/types.d.ts +38 -0
- package/dist/runtime/compat/types.js +1 -0
- package/dist/runtime/model/ollama.d.ts +2 -0
- package/dist/runtime/model/ollama.js +1 -0
- package/dist/runtime/skills/skill-metadata.d.ts +7 -0
- package/dist/runtime/skills/skill-metadata.js +1 -0
- package/dist/runtime/workspace/types.d.ts +38 -0
- package/dist/runtime/workspace/types.js +1 -0
- package/dist/tools.d.ts +12 -0
- package/dist/tools.js +1 -0
- package/dist/workspace/compile.d.ts +2 -0
- package/dist/workspace/compile.js +1 -0
- package/package.json +94 -0
- package/packages/adapter-deepagents/dist/src/adapter.d.ts +8 -0
- package/packages/adapter-deepagents/dist/src/adapter.js +1 -0
- package/packages/adapter-deepagents/dist/src/builtin-tool-policy.d.ts +18 -0
- package/packages/adapter-deepagents/dist/src/builtin-tool-policy.js +1 -0
- package/packages/adapter-deepagents/dist/src/index.d.ts +2 -0
- package/packages/adapter-deepagents/dist/src/index.js +1 -0
- package/packages/adapter-deepagents/dist/src/messages.d.ts +9 -0
- package/packages/adapter-deepagents/dist/src/messages.js +1 -0
- package/packages/adapter-deepagents/dist/src/retry-policy.d.ts +2 -0
- package/packages/adapter-deepagents/dist/src/retry-policy.js +1 -0
- package/packages/adapter-deepagents/dist/src/stream-events.d.ts +2 -0
- package/packages/adapter-deepagents/dist/src/stream-events.js +1 -0
- package/packages/adapter-deepagents/dist/src/types.d.ts +6 -0
- package/packages/adapter-deepagents/dist/src/types.js +1 -0
- package/packages/adapter-deepagents/package.json +26 -0
- package/packages/cli/dist/src/cli.d.ts +2 -0
- package/packages/cli/dist/src/cli.js +2 -0
- package/packages/cli/dist/src/index.d.ts +1 -0
- package/packages/cli/dist/src/index.js +1 -0
- package/packages/cli/package.json +22 -0
- package/packages/core/dist/artifacts.d.ts +8 -0
- package/packages/core/dist/artifacts.js +1 -0
- package/packages/core/dist/execution-contract.d.ts +8 -0
- package/packages/core/dist/execution-contract.js +1 -0
- package/packages/core/dist/index.d.ts +9 -0
- package/packages/core/dist/index.js +1 -0
- package/packages/core/dist/inspection.d.ts +4 -0
- package/packages/core/dist/inspection.js +1 -0
- package/packages/core/dist/memory-plugins.d.ts +68 -0
- package/packages/core/dist/memory-plugins.js +1 -0
- package/packages/core/dist/queue.d.ts +2 -0
- package/packages/core/dist/queue.js +1 -0
- package/packages/core/dist/runtime.d.ts +12 -0
- package/packages/core/dist/runtime.js +1 -0
- package/packages/core/dist/stores.d.ts +3 -0
- package/packages/core/dist/stores.js +1 -0
- package/packages/core/dist/trace.d.ts +15 -0
- package/packages/core/dist/trace.js +1 -0
- package/packages/core/dist/types.d.ts +526 -0
- package/packages/core/dist/types.js +1 -0
- package/packages/core/package.json +17 -0
- package/packages/evaluation/dist/src/index.d.ts +2 -0
- package/packages/evaluation/dist/src/index.js +1 -0
- package/packages/evaluation/dist/src/trace.d.ts +16 -0
- package/packages/evaluation/dist/src/trace.js +1 -0
- package/packages/evaluation/dist/src/types.d.ts +11 -0
- package/packages/evaluation/dist/src/types.js +1 -0
- package/packages/evaluation/package.json +15 -0
- package/packages/governance/dist/src/approval-queue.d.ts +2 -0
- package/packages/governance/dist/src/approval-queue.js +1 -0
- package/packages/governance/dist/src/index.d.ts +4 -0
- package/packages/governance/dist/src/index.js +1 -0
- package/packages/governance/dist/src/policy-engine.d.ts +2 -0
- package/packages/governance/dist/src/policy-engine.js +1 -0
- package/packages/governance/dist/src/skill-candidates.d.ts +2 -0
- package/packages/governance/dist/src/skill-candidates.js +1 -0
- package/packages/governance/dist/src/types.d.ts +100 -0
- package/packages/governance/dist/src/types.js +1 -0
- package/packages/governance/package.json +12 -0
- package/packages/memory/dist/src/index.d.ts +9 -0
- package/packages/memory/dist/src/index.js +1 -0
- package/packages/memory/dist/src/langmem-service.d.ts +8 -0
- package/packages/memory/dist/src/langmem-service.js +1 -0
- package/packages/memory/dist/src/maintenance.d.ts +2 -0
- package/packages/memory/dist/src/maintenance.js +1 -0
- package/packages/memory/dist/src/persistence.d.ts +4 -0
- package/packages/memory/dist/src/persistence.js +1 -0
- package/packages/memory/dist/src/policy.d.ts +2 -0
- package/packages/memory/dist/src/policy.js +1 -0
- package/packages/memory/dist/src/provider.d.ts +50 -0
- package/packages/memory/dist/src/provider.js +1 -0
- package/packages/memory/dist/src/store.d.ts +5 -0
- package/packages/memory/dist/src/store.js +1 -0
- package/packages/memory/dist/src/types.d.ts +138 -0
- package/packages/memory/dist/src/types.js +1 -0
- package/packages/memory/package.json +12 -0
- package/packages/protocols/dist/src/http-server.d.ts +3 -0
- package/packages/protocols/dist/src/http-server.js +1 -0
- package/packages/protocols/dist/src/in-process-client.d.ts +2 -0
- package/packages/protocols/dist/src/in-process-client.js +1 -0
- package/packages/protocols/dist/src/index.d.ts +4 -0
- package/packages/protocols/dist/src/index.js +1 -0
- package/packages/protocols/dist/src/openai-compatible.d.ts +9 -0
- package/packages/protocols/dist/src/openai-compatible.js +1 -0
- package/packages/protocols/package.json +15 -0
- package/packages/tool-gateway/dist/src/argument-guard.d.ts +32 -0
- package/packages/tool-gateway/dist/src/argument-guard.js +1 -0
- package/packages/tool-gateway/dist/src/in-memory.d.ts +4 -0
- package/packages/tool-gateway/dist/src/in-memory.js +1 -0
- package/packages/tool-gateway/dist/src/index.d.ts +7 -0
- package/packages/tool-gateway/dist/src/index.js +1 -0
- package/packages/tool-gateway/dist/src/module-loader.d.ts +13 -0
- package/packages/tool-gateway/dist/src/module-loader.js +1 -0
- package/packages/tool-gateway/dist/src/types.d.ts +65 -0
- package/packages/tool-gateway/dist/src/types.js +1 -0
- package/packages/tool-gateway/package.json +15 -0
- package/packages/workspace-yaml/dist/index.d.ts +1 -0
- package/packages/workspace-yaml/dist/index.js +1 -0
- package/packages/workspace-yaml/dist/loader.d.ts +2 -0
- package/packages/workspace-yaml/dist/loader.js +1 -0
- package/packages/workspace-yaml/package.json +16 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
import type { MemoryCandidate, MemoryDecision, MemoryProvider, MemoryRecord, RuntimeMemoryStore } from "@stable-harness/memory";
|
|
2
|
+
import type { ApprovalQueue, ApprovalRequest } from "@stable-harness/governance";
|
|
3
|
+
export type RuntimeRecordState = "queued" | "running" | "completed" | "failed" | "cancelled";
|
|
4
|
+
export type RuntimeOutput = {
|
|
5
|
+
text: string;
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
7
|
+
artifacts?: RuntimeArtifact[];
|
|
8
|
+
};
|
|
9
|
+
export type RuntimeArtifact = {
|
|
10
|
+
id: string;
|
|
11
|
+
kind: string;
|
|
12
|
+
uri?: string;
|
|
13
|
+
metadata?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
export type RuntimeArtifactRecord = RuntimeArtifact & {
|
|
16
|
+
requestId: string;
|
|
17
|
+
sessionId: string;
|
|
18
|
+
agentId: string;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
contentType?: string;
|
|
21
|
+
size?: number;
|
|
22
|
+
};
|
|
23
|
+
export type RuntimeArtifactInput = RuntimeArtifact & {
|
|
24
|
+
requestId: string;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
agentId: string;
|
|
27
|
+
content?: unknown;
|
|
28
|
+
contentType?: string;
|
|
29
|
+
createdAt?: string;
|
|
30
|
+
};
|
|
31
|
+
export type RuntimeArtifactStore = {
|
|
32
|
+
createArtifact(input: RuntimeArtifactInput): RuntimeArtifactRecord;
|
|
33
|
+
listArtifacts(filter?: RuntimeArtifactFilter): RuntimeArtifactRecord[];
|
|
34
|
+
readArtifact(id: string): unknown;
|
|
35
|
+
};
|
|
36
|
+
export type RuntimeArtifactFilter = {
|
|
37
|
+
requestId?: string;
|
|
38
|
+
sessionId?: string;
|
|
39
|
+
agentId?: string;
|
|
40
|
+
};
|
|
41
|
+
export type WorkspaceModel = {
|
|
42
|
+
id: string;
|
|
43
|
+
provider: string;
|
|
44
|
+
model: string;
|
|
45
|
+
config?: Record<string, unknown>;
|
|
46
|
+
};
|
|
47
|
+
export type WorkspaceTool = {
|
|
48
|
+
id: string;
|
|
49
|
+
description?: string;
|
|
50
|
+
schema?: unknown;
|
|
51
|
+
implementation?: string;
|
|
52
|
+
sourcePath?: string;
|
|
53
|
+
};
|
|
54
|
+
export type WorkspaceSkill = {
|
|
55
|
+
id: string;
|
|
56
|
+
path: string;
|
|
57
|
+
description?: string;
|
|
58
|
+
allowedTools: string[];
|
|
59
|
+
};
|
|
60
|
+
export type WorkspaceMemory = {
|
|
61
|
+
id: string;
|
|
62
|
+
provider: string;
|
|
63
|
+
profile?: string;
|
|
64
|
+
mode?: string;
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
prompts?: {
|
|
67
|
+
semantic?: string;
|
|
68
|
+
episodic?: string;
|
|
69
|
+
procedural?: string;
|
|
70
|
+
};
|
|
71
|
+
config?: Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
export type WorkspaceAgent = {
|
|
74
|
+
id: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
sourcePath?: string;
|
|
77
|
+
backend: string;
|
|
78
|
+
modelRef?: string;
|
|
79
|
+
systemPrompt?: string;
|
|
80
|
+
tools: string[];
|
|
81
|
+
skills?: string[];
|
|
82
|
+
memory?: unknown[];
|
|
83
|
+
subagents: string[];
|
|
84
|
+
config: Record<string, unknown>;
|
|
85
|
+
};
|
|
86
|
+
export type WorkspaceRuntimePolicy = {
|
|
87
|
+
defaultAgentId: string;
|
|
88
|
+
workspaceId?: string;
|
|
89
|
+
profile?: string;
|
|
90
|
+
approvals?: Record<string, unknown>;
|
|
91
|
+
recovery?: Record<string, unknown>;
|
|
92
|
+
retry?: WorkspaceRetryPolicy;
|
|
93
|
+
memory?: Record<string, unknown>;
|
|
94
|
+
protocols?: Record<string, unknown>;
|
|
95
|
+
};
|
|
96
|
+
export type WorkspaceRetryPolicy = {
|
|
97
|
+
model?: WorkspaceRetryTargetPolicy;
|
|
98
|
+
tools?: WorkspaceToolRetryPolicy;
|
|
99
|
+
};
|
|
100
|
+
export type WorkspaceRetryTargetPolicy = {
|
|
101
|
+
enabled?: boolean;
|
|
102
|
+
maxRetries?: number;
|
|
103
|
+
retryOn?: WorkspaceRetryReason[];
|
|
104
|
+
backoffFactor?: number;
|
|
105
|
+
initialDelayMs?: number;
|
|
106
|
+
maxDelayMs?: number;
|
|
107
|
+
jitter?: boolean;
|
|
108
|
+
onFailure?: "continue" | "error";
|
|
109
|
+
};
|
|
110
|
+
export type WorkspaceToolRetryPolicy = WorkspaceRetryTargetPolicy & {
|
|
111
|
+
tools?: string[];
|
|
112
|
+
};
|
|
113
|
+
export type WorkspaceRetryReason = "timeout" | "network" | "rateLimit" | "serverError";
|
|
114
|
+
export type CompiledWorkspace = {
|
|
115
|
+
root: string;
|
|
116
|
+
runtime: WorkspaceRuntimePolicy;
|
|
117
|
+
agents: Map<string, WorkspaceAgent>;
|
|
118
|
+
models: Map<string, WorkspaceModel>;
|
|
119
|
+
tools: Map<string, WorkspaceTool>;
|
|
120
|
+
skills: Map<string, WorkspaceSkill>;
|
|
121
|
+
memories: Map<string, WorkspaceMemory>;
|
|
122
|
+
};
|
|
123
|
+
export type RuntimeRequest = {
|
|
124
|
+
input: string;
|
|
125
|
+
agentId?: string;
|
|
126
|
+
sessionId?: string;
|
|
127
|
+
requestId?: string;
|
|
128
|
+
parentRunId?: string;
|
|
129
|
+
toolCall?: RuntimeToolCallRequest;
|
|
130
|
+
memory?: RuntimeRequestMemory;
|
|
131
|
+
metadata?: Record<string, unknown>;
|
|
132
|
+
};
|
|
133
|
+
export type RuntimeToolCallRequest = {
|
|
134
|
+
toolId: string;
|
|
135
|
+
args?: unknown;
|
|
136
|
+
};
|
|
137
|
+
export type RuntimeRequestMemory = {
|
|
138
|
+
namespace?: string;
|
|
139
|
+
recall?: false | {
|
|
140
|
+
query?: string;
|
|
141
|
+
limit?: number;
|
|
142
|
+
};
|
|
143
|
+
candidates?: RuntimeMemoryCandidateInput[];
|
|
144
|
+
};
|
|
145
|
+
export type RuntimeMemoryCandidateInput = Omit<MemoryCandidate, "namespace"> & {
|
|
146
|
+
namespace?: string;
|
|
147
|
+
};
|
|
148
|
+
export type RuntimeResponse = {
|
|
149
|
+
requestId: string;
|
|
150
|
+
sessionId: string;
|
|
151
|
+
agentId: string;
|
|
152
|
+
state: RuntimeRecordState;
|
|
153
|
+
output: string;
|
|
154
|
+
metadata?: Record<string, unknown>;
|
|
155
|
+
artifacts?: RuntimeArtifact[];
|
|
156
|
+
};
|
|
157
|
+
export type RuntimeRunRecord = {
|
|
158
|
+
requestId: string;
|
|
159
|
+
sessionId: string;
|
|
160
|
+
agentId: string;
|
|
161
|
+
input: string;
|
|
162
|
+
state: RuntimeRecordState;
|
|
163
|
+
output?: string;
|
|
164
|
+
error?: string;
|
|
165
|
+
parentRunId?: string;
|
|
166
|
+
metadata?: Record<string, unknown>;
|
|
167
|
+
artifacts: RuntimeArtifact[];
|
|
168
|
+
startedAt: string;
|
|
169
|
+
completedAt?: string;
|
|
170
|
+
events: RuntimeEvent[];
|
|
171
|
+
};
|
|
172
|
+
export type RuntimeStoreRunPatch = Partial<Pick<RuntimeRunRecord, "state" | "output" | "error" | "metadata" | "artifacts" | "completedAt">>;
|
|
173
|
+
export type RuntimeRunFilter = {
|
|
174
|
+
agentId?: string;
|
|
175
|
+
sessionId?: string;
|
|
176
|
+
state?: RuntimeRecordState;
|
|
177
|
+
};
|
|
178
|
+
export type RuntimeStore = {
|
|
179
|
+
createRun(record: RuntimeRunRecord): void;
|
|
180
|
+
updateRun(requestId: string, patch: RuntimeStoreRunPatch): RuntimeRunRecord | undefined;
|
|
181
|
+
appendEvent(event: RuntimeEvent): RuntimeRunRecord | undefined;
|
|
182
|
+
getRun(requestId: string): RuntimeRunRecord | undefined;
|
|
183
|
+
listRuns(filter?: RuntimeRunFilter): RuntimeRunRecord[];
|
|
184
|
+
};
|
|
185
|
+
export type RuntimeQueueRecord = {
|
|
186
|
+
requestId: string;
|
|
187
|
+
sessionId: string;
|
|
188
|
+
priority: number;
|
|
189
|
+
queueKey?: string;
|
|
190
|
+
enqueuedAt: string;
|
|
191
|
+
availableAt: string;
|
|
192
|
+
claimedBy?: string;
|
|
193
|
+
claimedAt?: string;
|
|
194
|
+
leaseExpiresAt?: string;
|
|
195
|
+
attemptCount: number;
|
|
196
|
+
lastError?: string;
|
|
197
|
+
};
|
|
198
|
+
export type RuntimeRequestControlRecord = {
|
|
199
|
+
requestId: string;
|
|
200
|
+
cancelRequested: boolean;
|
|
201
|
+
cancelReason?: string;
|
|
202
|
+
cancelRequestedAt?: string;
|
|
203
|
+
heartbeatAt?: string;
|
|
204
|
+
workerId?: string;
|
|
205
|
+
workerStartedAt?: string;
|
|
206
|
+
};
|
|
207
|
+
export type RuntimeRecoveryIntent = {
|
|
208
|
+
requestId: string;
|
|
209
|
+
sessionId: string;
|
|
210
|
+
kind: "approval-decision" | "restart-request";
|
|
211
|
+
savedAt: string;
|
|
212
|
+
checkpointRef?: string;
|
|
213
|
+
resumePayload?: unknown;
|
|
214
|
+
attempts: number;
|
|
215
|
+
};
|
|
216
|
+
export type RuntimeQueueStore = {
|
|
217
|
+
enqueue(record: Omit<RuntimeQueueRecord, "attemptCount" | "enqueuedAt"> & {
|
|
218
|
+
attemptCount?: number;
|
|
219
|
+
enqueuedAt?: string;
|
|
220
|
+
}): RuntimeQueueRecord;
|
|
221
|
+
listQueue(): RuntimeQueueRecord[];
|
|
222
|
+
getQueuedRequest(requestId: string): RuntimeQueueRecord | undefined;
|
|
223
|
+
claimNext(input: RuntimeQueueClaimInput): RuntimeQueueRecord | undefined;
|
|
224
|
+
heartbeat(input: RuntimeHeartbeatInput): RuntimeRequestControlRecord | undefined;
|
|
225
|
+
requestCancel(input: RuntimeCancelIntentInput): RuntimeRequestControlRecord;
|
|
226
|
+
getControl(requestId: string): RuntimeRequestControlRecord | undefined;
|
|
227
|
+
listStuck(input: RuntimeStuckRequestInput): RuntimeQueueRecord[];
|
|
228
|
+
saveRecoveryIntent(intent: RuntimeRecoveryIntent): RuntimeRecoveryIntent;
|
|
229
|
+
getRecoveryIntent(requestId: string): RuntimeRecoveryIntent | undefined;
|
|
230
|
+
clearRecoveryIntent(requestId: string): boolean;
|
|
231
|
+
};
|
|
232
|
+
export type RuntimeQueueClaimInput = {
|
|
233
|
+
workerId: string;
|
|
234
|
+
now?: string;
|
|
235
|
+
leaseMs: number;
|
|
236
|
+
queueKey?: string;
|
|
237
|
+
};
|
|
238
|
+
export type RuntimeHeartbeatInput = {
|
|
239
|
+
requestId: string;
|
|
240
|
+
workerId: string;
|
|
241
|
+
now?: string;
|
|
242
|
+
};
|
|
243
|
+
export type RuntimeCancelIntentInput = {
|
|
244
|
+
requestId: string;
|
|
245
|
+
reason?: string;
|
|
246
|
+
now?: string;
|
|
247
|
+
};
|
|
248
|
+
export type RuntimeStuckRequestInput = {
|
|
249
|
+
now?: string;
|
|
250
|
+
staleAfterMs: number;
|
|
251
|
+
};
|
|
252
|
+
export type RuntimeEvent = {
|
|
253
|
+
type: "request.started";
|
|
254
|
+
requestId: string;
|
|
255
|
+
sessionId: string;
|
|
256
|
+
agentId: string;
|
|
257
|
+
} | {
|
|
258
|
+
type: "request.completed";
|
|
259
|
+
requestId: string;
|
|
260
|
+
sessionId: string;
|
|
261
|
+
agentId: string;
|
|
262
|
+
output: string;
|
|
263
|
+
} | {
|
|
264
|
+
type: "request.failed";
|
|
265
|
+
requestId: string;
|
|
266
|
+
sessionId: string;
|
|
267
|
+
agentId: string;
|
|
268
|
+
error: string;
|
|
269
|
+
} | {
|
|
270
|
+
type: "request.cancelled";
|
|
271
|
+
requestId: string;
|
|
272
|
+
sessionId: string;
|
|
273
|
+
agentId: string;
|
|
274
|
+
reason?: string;
|
|
275
|
+
} | {
|
|
276
|
+
type: "artifact.created";
|
|
277
|
+
requestId: string;
|
|
278
|
+
sessionId: string;
|
|
279
|
+
agentId: string;
|
|
280
|
+
artifact: RuntimeArtifact;
|
|
281
|
+
} | {
|
|
282
|
+
type: "execution.contract.failed";
|
|
283
|
+
requestId: string;
|
|
284
|
+
sessionId: string;
|
|
285
|
+
agentId: string;
|
|
286
|
+
reason: string;
|
|
287
|
+
missingEvidenceTools?: string[];
|
|
288
|
+
} | {
|
|
289
|
+
type: "tool.started";
|
|
290
|
+
requestId: string;
|
|
291
|
+
sessionId: string;
|
|
292
|
+
agentId: string;
|
|
293
|
+
toolId: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: "tool.completed";
|
|
296
|
+
requestId: string;
|
|
297
|
+
sessionId: string;
|
|
298
|
+
agentId: string;
|
|
299
|
+
toolId: string;
|
|
300
|
+
output: unknown;
|
|
301
|
+
} | {
|
|
302
|
+
type: "memory.lifecycle";
|
|
303
|
+
requestId: string;
|
|
304
|
+
sessionId: string;
|
|
305
|
+
agentId: string;
|
|
306
|
+
hook: RuntimeMemoryHook;
|
|
307
|
+
} | {
|
|
308
|
+
type: "memory.recall.completed";
|
|
309
|
+
requestId: string;
|
|
310
|
+
sessionId: string;
|
|
311
|
+
agentId: string;
|
|
312
|
+
namespace: string;
|
|
313
|
+
recordIds: string[];
|
|
314
|
+
context: string;
|
|
315
|
+
} | {
|
|
316
|
+
type: "memory.candidate.submitted";
|
|
317
|
+
requestId: string;
|
|
318
|
+
sessionId: string;
|
|
319
|
+
agentId: string;
|
|
320
|
+
candidate: MemoryCandidate;
|
|
321
|
+
decision: MemoryDecision;
|
|
322
|
+
record?: MemoryRecord;
|
|
323
|
+
} | {
|
|
324
|
+
type: "memory.approval.requested";
|
|
325
|
+
requestId: string;
|
|
326
|
+
sessionId: string;
|
|
327
|
+
agentId: string;
|
|
328
|
+
approval: ApprovalRequest;
|
|
329
|
+
} | {
|
|
330
|
+
type: "memory.plugin.started";
|
|
331
|
+
requestId: string;
|
|
332
|
+
sessionId: string;
|
|
333
|
+
agentId: string;
|
|
334
|
+
memoryId: string;
|
|
335
|
+
provider: string;
|
|
336
|
+
namespace: string;
|
|
337
|
+
} | {
|
|
338
|
+
type: "memory.plugin.completed";
|
|
339
|
+
requestId: string;
|
|
340
|
+
sessionId: string;
|
|
341
|
+
agentId: string;
|
|
342
|
+
memoryId: string;
|
|
343
|
+
provider: string;
|
|
344
|
+
namespace: string;
|
|
345
|
+
candidateCount: number;
|
|
346
|
+
} | {
|
|
347
|
+
type: "memory.plugin.failed";
|
|
348
|
+
requestId: string;
|
|
349
|
+
sessionId: string;
|
|
350
|
+
agentId: string;
|
|
351
|
+
memoryId: string;
|
|
352
|
+
provider: string;
|
|
353
|
+
namespace: string;
|
|
354
|
+
error: string;
|
|
355
|
+
} | {
|
|
356
|
+
type: "memory.maintenance.started";
|
|
357
|
+
requestId: string;
|
|
358
|
+
sessionId: string;
|
|
359
|
+
agentId: string;
|
|
360
|
+
target: string;
|
|
361
|
+
} | {
|
|
362
|
+
type: "memory.maintenance.completed";
|
|
363
|
+
requestId: string;
|
|
364
|
+
sessionId: string;
|
|
365
|
+
agentId: string;
|
|
366
|
+
target: string;
|
|
367
|
+
operationCount: number;
|
|
368
|
+
} | {
|
|
369
|
+
type: "memory.maintenance.failed";
|
|
370
|
+
requestId: string;
|
|
371
|
+
sessionId: string;
|
|
372
|
+
agentId: string;
|
|
373
|
+
target: string;
|
|
374
|
+
error: string;
|
|
375
|
+
} | {
|
|
376
|
+
type: "skill.candidate.created";
|
|
377
|
+
requestId: string;
|
|
378
|
+
sessionId: string;
|
|
379
|
+
agentId: string;
|
|
380
|
+
candidateId: string;
|
|
381
|
+
name: string;
|
|
382
|
+
confidence: number;
|
|
383
|
+
evidenceCount: number;
|
|
384
|
+
status: string;
|
|
385
|
+
proposedPath?: string;
|
|
386
|
+
} | {
|
|
387
|
+
type: "adapter.event";
|
|
388
|
+
requestId: string;
|
|
389
|
+
sessionId: string;
|
|
390
|
+
agentId: string;
|
|
391
|
+
event: unknown;
|
|
392
|
+
};
|
|
393
|
+
export type RuntimeMemoryHook = "read-before-plan" | "read-before-finalize" | "write-after-run";
|
|
394
|
+
export type RuntimeEventListener = (event: RuntimeEvent) => void;
|
|
395
|
+
export type RuntimeEmit = (event: RuntimeEvent) => void;
|
|
396
|
+
export type RuntimeAdapterContext = {
|
|
397
|
+
workspace: CompiledWorkspace;
|
|
398
|
+
agent: WorkspaceAgent;
|
|
399
|
+
request: RuntimeRequest;
|
|
400
|
+
requestId: string;
|
|
401
|
+
sessionId: string;
|
|
402
|
+
memory?: RuntimeMemoryContext;
|
|
403
|
+
pluginMemories?: RuntimeMemoryContext[];
|
|
404
|
+
toolGateway?: RuntimeToolGateway;
|
|
405
|
+
emit: RuntimeEmit;
|
|
406
|
+
};
|
|
407
|
+
export type RuntimeMemoryContext = {
|
|
408
|
+
namespace: string;
|
|
409
|
+
records: MemoryRecord[];
|
|
410
|
+
context: string;
|
|
411
|
+
};
|
|
412
|
+
export type RuntimeAdapterResult = string | RuntimeOutput;
|
|
413
|
+
export type RuntimeAdapter = {
|
|
414
|
+
name: string;
|
|
415
|
+
canRun(agent: WorkspaceAgent): boolean;
|
|
416
|
+
run(input: RuntimeAdapterContext): Promise<RuntimeAdapterResult>;
|
|
417
|
+
};
|
|
418
|
+
export type RuntimeMemoryServices = {
|
|
419
|
+
store: RuntimeMemoryStore;
|
|
420
|
+
providers?: MemoryProvider[];
|
|
421
|
+
};
|
|
422
|
+
export type RuntimeGovernanceServices = {
|
|
423
|
+
approvals?: ApprovalQueue;
|
|
424
|
+
};
|
|
425
|
+
export type RuntimeToolServices = {
|
|
426
|
+
gateway?: RuntimeToolGateway;
|
|
427
|
+
};
|
|
428
|
+
export type RuntimeToolGatewayContext = {
|
|
429
|
+
workspaceRoot: string;
|
|
430
|
+
requestId: string;
|
|
431
|
+
sessionId: string;
|
|
432
|
+
agentId: string;
|
|
433
|
+
};
|
|
434
|
+
export type RuntimeToolGatewayTool = {
|
|
435
|
+
id: string;
|
|
436
|
+
description?: string;
|
|
437
|
+
schema?: unknown;
|
|
438
|
+
};
|
|
439
|
+
export type RuntimeToolGateway = {
|
|
440
|
+
get(toolId: string): RuntimeToolGatewayTool | undefined;
|
|
441
|
+
repairToolCall?(request: {
|
|
442
|
+
toolId: string;
|
|
443
|
+
args?: unknown;
|
|
444
|
+
allowedToolIds?: string[];
|
|
445
|
+
context: RuntimeToolGatewayContext;
|
|
446
|
+
}): Promise<{
|
|
447
|
+
toolId: string;
|
|
448
|
+
args: unknown;
|
|
449
|
+
} | undefined>;
|
|
450
|
+
invoke(request: {
|
|
451
|
+
toolId: string;
|
|
452
|
+
args?: unknown;
|
|
453
|
+
context: RuntimeToolGatewayContext;
|
|
454
|
+
}): Promise<{
|
|
455
|
+
toolId: string;
|
|
456
|
+
output: unknown;
|
|
457
|
+
}>;
|
|
458
|
+
};
|
|
459
|
+
export type RuntimeInspectionSnapshot = {
|
|
460
|
+
workspaceRoot: string;
|
|
461
|
+
agents: string[];
|
|
462
|
+
models: string[];
|
|
463
|
+
tools: string[];
|
|
464
|
+
runs: RuntimeRunRecord[];
|
|
465
|
+
};
|
|
466
|
+
export type RuntimeRequestSummary = {
|
|
467
|
+
requestId: string;
|
|
468
|
+
sessionId: string;
|
|
469
|
+
agentId: string;
|
|
470
|
+
parentRunId?: string;
|
|
471
|
+
state: RuntimeRecordState;
|
|
472
|
+
startedAt: string;
|
|
473
|
+
completedAt?: string;
|
|
474
|
+
eventCount: number;
|
|
475
|
+
artifactCount: number;
|
|
476
|
+
};
|
|
477
|
+
export type RuntimeSessionSummary = {
|
|
478
|
+
sessionId: string;
|
|
479
|
+
requestCount: number;
|
|
480
|
+
agentIds: string[];
|
|
481
|
+
states: Partial<Record<RuntimeRecordState, number>>;
|
|
482
|
+
startedAt: string;
|
|
483
|
+
updatedAt: string;
|
|
484
|
+
};
|
|
485
|
+
export type RuntimeBindingSnapshot = {
|
|
486
|
+
workspaceRoot: string;
|
|
487
|
+
agentId: string;
|
|
488
|
+
backend: string;
|
|
489
|
+
modelRef?: string;
|
|
490
|
+
tools: string[];
|
|
491
|
+
skills: string[];
|
|
492
|
+
subagents: string[];
|
|
493
|
+
};
|
|
494
|
+
export type RuntimeTimelineItem = {
|
|
495
|
+
index: number;
|
|
496
|
+
type: RuntimeEvent["type"];
|
|
497
|
+
event: RuntimeEvent;
|
|
498
|
+
};
|
|
499
|
+
export type RuntimeRequestInspection = {
|
|
500
|
+
summary: RuntimeRequestSummary;
|
|
501
|
+
input: string;
|
|
502
|
+
output?: string;
|
|
503
|
+
error?: string;
|
|
504
|
+
metadata?: Record<string, unknown>;
|
|
505
|
+
artifacts: RuntimeArtifact[];
|
|
506
|
+
runtimeSnapshot: RuntimeBindingSnapshot;
|
|
507
|
+
timeline: RuntimeTimelineItem[];
|
|
508
|
+
};
|
|
509
|
+
export type RuntimeClient = {
|
|
510
|
+
request(request: RuntimeRequest): Promise<RuntimeResponse>;
|
|
511
|
+
};
|
|
512
|
+
export type RuntimeEventSource = {
|
|
513
|
+
subscribe(listener: RuntimeEventListener): () => void;
|
|
514
|
+
};
|
|
515
|
+
export type RuntimeInspector = {
|
|
516
|
+
inspect(): RuntimeInspectionSnapshot;
|
|
517
|
+
getRun(requestId: string): RuntimeRunRecord | undefined;
|
|
518
|
+
listRequests(filter?: RuntimeRunFilter): RuntimeRequestSummary[];
|
|
519
|
+
listSessions(): RuntimeSessionSummary[];
|
|
520
|
+
inspectRequest(requestId: string): RuntimeRequestInspection | undefined;
|
|
521
|
+
};
|
|
522
|
+
export type RuntimeLifecycle = {
|
|
523
|
+
cancel(requestId: string, reason?: string): void;
|
|
524
|
+
stop(): Promise<void>;
|
|
525
|
+
};
|
|
526
|
+
export type StableHarnessRuntime = RuntimeClient & RuntimeEventSource & RuntimeInspector & RuntimeLifecycle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stable-harness/core",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/**/*.js",
|
|
7
|
+
"dist/**/*.d.ts",
|
|
8
|
+
"package.json"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@stable-harness/governance": "0.0.1",
|
|
15
|
+
"@stable-harness/memory": "0.0.1"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createTraceRecorder,createReplayManifest,createEvaluationBundle}from"./trace.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RuntimeArtifactRecord, RuntimeEvent, RuntimeRunRecord } from "@stable-harness/core";
|
|
2
|
+
import type { EvaluationBundle, ReplayManifest } from "./types.js";
|
|
3
|
+
export declare function createTraceRecorder(): {
|
|
4
|
+
listener(event: RuntimeEvent): void;
|
|
5
|
+
events(): RuntimeEvent[];
|
|
6
|
+
};
|
|
7
|
+
export declare function createReplayManifest(input: {
|
|
8
|
+
runs: RuntimeRunRecord[];
|
|
9
|
+
events: RuntimeEvent[];
|
|
10
|
+
}): ReplayManifest;
|
|
11
|
+
export declare function createEvaluationBundle(input: {
|
|
12
|
+
runs: RuntimeRunRecord[];
|
|
13
|
+
events: RuntimeEvent[];
|
|
14
|
+
artifacts?: RuntimeArtifactRecord[];
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
}): EvaluationBundle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createTraceRecorder(){const e=[];return{listener(t){e.push(t)},events:()=>[...e]}}export function createReplayManifest(e){return{schemaVersion:1,createdAt:(new Date).toISOString(),runs:e.runs,events:e.events}}export function createEvaluationBundle(e){return{...createReplayManifest({runs:e.runs,events:e.events}),artifacts:e.artifacts??[],metadata:e.metadata}}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RuntimeArtifactRecord, RuntimeEvent, RuntimeRunRecord } from "@stable-harness/core";
|
|
2
|
+
export type ReplayManifest = {
|
|
3
|
+
schemaVersion: 1;
|
|
4
|
+
createdAt: string;
|
|
5
|
+
runs: RuntimeRunRecord[];
|
|
6
|
+
events: RuntimeEvent[];
|
|
7
|
+
};
|
|
8
|
+
export type EvaluationBundle = ReplayManifest & {
|
|
9
|
+
artifacts: RuntimeArtifactRecord[];
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stable-harness/evaluation",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/**/*.js",
|
|
7
|
+
"dist/**/*.d.ts",
|
|
8
|
+
"package.json"
|
|
9
|
+
],
|
|
10
|
+
"main": "dist/src/index.js",
|
|
11
|
+
"types": "dist/src/index.d.ts",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@stable-harness/core": "0.0.1"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";export function createInMemoryApprovalQueue(){const t=[];return{async create(n){const s={id:e(),kind:n.kind,reason:n.reason,status:"pending",requestId:n.requestId,sessionId:n.sessionId,agentId:n.agentId,subject:n.subject,createdAt:(new Date).toISOString()};return t.push(s),s},list:async e=>e?t.filter(t=>t.status===e):[...t],async resolve(e,n){const s=t.find(t=>t.id===e);if(s)return s.status=n,s.resolvedAt=(new Date).toISOString(),s}}}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createInMemoryApprovalQueue } from "./approval-queue.js";
|
|
2
|
+
export { createPolicyEngine } from "./policy-engine.js";
|
|
3
|
+
export { createSqliteSkillCandidateStore } from "./skill-candidates.js";
|
|
4
|
+
export type { ApprovalQueue, ApprovalRequest, ApprovalRequestKind, ApprovalRequestStatus, PolicyDecision, RuntimePolicyEngine, SkillCandidate, SkillCandidateEvidence, SkillCandidateInput, SkillCandidateStatus, SkillCandidateStore, ToolPolicy, } from "./types.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createInMemoryApprovalQueue}from"./approval-queue.js";export{createPolicyEngine}from"./policy-engine.js";export{createSqliteSkillCandidateStore}from"./skill-candidates.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function createPolicyEngine(o={}){const e=new Set(o.approvalRequiredToolIds??[]),l=o.sandboxByToolId??{};return{evaluateTool:o=>e.has(o.toolId)?{action:"require_approval",reason:`Tool '${o.toolId}' requires explicit approval.`}:{action:"allow",reason:`Tool '${o.toolId}' is allowed by configured policy.`},resolveSandbox:o=>l[o.toolId]??o.defaultSandbox??"default"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{randomUUID as e}from"node:crypto";import{mkdirSync as t}from"node:fs";import n from"node:path";import{DatabaseSync as r}from"node:sqlite";export function createSqliteSkillCandidateStore(c){t(n.dirname(c),{recursive:!0});const o=new r(c);return function(e){e.exec("\n create table if not exists skill_candidates (\n id text primary key, workspace_id text not null, name text not null,\n status text not null, confidence real not null, evidence_count integer not null,\n proposed_path text, title text not null, summary text not null,\n draft_markdown text not null, created_at text not null, updated_at text not null,\n reviewed_at text, reviewed_by text, rejection_reason text,\n unique(workspace_id, name)\n );\n create table if not exists skill_candidate_evidence (\n id text primary key, candidate_id text not null, evidence_type text not null,\n evidence_ref text not null, summary text, weight real, created_at text not null,\n foreign key(candidate_id) references skill_candidates(id)\n );\n ")}(o),{async upsert(t){const n=(new Date).toISOString(),r=function(e,t,n){const r=e.prepare("select * from skill_candidates where workspace_id = ? and name = ?").get(t,n);return r?d(r):void 0}(o,t.workspaceId,t.name),i=r?function(e,t,n,r){return e.prepare("\n update skill_candidates\n set status = ?, confidence = ?, evidence_count = ?, proposed_path = ?,\n title = ?, summary = ?, draft_markdown = ?, updated_at = ?\n where id = ?\n ").run(n.status??"review_required",n.confidence,n.evidence.length,n.proposedPath??null,n.title,n.summary,n.draftMarkdown,r,t),a(e,t)}(o,r.id,t,n):function(t,n,r){const d=String(e());return t.prepare("\n insert into skill_candidates\n (id, workspace_id, name, status, confidence, evidence_count, proposed_path,\n title, summary, draft_markdown, created_at, updated_at)\n values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n ").run(d,n.workspaceId,n.name,n.status??"review_required",n.confidence,n.evidence.length,n.proposedPath??null,n.title,n.summary,n.draftMarkdown,r,r),a(t,d)}(o,t,n);return function(t,n,r,a){t.prepare("delete from skill_candidate_evidence where candidate_id = ?").run(n);const d=t.prepare("\n insert into skill_candidate_evidence\n (id, candidate_id, evidence_type, evidence_ref, summary, weight, created_at)\n values (?, ?, ?, ?, ?, ?, ?)\n ");for(const t of r)d.run(String(e()),n,t.evidenceType,t.evidenceRef,t.summary??null,t.weight??null,a)}(o,i.id,t.evidence,n),i},list:async(e={})=>function(e,t,n){return(t&&n?e.prepare("select * from skill_candidates where workspace_id = ? and status = ? order by updated_at desc").all(t,n):t?e.prepare("select * from skill_candidates where workspace_id = ? order by updated_at desc").all(t):e.prepare("select * from skill_candidates order by updated_at desc").all()).map(e=>d(e))}(o,e.workspaceId,e.status),get:async e=>a(o,e),listEvidence:async e=>function(e,t){return e.prepare("select * from skill_candidate_evidence where candidate_id = ? order by created_at asc").all(t).map(e=>function(e){return{id:String(e.id),candidateId:String(e.candidate_id),evidenceType:e.evidence_type,evidenceRef:String(e.evidence_ref),summary:i(e.summary),weight:"number"==typeof e.weight?e.weight:void 0,createdAt:String(e.created_at)}}(e))}(o,e),async updateStatus(e){const t=(new Date).toISOString();return o.prepare("\n update skill_candidates\n set status = ?, reviewed_at = ?, reviewed_by = ?, rejection_reason = ?, updated_at = ?\n where id = ?\n ").run(e.status,t,e.reviewedBy??null,e.rejectionReason??null,t,e.id),a(o,e.id)}}}function a(e,t){const n=e.prepare("select * from skill_candidates where id = ?").get(t);return n?d(n):void 0}function d(e){return{id:String(e.id),workspaceId:String(e.workspace_id),name:String(e.name),status:e.status,confidence:Number(e.confidence),evidenceCount:Number(e.evidence_count),proposedPath:i(e.proposed_path),title:String(e.title),summary:String(e.summary),draftMarkdown:String(e.draft_markdown),createdAt:String(e.created_at),updatedAt:String(e.updated_at),reviewedAt:i(e.reviewed_at),reviewedBy:i(e.reviewed_by),rejectionReason:i(e.rejection_reason)}}function i(e){return"string"==typeof e&&e?e:void 0}
|