@andorra-labs/code 0.1.16 → 0.1.17

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 (188) hide show
  1. package/dist/src/acp-agent.d.ts +6 -0
  2. package/dist/src/acp-agent.js +15 -4
  3. package/dist/src/agent-execution.js +11 -8
  4. package/dist/src/agent-mcp-catalog.js +1 -0
  5. package/dist/src/agent-mcp.d.ts +3 -0
  6. package/dist/src/agent-mcp.js +33 -1
  7. package/dist/src/andorra/entry.d.ts +10 -0
  8. package/dist/src/andorra/entry.js +18 -4
  9. package/dist/src/andorra/hosted.d.ts +2 -1
  10. package/dist/src/andorra/hosted.js +2 -1
  11. package/dist/src/andorra/notices.d.ts +5 -0
  12. package/dist/src/andorra/notices.js +7 -0
  13. package/dist/src/andorra/state.d.ts +3 -2
  14. package/dist/src/andorra/state.js +4 -4
  15. package/dist/src/andorra/terminal.js +7 -2
  16. package/dist/src/anthropic-credentials.js +2 -0
  17. package/dist/src/app-server/error.d.ts +5 -0
  18. package/dist/src/app-server/error.js +7 -0
  19. package/dist/src/app-server/protocol.d.ts +19 -44
  20. package/dist/src/app-server/protocol.js +5 -1
  21. package/dist/src/app-server/workspace.d.ts +89 -0
  22. package/dist/src/app-server/workspace.js +457 -11
  23. package/dist/src/app-server.d.ts +358 -32
  24. package/dist/src/app-server.js +2429 -509
  25. package/dist/src/bridge/cloud.d.ts +27 -0
  26. package/dist/src/bridge/cloud.js +187 -0
  27. package/dist/src/bridge/command.d.ts +30 -0
  28. package/dist/src/bridge/command.js +347 -0
  29. package/dist/src/bridge/control.d.ts +68 -0
  30. package/dist/src/bridge/control.js +233 -0
  31. package/dist/src/bridge/engines.d.ts +90 -0
  32. package/dist/src/bridge/engines.js +601 -0
  33. package/dist/src/bridge/host-ops.d.ts +9 -0
  34. package/dist/src/bridge/host-ops.js +129 -0
  35. package/dist/src/bridge/host.d.ts +47 -0
  36. package/dist/src/bridge/host.js +540 -0
  37. package/dist/src/bridge/link.d.ts +38 -0
  38. package/dist/src/bridge/link.js +508 -0
  39. package/dist/src/bridge/login-link.d.ts +29 -0
  40. package/dist/src/bridge/login-link.js +54 -0
  41. package/dist/src/bridge/protocol.d.ts +136 -0
  42. package/dist/src/bridge/protocol.js +11 -0
  43. package/dist/src/bridge/store.d.ts +12 -0
  44. package/dist/src/bridge/store.js +61 -0
  45. package/dist/src/bridge/wording.d.ts +6 -0
  46. package/dist/src/bridge/wording.js +10 -0
  47. package/dist/src/browser-server.js +7 -1
  48. package/dist/src/browser-ui/tokens.css +1 -1
  49. package/dist/src/change-authors.d.ts +41 -0
  50. package/dist/src/change-authors.js +146 -0
  51. package/dist/src/cli.js +182 -32
  52. package/dist/src/coding-tools.js +15 -15
  53. package/dist/src/command-screens.d.ts +6 -0
  54. package/dist/src/command-screens.js +14 -11
  55. package/dist/src/commands.d.ts +14 -2
  56. package/dist/src/compaction-phrases.js +1 -1
  57. package/dist/src/completion.js +82 -5
  58. package/dist/src/config.d.ts +71 -3
  59. package/dist/src/config.js +202 -77
  60. package/dist/src/deadline.js +13 -1
  61. package/dist/src/decision/checks.js +1 -1
  62. package/dist/src/decision/requestPhrases.js +0 -1
  63. package/dist/src/default-graph.js +1 -1
  64. package/dist/src/file-diff.d.ts +4 -0
  65. package/dist/src/file-diff.js +2 -1
  66. package/dist/src/github-app/agent-writes.d.ts +102 -0
  67. package/dist/src/github-app/agent-writes.js +320 -0
  68. package/dist/src/github-app/client.d.ts +349 -0
  69. package/dist/src/github-app/client.js +810 -0
  70. package/dist/src/github-app/event-source.d.ts +208 -0
  71. package/dist/src/github-app/event-source.js +684 -0
  72. package/dist/src/github-app/metrics.d.ts +32 -0
  73. package/dist/src/github-app/metrics.js +49 -0
  74. package/dist/src/github-app/review-loop.d.ts +274 -0
  75. package/dist/src/github-app/review-loop.js +1177 -0
  76. package/dist/src/github-app/review-node.d.ts +81 -0
  77. package/dist/src/github-app/review-node.js +205 -0
  78. package/dist/src/github-app/review-post.d.ts +73 -0
  79. package/dist/src/github-app/review-post.js +139 -0
  80. package/dist/src/github-app/review-text.d.ts +107 -0
  81. package/dist/src/github-app/review-text.js +1133 -0
  82. package/dist/src/github-app/review-threads.d.ts +47 -0
  83. package/dist/src/github-app/review-threads.js +107 -0
  84. package/dist/src/github-app/reviewer.d.ts +121 -0
  85. package/dist/src/github-app/reviewer.js +598 -0
  86. package/dist/src/github-app/store.d.ts +59 -0
  87. package/dist/src/github-app/store.js +148 -0
  88. package/dist/src/github-app/triggers.d.ts +141 -0
  89. package/dist/src/github-app/triggers.js +441 -0
  90. package/dist/src/github-names.d.ts +8 -0
  91. package/dist/src/github-names.js +8 -0
  92. package/dist/src/glob-search.d.ts +61 -0
  93. package/dist/src/glob-search.js +180 -0
  94. package/dist/src/graph-health.js +6 -1
  95. package/dist/src/graph-manager-chat.js +1 -1
  96. package/dist/src/graph-preview.d.ts +46 -0
  97. package/dist/src/graph-preview.js +55 -0
  98. package/dist/src/graph-provider-portability.js +2 -1
  99. package/dist/src/graph-runner.js +64 -3
  100. package/dist/src/graph-server.js +3 -3
  101. package/dist/src/graph-sync.js +3 -3
  102. package/dist/src/graph-ui/app.js +91 -7
  103. package/dist/src/graph-ui/icons.js +2 -1
  104. package/dist/src/graph-ui/studio.js +15 -1
  105. package/dist/src/graph-ui/tokens.css +1 -1
  106. package/dist/src/graphs.d.ts +34 -1
  107. package/dist/src/graphs.js +158 -14
  108. package/dist/src/image-input.d.ts +16 -0
  109. package/dist/src/image-input.js +41 -0
  110. package/dist/src/membership.d.ts +10 -0
  111. package/dist/src/membership.js +19 -4
  112. package/dist/src/model-health-cache.js +1 -1
  113. package/dist/src/model-metadata.d.ts +6 -0
  114. package/dist/src/model-metadata.js +35 -15
  115. package/dist/src/model-relay/local.d.ts +116 -0
  116. package/dist/src/model-relay/local.js +468 -0
  117. package/dist/src/model-relay/remote.d.ts +129 -0
  118. package/dist/src/model-relay/remote.js +252 -0
  119. package/dist/src/model-relay/runs.d.ts +34 -0
  120. package/dist/src/model-relay/runs.js +146 -0
  121. package/dist/src/model-relay/wire.d.ts +5 -0
  122. package/dist/src/model-relay/wire.js +5 -0
  123. package/dist/src/project-registry.d.ts +21 -0
  124. package/dist/src/project-registry.js +74 -0
  125. package/dist/src/provider-import.d.ts +0 -12
  126. package/dist/src/provider-import.js +7 -195
  127. package/dist/src/providers.d.ts +23 -2
  128. package/dist/src/providers.js +25 -4
  129. package/dist/src/pull-request-logs.d.ts +12 -1
  130. package/dist/src/pull-request-logs.js +14 -3
  131. package/dist/src/pull-requests.d.ts +327 -7
  132. package/dist/src/pull-requests.js +429 -51
  133. package/dist/src/react-runtime.js +1 -1
  134. package/dist/src/remote/engine-pool.d.ts +88 -4
  135. package/dist/src/remote/engine-pool.js +366 -89
  136. package/dist/src/remote/roots.d.ts +19 -0
  137. package/dist/src/remote/roots.js +45 -7
  138. package/dist/src/remote/types.d.ts +0 -44
  139. package/dist/src/run-control.d.ts +7 -0
  140. package/dist/src/run-control.js +23 -0
  141. package/dist/src/run-records.d.ts +7 -2
  142. package/dist/src/run-records.js +71 -6
  143. package/dist/src/runtime.d.ts +5 -1
  144. package/dist/src/runtime.js +10 -2
  145. package/dist/src/session-changes.d.ts +35 -0
  146. package/dist/src/session-changes.js +194 -6
  147. package/dist/src/session-monitor.js +2 -1
  148. package/dist/src/session-reaper.d.ts +1 -1
  149. package/dist/src/session-reaper.js +6 -1
  150. package/dist/src/session-summary.d.ts +2 -1
  151. package/dist/src/session-summary.js +2 -1
  152. package/dist/src/sessions.d.ts +11 -1
  153. package/dist/src/sessions.js +17 -4
  154. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  155. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  156. package/dist/src/skills/bundled/provenance.json +2 -2
  157. package/dist/src/skills/runtime-skills.js +1 -1
  158. package/dist/src/telemetry/emitter.d.ts +15 -0
  159. package/dist/src/telemetry/emitter.js +35 -1
  160. package/dist/src/telemetry/schema.d.ts +25 -2
  161. package/dist/src/telemetry/schema.js +52 -4
  162. package/dist/src/telemetry/surface.d.ts +2 -1
  163. package/dist/src/telemetry/surface.js +4 -1
  164. package/dist/src/terminal-ui.d.ts +1 -0
  165. package/dist/src/terminal-ui.js +10 -3
  166. package/dist/src/test-edit-guard.d.ts +7 -0
  167. package/dist/src/test-edit-guard.js +49 -1
  168. package/dist/src/timers.d.ts +2 -0
  169. package/dist/src/tools.js +59 -9
  170. package/package.json +6 -1
  171. package/dist/src/remote/cert.d.ts +0 -11
  172. package/dist/src/remote/cert.js +0 -87
  173. package/dist/src/remote/client.d.ts +0 -119
  174. package/dist/src/remote/client.js +0 -544
  175. package/dist/src/remote/command.d.ts +0 -4
  176. package/dist/src/remote/command.js +0 -194
  177. package/dist/src/remote/errors.d.ts +0 -11
  178. package/dist/src/remote/errors.js +0 -14
  179. package/dist/src/remote/network.d.ts +0 -22
  180. package/dist/src/remote/network.js +0 -102
  181. package/dist/src/remote/pairing.d.ts +0 -63
  182. package/dist/src/remote/pairing.js +0 -299
  183. package/dist/src/remote/pem.d.ts +0 -2
  184. package/dist/src/remote/pem.js +0 -7
  185. package/dist/src/remote/serve.d.ts +0 -68
  186. package/dist/src/remote/serve.js +0 -244
  187. package/dist/src/remote/server.d.ts +0 -21
  188. package/dist/src/remote/server.js +0 -406
@@ -0,0 +1,129 @@
1
+ import { opendir, stat } from 'node:fs/promises';
2
+ import { basename, dirname, isAbsolute, join } from 'node:path';
3
+ import { loadConfig } from '../config.js';
4
+ import { addProjectEntry } from '../project-registry.js';
5
+ import { authorizedRoots, directoryInsideFolders, projectRootId, sharedFolders } from '../remote/roots.js';
6
+ import { RELAY_CAPABILITY_REQUIREMENT } from '../remote/engine-pool.js';
7
+ import { bridgeCommand } from './wording.js';
8
+ export const BROWSE_ENTRY_CAP = 1000;
9
+ const SKIP_NAMES = new Set(['.git', 'node_modules', '.andorracode']);
10
+ const outsideFolders = () => `That folder is outside the folders this machine shares. Run ${bridgeCommand('folders add <path>')} on it.`;
11
+ export class HostOperationError extends Error {
12
+ code;
13
+ constructor(code, message) {
14
+ super(message);
15
+ this.code = code;
16
+ this.name = 'HostOperationError';
17
+ }
18
+ }
19
+ async function listDirectory(directory) {
20
+ const entries = [];
21
+ let hasMore = false;
22
+ for await (const entry of await opendir(directory)) {
23
+ if (entry.isSymbolicLink() || SKIP_NAMES.has(entry.name))
24
+ continue;
25
+ if (!(entry.isDirectory() || entry.isFile()))
26
+ continue;
27
+ if (entries.length >= BROWSE_ENTRY_CAP) {
28
+ hasMore = true;
29
+ break;
30
+ }
31
+ entries.push({ name: entry.name, type: entry.isDirectory() ? 'directory' : 'file' });
32
+ }
33
+ entries.sort((left, right) => left.type === right.type ? left.name.localeCompare(right.name) : left.type === 'directory' ? -1 : 1);
34
+ return { entries, hasMore };
35
+ }
36
+ function optionalString(params, key) {
37
+ const value = params[key];
38
+ return typeof value === 'string' ? value : undefined;
39
+ }
40
+ /** The real directory at `path`, which must lie inside a shared folder (`forbidden` otherwise). */
41
+ async function sharedDirectory(directory, path, missing) {
42
+ const found = await directoryInsideFolders(await sharedFolders(await loadConfig(directory)), path);
43
+ if (found === undefined)
44
+ throw new HostOperationError('not-found', missing);
45
+ if (!found.inside)
46
+ throw new HostOperationError('forbidden', outsideFolders());
47
+ return found.path;
48
+ }
49
+ export async function hostOperation(directory, op, params, host) {
50
+ switch (op) {
51
+ case 'whoami': {
52
+ const { APP_SERVER_CAPABILITIES } = await import('../app-server/protocol.js');
53
+ return {
54
+ hostname: host.hostname, platform: host.platform, version: host.version, grant: 'full', relay: true,
55
+ capabilities: [...new Set([...APP_SERVER_CAPABILITIES, 'remote.engine.relay', RELAY_CAPABILITY_REQUIREMENT])],
56
+ };
57
+ }
58
+ case 'projects': {
59
+ const roots = await authorizedRoots(await loadConfig(directory));
60
+ return { projects: roots.filter(root => root.kind === 'project').map(root => ({ rootId: root.id, name: root.label })) };
61
+ }
62
+ case 'roots': {
63
+ const roots = await authorizedRoots(await loadConfig(directory));
64
+ return { roots: roots.map(root => ({ id: root.id, label: root.label, kind: root.kind })) };
65
+ }
66
+ case 'browse': {
67
+ const rootId = optionalString(params, 'root');
68
+ const roots = await authorizedRoots(await loadConfig(directory));
69
+ const root = roots.find(entry => entry.id === rootId);
70
+ if (!root)
71
+ throw new HostOperationError('not-found', 'Unknown root');
72
+ const rel = optionalString(params, 'rel') ?? '';
73
+ if (rel.includes('\0') || rel.length > 4096
74
+ || rel.startsWith('/') || rel.startsWith('\\') || /^[A-Za-z]:/.test(rel)
75
+ || rel.split(/[\\/]/).includes('..'))
76
+ throw new HostOperationError('invalid-params', 'Invalid path');
77
+ const { resolveInside } = await import('../app-server/workspace.js');
78
+ const target = await resolveInside(root.path, rel).catch(() => undefined);
79
+ if (target === undefined)
80
+ throw new HostOperationError('forbidden', 'That path is outside the shared folder');
81
+ const info = await stat(target).catch(() => undefined);
82
+ if (!info)
83
+ throw new HostOperationError('not-found', 'That folder no longer exists');
84
+ if (!info.isDirectory())
85
+ throw new HostOperationError('invalid-params', 'Only folders can be listed');
86
+ const listing = await listDirectory(target);
87
+ return {
88
+ rootId: root.id,
89
+ rel,
90
+ parent: rel === '' || rel === '.' ? null : dirname(rel.split('\\').join('/')) === '.' ? '' : dirname(rel.split('\\').join('/')),
91
+ ...listing,
92
+ };
93
+ }
94
+ case 'owner.roots': {
95
+ // The desktop browses for projects only inside the folders this machine shares.
96
+ return { roots: (await sharedFolders(await loadConfig(directory))).map(folder => ({ path: folder.path, name: folder.label })) };
97
+ }
98
+ case 'owner.browse': {
99
+ const requested = optionalString(params, 'path') ?? '';
100
+ if (!requested || requested.length > 4096 || requested.includes('\0') || !isAbsolute(requested)) {
101
+ throw new HostOperationError('invalid-params', 'An absolute host directory is required');
102
+ }
103
+ const actual = await sharedDirectory(directory, requested, 'Directory does not exist');
104
+ const listing = await listDirectory(actual);
105
+ const parent = dirname(actual);
106
+ // Never offer a way above a shared folder.
107
+ const upward = parent !== actual && (await directoryInsideFolders(await sharedFolders(await loadConfig(directory)), parent))?.inside === true;
108
+ return {
109
+ path: actual, parent: upward ? parent : null,
110
+ ...listing, entries: listing.entries.map(entry => ({ ...entry, path: join(actual, entry.name) })),
111
+ };
112
+ }
113
+ case 'owner.projects.add': {
114
+ const path = params.path;
115
+ const name = params.name;
116
+ if (typeof path !== 'string' || path.length > 4096 || path.includes('\0') || !isAbsolute(path)
117
+ || (name !== undefined && (typeof name !== 'string' || !name.trim() || name.length > 100 || /[\0\r\n]/.test(name)))) {
118
+ throw new HostOperationError('invalid-params', 'Invalid host project path/name');
119
+ }
120
+ const actual = await sharedDirectory(directory, path, 'Project directory does not exist');
121
+ const projectName = typeof name === 'string' ? name.trim() : basename(actual) || actual;
122
+ await addProjectEntry(actual, { directory, name: projectName });
123
+ const recorded = (await loadConfig(directory)).projects?.find(project => project.path === actual);
124
+ return { rootId: projectRootId(actual), name: recorded?.name?.trim() || basename(actual) || actual };
125
+ }
126
+ default:
127
+ throw new HostOperationError('invalid-params', 'Unknown host operation');
128
+ }
129
+ }
@@ -0,0 +1,47 @@
1
+ import { RemoteEngineRelay } from '../remote/engine-pool.js';
2
+ import { type EngineStore } from './engines.js';
3
+ export declare const DEFAULT_RELAY_URL = "wss://relay.andorracode.com/v1/link";
4
+ /** How often a host started by the launcher checks that the launcher is still there. */
5
+ export declare const LAUNCHER_CHECK_MS = 30000;
6
+ /** How often a host that a newer desktop has seen checks whether it can hand over to that version. */
7
+ export declare const RESTART_CHECK_MS = 10000;
8
+ /** How long a host that was started for another version than it runs waits before asking for that version again. */
9
+ export declare const HOST_REQUEST_HOLD_MS: number;
10
+ export declare const MAX_NEWER_VERSIONS = 4;
11
+ export declare const RESTARTING_MESSAGE = "This machine is restarting to update Andorra Code. Try again in a moment.";
12
+ export type BridgeRelay = Pick<RemoteEngineRelay, 'request' | 'events' | 'disconnect' | 'close' | 'activity' | 'runningTasks' | 'holdsWork'>;
13
+ export interface BridgeActivity {
14
+ running: number;
15
+ attached: number;
16
+ }
17
+ export declare const hostDependencies: {
18
+ createRelay(directory: string, engines?: EngineStore): BridgeRelay;
19
+ };
20
+ export interface BridgeHostOptions {
21
+ directory: string;
22
+ relayUrl: string;
23
+ version: string;
24
+ token: () => Promise<{
25
+ token: string;
26
+ expiresAt: string;
27
+ }>;
28
+ signal: AbortSignal;
29
+ log: (line: string) => void;
30
+ socket?: (url: string) => WebSocket;
31
+ backoffMs?: (attempt: number) => number;
32
+ /** Reports the machine's activity to the service; it throws a ControlError with code `unlinked` when the service no longer knows the machine. */
33
+ heartbeat?: (activity: BridgeActivity) => Promise<void>;
34
+ /** The launcher's engine store: present only when the bridge launcher started this host. */
35
+ engines?: EngineStore;
36
+ /** Whether the launcher that started this host is still running; the host stops once it is not. */
37
+ launcherAlive?: () => boolean;
38
+ launcherCheckMs?: number;
39
+ restartCheckMs?: number;
40
+ /** The clock of the restart hold; tests replace it. */
41
+ now?: () => number;
42
+ }
43
+ export type BridgeHostOutcome = 'stopped' | 'unlinked' | 'restart';
44
+ export declare function relayUrlFromEnvironment(environment?: NodeJS.ProcessEnv): string;
45
+ export declare function reconnectDelayMs(attempt: number, random?: () => number): number;
46
+ export declare function refreshDelayMs(expiresAt: string, now?: number): number;
47
+ export declare function runBridgeHost(hostOptions: BridgeHostOptions): Promise<BridgeHostOutcome>;