actoviq-agent-sdk 0.4.12 → 0.4.13

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 (194) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/config/agentDefinitionMigration.d.ts +125 -0
  3. package/dist/src/config/agentDefinitionMigration.d.ts.map +1 -0
  4. package/dist/src/config/agentDefinitionMigration.js +540 -0
  5. package/dist/src/config/agentDefinitionMigration.js.map +1 -0
  6. package/dist/src/config/agentProfiles.d.ts +19 -0
  7. package/dist/src/config/agentProfiles.d.ts.map +1 -1
  8. package/dist/src/config/agentProfiles.js +65 -13
  9. package/dist/src/config/agentProfiles.js.map +1 -1
  10. package/dist/src/config/modelConfigurationCatalog.d.ts +25 -0
  11. package/dist/src/config/modelConfigurationCatalog.d.ts.map +1 -0
  12. package/dist/src/config/modelConfigurationCatalog.js +50 -0
  13. package/dist/src/config/modelConfigurationCatalog.js.map +1 -0
  14. package/dist/src/gui/agentTargetPicker.d.ts +32 -0
  15. package/dist/src/gui/agentTargetPicker.d.ts.map +1 -0
  16. package/dist/src/gui/agentTargetPicker.js +99 -0
  17. package/dist/src/gui/agentTargetPicker.js.map +1 -0
  18. package/dist/src/gui/electronMain.js +1 -0
  19. package/dist/src/gui/electronMain.js.map +1 -1
  20. package/dist/src/gui/hadamardGui.d.ts +23 -0
  21. package/dist/src/gui/hadamardGui.d.ts.map +1 -1
  22. package/dist/src/gui/hadamardGui.js +4120 -931
  23. package/dist/src/gui/hadamardGui.js.map +1 -1
  24. package/dist/src/gui/projectWorkbench.d.ts +6 -2
  25. package/dist/src/gui/projectWorkbench.d.ts.map +1 -1
  26. package/dist/src/gui/projectWorkbench.js +76 -67
  27. package/dist/src/gui/projectWorkbench.js.map +1 -1
  28. package/dist/src/gui/promptTemplates.d.ts +0 -1
  29. package/dist/src/gui/promptTemplates.d.ts.map +1 -1
  30. package/dist/src/gui/promptTemplates.js +0 -3
  31. package/dist/src/gui/promptTemplates.js.map +1 -1
  32. package/dist/src/gui/transcript/clientBundle.d.ts +6 -1
  33. package/dist/src/gui/transcript/clientBundle.d.ts.map +1 -1
  34. package/dist/src/gui/transcript/clientBundle.js +6 -1
  35. package/dist/src/gui/transcript/clientBundle.js.map +1 -1
  36. package/dist/src/help/productCapabilities.d.ts +17 -0
  37. package/dist/src/help/productCapabilities.d.ts.map +1 -0
  38. package/dist/src/help/productCapabilities.js +146 -0
  39. package/dist/src/help/productCapabilities.js.map +1 -0
  40. package/dist/src/index.d.ts +15 -4
  41. package/dist/src/index.d.ts.map +1 -1
  42. package/dist/src/index.js +9 -3
  43. package/dist/src/index.js.map +1 -1
  44. package/dist/src/issues/issueExecution.d.ts.map +1 -1
  45. package/dist/src/issues/issueExecution.js +29 -9
  46. package/dist/src/issues/issueExecution.js.map +1 -1
  47. package/dist/src/manager/assistantGlobalTools.d.ts +44 -0
  48. package/dist/src/manager/assistantGlobalTools.d.ts.map +1 -1
  49. package/dist/src/manager/assistantGlobalTools.js +565 -32
  50. package/dist/src/manager/assistantGlobalTools.js.map +1 -1
  51. package/dist/src/manager/assistantProposals.d.ts +87 -0
  52. package/dist/src/manager/assistantProposals.d.ts.map +1 -0
  53. package/dist/src/manager/assistantProposals.js +207 -0
  54. package/dist/src/manager/assistantProposals.js.map +1 -0
  55. package/dist/src/manager/referenceIndex.d.ts +82 -0
  56. package/dist/src/manager/referenceIndex.d.ts.map +1 -0
  57. package/dist/src/manager/referenceIndex.js +167 -0
  58. package/dist/src/manager/referenceIndex.js.map +1 -0
  59. package/dist/src/manager/referenceOperations.d.ts +108 -0
  60. package/dist/src/manager/referenceOperations.d.ts.map +1 -0
  61. package/dist/src/manager/referenceOperations.js +821 -0
  62. package/dist/src/manager/referenceOperations.js.map +1 -0
  63. package/dist/src/manager/resolveTargetRef.d.ts +67 -0
  64. package/dist/src/manager/resolveTargetRef.d.ts.map +1 -0
  65. package/dist/src/manager/resolveTargetRef.js +81 -0
  66. package/dist/src/manager/resolveTargetRef.js.map +1 -0
  67. package/dist/src/router/modelRouter.d.ts +22 -2
  68. package/dist/src/router/modelRouter.d.ts.map +1 -1
  69. package/dist/src/router/modelRouter.js +76 -9
  70. package/dist/src/router/modelRouter.js.map +1 -1
  71. package/dist/src/runtime/agentClient.d.ts +18 -0
  72. package/dist/src/runtime/agentClient.d.ts.map +1 -1
  73. package/dist/src/runtime/agentClient.js +209 -21
  74. package/dist/src/runtime/agentClient.js.map +1 -1
  75. package/dist/src/runtime/agentSession.d.ts +7 -0
  76. package/dist/src/runtime/agentSession.d.ts.map +1 -1
  77. package/dist/src/runtime/agentSession.js +10 -0
  78. package/dist/src/runtime/agentSession.js.map +1 -1
  79. package/dist/src/runtime/agentTemplates.d.ts +28 -0
  80. package/dist/src/runtime/agentTemplates.d.ts.map +1 -0
  81. package/dist/src/runtime/agentTemplates.js +73 -0
  82. package/dist/src/runtime/agentTemplates.js.map +1 -0
  83. package/dist/src/runtime/conversationEngine.d.ts +2 -0
  84. package/dist/src/runtime/conversationEngine.d.ts.map +1 -1
  85. package/dist/src/runtime/conversationEngine.js +10 -1
  86. package/dist/src/runtime/conversationEngine.js.map +1 -1
  87. package/dist/src/runtime/defaultHadamardAgents.d.ts.map +1 -1
  88. package/dist/src/runtime/defaultHadamardAgents.js +9 -47
  89. package/dist/src/runtime/defaultHadamardAgents.js.map +1 -1
  90. package/dist/src/runtime/effectiveAgentRunOptions.d.ts +49 -0
  91. package/dist/src/runtime/effectiveAgentRunOptions.d.ts.map +1 -0
  92. package/dist/src/runtime/effectiveAgentRunOptions.js +50 -0
  93. package/dist/src/runtime/effectiveAgentRunOptions.js.map +1 -0
  94. package/dist/src/runtime/externalAgentRunner.d.ts +25 -0
  95. package/dist/src/runtime/externalAgentRunner.d.ts.map +1 -0
  96. package/dist/src/runtime/externalAgentRunner.js +57 -0
  97. package/dist/src/runtime/externalAgentRunner.js.map +1 -0
  98. package/dist/src/runtime/hadamardAgentDefinitions.d.ts +15 -0
  99. package/dist/src/runtime/hadamardAgentDefinitions.d.ts.map +1 -1
  100. package/dist/src/runtime/hadamardAgentDefinitions.js +42 -2
  101. package/dist/src/runtime/hadamardAgentDefinitions.js.map +1 -1
  102. package/dist/src/runtime/hadamardAgents.d.ts +6 -0
  103. package/dist/src/runtime/hadamardAgents.d.ts.map +1 -1
  104. package/dist/src/runtime/hadamardAgents.js +52 -1
  105. package/dist/src/runtime/hadamardAgents.js.map +1 -1
  106. package/dist/src/runtime/hadamardPermissions.d.ts +1 -0
  107. package/dist/src/runtime/hadamardPermissions.d.ts.map +1 -1
  108. package/dist/src/runtime/hadamardPermissions.js +6 -0
  109. package/dist/src/runtime/hadamardPermissions.js.map +1 -1
  110. package/dist/src/runtime/tools.d.ts.map +1 -1
  111. package/dist/src/runtime/tools.js +2 -0
  112. package/dist/src/runtime/tools.js.map +1 -1
  113. package/dist/src/team/executorTarget.d.ts +26 -0
  114. package/dist/src/team/executorTarget.d.ts.map +1 -0
  115. package/dist/src/team/executorTarget.js +15 -0
  116. package/dist/src/team/executorTarget.js.map +1 -0
  117. package/dist/src/team/modelTeam.d.ts +5 -1
  118. package/dist/src/team/modelTeam.d.ts.map +1 -1
  119. package/dist/src/team/modelTeam.js +157 -41
  120. package/dist/src/team/modelTeam.js.map +1 -1
  121. package/dist/src/team/teamComposition.d.ts +20 -0
  122. package/dist/src/team/teamComposition.d.ts.map +1 -0
  123. package/dist/src/team/teamComposition.js +78 -0
  124. package/dist/src/team/teamComposition.js.map +1 -0
  125. package/dist/src/team/teamDefinitions.d.ts +10 -1
  126. package/dist/src/team/teamDefinitions.d.ts.map +1 -1
  127. package/dist/src/team/teamDefinitions.js +123 -16
  128. package/dist/src/team/teamDefinitions.js.map +1 -1
  129. package/dist/src/team/teamGraph.d.ts +1 -1
  130. package/dist/src/team/teamGraph.d.ts.map +1 -1
  131. package/dist/src/team/teamGraph.js +1 -1
  132. package/dist/src/team/teamGraph.js.map +1 -1
  133. package/dist/src/team/teamPrompts.d.ts.map +1 -1
  134. package/dist/src/team/teamPrompts.js +0 -4
  135. package/dist/src/team/teamPrompts.js.map +1 -1
  136. package/dist/src/team/teamProposalService.d.ts +9 -1
  137. package/dist/src/team/teamProposalService.d.ts.map +1 -1
  138. package/dist/src/team/teamProposalService.js +66 -6
  139. package/dist/src/team/teamProposalService.js.map +1 -1
  140. package/dist/src/team/teamPropose.d.ts +3 -1
  141. package/dist/src/team/teamPropose.d.ts.map +1 -1
  142. package/dist/src/team/teamPropose.js +16 -10
  143. package/dist/src/team/teamPropose.js.map +1 -1
  144. package/dist/src/team/teamRuntime.d.ts +5 -0
  145. package/dist/src/team/teamRuntime.d.ts.map +1 -1
  146. package/dist/src/team/teamRuntime.js +23 -5
  147. package/dist/src/team/teamRuntime.js.map +1 -1
  148. package/dist/src/team/workflowSquad.d.ts +10 -2
  149. package/dist/src/team/workflowSquad.d.ts.map +1 -1
  150. package/dist/src/team/workflowSquad.js +250 -12
  151. package/dist/src/team/workflowSquad.js.map +1 -1
  152. package/dist/src/tools/enterWorktree.d.ts.map +1 -1
  153. package/dist/src/tools/enterWorktree.js +3 -0
  154. package/dist/src/tools/enterWorktree.js.map +1 -1
  155. package/dist/src/tools/exaSearch.d.ts +2 -2
  156. package/dist/src/tools/exitWorktree.d.ts.map +1 -1
  157. package/dist/src/tools/exitWorktree.js +3 -1
  158. package/dist/src/tools/exitWorktree.js.map +1 -1
  159. package/dist/src/tools/hadamardCoreTools.d.ts +5 -14
  160. package/dist/src/tools/hadamardCoreTools.d.ts.map +1 -1
  161. package/dist/src/tools/hadamardCoreTools.js +31 -0
  162. package/dist/src/tools/hadamardCoreTools.js.map +1 -1
  163. package/dist/src/tools/hadamardFileTools.d.ts.map +1 -1
  164. package/dist/src/tools/hadamardFileTools.js +116 -38
  165. package/dist/src/tools/hadamardFileTools.js.map +1 -1
  166. package/dist/src/tools/planMode/PlanModeTools.js +2 -2
  167. package/dist/src/tools/planMode/PlanModeTools.js.map +1 -1
  168. package/dist/src/tui/hadamardTui.d.ts.map +1 -1
  169. package/dist/src/tui/hadamardTui.js +358 -69
  170. package/dist/src/tui/hadamardTui.js.map +1 -1
  171. package/dist/src/tui/pendingInput.d.ts +17 -0
  172. package/dist/src/tui/pendingInput.d.ts.map +1 -0
  173. package/dist/src/tui/pendingInput.js +23 -0
  174. package/dist/src/tui/pendingInput.js.map +1 -0
  175. package/dist/src/tui/reasoningDisplay.d.ts +13 -0
  176. package/dist/src/tui/reasoningDisplay.d.ts.map +1 -0
  177. package/dist/src/tui/reasoningDisplay.js +45 -0
  178. package/dist/src/tui/reasoningDisplay.js.map +1 -0
  179. package/dist/src/tui/screen.d.ts +11 -1
  180. package/dist/src/tui/screen.d.ts.map +1 -1
  181. package/dist/src/tui/screen.js +64 -34
  182. package/dist/src/tui/screen.js.map +1 -1
  183. package/dist/src/types.d.ts +171 -4
  184. package/dist/src/types.d.ts.map +1 -1
  185. package/dist/src/types.js.map +1 -1
  186. package/dist/src/ui/commandSurface.d.ts +8 -0
  187. package/dist/src/ui/commandSurface.d.ts.map +1 -1
  188. package/dist/src/ui/commandSurface.js +71 -7
  189. package/dist/src/ui/commandSurface.js.map +1 -1
  190. package/package.json +1 -1
  191. package/dist/src/gui/projectSettings.d.ts +0 -2
  192. package/dist/src/gui/projectSettings.d.ts.map +0 -1
  193. package/dist/src/gui/projectSettings.js +0 -2
  194. package/dist/src/gui/projectSettings.js.map +0 -1
@@ -0,0 +1,17 @@
1
+ export type ActiveInputMode = 'follow-up' | 'steer';
2
+ export interface PendingInputPort {
3
+ followUp(input: string): void;
4
+ steer(input: string): void;
5
+ cancelLatestFollowUp(): string | undefined;
6
+ }
7
+ /** TUI policy adapter; the runtime queue remains owned by AgentSession. */
8
+ export declare function submitActiveInput(port: PendingInputPort, input: string, mode: ActiveInputMode): void;
9
+ /**
10
+ * Pull the newest queued follow-up into the editor for editing.
11
+ * Callers must restore it via {@link restoreAbandonedFollowUp} if the user
12
+ * clears the editor without resubmitting.
13
+ */
14
+ export declare function recallLatestFollowUp(port: PendingInputPort): string | undefined;
15
+ /** Re-queue a follow-up that was recalled into the editor but abandoned. */
16
+ export declare function restoreAbandonedFollowUp(port: PendingInputPort, recalled: string | null | undefined): void;
17
+ //# sourceMappingURL=pendingInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pendingInput.d.ts","sourceRoot":"","sources":["../../../src/tui/pendingInput.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,OAAO,CAAC;AAEpD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,oBAAoB,IAAI,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,eAAe,GACpB,IAAI,CAGN;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAE/E;AAED,4EAA4E;AAC5E,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,gBAAgB,EACtB,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAClC,IAAI,CAIN"}
@@ -0,0 +1,23 @@
1
+ /** TUI policy adapter; the runtime queue remains owned by AgentSession. */
2
+ export function submitActiveInput(port, input, mode) {
3
+ if (mode === 'steer')
4
+ port.steer(input);
5
+ else
6
+ port.followUp(input);
7
+ }
8
+ /**
9
+ * Pull the newest queued follow-up into the editor for editing.
10
+ * Callers must restore it via {@link restoreAbandonedFollowUp} if the user
11
+ * clears the editor without resubmitting.
12
+ */
13
+ export function recallLatestFollowUp(port) {
14
+ return port.cancelLatestFollowUp();
15
+ }
16
+ /** Re-queue a follow-up that was recalled into the editor but abandoned. */
17
+ export function restoreAbandonedFollowUp(port, recalled) {
18
+ const text = recalled?.trim();
19
+ if (!text)
20
+ return;
21
+ port.followUp(text);
22
+ }
23
+ //# sourceMappingURL=pendingInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pendingInput.js","sourceRoot":"","sources":["../../../src/tui/pendingInput.ts"],"names":[],"mappings":"AAQA,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAC/B,IAAsB,EACtB,KAAa,EACb,IAAqB;IAErB,IAAI,IAAI,KAAK,OAAO;QAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;;QACnC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAsB;IACzD,OAAO,IAAI,CAAC,oBAAoB,EAAE,CAAC;AACrC,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,wBAAwB,CACtC,IAAsB,EACtB,QAAmC;IAEnC,MAAM,IAAI,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC9B,IAAI,CAAC,IAAI;QAAE,OAAO;IAClB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** Owns one reasoning segment independently from transport event boundaries. */
2
+ export declare class ReasoningDisplayState {
3
+ private activeText;
4
+ private streamed;
5
+ get hasActive(): boolean;
6
+ get hasStreamedContent(): boolean;
7
+ append(delta: string): void;
8
+ setCompleteContent(text: string): void;
9
+ liveLines(width: number, maxRows?: number): string[];
10
+ complete(): string[];
11
+ reset(): void;
12
+ }
13
+ //# sourceMappingURL=reasoningDisplay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reasoningDisplay.d.ts","sourceRoot":"","sources":["../../../src/tui/reasoningDisplay.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,qBAAa,qBAAqB;IAChC,OAAO,CAAC,UAAU,CAAM;IACxB,OAAO,CAAC,QAAQ,CAAS;IAEzB,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,kBAAkB,IAAI,OAAO,CAEhC;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAM3B,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAItC,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAI,GAAG,MAAM,EAAE;IAU/C,QAAQ,IAAI,MAAM,EAAE;IAUpB,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,45 @@
1
+ import { A, wrapToWidth } from './ansi.js';
2
+ /** Owns one reasoning segment independently from transport event boundaries. */
3
+ export class ReasoningDisplayState {
4
+ activeText = '';
5
+ streamed = false;
6
+ get hasActive() {
7
+ return this.activeText.trim().length > 0;
8
+ }
9
+ get hasStreamedContent() {
10
+ return this.streamed;
11
+ }
12
+ append(delta) {
13
+ if (!delta)
14
+ return;
15
+ this.activeText += delta;
16
+ this.streamed = true;
17
+ }
18
+ setCompleteContent(text) {
19
+ if (!this.hasActive && text.trim())
20
+ this.activeText = text;
21
+ }
22
+ liveLines(width, maxRows = 6) {
23
+ const condensed = this.activeText.replace(/\s+/g, ' ').trim();
24
+ if (!condensed)
25
+ return [];
26
+ const contentWidth = Math.max(width - 4, 16);
27
+ const lines = wrapToWidth(condensed, contentWidth).map((line, index) => (`${A.dim}${index === 0 ? '∴ ' : ' '}${line}${A.reset}`));
28
+ return lines.slice(Math.max(lines.length - maxRows, 0));
29
+ }
30
+ complete() {
31
+ const condensed = this.activeText.replace(/\s+/g, ' ').trim();
32
+ if (!condensed)
33
+ return [];
34
+ const words = condensed.split(/\s+/u).length;
35
+ const detail = words > 1 ? `${words} words` : `${[...condensed].length} chars`;
36
+ this.activeText = '';
37
+ this.streamed = false;
38
+ return [`${A.dim}∴ Thinking · ${detail} · collapsed${A.reset}`];
39
+ }
40
+ reset() {
41
+ this.activeText = '';
42
+ this.streamed = false;
43
+ }
44
+ }
45
+ //#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,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,CACxD,CAAC,CAAC;QACH,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,QAAQ;QACN,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9D,IAAI,CAAC,SAAS;YAAE,OAAO,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;QAC7C,MAAM,MAAM,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,MAAM,QAAQ,CAAC;QAC/E,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,gBAAgB,MAAM,eAAe,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,KAAK;QACH,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;CACF"}
@@ -5,10 +5,18 @@ export interface ScreenOutput {
5
5
  on?(event: 'resize', listener: () => void): unknown;
6
6
  off?(event: 'resize', listener: () => void): unknown;
7
7
  }
8
+ export interface DynamicCursorPosition {
9
+ /** Zero-based source line passed to setDynamic. */
10
+ line: number;
11
+ /** Zero-based visible terminal column. */
12
+ column: number;
13
+ }
8
14
  export declare class TuiScreen {
9
15
  private readonly out;
10
16
  private dynamicLines;
11
17
  private dynamicVisualCount;
18
+ private parkedRow;
19
+ private parkedColumn;
12
20
  private started;
13
21
  private readonly resizeListener;
14
22
  constructor(out: ScreenOutput);
@@ -20,9 +28,11 @@ export declare class TuiScreen {
20
28
  /** Print lines permanently into scrollback above the dynamic region. */
21
29
  appendStatic(lines: readonly string[]): void;
22
30
  /** Replace the dynamic bottom region. Lines are pre-wrapped to width. */
23
- setDynamic(lines: readonly string[]): void;
31
+ setDynamic(lines: readonly string[], cursor?: DynamicCursorPosition): void;
24
32
  private redraw;
25
33
  private redrawChangedLines;
26
34
  private buildDynamicPaint;
35
+ private moveToTop;
36
+ private moveFromTopToParkedCursor;
27
37
  }
28
38
  //# sourceMappingURL=screen.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../../src/tui/screen.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,YAAY;IAC3B,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;IACpD,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;CACtD;AAED,qBAAa,SAAS;IAMR,OAAO,CAAC,QAAQ,CAAC,GAAG;IALhC,OAAO,CAAC,YAAY,CAAgB;IACpC,OAAO,CAAC,kBAAkB,CAAK;IAC/B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAuB;gBAEzB,GAAG,EAAE,YAAY;IAE9C,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,KAAK,IAAI,IAAI;IAOb,0EAA0E;IAC1E,IAAI,IAAI,IA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,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI;IAa5C,yEAAyE;IACzE,UAAU,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,CAAC,EAAE,qBAAqB,GAAG,IAAI;IAyC1E,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,kBAAkB;IAY1B,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,yBAAyB;CAMlC"}
@@ -1,15 +1,10 @@
1
1
  /**
2
- * Scrollback-friendly renderer for the Hadamard TUI, mirroring Claude Code's
3
- * default REPL model (Ink <Static> + dynamic bottom region) without React:
2
+ * Scrollback-friendly renderer for the Hadamard TUI:
4
3
  *
5
- * - Transcript lines are printed permanently into the normal terminal
6
- * scrollback (`appendStatic`).
7
- * - A bottom dynamic region (status line, prompt bar, menus, dialogs) is
8
- * redrawn in place (`setDynamic`).
9
- *
10
- * The real terminal cursor stays hidden and parked at the top-left of the
11
- * dynamic region; the input caret is drawn as an inverse-video cell by the
12
- * caller. That single invariant keeps erase/redraw bookkeeping trivial.
4
+ * - Transcript lines are printed permanently into normal scrollback.
5
+ * - A bottom dynamic region is redrawn in place.
6
+ * - The hidden real cursor is parked at the input caret. Terminals and IMEs
7
+ * use that position even while the TUI draws its own inverse-video caret.
13
8
  */
14
9
  import { wrapToWidth } from './ansi.js';
15
10
  const HIDE_CURSOR = '\x1b[?25l';
@@ -22,6 +17,8 @@ export class TuiScreen {
22
17
  out;
23
18
  dynamicLines = [];
24
19
  dynamicVisualCount = 0;
20
+ parkedRow = 0;
21
+ parkedColumn = 0;
25
22
  started = false;
26
23
  resizeListener = () => this.redraw();
27
24
  constructor(out) {
@@ -46,48 +43,69 @@ export class TuiScreen {
46
43
  return;
47
44
  this.started = false;
48
45
  this.out.off?.('resize', this.resizeListener);
49
- this.out.write(CLEAR_DOWN + SHOW_CURSOR);
46
+ this.out.write(this.moveToTop() + CLEAR_DOWN + SHOW_CURSOR);
50
47
  this.dynamicLines = [];
51
48
  this.dynamicVisualCount = 0;
49
+ this.parkedRow = 0;
50
+ this.parkedColumn = 0;
52
51
  }
53
52
  /** Print lines permanently into scrollback above the dynamic region. */
54
53
  appendStatic(lines) {
55
54
  if (lines.length === 0)
56
55
  return;
57
56
  const wrapped = [];
58
- for (const line of lines) {
57
+ for (const line of lines)
59
58
  wrapped.push(...wrapToWidth(line, this.width));
60
- }
61
- this.out.write(CLEAR_DOWN +
62
- wrapped.join('\n') +
63
- '\n' +
64
- this.buildDynamicPaint());
59
+ this.out.write(this.moveToTop()
60
+ + CLEAR_DOWN
61
+ + wrapped.join('\n')
62
+ + '\n'
63
+ + this.buildDynamicPaint());
65
64
  }
66
65
  /** Replace the dynamic bottom region. Lines are pre-wrapped to width. */
67
- setDynamic(lines) {
66
+ setDynamic(lines, cursor) {
68
67
  const wrapped = [];
69
- for (const line of lines) {
70
- wrapped.push(...wrapToWidth(line, this.width));
68
+ let cursorRow = 0;
69
+ let cursorColumn = 0;
70
+ for (let index = 0; index < lines.length; index += 1) {
71
+ const start = wrapped.length;
72
+ const parts = wrapToWidth(lines[index], this.width);
73
+ wrapped.push(...parts);
74
+ if (cursor && cursor.line === index) {
75
+ cursorRow = start + Math.floor(Math.max(cursor.column, 0) / this.width);
76
+ cursorColumn = Math.max(cursor.column, 0) % this.width;
77
+ }
71
78
  }
72
- // Keep the region within the viewport so cursor-up math stays valid.
73
79
  const maxRows = this.height - 1;
74
- const nextLines = wrapped.slice(0, maxRows);
75
- if (sameLines(this.dynamicLines, nextLines))
80
+ const startRow = cursor && wrapped.length > maxRows
81
+ ? Math.min(Math.max(cursorRow - maxRows + 1, 0), wrapped.length - maxRows)
82
+ : 0;
83
+ const nextLines = wrapped.slice(startRow, startRow + maxRows);
84
+ const nextParkedRow = cursor
85
+ ? Math.max(0, Math.min(cursorRow - startRow, Math.max(nextLines.length - 1, 0)))
86
+ : 0;
87
+ const nextParkedColumn = cursor ? Math.min(cursorColumn, this.width - 1) : 0;
88
+ if (sameLines(this.dynamicLines, nextLines)
89
+ && this.parkedRow === nextParkedRow
90
+ && this.parkedColumn === nextParkedColumn)
76
91
  return;
77
92
  const previousLines = this.dynamicLines;
93
+ const previousParkedRow = this.parkedRow;
78
94
  this.dynamicLines = nextLines;
95
+ this.parkedRow = nextParkedRow;
96
+ this.parkedColumn = nextParkedColumn;
79
97
  if (previousLines.length === nextLines.length && nextLines.length > 0) {
80
- this.redrawChangedLines(previousLines);
98
+ this.redrawChangedLines(previousLines, previousParkedRow);
81
99
  }
82
100
  else {
83
- this.redraw();
101
+ this.redraw(previousParkedRow);
84
102
  }
85
103
  }
86
- redraw() {
87
- this.out.write(CLEAR_DOWN + this.buildDynamicPaint());
104
+ redraw(previousParkedRow = this.parkedRow) {
105
+ this.out.write(this.moveToTop(previousParkedRow) + CLEAR_DOWN + this.buildDynamicPaint());
88
106
  }
89
- redrawChangedLines(previousLines) {
90
- let output = SAVE_CURSOR;
107
+ redrawChangedLines(previousLines, previousParkedRow) {
108
+ let output = this.moveToTop(previousParkedRow) + SAVE_CURSOR;
91
109
  for (let index = 0; index < this.dynamicLines.length; index += 1) {
92
110
  if (previousLines[index] === this.dynamicLines[index])
93
111
  continue;
@@ -96,7 +114,7 @@ export class TuiScreen {
96
114
  output += `\x1b[${index}B`;
97
115
  output += `\r${this.dynamicLines[index]}${CLEAR_LINE_RIGHT}`;
98
116
  }
99
- output += RESTORE_CURSOR;
117
+ output += RESTORE_CURSOR + this.moveFromTopToParkedCursor();
100
118
  this.out.write(output);
101
119
  }
102
120
  buildDynamicPaint() {
@@ -105,11 +123,23 @@ export class TuiScreen {
105
123
  return '';
106
124
  }
107
125
  this.dynamicVisualCount = this.dynamicLines.length;
108
- // Park the cursor back at the start of the region (column 1, top row).
109
126
  let output = this.dynamicLines.join('\n') + '\r';
110
- if (this.dynamicVisualCount > 1) {
111
- output += `\x1b[${this.dynamicVisualCount - 1}A`;
112
- }
127
+ const rowsUp = this.dynamicVisualCount - 1 - this.parkedRow;
128
+ if (rowsUp > 0)
129
+ output += `\x1b[${rowsUp}A`;
130
+ if (this.parkedColumn > 0)
131
+ output += `\x1b[${this.parkedColumn}C`;
132
+ return output;
133
+ }
134
+ moveToTop(row = this.parkedRow) {
135
+ return `\r${row > 0 ? `\x1b[${row}A` : ''}`;
136
+ }
137
+ moveFromTopToParkedCursor() {
138
+ let output = '\r';
139
+ if (this.parkedRow > 0)
140
+ output += `\x1b[${this.parkedRow}B`;
141
+ if (this.parkedColumn > 0)
142
+ output += `\x1b[${this.parkedColumn}C`;
113
143
  return output;
114
144
  }
115
145
  }
@@ -1 +1 @@
1
- {"version":3,"file":"screen.js","sourceRoot":"","sources":["../../../src/tui/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,gBAAgB,GAAG,SAAS,CAAC;AACnC,MAAM,WAAW,GAAG,QAAQ,CAAC;AAC7B,MAAM,cAAc,GAAG,QAAQ,CAAC;AAUhC,MAAM,OAAO,SAAS;IAMS;IALrB,YAAY,GAAa,EAAE,CAAC;IAC5B,kBAAkB,GAAG,CAAC,CAAC;IACvB,OAAO,GAAG,KAAK,CAAC;IACP,cAAc,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IAEtD,YAA6B,GAAiB;QAAjB,QAAG,GAAH,GAAG,CAAc;IAAG,CAAC;IAElD,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,E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AAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5F,CAAC"}
@@ -151,6 +151,13 @@ export interface CreateToolOptions<Input = any, Output = any> {
151
151
  examples?: Array<Record<string, unknown>>;
152
152
  isReadOnly?: (input?: Input) => boolean;
153
153
  isDestructive?: (input?: Input) => boolean;
154
+ /**
155
+ * Plan-mode-only read-only classification (S1b §9.5): evaluated only in
156
+ * plan mode when the tool is otherwise unclassified — lets the Agent tool
157
+ * allow delegations to read-only subagents without changing default-mode
158
+ * behavior.
159
+ */
160
+ isPlanReadOnly?: (input?: Input) => boolean;
154
161
  requiresUserInteraction?: () => boolean;
155
162
  isConcurrencySafe?: () => boolean;
156
163
  checkPermissions?: (context: {
@@ -192,6 +199,13 @@ export interface AgentToolDefinition<Input = any, Output = any> {
192
199
  examples?: Array<Record<string, unknown>>;
193
200
  isReadOnly?: (input?: Input) => boolean;
194
201
  isDestructive?: (input?: Input) => boolean;
202
+ /**
203
+ * Plan-mode-only read-only classification (S1b §9.5): evaluated only in
204
+ * plan mode when the tool is otherwise unclassified — lets the Agent tool
205
+ * allow delegations to read-only subagents without changing default-mode
206
+ * behavior.
207
+ */
208
+ isPlanReadOnly?: (input?: Input) => boolean;
195
209
  requiresUserInteraction?: () => boolean;
196
210
  isConcurrencySafe?: () => boolean;
197
211
  checkPermissions?: (context: {
@@ -273,6 +287,8 @@ export interface ResolvedToolAdapter {
273
287
  execute: (input: unknown, context: ToolExecutionContext, onProgress?: ToolCallProgress) => Promise<ResolvedToolExecutionResult>;
274
288
  isReadOnly?: (input?: unknown) => boolean;
275
289
  isDestructive?: (input?: unknown) => boolean;
290
+ /** Plan-mode-only read-only classification (S1b §9.5). */
291
+ isPlanReadOnly?: (input?: unknown) => boolean;
276
292
  requiresUserInteraction?: () => boolean;
277
293
  isConcurrencySafe?: () => boolean;
278
294
  interruptBehavior?: 'cancel' | 'block';
@@ -405,8 +421,32 @@ export interface HadamardAgentDefinition {
405
421
  description: string;
406
422
  systemPrompt?: string;
407
423
  model?: string;
424
+ /** Referenced provider/bridge config name (unified store, S1a) — the definition runs on this config's own model client instead of inheriting the session's. */
425
+ bridgeConfig?: string;
426
+ /**
427
+ * Delegation runtime (09 Aug 2026): absent or 'hadamard' = in-process SDK;
428
+ * an external CLI runtime id ('claude' | 'pi' | 'codex' | …) routes Agent/Task
429
+ * delegations to that CLI via the bridge runner. Main-chat activation ignores
430
+ * this field (the main chat runtime comes from the active config).
431
+ */
432
+ runtime?: string;
433
+ /**
434
+ * Prompt composition (S1a): `extend` = built-in base prompt + body appended
435
+ * (profile semantics); `replace` = body is the complete system prompt
436
+ * (.md semantics). Definitions loaded from .md default to `replace`.
437
+ */
438
+ promptMode?: 'extend' | 'replace';
408
439
  effort?: HadamardRunEffort;
409
440
  permissionMode?: HadamardPermissionMode;
441
+ temperature?: number;
442
+ topP?: number;
443
+ maxTokens?: number;
444
+ /** Run timeout (ms) for runs under this definition. */
445
+ timeoutMs?: number;
446
+ /** `workspace` (default): project workspace only; `full`: unrestricted filesystem. */
447
+ workspaceAccess?: 'workspace' | 'full';
448
+ /** Whether the Agent/Task tool may delegate to this definition (default true). `false` = main-chat-only agent. */
449
+ subagent?: boolean;
410
450
  maxToolIterations?: number;
411
451
  maxTurns?: number;
412
452
  metadata?: Record<string, unknown>;
@@ -433,6 +473,10 @@ export interface HadamardAgentDefinitionSummary {
433
473
  name: string;
434
474
  description: string;
435
475
  model?: string;
476
+ /** Present when the definition pins a provider config (unified store). */
477
+ bridgeConfig?: string;
478
+ /** False = main-chat-only agent (not delegatable via the Agent/Task tool). */
479
+ subagent?: boolean;
436
480
  effort?: HadamardRunEffort;
437
481
  permissionMode?: HadamardPermissionMode;
438
482
  maxToolIterations?: number;
@@ -614,6 +658,27 @@ export interface HadamardInvokedSkillRecord {
614
658
  agent?: string;
615
659
  skillRoot?: string;
616
660
  }
661
+ /** One-shot external-CLI delegation request (agent runtime routing, 09 Aug 2026). */
662
+ export interface ExternalAgentRunRequest {
663
+ /** External runtime id (e.g. 'claude', 'codex'); never 'hadamard' here. */
664
+ runtime: string;
665
+ /** Definition name — used in error messages. */
666
+ agentName: string;
667
+ prompt: string;
668
+ systemPrompt?: string;
669
+ cwd: string;
670
+ signal?: AbortSignal;
671
+ model?: string;
672
+ /** Definition-pinned permission mode; the runner maps it to bridge semantics. */
673
+ permissionMode?: string;
674
+ homeDir?: string;
675
+ }
676
+ export interface ExternalAgentRunResult {
677
+ text: string;
678
+ sessionId?: string;
679
+ durationMs?: number;
680
+ numTurns?: number;
681
+ }
617
682
  export interface CreateAgentSdkOptions {
618
683
  homeDir?: string;
619
684
  apiKey?: string;
@@ -646,6 +711,12 @@ export interface CreateAgentSdkOptions {
646
711
  agentDirectories?: string[];
647
712
  loadDefaultAgentDirectories?: boolean;
648
713
  disableDefaultAgents?: boolean;
714
+ /**
715
+ * Override the external-CLI delegation runner (definitions with
716
+ * `runtime` ≠ 'hadamard'). Defaults to the bridge runner in
717
+ * runtime/externalAgentRunner.ts; inject a stub in tests.
718
+ */
719
+ externalAgentRunner?: (request: ExternalAgentRunRequest) => Promise<ExternalAgentRunResult>;
649
720
  maxSubagentDepth?: number;
650
721
  maxSubagentFanout?: number;
651
722
  skills?: HadamardSkillDefinition[];
@@ -770,6 +841,12 @@ export interface AgentRunOptions {
770
841
  /** Override the model client for this run — used by the /model router for cross-provider routing. */
771
842
  modelApi?: CreateAgentSdkOptions['modelApi'];
772
843
  maxTokens?: number;
844
+ /** Per-run tool-iteration cap; overrides the SDK config cap for this run. */
845
+ maxToolIterations?: number;
846
+ /** Restrict the effective default/custom tool catalog to these names. */
847
+ allowedTools?: string[];
848
+ /** Apply Agent filesystem/process confinement for this run. */
849
+ workspaceAccess?: 'workspace' | 'full';
773
850
  temperature?: number;
774
851
  topP?: number;
775
852
  toolChoice?: ToolChoice;
@@ -2394,7 +2471,32 @@ export interface WorktreeInfo {
2394
2471
  * convergence (the `panel` capability). `panel` and `analysis` are retained as
2395
2472
  * backward-compatible aliases that route to the same engine.
2396
2473
  */
2397
- export type ModelTeamMode = 'panel-analysis' | 'panel' | 'analysis' | 'reviewer' | 'executor-reviewer' | 'graph';
2474
+ export type ModelTeamMode = 'panel-analysis' | 'panel' | 'analysis' | 'reviewer' | 'executor-reviewer' | 'graph' | 'workflow';
2475
+ /**
2476
+ * Unified typed reference to an execution target (reference model redesign).
2477
+ * Schemas persist the reference, not a copied provider/baseURL/apiKey snapshot;
2478
+ * runtime resolution expands a ref via `resolveTargetRef`
2479
+ * (`src/manager/resolveTargetRef.ts`).
2480
+ *
2481
+ * There is deliberately no `router` kind: routers cannot be route/execution
2482
+ * targets (nested classification chains and cycles are disallowed).
2483
+ *
2484
+ * For `{ kind: 'model' }`, an empty `config` string marks a "raw model ref":
2485
+ * a legacy target whose originating bridge config is unknown — resolution then
2486
+ * falls back to whatever legacy provider/baseURL/apiKey fields sit next to the
2487
+ * ref (or to session defaults).
2488
+ */
2489
+ export type AgentTargetRef = {
2490
+ kind: 'model';
2491
+ config: string;
2492
+ model: string;
2493
+ } | {
2494
+ kind: 'agent';
2495
+ name: string;
2496
+ } | {
2497
+ kind: 'team';
2498
+ name: string;
2499
+ };
2398
2500
  /** A node in a workflow squad's execution tree. */
2399
2501
  export interface WorkflowNode {
2400
2502
  id: string;
@@ -2407,6 +2509,23 @@ export interface WorkflowNode {
2407
2509
  condition?: string;
2408
2510
  runtime?: string;
2409
2511
  model?: string;
2512
+ /** Agent nodes: specialist system prompt (separate from the task `prompt`). */
2513
+ systemPrompt?: string;
2514
+ /** Agent nodes: core-tool whitelist. Absent → no tools (legacy workflow behavior). */
2515
+ allowedTools?: string[];
2516
+ /** Per-node run timeout (ms). Omit → squad default. */
2517
+ timeoutMs?: number;
2518
+ /** Per-node ReAct tool-iteration cap. Omit or ≤0 = unlimited. */
2519
+ maxIterations?: number;
2520
+ /** `workspace` (default): project workspace only; `full`: unrestricted filesystem. */
2521
+ workspaceAccess?: 'workspace' | 'full';
2522
+ /**
2523
+ * Typed reference to this agent node's executor (saved agent profile, team,
2524
+ * or config-scoped model). When present, runtime resolution prefers it over
2525
+ * the legacy inline `model` field. Absent on legacy nodes — lazy migration
2526
+ * only fills it when the target is clearly resolvable.
2527
+ */
2528
+ targetRef?: AgentTargetRef;
2410
2529
  /** Children: branch=[if,else], parallel=all, agent=[] or one sequential continuation. */
2411
2530
  children: WorkflowNode[];
2412
2531
  }
@@ -2440,6 +2559,14 @@ export interface TeamMember {
2440
2559
  * `full`: unrestricted filesystem access (same as the main agent).
2441
2560
  */
2442
2561
  workspaceAccess?: 'workspace' | 'full';
2562
+ /**
2563
+ * Typed reference to this member's execution target (saved agent profile or
2564
+ * config-scoped model). Runtime resolution prefers it over the legacy
2565
+ * by-value model fields when present.
2566
+ */
2567
+ targetRef?: AgentTargetRef;
2568
+ /** Core-tool whitelist for this member. Absent → the squad's default toolset. */
2569
+ allowedTools?: string[];
2443
2570
  }
2444
2571
  export interface TeamReviewEdge {
2445
2572
  /** Reviewer member id/name/role. */
@@ -2481,6 +2608,14 @@ export interface TeamGraphNode extends Omit<TeamMember, 'model'> {
2481
2608
  type?: 'react' | 'single' | 'team';
2482
2609
  /** When `type === 'team'`, name of the persisted team definition to invoke. */
2483
2610
  teamRef?: string;
2611
+ /**
2612
+ * Typed reference to this node's execution target. Lazy migration on load
2613
+ * turns `type: 'team'` + `teamRef` into `{ kind: 'team', name: teamRef }`;
2614
+ * nodes with only a raw `model` keep `targetRef` absent (the legacy by-value
2615
+ * fields remain the fallback) since the originating config is not knowable.
2616
+ * Runtime resolution prefers `targetRef` when present.
2617
+ */
2618
+ targetRef?: AgentTargetRef;
2484
2619
  /** Return ports only — `void` (return 0) or structured `payload`. */
2485
2620
  returnMode?: TeamGraphReturnMode;
2486
2621
  /** Return ports in `payload` mode — template for the structured return value. */
@@ -2594,9 +2729,10 @@ export interface TeamDefinition {
2594
2729
  * Squad kind — drives which editor the GUI shows. Absent → 'graph' (back-compat).
2595
2730
  * - `graph`: collaboration graph (Task → agents → Return), the existing editor.
2596
2731
  * - `workflow`: linear/tree work-flow node editor (Phase 3 — visual work tree).
2597
- * - `subagent`: a single configured agent (prompt + tools + workspace + runtime).
2732
+ * - `agent`: a single configured agent (prompt + tools + workspace + runtime).
2733
+ * - `subagent`: legacy alias of `agent` (still accepted when loading).
2598
2734
  */
2599
- squadType?: 'graph' | 'workflow' | 'subagent';
2735
+ squadType?: 'graph' | 'workflow' | 'agent' | 'subagent';
2600
2736
  /** Workflow squad only: the execution tree. */
2601
2737
  workflowTree?: WorkflowNode;
2602
2738
  /** Panel members (panel-analysis / its `panel`+`analysis` aliases). */
@@ -2716,6 +2852,11 @@ export interface TeamAskOptions {
2716
2852
  context?: string;
2717
2853
  /** Working directory the team members operate over. */
2718
2854
  workDir?: string;
2855
+ /** Hadamard data root input for personal Agents/configs/teams. */
2856
+ homeDir?: string;
2857
+ /** Caller model/client used by inherit-session-model Agent targets. */
2858
+ model?: string;
2859
+ modelApi?: ModelApi;
2719
2860
  /** Receives progress events as the team deliberates. */
2720
2861
  onEvent?: (event: TeamEvent) => void;
2721
2862
  /** Permission policy inherited by every member runtime. Defaults to `default`, never bypass. */
@@ -2730,6 +2871,8 @@ export interface TeamAskOptions {
2730
2871
  * appends its own ref before invoking the sub-team.
2731
2872
  */
2732
2873
  teamStack?: string[];
2874
+ /** Maximum Graph/Workflow definitions allowed in one nested execution chain. Defaults to 16. */
2875
+ maxTeamNestingDepth?: number;
2733
2876
  }
2734
2877
  export interface TeamResult {
2735
2878
  answer: string;
@@ -2772,6 +2915,10 @@ export interface GraphTeamResult extends TeamResult {
2772
2915
  /** Convergence loop rounds (v3 graphs with loop edges). */
2773
2916
  graphRounds?: number;
2774
2917
  }
2918
+ /** `workflow` mode result. It retains the common graph-era report/status shape for API compatibility. */
2919
+ export interface WorkflowTeamResult extends Omit<GraphTeamResult, 'mode'> {
2920
+ mode: 'workflow';
2921
+ }
2775
2922
  /** @deprecated Runtime always returns {@link GraphTeamResult}. Kept for type compatibility. */
2776
2923
  export type ReviewerResult = GraphTeamResult & {
2777
2924
  report?: string;
@@ -2781,7 +2928,7 @@ export type ReviewerResult = GraphTeamResult & {
2781
2928
  export type AnalysisResult = GraphTeamResult & {
2782
2929
  rounds?: number;
2783
2930
  };
2784
- export type ModelTeamResult = GraphTeamResult;
2931
+ export type ModelTeamResult = GraphTeamResult | WorkflowTeamResult;
2785
2932
  /** A model target: a model id plus optional per-target provider config. */
2786
2933
  export interface RouterModelRef {
2787
2934
  model: string;
@@ -2801,6 +2948,16 @@ export interface RouterRoute extends RouterModelRef {
2801
2948
  role?: string;
2802
2949
  /** Optional richer description of the specialist's strengths, for the leader to weigh. */
2803
2950
  description?: string;
2951
+ /** Preferred effort for this route's run; omit to keep session/default effort. */
2952
+ effort?: HadamardRunEffort;
2953
+ /**
2954
+ * Typed execution target for this route. Lazily migrated on load from the
2955
+ * legacy by-value fields: a route whose role/name matches a saved agent
2956
+ * profile becomes `{ kind: 'agent', name }`; a model-only route becomes
2957
+ * `{ kind: 'model', config: '', model }` (empty config = raw legacy model
2958
+ * ref). Saves always write `target` while keeping the legacy fields.
2959
+ */
2960
+ target?: AgentTargetRef;
2804
2961
  }
2805
2962
  /**
2806
2963
  * A router profile = a Leader/Dispatch configuration under `/model`. The
@@ -2814,10 +2971,18 @@ export interface RouterProfile {
2814
2971
  description?: string;
2815
2972
  /** The leader: classifies each turn and dispatches it to a specialist route. */
2816
2973
  routerModel: RouterModelRef;
2974
+ /** Typed identity for the leader's model configuration. */
2975
+ routerModelTarget?: AgentTargetRef;
2817
2976
  /** The specialist roster the leader dispatches among. */
2818
2977
  routes: RouterRoute[];
2819
2978
  /** Used when the leader matches no route. Defaults to the first route. */
2820
2979
  fallback?: RouterModelRef;
2980
+ /**
2981
+ * Typed fallback target (allows fallback to a saved agent). Lazily migrated
2982
+ * on load from the legacy `fallback` model ref; `fallback` is kept as the
2983
+ * legacy by-value copy for back-compat.
2984
+ */
2985
+ fallbackTarget?: AgentTargetRef;
2821
2986
  /** Optional custom leader/dispatch-prompt prefix. */
2822
2987
  classificationPrompt?: string;
2823
2988
  }
@@ -2831,6 +2996,8 @@ export interface RouterDecision {
2831
2996
  classification: string;
2832
2997
  /** Whether the classifier matched a configured route (vs fell back). */
2833
2998
  matched: boolean;
2999
+ /** The matched route's preferred effort (routes only; fallback carries none). */
3000
+ effort?: HadamardRunEffort;
2834
3001
  }
2835
3002
  export interface ModelPricing {
2836
3003
  input: number;