@runuai/host 0.9.152 → 0.9.154

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/src/main.ts CHANGED
@@ -28,7 +28,9 @@ import {
28
28
  closeTaskRunAssignment,
29
29
  getHostTask,
30
30
  hasInFlightHostTaskLifecycle,
31
+ hostTaskSharedFilesMode,
31
32
  readTaskRunEpochState,
33
+ taskFilesRecoveryBinding,
32
34
  upsertHostTask,
33
35
  } from "../lib/runtime-state";
34
36
  import {
@@ -112,6 +114,7 @@ import {
112
114
  parseLeaseGrantV1Frame,
113
115
  parseLeaseStaleFrame,
114
116
  parseLeaseUnavailableFrame,
117
+ HOST_TASK_FILES_LEASE_FEATURE,
115
118
  } from "./cloud-credentials";
116
119
  import { captureEngineAccount } from "../lib/capture-flow";
117
120
  import { registerTaskGatewayTlsHandler, setMcpGatewayLeaseOnly, startMcpGateway } from "../lib/mcp-gateway";
@@ -175,6 +178,7 @@ import {
175
178
  reprobeContainerRuntimeMachineIdentity,
176
179
  } from "../lib/container-runtime";
177
180
  import { persistedTaskEnvironmentsMatchMachine, reconstructPersistedTaskEnvironment } from "../lib/task-environment";
181
+ import { reconcileRunningTaskPersonCredentials } from "../lib/task-person-credentials";
178
182
  import { logVnodePressure } from "../lib/vnode-pressure";
179
183
  import { resolveAppleTunnelRoute } from "./apple-tunnel-route";
180
184
  import {
@@ -408,6 +412,12 @@ import {
408
412
  } from "../lib/legacy-runtime-retirement";
409
413
  import { taskContainerBackend, taskContainerCli } from "../lib/task-container-cli";
410
414
  import { CloudCredentialRuntime } from "../lib/cloud-credential-runtime";
415
+ import { createTaskFilesV1Consumer } from "../lib/credential-consumers/files";
416
+ import { taskFilesV1Readiness } from "../lib/task-files-readiness";
417
+ import {
418
+ requestTaskFilesMachineRetirement,
419
+ taskFilesMachineRetirementReady,
420
+ } from "../lib/task-files-machine-retirement";
411
421
  import { ProjectEnvTaskReplicaManager } from "../lib/project-env-task-replica";
412
422
  import {
413
423
  purgeDefaultEngineSlots,
@@ -908,15 +918,30 @@ if (signInBoxMode()) {
908
918
  // ADR-154: the composer for tasks on cloud credentials. Nothing runs on it
909
919
  // until the runner's activation authority makes cloud credentials its
910
920
  // tasks' only ones (lib/cloud-credential-host.ts).
921
+ const taskFilesReadiness = taskFilesV1Readiness(sidecarMode());
922
+ const taskFiles = sidecarMode()
923
+ ? createTaskFilesV1Consumer({
924
+ recoveredBinding: (assignment) => {
925
+ return taskFilesRecoveryBinding(getHostTask(assignment.taskId), assignment);
926
+ },
927
+ ready: () =>
928
+ taskFilesV1Readiness(true).ready &&
929
+ taskFilesMachineRetirementReady(),
930
+ retireMachine: requestTaskFilesMachineRetirement,
931
+ })
932
+ : null;
911
933
  const cloudCredentials = new CloudCredentialRuntime({
912
934
  runnerKind: sidecarMode() ? "task-machine" : "owned",
913
935
  send: sendCredentialFrame,
914
936
  quiesceProcesses: (request) => getOrchestrator().quiesceLeasedEngineAgents(request),
937
+ mcpServedChanged: (taskId) => getOrchestrator().mcpServedChanged(taskId),
915
938
  // The task-keyed env replica the cloud streams for each run. A change to
916
939
  // it, or to what the composer serves from it, makes the proxy's trust
917
940
  // delivery look again; /env reads it afresh on every command.
918
941
  envReplica: new ProjectEnvTaskReplicaManager({ onChange: () => noteProjectEnvViewChange() }),
919
942
  envServedChanged: () => noteProjectEnvViewChange(),
943
+ personCredentialsReady: reconcileRunningTaskPersonCredentials,
944
+ files: taskFiles,
920
945
  });
921
946
  // Leaving its own credentials ends every task's env from the runner's
922
947
  // stores at once, and makes the proxy's trust delivery look again.
@@ -926,8 +951,25 @@ followLeavingLegacy();
926
951
  // from its own run's Files session, never the runner's v0 lease); and the
927
952
  // proxy's upkeep from activation on, with no v0 first grant to start it.
928
953
  if (sidecarMode()) {
929
- setRecoveredRuntimeSetup(async (_run, signal) => {
930
- const resumed = await resumeSidecarTask({ remountFiles: false, signal });
954
+ setRecoveredRuntimeSetup(async (run, signal) => {
955
+ const task = getHostTask(run.taskId);
956
+ let mode: ReturnType<typeof hostTaskSharedFilesMode>;
957
+ try {
958
+ mode = task ? hostTaskSharedFilesMode(task) : null;
959
+ if (mode === null) {
960
+ throw new Error("the recovered task has no trusted Files-v1 mode");
961
+ }
962
+ } catch (error) {
963
+ if (signal.aborted) throw signal.reason;
964
+ cloudCredentials.failTaskFilesSetup(run, error);
965
+ throw error;
966
+ }
967
+ const resumed = await resumeSidecarTask({
968
+ remountFiles: false,
969
+ signal,
970
+ prepareFiles: (handle) =>
971
+ cloudCredentials.prepareTaskFiles(run, handle, mode, signal),
972
+ });
931
973
  if (resumed.outcome === "resumed") {
932
974
  console.log(
933
975
  `[sidecar] task ${sidecarTaskId()} resumed on cloud credentials: loader, proxy and editor re-asserted` +
@@ -1365,6 +1407,11 @@ function buildCapabilities(): HostCapabilities {
1365
1407
  ...(projectEnvBindings === null ? [] : [projectEnvBindings.feature]),
1366
1408
  // ADR-154 §13: the runner reads cloud credentials, its stores purged.
1367
1409
  ...(credentialsMode() === "active" ? [HOST_CLOUD_CREDENTIALS_FEATURE] : []),
1410
+ ...(taskFiles !== null &&
1411
+ taskFilesReadiness.ready &&
1412
+ taskFilesMachineRetirementReady()
1413
+ ? [HOST_TASK_FILES_LEASE_FEATURE]
1414
+ : []),
1368
1415
  // ADR-154: only the sign-in box writes cloud credentials.
1369
1416
  ...(signInBoxMode()
1370
1417
  ? [