@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.d.cts CHANGED
@@ -1,3 +1,3 @@
1
- export { N as Cron } from './cron-CWQPZTwX.cjs';
1
+ export { N as Cron } from './cron-26WH1n7o.cjs';
2
2
  import './run-DFM1H2jW.cjs';
3
3
  import 'zod';
package/dist/cron.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { N as Cron } from './cron-DVM9f1I_.js';
1
+ export { N as Cron } from './cron-D_0p_gXd.js';
2
2
  import './run-DFM1H2jW.js';
3
3
  import 'zod';
package/dist/cron.js CHANGED
@@ -6707,22 +6707,84 @@ async function readProjectSubagents(cwd) {
6707
6707
  }
6708
6708
  return subagents;
6709
6709
  }
6710
+ var ACCEPTED_FIELDS = /* @__PURE__ */ new Set([
6711
+ "name",
6712
+ "description",
6713
+ "model",
6714
+ "tools",
6715
+ "reasoning_effort",
6716
+ "mcp",
6717
+ "sandbox"
6718
+ ]);
6710
6719
  function parseSubagentMarkdown(raw, filename) {
6711
6720
  const { frontmatter, body } = splitFrontmatter(raw, filename);
6712
6721
  const fields = parseFrontmatterFields(frontmatter);
6713
- const baseName = filename.replace(/\.md$/, "");
6714
- const name = fields.name ?? baseName;
6722
+ rejectUnknownFields(fields, filename);
6723
+ rejectMcp(fields, filename);
6715
6724
  const definition = {
6716
- description: fields.description ?? "",
6725
+ description: asString(fields.description) ?? "",
6717
6726
  prompt: body
6718
6727
  };
6719
- if (fields.model !== void 0) {
6720
- definition.model = fields.model === "inherit" ? "inherit" : { id: fields.model };
6721
- }
6722
- const tools = fields.tools?.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6723
- 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$/, "");
6724
6735
  return { name, definition };
6725
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) {
6759
+ throw new ConfigurationError(
6760
+ `Subagent ${filename}: reasoning_effort requires a model (effort is a model parameter)`,
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
+ return typeof v === "string" ? v : void 0;
6780
+ }
6781
+ function toStringList(v) {
6782
+ if (Array.isArray(v)) return v.map((t) => t.trim()).filter((t) => t.length > 0);
6783
+ if (typeof v === "string") {
6784
+ return v.split(/[\s,]+/).map((t) => t.trim()).filter((t) => t.length > 0);
6785
+ }
6786
+ return [];
6787
+ }
6726
6788
  function splitFrontmatter(raw, filename) {
6727
6789
  const match = /^---\s*\n([\s\S]*?)\n---\s*\n([\s\S]*)$/.exec(raw);
6728
6790
  if (match === null) {
@@ -6733,12 +6795,7 @@ function splitFrontmatter(raw, filename) {
6733
6795
  return { frontmatter: match[1] ?? "", body: (match[2] ?? "").trim() };
6734
6796
  }
6735
6797
  function parseFrontmatterFields(frontmatter) {
6736
- const raw = parseSimpleYaml(frontmatter);
6737
- const out = {};
6738
- for (const [k, v] of Object.entries(raw)) {
6739
- out[k] = typeof v === "string" ? v : void 0;
6740
- }
6741
- return out;
6798
+ return parseSimpleYaml(frontmatter);
6742
6799
  }
6743
6800
 
6744
6801
  // src/define-tool.ts
@@ -6936,12 +6993,12 @@ init_errors();
6936
6993
 
6937
6994
  // src/internal/runtime/skills/skill-frontmatter.ts
6938
6995
  init_errors();
6939
- function asString(v) {
6996
+ function asString2(v) {
6940
6997
  return typeof v === "string" ? v : void 0;
6941
6998
  }
6942
6999
  function toStringFields(raw) {
6943
7000
  const out = {};
6944
- for (const [k, v] of Object.entries(raw)) out[k] = asString(v);
7001
+ for (const [k, v] of Object.entries(raw)) out[k] = asString2(v);
6945
7002
  return out;
6946
7003
  }
6947
7004
  function parseSkillFrontmatter(raw, fallbackName) {
@@ -13805,10 +13862,11 @@ ${lines.join("\n")}
13805
13862
  </subagent-tool-results>`;
13806
13863
  }
13807
13864
  function buildChildCreateOptions(spec, inherited) {
13808
- const model = spec.model ? { id: spec.model } : inherited?.model;
13865
+ const model = spec.model !== void 0 ? typeof spec.model === "string" ? { id: spec.model } : spec.model : inherited?.model;
13809
13866
  return {
13810
13867
  ...inherited?.apiKey !== void 0 ? { apiKey: inherited.apiKey } : {},
13811
13868
  ...model !== void 0 ? { model } : {},
13869
+ ...spec.sandbox === true ? { local: { sandboxOptions: { enabled: true } } } : {},
13812
13870
  ...inherited?.plugins !== void 0 ? { plugins: inherited.plugins } : {},
13813
13871
  systemPrompt: spec.instructions,
13814
13872
  tools: spec.tools ?? []
@@ -13917,7 +13975,10 @@ function subAgentToolsFromDefinitions(agents2, parentTools) {
13917
13975
  name,
13918
13976
  description: def.description,
13919
13977
  instructions: def.prompt,
13920
- ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model.id } : {},
13978
+ // Carry the FULL ModelSelection (id + reasoning params), not just the id, so
13979
+ // per-subagent reasoning effort survives to buildChildCreateOptions.
13980
+ ...def.model !== void 0 && def.model !== "inherit" ? { model: def.model } : {},
13981
+ ...def.sandbox !== void 0 ? { sandbox: def.sandbox } : {},
13921
13982
  tools: [...childTools]
13922
13983
  });
13923
13984
  });