@parcha/agentrun-computer 0.1.0-beta.58 → 0.1.0-beta.60

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 (143) hide show
  1. package/README.md +285 -81
  2. package/box/Dockerfile +4 -3
  3. package/box/install.sh +57 -11
  4. package/dist/agent37.d.ts +11 -4
  5. package/dist/agent37.js +217 -19
  6. package/dist/attach.d.ts +24 -4
  7. package/dist/attach.js +50 -19
  8. package/dist/boxd.js +22 -9
  9. package/dist/browser.d.ts +56 -11
  10. package/dist/browser.js +76 -17
  11. package/dist/browserbase.d.ts +20 -5
  12. package/dist/browserbase.js +186 -21
  13. package/dist/child-env.d.ts +11 -0
  14. package/dist/child-env.js +22 -0
  15. package/dist/chrome.d.ts +5 -2
  16. package/dist/chrome.js +5 -2
  17. package/dist/cloudflare.d.ts +2 -0
  18. package/dist/cloudflare.js +5 -3
  19. package/dist/computerd-linux-amd64 +0 -0
  20. package/dist/computerd-linux-arm64 +0 -0
  21. package/dist/computerd.json +1 -1
  22. package/dist/conformance/agent37.d.ts +20 -40
  23. package/dist/conformance/agent37.js +31 -118
  24. package/dist/conformance/archil.d.ts +13 -3
  25. package/dist/conformance/archil.js +22 -17
  26. package/dist/conformance/boxd.d.ts +8 -31
  27. package/dist/conformance/boxd.js +19 -74
  28. package/dist/conformance/browserbase.d.ts +3 -6
  29. package/dist/conformance/browserbase.js +6 -17
  30. package/dist/conformance/cases/health.js +6 -3
  31. package/dist/conformance/cases/provider.js +4 -1
  32. package/dist/conformance/cli.d.ts +3 -1
  33. package/dist/conformance/cli.js +69 -9
  34. package/dist/conformance/cloudflare.d.ts +3 -6
  35. package/dist/conformance/cloudflare.js +7 -15
  36. package/dist/conformance/daytona.d.ts +6 -20
  37. package/dist/conformance/daytona.js +22 -57
  38. package/dist/conformance/dial-only.d.ts +4 -3
  39. package/dist/conformance/dial-only.js +3 -3
  40. package/dist/conformance/docker.d.ts +4 -5
  41. package/dist/conformance/docker.js +8 -14
  42. package/dist/conformance/e2b.d.ts +10 -36
  43. package/dist/conformance/e2b.js +27 -84
  44. package/dist/conformance/fly.d.ts +3 -6
  45. package/dist/conformance/fly.js +2 -6
  46. package/dist/conformance/groundbox.d.ts +7 -23
  47. package/dist/conformance/groundbox.js +16 -56
  48. package/dist/conformance/index.d.ts +1 -0
  49. package/dist/conformance/index.js +1 -0
  50. package/dist/conformance/kernel.d.ts +3 -6
  51. package/dist/conformance/kernel.js +5 -15
  52. package/dist/conformance/kind.d.ts +0 -6
  53. package/dist/conformance/kind.js +0 -4
  54. package/dist/conformance/local-chrome.d.ts +5 -7
  55. package/dist/conformance/local-chrome.js +7 -11
  56. package/dist/conformance/modal.d.ts +10 -38
  57. package/dist/conformance/modal.js +27 -74
  58. package/dist/conformance/module-kit.d.ts +87 -0
  59. package/dist/conformance/module-kit.js +88 -0
  60. package/dist/conformance/morph.d.ts +7 -23
  61. package/dist/conformance/morph.js +20 -66
  62. package/dist/conformance/orgo.d.ts +5 -10
  63. package/dist/conformance/orgo.js +15 -27
  64. package/dist/conformance/phone-harness.d.ts +3 -5
  65. package/dist/conformance/phone-harness.js +3 -11
  66. package/dist/conformance/runner.d.ts +13 -3
  67. package/dist/conformance/runner.js +32 -11
  68. package/dist/conformance/smolcloud.d.ts +7 -23
  69. package/dist/conformance/smolcloud.js +16 -49
  70. package/dist/conformance/sweep.d.ts +10 -5
  71. package/dist/conformance/sweep.js +91 -38
  72. package/dist/conformance/tti.d.ts +69 -0
  73. package/dist/conformance/tti.js +205 -0
  74. package/dist/conformance/types.d.ts +9 -2
  75. package/dist/daytona.js +60 -20
  76. package/dist/descriptor.d.ts +37 -0
  77. package/dist/descriptor.js +9 -0
  78. package/dist/descriptors/agent37.d.ts +4 -1
  79. package/dist/descriptors/agent37.js +5 -2
  80. package/dist/descriptors/browserbase.d.ts +3 -0
  81. package/dist/descriptors/browserbase.js +4 -0
  82. package/dist/descriptors/docker.d.ts +2 -0
  83. package/dist/descriptors/docker.js +5 -0
  84. package/dist/descriptors/env-names.d.ts +32 -0
  85. package/dist/descriptors/env-names.js +60 -0
  86. package/dist/descriptors/index.d.ts +14 -3
  87. package/dist/descriptors/kernel.d.ts +3 -0
  88. package/dist/descriptors/kernel.js +2 -0
  89. package/dist/descriptors/local-chrome.d.ts +1 -1
  90. package/dist/descriptors/local-chrome.js +5 -3
  91. package/dist/descriptors/phone-harness.d.ts +1 -1
  92. package/dist/descriptors/phone-harness.js +4 -2
  93. package/dist/docker/egress.d.ts +7 -0
  94. package/dist/docker/egress.js +8 -0
  95. package/dist/docker/image.d.ts +5 -1
  96. package/dist/docker/image.js +12 -8
  97. package/dist/docker.d.ts +52 -13
  98. package/dist/docker.js +166 -92
  99. package/dist/drift.js +6 -6
  100. package/dist/e2b.d.ts +2 -2
  101. package/dist/e2b.js +2 -3
  102. package/dist/groundbox.js +6 -6
  103. package/dist/host.d.ts +23 -0
  104. package/dist/hosted/download.d.ts +23 -0
  105. package/dist/hosted/download.js +144 -0
  106. package/dist/hosted/process.d.ts +5 -0
  107. package/dist/hosted/process.js +20 -0
  108. package/dist/hosted/provider.js +120 -48
  109. package/dist/hosted/rest.d.ts +19 -8
  110. package/dist/hosted/rest.js +47 -14
  111. package/dist/hosted/scripts.d.ts +10 -0
  112. package/dist/hosted/scripts.js +23 -2
  113. package/dist/hosted/ssh-exec.d.ts +7 -1
  114. package/dist/hosted/ssh-exec.js +19 -14
  115. package/dist/hosted/ssh-key.d.ts +18 -0
  116. package/dist/hosted/ssh-key.js +36 -0
  117. package/dist/index.d.ts +5 -3
  118. package/dist/index.js +4 -2
  119. package/dist/janitor.d.ts +7 -1
  120. package/dist/janitor.js +2 -2
  121. package/dist/kernel.d.ts +14 -4
  122. package/dist/kernel.js +141 -18
  123. package/dist/local-chrome.d.ts +12 -3
  124. package/dist/local-chrome.js +108 -10
  125. package/dist/local-supervisor.js +1 -0
  126. package/dist/modal.d.ts +6 -5
  127. package/dist/modal.js +7 -7
  128. package/dist/morph.js +5 -8
  129. package/dist/orgo-channel.d.ts +3 -2
  130. package/dist/orgo-channel.js +3 -3
  131. package/dist/orgo-desktop.js +2 -4
  132. package/dist/orgo.d.ts +6 -0
  133. package/dist/orgo.js +158 -15
  134. package/dist/phone-harness.d.ts +7 -5
  135. package/dist/phone-harness.js +60 -61
  136. package/dist/protocol.d.ts +10 -0
  137. package/dist/protocol.js +17 -0
  138. package/dist/provider.d.ts +6 -2
  139. package/dist/screen-watch.d.ts +6 -1
  140. package/dist/screen-watch.js +166 -12
  141. package/dist/vendor-sdk.d.ts +9 -0
  142. package/dist/vendor-sdk.js +26 -0
  143. package/package.json +8 -1
package/box/Dockerfile CHANGED
@@ -14,9 +14,10 @@
14
14
  # computer user's, 0700, before init (by the provider's install, or by agentrun-dial on a machine that dials);
15
15
  # - a desktop, with nothing started: Xvfb and xfwm4 (with dbus-run-session, which xfconf's packages bring) and
16
16
  # xsetroot (x11-xserver-utils, the desktop's background), which the provider starts through computerd as the tool
17
- # user on :0 (src/desktop.ts), and the apps E2B Desktop has that are cheap to carry: Xfce's terminal and text editor,
18
- # Firefox ESR, and xdotool. computerd's apps group lists and opens them by their desktop files. No VNC server comes
19
- # with it. One image serves a sandbox and a desktop (an Agent37 desktop starts from it too).
17
+ # user on :0 (src/desktop.ts), and the apps E2B Desktop has that are cheap to carry: Xfce's terminal, text editor
18
+ # and file manager (Thunar), Firefox ESR, and xdotool. computerd's apps group lists and opens them by their desktop
19
+ # files. No VNC server comes with it. One image serves a sandbox and a desktop (an Agent37 desktop starts from it
20
+ # too).
20
21
  #
21
22
  # No sudo and no sudoers file: the image's user is root, so the provider's own exec (Daytona's toolbox, Modal's exec,
22
23
  # E2B's commands as root) runs the helper as root, and the tool user has no way to root. The build fails if the base
package/box/install.sh CHANGED
@@ -53,10 +53,10 @@ packages() {
53
53
  desktop() {
54
54
  apt-get update -qq
55
55
  DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends \
56
- xvfb xfwm4 x11-xserver-utils xfce4-terminal mousepad firefox-esr xdotool fonts-dejavu-core adwaita-icon-theme >/dev/null
56
+ xvfb xfwm4 x11-xserver-utils xfce4-terminal mousepad firefox-esr thunar xdotool fonts-dejavu-core adwaita-icon-theme >/dev/null
57
57
  rm -rf /var/lib/apt/lists/*
58
- for x in Xvfb xfwm4 dbus-run-session xsetroot xfce4-terminal mousepad firefox-esr xdotool; do command -v "$x" >/dev/null || { echo "the image has no $x" >&2; exit 1; }; done
59
- for app in org.xfce.mousepad xfce4-terminal firefox-esr; do [ -f "/usr/share/applications/$app.desktop" ] || { echo "the image has no desktop file $app.desktop" >&2; exit 1; }; done
58
+ for x in Xvfb xfwm4 dbus-run-session xsetroot xfce4-terminal mousepad firefox-esr thunar xdotool; do command -v "$x" >/dev/null || { echo "the image has no $x" >&2; exit 1; }; done
59
+ for app in org.xfce.mousepad xfce4-terminal firefox-esr thunar; do [ -f "/usr/share/applications/$app.desktop" ] || { echo "the image has no desktop file $app.desktop" >&2; exit 1; }; done
60
60
  }
61
61
 
62
62
  # The root helper, from beside this file.
@@ -77,8 +77,12 @@ dial() {
77
77
  # gives /workspace to init's user (its --user), 0700, where a synced folder's runner pushes the run's folder. A daemon
78
78
  # whose sha256 is not AGENTRUN_DAEMON_SHA256 is removed, and nothing runs. With AGENTRUN_ATTACH_EGRESS, the operator's
79
79
  # relay (<IPv4>:<port>), the fetch and attach's dial both connect to the relay and speak TLS and HTTP to the URL's host
80
- # through it, and attach is given it too. Exits 2 for env missing or a malformed relay, 3 when the fetch failed, 4 for
81
- # a sha256 mismatch, 5 when init never listened, 6 when /workspace was not made init's user's; else it is
80
+ # through it, and attach is given it too. The fetch is tried again, after 1, 2, 4 then 8 s, on a connection that failed
81
+ # (refused, reset, dropped in TLS, timed out) or an HTTP 5xx, within FETCH_S seconds in all (each try's transfer is
82
+ # held to the seconds left, so a stalled or trickling one ends there too), one line on stderr per retry;
83
+ # an HTTP 4xx is the server's refusal and is never tried again. Exits 2 for env missing or a malformed relay, 3 when the
84
+ # fetch failed, 4 for a sha256 mismatch, 5 when init never listened (init is ended first, so agentrun-dial may be
85
+ # started again), 6 when /workspace was not made init's user's, 7 when the server refused the fetch; else it is
82
86
  # `computerd attach` and exits as it does.
83
87
  set -euf
84
88
  DAEMON=/opt/agentrun/computerd
@@ -87,6 +91,8 @@ SOCKET_DIR=/run/agentrun
87
91
  INIT_LOG=/run/agentrun-init.log
88
92
  WORKSPACE=/workspace
89
93
  OWNER=0:0
94
+ FETCH_S=45
95
+ INIT_WAIT_TENTHS=300
90
96
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
91
97
  for v in AGENTRUN_ATTACH_URL AGENTRUN_ATTACH_TOKEN AGENTRUN_DAEMON_URL AGENTRUN_DAEMON_SHA256 AGENTRUN_INIT_ARGS; do
92
98
  eval "[ -n \"\${$v-}\" ]" || { echo "agentrun-dial: $v is not set; the provider's create sets it" >&2; exit 2; }
@@ -117,10 +123,41 @@ chmod 0755 "${DAEMON%/*}"
117
123
  # init's socket is root's alone: whoever can connect to it drives the machine.
118
124
  chmod 0700 "$SOCKET_DIR"
119
125
  rm -f "$DAEMON.part"
120
- # The token goes to curl on its stdin, never on a command line, which every user may read in /proc.
121
- printf 'Authorization: Bearer %s\n' "$AGENTRUN_ATTACH_TOKEN" |
122
- curl -fsS --connect-timeout 10 --retry 10 --retry-connrefused --retry-max-time 300 $relay -H @- -o "$DAEMON.part" "$AGENTRUN_DAEMON_URL" ||
123
- { echo "agentrun-dial: fetching the daemon from $AGENTRUN_DAEMON_URL${relay:+ through $AGENTRUN_ATTACH_EGRESS} failed" >&2; rm -f "$DAEMON.part"; exit 3; }
126
+ # One try of the fetch, in at most $1 seconds: the HTTP status on stdout, 000 when no answer came. The token goes to curl
127
+ # on its stdin, never on a command line, which every user may read in /proc.
128
+ fetch() {
129
+ printf 'Authorization: Bearer %s\n' "$AGENTRUN_ATTACH_TOKEN" |
130
+ curl -sS --connect-timeout 10 --max-time "$1" --speed-limit 1024 --speed-time 30 $relay -H @- -o "$DAEMON.part" -w '%{http_code}' "$AGENTRUN_DAEMON_URL"
131
+ }
132
+ unfetched() {
133
+ echo "agentrun-dial: fetching the daemon from $AGENTRUN_DAEMON_URL${relay:+ through $AGENTRUN_ATTACH_EGRESS} failed: $1" >&2
134
+ rm -f "$DAEMON.part"
135
+ exit "$2"
136
+ }
137
+ tries() { if [ "$1" = 1 ]; then echo "1 try"; else echo "$1 tries"; fi; }
138
+ began=$(date +%s)
139
+ try=1
140
+ pause=1
141
+ why="no time was left"
142
+ while :; do
143
+ left=$((FETCH_S - ($(date +%s) - began)))
144
+ [ "$left" -ge 1 ] || unfetched "$why, after $(tries $((try - 1)))" 3
145
+ code=0
146
+ answer=$(fetch "$left") || code=$?
147
+ case "$code:$answer" in
148
+ 0:2??) break ;;
149
+ 0:4??) unfetched "the server answered HTTP $answer" 7 ;;
150
+ 0:5??) why="the server answered HTTP $answer" ;;
151
+ 0:*) unfetched "the server answered HTTP $answer" 3 ;;
152
+ 5:* | 6:* | 7:* | 28:* | 35:* | 52:* | 55:* | 56:*) why="curl exit $code" ;;
153
+ *) unfetched "curl exit $code" 3 ;;
154
+ esac
155
+ [ $(($(date +%s) - began + pause)) -lt "$FETCH_S" ] || unfetched "$why, after $(tries "$try")" 3
156
+ echo "agentrun-dial: the daemon fetch's try $try failed ($why); trying again in $pause s" >&2
157
+ sleep "$pause"
158
+ try=$((try + 1))
159
+ [ "$pause" -ge 8 ] || pause=$((pause * 2))
160
+ done
124
161
  sum=$(sha256sum "$DAEMON.part" | cut -c1-64)
125
162
  if [ "$sum" != "$AGENTRUN_DAEMON_SHA256" ]; then
126
163
  rm -f "$DAEMON.part"
@@ -134,10 +171,19 @@ mv -f "$DAEMON.part" "$DAEMON"
134
171
  # DISPLAY, the display init's screen and input methods drive, as the provider's exec start gives it.
135
172
  env -i PATH="$PATH" HOME="$HOME_DIR" AGENTRUN_COMPUTERD_SOCKET="$SOCKET_DIR/computerd.sock" ${DISPLAY:+DISPLAY="$DISPLAY"} \
136
173
  setsid sh -c 'cd "$HOME" && exec "$@"' sh "$DAEMON" init $AGENTRUN_INIT_ARGS >"$INIT_LOG" 2>&1 </dev/null &
174
+ # setsid in a background job, never its process group's leader, makes init's own session in place: $! leads it.
175
+ init=$!
137
176
  i=0
138
177
  until [ -S "$SOCKET_DIR/computerd.sock" ]; do
139
178
  i=$((i + 1))
140
- [ "$i" -le 300 ] || { echo "agentrun-dial: init did not listen at $SOCKET_DIR/computerd.sock within 30 s; its log:" >&2; cat "$INIT_LOG" >&2; exit 5; }
179
+ if [ "$i" -gt "$INIT_WAIT_TENTHS" ]; then
180
+ echo "agentrun-dial: init did not listen at $SOCKET_DIR/computerd.sock within $((INIT_WAIT_TENTHS / 10)).$((INIT_WAIT_TENTHS % 10)) s; its log:" >&2
181
+ cat "$INIT_LOG" >&2
182
+ # init's group exists once setsid has run; until then $! is the start itself, ended by its pid alone.
183
+ kill -s TERM -- "-$init" 2>/dev/null || :
184
+ kill -s TERM "$init" 2>/dev/null || :
185
+ exit 5
186
+ fi
141
187
  sleep 0.1
142
188
  done
143
189
  # attach's environment: the URL and token alone, and the relay when given (it dials init at its default socket,
@@ -158,7 +204,7 @@ checked() {
158
204
  rm -rf /etc/sudoers /etc/sudoers.d
159
205
  chown root:root "$HELPER" "$DIAL"
160
206
  chmod 0755 "$HELPER" "$DIAL"
161
- for x in /usr/bin/archil /usr/bin/awk /usr/bin/realpath /usr/bin/mount /usr/bin/chown /usr/bin/find /usr/bin/id /usr/bin/ls /usr/bin/curl /usr/bin/setsid /usr/bin/sha256sum; do
207
+ for x in /usr/bin/archil /usr/bin/awk /usr/bin/realpath /usr/bin/mount /usr/bin/chown /usr/bin/find /usr/bin/id /usr/bin/ls /usr/bin/curl /usr/bin/setsid /usr/bin/sha256sum /usr/bin/date; do
162
208
  [ -x "$x" ] || { echo "the image has no $x" >&2; exit 1; }
163
209
  done
164
210
  ! command -v sudo >/dev/null 2>&1 || { echo "the image has sudo" >&2; exit 1; }
package/dist/agent37.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ProviderSecrets } from "./descriptor.js";
1
2
  import { HostedProvider, type HostedOptions, type HostedTimeouts } from "./hosted/provider.js";
2
3
  import { type Ssh2Module } from "./hosted/ssh-exec.js";
3
4
  import type { CallContext } from "./provider.js";
@@ -55,9 +56,14 @@ export interface Agent37ProviderOptions extends Omit<HostedOptions, "maxLifetime
55
56
  apiKey: string;
56
57
  /**
57
58
  * The private half of an SSH key registered on the same workspace (POST /v1/ssh-keys), in OpenSSH or PEM form: its
58
- * contents, never a path. Every command reaches an instance over SSH as root with it.
59
+ * contents, never a path. Every command reaches an instance over SSH as root with it. Absent: the provider's own key.
59
60
  */
60
- sshKey: string;
61
+ sshKey?: string;
62
+ /**
63
+ * Where the provider's own SSH key is kept, with no sshKey: a server's sealed store (its descriptor's `secrets`), one
64
+ * key per store. Absent: this process's memory, one key shared by its providers until it exits.
65
+ */
66
+ secrets?: ProviderSecrets;
61
67
  /** The ssh2 package: the host's own, or anything with the same slice. */
62
68
  ssh2: Ssh2Module;
63
69
  /** The fetch every REST call goes through; default the global one. */
@@ -89,8 +95,9 @@ export interface Agent37Options extends Omit<Agent37ProviderOptions, "ssh2"> {
89
95
  export declare const AGENT37_SSH_PORT = 22022;
90
96
  /**
91
97
  * An Agent37Provider from its options alone; it reads no environment. The key is options.apiKey and the SSH key
92
- * options.sshKey, nowhere else (serve passes its AGENT37_API_KEY and AGENT37_SSH_KEY, the conformance module what it
93
- * reads), and ssh2 is the host's package unless given. Throws in words when an option is missing or wrong, never echoing a key.
98
+ * options.sshKey when given, nowhere else (serve passes its AGENT37_API_KEY, its AGENT37_SSH_KEY when set, and its sealed
99
+ * store as options.secrets; the conformance module what it reads), and ssh2 is the host's package unless given. Throws
100
+ * in words when an option is missing or wrong, never echoing a key.
94
101
  */
95
102
  export declare function create(options: Agent37Options): Promise<Agent37Provider>;
96
103
  /** The conformance CLI's module for Agent37: its live switch, the run's cap, its template and the drifted twin. */
package/dist/agent37.js CHANGED
@@ -2,10 +2,12 @@
2
2
  // the adapter starts through the daemon), each a whole VM by default (type "vm"), or a gVisor sandbox
3
3
  // (type "default"). The control plane is Agent37's REST API over fetch (https://api.agent37.com/v1, a Bearer key);
4
4
  // every command (the daemon's upload, its install, init's start, the stdio bridge) goes over SSH, as root, through the
5
- // host's own ssh2 package, of which this package names only the slice it uses (Ssh2Module) and imports nothing at load.
5
+ // ssh2 package (an optional dependency), of which this package names only the slice it uses (Ssh2Module) and imports nothing at load.
6
6
  // Agent37 has no SSH port on the internet: the SSH stream rides a binary WebSocket to wss://{id}-22022.agent37.app,
7
7
  // which the edge opens for the workspace key in X-Agent37-Key (npm agent37@0.4.1 src/cli.js, wsHandshake and runTunnel),
8
- // and the instance's sshd then takes the workspace's registered SSH key. Agent37's REST exec is one-shot (no stdin,
8
+ // and the instance's sshd then takes the workspace's registered SSH keys (docs: agents-api/ssh): the one the caller gives
9
+ // (sshKey), else the provider's own, an ed25519 key it makes on first use, keeps in its store (secrets: a server's
10
+ // sealed one, else this process's memory) and registers with POST /v1/ssh-keys before its first create. Agent37's REST exec is one-shot (no stdin,
9
11
  // output only at its end), so it is not used. The rest of the computer is the shared machine-host adapter's
10
12
  // (./hosted/provider.ts). Every vendor fact here is cited in the README's Agent37 section.
11
13
  import { createHash } from "node:crypto";
@@ -14,14 +16,14 @@ import { boxImageRef, boxRecipeHash } from "./box-image.js";
14
16
  import { AGENT37, AGENT37_BASE_TEMPLATE } from "./descriptors/agent37.js";
15
17
  import { DEADLINE_LABEL, show } from "./drift.js";
16
18
  import { HostError } from "./host.js";
17
- import { orThrow } from "./hosted/process.js";
19
+ import { boundOf, codeOfError, orThrow } from "./hosted/process.js";
18
20
  import { httpsBase, jsonOf, rest } from "./hosted/rest.js";
19
21
  import { HostedProvider } from "./hosted/provider.js";
20
22
  import { pemOf, SshExec, SshTunnelError } from "./hosted/ssh-exec.js";
23
+ import { ed25519PublicOf, newEd25519 } from "./hosted/ssh-key.js";
21
24
  import { dateOf, DOMAIN, isWhole } from "./hosted/values.js";
22
25
  import { failFor, ok } from "./result.js";
23
- /** Not a literal, so no type checker or bundler resolves ssh2 from this package. */
24
- const SSH2_PACKAGE = "ssh2";
26
+ import { vendorSdk } from "./vendor-sdk.js";
25
27
  const DEFAULT_API_URL = "https://api.agent37.com";
26
28
  const DEFAULT_PROXY_DOMAIN = "agent37.app";
27
29
  /** The port the platform's sshd answers on inside every instance, reached as {id}-22022.<domain> (cli.js:21, 720). */
@@ -60,6 +62,68 @@ const REGISTER_MS = 15 * 60_000;
60
62
  const TEMPLATE_READ_MS = 30_000;
61
63
  /** How often a template another registration is making is read again. */
62
64
  const TEMPLATE_POLL_MS = 1_000;
65
+ /** The name the provider's own SSH key is kept under in its store. */
66
+ const SSH_KEY_SECRET = "ssh_key";
67
+ /** Agent37's cap on one workspace's SSH keys: the 21st POST /v1/ssh-keys answers 400 invalid_request (docs: agents-api/ssh). */
68
+ const MAX_SSH_KEYS = 20;
69
+ /**
70
+ * How long after its registration a key may still be on its way to an instance made before it, so a login its sshd
71
+ * refuses is tried again: Agent37 hands a key to running instances "within about two minutes" (docs: agents-api/ssh),
72
+ * and a minute more is allowed. An instance made after the registration has the key from boot.
73
+ */
74
+ const KEY_SETTLE_MS = 3 * 60_000;
75
+ /** Each call of the key's registration: the listing, then the POST. */
76
+ const SSH_KEY_CALL_MS = 30_000;
77
+ /** Where a provider given no store keeps its own key: this process's memory, one key shared by its providers. */
78
+ const PROCESS_SECRETS = (() => {
79
+ const held = new Map();
80
+ return {
81
+ get: async (name) => held.get(name),
82
+ putIfAbsent: async (name, value) => {
83
+ if (!held.has(name))
84
+ held.set(name, value);
85
+ return held.get(name);
86
+ },
87
+ };
88
+ })();
89
+ /** Words in a 400 to POST /v1/ssh-keys that say it is the workspace's cap, not the key. */
90
+ const CAP_SAID = /\b(?:at most|maximum|limit|too many)\b/i;
91
+ /**
92
+ * Each store's own key, on its way or kept: one read, make and putIfAbsent for every provider on the store in this
93
+ * process, so of first uses together one key is made; dropped when it fails.
94
+ */
95
+ const KEPT = new WeakMap();
96
+ /**
97
+ * Each store's registrations of its key, by workspace and fingerprint, and when each was made (ms): one listing and at
98
+ * most one POST /v1/ssh-keys for every provider on the store in this process; dropped when one fails, and when the key
99
+ * is refused past KEY_SETTLE_MS (it may be gone from the workspace).
100
+ */
101
+ const REGISTERED = new WeakMap();
102
+ /** What `held` has under `key`, else `make()` put there: every caller waits on the one promise, dropped when it fails. */
103
+ function sharedBy(held, key, make) {
104
+ const known = held.get(key);
105
+ if (known !== undefined)
106
+ return known;
107
+ const making = make();
108
+ held.set(key, making);
109
+ making.catch(() => {
110
+ if (held.get(key) === making)
111
+ held.delete(key);
112
+ });
113
+ return making;
114
+ }
115
+ /**
116
+ * The ed25519 key `secrets` keeps (PKCS#8 PEM), else a new one kept there by putIfAbsent: of first uses racing on the
117
+ * store, in this process or another, every one answers the key the store kept, and only that one is registered.
118
+ */
119
+ async function keptKey(secrets) {
120
+ const kept = (await secrets.get(SSH_KEY_SECRET)) ?? (await secrets.putIfAbsent(SSH_KEY_SECRET, newEd25519()));
121
+ if (kept === undefined)
122
+ throw new HostError("vendor", "this server's own SSH key could not be kept in its store: it kept none, and read none back");
123
+ if (ed25519PublicOf(kept) === undefined)
124
+ throw new HostError("vendor", `this server's store holds a value as its own SSH key (${SSH_KEY_SECRET}) that is not an ed25519 private key: set AGENT37_SSH_KEY to the private half of a key on the workspace`);
125
+ return kept;
126
+ }
63
127
  /** An id held to Agent37's form before it reaches a URL or a host name (an id is also a DNS label here): not_found else. */
64
128
  function instanceId(id) {
65
129
  if (!INSTANCE_ID.test(id))
@@ -103,6 +167,8 @@ function codeOf(error) {
103
167
  return "timeout";
104
168
  return "vendor";
105
169
  }
170
+ /** A workspace at Agent37's cap of SSH keys, in words: what shows it there (`why`), and the two ways out. Nothing is deleted. */
171
+ const fullOf = (why) => new HostError("limit", `this server's own SSH key could not be registered: Agent37 takes at most ${MAX_SSH_KEYS} SSH keys a workspace, and ${why}. Delete keys the workspace no longer needs (those named agentrun-<hash> were registered by AgentRun; DELETE /v1/ssh-keys/{id}), or set AGENT37_SSH_KEY to the private half of a key already on it`);
106
172
  /** Agent37's statuses (docs: instances/object, Statuses) as the adapter's states; failed, deleting and deleted are gone (get answers none for deleted). */
107
173
  function stateOf(status) {
108
174
  if (status === "running")
@@ -221,9 +287,27 @@ class Agent37Host {
221
287
  #WebSocket;
222
288
  #proxyDomain;
223
289
  #declared;
290
+ #secrets;
291
+ #onNote;
292
+ /** The workspace a registration is made on: the API URL and the API key's SHA-256, never the key. */
293
+ #workspace;
294
+ /** The key every login takes: the given one from the start; the provider's own once kept and registered. */
295
+ #key;
296
+ /** The provider's own key on its way: kept and registered once, every call waiting on the same; dropped when it fails. */
297
+ #ready;
224
298
  constructor(options) {
225
299
  this.#apiKey = options.apiKey;
226
- this.#ssh = new SshExec({ ssh2: options.ssh2, loginOf: () => ({ username: "root", privateKey: options.sshKey }), tunnelOf: (id) => this.#tunnel(id) });
300
+ this.#key = options.sshKey === undefined ? undefined : { privateKey: options.sshKey };
301
+ this.#secrets = options.secrets;
302
+ this.#onNote = options.onNote;
303
+ this.#workspace = `${options.apiUrl} ${createHash("sha256").update(options.apiKey, "utf8").digest("hex")}`;
304
+ this.#ssh = new SshExec({
305
+ ssh2: options.ssh2,
306
+ loginOf: () => ({ username: "root", privateKey: this.#key?.privateKey }),
307
+ tunnelOf: (id) => this.#tunnel(id),
308
+ // The provider's own key may still be on its way to an instance made before its registration.
309
+ deniedUntil: () => (this.#key?.own ? this.#key.own.registeredAt + KEY_SETTLE_MS : 0),
310
+ });
227
311
  this.#client = rest({
228
312
  base: options.apiUrl,
229
313
  headers: () => ({ Authorization: `Bearer ${options.apiKey}`, Accept: "application/json" }),
@@ -262,9 +346,118 @@ class Agent37Host {
262
346
  ws.binaryType = "arraybuffer";
263
347
  return { ...tunnelOf(ws, host), host };
264
348
  }
265
- /** argv as root over SSH (hosted/ssh-exec.ts): one connection per instance through its tunnel, shared by its execs. */
349
+ /**
350
+ * argv as root over SSH (hosted/ssh-exec.ts): one connection per instance through its tunnel, shared by its execs,
351
+ * with the given key or the provider's own (#keyReady), within ctx. The provider's own key refused past KEY_SETTLE_MS
352
+ * after its registration is denied in words, and the next call reads the workspace's keys again (it may be gone).
353
+ */
266
354
  async exec(id, argv, ctx) {
267
- return this.#ssh.exec(instanceId(id), argv, ctx);
355
+ const machine = instanceId(id);
356
+ const end = Date.now() + ctx.timeoutMs;
357
+ const key = await this.#keyReady(ctx);
358
+ try {
359
+ return await this.#ssh.exec(machine, argv, { ...ctx, timeoutMs: Math.max(1, end - Date.now()) });
360
+ }
361
+ catch (error) {
362
+ if (key.own === undefined || codeOf(error) !== "denied")
363
+ throw error;
364
+ if (this.#key === key)
365
+ this.#ready = undefined;
366
+ key.own.forget();
367
+ const { fingerprint, registeredAt } = key.own;
368
+ throw new HostError("denied", `the sshd of Agent37 instance ${machine} refused this server's own SSH key ${fingerprint}, registered on the workspace at ${new Date(registeredAt).toISOString()}: Agent37 hands a key to running instances within about two minutes, and it was tried until ${KEY_SETTLE_MS / 60_000} minutes after its registration. Check that the key is still on the workspace (GET /v1/ssh-keys), or set AGENT37_SSH_KEY to the private half of a key that is`);
369
+ }
370
+ }
371
+ /**
372
+ * The key a login takes, within ctx: the given one, or the provider's own, kept in its store and registered on the
373
+ * workspace once (#ownKey), every call waiting on the same; one that failed is tried afresh by the next call.
374
+ */
375
+ async #keyReady(ctx) {
376
+ if (this.#key !== undefined && this.#key.own === undefined)
377
+ return this.#key;
378
+ if (this.#ready === undefined) {
379
+ const making = this.#ownKey();
380
+ this.#ready = making;
381
+ making.catch(() => {
382
+ if (this.#ready === making)
383
+ this.#ready = undefined;
384
+ });
385
+ }
386
+ const bound = boundOf(ctx.timeoutMs, ctx.signal, "the registration of this server's own SSH key on the Agent37 workspace");
387
+ try {
388
+ return await Promise.race([this.#ready, bound.promise]);
389
+ }
390
+ finally {
391
+ bound.clear();
392
+ }
393
+ }
394
+ /**
395
+ * The provider's own key, the one its store keeps (keptKey), registered on the workspace (#register): the key every
396
+ * login takes from then on. Both are the store's in this process, shared by every provider on it.
397
+ */
398
+ async #ownKey() {
399
+ const secrets = this.#secrets;
400
+ const pem = await sharedBy(KEPT, secrets, () => keptKey(secrets));
401
+ const pub = ed25519PublicOf(pem);
402
+ let registrations = REGISTERED.get(secrets);
403
+ if (registrations === undefined)
404
+ REGISTERED.set(secrets, (registrations = new Map()));
405
+ const at = `${this.#workspace} ${pub.fingerprint}`;
406
+ const registering = sharedBy(registrations, at, () => this.#register(pub));
407
+ const registeredAt = await registering;
408
+ const privateKey = pemOf(pem);
409
+ if (privateKey === undefined)
410
+ throw new HostError("vendor", `this server's own SSH key ${pub.fingerprint} could not be read as SSH reads it`);
411
+ const forget = () => {
412
+ if (registrations.get(at) === registering)
413
+ registrations.delete(at);
414
+ };
415
+ this.#key = { privateKey, own: { fingerprint: pub.fingerprint, registeredAt, forget } };
416
+ return this.#key;
417
+ }
418
+ /**
419
+ * The key on the workspace, and when it was registered (ms): GET /v1/ssh-keys, which echoes no key, matched by
420
+ * fingerprint; else POST /v1/ssh-keys { public_key, name agentrun-<its hash> }, where a 409 ssh_key_exists is a
421
+ * registration another made (docs: agents-api/ssh). A workspace at its 20 keys is refused in words, and no key of it
422
+ * is deleted. Throws a HostError, in Agent37's words.
423
+ */
424
+ async #register({ line, fingerprint, hash }) {
425
+ const name = `agentrun-${hash.slice(0, 12)}`;
426
+ const failed = (error) => {
427
+ const said = error instanceof Error ? error.message : String(error);
428
+ return new HostError(codeOfError(this, error), `this server's own SSH key ${fingerprint} could not be registered on the Agent37 workspace: ${said}`);
429
+ };
430
+ const listed = await this.#rest("GET", "/v1/ssh-keys", undefined, { timeoutMs: SSH_KEY_CALL_MS }).catch((error) => {
431
+ throw failed(error);
432
+ });
433
+ if (!Array.isArray(listed?.data))
434
+ throw failed(new HostError("vendor", "GET /v1/ssh-keys answered no data list"));
435
+ const keys = listed.data;
436
+ const found = keys.find((one) => one?.fingerprint === fingerprint);
437
+ if (found)
438
+ return typeof found.created === "number" && Number.isFinite(found.created) ? found.created * 1000 : Date.now();
439
+ if (keys.length >= MAX_SSH_KEYS)
440
+ throw fullOf(`the workspace holds ${keys.length}`);
441
+ let status;
442
+ try {
443
+ status = orThrow(await this.#client.call("POST", this.#client.url("/v1/ssh-keys"), { json: { public_key: `${line} ${name}`, name }, timeoutMs: SSH_KEY_CALL_MS, accept: (code) => (code >= 200 && code < 300) || code === 409 })).status;
444
+ }
445
+ catch (error) {
446
+ if (!(error instanceof HostError) || error.code !== "invalid")
447
+ throw failed(error);
448
+ // A 400 is the cap when its words say so, or when the workspace holds 20 keys now (taken since the listing);
449
+ // any other is Agent37's refusal of the key, in its words.
450
+ if (CAP_SAID.test(error.message))
451
+ throw fullOf(`Agent37 said so: ${error.message}`);
452
+ const again = await this.#rest("GET", "/v1/ssh-keys", undefined, { timeoutMs: SSH_KEY_CALL_MS }).catch(() => undefined);
453
+ const held = Array.isArray(again?.data) ? again.data.length : 0;
454
+ if (held >= MAX_SSH_KEYS)
455
+ throw fullOf(`the workspace holds ${held}`);
456
+ throw new HostError("vendor", `this server's own SSH key ${fingerprint} could not be registered on the Agent37 workspace: Agent37 refused it: ${error.message}`);
457
+ }
458
+ if (status !== 409)
459
+ this.#onNote?.({ computer: name, note: `this server's own SSH key ${fingerprint} was registered on the Agent37 workspace as ${name}` });
460
+ return Date.now();
268
461
  }
269
462
  /** One REST call, bounded by ctx: its JSON answer; a failure throws a HostError in Agent37's words. */
270
463
  async #rest(method, path, body, ctx) {
@@ -294,13 +487,17 @@ class Agent37Host {
294
487
  * instance's name, the labels as metadata, deny-all (or allow-all where the adapter asks egress: an Archil computer's root, or the
295
488
  * egress proxy of a network open or a list), auto-sleep off and
296
489
  * no public port. It answers once the instance runs (docs: instances/create, Defaults). req.backstopAt is left:
297
- * Agent37 has no delete or stop timer to set it on, so the janitor alone ends an instance.
490
+ * Agent37 has no delete or stop timer to set it on, so the janitor alone ends an instance. The provider's own SSH key
491
+ * is registered first (#keyReady), so the instance has it from boot.
298
492
  */
299
493
  async create(req, ctx) {
300
494
  const bytes = Buffer.byteLength(JSON.stringify(req.labels));
301
495
  if (bytes > METADATA_MAX_BYTES)
302
496
  throw new HostError("invalid", `Agent37 holds an instance's metadata to ${METADATA_MAX_BYTES} bytes as JSON, and this one's would be ${bytes}: give shorter labels`);
303
497
  const shape = req.cpus !== undefined || req.memoryMb !== undefined ? shapeOf(req.cpus, req.memoryMb) : undefined;
498
+ const end = Date.now() + ctx.timeoutMs;
499
+ await this.#keyReady(ctx);
500
+ ctx = { ...ctx, timeoutMs: Math.max(1, end - Date.now()) };
304
501
  const made = await this.#rest("POST", "/v1/instances", {
305
502
  template: req.image,
306
503
  type: this.#declared.type,
@@ -401,13 +598,14 @@ class Agent37Host {
401
598
  }
402
599
  /**
403
600
  * An Agent37Provider from its options alone; it reads no environment. The key is options.apiKey and the SSH key
404
- * options.sshKey, nowhere else (serve passes its AGENT37_API_KEY and AGENT37_SSH_KEY, the conformance module what it
405
- * reads), and ssh2 is the host's package unless given. Throws in words when an option is missing or wrong, never echoing a key.
601
+ * options.sshKey when given, nowhere else (serve passes its AGENT37_API_KEY, its AGENT37_SSH_KEY when set, and its sealed
602
+ * store as options.secrets; the conformance module what it reads), and ssh2 is the host's package unless given. Throws
603
+ * in words when an option is missing or wrong, never echoing a key.
406
604
  */
407
605
  export async function create(options) {
408
606
  const { ssh2: given, ...rest } = options ?? {};
409
607
  // ssh2 is CommonJS: its Client is a named export of the module, and of its default.
410
- const loaded = given ?? (await import(SSH2_PACKAGE));
608
+ const loaded = given ?? (await vendorSdk(AGENT37.label, "ssh2"));
411
609
  const ssh2 = typeof loaded.Client === "function" ? loaded : loaded.default;
412
610
  return new Agent37Provider({ ...rest, ssh2: ssh2 });
413
611
  }
@@ -444,21 +642,21 @@ export class Agent37Provider extends HostedProvider {
444
642
  }
445
643
  }
446
644
  constructor(options) {
447
- const { apiKey, sshKey, ssh2, fetch: fetcher = globalThis.fetch, WebSocket = globalThis.WebSocket, apiUrl = DEFAULT_API_URL, proxyDomain = DEFAULT_PROXY_DOMAIN, type = "vm", region = "us", timeouts = {}, ...rest } = options ?? {};
645
+ const { apiKey, sshKey, secrets = PROCESS_SECRETS, ssh2, fetch: fetcher = globalThis.fetch, WebSocket = globalThis.WebSocket, apiUrl = DEFAULT_API_URL, proxyDomain = DEFAULT_PROXY_DOMAIN, type = "vm", region = "us", timeouts = {}, ...rest } = options ?? {};
448
646
  if (typeof apiKey !== "string" || apiKey === "")
449
647
  throw new Error("options.apiKey, the Agent37 API key, is required: the provider reads no environment, so the caller passes it");
450
648
  const privateKey = typeof sshKey === "string" ? pemOf(sshKey) : undefined;
451
- if (privateKey === undefined)
649
+ if (sshKey !== undefined && privateKey === undefined)
452
650
  throw new Error("options.sshKey must be the contents of an SSH private key (-----BEGIN ... PRIVATE KEY-----), never a path");
651
+ if (typeof secrets?.get !== "function" || typeof secrets.putIfAbsent !== "function")
652
+ throw new Error("options.secrets must be a store of the provider's own secrets, with get and putIfAbsent, as a server's sealed one is");
453
653
  if (typeof ssh2?.Client !== "function")
454
654
  throw new Error("options.ssh2 must be the ssh2 package (its Client class): the host installs it, as it does e2b");
455
655
  if (typeof fetcher !== "function")
456
656
  throw new Error("options.fetch must be a function, as the global fetch is");
457
657
  if (typeof WebSocket !== "function")
458
658
  throw new Error("options.WebSocket must be a WebSocket class that takes headers, as Node's global one does");
459
- const api = new URL(httpsBase(apiUrl, "the Agent37 API URL"));
460
- if (api.search !== "" || api.hash !== "")
461
- throw new Error(`the Agent37 API URL takes no query or fragment, as ${DEFAULT_API_URL} has none: ${JSON.stringify(apiUrl)}`);
659
+ const api = httpsBase(apiUrl, "the Agent37 API URL");
462
660
  if (typeof proxyDomain !== "string" || !DOMAIN.test(proxyDomain))
463
661
  throw new Error(`proxyDomain must be a host name such as ${DEFAULT_PROXY_DOMAIN}, not ${JSON.stringify(proxyDomain)}`);
464
662
  if (type !== "vm" && type !== "default")
@@ -467,11 +665,11 @@ export class Agent37Provider extends HostedProvider {
467
665
  throw new Error(`region is us, eu or ap-south, not ${JSON.stringify(region)}`);
468
666
  if (region !== "us" && type !== "vm")
469
667
  throw new Error(`Agent37 runs type default in us alone: ${region} takes type vm`);
470
- const host = new Agent37Host({ apiKey, sshKey: privateKey, ssh2, fetch: fetcher, WebSocket, apiUrl: api.href.replace(/\/+$/, ""), proxyDomain, type, region });
668
+ const host = new Agent37Host({ apiKey, sshKey: privateKey, secrets, onNote: rest.onNote, ssh2, fetch: fetcher, WebSocket, apiUrl: api, proxyDomain, type, region });
471
669
  super(host, { ...rest, timeouts: { createMs: DEFAULT_CREATE_MS, ...timeouts } });
472
670
  }
473
671
  }
474
672
  /** The workspace a key reaches, in words, for the sweep's scope: the key's sha256 prefix, never the key. */
475
673
  export function workspaceOf(apiKey, apiUrl = DEFAULT_API_URL) {
476
- return `the Agent37 workspace of the key sha256:${createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12)} at ${apiUrl.replace(/\/+$/, "")}`;
674
+ return `the Agent37 workspace of the key sha256:${createHash("sha256").update(apiKey, "utf8").digest("hex").slice(0, 12)} at ${httpsBase(apiUrl, "the Agent37 API URL")}`;
477
675
  }
package/dist/attach.d.ts CHANGED
@@ -14,8 +14,14 @@ export declare const ATTACH_EGRESS_ENV = "AGENTRUN_ATTACH_EGRESS";
14
14
  * it to the same shape. Anything else throws, in words.
15
15
  */
16
16
  export declare function attachEgressOf(text: string): string;
17
- /** The WebSocket subprotocol a driver asks for: the protocol version it speaks. Serve answers with it or refuses. */
17
+ /** The WebSocket subprotocol a driver asks for: the protocol version it speaks. */
18
18
  export declare const ATTACH_SUBPROTOCOL = "agentrun.computer.0.2";
19
+ /**
20
+ * The subprotocol of those a driver asked for that serve answers with: this server's own when it is asked for, as the
21
+ * answer tells the driver what the server speaks; else the first naming a protocol version that works with this one
22
+ * (helloProblem: 0.2 or a later 0.x); else undefined, and serve refuses the upgrade.
23
+ */
24
+ export declare function attachSubprotocolOf(asked: readonly string[]): string | undefined;
19
25
  /** Each side pings this often (WebSocket ping frames, not JSON-RPC), so a NAT keeps the path open. */
20
26
  export declare const ATTACH_HEARTBEAT_MS = 20000;
21
27
  /** A side that hears nothing, not even a pong, for this long closes the socket with ATTACH_CLOSE.idle. */
@@ -45,7 +51,7 @@ export declare const ATTACH_CLOSE: {
45
51
  readonly idle: 4408;
46
52
  /** The same computer dialed again; the older socket is closed. */
47
53
  readonly replaced: 4409;
48
- /** The driver speaks another protocol version, or its hello lacks a group its kind needs (kindServed): update it. */
54
+ /** The driver speaks a protocol the server does not take (helloProblem), or its hello lacks a group its kind needs (kindServed): update it. */
49
55
  readonly protocol: 4426;
50
56
  };
51
57
  /** Whether a driver dials again after a close with this code; false means a person must act (pair, update). */
@@ -151,8 +157,22 @@ export declare class MemoryMachineTokens implements MachineTokens {
151
157
  /** A minted machine as the AttachHub takes its socket: under the machine's name, its hello held to the mint. */
152
158
  export declare function mintedComputer(machine: string, { kind, os, arch }: Pick<MachineMint, "kind" | "os" | "arch">): PairedComputer;
153
159
  /**
154
- * Why a hello may not stand for a paired computer, or undefined. The protocol version must be the server's; the
155
- * driver's own version may be any: a person's installed app updates on its own schedule, and the server cannot
160
+ * Whether a refused driver's protocol version comes after this server's, so the server is the side to update: a
161
+ * "<major>.<minor>" later part by part as numbers ("1.0" after "0.2"). A version of any other shape ("0.2.1",
162
+ * "0.3-beta") is no server's, so updating the server never helps, and the driver is the side to update. Serve's pairing
163
+ * reads it too.
164
+ */
165
+ export declare function laterProtocol(protocol: string): boolean;
166
+ /**
167
+ * The words of serve's 426 at the attach upgrade, when no subprotocol `asked` names a protocol this server takes
168
+ * (attachSubprotocolOf). They name the side to update as helloMismatch does: the server when one asked names a later
169
+ * protocol, else the driver. A driver stops dialing on this 426 as on a 4426 close, and a 0.1 driver, which offers only
170
+ * its own subprotocol, is refused here and never reaches hello.
171
+ */
172
+ export declare function upgradeRefusal(paired: PairedComputer, asked: readonly string[]): string;
173
+ /**
174
+ * Why a hello may not stand for a paired computer, or undefined. The protocol version must work with the server's
175
+ * (helloProblem: 0.2 or a later 0.x); the driver's own version may be any: a person's installed app updates on its own schedule, and the server cannot
156
176
  * replace it the way a provider replaces a copied daemon.
157
177
  */
158
178
  export declare function helloMismatch(paired: PairedComputer, hello: HelloResult): {