svamp-cli 0.2.278 → 0.2.280
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.
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { c as connectToHypha } from './run-CumVWywx.mjs';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import 'os';
|
|
6
|
+
import 'fs/promises';
|
|
7
|
+
import 'fs';
|
|
8
|
+
import 'path';
|
|
9
|
+
import 'url';
|
|
10
|
+
import 'child_process';
|
|
11
|
+
import 'crypto';
|
|
12
|
+
import 'node:crypto';
|
|
13
|
+
import 'node:child_process';
|
|
14
|
+
import 'util';
|
|
15
|
+
import 'http';
|
|
16
|
+
import 'net';
|
|
17
|
+
import 'node:events';
|
|
18
|
+
import '@agentclientprotocol/sdk';
|
|
19
|
+
import 'node:readline';
|
|
20
|
+
import 'node:fs/promises';
|
|
21
|
+
import 'node:util';
|
|
22
|
+
import 'yaml';
|
|
23
|
+
|
|
24
|
+
function computeCollectionConfigUpdate(existingConfig, extra) {
|
|
25
|
+
const cfg = existingConfig || {};
|
|
26
|
+
const changed = Object.entries(extra).some(([k, v]) => JSON.stringify(cfg[k]) !== JSON.stringify(v));
|
|
27
|
+
return { changed, merged: { ...cfg, ...extra } };
|
|
28
|
+
}
|
|
29
|
+
function loadEnv() {
|
|
30
|
+
const SVAMP_HOME = process.env.SVAMP_HOME || join(os.homedir(), ".svamp");
|
|
31
|
+
for (const f of [join(SVAMP_HOME, ".env"), join(os.homedir(), ".hypha", ".env")]) {
|
|
32
|
+
if (!existsSync(f)) continue;
|
|
33
|
+
try {
|
|
34
|
+
for (const line of readFileSync(f, "utf-8").split("\n")) {
|
|
35
|
+
const m = line.match(/^\s*([A-Za-z0-9_]+)\s*=\s*(.*)\s*$/);
|
|
36
|
+
if (m && process.env[m[1]] === void 0) process.env[m[1]] = m[2].replace(/^["']|["']$/g, "");
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
async function setCollectionConfig(alias, configJson) {
|
|
43
|
+
if (!alias || !configJson) {
|
|
44
|
+
console.error("Usage: svamp admin set-collection-config <alias> --config '<json>'");
|
|
45
|
+
console.error(` e.g. svamp admin set-collection-config svamp-user-events --config '{"private_children":true,"recipient_field":"recipientEmail"}'`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
let extra;
|
|
49
|
+
try {
|
|
50
|
+
extra = JSON.parse(configJson);
|
|
51
|
+
if (!extra || typeof extra !== "object" || Array.isArray(extra)) throw new Error("config must be a JSON object");
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error(`--config must be a JSON object: ${e.message}`);
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
loadEnv();
|
|
57
|
+
const serverUrl = process.env.HYPHA_SERVER_URL;
|
|
58
|
+
const token = process.env.HYPHA_TOKEN;
|
|
59
|
+
if (!serverUrl || !token) {
|
|
60
|
+
console.error('Not logged in. Run "svamp login <url>" first.');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
let server;
|
|
64
|
+
try {
|
|
65
|
+
server = await connectToHypha({ serverUrl, token, name: "svamp-admin-cli" });
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error(`Failed to connect to Hypha: ${e.message}`);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const am = await server.getService("public/artifact-manager");
|
|
72
|
+
if (!am) {
|
|
73
|
+
console.error("Artifact manager not available.");
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
let col;
|
|
77
|
+
try {
|
|
78
|
+
col = await am.read({ artifact_id: alias, _rkwargs: true });
|
|
79
|
+
} catch (e) {
|
|
80
|
+
console.error(`Collection "${alias}" not found (or not readable): ${e.message}`);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
const { changed, merged } = computeCollectionConfigUpdate(col.config, extra);
|
|
84
|
+
if (!changed) {
|
|
85
|
+
console.log(`${alias}: config already up to date (no change).`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
await am.edit({ artifact_id: col.id, config: merged, _rkwargs: true });
|
|
90
|
+
await am.commit({ artifact_id: col.id, _rkwargs: true }).catch(() => {
|
|
91
|
+
});
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error(`Failed to set config on "${alias}" (need owner/admin/root rights): ${e.message}`);
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
console.log(`\u2713 ${alias}: merged {${Object.keys(extra).join(", ")}} into config (existing keys preserved).`);
|
|
97
|
+
} finally {
|
|
98
|
+
try {
|
|
99
|
+
await server.disconnect?.();
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export { computeCollectionConfigUpdate, setCollectionConfig };
|
|
@@ -387,7 +387,7 @@ async function main() {
|
|
|
387
387
|
}), machineId);
|
|
388
388
|
process.exit(0);
|
|
389
389
|
} else if (subcommand === "issue" || subcommand === "issues") {
|
|
390
|
-
const { issueCommand } = await import('./commands-
|
|
390
|
+
const { issueCommand } = await import('./commands-DVQTULwh.mjs');
|
|
391
391
|
await issueCommand(args.slice(1));
|
|
392
392
|
await flushAndExit(0);
|
|
393
393
|
} else if (subcommand === "workflow" || subcommand === "workflows") {
|
|
@@ -416,6 +416,22 @@ async function main() {
|
|
|
416
416
|
}
|
|
417
417
|
await notifyUser(email, o);
|
|
418
418
|
process.exit(0);
|
|
419
|
+
} else if (subcommand === "admin") {
|
|
420
|
+
const adminSub = args[1];
|
|
421
|
+
if (adminSub === "set-collection-config") {
|
|
422
|
+
const { setCollectionConfig } = await import('./adminCommands-7A_djft2.mjs');
|
|
423
|
+
const rest = args.slice(2);
|
|
424
|
+
let alias;
|
|
425
|
+
let configJson;
|
|
426
|
+
for (let i = 0; i < rest.length; i++) {
|
|
427
|
+
if (rest[i] === "--config" && i + 1 < rest.length) configJson = rest[++i];
|
|
428
|
+
else if (!rest[i].startsWith("-") && !alias) alias = rest[i];
|
|
429
|
+
}
|
|
430
|
+
await setCollectionConfig(alias, configJson);
|
|
431
|
+
} else {
|
|
432
|
+
console.error("Usage: svamp admin set-collection-config <alias> --config '<json>'");
|
|
433
|
+
}
|
|
434
|
+
process.exit(0);
|
|
419
435
|
} else if (subcommand === "events") {
|
|
420
436
|
const { listEvents, ackEvent } = await import('./notifyCommands-Db7qJUME.mjs');
|
|
421
437
|
const sub = args[1];
|
|
@@ -438,7 +454,7 @@ async function main() {
|
|
|
438
454
|
} else if (!subcommand || subcommand === "start") {
|
|
439
455
|
await handleInteractiveCommand();
|
|
440
456
|
} else if (subcommand === "--version" || subcommand === "-v") {
|
|
441
|
-
const pkg = await import('./package-
|
|
457
|
+
const pkg = await import('./package-Cuybud2_.mjs').catch(() => ({ default: { version: "unknown" } }));
|
|
442
458
|
console.log(`svamp version: ${pkg.default.version}`);
|
|
443
459
|
} else {
|
|
444
460
|
console.error(`Unknown command: ${subcommand}`);
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
import { existsSync, readFileSync } from 'node:fs';
|
|
3
3
|
import { join } from 'node:path';
|
|
4
|
-
import { f as flushAndExit } from './cli-
|
|
4
|
+
import { f as flushAndExit } from './cli-DqFchp_7.mjs';
|
|
5
5
|
import { j as resolveProjectRoot, q as searchIssues, o as listIssues, l as resumeIssue, p as pauseIssue, m as addComment, u as updateIssue, k as getIssue, t as isVisibleTo, H as summarize, n as addIssue } from './run-CumVWywx.mjs';
|
|
6
6
|
import './serviceManager-hlOVxkhW.mjs';
|
|
7
7
|
import 'os';
|