@andorra-labs/code 0.1.17 → 0.1.19

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 (313) hide show
  1. package/dist/src/account-jev-savings.d.ts +4 -0
  2. package/dist/src/account-jev-savings.js +92 -0
  3. package/dist/src/acp-agent.js +2 -2
  4. package/dist/src/agent-execution.js +441 -53
  5. package/dist/src/agent-mcp.js +7 -1
  6. package/dist/src/agent-modifiers.js +5 -7
  7. package/dist/src/analytics.d.ts +19 -1
  8. package/dist/src/analytics.js +9 -1
  9. package/dist/src/andorra/entry.js +15 -6
  10. package/dist/src/andorra/errors.js +3 -0
  11. package/dist/src/andorra/hosted.d.ts +8 -0
  12. package/dist/src/andorra/hosted.js +22 -3
  13. package/dist/src/andorra/streams.d.ts +49 -0
  14. package/dist/src/andorra/streams.js +98 -0
  15. package/dist/src/antigravity-acp.d.ts +28 -0
  16. package/dist/src/antigravity-acp.js +150 -0
  17. package/dist/src/antigravity-terminal.d.ts +2 -0
  18. package/dist/src/antigravity-terminal.js +214 -0
  19. package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
  20. package/dist/src/app-server/adaptive-routing-settings.js +69 -0
  21. package/dist/src/app-server/artifact.d.ts +14 -0
  22. package/dist/src/app-server/artifact.js +46 -0
  23. package/dist/src/app-server/legal-protocol.d.ts +33 -0
  24. package/dist/src/app-server/legal-protocol.js +16 -0
  25. package/dist/src/app-server/protocol.d.ts +34 -3
  26. package/dist/src/app-server/protocol.js +3 -1
  27. package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
  28. package/dist/src/app-server/telemetry-protocol.js +2 -0
  29. package/dist/src/app-server/telemetry.d.ts +38 -0
  30. package/dist/src/app-server/telemetry.js +163 -0
  31. package/dist/src/app-server/workspace.d.ts +21 -0
  32. package/dist/src/app-server/workspace.js +192 -10
  33. package/dist/src/app-server.d.ts +82 -26
  34. package/dist/src/app-server.js +1573 -417
  35. package/dist/src/attachments.d.ts +10 -0
  36. package/dist/src/attachments.js +102 -7
  37. package/dist/src/auth/AuthManager.d.ts +11 -2
  38. package/dist/src/auth/AuthManager.js +56 -13
  39. package/dist/src/auth/index.d.ts +5 -1
  40. package/dist/src/auth/index.js +8 -1
  41. package/dist/src/auth/lifecycle.d.ts +13 -0
  42. package/dist/src/auth/lifecycle.js +109 -0
  43. package/dist/src/auth/store.d.ts +1 -0
  44. package/dist/src/auth/store.js +12 -0
  45. package/dist/src/auth/types.d.ts +12 -0
  46. package/dist/src/automation-runner.js +2 -0
  47. package/dist/src/automation-service.js +7 -2
  48. package/dist/src/automation-tool.js +2 -1
  49. package/dist/src/benchmark-scores.d.ts +88 -0
  50. package/dist/src/benchmark-scores.js +302 -0
  51. package/dist/src/bridge/command.js +16 -1
  52. package/dist/src/bridge/control.d.ts +3 -1
  53. package/dist/src/bridge/control.js +9 -3
  54. package/dist/src/bridge/engines.d.ts +2 -0
  55. package/dist/src/bridge/engines.js +9 -0
  56. package/dist/src/bridge/github.d.ts +108 -0
  57. package/dist/src/bridge/github.js +378 -0
  58. package/dist/src/bridge/host-ops.d.ts +3 -3
  59. package/dist/src/bridge/host-ops.js +14 -2
  60. package/dist/src/bridge/host.d.ts +2 -0
  61. package/dist/src/bridge/host.js +70 -16
  62. package/dist/src/bridge/protocol.d.ts +1 -0
  63. package/dist/src/bridge/protocol.js +1 -0
  64. package/dist/src/browser-panel-tool.d.ts +12 -0
  65. package/dist/src/browser-panel-tool.js +30 -3
  66. package/dist/src/browser-runner.js +53 -62
  67. package/dist/src/browser-server.js +10 -4
  68. package/dist/src/browser-session.d.ts +14 -0
  69. package/dist/src/browser-session.js +57 -12
  70. package/dist/src/browser-view.d.ts +40 -1
  71. package/dist/src/browser-view.js +163 -9
  72. package/dist/src/browser-window-style.d.ts +27 -0
  73. package/dist/src/browser-window-style.js +244 -0
  74. package/dist/src/bug-report-attachments.d.ts +48 -0
  75. package/dist/src/bug-report-attachments.js +327 -0
  76. package/dist/src/bug-report.d.ts +23 -3
  77. package/dist/src/bug-report.js +72 -9
  78. package/dist/src/claude-provider.d.ts +1 -0
  79. package/dist/src/claude-provider.js +77 -36
  80. package/dist/src/cli.d.ts +1 -3
  81. package/dist/src/cli.js +245 -62
  82. package/dist/src/codex-provider.d.ts +1 -0
  83. package/dist/src/codex-provider.js +44 -8
  84. package/dist/src/coding-tools.d.ts +1 -0
  85. package/dist/src/coding-tools.js +28 -7
  86. package/dist/src/command-screens.d.ts +1 -1
  87. package/dist/src/command-screens.js +2 -2
  88. package/dist/src/commands.d.ts +9 -2
  89. package/dist/src/commands.js +69 -64
  90. package/dist/src/completion.js +13 -7
  91. package/dist/src/config.d.ts +14 -3
  92. package/dist/src/config.js +57 -17
  93. package/dist/src/context-budget.d.ts +11 -2
  94. package/dist/src/context-budget.js +38 -4
  95. package/dist/src/context-compaction.d.ts +10 -8
  96. package/dist/src/context-compaction.js +23 -24
  97. package/dist/src/deadline.js +1 -1
  98. package/dist/src/decision/DecisionEngine.d.ts +2 -0
  99. package/dist/src/decision/DecisionManager.d.ts +16 -0
  100. package/dist/src/decision/DecisionManager.js +75 -2
  101. package/dist/src/decision/applyTaskKind.d.ts +8 -0
  102. package/dist/src/decision/applyTaskKind.js +53 -0
  103. package/dist/src/decision/applyToolMenu.js +6 -2
  104. package/dist/src/decision/hostedPolicy.js +6 -3
  105. package/dist/src/decision/optimizationPolicy.d.ts +10 -0
  106. package/dist/src/decision/optimizationPolicy.js +23 -3
  107. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +4 -1
  108. package/dist/src/decision/providers/AndorraDecisionProvider.js +29 -7
  109. package/dist/src/decision/providers/index.js +1 -1
  110. package/dist/src/decision/taskKind.d.ts +52 -0
  111. package/dist/src/decision/taskKind.js +76 -0
  112. package/dist/src/decision/toolFamilies.js +1 -1
  113. package/dist/src/decision/types.d.ts +3 -1
  114. package/dist/src/default-graph.js +1 -1
  115. package/dist/src/efficiency.d.ts +80 -1
  116. package/dist/src/efficiency.js +119 -4
  117. package/dist/src/effort-routing.d.ts +27 -0
  118. package/dist/src/effort-routing.js +34 -0
  119. package/dist/src/evidence.d.ts +110 -0
  120. package/dist/src/evidence.js +195 -0
  121. package/dist/src/extensions.d.ts +2 -0
  122. package/dist/src/extensions.js +30 -20
  123. package/dist/src/github-app/agent-writes.d.ts +1 -1
  124. package/dist/src/github-app/agent-writes.js +1 -1
  125. package/dist/src/github-app/client.d.ts +19 -0
  126. package/dist/src/github-app/client.js +21 -1
  127. package/dist/src/github-app/event-source.d.ts +0 -5
  128. package/dist/src/github-app/event-source.js +1 -31
  129. package/dist/src/github-app/metrics.d.ts +2 -5
  130. package/dist/src/github-app/metrics.js +2 -14
  131. package/dist/src/github-app/review-loop.d.ts +5 -5
  132. package/dist/src/github-app/review-loop.js +1 -1
  133. package/dist/src/github-app/review-node.d.ts +2 -2
  134. package/dist/src/github-app/triggers.d.ts +3 -3
  135. package/dist/src/github-names.d.ts +7 -0
  136. package/dist/src/github-names.js +7 -0
  137. package/dist/src/glob-search.d.ts +1 -0
  138. package/dist/src/glob-search.js +3 -0
  139. package/dist/src/google-provider.d.ts +5 -28
  140. package/dist/src/google-provider.js +6 -141
  141. package/dist/src/graph-editor-session.d.ts +1 -0
  142. package/dist/src/graph-editor-session.js +2 -0
  143. package/dist/src/graph-health.js +3 -1
  144. package/dist/src/graph-preview.d.ts +2 -0
  145. package/dist/src/graph-preview.js +1 -0
  146. package/dist/src/graph-runner.js +20 -14
  147. package/dist/src/graph-selection.d.ts +3 -1
  148. package/dist/src/graph-selection.js +2 -2
  149. package/dist/src/graph-server.d.ts +8 -1
  150. package/dist/src/graph-server.js +49 -12
  151. package/dist/src/graph-sync.d.ts +2 -1
  152. package/dist/src/graph-sync.js +13 -0
  153. package/dist/src/graph-ui/app.js +49 -8
  154. package/dist/src/graph-ui/index.html +1 -1
  155. package/dist/src/graphs.d.ts +23 -1
  156. package/dist/src/graphs.js +58 -7
  157. package/dist/src/grok-provider.js +17 -14
  158. package/dist/src/hardened-runtime.js +39 -25
  159. package/dist/src/jev-savings.d.ts +4 -0
  160. package/dist/src/jev-savings.js +13 -0
  161. package/dist/src/legal/client.d.ts +25 -0
  162. package/dist/src/legal/client.js +47 -0
  163. package/dist/src/legal/command.d.ts +13 -0
  164. package/dist/src/legal/command.js +98 -0
  165. package/dist/src/legal/documents.d.ts +2 -0
  166. package/dist/src/legal/documents.js +14 -0
  167. package/dist/src/legal/gate.d.ts +13 -0
  168. package/dist/src/legal/gate.js +96 -0
  169. package/dist/src/legal/manifest.d.ts +21 -0
  170. package/dist/src/legal/manifest.js +23 -0
  171. package/dist/src/legal/receipt.d.ts +13 -0
  172. package/dist/src/legal/receipt.js +137 -0
  173. package/dist/src/legal/release.d.ts +27 -0
  174. package/dist/src/legal/release.js +28 -0
  175. package/dist/src/managed-sign-in.d.ts +0 -1
  176. package/dist/src/managed-sign-in.js +0 -13
  177. package/dist/src/membership.d.ts +27 -1
  178. package/dist/src/membership.js +139 -7
  179. package/dist/src/model-health-cache.js +1 -1
  180. package/dist/src/model-metadata.js +3 -7
  181. package/dist/src/model-override.d.ts +2 -1
  182. package/dist/src/model-override.js +9 -0
  183. package/dist/src/model-pool.d.ts +99 -0
  184. package/dist/src/model-pool.js +136 -0
  185. package/dist/src/model-relay/local.js +5 -0
  186. package/dist/src/model-relay/remote.d.ts +2 -0
  187. package/dist/src/model-relay/remote.js +4 -0
  188. package/dist/src/model-tiers.d.ts +16 -1
  189. package/dist/src/model-tiers.js +31 -7
  190. package/dist/src/opencode-cli-provider.js +59 -56
  191. package/dist/src/opencode-provider.js +16 -13
  192. package/dist/src/permissions.d.ts +5 -0
  193. package/dist/src/permissions.js +7 -0
  194. package/dist/src/plan-pass.js +2 -1
  195. package/dist/src/pool-scores.d.ts +45 -0
  196. package/dist/src/pool-scores.js +40 -0
  197. package/dist/src/provider-connection.js +3 -17
  198. package/dist/src/provider-engine.d.ts +13 -1
  199. package/dist/src/provider-engine.js +116 -12
  200. package/dist/src/provider-request-error.d.ts +8 -0
  201. package/dist/src/provider-request-error.js +12 -0
  202. package/dist/src/provider-settings.d.ts +1 -1
  203. package/dist/src/provider-settings.js +36 -18
  204. package/dist/src/provider-turn-deadline.d.ts +39 -0
  205. package/dist/src/provider-turn-deadline.js +139 -0
  206. package/dist/src/providers.d.ts +8 -9
  207. package/dist/src/providers.js +211 -150
  208. package/dist/src/pull-request-merge.d.ts +1 -8
  209. package/dist/src/pull-request-merge.js +0 -4
  210. package/dist/src/pull-requests.d.ts +83 -57
  211. package/dist/src/pull-requests.js +266 -225
  212. package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
  213. package/dist/src/qa/runtime/ProcessManager.js +9 -3
  214. package/dist/src/react-runtime.js +245 -71
  215. package/dist/src/reasoning-probe-cloud.d.ts +10 -0
  216. package/dist/src/reasoning-probe-cloud.js +209 -0
  217. package/dist/src/remote/engine-pool.d.ts +3 -0
  218. package/dist/src/remote/engine-pool.js +88 -21
  219. package/dist/src/remote/recovery.d.ts +6 -0
  220. package/dist/src/remote/recovery.js +37 -0
  221. package/dist/src/run-records.d.ts +13 -3
  222. package/dist/src/run-records.js +59 -34
  223. package/dist/src/runtime.d.ts +47 -2
  224. package/dist/src/runtime.js +33 -7
  225. package/dist/src/session-summary.d.ts +8 -0
  226. package/dist/src/session-summary.js +34 -0
  227. package/dist/src/sessions.d.ts +32 -0
  228. package/dist/src/sessions.js +65 -3
  229. package/dist/src/shell.js +6 -0
  230. package/dist/src/side-panel.js +36 -2
  231. package/dist/src/sign-in-detection.d.ts +1 -1
  232. package/dist/src/sign-in-detection.js +4 -10
  233. package/dist/src/sign-in-offer.js +1 -1
  234. package/dist/src/skill-commands.js +1 -1
  235. package/dist/src/skills/bundled/bug-report/SKILL.md +51 -7
  236. package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
  237. package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
  238. package/dist/src/skills/bundled/provenance.json +3 -3
  239. package/dist/src/subagent-run.js +50 -50
  240. package/dist/src/subscription-usage.d.ts +50 -0
  241. package/dist/src/subscription-usage.js +92 -0
  242. package/dist/src/task-checkout.d.ts +157 -0
  243. package/dist/src/task-checkout.js +628 -0
  244. package/dist/src/telemetry/access.d.ts +18 -0
  245. package/dist/src/telemetry/access.js +43 -0
  246. package/dist/src/telemetry/aggregate.d.ts +18 -2
  247. package/dist/src/telemetry/aggregate.js +22 -9
  248. package/dist/src/telemetry/capture-core.d.ts +33 -14
  249. package/dist/src/telemetry/capture-core.js +124 -25
  250. package/dist/src/telemetry/capture.d.ts +3 -2
  251. package/dist/src/telemetry/capture.js +21 -1
  252. package/dist/src/telemetry/decision-capture.js +4 -0
  253. package/dist/src/telemetry/emitter.d.ts +6 -7
  254. package/dist/src/telemetry/emitter.js +124 -29
  255. package/dist/src/telemetry/gate.d.ts +41 -2
  256. package/dist/src/telemetry/gate.js +89 -4
  257. package/dist/src/telemetry/home.d.ts +1 -0
  258. package/dist/src/telemetry/home.js +20 -0
  259. package/dist/src/telemetry/identity.d.ts +6 -3
  260. package/dist/src/telemetry/identity.js +19 -6
  261. package/dist/src/telemetry/lifecycle.d.ts +8 -0
  262. package/dist/src/telemetry/lifecycle.js +76 -0
  263. package/dist/src/telemetry/outbox.d.ts +13 -8
  264. package/dist/src/telemetry/outbox.js +68 -12
  265. package/dist/src/telemetry/permission-command.d.ts +38 -0
  266. package/dist/src/telemetry/permission-command.js +208 -0
  267. package/dist/src/telemetry/permission.d.ts +168 -0
  268. package/dist/src/telemetry/permission.js +662 -0
  269. package/dist/src/telemetry/record-installation.d.ts +1 -0
  270. package/dist/src/telemetry/record-installation.js +9 -0
  271. package/dist/src/telemetry/region-data.d.ts +12 -0
  272. package/dist/src/telemetry/region-data.js +1314 -0
  273. package/dist/src/telemetry/region.d.ts +34 -0
  274. package/dist/src/telemetry/region.js +87 -0
  275. package/dist/src/telemetry/run-privacy.d.ts +11 -0
  276. package/dist/src/telemetry/run-privacy.js +165 -0
  277. package/dist/src/telemetry/schema.d.ts +27 -6
  278. package/dist/src/telemetry/schema.js +109 -14
  279. package/dist/src/telemetry/state.d.ts +11 -7
  280. package/dist/src/telemetry/state.js +39 -6
  281. package/dist/src/telemetry/surface.d.ts +20 -3
  282. package/dist/src/telemetry/surface.js +71 -15
  283. package/dist/src/telemetry/uploader.d.ts +6 -11
  284. package/dist/src/telemetry/uploader.js +72 -46
  285. package/dist/src/telemetry/uploads.d.ts +5 -1
  286. package/dist/src/telemetry/uploads.js +25 -6
  287. package/dist/src/telemetry/version.d.ts +5 -0
  288. package/dist/src/telemetry/version.js +34 -0
  289. package/dist/src/telemetry/workspace.d.ts +4 -1
  290. package/dist/src/telemetry/workspace.js +18 -3
  291. package/dist/src/terminal-ui.d.ts +3 -0
  292. package/dist/src/terminal-ui.js +48 -6
  293. package/dist/src/test-edit-guard.d.ts +30 -0
  294. package/dist/src/test-edit-guard.js +167 -2
  295. package/dist/src/thinking-level-detect.d.ts +13 -0
  296. package/dist/src/thinking-level-detect.js +52 -0
  297. package/dist/src/thinking-levels.d.ts +30 -0
  298. package/dist/src/thinking-levels.js +131 -0
  299. package/dist/src/timers.d.ts +3 -0
  300. package/dist/src/todos.d.ts +2 -1
  301. package/dist/src/todos.js +24 -4
  302. package/dist/src/tool-argument-coercion.d.ts +7 -0
  303. package/dist/src/tool-argument-coercion.js +49 -0
  304. package/dist/src/tool-catalog.d.ts +2 -2
  305. package/dist/src/tool-catalog.js +1 -1
  306. package/dist/src/tools.js +67 -22
  307. package/dist/src/transcript.js +3 -2
  308. package/dist/src/types.d.ts +48 -1
  309. package/dist/src/update.js +4 -0
  310. package/dist/src/usage-analytics.d.ts +7 -0
  311. package/dist/src/usage-analytics.js +85 -13
  312. package/dist/telemetry-consent-v1 +1 -0
  313. package/package.json +97 -96
@@ -0,0 +1,38 @@
1
+ import type { Config } from '../config.js';
2
+ import { type TelemetryPermissionStatus } from '../telemetry/permission.js';
3
+ import { type TelemetryLocationSignals } from '../telemetry/region.js';
4
+ import type { TelemetryAccess } from '../telemetry/access.js';
5
+ import type { TelemetryStatusResult, TelemetrySetConsentResult } from './telemetry-protocol.js';
6
+ /** Strict, bounded transport. Errors never echo raw location hints. */
7
+ export declare function rendererTelemetryHints(value: unknown): TelemetryLocationSignals;
8
+ /** Purpose-limited shared run-file read; a blocked read never gets an analytics subtree. */
9
+ export declare function readTelemetryRunRecord(home: string, path: string, access?: TelemetryAccess): Promise<Record<string, unknown>>;
10
+ /** One execution process's transient protective context; never a second permission store. */
11
+ export declare class AppServerTelemetry {
12
+ readonly home: string;
13
+ private readonly changed;
14
+ private readonly invalidated;
15
+ private renderer?;
16
+ private lastStatus?;
17
+ private watcher?;
18
+ private permissionKey?;
19
+ private polling;
20
+ private watchEpoch;
21
+ constructor(home: string, changed: (result: TelemetryStatusResult) => void, invalidated?: () => void);
22
+ readonly signals: () => import("../telemetry/region.js").TelemetryRegionSignals;
23
+ private protectProcess;
24
+ private addRenderer;
25
+ permission(): Promise<TelemetryPermissionStatus>;
26
+ snapshot(): Promise<TelemetryStatusResult & {
27
+ analytics?: Config['analytics'] & {
28
+ plan: 'paid' | 'free' | 'legacy' | 'unknown';
29
+ canOptOut: boolean;
30
+ };
31
+ }>;
32
+ private publish;
33
+ status(params: Record<string, unknown>): Promise<TelemetryStatusResult>;
34
+ setConsent(params: Record<string, unknown>): Promise<TelemetrySetConsentResult>;
35
+ private poll;
36
+ watch(): void;
37
+ close(): void;
38
+ }
@@ -0,0 +1,163 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import { getAuthStatus } from '../auth/index.js';
3
+ import { telemetryStatusGate } from '../telemetry/gate.js';
4
+ import { TELEMETRY_NOTICE, TELEMETRY_NOTICE_VERSION, TelemetryPrivacyError, setTelemetryConsent, telemetryPermission, withTelemetryAdmission } from '../telemetry/permission.js';
5
+ import { readLocalTelemetrySignals, resolveTelemetryRegion } from '../telemetry/region.js';
6
+ import { scrubRuns, functionalRunRecord } from '../run-records.js';
7
+ import { admittedRunRecord } from '../telemetry/run-privacy.js';
8
+ /** Strict, bounded transport. Errors never echo raw location hints. */
9
+ export function rendererTelemetryHints(value) {
10
+ if (!value || typeof value !== 'object' || Array.isArray(value))
11
+ throw new TelemetryPrivacyError('invalid-params', 'renderer must be an object');
12
+ const hints = value;
13
+ if (Object.keys(hints).some(key => key !== 'timeZone' && key !== 'locales'))
14
+ throw new TelemetryPrivacyError('invalid-params', 'renderer accepts only timeZone and locales');
15
+ const signal = (entry) => typeof entry === 'string' && entry.length <= 128 && !/[\u0000-\u001f\u007f]/.test(entry);
16
+ if (hints.timeZone !== undefined && !signal(hints.timeZone))
17
+ throw new TelemetryPrivacyError('invalid-params', 'timeZone must be a string of at most 128 characters');
18
+ if (hints.locales !== undefined && (!Array.isArray(hints.locales) || hints.locales.length > 4 || !hints.locales.every(signal)))
19
+ throw new TelemetryPrivacyError('invalid-params', 'locales must contain at most four strings of at most 128 characters');
20
+ return { ...(hints.timeZone === undefined ? {} : { timeZone: hints.timeZone }), ...(hints.locales === undefined ? {} : { locales: [...hints.locales] }) };
21
+ }
22
+ function wireStatus(permission) {
23
+ const { permitted, reason, ...status } = permission;
24
+ return { ...status, report: permitted, reason: reason === 'outside-policy' ? 'included-with-plan' : reason };
25
+ }
26
+ /** Purpose-limited shared run-file read; a blocked read never gets an analytics subtree. */
27
+ export async function readTelemetryRunRecord(home, path, access) {
28
+ const read = async () => JSON.parse(await readFile(path, 'utf8'));
29
+ const admitted = await withTelemetryAdmission({ home, signals: access?.signals }, async (admission) => admittedRunRecord(await read(), admission.lease), access?.lease);
30
+ return admitted ?? functionalRunRecord(await read());
31
+ }
32
+ /** One execution process's transient protective context; never a second permission store. */
33
+ export class AppServerTelemetry {
34
+ home;
35
+ changed;
36
+ invalidated;
37
+ renderer;
38
+ lastStatus;
39
+ watcher;
40
+ permissionKey;
41
+ polling = false;
42
+ watchEpoch = 0;
43
+ constructor(home, changed, invalidated = () => { }) {
44
+ this.home = home;
45
+ this.changed = changed;
46
+ this.invalidated = invalidated;
47
+ // Must run before recovery, membership, configuration or any producer. Missing transport is
48
+ // normal for CLI hosts. Malformed supplied transport is not evidence for an outside waiver.
49
+ const raw = process.env.ANDORRA_TELEMETRY_RENDERER_HINTS;
50
+ // Consume the transport before parsing: even malformed hints must not reach tools, MCP or PTYs.
51
+ delete process.env.ANDORRA_TELEMETRY_RENDERER_HINTS;
52
+ if (raw !== undefined) {
53
+ try {
54
+ if (raw.length > 4096)
55
+ throw new Error();
56
+ this.addRenderer(rendererTelemetryHints(JSON.parse(raw)));
57
+ }
58
+ catch {
59
+ this.protectProcess();
60
+ }
61
+ }
62
+ }
63
+ signals = () => readLocalTelemetrySignals({ renderer: this.renderer });
64
+ protectProcess() {
65
+ // Some functional membership/graph helpers own their own nested telemetry calls. The process-
66
+ // local, one-way ask policy protects those too, and is inherited before any child can start.
67
+ // This is NOT a shell export, a persisted hint or affirmative permission. Never restore auto.
68
+ process.env.ANDORRA_TELEMETRY_POLICY = 'ask';
69
+ }
70
+ addRenderer(hints) {
71
+ // Keep only a bounded protective representative, not an accumulating location history.
72
+ if (resolveTelemetryRegion({ renderer: hints }).region === 'in') {
73
+ this.renderer = hints;
74
+ this.protectProcess();
75
+ }
76
+ }
77
+ permission() { return telemetryPermission({ home: this.home, signals: this.signals }); }
78
+ async snapshot() {
79
+ const gate = await telemetryStatusGate({ home: this.home, signals: this.signals, subject: async () => {
80
+ const auth = await getAuthStatus(undefined, { readOnly: true }).catch(() => undefined); // no refresh or recovery write
81
+ return auth?.signedIn ? auth.subject : undefined;
82
+ } });
83
+ this.permissionKey = JSON.stringify(gate.permission);
84
+ return { status: { ...wireStatus(gate.permission), report: gate.report, canChange: gate.canOptOut,
85
+ reason: gate.permission.permissionRequired ? wireStatus(gate.permission).reason : gate.plan === 'paid' ? 'paid-preference' : 'included-with-plan' },
86
+ notice: TELEMETRY_NOTICE,
87
+ ...(!gate.permission.permissionRequired ? { analytics: { ...gate.savedAnalytics, plan: gate.plan, canOptOut: gate.canOptOut } } : {}) };
88
+ }
89
+ publish(result) {
90
+ const key = JSON.stringify(result);
91
+ if (this.lastStatus !== key) {
92
+ this.lastStatus = key;
93
+ this.changed(result);
94
+ }
95
+ }
96
+ async status(params) {
97
+ if (Object.keys(params).some(key => key !== 'renderer'))
98
+ throw new TelemetryPrivacyError('invalid-params', 'telemetry.status accepts only renderer');
99
+ if (Object.hasOwn(params, 'renderer'))
100
+ this.addRenderer(rendererTelemetryHints(params.renderer));
101
+ const { status, notice } = await this.snapshot();
102
+ const result = { status, notice };
103
+ this.publish(result);
104
+ return result;
105
+ }
106
+ async setConsent(params) {
107
+ const { answer, expectedRevision, noticeVersion } = params;
108
+ if (Object.keys(params).some(key => !['answer', 'expectedRevision', 'noticeVersion'].includes(key)) || (answer !== 'yes' && answer !== 'no')
109
+ || !Number.isSafeInteger(expectedRevision) || expectedRevision < 0 || noticeVersion !== TELEMETRY_NOTICE_VERSION) {
110
+ throw new TelemetryPrivacyError('invalid-params', 'answer, a nonnegative expectedRevision and the current noticeVersion are required');
111
+ }
112
+ const current = await this.permission();
113
+ if (!current.permissionRequired)
114
+ throw new TelemetryPrivacyError('invalid-params', 'Outside protected policy, use the saved analytics preference');
115
+ // Avoid cancelling live work for an already-known stale refusal. The store still performs
116
+ // the authoritative CAS under its barrier; a race after this read remains fail-closed.
117
+ if (expectedRevision !== current.revision && !(answer === 'no' && current.answer === 'no')) {
118
+ return { saved: false, conflict: true, status: wireStatus(current), notice: TELEMETRY_NOTICE };
119
+ }
120
+ const update = await setTelemetryConsent({ home: this.home, signals: this.signals }, { action: answer === 'yes' ? 'allow' : 'deny', expectedRevision: expectedRevision, noticeVersion: noticeVersion }, scrubRuns);
121
+ const result = { ...update, status: wireStatus(update.status), notice: TELEMETRY_NOTICE };
122
+ this.publish({ status: result.status, notice: result.notice });
123
+ return result;
124
+ }
125
+ async poll(epoch) {
126
+ if (this.polling)
127
+ return;
128
+ this.polling = true;
129
+ try {
130
+ // A display poll never resolves a subject, reads analytics config/cache, or takes auth's
131
+ // machine-wide lock. Only explicit status/config reads need those outside-plan details.
132
+ const permission = await this.permission();
133
+ if (!this.watcher || epoch !== this.watchEpoch)
134
+ return;
135
+ const key = JSON.stringify(permission);
136
+ if (key === this.permissionKey)
137
+ return;
138
+ this.permissionKey = key;
139
+ if (permission.permissionRequired)
140
+ this.publish({ status: wireStatus(permission), notice: TELEMETRY_NOTICE });
141
+ else
142
+ this.invalidated(); // request a real display refresh; never invent outside plan/reporting
143
+ }
144
+ finally {
145
+ this.polling = false;
146
+ }
147
+ }
148
+ watch() {
149
+ if (this.watcher)
150
+ return;
151
+ const epoch = ++this.watchEpoch;
152
+ // Missing privacy/ is normal. No mkdir/prompt election, no overlapping reads, and a slower
153
+ // necessary-state poll. Local writes and desktop focus/status already refresh immediately.
154
+ this.watcher = setInterval(() => { void this.poll(epoch).catch(() => { }); }, 2000);
155
+ this.watcher.unref();
156
+ }
157
+ close() {
158
+ if (this.watcher)
159
+ clearInterval(this.watcher);
160
+ this.watcher = undefined;
161
+ this.watchEpoch++;
162
+ }
163
+ }
@@ -24,6 +24,27 @@ export declare function readWorkspaceFile(root: string, name: unknown): Promise<
24
24
  hash?: string;
25
25
  notUtf8?: true;
26
26
  }>;
27
+ /** The largest image the Files tab previews; a larger one keeps the binary note. */
28
+ export declare const MAX_IMAGE_BYTES: number;
29
+ export declare function imageTypeOf(path: string): string | undefined;
30
+ /**
31
+ * A project image's bytes, base64, for the Files tab's preview (`workspace.image`). `tooLarge` past 10 MB, with no
32
+ * bytes. The type comes from the extension only: the desktop draws it in an <img>, which never runs an SVG's script.
33
+ */
34
+ export declare function readWorkspaceImage(root: string, name: unknown, options?: {
35
+ outside?: boolean;
36
+ }): Promise<{
37
+ mimeType: string;
38
+ size: number;
39
+ dataBase64?: string;
40
+ tooLarge?: true;
41
+ }>;
42
+ export declare function globMatches(path: string, glob: string): boolean;
43
+ /**
44
+ * A glob list's problems ripgrep would refuse, said before a search: an unclosed `{`, or so many alternatives or
45
+ * `**` that matching could take seconds.
46
+ */
47
+ export declare function globProblem(glob: string): string | undefined;
27
48
  /** The most a save from the Files tab may write. */
28
49
  export declare const MAX_WRITE_BYTES: number;
29
50
  /** `workspace.write`'s checked parameters: the file, as a project-relative path with `/`, and the bytes to save. */
@@ -3,9 +3,11 @@ import { createHash } from 'node:crypto';
3
3
  import { createReadStream } from 'node:fs';
4
4
  import { opendir, open, readFile, readdir, realpath, stat } from 'node:fs/promises';
5
5
  import { StringDecoder } from 'node:string_decoder';
6
- import { dirname, isAbsolute, join, matchesGlob as pathMatchesGlob, posix, relative, resolve, sep } from 'node:path';
6
+ import { dirname, extname, isAbsolute, join, posix, relative, resolve, sep } from 'node:path';
7
+ import { readTelemetryRunRecord } from './telemetry.js';
7
8
  import { runRecordPath, runRecordsDirectory, sessionHasOpenRun } from '../run-records.js';
8
9
  import { validSavedSession } from '../sessions.js';
10
+ import { decodeDoubleEscapedSummary, stripEchoedEnvelope } from '../completion.js';
9
11
  import { listBundles } from '../extensions.js';
10
12
  import { builtinSkillEntries } from '../skills/invocable-skills.js';
11
13
  const SKIP_NAMES = new Set(['.git', '.andorracode']);
@@ -162,6 +164,165 @@ export async function readWorkspaceFile(root, name) {
162
164
  await handle.close();
163
165
  }
164
166
  }
167
+ /** The image types the Files tab previews (`workspace.image`), by extension. */
168
+ const IMAGE_TYPES = {
169
+ '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.gif': 'image/gif', '.webp': 'image/webp',
170
+ '.bmp': 'image/bmp', '.ico': 'image/x-icon', '.svg': 'image/svg+xml',
171
+ };
172
+ /** The largest image the Files tab previews; a larger one keeps the binary note. */
173
+ export const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
174
+ export function imageTypeOf(path) {
175
+ return IMAGE_TYPES[extname(path).toLowerCase()];
176
+ }
177
+ /**
178
+ * An image path for the chat's preview of a Read, which may have looked at an image anywhere on this machine: resolved
179
+ * from the project, links followed, and not held to the project. The caller still accepts only an image file, judged
180
+ * by the followed path's extension, so a link named `.png` cannot reach a file of another kind.
181
+ */
182
+ async function resolveImageAnywhere(root, name) {
183
+ if (typeof name !== 'string' || !name || name.length > 4096 || name.includes('\0'))
184
+ throw new Error('An image path must be a string of up to 4096 characters');
185
+ const candidate = resolve(root, name);
186
+ return realpath(candidate).catch((error) => {
187
+ if (error.code === 'ENOENT')
188
+ return candidate;
189
+ throw error;
190
+ });
191
+ }
192
+ /**
193
+ * A project image's bytes, base64, for the Files tab's preview (`workspace.image`). `tooLarge` past 10 MB, with no
194
+ * bytes. The type comes from the extension only: the desktop draws it in an <img>, which never runs an SVG's script.
195
+ */
196
+ export async function readWorkspaceImage(root, name, options = {}) {
197
+ const path = options.outside ? await resolveImageAnywhere(root, name) : await resolveInside(root, name);
198
+ const mimeType = imageTypeOf(path);
199
+ if (!mimeType)
200
+ throw new Error('This file is not an image the Files tab can show');
201
+ const info = await stat(path);
202
+ if (!info.isFile())
203
+ throw new Error('Only files can be opened');
204
+ if (info.size > MAX_IMAGE_BYTES)
205
+ return { mimeType, size: info.size, tooLarge: true };
206
+ const bytes = await readFile(path);
207
+ if (bytes.length > MAX_IMAGE_BYTES)
208
+ return { mimeType, size: bytes.length, tooLarge: true };
209
+ return { mimeType, size: bytes.length, dataBase64: bytes.toString('base64') };
210
+ }
211
+ /**
212
+ * Whether a project path matches a glob as ripgrep's `--glob` does: `*` and `?` stay inside one folder, `**` crosses
213
+ * folders, `{a,b}` and `[…]` work, and a leading dot is matched like any other character (Node's matcher skips
214
+ * dotfiles, so the built-in search's globs missed `.eslintrc.js` and `.github/…`).
215
+ */
216
+ /** A path and each folder above it: `a/b/c.ts`, `a/b`, `a`. */
217
+ function withAncestors(path) {
218
+ const parts = path.split('/');
219
+ return parts.map((_, index) => parts.slice(0, parts.length - index).join('/'));
220
+ }
221
+ export function globMatches(path, glob) {
222
+ return globRegExp(glob).test(path);
223
+ }
224
+ const globCache = new Map();
225
+ const GLOB_CACHE_LIMIT = 500;
226
+ function globRegExp(raw) {
227
+ const cached = globCache.get(raw);
228
+ if (cached)
229
+ return cached;
230
+ // A leading slash anchors at the project, as every glob here already is; repeated `**/` mean one.
231
+ const glob = raw.replace(/^\/+/, '').replace(/(\*\*\/){2,}/g, '**/');
232
+ let out = '';
233
+ let braces = 0;
234
+ for (let index = 0; index < glob.length; index += 1) {
235
+ const char = glob[index];
236
+ if (char === '*') {
237
+ if (glob[index + 1] === '*') {
238
+ // `**` crosses folders only as a whole path part (`**/`, `/**`, or alone in an alternative); elsewhere, as in
239
+ // ripgrep, it is two `*`.
240
+ const before = index === 0 ? '/' : glob[index - 1];
241
+ const after = glob[index + 2] ?? '';
242
+ const whole = (before === '/' || (braces > 0 && (before === '{' || before === ','))) && (after === '' || after === '/' || (braces > 0 && (after === '}' || after === ',')));
243
+ if (whole && after === '/') {
244
+ out += '(?:.*/)?';
245
+ index += 2;
246
+ }
247
+ else if (whole) {
248
+ out += '.*';
249
+ index += 1;
250
+ }
251
+ else {
252
+ out += '[^/]*';
253
+ index += 1;
254
+ }
255
+ }
256
+ else
257
+ out += '[^/]*';
258
+ }
259
+ else if (char === '?')
260
+ out += '[^/]';
261
+ else if (char === '{') {
262
+ out += '(?:';
263
+ braces += 1;
264
+ }
265
+ else if (char === '}' && braces > 0) {
266
+ out += ')';
267
+ braces -= 1;
268
+ }
269
+ else if (char === ',' && braces > 0)
270
+ out += '|';
271
+ else if (char === '[') {
272
+ const end = glob.indexOf(']', index + 2);
273
+ if (end < 0) {
274
+ out += '\\[';
275
+ continue;
276
+ }
277
+ let body = glob.slice(index + 1, end);
278
+ if (body.startsWith('!'))
279
+ body = `^${body.slice(1)}`;
280
+ out += `[${body.replace(/\\/g, '\\\\')}]`;
281
+ index = end;
282
+ }
283
+ else if (char === '\\' && index + 1 < glob.length) {
284
+ out += glob[index + 1].replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
285
+ index += 1;
286
+ }
287
+ else
288
+ out += char.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&');
289
+ }
290
+ let pattern;
291
+ // Case-sensitive everywhere, as ripgrep's --glob is.
292
+ try {
293
+ pattern = new RegExp(`^${out}$`);
294
+ }
295
+ catch {
296
+ pattern = /(?!)/;
297
+ }
298
+ if (globCache.size >= GLOB_CACHE_LIMIT)
299
+ globCache.clear();
300
+ globCache.set(raw, pattern);
301
+ return pattern;
302
+ }
303
+ /**
304
+ * A glob list's problems ripgrep would refuse, said before a search: an unclosed `{`, or so many alternatives or
305
+ * `**` that matching could take seconds.
306
+ */
307
+ export function globProblem(glob) {
308
+ let depth = 0;
309
+ for (let index = 0; index < glob.length; index += 1) {
310
+ const char = glob[index];
311
+ if (char === '\\') {
312
+ index += 1;
313
+ continue;
314
+ }
315
+ if (char === '{')
316
+ depth += 1;
317
+ else if (char === '}' && depth > 0)
318
+ depth -= 1;
319
+ }
320
+ if (depth > 0)
321
+ return `The glob "${glob}" has an unclosed {`;
322
+ if ((glob.match(/\{/g) ?? []).length > 8 || (glob.match(/\*\*/g) ?? []).length > 8)
323
+ return `The glob "${glob}" is too complex to search with`;
324
+ return undefined;
325
+ }
165
326
  /** The most a save from the Files tab may write. */
166
327
  export const MAX_WRITE_BYTES = 16 * 1024 * 1024;
167
328
  /** `workspace.write`'s checked parameters: the file, as a project-relative path with `/`, and the bytes to save. */
@@ -560,12 +721,12 @@ async function readJournalTail(path, limit) {
560
721
  await handle?.close().catch(() => { });
561
722
  }
562
723
  }
563
- // Events that say which graph nodes and subagents ran. A long run's journal is read from its tail,
564
- // and without these the desktop's Graph list loses every node and subagent that started before the
565
- // newest events: a long run's entry node went missing that way.
724
+ // Keep graph and subagent metadata and answered questions from before the journal tail.
725
+ // The desktop uses these to restore the graph outline and inline question history.
566
726
  const OUTLINE_TYPES = [
567
727
  'graph.started', 'graph.node.started', 'graph.node.completed', 'graph.finalization.resumed', 'graph.completed', 'graph.stopped',
568
728
  'graph.todos.updated', 'graph.widgets.updated', 'subagent.started', 'subagent.completed', 'subagent.change',
729
+ 'agent.clarification.answered',
569
730
  ];
570
731
  // Journal lines are written as {"type":"…",…}, so a line is matched on its opening bytes.
571
732
  const OUTLINE_PREFIXES = OUTLINE_TYPES.map(type => Buffer.from(`{"type":"${type}"`));
@@ -672,11 +833,11 @@ async function readJournalOutline(path, end, collector) {
672
833
  }
673
834
  }
674
835
  // `events` is the newest part of the journal. When older events were left out, `outline` carries
675
- // the graph, node and subagent events among them, in journal order, so a reader can still tell
676
- // which nodes and subagents ran.
836
+ // selected graph, node, subagent and clarification events among them, in journal order.
677
837
  export async function readRun(directory, id) {
678
838
  const path = runRecordPath(directory, id, 'json');
679
- const result = JSON.parse(await readFile(path, 'utf8'));
839
+ const result = await readTelemetryRunRecord(directory, path);
840
+ displayRunCompletion(result);
680
841
  const journal = runRecordPath(directory, id, 'jsonl');
681
842
  const { lines, start, truncated } = await readJournalTail(journal, MAX_RUN_EVENTS);
682
843
  const parsed = [];
@@ -704,6 +865,20 @@ export async function readRun(directory, id) {
704
865
  const outline = collector.events();
705
866
  return { result, events, truncated, ...(outline.length > 0 ? { outline } : {}) };
706
867
  }
868
+ /** The record's completion summary is display text: restore line breaks its JSON escaped away, as saved sessions do. */
869
+ function displayRunCompletion(result) {
870
+ if (!result || typeof result !== 'object')
871
+ return;
872
+ const completion = result.completion;
873
+ if (!completion || typeof completion !== 'object')
874
+ return;
875
+ const record = completion;
876
+ if (typeof record.summary !== 'string')
877
+ return;
878
+ const summary = stripEchoedEnvelope(decodeDoubleEscapedSummary(record.summary), typeof record.outcome === 'string' ? record.outcome : undefined);
879
+ if (summary !== record.summary)
880
+ record.summary = summary;
881
+ }
707
882
  export async function runRecordFile(directory, id) {
708
883
  const path = resolve(runRecordPath(directory, id, 'json'));
709
884
  let raw;
@@ -1035,7 +1210,13 @@ export function globList(value) {
1035
1210
  current += char;
1036
1211
  }
1037
1212
  parts.push(current);
1038
- return parts.map(part => part.trim()).filter(Boolean);
1213
+ const globs = parts.map(part => part.trim()).filter(Boolean);
1214
+ for (const glob of globs) {
1215
+ const problem = globProblem(glob);
1216
+ if (problem)
1217
+ throw new Error(problem);
1218
+ }
1219
+ return globs;
1039
1220
  }
1040
1221
  export function searchOptions(params) {
1041
1222
  const query = params.query;
@@ -1219,7 +1400,7 @@ async function searchBuiltIn(root, options, signal) {
1219
1400
  const include = globList(options.include);
1220
1401
  const exclude = globList(options.exclude);
1221
1402
  // A glob without a folder matches the file's name anywhere, as ripgrep's --glob does.
1222
- const matchesGlob = (path, glob) => pathMatchesGlob(path, glob) || (!glob.includes('/') && pathMatchesGlob(posix.basename(path), glob));
1403
+ const matchesGlob = (path, glob) => globMatches(path, glob) || (!glob.includes('/') && globMatches(posix.basename(path), glob));
1223
1404
  const collected = new SearchCollector();
1224
1405
  const deadline = Date.now() + SEARCH_TIME_MS;
1225
1406
  let incomplete;
@@ -1234,7 +1415,8 @@ async function searchBuiltIn(root, options, signal) {
1234
1415
  continue;
1235
1416
  if (include.length && !include.some(glob => matchesGlob(file.path, glob)))
1236
1417
  continue;
1237
- if (exclude.some(glob => matchesGlob(file.path, glob)))
1418
+ // An exclude that names a folder leaves out everything in it, as ripgrep's does.
1419
+ if (exclude.some(glob => withAncestors(file.path).some(path => matchesGlob(path, glob))))
1238
1420
  continue;
1239
1421
  if (scanned >= SEARCH_FALLBACK_FILES) {
1240
1422
  incomplete = `Search stopped at ${SEARCH_FALLBACK_FILES.toLocaleString('en-US')} files`;