@geminixiang/mikan 1.0.0-beta.21 → 1.0.0-beta.22

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 (112) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/adapters/intake.d.ts.map +1 -1
  3. package/dist/adapters/intake.js +5 -0
  4. package/dist/adapters/intake.js.map +1 -1
  5. package/dist/adapters/slack/bot.d.ts.map +1 -1
  6. package/dist/adapters/slack/bot.js +13 -2
  7. package/dist/adapters/slack/bot.js.map +1 -1
  8. package/dist/adapters/slack/types.d.ts +2 -0
  9. package/dist/adapters/slack/types.d.ts.map +1 -1
  10. package/dist/adapters/slack/types.js.map +1 -1
  11. package/dist/agent.d.ts.map +1 -1
  12. package/dist/agent.js +26 -15
  13. package/dist/agent.js.map +1 -1
  14. package/dist/commands/login.js +2 -2
  15. package/dist/commands/login.js.map +1 -1
  16. package/dist/commands/sandbox.js +2 -2
  17. package/dist/commands/sandbox.js.map +1 -1
  18. package/dist/execution-resolver.d.ts +5 -6
  19. package/dist/execution-resolver.d.ts.map +1 -1
  20. package/dist/execution-resolver.js +72 -103
  21. package/dist/execution-resolver.js.map +1 -1
  22. package/dist/harness/index.d.ts +1 -1
  23. package/dist/harness/index.d.ts.map +1 -1
  24. package/dist/harness/index.js.map +1 -1
  25. package/dist/harness/runner.d.ts +4 -0
  26. package/dist/harness/runner.d.ts.map +1 -1
  27. package/dist/harness/runner.js +16 -2
  28. package/dist/harness/runner.js.map +1 -1
  29. package/dist/harness/subagent-runner.d.ts +14 -13
  30. package/dist/harness/subagent-runner.d.ts.map +1 -1
  31. package/dist/harness/subagent-runner.js +105 -19
  32. package/dist/harness/subagent-runner.js.map +1 -1
  33. package/dist/harness/types.d.ts +11 -0
  34. package/dist/harness/types.d.ts.map +1 -1
  35. package/dist/harness/types.js.map +1 -1
  36. package/dist/runtime/conversation-runtime.d.ts.map +1 -1
  37. package/dist/runtime/conversation-runtime.js +23 -79
  38. package/dist/runtime/conversation-runtime.js.map +1 -1
  39. package/dist/runtime/session-lifecycle.d.ts +19 -0
  40. package/dist/runtime/session-lifecycle.d.ts.map +1 -0
  41. package/dist/runtime/session-lifecycle.js +76 -0
  42. package/dist/runtime/session-lifecycle.js.map +1 -0
  43. package/dist/runtime/types.d.ts +5 -0
  44. package/dist/runtime/types.d.ts.map +1 -1
  45. package/dist/runtime/types.js.map +1 -1
  46. package/dist/sandbox/cloudflare.d.ts.map +1 -1
  47. package/dist/sandbox/cloudflare.js +1 -0
  48. package/dist/sandbox/cloudflare.js.map +1 -1
  49. package/dist/sandbox/container.d.ts.map +1 -1
  50. package/dist/sandbox/container.js +1 -0
  51. package/dist/sandbox/container.js.map +1 -1
  52. package/dist/sandbox/firecracker.d.ts.map +1 -1
  53. package/dist/sandbox/firecracker.js +1 -0
  54. package/dist/sandbox/firecracker.js.map +1 -1
  55. package/dist/sandbox/gondolin.d.ts.map +1 -1
  56. package/dist/sandbox/gondolin.js +1 -0
  57. package/dist/sandbox/gondolin.js.map +1 -1
  58. package/dist/sandbox/host.d.ts.map +1 -1
  59. package/dist/sandbox/host.js +1 -0
  60. package/dist/sandbox/host.js.map +1 -1
  61. package/dist/sandbox/identity.d.ts +11 -16
  62. package/dist/sandbox/identity.d.ts.map +1 -1
  63. package/dist/sandbox/identity.js +32 -26
  64. package/dist/sandbox/identity.js.map +1 -1
  65. package/dist/sandbox/image.d.ts.map +1 -1
  66. package/dist/sandbox/image.js +1 -0
  67. package/dist/sandbox/image.js.map +1 -1
  68. package/dist/sandbox/index.d.ts +1 -0
  69. package/dist/sandbox/index.d.ts.map +1 -1
  70. package/dist/sandbox/index.js +6 -0
  71. package/dist/sandbox/index.js.map +1 -1
  72. package/dist/sandbox/types.d.ts +5 -0
  73. package/dist/sandbox/types.d.ts.map +1 -1
  74. package/dist/sandbox/types.js.map +1 -1
  75. package/dist/sessions/session-key.d.ts +9 -0
  76. package/dist/sessions/session-key.d.ts.map +1 -1
  77. package/dist/sessions/session-key.js +50 -2
  78. package/dist/sessions/session-key.js.map +1 -1
  79. package/dist/sessions/store.d.ts.map +1 -1
  80. package/dist/sessions/store.js +36 -8
  81. package/dist/sessions/store.js.map +1 -1
  82. package/dist/tools/sandbox.js +2 -2
  83. package/dist/tools/sandbox.js.map +1 -1
  84. package/dist/tools/subagent-slots.d.ts +3 -3
  85. package/dist/tools/subagent-slots.d.ts.map +1 -1
  86. package/dist/tools/subagent-slots.js +25 -10
  87. package/dist/tools/subagent-slots.js.map +1 -1
  88. package/dist/tools/subagent.d.ts +13 -2
  89. package/dist/tools/subagent.d.ts.map +1 -1
  90. package/dist/tools/subagent.js +16 -16
  91. package/dist/tools/subagent.js.map +1 -1
  92. package/dist/types.d.ts +7 -0
  93. package/dist/types.d.ts.map +1 -1
  94. package/dist/types.js.map +1 -1
  95. package/dist/vault/injection.d.ts +4 -14
  96. package/dist/vault/injection.d.ts.map +1 -1
  97. package/dist/vault/injection.js +5 -2
  98. package/dist/vault/injection.js.map +1 -1
  99. package/dist/vault/types.d.ts +4 -0
  100. package/dist/vault/types.d.ts.map +1 -1
  101. package/dist/vault/types.js.map +1 -1
  102. package/dist/web/admin/portal.js +2 -2
  103. package/dist/web/admin/portal.js.map +1 -1
  104. package/dist/workspace-projection/index.d.ts +5 -0
  105. package/dist/workspace-projection/index.d.ts.map +1 -0
  106. package/dist/workspace-projection/index.js +71 -0
  107. package/dist/workspace-projection/index.js.map +1 -0
  108. package/dist/workspace-projection/types.d.ts +7 -0
  109. package/dist/workspace-projection/types.d.ts.map +1 -0
  110. package/dist/workspace-projection/types.js +2 -0
  111. package/dist/workspace-projection/types.js.map +1 -0
  112. package/package.json +1 -1
@@ -3,8 +3,8 @@
3
3
  * serialize agent runs, and each run's subagent tool bounds its own fan-out
4
4
  * — but without a shared ceiling, N busy conversations hold N × per-run-cap
5
5
  * live subagent sessions. Every subagent launch draws a slot from one shared
6
- * pool; the per-run cap and this global ceiling are the two bounds, both
7
- * enforced at the same seam (the tool's slot acquisition).
6
+ * pool; the per-run cap and this global ceiling are the two bounds, enforced
7
+ * where each concrete subagent session is launched.
8
8
  */
9
9
  /** Default process-wide ceiling on concurrently live subagent sessions. */
10
10
  export declare const DEFAULT_GLOBAL_SUBAGENT_SLOTS = 8;
@@ -20,7 +20,7 @@ export declare class SubagentSlotPool {
20
20
  * Resolve with a release function once a slot frees up. Call the release
21
21
  * exactly once; releasing hands the slot to the oldest waiter.
22
22
  */
23
- acquire(): Promise<() => void>;
23
+ acquire(signal?: AbortSignal): Promise<() => void>;
24
24
  private releaser;
25
25
  }
26
26
  /** A pool that never blocks — the default when no shared ceiling is wired. */
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-slots.d.ts","sourceRoot":"","sources":["../../src/tools/subagent-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,4EAA4E;AAC5E,qBAAa,gBAAgB;IAIf,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAHrC,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,OAAO,CAAyB;IAExC,YAAqB,QAAQ,EAAE,MAAM,EAIpC;IAED,+DAA+D;IAC/D,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,CAUnC;IAED,OAAO,CAAC,QAAQ;CAUjB;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,IAAI,gBAAgB,CAEpD"}
1
+ {"version":3,"file":"subagent-slots.d.ts","sourceRoot":"","sources":["../../src/tools/subagent-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,2EAA2E;AAC3E,eAAO,MAAM,6BAA6B,IAAI,CAAC;AAE/C,4EAA4E;AAC5E,qBAAa,gBAAgB;IAQf,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAPrC,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,OAAO,CAIP;IAER,YAAqB,QAAQ,EAAE,MAAM,EAIpC;IAED,+DAA+D;IAC/D,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED;;;OAGG;IACG,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAiBvD;IAED,OAAO,CAAC,QAAQ;CAcjB;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,IAAI,gBAAgB,CAEpD"}
@@ -3,9 +3,12 @@
3
3
  * serialize agent runs, and each run's subagent tool bounds its own fan-out
4
4
  * — but without a shared ceiling, N busy conversations hold N × per-run-cap
5
5
  * live subagent sessions. Every subagent launch draws a slot from one shared
6
- * pool; the per-run cap and this global ceiling are the two bounds, both
7
- * enforced at the same seam (the tool's slot acquisition).
6
+ * pool; the per-run cap and this global ceiling are the two bounds, enforced
7
+ * where each concrete subagent session is launched.
8
8
  */
9
+ function abortError() {
10
+ return new DOMException("The operation was aborted", "AbortError");
11
+ }
9
12
  /** Default process-wide ceiling on concurrently live subagent sessions. */
10
13
  export const DEFAULT_GLOBAL_SUBAGENT_SLOTS = 8;
11
14
  /** Async slot pool: at most `capacity` concurrent holders, FIFO waiters. */
@@ -26,16 +29,25 @@ export class SubagentSlotPool {
26
29
  * Resolve with a release function once a slot frees up. Call the release
27
30
  * exactly once; releasing hands the slot to the oldest waiter.
28
31
  */
29
- async acquire() {
32
+ async acquire(signal) {
33
+ if (signal?.aborted)
34
+ throw abortError();
30
35
  if (this.held < this.capacity) {
31
36
  this.held += 1;
32
37
  return this.releaser();
33
38
  }
34
- await new Promise((resolve) => {
35
- this.waiters.push(resolve);
39
+ return new Promise((resolve, reject) => {
40
+ const waiter = { resolve, signal };
41
+ waiter.onAbort = () => {
42
+ const index = this.waiters.indexOf(waiter);
43
+ if (index < 0)
44
+ return;
45
+ this.waiters.splice(index, 1);
46
+ reject(abortError());
47
+ };
48
+ signal?.addEventListener("abort", waiter.onAbort, { once: true });
49
+ this.waiters.push(waiter);
36
50
  });
37
- this.held += 1;
38
- return this.releaser();
39
51
  }
40
52
  releaser() {
41
53
  let released = false;
@@ -43,10 +55,13 @@ export class SubagentSlotPool {
43
55
  if (released)
44
56
  return;
45
57
  released = true;
46
- this.held -= 1;
47
58
  const next = this.waiters.shift();
48
- if (next)
49
- next();
59
+ if (next) {
60
+ next.signal?.removeEventListener("abort", next.onAbort);
61
+ next.resolve(this.releaser());
62
+ return;
63
+ }
64
+ this.held -= 1;
50
65
  };
51
66
  }
52
67
  }
@@ -1 +1 @@
1
- {"version":3,"file":"subagent-slots.js","sourceRoot":"","sources":["../../src/tools/subagent-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,2EAA2E;AAC3E,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAE/C,4EAA4E;AAC5E,MAAM,OAAO,gBAAgB;IAI3B,YAAqB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAH7B,SAAI,GAAG,CAAC,CAAC;QACT,YAAO,GAAsB,EAAE,CAAC;QAGtC,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,+CAA+C,QAAQ,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;YACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;QACD,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAClC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;QACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAEO,QAAQ;QACd,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,OAAO,GAAG,EAAE;YACV,IAAI,QAAQ;gBAAE,OAAO;YACrB,QAAQ,GAAG,IAAI,CAAC;YAChB,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;YACf,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YAClC,IAAI,IAAI;gBAAE,IAAI,EAAE,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC;CACF;AAED,8EAA8E;AAC9E,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,gBAAgB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AACvD,CAAC","sourcesContent":["/**\n * Process-wide subagent fan-out account. The per-conversation queues\n * serialize agent runs, and each run's subagent tool bounds its own fan-out\n * — but without a shared ceiling, N busy conversations hold N × per-run-cap\n * live subagent sessions. Every subagent launch draws a slot from one shared\n * pool; the per-run cap and this global ceiling are the two bounds, both\n * enforced at the same seam (the tool's slot acquisition).\n */\n\n/** Default process-wide ceiling on concurrently live subagent sessions. */\nexport const DEFAULT_GLOBAL_SUBAGENT_SLOTS = 8;\n\n/** Async slot pool: at most `capacity` concurrent holders, FIFO waiters. */\nexport class SubagentSlotPool {\n private held = 0;\n private waiters: Array<() => void> = [];\n\n constructor(readonly capacity: number) {\n if (!(capacity >= 1)) {\n throw new Error(`SubagentSlotPool capacity must be >= 1, got ${capacity}`);\n }\n }\n\n /** Currently held slots (for tests and capacity reporting). */\n get inFlight(): number {\n return this.held;\n }\n\n /**\n * Resolve with a release function once a slot frees up. Call the release\n * exactly once; releasing hands the slot to the oldest waiter.\n */\n async acquire(): Promise<() => void> {\n if (this.held < this.capacity) {\n this.held += 1;\n return this.releaser();\n }\n await new Promise<void>((resolve) => {\n this.waiters.push(resolve);\n });\n this.held += 1;\n return this.releaser();\n }\n\n private releaser(): () => void {\n let released = false;\n return () => {\n if (released) return;\n released = true;\n this.held -= 1;\n const next = this.waiters.shift();\n if (next) next();\n };\n }\n}\n\n/** A pool that never blocks — the default when no shared ceiling is wired. */\nexport function unboundedSlotPool(): SubagentSlotPool {\n return new SubagentSlotPool(Number.MAX_SAFE_INTEGER);\n}\n"]}
1
+ {"version":3,"file":"subagent-slots.js","sourceRoot":"","sources":["../../src/tools/subagent-slots.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,SAAS,UAAU;IACjB,OAAO,IAAI,YAAY,CAAC,2BAA2B,EAAE,YAAY,CAAC,CAAC;AACrE,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAAC,CAAC;AAE/C,4EAA4E;AAC5E,MAAM,OAAO,gBAAgB;IAQ3B,YAAqB,QAAgB;QAAhB,aAAQ,GAAR,QAAQ,CAAQ;QAP7B,SAAI,GAAG,CAAC,CAAC;QACT,YAAO,GAIV,EAAE,CAAC;QAGN,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,+CAA+C,QAAQ,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC;IAED,+DAA+D;IAC/D,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,MAAoB;QAChC,IAAI,MAAM,EAAE,OAAO;YAAE,MAAM,UAAU,EAAE,CAAC;QACxC,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;YACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;QACzB,CAAC;QACD,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,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ialize agent runs, and each run's subagent tool bounds its own fan-out\n * — but without a shared ceiling, N busy conversations hold N × per-run-cap\n * live subagent sessions. Every subagent launch draws a slot from one shared\n * pool; the per-run cap and this global ceiling are the two bounds, enforced\n * where each concrete subagent session is launched.\n */\n\nfunction abortError(): Error {\n return new DOMException(\"The operation was aborted\", \"AbortError\");\n}\n\n/** Default process-wide ceiling on concurrently live subagent sessions. */\nexport const DEFAULT_GLOBAL_SUBAGENT_SLOTS = 8;\n\n/** Async slot pool: at most `capacity` concurrent holders, FIFO waiters. */\nexport class SubagentSlotPool {\n private held = 0;\n private waiters: Array<{\n resolve: (release: () => void) => void;\n signal?: AbortSignal;\n onAbort?: () => void;\n }> = [];\n\n constructor(readonly capacity: number) {\n if (!(capacity >= 1)) {\n throw new Error(`SubagentSlotPool capacity must be >= 1, got ${capacity}`);\n }\n }\n\n /** Currently held slots (for tests and capacity reporting). */\n get inFlight(): number {\n return this.held;\n }\n\n /**\n * Resolve with a release function once a slot frees up. Call the release\n * exactly once; releasing hands the slot to the oldest waiter.\n */\n async acquire(signal?: AbortSignal): Promise<() => void> {\n if (signal?.aborted) throw abortError();\n if (this.held < this.capacity) {\n this.held += 1;\n return this.releaser();\n }\n return new Promise<() => void>((resolve, reject) => {\n const waiter: (typeof this.waiters)[number] = { resolve, signal };\n waiter.onAbort = () => {\n const index = this.waiters.indexOf(waiter);\n if (index < 0) return;\n this.waiters.splice(index, 1);\n reject(abortError());\n };\n signal?.addEventListener(\"abort\", waiter.onAbort, { once: true });\n this.waiters.push(waiter);\n });\n }\n\n private releaser(): () => void {\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const next = this.waiters.shift();\n if (next) {\n next.signal?.removeEventListener(\"abort\", next.onAbort!);\n next.resolve(this.releaser());\n return;\n }\n this.held -= 1;\n };\n }\n}\n\n/** A pool that never blocks — the default when no shared ceiling is wired. */\nexport function unboundedSlotPool(): SubagentSlotPool {\n return new SubagentSlotPool(Number.MAX_SAFE_INTEGER);\n}\n"]}
@@ -1,12 +1,15 @@
1
1
  import type { AgentTool } from "@earendil-works/pi-agent-core";
2
2
  import { type TSchema } from "@sinclair/typebox";
3
3
  import type { SubagentRunOutput, SubagentRunRequest, SubagentRunResult } from "../harness/types.js";
4
- import { type SubagentSlotPool } from "./subagent-slots.js";
5
4
  declare const subagentSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
6
5
  task: import("@sinclair/typebox").TString;
7
6
  label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
8
7
  systemPrompt: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
9
8
  input: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
9
+ parentContext: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
10
+ mode: import("@sinclair/typebox").TLiteral<"normalized">;
11
+ recentTurns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
12
+ }>>;
10
13
  model: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
11
14
  provider: import("@sinclair/typebox").TString;
12
15
  id: import("@sinclair/typebox").TString;
@@ -20,6 +23,10 @@ declare const subagentSchema: import("@sinclair/typebox").TUnion<[import("@sincl
20
23
  maxDurationMs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
21
24
  }>>;
22
25
  }>, import("@sinclair/typebox").TObject<{
26
+ parentContext: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
27
+ mode: import("@sinclair/typebox").TLiteral<"normalized">;
28
+ recentTurns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
29
+ }>>;
23
30
  model: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
24
31
  provider: import("@sinclair/typebox").TString;
25
32
  id: import("@sinclair/typebox").TString;
@@ -39,6 +46,10 @@ declare const subagentSchema: import("@sinclair/typebox").TUnion<[import("@sincl
39
46
  input: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnknown>;
40
47
  }>>;
41
48
  }>, import("@sinclair/typebox").TObject<{
49
+ parentContext: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
50
+ mode: import("@sinclair/typebox").TLiteral<"normalized">;
51
+ recentTurns: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
52
+ }>>;
42
53
  model: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
43
54
  provider: import("@sinclair/typebox").TString;
44
55
  id: import("@sinclair/typebox").TString;
@@ -69,6 +80,6 @@ type RunSubagent = <TOutputSchema extends TSchema | undefined = undefined>(reque
69
80
  * `globalSlots` is the process-wide fan-out account shared across every
70
81
  * conversation's tool instance; omitted, fan-out is bounded per run only.
71
82
  */
72
- export declare function createSubagentTool(runSubagent: RunSubagent, globalSlots?: SubagentSlotPool): AgentTool<typeof subagentSchema>;
83
+ export declare function createSubagentTool(runSubagent: RunSubagent): AgentTool<typeof subagentSchema>;
73
84
  export {};
74
85
  //# sourceMappingURL=subagent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../src/tools/subagent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA2B,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAqD/E,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBlB,CAAC;AAMH,KAAK,WAAW,GAAG,CAAC,aAAa,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EACvE,OAAO,EAAE,kBAAkB,CAAC,aAAa,CAAC,KACvC,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AA8RlE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,WAAW,EACxB,WAAW,GAAE,gBAAsC,GAClD,SAAS,CAAC,OAAO,cAAc,CAAC,CAgElC"}
1
+ {"version":3,"file":"subagent.d.ts","sourceRoot":"","sources":["../../src/tools/subagent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAA2B,MAAM,+BAA+B,CAAC;AACxF,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AA2D7B,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwBlB,CAAC;AASH,KAAK,WAAW,GAAG,CAAC,aAAa,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EACvE,OAAO,EAAE,kBAAkB,CAAC,aAAa,CAAC,KACvC,OAAO,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;AA2RlE;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC,OAAO,cAAc,CAAC,CAgE7F"}
@@ -1,5 +1,4 @@
1
1
  import { Type } from "@sinclair/typebox";
2
- import { unboundedSlotPool } from "./subagent-slots.js";
3
2
  const MAX_DAG_NODES = 8;
4
3
  const MAX_DAG_EDGES = 16;
5
4
  const MAX_DAG_DEPTH = 4;
@@ -12,6 +11,10 @@ const taskProperties = {
12
11
  input: Type.Optional(Type.Unknown({ description: "Optional JSON-serializable structured input for the task." })),
13
12
  };
14
13
  const sharedProperties = {
14
+ parentContext: Type.Optional(Type.Object({
15
+ mode: Type.Literal("normalized"),
16
+ recentTurns: Type.Optional(Type.Integer({ minimum: 1, maximum: 8, default: 3 })),
17
+ })),
15
18
  model: Type.Optional(Type.Object({ provider: Type.String(), id: Type.String() })),
16
19
  tools: Type.Optional(Type.Array(Type.String(), {
17
20
  description: "Tool names explicitly granted to each subagent. Defaults to no tools.",
@@ -105,6 +108,9 @@ function taskLabel(task, fallback) {
105
108
  return task.label?.trim() || task.task.trim().slice(0, 48) || fallback;
106
109
  }
107
110
  function formatOutcome(outcome) {
111
+ if (outcome.status === "budget_exceeded") {
112
+ return `Subagent stopped: budget limit exceeded${outcome.error ? ` (${outcome.error})` : ""}`;
113
+ }
108
114
  if (outcome.status !== "completed") {
109
115
  return `Subagent ${outcome.status}${outcome.error ? `: ${outcome.error}` : ""}`;
110
116
  }
@@ -118,6 +124,7 @@ function buildRequest(task, shared, signal) {
118
124
  task: task.task,
119
125
  ...(task.systemPrompt ? { systemPrompt: task.systemPrompt } : {}),
120
126
  ...(task.input !== undefined ? { input: task.input } : {}),
127
+ ...(shared.parentContext ? { parentContext: shared.parentContext } : {}),
121
128
  ...(shared.model ? { model: shared.model } : {}),
122
129
  ...(shared.tools ? { tools: shared.tools } : {}),
123
130
  ...(outputSchema ? { outputSchema } : {}),
@@ -240,11 +247,10 @@ function planRequest(item, shared, outcomes, signal) {
240
247
  return buildRequest({ ...item.task, input }, shared, signal);
241
248
  }
242
249
  /**
243
- * One executor for every mode: wave barriers, a bounded slot pool inside
244
- * each wave, and one global slot per actual subagent launch — the seam where
245
- * both the per-run cap and the process-wide ceiling are enforced.
250
+ * One executor for every mode: wave barriers and a per-invocation concurrency
251
+ * bound. Process-wide slots are acquired by the shared runner seam.
246
252
  */
247
- async function runWaves(plan, shared, runSubagent, progress, globalSlots, signal) {
253
+ async function runWaves(plan, shared, runSubagent, progress, signal) {
248
254
  const outcomes = new Map();
249
255
  for (const wave of plan.waves) {
250
256
  await forEachConcurrent(wave, plan.concurrency, async (item) => {
@@ -258,15 +264,9 @@ async function runWaves(plan, shared, runSubagent, progress, globalSlots, signal
258
264
  progress.update(item.id, "skipped");
259
265
  return;
260
266
  }
261
- const release = await globalSlots.acquire();
262
267
  let result;
263
- try {
264
- progress.update(item.id, "running");
265
- result = await runSubagent(planRequest(item, shared, outcomes, signal));
266
- }
267
- finally {
268
- release();
269
- }
268
+ progress.update(item.id, "running");
269
+ result = await runSubagent(planRequest(item, shared, outcomes, signal));
270
270
  outcomes.set(item.id, { id: item.id, ...result });
271
271
  progress.update(item.id, result.status);
272
272
  });
@@ -278,18 +278,18 @@ async function runWaves(plan, shared, runSubagent, progress, globalSlots, signal
278
278
  * `globalSlots` is the process-wide fan-out account shared across every
279
279
  * conversation's tool instance; omitted, fan-out is bounded per run only.
280
280
  */
281
- export function createSubagentTool(runSubagent, globalSlots = unboundedSlotPool()) {
281
+ export function createSubagentTool(runSubagent) {
282
282
  return {
283
283
  name: "subagent",
284
284
  label: "Subagent",
285
285
  description: `Run fresh isolated subagents. Use task for one subagent, tasks for independent concurrent work, or dag.nodes for a bounded dependency graph. At most ${MAX_CONCURRENT_SUBAGENTS} subagents run concurrently. DAG limits: ${MAX_DAG_NODES} nodes, ${MAX_DAG_EDGES} edges, depth ${MAX_DAG_DEPTH}; failed dependencies skip descendants, and dependency outputs larger than ${MAX_DEPENDENCY_OUTPUT_CHARS} characters reach downstream nodes as a truncated string. ` +
286
- "Subagents have no history or tools unless explicitly provided; nested subagents are not allowed.",
286
+ "Subagents are fresh by default; parentContext.mode=normalized can include a sanitized reference snapshot of the active parent run. They have no tools unless explicitly provided; nested subagents are not allowed.",
287
287
  parameters: subagentSchema,
288
288
  execute: async (_toolCallId, params, signal, onUpdate) => {
289
289
  const plan = buildPlan(params);
290
290
  const progress = new SubagentProgressTracker(plan.mode, plan.items.map(({ id, label }) => ({ id, label })), onUpdate);
291
291
  progress.emit();
292
- const ordered = await runWaves(plan, params, runSubagent, progress, globalSlots, signal);
292
+ const ordered = await runWaves(plan, params, runSubagent, progress, signal);
293
293
  switch (plan.mode) {
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C,MAAM,CAAC;6BAChB;yBACF;wBACD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE;qBACvC,CAAC;gBACJ,CAAC;gBACD,KAAK,QAAQ,EAAE,CAAC;oBACd,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;oBAC1C,OAAO;wBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;wBACxD,OAAO,EAAE,MAAM;qBAChB,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool, AgentToolUpdateCallback } from \"@earendil-works/pi-agent-core\";\nimport { Type, type Static, type TSchema } from \"@sinclair/typebox\";\nimport type {\n SubagentRunOutput,\n SubagentRunRequest,\n SubagentRunResult,\n SubagentRunStatus,\n} from \"../harness/types.js\";\nimport { unboundedSlotPool, type SubagentSlotPool } from \"./subagent-slots.js\";\n\nconst MAX_DAG_NODES = 8;\nconst MAX_DAG_EDGES = 16;\nconst MAX_DAG_DEPTH = 4;\nconst MAX_CONCURRENT_SUBAGENTS = 4;\nconst MAX_DEPENDENCY_OUTPUT_CHARS = 4000;\n\nconst taskProperties = {\n task: Type.String({ minLength: 1, description: \"Self-contained task for a fresh subagent.\" }),\n label: Type.Optional(\n Type.String({ maxLength: 64, description: \"Short progress label for this subagent.\" }),\n ),\n systemPrompt: Type.Optional(\n Type.String({ description: \"Optional role or behavior instructions for the subagent.\" }),\n ),\n input: Type.Optional(\n Type.Unknown({ description: \"Optional JSON-serializable structured input for the task.\" }),\n ),\n};\n\nconst sharedProperties = {\n model: Type.Optional(Type.Object({ provider: Type.String(), id: Type.String() })),\n tools: Type.Optional(\n Type.Array(Type.String(), {\n description: \"Tool names explicitly granted to each subagent. Defaults to no tools.\",\n }),\n ),\n outputSchema: Type.Optional(\n Type.Record(Type.String(), Type.Unknown(), {\n description: \"Optional TypeBox/JSON Schema applied to every subagent result.\",\n }),\n ),\n budget: Type.Optional(\n Type.Object({\n maxTurns: Type.Optional(Type.Integer({ minimum: 1 })),\n maxTokens: Type.Optional(Type.Integer({ minimum: 1 })),\n maxCostUsd: Type.Optional(Type.Number({ minimum: 0 })),\n maxDurationMs: Type.Optional(Type.Integer({ minimum: 1 })),\n }),\n ),\n};\n\nconst subagentTaskSchema = Type.Object(taskProperties);\nconst dagNodeSchema = Type.Object({\n id: Type.String({\n pattern: \"^[A-Za-z0-9_-]+$\",\n maxLength: 64,\n description: \"Unique stable node id used by dependsOn.\",\n }),\n ...taskProperties,\n dependsOn: Type.Optional(Type.Array(Type.String(), { maxItems: MAX_DAG_NODES })),\n});\nconst subagentSchema = Type.Union([\n Type.Object({ ...taskProperties, ...sharedProperties }),\n Type.Object({\n tasks: Type.Array(subagentTaskSchema, {\n minItems: 1,\n maxItems: MAX_DAG_NODES,\n description:\n \"Independent subagent tasks executed concurrently; results preserve input order.\",\n }),\n ...sharedProperties,\n }),\n Type.Object({\n dag: Type.Object({\n nodes: Type.Array(dagNodeSchema, { minItems: 1, maxItems: MAX_DAG_NODES }),\n maxConcurrency: Type.Optional(\n Type.Integer({\n minimum: 1,\n maximum: MAX_CONCURRENT_SUBAGENTS,\n default: MAX_CONCURRENT_SUBAGENTS,\n }),\n ),\n }),\n ...sharedProperties,\n }),\n]);\n\ntype SubagentParams = Static<typeof subagentSchema>;\ntype SubagentTask = Static<typeof subagentTaskSchema>;\ntype DagNode = Static<typeof dagNodeSchema>;\ntype SharedParams = Pick<SubagentParams, \"model\" | \"tools\" | \"outputSchema\" | \"budget\">;\ntype RunSubagent = <TOutputSchema extends TSchema | undefined = undefined>(\n request: SubagentRunRequest<TOutputSchema>,\n) => Promise<SubagentRunResult<SubagentRunOutput<TOutputSchema>>>;\n\ntype PlanMode = \"single\" | \"parallel\" | \"dag\";\n\n/** One planned subagent run; single and tasks modes are plans with no edges. */\ninterface PlanItem {\n id: string;\n label: string;\n task: SubagentTask;\n dependsOn: string[];\n}\n\ninterface Plan {\n mode: PlanMode;\n items: PlanItem[];\n waves: PlanItem[][];\n concurrency: number;\n}\n\ntype PlanOutcome =\n | ({ id: string } & SubagentRunResult<unknown>)\n | { id: string; status: \"skipped\"; error: string };\n\n/**\n * Progress statuses extend run statuses with the pre- and non-run states, so\n * a new run status is surfaced verbatim (and the marker map below fails to\n * compile until it covers it) instead of silently collapsing.\n */\ntype SubagentProgressStatus = SubagentRunStatus | \"pending\" | \"running\" | \"skipped\";\n\nconst STATUS_MARKER = {\n pending: \"○\",\n running: \"●\",\n completed: \"✓\",\n failed: \"✗\",\n cancelled: \"✗\",\n timeout: \"✗\",\n budget_exceeded: \"✗\",\n invalid_output: \"✗\",\n skipped: \"⊘\",\n} satisfies Record<SubagentProgressStatus, string>;\n\nclass SubagentProgressTracker {\n private readonly states = new Map<string, SubagentProgressStatus>();\n\n constructor(\n private readonly mode: PlanMode,\n private readonly items: Array<{ id: string; label: string }>,\n private readonly onUpdate?: AgentToolUpdateCallback,\n ) {\n for (const item of items) this.states.set(item.id, \"pending\");\n }\n\n update(id: string, status: SubagentProgressStatus): void {\n this.states.set(id, status);\n this.emit();\n }\n\n emit(): void {\n if (!this.onUpdate) return;\n const nodes = this.items.map((item) => ({\n ...item,\n status: this.states.get(item.id) ?? (\"pending\" as SubagentProgressStatus),\n }));\n const settled = nodes.filter(\n (node) => node.status !== \"pending\" && node.status !== \"running\",\n ).length;\n const modeLabel = this.mode === \"dag\" ? \"DAG\" : this.mode === \"parallel\" ? \"parallel\" : \"run\";\n const progressLabel = [\n `Subagent ${modeLabel} ${settled}/${nodes.length}`,\n ...nodes.map((node) => `${STATUS_MARKER[node.status]} ${node.label}`),\n ].join(\" · \");\n this.onUpdate({\n content: [],\n details: { progressLabel, progress: { mode: this.mode, nodes } },\n });\n }\n}\n\nfunction taskLabel(task: SubagentTask, fallback: string): string {\n return task.label?.trim() || task.task.trim().slice(0, 48) || fallback;\n}\n\nfunction formatOutcome(outcome: {\n status: SubagentProgressStatus;\n output?: unknown;\n error?: string;\n}): string {\n if (outcome.status !== \"completed\") {\n return `Subagent ${outcome.status}${outcome.error ? `: ${outcome.error}` : \"\"}`;\n }\n return typeof outcome.output === \"string\"\n ? outcome.output\n : JSON.stringify(outcome.output, null, 2);\n}\n\nfunction buildRequest(\n task: SubagentTask,\n shared: SharedParams,\n signal?: AbortSignal,\n): SubagentRunRequest<TSchema | undefined> {\n const outputSchema = shared.outputSchema as TSchema | undefined;\n return {\n task: task.task,\n ...(task.systemPrompt ? { systemPrompt: task.systemPrompt } : {}),\n ...(task.input !== undefined ? { input: task.input } : {}),\n ...(shared.model ? { model: shared.model } : {}),\n ...(shared.tools ? { tools: shared.tools } : {}),\n ...(outputSchema ? { outputSchema } : {}),\n ...(shared.budget ? { budget: shared.budget } : {}),\n ...(signal ? { signal } : {}),\n };\n}\n\nfunction buildDagWaves(nodes: DagNode[]): DagNode[][] {\n if (nodes.length === 0 || nodes.length > MAX_DAG_NODES) {\n throw new Error(`Subagent DAG must contain 1-${MAX_DAG_NODES} nodes`);\n }\n const byId = new Map<string, DagNode>();\n let edgeCount = 0;\n for (const node of nodes) {\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(node.id)) {\n throw new Error(`Invalid subagent DAG node id: ${node.id}`);\n }\n if (byId.has(node.id)) throw new Error(`Duplicate subagent DAG node id: ${node.id}`);\n byId.set(node.id, node);\n const dependencies = new Set(node.dependsOn ?? []);\n if (dependencies.size !== (node.dependsOn?.length ?? 0)) {\n throw new Error(`Duplicate dependency on subagent DAG node: ${node.id}`);\n }\n edgeCount += dependencies.size;\n }\n if (edgeCount > MAX_DAG_EDGES) {\n throw new Error(`Subagent DAG exceeds ${MAX_DAG_EDGES} dependency edges`);\n }\n for (const node of nodes) {\n for (const dependency of node.dependsOn ?? []) {\n if (!byId.has(dependency)) {\n throw new Error(`Unknown subagent DAG dependency ${dependency} for node ${node.id}`);\n }\n if (dependency === node.id) throw new Error(`Subagent DAG node ${node.id} depends on itself`);\n }\n }\n\n const remaining = new Set(nodes.map((node) => node.id));\n const completed = new Set<string>();\n const waves: DagNode[][] = [];\n while (remaining.size > 0) {\n const wave = nodes.filter(\n (node) => remaining.has(node.id) && (node.dependsOn ?? []).every((id) => completed.has(id)),\n );\n if (wave.length === 0) throw new Error(\"Subagent DAG contains a cycle\");\n waves.push(wave);\n if (waves.length > MAX_DAG_DEPTH) {\n throw new Error(`Subagent DAG exceeds maximum depth ${MAX_DAG_DEPTH}`);\n }\n for (const node of wave) {\n remaining.delete(node.id);\n completed.add(node.id);\n }\n }\n return waves;\n}\n\nfunction itemForNode(node: DagNode): PlanItem {\n return {\n id: node.id,\n label: node.label?.trim() || node.id,\n task: node,\n dependsOn: node.dependsOn ?? [],\n };\n}\n\n/** Normalize every tool mode into one plan: nodes, waves, concurrency. */\nfunction buildPlan(params: SubagentParams): Plan {\n if (\"dag\" in params) {\n const waves = buildDagWaves(params.dag.nodes).map((wave) => wave.map(itemForNode));\n const requested = params.dag.maxConcurrency ?? MAX_CONCURRENT_SUBAGENTS;\n return {\n mode: \"dag\",\n items: params.dag.nodes.map(itemForNode),\n waves,\n concurrency: Math.max(1, Math.min(MAX_CONCURRENT_SUBAGENTS, Math.floor(requested))),\n };\n }\n if (\"tasks\" in params) {\n const items = params.tasks.map((task, index) => ({\n id: String(index),\n label: taskLabel(task, String(index + 1)),\n task,\n dependsOn: [],\n }));\n return { mode: \"parallel\", items, waves: [items], concurrency: MAX_CONCURRENT_SUBAGENTS };\n }\n const item = { id: \"0\", label: taskLabel(params, \"subagent\"), task: params, dependsOn: [] };\n return { mode: \"single\", items: [item], waves: [[item]], concurrency: 1 };\n}\n\n/** Run `worker` over every item with at most `limit` in flight. */\nasync function forEachConcurrent<T>(\n items: readonly T[],\n limit: number,\n worker: (item: T, index: number) => Promise<void>,\n): Promise<void> {\n let cursor = 0;\n await Promise.all(\n Array.from({ length: Math.min(limit, items.length) }, async () => {\n while (cursor < items.length) {\n const index = cursor++;\n await worker(items[index], index);\n }\n }),\n );\n}\n\nfunction dependencyOutput(outcome: PlanOutcome): unknown {\n if (outcome.status !== \"completed\") return undefined;\n const value = outcome.output;\n const serialized = typeof value === \"string\" ? value : JSON.stringify(value);\n if (serialized === undefined) return null;\n if (serialized.length <= MAX_DEPENDENCY_OUTPUT_CHARS) return value;\n // Oversized structured output becomes a marked string — the shape is lost,\n // which the tool description warns downstream consumers about.\n return `${serialized.slice(0, MAX_DEPENDENCY_OUTPUT_CHARS)}\\n[truncated]`;\n}\n\nfunction planRequest(\n item: PlanItem,\n shared: SharedParams,\n outcomes: Map<string, PlanOutcome>,\n signal?: AbortSignal,\n): SubagentRunRequest<TSchema | undefined> {\n if (item.dependsOn.length === 0) return buildRequest(item.task, shared, signal);\n const dependencies = Object.fromEntries(\n item.dependsOn.map((id) => [id, dependencyOutput(outcomes.get(id)!)]),\n );\n const input = {\n ...(item.task.input !== undefined ? { input: item.task.input } : {}),\n dependencies,\n };\n return buildRequest({ ...item.task, input }, shared, signal);\n}\n\n/**\n * One executor for every mode: wave barriers, a bounded slot pool inside\n * each wave, and one global slot per actual subagent launch — the seam where\n * both the per-run cap and the process-wide ceiling are enforced.\n */\nasync function runWaves(\n plan: Plan,\n shared: SharedParams,\n runSubagent: RunSubagent,\n progress: SubagentProgressTracker,\n globalSlots: SubagentSlotPool,\n signal?: AbortSignal,\n): Promise<PlanOutcome[]> {\n const outcomes = new Map<string, PlanOutcome>();\n for (const wave of plan.waves) {\n await forEachConcurrent(wave, plan.concurrency, async (item) => {\n const failedDependency = item.dependsOn.find(\n (id) => outcomes.get(id)?.status !== \"completed\",\n );\n if (failedDependency) {\n outcomes.set(item.id, {\n id: item.id,\n status: \"skipped\",\n error: `Dependency ${failedDependency} did not complete`,\n });\n progress.update(item.id, \"skipped\");\n return;\n }\n const release = await globalSlots.acquire();\n let result: SubagentRunResult<unknown>;\n try {\n progress.update(item.id, \"running\");\n result = await runSubagent(planRequest(item, shared, outcomes, signal));\n } finally {\n release();\n }\n outcomes.set(item.id, { id: item.id, ...result });\n progress.update(item.id, result.status);\n });\n }\n return plan.items.map((item) => outcomes.get(item.id)!);\n}\n\n/**\n * Create the normal agent's bounded subagent delegation and DAG tool.\n * `globalSlots` is the process-wide fan-out account shared across every\n * conversation's tool instance; omitted, fan-out is bounded per run only.\n */\nexport function createSubagentTool(\n runSubagent: RunSubagent,\n globalSlots: SubagentSlotPool = unboundedSlotPool(),\n): AgentTool<typeof subagentSchema> {\n return {\n name: \"subagent\",\n label: \"Subagent\",\n description:\n `Run fresh isolated subagents. Use task for one subagent, tasks for independent concurrent work, or dag.nodes for a bounded dependency graph. At most ${MAX_CONCURRENT_SUBAGENTS} subagents run concurrently. DAG limits: ${MAX_DAG_NODES} nodes, ${MAX_DAG_EDGES} edges, depth ${MAX_DAG_DEPTH}; failed dependencies skip descendants, and dependency outputs larger than ${MAX_DEPENDENCY_OUTPUT_CHARS} characters reach downstream nodes as a truncated string. ` +\n \"Subagents have no history or tools unless explicitly provided; nested subagents are not allowed.\",\n parameters: subagentSchema,\n execute: async (\n _toolCallId: string,\n params: SubagentParams,\n signal?: AbortSignal,\n onUpdate?: AgentToolUpdateCallback,\n ) => {\n const plan = buildPlan(params);\n const progress = new SubagentProgressTracker(\n plan.mode,\n plan.items.map(({ id, label }) => ({ id, label })),\n onUpdate,\n );\n progress.emit();\n const ordered = await runWaves(plan, params, runSubagent, progress, globalSlots, signal);\n\n switch (plan.mode) {\n case \"dag\":\n return {\n content: [\n {\n type: \"text\",\n text: ordered\n .map((outcome) => `[${outcome.id}] ${formatOutcome(outcome)}`)\n .join(\"\\n\\n\"),\n },\n ],\n details: {\n mode: \"dag\",\n waves: plan.waves.map((wave) => wave.map((item) => item.id)),\n results: ordered,\n },\n };\n case \"parallel\": {\n const results = ordered.map(({ id: _id, ...result }) => result);\n return {\n content: [\n {\n type: \"text\",\n text: results\n .map((result, index) => `[${index + 1}] ${formatOutcome(result)}`)\n .join(\"\\n\\n\"),\n },\n ],\n details: { mode: \"parallel\", results },\n };\n }\n case \"single\": {\n const { id: _id, ...result } = ordered[0];\n return {\n content: [{ type: \"text\", text: formatOutcome(result) }],\n details: result,\n };\n }\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"subagent.js","sourceRoot":"","sources":["../../src/tools/subagent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAA6B,MAAM,mBAAmB,CAAC;AAQpE,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,wBAAwB,GAAG,CAAC,CAAC;AACnC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEzC,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;IAC7F,KAAK,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC,CACvF;IACD,YAAY,EAAE,IAAI,CAAC,QAAQ,CACzB,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,0DAA0D,EAAE,CAAC,CACzF;IACD,KAAK,EAAE,IAAI,CAAC,QAAQ,CAClB,IAAI,CAAC,OAAO,CAAC,EAAE,WAAW,EAAE,2DAA2D,EAAE,CAAC,CAC3F;CACF,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,aAAa,EAAE,IAAI,CAAC,QAAQ,CAC1B,IAAI,CAAC,MAAM,CAAC;QACV,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC;QAChC,WAAW,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAA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,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;4BAC5D,OAAO,EAAE,OAAO;yBACjB;qBACF,CAAC;gBACJ,KAAK,UAAU,EAAE,CAAC;oBAChB,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;oBAChE,OAAO;wBACL,OAAO,EAAE;4BACP;gCACE,IAAI,EAAE,MAAM;gCACZ,IAAI,EAAE,OAAO;qCACV,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;qCACjE,IAAI,CAAC,MAAM,CAAC;6BAChB;yBACF;wBACD,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE;qBACvC,CAAC;gBACJ,CAAC;gBACD,KAAK,QAAQ,EAAE,CAAC;oBACd,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;oBAC1C,OAAO;wBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;wBACxD,OAAO,EAAE,MAAM;qBAChB,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentTool, AgentToolUpdateCallback } from \"@earendil-works/pi-agent-core\";\nimport { Type, type Static, type TSchema } from \"@sinclair/typebox\";\nimport type {\n SubagentRunOutput,\n SubagentRunRequest,\n SubagentRunResult,\n SubagentRunStatus,\n} from \"../harness/types.js\";\n\nconst MAX_DAG_NODES = 8;\nconst MAX_DAG_EDGES = 16;\nconst MAX_DAG_DEPTH = 4;\nconst MAX_CONCURRENT_SUBAGENTS = 4;\nconst MAX_DEPENDENCY_OUTPUT_CHARS = 4000;\n\nconst taskProperties = {\n task: Type.String({ minLength: 1, description: \"Self-contained task for a fresh subagent.\" }),\n label: Type.Optional(\n Type.String({ maxLength: 64, description: \"Short progress label for this subagent.\" }),\n ),\n systemPrompt: Type.Optional(\n Type.String({ description: \"Optional role or behavior instructions for the subagent.\" }),\n ),\n input: Type.Optional(\n Type.Unknown({ description: \"Optional JSON-serializable structured input for the task.\" }),\n ),\n};\n\nconst sharedProperties = {\n parentContext: Type.Optional(\n Type.Object({\n mode: Type.Literal(\"normalized\"),\n recentTurns: Type.Optional(Type.Integer({ minimum: 1, maximum: 8, default: 3 })),\n }),\n ),\n model: Type.Optional(Type.Object({ provider: Type.String(), id: Type.String() })),\n tools: Type.Optional(\n Type.Array(Type.String(), {\n description: \"Tool names explicitly granted to each subagent. Defaults to no tools.\",\n }),\n ),\n outputSchema: Type.Optional(\n Type.Record(Type.String(), Type.Unknown(), {\n description: \"Optional TypeBox/JSON Schema applied to every subagent result.\",\n }),\n ),\n budget: Type.Optional(\n Type.Object({\n maxTurns: Type.Optional(Type.Integer({ minimum: 1 })),\n maxTokens: Type.Optional(Type.Integer({ minimum: 1 })),\n maxCostUsd: Type.Optional(Type.Number({ minimum: 0 })),\n maxDurationMs: Type.Optional(Type.Integer({ minimum: 1 })),\n }),\n ),\n};\n\nconst subagentTaskSchema = Type.Object(taskProperties);\nconst dagNodeSchema = Type.Object({\n id: Type.String({\n pattern: \"^[A-Za-z0-9_-]+$\",\n maxLength: 64,\n description: \"Unique stable node id used by dependsOn.\",\n }),\n ...taskProperties,\n dependsOn: Type.Optional(Type.Array(Type.String(), { maxItems: MAX_DAG_NODES })),\n});\nconst subagentSchema = Type.Union([\n Type.Object({ ...taskProperties, ...sharedProperties }),\n Type.Object({\n tasks: Type.Array(subagentTaskSchema, {\n minItems: 1,\n maxItems: MAX_DAG_NODES,\n description:\n \"Independent subagent tasks executed concurrently; results preserve input order.\",\n }),\n ...sharedProperties,\n }),\n Type.Object({\n dag: Type.Object({\n nodes: Type.Array(dagNodeSchema, { minItems: 1, maxItems: MAX_DAG_NODES }),\n maxConcurrency: Type.Optional(\n Type.Integer({\n minimum: 1,\n maximum: MAX_CONCURRENT_SUBAGENTS,\n default: MAX_CONCURRENT_SUBAGENTS,\n }),\n ),\n }),\n ...sharedProperties,\n }),\n]);\n\ntype SubagentParams = Static<typeof subagentSchema>;\ntype SubagentTask = Static<typeof subagentTaskSchema>;\ntype DagNode = Static<typeof dagNodeSchema>;\ntype SharedParams = Pick<\n SubagentParams,\n \"parentContext\" | \"model\" | \"tools\" | \"outputSchema\" | \"budget\"\n>;\ntype RunSubagent = <TOutputSchema extends TSchema | undefined = undefined>(\n request: SubagentRunRequest<TOutputSchema>,\n) => Promise<SubagentRunResult<SubagentRunOutput<TOutputSchema>>>;\n\ntype PlanMode = \"single\" | \"parallel\" | \"dag\";\n\n/** One planned subagent run; single and tasks modes are plans with no edges. */\ninterface PlanItem {\n id: string;\n label: string;\n task: SubagentTask;\n dependsOn: string[];\n}\n\ninterface Plan {\n mode: PlanMode;\n items: PlanItem[];\n waves: PlanItem[][];\n concurrency: number;\n}\n\ntype PlanOutcome =\n | ({ id: string } & SubagentRunResult<unknown>)\n | { id: string; status: \"skipped\"; error: string };\n\n/**\n * Progress statuses extend run statuses with the pre- and non-run states, so\n * a new run status is surfaced verbatim (and the marker map below fails to\n * compile until it covers it) instead of silently collapsing.\n */\ntype SubagentProgressStatus = SubagentRunStatus | \"pending\" | \"running\" | \"skipped\";\n\nconst STATUS_MARKER = {\n pending: \"○\",\n running: \"●\",\n completed: \"✓\",\n failed: \"✗\",\n cancelled: \"✗\",\n timeout: \"✗\",\n budget_exceeded: \"✗\",\n invalid_output: \"✗\",\n skipped: \"⊘\",\n} satisfies Record<SubagentProgressStatus, string>;\n\nclass SubagentProgressTracker {\n private readonly states = new Map<string, SubagentProgressStatus>();\n\n constructor(\n private readonly mode: PlanMode,\n private readonly items: Array<{ id: string; label: string }>,\n private readonly onUpdate?: AgentToolUpdateCallback,\n ) {\n for (const item of items) this.states.set(item.id, \"pending\");\n }\n\n update(id: string, status: SubagentProgressStatus): void {\n this.states.set(id, status);\n this.emit();\n }\n\n emit(): void {\n if (!this.onUpdate) return;\n const nodes = this.items.map((item) => ({\n ...item,\n status: this.states.get(item.id) ?? (\"pending\" as SubagentProgressStatus),\n }));\n const settled = nodes.filter(\n (node) => node.status !== \"pending\" && node.status !== \"running\",\n ).length;\n const modeLabel = this.mode === \"dag\" ? \"DAG\" : this.mode === \"parallel\" ? \"parallel\" : \"run\";\n const progressLabel = [\n `Subagent ${modeLabel} ${settled}/${nodes.length}`,\n ...nodes.map((node) => `${STATUS_MARKER[node.status]} ${node.label}`),\n ].join(\" · \");\n this.onUpdate({\n content: [],\n details: { progressLabel, progress: { mode: this.mode, nodes } },\n });\n }\n}\n\nfunction taskLabel(task: SubagentTask, fallback: string): string {\n return task.label?.trim() || task.task.trim().slice(0, 48) || fallback;\n}\n\nfunction formatOutcome(outcome: {\n status: SubagentProgressStatus;\n output?: unknown;\n error?: string;\n}): string {\n if (outcome.status === \"budget_exceeded\") {\n return `Subagent stopped: budget limit exceeded${outcome.error ? ` (${outcome.error})` : \"\"}`;\n }\n if (outcome.status !== \"completed\") {\n return `Subagent ${outcome.status}${outcome.error ? `: ${outcome.error}` : \"\"}`;\n }\n return typeof outcome.output === \"string\"\n ? outcome.output\n : JSON.stringify(outcome.output, null, 2);\n}\n\nfunction buildRequest(\n task: SubagentTask,\n shared: SharedParams,\n signal?: AbortSignal,\n): SubagentRunRequest<TSchema | undefined> {\n const outputSchema = shared.outputSchema as TSchema | undefined;\n return {\n task: task.task,\n ...(task.systemPrompt ? { systemPrompt: task.systemPrompt } : {}),\n ...(task.input !== undefined ? { input: task.input } : {}),\n ...(shared.parentContext ? { parentContext: shared.parentContext } : {}),\n ...(shared.model ? { model: shared.model } : {}),\n ...(shared.tools ? { tools: shared.tools } : {}),\n ...(outputSchema ? { outputSchema } : {}),\n ...(shared.budget ? { budget: shared.budget } : {}),\n ...(signal ? { signal } : {}),\n };\n}\n\nfunction buildDagWaves(nodes: DagNode[]): DagNode[][] {\n if (nodes.length === 0 || nodes.length > MAX_DAG_NODES) {\n throw new Error(`Subagent DAG must contain 1-${MAX_DAG_NODES} nodes`);\n }\n const byId = new Map<string, DagNode>();\n let edgeCount = 0;\n for (const node of nodes) {\n if (!/^[A-Za-z0-9_-]{1,64}$/.test(node.id)) {\n throw new Error(`Invalid subagent DAG node id: ${node.id}`);\n }\n if (byId.has(node.id)) throw new Error(`Duplicate subagent DAG node id: ${node.id}`);\n byId.set(node.id, node);\n const dependencies = new Set(node.dependsOn ?? []);\n if (dependencies.size !== (node.dependsOn?.length ?? 0)) {\n throw new Error(`Duplicate dependency on subagent DAG node: ${node.id}`);\n }\n edgeCount += dependencies.size;\n }\n if (edgeCount > MAX_DAG_EDGES) {\n throw new Error(`Subagent DAG exceeds ${MAX_DAG_EDGES} dependency edges`);\n }\n for (const node of nodes) {\n for (const dependency of node.dependsOn ?? []) {\n if (!byId.has(dependency)) {\n throw new Error(`Unknown subagent DAG dependency ${dependency} for node ${node.id}`);\n }\n if (dependency === node.id) throw new Error(`Subagent DAG node ${node.id} depends on itself`);\n }\n }\n\n const remaining = new Set(nodes.map((node) => node.id));\n const completed = new Set<string>();\n const waves: DagNode[][] = [];\n while (remaining.size > 0) {\n const wave = nodes.filter(\n (node) => remaining.has(node.id) && (node.dependsOn ?? []).every((id) => completed.has(id)),\n );\n if (wave.length === 0) throw new Error(\"Subagent DAG contains a cycle\");\n waves.push(wave);\n if (waves.length > MAX_DAG_DEPTH) {\n throw new Error(`Subagent DAG exceeds maximum depth ${MAX_DAG_DEPTH}`);\n }\n for (const node of wave) {\n remaining.delete(node.id);\n completed.add(node.id);\n }\n }\n return waves;\n}\n\nfunction itemForNode(node: DagNode): PlanItem {\n return {\n id: node.id,\n label: node.label?.trim() || node.id,\n task: node,\n dependsOn: node.dependsOn ?? [],\n };\n}\n\n/** Normalize every tool mode into one plan: nodes, waves, concurrency. */\nfunction buildPlan(params: SubagentParams): Plan {\n if (\"dag\" in params) {\n const waves = buildDagWaves(params.dag.nodes).map((wave) => wave.map(itemForNode));\n const requested = params.dag.maxConcurrency ?? MAX_CONCURRENT_SUBAGENTS;\n return {\n mode: \"dag\",\n items: params.dag.nodes.map(itemForNode),\n waves,\n concurrency: Math.max(1, Math.min(MAX_CONCURRENT_SUBAGENTS, Math.floor(requested))),\n };\n }\n if (\"tasks\" in params) {\n const items = params.tasks.map((task, index) => ({\n id: String(index),\n label: taskLabel(task, String(index + 1)),\n task,\n dependsOn: [],\n }));\n return { mode: \"parallel\", items, waves: [items], concurrency: MAX_CONCURRENT_SUBAGENTS };\n }\n const item = { id: \"0\", label: taskLabel(params, \"subagent\"), task: params, dependsOn: [] };\n return { mode: \"single\", items: [item], waves: [[item]], concurrency: 1 };\n}\n\n/** Run `worker` over every item with at most `limit` in flight. */\nasync function forEachConcurrent<T>(\n items: readonly T[],\n limit: number,\n worker: (item: T, index: number) => Promise<void>,\n): Promise<void> {\n let cursor = 0;\n await Promise.all(\n Array.from({ length: Math.min(limit, items.length) }, async () => {\n while (cursor < items.length) {\n const index = cursor++;\n await worker(items[index], index);\n }\n }),\n );\n}\n\nfunction dependencyOutput(outcome: PlanOutcome): unknown {\n if (outcome.status !== \"completed\") return undefined;\n const value = outcome.output;\n const serialized = typeof value === \"string\" ? value : JSON.stringify(value);\n if (serialized === undefined) return null;\n if (serialized.length <= MAX_DEPENDENCY_OUTPUT_CHARS) return value;\n // Oversized structured output becomes a marked string — the shape is lost,\n // which the tool description warns downstream consumers about.\n return `${serialized.slice(0, MAX_DEPENDENCY_OUTPUT_CHARS)}\\n[truncated]`;\n}\n\nfunction planRequest(\n item: PlanItem,\n shared: SharedParams,\n outcomes: Map<string, PlanOutcome>,\n signal?: AbortSignal,\n): SubagentRunRequest<TSchema | undefined> {\n if (item.dependsOn.length === 0) return buildRequest(item.task, shared, signal);\n const dependencies = Object.fromEntries(\n item.dependsOn.map((id) => [id, dependencyOutput(outcomes.get(id)!)]),\n );\n const input = {\n ...(item.task.input !== undefined ? { input: item.task.input } : {}),\n dependencies,\n };\n return buildRequest({ ...item.task, input }, shared, signal);\n}\n\n/**\n * One executor for every mode: wave barriers and a per-invocation concurrency\n * bound. Process-wide slots are acquired by the shared runner seam.\n */\nasync function runWaves(\n plan: Plan,\n shared: SharedParams,\n runSubagent: RunSubagent,\n progress: SubagentProgressTracker,\n signal?: AbortSignal,\n): Promise<PlanOutcome[]> {\n const outcomes = new Map<string, PlanOutcome>();\n for (const wave of plan.waves) {\n await forEachConcurrent(wave, plan.concurrency, async (item) => {\n const failedDependency = item.dependsOn.find(\n (id) => outcomes.get(id)?.status !== \"completed\",\n );\n if (failedDependency) {\n outcomes.set(item.id, {\n id: item.id,\n status: \"skipped\",\n error: `Dependency ${failedDependency} did not complete`,\n });\n progress.update(item.id, \"skipped\");\n return;\n }\n let result: SubagentRunResult<unknown>;\n progress.update(item.id, \"running\");\n result = await runSubagent(planRequest(item, shared, outcomes, signal));\n outcomes.set(item.id, { id: item.id, ...result });\n progress.update(item.id, result.status);\n });\n }\n return plan.items.map((item) => outcomes.get(item.id)!);\n}\n\n/**\n * Create the normal agent's bounded subagent delegation and DAG tool.\n * `globalSlots` is the process-wide fan-out account shared across every\n * conversation's tool instance; omitted, fan-out is bounded per run only.\n */\nexport function createSubagentTool(runSubagent: RunSubagent): AgentTool<typeof subagentSchema> {\n return {\n name: \"subagent\",\n label: \"Subagent\",\n description:\n `Run fresh isolated subagents. Use task for one subagent, tasks for independent concurrent work, or dag.nodes for a bounded dependency graph. At most ${MAX_CONCURRENT_SUBAGENTS} subagents run concurrently. DAG limits: ${MAX_DAG_NODES} nodes, ${MAX_DAG_EDGES} edges, depth ${MAX_DAG_DEPTH}; failed dependencies skip descendants, and dependency outputs larger than ${MAX_DEPENDENCY_OUTPUT_CHARS} characters reach downstream nodes as a truncated string. ` +\n \"Subagents are fresh by default; parentContext.mode=normalized can include a sanitized reference snapshot of the active parent run. They have no tools unless explicitly provided; nested subagents are not allowed.\",\n parameters: subagentSchema,\n execute: async (\n _toolCallId: string,\n params: SubagentParams,\n signal?: AbortSignal,\n onUpdate?: AgentToolUpdateCallback,\n ) => {\n const plan = buildPlan(params);\n const progress = new SubagentProgressTracker(\n plan.mode,\n plan.items.map(({ id, label }) => ({ id, label })),\n onUpdate,\n );\n progress.emit();\n const ordered = await runWaves(plan, params, runSubagent, progress, signal);\n\n switch (plan.mode) {\n case \"dag\":\n return {\n content: [\n {\n type: \"text\",\n text: ordered\n .map((outcome) => `[${outcome.id}] ${formatOutcome(outcome)}`)\n .join(\"\\n\\n\"),\n },\n ],\n details: {\n mode: \"dag\",\n waves: plan.waves.map((wave) => wave.map((item) => item.id)),\n results: ordered,\n },\n };\n case \"parallel\": {\n const results = ordered.map(({ id: _id, ...result }) => result);\n return {\n content: [\n {\n type: \"text\",\n text: results\n .map((result, index) => `[${index + 1}] ${formatOutcome(result)}`)\n .join(\"\\n\\n\"),\n },\n ],\n details: { mode: \"parallel\", results },\n };\n }\n case \"single\": {\n const { id: _id, ...result } = ordered[0];\n return {\n content: [{ type: \"text\", text: formatOutcome(result) }],\n details: result,\n };\n }\n }\n },\n };\n}\n"]}
package/dist/types.d.ts CHANGED
@@ -420,6 +420,13 @@ export interface DockerContainerManagerOptions {
420
420
  boostLimits?: ResourceLimits;
421
421
  execFileImpl?: ExecFileAsync;
422
422
  }
423
+ export interface ExecutionPlan {
424
+ credentialKey: string;
425
+ resourceKey: string;
426
+ sandboxConfig: import("./sandbox/types.js").SandboxConfig;
427
+ env?: Record<string, string>;
428
+ mounts: ContainerMount[];
429
+ }
423
430
  export interface Attachment {
424
431
  original: string;
425
432
  localPath: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE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CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAOjC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport type {\n ImmediateEventPayload,\n OneShotEventPayload,\n PeriodicEventPayload,\n} from \"./harness/event-format.js\";\n\nconst execFileAsync = promisify(execFile);\ntype ExecFileAsync = typeof execFileAsync;\n\n// ── adapter ───────────────────────────────────────────────────────────────────\n\nexport type ConversationKind = \"direct\" | \"shared\";\n\nexport type PlatformName = \"slack\" | \"discord\" | \"telegram\" | \"github\";\n\n/**\n * Who can drive conversations on a platform — gates ambient credential policy.\n *\n * - `membership`: only invited workspace/server members (Slack/Discord/Telegram).\n * Safe to copy `sandbox.defaultSharedVault` into new conversation vaults.\n * - `open-trigger`: broader trigger surface (e.g. GitHub repo writers on public\n * issues/PRs). Ambient shared vault must not apply; use host-side platform\n * identity or an explicitly provisioned vault.\n */\nexport type PlatformTrustModel = \"membership\" | \"open-trigger\";\n\nexport interface ConversationMessage {\n id: string;\n sessionKey: string;\n conversationKind: ConversationKind;\n userId: string;\n userName?: string;\n text: string;\n attachments?: { name: string; localPath: string }[];\n threadTs?: string;\n}\n\nexport interface ChatToolResult {\n toolName: string;\n label?: string;\n args?: Record<string, unknown>;\n result: string;\n isError: boolean;\n durationMs: number;\n}\n\nexport interface ConversationResponder {\n respond(text: string): Promise<void>;\n appendResponseDelta?(delta: string): Promise<void>;\n finishResponse?(finalText?: string): Promise<void>;\n replaceResponse(text: string, options?: { createOverflowLink?: () => string }): Promise<void>;\n respondDiagnostic(text: string, options?: { style?: \"muted\" | \"error\" }): Promise<void>;\n respondToolResult(result: ChatToolResult): Promise<void>;\n setTyping(isTyping: boolean): Promise<void>;\n setWorking(working: boolean): Promise<void>;\n uploadFile(filePath: string, title?: string): Promise<void>;\n /**\n * React to the message that triggered this run with an emoji short name\n * (no colons). Optional: platforms/contexts without reaction support omit\n * it, and callers must handle its absence.\n */\n react?(emoji: string): Promise<void>;\n deleteResponse(): Promise<void>;\n}\n\nexport interface MessagingInfo {\n name: string;\n formattingGuide: string;\n channels: { id: string; name: string }[];\n users: { id: string; userName: string; displayName: string }[];\n /**\n * Trust boundary for ambient credentials. Defaults to `membership` when\n * omitted (closed chat platforms). Open-trigger platforms must set this\n * explicitly so vault policy does not key off platform name strings.\n */\n trustModel?: PlatformTrustModel;\n diagnostics?: {\n showUsageSummary?: boolean;\n };\n}\n\nexport interface ChatAdapter {\n start(): Promise<void>;\n stop(): Promise<void>;\n getMessagingInfo(): MessagingInfo;\n}\n\nexport type AgentEventPayload =\n | { kind: \"sessionStart\" }\n | { kind: \"responseDelta\"; delta: string }\n | { kind: \"responseFinal\"; text: string }\n | { kind: \"diagnostic\"; text: string }\n | { kind: \"toolStart\"; toolId: string; toolName: string; input?: unknown }\n | { kind: \"toolEnd\"; toolId: string }\n | { kind: \"turnEnd\"; awaitingInput?: boolean }\n | { kind: \"sessionEnd\"; reason?: string };\n\nexport interface AgentEventEnvelope {\n source: \"mikan\";\n sessionId: string;\n actorName: string;\n event: AgentEventPayload;\n}\n\n/**\n * A platform-agnostic event (message/mention) that triggers the agent.\n */\nexport interface ConversationEvent {\n type: string;\n /** Platform-specific raw conversation/channel/chat identifier */\n conversationId: string;\n /** Optional alternate conversation identity used for vault routing. */\n vaultConversationId?: string;\n /** Cross-platform conversation shape: direct message vs shared space */\n conversationKind: ConversationKind;\n /** Message timestamp or ID as string */\n ts: string;\n /** Parent message ID for threaded replies (optional) */\n thread_ts?: string;\n /** User ID */\n user: string;\n /** Message text (already stripped of bot mentions) */\n text: string;\n /** Downloaded attachments */\n attachments?: { name: string; localPath: string }[];\n /** Platform-computed session key; overrides default conversationId:thread_ts computation */\n sessionKey?: string;\n}\n\n/**\n * Minimum interface that every platform bot must implement,\n * used by the central handler in main.ts and by EventsWatcher.\n */\nexport interface MessagingBot {\n start(): Promise<void>;\n postMessage(channel: string, text: string): Promise<string>;\n updateMessage(channel: string, ts: string, text: string): Promise<void>;\n /**\n * Add an emoji reaction to a message. `emoji` is a platform-agnostic short\n * name without colons (e.g. \"eyes\", \"white_check_mark\"). Optional so\n * adapters adopt it incrementally; callers must handle its absence.\n */\n addReaction?(channel: string, messageTs: string, emoji: string): Promise<void>;\n /**\n * Upload a host-side file into a conversation. Optional so adapters adopt\n * it incrementally; callers must handle its absence. Existing adapter\n * implementations (Slack/Discord/Telegram) already match this shape.\n */\n uploadFile?(channel: string, filePath: string, title?: string): Promise<void>;\n enqueueEvent(event: ConversationEvent): boolean;\n getMessagingInfo(): MessagingInfo;\n postPrivate?(conversationId: string, userId: string, text: string): Promise<void>;\n postPrivateDiagnostic?(\n conversationId: string,\n userId: string,\n text: string,\n options?: { style?: \"muted\" | \"error\" },\n ): Promise<void>;\n}\n\n/**\n * Post a plain message to a conversation without triggering an agent run.\n * Backs extension `api.notify`; implemented in main.ts over the platform bots.\n * `platform` is required only when more than one platform is running.\n */\nexport type PlatformNotifier = (\n conversationId: string,\n text: string,\n platform?: string,\n) => Promise<void>;\n\n/**\n * Add an emoji reaction to a message without triggering an agent run. Backs\n * extension `api.react`; implemented in main.ts over the platform bots.\n */\nexport type PlatformReactor = (\n conversationId: string,\n messageTs: string,\n emoji: string,\n platform?: string,\n) => Promise<void>;\n\n/**\n * Upload a host-side file into a conversation without triggering an agent\n * run. Backs extension `api.uploadFile`; implemented in main.ts over the\n * platform bots. `platform` is required only when more than one is running.\n */\nexport type PlatformUploader = (\n conversationId: string,\n filePath: string,\n title?: string,\n platform?: string,\n) => Promise<void>;\n\n/** Normalized platform data and reply hook for one event. */\nexport interface ConversationContext {\n message: ConversationMessage;\n responder: ConversationResponder;\n platform: MessagingInfo;\n}\n\nexport interface RunningSession {\n sessionKey: string;\n startedAt: number;\n lastActivityAt?: number;\n currentTool?: string;\n}\n\nexport interface MessagingEventHandler {\n isRunning(sessionKey: string): boolean;\n getRunningSessions(): RunningSession[];\n handleEvent(\n event: ConversationEvent,\n bot: MessagingBot,\n context: ConversationContext,\n ): Promise<void>;\n handleStop(sessionKey: string, conversationId: string, bot: MessagingBot): Promise<void>;\n forceStop(sessionKey: string): void;\n handleNewCommand(sessionKey: string, conversationId: string, bot: MessagingBot): Promise<void>;\n}\n\n// ── agent ─────────────────────────────────────────────────────────────────────\n\nexport interface PiAgentWrapper {\n syncChatHistory(currentMessageId?: string): void;\n run(\n message: ConversationMessage,\n responder: ConversationResponder,\n platform: MessagingInfo,\n ): Promise<{ stopReason: string; errorMessage?: string }>;\n abort(): void;\n getCurrentStep(): { toolName?: string; label?: string } | undefined;\n /**\n * Dispatch a leading-slash message to an extension-registered command.\n * Returns true when a command consumed the message (no agent run follows).\n */\n tryExtensionCommand(\n message: ConversationMessage,\n responder: ConversationResponder,\n ): Promise<boolean>;\n /** Run extension disposers. Call once when this wrapper is discarded. */\n dispose(): Promise<void>;\n}\n\n// ── config ────────────────────────────────────────────────────────────────────\n\nexport interface GondolinRemoteWorkerSettings {\n /** Stable placement identity; defaults to the URL. */\n name?: string;\n /** Base URL of the mikan-worker daemon, e.g. https://worker.internal:8433 */\n url: string;\n /** CA bundle that signs the daemon's server certificate. */\n caFile?: string;\n /** Client certificate + key presented to the daemon (mTLS); falls back to the fleet-level pair. */\n certFile?: string;\n keyFile?: string;\n /** Worker-side path of the shared workspace filesystem. */\n workspaceRoot?: string;\n /** Admission cap for new placements (existing runtimes always count). */\n maxRuntimes?: number;\n /** Drained workers accept no new placements; existing ones finish out. */\n draining?: boolean;\n}\n\nexport interface GondolinGatewaySettings {\n /** Port the worker gateway listens on for dial-home workers. */\n port: number;\n /**\n * Gateway server certificate + key and the CA that signs worker client\n * certificates. Omit all three to let the gateway provision its own CA and\n * server certificate under the state dir (required for `--worker-token`\n * joins).\n */\n certFile?: string;\n keyFile?: string;\n clientCaFile?: string;\n /** SANs for the auto-issued server certificate (defaults to os.hostname). */\n hostnames?: string[];\n /**\n * Worker-side path of the shared workspace filesystem. Required in practice:\n * mount sources are translated to it, and without it every runtime is\n * rejected with \"escapes the workspace root\". gondolinGateway.start()\n * enforces it at boot; typed optional to match the settings schema.\n */\n workspaceRoot?: string;\n /** Per-worker host-side overrides, keyed by worker name. */\n workers?: Record<string, { maxRuntimes?: number; draining?: boolean }>;\n}\n\nexport interface GondolinRemoteSettings {\n /** Single-worker form: connection fields inline (a fleet of one). */\n url?: string;\n caFile?: string;\n certFile?: string;\n keyFile?: string;\n workspaceRoot?: string;\n maxRuntimes?: number;\n /** Fleet form: several workers; per-worker fields fall back to the inline ones. */\n workers?: GondolinRemoteWorkerSettings[];\n /** Dial-home form: listen for workers that connect to mikan instead. */\n gateway?: GondolinGatewaySettings;\n /** Guest image selector resolved on the workers. */\n imageSelector?: string;\n /** How long a new conversation waits for capacity before failing. */\n queueWaitSeconds?: number;\n}\n\nexport interface SandboxSettings {\n cpus?: string;\n memory?: string;\n boost?: { cpus?: string; memory?: string };\n image?: { workspaceMount?: \"private\" | \"full\" };\n gondolin?: { remote?: GondolinRemoteSettings };\n defaultSharedVault?: string;\n}\n\nexport interface AgentConfig {\n provider: string;\n model: string;\n thinkingLevel: ThinkingLevel;\n sentryDsn?: string;\n sandbox?: SandboxSettings;\n slack?: {\n replyMode?: \"top-level\" | \"thread\";\n };\n}\n\n/**\n * @deprecated Auto-reply is kept for compatibility while its future is undecided.\n */\nexport interface AutoReplyConfig {\n enabled: boolean;\n rules: string[];\n}\n\nexport interface JudgeModelConfig {\n provider: string;\n model: string;\n}\n\n// ── context ───────────────────────────────────────────────────────────────────\n\n/**\n * Platform conversation history entry from log.jsonl.\n */\nexport interface ConversationLogMessage {\n date?: string;\n ts?: string;\n threadTs?: string;\n user?: string;\n userName?: string;\n text?: string;\n isMessagingBot?: boolean;\n}\n\n// ── events ────────────────────────────────────────────────────────────────────\n// The wire format (payload union, schema, parser, builder) is owned by\n// src/harness/event-format.ts. These are the *resolved* runtime shapes: the\n// EventsWatcher fills in the platform default and infers the conversation\n// kind before an event reaches a bot.\n\ninterface ResolvedEventFields {\n platform: string;\n conversationKind: ConversationKind;\n}\n\nexport type ImmediateEvent = ImmediateEventPayload & ResolvedEventFields;\n\nexport type OneShotEvent = OneShotEventPayload & ResolvedEventFields;\n\nexport type PeriodicEvent = PeriodicEventPayload & ResolvedEventFields;\n\nexport type MikanEvent = ImmediateEvent | OneShotEvent | PeriodicEvent;\n\nexport interface PeriodicEventInfo {\n filename: string;\n platform: string;\n conversationId: string;\n conversationKind: ConversationKind;\n text: string;\n schedule: string;\n timezone: string;\n nextRun: string | null;\n}\n\n// ── execution-resolver ────────────────────────────────────────────────────────\n\nexport interface ActorContext {\n platform: string;\n userId: string;\n conversationId: string;\n /** From MessagingInfo.trustModel; vault policy uses this, not platform name. */\n trustModel?: PlatformTrustModel;\n}\n\nexport type ImageWorkspaceMountMode = \"private\" | \"full\";\n\n// ── log ───────────────────────────────────────────────────────────────────────\n\nexport interface LogContext {\n conversationId: string;\n userName?: string;\n conversationName?: string;\n sessionId?: string;\n}\n\n// ── portal shell (src/web/portal-shell.ts) ────────────────────────────────────\n\ntype PortalView = \"admin\" | \"session\" | \"vault\";\n\nexport interface PortalShellOptions {\n activeView: PortalView;\n pageTitle: string;\n identity?: {\n primary: string;\n secondary?: string;\n };\n conversationSwitcher?: {\n currentId: string;\n options?: Array<{ id: string; label: string; running?: boolean }>;\n };\n navLinks?: Partial<Record<PortalView, string>>;\n body: string;\n extraStyles?: string;\n inlineScript?: string;\n extraHead?: string;\n bodyAttributes?: Record<string, string>;\n}\n\n// ── provisioner ───────────────────────────────────────────────────────────────\n\nexport interface ContainerMount {\n source: string;\n target: string;\n}\n\nexport interface ResourceLimits {\n cpus?: string;\n memory?: string;\n}\n\nexport interface SandboxLimitStatus {\n limits?: ResourceLimits;\n boosted: boolean;\n}\n\nexport interface SandboxResourceController {\n boost(key: string): Promise<SandboxLimitStatus>;\n setLimits(key: string, limits: ResourceLimits): Promise<SandboxLimitStatus>;\n getLimitStatus(key: string): SandboxLimitStatus;\n getDefaultLimits(): ResourceLimits | undefined;\n getBoostLimits(): ResourceLimits | undefined;\n}\n\nexport interface ProvisionOptions {\n containerName?: string;\n mounts?: ContainerMount[];\n conversationId?: string;\n}\n\nexport interface DockerContainerManagerOptions {\n limits?: ResourceLimits;\n boostLimits?: ResourceLimits;\n execFileImpl?: ExecFileAsync;\n}\n\n// ── store ─────────────────────────────────────────────────────────────────────\n\nexport interface Attachment {\n original: string;\n localPath: string;\n}\n\nexport interface LoggedMessage {\n date: string;\n ts: string;\n user: string;\n userName?: string;\n displayName?: string;\n text: string;\n attachments: Attachment[];\n isMessagingBot: boolean;\n threadTs?: string;\n}\n\nexport interface ChannelStoreConfig {\n workingDir: string;\n botToken: string;\n}\n\n// ── trigger ───────────────────────────────────────────────────────────────────\n\nexport type TriggerIntent = \"mention\" | \"direct\" | \"thread-continuation\" | \"auto-reply-candidate\";\n\nexport type TriggerResult = { trigger: true; reason: string } | { trigger: false; reason: string };\n\n/**\n * @deprecated Auto-reply is kept for compatibility while its future is undecided.\n */\nexport type AutoReplyJudge = (input: {\n event: ConversationEvent;\n rules: string[];\n conversationDir: string;\n}) => Promise<boolean>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAOjC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport { execFile } from \"child_process\";\nimport { promisify } from \"util\";\nimport type {\n ImmediateEventPayload,\n OneShotEventPayload,\n PeriodicEventPayload,\n} from \"./harness/event-format.js\";\n\nconst execFileAsync = promisify(execFile);\ntype ExecFileAsync = typeof execFileAsync;\n\n// ── adapter ───────────────────────────────────────────────────────────────────\n\nexport type ConversationKind = \"direct\" | \"shared\";\n\nexport type PlatformName = \"slack\" | \"discord\" | \"telegram\" | \"github\";\n\n/**\n * Who can drive conversations on a platform — gates ambient credential policy.\n *\n * - `membership`: only invited workspace/server members (Slack/Discord/Telegram).\n * Safe to copy `sandbox.defaultSharedVault` into new conversation vaults.\n * - `open-trigger`: broader trigger surface (e.g. GitHub repo writers on public\n * issues/PRs). Ambient shared vault must not apply; use host-side platform\n * identity or an explicitly provisioned vault.\n */\nexport type PlatformTrustModel = \"membership\" | \"open-trigger\";\n\nexport interface ConversationMessage {\n id: string;\n sessionKey: string;\n conversationKind: ConversationKind;\n userId: string;\n userName?: string;\n text: string;\n attachments?: { name: string; localPath: string }[];\n threadTs?: string;\n}\n\nexport interface ChatToolResult {\n toolName: string;\n label?: string;\n args?: Record<string, unknown>;\n result: string;\n isError: boolean;\n durationMs: number;\n}\n\nexport interface ConversationResponder {\n respond(text: string): Promise<void>;\n appendResponseDelta?(delta: string): Promise<void>;\n finishResponse?(finalText?: string): Promise<void>;\n replaceResponse(text: string, options?: { createOverflowLink?: () => string }): Promise<void>;\n respondDiagnostic(text: string, options?: { style?: \"muted\" | \"error\" }): Promise<void>;\n respondToolResult(result: ChatToolResult): Promise<void>;\n setTyping(isTyping: boolean): Promise<void>;\n setWorking(working: boolean): Promise<void>;\n uploadFile(filePath: string, title?: string): Promise<void>;\n /**\n * React to the message that triggered this run with an emoji short name\n * (no colons). Optional: platforms/contexts without reaction support omit\n * it, and callers must handle its absence.\n */\n react?(emoji: string): Promise<void>;\n deleteResponse(): Promise<void>;\n}\n\nexport interface MessagingInfo {\n name: string;\n formattingGuide: string;\n channels: { id: string; name: string }[];\n users: { id: string; userName: string; displayName: string }[];\n /**\n * Trust boundary for ambient credentials. Defaults to `membership` when\n * omitted (closed chat platforms). Open-trigger platforms must set this\n * explicitly so vault policy does not key off platform name strings.\n */\n trustModel?: PlatformTrustModel;\n diagnostics?: {\n showUsageSummary?: boolean;\n };\n}\n\nexport interface ChatAdapter {\n start(): Promise<void>;\n stop(): Promise<void>;\n getMessagingInfo(): MessagingInfo;\n}\n\nexport type AgentEventPayload =\n | { kind: \"sessionStart\" }\n | { kind: \"responseDelta\"; delta: string }\n | { kind: \"responseFinal\"; text: string }\n | { kind: \"diagnostic\"; text: string }\n | { kind: \"toolStart\"; toolId: string; toolName: string; input?: unknown }\n | { kind: \"toolEnd\"; toolId: string }\n | { kind: \"turnEnd\"; awaitingInput?: boolean }\n | { kind: \"sessionEnd\"; reason?: string };\n\nexport interface AgentEventEnvelope {\n source: \"mikan\";\n sessionId: string;\n actorName: string;\n event: AgentEventPayload;\n}\n\n/**\n * A platform-agnostic event (message/mention) that triggers the agent.\n */\nexport interface ConversationEvent {\n type: string;\n /** Platform-specific raw conversation/channel/chat identifier */\n conversationId: string;\n /** Optional alternate conversation identity used for vault routing. */\n vaultConversationId?: string;\n /** Cross-platform conversation shape: direct message vs shared space */\n conversationKind: ConversationKind;\n /** Message timestamp or ID as string */\n ts: string;\n /** Parent message ID for threaded replies (optional) */\n thread_ts?: string;\n /** User ID */\n user: string;\n /** Message text (already stripped of bot mentions) */\n text: string;\n /** Downloaded attachments */\n attachments?: { name: string; localPath: string }[];\n /** Platform-computed session key; overrides default conversationId:thread_ts computation */\n sessionKey?: string;\n}\n\n/**\n * Minimum interface that every platform bot must implement,\n * used by the central handler in main.ts and by EventsWatcher.\n */\nexport interface MessagingBot {\n start(): Promise<void>;\n postMessage(channel: string, text: string): Promise<string>;\n updateMessage(channel: string, ts: string, text: string): Promise<void>;\n /**\n * Add an emoji reaction to a message. `emoji` is a platform-agnostic short\n * name without colons (e.g. \"eyes\", \"white_check_mark\"). Optional so\n * adapters adopt it incrementally; callers must handle its absence.\n */\n addReaction?(channel: string, messageTs: string, emoji: string): Promise<void>;\n /**\n * Upload a host-side file into a conversation. Optional so adapters adopt\n * it incrementally; callers must handle its absence. Existing adapter\n * implementations (Slack/Discord/Telegram) already match this shape.\n */\n uploadFile?(channel: string, filePath: string, title?: string): Promise<void>;\n enqueueEvent(event: ConversationEvent): boolean;\n getMessagingInfo(): MessagingInfo;\n postPrivate?(conversationId: string, userId: string, text: string): Promise<void>;\n postPrivateDiagnostic?(\n conversationId: string,\n userId: string,\n text: string,\n options?: { style?: \"muted\" | \"error\" },\n ): Promise<void>;\n}\n\n/**\n * Post a plain message to a conversation without triggering an agent run.\n * Backs extension `api.notify`; implemented in main.ts over the platform bots.\n * `platform` is required only when more than one platform is running.\n */\nexport type PlatformNotifier = (\n conversationId: string,\n text: string,\n platform?: string,\n) => Promise<void>;\n\n/**\n * Add an emoji reaction to a message without triggering an agent run. Backs\n * extension `api.react`; implemented in main.ts over the platform bots.\n */\nexport type PlatformReactor = (\n conversationId: string,\n messageTs: string,\n emoji: string,\n platform?: string,\n) => Promise<void>;\n\n/**\n * Upload a host-side file into a conversation without triggering an agent\n * run. Backs extension `api.uploadFile`; implemented in main.ts over the\n * platform bots. `platform` is required only when more than one is running.\n */\nexport type PlatformUploader = (\n conversationId: string,\n filePath: string,\n title?: string,\n platform?: string,\n) => Promise<void>;\n\n/** Normalized platform data and reply hook for one event. */\nexport interface ConversationContext {\n message: ConversationMessage;\n responder: ConversationResponder;\n platform: MessagingInfo;\n}\n\nexport interface RunningSession {\n sessionKey: string;\n startedAt: number;\n lastActivityAt?: number;\n currentTool?: string;\n}\n\nexport interface MessagingEventHandler {\n isRunning(sessionKey: string): boolean;\n getRunningSessions(): RunningSession[];\n handleEvent(\n event: ConversationEvent,\n bot: MessagingBot,\n context: ConversationContext,\n ): Promise<void>;\n handleStop(sessionKey: string, conversationId: string, bot: MessagingBot): Promise<void>;\n forceStop(sessionKey: string): void;\n handleNewCommand(sessionKey: string, conversationId: string, bot: MessagingBot): Promise<void>;\n}\n\n// ── agent ─────────────────────────────────────────────────────────────────────\n\nexport interface PiAgentWrapper {\n syncChatHistory(currentMessageId?: string): void;\n run(\n message: ConversationMessage,\n responder: ConversationResponder,\n platform: MessagingInfo,\n ): Promise<{ stopReason: string; errorMessage?: string }>;\n abort(): void;\n getCurrentStep(): { toolName?: string; label?: string } | undefined;\n /**\n * Dispatch a leading-slash message to an extension-registered command.\n * Returns true when a command consumed the message (no agent run follows).\n */\n tryExtensionCommand(\n message: ConversationMessage,\n responder: ConversationResponder,\n ): Promise<boolean>;\n /** Run extension disposers. Call once when this wrapper is discarded. */\n dispose(): Promise<void>;\n}\n\n// ── config ────────────────────────────────────────────────────────────────────\n\nexport interface GondolinRemoteWorkerSettings {\n /** Stable placement identity; defaults to the URL. */\n name?: string;\n /** Base URL of the mikan-worker daemon, e.g. https://worker.internal:8433 */\n url: string;\n /** CA bundle that signs the daemon's server certificate. */\n caFile?: string;\n /** Client certificate + key presented to the daemon (mTLS); falls back to the fleet-level pair. */\n certFile?: string;\n keyFile?: string;\n /** Worker-side path of the shared workspace filesystem. */\n workspaceRoot?: string;\n /** Admission cap for new placements (existing runtimes always count). */\n maxRuntimes?: number;\n /** Drained workers accept no new placements; existing ones finish out. */\n draining?: boolean;\n}\n\nexport interface GondolinGatewaySettings {\n /** Port the worker gateway listens on for dial-home workers. */\n port: number;\n /**\n * Gateway server certificate + key and the CA that signs worker client\n * certificates. Omit all three to let the gateway provision its own CA and\n * server certificate under the state dir (required for `--worker-token`\n * joins).\n */\n certFile?: string;\n keyFile?: string;\n clientCaFile?: string;\n /** SANs for the auto-issued server certificate (defaults to os.hostname). */\n hostnames?: string[];\n /**\n * Worker-side path of the shared workspace filesystem. Required in practice:\n * mount sources are translated to it, and without it every runtime is\n * rejected with \"escapes the workspace root\". gondolinGateway.start()\n * enforces it at boot; typed optional to match the settings schema.\n */\n workspaceRoot?: string;\n /** Per-worker host-side overrides, keyed by worker name. */\n workers?: Record<string, { maxRuntimes?: number; draining?: boolean }>;\n}\n\nexport interface GondolinRemoteSettings {\n /** Single-worker form: connection fields inline (a fleet of one). */\n url?: string;\n caFile?: string;\n certFile?: string;\n keyFile?: string;\n workspaceRoot?: string;\n maxRuntimes?: number;\n /** Fleet form: several workers; per-worker fields fall back to the inline ones. */\n workers?: GondolinRemoteWorkerSettings[];\n /** Dial-home form: listen for workers that connect to mikan instead. */\n gateway?: GondolinGatewaySettings;\n /** Guest image selector resolved on the workers. */\n imageSelector?: string;\n /** How long a new conversation waits for capacity before failing. */\n queueWaitSeconds?: number;\n}\n\nexport interface SandboxSettings {\n cpus?: string;\n memory?: string;\n boost?: { cpus?: string; memory?: string };\n image?: { workspaceMount?: \"private\" | \"full\" };\n gondolin?: { remote?: GondolinRemoteSettings };\n defaultSharedVault?: string;\n}\n\nexport interface AgentConfig {\n provider: string;\n model: string;\n thinkingLevel: ThinkingLevel;\n sentryDsn?: string;\n sandbox?: SandboxSettings;\n slack?: {\n replyMode?: \"top-level\" | \"thread\";\n };\n}\n\n/**\n * @deprecated Auto-reply is kept for compatibility while its future is undecided.\n */\nexport interface AutoReplyConfig {\n enabled: boolean;\n rules: string[];\n}\n\nexport interface JudgeModelConfig {\n provider: string;\n model: string;\n}\n\n// ── context ───────────────────────────────────────────────────────────────────\n\n/**\n * Platform conversation history entry from log.jsonl.\n */\nexport interface ConversationLogMessage {\n date?: string;\n ts?: string;\n threadTs?: string;\n user?: string;\n userName?: string;\n text?: string;\n isMessagingBot?: boolean;\n}\n\n// ── events ────────────────────────────────────────────────────────────────────\n// The wire format (payload union, schema, parser, builder) is owned by\n// src/harness/event-format.ts. These are the *resolved* runtime shapes: the\n// EventsWatcher fills in the platform default and infers the conversation\n// kind before an event reaches a bot.\n\ninterface ResolvedEventFields {\n platform: string;\n conversationKind: ConversationKind;\n}\n\nexport type ImmediateEvent = ImmediateEventPayload & ResolvedEventFields;\n\nexport type OneShotEvent = OneShotEventPayload & ResolvedEventFields;\n\nexport type PeriodicEvent = PeriodicEventPayload & ResolvedEventFields;\n\nexport type MikanEvent = ImmediateEvent | OneShotEvent | PeriodicEvent;\n\nexport interface PeriodicEventInfo {\n filename: string;\n platform: string;\n conversationId: string;\n conversationKind: ConversationKind;\n text: string;\n schedule: string;\n timezone: string;\n nextRun: string | null;\n}\n\n// ── execution-resolver ────────────────────────────────────────────────────────\n\nexport interface ActorContext {\n platform: string;\n userId: string;\n conversationId: string;\n /** From MessagingInfo.trustModel; vault policy uses this, not platform name. */\n trustModel?: PlatformTrustModel;\n}\n\nexport type ImageWorkspaceMountMode = \"private\" | \"full\";\n\n// ── log ───────────────────────────────────────────────────────────────────────\n\nexport interface LogContext {\n conversationId: string;\n userName?: string;\n conversationName?: string;\n sessionId?: string;\n}\n\n// ── portal shell (src/web/portal-shell.ts) ────────────────────────────────────\n\ntype PortalView = \"admin\" | \"session\" | \"vault\";\n\nexport interface PortalShellOptions {\n activeView: PortalView;\n pageTitle: string;\n identity?: {\n primary: string;\n secondary?: string;\n };\n conversationSwitcher?: {\n currentId: string;\n options?: Array<{ id: string; label: string; running?: boolean }>;\n };\n navLinks?: Partial<Record<PortalView, string>>;\n body: string;\n extraStyles?: string;\n inlineScript?: string;\n extraHead?: string;\n bodyAttributes?: Record<string, string>;\n}\n\n// ── provisioner ───────────────────────────────────────────────────────────────\n\nexport interface ContainerMount {\n source: string;\n target: string;\n}\n\nexport interface ResourceLimits {\n cpus?: string;\n memory?: string;\n}\n\nexport interface SandboxLimitStatus {\n limits?: ResourceLimits;\n boosted: boolean;\n}\n\nexport interface SandboxResourceController {\n boost(key: string): Promise<SandboxLimitStatus>;\n setLimits(key: string, limits: ResourceLimits): Promise<SandboxLimitStatus>;\n getLimitStatus(key: string): SandboxLimitStatus;\n getDefaultLimits(): ResourceLimits | undefined;\n getBoostLimits(): ResourceLimits | undefined;\n}\n\nexport interface ProvisionOptions {\n containerName?: string;\n mounts?: ContainerMount[];\n conversationId?: string;\n}\n\nexport interface DockerContainerManagerOptions {\n limits?: ResourceLimits;\n boostLimits?: ResourceLimits;\n execFileImpl?: ExecFileAsync;\n}\n\nexport interface ExecutionPlan {\n credentialKey: string;\n resourceKey: string;\n sandboxConfig: import(\"./sandbox/types.js\").SandboxConfig;\n env?: Record<string, string>;\n mounts: ContainerMount[];\n}\n\n// ── store ─────────────────────────────────────────────────────────────────────\n\nexport interface Attachment {\n original: string;\n localPath: string;\n}\n\nexport interface LoggedMessage {\n date: string;\n ts: string;\n user: string;\n userName?: string;\n displayName?: string;\n text: string;\n attachments: Attachment[];\n isMessagingBot: boolean;\n threadTs?: string;\n}\n\nexport interface ChannelStoreConfig {\n workingDir: string;\n botToken: string;\n}\n\n// ── trigger ───────────────────────────────────────────────────────────────────\n\nexport type TriggerIntent = \"mention\" | \"direct\" | \"thread-continuation\" | \"auto-reply-candidate\";\n\nexport type TriggerResult = { trigger: true; reason: string } | { trigger: false; reason: string };\n\n/**\n * @deprecated Auto-reply is kept for compatibility while its future is undecided.\n */\nexport type AutoReplyJudge = (input: {\n event: ConversationEvent;\n rules: string[];\n conversationDir: string;\n}) => Promise<boolean>;\n"]}
@@ -1,19 +1,9 @@
1
- import type { SandboxConfig } from "../sandbox/types.js";
2
- import type { ResolvedVault, ResolvedVaultMount } from "./types.js";
3
- /**
4
- * What an actor's vault contributes to one sandbox execution. This is the
5
- * vault side of credential injection — the execution resolver composes it
6
- * with its own workspace layout and per-actor config shaping, without
7
- * knowing what a vault mount means or when vault env may flow.
8
- */
9
- export interface VaultInjection {
10
- /** Per-exec env; absent for host sandboxes (no isolation) and empty vaults. */
11
- env?: Record<string, string>;
12
- /** Credential mounts whose sources exist; missing sources are reported and skipped. */
13
- mounts: ResolvedVaultMount[];
14
- }
1
+ import type { SandboxConfig, SandboxCredentialCapabilities } from "../sandbox/types.js";
2
+ import type { ResolvedVault, VaultInjection } from "./types.js";
3
+ export type { VaultInjection } from "./types.js";
15
4
  export declare function resolveVaultInjection(options: {
16
5
  vault: ResolvedVault | undefined;
6
+ capabilities: SandboxCredentialCapabilities;
17
7
  sandboxType: SandboxConfig["type"];
18
8
  conversationId: string;
19
9
  }): VaultInjection;
@@ -1 +1 @@
1
- {"version":3,"file":"injection.d.ts","sourceRoot":"","sources":["../../src/vault/injection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,uFAAuF;IACvF,MAAM,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,cAAc,CA0BjB"}
1
+ {"version":3,"file":"injection.d.ts","sourceRoot":"","sources":["../../src/vault/injection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,KAAK,EAAE,aAAa,EAAsB,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpF,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE;IAC7C,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,YAAY,EAAE,6BAA6B,CAAC;IAC5C,WAAW,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,cAAc,CA6BjB"}