@andorra-labs/code 0.1.18 → 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 (277) 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 +347 -45
  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/hosted.d.ts +8 -0
  11. package/dist/src/andorra/hosted.js +22 -3
  12. package/dist/src/andorra/streams.d.ts +49 -0
  13. package/dist/src/andorra/streams.js +98 -0
  14. package/dist/src/antigravity-acp.d.ts +28 -0
  15. package/dist/src/antigravity-acp.js +150 -0
  16. package/dist/src/antigravity-terminal.d.ts +2 -0
  17. package/dist/src/antigravity-terminal.js +214 -0
  18. package/dist/src/app-server/adaptive-routing-settings.d.ts +37 -0
  19. package/dist/src/app-server/adaptive-routing-settings.js +69 -0
  20. package/dist/src/app-server/artifact.d.ts +14 -0
  21. package/dist/src/app-server/artifact.js +46 -0
  22. package/dist/src/app-server/legal-protocol.d.ts +33 -0
  23. package/dist/src/app-server/legal-protocol.js +16 -0
  24. package/dist/src/app-server/protocol.d.ts +23 -3
  25. package/dist/src/app-server/protocol.js +3 -1
  26. package/dist/src/app-server/telemetry-protocol.d.ts +53 -0
  27. package/dist/src/app-server/telemetry-protocol.js +2 -0
  28. package/dist/src/app-server/telemetry.d.ts +38 -0
  29. package/dist/src/app-server/telemetry.js +163 -0
  30. package/dist/src/app-server/workspace.d.ts +3 -1
  31. package/dist/src/app-server/workspace.js +39 -8
  32. package/dist/src/app-server.d.ts +50 -25
  33. package/dist/src/app-server.js +1008 -400
  34. package/dist/src/auth/AuthManager.d.ts +11 -2
  35. package/dist/src/auth/AuthManager.js +56 -13
  36. package/dist/src/auth/index.d.ts +5 -1
  37. package/dist/src/auth/index.js +8 -1
  38. package/dist/src/auth/lifecycle.d.ts +13 -0
  39. package/dist/src/auth/lifecycle.js +109 -0
  40. package/dist/src/auth/store.d.ts +1 -0
  41. package/dist/src/auth/store.js +12 -0
  42. package/dist/src/auth/types.d.ts +12 -0
  43. package/dist/src/automation-runner.js +2 -0
  44. package/dist/src/automation-service.js +7 -2
  45. package/dist/src/benchmark-scores.d.ts +88 -0
  46. package/dist/src/benchmark-scores.js +302 -0
  47. package/dist/src/bridge/command.js +4 -1
  48. package/dist/src/bridge/control.js +2 -1
  49. package/dist/src/bridge/engines.d.ts +2 -0
  50. package/dist/src/bridge/engines.js +9 -0
  51. package/dist/src/bridge/host-ops.d.ts +2 -2
  52. package/dist/src/bridge/host-ops.js +4 -2
  53. package/dist/src/bridge/host.d.ts +2 -0
  54. package/dist/src/bridge/host.js +63 -12
  55. package/dist/src/bridge/protocol.d.ts +1 -0
  56. package/dist/src/bridge/protocol.js +1 -0
  57. package/dist/src/browser-panel-tool.d.ts +12 -0
  58. package/dist/src/browser-panel-tool.js +30 -3
  59. package/dist/src/browser-runner.js +53 -62
  60. package/dist/src/browser-server.js +10 -4
  61. package/dist/src/browser-session.d.ts +14 -0
  62. package/dist/src/browser-session.js +57 -12
  63. package/dist/src/browser-view.d.ts +40 -1
  64. package/dist/src/browser-view.js +163 -9
  65. package/dist/src/browser-window-style.d.ts +27 -0
  66. package/dist/src/browser-window-style.js +244 -0
  67. package/dist/src/claude-provider.d.ts +1 -0
  68. package/dist/src/claude-provider.js +77 -36
  69. package/dist/src/cli.js +235 -58
  70. package/dist/src/codex-provider.d.ts +1 -0
  71. package/dist/src/codex-provider.js +43 -7
  72. package/dist/src/coding-tools.d.ts +1 -0
  73. package/dist/src/coding-tools.js +19 -5
  74. package/dist/src/command-screens.d.ts +1 -1
  75. package/dist/src/command-screens.js +2 -2
  76. package/dist/src/commands.d.ts +8 -1
  77. package/dist/src/commands.js +67 -63
  78. package/dist/src/completion.js +5 -3
  79. package/dist/src/config.d.ts +14 -3
  80. package/dist/src/config.js +54 -16
  81. package/dist/src/context-budget.d.ts +11 -2
  82. package/dist/src/context-budget.js +23 -2
  83. package/dist/src/context-compaction.d.ts +10 -8
  84. package/dist/src/context-compaction.js +23 -24
  85. package/dist/src/deadline.js +1 -1
  86. package/dist/src/decision/DecisionManager.d.ts +5 -0
  87. package/dist/src/decision/DecisionManager.js +39 -2
  88. package/dist/src/decision/applyToolMenu.js +6 -2
  89. package/dist/src/decision/hostedPolicy.js +6 -4
  90. package/dist/src/decision/optimizationPolicy.d.ts +10 -0
  91. package/dist/src/decision/optimizationPolicy.js +23 -3
  92. package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +2 -1
  93. package/dist/src/decision/providers/AndorraDecisionProvider.js +17 -7
  94. package/dist/src/decision/providers/index.js +1 -1
  95. package/dist/src/decision/toolFamilies.js +1 -1
  96. package/dist/src/decision/types.d.ts +2 -0
  97. package/dist/src/efficiency.d.ts +75 -1
  98. package/dist/src/efficiency.js +114 -3
  99. package/dist/src/extensions.d.ts +2 -0
  100. package/dist/src/extensions.js +30 -20
  101. package/dist/src/github-app/agent-writes.d.ts +1 -1
  102. package/dist/src/github-app/agent-writes.js +1 -1
  103. package/dist/src/github-app/event-source.d.ts +0 -5
  104. package/dist/src/github-app/event-source.js +1 -31
  105. package/dist/src/github-app/metrics.d.ts +2 -5
  106. package/dist/src/github-app/metrics.js +2 -14
  107. package/dist/src/github-app/review-loop.d.ts +5 -5
  108. package/dist/src/github-app/review-loop.js +1 -1
  109. package/dist/src/github-app/review-node.d.ts +2 -2
  110. package/dist/src/github-app/triggers.d.ts +3 -3
  111. package/dist/src/glob-search.d.ts +1 -0
  112. package/dist/src/glob-search.js +3 -0
  113. package/dist/src/google-provider.d.ts +5 -28
  114. package/dist/src/google-provider.js +6 -141
  115. package/dist/src/graph-editor-session.d.ts +1 -0
  116. package/dist/src/graph-editor-session.js +2 -0
  117. package/dist/src/graph-health.js +3 -1
  118. package/dist/src/graph-runner.js +19 -13
  119. package/dist/src/graph-selection.d.ts +3 -1
  120. package/dist/src/graph-selection.js +2 -2
  121. package/dist/src/graph-server.d.ts +8 -1
  122. package/dist/src/graph-server.js +45 -10
  123. package/dist/src/graph-sync.d.ts +2 -1
  124. package/dist/src/graph-sync.js +13 -0
  125. package/dist/src/graph-ui/app.js +19 -8
  126. package/dist/src/graph-ui/index.html +1 -1
  127. package/dist/src/graphs.d.ts +17 -1
  128. package/dist/src/graphs.js +51 -5
  129. package/dist/src/grok-provider.js +17 -14
  130. package/dist/src/hardened-runtime.js +7 -4
  131. package/dist/src/jev-savings.d.ts +4 -0
  132. package/dist/src/jev-savings.js +13 -0
  133. package/dist/src/legal/client.d.ts +25 -0
  134. package/dist/src/legal/client.js +47 -0
  135. package/dist/src/legal/command.d.ts +13 -0
  136. package/dist/src/legal/command.js +98 -0
  137. package/dist/src/legal/documents.d.ts +2 -0
  138. package/dist/src/legal/documents.js +14 -0
  139. package/dist/src/legal/gate.d.ts +13 -0
  140. package/dist/src/legal/gate.js +96 -0
  141. package/dist/src/legal/manifest.d.ts +21 -0
  142. package/dist/src/legal/manifest.js +23 -0
  143. package/dist/src/legal/receipt.d.ts +13 -0
  144. package/dist/src/legal/receipt.js +137 -0
  145. package/dist/src/legal/release.d.ts +27 -0
  146. package/dist/src/legal/release.js +28 -0
  147. package/dist/src/managed-sign-in.d.ts +0 -1
  148. package/dist/src/managed-sign-in.js +0 -13
  149. package/dist/src/membership.d.ts +27 -1
  150. package/dist/src/membership.js +139 -7
  151. package/dist/src/model-metadata.js +3 -7
  152. package/dist/src/model-pool.d.ts +99 -0
  153. package/dist/src/model-pool.js +136 -0
  154. package/dist/src/model-relay/local.js +5 -0
  155. package/dist/src/model-relay/remote.d.ts +2 -0
  156. package/dist/src/model-relay/remote.js +4 -0
  157. package/dist/src/model-tiers.d.ts +13 -1
  158. package/dist/src/model-tiers.js +28 -4
  159. package/dist/src/opencode-cli-provider.js +59 -56
  160. package/dist/src/opencode-provider.js +16 -13
  161. package/dist/src/permissions.d.ts +5 -0
  162. package/dist/src/permissions.js +7 -0
  163. package/dist/src/plan-pass.js +2 -1
  164. package/dist/src/pool-scores.d.ts +45 -0
  165. package/dist/src/pool-scores.js +40 -0
  166. package/dist/src/provider-connection.js +3 -17
  167. package/dist/src/provider-engine.js +42 -12
  168. package/dist/src/provider-request-error.d.ts +8 -0
  169. package/dist/src/provider-request-error.js +12 -0
  170. package/dist/src/provider-settings.d.ts +1 -1
  171. package/dist/src/provider-settings.js +36 -18
  172. package/dist/src/provider-turn-deadline.d.ts +39 -0
  173. package/dist/src/provider-turn-deadline.js +139 -0
  174. package/dist/src/providers.d.ts +3 -9
  175. package/dist/src/providers.js +181 -146
  176. package/dist/src/pull-request-merge.d.ts +1 -8
  177. package/dist/src/pull-request-merge.js +0 -4
  178. package/dist/src/pull-requests.d.ts +82 -66
  179. package/dist/src/pull-requests.js +266 -276
  180. package/dist/src/qa/runtime/ProcessManager.d.ts +5 -1
  181. package/dist/src/qa/runtime/ProcessManager.js +9 -3
  182. package/dist/src/react-runtime.js +147 -56
  183. package/dist/src/reasoning-probe-cloud.d.ts +10 -0
  184. package/dist/src/reasoning-probe-cloud.js +209 -0
  185. package/dist/src/remote/engine-pool.d.ts +3 -0
  186. package/dist/src/remote/engine-pool.js +85 -18
  187. package/dist/src/remote/recovery.d.ts +6 -0
  188. package/dist/src/remote/recovery.js +37 -0
  189. package/dist/src/run-records.d.ts +13 -3
  190. package/dist/src/run-records.js +59 -34
  191. package/dist/src/runtime.d.ts +18 -1
  192. package/dist/src/runtime.js +25 -7
  193. package/dist/src/session-summary.d.ts +8 -0
  194. package/dist/src/session-summary.js +34 -0
  195. package/dist/src/sessions.d.ts +8 -0
  196. package/dist/src/sessions.js +12 -3
  197. package/dist/src/shell.js +6 -0
  198. package/dist/src/side-panel.js +36 -2
  199. package/dist/src/sign-in-detection.d.ts +1 -1
  200. package/dist/src/sign-in-detection.js +4 -10
  201. package/dist/src/sign-in-offer.js +1 -1
  202. package/dist/src/skill-commands.js +1 -1
  203. package/dist/src/skills/bundled/graph-manager/SKILL.md +2 -2
  204. package/dist/src/skills/bundled/graph-manager/patterns.md +13 -19
  205. package/dist/src/skills/bundled/provenance.json +2 -2
  206. package/dist/src/subagent-run.js +50 -50
  207. package/dist/src/subscription-usage.d.ts +50 -0
  208. package/dist/src/subscription-usage.js +92 -0
  209. package/dist/src/task-checkout.d.ts +20 -4
  210. package/dist/src/task-checkout.js +78 -8
  211. package/dist/src/telemetry/access.d.ts +18 -0
  212. package/dist/src/telemetry/access.js +43 -0
  213. package/dist/src/telemetry/aggregate.d.ts +18 -2
  214. package/dist/src/telemetry/aggregate.js +22 -9
  215. package/dist/src/telemetry/capture-core.d.ts +33 -14
  216. package/dist/src/telemetry/capture-core.js +124 -25
  217. package/dist/src/telemetry/capture.d.ts +3 -2
  218. package/dist/src/telemetry/capture.js +21 -1
  219. package/dist/src/telemetry/decision-capture.js +4 -0
  220. package/dist/src/telemetry/emitter.d.ts +6 -7
  221. package/dist/src/telemetry/emitter.js +124 -29
  222. package/dist/src/telemetry/gate.d.ts +41 -2
  223. package/dist/src/telemetry/gate.js +89 -4
  224. package/dist/src/telemetry/home.d.ts +1 -0
  225. package/dist/src/telemetry/home.js +20 -0
  226. package/dist/src/telemetry/identity.d.ts +6 -3
  227. package/dist/src/telemetry/identity.js +19 -6
  228. package/dist/src/telemetry/lifecycle.d.ts +8 -0
  229. package/dist/src/telemetry/lifecycle.js +76 -0
  230. package/dist/src/telemetry/outbox.d.ts +13 -8
  231. package/dist/src/telemetry/outbox.js +68 -12
  232. package/dist/src/telemetry/permission-command.d.ts +38 -0
  233. package/dist/src/telemetry/permission-command.js +208 -0
  234. package/dist/src/telemetry/permission.d.ts +168 -0
  235. package/dist/src/telemetry/permission.js +662 -0
  236. package/dist/src/telemetry/record-installation.d.ts +1 -0
  237. package/dist/src/telemetry/record-installation.js +9 -0
  238. package/dist/src/telemetry/region-data.d.ts +12 -0
  239. package/dist/src/telemetry/region-data.js +1314 -0
  240. package/dist/src/telemetry/region.d.ts +34 -0
  241. package/dist/src/telemetry/region.js +87 -0
  242. package/dist/src/telemetry/run-privacy.d.ts +11 -0
  243. package/dist/src/telemetry/run-privacy.js +165 -0
  244. package/dist/src/telemetry/schema.d.ts +27 -6
  245. package/dist/src/telemetry/schema.js +109 -14
  246. package/dist/src/telemetry/state.d.ts +11 -7
  247. package/dist/src/telemetry/state.js +39 -6
  248. package/dist/src/telemetry/surface.d.ts +20 -3
  249. package/dist/src/telemetry/surface.js +71 -15
  250. package/dist/src/telemetry/uploader.d.ts +6 -11
  251. package/dist/src/telemetry/uploader.js +72 -46
  252. package/dist/src/telemetry/uploads.d.ts +5 -1
  253. package/dist/src/telemetry/uploads.js +25 -6
  254. package/dist/src/telemetry/version.d.ts +5 -0
  255. package/dist/src/telemetry/version.js +34 -0
  256. package/dist/src/telemetry/workspace.d.ts +4 -1
  257. package/dist/src/telemetry/workspace.js +18 -3
  258. package/dist/src/terminal-ui.d.ts +3 -0
  259. package/dist/src/terminal-ui.js +48 -6
  260. package/dist/src/thinking-level-detect.d.ts +3 -1
  261. package/dist/src/thinking-level-detect.js +8 -3
  262. package/dist/src/thinking-levels.d.ts +1 -1
  263. package/dist/src/thinking-levels.js +11 -4
  264. package/dist/src/timers.d.ts +2 -0
  265. package/dist/src/todos.d.ts +2 -1
  266. package/dist/src/todos.js +24 -4
  267. package/dist/src/tool-argument-coercion.d.ts +7 -0
  268. package/dist/src/tool-argument-coercion.js +49 -0
  269. package/dist/src/tool-catalog.d.ts +2 -2
  270. package/dist/src/tools.js +67 -22
  271. package/dist/src/transcript.js +2 -1
  272. package/dist/src/types.d.ts +14 -1
  273. package/dist/src/update.js +4 -0
  274. package/dist/src/usage-analytics.d.ts +7 -0
  275. package/dist/src/usage-analytics.js +85 -13
  276. package/dist/telemetry-consent-v1 +1 -0
  277. package/package.json +97 -96
@@ -0,0 +1,302 @@
1
+ import { POOL_EFFORTS, poolScoreKey } from './efficiency.js';
2
+ export const BENCHMARK_NAMES = {
3
+ 'artificial-analysis': 'Artificial Analysis Intelligence Index', livebench: 'LiveBench overall', lmarena: 'LMArena overall text rating',
4
+ };
5
+ /** The benchmark whose scale the average is expressed on. Without it there are no scores. */
6
+ export const REFERENCE_BENCHMARK = 'artificial-analysis';
7
+ /** A benchmark is fitted onto the reference scale only when at least this many of its entries are listed by both. */
8
+ const MIN_COMMON_ENTRIES = 5;
9
+ const mean = (values) => values.reduce((sum, value) => sum + value, 0) / values.length;
10
+ const tenth = (value) => Math.round(value * 10) / 10;
11
+ const finite = (value) => typeof value === 'number' && Number.isFinite(value);
12
+ /** A model name as every source can be compared: no provider prefix, no trailing date, letters and digits only. */
13
+ export function modelKey(name) {
14
+ return name.toLowerCase().replace(/^.*\//, '').replace(/[-_ ]?20\d{6}$/, '').replace(/[^a-z0-9]/g, '');
15
+ }
16
+ const LEVEL_WORDS = { 'non-reasoning': 'none', 'no reasoning': 'none', 'no thinking': 'none' };
17
+ const levelOf = (word) => Object.hasOwn(LEVEL_WORDS, word) ? LEVEL_WORDS[word] : POOL_EFFORTS.includes(word) ? word : undefined;
18
+ /**
19
+ * The model and thinking level in a leaderboard name such as "GPT-6.2 Astra (Xhigh)". A name whose brackets hold
20
+ * anything but a level, a date or a size is another variant of the model and is left out.
21
+ */
22
+ export function listedModel(name) {
23
+ const match = /^(.*?)\s*\(([^()]*)\)\s*$/.exec(name.trim());
24
+ let effort;
25
+ for (const raw of match ? match[2].split(',') : []) {
26
+ const word = raw.trim().toLowerCase();
27
+ const level = levelOf(word);
28
+ if (level)
29
+ effort = level;
30
+ else if (!/^(\d{6,8}|\d+k|default fallback|thinking|reasoning)$/.test(word))
31
+ return undefined;
32
+ }
33
+ const key = modelKey(match ? match[1] : name);
34
+ return key ? { key, ...(effort ? { effort } : {}) } : undefined;
35
+ }
36
+ /** The models in the Artificial Analysis leaderboard page, which carries its table as data inside the page. */
37
+ export function parseArtificialAnalysis(html) {
38
+ const text = html.replaceAll('\\"', '"');
39
+ const starts = [...text.matchAll(/"name":"([^"]{1,160})","shortName":"/g)];
40
+ const entries = [];
41
+ const seen = new Set();
42
+ starts.forEach((start, index) => {
43
+ // A record runs to the start of the next one, so a figure is never read from a neighbour.
44
+ const record = text.slice(start.index, starts[index + 1]?.index ?? start.index + 12_000);
45
+ const score = Number(/"intelligenceIndex":(-?[\d.]+)/.exec(record)?.[1]);
46
+ const model = listedModel(start[1]);
47
+ if (!model || !Number.isFinite(score))
48
+ return;
49
+ const id = `${model.key}\u0000${model.effort ?? ''}`;
50
+ if (seen.has(id))
51
+ return;
52
+ seen.add(id);
53
+ const cost = Number(/"intelligenceIndexCostPerTask":(-?[\d.]+)/.exec(record)?.[1]);
54
+ entries.push({ ...model, score, ...(Number.isFinite(cost) && cost >= 0 ? { cost: cost * 100 } : {}) });
55
+ });
56
+ return entries;
57
+ }
58
+ /** The models in a LiveBench release table. The overall score is the weighted mean of the categories, as the site computes it. */
59
+ export function parseLiveBench(table, categories, costs = '') {
60
+ const lines = table.split(/\r?\n/).filter(line => line.trim());
61
+ const header = (lines[0] ?? '').split(',').map(cell => cell.trim());
62
+ if (header[0] !== 'model')
63
+ return [];
64
+ let groups = [];
65
+ try {
66
+ const parsed = JSON.parse(categories);
67
+ const weights = parsed._overall_weights && typeof parsed._overall_weights === 'object' ? parsed._overall_weights : {};
68
+ groups = Object.entries(parsed).flatMap(([name, columns]) => {
69
+ const listed = Array.isArray(columns) ? columns.filter((column) => typeof column === 'string' && header.includes(column)) : [];
70
+ const weight = Object.hasOwn(weights, name) ? weights[name] : 1;
71
+ return listed.length ? [{ columns: listed, weight: finite(weight) && weight > 0 ? weight : 1 }] : [];
72
+ });
73
+ }
74
+ catch { /* an unreadable category file leaves every column weighted alike */ }
75
+ if (!groups.length)
76
+ groups = header.slice(1).map(column => ({ columns: [column], weight: 1 }));
77
+ // The release's cost file gives what each category cost to run; a model's cost is their sum, in the file's own unit.
78
+ const costLines = costs.split(/\r?\n/).filter(line => line.trim());
79
+ const costHeader = (costLines[0] ?? '').split(',').map(cell => cell.trim());
80
+ const costOf = new Map();
81
+ if (costHeader[0] === 'model') {
82
+ for (const line of costLines.slice(1)) {
83
+ const cells = line.split(',').map(cell => cell.trim());
84
+ const values = header.slice(1).map(column => costHeader.indexOf(column)).filter(at => at > 0)
85
+ .map(at => Number(cells[at] || NaN)).filter(value => Number.isFinite(value) && value >= 0);
86
+ if (cells[0] && values.length)
87
+ costOf.set(cells[0], values.reduce((sum, value) => sum + value, 0));
88
+ }
89
+ }
90
+ return lines.slice(1).flatMap((line) => {
91
+ const cells = line.split(',').map(cell => cell.trim());
92
+ const name = cells[0] ?? '';
93
+ const level = /^(.*)-(none|minimal|low|medium|high|xhigh|max)$/.exec(name);
94
+ const key = modelKey(level ? level[1] : name);
95
+ let total = 0;
96
+ let weight = 0;
97
+ for (const group of groups) {
98
+ const values = group.columns.map(column => Number(cells[header.indexOf(column)] || NaN)).filter(Number.isFinite);
99
+ if (!values.length)
100
+ continue;
101
+ total += mean(values) * group.weight;
102
+ weight += group.weight;
103
+ }
104
+ const cost = costOf.get(name);
105
+ return key && weight > 0 ? [{ key, ...(level ? { effort: level[2] } : {}), score: total / weight, ...(cost !== undefined && cost > 0 ? { cost } : {}) }] : [];
106
+ });
107
+ }
108
+ /** The models in LMArena's leaderboard rows, from the overall category only. */
109
+ export function parseLmArena(rows) {
110
+ const entries = [];
111
+ const seen = new Set();
112
+ for (const row of rows) {
113
+ if (!row || typeof row !== 'object')
114
+ continue;
115
+ const { model_name: name, rating, category } = row;
116
+ if (typeof name !== 'string' || !finite(rating) || category !== 'overall')
117
+ continue;
118
+ const model = listedModel(name);
119
+ const id = model ? `${model.key}\u0000${model.effort ?? ''}` : '';
120
+ if (!model || seen.has(id))
121
+ continue;
122
+ seen.add(id);
123
+ entries.push({ ...model, score: rating });
124
+ }
125
+ return entries;
126
+ }
127
+ function byModel(entries) {
128
+ const models = new Map();
129
+ for (const entry of entries)
130
+ models.set(entry.key, [...(models.get(entry.key) ?? []), entry]);
131
+ return models;
132
+ }
133
+ /** A model's figure at a level: the level as listed, else the entry with no level, else the mean of its levels. */
134
+ function figureAt(list, effort, figure) {
135
+ const having = list.filter(entry => entry[figure] !== undefined);
136
+ if (!having.length)
137
+ return undefined;
138
+ const chosen = having.find(entry => entry.effort === effort) ?? having.find(entry => entry.effort === undefined);
139
+ return chosen ? chosen[figure] : mean(having.map(entry => entry[figure]));
140
+ }
141
+ /**
142
+ * The straight line that turns a benchmark's scores into reference scores: over the entries both list, it gives the
143
+ * benchmark the reference's mean and spread. (A least-squares line would pull every score toward the middle wherever
144
+ * the two disagree.) Undefined when too few are shared or the two do not rise together.
145
+ */
146
+ export function fitToReference(source, reference) {
147
+ const models = byModel(reference);
148
+ const xs = [];
149
+ const ys = [];
150
+ for (const entry of source) {
151
+ const list = models.get(entry.key);
152
+ if (!list || (entry.effort !== undefined && !list.some(item => item.effort === entry.effort)))
153
+ continue;
154
+ xs.push(entry.score);
155
+ ys.push(figureAt(list, entry.effort, 'score'));
156
+ }
157
+ if (xs.length < MIN_COMMON_ENTRIES)
158
+ return undefined;
159
+ const mx = mean(xs);
160
+ const my = mean(ys);
161
+ let sxx = 0;
162
+ let syy = 0;
163
+ let sxy = 0;
164
+ xs.forEach((x, index) => { sxx += (x - mx) ** 2; syy += (ys[index] - my) ** 2; sxy += (x - mx) * (ys[index] - my); });
165
+ if (!(sxx > 0 && syy > 0 && sxy > 0))
166
+ return undefined;
167
+ const slope = Math.sqrt(syy / sxx);
168
+ return { slope, intercept: my - slope * mx, common: xs.length };
169
+ }
170
+ /**
171
+ * What one unit of a benchmark's cost is worth in reference cost: the median ratio over the entries both give a cost
172
+ * for. Undefined when too few do, and then that benchmark's costs are not used.
173
+ */
174
+ function costRate(source, reference) {
175
+ const models = byModel(reference);
176
+ const ratios = source.flatMap(entry => {
177
+ const list = models.get(entry.key);
178
+ const cost = list ? figureAt(list, entry.effort, 'cost') : undefined;
179
+ return entry.cost !== undefined && entry.cost > 0 && cost !== undefined && cost > 0 ? [cost / entry.cost] : [];
180
+ }).sort((a, b) => a - b);
181
+ return ratios.length >= MIN_COMMON_ENTRIES ? ratios[Math.floor(ratios.length / 2)] : undefined;
182
+ }
183
+ /**
184
+ * Scores for the subjects the benchmarks list, keyed `provider/model`. A model the reference does not price takes its
185
+ * cost from another benchmark, converted to the reference's unit. A model's score is the mean over the
186
+ * benchmarks that list it; a thinking level is scored on its own when at least one benchmark lists that level, and a
187
+ * benchmark that does not list the level contributes its score for the model.
188
+ */
189
+ export function benchmarkScores(subjects, benchmarks) {
190
+ const reference = benchmarks.find(item => item.id === REFERENCE_BENCHMARK);
191
+ if (!reference?.entries.length)
192
+ throw new Error(`${BENCHMARK_NAMES[REFERENCE_BENCHMARK]} could not be read, and the other scores are expressed on its scale.`);
193
+ const scaled = [];
194
+ const report = [];
195
+ for (const benchmark of benchmarks) {
196
+ const described = { id: benchmark.id, name: BENCHMARK_NAMES[benchmark.id], listed: benchmark.entries.length };
197
+ if (benchmark.id === REFERENCE_BENCHMARK) {
198
+ scaled.push({ id: benchmark.id, models: byModel(benchmark.entries) });
199
+ report.push({ ...described, used: true });
200
+ continue;
201
+ }
202
+ const fit = fitToReference(benchmark.entries, reference.entries);
203
+ if (!fit) {
204
+ report.push({ ...described, used: false, reason: 'too few models in common with the reference to compare scales' });
205
+ continue;
206
+ }
207
+ const rate = costRate(benchmark.entries, reference.entries);
208
+ scaled.push({ id: benchmark.id, models: byModel(benchmark.entries.map(({ cost, ...entry }) => ({ ...entry, score: Math.min(100, Math.max(0, fit.intercept + fit.slope * entry.score)),
209
+ ...(cost !== undefined && rate !== undefined ? { cost: cost * rate } : {}) }))) });
210
+ report.push({ ...described, used: true, common: fit.common });
211
+ }
212
+ const scores = {};
213
+ for (const subject of subjects) {
214
+ const keys = [...new Set([modelKey(subject.model), ...(subject.name ? [modelKey(subject.name)] : [])])].filter(Boolean);
215
+ const listed = scaled.flatMap(source => {
216
+ const list = keys.map(key => source.models.get(key)).find(found => found !== undefined);
217
+ return list ? [list] : [];
218
+ });
219
+ if (!listed.length)
220
+ continue;
221
+ const pair = (effort) => {
222
+ const cost = listed.map(list => figureAt(list, effort, 'cost')).find(finite);
223
+ return { quality: tenth(mean(listed.map(list => figureAt(list, effort, 'score')))), ...(cost === undefined ? {} : { cost: tenth(cost) }) };
224
+ };
225
+ const efforts = {};
226
+ for (const effort of subject.efforts)
227
+ if (listed.some(list => list.some(entry => entry.effort === effort)))
228
+ efforts[effort] = pair(effort);
229
+ scores[poolScoreKey(subject.provider, subject.model)] = { ...pair(undefined), ...(Object.keys(efforts).length ? { efforts } : {}) };
230
+ }
231
+ return { scores, report };
232
+ }
233
+ const ARTIFICIAL_ANALYSIS_URL = 'https://artificialanalysis.ai/leaderboards/models';
234
+ const LIVEBENCH_URL = 'https://livebench.ai/';
235
+ const LMARENA_ROWS_URL = 'https://datasets-server.huggingface.co/filter';
236
+ const SOURCE_TIMEOUT_MS = 60_000;
237
+ const LMARENA_PAGE = 100;
238
+ const LMARENA_MAX_PAGES = 20;
239
+ async function page(url, signal, fetcher) {
240
+ const response = await fetcher(url, { signal, headers: { 'user-agent': 'Mozilla/5.0 (compatible; AndorraCode)', accept: '*/*' } });
241
+ if (!response.ok)
242
+ throw new Error(`${new URL(url).host} answered ${response.status}`);
243
+ return response.text();
244
+ }
245
+ async function readLiveBench(signal, fetcher) {
246
+ // The site names its releases inside its script, newest last; each release has its own table.
247
+ const script = /static\/js\/main\.[\w.-]+\.js/.exec(await page(LIVEBENCH_URL, signal, fetcher))?.[0];
248
+ if (!script)
249
+ throw new Error('livebench.ai no longer names its script');
250
+ const bundle = await page(`${LIVEBENCH_URL}${script}`, signal, fetcher);
251
+ const releases = [...new Set([...bundle.matchAll(/"(20\d{6})"/g)].map(match => match[1]))].sort().reverse().slice(0, 4);
252
+ for (const release of releases) {
253
+ try {
254
+ const table = await page(`${LIVEBENCH_URL}data/${release}/table.csv`, signal, fetcher);
255
+ const categories = await page(`${LIVEBENCH_URL}data/${release}/categories.json`, signal, fetcher).catch(() => { signal.throwIfAborted(); return '{}'; });
256
+ const costs = await page(`${LIVEBENCH_URL}data/${release}/cost.csv`, signal, fetcher).catch(() => { signal.throwIfAborted(); return ''; });
257
+ const entries = parseLiveBench(table, categories, costs);
258
+ if (entries.length)
259
+ return entries;
260
+ }
261
+ catch {
262
+ signal.throwIfAborted();
263
+ }
264
+ }
265
+ throw new Error('livebench.ai lists no release table');
266
+ }
267
+ async function readLmArena(signal, fetcher) {
268
+ const rows = [];
269
+ for (let index = 0; index < LMARENA_MAX_PAGES; index++) {
270
+ const query = new URLSearchParams({ dataset: 'lmarena-ai/leaderboard-dataset', config: 'text', split: 'latest', where: `"category"='overall'`, offset: String(index * LMARENA_PAGE), length: String(LMARENA_PAGE) });
271
+ const answer = JSON.parse(await page(`${LMARENA_ROWS_URL}?${query}`, signal, fetcher));
272
+ const received = answer.rows ?? [];
273
+ rows.push(...received.map(item => item.row));
274
+ if (received.length < LMARENA_PAGE || rows.length >= (answer.num_rows_total ?? Infinity))
275
+ break;
276
+ }
277
+ return parseLmArena(rows);
278
+ }
279
+ /** Read the three benchmarks. One that cannot be read is reported in `failed` and never fails the others. */
280
+ export async function readBenchmarks(signal, fetcher = (url, init) => fetch(url, init)) {
281
+ const sources = {
282
+ 'artificial-analysis': async (bounded) => parseArtificialAnalysis(await page(ARTIFICIAL_ANALYSIS_URL, bounded, fetcher)),
283
+ livebench: bounded => readLiveBench(bounded, fetcher),
284
+ lmarena: bounded => readLmArena(bounded, fetcher),
285
+ };
286
+ const reading = { benchmarks: [], failed: [] };
287
+ await Promise.all(Object.keys(sources).map(async (id) => {
288
+ try {
289
+ const entries = await sources[id](AbortSignal.any([signal, AbortSignal.timeout(SOURCE_TIMEOUT_MS)]));
290
+ if (!entries.length)
291
+ throw new Error('no model scores were found in its answer');
292
+ reading.benchmarks.push({ id, entries });
293
+ }
294
+ catch (error) {
295
+ signal.throwIfAborted();
296
+ reading.failed.push({ id, name: BENCHMARK_NAMES[id], listed: 0, used: false, reason: error instanceof Error ? error.message : String(error) });
297
+ }
298
+ }));
299
+ const order = Object.keys(sources);
300
+ reading.benchmarks.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
301
+ return reading;
302
+ }
@@ -247,7 +247,10 @@ async function run(print, apiBase, dependencies) {
247
247
  },
248
248
  signal: controller.signal,
249
249
  log: print,
250
- ...(process.env.ANDORRA_CLOUD === '1' ? { heartbeat: activity => heartbeat(apiBase, identity.environmentId, identity.secret, activity) } : {}),
250
+ ...(process.env.ANDORRA_CLOUD === '1' ? {
251
+ heartbeat: activity => heartbeat(apiBase, identity.environmentId, identity.secret, activity),
252
+ cloudUpdates: engines !== undefined,
253
+ } : {}),
251
254
  ...(engines ? { engines } : {}),
252
255
  ...(launcherAlive ? { launcherAlive } : {}),
253
256
  });
@@ -170,7 +170,8 @@ const CLOUD_REFUSALS = {
170
170
  invalid_version: { status: 400, code: 'invalid_version', message: 'This version of Andorra Code cannot start Cloud. Update Andorra Code and try again.' },
171
171
  };
172
172
  const CLOUD_STATES = ['none', 'starting', 'running', 'stopping', 'stopped'];
173
- const CLOUD_LABEL = /^Andorra-Code-Cloud-[1-9][0-9]{9}$/;
173
+ // The last group of the user's id, or the numbered name of a Cloud made before names came from it.
174
+ const CLOUD_LABEL = /^(?:[0-9a-f]{12}|Andorra-Code-Cloud-[1-9][0-9]{9})$/;
174
175
  const CLOUD_ENVIRONMENT_ID = /^env_[A-Za-z0-9_-]{22}$/;
175
176
  const CLOUD_VERSION = /^\d{1,4}\.\d{1,4}\.\d{1,4}$/;
176
177
  const ISO_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?(Z|[+-]\d{2}:\d{2})$/;
@@ -48,6 +48,8 @@ export interface EngineStore extends RelayEngines {
48
48
  } | undefined;
49
49
  /** Whether that version is installed and ready to start. */
50
50
  installed(version: string): Promise<boolean>;
51
+ /** The stable release of the CLI on the public npm registry, if it answers. */
52
+ latestRelease(): Promise<string | undefined>;
51
53
  /** Installs under way or waiting for a slot in this process. */
52
54
  installing(): number;
53
55
  /** Names the version the launcher should start as the next host, and records when it was asked for in last-host-request. */
@@ -12,6 +12,7 @@ export const PACKAGE_NAME = '@andorra-labs/code';
12
12
  export const MIN_ENGINE_VERSION = '0.1.16';
13
13
  export const MAX_ENGINE_VERSIONS = 3;
14
14
  export const ENGINE_INSTALL_TIMEOUT_MS = 300_000;
15
+ const RELEASE_CHECK_TIMEOUT_MS = 5_000;
15
16
  /** The exit code with which a host asks the launcher to start it again as the version in next-host-version. */
16
17
  export const HOST_RESTART_EXIT_CODE = 75;
17
18
  export const MAX_CONCURRENT_INSTALLS = 2;
@@ -507,6 +508,14 @@ export function createEngineStore(options) {
507
508
  const installQueueFull = () => new EngineStoreError('busy', 'This machine is busy installing other versions of Andorra Code. Try again in a moment.');
508
509
  return {
509
510
  hostVersion,
511
+ async latestRelease() {
512
+ const { program, prefix } = await npmProgram();
513
+ const result = await run(program, [
514
+ ...prefix, 'view', `${PACKAGE_NAME}@latest`, 'version', '--prefer-online', '--registry=https://registry.npmjs.org',
515
+ ], root, RELEASE_CHECK_TIMEOUT_MS);
516
+ const version = result.stdout.trim();
517
+ return result.code === 0 && !result.timedOut && acceptable(version) ? version : undefined;
518
+ },
510
519
  async commandFor(version) {
511
520
  if (version === undefined || version === hostVersion)
512
521
  return hostCommand();
@@ -1,4 +1,4 @@
1
- import type { Host } from './protocol.js';
1
+ import { type Host } from './protocol.js';
2
2
  export declare const BROWSE_ENTRY_CAP = 1000;
3
3
  export type HostOperationName = 'whoami' | 'projects' | 'roots' | 'browse' | 'owner.roots' | 'owner.browse' | 'owner.projects.add' | 'owner.github.clone';
4
4
  export type HostOperationErrorCode = 'not-found' | 'invalid-params' | 'forbidden';
@@ -6,4 +6,4 @@ export declare class HostOperationError extends Error {
6
6
  readonly code: HostOperationErrorCode;
7
7
  constructor(code: HostOperationErrorCode, message: string);
8
8
  }
9
- export declare function hostOperation(directory: string, op: HostOperationName, params: Record<string, unknown>, host: Host): Promise<unknown>;
9
+ export declare function hostOperation(directory: string, op: HostOperationName, params: Record<string, unknown>, host: Host, cloudUpdates?: boolean): Promise<unknown>;
@@ -4,6 +4,7 @@ import { loadConfig } from '../config.js';
4
4
  import { addProjectEntry } from '../project-registry.js';
5
5
  import { authorizedRoots, directoryInsideFolders, projectRootId, sharedFolders } from '../remote/roots.js';
6
6
  import { RELAY_CAPABILITY_REQUIREMENT } from '../remote/engine-pool.js';
7
+ import { CLOUD_BRIDGE_AUTO_UPDATE } from './protocol.js';
7
8
  import { cloneDependenciesFromEnvironment, cloneRepository } from './github.js';
8
9
  import { bridgeCommand } from './wording.js';
9
10
  export const BROWSE_ENTRY_CAP = 1000;
@@ -47,13 +48,14 @@ async function sharedDirectory(directory, path, missing) {
47
48
  throw new HostOperationError('forbidden', outsideFolders());
48
49
  return found.path;
49
50
  }
50
- export async function hostOperation(directory, op, params, host) {
51
+ export async function hostOperation(directory, op, params, host, cloudUpdates = false) {
51
52
  switch (op) {
52
53
  case 'whoami': {
53
54
  const { APP_SERVER_CAPABILITIES } = await import('../app-server/protocol.js');
54
55
  return {
55
56
  hostname: host.hostname, platform: host.platform, version: host.version, grant: 'full', relay: true,
56
- capabilities: [...new Set([...APP_SERVER_CAPABILITIES, 'remote.engine.relay', RELAY_CAPABILITY_REQUIREMENT, 'remote.github.clone'])],
57
+ capabilities: [...new Set([...APP_SERVER_CAPABILITIES, 'remote.engine.relay', RELAY_CAPABILITY_REQUIREMENT, 'remote.github.clone',
58
+ ...(cloudUpdates ? [CLOUD_BRIDGE_AUTO_UPDATE] : [])])],
57
59
  };
58
60
  }
59
61
  case 'projects': {
@@ -33,6 +33,8 @@ export interface BridgeHostOptions {
33
33
  heartbeat?: (activity: BridgeActivity) => Promise<void>;
34
34
  /** The launcher's engine store: present only when the bridge launcher started this host. */
35
35
  engines?: EngineStore;
36
+ /** Managed Cloud hosts follow the published release before accepting new work. */
37
+ cloudUpdates?: boolean;
36
38
  /** Whether the launcher that started this host is still running; the host stops once it is not. */
37
39
  launcherAlive?: () => boolean;
38
40
  launcherCheckMs?: number;
@@ -3,7 +3,7 @@ import { RemoteEngineRelay } from '../remote/engine-pool.js';
3
3
  import { MODEL_RELAY_CONNECTION_PREFIX } from '../model-relay/wire.js';
4
4
  import { HEARTBEAT_MS } from './cloud.js';
5
5
  import { ControlError } from './control.js';
6
- import { compareVersions } from './engines.js';
6
+ import { compareVersions, validVersion } from './engines.js';
7
7
  import { clonesRunning } from './github.js';
8
8
  import { hostOperation, HostOperationError } from './host-ops.js';
9
9
  import { CLIENT_DEAD_MS, CLIENT_PING_MS, CLOSE, MAX_FRAME_BYTES, PROTOCOL_VERSION } from './protocol.js';
@@ -23,6 +23,8 @@ export const HOST_REQUEST_HOLD_MS = 10 * 60_000;
23
23
  export const MAX_NEWER_VERSIONS = 4;
24
24
  export const RESTARTING_MESSAGE = 'This machine is restarting to update Andorra Code. Try again in a moment.';
25
25
  const TASK_START_METHODS = new Set(['run.start', 'run.resume']);
26
+ const CLOUD_RELEASE_CHECK_MS = 60_000;
27
+ const CLOUD_RELEASE_RETRY_MS = 15_000;
26
28
  const HOST_OPERATIONS = new Set(['whoami', 'projects', 'roots', 'browse', 'owner.roots', 'owner.browse', 'owner.projects.add', 'owner.github.clone']);
27
29
  export const hostDependencies = {
28
30
  createRelay: (directory, engines) => new RemoteEngineRelay(directory, {}, engines ? { engines } : {}),
@@ -154,6 +156,9 @@ export async function runBridgeHost(hostOptions) {
154
156
  // Only the highest MAX_NEWER_VERSIONS are kept, so a desktop naming made-up versions cannot grow the set.
155
157
  const newer = new Set();
156
158
  const now = options.now ?? Date.now;
159
+ let releaseVersion;
160
+ let releaseCheck;
161
+ let releaseCheckAfter = 0;
157
162
  // A host started for a restart it asked for, but running another version (the launcher could not start that one),
158
163
  // does not ask for the same version again at once: the launcher would fall back again and again.
159
164
  let held;
@@ -183,14 +188,16 @@ export async function runBridgeHost(hostOptions) {
183
188
  };
184
189
  const checkRestart = async () => {
185
190
  const engines = options.engines;
186
- if (!engines || restarting || signal.aborted || newer.size === 0)
191
+ const candidates = options.cloudUpdates ? (releaseVersion ? [releaseVersion] : []) : newer;
192
+ if (!engines || restarting || signal.aborted)
187
193
  return;
188
194
  if (busyHere() || relay.runningTasks() > 0 || engines.installing() > 0)
189
195
  return;
190
196
  const installed = [];
191
- for (const version of newer)
192
- if (await engines.installed(version))
197
+ for (const version of candidates) {
198
+ if (compareVersions(version, options.version) > 0 && await engines.installed(version))
193
199
  installed.push(version);
200
+ }
194
201
  if (installed.length === 0)
195
202
  return;
196
203
  const next = installed.sort(compareVersions).at(-1);
@@ -208,6 +215,8 @@ export async function runBridgeHost(hostOptions) {
208
215
  }
209
216
  catch (error) {
210
217
  restarting = false;
218
+ if (options.cloudUpdates)
219
+ held = { version: next, until: now() + HOST_REQUEST_HOLD_MS };
211
220
  log(`Could not hand this bridge over to Andorra Code ${next}: ${error instanceof Error ? error.message : String(error)}`);
212
221
  return;
213
222
  }
@@ -220,7 +229,7 @@ export async function runBridgeHost(hostOptions) {
220
229
  stopped.abort();
221
230
  };
222
231
  const noteVersion = (version) => {
223
- if (!options.engines || compareVersions(version, options.version) <= 0 || !ENGINE_VERSION.test(options.version))
232
+ if (options.cloudUpdates || !options.engines || compareVersions(version, options.version) <= 0 || !ENGINE_VERSION.test(options.version))
224
233
  return;
225
234
  newer.add(version);
226
235
  if (newer.size > MAX_NEWER_VERSIONS)
@@ -242,7 +251,46 @@ export async function runBridgeHost(hostOptions) {
242
251
  answering -= 1;
243
252
  }
244
253
  };
245
- const watch = { noteVersion, settled: () => { void restartIfIdle(); }, restarting: () => restarting, answer };
254
+ const updatingBeforeTask = async () => {
255
+ const engines = options.engines;
256
+ if (restarting || !options.cloudUpdates || !engines)
257
+ return restarting;
258
+ if (now() >= releaseCheckAfter) {
259
+ releaseCheck ??= (async () => {
260
+ let version;
261
+ try {
262
+ version = await engines.latestRelease();
263
+ }
264
+ catch { /* Keep serving the current release. */ }
265
+ releaseVersion = validVersion(version) ? version : undefined;
266
+ releaseCheckAfter = now() + (releaseVersion ? CLOUD_RELEASE_CHECK_MS : CLOUD_RELEASE_RETRY_MS);
267
+ if (!releaseVersion && !signal.aborted)
268
+ log('Could not check for a Cloud bridge update. Continuing with the current version.');
269
+ })().finally(() => { releaseCheck = undefined; });
270
+ await releaseCheck;
271
+ }
272
+ if (signal.aborted || restarting)
273
+ return true;
274
+ const target = releaseVersion;
275
+ if (!target || !validVersion(options.version) || compareVersions(target, options.version) <= 0)
276
+ return false;
277
+ if (held?.version === target && now() < held.until)
278
+ return false;
279
+ try {
280
+ const stage = await engines.prepare(target);
281
+ if (stage === 'failed' || (stage === 'none' && !await engines.installed(target)))
282
+ return restarting;
283
+ // A terminal, clone, or running task may keep the host on its current release for a while.
284
+ if (relay.runningTasks() > 0 || clonesRunning() > 0 || await relay.holdsWork())
285
+ return restarting;
286
+ return true;
287
+ }
288
+ catch (error) {
289
+ log(`Could not prepare Cloud bridge update ${target}: ${error instanceof Error ? error.message : String(error)}`);
290
+ return restarting;
291
+ }
292
+ };
293
+ const watch = { noteVersion, settled: () => { void restartIfIdle(); }, updatingBeforeTask, answer };
246
294
  try {
247
295
  while (!signal.aborted) {
248
296
  let credential;
@@ -474,12 +522,15 @@ function runSession(options, relay, host, credential, connections, onToken, vers
474
522
  answerWith(viewer, id, { error: { code: 'invalid-params', message: 'A request body is required.' } });
475
523
  return;
476
524
  }
477
- if (versions.restarting() && TASK_START_METHODS.has(frame.body.method)) {
478
- answerWith(viewer, id, { error: { code: 'busy', message: RESTARTING_MESSAGE } });
479
- return;
480
- }
481
525
  const body = frame.body;
482
- await versions.answer(async () => { answerWith(viewer, id, await relay.request(viewer, body)); });
526
+ await versions.answer(async () => {
527
+ if (TASK_START_METHODS.has(body.method) && await versions.updatingBeforeTask()) {
528
+ answerWith(viewer, id, { error: { code: 'busy', message: RESTARTING_MESSAGE } });
529
+ return;
530
+ }
531
+ if (!finished && !signal.aborted)
532
+ answerWith(viewer, id, await relay.request(viewer, body));
533
+ });
483
534
  versions.settled();
484
535
  return;
485
536
  }
@@ -494,7 +545,7 @@ function runSession(options, relay, host, credential, connections, onToken, vers
494
545
  const params = isRecord(frame.params) ? frame.params : {};
495
546
  await versions.answer(async () => {
496
547
  try {
497
- answerWith(viewer, id, { result: await hostOperation(options.directory, op, params, host) });
548
+ answerWith(viewer, id, { result: await hostOperation(options.directory, op, params, host, options.cloudUpdates === true && options.engines !== undefined) });
498
549
  }
499
550
  catch (error) {
500
551
  const code = error instanceof HostOperationError ? error.code : 'remote';
@@ -1,4 +1,5 @@
1
1
  export declare const PROTOCOL_VERSION = 1;
2
+ export declare const CLOUD_BRIDGE_AUTO_UPDATE = "cloud.bridgeAutoUpdate";
2
3
  export declare const MAX_FRAME_BYTES: number;
3
4
  /** The hello, the only frame the relay reads before `ready`, may be at most this large. */
4
5
  export declare const PRE_HELLO_MAX_BYTES: number;
@@ -1,6 +1,7 @@
1
1
  // The wire protocol between a bridge host, the relay and a desktop engine. Every frame is one JSON text
2
2
  // message of at most MAX_FRAME_BYTES. The bridge host and the engine client keep a byte-for-byte copy of this file.
3
3
  export const PROTOCOL_VERSION = 1;
4
+ export const CLOUD_BRIDGE_AUTO_UPDATE = 'cloud.bridgeAutoUpdate';
4
5
  export const MAX_FRAME_BYTES = 16 * 1024 * 1024;
5
6
  /** The hello, the only frame the relay reads before `ready`, may be at most this large. */
6
7
  export const PRE_HELLO_MAX_BYTES = 16 * 1024;
@@ -2,6 +2,16 @@ import type { Tool, ToolImage } from './types.js';
2
2
  import type { BrowserViewManager } from './browser-view.js';
3
3
  export declare const PANEL_HOLD_LEASE_MS: number;
4
4
  export declare const PANEL_HOLD_RENEW_MS: number;
5
+ export declare const PANEL_RESIZE_LIMITS: {
6
+ readonly width: {
7
+ readonly min: 320;
8
+ readonly max: 1600;
9
+ };
10
+ readonly height: {
11
+ readonly min: 240;
12
+ readonly max: 1200;
13
+ };
14
+ };
5
15
  export interface PanelArguments {
6
16
  operation: string;
7
17
  url?: string;
@@ -11,6 +21,8 @@ export interface PanelArguments {
11
21
  key?: string;
12
22
  button?: 'left' | 'right' | 'middle';
13
23
  deltaY?: number;
24
+ width?: number;
25
+ height?: number;
14
26
  }
15
27
  export declare function validatePanelArguments(args: Record<string, unknown>): PanelArguments;
16
28
  /**