@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/eval.cjs CHANGED
@@ -6705,22 +6705,84 @@ async function readProjectSubagents(cwd) {
6705
6705
  }
6706
6706
  return subagents;
6707
6707
  }
6708
+ var ACCEPTED_FIELDS = /* @__PURE__ */ new Set([
6709
+ "name",
6710
+ "description",
6711
+ "model",
6712
+ "tools",
6713
+ "reasoning_effort",
6714
+ "mcp",
6715
+ "sandbox"
6716
+ ]);
6708
6717
  function parseSubagentMarkdown(raw, filename) {
6709
6718
  const { frontmatter, body } = splitFrontmatter(raw, filename);
6710
6719
  const fields = parseFrontmatterFields(frontmatter);
6711
- const baseName = filename.replace(/\.md$/, "");
6712
- const name = fields.name ?? baseName;
6720
+ rejectUnknownFields(fields, filename);
6721
+ rejectMcp(fields, filename);
6713
6722
  const definition = {
6714
- description: fields.description ?? "",
6723
+ description: asString(fields.description) ?? "",
6715
6724
  prompt: body
6716
6725
  };
6717
- if (fields.model !== void 0) {
6718
- definition.model = fields.model === "inherit" ? "inherit" : { id: fields.model };
6719
- }
6720
- const tools = fields.tools?.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6721
- if (tools !== void 0 && tools.length > 0) definition.tools = tools;
6726
+ const model = resolveModel(fields, filename);
6727
+ if (model !== void 0) definition.model = model;
6728
+ const tools = toStringList(fields.tools);
6729
+ if (tools.length > 0) definition.tools = tools;
6730
+ const sandbox = resolveSandbox(fields, filename);
6731
+ if (sandbox !== void 0) definition.sandbox = sandbox;
6732
+ const name = asString(fields.name) ?? filename.replace(/\.md$/, "");
6722
6733
  return { name, definition };
6723
6734
  }
6735
+ function rejectUnknownFields(fields, filename) {
6736
+ for (const key of Object.keys(fields)) {
6737
+ if (!ACCEPTED_FIELDS.has(key)) {
6738
+ throw new ConfigurationError(
6739
+ `Subagent ${filename}: unknown frontmatter field "${key}" (accepted: ${[...ACCEPTED_FIELDS].join(", ")})`,
6740
+ { code: "subagent_unknown_field" }
6741
+ );
6742
+ }
6743
+ }
6744
+ }
6745
+ function rejectMcp(fields, filename) {
6746
+ if (fields.mcp !== void 0) {
6747
+ throw new ConfigurationError(
6748
+ `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`,
6749
+ { code: "subagent_mcp_unsupported_local" }
6750
+ );
6751
+ }
6752
+ }
6753
+ function resolveModel(fields, filename) {
6754
+ const modelId = asString(fields.model);
6755
+ const effort = asString(fields.reasoning_effort);
6756
+ if (effort !== void 0 && modelId === void 0) {
6757
+ throw new ConfigurationError(
6758
+ `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
6759
+ { code: "subagent_reasoning_effort_without_model" }
6760
+ );
6761
+ }
6762
+ if (modelId === void 0) return void 0;
6763
+ if (modelId === "inherit") return "inherit";
6764
+ return effort !== void 0 ? { id: modelId, params: [{ id: "thinking", value: effort }] } : { id: modelId };
6765
+ }
6766
+ function resolveSandbox(fields, filename) {
6767
+ if (fields.sandbox === void 0) return void 0;
6768
+ if (typeof fields.sandbox !== "boolean") {
6769
+ throw new ConfigurationError(
6770
+ `Subagent ${filename}: sandbox must be a boolean (got "${String(fields.sandbox)}"); granular sandbox modes are not supported by the runtime`,
6771
+ { code: "subagent_sandbox_not_boolean" }
6772
+ );
6773
+ }
6774
+ return fields.sandbox;
6775
+ }
6776
+ function asString(v) {
6777
+ return typeof v === "string" ? v : void 0;
6778
+ }
6779
+ function toStringList(v) {
6780
+ if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
6781
+ if (typeof v === "string") {
6782
+ return v.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6783
+ }
6784
+ return [];
6785
+ }
6724
6786
  function splitFrontmatter(raw, filename) {
6725
6787
  const match = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/.exec(raw);
6726
6788
  if (match === null) {
@@ -6731,12 +6793,7 @@ function splitFrontmatter(raw, filename) {
6731
6793
  return { frontmatter: match[1] ?? "", body: (match[2] ?? "").trim() };
6732
6794
  }
6733
6795
  function parseFrontmatterFields(frontmatter) {
6734
- const raw = parseSimpleYaml(frontmatter);
6735
- const out = {};
6736
- for (const [k, v] of Object.entries(raw)) {
6737
- out[k] = typeof v === "string" ? v : void 0;
6738
- }
6739
- return out;
6796
+ return parseSimpleYaml(frontmatter);
6740
6797
  }
6741
6798
 
6742
6799
  // src/define-tool.ts
@@ -6934,12 +6991,12 @@ init_errors();
6934
6991
 
6935
6992
  // src/internal/runtime/skills/skill-frontmatter.ts
6936
6993
  init_errors();
6937
- function asString(v) {
6994
+ function asString2(v) {
6938
6995
  return typeof v === "string" ? v : void 0;
6939
6996
  }
6940
6997
  function toStringFields(raw) {
6941
6998
  const out = {};
6942
- for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
6999
+ for (const [k, v] of Object.entries(raw)) out[k] = asString2(v);
6943
7000
  return out;
6944
7001
  }
6945
7002
  function parseSkillFrontmatter(raw, fallbackName) {
@@ -13803,10 +13860,11 @@ ${lines.join("\n")}
13803
13860
  </subagent-tool-results>`;
13804
13861
  }
13805
13862
  function buildChildCreateOptions(spec, inherited) {
13806
- const model = spec.model ? { id: spec.model } : inherited?.model;
13863
+ const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
13807
13864
  return {
13808
13865
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
13809
13866
  ...model !== void 0 ? { model } : {},
13867
+ ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
13810
13868
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
13811
13869
  systemPrompt: spec.instructions,
13812
13870
  tools: spec.tools ?? []
@@ -13915,7 +13973,10 @@ function subAgentToolsFromDefinitions(agents2, parentTools) {
13915
13973
  name,
13916
13974
  description: def.description,
13917
13975
  instructions: def.prompt,
13918
- ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model.id } : {},
13976
+ // Carry the FULL ModelSelection (id + reasoning params), not just the id, so
13977
+ // per-subagent reasoning effort survives to buildChildCreateOptions.
13978
+ ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model } : {},
13979
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {},
13919
13980
  tools: [...childTools]
13920
13981
  });
13921
13982
  });