@runuai/host 0.9.151 → 0.9.153
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/db/migrations/0029_task_shared_files_mode.sql +5 -0
- package/db/migrations/meta/_journal.json +7 -0
- package/db/schema.ts +10 -0
- package/lib/agent.ts +4 -0
- package/lib/browser-testing.ts +8 -3
- package/lib/cloud-credential-leases.ts +15 -4
- package/lib/cloud-credential-runtime.ts +142 -3
- package/lib/credential-cleanup-inventory.ts +2 -0
- package/lib/credential-consumers/engine-anchor.ts +5 -1
- package/lib/credential-consumers/files.ts +934 -0
- package/lib/credential-consumers/mcp.ts +6 -1
- package/lib/mcp-gateway.ts +576 -122
- package/lib/orchestrator.ts +99 -10
- package/lib/runtime-state.ts +88 -0
- package/lib/shared-files-s3.ts +743 -3
- package/lib/sidecar-resume.ts +9 -0
- package/lib/task-credential-cleanup.ts +36 -5
- package/lib/task-environment/machine-task-up.ts +35 -19
- package/lib/task-environment/workspace-files.ts +33 -6
- package/lib/task-files-machine-retirement.ts +88 -0
- package/lib/task-files-readiness.ts +127 -0
- package/package.json +1 -1
- package/src/cloud-credentials.ts +10 -0
- package/src/index.ts +38 -2
- package/src/main.ts +47 -2
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";
|
|
@@ -408,6 +411,12 @@ import {
|
|
|
408
411
|
} from "../lib/legacy-runtime-retirement";
|
|
409
412
|
import { taskContainerBackend, taskContainerCli } from "../lib/task-container-cli";
|
|
410
413
|
import { CloudCredentialRuntime } from "../lib/cloud-credential-runtime";
|
|
414
|
+
import { createTaskFilesV1Consumer } from "../lib/credential-consumers/files";
|
|
415
|
+
import { taskFilesV1Readiness } from "../lib/task-files-readiness";
|
|
416
|
+
import {
|
|
417
|
+
requestTaskFilesMachineRetirement,
|
|
418
|
+
taskFilesMachineRetirementReady,
|
|
419
|
+
} from "../lib/task-files-machine-retirement";
|
|
411
420
|
import { ProjectEnvTaskReplicaManager } from "../lib/project-env-task-replica";
|
|
412
421
|
import {
|
|
413
422
|
purgeDefaultEngineSlots,
|
|
@@ -908,15 +917,29 @@ if (signInBoxMode()) {
|
|
|
908
917
|
// ADR-154: the composer for tasks on cloud credentials. Nothing runs on it
|
|
909
918
|
// until the runner's activation authority makes cloud credentials its
|
|
910
919
|
// tasks' only ones (lib/cloud-credential-host.ts).
|
|
920
|
+
const taskFilesReadiness = taskFilesV1Readiness(sidecarMode());
|
|
921
|
+
const taskFiles = sidecarMode()
|
|
922
|
+
? createTaskFilesV1Consumer({
|
|
923
|
+
recoveredBinding: (assignment) => {
|
|
924
|
+
return taskFilesRecoveryBinding(getHostTask(assignment.taskId), assignment);
|
|
925
|
+
},
|
|
926
|
+
ready: () =>
|
|
927
|
+
taskFilesV1Readiness(true).ready &&
|
|
928
|
+
taskFilesMachineRetirementReady(),
|
|
929
|
+
retireMachine: requestTaskFilesMachineRetirement,
|
|
930
|
+
})
|
|
931
|
+
: null;
|
|
911
932
|
const cloudCredentials = new CloudCredentialRuntime({
|
|
912
933
|
runnerKind: sidecarMode() ? "task-machine" : "owned",
|
|
913
934
|
send: sendCredentialFrame,
|
|
914
935
|
quiesceProcesses: (request) => getOrchestrator().quiesceLeasedEngineAgents(request),
|
|
936
|
+
mcpServedChanged: (taskId) => getOrchestrator().mcpServedChanged(taskId),
|
|
915
937
|
// The task-keyed env replica the cloud streams for each run. A change to
|
|
916
938
|
// it, or to what the composer serves from it, makes the proxy's trust
|
|
917
939
|
// delivery look again; /env reads it afresh on every command.
|
|
918
940
|
envReplica: new ProjectEnvTaskReplicaManager({ onChange: () => noteProjectEnvViewChange() }),
|
|
919
941
|
envServedChanged: () => noteProjectEnvViewChange(),
|
|
942
|
+
files: taskFiles,
|
|
920
943
|
});
|
|
921
944
|
// Leaving its own credentials ends every task's env from the runner's
|
|
922
945
|
// stores at once, and makes the proxy's trust delivery look again.
|
|
@@ -926,8 +949,25 @@ followLeavingLegacy();
|
|
|
926
949
|
// from its own run's Files session, never the runner's v0 lease); and the
|
|
927
950
|
// proxy's upkeep from activation on, with no v0 first grant to start it.
|
|
928
951
|
if (sidecarMode()) {
|
|
929
|
-
setRecoveredRuntimeSetup(async (
|
|
930
|
-
const
|
|
952
|
+
setRecoveredRuntimeSetup(async (run, signal) => {
|
|
953
|
+
const task = getHostTask(run.taskId);
|
|
954
|
+
let mode: ReturnType<typeof hostTaskSharedFilesMode>;
|
|
955
|
+
try {
|
|
956
|
+
mode = task ? hostTaskSharedFilesMode(task) : null;
|
|
957
|
+
if (mode === null) {
|
|
958
|
+
throw new Error("the recovered task has no trusted Files-v1 mode");
|
|
959
|
+
}
|
|
960
|
+
} catch (error) {
|
|
961
|
+
if (signal.aborted) throw signal.reason;
|
|
962
|
+
cloudCredentials.failTaskFilesSetup(run, error);
|
|
963
|
+
throw error;
|
|
964
|
+
}
|
|
965
|
+
const resumed = await resumeSidecarTask({
|
|
966
|
+
remountFiles: false,
|
|
967
|
+
signal,
|
|
968
|
+
prepareFiles: (handle) =>
|
|
969
|
+
cloudCredentials.prepareTaskFiles(run, handle, mode, signal),
|
|
970
|
+
});
|
|
931
971
|
if (resumed.outcome === "resumed") {
|
|
932
972
|
console.log(
|
|
933
973
|
`[sidecar] task ${sidecarTaskId()} resumed on cloud credentials: loader, proxy and editor re-asserted` +
|
|
@@ -1365,6 +1405,11 @@ function buildCapabilities(): HostCapabilities {
|
|
|
1365
1405
|
...(projectEnvBindings === null ? [] : [projectEnvBindings.feature]),
|
|
1366
1406
|
// ADR-154 §13: the runner reads cloud credentials, its stores purged.
|
|
1367
1407
|
...(credentialsMode() === "active" ? [HOST_CLOUD_CREDENTIALS_FEATURE] : []),
|
|
1408
|
+
...(taskFiles !== null &&
|
|
1409
|
+
taskFilesReadiness.ready &&
|
|
1410
|
+
taskFilesMachineRetirementReady()
|
|
1411
|
+
? [HOST_TASK_FILES_LEASE_FEATURE]
|
|
1412
|
+
: []),
|
|
1368
1413
|
// ADR-154: only the sign-in box writes cloud credentials.
|
|
1369
1414
|
...(signInBoxMode()
|
|
1370
1415
|
? [
|