@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/cron.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export {
|
|
1
|
+
import './run-BgfBWX-z.cjs';
|
|
2
|
+
export { N as Cron } from './cron-B8fqui49.cjs';
|
package/dist/cron.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import './run-
|
|
2
|
-
export {
|
|
1
|
+
import './run-BgfBWX-z.js';
|
|
2
|
+
export { N as Cron } from './cron-D2yLOrk2.js';
|
package/dist/cron.js
CHANGED
|
@@ -2253,6 +2253,37 @@ __export(generate_object_exports, {
|
|
|
2253
2253
|
GenerateObjectError: () => GenerateObjectError,
|
|
2254
2254
|
generateObjectImpl: () => generateObjectImpl
|
|
2255
2255
|
});
|
|
2256
|
+
function salvagePartial(schema, raw) {
|
|
2257
|
+
if (typeof raw !== "object" || raw === null) return raw;
|
|
2258
|
+
const shape = schema.shape;
|
|
2259
|
+
if (shape === void 0 || typeof shape !== "object") return raw;
|
|
2260
|
+
const rawObj = raw;
|
|
2261
|
+
const out = {};
|
|
2262
|
+
for (const [key, fieldSchema] of Object.entries(shape)) {
|
|
2263
|
+
if (typeof fieldSchema?.safeParse !== "function") continue;
|
|
2264
|
+
const parsed = fieldSchema.safeParse(rawObj[key]);
|
|
2265
|
+
if (parsed.success) out[key] = parsed.data;
|
|
2266
|
+
}
|
|
2267
|
+
return out;
|
|
2268
|
+
}
|
|
2269
|
+
async function runReasoningPhase(options, deps) {
|
|
2270
|
+
const reasoningOptions = {
|
|
2271
|
+
model: options.model,
|
|
2272
|
+
local: options.local,
|
|
2273
|
+
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
2274
|
+
...options.apiKey !== void 0 ? { apiKey: options.apiKey } : {},
|
|
2275
|
+
...options.providers !== void 0 ? { providers: options.providers } : {}
|
|
2276
|
+
};
|
|
2277
|
+
const reasoningAgent = await deps.create(reasoningOptions);
|
|
2278
|
+
try {
|
|
2279
|
+
const run = await reasoningAgent.send(options.prompt);
|
|
2280
|
+
const result = await run.wait();
|
|
2281
|
+
const text = result.result;
|
|
2282
|
+
return typeof text === "string" ? text : options.prompt;
|
|
2283
|
+
} finally {
|
|
2284
|
+
await disposeAndDeleteTransient(reasoningAgent, deps.delete);
|
|
2285
|
+
}
|
|
2286
|
+
}
|
|
2256
2287
|
async function generateObjectImpl(options, deps) {
|
|
2257
2288
|
const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
|
|
2258
2289
|
options.schema,
|
|
@@ -2275,8 +2306,11 @@ async function generateObjectImpl(options, deps) {
|
|
|
2275
2306
|
}
|
|
2276
2307
|
throw new CaptureSentinel(input);
|
|
2277
2308
|
});
|
|
2309
|
+
const reasoningText = options.structuringModel !== void 0 ? await runReasoningPhase(options, deps) : void 0;
|
|
2310
|
+
const structuringModel = options.structuringModel ?? options.model;
|
|
2311
|
+
const structuringPrompt = reasoningText ?? options.prompt;
|
|
2278
2312
|
const agentOptions = buildTransientAgentOptions({
|
|
2279
|
-
model:
|
|
2313
|
+
model: structuringModel,
|
|
2280
2314
|
local: options.local,
|
|
2281
2315
|
outputTool,
|
|
2282
2316
|
...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
|
|
@@ -2285,7 +2319,7 @@ async function generateObjectImpl(options, deps) {
|
|
|
2285
2319
|
});
|
|
2286
2320
|
const agent = await deps.create(agentOptions);
|
|
2287
2321
|
try {
|
|
2288
|
-
const userMessage = buildToolPrompt(
|
|
2322
|
+
const userMessage = buildToolPrompt(structuringPrompt);
|
|
2289
2323
|
let lastParseError;
|
|
2290
2324
|
for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
|
|
2291
2325
|
capturedRaw = void 0;
|
|
@@ -2319,6 +2353,22 @@ async function generateObjectImpl(options, deps) {
|
|
|
2319
2353
|
}
|
|
2320
2354
|
lastParseError = parsed.error;
|
|
2321
2355
|
}
|
|
2356
|
+
if (options.errorStrategy === "return-raw") {
|
|
2357
|
+
return {
|
|
2358
|
+
object: capturedRaw,
|
|
2359
|
+
raw: capturedRaw,
|
|
2360
|
+
usage: lastUsage,
|
|
2361
|
+
finishReason: "tool_use"
|
|
2362
|
+
};
|
|
2363
|
+
}
|
|
2364
|
+
if (options.errorStrategy === "return-partial") {
|
|
2365
|
+
return {
|
|
2366
|
+
object: salvagePartial(options.schema, capturedRaw),
|
|
2367
|
+
raw: capturedRaw,
|
|
2368
|
+
usage: lastUsage,
|
|
2369
|
+
finishReason: "tool_use"
|
|
2370
|
+
};
|
|
2371
|
+
}
|
|
2322
2372
|
throw new GenerateObjectError(
|
|
2323
2373
|
"parse_failed",
|
|
2324
2374
|
"Schema parse failed after all retries.",
|
|
@@ -8309,23 +8359,27 @@ function tryParseSkill(raw, fallbackName, source, options) {
|
|
|
8309
8359
|
|
|
8310
8360
|
// src/internal/runtime/skills/skills-manager.ts
|
|
8311
8361
|
var SkillsManager = class {
|
|
8312
|
-
constructor(cwd, _enabled, settingSourcesIncludeProject) {
|
|
8362
|
+
constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
|
|
8313
8363
|
this.cwd = cwd;
|
|
8314
8364
|
this.settingSourcesIncludeProject = settingSourcesIncludeProject;
|
|
8365
|
+
this.skillsDir = skillsDir;
|
|
8366
|
+
this.inline = inline;
|
|
8315
8367
|
}
|
|
8316
8368
|
cwd;
|
|
8317
8369
|
settingSourcesIncludeProject;
|
|
8370
|
+
skillsDir;
|
|
8371
|
+
inline;
|
|
8318
8372
|
skills = [];
|
|
8319
8373
|
async initialize() {
|
|
8320
8374
|
if (!this.settingSourcesIncludeProject) {
|
|
8321
|
-
this.skills = [];
|
|
8375
|
+
this.skills = this.mergeInline([]);
|
|
8322
8376
|
return;
|
|
8323
8377
|
}
|
|
8324
8378
|
await this.refresh();
|
|
8325
8379
|
}
|
|
8326
8380
|
async refresh() {
|
|
8327
|
-
const skillsRoot = join(this.cwd, ".theokit", "skills");
|
|
8328
|
-
|
|
8381
|
+
const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
|
|
8382
|
+
const discovered = await discoverSkills(skillsRoot, {
|
|
8329
8383
|
onInvalidSkill: (info) => {
|
|
8330
8384
|
process.stderr.write(
|
|
8331
8385
|
`[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
|
|
@@ -8333,6 +8387,13 @@ var SkillsManager = class {
|
|
|
8333
8387
|
);
|
|
8334
8388
|
}
|
|
8335
8389
|
});
|
|
8390
|
+
this.skills = this.mergeInline(discovered);
|
|
8391
|
+
}
|
|
8392
|
+
/** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
|
|
8393
|
+
mergeInline(discovered) {
|
|
8394
|
+
if (this.inline === void 0 || this.inline.length === 0) return discovered;
|
|
8395
|
+
const inlineNames = new Set(this.inline.map((s) => s.name));
|
|
8396
|
+
return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
|
|
8336
8397
|
}
|
|
8337
8398
|
list() {
|
|
8338
8399
|
return Promise.resolve(this.skills);
|
|
@@ -8377,7 +8438,10 @@ function bootstrapSubmanagers(args) {
|
|
|
8377
8438
|
out.skillsManager = new SkillsManager(
|
|
8378
8439
|
args.workspaceCwd,
|
|
8379
8440
|
args.options.skills?.enabled,
|
|
8380
|
-
args.settingSourcesIncludeProject
|
|
8441
|
+
args.settingSourcesIncludeProject,
|
|
8442
|
+
// M22 — custom skills directory + inline (code-defined) skills.
|
|
8443
|
+
args.options.skills?.skillsDir,
|
|
8444
|
+
args.options.skills?.inline
|
|
8381
8445
|
);
|
|
8382
8446
|
const localSkills = out.skillsManager;
|
|
8383
8447
|
out.skills = { list: () => localSkills.list() };
|
|
@@ -9217,22 +9281,23 @@ async function executeTool(inputs, resolved, call) {
|
|
|
9217
9281
|
return { stdout: "", stderr: `Unknown tool ${call.name}`, exitCode: 127 };
|
|
9218
9282
|
}
|
|
9219
9283
|
if (resolved.origin === "shell") return runShellTool(inputs, call);
|
|
9220
|
-
if (resolved.origin === "memory") return runMemoryTool(resolved, call);
|
|
9221
|
-
if (resolved.origin === "custom")
|
|
9284
|
+
if (resolved.origin === "memory") return runMemoryTool(resolved, call, inputs.context);
|
|
9285
|
+
if (resolved.origin === "custom")
|
|
9286
|
+
return runCustomTool(resolved, call, inputs.signal, inputs.context);
|
|
9222
9287
|
return runMcpTool(inputs, resolved, call);
|
|
9223
9288
|
}
|
|
9224
|
-
async function runMemoryTool(resolved, call) {
|
|
9225
|
-
return runHandlerTool("memory", resolved.memoryHandler, call);
|
|
9289
|
+
async function runMemoryTool(resolved, call, context) {
|
|
9290
|
+
return runHandlerTool("memory", resolved.memoryHandler, call, void 0, context);
|
|
9226
9291
|
}
|
|
9227
|
-
async function runCustomTool(resolved, call, signal) {
|
|
9228
|
-
return runHandlerTool("custom", resolved.customHandler, call, signal);
|
|
9292
|
+
async function runCustomTool(resolved, call, signal, context) {
|
|
9293
|
+
return runHandlerTool("custom", resolved.customHandler, call, signal, context);
|
|
9229
9294
|
}
|
|
9230
|
-
async function runHandlerTool(kind, handler, call, signal) {
|
|
9295
|
+
async function runHandlerTool(kind, handler, call, signal, context) {
|
|
9231
9296
|
if (handler === void 0) {
|
|
9232
9297
|
return { stdout: "", stderr: `${kind} tool ${call.name} has no handler`, exitCode: 127 };
|
|
9233
9298
|
}
|
|
9234
9299
|
try {
|
|
9235
|
-
const stdout = await handler(call.input, { signal });
|
|
9300
|
+
const stdout = await handler(call.input, { signal, context });
|
|
9236
9301
|
return { stdout, stderr: "", exitCode: 0 };
|
|
9237
9302
|
} catch (cause) {
|
|
9238
9303
|
const message = cause instanceof Error ? cause.message : String(cause);
|
|
@@ -13115,6 +13180,9 @@ function buildLoopInputs(options, runId, userText) {
|
|
|
13115
13180
|
// D318 — forward SendOptions.signal to the agent loop so streamLlmTurn
|
|
13116
13181
|
// can attach it to the LLM `fetch({ signal })` call.
|
|
13117
13182
|
...options.sendOptions.signal !== void 0 ? { signal: options.sendOptions.signal } : {},
|
|
13183
|
+
// M7 — forward SendOptions.context to the loop so every tool handler receives
|
|
13184
|
+
// it on `ctx.context` (shared run config set once, e.g. projectRoot).
|
|
13185
|
+
...options.sendOptions.context !== void 0 ? { context: options.sendOptions.context } : {},
|
|
13118
13186
|
// #58 / #57 — forward the per-tool timeout + tool-result guard so a consumer
|
|
13119
13187
|
// can enable them via SendOptions (not only internal AgentLoopInputs).
|
|
13120
13188
|
...options.sendOptions.perToolTimeoutMs !== void 0 ? { perToolTimeoutMs: options.sendOptions.perToolTimeoutMs } : {},
|