@andorra-labs/code 0.1.9 → 0.1.11

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 (212) hide show
  1. package/README.md +28 -208
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/dist/src/agent-execution.js +56 -0
  4. package/dist/src/app-server/protocol.d.ts +109 -1
  5. package/dist/src/app-server/protocol.js +8 -1
  6. package/dist/src/app-server.d.ts +59 -1
  7. package/dist/src/app-server.js +418 -63
  8. package/dist/src/auth/index.d.ts +1 -1
  9. package/dist/src/auth/index.js +1 -1
  10. package/dist/src/auth/store.d.ts +17 -1
  11. package/dist/src/auth/store.js +25 -2
  12. package/dist/src/automation-service.js +1 -1
  13. package/dist/src/browser-session.d.ts +8 -0
  14. package/dist/src/browser-session.js +27 -1
  15. package/dist/src/browser-ui/app.js +255 -33
  16. package/dist/src/browser-ui/index.html +9 -9
  17. package/dist/src/browser-ui/style.css +110 -65
  18. package/dist/src/browser-ui/tokens.css +27 -26
  19. package/dist/src/cli.js +10 -5
  20. package/dist/src/coding-tools.d.ts +24 -0
  21. package/dist/src/coding-tools.js +71 -8
  22. package/dist/src/command-screens.js +1 -1
  23. package/dist/src/commands.d.ts +1 -1
  24. package/dist/src/commands.js +2 -2
  25. package/dist/src/completion-gates.d.ts +42 -7
  26. package/dist/src/completion-gates.js +55 -9
  27. package/dist/src/completion.d.ts +9 -1
  28. package/dist/src/completion.js +20 -2
  29. package/dist/src/dashboard-view.js +2 -2
  30. package/dist/src/deadline.js +4 -0
  31. package/dist/src/decision/checks.js +1 -1
  32. package/dist/src/file-diff.d.ts +105 -0
  33. package/dist/src/file-diff.js +244 -0
  34. package/dist/src/graph-manager-chat.js +4 -4
  35. package/dist/src/graph-runner.js +39 -2
  36. package/dist/src/graph-sync.d.ts +8 -0
  37. package/dist/src/graph-sync.js +54 -3
  38. package/dist/src/graph-tool.js +1 -1
  39. package/dist/src/graph-ui/app.js +303 -129
  40. package/dist/src/graph-ui/controls.css +43 -22
  41. package/dist/src/graph-ui/controls.js +31 -1
  42. package/dist/src/graph-ui/embed.js +56 -7
  43. package/dist/src/graph-ui/icons.js +5 -0
  44. package/dist/src/graph-ui/index.html +3 -3
  45. package/dist/src/graph-ui/manager-state.js +2 -2
  46. package/dist/src/graph-ui/manager.css +19 -18
  47. package/dist/src/graph-ui/manager.js +5 -5
  48. package/dist/src/graph-ui/skill-picker.js +5 -5
  49. package/dist/src/graph-ui/studio-canvas.js +16 -16
  50. package/dist/src/graph-ui/studio.css +18 -15
  51. package/dist/src/graph-ui/studio.js +99 -42
  52. package/dist/src/graph-ui/style.css +125 -80
  53. package/dist/src/graph-ui/theme.js +2 -2
  54. package/dist/src/graph-ui/tokens.css +33 -29
  55. package/dist/src/graphs.d.ts +10 -3
  56. package/dist/src/graphs.js +15 -4
  57. package/dist/src/mcp.d.ts +75 -0
  58. package/dist/src/mcp.js +240 -8
  59. package/dist/src/membership-errors.d.ts +7 -1
  60. package/dist/src/membership-errors.js +9 -3
  61. package/dist/src/provider-keys.d.ts +5 -1
  62. package/dist/src/provider-keys.js +7 -3
  63. package/dist/src/provider-settings.d.ts +4 -1
  64. package/dist/src/provider-settings.js +46 -5
  65. package/dist/src/pull-requests.d.ts +42 -6
  66. package/dist/src/pull-requests.js +11 -3
  67. package/dist/src/qa/guidance.js +6 -19
  68. package/dist/src/qa/index.d.ts +0 -2
  69. package/dist/src/qa/index.js +0 -2
  70. package/dist/src/qa/profile/QaProfile.d.ts +5 -1
  71. package/dist/src/qa/profile/QaProfile.js +6 -2
  72. package/dist/src/qa/tools.d.ts +19 -1
  73. package/dist/src/qa/tools.js +20 -145
  74. package/dist/src/react-runtime.js +134 -16
  75. package/dist/src/read-document-doc.d.ts +20 -0
  76. package/dist/src/read-document-doc.js +524 -0
  77. package/dist/src/read-document-docx.d.ts +21 -0
  78. package/dist/src/read-document-docx.js +584 -0
  79. package/dist/src/read-document-text.d.ts +29 -0
  80. package/dist/src/read-document-text.js +67 -0
  81. package/dist/src/read-document-tool.d.ts +48 -0
  82. package/dist/src/read-document-tool.js +162 -0
  83. package/dist/src/read-document.d.ts +78 -0
  84. package/dist/src/read-document.js +353 -0
  85. package/dist/src/read-image.d.ts +29 -2
  86. package/dist/src/read-image.js +42 -17
  87. package/dist/src/remote/engine-pool.js +18 -6
  88. package/dist/src/runtime.d.ts +19 -0
  89. package/dist/src/runtime.js +10 -1
  90. package/dist/src/screen-selection.d.ts +38 -0
  91. package/dist/src/screen-selection.js +103 -0
  92. package/dist/src/session-changes.d.ts +122 -0
  93. package/dist/src/session-changes.js +804 -0
  94. package/dist/src/side-panel.d.ts +6 -1
  95. package/dist/src/side-panel.js +12 -10
  96. package/dist/src/skills/bundled/create-skill/SKILL.md +1 -1
  97. package/dist/src/skills/bundled/diagram/SKILL.md +1 -1
  98. package/dist/src/skills/bundled/graph-manager/SKILL.md +37 -3
  99. package/dist/src/skills/bundled/graph-manager/patterns.md +27 -0
  100. package/dist/src/skills/bundled/provenance.json +4 -4
  101. package/dist/src/skills/runtime-skills.js +3 -3
  102. package/dist/src/stall-recovery.d.ts +15 -0
  103. package/dist/src/stall-recovery.js +17 -0
  104. package/dist/src/telemetry/schema.d.ts +1 -1
  105. package/dist/src/telemetry/schema.js +1 -2
  106. package/dist/src/terminal-ui.d.ts +64 -20
  107. package/dist/src/terminal-ui.js +312 -82
  108. package/dist/src/time-limit.d.ts +53 -0
  109. package/dist/src/time-limit.js +79 -0
  110. package/dist/src/tool-diff-stats.d.ts +9 -0
  111. package/dist/src/tool-diff-stats.js +20 -0
  112. package/dist/src/tool-names.d.ts +1 -1
  113. package/dist/src/tool-result-filter.js +1 -1
  114. package/dist/src/tools.js +118 -9
  115. package/dist/src/transcript.d.ts +11 -0
  116. package/dist/src/transcript.js +15 -3
  117. package/dist/src/types.d.ts +12 -0
  118. package/dist/src/usage-analytics.d.ts +3 -1
  119. package/dist/src/usage-analytics.js +16 -2
  120. package/package.json +6 -26
  121. package/dist/src/qa/api/http-runner.d.ts +0 -3
  122. package/dist/src/qa/api/http-runner.js +0 -47
  123. package/dist/src/qa/git/ChangeDetector.d.ts +0 -26
  124. package/dist/src/qa/git/ChangeDetector.js +0 -177
  125. package/dist/src/qa/git/DiffReviewer.d.ts +0 -28
  126. package/dist/src/qa/git/DiffReviewer.js +0 -115
  127. package/dist/src/qa/orchestrator/ChangeClassifier.d.ts +0 -14
  128. package/dist/src/qa/orchestrator/ChangeClassifier.js +0 -28
  129. package/dist/src/qa/orchestrator/MergeGate.d.ts +0 -14
  130. package/dist/src/qa/orchestrator/MergeGate.js +0 -40
  131. package/dist/src/qa/orchestrator/QaOrchestrator.d.ts +0 -79
  132. package/dist/src/qa/orchestrator/QaOrchestrator.js +0 -373
  133. package/dist/src/qa/runners/CommandRunner.d.ts +0 -22
  134. package/dist/src/qa/runners/CommandRunner.js +0 -96
  135. package/dist/src/qa/runners/TestRunner.d.ts +0 -21
  136. package/dist/src/qa/runners/TestRunner.js +0 -66
  137. package/dist/src/qa/runtime/RuntimeSmoke.d.ts +0 -11
  138. package/dist/src/qa/runtime/RuntimeSmoke.js +0 -78
  139. package/dist/src/qa/runtime-detect.d.ts +0 -10
  140. package/dist/src/qa/runtime-detect.js +0 -72
  141. package/dist/src/qa/security/DependencyScanner.d.ts +0 -19
  142. package/dist/src/qa/security/DependencyScanner.js +0 -167
  143. package/dist/src/qa/security/SecretScanner.d.ts +0 -3
  144. package/dist/src/qa/security/SecretScanner.js +0 -55
  145. package/docs/README.md +0 -36
  146. package/docs/agents/README.md +0 -62
  147. package/docs/agents/install-for-agents.md +0 -56
  148. package/docs/agents/mcp-server.md +0 -212
  149. package/docs/agents/subagent-mode.md +0 -149
  150. package/docs/concepts/README.md +0 -47
  151. package/docs/concepts/jev-actionable-routing.md +0 -113
  152. package/docs/concepts/jev-decision-thresholds.md +0 -412
  153. package/docs/concepts/jev-efficiency.md +0 -217
  154. package/docs/concepts/jev-eval-2026-11-01.md +0 -78
  155. package/docs/concepts/limits.md +0 -52
  156. package/docs/concepts/memory.md +0 -10
  157. package/docs/concepts/security.md +0 -50
  158. package/docs/concepts/workspace-instructions.md +0 -29
  159. package/docs/getting-started/README.md +0 -82
  160. package/docs/getting-started/accounts.md +0 -78
  161. package/docs/getting-started/configure-providers.md +0 -132
  162. package/docs/guides/README.md +0 -13
  163. package/docs/guides/browser.md +0 -39
  164. package/docs/guides/desktop-app.md +0 -414
  165. package/docs/guides/extensions.md +0 -102
  166. package/docs/guides/graph-builder.md +0 -116
  167. package/docs/guides/headless.md +0 -46
  168. package/docs/guides/tui.md +0 -75
  169. package/docs/guides/update.md +0 -70
  170. package/docs/guides/web-search.md +0 -51
  171. package/docs/guides/windows-code-signing.md +0 -319
  172. package/docs/llms.txt +0 -45
  173. package/docs/reference/README.md +0 -7
  174. package/docs/reference/cli.md +0 -76
  175. package/docs/reference/config.md +0 -91
  176. package/docs/reference/slash-commands.md +0 -59
  177. package/docs/superpowers/plans/2026-11-01-claude-console-sign-in.md +0 -111
  178. package/docs/superpowers/plans/2026-11-01-jev-node-opt-in.md +0 -910
  179. package/docs/superpowers/plans/2026-11-02-workflow-pane.md +0 -398
  180. package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +0 -125
  181. package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +0 -295
  182. package/docs/superpowers/plans/2026-11-13-graph-manager-chat.md +0 -203
  183. package/docs/superpowers/plans/2026-11-14-jev-fair-use-pricing.md +0 -79
  184. package/docs/superpowers/specs/2026-10-31-work-line-summary-design.md +0 -50
  185. package/docs/superpowers/specs/2026-11-01-claude-console-sign-in-design.md +0 -176
  186. package/docs/superpowers/specs/2026-11-01-jev-node-opt-in-design.md +0 -164
  187. package/docs/superpowers/specs/2026-11-01-pr-section-design.md +0 -111
  188. package/docs/superpowers/specs/2026-11-02-workflow-pane-design.md +0 -130
  189. package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +0 -206
  190. package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +0 -291
  191. package/docs/superpowers/specs/2026-11-13-graph-manager-chat-design.md +0 -182
  192. package/docs/superpowers/specs/2026-11-14-jev-fair-use-pricing-design.md +0 -156
  193. package/scripts/jev-efficiency-eval.mjs +0 -187
  194. package/scripts/jev-efficiency-live.mjs +0 -193
  195. package/scripts/zcode-engine-replay.mjs +0 -223
  196. package/tests/agent-centric-mcp-test-plan.md +0 -208
  197. package/tests/analytics-settings-test-plan.md +0 -165
  198. package/tests/browser-cli-smoke.mjs +0 -276
  199. package/tests/browser-test-plan.md +0 -280
  200. package/tests/chat-side-panel-test-plan.md +0 -309
  201. package/tests/decision-engine-test-plan.md +0 -163
  202. package/tests/default-active-jev-test-plan.md +0 -85
  203. package/tests/harness-extensions-test-plan.md +0 -113
  204. package/tests/jev-all-decisions-test-plan.md +0 -156
  205. package/tests/jev-efficiency/criteria.json +0 -158
  206. package/tests/jev-efficiency/workloads.mjs +0 -242
  207. package/tests/jev-efficiency-test-plan.md +0 -198
  208. package/tests/permissions-sandbox-probe.mjs +0 -74
  209. package/tests/permissions-test-plan.md +0 -191
  210. package/tests/product-telemetry-test-plan.md +0 -536
  211. package/tests/thinking-stream-preview-test-plan.md +0 -136
  212. package/tests/zcode-react-engine-test-plan.md +0 -396
@@ -13,7 +13,7 @@
13
13
  /* Measurements. The row is the Siderail row everywhere: 28px tall, 6px radius, 13px type. */
14
14
  --rail-width: 232px; /* written live by RailResizeHandle while the edge is dragged */
15
15
  --chrome-height: 36px; /* every title strip */
16
- --reading-measure: 720px; /* the prose column */
16
+ --reading-measure: 792px; /* the prose column */
17
17
  --settings-measure: 880px; /* every settings page: one column, one left edge */
18
18
  --row-height: 28px;
19
19
  --row-radius: 6px;
@@ -21,14 +21,13 @@
21
21
  --btn-height: 32px; /* the primary/soft button */
22
22
  --btn-radius: 8px;
23
23
  --card-radius: 12px;
24
- --setting-row-height: 52px; /* a Settings row: a title over its one-line description */
25
24
  /* The radius scale. Every corner takes one of these steps, and a corner inside another is the
26
25
  outer step minus the padding between them, floored at the next step down: 4 for badges, menu
27
26
  rows and inline code, 6 for rows, 28px buttons and icon buttons, 8 for 32px buttons, fields,
28
27
  code blocks and menus, 12 for cards and dialogs, 20 for the composer (the one large rounded
29
28
  object), and full for dots, avatars, switches and status pills. The --row/--btn/--input/--card
30
29
  radii above are positions on it. */
31
- --radius-xs: 4px; --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px; --radius-full: 999px;
30
+ --radius-xs: 4px; --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-full: 999px;
32
31
  --radius-composer: 20px;
33
32
 
34
33
  --font-ui: "Geist Sans", "Geist", -apple-system, "SF Pro Text", system-ui, sans-serif;
@@ -39,10 +38,15 @@
39
38
  --type-label: 12px;
40
39
  --type-section: 15px;
41
40
  --type-hint: 12px;
41
+ --type-h1: 17px; /* a message's top heading (D2): one step between the prose and the page title */
42
42
  --weight-regular: 400; --weight-strong: 500;
43
- /* Leading and tracking, one value per size: 12px on 16, 13px on 18, prose 14px on 22. 13px type is
44
- tracked in by a hair (−0.08px), the way the platform faces set their text size. */
45
- --leading-xs: 16px; --leading-sm: 18px; --leading-prose: 22px; --leading-code: 1.55;
43
+ /* Leading and tracking, one value per size, every line on the 2px grid: 12px on 16, 13px on 18,
44
+ 14–15px headings and titles on 20, prose 14px on 22, the 17px heading and 20px titles on 24, and
45
+ 12px code on 18. 13px type is tracked in by a hair (−0.08px), the way the platform faces set their
46
+ text size; a title is tracked in by a hundredth of its size, and a code meant to be read out (a
47
+ sign-in code) is spaced out. */
48
+ --leading-xs: 16px; --leading-sm: 18px; --leading-md: 20px; --leading-prose: 22px; --leading-lg: 24px;
49
+ --leading-code: 18px;
46
50
  --tracking-sm: -0.08px; --tracking-title: -0.01em; --tracking-code: .06em;
47
51
  /* A message is the one thing the window is read for at length, so its prose takes one step up
48
52
  from the row size. The body is regular 400; a heading is 600 and a bold term 500. A bold term is
@@ -81,9 +85,11 @@
81
85
  --hover: color-mix(in srgb, var(--text) 7%, transparent);
82
86
  --selected: color-mix(in srgb, var(--text) 12%, transparent);
83
87
  --bg-hover: var(--hover);
84
- /* The neutral accent: the send button, the caret, a checked checkbox, a field's focus halo. */
88
+ /* The neutral accent: the send button, the caret, a checked checkbox, a field's focus halo. The halo
89
+ is a focus indicator, so it keeps 3:1 against the ground it sits on (WCAG 1.4.11): the ink at 36%
90
+ here, 48% in light (P-IXD-16). */
85
91
  --accent: #ececec; --accent-soft: rgba(245,245,245,.16); --on-accent: #141414;
86
- --accent-hover: #ffffff; --accent-ring: rgba(245,245,245,.22);
92
+ --accent-hover: #ffffff; --accent-ring: rgba(245,245,245,.36);
87
93
  /* The one hue in the chrome: the primary button's fill, keyboard focus, a switch that is on, links
88
94
  and progress. Everything else is neutral, so the blue stays rare and means "the action". */
89
95
  --accent-fill: #1372da; --accent-fill-hover: #2a7fdd; --on-accent-fill: #f5f5f5;
@@ -91,13 +97,12 @@
91
97
  /* 2026-11-12: the chrome keeps no amber. --warn is the attention ink, a bright neutral: a row or
92
98
  a pill that needs its person is marked by contrast, weight and motion, never by a warning hue.
93
99
  --err is one clean red, kept for what failed and for removed lines; it is never a button. */
94
- --ok: #2f9e6a; --err: #e5484d; --warn: #c9c9c9; --you: #c9c9c9;
95
- /* Merged: the violet GitHub gives a merged pull request, the one state the three status hues above
96
- do not already name. */
97
- --merged: #8e6ee0;
100
+ --ok: #2f9e6a; --err: #e5484d; --warn: #c9c9c9;
98
101
  /* Text-safe status variants: --ok/--err/--warn are the dot and border colours the Siderail
99
102
  language defines, and at small text sizes they fall short of 4.5:1 on these surfaces. Any use
100
103
  of a status colour as foreground text takes the -text variant instead. */
104
+ /* Merged is the violet GitHub gives a merged pull request, the one state the hues above do not
105
+ already name; it only ever shows as a pill's word on its wash, so it has no dot ink. */
101
106
  --ok-text: #7cc79a; --err-text: #f47174; --warn-text: #ececec; --merged-text: #bba4f2;
102
107
  /* A picked skill in the composer. It is content the person typed, not chrome, and it has to read as
103
108
  recognised at a glance, so it carries the one hue outside status and the accent (see ADR 0022).
@@ -106,7 +111,6 @@
106
111
  /* A status pill's fill: a faint wash of its hue under the -text ink, light enough that the ink
107
112
  keeps 4.5:1 on both the card and the pane ground. */
108
113
  --ok-wash: rgba(47,158,106,.14); --err-wash: rgba(229,72,77,.14); --merged-wash: rgba(142,110,224,.14);
109
- --warn-wash: rgba(245,245,245,.10);
110
114
  --add-wash: rgba(47,158,106,.16); --del-wash: rgba(229,72,77,.16);
111
115
  --overlay: rgba(0,0,0,.5);
112
116
 
@@ -119,8 +123,6 @@
119
123
  --rail-wash: var(--hover);
120
124
  /* 2026-11-12: the rail is a flat ground. The glow and grain are kept as tokens and switched off. */
121
125
  --glow-1: transparent; --glow-2: transparent; --glow-size: 440px 380px; --grain: 0;
122
- /* The waiting update row's halo: faint at rest and brighter at its peak. */
123
- --update-glow-rest: rgba(245,245,245,.10); --update-glow-peak: rgba(245,245,245,.28);
124
126
 
125
127
  /* Elevation: one shadow per step. lift-2 under a bordered card at rest, lift-3 for the composer
126
128
  holding focus, menu for every menu and popover, panel for dialogs and toasts, raised for a chip
@@ -130,7 +132,6 @@
130
132
  --lift-3: inset 0 1px 0 rgba(255,255,255,.07), 0 2px 4px rgba(0,0,0,.3), 0 18px 38px -10px rgba(0,0,0,.7);
131
133
  --shadow-menu: 0 8px 28px rgba(0,0,0,.4);
132
134
  --shadow-panel: var(--shadow-menu);
133
- --shadow-lift: var(--shadow-menu); /* kept for the graph editor's copy; unused here */
134
135
  --shadow-raised: 0 1px 2px rgba(0,0,0,.32);
135
136
  --shadow-knob: 0 1px 2px rgba(0,0,0,.4);
136
137
 
@@ -143,14 +144,16 @@
143
144
  the app is idle: the spinner turns only while work runs. */
144
145
  /* 2026-11-12: quick and soft, with no overshoot. Row hover arrives and leaves at once; popovers
145
146
  and rows take --dur-2, dialogs and view changes --dur-3, height --dur-4. */
146
- --dur-0: 80ms; --dur-1: 120ms; --dur-2: 160ms; --dur-3: 200ms; --dur-4: 240ms; --stagger: 40ms;
147
+ --dur-0: 80ms; --dur-1: 120ms; --dur-2: 160ms; --dur-3: 200ms; --dur-4: 240ms;
147
148
  --ease-standard: cubic-bezier(.2,.8,.2,1);
148
149
  --ease-out: var(--ease-standard);
149
150
  --ease-in-out: cubic-bezier(.65,0,.35,1);
150
151
  --ease-exit: cubic-bezier(.4,0,1,1);
151
- --ease-settle: var(--ease-standard); /* kept for the graph editor's copy; unused here */
152
152
  --pop-distance: 4px; --pop-scale: .98;
153
153
  --loop-spin: 1s; --loop-shimmer: 1.8s; --loop-breathe: 2.4s;
154
+ /* How long the pointer rests on a quiet affordance (the sidebar's sash) before it lights, so a pointer
155
+ only crossing it lights nothing. */
156
+ --delay-hover-intent: 150ms;
154
157
 
155
158
  color-scheme: dark;
156
159
  }
@@ -169,17 +172,17 @@
169
172
  --bg-raised: #ffffff;
170
173
  --switch-off: color-mix(in srgb, var(--text) 50%, transparent);
171
174
  --accent: #1c1c1c; --accent-soft: rgba(28,28,28,.16); --on-accent: #ffffff;
172
- --accent-hover: #333333; --accent-ring: rgba(28,28,28,.16);
175
+ --accent-hover: #333333; --accent-ring: rgba(28,28,28,.48);
173
176
  --accent-fill: #1680f3; --accent-fill-hover: #1776dd; --on-accent-fill: #ffffff;
174
177
  --accent-text: #0b6dd3; --focus: #1680f3;
175
- --ok: #3d7a5c; --err: #d13438; --warn: #45464b; --you: #45464b;
176
- /* No merged ink in the source palette; this violet is in the key of its pass and fail inks. */
177
- --merged: #6a4fc4;
178
- --ok-text: #3d7a5c; --err-text: #c4262e; --warn-text: #1c1c1c; --merged-text: #6a4fc4;
178
+ --ok: #3d7a5c; --err: #d13438; --warn: #45464b;
179
+ /* The pass word is a step darker than its dot: on the add wash an added line's "+" needs 4.5:1
180
+ (4.88:1 here, P-IXD-15). No merged ink in the source palette; this violet is in the key of the
181
+ pass and fail inks. */
182
+ --ok-text: #36704f; --err-text: #c4262e; --warn-text: #1c1c1c; --merged-text: #6a4fc4;
179
183
  --skill: #3b4fc4; --skill-wash: rgba(59,79,196,.10);
180
184
  /* Fainter than the dark washes: at .14 the pass ink on its own wash drops under 4.5:1. */
181
185
  --ok-wash: rgba(61,122,92,.08); --err-wash: rgba(209,52,56,.08); --merged-wash: rgba(106,79,196,.08);
182
- --warn-wash: rgba(28,28,28,.06);
183
186
  /* A removed line has to be found beside an added one: at .08 it was all but white. At .13 the
184
187
  fail ink still keeps 5:1 on it. */
185
188
  --add-wash: rgba(61,122,92,.14); --del-wash: rgba(209,52,56,.13);
@@ -189,13 +192,11 @@
189
192
  --code-fn: #795e26; --code-var: #001080; --code-type: #267f99; --code-meta: #af00db;
190
193
 
191
194
  --glow-1: transparent; --glow-2: transparent; --glow-size: 480px 420px; --grain: 0;
192
- --update-glow-rest: rgba(28,28,28,.08); --update-glow-peak: rgba(28,28,28,.20);
193
195
 
194
196
  --lift-2: 0 1px 2px rgba(16,18,24,.04), 0 6px 24px rgba(16,18,24,.07);
195
197
  --lift-3: 0 1px 2px rgba(16,18,24,.05), 0 6px 24px rgba(16,18,24,.085);
196
198
  --shadow-menu: 0 2px 4px rgba(16,18,24,.05), 0 8px 20px rgba(16,18,24,.07), 0 24px 48px rgba(16,18,24,.07);
197
199
  --shadow-panel: var(--shadow-menu);
198
- --shadow-lift: var(--shadow-menu);
199
200
  --shadow-raised: 0 1px 2px rgba(16,18,24,.12), 0 0 0 .5px rgba(16,18,24,.06);
200
201
  --shadow-knob: 0 1px 2px rgba(16,18,24,.3);
201
202
 
@@ -243,11 +244,14 @@
243
244
  :root {
244
245
  --panel: 380px; /* the node inspector's width; the edge drag keeps it between 360 and 720 */
245
246
 
246
- /* The canvas: the pane's own ground, and the dot of the grid that marks every snap point. */
247
+ /* The canvas: the pane's own ground, and the dot of the grid that marks every snap point. The dot is
248
+ the ink at a fixed share of the ground (ADR 0022, A2: every grey is one ink at an alpha), so it is
249
+ a pure neutral in either appearance; light takes a slightly larger share to keep the grid as
250
+ visible on white as it is on the dark pane. */
247
251
  --canvas-bg: var(--bg-surface);
248
- --canvas-dot: #2f2f36;
252
+ --canvas-dot: color-mix(in srgb, var(--text) 12%, var(--canvas-bg));
249
253
  }
250
254
 
251
255
  :root[data-theme='light'] {
252
- --canvas-dot: #e0e0e3;
256
+ --canvas-dot: color-mix(in srgb, var(--text) 14%, var(--canvas-bg));
253
257
  }
@@ -177,9 +177,15 @@ export interface Graph {
177
177
  [key: string]: unknown;
178
178
  };
179
179
  }
180
- export declare const GRAPH_TOOLS: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "NativeExec", "AsyncProcess", "PowerShellFast", "ShellMetrics", "read_file", "list_files", "search_files", "write_file", "edit_file", "read", "write", "edit", "find", "grep", "ls", "powershell", "bash", "shell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "graphs", "qa.inspect_project", "qa.status", "qa.fast", "qa.deep", "qa.test", "qa.terminal", "qa.security", "qa.browser", "qa.browser_session", "browser.solve_captcha", "web_search", "read_skill_resource", "browser.panel", "browser.incognito"];
180
+ export declare const GRAPH_TOOLS: readonly ["Read", "Write", "Edit", "Glob", "Grep", "Bash", "PowerShell", "NativeExec", "AsyncProcess", "PowerShellFast", "ShellMetrics", "read_file", "list_files", "search_files", "write_file", "edit_file", "read", "write", "edit", "find", "grep", "ls", "powershell", "bash", "shell", "git_read", "read_artifact", "write_artifact", "repo_explore", "memory_search", "set_timer", "pull_request", "graphs", "qa.terminal", "qa.browser", "qa.browser_session", "browser.solve_captcha", "web_search", "read_skill_resource", "browser.panel", "browser.incognito"];
181
181
  /** QA tool names are an explicit allowlist; gating keys off membership, never a name prefix. */
182
182
  export declare const QA_TOOL_NAMES: readonly string[];
183
+ /**
184
+ * The QA check pipeline, removed: these tools ran lint, tests and a merge gate that the agent's
185
+ * own shell commands already cover, at about two extra requests per run. A saved graph may still
186
+ * list them in a node's tools; they are dropped on load instead of failing the graph.
187
+ */
188
+ export declare const RETIRED_GRAPH_TOOLS: ReadonlySet<string>;
183
189
  export declare const isQaToolName: (name: string) => boolean;
184
190
  export declare const LEGACY_DEFAULT_HARNESS: Graph;
185
191
  /** The intake role is configuration for the shared executor, not a separate runtime. */
@@ -241,8 +247,9 @@ export declare const GRAPH_MANAGER_GRAPH_ID = "andorra-graph-manager";
241
247
  * sets neither `capabilities` nor `tools`, exactly as the default graph's execution agent: the
242
248
  * defaults allow the shell, which is what grants the `graphs` tool, and filesystem reads, which
243
249
  * grant `read_skill_resource`. A delegated subagent never receives `graphs`, so the work stays on
244
- * this node. Only an Orchestrator is given `ask_user`, so the agent asks in its reply and the user's
245
- * next message is the answer; the node keeps session history so that message sees the question.
250
+ * this node. Its instruction has the agent ask in its reply, with the user's next message as the
251
+ * answer, and the node keeps session history so that message sees the question; as a top-level
252
+ * agent it is also offered `ask_user` wherever a person can answer.
246
253
  */
247
254
  export declare const GRAPH_MANAGER_HARNESS: Graph;
248
255
  /**
@@ -6,9 +6,15 @@ import { acquireSaveLock, archiveUnpublishedSnapshot, removeLockedFolder, SaveLo
6
6
  import { validateMappingConstants, validateMappings, validateSchema, validateValue, schemaAt, nodeOutputSchema } from './handoffs.js';
7
7
  import { CANONICAL_CODING_TOOLS, canonicalToolName, canonicalizeToolList, toolNameMatches } from './tool-names.js';
8
8
  import { DEFAULT_AGENT_GRAPH } from './default-graph.js';
9
- export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'graphs', 'qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'web_search', 'read_skill_resource', 'browser.panel', 'browser.incognito'];
9
+ export const GRAPH_TOOLS = [...CANONICAL_CODING_TOOLS, 'NativeExec', 'AsyncProcess', 'PowerShellFast', 'ShellMetrics', 'read_file', 'list_files', 'search_files', 'write_file', 'edit_file', 'read', 'write', 'edit', 'find', 'grep', 'ls', 'powershell', 'bash', 'shell', 'git_read', 'read_artifact', 'write_artifact', 'repo_explore', 'memory_search', 'set_timer', 'pull_request', 'graphs', 'qa.terminal', 'qa.browser', 'qa.browser_session', 'browser.solve_captcha', 'web_search', 'read_skill_resource', 'browser.panel', 'browser.incognito'];
10
10
  /** QA tool names are an explicit allowlist; gating keys off membership, never a name prefix. */
11
- export const QA_TOOL_NAMES = ['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.terminal', 'qa.security', 'qa.browser'];
11
+ export const QA_TOOL_NAMES = ['qa.terminal', 'qa.browser'];
12
+ /**
13
+ * The QA check pipeline, removed: these tools ran lint, tests and a merge gate that the agent's
14
+ * own shell commands already cover, at about two extra requests per run. A saved graph may still
15
+ * list them in a node's tools; they are dropped on load instead of failing the graph.
16
+ */
17
+ export const RETIRED_GRAPH_TOOLS = new Set(['qa.inspect_project', 'qa.status', 'qa.fast', 'qa.deep', 'qa.test', 'qa.security']);
12
18
  export const isQaToolName = (name) => QA_TOOL_NAMES.includes(name);
13
19
  export const LEGACY_DEFAULT_HARNESS = {
14
20
  schemaVersion: 1, id: 'default', name: 'Software Engineer', revision: 1, entry: 'engineer',
@@ -120,8 +126,9 @@ export const GRAPH_MANAGER_GRAPH_ID = 'andorra-graph-manager';
120
126
  * sets neither `capabilities` nor `tools`, exactly as the default graph's execution agent: the
121
127
  * defaults allow the shell, which is what grants the `graphs` tool, and filesystem reads, which
122
128
  * grant `read_skill_resource`. A delegated subagent never receives `graphs`, so the work stays on
123
- * this node. Only an Orchestrator is given `ask_user`, so the agent asks in its reply and the user's
124
- * next message is the answer; the node keeps session history so that message sees the question.
129
+ * this node. Its instruction has the agent ask in its reply, with the user's next message as the
130
+ * answer, and the node keeps session history so that message sees the question; as a top-level
131
+ * agent it is also offered `ask_user` wherever a person can answer.
125
132
  */
126
133
  export const GRAPH_MANAGER_HARNESS = {
127
134
  schemaVersion: 3, id: GRAPH_MANAGER_GRAPH_ID, name: 'Graph Manager', revision: 1, entry: 'manager',
@@ -686,6 +693,8 @@ function validateGraphInternal(value, options = {}) {
686
693
  if (node[k] !== undefined && (typeof node[k] !== 'string' || node[k].length > 100000))
687
694
  fail(`${label}: invalid ${k}`);
688
695
  modelRef(node, label, options);
696
+ if (Array.isArray(node.tools) && node.tools.some(tool => RETIRED_GRAPH_TOOLS.has(tool)))
697
+ node.tools = node.tools.filter(tool => !RETIRED_GRAPH_TOOLS.has(tool));
689
698
  toolsValid(node.tools, label);
690
699
  bounds(node.maxIterations, `${label} maxIterations`, 1000, 0);
691
700
  if (node.maxIterations === 0)
@@ -908,6 +917,8 @@ function validateGraphInternal(value, options = {}) {
908
917
  if (r.outputSchema)
909
918
  objectSchema(r.outputSchema, `${label} role outputSchema`);
910
919
  subagentModelRef({ ...r, provider: r.provider ?? node.provider ?? options.defaultProvider }, `${label} role ${r.id}`, options);
920
+ if (Array.isArray(r.tools) && r.tools.some(tool => RETIRED_GRAPH_TOOLS.has(tool)))
921
+ r.tools = r.tools.filter(tool => !RETIRED_GRAPH_TOOLS.has(tool));
911
922
  toolsValid(r.tools, `${label} role ${r.id}`);
912
923
  if (s.context === 'task-only' && r.inputSchema?.required?.length)
913
924
  fail(`${label}: task-only context cannot supply required inputs for role ${r.id}; select selected context or make the role inputs optional`);
package/dist/src/mcp.d.ts CHANGED
@@ -42,6 +42,80 @@ export declare function mcpCatalogKey(id: string, config: RuntimeMcpServerConfig
42
42
  /** Remembered catalogs as one small file each under the configuration home. Every failure reads as "not remembered". */
43
43
  export declare function mcpCatalogStore(directory: string): McpCatalogStore;
44
44
  export declare function mcpToolName(server: string, tool: string): string;
45
+ /**
46
+ * A server definition as an edit form sent it, applied over the saved one.
47
+ *
48
+ * Environment values and header values are secrets the engine never returns, so the form cannot
49
+ * send them back: an entry whose value is `null` keeps the saved value of that name, an entry with
50
+ * a string is the new value, and a name the edit leaves out is removed. An endpoint sent without
51
+ * the query string the saved one carries (the form is shown it without, since a query can hold a
52
+ * credential) keeps the saved endpoint. The transport may change; whether the server is enabled
53
+ * does not — the switch beside it does that.
54
+ */
55
+ export declare function mergeMcpEdit(saved: McpServerConfig, edit: unknown): McpServerConfig;
56
+ /** Told how a server's connection went, by the task that made it: what the status store records. */
57
+ export type McpStatusReporter = (id: string, config: RuntimeMcpServerConfig, result: McpProbeResult) => void;
58
+ /**
59
+ * A reporter that records what a task's connections answered. A task names a server from the
60
+ * configuration `configured:<id>` (the extension snapshot's namespace, apart from plugins' servers),
61
+ * and the record is filed under the configuration's own id, which is what the settings page lists.
62
+ */
63
+ export declare function mcpTaskStatusReporter(directory: string): McpStatusReporter;
64
+ /** What a server last answered — to a task's connection or an explicit check — and when. */
65
+ export interface McpStatusRecord {
66
+ id: string;
67
+ /** The definition it answered for (`mcpDefinitionKey`): an edited server has no status yet. */
68
+ definition: string;
69
+ state: 'ready' | 'failed';
70
+ tools?: number;
71
+ error?: string;
72
+ checkedAt: string;
73
+ source: 'task' | 'check';
74
+ }
75
+ /**
76
+ * The identity of a server's definition — command, arguments, environment, address, headers — and
77
+ * not whether it is turned on, so a status survives the switch but not an edit. Credentials in the
78
+ * definition only enter the digest.
79
+ */
80
+ export declare function mcpDefinitionKey(config: RuntimeMcpServerConfig): string;
81
+ /**
82
+ * The last thing each server answered, one small file per server under the configuration home, so a
83
+ * settings page can show it without starting anything. A task's connection writes it, and so does an
84
+ * explicit check (`mcp.status`); one file per server keeps two processes recording at once from
85
+ * overwriting each other's servers. Every failure to read reads as "not checked".
86
+ */
87
+ export declare function mcpStatusStore(directory: string): {
88
+ list(): Promise<McpStatusRecord[]>;
89
+ record(id: string, config: RuntimeMcpServerConfig, result: McpProbeResult, source: McpStatusRecord['source'], at?: Date): Promise<McpStatusRecord>;
90
+ };
91
+ /** What a configured server answered when it was asked for its tools outside a task. */
92
+ export type McpProbeResult = {
93
+ state: 'ready';
94
+ tools: number;
95
+ } | {
96
+ state: 'failed';
97
+ error: string;
98
+ };
99
+ /**
100
+ * Start one configured server, list its tools, and stop it again: the check a person asks for from
101
+ * the settings page ("Check Connection"), never one a page makes on its own — a task asks before it
102
+ * connects a server, and opening a page is not that consent.
103
+ *
104
+ * Nothing is kept. The catalog is only counted, and the client — with the process it started, for a
105
+ * stdio server — is closed before this returns, whatever happened. A probe is bounded in time as a
106
+ * task's connection is: 15 seconds to connect, 15 per page of tools, 30 in all.
107
+ */
108
+ export declare function probeMcpServer(config: RuntimeMcpServerConfig, workspace: string, signal?: AbortSignal): Promise<McpProbeResult>;
109
+ /**
110
+ * Why a probe failed, in words a person can act on.
111
+ *
112
+ * A transport error can carry what the server sent back, and an HTTP one can echo the request's own
113
+ * headers, so the message itself is never passed on: the error is sorted into a known kind, and only
114
+ * the facts that are the configuration's own (its command) or the protocol's (a status code) are named.
115
+ */
116
+ export declare function probeFailureReason(error: unknown, config: Pick<McpServerConfig, 'transport'> & {
117
+ command?: string;
118
+ }): string;
45
119
  /**
46
120
  * Each task owns its clients; no server tools or spawned processes survive task exit.
47
121
  *
@@ -57,6 +131,7 @@ export declare function mcpToolName(server: string, tool: string): string;
57
131
  */
58
132
  export declare function connectMcpServers(servers: Record<string, RuntimeMcpServerConfig>, context: ToolContext, notice: (message: string) => void, taskSignal?: AbortSignal, options?: {
59
133
  catalogs?: McpCatalogStore;
134
+ status?: McpStatusReporter;
60
135
  }): Promise<{
61
136
  tools: Tool[];
62
137
  close(): Promise<void>;
package/dist/src/mcp.js CHANGED
@@ -2,7 +2,7 @@ import { Client } from '@modelcontextprotocol/sdk/client/index.js';
2
2
  import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
3
3
  import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
4
4
  import { createHash, randomUUID } from 'node:crypto';
5
- import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises';
5
+ import { mkdir, readFile, readdir, rename, rm, writeFile } from 'node:fs/promises';
6
6
  import { join } from 'node:path';
7
7
  import { authorize } from './tools.js';
8
8
  import { permissionMode, PLAN_MODE_MUTATION_ERROR } from './permissions.js';
@@ -132,6 +132,238 @@ function checkCatalogTool(id, tool, seen) {
132
132
  throw new Error('MCP tool metadata exceeds limits');
133
133
  seen.add(mcpToolName(id, tool.name));
134
134
  }
135
+ /**
136
+ * The transport one configured server is reached over.
137
+ *
138
+ * The SDK adds its minimal default environment; only the explicitly configured entries are passed,
139
+ * so unrelated provider and cloud credentials never reach an MCP process. `${NAME}` references in
140
+ * the environment and headers are expanded from this process's environment (and `${PLUGIN_ROOT}`
141
+ * from the plugin that declared the server); a reference that is not set throws.
142
+ */
143
+ function mcpTransport(config, workspace, overflow) {
144
+ const expand = (value) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => { const value = name === 'PLUGIN_ROOT' && config.pluginRoot !== undefined ? config.pluginRoot : process.env[name]; if (value === undefined)
145
+ throw new Error(MISSING_REFERENCE); return value; });
146
+ const transport = config.transport === 'stdio' ? new StdioClientTransport({ command: config.command, args: config.args, env: Object.fromEntries(Object.entries(config.env ?? {}).map(([k, v]) => [k, expand(v)])), cwd: workspace, stderr: 'pipe', maxBufferSize: MCP_RESPONSE_MAX_BYTES }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: Object.fromEntries(Object.entries(config.headers ?? {}).map(([k, v]) => [k, expand(v)])), redirect: 'error' }, fetch: (url, init) => boundedMcpFetch(url, init, overflow) });
147
+ if (transport instanceof StdioClientTransport)
148
+ transport.stderr?.on('data', () => { });
149
+ return transport;
150
+ }
151
+ const MISSING_REFERENCE = 'Missing MCP environment reference';
152
+ /**
153
+ * A server definition as an edit form sent it, applied over the saved one.
154
+ *
155
+ * Environment values and header values are secrets the engine never returns, so the form cannot
156
+ * send them back: an entry whose value is `null` keeps the saved value of that name, an entry with
157
+ * a string is the new value, and a name the edit leaves out is removed. An endpoint sent without
158
+ * the query string the saved one carries (the form is shown it without, since a query can hold a
159
+ * credential) keeps the saved endpoint. The transport may change; whether the server is enabled
160
+ * does not — the switch beside it does that.
161
+ */
162
+ export function mergeMcpEdit(saved, edit) {
163
+ if (!edit || typeof edit !== 'object' || Array.isArray(edit))
164
+ throw new Error('Invalid MCP server');
165
+ const draft = edit;
166
+ const keep = (values, previous, what) => {
167
+ if (values === undefined)
168
+ return undefined;
169
+ if (!values || typeof values !== 'object' || Array.isArray(values))
170
+ throw new Error(`Invalid MCP ${what}`);
171
+ const merged = {};
172
+ for (const [key, value] of Object.entries(values)) {
173
+ if (value === null) {
174
+ if (previous === undefined || !Object.prototype.hasOwnProperty.call(previous, key))
175
+ throw new Error(`MCP ${what} ${key} has no saved value to keep`);
176
+ merged[key] = previous[key];
177
+ }
178
+ else
179
+ merged[key] = value;
180
+ }
181
+ return Object.keys(merged).length > 0 ? merged : undefined;
182
+ };
183
+ const enabled = saved.enabled === undefined ? {} : { enabled: saved.enabled };
184
+ if (draft.transport === 'stdio') {
185
+ const env = keep(draft.env, saved.transport === 'stdio' ? saved.env : undefined, 'environment variable');
186
+ return validateMcpServer({ transport: 'stdio', command: draft.command, ...(draft.args === undefined ? {} : { args: draft.args }), ...(env === undefined ? {} : { env }), ...enabled });
187
+ }
188
+ if (draft.transport === 'http') {
189
+ const headers = keep(draft.headers, saved.transport === 'http' ? saved.headers : undefined, 'header');
190
+ let url = draft.url;
191
+ if (saved.transport === 'http' && typeof url === 'string') {
192
+ try {
193
+ const bare = new URL(saved.url);
194
+ bare.search = '';
195
+ if (new URL(url).href === bare.href)
196
+ url = saved.url;
197
+ }
198
+ catch { /* An endpoint that does not parse is refused by the validation below. */ }
199
+ }
200
+ return validateMcpServer({ transport: 'http', url, ...(headers === undefined ? {} : { headers }), ...enabled });
201
+ }
202
+ throw new Error('MCP transport must be stdio or http');
203
+ }
204
+ /**
205
+ * A reporter that records what a task's connections answered. A task names a server from the
206
+ * configuration `configured:<id>` (the extension snapshot's namespace, apart from plugins' servers),
207
+ * and the record is filed under the configuration's own id, which is what the settings page lists.
208
+ */
209
+ export function mcpTaskStatusReporter(directory) {
210
+ const store = mcpStatusStore(directory);
211
+ return (id, config, result) => {
212
+ const configured = id.startsWith('configured:') ? id.slice('configured:'.length) : id;
213
+ void store.record(configured, config, result, 'task').catch(() => { });
214
+ };
215
+ }
216
+ /**
217
+ * The identity of a server's definition — command, arguments, environment, address, headers — and
218
+ * not whether it is turned on, so a status survives the switch but not an edit. Credentials in the
219
+ * definition only enter the digest.
220
+ */
221
+ export function mcpDefinitionKey(config) {
222
+ const { enabled: _enabled, ...definition } = config;
223
+ return createHash('sha256').update(canonical(definition)).digest('hex');
224
+ }
225
+ /** Status records are small; a file past this was not written here and is not read. */
226
+ const MCP_STATUS_FILE_MAX_BYTES = 16_000;
227
+ /**
228
+ * The last thing each server answered, one small file per server under the configuration home, so a
229
+ * settings page can show it without starting anything. A task's connection writes it, and so does an
230
+ * explicit check (`mcp.status`); one file per server keeps two processes recording at once from
231
+ * overwriting each other's servers. Every failure to read reads as "not checked".
232
+ */
233
+ export function mcpStatusStore(directory) {
234
+ const root = join(directory, 'mcp-status');
235
+ const file = (id) => join(root, `${createHash('sha256').update(id).digest('hex')}.json`);
236
+ return {
237
+ async list() {
238
+ let names;
239
+ try {
240
+ names = await readdir(root);
241
+ }
242
+ catch {
243
+ return [];
244
+ }
245
+ const records = [];
246
+ for (const name of names.filter(entry => /^[a-f0-9]{64}\.json$/.test(entry)).slice(0, 1000)) {
247
+ try {
248
+ const raw = await readFile(join(root, name), 'utf8');
249
+ if (raw.length > MCP_STATUS_FILE_MAX_BYTES)
250
+ continue;
251
+ const parsed = JSON.parse(raw);
252
+ if (parsed.version !== 1 || typeof parsed.id !== 'string' || typeof parsed.definition !== 'string' || typeof parsed.checkedAt !== 'string'
253
+ || (parsed.state !== 'ready' && parsed.state !== 'failed') || (parsed.source !== 'task' && parsed.source !== 'check'))
254
+ continue;
255
+ records.push({
256
+ id: parsed.id, definition: parsed.definition, state: parsed.state, checkedAt: parsed.checkedAt, source: parsed.source,
257
+ ...(typeof parsed.tools === 'number' ? { tools: parsed.tools } : {}),
258
+ ...(typeof parsed.error === 'string' ? { error: parsed.error } : {}),
259
+ });
260
+ }
261
+ catch { /* An unreadable record is a server not checked. */ }
262
+ }
263
+ return records;
264
+ },
265
+ async record(id, config, result, source, at = new Date()) {
266
+ const record = {
267
+ id, definition: mcpDefinitionKey(config), state: result.state, checkedAt: at.toISOString(), source,
268
+ ...(result.state === 'ready' ? { tools: result.tools } : { error: result.error }),
269
+ };
270
+ const target = file(id);
271
+ const staging = `${target}.${process.pid}.${randomUUID()}.tmp`;
272
+ try {
273
+ await mkdir(root, { recursive: true });
274
+ await writeFile(staging, `${JSON.stringify({ version: 1, ...record })}\n`, { mode: 0o600 });
275
+ await rename(staging, target);
276
+ }
277
+ catch (error) {
278
+ await rm(staging, { force: true }).catch(() => { });
279
+ throw error;
280
+ }
281
+ return record;
282
+ },
283
+ };
284
+ }
285
+ /**
286
+ * Start one configured server, list its tools, and stop it again: the check a person asks for from
287
+ * the settings page ("Check Connection"), never one a page makes on its own — a task asks before it
288
+ * connects a server, and opening a page is not that consent.
289
+ *
290
+ * Nothing is kept. The catalog is only counted, and the client — with the process it started, for a
291
+ * stdio server — is closed before this returns, whatever happened. A probe is bounded in time as a
292
+ * task's connection is: 15 seconds to connect, 15 per page of tools, 30 in all.
293
+ */
294
+ export async function probeMcpServer(config, workspace, signal) {
295
+ const client = new Client({ name: 'andorra-code', version: '0.1.0' }, { capabilities: {} });
296
+ const limit = AbortSignal.timeout(30_000);
297
+ const probeSignal = signal === undefined ? limit : AbortSignal.any([signal, limit]);
298
+ let http;
299
+ try {
300
+ validateMcpServer(config);
301
+ const transport = mcpTransport(config, workspace, () => { void client.close().catch(() => { }); });
302
+ if (transport instanceof StreamableHTTPClientTransport)
303
+ http = transport;
304
+ await client.connect(transport, { signal: probeSignal, timeout: 15_000 });
305
+ let tools = 0;
306
+ const cursors = new Set();
307
+ let cursor;
308
+ let pages = 0;
309
+ do {
310
+ if (++pages > 100)
311
+ throw new Error('MCP catalog exceeded the 100-page limit');
312
+ const page = await client.listTools({ cursor }, { signal: probeSignal, timeout: 15_000 });
313
+ tools += page.tools.length;
314
+ cursor = page.nextCursor;
315
+ if (cursor && cursors.has(cursor))
316
+ throw new Error('MCP catalog repeated a cursor');
317
+ if (cursor)
318
+ cursors.add(cursor);
319
+ } while (cursor);
320
+ return { state: 'ready', tools };
321
+ }
322
+ catch (error) {
323
+ return { state: 'failed', error: probeFailureReason(error, config) };
324
+ }
325
+ finally {
326
+ try {
327
+ await http?.terminateSession();
328
+ }
329
+ catch { }
330
+ await client.close().catch(() => { });
331
+ }
332
+ }
333
+ /**
334
+ * Why a probe failed, in words a person can act on.
335
+ *
336
+ * A transport error can carry what the server sent back, and an HTTP one can echo the request's own
337
+ * headers, so the message itself is never passed on: the error is sorted into a known kind, and only
338
+ * the facts that are the configuration's own (its command) or the protocol's (a status code) are named.
339
+ */
340
+ export function probeFailureReason(error, config) {
341
+ const message = error instanceof Error ? error.message : String(error);
342
+ const name = error instanceof Error ? error.name : '';
343
+ const code = error?.code ?? error?.cause?.code;
344
+ if (message === MISSING_REFERENCE)
345
+ return 'An environment variable its settings refer to is not set.';
346
+ if (message.startsWith('Invalid MCP') || message.startsWith('MCP requires') || message.startsWith('MCP transport'))
347
+ return 'Its settings are not valid.';
348
+ if (config.transport === 'stdio' && (code === 'ENOENT' || /\bENOENT\b/.test(message)))
349
+ return `Command not found: ${config.command ?? 'the configured command'}.`;
350
+ if (config.transport === 'stdio' && (code === 'EACCES' || /\bEACCES\b/.test(message)))
351
+ return `Not allowed to run ${config.command ?? 'the configured command'}.`;
352
+ if (name === 'TimeoutError' || /timed? ?out/i.test(message) || code === -32001)
353
+ return 'It did not answer in time.';
354
+ const status = /\(HTTP (\d{3})\)/.exec(message)?.[1];
355
+ if (status === '401' || status === '403')
356
+ return `Not authorized (HTTP ${status}). Check its headers.`;
357
+ if (status !== undefined)
358
+ return `The server answered HTTP ${status}.`;
359
+ if (typeof code === 'string' && /^(ECONNREFUSED|ENOTFOUND|EAI_AGAIN|ECONNRESET|ETIMEDOUT|EHOSTUNREACH)$/.test(code))
360
+ return 'Could not reach the server.';
361
+ if (/connection closed/i.test(message))
362
+ return 'The server stopped before it answered.';
363
+ if (message === 'MCP response exceeds 1 MiB transport limit')
364
+ return 'Its answer was larger than 1 MiB.';
365
+ return 'Could not connect or list its tools. Check its command and authentication.';
366
+ }
135
367
  const OVER_BUDGET = 'MCP catalog exceeds task metadata budget';
136
368
  // Transport errors can contain server-provided strings or auth headers: report a bounded, non-secret status.
137
369
  const unavailableReason = (error) => error instanceof Error && error.message === 'Permission denied' ? 'connection permission denied'
@@ -214,14 +446,8 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
214
446
  const connectServer = async (id, config, accept) => {
215
447
  const client = new Client({ name: 'andorra-code', version: '0.1.0' }, { capabilities: {} });
216
448
  try {
217
- const expand = (value) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_, name) => { const value = name === 'PLUGIN_ROOT' && config.pluginRoot !== undefined ? config.pluginRoot : process.env[name]; if (value === undefined)
218
- throw new Error('Missing MCP environment reference'); return value; });
219
449
  startupSignal.throwIfAborted();
220
- // The SDK adds its minimal default environment; pass only explicitly configured
221
- // entries so unrelated provider/cloud credentials never reach MCP processes.
222
- const transport = config.transport === 'stdio' ? new StdioClientTransport({ command: config.command, args: config.args, env: Object.fromEntries(Object.entries(config.env ?? {}).map(([k, v]) => [k, expand(v)])), cwd: context.workspace, stderr: 'pipe', maxBufferSize: MCP_RESPONSE_MAX_BYTES }) : new StreamableHTTPClientTransport(new URL(config.url), { requestInit: { headers: Object.fromEntries(Object.entries(config.headers ?? {}).map(([k, v]) => [k, expand(v)])), redirect: 'error' }, fetch: (url, init) => boundedMcpFetch(url, init, () => { void client.close().catch(() => { }); }) });
223
- if (transport instanceof StdioClientTransport)
224
- transport.stderr?.on('data', () => { });
450
+ const transport = mcpTransport(config, context.workspace, () => { void client.close().catch(() => { }); });
225
451
  clients.set(client, transport instanceof StreamableHTTPClientTransport ? transport : undefined);
226
452
  await client.connect(transport, { signal: startupSignal, timeout: 15_000 });
227
453
  const discoverySignal = AbortSignal.any([startupSignal, AbortSignal.timeout(30_000)]);
@@ -374,6 +600,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
374
600
  });
375
601
  });
376
602
  background = connection.then(async (live) => {
603
+ options.status?.(id, config, { state: 'ready', tools: live.catalog.length });
377
604
  // Key order inside a schema is the server's serializer's business, not a change of catalog.
378
605
  if (canonical(live.catalog) === canonical(known.catalog)) {
379
606
  notice(`MCP ${id}: ${known.catalog.length} tools available to agents with shell permission.`);
@@ -390,6 +617,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
390
617
  // A task that is ending says nothing about the server: its record stands.
391
618
  if (startupSignal.aborted)
392
619
  return;
620
+ options.status?.(id, config, { state: 'failed', error: probeFailureReason(error, config) });
393
621
  // The next task asks the server before offering its tools, as for one never seen.
394
622
  await store.remove(key).catch(() => { });
395
623
  notice(`MCP ${id}: unavailable (${unavailableReason(error)}).`);
@@ -434,6 +662,7 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
434
662
  }
435
663
  catalogBytes += limits.bytes;
436
664
  notice(`MCP ${id}: ${live.catalog.length} tools available to agents with shell permission.`);
665
+ options.status?.(id, config, { state: 'ready', tools: live.catalog.length });
437
666
  // Remembered for the next task. An empty catalog offers nothing to wait for and is asked again.
438
667
  if (store && key !== undefined && live.catalog.length > 0)
439
668
  await store.write(key, { tools: live.catalog }).catch(() => { });
@@ -444,6 +673,9 @@ export async function connectMcpServers(servers, context, notice, taskSignal = c
444
673
  // next task is told the same thing without waiting for the server to say it again.
445
674
  if (store && key !== undefined && error instanceof Error && error.message === OVER_BUDGET)
446
675
  await store.write(key, { overBudget: true }).catch(() => { });
676
+ // A catalog refused for the task's budget came from a server that answered: that is not its status.
677
+ else
678
+ options.status?.(id, config, { state: 'failed', error: probeFailureReason(error, config) });
447
679
  notice(`MCP ${id}: unavailable (${unavailableReason(error)}).`);
448
680
  }
449
681
  }