@guildai/cli 0.5.13 → 0.6.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.
Files changed (54) hide show
  1. package/dist/commands/agent/clone.js +3 -1
  2. package/dist/commands/agent/code.js +3 -2
  3. package/dist/commands/agent/fork.js +40 -14
  4. package/dist/commands/agent/get.js +3 -2
  5. package/dist/commands/agent/grep.js +61 -31
  6. package/dist/commands/agent/publish.js +3 -2
  7. package/dist/commands/agent/revalidate.js +4 -3
  8. package/dist/commands/agent/search.js +3 -3
  9. package/dist/commands/agent/tags/add.js +4 -3
  10. package/dist/commands/agent/tags/list.js +3 -2
  11. package/dist/commands/agent/tags/remove.js +4 -3
  12. package/dist/commands/agent/tags/set.js +3 -2
  13. package/dist/commands/agent/unpublish.js +3 -2
  14. package/dist/commands/agent/update.js +9 -8
  15. package/dist/commands/agent/versions.js +3 -2
  16. package/dist/commands/agent/workspaces.js +3 -2
  17. package/dist/commands/credentials/endpoint-list.d.ts +3 -0
  18. package/dist/commands/credentials/endpoint-list.js +87 -0
  19. package/dist/commands/credentials/list.d.ts +3 -0
  20. package/dist/commands/{container → credentials}/list.js +11 -10
  21. package/dist/commands/credentials/policy-create.d.ts +3 -0
  22. package/dist/commands/credentials/policy-create.js +66 -0
  23. package/dist/commands/credentials/policy-delete.d.ts +3 -0
  24. package/dist/commands/{container/get.js → credentials/policy-delete.js} +9 -9
  25. package/dist/commands/credentials/policy-list.d.ts +3 -0
  26. package/dist/commands/{container-image/list.js → credentials/policy-list.js} +9 -9
  27. package/dist/commands/credentials/policy-update.d.ts +3 -0
  28. package/dist/commands/credentials/policy-update.js +66 -0
  29. package/dist/commands/trigger/create.js +35 -19
  30. package/dist/commands/workspace/select.js +0 -1
  31. package/dist/index.js +22 -27
  32. package/dist/lib/agent-helpers.d.ts +8 -0
  33. package/dist/lib/agent-helpers.js +15 -0
  34. package/dist/lib/api-types.d.ts +52 -78
  35. package/dist/lib/auth.js +7 -4
  36. package/dist/lib/output.d.ts +3 -16
  37. package/dist/lib/output.js +43 -109
  38. package/dist/mcp/tools.js +1 -1
  39. package/docs/CLI_WORKFLOW.md +4 -2
  40. package/docs/skills/agent-dev.md +2 -2
  41. package/package.json +3 -3
  42. package/dist/commands/container/destroy.d.ts +0 -3
  43. package/dist/commands/container/destroy.js +0 -48
  44. package/dist/commands/container/events.d.ts +0 -3
  45. package/dist/commands/container/events.js +0 -44
  46. package/dist/commands/container/exec.d.ts +0 -3
  47. package/dist/commands/container/exec.js +0 -64
  48. package/dist/commands/container/get.d.ts +0 -3
  49. package/dist/commands/container/list.d.ts +0 -3
  50. package/dist/commands/container-image/create.d.ts +0 -3
  51. package/dist/commands/container-image/create.js +0 -41
  52. package/dist/commands/container-image/get.d.ts +0 -3
  53. package/dist/commands/container-image/get.js +0 -33
  54. package/dist/commands/container-image/list.d.ts +0 -3
@@ -8,6 +8,7 @@ import * as path from 'path';
8
8
  import { getAuthenticatedUrl } from '../../lib/auth.js';
9
9
  import { runGit, GitError, formatGitError, installPrePushHook } from '../../lib/git.js';
10
10
  import { createOutputWriter } from '../../lib/output.js';
11
+ import { resolveAgentRef } from '../../lib/agent-helpers.js';
11
12
  async function isDirectoryEmpty(dirPath) {
12
13
  try {
13
14
  const files = await fs.readdir(dirPath);
@@ -30,7 +31,8 @@ export function createAgentCloneCommand() {
30
31
  try {
31
32
  // Fetch agent details
32
33
  const client = new GuildAPIClient();
33
- const agent = await client.get(`/agents/${agentId}`);
34
+ const resolvedId = await resolveAgentRef(client, agentId);
35
+ const agent = await client.get(`/agents/${resolvedId}`);
34
36
  if (!agent.git_url) {
35
37
  output.error('Error: Agent does not have a git repository', 'This agent may not have been initialized with git.');
36
38
  process.exit(1);
@@ -3,7 +3,7 @@
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
5
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
6
- import { getAgentId } from '../../lib/agent-helpers.js';
6
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
7
7
  import { createOutputWriter } from '../../lib/output.js';
8
8
  import * as fs from 'fs/promises';
9
9
  import * as path from 'path';
@@ -22,7 +22,8 @@ export function createAgentCodeCommand() {
22
22
  const includeDraft = options.draft ? '1' : '0';
23
23
  let files;
24
24
  try {
25
- files = await client.get(`/agents/${agentId}/code?include_unpublished=${includeDraft}`);
25
+ const resolvedId = await resolveAgentRef(client, agentId);
26
+ files = await client.get(`/agents/${resolvedId}/code?include_unpublished=${includeDraft}`);
26
27
  }
27
28
  catch (error) {
28
29
  const formattedError = handleAxiosError(error);
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
5
6
  import { handleAxiosError, ErrorCodes, debug } from '../../lib/errors.js';
6
7
  import * as fs from 'fs/promises';
7
8
  import * as readline from 'readline';
@@ -47,21 +48,48 @@ export function createAgentForkCommand() {
47
48
  const cmd = new Command('fork');
48
49
  cmd
49
50
  .description('Fork an existing agent version to create a new agent')
50
- .argument('<agent-id>:<version-id>', 'Source agent and version (e.g., agent_abc:version_xyz)')
51
+ .argument('[identifier]', 'Agent ID, full name, or agent:version (e.g., owner/agent-name:version_xyz)')
51
52
  .option('--name <name>', 'Name for the forked agent')
52
53
  .option('--description <desc>', 'Description for the forked agent')
53
54
  .option('--directory <path>', 'Target directory for clone')
54
55
  .option('--owner <owner-id>', 'Owner account (user or organization ID)')
55
- .action(async (sourceArg, options) => {
56
+ .action(async (identifierArg, options) => {
56
57
  const output = createOutputWriter();
57
58
  try {
58
- // Parse agent-id:version-id format
59
- const parts = sourceArg.split(':');
60
- if (parts.length !== 2 || !parts[0] || !parts[1]) {
61
- output.error('Error: Invalid argument format', `Expected: <agent-id>:<version-id>\nExample: guild agent fork agent_abc123:version_xyz789\n\nTo find versions:\n guild agent versions ${parts[0] || '<agent-id>'}`);
62
- process.exit(1);
59
+ // Resolve agent ID and optional version ID
60
+ let sourceAgentId;
61
+ let sourceVersionId;
62
+ if (identifierArg && identifierArg.includes(':')) {
63
+ // Explicit agent:version format
64
+ const colonIndex = identifierArg.lastIndexOf(':');
65
+ const agentPart = identifierArg.substring(0, colonIndex);
66
+ sourceVersionId = identifierArg.substring(colonIndex + 1);
67
+ if (!agentPart || !sourceVersionId) {
68
+ output.error('Error: Invalid argument format', 'Expected: [identifier] or [identifier]:[version-id]\nExample: guild agent fork owner/agent-name:version_xyz\n\nTo find versions:\n guild agent versions <agent-id>');
69
+ process.exit(1);
70
+ }
71
+ const resolved = await getAgentId(agentPart);
72
+ sourceAgentId = resolved.agentId;
73
+ }
74
+ else {
75
+ // No version specified — resolve agent, then find latest published
76
+ const resolved = await getAgentId(identifierArg);
77
+ sourceAgentId = resolved.agentId;
78
+ }
79
+ // Auto-resolve version if not specified
80
+ const client = new GuildAPIClient();
81
+ sourceAgentId = await resolveAgentRef(client, sourceAgentId);
82
+ if (!sourceVersionId) {
83
+ const versions = await client.get(`/agents/${sourceAgentId}/versions`);
84
+ const published = versions.items
85
+ .filter((v) => v.status === 'PUBLISHED')
86
+ .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
87
+ if (published.length === 0) {
88
+ output.error('No published versions found', `Agent ${sourceAgentId} has no published versions to fork.\n\nTo see all versions:\n guild agent versions ${sourceAgentId}`);
89
+ process.exit(1);
90
+ }
91
+ sourceVersionId = published[0].id;
63
92
  }
64
- const [sourceAgentId, sourceVersionId] = parts;
65
93
  // Determine name (validate before API call for better UX)
66
94
  let agentName = options.name;
67
95
  if (!agentName) {
@@ -73,7 +101,7 @@ export function createAgentForkCommand() {
73
101
  }
74
102
  }
75
103
  else {
76
- output.error('Error: Agent name required in non-interactive mode', `Provide a name:\n guild agent fork ${sourceArg} --name my-forked-agent\n\nOr run interactively to be prompted.`);
104
+ output.error('Error: Agent name required in non-interactive mode', `Provide a name:\n guild agent fork ${identifierArg || '<identifier>'} --name my-forked-agent\n\nOr run interactively to be prompted.`);
77
105
  process.exit(1);
78
106
  }
79
107
  }
@@ -92,12 +120,11 @@ export function createAgentForkCommand() {
92
120
  if (dirExists) {
93
121
  const isEmpty = await isDirectoryEmpty(targetDir);
94
122
  if (!isEmpty) {
95
- output.error(`Error: Directory '${targetDir}' already exists and is not empty`, `Choose a different directory:\n guild agent fork ${sourceArg} --directory ./different-path\n\nOr remove the existing directory first.`);
123
+ output.error(`Error: Directory '${targetDir}' already exists and is not empty`, `Choose a different directory:\n guild agent fork ${identifierArg || '<identifier>'} --directory ./different-path\n\nOr remove the existing directory first.`);
96
124
  process.exit(1);
97
125
  }
98
126
  }
99
- // Now fetch source version from API (after local validations)
100
- const client = new GuildAPIClient();
127
+ // Fetch source version from API (after local validations)
101
128
  const sourceVersion = await client.get(`/agents/${sourceAgentId}/versions/${sourceVersionId}`);
102
129
  output.progress(`✓ Fetched source version from '${sourceVersion.agent.name}' (${sourceVersionId.substring(0, 12)})`);
103
130
  // Determine description
@@ -174,8 +201,7 @@ export function createAgentForkCommand() {
174
201
  process.exit(1);
175
202
  }
176
203
  if (formattedError.code === ErrorCodes.NOT_FOUND) {
177
- const [sourceAgentId] = sourceArg.split(':');
178
- output.error(`Error: Version not found: ${sourceArg}`, `Check available versions:\n guild agent versions ${sourceAgentId}`);
204
+ output.error(`Error: Agent or version not found: ${identifierArg || '<identifier>'}`, `Check available versions:\n guild agent versions <agent-id>`);
179
205
  process.exit(1);
180
206
  }
181
207
  if (formattedError.code === ErrorCodes.CONN_REFUSED) {
@@ -3,7 +3,7 @@
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
5
  import { getAuthToken } from '../../lib/auth.js';
6
- import { getAgentId } from '../../lib/agent-helpers.js';
6
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
7
7
  import { handleAxiosError } from '../../lib/errors.js';
8
8
  import { createOutputWriter } from '../../lib/output.js';
9
9
  export function createAgentGetCommand() {
@@ -22,7 +22,8 @@ export function createAgentGetCommand() {
22
22
  // Get agent ID from argument or guild.json
23
23
  const { agentId } = await getAgentId(idArg);
24
24
  const client = new GuildAPIClient();
25
- const response = await client.get(`/agents/${agentId}`);
25
+ const resolvedId = await resolveAgentRef(client, agentId);
26
+ const response = await client.get(`/agents/${resolvedId}`);
26
27
  output.data(response);
27
28
  }
28
29
  catch (error) {
@@ -5,12 +5,14 @@ import { GuildAPIClient } from '../../lib/api-client.js';
5
5
  import { getAuthToken } from '../../lib/auth.js';
6
6
  import { createOutputWriter } from '../../lib/output.js';
7
7
  import { handleAxiosError } from '../../lib/errors.js';
8
+ import { loadLocalConfig } from '../../lib/guild-config.js';
8
9
  export function createAgentGrepCommand() {
9
10
  const cmd = new Command('grep');
10
11
  cmd
11
12
  .description('Search agent files for a matching pattern')
12
13
  .argument('[pattern]', 'JavaScript regex for which to search: all lines matching this pattern will be printed')
13
- .option('--published', 'Only search published agents')
14
+ .option('--all', 'Search all agents (default: current agent only)')
15
+ .option('--published', 'Only search published agents (requires --all)')
14
16
  .action(grep);
15
17
  return cmd;
16
18
  }
@@ -36,36 +38,11 @@ async function grep(patternArg, options) {
36
38
  process.exit(1);
37
39
  }
38
40
  const client = new GuildAPIClient();
39
- let offset = 0;
40
- while (true) {
41
- const params = new URLSearchParams();
42
- params.append('offset', `${offset}`);
43
- params.append('limit', `${BATCH_SIZE}`);
44
- if (options.published) {
45
- params.append('published_only', 'true');
46
- }
47
- const response = await client.get(`/agents?${params.toString()}`);
48
- await Promise.all(response.items.map(async (agent) => {
49
- let files = [];
50
- try {
51
- files = await client.get(`/agents/${agent.id}/code`);
52
- }
53
- catch (ex) {
54
- const formattedError = handleAxiosError(ex);
55
- output.error(`${agent.owner?.name}/${agent.name}: ${formattedError.details}`);
56
- return;
57
- }
58
- for (const { path, content } of files) {
59
- content.split('\n').forEach((line, lineNumber) => {
60
- if (patternRE.test(line)) {
61
- output.progress(`${agent.owner?.name}/${agent.name}/${path}:${lineNumber + 1}:${line}`);
62
- }
63
- });
64
- }
65
- }));
66
- offset += response.pagination.limit;
67
- if (!response.pagination.has_more)
68
- break;
41
+ if (options.all) {
42
+ await grepAllAgents(client, patternRE, options.published, output);
43
+ }
44
+ else {
45
+ await grepCurrentAgent(client, patternRE, output);
69
46
  }
70
47
  }
71
48
  catch (error) {
@@ -74,4 +51,57 @@ async function grep(patternArg, options) {
74
51
  process.exit(1);
75
52
  }
76
53
  }
54
+ function searchFiles(files, patternRE, prefix, output) {
55
+ for (const { path, content } of files) {
56
+ content.split('\n').forEach((line, lineNumber) => {
57
+ if (patternRE.test(line)) {
58
+ output.progress(`${prefix}${path}:${lineNumber + 1}:${line}`);
59
+ }
60
+ });
61
+ }
62
+ }
63
+ async function grepCurrentAgent(client, patternRE, output) {
64
+ const config = await loadLocalConfig();
65
+ if (!config?.agent_id) {
66
+ output.error('Not in an agent directory.', 'Either run from an agent directory with guild.json:\n cd <agent-directory>\n guild agent grep <pattern>\n\nOr search all agents:\n guild agent grep <pattern> --all');
67
+ process.exit(1);
68
+ }
69
+ let files = [];
70
+ try {
71
+ files = await client.get(`/agents/${config.agent_id}/code`);
72
+ }
73
+ catch (ex) {
74
+ const formattedError = handleAxiosError(ex);
75
+ output.error(`Failed to fetch agent code: ${formattedError.details}`);
76
+ process.exit(1);
77
+ }
78
+ searchFiles(files, patternRE, '', output);
79
+ }
80
+ async function grepAllAgents(client, patternRE, publishedOnly, output) {
81
+ let offset = 0;
82
+ while (true) {
83
+ const params = new URLSearchParams();
84
+ params.append('offset', `${offset}`);
85
+ params.append('limit', `${BATCH_SIZE}`);
86
+ if (publishedOnly) {
87
+ params.append('published_only', 'true');
88
+ }
89
+ const response = await client.get(`/agents?${params.toString()}`);
90
+ await Promise.all(response.items.map(async (agent) => {
91
+ let files = [];
92
+ try {
93
+ files = await client.get(`/agents/${agent.id}/code`);
94
+ }
95
+ catch (ex) {
96
+ const formattedError = handleAxiosError(ex);
97
+ output.error(`${agent.owner?.name}/${agent.name}: ${formattedError.details}`);
98
+ return;
99
+ }
100
+ searchFiles(files, patternRE, `${agent.owner?.name}/${agent.name}/`, output);
101
+ }));
102
+ offset += response.pagination.limit;
103
+ if (!response.pagination.has_more)
104
+ break;
105
+ }
106
+ }
77
107
  //# sourceMappingURL=grep.js.map
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
- import { getAgentId } from '../../lib/agent-helpers.js';
5
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
7
  import { pollUntilComplete } from '../../lib/polling.js';
8
8
  import { createOutputWriter } from '../../lib/output.js';
@@ -18,8 +18,9 @@ export function createAgentPublishCommand() {
18
18
  const client = new GuildAPIClient();
19
19
  // Resolve agent ID
20
20
  const { agentId, config } = await getAgentId(agentIdArg);
21
+ const resolvedId = await resolveAgentRef(client, agentId);
21
22
  // Fetch all versions
22
- const response = await client.get(`/agents/${agentId}/versions`);
23
+ const response = await client.get(`/agents/${resolvedId}/versions`);
23
24
  // Find latest DRAFT version
24
25
  const draftVersions = response.items
25
26
  .filter((v) => v.status === 'DRAFT')
@@ -4,7 +4,7 @@ import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
5
  import { getGuildcoreUrl } from '../../lib/config.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
- import { getAgentId } from '../../lib/agent-helpers.js';
7
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
8
8
  import { createOutputWriter } from '../../lib/output.js';
9
9
  export function createAgentRevalidateCommand() {
10
10
  const cmd = new Command('revalidate');
@@ -19,10 +19,11 @@ export function createAgentRevalidateCommand() {
19
19
  const baseUrl = getGuildcoreUrl();
20
20
  const client = new GuildAPIClient({ baseUrl });
21
21
  try {
22
+ const resolvedId = await resolveAgentRef(client, agentId);
22
23
  let versionId = versionIdArg;
23
24
  // If no version ID provided, get the latest version
24
25
  if (!versionId) {
25
- const versions = await client.get(`/agents/${agentId}/versions?limit=1&offset=0`);
26
+ const versions = await client.get(`/agents/${resolvedId}/versions?limit=1&offset=0`);
26
27
  if (!versions.items || versions.items.length === 0) {
27
28
  output.error('No versions found for this agent.', `The agent may still be initializing. Check status:\n guild agent get ${agentId}`);
28
29
  process.exit(1);
@@ -30,7 +31,7 @@ export function createAgentRevalidateCommand() {
30
31
  versionId = versions.items[0].id;
31
32
  }
32
33
  // Revalidate the version
33
- const result = await client.post(`/agents/${agentId}/versions/${versionId}/revalidate`);
34
+ const result = await client.post(`/agents/${resolvedId}/versions/${versionId}/revalidate`);
34
35
  output.data(result);
35
36
  }
36
37
  catch (error) {
@@ -15,10 +15,10 @@ const SORT_MAP = {
15
15
  export function createAgentSearchCommand() {
16
16
  const cmd = new Command('search');
17
17
  cmd
18
- .description('Search published agents')
18
+ .description('Search agents')
19
19
  .argument('<query>', 'Search query')
20
20
  .option('--sort <field>', 'Sort by: updated, newest, name, popular (default: updated)', 'updated')
21
- .option('--all', 'Include unpublished agents')
21
+ .option('--published', 'Only show published agents')
22
22
  .option('--limit <number>', 'Number of results to return', '20')
23
23
  .option('--offset <number>', 'Offset for pagination', '0')
24
24
  .action(async (query, options) => {
@@ -34,7 +34,7 @@ export function createAgentSearchCommand() {
34
34
  params.append('search', query);
35
35
  params.append('limit', options.limit);
36
36
  params.append('offset', options.offset);
37
- if (!options.all) {
37
+ if (options.published) {
38
38
  params.append('published_only', 'true');
39
39
  }
40
40
  const sortField = SORT_MAP[options.sort];
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../../lib/api-client.js';
5
- import { getAgentId } from '../../../lib/agent-helpers.js';
5
+ import { getAgentId, resolveAgentRef } from '../../../lib/agent-helpers.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
7
7
  import { createOutputWriter } from '../../../lib/output.js';
8
8
  export function createAgentTagsAddCommand() {
@@ -34,17 +34,18 @@ export function createAgentTagsAddCommand() {
34
34
  }
35
35
  // Now resolve agent ID properly
36
36
  const { agentId, config } = await getAgentId(agentIdArg);
37
+ const resolvedId = await resolveAgentRef(client, agentId);
37
38
  if (tagsToAdd.length === 0) {
38
39
  output.error('At least one tag is required.', 'Usage: guild agent tags add [agent-id] <tag...>');
39
40
  process.exit(1);
40
41
  }
41
42
  // Fetch current tags
42
- const response = await client.get(`/agents/${agentId}/tags`);
43
+ const response = await client.get(`/agents/${resolvedId}/tags`);
43
44
  const currentTags = response.names;
44
45
  // Add new tags (deduplicate)
45
46
  const updatedTags = Array.from(new Set([...currentTags, ...tagsToAdd]));
46
47
  // Update tags
47
- await client.post(`/agents/${agentId}/tags`, { names: updatedTags });
48
+ await client.post(`/agents/${resolvedId}/tags`, { names: updatedTags });
48
49
  const agentName = config?.name || `agent ${agentId}`;
49
50
  const label = `${agentName}${config ? '' : ` (${agentId})`}`;
50
51
  output.success(`Updated tags for agent: ${label}`);
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../../lib/api-client.js';
5
- import { getAgentId } from '../../../lib/agent-helpers.js';
5
+ import { getAgentId, resolveAgentRef } from '../../../lib/agent-helpers.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
7
7
  import { createOutputWriter } from '../../../lib/output.js';
8
8
  export function createAgentTagsListCommand() {
@@ -16,8 +16,9 @@ export function createAgentTagsListCommand() {
16
16
  const client = new GuildAPIClient();
17
17
  // Resolve agent ID
18
18
  const { agentId } = await getAgentId(agentIdArg);
19
+ const resolvedId = await resolveAgentRef(client, agentId);
19
20
  // Fetch tags
20
- const response = await client.get(`/agents/${agentId}/tags`);
21
+ const response = await client.get(`/agents/${resolvedId}/tags`);
21
22
  output.data(response);
22
23
  }
23
24
  catch (error) {
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../../lib/api-client.js';
5
- import { getAgentId } from '../../../lib/agent-helpers.js';
5
+ import { getAgentId, resolveAgentRef } from '../../../lib/agent-helpers.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
7
7
  import { createOutputWriter } from '../../../lib/output.js';
8
8
  export function createAgentTagsRemoveCommand() {
@@ -34,19 +34,20 @@ export function createAgentTagsRemoveCommand() {
34
34
  }
35
35
  // Now resolve agent ID properly
36
36
  const { agentId, config } = await getAgentId(agentIdArg);
37
+ const resolvedId = await resolveAgentRef(client, agentId);
37
38
  if (tagsToRemove.length === 0) {
38
39
  output.error('At least one tag is required.', 'Usage: guild agent tags remove [agent-id] <tag...>');
39
40
  process.exit(1);
40
41
  }
41
42
  // Fetch current tags
42
- const response = await client.get(`/agents/${agentId}/tags`);
43
+ const response = await client.get(`/agents/${resolvedId}/tags`);
43
44
  const currentTags = response.names;
44
45
  // Remove specified tags
45
46
  const updatedTags = currentTags.filter((tag) => !tagsToRemove.includes(tag));
46
47
  // Track which tags were not present
47
48
  const notPresentTags = tagsToRemove.filter((tag) => !currentTags.includes(tag));
48
49
  // Update tags
49
- await client.post(`/agents/${agentId}/tags`, { names: updatedTags });
50
+ await client.post(`/agents/${resolvedId}/tags`, { names: updatedTags });
50
51
  const agentName = config?.name || `agent ${agentId}`;
51
52
  const label = `${agentName}${config ? '' : ` (${agentId})`}`;
52
53
  output.success(`Updated tags for agent: ${label}`);
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../../lib/api-client.js';
5
- import { getAgentId } from '../../../lib/agent-helpers.js';
5
+ import { getAgentId, resolveAgentRef } from '../../../lib/agent-helpers.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
7
7
  import { createOutputWriter } from '../../../lib/output.js';
8
8
  export function createAgentTagsSetCommand() {
@@ -36,8 +36,9 @@ export function createAgentTagsSetCommand() {
36
36
  }
37
37
  // Now resolve agent ID properly
38
38
  const { agentId, config } = await getAgentId(agentIdArg);
39
+ const resolvedId = await resolveAgentRef(client, agentId);
39
40
  // Update tags (direct replacement)
40
- await client.post(`/agents/${agentId}/tags`, { names: tagsToSet });
41
+ await client.post(`/agents/${resolvedId}/tags`, { names: tagsToSet });
41
42
  const agentName = config?.name || `agent ${agentId}`;
42
43
  const label = `${agentName}${config ? '' : ` (${agentId})`}`;
43
44
  if (tagsToSet.length === 0) {
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
- import { getAgentId } from '../../lib/agent-helpers.js';
5
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
7
  import { createOutputWriter } from '../../lib/output.js';
8
8
  export function createAgentUnpublishCommand() {
@@ -16,8 +16,9 @@ export function createAgentUnpublishCommand() {
16
16
  const client = new GuildAPIClient();
17
17
  // Resolve agent ID
18
18
  const { agentId, config } = await getAgentId(agentIdArg);
19
+ const resolvedId = await resolveAgentRef(client, agentId);
19
20
  // Fetch all versions
20
- const response = await client.get(`/agents/${agentId}/versions`);
21
+ const response = await client.get(`/agents/${resolvedId}/versions`);
21
22
  // Find latest PUBLISHED version
22
23
  const publishedVersions = response.items
23
24
  .filter((v) => v.status === 'PUBLISHED')
@@ -3,7 +3,7 @@
3
3
  import { Command } from 'commander';
4
4
  import * as readline from 'readline';
5
5
  import { GuildAPIClient } from '../../lib/api-client.js';
6
- import { getGuildcoreUrl } from '../../lib/config.js';
6
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
7
7
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
8
8
  import { createOutputWriter } from '../../lib/output.js';
9
9
  async function confirmVisibilityChange(agentName, makePublic) {
@@ -26,15 +26,15 @@ export function createAgentUpdateCommand() {
26
26
  const cmd = new Command('update');
27
27
  cmd
28
28
  .description('Update agent properties (visibility)')
29
- .argument('<identifier>', 'Agent ID or full name (e.g., owner/agent-name)')
29
+ .argument('[identifier]', 'Agent ID or full name (e.g., owner/agent-name)')
30
30
  .option('--public', 'Make the agent public (visible to everyone)')
31
31
  .option('--private', 'Make the agent private (only visible to owner)')
32
32
  .option('--yes', 'Skip confirmation prompt for visibility changes')
33
- .action(async (agentId, options) => {
33
+ .action(async (identifierArg, options) => {
34
34
  const output = createOutputWriter();
35
35
  // Validate that at least one option is provided
36
36
  if (!options.public && !options.private) {
37
- output.error('No update options provided.', 'Usage: guild agent update <agent-id> [options]\n\nOptions:\n --public Make the agent public\n --private Make the agent private\n --yes Skip confirmation prompt\n\nExamples:\n guild agent update my-agent --public\n guild agent update my-agent --private --yes\n\nNote: Agent descriptions are set from README.md when publishing.');
37
+ output.error('No update options provided.', 'Usage: guild agent update [identifier] [options]\n\nOptions:\n --public Make the agent public\n --private Make the agent private\n --yes Skip confirmation prompt\n\nExamples:\n guild agent update my-agent --public\n guild agent update my-agent --private --yes\n guild agent update --public (uses guild.json)\n\nNote: Agent descriptions are set from README.md when publishing.');
38
38
  process.exit(1);
39
39
  }
40
40
  // Validate that --public and --private are not both specified
@@ -42,11 +42,12 @@ export function createAgentUpdateCommand() {
42
42
  output.error('Cannot specify both --public and --private');
43
43
  process.exit(1);
44
44
  }
45
- const baseUrl = getGuildcoreUrl();
46
- const client = new GuildAPIClient({ baseUrl });
45
+ const { agentId } = await getAgentId(identifierArg);
46
+ const client = new GuildAPIClient();
47
47
  try {
48
+ const resolvedId = await resolveAgentRef(client, agentId);
48
49
  // Fetch current agent info for confirmation prompts
49
- const agent = await client.get(`/agents/${agentId}`);
50
+ const agent = await client.get(`/agents/${resolvedId}`);
50
51
  // Handle visibility change confirmation
51
52
  const changingVisibility = options.public || options.private;
52
53
  if (changingVisibility) {
@@ -73,7 +74,7 @@ export function createAgentUpdateCommand() {
73
74
  if (options.private) {
74
75
  updatePayload.is_public = false;
75
76
  }
76
- const result = await client.patch(`/agents/${agentId}`, updatePayload);
77
+ const result = await client.patch(`/agents/${resolvedId}`, updatePayload);
77
78
  // Build success message
78
79
  const changes = [];
79
80
  if (changingVisibility) {
@@ -4,7 +4,7 @@ import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
5
  import { getGuildcoreUrl } from '../../lib/config.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
- import { getAgentId } from '../../lib/agent-helpers.js';
7
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
8
8
  import { getOutputMode } from '../../lib/output-mode.js';
9
9
  import { createOutputWriter, formatVersionTable } from '../../lib/output.js';
10
10
  export function createAgentVersionsCommand() {
@@ -23,7 +23,8 @@ export function createAgentVersionsCommand() {
23
23
  const limit = parseInt(options.limit, 10);
24
24
  const offset = parseInt(options.offset, 10);
25
25
  try {
26
- const result = await client.get(`/agents/${agentId}/versions?limit=${limit}&offset=${offset}`);
26
+ const resolvedId = await resolveAgentRef(client, agentId);
27
+ const result = await client.get(`/agents/${resolvedId}/versions?limit=${limit}&offset=${offset}`);
27
28
  if (getOutputMode() === 'json') {
28
29
  output.data(result);
29
30
  }
@@ -4,7 +4,7 @@ import { Command } from 'commander';
4
4
  import { GuildAPIClient } from '../../lib/api-client.js';
5
5
  import { getGuildcoreUrl } from '../../lib/config.js';
6
6
  import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
7
- import { getAgentId } from '../../lib/agent-helpers.js';
7
+ import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
8
8
  import { createOutputWriter, formatWorkspaceTable } from '../../lib/output.js';
9
9
  import { getOutputMode } from '../../lib/output-mode.js';
10
10
  export function createAgentWorkspacesCommand() {
@@ -22,7 +22,8 @@ export function createAgentWorkspacesCommand() {
22
22
  const limit = parseInt(options.limit, 10);
23
23
  const offset = parseInt(options.offset, 10);
24
24
  try {
25
- const result = await client.get(`/agents/${agentId}/workspaces?limit=${limit}&offset=${offset}`);
25
+ const resolvedId = await resolveAgentRef(client, agentId);
26
+ const result = await client.get(`/agents/${resolvedId}/workspaces?limit=${limit}&offset=${offset}`);
26
27
  if (getOutputMode() === 'json') {
27
28
  output.data(result);
28
29
  }
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare function createCredentialsEndpointListCommand(): Command;
3
+ //# sourceMappingURL=endpoint-list.d.ts.map