@runuai/host 0.9.150 → 0.9.152

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/db/migrations/0027_cloud_credential_foundation.sql +51 -0
  2. package/db/migrations/0028_leased_engine_runtimes.sql +11 -0
  3. package/db/migrations/meta/_journal.json +14 -0
  4. package/db/schema.ts +188 -0
  5. package/lib/agent-cli.ts +11 -13
  6. package/lib/agent.ts +177 -7
  7. package/lib/agents/durable-proc.ts +56 -44
  8. package/lib/agents/registry.ts +19 -3
  9. package/lib/agents/session-state.ts +23 -10
  10. package/lib/agents/transport.ts +101 -69
  11. package/lib/apple-one-off.ts +277 -0
  12. package/lib/apple-runtime-recycle.ts +4 -3
  13. package/lib/attachments.ts +19 -17
  14. package/lib/capture-flow.ts +319 -0
  15. package/lib/cloud-credential-cleanup-adapter.ts +123 -0
  16. package/lib/cloud-credential-host.ts +512 -0
  17. package/lib/cloud-credential-leases.ts +2544 -0
  18. package/lib/cloud-credential-runtime.ts +1035 -0
  19. package/lib/codex-auth.ts +21 -1
  20. package/lib/container-runtime.ts +76 -0
  21. package/lib/credential-cleanup-inventory.ts +405 -0
  22. package/lib/credential-consumers/engine-anchor.ts +1880 -0
  23. package/lib/credential-consumers/engines.ts +773 -0
  24. package/lib/credential-consumers/github.ts +594 -0
  25. package/lib/credential-consumers/mcp.ts +384 -0
  26. package/lib/credential-consumers/task-files.ts +127 -0
  27. package/lib/credential-store-pickup.ts +15 -2
  28. package/lib/credential-store.ts +361 -33
  29. package/lib/credentials-activation-authority.ts +546 -0
  30. package/lib/credentials-purge.ts +1006 -0
  31. package/lib/db.ts +11 -0
  32. package/lib/docker-exec.ts +3 -1
  33. package/lib/engine-accounts.ts +42 -32
  34. package/lib/engine-connect.ts +47 -2
  35. package/lib/engine-credential-env.ts +50 -0
  36. package/lib/engine-login.ts +83 -1
  37. package/lib/env-file.ts +62 -8
  38. package/lib/env.ts +5 -0
  39. package/lib/fs-aliases.ts +49 -0
  40. package/lib/git-clone-credentials.ts +334 -0
  41. package/lib/git-diff.ts +219 -177
  42. package/lib/git-identity.ts +59 -14
  43. package/lib/github-origin.ts +28 -0
  44. package/lib/github-tokens.ts +56 -21
  45. package/lib/host-env.ts +17 -4
  46. package/lib/launch-mode.ts +25 -0
  47. package/lib/legacy-runtime-retirement.ts +388 -0
  48. package/lib/machine-exec.ts +14 -3
  49. package/lib/machine-provider-aws.ts +50 -8
  50. package/lib/machine-provider-local.ts +4 -0
  51. package/lib/machine-provider.ts +4 -0
  52. package/lib/managed-operation-drain.ts +8 -0
  53. package/lib/managed-runtime.ts +371 -7
  54. package/lib/mcp-capture.ts +860 -0
  55. package/lib/mcp-connections.ts +8 -1
  56. package/lib/mcp-gateway.ts +168 -10
  57. package/lib/obs.ts +2 -6
  58. package/lib/orchestrator.ts +1837 -224
  59. package/lib/person-capture.ts +327 -0
  60. package/lib/project-env-legacy-tags.ts +130 -0
  61. package/lib/project-env-task-replica.ts +1752 -0
  62. package/lib/runner-boot.ts +10 -0
  63. package/lib/runtime-activation-tail.ts +50 -3
  64. package/lib/runtime-archive.ts +68 -1
  65. package/lib/runtime-reconnect.ts +86 -0
  66. package/lib/runtime-state.ts +429 -13
  67. package/lib/safe-http.ts +364 -0
  68. package/lib/secrets-proxy/task-trust.ts +34 -3
  69. package/lib/sidecar-resume.ts +18 -5
  70. package/lib/skills.ts +47 -8
  71. package/lib/standard-image.ts +157 -103
  72. package/lib/stopped-task-status-queue.ts +68 -10
  73. package/lib/task-credential-cleanup.ts +525 -0
  74. package/lib/task-diff-sandbox.ts +464 -0
  75. package/lib/task-diff.ts +66 -163
  76. package/lib/task-env-source.ts +68 -14
  77. package/lib/task-environment/anchor.ts +31 -0
  78. package/lib/task-environment/apple-container.ts +69 -28
  79. package/lib/task-environment/docker.ts +101 -20
  80. package/lib/task-environment/machine-environment.ts +61 -0
  81. package/lib/task-environment/machine-task-up.ts +459 -96
  82. package/lib/task-environment/machine.ts +101 -11
  83. package/lib/task-environment/self.ts +108 -50
  84. package/lib/task-environment/types.ts +89 -5
  85. package/lib/task-environment/workspace-files.ts +650 -25
  86. package/lib/task-environment/workspace-runtime.fixture.ts +50 -0
  87. package/lib/task-gateway-recovery.ts +4 -1
  88. package/lib/task-gateway-state.ts +15 -0
  89. package/lib/task-machine-swap-safety.ts +729 -0
  90. package/lib/token-broker-adopt.ts +344 -0
  91. package/lib/token-broker-lambda.ts +56 -2
  92. package/lib/token-broker-local.ts +28 -4
  93. package/lib/token-broker-revision.ts +310 -0
  94. package/lib/token-broker-ssm.ts +368 -28
  95. package/lib/token-lanes/openai-oauth.ts +7 -3
  96. package/lib/token-lanes/xai-oauth.ts +7 -3
  97. package/lib/transcript.ts +9 -5
  98. package/package.json +6 -2
  99. package/scripts/agent/task-up.sh +242 -100
  100. package/src/cloud-credentials.ts +2399 -0
  101. package/src/event-outbox.ts +8 -6
  102. package/src/index.ts +1386 -875
  103. package/src/main.ts +1061 -139
  104. package/src/outbound-frame.ts +31 -0
  105. package/src/project-env-policy.ts +125 -10
  106. package/src/protocol.ts +699 -23
  107. package/src/ui/server.ts +48 -10
package/src/ui/server.ts CHANGED
@@ -25,6 +25,7 @@ import type { ZodType } from "zod";
25
25
 
26
26
  import { agentMode } from "../../lib/agents/mode";
27
27
  import { schema, type Db } from "../../lib/db";
28
+ import { whileOnOwnCredentials } from "../../lib/cloud-credential-host";
28
29
  import { getOrchestrator } from "../../lib/orchestrator";
29
30
  import { parsePreviewPortRuntimes } from "../../lib/preview-ports";
30
31
  import { getCloudState } from "../../lib/cloud-state";
@@ -178,6 +179,38 @@ async function listenWithFallback(
178
179
  );
179
180
  }
180
181
 
182
+ /** The local UI's writes of an engine credential (a sign-in, a key, an
183
+ * account): refused once the runner is off its own credentials. */
184
+ const ENGINE_CREDENTIAL_ROUTES: ReadonlySet<string> = new Set([
185
+ "/api/engines/connect",
186
+ "/api/engines/disconnect",
187
+ "/api/engines/accounts/connect",
188
+ "/api/engines/accounts/add",
189
+ "/api/engines/accounts/remove",
190
+ ]);
191
+
192
+ async function handleEngineCredentialWrite(
193
+ path: string,
194
+ req: IncomingMessage,
195
+ res: ServerResponse,
196
+ opts: UiServerOptions,
197
+ ): Promise<void> {
198
+ switch (path) {
199
+ case "/api/engines/connect":
200
+ return handleEngineConnect(req, res, opts);
201
+ case "/api/engines/disconnect":
202
+ return handleEngineDisconnect(req, res, opts);
203
+ case "/api/engines/accounts/connect":
204
+ return handleEngineAccountConnect(req, res, opts);
205
+ case "/api/engines/accounts/add":
206
+ return handleEngineAccountAdd(req, res, opts);
207
+ case "/api/engines/accounts/remove":
208
+ return handleEngineAccountRemove(req, res, opts);
209
+ default:
210
+ return sendError(res, 404, `no such endpoint: ${path}`);
211
+ }
212
+ }
213
+
181
214
  async function handle(
182
215
  req: IncomingMessage,
183
216
  res: ServerResponse,
@@ -192,19 +225,24 @@ async function handle(
192
225
  // POST — engine connect/disconnect (the only writes; localhost-bound, so
193
226
  // the loopback binding is the perimeter, ADR-028).
194
227
  if (method === "POST") {
228
+ // ADR-154 §13: an engine credential is written here only while the
229
+ // runner is on its own credentials, as work on them that leaving them
230
+ // waits for; off them it keeps none, and Connections in Uai Cloud
231
+ // holds them.
232
+ if (ENGINE_CREDENTIAL_ROUTES.has(path)) {
233
+ const write = whileOnOwnCredentials(() => handleEngineCredentialWrite(path, req, res, opts));
234
+ if (write === null) {
235
+ return sendError(
236
+ res,
237
+ 409,
238
+ "this runner reads its credentials from Uai Cloud; manage them in Connections",
239
+ );
240
+ }
241
+ return await write;
242
+ }
195
243
  switch (path) {
196
- case "/api/engines/connect":
197
- return await handleEngineConnect(req, res, opts);
198
244
  case "/api/engines/install":
199
245
  return await handleEngineInstall(req, res);
200
- case "/api/engines/disconnect":
201
- return await handleEngineDisconnect(req, res, opts);
202
- case "/api/engines/accounts/connect":
203
- return await handleEngineAccountConnect(req, res, opts);
204
- case "/api/engines/accounts/add":
205
- return await handleEngineAccountAdd(req, res, opts);
206
- case "/api/engines/accounts/remove":
207
- return await handleEngineAccountRemove(req, res, opts);
208
246
  case "/api/tasks/stop":
209
247
  return await handleTaskStop(req, res, opts);
210
248
  case "/api/runtime/recheck": {