@theokit/sdk 2.18.1 → 2.20.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 +14 -0
- package/dist/a2a/index.cjs +83 -15
- package/dist/a2a/index.cjs.map +1 -1
- package/dist/a2a/index.js +83 -15
- package/dist/a2a/index.js.map +1 -1
- package/dist/create-skill.d.ts +29 -0
- package/dist/{cron-Bbg0mBOv.d.ts → cron-B8fqui49.d.cts} +59 -2
- package/dist/{cron-ZLSKbDbB.d.cts → cron-D2yLOrk2.d.ts} +59 -2
- package/dist/cron.cjs +83 -15
- 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 +83 -15
- package/dist/cron.js.map +1 -1
- package/dist/define-tool.d.ts +1 -0
- package/dist/{errors-qyVYfk9H.d.ts → errors-5lj1EWgs.d.ts} +1 -1
- package/dist/{errors-1tVcX3Fq.d.cts → errors-CE-lMBi2.d.cts} +1 -1
- package/dist/errors.d.cts +2 -2
- package/dist/eval.cjs +83 -15
- package/dist/eval.cjs.map +1 -1
- package/dist/eval.js +83 -15
- package/dist/eval.js.map +1 -1
- package/dist/generate-object.d.ts +27 -2
- package/dist/index.cjs +146 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +35 -7
- package/dist/index.d.ts +35 -7
- package/dist/index.js +145 -16
- package/dist/index.js.map +1 -1
- package/dist/{run-pE-34AAo.d.cts → run-BgfBWX-z.d.cts} +13 -1
- package/dist/{run-pE-34AAo.d.ts → run-BgfBWX-z.d.ts} +13 -1
- package/dist/types/agent-prims.d.ts +4 -1
- package/dist/types/agent.d.ts +10 -0
- package/dist/types/run.d.ts +9 -0
- package/package.json +14 -14
package/dist/a2a/index.js
CHANGED
|
@@ -6804,23 +6804,27 @@ var init_skills_manager = __esm({
|
|
|
6804
6804
|
"src/internal/runtime/skills/skills-manager.ts"() {
|
|
6805
6805
|
init_discover_skills();
|
|
6806
6806
|
SkillsManager = class {
|
|
6807
|
-
constructor(cwd, _enabled, settingSourcesIncludeProject) {
|
|
6807
|
+
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
6808
6808
|
this.cwd = cwd;
|
|
6809
6809
|
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
6810
|
+
this.skillsDir = skillsDir;
|
|
6811
|
+
this.inline = inline;
|
|
6810
6812
|
}
|
|
6811
6813
|
cwd;
|
|
6812
6814
|
settingSourcesIncludeProject;
|
|
6815
|
+
skillsDir;
|
|
6816
|
+
inline;
|
|
6813
6817
|
skills = [];
|
|
6814
6818
|
async initialize() {
|
|
6815
6819
|
if (!this.settingSourcesIncludeProject) {
|
|
6816
|
-
this.skills = [];
|
|
6820
|
+
this.skills = this.mergeInline([]);
|
|
6817
6821
|
return;
|
|
6818
6822
|
}
|
|
6819
6823
|
await this.refresh();
|
|
6820
6824
|
}
|
|
6821
6825
|
async refresh() {
|
|
6822
|
-
const skillsRoot = join(this.cwd, ".theokit", "skills");
|
|
6823
|
-
|
|
6826
|
+
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
6827
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
6824
6828
|
onInvalidSkill: (info) => {
|
|
6825
6829
|
process.stderr.write(
|
|
6826
6830
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -6828,6 +6832,13 @@ var init_skills_manager = __esm({
|
|
|
6828
6832
|
);
|
|
6829
6833
|
}
|
|
6830
6834
|
});
|
|
6835
|
+
this.skills = this.mergeInline(discovered);
|
|
6836
|
+
}
|
|
6837
|
+
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
6838
|
+
mergeInline(discovered) {
|
|
6839
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
6840
|
+
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
6841
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
6831
6842
|
}
|
|
6832
6843
|
list() {
|
|
6833
6844
|
return Promise.resolve(this.skills);
|
|
@@ -6874,7 +6885,10 @@ function bootstrapSubmanagers(args) {
|
|
|
6874
6885
|
out.skillsManager = new SkillsManager(
|
|
6875
6886
|
args.workspaceCwd,
|
|
6876
6887
|
args.options.skills?.enabled,
|
|
6877
|
-
args.settingSourcesIncludeProject
|
|
6888
|
+
args.settingSourcesIncludeProject,
|
|
6889
|
+
// M22 — custom skills directory + inline (code-defined) skills.
|
|
6890
|
+
args.options.skills?.skillsDir,
|
|
6891
|
+
args.options.skills?.inline
|
|
6878
6892
|
);
|
|
6879
6893
|
const localSkills = out.skillsManager;
|
|
6880
6894
|
out.skills = { list: () => localSkills.list() };
|
|
@@ -7860,22 +7874,23 @@ async function executeTool(inputs, resolved, call) {
|
|
|
7860
7874
|
return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
|
|
7861
7875
|
}
|
|
7862
7876
|
if (resolved.origin === "shell") return runShellTool(inputs, call);
|
|
7863
|
-
if (resolved.origin === "memory") return runMemoryTool(resolved, call);
|
|
7864
|
-
if (resolved.origin === "custom")
|
|
7877
|
+
if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
|
|
7878
|
+
if (resolved.origin === "custom")
|
|
7879
|
+
return runCustomTool(resolved, call, inputs.signal, inputs.context);
|
|
7865
7880
|
return runMcpTool(inputs, resolved, call);
|
|
7866
7881
|
}
|
|
7867
|
-
async function runMemoryTool(resolved, call) {
|
|
7868
|
-
return runHandlerTool("memory", resolved.memoryHandler, call);
|
|
7882
|
+
async function runMemoryTool(resolved, call, context) {
|
|
7883
|
+
return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
|
|
7869
7884
|
}
|
|
7870
|
-
async function runCustomTool(resolved, call, signal) {
|
|
7871
|
-
return runHandlerTool("custom", resolved.customHandler, call, signal);
|
|
7885
|
+
async function runCustomTool(resolved, call, signal, context) {
|
|
7886
|
+
return runHandlerTool("custom", resolved.customHandler, call, signal, context);
|
|
7872
7887
|
}
|
|
7873
|
-
async function runHandlerTool(kind, handler, call, signal) {
|
|
7888
|
+
async function runHandlerTool(kind, handler, call, signal, context) {
|
|
7874
7889
|
if (handler === void 0) {
|
|
7875
7890
|
return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
|
|
7876
7891
|
}
|
|
7877
7892
|
try {
|
|
7878
|
-
const stdout = await handler(call.input, { signal });
|
|
7893
|
+
const stdout = await handler(call.input, { signal, context });
|
|
7879
7894
|
return { stdout, stderr: "", exitCode: 0 };
|
|
7880
7895
|
} catch (cause) {
|
|
7881
7896
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -12380,6 +12395,9 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
12380
12395
|
// D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
|
|
12381
12396
|
// can attach it to the LLM `fetch({ signal })` call.
|
|
12382
12397
|
...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
|
|
12398
|
+
// M7 — forward SendOptions.context to the loop so every tool handler receives
|
|
12399
|
+
// it on `ctx.context` (shared run config set once, e.g. projectRoot).
|
|
12400
|
+
...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
|
|
12383
12401
|
// #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
|
|
12384
12402
|
// can enable them via SendOptions (not only internal AgentLoopInputs).
|
|
12385
12403
|
...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
|
|
@@ -17150,6 +17168,37 @@ __export(generate_object_exports, {
|
|
|
17150
17168
|
GenerateObjectError: () => GenerateObjectError,
|
|
17151
17169
|
generateObjectImpl: () => generateObjectImpl
|
|
17152
17170
|
});
|
|
17171
|
+
function salvagePartial(schema, raw) {
|
|
17172
|
+
if (typeof raw !== "object" || raw === null) return raw;
|
|
17173
|
+
const shape = schema.shape;
|
|
17174
|
+
if (shape === void 0 || typeof shape !== "object") return raw;
|
|
17175
|
+
const rawObj = raw;
|
|
17176
|
+
const out = {};
|
|
17177
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
17178
|
+
if (typeof fieldSchema?.safeParse !== "function") continue;
|
|
17179
|
+
const parsed = fieldSchema.safeParse(rawObj[key]);
|
|
17180
|
+
if (parsed.success) out[key] = parsed.data;
|
|
17181
|
+
}
|
|
17182
|
+
return out;
|
|
17183
|
+
}
|
|
17184
|
+
async function runReasoningPhase(options, deps) {
|
|
17185
|
+
const reasoningOptions = {
|
|
17186
|
+
model: options.model,
|
|
17187
|
+
local: options.local,
|
|
17188
|
+
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
17189
|
+
...options.apiKey !== void 0 ? { apiKey: options.apiKey } : {},
|
|
17190
|
+
...options.providers !== void 0 ? { providers: options.providers } : {}
|
|
17191
|
+
};
|
|
17192
|
+
const reasoningAgent = await deps.create(reasoningOptions);
|
|
17193
|
+
try {
|
|
17194
|
+
const run = await reasoningAgent.send(options.prompt);
|
|
17195
|
+
const result = await run.wait();
|
|
17196
|
+
const text = result.result;
|
|
17197
|
+
return typeof text === "string" ? text : options.prompt;
|
|
17198
|
+
} finally {
|
|
17199
|
+
await disposeAndDeleteTransient(reasoningAgent, deps.delete);
|
|
17200
|
+
}
|
|
17201
|
+
}
|
|
17153
17202
|
async function generateObjectImpl(options, deps) {
|
|
17154
17203
|
const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
|
|
17155
17204
|
options.schema,
|
|
@@ -17172,8 +17221,11 @@ async function generateObjectImpl(options, deps) {
|
|
|
17172
17221
|
}
|
|
17173
17222
|
throw new CaptureSentinel(input);
|
|
17174
17223
|
});
|
|
17224
|
+
const reasoningText = options.structuringModel !== void 0 ? await runReasoningPhase(options, deps) : void 0;
|
|
17225
|
+
const structuringModel = options.structuringModel ?? options.model;
|
|
17226
|
+
const structuringPrompt = reasoningText ?? options.prompt;
|
|
17175
17227
|
const agentOptions = buildTransientAgentOptions({
|
|
17176
|
-
model:
|
|
17228
|
+
model: structuringModel,
|
|
17177
17229
|
local: options.local,
|
|
17178
17230
|
outputTool,
|
|
17179
17231
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
@@ -17182,7 +17234,7 @@ async function generateObjectImpl(options, deps) {
|
|
|
17182
17234
|
});
|
|
17183
17235
|
const agent = await deps.create(agentOptions);
|
|
17184
17236
|
try {
|
|
17185
|
-
const userMessage = buildToolPrompt(
|
|
17237
|
+
const userMessage = buildToolPrompt(structuringPrompt);
|
|
17186
17238
|
let lastParseError;
|
|
17187
17239
|
for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
|
|
17188
17240
|
capturedRaw = void 0;
|
|
@@ -17216,6 +17268,22 @@ async function generateObjectImpl(options, deps) {
|
|
|
17216
17268
|
}
|
|
17217
17269
|
lastParseError = parsed.error;
|
|
17218
17270
|
}
|
|
17271
|
+
if (options.errorStrategy === "return-raw") {
|
|
17272
|
+
return {
|
|
17273
|
+
object: capturedRaw,
|
|
17274
|
+
raw: capturedRaw,
|
|
17275
|
+
usage: lastUsage,
|
|
17276
|
+
finishReason: "tool_use"
|
|
17277
|
+
};
|
|
17278
|
+
}
|
|
17279
|
+
if (options.errorStrategy === "return-partial") {
|
|
17280
|
+
return {
|
|
17281
|
+
object: salvagePartial(options.schema, capturedRaw),
|
|
17282
|
+
raw: capturedRaw,
|
|
17283
|
+
usage: lastUsage,
|
|
17284
|
+
finishReason: "tool_use"
|
|
17285
|
+
};
|
|
17286
|
+
}
|
|
17219
17287
|
throw new GenerateObjectError(
|
|
17220
17288
|
"parse_failed",
|
|
17221
17289
|
"Schema parse failed after all retries.",
|