@guildai/cli 0.5.10 → 0.5.12
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/commands/agent/init.js +24 -3
- package/dist/commands/auth/login.js +3 -1
- package/dist/commands/container/destroy.d.ts +3 -0
- package/dist/commands/container/destroy.js +48 -0
- package/dist/commands/container/events.d.ts +3 -0
- package/dist/commands/container/events.js +44 -0
- package/dist/commands/container/exec.d.ts +3 -0
- package/dist/commands/container/exec.js +64 -0
- package/dist/commands/container/get.d.ts +3 -0
- package/dist/commands/container/get.js +33 -0
- package/dist/commands/container/list.d.ts +3 -0
- package/dist/commands/container/list.js +48 -0
- package/dist/commands/container-image/create.d.ts +3 -0
- package/dist/commands/container-image/create.js +41 -0
- package/dist/commands/container-image/get.d.ts +3 -0
- package/dist/commands/container-image/get.js +33 -0
- package/dist/commands/container-image/list.d.ts +3 -0
- package/dist/commands/container-image/list.js +44 -0
- package/dist/commands/job/get.d.ts +3 -0
- package/dist/commands/job/get.js +44 -0
- package/dist/commands/job/step-get.d.ts +3 -0
- package/dist/commands/job/step-get.js +40 -0
- package/dist/commands/trigger/create.js +4 -0
- package/dist/commands/trigger/update.js +4 -0
- package/dist/index.js +33 -2
- package/dist/lib/api-types.d.ts +135 -0
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/auth.js +29 -23
- package/dist/lib/config.js +0 -4
- package/dist/lib/generated-types.d.ts +2 -2
- package/dist/lib/generated-types.js +2 -0
- package/dist/lib/gk.d.ts +15 -0
- package/dist/lib/gk.js +91 -0
- package/dist/lib/output.d.ts +21 -16
- package/dist/lib/output.js +184 -1
- package/dist/lib/session-events.d.ts +1 -0
- package/dist/lib/table.d.ts +22 -0
- package/dist/lib/table.js +60 -0
- package/docs/CLI_WORKFLOW.md +9 -9
- package/docs/skills/agent-dev.md +11 -15
- package/package.json +2 -3
- package/dist/commands/agent/create.d.ts +0 -3
- package/dist/commands/agent/create.js +0 -132
package/dist/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import { createAuthLogoutCommand } from './commands/auth/logout.js';
|
|
|
11
11
|
import { createAuthStatusCommand } from './commands/auth/status.js';
|
|
12
12
|
import { createAuthTokenCommand } from './commands/auth/token.js';
|
|
13
13
|
import { createAgentListCommand } from './commands/agent/list.js';
|
|
14
|
-
import { createAgentCreateCommand } from './commands/agent/create.js';
|
|
15
14
|
import { createAgentGetCommand } from './commands/agent/get.js';
|
|
16
15
|
import { createAgentUpdateCommand } from './commands/agent/update.js';
|
|
17
16
|
import { createAgentVersionsCommand } from './commands/agent/versions.js';
|
|
@@ -60,6 +59,16 @@ import { createSessionEventsCommand } from './commands/session/events.js';
|
|
|
60
59
|
import { createSessionTasksCommand } from './commands/session/tasks.js';
|
|
61
60
|
import { createSessionCreateCommand } from './commands/session/create.js';
|
|
62
61
|
import { createSessionSendCommand } from './commands/session/send.js';
|
|
62
|
+
import { createContainerGetCommand } from './commands/container/get.js';
|
|
63
|
+
import { createContainerListCommand } from './commands/container/list.js';
|
|
64
|
+
import { createContainerEventsCommand } from './commands/container/events.js';
|
|
65
|
+
import { createContainerExecCommand } from './commands/container/exec.js';
|
|
66
|
+
import { createContainerDestroyCommand } from './commands/container/destroy.js';
|
|
67
|
+
import { createContainerImageListCommand } from './commands/container-image/list.js';
|
|
68
|
+
import { createContainerImageGetCommand } from './commands/container-image/get.js';
|
|
69
|
+
import { createContainerImageCreateCommand } from './commands/container-image/create.js';
|
|
70
|
+
import { createJobGetCommand } from './commands/job/get.js';
|
|
71
|
+
import { createJobStepGetCommand } from './commands/job/step-get.js';
|
|
63
72
|
import { createConfigListCommand } from './commands/config/list.js';
|
|
64
73
|
import { createConfigGetCommand } from './commands/config/get.js';
|
|
65
74
|
import { createConfigSetCommand } from './commands/config/set.js';
|
|
@@ -70,6 +79,7 @@ import { createMcpCommand } from './commands/mcp.js';
|
|
|
70
79
|
import { showSplashScreen, shouldShowSplash } from './lib/splash.js';
|
|
71
80
|
import { checkForUpdate } from './lib/update-check.js';
|
|
72
81
|
import { setupUnknownCommandSuggestions } from './lib/did-you-mean.js';
|
|
82
|
+
import { getEnabledGKs, isGKEnabled } from './lib/gk.js';
|
|
73
83
|
import chalk from 'chalk';
|
|
74
84
|
// ESM equivalent of __dirname
|
|
75
85
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -122,7 +132,6 @@ authCmd.addCommand(createAuthTokenCommand());
|
|
|
122
132
|
// Agent command group
|
|
123
133
|
const agentCmd = program.command('agent').description('Agent management');
|
|
124
134
|
agentCmd.addCommand(createAgentListCommand());
|
|
125
|
-
agentCmd.addCommand(createAgentCreateCommand());
|
|
126
135
|
agentCmd.addCommand(createAgentGetCommand());
|
|
127
136
|
agentCmd.addCommand(createAgentUpdateCommand());
|
|
128
137
|
agentCmd.addCommand(createAgentVersionsCommand());
|
|
@@ -208,6 +217,24 @@ triggerCmd.addCommand(createTriggerUpdateCommand());
|
|
|
208
217
|
triggerCmd.addCommand(createTriggerActivateCommand());
|
|
209
218
|
triggerCmd.addCommand(createTriggerDeactivateCommand());
|
|
210
219
|
triggerCmd.addCommand(createTriggerSessionsCommand());
|
|
220
|
+
// GK-gated commands: fetch enabled GKs and conditionally register command groups
|
|
221
|
+
const enabledGKs = await getEnabledGKs();
|
|
222
|
+
if (isGKEnabled('CONTAINERS', enabledGKs)) {
|
|
223
|
+
// Container command group
|
|
224
|
+
const containerCmd = program.command('container').description('Container management');
|
|
225
|
+
containerCmd.addCommand(createContainerListCommand());
|
|
226
|
+
containerCmd.addCommand(createContainerGetCommand());
|
|
227
|
+
containerCmd.addCommand(createContainerEventsCommand());
|
|
228
|
+
containerCmd.addCommand(createContainerExecCommand());
|
|
229
|
+
containerCmd.addCommand(createContainerDestroyCommand());
|
|
230
|
+
// Container image command group
|
|
231
|
+
const containerImageCmd = program
|
|
232
|
+
.command('container-image')
|
|
233
|
+
.description('Container image management');
|
|
234
|
+
containerImageCmd.addCommand(createContainerImageCreateCommand());
|
|
235
|
+
containerImageCmd.addCommand(createContainerImageListCommand());
|
|
236
|
+
containerImageCmd.addCommand(createContainerImageGetCommand());
|
|
237
|
+
}
|
|
211
238
|
// Session command group
|
|
212
239
|
const sessionCmd = program.command('session').description('Session management');
|
|
213
240
|
sessionCmd.addCommand(createSessionListCommand());
|
|
@@ -216,6 +243,10 @@ sessionCmd.addCommand(createSessionEventsCommand());
|
|
|
216
243
|
sessionCmd.addCommand(createSessionTasksCommand());
|
|
217
244
|
sessionCmd.addCommand(createSessionCreateCommand());
|
|
218
245
|
sessionCmd.addCommand(createSessionSendCommand());
|
|
246
|
+
// Job command group
|
|
247
|
+
const jobCmd = program.command('job').description('Job management');
|
|
248
|
+
jobCmd.addCommand(createJobGetCommand());
|
|
249
|
+
jobCmd.addCommand(createJobStepGetCommand());
|
|
219
250
|
// Config command group
|
|
220
251
|
const configCmd = program
|
|
221
252
|
.command('config')
|
package/dist/lib/api-types.d.ts
CHANGED
|
@@ -315,6 +315,141 @@ export interface Organization {
|
|
|
315
315
|
viewer_role: 'ADMIN' | 'MEMBER' | null;
|
|
316
316
|
}
|
|
317
317
|
export type OrganizationListResponse = PaginatedResponse<Organization>;
|
|
318
|
+
/**
|
|
319
|
+
* Session entity from API responses.
|
|
320
|
+
* Used by: session list, container list (as owner)
|
|
321
|
+
*/
|
|
322
|
+
export interface Session {
|
|
323
|
+
id: string;
|
|
324
|
+
session_type: 'chat' | 'agent_test' | 'time' | 'webhook';
|
|
325
|
+
name?: string;
|
|
326
|
+
workspace?: {
|
|
327
|
+
id: string;
|
|
328
|
+
name: string;
|
|
329
|
+
};
|
|
330
|
+
created_at: string;
|
|
331
|
+
updated_at: string;
|
|
332
|
+
}
|
|
333
|
+
export type ContainerStatus = 'STARTING' | 'RUNNING' | 'ERRORED' | 'DESTROYED';
|
|
334
|
+
/**
|
|
335
|
+
* Container image entity from the API.
|
|
336
|
+
*/
|
|
337
|
+
export interface ContainerImage {
|
|
338
|
+
id: string;
|
|
339
|
+
name: string;
|
|
340
|
+
image_name: string;
|
|
341
|
+
tag: string;
|
|
342
|
+
is_public: boolean;
|
|
343
|
+
created_at: string;
|
|
344
|
+
updated_at: string;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The actor that created the container (user or task agent).
|
|
348
|
+
*/
|
|
349
|
+
export interface ContainerActor {
|
|
350
|
+
id: string;
|
|
351
|
+
entity_type: string;
|
|
352
|
+
name?: string;
|
|
353
|
+
full_name?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Container entity from the API.
|
|
357
|
+
* Used by: container list
|
|
358
|
+
*/
|
|
359
|
+
export interface Container {
|
|
360
|
+
id: string;
|
|
361
|
+
status: ContainerStatus;
|
|
362
|
+
owner: Session;
|
|
363
|
+
created_by: ContainerActor;
|
|
364
|
+
image: ContainerImage;
|
|
365
|
+
created_at: string;
|
|
366
|
+
updated_at: string;
|
|
367
|
+
}
|
|
368
|
+
export type ContainerListResponse = PaginatedResponse<Container>;
|
|
369
|
+
/**
|
|
370
|
+
* Container image as returned in list responses.
|
|
371
|
+
*/
|
|
372
|
+
export interface ContainerImageListItem {
|
|
373
|
+
id: string;
|
|
374
|
+
name: string;
|
|
375
|
+
image_name: string;
|
|
376
|
+
tag: string;
|
|
377
|
+
is_public: boolean;
|
|
378
|
+
created_at: string;
|
|
379
|
+
updated_at: string;
|
|
380
|
+
}
|
|
381
|
+
export type ContainerImageListResponse = PaginatedResponse<ContainerImageListItem>;
|
|
382
|
+
export type ContainerEventStatus = 'PENDING' | 'ERROR' | 'SUCCESS';
|
|
383
|
+
/**
|
|
384
|
+
* Base fields shared by all container events.
|
|
385
|
+
*/
|
|
386
|
+
export interface ContainerEventBase {
|
|
387
|
+
id: string;
|
|
388
|
+
entity_type: string;
|
|
389
|
+
actor: ContainerActor;
|
|
390
|
+
status: ContainerEventStatus;
|
|
391
|
+
completed_at: string | null;
|
|
392
|
+
error: string | null;
|
|
393
|
+
created_at: string;
|
|
394
|
+
updated_at: string;
|
|
395
|
+
}
|
|
396
|
+
export interface ContainerEventCreate extends ContainerEventBase {
|
|
397
|
+
entity_type: 'EntContainerEventCreate';
|
|
398
|
+
is_local: boolean;
|
|
399
|
+
}
|
|
400
|
+
export interface ContainerEventDestroy extends ContainerEventBase {
|
|
401
|
+
entity_type: 'EntContainerEventDestroy';
|
|
402
|
+
found: boolean | null;
|
|
403
|
+
}
|
|
404
|
+
export interface ContainerEventCommand extends ContainerEventBase {
|
|
405
|
+
entity_type: 'EntContainerEventCommand';
|
|
406
|
+
command: string;
|
|
407
|
+
return_code: number | null;
|
|
408
|
+
stdout: string | null;
|
|
409
|
+
stderr: string | null;
|
|
410
|
+
}
|
|
411
|
+
export type ContainerEvent = ContainerEventCreate | ContainerEventDestroy | ContainerEventCommand;
|
|
412
|
+
export type ContainerEventListResponse = PaginatedResponse<ContainerEvent>;
|
|
413
|
+
export type JobType = 'VALIDATION' | 'PUBLISH' | 'PUBLISH_PRE_CHECK';
|
|
414
|
+
export type JobStatus = 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'ERRORED' | 'CANCELLED';
|
|
415
|
+
export type JobStepStatus = 'PENDING' | 'RUNNING' | 'SUCCEEDED' | 'FAILED' | 'SKIPPED' | 'ERRORED';
|
|
416
|
+
/**
|
|
417
|
+
* Job entity from the API.
|
|
418
|
+
* Used by: job get
|
|
419
|
+
*/
|
|
420
|
+
export interface Job {
|
|
421
|
+
id: string;
|
|
422
|
+
target_id: string;
|
|
423
|
+
job_type: JobType;
|
|
424
|
+
status: JobStatus;
|
|
425
|
+
started_at: string | null;
|
|
426
|
+
completed_at: string | null;
|
|
427
|
+
error_message: string | null;
|
|
428
|
+
created_at: string;
|
|
429
|
+
updated_at: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Job step entity from the API.
|
|
433
|
+
* Used by: job get (steps table)
|
|
434
|
+
*/
|
|
435
|
+
export interface JobStep {
|
|
436
|
+
id: string;
|
|
437
|
+
job: Job;
|
|
438
|
+
name: string;
|
|
439
|
+
status: JobStepStatus;
|
|
440
|
+
started_at: string | null;
|
|
441
|
+
completed_at: string | null;
|
|
442
|
+
content: string | null;
|
|
443
|
+
created_at: string;
|
|
444
|
+
updated_at: string;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Response from GET /jobs/:id/steps.
|
|
448
|
+
*/
|
|
449
|
+
export interface JobStepsResponse {
|
|
450
|
+
job_id: string;
|
|
451
|
+
steps: JobStep[];
|
|
452
|
+
}
|
|
318
453
|
/**
|
|
319
454
|
* Contents of guild.json file in agent directories.
|
|
320
455
|
*/
|
package/dist/lib/auth.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export declare function showBetaGuidance(): void;
|
|
|
50
50
|
* @param returnLabel - Optional friendly label for return button (e.g., "VSCode")
|
|
51
51
|
* @returns true if successful, false otherwise
|
|
52
52
|
*/
|
|
53
|
-
export declare function login(returnUrl?: string, returnLabel?: string): Promise<boolean>;
|
|
53
|
+
export declare function login(returnUrl?: string, returnLabel?: string, noBrowser?: boolean): Promise<boolean>;
|
|
54
54
|
/**
|
|
55
55
|
* Perform logout
|
|
56
56
|
*/
|
package/dist/lib/auth.js
CHANGED
|
@@ -196,36 +196,42 @@ export function showBetaGuidance() {
|
|
|
196
196
|
* @param returnLabel - Optional friendly label for return button (e.g., "VSCode")
|
|
197
197
|
* @returns true if successful, false otherwise
|
|
198
198
|
*/
|
|
199
|
-
export async function login(returnUrl, returnLabel) {
|
|
199
|
+
export async function login(returnUrl, returnLabel, noBrowser) {
|
|
200
200
|
const authUrl = getGuildcoreUrl();
|
|
201
201
|
try {
|
|
202
202
|
console.log(chalk.bold('\nGuild.ai Authentication'));
|
|
203
203
|
const deviceCode = await startDeviceFlow(authUrl, returnUrl, returnLabel);
|
|
204
204
|
// Display styled verification code box
|
|
205
205
|
displayVerificationCode(deviceCode.user_code, deviceCode.verification_uri_complete);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const { openBrowser } = await inquirer.prompt([
|
|
210
|
-
{
|
|
211
|
-
type: 'confirm',
|
|
212
|
-
name: 'openBrowser',
|
|
213
|
-
message: 'Press Enter to open browser in your default web browser...',
|
|
214
|
-
default: true,
|
|
215
|
-
},
|
|
216
|
-
]);
|
|
217
|
-
if (!openBrowser) {
|
|
218
|
-
console.error(chalk.red('✗ Authentication cancelled by user'));
|
|
219
|
-
return false;
|
|
206
|
+
const skipBrowser = noBrowser || process.stdin.isTTY !== true;
|
|
207
|
+
if (skipBrowser) {
|
|
208
|
+
console.log(chalk.dim('Open the URL above in your browser to complete authentication.'));
|
|
220
209
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
210
|
+
else {
|
|
211
|
+
// Wait for user to press Enter before opening browser
|
|
212
|
+
// This gives them time to see and copy the code before browser opens
|
|
213
|
+
// Critical for VSCode integration where browser may open full screen
|
|
214
|
+
const { openBrowser } = await inquirer.prompt([
|
|
215
|
+
{
|
|
216
|
+
type: 'confirm',
|
|
217
|
+
name: 'openBrowser',
|
|
218
|
+
message: 'Press Enter to open browser in your default web browser...',
|
|
219
|
+
default: true,
|
|
220
|
+
},
|
|
221
|
+
]);
|
|
222
|
+
if (!openBrowser) {
|
|
223
|
+
console.error(chalk.red('✗ Authentication cancelled by user'));
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
// Open URL in default browser after user confirmation
|
|
227
|
+
try {
|
|
228
|
+
const open = (await import('open')).default;
|
|
229
|
+
await open(deviceCode.verification_uri_complete);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
// Fallback if open fails - user can manually open URL
|
|
233
|
+
console.log(chalk.red('✗ Could not open browser automatically. Please visit the URL manually.\n'));
|
|
234
|
+
}
|
|
229
235
|
}
|
|
230
236
|
const token = await pollForToken(authUrl, deviceCode.device_code, deviceCode.interval);
|
|
231
237
|
if (token) {
|
package/dist/lib/config.js
CHANGED
|
@@ -46,10 +46,6 @@ export const IAP_CLIENT_ID = SHARED_IAP_CONFIG.clientId;
|
|
|
46
46
|
export const IAP_SERVICE_ACCOUNT = SHARED_IAP_CONFIG.serviceAccount;
|
|
47
47
|
/**
|
|
48
48
|
* GuildCore URL constants
|
|
49
|
-
*
|
|
50
|
-
* TODO: Consider implementing proper feature flags (GK) for the CLI instead of
|
|
51
|
-
* these hardcoded shortcuts. For now, --shared and --local are undocumented
|
|
52
|
-
* developer conveniences.
|
|
53
49
|
*/
|
|
54
50
|
const PROD_GUILDCORE_URL = 'https://app.guild.ai/api';
|
|
55
51
|
const SHARED_GUILDCORE_URL = 'https://shared.guildai.dev/api';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const WEBHOOK_SERVICES: readonly ["AZURE_DEVOPS", "BITBUCKET", "CYPRESS", "GITHUB", "GOOGLE_DOCS", "GOOGLE_COMPUTE", "GOOGLE_LOGGING", "JIRA", "LINEAR", "NEWRELIC", "NOTION", "SLACK", "TESTRAIL", "ZENDESK"];
|
|
1
|
+
export declare const WEBHOOK_SERVICES: readonly ["AZURE_DEVOPS", "BITBUCKET", "CURL", "CYPRESS", "GITHUB", "GOOGLE_DOCS", "GOOGLE_COMPUTE", "GOOGLE_LOGGING", "JIRA", "LINEAR", "NEWRELIC", "NOTION", "SLACK", "TESTRAIL", "ZENDESK"];
|
|
2
2
|
export type WebhookService = (typeof WEBHOOK_SERVICES)[number];
|
|
3
|
-
export declare const TIME_TRIGGER_FREQUENCIES: readonly ["HOURLY", "DAILY", "WEEKLY", "MONTHLY"];
|
|
3
|
+
export declare const TIME_TRIGGER_FREQUENCIES: readonly ["HOURLY", "DAILY", "WEEKLY", "MONTHLY", "CRON"];
|
|
4
4
|
export type TimeTriggerFrequency = (typeof TIME_TRIGGER_FREQUENCIES)[number];
|
|
5
5
|
//# sourceMappingURL=generated-types.d.ts.map
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export const WEBHOOK_SERVICES = [
|
|
11
11
|
'AZURE_DEVOPS',
|
|
12
12
|
'BITBUCKET',
|
|
13
|
+
'CURL',
|
|
13
14
|
'CYPRESS',
|
|
14
15
|
'GITHUB',
|
|
15
16
|
'GOOGLE_DOCS',
|
|
@@ -29,5 +30,6 @@ export const TIME_TRIGGER_FREQUENCIES = [
|
|
|
29
30
|
'DAILY',
|
|
30
31
|
'WEEKLY',
|
|
31
32
|
'MONTHLY',
|
|
33
|
+
'CRON',
|
|
32
34
|
];
|
|
33
35
|
//# sourceMappingURL=generated-types.js.map
|
package/dist/lib/gk.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch the set of GK names enabled for the current user.
|
|
3
|
+
*
|
|
4
|
+
* Returns null when the enabled set cannot be determined (not authenticated,
|
|
5
|
+
* network error, etc.). Callers should treat null as "show everything" (fail-open).
|
|
6
|
+
*/
|
|
7
|
+
export declare function getEnabledGKs(): Promise<Set<string> | null>;
|
|
8
|
+
/**
|
|
9
|
+
* Check whether a specific GK is enabled for the current user.
|
|
10
|
+
*
|
|
11
|
+
* When enabledGKs is null (could not be determined), returns true (fail-open)
|
|
12
|
+
* so that commands are not hidden due to transient errors.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isGKEnabled(gk: string, enabledGKs: Set<string> | null): boolean;
|
|
15
|
+
//# sourceMappingURL=gk.d.ts.map
|
package/dist/lib/gk.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright 2026 Guild.ai
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import * as fs from 'fs/promises';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import axios from 'axios';
|
|
6
|
+
import { getGlobalConfigDir } from './guild-config.js';
|
|
7
|
+
import { getGuildcoreUrl } from './config.js';
|
|
8
|
+
import { getAuthToken } from './auth.js';
|
|
9
|
+
import { getIapHeaders } from './iap.js';
|
|
10
|
+
import { debug } from './errors.js';
|
|
11
|
+
const GK_CACHE_FILE = 'gk-cache.json';
|
|
12
|
+
const GK_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
13
|
+
function getCachePath() {
|
|
14
|
+
return path.join(getGlobalConfigDir(), GK_CACHE_FILE);
|
|
15
|
+
}
|
|
16
|
+
async function readCache(host) {
|
|
17
|
+
try {
|
|
18
|
+
const content = await fs.readFile(getCachePath(), 'utf-8');
|
|
19
|
+
const entry = JSON.parse(content);
|
|
20
|
+
if (entry.host === host && Date.now() - entry.ts < GK_CACHE_TTL_MS) {
|
|
21
|
+
debug('GK cache hit for %s', host);
|
|
22
|
+
return entry.gks;
|
|
23
|
+
}
|
|
24
|
+
debug('GK cache stale or host mismatch');
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
debug('GK cache not found or unreadable');
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
async function writeCache(host, gks) {
|
|
32
|
+
const configDir = getGlobalConfigDir();
|
|
33
|
+
await fs.mkdir(configDir, { recursive: true });
|
|
34
|
+
await fs.writeFile(getCachePath(), JSON.stringify({ gks, ts: Date.now(), host }));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Fetch the set of GK names enabled for the current user.
|
|
38
|
+
*
|
|
39
|
+
* Returns null when the enabled set cannot be determined (not authenticated,
|
|
40
|
+
* network error, etc.). Callers should treat null as "show everything" (fail-open).
|
|
41
|
+
*/
|
|
42
|
+
export async function getEnabledGKs() {
|
|
43
|
+
const token = await getAuthToken();
|
|
44
|
+
if (!token) {
|
|
45
|
+
debug('Not authenticated, skipping GK fetch');
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const baseUrl = getGuildcoreUrl();
|
|
49
|
+
let host;
|
|
50
|
+
try {
|
|
51
|
+
host = new URL(baseUrl).host;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const cached = await readCache(host);
|
|
57
|
+
if (cached) {
|
|
58
|
+
return new Set(cached);
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
const iapHeaders = await getIapHeaders(baseUrl);
|
|
62
|
+
const response = await axios.get(`${baseUrl}/gks/enabled`, {
|
|
63
|
+
headers: {
|
|
64
|
+
...iapHeaders,
|
|
65
|
+
Authorization: `Bearer ${token}`,
|
|
66
|
+
Accept: 'application/json',
|
|
67
|
+
},
|
|
68
|
+
timeout: 5000,
|
|
69
|
+
});
|
|
70
|
+
const gkNames = response.data.gks.map((g) => g.name);
|
|
71
|
+
await writeCache(host, gkNames);
|
|
72
|
+
debug('Fetched %d enabled GKs', gkNames.length);
|
|
73
|
+
return new Set(gkNames);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
debug('Failed to fetch GKs: %s', error);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check whether a specific GK is enabled for the current user.
|
|
82
|
+
*
|
|
83
|
+
* When enabledGKs is null (could not be determined), returns true (fail-open)
|
|
84
|
+
* so that commands are not hidden due to transient errors.
|
|
85
|
+
*/
|
|
86
|
+
export function isGKEnabled(gk, enabledGKs) {
|
|
87
|
+
if (!enabledGKs)
|
|
88
|
+
return true;
|
|
89
|
+
return enabledGKs.has(gk);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=gk.js.map
|
package/dist/lib/output.d.ts
CHANGED
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { type Spinner } from './progress.js';
|
|
2
|
-
import type { Agent, AgentVersion, Context, Pagination, Workspace, WorkspaceAgent, Trigger } from './api-types.js';
|
|
3
|
-
/**
|
|
4
|
-
* Session type from API responses
|
|
5
|
-
*/
|
|
6
|
-
interface Session {
|
|
7
|
-
id: string;
|
|
8
|
-
session_type: 'chat' | 'agent_test' | 'time' | 'webhook';
|
|
9
|
-
name?: string;
|
|
10
|
-
workspace?: {
|
|
11
|
-
id: string;
|
|
12
|
-
name: string;
|
|
13
|
-
};
|
|
14
|
-
created_at: string;
|
|
15
|
-
updated_at: string;
|
|
16
|
-
}
|
|
2
|
+
import type { Agent, AgentVersion, Container, ContainerEvent, ContainerImageListItem, Context, JobStep, Pagination, Session, Workspace, WorkspaceAgent, Trigger } from './api-types.js';
|
|
17
3
|
/**
|
|
18
4
|
* Format an agent list as a human-readable table.
|
|
19
5
|
* Shared by agent list and agent search commands.
|
|
@@ -49,6 +35,26 @@ export declare function formatSessionTable(sessions: Session[], pagination: Pagi
|
|
|
49
35
|
* Used by trigger list command.
|
|
50
36
|
*/
|
|
51
37
|
export declare function formatTriggerTable(triggers: Trigger[], pagination: Pagination): void;
|
|
38
|
+
/**
|
|
39
|
+
* Format a container list as a human-readable table.
|
|
40
|
+
* Used by container list command.
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatContainerTable(containers: Container[], pagination: Pagination): void;
|
|
43
|
+
/**
|
|
44
|
+
* Format a container image list as a human-readable table.
|
|
45
|
+
* Used by container-image list command.
|
|
46
|
+
*/
|
|
47
|
+
export declare function formatContainerImageTable(images: ContainerImageListItem[], pagination: Pagination): void;
|
|
48
|
+
/**
|
|
49
|
+
* Format a container event list as a human-readable table.
|
|
50
|
+
* Used by container events command.
|
|
51
|
+
*/
|
|
52
|
+
export declare function formatContainerEventTable(events: ContainerEvent[], pagination: Pagination): void;
|
|
53
|
+
/**
|
|
54
|
+
* Format job steps as a human-readable table.
|
|
55
|
+
* Used by job get command.
|
|
56
|
+
*/
|
|
57
|
+
export declare function formatJobStepTable(steps: JobStep[]): void;
|
|
52
58
|
/**
|
|
53
59
|
* Output writer interface for consistent CLI output
|
|
54
60
|
*
|
|
@@ -108,5 +114,4 @@ export declare class JSONOutputWriter implements OutputWriter {
|
|
|
108
114
|
* Create output writer based on current mode
|
|
109
115
|
*/
|
|
110
116
|
export declare function createOutputWriter(): OutputWriter;
|
|
111
|
-
export {};
|
|
112
117
|
//# sourceMappingURL=output.d.ts.map
|