@theokit/sdk 4.5.1 → 4.6.1

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
@@ -3272,7 +3272,9 @@ function serializeAgents(agents2) {
3272
3272
  out[name] = {
3273
3273
  description: def.description,
3274
3274
  prompt: def.prompt,
3275
- ...def.model !== void 0 ? { model: def.model } : {}
3275
+ ...def.model !== void 0 ? { model: def.model } : {},
3276
+ ...def.tools !== void 0 ? { tools: def.tools } : {},
3277
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {}
3276
3278
  };
3277
3279
  }
3278
3280
  return out;
@@ -6705,22 +6707,86 @@ async function readProjectSubagents(cwd) {
6705
6707
  }
6706
6708
  return subagents;
6707
6709
  }
6710
+ var ACCEPTED_FIELDS = /* @__PURE__ */ new Set([
6711
+ "name",
6712
+ "description",
6713
+ "model",
6714
+ "tools",
6715
+ "reasoning_effort",
6716
+ "mcp",
6717
+ "sandbox"
6718
+ ]);
6708
6719
  function parseSubagentMarkdown(raw, filename) {
6709
6720
  const { frontmatter, body } = splitFrontmatter(raw, filename);
6710
6721
  const fields = parseFrontmatterFields(frontmatter);
6711
- const baseName = filename.replace(/\.md$/, "");
6712
- const name = fields.name ?? baseName;
6722
+ rejectUnknownFields(fields, filename);
6723
+ rejectMcp(fields, filename);
6713
6724
  const definition = {
6714
- description: fields.description ?? "",
6725
+ description: asString(fields.description) ?? "",
6715
6726
  prompt: body
6716
6727
  };
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;
6728
+ const model = resolveModel(fields, filename);
6729
+ if (model !== void 0) definition.model = model;
6730
+ const tools = toStringList(fields.tools);
6731
+ if (tools.length > 0) definition.tools = tools;
6732
+ const sandbox = resolveSandbox(fields, filename);
6733
+ if (sandbox !== void 0) definition.sandbox = sandbox;
6734
+ const name = asString(fields.name) ?? filename.replace(/\.md$/, "");
6722
6735
  return { name, definition };
6723
6736
  }
6737
+ function rejectUnknownFields(fields, filename) {
6738
+ for (const key of Object.keys(fields)) {
6739
+ if (!ACCEPTED_FIELDS.has(key)) {
6740
+ throw new ConfigurationError(
6741
+ `Subagent ${filename}: unknown frontmatter field "${key}" (accepted: ${[...ACCEPTED_FIELDS].join(", ")})`,
6742
+ { code: "subagent_unknown_field" }
6743
+ );
6744
+ }
6745
+ }
6746
+ }
6747
+ function rejectMcp(fields, filename) {
6748
+ if (fields.mcp !== void 0) {
6749
+ throw new ConfigurationError(
6750
+ `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`,
6751
+ { code: "subagent_mcp_unsupported_local" }
6752
+ );
6753
+ }
6754
+ }
6755
+ function resolveModel(fields, filename) {
6756
+ const modelId = asString(fields.model);
6757
+ const effort = asString(fields.reasoning_effort);
6758
+ if (effort !== void 0 && (modelId === void 0 || modelId === "inherit")) {
6759
+ throw new ConfigurationError(
6760
+ `Subagent ${filename}: reasoning_effort requires a concrete model (effort is a model parameter; an absent model or "inherit" cannot carry it)`,
6761
+ { code: "subagent_reasoning_effort_without_model" }
6762
+ );
6763
+ }
6764
+ if (modelId === void 0) return void 0;
6765
+ if (modelId === "inherit") return "inherit";
6766
+ return effort !== void 0 ? { id: modelId, params: [{ id: "thinking", value: effort }] } : { id: modelId };
6767
+ }
6768
+ function resolveSandbox(fields, filename) {
6769
+ if (fields.sandbox === void 0) return void 0;
6770
+ if (typeof fields.sandbox !== "boolean") {
6771
+ throw new ConfigurationError(
6772
+ `Subagent ${filename}: sandbox must be a boolean (got "${String(fields.sandbox)}"); granular sandbox modes are not supported by the runtime`,
6773
+ { code: "subagent_sandbox_not_boolean" }
6774
+ );
6775
+ }
6776
+ return fields.sandbox;
6777
+ }
6778
+ function asString(v) {
6779
+ if (typeof v !== "string") return void 0;
6780
+ const m = /^(["'])(.*)\1$/.exec(v);
6781
+ return m ? m[2] : v;
6782
+ }
6783
+ function toStringList(v) {
6784
+ if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
6785
+ if (typeof v === "string") {
6786
+ return v.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6787
+ }
6788
+ return [];
6789
+ }
6724
6790
  function splitFrontmatter(raw, filename) {
6725
6791
  const match = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/.exec(raw);
6726
6792
  if (match === null) {
@@ -6731,12 +6797,7 @@ function splitFrontmatter(raw, filename) {
6731
6797
  return { frontmatter: match[1] ?? "", body: (match[2] ?? "").trim() };
6732
6798
  }
6733
6799
  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;
6800
+ return parseSimpleYaml(frontmatter);
6740
6801
  }
6741
6802
 
6742
6803
  // src/define-tool.ts
@@ -6934,12 +6995,12 @@ init_errors();
6934
6995
 
6935
6996
  // src/internal/runtime/skills/skill-frontmatter.ts
6936
6997
  init_errors();
6937
- function asString(v) {
6998
+ function asString2(v) {
6938
6999
  return typeof v === "string" ? v : void 0;
6939
7000
  }
6940
7001
  function toStringFields(raw) {
6941
7002
  const out = {};
6942
- for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
7003
+ for (const [k, v] of Object.entries(raw)) out[k] = asString2(v);
6943
7004
  return out;
6944
7005
  }
6945
7006
  function parseSkillFrontmatter(raw, fallbackName) {
@@ -13803,10 +13864,12 @@ ${lines.join("\n")}
13803
13864
  </subagent-tool-results>`;
13804
13865
  }
13805
13866
  function buildChildCreateOptions(spec, inherited) {
13806
- const model = spec.model ? { id: spec.model } : inherited?.model;
13867
+ const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
13868
+ const sandbox = spec.sandbox ?? inherited?.sandbox;
13807
13869
  return {
13808
13870
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
13809
13871
  ...model !== void 0 ? { model } : {},
13872
+ ...sandbox !== void 0 ? { local: { sandboxOptions: { enabled: sandbox } } } : {},
13810
13873
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
13811
13874
  systemPrompt: spec.instructions,
13812
13875
  tools: spec.tools ?? []
@@ -13915,7 +13978,10 @@ function subAgentToolsFromDefinitions(agents2, parentTools) {
13915
13978
  name,
13916
13979
  description: def.description,
13917
13980
  instructions: def.prompt,
13918
- ...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 } : {},
13919
13985
  tools: [...childTools]
13920
13986
  });
13921
13987
  });
@@ -13979,10 +14045,12 @@ function declarativeSubagentTools(agents2, parentTools) {
13979
14045
  }
13980
14046
  function bindParentCredentials(tools, agentOptions) {
13981
14047
  const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
14048
+ const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
13982
14049
  const credentials = {
13983
14050
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13984
14051
  ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13985
- ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
14052
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
14053
+ ...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
13986
14054
  };
13987
14055
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13988
14056
  }