@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/cron.cjs CHANGED
@@ -3277,7 +3277,9 @@ function serializeAgents(agents2) {
3277
3277
  out[name] = {
3278
3278
  description: def.description,
3279
3279
  prompt: def.prompt,
3280
- ...def.model !== void 0 ? { model: def.model } : {}
3280
+ ...def.model !== void 0 ? { model: def.model } : {},
3281
+ ...def.tools !== void 0 ? { tools: def.tools } : {},
3282
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {}
3281
3283
  };
3282
3284
  }
3283
3285
  return out;
@@ -6710,22 +6712,86 @@ async function readProjectSubagents(cwd) {
6710
6712
  }
6711
6713
  return subagents;
6712
6714
  }
6715
+ var ACCEPTED_FIELDS = /* @__PURE__ */ new Set([
6716
+ "name",
6717
+ "description",
6718
+ "model",
6719
+ "tools",
6720
+ "reasoning_effort",
6721
+ "mcp",
6722
+ "sandbox"
6723
+ ]);
6713
6724
  function parseSubagentMarkdown(raw, filename) {
6714
6725
  const { frontmatter, body } = splitFrontmatter(raw, filename);
6715
6726
  const fields = parseFrontmatterFields(frontmatter);
6716
- const baseName = filename.replace(/\.md$/, "");
6717
- const name = fields.name ?? baseName;
6727
+ rejectUnknownFields(fields, filename);
6728
+ rejectMcp(fields, filename);
6718
6729
  const definition = {
6719
- description: fields.description ?? "",
6730
+ description: asString(fields.description) ?? "",
6720
6731
  prompt: body
6721
6732
  };
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;
6733
+ const model = resolveModel(fields, filename);
6734
+ if (model !== void 0) definition.model = model;
6735
+ const tools = toStringList(fields.tools);
6736
+ if (tools.length > 0) definition.tools = tools;
6737
+ const sandbox = resolveSandbox(fields, filename);
6738
+ if (sandbox !== void 0) definition.sandbox = sandbox;
6739
+ const name = asString(fields.name) ?? filename.replace(/\.md$/, "");
6727
6740
  return { name, definition };
6728
6741
  }
6742
+ function rejectUnknownFields(fields, filename) {
6743
+ for (const key of Object.keys(fields)) {
6744
+ if (!ACCEPTED_FIELDS.has(key)) {
6745
+ throw new ConfigurationError(
6746
+ `Subagent ${filename}: unknown frontmatter field "${key}" (accepted: ${[...ACCEPTED_FIELDS].join(", ")})`,
6747
+ { code: "subagent_unknown_field" }
6748
+ );
6749
+ }
6750
+ }
6751
+ }
6752
+ function rejectMcp(fields, filename) {
6753
+ if (fields.mcp !== void 0) {
6754
+ throw new ConfigurationError(
6755
+ `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`,
6756
+ { code: "subagent_mcp_unsupported_local" }
6757
+ );
6758
+ }
6759
+ }
6760
+ function resolveModel(fields, filename) {
6761
+ const modelId = asString(fields.model);
6762
+ const effort = asString(fields.reasoning_effort);
6763
+ if (effort !== void 0 && (modelId === void 0 || modelId === "inherit")) {
6764
+ throw new ConfigurationError(
6765
+ `Subagent ${filename}: reasoning_effort requires a concrete model (effort is a model parameter; an absent model or "inherit" cannot carry it)`,
6766
+ { code: "subagent_reasoning_effort_without_model" }
6767
+ );
6768
+ }
6769
+ if (modelId === void 0) return void 0;
6770
+ if (modelId === "inherit") return "inherit";
6771
+ return effort !== void 0 ? { id: modelId, params: [{ id: "thinking", value: effort }] } : { id: modelId };
6772
+ }
6773
+ function resolveSandbox(fields, filename) {
6774
+ if (fields.sandbox === void 0) return void 0;
6775
+ if (typeof fields.sandbox !== "boolean") {
6776
+ throw new ConfigurationError(
6777
+ `Subagent ${filename}: sandbox must be a boolean (got "${String(fields.sandbox)}"); granular sandbox modes are not supported by the runtime`,
6778
+ { code: "subagent_sandbox_not_boolean" }
6779
+ );
6780
+ }
6781
+ return fields.sandbox;
6782
+ }
6783
+ function asString(v) {
6784
+ if (typeof v !== "string") return void 0;
6785
+ const m = /^(["'])(.*)\1$/.exec(v);
6786
+ return m ? m[2] : v;
6787
+ }
6788
+ function toStringList(v) {
6789
+ if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
6790
+ if (typeof v === "string") {
6791
+ return v.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6792
+ }
6793
+ return [];
6794
+ }
6729
6795
  function splitFrontmatter(raw, filename) {
6730
6796
  const match = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/.exec(raw);
6731
6797
  if (match === null) {
@@ -6736,12 +6802,7 @@ function splitFrontmatter(raw, filename) {
6736
6802
  return { frontmatter: match[1] ?? "", body: (match[2] ?? "").trim() };
6737
6803
  }
6738
6804
  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;
6805
+ return parseSimpleYaml(frontmatter);
6745
6806
  }
6746
6807
 
6747
6808
  // src/define-tool.ts
@@ -6939,12 +7000,12 @@ init_errors();
6939
7000
 
6940
7001
  // src/internal/runtime/skills/skill-frontmatter.ts
6941
7002
  init_errors();
6942
- function asString(v) {
7003
+ function asString2(v) {
6943
7004
  return typeof v === "string" ? v : void 0;
6944
7005
  }
6945
7006
  function toStringFields(raw) {
6946
7007
  const out = {};
6947
- for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
7008
+ for (const [k, v] of Object.entries(raw)) out[k] = asString2(v);
6948
7009
  return out;
6949
7010
  }
6950
7011
  function parseSkillFrontmatter(raw, fallbackName) {
@@ -13808,10 +13869,12 @@ ${lines.join("\n")}
13808
13869
  </subagent-tool-results>`;
13809
13870
  }
13810
13871
  function buildChildCreateOptions(spec, inherited) {
13811
- const model = spec.model ? { id: spec.model } : inherited?.model;
13872
+ const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
13873
+ const sandbox = spec.sandbox ?? inherited?.sandbox;
13812
13874
  return {
13813
13875
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
13814
13876
  ...model !== void 0 ? { model } : {},
13877
+ ...sandbox !== void 0 ? { local: { sandboxOptions: { enabled: sandbox } } } : {},
13815
13878
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
13816
13879
  systemPrompt: spec.instructions,
13817
13880
  tools: spec.tools ?? []
@@ -13920,7 +13983,10 @@ function subAgentToolsFromDefinitions(agents2, parentTools) {
13920
13983
  name,
13921
13984
  description: def.description,
13922
13985
  instructions: def.prompt,
13923
- ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model.id } : {},
13986
+ // Carry the FULL ModelSelection (id + reasoning params), not just the id, so
13987
+ // per-subagent reasoning effort survives to buildChildCreateOptions.
13988
+ ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model } : {},
13989
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {},
13924
13990
  tools: [...childTools]
13925
13991
  });
13926
13992
  });
@@ -13984,10 +14050,12 @@ function declarativeSubagentTools(agents2, parentTools) {
13984
14050
  }
13985
14051
  function bindParentCredentials(tools, agentOptions) {
13986
14052
  const parentPlugins = Array.isArray(agentOptions.plugins) ? agentOptions.plugins : void 0;
14053
+ const parentSandbox = agentOptions.local?.sandboxOptions?.enabled;
13987
14054
  const credentials = {
13988
14055
  ...agentOptions.apiKey !== void 0 ? { apiKey: agentOptions.apiKey } : {},
13989
14056
  ...typeof agentOptions.model === "object" ? { model: agentOptions.model } : {},
13990
- ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {}
14057
+ ...parentPlugins !== void 0 ? { plugins: parentPlugins } : {},
14058
+ ...parentSandbox !== void 0 ? { sandbox: parentSandbox } : {}
13991
14059
  };
13992
14060
  for (const tool of tools) inheritSubAgentCredentials(tool, credentials);
13993
14061
  }