@theokit/sdk 2.2.0 → 2.4.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 +122 -0
- package/dist/a2a/index.cjs +191 -48
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +192 -49
- package/dist/a2a/index.js.map +1 -1
- package/dist/compaction.cjs +78 -0
- package/dist/compaction.cjs.map +1 -0
- package/dist/compaction.d.cts +76 -0
- package/dist/compaction.d.ts +76 -0
- package/dist/compaction.js +70 -0
- package/dist/compaction.js.map +1 -0
- package/dist/{cron-JSPSFczQ.d.cts → cron-B656C3iq.d.cts} +28 -2
- package/dist/{cron-Aksw2Hy4.d.ts → cron-CM2M9mhB.d.ts} +28 -2
- package/dist/cron.cjs +192 -57
- 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 +192 -57
- package/dist/cron.js.map +1 -1
- package/dist/{errors-Bcw_Pakm.d.ts → errors-DG_7CAUg.d.ts} +1 -1
- package/dist/{errors-Vhg6ZV4o.d.cts → errors-QDYUPABr.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +192 -57
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +192 -57
- package/dist/eval.js.map +1 -1
- package/dist/index.cjs +275 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -7
- package/dist/index.d.ts +50 -7
- package/dist/index.js +275 -69
- package/dist/index.js.map +1 -1
- package/dist/internal/agent-loop/loop.d.ts +5 -0
- package/dist/internal/llm/model-capabilities.d.ts +40 -0
- package/dist/internal/llm/model-identifier.d.ts +9 -1
- package/dist/internal/llm/model-option.d.ts +38 -0
- package/dist/internal/runtime/compression/compression-attempt.d.ts +24 -0
- package/dist/internal/runtime/compression/compression-config.d.ts +33 -0
- package/dist/internal/runtime/compression/compression-decision.d.ts +10 -0
- package/dist/internal/runtime/compression/compression-helpers.d.ts +18 -0
- package/dist/internal/runtime/compression/compression-model-registry.d.ts +41 -0
- package/dist/internal/runtime/compression/compression-summarizer.d.ts +29 -0
- package/dist/internal/runtime/context/project-instructions.d.ts +66 -0
- package/dist/internal/runtime/context/replay-history.d.ts +43 -0
- package/dist/internal/runtime/hooks/hooks-frontmatter.d.ts +1 -1
- package/dist/internal/runtime/lifecycle/run-to-completion.d.ts +22 -0
- package/dist/internal/runtime/skills/discover-skills.d.ts +68 -0
- package/dist/internal/runtime/skills/skills-block.d.ts +18 -0
- package/dist/internal/runtime/skills/subagent-tool-scope.d.ts +25 -0
- package/dist/messages.cjs +24 -0
- package/dist/messages.cjs.map +1 -0
- package/dist/messages.d.cts +33 -0
- package/dist/messages.d.ts +33 -0
- package/dist/messages.js +20 -0
- package/dist/messages.js.map +1 -0
- package/dist/models.cjs +233 -0
- package/dist/models.cjs.map +1 -0
- package/dist/models.d.cts +16 -0
- package/dist/models.d.ts +16 -0
- package/dist/models.js +228 -0
- package/dist/models.js.map +1 -0
- package/dist/project.cjs +149 -0
- package/dist/project.cjs.map +1 -0
- package/dist/project.d.cts +14 -0
- package/dist/project.d.ts +14 -0
- package/dist/project.js +146 -0
- package/dist/project.js.map +1 -0
- package/dist/{run-ekGKZlmg.d.cts → run-BPRYG1Id.d.cts} +55 -2
- package/dist/{run-ekGKZlmg.d.ts → run-BPRYG1Id.d.ts} +55 -2
- package/dist/skills.cjs +282 -0
- package/dist/skills.cjs.map +1 -0
- package/dist/skills.d.cts +19 -0
- package/dist/skills.d.ts +19 -0
- package/dist/skills.js +279 -0
- package/dist/skills.js.map +1 -0
- package/dist/subagents.cjs +24 -0
- package/dist/subagents.cjs.map +1 -0
- package/dist/subagents.d.cts +14 -0
- package/dist/subagents.d.ts +14 -0
- package/dist/subagents.js +21 -0
- package/dist/subagents.js.map +1 -0
- package/dist/types/agent.d.ts +22 -0
- package/dist/types/conversation-storage.d.ts +5 -1
- package/dist/types/run.d.ts +54 -1
- package/package.json +62 -2
package/dist/eval.js
CHANGED
|
@@ -1436,6 +1436,71 @@ var init_agent_factory_registry = __esm({
|
|
|
1436
1436
|
}
|
|
1437
1437
|
});
|
|
1438
1438
|
|
|
1439
|
+
// src/internal/runtime/lifecycle/run-to-completion.ts
|
|
1440
|
+
var run_to_completion_exports = {};
|
|
1441
|
+
__export(run_to_completion_exports, {
|
|
1442
|
+
classifyRound: () => classifyRound,
|
|
1443
|
+
runToCompletionImpl: () => runToCompletionImpl
|
|
1444
|
+
});
|
|
1445
|
+
function isEmptyRound(result) {
|
|
1446
|
+
return (result.result ?? "").trim() === "";
|
|
1447
|
+
}
|
|
1448
|
+
function classifyRound(result, round, maxRounds, emptyStreak) {
|
|
1449
|
+
if (result.stoppedAtIterationLimit !== true) return "done";
|
|
1450
|
+
if (isEmptyRound(result) && emptyStreak >= 1) return "no_progress";
|
|
1451
|
+
if (round >= maxRounds) return "step_limit";
|
|
1452
|
+
return "continue";
|
|
1453
|
+
}
|
|
1454
|
+
function addUsage(acc, u) {
|
|
1455
|
+
if (u === void 0) return acc;
|
|
1456
|
+
const inputTokens = (acc?.inputTokens ?? 0) + u.inputTokens;
|
|
1457
|
+
const outputTokens = (acc?.outputTokens ?? 0) + u.outputTokens;
|
|
1458
|
+
const sumOpt = (a, b) => a === void 0 && b === void 0 ? void 0 : (a ?? 0) + (b ?? 0);
|
|
1459
|
+
return {
|
|
1460
|
+
inputTokens,
|
|
1461
|
+
outputTokens,
|
|
1462
|
+
totalTokens: inputTokens + outputTokens,
|
|
1463
|
+
cacheReadTokens: sumOpt(acc?.cacheReadTokens, u.cacheReadTokens),
|
|
1464
|
+
cacheWriteTokens: sumOpt(acc?.cacheWriteTokens, u.cacheWriteTokens),
|
|
1465
|
+
reasoningTokens: sumOpt(acc?.reasoningTokens, u.reasoningTokens)
|
|
1466
|
+
};
|
|
1467
|
+
}
|
|
1468
|
+
function buildResult(terminal, rounds, lastResult, usage) {
|
|
1469
|
+
return { terminal, rounds, lastResult, ...usage !== void 0 ? { usage } : {} };
|
|
1470
|
+
}
|
|
1471
|
+
async function stepRound(agent, prompt, sendOptions, round, maxRounds, state2) {
|
|
1472
|
+
const run = await agent.send(prompt, sendOptions);
|
|
1473
|
+
const result = await run.wait();
|
|
1474
|
+
const usage = addUsage(state2.usage, result.usage);
|
|
1475
|
+
const decision = classifyRound(result, round, maxRounds, state2.emptyStreak);
|
|
1476
|
+
if (decision !== "continue") return { terminal: buildResult(decision, round, result, usage) };
|
|
1477
|
+
const emptyStreak = isEmptyRound(result) ? state2.emptyStreak + 1 : 0;
|
|
1478
|
+
return { next: { usage, emptyStreak }, lastResult: result };
|
|
1479
|
+
}
|
|
1480
|
+
async function runToCompletionImpl(agent, message, options) {
|
|
1481
|
+
const maxRounds = options?.maxRounds ?? DEFAULT_MAX_ROUNDS;
|
|
1482
|
+
const continuationPrompt = options?.continuationPrompt ?? DEFAULT_CONTINUATION_PROMPT;
|
|
1483
|
+
const { onTruncated, signal, sendOptions } = options ?? {};
|
|
1484
|
+
let state2 = { usage: void 0, emptyStreak: 0 };
|
|
1485
|
+
for (let round = 0; ; round += 1) {
|
|
1486
|
+
const prompt = round === 0 ? message : continuationPrompt;
|
|
1487
|
+
const outcome = await stepRound(agent, prompt, sendOptions, round, maxRounds, state2);
|
|
1488
|
+
if ("terminal" in outcome) return outcome.terminal;
|
|
1489
|
+
state2 = outcome.next;
|
|
1490
|
+
await onTruncated?.({ round });
|
|
1491
|
+
if (signal?.aborted === true) {
|
|
1492
|
+
return buildResult("step_limit", round, outcome.lastResult, state2.usage);
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
var DEFAULT_MAX_ROUNDS, DEFAULT_CONTINUATION_PROMPT;
|
|
1497
|
+
var init_run_to_completion = __esm({
|
|
1498
|
+
"src/internal/runtime/lifecycle/run-to-completion.ts"() {
|
|
1499
|
+
DEFAULT_MAX_ROUNDS = 5;
|
|
1500
|
+
DEFAULT_CONTINUATION_PROMPT = "Continue from where you left off and finish the task. If it is already complete, give the final answer.";
|
|
1501
|
+
}
|
|
1502
|
+
});
|
|
1503
|
+
|
|
1439
1504
|
// src/internal/runtime/lifecycle/fork-agent.ts
|
|
1440
1505
|
var fork_agent_exports = {};
|
|
1441
1506
|
__export(fork_agent_exports, {
|
|
@@ -4859,6 +4924,18 @@ var CloudAgent = class {
|
|
|
4859
4924
|
"fork"
|
|
4860
4925
|
);
|
|
4861
4926
|
}
|
|
4927
|
+
/**
|
|
4928
|
+
* The continuation driver re-sends against a stateful local session; the
|
|
4929
|
+
* cloud runtime manages its own continuation policy server-side (M1 Phase 3).
|
|
4930
|
+
*
|
|
4931
|
+
* @public
|
|
4932
|
+
*/
|
|
4933
|
+
runToCompletion() {
|
|
4934
|
+
throw new UnsupportedRunOperationError(
|
|
4935
|
+
"Agent.runToCompletion() is not supported on cloud agents. Cloud runtime manages continuation server-side. Use a local agent.",
|
|
4936
|
+
"runToCompletion"
|
|
4937
|
+
);
|
|
4938
|
+
}
|
|
4862
4939
|
/**
|
|
4863
4940
|
* Personality presets require consistent server-side enforcement that
|
|
4864
4941
|
* the cloud runtime (pre-release) does not yet provide. Reject explicitly
|
|
@@ -6419,6 +6496,8 @@ function parseSubagentMarkdown(raw, filename) {
|
|
|
6419
6496
|
if (fields.model !== void 0) {
|
|
6420
6497
|
definition.model = fields.model === "inherit" ? "inherit" : { id: fields.model };
|
|
6421
6498
|
}
|
|
6499
|
+
const tools = fields.tools?.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
|
|
6500
|
+
if (tools !== void 0 && tools.length > 0) definition.tools = tools;
|
|
6422
6501
|
return { name, definition };
|
|
6423
6502
|
}
|
|
6424
6503
|
function splitFrontmatter2(raw, filename) {
|
|
@@ -6582,21 +6661,24 @@ ${lines.join("\n")}
|
|
|
6582
6661
|
}
|
|
6583
6662
|
};
|
|
6584
6663
|
|
|
6664
|
+
// src/internal/runtime/skills/skills-block.ts
|
|
6665
|
+
function buildSkillsBlock(skills) {
|
|
6666
|
+
if (skills.length === 0) return void 0;
|
|
6667
|
+
const lines = skills.map(
|
|
6668
|
+
(skill) => ` - ${escapeBlockBody(skill.name)}: ${escapeBlockBody(skill.description)}`
|
|
6669
|
+
);
|
|
6670
|
+
return `<skills>
|
|
6671
|
+
${lines.join("\n")}
|
|
6672
|
+
</skills>`;
|
|
6673
|
+
}
|
|
6674
|
+
|
|
6585
6675
|
// src/internal/runtime/system-prompt/sources/skills-provider.ts
|
|
6586
6676
|
var SkillsPromptProvider = class {
|
|
6587
6677
|
id = "skills";
|
|
6588
6678
|
priority = 20;
|
|
6589
6679
|
contribute(ctx) {
|
|
6590
6680
|
if (ctx.skillsAutoInject === false) return Promise.resolve(void 0);
|
|
6591
|
-
|
|
6592
|
-
const lines = ctx.skills.map((skill) => {
|
|
6593
|
-
const name = escapeBlockBody(skill.name);
|
|
6594
|
-
const description = escapeBlockBody(skill.description);
|
|
6595
|
-
return ` - ${name}: ${description}`;
|
|
6596
|
-
});
|
|
6597
|
-
return Promise.resolve(`<skills>
|
|
6598
|
-
${lines.join("\n")}
|
|
6599
|
-
</skills>`);
|
|
6681
|
+
return Promise.resolve(buildSkillsBlock(ctx.skills));
|
|
6600
6682
|
}
|
|
6601
6683
|
};
|
|
6602
6684
|
|
|
@@ -7704,7 +7786,7 @@ async function loadPluginManifestFromMarkdown(pluginsRoot, folderName) {
|
|
|
7704
7786
|
return metadata;
|
|
7705
7787
|
}
|
|
7706
7788
|
|
|
7707
|
-
// src/internal/runtime/skills/skills
|
|
7789
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
7708
7790
|
init_errors();
|
|
7709
7791
|
|
|
7710
7792
|
// src/internal/runtime/skills/skill-frontmatter.ts
|
|
@@ -7776,6 +7858,61 @@ function hasContent(value) {
|
|
|
7776
7858
|
return value !== void 0 && value.trim().length > 0;
|
|
7777
7859
|
}
|
|
7778
7860
|
|
|
7861
|
+
// src/internal/runtime/skills/discover-skills.ts
|
|
7862
|
+
async function discoverSkills(dir, options) {
|
|
7863
|
+
let entries;
|
|
7864
|
+
try {
|
|
7865
|
+
entries = await readWorkspaceDir(dir, "skills_read_error", "skills directory");
|
|
7866
|
+
} catch {
|
|
7867
|
+
return [];
|
|
7868
|
+
}
|
|
7869
|
+
const skills = [];
|
|
7870
|
+
for (const entry of entries) {
|
|
7871
|
+
if (!entry.isDirectory()) continue;
|
|
7872
|
+
let skillDir;
|
|
7873
|
+
try {
|
|
7874
|
+
skillDir = safePathJoin(dir, entry.name);
|
|
7875
|
+
assertNoSymlinkEscape(skillDir, dir);
|
|
7876
|
+
} catch {
|
|
7877
|
+
continue;
|
|
7878
|
+
}
|
|
7879
|
+
const skillPath = join(skillDir, "SKILL.md");
|
|
7880
|
+
let raw;
|
|
7881
|
+
try {
|
|
7882
|
+
raw = await readFile(skillPath, "utf8");
|
|
7883
|
+
} catch {
|
|
7884
|
+
continue;
|
|
7885
|
+
}
|
|
7886
|
+
const skill = tryParseSkill(raw, entry.name, skillPath, options);
|
|
7887
|
+
if (skill !== void 0) skills.push(skill);
|
|
7888
|
+
}
|
|
7889
|
+
return skills;
|
|
7890
|
+
}
|
|
7891
|
+
function tryParseSkill(raw, fallbackName, source, options) {
|
|
7892
|
+
try {
|
|
7893
|
+
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
7894
|
+
const skill = {
|
|
7895
|
+
name: frontmatter.name,
|
|
7896
|
+
description: frontmatter.description,
|
|
7897
|
+
source
|
|
7898
|
+
};
|
|
7899
|
+
if (frontmatter.category !== void 0) skill.category = frontmatter.category;
|
|
7900
|
+
if (frontmatter.dependencies !== void 0) skill.dependencies = frontmatter.dependencies;
|
|
7901
|
+
return skill;
|
|
7902
|
+
} catch (cause) {
|
|
7903
|
+
if (cause instanceof ConfigurationError) {
|
|
7904
|
+
options?.onInvalidSkill?.({
|
|
7905
|
+
name: fallbackName,
|
|
7906
|
+
source,
|
|
7907
|
+
code: cause.code ?? "unknown",
|
|
7908
|
+
message: cause.message
|
|
7909
|
+
});
|
|
7910
|
+
return void 0;
|
|
7911
|
+
}
|
|
7912
|
+
throw cause;
|
|
7913
|
+
}
|
|
7914
|
+
}
|
|
7915
|
+
|
|
7779
7916
|
// src/internal/runtime/skills/skills-manager.ts
|
|
7780
7917
|
var SkillsManager = class {
|
|
7781
7918
|
constructor(cwd, _enabled, settingSourcesIncludeProject) {
|
|
@@ -7793,56 +7930,20 @@ var SkillsManager = class {
|
|
|
7793
7930
|
await this.refresh();
|
|
7794
7931
|
}
|
|
7795
7932
|
async refresh() {
|
|
7796
|
-
this.skills = [];
|
|
7797
7933
|
const skillsRoot = join(this.cwd, ".theokit", "skills");
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
assertNoSymlinkEscape(skillDir, skillsRoot);
|
|
7805
|
-
} catch {
|
|
7806
|
-
continue;
|
|
7807
|
-
}
|
|
7808
|
-
const skillPath = join(skillDir, "SKILL.md");
|
|
7809
|
-
let raw;
|
|
7810
|
-
try {
|
|
7811
|
-
raw = await readFile(skillPath, "utf8");
|
|
7812
|
-
} catch {
|
|
7813
|
-
continue;
|
|
7934
|
+
this.skills = await discoverSkills(skillsRoot, {
|
|
7935
|
+
onInvalidSkill: (info) => {
|
|
7936
|
+
process.stderr.write(
|
|
7937
|
+
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
7938
|
+
`
|
|
7939
|
+
);
|
|
7814
7940
|
}
|
|
7815
|
-
|
|
7816
|
-
if (metadata !== void 0) this.skills.push(metadata);
|
|
7817
|
-
}
|
|
7941
|
+
});
|
|
7818
7942
|
}
|
|
7819
7943
|
list() {
|
|
7820
7944
|
return Promise.resolve(this.skills);
|
|
7821
7945
|
}
|
|
7822
7946
|
};
|
|
7823
|
-
function tryParseSkill(raw, fallbackName, source) {
|
|
7824
|
-
try {
|
|
7825
|
-
const frontmatter = parseSkillFrontmatter(raw, fallbackName);
|
|
7826
|
-
const metadata = {
|
|
7827
|
-
name: frontmatter.name,
|
|
7828
|
-
description: frontmatter.description,
|
|
7829
|
-
source
|
|
7830
|
-
};
|
|
7831
|
-
if (frontmatter.category !== void 0) metadata.category = frontmatter.category;
|
|
7832
|
-
if (frontmatter.dependencies !== void 0) metadata.dependencies = frontmatter.dependencies;
|
|
7833
|
-
return metadata;
|
|
7834
|
-
} catch (cause) {
|
|
7835
|
-
if (cause instanceof ConfigurationError) {
|
|
7836
|
-
const code = cause.code ?? "unknown";
|
|
7837
|
-
process.stderr.write(
|
|
7838
|
-
`[theokit-sdk] skill ${fallbackName} skipped (${code}): ${cause.message}
|
|
7839
|
-
`
|
|
7840
|
-
);
|
|
7841
|
-
return void 0;
|
|
7842
|
-
}
|
|
7843
|
-
throw cause;
|
|
7844
|
-
}
|
|
7845
|
-
}
|
|
7846
7947
|
|
|
7847
7948
|
// src/internal/runtime/local-agent/local-agent-bootstrap.ts
|
|
7848
7949
|
function registerLocalAgent(args) {
|
|
@@ -8255,6 +8356,7 @@ async function initLoopContext(inputs) {
|
|
|
8255
8356
|
finalStatus: "finished",
|
|
8256
8357
|
usage: new UsageAccumulator(),
|
|
8257
8358
|
nudgeAttempts: 0,
|
|
8359
|
+
stopFeedbackAttempts: 0,
|
|
8258
8360
|
...memoryProviderHandle !== void 0 ? { memoryProviderHandle } : {},
|
|
8259
8361
|
...memorySystemPromptAdditions !== void 0 ? { memorySystemPromptAdditions } : {}
|
|
8260
8362
|
};
|
|
@@ -8399,8 +8501,9 @@ function registerLoopError(ctx, cause) {
|
|
|
8399
8501
|
if (ctx.error !== void 0) return;
|
|
8400
8502
|
const rawMessage = cause?.message;
|
|
8401
8503
|
const message = typeof rawMessage === "string" ? rawMessage : cause instanceof Error ? cause.message : String(cause);
|
|
8504
|
+
const metaCode = cause?.metadata?.code;
|
|
8402
8505
|
const rawCode = cause?.code;
|
|
8403
|
-
const code = typeof rawCode === "string" ? rawCode : void 0;
|
|
8506
|
+
const code = typeof metaCode === "string" ? metaCode : typeof rawCode === "string" ? rawCode : void 0;
|
|
8404
8507
|
ctx.error = code !== void 0 ? { message, code, cause } : { message, cause };
|
|
8405
8508
|
}
|
|
8406
8509
|
async function runCollectorLoop(generator, inputs, ctx) {
|
|
@@ -9196,6 +9299,7 @@ function computeUsageCost(inputs, usage) {
|
|
|
9196
9299
|
|
|
9197
9300
|
// src/internal/agent-loop/loop.ts
|
|
9198
9301
|
var MAX_NUDGE_ATTEMPTS = 2;
|
|
9302
|
+
var MAX_STOP_FEEDBACK_ATTEMPTS = 2;
|
|
9199
9303
|
async function runAgentLoop(inputs) {
|
|
9200
9304
|
const sendSpan = inputs.telemetry?.startSpan("agent.send", {
|
|
9201
9305
|
agentId: inputs.agentId,
|
|
@@ -9353,6 +9457,28 @@ function shouldNudgeAndContinue(ctx, llmOutput) {
|
|
|
9353
9457
|
});
|
|
9354
9458
|
return true;
|
|
9355
9459
|
}
|
|
9460
|
+
async function reflectAfterStop(inputs, ctx) {
|
|
9461
|
+
const result = await inputs.hooks.run({
|
|
9462
|
+
event: "stop",
|
|
9463
|
+
agentId: inputs.agentId,
|
|
9464
|
+
runId: inputs.runId
|
|
9465
|
+
});
|
|
9466
|
+
if (result.blocked) return false;
|
|
9467
|
+
if (ctx.stopFeedbackAttempts >= MAX_STOP_FEEDBACK_ATTEMPTS) return false;
|
|
9468
|
+
const feedback = result.decisions.find(
|
|
9469
|
+
(d) => d.decision === "feedback" && (d.feedback ?? "").length > 0
|
|
9470
|
+
)?.feedback;
|
|
9471
|
+
if (feedback === void 0) return false;
|
|
9472
|
+
ctx.stopFeedbackAttempts += 1;
|
|
9473
|
+
ctx.messages.push({ role: "user", content: [{ type: "text", text: feedback }] });
|
|
9474
|
+
return true;
|
|
9475
|
+
}
|
|
9476
|
+
async function finishOrReflect(inputs, ctx, llmOutput) {
|
|
9477
|
+
if (shouldNudgeAndContinue(ctx, llmOutput)) return "continue";
|
|
9478
|
+
if (await reflectAfterStop(inputs, ctx)) return "continue";
|
|
9479
|
+
ctx.finalStatus = "finished";
|
|
9480
|
+
return "done";
|
|
9481
|
+
}
|
|
9356
9482
|
async function runIteration(inputs, ctx) {
|
|
9357
9483
|
const llmOutput = await streamLlmTurn(inputs, ctx);
|
|
9358
9484
|
accumulateUsage(ctx.usage, llmOutput);
|
|
@@ -9386,9 +9512,7 @@ async function continueOrTerminate(inputs, ctx, llmOutput) {
|
|
|
9386
9512
|
await emitAssistantTextStep(inputs, ctx, llmOutput.text);
|
|
9387
9513
|
}
|
|
9388
9514
|
if (llmOutput.stopReason !== "tool_use" || llmOutput.toolCalls.length === 0) {
|
|
9389
|
-
|
|
9390
|
-
ctx.finalStatus = "finished";
|
|
9391
|
-
return "done";
|
|
9515
|
+
return finishOrReflect(inputs, ctx, llmOutput);
|
|
9392
9516
|
}
|
|
9393
9517
|
ctx.messages.push(buildAssistantTurn(llmOutput.text, llmOutput.toolCalls));
|
|
9394
9518
|
const toolResults = await dispatchTools(inputs, ctx.tools, llmOutput.toolCalls, ctx.events);
|
|
@@ -14339,6 +14463,13 @@ function localAgentRunUntil(agent, goal, options) {
|
|
|
14339
14463
|
}
|
|
14340
14464
|
return wrap();
|
|
14341
14465
|
}
|
|
14466
|
+
function localAgentRunToCompletion(agent, message, options) {
|
|
14467
|
+
async function run() {
|
|
14468
|
+
const { runToCompletionImpl: runToCompletionImpl2 } = await Promise.resolve().then(() => (init_run_to_completion(), run_to_completion_exports));
|
|
14469
|
+
return runToCompletionImpl2({ send: (m, o) => agent.send(m, o) }, message, options);
|
|
14470
|
+
}
|
|
14471
|
+
return run();
|
|
14472
|
+
}
|
|
14342
14473
|
async function localAgentFork(parent, options) {
|
|
14343
14474
|
const { forkAgentImpl: forkAgentImpl2 } = await Promise.resolve().then(() => (init_fork_agent(), fork_agent_exports));
|
|
14344
14475
|
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
@@ -14879,6 +15010,10 @@ var LocalAgent = class {
|
|
|
14879
15010
|
fork(options) {
|
|
14880
15011
|
return localAgentFork({ agentId: this.agentId, options: this.options, personalitySlugSnapshot: this.personalityStore.active(this.agentId) }, options);
|
|
14881
15012
|
}
|
|
15013
|
+
// biome-ignore format: G8 budget — see runUntil comment above.
|
|
15014
|
+
runToCompletion(message, options) {
|
|
15015
|
+
return localAgentRunToCompletion(this, message, options);
|
|
15016
|
+
}
|
|
14882
15017
|
};
|
|
14883
15018
|
function resolveCwd(cwd) {
|
|
14884
15019
|
return (Array.isArray(cwd) ? cwd[0] : cwd) ?? process.cwd();
|