@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/cron.cjs CHANGED
@@ -6710,22 +6710,84 @@ async function readProjectSubagents(cwd) {
6710
6710
  }
6711
6711
  return subagents;
6712
6712
  }
6713
+ var ACCEPTED_FIELDS = /* @__PURE__ */ new Set([
6714
+ "name",
6715
+ "description",
6716
+ "model",
6717
+ "tools",
6718
+ "reasoning_effort",
6719
+ "mcp",
6720
+ "sandbox"
6721
+ ]);
6713
6722
  function parseSubagentMarkdown(raw, filename) {
6714
6723
  const { frontmatter, body } = splitFrontmatter(raw, filename);
6715
6724
  const fields = parseFrontmatterFields(frontmatter);
6716
- const baseName = filename.replace(/\.md$/, "");
6717
- const name = fields.name ?? baseName;
6725
+ rejectUnknownFields(fields, filename);
6726
+ rejectMcp(fields, filename);
6718
6727
  const definition = {
6719
- description: fields.description ?? "",
6728
+ description: asString(fields.description) ?? "",
6720
6729
  prompt: body
6721
6730
  };
6722
- if (fields.model !== void 0) {
6723
- definition.model = fields.model === "inherit" ? "inherit" : { id: fields.model };
6724
- }
6725
- const tools = fields.tools?.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6726
- if (tools !== void 0 && tools.length > 0) definition.tools = tools;
6731
+ const model = resolveModel(fields, filename);
6732
+ if (model !== void 0) definition.model = model;
6733
+ const tools = toStringList(fields.tools);
6734
+ if (tools.length > 0) definition.tools = tools;
6735
+ const sandbox = resolveSandbox(fields, filename);
6736
+ if (sandbox !== void 0) definition.sandbox = sandbox;
6737
+ const name = asString(fields.name) ?? filename.replace(/\.md$/, "");
6727
6738
  return { name, definition };
6728
6739
  }
6740
+ function rejectUnknownFields(fields, filename) {
6741
+ for (const key of Object.keys(fields)) {
6742
+ if (!ACCEPTED_FIELDS.has(key)) {
6743
+ throw new ConfigurationError(
6744
+ `Subagent ${filename}: unknown frontmatter field "${key}" (accepted: ${[...ACCEPTED_FIELDS].join(", ")})`,
6745
+ { code: "subagent_unknown_field" }
6746
+ );
6747
+ }
6748
+ }
6749
+ }
6750
+ function rejectMcp(fields, filename) {
6751
+ if (fields.mcp !== void 0) {
6752
+ throw new ConfigurationError(
6753
+ `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`,
6754
+ { code: "subagent_mcp_unsupported_local" }
6755
+ );
6756
+ }
6757
+ }
6758
+ function resolveModel(fields, filename) {
6759
+ const modelId = asString(fields.model);
6760
+ const effort = asString(fields.reasoning_effort);
6761
+ if (effort !== void 0 && modelId === void 0) {
6762
+ throw new ConfigurationError(
6763
+ `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
6764
+ { code: "subagent_reasoning_effort_without_model" }
6765
+ );
6766
+ }
6767
+ if (modelId === void 0) return void 0;
6768
+ if (modelId === "inherit") return "inherit";
6769
+ return effort !== void 0 ? { id: modelId, params: [{ id: "thinking", value: effort }] } : { id: modelId };
6770
+ }
6771
+ function resolveSandbox(fields, filename) {
6772
+ if (fields.sandbox === void 0) return void 0;
6773
+ if (typeof fields.sandbox !== "boolean") {
6774
+ throw new ConfigurationError(
6775
+ `Subagent ${filename}: sandbox must be a boolean (got "${String(fields.sandbox)}"); granular sandbox modes are not supported by the runtime`,
6776
+ { code: "subagent_sandbox_not_boolean" }
6777
+ );
6778
+ }
6779
+ return fields.sandbox;
6780
+ }
6781
+ function asString(v) {
6782
+ return typeof v === "string" ? v : void 0;
6783
+ }
6784
+ function toStringList(v) {
6785
+ if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
6786
+ if (typeof v === "string") {
6787
+ return v.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6788
+ }
6789
+ return [];
6790
+ }
6729
6791
  function splitFrontmatter(raw, filename) {
6730
6792
  const match = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/.exec(raw);
6731
6793
  if (match === null) {
@@ -6736,12 +6798,7 @@ function splitFrontmatter(raw, filename) {
6736
6798
  return { frontmatter: match[1] ?? "", body: (match[2] ?? "").trim() };
6737
6799
  }
6738
6800
  function parseFrontmatterFields(frontmatter) {
6739
- const raw = parseSimpleYaml(frontmatter);
6740
- const out = {};
6741
- for (const [k, v] of Object.entries(raw)) {
6742
- out[k] = typeof v === "string" ? v : void 0;
6743
- }
6744
- return out;
6801
+ return parseSimpleYaml(frontmatter);
6745
6802
  }
6746
6803
 
6747
6804
  // src/define-tool.ts
@@ -6939,12 +6996,12 @@ init_errors();
6939
6996
 
6940
6997
  // src/internal/runtime/skills/skill-frontmatter.ts
6941
6998
  init_errors();
6942
- function asString(v) {
6999
+ function asString2(v) {
6943
7000
  return typeof v === "string" ? v : void 0;
6944
7001
  }
6945
7002
  function toStringFields(raw) {
6946
7003
  const out = {};
6947
- for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
7004
+ for (const [k, v] of Object.entries(raw)) out[k] = asString2(v);
6948
7005
  return out;
6949
7006
  }
6950
7007
  function parseSkillFrontmatter(raw, fallbackName) {
@@ -13808,10 +13865,11 @@ ${lines.join("\n")}
13808
13865
  </subagent-tool-results>`;
13809
13866
  }
13810
13867
  function buildChildCreateOptions(spec, inherited) {
13811
- const model = spec.model ? { id: spec.model } : inherited?.model;
13868
+ const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
13812
13869
  return {
13813
13870
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
13814
13871
  ...model !== void 0 ? { model } : {},
13872
+ ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
13815
13873
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
13816
13874
  systemPrompt: spec.instructions,
13817
13875
  tools: spec.tools ?? []
@@ -13920,7 +13978,10 @@ function subAgentToolsFromDefinitions(agents2, parentTools) {
13920
13978
  name,
13921
13979
  description: def.description,
13922
13980
  instructions: def.prompt,
13923
- ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model.id } : {},
13981
+ // Carry the FULL ModelSelection (id + reasoning params), not just the id, so
13982
+ // per-subagent reasoning effort survives to buildChildCreateOptions.
13983
+ ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model } : {},
13984
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {},
13924
13985
  tools: [...childTools]
13925
13986
  });
13926
13987
  });