svamp-cli 0.2.283 → 0.2.289
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/{adminCommands-BfRJD2aA.mjs → adminCommands-C7-LgldE.mjs} +71 -22
- package/dist/{agentCommands-B23M4vER.mjs → agentCommands-B7HQJo3X.mjs} +5 -5
- package/dist/{auth-DPZSnISj.mjs → auth-BB_4_6P7.mjs} +1 -1
- package/dist/{cli-yOuFbsef.mjs → cli-BH5LIMPI.mjs} +72 -69
- package/dist/cli.mjs +2 -2
- package/dist/{commands-Cp8G-iuw.mjs → commands-BNxsrqSl.mjs} +2 -2
- package/dist/{commands-BABblJRp.mjs → commands-BaVcBOKA.mjs} +1 -1
- package/dist/{commands-DqsoW-S0.mjs → commands-Bb-RzoKB.mjs} +1 -1
- package/dist/{commands-DDf0W30g.mjs → commands-BsiQdwUs.mjs} +2 -2
- package/dist/{commands-BHO7rzSh.mjs → commands-CZSPOqtd.mjs} +1 -1
- package/dist/{commands-CRA262P3.mjs → commands-Cf9KT-Ob.mjs} +2 -2
- package/dist/{commands-BqaOHWym.mjs → commands-DFSD7jBH.mjs} +8 -8
- package/dist/{fleet-BxhHefua.mjs → fleet-2c-iNucb.mjs} +1 -1
- package/dist/{frpc-BsR6aGNJ.mjs → frpc-CuvdlU0g.mjs} +1 -1
- package/dist/{headlessCli-B-aMhdKx.mjs → headlessCli-CftEZbxm.mjs} +2 -2
- package/dist/index.mjs +1 -1
- package/dist/{notifyCommands-CfnthGpX.mjs → notifyCommands-1q8COUDd.mjs} +1 -1
- package/dist/package-DrTlgNWY.mjs +64 -0
- package/dist/{rpc-BjrKqEib.mjs → rpc-C9U0Ho27.mjs} +1 -1
- package/dist/{rpc-B5BRaVsS.mjs → rpc-DMpJef5v.mjs} +1 -1
- package/dist/{run-CRTzyKbn.mjs → run-BNeZiySO.mjs} +61 -19
- package/dist/{run-DWJenrBe.mjs → run-CCENV09o.mjs} +1 -1
- package/dist/{scheduler-QYMtbUDe.mjs → scheduler-CAUwniWA.mjs} +1 -1
- package/dist/{serveCommands-Cj3MLbZb.mjs → serveCommands-XJVDS4zB.mjs} +5 -5
- package/dist/{sideband-CKmZxwY6.mjs → sideband-DB4Uipz9.mjs} +1 -1
- package/package.json +2 -2
- package/dist/package-COj14J00.mjs +0 -64
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as connectToHypha, K as computeCollectionConfigUpdate, L as SYSTEM_COLLECTION_CONFIG } from './run-
|
|
1
|
+
import { c as connectToHypha, K as computeCollectionConfigUpdate, L as SYSTEM_COLLECTION_CONFIG } from './run-BNeZiySO.mjs';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
4
|
import os from 'node:os';
|
|
@@ -157,6 +157,68 @@ async function createSystemCollections() {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
+
async function listAllChildren(am, parentId) {
|
|
161
|
+
const PAGE = 100;
|
|
162
|
+
const all = [];
|
|
163
|
+
const seen = /* @__PURE__ */ new Set();
|
|
164
|
+
for (let offset = 0; ; offset += PAGE) {
|
|
165
|
+
const page = await am.list({ parent_id: parentId, offset, limit: PAGE, _rkwargs: true });
|
|
166
|
+
if (!Array.isArray(page) || page.length === 0) break;
|
|
167
|
+
let fresh = 0;
|
|
168
|
+
for (const c of page) {
|
|
169
|
+
const k = String(c?.id ?? c?.manifest?.id ?? c?.alias ?? `${offset}:${fresh}`);
|
|
170
|
+
if (seen.has(k)) continue;
|
|
171
|
+
seen.add(k);
|
|
172
|
+
all.push(c);
|
|
173
|
+
fresh++;
|
|
174
|
+
}
|
|
175
|
+
if (page.length < PAGE || fresh === 0) break;
|
|
176
|
+
}
|
|
177
|
+
return all;
|
|
178
|
+
}
|
|
179
|
+
async function migrateChildren(am, fromId, toId) {
|
|
180
|
+
const children = await listAllChildren(am, fromId);
|
|
181
|
+
if (!Array.isArray(children) || children.length === 0) {
|
|
182
|
+
return { total: 0, copied: 0, alreadyPresent: 0, failed: 0, errors: [] };
|
|
183
|
+
}
|
|
184
|
+
let existing = [];
|
|
185
|
+
try {
|
|
186
|
+
existing = await listAllChildren(am, toId);
|
|
187
|
+
} catch {
|
|
188
|
+
}
|
|
189
|
+
const keyOf = (c) => String(c?.manifest?.id ?? c?.alias ?? "");
|
|
190
|
+
const existingKeys = new Set((Array.isArray(existing) ? existing : []).map(keyOf).filter(Boolean));
|
|
191
|
+
let copied = 0, alreadyPresent = 0, failed = 0;
|
|
192
|
+
const errors = [];
|
|
193
|
+
const noteErr = (m) => {
|
|
194
|
+
if (errors.length < 5 && !errors.includes(m)) errors.push(m);
|
|
195
|
+
};
|
|
196
|
+
for (const c of children) {
|
|
197
|
+
const manifest = c?.manifest;
|
|
198
|
+
const key = keyOf(c);
|
|
199
|
+
const alias = c?.alias || (manifest?.id ? `mig-${String(manifest.id).slice(0, 12)}` : void 0);
|
|
200
|
+
if (!manifest || !alias) {
|
|
201
|
+
failed++;
|
|
202
|
+
noteErr("child had no manifest/alias");
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (key && existingKeys.has(key)) {
|
|
206
|
+
alreadyPresent++;
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
const artifact = await am.create({ alias, parent_id: toId, type: c.type || "user-event", stage: true, manifest, _rkwargs: true });
|
|
211
|
+
await am.commit({ artifact_id: artifact.id, _rkwargs: true });
|
|
212
|
+
if (key) existingKeys.add(key);
|
|
213
|
+
copied++;
|
|
214
|
+
} catch (e) {
|
|
215
|
+
const msg = String(e?.message || e);
|
|
216
|
+
failed++;
|
|
217
|
+
noteErr(msg.slice(0, 160));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return { total: children.length, copied, alreadyPresent, failed, errors };
|
|
221
|
+
}
|
|
160
222
|
async function migrateCollectionChildren(fromId, toId) {
|
|
161
223
|
if (!fromId || !toId) {
|
|
162
224
|
console.error("Usage: svamp admin migrate-collection-children <fromId> <toId>");
|
|
@@ -165,35 +227,22 @@ async function migrateCollectionChildren(fromId, toId) {
|
|
|
165
227
|
}
|
|
166
228
|
const { server, am } = await connectAdmin("svamp-admin-migrate");
|
|
167
229
|
try {
|
|
168
|
-
let
|
|
230
|
+
let result;
|
|
169
231
|
try {
|
|
170
|
-
|
|
232
|
+
result = await migrateChildren(am, fromId, toId);
|
|
171
233
|
} catch (e) {
|
|
172
234
|
console.error(`Cannot list source "${fromId}" (need read/list rights on it): ${e.message}`);
|
|
173
235
|
process.exit(1);
|
|
174
236
|
}
|
|
175
|
-
if (
|
|
237
|
+
if (result.total === 0) {
|
|
176
238
|
console.log(`${fromId}: no children to migrate.`);
|
|
177
239
|
return;
|
|
178
240
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const alias = c?.alias || (manifest?.id ? `mig-${String(manifest.id).slice(0, 12)}` : void 0);
|
|
183
|
-
if (!manifest || !alias) {
|
|
184
|
-
skipped++;
|
|
185
|
-
continue;
|
|
186
|
-
}
|
|
187
|
-
try {
|
|
188
|
-
await am.create({ alias, parent_id: toId, type: c.type || "user-event", stage: true, manifest, _rkwargs: true });
|
|
189
|
-
await am.commit({ artifact_id: `${toId}`, _rkwargs: true }).catch(() => {
|
|
190
|
-
});
|
|
191
|
-
copied++;
|
|
192
|
-
} catch (e) {
|
|
193
|
-
skipped++;
|
|
194
|
-
}
|
|
241
|
+
console.log(`${fromId} \u2192 ${toId}: ${result.copied} copied, ${result.alreadyPresent} already-present, ${result.failed} failed (of ${result.total}). Source left intact; delete it manually once verified.`);
|
|
242
|
+
if (result.errors.length) {
|
|
243
|
+
console.error(` errors (sample): ${result.errors.join(" | ")}`);
|
|
195
244
|
}
|
|
196
|
-
|
|
245
|
+
if (result.failed > 0) process.exit(1);
|
|
197
246
|
} finally {
|
|
198
247
|
try {
|
|
199
248
|
await server.disconnect?.();
|
|
@@ -202,4 +251,4 @@ async function migrateCollectionChildren(fromId, toId) {
|
|
|
202
251
|
}
|
|
203
252
|
}
|
|
204
253
|
|
|
205
|
-
export { createSystemCollections, migrateCollectionChildren, setCollectionConfig };
|
|
254
|
+
export { createSystemCollections, migrateChildren, migrateCollectionChildren, setCollectionConfig };
|
|
@@ -2,7 +2,7 @@ import { existsSync, readFileSync, mkdirSync, writeFileSync, renameSync } from '
|
|
|
2
2
|
import { join, dirname } from 'node:path';
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import { requireNotSandboxed } from './sandboxDetect-DNTcbgWD.mjs';
|
|
5
|
-
import { i as shortId } from './run-
|
|
5
|
+
import { i as shortId } from './run-BNeZiySO.mjs';
|
|
6
6
|
import 'os';
|
|
7
7
|
import 'fs/promises';
|
|
8
8
|
import 'fs';
|
|
@@ -96,7 +96,7 @@ async function sessionSetTitle(title) {
|
|
|
96
96
|
}
|
|
97
97
|
async function sessionSetProjectDescription(description) {
|
|
98
98
|
const dir = process.cwd();
|
|
99
|
-
const { projectName, writeProjectInfo, sanitizeDescription, projectInfoPath } = await import('./run-
|
|
99
|
+
const { projectName, writeProjectInfo, sanitizeDescription, projectInfoPath } = await import('./run-BNeZiySO.mjs').then(function (n) { return n.ap; });
|
|
100
100
|
const desc = sanitizeDescription(description, 240);
|
|
101
101
|
if (!desc) {
|
|
102
102
|
console.error("Project description is empty.");
|
|
@@ -343,7 +343,7 @@ async function sessionBroadcast(action, args) {
|
|
|
343
343
|
console.log(`Broadcast sent: ${action}`);
|
|
344
344
|
}
|
|
345
345
|
async function connectToMachineService() {
|
|
346
|
-
const { connectAndGetMachine } = await import('./commands-
|
|
346
|
+
const { connectAndGetMachine } = await import('./commands-BaVcBOKA.mjs');
|
|
347
347
|
return connectAndGetMachine();
|
|
348
348
|
}
|
|
349
349
|
function buildInboxMessage(args) {
|
|
@@ -421,7 +421,7 @@ async function inboxSend(targetSessionId, opts) {
|
|
|
421
421
|
console.error("Message body is required.");
|
|
422
422
|
process.exit(1);
|
|
423
423
|
}
|
|
424
|
-
const { connectAndResolveSession } = await import('./commands-
|
|
424
|
+
const { connectAndResolveSession } = await import('./commands-BaVcBOKA.mjs');
|
|
425
425
|
let server;
|
|
426
426
|
try {
|
|
427
427
|
const { targetId, messageId } = await inboxSendCore(
|
|
@@ -475,7 +475,7 @@ async function inboxReply(messageId, body) {
|
|
|
475
475
|
console.error("SVAMP_SESSION_ID not set. This command must be run inside a Svamp session.");
|
|
476
476
|
process.exit(1);
|
|
477
477
|
}
|
|
478
|
-
const { connectAndResolveSession } = await import('./commands-
|
|
478
|
+
const { connectAndResolveSession } = await import('./commands-BaVcBOKA.mjs');
|
|
479
479
|
const { server: localServer, machine: localMachine } = await connectToMachineService();
|
|
480
480
|
let localDisconnected = false;
|
|
481
481
|
const disconnectLocal = async () => {
|