vigthoria-cli 1.13.18 → 1.13.22
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/completions/_vigthoria +49 -0
- package/completions/vigthoria.bash +6 -0
- package/completions/vigthoria.fish +41 -0
- package/dist/commands/auth.d.ts +1 -0
- package/dist/commands/auth.js +84 -135
- package/dist/commands/background.d.ts +0 -2
- package/dist/commands/background.js +26 -34
- package/dist/commands/bridge.js +45 -41
- package/dist/commands/cancel.d.ts +1 -0
- package/dist/commands/cancel.js +22 -16
- package/dist/commands/chat.d.ts +5 -42
- package/dist/commands/chat.js +462 -1122
- package/dist/commands/coding-registration.d.ts +4 -0
- package/dist/commands/coding-registration.js +24 -0
- package/dist/commands/config.js +32 -42
- package/dist/commands/conversation-registration.d.ts +4 -0
- package/dist/commands/conversation-registration.js +122 -0
- package/dist/commands/deploy.d.ts +8 -2
- package/dist/commands/deploy.js +92 -90
- package/dist/commands/device.d.ts +1 -2
- package/dist/commands/device.js +37 -21
- package/dist/commands/doctor-registration.d.ts +4 -0
- package/dist/commands/doctor-registration.js +200 -0
- package/dist/commands/edit.js +22 -33
- package/dist/commands/explain.js +7 -10
- package/dist/commands/fork.d.ts +1 -2
- package/dist/commands/fork.js +72 -22
- package/dist/commands/game.d.ts +1 -1
- package/dist/commands/game.js +17 -6
- package/dist/commands/generate.js +7 -9
- package/dist/commands/history.js +11 -7
- package/dist/commands/hub.d.ts +2 -2
- package/dist/commands/hub.js +34 -35
- package/dist/commands/legion.d.ts +0 -1
- package/dist/commands/legion.js +62 -79
- package/dist/commands/music.d.ts +1 -2
- package/dist/commands/music.js +62 -27
- package/dist/commands/platform-registration.d.ts +4 -0
- package/dist/commands/platform-registration.js +45 -0
- package/dist/commands/preview.d.ts +0 -1
- package/dist/commands/preview.js +82 -35
- package/dist/commands/product-run-registration.d.ts +4 -0
- package/dist/commands/product-run-registration.js +490 -0
- package/dist/commands/replay.d.ts +1 -2
- package/dist/commands/replay.js +15 -11
- package/dist/commands/repo.d.ts +14 -7
- package/dist/commands/repo.js +245 -196
- package/dist/commands/review.js +9 -12
- package/dist/commands/security.d.ts +1 -2
- package/dist/commands/security.js +12 -6
- package/dist/commands/update-registration.d.ts +3 -0
- package/dist/commands/update-registration.js +338 -0
- package/dist/commands/v4-registration.d.ts +4 -0
- package/dist/commands/v4-registration.js +24 -0
- package/dist/commands/v4.d.ts +1 -1
- package/dist/commands/v4.js +46 -8
- package/dist/commands/wallet.d.ts +1 -3
- package/dist/commands/wallet.js +18 -45
- package/dist/commands/workflow.d.ts +2 -0
- package/dist/commands/workflow.js +52 -39
- package/dist/index.js +122 -1498
- package/dist/utils/agent-stream-state.d.ts +27 -0
- package/dist/utils/agent-stream-state.js +93 -0
- package/dist/utils/agentRoute.d.ts +2 -1
- package/dist/utils/agentRoute.js +22 -9
- package/dist/utils/agentRunOutcome.d.ts +16 -0
- package/dist/utils/agentRunOutcome.js +37 -2
- package/dist/utils/api-client-factory.d.ts +8 -0
- package/dist/utils/api-client-factory.js +8 -0
- package/dist/utils/api.d.ts +45 -269
- package/dist/utils/api.js +664 -3210
- package/dist/utils/auth-session.d.ts +41 -0
- package/dist/utils/auth-session.js +224 -0
- package/dist/utils/brain-hub-client.d.ts +0 -4
- package/dist/utils/brain-hub-client.js +6 -3
- package/dist/utils/bridge-client.js +2 -0
- package/dist/utils/capability-health-service.d.ts +48 -0
- package/dist/utils/capability-health-service.js +64 -0
- package/dist/utils/chat-prompt-policy.d.ts +18 -0
- package/dist/utils/chat-prompt-policy.js +61 -0
- package/dist/utils/chat-tool-call-parser.d.ts +11 -0
- package/dist/utils/chat-tool-call-parser.js +71 -0
- package/dist/utils/cli-state.d.ts +22 -4
- package/dist/utils/cli-state.js +105 -47
- package/dist/utils/code-operations-service.d.ts +104 -0
- package/dist/utils/code-operations-service.js +837 -0
- package/dist/utils/codebase-indexer.d.ts +1 -0
- package/dist/utils/codebase-indexer.js +28 -8
- package/dist/utils/command-contract.d.ts +61 -0
- package/dist/utils/command-contract.js +149 -0
- package/dist/utils/command-policy.d.ts +10 -0
- package/dist/utils/command-policy.js +54 -0
- package/dist/utils/config.d.ts +13 -5
- package/dist/utils/config.js +227 -99
- package/dist/utils/context-ranker.js +11 -2
- package/dist/utils/context-state.d.ts +39 -0
- package/dist/utils/context-state.js +52 -0
- package/dist/utils/deckEvents.d.ts +0 -5
- package/dist/utils/deckEvents.js +3 -2
- package/dist/utils/desktop-bridge-client.js +2 -0
- package/dist/utils/direct-output-policy.d.ts +3 -0
- package/dist/utils/direct-output-policy.js +76 -0
- package/dist/utils/durable-json.d.ts +57 -0
- package/dist/utils/durable-json.js +319 -0
- package/dist/utils/fastAgentRouter.d.ts +6 -7
- package/dist/utils/fastAgentRouter.js +21 -30
- package/dist/utils/files.js +21 -13
- package/dist/utils/frontend-preview-service.d.ts +76 -0
- package/dist/utils/frontend-preview-service.js +482 -0
- package/dist/utils/goaEvents.d.ts +0 -4
- package/dist/utils/goaEvents.js +5 -2
- package/dist/utils/logger.d.ts +2 -1
- package/dist/utils/logger.js +27 -20
- package/dist/utils/mcp-context-client.d.ts +24 -0
- package/dist/utils/mcp-context-client.js +58 -0
- package/dist/utils/model-governance.d.ts +18 -0
- package/dist/utils/model-governance.js +75 -0
- package/dist/utils/model-transport-service.d.ts +44 -0
- package/dist/utils/model-transport-service.js +111 -0
- package/dist/utils/mutation-journal.d.ts +42 -0
- package/dist/utils/mutation-journal.js +387 -0
- package/dist/utils/network-policy.d.ts +24 -0
- package/dist/utils/network-policy.js +202 -0
- package/dist/utils/operator-client.d.ts +45 -0
- package/dist/utils/operator-client.js +159 -0
- package/dist/utils/post-write-validator.js +7 -9
- package/dist/utils/preview-screenshot-adapter.d.ts +13 -0
- package/dist/utils/preview-screenshot-adapter.js +36 -0
- package/dist/utils/process-policy.d.ts +23 -0
- package/dist/utils/process-policy.js +284 -0
- package/dist/utils/project-memory.d.ts +13 -3
- package/dist/utils/project-memory.js +70 -17
- package/dist/utils/prompt-workspace-resolver.d.ts +14 -0
- package/dist/utils/prompt-workspace-resolver.js +64 -0
- package/dist/utils/release-install.d.ts +11 -0
- package/dist/utils/release-install.js +155 -0
- package/dist/utils/release-policy.d.ts +64 -0
- package/dist/utils/release-policy.js +293 -0
- package/dist/utils/requestIntent.js +22 -3
- package/dist/utils/runtime-capability.d.ts +8 -0
- package/dist/utils/runtime-capability.js +16 -0
- package/dist/utils/secret-policy.d.ts +20 -0
- package/dist/utils/secret-policy.js +160 -0
- package/dist/utils/session.d.ts +34 -2
- package/dist/utils/session.js +354 -110
- package/dist/utils/tool-approval-service.d.ts +17 -0
- package/dist/utils/tool-approval-service.js +78 -0
- package/dist/utils/tool-capability-providers.d.ts +57 -0
- package/dist/utils/tool-capability-providers.js +57 -0
- package/dist/utils/tools.d.ts +2 -23
- package/dist/utils/tools.js +216 -508
- package/dist/utils/update-policy.d.ts +18 -0
- package/dist/utils/update-policy.js +137 -0
- package/dist/utils/v3-agent-client.d.ts +40 -0
- package/dist/utils/v3-agent-client.js +165 -0
- package/dist/utils/v3-workspace-service.d.ts +28 -0
- package/dist/utils/v3-workspace-service.js +279 -0
- package/dist/utils/vigflow-client.d.ts +95 -0
- package/dist/utils/vigflow-client.js +105 -0
- package/dist/utils/workspace-boundary.d.ts +45 -0
- package/dist/utils/workspace-boundary.js +377 -0
- package/dist/utils/workspace-brain-service.d.ts +2 -0
- package/dist/utils/workspace-brain-service.js +11 -1
- package/dist/utils/workspace-cache.js +37 -15
- package/dist/utils/workspace-stream.js +35 -10
- package/install.ps1 +86 -143
- package/install.sh +76 -81
- package/package.json +44 -9
- package/release-policy.json +43 -0
- package/scripts/release/LOCAL_MACHINE_USER_VERIFICATION.md +1 -1
- package/scripts/release/generate-completions.mjs +24 -0
- package/scripts/release/install-release.mjs +10 -0
- package/scripts/release/publish-cli-release.mjs +116 -0
- package/scripts/release/publish-cli-release.sh +2 -70
- package/scripts/release/resolve-release-manifest.mjs +26 -0
- package/scripts/release/test-balanced-model-live.sh +42 -0
- package/scripts/release/validate-live-service-gates.sh +90 -0
- package/scripts/release/validate-no-go-gates.sh +135 -172
- package/scripts/release/verify-runtime-consistency.mjs +4 -1
- package/dist/commands/index.d.ts +0 -12
- package/dist/commands/index.js +0 -194
- package/dist/commands/update.d.ts +0 -9
- package/dist/commands/update.js +0 -301
- package/dist/utils/templateInstantPath.d.ts +0 -18
- package/dist/utils/templateInstantPath.js +0 -228
package/dist/commands/wallet.js
CHANGED
|
@@ -7,13 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import chalk from 'chalk';
|
|
9
9
|
import { Config } from '../utils/config.js';
|
|
10
|
-
import {
|
|
10
|
+
import { AuthSessionService } from '../utils/auth-session.js';
|
|
11
|
+
import { CliCommandError, commandFailure, formatSuccessJson } from '../utils/command-contract.js';
|
|
11
12
|
export class WalletCommand {
|
|
12
13
|
config;
|
|
13
|
-
|
|
14
|
+
authSession;
|
|
14
15
|
constructor() {
|
|
15
16
|
this.config = new Config();
|
|
16
|
-
this.
|
|
17
|
+
this.authSession = new AuthSessionService(this.config);
|
|
17
18
|
}
|
|
18
19
|
register(program) {
|
|
19
20
|
const wallet = program
|
|
@@ -44,36 +45,7 @@ export class WalletCommand {
|
|
|
44
45
|
return String(this.config.get('apiUrl') || 'https://coder.vigthoria.io').replace(/\/$/, '');
|
|
45
46
|
}
|
|
46
47
|
getToken() {
|
|
47
|
-
return this.
|
|
48
|
-
}
|
|
49
|
-
getRefreshToken() {
|
|
50
|
-
return this.config.get('refreshToken') || null;
|
|
51
|
-
}
|
|
52
|
-
async refreshAccessToken() {
|
|
53
|
-
const refreshToken = this.getRefreshToken();
|
|
54
|
-
if (!refreshToken)
|
|
55
|
-
return false;
|
|
56
|
-
try {
|
|
57
|
-
const response = await fetch(`${this.getBaseUrl()}/api/token/refresh`, {
|
|
58
|
-
method: 'POST',
|
|
59
|
-
headers: { 'Content-Type': 'application/json' },
|
|
60
|
-
body: JSON.stringify({ refresh_token: refreshToken }),
|
|
61
|
-
});
|
|
62
|
-
if (!response.ok)
|
|
63
|
-
return false;
|
|
64
|
-
const payload = await response.json();
|
|
65
|
-
const nextToken = payload.token || payload.access_token;
|
|
66
|
-
if (!nextToken)
|
|
67
|
-
return false;
|
|
68
|
-
this.config.set('authToken', nextToken);
|
|
69
|
-
if (payload.refresh_token) {
|
|
70
|
-
this.config.set('refreshToken', payload.refresh_token);
|
|
71
|
-
}
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
48
|
+
return this.authSession.getAccessToken();
|
|
77
49
|
}
|
|
78
50
|
async parseResponseBody(resp) {
|
|
79
51
|
const raw = await resp.text();
|
|
@@ -96,10 +68,10 @@ export class WalletCommand {
|
|
|
96
68
|
});
|
|
97
69
|
let token = this.getToken();
|
|
98
70
|
if (!token)
|
|
99
|
-
throw new
|
|
71
|
+
throw new CliCommandError('Not authenticated. Run: vigthoria login', { code: 'AUTH_REQUIRED', category: 'authentication' });
|
|
100
72
|
let resp = await runRequest(token);
|
|
101
73
|
if (resp.status === 401 || resp.status === 403) {
|
|
102
|
-
const refreshed = await this.
|
|
74
|
+
const refreshed = await this.authSession.refresh();
|
|
103
75
|
if (refreshed) {
|
|
104
76
|
token = this.getToken();
|
|
105
77
|
if (token) {
|
|
@@ -112,7 +84,11 @@ export class WalletCommand {
|
|
|
112
84
|
const err = body.error
|
|
113
85
|
|| body.message
|
|
114
86
|
|| `HTTP ${resp.status}`;
|
|
115
|
-
throw new
|
|
87
|
+
throw new CliCommandError(err, {
|
|
88
|
+
code: resp.status === 401 ? 'AUTH_SESSION_INVALID' : 'WALLET_REQUEST_FAILED',
|
|
89
|
+
category: resp.status === 401 ? 'authentication' : resp.status === 403 ? 'authorization' : undefined,
|
|
90
|
+
status: resp.status,
|
|
91
|
+
});
|
|
116
92
|
}
|
|
117
93
|
return body;
|
|
118
94
|
}
|
|
@@ -120,7 +96,7 @@ export class WalletCommand {
|
|
|
120
96
|
try {
|
|
121
97
|
const data = await this.apiFetch('/api/user/vigcoin/balance');
|
|
122
98
|
if (opts.json) {
|
|
123
|
-
console.log(
|
|
99
|
+
console.log(formatSuccessJson('wallet balance', data));
|
|
124
100
|
return;
|
|
125
101
|
}
|
|
126
102
|
console.log('');
|
|
@@ -142,8 +118,7 @@ export class WalletCommand {
|
|
|
142
118
|
console.log('');
|
|
143
119
|
}
|
|
144
120
|
catch (err) {
|
|
145
|
-
|
|
146
|
-
process.exit(1);
|
|
121
|
+
throw commandFailure(err, { code: 'WALLET_BALANCE_FAILED' });
|
|
147
122
|
}
|
|
148
123
|
}
|
|
149
124
|
async showHistory(opts = {}) {
|
|
@@ -151,7 +126,7 @@ export class WalletCommand {
|
|
|
151
126
|
try {
|
|
152
127
|
const data = await this.apiFetch(`/api/user/vigcoin/transactions?limit=${limit}`);
|
|
153
128
|
if (opts.json) {
|
|
154
|
-
console.log(
|
|
129
|
+
console.log(formatSuccessJson('wallet history', data));
|
|
155
130
|
return;
|
|
156
131
|
}
|
|
157
132
|
const txs = data.transactions || [];
|
|
@@ -172,15 +147,14 @@ export class WalletCommand {
|
|
|
172
147
|
console.log('');
|
|
173
148
|
}
|
|
174
149
|
catch (err) {
|
|
175
|
-
|
|
176
|
-
process.exit(1);
|
|
150
|
+
throw commandFailure(err, { code: 'WALLET_HISTORY_FAILED' });
|
|
177
151
|
}
|
|
178
152
|
}
|
|
179
153
|
async showCloudStatus(opts = {}) {
|
|
180
154
|
try {
|
|
181
155
|
const data = await this.apiFetch('/api/user/cloud-access/status');
|
|
182
156
|
if (opts.json) {
|
|
183
|
-
console.log(
|
|
157
|
+
console.log(formatSuccessJson('wallet cloud-status', data));
|
|
184
158
|
return;
|
|
185
159
|
}
|
|
186
160
|
console.log('');
|
|
@@ -213,8 +187,7 @@ export class WalletCommand {
|
|
|
213
187
|
console.log('');
|
|
214
188
|
}
|
|
215
189
|
catch (err) {
|
|
216
|
-
|
|
217
|
-
process.exit(1);
|
|
190
|
+
throw commandFailure(err, { code: 'WALLET_CLOUD_STATUS_FAILED' });
|
|
218
191
|
}
|
|
219
192
|
}
|
|
220
193
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
1
2
|
import { Config } from '../utils/config.js';
|
|
2
3
|
import { Logger } from '../utils/logger.js';
|
|
3
4
|
interface WorkflowOutputOptions {
|
|
@@ -35,4 +36,5 @@ export declare class WorkflowCommand {
|
|
|
35
36
|
run(workflowId: string, options: WorkflowRunOptions): Promise<void>;
|
|
36
37
|
status(executionId: string, options: WorkflowStatusOptions): Promise<void>;
|
|
37
38
|
}
|
|
39
|
+
export declare function registerWorkflowCommands(program: Command, config: Config, logger: Logger): void;
|
|
38
40
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
|
-
import {
|
|
2
|
+
import { createAPIClient } from '../utils/api-client-factory.js';
|
|
3
3
|
import { ProjectMemoryService } from '../utils/project-memory.js';
|
|
4
|
+
import { CliCommandError, commandFailure, formatSuccessJson } from '../utils/command-contract.js';
|
|
4
5
|
export class WorkflowCommand {
|
|
5
6
|
config;
|
|
6
7
|
logger;
|
|
@@ -8,20 +9,16 @@ export class WorkflowCommand {
|
|
|
8
9
|
constructor(config, logger) {
|
|
9
10
|
this.config = config;
|
|
10
11
|
this.logger = logger;
|
|
11
|
-
this.api =
|
|
12
|
+
this.api = createAPIClient(config, logger);
|
|
12
13
|
}
|
|
13
|
-
ensureAuthenticated(
|
|
14
|
+
ensureAuthenticated() {
|
|
14
15
|
if (this.config.isAuthenticated()) {
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
this.logger.error(message);
|
|
23
|
-
}
|
|
24
|
-
throw new Error(message);
|
|
18
|
+
throw new CliCommandError('Not authenticated. Run vigthoria login first.', {
|
|
19
|
+
code: 'AUTH_REQUIRED',
|
|
20
|
+
category: 'authentication',
|
|
21
|
+
});
|
|
25
22
|
}
|
|
26
23
|
parseJsonOption(rawValue, fieldName) {
|
|
27
24
|
if (!rawValue) {
|
|
@@ -30,16 +27,18 @@ export class WorkflowCommand {
|
|
|
30
27
|
try {
|
|
31
28
|
const parsed = JSON.parse(rawValue);
|
|
32
29
|
if (!parsed || Array.isArray(parsed) || typeof parsed !== 'object') {
|
|
33
|
-
throw new
|
|
30
|
+
throw new CliCommandError(`${fieldName} must be a JSON object.`, { code: 'INVALID_JSON_OPTION', category: 'usage' });
|
|
34
31
|
}
|
|
35
32
|
return parsed;
|
|
36
33
|
}
|
|
37
34
|
catch (error) {
|
|
38
|
-
|
|
35
|
+
if (error instanceof CliCommandError)
|
|
36
|
+
throw error;
|
|
37
|
+
throw new CliCommandError(`Invalid ${fieldName} JSON: ${error.message}`, { code: 'INVALID_JSON_OPTION', category: 'usage', cause: error });
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
printJson(payload) {
|
|
42
|
-
console.log(
|
|
40
|
+
printJson(command, payload) {
|
|
41
|
+
console.log(formatSuccessJson(command, payload));
|
|
43
42
|
}
|
|
44
43
|
createProjectMemory() {
|
|
45
44
|
return new ProjectMemoryService(process.cwd());
|
|
@@ -70,7 +69,7 @@ export class WorkflowCommand {
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
async templates(options) {
|
|
73
|
-
this.ensureAuthenticated(
|
|
72
|
+
this.ensureAuthenticated();
|
|
74
73
|
let templates;
|
|
75
74
|
try {
|
|
76
75
|
templates = await this.api.listVigFlowTemplates({
|
|
@@ -83,16 +82,10 @@ export class WorkflowCommand {
|
|
|
83
82
|
const msg = /not available|not reachable|not deployed/i.test(raw)
|
|
84
83
|
? raw
|
|
85
84
|
: `Workflow service is not reachable: ${raw}`;
|
|
86
|
-
|
|
87
|
-
this.printJson({ success: false, error: msg, templates: [] });
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
this.logger.error(msg);
|
|
91
|
-
}
|
|
92
|
-
return;
|
|
85
|
+
throw commandFailure(error, { code: 'WORKFLOW_TEMPLATES_FAILED', message: msg });
|
|
93
86
|
}
|
|
94
87
|
if (options.json) {
|
|
95
|
-
this.printJson(
|
|
88
|
+
this.printJson('workflow templates', { templates });
|
|
96
89
|
return;
|
|
97
90
|
}
|
|
98
91
|
this.logger.section('Workflow Templates');
|
|
@@ -108,7 +101,7 @@ export class WorkflowCommand {
|
|
|
108
101
|
]));
|
|
109
102
|
}
|
|
110
103
|
async list(options) {
|
|
111
|
-
this.ensureAuthenticated(
|
|
104
|
+
this.ensureAuthenticated();
|
|
112
105
|
let workflows;
|
|
113
106
|
try {
|
|
114
107
|
workflows = await this.api.listVigFlowWorkflows();
|
|
@@ -118,16 +111,10 @@ export class WorkflowCommand {
|
|
|
118
111
|
const msg = /not available|not reachable|not deployed/i.test(raw)
|
|
119
112
|
? raw
|
|
120
113
|
: `Workflow service is not reachable: ${raw}`;
|
|
121
|
-
|
|
122
|
-
this.printJson({ success: false, error: msg, workflows: [] });
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
this.logger.error(msg);
|
|
126
|
-
}
|
|
127
|
-
return;
|
|
114
|
+
throw commandFailure(error, { code: 'WORKFLOW_LIST_FAILED', message: msg });
|
|
128
115
|
}
|
|
129
116
|
if (options.json) {
|
|
130
|
-
this.printJson(
|
|
117
|
+
this.printJson('workflow list', { workflows });
|
|
131
118
|
return;
|
|
132
119
|
}
|
|
133
120
|
this.logger.section('Workflows');
|
|
@@ -144,14 +131,14 @@ export class WorkflowCommand {
|
|
|
144
131
|
]));
|
|
145
132
|
}
|
|
146
133
|
async useTemplate(templateId, options) {
|
|
147
|
-
this.ensureAuthenticated(
|
|
134
|
+
this.ensureAuthenticated();
|
|
148
135
|
const variables = this.parseJsonOption(options.variables, 'variables');
|
|
149
136
|
const workflow = await this.api.useVigFlowTemplate(templateId, {
|
|
150
137
|
name: options.name,
|
|
151
138
|
variables,
|
|
152
139
|
});
|
|
153
140
|
if (options.json) {
|
|
154
|
-
this.printJson(
|
|
141
|
+
this.printJson('workflow use-template', { workflow });
|
|
155
142
|
return;
|
|
156
143
|
}
|
|
157
144
|
this.logger.success(`Created workflow ${workflow.name}`);
|
|
@@ -161,7 +148,7 @@ export class WorkflowCommand {
|
|
|
161
148
|
}
|
|
162
149
|
}
|
|
163
150
|
async run(workflowId, options) {
|
|
164
|
-
this.ensureAuthenticated(
|
|
151
|
+
this.ensureAuthenticated();
|
|
165
152
|
const data = this.parseJsonOption(options.data, 'data');
|
|
166
153
|
const executionData = { ...data };
|
|
167
154
|
if (options.brain !== false) {
|
|
@@ -174,7 +161,7 @@ export class WorkflowCommand {
|
|
|
174
161
|
const execution = await this.api.runVigFlowWorkflow(workflowId, { data: executionData });
|
|
175
162
|
this.rememberWorkflowEvent(execution.error ? 'issue' : 'validation', `VigFlow workflow ${workflowId} execution ${execution.executionId || 'unknown'} finished with status ${execution.status}; nodes executed ${execution.nodesExecuted ?? 0}${execution.error ? `; error: ${execution.error}` : ''}.`);
|
|
176
163
|
if (options.json) {
|
|
177
|
-
this.printJson(
|
|
164
|
+
this.printJson('workflow run', { execution });
|
|
178
165
|
return;
|
|
179
166
|
}
|
|
180
167
|
this.logger.success(`Workflow execution ${execution.status}`);
|
|
@@ -185,13 +172,13 @@ export class WorkflowCommand {
|
|
|
185
172
|
}
|
|
186
173
|
}
|
|
187
174
|
async status(executionId, options) {
|
|
188
|
-
this.ensureAuthenticated(
|
|
175
|
+
this.ensureAuthenticated();
|
|
189
176
|
const execution = await this.api.getVigFlowExecutionStatus(executionId);
|
|
190
177
|
if (options.brain !== false) {
|
|
191
178
|
this.rememberWorkflowEvent(execution.status === 'failed' ? 'issue' : 'validation', `VigFlow execution ${execution.id} for workflow ${execution.workflowId} status ${execution.status}; nodes ${execution.nodesExecuted ?? 0}/${execution.totalNodes ?? '-'}.`);
|
|
192
179
|
}
|
|
193
180
|
if (options.json) {
|
|
194
|
-
this.printJson(
|
|
181
|
+
this.printJson('workflow status', { execution });
|
|
195
182
|
return;
|
|
196
183
|
}
|
|
197
184
|
this.logger.box([
|
|
@@ -204,3 +191,29 @@ export class WorkflowCommand {
|
|
|
204
191
|
].join('\n'), 'Workflow Status');
|
|
205
192
|
}
|
|
206
193
|
}
|
|
194
|
+
export function registerWorkflowCommands(program, config, logger) {
|
|
195
|
+
const workflowCommand = program.command('workflow').alias('flow')
|
|
196
|
+
.description('List, instantiate, and run repeatable VigFlow workflows');
|
|
197
|
+
workflowCommand.command('templates').alias('catalog').description('List available VigFlow templates')
|
|
198
|
+
.option('-c, --category <category>', 'Filter templates by category')
|
|
199
|
+
.option('-s, --search <query>', 'Search template names, descriptions, and tags')
|
|
200
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
201
|
+
.action(async (options) => new WorkflowCommand(config, logger).templates(options));
|
|
202
|
+
workflowCommand.command('list').alias('ls').description('List workflows created for the current account')
|
|
203
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
204
|
+
.action(async (options) => new WorkflowCommand(config, logger).list(options));
|
|
205
|
+
workflowCommand.command('use-template <templateId>').description('Create a workflow from a built-in or saved template')
|
|
206
|
+
.option('-n, --name <name>', 'Override the workflow name').option('-v, --variables <json>', 'Template variables as a JSON object')
|
|
207
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
208
|
+
.action(async (templateId, options) => new WorkflowCommand(config, logger).useTemplate(templateId, options));
|
|
209
|
+
workflowCommand.command('run <workflowId>').description('Run a workflow immediately')
|
|
210
|
+
.option('-d, --data <json>', 'Execution input data as a JSON object')
|
|
211
|
+
.option('--no-brain', 'Do not attach local Project Brain context to this workflow run')
|
|
212
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
213
|
+
.action(async (workflowId, options) => new WorkflowCommand(config, logger).run(workflowId, options));
|
|
214
|
+
workflowCommand.command('status <executionId>').description('Get the current or final status of a workflow execution')
|
|
215
|
+
.option('--no-brain', 'Do not remember this workflow status in local Project Brain')
|
|
216
|
+
.option('--json', 'Emit machine-readable JSON output', false)
|
|
217
|
+
.action(async (executionId, options) => new WorkflowCommand(config, logger).status(executionId, options));
|
|
218
|
+
workflowCommand.action(async () => new WorkflowCommand(config, logger).templates({}));
|
|
219
|
+
}
|