@engini/cli 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +478 -17
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -386,6 +386,8 @@ import {
|
|
|
386
386
|
EnginiError,
|
|
387
387
|
EnginiMcpServerNotFoundError,
|
|
388
388
|
EnginiNotFoundError,
|
|
389
|
+
EnginiOpaAgentTimeoutError,
|
|
390
|
+
EnginiOpaApplicationAmbiguousError,
|
|
389
391
|
EnginiTimeoutError,
|
|
390
392
|
EnginiToolsetNotFoundError,
|
|
391
393
|
EnginiValidationError
|
|
@@ -439,7 +441,7 @@ function saveConfig(config, path = configPath()) {
|
|
|
439
441
|
}
|
|
440
442
|
|
|
441
443
|
// src/version.ts
|
|
442
|
-
var VERSION = true ? "0.
|
|
444
|
+
var VERSION = true ? "0.19.0" : "0.0.0";
|
|
443
445
|
|
|
444
446
|
// src/http.ts
|
|
445
447
|
var USER_AGENT_PREFIX = `engini-cli/${VERSION}`;
|
|
@@ -463,6 +465,8 @@ function buildClient(overrides = {}) {
|
|
|
463
465
|
}
|
|
464
466
|
function exitForError(err) {
|
|
465
467
|
if (err instanceof EnginiAuthError) return 3 /* AUTH */;
|
|
468
|
+
if (err instanceof EnginiOpaApplicationAmbiguousError) return 5 /* VALIDATION */;
|
|
469
|
+
if (err instanceof EnginiOpaAgentTimeoutError) return 124 /* TIMEOUT */;
|
|
466
470
|
if (err instanceof EnginiToolsetNotFoundError) return 4 /* NOT_FOUND */;
|
|
467
471
|
if (err instanceof EnginiMcpServerNotFoundError) return 4 /* NOT_FOUND */;
|
|
468
472
|
if (err instanceof EnginiNotFoundError) return 4 /* NOT_FOUND */;
|
|
@@ -1534,8 +1538,9 @@ CONNECTIONS
|
|
|
1534
1538
|
--connection <id> (object selection). No app \u2192 web page.
|
|
1535
1539
|
connections list [--application <slug>] [--kind <kind>]
|
|
1536
1540
|
List your connections. --kind filters on
|
|
1537
|
-
Regular | Key |
|
|
1538
|
-
"Keys" tab is --kind Key.
|
|
1541
|
+
Regular | Key | MCPClient. The web UI's
|
|
1542
|
+
"Keys" tab is --kind Key. On-premise agents are
|
|
1543
|
+
not connections - see ON-PREMISE AGENTS.
|
|
1539
1544
|
connections get <id> Inspect a connection.
|
|
1540
1545
|
connections create <app> --auth <id> --name <n> --field k=v
|
|
1541
1546
|
Create a direct-credential connection.
|
|
@@ -1590,6 +1595,22 @@ MCP SERVERS
|
|
|
1590
1595
|
Note: the server token is part of the server's SSE URL \u2014 treat it as a secret.
|
|
1591
1596
|
--dry-run previews every mutating command's resulting set before you commit to it.
|
|
1592
1597
|
|
|
1598
|
+
ON-PREMISE AGENTS
|
|
1599
|
+
The Engini component a customer installs behind their firewall to reach SQL Server,
|
|
1600
|
+
Oracle, Priority ERP and file shares. Not connections: connections list never shows them.
|
|
1601
|
+
opa list [--status <s>] [--name <substr>] List the account's on-premise agents.
|
|
1602
|
+
opa get <id> Status, version, last heartbeat, settings.
|
|
1603
|
+
opa create --name <n> [...] Register an agent. PRINTS ITS TOKEN.
|
|
1604
|
+
opa update <id> [...] Change name/description/settings (merges).
|
|
1605
|
+
opa delete <id> [--force] Permanently delete an agent.
|
|
1606
|
+
opa enable <id> | opa disable <id> Toggle whether the agent is marked online.
|
|
1607
|
+
opa token get <id> Read the agent's token (a credential).
|
|
1608
|
+
opa token rotate <id> [--force] New token; the running agent stops until reconfigured.
|
|
1609
|
+
opa logs <id> -o <file> Collect the agent's logs as a zip (agent must be Online).
|
|
1610
|
+
opa download [-o <file>] [--json] Fetch the current installer; --json prints the manifest.
|
|
1611
|
+
Note: an agent polls Engini, so anything that "talks to" it waits for its next poll.
|
|
1612
|
+
A settings update on an offline agent still stores - the response says applied_to_agent: false.
|
|
1613
|
+
|
|
1593
1614
|
OUTPUT & EXIT CODES
|
|
1594
1615
|
Output adapts to context: human-readable on a TTY, compact JSON when piped, pretty
|
|
1595
1616
|
JSON with --json. Universal flags on every command:
|
|
@@ -2370,6 +2391,445 @@ function registerMcp(program) {
|
|
|
2370
2391
|
registerMcpWorkflows(mcp);
|
|
2371
2392
|
}
|
|
2372
2393
|
|
|
2394
|
+
// src/opa/shared.ts
|
|
2395
|
+
function parseAgentId(raw) {
|
|
2396
|
+
if (raw === void 0 || raw === "") fail(2 /* USAGE */, "An agent id is required.");
|
|
2397
|
+
if (!/^[1-9]\d*$/.test(raw)) {
|
|
2398
|
+
fail(2 /* USAGE */, `'${raw}' is not a valid agent id (expected a positive integer).`);
|
|
2399
|
+
}
|
|
2400
|
+
return Number(raw);
|
|
2401
|
+
}
|
|
2402
|
+
function summarizeAgent(agent) {
|
|
2403
|
+
return {
|
|
2404
|
+
agent_id: agent.agentId,
|
|
2405
|
+
name: clean(agent.name),
|
|
2406
|
+
status: agent.status,
|
|
2407
|
+
version: clean(agent.version),
|
|
2408
|
+
last_seen_at: clean(agent.lastSeenAt)
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2411
|
+
function renderSettings(settings) {
|
|
2412
|
+
return {
|
|
2413
|
+
parallel_tasks: clean(settings?.parallelTasks),
|
|
2414
|
+
pull_period_seconds: clean(settings?.pullPeriodSeconds),
|
|
2415
|
+
log_level: clean(settings?.logLevel)
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
function parseSettingsFlags(flags) {
|
|
2419
|
+
const integer = (raw, flag) => {
|
|
2420
|
+
if (raw === void 0) return void 0;
|
|
2421
|
+
if (!/^\d+$/.test(raw)) {
|
|
2422
|
+
fail(2 /* USAGE */, `${flag} must be a non-negative integer, got '${raw}'.`);
|
|
2423
|
+
}
|
|
2424
|
+
return Number(raw);
|
|
2425
|
+
};
|
|
2426
|
+
const out = {};
|
|
2427
|
+
const parallelTasks = integer(flags.parallelTasks, "--parallel-tasks");
|
|
2428
|
+
const pullPeriodSeconds = integer(flags.pullPeriod, "--pull-period");
|
|
2429
|
+
if (parallelTasks !== void 0) out.parallelTasks = parallelTasks;
|
|
2430
|
+
if (pullPeriodSeconds !== void 0) out.pullPeriodSeconds = pullPeriodSeconds;
|
|
2431
|
+
if (flags.logLevel !== void 0) out.logLevel = flags.logLevel;
|
|
2432
|
+
return out;
|
|
2433
|
+
}
|
|
2434
|
+
function settingsPreview(settings) {
|
|
2435
|
+
return Object.keys(settings).length === 0 ? void 0 : { ...settings };
|
|
2436
|
+
}
|
|
2437
|
+
function addSettingsOptions(cmd) {
|
|
2438
|
+
return cmd.option(
|
|
2439
|
+
"--parallel-tasks <n>",
|
|
2440
|
+
"Concurrent tasks the agent runs (server-declared range, currently 1-100)"
|
|
2441
|
+
).option(
|
|
2442
|
+
"--pull-period <seconds>",
|
|
2443
|
+
"Seconds between task polls (server-declared minimum, currently 10)"
|
|
2444
|
+
).option("--log-level <level>", "Agent log level, e.g. Information, Debug");
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
// src/opa/create.ts
|
|
2448
|
+
async function createBody2(opts) {
|
|
2449
|
+
if (opts.name === void 0 || opts.name.trim() === "") fail(2 /* USAGE */, "--name is required.");
|
|
2450
|
+
const settings = parseSettingsFlags(opts);
|
|
2451
|
+
const preview = settingsPreview(settings);
|
|
2452
|
+
if (dryRun()) {
|
|
2453
|
+
printOutput({
|
|
2454
|
+
would_create: {
|
|
2455
|
+
name: opts.name,
|
|
2456
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
2457
|
+
...opts.applicationSlug !== void 0 ? { applicationSlug: opts.applicationSlug } : {},
|
|
2458
|
+
...preview ? { settings: preview } : {}
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
return;
|
|
2462
|
+
}
|
|
2463
|
+
const agent = await apiErrors(
|
|
2464
|
+
async () => buildClient().opa.create({
|
|
2465
|
+
name: opts.name,
|
|
2466
|
+
description: opts.description,
|
|
2467
|
+
applicationSlug: opts.applicationSlug,
|
|
2468
|
+
...settings
|
|
2469
|
+
})
|
|
2470
|
+
);
|
|
2471
|
+
printOutput({
|
|
2472
|
+
...summarizeAgent(agent),
|
|
2473
|
+
settings: renderSettings(agent.settings),
|
|
2474
|
+
token: agent.token
|
|
2475
|
+
});
|
|
2476
|
+
}
|
|
2477
|
+
function registerOpaCreate(opa) {
|
|
2478
|
+
const cmd = opa.command("create").description(
|
|
2479
|
+
"Register a new on-premise agent. Prints its token - treat the output as a secret."
|
|
2480
|
+
).option("--name <name>", "Display name (required)").option("--description <text>", "Optional description").option(
|
|
2481
|
+
"--application-slug <slug>",
|
|
2482
|
+
"Only when more than one agent application exists; the 409 lists the candidates"
|
|
2483
|
+
);
|
|
2484
|
+
addSettingsOptions(cmd);
|
|
2485
|
+
cmd.addHelpText(
|
|
2486
|
+
"after",
|
|
2487
|
+
'\nExamples:\n engini opa create --name "Warehouse SQL" --json\n engini opa create --name Backoffice --pull-period 30 --log-level Debug\n engini opa create --name Backoffice --dry-run'
|
|
2488
|
+
);
|
|
2489
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2490
|
+
cmd.action(async (opts, command) => {
|
|
2491
|
+
await runCommand(command, opts, true, () => createBody2(opts));
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
// src/opa/delete.ts
|
|
2496
|
+
async function deleteBody2(raw, opts) {
|
|
2497
|
+
const agentId = parseAgentId(raw);
|
|
2498
|
+
if (dryRun()) {
|
|
2499
|
+
printOutput({ would_delete: agentId });
|
|
2500
|
+
return;
|
|
2501
|
+
}
|
|
2502
|
+
await confirmOrFail(
|
|
2503
|
+
`Delete on-premise agent ${agentId}? Workflows routed through it will stop working.`,
|
|
2504
|
+
{ force: Boolean(opts.force) }
|
|
2505
|
+
);
|
|
2506
|
+
await apiErrors(async () => buildClient().opa.delete(agentId));
|
|
2507
|
+
printOutput({ deleted: agentId });
|
|
2508
|
+
}
|
|
2509
|
+
function registerOpaDelete(opa) {
|
|
2510
|
+
const cmd = opa.command("delete").description("Permanently delete an on-premise agent.").argument("[agent_id]", "Agent id").option("--force", "Delete without confirming");
|
|
2511
|
+
cmd.addHelpText("after", "\nExamples:\n engini opa delete 41 --force");
|
|
2512
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2513
|
+
cmd.action(async (raw, opts, command) => {
|
|
2514
|
+
await runCommand(
|
|
2515
|
+
command,
|
|
2516
|
+
opts,
|
|
2517
|
+
true,
|
|
2518
|
+
() => deleteBody2(raw, opts)
|
|
2519
|
+
);
|
|
2520
|
+
});
|
|
2521
|
+
}
|
|
2522
|
+
|
|
2523
|
+
// src/opa/download.ts
|
|
2524
|
+
import { createHash } from "crypto";
|
|
2525
|
+
import { writeFile } from "fs/promises";
|
|
2526
|
+
import { basename } from "path";
|
|
2527
|
+
function targetFromManifest(url) {
|
|
2528
|
+
let name;
|
|
2529
|
+
try {
|
|
2530
|
+
name = basename(new URL(url).pathname);
|
|
2531
|
+
} catch {
|
|
2532
|
+
fail(1 /* GENERIC */, `The release manifest carries an unusable installer URL: ${url}`);
|
|
2533
|
+
}
|
|
2534
|
+
if (name === "" || name === "." || name === ".." || name.includes("/") || name.includes("\\")) {
|
|
2535
|
+
fail(
|
|
2536
|
+
1 /* GENERIC */,
|
|
2537
|
+
`Cannot derive a filename from the manifest URL (${url}). Pass -o <file>.`
|
|
2538
|
+
);
|
|
2539
|
+
}
|
|
2540
|
+
return name;
|
|
2541
|
+
}
|
|
2542
|
+
async function downloadBody(opts) {
|
|
2543
|
+
const manifest = await apiErrors(async () => buildClient().opa.latestRelease());
|
|
2544
|
+
if (outputFlags().forceJson && opts.out === void 0) {
|
|
2545
|
+
printOutput(manifest);
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
const target = opts.out ?? targetFromManifest(manifest.url);
|
|
2549
|
+
if (dryRun()) {
|
|
2550
|
+
printOutput({
|
|
2551
|
+
would_write: target,
|
|
2552
|
+
version: manifest.version,
|
|
2553
|
+
url: manifest.url,
|
|
2554
|
+
degraded: manifest.degraded
|
|
2555
|
+
});
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
const response = await fetch(manifest.url);
|
|
2559
|
+
if (!response.ok) {
|
|
2560
|
+
fail(
|
|
2561
|
+
1 /* GENERIC */,
|
|
2562
|
+
`Installer download failed: HTTP ${response.status} from ${manifest.url}`
|
|
2563
|
+
);
|
|
2564
|
+
}
|
|
2565
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
2566
|
+
let verified;
|
|
2567
|
+
if (manifest.sha256) {
|
|
2568
|
+
const actual = createHash("sha256").update(bytes).digest("hex");
|
|
2569
|
+
if (actual !== manifest.sha256.toLowerCase()) {
|
|
2570
|
+
fail(
|
|
2571
|
+
5 /* VALIDATION */,
|
|
2572
|
+
`sha256 mismatch: the manifest says ${manifest.sha256}, the download is ${actual}. Nothing written.`
|
|
2573
|
+
);
|
|
2574
|
+
}
|
|
2575
|
+
verified = true;
|
|
2576
|
+
} else {
|
|
2577
|
+
verified = false;
|
|
2578
|
+
}
|
|
2579
|
+
await writeFile(target, bytes);
|
|
2580
|
+
printOutput({
|
|
2581
|
+
wrote: target,
|
|
2582
|
+
bytes: bytes.length,
|
|
2583
|
+
version: manifest.version,
|
|
2584
|
+
verified,
|
|
2585
|
+
degraded: manifest.degraded
|
|
2586
|
+
});
|
|
2587
|
+
}
|
|
2588
|
+
function registerOpaDownload(opa) {
|
|
2589
|
+
const cmd = opa.command("download").description("Download the current on-premise agent installer.").option(
|
|
2590
|
+
"-o, --out <file>",
|
|
2591
|
+
"Where to write the installer (default: the manifest's filename, in the current directory)"
|
|
2592
|
+
);
|
|
2593
|
+
cmd.addHelpText(
|
|
2594
|
+
"after",
|
|
2595
|
+
"\nExamples:\n engini opa download # writes EnginiAgent-<version>.exe here\n engini opa download -o ./agent.exe\n engini opa download --json # print the manifest, download nothing\n engini opa download --dry-run # show where it would land"
|
|
2596
|
+
);
|
|
2597
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2598
|
+
cmd.action(async (opts, command) => {
|
|
2599
|
+
await runCommand(command, opts, true, () => downloadBody(opts));
|
|
2600
|
+
});
|
|
2601
|
+
}
|
|
2602
|
+
|
|
2603
|
+
// src/opa/get.ts
|
|
2604
|
+
async function getBody4(raw) {
|
|
2605
|
+
const agentId = parseAgentId(raw);
|
|
2606
|
+
const agent = await apiErrors(async () => buildClient().opa.get(agentId));
|
|
2607
|
+
printOutput({
|
|
2608
|
+
...summarizeAgent(agent),
|
|
2609
|
+
description: clean(agent.description),
|
|
2610
|
+
settings: renderSettings(agent.settings),
|
|
2611
|
+
created_date: clean(agent.createdDate),
|
|
2612
|
+
updated_date: clean(agent.updatedDate)
|
|
2613
|
+
});
|
|
2614
|
+
}
|
|
2615
|
+
function registerOpaGet(opa) {
|
|
2616
|
+
const cmd = opa.command("get").description("Show full detail for one on-premise agent.").argument("[agent_id]", "Agent id");
|
|
2617
|
+
cmd.addHelpText("after", "\nExamples:\n engini opa get 41 --json");
|
|
2618
|
+
addUniversalOptions(cmd);
|
|
2619
|
+
cmd.action(async (raw, opts, command) => {
|
|
2620
|
+
await runCommand(command, opts, false, () => getBody4(raw));
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
// src/opa/list.ts
|
|
2625
|
+
async function listBody6(opts) {
|
|
2626
|
+
const agents = await apiErrors(
|
|
2627
|
+
async () => buildClient().opa.list({ status: opts.status, name: opts.name })
|
|
2628
|
+
);
|
|
2629
|
+
printOutput(agents.map(summarizeAgent));
|
|
2630
|
+
}
|
|
2631
|
+
function registerOpaList(opa) {
|
|
2632
|
+
const cmd = opa.command("list").description("List the account's on-premise agents.").option(
|
|
2633
|
+
"--status <status>",
|
|
2634
|
+
"Filter: WaitingForConnection | Online | Offline | Disabled (case-insensitive)"
|
|
2635
|
+
).option("--name <substring>", "Filter by name substring");
|
|
2636
|
+
cmd.addHelpText(
|
|
2637
|
+
"after",
|
|
2638
|
+
"\nExamples:\n engini opa list\n engini opa list --status offline --json"
|
|
2639
|
+
);
|
|
2640
|
+
addUniversalOptions(cmd);
|
|
2641
|
+
cmd.action(async (opts, command) => {
|
|
2642
|
+
await runCommand(command, opts, false, () => listBody6(opts));
|
|
2643
|
+
});
|
|
2644
|
+
}
|
|
2645
|
+
|
|
2646
|
+
// src/opa/logs.ts
|
|
2647
|
+
import { writeFile as writeFile2 } from "fs/promises";
|
|
2648
|
+
async function logsBody(raw, opts) {
|
|
2649
|
+
const agentId = parseAgentId(raw);
|
|
2650
|
+
if (opts.out === void 0 || opts.out === "") {
|
|
2651
|
+
fail(2 /* USAGE */, "-o <file> is required: where to write the log archive.");
|
|
2652
|
+
}
|
|
2653
|
+
if (dryRun()) {
|
|
2654
|
+
printOutput({ would_write: opts.out, agent_id: agentId });
|
|
2655
|
+
return;
|
|
2656
|
+
}
|
|
2657
|
+
const bytes = await apiErrors(async () => buildClient().opa.downloadLogs(agentId));
|
|
2658
|
+
await writeFile2(opts.out, bytes);
|
|
2659
|
+
printOutput({ wrote: opts.out, bytes: bytes.length, agent_id: agentId });
|
|
2660
|
+
}
|
|
2661
|
+
function registerOpaLogs(opa) {
|
|
2662
|
+
const cmd = opa.command("logs").description("Collect an agent's logs as a zip archive. The agent must be Online.").argument("[agent_id]", "Agent id").option("-o, --out <file>", "Where to write the archive (required)");
|
|
2663
|
+
cmd.addHelpText(
|
|
2664
|
+
"after",
|
|
2665
|
+
"\nExamples:\n engini opa logs 41 -o ./opa-41-logs.zip\n engini opa logs 41 -o ./opa-41-logs.zip --json"
|
|
2666
|
+
);
|
|
2667
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2668
|
+
cmd.action(async (raw, opts, command) => {
|
|
2669
|
+
await runCommand(
|
|
2670
|
+
command,
|
|
2671
|
+
opts,
|
|
2672
|
+
true,
|
|
2673
|
+
() => logsBody(raw, opts)
|
|
2674
|
+
);
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
// src/opa/status.ts
|
|
2679
|
+
async function toggleBody(raw, enabled) {
|
|
2680
|
+
const agentId = parseAgentId(raw);
|
|
2681
|
+
if (dryRun()) {
|
|
2682
|
+
printOutput(enabled ? { would_enable: agentId } : { would_disable: agentId });
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2685
|
+
const agent = await apiErrors(async () => {
|
|
2686
|
+
const client = buildClient();
|
|
2687
|
+
return enabled ? client.opa.enable(agentId) : client.opa.disable(agentId);
|
|
2688
|
+
});
|
|
2689
|
+
printOutput(summarizeAgent(agent));
|
|
2690
|
+
}
|
|
2691
|
+
function register2(opa, name, description) {
|
|
2692
|
+
const cmd = opa.command(name).description(description).argument("[agent_id]", "Agent id");
|
|
2693
|
+
cmd.addHelpText("after", `
|
|
2694
|
+
Examples:
|
|
2695
|
+
engini opa ${name} 41`);
|
|
2696
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2697
|
+
cmd.action(async (raw, opts, command) => {
|
|
2698
|
+
await runCommand(command, opts, true, () => toggleBody(raw, name === "enable"));
|
|
2699
|
+
});
|
|
2700
|
+
}
|
|
2701
|
+
function registerOpaEnable(opa) {
|
|
2702
|
+
register2(
|
|
2703
|
+
opa,
|
|
2704
|
+
"enable",
|
|
2705
|
+
"Re-enable a disabled agent; it returns to WaitingForConnection. A no-op if it is not disabled."
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
function registerOpaDisable(opa) {
|
|
2709
|
+
register2(
|
|
2710
|
+
opa,
|
|
2711
|
+
"disable",
|
|
2712
|
+
"Stop an agent being marked online. Tasks it already holds still complete."
|
|
2713
|
+
);
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
// src/opa/token.ts
|
|
2717
|
+
async function getBody5(raw) {
|
|
2718
|
+
const agentId = parseAgentId(raw);
|
|
2719
|
+
const token = await apiErrors(async () => buildClient().opa.getToken(agentId));
|
|
2720
|
+
printOutput({ agent_id: token.agentId, token: token.token });
|
|
2721
|
+
}
|
|
2722
|
+
async function rotateBody(raw, opts) {
|
|
2723
|
+
const agentId = parseAgentId(raw);
|
|
2724
|
+
if (dryRun()) {
|
|
2725
|
+
printOutput({ would_rotate_token_for: agentId });
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
await confirmOrFail(
|
|
2729
|
+
`Rotate the token for on-premise agent ${agentId}? The running agent stops authenticating immediately and stays down until it is reconfigured with the new token.`,
|
|
2730
|
+
{ force: Boolean(opts.force) }
|
|
2731
|
+
);
|
|
2732
|
+
const token = await apiErrors(async () => buildClient().opa.rotateToken(agentId));
|
|
2733
|
+
printOutput({
|
|
2734
|
+
agent_id: token.agentId,
|
|
2735
|
+
token: token.token,
|
|
2736
|
+
note: "Reconfigure the agent with this token; the previous one no longer works."
|
|
2737
|
+
});
|
|
2738
|
+
}
|
|
2739
|
+
function registerOpaToken(opa) {
|
|
2740
|
+
const token = opa.command("token").description("Read or rotate an agent's token (a live credential).");
|
|
2741
|
+
const get = token.command("get").description("Print the agent's current token.").argument("[agent_id]", "Agent id");
|
|
2742
|
+
get.addHelpText("after", "\nExamples:\n engini opa token get 41 --json");
|
|
2743
|
+
addUniversalOptions(get);
|
|
2744
|
+
get.action(async (raw, opts, command) => {
|
|
2745
|
+
await runCommand(command, opts, false, () => getBody5(raw));
|
|
2746
|
+
});
|
|
2747
|
+
const rotate = token.command("rotate").description(
|
|
2748
|
+
"Issue a new token, invalidating the current one. Stops the running agent until it is reconfigured."
|
|
2749
|
+
).argument("[agent_id]", "Agent id").option("--force", "Rotate without confirming");
|
|
2750
|
+
rotate.addHelpText("after", "\nExamples:\n engini opa token rotate 41 --force --json");
|
|
2751
|
+
addUniversalOptions(rotate, { mutating: true });
|
|
2752
|
+
rotate.action(
|
|
2753
|
+
async (raw, opts, command) => {
|
|
2754
|
+
await runCommand(
|
|
2755
|
+
command,
|
|
2756
|
+
opts,
|
|
2757
|
+
true,
|
|
2758
|
+
() => rotateBody(raw, opts)
|
|
2759
|
+
);
|
|
2760
|
+
}
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
|
|
2764
|
+
// src/opa/update.ts
|
|
2765
|
+
async function updateBody2(raw, opts) {
|
|
2766
|
+
const agentId = parseAgentId(raw);
|
|
2767
|
+
const settings = parseSettingsFlags(opts);
|
|
2768
|
+
const preview = settingsPreview(settings);
|
|
2769
|
+
const changes = {
|
|
2770
|
+
...opts.name !== void 0 ? { name: opts.name } : {},
|
|
2771
|
+
...opts.description !== void 0 ? { description: opts.description } : {},
|
|
2772
|
+
...preview ? { settings: preview } : {}
|
|
2773
|
+
};
|
|
2774
|
+
if (Object.keys(changes).length === 0) {
|
|
2775
|
+
fail(
|
|
2776
|
+
2 /* USAGE */,
|
|
2777
|
+
"Nothing to update - pass at least one of --name, --description, --parallel-tasks, --pull-period, --log-level."
|
|
2778
|
+
);
|
|
2779
|
+
}
|
|
2780
|
+
if (dryRun()) {
|
|
2781
|
+
printOutput({ would_update: agentId, changes });
|
|
2782
|
+
return;
|
|
2783
|
+
}
|
|
2784
|
+
const agent = await apiErrors(
|
|
2785
|
+
async () => buildClient().opa.update(agentId, {
|
|
2786
|
+
name: opts.name,
|
|
2787
|
+
description: opts.description,
|
|
2788
|
+
...settings
|
|
2789
|
+
})
|
|
2790
|
+
);
|
|
2791
|
+
printOutput({
|
|
2792
|
+
...summarizeAgent(agent),
|
|
2793
|
+
settings: renderSettings(agent.settings),
|
|
2794
|
+
applied_to_agent: clean(agent.appliedToAgent),
|
|
2795
|
+
dispatched_task_ids: agent.dispatchedTaskIds ?? []
|
|
2796
|
+
});
|
|
2797
|
+
}
|
|
2798
|
+
function registerOpaUpdate(opa) {
|
|
2799
|
+
const cmd = opa.command("update").description(
|
|
2800
|
+
"Change an agent's name, description or settings. Merges - omitted flags leave the field alone."
|
|
2801
|
+
).argument("[agent_id]", "Agent id").option("--name <name>", "New display name").option("--description <text>", "New description");
|
|
2802
|
+
addSettingsOptions(cmd);
|
|
2803
|
+
cmd.addHelpText(
|
|
2804
|
+
"after",
|
|
2805
|
+
"\nExamples:\n engini opa update 41 --log-level Debug\n engini opa update 41 --parallel-tasks 8 --pull-period 15 --json\n engini opa update 41 --log-level Debug --dry-run"
|
|
2806
|
+
);
|
|
2807
|
+
addUniversalOptions(cmd, { mutating: true });
|
|
2808
|
+
cmd.action(async (raw, opts, command) => {
|
|
2809
|
+
await runCommand(
|
|
2810
|
+
command,
|
|
2811
|
+
opts,
|
|
2812
|
+
true,
|
|
2813
|
+
() => updateBody2(raw, opts)
|
|
2814
|
+
);
|
|
2815
|
+
});
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
// src/opa/index.ts
|
|
2819
|
+
function registerOpa(program) {
|
|
2820
|
+
const opa = program.command("opa").description("Provision, inspect, configure and credential on-premise agents.");
|
|
2821
|
+
registerOpaList(opa);
|
|
2822
|
+
registerOpaGet(opa);
|
|
2823
|
+
registerOpaCreate(opa);
|
|
2824
|
+
registerOpaUpdate(opa);
|
|
2825
|
+
registerOpaDelete(opa);
|
|
2826
|
+
registerOpaEnable(opa);
|
|
2827
|
+
registerOpaDisable(opa);
|
|
2828
|
+
registerOpaToken(opa);
|
|
2829
|
+
registerOpaLogs(opa);
|
|
2830
|
+
registerOpaDownload(opa);
|
|
2831
|
+
}
|
|
2832
|
+
|
|
2373
2833
|
// src/tools/call.ts
|
|
2374
2834
|
import { readFileSync as readFileSync4 } from "fs";
|
|
2375
2835
|
import {
|
|
@@ -2792,7 +3252,7 @@ function detail3(schema) {
|
|
|
2792
3252
|
max_sorts: clean(schema.maxSorts)
|
|
2793
3253
|
};
|
|
2794
3254
|
}
|
|
2795
|
-
async function
|
|
3255
|
+
async function getBody6(toolId) {
|
|
2796
3256
|
if (!toolId) {
|
|
2797
3257
|
fail(2 /* USAGE */, "Missing required argument 'tool_id'.");
|
|
2798
3258
|
}
|
|
@@ -2806,7 +3266,7 @@ function registerToolsGet(tools) {
|
|
|
2806
3266
|
const cmd = tools.command("get").description("Show full canonical detail for one tool.").argument("[tool_id]", "Tool slug");
|
|
2807
3267
|
addUniversalOptions(cmd);
|
|
2808
3268
|
cmd.action(async (toolId, opts, command) => {
|
|
2809
|
-
await runCommand(command, opts, false, () =>
|
|
3269
|
+
await runCommand(command, opts, false, () => getBody6(toolId));
|
|
2810
3270
|
});
|
|
2811
3271
|
}
|
|
2812
3272
|
|
|
@@ -2829,7 +3289,7 @@ function parseLimit2(value) {
|
|
|
2829
3289
|
}
|
|
2830
3290
|
return limit;
|
|
2831
3291
|
}
|
|
2832
|
-
async function
|
|
3292
|
+
async function listBody7(opts) {
|
|
2833
3293
|
if (opts.application && opts.toolset) {
|
|
2834
3294
|
fail(2 /* USAGE */, "Pass only one of --application / --toolset.");
|
|
2835
3295
|
}
|
|
@@ -2852,7 +3312,7 @@ function registerToolsList(tools) {
|
|
|
2852
3312
|
const cmd = tools.command("list").description("List available tools, optionally filtered.").option("--application <slug>", "Filter by application slug (e.g. monday)").option("--toolset <id>", "List the tools of a server toolset (by id)").option("--limit <n>", "Cap the number of tools returned");
|
|
2853
3313
|
addUniversalOptions(cmd);
|
|
2854
3314
|
cmd.action(async (opts, command) => {
|
|
2855
|
-
await runCommand(command, opts, false, () =>
|
|
3315
|
+
await runCommand(command, opts, false, () => listBody7(opts));
|
|
2856
3316
|
});
|
|
2857
3317
|
}
|
|
2858
3318
|
|
|
@@ -3043,7 +3503,7 @@ function buildRequestBody(opts) {
|
|
|
3043
3503
|
workflows: workflowsFromFlagsOrUndefined(opts.workflow)
|
|
3044
3504
|
};
|
|
3045
3505
|
}
|
|
3046
|
-
async function
|
|
3506
|
+
async function createBody3(opts) {
|
|
3047
3507
|
const body = buildRequestBody(opts);
|
|
3048
3508
|
if (dryRun()) {
|
|
3049
3509
|
printOutput({
|
|
@@ -3077,12 +3537,12 @@ function registerToolsetsCreate(toolsets) {
|
|
|
3077
3537
|
);
|
|
3078
3538
|
addUniversalOptions(cmd, { mutating: true });
|
|
3079
3539
|
cmd.action(async (opts, command) => {
|
|
3080
|
-
await runCommand(command, opts, true, () =>
|
|
3540
|
+
await runCommand(command, opts, true, () => createBody3(opts));
|
|
3081
3541
|
});
|
|
3082
3542
|
}
|
|
3083
3543
|
|
|
3084
3544
|
// src/toolsets/delete.ts
|
|
3085
|
-
async function
|
|
3545
|
+
async function deleteBody3(toolsetId, opts) {
|
|
3086
3546
|
const id = parseToolsetId(toolsetId);
|
|
3087
3547
|
if (dryRun()) {
|
|
3088
3548
|
printOutput({ would_delete: id });
|
|
@@ -3100,12 +3560,12 @@ function registerToolsetsDelete(toolsets) {
|
|
|
3100
3560
|
cmd.addHelpText("after", "\nExamples:\n engini toolsets delete <toolset_id> --force");
|
|
3101
3561
|
addUniversalOptions(cmd, { mutating: true });
|
|
3102
3562
|
cmd.action(async (id, opts, command) => {
|
|
3103
|
-
await runCommand(command, opts, true, () =>
|
|
3563
|
+
await runCommand(command, opts, true, () => deleteBody3(id, opts));
|
|
3104
3564
|
});
|
|
3105
3565
|
}
|
|
3106
3566
|
|
|
3107
3567
|
// src/toolsets/get.ts
|
|
3108
|
-
async function
|
|
3568
|
+
async function getBody7(toolsetId) {
|
|
3109
3569
|
const id = parseToolsetId(toolsetId);
|
|
3110
3570
|
const toolset = await apiErrors(async () => {
|
|
3111
3571
|
const client = buildClient();
|
|
@@ -3123,12 +3583,12 @@ function registerToolsetsGet(toolsets) {
|
|
|
3123
3583
|
cmd.addHelpText("after", "\nExamples:\n engini toolsets get <toolset_id> --json");
|
|
3124
3584
|
addUniversalOptions(cmd);
|
|
3125
3585
|
cmd.action(async (id, opts, command) => {
|
|
3126
|
-
await runCommand(command, opts, false, () =>
|
|
3586
|
+
await runCommand(command, opts, false, () => getBody7(id));
|
|
3127
3587
|
});
|
|
3128
3588
|
}
|
|
3129
3589
|
|
|
3130
3590
|
// src/toolsets/list.ts
|
|
3131
|
-
async function
|
|
3591
|
+
async function listBody8() {
|
|
3132
3592
|
const toolsets = await apiErrors(async () => {
|
|
3133
3593
|
const client = buildClient();
|
|
3134
3594
|
return client.toolsets.list();
|
|
@@ -3143,7 +3603,7 @@ function registerToolsetsList(toolsets) {
|
|
|
3143
3603
|
);
|
|
3144
3604
|
addUniversalOptions(cmd);
|
|
3145
3605
|
cmd.action(async (opts, command) => {
|
|
3146
|
-
await runCommand(command, opts, false, () =>
|
|
3606
|
+
await runCommand(command, opts, false, () => listBody8());
|
|
3147
3607
|
});
|
|
3148
3608
|
}
|
|
3149
3609
|
|
|
@@ -3178,7 +3638,7 @@ async function previewDryRun(toolsetId, body) {
|
|
|
3178
3638
|
}
|
|
3179
3639
|
});
|
|
3180
3640
|
}
|
|
3181
|
-
async function
|
|
3641
|
+
async function updateBody3(toolsetId, opts) {
|
|
3182
3642
|
const id = parseToolsetId(toolsetId);
|
|
3183
3643
|
const body = buildRequestBody2(opts);
|
|
3184
3644
|
if (body.name === void 0 && body.connections === void 0 && body.workflows === void 0) {
|
|
@@ -3215,7 +3675,7 @@ function registerToolsetsUpdate(toolsets) {
|
|
|
3215
3675
|
);
|
|
3216
3676
|
addUniversalOptions(cmd, { mutating: true });
|
|
3217
3677
|
cmd.action(async (id, opts, command) => {
|
|
3218
|
-
await runCommand(command, opts, true, () =>
|
|
3678
|
+
await runCommand(command, opts, true, () => updateBody3(id, opts));
|
|
3219
3679
|
});
|
|
3220
3680
|
}
|
|
3221
3681
|
|
|
@@ -3268,6 +3728,7 @@ function buildProgram() {
|
|
|
3268
3728
|
registerConnections(program);
|
|
3269
3729
|
registerToolsets(program);
|
|
3270
3730
|
registerMcp(program);
|
|
3731
|
+
registerOpa(program);
|
|
3271
3732
|
installHelp(program);
|
|
3272
3733
|
return program;
|
|
3273
3734
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@engini/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.19.0",
|
|
4
4
|
"description": "Engini CLI — machine-first command line over the Engini Public API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "vitest run"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@engini/sdk": "^0.
|
|
29
|
+
"@engini/sdk": "^0.19.0",
|
|
30
30
|
"commander": "^12.1.0",
|
|
31
31
|
"smol-toml": "^1.3.0"
|
|
32
32
|
},
|