suzi-cli 0.1.24 → 0.1.26
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/CLAUDE.md +1 -1
- package/TEST_CHECKLIST.md +243 -0
- package/dist/commands/accounts.d.ts.map +1 -1
- package/dist/commands/accounts.js +68 -33
- package/dist/commands/accounts.js.map +1 -1
- package/dist/commands/agent.d.ts +5 -0
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +410 -38
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/debug.d.ts.map +1 -1
- package/dist/commands/debug.js +14 -14
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +22 -21
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/feedback.js +4 -4
- package/dist/commands/feedback.js.map +1 -1
- package/dist/commands/import.js +13 -16
- package/dist/commands/import.js.map +1 -1
- package/dist/commands/list-actions.d.ts.map +1 -1
- package/dist/commands/list-actions.js +4 -4
- package/dist/commands/list-actions.js.map +1 -1
- package/dist/commands/list-triggers.d.ts.map +1 -1
- package/dist/commands/list-triggers.js +3 -3
- package/dist/commands/list-triggers.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +130 -36
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/portfolio.d.ts.map +1 -1
- package/dist/commands/portfolio.js +106 -7
- package/dist/commands/portfolio.js.map +1 -1
- package/dist/commands/preferences.d.ts.map +1 -1
- package/dist/commands/preferences.js +7 -6
- package/dist/commands/preferences.js.map +1 -1
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +16 -13
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/share.d.ts.map +1 -1
- package/dist/commands/share.js +48 -24
- package/dist/commands/share.js.map +1 -1
- package/dist/commands/transactions.d.ts.map +1 -1
- package/dist/commands/transactions.js +7 -9
- package/dist/commands/transactions.js.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-config.d.ts +38 -0
- package/dist/lib/agent-config.d.ts.map +1 -0
- package/dist/lib/agent-config.js +122 -0
- package/dist/lib/agent-config.js.map +1 -0
- package/dist/lib/agent-config.test.d.ts +2 -0
- package/dist/lib/agent-config.test.d.ts.map +1 -0
- package/dist/lib/agent-config.test.js +60 -0
- package/dist/lib/agent-config.test.js.map +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +20 -2
- package/dist/lib/config.js.map +1 -1
- package/dist/types/portfolio.d.ts +11 -2
- package/dist/types/portfolio.d.ts.map +1 -1
- package/dist/utils/tty.d.ts +15 -3
- package/dist/utils/tty.d.ts.map +1 -1
- package/dist/utils/tty.js +54 -5
- package/dist/utils/tty.js.map +1 -1
- package/dist/utils/ui.d.ts +1 -1
- package/dist/utils/ui.d.ts.map +1 -1
- package/dist/utils/ui.js +17 -6
- package/dist/utils/ui.js.map +1 -1
- package/package.json +1 -1
package/dist/commands/agent.js
CHANGED
|
@@ -39,6 +39,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.registerAgentCommand = registerAgentCommand;
|
|
40
40
|
exports.listAgentsCommand = listAgentsCommand;
|
|
41
41
|
exports.viewAgentCommand = viewAgentCommand;
|
|
42
|
+
exports.getAgentConfigCommand = getAgentConfigCommand;
|
|
43
|
+
exports.setAgentConfigCommand = setAgentConfigCommand;
|
|
42
44
|
exports.deployAgentCommand = deployAgentCommand;
|
|
43
45
|
exports.validateAgentCommand = validateAgentCommand;
|
|
44
46
|
exports.activateAgentCommand = activateAgentCommand;
|
|
@@ -62,6 +64,7 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
62
64
|
const fs_1 = __importDefault(require("fs"));
|
|
63
65
|
const path_1 = __importDefault(require("path"));
|
|
64
66
|
const api_1 = require("../lib/api");
|
|
67
|
+
const agent_config_1 = require("../lib/agent-config");
|
|
65
68
|
const api_errors_1 = require("../lib/api-errors");
|
|
66
69
|
const ui_1 = require("../utils/ui");
|
|
67
70
|
const memory_1 = require("../lib/memory");
|
|
@@ -129,6 +132,24 @@ function registerAgentCommand(program) {
|
|
|
129
132
|
.action(async (id, opts) => {
|
|
130
133
|
await viewAgentCommand(id, opts);
|
|
131
134
|
});
|
|
135
|
+
const configCommand = agent
|
|
136
|
+
.command('config')
|
|
137
|
+
.description('View and update agent config');
|
|
138
|
+
configCommand
|
|
139
|
+
.command('get [id]')
|
|
140
|
+
.description('Get config for an agent')
|
|
141
|
+
.option('--json', 'Output as JSON')
|
|
142
|
+
.action(async (id, opts) => {
|
|
143
|
+
await getAgentConfigCommand(id, opts);
|
|
144
|
+
});
|
|
145
|
+
configCommand
|
|
146
|
+
.command('set [args...]')
|
|
147
|
+
.description('Set one or more config values using key=value pairs')
|
|
148
|
+
.option('--json', 'Output as JSON')
|
|
149
|
+
.action(async (args, opts) => {
|
|
150
|
+
const parsed = (0, agent_config_1.splitConfigSetArgs)(args || []);
|
|
151
|
+
await setAgentConfigCommand(parsed.idOrName, parsed.updates, opts);
|
|
152
|
+
});
|
|
132
153
|
// suzi agents deploy [file]
|
|
133
154
|
agent
|
|
134
155
|
.command('deploy [file]')
|
|
@@ -290,9 +311,9 @@ function registerAgentCommand(program) {
|
|
|
290
311
|
// Command Implementations
|
|
291
312
|
// ============================================================================
|
|
292
313
|
async function listAgentsCommand(opts) {
|
|
293
|
-
if (!(0, ui_1.requireAuth)())
|
|
294
|
-
return;
|
|
295
314
|
const jsonMode = opts?.json || false;
|
|
315
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
316
|
+
return;
|
|
296
317
|
const spinner = (0, tty_1.createSpinner)('Loading agents...', jsonMode);
|
|
297
318
|
spinner?.start();
|
|
298
319
|
const resp = await (0, api_1.get)('/api/agent?limit=50');
|
|
@@ -329,7 +350,7 @@ async function listAgentsCommand(opts) {
|
|
|
329
350
|
chalk_1.default.gray('ID'),
|
|
330
351
|
chalk_1.default.gray('Created'),
|
|
331
352
|
],
|
|
332
|
-
style: { head: [], border: ['gray'] },
|
|
353
|
+
style: { head: [], border: chalk_1.default.level > 0 ? ['gray'] : [] },
|
|
333
354
|
});
|
|
334
355
|
for (let i = 0; i < agentList.length; i++) {
|
|
335
356
|
const agent = agentList[i];
|
|
@@ -344,9 +365,9 @@ async function listAgentsCommand(opts) {
|
|
|
344
365
|
console.log(table.toString());
|
|
345
366
|
}
|
|
346
367
|
async function viewAgentCommand(idOrName, opts) {
|
|
347
|
-
if (!(0, ui_1.requireAuth)())
|
|
348
|
-
return;
|
|
349
368
|
const jsonMode = opts?.json || false;
|
|
369
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
370
|
+
return;
|
|
350
371
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
351
372
|
if (!agent)
|
|
352
373
|
return;
|
|
@@ -415,10 +436,361 @@ async function viewAgentCommand(idOrName, opts) {
|
|
|
415
436
|
console.log();
|
|
416
437
|
(0, ui_1.divider)();
|
|
417
438
|
}
|
|
418
|
-
|
|
419
|
-
if (
|
|
439
|
+
function formatConfigValue(value) {
|
|
440
|
+
if (value === undefined)
|
|
441
|
+
return '<unset>';
|
|
442
|
+
if (typeof value === 'string')
|
|
443
|
+
return JSON.stringify(value);
|
|
444
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
445
|
+
return String(value);
|
|
446
|
+
return JSON.stringify(value);
|
|
447
|
+
}
|
|
448
|
+
function formatConfigSource(source) {
|
|
449
|
+
switch (source) {
|
|
450
|
+
case 'saved':
|
|
451
|
+
return chalk_1.default.green('saved');
|
|
452
|
+
case 'default':
|
|
453
|
+
return chalk_1.default.yellow('default');
|
|
454
|
+
default:
|
|
455
|
+
return ui_1.colors.muted('unset');
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function formatRequirementTarget(requirement, schema, values) {
|
|
459
|
+
const resolved = (0, agent_config_1.resolveRequirementAmount)(requirement.minAmount, schema, values);
|
|
460
|
+
const token = requirement.token ||
|
|
461
|
+
(requirement.type === 'svm_native_balance' ? 'SOL' : '');
|
|
462
|
+
const minAmount = requirement.minAmount;
|
|
463
|
+
const multiply = typeof minAmount === 'object' &&
|
|
464
|
+
minAmount !== null &&
|
|
465
|
+
'multiply' in minAmount &&
|
|
466
|
+
typeof minAmount.multiply === 'number'
|
|
467
|
+
? minAmount.multiply
|
|
468
|
+
: undefined;
|
|
469
|
+
if (resolved.value !== undefined) {
|
|
470
|
+
return `>= ${resolved.value} ${token}`.trim();
|
|
471
|
+
}
|
|
472
|
+
if (resolved.ref) {
|
|
473
|
+
return `${resolved.ref}${multiply !== undefined ? ` * ${multiply}` : ''} (${ui_1.colors.muted('unresolved')})`;
|
|
474
|
+
}
|
|
475
|
+
return ui_1.colors.muted('unresolved');
|
|
476
|
+
}
|
|
477
|
+
function printAgentConfig(agent, configData) {
|
|
478
|
+
(0, ui_1.header)(`${agent.title || 'Untitled Agent'} Config`);
|
|
479
|
+
console.log();
|
|
480
|
+
(0, ui_1.label)('ID', agent.id);
|
|
481
|
+
if (agent.status) {
|
|
482
|
+
(0, ui_1.label)('Status', (0, ui_1.statusBadge)(agent.status));
|
|
483
|
+
}
|
|
484
|
+
const schemaEntries = Object.entries(configData.schema || {});
|
|
485
|
+
console.log();
|
|
486
|
+
if (schemaEntries.length === 0) {
|
|
487
|
+
(0, ui_1.info)('This agent has no configurable fields.');
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
const table = new cli_table3_1.default({
|
|
491
|
+
head: [
|
|
492
|
+
chalk_1.default.gray('Field'),
|
|
493
|
+
chalk_1.default.gray('Type'),
|
|
494
|
+
chalk_1.default.gray('Current'),
|
|
495
|
+
chalk_1.default.gray('Source'),
|
|
496
|
+
chalk_1.default.gray('Required'),
|
|
497
|
+
chalk_1.default.gray('Default'),
|
|
498
|
+
chalk_1.default.gray('Constraints'),
|
|
499
|
+
],
|
|
500
|
+
style: { head: [], border: chalk_1.default.level > 0 ? ['gray'] : [] },
|
|
501
|
+
wordWrap: true,
|
|
502
|
+
});
|
|
503
|
+
for (const [key, field] of schemaEntries) {
|
|
504
|
+
const effective = (0, agent_config_1.getEffectiveConfigValue)(key, configData.schema, configData.values);
|
|
505
|
+
table.push([
|
|
506
|
+
chalk_1.default.bold(key),
|
|
507
|
+
field.type,
|
|
508
|
+
formatConfigValue(effective.value),
|
|
509
|
+
formatConfigSource(effective.source),
|
|
510
|
+
field.required === false ? 'no' : 'yes',
|
|
511
|
+
field.default !== undefined ? formatConfigValue(field.default) : ui_1.colors.muted('—'),
|
|
512
|
+
(0, agent_config_1.describeConfigConstraints)(field) || ui_1.colors.muted('—'),
|
|
513
|
+
]);
|
|
514
|
+
}
|
|
515
|
+
console.log(table.toString());
|
|
516
|
+
}
|
|
517
|
+
const requirementEntries = Object.entries(configData.activationRequirements || {});
|
|
518
|
+
if (requirementEntries.length > 0) {
|
|
519
|
+
console.log();
|
|
520
|
+
console.log(ui_1.colors.muted(' Activation Requirements:'));
|
|
521
|
+
const requirementTable = new cli_table3_1.default({
|
|
522
|
+
head: [
|
|
523
|
+
chalk_1.default.gray('Name'),
|
|
524
|
+
chalk_1.default.gray('Wallet'),
|
|
525
|
+
chalk_1.default.gray('Need'),
|
|
526
|
+
chalk_1.default.gray('Description'),
|
|
527
|
+
],
|
|
528
|
+
style: { head: [], border: chalk_1.default.level > 0 ? ['gray'] : [] },
|
|
529
|
+
wordWrap: true,
|
|
530
|
+
});
|
|
531
|
+
for (const [name, requirement] of requirementEntries) {
|
|
532
|
+
requirementTable.push([
|
|
533
|
+
chalk_1.default.bold(name),
|
|
534
|
+
requirement.type.startsWith('evm') ? 'evm' : 'svm',
|
|
535
|
+
formatRequirementTarget(requirement, configData.schema, configData.values),
|
|
536
|
+
requirement.description || ui_1.colors.muted('—'),
|
|
537
|
+
]);
|
|
538
|
+
}
|
|
539
|
+
console.log(requirementTable.toString());
|
|
540
|
+
}
|
|
541
|
+
console.log();
|
|
542
|
+
(0, ui_1.divider)();
|
|
543
|
+
}
|
|
544
|
+
function outputLocalConfigError(jsonMode, message) {
|
|
545
|
+
process.exitCode = 1;
|
|
546
|
+
if (jsonMode) {
|
|
547
|
+
(0, tty_1.outputJson)({ success: false, error: message });
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
(0, ui_1.error)(message);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
async function fetchAgentConfig(agentId, jsonMode) {
|
|
554
|
+
const spinner = (0, tty_1.createSpinner)('Loading agent config...', jsonMode);
|
|
555
|
+
spinner?.start();
|
|
556
|
+
const resp = await (0, api_1.get)(`/api/agent/${agentId}/config`);
|
|
557
|
+
if (!resp.ok) {
|
|
558
|
+
spinner?.fail();
|
|
559
|
+
process.exitCode = 1;
|
|
560
|
+
handleCliApiFailure(resp.data, {
|
|
561
|
+
jsonMode,
|
|
562
|
+
prefix: 'Failed to load config: ',
|
|
563
|
+
});
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
spinner?.stop();
|
|
567
|
+
return resp.data;
|
|
568
|
+
}
|
|
569
|
+
async function getAgentConfigCommand(idOrName, opts) {
|
|
570
|
+
const jsonMode = opts?.json || false;
|
|
571
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
572
|
+
return;
|
|
573
|
+
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
574
|
+
if (!agent)
|
|
575
|
+
return;
|
|
576
|
+
const configData = await fetchAgentConfig(agent.id, jsonMode);
|
|
577
|
+
if (!configData)
|
|
578
|
+
return;
|
|
579
|
+
if (jsonMode) {
|
|
580
|
+
(0, tty_1.outputJson)({
|
|
581
|
+
success: true,
|
|
582
|
+
data: {
|
|
583
|
+
agentId: agent.id,
|
|
584
|
+
...configData,
|
|
585
|
+
},
|
|
586
|
+
});
|
|
420
587
|
return;
|
|
588
|
+
}
|
|
589
|
+
printAgentConfig(agent, configData);
|
|
590
|
+
}
|
|
591
|
+
function printUpdatedConfigValues(updatedKeys, schema, values) {
|
|
592
|
+
const table = new cli_table3_1.default({
|
|
593
|
+
head: [
|
|
594
|
+
chalk_1.default.gray('Field'),
|
|
595
|
+
chalk_1.default.gray('Saved Value'),
|
|
596
|
+
chalk_1.default.gray('Type'),
|
|
597
|
+
],
|
|
598
|
+
style: { head: [], border: chalk_1.default.level > 0 ? ['gray'] : [] },
|
|
599
|
+
});
|
|
600
|
+
for (const key of updatedKeys) {
|
|
601
|
+
table.push([
|
|
602
|
+
chalk_1.default.bold(key),
|
|
603
|
+
formatConfigValue(values[key]),
|
|
604
|
+
schema[key]?.type || ui_1.colors.muted('unknown'),
|
|
605
|
+
]);
|
|
606
|
+
}
|
|
607
|
+
console.log(table.toString());
|
|
608
|
+
}
|
|
609
|
+
async function setAgentConfigCommand(idOrName, updatesArgs = [], opts) {
|
|
421
610
|
const jsonMode = opts?.json || false;
|
|
611
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
612
|
+
return;
|
|
613
|
+
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
614
|
+
if (!agent)
|
|
615
|
+
return;
|
|
616
|
+
const configData = await fetchAgentConfig(agent.id, jsonMode);
|
|
617
|
+
if (!configData)
|
|
618
|
+
return;
|
|
619
|
+
const schemaEntries = Object.entries(configData.schema || {});
|
|
620
|
+
if (schemaEntries.length === 0) {
|
|
621
|
+
outputLocalConfigError(jsonMode, 'This agent has no configurable fields.');
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
let updates;
|
|
625
|
+
try {
|
|
626
|
+
updates = (0, agent_config_1.parseConfigUpdateArgs)(updatesArgs, configData.schema);
|
|
627
|
+
}
|
|
628
|
+
catch (err) {
|
|
629
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
630
|
+
outputLocalConfigError(jsonMode, message);
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
const updatedKeys = Object.keys(updates);
|
|
634
|
+
const startedActive = agent.status === 'active';
|
|
635
|
+
let deactivatedForUpdate = false;
|
|
636
|
+
if (startedActive) {
|
|
637
|
+
if (jsonMode || !(0, tty_1.shouldUseInteractive)()) {
|
|
638
|
+
outputLocalConfigError(jsonMode, 'Cannot update config for an active agent in non-interactive mode. Deactivate the agent first.');
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const answers = await inquirer_1.default.prompt([
|
|
642
|
+
{
|
|
643
|
+
type: 'confirm',
|
|
644
|
+
name: 'confirm',
|
|
645
|
+
message: `Agent "${agent.title || 'Untitled'}" is active. Deactivate, update config, and reactivate it?`,
|
|
646
|
+
default: false,
|
|
647
|
+
},
|
|
648
|
+
]);
|
|
649
|
+
if (!answers.confirm) {
|
|
650
|
+
(0, ui_1.info)('Cancelled.');
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
const deactivateSpinner = (0, tty_1.createSpinner)('Deactivating agent...', jsonMode);
|
|
654
|
+
deactivateSpinner?.start();
|
|
655
|
+
const deactivateResp = await (0, api_1.post)(`/api/agent/${agent.id}/deactivate`);
|
|
656
|
+
if (!deactivateResp.ok) {
|
|
657
|
+
deactivateSpinner?.fail();
|
|
658
|
+
handleCliApiFailure(deactivateResp.data, {
|
|
659
|
+
jsonMode,
|
|
660
|
+
prefix: 'Failed to deactivate before config update: ',
|
|
661
|
+
});
|
|
662
|
+
process.exitCode = 1;
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
deactivateSpinner?.succeed();
|
|
666
|
+
deactivatedForUpdate = true;
|
|
667
|
+
}
|
|
668
|
+
const updateSpinner = (0, tty_1.createSpinner)('Updating config...', jsonMode);
|
|
669
|
+
updateSpinner?.start();
|
|
670
|
+
const updateResp = await (0, api_1.patch)(`/api/agent/${agent.id}/config`, { values: updates });
|
|
671
|
+
if (!updateResp.ok) {
|
|
672
|
+
updateSpinner?.fail();
|
|
673
|
+
const patchError = (0, api_errors_1.parseCliApiError)(updateResp.data);
|
|
674
|
+
let restoreError = null;
|
|
675
|
+
if (deactivatedForUpdate) {
|
|
676
|
+
const restoreSpinner = (0, tty_1.createSpinner)('Reactivating agent after failed update...', jsonMode);
|
|
677
|
+
restoreSpinner?.start();
|
|
678
|
+
const restoreResp = await (0, api_1.post)(`/api/agent/${agent.id}/activate`);
|
|
679
|
+
if (!restoreResp.ok) {
|
|
680
|
+
restoreSpinner?.fail();
|
|
681
|
+
restoreError = (0, api_errors_1.parseCliApiError)(restoreResp.data);
|
|
682
|
+
}
|
|
683
|
+
else {
|
|
684
|
+
restoreSpinner?.succeed();
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
process.exitCode = 1;
|
|
688
|
+
if (jsonMode) {
|
|
689
|
+
(0, tty_1.outputJson)({
|
|
690
|
+
success: false,
|
|
691
|
+
error: restoreError
|
|
692
|
+
? `${patchError.summary}. Agent could not be reactivated after the failed update.`
|
|
693
|
+
: patchError.summary,
|
|
694
|
+
data: {
|
|
695
|
+
agentId: agent.id,
|
|
696
|
+
updatedKeys,
|
|
697
|
+
configUpdated: false,
|
|
698
|
+
reactivated: deactivatedForUpdate && !restoreError,
|
|
699
|
+
patchError: {
|
|
700
|
+
summary: patchError.summary,
|
|
701
|
+
error: patchError.raw,
|
|
702
|
+
},
|
|
703
|
+
...(restoreError && {
|
|
704
|
+
reactivationError: {
|
|
705
|
+
summary: restoreError.summary,
|
|
706
|
+
error: restoreError.raw,
|
|
707
|
+
},
|
|
708
|
+
}),
|
|
709
|
+
},
|
|
710
|
+
});
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
(0, ui_1.error)(`Failed to update config: ${patchError.summary}`);
|
|
714
|
+
if (patchError.issues.length > 0) {
|
|
715
|
+
printCliApiIssues(patchError.issues);
|
|
716
|
+
}
|
|
717
|
+
else if (patchError.detailsText) {
|
|
718
|
+
console.log(ui_1.colors.muted(` ${patchError.detailsText}`));
|
|
719
|
+
}
|
|
720
|
+
if (restoreError) {
|
|
721
|
+
(0, ui_1.warn)(`Agent could not be reactivated after the failed update: ${restoreError.summary}`);
|
|
722
|
+
if (restoreError.issues.length > 0) {
|
|
723
|
+
printCliApiIssues(restoreError.issues, ' Reactivation issues:');
|
|
724
|
+
}
|
|
725
|
+
else if (restoreError.detailsText) {
|
|
726
|
+
console.log(ui_1.colors.muted(` ${restoreError.detailsText}`));
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
else if (deactivatedForUpdate) {
|
|
730
|
+
(0, ui_1.info)('Agent was reactivated after the failed config update.');
|
|
731
|
+
}
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
updateSpinner?.succeed('Config updated!');
|
|
735
|
+
if (deactivatedForUpdate) {
|
|
736
|
+
const reactivateSpinner = (0, tty_1.createSpinner)('Reactivating agent...', jsonMode);
|
|
737
|
+
reactivateSpinner?.start();
|
|
738
|
+
const reactivateResp = await (0, api_1.post)(`/api/agent/${agent.id}/activate`);
|
|
739
|
+
if (!reactivateResp.ok) {
|
|
740
|
+
reactivateSpinner?.fail();
|
|
741
|
+
const activationError = (0, api_errors_1.parseCliApiError)(reactivateResp.data);
|
|
742
|
+
process.exitCode = 1;
|
|
743
|
+
if (jsonMode) {
|
|
744
|
+
(0, tty_1.outputJson)({
|
|
745
|
+
success: false,
|
|
746
|
+
error: `Config updated, but reactivation failed: ${activationError.summary}`,
|
|
747
|
+
data: {
|
|
748
|
+
agentId: agent.id,
|
|
749
|
+
updatedKeys,
|
|
750
|
+
values: updateResp.data.values,
|
|
751
|
+
configUpdated: true,
|
|
752
|
+
reactivated: false,
|
|
753
|
+
activationError: {
|
|
754
|
+
summary: activationError.summary,
|
|
755
|
+
error: activationError.raw,
|
|
756
|
+
},
|
|
757
|
+
},
|
|
758
|
+
});
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
(0, ui_1.error)(`Config updated, but reactivation failed: ${activationError.summary}`);
|
|
762
|
+
if (activationError.issues.length > 0) {
|
|
763
|
+
printCliApiIssues(activationError.issues, ' Reactivation issues:');
|
|
764
|
+
}
|
|
765
|
+
else if (activationError.detailsText) {
|
|
766
|
+
console.log(ui_1.colors.muted(` ${activationError.detailsText}`));
|
|
767
|
+
}
|
|
768
|
+
console.log();
|
|
769
|
+
printUpdatedConfigValues(updatedKeys, configData.schema, updateResp.data.values);
|
|
770
|
+
return;
|
|
771
|
+
}
|
|
772
|
+
reactivateSpinner?.succeed();
|
|
773
|
+
}
|
|
774
|
+
if (jsonMode) {
|
|
775
|
+
(0, tty_1.outputJson)({
|
|
776
|
+
success: true,
|
|
777
|
+
data: {
|
|
778
|
+
agentId: agent.id,
|
|
779
|
+
updatedKeys,
|
|
780
|
+
values: updateResp.data.values,
|
|
781
|
+
reactivated: deactivatedForUpdate,
|
|
782
|
+
},
|
|
783
|
+
});
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
(0, ui_1.success)(`Updated config for ${agent.title || agent.id}.`);
|
|
787
|
+
console.log();
|
|
788
|
+
printUpdatedConfigValues(updatedKeys, configData.schema, updateResp.data.values);
|
|
789
|
+
}
|
|
790
|
+
async function deployAgentCommand(file, opts) {
|
|
791
|
+
const jsonMode = opts?.json || false;
|
|
792
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
793
|
+
return;
|
|
422
794
|
// Find the agent file
|
|
423
795
|
let filePath = file;
|
|
424
796
|
if (!filePath) {
|
|
@@ -635,9 +1007,9 @@ async function deployAgentCommand(file, opts) {
|
|
|
635
1007
|
}
|
|
636
1008
|
}
|
|
637
1009
|
async function validateAgentCommand(file, opts) {
|
|
638
|
-
if (!(0, ui_1.requireAuth)())
|
|
639
|
-
return;
|
|
640
1010
|
const jsonMode = opts?.json || false;
|
|
1011
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1012
|
+
return;
|
|
641
1013
|
// Resolve file path
|
|
642
1014
|
let filePath = file;
|
|
643
1015
|
if (!filePath && !jsonMode && (0, tty_1.shouldUseInteractive)()) {
|
|
@@ -821,9 +1193,9 @@ async function validateAgentCommand(file, opts) {
|
|
|
821
1193
|
}
|
|
822
1194
|
}
|
|
823
1195
|
async function activateAgentCommand(idOrName, opts) {
|
|
824
|
-
if (!(0, ui_1.requireAuth)())
|
|
825
|
-
return;
|
|
826
1196
|
const jsonMode = opts?.json || false;
|
|
1197
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1198
|
+
return;
|
|
827
1199
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
828
1200
|
if (!agent)
|
|
829
1201
|
return;
|
|
@@ -848,9 +1220,9 @@ async function activateAgentCommand(idOrName, opts) {
|
|
|
848
1220
|
}
|
|
849
1221
|
}
|
|
850
1222
|
async function deactivateAgentCommand(idOrName, opts) {
|
|
851
|
-
if (!(0, ui_1.requireAuth)())
|
|
852
|
-
return;
|
|
853
1223
|
const jsonMode = opts?.json || false;
|
|
1224
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1225
|
+
return;
|
|
854
1226
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
855
1227
|
if (!agent)
|
|
856
1228
|
return;
|
|
@@ -890,9 +1262,9 @@ async function deactivateAgentCommand(idOrName, opts) {
|
|
|
890
1262
|
}
|
|
891
1263
|
}
|
|
892
1264
|
async function executeAgentCommand(idOrName, trigger, opts) {
|
|
893
|
-
if (!(0, ui_1.requireAuth)())
|
|
894
|
-
return;
|
|
895
1265
|
const jsonMode = opts?.json || false;
|
|
1266
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1267
|
+
return;
|
|
896
1268
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
897
1269
|
if (!agent)
|
|
898
1270
|
return;
|
|
@@ -973,9 +1345,9 @@ async function executeAgentCommand(idOrName, trigger, opts) {
|
|
|
973
1345
|
}
|
|
974
1346
|
}
|
|
975
1347
|
async function logsAgentCommand(idOrName, opts) {
|
|
976
|
-
if (!(0, ui_1.requireAuth)())
|
|
977
|
-
return;
|
|
978
1348
|
const jsonMode = opts?.json || false;
|
|
1349
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1350
|
+
return;
|
|
979
1351
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
980
1352
|
if (!agent)
|
|
981
1353
|
return;
|
|
@@ -1021,9 +1393,9 @@ async function logsAgentCommand(idOrName, opts) {
|
|
|
1021
1393
|
}
|
|
1022
1394
|
}
|
|
1023
1395
|
async function codeAgentCommand(idOrName, opts) {
|
|
1024
|
-
if (!(0, ui_1.requireAuth)())
|
|
1025
|
-
return;
|
|
1026
1396
|
const jsonMode = opts?.json || false;
|
|
1397
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1398
|
+
return;
|
|
1027
1399
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1028
1400
|
if (!agent)
|
|
1029
1401
|
return;
|
|
@@ -1068,9 +1440,9 @@ async function codeAgentCommand(idOrName, opts) {
|
|
|
1068
1440
|
console.log(ui_1.colors.muted(` ${lines.length} lines`));
|
|
1069
1441
|
}
|
|
1070
1442
|
async function deleteAgentCommand(idOrName, opts) {
|
|
1071
|
-
if (!(0, ui_1.requireAuth)())
|
|
1072
|
-
return;
|
|
1073
1443
|
const jsonMode = opts?.json || false;
|
|
1444
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1445
|
+
return;
|
|
1074
1446
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1075
1447
|
if (!agent)
|
|
1076
1448
|
return;
|
|
@@ -1114,9 +1486,9 @@ async function deleteAgentCommand(idOrName, opts) {
|
|
|
1114
1486
|
// Git Version Control Commands
|
|
1115
1487
|
// ============================================================================
|
|
1116
1488
|
async function historyCommand(idOrName, opts) {
|
|
1117
|
-
if (!(0, ui_1.requireAuth)())
|
|
1118
|
-
return;
|
|
1119
1489
|
const jsonMode = opts?.json || false;
|
|
1490
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1491
|
+
return;
|
|
1120
1492
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1121
1493
|
if (!agent)
|
|
1122
1494
|
return;
|
|
@@ -1159,9 +1531,9 @@ async function historyCommand(idOrName, opts) {
|
|
|
1159
1531
|
console.log(ui_1.colors.muted(` ${commits.length} commit(s)`));
|
|
1160
1532
|
}
|
|
1161
1533
|
async function diffCommand(idOrName, sha, opts) {
|
|
1162
|
-
if (!(0, ui_1.requireAuth)())
|
|
1163
|
-
return;
|
|
1164
1534
|
const jsonMode = opts?.json || false;
|
|
1535
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1536
|
+
return;
|
|
1165
1537
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1166
1538
|
if (!agent)
|
|
1167
1539
|
return;
|
|
@@ -1245,9 +1617,9 @@ async function diffCommand(idOrName, sha, opts) {
|
|
|
1245
1617
|
}
|
|
1246
1618
|
}
|
|
1247
1619
|
async function versionCommand(idOrName, sha, opts) {
|
|
1248
|
-
if (!(0, ui_1.requireAuth)())
|
|
1249
|
-
return;
|
|
1250
1620
|
const jsonMode = opts?.json || false;
|
|
1621
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1622
|
+
return;
|
|
1251
1623
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1252
1624
|
if (!agent)
|
|
1253
1625
|
return;
|
|
@@ -1316,9 +1688,9 @@ async function versionCommand(idOrName, sha, opts) {
|
|
|
1316
1688
|
console.log(ui_1.colors.muted(` ${lines.length} lines`));
|
|
1317
1689
|
}
|
|
1318
1690
|
async function checkoutCommand(idOrName, sha, opts) {
|
|
1319
|
-
if (!(0, ui_1.requireAuth)())
|
|
1320
|
-
return;
|
|
1321
1691
|
const jsonMode = opts?.json || false;
|
|
1692
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1693
|
+
return;
|
|
1322
1694
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1323
1695
|
if (!agent)
|
|
1324
1696
|
return;
|
|
@@ -1390,9 +1762,9 @@ async function checkoutCommand(idOrName, sha, opts) {
|
|
|
1390
1762
|
}
|
|
1391
1763
|
}
|
|
1392
1764
|
async function forkCommand(idOrName, opts) {
|
|
1393
|
-
if (!(0, ui_1.requireAuth)())
|
|
1394
|
-
return;
|
|
1395
1765
|
const jsonMode = opts?.json || false;
|
|
1766
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1767
|
+
return;
|
|
1396
1768
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1397
1769
|
if (!agent)
|
|
1398
1770
|
return;
|
|
@@ -1428,9 +1800,9 @@ async function forkCommand(idOrName, opts) {
|
|
|
1428
1800
|
(0, ui_1.divider)();
|
|
1429
1801
|
}
|
|
1430
1802
|
async function upstreamCommand(idOrName, opts) {
|
|
1431
|
-
if (!(0, ui_1.requireAuth)())
|
|
1432
|
-
return;
|
|
1433
1803
|
const jsonMode = opts?.json || false;
|
|
1804
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1805
|
+
return;
|
|
1434
1806
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1435
1807
|
if (!agent)
|
|
1436
1808
|
return;
|
|
@@ -1475,9 +1847,9 @@ async function upstreamCommand(idOrName, opts) {
|
|
|
1475
1847
|
}
|
|
1476
1848
|
}
|
|
1477
1849
|
async function pullCommand(idOrName, opts) {
|
|
1478
|
-
if (!(0, ui_1.requireAuth)())
|
|
1479
|
-
return;
|
|
1480
1850
|
const jsonMode = opts?.json || false;
|
|
1851
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1852
|
+
return;
|
|
1481
1853
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1482
1854
|
if (!agent)
|
|
1483
1855
|
return;
|
|
@@ -1566,9 +1938,9 @@ async function pullCommand(idOrName, opts) {
|
|
|
1566
1938
|
(0, ui_1.info)(`Pull result: ${result.status || 'unknown'}`);
|
|
1567
1939
|
}
|
|
1568
1940
|
async function listForksCommand(idOrName, opts) {
|
|
1569
|
-
if (!(0, ui_1.requireAuth)())
|
|
1570
|
-
return;
|
|
1571
1941
|
const jsonMode = opts?.json || false;
|
|
1942
|
+
if (!(0, ui_1.requireAuth)(jsonMode))
|
|
1943
|
+
return;
|
|
1572
1944
|
const agent = await (0, agent_picker_1.fetchAndPickAgent)(idOrName, jsonMode);
|
|
1573
1945
|
if (!agent)
|
|
1574
1946
|
return;
|
|
@@ -1607,7 +1979,7 @@ async function listForksCommand(idOrName, opts) {
|
|
|
1607
1979
|
chalk_1.default.gray('Last Synced'),
|
|
1608
1980
|
chalk_1.default.gray('Created'),
|
|
1609
1981
|
],
|
|
1610
|
-
style: { head: [], border: ['gray'] },
|
|
1982
|
+
style: { head: [], border: chalk_1.default.level > 0 ? ['gray'] : [] },
|
|
1611
1983
|
});
|
|
1612
1984
|
for (let i = 0; i < forks.length; i++) {
|
|
1613
1985
|
const f = forks[i];
|