@gresearch/marimohub-compute-armada 0.2.0 → 0.2.1

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.
package/README.md CHANGED
@@ -153,6 +153,12 @@ Lookout by job set for a sandbox it has never seen, since marimohub addresses sa
153
153
  id alone on several paths. A queue map therefore requires `ARMADA_LOOKOUT_URL`, and a
154
154
  call Lookout cannot answer fails rather than guesses; marimohub retries it.
155
155
 
156
+ The browser gives a starting session `MARIMOHUB_SANDBOX_STARTUP_TIMEOUT_SECONDS`
157
+ (default 120) plus 30 seconds, and that clock includes the time the job waits in its
158
+ Armada queue. On a busy cluster, raise it so users see their kernel arrive, not a
159
+ timeout. The adapter waits at most 5 minutes for the job to start running, so a
160
+ value above 270 gains nothing.
161
+
156
162
  Compute profiles (`MARIMOHUB_COMPUTE_PROFILES`, marimohub 0.4.13 onwards) let editors
157
163
  pick hardware per notebook: when creating it, later through "Change compute profile", or
158
164
  for one edit session. The adapter tells marimohub it applies them, and a profile's CPU
@@ -1,2 +1,2 @@
1
- 68c9ec13d55d53026e622ca506275df690901ac8e5b91c23794f3d35a7c66018 linux-amd64/agent
2
- af33c838031f5ba1c2ec20345135bcbc0ed0ea8fd64a3b626548163bf0180cad linux-arm64/agent
1
+ 9ad7981f758c2d6a9c5fa2df06bc138718dbb9cd7bb2b524ac62ef1258eb7487 linux-amd64/agent
2
+ 8c7adaf8cfb44d889c7f9747c6a74fad4af9c5ede8adb2cef2f4845446028b35 linux-arm64/agent
Binary file
Binary file
package/dist/index.js CHANGED
@@ -184,6 +184,7 @@ function asObject(value, what) {
184
184
  }
185
185
  var DEFAULT_RUNNING_TIMEOUT_MS = 5 * 60 * 1000;
186
186
  var DEFAULT_INGRESS_TIMEOUT_MS = 60 * 1000;
187
+ var DEFAULT_STATUS_TIMEOUT_MS = 5 * 1000;
187
188
  var SANDBOX_MARK = "marimohub/sandbox";
188
189
  var ACTIVE_JOB_STATES = ["QUEUED", "LEASED", "PENDING", "RUNNING"];
189
190
  var FINISHED_JOB_STATES = new Set([
@@ -346,15 +347,23 @@ class ArmadaClient {
346
347
  await this.post("/v1/job/cancel", request);
347
348
  }
348
349
  async findJob(sandboxId, queue) {
350
+ const live = Object.entries(await this.jobStates(sandboxId, queue)).filter(([, state]) => !FINISHED_JOB_STATES.has(state)).map(([jobId]) => jobId).toSorted();
351
+ const jobId = live.at(-1);
352
+ return jobId === undefined ? undefined : { jobId, jobSetId: sandboxId, queue };
353
+ }
354
+ async isFinished(job, timeoutMs = DEFAULT_STATUS_TIMEOUT_MS) {
355
+ const states = await this.jobStates(job.jobSetId, job.queue, AbortSignal.timeout(timeoutMs));
356
+ const state = states[job.jobId];
357
+ return state !== undefined && FINISHED_JOB_STATES.has(state);
358
+ }
359
+ async jobStates(sandboxId, queue, signal) {
349
360
  const request = {
350
361
  queue,
351
362
  jobset: sandboxId,
352
363
  externalJobUri: sandboxId
353
364
  };
354
- const response = await this.postJson("/v1/job/statusUsingExternalJobUri", request);
355
- const live = Object.entries(response.jobStates ?? {}).filter(([, state]) => !FINISHED_JOB_STATES.has(state)).map(([jobId]) => jobId).toSorted();
356
- const jobId = live.at(-1);
357
- return jobId === undefined ? undefined : { jobId, jobSetId: sandboxId, queue };
365
+ const response = await this.postJson("/v1/job/statusUsingExternalJobUri", request, signal);
366
+ return response.jobStates ?? {};
358
367
  }
359
368
  async findQueue(jobSetId) {
360
369
  const lookout = this.config.lookoutUrl;
@@ -416,8 +425,8 @@ class ArmadaClient {
416
425
  }
417
426
  return response;
418
427
  }
419
- async postJson(path, body) {
420
- const response = await this.post(path, body);
428
+ async postJson(path, body, signal) {
429
+ const response = await this.post(path, body, signal);
421
430
  return asObject(await response.json(), `a response to ${path}`);
422
431
  }
423
432
  async postJsonTo(base, path, body) {
@@ -1255,6 +1264,14 @@ function agentToken(secret, id) {
1255
1264
  var WRITE_CONCURRENCY = 8;
1256
1265
  var AGENT_READY_TIMEOUT_MS = 30000;
1257
1266
  var PORT_READY_TIMEOUT_MS = 0;
1267
+
1268
+ class SandboxGoneError extends Error {
1269
+ name = "SandboxGoneError";
1270
+ }
1271
+ var goneErrors = new WeakSet;
1272
+ function isSandboxGone(error) {
1273
+ return error instanceof Error && goneErrors.has(error);
1274
+ }
1258
1275
  function toExecResult(result) {
1259
1276
  if (result.exitCode === 0) {
1260
1277
  return { success: true, stdout: result.stdout, stderr: result.stderr };
@@ -1292,6 +1309,7 @@ class ArmadaSandbox {
1292
1309
  placements;
1293
1310
  options;
1294
1311
  attachOnly;
1312
+ notFound;
1295
1313
  supportsBucketMount = false;
1296
1314
  job;
1297
1315
  pod;
@@ -1299,7 +1317,7 @@ class ArmadaSandbox {
1299
1317
  token;
1300
1318
  env = {};
1301
1319
  envDefaults = {};
1302
- constructor(id, config, armada, openChannel, queues, placements, options, attachOnly = false) {
1320
+ constructor(id, config, armada, openChannel, queues, placements, options, attachOnly = false, notFound = (message) => new SandboxGoneError(message)) {
1303
1321
  this.id = id;
1304
1322
  this.config = config;
1305
1323
  this.armada = armada;
@@ -1308,8 +1326,14 @@ class ArmadaSandbox {
1308
1326
  this.placements = placements;
1309
1327
  this.options = options;
1310
1328
  this.attachOnly = attachOnly;
1329
+ this.notFound = notFound;
1311
1330
  this.token = agentToken(config.agentTokenSecret, id);
1312
1331
  }
1332
+ gone(message) {
1333
+ const error = this.notFound(message);
1334
+ goneErrors.add(error);
1335
+ return error;
1336
+ }
1313
1337
  async ready() {
1314
1338
  if (this.channel !== undefined)
1315
1339
  return;
@@ -1326,6 +1350,10 @@ class ArmadaSandbox {
1326
1350
  }
1327
1351
  }
1328
1352
  this.job ??= this.attachOnly ? await this.existingJob() : await this.submit();
1353
+ const finished = !this.attachOnly && await this.armada.isFinished(this.job).catch(() => false);
1354
+ if (finished) {
1355
+ throw this.gone(`Sandbox ${this.id} is gone: its Armada job ${this.job.jobId} has finished, and a finished job is never started again`);
1356
+ }
1329
1357
  this.pod = await this.armada.waitForRunning(this.job);
1330
1358
  const url = await this.armada.portUrl(this.job, this.config.agentPort);
1331
1359
  const channel = this.openChannel({ url, token: this.token, pod: this.pod });
@@ -1341,7 +1369,7 @@ class ArmadaSandbox {
1341
1369
  const queue = await this.queue();
1342
1370
  const job = await this.armada.findJob(this.id, queue);
1343
1371
  if (job === undefined) {
1344
- throw new Error(`Sandbox ${this.id} has no unfinished job in queue "${queue}" to attach to, and attaching never submits one`);
1372
+ throw this.gone(`Sandbox ${this.id} has no unfinished job in queue "${queue}" to attach to, and attaching never submits one`);
1345
1373
  }
1346
1374
  return job;
1347
1375
  }
@@ -1372,6 +1400,8 @@ class ArmadaSandbox {
1372
1400
  const result = await channel.run(["sh", "-lc", command], deadline === undefined ? {} : { timeoutMs: deadline });
1373
1401
  return toExecResult(result);
1374
1402
  } catch (error) {
1403
+ if (isSandboxGone(error))
1404
+ throw error;
1375
1405
  const stderr = error instanceof CommandTimeoutError && backstopMs !== undefined ? `Command ran past ARMADA_COMMAND_MAX_SECONDS (${String(this.config.commandMaxSeconds)}s) and was killed: ${cmd}` : reason(error);
1376
1406
  return {
1377
1407
  success: false,
@@ -1418,6 +1448,8 @@ class ArmadaSandbox {
1418
1448
  try {
1419
1449
  outcome = await read(await this.open());
1420
1450
  } catch (error) {
1451
+ if (isSandboxGone(error))
1452
+ throw error;
1421
1453
  return this.readFailed(path, "BACKEND_ERROR", reason(error));
1422
1454
  }
1423
1455
  if (outcome.outcome === "not-found") {
@@ -1437,7 +1469,9 @@ class ArmadaSandbox {
1437
1469
  let listed;
1438
1470
  try {
1439
1471
  listed = await (await this.open()).listFiles(path, options?.recursive === true);
1440
- } catch {
1472
+ } catch (error) {
1473
+ if (isSandboxGone(error))
1474
+ throw error;
1441
1475
  return { success: false, files: [], error: { code: "BACKEND_ERROR" } };
1442
1476
  }
1443
1477
  if (listed.outcome === "not-a-directory") {
@@ -1569,13 +1603,15 @@ ${log}`);
1569
1603
  // src/provider.ts
1570
1604
  class ArmadaCompute {
1571
1605
  config;
1606
+ notFound;
1572
1607
  armada;
1573
1608
  queues;
1574
1609
  placements = new Map;
1575
1610
  listActive;
1576
1611
  capabilities;
1577
- constructor(config) {
1612
+ constructor(config, notFound) {
1578
1613
  this.config = config;
1614
+ this.notFound = notFound;
1579
1615
  this.armada = new ArmadaClient(config);
1580
1616
  this.capabilities = {
1581
1617
  multiPort: config.surfacePorts.length > 0,
@@ -1593,10 +1629,10 @@ class ArmadaCompute {
1593
1629
  }
1594
1630
  }
1595
1631
  create(id, options) {
1596
- return new ArmadaSandbox(id, this.config, this.armada, openAgent, this.queues, this.placements, options);
1632
+ return new ArmadaSandbox(id, this.config, this.armada, openAgent, this.queues, this.placements, options, false, this.notFound);
1597
1633
  }
1598
1634
  connectExisting(id, options) {
1599
- return new ArmadaSandbox(id, this.config, this.armada, openAgent, this.queues, this.placements, options, true);
1635
+ return new ArmadaSandbox(id, this.config, this.armada, openAgent, this.queues, this.placements, options, true, this.notFound);
1600
1636
  }
1601
1637
  async proxy(_request) {
1602
1638
  return null;
@@ -1611,7 +1647,7 @@ var manifest = {
1611
1647
  apiVersion: 1,
1612
1648
  kind: "compute",
1613
1649
  create(context) {
1614
- return new ArmadaCompute(readConfig(context.env, context.compute));
1650
+ return new ArmadaCompute(readConfig(context.env, context.compute), context.errors.notFound);
1615
1651
  }
1616
1652
  };
1617
1653
  var src_default = manifest;
@@ -1619,5 +1655,5 @@ export {
1619
1655
  src_default as default
1620
1656
  };
1621
1657
 
1622
- //# debugId=39F702F4B98F089364756E2164756E21
1658
+ //# debugId=BD771C93E88246D664756E2164756E21
1623
1659
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -7,15 +7,15 @@
7
7
  "/**\n * How the adapter authenticates to Armada.\n *\n * Armada offers basic, OIDC, Kubernetes-native and exec-based credentials\n * (`pkg/client/connection.go`), but on the wire they are all one header. The\n * server matches the scheme case-insensitively for both basic\n * (`internal/common/auth/basic.go`) and bearer (`internal/common/auth/oidc.go`),\n * and the REST gateway reads `Authorization` exactly like the gRPC path does.\n *\n * We implement basic and bearer. Kubernetes-native is deliberately absent: it\n * uses a custom `KubernetesAuth <base64>` scheme carrying a CA alongside the\n * token, and it exists for executors authenticating to the server, not for\n * clients like this one.\n *\n * OIDC flows are covered by pointing `ARMADA_AUTH_TOKEN_FILE` at a file some\n * other process keeps fresh. We re-read it per request rather than caching, so a\n * rotated token (a projected Kubernetes service account token, for example) is\n * picked up without restarting marimohub.\n */\nimport { readFile } from 'node:fs/promises';\n\nexport type ArmadaAuth =\n\t| { kind: 'anonymous' }\n\t| { kind: 'basic'; username: string; password: string }\n\t| { kind: 'bearer'; token: string }\n\t| { kind: 'bearerFile'; path: string };\n\n/** The `Authorization` value, or nothing when the server allows anonymous access. */\nexport async function authorizationHeader(auth: ArmadaAuth): Promise<string | undefined> {\n\tswitch (auth.kind) {\n\t\tcase 'anonymous':\n\t\t\treturn undefined;\n\t\tcase 'basic': {\n\t\t\tconst credentials: string = `${auth.username}:${auth.password}`;\n\t\t\treturn `Basic ${Buffer.from(credentials, 'utf8').toString('base64')}`;\n\t\t}\n\t\tcase 'bearer':\n\t\t\treturn `Bearer ${auth.token}`;\n\t\tcase 'bearerFile': {\n\t\t\tconst token: string = (await readFile(auth.path, 'utf8')).trim();\n\t\t\tif (!token) throw new Error(`ARMADA_AUTH_TOKEN_FILE is empty: ${auth.path}`);\n\t\t\treturn `Bearer ${token}`;\n\t\t}\n\t\tdefault: {\n\t\t\tconst unhandled: never = auth;\n\t\t\tthrow new Error(`Unhandled Armada auth kind: ${JSON.stringify(unhandled)}`);\n\t\t}\n\t}\n}\n",
8
8
  "/**\n * Reader for the `application/ndjson-stream` responses grpc-gateway produces for\n * a streaming RPC: one JSON object per line, and a line is only complete at its\n * newline, which a chunk boundary does not respect.\n */\n\n/** Yields one parsed value per line, ignoring blank lines. */\nexport async function* readNdjson(body: ReadableStream<Uint8Array>): AsyncGenerator {\n\tconst decoder: TextDecoder = new TextDecoder();\n\tconst reader: ReadableStreamDefaultReader = body.getReader();\n\tlet buffered = '';\n\n\ttry {\n\t\tfor (;;) {\n\t\t\t// Sequential by nature: the next chunk does not exist until this one is read.\n\t\t\t// oxlint-disable-next-line no-await-in-loop\n\t\t\tconst { done, value } = await reader.read();\n\t\t\tif (done) break;\n\n\t\t\tbuffered += decoder.decode(value, { stream: true });\n\t\t\tlet newline: number = buffered.indexOf('\\n');\n\t\t\twhile (newline !== -1) {\n\t\t\t\tconst line: string = buffered.slice(0, newline).trim();\n\t\t\t\tbuffered = buffered.slice(newline + 1);\n\t\t\t\tif (line !== '') yield JSON.parse(line);\n\t\t\t\tnewline = buffered.indexOf('\\n');\n\t\t\t}\n\t\t}\n\n\t\tconst last: string = buffered.trim();\n\t\tif (last !== '') yield JSON.parse(last);\n\t} finally {\n\t\t// A consumer that stops early, on the event it wanted or an abort, leaves\n\t\t// the rest unread. Cancelling releases the connection; releasing the lock\n\t\t// alone would leave a watch stream open for as long as the server keeps\n\t\t// it, one socket per sandbox start in a long-lived process.\n\t\tawait reader.cancel().catch((): undefined => undefined);\n\t}\n}\n",
9
9
  "/**\n * The podspec we submit for one kernel session.\n *\n * Armada validates submissions strictly, and the rules that shape this file are\n * documented in docs/DECISIONS.md with citations. The ones that bite:\n *\n * - Resource requests must equal limits, and every container must set both,\n * init containers included. A server may insist an init container's CPU is\n * fractional, so the agent's is `100m` and never `1`.\n * - A pod that does not set `activeDeadlineSeconds` inherits the server default,\n * which ships at 72 hours. A kernel must never inherit that.\n * - The grace period must sit inside the server's bounds, 1s to 5m by default.\n * - A port is only exposable through a service or ingress if the container\n * declares it as a `containerPort`.\n *\n * The container does not run marimo. marimohub starts the kernel itself through\n * `startProcess` once the sandbox is reachable. What the container runs as\n * PID 1 is the agent (`agent/`): it keeps the container alive, runs the\n * commands marimohub sends on a second port, and reaps what the kernel leaves\n * behind. An init container copies it from its own image into a volume, so the\n * operator's kernel image is used unchanged.\n */\nimport type { V1PodSecurityContext, V1PodSpec } from '@kubernetes/client-node';\nimport type { ArmadaConfig } from './config.js';\nimport type { ComputeResources, CreateSandboxOptions } from './types.js';\n\n/** Name of the kernel container in the pod. Also the prefix of its service port. */\nexport const KERNEL_CONTAINER = 'kernel';\n\n/** Where the kernel container finds the agent: a volume the init container fills. */\nexport const AGENT_DIR = '/mh-agent';\nexport const AGENT_PATH = `${AGENT_DIR}/agent`;\nconst AGENT_VOLUME = 'mh-agent';\n\n/** The agent reads the hex SHA-256 of its bearer token from this variable. */\nexport const AGENT_TOKEN_HASH_ENV = 'MH_AGENT_TOKEN_SHA256';\n\n/** What the pod spec carries for the agent: never the token, only its hash. */\nexport interface AgentSpec {\n\ttokenSha256: string;\n}\n\nconst DEFAULT_CPU = '1';\nconst DEFAULT_MEMORY = '2Gi';\n\n/** Long enough for marimo to shut down cleanly, inside Armada's default 5m cap. */\nconst TERMINATION_GRACE_SECONDS = 30;\n\n/** Copying one small binary needs next to nothing, but Armada insists it be stated. */\nconst AGENT_INSTALL_RESOURCES: Record<string, string> = { cpu: '100m', memory: '64Mi' };\n\nconst MI: number = 1024 ** 2;\nconst GI: number = 1024 ** 3;\n\n/**\n * marimohub hands memory over in bytes. Kubernetes takes a byte count as is, but\n * `8Gi` is what an operator reads in Lookout and `kubectl`. marimohub's profiles\n * are whole `Mi` at least (`mem=<n><Mi|Gi|Ti>`); anything else stays bytes,\n * rounded up so a fraction is never refused.\n */\nfunction memoryQuantity(bytes: number): string {\n\tif (bytes % GI === 0) return `${String(bytes / GI)}Gi`;\n\tif (bytes % MI === 0) return `${String(bytes / MI)}Mi`;\n\treturn String(Math.ceil(bytes));\n}\n\n/** `A100:2` is two of that type, `A100` one. The type is upper-cased by marimohub. */\nfunction parseGpu(gpu: string): { type: string; count: string } {\n\tconst [type = '', count = '1'] = gpu.split(':');\n\treturn { type: type.toUpperCase(), count };\n}\n\nfunction quantities(resources: ComputeResources | undefined): Record<string, string> {\n\tconst requested: Record<string, string> = {\n\t\tcpu: resources?.cpu === undefined ? DEFAULT_CPU : String(resources.cpu),\n\t\tmemory:\n\t\t\tresources?.memoryBytes === undefined ? DEFAULT_MEMORY : memoryQuantity(resources.memoryBytes),\n\t};\n\n\t// Armada schedules the count as an ordinary resource and adds the GPU\n\t// toleration itself; the type is placement, which `gpuNodeSelector` answers.\n\tif (resources?.gpu !== undefined && resources.gpu !== '') {\n\t\trequested['nvidia.com/gpu'] = parseGpu(resources.gpu).count;\n\t}\n\n\treturn requested;\n}\n\n/**\n * Where a GPU of the requested type is, from `ARMADA_GPU_NODE_SELECTORS`, or\n * nothing when no GPU is asked for. A type the map does not name fails the\n * submission: `readConfig` already refuses a profile like that at startup, so\n * this is the backstop, and a pod on the wrong GPU is not an answer.\n */\nfunction gpuNodeSelector(\n\tconfig: ArmadaConfig,\n\tresources: ComputeResources | undefined,\n): Record<string, string> | undefined {\n\tif (resources?.gpu === undefined || resources.gpu === '') return undefined;\n\tconst { type } = parseGpu(resources.gpu);\n\tconst selector: Record<string, string> | undefined = config.gpuNodeSelectors[type];\n\tif (selector === undefined) {\n\t\tthrow new Error(\n\t\t\t`GPU type ${type} has no node selector in ARMADA_GPU_NODE_SELECTORS, so a pod cannot be placed on it`,\n\t\t);\n\t}\n\treturn selector;\n}\n\n/**\n * The pod-level `securityContext`, carrying only the ids that are configured,\n * or nothing when none is so the spec stays exactly what it was before these\n * existed. Pod-level, not container-level: the init container that copies the\n * agent must run with the same ids as the kernel container, or the copy is\n * owned by someone the kernel is not.\n */\nfunction securityContext(config: ArmadaConfig): V1PodSecurityContext | undefined {\n\tconst context: V1PodSecurityContext = {\n\t\t...(config.runAsUser === undefined ? {} : { runAsUser: config.runAsUser }),\n\t\t...(config.runAsGroup === undefined ? {} : { runAsGroup: config.runAsGroup }),\n\t\t...(config.fsGroup === undefined ? {} : { fsGroup: config.fsGroup }),\n\t};\n\treturn Object.keys(context).length === 0 ? undefined : context;\n}\n\nexport function buildPodSpec(\n\tconfig: ArmadaConfig,\n\tagent: AgentSpec,\n\toptions?: CreateSandboxOptions,\n): V1PodSpec {\n\tconst resources: Record<string, string> = quantities(options?.resources);\n\tconst nodeSelector: Record<string, string> | undefined = gpuNodeSelector(\n\t\tconfig,\n\t\toptions?.resources,\n\t);\n\tconst context: V1PodSecurityContext | undefined = securityContext(config);\n\n\treturn {\n\t\trestartPolicy: 'Never',\n\t\tterminationGracePeriodSeconds: TERMINATION_GRACE_SECONDS,\n\t\tactiveDeadlineSeconds: config.maxLifetimeSeconds,\n\t\t...(config.priorityClassName === undefined\n\t\t\t? {}\n\t\t\t: { priorityClassName: config.priorityClassName }),\n\t\t// A plain selector: Armada rejects the preferred kind of node affinity, and\n\t\t// only matches labels the executor tracks (docs/DECISIONS.md).\n\t\t...(nodeSelector === undefined ? {} : { nodeSelector }),\n\t\t// The worker cluster pulls both images, so the credential is named here.\n\t\t...(config.imagePullSecrets.length === 0\n\t\t\t? {}\n\t\t\t: {\n\t\t\t\t\timagePullSecrets: config.imagePullSecrets.map((name: string): { name: string } => ({\n\t\t\t\t\t\tname,\n\t\t\t\t\t})),\n\t\t\t\t}),\n\t\t...(context === undefined ? {} : { securityContext: context }),\n\t\tvolumes: [{ name: AGENT_VOLUME, emptyDir: {} }],\n\t\tinitContainers: [\n\t\t\t{\n\t\t\t\tname: 'agent-install',\n\t\t\t\timage: config.agentImage,\n\t\t\t\t// The agent copies itself, so its image holds nothing but the agent.\n\t\t\t\tcommand: ['/agent', 'install', AGENT_PATH],\n\t\t\t\tresources: { requests: AGENT_INSTALL_RESOURCES, limits: AGENT_INSTALL_RESOURCES },\n\t\t\t\tvolumeMounts: [{ name: AGENT_VOLUME, mountPath: AGENT_DIR }],\n\t\t\t},\n\t\t],\n\t\tcontainers: [\n\t\t\t{\n\t\t\t\tname: KERNEL_CONTAINER,\n\t\t\t\timage: options?.image ?? config.image,\n\t\t\t\t// The agent is PID 1: it idles until marimohub sends a command,\n\t\t\t\t// and it reaps what a detached kernel leaves behind.\n\t\t\t\tcommand: [AGENT_PATH, '--port', String(config.agentPort)],\n\t\t\t\tenv: [{ name: AGENT_TOKEN_HASH_ENV, value: agent.tokenSha256 }],\n\t\t\t\t// The kernel, the agent, then each surface marimohub may start\n\t\t\t\t// (`config.surfacePorts`): all of them earn an address this way.\n\t\t\t\tports: [config.port, config.agentPort, ...config.surfacePorts].map(\n\t\t\t\t\t(port: number): { containerPort: number; protocol: string } => ({\n\t\t\t\t\t\tcontainerPort: port,\n\t\t\t\t\t\tprotocol: 'TCP',\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t\tresources: { requests: resources, limits: resources },\n\t\t\t\tvolumeMounts: [{ name: AGENT_VOLUME, mountPath: AGENT_DIR }],\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Every port the pod declares, which is every port the job's service exposes.\n *\n * Armada only exposes a port the pod declares as a `containerPort`, and the\n * address event carries one entry per exposed port. So declaring a port here is\n * what earns it an address in that event: the kernel's, and the agent's.\n */\nexport function exposedPorts(spec: V1PodSpec): number[] {\n\tconst ports: number[] = [];\n\tfor (const container of spec.containers) {\n\t\tfor (const port of container.ports ?? []) ports.push(port.containerPort);\n\t}\n\treturn ports;\n}\n",
10
- "/**\n * Placement half of the adapter: submit a job, follow its event stream, and\n * resolve where it landed.\n *\n * There is no official JS/TS Armada client (Go, Java, Scala, Python and .NET\n * only), so this talks to the grpc-gateway REST endpoints. The protos carry\n * `google.api.http` annotations, so every RPC has an HTTP form.\n */\nimport type { V1PodSpec } from '@kubernetes/client-node';\nimport type {\n\tLookoutFilter,\n\tEventMessage,\n\tEventStreamLine,\n\tJobFailedEvent,\n\tJobIngressInfoEvent,\n\tJobRunningEvent,\n\tJobCancelRequest,\n\tJobSetRequest,\n\tJobSubmitRequest,\n\tJobSubmitRequestItem,\n\tJobStatusResponse,\n\tJobStatusUsingExternalJobUriRequest,\n\tJobSubmitResponse,\n\tJobSubmitResponseItem,\n\tLookoutGetJobsRequest,\n\tLookoutGetJobsResponse,\n\tLookoutJob,\n} from './armada-types.js';\nimport { JOB_STATE } from './armada-types.js';\nimport { authorizationHeader } from './auth.js';\nimport type { ArmadaConfig, Exposure } from './config.js';\nimport { readNdjson } from './ndjson.js';\nimport { exposedPorts } from './podspec.js';\nimport type { ActiveSandbox, SandboxId } from './types.js';\n\n/** Where a running job's pod lives, from `JobRunningEvent`. */\nexport interface PodLocation {\n\tclusterId: string;\n\tpodName: string;\n\tpodNamespace: string;\n\tnodeName?: string;\n}\n\nexport interface SubmittedJob {\n\tjobId: string;\n\tjobSetId: string;\n\t/** Every later call about the job is addressed by queue and job set. */\n\tqueue: string;\n}\n\n/** A live job as Lookout reports it: the sandbox, and the queue that holds it. */\nexport interface ActiveJob extends ActiveSandbox {\n\tqueue: string;\n}\n\n/**\n * Every Armada response type we read has only optional fields, so a JSON object\n * is structurally one of them. Checking that much and no more keeps the parse\n * honest without a schema validator: a field we read but the server stopped\n * sending is caught by `bun run check:armada-api`, not at runtime.\n */\nfunction asObject(value: unknown, what: string): object {\n\tif (typeof value !== 'object' || value === null) {\n\t\tthrow new Error(`Armada returned ${what} that is not a JSON object: ${JSON.stringify(value)}`);\n\t}\n\treturn value;\n}\n\n/** Long enough for an image pull on a cold node, short enough to fail a wedged queue. */\nconst DEFAULT_RUNNING_TIMEOUT_MS = 5 * 60 * 1000;\n\n/** The ingress event lands around Running, so by expose time it usually replays. */\nconst DEFAULT_INGRESS_TIMEOUT_MS = 60 * 1000;\n\n/**\n * Annotation marking a job as this installation's, set at submit and filtered\n * on by `listActive` and `findQueue`. Its value is the default queue name\n * (`ARMADA_QUEUE`), which names one marimohub installation however many queues\n * its owner map spreads jobs over, so enumeration does not depend on the map\n * of the day and two installations sharing an Armada never see each other's\n * sandboxes. Job annotations land on the pod too, so the mark is visible from\n * Lookout and from Kubernetes alike.\n */\nexport const SANDBOX_MARK = 'marimohub/sandbox';\n\n/** Lookout job states meaning \"this sandbox is alive or on its way\". */\nconst ACTIVE_JOB_STATES: string[] = ['QUEUED', 'LEASED', 'PENDING', 'RUNNING'];\n\n/**\n * Job states after which no pod runs and none will. `UNKNOWN` is not among\n * them: the server knows the job but not its state, and attaching to it finds\n * out the same way it does for a live one.\n */\nconst FINISHED_JOB_STATES: ReadonlySet<number> = new Set([\n\tJOB_STATE.SUCCEEDED,\n\tJOB_STATE.FAILED,\n\tJOB_STATE.PREEMPTED,\n\tJOB_STATE.CANCELLED,\n\tJOB_STATE.REJECTED,\n]);\n\n/** Lookout page size; more active kernels than this loops rather than truncates. */\nconst LIST_ACTIVE_PAGE = 500;\n\nexport class ArmadaClient {\n\tconstructor(private readonly config: ArmadaConfig) {}\n\n\t/**\n\t * Headers for every call to the gateway.\n\t *\n\t * Authorization is resolved per request rather than at construction, so a\n\t * token file that is rotated under us is picked up without a restart.\n\t */\n\tasync requestHeaders(): Promise<Record<string, string>> {\n\t\tconst authorization: string | undefined = await authorizationHeader(this.config.auth);\n\t\treturn {\n\t\t\t'content-type': 'application/json',\n\t\t\t...(authorization === undefined ? {} : { authorization }),\n\t\t};\n\t}\n\n\t/**\n\t * Submit one job for a sandbox.\n\t *\n\t * The sandbox id is used three times over, each for a different reason:\n\t * `clientId` so a resubmit dedupes instead of starting a second kernel,\n\t * `jobSetId` so this sandbox's events are their own stream, and\n\t * `externalJobUri` because it is the only way to find the job again later.\n\t *\n\t * The queue is the caller's choice (`src/queues.ts`) and travels with the\n\t * returned job, since every later call is addressed by it.\n\t */\n\tasync submit(sandboxId: SandboxId, podSpec: V1PodSpec, queue: string): Promise<SubmittedJob> {\n\t\tconst ports: number[] = exposedPorts(podSpec);\n\t\tconst expose: Exposure = this.config.expose;\n\t\t// Either way the executor reports one address per port in the same event.\n\t\t// An Ingress needs a service behind it, and Armada creates that itself: a\n\t\t// ClusterIP one, since a headless service (Armada's default) leaves the\n\t\t// ingress controller to resolve pod IPs on its own.\n\t\tconst exposure: Pick<JobSubmitRequestItem, 'ingress' | 'services'> =\n\t\t\texpose.kind === 'ingress'\n\t\t\t\t? {\n\t\t\t\t\t\tingress: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tports,\n\t\t\t\t\t\t\t\ttlsEnabled: expose.tls,\n\t\t\t\t\t\t\t\t...(expose.certName === undefined ? {} : { certName: expose.certName }),\n\t\t\t\t\t\t\t\tuseClusterIP: true,\n\t\t\t\t\t\t\t\t...(Object.keys(expose.annotations).length === 0\n\t\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t\t: { annotations: expose.annotations }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\t\t\t\t: { services: [{ type: 'NodePort', ports }] };\n\t\tconst request: JobSubmitRequest = {\n\t\t\tqueue,\n\t\t\tjobSetId: sandboxId,\n\t\t\tjobRequestItems: [\n\t\t\t\t{\n\t\t\t\t\tclientId: sandboxId,\n\t\t\t\t\texternalJobUri: sandboxId,\n\t\t\t\t\tnamespace: this.config.namespace,\n\t\t\t\t\tpodSpec,\n\t\t\t\t\t...(Object.keys(this.config.podLabels).length === 0\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { labels: this.config.podLabels }),\n\t\t\t\t\t// A retry would hand the user an empty kernel wearing their session's\n\t\t\t\t\t// name, so fail terminally and let marimohub offer the retry. The\n\t\t\t\t\t// sandbox mark is what `listActive` filters on: a queue may hold jobs\n\t\t\t\t\t// that are not marimohub's, and enumeration feeds a reconciler that\n\t\t\t\t\t// destroys what it does not recognise, so only marked jobs may appear.\n\t\t\t\t\t// The operator's annotations go first: `readConfig` refuses our keys,\n\t\t\t\t\t// and ours win regardless.\n\t\t\t\t\tannotations: {\n\t\t\t\t\t\t...this.config.podAnnotations,\n\t\t\t\t\t\t'armadaproject.io/failFast': 'true',\n\t\t\t\t\t\t[SANDBOX_MARK]: this.config.queue,\n\t\t\t\t\t},\n\t\t\t\t\t...exposure,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst response: JobSubmitResponse = await this.postJson('/v1/job/submit', request);\n\t\tconst item: JobSubmitResponseItem | undefined = response.jobResponseItems?.[0];\n\t\tif (item?.error !== undefined && item.error !== '') {\n\t\t\tthrow new Error(`Armada rejected the job for sandbox ${sandboxId}: ${item.error}`);\n\t\t}\n\t\tif (item?.jobId === undefined || item.jobId === '') {\n\t\t\tthrow new Error(`Armada returned no job id for sandbox ${sandboxId}`);\n\t\t}\n\t\treturn { jobId: item.jobId, jobSetId: sandboxId, queue };\n\t}\n\n\t/**\n\t * Block until the job reaches Running, returning where its pod landed.\n\t *\n\t * Terminal failures arrive on the same stream, so we react to them rather than\n\t * waiting out the timeout with no explanation. A failure marked `retryable` is\n\t * the scheduler saying another run follows, so it is not the end.\n\t */\n\tasync waitForRunning(\n\t\tjob: SubmittedJob,\n\t\ttimeoutMs: number = DEFAULT_RUNNING_TIMEOUT_MS,\n\t): Promise<PodLocation> {\n\t\tconst request: JobSetRequest = {\n\t\t\tqueue: job.queue,\n\t\t\tid: job.jobSetId,\n\t\t\twatch: true,\n\t\t\terrorIfMissing: false,\n\t\t};\n\t\tconst path: string = `/v1/job-set/${encodeURIComponent(job.queue)}/${encodeURIComponent(job.jobSetId)}`;\n\t\tconst response: Response = await this.post(path, request, AbortSignal.timeout(timeoutMs));\n\t\tif (response.body === null) throw new Error(`Armada returned no event stream for ${path}`);\n\n\t\tfor await (const value of readNdjson(response.body)) {\n\t\t\tconst line: EventStreamLine = asObject(value, 'an event stream line');\n\t\t\tif (line.error !== undefined) {\n\t\t\t\tthrow new Error(`Armada event stream failed: ${line.error.message ?? 'unknown error'}`);\n\t\t\t}\n\n\t\t\tconst message: EventMessage | undefined = line.result?.message;\n\t\t\tif (message === undefined) continue;\n\n\t\t\tconst running: JobRunningEvent | undefined = message.running;\n\t\t\tif (running !== undefined && running.jobId === job.jobId) {\n\t\t\t\treturn {\n\t\t\t\t\tclusterId: running.clusterId ?? '',\n\t\t\t\t\tpodName: running.podName ?? '',\n\t\t\t\t\tpodNamespace: running.podNamespace ?? this.config.namespace,\n\t\t\t\t\t...(running.nodeName === undefined ? {} : { nodeName: running.nodeName }),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst failed: JobFailedEvent | undefined = message.failed;\n\t\t\tif (failed !== undefined && failed.jobId === job.jobId && failed.retryable !== true) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} failed: ${failed.reason ?? 'no reason given'}`);\n\t\t\t}\n\n\t\t\tif (message.cancelled !== undefined && message.cancelled.jobId === job.jobId) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} was cancelled before it started`);\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Armada event stream ended before job ${job.jobId} started`);\n\t}\n\n\t/**\n\t * The address Armada assigned for a container port, from\n\t * `JobIngressInfoEvent`: `hostIP:nodePort` for a NodePort service, the rule\n\t * host for an Ingress. The stream replays existing messages before watching,\n\t * so an address reported before this call resolves without waiting.\n\t *\n\t * The event carries every exposed port at once, so an event for our job that\n\t * lacks the asked-for port is a configuration error, not something to wait\n\t * out.\n\t */\n\tasync ingressAddress(\n\t\tjob: SubmittedJob,\n\t\tport: number,\n\t\ttimeoutMs: number = DEFAULT_INGRESS_TIMEOUT_MS,\n\t): Promise<string> {\n\t\tconst request: JobSetRequest = {\n\t\t\tqueue: job.queue,\n\t\t\tid: job.jobSetId,\n\t\t\twatch: true,\n\t\t\terrorIfMissing: false,\n\t\t};\n\t\tconst path: string = `/v1/job-set/${encodeURIComponent(job.queue)}/${encodeURIComponent(job.jobSetId)}`;\n\t\tconst response: Response = await this.post(path, request, AbortSignal.timeout(timeoutMs));\n\t\tif (response.body === null) throw new Error(`Armada returned no event stream for ${path}`);\n\n\t\tfor await (const value of readNdjson(response.body)) {\n\t\t\tconst line: EventStreamLine = asObject(value, 'an event stream line');\n\t\t\tif (line.error !== undefined) {\n\t\t\t\tthrow new Error(`Armada event stream failed: ${line.error.message ?? 'unknown error'}`);\n\t\t\t}\n\n\t\t\tconst message: EventMessage | undefined = line.result?.message;\n\t\t\tif (message === undefined) continue;\n\n\t\t\tconst info: JobIngressInfoEvent | undefined = message.ingressInfo;\n\t\t\tif (info !== undefined && info.jobId === job.jobId) {\n\t\t\t\tconst address: string | undefined = info.ingressAddresses?.[String(port)];\n\t\t\t\tif (address !== undefined && address !== '') return address;\n\t\t\t\tconst known: string = Object.keys(info.ingressAddresses ?? {}).join(', ');\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Armada reported no address for port ${String(port)} of job ${job.jobId}; it exposes: ${known === '' ? 'nothing' : known}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst failed: JobFailedEvent | undefined = message.failed;\n\t\t\tif (failed !== undefined && failed.jobId === job.jobId && failed.retryable !== true) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} failed: ${failed.reason ?? 'no reason given'}`);\n\t\t\t}\n\n\t\t\tif (message.cancelled !== undefined && message.cancelled.jobId === job.jobId) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} was cancelled`);\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`Armada event stream ended before job ${job.jobId} reported an ingress address`,\n\t\t);\n\t}\n\n\t/**\n\t * `ingressAddress` as a URL. The scheme is the submit's to choose, since the\n\t * submit is what decided whether the address is a NodePort on the cluster\n\t * network or an Ingress hostname with or without a certificate.\n\t */\n\tasync portUrl(job: SubmittedJob, port: number): Promise<string> {\n\t\tconst address: string = await this.ingressAddress(job, port);\n\t\tif (address.includes('://')) return address;\n\t\tconst expose: Exposure = this.config.expose;\n\t\tconst scheme: string = expose.kind === 'ingress' && expose.tls ? 'https' : 'http';\n\t\treturn `${scheme}://${address}`;\n\t}\n\n\tasync cancel(job: SubmittedJob): Promise<void> {\n\t\tconst request: JobCancelRequest = {\n\t\t\tqueue: job.queue,\n\t\t\tjobSetId: job.jobSetId,\n\t\t\tjobId: job.jobId,\n\t\t};\n\t\tawait this.post('/v1/job/cancel', request);\n\t}\n\n\t/**\n\t * Cancel every job in a set, for a sandbox this process never submitted.\n\t *\n\t * The reconciler addresses sandboxes by id alone, and a job set id is a\n\t * sandbox id, so no job lookup is needed: a cancel with no job id is\n\t * explicitly redirected to CancelJobSet by the server\n\t * (`internal/server/submit/submit.go:170`). Cancelling a set that no longer\n\t * exists (or never did) is a no-op, not an error.\n\t */\n\tasync cancelSet(jobSetId: string, queue: string): Promise<void> {\n\t\tconst request: JobCancelRequest = { queue, jobSetId };\n\t\tawait this.post('/v1/job/cancel', request);\n\t}\n\n\t/**\n\t * The sandbox's job, if it has one that has not finished, found without\n\t * submitting anything: by the `externalJobUri` the submit set to the sandbox\n\t * id, the one lookup the server keys by something we choose\n\t * (`GetJobStatusUsingExternalJobUri`). `undefined` when the queue holds no\n\t * such job, or only finished ones, which is how attaching tells a sandbox\n\t * that is gone from one that is there.\n\t *\n\t * The server answers from the database Lookout's ingester fills, so a job\n\t * submitted a moment ago may not be there yet. That suits its one caller,\n\t * attaching to a sandbox marimohub started long before.\n\t */\n\tasync findJob(sandboxId: SandboxId, queue: string): Promise<SubmittedJob | undefined> {\n\t\tconst request: JobStatusUsingExternalJobUriRequest = {\n\t\t\tqueue,\n\t\t\tjobset: sandboxId,\n\t\t\texternalJobUri: sandboxId,\n\t\t};\n\t\tconst response: JobStatusResponse = await this.postJson(\n\t\t\t'/v1/job/statusUsingExternalJobUri',\n\t\t\trequest,\n\t\t);\n\t\t// The set holds one job, as `clientId` dedupes the submit. Should it ever\n\t\t// hold more, job ids are ULIDs, so the greatest is the newest.\n\t\tconst live: string[] = Object.entries(response.jobStates ?? {})\n\t\t\t.filter(([, state]: [string, number]) => !FINISHED_JOB_STATES.has(state))\n\t\t\t.map(([jobId]: [string, number]) => jobId)\n\t\t\t.toSorted();\n\t\tconst jobId: string | undefined = live.at(-1);\n\t\treturn jobId === undefined ? undefined : { jobId, jobSetId: sandboxId, queue };\n\t}\n\n\t/**\n\t * Which queue holds a sandbox's job, asked of Lookout by job set, for a\n\t * sandbox this process never submitted and has not enumerated\n\t * (`src/queues.ts`). `undefined` when no live or finished job carries the set\n\t * and the mark, or when Lookout is not configured; rejects when Lookout\n\t * cannot be asked, which the directory turns into a `QueueUnknownError`.\n\t */\n\tasync findQueue(jobSetId: SandboxId): Promise<string | undefined> {\n\t\tconst lookout: string | undefined = this.config.lookoutUrl;\n\t\tif (lookout === undefined) return undefined;\n\t\tconst jobs: LookoutJob[] = await this.lookoutJobs(\n\t\t\tlookout,\n\t\t\t[{ field: 'jobSet', value: jobSetId, match: 'exact' }],\n\t\t\t{ field: 'submitted', direction: 'DESC' },\n\t\t\t0,\n\t\t\t1,\n\t\t);\n\t\tconst queue: string | undefined = jobs[0]?.queue;\n\t\treturn queue === undefined || queue === '' ? undefined : queue;\n\t}\n\n\t/**\n\t * One page of Lookout's job list, always scoped by the {@link SANDBOX_MARK}\n\t * annotation carrying this installation's name: the reconciler destroys\n\t * what `listActive` returns, and Lookout sees every queue of every tenant,\n\t * so an unmarked answer would cancel strangers' work on the next sweep.\n\t */\n\tprivate async lookoutJobs(\n\t\tlookout: string,\n\t\tfilters: LookoutFilter[],\n\t\torder: LookoutGetJobsRequest['order'],\n\t\tskip: number,\n\t\ttake: number,\n\t): Promise<LookoutJob[]> {\n\t\tconst request: LookoutGetJobsRequest = {\n\t\t\tfilters: [\n\t\t\t\t...filters,\n\t\t\t\t{ field: SANDBOX_MARK, value: this.config.queue, match: 'exact', isAnnotation: true },\n\t\t\t],\n\t\t\torder,\n\t\t\tskip,\n\t\t\ttake,\n\t\t};\n\t\tconst response: object = await this.postJsonTo(lookout, '/api/v1/jobs', request);\n\t\treturn (response as LookoutGetJobsResponse).jobs ?? [];\n\t}\n\n\t/**\n\t * Every sandbox with a live job, for marimohub's reconciler.\n\t *\n\t * Asked of Lookout, not the Armada server, because the server has no \"list\n\t * the jobs I own\" call at all. Lookout is the component that\n\t * aggregates jobs across every executor cluster, so this needs no cluster\n\t * inventory, and it sees jobs still QUEUED, which have no pod anywhere yet.\n\t * The answer is scoped by the mark alone, not by queue: a job is this\n\t * installation's wherever the owner map of the day put it, or a map since\n\t * retired. Each job comes back with its queue, so a sandbox found here can\n\t * be cancelled without another lookup; a job Lookout reports without one is\n\t * skipped rather than guessed at.\n\t */\n\tasync listActive(): Promise<ActiveJob[]> {\n\t\tconst lookout: string | undefined = this.config.lookoutUrl;\n\t\tif (lookout === undefined) {\n\t\t\tthrow new Error('listActive needs ARMADA_LOOKOUT_URL, which is not configured');\n\t\t}\n\n\t\t// Keyed by job set so a set holding several jobs (ours hold one) appears\n\t\t// once. Insertion order is submission order, per `order` below.\n\t\tconst sandboxes: Map<string, ActiveJob> = new Map();\n\t\tfor (let skip = 0; ; skip += LIST_ACTIVE_PAGE) {\n\t\t\t// oxlint-disable-next-line no-await-in-loop -- each page's fullness decides whether another exists\n\t\t\tconst jobs: LookoutJob[] = await this.lookoutJobs(\n\t\t\t\tlookout,\n\t\t\t\t[{ field: 'state', value: ACTIVE_JOB_STATES, match: 'anyOf' }],\n\t\t\t\t{ field: 'submitted', direction: 'ASC' },\n\t\t\t\tskip,\n\t\t\t\tLIST_ACTIVE_PAGE,\n\t\t\t);\n\t\t\tfor (const job of jobs) {\n\t\t\t\tif (job.jobSet === undefined || job.jobSet === '') continue;\n\t\t\t\tif (job.queue === undefined || job.queue === '') continue;\n\t\t\t\tsandboxes.set(job.jobSet, {\n\t\t\t\t\tid: job.jobSet,\n\t\t\t\t\tqueue: job.queue,\n\t\t\t\t\t...(job.submitted === undefined ? {} : { createdAt: job.submitted }),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (jobs.length < LIST_ACTIVE_PAGE) return [...sandboxes.values()];\n\t\t}\n\t}\n\n\tprivate async post(path: string, body: unknown, signal?: AbortSignal): Promise<Response> {\n\t\treturn this.postTo(this.config.url, path, body, signal);\n\t}\n\n\tprivate async postTo(\n\t\tbase: string,\n\t\tpath: string,\n\t\tbody: unknown,\n\t\tsignal?: AbortSignal,\n\t): Promise<Response> {\n\t\tconst response: Response = await fetch(`${base.replace(/\\/$/, '')}${path}`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: await this.requestHeaders(),\n\t\t\tbody: JSON.stringify(body),\n\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// The gateway puts the useful part in the body, not the status text.\n\t\t\tconst detail: string = (await response.text()).trim();\n\t\t\tthrow new Error(\n\t\t\t\t`Armada ${path} failed (${response.status}): ${detail === '' ? response.statusText : detail}`,\n\t\t\t);\n\t\t}\n\t\treturn response;\n\t}\n\n\tprivate async postJson(path: string, body: unknown): Promise<object> {\n\t\tconst response: Response = await this.post(path, body);\n\t\treturn asObject(await response.json(), `a response to ${path}`);\n\t}\n\n\tprivate async postJsonTo(base: string, path: string, body: unknown): Promise<object> {\n\t\tconst response: Response = await this.postTo(base, path, body);\n\t\treturn asObject(await response.json(), `a response to ${path}`);\n\t}\n}\n",
10
+ "/**\n * Placement half of the adapter: submit a job, follow its event stream, and\n * resolve where it landed.\n *\n * There is no official JS/TS Armada client (Go, Java, Scala, Python and .NET\n * only), so this talks to the grpc-gateway REST endpoints. The protos carry\n * `google.api.http` annotations, so every RPC has an HTTP form.\n */\nimport type { V1PodSpec } from '@kubernetes/client-node';\nimport type {\n\tLookoutFilter,\n\tEventMessage,\n\tEventStreamLine,\n\tJobFailedEvent,\n\tJobIngressInfoEvent,\n\tJobRunningEvent,\n\tJobCancelRequest,\n\tJobSetRequest,\n\tJobSubmitRequest,\n\tJobSubmitRequestItem,\n\tJobStatusResponse,\n\tJobStatusUsingExternalJobUriRequest,\n\tJobSubmitResponse,\n\tJobSubmitResponseItem,\n\tLookoutGetJobsRequest,\n\tLookoutGetJobsResponse,\n\tLookoutJob,\n} from './armada-types.js';\nimport { JOB_STATE } from './armada-types.js';\nimport { authorizationHeader } from './auth.js';\nimport type { ArmadaConfig, Exposure } from './config.js';\nimport { readNdjson } from './ndjson.js';\nimport { exposedPorts } from './podspec.js';\nimport type { ActiveSandbox, SandboxId } from './types.js';\n\n/** Where a running job's pod lives, from `JobRunningEvent`. */\nexport interface PodLocation {\n\tclusterId: string;\n\tpodName: string;\n\tpodNamespace: string;\n\tnodeName?: string;\n}\n\nexport interface SubmittedJob {\n\tjobId: string;\n\tjobSetId: string;\n\t/** Every later call about the job is addressed by queue and job set. */\n\tqueue: string;\n}\n\n/** A live job as Lookout reports it: the sandbox, and the queue that holds it. */\nexport interface ActiveJob extends ActiveSandbox {\n\tqueue: string;\n}\n\n/**\n * Every Armada response type we read has only optional fields, so a JSON object\n * is structurally one of them. Checking that much and no more keeps the parse\n * honest without a schema validator: a field we read but the server stopped\n * sending is caught by `bun run check:armada-api`, not at runtime.\n */\nfunction asObject(value: unknown, what: string): object {\n\tif (typeof value !== 'object' || value === null) {\n\t\tthrow new Error(`Armada returned ${what} that is not a JSON object: ${JSON.stringify(value)}`);\n\t}\n\treturn value;\n}\n\n/** Long enough for an image pull on a cold node, short enough to fail a wedged queue. */\nconst DEFAULT_RUNNING_TIMEOUT_MS = 5 * 60 * 1000;\n\n/** The ingress event lands around Running, so by expose time it usually replays. */\nconst DEFAULT_INGRESS_TIMEOUT_MS = 60 * 1000;\n\n/**\n * The finished-job check is a shortcut ahead of the wait for Running, so a\n * status read that stalls must give up soon and let that wait go on.\n */\nconst DEFAULT_STATUS_TIMEOUT_MS = 5 * 1000;\n\n/**\n * Annotation marking a job as this installation's, set at submit and filtered\n * on by `listActive` and `findQueue`. Its value is the default queue name\n * (`ARMADA_QUEUE`), which names one marimohub installation however many queues\n * its owner map spreads jobs over, so enumeration does not depend on the map\n * of the day and two installations sharing an Armada never see each other's\n * sandboxes. Job annotations land on the pod too, so the mark is visible from\n * Lookout and from Kubernetes alike.\n */\nexport const SANDBOX_MARK = 'marimohub/sandbox';\n\n/** Lookout job states meaning \"this sandbox is alive or on its way\". */\nconst ACTIVE_JOB_STATES: string[] = ['QUEUED', 'LEASED', 'PENDING', 'RUNNING'];\n\n/**\n * Job states after which no pod runs and none will. `UNKNOWN` is not among\n * them: the server knows the job but not its state, and attaching to it finds\n * out the same way it does for a live one.\n */\nconst FINISHED_JOB_STATES: ReadonlySet<number> = new Set([\n\tJOB_STATE.SUCCEEDED,\n\tJOB_STATE.FAILED,\n\tJOB_STATE.PREEMPTED,\n\tJOB_STATE.CANCELLED,\n\tJOB_STATE.REJECTED,\n]);\n\n/** Lookout page size; more active kernels than this loops rather than truncates. */\nconst LIST_ACTIVE_PAGE = 500;\n\nexport class ArmadaClient {\n\tconstructor(private readonly config: ArmadaConfig) {}\n\n\t/**\n\t * Headers for every call to the gateway.\n\t *\n\t * Authorization is resolved per request rather than at construction, so a\n\t * token file that is rotated under us is picked up without a restart.\n\t */\n\tasync requestHeaders(): Promise<Record<string, string>> {\n\t\tconst authorization: string | undefined = await authorizationHeader(this.config.auth);\n\t\treturn {\n\t\t\t'content-type': 'application/json',\n\t\t\t...(authorization === undefined ? {} : { authorization }),\n\t\t};\n\t}\n\n\t/**\n\t * Submit one job for a sandbox.\n\t *\n\t * The sandbox id is used three times over, each for a different reason:\n\t * `clientId` so a resubmit dedupes instead of starting a second kernel,\n\t * `jobSetId` so this sandbox's events are their own stream, and\n\t * `externalJobUri` because it is the only way to find the job again later.\n\t *\n\t * The queue is the caller's choice (`src/queues.ts`) and travels with the\n\t * returned job, since every later call is addressed by it.\n\t */\n\tasync submit(sandboxId: SandboxId, podSpec: V1PodSpec, queue: string): Promise<SubmittedJob> {\n\t\tconst ports: number[] = exposedPorts(podSpec);\n\t\tconst expose: Exposure = this.config.expose;\n\t\t// Either way the executor reports one address per port in the same event.\n\t\t// An Ingress needs a service behind it, and Armada creates that itself: a\n\t\t// ClusterIP one, since a headless service (Armada's default) leaves the\n\t\t// ingress controller to resolve pod IPs on its own.\n\t\tconst exposure: Pick<JobSubmitRequestItem, 'ingress' | 'services'> =\n\t\t\texpose.kind === 'ingress'\n\t\t\t\t? {\n\t\t\t\t\t\tingress: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tports,\n\t\t\t\t\t\t\t\ttlsEnabled: expose.tls,\n\t\t\t\t\t\t\t\t...(expose.certName === undefined ? {} : { certName: expose.certName }),\n\t\t\t\t\t\t\t\tuseClusterIP: true,\n\t\t\t\t\t\t\t\t...(Object.keys(expose.annotations).length === 0\n\t\t\t\t\t\t\t\t\t? {}\n\t\t\t\t\t\t\t\t\t: { annotations: expose.annotations }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t}\n\t\t\t\t: { services: [{ type: 'NodePort', ports }] };\n\t\tconst request: JobSubmitRequest = {\n\t\t\tqueue,\n\t\t\tjobSetId: sandboxId,\n\t\t\tjobRequestItems: [\n\t\t\t\t{\n\t\t\t\t\tclientId: sandboxId,\n\t\t\t\t\texternalJobUri: sandboxId,\n\t\t\t\t\tnamespace: this.config.namespace,\n\t\t\t\t\tpodSpec,\n\t\t\t\t\t...(Object.keys(this.config.podLabels).length === 0\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { labels: this.config.podLabels }),\n\t\t\t\t\t// A retry would hand the user an empty kernel wearing their session's\n\t\t\t\t\t// name, so fail terminally and let marimohub offer the retry. The\n\t\t\t\t\t// sandbox mark is what `listActive` filters on: a queue may hold jobs\n\t\t\t\t\t// that are not marimohub's, and enumeration feeds a reconciler that\n\t\t\t\t\t// destroys what it does not recognise, so only marked jobs may appear.\n\t\t\t\t\t// The operator's annotations go first: `readConfig` refuses our keys,\n\t\t\t\t\t// and ours win regardless.\n\t\t\t\t\tannotations: {\n\t\t\t\t\t\t...this.config.podAnnotations,\n\t\t\t\t\t\t'armadaproject.io/failFast': 'true',\n\t\t\t\t\t\t[SANDBOX_MARK]: this.config.queue,\n\t\t\t\t\t},\n\t\t\t\t\t...exposure,\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\n\t\tconst response: JobSubmitResponse = await this.postJson('/v1/job/submit', request);\n\t\tconst item: JobSubmitResponseItem | undefined = response.jobResponseItems?.[0];\n\t\tif (item?.error !== undefined && item.error !== '') {\n\t\t\tthrow new Error(`Armada rejected the job for sandbox ${sandboxId}: ${item.error}`);\n\t\t}\n\t\tif (item?.jobId === undefined || item.jobId === '') {\n\t\t\tthrow new Error(`Armada returned no job id for sandbox ${sandboxId}`);\n\t\t}\n\t\treturn { jobId: item.jobId, jobSetId: sandboxId, queue };\n\t}\n\n\t/**\n\t * Block until the job reaches Running, returning where its pod landed.\n\t *\n\t * Terminal failures arrive on the same stream, so we react to them rather than\n\t * waiting out the timeout with no explanation. A failure marked `retryable` is\n\t * the scheduler saying another run follows, so it is not the end.\n\t */\n\tasync waitForRunning(\n\t\tjob: SubmittedJob,\n\t\ttimeoutMs: number = DEFAULT_RUNNING_TIMEOUT_MS,\n\t): Promise<PodLocation> {\n\t\tconst request: JobSetRequest = {\n\t\t\tqueue: job.queue,\n\t\t\tid: job.jobSetId,\n\t\t\twatch: true,\n\t\t\terrorIfMissing: false,\n\t\t};\n\t\tconst path: string = `/v1/job-set/${encodeURIComponent(job.queue)}/${encodeURIComponent(job.jobSetId)}`;\n\t\tconst response: Response = await this.post(path, request, AbortSignal.timeout(timeoutMs));\n\t\tif (response.body === null) throw new Error(`Armada returned no event stream for ${path}`);\n\n\t\tfor await (const value of readNdjson(response.body)) {\n\t\t\tconst line: EventStreamLine = asObject(value, 'an event stream line');\n\t\t\tif (line.error !== undefined) {\n\t\t\t\tthrow new Error(`Armada event stream failed: ${line.error.message ?? 'unknown error'}`);\n\t\t\t}\n\n\t\t\tconst message: EventMessage | undefined = line.result?.message;\n\t\t\tif (message === undefined) continue;\n\n\t\t\tconst running: JobRunningEvent | undefined = message.running;\n\t\t\tif (running !== undefined && running.jobId === job.jobId) {\n\t\t\t\treturn {\n\t\t\t\t\tclusterId: running.clusterId ?? '',\n\t\t\t\t\tpodName: running.podName ?? '',\n\t\t\t\t\tpodNamespace: running.podNamespace ?? this.config.namespace,\n\t\t\t\t\t...(running.nodeName === undefined ? {} : { nodeName: running.nodeName }),\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tconst failed: JobFailedEvent | undefined = message.failed;\n\t\t\tif (failed !== undefined && failed.jobId === job.jobId && failed.retryable !== true) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} failed: ${failed.reason ?? 'no reason given'}`);\n\t\t\t}\n\n\t\t\tif (message.cancelled !== undefined && message.cancelled.jobId === job.jobId) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} was cancelled before it started`);\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(`Armada event stream ended before job ${job.jobId} started`);\n\t}\n\n\t/**\n\t * The address Armada assigned for a container port, from\n\t * `JobIngressInfoEvent`: `hostIP:nodePort` for a NodePort service, the rule\n\t * host for an Ingress. The stream replays existing messages before watching,\n\t * so an address reported before this call resolves without waiting.\n\t *\n\t * The event carries every exposed port at once, so an event for our job that\n\t * lacks the asked-for port is a configuration error, not something to wait\n\t * out.\n\t */\n\tasync ingressAddress(\n\t\tjob: SubmittedJob,\n\t\tport: number,\n\t\ttimeoutMs: number = DEFAULT_INGRESS_TIMEOUT_MS,\n\t): Promise<string> {\n\t\tconst request: JobSetRequest = {\n\t\t\tqueue: job.queue,\n\t\t\tid: job.jobSetId,\n\t\t\twatch: true,\n\t\t\terrorIfMissing: false,\n\t\t};\n\t\tconst path: string = `/v1/job-set/${encodeURIComponent(job.queue)}/${encodeURIComponent(job.jobSetId)}`;\n\t\tconst response: Response = await this.post(path, request, AbortSignal.timeout(timeoutMs));\n\t\tif (response.body === null) throw new Error(`Armada returned no event stream for ${path}`);\n\n\t\tfor await (const value of readNdjson(response.body)) {\n\t\t\tconst line: EventStreamLine = asObject(value, 'an event stream line');\n\t\t\tif (line.error !== undefined) {\n\t\t\t\tthrow new Error(`Armada event stream failed: ${line.error.message ?? 'unknown error'}`);\n\t\t\t}\n\n\t\t\tconst message: EventMessage | undefined = line.result?.message;\n\t\t\tif (message === undefined) continue;\n\n\t\t\tconst info: JobIngressInfoEvent | undefined = message.ingressInfo;\n\t\t\tif (info !== undefined && info.jobId === job.jobId) {\n\t\t\t\tconst address: string | undefined = info.ingressAddresses?.[String(port)];\n\t\t\t\tif (address !== undefined && address !== '') return address;\n\t\t\t\tconst known: string = Object.keys(info.ingressAddresses ?? {}).join(', ');\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Armada reported no address for port ${String(port)} of job ${job.jobId}; it exposes: ${known === '' ? 'nothing' : known}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst failed: JobFailedEvent | undefined = message.failed;\n\t\t\tif (failed !== undefined && failed.jobId === job.jobId && failed.retryable !== true) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} failed: ${failed.reason ?? 'no reason given'}`);\n\t\t\t}\n\n\t\t\tif (message.cancelled !== undefined && message.cancelled.jobId === job.jobId) {\n\t\t\t\tthrow new Error(`Armada job ${job.jobId} was cancelled`);\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error(\n\t\t\t`Armada event stream ended before job ${job.jobId} reported an ingress address`,\n\t\t);\n\t}\n\n\t/**\n\t * `ingressAddress` as a URL. The scheme is the submit's to choose, since the\n\t * submit is what decided whether the address is a NodePort on the cluster\n\t * network or an Ingress hostname with or without a certificate.\n\t */\n\tasync portUrl(job: SubmittedJob, port: number): Promise<string> {\n\t\tconst address: string = await this.ingressAddress(job, port);\n\t\tif (address.includes('://')) return address;\n\t\tconst expose: Exposure = this.config.expose;\n\t\tconst scheme: string = expose.kind === 'ingress' && expose.tls ? 'https' : 'http';\n\t\treturn `${scheme}://${address}`;\n\t}\n\n\tasync cancel(job: SubmittedJob): Promise<void> {\n\t\tconst request: JobCancelRequest = {\n\t\t\tqueue: job.queue,\n\t\t\tjobSetId: job.jobSetId,\n\t\t\tjobId: job.jobId,\n\t\t};\n\t\tawait this.post('/v1/job/cancel', request);\n\t}\n\n\t/**\n\t * Cancel every job in a set, for a sandbox this process never submitted.\n\t *\n\t * The reconciler addresses sandboxes by id alone, and a job set id is a\n\t * sandbox id, so no job lookup is needed: a cancel with no job id is\n\t * explicitly redirected to CancelJobSet by the server\n\t * (`internal/server/submit/submit.go:170`). Cancelling a set that no longer\n\t * exists (or never did) is a no-op, not an error.\n\t */\n\tasync cancelSet(jobSetId: string, queue: string): Promise<void> {\n\t\tconst request: JobCancelRequest = { queue, jobSetId };\n\t\tawait this.post('/v1/job/cancel', request);\n\t}\n\n\t/**\n\t * The sandbox's job, if it has one that has not finished, found without\n\t * submitting anything: by the `externalJobUri` the submit set to the sandbox\n\t * id, the one lookup the server keys by something we choose\n\t * (`GetJobStatusUsingExternalJobUri`). `undefined` when the queue holds no\n\t * such job, or only finished ones, which is how attaching tells a sandbox\n\t * that is gone from one that is there.\n\t *\n\t * The server answers from the database Lookout's ingester fills, so a job\n\t * submitted a moment ago may not be there yet. That suits its one caller,\n\t * attaching to a sandbox marimohub started long before.\n\t */\n\tasync findJob(sandboxId: SandboxId, queue: string): Promise<SubmittedJob | undefined> {\n\t\t// The set holds one job, as `clientId` dedupes the submit. Should it ever\n\t\t// hold more, job ids are ULIDs, so the greatest is the newest.\n\t\tconst live: string[] = Object.entries(await this.jobStates(sandboxId, queue))\n\t\t\t.filter(([, state]: [string, number]) => !FINISHED_JOB_STATES.has(state))\n\t\t\t.map(([jobId]: [string, number]) => jobId)\n\t\t\t.toSorted();\n\t\tconst jobId: string | undefined = live.at(-1);\n\t\treturn jobId === undefined ? undefined : { jobId, jobSetId: sandboxId, queue };\n\t}\n\n\t/**\n\t * Whether the server says this job has finished, so that no pod runs for it\n\t * and none ever will. A submit for a sandbox whose job has finished is\n\t * deduped on `clientId` to that same job, and its event stream replays the\n\t * old `Running` before the end, so this is what keeps a waiter from going on\n\t * to an agent that is long gone.\n\t *\n\t * A job the server does not list yet is not finished: like {@link findJob},\n\t * this reads what Lookout's ingester has written, which lags a fresh submit.\n\t * Rejects when the server has not answered within `timeoutMs`.\n\t */\n\tasync isFinished(\n\t\tjob: SubmittedJob,\n\t\ttimeoutMs: number = DEFAULT_STATUS_TIMEOUT_MS,\n\t): Promise<boolean> {\n\t\tconst states: Record<string, number> = await this.jobStates(\n\t\t\tjob.jobSetId,\n\t\t\tjob.queue,\n\t\t\tAbortSignal.timeout(timeoutMs),\n\t\t);\n\t\tconst state: number | undefined = states[job.jobId];\n\t\treturn state !== undefined && FINISHED_JOB_STATES.has(state);\n\t}\n\n\t/** Every job of a sandbox's job set with its state, by the `externalJobUri` the submit set. */\n\tprivate async jobStates(\n\t\tsandboxId: SandboxId,\n\t\tqueue: string,\n\t\tsignal?: AbortSignal,\n\t): Promise<Record<string, number>> {\n\t\tconst request: JobStatusUsingExternalJobUriRequest = {\n\t\t\tqueue,\n\t\t\tjobset: sandboxId,\n\t\t\texternalJobUri: sandboxId,\n\t\t};\n\t\tconst response: JobStatusResponse = await this.postJson(\n\t\t\t'/v1/job/statusUsingExternalJobUri',\n\t\t\trequest,\n\t\t\tsignal,\n\t\t);\n\t\treturn response.jobStates ?? {};\n\t}\n\n\t/**\n\t * Which queue holds a sandbox's job, asked of Lookout by job set, for a\n\t * sandbox this process never submitted and has not enumerated\n\t * (`src/queues.ts`). `undefined` when no live or finished job carries the set\n\t * and the mark, or when Lookout is not configured; rejects when Lookout\n\t * cannot be asked, which the directory turns into a `QueueUnknownError`.\n\t */\n\tasync findQueue(jobSetId: SandboxId): Promise<string | undefined> {\n\t\tconst lookout: string | undefined = this.config.lookoutUrl;\n\t\tif (lookout === undefined) return undefined;\n\t\tconst jobs: LookoutJob[] = await this.lookoutJobs(\n\t\t\tlookout,\n\t\t\t[{ field: 'jobSet', value: jobSetId, match: 'exact' }],\n\t\t\t{ field: 'submitted', direction: 'DESC' },\n\t\t\t0,\n\t\t\t1,\n\t\t);\n\t\tconst queue: string | undefined = jobs[0]?.queue;\n\t\treturn queue === undefined || queue === '' ? undefined : queue;\n\t}\n\n\t/**\n\t * One page of Lookout's job list, always scoped by the {@link SANDBOX_MARK}\n\t * annotation carrying this installation's name: the reconciler destroys\n\t * what `listActive` returns, and Lookout sees every queue of every tenant,\n\t * so an unmarked answer would cancel strangers' work on the next sweep.\n\t */\n\tprivate async lookoutJobs(\n\t\tlookout: string,\n\t\tfilters: LookoutFilter[],\n\t\torder: LookoutGetJobsRequest['order'],\n\t\tskip: number,\n\t\ttake: number,\n\t): Promise<LookoutJob[]> {\n\t\tconst request: LookoutGetJobsRequest = {\n\t\t\tfilters: [\n\t\t\t\t...filters,\n\t\t\t\t{ field: SANDBOX_MARK, value: this.config.queue, match: 'exact', isAnnotation: true },\n\t\t\t],\n\t\t\torder,\n\t\t\tskip,\n\t\t\ttake,\n\t\t};\n\t\tconst response: object = await this.postJsonTo(lookout, '/api/v1/jobs', request);\n\t\treturn (response as LookoutGetJobsResponse).jobs ?? [];\n\t}\n\n\t/**\n\t * Every sandbox with a live job, for marimohub's reconciler.\n\t *\n\t * Asked of Lookout, not the Armada server, because the server has no \"list\n\t * the jobs I own\" call at all. Lookout is the component that\n\t * aggregates jobs across every executor cluster, so this needs no cluster\n\t * inventory, and it sees jobs still QUEUED, which have no pod anywhere yet.\n\t * The answer is scoped by the mark alone, not by queue: a job is this\n\t * installation's wherever the owner map of the day put it, or a map since\n\t * retired. Each job comes back with its queue, so a sandbox found here can\n\t * be cancelled without another lookup; a job Lookout reports without one is\n\t * skipped rather than guessed at.\n\t */\n\tasync listActive(): Promise<ActiveJob[]> {\n\t\tconst lookout: string | undefined = this.config.lookoutUrl;\n\t\tif (lookout === undefined) {\n\t\t\tthrow new Error('listActive needs ARMADA_LOOKOUT_URL, which is not configured');\n\t\t}\n\n\t\t// Keyed by job set so a set holding several jobs (ours hold one) appears\n\t\t// once. Insertion order is submission order, per `order` below.\n\t\tconst sandboxes: Map<string, ActiveJob> = new Map();\n\t\tfor (let skip = 0; ; skip += LIST_ACTIVE_PAGE) {\n\t\t\t// oxlint-disable-next-line no-await-in-loop -- each page's fullness decides whether another exists\n\t\t\tconst jobs: LookoutJob[] = await this.lookoutJobs(\n\t\t\t\tlookout,\n\t\t\t\t[{ field: 'state', value: ACTIVE_JOB_STATES, match: 'anyOf' }],\n\t\t\t\t{ field: 'submitted', direction: 'ASC' },\n\t\t\t\tskip,\n\t\t\t\tLIST_ACTIVE_PAGE,\n\t\t\t);\n\t\t\tfor (const job of jobs) {\n\t\t\t\tif (job.jobSet === undefined || job.jobSet === '') continue;\n\t\t\t\tif (job.queue === undefined || job.queue === '') continue;\n\t\t\t\tsandboxes.set(job.jobSet, {\n\t\t\t\t\tid: job.jobSet,\n\t\t\t\t\tqueue: job.queue,\n\t\t\t\t\t...(job.submitted === undefined ? {} : { createdAt: job.submitted }),\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (jobs.length < LIST_ACTIVE_PAGE) return [...sandboxes.values()];\n\t\t}\n\t}\n\n\tprivate async post(path: string, body: unknown, signal?: AbortSignal): Promise<Response> {\n\t\treturn this.postTo(this.config.url, path, body, signal);\n\t}\n\n\tprivate async postTo(\n\t\tbase: string,\n\t\tpath: string,\n\t\tbody: unknown,\n\t\tsignal?: AbortSignal,\n\t): Promise<Response> {\n\t\tconst response: Response = await fetch(`${base.replace(/\\/$/, '')}${path}`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: await this.requestHeaders(),\n\t\t\tbody: JSON.stringify(body),\n\t\t\t...(signal === undefined ? {} : { signal }),\n\t\t});\n\n\t\tif (!response.ok) {\n\t\t\t// The gateway puts the useful part in the body, not the status text.\n\t\t\tconst detail: string = (await response.text()).trim();\n\t\t\tthrow new Error(\n\t\t\t\t`Armada ${path} failed (${response.status}): ${detail === '' ? response.statusText : detail}`,\n\t\t\t);\n\t\t}\n\t\treturn response;\n\t}\n\n\tprivate async postJson(path: string, body: unknown, signal?: AbortSignal): Promise<object> {\n\t\tconst response: Response = await this.post(path, body, signal);\n\t\treturn asObject(await response.json(), `a response to ${path}`);\n\t}\n\n\tprivate async postJsonTo(base: string, path: string, body: unknown): Promise<object> {\n\t\tconst response: Response = await this.postTo(base, path, body);\n\t\treturn asObject(await response.json(), `a response to ${path}`);\n\t}\n}\n",
11
11
  "/**\n * Control channel: the agent inside the kernel container.\n *\n * Armada exposes no exec, so the container runs a small agent as PID 1\n * (`agent/`) that listens on a second port next\n * to marimo's. The job asks Armada to expose both ports and the address event\n * reports both, so this is the one place the adapter reaches into a pod, and it\n * does so with an address Armada handed it and a token minted for that one pod.\n * No Kubernetes credential is involved.\n *\n * `POST /exec` runs a shell command and streams its output as NDJSON:\n * `{\"pid\"}`, then `{\"stdout\"}` and `{\"stderr\"}` chunks as base64, then\n * `{\"exit\",\"timedOut\"}`. Closing the request kills the command's process group\n * in the pod, which is what makes a cancel or a timeout mean something.\n *\n * The rest of the surface answers what a shell answered badly. `/process/*`\n * starts a detached process as the agent's own child, so liveness and the exit\n * status are exact, and waits for its port in-pod. `/files` carries bytes raw\n * in request and response bodies, so no path is quoted for a shell and no\n * content is wrapped in base64. `/files/bounded` is the read marimohub's\n * session capture asks for: the agent refuses symlinks, anything but a regular\n * file, and a file over a byte budget, and answers by a deadline.\n */\nimport type { PodLocation } from './armada.js';\nimport { readNdjson } from './ndjson.js';\n\nexport interface CommandResult {\n\tstdout: string;\n\tstderr: string;\n\texitCode: number;\n}\n\nexport interface RunOptions {\n\t/** Piped to the process when given. */\n\tstdin?: string | Uint8Array;\n\t/** Deadline the agent enforces by killing the process group; the call rejects. */\n\ttimeoutMs?: number;\n}\n\nexport interface StreamOptions {\n\t/** Ends the stream rather than failing it: it bounds a `tail -f`. */\n\ttimeoutMs?: number;\n}\n\n/** What the agent reports of a process it started. */\nexport interface ProcessStatus {\n\trunning: boolean;\n\t/** Set once it has exited; `-1` means it died to a signal. */\n\texitCode?: number;\n}\n\n/**\n * What \"open\" means to a port wait. `tcp` (the default) is a connection\n * accepted; `http` is any HTTP response to a GET of `path`, the readiness\n * meaning marimohub's surfaces ask for.\n */\nexport interface PortProbe {\n\tmode?: 'tcp' | 'http';\n\tpath?: string;\n}\n\n/** How an in-pod port wait ended. */\nexport interface PortWait {\n\topen: boolean;\n\t/** The watched process exited before the port opened. */\n\texited?: boolean;\n\texitCode?: number;\n}\n\nexport type AgentFileType = 'file' | 'directory' | 'symlink' | 'other';\n\n/** One entry of a directory listing, as the agent walked it. */\nexport interface AgentFileEntry {\n\tpath: string;\n\ttype: AgentFileType;\n\tsize: number;\n}\n\n/**\n * How a read ended. A channel that cannot be reached throws instead, so a\n * caller can tell \"the pod said no\" from \"the pod said nothing\".\n */\nexport type ReadFileOutcome =\n\t| { outcome: 'ok'; bytes: Uint8Array }\n\t| { outcome: 'not-found' }\n\t| { outcome: 'failed'; message: string };\n\n/**\n * What a bounded read may cost. Both are whole numbers: the sandbox validates\n * marimohub's budget and rounds the deadline up before it gets here.\n */\nexport interface ReadBudget {\n\tmaxBytes: number;\n\ttimeoutMs: number;\n}\n\n/** How a listing ended, on the same terms as {@link ReadFileOutcome}. */\nexport type ListFilesOutcome =\n\t| { outcome: 'ok'; entries: AgentFileEntry[] }\n\t| { outcome: 'not-a-directory' }\n\t| { outcome: 'failed'; message: string };\n\n/** Thrown by {@link AgentChannel.run} when the agent killed the command at its deadline. */\nexport class CommandTimeoutError extends Error {}\n\n/** What a sandbox needs of its pod: commands, detached processes, and files. */\nexport interface ControlChannel {\n\t/** Resolves once the pod answers, or rejects with the last reason it did not. */\n\tready(timeoutMs: number): Promise<void>;\n\trun(command: readonly string[], options?: RunOptions): Promise<CommandResult>;\n\tstream(command: readonly string[], options?: StreamOptions): Promise<ReadableStream<Uint8Array>>;\n\t/** Write bytes to a path, creating parent directories. */\n\twriteFile(path: string, content: string | Uint8Array): Promise<void>;\n\treadFile(path: string): Promise<ReadFileOutcome>;\n\t/** A regular file reached through no symlink, within the budget, or a failure. */\n\treadFileBounded(path: string, budget: ReadBudget): Promise<ReadFileOutcome>;\n\tlistFiles(path: string, recursive: boolean): Promise<ListFilesOutcome>;\n\t/** Start a detached process the agent parents, returning its pid. */\n\tstartProcess(command: readonly string[], cwd?: string): Promise<number>;\n\tprocessStatus(pid: number): Promise<ProcessStatus>;\n\t/** Best effort by contract: a process that is already gone is a success. */\n\tsignalProcess(pid: number, signal: string): Promise<void>;\n\t/** Everything the process printed, both streams in order. */\n\tprocessLogs(pid: number): Promise<string>;\n\t/** Wait in-pod until the port answers, `timeoutMs` passes, or `pid` exits. */\n\twaitForPort(port: number, timeoutMs: number, pid?: number, probe?: PortProbe): Promise<PortWait>;\n}\n\n/** Where one pod's agent is, and what it will accept. */\nexport interface AgentEndpoint {\n\t/**\n\t * Where the agent answers: the address Armada reported for its port, with the\n\t * scheme the exposure implies. `http://host:port` for a NodePort, `https://host`\n\t * for an Ingress with TLS.\n\t */\n\turl: string;\n\ttoken: string;\n\tpod: PodLocation;\n}\n\n/** One line of the agent's `/exec` response. */\ninterface AgentEvent {\n\tpid?: number;\n\tstdout?: string;\n\tstderr?: string;\n\texit?: number;\n\ttimedOut?: boolean;\n\terror?: string;\n}\n\nconst READY_POLL_MS = 250;\n/** Past the agent's own deadline, the client gives up on its own. */\nconst TIMEOUT_SLACK_MS = 10_000;\n/**\n * The same for a bounded read, kept short because the budget is the caller's:\n * long enough that the agent's own \"deadline passed\" arrives first and is what\n * gets reported, rather than an abort that says nothing.\n */\nconst BOUNDED_READ_SLACK_MS = 1_000;\n/** The longest delay a timer honours; past it Node fires almost at once. */\nconst MAX_TIMER_MS = 2 ** 31 - 1;\n\nfunction asEvent(value: unknown): AgentEvent {\n\tif (typeof value !== 'object' || value === null) {\n\t\tthrow new Error(`the agent sent something that is not an event: ${JSON.stringify(value)}`);\n\t}\n\t// Every field is optional, so any object is an event; each field is checked where it is read.\n\treturn value;\n}\n\nfunction describe(cause: unknown): string {\n\treturn cause instanceof Error ? cause.message : String(cause);\n}\n\n/** A refused request, as the agent's `{error, code}` body describes it. */\ninterface AgentRefusal {\n\tcode: string | undefined;\n\tmessage: string;\n}\n\nasync function refusalOf(response: Response): Promise<AgentRefusal> {\n\tconst text: string = await response.text();\n\tlet code: string | undefined;\n\tlet message: string = text.trim();\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(text);\n\t\tif (typeof parsed === 'object' && parsed !== null) {\n\t\t\tif ('error' in parsed && typeof parsed.error === 'string') message = parsed.error;\n\t\t\tif ('code' in parsed && typeof parsed.code === 'string') code = parsed.code;\n\t\t}\n\t} catch {\n\t\t// Not JSON; the text itself is the message.\n\t}\n\treturn { code, message: `HTTP ${String(response.status)}: ${message}` };\n}\n\nasync function sleep(ms: number): Promise<void> {\n\tawait new Promise((resolve: (value: void) => void) => setTimeout(resolve, ms));\n}\n\nfunction pidOf(value: unknown): number | undefined {\n\treturn typeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t'pid' in value &&\n\t\ttypeof value.pid === 'number'\n\t\t? value.pid\n\t\t: undefined;\n}\n\nfunction statusOf(value: unknown): ProcessStatus | undefined {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tvalue === null ||\n\t\t!('running' in value) ||\n\t\ttypeof value.running !== 'boolean'\n\t) {\n\t\treturn undefined;\n\t}\n\tconst exitCode: number | undefined =\n\t\t'exitCode' in value && typeof value.exitCode === 'number' ? value.exitCode : undefined;\n\treturn { running: value.running, ...(exitCode === undefined ? {} : { exitCode }) };\n}\n\nfunction portWaitOf(value: unknown): PortWait | undefined {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tvalue === null ||\n\t\t!('open' in value) ||\n\t\ttypeof value.open !== 'boolean'\n\t) {\n\t\treturn undefined;\n\t}\n\tconst exited: boolean = 'exited' in value && value.exited === true;\n\tconst exitCode: number | undefined =\n\t\t'exitCode' in value && typeof value.exitCode === 'number' ? value.exitCode : undefined;\n\treturn {\n\t\topen: value.open,\n\t\t...(exited ? { exited } : {}),\n\t\t...(exitCode === undefined ? {} : { exitCode }),\n\t};\n}\n\nfunction isFileType(value: string): value is AgentFileType {\n\treturn value === 'file' || value === 'directory' || value === 'symlink' || value === 'other';\n}\n\nfunction entryOf(value: unknown): AgentFileEntry | undefined {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\tif (!('path' in value) || typeof value.path !== 'string') return undefined;\n\tconst type: AgentFileType =\n\t\t'type' in value && typeof value.type === 'string' && isFileType(value.type)\n\t\t\t? value.type\n\t\t\t: 'other';\n\tconst size: number = 'size' in value && typeof value.size === 'number' ? value.size : 0;\n\treturn { path: value.path, type, size };\n}\n\nfunction entriesOf(value: unknown): AgentFileEntry[] | undefined {\n\tif (\n\t\ttypeof value !== 'object' ||\n\t\tvalue === null ||\n\t\t!('entries' in value) ||\n\t\t!Array.isArray(value.entries)\n\t) {\n\t\treturn undefined;\n\t}\n\tconst entries: AgentFileEntry[] = [];\n\tfor (const raw of value.entries as unknown[]) {\n\t\tconst entry: AgentFileEntry | undefined = entryOf(raw);\n\t\tif (entry === undefined) return undefined;\n\t\tentries.push(entry);\n\t}\n\treturn entries;\n}\n\nexport class AgentChannel implements ControlChannel {\n\tprivate readonly base: string;\n\tprivate readonly where: string;\n\n\tconstructor(private readonly endpoint: AgentEndpoint) {\n\t\tthis.base = endpoint.url;\n\t\tthis.where = `${endpoint.pod.podNamespace}/${endpoint.pod.podName}`;\n\t}\n\n\t/**\n\t * The agent is up the instant the pod runs; what takes a moment is the route\n\t * to it. A wrong agent image, or one built for the wrong architecture, shows\n\t * up here as a pod that runs but never answers.\n\t */\n\tasync ready(timeoutMs: number): Promise<void> {\n\t\tconst deadline: number = Date.now() + timeoutMs;\n\t\tlet last = 'no answer';\n\t\t// oxlint-disable no-await-in-loop -- a poll: each probe waits on the last\n\t\tfor (;;) {\n\t\t\ttry {\n\t\t\t\tconst response: Response = await fetch(`${this.base}/healthz`, {\n\t\t\t\t\tsignal: AbortSignal.timeout(READY_POLL_MS * 4),\n\t\t\t\t});\n\t\t\t\tif (response.ok) return;\n\t\t\t\tlast = `HTTP ${String(response.status)}`;\n\t\t\t} catch (cause) {\n\t\t\t\tlast = describe(cause);\n\t\t\t}\n\t\t\tif (Date.now() >= deadline) break;\n\t\t\tawait sleep(READY_POLL_MS);\n\t\t}\n\t\t// oxlint-enable no-await-in-loop\n\t\tthrow new Error(\n\t\t\t`The agent in ${this.where} at ${this.base} did not answer within ${String(timeoutMs)}ms: ${last}`,\n\t\t);\n\t}\n\n\tasync run(command: readonly string[], options: RunOptions = {}): Promise<CommandResult> {\n\t\tconst controller: AbortController = new AbortController();\n\t\tconst guard: ReturnType<typeof setTimeout> | undefined =\n\t\t\toptions.timeoutMs === undefined\n\t\t\t\t? undefined\n\t\t\t\t: setTimeout(() => controller.abort(), options.timeoutMs + TIMEOUT_SLACK_MS);\n\t\tconst out: Buffer[] = [];\n\t\tconst err: Buffer[] = [];\n\t\tlet exit: AgentEvent | undefined;\n\t\ttry {\n\t\t\tconst response: Response = await this.exec(\n\t\t\t\t{\n\t\t\t\t\tcmd: [...command],\n\t\t\t\t\t...(options.stdin === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { stdin: Buffer.from(options.stdin).toString('base64') }),\n\t\t\t\t\t...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),\n\t\t\t\t},\n\t\t\t\tcontroller.signal,\n\t\t\t);\n\t\t\tfor await (const value of readNdjson(bodyOf(response))) {\n\t\t\t\tconst event: AgentEvent = asEvent(value);\n\t\t\t\tif (event.stdout !== undefined) out.push(Buffer.from(event.stdout, 'base64'));\n\t\t\t\tif (event.stderr !== undefined) err.push(Buffer.from(event.stderr, 'base64'));\n\t\t\t\tif (event.error !== undefined) throw new Error(event.error);\n\t\t\t\tif (event.exit !== undefined) exit = event;\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tthrow this.failure(runWhat(command), cause);\n\t\t} finally {\n\t\t\tclearTimeout(guard);\n\t\t}\n\t\tif (exit?.exit === undefined) {\n\t\t\tthrow this.failure(runWhat(command), new Error('the response ended without an exit status'));\n\t\t}\n\t\tif (exit.timedOut === true) {\n\t\t\t// The agent has killed the command's process group by now.\n\t\t\tthrow new CommandTimeoutError(\n\t\t\t\t`Command timed out after ${String(options.timeoutMs)}ms in ${this.where}: ${programOf(command)}`,\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tstdout: Buffer.concat(out).toString('utf8'),\n\t\t\tstderr: Buffer.concat(err).toString('utf8'),\n\t\t\texitCode: exit.exit,\n\t\t};\n\t}\n\n\t/**\n\t * Run a command and hand back its stdout as it arrives.\n\t *\n\t * stdout only, as marimohub's local backend does: the stream carries no\n\t * framing, so interleaving stderr would corrupt output the caller parses.\n\t * The exit code is unreachable through a `ReadableStream`, so a command that\n\t * fails is a stream that ends. Cancelling the stream closes the request, and\n\t * the agent kills the command's process group when it sees that; the\n\t * timeout does the same, truncating the output rather than discarding it.\n\t */\n\tasync stream(\n\t\tcommand: readonly string[],\n\t\toptions: StreamOptions = {},\n\t): Promise<ReadableStream<Uint8Array>> {\n\t\tconst controller: AbortController = new AbortController();\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await this.exec({ cmd: [...command] }, controller.signal);\n\t\t} catch (cause) {\n\t\t\tthrow this.failure(runWhat(command), cause);\n\t\t}\n\t\tconst events: AsyncGenerator = readNdjson(bodyOf(response));\n\t\tconst failure: (cause: unknown) => Error = (cause: unknown): Error =>\n\t\t\tthis.failure(runWhat(command), cause);\n\n\t\tconst stop: () => void = (): void => {\n\t\t\tcontroller.abort();\n\t\t};\n\t\tconst timer: ReturnType<typeof setTimeout> | undefined =\n\t\t\toptions.timeoutMs === undefined ? undefined : setTimeout(stop, options.timeoutMs);\n\n\t\treturn new ReadableStream<Uint8Array>({\n\t\t\tasync pull(output: ReadableStreamDefaultController<Uint8Array>): Promise<void> {\n\t\t\t\t// oxlint-disable no-await-in-loop -- lines that carry no stdout are skipped in place\n\t\t\t\tfor (;;) {\n\t\t\t\t\tlet next: IteratorResult<unknown>;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tnext = await events.next();\n\t\t\t\t\t} catch (cause) {\n\t\t\t\t\t\tif (!controller.signal.aborted) {\n\t\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\t\toutput.error(failure(cause));\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// The abort was ours, so this is an ending, not a failure.\n\t\t\t\t\t\tnext = { done: true, value: undefined };\n\t\t\t\t\t}\n\t\t\t\t\tif (next.done) {\n\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\tcloseQuietly(output);\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tconst event: AgentEvent = asEvent(next.value);\n\t\t\t\t\tif (event.error !== undefined) {\n\t\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\t\toutput.error(failure(new Error(event.error)));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif (event.stdout !== undefined) {\n\t\t\t\t\t\toutput.enqueue(new Uint8Array(Buffer.from(event.stdout, 'base64')));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// oxlint-enable no-await-in-loop\n\t\t\t},\n\t\t\tcancel(): void {\n\t\t\t\tclearTimeout(timer);\n\t\t\t\tstop();\n\t\t\t},\n\t\t});\n\t}\n\n\tasync writeFile(path: string, content: string | Uint8Array): Promise<void> {\n\t\tconst what = `write ${path}`;\n\t\t// Copied into a fresh array because `fetch` wants a view over a plain\n\t\t// ArrayBuffer, which a caller's slice of a shared one is not typed as.\n\t\tconst body: string | Uint8Array<ArrayBuffer> =\n\t\t\ttypeof content === 'string' ? content : new Uint8Array(content);\n\t\tconst response: Response = await this.request(what, 'PUT', filePath('/files', path), {\n\t\t\tbody,\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow this.failure(what, new Error((await refusalOf(response)).message));\n\t\t}\n\t}\n\n\tasync readFile(path: string): Promise<ReadFileOutcome> {\n\t\tconst what = `read ${path}`;\n\t\tconst response: Response = await this.request(what, 'GET', filePath('/files', path));\n\t\tif (response.ok) {\n\t\t\treturn { outcome: 'ok', bytes: new Uint8Array(await response.arrayBuffer()) };\n\t\t}\n\t\treturn this.readRefused(what, response);\n\t}\n\n\t/** A refused read: `not_found` and `read_failed` are the pod's answers, anything else a failure to ask. */\n\tprivate async readRefused(what: string, response: Response): Promise<ReadFileOutcome> {\n\t\tconst refusal: AgentRefusal = await refusalOf(response);\n\t\tif (refusal.code === 'not_found') return { outcome: 'not-found' };\n\t\tif (refusal.code === 'read_failed') return { outcome: 'failed', message: refusal.message };\n\t\tthrow this.failure(what, new Error(refusal.message));\n\t}\n\n\t/**\n\t * The agent enforces the budget where the file is; this side holds it to\n\t * the same terms, so an agent that misbehaves cannot exceed it either. The\n\t * request is abandoned shortly after the deadline, if the agent's own answer\n\t * to it has not arrived, and a body that runs past `maxBytes` is cancelled\n\t * at the first byte over.\n\t */\n\tasync readFileBounded(path: string, budget: ReadBudget): Promise<ReadFileOutcome> {\n\t\tconst what = `read ${path}`;\n\t\tconst response: Response = await this.request(\n\t\t\twhat,\n\t\t\t'GET',\n\t\t\t`${filePath('/files/bounded', path)}&maxBytes=${String(budget.maxBytes)}&timeoutMs=${String(budget.timeoutMs)}`,\n\t\t\t{ signal: AbortSignal.timeout(boundedReadGiveUpMs(budget.timeoutMs)) },\n\t\t);\n\t\tif (!response.ok) return this.readRefused(what, response);\n\t\tlet bytes: Uint8Array | undefined;\n\t\ttry {\n\t\t\tbytes = await readAtMost(bodyOf(response), budget.maxBytes);\n\t\t} catch (cause) {\n\t\t\tthrow this.failure(what, cause);\n\t\t}\n\t\tif (bytes === undefined) {\n\t\t\treturn {\n\t\t\t\toutcome: 'failed',\n\t\t\t\tmessage: `the agent sent more than the budget of ${String(budget.maxBytes)} bytes`,\n\t\t\t};\n\t\t}\n\t\treturn { outcome: 'ok', bytes };\n\t}\n\n\tasync listFiles(path: string, recursive: boolean): Promise<ListFilesOutcome> {\n\t\tconst what = `list ${path}`;\n\t\tconst response: Response = await this.request(\n\t\t\twhat,\n\t\t\t'GET',\n\t\t\t`${filePath('/files/list', path)}${recursive ? '&recursive=true' : ''}`,\n\t\t);\n\t\tif (!response.ok) {\n\t\t\tconst refusal: AgentRefusal = await refusalOf(response);\n\t\t\tif (refusal.code === 'not_a_directory') return { outcome: 'not-a-directory' };\n\t\t\tif (refusal.code === 'not_found' || refusal.code === 'list_failed') {\n\t\t\t\treturn { outcome: 'failed', message: refusal.message };\n\t\t\t}\n\t\t\tthrow this.failure(what, new Error(refusal.message));\n\t\t}\n\t\tconst entries: AgentFileEntry[] | undefined = entriesOf(await response.json());\n\t\tif (entries === undefined) {\n\t\t\tthrow this.failure(what, new Error('the agent sent a listing with no entries'));\n\t\t}\n\t\treturn { outcome: 'ok', entries };\n\t}\n\n\tasync startProcess(command: readonly string[], cwd?: string): Promise<number> {\n\t\tconst what = `start ${programOf(command)}`;\n\t\tconst response: Response = await this.request(what, 'POST', '/process/start', {\n\t\t\tjson: { cmd: [...command], ...(cwd === undefined ? {} : { cwd }) },\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow this.failure(what, new Error((await refusalOf(response)).message));\n\t\t}\n\t\tconst pid: number | undefined = pidOf(await response.json());\n\t\tif (pid === undefined) {\n\t\t\tthrow this.failure(what, new Error('the agent named no pid'));\n\t\t}\n\t\treturn pid;\n\t}\n\n\tasync processStatus(pid: number): Promise<ProcessStatus> {\n\t\tconst what = `check process ${String(pid)}`;\n\t\tconst response: Response = await this.request(\n\t\t\twhat,\n\t\t\t'GET',\n\t\t\t`/process/status?pid=${String(pid)}`,\n\t\t);\n\t\tif (!response.ok) {\n\t\t\tthrow this.failure(what, new Error((await refusalOf(response)).message));\n\t\t}\n\t\tconst status: ProcessStatus | undefined = statusOf(await response.json());\n\t\tif (status === undefined) {\n\t\t\tthrow this.failure(what, new Error('the agent sent no status'));\n\t\t}\n\t\treturn status;\n\t}\n\n\tasync signalProcess(pid: number, signal: string): Promise<void> {\n\t\tconst what = `signal process ${String(pid)}`;\n\t\tconst response: Response = await this.request(what, 'POST', '/process/signal', {\n\t\t\tjson: { pid, signal },\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow this.failure(what, new Error((await refusalOf(response)).message));\n\t\t}\n\t}\n\n\tasync processLogs(pid: number): Promise<string> {\n\t\tconst what = `read the log of process ${String(pid)}`;\n\t\tconst response: Response = await this.request(what, 'GET', `/process/logs?pid=${String(pid)}`);\n\t\tif (!response.ok) {\n\t\t\tthrow this.failure(what, new Error((await refusalOf(response)).message));\n\t\t}\n\t\treturn response.text();\n\t}\n\n\tasync waitForPort(\n\t\tport: number,\n\t\ttimeoutMs: number,\n\t\tpid?: number,\n\t\tprobe?: PortProbe,\n\t): Promise<PortWait> {\n\t\tconst what = `wait for port ${String(port)}`;\n\t\t// The agent holds the request for up to the timeout; past that plus\n\t\t// slack, the wait itself has gone missing.\n\t\tconst response: Response = await this.request(what, 'POST', '/process/waitport', {\n\t\t\tjson: {\n\t\t\t\tport,\n\t\t\t\ttimeoutMs,\n\t\t\t\t...(pid === undefined ? {} : { pid }),\n\t\t\t\t...(probe?.mode === undefined ? {} : { mode: probe.mode }),\n\t\t\t\t...(probe?.path === undefined ? {} : { path: probe.path }),\n\t\t\t},\n\t\t\tsignal: AbortSignal.timeout(timeoutMs + TIMEOUT_SLACK_MS),\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow this.failure(what, new Error((await refusalOf(response)).message));\n\t\t}\n\t\tconst wait: PortWait | undefined = portWaitOf(await response.json());\n\t\tif (wait === undefined) {\n\t\t\tthrow this.failure(what, new Error('the agent sent no answer for the wait'));\n\t\t}\n\t\treturn wait;\n\t}\n\n\t/** `POST /exec`, whose refusals are read before the NDJSON stream begins. */\n\tprivate async exec(body: object, signal: AbortSignal): Promise<Response> {\n\t\tconst response: Response = await fetch(`${this.base}/exec`, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/json',\n\t\t\t\tauthorization: `Bearer ${this.endpoint.token}`,\n\t\t\t},\n\t\t\tbody: JSON.stringify(body),\n\t\t\tsignal,\n\t\t});\n\t\tif (!response.ok) {\n\t\t\tthrow new Error((await refusalOf(response)).message);\n\t\t}\n\t\treturn response;\n\t}\n\n\t/** One request to the agent, with network failures wrapped and named. */\n\tprivate async request(\n\t\twhat: string,\n\t\tmethod: string,\n\t\tpath: string,\n\t\toptions: { body?: string | Uint8Array<ArrayBuffer>; json?: object; signal?: AbortSignal } = {},\n\t): Promise<Response> {\n\t\tconst headers: Record<string, string> = { authorization: `Bearer ${this.endpoint.token}` };\n\t\tif (options.json !== undefined) headers['content-type'] = 'application/json';\n\t\tconst body: string | Uint8Array<ArrayBuffer> | undefined =\n\t\t\toptions.json === undefined ? options.body : JSON.stringify(options.json);\n\t\ttry {\n\t\t\treturn await fetch(`${this.base}${path}`, {\n\t\t\t\tmethod,\n\t\t\t\theaders,\n\t\t\t\t...(body === undefined ? {} : { body }),\n\t\t\t\t...(options.signal === undefined ? {} : { signal: options.signal }),\n\t\t\t});\n\t\t} catch (cause) {\n\t\t\tthrow this.failure(what, cause);\n\t\t}\n\t}\n\n\tprivate failure(what: string, cause: unknown): Error {\n\t\treturn new Error(`The agent in ${this.where} could not ${what}: ${describe(cause)}`, { cause });\n\t}\n}\n\nfunction runWhat(command: readonly string[]): string {\n\treturn `run ${programOf(command)}`;\n}\n\n/**\n * A command as messages name it: the program, never its arguments. The sandbox\n * exports marimohub's env vars inline (`sh -lc \"export K='v'; …\"`), and those\n * are session credentials, so the arguments would carry them into marimohub's\n * logs and whatever it shows a user. The caller knows its own command.\n */\nfunction programOf(command: readonly string[]): string {\n\treturn JSON.stringify(command[0] ?? '');\n}\n\n/** The path travels as a query parameter, so it needs no quoting of any kind. */\nfunction filePath(endpoint: string, path: string): string {\n\treturn `${endpoint}?path=${encodeURIComponent(path)}`;\n}\n\nfunction bodyOf(response: Response): ReadableStream<Uint8Array> {\n\tif (response.body === null) throw new Error('the response had no body');\n\treturn response.body;\n}\n\n/**\n * When the client abandons a bounded read: the slack past the agent's deadline,\n * but never past what a timer holds. Node fires an overflowing timer after 1ms,\n * which would abort every read whose deadline is within a second of the\n * largest the port allows.\n */\nexport function boundedReadGiveUpMs(timeoutMs: number): number {\n\treturn Math.min(timeoutMs + BOUNDED_READ_SLACK_MS, MAX_TIMER_MS);\n}\n\n/** The whole body, or undefined as soon as it runs past `maxBytes`. */\nasync function readAtMost(\n\tbody: ReadableStream<Uint8Array>,\n\tmaxBytes: number,\n): Promise<Uint8Array | undefined> {\n\tconst reader: ReadableStreamDefaultReader<Uint8Array> = body.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\t// oxlint-disable no-await-in-loop -- a stream is read one chunk at a time\n\tfor (;;) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\ttotal += value.byteLength;\n\t\tif (total > maxBytes) {\n\t\t\tawait reader.cancel();\n\t\t\treturn undefined;\n\t\t}\n\t\tchunks.push(value);\n\t}\n\t// oxlint-enable no-await-in-loop\n\treturn Buffer.concat(chunks);\n}\n\n/** Closing a stream that a cancel already closed throws, and means nothing. */\nfunction closeQuietly(output: ReadableStreamDefaultController<Uint8Array>): void {\n\ttry {\n\t\toutput.close();\n\t} catch {\n\t\t// Already closed or cancelled.\n\t}\n}\n",
12
12
  "/**\n * Which Armada queue a sandbox belongs to.\n *\n * Armada tells tenants apart by queue: fair share and priority are computed per\n * queue, so the queue is the fairness model for a multi-tenant notebook server.\n * marimohub names a sandbox's owner (project, and user when it has one) on the\n * calls where it holds a record; `ARMADA_QUEUE_BY_USER` and\n * `ARMADA_QUEUE_BY_PROJECT` map those to queues, and `ARMADA_QUEUE` takes the\n * rest.\n *\n * The queue must be known again later, because every call that touches a job\n * (the event stream, cancel, even \"cancel whatever is in this job set\") is\n * addressed by queue and job set. The queue a job is in is state; the owner\n * map is configuration, and the two disagree the moment an operator moves a\n * project while its sessions run. So state is asked first, and the map only\n * places a sandbox that does not exist yet:\n *\n * 1. What this process has seen: a queue chosen at `create`, or reported by\n * Lookout during `listActive`.\n * 2. Lookout, asked for the job set by name. marimohub creates sandboxes by id\n * alone on paths that exec and destroy (surfaces, the reconciler, job\n * cleanup), so after a restart this is the only source for those, on every\n * marimohub version. A queue map therefore requires `ARMADA_LOOKOUT_URL`,\n * which `readConfig` enforces.\n * 3. The owner map, for a job set Lookout says holds nothing: this is a submit\n * that has not happened yet, and the owner decides where it goes.\n *\n * With no map configured every sandbox is in `ARMADA_QUEUE`, and none of this\n * costs a request.\n */\nimport type { ArmadaConfig } from './config.js';\nimport type { SandboxId, SandboxOwner } from './types.js';\n\n/** Asks Lookout which queue holds a job set; `undefined` when it holds none. */\nexport type QueueLookup = (jobSetId: SandboxId) => Promise<string | undefined>;\n\n/**\n * Lookout could not be asked, so the sandbox's queue is unknown. A guess would\n * cancel in the wrong queue and report success, or submit a second kernel next\n * to the first (Armada dedupes the client id per queue), so the call fails\n * instead. Every marimohub caller retries a failed create or destroy.\n */\nexport class QueueUnknownError extends Error {\n\tconstructor(id: SandboxId, cause: unknown) {\n\t\tsuper(\n\t\t\t`cannot tell which queue sandbox ${id} is in: Lookout did not answer (${cause instanceof Error ? cause.message : String(cause)})`,\n\t\t\t{ cause },\n\t\t);\n\t\tthis.name = 'QueueUnknownError';\n\t}\n}\n\nexport class QueueDirectory {\n\t/** Every queue a sandbox of this deployment can be in, the default first. */\n\treadonly all: readonly string[];\n\t/** Whether any owner maps anywhere but the default queue. */\n\treadonly mapped: boolean;\n\tprivate readonly remembered: Map<SandboxId, string> = new Map();\n\n\tconstructor(\n\t\tprivate readonly config: ArmadaConfig,\n\t\tprivate readonly lookup: QueueLookup | undefined,\n\t) {\n\t\tthis.all = [\n\t\t\t...new Set([\n\t\t\t\tconfig.queue,\n\t\t\t\t...Object.values(config.queueByUser),\n\t\t\t\t...Object.values(config.queueByProject),\n\t\t\t]),\n\t\t];\n\t\tthis.mapped = this.all.length > 1;\n\t}\n\n\t/** The queue an owner maps to: the user's, else the project's, else the default. */\n\tforOwner(owner: SandboxOwner): string {\n\t\tconst byUser: string | undefined =\n\t\t\towner.userId === undefined ? undefined : this.config.queueByUser[owner.userId];\n\t\treturn byUser ?? this.config.queueByProject[owner.projectId] ?? this.config.queue;\n\t}\n\n\tremember(id: SandboxId, queue: string): void {\n\t\tthis.remembered.set(id, queue);\n\t}\n\n\t/** Drops what was remembered for a sandbox whose job set is cancelled. */\n\tforget(id: SandboxId): void {\n\t\tthis.remembered.delete(id);\n\t}\n\n\t/**\n\t * The queue for a sandbox, by the three sources above. Fails only with\n\t * {@link QueueUnknownError}, when a map is configured and Lookout cannot say.\n\t */\n\tasync resolve(id: SandboxId, owner: SandboxOwner | undefined): Promise<string> {\n\t\tconst known: string | undefined = this.remembered.get(id);\n\t\tif (known !== undefined) return known;\n\t\tif (!this.mapped) return this.config.queue;\n\t\tif (this.lookup !== undefined) {\n\t\t\tlet found: string | undefined;\n\t\t\ttry {\n\t\t\t\tfound = await this.lookup(id);\n\t\t\t} catch (cause: unknown) {\n\t\t\t\tthrow new QueueUnknownError(id, cause);\n\t\t\t}\n\t\t\tif (found !== undefined) {\n\t\t\t\tthis.remembered.set(id, found);\n\t\t\t\treturn found;\n\t\t\t}\n\t\t}\n\t\tconst queue: string = owner === undefined ? this.config.queue : this.forOwner(owner);\n\t\tthis.remembered.set(id, queue);\n\t\treturn queue;\n\t}\n}\n",
13
- "import { createHash, createHmac } from 'node:crypto';\nimport type { ArmadaClient, PodLocation, SubmittedJob } from './armada.js';\nimport type { ArmadaConfig } from './config.js';\nimport type {\n\tAgentEndpoint,\n\tAgentFileEntry,\n\tCommandResult,\n\tControlChannel,\n\tListFilesOutcome,\n\tPortProbe,\n\tPortWait,\n\tReadBudget,\n\tReadFileOutcome,\n} from './channel.js';\nimport { CommandTimeoutError } from './channel.js';\nimport { buildPodSpec } from './podspec.js';\nimport type { QueueDirectory } from './queues.js';\nimport { assertEnvName, gitCloneCommand, withEnvPrefix } from './shell.js';\nimport type {\n\tBoundedReadOptions,\n\tCreateSandboxOptions,\n\tExecOptions,\n\tExecResult,\n\tExecStreamOptions,\n\tExposePortOptions,\n\tExposePortResult,\n\tFileInfo,\n\tGitCheckoutOptions,\n\tListFilesOptions,\n\tListFilesResult,\n\tMountBucketOptions,\n\tReadFileResult,\n\tSandboxFileWrite,\n\tSandboxId,\n\tSandboxInstance,\n\tSandboxProcess,\n\tSetEnvVarsOptions,\n\tStartProcessOptions,\n\tWaitForPortOptions,\n} from './types.js';\n\n/**\n * The bytes as text, or undefined when they are not valid UTF-8, which is how\n * `readFile` chooses what encoding to report. `ignoreBOM` keeps a leading BOM in\n * the string (the flag means \"do not treat it specially\"), so a file that has\n * one round-trips byte for byte.\n */\nfunction decodeUtf8(bytes: Uint8Array): string | undefined {\n\ttry {\n\t\treturn new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Control characters escaped as JSON would, so a value cannot break a log line. */\nfunction oneLine(text: string): string {\n\t// oxlint-disable-next-line no-control-regex -- matching control characters is the point\n\treturn text.replace(/[\\u0000-\\u001f\\u007f]/g, (char: string): string =>\n\t\tJSON.stringify(char).slice(1, -1),\n\t);\n}\n\nfunction reason(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\n/**\n * Whether a bounded read's budget is one marimohub's port allows\n * (`BoundedReadOptions`), checked as its reference reader checks it\n * (`packages/compute-commons/src/boundedRead.ts`): a nonnegative safe integer\n * of bytes whose base64 size is safe too, and a positive deadline a timer can\n * hold.\n */\nexport function isValidBudget(options: BoundedReadOptions): boolean {\n\treturn (\n\t\tNumber.isSafeInteger(options.maxBytes) &&\n\t\toptions.maxBytes >= 0 &&\n\t\tNumber.isSafeInteger(4 * Math.ceil(options.maxBytes / 3)) &&\n\t\tNumber.isFinite(options.timeoutMs) &&\n\t\toptions.timeoutMs > 0 &&\n\t\toptions.timeoutMs <= 2 ** 31 - 1\n\t);\n}\n\n/**\n * The bearer token a sandbox's agent expects: an HMAC of the sandbox id under\n * `ARMADA_AGENT_TOKEN_SECRET`. Derived rather than minted, because marimohub\n * reaches a sandbox through a fresh `create(id)` on every path after the\n * first, teardown and the snapshot sweep included, and in another process after\n * a restart; each of them has to arrive at the token the pod was started with.\n */\nexport function agentToken(secret: string, id: SandboxId): string {\n\treturn createHmac('sha256', secret).update(id).digest('hex');\n}\n\n/**\n * Where a sandbox this process has reached lives: its job, its pod, and the\n * channel to its agent. marimohub builds a new instance for every call after\n * provisioning (each snapshot, the teardown, a surface check), and without this\n * each would resubmit the job, wait for its running event and poll the agent\n * again before doing anything. The provider holds one map for all of them.\n */\nexport interface Placement {\n\tjob: SubmittedJob;\n\tpod: PodLocation;\n\tchannel: ControlChannel;\n}\n\nexport type Placements = Map<SandboxId, Placement>;\n\n/** Each write is one request to the agent; cap how many are in flight. */\nconst WRITE_CONCURRENCY = 8;\n\n/** How long a running pod gets to answer on the agent port before `ready` gives up. */\nconst AGENT_READY_TIMEOUT_MS = 30_000;\n\n/**\n * `isPortReady` is one look, not a wait: a zero timeout makes the agent probe\n * once and answer, the probe itself bounded to the 2s marimohub's local\n * adapter allows (`agent/process.go`).\n */\nconst PORT_READY_TIMEOUT_MS = 0;\n\n/** A non-zero exit is the command's business; marimohub wants it as a result. */\nexport function toExecResult(result: CommandResult): ExecResult {\n\tif (result.exitCode === 0) {\n\t\treturn { success: true, stdout: result.stdout, stderr: result.stderr };\n\t}\n\treturn {\n\t\tsuccess: false,\n\t\tstdout: result.stdout,\n\t\tstderr: result.stderr,\n\t\terror: { code: 'COMMAND_FAILED' },\n\t};\n}\n\n/**\n * The agent's listing as marimohub's `FileInfo` records.\n *\n * Hiding is done here rather than in the agent's walk, so a recursive listing\n * still descends into a dot directory and reports its non-dot children, which\n * is what upstream does and what `readSessionArtifacts` needs for `__marimo__`\n * trees: each entry is judged on its own name alone.\n */\nexport function toFileInfos(\n\tentries: readonly AgentFileEntry[],\n\trootPath: string,\n\toptions?: ListFilesOptions,\n): FileInfo[] {\n\tconst files: FileInfo[] = [];\n\tfor (const entry of entries) {\n\t\tconst name: string = entry.path.slice(entry.path.lastIndexOf('/') + 1);\n\t\tif (options?.includeHidden !== true && name.startsWith('.')) continue;\n\t\tfiles.push({\n\t\t\tname,\n\t\t\tabsolutePath: entry.path,\n\t\t\trelativePath: entry.path.startsWith(rootPath)\n\t\t\t\t? entry.path.slice(rootPath.length).replace(/^\\//, '')\n\t\t\t\t: entry.path,\n\t\t\ttype: entry.type,\n\t\t\tsize: entry.size,\n\t\t});\n\t}\n\treturn files;\n}\n\n/**\n * One kernel session, backed by one Armada job.\n *\n * Resolution is lazy: `create()` is synchronous and id-addressed, so the job is\n * submitted on first use. An instance from `connectExisting` never submits: it\n * finds the job the sandbox already has, and fails every call when there is\n * none (`attachOnly`). Commands run through the agent's `/exec`; detached\n * processes and files go through its own endpoints, so nothing here builds a\n * shell command beyond the env prefix and the quoted `git clone`.\n */\nexport class ArmadaSandbox implements SandboxInstance {\n\t/** Armada cannot mount a bucket; the provisioner falls back to copying files. */\n\treadonly supportsBucketMount = false;\n\n\tprivate job?: SubmittedJob;\n\tprivate pod?: PodLocation | undefined;\n\t/** The agent in the pod, once `ready` has reached it. */\n\tprivate channel?: ControlChannel | undefined;\n\t/** The bearer token this sandbox's agent expects. The pod carries only its hash. */\n\tprivate readonly token: string;\n\t/** Settled by `queue()`, and fixed for the life of the sandbox once it is. */\n\n\t/**\n\t * The pod's environment is fixed at submission, so `setEnvVars` accumulates\n\t * here and is replayed as an `export` prefix on every later command, the way\n\t * marimohub's kubernetes adapter does it. `envDefaults` holds the\n\t * `onlyIfUnset` vars, exported behind a guard so any existing value wins.\n\t */\n\tprivate env: Record<string, string> = {};\n\tprivate envDefaults: Record<string, string> = {};\n\n\tconstructor(\n\t\tprivate readonly id: SandboxId,\n\t\tprivate readonly config: ArmadaConfig,\n\t\tprivate readonly armada: ArmadaClient,\n\t\tprivate readonly openChannel: (endpoint: AgentEndpoint) => ControlChannel,\n\t\tprivate readonly queues: QueueDirectory,\n\t\tprivate readonly placements: Placements,\n\t\tprivate readonly options?: CreateSandboxOptions,\n\t\t/**\n\t\t * Reach the job the sandbox already has, never submit one. marimohub\n\t\t * attaches this way to save an expired session's edits before reclaiming\n\t\t * it, and a fresh pod there would be an empty workspace to capture.\n\t\t */\n\t\tprivate readonly attachOnly: boolean = false,\n\t) {\n\t\tthis.token = agentToken(config.agentTokenSecret, id);\n\t}\n\n\t/**\n\t * Submit the job, block until its pod is running, and reach the agent in it.\n\t *\n\t * Idempotent: marimohub calls this before each use, and the submission dedupes\n\t * on `clientId` anyway, so a second call on a started sandbox does nothing.\n\t *\n\t * The token ({@link agentToken}) never leaves this process except in request\n\t * headers to the one pod that knows its hash. The pod spec, which anyone with\n\t * read access to the job can fetch, carries the hash alone. A resubmit that\n\t * Armada dedupes to the running job carries the same hash, since the token\n\t * depends on the id alone.\n\t *\n\t * A sandbox another instance in this process already reached is taken from\n\t * {@link Placements} after one look at the agent's health, which is what\n\t * tells a live pod from one that has since gone; a gone one is resolved\n\t * again from the start.\n\t */\n\tasync ready(): Promise<void> {\n\t\tif (this.channel !== undefined) return;\n\t\tconst known: Placement | undefined = this.placements.get(this.id);\n\t\tif (known !== undefined) {\n\t\t\ttry {\n\t\t\t\tawait known.channel.ready(0);\n\t\t\t\tthis.job = known.job;\n\t\t\t\tthis.pod = known.pod;\n\t\t\t\tthis.channel = known.channel;\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tthis.placements.delete(this.id);\n\t\t\t}\n\t\t}\n\t\tthis.job ??= this.attachOnly ? await this.existingJob() : await this.submit();\n\t\tthis.pod = await this.armada.waitForRunning(this.job);\n\t\t// The agent's address comes from the same event as the kernel's.\n\t\tconst url: string = await this.armada.portUrl(this.job, this.config.agentPort);\n\t\tconst channel: ControlChannel = this.openChannel({ url, token: this.token, pod: this.pod });\n\t\tawait channel.ready(AGENT_READY_TIMEOUT_MS);\n\t\tthis.channel = channel;\n\t\tthis.placements.set(this.id, { job: this.job, pod: this.pod, channel });\n\t}\n\n\tprivate async submit(): Promise<SubmittedJob> {\n\t\tconst tokenSha256: string = createHash('sha256').update(this.token).digest('hex');\n\t\treturn this.armada.submit(\n\t\t\tthis.id,\n\t\t\tbuildPodSpec(this.config, { tokenSha256 }, this.options),\n\t\t\tawait this.queue(),\n\t\t);\n\t}\n\n\t/**\n\t * The sandbox's unfinished job, for an `attachOnly` instance. Its absence is\n\t * the answer marimohub needs: the read or command that asked fails, its\n\t * capture with it, and reclaiming goes on to `destroy`, which cancels the\n\t * job set and releases the session.\n\t */\n\tprivate async existingJob(): Promise<SubmittedJob> {\n\t\tconst queue: string = await this.queue();\n\t\tconst job: SubmittedJob | undefined = await this.armada.findJob(this.id, queue);\n\t\tif (job === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t`Sandbox ${this.id} has no unfinished job in queue \"${queue}\" to attach to, and attaching never submits one`,\n\t\t\t);\n\t\t}\n\t\treturn job;\n\t}\n\n\t/** Where the pod landed, once it has. For reporting, not for reaching it. */\n\tget placement(): PodLocation | undefined {\n\t\treturn this.pod;\n\t}\n\n\t/**\n\t * The queue this sandbox's job is in, or will be submitted to: the job's own\n\t * once submitted here, else what this process or Lookout knows of the\n\t * sandbox, else where the owner marimohub named maps to (`src/queues.ts`).\n\t */\n\tasync queue(): Promise<string> {\n\t\treturn this.job?.queue ?? this.queues.resolve(this.id, this.options?.owner);\n\t}\n\n\t/**\n\t * One probe of a port, for marimohub's surface manager checking whether a\n\t * surface it started earlier still answers. Without this it runs a\n\t * `python3` one-liner in the pod; the agent answers the same question from\n\t * inside without needing an interpreter. Anything but a clean answer is\n\t * \"not ready\", as marimohub's own adapters treat it, since the caller's\n\t * remedy is the same either way: start the surface again. Only the probe is\n\t * treated that way: a sandbox this process has not reached cannot have a\n\t * surface listening, and is not submitted or waited for to find that out.\n\t * One another instance reached counts as reached, since marimohub asks\n\t * through a fresh instance.\n\t */\n\tasync isPortReady(port: number, options?: Omit<WaitForPortOptions, 'timeout'>): Promise<boolean> {\n\t\tconst channel: ControlChannel | undefined =\n\t\t\tthis.channel ?? this.placements.get(this.id)?.channel;\n\t\tif (channel === undefined) return false;\n\t\ttry {\n\t\t\tconst wait: PortWait = await channel.waitForPort(\n\t\t\t\tport,\n\t\t\t\tPORT_READY_TIMEOUT_MS,\n\t\t\t\tundefined,\n\t\t\t\tprobeOf({ ...options, mode: options?.mode ?? 'http' }),\n\t\t\t);\n\t\t\treturn wait.open;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Everything above this method is built on the channel, so this is the one\n\t * that has to be right. A command that fails is a normal result, not an\n\t * exception; only the channel itself failing is a `BACKEND_ERROR`.\n\t *\n\t * A login shell, matching marimohub's kubernetes adapter: what arrives here is\n\t * user and provisioner code, and an image that puts `uv` or `python3` on the\n\t * PATH through a profile script has to keep working.\n\t *\n\t * The caller's timeout goes to the agent, which kills the command's process\n\t * group at the deadline. A command with no timeout gets\n\t * `ARMADA_COMMAND_MAX_SECONDS` instead: most of marimohub's exec calls carry\n\t * none because the work legitimately takes minutes, and this is the\n\t * hours-later answer to \"nobody expected this to still be running\", which\n\t * would otherwise hold a request and a process for the rest of the session.\n\t */\n\tasync exec(cmd: string, options?: ExecOptions): Promise<ExecResult> {\n\t\tconst command: string = withEnvPrefix(cmd, this.env, this.envDefaults);\n\t\tconst timeout: number | undefined = options?.timeout;\n\t\tconst backstopMs: number | undefined =\n\t\t\ttimeout === undefined && this.config.commandMaxSeconds > 0\n\t\t\t\t? this.config.commandMaxSeconds * 1000\n\t\t\t\t: undefined;\n\t\tconst deadline: number | undefined = timeout ?? backstopMs;\n\t\ttry {\n\t\t\tconst channel: ControlChannel = await this.open();\n\t\t\tconst result: CommandResult = await channel.run(\n\t\t\t\t['sh', '-lc', command],\n\t\t\t\tdeadline === undefined ? {} : { timeoutMs: deadline },\n\t\t\t);\n\t\t\treturn toExecResult(result);\n\t\t} catch (error) {\n\t\t\tconst stderr: string =\n\t\t\t\terror instanceof CommandTimeoutError && backstopMs !== undefined\n\t\t\t\t\t? `Command ran past ARMADA_COMMAND_MAX_SECONDS (${String(this.config.commandMaxSeconds)}s) and was killed: ${cmd}`\n\t\t\t\t\t: reason(error);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tstdout: '',\n\t\t\t\tstderr,\n\t\t\t\terror: { code: 'BACKEND_ERROR' },\n\t\t\t};\n\t\t}\n\t}\n\n\t/** The agent, submitting the job and waiting for its pod first if nobody has yet. */\n\tprivate async open(): Promise<ControlChannel> {\n\t\tif (this.channel === undefined) await this.ready();\n\t\tif (this.channel === undefined)\n\t\t\tthrow new Error(`Sandbox ${this.id} has no agent after ready()`);\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * The same command as `exec`, with its stdout arriving as it is produced.\n\t *\n\t * A login shell, like `exec`: this runs whatever the caller asked for. Unlike\n\t * `exec` there is no typed failure to return, so a control channel that\n\t * cannot be reached throws here rather than resolving to a `BACKEND_ERROR`\n\t * stream. Cancelling, or the timeout passing, closes the request, and the\n\t * agent kills the command's process group when it sees that.\n\t */\n\tasync execStream(cmd: string, options?: ExecStreamOptions): Promise<ReadableStream> {\n\t\tconst channel: ControlChannel = await this.open();\n\t\tconst command: string = withEnvPrefix(cmd, this.env, this.envDefaults);\n\t\treturn channel.stream(\n\t\t\t['sh', '-lc', command],\n\t\t\toptions?.timeout === undefined ? {} : { timeoutMs: options.timeout },\n\t\t);\n\t}\n\n\t/**\n\t * Read one file back out of the pod.\n\t *\n\t * The bytes cross raw, and the encoding we report is decided from them: text\n\t * is returned decoded, because marimohub's `readSessionArtifacts` takes\n\t * `content` and never looks at `encoding`, and anything that is not valid\n\t * UTF-8 is returned as base64, which is what `proposalCapture` decodes.\n\t * Reporting base64 unconditionally would store base64 as the notebook\n\t * source; reporting UTF-8 unconditionally would corrupt an image the user\n\t * changed.\n\t *\n\t * Unlike upstream, an absent path is `NOT_FOUND` rather than `READ_FAILED`.\n\t * Session capture reads four fixed paths of which some routinely do not\n\t * exist, so \"never written\" is the common answer and worth distinguishing\n\t * from \"could not be read\". The agent's `not_found` carries it.\n\t */\n\tasync readFile(path: string): Promise<ReadFileResult> {\n\t\treturn this.readThrough(\n\t\t\tpath,\n\t\t\tasync (channel: ControlChannel): Promise<ReadFileOutcome> => channel.readFile(path),\n\t\t\t(bytes: Uint8Array): ReadFileResult => {\n\t\t\t\tconst text: string | undefined = decodeUtf8(bytes);\n\t\t\t\treturn text === undefined\n\t\t\t\t\t? { success: true, content: Buffer.from(bytes).toString('base64'), encoding: 'base64' }\n\t\t\t\t\t: { success: true, content: text, encoding: 'utf-8' };\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * The read marimohub's session capture makes from `main` f4e5ef8 on, and\n\t * without which it captures nothing at all. The agent does the refusing\n\t * where the file is (`agent/files.go`): no symlink anywhere in the path,\n\t * regular files only, at most `maxBytes`, answered by the deadline. A\n\t * budget marimohub's port does not allow is refused here, before the job is\n\t * submitted or the agent asked, as upstream's contract test requires.\n\t *\n\t * Always base64, as upstream's reference reader answers. The guess\n\t * `readFile` makes from the bytes is there for a consumer that ignores\n\t * `encoding`; the bounded read's consumer (`readBoundedBytes`) decodes by\n\t * it and then re-checks the size, so base64 is exact and never wrong.\n\t *\n\t * The deadline bounds the read, not reaching the pod: a sandbox this\n\t * process has not reached yet is resolved first, as for every other call.\n\t */\n\tasync readFileBounded(path: string, options: BoundedReadOptions): Promise<ReadFileResult> {\n\t\tif (!isValidBudget(options)) {\n\t\t\treturn this.readFailed(\n\t\t\t\tpath,\n\t\t\t\t'READ_FAILED',\n\t\t\t\t`maxBytes ${String(options.maxBytes)} and timeoutMs ${String(options.timeoutMs)} are not a valid budget`,\n\t\t\t);\n\t\t}\n\t\tconst budget: ReadBudget = {\n\t\t\tmaxBytes: options.maxBytes,\n\t\t\ttimeoutMs: Math.ceil(options.timeoutMs),\n\t\t};\n\t\treturn this.readThrough(\n\t\t\tpath,\n\t\t\tasync (channel: ControlChannel): Promise<ReadFileOutcome> =>\n\t\t\t\tchannel.readFileBounded(path, budget),\n\t\t\t(bytes: Uint8Array): ReadFileResult => ({\n\t\t\t\tsuccess: true,\n\t\t\t\tcontent: Buffer.from(bytes).toString('base64'),\n\t\t\t\tencoding: 'base64',\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * One read through the agent, as marimohub's result: the bytes as `encode`\n\t * words them, `NOT_FOUND` quietly, and any other failure through\n\t * {@link readFailed}, with a channel that cannot be reached a `BACKEND_ERROR`.\n\t */\n\tprivate async readThrough(\n\t\tpath: string,\n\t\tread: (channel: ControlChannel) => Promise<ReadFileOutcome>,\n\t\tencode: (bytes: Uint8Array) => ReadFileResult,\n\t): Promise<ReadFileResult> {\n\t\tlet outcome: ReadFileOutcome;\n\t\ttry {\n\t\t\toutcome = await read(await this.open());\n\t\t} catch (error) {\n\t\t\treturn this.readFailed(path, 'BACKEND_ERROR', reason(error));\n\t\t}\n\t\tif (outcome.outcome === 'not-found') {\n\t\t\treturn { success: false, content: '', error: { code: 'NOT_FOUND' } };\n\t\t}\n\t\tif (outcome.outcome === 'failed') {\n\t\t\treturn this.readFailed(path, 'READ_FAILED', outcome.message);\n\t\t}\n\t\treturn encode(outcome.bytes);\n\t}\n\n\t/**\n\t * A failed read, reported as marimohub expects and said once on stderr. A\n\t * file marimohub cannot read back it leaves out without a word, and a\n\t * session whose notebook is left out commits nothing and is then destroyed,\n\t * so this line is the only trace of edits lost that way. `NOT_FOUND` never\n\t * comes here: capture reads paths that routinely do not exist. The token is\n\t * masked anywhere in the line, in case a transport error ever quotes a\n\t * header or a path happens to hold it, and control\n\t * characters are escaped, since a workspace file name may hold a newline.\n\t */\n\tprivate readFailed(\n\t\tpath: string,\n\t\tcode: 'READ_FAILED' | 'BACKEND_ERROR',\n\t\twhy: string,\n\t): ReadFileResult {\n\t\tconst line: string = `marimohub-compute-armada: sandbox ${this.id} could not read ${oneLine(path)} (${code}): ${oneLine(why)}`;\n\t\tconsole.warn(line.replaceAll(this.token, '<token>'));\n\t\treturn { success: false, content: '', error: { code } };\n\t}\n\n\t/**\n\t * List a directory, which session capture uses to size the files it is about\n\t * to read and to enumerate a workspace. The agent walks the tree itself and\n\t * answers structured records; only the hidden-file filter and the relative\n\t * paths are decided here ({@link toFileInfos}).\n\t */\n\tasync listFiles(path: string, options?: ListFilesOptions): Promise<ListFilesResult> {\n\t\tlet listed: ListFilesOutcome;\n\t\ttry {\n\t\t\tlisted = await (await this.open()).listFiles(path, options?.recursive === true);\n\t\t} catch {\n\t\t\treturn { success: false, files: [], error: { code: 'BACKEND_ERROR' } };\n\t\t}\n\t\tif (listed.outcome === 'not-a-directory') {\n\t\t\treturn { success: false, files: [], error: { code: 'NOT_A_DIRECTORY' } };\n\t\t}\n\t\tif (listed.outcome === 'failed') {\n\t\t\treturn { success: false, files: [], error: { code: 'LIST_FAILED' } };\n\t\t}\n\t\treturn { success: true, files: toFileInfos(listed.entries, path, options) };\n\t}\n\n\t/**\n\t * One request per file, bytes in the body: nothing is quoted, nothing passes\n\t * through a shell, and `Uint8Array` content arrives verbatim.\n\t */\n\tasync writeFiles(files: readonly SandboxFileWrite[]): Promise<void> {\n\t\tif (files.length === 0) return;\n\t\tconst channel: ControlChannel = await this.open();\n\n\t\tconst write: (file: SandboxFileWrite) => Promise<void> = async (\n\t\t\tfile: SandboxFileWrite,\n\t\t): Promise<void> => {\n\t\t\ttry {\n\t\t\t\tawait channel.writeFile(file.path, file.content);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`Writing ${file.path} failed: ${reason(error)}`, { cause: error });\n\t\t\t}\n\t\t};\n\n\t\tfor (let start = 0; start < files.length; start += WRITE_CONCURRENCY) {\n\t\t\t// oxlint-disable-next-line no-await-in-loop -- each chunk is parallel; the loop is the cap\n\t\t\tawait Promise.all(files.slice(start, start + WRITE_CONCURRENCY).map(write));\n\t\t}\n\t}\n\n\t/**\n\t * Clone a repository, upstream's one-liner: build a quoted `git clone` and\n\t * run it through the ordinary `exec` path. That path is what gives it a login\n\t * shell (a `git` a profile script put on PATH is found) and the accumulated\n\t * env (credential helpers read variables), and the agent kills the clone if\n\t * it is abandoned mid-transfer.\n\t */\n\tasync gitCheckout(repo: string, options?: GitCheckoutOptions): Promise<void> {\n\t\tconst result: ExecResult = await this.exec(gitCloneCommand(repo, options));\n\t\tif (!result.success) throw new Error(`git checkout failed: ${result.stderr}`);\n\t}\n\n\t/** Remembered, not sent anywhere: the pod sees these on the next command. */\n\tasync setEnvVars(vars: Record<string, string>, options?: SetEnvVarsOptions): Promise<void> {\n\t\t// Failing here names the bad key at its source; failing at the next exec\n\t\t// would blame an unrelated command.\n\t\tfor (const name of Object.keys(vars)) assertEnvName(name);\n\t\tif (options?.onlyIfUnset) {\n\t\t\tthis.envDefaults = { ...this.envDefaults, ...vars };\n\t\t} else {\n\t\t\tthis.env = { ...this.env, ...vars };\n\t\t}\n\t}\n\n\t/** Never supported here — the throw is what triggers the file-copy fallback. */\n\tasync mountBucket(_options: MountBucketOptions): Promise<void> {\n\t\tthrow new Error('mountBucket is not supported on the armada backend; using file copy fallback');\n\t}\n\n\tasync unmountBucket(_mountPath: string): Promise<void> {\n\t\t// Nothing was ever mounted.\n\t}\n\n\t/**\n\t * Launch a long-lived process (the kernel) through the agent, which parents\n\t * it: it survives this request because the agent lives for the pod's life,\n\t * its exit status is collected by a real `wait`, and its output goes to a\n\t * log the agent owns. A login shell, so profile-provided env (a PATH with\n\t * uv and python on it) reaches the kernel; its stdout is a log, not a\n\t * protocol value, so profile noise is harmless.\n\t */\n\tasync startProcess(cmd: string, options?: StartProcessOptions): Promise<SandboxProcess> {\n\t\tconst channel: ControlChannel = await this.open();\n\n\t\tconst processEnv: Record<string, string> = {};\n\t\tfor (const [name, value] of Object.entries(options?.env ?? {})) {\n\t\t\tif (value !== undefined) processEnv[name] = value;\n\t\t}\n\t\t// Per-process env is exported after the sandbox-wide vars, so it wins.\n\t\tconst command: string = withEnvPrefix(\n\t\t\twithEnvPrefix(cmd, processEnv),\n\t\t\tthis.env,\n\t\t\tthis.envDefaults,\n\t\t);\n\n\t\tlet pid: number;\n\t\ttry {\n\t\t\tpid = await channel.startProcess(['sh', '-lc', command], options?.cwd);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Starting \"${cmd}\" failed: ${reason(error)}`, { cause: error });\n\t\t}\n\t\treturn new ArmadaProcess(\n\t\t\toptions?.processId ?? `armada-proc-${String(pid)}`,\n\t\t\tcmd,\n\t\t\tchannel,\n\t\t\tthis.pod === undefined ? this.id : `${this.pod.podNamespace}/${this.pod.podName}`,\n\t\t\tpid,\n\t\t);\n\t}\n\n\t/**\n\t * The URL is the address Armada assigned, never a hostname we template, so\n\t * `options.hostname` is deliberately ignored (Armada names the\n\t * host, we read it from the event stream). The scheme follows the submit:\n\t * plain http to a NodePort on the cluster network, https to an Ingress\n\t * hostname when its TLS is on (`ARMADA_EXPOSE`).\n\t */\n\tasync exposePort(port: number, _options: ExposePortOptions): Promise<ExposePortResult> {\n\t\tawait this.ready();\n\t\tif (this.job === undefined) throw new Error(`Sandbox ${this.id} has no job after ready()`);\n\t\treturn { url: await this.armada.portUrl(this.job, port) };\n\t}\n\n\t/**\n\t * Cancelling the job deletes the pod and every object Armada created with it.\n\t *\n\t * A sandbox the reconciler addresses by id alone has no `job` in this\n\t * process, but the job set id is the sandbox id, so cancelling the set\n\t * reaches the job without a lookup. That also covers a sandbox that was\n\t * never submitted at all: cancelling an empty set is a no-op.\n\t */\n\tasync destroy(): Promise<void> {\n\t\tif (this.job === undefined) await this.armada.cancelSet(this.id, await this.queue());\n\t\telse await this.armada.cancel(this.job);\n\t\tthis.queues.forget(this.id);\n\t\tthis.placements.delete(this.id);\n\t\tthis.pod = undefined;\n\t\tthis.channel = undefined;\n\t}\n}\n\n/**\n * marimohub's wait options as the agent's probe. `http` with a path is what a\n * surface's readiness means; the kernel's own wait passes no mode and gets tcp.\n */\nfunction probeOf(options: Omit<WaitForPortOptions, 'timeout'> | undefined): PortProbe | undefined {\n\tif (options?.mode === undefined && options?.path === undefined) return undefined;\n\treturn {\n\t\t...(options.mode === undefined ? {} : { mode: options.mode }),\n\t\t...(options.path === undefined ? {} : { path: options.path }),\n\t};\n}\n\n/** A detached process in the pod, addressed by the pid the agent returned. */\nclass ArmadaProcess implements SandboxProcess {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly command: string,\n\t\tprivate readonly channel: ControlChannel,\n\t\t/** The pod, for messages. */\n\t\tprivate readonly where: string,\n\t\tprivate readonly pid: number,\n\t) {}\n\n\tasync kill(signal?: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.channel.signalProcess(this.pid, signal ?? 'TERM');\n\t\t} catch {\n\t\t\t// Killing is best effort; a process already gone is the goal reached.\n\t\t}\n\t}\n\n\t/**\n\t * `mode` and `path` go to the agent as they are: `http` with a path is open\n\t * on any HTTP answer from that path, which is what a surface's readiness\n\t * means; no mode is a TCP accept, which is all the kernel's wait needs.\n\t *\n\t * One request: the agent loops in-pod against `127.0.0.1` and watches this\n\t * process at the same time, so a kernel that dies is reported the moment it\n\t * does, worded so the provisioner classifies it as a crash, not a timeout.\n\t */\n\tasync waitForPort(port: number, options?: WaitForPortOptions): Promise<void> {\n\t\tconst timeout: number = options?.timeout ?? 30_000;\n\t\tconst wait: PortWait = await this.channel.waitForPort(\n\t\t\tport,\n\t\t\ttimeout,\n\t\t\tthis.pid,\n\t\t\tprobeOf(options),\n\t\t);\n\t\tif (wait.open) return;\n\t\tconst log: string = await this.logsQuietly();\n\t\tif (wait.exited === true) {\n\t\t\tthrow new Error(`process exited before port ${String(port)} opened.\\n${log}`.trim());\n\t\t}\n\t\tthrow new Error(\n\t\t\t`timed out waiting for port ${String(port)} in ${this.where} after ${String(timeout)}ms.\\n${log}`,\n\t\t);\n\t}\n\n\tasync getLogs(): Promise<{ stdout: string; stderr: string }> {\n\t\treturn { stdout: await this.channel.processLogs(this.pid), stderr: '' };\n\t}\n\n\t/** The log, for a failure message that is already being thrown. */\n\tprivate async logsQuietly(): Promise<string> {\n\t\ttry {\n\t\t\treturn await this.channel.processLogs(this.pid);\n\t\t} catch {\n\t\t\treturn '';\n\t\t}\n\t}\n}\n",
13
+ "import { createHash, createHmac } from 'node:crypto';\nimport type { ArmadaClient, PodLocation, SubmittedJob } from './armada.js';\nimport type { ArmadaConfig } from './config.js';\nimport type {\n\tAgentEndpoint,\n\tAgentFileEntry,\n\tCommandResult,\n\tControlChannel,\n\tListFilesOutcome,\n\tPortProbe,\n\tPortWait,\n\tReadBudget,\n\tReadFileOutcome,\n} from './channel.js';\nimport { CommandTimeoutError } from './channel.js';\nimport { buildPodSpec } from './podspec.js';\nimport type { QueueDirectory } from './queues.js';\nimport { assertEnvName, gitCloneCommand, withEnvPrefix } from './shell.js';\nimport type {\n\tBoundedReadOptions,\n\tCreateSandboxOptions,\n\tExecOptions,\n\tExecResult,\n\tExecStreamOptions,\n\tExposePortOptions,\n\tExposePortResult,\n\tFileInfo,\n\tGitCheckoutOptions,\n\tListFilesOptions,\n\tListFilesResult,\n\tMountBucketOptions,\n\tReadFileResult,\n\tSandboxFileWrite,\n\tSandboxId,\n\tSandboxInstance,\n\tSandboxProcess,\n\tSetEnvVarsOptions,\n\tStartProcessOptions,\n\tWaitForPortOptions,\n} from './types.js';\n\n/**\n * The bytes as text, or undefined when they are not valid UTF-8, which is how\n * `readFile` chooses what encoding to report. `ignoreBOM` keeps a leading BOM in\n * the string (the flag means \"do not treat it specially\"), so a file that has\n * one round-trips byte for byte.\n */\nfunction decodeUtf8(bytes: Uint8Array): string | undefined {\n\ttry {\n\t\treturn new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Control characters escaped as JSON would, so a value cannot break a log line. */\nfunction oneLine(text: string): string {\n\t// oxlint-disable-next-line no-control-regex -- matching control characters is the point\n\treturn text.replace(/[\\u0000-\\u001f\\u007f]/g, (char: string): string =>\n\t\tJSON.stringify(char).slice(1, -1),\n\t);\n}\n\nfunction reason(error: unknown): string {\n\treturn error instanceof Error ? error.message : String(error);\n}\n\n/**\n * Whether a bounded read's budget is one marimohub's port allows\n * (`BoundedReadOptions`), checked as its reference reader checks it\n * (`packages/compute-commons/src/boundedRead.ts`): a nonnegative safe integer\n * of bytes whose base64 size is safe too, and a positive deadline a timer can\n * hold.\n */\nexport function isValidBudget(options: BoundedReadOptions): boolean {\n\treturn (\n\t\tNumber.isSafeInteger(options.maxBytes) &&\n\t\toptions.maxBytes >= 0 &&\n\t\tNumber.isSafeInteger(4 * Math.ceil(options.maxBytes / 3)) &&\n\t\tNumber.isFinite(options.timeoutMs) &&\n\t\toptions.timeoutMs > 0 &&\n\t\toptions.timeoutMs <= 2 ** 31 - 1\n\t);\n}\n\n/**\n * The bearer token a sandbox's agent expects: an HMAC of the sandbox id under\n * `ARMADA_AGENT_TOKEN_SECRET`. Derived rather than minted, because marimohub\n * reaches a sandbox through a fresh `create(id)` on every path after the\n * first, teardown and the snapshot sweep included, and in another process after\n * a restart; each of them has to arrive at the token the pod was started with.\n */\nexport function agentToken(secret: string, id: SandboxId): string {\n\treturn createHmac('sha256', secret).update(id).digest('hex');\n}\n\n/**\n * Where a sandbox this process has reached lives: its job, its pod, and the\n * channel to its agent. marimohub builds a new instance for every call after\n * provisioning (each snapshot, the teardown, a surface check), and without this\n * each would resubmit the job, wait for its running event and poll the agent\n * again before doing anything. The provider holds one map for all of them.\n */\nexport interface Placement {\n\tjob: SubmittedJob;\n\tpod: PodLocation;\n\tchannel: ControlChannel;\n}\n\nexport type Placements = Map<SandboxId, Placement>;\n\n/** Each write is one request to the agent; cap how many are in flight. */\nconst WRITE_CONCURRENCY = 8;\n\n/** How long a running pod gets to answer on the agent port before `ready` gives up. */\nconst AGENT_READY_TIMEOUT_MS = 30_000;\n\n/**\n * `isPortReady` is one look, not a wait: a zero timeout makes the agent probe\n * once and answer, the probe itself bounded to the 2s marimohub's local\n * adapter allows (`agent/process.go`).\n */\nconst PORT_READY_TIMEOUT_MS = 0;\n\n/**\n * The sandbox is gone for good: its job has finished (preempted, cancelled,\n * failed, or its node lost), so no pod runs for it and none will. A finished\n * job cannot come back either, as a resubmit dedupes to it on `clientId`.\n *\n * Calls that otherwise answer a typed failure throw this instead, as\n * marimohub's own Kubernetes adapter does, because the answer marimohub needs\n * is \"gone\", not \"this one call failed\": a session whose sandbox is gone has\n * nothing left to save, and its editor claim has to be released. marimohub\n * recognises only its own `NotFoundError` as that answer, so when it hands us\n * a factory for one (`errors.notFound`) that is what is thrown, and this class\n * is the stand-in for a marimohub that does not.\n */\nexport class SandboxGoneError extends Error {\n\toverride readonly name: string = 'SandboxGoneError';\n}\n\n/** Every error made to say a sandbox is gone, whichever class it has. */\nconst goneErrors: WeakSet<Error> = new WeakSet();\n\n/** Whether `error` says the sandbox is gone, rather than that one call failed. */\nexport function isSandboxGone(error: unknown): boolean {\n\treturn error instanceof Error && goneErrors.has(error);\n}\n\n/** A non-zero exit is the command's business; marimohub wants it as a result. */\nexport function toExecResult(result: CommandResult): ExecResult {\n\tif (result.exitCode === 0) {\n\t\treturn { success: true, stdout: result.stdout, stderr: result.stderr };\n\t}\n\treturn {\n\t\tsuccess: false,\n\t\tstdout: result.stdout,\n\t\tstderr: result.stderr,\n\t\terror: { code: 'COMMAND_FAILED' },\n\t};\n}\n\n/**\n * The agent's listing as marimohub's `FileInfo` records.\n *\n * Hiding is done here rather than in the agent's walk, so a recursive listing\n * still descends into a dot directory and reports its non-dot children, which\n * is what upstream does and what `readSessionArtifacts` needs for `__marimo__`\n * trees: each entry is judged on its own name alone.\n */\nexport function toFileInfos(\n\tentries: readonly AgentFileEntry[],\n\trootPath: string,\n\toptions?: ListFilesOptions,\n): FileInfo[] {\n\tconst files: FileInfo[] = [];\n\tfor (const entry of entries) {\n\t\tconst name: string = entry.path.slice(entry.path.lastIndexOf('/') + 1);\n\t\tif (options?.includeHidden !== true && name.startsWith('.')) continue;\n\t\tfiles.push({\n\t\t\tname,\n\t\t\tabsolutePath: entry.path,\n\t\t\trelativePath: entry.path.startsWith(rootPath)\n\t\t\t\t? entry.path.slice(rootPath.length).replace(/^\\//, '')\n\t\t\t\t: entry.path,\n\t\t\ttype: entry.type,\n\t\t\tsize: entry.size,\n\t\t});\n\t}\n\treturn files;\n}\n\n/**\n * One kernel session, backed by one Armada job.\n *\n * Resolution is lazy: `create()` is synchronous and id-addressed, so the job is\n * submitted on first use. An instance from `connectExisting` never submits: it\n * finds the job the sandbox already has, and fails every call when there is\n * none (`attachOnly`). Commands run through the agent's `/exec`; detached\n * processes and files go through its own endpoints, so nothing here builds a\n * shell command beyond the env prefix and the quoted `git clone`.\n */\nexport class ArmadaSandbox implements SandboxInstance {\n\t/** Armada cannot mount a bucket; the provisioner falls back to copying files. */\n\treadonly supportsBucketMount = false;\n\n\tprivate job?: SubmittedJob;\n\tprivate pod?: PodLocation | undefined;\n\t/** The agent in the pod, once `ready` has reached it. */\n\tprivate channel?: ControlChannel | undefined;\n\t/** The bearer token this sandbox's agent expects. The pod carries only its hash. */\n\tprivate readonly token: string;\n\t/** Settled by `queue()`, and fixed for the life of the sandbox once it is. */\n\n\t/**\n\t * The pod's environment is fixed at submission, so `setEnvVars` accumulates\n\t * here and is replayed as an `export` prefix on every later command, the way\n\t * marimohub's kubernetes adapter does it. `envDefaults` holds the\n\t * `onlyIfUnset` vars, exported behind a guard so any existing value wins.\n\t */\n\tprivate env: Record<string, string> = {};\n\tprivate envDefaults: Record<string, string> = {};\n\n\tconstructor(\n\t\tprivate readonly id: SandboxId,\n\t\tprivate readonly config: ArmadaConfig,\n\t\tprivate readonly armada: ArmadaClient,\n\t\tprivate readonly openChannel: (endpoint: AgentEndpoint) => ControlChannel,\n\t\tprivate readonly queues: QueueDirectory,\n\t\tprivate readonly placements: Placements,\n\t\tprivate readonly options?: CreateSandboxOptions,\n\t\t/**\n\t\t * Reach the job the sandbox already has, never submit one. marimohub\n\t\t * attaches this way to save an expired session's edits before reclaiming\n\t\t * it, and a fresh pod there would be an empty workspace to capture.\n\t\t */\n\t\tprivate readonly attachOnly: boolean = false,\n\t\t/** Makes the error a gone sandbox is reported with ({@link SandboxGoneError}). */\n\t\tprivate readonly notFound: (message: string) => Error = (message: string): Error =>\n\t\t\tnew SandboxGoneError(message),\n\t) {\n\t\tthis.token = agentToken(config.agentTokenSecret, id);\n\t}\n\n\t/** The error for this sandbox being gone, recognisable by {@link isSandboxGone}. */\n\tprivate gone(message: string): Error {\n\t\tconst error: Error = this.notFound(message);\n\t\tgoneErrors.add(error);\n\t\treturn error;\n\t}\n\n\t/**\n\t * Submit the job, block until its pod is running, and reach the agent in it.\n\t *\n\t * Idempotent: marimohub calls this before each use, and the submission dedupes\n\t * on `clientId` anyway, so a second call on a started sandbox does nothing.\n\t *\n\t * The token ({@link agentToken}) never leaves this process except in request\n\t * headers to the one pod that knows its hash. The pod spec, which anyone with\n\t * read access to the job can fetch, carries the hash alone. A resubmit that\n\t * Armada dedupes to the running job carries the same hash, since the token\n\t * depends on the id alone.\n\t *\n\t * A sandbox another instance in this process already reached is taken from\n\t * {@link Placements} after one look at the agent's health, which is what\n\t * tells a live pod from one that has since gone; a gone one is resolved\n\t * again from the start.\n\t *\n\t * Resolving again is where a sandbox whose job has finished is caught. The\n\t * submit dedupes to that finished job, and its event stream replays the old\n\t * `Running`, so without asking for the job's state first this would go on\n\t * to wait out the agent timeout against a pod that no longer exists, once\n\t * per call marimohub makes.\n\t */\n\tasync ready(): Promise<void> {\n\t\tif (this.channel !== undefined) return;\n\t\tconst known: Placement | undefined = this.placements.get(this.id);\n\t\tif (known !== undefined) {\n\t\t\ttry {\n\t\t\t\tawait known.channel.ready(0);\n\t\t\t\tthis.job = known.job;\n\t\t\t\tthis.pod = known.pod;\n\t\t\t\tthis.channel = known.channel;\n\t\t\t\treturn;\n\t\t\t} catch {\n\t\t\t\tthis.placements.delete(this.id);\n\t\t\t}\n\t\t}\n\t\tthis.job ??= this.attachOnly ? await this.existingJob() : await this.submit();\n\t\t// An attached job was found unfinished a moment ago; a submitted one may be\n\t\t// a finished job handed back by the dedupe. The check is an early exit, not\n\t\t// a gate: it reads the database Lookout's ingester fills, which can be\n\t\t// down or slow while submit and the event stream work, so a check that fails\n\t\t// or runs past its short deadline counts as \"not finished\" and the wait below\n\t\t// behaves as it did before the check.\n\t\tconst finished: boolean =\n\t\t\t!this.attachOnly && (await this.armada.isFinished(this.job).catch(() => false));\n\t\tif (finished) {\n\t\t\tthrow this.gone(\n\t\t\t\t`Sandbox ${this.id} is gone: its Armada job ${this.job.jobId} has finished, and a finished job is never started again`,\n\t\t\t);\n\t\t}\n\t\tthis.pod = await this.armada.waitForRunning(this.job);\n\t\t// The agent's address comes from the same event as the kernel's.\n\t\tconst url: string = await this.armada.portUrl(this.job, this.config.agentPort);\n\t\tconst channel: ControlChannel = this.openChannel({ url, token: this.token, pod: this.pod });\n\t\tawait channel.ready(AGENT_READY_TIMEOUT_MS);\n\t\tthis.channel = channel;\n\t\tthis.placements.set(this.id, { job: this.job, pod: this.pod, channel });\n\t}\n\n\tprivate async submit(): Promise<SubmittedJob> {\n\t\tconst tokenSha256: string = createHash('sha256').update(this.token).digest('hex');\n\t\treturn this.armada.submit(\n\t\t\tthis.id,\n\t\t\tbuildPodSpec(this.config, { tokenSha256 }, this.options),\n\t\t\tawait this.queue(),\n\t\t);\n\t}\n\n\t/**\n\t * The sandbox's unfinished job, for an `attachOnly` instance. Its absence is\n\t * the answer marimohub needs, so it is thrown as the sandbox being gone\n\t * ({@link SandboxGoneError}) by every call that asked, never folded into a\n\t * failed result.\n\t */\n\tprivate async existingJob(): Promise<SubmittedJob> {\n\t\tconst queue: string = await this.queue();\n\t\tconst job: SubmittedJob | undefined = await this.armada.findJob(this.id, queue);\n\t\tif (job === undefined) {\n\t\t\tthrow this.gone(\n\t\t\t\t`Sandbox ${this.id} has no unfinished job in queue \"${queue}\" to attach to, and attaching never submits one`,\n\t\t\t);\n\t\t}\n\t\treturn job;\n\t}\n\n\t/** Where the pod landed, once it has. For reporting, not for reaching it. */\n\tget placement(): PodLocation | undefined {\n\t\treturn this.pod;\n\t}\n\n\t/**\n\t * The queue this sandbox's job is in, or will be submitted to: the job's own\n\t * once submitted here, else what this process or Lookout knows of the\n\t * sandbox, else where the owner marimohub named maps to (`src/queues.ts`).\n\t */\n\tasync queue(): Promise<string> {\n\t\treturn this.job?.queue ?? this.queues.resolve(this.id, this.options?.owner);\n\t}\n\n\t/**\n\t * One probe of a port, for marimohub's surface manager checking whether a\n\t * surface it started earlier still answers. Without this it runs a\n\t * `python3` one-liner in the pod; the agent answers the same question from\n\t * inside without needing an interpreter. Anything but a clean answer is\n\t * \"not ready\", as marimohub's own adapters treat it, since the caller's\n\t * remedy is the same either way: start the surface again. Only the probe is\n\t * treated that way: a sandbox this process has not reached cannot have a\n\t * surface listening, and is not submitted or waited for to find that out.\n\t * One another instance reached counts as reached, since marimohub asks\n\t * through a fresh instance.\n\t */\n\tasync isPortReady(port: number, options?: Omit<WaitForPortOptions, 'timeout'>): Promise<boolean> {\n\t\tconst channel: ControlChannel | undefined =\n\t\t\tthis.channel ?? this.placements.get(this.id)?.channel;\n\t\tif (channel === undefined) return false;\n\t\ttry {\n\t\t\tconst wait: PortWait = await channel.waitForPort(\n\t\t\t\tport,\n\t\t\t\tPORT_READY_TIMEOUT_MS,\n\t\t\t\tundefined,\n\t\t\t\tprobeOf({ ...options, mode: options?.mode ?? 'http' }),\n\t\t\t);\n\t\t\treturn wait.open;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Everything above this method is built on the channel, so this is the one\n\t * that has to be right. A command that fails is a normal result, not an\n\t * exception; only the channel itself failing is a `BACKEND_ERROR`. A\n\t * sandbox that is gone throws ({@link SandboxGoneError}): that is not this\n\t * command failing, and marimohub's kernel probe reads any failed result as\n\t * \"unknown\", which keeps a lost session's editor claim for good.\n\t *\n\t * A login shell, matching marimohub's kubernetes adapter: what arrives here is\n\t * user and provisioner code, and an image that puts `uv` or `python3` on the\n\t * PATH through a profile script has to keep working.\n\t *\n\t * The caller's timeout goes to the agent, which kills the command's process\n\t * group at the deadline. A command with no timeout gets\n\t * `ARMADA_COMMAND_MAX_SECONDS` instead: most of marimohub's exec calls carry\n\t * none because the work legitimately takes minutes, and this is the\n\t * hours-later answer to \"nobody expected this to still be running\", which\n\t * would otherwise hold a request and a process for the rest of the session.\n\t */\n\tasync exec(cmd: string, options?: ExecOptions): Promise<ExecResult> {\n\t\tconst command: string = withEnvPrefix(cmd, this.env, this.envDefaults);\n\t\tconst timeout: number | undefined = options?.timeout;\n\t\tconst backstopMs: number | undefined =\n\t\t\ttimeout === undefined && this.config.commandMaxSeconds > 0\n\t\t\t\t? this.config.commandMaxSeconds * 1000\n\t\t\t\t: undefined;\n\t\tconst deadline: number | undefined = timeout ?? backstopMs;\n\t\ttry {\n\t\t\tconst channel: ControlChannel = await this.open();\n\t\t\tconst result: CommandResult = await channel.run(\n\t\t\t\t['sh', '-lc', command],\n\t\t\t\tdeadline === undefined ? {} : { timeoutMs: deadline },\n\t\t\t);\n\t\t\treturn toExecResult(result);\n\t\t} catch (error) {\n\t\t\tif (isSandboxGone(error)) throw error;\n\t\t\tconst stderr: string =\n\t\t\t\terror instanceof CommandTimeoutError && backstopMs !== undefined\n\t\t\t\t\t? `Command ran past ARMADA_COMMAND_MAX_SECONDS (${String(this.config.commandMaxSeconds)}s) and was killed: ${cmd}`\n\t\t\t\t\t: reason(error);\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\tstdout: '',\n\t\t\t\tstderr,\n\t\t\t\terror: { code: 'BACKEND_ERROR' },\n\t\t\t};\n\t\t}\n\t}\n\n\t/** The agent, submitting the job and waiting for its pod first if nobody has yet. */\n\tprivate async open(): Promise<ControlChannel> {\n\t\tif (this.channel === undefined) await this.ready();\n\t\tif (this.channel === undefined)\n\t\t\tthrow new Error(`Sandbox ${this.id} has no agent after ready()`);\n\t\treturn this.channel;\n\t}\n\n\t/**\n\t * The same command as `exec`, with its stdout arriving as it is produced.\n\t *\n\t * A login shell, like `exec`: this runs whatever the caller asked for. Unlike\n\t * `exec` there is no typed failure to return, so a control channel that\n\t * cannot be reached throws here rather than resolving to a `BACKEND_ERROR`\n\t * stream. Cancelling, or the timeout passing, closes the request, and the\n\t * agent kills the command's process group when it sees that.\n\t */\n\tasync execStream(cmd: string, options?: ExecStreamOptions): Promise<ReadableStream> {\n\t\tconst channel: ControlChannel = await this.open();\n\t\tconst command: string = withEnvPrefix(cmd, this.env, this.envDefaults);\n\t\treturn channel.stream(\n\t\t\t['sh', '-lc', command],\n\t\t\toptions?.timeout === undefined ? {} : { timeoutMs: options.timeout },\n\t\t);\n\t}\n\n\t/**\n\t * Read one file back out of the pod.\n\t *\n\t * The bytes cross raw, and the encoding we report is decided from them: text\n\t * is returned decoded, because marimohub's `readSessionArtifacts` takes\n\t * `content` and never looks at `encoding`, and anything that is not valid\n\t * UTF-8 is returned as base64, which is what `proposalCapture` decodes.\n\t * Reporting base64 unconditionally would store base64 as the notebook\n\t * source; reporting UTF-8 unconditionally would corrupt an image the user\n\t * changed.\n\t *\n\t * Unlike upstream, an absent path is `NOT_FOUND` rather than `READ_FAILED`.\n\t * Session capture reads four fixed paths of which some routinely do not\n\t * exist, so \"never written\" is the common answer and worth distinguishing\n\t * from \"could not be read\". The agent's `not_found` carries it.\n\t */\n\tasync readFile(path: string): Promise<ReadFileResult> {\n\t\treturn this.readThrough(\n\t\t\tpath,\n\t\t\tasync (channel: ControlChannel): Promise<ReadFileOutcome> => channel.readFile(path),\n\t\t\t(bytes: Uint8Array): ReadFileResult => {\n\t\t\t\tconst text: string | undefined = decodeUtf8(bytes);\n\t\t\t\treturn text === undefined\n\t\t\t\t\t? { success: true, content: Buffer.from(bytes).toString('base64'), encoding: 'base64' }\n\t\t\t\t\t: { success: true, content: text, encoding: 'utf-8' };\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * The read marimohub's session capture makes from `main` f4e5ef8 on, and\n\t * without which it captures nothing at all. The agent does the refusing\n\t * where the file is (`agent/files.go`): no symlink anywhere in the path,\n\t * regular files only, at most `maxBytes`, answered by the deadline. A\n\t * budget marimohub's port does not allow is refused here, before the job is\n\t * submitted or the agent asked, as upstream's contract test requires.\n\t *\n\t * Always base64, as upstream's reference reader answers. The guess\n\t * `readFile` makes from the bytes is there for a consumer that ignores\n\t * `encoding`; the bounded read's consumer (`readBoundedBytes`) decodes by\n\t * it and then re-checks the size, so base64 is exact and never wrong.\n\t *\n\t * The deadline bounds the read, not reaching the pod: a sandbox this\n\t * process has not reached yet is resolved first, as for every other call.\n\t */\n\tasync readFileBounded(path: string, options: BoundedReadOptions): Promise<ReadFileResult> {\n\t\tif (!isValidBudget(options)) {\n\t\t\treturn this.readFailed(\n\t\t\t\tpath,\n\t\t\t\t'READ_FAILED',\n\t\t\t\t`maxBytes ${String(options.maxBytes)} and timeoutMs ${String(options.timeoutMs)} are not a valid budget`,\n\t\t\t);\n\t\t}\n\t\tconst budget: ReadBudget = {\n\t\t\tmaxBytes: options.maxBytes,\n\t\t\ttimeoutMs: Math.ceil(options.timeoutMs),\n\t\t};\n\t\treturn this.readThrough(\n\t\t\tpath,\n\t\t\tasync (channel: ControlChannel): Promise<ReadFileOutcome> =>\n\t\t\t\tchannel.readFileBounded(path, budget),\n\t\t\t(bytes: Uint8Array): ReadFileResult => ({\n\t\t\t\tsuccess: true,\n\t\t\t\tcontent: Buffer.from(bytes).toString('base64'),\n\t\t\t\tencoding: 'base64',\n\t\t\t}),\n\t\t);\n\t}\n\n\t/**\n\t * One read through the agent, as marimohub's result: the bytes as `encode`\n\t * words them, `NOT_FOUND` quietly, and any other failure through\n\t * {@link readFailed}, with a channel that cannot be reached a `BACKEND_ERROR`.\n\t * A sandbox that is gone throws, as for `exec`.\n\t */\n\tprivate async readThrough(\n\t\tpath: string,\n\t\tread: (channel: ControlChannel) => Promise<ReadFileOutcome>,\n\t\tencode: (bytes: Uint8Array) => ReadFileResult,\n\t): Promise<ReadFileResult> {\n\t\tlet outcome: ReadFileOutcome;\n\t\ttry {\n\t\t\toutcome = await read(await this.open());\n\t\t} catch (error) {\n\t\t\tif (isSandboxGone(error)) throw error;\n\t\t\treturn this.readFailed(path, 'BACKEND_ERROR', reason(error));\n\t\t}\n\t\tif (outcome.outcome === 'not-found') {\n\t\t\treturn { success: false, content: '', error: { code: 'NOT_FOUND' } };\n\t\t}\n\t\tif (outcome.outcome === 'failed') {\n\t\t\treturn this.readFailed(path, 'READ_FAILED', outcome.message);\n\t\t}\n\t\treturn encode(outcome.bytes);\n\t}\n\n\t/**\n\t * A failed read, reported as marimohub expects and said once on stderr. A\n\t * file marimohub cannot read back it leaves out without a word, and a\n\t * session whose notebook is left out commits nothing and is then destroyed,\n\t * so this line is the only trace of edits lost that way. `NOT_FOUND` never\n\t * comes here: capture reads paths that routinely do not exist. The token is\n\t * masked anywhere in the line, in case a transport error ever quotes a\n\t * header or a path happens to hold it, and control\n\t * characters are escaped, since a workspace file name may hold a newline.\n\t */\n\tprivate readFailed(\n\t\tpath: string,\n\t\tcode: 'READ_FAILED' | 'BACKEND_ERROR',\n\t\twhy: string,\n\t): ReadFileResult {\n\t\tconst line: string = `marimohub-compute-armada: sandbox ${this.id} could not read ${oneLine(path)} (${code}): ${oneLine(why)}`;\n\t\tconsole.warn(line.replaceAll(this.token, '<token>'));\n\t\treturn { success: false, content: '', error: { code } };\n\t}\n\n\t/**\n\t * List a directory, which session capture uses to size the files it is about\n\t * to read and to enumerate a workspace. The agent walks the tree itself and\n\t * answers structured records; only the hidden-file filter and the relative\n\t * paths are decided here ({@link toFileInfos}). A sandbox that is gone\n\t * throws, as for `exec`.\n\t */\n\tasync listFiles(path: string, options?: ListFilesOptions): Promise<ListFilesResult> {\n\t\tlet listed: ListFilesOutcome;\n\t\ttry {\n\t\t\tlisted = await (await this.open()).listFiles(path, options?.recursive === true);\n\t\t} catch (error) {\n\t\t\tif (isSandboxGone(error)) throw error;\n\t\t\treturn { success: false, files: [], error: { code: 'BACKEND_ERROR' } };\n\t\t}\n\t\tif (listed.outcome === 'not-a-directory') {\n\t\t\treturn { success: false, files: [], error: { code: 'NOT_A_DIRECTORY' } };\n\t\t}\n\t\tif (listed.outcome === 'failed') {\n\t\t\treturn { success: false, files: [], error: { code: 'LIST_FAILED' } };\n\t\t}\n\t\treturn { success: true, files: toFileInfos(listed.entries, path, options) };\n\t}\n\n\t/**\n\t * One request per file, bytes in the body: nothing is quoted, nothing passes\n\t * through a shell, and `Uint8Array` content arrives verbatim.\n\t */\n\tasync writeFiles(files: readonly SandboxFileWrite[]): Promise<void> {\n\t\tif (files.length === 0) return;\n\t\tconst channel: ControlChannel = await this.open();\n\n\t\tconst write: (file: SandboxFileWrite) => Promise<void> = async (\n\t\t\tfile: SandboxFileWrite,\n\t\t): Promise<void> => {\n\t\t\ttry {\n\t\t\t\tawait channel.writeFile(file.path, file.content);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new Error(`Writing ${file.path} failed: ${reason(error)}`, { cause: error });\n\t\t\t}\n\t\t};\n\n\t\tfor (let start = 0; start < files.length; start += WRITE_CONCURRENCY) {\n\t\t\t// oxlint-disable-next-line no-await-in-loop -- each chunk is parallel; the loop is the cap\n\t\t\tawait Promise.all(files.slice(start, start + WRITE_CONCURRENCY).map(write));\n\t\t}\n\t}\n\n\t/**\n\t * Clone a repository, upstream's one-liner: build a quoted `git clone` and\n\t * run it through the ordinary `exec` path. That path is what gives it a login\n\t * shell (a `git` a profile script put on PATH is found) and the accumulated\n\t * env (credential helpers read variables), and the agent kills the clone if\n\t * it is abandoned mid-transfer.\n\t */\n\tasync gitCheckout(repo: string, options?: GitCheckoutOptions): Promise<void> {\n\t\tconst result: ExecResult = await this.exec(gitCloneCommand(repo, options));\n\t\tif (!result.success) throw new Error(`git checkout failed: ${result.stderr}`);\n\t}\n\n\t/** Remembered, not sent anywhere: the pod sees these on the next command. */\n\tasync setEnvVars(vars: Record<string, string>, options?: SetEnvVarsOptions): Promise<void> {\n\t\t// Failing here names the bad key at its source; failing at the next exec\n\t\t// would blame an unrelated command.\n\t\tfor (const name of Object.keys(vars)) assertEnvName(name);\n\t\tif (options?.onlyIfUnset) {\n\t\t\tthis.envDefaults = { ...this.envDefaults, ...vars };\n\t\t} else {\n\t\t\tthis.env = { ...this.env, ...vars };\n\t\t}\n\t}\n\n\t/** Never supported here — the throw is what triggers the file-copy fallback. */\n\tasync mountBucket(_options: MountBucketOptions): Promise<void> {\n\t\tthrow new Error('mountBucket is not supported on the armada backend; using file copy fallback');\n\t}\n\n\tasync unmountBucket(_mountPath: string): Promise<void> {\n\t\t// Nothing was ever mounted.\n\t}\n\n\t/**\n\t * Launch a long-lived process (the kernel) through the agent, which parents\n\t * it: it survives this request because the agent lives for the pod's life,\n\t * its exit status is collected by a real `wait`, and its output goes to a\n\t * log the agent owns. A login shell, so profile-provided env (a PATH with\n\t * uv and python on it) reaches the kernel; its stdout is a log, not a\n\t * protocol value, so profile noise is harmless.\n\t */\n\tasync startProcess(cmd: string, options?: StartProcessOptions): Promise<SandboxProcess> {\n\t\tconst channel: ControlChannel = await this.open();\n\n\t\tconst processEnv: Record<string, string> = {};\n\t\tfor (const [name, value] of Object.entries(options?.env ?? {})) {\n\t\t\tif (value !== undefined) processEnv[name] = value;\n\t\t}\n\t\t// Per-process env is exported after the sandbox-wide vars, so it wins.\n\t\tconst command: string = withEnvPrefix(\n\t\t\twithEnvPrefix(cmd, processEnv),\n\t\t\tthis.env,\n\t\t\tthis.envDefaults,\n\t\t);\n\n\t\tlet pid: number;\n\t\ttry {\n\t\t\tpid = await channel.startProcess(['sh', '-lc', command], options?.cwd);\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Starting \"${cmd}\" failed: ${reason(error)}`, { cause: error });\n\t\t}\n\t\treturn new ArmadaProcess(\n\t\t\toptions?.processId ?? `armada-proc-${String(pid)}`,\n\t\t\tcmd,\n\t\t\tchannel,\n\t\t\tthis.pod === undefined ? this.id : `${this.pod.podNamespace}/${this.pod.podName}`,\n\t\t\tpid,\n\t\t);\n\t}\n\n\t/**\n\t * The URL is the address Armada assigned, never a hostname we template, so\n\t * `options.hostname` is deliberately ignored (Armada names the\n\t * host, we read it from the event stream). The scheme follows the submit:\n\t * plain http to a NodePort on the cluster network, https to an Ingress\n\t * hostname when its TLS is on (`ARMADA_EXPOSE`).\n\t */\n\tasync exposePort(port: number, _options: ExposePortOptions): Promise<ExposePortResult> {\n\t\tawait this.ready();\n\t\tif (this.job === undefined) throw new Error(`Sandbox ${this.id} has no job after ready()`);\n\t\treturn { url: await this.armada.portUrl(this.job, port) };\n\t}\n\n\t/**\n\t * Cancelling the job deletes the pod and every object Armada created with it.\n\t *\n\t * A sandbox the reconciler addresses by id alone has no `job` in this\n\t * process, but the job set id is the sandbox id, so cancelling the set\n\t * reaches the job without a lookup. That also covers a sandbox that was\n\t * never submitted at all: cancelling an empty set is a no-op.\n\t */\n\tasync destroy(): Promise<void> {\n\t\tif (this.job === undefined) await this.armada.cancelSet(this.id, await this.queue());\n\t\telse await this.armada.cancel(this.job);\n\t\tthis.queues.forget(this.id);\n\t\tthis.placements.delete(this.id);\n\t\tthis.pod = undefined;\n\t\tthis.channel = undefined;\n\t}\n}\n\n/**\n * marimohub's wait options as the agent's probe. `http` with a path is what a\n * surface's readiness means; the kernel's own wait passes no mode and gets tcp.\n */\nfunction probeOf(options: Omit<WaitForPortOptions, 'timeout'> | undefined): PortProbe | undefined {\n\tif (options?.mode === undefined && options?.path === undefined) return undefined;\n\treturn {\n\t\t...(options.mode === undefined ? {} : { mode: options.mode }),\n\t\t...(options.path === undefined ? {} : { path: options.path }),\n\t};\n}\n\n/** A detached process in the pod, addressed by the pid the agent returned. */\nclass ArmadaProcess implements SandboxProcess {\n\tconstructor(\n\t\treadonly id: string,\n\t\treadonly command: string,\n\t\tprivate readonly channel: ControlChannel,\n\t\t/** The pod, for messages. */\n\t\tprivate readonly where: string,\n\t\tprivate readonly pid: number,\n\t) {}\n\n\tasync kill(signal?: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.channel.signalProcess(this.pid, signal ?? 'TERM');\n\t\t} catch {\n\t\t\t// Killing is best effort; a process already gone is the goal reached.\n\t\t}\n\t}\n\n\t/**\n\t * `mode` and `path` go to the agent as they are: `http` with a path is open\n\t * on any HTTP answer from that path, which is what a surface's readiness\n\t * means; no mode is a TCP accept, which is all the kernel's wait needs.\n\t *\n\t * One request: the agent loops in-pod against `127.0.0.1` and watches this\n\t * process at the same time, so a kernel that dies is reported the moment it\n\t * does, worded so the provisioner classifies it as a crash, not a timeout.\n\t */\n\tasync waitForPort(port: number, options?: WaitForPortOptions): Promise<void> {\n\t\tconst timeout: number = options?.timeout ?? 30_000;\n\t\tconst wait: PortWait = await this.channel.waitForPort(\n\t\t\tport,\n\t\t\ttimeout,\n\t\t\tthis.pid,\n\t\t\tprobeOf(options),\n\t\t);\n\t\tif (wait.open) return;\n\t\tconst log: string = await this.logsQuietly();\n\t\tif (wait.exited === true) {\n\t\t\tthrow new Error(`process exited before port ${String(port)} opened.\\n${log}`.trim());\n\t\t}\n\t\tthrow new Error(\n\t\t\t`timed out waiting for port ${String(port)} in ${this.where} after ${String(timeout)}ms.\\n${log}`,\n\t\t);\n\t}\n\n\tasync getLogs(): Promise<{ stdout: string; stderr: string }> {\n\t\treturn { stdout: await this.channel.processLogs(this.pid), stderr: '' };\n\t}\n\n\t/** The log, for a failure message that is already being thrown. */\n\tprivate async logsQuietly(): Promise<string> {\n\t\ttry {\n\t\t\treturn await this.channel.processLogs(this.pid);\n\t\t} catch {\n\t\t\treturn '';\n\t\t}\n\t}\n}\n",
14
14
  "/**\n * Shell-building helpers for commands run through the agent's `/exec`.\n *\n * Semantics transcribed from marimohub's `@marimo-hub/compute-commons` (v0.4.2, unchanged since v0.3.12),\n * like `src/types.ts`, so this adapter behaves the same as marimohub's own\n * pod-exec backends. Replace with an import once the packages are published.\n *\n * Only `exec` and its relatives need a shell; files and processes go through\n * the agent's own endpoints (`src/channel.ts`). So this is the env prefix and\n * quoting that `exec` needs, the quoted clone, and the stray-process check the\n * smoke run uses.\n */\n\n/**\n * Single-quote a value for safe interpolation into an `sh -c` string. An\n * embedded single quote becomes the classic `'\\''` sequence, so the result is\n * injection-safe for arbitrary input (paths, repo URLs, env values).\n */\nexport function shellQuote(value: string): string {\n\treturn `'${value.replaceAll(\"'\", `'\\\\''`)}'`;\n}\n\n/**\n * Prefix `cmd` with `export K='v'; …` for the accumulated env vars, because the\n * pod's environment is fixed once it starts. Values are {@link shellQuote}d.\n *\n * `defaults` are fallbacks (`setEnvVars` with `onlyIfUnset`): each is exported\n * behind a `[ -n \"${K:-}\" ]` guard, so a value the sandbox already defines (image\n * ENV, profile script, or a forced export from `env`) wins. The guards come\n * after the forced exports, which is what lets a key present in both resolve to\n * the forced value.\n */\nexport function withEnvPrefix(\n\tcmd: string,\n\tenv: Record<string, string>,\n\tdefaults: Record<string, string> = {},\n): string {\n\tconst forced: string[] = Object.entries(env).map(\n\t\t([key, value]: [string, string]) => `export ${assertEnvName(key)}=${shellQuote(value)}; `,\n\t);\n\tconst guarded: string[] = Object.entries(defaults).map(\n\t\t([key, value]: [string, string]) =>\n\t\t\t`[ -n \"\\${${assertEnvName(key)}:-}\" ] || export ${key}=${shellQuote(value)}; `,\n\t);\n\treturn forced.join('') + guarded.join('') + cmd;\n}\n\n/**\n * Names are interpolated unquoted, so anything `sh` would not accept as a\n * variable name must fail here, as a clear error instead of in-pod shell noise.\n */\nexport function assertEnvName(name: string): string {\n\tif (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {\n\t\tthrow new Error(`Invalid environment variable name: ${JSON.stringify(name)}`);\n\t}\n\treturn name;\n}\n\n/**\n * Build a `git clone` command, upstream's `buildGitCloneCommand` verbatim: the\n * repo, branch and target are all {@link shellQuote}d, closing the injection\n * hole that interpolating them raw would open, and the target defaults to `.`,\n * the working directory the caller is already in.\n */\nexport function gitCloneCommand(\n\trepo: string,\n\toptions?: { branch?: string; targetDir?: string },\n): string {\n\tconst parts: string[] = ['git', 'clone'];\n\tif (options?.branch !== undefined) parts.push('--branch', shellQuote(options.branch));\n\tparts.push(shellQuote(repo), shellQuote(options?.targetDir ?? '.'));\n\treturn parts.join(' ');\n}\n\n/**\n * Report every process in the pod except PID 1 and the shell doing the asking.\n *\n * A leak check, for `dev/smoke.ts`. It reads `/proc` rather than running `ps`\n * because the kernel image has no `procps`: `ps` prints nothing at all there,\n * which would make an empty result look like a clean pod. Records are\n * NUL-separated `pid<TAB>state<TAB>command`, and the state is reported so a\n * zombie left behind by a PID 1 that never reaps is visible rather than\n * indistinguishable from a live process.\n *\n * The asking shell skips itself and its own children, since `$(...)` in the\n * loop forks and those forks are not news.\n */\nexport function strayProcessCommand(): string {\n\treturn (\n\t\t'self=$$; for dir in /proc/[0-9]*; do pid=${dir#/proc/}; ' +\n\t\t'[ \"$pid\" = 1 ] && continue; [ \"$pid\" = \"$self\" ] && continue; ' +\n\t\t\"rest=$(sed 's/^.*) //' $dir/stat 2>/dev/null) || continue; \" +\n\t\t'set -- $rest; [ \"$2\" = \"$self\" ] && continue; ' +\n\t\t\"cmd=$(tr '\\\\0' ' ' < $dir/cmdline 2>/dev/null); \" +\n\t\t'printf \\'%s\\\\t%s\\\\t%s\\\\0\\' \"$pid\" \"$1\" \"$cmd\"; done'\n\t);\n}\n\n/** One process {@link strayProcessCommand} found. */\nexport interface StrayProcess {\n\tpid: string;\n\t/** The `/proc/<pid>/stat` state field; `Z` is a zombie nobody reaped. */\n\tstate: string;\n\t/** The command line, empty for a zombie, which no longer has one. */\n\tcommand: string;\n}\n\n/** Parse the NUL-separated records {@link strayProcessCommand} printed. */\nexport function parseStrayProcesses(stdout: string): StrayProcess[] {\n\tconst found: StrayProcess[] = [];\n\tfor (const record of stdout.split('\\0')) {\n\t\t// The command terminates each record with a NUL, so the split leaves a\n\t\t// trailing empty string, and a clean pod produces nothing else.\n\t\tif (record === '') continue;\n\t\tconst [pid, state, ...rest] = record.split('\\t');\n\t\t// Without a pid there is nothing to report and nothing to kill.\n\t\tif (pid === undefined || pid === '') continue;\n\t\tfound.push({ pid, state: state ?? '', command: rest.join('\\t').trim() });\n\t}\n\treturn found;\n}\n",
15
- "import { ArmadaClient } from './armada.js';\nimport type { ActiveJob } from './armada.js';\nimport { AgentChannel } from './channel.js';\nimport type { AgentEndpoint, ControlChannel } from './channel.js';\nimport type { ArmadaConfig } from './config.js';\nimport { QueueDirectory } from './queues.js';\nimport { ArmadaSandbox } from './sandbox.js';\nimport type { Placements } from './sandbox.js';\nimport type { ActiveSandbox, CreateSandboxOptions, SandboxId, SandboxProvider } from './types.js';\n\nexport class ArmadaCompute implements SandboxProvider {\n\tprivate readonly armada: ArmadaClient;\n\t/** Which queue each sandbox is in, shared by every sandbox this provider makes. */\n\tprivate readonly queues: QueueDirectory;\n\t/** The job, pod and agent channel of each sandbox reached, shared the same way. */\n\tprivate readonly placements: Placements = new Map();\n\n\t/**\n\t * Present only when `ARMADA_LOOKOUT_URL` is configured, because marimohub\n\t * treats the optional members of `SandboxProvider` as capability flags:\n\t * declaring a `listActive` we cannot answer would make every reconciliation\n\t * sweep fail, where its absence makes reconciliation a clean no-op.\n\t */\n\treadonly listActive?: () => Promise<ActiveSandbox[]>;\n\n\t/**\n\t * Every pod declares the enabled surfaces' ports next to the kernel's and\n\t * Armada exposes them all, so a second port has an address exactly when a\n\t * surface is configured. marimohub refuses to start a surface otherwise.\n\t *\n\t * The profile flags are what make marimohub (0.4.13 onwards) offer compute\n\t * profiles at all and pass their `resources` to `create`.\n\t */\n\treadonly capabilities: { multiPort: boolean; computeProfiles: boolean; gpuProfiles: boolean };\n\n\tconstructor(private readonly config: ArmadaConfig) {\n\t\tthis.armada = new ArmadaClient(config);\n\t\tthis.capabilities = {\n\t\t\tmultiPort: config.surfacePorts.length > 0,\n\t\t\t// CPU and memory become the kernel container's requests and limits.\n\t\t\tcomputeProfiles: true,\n\t\t\t// A GPU count alone would put an `A100` profile on any GPU node, so GPU\n\t\t\t// profiles are offered only once each type maps to a node selector.\n\t\t\tgpuProfiles: Object.keys(config.gpuNodeSelectors).length > 0,\n\t\t};\n\t\t// `findQueue` answers `undefined` by itself when Lookout is not configured.\n\t\tthis.queues = new QueueDirectory(config, async (id: SandboxId): Promise<string | undefined> =>\n\t\t\tthis.armada.findQueue(id),\n\t\t);\n\t\tif (config.lookoutUrl !== undefined) {\n\t\t\t// The reconciler destroys what this returns, addressing each sandbox by\n\t\t\t// id alone, so the queue each job was found in is remembered here for\n\t\t\t// that later `destroy` to cancel in.\n\t\t\tthis.listActive = async (): Promise<ActiveSandbox[]> => {\n\t\t\t\tconst jobs: ActiveJob[] = await this.armada.listActive();\n\t\t\t\tfor (const job of jobs) this.queues.remember(job.id, job.queue);\n\t\t\t\treturn jobs.map(({ queue: _queue, ...sandbox }: ActiveJob): ActiveSandbox => sandbox);\n\t\t\t};\n\t\t}\n\t}\n\n\tcreate(id: SandboxId, options?: CreateSandboxOptions): ArmadaSandbox {\n\t\treturn new ArmadaSandbox(\n\t\t\tid,\n\t\t\tthis.config,\n\t\t\tthis.armada,\n\t\t\topenAgent,\n\t\t\tthis.queues,\n\t\t\tthis.placements,\n\t\t\toptions,\n\t\t);\n\t}\n\n\t/**\n\t * Strict attachment, which marimohub (0.4.16 onwards) needs before it saves\n\t * an expired session's edits and reclaims its sandbox: the same sandbox as\n\t * `create`, except that it reaches only a job that already exists. Without\n\t * this method marimohub keeps such a session, its pod and its editor claim\n\t * until the session's authorization runs out or an admin discards it.\n\t *\n\t * Warm pools stay off: marimohub needs a `warmPool` capability too, which\n\t * this provider does not declare, so `MARIMOHUB_COMPUTE_WARM_POOL_ENABLED`\n\t * is still refused at startup.\n\t */\n\tconnectExisting(id: SandboxId, options?: CreateSandboxOptions): ArmadaSandbox {\n\t\treturn new ArmadaSandbox(\n\t\t\tid,\n\t\t\tthis.config,\n\t\t\tthis.armada,\n\t\t\topenAgent,\n\t\t\tthis.queues,\n\t\t\tthis.placements,\n\t\t\toptions,\n\t\t\ttrue,\n\t\t);\n\t}\n\n\t/** Kernels are reached directly at their Armada ingress, so nothing is proxied. */\n\tasync proxy(_request: Request): Promise<Response | null> {\n\t\treturn null;\n\t}\n}\n\n/** Each sandbox reaches its own pod's agent, at the address Armada reported for it. */\nfunction openAgent(endpoint: AgentEndpoint): ControlChannel {\n\treturn new AgentChannel(endpoint);\n}\n",
16
- "import { readConfig } from './config.js';\nimport { ArmadaCompute } from './provider.js';\nimport type { AdapterFactoryContext, ComputeAdapterModule } from './types.js';\n\nconst manifest: ComputeAdapterModule = {\n\tapiVersion: 1,\n\tkind: 'compute',\n\tcreate(context: AdapterFactoryContext) {\n\t\treturn new ArmadaCompute(readConfig(context.env, context.compute));\n\t},\n};\n\nexport default manifest;\n"
15
+ "import { ArmadaClient } from './armada.js';\nimport type { ActiveJob } from './armada.js';\nimport { AgentChannel } from './channel.js';\nimport type { AgentEndpoint, ControlChannel } from './channel.js';\nimport type { ArmadaConfig } from './config.js';\nimport { QueueDirectory } from './queues.js';\nimport { ArmadaSandbox } from './sandbox.js';\nimport type { Placements } from './sandbox.js';\nimport type { ActiveSandbox, CreateSandboxOptions, SandboxId, SandboxProvider } from './types.js';\n\nexport class ArmadaCompute implements SandboxProvider {\n\tprivate readonly armada: ArmadaClient;\n\t/** Which queue each sandbox is in, shared by every sandbox this provider makes. */\n\tprivate readonly queues: QueueDirectory;\n\t/** The job, pod and agent channel of each sandbox reached, shared the same way. */\n\tprivate readonly placements: Placements = new Map();\n\n\t/**\n\t * Present only when `ARMADA_LOOKOUT_URL` is configured, because marimohub\n\t * treats the optional members of `SandboxProvider` as capability flags:\n\t * declaring a `listActive` we cannot answer would make every reconciliation\n\t * sweep fail, where its absence makes reconciliation a clean no-op.\n\t */\n\treadonly listActive?: () => Promise<ActiveSandbox[]>;\n\n\t/**\n\t * Every pod declares the enabled surfaces' ports next to the kernel's and\n\t * Armada exposes them all, so a second port has an address exactly when a\n\t * surface is configured. marimohub refuses to start a surface otherwise.\n\t *\n\t * The profile flags are what make marimohub (0.4.13 onwards) offer compute\n\t * profiles at all and pass their `resources` to `create`.\n\t */\n\treadonly capabilities: { multiPort: boolean; computeProfiles: boolean; gpuProfiles: boolean };\n\n\t/**\n\t * `notFound` is marimohub's factory for its own not-found error, when the\n\t * marimohub in use offers one: a sandbox found gone is reported with it, so\n\t * the session lifecycle recognises the loss (see `SandboxGoneError`).\n\t */\n\tconstructor(\n\t\tprivate readonly config: ArmadaConfig,\n\t\tprivate readonly notFound?: (message: string) => Error,\n\t) {\n\t\tthis.armada = new ArmadaClient(config);\n\t\tthis.capabilities = {\n\t\t\tmultiPort: config.surfacePorts.length > 0,\n\t\t\t// CPU and memory become the kernel container's requests and limits.\n\t\t\tcomputeProfiles: true,\n\t\t\t// A GPU count alone would put an `A100` profile on any GPU node, so GPU\n\t\t\t// profiles are offered only once each type maps to a node selector.\n\t\t\tgpuProfiles: Object.keys(config.gpuNodeSelectors).length > 0,\n\t\t};\n\t\t// `findQueue` answers `undefined` by itself when Lookout is not configured.\n\t\tthis.queues = new QueueDirectory(config, async (id: SandboxId): Promise<string | undefined> =>\n\t\t\tthis.armada.findQueue(id),\n\t\t);\n\t\tif (config.lookoutUrl !== undefined) {\n\t\t\t// The reconciler destroys what this returns, addressing each sandbox by\n\t\t\t// id alone, so the queue each job was found in is remembered here for\n\t\t\t// that later `destroy` to cancel in.\n\t\t\tthis.listActive = async (): Promise<ActiveSandbox[]> => {\n\t\t\t\tconst jobs: ActiveJob[] = await this.armada.listActive();\n\t\t\t\tfor (const job of jobs) this.queues.remember(job.id, job.queue);\n\t\t\t\treturn jobs.map(({ queue: _queue, ...sandbox }: ActiveJob): ActiveSandbox => sandbox);\n\t\t\t};\n\t\t}\n\t}\n\n\tcreate(id: SandboxId, options?: CreateSandboxOptions): ArmadaSandbox {\n\t\treturn new ArmadaSandbox(\n\t\t\tid,\n\t\t\tthis.config,\n\t\t\tthis.armada,\n\t\t\topenAgent,\n\t\t\tthis.queues,\n\t\t\tthis.placements,\n\t\t\toptions,\n\t\t\tfalse, // attachOnly\n\t\t\tthis.notFound,\n\t\t);\n\t}\n\n\t/**\n\t * Strict attachment, which marimohub (0.4.16 onwards) needs before it saves\n\t * an expired session's edits and reclaims its sandbox: the same sandbox as\n\t * `create`, except that it reaches only a job that already exists. Without\n\t * this method marimohub keeps such a session, its pod and its editor claim\n\t * until the session's authorization runs out or an admin discards it.\n\t *\n\t * Warm pools stay off: marimohub needs a `warmPool` capability too, which\n\t * this provider does not declare, so `MARIMOHUB_COMPUTE_WARM_POOL_ENABLED`\n\t * is still refused at startup.\n\t */\n\tconnectExisting(id: SandboxId, options?: CreateSandboxOptions): ArmadaSandbox {\n\t\treturn new ArmadaSandbox(\n\t\t\tid,\n\t\t\tthis.config,\n\t\t\tthis.armada,\n\t\t\topenAgent,\n\t\t\tthis.queues,\n\t\t\tthis.placements,\n\t\t\toptions,\n\t\t\ttrue,\n\t\t\tthis.notFound,\n\t\t);\n\t}\n\n\t/** Kernels are reached directly at their Armada ingress, so nothing is proxied. */\n\tasync proxy(_request: Request): Promise<Response | null> {\n\t\treturn null;\n\t}\n}\n\n/** Each sandbox reaches its own pod's agent, at the address Armada reported for it. */\nfunction openAgent(endpoint: AgentEndpoint): ControlChannel {\n\treturn new AgentChannel(endpoint);\n}\n",
16
+ "import { readConfig } from './config.js';\nimport { ArmadaCompute } from './provider.js';\nimport type { AdapterFactoryContext, ComputeAdapterModule } from './types.js';\n\nconst manifest: ComputeAdapterModule = {\n\tapiVersion: 1,\n\tkind: 'compute',\n\tcreate(context: AdapterFactoryContext) {\n\t\treturn new ArmadaCompute(readConfig(context.env, context.compute), context.errors.notFound);\n\t},\n};\n\nexport default manifest;\n"
17
17
  ],
18
- "mappings": ";AAAA;;;AC2LO,IAAM,YAAY;AAAA,EACxB,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,WAAW;AAAA,EACX,QAAQ;AAAA,EACR,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AACX;;;ACpLA;AASA,eAAsB,mBAAmB,CAAC,MAA+C;AAAA,EACxF,QAAQ,KAAK;AAAA,SACP;AAAA,MACJ;AAAA,SACI,SAAS;AAAA,MACb,MAAM,cAAsB,GAAG,KAAK,YAAY,KAAK;AAAA,MACrD,OAAO,SAAS,OAAO,KAAK,aAAa,MAAM,EAAE,SAAS,QAAQ;AAAA,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KAAK,QAAQ,OAAO,GAAG,QAAQ,OAAO,QAAQ;AAAA;AAE5F;AAEA,IAAe;",
19
+ "debugId": "BD771C93E88246D664756E2164756E21",
20
20
  "names": []
21
21
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gresearch/marimohub-compute-armada",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "marimohub compute adapter running notebook kernels as Armada jobs",
5
5
  "homepage": "https://github.com/G-Research/marimohub-compute-armada#readme",
6
6
  "license": "Apache-2.0",