@theokit/sdk 4.63.3 → 4.63.4
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 +67 -0
- package/dist/{agent-3JK7VXNN.js → agent-A5XMIVNP.js} +6 -6
- package/dist/{agent-3JK7VXNN.js.map → agent-A5XMIVNP.js.map} +1 -1
- package/dist/{agent-PVINJTUR.cjs → agent-UX7WFI6B.cjs} +7 -7
- package/dist/{agent-PVINJTUR.cjs.map → agent-UX7WFI6B.cjs.map} +1 -1
- package/dist/chunk-247ZTLNU.js +73 -0
- package/dist/chunk-247ZTLNU.js.map +1 -0
- package/dist/{chunk-GPKAF7SG.js → chunk-32WTYBUH.js} +3 -3
- package/dist/{chunk-GPKAF7SG.js.map → chunk-32WTYBUH.js.map} +1 -1
- package/dist/{chunk-CQBXOJ6U.cjs → chunk-43ZQRWAP.cjs} +5 -5
- package/dist/{chunk-CQBXOJ6U.cjs.map → chunk-43ZQRWAP.cjs.map} +1 -1
- package/dist/{chunk-JJ3OVRUM.cjs → chunk-7VT4P3Z4.cjs} +136 -35
- package/dist/chunk-7VT4P3Z4.cjs.map +1 -0
- package/dist/chunk-AKJP2STZ.cjs +81 -0
- package/dist/chunk-AKJP2STZ.cjs.map +1 -0
- package/dist/{chunk-ZWRG4NWT.cjs → chunk-GMLBYDW4.cjs} +4 -4
- package/dist/{chunk-ZWRG4NWT.cjs.map → chunk-GMLBYDW4.cjs.map} +1 -1
- package/dist/{chunk-LXI4XZEC.js → chunk-LKBEROHN.js} +3 -3
- package/dist/{chunk-LXI4XZEC.js.map → chunk-LKBEROHN.js.map} +1 -1
- package/dist/{chunk-25BD2R5G.js → chunk-LYTOXSRH.js} +113 -12
- package/dist/chunk-LYTOXSRH.js.map +1 -0
- package/dist/{chunk-K5OJUYSZ.js → chunk-NDGGJQTZ.js} +13 -4
- package/dist/chunk-NDGGJQTZ.js.map +1 -0
- package/dist/{chunk-ZCIRZE37.cjs → chunk-VCLBZAZU.cjs} +14 -5
- package/dist/chunk-VCLBZAZU.cjs.map +1 -0
- package/dist/{context-AGQ3DIZU.cjs → context-WFLTTMK3.cjs} +7 -7
- package/dist/{context-AGQ3DIZU.cjs.map → context-WFLTTMK3.cjs.map} +1 -1
- package/dist/context-WI2DFG7V.js +7 -0
- package/dist/{context-GQRFBCLP.js.map → context-WI2DFG7V.js.map} +1 -1
- package/dist/cron.cjs +6 -6
- package/dist/cron.js +5 -5
- package/dist/eval.cjs +5 -5
- package/dist/eval.js +4 -4
- package/dist/index.cjs +20 -20
- package/dist/index.js +7 -7
- package/dist/internal/agent-loop/replay-messages.d.ts +41 -0
- package/dist/internal/local-agent/local-option-keys.d.ts +2 -0
- package/dist/internal/persistence/index.cjs +4 -4
- package/dist/internal/persistence/index.js +1 -1
- package/dist/internal/runtime/compat/foreign-config-sources.d.ts +92 -0
- package/dist/internal/runtime/hooks/hooks-executor.d.ts +9 -0
- package/dist/internal/runtime/hooks/hooks-source.d.ts +9 -0
- package/dist/subagents-loader-UCNO7FUH.cjs +17 -0
- package/dist/{subagents-loader-YEUFFPAL.cjs.map → subagents-loader-UCNO7FUH.cjs.map} +1 -1
- package/dist/subagents-loader-XP5ERVDZ.js +8 -0
- package/dist/{subagents-loader-CRT5LLL3.js.map → subagents-loader-XP5ERVDZ.js.map} +1 -1
- package/dist/subagents-loader.cjs +3 -3
- package/dist/subagents-loader.js +2 -2
- package/docs/error-codes.md +5 -5
- package/package.json +1 -1
- package/dist/chunk-25BD2R5G.js.map +0 -1
- package/dist/chunk-AQO3NSRG.cjs +0 -41
- package/dist/chunk-AQO3NSRG.cjs.map +0 -1
- package/dist/chunk-JJ3OVRUM.cjs.map +0 -1
- package/dist/chunk-K5OJUYSZ.js.map +0 -1
- package/dist/chunk-UFLD2HEV.js +0 -35
- package/dist/chunk-UFLD2HEV.js.map +0 -1
- package/dist/chunk-ZCIRZE37.cjs.map +0 -1
- package/dist/context-GQRFBCLP.js +0 -7
- package/dist/subagents-loader-CRT5LLL3.js +0 -8
- package/dist/subagents-loader-YEUFFPAL.cjs +0 -17
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { submit, emitRunEvent } from './chunk-A46SWMIF.js';
|
|
2
2
|
import { enqueueSessionWrite, hydrateSession, persistTurnToTranscript, flushSessionWrites, appendSessionMessage, getSessionMessages, discardSession, clearSession } from './chunk-4FFBAUFS.js';
|
|
3
3
|
import { IndexManager } from './chunk-L3MTL4NA.js';
|
|
4
|
-
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-
|
|
4
|
+
import { loadHookConfig, warnOnce, currentPersonalityContext, warnPersonalitySwitchInsideFork } from './chunk-NDGGJQTZ.js';
|
|
5
5
|
import { extractCodePlugins } from './chunk-2SFBB54R.js';
|
|
6
6
|
import { createOpenAiCompatibleRuntime } from './chunk-UBDMVMBZ.js';
|
|
7
7
|
import { persistActiveMemoryTranscript } from './chunk-XO4SOZN6.js';
|
|
@@ -24,8 +24,8 @@ import { expandTilde, defaultBaseDir } from './chunk-UMP6OJIM.js';
|
|
|
24
24
|
import { withFileLock } from './chunk-3O42QOMJ.js';
|
|
25
25
|
import { withCwdMutex } from './chunk-Q5EWJPRY.js';
|
|
26
26
|
import { atomicWriteJson } from './chunk-2GUYQR5P.js';
|
|
27
|
-
import { loadSubagents, pluginBundleDirs } from './chunk-
|
|
28
|
-
import { getTheokitHome, projectConfigRoots, pluginBundleRoots } from './chunk-
|
|
27
|
+
import { loadSubagents, pluginBundleDirs } from './chunk-LKBEROHN.js';
|
|
28
|
+
import { undefinedVariablesIn, getTheokitHome, projectConfigRoots, pluginBundleRoots, adapterForConfigPath } from './chunk-247ZTLNU.js';
|
|
29
29
|
import { readWorkspaceDir, parseSimpleYaml } from './chunk-LXQ6HKPS.js';
|
|
30
30
|
import { resolveEffectiveContextWindow, CONTEXT_WINDOW_FLOOR, CONTEXT_WINDOW_MARGIN } from './chunk-A4JVILQU.js';
|
|
31
31
|
import { parseModelId } from './chunk-R7WIIPUR.js';
|
|
@@ -2595,6 +2595,8 @@ function spawnAndCollect(options) {
|
|
|
2595
2595
|
settle({ stdout, stderr, exitCode: code, timedOut });
|
|
2596
2596
|
});
|
|
2597
2597
|
if (options.stdin !== void 0 && child.stdin !== null) {
|
|
2598
|
+
child.stdin.on("error", () => {
|
|
2599
|
+
});
|
|
2598
2600
|
child.stdin.end(options.stdin);
|
|
2599
2601
|
}
|
|
2600
2602
|
});
|
|
@@ -2647,10 +2649,12 @@ var HooksExecutor = class {
|
|
|
2647
2649
|
}
|
|
2648
2650
|
async executeOne(command, payload) {
|
|
2649
2651
|
const timeoutMs = command.timeoutMs ?? 3e4;
|
|
2652
|
+
const env = runtimeEnvFor(command.sourcePath, this.cwd);
|
|
2650
2653
|
const result = await spawnAndCollect({
|
|
2651
2654
|
command: "sh",
|
|
2652
2655
|
args: ["-c", command.command],
|
|
2653
2656
|
cwd: this.cwd,
|
|
2657
|
+
...Object.keys(env).length > 0 ? { env } : {},
|
|
2654
2658
|
timeoutMs,
|
|
2655
2659
|
stdin: JSON.stringify(payload)
|
|
2656
2660
|
});
|
|
@@ -2661,14 +2665,22 @@ var HooksExecutor = class {
|
|
|
2661
2665
|
return { decision: "deny", reason: `Hook spawn failed: ${result.spawnError.message}` };
|
|
2662
2666
|
}
|
|
2663
2667
|
if (result.exitCode !== 0) {
|
|
2668
|
+
const stderr = result.stderr.trim();
|
|
2669
|
+
const base = stderr.length > 0 ? stderr : `Hook exited with code ${result.exitCode}`;
|
|
2670
|
+
const missing = undefinedVariablesIn(command.command, env);
|
|
2671
|
+
if (missing.length === 0) return { decision: "deny", reason: base };
|
|
2664
2672
|
return {
|
|
2665
2673
|
decision: "deny",
|
|
2666
|
-
reason:
|
|
2674
|
+
reason: `${base} \u2014 this hook came from ${command.sourcePath ?? "an unrecorded source"} and uses ${missing.map((n) => `$${n}`).join(", ")}, which nothing defines here. A variable this runtime does not supply expands to the empty string, so the error above names a path rather than the cause.`
|
|
2667
2675
|
};
|
|
2668
2676
|
}
|
|
2669
2677
|
return parseDecisionFromStdout(result.stdout);
|
|
2670
2678
|
}
|
|
2671
2679
|
};
|
|
2680
|
+
function runtimeEnvFor(sourcePath, cwd) {
|
|
2681
|
+
if (sourcePath === void 0) return {};
|
|
2682
|
+
return adapterForConfigPath(sourcePath)?.runtimeEnv(cwd) ?? {};
|
|
2683
|
+
}
|
|
2672
2684
|
function parseDecisionFromStdout(stdout) {
|
|
2673
2685
|
const trimmed = stdout.trim();
|
|
2674
2686
|
if (trimmed.length === 0) return { decision: "allow" };
|
|
@@ -4811,6 +4823,44 @@ var UsageAccumulator = class {
|
|
|
4811
4823
|
}
|
|
4812
4824
|
};
|
|
4813
4825
|
|
|
4826
|
+
// src/internal/agent-loop/replay-messages.ts
|
|
4827
|
+
function replayMessages(prior) {
|
|
4828
|
+
return prior.flatMap(replayTurn);
|
|
4829
|
+
}
|
|
4830
|
+
function replayTurn(msg) {
|
|
4831
|
+
if (msg.parts === void 0 || msg.parts.length === 0) {
|
|
4832
|
+
return [{ role: msg.role, content: [{ type: "text", text: msg.text }] }];
|
|
4833
|
+
}
|
|
4834
|
+
const { own, results } = splitParts(msg.parts);
|
|
4835
|
+
const out = [];
|
|
4836
|
+
if (own.length > 0) out.push({ role: msg.role, content: own });
|
|
4837
|
+
if (results.length > 0) out.push({ role: "user", content: results });
|
|
4838
|
+
return out;
|
|
4839
|
+
}
|
|
4840
|
+
function splitParts(parts) {
|
|
4841
|
+
const own = [];
|
|
4842
|
+
const results = [];
|
|
4843
|
+
for (const part of parts) {
|
|
4844
|
+
if (part.type === "tool_result") {
|
|
4845
|
+
results.push(toToolResult(part));
|
|
4846
|
+
continue;
|
|
4847
|
+
}
|
|
4848
|
+
if (part.type === "text" && part.text.length === 0) continue;
|
|
4849
|
+
own.push({ ...part });
|
|
4850
|
+
}
|
|
4851
|
+
return { own, results };
|
|
4852
|
+
}
|
|
4853
|
+
function toToolResult(part) {
|
|
4854
|
+
return {
|
|
4855
|
+
type: "tool_result",
|
|
4856
|
+
toolUseId: part.toolUseId,
|
|
4857
|
+
// `SessionMessagePart` holds the blocks readonly and `LlmToolResultPart` takes a mutable array:
|
|
4858
|
+
// same elements, different variance, so the copy is the whole conversion.
|
|
4859
|
+
content: typeof part.content === "string" ? part.content : [...part.content],
|
|
4860
|
+
...part.isError === void 0 ? {} : { isError: part.isError }
|
|
4861
|
+
};
|
|
4862
|
+
}
|
|
4863
|
+
|
|
4814
4864
|
// src/internal/agent-loop/live-events.ts
|
|
4815
4865
|
var LiveEventLog = class extends Array {
|
|
4816
4866
|
/**
|
|
@@ -4962,10 +5012,7 @@ async function initLoopContext(inputs) {
|
|
|
4962
5012
|
buildUserEvent(inputs)
|
|
4963
5013
|
]);
|
|
4964
5014
|
if (inputs.onLoopEvent !== void 0) events.subscribe(inputs.onLoopEvent);
|
|
4965
|
-
const priorMessages = (inputs.priorMessages ?? [])
|
|
4966
|
-
role: msg.role,
|
|
4967
|
-
content: [{ type: "text", text: msg.text }]
|
|
4968
|
-
}));
|
|
5015
|
+
const priorMessages = replayMessages(inputs.priorMessages ?? []);
|
|
4969
5016
|
let memorySystemPromptAdditions;
|
|
4970
5017
|
if (inputs.memoryProvider !== void 0 && memoryProviderHandle !== void 0) {
|
|
4971
5018
|
try {
|
|
@@ -9010,7 +9057,7 @@ async function* localAgentStreamToCompletion(agent, message, options) {
|
|
|
9010
9057
|
async function localAgentFork(parent, options) {
|
|
9011
9058
|
const { forkAgentImpl } = await import('./fork-agent-RSV4E3EA.js');
|
|
9012
9059
|
const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
|
|
9013
|
-
const { withPersonalityContext } = await import('./context-
|
|
9060
|
+
const { withPersonalityContext } = await import('./context-WI2DFG7V.js');
|
|
9014
9061
|
const create = getAgentFacade().create;
|
|
9015
9062
|
return withPersonalityContext(
|
|
9016
9063
|
{ slug: parent.personalitySlugSnapshot, isFork: true },
|
|
@@ -9649,6 +9696,59 @@ function registerRunAsTask(run, agentId, taskOpt, userText) {
|
|
|
9649
9696
|
});
|
|
9650
9697
|
}
|
|
9651
9698
|
|
|
9699
|
+
// src/internal/local-agent/local-option-keys.ts
|
|
9700
|
+
var KNOWN_LOCAL_OPTION_KEYS = /* @__PURE__ */ new Set([
|
|
9701
|
+
"cwd",
|
|
9702
|
+
"settingSources",
|
|
9703
|
+
"sandboxOptions",
|
|
9704
|
+
"sessionDir",
|
|
9705
|
+
"baseDir",
|
|
9706
|
+
"sessionStore"
|
|
9707
|
+
]);
|
|
9708
|
+
var reported = /* @__PURE__ */ new Set();
|
|
9709
|
+
function distance(a, b) {
|
|
9710
|
+
let previous = Array.from({ length: b.length + 1 }, (_, j) => j);
|
|
9711
|
+
for (let i = 1; i <= a.length; i++) {
|
|
9712
|
+
const current = [i, ...new Array(b.length).fill(0)];
|
|
9713
|
+
for (let j = 1; j <= b.length; j++) {
|
|
9714
|
+
const cost = a.charAt(i - 1) === b.charAt(j - 1) ? 0 : 1;
|
|
9715
|
+
current[j] = Math.min(
|
|
9716
|
+
(previous[j] ?? 0) + 1,
|
|
9717
|
+
(current[j - 1] ?? 0) + 1,
|
|
9718
|
+
(previous[j - 1] ?? 0) + cost
|
|
9719
|
+
);
|
|
9720
|
+
}
|
|
9721
|
+
previous = current;
|
|
9722
|
+
}
|
|
9723
|
+
return previous[b.length] ?? 0;
|
|
9724
|
+
}
|
|
9725
|
+
function nearest(key) {
|
|
9726
|
+
let best;
|
|
9727
|
+
let bestDistance = 4;
|
|
9728
|
+
for (const known of KNOWN_LOCAL_OPTION_KEYS) {
|
|
9729
|
+
const d = distance(key.toLowerCase(), known.toLowerCase());
|
|
9730
|
+
if (d < bestDistance) {
|
|
9731
|
+
bestDistance = d;
|
|
9732
|
+
best = known;
|
|
9733
|
+
}
|
|
9734
|
+
}
|
|
9735
|
+
return best;
|
|
9736
|
+
}
|
|
9737
|
+
function reportUnknownLocalOptions(local) {
|
|
9738
|
+
if (local === void 0) return;
|
|
9739
|
+
for (const key of Object.keys(local)) {
|
|
9740
|
+
if (KNOWN_LOCAL_OPTION_KEYS.has(key)) continue;
|
|
9741
|
+
if (reported.has(key)) continue;
|
|
9742
|
+
reported.add(key);
|
|
9743
|
+
const guess = nearest(key);
|
|
9744
|
+
const hint = guess === void 0 ? "" : ` Did you mean \`${guess}\`?`;
|
|
9745
|
+
diag(
|
|
9746
|
+
`[theokit] \`local.${key}\` is not an option this SDK version knows, so it was ignored.${hint}
|
|
9747
|
+
`
|
|
9748
|
+
);
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9751
|
+
|
|
9652
9752
|
// src/internal/local-agent/local-agent.ts
|
|
9653
9753
|
var LocalAgent = class {
|
|
9654
9754
|
agentId;
|
|
@@ -9729,6 +9829,7 @@ var LocalAgent = class {
|
|
|
9729
9829
|
if (sub.skills !== void 0) this.skills = sub.skills;
|
|
9730
9830
|
this.pluginsManager = sub.pluginsManager;
|
|
9731
9831
|
if (sub.plugins !== void 0) this.plugins = sub.plugins;
|
|
9832
|
+
reportUnknownLocalOptions(options.local);
|
|
9732
9833
|
this.hooksExecutor = new HooksExecutor(this.workspaceCwd);
|
|
9733
9834
|
this.memoryGlue = new LocalAgentMemory(options, this.workspaceCwd, this.agentId);
|
|
9734
9835
|
this.defaultMemoryProviderForLoop = createLocalAgentMemoryProvider({
|
|
@@ -10719,7 +10820,7 @@ var Agent = class _Agent {
|
|
|
10719
10820
|
*/
|
|
10720
10821
|
static async describe(agentId) {
|
|
10721
10822
|
const agent = await getRegisteredAgentOrThrow(agentId);
|
|
10722
|
-
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-
|
|
10823
|
+
const { loadSubagents: loadSubagents2 } = await import('./subagents-loader-XP5ERVDZ.js');
|
|
10723
10824
|
const settingSources = agent.options.local?.settingSources;
|
|
10724
10825
|
const subagents = await loadSubagents2(
|
|
10725
10826
|
agent.cwd ?? process.cwd(),
|
|
@@ -10794,5 +10895,5 @@ async function openLocalStore(reg) {
|
|
|
10794
10895
|
}
|
|
10795
10896
|
|
|
10796
10897
|
export { Agent, AgentBuilder, DEFAULT_AGENTIC_MODEL_ID, MEMORY_EMBEDDING_ADAPTERS, Tool, ToolError, UsageAccumulator, computeCost, generateCronId, getPricingEntry, openRouterMemoryEmbeddingProviderAdapter };
|
|
10797
|
-
//# sourceMappingURL=chunk-
|
|
10798
|
-
//# sourceMappingURL=chunk-
|
|
10898
|
+
//# sourceMappingURL=chunk-LYTOXSRH.js.map
|
|
10899
|
+
//# sourceMappingURL=chunk-LYTOXSRH.js.map
|