@andorra-labs/code 0.1.13 → 0.1.15

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 (168) hide show
  1. package/dist/src/account-presentation.js +4 -1
  2. package/dist/src/acp-agent.d.ts +54 -0
  3. package/dist/src/acp-agent.js +991 -0
  4. package/dist/src/agent-execution.js +304 -140
  5. package/dist/src/agent-mcp-catalog.js +2 -0
  6. package/dist/src/agent-mcp.d.ts +2 -0
  7. package/dist/src/agent-mcp.js +86 -4
  8. package/dist/src/andorra/endpoint.d.ts +7 -0
  9. package/dist/src/andorra/endpoint.js +46 -0
  10. package/dist/src/andorra/entry.d.ts +21 -0
  11. package/dist/src/andorra/entry.js +118 -0
  12. package/dist/src/andorra/errors.d.ts +2 -0
  13. package/dist/src/andorra/errors.js +39 -0
  14. package/dist/src/andorra/hosted.d.ts +55 -0
  15. package/dist/src/andorra/hosted.js +130 -0
  16. package/dist/src/andorra/monitor.d.ts +151 -0
  17. package/dist/src/andorra/monitor.js +393 -0
  18. package/dist/src/andorra/notices.d.ts +16 -0
  19. package/dist/src/andorra/notices.js +38 -0
  20. package/dist/src/andorra/opt-in.d.ts +58 -0
  21. package/dist/src/andorra/opt-in.js +112 -0
  22. package/dist/src/andorra/request-watch.d.ts +6 -0
  23. package/dist/src/andorra/request-watch.js +10 -0
  24. package/dist/src/andorra/state.d.ts +86 -0
  25. package/dist/src/andorra/state.js +238 -0
  26. package/dist/src/andorra/terminal.d.ts +70 -0
  27. package/dist/src/andorra/terminal.js +125 -0
  28. package/dist/src/andorra/usage-format.d.ts +9 -0
  29. package/dist/src/andorra/usage-format.js +19 -0
  30. package/dist/src/anthropic-credentials.js +9 -1
  31. package/dist/src/app-server/protocol.d.ts +10 -2
  32. package/dist/src/app-server/protocol.js +1 -1
  33. package/dist/src/app-server/workspace.d.ts +1 -0
  34. package/dist/src/app-server/workspace.js +141 -10
  35. package/dist/src/app-server.d.ts +35 -0
  36. package/dist/src/app-server.js +377 -124
  37. package/dist/src/auth/AuthManager.d.ts +9 -0
  38. package/dist/src/auth/AuthManager.js +164 -24
  39. package/dist/src/auth/deployment.d.ts +1 -0
  40. package/dist/src/auth/deployment.js +1 -0
  41. package/dist/src/auth/index.d.ts +1 -1
  42. package/dist/src/auth/index.js +1 -1
  43. package/dist/src/auth/store.d.ts +26 -0
  44. package/dist/src/auth/store.js +34 -1
  45. package/dist/src/browser-bridge.d.ts +1 -0
  46. package/dist/src/browser-bridge.js +5 -2
  47. package/dist/src/browser-external-app.d.ts +27 -0
  48. package/dist/src/browser-external-app.js +60 -0
  49. package/dist/src/browser-panel-tool.d.ts +6 -0
  50. package/dist/src/browser-panel-tool.js +36 -0
  51. package/dist/src/browser-runner.js +1 -1
  52. package/dist/src/browser-server.d.ts +5 -0
  53. package/dist/src/browser-server.js +27 -3
  54. package/dist/src/browser-stealth.d.ts +19 -1
  55. package/dist/src/browser-stealth.js +23 -3
  56. package/dist/src/browser-ui/tokens.css +4 -4
  57. package/dist/src/browser-view.d.ts +81 -0
  58. package/dist/src/browser-view.js +289 -18
  59. package/dist/src/bug-report.d.ts +81 -0
  60. package/dist/src/bug-report.js +235 -0
  61. package/dist/src/claude-provider.d.ts +2 -1
  62. package/dist/src/claude-provider.js +10 -8
  63. package/dist/src/cli-sign-in.d.ts +3 -1
  64. package/dist/src/cli-sign-in.js +4 -1
  65. package/dist/src/cli.js +205 -58
  66. package/dist/src/coding-tools.js +7 -7
  67. package/dist/src/command-screens.d.ts +26 -3
  68. package/dist/src/command-screens.js +323 -85
  69. package/dist/src/commands.d.ts +7 -1
  70. package/dist/src/commands.js +79 -27
  71. package/dist/src/completion-gates.d.ts +22 -0
  72. package/dist/src/completion-gates.js +11 -0
  73. package/dist/src/config.d.ts +11 -1
  74. package/dist/src/config.js +134 -3
  75. package/dist/src/dashboard-view.d.ts +2 -0
  76. package/dist/src/dashboard-view.js +11 -2
  77. package/dist/src/decision/PreparedSteps.js +1 -1
  78. package/dist/src/decision/applyToolMenu.js +1 -1
  79. package/dist/src/decision/toolFamilies.js +1 -1
  80. package/dist/src/decision/types.d.ts +1 -0
  81. package/dist/src/google-provider.d.ts +31 -0
  82. package/dist/src/google-provider.js +153 -0
  83. package/dist/src/graph-health.d.ts +11 -0
  84. package/dist/src/graph-health.js +36 -4
  85. package/dist/src/graph-manager-chat.d.ts +33 -0
  86. package/dist/src/graph-manager-chat.js +165 -6
  87. package/dist/src/graph-runner.js +27 -0
  88. package/dist/src/graph-selection.js +2 -1
  89. package/dist/src/graph-sync.d.ts +1 -0
  90. package/dist/src/graph-sync.js +93 -34
  91. package/dist/src/graph-tool.d.ts +2 -0
  92. package/dist/src/graph-tool.js +2 -2
  93. package/dist/src/graph-ui/app.js +92 -10
  94. package/dist/src/graph-ui/edge-router.js +121 -53
  95. package/dist/src/graph-ui/manager.js +40 -5
  96. package/dist/src/graph-ui/style.css +5 -2
  97. package/dist/src/graph-ui/tokens.css +4 -4
  98. package/dist/src/graph-visibility.d.ts +31 -0
  99. package/dist/src/graph-visibility.js +102 -0
  100. package/dist/src/graphs.js +1 -3
  101. package/dist/src/hardened-runtime.js +1 -1
  102. package/dist/src/live-model.d.ts +24 -0
  103. package/dist/src/live-model.js +37 -0
  104. package/dist/src/managed-sign-in.d.ts +1 -0
  105. package/dist/src/managed-sign-in.js +13 -0
  106. package/dist/src/membership-errors.d.ts +2 -0
  107. package/dist/src/membership-errors.js +6 -2
  108. package/dist/src/membership.d.ts +13 -2
  109. package/dist/src/membership.js +39 -8
  110. package/dist/src/model-context-windows.d.ts +2 -0
  111. package/dist/src/model-context-windows.js +24 -0
  112. package/dist/src/model-health-cache.js +1 -1
  113. package/dist/src/model-metadata.d.ts +1 -0
  114. package/dist/src/model-metadata.js +47 -3
  115. package/dist/src/paged-transcript.d.ts +2 -0
  116. package/dist/src/paged-transcript.js +16 -0
  117. package/dist/src/palette.d.ts +1 -0
  118. package/dist/src/palette.js +1 -1
  119. package/dist/src/permissions.js +17 -4
  120. package/dist/src/provider-connection.js +32 -0
  121. package/dist/src/provider-engine.d.ts +5 -0
  122. package/dist/src/provider-engine.js +3 -3
  123. package/dist/src/provider-import.js +3 -1
  124. package/dist/src/provider-settings.d.ts +16 -1
  125. package/dist/src/provider-settings.js +50 -22
  126. package/dist/src/providers.d.ts +29 -3
  127. package/dist/src/providers.js +100 -18
  128. package/dist/src/react-runtime.js +33 -12
  129. package/dist/src/read-document-tool.d.ts +2 -0
  130. package/dist/src/read-document-tool.js +6 -6
  131. package/dist/src/remote/engine-pool.js +31 -6
  132. package/dist/src/run-control.d.ts +2 -2
  133. package/dist/src/run-control.js +9 -6
  134. package/dist/src/runtime-environment.d.ts +1 -0
  135. package/dist/src/runtime-environment.js +13 -0
  136. package/dist/src/runtime.d.ts +2 -0
  137. package/dist/src/runtime.js +2 -1
  138. package/dist/src/save-lock.js +14 -7
  139. package/dist/src/session-title.d.ts +3 -0
  140. package/dist/src/session-title.js +5 -2
  141. package/dist/src/sessions.d.ts +1 -0
  142. package/dist/src/sessions.js +4 -2
  143. package/dist/src/sign-in-detection.d.ts +1 -1
  144. package/dist/src/sign-in-detection.js +10 -3
  145. package/dist/src/sign-in-offer.js +1 -1
  146. package/dist/src/skill-commands.js +1 -1
  147. package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
  148. package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
  149. package/dist/src/skills/bundled/graph-manager/errors.md +2 -1
  150. package/dist/src/skills/bundled/provenance.json +743 -738
  151. package/dist/src/skills/runtime-skills.js +1 -0
  152. package/dist/src/subagent-run.d.ts +2 -0
  153. package/dist/src/subagent-run.js +14 -3
  154. package/dist/src/telemetry/schema.d.ts +1 -1
  155. package/dist/src/telemetry/schema.js +2 -2
  156. package/dist/src/telemetry/uploader.d.ts +7 -1
  157. package/dist/src/telemetry/uploader.js +11 -2
  158. package/dist/src/terminal-links.d.ts +16 -0
  159. package/dist/src/terminal-links.js +113 -0
  160. package/dist/src/terminal-ui.d.ts +29 -1
  161. package/dist/src/terminal-ui.js +113 -24
  162. package/dist/src/tool-catalog.js +1 -1
  163. package/dist/src/trajectory.js +6 -1
  164. package/dist/src/transcript.d.ts +2 -0
  165. package/dist/src/transcript.js +5 -1
  166. package/dist/src/types.d.ts +5 -0
  167. package/dist/src/workspace-instructions.js +1 -1
  168. package/package.json +13 -1
@@ -3,41 +3,49 @@ globalThis.AndorraEdgeRouter = (() => {
3
3
  const clear = (a, b, boxes) => !boxes.some(r => a.x === b.x
4
4
  ? a.x > r.x && a.x < r.x + r.width && Math.max(a.y,b.y) > r.y && Math.min(a.y,b.y) < r.y+r.height
5
5
  : a.y > r.y && a.y < r.y+r.height && Math.max(a.x,b.x) > r.x && Math.min(a.x,b.x) < r.x+r.width);
6
- const GAP = 8;
7
- const NUDGE = 10, NUDGES = 4;
8
- function collinear(a, b, c, d) {
9
- const shared = (p, q, r, s) => Math.min(Math.max(p,q),Math.max(r,s)) - Math.max(Math.min(p,q),Math.min(r,s)) > 0;
10
- if (a.y === b.y && c.y === d.y && a.x !== b.x && c.x !== d.x) return Math.abs(a.y-c.y) < GAP && shared(a.x,b.x,c.x,d.x);
11
- if (a.x === b.x && c.x === d.x && a.y !== b.y && c.y !== d.y) return Math.abs(a.x-c.x) < GAP && shared(a.y,b.y,c.y,d.y);
12
- return false;
13
- }
14
- function lineIndex(occupied) {
15
- const rows = new Map(), columns = new Map();
16
- for (const route of occupied) for (let i = 1; i < route.length; i++) {
6
+ const GAP = 16;
7
+ const NUDGE = 16, NUDGES = 5, ROWS = 12;
8
+ function addLines(index, route) {
9
+ const { rows, columns } = index;
10
+ index.empty = false;
11
+ for (let i = 1; i < route.length; i++) {
17
12
  const a = route[i-1], b = route[i];
18
13
  if (a.x === b.x && a.y === b.y) continue;
19
- const table = a.y === b.y ? rows : columns, line = a.y === b.y ? a.y : a.x, bucket = Math.floor(line / GAP);
14
+ const flat = a.y === b.y, table = flat ? rows : columns, line = flat ? a.y : a.x, bucket = Math.floor(line / GAP);
20
15
  if (!table.has(bucket)) table.set(bucket, []);
21
- table.get(bucket).push({ a, b, final: i === route.length - 1, end: route.at(-1) });
16
+ table.get(bucket).push({ line, low: flat ? Math.min(a.x,b.x) : Math.min(a.y,b.y), high: flat ? Math.max(a.x,b.x) : Math.max(a.y,b.y), final: i === route.length - 1, end: route.at(-1) });
22
17
  }
23
- return { rows, columns, empty: !occupied.length };
18
+ }
19
+ function lineIndex(occupied) {
20
+ const index = { rows: new Map(), columns: new Map(), empty: true };
21
+ for (const route of occupied) addLines(index, route);
22
+ return index;
24
23
  }
25
24
  function along(index, a, b, final = false, end = undefined) {
26
- if (index.empty || (a.x === b.x && a.y === b.y)) return false;
27
- const table = a.y === b.y ? index.rows : index.columns, bucket = Math.floor((a.y === b.y ? a.y : a.x) / GAP);
28
- for (let near = bucket - 1; near <= bucket + 1; near++) for (const other of table.get(near) || []) {
29
- if (final && other.final && end && other.end.x === end.x && other.end.y === end.y) continue;
30
- if (collinear(a, b, other.a, other.b)) return true;
25
+ if (index.empty || (a.x === b.x && a.y === b.y)) return 0;
26
+ const flat = a.y === b.y, table = flat ? index.rows : index.columns, line = flat ? a.y : a.x, bucket = Math.floor(line / GAP);
27
+ const low = flat ? Math.min(a.x,b.x) : Math.min(a.y,b.y), high = flat ? Math.max(a.x,b.x) : Math.max(a.y,b.y);
28
+ let total = 0;
29
+ for (let near = bucket - 1; near <= bucket + 1; near++) {
30
+ const others = table.get(near);
31
+ if (others) for (const other of others) {
32
+ const apart = Math.abs(line - other.line);
33
+ if (apart >= GAP) continue;
34
+ const run = Math.min(high, other.high) - Math.max(low, other.low);
35
+ if (run <= 0 || (final && other.final && end && other.end.x === end.x && other.end.y === end.y)) continue;
36
+ total += run * (GAP - apart);
37
+ }
31
38
  }
32
- return false;
39
+ return total;
33
40
  }
34
- function crowdsIndex(points, index) {
35
- if (index.empty) return false;
41
+ function crowdsIndex(points, index, limit = Infinity) {
42
+ if (index.empty) return 0;
36
43
  const end = points.at(-1);
37
- for (let i = 1; i < points.length; i++) if (along(index, points[i-1], points[i], i === points.length - 1, end)) return true;
38
- return false;
44
+ let total = 0;
45
+ for (let i = 1; i < points.length && total < limit; i++) total += along(index, points[i-1], points[i], i === points.length - 1, end);
46
+ return total;
39
47
  }
40
- const crowds = (points, occupied) => crowdsIndex(points, lineIndex(occupied));
48
+ const crowds = (points, occupied) => crowdsIndex(points, lineIndex(occupied)) > 0;
41
49
  function routeEdge(source, target, rectangles, lane = 0, padding = 12, occupied = []) {
42
50
  const escape = padding + 2, start = {x:source.x+escape,y:source.y}, end = {x:target.x-escape,y:target.y};
43
51
  const boxes = rectangles.map(r => ({x:r.x-padding,y:r.y-padding,width:r.width+padding*2,height:r.height+padding*2}));
@@ -50,45 +58,59 @@ globalThis.AndorraEdgeRouter = (() => {
50
58
  };
51
59
  const finish = points => simplify([source,...points,target]);
52
60
  const clearOfCards = points => points.every((p,i)=>!i||clear(points[i-1],p,boxes));
53
- const index = lineIndex(occupied);
54
- const verdict = points => !clearOfCards(points) ? 'blocked' : crowdsIndex(finish(points), index) ? 'crowded' : 'ok';
61
+ const index = Array.isArray(occupied) ? lineIndex(occupied) : occupied;
55
62
  const rowNudges = (y, k) => (y <= Math.min(start.y,end.y) ? [-1] : y >= Math.max(start.y,end.y) ? [1] : [1,-1]).map(way=>y+way*NUDGE*k);
56
- let crowdedFallback;
63
+ let leastCrowded;
64
+ const attempt = (points, nudged = false) => {
65
+ if (!nudged && !clearOfCards(points)) return 'blocked';
66
+ const route = finish(points), score = crowdsIndex(route, index, leastCrowded?.score);
67
+ if (nudged && ((leastCrowded && score >= leastCrowded.score) || !clearOfCards(points))) return 'blocked';
68
+ if (!score) return route;
69
+ if (!leastCrowded || score < leastCrowded.score) leastCrowded = { route, score };
70
+ return 'crowded';
71
+ };
57
72
  const corridor = (build, row) => {
58
- const base = build(row, 0), first = verdict(base);
59
- if (first === 'ok') return finish(base);
73
+ const first = attempt(build(row, 0));
60
74
  if (first === 'blocked') return undefined;
75
+ if (first !== 'crowded') return first;
61
76
  for (let k = 1; k <= NUDGES; k++) {
62
77
  for (const points of [...rowNudges(row,k).map(y=>build(y,0)), build(row,NUDGE*k), ...rowNudges(row,k).map(y=>build(y,NUDGE*k))]) {
63
- if (verdict(points) === 'ok') return finish(points);
78
+ const found = attempt(points, true);
79
+ if (typeof found !== 'string') return found;
64
80
  }
65
81
  }
66
- crowdedFallback ??= finish(base);
67
82
  return undefined;
68
83
  };
69
84
  const middleX=(start.x+end.x)/2, middleY=(start.y+end.y)/2;
70
85
  const rowsByDistance=[...new Set([middleY,...ys])].sort((a,b)=>Math.abs(a-start.y)+Math.abs(a-end.y)-Math.abs(b-start.y)-Math.abs(b-end.y));
71
- const rowCandidates=rowsByDistance.slice(0,12);
72
- if (target.x <= source.x) {
73
- const offset=(lane+1)*8;
74
- for (const y of rowCandidates) {
75
- const found=corridor((row,dx)=>{const sx=start.x+offset+dx,tx=end.x-offset-dx;return [start,{x:sx,y:start.y},{x:sx,y:row},{x:tx,y:row},{x:tx,y:end.y},end];},y);
76
- if(found)return found;
77
- }
78
- }
79
- for(const [build,row] of [
80
- [(_,dx)=>[start,{x:middleX+dx,y:start.y},{x:middleX+dx,y:end.y},end],middleY],
81
- [(row)=>[start,{x:start.x,y:row},{x:end.x,y:row},end],middleY],
82
- ...rowCandidates.map(y=>[(row)=>[start,{x:start.x,y:row},{x:end.x,y:row},end],y]),
83
- ]){const found=corridor(build,row);if(found)return found;}
84
86
  const right=xs.filter(x=>x>=start.x&&clear(start,{x,y:start.y},boxes)).sort((a,b)=>a-b);
85
87
  const left=xs.filter(x=>x<=end.x&&clear({x,y:end.y},end,boxes)).sort((a,b)=>b-a);
86
- for(const y of rowCandidates){
87
- const sx=right.find(x=>clear({x,y:start.y},{x,y},boxes));
88
- const tx=left.find(x=>clear({x,y:end.y},{x,y},boxes));
89
- if(sx!==undefined&&tx!==undefined){const found=corridor((row,dx)=>[start,{x:sx+dx,y:start.y},{x:sx+dx,y:row},{x:tx-dx,y:row},{x:tx-dx,y:end.y},end],y);if(found)return found;}
88
+ const search = (rows, direct) => {
89
+ if (target.x <= source.x) {
90
+ const offset=(lane+1)*8;
91
+ for (const y of rows) {
92
+ const found=corridor((row,dx)=>{const sx=start.x+offset+dx,tx=end.x-offset-dx;return [start,{x:sx,y:start.y},{x:sx,y:row},{x:tx,y:row},{x:tx,y:end.y},end];},y);
93
+ if(found)return found;
94
+ }
95
+ }
96
+ for(const [build,row] of [
97
+ ...(direct?[[(_,dx)=>[start,{x:middleX+dx,y:start.y},{x:middleX+dx,y:end.y},end],middleY],
98
+ [(row)=>[start,{x:start.x,y:row},{x:end.x,y:row},end],middleY]]:[]),
99
+ ...rows.map(y=>[(row)=>[start,{x:start.x,y:row},{x:end.x,y:row},end],y]),
100
+ ]){const found=corridor(build,row);if(found)return found;}
101
+ for(const y of rows){
102
+ const sx=right.find(x=>clear({x,y:start.y},{x,y},boxes));
103
+ const tx=left.find(x=>clear({x,y:end.y},{x,y},boxes));
104
+ if(sx!==undefined&&tx!==undefined){const found=corridor((row,dx)=>[start,{x:sx+dx,y:start.y},{x:sx+dx,y:row},{x:tx-dx,y:row},{x:tx-dx,y:end.y},end],y);if(found)return found;}
105
+ }
106
+ return undefined;
107
+ };
108
+ const near=search(rowsByDistance.slice(0,ROWS),true);
109
+ if(near)return near;
110
+ if(leastCrowded){
111
+ const wider=search(rowsByDistance.slice(ROWS,ROWS*2),false);
112
+ return wider||leastCrowded.route;
90
113
  }
91
- if(crowdedFallback)return crowdedFallback;
92
114
  const key=(x,y,dir)=>`${x},${y},${dir}`, heuristic=(x,y)=>Math.abs(xs[x]-end.x)+Math.abs(ys[y]-end.y);
93
115
  const heap=[];
94
116
  function push(item){heap.push(item);let i=heap.length-1;while(i){const p=(i-1)>>1;if(heap[p].score<=item.score)break;heap[i]=heap[p];i=p;}heap[i]=item;}
@@ -117,11 +139,11 @@ globalThis.AndorraEdgeRouter = (() => {
117
139
  return simplify(points);
118
140
  }
119
141
  function routeEdges(entries, rectangles) {
120
- const occupied=[];
142
+ const occupied=lineIndex([]);
121
143
  return entries.map((entry,index)=>{
122
144
  if(!entry)return null;
123
145
  const points=routeEdge(entry.source,entry.target,rectangles,index,undefined,occupied);
124
- occupied.push(points);
146
+ addLines(occupied,points);
125
147
  return points;
126
148
  });
127
149
  }
@@ -152,5 +174,51 @@ globalThis.AndorraEdgeRouter = (() => {
152
174
  }
153
175
  return best||{x:(points[0].x+points.at(-1).x)/2,y:(points[0].y+points.at(-1).y)/2};
154
176
  }
155
- return {routeEdge,routeEdges,crowds,path,roundedPath,labelPoint,clear};
177
+ const LABEL_MARGIN = 4, LABEL_STOPS = [0.5, 0.3, 0.7, 0.15, 0.85];
178
+ function placeLabels(routes, widths, height, rectangles = []) {
179
+ const placed = [], touches = (a, b, margin) => a.x - margin < b.x + b.width && b.x - margin < a.x + a.width && a.y - margin < b.y + b.height && b.y - margin < a.y + a.height;
180
+ const segments = routes.map(points => {
181
+ const list = [];
182
+ if (points) for (let i = 1; i < points.length; i++) {
183
+ const a = points[i-1], b = points[i];
184
+ list.push({ x: Math.min(a.x,b.x), y: Math.min(a.y,b.y), width: Math.abs(b.x-a.x), height: Math.abs(b.y-a.y) });
185
+ }
186
+ return list;
187
+ });
188
+ return routes.map((points, index) => {
189
+ const width = widths[index];
190
+ if (!points || !width) return null;
191
+ const candidates = [], first = labelPoint(points);
192
+ const runs = [];
193
+ for (let i = 1; i < points.length; i++) {
194
+ const a = points[i-1], b = points[i], flat = a.y === b.y, length = flat ? Math.abs(b.x-a.x) : Math.abs(b.y-a.y);
195
+ if (length) runs.push({ a, b, flat, length, room: length - (flat ? width : height) - LABEL_MARGIN * 2 });
196
+ }
197
+ runs.sort((p, q) => Number(q.flat) - Number(p.flat) || q.length - p.length);
198
+ runs.forEach((run, rank) => {
199
+ for (const [order, stop] of (run.room > 0 ? LABEL_STOPS : [0.5]).entries()) {
200
+ const half = (run.flat ? width : height) / 2 + LABEL_MARGIN, low = Math.min(run.flat ? run.a.x : run.a.y, run.flat ? run.b.x : run.b.y);
201
+ const along = run.room > 0 ? Math.min(Math.max(low + run.length * stop, low + half), low + run.length - half) : low + run.length / 2;
202
+ const at = run.flat ? { x: along, y: run.a.y } : { x: run.a.x, y: along };
203
+ candidates.push({ at, cost: rank * 3 + order + (run.flat ? 0 : 4) + (run.room > 0 ? 0 : 6) });
204
+ }
205
+ });
206
+ if (!candidates.length) candidates.push({ at: first, cost: 0 });
207
+ let best;
208
+ for (const candidate of candidates) {
209
+ const box = { x: candidate.at.x - width / 2, y: candidate.at.y - height / 2, width, height };
210
+ let cost = candidate.cost;
211
+ for (const other of placed) if (touches(box, other, LABEL_MARGIN)) cost += 1000;
212
+ for (const card of rectangles) if (touches(box, card, 2)) cost += 1000;
213
+ if (!best || cost < best.cost) {
214
+ for (let other = 0; other < segments.length && cost < (best?.cost ?? Infinity); other++) if (other !== index) for (const segment of segments[other]) if (touches(box, segment, 2)) cost += 40;
215
+ if (!best || cost < best.cost) best = { cost, at: candidate.at, box };
216
+ }
217
+ if (best.cost === candidate.cost && best.at === candidate.at) break;
218
+ }
219
+ placed.push(best.box);
220
+ return best.at;
221
+ });
222
+ }
223
+ return {routeEdge,routeEdges,crowds,path,roundedPath,labelPoint,placeLabels,clear};
156
224
  })();
@@ -46,6 +46,9 @@ globalThis.AndorraManager = (() => {
46
46
  agentFields = { ...saved.fields };
47
47
  }
48
48
  let deferredEdits = [];
49
+ // The newest live edit this page has received, per graph. Kept across panel close and graph
50
+ // switches, so a snapshot after reconnecting applies only the edits made while nobody listened.
51
+ const editsSeen = new Map();
49
52
  let shownGraphId = null;
50
53
  let choice;
51
54
  let providersSeen = '';
@@ -83,15 +86,22 @@ globalThis.AndorraManager = (() => {
83
86
  if (open) fillModels();
84
87
  }
85
88
 
89
+ // What each graph's conversation last sent, kept while another graph is open: edits that arrive
90
+ // after coming back are merged against the canvas that conversation's message carried.
91
+ const baselines = new Map();
86
92
  function switchConversation(graphId) {
87
93
  disconnect();
94
+ if (streamGraphId) baselines.set(streamGraphId, { merge: mergeState(), latestUserSeen, sentCanvas, chatGraphId });
95
+ const kept = baselines.get(graphId);
96
+ baselines.delete(graphId);
88
97
  streamGraphId = graphId;
89
- chatGraphId = graphId;
98
+ chatGraphId = kept?.chatGraphId ?? graphId;
90
99
  transcript = []; runState = 'idle';
91
- posted = []; sentCanvas = null; beforeLastMessage = null; unsureCanvas = false;
100
+ posted = []; sentCanvas = kept?.sentCanvas ?? null; beforeLastMessage = null; unsureCanvas = false;
92
101
  offeredRevision = null; createdOffer = null; localError = '';
93
102
  decisions.clear(); answering.clear(); openRows.clear();
94
- rebase(null); latestUserSeen = null; mergeBeforeMessage = null; deferredEdits = [];
103
+ if (kept) restoreMerge(kept.merge); else rebase(null);
104
+ latestUserSeen = kept?.latestUserSeen ?? null; mergeBeforeMessage = null; deferredEdits = [];
95
105
  rendered = [];
96
106
  if (open) { connect(); render(); }
97
107
  }
@@ -203,6 +213,7 @@ globalThis.AndorraManager = (() => {
203
213
  if (missed && !deleted.has(missed.graphId) && missed.revision > (state.graph.revision || 0)) offeredRevision = missed.revision;
204
214
  const created = transcript.map(entry => logic.createdGraph(state.graph?.id, entry)).filter(Boolean).pop();
205
215
  if (created && !deleted.has(created.id)) createdOffer = created;
216
+ replayEdits(event);
206
217
  } else if (event.type === 'user') {
207
218
  latestUserSeen = event.text;
208
219
  accepted(event.text);
@@ -296,7 +307,31 @@ globalThis.AndorraManager = (() => {
296
307
  return Object.fromEntries(keys.map(key => [key, Object.hasOwn(agentFields, key) ? JSON.parse(agentFields[key]) : sent[key]]));
297
308
  }
298
309
 
310
+ // Each conversation numbers its own edits, so a watermark belongs to a conversation and a graph.
311
+ const editKey = (stream, graphId) => `${typeof stream === 'string' ? stream : ''}\n${graphId}`;
312
+ function replayEdits(snapshot) {
313
+ const stream = typeof snapshot.stream === 'string' ? snapshot.stream : '';
314
+ const edits = (Array.isArray(snapshot.edits) ? snapshot.edits : [])
315
+ .filter(entry => entry && Number.isSafeInteger(entry.seq) && typeof entry.graphId === 'string')
316
+ .map(entry => ({ ...entry, key: editKey(entry.stream ?? stream, entry.graphId) }));
317
+ const newest = new Map();
318
+ for (const entry of edits) newest.set(entry.key, Math.max(newest.get(entry.key) ?? 0, entry.seq));
319
+ const own = streamGraphId ? editKey(stream, streamGraphId) : null;
320
+ if (own && !newest.has(own)) newest.set(own, 0);
321
+ // The first snapshot this page sees for a conversation only marks its edits: they predate this page's canvas.
322
+ const first = new Set([...newest.keys()].filter(key => !editsSeen.has(key)));
323
+ for (const key of first) editsSeen.set(key, newest.get(key));
324
+ for (const entry of edits) {
325
+ if (first.has(entry.key) || !(entry.seq > (editsSeen.get(entry.key) ?? 0))) continue;
326
+ liveEdit({ type: 'graph.edit', graphId: entry.graphId, edit: entry.edit, seq: entry.seq, stream: entry.stream ?? stream });
327
+ }
328
+ }
329
+
299
330
  function liveEdit(event) {
331
+ if (Number.isSafeInteger(event.seq) && typeof event.graphId === 'string') {
332
+ const key = editKey(event.stream, event.graphId);
333
+ editsSeen.set(key, Math.max(editsSeen.get(key) ?? 0, event.seq));
334
+ }
300
335
  if (!state.graph || event.graphId !== state.graph.id || !logic.soundEdit(event.edit)) return;
301
336
  if (typingInEditor()) {
302
337
  deferredEdits.push(event);
@@ -377,7 +412,7 @@ globalThis.AndorraManager = (() => {
377
412
  if (event.edit.kind === 'edge.remove') agentEdges.set(event.edit.edgeId, 'null');
378
413
  if (event.edit.kind === 'graph') for (const [key, value] of Object.entries(event.edit.patch)) agentFields[key] = JSON.stringify(value);
379
414
  if (!edit) {
380
- if (kept.length) { sentCanvas = null; status('Graph Manager changed the draft; your own edits were kept. Approve its save, then load it to see its changes.'); }
415
+ if (kept.length) { sentCanvas = null; status('Graph Manager changed something you also edited; your own edits were kept.'); }
381
416
  return;
382
417
  }
383
418
  const trial = JSON.parse(JSON.stringify(graph));
@@ -401,7 +436,7 @@ globalThis.AndorraManager = (() => {
401
436
  return;
402
437
  }
403
438
  if (followed) sentCanvas = JSON.stringify(state.graph);
404
- status(kept.length ? 'Graph Manager changed the draft; your own edits were kept. Approve its save to keep its changes.' : 'Graph Manager changed the draft. Approve its save to keep it.');
439
+ status(kept.length ? 'Graph Manager changed the graph; your own edits were kept. Save to keep its changes.' : 'Graph Manager changed the graph. Save to keep it.');
405
440
  }
406
441
  function graphDeleted(event) {
407
442
  if (state.graphs.some(entry => entry.id === event.graphId)) {
@@ -234,10 +234,13 @@ main { display: flex; flex: 1; min-width: 0; flex-direction: column; }
234
234
 
235
235
  #canvas {
236
236
  flex: 1; position: relative; overflow: hidden; min-width: 0; touch-action: none;
237
+ /* Panning and dragging steps would otherwise select node, edge and group text. */
238
+ user-select: none; -webkit-user-select: none;
237
239
  background-color: var(--canvas-bg);
238
240
  background-image: radial-gradient(var(--canvas-dot) 1px, transparent 1.2px);
239
241
  background-size: 20px 20px; background-position: -10px -10px;
240
242
  }
243
+ #canvas :is(input, textarea, [contenteditable]) { user-select: text; -webkit-user-select: text; }
241
244
  #scene { position: absolute; transform-origin: 0 0; }
242
245
  #edges { position: absolute; overflow: visible; width: 1px; height: 1px; pointer-events: none; }
243
246
  #nodes { position: absolute; }
@@ -340,14 +343,14 @@ main { display: flex; flex: 1; min-width: 0; flex-direction: column; }
340
343
  .tool-label { display: flex; align-items: center; gap: var(--space-2); padding: 6px 0; }
341
344
  .tool-label input { width: auto; min-height: 0; }
342
345
 
343
- .prompt-field > textarea { min-height: 120px; max-height: 60vh; resize: none; overflow-y: auto; padding-right: 40px; }
346
+ .prompt-field > textarea { min-height: 120px; resize: vertical; overflow-y: auto; padding-right: 40px; }
344
347
  .prompt-field > .prompt-expand { grid-column: 2; grid-row: 2; justify-self: end; align-self: start; z-index: 1; margin: var(--space-1); min-width: var(--control-height); }
345
348
  .prompt-field.fullscreen {
346
349
  position: fixed; z-index: var(--z-raised); inset: var(--space-5); margin: 0; grid-template-rows: auto 1fr;
347
350
  padding: var(--space-4); background: var(--bg-surface); border: 1px solid var(--border);
348
351
  border-radius: var(--card-radius); box-shadow: var(--shadow-menu);
349
352
  }
350
- .prompt-field.fullscreen > textarea { height: 100%; max-height: none; font-size: var(--type-sm); }
353
+ .prompt-field.fullscreen > textarea { height: 100%; resize: none; font-size: var(--type-sm); }
351
354
  body.prompt-fullscreen #inspector { z-index: calc(var(--z-dialog) + 1); }
352
355
  .prompt-backdrop { position: fixed; inset: 0; z-index: var(--z-dialog); background: var(--overlay); }
353
356
 
@@ -52,8 +52,8 @@
52
52
  --accent-hover: #ffffff; --accent-ring: rgba(245,245,245,.36);
53
53
  --accent-fill: #1372da; --accent-fill-hover: #2a7fdd; --on-accent-fill: #f5f5f5;
54
54
  --accent-text: #71aeff; --focus: #1f87fc;
55
- --ok: #2f9e6a; --err: #e5484d; --warn: #c9c9c9;
56
- --ok-text: #7cc79a; --err-text: #f47174; --warn-text: #ececec; --merged-text: #bba4f2;
55
+ --ok: #2f9e6a; --err: #e5484d; --warn: #c9c9c9; --caution: #d9a520; --caution-text: #f2c94c;
56
+ --ok-text: #7cc79a; --err-text: #f47174; --warn-text: #ececec; --merged-text: #bba4f2; --draft-text: #f0a35e;
57
57
  --skill: #aab8ff; --skill-wash: rgba(120,140,255,.18);
58
58
  --ok-wash: rgba(47,158,106,.14); --err-wash: rgba(229,72,77,.14); --merged-wash: rgba(142,110,224,.14);
59
59
  --add-wash: rgba(47,158,106,.16); --del-wash: rgba(229,72,77,.16);
@@ -99,8 +99,8 @@
99
99
  --accent-hover: #333333; --accent-ring: rgba(28,28,28,.48);
100
100
  --accent-fill: #1680f3; --accent-fill-hover: #1776dd; --on-accent-fill: #ffffff;
101
101
  --accent-text: #0b6dd3; --focus: #1680f3;
102
- --ok: #3d7a5c; --err: #d13438; --warn: #45464b;
103
- --ok-text: #36704f; --err-text: #c4262e; --warn-text: #1c1c1c; --merged-text: #6a4fc4;
102
+ --ok: #3d7a5c; --err: #d13438; --warn: #45464b; --caution: #b8860b; --caution-text: #8a6100;
103
+ --ok-text: #36704f; --err-text: #c4262e; --warn-text: #1c1c1c; --merged-text: #6a4fc4; --draft-text: #b35a0e;
104
104
  --skill: #3b4fc4; --skill-wash: rgba(59,79,196,.10);
105
105
  --ok-wash: rgba(61,122,92,.08); --err-wash: rgba(209,52,56,.08); --merged-wash: rgba(106,79,196,.08);
106
106
  --add-wash: rgba(61,122,92,.14); --del-wash: rgba(209,52,56,.13);
@@ -0,0 +1,31 @@
1
+ import { type Config } from './config.js';
2
+ /**
3
+ * Which projects list a graph, per signed-in account. A graph with no entry is listed in every project; an entry
4
+ * lists it only in the project paths it names. The engine owns this so the graph manager's tool can set it and the
5
+ * desktop, the TUI and the MCP server all read the same answer. It lives in config.json beside graphSelections and
6
+ * changes under the same cross-process config lock.
7
+ *
8
+ * graphVisibilityChosen lists, per account, the graphs whose visibility was chosen through the engine. A choice of
9
+ * every project leaves no entry in graphVisibility, so this is what tells it apart from a graph never configured:
10
+ * an older client's copy must not bring back a restriction the user lifted through the engine.
11
+ */
12
+ export type AccountGraphVisibility = Record<string, string[]>;
13
+ /** Called after this process changes visibility, so a host can tell its clients to reload. */
14
+ export declare function onGraphVisibilityChange(listener: () => void): () => void;
15
+ export declare function graphVisibilityFor(config: Pick<Config, 'graphVisibility'>, subject: string | undefined): AccountGraphVisibility;
16
+ /**
17
+ * Sets the projects that list `graphId` for `subject`, or lists it everywhere when `paths` is undefined.
18
+ * Returns the account's whole visibility after the change.
19
+ */
20
+ export declare function setGraphVisibility(directory: string, subject: string, graphId: string, paths: readonly string[] | undefined): Promise<AccountGraphVisibility>;
21
+ /**
22
+ * Brings in visibility a client kept before the engine owned it. Only graphs whose visibility was never chosen
23
+ * through the engine are taken, so a choice made there, "every project" included, is never overwritten by an older copy.
24
+ */
25
+ export declare function importGraphVisibility(directory: string, subject: string, entries: AccountGraphVisibility): Promise<AccountGraphVisibility>;
26
+ /**
27
+ * Moves grants from one project path to another for every account. A rename moves the grant; a merge narrows what is
28
+ * visible instead, because a graph shared only with the merged-away project is not the survivor's to inherit.
29
+ */
30
+ export declare function relinkGraphVisibility(config: Config, from: string, to: string, merged: boolean): Config;
31
+ export declare function announceGraphVisibilityChange(): void;
@@ -0,0 +1,102 @@
1
+ import { changeConfigFile, MAX_GRAPH_VISIBILITY_PROJECTS } from './config.js';
2
+ const listeners = new Set();
3
+ /** Called after this process changes visibility, so a host can tell its clients to reload. */
4
+ export function onGraphVisibilityChange(listener) {
5
+ listeners.add(listener);
6
+ return () => { listeners.delete(listener); };
7
+ }
8
+ function announce() {
9
+ for (const listener of listeners) {
10
+ try {
11
+ listener();
12
+ }
13
+ catch { /* a listener's failure is its own */ }
14
+ }
15
+ }
16
+ export function graphVisibilityFor(config, subject) {
17
+ if (!subject)
18
+ return {};
19
+ const account = config.graphVisibility?.[subject];
20
+ return account ? Object.fromEntries(Object.entries(account).map(([graph, paths]) => [graph, [...paths]])) : {};
21
+ }
22
+ function uniquePaths(paths) {
23
+ const unique = [...new Set(paths)];
24
+ if (unique.length > MAX_GRAPH_VISIBILITY_PROJECTS)
25
+ throw new Error(`A graph can be limited to at most ${MAX_GRAPH_VISIBILITY_PROJECTS} projects.`);
26
+ return unique;
27
+ }
28
+ function withAccount(config, subject, account) {
29
+ const all = { ...config.graphVisibility };
30
+ if (Object.keys(account).length === 0)
31
+ delete all[subject];
32
+ else
33
+ all[subject] = account;
34
+ const { graphVisibility: _previous, ...rest } = config;
35
+ return Object.keys(all).length === 0 ? rest : { ...rest, graphVisibility: all };
36
+ }
37
+ /**
38
+ * Sets the projects that list `graphId` for `subject`, or lists it everywhere when `paths` is undefined.
39
+ * Returns the account's whole visibility after the change.
40
+ */
41
+ export async function setGraphVisibility(directory, subject, graphId, paths) {
42
+ if (graphId === 'default')
43
+ throw new Error('The bundled Default graph is always listed in every project.');
44
+ const wanted = paths === undefined ? undefined : uniquePaths(paths);
45
+ let changed = false;
46
+ const saved = await changeConfigFile(directory, current => {
47
+ const account = graphVisibilityFor(current, subject);
48
+ const before = JSON.stringify(account[graphId] ?? null);
49
+ if (wanted === undefined)
50
+ delete account[graphId];
51
+ else
52
+ account[graphId] = wanted;
53
+ changed = JSON.stringify(account[graphId] ?? null) !== before;
54
+ const chosen = current.graphVisibilityChosen?.[subject] ?? [];
55
+ if (!changed && chosen.includes(graphId))
56
+ return current;
57
+ const next = changed ? withAccount(current, subject, account) : current;
58
+ return chosen.includes(graphId) ? next : { ...next, graphVisibilityChosen: { ...current.graphVisibilityChosen, [subject]: [...chosen, graphId] } };
59
+ });
60
+ if (changed)
61
+ announce();
62
+ return graphVisibilityFor(saved, subject);
63
+ }
64
+ /**
65
+ * Brings in visibility a client kept before the engine owned it. Only graphs whose visibility was never chosen
66
+ * through the engine are taken, so a choice made there, "every project" included, is never overwritten by an older copy.
67
+ */
68
+ export async function importGraphVisibility(directory, subject, entries) {
69
+ let changed = false;
70
+ const saved = await changeConfigFile(directory, current => {
71
+ const account = graphVisibilityFor(current, subject);
72
+ const chosen = new Set(current.graphVisibilityChosen?.[subject] ?? []);
73
+ for (const [graph, paths] of Object.entries(entries)) {
74
+ if (graph === 'default' || Object.hasOwn(account, graph) || chosen.has(graph))
75
+ continue;
76
+ account[graph] = uniquePaths(paths);
77
+ changed = true;
78
+ }
79
+ return changed ? withAccount(current, subject, account) : current;
80
+ });
81
+ if (changed)
82
+ announce();
83
+ return graphVisibilityFor(saved, subject);
84
+ }
85
+ /**
86
+ * Moves grants from one project path to another for every account. A rename moves the grant; a merge narrows what is
87
+ * visible instead, because a graph shared only with the merged-away project is not the survivor's to inherit.
88
+ */
89
+ export function relinkGraphVisibility(config, from, to, merged) {
90
+ if (!config.graphVisibility)
91
+ return config;
92
+ let changed = false;
93
+ const accounts = Object.fromEntries(Object.entries(config.graphVisibility).map(([subject, graphs]) => [subject,
94
+ Object.fromEntries(Object.entries(graphs).map(([graph, paths]) => {
95
+ if (!paths.includes(from))
96
+ return [graph, paths];
97
+ changed = true;
98
+ return [graph, merged ? paths.filter(path => path !== from) : [...new Set(paths.map(path => (path === from ? to : path)))]];
99
+ }))]));
100
+ return changed ? { ...config, graphVisibility: accounts } : config;
101
+ }
102
+ export function announceGraphVisibilityChange() { announce(); }
@@ -746,9 +746,7 @@ function validateGraphInternal(value, options = {}) {
746
746
  const delegated = node.agentRole === 'orchestrator' && spawningEnabled && isWritingRole(r);
747
747
  if (delegated && (s.workspace ?? 'shared-read-only') !== 'worktree')
748
748
  fail(`${label}: writing roles on an Orchestrator require separate worktrees; set subagents.workspace to "worktree" (Separate Git worktree)`);
749
- if (delegated && node.completion?.mode === 'outcomes')
750
- fail(`${label}: Orchestrator delegation needs a single completion outcome; remove declared outcomes or the writing roles`);
751
- if (delegated && node.completion?.mode === 'single' && node.completion.outcome === DELIVERED_OUTCOME)
749
+ if (delegated && (node.completion?.mode === 'outcomes' ? node.completion.outcomes.includes(DELIVERED_OUTCOME) : node.completion?.outcome === DELIVERED_OUTCOME))
752
750
  fail(`${label}: the outcome name ${DELIVERED_OUTCOME} is reserved for Orchestrator delegation; rename the completion outcome`);
753
751
  const parent = node.agentRole === 'orchestrator' && spawningEnabled && !delegated ? intakeCapabilities(node) : effectiveCapabilities(node);
754
752
  const child = r.capabilities ?? { ...parent, ...((s.workspace ?? 'shared-read-only') === 'shared-read-only' ? { filesystem: parent.filesystem === 'none' ? 'none' : 'read', git: parent.git === 'none' ? 'none' : 'read', shell: 'disabled' } : {}) };
@@ -103,7 +103,7 @@ export class AndorraAgentEngine {
103
103
  catalog: name => { const t = catalog(name); return t ? { family: toolFamily(t), readOnly: retrySafe(t) } : undefined; },
104
104
  fact: (input, signal) => !remoteFactsEnabled || !manager ? Promise.resolve(undefined) : manager.fact(input.id === 'task_needs_checks'
105
105
  ? { ...input, state: { task: factTaskText(redactSecrets(task).text, options.nodeInstruction ? redactSecrets(options.nodeInstruction).text : undefined) } }
106
- : input, { runId, nodeId, invocationId }, signal, options.onEvent),
106
+ : input, { runId, nodeId, invocationId, ...(options.subagentId ? { subagentId: options.subagentId } : {}) }, signal, options.onEvent),
107
107
  emit,
108
108
  });
109
109
  const shell = permitted.find(t => t.exitZeroOnReturn)?.name ?? catalog('shell')?.name;
@@ -0,0 +1,24 @@
1
+ import type { Graph } from './graphs.js';
2
+ /** A model chosen while a run is working: the pair the run moves to, and which of its nodes follow. */
3
+ export interface LiveModelSelection {
4
+ provider: string;
5
+ model: string;
6
+ /** Every node and delegation follows the pair, including nodes that name their own model. */
7
+ overrideAllNodes: boolean;
8
+ /** Only the nodes in `nodeOverrides` were changed: a node that follows the run's model stays as it is. */
9
+ nodeOnly?: boolean;
10
+ nodeOverrides?: Record<string, {
11
+ provider: string;
12
+ model: string;
13
+ }>;
14
+ }
15
+ /**
16
+ * The provider and model a live selection gives one agent of the run, or undefined when the selection
17
+ * leaves that agent alone. `nodeId` is the engine's live id: `<node>`, `<node>/<role>` for a subagent,
18
+ * either part ending in `#fallback` on a retry's fallback attempt. A missing `model` means the
19
+ * provider's configured one.
20
+ */
21
+ export declare function liveModelTarget(current: LiveModelSelection, nodes: Graph['nodes'] | undefined, nodeId: string | undefined): {
22
+ provider: string;
23
+ model?: string;
24
+ } | undefined;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The provider and model a live selection gives one agent of the run, or undefined when the selection
3
+ * leaves that agent alone. `nodeId` is the engine's live id: `<node>`, `<node>/<role>` for a subagent,
4
+ * either part ending in `#fallback` on a retry's fallback attempt. A missing `model` means the
5
+ * provider's configured one.
6
+ */
7
+ export function liveModelTarget(current, nodes, nodeId) {
8
+ const [rootId, roleId] = (nodeId ?? '').split('/');
9
+ const fallback = roleId?.endsWith('#fallback') || rootId.endsWith('#fallback');
10
+ const own = nodes?.[rootId.replace(/#fallback$/, '')];
11
+ const nodeOverride = current.nodeOverrides?.[rootId.replace(/#fallback$/, '')];
12
+ if (current.nodeOnly === true && nodeOverride === undefined && own?.provider === undefined)
13
+ return undefined;
14
+ const policy = own?.subagents;
15
+ const role = policy?.roles?.find(item => item.id === roleId?.replace(/#fallback$/, ''));
16
+ const parentProvider = nodeOverride?.provider ?? own?.provider ?? current.provider;
17
+ const parentModel = nodeOverride?.model ?? own?.model ?? (own?.provider === undefined ? current.model : undefined);
18
+ let targetProvider = parentProvider, targetModel = parentModel;
19
+ if (fallback && own?.retry?.fallback) {
20
+ targetProvider = own.retry.fallback.provider;
21
+ targetModel = own.retry.fallback.model;
22
+ }
23
+ const inheritedProvider = targetProvider, inheritedModel = targetModel;
24
+ if (roleId && policy?.modelPolicy === 'specific') {
25
+ targetProvider = policy.provider ?? inheritedProvider;
26
+ targetModel = policy.model;
27
+ }
28
+ else if (roleId && policy?.modelPolicy === 'per-role') {
29
+ targetProvider = role?.provider ?? inheritedProvider;
30
+ targetModel = role?.model ?? (targetProvider === inheritedProvider ? inheritedModel : undefined);
31
+ }
32
+ if (current.overrideAllNodes && nodeOverride === undefined) {
33
+ targetProvider = current.provider;
34
+ targetModel = current.model;
35
+ }
36
+ return { provider: targetProvider, ...(targetModel === undefined ? {} : { model: targetModel }) };
37
+ }
@@ -2,6 +2,7 @@ import { CliSignIn, type ManagedSignInState } from './cli-sign-in.js';
2
2
  import { type OpenCodeServerLike, type OpenCodeSignInOption } from './opencode-cli-provider.js';
3
3
  export declare function claudeSignIn(): CliSignIn;
4
4
  export declare function grokSignIn(): CliSignIn;
5
+ export declare function googleSignIn(): CliSignIn;
5
6
  export interface OpenCodeSignInState extends ManagedSignInState {
6
7
  connected?: {
7
8
  id: string;
@@ -2,6 +2,7 @@ import { resolveCliExecutable } from './cli-executable.js';
2
2
  import { CliSignIn } from './cli-sign-in.js';
3
3
  import { claudeEnvironment, readClaudeSignIn } from './claude-provider.js';
4
4
  import { resolveClaudeExecutable } from './claude-executable.js';
5
+ import { GOOGLE_EXECUTABLE, googleEnvironment, readGoogleCatalog } from './google-provider.js';
5
6
  import { GROK_EXECUTABLE, grokEnvironment, readGrokCatalog } from './grok-provider.js';
6
7
  import { authorizeOpenCode, completeOpenCode, listOpenCodeSignIns, readOpenCodeCatalog, sharedOpenCodeServer, signOutOpenCode, } from './opencode-cli-provider.js';
7
8
  export function claudeSignIn() {
@@ -28,6 +29,18 @@ export function grokSignIn() {
28
29
  deviceCode: true,
29
30
  });
30
31
  }
32
+ export function googleSignIn() {
33
+ return new CliSignIn({
34
+ product: 'Google',
35
+ resolveExecutable: () => resolveCliExecutable(GOOGLE_EXECUTABLE),
36
+ env: () => googleEnvironment(),
37
+ loginArgs: ['acp', '--login'],
38
+ signOutHint: 'The Antigravity CLI signs out only from inside it: run agy in a terminal, type /logout, then refresh here.',
39
+ status: signal => readGoogleCatalog(signal),
40
+ pageHosts: ['accounts.google.com'],
41
+ acceptsCode: true,
42
+ });
43
+ }
31
44
  export class OpenCodeSignIn {
32
45
  server;
33
46
  attempt;
@@ -5,6 +5,8 @@ export interface MembershipVerdict {
5
5
  subject?: string;
6
6
  }
7
7
  export declare class PaidMembershipRequiredError extends Error {
8
+ /** The membership could not be checked (timeout, 5xx, 429, network). Says nothing about the account's plan. */
9
+ unavailable: boolean;
8
10
  constructor(message?: string);
9
11
  static for(access: MembershipVerdict): PaidMembershipRequiredError;
10
12
  }