@theokit/sdk 5.0.1 → 5.1.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.
Files changed (98) hide show
  1. package/CHANGELOG.md +267 -0
  2. package/dist/a2a/index.cjs +3 -3
  3. package/dist/a2a/index.js +1 -1
  4. package/dist/a2a/subagent.d.cts +22 -3
  5. package/dist/a2a/subagent.d.ts +22 -3
  6. package/dist/{agent-TKJBWGGQ.cjs → agent-ARLOD4JX.cjs} +9 -9
  7. package/dist/{agent-TKJBWGGQ.cjs.map → agent-ARLOD4JX.cjs.map} +1 -1
  8. package/dist/{agent-UGYIYC3R.js → agent-N6WJ54ML.js} +8 -8
  9. package/dist/{agent-UGYIYC3R.js.map → agent-N6WJ54ML.js.map} +1 -1
  10. package/dist/{chunk-CC7EYKBJ.cjs → chunk-67SBTGMA.cjs} +4 -4
  11. package/dist/{chunk-CC7EYKBJ.cjs.map → chunk-67SBTGMA.cjs.map} +1 -1
  12. package/dist/{chunk-D7WAROJR.js → chunk-AW6F6HZR.js} +3 -3
  13. package/dist/{chunk-D7WAROJR.js.map → chunk-AW6F6HZR.js.map} +1 -1
  14. package/dist/{chunk-6WAKKTBO.js → chunk-CFE6QF2Q.js} +19 -3
  15. package/dist/chunk-CFE6QF2Q.js.map +1 -0
  16. package/dist/{chunk-CQLVA4CO.cjs → chunk-D3CCY3A2.cjs} +60 -53
  17. package/dist/chunk-D3CCY3A2.cjs.map +1 -0
  18. package/dist/{chunk-UFPUHJWS.js → chunk-IUMAQURF.js} +7 -2
  19. package/dist/chunk-IUMAQURF.js.map +1 -0
  20. package/dist/{chunk-LTLPBGHC.cjs → chunk-KGANQYP7.cjs} +5 -5
  21. package/dist/{chunk-LTLPBGHC.cjs.map → chunk-KGANQYP7.cjs.map} +1 -1
  22. package/dist/{chunk-XDANGA2C.js → chunk-LX7SEXOQ.js} +6 -3
  23. package/dist/chunk-LX7SEXOQ.js.map +1 -0
  24. package/dist/{chunk-QME6FDFG.cjs → chunk-NQTD6QOW.cjs} +19 -3
  25. package/dist/chunk-NQTD6QOW.cjs.map +1 -0
  26. package/dist/{chunk-DLRP7BI6.cjs → chunk-NYQ3IS7K.cjs} +3 -3
  27. package/dist/chunk-NYQ3IS7K.cjs.map +1 -0
  28. package/dist/{chunk-7RHC7HMS.js → chunk-OQRGVTQF.js} +3 -3
  29. package/dist/{chunk-7RHC7HMS.js.map → chunk-OQRGVTQF.js.map} +1 -1
  30. package/dist/{chunk-SVWMQCXF.js → chunk-OYD3U3LY.js} +19 -12
  31. package/dist/chunk-OYD3U3LY.js.map +1 -0
  32. package/dist/{chunk-UGRS7ZA7.cjs → chunk-QATRS7JD.cjs} +6 -2
  33. package/dist/chunk-QATRS7JD.cjs.map +1 -0
  34. package/dist/{chunk-DRL7URI4.cjs → chunk-QDM3OHUT.cjs} +7 -2
  35. package/dist/chunk-QDM3OHUT.cjs.map +1 -0
  36. package/dist/{chunk-5AXMNUCY.cjs → chunk-QYLZQ43D.cjs} +5 -5
  37. package/dist/{chunk-5AXMNUCY.cjs.map → chunk-QYLZQ43D.cjs.map} +1 -1
  38. package/dist/{chunk-GUKPXDGJ.js → chunk-WMWEI3NS.js} +3 -3
  39. package/dist/chunk-WMWEI3NS.js.map +1 -0
  40. package/dist/{chunk-YEL3SP6X.js → chunk-XU6MLSC6.js} +3 -3
  41. package/dist/{chunk-YEL3SP6X.js.map → chunk-XU6MLSC6.js.map} +1 -1
  42. package/dist/{context-XQJIGZMR.cjs → context-4QOEWRDF.cjs} +7 -7
  43. package/dist/{context-XQJIGZMR.cjs.map → context-4QOEWRDF.cjs.map} +1 -1
  44. package/dist/context-Z3CFTT3H.js +6 -0
  45. package/dist/{context-FM6UZPTL.js.map → context-Z3CFTT3H.js.map} +1 -1
  46. package/dist/cron.cjs +8 -8
  47. package/dist/cron.js +7 -7
  48. package/dist/eval.cjs +22 -7
  49. package/dist/eval.cjs.map +1 -1
  50. package/dist/eval.js +21 -6
  51. package/dist/eval.js.map +1 -1
  52. package/dist/index.cjs +26 -26
  53. package/dist/index.js +11 -11
  54. package/dist/internal/concurrency/subagent-credentials.d.ts +45 -0
  55. package/dist/internal/persistence/index.cjs +4 -4
  56. package/dist/internal/persistence/index.js +1 -1
  57. package/dist/internal/runtime/registry/agent-registry-store.d.ts +1 -0
  58. package/dist/internal/runtime/skills/discover-skills.d.ts +35 -0
  59. package/dist/judge-call-46M2E5FA.cjs +22 -0
  60. package/dist/{judge-call-I3P4D5QR.cjs.map → judge-call-46M2E5FA.cjs.map} +1 -1
  61. package/dist/judge-call-FGUNNWEI.js +5 -0
  62. package/dist/{judge-call-6MVARKU2.js.map → judge-call-FGUNNWEI.js.map} +1 -1
  63. package/dist/persistence.cjs +8 -0
  64. package/dist/persistence.d.cts +1 -1
  65. package/dist/persistence.d.ts +1 -1
  66. package/dist/persistence.js +1 -1
  67. package/dist/skills.cjs +7 -3
  68. package/dist/skills.d.cts +1 -1
  69. package/dist/skills.d.ts +1 -1
  70. package/dist/skills.js +1 -1
  71. package/dist/subagents-loader-DOBTTICM.js +7 -0
  72. package/dist/{subagents-loader-7ES7PJNM.js.map → subagents-loader-DOBTTICM.js.map} +1 -1
  73. package/dist/subagents-loader-GEHYCMEX.cjs +16 -0
  74. package/dist/{subagents-loader-OMOH6ERO.cjs.map → subagents-loader-GEHYCMEX.cjs.map} +1 -1
  75. package/dist/subagents-loader.cjs +3 -3
  76. package/dist/subagents-loader.cjs.map +1 -1
  77. package/dist/subagents-loader.d.cts +34 -1
  78. package/dist/subagents-loader.d.ts +34 -1
  79. package/dist/subagents-loader.js +3 -3
  80. package/dist/subagents-loader.js.map +1 -1
  81. package/docs/error-codes.md +2 -2
  82. package/docs/harness-capability-map.md +5 -1
  83. package/package.json +1 -1
  84. package/dist/chunk-6WAKKTBO.js.map +0 -1
  85. package/dist/chunk-CQLVA4CO.cjs.map +0 -1
  86. package/dist/chunk-DLRP7BI6.cjs.map +0 -1
  87. package/dist/chunk-DRL7URI4.cjs.map +0 -1
  88. package/dist/chunk-GUKPXDGJ.js.map +0 -1
  89. package/dist/chunk-QME6FDFG.cjs.map +0 -1
  90. package/dist/chunk-SVWMQCXF.js.map +0 -1
  91. package/dist/chunk-UFPUHJWS.js.map +0 -1
  92. package/dist/chunk-UGRS7ZA7.cjs.map +0 -1
  93. package/dist/chunk-XDANGA2C.js.map +0 -1
  94. package/dist/context-FM6UZPTL.js +0 -6
  95. package/dist/judge-call-6MVARKU2.js +0 -5
  96. package/dist/judge-call-I3P4D5QR.cjs +0 -22
  97. package/dist/subagents-loader-7ES7PJNM.js +0 -7
  98. package/dist/subagents-loader-OMOH6ERO.cjs +0 -16
package/dist/index.cjs CHANGED
@@ -2,20 +2,20 @@
2
2
 
3
3
  var chunkTFG5IBZS_cjs = require('./chunk-TFG5IBZS.cjs');
4
4
  var chunkOBA6YK2R_cjs = require('./chunk-OBA6YK2R.cjs');
5
- var chunkDRL7URI4_cjs = require('./chunk-DRL7URI4.cjs');
5
+ var chunkQDM3OHUT_cjs = require('./chunk-QDM3OHUT.cjs');
6
6
  var chunkVPK6PHIE_cjs = require('./chunk-VPK6PHIE.cjs');
7
7
  var chunkQWD4RDZ3_cjs = require('./chunk-QWD4RDZ3.cjs');
8
8
  require('./chunk-7JJ3A6AT.cjs');
9
9
  var chunk4HS6FFGL_cjs = require('./chunk-4HS6FFGL.cjs');
10
10
  require('./chunk-4A3SKJ53.cjs');
11
11
  require('./chunk-VTYY7XL5.cjs');
12
- var chunkCC7EYKBJ_cjs = require('./chunk-CC7EYKBJ.cjs');
13
- var chunkCQLVA4CO_cjs = require('./chunk-CQLVA4CO.cjs');
12
+ var chunk67SBTGMA_cjs = require('./chunk-67SBTGMA.cjs');
13
+ var chunkD3CCY3A2_cjs = require('./chunk-D3CCY3A2.cjs');
14
14
  var chunkKVSAY6NZ_cjs = require('./chunk-KVSAY6NZ.cjs');
15
15
  require('./chunk-Y2KYR2ED.cjs');
16
16
  require('./chunk-BUUUWQMB.cjs');
17
17
  require('./chunk-Z2JFX372.cjs');
18
- require('./chunk-LTLPBGHC.cjs');
18
+ require('./chunk-KGANQYP7.cjs');
19
19
  require('./chunk-BV2MWEMV.cjs');
20
20
  require('./chunk-D6POWE7E.cjs');
21
21
  require('./chunk-GHX4P3V2.cjs');
@@ -36,9 +36,9 @@ require('./chunk-MUUQ2WFJ.cjs');
36
36
  var chunkAA27GEYS_cjs = require('./chunk-AA27GEYS.cjs');
37
37
  require('./chunk-YSTXFWQE.cjs');
38
38
  require('./chunk-FRITRLZQ.cjs');
39
- require('./chunk-QME6FDFG.cjs');
39
+ require('./chunk-NQTD6QOW.cjs');
40
40
  require('./chunk-NINIJCHU.cjs');
41
- require('./chunk-UGRS7ZA7.cjs');
41
+ require('./chunk-QATRS7JD.cjs');
42
42
  require('./chunk-LOHMT36V.cjs');
43
43
  require('./chunk-IJ7M6GOG.cjs');
44
44
  require('./chunk-7A6535RA.cjs');
@@ -53,8 +53,8 @@ require('./chunk-BJUJT5ED.cjs');
53
53
  var chunkZF2LDKQQ_cjs = require('./chunk-ZF2LDKQQ.cjs');
54
54
  var chunkHCT4HPCL_cjs = require('./chunk-HCT4HPCL.cjs');
55
55
  var chunkJLRLCBJ4_cjs = require('./chunk-JLRLCBJ4.cjs');
56
- require('./chunk-5AXMNUCY.cjs');
57
- require('./chunk-DLRP7BI6.cjs');
56
+ require('./chunk-QYLZQ43D.cjs');
57
+ require('./chunk-NYQ3IS7K.cjs');
58
58
  require('./chunk-HW7SEELD.cjs');
59
59
  var chunkATT276RD_cjs = require('./chunk-ATT276RD.cjs');
60
60
  var chunk3EE6LVWT_cjs = require('./chunk-3EE6LVWT.cjs');
@@ -74,8 +74,8 @@ var path = require('path');
74
74
  // src/agent-factory.ts
75
75
  function createAgentFactory(common) {
76
76
  return {
77
- forSession: (agentId, overrides) => chunkCQLVA4CO_cjs.Agent.create(mergeAgentOptions(common, overrides, agentId)),
78
- getOrCreate: (agentId, overrides) => chunkCQLVA4CO_cjs.Agent.getOrCreate(agentId, mergeAgentOptions(common, overrides, agentId))
77
+ forSession: (agentId, overrides) => chunkD3CCY3A2_cjs.Agent.create(mergeAgentOptions(common, overrides, agentId)),
78
+ getOrCreate: (agentId, overrides) => chunkD3CCY3A2_cjs.Agent.getOrCreate(agentId, mergeAgentOptions(common, overrides, agentId))
79
79
  };
80
80
  }
81
81
  function mergeAgentOptions(common, overrides, agentId) {
@@ -803,7 +803,7 @@ function runGoalLoop(agent, goal, options, depsOverride) {
803
803
  async function* wrap() {
804
804
  const { runUntilImpl } = await import('./run-until-DG2KXWB2.cjs');
805
805
  const deps = depsOverride ?? await (async () => {
806
- const { judgeCallImpl } = await import('./judge-call-I3P4D5QR.cjs');
806
+ const { judgeCallImpl } = await import('./judge-call-46M2E5FA.cjs');
807
807
  const { getAgentFacade } = await import('./agent-factory-registry-UU46BUMU.cjs');
808
808
  const create = getAgentFacade().create;
809
809
  return {
@@ -1293,7 +1293,7 @@ var Memory = {
1293
1293
  return await peer.IndexManager.open(openArgs);
1294
1294
  }
1295
1295
  const { IndexManager } = await import('./index-manager-3UNPYH34.cjs');
1296
- openArgs.embedding = await resolveEmbedding(opts.embedding, chunkCQLVA4CO_cjs.MEMORY_EMBEDDING_ADAPTERS);
1296
+ openArgs.embedding = await resolveEmbedding(opts.embedding, chunkD3CCY3A2_cjs.MEMORY_EMBEDDING_ADAPTERS);
1297
1297
  return await IndexManager.open(openArgs);
1298
1298
  },
1299
1299
  /**
@@ -1304,7 +1304,7 @@ var Memory = {
1304
1304
  */
1305
1305
  async runDreamingSweep(opts) {
1306
1306
  const peer = await tryLoadSdkMemoryPeer();
1307
- const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS : chunkCQLVA4CO_cjs.MEMORY_EMBEDDING_ADAPTERS;
1307
+ const catalog = peer !== null ? peer.MEMORY_EMBEDDING_ADAPTERS : chunkD3CCY3A2_cjs.MEMORY_EMBEDDING_ADAPTERS;
1308
1308
  const sweepArgs = await buildDreamingSweepArgs(opts, catalog);
1309
1309
  const result = peer !== null ? (
1310
1310
  // biome-ignore lint/suspicious/noExplicitAny: peer is dynamically loaded — structural compat ensured by sdk-memory
@@ -1728,7 +1728,7 @@ function guardSessionDestruction(sessionId, live) {
1728
1728
  // src/session-messages.ts
1729
1729
  async function readSessionMessages2(options) {
1730
1730
  const cwd = options.cwd ?? process.cwd();
1731
- const baseDir = chunkCQLVA4CO_cjs.resolveSessionDir({ sessionDir: options.sessionDir });
1731
+ const baseDir = chunkD3CCY3A2_cjs.resolveSessionDir({ sessionDir: options.sessionDir });
1732
1732
  return chunkYIFFF23U_cjs.readSessionMessages(new chunk7FDKWDA2_cjs.FsSessionStore({ baseDir, cwd }), options.sessionId);
1733
1733
  }
1734
1734
 
@@ -1745,7 +1745,7 @@ function isBuiltAgent(m) {
1745
1745
  return typeof m.send === "function";
1746
1746
  }
1747
1747
  async function materialize(def, index) {
1748
- const { Agent: Agent2 } = await import('./agent-TKJBWGGQ.cjs');
1748
+ const { Agent: Agent2 } = await import('./agent-ARLOD4JX.cjs');
1749
1749
  return Agent2.create({
1750
1750
  // `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
1751
1751
  // here means "declare nothing and let the default apply" — forwarding the literal would create
@@ -1887,7 +1887,7 @@ var FIXTURE_USER = {
1887
1887
  };
1888
1888
  var FIXTURE_MODELS = [
1889
1889
  {
1890
- id: chunkCQLVA4CO_cjs.DEFAULT_AGENTIC_MODEL_ID,
1890
+ id: chunkD3CCY3A2_cjs.DEFAULT_AGENTIC_MODEL_ID,
1891
1891
  name: "Gemini 2.0 Flash",
1892
1892
  displayName: "Gemini 2.0 Flash",
1893
1893
  parameters: [
@@ -2090,7 +2090,7 @@ var Theokit = class {
2090
2090
  envVars: p.envVars
2091
2091
  }));
2092
2092
  },
2093
- embeddingAdapters: () => Object.entries(chunkCQLVA4CO_cjs.MEMORY_EMBEDDING_ADAPTERS).map(([id, adapter]) => ({
2093
+ embeddingAdapters: () => Object.entries(chunkD3CCY3A2_cjs.MEMORY_EMBEDDING_ADAPTERS).map(([id, adapter]) => ({
2094
2094
  id,
2095
2095
  transport: adapter.transport,
2096
2096
  defaultModel: adapter.defaultModel
@@ -2289,7 +2289,7 @@ Object.defineProperty(exports, "GOAL_CONTINUATION_MARKER", {
2289
2289
  });
2290
2290
  Object.defineProperty(exports, "JudgeCredentialError", {
2291
2291
  enumerable: true,
2292
- get: function () { return chunkDRL7URI4_cjs.JudgeCredentialError; }
2292
+ get: function () { return chunkQDM3OHUT_cjs.JudgeCredentialError; }
2293
2293
  });
2294
2294
  Object.defineProperty(exports, "GenerateObjectError", {
2295
2295
  enumerable: true,
@@ -2309,35 +2309,35 @@ Object.defineProperty(exports, "fn", {
2309
2309
  });
2310
2310
  Object.defineProperty(exports, "Cron", {
2311
2311
  enumerable: true,
2312
- get: function () { return chunkCC7EYKBJ_cjs.Cron; }
2312
+ get: function () { return chunk67SBTGMA_cjs.Cron; }
2313
2313
  });
2314
2314
  Object.defineProperty(exports, "Agent", {
2315
2315
  enumerable: true,
2316
- get: function () { return chunkCQLVA4CO_cjs.Agent; }
2316
+ get: function () { return chunkD3CCY3A2_cjs.Agent; }
2317
2317
  });
2318
2318
  Object.defineProperty(exports, "AgentBuilder", {
2319
2319
  enumerable: true,
2320
- get: function () { return chunkCQLVA4CO_cjs.AgentBuilder; }
2320
+ get: function () { return chunkD3CCY3A2_cjs.AgentBuilder; }
2321
2321
  });
2322
2322
  Object.defineProperty(exports, "Tool", {
2323
2323
  enumerable: true,
2324
- get: function () { return chunkCQLVA4CO_cjs.Tool; }
2324
+ get: function () { return chunkD3CCY3A2_cjs.Tool; }
2325
2325
  });
2326
2326
  Object.defineProperty(exports, "ToolError", {
2327
2327
  enumerable: true,
2328
- get: function () { return chunkCQLVA4CO_cjs.ToolError; }
2328
+ get: function () { return chunkD3CCY3A2_cjs.ToolError; }
2329
2329
  });
2330
2330
  Object.defineProperty(exports, "UsageAccumulator", {
2331
2331
  enumerable: true,
2332
- get: function () { return chunkCQLVA4CO_cjs.UsageAccumulator; }
2332
+ get: function () { return chunkD3CCY3A2_cjs.UsageAccumulator; }
2333
2333
  });
2334
2334
  Object.defineProperty(exports, "computeCost", {
2335
2335
  enumerable: true,
2336
- get: function () { return chunkCQLVA4CO_cjs.computeCost; }
2336
+ get: function () { return chunkD3CCY3A2_cjs.computeCost; }
2337
2337
  });
2338
2338
  Object.defineProperty(exports, "getPricingEntry", {
2339
2339
  enumerable: true,
2340
- get: function () { return chunkCQLVA4CO_cjs.getPricingEntry; }
2340
+ get: function () { return chunkD3CCY3A2_cjs.getPricingEntry; }
2341
2341
  });
2342
2342
  Object.defineProperty(exports, "emitRunEvent", {
2343
2343
  enumerable: true,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export { StreamObjectError } from './chunk-5WKQDIGO.js';
2
2
  export { GOAL_CONTINUATION_MARKER } from './chunk-PY2RQOA7.js';
3
- export { JudgeCredentialError } from './chunk-UFPUHJWS.js';
3
+ export { JudgeCredentialError } from './chunk-IUMAQURF.js';
4
4
  import { migrateSqliteToLance, appendDiaryEntry } from './chunk-WS5ULCL4.js';
5
5
  export { GenerateObjectError } from './chunk-44I6UYVH.js';
6
6
  import './chunk-47TF32NQ.js';
@@ -8,15 +8,15 @@ import { Workflow, agentStep } from './chunk-HFEJE7AC.js';
8
8
  export { Workflow, agentStep, fn } from './chunk-HFEJE7AC.js';
9
9
  import './chunk-GBCVPKHE.js';
10
10
  import './chunk-HY66GLM6.js';
11
- export { Cron } from './chunk-YEL3SP6X.js';
12
- import { MEMORY_EMBEDDING_ADAPTERS, resolveSessionDir, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-SVWMQCXF.js';
13
- export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-SVWMQCXF.js';
11
+ export { Cron } from './chunk-XU6MLSC6.js';
12
+ import { MEMORY_EMBEDDING_ADAPTERS, resolveSessionDir, DEFAULT_AGENTIC_MODEL_ID, Agent } from './chunk-OYD3U3LY.js';
13
+ export { Agent, AgentBuilder, Tool, ToolError, UsageAccumulator, computeCost, getPricingEntry } from './chunk-OYD3U3LY.js';
14
14
  import { configure, submit, list, get, cancel, subscribe } from './chunk-K2VMFZQ5.js';
15
15
  export { emitRunEvent } from './chunk-K2VMFZQ5.js';
16
16
  import './chunk-AWINL3ZC.js';
17
17
  import './chunk-K2BQQ445.js';
18
18
  import './chunk-7SZAV6QG.js';
19
- import './chunk-D7WAROJR.js';
19
+ import './chunk-AW6F6HZR.js';
20
20
  import './chunk-2SFBB54R.js';
21
21
  import './chunk-55GB6JYQ.js';
22
22
  import './chunk-H73MEMQB.js';
@@ -37,9 +37,9 @@ import './chunk-FD2UT76F.js';
37
37
  import { toJsonSchema } from './chunk-7I5Z3UBJ.js';
38
38
  import './chunk-FJWQP6EE.js';
39
39
  import './chunk-NAF4L3T6.js';
40
- import './chunk-6WAKKTBO.js';
40
+ import './chunk-CFE6QF2Q.js';
41
41
  import './chunk-6X6ID4MO.js';
42
- import './chunk-XDANGA2C.js';
42
+ import './chunk-LX7SEXOQ.js';
43
43
  import './chunk-2XRAWOZZ.js';
44
44
  import './chunk-SAGRF4IB.js';
45
45
  import './chunk-EH6XD3FY.js';
@@ -55,8 +55,8 @@ import { withCwdMutex } from './chunk-Q5EWJPRY.js';
55
55
  export { withCwdMutex } from './chunk-Q5EWJPRY.js';
56
56
  export { TASK_RESERVED_PREFIXES, isValidTaskId } from './chunk-EIQFAOFD.js';
57
57
  import { replaceFileAtomic } from './chunk-3JHIFQ4I.js';
58
- import './chunk-7RHC7HMS.js';
59
- import './chunk-GUKPXDGJ.js';
58
+ import './chunk-OQRGVTQF.js';
59
+ import './chunk-WMWEI3NS.js';
60
60
  import './chunk-JNAA4G4H.js';
61
61
  import { estimateTokens, CHARS_PER_TOKEN } from './chunk-6M2OIS4Y.js';
62
62
  export { estimateTokens } from './chunk-6M2OIS4Y.js';
@@ -808,7 +808,7 @@ function runGoalLoop(agent, goal, options, depsOverride) {
808
808
  async function* wrap() {
809
809
  const { runUntilImpl } = await import('./run-until-6D6TQ4JN.js');
810
810
  const deps = depsOverride ?? await (async () => {
811
- const { judgeCallImpl } = await import('./judge-call-6MVARKU2.js');
811
+ const { judgeCallImpl } = await import('./judge-call-FGUNNWEI.js');
812
812
  const { getAgentFacade } = await import('./agent-factory-registry-ZVTABLEY.js');
813
813
  const create = getAgentFacade().create;
814
814
  return {
@@ -1750,7 +1750,7 @@ function isBuiltAgent(m) {
1750
1750
  return typeof m.send === "function";
1751
1751
  }
1752
1752
  async function materialize(def, index) {
1753
- const { Agent: Agent2 } = await import('./agent-UGYIYC3R.js');
1753
+ const { Agent: Agent2 } = await import('./agent-N6WJ54ML.js');
1754
1754
  return Agent2.create({
1755
1755
  // `AgentDefinition.model` admits the sentinel `'inherit'`, which is not a model id. Inheriting
1756
1756
  // here means "declare nothing and let the default apply" — forwarding the literal would create
@@ -32,6 +32,7 @@
32
32
  *
33
33
  * @internal
34
34
  */
35
+ import type { BuiltinToolName, CompatSource, SettingSource } from "../../types/agent.js";
35
36
  import type { ModelSelection } from "../../types/agent-prims.js";
36
37
  import type { Plugin } from "../plugins/types.js";
37
38
  /**
@@ -64,4 +65,48 @@ export interface InheritedCredentials {
64
65
  * third-party tool `ctx`.
65
66
  */
66
67
  readonly plugins?: readonly Plugin[];
68
+ /**
69
+ * #578 — the parent's RESOLVED `local.settingSources` / `local.compatSources`, handed down so a
70
+ * delegated child can see the configuration surfaces its parent was declared to read.
71
+ *
72
+ * `compatSources` arrived with #524 and neither carrier was updated, so a parent declaring
73
+ * `compatSources: ["claude-code"]` read `.claude/agents/` and its child did not: a team could
74
+ * delegate TO a role by name and the child could not resolve the rest of the team.
75
+ *
76
+ * ## Why inheriting is safe here, unlike widening
77
+ *
78
+ * Every other field on this interface hands DOWN a restriction (the sandbox posture, the
79
+ * permission plugins) and the danger is a child escaping it. These two are the mirror image: the
80
+ * child is currently MORE restricted than its parent, so the failure is a missing capability
81
+ * rather than an open door. Inheritance cannot widen — the child receives what the parent already
82
+ * resolved, and it runs in the parent's cwd, so it reads no directory the parent could not.
83
+ *
84
+ * A role's explicit value still wins; these are the fallback, exactly as `model` and `sandbox` are.
85
+ */
86
+ readonly settingSources?: readonly SettingSource[];
87
+ /** @see {@link InheritedCredentials.settingSources} — carried together, same reasoning. */
88
+ readonly compatSources?: readonly CompatSource[];
89
+ /**
90
+ * #580 — the builtin tools the parent removed from its catalog, handed down so a delegated child
91
+ * cannot recover one its parent revoked.
92
+ *
93
+ * This is the third field here that hands down a RESTRICTION, and it was the one that crossed no
94
+ * carrier at all: measured, a parent with `withheldBuiltinTools: ["shell"]` produced a child whose
95
+ * value was `undefined`, so the child got the shell back. Delegation widened authority the operator
96
+ * had revoked — the inverse of #578 and materially worse, because there the child was merely
97
+ * over-restricted.
98
+ *
99
+ * It bites because of a documented default (`types/agent.ts` § LocalOptions): a `shell` tool is
100
+ * ALWAYS registered on a local agent, including when `tools: []` is passed. Withholding is the only
101
+ * mechanism that removes it, so a withholding that does not survive delegation leaves no other way
102
+ * for a child to be without a shell.
103
+ *
104
+ * ## The union rule
105
+ *
106
+ * A child's own list is UNIONED with this one, never substituted for it — see
107
+ * {@link buildChildWithheldBuiltins}. Every other field on this interface lets the role's own value
108
+ * win, and copying that here would let a child un-withhold what its parent revoked: the bug,
109
+ * reintroduced by its own fix.
110
+ */
111
+ readonly withheldBuiltinTools?: readonly BuiltinToolName[];
67
112
  }
@@ -7,7 +7,7 @@ var chunkDQZU7JK6_cjs = require('../../chunk-DQZU7JK6.cjs');
7
7
  var chunkBJUJT5ED_cjs = require('../../chunk-BJUJT5ED.cjs');
8
8
  var chunkZF2LDKQQ_cjs = require('../../chunk-ZF2LDKQQ.cjs');
9
9
  var chunkJLRLCBJ4_cjs = require('../../chunk-JLRLCBJ4.cjs');
10
- var chunkDLRP7BI6_cjs = require('../../chunk-DLRP7BI6.cjs');
10
+ var chunkNYQ3IS7K_cjs = require('../../chunk-NYQ3IS7K.cjs');
11
11
  require('../../chunk-J7J7J2GN.cjs');
12
12
  require('../../chunk-6LHQPOMI.cjs');
13
13
  var promises = require('fs/promises');
@@ -111,15 +111,15 @@ Object.defineProperty(exports, "replaceFileAtomic", {
111
111
  });
112
112
  Object.defineProperty(exports, "displayTheokitHome", {
113
113
  enumerable: true,
114
- get: function () { return chunkDLRP7BI6_cjs.displayTheokitHome; }
114
+ get: function () { return chunkNYQ3IS7K_cjs.displayTheokitHome; }
115
115
  });
116
116
  Object.defineProperty(exports, "getProfilesRoot", {
117
117
  enumerable: true,
118
- get: function () { return chunkDLRP7BI6_cjs.getProfilesRoot; }
118
+ get: function () { return chunkNYQ3IS7K_cjs.getProfilesRoot; }
119
119
  });
120
120
  Object.defineProperty(exports, "getTheokitHome", {
121
121
  enumerable: true,
122
- get: function () { return chunkDLRP7BI6_cjs.getTheokitHome; }
122
+ get: function () { return chunkNYQ3IS7K_cjs.getTheokitHome; }
123
123
  });
124
124
  exports.casUpdate = casUpdate;
125
125
  exports.createExclusive = createExclusive;
@@ -5,7 +5,7 @@ export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from '..
5
5
  export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from '../../chunk-TA3K7SBK.js';
6
6
  export { withCwdMutex } from '../../chunk-Q5EWJPRY.js';
7
7
  export { atomicWriteJson, atomicWriteText, replaceFileAtomic } from '../../chunk-3JHIFQ4I.js';
8
- export { displayTheokitHome, getProfilesRoot, getTheokitHome } from '../../chunk-GUKPXDGJ.js';
8
+ export { displayTheokitHome, getProfilesRoot, getTheokitHome } from '../../chunk-WMWEI3NS.js';
9
9
  import '../../chunk-ALUN2B4W.js';
10
10
  import '../../chunk-CZJ6Q7CW.js';
11
11
  import { open } from 'fs/promises';
@@ -20,6 +20,7 @@ export interface SerializedAgentOptions {
20
20
  local?: {
21
21
  cwd?: string;
22
22
  settingSources?: ReadonlyArray<string>;
23
+ compatSources?: ReadonlyArray<unknown>;
23
24
  sandboxOptions?: {
24
25
  enabled: boolean;
25
26
  };
@@ -66,3 +66,38 @@ export interface DiscoverSkillsOptions {
66
66
  * @public
67
67
  */
68
68
  export declare function discoverSkills(dir: string, options?: DiscoverSkillsOptions): Promise<Skill[]>;
69
+ /**
70
+ * Read the BODY of a discovered skill — everything after its frontmatter.
71
+ *
72
+ * A thin selector over {@link discoverSkills} rather than a second reader, which is the same
73
+ * relationship `loadSubagentDefinition` has to `discoverSubagents` in the sibling domain: one
74
+ * parser is the point.
75
+ *
76
+ * ## Why this exists rather than a field on `Skill`
77
+ *
78
+ * `Skill` documents that *"the skill BODY is never included"*. That is a written contract with no
79
+ * written reason, and widening it on a guess about the reason is not a trade worth making — a
80
+ * catalog you can put in a prompt without carrying every body is the likely intent, and this keeps
81
+ * that shape intact for whoever relied on it.
82
+ *
83
+ * The body was never expensive to obtain: `discoverSkills` already reads each file in full and
84
+ * discards everything but the frontmatter. What was missing was a door that hands it over.
85
+ *
86
+ * ## What it is for
87
+ *
88
+ * Turning a discovered skill into an inline one — `SkillsSettings.inline` requires `instructions`,
89
+ * and without this the only route was to open `source` and split the frontmatter by hand. That is a
90
+ * second implementation of this module's own convention, and it would fail SILENTLY if the format
91
+ * moved: the frontmatter would land inside the instructions and nothing would say so.
92
+ *
93
+ * Reported by the `theocode` session, which needed exactly that to give an operator's
94
+ * `~/.theokit/skills/` to an agent through the SDK's own parser.
95
+ *
96
+ * @param skill - a record returned by {@link discoverSkills}; its `source` is read.
97
+ * @returns the trimmed body. A file that is all frontmatter yields an empty string.
98
+ * @throws if `source` is unreadable — unlike discovery, which skips what it cannot read, a caller
99
+ * naming ONE skill has asked about that skill and an empty string would answer a question it did
100
+ * not ask.
101
+ * @public
102
+ */
103
+ export declare function loadSkillInstructions(skill: Skill): Promise<string>;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ var chunkQDM3OHUT_cjs = require('./chunk-QDM3OHUT.cjs');
4
+ require('./chunk-J7J7J2GN.cjs');
5
+ require('./chunk-6LHQPOMI.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "JudgeCredentialError", {
10
+ enumerable: true,
11
+ get: function () { return chunkQDM3OHUT_cjs.JudgeCredentialError; }
12
+ });
13
+ Object.defineProperty(exports, "composeJudgePrompt", {
14
+ enumerable: true,
15
+ get: function () { return chunkQDM3OHUT_cjs.composeJudgePrompt; }
16
+ });
17
+ Object.defineProperty(exports, "judgeCallImpl", {
18
+ enumerable: true,
19
+ get: function () { return chunkQDM3OHUT_cjs.judgeCallImpl; }
20
+ });
21
+ //# sourceMappingURL=judge-call-46M2E5FA.cjs.map
22
+ //# sourceMappingURL=judge-call-46M2E5FA.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-I3P4D5QR.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-46M2E5FA.cjs"}
@@ -0,0 +1,5 @@
1
+ export { JudgeCredentialError, composeJudgePrompt, judgeCallImpl } from './chunk-IUMAQURF.js';
2
+ import './chunk-ALUN2B4W.js';
3
+ import './chunk-CZJ6Q7CW.js';
4
+ //# sourceMappingURL=judge-call-FGUNNWEI.js.map
5
+ //# sourceMappingURL=judge-call-FGUNNWEI.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-6MVARKU2.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"judge-call-FGUNNWEI.js"}
@@ -116,6 +116,14 @@ Object.defineProperty(exports, "encodeProjectDir", {
116
116
  enumerable: true,
117
117
  get: function () { return chunkGZV6AVRL_cjs.encodeProjectDir; }
118
118
  });
119
+ Object.defineProperty(exports, "legacyTranscriptPath", {
120
+ enumerable: true,
121
+ get: function () { return chunkGZV6AVRL_cjs.legacyTranscriptPath; }
122
+ });
123
+ Object.defineProperty(exports, "sessionUuidFor", {
124
+ enumerable: true,
125
+ get: function () { return chunkGZV6AVRL_cjs.sessionUuidFor; }
126
+ });
119
127
  Object.defineProperty(exports, "transcriptPath", {
120
128
  enumerable: true,
121
129
  get: function () { return chunkGZV6AVRL_cjs.transcriptPath; }
@@ -24,7 +24,7 @@ export { sanitizeFts5Query } from "./internal/persistence/fts5-sanitize.js";
24
24
  export { appendJsonl, JsonlParseError, loadJsonl, readJsonlIds, } from "./internal/persistence/jsonl.js";
25
25
  export { PersistenceSchema } from "./internal/persistence/persistence-schema.js";
26
26
  export { classifySessionArtifact, type SessionArtifact, } from "./internal/persistence/session-artifacts.js";
27
- export { encodeProjectDir, transcriptPath, transcriptRoot, } from "./internal/persistence/session-transcript.js";
27
+ export { encodeProjectDir, legacyTranscriptPath, sessionUuidFor, transcriptPath, transcriptRoot, } from "./internal/persistence/session-transcript.js";
28
28
  export { acquireSessionWriter, SessionBusyError, type SessionWriterLease, sessionHasWriter, } from "./internal/persistence/session-writer.js";
29
29
  export type { OpenSqliteResilientOptions, ResilientSqliteDb, } from "./internal/persistence/sqlite-open.js";
30
30
  export { isCorruptionError, openSqliteResilient } from "./internal/persistence/sqlite-open.js";
@@ -24,7 +24,7 @@ export { sanitizeFts5Query } from "./internal/persistence/fts5-sanitize.js";
24
24
  export { appendJsonl, JsonlParseError, loadJsonl, readJsonlIds, } from "./internal/persistence/jsonl.js";
25
25
  export { PersistenceSchema } from "./internal/persistence/persistence-schema.js";
26
26
  export { classifySessionArtifact, type SessionArtifact, } from "./internal/persistence/session-artifacts.js";
27
- export { encodeProjectDir, transcriptPath, transcriptRoot, } from "./internal/persistence/session-transcript.js";
27
+ export { encodeProjectDir, legacyTranscriptPath, sessionUuidFor, transcriptPath, transcriptRoot, } from "./internal/persistence/session-transcript.js";
28
28
  export { acquireSessionWriter, SessionBusyError, type SessionWriterLease, sessionHasWriter, } from "./internal/persistence/session-writer.js";
29
29
  export type { OpenSqliteResilientOptions, ResilientSqliteDb, } from "./internal/persistence/sqlite-open.js";
30
30
  export { isCorruptionError, openSqliteResilient } from "./internal/persistence/sqlite-open.js";
@@ -1,6 +1,6 @@
1
1
  export { PersistenceSchema } from './chunk-HY66GLM6.js';
2
2
  export { SessionBusyError, acquireSessionWriter, sessionHasWriter } from './chunk-VE6DFSKU.js';
3
- export { encodeProjectDir, transcriptPath, transcriptRoot } from './chunk-JOFVLOFY.js';
3
+ export { encodeProjectDir, legacyTranscriptPath, sessionUuidFor, transcriptPath, transcriptRoot } from './chunk-JOFVLOFY.js';
4
4
  export { sanitizeFts5Query } from './chunk-WE22OXQA.js';
5
5
  export { applyWalWithFallback, isCorruptionError, openSqliteResilient } from './chunk-6PWOWXMC.js';
6
6
  export { JsonlParseError, appendJsonl, loadJsonl, readJsonlIds, withFileLock } from './chunk-TA3K7SBK.js';
package/dist/skills.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkUGRS7ZA7_cjs = require('./chunk-UGRS7ZA7.cjs');
3
+ var chunkQATRS7JD_cjs = require('./chunk-QATRS7JD.cjs');
4
4
  require('./chunk-7A6535RA.cjs');
5
5
  require('./chunk-SA6K24NB.cjs');
6
6
  require('./chunk-HW7SEELD.cjs');
@@ -11,11 +11,15 @@ require('./chunk-6LHQPOMI.cjs');
11
11
 
12
12
  Object.defineProperty(exports, "buildSkillsBlock", {
13
13
  enumerable: true,
14
- get: function () { return chunkUGRS7ZA7_cjs.buildSkillsBlock; }
14
+ get: function () { return chunkQATRS7JD_cjs.buildSkillsBlock; }
15
15
  });
16
16
  Object.defineProperty(exports, "discoverSkills", {
17
17
  enumerable: true,
18
- get: function () { return chunkUGRS7ZA7_cjs.discoverSkills; }
18
+ get: function () { return chunkQATRS7JD_cjs.discoverSkills; }
19
+ });
20
+ Object.defineProperty(exports, "loadSkillInstructions", {
21
+ enumerable: true,
22
+ get: function () { return chunkQATRS7JD_cjs.loadSkillInstructions; }
19
23
  });
20
24
  //# sourceMappingURL=skills.cjs.map
21
25
  //# sourceMappingURL=skills.cjs.map
package/dist/skills.d.cts CHANGED
@@ -15,5 +15,5 @@
15
15
  * `.theokit/skills` discovery and `<skills>` injection — exposed so consumers
16
16
  * orient an agent with one import instead of hand-rolling discovery.
17
17
  */
18
- export { type DiscoverSkillsOptions, discoverSkills, type InvalidSkillInfo, type Skill, } from "./internal/runtime/skills/discover-skills.js";
18
+ export { type DiscoverSkillsOptions, discoverSkills, type InvalidSkillInfo, loadSkillInstructions, type Skill, } from "./internal/runtime/skills/discover-skills.js";
19
19
  export { buildSkillsBlock } from "./internal/runtime/skills/skills-block.js";
package/dist/skills.d.ts CHANGED
@@ -15,5 +15,5 @@
15
15
  * `.theokit/skills` discovery and `<skills>` injection — exposed so consumers
16
16
  * orient an agent with one import instead of hand-rolling discovery.
17
17
  */
18
- export { type DiscoverSkillsOptions, discoverSkills, type InvalidSkillInfo, type Skill, } from "./internal/runtime/skills/discover-skills.js";
18
+ export { type DiscoverSkillsOptions, discoverSkills, type InvalidSkillInfo, loadSkillInstructions, type Skill, } from "./internal/runtime/skills/discover-skills.js";
19
19
  export { buildSkillsBlock } from "./internal/runtime/skills/skills-block.js";
package/dist/skills.js CHANGED
@@ -1,4 +1,4 @@
1
- export { buildSkillsBlock, discoverSkills } from './chunk-XDANGA2C.js';
1
+ export { buildSkillsBlock, discoverSkills, loadSkillInstructions } from './chunk-LX7SEXOQ.js';
2
2
  import './chunk-EH6XD3FY.js';
3
3
  import './chunk-UKMBRMGT.js';
4
4
  import './chunk-JNAA4G4H.js';
@@ -0,0 +1,7 @@
1
+ export { loadSubagents } from './chunk-OQRGVTQF.js';
2
+ import './chunk-WMWEI3NS.js';
3
+ import './chunk-JNAA4G4H.js';
4
+ import './chunk-ALUN2B4W.js';
5
+ import './chunk-CZJ6Q7CW.js';
6
+ //# sourceMappingURL=subagents-loader-DOBTTICM.js.map
7
+ //# sourceMappingURL=subagents-loader-DOBTTICM.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-7ES7PJNM.js"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-DOBTTICM.js"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var chunkQYLZQ43D_cjs = require('./chunk-QYLZQ43D.cjs');
4
+ require('./chunk-NYQ3IS7K.cjs');
5
+ require('./chunk-HW7SEELD.cjs');
6
+ require('./chunk-J7J7J2GN.cjs');
7
+ require('./chunk-6LHQPOMI.cjs');
8
+
9
+
10
+
11
+ Object.defineProperty(exports, "loadSubagents", {
12
+ enumerable: true,
13
+ get: function () { return chunkQYLZQ43D_cjs.loadSubagents; }
14
+ });
15
+ //# sourceMappingURL=subagents-loader-GEHYCMEX.cjs.map
16
+ //# sourceMappingURL=subagents-loader-GEHYCMEX.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-OMOH6ERO.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"subagents-loader-GEHYCMEX.cjs"}
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var chunk5AXMNUCY_cjs = require('./chunk-5AXMNUCY.cjs');
4
- require('./chunk-DLRP7BI6.cjs');
3
+ var chunkQYLZQ43D_cjs = require('./chunk-QYLZQ43D.cjs');
4
+ require('./chunk-NYQ3IS7K.cjs');
5
5
  require('./chunk-HW7SEELD.cjs');
6
6
  var chunkJ7J7J2GN_cjs = require('./chunk-J7J7J2GN.cjs');
7
7
  require('./chunk-6LHQPOMI.cjs');
@@ -23,7 +23,7 @@ function resolveSources(options) {
23
23
  }
24
24
  async function discoverSubagents(cwd, options) {
25
25
  const sources = resolveSources(options);
26
- return chunk5AXMNUCY_cjs.loadSubagents(cwd, sources.includes("project"), void 0);
26
+ return chunkQYLZQ43D_cjs.loadSubagents(cwd, sources.includes("project"), void 0, options?.compatSources ?? []);
27
27
  }
28
28
  async function loadSubagentDefinition(name, cwd, options) {
29
29
  return (await discoverSubagents(cwd, options))[name];
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/subagents-loader.ts"],"names":["ConfigurationError","loadSubagents"],"mappings":";;;;;;;;;AAyCA,IAAM,gBAAA,GAA8C,CAAC,SAAS,CAAA;AAgB9D,SAAS,eAAe,OAAA,EAA0E;AAChG,EAAA,MAAM,WAAW,OAAA,EAAS,cAAA;AAC1B,EAAA,IAAI,QAAA,KAAa,QAAW,OAAO,gBAAA;AACnC,EAAA,KAAA,MAAW,UAAU,QAAA,EAAU;AAC7B,IAAA,IAAI,CAAC,gBAAA,CAAiB,QAAA,CAAS,MAAM,CAAA,EAAG;AACtC,MAAA,MAAM,IAAIA,oCAAA;AAAA,QACR,CAAA,iCAAA,EAAoC,OAAO,MAAM,CAAC,gBAAgB,gBAAA,CAAiB,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAA;AAAA,QAC7F,EAAE,MAAM,iCAAA;AAAkC,OAC5C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;AAOA,eAAsB,iBAAA,CACpB,KACA,OAAA,EAC0C;AAC1C,EAAA,MAAM,OAAA,GAAU,eAAe,OAAO,CAAA;AACtC,EAAA,OAAOC,gCAAc,GAAA,EAAK,OAAA,CAAQ,QAAA,CAAS,SAAS,GAAG,MAAS,CAAA;AAClE;AAQA,eAAsB,sBAAA,CACpB,IAAA,EACA,GAAA,EACA,OAAA,EACsC;AACtC,EAAA,OAAA,CAAQ,MAAM,iBAAA,CAAkB,GAAA,EAAK,OAAO,GAAG,IAAI,CAAA;AACrD","file":"subagents-loader.cjs","sourcesContent":["/**\n * Published as `@theokit/sdk/subagents-loader`.\n *\n * M81 — `.theokit/agents` discovery, exposed so a consumer can read the on-disk subagent\n * definitions with one import instead of hand-rolling a second parser.\n *\n * ## Why this file exists\n *\n * `src/skills.ts` already exposed `discoverSkills` for the sibling domain. Subagents had the same\n * loader — `internal/runtime/skills/subagents-loader.ts` — with no public door. A consumer behind\n * the layer boundary (the agent-builder never imports `@theokit/sdk*` directly) could not reach it,\n * so re-implementing was the only legal option. It re-implemented, and then wrote a test whose only\n * job was to watch the two parsers for drift. That test is the cleanest possible evidence that the\n * duplication should not exist.\n *\n * ## What crosses is the PARSED config\n *\n * The return is `AgentDefinition` — already interpreted — never the `.md` text or the frontmatter\n * shape. Exporting the file format would freeze an internal detail as public API; exporting the\n * parsed value leaves the format free to change.\n */\n\nimport { ConfigurationError } from \"./errors.js\";\nimport { loadSubagents } from \"./internal/runtime/skills/subagents-loader.js\";\nimport type { AgentDefinition } from \"./types/agent.js\";\n\n/**\n * The parsed subagent definition this module hands back.\n *\n * Re-exported here — beside the loader that produces it — so a consumer can NAME the value it\n * receives without reaching into `types/agent`, which no subpath publishes. A layer above may then\n * alias it (`AgentDefinition as SubagentDefinition`) to sidestep a name it has already spent.\n */\nexport type { AgentDefinition } from \"./types/agent.js\";\n\n/**\n * Where subagent definitions may be read from. A closed union rather than a boolean: a third\n * source can join it without breaking the signature, and the call site reads as what it means.\n */\nexport type SubagentSource = \"project\";\n\nconst ACCEPTED_SOURCES: readonly SubagentSource[] = [\"project\"];\n\n/** Options for {@link discoverSubagents} / {@link loadSubagentDefinition}. */\nexport interface DiscoverSubagentsOptions {\n /**\n * Which sources to read. Defaults to `[\"project\"]` — `<cwd>/.theokit/agents/*.md`.\n *\n * An empty list reads NOTHING: the directory is never opened, so a caller that has not yet\n * established trust in `cwd` can decline the read rather than filter its result.\n */\n readonly settingSources?: readonly SubagentSource[];\n}\n\n// Validated at the boundary (error-handling.md § 2): the union is erased at runtime, so a JS\n// caller — or a value crossing a serialization hop — can still carry a source nobody honors.\n// Dropping it silently would read as \"no subagents found\", which is the same shape as success.\nfunction resolveSources(options: DiscoverSubagentsOptions | undefined): readonly SubagentSource[] {\n const declared = options?.settingSources;\n if (declared === undefined) return ACCEPTED_SOURCES;\n for (const source of declared) {\n if (!ACCEPTED_SOURCES.includes(source)) {\n throw new ConfigurationError(\n `Unknown subagent setting source \"${String(source)}\" (accepted: ${ACCEPTED_SOURCES.join(\", \")})`,\n { code: \"subagent_unknown_setting_source\" },\n );\n }\n }\n return declared;\n}\n\n/**\n * Discover the subagents defined under `<cwd>/.theokit/agents/*.md`.\n *\n * An absent directory yields `{}` — a project without subagents is the common case, not an error.\n */\nexport async function discoverSubagents(\n cwd: string,\n options?: DiscoverSubagentsOptions,\n): Promise<Record<string, AgentDefinition>> {\n const sources = resolveSources(options);\n return loadSubagents(cwd, sources.includes(\"project\"), undefined);\n}\n\n/**\n * Load ONE subagent definition by name, or `undefined` when it is not defined on disk.\n *\n * A thin selector over {@link discoverSubagents} rather than a second reader: one parser is the\n * whole point of this module.\n */\nexport async function loadSubagentDefinition(\n name: string,\n cwd: string,\n options?: DiscoverSubagentsOptions,\n): Promise<AgentDefinition | undefined> {\n return (await discoverSubagents(cwd, options))[name];\n}\n"]}
1
+ {"version":3,"sources":["../src/subagents-loader.ts"],"names":["ConfigurationError","loadSubagents"],"mappings":";;;;;;;;;AAgDA,IAAM,gBAAA,GAA8C,CAAC,SAAS,CAAA;AA0C9D,SAAS,eAAe,OAAA,EAA0E;AAChG,EAAA,MAAM,WAAW,OAAA,EAAS,cAAA;AAC1B,EAAA,IAAI,QAAA,KAAa,QAAW,OAAO,gBAAA;AACnC,EAAA,KAAA,MAAW,UAAU,QAAA,EAAU;AAC7B,IAAA,IAAI,CAAC,gBAAA,CAAiB,QAAA,CAAS,MAAM,CAAA,EAAG;AACtC,MAAA,MAAM,IAAIA,oCAAA;AAAA,QACR,CAAA,iCAAA,EAAoC,OAAO,MAAM,CAAC,gBAAgB,gBAAA,CAAiB,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,CAAA;AAAA,QAC7F,EAAE,MAAM,iCAAA;AAAkC,OAC5C;AAAA,IACF;AAAA,EACF;AACA,EAAA,OAAO,QAAA;AACT;AAOA,eAAsB,iBAAA,CACpB,KACA,OAAA,EAC0C;AAC1C,EAAA,MAAM,OAAA,GAAU,eAAe,OAAO,CAAA;AACtC,EAAA,OAAOC,+BAAA,CAAc,GAAA,EAAK,OAAA,CAAQ,QAAA,CAAS,SAAS,GAAG,MAAA,EAAW,OAAA,EAAS,aAAA,IAAiB,EAAE,CAAA;AAChG;AAQA,eAAsB,sBAAA,CACpB,IAAA,EACA,GAAA,EACA,OAAA,EACsC;AACtC,EAAA,OAAA,CAAQ,MAAM,iBAAA,CAAkB,GAAA,EAAK,OAAO,GAAG,IAAI,CAAA;AACrD","file":"subagents-loader.cjs","sourcesContent":["/**\n * Published as `@theokit/sdk/subagents-loader`.\n *\n * M81 — `.theokit/agents` discovery, exposed so a consumer can read the on-disk subagent\n * definitions with one import instead of hand-rolling a second parser.\n *\n * ## Why this file exists\n *\n * `src/skills.ts` already exposed `discoverSkills` for the sibling domain. Subagents had the same\n * loader — `internal/runtime/skills/subagents-loader.ts` — with no public door. A consumer behind\n * the layer boundary (the agent-builder never imports `@theokit/sdk*` directly) could not reach it,\n * so re-implementing was the only legal option. It re-implemented, and then wrote a test whose only\n * job was to watch the two parsers for drift. That test is the cleanest possible evidence that the\n * duplication should not exist.\n *\n * ## What crosses is the PARSED config\n *\n * The return is `AgentDefinition` — already interpreted — never the `.md` text or the frontmatter\n * shape. Exporting the file format would freeze an internal detail as public API; exporting the\n * parsed value leaves the format free to change.\n */\n\nimport { ConfigurationError } from \"./errors.js\";\nimport type { CompatSourceDeclaration } from \"./internal/runtime/compat/foreign-config-sources.js\";\nimport { loadSubagents } from \"./internal/runtime/skills/subagents-loader.js\";\nimport type { AgentDefinition } from \"./types/agent.js\";\n\n/**\n * Re-exported for the same reason `AgentDefinition` is: a consumer passing `compatSources`\n * must be able to NAME the value without importing from `types/agent`, which no subpath\n * publishes. An option whose type is unreachable is an option only `any` can call.\n */\nexport type { CompatSourceDeclaration } from \"./internal/runtime/compat/foreign-config-sources.js\";\n/**\n * The parsed subagent definition this module hands back.\n *\n * Re-exported here — beside the loader that produces it — so a consumer can NAME the value it\n * receives without reaching into `types/agent`, which no subpath publishes. A layer above may then\n * alias it (`AgentDefinition as SubagentDefinition`) to sidestep a name it has already spent.\n */\nexport type { AgentDefinition } from \"./types/agent.js\";\n\n/**\n * Where subagent definitions may be read from. A closed union rather than a boolean: a third\n * source can join it without breaking the signature, and the call site reads as what it means.\n */\nexport type SubagentSource = \"project\";\n\nconst ACCEPTED_SOURCES: readonly SubagentSource[] = [\"project\"];\n\n/** Options for {@link discoverSubagents} / {@link loadSubagentDefinition}. */\nexport interface DiscoverSubagentsOptions {\n /**\n * Which sources to read. Defaults to `[\"project\"]` — `<cwd>/.theokit/agents/*.md`.\n *\n * An empty list reads NOTHING: the directory is never opened, so a caller that has not yet\n * established trust in `cwd` can decline the read rather than filter its result.\n */\n readonly settingSources?: readonly SubagentSource[];\n\n /**\n * Foreign configuration dialects to read alongside `.theokit/agents/` (#524). Defaults to none,\n * so this reads `.theokit/` only unless a caller declares otherwise.\n *\n * SEPARATE FROM `settingSources`, and the separation is the contract. That option answers *which\n * sources* — project, and one day user or team. This one answers *which dialects* within them.\n * Folding `\"claude-code\"` into `SubagentSource` would conflate the two, and the internal loader\n * has kept them apart since #524 precisely because they are orthogonal.\n *\n * ## Why this exists\n *\n * The reader underneath already accepted it; this entry point simply never passed it, so\n * `discoverSubagents` was `.theokit/`-only while the agent's own subagent registry — which goes\n * through `settingSources` + `compatSources` — could see the same files. Measured by the\n * `theocode` session on `5.0.1`, both arms in fresh trusted directories with the same task:\n *\n * roles in .theokit/agents/ delegate_to_team works\n * the SAME files in .claude/agents/ \"the `explorer` role is not configured\"\n *\n * So a repository adopting the product could delegate TO a `.claude/agents/` subagent by name and\n * could not define its team's roles there — one dialect, two answers, depending on which selector\n * asked. That asymmetry was an omission rather than a decision: the plumbing existed and the\n * public signature did not reach it.\n */\n readonly compatSources?: readonly CompatSourceDeclaration[];\n}\n\n// Validated at the boundary (error-handling.md § 2): the union is erased at runtime, so a JS\n// caller — or a value crossing a serialization hop — can still carry a source nobody honors.\n// Dropping it silently would read as \"no subagents found\", which is the same shape as success.\nfunction resolveSources(options: DiscoverSubagentsOptions | undefined): readonly SubagentSource[] {\n const declared = options?.settingSources;\n if (declared === undefined) return ACCEPTED_SOURCES;\n for (const source of declared) {\n if (!ACCEPTED_SOURCES.includes(source)) {\n throw new ConfigurationError(\n `Unknown subagent setting source \"${String(source)}\" (accepted: ${ACCEPTED_SOURCES.join(\", \")})`,\n { code: \"subagent_unknown_setting_source\" },\n );\n }\n }\n return declared;\n}\n\n/**\n * Discover the subagents defined under `<cwd>/.theokit/agents/*.md`.\n *\n * An absent directory yields `{}` — a project without subagents is the common case, not an error.\n */\nexport async function discoverSubagents(\n cwd: string,\n options?: DiscoverSubagentsOptions,\n): Promise<Record<string, AgentDefinition>> {\n const sources = resolveSources(options);\n return loadSubagents(cwd, sources.includes(\"project\"), undefined, options?.compatSources ?? []);\n}\n\n/**\n * Load ONE subagent definition by name, or `undefined` when it is not defined on disk.\n *\n * A thin selector over {@link discoverSubagents} rather than a second reader: one parser is the\n * whole point of this module.\n */\nexport async function loadSubagentDefinition(\n name: string,\n cwd: string,\n options?: DiscoverSubagentsOptions,\n): Promise<AgentDefinition | undefined> {\n return (await discoverSubagents(cwd, options))[name];\n}\n"]}