autodev-cli 1.4.0 → 1.4.4
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/bin/autodev.js +0 -0
- package/out/agentBackup/archive.d.ts +44 -0
- package/out/agentBackup/archive.js +131 -0
- package/out/agentBackup/archive.js.map +1 -0
- package/out/agentBackup/export.d.ts +18 -0
- package/out/agentBackup/export.js +92 -0
- package/out/agentBackup/export.js.map +1 -0
- package/out/agentBackup/import.d.ts +21 -0
- package/out/agentBackup/import.js +40 -0
- package/out/agentBackup/import.js.map +1 -0
- package/out/agentBackup/index.d.ts +6 -0
- package/out/agentBackup/index.js +11 -0
- package/out/agentBackup/index.js.map +1 -0
- package/out/agentBackup/layout.d.ts +30 -0
- package/out/agentBackup/layout.js +126 -0
- package/out/agentBackup/layout.js.map +1 -0
- package/out/agentBackup/manifest.d.ts +24 -0
- package/out/agentBackup/manifest.js +70 -0
- package/out/agentBackup/manifest.js.map +1 -0
- package/out/agentBackup/opencodeDb.d.ts +20 -0
- package/out/agentBackup/opencodeDb.js +213 -0
- package/out/agentBackup/opencodeDb.js.map +1 -0
- package/out/agentBackup/sessionProviders.d.ts +35 -0
- package/out/agentBackup/sessionProviders.js +263 -0
- package/out/agentBackup/sessionProviders.js.map +1 -0
- package/out/agentBackup/upload.d.ts +9 -0
- package/out/agentBackup/upload.js +121 -0
- package/out/agentBackup/upload.js.map +1 -0
- package/out/cli.d.ts +1 -0
- package/out/cli.js +8 -0
- package/out/cli.js.map +1 -1
- package/out/cliExit.d.ts +34 -0
- package/out/cliExit.js +159 -0
- package/out/cliExit.js.map +1 -0
- package/out/commands/config.d.ts +2 -0
- package/out/commands/config.js +7 -7
- package/out/commands/config.js.map +1 -1
- package/out/commands/connect.d.ts +2 -0
- package/out/commands/connect.js +11 -0
- package/out/commands/connect.js.map +1 -1
- package/out/commands/export.d.ts +2 -0
- package/out/commands/export.js +79 -0
- package/out/commands/export.js.map +1 -0
- package/out/commands/import.d.ts +2 -0
- package/out/commands/import.js +92 -0
- package/out/commands/import.js.map +1 -0
- package/out/commands/init.d.ts +16 -0
- package/out/commands/init.js +9 -5
- package/out/commands/init.js.map +1 -1
- package/out/commands/resume.d.ts +2 -0
- package/out/commands/resume.js +65 -0
- package/out/commands/resume.js.map +1 -0
- package/out/commands/sessions.d.ts +2 -0
- package/out/commands/sessions.js +64 -0
- package/out/commands/sessions.js.map +1 -0
- package/out/commands/start.d.ts +2 -0
- package/out/commands/start.js +40 -7
- package/out/commands/start.js.map +1 -1
- package/out/commands/status.d.ts +2 -0
- package/out/commands/status.js +3 -3
- package/out/commands/status.js.map +1 -1
- package/out/commands/tailOutput.d.ts +12 -0
- package/out/commands/up.d.ts +3 -0
- package/out/configManager.d.ts +42 -0
- package/out/configManager.js +447 -0
- package/out/configManager.js.map +1 -0
- package/out/connect.d.ts +4 -0
- package/out/connect.js +7 -7
- package/out/connect.js.map +1 -1
- package/out/core/adapters.d.ts +34 -0
- package/out/core/adapters.js +84 -0
- package/out/core/adapters.js.map +1 -0
- package/out/core/commandHelpers.d.ts +12 -0
- package/out/core/commandHelpers.js +96 -0
- package/out/core/commandHelpers.js.map +1 -0
- package/out/core/projectMcp.d.ts +34 -0
- package/out/core/projectMcp.js +160 -0
- package/out/core/projectMcp.js.map +1 -0
- package/out/core/provider/BaseProvider.d.ts +14 -0
- package/out/core/provider/BaseProvider.js +25 -0
- package/out/core/provider/BaseProvider.js.map +1 -0
- package/out/core/provider/ProviderRegistry.d.ts +12 -0
- package/out/core/provider/ProviderRegistry.js +40 -0
- package/out/core/provider/ProviderRegistry.js.map +1 -0
- package/out/core/provider/contract.d.ts +62 -0
- package/out/core/provider/contract.js +9 -0
- package/out/core/provider/contract.js.map +1 -0
- package/out/core/provider/implementations.d.ts +54 -0
- package/out/core/provider/implementations.js +147 -0
- package/out/core/provider/implementations.js.map +1 -0
- package/out/core/settingsLoader.d.ts +221 -0
- package/out/core/settingsLoader.js +176 -0
- package/out/core/settingsLoader.js.map +1 -0
- package/out/discordGateway.d.ts +26 -0
- package/out/discordGateway.js +230 -0
- package/out/discordGateway.js.map +1 -0
- package/out/discordPoller.d.ts +28 -0
- package/out/discordPoller.js +247 -0
- package/out/discordPoller.js.map +1 -0
- package/out/dispatcher.d.ts +12 -0
- package/out/dispatcher.js +214 -0
- package/out/dispatcher.js.map +1 -0
- package/out/emailPoller.d.ts +42 -0
- package/out/emailPoller.js +221 -0
- package/out/emailPoller.js.map +1 -0
- package/out/git/gitService.d.ts +36 -0
- package/out/git/gitService.js +165 -0
- package/out/git/gitService.js.map +1 -0
- package/out/hookEventNormalizer.d.ts +39 -0
- package/out/hookEventNormalizer.js +397 -0
- package/out/hookEventNormalizer.js.map +1 -0
- package/out/hooksManager.d.ts +25 -0
- package/out/hooksManager.js +471 -0
- package/out/hooksManager.js.map +1 -0
- package/out/launchIde.d.ts +14 -0
- package/out/logger.d.ts +12 -0
- package/out/mcpEmailTest.d.ts +29 -0
- package/out/mcpEmailTest.js +245 -0
- package/out/mcpEmailTest.js.map +1 -0
- package/out/mcpInstallCheck.d.ts +23 -0
- package/out/mcpInstallCheck.js +219 -0
- package/out/mcpInstallCheck.js.map +1 -0
- package/out/mcpManager.d.ts +35 -0
- package/out/mcpManager.js +371 -0
- package/out/mcpManager.js.map +1 -0
- package/out/messageBuilder.d.ts +54 -0
- package/out/messageBuilder.js +373 -0
- package/out/messageBuilder.js.map +1 -0
- package/out/openCodeHooksManager.d.ts +23 -0
- package/out/openCodeHooksManager.js +511 -0
- package/out/openCodeHooksManager.js.map +1 -0
- package/out/periodicActions.d.ts +63 -0
- package/out/periodicActions.js +237 -0
- package/out/periodicActions.js.map +1 -0
- package/out/profileBuilder.d.ts +29 -0
- package/out/profileBuilder.js +366 -0
- package/out/profileBuilder.js.map +1 -0
- package/out/prompt.d.ts +12 -0
- package/out/prompt.js +18 -0
- package/out/prompt.js.map +1 -0
- package/out/protocolSections.d.ts +26 -0
- package/out/protocolSections.js +209 -0
- package/out/protocolSections.js.map +1 -0
- package/out/providers/claudeCliProvider.d.ts +71 -0
- package/out/providers/claudeCliProvider.js +425 -0
- package/out/providers/claudeCliProvider.js.map +1 -0
- package/out/providers/claudeTuiProvider.d.ts +23 -0
- package/out/providers/claudeTuiProvider.js +296 -0
- package/out/providers/claudeTuiProvider.js.map +1 -0
- package/out/providers/copilotCliProvider.d.ts +16 -0
- package/out/providers/copilotCliProvider.js +44 -0
- package/out/providers/copilotCliProvider.js.map +1 -0
- package/out/providers/copilotSdkProvider.d.ts +12 -0
- package/out/providers/copilotSdkProvider.js +445 -0
- package/out/providers/copilotSdkProvider.js.map +1 -0
- package/out/providers/grokTuiProvider.d.ts +14 -0
- package/out/providers/grokTuiProvider.js +271 -0
- package/out/providers/grokTuiProvider.js.map +1 -0
- package/out/providers/opencodeCliProvider.d.ts +29 -0
- package/out/providers/opencodeCliProvider.js +199 -0
- package/out/providers/opencodeCliProvider.js.map +1 -0
- package/out/providers/opencodeSdkProvider.d.ts +22 -0
- package/out/providers/opencodeSdkProvider.js +557 -0
- package/out/providers/opencodeSdkProvider.js.map +1 -0
- package/out/providers.d.ts +9 -0
- package/out/providers.js +44 -0
- package/out/providers.js.map +1 -0
- package/out/rateLimit.d.ts +18 -0
- package/out/rateLimit.js +90 -0
- package/out/rateLimit.js.map +1 -0
- package/out/rdp/auth.d.ts +55 -0
- package/out/rdp/auth.js +197 -0
- package/out/rdp/auth.js.map +1 -0
- package/out/rdp/bridge.d.ts +86 -0
- package/out/rdp/bridge.js +1398 -0
- package/out/rdp/bridge.js.map +1 -0
- package/out/rdp/constants.d.ts +86 -0
- package/out/rdp/constants.js +182 -0
- package/out/rdp/constants.js.map +1 -0
- package/out/rdp/index.d.ts +7 -0
- package/out/rdp/index.js +14 -0
- package/out/rdp/index.js.map +1 -0
- package/out/rdp/session.d.ts +30 -0
- package/out/rdp/session.js +196 -0
- package/out/rdp/session.js.map +1 -0
- package/out/rdp/types.d.ts +27 -0
- package/out/rdp/types.js +6 -0
- package/out/rdp/types.js.map +1 -0
- package/out/sdk/index.d.ts +22 -0
- package/out/sdk/index.js +81 -0
- package/out/sdk/index.js.map +1 -0
- package/out/sessionState.d.ts +54 -0
- package/out/sessionState.js +284 -0
- package/out/sessionState.js.map +1 -0
- package/out/sessions.d.ts +11 -0
- package/out/sessions.js +32 -0
- package/out/sessions.js.map +1 -0
- package/out/taskLoop.d.ts +152 -0
- package/out/taskLoop.js +2505 -0
- package/out/taskLoop.js.map +1 -0
- package/out/todo.d.ts +42 -0
- package/out/todo.js +311 -0
- package/out/todo.js.map +1 -0
- package/out/todoWriteManager.d.ts +26 -0
- package/out/todoWriteManager.js +44 -0
- package/out/todoWriteManager.js.map +1 -0
- package/out/vnc/auth.d.ts +52 -0
- package/out/vnc/auth.js +181 -0
- package/out/vnc/auth.js.map +1 -0
- package/out/vnc/bridge.d.ts +40 -0
- package/out/vnc/bridge.js +540 -0
- package/out/vnc/bridge.js.map +1 -0
- package/out/vnc/constants.d.ts +8 -0
- package/out/vnc/constants.js +34 -0
- package/out/vnc/constants.js.map +1 -0
- package/out/vnc/des.d.ts +6 -0
- package/out/vnc/des.js +93 -0
- package/out/vnc/des.js.map +1 -0
- package/out/vnc/index.d.ts +7 -0
- package/out/vnc/index.js +13 -0
- package/out/vnc/index.js.map +1 -0
- package/out/vnc/session.d.ts +18 -0
- package/out/vnc/session.js +193 -0
- package/out/vnc/session.js.map +1 -0
- package/out/vnc/types.d.ts +16 -0
- package/out/vnc/types.js +6 -0
- package/out/vnc/types.js.map +1 -0
- package/out/webSocketPoller.d.ts +95 -0
- package/out/webSocketPoller.js +986 -0
- package/out/webSocketPoller.js.map +1 -0
- package/out/webhook.d.ts +37 -0
- package/out/webhook.js +265 -0
- package/out/webhook.js.map +1 -0
- package/out/webhookPoller.d.ts +40 -0
- package/out/webhookPoller.js +378 -0
- package/out/webhookPoller.js.map +1 -0
- package/package.json +54 -41
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifest.js","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>;
|
|
2
|
+
export interface OpenCodeDump {
|
|
3
|
+
sessions: Row[];
|
|
4
|
+
projects: Row[];
|
|
5
|
+
workspaces: Row[];
|
|
6
|
+
messages: Row[];
|
|
7
|
+
parts: Row[];
|
|
8
|
+
}
|
|
9
|
+
export declare function opencodeDbPath(): string;
|
|
10
|
+
/** Dump every row that belongs to the session(s) rooted at `root`, or null. */
|
|
11
|
+
export declare function dumpOpenCodeSessions(root: string): OpenCodeDump | null;
|
|
12
|
+
/** Insert a dump into the destination DB, rewriting paths to `destRoot`. */
|
|
13
|
+
export declare function restoreOpenCodeSessions(destRoot: string, dump: OpenCodeDump): number;
|
|
14
|
+
/** List sessions for a workspace with id + title + updated (for UI). */
|
|
15
|
+
export declare function listOpenCodeSessionsDetailed(root: string): Array<{
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
updated: number;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// OpenCode session portability — dump/restore the rows that make up a session
|
|
4
|
+
// from opencode's shared SQLite store (~/.local/share/opencode/opencode.db).
|
|
5
|
+
//
|
|
6
|
+
// A session spans 5 tables: project → workspace → session → message → part.
|
|
7
|
+
// On restore we rewrite the directory/worktree to the destination root and
|
|
8
|
+
// INSERT OR REPLACE the rows (parents first) into the destination DB so
|
|
9
|
+
// `opencode session list` finds the session under the new path and resume works.
|
|
10
|
+
//
|
|
11
|
+
// Uses the built-in `node:sqlite` (experimental but present in Node 22) so no
|
|
12
|
+
// new dependency is required. Loaded lazily — agentBackup still works if it's
|
|
13
|
+
// unavailable (opencode just falls back to non-portable).
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.opencodeDbPath = opencodeDbPath;
|
|
50
|
+
exports.dumpOpenCodeSessions = dumpOpenCodeSessions;
|
|
51
|
+
exports.restoreOpenCodeSessions = restoreOpenCodeSessions;
|
|
52
|
+
exports.listOpenCodeSessionsDetailed = listOpenCodeSessionsDetailed;
|
|
53
|
+
const fs = __importStar(require("fs"));
|
|
54
|
+
const os = __importStar(require("os"));
|
|
55
|
+
const path = __importStar(require("path"));
|
|
56
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
|
+
function openDb(file, readOnly) {
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
59
|
+
const { DatabaseSync } = require('node:sqlite');
|
|
60
|
+
return new DatabaseSync(file, { readOnly });
|
|
61
|
+
}
|
|
62
|
+
function opencodeDbPath() {
|
|
63
|
+
const base = process.env['XDG_DATA_HOME'] ?? path.join(os.homedir(), '.local', 'share');
|
|
64
|
+
return path.join(base, 'opencode', 'opencode.db');
|
|
65
|
+
}
|
|
66
|
+
function norm(p) {
|
|
67
|
+
let r = p;
|
|
68
|
+
try {
|
|
69
|
+
r = fs.realpathSync(p);
|
|
70
|
+
}
|
|
71
|
+
catch { /* keep lexical */ }
|
|
72
|
+
return r.replace(/\\/g, '/').replace(/\/+$/, '').toLowerCase();
|
|
73
|
+
}
|
|
74
|
+
const TABLES = ['session', 'project', 'workspace', 'message', 'part'];
|
|
75
|
+
/** Dump every row that belongs to the session(s) rooted at `root`, or null. */
|
|
76
|
+
function dumpOpenCodeSessions(root) {
|
|
77
|
+
const dbFile = opencodeDbPath();
|
|
78
|
+
if (!fs.existsSync(dbFile)) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
let db;
|
|
83
|
+
try {
|
|
84
|
+
db = openDb(dbFile, true);
|
|
85
|
+
const target = norm(root);
|
|
86
|
+
const sessions = db.prepare('SELECT * FROM session').all()
|
|
87
|
+
.filter(s => norm(String(s.directory)) === target);
|
|
88
|
+
if (sessions.length === 0) {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
const ids = (arr) => [...new Set(arr.filter(Boolean).map(String))];
|
|
92
|
+
const sids = ids(sessions.map(s => s.id));
|
|
93
|
+
const projIds = ids(sessions.map(s => s.project_id));
|
|
94
|
+
const wsIds = ids(sessions.map(s => s.workspace_id));
|
|
95
|
+
const inq = (a) => a.map(() => '?').join(',');
|
|
96
|
+
const sel = (sql, params) => params.length ? db.prepare(sql).all(...params) : [];
|
|
97
|
+
return {
|
|
98
|
+
sessions,
|
|
99
|
+
projects: sel(`SELECT * FROM project WHERE id IN (${inq(projIds)})`, projIds),
|
|
100
|
+
workspaces: sel(`SELECT * FROM workspace WHERE id IN (${inq(wsIds)})`, wsIds),
|
|
101
|
+
messages: sel(`SELECT * FROM message WHERE session_id IN (${inq(sids)})`, sids),
|
|
102
|
+
parts: sel(`SELECT * FROM part WHERE session_id IN (${inq(sids)})`, sids),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
catch {
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
finally {
|
|
109
|
+
try {
|
|
110
|
+
db?.close();
|
|
111
|
+
}
|
|
112
|
+
catch { /* ignore */ }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/** Insert a dump into the destination DB, rewriting paths to `destRoot`. */
|
|
116
|
+
function restoreOpenCodeSessions(destRoot, dump) {
|
|
117
|
+
const dbFile = opencodeDbPath();
|
|
118
|
+
// Requires opencode to have initialised its schema on this machine at least
|
|
119
|
+
// once. Without the DB we can't insert (no tables) — caller treats 0 as skip.
|
|
120
|
+
if (!fs.existsSync(dbFile)) {
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
124
|
+
let db;
|
|
125
|
+
let written = 0;
|
|
126
|
+
try {
|
|
127
|
+
db = openDb(dbFile, false);
|
|
128
|
+
for (const s of dump.sessions) {
|
|
129
|
+
s.directory = destRoot;
|
|
130
|
+
}
|
|
131
|
+
for (const p of dump.projects) {
|
|
132
|
+
p.worktree = destRoot;
|
|
133
|
+
}
|
|
134
|
+
for (const w of dump.workspaces) {
|
|
135
|
+
if (w.directory != null) {
|
|
136
|
+
w.directory = destRoot;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
const insert = (table, rows) => {
|
|
140
|
+
for (const row of rows) {
|
|
141
|
+
const cols = Object.keys(row);
|
|
142
|
+
const sql = `INSERT OR REPLACE INTO ${table} (${cols.map(c => '`' + c + '`').join(',')}) `
|
|
143
|
+
+ `VALUES (${cols.map(() => '?').join(',')})`;
|
|
144
|
+
try {
|
|
145
|
+
db.prepare(sql).run(...cols.map(c => normValue(row[c])));
|
|
146
|
+
written++;
|
|
147
|
+
}
|
|
148
|
+
catch { /* skip a bad row, keep going */ }
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
try {
|
|
152
|
+
db.exec('PRAGMA foreign_keys=OFF');
|
|
153
|
+
}
|
|
154
|
+
catch { /* ignore */ }
|
|
155
|
+
// Parents first to satisfy FKs even with enforcement on.
|
|
156
|
+
insert('project', dump.projects);
|
|
157
|
+
insert('workspace', dump.workspaces);
|
|
158
|
+
insert('session', dump.sessions);
|
|
159
|
+
insert('message', dump.messages);
|
|
160
|
+
insert('part', dump.parts);
|
|
161
|
+
return written;
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
return written;
|
|
165
|
+
}
|
|
166
|
+
finally {
|
|
167
|
+
try {
|
|
168
|
+
db?.close();
|
|
169
|
+
}
|
|
170
|
+
catch { /* ignore */ }
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/** node:sqlite only binds null|number|bigint|string|Uint8Array. */
|
|
174
|
+
function normValue(v) {
|
|
175
|
+
if (v === null || v === undefined) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
if (typeof v === 'boolean') {
|
|
179
|
+
return v ? 1 : 0;
|
|
180
|
+
}
|
|
181
|
+
if (typeof v === 'number' || typeof v === 'bigint' || typeof v === 'string' || v instanceof Uint8Array) {
|
|
182
|
+
return v;
|
|
183
|
+
}
|
|
184
|
+
return JSON.stringify(v);
|
|
185
|
+
}
|
|
186
|
+
void TABLES;
|
|
187
|
+
/** List sessions for a workspace with id + title + updated (for UI). */
|
|
188
|
+
function listOpenCodeSessionsDetailed(root) {
|
|
189
|
+
const dbFile = opencodeDbPath();
|
|
190
|
+
if (!fs.existsSync(dbFile)) {
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
194
|
+
let db;
|
|
195
|
+
try {
|
|
196
|
+
db = openDb(dbFile, true);
|
|
197
|
+
const target = norm(root);
|
|
198
|
+
return db.prepare('SELECT id, title, directory, time_updated FROM session').all()
|
|
199
|
+
.filter(r => norm(String(r.directory ?? '')) === target)
|
|
200
|
+
.map(r => ({ id: String(r.id), title: String(r.title ?? ''), updated: Number(r.time_updated ?? 0) }))
|
|
201
|
+
.sort((a, b) => b.updated - a.updated);
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return [];
|
|
205
|
+
}
|
|
206
|
+
finally {
|
|
207
|
+
try {
|
|
208
|
+
db?.close();
|
|
209
|
+
}
|
|
210
|
+
catch { /* ignore */ }
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=opencodeDb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencodeDb.js","sourceRoot":"","sources":["../../src/agentBackup/opencodeDb.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,8EAA8E;AAC9E,6EAA6E;AAC7E,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAC3E,wEAAwE;AACxE,iFAAiF;AACjF,EAAE;AACF,8EAA8E;AAC9E,8EAA8E;AAC9E,0DAA0D;AAC1D,8EAA8E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuB9E,wCAGC;AAWD,oDA0BC;AAGD,0DAgCC;AAaD,oEAaC;AA1HD,uCAAyB;AACzB,uCAAyB;AACzB,2CAA6B;AAY7B,8DAA8D;AAC9D,SAAS,MAAM,CAAC,IAAY,EAAE,QAAiB;IAC7C,8DAA8D;IAC9D,MAAM,EAAE,YAAY,EAAE,GA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wDAAwD,CAAC,CAAC,GAAG,EAAY;aACzF,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC;aACvD,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;aACpG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QAAC,OAAO,EAAE,CAAC;IAAC,CAAC;YAAS,CAAC;QAAC,IAAI,CAAC;YAAC,EAAE,EAAE,KAAK,EAAE,CAAC;QAAC,CAAC;QAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC;IAAC,CAAC;AAChF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Archive } from './archive';
|
|
2
|
+
/**
|
|
3
|
+
* How portable a provider's session traces are across a folder/machine move:
|
|
4
|
+
* - `full` — the conversation can be restored and resumed elsewhere.
|
|
5
|
+
* - `partial` — some artifacts travel, but resume is best-effort/unverified.
|
|
6
|
+
* - `none` — nothing resumable on disk (in-memory only or no store).
|
|
7
|
+
*/
|
|
8
|
+
export type Portability = 'full' | 'partial' | 'none';
|
|
9
|
+
export interface CollectResult {
|
|
10
|
+
/** Session IDs discovered for this workspace (informational). */
|
|
11
|
+
discoveredIds: string[];
|
|
12
|
+
/** True if real conversation traces were written into the archive. */
|
|
13
|
+
tracesCaptured: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Strategy for backing up and restoring one provider family's session traces.
|
|
17
|
+
* Adding a provider is a new implementation — export/import never change
|
|
18
|
+
* (Open/Closed). Each strategy is honest about its {@link Portability}.
|
|
19
|
+
*/
|
|
20
|
+
export interface SessionBackupProvider {
|
|
21
|
+
/** Stable id — also the archive sub-folder and manifest key. */
|
|
22
|
+
readonly id: string;
|
|
23
|
+
/** `session-state.json` keys this strategy owns. */
|
|
24
|
+
readonly sessionStateKeys: readonly string[];
|
|
25
|
+
/** Portability classification (drives honest manifest + UI messaging). */
|
|
26
|
+
readonly portability: Portability;
|
|
27
|
+
/** Human-readable explanation of what is/isn't captured. */
|
|
28
|
+
readonly note: string;
|
|
29
|
+
/** Capture this provider's sessions into the archive. */
|
|
30
|
+
collect(root: string, archive: Archive): Promise<CollectResult>;
|
|
31
|
+
/** Restore this provider's sessions for the destination workspace. Returns files written. */
|
|
32
|
+
restore(destRoot: string, archive: Archive): Promise<number>;
|
|
33
|
+
}
|
|
34
|
+
/** All registered session-backup strategies (covers every ProviderId). */
|
|
35
|
+
export declare const SESSION_BACKUP_PROVIDERS: readonly SessionBackupProvider[];
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SESSION_BACKUP_PROVIDERS = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const layout_1 = require("./layout");
|
|
40
|
+
const claudeCliProvider_1 = require("../providers/claudeCliProvider");
|
|
41
|
+
const opencodeCliProvider_1 = require("../providers/opencodeCliProvider");
|
|
42
|
+
const opencodeDb_1 = require("./opencodeDb");
|
|
43
|
+
/** List the immediate child folder names under an archive directory prefix. */
|
|
44
|
+
function archiveChildDirs(archive, prefix) {
|
|
45
|
+
const base = prefix.replace(/\/$/, '') + '/';
|
|
46
|
+
const names = new Set();
|
|
47
|
+
for (const entry of archive.entryPaths()) {
|
|
48
|
+
if (!entry.startsWith(base)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const top = entry.slice(base.length).split('/')[0];
|
|
52
|
+
if (top) {
|
|
53
|
+
names.add(top);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return [...names];
|
|
57
|
+
}
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Claude (covers claude-cli AND claude-tui — shared ~/.claude/projects store)
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
class ClaudeSessionBackup {
|
|
62
|
+
id = 'claude';
|
|
63
|
+
sessionStateKeys = ['claude-cli', 'claude-tui'];
|
|
64
|
+
portability = 'full';
|
|
65
|
+
note = 'JSONL traces from ~/.claude/projects re-encoded for the destination path.';
|
|
66
|
+
async collect(root, archive) {
|
|
67
|
+
const files = (0, claudeCliProvider_1.listClaudeSessionFiles)(root);
|
|
68
|
+
const discoveredIds = [];
|
|
69
|
+
for (const f of files) {
|
|
70
|
+
const sid = f.name.replace(/\.jsonl$/i, '');
|
|
71
|
+
discoveredIds.push(sid);
|
|
72
|
+
archive.addFile(f.full, `${(0, layout_1.sessionsPath)(this.id)}/${path.basename(f.full)}`);
|
|
73
|
+
// Include matching agent-* sidecar traces for this session.
|
|
74
|
+
try {
|
|
75
|
+
const dir = path.dirname(f.full);
|
|
76
|
+
for (const child of fs.readdirSync(dir)) {
|
|
77
|
+
if (child.startsWith(`agent-${sid}`) && child.endsWith('.jsonl')) {
|
|
78
|
+
archive.addFile(path.join(dir, child), `${(0, layout_1.sessionsPath)(this.id)}/${child}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
catch { /* ignore */ }
|
|
83
|
+
}
|
|
84
|
+
return { discoveredIds, tracesCaptured: discoveredIds.length > 0 };
|
|
85
|
+
}
|
|
86
|
+
async restore(destRoot, archive) {
|
|
87
|
+
// Claude resolves sessions by an encoding of the *destination* path, so
|
|
88
|
+
// traces must land in that folder even though captured under another.
|
|
89
|
+
const destDir = (0, claudeCliProvider_1.getClaudeProjectDir)(destRoot);
|
|
90
|
+
const n = archive.extractDir((0, layout_1.sessionsPath)(this.id), destDir);
|
|
91
|
+
// Rewrite path references INSIDE each JSONL from the captured (old) root to
|
|
92
|
+
// destRoot — otherwise a resumed session carries a stale `cwd` and
|
|
93
|
+
// `transcript_path` pointing at the original machine/folder. The old root is
|
|
94
|
+
// discovered from the first `"cwd"` field; both the raw path and Claude's
|
|
95
|
+
// dash-encoded project-folder form are replaced.
|
|
96
|
+
try {
|
|
97
|
+
const newEnc = (0, claudeCliProvider_1.claudeProjectFolder)(destRoot);
|
|
98
|
+
for (const file of fs.readdirSync(destDir)) {
|
|
99
|
+
if (!file.endsWith('.jsonl')) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const full = path.join(destDir, file);
|
|
103
|
+
let text = fs.readFileSync(full, 'utf8');
|
|
104
|
+
const oldRoot = text.match(/"cwd"\s*:\s*"([^"]+)"/)?.[1];
|
|
105
|
+
if (!oldRoot || oldRoot === destRoot) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const oldEnc = (0, claudeCliProvider_1.claudeProjectFolder)(oldRoot);
|
|
109
|
+
text = text.split(oldRoot).join(destRoot);
|
|
110
|
+
if (oldEnc !== newEnc) {
|
|
111
|
+
text = text.split(oldEnc).join(newEnc);
|
|
112
|
+
}
|
|
113
|
+
fs.writeFileSync(full, text, 'utf8');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
catch { /* best-effort rewrite — files are still resumable with stale cwd */ }
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
// Copilot CLI — ~/.copilot/session-state/<uuid>/ bound to a cwd via workspace.yaml
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
/** Extract the `cwd:` value from a Copilot session `workspace.yaml`. */
|
|
124
|
+
function readCopilotCwd(yamlPath) {
|
|
125
|
+
try {
|
|
126
|
+
const text = fs.readFileSync(yamlPath, 'utf8');
|
|
127
|
+
const m = text.match(/^cwd:\s*(.+?)\s*$/m);
|
|
128
|
+
return m?.[1];
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Rewrite the `cwd:` value of a Copilot session `workspace.yaml` to `destRoot`. */
|
|
135
|
+
function rewriteCopilotCwd(yamlPath, destRoot) {
|
|
136
|
+
try {
|
|
137
|
+
const text = fs.readFileSync(yamlPath, 'utf8');
|
|
138
|
+
if (!/^cwd:\s*.+$/m.test(text)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const next = text.replace(/^cwd:\s*.+$/m, `cwd: ${destRoot}`);
|
|
142
|
+
fs.writeFileSync(yamlPath, next, 'utf8');
|
|
143
|
+
}
|
|
144
|
+
catch { /* ignore */ }
|
|
145
|
+
}
|
|
146
|
+
class CopilotCliSessionBackup {
|
|
147
|
+
id = 'copilot-cli';
|
|
148
|
+
sessionStateKeys = ['copilot-cli'];
|
|
149
|
+
portability = 'full';
|
|
150
|
+
note = 'Copies ~/.copilot/session-state/<uuid>/ and rewrites workspace.yaml cwd. '
|
|
151
|
+
+ 'session-store.db (SQLite index) is not modified; resume by explicit --resume=<uuid>.';
|
|
152
|
+
async collect(root, archive) {
|
|
153
|
+
const stateDir = (0, layout_1.copilotSessionStateDir)();
|
|
154
|
+
const discoveredIds = [];
|
|
155
|
+
let entries = [];
|
|
156
|
+
try {
|
|
157
|
+
entries = fs.readdirSync(stateDir);
|
|
158
|
+
}
|
|
159
|
+
catch {
|
|
160
|
+
return { discoveredIds, tracesCaptured: false };
|
|
161
|
+
}
|
|
162
|
+
const target = (0, layout_1.normalizePath)(root);
|
|
163
|
+
for (const uuid of entries) {
|
|
164
|
+
const dir = path.join(stateDir, uuid);
|
|
165
|
+
try {
|
|
166
|
+
if (!fs.statSync(dir).isDirectory()) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
const cwd = readCopilotCwd(path.join(dir, 'workspace.yaml'));
|
|
174
|
+
if (!cwd || (0, layout_1.normalizePath)(cwd) !== target) {
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
archive.addDir(dir, `${(0, layout_1.sessionsPath)(this.id)}/${uuid}`);
|
|
178
|
+
discoveredIds.push(uuid);
|
|
179
|
+
}
|
|
180
|
+
return { discoveredIds, tracesCaptured: discoveredIds.length > 0 };
|
|
181
|
+
}
|
|
182
|
+
async restore(destRoot, archive) {
|
|
183
|
+
const stateDir = (0, layout_1.copilotSessionStateDir)();
|
|
184
|
+
let written = 0;
|
|
185
|
+
for (const uuid of archiveChildDirs(archive, (0, layout_1.sessionsPath)(this.id))) {
|
|
186
|
+
const target = path.join(stateDir, uuid);
|
|
187
|
+
written += archive.extractDir(`${(0, layout_1.sessionsPath)(this.id)}/${uuid}`, target);
|
|
188
|
+
rewriteCopilotCwd(path.join(target, 'workspace.yaml'), destRoot);
|
|
189
|
+
}
|
|
190
|
+
return written;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
// Non-portable providers — recorded honestly, no trace capture/restore.
|
|
195
|
+
// ---------------------------------------------------------------------------
|
|
196
|
+
/** OpenCode (cli + sdk): sessions live in SQLite opencode.db — not portable per-session. */
|
|
197
|
+
class OpenCodeSessionBackup {
|
|
198
|
+
id = 'opencode';
|
|
199
|
+
sessionStateKeys = ['opencode-cli', 'opencode-sdk'];
|
|
200
|
+
portability = 'full';
|
|
201
|
+
note = 'Dumps the session/project/workspace/message/part rows from the shared '
|
|
202
|
+
+ 'SQLite opencode.db and re-inserts them with the directory rewritten to the '
|
|
203
|
+
+ 'destination. Restore needs opencode initialised on the target machine.';
|
|
204
|
+
async collect(root, archive) {
|
|
205
|
+
let discoveredIds = [];
|
|
206
|
+
try {
|
|
207
|
+
discoveredIds = (await (0, opencodeCliProvider_1.listOpenCodeSessions)(root)).map(s => s.id);
|
|
208
|
+
}
|
|
209
|
+
catch { /* ignore */ }
|
|
210
|
+
let tracesCaptured = false;
|
|
211
|
+
try {
|
|
212
|
+
const dump = (0, opencodeDb_1.dumpOpenCodeSessions)(root);
|
|
213
|
+
if (dump && dump.sessions.length > 0) {
|
|
214
|
+
const json = JSON.stringify(dump, (_k, v) => (typeof v === 'bigint' ? Number(v) : v));
|
|
215
|
+
archive.addBuffer(`${(0, layout_1.sessionsPath)(this.id)}/dump.json`, Buffer.from(json, 'utf8'));
|
|
216
|
+
tracesCaptured = true;
|
|
217
|
+
discoveredIds = dump.sessions.map(s => String(s.id));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch { /* fall back to ids-only */ }
|
|
221
|
+
return { discoveredIds, tracesCaptured };
|
|
222
|
+
}
|
|
223
|
+
async restore(destRoot, archive) {
|
|
224
|
+
const json = archive.readText(`${(0, layout_1.sessionsPath)(this.id)}/dump.json`);
|
|
225
|
+
if (!json) {
|
|
226
|
+
return 0;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
const dump = JSON.parse(json);
|
|
230
|
+
return (0, opencodeDb_1.restoreOpenCodeSessions)(destRoot, dump);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return 0;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/** Copilot SDK: in-process LocalSession with a synthetic id — nothing on disk. */
|
|
238
|
+
class CopilotSdkSessionBackup {
|
|
239
|
+
id = 'copilot-sdk';
|
|
240
|
+
sessionStateKeys = ['copilot-sdk'];
|
|
241
|
+
portability = 'none';
|
|
242
|
+
note = 'Copilot SDK sessions are in-memory only; no resumable trace exists on disk.';
|
|
243
|
+
async collect() { return { discoveredIds: [], tracesCaptured: false }; }
|
|
244
|
+
async restore() { return 0; }
|
|
245
|
+
}
|
|
246
|
+
/** Grok TUI: fresh process per task, no session store at all. */
|
|
247
|
+
class GrokSessionBackup {
|
|
248
|
+
id = 'grok-tui';
|
|
249
|
+
sessionStateKeys = ['grok-tui'];
|
|
250
|
+
portability = 'none';
|
|
251
|
+
note = 'Grok TUI keeps no session state; each task is an independent process.';
|
|
252
|
+
async collect() { return { discoveredIds: [], tracesCaptured: false }; }
|
|
253
|
+
async restore() { return 0; }
|
|
254
|
+
}
|
|
255
|
+
/** All registered session-backup strategies (covers every ProviderId). */
|
|
256
|
+
exports.SESSION_BACKUP_PROVIDERS = [
|
|
257
|
+
new ClaudeSessionBackup(),
|
|
258
|
+
new CopilotCliSessionBackup(),
|
|
259
|
+
new OpenCodeSessionBackup(),
|
|
260
|
+
new CopilotSdkSessionBackup(),
|
|
261
|
+
new GrokSessionBackup(),
|
|
262
|
+
];
|
|
263
|
+
//# sourceMappingURL=sessionProviders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionProviders.js","sourceRoot":"","sources":["../../src/agentBackup/sessionProviders.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,qCAA+E;AAC/E,sEAAkH;AAClH,0EAAwE;AACxE,6CAA2F;AAqC3F,+EAA+E;AAC/E,SAAS,gBAAgB,CAAC,OAAgB,EAAE,MAAc;IACxD,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC;IAC7C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAAC,SAAS;QAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,IAAI,GAAG,EAAE,CAAC;YAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAAC,CAAC;IAC9B,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
|
3
|
+
filename: string;
|
|
4
|
+
downloadUrl: string;
|
|
5
|
+
}
|
|
6
|
+
/** Upload a backup zip to `POST /api/agents/{agentId}/exports`. */
|
|
7
|
+
export declare function uploadAgentBackup(zipPath: string, agentId: string, serverBaseUrl: string, serverApiKey: string): Promise<UploadResult>;
|
|
8
|
+
/** Download a zip from a URL (authenticated) and save to destPath. */
|
|
9
|
+
export declare function downloadAgentBackup(downloadUrl: string, destPath: string, serverApiKey: string): Promise<void>;
|