@theokit/sdk 4.19.1 → 4.19.3
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/cron-Bhdyjl0B.d.ts +2582 -0
- package/dist/cron-M2Xz7lq2.d.cts +2582 -0
- package/dist/cron.cjs +19 -8
- package/dist/cron.cjs.map +1 -1
- package/dist/cron.d.cts +3 -0
- package/dist/cron.d.ts +3 -0
- package/dist/cron.js +19 -8
- package/dist/cron.js.map +1 -1
- package/dist/errors-CG2RpeW-.d.ts +516 -0
- package/dist/errors-gE8612p9.d.cts +516 -0
- package/dist/errors.d.cts +3 -0
- package/dist/eval.cjs +19 -8
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +19 -8
- package/dist/eval.js.map +1 -1
- package/dist/filesystem/index.cjs +2 -1
- package/dist/filesystem/index.cjs.map +1 -1
- package/dist/filesystem/index.js +2 -1
- package/dist/filesystem/index.js.map +1 -1
- package/dist/goal-loop.d.ts +35 -0
- package/dist/index.cjs +139 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2309 -0
- package/dist/index.d.ts +2309 -0
- package/dist/index.js +139 -130
- package/dist/index.js.map +1 -1
- package/dist/internal/runtime/lifecycle/run-until.d.ts +1 -1
- package/dist/internal/security/index.cjs +2 -1
- package/dist/internal/security/index.cjs.map +1 -1
- package/dist/internal/security/index.js +2 -1
- package/dist/internal/security/index.js.map +1 -1
- package/dist/path-safety.cjs +2 -1
- package/dist/path-safety.cjs.map +1 -1
- package/dist/path-safety.js +2 -1
- package/dist/path-safety.js.map +1 -1
- package/dist/provider-catalog.json +1620 -0
- package/dist/run-DFM1H2jW.d.cts +1589 -0
- package/dist/run-DFM1H2jW.d.ts +1589 -0
- package/dist/skills.cjs +2 -1
- package/dist/skills.cjs.map +1 -1
- package/dist/skills.js +2 -1
- package/dist/skills.js.map +1 -1
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.js.map +1 -1
- package/package.json +13 -12
package/dist/index.js
CHANGED
|
@@ -864,7 +864,8 @@ function safePathJoin(base, ...parts) {
|
|
|
864
864
|
}
|
|
865
865
|
const baseResolved = resolve(base);
|
|
866
866
|
const target = resolve(base, ...parts);
|
|
867
|
-
|
|
867
|
+
const prefix = baseResolved.endsWith(sep) ? baseResolved : baseResolved + sep;
|
|
868
|
+
if (target !== baseResolved && !target.startsWith(prefix)) {
|
|
868
869
|
throw new PathTraversalError(parts.join("/"), target);
|
|
869
870
|
}
|
|
870
871
|
return target;
|
|
@@ -6176,7 +6177,9 @@ function isCompactSummary(content) {
|
|
|
6176
6177
|
function plainText(content) {
|
|
6177
6178
|
if (typeof content === "string") return content;
|
|
6178
6179
|
if (!Array.isArray(content)) return void 0;
|
|
6179
|
-
const texts = content.filter(
|
|
6180
|
+
const texts = content.filter(
|
|
6181
|
+
(p) => p !== null && typeof p === "object" && p.type === "text" && typeof p.text === "string"
|
|
6182
|
+
).map((p) => p.text);
|
|
6180
6183
|
return texts.length > 0 ? texts.join("\n") : void 0;
|
|
6181
6184
|
}
|
|
6182
6185
|
async function compactSessionTranscript(opts) {
|
|
@@ -6297,8 +6300,10 @@ async function autoCompactIfNeeded(opts) {
|
|
|
6297
6300
|
return true;
|
|
6298
6301
|
} catch (cause) {
|
|
6299
6302
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
6300
|
-
process.stderr.write(
|
|
6301
|
-
`)
|
|
6303
|
+
process.stderr.write(
|
|
6304
|
+
`[theokit-sdk] auto-compaction failed (left transcript untouched): ${msg}
|
|
6305
|
+
`
|
|
6306
|
+
);
|
|
6302
6307
|
return false;
|
|
6303
6308
|
}
|
|
6304
6309
|
}
|
|
@@ -6308,11 +6313,11 @@ var init_compact_session = __esm({
|
|
|
6308
6313
|
init_compaction();
|
|
6309
6314
|
init_router();
|
|
6310
6315
|
init_real_local_run_provider();
|
|
6316
|
+
init_session_transcript();
|
|
6311
6317
|
init_providers();
|
|
6312
6318
|
init_compression_model_registry();
|
|
6313
6319
|
init_compression_summarizer();
|
|
6314
6320
|
init_agent_session();
|
|
6315
|
-
init_session_transcript();
|
|
6316
6321
|
COMPACT_SUMMARY_MARKER = "[[theokit:compact-summary]]";
|
|
6317
6322
|
COMPACT_USER_MESSAGE_MAX_TOKENS = 2e4;
|
|
6318
6323
|
autoCompactAttempts = (() => {
|
|
@@ -7501,10 +7506,136 @@ var init_context = __esm({
|
|
|
7501
7506
|
}
|
|
7502
7507
|
});
|
|
7503
7508
|
|
|
7509
|
+
// src/internal/judge/parse-verdict.ts
|
|
7510
|
+
function parseVerdict(text) {
|
|
7511
|
+
const trimmed = text.trim();
|
|
7512
|
+
if (trimmed.startsWith(DONE_PREFIX)) {
|
|
7513
|
+
return {
|
|
7514
|
+
verdict: "done",
|
|
7515
|
+
reason: trimmed.slice(DONE_PREFIX.length).trim(),
|
|
7516
|
+
parseFailed: false
|
|
7517
|
+
};
|
|
7518
|
+
}
|
|
7519
|
+
if (trimmed.startsWith(CONTINUE_PREFIX)) {
|
|
7520
|
+
return {
|
|
7521
|
+
verdict: "continue",
|
|
7522
|
+
reason: trimmed.slice(CONTINUE_PREFIX.length).trim(),
|
|
7523
|
+
parseFailed: false
|
|
7524
|
+
};
|
|
7525
|
+
}
|
|
7526
|
+
if (trimmed.startsWith(SKIPPED_PREFIX)) {
|
|
7527
|
+
return {
|
|
7528
|
+
verdict: "skipped",
|
|
7529
|
+
reason: trimmed.slice(SKIPPED_PREFIX.length).trim(),
|
|
7530
|
+
parseFailed: false
|
|
7531
|
+
};
|
|
7532
|
+
}
|
|
7533
|
+
return {
|
|
7534
|
+
verdict: "continue",
|
|
7535
|
+
reason: `judge response malformed: "${trimmed.slice(0, 100)}"`,
|
|
7536
|
+
parseFailed: true
|
|
7537
|
+
};
|
|
7538
|
+
}
|
|
7539
|
+
var DONE_PREFIX, CONTINUE_PREFIX, SKIPPED_PREFIX;
|
|
7540
|
+
var init_parse_verdict = __esm({
|
|
7541
|
+
"src/internal/judge/parse-verdict.ts"() {
|
|
7542
|
+
DONE_PREFIX = "DONE:";
|
|
7543
|
+
CONTINUE_PREFIX = "CONTINUE:";
|
|
7544
|
+
SKIPPED_PREFIX = "SKIPPED:";
|
|
7545
|
+
}
|
|
7546
|
+
});
|
|
7547
|
+
|
|
7548
|
+
// src/internal/judge/judge-call.ts
|
|
7549
|
+
var judge_call_exports = {};
|
|
7550
|
+
__export(judge_call_exports, {
|
|
7551
|
+
composeJudgePrompt: () => composeJudgePrompt,
|
|
7552
|
+
judgeCallImpl: () => judgeCallImpl
|
|
7553
|
+
});
|
|
7554
|
+
async function judgeCallImpl(ctx, options, deps) {
|
|
7555
|
+
const prompt = composeJudgePrompt(ctx);
|
|
7556
|
+
const apiKey = options?.apiKey ?? process.env.OPENROUTER_API_KEY;
|
|
7557
|
+
if (apiKey === void 0) {
|
|
7558
|
+
return {
|
|
7559
|
+
verdict: "continue",
|
|
7560
|
+
reason: "judge unavailable: OPENROUTER_API_KEY missing and no override passed via options.apiKey",
|
|
7561
|
+
parseFailed: true
|
|
7562
|
+
};
|
|
7563
|
+
}
|
|
7564
|
+
const judgeModel = options?.judgeModel ?? "openai/gpt-4o-mini";
|
|
7565
|
+
let auxAgent;
|
|
7566
|
+
try {
|
|
7567
|
+
auxAgent = await deps.create({
|
|
7568
|
+
apiKey,
|
|
7569
|
+
model: { id: judgeModel },
|
|
7570
|
+
tools: [],
|
|
7571
|
+
local: {},
|
|
7572
|
+
metadata: { forkOrigin: "judge" }
|
|
7573
|
+
});
|
|
7574
|
+
const run = await auxAgent.send(prompt);
|
|
7575
|
+
const result = await run.wait();
|
|
7576
|
+
return parseVerdict(result.result ?? "");
|
|
7577
|
+
} catch (err) {
|
|
7578
|
+
return {
|
|
7579
|
+
verdict: "continue",
|
|
7580
|
+
reason: `judge call failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
7581
|
+
parseFailed: true
|
|
7582
|
+
};
|
|
7583
|
+
} finally {
|
|
7584
|
+
if (auxAgent !== void 0) {
|
|
7585
|
+
try {
|
|
7586
|
+
await auxAgent.dispose();
|
|
7587
|
+
} catch {
|
|
7588
|
+
}
|
|
7589
|
+
}
|
|
7590
|
+
}
|
|
7591
|
+
}
|
|
7592
|
+
function composeJudgePrompt(ctx) {
|
|
7593
|
+
const subgoals = ctx.subgoals !== void 0 && ctx.subgoals.length > 0 ? ctx.subgoals.join(", ") : "(none)";
|
|
7594
|
+
return `You are a goal judge. Determine if this goal is satisfied.
|
|
7595
|
+
|
|
7596
|
+
Goal: ${ctx.goal}
|
|
7597
|
+
Subgoals: ${subgoals}
|
|
7598
|
+
Last agent response: ${ctx.lastResponse}
|
|
7599
|
+
|
|
7600
|
+
Respond with EXACTLY one of:
|
|
7601
|
+
- DONE: <reason>
|
|
7602
|
+
- CONTINUE: <what's left>
|
|
7603
|
+
- SKIPPED: <why not applicable>
|
|
7604
|
+
|
|
7605
|
+
Be strict. If unclear, prefer CONTINUE.`;
|
|
7606
|
+
}
|
|
7607
|
+
var init_judge_call = __esm({
|
|
7608
|
+
"src/internal/judge/judge-call.ts"() {
|
|
7609
|
+
init_parse_verdict();
|
|
7610
|
+
}
|
|
7611
|
+
});
|
|
7612
|
+
|
|
7613
|
+
// src/goal-loop.ts
|
|
7614
|
+
function runGoalLoop(agent, goal, options, depsOverride) {
|
|
7615
|
+
async function* wrap() {
|
|
7616
|
+
const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
|
|
7617
|
+
const deps = depsOverride ?? await (async () => {
|
|
7618
|
+
const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
|
|
7619
|
+
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
7620
|
+
const create = getAgentFacade2().create;
|
|
7621
|
+
return {
|
|
7622
|
+
judge: (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
|
|
7623
|
+
};
|
|
7624
|
+
})();
|
|
7625
|
+
return yield* runUntilImpl2(agent, goal, options, deps);
|
|
7626
|
+
}
|
|
7627
|
+
return wrap();
|
|
7628
|
+
}
|
|
7629
|
+
var GOAL_CONTINUATION_MARKER;
|
|
7630
|
+
var init_goal_loop = __esm({
|
|
7631
|
+
"src/goal-loop.ts"() {
|
|
7632
|
+
GOAL_CONTINUATION_MARKER = "[[theokit:goal-continuation]]";
|
|
7633
|
+
}
|
|
7634
|
+
});
|
|
7635
|
+
|
|
7504
7636
|
// src/internal/runtime/lifecycle/run-until.ts
|
|
7505
7637
|
var run_until_exports = {};
|
|
7506
7638
|
__export(run_until_exports, {
|
|
7507
|
-
GOAL_CONTINUATION_MARKER: () => GOAL_CONTINUATION_MARKER,
|
|
7508
7639
|
composeContinuation: () => composeContinuation,
|
|
7509
7640
|
runUntilImpl: () => runUntilImpl
|
|
7510
7641
|
});
|
|
@@ -7669,114 +7800,9 @@ ${goal}
|
|
|
7669
7800
|
${lastResponse.slice(-1e3)}`
|
|
7670
7801
|
].join("\n");
|
|
7671
7802
|
}
|
|
7672
|
-
var GOAL_CONTINUATION_MARKER;
|
|
7673
7803
|
var init_run_until = __esm({
|
|
7674
7804
|
"src/internal/runtime/lifecycle/run-until.ts"() {
|
|
7675
|
-
|
|
7676
|
-
}
|
|
7677
|
-
});
|
|
7678
|
-
|
|
7679
|
-
// src/internal/judge/parse-verdict.ts
|
|
7680
|
-
function parseVerdict(text) {
|
|
7681
|
-
const trimmed = text.trim();
|
|
7682
|
-
if (trimmed.startsWith(DONE_PREFIX)) {
|
|
7683
|
-
return {
|
|
7684
|
-
verdict: "done",
|
|
7685
|
-
reason: trimmed.slice(DONE_PREFIX.length).trim(),
|
|
7686
|
-
parseFailed: false
|
|
7687
|
-
};
|
|
7688
|
-
}
|
|
7689
|
-
if (trimmed.startsWith(CONTINUE_PREFIX)) {
|
|
7690
|
-
return {
|
|
7691
|
-
verdict: "continue",
|
|
7692
|
-
reason: trimmed.slice(CONTINUE_PREFIX.length).trim(),
|
|
7693
|
-
parseFailed: false
|
|
7694
|
-
};
|
|
7695
|
-
}
|
|
7696
|
-
if (trimmed.startsWith(SKIPPED_PREFIX)) {
|
|
7697
|
-
return {
|
|
7698
|
-
verdict: "skipped",
|
|
7699
|
-
reason: trimmed.slice(SKIPPED_PREFIX.length).trim(),
|
|
7700
|
-
parseFailed: false
|
|
7701
|
-
};
|
|
7702
|
-
}
|
|
7703
|
-
return {
|
|
7704
|
-
verdict: "continue",
|
|
7705
|
-
reason: `judge response malformed: "${trimmed.slice(0, 100)}"`,
|
|
7706
|
-
parseFailed: true
|
|
7707
|
-
};
|
|
7708
|
-
}
|
|
7709
|
-
var DONE_PREFIX, CONTINUE_PREFIX, SKIPPED_PREFIX;
|
|
7710
|
-
var init_parse_verdict = __esm({
|
|
7711
|
-
"src/internal/judge/parse-verdict.ts"() {
|
|
7712
|
-
DONE_PREFIX = "DONE:";
|
|
7713
|
-
CONTINUE_PREFIX = "CONTINUE:";
|
|
7714
|
-
SKIPPED_PREFIX = "SKIPPED:";
|
|
7715
|
-
}
|
|
7716
|
-
});
|
|
7717
|
-
|
|
7718
|
-
// src/internal/judge/judge-call.ts
|
|
7719
|
-
var judge_call_exports = {};
|
|
7720
|
-
__export(judge_call_exports, {
|
|
7721
|
-
composeJudgePrompt: () => composeJudgePrompt,
|
|
7722
|
-
judgeCallImpl: () => judgeCallImpl
|
|
7723
|
-
});
|
|
7724
|
-
async function judgeCallImpl(ctx, options, deps) {
|
|
7725
|
-
const prompt = composeJudgePrompt(ctx);
|
|
7726
|
-
const apiKey = options?.apiKey ?? process.env.OPENROUTER_API_KEY;
|
|
7727
|
-
if (apiKey === void 0) {
|
|
7728
|
-
return {
|
|
7729
|
-
verdict: "continue",
|
|
7730
|
-
reason: "judge unavailable: OPENROUTER_API_KEY missing and no override passed via options.apiKey",
|
|
7731
|
-
parseFailed: true
|
|
7732
|
-
};
|
|
7733
|
-
}
|
|
7734
|
-
const judgeModel = options?.judgeModel ?? "openai/gpt-4o-mini";
|
|
7735
|
-
let auxAgent;
|
|
7736
|
-
try {
|
|
7737
|
-
auxAgent = await deps.create({
|
|
7738
|
-
apiKey,
|
|
7739
|
-
model: { id: judgeModel },
|
|
7740
|
-
tools: [],
|
|
7741
|
-
local: {},
|
|
7742
|
-
metadata: { forkOrigin: "judge" }
|
|
7743
|
-
});
|
|
7744
|
-
const run = await auxAgent.send(prompt);
|
|
7745
|
-
const result = await run.wait();
|
|
7746
|
-
return parseVerdict(result.result ?? "");
|
|
7747
|
-
} catch (err) {
|
|
7748
|
-
return {
|
|
7749
|
-
verdict: "continue",
|
|
7750
|
-
reason: `judge call failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
7751
|
-
parseFailed: true
|
|
7752
|
-
};
|
|
7753
|
-
} finally {
|
|
7754
|
-
if (auxAgent !== void 0) {
|
|
7755
|
-
try {
|
|
7756
|
-
await auxAgent.dispose();
|
|
7757
|
-
} catch {
|
|
7758
|
-
}
|
|
7759
|
-
}
|
|
7760
|
-
}
|
|
7761
|
-
}
|
|
7762
|
-
function composeJudgePrompt(ctx) {
|
|
7763
|
-
const subgoals = ctx.subgoals !== void 0 && ctx.subgoals.length > 0 ? ctx.subgoals.join(", ") : "(none)";
|
|
7764
|
-
return `You are a goal judge. Determine if this goal is satisfied.
|
|
7765
|
-
|
|
7766
|
-
Goal: ${ctx.goal}
|
|
7767
|
-
Subgoals: ${subgoals}
|
|
7768
|
-
Last agent response: ${ctx.lastResponse}
|
|
7769
|
-
|
|
7770
|
-
Respond with EXACTLY one of:
|
|
7771
|
-
- DONE: <reason>
|
|
7772
|
-
- CONTINUE: <what's left>
|
|
7773
|
-
- SKIPPED: <why not applicable>
|
|
7774
|
-
|
|
7775
|
-
Be strict. If unclear, prefer CONTINUE.`;
|
|
7776
|
-
}
|
|
7777
|
-
var init_judge_call = __esm({
|
|
7778
|
-
"src/internal/judge/judge-call.ts"() {
|
|
7779
|
-
init_parse_verdict();
|
|
7805
|
+
init_goal_loop();
|
|
7780
7806
|
}
|
|
7781
7807
|
});
|
|
7782
7808
|
|
|
@@ -22810,24 +22836,7 @@ var EventBus = class {
|
|
|
22810
22836
|
|
|
22811
22837
|
// src/index.ts
|
|
22812
22838
|
init_generate_object();
|
|
22813
|
-
|
|
22814
|
-
// src/goal-loop.ts
|
|
22815
|
-
init_run_until();
|
|
22816
|
-
function runGoalLoop(agent, goal, options, depsOverride) {
|
|
22817
|
-
async function* wrap() {
|
|
22818
|
-
const { runUntilImpl: runUntilImpl2 } = await Promise.resolve().then(() => (init_run_until(), run_until_exports));
|
|
22819
|
-
const deps = depsOverride ?? await (async () => {
|
|
22820
|
-
const { judgeCallImpl: judgeCallImpl2 } = await Promise.resolve().then(() => (init_judge_call(), judge_call_exports));
|
|
22821
|
-
const { getAgentFacade: getAgentFacade2 } = await Promise.resolve().then(() => (init_agent_factory_registry(), agent_factory_registry_exports));
|
|
22822
|
-
const create = getAgentFacade2().create;
|
|
22823
|
-
return {
|
|
22824
|
-
judge: (ctx, opts) => judgeCallImpl2(ctx, opts, { create })
|
|
22825
|
-
};
|
|
22826
|
-
})();
|
|
22827
|
-
return yield* runUntilImpl2(agent, goal, options, deps);
|
|
22828
|
-
}
|
|
22829
|
-
return wrap();
|
|
22830
|
-
}
|
|
22839
|
+
init_goal_loop();
|
|
22831
22840
|
|
|
22832
22841
|
// src/internal/budget/tracker/budget-tracker-counter.ts
|
|
22833
22842
|
function createCounterBudgetTracker(options = {}) {
|