@andorra-labs/code 0.1.15 → 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 (242) 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-definitions.js +29 -6
  4. package/dist/src/agent-execution.js +15 -10
  5. package/dist/src/agent-mcp-catalog.js +1 -0
  6. package/dist/src/agent-mcp.d.ts +4 -1
  7. package/dist/src/agent-mcp.js +46 -10
  8. package/dist/src/andorra/entry.d.ts +10 -0
  9. package/dist/src/andorra/entry.js +18 -4
  10. package/dist/src/andorra/hosted.d.ts +2 -1
  11. package/dist/src/andorra/hosted.js +2 -1
  12. package/dist/src/andorra/notices.d.ts +5 -0
  13. package/dist/src/andorra/notices.js +7 -0
  14. package/dist/src/andorra/state.d.ts +3 -2
  15. package/dist/src/andorra/state.js +4 -4
  16. package/dist/src/andorra/terminal.js +7 -2
  17. package/dist/src/anthropic-credentials.js +2 -0
  18. package/dist/src/app-server/error.d.ts +5 -0
  19. package/dist/src/app-server/error.js +7 -0
  20. package/dist/src/app-server/protocol.d.ts +22 -44
  21. package/dist/src/app-server/protocol.js +5 -1
  22. package/dist/src/app-server/workspace.d.ts +89 -0
  23. package/dist/src/app-server/workspace.js +457 -11
  24. package/dist/src/app-server.d.ts +465 -32
  25. package/dist/src/app-server.js +3308 -517
  26. package/dist/src/auth/deployment.js +2 -2
  27. package/dist/src/bridge/cloud.d.ts +27 -0
  28. package/dist/src/bridge/cloud.js +187 -0
  29. package/dist/src/bridge/command.d.ts +30 -0
  30. package/dist/src/bridge/command.js +347 -0
  31. package/dist/src/bridge/control.d.ts +68 -0
  32. package/dist/src/bridge/control.js +233 -0
  33. package/dist/src/bridge/engines.d.ts +90 -0
  34. package/dist/src/bridge/engines.js +601 -0
  35. package/dist/src/bridge/host-ops.d.ts +9 -0
  36. package/dist/src/bridge/host-ops.js +129 -0
  37. package/dist/src/bridge/host.d.ts +47 -0
  38. package/dist/src/bridge/host.js +540 -0
  39. package/dist/src/bridge/link.d.ts +38 -0
  40. package/dist/src/bridge/link.js +508 -0
  41. package/dist/src/bridge/login-link.d.ts +29 -0
  42. package/dist/src/bridge/login-link.js +54 -0
  43. package/dist/src/bridge/protocol.d.ts +136 -0
  44. package/dist/src/bridge/protocol.js +11 -0
  45. package/dist/src/bridge/store.d.ts +12 -0
  46. package/dist/src/bridge/store.js +61 -0
  47. package/dist/src/bridge/wording.d.ts +6 -0
  48. package/dist/src/bridge/wording.js +10 -0
  49. package/dist/src/browser-runner.js +1 -0
  50. package/dist/src/browser-server.js +7 -1
  51. package/dist/src/browser-ui/style.css +3 -3
  52. package/dist/src/browser-ui/tokens.css +28 -17
  53. package/dist/src/change-authors.d.ts +41 -0
  54. package/dist/src/change-authors.js +146 -0
  55. package/dist/src/claude-provider.js +3 -1
  56. package/dist/src/cli.js +202 -38
  57. package/dist/src/codex-errors.js +4 -1
  58. package/dist/src/coding-tools.js +15 -15
  59. package/dist/src/command-screens.d.ts +6 -0
  60. package/dist/src/command-screens.js +19 -14
  61. package/dist/src/commands.d.ts +14 -1
  62. package/dist/src/compaction-phrases.d.ts +4 -0
  63. package/dist/src/compaction-phrases.js +20 -0
  64. package/dist/src/completion.js +82 -5
  65. package/dist/src/config.d.ts +71 -3
  66. package/dist/src/config.js +202 -77
  67. package/dist/src/context-compaction.js +2 -1
  68. package/dist/src/deadline.js +13 -1
  69. package/dist/src/decision/DecisionManager.js +3 -2
  70. package/dist/src/decision/checks.js +1 -1
  71. package/dist/src/decision/requestPhrases.d.ts +4 -0
  72. package/dist/src/decision/requestPhrases.js +22 -0
  73. package/dist/src/default-graph.js +1 -1
  74. package/dist/src/file-diff.d.ts +4 -0
  75. package/dist/src/file-diff.js +2 -1
  76. package/dist/src/github-app/agent-writes.d.ts +102 -0
  77. package/dist/src/github-app/agent-writes.js +320 -0
  78. package/dist/src/github-app/client.d.ts +349 -0
  79. package/dist/src/github-app/client.js +810 -0
  80. package/dist/src/github-app/event-source.d.ts +208 -0
  81. package/dist/src/github-app/event-source.js +684 -0
  82. package/dist/src/github-app/metrics.d.ts +32 -0
  83. package/dist/src/github-app/metrics.js +49 -0
  84. package/dist/src/github-app/review-loop.d.ts +274 -0
  85. package/dist/src/github-app/review-loop.js +1177 -0
  86. package/dist/src/github-app/review-node.d.ts +81 -0
  87. package/dist/src/github-app/review-node.js +205 -0
  88. package/dist/src/github-app/review-post.d.ts +73 -0
  89. package/dist/src/github-app/review-post.js +139 -0
  90. package/dist/src/github-app/review-text.d.ts +107 -0
  91. package/dist/src/github-app/review-text.js +1133 -0
  92. package/dist/src/github-app/review-threads.d.ts +47 -0
  93. package/dist/src/github-app/review-threads.js +107 -0
  94. package/dist/src/github-app/reviewer.d.ts +121 -0
  95. package/dist/src/github-app/reviewer.js +598 -0
  96. package/dist/src/github-app/store.d.ts +59 -0
  97. package/dist/src/github-app/store.js +148 -0
  98. package/dist/src/github-app/triggers.d.ts +141 -0
  99. package/dist/src/github-app/triggers.js +441 -0
  100. package/dist/src/github-inbox.d.ts +55 -0
  101. package/dist/src/github-inbox.js +153 -0
  102. package/dist/src/github-names.d.ts +8 -0
  103. package/dist/src/github-names.js +8 -0
  104. package/dist/src/glob-search.d.ts +61 -0
  105. package/dist/src/glob-search.js +180 -0
  106. package/dist/src/graph-health.js +13 -4
  107. package/dist/src/graph-manager-chat.js +1 -1
  108. package/dist/src/graph-preview.d.ts +46 -0
  109. package/dist/src/graph-preview.js +55 -0
  110. package/dist/src/graph-provider-portability.js +34 -11
  111. package/dist/src/graph-quota.d.ts +29 -2
  112. package/dist/src/graph-quota.js +68 -10
  113. package/dist/src/graph-runner.js +88 -10
  114. package/dist/src/graph-server.d.ts +1 -1
  115. package/dist/src/graph-server.js +11 -9
  116. package/dist/src/graph-sync.js +3 -3
  117. package/dist/src/graph-ui/app.js +201 -40
  118. package/dist/src/graph-ui/controls.css +1 -0
  119. package/dist/src/graph-ui/embed.js +2 -2
  120. package/dist/src/graph-ui/icons.js +3 -1
  121. package/dist/src/graph-ui/index.html +1 -1
  122. package/dist/src/graph-ui/manager.css +1 -1
  123. package/dist/src/graph-ui/manager.js +2 -2
  124. package/dist/src/graph-ui/sidebar.js +30 -0
  125. package/dist/src/graph-ui/studio-canvas.js +26 -13
  126. package/dist/src/graph-ui/studio.css +15 -7
  127. package/dist/src/graph-ui/studio.js +26 -5
  128. package/dist/src/graph-ui/style.css +77 -45
  129. package/dist/src/graph-ui/theme.js +3 -36
  130. package/dist/src/graph-ui/tokens.css +28 -20
  131. package/dist/src/graphs.d.ts +34 -1
  132. package/dist/src/graphs.js +162 -17
  133. package/dist/src/image-input.d.ts +16 -0
  134. package/dist/src/image-input.js +41 -0
  135. package/dist/src/membership.d.ts +30 -1
  136. package/dist/src/membership.js +48 -8
  137. package/dist/src/model-health-cache.js +1 -1
  138. package/dist/src/model-metadata.d.ts +7 -1
  139. package/dist/src/model-metadata.js +39 -17
  140. package/dist/src/model-relay/local.d.ts +116 -0
  141. package/dist/src/model-relay/local.js +468 -0
  142. package/dist/src/model-relay/remote.d.ts +129 -0
  143. package/dist/src/model-relay/remote.js +252 -0
  144. package/dist/src/model-relay/runs.d.ts +34 -0
  145. package/dist/src/model-relay/runs.js +146 -0
  146. package/dist/src/model-relay/wire.d.ts +5 -0
  147. package/dist/src/model-relay/wire.js +5 -0
  148. package/dist/src/plan-pass.d.ts +59 -0
  149. package/dist/src/plan-pass.js +165 -0
  150. package/dist/src/project-registry.d.ts +21 -0
  151. package/dist/src/project-registry.js +74 -0
  152. package/dist/src/provider-engine.js +3 -0
  153. package/dist/src/provider-import.d.ts +0 -12
  154. package/dist/src/provider-import.js +7 -195
  155. package/dist/src/providers.d.ts +40 -2
  156. package/dist/src/providers.js +93 -23
  157. package/dist/src/pull-request-checks.d.ts +26 -0
  158. package/dist/src/pull-request-checks.js +56 -0
  159. package/dist/src/pull-request-conversation.d.ts +134 -0
  160. package/dist/src/pull-request-conversation.js +221 -0
  161. package/dist/src/pull-request-create.d.ts +175 -0
  162. package/dist/src/pull-request-create.js +392 -0
  163. package/dist/src/pull-request-details.d.ts +242 -0
  164. package/dist/src/pull-request-details.js +614 -0
  165. package/dist/src/pull-request-edit.d.ts +23 -0
  166. package/dist/src/pull-request-edit.js +91 -0
  167. package/dist/src/pull-request-logs.d.ts +87 -0
  168. package/dist/src/pull-request-logs.js +183 -0
  169. package/dist/src/pull-request-merge.d.ts +112 -0
  170. package/dist/src/pull-request-merge.js +258 -0
  171. package/dist/src/pull-request-review.d.ts +137 -0
  172. package/dist/src/pull-request-review.js +401 -0
  173. package/dist/src/pull-requests.d.ts +369 -8
  174. package/dist/src/pull-requests.js +524 -55
  175. package/dist/src/react-runtime.js +38 -5
  176. package/dist/src/remote/engine-pool.d.ts +88 -4
  177. package/dist/src/remote/engine-pool.js +379 -90
  178. package/dist/src/remote/roots.d.ts +19 -0
  179. package/dist/src/remote/roots.js +45 -7
  180. package/dist/src/remote/types.d.ts +0 -44
  181. package/dist/src/run-control.d.ts +17 -0
  182. package/dist/src/run-control.js +47 -0
  183. package/dist/src/run-progress.d.ts +10 -0
  184. package/dist/src/run-progress.js +122 -0
  185. package/dist/src/run-records.d.ts +7 -2
  186. package/dist/src/run-records.js +71 -6
  187. package/dist/src/runtime.d.ts +9 -1
  188. package/dist/src/runtime.js +24 -4
  189. package/dist/src/session-changes.d.ts +35 -0
  190. package/dist/src/session-changes.js +194 -6
  191. package/dist/src/session-monitor.js +2 -1
  192. package/dist/src/session-reaper.d.ts +1 -1
  193. package/dist/src/session-reaper.js +6 -1
  194. package/dist/src/session-summary.d.ts +2 -1
  195. package/dist/src/session-summary.js +2 -1
  196. package/dist/src/sessions.d.ts +11 -1
  197. package/dist/src/sessions.js +17 -4
  198. package/dist/src/skills/bundled/diagram/SKILL.md +5 -3
  199. package/dist/src/skills/bundled/graph-manager/SKILL.md +7 -4
  200. package/dist/src/skills/bundled/provenance.json +2 -2
  201. package/dist/src/skills/runtime-skills.js +1 -1
  202. package/dist/src/subagent-run.js +1 -0
  203. package/dist/src/telemetry/capture-core.d.ts +17 -0
  204. package/dist/src/telemetry/capture-core.js +59 -1
  205. package/dist/src/telemetry/classify.d.ts +3 -1
  206. package/dist/src/telemetry/classify.js +37 -0
  207. package/dist/src/telemetry/emitter.d.ts +17 -0
  208. package/dist/src/telemetry/emitter.js +76 -5
  209. package/dist/src/telemetry/schema.d.ts +47 -2
  210. package/dist/src/telemetry/schema.js +120 -5
  211. package/dist/src/telemetry/surface.d.ts +3 -1
  212. package/dist/src/telemetry/surface.js +4 -1
  213. package/dist/src/telemetry/uploader.d.ts +6 -1
  214. package/dist/src/telemetry/uploader.js +22 -3
  215. package/dist/src/terminal-ui.d.ts +1 -0
  216. package/dist/src/terminal-ui.js +10 -3
  217. package/dist/src/test-edit-guard.d.ts +7 -0
  218. package/dist/src/test-edit-guard.js +49 -1
  219. package/dist/src/timers.d.ts +2 -0
  220. package/dist/src/tools.js +59 -9
  221. package/dist/src/transcript.js +8 -2
  222. package/dist/src/types.d.ts +7 -0
  223. package/dist/src/usage-analytics.js +18 -10
  224. package/package.json +6 -1
  225. package/dist/src/remote/cert.d.ts +0 -11
  226. package/dist/src/remote/cert.js +0 -87
  227. package/dist/src/remote/client.d.ts +0 -119
  228. package/dist/src/remote/client.js +0 -544
  229. package/dist/src/remote/command.d.ts +0 -4
  230. package/dist/src/remote/command.js +0 -194
  231. package/dist/src/remote/errors.d.ts +0 -11
  232. package/dist/src/remote/errors.js +0 -14
  233. package/dist/src/remote/network.d.ts +0 -22
  234. package/dist/src/remote/network.js +0 -102
  235. package/dist/src/remote/pairing.d.ts +0 -63
  236. package/dist/src/remote/pairing.js +0 -299
  237. package/dist/src/remote/pem.d.ts +0 -2
  238. package/dist/src/remote/pem.js +0 -7
  239. package/dist/src/remote/serve.d.ts +0 -68
  240. package/dist/src/remote/serve.js +0 -244
  241. package/dist/src/remote/server.d.ts +0 -21
  242. package/dist/src/remote/server.js +0 -406
@@ -9,7 +9,7 @@ import { runRegularTurnLoop } from '../vendor/zcode/source/runtime/turn-loop.js'
9
9
  import { validateInitialModelToolInput, getInitialInputValidationModelContent } from '../vendor/zcode/source/tool/executor/validation.js';
10
10
  import { andorraIsContextOverflow } from '../vendor/engine/runtime/ai/utils/overflow.js';
11
11
  import { toEngineResponse, engineModel } from './engine/protocol.js';
12
- import { ProviderRequestError } from './providers.js';
12
+ import { ProviderRequestError, runFailureCode } from './providers.js';
13
13
  import { COMPLETION_ALONE_ERROR, COMPLETION_TOOL, COMPLETION_GUIDANCE, FINAL_RESPONSE_GUIDANCE, OUTPUT_STOOD_IN_NOTE, RESPONSE_STRUCTURE_GUIDANCE, completionTool, completionResponse, parseCompletion, withoutTrailingEnvelope } from './completion.js';
14
14
  import { MAX_GATE_ASKS, MAX_IDLE_UNFINISHED_ASKS, finalAnswerGate, proseIsFinalAnswer } from './completion-gates.js';
15
15
  import { TestEditGuard, testEditNudge } from './test-edit-guard.js';
@@ -23,7 +23,7 @@ import { monotonicNow, elapsedMs } from './duration.js';
23
23
  import { planToolDependencies, requiresToolBarrier } from './tool-dependencies.js';
24
24
  import { realpath, stat } from 'node:fs/promises';
25
25
  import { isAbsolute, relative, resolve } from 'node:path';
26
- import { createRunTelemetry, recordEdit, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
26
+ import { createRunTelemetry, recordEdit, recordErrorOnce, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
27
27
  import { isTestCommandLine } from './telemetry/classify.js';
28
28
  import { callFileDiff, diffLineStats, fileDiffTarget, readFileSnapshot } from './tool-diff-stats.js';
29
29
  import { TodoStore } from './todos.js';
@@ -47,7 +47,7 @@ const DEFAULT_AGENT_INSTRUCTIONS = `You are the Andorra Agent in Andorra Code's
47
47
  Handle the user's task end to end, whether it is a coding task or a general one: implement code and verify changes with appropriate tools, and answer general research, writing and analysis directly from the available sources.`;
48
48
  const IMPLEMENTATION_GUIDANCE = `Every model turn resends the whole conversation, so finish in the fewest turns that fully cover the task.
49
49
  Compose new or fully rewritten files in a single Write; reserve Edit for surgical changes to long existing files. Tool results already show the applied change, so never re-read a file just to confirm your own Write or Edit.
50
- Issue independent read-only calls together in one turn. Combine quick related shell checks into one labeled command, but give a search or scan that may be slow its own call: a timeout stops the whole command and loses the output of every check in it.
50
+ Issue independent read-only calls together in one turn. Send the edits for one change together in one turn as well: several Edit or Write calls, in different files or in the same file, run in the order you list them, and the command that checks them goes last in that same turn. Each call reports its own result, and a later call still runs when an earlier edit failed to match, so read every result before trusting the check. Combine quick related shell checks into one labeled command, but give a search or scan that may be slow its own call: a timeout stops the whole command and loses the output of every check in it.
51
51
  Do mechanical or repetitive work by executing code (a shell one-liner or script), not through repeated model-driven edits.
52
52
  Keep tool output proportionate: filter, count, select, or tail large files, logs and command output instead of feeding them whole into context. Finding something is the exception. When the task names a thing you have not located (a host, service, project, tool or file), look for it by file and directory name before anything else: list the working directory in full, without a first-N or last-N cap, and search names as well as contents, because a file can be named for a thing its text never mentions. A listing you cut short, or a search that timed out or was stopped, is not evidence that the thing is absent: rerun it narrower or in its own call before concluding so or asking the user.
53
53
  Reuse unchanged evidence and known interfaces rather than rereading files. For runnable software, build the smallest integrated vertical slice first: entry point, initialization and one real interaction. Run a boot/syntax smoke check as soon as that slice exists, before broad subsystem inventories or polishing. Use observed failures to choose the next targeted inspection, and verify with the smallest check that can actually fail. Then complete every requested behavior and verification.
@@ -708,6 +708,11 @@ ${runtimeEnvironmentNote()}` + (options.systemPrompt ? `\nAgent instructions:\n$
708
708
  let imageInputRejected = false;
709
709
  let forceSequential = false;
710
710
  let model = engineModel(options.model, options.provider, options.contextWindow);
711
+ // /compact sent during a run: the run was stopped and resumed with this flag, so its first turn summarizes
712
+ // every eligible earlier exchange (keeping the latest tool turns), whatever the context pressure.
713
+ let compactRequested = !options.subagentId && options.resumeMessages !== undefined && options.resumeState?.compactRequested === true;
714
+ // The same request made in-process (the terminal's /compact) stays pending on RunControl until the run's own agent takes it,
715
+ // so one made while the run was still starting is acted on at the first turn.
711
716
  const recoverCompaction = async (error) => {
712
717
  if (!(error instanceof CompactionRecoveryError))
713
718
  return false;
@@ -810,6 +815,29 @@ ${runtimeEnvironmentNote()}` + (options.systemPrompt ? `\nAgent instructions:\n$
810
815
  retireTodoUpdates(messages, (_call, owner, observation) => !inheritedMessages.has(owner) && !!observation && !observation.content.startsWith('Tool error:'));
811
816
  closeAssistantTail();
812
817
  const threshold = contextThreshold(model.contextWindow, model.maxTokens);
818
+ if (control && !options.subagentId && control.takeCompactionRequest())
819
+ compactRequested = true;
820
+ if (compactRequested) {
821
+ compactRequested = false;
822
+ const before = contextUsage.pressure(messages, toolContextChars, schemaKey);
823
+ try {
824
+ const requested = await historyCompactor.compact(messages, toolContextChars, limits.maxContextChars, { options, result, signal: operationSignal, invocationId }, { triggerChars: 0, targetChars: Math.max(1, limits.maxContextChars - pinnedContextChars(messages, toolContextChars)), protectDiscovery: false, keepRecentToolTurns: 2, retireAllEligible: true });
825
+ await emit('agent.context.compacted', { reason: 'requested', removedExchanges: requested.removed, contextChars: requested.chars, beforeTokens: before.tokens, afterTokens: contextUsage.pressure(messages, toolContextChars).tokens, tokenSource: before.source, threshold });
826
+ }
827
+ catch (error) {
828
+ signal.throwIfAborted();
829
+ if (operationSignal.aborted) {
830
+ // Paused (Ctrl+C) while the summary was being written: keep the request and redo this turn once the run resumes.
831
+ compactRequested = true;
832
+ iteration--;
833
+ return;
834
+ }
835
+ if (!(error instanceof CompactionRecoveryError))
836
+ throw error;
837
+ // The user asked for it, but the run need not stop over it: carry on with the full history.
838
+ await emit('agent.context.compaction.deferred', { reason: error.reason, requested: true, contextChars: contextChars() });
839
+ }
840
+ }
813
841
  let beforeCleanup = contextUsage.pressure(messages, toolContextChars, schemaKey);
814
842
  const underPressure = () => beforeCleanup.tokens >= Math.floor(threshold * .9) || contextChars() > limits.maxContextChars;
815
843
  if (supersededSnapshots.size && underPressure()) {
@@ -927,7 +955,7 @@ ${runtimeEnvironmentNote()}` + (options.systemPrompt ? `\nAgent instructions:\n$
927
955
  const forced = !selectedStep && forceToolCall;
928
956
  if (forced)
929
957
  forceToolCall = false;
930
- const stopSteerWatch = !selectedStep && control && options.getSteeringMessages
958
+ const stopSteerWatch = !selectedStep && control && (options.getSteeringMessages || !options.subagentId)
931
959
  ? control.onSteer(() => steerCut.abort(new Error('Interrupted to read a steering message.')), options.subagentId)
932
960
  : () => { };
933
961
  try {
@@ -936,7 +964,8 @@ ${runtimeEnvironmentNote()}` + (options.systemPrompt ? `\nAgent instructions:\n$
936
964
  : await generateWithUsage(options, result, { model: options.model, messages: requestMessages, tools: advertisedTools, signal: AbortSignal.any([operationSignal, steerCut.signal]),
937
965
  mutableTail, estimateInputTokens,
938
966
  ...(forced ? { toolChoice: 'required' } : {}),
939
- onRetry: ({ unparsedReply: _unparsedReply, ...retry }) => emit('agent.model.retry', { ...retry }),
967
+ // generateWithUsage records the retried error in the run's telemetry; the code stays out of the event.
968
+ onRetry: ({ unparsedReply: _unparsedReply, code: _code, ...retry }) => emit('agent.model.retry', { ...retry }),
940
969
  context: { runId: result.id, nodeId: options.nodeId ?? 'engineer', providerId: options.provider, invocationId, ...(options.subagentId ? { subagentId: options.subagentId } : {}) } }));
941
970
  }
942
971
  catch (error) {
@@ -1777,6 +1806,10 @@ ${runtimeEnvironmentNote()}` + (options.systemPrompt ? `\nAgent instructions:\n$
1777
1806
  if (error.contextOverflow)
1778
1807
  result.providerOverflow = true;
1779
1808
  }
1809
+ if (!cancelled && !deadline && !(error instanceof ClarificationRequiredError)) {
1810
+ // A model request's failure was recorded where it happened; this reuses that code rather than counting it again.
1811
+ result.failureCode = recordErrorOnce(result.telemetry, error, runFailureCode(error));
1812
+ }
1780
1813
  result.status = cancelled ? 'cancelled' : deadline ? 'exhausted' : error instanceof ClarificationRequiredError ? 'needs_clarification' : 'infrastructure_error';
1781
1814
  result.reason = cancelled ? 'cancelled' : deadline ? 'wallTimeMs' : error instanceof Error ? error.message : 'Runtime failure';
1782
1815
  }
@@ -1,5 +1,11 @@
1
1
  export declare const REMOTE_PRIMARY_ENGINE = "remote-primary";
2
2
  export declare const RELAY_CAPABILITY_REQUIREMENT = "remote.engine.relay.capability";
3
+ /** How the relay treats a method: whether a desktop may call it on a machine, and whether it changes something there (no deadline slack). */
4
+ export declare function relayMethodClass(method: string): {
5
+ relayed: boolean;
6
+ primary: boolean;
7
+ mutating: boolean;
8
+ };
3
9
  export interface RelayError {
4
10
  code: string;
5
11
  message: string;
@@ -16,6 +22,42 @@ export interface RelayAnswer {
16
22
  result?: unknown;
17
23
  error?: RelayError;
18
24
  }
25
+ export type RelayInstallEvent = {
26
+ version: string;
27
+ state: 'installing';
28
+ } | {
29
+ version: string;
30
+ state: 'ready';
31
+ } | {
32
+ version: string;
33
+ state: 'failed';
34
+ reason: string;
35
+ };
36
+ /** Engines of other versions than this host's: what starts them, and which versions have one running. */
37
+ export interface RelayEngines {
38
+ readonly hostVersion: string;
39
+ /**
40
+ * The command that starts an engine of that version (undefined: the host's own). It never waits on an install: it
41
+ * throws an error whose `code` is `busy` while the version installs, `remote` after an install failed and
42
+ * `invalid-params` for a version this machine cannot run.
43
+ */
44
+ commandFor(version: string | undefined): Promise<string[]>;
45
+ /**
46
+ * Starts installing a missing version when a connection of it opens: `underway` when an install of it had already
47
+ * started, `failed` while a failed install of it cools down.
48
+ */
49
+ prepare?(version: string | undefined): Promise<'started' | 'underway' | 'none' | 'failed'>;
50
+ /** What a connection of that version is to be told at this moment: being installed, the failure it cools down from, or nothing. */
51
+ installState?(version: string): {
52
+ state: 'installing';
53
+ } | {
54
+ state: 'failed';
55
+ reason: string;
56
+ } | undefined;
57
+ watch?(listener: (event: RelayInstallEvent) => void): () => void;
58
+ inUse(version: string): void;
59
+ released(version: string): void;
60
+ }
19
61
  type EventSink = (payload: {
20
62
  engine: string;
21
63
  event: string;
@@ -32,6 +74,7 @@ declare function isRemoteProjectSpelling(value: string): boolean;
32
74
  declare function rootPartOf(value: string): string | undefined;
33
75
  export declare class RemoteEngineRelay {
34
76
  private readonly directory;
77
+ private readonly timing;
35
78
  private readonly children;
36
79
  private readonly retiringChildren;
37
80
  private taskSeq;
@@ -41,24 +84,42 @@ export declare class RemoteEngineRelay {
41
84
  private readonly runEngine;
42
85
  private readonly sessionEngine;
43
86
  private readonly activeRuns;
87
+ private readonly runStates;
44
88
  private readonly finishedRuns;
45
89
  private readonly translations;
46
- private revocationTimer;
90
+ private sinklessTimer;
47
91
  private delivery;
48
92
  private closed;
49
- constructor(directory: string);
93
+ private startsInFlight;
94
+ private readonly engines;
95
+ private readonly stopWatching;
96
+ constructor(directory: string, timing?: {
97
+ sinklessTtlMs?: number;
98
+ sweepMs?: number;
99
+ wakeAnswerMs?: number;
100
+ now?: () => number;
101
+ }, options?: {
102
+ engines?: RelayEngines;
103
+ });
104
+ /** The engine version a connection's tasks run on: undefined for the host's own, and always without a store. */
105
+ private engineVersion;
106
+ private announceInstall;
107
+ private sendInstallEvent;
108
+ private prepareEngine;
50
109
  request(deviceId: string, body: RelayRequestBody): Promise<RelayAnswer>;
51
110
  private validate;
52
111
  private childDeadline;
53
112
  private dispatch;
54
113
  private startRequest;
114
+ private reclaimIdleEngine;
115
+ private taskEngineCount;
55
116
  private runTargetRequest;
56
117
  private terminalRequest;
57
118
  private translateParams;
58
119
  private restoreRequestedEcho;
59
120
  private connection;
60
121
  private sever;
61
- events(deviceId: string, connectionId: string, viewerWorkspaceId: string | undefined, sink: EventSink, cut: () => void): () => void;
122
+ events(deviceId: string, connectionId: string, viewerWorkspaceId: string | undefined, sink: EventSink, cut: () => void, version?: string): () => void;
62
123
  private replayTo;
63
124
  private enqueueTo;
64
125
  private enqueue;
@@ -68,11 +129,34 @@ export declare class RemoteEngineRelay {
68
129
  private engineOwnsRun;
69
130
  private engine;
70
131
  private spawnChild;
132
+ private refuseAtEngineCap;
133
+ private engineCommand;
134
+ private releaseEngine;
71
135
  private childIsIdle;
136
+ private childRunsBackground;
72
137
  private childHoldsWake;
73
138
  private retireChild;
74
139
  private translation;
75
- private startRevocationPoll;
140
+ private startSinklessSweep;
141
+ /** Runs doing work on this machine: a run waiting for the user's computer, an approval or an answer is not counted. */
142
+ activity(): {
143
+ running: number;
144
+ };
145
+ /** Task starts in flight plus runs on task engines, waiting ones included: what a host restart would interrupt. */
146
+ runningTasks(): number;
147
+ /**
148
+ * Work a host restart would lose that runningTasks() may not show: a terminal open on the primary engine, and in any engine
149
+ * a wake armed (it lives only in that engine's memory and starts a run when due), a run as the engine itself reports it
150
+ * (one it started from a wake, the primary's included, which no run.start announced), or a background process still running.
151
+ * An engine that does not answer counts as holding for UNANSWERING_ENGINE_HOLD_MS of silence, and no longer.
152
+ */
153
+ holdsWork(): Promise<boolean>;
154
+ private childHoldsWork;
155
+ /** The engine version the desktop that opened this connection runs, or undefined when it said none or the connection is gone. */
156
+ connectionVersion(connectionId: string): string | undefined;
157
+ disconnect(deviceId: string, connectionId?: string): void;
76
158
  close(): Promise<void>;
77
159
  }
160
+ /** How long an engine that keeps failing to say what wakes it holds is taken to hold one. */
161
+ export declare const UNANSWERING_ENGINE_HOLD_MS = 120000;
78
162
  export { REMOTE_PROJECT_PREFIX, isRemoteProjectSpelling, rootPartOf };