@sentropic/h2a-runtime 0.81.0
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/dist/account-pool.d.ts +168 -0
- package/dist/account-pool.d.ts.map +1 -0
- package/dist/account-pool.js +385 -0
- package/dist/account-pool.js.map +1 -0
- package/dist/agents-projection.d.ts +56 -0
- package/dist/agents-projection.d.ts.map +1 -0
- package/dist/agents-projection.js +82 -0
- package/dist/agents-projection.js.map +1 -0
- package/dist/attach.d.ts +75 -0
- package/dist/attach.d.ts.map +1 -0
- package/dist/attach.js +432 -0
- package/dist/attach.js.map +1 -0
- package/dist/auth-bundle.d.ts +21 -0
- package/dist/auth-bundle.d.ts.map +1 -0
- package/dist/auth-bundle.js +112 -0
- package/dist/auth-bundle.js.map +1 -0
- package/dist/auth-diagnostics.d.ts +18 -0
- package/dist/auth-diagnostics.d.ts.map +1 -0
- package/dist/auth-diagnostics.js +23 -0
- package/dist/auth-diagnostics.js.map +1 -0
- package/dist/auth-login.d.ts +9 -0
- package/dist/auth-login.d.ts.map +1 -0
- package/dist/auth-login.js +21 -0
- package/dist/auth-login.js.map +1 -0
- package/dist/auth-refresh.d.ts +32 -0
- package/dist/auth-refresh.d.ts.map +1 -0
- package/dist/auth-refresh.js +83 -0
- package/dist/auth-refresh.js.map +1 -0
- package/dist/auth-tools.d.ts +55 -0
- package/dist/auth-tools.d.ts.map +1 -0
- package/dist/auth-tools.js +163 -0
- package/dist/auth-tools.js.map +1 -0
- package/dist/browser-bridge-local.d.ts +27 -0
- package/dist/browser-bridge-local.d.ts.map +1 -0
- package/dist/browser-bridge-local.js +51 -0
- package/dist/browser-bridge-local.js.map +1 -0
- package/dist/browser.d.ts +53 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +61 -0
- package/dist/browser.js.map +1 -0
- package/dist/conductor-launch.d.ts +179 -0
- package/dist/conductor-launch.d.ts.map +1 -0
- package/dist/conductor-launch.js +414 -0
- package/dist/conductor-launch.js.map +1 -0
- package/dist/config.d.ts +182 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +334 -0
- package/dist/config.js.map +1 -0
- package/dist/conv-guard.d.ts +76 -0
- package/dist/conv-guard.d.ts.map +1 -0
- package/dist/conv-guard.js +131 -0
- package/dist/conv-guard.js.map +1 -0
- package/dist/convsync.d.ts +24 -0
- package/dist/convsync.d.ts.map +1 -0
- package/dist/convsync.js +108 -0
- package/dist/convsync.js.map +1 -0
- package/dist/cred-health.d.ts +96 -0
- package/dist/cred-health.d.ts.map +1 -0
- package/dist/cred-health.js +170 -0
- package/dist/cred-health.js.map +1 -0
- package/dist/delegate.d.ts +406 -0
- package/dist/delegate.d.ts.map +1 -0
- package/dist/delegate.js +739 -0
- package/dist/delegate.js.map +1 -0
- package/dist/enroll.d.ts +91 -0
- package/dist/enroll.d.ts.map +1 -0
- package/dist/enroll.js +248 -0
- package/dist/enroll.js.map +1 -0
- package/dist/fanout.d.ts +63 -0
- package/dist/fanout.d.ts.map +1 -0
- package/dist/fanout.js +115 -0
- package/dist/fanout.js.map +1 -0
- package/dist/forward.d.ts +66 -0
- package/dist/forward.d.ts.map +1 -0
- package/dist/forward.js +141 -0
- package/dist/forward.js.map +1 -0
- package/dist/gitdiff.d.ts +31 -0
- package/dist/gitdiff.d.ts.map +1 -0
- package/dist/gitdiff.js +133 -0
- package/dist/gitdiff.js.map +1 -0
- package/dist/h2a-bridge.d.ts +102 -0
- package/dist/h2a-bridge.d.ts.map +1 -0
- package/dist/h2a-bridge.js +333 -0
- package/dist/h2a-bridge.js.map +1 -0
- package/dist/h2a-jobs.d.ts +235 -0
- package/dist/h2a-jobs.d.ts.map +1 -0
- package/dist/h2a-jobs.js +388 -0
- package/dist/h2a-jobs.js.map +1 -0
- package/dist/h2a-ping.d.ts +38 -0
- package/dist/h2a-ping.d.ts.map +1 -0
- package/dist/h2a-ping.js +58 -0
- package/dist/h2a-ping.js.map +1 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5887 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive-throttle.d.ts +164 -0
- package/dist/interactive-throttle.d.ts.map +1 -0
- package/dist/interactive-throttle.js +194 -0
- package/dist/interactive-throttle.js.map +1 -0
- package/dist/lineage-client.d.ts +77 -0
- package/dist/lineage-client.d.ts.map +1 -0
- package/dist/lineage-client.js +117 -0
- package/dist/lineage-client.js.map +1 -0
- package/dist/lineage-lease.d.ts +152 -0
- package/dist/lineage-lease.d.ts.map +1 -0
- package/dist/lineage-lease.js +303 -0
- package/dist/lineage-lease.js.map +1 -0
- package/dist/llm-gateway-runtime/accounts.d.ts +48 -0
- package/dist/llm-gateway-runtime/accounts.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/accounts.js +226 -0
- package/dist/llm-gateway-runtime/accounts.js.map +1 -0
- package/dist/llm-gateway-runtime/index.d.ts +4 -0
- package/dist/llm-gateway-runtime/index.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/index.js +58 -0
- package/dist/llm-gateway-runtime/index.js.map +1 -0
- package/dist/llm-gateway-runtime/model-catalog.d.ts +36 -0
- package/dist/llm-gateway-runtime/model-catalog.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/model-catalog.js +146 -0
- package/dist/llm-gateway-runtime/model-catalog.js.map +1 -0
- package/dist/llm-gateway-runtime/proxy-anthropic.d.ts +3 -0
- package/dist/llm-gateway-runtime/proxy-anthropic.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/proxy-anthropic.js +139 -0
- package/dist/llm-gateway-runtime/proxy-anthropic.js.map +1 -0
- package/dist/llm-gateway-runtime/proxy-openai.d.ts +117 -0
- package/dist/llm-gateway-runtime/proxy-openai.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/proxy-openai.js +1132 -0
- package/dist/llm-gateway-runtime/proxy-openai.js.map +1 -0
- package/dist/llm-gateway-runtime/session-ledger.d.ts +32 -0
- package/dist/llm-gateway-runtime/session-ledger.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/session-ledger.js +62 -0
- package/dist/llm-gateway-runtime/session-ledger.js.map +1 -0
- package/dist/llm-gateway-runtime/sticky.d.ts +40 -0
- package/dist/llm-gateway-runtime/sticky.d.ts.map +1 -0
- package/dist/llm-gateway-runtime/sticky.js +254 -0
- package/dist/llm-gateway-runtime/sticky.js.map +1 -0
- package/dist/llm-mesh.d.ts +102 -0
- package/dist/llm-mesh.d.ts.map +1 -0
- package/dist/llm-mesh.js +433 -0
- package/dist/llm-mesh.js.map +1 -0
- package/dist/migrate-candidates.d.ts +35 -0
- package/dist/migrate-candidates.d.ts.map +1 -0
- package/dist/migrate-candidates.js +128 -0
- package/dist/migrate-candidates.js.map +1 -0
- package/dist/migrate.d.ts +125 -0
- package/dist/migrate.d.ts.map +1 -0
- package/dist/migrate.js +561 -0
- package/dist/migrate.js.map +1 -0
- package/dist/plugin-manifest.d.ts +143 -0
- package/dist/plugin-manifest.d.ts.map +1 -0
- package/dist/plugin-manifest.js +233 -0
- package/dist/plugin-manifest.js.map +1 -0
- package/dist/plugin.d.ts +274 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +919 -0
- package/dist/plugin.js.map +1 -0
- package/dist/pod-liveness.d.ts +51 -0
- package/dist/pod-liveness.d.ts.map +1 -0
- package/dist/pod-liveness.js +80 -0
- package/dist/pod-liveness.js.map +1 -0
- package/dist/profile-menu.d.ts +7 -0
- package/dist/profile-menu.d.ts.map +1 -0
- package/dist/profile-menu.js +52 -0
- package/dist/profile-menu.js.map +1 -0
- package/dist/profiles.d.ts +23 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +66 -0
- package/dist/profiles.js.map +1 -0
- package/dist/protocol-local.d.ts +27 -0
- package/dist/protocol-local.d.ts.map +1 -0
- package/dist/protocol-local.js +12 -0
- package/dist/protocol-local.js.map +1 -0
- package/dist/pty.d.ts +26 -0
- package/dist/pty.d.ts.map +1 -0
- package/dist/pty.js +45 -0
- package/dist/pty.js.map +1 -0
- package/dist/readiness.d.ts +38 -0
- package/dist/readiness.d.ts.map +1 -0
- package/dist/readiness.js +169 -0
- package/dist/readiness.js.map +1 -0
- package/dist/registry.d.ts +258 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +570 -0
- package/dist/registry.js.map +1 -0
- package/dist/relaunch.d.ts +52 -0
- package/dist/relaunch.d.ts.map +1 -0
- package/dist/relaunch.js +76 -0
- package/dist/relaunch.js.map +1 -0
- package/dist/restore.d.ts +165 -0
- package/dist/restore.d.ts.map +1 -0
- package/dist/restore.js +530 -0
- package/dist/restore.js.map +1 -0
- package/dist/run.d.ts +29 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +206 -0
- package/dist/run.js.map +1 -0
- package/dist/secrets.d.ts +25 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +98 -0
- package/dist/secrets.js.map +1 -0
- package/dist/session-restore.d.ts +26 -0
- package/dist/session-restore.d.ts.map +1 -0
- package/dist/session-restore.js +122 -0
- package/dist/session-restore.js.map +1 -0
- package/dist/skills-sync.d.ts +126 -0
- package/dist/skills-sync.d.ts.map +1 -0
- package/dist/skills-sync.js +255 -0
- package/dist/skills-sync.js.map +1 -0
- package/dist/smoke.d.ts +23 -0
- package/dist/smoke.d.ts.map +1 -0
- package/dist/smoke.js +138 -0
- package/dist/smoke.js.map +1 -0
- package/dist/soft-refresh.d.ts +107 -0
- package/dist/soft-refresh.d.ts.map +1 -0
- package/dist/soft-refresh.js +426 -0
- package/dist/soft-refresh.js.map +1 -0
- package/dist/sync-status.d.ts +22 -0
- package/dist/sync-status.d.ts.map +1 -0
- package/dist/sync-status.js +41 -0
- package/dist/sync-status.js.map +1 -0
- package/dist/sync.d.ts +77 -0
- package/dist/sync.d.ts.map +1 -0
- package/dist/sync.js +302 -0
- package/dist/sync.js.map +1 -0
- package/dist/throttle-signatures.d.ts +43 -0
- package/dist/throttle-signatures.d.ts.map +1 -0
- package/dist/throttle-signatures.js +116 -0
- package/dist/throttle-signatures.js.map +1 -0
- package/dist/tmux.d.ts +286 -0
- package/dist/tmux.d.ts.map +1 -0
- package/dist/tmux.js +970 -0
- package/dist/tmux.js.map +1 -0
- package/dist/tunnel.d.ts +25 -0
- package/dist/tunnel.d.ts.map +1 -0
- package/dist/tunnel.js +127 -0
- package/dist/tunnel.js.map +1 -0
- package/dist/workspace-merge.d.ts +17 -0
- package/dist/workspace-merge.d.ts.map +1 -0
- package/dist/workspace-merge.js +153 -0
- package/dist/workspace-merge.js.map +1 -0
- package/dist/workspace-sync-incremental.d.ts +64 -0
- package/dist/workspace-sync-incremental.d.ts.map +1 -0
- package/dist/workspace-sync-incremental.js +199 -0
- package/dist/workspace-sync-incremental.js.map +1 -0
- package/dist/workspace-sync.d.ts +3 -0
- package/dist/workspace-sync.d.ts.map +1 -0
- package/dist/workspace-sync.js +187 -0
- package/dist/workspace-sync.js.map +1 -0
- package/dist/workspace.d.ts +70 -0
- package/dist/workspace.d.ts.map +1 -0
- package/dist/workspace.js +173 -0
- package/dist/workspace.js.map +1 -0
- package/package.json +44 -0
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* remote migrate — convenience wrapper for round-tripping a local CLI session
|
|
3
|
+
* to a remote (SCW k8s) session and back.
|
|
4
|
+
*
|
|
5
|
+
* Forward (local → remote):
|
|
6
|
+
* 1. Resolve remote URL.
|
|
7
|
+
* 2. Ensure the cwd is linked to a workspace (reads .remote/workspace.json).
|
|
8
|
+
* 3. Push the workspace archive (project files, honours .gitignore).
|
|
9
|
+
* 4. Create a remote session for <profile> bound to that workspace.
|
|
10
|
+
* 5. Hand off the current terminal to the remote session via `attach`.
|
|
11
|
+
* The attach call blocks until the session ends or the user detaches
|
|
12
|
+
* (Ctrl+P Ctrl+Q). There is no separate process to kill — `migrate`
|
|
13
|
+
* itself IS the process holding the terminal, and attach takes it over.
|
|
14
|
+
*
|
|
15
|
+
* Back (remote → local):
|
|
16
|
+
* 1. Resolve URL + workspace.
|
|
17
|
+
* 2. Pull the workspace + conversation state (3-way merge).
|
|
18
|
+
* 3. Restore conversation state to the local HOME.
|
|
19
|
+
* 4. Stop the remote session.
|
|
20
|
+
* 5. Print the exact local CLI command to resume from the restored state.
|
|
21
|
+
* We do NOT spawn the CLI — we print the command so the user can run it.
|
|
22
|
+
*/
|
|
23
|
+
import { cpSync, existsSync, mkdirSync, readdirSync, rmSync, statSync, writeFileSync, } from "node:fs";
|
|
24
|
+
import { spawnSync } from "node:child_process";
|
|
25
|
+
import { randomUUID } from "node:crypto";
|
|
26
|
+
import { homedir } from "node:os";
|
|
27
|
+
import { join } from "node:path";
|
|
28
|
+
import { attach, createRemoteSession, stopRemoteSession } from "./attach.js";
|
|
29
|
+
import { coerceCliProfileName, resolveProfile, resumeArgsFor, } from "./profiles.js";
|
|
30
|
+
import { collectProfileAuth } from "./auth-bundle.js";
|
|
31
|
+
import { collectToolAuth } from "./auth-tools.js";
|
|
32
|
+
import { acquireWorkspaceLock, createWorkspace, downloadWorkspaceExport, lockHolderId, readBaseSnapshot, readLineageRecord, readWorkspaceMarker, releaseWorkspaceLock, writeBaseSnapshot, writeLineageRecord, writeWorkspaceMarker, } from "./workspace.js";
|
|
33
|
+
import { buildWorkspaceArchive, uploadWorkspaceArchive, } from "./workspace-sync.js";
|
|
34
|
+
import { mergeWorkspaceArchive } from "./workspace-merge.js";
|
|
35
|
+
import { restoreSessionsToLocal } from "./session-restore.js";
|
|
36
|
+
import { acquireLineageLease, leaseHeaders, releaseLineageLease, } from "./lineage-client.js";
|
|
37
|
+
import { CLI_PROFILES } from "./protocol-local.js";
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Helpers
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
/**
|
|
42
|
+
* Resolve (or create + link) a workspace for the given cwd.
|
|
43
|
+
* Priority: explicit workspaceId arg > .remote/workspace.json > create new.
|
|
44
|
+
*/
|
|
45
|
+
async function resolveOrCreateWorkspace(cwd, remoteUrl, workspaceIdOverride, fetchImpl, stderr) {
|
|
46
|
+
if (workspaceIdOverride) {
|
|
47
|
+
// Honour the override; persist a marker if one doesn't already exist.
|
|
48
|
+
const existing = readWorkspaceMarker(cwd);
|
|
49
|
+
if (existing && existing.workspaceId === workspaceIdOverride) {
|
|
50
|
+
return existing;
|
|
51
|
+
}
|
|
52
|
+
const marker = {
|
|
53
|
+
remote: remoteUrl,
|
|
54
|
+
workspaceId: workspaceIdOverride,
|
|
55
|
+
};
|
|
56
|
+
writeWorkspaceMarker(cwd, marker);
|
|
57
|
+
stderr.write(`[remote] using workspace ${workspaceIdOverride} (from --workspace flag)\n`);
|
|
58
|
+
return marker;
|
|
59
|
+
}
|
|
60
|
+
const existing = readWorkspaceMarker(cwd);
|
|
61
|
+
if (existing) {
|
|
62
|
+
stderr.write(`[remote] cwd mapped to ${existing.workspaceId} (reusing workspace)\n`);
|
|
63
|
+
return existing;
|
|
64
|
+
}
|
|
65
|
+
// Create and link a new workspace.
|
|
66
|
+
const ws = await createWorkspace(remoteUrl, {}, fetchImpl);
|
|
67
|
+
const marker = { remote: remoteUrl, workspaceId: ws.id };
|
|
68
|
+
writeWorkspaceMarker(cwd, marker);
|
|
69
|
+
stderr.write(`[remote] created workspace ${ws.id} and linked to ${cwd}\n`);
|
|
70
|
+
return marker;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Build the resume startupArgs for a profile, given a session id (or true for
|
|
74
|
+
* the most-recent session).
|
|
75
|
+
*/
|
|
76
|
+
function buildResumeStartupArgs(profileName, resume) {
|
|
77
|
+
const config = resolveProfile(profileName);
|
|
78
|
+
return resumeArgsFor(config, resume);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Profile conversation dirs (HOME-relative), mirrored from the session-agent's
|
|
82
|
+
* restore mapping (`<workspace>/.remote/sessions/<profile>/<relDir>` →
|
|
83
|
+
* `<home>/<relDir>`).
|
|
84
|
+
*/
|
|
85
|
+
const PROFILE_STATE_DIRS = {
|
|
86
|
+
claude: ".claude/projects",
|
|
87
|
+
};
|
|
88
|
+
const STATE_SUBDIR = ".remote/sessions";
|
|
89
|
+
/**
|
|
90
|
+
* Stage the live (most-recent) local conversation for `cwd` into the workspace
|
|
91
|
+
* under `.remote/sessions/<profile>/<relDir>/<projectDir>` so it rides the
|
|
92
|
+
* pushed archive and the session-agent restores it into the Pod's HOME — so the
|
|
93
|
+
* remote CLI `--resume` picks up exactly where the local session left off.
|
|
94
|
+
*
|
|
95
|
+
* Uses claude's cwd→dir encoding (slashes → dashes). With path parity (the
|
|
96
|
+
* Pod's cwd equals `cwd`) the remote CLI derives the identical project dir name,
|
|
97
|
+
* so the staged conversation is found on resume. Returns the staged conversation
|
|
98
|
+
* id (filename stem), or undefined if nothing was captured.
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Most-recent local conversation id for `cwd` (the active session), or
|
|
102
|
+
* undefined. Used to pass the exact id to the remote CLI's `--resume <id>` so it
|
|
103
|
+
* resumes directly instead of showing the interactive picker.
|
|
104
|
+
*/
|
|
105
|
+
function newestLocalConvId(cwd, profile, home) {
|
|
106
|
+
const relDir = PROFILE_STATE_DIRS[profile];
|
|
107
|
+
if (!relDir)
|
|
108
|
+
return undefined;
|
|
109
|
+
const src = join(home, relDir, cwd.replace(/\//g, "-"));
|
|
110
|
+
if (!existsSync(src))
|
|
111
|
+
return undefined;
|
|
112
|
+
let newest;
|
|
113
|
+
for (const e of readdirSync(src, { withFileTypes: true })) {
|
|
114
|
+
if (e.isFile() && e.name.endsWith(".jsonl")) {
|
|
115
|
+
const m = statSync(join(src, e.name)).mtimeMs;
|
|
116
|
+
if (!newest || m > newest.mtime)
|
|
117
|
+
newest = { name: e.name, mtime: m };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return newest?.name.replace(/\.jsonl$/, "");
|
|
121
|
+
}
|
|
122
|
+
function captureLiveConversation(cwd, profile, home, stderr) {
|
|
123
|
+
const relDir = PROFILE_STATE_DIRS[profile];
|
|
124
|
+
if (!relDir)
|
|
125
|
+
return undefined; // only claude's path-encoded projects for now
|
|
126
|
+
const projectDir = cwd.replace(/\//g, "-");
|
|
127
|
+
const src = join(home, relDir, projectDir);
|
|
128
|
+
if (!existsSync(src))
|
|
129
|
+
return undefined;
|
|
130
|
+
let newest;
|
|
131
|
+
for (const e of readdirSync(src, { withFileTypes: true })) {
|
|
132
|
+
if (e.isFile() && e.name.endsWith(".jsonl")) {
|
|
133
|
+
const m = statSync(join(src, e.name)).mtimeMs;
|
|
134
|
+
if (!newest || m > newest.mtime)
|
|
135
|
+
newest = { name: e.name, mtime: m };
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (!newest)
|
|
139
|
+
return undefined;
|
|
140
|
+
const dstDir = join(cwd, STATE_SUBDIR, profile, relDir, projectDir);
|
|
141
|
+
rmSync(join(cwd, STATE_SUBDIR, profile), { recursive: true, force: true });
|
|
142
|
+
mkdirSync(dstDir, { recursive: true });
|
|
143
|
+
// Stage only the main conversation .jsonl — it holds the full conversation.
|
|
144
|
+
// The companion `<convId>/` dir (subagent transcripts) is auxiliary, only used
|
|
145
|
+
// to expand subagent detail, and can be huge; skip it to stay lean (the remote
|
|
146
|
+
// archive has a size cap and rides a fragile port-forward).
|
|
147
|
+
cpSync(join(src, newest.name), join(dstDir, newest.name));
|
|
148
|
+
const convId = newest.name.replace(/\.jsonl$/, "");
|
|
149
|
+
stderr.write(`[remote] captured live ${profile} conversation ${convId} for resume\n`);
|
|
150
|
+
return convId;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Record the repo's origin/branch/HEAD into `<cwd>/.remote/git.json` so the
|
|
154
|
+
* session-agent can bootstrap git in the Pod (clone-on-start) when the full
|
|
155
|
+
* `.git` was too big to ship — the Pod fetches history from origin (gh auth is
|
|
156
|
+
* bundled) instead of transferring it. No-op outside a git repo / without an
|
|
157
|
+
* origin remote.
|
|
158
|
+
*/
|
|
159
|
+
function writeGitMetadata(cwd, stderr) {
|
|
160
|
+
const git = (args) => {
|
|
161
|
+
const r = spawnSync("git", args, { cwd, encoding: "utf8" });
|
|
162
|
+
return r.status === 0 ? r.stdout.trim() : "";
|
|
163
|
+
};
|
|
164
|
+
const origin = git(["remote", "get-url", "origin"]);
|
|
165
|
+
if (!origin)
|
|
166
|
+
return;
|
|
167
|
+
const branch = git(["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
168
|
+
const head = git(["rev-parse", "HEAD"]);
|
|
169
|
+
try {
|
|
170
|
+
mkdirSync(join(cwd, ".remote"), { recursive: true });
|
|
171
|
+
writeFileSync(join(cwd, ".remote", "git.json"), JSON.stringify({ origin, branch, head }, null, 2), "utf8");
|
|
172
|
+
stderr.write(`[remote] recorded git origin for clone-on-start: ${origin} (${branch || "HEAD"})\n`);
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
// best-effort
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Friendly project name for display in `remote ls`/`status`/`secrets`: the short
|
|
180
|
+
* GitHub repo name (last segment of origin) if it's a git repo, else the source
|
|
181
|
+
* directory basename.
|
|
182
|
+
*/
|
|
183
|
+
function friendlyName(cwd) {
|
|
184
|
+
const r = spawnSync("git", ["remote", "get-url", "origin"], {
|
|
185
|
+
cwd,
|
|
186
|
+
encoding: "utf8",
|
|
187
|
+
});
|
|
188
|
+
const origin = r.status === 0 ? r.stdout.trim() : "";
|
|
189
|
+
const m = origin ? /([^/:]+?)(?:\.git)?$/.exec(origin) : null;
|
|
190
|
+
if (m && m[1])
|
|
191
|
+
return m[1];
|
|
192
|
+
return cwd.replace(/\/+$/, "").split("/").pop() ?? cwd;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Push workspace project files to the remote, reusing the same pattern as
|
|
196
|
+
* `workspace push` in index.ts.
|
|
197
|
+
*/
|
|
198
|
+
async function pushWorkspace(cwd, remoteUrl, workspaceId, fetchImpl, stderr, leaseHdrs) {
|
|
199
|
+
await acquireWorkspaceLock(remoteUrl, workspaceId, lockHolderId(), 300, fetchImpl);
|
|
200
|
+
try {
|
|
201
|
+
stderr.write(`[remote] packing ${cwd} (respecting .gitignore)\n`);
|
|
202
|
+
const archive = await buildWorkspaceArchive(cwd);
|
|
203
|
+
stderr.write(`[remote] archive: ${(archive.byteLength / 1024).toFixed(0)} KiB -> ${workspaceId}\n`);
|
|
204
|
+
// Use a throwaway shell session to seed the PVC.
|
|
205
|
+
const session = await createRemoteSession(remoteUrl, {
|
|
206
|
+
profile: "shell",
|
|
207
|
+
workspaceId,
|
|
208
|
+
workspaceSync: true,
|
|
209
|
+
startupArgs: ["-c", "exit 0"],
|
|
210
|
+
}, fetchImpl);
|
|
211
|
+
await uploadWorkspaceArchive(remoteUrl, session.id, archive, fetchImpl, leaseHdrs);
|
|
212
|
+
const attached = await attach({
|
|
213
|
+
baseUrl: remoteUrl,
|
|
214
|
+
sessionId: session.id,
|
|
215
|
+
fetchImpl,
|
|
216
|
+
});
|
|
217
|
+
await attached.finished;
|
|
218
|
+
writeBaseSnapshot(cwd, archive);
|
|
219
|
+
stderr.write(`[remote] pushed ${cwd} to ${workspaceId}\n`);
|
|
220
|
+
return archive;
|
|
221
|
+
}
|
|
222
|
+
finally {
|
|
223
|
+
await releaseWorkspaceLock(remoteUrl, workspaceId, fetchImpl);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Pull workspace project files + session state from the remote, using the same
|
|
228
|
+
* pattern as `workspace pull --restore-sessions` in index.ts.
|
|
229
|
+
*/
|
|
230
|
+
async function pullWorkspace(cwd, home, remoteUrl, workspaceId, onConflict, fetchImpl, stderr) {
|
|
231
|
+
await acquireWorkspaceLock(remoteUrl, workspaceId, lockHolderId(), 300, fetchImpl);
|
|
232
|
+
try {
|
|
233
|
+
const session = await createRemoteSession(remoteUrl, {
|
|
234
|
+
profile: "shell",
|
|
235
|
+
workspaceId,
|
|
236
|
+
workspaceExport: true,
|
|
237
|
+
startupArgs: ["-c", "sleep 120"],
|
|
238
|
+
}, fetchImpl);
|
|
239
|
+
let remoteArchive = null;
|
|
240
|
+
try {
|
|
241
|
+
for (let attempt = 0; attempt < 60; attempt++) {
|
|
242
|
+
remoteArchive = await downloadWorkspaceExport(remoteUrl, session.id, fetchImpl);
|
|
243
|
+
if (remoteArchive)
|
|
244
|
+
break;
|
|
245
|
+
await new Promise((r) => setTimeout(r, 1000));
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
finally {
|
|
249
|
+
await stopRemoteSession(remoteUrl, session.id, "pull-complete", fetchImpl);
|
|
250
|
+
}
|
|
251
|
+
if (!remoteArchive) {
|
|
252
|
+
stderr.write(`[remote] nothing to pull (workspace ${workspaceId} produced no export)\n`);
|
|
253
|
+
return { remoteArchive: null, hasConflicts: false };
|
|
254
|
+
}
|
|
255
|
+
const mergeResult = mergeWorkspaceArchive({
|
|
256
|
+
cwd,
|
|
257
|
+
remoteArchive,
|
|
258
|
+
baseArchive: readBaseSnapshot(cwd),
|
|
259
|
+
});
|
|
260
|
+
stderr.write(`[remote] pull: ${mergeResult.tookRemote.length} from remote, ${mergeResult.keptLocal.length} kept local, ${mergeResult.merged.length} merged\n`);
|
|
261
|
+
let hasConflicts = false;
|
|
262
|
+
if (mergeResult.conflicts.length > 0) {
|
|
263
|
+
stderr.write(`[remote] ${mergeResult.conflicts.length} conflict(s) (left with markers, resolve then re-run):\n`);
|
|
264
|
+
for (const f of mergeResult.conflicts)
|
|
265
|
+
stderr.write(` ${f}\n`);
|
|
266
|
+
hasConflicts = true;
|
|
267
|
+
}
|
|
268
|
+
else {
|
|
269
|
+
writeBaseSnapshot(cwd, remoteArchive);
|
|
270
|
+
stderr.write(`[remote] pulled ${workspaceId} into ${cwd}\n`);
|
|
271
|
+
}
|
|
272
|
+
// Restore conversation state.
|
|
273
|
+
let anySessionConflict = false;
|
|
274
|
+
for (const profile of CLI_PROFILES) {
|
|
275
|
+
const r = restoreSessionsToLocal({
|
|
276
|
+
home,
|
|
277
|
+
profile,
|
|
278
|
+
remoteArchive,
|
|
279
|
+
onConflict,
|
|
280
|
+
});
|
|
281
|
+
const touched = r.restored.length + r.backedUp.length + r.conflicts.length;
|
|
282
|
+
if (touched === 0 && r.keptLocal.length === 0)
|
|
283
|
+
continue;
|
|
284
|
+
stderr.write(`[remote] sessions(${profile}): ${r.restored.length} restored, ${r.backedUp.length} backed-up, ${r.keptLocal.length} kept, ${r.conflicts.length} conflict\n`);
|
|
285
|
+
for (const b of r.backedUp)
|
|
286
|
+
stderr.write(` backup ${b}\n`);
|
|
287
|
+
if (r.conflicts.length > 0) {
|
|
288
|
+
anySessionConflict = true;
|
|
289
|
+
for (const c of r.conflicts)
|
|
290
|
+
stderr.write(` conflict ${c}\n`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
if (anySessionConflict) {
|
|
294
|
+
stderr.write(`[remote] diverged conversations left untouched. Re-run with --on-conflict backup or keep-local.\n`);
|
|
295
|
+
hasConflicts = true;
|
|
296
|
+
}
|
|
297
|
+
return { remoteArchive, hasConflicts };
|
|
298
|
+
}
|
|
299
|
+
finally {
|
|
300
|
+
await releaseWorkspaceLock(remoteUrl, workspaceId, fetchImpl);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
// ---------------------------------------------------------------------------
|
|
304
|
+
// Public API
|
|
305
|
+
// ---------------------------------------------------------------------------
|
|
306
|
+
/**
|
|
307
|
+
* Forward: migrate the current local session to a remote k8s session.
|
|
308
|
+
*
|
|
309
|
+
* Steps: link workspace → push files → create remote session → attach terminal.
|
|
310
|
+
*
|
|
311
|
+
* Terminal handoff: `migrateForward` calls `attach`, which hijacks the current
|
|
312
|
+
* process's stdin/stdout in raw mode and blocks until the remote session ends
|
|
313
|
+
* or the user presses Ctrl+P Ctrl+Q to detach. There is no separate process
|
|
314
|
+
* involved — this function IS the process holding the terminal.
|
|
315
|
+
*/
|
|
316
|
+
export async function migrateForward(options) {
|
|
317
|
+
const { profile: profileName, remoteUrl, resume, fetchImpl = fetch, cwd = process.cwd(), stderr = process.stderr, } = options;
|
|
318
|
+
const profile = coerceCliProfileName(profileName);
|
|
319
|
+
if (!profile) {
|
|
320
|
+
throw new Error(`Unknown profile "${profileName}". Known: codex, claude, agy, gemini, mistral, opencode, shell`);
|
|
321
|
+
}
|
|
322
|
+
// Step 1: ensure workspace is linked.
|
|
323
|
+
const marker = await resolveOrCreateWorkspace(cwd, remoteUrl, options.workspaceId, fetchImpl, stderr);
|
|
324
|
+
// Environment parity ("feel at home"): the project mounts at its real local
|
|
325
|
+
// path inside the Pod and HOME is reproduced, so the resumed conversation's
|
|
326
|
+
// absolute paths (cwd, file refs) resolve identically. Persisted on the
|
|
327
|
+
// workspace marker so every session bound to it is path-identical.
|
|
328
|
+
const home = marker.home ?? homedir();
|
|
329
|
+
const workspacePath = marker.path ?? cwd;
|
|
330
|
+
if (marker.path === undefined || marker.home === undefined) {
|
|
331
|
+
writeWorkspaceMarker(cwd, { ...marker, path: workspacePath, home });
|
|
332
|
+
}
|
|
333
|
+
// Resume the EXACT conversation by id so the remote CLI loads it directly
|
|
334
|
+
// instead of showing its interactive picker. `resume === true` ("most recent")
|
|
335
|
+
// is resolved to the local conversation id — which matches what the agent
|
|
336
|
+
// restores in the Pod thanks to path parity (same project-dir encoding).
|
|
337
|
+
let resolvedResume = resume;
|
|
338
|
+
if (resume === true) {
|
|
339
|
+
const cid = newestLocalConvId(cwd, profile, home);
|
|
340
|
+
if (cid)
|
|
341
|
+
resolvedResume = cid;
|
|
342
|
+
}
|
|
343
|
+
if (options.reconnect) {
|
|
344
|
+
// Revive on the existing PVC: no capture, no push — the conversation and any
|
|
345
|
+
// work done remotely are already on the retained workspace volume.
|
|
346
|
+
stderr.write(`[remote] reconnect: reusing workspace ${marker.workspaceId} as-is (no push)\n`);
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
// Record git origin so the Pod can clone-on-start when .git is too big to
|
|
350
|
+
// ship (the size-gate in buildWorkspaceArchive skips large histories).
|
|
351
|
+
writeGitMetadata(cwd, stderr);
|
|
352
|
+
// When resuming, stage the live conversation so it rides the pushed archive
|
|
353
|
+
// and the session-agent restores it into HOME — the remote CLI then resumes
|
|
354
|
+
// exactly where the local session left off (path parity makes the project
|
|
355
|
+
// dir encoding match on both sides).
|
|
356
|
+
if (resume !== undefined) {
|
|
357
|
+
captureLiveConversation(cwd, profile, home, stderr);
|
|
358
|
+
}
|
|
359
|
+
// Step 2 & 3: push workspace, protected by a lineage lease (A0c fencing).
|
|
360
|
+
// Phase A: read or create a persistent lineageId in .remote/lineages/ so
|
|
361
|
+
// the same id is reused across forward/back cycles for this workspace.
|
|
362
|
+
let lineageRec = readLineageRecord(cwd, marker.workspaceId) ??
|
|
363
|
+
{ lineageId: `lin_${randomUUID().replace(/-/g, "").slice(0, 24)}` };
|
|
364
|
+
writeLineageRecord(cwd, marker.workspaceId, lineageRec);
|
|
365
|
+
const lineageId = lineageRec.lineageId;
|
|
366
|
+
const holder = lockHolderId();
|
|
367
|
+
const incarnationId = `${holder}:${process.pid}`;
|
|
368
|
+
let activeLease;
|
|
369
|
+
try {
|
|
370
|
+
const result = await acquireLineageLease(remoteUrl, { lineageId, holder, incarnationId, location: "local", ttlMs: 300_000 }, fetchImpl);
|
|
371
|
+
if ("error" in result) {
|
|
372
|
+
throw new Error(`[remote] workspace is already being migrated (concurrent push detected).\n` +
|
|
373
|
+
` Current holder: ${result.current.holder}\n` +
|
|
374
|
+
` Wait for the other migration to complete, or release the lease manually.`);
|
|
375
|
+
}
|
|
376
|
+
activeLease = result;
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
const msg = err.message;
|
|
380
|
+
// Graceful fallback: if the CP doesn't have the lineage-leases route yet
|
|
381
|
+
// (404) or is unreachable, skip enforcement (backward compat).
|
|
382
|
+
if (msg.includes("acquireLineageLease: 404") || msg.includes("ECONNREFUSED") || msg.includes("ENOTFOUND")) {
|
|
383
|
+
stderr.write(`[remote] lineage lease skipped (CP missing route or unreachable)\n`);
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
throw err;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
try {
|
|
390
|
+
await pushWorkspace(cwd, remoteUrl, marker.workspaceId, fetchImpl, stderr, activeLease ? leaseHeaders(activeLease) : undefined);
|
|
391
|
+
}
|
|
392
|
+
finally {
|
|
393
|
+
if (activeLease) {
|
|
394
|
+
// Release the lease now that the push is complete. The remote session
|
|
395
|
+
// will acquire its own lease when it starts writing (Phase A wires this
|
|
396
|
+
// into the session-agent). Idempotent — errors are swallowed.
|
|
397
|
+
await releaseLineageLease(remoteUrl, activeLease.lineageId, { holder, expectedEpoch: activeLease.epoch }, fetchImpl).catch(() => undefined);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// Step 4: create remote session. Bundle the profile's local credentials so
|
|
402
|
+
// the migrated CLI is authenticated in-pod, mirroring the `remote <profile>`
|
|
403
|
+
// run path. Missing creds are tolerated (the session still starts; shell /
|
|
404
|
+
// opencode need none) — we warn rather than hard-fail.
|
|
405
|
+
const authFiles = {
|
|
406
|
+
...(await collectProfileAuth(profile)),
|
|
407
|
+
};
|
|
408
|
+
// Also bundle the auth of selected tool CLIs (scw, gh, aws, gcloud, az) so
|
|
409
|
+
// they work inside the Pod — opt-in via `tools`.
|
|
410
|
+
let bundledTools = [];
|
|
411
|
+
if (options.tools && options.tools.length > 0) {
|
|
412
|
+
const { bundle: toolBundle, bundled } = await collectToolAuth(options.tools);
|
|
413
|
+
Object.assign(authFiles, toolBundle);
|
|
414
|
+
bundledTools = bundled;
|
|
415
|
+
}
|
|
416
|
+
const credentials = Object.keys(authFiles).length > 0 ? authFiles : undefined;
|
|
417
|
+
const resumeArgs = resolvedResume !== undefined
|
|
418
|
+
? buildResumeStartupArgs(profile, resolvedResume)
|
|
419
|
+
: [];
|
|
420
|
+
const session = await createRemoteSession(remoteUrl, {
|
|
421
|
+
profile,
|
|
422
|
+
workspaceId: marker.workspaceId,
|
|
423
|
+
workspacePath,
|
|
424
|
+
home,
|
|
425
|
+
displayName: friendlyName(cwd),
|
|
426
|
+
workspaceSync: true,
|
|
427
|
+
...(credentials ? { credentials } : {}),
|
|
428
|
+
...(resumeArgs.length > 0 ? { startupArgs: resumeArgs } : {}),
|
|
429
|
+
}, fetchImpl);
|
|
430
|
+
stderr.write(credentials
|
|
431
|
+
? `[remote] bundled ${profile} creds: ${Object.keys(credentials).join(", ")}\n`
|
|
432
|
+
: `[remote] no ${profile} creds found locally — session starts unauthenticated\n`);
|
|
433
|
+
if (bundledTools.length > 0) {
|
|
434
|
+
stderr.write(`[remote] bundled tool auth: ${bundledTools.join(", ")}\n`);
|
|
435
|
+
}
|
|
436
|
+
stderr.write(`[remote] migrated to remote session ${session.id} on ${remoteUrl} (workspace ${marker.workspaceId})\n`);
|
|
437
|
+
// Phase A: record the active remote session so migrateBack can target it
|
|
438
|
+
// directly without a list-sessions round-trip.
|
|
439
|
+
if (!options.reconnect) {
|
|
440
|
+
// lineageRec may be undefined if the push was skipped (reconnect path) or
|
|
441
|
+
// if the lease acquisition fell back (old CP). Read fresh to avoid closure issues.
|
|
442
|
+
const rec = readLineageRecord(cwd, marker.workspaceId);
|
|
443
|
+
if (rec) {
|
|
444
|
+
writeLineageRecord(cwd, marker.workspaceId, {
|
|
445
|
+
...rec,
|
|
446
|
+
remoteSessionId: session.id,
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
// Step 5: hand off terminal — unless --no-attach (bulk / reconnect-yourself).
|
|
451
|
+
if (options.noAttach) {
|
|
452
|
+
stderr.write(`[remote] session ready (not attached). Reconnect your terminal with:\n` +
|
|
453
|
+
` remote attach ${remoteUrl} ${session.id}\n`);
|
|
454
|
+
return { workspaceId: marker.workspaceId, sessionId: session.id };
|
|
455
|
+
}
|
|
456
|
+
stderr.write(`[remote] terminal is now REMOTE — press Ctrl+P Ctrl+Q to detach without stopping the session\n`);
|
|
457
|
+
const attached = await attach({
|
|
458
|
+
baseUrl: remoteUrl,
|
|
459
|
+
sessionId: session.id,
|
|
460
|
+
fetchImpl,
|
|
461
|
+
});
|
|
462
|
+
await attached.finished;
|
|
463
|
+
return { workspaceId: marker.workspaceId, sessionId: session.id };
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Back: pull the remote session back to local.
|
|
467
|
+
*
|
|
468
|
+
* Steps: pull workspace + conversation state → stop remote session → print
|
|
469
|
+
* resume command.
|
|
470
|
+
*
|
|
471
|
+
* We do NOT spawn the local CLI — we print the resume command so the user
|
|
472
|
+
* retains control of when and how they restart.
|
|
473
|
+
*/
|
|
474
|
+
export async function migrateBack(options) {
|
|
475
|
+
const { remoteUrl, onConflict = "block", fetchImpl = fetch, cwd = process.cwd(), home = process.env.HOME ?? "", stderr = process.stderr, stdout = process.stdout, } = options;
|
|
476
|
+
// Step 1: resolve workspace.
|
|
477
|
+
const existing = readWorkspaceMarker(cwd);
|
|
478
|
+
const workspaceId = options.workspaceId ?? existing?.workspaceId;
|
|
479
|
+
if (!workspaceId) {
|
|
480
|
+
throw new Error("No workspace mapped for this directory and no --workspace given. Run `remote workspace link` first or pass --workspace <id>.");
|
|
481
|
+
}
|
|
482
|
+
// Step 2: pull workspace + conversation state.
|
|
483
|
+
const { remoteArchive, hasConflicts } = await pullWorkspace(cwd, home, remoteUrl, workspaceId, onConflict, fetchImpl, stderr);
|
|
484
|
+
// Phase A: read the lineage record so we can target the exact session that
|
|
485
|
+
// was created by migrateForward, skipping the list-sessions round-trip.
|
|
486
|
+
const lineageRec = readLineageRecord(cwd, workspaceId);
|
|
487
|
+
// Step 3: stop the remote session for this workspace.
|
|
488
|
+
let stoppedSessionId;
|
|
489
|
+
try {
|
|
490
|
+
const { listRemoteSessions } = await import("./attach.js");
|
|
491
|
+
// Priority: explicit sessionId arg > lineage record > list-sessions heuristic.
|
|
492
|
+
let target;
|
|
493
|
+
if (options.sessionId) {
|
|
494
|
+
target = { id: options.sessionId };
|
|
495
|
+
}
|
|
496
|
+
else if (lineageRec?.remoteSessionId) {
|
|
497
|
+
target = { id: lineageRec.remoteSessionId };
|
|
498
|
+
stderr.write(`[remote] targeting session ${target.id} from lineage record\n`);
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
const sessions = await listRemoteSessions(remoteUrl, fetchImpl);
|
|
502
|
+
if (sessions.length > 0) {
|
|
503
|
+
const sorted = [...sessions].sort((a, b) => b.createdAt.localeCompare(a.createdAt));
|
|
504
|
+
target =
|
|
505
|
+
sorted.find((s) => s.workspaceId === workspaceId) ?? sorted[0];
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
if (target !== undefined) {
|
|
509
|
+
await stopRemoteSession(remoteUrl, target.id, "migrate-back", fetchImpl);
|
|
510
|
+
stoppedSessionId = target.id;
|
|
511
|
+
stderr.write(`[remote] stopped remote session ${target.id}\n`);
|
|
512
|
+
// Clear the active session from the lineage record — the migration is done.
|
|
513
|
+
if (lineageRec) {
|
|
514
|
+
writeLineageRecord(cwd, workspaceId, { lineageId: lineageRec.lineageId });
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
catch (err) {
|
|
519
|
+
stderr.write(`[remote] warning: could not stop remote session: ${String(err)}\n`);
|
|
520
|
+
}
|
|
521
|
+
// Step 4: derive and print resume command.
|
|
522
|
+
// Pick a profile from the restored archive — use the first CLI profile that
|
|
523
|
+
// has session state in the archive; fall back to the session's profile if
|
|
524
|
+
// available.
|
|
525
|
+
let resumeProfile;
|
|
526
|
+
let resumeConvId;
|
|
527
|
+
if (remoteArchive) {
|
|
528
|
+
// Peek at which profiles have session state in the archive.
|
|
529
|
+
// (restoreSessionsToLocal already ran — we just need to know the profile.)
|
|
530
|
+
for (const p of CLI_PROFILES) {
|
|
531
|
+
const r = restoreSessionsToLocal({
|
|
532
|
+
home,
|
|
533
|
+
profile: p,
|
|
534
|
+
remoteArchive,
|
|
535
|
+
onConflict: "keep-local", // dry-run: don't overwrite again
|
|
536
|
+
});
|
|
537
|
+
// Pick profile that has the most restored/kept items.
|
|
538
|
+
if (r.restored.length + r.keptLocal.length > 0) {
|
|
539
|
+
resumeProfile = p;
|
|
540
|
+
// The restored conversation id is not trivially extractable here;
|
|
541
|
+
// we fall back to the generic --resume / --continue flag without an id.
|
|
542
|
+
break;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const finalProfile = resumeProfile ?? "claude";
|
|
547
|
+
// Advice string: the ACTUAL CLI command shape (remote run … -r <id>), not a
|
|
548
|
+
// raw profile flag — codex's resume is a subcommand, claude's differs by id.
|
|
549
|
+
const resumeCommand = resumeConvId
|
|
550
|
+
? `remote run ${finalProfile} -r ${resumeConvId}`
|
|
551
|
+
: `remote run ${finalProfile}`;
|
|
552
|
+
stdout.write(`\n[remote] local state restored from workspace ${workspaceId}\n`);
|
|
553
|
+
stdout.write(`[remote] resume your session with:\n\n ${resumeCommand}\n\n`);
|
|
554
|
+
return {
|
|
555
|
+
workspaceId,
|
|
556
|
+
...(stoppedSessionId !== undefined ? { stoppedSessionId } : {}),
|
|
557
|
+
resumeCommand,
|
|
558
|
+
hasConflicts,
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,WAAW,EACX,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,E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