@alsdd/t3-import 0.1.1-alsd.1 → 0.1.2-alsd.1
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/CHANGELOG.md +13 -0
- package/README.md +11 -3
- package/dist/cli.js +125 -18
- package/dist/cli.js.map +1 -1
- package/dist/core/jsonl.d.ts +2 -0
- package/dist/core/jsonl.js +38 -3
- package/dist/core/jsonl.js.map +1 -1
- package/dist/sources/codex.js +23 -27
- package/dist/sources/codex.js.map +1 -1
- package/dist/sources/files.d.ts +1 -1
- package/dist/sources/files.js +2 -1
- package/dist/sources/files.js.map +1 -1
- package/dist/target/runtimeActivity.d.ts +10 -0
- package/dist/target/runtimeActivity.js +197 -0
- package/dist/target/runtimeActivity.js.map +1 -0
- package/dist/target/runtimeControl.d.ts +32 -0
- package/dist/target/runtimeControl.js +195 -0
- package/dist/target/runtimeControl.js.map +1 -0
- package/dist/target/schema.d.ts +1 -0
- package/dist/target/schema.js +18 -3
- package/dist/target/schema.js.map +1 -1
- package/dist/target/v2Profiles.js +1 -1
- package/dist/target/v2Profiles.js.map +1 -1
- package/dist/tui.d.ts +5 -2
- package/dist/tui.js +37 -7
- package/dist/tui.js.map +1 -1
- package/package.json +4 -2
- package/vendor/t3-v012/LICENSE +21 -0
- package/vendor/t3-v012/THIRD-PARTY-NOTICES.txt +2274 -0
- package/vendor/t3-v012/reference.json +6 -0
- package/vendor/t3-v012/runtime.mjs +61395 -0
- package/vendor/t3-v012/schema-columns.json +526 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { promisify } from "node:util";
|
|
5
|
+
import { safetyError } from "../core/errors.js";
|
|
6
|
+
import { inspectRuntime, runtimeMaintenancePath } from "./schema.js";
|
|
7
|
+
import { inspectRuntimeActivity, runtimeActivityText } from "./runtimeActivity.js";
|
|
8
|
+
const execute = promisify(execFile);
|
|
9
|
+
async function systemctl(args) {
|
|
10
|
+
return (await execute("systemctl", args, { timeout: args.includes("show") ? 3_000 : 120_000, maxBuffer: 64 * 1024, windowsHide: true })).stdout;
|
|
11
|
+
}
|
|
12
|
+
function serviceArgs(service, action) {
|
|
13
|
+
return [...(service.scope === "user" ? ["--user"] : []), "--no-ask-password", action, service.unit];
|
|
14
|
+
}
|
|
15
|
+
async function properties(service, run) {
|
|
16
|
+
const output = await run([...serviceArgs(service, "show"), "--property=Id,MainPID,ActiveState,SubState,ControlGroup,TriggeredBy"]);
|
|
17
|
+
return Object.fromEntries(output.trim().split("\n").map((line) => {
|
|
18
|
+
const separator = line.indexOf("=");
|
|
19
|
+
return [line.slice(0, separator), line.slice(separator + 1)];
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function cgroup(pid, procRoot) {
|
|
23
|
+
return readFileSync(join(procRoot, String(pid), "cgroup"), "utf8");
|
|
24
|
+
}
|
|
25
|
+
function processIdentity(pid, procRoot) {
|
|
26
|
+
const value = readFileSync(join(procRoot, String(pid), "stat"), "utf8");
|
|
27
|
+
// /proc stat field 2 can contain spaces and parentheses; starttime is field 22.
|
|
28
|
+
const start = value.slice(value.lastIndexOf(")") + 2).trim().split(/\s+/u)[19];
|
|
29
|
+
if (!start || !/^\d+$/u.test(start))
|
|
30
|
+
throw safetyError("Cannot verify the T3 process start time.");
|
|
31
|
+
return `${pid}:${start}`;
|
|
32
|
+
}
|
|
33
|
+
/** Identify the unit that actually owns this runtime, never infer it from its name. */
|
|
34
|
+
export async function discoverRuntimeService(pid, run = systemctl, procRoot = "/proc") {
|
|
35
|
+
const groups = cgroup(pid, procRoot);
|
|
36
|
+
const units = [...groups.matchAll(/(?:^|\/)([a-zA-Z0-9][a-zA-Z0-9_.@:\\-]*\.service)(?=\/|$)/gmu)]
|
|
37
|
+
.map((match) => match[1]).filter((name) => !/^user@\d+\.service$/u.test(name));
|
|
38
|
+
const unit = [...new Set(units)].at(-1);
|
|
39
|
+
if (!unit)
|
|
40
|
+
return undefined;
|
|
41
|
+
for (const scope of ["user", "system"]) {
|
|
42
|
+
try {
|
|
43
|
+
if (scope === "user" && process.getuid && statSync(join(procRoot, String(pid))).uid !== process.getuid())
|
|
44
|
+
continue;
|
|
45
|
+
const data = await properties({ scope, unit }, run);
|
|
46
|
+
const mainPid = Number(data.MainPID);
|
|
47
|
+
if (data.Id !== unit || data.ActiveState !== "active" || !mainPid || !data.ControlGroup || data.TriggeredBy)
|
|
48
|
+
continue;
|
|
49
|
+
if (!groups.split("\n").some((line) => {
|
|
50
|
+
const path = line.slice(line.indexOf(":", line.indexOf(":") + 1) + 1);
|
|
51
|
+
return path === data.ControlGroup || path.startsWith(`${data.ControlGroup}/`);
|
|
52
|
+
}))
|
|
53
|
+
continue;
|
|
54
|
+
// A broad login/session unit is not sufficient: its main process must own T3.
|
|
55
|
+
let ancestor = pid;
|
|
56
|
+
const visited = new Set();
|
|
57
|
+
while (ancestor > 0 && !visited.has(ancestor)) {
|
|
58
|
+
if (ancestor === mainPid)
|
|
59
|
+
return { scope, unit, mainPid, controlGroup: data.ControlGroup };
|
|
60
|
+
visited.add(ancestor);
|
|
61
|
+
const status = readFileSync(join(procRoot, String(ancestor), "status"), "utf8");
|
|
62
|
+
ancestor = Number(/^PPid:\s*(\d+)/mu.exec(status)?.[1] ?? 0);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// A different manager scope may own the process; never fall back to kill().
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
export async function inspectRuntimeStatus(paths) {
|
|
72
|
+
const runtime = await inspectRuntime(paths);
|
|
73
|
+
const activity = inspectRuntimeActivity(paths);
|
|
74
|
+
if (!runtime.live)
|
|
75
|
+
return { ...runtime, activity };
|
|
76
|
+
if (process.platform !== "linux" || !runtime.pid) {
|
|
77
|
+
return { ...runtime, activity, managementUnavailable: "Automatic pause requires a verified Linux systemd service. Close this runtime manually." };
|
|
78
|
+
}
|
|
79
|
+
try {
|
|
80
|
+
const database = realpathSync(paths.dbPath);
|
|
81
|
+
const ownsDatabase = readdirSync(`/proc/${runtime.pid}/fd`).some((fd) => {
|
|
82
|
+
try {
|
|
83
|
+
return realpathSync(`/proc/${runtime.pid}/fd/${fd}`) === database;
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (!ownsDatabase)
|
|
90
|
+
return { ...runtime, activity, managementUnavailable: "The recorded PID does not hold this T3 database open. Automatic pause refused." };
|
|
91
|
+
const service = await discoverRuntimeService(runtime.pid);
|
|
92
|
+
return service ? { ...runtime, activity, service }
|
|
93
|
+
: { ...runtime, activity, managementUnavailable: "No unambiguously owned systemd service without activation triggers was found. Close T3 manually." };
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return { ...runtime, activity, managementUnavailable: "Cannot verify the runtime's service ownership. Close T3 manually." };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function recoveryCommand(service) {
|
|
100
|
+
return `systemctl ${service.scope === "user" ? "--user " : ""}start ${service.unit}`;
|
|
101
|
+
}
|
|
102
|
+
async function runtimeReady(paths, service) {
|
|
103
|
+
const runtime = await inspectRuntime(paths);
|
|
104
|
+
if (!runtime.live || !runtime.pid || !runtime.origin)
|
|
105
|
+
return false;
|
|
106
|
+
const owner = await discoverRuntimeService(runtime.pid);
|
|
107
|
+
if (owner?.unit !== service.unit || owner.scope !== service.scope)
|
|
108
|
+
return false;
|
|
109
|
+
const origin = new URL(runtime.origin);
|
|
110
|
+
if (!["127.0.0.1", "localhost", "[::1]"].includes(origin.hostname) || origin.username || origin.password)
|
|
111
|
+
return false;
|
|
112
|
+
try {
|
|
113
|
+
return (await fetch(origin, { signal: AbortSignal.timeout(700) })).status > 0;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
/** Explicit maintenance only. Restore via the same unit; never replay argv or env. */
|
|
120
|
+
export async function pauseIdleRuntime(paths, options = {}) {
|
|
121
|
+
const inspect = options.inspect ?? inspectRuntimeStatus;
|
|
122
|
+
const run = options.run ?? systemctl;
|
|
123
|
+
const procRoot = options.procRoot ?? "/proc";
|
|
124
|
+
const marker = runtimeMaintenancePath(paths);
|
|
125
|
+
if (existsSync(marker))
|
|
126
|
+
throw safetyError(`A maintenance recovery record already exists at ${marker}. Review it before continuing; do not overwrite it.`);
|
|
127
|
+
const before = await inspect(paths);
|
|
128
|
+
if (!before.live)
|
|
129
|
+
return undefined;
|
|
130
|
+
if (before.activity.status !== "idle")
|
|
131
|
+
throw safetyError(`${runtimeActivityText(before.activity)} Automatic pause refused.`);
|
|
132
|
+
if (!before.service || !before.pid)
|
|
133
|
+
throw safetyError(before.managementUnavailable ?? "Cannot verify the runtime's service.");
|
|
134
|
+
const service = before.service;
|
|
135
|
+
const identity = processIdentity(before.pid, procRoot);
|
|
136
|
+
writeFileSync(marker, JSON.stringify({ version: 1, ownerPid: process.pid, startedAt: new Date().toISOString(), service, recoveryCommand: recoveryCommand(service) }) + "\n", { flag: "wx", mode: 0o600 });
|
|
137
|
+
let stopAttempted = false;
|
|
138
|
+
let restoration;
|
|
139
|
+
const maintenance = {
|
|
140
|
+
service,
|
|
141
|
+
restore() {
|
|
142
|
+
restoration ??= (async () => {
|
|
143
|
+
try {
|
|
144
|
+
await run(serviceArgs(service, "start"));
|
|
145
|
+
const deadline = Date.now() + (options.timeoutMs ?? 30_000);
|
|
146
|
+
while (Date.now() < deadline) {
|
|
147
|
+
if (await (options.ready ?? runtimeReady)(paths, service)) {
|
|
148
|
+
unlinkSync(marker);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
await new Promise((resolve) => setTimeout(resolve, 150));
|
|
152
|
+
}
|
|
153
|
+
throw new Error("The service did not become ready before the timeout.");
|
|
154
|
+
}
|
|
155
|
+
catch (cause) {
|
|
156
|
+
throw safetyError(`Unable to restore ${service.unit}: ${cause instanceof Error ? cause.message : String(cause)} Recovery: ${recoveryCommand(service)}. Record retained at ${marker}.`);
|
|
157
|
+
}
|
|
158
|
+
})();
|
|
159
|
+
return restoration;
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
try {
|
|
163
|
+
const current = await inspect(paths);
|
|
164
|
+
if (!current.live || current.pid !== before.pid || processIdentity(before.pid, procRoot) !== identity
|
|
165
|
+
|| current.service?.unit !== service.unit || current.service.scope !== service.scope
|
|
166
|
+
|| current.service.mainPid !== service.mainPid || current.service.controlGroup !== service.controlGroup
|
|
167
|
+
|| current.activity.status !== "idle" || current.activity.fingerprint !== before.activity.fingerprint) {
|
|
168
|
+
throw safetyError("Runtime identity or activity changed before stopping. No stop was attempted; retry inspection.");
|
|
169
|
+
}
|
|
170
|
+
stopAttempted = true;
|
|
171
|
+
await run(serviceArgs(service, "stop"));
|
|
172
|
+
const stopped = await properties(service, run);
|
|
173
|
+
if (stopped.ActiveState !== "inactive" || Number(stopped.MainPID) !== 0)
|
|
174
|
+
throw safetyError("The service has not fully stopped. Database writes are refused.");
|
|
175
|
+
const after = await inspect(paths);
|
|
176
|
+
if (after.live || after.activity.status !== "idle" || after.activity.fingerprint !== before.activity.fingerprint) {
|
|
177
|
+
throw safetyError("Runtime activity changed during shutdown or T3 is still reachable. Database writes are refused.");
|
|
178
|
+
}
|
|
179
|
+
return maintenance;
|
|
180
|
+
}
|
|
181
|
+
catch (cause) {
|
|
182
|
+
if (stopAttempted) {
|
|
183
|
+
try {
|
|
184
|
+
await maintenance.restore();
|
|
185
|
+
}
|
|
186
|
+
catch (restoreError) {
|
|
187
|
+
throw safetyError(`${cause instanceof Error ? cause.message : String(cause)} ${restoreError instanceof Error ? restoreError.message : String(restoreError)}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else
|
|
191
|
+
unlinkSync(marker);
|
|
192
|
+
throw cause;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
//# sourceMappingURL=runtimeControl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtimeControl.js","sourceRoot":"","sources":["../../src/target/runtimeControl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnH,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAqB,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAwB,MAAM,sBAAsB,CAAC;AAEzG,MAAM,OAAO,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAcpC,KAAK,UAAU,SAAS,CAAC,IAAc;IACrC,OAAO,CAAC,MAAM,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC;AAClJ,CAAC;AACD,SAAS,WAAW,CAAC,OAA+C,EAAE,MAAc;IAClF,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,mBAAmB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AAa,EAAE,CAAC;YAClB,IAAI,CAAC;gBAAC,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;YAAC,CAAC;YACpC,OAAO,YAAY,EAAE,CAAC;gBAAC,MAAM,WAAW,CAAC,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,YAAY,YAAY,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YAAC,CAAC;QACzL,CAAC;;YAAM,UAAU,CAAC,MAAM,CAAC,CAAC;QAC1B,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
package/dist/target/schema.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface RuntimeState {
|
|
|
12
12
|
stale: boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare function inspectRuntime(paths: TargetPaths): Promise<RuntimeState>;
|
|
15
|
+
export declare function runtimeMaintenancePath(paths: TargetPaths): string;
|
|
15
16
|
export declare function assertT3Closed(paths: TargetPaths): Promise<RuntimeState>;
|
|
16
17
|
export interface SchemaInfo {
|
|
17
18
|
migration: number;
|
package/dist/target/schema.js
CHANGED
|
@@ -11,7 +11,7 @@ export function isV2Database(db) {
|
|
|
11
11
|
export function targetMigration(db) {
|
|
12
12
|
const row = db.prepare("SELECT COALESCE(MAX(migration_id), 0) migration FROM effect_sql_migrations").get();
|
|
13
13
|
if (!SUPPORTED_MIGRATIONS.some((migration) => migration === row.migration)) {
|
|
14
|
-
throw compatibilityError(`Unsupported T3 schema migration ${row.migration}; supported migrations are 40–54 (V1), 62 (T3 0.1.0 V2), and 67 (T3 0.1.1 V2).`);
|
|
14
|
+
throw compatibilityError(`Unsupported T3 schema migration ${row.migration}; supported migrations are 40–54 (V1), 62 (T3 0.1.0 V2), and 67 (T3 0.1.1/0.1.2 V2).`);
|
|
15
15
|
}
|
|
16
16
|
return row.migration;
|
|
17
17
|
}
|
|
@@ -57,12 +57,27 @@ export async function inspectRuntime(paths) {
|
|
|
57
57
|
return { exists: true, live: false, stale: true };
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
+
export function runtimeMaintenancePath(paths) {
|
|
61
|
+
return join(paths.stateDir, ".t3-import-maintenance.json");
|
|
62
|
+
}
|
|
60
63
|
export async function assertT3Closed(paths) {
|
|
64
|
+
const marker = runtimeMaintenancePath(paths);
|
|
65
|
+
if (existsSync(marker)) {
|
|
66
|
+
let owner;
|
|
67
|
+
try {
|
|
68
|
+
owner = JSON.parse(readFileSync(marker, "utf8"));
|
|
69
|
+
}
|
|
70
|
+
catch { /* Refuse unreadable recovery records. */ }
|
|
71
|
+
if (!isObject(owner) || owner.ownerPid !== process.pid)
|
|
72
|
+
throw safetyError(`T3 maintenance is owned by another command or requires recovery. Review ${marker} before writing.`);
|
|
73
|
+
}
|
|
61
74
|
if (basename(paths.dbPath) === "state.sqlite" && existsSync(join(paths.stateDir, "statev2.sqlite")))
|
|
62
75
|
throw safetyError("This home has a V2 database. The legacy state.sqlite is a frozen pre-upgrade copy; select statev2.sqlite instead.");
|
|
63
76
|
const runtime = await inspectRuntime(paths);
|
|
64
|
-
if (runtime.live)
|
|
65
|
-
|
|
77
|
+
if (runtime.live) {
|
|
78
|
+
const { inspectRuntimeActivity, runtimeActivityText } = await import("./runtimeActivity.js");
|
|
79
|
+
throw safetyError(`T3 is running${runtime.pid ? ` (PID ${runtime.pid})` : ""}. ${runtimeActivityText(inspectRuntimeActivity(paths))} Close T3 before importing, or use --manage-runtime for a verified idle systemd service.`);
|
|
80
|
+
}
|
|
66
81
|
return runtime;
|
|
67
82
|
}
|
|
68
83
|
export function validateTargetDatabase(db) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/target/schema.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY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AO,CAAC,yFAAyF,CAAC,CAAC,GAAG,EAA4C,CAAC;IACrK,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const v2Profiles = {
|
|
2
2
|
62: { directory: "t3-v010", release: "0.1.0" },
|
|
3
|
-
67: { directory: "t3-
|
|
3
|
+
67: { directory: "t3-v012", release: "0.1.1 / 0.1.2" },
|
|
4
4
|
};
|
|
5
5
|
export const v2Migrations = new Map([
|
|
6
6
|
[55, "OrchestrationV2"], [56, "RemoveRedundantProjectionIndexes"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v2Profiles.js","sourceRoot":"","sources":["../../src/target/v2Profiles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAqE;IAC1F,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE;IAC9C,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"v2Profiles.js","sourceRoot":"","sources":["../../src/target/v2Profiles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAqE;IAC1F,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE;IAC9C,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE;CACvD,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAClC,CAAC,EAAE,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,EAAE,kCAAkC,CAAC;IACjE,CAAC,EAAE,EAAE,uBAAuB,CAAC,EAAE,CAAC,EAAE,EAAE,wBAAwB,CAAC;IAC7D,CAAC,EAAE,EAAE,oBAAoB,CAAC,EAAE,CAAC,EAAE,EAAE,6BAA6B,CAAC;IAC/D,CAAC,EAAE,EAAE,yBAAyB,CAAC,EAAE,CAAC,EAAE,EAAE,0BAA0B,CAAC;IACjE,CAAC,EAAE,EAAE,yBAAyB,CAAC,EAAE,CAAC,EAAE,EAAE,oCAAoC,CAAC;IAC3E,CAAC,EAAE,EAAE,2BAA2B,CAAC,EAAE,CAAC,EAAE,EAAE,kCAAkC,CAAC;IAC3E,CAAC,EAAE,EAAE,eAAe,CAAC;CACtB,CAAC,CAAC"}
|
package/dist/tui.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ConversationReplacePreview, ConversationSyncPreview, ReplaceSelection, SourceName, TargetPaths } from "./core/types.js";
|
|
3
3
|
import { type DestinationOptions } from "./target/destination.js";
|
|
4
|
-
export type Screen = "preflight" | "blocked" | "source" | "workspace" | "provider" | "threads" | "destination" | "review" | "running" | "result" | "launching" | "launch-error" | "error";
|
|
4
|
+
export type Screen = "preflight" | "blocked" | "pause-confirm" | "maintenance" | "source" | "workspace" | "provider" | "threads" | "destination" | "review" | "running" | "result" | "launching" | "launch-error" | "error";
|
|
5
5
|
export interface TuiDestinationChoice {
|
|
6
6
|
label: string;
|
|
7
7
|
options?: DestinationOptions;
|
|
@@ -17,6 +17,9 @@ interface TuiProps {
|
|
|
17
17
|
initialProvider?: string;
|
|
18
18
|
mode?: "auto" | "sync" | "replace";
|
|
19
19
|
resetCache?: boolean;
|
|
20
|
+
initialManagedService?: string;
|
|
21
|
+
onPauseRuntime?: () => Promise<string | undefined>;
|
|
22
|
+
onOperation?: (operation: Promise<void>) => void;
|
|
20
23
|
}
|
|
21
24
|
export declare function helpTextForScreen(screen: Screen, searching?: boolean): string | undefined;
|
|
22
25
|
export declare function selectionMarker(isSelected: boolean, isDisabled: boolean): string;
|
|
@@ -45,5 +48,5 @@ export declare function ConversationStatusDetails({ preview, replacement, checki
|
|
|
45
48
|
mode?: "auto" | "sync" | "replace";
|
|
46
49
|
review?: boolean;
|
|
47
50
|
}): React.JSX.Element;
|
|
48
|
-
export declare function ImportTui({ paths, initialSource, initialWorkspace, initialProvider, mode, resetCache }: TuiProps): React.JSX.Element;
|
|
51
|
+
export declare function ImportTui({ paths, initialSource, initialWorkspace, initialProvider, mode, resetCache, initialManagedService, onPauseRuntime, onOperation }: TuiProps): React.JSX.Element;
|
|
49
52
|
export {};
|
package/dist/tui.js
CHANGED
|
@@ -6,7 +6,8 @@ import { sourceAdapter } from "./sources/index.js";
|
|
|
6
6
|
import { compactThreadForImport, importConversations } from "./target/importer.js";
|
|
7
7
|
import { inspectConversationSync, syncConversations } from "./target/sync.js";
|
|
8
8
|
import { listProviderInstances } from "./target/config.js";
|
|
9
|
-
import {
|
|
9
|
+
import { inspectRuntimeStatus } from "./target/runtimeControl.js";
|
|
10
|
+
import { runtimeActivityText } from "./target/runtimeActivity.js";
|
|
10
11
|
import { launchT3Code } from "./target/launch.js";
|
|
11
12
|
import { resetT3RebuildableCache } from "./target/cache.js";
|
|
12
13
|
import { inspectConversationReplacement, replaceConversations } from "./target/replace.js";
|
|
@@ -167,11 +168,13 @@ export function ConversationStatusDetails({ preview, replacement, checking, erro
|
|
|
167
168
|
const warnings = [...new Set([...(preview?.warnings ?? []), ...(replacement?.warnings ?? [])])];
|
|
168
169
|
return _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { children: action }), preview?.ignoredActiveTurns ? _jsxs(Text, { color: "yellow", children: [preview.ignoredActiveTurns, " unfinished source turn(s) excluded; only settled history is eligible."] }) : null, error ? _jsxs(Text, { color: "yellow", children: ["Reason: ", error] }) : null, warnings.map((warning) => _jsxs(Text, { color: "yellow", children: ["Reason: ", warning] }, warning))] });
|
|
169
170
|
}
|
|
170
|
-
export function ImportTui({ paths, initialSource, initialWorkspace, initialProvider, mode = "auto", resetCache = false }) {
|
|
171
|
+
export function ImportTui({ paths, initialSource, initialWorkspace, initialProvider, mode = "auto", resetCache = false, initialManagedService, onPauseRuntime, onOperation }) {
|
|
171
172
|
const app = useApp();
|
|
172
173
|
const [screen, setScreen] = useState("preflight");
|
|
173
174
|
const [screenHistory, setScreenHistory] = useState([]);
|
|
174
175
|
const [runtime, setRuntime] = useState();
|
|
176
|
+
const [managedService, setManagedService] = useState(initialManagedService);
|
|
177
|
+
const [maintenanceError, setMaintenanceError] = useState();
|
|
175
178
|
const [source, setSource] = useState(initialSource ?? "codex");
|
|
176
179
|
const [summaries, setSummaries] = useState([]);
|
|
177
180
|
const [workspace, setWorkspace] = useState();
|
|
@@ -280,7 +283,7 @@ export function ImportTui({ paths, initialSource, initialWorkspace, initialProvi
|
|
|
280
283
|
const checkRuntime = useCallback(() => {
|
|
281
284
|
setScreenHistory([]);
|
|
282
285
|
setScreen("preflight");
|
|
283
|
-
|
|
286
|
+
inspectRuntimeStatus(paths)
|
|
284
287
|
.then((state) => {
|
|
285
288
|
setRuntime(state);
|
|
286
289
|
setScreen(state.live ? "blocked" : initialSource ? "workspace" : "source");
|
|
@@ -378,7 +381,7 @@ export function ImportTui({ paths, initialSource, initialWorkspace, initialProvi
|
|
|
378
381
|
}, [paths, screen, workspace]);
|
|
379
382
|
const move = (delta, length) => setIndex((current) => length === 0 ? 0 : (current + delta + length) % length);
|
|
380
383
|
useInput((input, key) => {
|
|
381
|
-
if (screen === "running")
|
|
384
|
+
if (screen === "running" || screen === "maintenance")
|
|
382
385
|
return;
|
|
383
386
|
if (searching) {
|
|
384
387
|
if (key.escape || key.return)
|
|
@@ -397,6 +400,28 @@ export function ImportTui({ paths, initialSource, initialWorkspace, initialProvi
|
|
|
397
400
|
checkRuntime();
|
|
398
401
|
return;
|
|
399
402
|
}
|
|
403
|
+
if (screen === "blocked" && input === "s" && runtime?.activity.status === "idle" && runtime.service && onPauseRuntime) {
|
|
404
|
+
setScreen("pause-confirm");
|
|
405
|
+
return;
|
|
406
|
+
}
|
|
407
|
+
if (screen === "pause-confirm") {
|
|
408
|
+
if (key.escape) {
|
|
409
|
+
setScreen("blocked");
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
if (key.return && onPauseRuntime) {
|
|
413
|
+
setScreen("maintenance");
|
|
414
|
+
onPauseRuntime().then((unit) => {
|
|
415
|
+
setManagedService(unit);
|
|
416
|
+
setMaintenanceError(undefined);
|
|
417
|
+
checkRuntime();
|
|
418
|
+
}).catch((cause) => {
|
|
419
|
+
setMaintenanceError(cause instanceof Error ? cause.message : String(cause));
|
|
420
|
+
setScreen("blocked");
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
400
425
|
if (key.upArrow || input === "k") {
|
|
401
426
|
move(-1, screen === "source" ? sourceNames.length : screen === "result" ? 2 : screen === "workspace" ? workspaces.length : screen === "provider" ? providers.length : screen === "destination" ? destinationChoices.length : visibleThreads.length);
|
|
402
427
|
return;
|
|
@@ -529,9 +554,14 @@ export function ImportTui({ paths, initialSource, initialWorkspace, initialProvi
|
|
|
529
554
|
setIndex(0);
|
|
530
555
|
setScreen("result");
|
|
531
556
|
};
|
|
532
|
-
run().catch((cause) => { setError(cause instanceof Error ? cause.message : String(cause)); setScreen("error"); });
|
|
557
|
+
const operation = run().catch((cause) => { setError(cause instanceof Error ? cause.message : String(cause)); setScreen("error"); });
|
|
558
|
+
onOperation?.(operation);
|
|
533
559
|
}
|
|
534
560
|
if (screen === "result" && key.return) {
|
|
561
|
+
if (managedService) {
|
|
562
|
+
app.exit();
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
535
565
|
if (index === 1) {
|
|
536
566
|
app.exit();
|
|
537
567
|
return;
|
|
@@ -546,7 +576,7 @@ export function ImportTui({ paths, initialSource, initialWorkspace, initialProvi
|
|
|
546
576
|
if ((screen === "launch-error" || screen === "error") && key.return)
|
|
547
577
|
app.exit();
|
|
548
578
|
});
|
|
549
|
-
return _jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "t3-import" }), _jsxs(Text, { dimColor: true, children: ["Target: ", paths.dbPath] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [screen === "preflight" && _jsx(Text, { children: "Checking whether T3 is running\u2026" }), screen === "blocked" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "red", children: "T3 is running" }), _jsxs(Text, { children: ["Close T3 before importing, syncing, or replacing", runtime?.pid ? ` (detected PID ${runtime.pid})` : "", "."] }), runtime?.origin ? _jsxs(Text, { dimColor: true, children: ["Runtime: ", runtime.origin] }) : null, _jsx(Text, { children: "Press r or Enter to check again, or q to quit." })] }), screen === "source" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a source" }), _jsx(Menu, { items: sourceNames.map(sourceLabel), index: index })] }), screen === "workspace" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a workspace" }), summaries.length === 0 ? _jsxs(Text, { children: ["Discovering ", source, " conversations\u2026"] }) : _jsx(Menu, { items: workspaces, index: index })] }), screen === "provider" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a T3 provider instance" }), _jsx(Menu, { items: providers, index: index })] }), screen === "destination" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a T3 destination for new imports" }), _jsx(Text, { dimColor: true, children: "Available choices preserve the source working directory." }), destinationError ? _jsx(Text, { color: "red", children: destinationError }) : destinationChoices.length ? _jsx(Menu, { items: destinationChoices.map((choice) => choice.label), index: index }) : _jsx(Text, { children: "Checking available destinations\u2026" })] }), screen === "threads" && _jsxs(_Fragment, { children: [_jsxs(Text, { bold: true, children: [mode === "sync" ? "Select conversations to sync" : mode === "replace" ? "Select conversations to replace" : "Select conversations", " \u2014 ", workspace] }), searching || query ? _jsxs(Text, { color: "yellow", children: ["Search: ", query, _jsx(Text, { dimColor: true, children: "_" })] }) : null, _jsx(Menu, { items: visibleThreads.map((item) => {
|
|
579
|
+
return _jsxs(Box, { flexDirection: "column", paddingX: 1, children: [_jsx(Text, { bold: true, color: "cyan", children: "t3-import" }), _jsxs(Text, { dimColor: true, children: ["Target: ", paths.dbPath] }), managedService ? _jsxs(Text, { color: "yellow", children: ["Paused service: ", managedService, ". It will restart automatically when you exit."] }) : null, _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [screen === "preflight" && _jsx(Text, { children: "Checking whether T3 is running\u2026" }), screen === "blocked" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "red", children: "T3 is running" }), _jsxs(Text, { children: ["Close T3 before importing, syncing, or replacing", runtime?.pid ? ` (detected PID ${runtime.pid})` : "", "."] }), runtime?.activity ? _jsx(Text, { children: runtimeActivityText(runtime.activity) }) : null, runtime?.activity.warnings.map((warning) => _jsx(Text, { color: "yellow", children: warning }, warning)), runtime?.service ? _jsxs(Text, { children: ["Service: systemd ", runtime.service.scope, " \u00B7 ", runtime.service.unit] }) : _jsx(Text, { dimColor: true, children: runtime?.managementUnavailable }), runtime?.origin ? _jsxs(Text, { dimColor: true, children: ["Runtime: ", runtime.origin] }) : null, maintenanceError ? _jsx(Text, { color: "red", children: maintenanceError }) : null, runtime?.activity.status === "idle" && runtime.service && onPauseRuntime ? _jsx(Text, { children: "Press s to pause the service and continue. It will restart automatically on exit." }) : null, _jsx(Text, { children: "Press r or Enter to check again, or q to quit." })] }), screen === "pause-confirm" && _jsxs(_Fragment, { children: [_jsxs(Text, { bold: true, children: ["Pause ", runtime?.service?.unit, " for maintenance?"] }), _jsx(Text, { children: "T3 and T3 Connect clients will disconnect until this command exits." }), _jsx(Text, { children: "The same systemd unit will restart after success, cancellation, or error." }), _jsx(Text, { children: "Activity is checked again before stopping and before database writes." }), _jsx(Text, { children: "Press Enter to pause, Escape to go back, or q to quit." })] }), screen === "maintenance" && _jsx(Text, { children: "Pausing the idle T3 service and verifying that it has stopped\u2026" }), screen === "source" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a source" }), _jsx(Menu, { items: sourceNames.map(sourceLabel), index: index })] }), screen === "workspace" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a workspace" }), summaries.length === 0 ? _jsxs(Text, { children: ["Discovering ", source, " conversations\u2026"] }) : _jsx(Menu, { items: workspaces, index: index })] }), screen === "provider" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a T3 provider instance" }), _jsx(Menu, { items: providers, index: index })] }), screen === "destination" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Choose a T3 destination for new imports" }), _jsx(Text, { dimColor: true, children: "Available choices preserve the source working directory." }), destinationError ? _jsx(Text, { color: "red", children: destinationError }) : destinationChoices.length ? _jsx(Menu, { items: destinationChoices.map((choice) => choice.label), index: index }) : _jsx(Text, { children: "Checking available destinations\u2026" })] }), screen === "threads" && _jsxs(_Fragment, { children: [_jsxs(Text, { bold: true, children: [mode === "sync" ? "Select conversations to sync" : mode === "replace" ? "Select conversations to replace" : "Select conversations", " \u2014 ", workspace] }), searching || query ? _jsxs(Text, { color: "yellow", children: ["Search: ", query, _jsx(Text, { dimColor: true, children: "_" })] }) : null, _jsx(Menu, { items: visibleThreads.map((item) => {
|
|
550
580
|
const syncText = conversationStatusText(syncPreviews.get(item.id), checkingStatuses);
|
|
551
581
|
const replacement = replacePreviews.get(item.id);
|
|
552
582
|
const status = mode === "replace"
|
|
@@ -555,6 +585,6 @@ export function ImportTui({ paths, initialSource, initialWorkspace, initialProvi
|
|
|
555
585
|
? "history changed · replace available"
|
|
556
586
|
: syncText;
|
|
557
587
|
return `${item.title} ${status}`;
|
|
558
|
-
}), index: index, selected: selectedVisible, disabled: disabledVisible }), mode !== "replace" ? _jsxs(Text, { dimColor: true, children: ["New: ", statusCounts.new, " · To sync: ", statusCounts.syncable, " · Current: ", statusCounts.current, " · Active only: ", statusCounts.active, " · Conflicts: ", statusCounts.conflicts, " · Unavailable: ", statusCounts.unavailable] }) : null, visibleThreads[index] ? _jsx(ConversationStatusDetails, { preview: syncPreviews.get(visibleThreads[index].id), replacement: replacePreviews.get(visibleThreads[index].id), checking: checkingStatuses, error: inspectionErrors.get(visibleThreads[index].id), mode: mode }) : null, pendingStatuses > 0 ? _jsxs(Text, { dimColor: true, children: ["Checking ", pendingStatuses, " conversation", pendingStatuses === 1 ? "" : "s", "\u2026"] }) : null, visibleThreads.length === 0 && _jsx(Text, { color: "yellow", children: "No matching conversations." })] }), screen === "review" && _jsx(_Fragment, { children: preparedReplacements.length ? _jsx(_Fragment, { children: _jsx(ReplacementReview, { workspace: workspace, selections: preparedReplacements, previews: replacePreviews, counts: replacementPreview, resetCache: resetCache }) }) : _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Review changes" }), _jsxs(Text, { children: ["Source: ", source, " \u00B7 Workspace: ", workspace] }), preparedImports.length ? _jsxs(_Fragment, { children: [_jsxs(Text, { children: ["Source working directory: ", workspace] }), _jsxs(Text, { children: ["Effective T3 working directory: ", workspace] }), _jsxs(Text, { children: ["Destination: ", destinationChoices.find((choice) => JSON.stringify(choice.options ?? {}) === JSON.stringify(destinationOptions))?.label ?? "Use workspace project automatically"] })] }) : null, _jsxs(Text, { children: ["New tasks: ", importPreview.tasks, " \u00B7 synchronized tasks: ", syncPreview.tasks] }), _jsxs(Text, { children: ["Imported turns: ", importPreview.turns, " \u00B7 added turns: ", syncPreview.turns, " \u00B7 adopted turns: ", syncPreview.adopted] }), _jsxs(Text, { children: ["Messages: ", importPreview.messages, " \u00B7 activities: ", importPreview.activities, " \u00B7 attachments: ", importPreview.attachments] }), _jsxs(Text, { children: ["Title updates: ", syncPreview.titles] }), [...preparedImports, ...preparedSync].map((selection) => _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { bold: true, children: selection.conversation.summary.title }), _jsx(ConversationStatusDetails, { preview: syncPreviews.get(selection.conversation.summary.id), checking: false, mode: mode, review: true })] }, selection.conversation.summary.id)), preparedImports.length ? _jsxs(Text, { children: ["Provider for new tasks: ", provider] }) : null, resetCache ? _jsx(Text, { children: "T3 IndexedDB cache: back up and reset after successful changes" }) : _jsx(Text, { children: "T3 IndexedDB cache: keep existing cache" }), _jsx(Text, { color: "yellow", children: "T3 must remain closed. A verified backup will be created before database changes." }), _jsx(Text, { bold: true, children: "Press Enter to continue, Escape to go back." })] }) }), screen === "running" && _jsx(Text, { children: "Backing up and reconciling conversations\u2026" }), screen === "result" && (result || syncResult || replaceResult) && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "green", children: "Complete" }), result ? _jsxs(Text, { children: ["Import backup: ", result.backup ?? "not needed"] }) : null, result?.results.map((item) => _jsxs(Text, { children: [item.status === "imported" ? "✓" : "•", " ", item.title, " \u2014 ", item.status, ", ", item.turns, " turns, ", item.events, " events"] }, `import:${item.threadId}`)), syncResult ? _jsxs(Text, { children: ["Sync backup: ", syncResult.backup ?? "not needed"] }) : null, syncResult?.results.map((item) => _jsxs(Text, { children: [item.status === "synced" ? "✓" : "•", " ", item.title, " \u2014 ", item.status, ", ", item.turnsAdded, " added, ", item.turnsAdopted, " adopted, ", item.events, " events"] }, `sync:${item.sourceKey}`)), replaceResult ? _jsxs(Text, { children: ["Replacement backup: ", replaceResult.backup ?? "not needed"] }) : null, replaceResult?.results.map((item) => _jsxs(Text, { children: [item.status === "replaced" ? "✓" : "•", " ", item.title, " \u2014 ", item.status, item.oldThreadId ? `, old ${item.oldThreadId}` : "", item.newThreadId ? `, new ${item.newThreadId}` : "", ", ", item.turns, " turns, ", item.events, " events"] }, `replace:${item.sourceKey}`)), (replaceResult?.cache ?? syncResult?.cache ?? result?.cache) ? _jsxs(Text, { children: ["Cache backup: ", (replaceResult?.cache ?? syncResult?.cache ?? result?.cache)?.backup ?? "cache not found"] }) : null, cacheWarning ? _jsx(Text, { color: "yellow", children: cacheWarning }) : null, _jsx(StartT3Prompt, { index: index })] }), screen === "launching" && _jsx(Text, { children: "Starting T3 Code\u2026" }), screen === "launch-error" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "red", children: "Could not start T3 Code" }), _jsx(Text, { children: launchError }), _jsx(Text, { dimColor: true, children: "Press Enter to exit and start it manually." })] }), screen === "error" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "red", children: "Operation failed" }), _jsx(Text, { children: error }), _jsx(Text, { dimColor: true, children: "Press Enter to exit." })] })] }), helpTextForScreen(screen, searching) ? _jsx(Box, { marginTop: 1, children: _jsx(Help, { screen: screen, searching: searching }) }) : null] });
|
|
588
|
+
}), index: index, selected: selectedVisible, disabled: disabledVisible }), mode !== "replace" ? _jsxs(Text, { dimColor: true, children: ["New: ", statusCounts.new, " · To sync: ", statusCounts.syncable, " · Current: ", statusCounts.current, " · Active only: ", statusCounts.active, " · Conflicts: ", statusCounts.conflicts, " · Unavailable: ", statusCounts.unavailable] }) : null, visibleThreads[index] ? _jsx(ConversationStatusDetails, { preview: syncPreviews.get(visibleThreads[index].id), replacement: replacePreviews.get(visibleThreads[index].id), checking: checkingStatuses, error: inspectionErrors.get(visibleThreads[index].id), mode: mode }) : null, pendingStatuses > 0 ? _jsxs(Text, { dimColor: true, children: ["Checking ", pendingStatuses, " conversation", pendingStatuses === 1 ? "" : "s", "\u2026"] }) : null, visibleThreads.length === 0 && _jsx(Text, { color: "yellow", children: "No matching conversations." })] }), screen === "review" && _jsx(_Fragment, { children: preparedReplacements.length ? _jsx(_Fragment, { children: _jsx(ReplacementReview, { workspace: workspace, selections: preparedReplacements, previews: replacePreviews, counts: replacementPreview, resetCache: resetCache }) }) : _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, children: "Review changes" }), _jsxs(Text, { children: ["Source: ", source, " \u00B7 Workspace: ", workspace] }), preparedImports.length ? _jsxs(_Fragment, { children: [_jsxs(Text, { children: ["Source working directory: ", workspace] }), _jsxs(Text, { children: ["Effective T3 working directory: ", workspace] }), _jsxs(Text, { children: ["Destination: ", destinationChoices.find((choice) => JSON.stringify(choice.options ?? {}) === JSON.stringify(destinationOptions))?.label ?? "Use workspace project automatically"] })] }) : null, _jsxs(Text, { children: ["New tasks: ", importPreview.tasks, " \u00B7 synchronized tasks: ", syncPreview.tasks] }), _jsxs(Text, { children: ["Imported turns: ", importPreview.turns, " \u00B7 added turns: ", syncPreview.turns, " \u00B7 adopted turns: ", syncPreview.adopted] }), _jsxs(Text, { children: ["Messages: ", importPreview.messages, " \u00B7 activities: ", importPreview.activities, " \u00B7 attachments: ", importPreview.attachments] }), _jsxs(Text, { children: ["Title updates: ", syncPreview.titles] }), [...preparedImports, ...preparedSync].map((selection) => _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsx(Text, { bold: true, children: selection.conversation.summary.title }), _jsx(ConversationStatusDetails, { preview: syncPreviews.get(selection.conversation.summary.id), checking: false, mode: mode, review: true })] }, selection.conversation.summary.id)), preparedImports.length ? _jsxs(Text, { children: ["Provider for new tasks: ", provider] }) : null, resetCache ? _jsx(Text, { children: "T3 IndexedDB cache: back up and reset after successful changes" }) : _jsx(Text, { children: "T3 IndexedDB cache: keep existing cache" }), _jsx(Text, { color: "yellow", children: "T3 must remain closed. A verified backup will be created before database changes." }), _jsx(Text, { bold: true, children: "Press Enter to continue, Escape to go back." })] }) }), screen === "running" && _jsx(Text, { children: "Backing up and reconciling conversations\u2026" }), screen === "result" && (result || syncResult || replaceResult) && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "green", children: "Complete" }), result ? _jsxs(Text, { children: ["Import backup: ", result.backup ?? "not needed"] }) : null, result?.results.map((item) => _jsxs(Text, { children: [item.status === "imported" ? "✓" : "•", " ", item.title, " \u2014 ", item.status, ", ", item.turns, " turns, ", item.events, " events"] }, `import:${item.threadId}`)), syncResult ? _jsxs(Text, { children: ["Sync backup: ", syncResult.backup ?? "not needed"] }) : null, syncResult?.results.map((item) => _jsxs(Text, { children: [item.status === "synced" ? "✓" : "•", " ", item.title, " \u2014 ", item.status, ", ", item.turnsAdded, " added, ", item.turnsAdopted, " adopted, ", item.events, " events"] }, `sync:${item.sourceKey}`)), replaceResult ? _jsxs(Text, { children: ["Replacement backup: ", replaceResult.backup ?? "not needed"] }) : null, replaceResult?.results.map((item) => _jsxs(Text, { children: [item.status === "replaced" ? "✓" : "•", " ", item.title, " \u2014 ", item.status, item.oldThreadId ? `, old ${item.oldThreadId}` : "", item.newThreadId ? `, new ${item.newThreadId}` : "", ", ", item.turns, " turns, ", item.events, " events"] }, `replace:${item.sourceKey}`)), (replaceResult?.cache ?? syncResult?.cache ?? result?.cache) ? _jsxs(Text, { children: ["Cache backup: ", (replaceResult?.cache ?? syncResult?.cache ?? result?.cache)?.backup ?? "cache not found"] }) : null, cacheWarning ? _jsx(Text, { color: "yellow", children: cacheWarning }) : null, managedService ? _jsxs(Text, { children: ["Press Enter or q to exit and restore ", managedService, "."] }) : _jsx(StartT3Prompt, { index: index })] }), screen === "launching" && _jsx(Text, { children: "Starting T3 Code\u2026" }), screen === "launch-error" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "red", children: "Could not start T3 Code" }), _jsx(Text, { children: launchError }), _jsx(Text, { dimColor: true, children: "Press Enter to exit and start it manually." })] }), screen === "error" && _jsxs(_Fragment, { children: [_jsx(Text, { bold: true, color: "red", children: "Operation failed" }), _jsx(Text, { children: error }), _jsx(Text, { dimColor: true, children: "Press Enter to exit." })] })] }), helpTextForScreen(screen, searching) ? _jsx(Box, { marginTop: 1, children: _jsx(Help, { screen: screen, searching: searching }) }) : null] });
|
|
559
589
|
}
|
|
560
590
|
//# sourceMappingURL=tui.js.map
|