@theokit/agents 7.4.2 → 7.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +73 -74
- package/dist/auth.js.map +1 -1
- package/dist/{bridge-entry-Z8GjrwH4.d.ts → bridge-entry-CvmBrmc9.d.ts} +101 -5
- package/dist/bridge.d.ts +1 -1
- package/dist/bridge.js +6 -1
- package/dist/{chunk-PHUNONZT.js → chunk-22IPZFVT.js} +1007 -446
- package/dist/chunk-22IPZFVT.js.map +1 -0
- package/dist/{chunk-FJA4QQLZ.js → chunk-2BAFKRXT.js} +221 -165
- package/dist/chunk-2BAFKRXT.js.map +1 -0
- package/dist/chunk-Z4QWC7IK.js +7 -0
- package/dist/chunk-Z4QWC7IK.js.map +1 -0
- package/dist/client-react.js +9 -3
- package/dist/client-react.js.map +1 -1
- package/dist/client.js +2 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.js +382 -129
- package/dist/index.js.map +1 -1
- package/dist/interactive.js +3 -6
- package/dist/interactive.js.map +1 -1
- package/dist/persistence.d.ts +1 -1
- package/dist/persistence.js +6 -0
- package/dist/persistence.js.map +1 -1
- package/dist/pty.js +3 -7
- package/dist/pty.js.map +1 -1
- package/dist/sandbox.d.ts +1 -1
- package/dist/sandbox.js +6 -2
- package/dist/sandbox.js.map +1 -1
- package/dist/testing.js +21 -3
- package/dist/testing.js.map +1 -1
- package/dist/tools.js +3 -55
- package/dist/tools.js.map +1 -1
- package/package.json +14 -21
- package/dist/chunk-FJA4QQLZ.js.map +0 -1
- package/dist/chunk-PHUNONZT.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
GuardrailViolationError,
|
|
17
17
|
JudgeCredentialError,
|
|
18
18
|
McpFileError,
|
|
19
|
+
UntrustedSettingSourceError,
|
|
19
20
|
agentsPlugin,
|
|
20
21
|
buildModelSelection,
|
|
21
22
|
compactionStrategyConfigSchema,
|
|
@@ -66,6 +67,7 @@ import {
|
|
|
66
67
|
resolveCompactionStrategy,
|
|
67
68
|
resolveLoopStrategy,
|
|
68
69
|
resolveMcpServers,
|
|
70
|
+
resolveSettingSources,
|
|
69
71
|
runInputGuards,
|
|
70
72
|
runOutputGuards,
|
|
71
73
|
runWithApiErrorHandling,
|
|
@@ -76,7 +78,10 @@ import {
|
|
|
76
78
|
toolRuntimeName,
|
|
77
79
|
translateSdkEvent,
|
|
78
80
|
unicodeNormalizer
|
|
79
|
-
} from "./chunk-
|
|
81
|
+
} from "./chunk-22IPZFVT.js";
|
|
82
|
+
import {
|
|
83
|
+
__name
|
|
84
|
+
} from "./chunk-Z4QWC7IK.js";
|
|
80
85
|
|
|
81
86
|
// src/index.ts
|
|
82
87
|
import { Agent as AgentDoSdk } from "@theokit/sdk";
|
|
@@ -84,6 +89,9 @@ import { Agent as AgentDoSdk } from "@theokit/sdk";
|
|
|
84
89
|
// src/capability/capability.ts
|
|
85
90
|
import { isDeepStrictEqual } from "util";
|
|
86
91
|
var CapabilityConflictError = class extends Error {
|
|
92
|
+
static {
|
|
93
|
+
__name(this, "CapabilityConflictError");
|
|
94
|
+
}
|
|
87
95
|
name = "CapabilityConflictError";
|
|
88
96
|
constructor(field, previous, next, capability) {
|
|
89
97
|
super(
|
|
@@ -102,14 +110,21 @@ function shapeOf(value) {
|
|
|
102
110
|
}
|
|
103
111
|
return typeof value;
|
|
104
112
|
}
|
|
113
|
+
__name(shapeOf, "shapeOf");
|
|
105
114
|
function createDraft() {
|
|
106
|
-
return {
|
|
115
|
+
return {
|
|
116
|
+
tools: [],
|
|
117
|
+
agents: {},
|
|
118
|
+
provenance: []
|
|
119
|
+
};
|
|
107
120
|
}
|
|
121
|
+
__name(createDraft, "createDraft");
|
|
108
122
|
function applyCapabilities(capabilities, draft = createDraft()) {
|
|
109
123
|
for (const c of capabilities) c.apply(draft);
|
|
110
124
|
draft.stream ??= true;
|
|
111
125
|
return draft;
|
|
112
126
|
}
|
|
127
|
+
__name(applyCapabilities, "applyCapabilities");
|
|
113
128
|
function setOnce(draft, field, value, capability) {
|
|
114
129
|
if (value === void 0) return;
|
|
115
130
|
const previous = draft[field];
|
|
@@ -117,15 +132,28 @@ function setOnce(draft, field, value, capability) {
|
|
|
117
132
|
throw new CapabilityConflictError(field, previous, value, capability);
|
|
118
133
|
}
|
|
119
134
|
draft[field] = value;
|
|
120
|
-
draft.provenance.push({
|
|
135
|
+
draft.provenance.push({
|
|
136
|
+
capability,
|
|
137
|
+
contributed: [
|
|
138
|
+
field
|
|
139
|
+
]
|
|
140
|
+
});
|
|
121
141
|
}
|
|
142
|
+
__name(setOnce, "setOnce");
|
|
122
143
|
|
|
123
144
|
// src/capability/capabilities.ts
|
|
124
145
|
function describe(value) {
|
|
125
146
|
if (value === null) return "null";
|
|
126
147
|
return Array.isArray(value) ? "array" : typeof value;
|
|
127
148
|
}
|
|
149
|
+
__name(describe, "describe");
|
|
128
150
|
var ModelCapability = class {
|
|
151
|
+
static {
|
|
152
|
+
__name(this, "ModelCapability");
|
|
153
|
+
}
|
|
154
|
+
id;
|
|
155
|
+
reasoningEffort;
|
|
156
|
+
name = "model";
|
|
129
157
|
constructor(id, reasoningEffort) {
|
|
130
158
|
this.id = id;
|
|
131
159
|
this.reasoningEffort = reasoningEffort;
|
|
@@ -134,9 +162,6 @@ var ModelCapability = class {
|
|
|
134
162
|
}
|
|
135
163
|
if (id.trim().length === 0) throw new ConfigurationError("model: id cannot be empty");
|
|
136
164
|
}
|
|
137
|
-
id;
|
|
138
|
-
reasoningEffort;
|
|
139
|
-
name = "model";
|
|
140
165
|
apply(draft) {
|
|
141
166
|
setOnce(draft, "model", this.id, this.name);
|
|
142
167
|
if (this.reasoningEffort !== void 0) {
|
|
@@ -145,6 +170,9 @@ var ModelCapability = class {
|
|
|
145
170
|
}
|
|
146
171
|
};
|
|
147
172
|
var ToolsCapability = class {
|
|
173
|
+
static {
|
|
174
|
+
__name(this, "ToolsCapability");
|
|
175
|
+
}
|
|
148
176
|
name = "tools";
|
|
149
177
|
#tools;
|
|
150
178
|
constructor(tools) {
|
|
@@ -152,10 +180,18 @@ var ToolsCapability = class {
|
|
|
152
180
|
}
|
|
153
181
|
apply(draft) {
|
|
154
182
|
draft.tools.push(...this.#tools);
|
|
155
|
-
draft.provenance.push({
|
|
183
|
+
draft.provenance.push({
|
|
184
|
+
capability: this.name,
|
|
185
|
+
contributed: [
|
|
186
|
+
"tools"
|
|
187
|
+
]
|
|
188
|
+
});
|
|
156
189
|
}
|
|
157
190
|
};
|
|
158
191
|
var SkillsCapability = class {
|
|
192
|
+
static {
|
|
193
|
+
__name(this, "SkillsCapability");
|
|
194
|
+
}
|
|
159
195
|
name = "skills";
|
|
160
196
|
#entries;
|
|
161
197
|
constructor(entries) {
|
|
@@ -170,16 +206,16 @@ var SkillsCapability = class {
|
|
|
170
206
|
continue;
|
|
171
207
|
}
|
|
172
208
|
if (typeof e !== "object" || e === null || Array.isArray(e)) {
|
|
173
|
-
throw new ConfigurationError(
|
|
174
|
-
`skills: invalid entry (${describe(e)}) \u2014 use a name or an inline skill`
|
|
175
|
-
);
|
|
209
|
+
throw new ConfigurationError(`skills: invalid entry (${describe(e)}) \u2014 use a name or an inline skill`);
|
|
176
210
|
}
|
|
177
|
-
for (const field of [
|
|
211
|
+
for (const field of [
|
|
212
|
+
"name",
|
|
213
|
+
"description",
|
|
214
|
+
"instructions"
|
|
215
|
+
]) {
|
|
178
216
|
const value = e[field];
|
|
179
217
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
180
|
-
throw new ConfigurationError(
|
|
181
|
-
`skills: inline skill without a valid \`${field}\` (${describe(value)}) \u2014 name, description and instructions are all required`
|
|
182
|
-
);
|
|
218
|
+
throw new ConfigurationError(`skills: inline skill without a valid \`${field}\` (${describe(value)}) \u2014 name, description and instructions are all required`);
|
|
183
219
|
}
|
|
184
220
|
}
|
|
185
221
|
}
|
|
@@ -198,21 +234,40 @@ var SkillsCapability = class {
|
|
|
198
234
|
// and no reference array form can express it) — revisit when one can.
|
|
199
235
|
...previous,
|
|
200
236
|
...compiled.skills,
|
|
201
|
-
enabled: [
|
|
202
|
-
|
|
237
|
+
enabled: [
|
|
238
|
+
...previous.enabled ?? [],
|
|
239
|
+
...compiled.skills.enabled ?? []
|
|
240
|
+
],
|
|
241
|
+
...previous.inline !== void 0 || compiled.skills.inline !== void 0 ? {
|
|
242
|
+
inline: [
|
|
243
|
+
...previous.inline ?? [],
|
|
244
|
+
...compiled.skills.inline ?? []
|
|
245
|
+
]
|
|
246
|
+
} : {}
|
|
203
247
|
};
|
|
204
|
-
draft.provenance.push({
|
|
248
|
+
draft.provenance.push({
|
|
249
|
+
capability: this.name,
|
|
250
|
+
contributed: [
|
|
251
|
+
"skills"
|
|
252
|
+
]
|
|
253
|
+
});
|
|
205
254
|
}
|
|
206
255
|
};
|
|
207
256
|
|
|
208
257
|
// src/capability/registry.ts
|
|
209
258
|
var UnknownCapabilityError = class extends Error {
|
|
259
|
+
static {
|
|
260
|
+
__name(this, "UnknownCapabilityError");
|
|
261
|
+
}
|
|
210
262
|
name = "UnknownCapabilityError";
|
|
211
263
|
constructor(requested, known) {
|
|
212
264
|
super(`capability "${requested}" is not registered. Known: ${known.join(", ") || "(none)"}.`);
|
|
213
265
|
}
|
|
214
266
|
};
|
|
215
267
|
var CapabilityRegistry = class {
|
|
268
|
+
static {
|
|
269
|
+
__name(this, "CapabilityRegistry");
|
|
270
|
+
}
|
|
216
271
|
#factories = /* @__PURE__ */ new Map();
|
|
217
272
|
register(name, factory) {
|
|
218
273
|
this.#factories.set(name, factory);
|
|
@@ -222,7 +277,9 @@ var CapabilityRegistry = class {
|
|
|
222
277
|
return this.#factories.has(name);
|
|
223
278
|
}
|
|
224
279
|
names() {
|
|
225
|
-
return [
|
|
280
|
+
return [
|
|
281
|
+
...this.#factories.keys()
|
|
282
|
+
];
|
|
226
283
|
}
|
|
227
284
|
resolve(name, arg) {
|
|
228
285
|
const factory = this.#factories.get(name);
|
|
@@ -231,12 +288,15 @@ var CapabilityRegistry = class {
|
|
|
231
288
|
}
|
|
232
289
|
};
|
|
233
290
|
var CapabilityPreset = class {
|
|
291
|
+
static {
|
|
292
|
+
__name(this, "CapabilityPreset");
|
|
293
|
+
}
|
|
294
|
+
name;
|
|
295
|
+
#members;
|
|
234
296
|
constructor(name, members) {
|
|
235
297
|
this.name = name;
|
|
236
298
|
this.#members = members;
|
|
237
299
|
}
|
|
238
|
-
name;
|
|
239
|
-
#members;
|
|
240
300
|
apply(draft) {
|
|
241
301
|
for (const member of this.#members) member.apply(draft);
|
|
242
302
|
}
|
|
@@ -244,120 +304,169 @@ var CapabilityPreset = class {
|
|
|
244
304
|
|
|
245
305
|
// src/capability/agent-capabilities.ts
|
|
246
306
|
var FieldCapability = class {
|
|
307
|
+
static {
|
|
308
|
+
__name(this, "FieldCapability");
|
|
309
|
+
}
|
|
310
|
+
value;
|
|
247
311
|
constructor(value) {
|
|
248
312
|
this.value = value;
|
|
249
313
|
}
|
|
250
|
-
value;
|
|
251
314
|
apply(draft) {
|
|
252
315
|
setOnce(draft, this.field, this.value, this.name);
|
|
253
316
|
}
|
|
254
317
|
};
|
|
255
318
|
var MemoryCapability = class extends FieldCapability {
|
|
319
|
+
static {
|
|
320
|
+
__name(this, "MemoryCapability");
|
|
321
|
+
}
|
|
256
322
|
name = "memory";
|
|
257
323
|
field = "memory";
|
|
258
324
|
};
|
|
259
325
|
var ContextWindowCapability = class {
|
|
260
|
-
|
|
261
|
-
this
|
|
326
|
+
static {
|
|
327
|
+
__name(this, "ContextWindowCapability");
|
|
262
328
|
}
|
|
263
329
|
options;
|
|
264
330
|
name = "context-window";
|
|
331
|
+
constructor(options) {
|
|
332
|
+
this.options = options;
|
|
333
|
+
}
|
|
265
334
|
apply(draft) {
|
|
266
335
|
setOnce(draft, "context", compileContextWindow(this.options).context, this.name);
|
|
267
336
|
}
|
|
268
337
|
};
|
|
269
338
|
var ProjectContextCapability = class extends FieldCapability {
|
|
339
|
+
static {
|
|
340
|
+
__name(this, "ProjectContextCapability");
|
|
341
|
+
}
|
|
270
342
|
name = "project-context";
|
|
271
343
|
field = "projectContext";
|
|
272
344
|
};
|
|
273
345
|
var McpServersCapability = class extends FieldCapability {
|
|
346
|
+
static {
|
|
347
|
+
__name(this, "McpServersCapability");
|
|
348
|
+
}
|
|
274
349
|
name = "mcp";
|
|
275
350
|
field = "mcpServers";
|
|
276
351
|
};
|
|
277
352
|
var GuardrailsCapability = class extends FieldCapability {
|
|
353
|
+
static {
|
|
354
|
+
__name(this, "GuardrailsCapability");
|
|
355
|
+
}
|
|
278
356
|
name = "guardrails";
|
|
279
357
|
field = "guardrails";
|
|
280
358
|
};
|
|
281
359
|
var CheckpointCapability = class {
|
|
282
|
-
|
|
283
|
-
this
|
|
360
|
+
static {
|
|
361
|
+
__name(this, "CheckpointCapability");
|
|
284
362
|
}
|
|
285
363
|
options;
|
|
286
364
|
name = "checkpoint";
|
|
365
|
+
constructor(options) {
|
|
366
|
+
this.options = options;
|
|
367
|
+
}
|
|
287
368
|
apply(draft) {
|
|
288
369
|
if (this.options !== void 0 && this.options.storage !== "filesystem") {
|
|
289
|
-
console.warn(
|
|
290
|
-
`[THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY] checkpoint({ storage: '${this.options.storage ?? "memory"}' }) does NOT resume across requests \u2014 only 'filesystem' selects the SDK's durable conversation store. Use checkpoint({ storage: 'filesystem' }) for cross-request resume.`
|
|
291
|
-
);
|
|
370
|
+
console.warn(`[THEO_AGENT_CHECKPOINT_STORAGE_METADATA_ONLY] checkpoint({ storage: '${this.options.storage ?? "memory"}' }) does NOT resume across requests \u2014 only 'filesystem' selects the SDK's durable conversation store. Use checkpoint({ storage: 'filesystem' }) for cross-request resume.`);
|
|
292
371
|
}
|
|
293
372
|
setOnce(draft, "checkpoint", this.options, this.name);
|
|
294
373
|
}
|
|
295
374
|
};
|
|
296
375
|
var HumanInTheLoopCapability = class extends FieldCapability {
|
|
376
|
+
static {
|
|
377
|
+
__name(this, "HumanInTheLoopCapability");
|
|
378
|
+
}
|
|
297
379
|
name = "human-in-the-loop";
|
|
298
380
|
field = "hitl";
|
|
299
381
|
};
|
|
300
382
|
var SubAgentsCapability = class {
|
|
301
|
-
|
|
302
|
-
this
|
|
383
|
+
static {
|
|
384
|
+
__name(this, "SubAgentsCapability");
|
|
303
385
|
}
|
|
304
386
|
children;
|
|
305
387
|
name = "sub-agents";
|
|
388
|
+
constructor(children) {
|
|
389
|
+
this.children = children;
|
|
390
|
+
}
|
|
306
391
|
apply(draft) {
|
|
307
392
|
for (const [name, child] of Object.entries(this.children)) {
|
|
308
393
|
if (name in draft.agents && draft.agents[name] !== child) {
|
|
309
|
-
throw new ConfigurationError(
|
|
310
|
-
`sub-agents: child "${name}" declared twice with different definitions`
|
|
311
|
-
);
|
|
394
|
+
throw new ConfigurationError(`sub-agents: child "${name}" declared twice with different definitions`);
|
|
312
395
|
}
|
|
313
396
|
draft.agents[name] = child;
|
|
314
397
|
}
|
|
315
|
-
draft.provenance.push({
|
|
398
|
+
draft.provenance.push({
|
|
399
|
+
capability: this.name,
|
|
400
|
+
contributed: [
|
|
401
|
+
"agents"
|
|
402
|
+
]
|
|
403
|
+
});
|
|
316
404
|
}
|
|
317
405
|
};
|
|
318
406
|
var SkillsOptionsCapability = class {
|
|
319
|
-
|
|
320
|
-
this
|
|
407
|
+
static {
|
|
408
|
+
__name(this, "SkillsOptionsCapability");
|
|
321
409
|
}
|
|
322
410
|
options;
|
|
323
411
|
name = "skills";
|
|
412
|
+
constructor(options) {
|
|
413
|
+
this.options = options;
|
|
414
|
+
}
|
|
324
415
|
apply(draft) {
|
|
325
416
|
setOnce(draft, "skills", compileSkills(this.options), this.name);
|
|
326
417
|
}
|
|
327
418
|
};
|
|
328
419
|
var SettingSourcesCapability = class extends FieldCapability {
|
|
420
|
+
static {
|
|
421
|
+
__name(this, "SettingSourcesCapability");
|
|
422
|
+
}
|
|
329
423
|
name = "setting-sources";
|
|
330
424
|
field = "settingSources";
|
|
331
425
|
};
|
|
332
426
|
var PluginsCapability = class extends FieldCapability {
|
|
427
|
+
static {
|
|
428
|
+
__name(this, "PluginsCapability");
|
|
429
|
+
}
|
|
333
430
|
name = "plugins";
|
|
334
431
|
field = "plugins";
|
|
335
432
|
};
|
|
336
433
|
var RunContextCapability = class extends FieldCapability {
|
|
434
|
+
static {
|
|
435
|
+
__name(this, "RunContextCapability");
|
|
436
|
+
}
|
|
337
437
|
name = "run-context";
|
|
338
438
|
field = "runContext";
|
|
339
439
|
};
|
|
340
440
|
var SkillsResolverCapability = class extends FieldCapability {
|
|
441
|
+
static {
|
|
442
|
+
__name(this, "SkillsResolverCapability");
|
|
443
|
+
}
|
|
341
444
|
name = "skills-resolver";
|
|
342
445
|
field = "skillsResolver";
|
|
343
446
|
};
|
|
344
447
|
var AgentConfigCapability = class {
|
|
448
|
+
static {
|
|
449
|
+
__name(this, "AgentConfigCapability");
|
|
450
|
+
}
|
|
451
|
+
config;
|
|
452
|
+
name = "agent-config";
|
|
345
453
|
constructor(config) {
|
|
346
454
|
this.config = config;
|
|
347
455
|
if (typeof config !== "object" || config === null) {
|
|
348
456
|
throw new ConfigurationError("agent-config: expected a configuration object");
|
|
349
457
|
}
|
|
350
|
-
for (const field of [
|
|
458
|
+
for (const field of [
|
|
459
|
+
"maxIterations",
|
|
460
|
+
"timeoutMs"
|
|
461
|
+
]) {
|
|
351
462
|
const value = config[field];
|
|
352
463
|
if (value !== void 0 && (!Number.isFinite(value) || value <= 0)) {
|
|
353
464
|
throw new ConfigurationError(`agent-config: \`${field}\` must be a positive number`);
|
|
354
465
|
}
|
|
355
466
|
}
|
|
356
467
|
}
|
|
357
|
-
config;
|
|
358
|
-
name = "agent-config";
|
|
359
468
|
apply(draft) {
|
|
360
|
-
const claimedByMainLoop = (field) => draft.provenance.some((p) => p.capability === "main-loop" && p.contributed.includes(field));
|
|
469
|
+
const claimedByMainLoop = /* @__PURE__ */ __name((field) => draft.provenance.some((p) => p.capability === "main-loop" && p.contributed.includes(field)), "claimedByMainLoop");
|
|
361
470
|
if (!claimedByMainLoop("maxIterations")) {
|
|
362
471
|
setOnce(draft, "maxIterations", this.config.maxIterations, this.name);
|
|
363
472
|
}
|
|
@@ -372,11 +481,14 @@ var AgentConfigCapability = class {
|
|
|
372
481
|
}
|
|
373
482
|
};
|
|
374
483
|
var MainLoopCapability = class {
|
|
375
|
-
|
|
376
|
-
this
|
|
484
|
+
static {
|
|
485
|
+
__name(this, "MainLoopCapability");
|
|
377
486
|
}
|
|
378
487
|
config;
|
|
379
488
|
name = "main-loop";
|
|
489
|
+
constructor(config) {
|
|
490
|
+
this.config = config;
|
|
491
|
+
}
|
|
380
492
|
apply(draft) {
|
|
381
493
|
const contributed = [];
|
|
382
494
|
if (this.config.maxIterations !== void 0) {
|
|
@@ -387,12 +499,18 @@ var MainLoopCapability = class {
|
|
|
387
499
|
draft.timeoutMs = this.config.timeoutMs;
|
|
388
500
|
contributed.push("timeoutMs");
|
|
389
501
|
}
|
|
390
|
-
if (contributed.length > 0) draft.provenance.push({
|
|
502
|
+
if (contributed.length > 0) draft.provenance.push({
|
|
503
|
+
capability: this.name,
|
|
504
|
+
contributed
|
|
505
|
+
});
|
|
391
506
|
}
|
|
392
507
|
};
|
|
393
508
|
|
|
394
509
|
// src/capability/toolbox.ts
|
|
395
510
|
var ToolboxCapability = class {
|
|
511
|
+
static {
|
|
512
|
+
__name(this, "ToolboxCapability");
|
|
513
|
+
}
|
|
396
514
|
name = "toolbox";
|
|
397
515
|
#instance;
|
|
398
516
|
#declarations;
|
|
@@ -403,15 +521,11 @@ var ToolboxCapability = class {
|
|
|
403
521
|
}
|
|
404
522
|
const declared = options.tools ?? instance.constructor.tools;
|
|
405
523
|
if (declared === void 0 || declared.length === 0) {
|
|
406
|
-
throw new ConfigurationError(
|
|
407
|
-
`toolbox: ${instance.constructor.name} declares no tools \u2014 use \`static tools = [...]\` or the \`tools\` option`
|
|
408
|
-
);
|
|
524
|
+
throw new ConfigurationError(`toolbox: ${instance.constructor.name} declares no tools \u2014 use \`static tools = [...]\` or the \`tools\` option`);
|
|
409
525
|
}
|
|
410
526
|
for (const tool of declared) {
|
|
411
527
|
if (typeof instance[tool.method] !== "function") {
|
|
412
|
-
throw new ConfigurationError(
|
|
413
|
-
`toolbox: ${instance.constructor.name}.${tool.method} is not a method (tool "${tool.name}")`
|
|
414
|
-
);
|
|
528
|
+
throw new ConfigurationError(`toolbox: ${instance.constructor.name}.${tool.method} is not a method (tool "${tool.name}")`);
|
|
415
529
|
}
|
|
416
530
|
}
|
|
417
531
|
this.#instance = instance;
|
|
@@ -420,15 +534,15 @@ var ToolboxCapability = class {
|
|
|
420
534
|
for (const tool of declared) toolRuntimeName(this.#namespace, tool.name);
|
|
421
535
|
}
|
|
422
536
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
537
|
+
* The single derivation of this toolbox (M55). Both compilers below consume THIS object, so the
|
|
538
|
+
* tool registry and the HITL gate map cannot disagree on a name — the property is structural, not
|
|
539
|
+
* a convention repeated in two loops. That repetition is precisely how the two drifted apart in
|
|
540
|
+
* #145: the tool became `ns_tool` while its gate stayed `ns.tool`, silently ungating it.
|
|
541
|
+
*
|
|
542
|
+
* Same technique the `opencode` harness uses for the analogous tool↔permission coupling, where
|
|
543
|
+
* `Permission.visibleTools` filters the tool record itself rather than keeping a parallel map
|
|
544
|
+
* ("so the two cannot drift" — `permission/index.ts`).
|
|
545
|
+
*/
|
|
432
546
|
#walk() {
|
|
433
547
|
return {
|
|
434
548
|
// `constructor` is typed `Function` by lib.d.ts; here it is used purely as an IDENTITY key
|
|
@@ -443,48 +557,74 @@ var ToolboxCapability = class {
|
|
|
443
557
|
approval: tool.approval,
|
|
444
558
|
trace: tool.trace ?? false,
|
|
445
559
|
audit: tool.audit ?? false,
|
|
446
|
-
...tool.hitl !== void 0 ? {
|
|
560
|
+
...tool.hitl !== void 0 ? {
|
|
561
|
+
hitl: tool.hitl
|
|
562
|
+
} : {}
|
|
447
563
|
}))
|
|
448
564
|
};
|
|
449
565
|
}
|
|
450
566
|
/**
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
567
|
+
* M56 — the public `compile()` is GONE. It had zero callers anywhere in the monorepo and was kept
|
|
568
|
+
* only because deleting a public method is breaking; that concession is exactly the dead surface
|
|
569
|
+
* M55 set out to remove, preserved inside the milestone that removed it. `apply()` is the one path.
|
|
570
|
+
*/
|
|
455
571
|
apply(draft) {
|
|
456
572
|
const walk = this.#walk();
|
|
457
|
-
draft.tools.push(...compileTools([
|
|
458
|
-
|
|
459
|
-
|
|
573
|
+
draft.tools.push(...compileTools([
|
|
574
|
+
walk
|
|
575
|
+
], /* @__PURE__ */ new Map([
|
|
576
|
+
[
|
|
577
|
+
walk.class,
|
|
578
|
+
this.#instance
|
|
579
|
+
]
|
|
580
|
+
])));
|
|
581
|
+
draft.provenance.push({
|
|
582
|
+
capability: this.name,
|
|
583
|
+
contributed: [
|
|
584
|
+
"tools"
|
|
585
|
+
]
|
|
586
|
+
});
|
|
587
|
+
const gates = compileHitlGates([
|
|
588
|
+
walk
|
|
589
|
+
]);
|
|
460
590
|
if (gates.size === 0) return;
|
|
461
591
|
draft.hitl ??= /* @__PURE__ */ new Map();
|
|
462
592
|
for (const [key, options] of gates) draft.hitl.set(key, options);
|
|
463
|
-
draft.provenance.push({
|
|
593
|
+
draft.provenance.push({
|
|
594
|
+
capability: this.name,
|
|
595
|
+
contributed: [
|
|
596
|
+
"hitl"
|
|
597
|
+
]
|
|
598
|
+
});
|
|
464
599
|
}
|
|
465
600
|
};
|
|
466
601
|
|
|
467
602
|
// src/capability/toolset.ts
|
|
468
603
|
import { TheokitAgentError } from "@theokit/sdk/errors";
|
|
469
604
|
var ToolsetError = class extends TheokitAgentError {
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
this.code = code;
|
|
605
|
+
static {
|
|
606
|
+
__name(this, "ToolsetError");
|
|
473
607
|
}
|
|
474
608
|
code;
|
|
475
609
|
name = "ToolsetError";
|
|
610
|
+
constructor(message, code) {
|
|
611
|
+
super(message), this.code = code;
|
|
612
|
+
}
|
|
476
613
|
};
|
|
477
614
|
var Toolset = class _Toolset {
|
|
615
|
+
static {
|
|
616
|
+
__name(this, "Toolset");
|
|
617
|
+
}
|
|
478
618
|
#byName;
|
|
479
619
|
constructor(byName) {
|
|
480
620
|
this.#byName = byName;
|
|
481
621
|
Object.freeze(this);
|
|
482
622
|
}
|
|
483
623
|
/**
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
624
|
+
* Builds from tools that are already instantiated. Fails loud on a duplicate name **at construction**
|
|
625
|
+
* — not at resolution: a descriptor with two tools of the same name is wrong the moment it is
|
|
626
|
+
* written, and deferring the error to the first `resolve` hides half the cases.
|
|
627
|
+
*/
|
|
488
628
|
static from(tools) {
|
|
489
629
|
const byName = /* @__PURE__ */ new Map();
|
|
490
630
|
for (const tool of tools) {
|
|
@@ -504,9 +644,9 @@ var Toolset = class _Toolset {
|
|
|
504
644
|
return tool;
|
|
505
645
|
}
|
|
506
646
|
/**
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
647
|
+
* Resolves a whitelist. Fails loud on an unknown name **and** on a duplicate within the list itself:
|
|
648
|
+
* a team never silently grants a tool the role did not declare, nor silently drops one it did.
|
|
649
|
+
*/
|
|
510
650
|
resolve(names) {
|
|
511
651
|
const seen = /* @__PURE__ */ new Set();
|
|
512
652
|
return names.map((name) => {
|
|
@@ -519,11 +659,15 @@ var Toolset = class _Toolset {
|
|
|
519
659
|
}
|
|
520
660
|
/** The known names, in registration order. */
|
|
521
661
|
names() {
|
|
522
|
-
return [
|
|
662
|
+
return [
|
|
663
|
+
...this.#byName.keys()
|
|
664
|
+
];
|
|
523
665
|
}
|
|
524
666
|
/** All the tools, in registration order. */
|
|
525
667
|
all() {
|
|
526
|
-
return [
|
|
668
|
+
return [
|
|
669
|
+
...this.#byName.values()
|
|
670
|
+
];
|
|
527
671
|
}
|
|
528
672
|
};
|
|
529
673
|
|
|
@@ -531,6 +675,7 @@ var Toolset = class _Toolset {
|
|
|
531
675
|
function trimTrailingSlash(url) {
|
|
532
676
|
return url.endsWith("/") ? url.slice(0, -1) : url;
|
|
533
677
|
}
|
|
678
|
+
__name(trimTrailingSlash, "trimTrailingSlash");
|
|
534
679
|
function buildAgentCard(entry, options) {
|
|
535
680
|
const base = trimTrailingSlash(options.baseUrl);
|
|
536
681
|
return {
|
|
@@ -543,14 +688,24 @@ function buildAgentCard(entry, options) {
|
|
|
543
688
|
pushNotifications: false,
|
|
544
689
|
stateTransitionHistory: false
|
|
545
690
|
},
|
|
546
|
-
defaultInputModes: [
|
|
547
|
-
|
|
548
|
-
|
|
691
|
+
defaultInputModes: [
|
|
692
|
+
"text"
|
|
693
|
+
],
|
|
694
|
+
defaultOutputModes: [
|
|
695
|
+
"text"
|
|
696
|
+
],
|
|
697
|
+
skills: entry.tools.map((t) => ({
|
|
698
|
+
id: t.name,
|
|
699
|
+
name: t.name,
|
|
700
|
+
description: t.description
|
|
701
|
+
}))
|
|
549
702
|
};
|
|
550
703
|
}
|
|
704
|
+
__name(buildAgentCard, "buildAgentCard");
|
|
551
705
|
function wellKnownCardPath(agentName) {
|
|
552
706
|
return `/.well-known/${agentName}/agent-card.json`;
|
|
553
707
|
}
|
|
708
|
+
__name(wellKnownCardPath, "wellKnownCardPath");
|
|
554
709
|
|
|
555
710
|
// src/a2a/mcp-server-manifest.ts
|
|
556
711
|
var MCP_PROTOCOL_VERSION = "2024-11-05";
|
|
@@ -558,20 +713,33 @@ function buildMcpToolDescriptors(entry) {
|
|
|
558
713
|
return entry.tools.map((t) => ({
|
|
559
714
|
name: t.name,
|
|
560
715
|
description: t.description,
|
|
561
|
-
inputSchema: {
|
|
716
|
+
inputSchema: {
|
|
717
|
+
type: "object",
|
|
718
|
+
properties: {}
|
|
719
|
+
}
|
|
562
720
|
}));
|
|
563
721
|
}
|
|
722
|
+
__name(buildMcpToolDescriptors, "buildMcpToolDescriptors");
|
|
564
723
|
function mcpServerInfo(entry) {
|
|
565
|
-
return {
|
|
724
|
+
return {
|
|
725
|
+
name: entry.name,
|
|
726
|
+
version: "1.0",
|
|
727
|
+
protocolVersion: MCP_PROTOCOL_VERSION
|
|
728
|
+
};
|
|
566
729
|
}
|
|
730
|
+
__name(mcpServerInfo, "mcpServerInfo");
|
|
567
731
|
|
|
568
732
|
// src/a2a/a2a-client.ts
|
|
569
733
|
function buildHeaders(config) {
|
|
570
|
-
const headers = {
|
|
734
|
+
const headers = {
|
|
735
|
+
"content-type": "application/json",
|
|
736
|
+
...config.headers
|
|
737
|
+
};
|
|
571
738
|
if (config.auth?.bearer) headers.authorization = `Bearer ${config.auth.bearer}`;
|
|
572
739
|
if (config.auth?.apiKey) headers[config.auth.apiKey.header] = config.auth.apiKey.value;
|
|
573
740
|
return headers;
|
|
574
741
|
}
|
|
742
|
+
__name(buildHeaders, "buildHeaders");
|
|
575
743
|
function createA2ATool(config) {
|
|
576
744
|
const doFetch = config.fetchImpl ?? fetch;
|
|
577
745
|
return {
|
|
@@ -579,24 +747,34 @@ function createA2ATool(config) {
|
|
|
579
747
|
description: config.description,
|
|
580
748
|
inputSchema: {
|
|
581
749
|
type: "object",
|
|
582
|
-
properties: {
|
|
583
|
-
|
|
750
|
+
properties: {
|
|
751
|
+
message: {
|
|
752
|
+
type: "string",
|
|
753
|
+
description: "The message to send to the remote agent."
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
required: [
|
|
757
|
+
"message"
|
|
758
|
+
]
|
|
584
759
|
},
|
|
585
|
-
handler: async (input) => {
|
|
760
|
+
handler: /* @__PURE__ */ __name(async (input) => {
|
|
586
761
|
const message = typeof input.message === "string" ? input.message : "";
|
|
587
762
|
const res = await doFetch(config.url, {
|
|
588
763
|
method: "POST",
|
|
589
764
|
headers: buildHeaders(config),
|
|
590
|
-
body: JSON.stringify({
|
|
765
|
+
body: JSON.stringify({
|
|
766
|
+
message
|
|
767
|
+
})
|
|
591
768
|
});
|
|
592
769
|
if (!res.ok) {
|
|
593
770
|
throw new Error(`A2A call to "${config.name}" failed: ${res.status} ${res.statusText}`);
|
|
594
771
|
}
|
|
595
772
|
const data = await res.json();
|
|
596
773
|
return data.response ?? data.text ?? "";
|
|
597
|
-
}
|
|
774
|
+
}, "handler")
|
|
598
775
|
};
|
|
599
776
|
}
|
|
777
|
+
__name(createA2ATool, "createA2ATool");
|
|
600
778
|
|
|
601
779
|
// src/conversation-scope.ts
|
|
602
780
|
var SEPARATOR = "/";
|
|
@@ -605,14 +783,19 @@ function deriveConversationId(resource, thread) {
|
|
|
605
783
|
if (!thread) throw new Error("[@theokit/agents] deriveConversationId: thread must be non-empty");
|
|
606
784
|
return `${encodeURIComponent(resource)}${SEPARATOR}${encodeURIComponent(thread)}`;
|
|
607
785
|
}
|
|
786
|
+
__name(deriveConversationId, "deriveConversationId");
|
|
608
787
|
function parseConversationId(id) {
|
|
609
788
|
const idx = id.indexOf(SEPARATOR);
|
|
610
789
|
if (idx <= 0 || idx >= id.length - 1) return null;
|
|
611
790
|
const resource = decodeURIComponent(id.slice(0, idx));
|
|
612
791
|
const thread = decodeURIComponent(id.slice(idx + 1));
|
|
613
792
|
if (!resource || !thread) return null;
|
|
614
|
-
return {
|
|
793
|
+
return {
|
|
794
|
+
resource,
|
|
795
|
+
thread
|
|
796
|
+
};
|
|
615
797
|
}
|
|
798
|
+
__name(parseConversationId, "parseConversationId");
|
|
616
799
|
|
|
617
800
|
// src/skills-resolver.ts
|
|
618
801
|
async function resolveEnabledSkills(selection, ctx) {
|
|
@@ -628,15 +811,22 @@ async function resolveEnabledSkills(selection, ctx) {
|
|
|
628
811
|
if (!names.every((n) => typeof n === "string" && n.trim().length > 0)) {
|
|
629
812
|
throw new Error("[@theokit/agents] skills resolver must return non-empty skill NAME strings");
|
|
630
813
|
}
|
|
631
|
-
return [
|
|
814
|
+
return [
|
|
815
|
+
...names
|
|
816
|
+
];
|
|
632
817
|
}
|
|
818
|
+
__name(resolveEnabledSkills, "resolveEnabledSkills");
|
|
633
819
|
|
|
634
820
|
// src/acp/protocol.ts
|
|
635
821
|
function encodeAcpMessage(message) {
|
|
636
822
|
return `${JSON.stringify(message)}
|
|
637
823
|
`;
|
|
638
824
|
}
|
|
825
|
+
__name(encodeAcpMessage, "encodeAcpMessage");
|
|
639
826
|
var AcpMessageDecoder = class {
|
|
827
|
+
static {
|
|
828
|
+
__name(this, "AcpMessageDecoder");
|
|
829
|
+
}
|
|
640
830
|
buffer = "";
|
|
641
831
|
/** Feed a chunk; returns the messages completed by this chunk (possibly empty). */
|
|
642
832
|
push(chunk) {
|
|
@@ -650,7 +840,9 @@ var AcpMessageDecoder = class {
|
|
|
650
840
|
try {
|
|
651
841
|
messages.push(JSON.parse(line));
|
|
652
842
|
} catch (cause) {
|
|
653
|
-
throw new Error(`[@theokit/agents] ACP decode failed on line: ${line}`, {
|
|
843
|
+
throw new Error(`[@theokit/agents] ACP decode failed on line: ${line}`, {
|
|
844
|
+
cause
|
|
845
|
+
});
|
|
654
846
|
}
|
|
655
847
|
}
|
|
656
848
|
newlineIndex = this.buffer.indexOf("\n");
|
|
@@ -663,10 +855,20 @@ var AcpMessageDecoder = class {
|
|
|
663
855
|
function isResponse(m) {
|
|
664
856
|
return typeof m.id === "number" && ("result" in m || "error" in m) && !("method" in m);
|
|
665
857
|
}
|
|
858
|
+
__name(isResponse, "isResponse");
|
|
666
859
|
function isServerRequest(m) {
|
|
667
860
|
return typeof m.method === "string" && typeof m.id === "number";
|
|
668
861
|
}
|
|
862
|
+
__name(isServerRequest, "isServerRequest");
|
|
669
863
|
var AcpClient = class {
|
|
864
|
+
static {
|
|
865
|
+
__name(this, "AcpClient");
|
|
866
|
+
}
|
|
867
|
+
transport;
|
|
868
|
+
nextId = 1;
|
|
869
|
+
pending = /* @__PURE__ */ new Map();
|
|
870
|
+
handlers = /* @__PURE__ */ new Map();
|
|
871
|
+
decoder = new AcpMessageDecoder();
|
|
670
872
|
constructor(transport) {
|
|
671
873
|
this.transport = transport;
|
|
672
874
|
transport.subscribe((chunk) => {
|
|
@@ -675,17 +877,20 @@ var AcpClient = class {
|
|
|
675
877
|
}
|
|
676
878
|
});
|
|
677
879
|
}
|
|
678
|
-
transport;
|
|
679
|
-
nextId = 1;
|
|
680
|
-
pending = /* @__PURE__ */ new Map();
|
|
681
|
-
handlers = /* @__PURE__ */ new Map();
|
|
682
|
-
decoder = new AcpMessageDecoder();
|
|
683
880
|
/** Send a JSON-RPC request and resolve with its `result` (or reject on `error`). */
|
|
684
881
|
request(method, params) {
|
|
685
882
|
const id = this.nextId++;
|
|
686
883
|
return new Promise((resolve, reject) => {
|
|
687
|
-
this.pending.set(id, {
|
|
688
|
-
|
|
884
|
+
this.pending.set(id, {
|
|
885
|
+
resolve,
|
|
886
|
+
reject
|
|
887
|
+
});
|
|
888
|
+
this.transport.send(encodeAcpMessage({
|
|
889
|
+
jsonrpc: "2.0",
|
|
890
|
+
id,
|
|
891
|
+
method,
|
|
892
|
+
params
|
|
893
|
+
}));
|
|
689
894
|
});
|
|
690
895
|
}
|
|
691
896
|
/** Register a handler for a server→client request method (e.g. `session/request_permission`). */
|
|
@@ -708,22 +913,32 @@ var AcpClient = class {
|
|
|
708
913
|
async handleServerRequest(req) {
|
|
709
914
|
const handler = this.handlers.get(req.method);
|
|
710
915
|
if (!handler) {
|
|
711
|
-
this.transport.send(
|
|
712
|
-
|
|
713
|
-
|
|
916
|
+
this.transport.send(encodeAcpMessage({
|
|
917
|
+
jsonrpc: "2.0",
|
|
918
|
+
id: req.id,
|
|
919
|
+
error: {
|
|
920
|
+
code: -32601,
|
|
921
|
+
message: `No handler: ${req.method}`
|
|
922
|
+
}
|
|
923
|
+
}));
|
|
714
924
|
return;
|
|
715
925
|
}
|
|
716
926
|
try {
|
|
717
927
|
const result = await handler(req.params);
|
|
718
|
-
this.transport.send(encodeAcpMessage({
|
|
928
|
+
this.transport.send(encodeAcpMessage({
|
|
929
|
+
jsonrpc: "2.0",
|
|
930
|
+
id: req.id,
|
|
931
|
+
result
|
|
932
|
+
}));
|
|
719
933
|
} catch (err) {
|
|
720
|
-
this.transport.send(
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
934
|
+
this.transport.send(encodeAcpMessage({
|
|
935
|
+
jsonrpc: "2.0",
|
|
936
|
+
id: req.id,
|
|
937
|
+
error: {
|
|
938
|
+
code: -32603,
|
|
939
|
+
message: err instanceof Error ? err.message : "handler failed"
|
|
940
|
+
}
|
|
941
|
+
}));
|
|
727
942
|
}
|
|
728
943
|
}
|
|
729
944
|
};
|
|
@@ -733,12 +948,7 @@ import { Squad, Tool, Provider } from "@theokit/sdk";
|
|
|
733
948
|
import { setDiagnosticsSink } from "@theokit/sdk";
|
|
734
949
|
import { SubAgent } from "@theokit/sdk/a2a";
|
|
735
950
|
import { assertNoSymlinkEscape, isForbiddenPath, safePathJoin } from "@theokit/sdk/path-safety";
|
|
736
|
-
import {
|
|
737
|
-
CONTEXT_WINDOW_FLOOR,
|
|
738
|
-
CONTEXT_WINDOW_MARGIN,
|
|
739
|
-
ContextWindowMarginError,
|
|
740
|
-
resolveEffectiveContextWindow
|
|
741
|
-
} from "@theokit/sdk/compaction";
|
|
951
|
+
import { CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN, ContextWindowMarginError, resolveEffectiveContextWindow } from "@theokit/sdk/compaction";
|
|
742
952
|
export * from "@theokit/sdk/errors";
|
|
743
953
|
export * from "@theokit/sdk/retry";
|
|
744
954
|
export * from "@theokit/sdk/concurrency";
|
|
@@ -749,10 +959,11 @@ import { BudgetExceededError as BudgetExceededError2 } from "@theokit/sdk/errors
|
|
|
749
959
|
|
|
750
960
|
// src/in-process-turn.ts
|
|
751
961
|
var InProcessApprovalRequiredError = class extends Error {
|
|
962
|
+
static {
|
|
963
|
+
__name(this, "InProcessApprovalRequiredError");
|
|
964
|
+
}
|
|
752
965
|
constructor(toolNames) {
|
|
753
|
-
super(
|
|
754
|
-
`Agent has HITL-gated tool(s) [${toolNames.join(", ")}] but no \`awaitApproval\` resolver was supplied to streamAgentTurnInProcess. In-process runs must resolve approvals inline \u2014 pass awaitApproval, or remove the gate. Refused (fail-closed).`
|
|
755
|
-
);
|
|
966
|
+
super(`Agent has HITL-gated tool(s) [${toolNames.join(", ")}] but no \`awaitApproval\` resolver was supplied to streamAgentTurnInProcess. In-process runs must resolve approvals inline \u2014 pass awaitApproval, or remove the gate. Refused (fail-closed).`);
|
|
756
967
|
this.name = "InProcessApprovalRequiredError";
|
|
757
968
|
}
|
|
758
969
|
};
|
|
@@ -762,40 +973,69 @@ function postureResolver(posturePolicy) {
|
|
|
762
973
|
case "interactive":
|
|
763
974
|
return posturePolicy.awaitApproval;
|
|
764
975
|
case "auto-approve":
|
|
765
|
-
return () => Promise.resolve({
|
|
976
|
+
return () => Promise.resolve({
|
|
977
|
+
approved: true,
|
|
978
|
+
reason: posturePolicy.reason
|
|
979
|
+
});
|
|
766
980
|
case "auto-reject":
|
|
767
|
-
return () => Promise.resolve({
|
|
981
|
+
return () => Promise.resolve({
|
|
982
|
+
approved: false,
|
|
983
|
+
reason: posturePolicy.reason
|
|
984
|
+
});
|
|
768
985
|
case "owned-by-surface":
|
|
769
986
|
return void 0;
|
|
770
987
|
}
|
|
771
988
|
}
|
|
772
|
-
|
|
989
|
+
__name(postureResolver, "postureResolver");
|
|
990
|
+
function streamAgentTurnInProcess(mod, apiKey, input, deps = {
|
|
991
|
+
stream: streamAgentUIMessages
|
|
992
|
+
}) {
|
|
773
993
|
const compiled = compileAgentModule(mod, input.source);
|
|
774
994
|
const gated = compiled.hitl;
|
|
775
995
|
if (gated && gated.size > 0 && !input.awaitApproval && input.approvals === void 0) {
|
|
776
|
-
throw new InProcessApprovalRequiredError([
|
|
996
|
+
throw new InProcessApprovalRequiredError([
|
|
997
|
+
...gated.keys()
|
|
998
|
+
]);
|
|
777
999
|
}
|
|
778
1000
|
const resolve = input.awaitApproval;
|
|
779
|
-
const approvalResolver = resolve ? (approvalId, opts, toolName) => resolve({
|
|
780
|
-
|
|
1001
|
+
const approvalResolver = resolve ? (approvalId, opts, toolName) => resolve({
|
|
1002
|
+
approvalId,
|
|
1003
|
+
toolName,
|
|
1004
|
+
opts
|
|
1005
|
+
}) : postureResolver(input.approvals);
|
|
1006
|
+
const hitl = gated && gated.size > 0 && approvalResolver ? {
|
|
1007
|
+
gated,
|
|
1008
|
+
awaitApproval: approvalResolver
|
|
1009
|
+
} : void 0;
|
|
781
1010
|
const sessionId = input.sessionId ?? crypto.randomUUID();
|
|
782
1011
|
return (async function* () {
|
|
783
1012
|
if (compiled.skillsResolver) {
|
|
784
1013
|
const enabled = await resolveEnabledSkills(compiled.skillsResolver, compiled.runContext ?? {});
|
|
785
|
-
if (enabled !== void 0) compiled.skills = {
|
|
1014
|
+
if (enabled !== void 0) compiled.skills = {
|
|
1015
|
+
enabled,
|
|
1016
|
+
autoInject: true
|
|
1017
|
+
};
|
|
786
1018
|
}
|
|
787
1019
|
yield* deps.stream(compiled, apiKey, {
|
|
788
1020
|
message: input.message,
|
|
789
1021
|
// M35 — pass images through so the SDK send uses the structured `{ text, images }` form.
|
|
790
|
-
...input.images !== void 0 ? {
|
|
1022
|
+
...input.images !== void 0 ? {
|
|
1023
|
+
images: input.images
|
|
1024
|
+
} : {},
|
|
791
1025
|
sessionId,
|
|
792
1026
|
hitl,
|
|
793
|
-
signal: input.signal
|
|
1027
|
+
signal: input.signal,
|
|
1028
|
+
...input.onRunEvent !== void 0 ? {
|
|
1029
|
+
onRunEvent: input.onRunEvent
|
|
1030
|
+
} : {}
|
|
794
1031
|
});
|
|
795
1032
|
})();
|
|
796
1033
|
}
|
|
1034
|
+
__name(streamAgentTurnInProcess, "streamAgentTurnInProcess");
|
|
797
1035
|
|
|
798
1036
|
// src/index.ts
|
|
1037
|
+
import { applySecurityFloor, auditEnvReachability, foldLayers, recordWiring, resolveTrustPosture, verifyLayerOrdering } from "@theokit/sdk";
|
|
1038
|
+
import { GenerateObjectError, LayerOrderError, StreamObjectError, ToolError, UngatedCapabilityError } from "@theokit/sdk";
|
|
799
1039
|
var Agent = AgentDoSdk;
|
|
800
1040
|
export {
|
|
801
1041
|
AGENT_BRAND,
|
|
@@ -824,12 +1064,14 @@ export {
|
|
|
824
1064
|
DelegationBudgetExceededError,
|
|
825
1065
|
DelegationError,
|
|
826
1066
|
FieldCapability,
|
|
1067
|
+
GenerateObjectError,
|
|
827
1068
|
GoalRunner,
|
|
828
1069
|
GuardrailViolationError,
|
|
829
1070
|
GuardrailsCapability,
|
|
830
1071
|
HumanInTheLoopCapability,
|
|
831
1072
|
InProcessApprovalRequiredError,
|
|
832
1073
|
JudgeCredentialError,
|
|
1074
|
+
LayerOrderError,
|
|
833
1075
|
MCP_PROTOCOL_VERSION,
|
|
834
1076
|
MainLoopCapability,
|
|
835
1077
|
McpFileError,
|
|
@@ -845,18 +1087,24 @@ export {
|
|
|
845
1087
|
SkillsOptionsCapability,
|
|
846
1088
|
SkillsResolverCapability,
|
|
847
1089
|
Squad,
|
|
1090
|
+
StreamObjectError,
|
|
848
1091
|
SubAgent,
|
|
849
1092
|
SubAgentsCapability,
|
|
850
1093
|
Tool,
|
|
1094
|
+
ToolError,
|
|
851
1095
|
ToolboxCapability,
|
|
852
1096
|
ToolsCapability,
|
|
853
1097
|
Toolset,
|
|
854
1098
|
ToolsetError,
|
|
1099
|
+
UngatedCapabilityError,
|
|
855
1100
|
UnknownCapabilityError,
|
|
1101
|
+
UntrustedSettingSourceError,
|
|
856
1102
|
BudgetExceededError2 as WindowBudgetExceededError,
|
|
857
1103
|
agentsPlugin,
|
|
858
1104
|
applyCapabilities,
|
|
1105
|
+
applySecurityFloor,
|
|
859
1106
|
assertNoSymlinkEscape,
|
|
1107
|
+
auditEnvReachability,
|
|
860
1108
|
buildAgentCard,
|
|
861
1109
|
buildMcpToolDescriptors,
|
|
862
1110
|
buildModelSelection,
|
|
@@ -883,6 +1131,7 @@ export {
|
|
|
883
1131
|
encodeAcpMessage,
|
|
884
1132
|
estimateTokens,
|
|
885
1133
|
extractThinkTagStream,
|
|
1134
|
+
foldLayers,
|
|
886
1135
|
generateAgentManifest,
|
|
887
1136
|
generateAgentRoutes,
|
|
888
1137
|
isAgentContext,
|
|
@@ -911,12 +1160,15 @@ export {
|
|
|
911
1160
|
projectContextMetadataOnlyKnobs,
|
|
912
1161
|
promptInjectionDetector,
|
|
913
1162
|
reasoningEffortOf,
|
|
1163
|
+
recordWiring,
|
|
914
1164
|
reflectionStrategyConfigSchema,
|
|
915
1165
|
resolveCompactionStrategy,
|
|
916
1166
|
resolveEffectiveContextWindow,
|
|
917
1167
|
resolveEnabledSkills,
|
|
918
1168
|
resolveLoopStrategy,
|
|
919
1169
|
resolveMcpServers,
|
|
1170
|
+
resolveSettingSources,
|
|
1171
|
+
resolveTrustPosture,
|
|
920
1172
|
runInputGuards,
|
|
921
1173
|
runOutputGuards,
|
|
922
1174
|
runWithApiErrorHandling,
|
|
@@ -930,6 +1182,7 @@ export {
|
|
|
930
1182
|
tokenBudgetCompactionStrategy,
|
|
931
1183
|
translateSdkEvent,
|
|
932
1184
|
unicodeNormalizer,
|
|
1185
|
+
verifyLayerOrdering,
|
|
933
1186
|
wellKnownCardPath
|
|
934
1187
|
};
|
|
935
1188
|
//# sourceMappingURL=index.js.map
|