@theokit/sdk 2.22.0 → 2.24.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/CHANGELOG.md +52 -0
- package/dist/a2a/index.cjs +43 -15
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +43 -15
- package/dist/a2a/index.js.map +1 -1
- package/dist/a2a/subagent.d.cts +27 -2
- package/dist/a2a/subagent.d.ts +27 -2
- package/dist/{cron-Bpt_1khA.d.cts → cron-Bd2oRD7A.d.cts} +1 -1
- package/dist/{cron-7CruUd_0.d.ts → cron-vjod0qVQ.d.ts} +1 -1
- package/dist/cron.cjs +3 -1
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +2 -2
- package/dist/cron.d.ts +2 -2
- package/dist/cron.js +3 -1
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +33 -20
- package/dist/{errors-CkCaIqVP.d.cts → errors-DIKBXffg.d.cts} +1 -1
- package/dist/{errors-BuwwkrAk.d.ts → errors-DRS-kqOK.d.ts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +3 -1
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +3 -1
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +10 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -26
- package/dist/index.d.ts +37 -26
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/{run-CrIulPF7.d.cts → run-Cr0C6cOM.d.cts} +17 -0
- package/dist/{run-CrIulPF7.d.ts → run-Cr0C6cOM.d.ts} +17 -0
- package/dist/types/run.d.ts +17 -0
- package/dist/workflow.cjs +37 -0
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.d.cts +47 -1
- package/dist/workflow.d.ts +47 -1
- package/dist/workflow.js +37 -2
- package/dist/workflow.js.map +1 -1
- package/package.json +3 -3
package/dist/a2a/index.js
CHANGED
|
@@ -12919,6 +12919,7 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
12919
12919
|
...options.onStep !== void 0 ? { onStep: options.onStep } : {},
|
|
12920
12920
|
...options.onDelta !== void 0 ? { onDelta: options.onDelta } : {},
|
|
12921
12921
|
...options.sendOptions.toolChoice !== void 0 ? { toolChoice: options.sendOptions.toolChoice } : {},
|
|
12922
|
+
...options.sendOptions.activeTools !== void 0 ? { activeTools: options.sendOptions.activeTools } : {},
|
|
12922
12923
|
...options.priorMessages !== void 0 ? { priorMessages: options.priorMessages } : {},
|
|
12923
12924
|
...options.memoryTools !== void 0 && options.memoryTools.length > 0 ? { memoryTools: options.memoryTools } : {},
|
|
12924
12925
|
...buildCustomToolsInput(
|
|
@@ -13018,6 +13019,7 @@ var init_real_local_run = __esm({
|
|
|
13018
13019
|
init_register_plugin_providers();
|
|
13019
13020
|
init_tracer();
|
|
13020
13021
|
init_personality_filter();
|
|
13022
|
+
init_async_local_storage();
|
|
13021
13023
|
init_fixture_run_base();
|
|
13022
13024
|
init_run_registry();
|
|
13023
13025
|
pluginProvidersAnnounced = false;
|
|
@@ -13067,7 +13069,7 @@ var init_real_local_run = __esm({
|
|
|
13067
13069
|
}
|
|
13068
13070
|
async executeAgentLoop(inputs) {
|
|
13069
13071
|
try {
|
|
13070
|
-
const output = await runAgentLoop(inputs);
|
|
13072
|
+
const output = inputs.activeTools !== void 0 ? await withToolWhitelist(new Set(inputs.activeTools), () => runAgentLoop(inputs)) : await runAgentLoop(inputs);
|
|
13071
13073
|
this.applyAgentLoopOutput(output);
|
|
13072
13074
|
this.transitionTo(output.finalStatus);
|
|
13073
13075
|
} catch (cause) {
|
|
@@ -18423,15 +18425,33 @@ var MaxDelegationDepthError = class extends Error {
|
|
|
18423
18425
|
maxDepth;
|
|
18424
18426
|
code = "max_delegation_depth";
|
|
18425
18427
|
};
|
|
18426
|
-
async function applyDelegationStart(spec, input) {
|
|
18428
|
+
async function applyDelegationStart(spec, input, iteration) {
|
|
18427
18429
|
if (spec.onDelegationStart === void 0) return { input };
|
|
18428
|
-
const decision = await spec.onDelegationStart({ input, name: spec.name });
|
|
18430
|
+
const decision = await spec.onDelegationStart({ input, name: spec.name, iteration });
|
|
18429
18431
|
if (decision === void 0) return { input };
|
|
18430
18432
|
if (decision.proceed === false)
|
|
18431
18433
|
return { reject: decision.rejectionReason ?? "(delegation rejected)" };
|
|
18432
|
-
return {
|
|
18434
|
+
return {
|
|
18435
|
+
input: decision.modifiedInput ?? input,
|
|
18436
|
+
...decision.modifiedMaxSteps !== void 0 ? { maxSteps: decision.modifiedMaxSteps } : {}
|
|
18437
|
+
};
|
|
18433
18438
|
}
|
|
18434
|
-
async function
|
|
18439
|
+
async function collectChildToolResults(run) {
|
|
18440
|
+
const lines = [];
|
|
18441
|
+
for await (const event of run.stream()) {
|
|
18442
|
+
if (event.type === "tool_call" && event.status === "completed") {
|
|
18443
|
+
const rendered = typeof event.result === "string" ? event.result : JSON.stringify(event.result ?? null);
|
|
18444
|
+
lines.push(`${event.name}: ${rendered}`);
|
|
18445
|
+
}
|
|
18446
|
+
}
|
|
18447
|
+
if (lines.length === 0) return "";
|
|
18448
|
+
return `
|
|
18449
|
+
|
|
18450
|
+
<subagent-tool-results>
|
|
18451
|
+
${lines.join("\n")}
|
|
18452
|
+
</subagent-tool-results>`;
|
|
18453
|
+
}
|
|
18454
|
+
async function runChildAgent(spec, input, signal, maxSteps) {
|
|
18435
18455
|
const { Agent: Agent2 } = await Promise.resolve().then(() => (init_agent(), agent_exports));
|
|
18436
18456
|
const agent = await Agent2.create({
|
|
18437
18457
|
...spec.model ? { model: { id: spec.model } } : {},
|
|
@@ -18439,17 +18459,22 @@ async function runChildAgent(spec, input, signal) {
|
|
|
18439
18459
|
tools: spec.tools ?? []
|
|
18440
18460
|
});
|
|
18441
18461
|
try {
|
|
18442
|
-
const
|
|
18462
|
+
const sendOptions = {
|
|
18463
|
+
...signal !== void 0 ? { signal } : {},
|
|
18464
|
+
...maxSteps !== void 0 ? { maxIterations: maxSteps } : {}
|
|
18465
|
+
};
|
|
18466
|
+
const run = Object.keys(sendOptions).length > 0 ? await agent.send(input, sendOptions) : await agent.send(input);
|
|
18443
18467
|
const result = await run.wait();
|
|
18444
|
-
|
|
18468
|
+
const text = result.result ?? "(no response)";
|
|
18469
|
+
return spec.includeToolResults === true ? text + await collectChildToolResults(run) : text;
|
|
18445
18470
|
} finally {
|
|
18446
18471
|
agent.dispose();
|
|
18447
18472
|
}
|
|
18448
18473
|
}
|
|
18449
|
-
async function notifyDelegationError(spec, input, error) {
|
|
18474
|
+
async function notifyDelegationError(spec, input, error, iteration) {
|
|
18450
18475
|
if (spec.onDelegationComplete === void 0) return;
|
|
18451
18476
|
try {
|
|
18452
|
-
await spec.onDelegationComplete({ input, name: spec.name, error });
|
|
18477
|
+
await spec.onDelegationComplete({ input, name: spec.name, error, iteration });
|
|
18453
18478
|
} catch {
|
|
18454
18479
|
}
|
|
18455
18480
|
}
|
|
@@ -18464,9 +18489,9 @@ ${preamble}
|
|
|
18464
18489
|
Task:
|
|
18465
18490
|
${input}`;
|
|
18466
18491
|
}
|
|
18467
|
-
async function applyDelegationComplete(spec, input, result) {
|
|
18492
|
+
async function applyDelegationComplete(spec, input, result, iteration) {
|
|
18468
18493
|
if (spec.onDelegationComplete === void 0) return result;
|
|
18469
|
-
const completion = await spec.onDelegationComplete({ input, name: spec.name, result });
|
|
18494
|
+
const completion = await spec.onDelegationComplete({ input, name: spec.name, result, iteration });
|
|
18470
18495
|
return completion?.feedback !== void 0 ? result + completion.feedback : result;
|
|
18471
18496
|
}
|
|
18472
18497
|
function defineSubAgent(spec, _parentDepth = 0) {
|
|
@@ -18478,23 +18503,26 @@ function defineSubAgent(spec, _parentDepth = 0) {
|
|
|
18478
18503
|
const inputSchema = z.object({
|
|
18479
18504
|
input: z.string().describe("Task for the subagent")
|
|
18480
18505
|
});
|
|
18506
|
+
let iteration = 0;
|
|
18481
18507
|
return {
|
|
18482
18508
|
name: spec.name,
|
|
18483
18509
|
description: spec.description,
|
|
18484
18510
|
inputSchema,
|
|
18485
18511
|
handler: async (rawInput, ctx) => {
|
|
18486
18512
|
const { input: parsed } = inputSchema.parse(rawInput);
|
|
18487
|
-
|
|
18513
|
+
iteration += 1;
|
|
18514
|
+
const capturedIteration = iteration;
|
|
18515
|
+
const start = await applyDelegationStart(spec, parsed, capturedIteration);
|
|
18488
18516
|
if ("reject" in start) return start.reject;
|
|
18489
18517
|
const input = applyMessageFilter(spec, start.input, ctx?.messages);
|
|
18490
18518
|
let result;
|
|
18491
18519
|
try {
|
|
18492
|
-
result = await runChildAgent(spec, input, ctx?.signal);
|
|
18520
|
+
result = await runChildAgent(spec, input, ctx?.signal, start.maxSteps);
|
|
18493
18521
|
} catch (error) {
|
|
18494
|
-
await notifyDelegationError(spec, input, error);
|
|
18522
|
+
await notifyDelegationError(spec, input, error, capturedIteration);
|
|
18495
18523
|
throw error;
|
|
18496
18524
|
}
|
|
18497
|
-
return applyDelegationComplete(spec, input, result);
|
|
18525
|
+
return applyDelegationComplete(spec, input, result, capturedIteration);
|
|
18498
18526
|
}
|
|
18499
18527
|
};
|
|
18500
18528
|
}
|