@andorra-labs/code 0.1.14 → 0.1.16

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 (180) hide show
  1. package/dist/src/acp-agent.d.ts +54 -0
  2. package/dist/src/acp-agent.js +991 -0
  3. package/dist/src/agent-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +8 -2
  5. package/dist/src/agent-mcp-catalog.js +2 -0
  6. package/dist/src/agent-mcp.d.ts +3 -1
  7. package/dist/src/agent-mcp.js +97 -11
  8. package/dist/src/andorra/entry.js +21 -3
  9. package/dist/src/andorra/hosted.d.ts +3 -0
  10. package/dist/src/andorra/hosted.js +5 -1
  11. package/dist/src/andorra/notices.d.ts +10 -1
  12. package/dist/src/andorra/notices.js +25 -2
  13. package/dist/src/andorra/terminal.d.ts +2 -0
  14. package/dist/src/andorra/terminal.js +2 -2
  15. package/dist/src/app-server/protocol.d.ts +9 -2
  16. package/dist/src/app-server/protocol.js +1 -1
  17. package/dist/src/app-server/workspace.d.ts +1 -0
  18. package/dist/src/app-server/workspace.js +141 -10
  19. package/dist/src/app-server.d.ts +115 -0
  20. package/dist/src/app-server.js +980 -63
  21. package/dist/src/auth/AuthManager.js +4 -4
  22. package/dist/src/auth/deployment.js +2 -2
  23. package/dist/src/browser-bridge.d.ts +1 -0
  24. package/dist/src/browser-bridge.js +5 -2
  25. package/dist/src/browser-external-app.d.ts +27 -0
  26. package/dist/src/browser-external-app.js +60 -0
  27. package/dist/src/browser-panel-tool.d.ts +6 -0
  28. package/dist/src/browser-panel-tool.js +36 -0
  29. package/dist/src/browser-runner.js +1 -0
  30. package/dist/src/browser-server.d.ts +5 -0
  31. package/dist/src/browser-server.js +27 -3
  32. package/dist/src/browser-ui/style.css +3 -3
  33. package/dist/src/browser-ui/tokens.css +27 -16
  34. package/dist/src/browser-view.d.ts +16 -0
  35. package/dist/src/browser-view.js +60 -2
  36. package/dist/src/bug-report.d.ts +81 -0
  37. package/dist/src/bug-report.js +235 -0
  38. package/dist/src/claude-provider.d.ts +2 -1
  39. package/dist/src/claude-provider.js +13 -9
  40. package/dist/src/cli-sign-in.d.ts +3 -1
  41. package/dist/src/cli-sign-in.js +4 -1
  42. package/dist/src/cli.js +184 -40
  43. package/dist/src/codex-errors.js +4 -1
  44. package/dist/src/coding-tools.js +7 -7
  45. package/dist/src/command-screens.d.ts +9 -2
  46. package/dist/src/command-screens.js +166 -97
  47. package/dist/src/commands.d.ts +3 -2
  48. package/dist/src/commands.js +1 -0
  49. package/dist/src/compaction-phrases.d.ts +4 -0
  50. package/dist/src/compaction-phrases.js +20 -0
  51. package/dist/src/completion-gates.d.ts +22 -0
  52. package/dist/src/completion-gates.js +11 -0
  53. package/dist/src/config.d.ts +5 -0
  54. package/dist/src/config.js +48 -0
  55. package/dist/src/context-compaction.js +2 -1
  56. package/dist/src/decision/DecisionManager.js +3 -2
  57. package/dist/src/decision/requestPhrases.d.ts +4 -0
  58. package/dist/src/decision/requestPhrases.js +23 -0
  59. package/dist/src/github-inbox.d.ts +55 -0
  60. package/dist/src/github-inbox.js +153 -0
  61. package/dist/src/google-provider.d.ts +31 -0
  62. package/dist/src/google-provider.js +153 -0
  63. package/dist/src/graph-health.js +8 -4
  64. package/dist/src/graph-manager-chat.js +6 -1
  65. package/dist/src/graph-provider-portability.js +32 -10
  66. package/dist/src/graph-quota.d.ts +29 -2
  67. package/dist/src/graph-quota.js +68 -10
  68. package/dist/src/graph-runner.js +24 -7
  69. package/dist/src/graph-server.d.ts +1 -1
  70. package/dist/src/graph-server.js +9 -7
  71. package/dist/src/graph-sync.d.ts +1 -0
  72. package/dist/src/graph-sync.js +93 -34
  73. package/dist/src/graph-tool.d.ts +2 -0
  74. package/dist/src/graph-tool.js +2 -2
  75. package/dist/src/graph-ui/app.js +177 -41
  76. package/dist/src/graph-ui/controls.css +1 -0
  77. package/dist/src/graph-ui/edge-router.js +121 -53
  78. package/dist/src/graph-ui/embed.js +2 -2
  79. package/dist/src/graph-ui/icons.js +1 -0
  80. package/dist/src/graph-ui/index.html +1 -1
  81. package/dist/src/graph-ui/manager.css +1 -1
  82. package/dist/src/graph-ui/manager.js +2 -2
  83. package/dist/src/graph-ui/sidebar.js +30 -0
  84. package/dist/src/graph-ui/studio-canvas.js +26 -13
  85. package/dist/src/graph-ui/studio.css +15 -7
  86. package/dist/src/graph-ui/studio.js +11 -4
  87. package/dist/src/graph-ui/style.css +77 -45
  88. package/dist/src/graph-ui/theme.js +3 -36
  89. package/dist/src/graph-ui/tokens.css +27 -19
  90. package/dist/src/graph-visibility.d.ts +31 -0
  91. package/dist/src/graph-visibility.js +102 -0
  92. package/dist/src/graphs.js +4 -3
  93. package/dist/src/live-model.d.ts +24 -0
  94. package/dist/src/live-model.js +37 -0
  95. package/dist/src/managed-sign-in.d.ts +1 -0
  96. package/dist/src/managed-sign-in.js +13 -0
  97. package/dist/src/membership-errors.d.ts +2 -0
  98. package/dist/src/membership-errors.js +5 -1
  99. package/dist/src/membership.d.ts +23 -1
  100. package/dist/src/membership.js +48 -6
  101. package/dist/src/model-health-cache.js +1 -1
  102. package/dist/src/model-metadata.d.ts +1 -1
  103. package/dist/src/model-metadata.js +12 -3
  104. package/dist/src/paged-transcript.d.ts +2 -0
  105. package/dist/src/paged-transcript.js +16 -0
  106. package/dist/src/plan-pass.d.ts +59 -0
  107. package/dist/src/plan-pass.js +165 -0
  108. package/dist/src/provider-connection.js +17 -0
  109. package/dist/src/provider-engine.d.ts +5 -0
  110. package/dist/src/provider-engine.js +6 -3
  111. package/dist/src/provider-import.js +3 -1
  112. package/dist/src/provider-settings.js +14 -2
  113. package/dist/src/providers.d.ts +33 -2
  114. package/dist/src/providers.js +101 -28
  115. package/dist/src/pull-request-checks.d.ts +26 -0
  116. package/dist/src/pull-request-checks.js +56 -0
  117. package/dist/src/pull-request-conversation.d.ts +134 -0
  118. package/dist/src/pull-request-conversation.js +221 -0
  119. package/dist/src/pull-request-create.d.ts +175 -0
  120. package/dist/src/pull-request-create.js +392 -0
  121. package/dist/src/pull-request-details.d.ts +242 -0
  122. package/dist/src/pull-request-details.js +614 -0
  123. package/dist/src/pull-request-edit.d.ts +23 -0
  124. package/dist/src/pull-request-edit.js +91 -0
  125. package/dist/src/pull-request-logs.d.ts +76 -0
  126. package/dist/src/pull-request-logs.js +172 -0
  127. package/dist/src/pull-request-merge.d.ts +112 -0
  128. package/dist/src/pull-request-merge.js +258 -0
  129. package/dist/src/pull-request-review.d.ts +137 -0
  130. package/dist/src/pull-request-review.js +401 -0
  131. package/dist/src/pull-requests.d.ts +43 -2
  132. package/dist/src/pull-requests.js +112 -21
  133. package/dist/src/react-runtime.js +58 -9
  134. package/dist/src/read-document-tool.d.ts +2 -0
  135. package/dist/src/read-document-tool.js +6 -6
  136. package/dist/src/remote/engine-pool.js +42 -6
  137. package/dist/src/run-control.d.ts +10 -0
  138. package/dist/src/run-control.js +24 -0
  139. package/dist/src/run-progress.d.ts +10 -0
  140. package/dist/src/run-progress.js +122 -0
  141. package/dist/src/run-records.d.ts +2 -2
  142. package/dist/src/runtime-environment.d.ts +1 -0
  143. package/dist/src/runtime-environment.js +13 -0
  144. package/dist/src/runtime.d.ts +5 -1
  145. package/dist/src/runtime.js +14 -2
  146. package/dist/src/save-lock.js +14 -7
  147. package/dist/src/session-title.d.ts +3 -0
  148. package/dist/src/session-title.js +5 -2
  149. package/dist/src/sign-in-detection.d.ts +1 -1
  150. package/dist/src/sign-in-detection.js +10 -3
  151. package/dist/src/sign-in-offer.js +1 -1
  152. package/dist/src/skill-commands.js +1 -1
  153. package/dist/src/skills/bundled/bug-report/SKILL.md +80 -0
  154. package/dist/src/skills/bundled/graph-manager/SKILL.md +9 -1
  155. package/dist/src/skills/bundled/graph-manager/errors.md +1 -0
  156. package/dist/src/skills/bundled/provenance.json +7 -2
  157. package/dist/src/skills/runtime-skills.js +1 -0
  158. package/dist/src/subagent-run.js +1 -0
  159. package/dist/src/telemetry/capture-core.d.ts +17 -0
  160. package/dist/src/telemetry/capture-core.js +59 -1
  161. package/dist/src/telemetry/classify.d.ts +3 -1
  162. package/dist/src/telemetry/classify.js +37 -0
  163. package/dist/src/telemetry/emitter.d.ts +2 -0
  164. package/dist/src/telemetry/emitter.js +42 -5
  165. package/dist/src/telemetry/schema.d.ts +22 -0
  166. package/dist/src/telemetry/schema.js +68 -1
  167. package/dist/src/telemetry/surface.d.ts +1 -0
  168. package/dist/src/telemetry/uploader.d.ts +12 -1
  169. package/dist/src/telemetry/uploader.js +30 -2
  170. package/dist/src/terminal-links.d.ts +16 -0
  171. package/dist/src/terminal-links.js +113 -0
  172. package/dist/src/terminal-ui.d.ts +8 -1
  173. package/dist/src/terminal-ui.js +40 -14
  174. package/dist/src/tool-catalog.js +1 -1
  175. package/dist/src/trajectory.js +6 -1
  176. package/dist/src/transcript.d.ts +2 -0
  177. package/dist/src/transcript.js +10 -3
  178. package/dist/src/types.d.ts +9 -0
  179. package/dist/src/usage-analytics.js +18 -10
  180. package/package.json +2 -1
@@ -10,6 +10,7 @@ import { HOSTED_SKILL_LIMIT, hostedSkillLimitNotice, rankHostedSkills } from './
10
10
  import { markFactGuidance } from './guidancePolicy.js';
11
11
  import { actionablePreflightQuestion, answerOnlyTask } from './optimizationPolicy.js';
12
12
  import { parseToolRouteEvidence } from './routeTools.js';
13
+ import { pickJevRequestPhrase } from './requestPhrases.js';
13
14
  const FACT_TIMEOUT_MS = 2000;
14
15
  const families = new Set(['filesystem-read', 'filesystem-write', 'code-search', 'codegraph', 'git', 'shell', 'memory', 'web', 'browser', 'subagents', 'artifact']);
15
16
  export const toolFamilyQuestion = (family) => `tool_family_${family.replace(/-/g, '_')}`;
@@ -173,7 +174,7 @@ export class DecisionManager {
173
174
  };
174
175
  const evaluateFact = this.provider.evaluateFact?.bind(this.provider);
175
176
  if (!evaluateFact) {
176
- emit('decision.requested', { questions: [request.id] });
177
+ emit('decision.requested', { questions: [request.id], text: pickJevRequestPhrase() });
177
178
  emit('decision.fallback', { reason: 'provider_unavailable' });
178
179
  return undefined;
179
180
  }
@@ -229,7 +230,7 @@ export class DecisionManager {
229
230
  return this.settle(questions.map(q => q.id), (controllerSignal, deadlineAt) => this.provider.evaluate(structuredClone(snapshot), structuredClone(questions), controllerSignal, this.observer(emit), { deadlineAt }), value => validateBatch(value, questions), batch => Object.fromEntries(Object.entries(batch).map(([id, r]) => [id, r.type === 'noul' ? { probability: r.probability } : r.type === 'score' ? { score: r.score, confidence: r.confidence } : { ...(id === 'verification_tier' ? { choice: r.choice } : {}), confidence: r.confidence, selected: r.probabilities[r.choice] ?? 0 }])), signal, emit, this.config.requestTimeoutMs ?? DECISION_DEFAULTS.requestTimeoutMs);
230
231
  }
231
232
  async settle(questionIds, evaluate, validate, describe, signal, emit, timeoutMs) {
232
- emit('decision.requested', { questions: questionIds });
233
+ emit('decision.requested', { questions: questionIds, text: pickJevRequestPhrase() });
233
234
  if (this.config.mode === 'active' && !this.active) {
234
235
  emit('decision.fallback', { reason: 'active_unsupported' });
235
236
  return undefined;
@@ -0,0 +1,4 @@
1
+ export declare const JEV_DEFAULT_REQUEST_PHRASE = "Evaluating context needs";
2
+ export declare const JEV_REQUEST_PHRASES: readonly string[];
3
+ export declare function pickJevRequestPhrase(random?: () => number): string;
4
+ export declare function jevRequestPhrase(text: unknown): string;
@@ -0,0 +1,23 @@
1
+ // What the transcript says while a Jev request is in flight. The engine picks one per request and
2
+ // carries it on `decision.requested` as `text`, so the CLI and the desktop show the same line.
3
+ export const JEV_DEFAULT_REQUEST_PHRASE = 'Evaluating context needs';
4
+ export const JEV_REQUEST_PHRASES = [
5
+ 'Asking the tokens to carpool',
6
+ 'Clipping coupons for your context',
7
+ 'Checking which tokens spark joy',
8
+ 'Haggling with the token meter',
9
+ 'Teaching the prompt to travel light',
10
+ 'Bargain-hunting for bytes',
11
+ 'Squeezing the context like a toothpaste tube',
12
+ "Shrinking the bill before it's printed",
13
+ 'Leaving the extra tokens at home',
14
+ 'Sending unnecessary tokens home',
15
+ ];
16
+ export function pickJevRequestPhrase(random = Math.random) {
17
+ const index = Math.floor(random() * JEV_REQUEST_PHRASES.length);
18
+ return JEV_REQUEST_PHRASES[Math.min(Math.max(index, 0), JEV_REQUEST_PHRASES.length - 1)] ?? JEV_DEFAULT_REQUEST_PHRASE;
19
+ }
20
+ // Only a phrase from the list is shown; anything else on the event falls back to the default line.
21
+ export function jevRequestPhrase(text) {
22
+ return typeof text === 'string' && JEV_REQUEST_PHRASES.includes(text) ? text : JEV_DEFAULT_REQUEST_PHRASE;
23
+ }
@@ -0,0 +1,55 @@
1
+ import { type GhRunner } from './pull-requests.js';
2
+ export interface ReviewRequest {
3
+ url: string;
4
+ owner: string;
5
+ repo: string;
6
+ number: number;
7
+ title: string;
8
+ author: string;
9
+ draft: boolean;
10
+ createdAt?: string;
11
+ updatedAt?: string;
12
+ headRefName?: string;
13
+ /** The signed-in accounts asked to review it (directly or through a team). */
14
+ accounts: string[];
15
+ }
16
+ export interface RepositoryIssue {
17
+ url: string;
18
+ number: number;
19
+ title: string;
20
+ author: string;
21
+ updatedAt?: string;
22
+ labels: {
23
+ name: string;
24
+ color?: string;
25
+ }[];
26
+ assignees: string[];
27
+ comments: number;
28
+ /** Assigned to the account that read it. */
29
+ mine: boolean;
30
+ }
31
+ /** How many review requests one account's search reads; GitHub's search answers at most 100 a page. */
32
+ export declare const REVIEW_REQUESTS_READ = 50;
33
+ export declare function parseReviewRequests(raw: unknown, account: string): ReviewRequest[];
34
+ /**
35
+ * Every open pull request that asks one of gh's signed-in accounts to review it, newest activity first;
36
+ * one asked of two accounts is listed once, naming both. An account that cannot search is skipped, so one
37
+ * signed-out account does not hide the others' requests; when every account fails, the first error is thrown.
38
+ */
39
+ export declare function readReviewRequests(gh: GhRunner): Promise<{
40
+ requests: ReviewRequest[];
41
+ accounts: string[];
42
+ }>;
43
+ export declare function parseIssues(raw: unknown): {
44
+ viewer?: string;
45
+ enabled: boolean;
46
+ issues: RepositoryIssue[];
47
+ };
48
+ /** A repository's open issues, read as the first signed-in account that can read it. */
49
+ export declare function readRepositoryIssues(gh: GhRunner, owner: string, repo: string): Promise<{
50
+ viewer?: string;
51
+ enabled: boolean;
52
+ issues: RepositoryIssue[];
53
+ }>;
54
+ /** The issue of `owner/repo` that a task's first prompt names by its link, if one. */
55
+ export declare function issueNamedIn(prompt: string | undefined, owner: string, repo: string): number | undefined;
@@ -0,0 +1,153 @@
1
+ import { ghAccounts, isGhAccessError, isGhListingUnsupported } from './pull-requests.js';
2
+ const text = (value) => typeof value === 'string' && value !== '' ? value : undefined;
3
+ const record = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) ? value : {};
4
+ const list = (value) => Array.isArray(value) ? value : [];
5
+ const loginOf = (value) => text(record(value).login)?.replace(/^app\//, '');
6
+ function graphqlErrors(value) {
7
+ const errors = list(value.errors).map(entry => text(record(entry).message)).filter((message) => message !== undefined);
8
+ if (errors.length > 0)
9
+ throw new Error(`GraphQL: ${errors.join('; ')}`);
10
+ }
11
+ const SEARCH_QUERY = 'query($q: String!) { viewer { login } search(query: $q, type: ISSUE, first: 50) { issueCount nodes { ... on PullRequest { number title url isDraft createdAt updatedAt headRefName author { login } repository { name owner { login } } } } } }';
12
+ /** How many review requests one account's search reads; GitHub's search answers at most 100 a page. */
13
+ export const REVIEW_REQUESTS_READ = 50;
14
+ export function parseReviewRequests(raw, account) {
15
+ return list(record(record(record(raw).data).search).nodes).map(record).flatMap((node) => {
16
+ const url = text(node.url);
17
+ const number = typeof node.number === 'number' && Number.isSafeInteger(node.number) ? node.number : undefined;
18
+ const repository = record(node.repository);
19
+ const owner = loginOf(repository.owner);
20
+ const repo = text(repository.name);
21
+ if (url === undefined || number === undefined || owner === undefined || repo === undefined || !/^https:\/\/github\.com\//.test(url))
22
+ return [];
23
+ return [{
24
+ url, owner, repo, number, title: text(node.title) ?? `#${number}`, author: loginOf(node.author) ?? 'ghost', draft: node.isDraft === true,
25
+ ...defined({ createdAt: text(node.createdAt), updatedAt: text(node.updatedAt), headRefName: text(node.headRefName) }),
26
+ accounts: [account],
27
+ }];
28
+ });
29
+ }
30
+ /**
31
+ * Every open pull request that asks one of gh's signed-in accounts to review it, newest activity first;
32
+ * one asked of two accounts is listed once, naming both. An account that cannot search is skipped, so one
33
+ * signed-out account does not hide the others' requests; when every account fails, the first error is thrown.
34
+ */
35
+ export async function readReviewRequests(gh) {
36
+ let accounts;
37
+ try {
38
+ accounts = await ghAccounts(gh);
39
+ }
40
+ catch (error) {
41
+ if (!isGhListingUnsupported(error))
42
+ throw error;
43
+ accounts = [];
44
+ }
45
+ const asked = accounts.length > 0 ? accounts.map(user => ({ user, login: user })) : [{}];
46
+ const byUrl = new Map();
47
+ const read = [];
48
+ let firstError;
49
+ for (const entry of asked) {
50
+ try {
51
+ const run = entry.user === undefined ? gh : (args, options) => gh(args, { ...options, user: entry.user });
52
+ const raw = JSON.parse(await run(['api', 'graphql', '--hostname', 'github.com', '-f', `query=${SEARCH_QUERY}`, '-f', `q=is:pr is:open archived:false review-requested:${entry.login ?? '@me'} sort:updated-desc`]));
53
+ graphqlErrors(raw);
54
+ const login = entry.login ?? loginOf(record(record(raw.data).viewer)) ?? 'you';
55
+ read.push(login);
56
+ for (const request of parseReviewRequests(raw, login)) {
57
+ const held = byUrl.get(request.url);
58
+ if (held) {
59
+ if (!held.accounts.includes(login))
60
+ held.accounts.push(login);
61
+ }
62
+ else
63
+ byUrl.set(request.url, request);
64
+ }
65
+ }
66
+ catch (error) {
67
+ firstError ??= error;
68
+ }
69
+ }
70
+ if (read.length === 0 && firstError !== undefined)
71
+ throw firstError;
72
+ const stamp = (request) => Date.parse(request.updatedAt ?? request.createdAt ?? '') || 0;
73
+ return { requests: [...byUrl.values()].sort((a, b) => stamp(b) - stamp(a)), accounts: read };
74
+ }
75
+ const ISSUES_QUERY = 'query($owner: String!, $name: String!) { viewer { login } repository(owner: $owner, name: $name) { hasIssuesEnabled issues(states: OPEN, first: 50, orderBy: { field: UPDATED_AT, direction: DESC }) { nodes { number title url updatedAt author { login } labels(first: 5) { nodes { name color } } assignees(first: 5) { nodes { login } } comments { totalCount } } } } }';
76
+ export function parseIssues(raw) {
77
+ const data = record(record(raw).data);
78
+ const viewer = loginOf(data.viewer);
79
+ const repository = record(data.repository);
80
+ const issues = list(record(repository.issues).nodes).map(record).flatMap((node) => {
81
+ const url = text(node.url);
82
+ const number = typeof node.number === 'number' && Number.isSafeInteger(node.number) ? node.number : undefined;
83
+ if (url === undefined || number === undefined)
84
+ return [];
85
+ const assignees = list(record(node.assignees).nodes).map(loginOf).filter((login) => login !== undefined);
86
+ const count = record(node.comments).totalCount;
87
+ return [{
88
+ url, number, title: text(node.title) ?? `#${number}`, author: loginOf(node.author) ?? 'ghost',
89
+ ...defined({ updatedAt: text(node.updatedAt) }),
90
+ labels: list(record(node.labels).nodes).map(record).flatMap(label => {
91
+ const name = text(label.name);
92
+ const color = text(label.color);
93
+ return name === undefined ? [] : [{ name, ...(color !== undefined && /^[0-9a-f]{6}$/i.test(color) ? { color: color.toLowerCase() } : {}) }];
94
+ }),
95
+ assignees,
96
+ comments: typeof count === 'number' && Number.isSafeInteger(count) && count > 0 ? count : 0,
97
+ mine: viewer !== undefined && assignees.some(login => login.toLowerCase() === viewer.toLowerCase()),
98
+ }];
99
+ });
100
+ // Issues assigned to the reader first, then the rest, each by latest activity as GitHub sent them.
101
+ return { ...defined({ viewer }), enabled: repository.hasIssuesEnabled !== false, issues: [...issues.filter(issue => issue.mine), ...issues.filter(issue => !issue.mine)] };
102
+ }
103
+ /** A repository's open issues, read as the first signed-in account that can read it. */
104
+ export async function readRepositoryIssues(gh, owner, repo) {
105
+ let accounts;
106
+ try {
107
+ accounts = await ghAccounts(gh);
108
+ }
109
+ catch (error) {
110
+ if (!isGhListingUnsupported(error))
111
+ throw error;
112
+ accounts = [];
113
+ }
114
+ const read = async (user) => {
115
+ const run = user === undefined ? gh : (args, options) => gh(args, { ...options, user });
116
+ const raw = JSON.parse(await run(['api', 'graphql', '--hostname', 'github.com', '-f', `query=${ISSUES_QUERY}`, '-f', `owner=${owner}`, '-f', `name=${repo}`]));
117
+ graphqlErrors(raw);
118
+ const found = record(raw.data).repository;
119
+ if (found === null || found === undefined)
120
+ throw new Error(`GraphQL: Could not resolve to a Repository with the name '${owner}/${repo}'.`);
121
+ return parseIssues(raw);
122
+ };
123
+ if (accounts.length === 0)
124
+ return read(undefined);
125
+ let firstError;
126
+ for (const user of accounts) {
127
+ try {
128
+ return await read(user);
129
+ }
130
+ catch (error) {
131
+ if (!isGhAccessError(error))
132
+ throw error;
133
+ firstError ??= error;
134
+ }
135
+ }
136
+ throw firstError;
137
+ }
138
+ /** The issue of `owner/repo` that a task's first prompt names by its link, if one. */
139
+ export function issueNamedIn(prompt, owner, repo) {
140
+ if (prompt === undefined)
141
+ return undefined;
142
+ const pattern = new RegExp(`https://github\\.com/${owner.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/${repo.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/issues/(\\d+)\\b`, 'i');
143
+ const match = pattern.exec(prompt);
144
+ const number = match ? Number(match[1]) : undefined;
145
+ return number !== undefined && Number.isSafeInteger(number) && number > 0 ? number : undefined;
146
+ }
147
+ function defined(values) {
148
+ const kept = {};
149
+ for (const [key, value] of Object.entries(values))
150
+ if (value !== undefined)
151
+ kept[key] = value;
152
+ return kept;
153
+ }
@@ -0,0 +1,31 @@
1
+ import { type CliExecutableSpec } from './cli-executable.js';
2
+ import type { ModelAdapter, ModelResponse, ToolSchema } from './types.js';
3
+ export declare const GOOGLE_BASE_URL = "https://antigravity.google";
4
+ export declare const GOOGLE_EXECUTABLE: CliExecutableSpec;
5
+ export declare function googleEnvironment(source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
6
+ export interface GoogleRunOptions {
7
+ input?: string;
8
+ captureStderr?: boolean;
9
+ acceptedExitCodes?: number[];
10
+ }
11
+ export type GoogleRun = (args: string[], signal: AbortSignal, options?: GoogleRunOptions) => Promise<{
12
+ stdout: string;
13
+ stderr: string;
14
+ }>;
15
+ export interface GoogleDependencies {
16
+ run?: GoogleRun;
17
+ }
18
+ export declare const runGoogleProcess: GoogleRun;
19
+ export declare function parseGoogleModels(output: string): {
20
+ signedIn: boolean;
21
+ models: string[];
22
+ };
23
+ export declare function readGoogleCatalog(signal: AbortSignal, dependencies?: GoogleDependencies): Promise<{
24
+ signedIn: boolean;
25
+ models: string[];
26
+ }>;
27
+ export declare function parseGoogleResponse(output: string, tools?: readonly Pick<ToolSchema, 'name'>[]): ModelResponse;
28
+ export declare function parseGoogleText(output: string): ModelResponse;
29
+ export declare function createGoogleAdapter(_config: {
30
+ model: string;
31
+ }, dependencies?: GoogleDependencies): ModelAdapter;
@@ -0,0 +1,153 @@
1
+ import { join } from 'node:path';
2
+ import { resolveCliExecutable } from './cli-executable.js';
3
+ import { runBoundedCli } from './cli-process.js';
4
+ import { allowanceInstruction, boundTextStep, parseStructuredStep, STRUCTURED_STEP_PROMPT, STRUCTURED_STEP_SCHEMA, structuredStepPrompt, TEXT_STEP_PROMPT } from './structured-step.js';
5
+ export const GOOGLE_BASE_URL = 'https://antigravity.google';
6
+ export const GOOGLE_EXECUTABLE = {
7
+ names: ['agy'], overrideEnv: 'ANDORRA_AGY_PATH', homeDirectories: [join('AppData', 'Local', 'agy', 'bin'), join('.local', 'bin')],
8
+ installMessage: 'Install the Antigravity CLI (agy) from antigravity.google, sign in with Google, then retry the Google provider.',
9
+ };
10
+ const SIGN_IN_MESSAGE = 'Sign in with Google in the Antigravity CLI (agy) on this machine, then retry the Google provider.';
11
+ const REQUEST_TIMEOUT_MS = 10 * 60_000;
12
+ const CATALOG_TIMEOUT_MS = 30_000;
13
+ // Strict permissions make the CLI ask before every one of its own tools, and a headless run cannot
14
+ // answer, so each is denied: the CLI serves as a model and Andorra runs the tools.
15
+ const STEP_SETTINGS = JSON.stringify({ toolPermission: 'strict', disableSlashCommands: true, allowNonWorkspaceAccess: false });
16
+ export function googleEnvironment(source = process.env) {
17
+ const env = Object.fromEntries(Object.entries(source).filter(([key]) => !/^(?:GEMINI_API_KEY$|GOOGLE_API_KEY$|GOOGLE_GENAI_|NODE_OPTIONS$)/i.test(key)));
18
+ return { ...env, NO_COLOR: '1' };
19
+ }
20
+ export const runGoogleProcess = async (args, signal, options = {}) => {
21
+ const executable = await resolveCliExecutable(GOOGLE_EXECUTABLE);
22
+ return runBoundedCli(executable, () => args, signal, { env: googleEnvironment(), label: 'Antigravity CLI', ...options });
23
+ };
24
+ /** The CLI also lists models from other vendors; only Google's own are offered here. */
25
+ const GOOGLE_MODEL = /^gemini-[\w.-]{1,200}$/;
26
+ export function parseGoogleModels(output) {
27
+ const plain = output.replace(/\u001b\[[0-9;]*m/g, '');
28
+ if (/\b(?:please sign in|authentication required|not (?:authenticated|signed in|logged in))\b/i.test(plain))
29
+ return { signedIn: false, models: [] };
30
+ const models = [];
31
+ let listed = 0;
32
+ for (const line of plain.split(/\r?\n/)) {
33
+ const id = line.match(/^([\w.-]+)\t/)?.[1];
34
+ if (!id)
35
+ continue;
36
+ listed += 1;
37
+ if (GOOGLE_MODEL.test(id) && !models.includes(id) && models.length < 1000)
38
+ models.push(id);
39
+ }
40
+ return { signedIn: listed > 0, models };
41
+ }
42
+ export async function readGoogleCatalog(signal, dependencies = {}) {
43
+ const run = dependencies.run ?? runGoogleProcess;
44
+ const bounded = AbortSignal.any([signal, AbortSignal.timeout(CATALOG_TIMEOUT_MS)]);
45
+ const { stdout, stderr } = await run(['models'], bounded, { captureStderr: true, acceptedExitCodes: [0, 1] });
46
+ return parseGoogleModels(`${stdout}\n${stderr}`);
47
+ }
48
+ function frames(text) {
49
+ return text.split(/\r?\n/).filter(line => line.trim().startsWith('{')).map(line => {
50
+ try {
51
+ return JSON.parse(line);
52
+ }
53
+ catch {
54
+ throw new Error('Antigravity CLI returned malformed JSON');
55
+ }
56
+ });
57
+ }
58
+ function googleUsage(usage) {
59
+ if (!usage || typeof usage !== 'object')
60
+ return undefined;
61
+ const token = (name) => Number.isSafeInteger(usage[name]) && usage[name] >= 0 ? usage[name] : undefined;
62
+ const input = token('input_tokens');
63
+ const output = token('output_tokens');
64
+ const read = token('cache_read_tokens');
65
+ if (!input && !output && !read)
66
+ return { requests: 1 };
67
+ return { requests: 1,
68
+ ...(input === undefined ? {} : { inputTokens: input + (read ?? 0) }),
69
+ ...(output === undefined ? {} : { outputTokens: output }),
70
+ ...(read === undefined ? {} : { cacheRead: read }) };
71
+ }
72
+ function failure(message) {
73
+ if (typeof message === 'string' && /\bauthenticat|\bsign in\b|\blog in\b/i.test(message))
74
+ return new Error(SIGN_IN_MESSAGE);
75
+ return new Error('Google inference failed. Check the Antigravity CLI sign-in, model access, and plan limits.');
76
+ }
77
+ function singleResult(output, attempted) {
78
+ const events = frames(output);
79
+ for (const event of events) {
80
+ const step = event?.event === 'step_update' ? event.step_update : undefined;
81
+ if (step && (step.step_type === 'tool' || step.tool_name !== undefined || step.tool_info !== undefined || step.subagent_info !== undefined))
82
+ throw new Error(attempted);
83
+ }
84
+ const results = events.filter(event => event?.event === 'result').map(event => event.result);
85
+ if (results.length !== 1 || !results[0] || typeof results[0] !== 'object')
86
+ throw new Error('Google did not return exactly one model result');
87
+ const result = results[0];
88
+ if (result.status !== 'SUCCESS')
89
+ throw failure(result.error);
90
+ if (Array.isArray(result.denied_actions) && result.denied_actions.length)
91
+ throw new Error(attempted);
92
+ return result;
93
+ }
94
+ export function parseGoogleResponse(output, tools = []) {
95
+ const result = singleResult(output, 'Google attempted a native tool');
96
+ let structured = result.structured_output;
97
+ if (structured === undefined && typeof result.response === 'string') {
98
+ try {
99
+ structured = JSON.parse(result.response);
100
+ }
101
+ catch { }
102
+ }
103
+ if (structured === undefined)
104
+ throw new Error('Google did not return a complete Andorra model step');
105
+ const response = parseStructuredStep(structured, tools, 'Google');
106
+ const usage = googleUsage(result.usage);
107
+ if (usage)
108
+ response.usage = usage;
109
+ return response;
110
+ }
111
+ export function parseGoogleText(output) {
112
+ const result = singleResult(output, 'Google attempted a tool during text generation');
113
+ const usage = googleUsage(result.usage);
114
+ return { text: typeof result.response === 'string' ? result.response.replace(/\r?\n$/, '') : '', toolCalls: [], ...(usage ? { usage } : {}) };
115
+ }
116
+ export function createGoogleAdapter(_config, dependencies = {}) {
117
+ const run = dependencies.run ?? runGoogleProcess;
118
+ return {
119
+ async listModels(signal) {
120
+ const catalog = await readGoogleCatalog(signal, dependencies);
121
+ if (!catalog.signedIn)
122
+ throw new Error(SIGN_IN_MESSAGE);
123
+ return catalog.models;
124
+ },
125
+ async generate(request) {
126
+ request.signal.throwIfAborted();
127
+ if (!GOOGLE_MODEL.test(request.model))
128
+ throw new Error('The Google provider runs Gemini models only. Choose a Gemini model.');
129
+ const auxiliary = request.maxTokens !== undefined;
130
+ if (auxiliary && (!Number.isSafeInteger(request.maxTokens) || request.maxTokens < 1))
131
+ throw new Error('Invalid auxiliary output allowance.');
132
+ if (auxiliary && request.tools.length)
133
+ throw new Error('Google cannot apply an auxiliary output allowance to tool-bearing requests.');
134
+ const signal = AbortSignal.any([request.signal, AbortSignal.timeout(REQUEST_TIMEOUT_MS)]);
135
+ const imageCount = request.messages.reduce((total, message) => total + (message.images?.length ?? 0), 0);
136
+ // The CLI has no system-prompt override, so the model-component instructions travel in the prompt.
137
+ const prompt = JSON.stringify({
138
+ instructions: auxiliary ? `${TEXT_STEP_PROMPT} ${allowanceInstruction(request.maxTokens)}` : STRUCTURED_STEP_PROMPT,
139
+ ...JSON.parse(structuredStepPrompt(request)),
140
+ ...(imageCount ? { omittedImages: `This provider cannot forward images; ${imageCount} image${imageCount === 1 ? ' was' : 's were'} omitted from the conversation.` } : {})
141
+ });
142
+ request.onRequest?.();
143
+ const { stdout } = await run(['--input-format', 'stream-json', '--output-format', 'stream-json', '--model', request.model,
144
+ '--settings', STEP_SETTINGS, '--disable-slash-commands',
145
+ ...(auxiliary ? [] : ['--json-schema', JSON.stringify(STRUCTURED_STEP_SCHEMA)])], signal, { input: `${JSON.stringify({ event: 'user', message: { content: prompt } })}\n`, acceptedExitCodes: [0, 1] });
146
+ signal.throwIfAborted();
147
+ if (!auxiliary)
148
+ return parseGoogleResponse(stdout, request.tools);
149
+ const text = parseGoogleText(stdout);
150
+ return boundTextStep(text, request.maxTokens, text.usage?.outputTokens);
151
+ },
152
+ };
153
+ }
@@ -1,4 +1,4 @@
1
- import { configuredContextWindow, createAdapter } from './providers.js';
1
+ import { configuredContextWindow, createAdapter, findProviderById, providerModelId } from './providers.js';
2
2
  import { ANDORRA_UNAVAILABLE_MESSAGE } from './andorra/endpoint.js';
3
3
  export function resumeModelNodes(graph, resume) {
4
4
  if (resume === undefined)
@@ -30,7 +30,11 @@ export function resumeModelNodes(graph, resume) {
30
30
  function graphModels(graph, config, session = {}, only) {
31
31
  const references = new Map();
32
32
  const sessionProvider = session.provider ?? config.provider;
33
- const resolve = (provider, model) => ({ provider, model: model ?? config.providers.find(p => p.id === provider)?.model ?? '(default model)' });
33
+ // Each probe names the model as the provider it is sent to spells it.
34
+ const resolve = (provider, model) => {
35
+ const local = findProviderById(config.providers, provider);
36
+ return { provider, model: model === undefined ? local?.model ?? '(default model)' : local ? providerModelId(local, model) ?? model : model };
37
+ };
34
38
  const inherited = (node) => node.provider === undefined
35
39
  ? resolve(sessionProvider, node.model ?? session.model)
36
40
  : resolve(node.provider, node.model);
@@ -106,7 +110,7 @@ export async function checkGraphModelHealth(graph, config, signal, dependencies
106
110
  if (overall?.signal.aborted)
107
111
  return;
108
112
  const index = next++, reference = references[index];
109
- const provider = config.providers.find(p => p.id === reference.provider);
113
+ const provider = findProviderById(config.providers, reference.provider);
110
114
  if (!provider) {
111
115
  failures[index] = { ...reference, reason: 'Provider is not configured.' };
112
116
  continue;
@@ -157,7 +161,7 @@ export async function checkGraphModelHealth(graph, config, signal, dependencies
157
161
  // The probe of an Andorra model makes one attempt. The adapter's retry schedule (up to minutes, for a
158
162
  // router that cannot be reached) belongs to a conversation, where each retry is shown; here it would
159
163
  // only be a silent wait, so the first retry it announces ends the probe with that retry's reason.
160
- ...(provider.type === 'andorra' ? { onRetry: (retry) => { throw new Error(retry.reason); } } : {}),
164
+ ...(provider.type === 'andorra' ? { onRetry: (retry) => { throw new Error(retry.cause && /^[A-Z][A-Z0-9_]{0,63}$/.test(retry.cause) ? `${retry.reason} (${retry.cause})` : retry.reason); } } : {}),
161
165
  });
162
166
  }), aborted]);
163
167
  signal.throwIfAborted();
@@ -7,6 +7,7 @@ import { createInterface } from 'node:readline';
7
7
  import { fileURLToPath } from 'node:url';
8
8
  import { stopAutomationWorker } from './automation-worker-shutdown.js';
9
9
  import { configDirectory } from './config.js';
10
+ import { announceGraphVisibilityChange } from './graph-visibility.js';
10
11
  import { GRAPH_MANAGER_GRAPH_ID } from './graphs.js';
11
12
  import { clipText } from './text.js';
12
13
  import { describeTool } from './transcript.js';
@@ -579,7 +580,11 @@ export class GraphManagerChat {
579
580
  await stopAutomationWorker(engine.child, engine.closed);
580
581
  }
581
582
  onEngineEvent(event, data) {
582
- if (event === 'run.started' && typeof data.runId === 'string' && this.state === 'starting')
583
+ // The manager runs in its own engine process, so a change it makes to the account's graphs (project visibility
584
+ // included) is announced only there. Pass it on, so the engine hosting this editor tells its clients to reload.
585
+ if (event === 'graphs.changed')
586
+ announceGraphVisibilityChange();
587
+ else if (event === 'run.started' && typeof data.runId === 'string' && this.state === 'starting')
583
588
  this.runId = data.runId;
584
589
  else if (event === 'run.event')
585
590
  this.onRunEvent(record(data.event));
@@ -1,4 +1,4 @@
1
- import { PROVIDER_TYPES, providerModels } from './providers.js';
1
+ import { findProviderById, PROVIDER_TYPES, providerModelId } from './providers.js';
2
2
  const profileKey = 'graphProviderProfilesV1';
3
3
  export class GraphProviderUnavailableError extends Error {
4
4
  constructor(message) {
@@ -51,11 +51,11 @@ export function stampGraphProviderProfiles(graph, config, selectedModels = {}) {
51
51
  for (const reference of references(copy)) {
52
52
  if (!reference.provider)
53
53
  continue;
54
- const provider = config.providers.find(item => item.id === reference.provider);
54
+ const provider = findProviderById(config.providers, reference.provider);
55
55
  if (!provider)
56
56
  continue;
57
- const selectedModel = Object.hasOwn(selectedModels, reference.provider)
58
- ? selectedModels[reference.provider] : undefined;
57
+ const selectedModel = Object.hasOwn(selectedModels, reference.provider) ? selectedModels[reference.provider]
58
+ : Object.hasOwn(selectedModels, provider.id) ? selectedModels[provider.id] : undefined;
59
59
  if (!selectedModel && Object.hasOwn(saved, reference.provider))
60
60
  continue;
61
61
  Object.defineProperty(saved, reference.provider, {
@@ -71,6 +71,9 @@ export function bindPortableGraphProviders(graph, config) {
71
71
  const copy = structuredClone(graph);
72
72
  const saved = profiles(copy);
73
73
  const requirements = new Map();
74
+ // Subagent references without a provider of their own run on their node's provider; their model is respelled to it.
75
+ const inheritors = [];
76
+ const resolvedIds = new Map();
74
77
  const add = (reference, inheritedModels = [], inheritsParentModel = false) => {
75
78
  if (!reference.provider)
76
79
  return;
@@ -100,8 +103,11 @@ export function bindPortableGraphProviders(graph, config) {
100
103
  const children = policy.modelPolicy === 'per-role' ? policy.roles ?? []
101
104
  : policy.modelPolicy === 'specific' ? [policy] : [];
102
105
  for (const child of children) {
103
- if (!child.provider && child.model)
106
+ if (!child.provider && child.model) {
104
107
  inherited.push(child.model);
108
+ if (node.provider)
109
+ inheritors.push({ provider: node.provider, reference: child });
110
+ }
105
111
  }
106
112
  }
107
113
  add(node, inherited);
@@ -118,13 +124,20 @@ export function bindPortableGraphProviders(graph, config) {
118
124
  }
119
125
  }
120
126
  }
127
+ // A recorded profile is found under any spelling of its id, as the provider itself is.
128
+ const recorded = (id) => {
129
+ if (Object.hasOwn(saved, id))
130
+ return saved[id];
131
+ const matches = Object.keys(saved).filter(key => key.toLowerCase() === id.toLowerCase());
132
+ return matches.length === 1 ? saved[matches[0]] : undefined;
133
+ };
121
134
  for (const [originalId, required] of requirements) {
122
- const original = Object.hasOwn(saved, originalId) ? saved[originalId] : undefined;
135
+ const original = recorded(originalId);
123
136
  const explicitModels = [...required.models];
124
137
  const requiredModels = original && required.inheritsRecordedModel ? [...explicitModels, original.model] : explicitModels;
125
- const offers = (provider, models) => models.every(model => providerModels(provider).includes(model));
138
+ const offers = (provider, models) => models.every(model => providerModelId(provider, model) !== undefined);
126
139
  const sameType = (provider) => !original || provider.type === original.type;
127
- const exact = config.providers.find(provider => provider.id === originalId);
140
+ const exact = findProviderById(config.providers, originalId);
128
141
  let resolved = exact && sameType(exact) && offers(exact, explicitModels) ? exact : undefined;
129
142
  const exactResolved = resolved !== undefined;
130
143
  if (!resolved && exact === undefined && original?.type === 'codex') {
@@ -144,15 +157,24 @@ export function bindPortableGraphProviders(graph, config) {
144
157
  + 'Connect the corresponding OAuth provider or configure the same provider ID and models in /providers, '
145
158
  + 'or start the task with a model override so every node runs on one provider.');
146
159
  }
160
+ resolvedIds.set(originalId, resolved);
147
161
  for (const tracked of required.references) {
148
162
  tracked.reference.provider = resolved.id;
149
163
  if (tracked.inheritsParentModel && !tracked.reference.model)
150
164
  continue;
151
- if (tracked.reference.model)
165
+ if (tracked.reference.model) {
166
+ // The request names the model as this machine's provider spells it.
167
+ tracked.reference.model = providerModelId(resolved, tracked.reference.model) ?? tracked.reference.model;
152
168
  continue;
169
+ }
153
170
  if (!exactResolved && original?.model)
154
- tracked.reference.model = original.model;
171
+ tracked.reference.model = providerModelId(resolved, original.model) ?? original.model;
155
172
  }
156
173
  }
174
+ for (const { provider, reference } of inheritors) {
175
+ const resolved = resolvedIds.get(provider);
176
+ if (resolved && reference.model)
177
+ reference.model = providerModelId(resolved, reference.model) ?? reference.model;
178
+ }
157
179
  return copy;
158
180
  }