@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/restore.js
ADDED
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `remote restore` — relaunch recent local dev sessions (claude/codex) in their
|
|
3
|
+
* layout, each tab a remote-managed tmux session (durable, live-named).
|
|
4
|
+
*
|
|
5
|
+
* This OWNS the launcher logic in the CLI (discovery + grouping + layout +
|
|
6
|
+
* terminal launch), so `~/bin/resume-dev-sessions` is just `exec remote
|
|
7
|
+
* restore`. SCW sessions and persisted positions come later.
|
|
8
|
+
*/
|
|
9
|
+
import { spawn } from "node:child_process";
|
|
10
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, statSync, writeFileSync, } from "node:fs";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { dirname, join } from "node:path";
|
|
13
|
+
import { getLayoutConfig, resolveConfigPath, } from "./config.js";
|
|
14
|
+
import { listLive } from "./registry.js";
|
|
15
|
+
import { listLocalSessions, slugify } from "./tmux.js";
|
|
16
|
+
/** claude encodes a cwd into its project-dir name by replacing "/" with "-". */
|
|
17
|
+
function encodeCwd(cwd) {
|
|
18
|
+
return cwd.replace(/\//g, "-");
|
|
19
|
+
}
|
|
20
|
+
/** Discover claude + codex sessions under ~/src/* newer than maxAgeMs. */
|
|
21
|
+
export function discoverSessions(maxAgeMs, home = homedir()) {
|
|
22
|
+
const src = join(home, "src");
|
|
23
|
+
const cutoff = Date.now() - maxAgeMs;
|
|
24
|
+
const out = [];
|
|
25
|
+
// --- claude: <home>/.claude/projects/<encode(~/src/<proj>)…>/<sid>.jsonl ---
|
|
26
|
+
const claudeRoot = join(home, ".claude", "projects");
|
|
27
|
+
const claudePrefix = `${encodeCwd(src)}-`;
|
|
28
|
+
if (existsSync(claudeRoot)) {
|
|
29
|
+
for (const dirName of readdirSync(claudeRoot)) {
|
|
30
|
+
if (!dirName.startsWith(claudePrefix))
|
|
31
|
+
continue;
|
|
32
|
+
// claude encodes the full cwd as "/"→"-"; the remainder after the
|
|
33
|
+
// ~/src/ prefix IS the project for a direct child of ~/src. Keep it
|
|
34
|
+
// whole (project names contain "-": sent-tech-design-system) and skip
|
|
35
|
+
// anything that isn't an existing ~/src/<project> dir (sub-paths encode
|
|
36
|
+
// ambiguously and the workdir wouldn't exist anyway).
|
|
37
|
+
const project = dirName.slice(claudePrefix.length);
|
|
38
|
+
const cwd = join(src, project);
|
|
39
|
+
const cst = safeStat(cwd);
|
|
40
|
+
if (!cst || !statSync(cwd).isDirectory())
|
|
41
|
+
continue;
|
|
42
|
+
const dir = join(claudeRoot, dirName);
|
|
43
|
+
let entries;
|
|
44
|
+
try {
|
|
45
|
+
entries = readdirSync(dir);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
for (const f of entries) {
|
|
51
|
+
if (!f.endsWith(".jsonl"))
|
|
52
|
+
continue;
|
|
53
|
+
const st = safeStat(join(dir, f));
|
|
54
|
+
if (!st || st.mtimeMs < cutoff)
|
|
55
|
+
continue;
|
|
56
|
+
out.push({
|
|
57
|
+
project,
|
|
58
|
+
mtimeMs: st.mtimeMs,
|
|
59
|
+
tool: "claude",
|
|
60
|
+
sid: f.replace(/\.jsonl$/, ""),
|
|
61
|
+
cwd: join(src, project),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// --- codex: <home>/.codex/sessions/**/rollout-*.jsonl (cwd+id in line 1) ---
|
|
67
|
+
const codexRoot = join(home, ".codex", "sessions");
|
|
68
|
+
if (existsSync(codexRoot)) {
|
|
69
|
+
for (const file of walk(codexRoot)) {
|
|
70
|
+
const base = file.split("/").pop() ?? "";
|
|
71
|
+
if (!base.startsWith("rollout-") || !base.endsWith(".jsonl"))
|
|
72
|
+
continue;
|
|
73
|
+
const st = safeStat(file);
|
|
74
|
+
if (!st || st.mtimeMs < cutoff)
|
|
75
|
+
continue;
|
|
76
|
+
const meta = firstLineJson(file);
|
|
77
|
+
const cwd = meta?.payload?.cwd;
|
|
78
|
+
const id = meta?.payload?.id;
|
|
79
|
+
if (!cwd || !id || !cwd.startsWith(`${src}/`))
|
|
80
|
+
continue;
|
|
81
|
+
const project = cwd.slice(src.length + 1).split("/")[0];
|
|
82
|
+
out.push({ project, mtimeMs: st.mtimeMs, tool: "codex", sid: id, cwd });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return out;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* REGISTRY-FIRST discovery: live registry entries (local kinds) mapped to
|
|
89
|
+
* discovered sessions. label/cwd/convId come straight from enrolment, no
|
|
90
|
+
* mtime guessing. `entries` is injectable for tests (defaults to listLive()).
|
|
91
|
+
*/
|
|
92
|
+
export function registrySessions(home = homedir(), entries = listLive()) {
|
|
93
|
+
const src = join(home, "src");
|
|
94
|
+
const out = [];
|
|
95
|
+
for (const e of entries) {
|
|
96
|
+
if (e.kind === "remote")
|
|
97
|
+
continue; // remote groups are filled from SCW
|
|
98
|
+
if (!e.cwd.startsWith(`${src}/`))
|
|
99
|
+
continue;
|
|
100
|
+
const project = e.cwd.slice(src.length + 1).split("/")[0];
|
|
101
|
+
if (!project)
|
|
102
|
+
continue;
|
|
103
|
+
const seen = Date.parse(e.lastSeenAt);
|
|
104
|
+
const session = {
|
|
105
|
+
project,
|
|
106
|
+
mtimeMs: Number.isFinite(seen) ? seen : Date.now(),
|
|
107
|
+
tool: e.tool,
|
|
108
|
+
sid: e.convId ?? "",
|
|
109
|
+
cwd: e.cwd,
|
|
110
|
+
origin: "registry",
|
|
111
|
+
};
|
|
112
|
+
if (e.label !== undefined)
|
|
113
|
+
session.label = e.label;
|
|
114
|
+
if (e.gatewayMode !== undefined)
|
|
115
|
+
session.gatewayMode = e.gatewayMode;
|
|
116
|
+
out.push(session);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Merge discovery sources: registry entries win; the filesystem scan only
|
|
122
|
+
* completes projects that have NO registry entry (tagged origin "scan").
|
|
123
|
+
*/
|
|
124
|
+
export function mergeDiscovered(registry, scanned) {
|
|
125
|
+
const covered = new Set(registry.map((s) => s.project));
|
|
126
|
+
return [
|
|
127
|
+
...registry,
|
|
128
|
+
...scanned
|
|
129
|
+
.filter((s) => !covered.has(s.project))
|
|
130
|
+
.map((s) => ({ ...s, origin: "scan" })),
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Identity slug used to dedup a LOCAL discovered session against a REMOTE tab
|
|
135
|
+
* (bug #3). Both sides are reduced to lowercase alnum runs so "Sentropic
|
|
136
|
+
* Remote"/"sentropic-remote"/"sentropic_remote" collapse to one key. A `#N`
|
|
137
|
+
* fan-out suffix is kept distinct (it is a different session).
|
|
138
|
+
*/
|
|
139
|
+
export function sessionIdentitySlug(name) {
|
|
140
|
+
return name
|
|
141
|
+
.toLowerCase()
|
|
142
|
+
.replace(/[^a-z0-9#]+/g, "-")
|
|
143
|
+
.replace(/^-+|-+$/g, "");
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Bug #3 — a session that was MOVED to a remote Pod keeps reappearing as a fresh
|
|
147
|
+
* LOCAL tmux because the local conversation files (claude .jsonl / codex
|
|
148
|
+
* rollout) and any stale local registry entry survive the move, so the local
|
|
149
|
+
* discovery still emits a tab for that project. Drop every local discovered
|
|
150
|
+
* session whose project/label identity is already covered by a REMOTE tab: the
|
|
151
|
+
* remote group owns it, and re-launching it locally would spawn a ghost
|
|
152
|
+
* duplicate. Match is by identity slug of the local `label` (else `project`)
|
|
153
|
+
* against the remote tab `label` — the remote tab's cwd is the Pod path (often
|
|
154
|
+
* absent locally) so cwd can't be the key; the friendly name is. Pure; the
|
|
155
|
+
* remote-backed locals are returned separately so the caller can report them.
|
|
156
|
+
*/
|
|
157
|
+
export function dropRemoteBackedLocals(locals, remoteTabs) {
|
|
158
|
+
if (remoteTabs.length === 0)
|
|
159
|
+
return { kept: locals, dropped: [] };
|
|
160
|
+
const remoteKeys = new Set(remoteTabs.map((t) => sessionIdentitySlug(t.label)));
|
|
161
|
+
const kept = [];
|
|
162
|
+
const dropped = [];
|
|
163
|
+
for (const s of locals) {
|
|
164
|
+
const key = sessionIdentitySlug(s.label ?? s.project);
|
|
165
|
+
if (remoteKeys.has(key))
|
|
166
|
+
dropped.push(s);
|
|
167
|
+
else
|
|
168
|
+
kept.push(s);
|
|
169
|
+
}
|
|
170
|
+
return { kept, dropped };
|
|
171
|
+
}
|
|
172
|
+
function safeStat(p) {
|
|
173
|
+
try {
|
|
174
|
+
return statSync(p);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return undefined;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function firstLineJson(file) {
|
|
181
|
+
try {
|
|
182
|
+
const buf = readFileSync(file, "utf8");
|
|
183
|
+
const nl = buf.indexOf("\n");
|
|
184
|
+
return JSON.parse(nl === -1 ? buf : buf.slice(0, nl));
|
|
185
|
+
}
|
|
186
|
+
catch {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function* walk(root) {
|
|
191
|
+
let entries;
|
|
192
|
+
try {
|
|
193
|
+
entries = readdirSync(root, { withFileTypes: true });
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
for (const e of entries) {
|
|
199
|
+
const p = join(root, e.name);
|
|
200
|
+
if (e.isDirectory())
|
|
201
|
+
yield* walk(p);
|
|
202
|
+
else if (e.isFile())
|
|
203
|
+
yield p;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Group discovered sessions into terminal windows per the layout config:
|
|
208
|
+
* - explicit groups first (their projects leave the shared pool),
|
|
209
|
+
* - the rest round-robin into `sharedWindows` windows,
|
|
210
|
+
* - capped at `maxPerWindow` tabs each,
|
|
211
|
+
* - keeping the N most recent sessions per project (`multiSession`, def 1).
|
|
212
|
+
*/
|
|
213
|
+
export function groupSessions(sessions, cfg) {
|
|
214
|
+
// newest-first per project, capped per project
|
|
215
|
+
const byProject = new Map();
|
|
216
|
+
for (const s of sessions) {
|
|
217
|
+
const arr = byProject.get(s.project) ?? [];
|
|
218
|
+
arr.push(s);
|
|
219
|
+
byProject.set(s.project, arr);
|
|
220
|
+
}
|
|
221
|
+
const slotsFor = (project) => {
|
|
222
|
+
// Per-project cap: explicit override, else the global default. <= 0 = no
|
|
223
|
+
// limit (every live session of the project gets a tab) — `remote restore`
|
|
224
|
+
// then sweeps the WHOLE fleet, duplicates included.
|
|
225
|
+
const cap = cfg.multiSession[project] ?? cfg.multiSessionDefault;
|
|
226
|
+
const limit = cap <= 0 ? Number.POSITIVE_INFINITY : cap;
|
|
227
|
+
const arr = (byProject.get(project) ?? [])
|
|
228
|
+
.slice()
|
|
229
|
+
.sort((a, b) => b.mtimeMs - a.mtimeMs)
|
|
230
|
+
.slice(0, limit);
|
|
231
|
+
return arr.map((s, i) => {
|
|
232
|
+
const tab = {
|
|
233
|
+
cwd: s.cwd,
|
|
234
|
+
label: s.label ?? (i === 0 ? s.project : `${s.project}#${i + 1}`),
|
|
235
|
+
tool: s.tool,
|
|
236
|
+
sid: s.sid,
|
|
237
|
+
};
|
|
238
|
+
if (s.origin !== undefined)
|
|
239
|
+
tab.origin = s.origin;
|
|
240
|
+
if (s.gatewayMode !== undefined)
|
|
241
|
+
tab.gatewayMode = s.gatewayMode;
|
|
242
|
+
return tab;
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
const grouped = new Set();
|
|
246
|
+
const windows = [];
|
|
247
|
+
for (const g of cfg.groups) {
|
|
248
|
+
if (g.remote)
|
|
249
|
+
continue; // remote groups are filled from SCW by the caller
|
|
250
|
+
const tabs = [];
|
|
251
|
+
for (const project of g.projects ?? []) {
|
|
252
|
+
grouped.add(project);
|
|
253
|
+
for (const slot of slotsFor(project)) {
|
|
254
|
+
if (tabs.length >= cfg.maxPerWindow)
|
|
255
|
+
break;
|
|
256
|
+
tabs.push(slot);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (tabs.length > 0)
|
|
260
|
+
windows.push({ title: g.title, tabs });
|
|
261
|
+
}
|
|
262
|
+
// remaining projects, most-recent project first, round-robin into shared wins
|
|
263
|
+
const remaining = [...byProject.entries()]
|
|
264
|
+
.filter(([p]) => !grouped.has(p))
|
|
265
|
+
.sort((a, b) => projLatest(b[1]) - projLatest(a[1]))
|
|
266
|
+
.map(([p]) => p);
|
|
267
|
+
const sharedSlots = [];
|
|
268
|
+
for (const project of remaining)
|
|
269
|
+
sharedSlots.push(...slotsFor(project));
|
|
270
|
+
const shared = Array.from({ length: Math.max(1, cfg.sharedWindows) }, () => []);
|
|
271
|
+
const maxShared = cfg.sharedWindows * cfg.maxPerWindow;
|
|
272
|
+
let placed = 0;
|
|
273
|
+
for (const slot of sharedSlots) {
|
|
274
|
+
if (placed >= maxShared)
|
|
275
|
+
break;
|
|
276
|
+
shared[placed % cfg.sharedWindows].push(slot);
|
|
277
|
+
placed++;
|
|
278
|
+
}
|
|
279
|
+
const dropped = sharedSlots.length - placed;
|
|
280
|
+
shared.forEach((tabs, i) => {
|
|
281
|
+
if (tabs.length > 0)
|
|
282
|
+
windows.push({ title: `fenêtre partagée ${i + 1}`, tabs });
|
|
283
|
+
});
|
|
284
|
+
return { windows, dropped };
|
|
285
|
+
}
|
|
286
|
+
function projLatest(arr) {
|
|
287
|
+
return arr.reduce((m, s) => Math.max(m, s.mtimeMs), 0);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Per-tab command: SCW via `attach --exec`; a LOCAL session that is already
|
|
291
|
+
* live → `remote attach <slug>` (do NOT `remote run -r`, which the single-writer
|
|
292
|
+
* guard refuses while that session still holds the conversation — this is what
|
|
293
|
+
* broke a `restore` over still-detached sessions); otherwise create it via
|
|
294
|
+
* `remote run … --resume …` (which attaches by default). `liveSlugs` = slugs of
|
|
295
|
+
* currently-live local tmux sessions (empty for the reproducible layout snapshot).
|
|
296
|
+
*/
|
|
297
|
+
export function tabCommand(tab, liveSlugs = new Set(), opts = {}) {
|
|
298
|
+
const q = (s) => `'${s.replace(/'/g, "'\\''")}'`;
|
|
299
|
+
if (tab.remoteId) {
|
|
300
|
+
// SCW: attach straight into the Pod's tmux (live, copy-friendly).
|
|
301
|
+
return `remote attach ${q(tab.remoteId)} --exec`;
|
|
302
|
+
}
|
|
303
|
+
const slug = slugify(tab.label);
|
|
304
|
+
// Effective gateway posture: an explicit `restore --gw/--no-gw` OVERRIDES the
|
|
305
|
+
// per-instance pin; otherwise honour the pinned gatewayMode (absent = default).
|
|
306
|
+
const posture = opts.forceGateway ?? tab.gatewayMode;
|
|
307
|
+
const gwFlag = posture === "gateway" ? " --gw" : posture === "direct" ? " --no-gw" : "";
|
|
308
|
+
const runCmd = (extra) => `remote run ${q(tab.tool ?? "shell")} ${q(tab.cwd)} ` +
|
|
309
|
+
(tab.sid ? `--resume ${q(tab.sid)} ` : "") +
|
|
310
|
+
`--name ${q(tab.label)}${gwFlag}${extra}`;
|
|
311
|
+
if (liveSlugs.has(slug)) {
|
|
312
|
+
// Already running. Normally we just attach (no redundant relaunch, no guard
|
|
313
|
+
// fight). But a forced posture (restore --gw/--no-gw) must actually SWITCH a
|
|
314
|
+
// live session — a reattach can't change a running process's gateway env.
|
|
315
|
+
// `remote run` has NO --replace and refuses to clobber a live session, so
|
|
316
|
+
// relaunch via `remote resume --replace`: it kills the running tmux session,
|
|
317
|
+
// resumes the conversation in the forced posture (--no-gw scrubs the gateway
|
|
318
|
+
// env), and --attach reopens the terminal onto it.
|
|
319
|
+
if (!opts.forceGateway)
|
|
320
|
+
return `remote attach ${q(slug)}`;
|
|
321
|
+
return `remote resume ${q(slug)} --replace --attach${gwFlag}`;
|
|
322
|
+
}
|
|
323
|
+
return runCmd("");
|
|
324
|
+
}
|
|
325
|
+
// gnome-terminal applies ONE trailing `-- command` to EVERY tab of an
|
|
326
|
+
// invocation (you cannot give each tab its own `--`). So all tabs run the same
|
|
327
|
+
// dispatcher; each claims (under flock) the first map line matching its $PWD
|
|
328
|
+
// and runs that tab's command — exactly how ~/bin/resume-dev-sessions worked.
|
|
329
|
+
const DISPATCHER = `map="$1"
|
|
330
|
+
lock="$map.lock"
|
|
331
|
+
exec 9>"$lock"; flock 9
|
|
332
|
+
line=$(awk -F'\\t' -v c="$PWD" '$1==c{print;exit}' "$map")
|
|
333
|
+
if [ -n "$line" ]; then
|
|
334
|
+
awk -F'\\t' -v c="$PWD" 'BEGIN{d=0} d==0 && $1==c {d=1; next} {print}' "$map" > "$map.tmp" && mv "$map.tmp" "$map"
|
|
335
|
+
fi
|
|
336
|
+
flock -u 9
|
|
337
|
+
cmd=$(printf '%s' "$line" | cut -f2-)
|
|
338
|
+
if [ -n "$cmd" ]; then eval "$cmd"; else echo "[remote] rien a reprendre pour $PWD" >&2; fi
|
|
339
|
+
exec bash -l`;
|
|
340
|
+
let mapCounter = 0;
|
|
341
|
+
function runDir() {
|
|
342
|
+
const base = process.env.XDG_RUNTIME_DIR
|
|
343
|
+
? join(process.env.XDG_RUNTIME_DIR, "sentropic-remote")
|
|
344
|
+
: join(homedir(), ".config", "sentropic", "remote-cli", "run");
|
|
345
|
+
mkdirSync(base, { recursive: true });
|
|
346
|
+
return base;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Launch the layout in gnome-terminal: one window per group, one tab per session.
|
|
350
|
+
*
|
|
351
|
+
* Default behaviour (reattach=false): sessions already live in tmux are SKIPPED —
|
|
352
|
+
* no new terminal tab is opened for them. The assumption is that if a tmux session
|
|
353
|
+
* exists, the user either has a terminal showing it or intentionally left it running.
|
|
354
|
+
* Use reattach=true (--reattach flag) to reopen a terminal tab for every session
|
|
355
|
+
* regardless of its current tmux state.
|
|
356
|
+
*/
|
|
357
|
+
export function launchLayout(windows, stderr = process.stderr, opts = {}) {
|
|
358
|
+
const liveSlugs = new Set(listLocalSessions().map((s) => s.slug));
|
|
359
|
+
const skippedLive = [];
|
|
360
|
+
let opened = 0;
|
|
361
|
+
// A forced posture must reach EVERY session (live ones get relaunched), so it
|
|
362
|
+
// includes already-live tabs just like --reattach.
|
|
363
|
+
const includeLive = opts.reattach || opts.forceGateway !== undefined;
|
|
364
|
+
const tabOpts = opts.forceGateway ? { forceGateway: opts.forceGateway } : {};
|
|
365
|
+
for (const win of windows) {
|
|
366
|
+
// Filter tabs: skip local sessions already in tmux (attach would be redundant).
|
|
367
|
+
// Remote (k8s) tabs are always included — we can't probe pod health here.
|
|
368
|
+
const activeTabs = includeLive
|
|
369
|
+
? win.tabs
|
|
370
|
+
: win.tabs.filter((t) => {
|
|
371
|
+
if (t.remoteId)
|
|
372
|
+
return true;
|
|
373
|
+
const slug = slugify(t.label);
|
|
374
|
+
if (liveSlugs.has(slug)) {
|
|
375
|
+
skippedLive.push(t.label);
|
|
376
|
+
return false;
|
|
377
|
+
}
|
|
378
|
+
return true;
|
|
379
|
+
});
|
|
380
|
+
if (activeTabs.length === 0) {
|
|
381
|
+
// All sessions in this window are already active — no tab needed.
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
// Map keyed by per-tab working directory -> the tab's command. Tabs sharing
|
|
385
|
+
// a cwd (several sessions of one project) each claim a distinct line FIFO.
|
|
386
|
+
const slug = win.title.replace(/[^a-zA-Z0-9]+/g, "-");
|
|
387
|
+
const mapPath = join(runDir(), `restore-${process.pid}-${slug}-${mapCounter++}.map`);
|
|
388
|
+
const body = activeTabs
|
|
389
|
+
.map((t) => `${t.cwd}\t${tabCommand(t, liveSlugs, tabOpts)}`)
|
|
390
|
+
.join("\n") + "\n";
|
|
391
|
+
writeFileSync(mapPath, body, "utf8");
|
|
392
|
+
const args = [];
|
|
393
|
+
activeTabs.forEach((tab, i) => {
|
|
394
|
+
args.push(i === 0 ? "--window" : "--tab", `--working-directory=${tab.cwd}`, `--title=${tab.label}`);
|
|
395
|
+
});
|
|
396
|
+
// ONE shared dispatcher command for all tabs of this window.
|
|
397
|
+
args.push("--", "bash", "-lc", DISPATCHER, "remote-restore", mapPath);
|
|
398
|
+
stderr.write(`[remote] fenêtre "${win.title}" (${activeTabs.length} onglet(s))\n`);
|
|
399
|
+
// Surface gnome-terminal errors (e.g. "Failed to get screen…") instead of
|
|
400
|
+
// silently claiming the window opened.
|
|
401
|
+
const child = spawn("gnome-terminal", args, {
|
|
402
|
+
stdio: ["ignore", "ignore", "pipe"],
|
|
403
|
+
detached: true,
|
|
404
|
+
env: process.env,
|
|
405
|
+
});
|
|
406
|
+
child.stderr?.on("data", (chunk) => {
|
|
407
|
+
stderr.write(`[remote] gnome-terminal: ${chunk.toString().trim()}\n`);
|
|
408
|
+
});
|
|
409
|
+
child.unref();
|
|
410
|
+
opened += activeTabs.length;
|
|
411
|
+
}
|
|
412
|
+
if (skippedLive.length > 0) {
|
|
413
|
+
stderr.write(`[remote] ${skippedLive.length} session(s) déjà actives ignorées` +
|
|
414
|
+
` (--reattach pour les rouvrir quand même): ${skippedLive.join(", ")}\n`);
|
|
415
|
+
}
|
|
416
|
+
return { opened, skippedLive };
|
|
417
|
+
}
|
|
418
|
+
function titleMatches(title, query) {
|
|
419
|
+
const norm = (s) => s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
420
|
+
return norm(title) === norm(query);
|
|
421
|
+
}
|
|
422
|
+
/** Full restore: discover (local) + inject SCW (remote) -> order -> filter -> launch. */
|
|
423
|
+
export function restore(opts = {}) {
|
|
424
|
+
const cfg = getLayoutConfig();
|
|
425
|
+
const stderr = opts.stderr ?? process.stderr;
|
|
426
|
+
// Remote tabs resolved by the caller from `remote ls` (fill `remote: true`
|
|
427
|
+
// groups). Computed up-front so they can ALSO dedup the local discovery.
|
|
428
|
+
const remoteTabs = opts.remoteTabs ?? [];
|
|
429
|
+
// Local windows (groups + shared) — REGISTRY-FIRST: live enrolled sessions
|
|
430
|
+
// are the truth; the filesystem scan only completes uncovered projects.
|
|
431
|
+
const scanned = discoverSessions(cfg.maxAgeHours * 3600 * 1000);
|
|
432
|
+
const allLocal = mergeDiscovered(registrySessions(), scanned);
|
|
433
|
+
// Bug #3: a session moved to a remote Pod must NOT also be re-launched as a
|
|
434
|
+
// ghost LOCAL tmux. Drop locals already covered by a remote tab.
|
|
435
|
+
const { kept: sessions, dropped: remoteBacked } = dropRemoteBackedLocals(allLocal, remoteTabs);
|
|
436
|
+
if (remoteBacked.length > 0) {
|
|
437
|
+
stderr.write(`[remote] ${remoteBacked.length} session(s) déjà sur le contrôle distant — pas de relance locale: ${[
|
|
438
|
+
...new Set(remoteBacked.map((s) => s.label ?? s.project)),
|
|
439
|
+
].join(", ")}\n`);
|
|
440
|
+
}
|
|
441
|
+
const { windows: localWindows, dropped } = groupSessions(sessions, cfg);
|
|
442
|
+
const localByTitle = new Map(localWindows.map((w) => [w.title, w]));
|
|
443
|
+
// Remote windows: each `remote: true` group is filled with the SCW tabs.
|
|
444
|
+
const remoteByTitle = new Map();
|
|
445
|
+
for (const g of cfg.groups) {
|
|
446
|
+
if (!g.remote)
|
|
447
|
+
continue;
|
|
448
|
+
const tabs = remoteTabs
|
|
449
|
+
.slice(0, cfg.maxPerWindow)
|
|
450
|
+
.map((t) => ({ label: t.label, cwd: t.cwd, remoteId: t.id }));
|
|
451
|
+
if (tabs.length > 0)
|
|
452
|
+
remoteByTitle.set(g.title, { title: g.title, tabs });
|
|
453
|
+
}
|
|
454
|
+
// Order: follow cfg.groups (local or remote), then any shared windows.
|
|
455
|
+
let windows = [];
|
|
456
|
+
for (const g of cfg.groups) {
|
|
457
|
+
const w = g.remote ? remoteByTitle.get(g.title) : localByTitle.get(g.title);
|
|
458
|
+
if (w)
|
|
459
|
+
windows.push(w);
|
|
460
|
+
}
|
|
461
|
+
for (const w of localWindows) {
|
|
462
|
+
if (!cfg.groups.some((g) => g.title === w.title))
|
|
463
|
+
windows.push(w);
|
|
464
|
+
}
|
|
465
|
+
// Scope to a single group/batch if requested.
|
|
466
|
+
if (opts.group)
|
|
467
|
+
windows = windows.filter((w) => titleMatches(w.title, opts.group));
|
|
468
|
+
const total = windows.reduce((n, w) => n + w.tabs.length, 0);
|
|
469
|
+
for (const w of windows) {
|
|
470
|
+
stderr.write(` ${w.title} (${w.tabs.length}):\n`);
|
|
471
|
+
for (const t of w.tabs) {
|
|
472
|
+
const what = t.remoteId
|
|
473
|
+
? `SCW:${t.remoteId}`
|
|
474
|
+
: `${t.tool} (local) [${t.origin === "registry" ? "registry" : "guess"}]`;
|
|
475
|
+
stderr.write(` - ${t.label} ${what} ${t.cwd}\n`);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
if (dropped > 0 && !opts.group)
|
|
479
|
+
stderr.write(` (! ${dropped} session(s) ignorée(s), plafond atteint)\n`);
|
|
480
|
+
if (!opts.dryRun && total > 0) {
|
|
481
|
+
launchLayout(windows, stderr, {
|
|
482
|
+
...(opts.reattach ? { reattach: true } : {}),
|
|
483
|
+
...(opts.forceGateway ? { forceGateway: opts.forceGateway } : {}),
|
|
484
|
+
});
|
|
485
|
+
// Auto-record the launched layout (inspect with `remote layout show`).
|
|
486
|
+
try {
|
|
487
|
+
writeLastLayout(windows, opts.group);
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
// best-effort: the windows are open regardless
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
return { windows, total, dropped };
|
|
494
|
+
}
|
|
495
|
+
export function lastLayoutPath() {
|
|
496
|
+
return join(dirname(resolveConfigPath()), "layout-last.json");
|
|
497
|
+
}
|
|
498
|
+
/** Persist the just-launched layout to <configDir>/layout-last.json (atomic). */
|
|
499
|
+
export function writeLastLayout(windows, group) {
|
|
500
|
+
const data = {
|
|
501
|
+
at: new Date().toISOString(),
|
|
502
|
+
...(group !== undefined ? { group } : {}),
|
|
503
|
+
windows: windows.map((w) => ({
|
|
504
|
+
title: w.title,
|
|
505
|
+
tabs: w.tabs.map((t) => ({
|
|
506
|
+
cwd: t.cwd,
|
|
507
|
+
label: t.label,
|
|
508
|
+
cmd: tabCommand(t),
|
|
509
|
+
})),
|
|
510
|
+
})),
|
|
511
|
+
};
|
|
512
|
+
const path = lastLayoutPath();
|
|
513
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
514
|
+
const tmp = `${path}.tmp.${process.pid}`;
|
|
515
|
+
writeFileSync(tmp, JSON.stringify(data, null, 2), "utf8");
|
|
516
|
+
renameSync(tmp, path);
|
|
517
|
+
}
|
|
518
|
+
/** Read the recorded layout, or undefined when none was launched yet. */
|
|
519
|
+
export function readLastLayout() {
|
|
520
|
+
try {
|
|
521
|
+
const parsed = JSON.parse(readFileSync(lastLayoutPath(), "utf8"));
|
|
522
|
+
if (!parsed || typeof parsed !== "object")
|
|
523
|
+
return undefined;
|
|
524
|
+
return parsed;
|
|
525
|
+
}
|
|
526
|
+
catch {
|
|
527
|
+
return undefined;
|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AAC,CAAC;QAClE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAC;QAC5D,OAAO,MAAoB,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type PtySpawner } from "./pty.js";
|
|
2
|
+
export type RunOptions = {
|
|
3
|
+
readonly profile: string;
|
|
4
|
+
readonly resume?: string | true | undefined;
|
|
5
|
+
readonly port?: number;
|
|
6
|
+
readonly cwd?: string;
|
|
7
|
+
readonly env?: Readonly<Record<string, string>>;
|
|
8
|
+
readonly startupArgs?: ReadonlyArray<string>;
|
|
9
|
+
readonly stdin?: NodeJS.ReadStream;
|
|
10
|
+
readonly stdout?: NodeJS.WriteStream;
|
|
11
|
+
readonly spawner?: PtySpawner;
|
|
12
|
+
readonly randomId?: (prefix: string) => string;
|
|
13
|
+
readonly clock?: () => Date;
|
|
14
|
+
readonly initialSize?: {
|
|
15
|
+
cols: number;
|
|
16
|
+
rows: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type RunResult = {
|
|
20
|
+
readonly sessionId: string;
|
|
21
|
+
readonly port: number;
|
|
22
|
+
readonly exit: Promise<{
|
|
23
|
+
exitCode: number;
|
|
24
|
+
signal?: number;
|
|
25
|
+
}>;
|
|
26
|
+
readonly stop: () => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
export declare function run(options: RunOptions): Promise<RunResult>;
|
|
29
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAWA,OAAO,EAAkC,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,CAAC,OAAO,EA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