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