@guildai/cli 0.5.0 → 0.5.1

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.
@@ -13,7 +13,7 @@ export function createAgentOwnersCommand() {
13
13
  const client = new GuildAPIClient();
14
14
  const [me, orgs, globalConfig] = await Promise.all([
15
15
  client.get('/me'),
16
- client.get('/me/organizations'),
16
+ client.fetchAll('/me/organizations'),
17
17
  loadGlobalConfig(),
18
18
  ]);
19
19
  const defaultOwnerId = globalConfig?.default_owner;
@@ -24,7 +24,7 @@ export function createAgentOwnersCommand() {
24
24
  type: 'user',
25
25
  is_default: defaultOwnerId === me.id,
26
26
  },
27
- ...orgs.items.map((org) => ({
27
+ ...orgs.map((org) => ({
28
28
  id: org.id,
29
29
  name: org.name,
30
30
  type: 'organization',
@@ -56,8 +56,8 @@ async function resolveOwnerName(ownerId) {
56
56
  if (me.id === ownerId) {
57
57
  return me.name;
58
58
  }
59
- const orgs = await client.get('/me/organizations');
60
- const org = orgs.items.find((o) => o.id === ownerId);
59
+ const orgs = await client.fetchAll('/me/organizations');
60
+ const org = orgs.find((o) => o.id === ownerId);
61
61
  return org?.name;
62
62
  }
63
63
  catch (error) {
@@ -50,8 +50,8 @@ export function createTriggerCreateCommand() {
50
50
  }
51
51
  const client = new GuildAPIClient();
52
52
  // Find workspace_agent_id from agent identifier
53
- const workspaceAgentsResponse = await client.get(`/workspaces/${workspaceId}/workspace_agents`);
54
- const workspaceAgent = workspaceAgentsResponse.items.find((wa) => wa.agent.full_name === options.agent ||
53
+ const allWorkspaceAgents = await client.fetchAll(`/workspaces/${workspaceId}/workspace_agents`);
54
+ const workspaceAgent = allWorkspaceAgents.find((wa) => wa.agent.full_name === options.agent ||
55
55
  wa.agent.name === options.agent ||
56
56
  wa.agent.id === options.agent);
57
57
  if (!workspaceAgent) {
@@ -30,10 +30,10 @@ export function createWorkspaceAgentRemoveCommand() {
30
30
  }
31
31
  workspaceId = resolved.workspaceId;
32
32
  }
33
- // List workspace agents to find the one to remove
34
- const response = await client.get(`/workspaces/${workspaceId}/workspace_agents`);
33
+ // List all workspace agents to find the one to remove
34
+ const allWorkspaceAgents = await client.fetchAll(`/workspaces/${workspaceId}/workspace_agents`);
35
35
  // Find the agent by identifier (match full_name, name, agent id, or workspace_agent id)
36
- const workspaceAgent = response.items.find((wa) => wa.id === agentIdentifier ||
36
+ const workspaceAgent = allWorkspaceAgents.find((wa) => wa.id === agentIdentifier ||
37
37
  wa.agent.full_name === agentIdentifier ||
38
38
  wa.agent.name === agentIdentifier ||
39
39
  wa.agent.id === agentIdentifier);
@@ -50,5 +50,13 @@ export declare class GuildAPIClient {
50
50
  * Make a DELETE request
51
51
  */
52
52
  delete<T = unknown>(endpoint: string, config?: AxiosRequestConfig): Promise<T>;
53
+ /**
54
+ * Fetch all items from a paginated endpoint by paging through results.
55
+ * Use for display commands or ID-based lookups where you need the complete list.
56
+ *
57
+ * @param endpoint - API endpoint path (may include query params)
58
+ * @returns Flat array of all items across all pages
59
+ */
60
+ fetchAll<T>(endpoint: string): Promise<T[]>;
53
61
  }
54
62
  //# sourceMappingURL=api-client.d.ts.map
@@ -121,5 +121,27 @@ export class GuildAPIClient {
121
121
  async delete(endpoint, config) {
122
122
  return this.request('DELETE', endpoint, config);
123
123
  }
124
+ /**
125
+ * Fetch all items from a paginated endpoint by paging through results.
126
+ * Use for display commands or ID-based lookups where you need the complete list.
127
+ *
128
+ * @param endpoint - API endpoint path (may include query params)
129
+ * @returns Flat array of all items across all pages
130
+ */
131
+ async fetchAll(endpoint) {
132
+ const PAGE_SIZE = 100;
133
+ const allItems = [];
134
+ let offset = 0;
135
+ while (true) {
136
+ const separator = endpoint.includes('?') ? '&' : '?';
137
+ const url = `${endpoint}${separator}limit=${PAGE_SIZE}&offset=${offset}`;
138
+ const response = await this.get(url);
139
+ allItems.push(...response.items);
140
+ offset += response.pagination.limit;
141
+ if (!response.pagination.has_more)
142
+ break;
143
+ }
144
+ return allItems;
145
+ }
124
146
  }
125
147
  //# sourceMappingURL=api-client.js.map
@@ -170,7 +170,7 @@ export type AgentListResponse = PaginatedResponse<Agent>;
170
170
  export type WorkspaceListResponse = PaginatedResponse<Workspace>;
171
171
  export type VersionListResponse = PaginatedResponse<AgentVersion>;
172
172
  export type ContextListResponse = PaginatedResponse<Context>;
173
- export type WorkspaceAgentListResponse = CountedResponse<WorkspaceAgent>;
173
+ export type WorkspaceAgentListResponse = PaginatedResponse<WorkspaceAgent>;
174
174
  /**
175
175
  * Response from creating a new agent.
176
176
  */
@@ -27,8 +27,8 @@ export async function resolveOwnerId(options) {
27
27
  if (me.id === ownerFlag) {
28
28
  return { id: me.id, name: me.name, type: 'user' };
29
29
  }
30
- const orgs = await client.get('/me/organizations');
31
- const org = orgs.items.find((o) => o.id === ownerFlag);
30
+ const orgs = await client.fetchAll('/me/organizations');
31
+ const org = orgs.find((o) => o.id === ownerFlag);
32
32
  if (org) {
33
33
  return { id: org.id, name: org.name, type: 'organization' };
34
34
  }
@@ -43,8 +43,8 @@ export async function resolveOwnerId(options) {
43
43
  if (me.id === envOwnerId) {
44
44
  return { id: me.id, name: me.name, type: 'user' };
45
45
  }
46
- const orgs = await client.get('/me/organizations');
47
- const org = orgs.items.find((o) => o.id === envOwnerId);
46
+ const orgs = await client.fetchAll('/me/organizations');
47
+ const org = orgs.find((o) => o.id === envOwnerId);
48
48
  if (org) {
49
49
  return { id: org.id, name: org.name, type: 'organization' };
50
50
  }
@@ -63,9 +63,9 @@ export async function resolveOwnerId(options) {
63
63
  }
64
64
  // Priority 4: Fetch user + orgs
65
65
  const me = await client.get('/me');
66
- const orgs = await client.get('/me/organizations');
66
+ const orgs = await client.fetchAll('/me/organizations');
67
67
  // No orgs → use current user
68
- if (orgs.items.length === 0) {
68
+ if (orgs.length === 0) {
69
69
  debug('No organizations found, using current user as owner');
70
70
  return { id: me.id, name: me.name, type: 'user' };
71
71
  }
@@ -80,7 +80,7 @@ export async function resolveOwnerId(options) {
80
80
  name: `${me.name} (personal)`,
81
81
  value: { id: me.id, name: me.name, type: 'user' },
82
82
  },
83
- ...orgs.items.map((org) => ({
83
+ ...orgs.map((org) => ({
84
84
  name: org.name,
85
85
  value: { id: org.id, name: org.name, type: 'organization' },
86
86
  })),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guildai/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Guild.ai CLI - Build, test, and deploy AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",