@theokit/sdk 2.19.0 → 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/dist/eval.js CHANGED
@@ -2265,6 +2265,24 @@ function salvagePartial(schema, raw) {
2265
2265
  }
2266
2266
  return out;
2267
2267
  }
2268
+ async function runReasoningPhase(options, deps) {
2269
+ const reasoningOptions = {
2270
+ model: options.model,
2271
+ local: options.local,
2272
+ ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
2273
+ ...options.apiKey !== void 0 ? { apiKey: options.apiKey } : {},
2274
+ ...options.providers !== void 0 ? { providers: options.providers } : {}
2275
+ };
2276
+ const reasoningAgent = await deps.create(reasoningOptions);
2277
+ try {
2278
+ const run = await reasoningAgent.send(options.prompt);
2279
+ const result = await run.wait();
2280
+ const text = result.result;
2281
+ return typeof text === "string" ? text : options.prompt;
2282
+ } finally {
2283
+ await disposeAndDeleteTransient(reasoningAgent, deps.delete);
2284
+ }
2285
+ }
2268
2286
  async function generateObjectImpl(options, deps) {
2269
2287
  const { jsonSchema, maxRetries, initialUsage } = setupStructuredOutput(
2270
2288
  options.schema,
@@ -2287,8 +2305,11 @@ async function generateObjectImpl(options, deps) {
2287
2305
  }
2288
2306
  throw new CaptureSentinel(input);
2289
2307
  });
2308
+ const reasoningText = options.structuringModel !== void 0 ? await runReasoningPhase(options, deps) : void 0;
2309
+ const structuringModel = options.structuringModel ?? options.model;
2310
+ const structuringPrompt = reasoningText ?? options.prompt;
2290
2311
  const agentOptions = buildTransientAgentOptions({
2291
- model: options.model,
2312
+ model: structuringModel,
2292
2313
  local: options.local,
2293
2314
  outputTool,
2294
2315
  ...options.systemPrompt !== void 0 ? { systemPrompt: options.systemPrompt } : {},
@@ -2297,7 +2318,7 @@ async function generateObjectImpl(options, deps) {
2297
2318
  });
2298
2319
  const agent = await deps.create(agentOptions);
2299
2320
  try {
2300
- const userMessage = buildToolPrompt(options.prompt);
2321
+ const userMessage = buildToolPrompt(structuringPrompt);
2301
2322
  let lastParseError;
2302
2323
  for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
2303
2324
  capturedRaw = void 0;
@@ -8333,23 +8354,27 @@ function tryParseSkill(raw, fallbackName, source, options) {
8333
8354
 
8334
8355
  // src/internal/runtime/skills/skills-manager.ts
8335
8356
  var SkillsManager = class {
8336
- constructor(cwd, _enabled, settingSourcesIncludeProject) {
8357
+ constructor(cwd, _enabled, settingSourcesIncludeProject, skillsDir, inline) {
8337
8358
  this.cwd = cwd;
8338
8359
  this.settingSourcesIncludeProject = settingSourcesIncludeProject;
8360
+ this.skillsDir = skillsDir;
8361
+ this.inline = inline;
8339
8362
  }
8340
8363
  cwd;
8341
8364
  settingSourcesIncludeProject;
8365
+ skillsDir;
8366
+ inline;
8342
8367
  skills = [];
8343
8368
  async initialize() {
8344
8369
  if (!this.settingSourcesIncludeProject) {
8345
- this.skills = [];
8370
+ this.skills = this.mergeInline([]);
8346
8371
  return;
8347
8372
  }
8348
8373
  await this.refresh();
8349
8374
  }
8350
8375
  async refresh() {
8351
- const skillsRoot = join(this.cwd, ".theokit", "skills");
8352
- this.skills = await discoverSkills(skillsRoot, {
8376
+ const skillsRoot = this.skillsDir ?? join(this.cwd, ".theokit", "skills");
8377
+ const discovered = await discoverSkills(skillsRoot, {
8353
8378
  onInvalidSkill: (info) => {
8354
8379
  process.stderr.write(
8355
8380
  `[theokit-sdk] skill ${info.name} skipped (${info.code}): ${info.message}
@@ -8357,6 +8382,13 @@ var SkillsManager = class {
8357
8382
  );
8358
8383
  }
8359
8384
  });
8385
+ this.skills = this.mergeInline(discovered);
8386
+ }
8387
+ /** M22 — merge inline skills over discovered ones; inline wins on a name conflict. */
8388
+ mergeInline(discovered) {
8389
+ if (this.inline === void 0 || this.inline.length === 0) return discovered;
8390
+ const inlineNames = new Set(this.inline.map((s) => s.name));
8391
+ return [...discovered.filter((s) => !inlineNames.has(s.name)), ...this.inline];
8360
8392
  }
8361
8393
  list() {
8362
8394
  return Promise.resolve(this.skills);
@@ -8401,7 +8433,10 @@ function bootstrapSubmanagers(args) {
8401
8433
  out.skillsManager = new SkillsManager(
8402
8434
  args.workspaceCwd,
8403
8435
  args.options.skills?.enabled,
8404
- args.settingSourcesIncludeProject
8436
+ args.settingSourcesIncludeProject,
8437
+ // M22 — custom skills directory + inline (code-defined) skills.
8438
+ args.options.skills?.skillsDir,
8439
+ args.options.skills?.inline
8405
8440
  );
8406
8441
  const localSkills = out.skillsManager;
8407
8442
  out.skills = { list: () => localSkills.list() };