stable-harness 0.0.2 → 0.0.4

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.
Files changed (168) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/compat/agent-harness.js +1 -1
  3. package/dist/index.d.ts +29 -6
  4. package/dist/index.js +1 -1
  5. package/dist/runtime/compat/agent-harness-compat-runner.js +1 -1
  6. package/dist/runtime/compat/json.js +1 -1
  7. package/dist/runtime/compat/presentation.js +1 -1
  8. package/dist/runtime/compat/prompts.js +1 -1
  9. package/dist/runtime/model/ollama.js +1 -1
  10. package/dist/runtime/skills/skill-metadata.js +1 -1
  11. package/dist/workspace/compile.js +1 -1
  12. package/package.json +14 -10
  13. package/packages/adapter-deepagents/dist/src/adapter.d.ts +1 -0
  14. package/packages/adapter-deepagents/dist/src/adapter.js +1 -1
  15. package/packages/adapter-deepagents/dist/src/index.d.ts +1 -0
  16. package/packages/adapter-deepagents/dist/src/index.js +1 -1
  17. package/packages/adapter-deepagents/dist/src/internal/builtin-args.d.ts +4 -0
  18. package/packages/adapter-deepagents/dist/src/internal/builtin-args.js +1 -0
  19. package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.d.ts +39 -0
  20. package/packages/adapter-deepagents/dist/src/internal/builtin-tool-policy.js +1 -0
  21. package/packages/adapter-deepagents/dist/src/internal/gateway-tools.d.ts +32 -0
  22. package/packages/adapter-deepagents/dist/src/internal/gateway-tools.js +1 -0
  23. package/packages/adapter-deepagents/dist/src/internal/messages.js +1 -0
  24. package/packages/adapter-deepagents/dist/src/internal/raw-tool-call-parser.d.ts +12 -0
  25. package/packages/adapter-deepagents/dist/src/internal/raw-tool-call-parser.js +1 -0
  26. package/packages/adapter-deepagents/dist/src/internal/skill-file-policy.d.ts +10 -0
  27. package/packages/adapter-deepagents/dist/src/internal/skill-file-policy.js +1 -0
  28. package/packages/adapter-deepagents/dist/src/internal/stream-events.js +1 -0
  29. package/packages/adapter-deepagents/dist/src/internal/tool-repeat-visibility.d.ts +4 -0
  30. package/packages/adapter-deepagents/dist/src/internal/tool-repeat-visibility.js +1 -0
  31. package/packages/adapter-deepagents/dist/src/internal/trace-projection.d.ts +16 -0
  32. package/packages/adapter-deepagents/dist/src/internal/trace-projection.js +1 -0
  33. package/packages/adapter-deepagents/dist/src/memory.d.ts +5 -0
  34. package/packages/adapter-deepagents/dist/src/memory.js +1 -0
  35. package/packages/adapter-deepagents/dist/src/model-providers.d.ts +4 -0
  36. package/packages/adapter-deepagents/dist/src/model-providers.js +1 -0
  37. package/packages/adapter-deepagents/dist/src/retry-policy.js +1 -1
  38. package/packages/adapter-deepagents/dist/src/types.d.ts +7 -1
  39. package/packages/adapter-deepagents/package.json +1 -0
  40. package/packages/adapter-langgraph/dist/src/graph.d.ts +3 -0
  41. package/packages/adapter-langgraph/dist/src/graph.js +1 -0
  42. package/packages/adapter-langgraph/dist/src/index.d.ts +8 -0
  43. package/packages/adapter-langgraph/dist/src/index.js +1 -0
  44. package/packages/adapter-langgraph/dist/src/runtime.d.ts +3 -0
  45. package/packages/adapter-langgraph/dist/src/runtime.js +1 -0
  46. package/packages/adapter-langgraph/dist/src/skill-providers.d.ts +29 -0
  47. package/packages/adapter-langgraph/dist/src/skill-providers.js +1 -0
  48. package/packages/adapter-langgraph/dist/src/types.d.ts +60 -0
  49. package/packages/adapter-langgraph/dist/src/types.js +1 -0
  50. package/packages/adapter-langgraph/package.json +16 -0
  51. package/packages/cli/dist/src/args.d.ts +25 -0
  52. package/packages/cli/dist/src/args.js +1 -0
  53. package/packages/cli/dist/src/cli.js +1 -1
  54. package/packages/cli/dist/src/event-view.d.ts +9 -0
  55. package/packages/cli/dist/src/event-view.js +1 -0
  56. package/packages/cli/dist/src/index.d.ts +3 -0
  57. package/packages/cli/dist/src/index.js +1 -1
  58. package/packages/cli/dist/src/langgraph-env.d.ts +5 -0
  59. package/packages/cli/dist/src/langgraph-env.js +1 -0
  60. package/packages/cli/dist/src/langgraph-official.d.ts +13 -0
  61. package/packages/cli/dist/src/langgraph-official.js +1 -0
  62. package/packages/cli/dist/src/memory/lifecycle.d.ts +2 -0
  63. package/packages/cli/dist/src/memory/lifecycle.js +1 -0
  64. package/packages/cli/dist/src/memory/providers.d.ts +3 -0
  65. package/packages/cli/dist/src/memory/providers.js +1 -0
  66. package/packages/cli/dist/src/output.d.ts +8 -0
  67. package/packages/cli/dist/src/output.js +1 -0
  68. package/packages/cli/dist/src/server.d.ts +5 -0
  69. package/packages/cli/dist/src/server.js +1 -0
  70. package/packages/cli/package.json +3 -0
  71. package/packages/core/dist/evaluations/index.d.ts +18 -0
  72. package/packages/core/dist/evaluations/index.js +1 -0
  73. package/packages/core/dist/execution-contract.d.ts +1 -0
  74. package/packages/core/dist/execution-contract.js +1 -1
  75. package/packages/core/dist/index.d.ts +8 -4
  76. package/packages/core/dist/index.js +1 -1
  77. package/packages/core/dist/memory-plugins/maintenance.d.ts +42 -0
  78. package/packages/core/dist/memory-plugins/maintenance.js +1 -0
  79. package/packages/core/dist/memory-plugins/shared.d.ts +8 -0
  80. package/packages/core/dist/memory-plugins/shared.js +1 -0
  81. package/packages/core/dist/memory-plugins.d.ts +5 -48
  82. package/packages/core/dist/memory-plugins.js +1 -1
  83. package/packages/core/dist/recovery/tool-call.d.ts +28 -0
  84. package/packages/core/dist/recovery/tool-call.js +1 -0
  85. package/packages/core/dist/runtime/completion.d.ts +17 -0
  86. package/packages/core/dist/runtime/completion.js +1 -0
  87. package/packages/core/dist/runtime/direct-tool-call.d.ts +10 -0
  88. package/packages/core/dist/runtime/direct-tool-call.js +1 -0
  89. package/packages/core/dist/runtime/events.d.ts +204 -0
  90. package/packages/core/dist/runtime/events.js +1 -0
  91. package/packages/core/dist/runtime/memory.d.ts +23 -0
  92. package/packages/core/dist/runtime/memory.js +1 -0
  93. package/packages/core/dist/{artifacts.d.ts → runtime/persistence/artifacts.d.ts} +1 -1
  94. package/packages/core/dist/runtime/persistence/artifacts.js +1 -0
  95. package/packages/core/dist/{inspection.d.ts → runtime/persistence/inspection.d.ts} +1 -1
  96. package/packages/core/dist/runtime/persistence/inspection.js +1 -0
  97. package/packages/core/dist/{queue.d.ts → runtime/persistence/queue.d.ts} +1 -1
  98. package/packages/core/dist/runtime/persistence/queue.js +1 -0
  99. package/packages/core/dist/{stores.d.ts → runtime/persistence/stores.d.ts} +1 -1
  100. package/packages/core/dist/runtime/persistence/stores.js +1 -0
  101. package/packages/core/dist/runtime/progress-narration.d.ts +33 -0
  102. package/packages/core/dist/runtime/progress-narration.js +1 -0
  103. package/packages/core/dist/runtime/tool-gateway.d.ts +40 -0
  104. package/packages/core/dist/runtime/tool-gateway.js +1 -0
  105. package/packages/core/dist/runtime/types.d.ts +168 -0
  106. package/packages/core/dist/runtime/types.js +1 -0
  107. package/packages/core/dist/runtime.d.ts +7 -3
  108. package/packages/core/dist/runtime.js +1 -1
  109. package/packages/core/dist/spec-driven/config.d.ts +4 -0
  110. package/packages/core/dist/spec-driven/config.js +1 -0
  111. package/packages/core/dist/spec-driven/events.d.ts +11 -0
  112. package/packages/core/dist/spec-driven/events.js +1 -0
  113. package/packages/core/dist/spec-driven/index.d.ts +4 -0
  114. package/packages/core/dist/spec-driven/index.js +1 -0
  115. package/packages/core/dist/spec-driven/lifecycle.d.ts +11 -0
  116. package/packages/core/dist/spec-driven/lifecycle.js +1 -0
  117. package/packages/core/dist/spec-driven/types.d.ts +38 -0
  118. package/packages/core/dist/spec-driven/types.js +1 -0
  119. package/packages/core/dist/trace.d.ts +1 -1
  120. package/packages/core/dist/trace.js +1 -1
  121. package/packages/core/dist/types.d.ts +31 -426
  122. package/packages/core/dist/workflows/index.d.ts +70 -0
  123. package/packages/core/dist/workflows/index.js +1 -0
  124. package/packages/core/dist/workflows/runtime.d.ts +12 -0
  125. package/packages/core/dist/workflows/runtime.js +1 -0
  126. package/packages/core/dist/workspace/types.d.ts +101 -0
  127. package/packages/core/dist/workspace/types.js +1 -0
  128. package/packages/governance/dist/src/skill-candidates.js +1 -1
  129. package/packages/governance/dist/src/types.d.ts +1 -1
  130. package/packages/memory/dist/src/langmem-service.js +1 -1
  131. package/packages/memory/dist/src/maintenance.js +1 -1
  132. package/packages/memory/dist/src/policy.js +1 -1
  133. package/packages/memory/dist/src/provider.js +1 -1
  134. package/packages/memory/dist/src/store.js +1 -1
  135. package/packages/protocols/dist/src/http-server.js +1 -1
  136. package/packages/protocols/dist/src/in-process-client.js +1 -1
  137. package/packages/protocols/dist/src/openai-compatible.js +1 -1
  138. package/packages/protocols/dist/src/openai-payload.d.ts +74 -0
  139. package/packages/protocols/dist/src/openai-payload.js +1 -0
  140. package/packages/protocols/dist/src/openai-stream.d.ts +39 -0
  141. package/packages/protocols/dist/src/openai-stream.js +1 -0
  142. package/packages/tool-gateway/dist/src/argument-guard.d.ts +2 -1
  143. package/packages/tool-gateway/dist/src/argument-guard.js +1 -1
  144. package/packages/tool-gateway/dist/src/in-memory.js +1 -1
  145. package/packages/tool-gateway/dist/src/module-loader.js +1 -1
  146. package/packages/tool-gateway/dist/src/schema-validation.d.ts +3 -0
  147. package/packages/tool-gateway/dist/src/schema-validation.js +1 -0
  148. package/packages/tool-gateway/dist/src/types.d.ts +3 -0
  149. package/packages/tool-gateway/package.json +1 -1
  150. package/packages/workspace-yaml/dist/discovery.d.ts +4 -0
  151. package/packages/workspace-yaml/dist/discovery.js +1 -0
  152. package/packages/workspace-yaml/dist/documents.d.ts +16 -0
  153. package/packages/workspace-yaml/dist/documents.js +1 -0
  154. package/packages/workspace-yaml/dist/evaluations.d.ts +9 -0
  155. package/packages/workspace-yaml/dist/evaluations.js +1 -0
  156. package/packages/workspace-yaml/dist/loader.js +1 -1
  157. package/packages/workspace-yaml/dist/workflows.d.ts +16 -0
  158. package/packages/workspace-yaml/dist/workflows.js +1 -0
  159. package/packages/adapter-deepagents/dist/src/builtin-tool-policy.d.ts +0 -18
  160. package/packages/adapter-deepagents/dist/src/builtin-tool-policy.js +0 -1
  161. package/packages/adapter-deepagents/dist/src/messages.js +0 -1
  162. package/packages/adapter-deepagents/dist/src/stream-events.js +0 -1
  163. package/packages/core/dist/artifacts.js +0 -1
  164. package/packages/core/dist/inspection.js +0 -1
  165. package/packages/core/dist/queue.js +0 -1
  166. package/packages/core/dist/stores.js +0 -1
  167. /package/packages/adapter-deepagents/dist/src/{messages.d.ts → internal/messages.d.ts} +0 -0
  168. /package/packages/adapter-deepagents/dist/src/{stream-events.d.ts → internal/stream-events.d.ts} +0 -0
@@ -1,398 +1,18 @@
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;
1
+ import type { MemoryProvider, MemoryRecord, RuntimeMemoryStore } from "@stable-harness/memory";
2
+ import type { ApprovalQueue } from "@stable-harness/governance";
3
+ import type { RuntimeWorkflowAdapter, RuntimeWorkflowRequest, WorkspaceWorkflow } from "./workflows/index.js";
4
+ import type { SpecDrivenWorkflowState } from "./spec-driven/index.js";
5
+ import type { RuntimeEvent, RuntimeEventListener, RuntimeEmit } from "./runtime/events.js";
6
+ import type { RuntimeArtifact, RuntimeOutput, RuntimeRecordState, RuntimeRequest, RuntimeResponse, RuntimeRunFilter, RuntimeRunRecord } from "./runtime/types.js";
7
+ import type { RuntimeToolGateway } from "./runtime/tool-gateway.js";
8
+ import type { CompiledWorkspace, WorkspaceAgent, WorkspaceRuntimePolicy } from "./workspace/types.js";
9
+ export type { RuntimeEvent, RuntimeMemoryHook, RuntimeEventListener, RuntimeEmit } from "./runtime/events.js";
10
+ export type { RuntimeProgressNarrationOptions, RuntimeProgressNarrationProvider } from "./runtime/progress-narration.js";
11
+ export type { RuntimeArtifact, RuntimeArtifactFilter, RuntimeArtifactInput, RuntimeArtifactRecord, RuntimeArtifactStore, RuntimeCancelIntentInput, RuntimeHeartbeatInput, RuntimeMemoryCandidateInput, RuntimeOutput, RuntimeQueueClaimInput, RuntimeQueueRecord, RuntimeQueueStore, RuntimeRecoveryIntent, RuntimeRecordState, RuntimeRequest, RuntimeRequestControlRecord, RuntimeRequestMemory, RuntimeResponse, RuntimeRunFilter, RuntimeRunRecord, RuntimeStore, RuntimeStoreRunPatch, RuntimeStuckRequestInput, } from "./runtime/types.js";
12
+ export type { CompiledWorkspace, WorkspaceAdapterPolicy, WorkspaceAgent, WorkspaceMemory, WorkspaceModel, WorkspaceRetryPolicy, WorkspaceRetryReason, WorkspaceRetryTargetPolicy, WorkspaceRuntimePolicy, WorkspaceSkill, WorkspaceTool, WorkspaceToolRetryPolicy, } from "./workspace/types.js";
13
+ export type { WorkspaceEvaluation, WorkspaceEvaluationCase, } from "./evaluations/index.js";
14
+ export type { SpecDrivenPhaseId, SpecDrivenPhaseRecord, SpecDrivenPhaseStatus, SpecDrivenPhaseTransition, SpecDrivenWorkflowState, WorkspaceSpecDrivenPhase, WorkspaceSpecDrivenWorkflowPolicy, } from "./spec-driven/index.js";
15
+ export type { RuntimeToolCallRequest, RuntimeToolGateway, RuntimeToolGatewayContext, RuntimeToolRepairModel, RuntimeToolGatewayTool, } from "./runtime/tool-gateway.js";
396
16
  export type RuntimeAdapterContext = {
397
17
  workspace: CompiledWorkspace;
398
18
  agent: WorkspaceAgent;
@@ -402,6 +22,7 @@ export type RuntimeAdapterContext = {
402
22
  memory?: RuntimeMemoryContext;
403
23
  pluginMemories?: RuntimeMemoryContext[];
404
24
  toolGateway?: RuntimeToolGateway;
25
+ requestState?: Map<string, unknown>;
405
26
  emit: RuntimeEmit;
406
27
  };
407
28
  export type RuntimeMemoryContext = {
@@ -415,6 +36,7 @@ export type RuntimeAdapter = {
415
36
  canRun(agent: WorkspaceAgent): boolean;
416
37
  run(input: RuntimeAdapterContext): Promise<RuntimeAdapterResult>;
417
38
  };
39
+ export type { RuntimeWorkflowAdapter, RuntimeWorkflowRequest };
418
40
  export type RuntimeMemoryServices = {
419
41
  store: RuntimeMemoryStore;
420
42
  providers?: MemoryProvider[];
@@ -425,44 +47,24 @@ export type RuntimeGovernanceServices = {
425
47
  export type RuntimeToolServices = {
426
48
  gateway?: RuntimeToolGateway;
427
49
  };
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
50
  export type RuntimeInspectionSnapshot = {
460
51
  workspaceRoot: string;
461
52
  agents: string[];
53
+ workflows: string[];
54
+ specDrivenWorkflow?: RuntimeSpecDrivenWorkflowInspection;
55
+ evaluations: string[];
56
+ defaultWorkflowId?: string;
57
+ workflowRoutes: string[];
462
58
  models: string[];
463
59
  tools: string[];
464
60
  runs: RuntimeRunRecord[];
465
61
  };
62
+ export type RuntimeSpecDrivenWorkflowInspection = {
63
+ enabled: boolean;
64
+ artifactsDir: string;
65
+ constitution?: string;
66
+ phases: string[];
67
+ };
466
68
  export type RuntimeRequestSummary = {
467
69
  requestId: string;
468
70
  sessionId: string;
@@ -504,6 +106,7 @@ export type RuntimeRequestInspection = {
504
106
  metadata?: Record<string, unknown>;
505
107
  artifacts: RuntimeArtifact[];
506
108
  runtimeSnapshot: RuntimeBindingSnapshot;
109
+ specDrivenWorkflow?: SpecDrivenWorkflowState;
507
110
  timeline: RuntimeTimelineItem[];
508
111
  };
509
112
  export type RuntimeClient = {
@@ -514,6 +117,8 @@ export type RuntimeEventSource = {
514
117
  };
515
118
  export type RuntimeInspector = {
516
119
  inspect(): RuntimeInspectionSnapshot;
120
+ getRuntimePolicy(): WorkspaceRuntimePolicy;
121
+ getWorkflow(workflowId: string): WorkspaceWorkflow | undefined;
517
122
  getRun(requestId: string): RuntimeRunRecord | undefined;
518
123
  listRequests(filter?: RuntimeRunFilter): RuntimeRequestSummary[];
519
124
  listSessions(): RuntimeSessionSummary[];
@@ -0,0 +1,70 @@
1
+ import type { CompiledWorkspace, RuntimeOutput, RuntimeToolGateway } from "../types.js";
2
+ export type WorkspaceWorkflow = {
3
+ id: string;
4
+ description?: string;
5
+ sourcePath?: string;
6
+ adapter?: string;
7
+ entry?: string;
8
+ state?: WorkspaceWorkflowState;
9
+ nodes: WorkspaceWorkflowNode[];
10
+ edges: WorkspaceWorkflowEdge[];
11
+ policies?: Record<string, unknown>;
12
+ config?: Record<string, unknown>;
13
+ };
14
+ export type WorkspaceWorkflowState = {
15
+ schema?: string;
16
+ config?: Record<string, unknown>;
17
+ };
18
+ export type WorkspaceWorkflowNode = {
19
+ id: string;
20
+ use: string;
21
+ type?: string;
22
+ config?: Record<string, unknown>;
23
+ };
24
+ export type WorkspaceWorkflowEdge = {
25
+ from: string;
26
+ to: string;
27
+ condition?: string;
28
+ };
29
+ export type WorkspaceWorkflowRoutingPolicy = {
30
+ defaultWorkflowId?: string;
31
+ routes?: WorkspaceWorkflowRoute[];
32
+ };
33
+ export type WorkspaceWorkflowRoute = {
34
+ id: string;
35
+ workflowId: string;
36
+ description?: string;
37
+ metadata?: Record<string, unknown>;
38
+ };
39
+ export type RuntimeWorkflowRequest = {
40
+ workflowId?: string;
41
+ routeId?: string;
42
+ input?: unknown;
43
+ metadata?: Record<string, unknown>;
44
+ };
45
+ export type RuntimeWorkflowAdapterInput = {
46
+ workspace: CompiledWorkspace;
47
+ workflow: WorkspaceWorkflow;
48
+ request: RuntimeWorkflowRequest;
49
+ requestId: string;
50
+ sessionId: string;
51
+ toolGateway?: RuntimeToolGateway;
52
+ emit: (event: unknown) => void;
53
+ };
54
+ export type RuntimeWorkflowAdapter = {
55
+ name: string;
56
+ run(input: RuntimeWorkflowAdapterInput): Promise<string | RuntimeOutput>;
57
+ };
58
+ export type WorkflowPlan = {
59
+ workflowId: string;
60
+ adapter?: string;
61
+ entry: string;
62
+ nodes: WorkspaceWorkflowNode[];
63
+ edges: WorkspaceWorkflowEdge[];
64
+ terminalNodes: string[];
65
+ unreachableNodes: string[];
66
+ cycles: string[][];
67
+ };
68
+ export declare function compileWorkflowPlan(workflow: WorkspaceWorkflow): WorkflowPlan;
69
+ export declare function renderWorkflowMermaid(workflow: WorkspaceWorkflow): string;
70
+ export declare function renderAgentMermaid(workspace: CompiledWorkspace, agentId: string): string;
@@ -0,0 +1 @@
1
+ export function compileWorkflowPlan(e){const n=e.entry??e.nodes[0]?.id;if(!n)throw new Error(`Workflow ${e.id} has no entry node`);const t=function buildAdjacency(e){const n=new Map(e.nodes.map(e=>[e.id,[]]));for(const t of e.edges)n.get(t.from)?.push(t.to);return n}(e),o=function collectReachable(e,n){const t=new Set,o=[e];for(;o.length>0;){const e=o.pop();t.has(e)||(t.add(e),o.push(...n.get(e)??[]))}return t}(n,t),a=function findCycles(e,n){const t=[];for(const o of e)collectCycles(o,o,n,[],t);return function dedupeCycles(e){const n=new Set;return e.filter(e=>{const t=function canonicalCycleKey(e){const n=e.slice(0,-1);return n.map((e,t)=>[...n.slice(t),...n.slice(0,t)].join("|")).sort()[0]??""}(e);return!n.has(t)&&(n.add(t),!0)})}(t)}(e.nodes.map(e=>e.id),t);return{workflowId:e.id,...e.adapter?{adapter:e.adapter}:{},entry:n,nodes:e.nodes,edges:e.edges,terminalNodes:e.nodes.map(e=>e.id).filter(e=>0===(t.get(e)??[]).length),unreachableNodes:e.nodes.map(e=>e.id).filter(e=>!o.has(e)),cycles:a}}export function renderWorkflowMermaid(e){const n=["flowchart TD"];for(const t of e.nodes)n.push(` ${escapeId(t.id)}["${escapeLabel(`${t.id}\\n${t.use}`)}"]`);for(const t of e.edges){const e=t.condition?`|${escapeLabel(t.condition)}|`:"";n.push(` ${escapeId(t.from)} --\x3e${e} ${escapeId(t.to)}`)}return n.join("\n")}export function renderAgentMermaid(e,n){const t=e.agents.get(n);if(!t)throw new Error(`Agent is not defined: ${n}`);const o=function agentGraphNodes(e){return[...e.subagents.map(e=>agentGraphNode("agent",e)),...(e.skills??[]).map(e=>agentGraphNode("skill",e)),...e.tools.map(e=>agentGraphNode("tool",e))]}(t),a=["flowchart TD",` START_${escapeId(t.id)}([START])`,` END_${escapeId(t.id)}([END])`];for(const e of o)a.push(` ${e.diagramId}["${escapeLabel(`${e.id}\\n${e.label}`)}"]`);return 0===o.length?(a.push(` START_${escapeId(t.id)} --\x3e END_${escapeId(t.id)}`),a.join("\n")):[...a,...t.edges?.length?explicitAgentMermaidEdges(t,o):inventoryAgentMermaidEdges(t,o)].join("\n")}function agentGraphNode(e,n){return{id:n,diagramId:`${e}_${escapeId(n)}`,label:`${e}: ${n}`}}function explicitAgentMermaidEdges(e,n){const t=new Map(n.map(e=>[e.id,e.diagramId])),o=new Set((e.edges??[]).map(e=>e.to)),a=new Set((e.edges??[]).map(e=>e.from)),d=n.filter(e=>!o.has(e.id)).map(e=>e.diagramId),r=n.filter(e=>!a.has(e.id)).map(e=>e.diagramId);return[...d.map(n=>` START_${escapeId(e.id)} --\x3e ${escapeId(n)}`),...(e.edges??[]).flatMap(e=>function renderAgentEdge(e,n){const t=n.get(e.from),o=n.get(e.to);return t&&o?[` ${t} --\x3e${e.condition?`|${escapeLabel(e.condition)}|`:""} ${o}`]:[]}(e,t)),...r.map(n=>` ${escapeId(n)} --\x3e END_${escapeId(e.id)}`)]}function inventoryAgentMermaidEdges(e,n){return n.flatMap(n=>[` START_${escapeId(e.id)} -. available .-> ${n.diagramId}`,` ${n.diagramId} -.-> END_${escapeId(e.id)}`])}function collectCycles(e,n,t,o,a){const d=[...o,n];for(const r of t.get(n)??[])r===e?a.push([...d,e]):o.includes(r)||collectCycles(e,r,t,d,a)}function escapeId(e){return e.replace(/[^A-Za-z0-9_]/gu,"_")}function escapeLabel(e){return e.replace(/"/gu,'\\"')}
@@ -0,0 +1,12 @@
1
+ import type { CompiledWorkspace, RuntimeEvent, RuntimeOutput } from "../types.js";
2
+ import type { RuntimeWorkflowAdapter, RuntimeWorkflowAdapterInput, RuntimeWorkflowRequest } from "./index.js";
3
+ export declare function runWorkflowRequest(input: {
4
+ workspace: CompiledWorkspace;
5
+ adapters: RuntimeWorkflowAdapter[];
6
+ toolGateway?: RuntimeWorkflowAdapterInput["toolGateway"];
7
+ request: RuntimeWorkflowRequest;
8
+ requestId: string;
9
+ sessionId: string;
10
+ agentId: string;
11
+ emit: (event: RuntimeEvent) => void;
12
+ }): Promise<RuntimeOutput>;
@@ -0,0 +1 @@
1
+ export async function runWorkflowRequest(e){const o=function resolveWorkflow(e,o){const r=o.routeId?e.runtime.workflowRouting?.routes?.find(e=>e.id===o.routeId):void 0;if(o.routeId&&!r)throw new Error(`Workflow route is not defined: ${o.routeId}`);const t=o.workflowId??r?.workflowId??e.runtime.workflowRouting?.defaultWorkflowId;if(!t)throw new Error("Workflow request requires workflowId, routeId, or runtime.workflowRouting.defaultWorkflowId");const n=e.workflows.get(t);if(!n)throw new Error(`Workflow is not defined: ${t}`);return n}(e.workspace,e.request),r=function resolveWorkflowAdapter(e,o){const r=o?e.find(e=>e.name===o):e[0];if(!r)throw new Error("No workflow adapter is configured"+(o?` for ${o}`:""));return r}(e.adapters,o.adapter);e.emit({type:"runtime.workflow.started",requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,adapter:r.name,workflowId:o.id});const t=await r.run({workspace:e.workspace,workflow:o,request:e.request,requestId:e.requestId,sessionId:e.sessionId,toolGateway:e.toolGateway,emit:o=>e.emit({type:"runtime.adapter.event",requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,event:o})});return e.emit({type:"runtime.workflow.completed",requestId:e.requestId,sessionId:e.sessionId,agentId:e.agentId,adapter:r.name,workflowId:o.id}),"string"==typeof t?{text:t}:t}
@@ -0,0 +1,101 @@
1
+ import type { WorkspaceEvaluation } from "../evaluations/index.js";
2
+ import type { WorkspaceSpecDrivenWorkflowPolicy } from "../spec-driven/index.js";
3
+ import type { WorkspaceWorkflow, WorkspaceWorkflowEdge, WorkspaceWorkflowRoutingPolicy } from "../workflows/index.js";
4
+ export type WorkspaceModel = {
5
+ id: string;
6
+ provider: string;
7
+ model: string;
8
+ config?: Record<string, unknown>;
9
+ };
10
+ export type WorkspaceTool = {
11
+ id: string;
12
+ description?: string;
13
+ schema?: unknown;
14
+ implementation?: string;
15
+ sourcePath?: string;
16
+ };
17
+ export type WorkspaceSkill = {
18
+ id: string;
19
+ path: string;
20
+ description?: string;
21
+ allowedTools: string[];
22
+ };
23
+ export type WorkspaceMemory = {
24
+ id: string;
25
+ provider: string;
26
+ profile?: string;
27
+ mode?: string;
28
+ enabled: boolean;
29
+ prompts?: {
30
+ semantic?: string;
31
+ episodic?: string;
32
+ procedural?: string;
33
+ };
34
+ config?: Record<string, unknown>;
35
+ };
36
+ export type WorkspaceAgent = {
37
+ id: string;
38
+ description?: string;
39
+ sourcePath?: string;
40
+ backend: string;
41
+ modelRef?: string;
42
+ systemPrompt?: string;
43
+ tools: string[];
44
+ skills?: string[];
45
+ memory?: unknown[];
46
+ subagents: string[];
47
+ edges?: WorkspaceWorkflowEdge[];
48
+ config: Record<string, unknown>;
49
+ };
50
+ export type WorkspaceRuntimePolicy = {
51
+ defaultAgentId: string;
52
+ workspaceId?: string;
53
+ profile?: string;
54
+ adapters?: WorkspaceAdapterPolicy[];
55
+ workflowRouting?: WorkspaceWorkflowRoutingPolicy;
56
+ specDrivenWorkflow?: WorkspaceSpecDrivenWorkflowPolicy;
57
+ approvals?: Record<string, unknown>;
58
+ recovery?: Record<string, unknown>;
59
+ retry?: WorkspaceRetryPolicy;
60
+ toolGateway?: Record<string, unknown>;
61
+ memory?: Record<string, unknown>;
62
+ protocols?: Record<string, unknown>;
63
+ progress?: Record<string, unknown>;
64
+ cli?: Record<string, unknown>;
65
+ responseLanguage?: Record<string, unknown>;
66
+ responsePresentation?: Record<string, unknown>;
67
+ };
68
+ export type WorkspaceAdapterPolicy = {
69
+ name: string;
70
+ enabled?: boolean;
71
+ config?: Record<string, unknown>;
72
+ };
73
+ export type WorkspaceRetryPolicy = {
74
+ model?: WorkspaceRetryTargetPolicy;
75
+ tools?: WorkspaceToolRetryPolicy;
76
+ };
77
+ export type WorkspaceRetryTargetPolicy = {
78
+ enabled?: boolean;
79
+ maxRetries?: number;
80
+ retryOn?: WorkspaceRetryReason[];
81
+ backoffFactor?: number;
82
+ initialDelayMs?: number;
83
+ maxDelayMs?: number;
84
+ jitter?: boolean;
85
+ onFailure?: "continue" | "error";
86
+ };
87
+ export type WorkspaceToolRetryPolicy = WorkspaceRetryTargetPolicy & {
88
+ tools?: string[];
89
+ };
90
+ export type WorkspaceRetryReason = "timeout" | "network" | "rateLimit" | "serverError";
91
+ export type CompiledWorkspace = {
92
+ root: string;
93
+ runtime: WorkspaceRuntimePolicy;
94
+ agents: Map<string, WorkspaceAgent>;
95
+ models: Map<string, WorkspaceModel>;
96
+ tools: Map<string, WorkspaceTool>;
97
+ skills: Map<string, WorkspaceSkill>;
98
+ memories: Map<string, WorkspaceMemory>;
99
+ workflows: Map<string, WorkspaceWorkflow>;
100
+ evaluations?: Map<string, WorkspaceEvaluation>;
101
+ };
@@ -0,0 +1 @@
1
+ export{};