@esso0428/pi-subagents 0.17.6 → 0.17.7

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 (260) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/CONTRIBUTING.md +4 -0
  3. package/dist/abortable.d.ts +13 -0
  4. package/dist/abortable.d.ts.map +1 -0
  5. package/dist/abortable.js +43 -0
  6. package/dist/abortable.js.map +1 -0
  7. package/dist/agent-color.d.ts +36 -0
  8. package/dist/agent-color.d.ts.map +1 -0
  9. package/dist/agent-color.js +124 -0
  10. package/dist/agent-color.js.map +1 -0
  11. package/dist/agent-file-toggle.d.ts +126 -0
  12. package/dist/agent-file-toggle.d.ts.map +1 -0
  13. package/dist/agent-file-toggle.js +259 -0
  14. package/dist/agent-file-toggle.js.map +1 -0
  15. package/dist/agent-history.d.ts +4 -0
  16. package/dist/agent-history.d.ts.map +1 -1
  17. package/dist/agent-history.js +47 -1
  18. package/dist/agent-history.js.map +1 -1
  19. package/dist/agent-manager.d.ts +370 -56
  20. package/dist/agent-manager.d.ts.map +1 -1
  21. package/dist/agent-manager.js +1123 -409
  22. package/dist/agent-manager.js.map +1 -1
  23. package/dist/agent-runner.d.ts +100 -10
  24. package/dist/agent-runner.d.ts.map +1 -1
  25. package/dist/agent-runner.js +166 -21
  26. package/dist/agent-runner.js.map +1 -1
  27. package/dist/agent-types.d.ts +57 -5
  28. package/dist/agent-types.d.ts.map +1 -1
  29. package/dist/agent-types.js +164 -32
  30. package/dist/agent-types.js.map +1 -1
  31. package/dist/child-context.d.ts +3 -0
  32. package/dist/child-context.d.ts.map +1 -0
  33. package/dist/child-context.js +13 -0
  34. package/dist/child-context.js.map +1 -0
  35. package/dist/cross-extension-rpc.d.ts +23 -3
  36. package/dist/cross-extension-rpc.d.ts.map +1 -1
  37. package/dist/cross-extension-rpc.js +79 -17
  38. package/dist/cross-extension-rpc.js.map +1 -1
  39. package/dist/custom-agents.d.ts +38 -1
  40. package/dist/custom-agents.d.ts.map +1 -1
  41. package/dist/custom-agents.js +164 -12
  42. package/dist/custom-agents.js.map +1 -1
  43. package/dist/index.d.ts +34 -0
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +1908 -495
  46. package/dist/index.js.map +1 -1
  47. package/dist/invocation-config.d.ts +87 -2
  48. package/dist/invocation-config.d.ts.map +1 -1
  49. package/dist/invocation-config.js +71 -3
  50. package/dist/invocation-config.js.map +1 -1
  51. package/dist/mention-clone.d.ts +88 -0
  52. package/dist/mention-clone.d.ts.map +1 -0
  53. package/dist/mention-clone.js +154 -0
  54. package/dist/mention-clone.js.map +1 -0
  55. package/dist/mention.d.ts +82 -0
  56. package/dist/mention.d.ts.map +1 -0
  57. package/dist/mention.js +132 -0
  58. package/dist/mention.js.map +1 -0
  59. package/dist/model-resolver.d.ts +17 -0
  60. package/dist/model-resolver.d.ts.map +1 -1
  61. package/dist/model-resolver.js +15 -0
  62. package/dist/model-resolver.js.map +1 -1
  63. package/dist/model-scope.d.ts +50 -0
  64. package/dist/model-scope.d.ts.map +1 -0
  65. package/dist/model-scope.js +49 -0
  66. package/dist/model-scope.js.map +1 -0
  67. package/dist/nested-tools.d.ts +57 -0
  68. package/dist/nested-tools.d.ts.map +1 -0
  69. package/dist/nested-tools.js +301 -0
  70. package/dist/nested-tools.js.map +1 -0
  71. package/dist/output-file.d.ts +22 -3
  72. package/dist/output-file.d.ts.map +1 -1
  73. package/dist/output-file.js +58 -7
  74. package/dist/output-file.js.map +1 -1
  75. package/dist/prompts.d.ts +23 -0
  76. package/dist/prompts.d.ts.map +1 -1
  77. package/dist/prompts.js +20 -2
  78. package/dist/prompts.js.map +1 -1
  79. package/dist/schedule.d.ts.map +1 -1
  80. package/dist/schedule.js +36 -15
  81. package/dist/schedule.js.map +1 -1
  82. package/dist/settings.d.ts +228 -2
  83. package/dist/settings.d.ts.map +1 -1
  84. package/dist/settings.js +94 -0
  85. package/dist/settings.js.map +1 -1
  86. package/dist/status-note.d.ts +49 -1
  87. package/dist/status-note.d.ts.map +1 -1
  88. package/dist/status-note.js +62 -1
  89. package/dist/status-note.js.map +1 -1
  90. package/dist/structured-output.d.ts +62 -0
  91. package/dist/structured-output.d.ts.map +1 -0
  92. package/dist/structured-output.js +113 -0
  93. package/dist/structured-output.js.map +1 -0
  94. package/dist/types.d.ts +176 -10
  95. package/dist/types.d.ts.map +1 -1
  96. package/dist/ui/agent-mention.d.ts +83 -0
  97. package/dist/ui/agent-mention.d.ts.map +1 -0
  98. package/dist/ui/agent-mention.js +188 -0
  99. package/dist/ui/agent-mention.js.map +1 -0
  100. package/dist/ui/agent-widget.d.ts +96 -75
  101. package/dist/ui/agent-widget.d.ts.map +1 -1
  102. package/dist/ui/agent-widget.js +397 -420
  103. package/dist/ui/agent-widget.js.map +1 -1
  104. package/dist/ui/conversation-blocks.d.ts.map +1 -1
  105. package/dist/ui/conversation-blocks.js +6 -0
  106. package/dist/ui/conversation-blocks.js.map +1 -1
  107. package/dist/ui/conversation-timeline.d.ts +10 -2
  108. package/dist/ui/conversation-timeline.d.ts.map +1 -1
  109. package/dist/ui/conversation-timeline.js +130 -23
  110. package/dist/ui/conversation-timeline.js.map +1 -1
  111. package/dist/ui/conversation-viewer.d.ts +15 -5
  112. package/dist/ui/conversation-viewer.d.ts.map +1 -1
  113. package/dist/ui/conversation-viewer.js +202 -50
  114. package/dist/ui/conversation-viewer.js.map +1 -1
  115. package/dist/ui/fleet-list.d.ts +198 -0
  116. package/dist/ui/fleet-list.d.ts.map +1 -0
  117. package/dist/ui/fleet-list.js +487 -0
  118. package/dist/ui/fleet-list.js.map +1 -0
  119. package/dist/ui/schedule-menu.d.ts.map +1 -1
  120. package/dist/ui/schedule-menu.js +6 -7
  121. package/dist/ui/schedule-menu.js.map +1 -1
  122. package/dist/ui/select-item.d.ts +28 -0
  123. package/dist/ui/select-item.d.ts.map +1 -0
  124. package/dist/ui/select-item.js +35 -0
  125. package/dist/ui/select-item.js.map +1 -0
  126. package/dist/ui/workflow-card.d.ts +176 -0
  127. package/dist/ui/workflow-card.d.ts.map +1 -0
  128. package/dist/ui/workflow-card.js +333 -0
  129. package/dist/ui/workflow-card.js.map +1 -0
  130. package/dist/ui/workflow-dialog.d.ts +306 -0
  131. package/dist/ui/workflow-dialog.d.ts.map +1 -0
  132. package/dist/ui/workflow-dialog.js +844 -0
  133. package/dist/ui/workflow-dialog.js.map +1 -0
  134. package/dist/ui/workflow-menu.d.ts +61 -0
  135. package/dist/ui/workflow-menu.d.ts.map +1 -0
  136. package/dist/ui/workflow-menu.js +148 -0
  137. package/dist/ui/workflow-menu.js.map +1 -0
  138. package/dist/usage.d.ts +86 -1
  139. package/dist/usage.d.ts.map +1 -1
  140. package/dist/usage.js +72 -1
  141. package/dist/usage.js.map +1 -1
  142. package/dist/workflow/collisions.d.ts +96 -0
  143. package/dist/workflow/collisions.d.ts.map +1 -0
  144. package/dist/workflow/collisions.js +89 -0
  145. package/dist/workflow/collisions.js.map +1 -0
  146. package/dist/workflow/entry.d.ts +33 -0
  147. package/dist/workflow/entry.d.ts.map +1 -0
  148. package/dist/workflow/entry.js +30 -0
  149. package/dist/workflow/entry.js.map +1 -0
  150. package/dist/workflow/host.d.ts +63 -0
  151. package/dist/workflow/host.d.ts.map +1 -0
  152. package/dist/workflow/host.js +363 -0
  153. package/dist/workflow/host.js.map +1 -0
  154. package/dist/workflow/journal.d.ts +98 -0
  155. package/dist/workflow/journal.d.ts.map +1 -0
  156. package/dist/workflow/journal.js +121 -0
  157. package/dist/workflow/journal.js.map +1 -0
  158. package/dist/workflow/json-schema.d.ts +52 -0
  159. package/dist/workflow/json-schema.d.ts.map +1 -0
  160. package/dist/workflow/json-schema.js +112 -0
  161. package/dist/workflow/json-schema.js.map +1 -0
  162. package/dist/workflow/meta.d.ts +68 -0
  163. package/dist/workflow/meta.d.ts.map +1 -0
  164. package/dist/workflow/meta.js +318 -0
  165. package/dist/workflow/meta.js.map +1 -0
  166. package/dist/workflow/progress.d.ts +225 -0
  167. package/dist/workflow/progress.d.ts.map +1 -0
  168. package/dist/workflow/progress.js +362 -0
  169. package/dist/workflow/progress.js.map +1 -0
  170. package/dist/workflow/runtime.d.ts +335 -0
  171. package/dist/workflow/runtime.d.ts.map +1 -0
  172. package/dist/workflow/runtime.js +831 -0
  173. package/dist/workflow/runtime.js.map +1 -0
  174. package/dist/workflow/saved.d.ts +91 -0
  175. package/dist/workflow/saved.d.ts.map +1 -0
  176. package/dist/workflow/saved.js +204 -0
  177. package/dist/workflow/saved.js.map +1 -0
  178. package/dist/workflow/task.d.ts +137 -0
  179. package/dist/workflow/task.d.ts.map +1 -0
  180. package/dist/workflow/task.js +208 -0
  181. package/dist/workflow/task.js.map +1 -0
  182. package/dist/workflow/tool-description.d.ts +39 -0
  183. package/dist/workflow/tool-description.d.ts.map +1 -0
  184. package/dist/workflow/tool-description.js +200 -0
  185. package/dist/workflow/tool-description.js.map +1 -0
  186. package/dist/workflow/worker-source.d.ts +48 -0
  187. package/dist/workflow/worker-source.d.ts.map +1 -0
  188. package/dist/workflow/worker-source.js +779 -0
  189. package/dist/workflow/worker-source.js.map +1 -0
  190. package/dist/worktree.d.ts +10 -3
  191. package/dist/worktree.d.ts.map +1 -1
  192. package/dist/worktree.js +58 -54
  193. package/dist/worktree.js.map +1 -1
  194. package/dist/xml.d.ts +11 -0
  195. package/dist/xml.d.ts.map +1 -0
  196. package/dist/xml.js +13 -0
  197. package/dist/xml.js.map +1 -0
  198. package/docs/rpc.md +183 -0
  199. package/docs/superpowers/plans/2026-09-30-upstream-event-workflow-partial-history.md +195 -0
  200. package/docs/superpowers/specs/2026-09-30-upstream-event-workflow-partial-history-design.md +49 -0
  201. package/docs/workflows.md +437 -0
  202. package/examples/agent-tool-description.md +7 -7
  203. package/examples/workflows/compose.js +51 -0
  204. package/examples/workflows/fan-out-audit.js +47 -0
  205. package/examples/workflows/gated-fix.js +60 -0
  206. package/examples/workflows/lib/count-child.js +27 -0
  207. package/examples/workflows/review-panel.js +63 -0
  208. package/examples/workflows/structured-findings.js +78 -0
  209. package/package.json +1 -1
  210. package/src/abortable.ts +43 -0
  211. package/src/agent-color.ts +161 -0
  212. package/src/agent-file-toggle.ts +269 -0
  213. package/src/agent-history.ts +54 -2
  214. package/src/agent-manager.ts +1263 -402
  215. package/src/agent-runner.ts +251 -27
  216. package/src/agent-types.ts +188 -32
  217. package/src/child-context.ts +15 -0
  218. package/src/cross-extension-rpc.ts +96 -20
  219. package/src/custom-agents.ts +170 -13
  220. package/src/index.ts +2024 -537
  221. package/src/invocation-config.ts +118 -3
  222. package/src/mention-clone.ts +196 -0
  223. package/src/mention.ts +141 -0
  224. package/src/model-resolver.ts +18 -0
  225. package/src/model-scope.ts +70 -0
  226. package/src/nested-tools.ts +424 -0
  227. package/src/output-file.ts +61 -6
  228. package/src/prompts.ts +45 -2
  229. package/src/schedule.ts +35 -14
  230. package/src/settings.ts +312 -2
  231. package/src/status-note.ts +66 -1
  232. package/src/structured-output.ts +130 -0
  233. package/src/types.ts +177 -10
  234. package/src/ui/agent-mention.ts +216 -0
  235. package/src/ui/agent-widget.ts +389 -441
  236. package/src/ui/conversation-blocks.ts +6 -0
  237. package/src/ui/conversation-timeline.ts +139 -25
  238. package/src/ui/conversation-viewer.ts +212 -48
  239. package/src/ui/fleet-list.ts +558 -0
  240. package/src/ui/schedule-menu.ts +9 -8
  241. package/src/ui/select-item.ts +45 -0
  242. package/src/ui/workflow-card.ts +470 -0
  243. package/src/ui/workflow-dialog.ts +1115 -0
  244. package/src/ui/workflow-menu.ts +193 -0
  245. package/src/usage.ts +109 -2
  246. package/src/workflow/collisions.ts +123 -0
  247. package/src/workflow/entry.ts +47 -0
  248. package/src/workflow/host.ts +403 -0
  249. package/src/workflow/journal.ts +164 -0
  250. package/src/workflow/json-schema.ts +128 -0
  251. package/src/workflow/meta.ts +325 -0
  252. package/src/workflow/progress.ts +550 -0
  253. package/src/workflow/runtime.ts +1219 -0
  254. package/src/workflow/saved.ts +217 -0
  255. package/src/workflow/task.ts +302 -0
  256. package/src/workflow/tool-description.ts +200 -0
  257. package/src/workflow/worker-source.ts +781 -0
  258. package/src/worktree.ts +69 -55
  259. package/src/xml.ts +13 -0
  260. package/vitest.config.ts +0 -18
@@ -0,0 +1,50 @@
1
+ /**
2
+ * model-scope.ts — `scopeModels` policy, shared by the top-level Agent tool and
3
+ * the nested delegation tools so a nested spawn can't escape the allowlist the
4
+ * top-level path enforces.
5
+ *
6
+ * State lives here (rather than in an index.ts closure) for the same reason
7
+ * `disableDefaults` lives in agent-types.ts: both entry points need it.
8
+ */
9
+ import { type ModelRegistryRef } from "./enabled-models.js";
10
+ export declare function isScopeModelsEnabled(): boolean;
11
+ export declare function setScopeModelsEnabled(enabled: boolean): void;
12
+ export type ModelScopeVerdict =
13
+ /** In scope, or nothing to validate against (feature off / no allowlist). */
14
+ {
15
+ kind: "ok";
16
+ }
17
+ /** Caller-supplied out-of-scope choice — refuse the spawn with this message. */
18
+ | {
19
+ kind: "error";
20
+ message: string;
21
+ }
22
+ /** Frontmatter-pinned or parent-inherited — proceed, but tell the user. */
23
+ | {
24
+ kind: "warn";
25
+ message: string;
26
+ };
27
+ /**
28
+ * Check the effective resolved model against the user's enabledModels list.
29
+ *
30
+ * scopeModels guards against *runtime* LLM choices, not user-level config:
31
+ * - Caller-supplied out-of-scope → hard error (the orchestrator made an explicit
32
+ * out-of-scope choice; surface it so it picks differently).
33
+ * - Frontmatter-pinned or parent-inherited out-of-scope → warn but proceed (the
34
+ * user authored/installed this agent or chose the parent's model; trust it).
35
+ */
36
+ export declare function checkModelScope(args: {
37
+ model: {
38
+ provider: string;
39
+ id: string;
40
+ } | undefined;
41
+ cwd: string;
42
+ modelRegistry: ModelRegistryRef;
43
+ /** True when the model came from the tool call rather than frontmatter. */
44
+ callerSupplied: boolean;
45
+ /** Display name used in the warning toast. */
46
+ agentLabel: string;
47
+ /** The raw `model:` input, when there was one. */
48
+ modelInput?: string;
49
+ }): ModelScopeVerdict;
50
+ //# sourceMappingURL=model-scope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-scope.d.ts","sourceRoot":"","sources":["../src/model-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAkB,KAAK,gBAAgB,EAA2C,MAAM,qBAAqB,CAAC;AAWrH,wBAAgB,oBAAoB,IAAI,OAAO,CAA+B;AAC9E,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAkC;AAE/F,MAAM,MAAM,iBAAiB;AAC3B,6EAA6E;AAC3E;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE;AAChB,gFAAgF;GAC9E;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE;AACpC,2EAA2E;GACzE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC;IACpD,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,gBAAgB,CAAC;IAChC,2EAA2E;IAC3E,cAAc,EAAE,OAAO,CAAC;IACxB,8CAA8C;IAC9C,UAAU,EAAE,MAAM,CAAC;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,iBAAiB,CAmBpB"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * model-scope.ts — `scopeModels` policy, shared by the top-level Agent tool and
3
+ * the nested delegation tools so a nested spawn can't escape the allowlist the
4
+ * top-level path enforces.
5
+ *
6
+ * State lives here (rather than in an index.ts closure) for the same reason
7
+ * `disableDefaults` lives in agent-types.ts: both entry points need it.
8
+ */
9
+ import { isModelInScope, readEnabledModels, resolveEnabledModels } from "./enabled-models.js";
10
+ /**
11
+ * When enabled, subagent model choices are validated against `enabledModels`
12
+ * from pi's settings — both global `<agentDir>/settings.json` and project-local
13
+ * `<cwd>/.pi/settings.json` (project overrides global). Off by default; opt-in
14
+ * via `/agents → Settings`. See the SubagentsSettings.scopeModels docstring for
15
+ * the hard-error vs warn-and-proceed policy and its rationale.
16
+ */
17
+ let scopeModelsEnabled = false;
18
+ export function isScopeModelsEnabled() { return scopeModelsEnabled; }
19
+ export function setScopeModelsEnabled(enabled) { scopeModelsEnabled = enabled; }
20
+ /**
21
+ * Check the effective resolved model against the user's enabledModels list.
22
+ *
23
+ * scopeModels guards against *runtime* LLM choices, not user-level config:
24
+ * - Caller-supplied out-of-scope → hard error (the orchestrator made an explicit
25
+ * out-of-scope choice; surface it so it picks differently).
26
+ * - Frontmatter-pinned or parent-inherited out-of-scope → warn but proceed (the
27
+ * user authored/installed this agent or chose the parent's model; trust it).
28
+ */
29
+ export function checkModelScope(args) {
30
+ const { model, cwd, modelRegistry, callerSupplied, agentLabel, modelInput } = args;
31
+ if (!scopeModelsEnabled || !model)
32
+ return { kind: "ok" };
33
+ const allowed = resolveEnabledModels(readEnabledModels(cwd), modelRegistry, cwd);
34
+ if (!allowed || isModelInScope(model, allowed))
35
+ return { kind: "ok" };
36
+ if (callerSupplied) {
37
+ const list = [...allowed].sort().map(m => ` ${m}`).join("\n");
38
+ return {
39
+ kind: "error",
40
+ message: `Model not in scope: "${modelInput}".\n\nAllowed models (from enabledModels):\n${list}`,
41
+ };
42
+ }
43
+ const modelLabel = modelInput ?? `${model.provider}/${model.id}`;
44
+ return {
45
+ kind: "warn",
46
+ message: `Agent "${agentLabel}" using out-of-scope model "${modelLabel}"`,
47
+ };
48
+ }
49
+ //# sourceMappingURL=model-scope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-scope.js","sourceRoot":"","sources":["../src/model-scope.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAyB,iBAAiB,EA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CAAC"}
@@ -0,0 +1,57 @@
1
+ import type { Model } from "@earendil-works/pi-ai";
2
+ import { type AgentSession, type ExtensionAPI, type ExtensionContext, type ToolDefinition } from "@earendil-works/pi-coding-agent";
3
+ import type { AgentInvocation, AgentRecord, IsolationMode, ThinkingLevel } from "./types.js";
4
+ export declare function getMaxSubagentDepth(): number;
5
+ export declare function setMaxSubagentDepth(n: number): void;
6
+ interface NestedSpawnOptions {
7
+ description: string;
8
+ model?: Model<any>;
9
+ maxTurns?: number;
10
+ isolated?: boolean;
11
+ inheritContext?: boolean;
12
+ thinkingLevel?: ThinkingLevel;
13
+ isBackground?: boolean;
14
+ isolation?: IsolationMode;
15
+ outputTranscript?: boolean;
16
+ invocation?: AgentInvocation;
17
+ signal?: AbortSignal;
18
+ onAssistantUsage?: (usage: {
19
+ input: number;
20
+ output: number;
21
+ cacheWrite: number;
22
+ }) => void;
23
+ onSessionCreated?: (session: AgentSession) => void;
24
+ depth: number;
25
+ parentAgentId: string;
26
+ maxSubagentDepth: number;
27
+ configCwd?: string;
28
+ rootSessionId?: string;
29
+ }
30
+ export interface NestedAgentManager {
31
+ spawn(pi: ExtensionAPI, ctx: ExtensionContext, type: string, prompt: string, options: NestedSpawnOptions): string;
32
+ /** Resolves once the spawned agent is running; rejects on a startup failure. */
33
+ awaitStartup(id: string): Promise<void>;
34
+ spawnAndWait(pi: ExtensionAPI, ctx: ExtensionContext, type: string, prompt: string, options: Omit<NestedSpawnOptions, "isBackground">,
35
+ /** Fires synchronously after spawn, before the session exists — where the transcript is attached. */
36
+ onSpawned?: (id: string) => void): Promise<{
37
+ id: string;
38
+ record: AgentRecord;
39
+ }>;
40
+ getRecord(id: string): AgentRecord | undefined;
41
+ resume(id: string, prompt: string, signal?: AbortSignal): Promise<AgentRecord | undefined>;
42
+ }
43
+ export interface NestedToolContext {
44
+ manager: NestedAgentManager;
45
+ pi: ExtensionAPI;
46
+ parentAgentId: string;
47
+ depth: number;
48
+ maxSubagentDepth: number;
49
+ /** "all" = any enabled agent; string[] = only those types. Never empty. */
50
+ allowedSubagents: "all" | string[];
51
+ /** Root used for agent/config discovery; may differ from the agent's working directory. */
52
+ configCwd: string;
53
+ }
54
+ /** Build child-safe orchestration tools scoped to one parent agent instance. */
55
+ export declare function createNestedSubagentTools(context: NestedToolContext): ToolDefinition[];
56
+ export {};
57
+ //# sourceMappingURL=nested-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nested-tools.d.ts","sourceRoot":"","sources":["../src/nested-tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EACL,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,iCAAiC,CAAC;AAqBzC,OAAO,KAAK,EAEV,eAAe,EACf,WAAW,EACX,aAAa,EACb,aAAa,EACd,MAAM,YAAY,CAAC;AAYpB,wBAAgB,mBAAmB,IAAI,MAAM,CAA6B;AAC1E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAmD;AAIvG,UAAU,kBAAkB;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM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E,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,2EAA2E;IAC3E,gBAAgB,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC;IACnC,2FAA2F;IAC3F,SAAS,EAAE,MAAM,CAAC;CACnB;AAwCD,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,cAAc,EAAE,CAqRtF"}
@@ -0,0 +1,301 @@
1
+ import { defineTool, } from "@earendil-works/pi-coding-agent";
2
+ import { Type } from "@sinclair/typebox";
3
+ import { abortable } from "./abortable.js";
4
+ import { buildAgentRegistry, getAgentConfigIn, getAvailableTypesIn, resolveEnabledTypeIn, resolveTypeIn, } from "./agent-types.js";
5
+ import { loadCustomAgents } from "./custom-agents.js";
6
+ import { isolationParam, resolveAgentInvocationConfig } from "./invocation-config.js";
7
+ import { resolveModel } from "./model-resolver.js";
8
+ import { checkModelScope } from "./model-scope.js";
9
+ import { createOutputFilePath, getOutputTranscriptDefault, streamToOutputFile, writeInitialEntry, } from "./output-file.js";
10
+ import { getForegroundOutcomeNote, getStatusNote, partialOutputSuffix } from "./status-note.js";
11
+ import { addUsage } from "./usage.js";
12
+ import { isWorktreeIsolationEnabled } from "./worktree.js";
13
+ /**
14
+ * Hard ceiling on nesting for every branch: main session = 0, its subagents = 1,
15
+ * their children = 2. `0`/`1` disables nesting entirely. Set from
16
+ * `subagents.json` (`maxSubagentDepth`). Read when a subagent session is built,
17
+ * so a change applies to sessions started after it.
18
+ */
19
+ let maxSubagentDepth = 2;
20
+ export function getMaxSubagentDepth() { return maxSubagentDepth; }
21
+ export function setMaxSubagentDepth(n) { maxSubagentDepth = Math.max(0, Math.floor(n)); }
22
+ const NESTED_TOOL_NAMES = ["Agent", "get_subagent_result", "steer_subagent"];
23
+ function textResult(text, isError = false) {
24
+ return { content: [{ type: "text", text }], isError, details: {} };
25
+ }
26
+ function ownsRecord(record, parentAgentId) {
27
+ return record?.parentAgentId === parentAgentId;
28
+ }
29
+ function formatRecord(record, position) {
30
+ if (record.status === "error") {
31
+ return `Agent failed: ${record.error ?? "unknown error"}${partialOutputSuffix(record)}`;
32
+ }
33
+ if (record.status === "queued" || record.status === "running") {
34
+ return `Agent ${record.id} is ${record.status}.`;
35
+ }
36
+ // A truncated run must not read as a finished one. The top-level path carries
37
+ // this in its result headline; a nested result has no headline, so the note
38
+ // leads — appended, it would look like part of the child's own output.
39
+ const text = record.result?.trim() || record.error?.trim() || "No output.";
40
+ const note = position === "inline"
41
+ ? getForegroundOutcomeNote(record.status)
42
+ : getStatusNote(record.status);
43
+ return note ? `Nested agent${note}.\n\n${text}` : text;
44
+ }
45
+ /** Build child-safe orchestration tools scoped to one parent agent instance. */
46
+ export function createNestedSubagentTools(context) {
47
+ // Agents resolve from a registry built for THIS branch's config root (under
48
+ // worktree isolation, the copy). Never via registerAgents — that is
49
+ // process-global state shared with the main session and every other agent.
50
+ const loadRegistry = () => buildAgentRegistry(loadCustomAgents(context.configCwd));
51
+ const allowedTypesIn = (registry) => context.allowedSubagents === "all"
52
+ ? undefined
53
+ : new Set(context.allowedSubagents.map(name => resolveTypeIn(registry, name) ?? name));
54
+ const availableIn = (registry) => {
55
+ const allowed = allowedTypesIn(registry);
56
+ return getAvailableTypesIn(registry).filter(name => allowed === undefined || allowed.has(name));
57
+ };
58
+ const agentTool = defineTool({
59
+ name: NESTED_TOOL_NAMES[0],
60
+ label: "Agent",
61
+ description: "Launch a child-safe nested subagent for bounded delegated work. " +
62
+ "Only use agent types allowed by this parent agent; nesting is depth-limited.",
63
+ parameters: Type.Object({
64
+ prompt: Type.String({ description: "Self-contained task for the nested agent." }),
65
+ description: Type.String({ description: "Short 3-5 word task description." }),
66
+ subagent_type: Type.String({ description: `Allowed nested agent type. Available: ${availableIn(loadRegistry()).join(", ") || "none"}.` }),
67
+ model: Type.Optional(Type.String({ description: "Optional provider/model override." })),
68
+ thinking: Type.Optional(Type.String({ description: "Optional thinking level." })),
69
+ max_turns: Type.Optional(Type.Number({ minimum: 1 })),
70
+ run_in_background: Type.Optional(Type.Boolean({
71
+ description: "Defaults to false for nested spawns — the call blocks and returns the child's result inline. Set true only for work you will collect later with get_subagent_result; a detached child is stopped when you finish.",
72
+ })),
73
+ resume: Type.Optional(Type.String({ description: "Resume a nested agent owned by this parent." })),
74
+ isolated: Type.Optional(Type.Boolean()),
75
+ inherit_context: Type.Optional(Type.Boolean()),
76
+ ...isolationParam(isWorktreeIsolationEnabled()),
77
+ }),
78
+ execute: async (_toolCallId, params, signal, _onUpdate, ctx) => {
79
+ if (params.resume) {
80
+ const existing = context.manager.getRecord(params.resume);
81
+ if (!ownsRecord(existing, context.parentAgentId)) {
82
+ return textResult(`Nested agent not found or not owned by this parent: "${params.resume}".`, true);
83
+ }
84
+ const resumed = await context.manager.resume(params.resume, params.prompt, signal);
85
+ return resumed
86
+ ? textResult(formatRecord(resumed, "inline"), resumed.status === "error")
87
+ : textResult(`Failed to resume nested agent "${params.resume}".`, true);
88
+ }
89
+ if (context.depth >= context.maxSubagentDepth) {
90
+ return textResult(`Nested subagent call blocked (depth=${context.depth}, max=${context.maxSubagentDepth}). Complete the task directly.`, true);
91
+ }
92
+ // Reloaded per call so new agent files are picked up without a restart.
93
+ const registry = loadRegistry();
94
+ const rawType = params.subagent_type;
95
+ // Strict resolve, never the fallback policy: a project-level
96
+ // `fallbackSubagent` must not hand a nested caller an agent its allowlist
97
+ // never named. The list stays allowlist-filtered so a typo can't enumerate
98
+ // agents this parent may not reach.
99
+ const resolvedType = resolveEnabledTypeIn(registry, rawType);
100
+ if (resolvedType === undefined) {
101
+ return textResult(`Unknown or disabled nested agent type: "${rawType}". Allowed: ${availableIn(registry).join(", ") || "none"}.`, true);
102
+ }
103
+ const allowed = allowedTypesIn(registry);
104
+ if (allowed !== undefined && !allowed.has(resolvedType)) {
105
+ return textResult(`Nested agent type "${resolvedType}" is not allowed for this parent. Allowed: ${[...allowed].join(", ")}.`, true);
106
+ }
107
+ const config = getAgentConfigIn(registry, resolvedType);
108
+ // Foreground regardless of `backgroundByDefault` — see the reasoning on
109
+ // ResolveOptions. An explicit `true` here still opts in.
110
+ const invocation = resolveAgentInvocationConfig(config, params, {
111
+ worktreeAllowed: isWorktreeIsolationEnabled(),
112
+ defaultRunInBackground: false,
113
+ });
114
+ let model = ctx.model;
115
+ if (invocation.modelInput) {
116
+ const resolvedModel = resolveModel(invocation.modelInput, ctx.modelRegistry);
117
+ if (typeof resolvedModel === "string") {
118
+ if (invocation.modelFromParams)
119
+ return textResult(resolvedModel, true);
120
+ }
121
+ else {
122
+ model = resolvedModel;
123
+ }
124
+ }
125
+ // Same scopeModels policy as the top-level Agent tool — a nested spawn
126
+ // must not escape the allowlist. A "warn" verdict proceeds silently:
127
+ // child sessions have no UI surface to toast to.
128
+ const scopeVerdict = checkModelScope({
129
+ model,
130
+ cwd: context.configCwd,
131
+ modelRegistry: ctx.modelRegistry,
132
+ callerSupplied: invocation.modelFromParams,
133
+ agentLabel: config?.displayName ?? resolvedType,
134
+ modelInput: invocation.modelInput,
135
+ });
136
+ if (scopeVerdict.kind === "error")
137
+ return textResult(scopeVerdict.message, true);
138
+ // The whole branch shares the root session's transcript directory; read it
139
+ // off the owning parent rather than this child session's own id.
140
+ const rootSessionId = context.manager.getRecord(context.parentAgentId)?.rootSessionId;
141
+ const childDepth = context.depth + 1;
142
+ const options = {
143
+ description: params.description,
144
+ model,
145
+ maxTurns: invocation.maxTurns,
146
+ isolated: invocation.isolated,
147
+ inheritContext: invocation.inheritContext,
148
+ thinkingLevel: invocation.thinking,
149
+ isolation: invocation.isolation,
150
+ outputTranscript: config?.outputTranscript ?? getOutputTranscriptDefault(),
151
+ invocation: {
152
+ thinking: invocation.thinking,
153
+ maxTurns: invocation.maxTurns,
154
+ isolated: invocation.isolated,
155
+ inheritContext: invocation.inheritContext,
156
+ runInBackground: invocation.runInBackground,
157
+ isolation: invocation.isolation,
158
+ },
159
+ // Nested children are hidden from every reporting surface, so their spend
160
+ // would otherwise be unattributable. Fold it into every ancestor's record:
161
+ // the top-level one appears in lifecycle events, completion notifications,
162
+ // and `/agents`, and those all read `lifetimeUsage`. The whole chain is
163
+ // walked, not just the immediate parent — a spawn callback only fires for
164
+ // that child's OWN turns, so stopping at one level would hide a
165
+ // great-grandchild from the only record anyone can see. (The live
166
+ // widget/fleet counters read their own per-agent activity tracker, which
167
+ // still sees only the top-level agent's own turns.)
168
+ onAssistantUsage: (usage) => {
169
+ for (let id = context.parentAgentId; id !== undefined;) {
170
+ const ancestor = context.manager.getRecord(id);
171
+ if (!ancestor)
172
+ break;
173
+ addUsage(ancestor.lifetimeUsage, usage);
174
+ id = ancestor.parentAgentId;
175
+ }
176
+ },
177
+ depth: childDepth,
178
+ parentAgentId: context.parentAgentId,
179
+ maxSubagentDepth: context.maxSubagentDepth,
180
+ configCwd: context.configCwd,
181
+ rootSessionId,
182
+ };
183
+ // Transcript wiring, same gate as the top-level path: the child's
184
+ // `output_transcript` frontmatter wins, else the project default. Without
185
+ // it a nested run leaves no artifact but the string it returned — the
186
+ // parent's own transcript records the call and the answer, never the tool
187
+ // calls in between, which is exactly what a misbehaving child needs to
188
+ // explain itself. Filed under the ROOT session and this branch's config
189
+ // root, so a nested transcript lands in the same `tasks/` directory as its
190
+ // ancestors' rather than in a directory of its own.
191
+ const transcriptSessionId = rootSessionId !== undefined && (config?.outputTranscript ?? getOutputTranscriptDefault())
192
+ ? rootSessionId
193
+ : undefined;
194
+ let childId;
195
+ const attachTranscript = (id) => {
196
+ childId = id;
197
+ if (transcriptSessionId === undefined)
198
+ return;
199
+ const rec = context.manager.getRecord(id);
200
+ if (!rec)
201
+ return;
202
+ rec.outputFile = createOutputFilePath(context.configCwd, id, transcriptSessionId);
203
+ writeInitialEntry(rec.outputFile, id, params.prompt, ctx.cwd);
204
+ };
205
+ options.onSessionCreated = (session) => {
206
+ const rec = childId === undefined ? undefined : context.manager.getRecord(childId);
207
+ if (rec?.outputFile && childId !== undefined) {
208
+ rec.outputCleanup = streamToOutputFile(session, rec.outputFile, childId, ctx.cwd, undefined);
209
+ }
210
+ };
211
+ // `ctx` is forwarded to the manager unmodified, never captured at tool-build
212
+ // time: each AgentSession builds its own ExtensionRunner from that session's
213
+ // cwd/sessionManager/modelRegistry, so this is the CHILD's context. Capturing
214
+ // one earlier would silently give a grandchild the wrong worktree base, the
215
+ // wrong conversation under inherit_context, and the wrong inherited model.
216
+ //
217
+ // spawn() throws on strict worktree-isolation failure and cwd validation —
218
+ // report it as a tool error, like the top-level Agent tool does, instead of
219
+ // letting it escape into the child's turn.
220
+ try {
221
+ if (invocation.runInBackground) {
222
+ const id = context.manager.spawn(context.pi, ctx, resolvedType, params.prompt, {
223
+ ...options,
224
+ isBackground: true,
225
+ });
226
+ // Synchronous, before the event loop yields — onSessionCreated fires
227
+ // asynchronously inside runAgent, so the file is attached in time.
228
+ attachTranscript(id);
229
+ // Worktree isolation starts the agent asynchronously; surface its
230
+ // failure as a tool error, like the synchronous throw used to.
231
+ await context.manager.awaitStartup(id);
232
+ return textResult(`Nested agent started in background. Agent ID: ${id}`);
233
+ }
234
+ const { record } = await context.manager.spawnAndWait(context.pi, ctx, resolvedType, params.prompt, { ...options, signal }, attachTranscript);
235
+ return textResult(formatRecord(record, "inline"), record.status === "error");
236
+ }
237
+ catch (err) {
238
+ return textResult(err instanceof Error ? err.message : String(err), true);
239
+ }
240
+ },
241
+ });
242
+ const resultTool = defineTool({
243
+ name: NESTED_TOOL_NAMES[1],
244
+ label: "Get Nested Agent Result",
245
+ description: "Check or wait for a background nested agent owned by this parent.",
246
+ parameters: Type.Object({
247
+ agent_id: Type.String(),
248
+ wait: Type.Optional(Type.Boolean()),
249
+ }),
250
+ execute: async (_toolCallId, params, signal) => {
251
+ const record = context.manager.getRecord(params.agent_id);
252
+ if (!ownsRecord(record, context.parentAgentId)) {
253
+ return textResult(`Nested agent not found or not owned by this parent: "${params.agent_id}".`, true);
254
+ }
255
+ // Wait for completion if requested. Cancellation (e.g. the parent's tool
256
+ // call is aborted) stops only this wait; the nested child keeps running and
257
+ // stays unconsumed. Queued records have no promise until the manager starts
258
+ // them, so poll — abortably — until they leave the queue, then await.
259
+ if (params.wait && (record.status === "queued" || record.status === "running")) {
260
+ while (record.status === "queued") {
261
+ await abortable(new Promise(resolve => setTimeout(resolve, 250)), signal);
262
+ }
263
+ if (record.promise)
264
+ await abortable(record.promise, signal);
265
+ }
266
+ return textResult(formatRecord(record, "fetched"), record.status === "error");
267
+ },
268
+ });
269
+ const steerTool = defineTool({
270
+ name: NESTED_TOOL_NAMES[2],
271
+ label: "Steer Nested Agent",
272
+ description: "Send guidance to a running nested agent owned by this parent.",
273
+ parameters: Type.Object({
274
+ agent_id: Type.String(),
275
+ message: Type.String(),
276
+ }),
277
+ execute: async (_toolCallId, params) => {
278
+ const record = context.manager.getRecord(params.agent_id);
279
+ if (!ownsRecord(record, context.parentAgentId) || record.status !== "running") {
280
+ return textResult(`Running nested agent not found or not owned by this parent: "${params.agent_id}".`, true);
281
+ }
282
+ // Session not ready yet — queue the steer. The manager flushes pending
283
+ // steers when the session is created (same contract as the top-level tool).
284
+ if (!record.session) {
285
+ if (!record.pendingSteers)
286
+ record.pendingSteers = [];
287
+ record.pendingSteers.push(params.message);
288
+ return textResult(`Steering message queued for nested agent ${params.agent_id}.`);
289
+ }
290
+ try {
291
+ await record.session.steer(params.message);
292
+ }
293
+ catch (err) {
294
+ return textResult(`Failed to steer nested agent: ${err instanceof Error ? err.message : String(err)}`, true);
295
+ }
296
+ return textResult(`Steering message sent to nested agent ${params.agent_id}.`);
297
+ },
298
+ });
299
+ return [agentTool, resultTool, steerTool];
300
+ }
301
+ //# sourceMappingURL=nested-tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nested-tools.js","sourceRoot":"","sources":["../src/nested-tools.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,GAIX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,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AC"}
@@ -5,6 +5,8 @@
5
5
  * matching Claude Code's task output file format.
6
6
  */
7
7
  import type { AgentSession } from "@earendil-works/pi-coding-agent";
8
+ export declare function getOutputTranscriptDefault(): boolean;
9
+ export declare function setOutputTranscriptDefault(b: boolean): void;
8
10
  /**
9
11
  * Encode a cwd path as a filesystem-safe directory name. Handles:
10
12
  * - POSIX: "/home/user/project" → "home-user-project"
@@ -12,14 +14,31 @@ import type { AgentSession } from "@earendil-works/pi-coding-agent";
12
14
  * - UNC: "\\\\server\\share\\project" → "server-share-project"
13
15
  */
14
16
  export declare function encodeCwd(cwd: string): string;
15
- /** Create the output file path, ensuring the directory exists.
16
- * Mirrors Claude Code's layout: /tmp/{prefix}-{uid}/{encoded-cwd}/{sessionId}/tasks/{agentId}.output */
17
+ /**
18
+ * The per-session scratch directory, created if missing.
19
+ * Mirrors Claude Code's layout: /tmp/{prefix}-{uid}/{encoded-cwd}/{sessionId}/tasks
20
+ *
21
+ * Shared with the workflow tool, which persists each invocation's script here so
22
+ * iterating on one is edit-file-then-rerun — the same convention, one directory.
23
+ */
24
+ export declare function sessionTaskDir(cwd: string, sessionId: string): string;
25
+ /** Create the output file path, ensuring the directory exists. */
17
26
  export declare function createOutputFilePath(cwd: string, agentId: string, sessionId: string): string;
27
+ /**
28
+ * Ensure a transcript file exists without disturbing what is already in it.
29
+ *
30
+ * A resume reuses the agent's existing transcript (same deterministic path), so
31
+ * it must never call `writeInitialEntry` — that truncates, discarding turns the
32
+ * completion notification still points the user at, and any history the session
33
+ * has since compacted away is gone for good. Appending nothing creates the file
34
+ * when this is the agent's first transcript and is a no-op when it is not.
35
+ */
36
+ export declare function ensureOutputFile(path: string): void;
18
37
  /** Write the initial user prompt entry. */
19
38
  export declare function writeInitialEntry(path: string, agentId: string, prompt: string, cwd: string): void;
20
39
  /**
21
40
  * Subscribe to session events and flush new messages to the output file on each turn_end.
22
41
  * Returns a cleanup function that does a final flush and unsubscribes.
23
42
  */
24
- export declare function streamToOutputFile(session: AgentSession, path: string, agentId: string, cwd: string, historyPath?: string): () => void;
43
+ export declare function streamToOutputFile(session: AgentSession, path: string, agentId: string, cwd: string, startIndexOrHistoryPath?: number | string, historyPath?: string): () => void;
25
44
  //# sourceMappingURL=output-file.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../src/output-file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,iCAAiC,CAAC;AAEvF;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;yGACyG;AACzG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAc5F;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAUlG;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,MAAM,GACnB,MAAM,IAAI,CA+CZ"}
1
+ {"version":3,"file":"output-file.d.ts","sourceRoot":"","sources":["../src/output-file.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,iCAAiC,CAAC;AAavF,wBAAgB,0BAA0B,IAAI,OAAO,CAAoC;AACzF,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAiC;AAE7F;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK7C;AAED;;;;;;GAMG;AACH,wBAAgB,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