@botbotgo/agent-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/dist/api.d.ts +22 -0
- package/dist/api.js +48 -0
- package/dist/config/direct.yaml +48 -0
- package/dist/config/embedding-model.yaml +30 -0
- package/dist/config/model.yaml +44 -0
- package/dist/config/orchestra.yaml +92 -0
- package/dist/config/runtime.yaml +47 -0
- package/dist/config/vector-store.yaml +26 -0
- package/dist/contracts/types.d.ts +359 -0
- package/dist/contracts/types.js +1 -0
- package/dist/extensions.d.ts +16 -0
- package/dist/extensions.js +251 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/persistence/file-store.d.ts +39 -0
- package/dist/persistence/file-store.js +282 -0
- package/dist/presentation.d.ts +4 -0
- package/dist/presentation.js +175 -0
- package/dist/runtime/agent-runtime-adapter.d.ts +33 -0
- package/dist/runtime/agent-runtime-adapter.js +445 -0
- package/dist/runtime/event-bus.d.ts +6 -0
- package/dist/runtime/event-bus.js +15 -0
- package/dist/runtime/file-checkpoint-saver.d.ts +20 -0
- package/dist/runtime/file-checkpoint-saver.js +91 -0
- package/dist/runtime/harness.d.ts +57 -0
- package/dist/runtime/harness.js +696 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.js +10 -0
- package/dist/runtime/inventory.d.ts +25 -0
- package/dist/runtime/inventory.js +62 -0
- package/dist/runtime/parsing/index.d.ts +2 -0
- package/dist/runtime/parsing/index.js +2 -0
- package/dist/runtime/parsing/output-parsing.d.ts +12 -0
- package/dist/runtime/parsing/output-parsing.js +424 -0
- package/dist/runtime/parsing/stream-event-parsing.d.ts +27 -0
- package/dist/runtime/parsing/stream-event-parsing.js +161 -0
- package/dist/runtime/policy-engine.d.ts +9 -0
- package/dist/runtime/policy-engine.js +23 -0
- package/dist/runtime/store.d.ts +50 -0
- package/dist/runtime/store.js +118 -0
- package/dist/runtime/support/embedding-models.d.ts +4 -0
- package/dist/runtime/support/embedding-models.js +33 -0
- package/dist/runtime/support/harness-support.d.ts +27 -0
- package/dist/runtime/support/harness-support.js +116 -0
- package/dist/runtime/support/index.d.ts +4 -0
- package/dist/runtime/support/index.js +4 -0
- package/dist/runtime/support/llamaindex.d.ts +24 -0
- package/dist/runtime/support/llamaindex.js +108 -0
- package/dist/runtime/support/runtime-factories.d.ts +3 -0
- package/dist/runtime/support/runtime-factories.js +39 -0
- package/dist/runtime/support/skill-metadata.d.ts +1 -0
- package/dist/runtime/support/skill-metadata.js +34 -0
- package/dist/runtime/support/vector-stores.d.ts +7 -0
- package/dist/runtime/support/vector-stores.js +130 -0
- package/dist/runtime/thread-memory-sync.d.ts +14 -0
- package/dist/runtime/thread-memory-sync.js +88 -0
- package/dist/runtime/tool-hitl.d.ts +5 -0
- package/dist/runtime/tool-hitl.js +108 -0
- package/dist/utils/fs.d.ts +6 -0
- package/dist/utils/fs.js +39 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +8 -0
- package/dist/vendor/builtins.d.ts +23 -0
- package/dist/vendor/builtins.js +103 -0
- package/dist/vendor/sources.d.ts +12 -0
- package/dist/vendor/sources.js +115 -0
- package/dist/workspace/agent-binding-compiler.d.ts +4 -0
- package/dist/workspace/agent-binding-compiler.js +181 -0
- package/dist/workspace/compile.d.ts +2 -0
- package/dist/workspace/compile.js +107 -0
- package/dist/workspace/index.d.ts +6 -0
- package/dist/workspace/index.js +6 -0
- package/dist/workspace/object-loader.d.ts +16 -0
- package/dist/workspace/object-loader.js +405 -0
- package/dist/workspace/resource-compilers.d.ts +13 -0
- package/dist/workspace/resource-compilers.js +182 -0
- package/dist/workspace/support/discovery.d.ts +5 -0
- package/dist/workspace/support/discovery.js +108 -0
- package/dist/workspace/support/index.d.ts +2 -0
- package/dist/workspace/support/index.js +2 -0
- package/dist/workspace/support/source-collectors.d.ts +3 -0
- package/dist/workspace/support/source-collectors.js +30 -0
- package/dist/workspace/support/workspace-ref-utils.d.ts +8 -0
- package/dist/workspace/support/workspace-ref-utils.js +50 -0
- package/dist/workspace/validate.d.ts +3 -0
- package/dist/workspace/validate.js +65 -0
- package/package.json +32 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
export type ExecutionMode = "deepagent" | "langchain-v1";
|
|
2
|
+
export declare const AUTO_AGENT_ID = "auto";
|
|
3
|
+
export type RunState = "running" | "waiting_for_approval" | "resuming" | "completed" | "failed";
|
|
4
|
+
export type ParsedAgentObject = {
|
|
5
|
+
id: string;
|
|
6
|
+
executionMode: ExecutionMode;
|
|
7
|
+
description: string;
|
|
8
|
+
modelRef: string;
|
|
9
|
+
runRoot?: string;
|
|
10
|
+
toolRefs: string[];
|
|
11
|
+
skillPathRefs: string[];
|
|
12
|
+
memorySources: string[];
|
|
13
|
+
subagentRefs: string[];
|
|
14
|
+
subagentPathRefs: string[];
|
|
15
|
+
langchainAgentConfig?: Record<string, unknown>;
|
|
16
|
+
deepAgentConfig?: Record<string, unknown>;
|
|
17
|
+
sourcePath: string;
|
|
18
|
+
};
|
|
19
|
+
export type WorkspaceObject = {
|
|
20
|
+
id: string;
|
|
21
|
+
kind: string;
|
|
22
|
+
sourcePath: string;
|
|
23
|
+
value: Record<string, unknown>;
|
|
24
|
+
};
|
|
25
|
+
export type ParsedModelObject = {
|
|
26
|
+
id: string;
|
|
27
|
+
provider: string;
|
|
28
|
+
model: string;
|
|
29
|
+
init: Record<string, unknown>;
|
|
30
|
+
clientRef?: string;
|
|
31
|
+
fallbacks: string[];
|
|
32
|
+
metadata?: Record<string, unknown>;
|
|
33
|
+
sourcePath: string;
|
|
34
|
+
};
|
|
35
|
+
export type ParsedEmbeddingModelObject = {
|
|
36
|
+
id: string;
|
|
37
|
+
provider: string;
|
|
38
|
+
model: string;
|
|
39
|
+
init: Record<string, unknown>;
|
|
40
|
+
clientRef?: string;
|
|
41
|
+
metadata?: Record<string, unknown>;
|
|
42
|
+
sourcePath: string;
|
|
43
|
+
};
|
|
44
|
+
export type ParsedVectorStoreObject = {
|
|
45
|
+
id: string;
|
|
46
|
+
kind: string;
|
|
47
|
+
url?: string;
|
|
48
|
+
authToken?: string;
|
|
49
|
+
table?: string;
|
|
50
|
+
column?: string;
|
|
51
|
+
embeddingModelRef?: string;
|
|
52
|
+
metadata?: Record<string, unknown>;
|
|
53
|
+
sourcePath: string;
|
|
54
|
+
};
|
|
55
|
+
export type ParsedToolObject = {
|
|
56
|
+
id: string;
|
|
57
|
+
type: string;
|
|
58
|
+
name: string;
|
|
59
|
+
description: string;
|
|
60
|
+
config?: Record<string, unknown>;
|
|
61
|
+
inputSchemaRef?: string;
|
|
62
|
+
backendOperation?: string;
|
|
63
|
+
mcpRef?: string;
|
|
64
|
+
bundleRefs: string[];
|
|
65
|
+
hitl?: {
|
|
66
|
+
enabled: boolean;
|
|
67
|
+
allow?: Array<"approve" | "edit" | "reject">;
|
|
68
|
+
};
|
|
69
|
+
sourcePath: string;
|
|
70
|
+
};
|
|
71
|
+
export type LangChainAgentParams = {
|
|
72
|
+
model: CompiledModel;
|
|
73
|
+
tools: CompiledTool[];
|
|
74
|
+
systemPrompt?: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
export type CompiledSubAgent = {
|
|
78
|
+
name: string;
|
|
79
|
+
description: string;
|
|
80
|
+
systemPrompt: string;
|
|
81
|
+
tools?: CompiledTool[];
|
|
82
|
+
model?: CompiledModel;
|
|
83
|
+
interruptOn?: Record<string, boolean | object>;
|
|
84
|
+
skills?: string[];
|
|
85
|
+
memory?: string[];
|
|
86
|
+
};
|
|
87
|
+
export type DeepAgentParams = {
|
|
88
|
+
model: CompiledModel;
|
|
89
|
+
tools: CompiledTool[];
|
|
90
|
+
systemPrompt?: string;
|
|
91
|
+
description: string;
|
|
92
|
+
subagents: CompiledSubAgent[];
|
|
93
|
+
interruptOn?: Record<string, boolean | object>;
|
|
94
|
+
backend?: Record<string, unknown>;
|
|
95
|
+
store?: Record<string, unknown>;
|
|
96
|
+
name: string;
|
|
97
|
+
memory: string[];
|
|
98
|
+
skills: string[];
|
|
99
|
+
};
|
|
100
|
+
export type CompiledModel = {
|
|
101
|
+
id: string;
|
|
102
|
+
provider: string;
|
|
103
|
+
model: string;
|
|
104
|
+
init: Record<string, unknown>;
|
|
105
|
+
clientRef?: string;
|
|
106
|
+
fallbacks: string[];
|
|
107
|
+
runtimeValue: string;
|
|
108
|
+
};
|
|
109
|
+
export type CompiledEmbeddingModel = {
|
|
110
|
+
id: string;
|
|
111
|
+
provider: string;
|
|
112
|
+
model: string;
|
|
113
|
+
init: Record<string, unknown>;
|
|
114
|
+
clientRef?: string;
|
|
115
|
+
runtimeValue: string;
|
|
116
|
+
};
|
|
117
|
+
export type CompiledVectorStore = {
|
|
118
|
+
id: string;
|
|
119
|
+
kind: string;
|
|
120
|
+
url?: string;
|
|
121
|
+
authToken?: string;
|
|
122
|
+
table?: string;
|
|
123
|
+
column?: string;
|
|
124
|
+
embeddingModelRef?: string;
|
|
125
|
+
runtimeValue: string;
|
|
126
|
+
};
|
|
127
|
+
export type CompiledTool = {
|
|
128
|
+
id: string;
|
|
129
|
+
type: string;
|
|
130
|
+
name: string;
|
|
131
|
+
description: string;
|
|
132
|
+
config?: Record<string, unknown>;
|
|
133
|
+
inputSchemaRef?: string;
|
|
134
|
+
backendOperation?: string;
|
|
135
|
+
mcpRef?: string;
|
|
136
|
+
bundleRefs: string[];
|
|
137
|
+
hitl?: {
|
|
138
|
+
enabled: boolean;
|
|
139
|
+
allow: Array<"approve" | "edit" | "reject">;
|
|
140
|
+
};
|
|
141
|
+
runtimeValue: {
|
|
142
|
+
name: string;
|
|
143
|
+
description: string;
|
|
144
|
+
type: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export type CompiledAgentBinding = {
|
|
148
|
+
agent: ParsedAgentObject;
|
|
149
|
+
langchainAgentParams?: LangChainAgentParams;
|
|
150
|
+
directAgentParams?: LangChainAgentParams;
|
|
151
|
+
deepAgentParams?: DeepAgentParams;
|
|
152
|
+
harnessRuntime: {
|
|
153
|
+
runRoot: string;
|
|
154
|
+
hostFacing: boolean;
|
|
155
|
+
checkpointer?: Record<string, unknown>;
|
|
156
|
+
store?: Record<string, unknown>;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
export type WorkspaceBundle = {
|
|
160
|
+
workspaceRoot: string;
|
|
161
|
+
builtinSources: string[];
|
|
162
|
+
refs: Map<string, WorkspaceObject | ParsedAgentObject>;
|
|
163
|
+
models: Map<string, ParsedModelObject>;
|
|
164
|
+
embeddings: Map<string, ParsedEmbeddingModelObject>;
|
|
165
|
+
vectorStores: Map<string, ParsedVectorStoreObject>;
|
|
166
|
+
tools: Map<string, ParsedToolObject>;
|
|
167
|
+
agents: Map<string, ParsedAgentObject>;
|
|
168
|
+
bindings: Map<string, CompiledAgentBinding>;
|
|
169
|
+
};
|
|
170
|
+
export type WorkspaceLoadOptions = {
|
|
171
|
+
overlayRoots?: string[];
|
|
172
|
+
builtinSources?: string[];
|
|
173
|
+
};
|
|
174
|
+
export type SessionRecord = {
|
|
175
|
+
agentId: string;
|
|
176
|
+
threadId: string;
|
|
177
|
+
latestRunId: string;
|
|
178
|
+
createdAt: string;
|
|
179
|
+
updatedAt: string;
|
|
180
|
+
status: RunState;
|
|
181
|
+
};
|
|
182
|
+
export type HarnessEvent = {
|
|
183
|
+
eventId: string;
|
|
184
|
+
eventType: string;
|
|
185
|
+
timestamp: string;
|
|
186
|
+
threadId: string;
|
|
187
|
+
runId: string;
|
|
188
|
+
sequence: number;
|
|
189
|
+
source: "runtime" | "policy" | "surface" | "worker";
|
|
190
|
+
payload: Record<string, unknown>;
|
|
191
|
+
};
|
|
192
|
+
export type RunResult = {
|
|
193
|
+
threadId: string;
|
|
194
|
+
runId: string;
|
|
195
|
+
state: RunState;
|
|
196
|
+
output: string;
|
|
197
|
+
interruptContent?: string;
|
|
198
|
+
agentId?: string;
|
|
199
|
+
approvalId?: string;
|
|
200
|
+
pendingActionId?: string;
|
|
201
|
+
delegationId?: string;
|
|
202
|
+
};
|
|
203
|
+
export type RunOptions = {
|
|
204
|
+
agentId?: string;
|
|
205
|
+
input: string;
|
|
206
|
+
threadId?: string;
|
|
207
|
+
};
|
|
208
|
+
export type HarnessStreamItem = {
|
|
209
|
+
type: "event";
|
|
210
|
+
event: HarnessEvent;
|
|
211
|
+
} | {
|
|
212
|
+
type: "content";
|
|
213
|
+
threadId: string;
|
|
214
|
+
runId: string;
|
|
215
|
+
agentId: string;
|
|
216
|
+
content: string;
|
|
217
|
+
} | {
|
|
218
|
+
type: "reasoning";
|
|
219
|
+
threadId: string;
|
|
220
|
+
runId: string;
|
|
221
|
+
agentId: string;
|
|
222
|
+
content: string;
|
|
223
|
+
} | {
|
|
224
|
+
type: "step";
|
|
225
|
+
threadId: string;
|
|
226
|
+
runId: string;
|
|
227
|
+
agentId: string;
|
|
228
|
+
content: string;
|
|
229
|
+
} | {
|
|
230
|
+
type: "tool-result";
|
|
231
|
+
threadId: string;
|
|
232
|
+
runId: string;
|
|
233
|
+
agentId: string;
|
|
234
|
+
toolName: string;
|
|
235
|
+
output: unknown;
|
|
236
|
+
};
|
|
237
|
+
export type TranscriptMessage = {
|
|
238
|
+
role: "user" | "assistant";
|
|
239
|
+
content: string;
|
|
240
|
+
runId: string;
|
|
241
|
+
createdAt: string;
|
|
242
|
+
};
|
|
243
|
+
export type ResumeOptions = {
|
|
244
|
+
threadId?: string;
|
|
245
|
+
runId?: string;
|
|
246
|
+
approvalId?: string;
|
|
247
|
+
decision?: "approve" | "edit" | "reject";
|
|
248
|
+
editedInput?: Record<string, unknown>;
|
|
249
|
+
};
|
|
250
|
+
export type RestartConversationOptions = {
|
|
251
|
+
threadId: string;
|
|
252
|
+
mode: "restart-in-thread" | "restart-new-thread";
|
|
253
|
+
input: string;
|
|
254
|
+
};
|
|
255
|
+
export type ApprovalRecord = {
|
|
256
|
+
approvalId: string;
|
|
257
|
+
pendingActionId: string;
|
|
258
|
+
threadId: string;
|
|
259
|
+
runId: string;
|
|
260
|
+
toolCallId: string;
|
|
261
|
+
toolName: string;
|
|
262
|
+
status: "pending" | "approved" | "edited" | "rejected" | "expired";
|
|
263
|
+
requestedAt: string;
|
|
264
|
+
resolvedAt: string | null;
|
|
265
|
+
allowedDecisions: Array<"approve" | "edit" | "reject">;
|
|
266
|
+
inputPreview: Record<string, unknown>;
|
|
267
|
+
checkpointRef: string;
|
|
268
|
+
eventRefs: string[];
|
|
269
|
+
};
|
|
270
|
+
export type DelegationRecord = {
|
|
271
|
+
delegationId: string;
|
|
272
|
+
threadId: string;
|
|
273
|
+
runId: string;
|
|
274
|
+
parentRunId: string;
|
|
275
|
+
specialistAgentId: string;
|
|
276
|
+
specialistName: string;
|
|
277
|
+
specialistDescription: string;
|
|
278
|
+
status: "requested" | "running" | "completed" | "failed" | "cancelled" | "resumable";
|
|
279
|
+
requestedAt: string;
|
|
280
|
+
startedAt: string | null;
|
|
281
|
+
completedAt: string | null;
|
|
282
|
+
checkpointRef: string | null;
|
|
283
|
+
inputArtifactRef: string | null;
|
|
284
|
+
outputArtifactRef: string | null;
|
|
285
|
+
eventRefs: string[];
|
|
286
|
+
};
|
|
287
|
+
export type ArtifactRecord = {
|
|
288
|
+
artifactId: string;
|
|
289
|
+
kind: string;
|
|
290
|
+
path: string;
|
|
291
|
+
createdAt: string;
|
|
292
|
+
};
|
|
293
|
+
export type ArtifactListing = {
|
|
294
|
+
threadId: string;
|
|
295
|
+
runId: string;
|
|
296
|
+
items: ArtifactRecord[];
|
|
297
|
+
};
|
|
298
|
+
export type RuntimeToolResolver = (toolIds: string[], binding?: CompiledAgentBinding) => unknown[];
|
|
299
|
+
export type RuntimeModelResolver = (modelId: string) => unknown;
|
|
300
|
+
export type RuntimeEmbeddingModelResolver = (embeddingModelId: string) => unknown;
|
|
301
|
+
export type RuntimeVectorStoreResolver = (vectorStoreId: string) => unknown;
|
|
302
|
+
export type RuntimeMiddlewareResolver = (binding: CompiledAgentBinding) => unknown[];
|
|
303
|
+
export type RuntimeCheckpointerResolver = (binding: CompiledAgentBinding) => unknown;
|
|
304
|
+
export type RuntimeStoreResolver = (binding: CompiledAgentBinding) => unknown;
|
|
305
|
+
export type RuntimeBackendResolver = (binding: CompiledAgentBinding) => unknown;
|
|
306
|
+
export type RuntimeAdapterOptions = {
|
|
307
|
+
toolResolver?: RuntimeToolResolver;
|
|
308
|
+
modelResolver?: RuntimeModelResolver;
|
|
309
|
+
embeddingModelResolver?: RuntimeEmbeddingModelResolver;
|
|
310
|
+
vectorStoreResolver?: RuntimeVectorStoreResolver;
|
|
311
|
+
middlewareResolver?: RuntimeMiddlewareResolver;
|
|
312
|
+
checkpointerResolver?: RuntimeCheckpointerResolver;
|
|
313
|
+
storeResolver?: RuntimeStoreResolver;
|
|
314
|
+
backendResolver?: RuntimeBackendResolver;
|
|
315
|
+
};
|
|
316
|
+
export type ToolKindAdapter = {
|
|
317
|
+
type: string;
|
|
318
|
+
validate: (tool: ParsedToolObject, tools: Map<string, ParsedToolObject>) => void;
|
|
319
|
+
compile: (tool: ParsedToolObject, tools: Map<string, ParsedToolObject>) => CompiledTool[];
|
|
320
|
+
};
|
|
321
|
+
export type SkillSourceResolver = {
|
|
322
|
+
kind: string;
|
|
323
|
+
resolve: (input: {
|
|
324
|
+
workspaceRoot: string;
|
|
325
|
+
skill: {
|
|
326
|
+
sourcePathRef: string;
|
|
327
|
+
};
|
|
328
|
+
packagingRoots: string[];
|
|
329
|
+
}) => string[];
|
|
330
|
+
};
|
|
331
|
+
export type SkillInheritancePolicy = {
|
|
332
|
+
kind: string;
|
|
333
|
+
apply: (input: {
|
|
334
|
+
agent: ParsedAgentObject;
|
|
335
|
+
ownSkills: string[];
|
|
336
|
+
parentSkills: string[];
|
|
337
|
+
}) => string[];
|
|
338
|
+
};
|
|
339
|
+
export type SkillPackagingConvention = {
|
|
340
|
+
kind: string;
|
|
341
|
+
resolve: (input: {
|
|
342
|
+
workspaceRoot: string;
|
|
343
|
+
skill: {
|
|
344
|
+
sourcePathRef: string;
|
|
345
|
+
};
|
|
346
|
+
}) => string[];
|
|
347
|
+
};
|
|
348
|
+
export type PolicyDecision = {
|
|
349
|
+
allowed: boolean;
|
|
350
|
+
reasons: string[];
|
|
351
|
+
};
|
|
352
|
+
export type PolicyEvaluator = {
|
|
353
|
+
kind: string;
|
|
354
|
+
evaluate: (binding: CompiledAgentBinding) => PolicyDecision | null;
|
|
355
|
+
};
|
|
356
|
+
export type EventSubscriber = {
|
|
357
|
+
kind: string;
|
|
358
|
+
onEvent: (event: HarnessEvent) => void | Promise<void>;
|
|
359
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const AUTO_AGENT_ID = "auto";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CompiledTool, EventSubscriber, ParsedToolObject, PolicyEvaluator, SkillInheritancePolicy, SkillPackagingConvention, SkillSourceResolver, ToolKindAdapter } from "./contracts/types.js";
|
|
2
|
+
export declare function resolveToolTargets(tools: Map<string, ParsedToolObject>, ref: string): ParsedToolObject[];
|
|
3
|
+
export declare function registerToolKind(adapter: ToolKindAdapter): void;
|
|
4
|
+
export declare function getToolKindAdapter(type: string): ToolKindAdapter | undefined;
|
|
5
|
+
export declare function registerSkillSourceResolver(resolver: SkillSourceResolver): void;
|
|
6
|
+
export declare function getSkillSourceResolver(kind: string): SkillSourceResolver | undefined;
|
|
7
|
+
export declare function registerSkillInheritancePolicy(policy: SkillInheritancePolicy): void;
|
|
8
|
+
export declare function getSkillInheritancePolicy(kind: string): SkillInheritancePolicy | undefined;
|
|
9
|
+
export declare function registerSkillPackagingConvention(convention: SkillPackagingConvention): void;
|
|
10
|
+
export declare function getSkillPackagingConvention(kind: string): SkillPackagingConvention | undefined;
|
|
11
|
+
export declare function registerPolicyEvaluator(evaluator: PolicyEvaluator): void;
|
|
12
|
+
export declare function getPolicyEvaluators(): PolicyEvaluator[];
|
|
13
|
+
export declare function registerEventSubscriber(subscriber: EventSubscriber): void;
|
|
14
|
+
export declare function getEventSubscribers(): EventSubscriber[];
|
|
15
|
+
export declare function compileToolWithRegistry(tool: ParsedToolObject, tools: Map<string, ParsedToolObject>): CompiledTool[];
|
|
16
|
+
export declare function validateToolWithRegistry(tool: ParsedToolObject, tools: Map<string, ParsedToolObject>): void;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import { builtinSkillsRoot } from "./vendor/builtins.js";
|
|
3
|
+
import { isExternalSourceLocator, resolveExternalSourcePath } from "./vendor/sources.js";
|
|
4
|
+
const toolKindAdapters = new Map();
|
|
5
|
+
const skillSourceResolvers = new Map();
|
|
6
|
+
const skillInheritancePolicies = new Map();
|
|
7
|
+
const skillPackagingConventions = new Map();
|
|
8
|
+
const policyEvaluators = new Map();
|
|
9
|
+
const eventSubscribers = new Map();
|
|
10
|
+
function resolveToolRefId(ref) {
|
|
11
|
+
if (isExternalSourceLocator(ref)) {
|
|
12
|
+
return ref;
|
|
13
|
+
}
|
|
14
|
+
if (ref.startsWith("builtin/")) {
|
|
15
|
+
return ref;
|
|
16
|
+
}
|
|
17
|
+
return ref.split("/").slice(1).join("/");
|
|
18
|
+
}
|
|
19
|
+
export function resolveToolTargets(tools, ref) {
|
|
20
|
+
const resolved = resolveToolRefId(ref);
|
|
21
|
+
if (resolved === "builtin/*") {
|
|
22
|
+
return Array.from(tools.entries())
|
|
23
|
+
.filter(([id]) => id.startsWith("builtin/"))
|
|
24
|
+
.map(([, tool]) => tool);
|
|
25
|
+
}
|
|
26
|
+
const exact = tools.get(resolved);
|
|
27
|
+
if (exact) {
|
|
28
|
+
return [exact];
|
|
29
|
+
}
|
|
30
|
+
if (!resolved.startsWith("builtin/")) {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
const prefix = `${resolved}/`;
|
|
34
|
+
return Array.from(tools.entries())
|
|
35
|
+
.filter(([id]) => id.startsWith(prefix))
|
|
36
|
+
.map(([, tool]) => tool);
|
|
37
|
+
}
|
|
38
|
+
export function registerToolKind(adapter) {
|
|
39
|
+
toolKindAdapters.set(adapter.type, adapter);
|
|
40
|
+
}
|
|
41
|
+
export function getToolKindAdapter(type) {
|
|
42
|
+
return toolKindAdapters.get(type);
|
|
43
|
+
}
|
|
44
|
+
export function registerSkillSourceResolver(resolver) {
|
|
45
|
+
skillSourceResolvers.set(resolver.kind, resolver);
|
|
46
|
+
}
|
|
47
|
+
export function getSkillSourceResolver(kind) {
|
|
48
|
+
return skillSourceResolvers.get(kind);
|
|
49
|
+
}
|
|
50
|
+
export function registerSkillInheritancePolicy(policy) {
|
|
51
|
+
skillInheritancePolicies.set(policy.kind, policy);
|
|
52
|
+
}
|
|
53
|
+
export function getSkillInheritancePolicy(kind) {
|
|
54
|
+
return skillInheritancePolicies.get(kind);
|
|
55
|
+
}
|
|
56
|
+
export function registerSkillPackagingConvention(convention) {
|
|
57
|
+
skillPackagingConventions.set(convention.kind, convention);
|
|
58
|
+
}
|
|
59
|
+
export function getSkillPackagingConvention(kind) {
|
|
60
|
+
return skillPackagingConventions.get(kind);
|
|
61
|
+
}
|
|
62
|
+
export function registerPolicyEvaluator(evaluator) {
|
|
63
|
+
policyEvaluators.set(evaluator.kind, evaluator);
|
|
64
|
+
}
|
|
65
|
+
export function getPolicyEvaluators() {
|
|
66
|
+
return Array.from(policyEvaluators.values());
|
|
67
|
+
}
|
|
68
|
+
export function registerEventSubscriber(subscriber) {
|
|
69
|
+
eventSubscribers.set(subscriber.kind, subscriber);
|
|
70
|
+
}
|
|
71
|
+
export function getEventSubscribers() {
|
|
72
|
+
return Array.from(eventSubscribers.values());
|
|
73
|
+
}
|
|
74
|
+
function compileBundleTool(tool, tools) {
|
|
75
|
+
const compiled = tool.bundleRefs.flatMap((ref) => {
|
|
76
|
+
const nested = resolveToolTargets(tools, ref);
|
|
77
|
+
if (nested.length === 0) {
|
|
78
|
+
throw new Error(`Tool bundle target ${ref} not found`);
|
|
79
|
+
}
|
|
80
|
+
return nested.flatMap((item) => compileToolWithRegistry(item, tools));
|
|
81
|
+
});
|
|
82
|
+
const deduped = new Map();
|
|
83
|
+
for (const item of compiled) {
|
|
84
|
+
deduped.set(item.name, item);
|
|
85
|
+
}
|
|
86
|
+
return Array.from(deduped.values());
|
|
87
|
+
}
|
|
88
|
+
export function compileToolWithRegistry(tool, tools) {
|
|
89
|
+
const adapter = getToolKindAdapter(tool.type);
|
|
90
|
+
if (!adapter) {
|
|
91
|
+
throw new Error(`No tool kind adapter registered for ${tool.type}`);
|
|
92
|
+
}
|
|
93
|
+
return adapter.compile(tool, tools);
|
|
94
|
+
}
|
|
95
|
+
export function validateToolWithRegistry(tool, tools) {
|
|
96
|
+
const adapter = getToolKindAdapter(tool.type);
|
|
97
|
+
if (!adapter) {
|
|
98
|
+
throw new Error(`No tool kind adapter registered for ${tool.type}`);
|
|
99
|
+
}
|
|
100
|
+
adapter.validate(tool, tools);
|
|
101
|
+
}
|
|
102
|
+
registerToolKind({
|
|
103
|
+
type: "function",
|
|
104
|
+
validate(tool) {
|
|
105
|
+
if (!tool.name) {
|
|
106
|
+
throw new Error(`Tool ${tool.id} name must not be empty`);
|
|
107
|
+
}
|
|
108
|
+
if (!tool.description) {
|
|
109
|
+
throw new Error(`Tool ${tool.id} description must not be empty`);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
compile(tool) {
|
|
113
|
+
return [
|
|
114
|
+
{
|
|
115
|
+
id: tool.id,
|
|
116
|
+
type: "function",
|
|
117
|
+
name: tool.name,
|
|
118
|
+
description: tool.description,
|
|
119
|
+
config: tool.config,
|
|
120
|
+
inputSchemaRef: tool.inputSchemaRef,
|
|
121
|
+
bundleRefs: [],
|
|
122
|
+
hitl: tool.hitl
|
|
123
|
+
? {
|
|
124
|
+
enabled: tool.hitl.enabled,
|
|
125
|
+
allow: tool.hitl.allow ?? ["approve", "edit", "reject"],
|
|
126
|
+
}
|
|
127
|
+
: undefined,
|
|
128
|
+
runtimeValue: { name: tool.name, description: tool.description, type: "function" },
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
registerToolKind({
|
|
134
|
+
type: "backend",
|
|
135
|
+
validate(tool) {
|
|
136
|
+
if (!tool.name || !tool.description) {
|
|
137
|
+
throw new Error(`Tool ${tool.id} backend tool requires name and description`);
|
|
138
|
+
}
|
|
139
|
+
if (!tool.backendOperation) {
|
|
140
|
+
throw new Error(`Tool ${tool.id} backend tool must define operation`);
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
compile(tool) {
|
|
144
|
+
return [
|
|
145
|
+
{
|
|
146
|
+
id: tool.id,
|
|
147
|
+
type: "backend",
|
|
148
|
+
name: tool.name,
|
|
149
|
+
description: tool.description,
|
|
150
|
+
config: tool.config,
|
|
151
|
+
inputSchemaRef: tool.inputSchemaRef,
|
|
152
|
+
backendOperation: tool.backendOperation,
|
|
153
|
+
bundleRefs: [],
|
|
154
|
+
hitl: tool.hitl
|
|
155
|
+
? {
|
|
156
|
+
enabled: tool.hitl.enabled,
|
|
157
|
+
allow: tool.hitl.allow ?? ["approve", "edit", "reject"],
|
|
158
|
+
}
|
|
159
|
+
: undefined,
|
|
160
|
+
runtimeValue: { name: tool.name, description: tool.description, type: "backend" },
|
|
161
|
+
},
|
|
162
|
+
];
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
registerToolKind({
|
|
166
|
+
type: "mcp",
|
|
167
|
+
validate(tool) {
|
|
168
|
+
if (!tool.name || !tool.description) {
|
|
169
|
+
throw new Error(`Tool ${tool.id} mcp tool requires name and description`);
|
|
170
|
+
}
|
|
171
|
+
if (!tool.mcpRef) {
|
|
172
|
+
throw new Error(`Tool ${tool.id} mcp tool must define mcp.ref`);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
compile(tool) {
|
|
176
|
+
return [
|
|
177
|
+
{
|
|
178
|
+
id: tool.id,
|
|
179
|
+
type: "mcp",
|
|
180
|
+
name: tool.name,
|
|
181
|
+
description: tool.description,
|
|
182
|
+
config: tool.config,
|
|
183
|
+
inputSchemaRef: tool.inputSchemaRef,
|
|
184
|
+
mcpRef: tool.mcpRef,
|
|
185
|
+
bundleRefs: [],
|
|
186
|
+
hitl: tool.hitl
|
|
187
|
+
? {
|
|
188
|
+
enabled: tool.hitl.enabled,
|
|
189
|
+
allow: tool.hitl.allow ?? ["approve", "edit", "reject"],
|
|
190
|
+
}
|
|
191
|
+
: undefined,
|
|
192
|
+
runtimeValue: { name: tool.name, description: tool.description, type: "mcp" },
|
|
193
|
+
},
|
|
194
|
+
];
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
registerToolKind({
|
|
198
|
+
type: "bundle",
|
|
199
|
+
validate(tool, tools) {
|
|
200
|
+
if (tool.bundleRefs.length === 0) {
|
|
201
|
+
throw new Error(`Tool ${tool.id} bundle must contain nested refs`);
|
|
202
|
+
}
|
|
203
|
+
for (const ref of tool.bundleRefs) {
|
|
204
|
+
const target = resolveToolTargets(tools, ref);
|
|
205
|
+
if (target.length === 0) {
|
|
206
|
+
throw new Error(`Tool ${tool.id} bundle ref ${ref} does not exist`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
compile: compileBundleTool,
|
|
211
|
+
});
|
|
212
|
+
registerSkillSourceResolver({
|
|
213
|
+
kind: "path",
|
|
214
|
+
resolve({ workspaceRoot, skill, packagingRoots }) {
|
|
215
|
+
if (packagingRoots.length > 0) {
|
|
216
|
+
return packagingRoots;
|
|
217
|
+
}
|
|
218
|
+
const candidate = String(skill.sourcePathRef);
|
|
219
|
+
if (isExternalSourceLocator(candidate)) {
|
|
220
|
+
return [resolveExternalSourcePath(candidate, workspaceRoot)];
|
|
221
|
+
}
|
|
222
|
+
return [candidate.startsWith("/") ? candidate : `${workspaceRoot}/${candidate}`];
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
registerSkillSourceResolver({
|
|
226
|
+
kind: "builtin",
|
|
227
|
+
resolve({ skill }) {
|
|
228
|
+
return [path.join(builtinSkillsRoot(), skill.sourcePathRef)];
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
registerSkillInheritancePolicy({
|
|
232
|
+
kind: "default",
|
|
233
|
+
apply({ agent, ownSkills, parentSkills }) {
|
|
234
|
+
const systemPrompt = agent.deepAgentConfig?.systemPrompt;
|
|
235
|
+
const hasSystemPrompt = typeof systemPrompt === "string" && systemPrompt.trim().length > 0;
|
|
236
|
+
if (hasSystemPrompt && agent.id.includes(".")) {
|
|
237
|
+
return ownSkills;
|
|
238
|
+
}
|
|
239
|
+
return Array.from(new Set([...parentSkills, ...ownSkills]));
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
registerSkillPackagingConvention({
|
|
243
|
+
kind: "path",
|
|
244
|
+
resolve({ workspaceRoot, skill }) {
|
|
245
|
+
const candidate = String(skill.sourcePathRef);
|
|
246
|
+
if (isExternalSourceLocator(candidate)) {
|
|
247
|
+
return [resolveExternalSourcePath(candidate, workspaceRoot)];
|
|
248
|
+
}
|
|
249
|
+
return [candidate.startsWith("/") ? candidate : `${workspaceRoot}/${candidate}`];
|
|
250
|
+
},
|
|
251
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./contracts/types.js";
|
|
2
|
+
export * from "./extensions.js";
|
|
3
|
+
export * from "./api.js";
|
|
4
|
+
export * from "./presentation.js";
|
|
5
|
+
export * from "./runtime/index.js";
|
|
6
|
+
export * from "./workspace/index.js";
|
|
7
|
+
export { createBuiltinBackendResolver, createBuiltinToolResolver } from "./vendor/builtins.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./contracts/types.js";
|
|
2
|
+
export * from "./extensions.js";
|
|
3
|
+
export * from "./api.js";
|
|
4
|
+
export * from "./presentation.js";
|
|
5
|
+
export * from "./runtime/index.js";
|
|
6
|
+
export * from "./workspace/index.js";
|
|
7
|
+
export { createBuiltinBackendResolver, createBuiltinToolResolver } from "./vendor/builtins.js";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ApprovalRecord, ArtifactListing, ArtifactRecord, DelegationRecord, HarnessEvent, RunState, SessionRecord, TranscriptMessage } from "../contracts/types.js";
|
|
2
|
+
export declare class FilePersistence {
|
|
3
|
+
private readonly runRoot;
|
|
4
|
+
constructor(runRoot: string);
|
|
5
|
+
initialize(): Promise<void>;
|
|
6
|
+
threadDir(threadId: string): string;
|
|
7
|
+
runDir(threadId: string, runId: string): string;
|
|
8
|
+
createThread(input: {
|
|
9
|
+
threadId: string;
|
|
10
|
+
agentId: string;
|
|
11
|
+
runId: string;
|
|
12
|
+
status: RunState;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
createRun(input: {
|
|
16
|
+
threadId: string;
|
|
17
|
+
runId: string;
|
|
18
|
+
agentId: string;
|
|
19
|
+
executionMode: string;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
setRunState(threadId: string, runId: string, state: RunState, checkpointRef?: string | null): Promise<void>;
|
|
23
|
+
appendEvent(event: HarnessEvent): Promise<void>;
|
|
24
|
+
listSessions(): Promise<SessionRecord[]>;
|
|
25
|
+
getSession(threadId: string): Promise<SessionRecord | null>;
|
|
26
|
+
listRunEvents(threadId: string, runId: string): Promise<HarnessEvent[]>;
|
|
27
|
+
listApprovals(): Promise<ApprovalRecord[]>;
|
|
28
|
+
getApproval(approvalId: string): Promise<ApprovalRecord | null>;
|
|
29
|
+
getRunApprovals(threadId: string, runId: string): Promise<ApprovalRecord[]>;
|
|
30
|
+
listDelegations(): Promise<DelegationRecord[]>;
|
|
31
|
+
createApproval(record: ApprovalRecord): Promise<void>;
|
|
32
|
+
resolveApproval(threadId: string, runId: string, approvalId: string, status: ApprovalRecord["status"]): Promise<ApprovalRecord>;
|
|
33
|
+
createDelegation(record: DelegationRecord): Promise<void>;
|
|
34
|
+
updateDelegation(threadId: string, runId: string, delegationId: string, patch: Partial<DelegationRecord>): Promise<DelegationRecord>;
|
|
35
|
+
createArtifact(threadId: string, runId: string, artifact: ArtifactRecord, content: unknown): Promise<ArtifactRecord>;
|
|
36
|
+
listArtifacts(threadId: string, runId: string): Promise<ArtifactListing>;
|
|
37
|
+
appendThreadMessage(threadId: string, message: TranscriptMessage): Promise<void>;
|
|
38
|
+
listThreadMessages(threadId: string, limit?: number): Promise<TranscriptMessage[]>;
|
|
39
|
+
}
|