@theokit/sdk 4.5.1 → 4.6.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/index.cjs CHANGED
@@ -9287,22 +9287,84 @@ async function readProjectSubagents(cwd) {
9287
9287
  }
9288
9288
  return subagents;
9289
9289
  }
9290
+ var ACCEPTED_FIELDS = /* @__PURE__ */ new Set([
9291
+ "name",
9292
+ "description",
9293
+ "model",
9294
+ "tools",
9295
+ "reasoning_effort",
9296
+ "mcp",
9297
+ "sandbox"
9298
+ ]);
9290
9299
  function parseSubagentMarkdown(raw, filename) {
9291
9300
  const { frontmatter, body } = splitFrontmatter(raw, filename);
9292
9301
  const fields = parseFrontmatterFields(frontmatter);
9293
- const baseName = filename.replace(/\.md$/, "");
9294
- const name = fields.name ?? baseName;
9302
+ rejectUnknownFields(fields, filename);
9303
+ rejectMcp(fields, filename);
9295
9304
  const definition = {
9296
- description: fields.description ?? "",
9305
+ description: asString(fields.description) ?? "",
9297
9306
  prompt: body
9298
9307
  };
9299
- if (fields.model !== void 0) {
9300
- definition.model = fields.model === "inherit" ? "inherit" : { id: fields.model };
9301
- }
9302
- const tools = fields.tools?.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
9303
- if (tools !== void 0 && tools.length > 0) definition.tools = tools;
9308
+ const model = resolveModel(fields, filename);
9309
+ if (model !== void 0) definition.model = model;
9310
+ const tools = toStringList(fields.tools);
9311
+ if (tools.length > 0) definition.tools = tools;
9312
+ const sandbox = resolveSandbox(fields, filename);
9313
+ if (sandbox !== void 0) definition.sandbox = sandbox;
9314
+ const name = asString(fields.name) ?? filename.replace(/\.md$/, "");
9304
9315
  return { name, definition };
9305
9316
  }
9317
+ function rejectUnknownFields(fields, filename) {
9318
+ for (const key2 of Object.keys(fields)) {
9319
+ if (!ACCEPTED_FIELDS.has(key2)) {
9320
+ throw new exports.ConfigurationError(
9321
+ `Subagent ${filename}: unknown frontmatter field "${key2}" (accepted: ${[...ACCEPTED_FIELDS].join(", ")})`,
9322
+ { code: "subagent_unknown_field" }
9323
+ );
9324
+ }
9325
+ }
9326
+ }
9327
+ function rejectMcp(fields, filename) {
9328
+ if (fields.mcp !== void 0) {
9329
+ throw new exports.ConfigurationError(
9330
+ `Subagent ${filename}: per-subagent "mcp" is not yet supported on the local delegation path; declare MCP servers in .theokit/mcp.json (or the parent) instead`,
9331
+ { code: "subagent_mcp_unsupported_local" }
9332
+ );
9333
+ }
9334
+ }
9335
+ function resolveModel(fields, filename) {
9336
+ const modelId = asString(fields.model);
9337
+ const effort = asString(fields.reasoning_effort);
9338
+ if (effort !== void 0 && modelId === void 0) {
9339
+ throw new exports.ConfigurationError(
9340
+ `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
9341
+ { code: "subagent_reasoning_effort_without_model" }
9342
+ );
9343
+ }
9344
+ if (modelId === void 0) return void 0;
9345
+ if (modelId === "inherit") return "inherit";
9346
+ return effort !== void 0 ? { id: modelId, params: [{ id: "thinking", value: effort }] } : { id: modelId };
9347
+ }
9348
+ function resolveSandbox(fields, filename) {
9349
+ if (fields.sandbox === void 0) return void 0;
9350
+ if (typeof fields.sandbox !== "boolean") {
9351
+ throw new exports.ConfigurationError(
9352
+ `Subagent ${filename}: sandbox must be a boolean (got "${String(fields.sandbox)}"); granular sandbox modes are not supported by the runtime`,
9353
+ { code: "subagent_sandbox_not_boolean" }
9354
+ );
9355
+ }
9356
+ return fields.sandbox;
9357
+ }
9358
+ function asString(v) {
9359
+ return typeof v === "string" ? v : void 0;
9360
+ }
9361
+ function toStringList(v) {
9362
+ if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
9363
+ if (typeof v === "string") {
9364
+ return v.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
9365
+ }
9366
+ return [];
9367
+ }
9306
9368
  function splitFrontmatter(raw, filename) {
9307
9369
  const match = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/.exec(raw);
9308
9370
  if (match === null) {
@@ -9313,12 +9375,7 @@ function splitFrontmatter(raw, filename) {
9313
9375
  return { frontmatter: match[1] ?? "", body: (match[2] ?? "").trim() };
9314
9376
  }
9315
9377
  function parseFrontmatterFields(frontmatter) {
9316
- const raw = parseSimpleYaml(frontmatter);
9317
- const out = {};
9318
- for (const [k, v] of Object.entries(raw)) {
9319
- out[k] = typeof v === "string" ? v : void 0;
9320
- }
9321
- return out;
9378
+ return parseSimpleYaml(frontmatter);
9322
9379
  }
9323
9380
 
9324
9381
  // src/define-tool.ts
@@ -9517,12 +9574,12 @@ init_path_guard();
9517
9574
 
9518
9575
  // src/internal/runtime/skills/skill-frontmatter.ts
9519
9576
  init_errors();
9520
- function asString(v) {
9577
+ function asString2(v) {
9521
9578
  return typeof v === "string" ? v : void 0;
9522
9579
  }
9523
9580
  function toStringFields(raw) {
9524
9581
  const out = {};
9525
- for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
9582
+ for (const [k, v] of Object.entries(raw)) out[k] = asString2(v);
9526
9583
  return out;
9527
9584
  }
9528
9585
  function parseSkillFrontmatter(raw, fallbackName) {
@@ -16406,10 +16463,11 @@ ${lines.join("\n")}
16406
16463
  </subagent-tool-results>`;
16407
16464
  }
16408
16465
  function buildChildCreateOptions(spec, inherited) {
16409
- const model = spec.model ? { id: spec.model } : inherited?.model;
16466
+ const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
16410
16467
  return {
16411
16468
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
16412
16469
  ...model !== void 0 ? { model } : {},
16470
+ ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
16413
16471
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
16414
16472
  systemPrompt: spec.instructions,
16415
16473
  tools: spec.tools ?? []
@@ -16518,7 +16576,10 @@ function subAgentToolsFromDefinitions(agents2, parentTools) {
16518
16576
  name,
16519
16577
  description: def.description,
16520
16578
  instructions: def.prompt,
16521
- ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model.id } : {},
16579
+ // Carry the FULL ModelSelection (id + reasoning params), not just the id, so
16580
+ // per-subagent reasoning effort survives to buildChildCreateOptions.
16581
+ ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model } : {},
16582
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {},
16522
16583
  tools: [...childTools]
16523
16584
  });
16524
16585
  });