@guildai/cli 0.6.0 → 0.6.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.
Files changed (56) hide show
  1. package/README.md +17 -0
  2. package/dist/commands/agent/chat.js +31 -31
  3. package/dist/commands/agent/fork.js +1 -1
  4. package/dist/commands/agent/init.js +1 -1
  5. package/dist/commands/agent/pull.js +36 -21
  6. package/dist/commands/agent/save.js +2 -2
  7. package/dist/commands/agent/test.js +8 -12
  8. package/dist/commands/auth/login.js +3 -3
  9. package/dist/commands/chat.js +64 -102
  10. package/dist/commands/credentials/endpoint-list.js +1 -1
  11. package/dist/commands/integration/connect.d.ts +3 -0
  12. package/dist/commands/integration/connect.js +76 -0
  13. package/dist/commands/integration/create.d.ts +3 -0
  14. package/dist/commands/integration/create.js +298 -0
  15. package/dist/commands/integration/get.d.ts +3 -0
  16. package/dist/commands/integration/get.js +95 -0
  17. package/dist/commands/integration/list.d.ts +3 -0
  18. package/dist/commands/integration/list.js +61 -0
  19. package/dist/commands/integration/operation/create.d.ts +3 -0
  20. package/dist/commands/integration/operation/create.js +163 -0
  21. package/dist/commands/integration/operation/list.d.ts +3 -0
  22. package/dist/commands/integration/operation/list.js +83 -0
  23. package/dist/commands/integration/update.d.ts +3 -0
  24. package/dist/commands/integration/update.js +139 -0
  25. package/dist/commands/integration/version/build.d.ts +3 -0
  26. package/dist/commands/integration/version/build.js +86 -0
  27. package/dist/commands/integration/version/create.d.ts +3 -0
  28. package/dist/commands/integration/version/create.js +45 -0
  29. package/dist/commands/integration/version/get.d.ts +3 -0
  30. package/dist/commands/integration/version/get.js +72 -0
  31. package/dist/commands/integration/version/list.d.ts +3 -0
  32. package/dist/commands/integration/version/list.js +44 -0
  33. package/dist/commands/integration/version/publish.d.ts +3 -0
  34. package/dist/commands/integration/version/publish.js +79 -0
  35. package/dist/commands/integration/version/test.d.ts +3 -0
  36. package/dist/commands/integration/version/test.js +104 -0
  37. package/dist/commands/workspace/create.js +10 -4
  38. package/dist/index.js +38 -0
  39. package/dist/lib/api-types.d.ts +69 -12
  40. package/dist/lib/auth.d.ts +1 -1
  41. package/dist/lib/auth.js +3 -2
  42. package/dist/lib/integration-helpers.d.ts +15 -0
  43. package/dist/lib/integration-helpers.js +38 -0
  44. package/dist/lib/output.d.ts +11 -1
  45. package/dist/lib/output.js +94 -0
  46. package/dist/lib/session-events-fetch.d.ts +27 -0
  47. package/dist/lib/session-events-fetch.js +25 -0
  48. package/dist/lib/session-polling.d.ts +7 -2
  49. package/dist/lib/session-polling.js +18 -11
  50. package/dist/lib/session-resume.js +2 -5
  51. package/dist/lib/table.d.ts +0 -1
  52. package/dist/lib/table.js +0 -1
  53. package/dist/mcp/tools.js +5 -11
  54. package/docs/CLI_WORKFLOW.md +15 -0
  55. package/docs/skills/agent-dev.md +15 -0
  56. package/package.json +4 -3
@@ -1,6 +1,11 @@
1
1
  import { GuildAPIClient } from './api-client.js';
2
+ export interface PollResult {
3
+ response: string | null;
4
+ /** Last event ID seen — pass as `afterEventId` on next call. */
5
+ lastEventId: string | undefined;
6
+ }
2
7
  /**
3
- * Poll for agent response after a certain event count.
8
+ * Poll for agent response using from_id cursor.
4
9
  *
5
10
  * Handles both multi-turn agents (which emit agent_notification_message)
6
11
  * and one-shot agents (which may only emit runtime_done with output content).
@@ -10,5 +15,5 @@ import { GuildAPIClient } from './api-client.js';
10
15
  * 2. runtime_done from agent tasks — fallback for one-shot agents
11
16
  * 3. runtime_error from agent tasks — fail fast
12
17
  */
13
- export declare function pollForResponse(client: GuildAPIClient, sessionId: string, afterEventCount: number, maxWaitTime?: number): Promise<string | null>;
18
+ export declare function pollForResponse(client: GuildAPIClient, sessionId: string, afterEventId: string | undefined, maxWaitTime?: number): Promise<PollResult>;
14
19
  //# sourceMappingURL=session-polling.d.ts.map
@@ -1,8 +1,9 @@
1
1
  // Copyright 2026 Guild.ai
2
2
  // SPDX-License-Identifier: Apache-2.0
3
- import { isDebugMode } from './errors.js';
3
+ import { debug, isDebugMode } from './errors.js';
4
+ import { fetchEvents } from './session-events-fetch.js';
4
5
  /**
5
- * Poll for agent response after a certain event count.
6
+ * Poll for agent response using from_id cursor.
6
7
  *
7
8
  * Handles both multi-turn agents (which emit agent_notification_message)
8
9
  * and one-shot agents (which may only emit runtime_done with output content).
@@ -12,16 +13,16 @@ import { isDebugMode } from './errors.js';
12
13
  * 2. runtime_done from agent tasks — fallback for one-shot agents
13
14
  * 3. runtime_error from agent tasks — fail fast
14
15
  */
15
- export async function pollForResponse(client, sessionId, afterEventCount, maxWaitTime = 60000) {
16
+ export async function pollForResponse(client, sessionId, afterEventId, maxWaitTime = 60000) {
16
17
  const startTime = Date.now();
18
+ let fromId = afterEventId;
17
19
  while (Date.now() - startTime < maxWaitTime) {
18
- const response = await client.get(`/sessions/${sessionId}/events?limit=1000`);
19
- const events = response?.items || [];
20
+ const events = await fetchEvents(client, sessionId, { fromId });
20
21
  let lastAgentRuntimeDone = null;
21
- for (let i = afterEventCount; i < events.length; i++) {
22
- const event = events[i];
22
+ for (const event of events) {
23
+ debug(`pollForResponse event: ${event.type}`);
23
24
  if (event.type === 'agent_notification_message') {
24
- return event.content.data;
25
+ return { response: event.content.data, lastEventId: event.id };
25
26
  }
26
27
  if (event.type === 'runtime_done' &&
27
28
  event.content !== undefined &&
@@ -30,17 +31,23 @@ export async function pollForResponse(client, sessionId, afterEventCount, maxWai
30
31
  lastAgentRuntimeDone = JSON.stringify(event.content);
31
32
  }
32
33
  if (event.type === 'runtime_error' && event.task && 'agent' in event.task) {
33
- return JSON.stringify({ error: event.content });
34
+ return {
35
+ response: JSON.stringify({ error: event.content }),
36
+ lastEventId: event.id,
37
+ };
34
38
  }
35
39
  if (event.type === 'agent_console' && isDebugMode()) {
36
40
  process.stderr.write(`[console.${event.level}] ${event.content}\n`);
37
41
  }
38
42
  }
43
+ if (events.length > 0) {
44
+ fromId = events[events.length - 1].id;
45
+ }
39
46
  if (lastAgentRuntimeDone !== null) {
40
- return lastAgentRuntimeDone;
47
+ return { response: lastAgentRuntimeDone, lastEventId: fromId };
41
48
  }
42
49
  await new Promise((resolve) => setTimeout(resolve, 500));
43
50
  }
44
- return null;
51
+ return { response: null, lastEventId: fromId };
45
52
  }
46
53
  //# sourceMappingURL=session-polling.js.map
@@ -7,6 +7,7 @@
7
7
  import chalk from 'chalk';
8
8
  import { marked } from 'marked';
9
9
  import { markedTerminal } from 'marked-terminal';
10
+ import { fetchEvents } from './session-events-fetch.js';
10
11
  import { brand, code as codeColor } from './colors.js';
11
12
  // Configure marked for terminal rendering (same config as chat.tsx)
12
13
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -37,11 +38,7 @@ export function printResumeHint(sessionId, command) {
37
38
  * Fetch all events for a session from the API.
38
39
  */
39
40
  export async function fetchSessionEvents(client, sessionId) {
40
- const response = await client.get(`/sessions/${sessionId}/events?limit=1000`);
41
- const events = (Array.isArray(response)
42
- ? response
43
- : response?.items || []);
44
- return events;
41
+ return fetchEvents(client, sessionId);
45
42
  }
46
43
  /**
47
44
  * Fetch an existing session by ID.
@@ -6,7 +6,6 @@ interface ColumnConfig {
6
6
  }
7
7
  /**
8
8
  * Minimal table renderer using string-width@7 for ANSI-aware column sizing.
9
- * Handles OSC8 hyperlink sequences correctly (string-width uses strip-ansi@7).
10
9
  */
11
10
  export declare class Table {
12
11
  private columns;
package/dist/lib/table.js CHANGED
@@ -4,7 +4,6 @@ import chalk from 'chalk';
4
4
  import stringWidth from 'string-width';
5
5
  /**
6
6
  * Minimal table renderer using string-width@7 for ANSI-aware column sizing.
7
- * Handles OSC8 hyperlink sequences correctly (string-width uses strip-ansi@7).
8
7
  */
9
8
  export class Table {
10
9
  columns;
package/dist/mcp/tools.js CHANGED
@@ -24,17 +24,13 @@ async function pollForResponse(apiClient, sessionId, debug) {
24
24
  let lastEventId;
25
25
  while (Date.now() - startTime < POLL_TIMEOUT_MS) {
26
26
  try {
27
- const response = await apiClient.get(`/sessions/${sessionId}/events`);
27
+ let url = `/sessions/${sessionId}/events`;
28
+ if (lastEventId) {
29
+ url += `?from_id=${lastEventId}`;
30
+ }
31
+ const response = await apiClient.get(url);
28
32
  const events = response.events || [];
29
- // Find new events after last seen
30
- let foundLast = !lastEventId;
31
33
  for (const event of events) {
32
- if (!foundLast) {
33
- if (event.id === lastEventId) {
34
- foundLast = true;
35
- }
36
- continue;
37
- }
38
34
  debugLog(debug, `Event: ${event.event_type}`);
39
35
  if (event.event_type === 'agent_notification_message') {
40
36
  const data = extractEventText(event);
@@ -53,9 +49,7 @@ async function pollForResponse(apiClient, sessionId, debug) {
53
49
  debugLog(debug, 'Runtime done');
54
50
  return messages.join('\n\n') || 'Agent completed without output.';
55
51
  }
56
- lastEventId = event.id;
57
52
  }
58
- // Update lastEventId to latest
59
53
  if (events.length > 0) {
60
54
  lastEventId = events[events.length - 1].id;
61
55
  }
@@ -145,6 +145,21 @@ guild agent test --ephemeral
145
145
  guild agent chat "Hello, can you help me?"
146
146
  ```
147
147
 
148
+ ### Chatting with Agents
149
+
150
+ ```bash
151
+ # Chat with any published agent by name
152
+ guild chat --agent owner/agent-name
153
+
154
+ # Chat with a specific agent in a specific workspace
155
+ guild chat --agent owner/agent-name --workspace owner/workspace-name
156
+
157
+ # One-shot mode (send prompt, get response, exit)
158
+ guild chat --agent owner/agent-name --once "What can you do?"
159
+ ```
160
+
161
+ To chat with the agent you are developing locally, use `guild agent chat` from within the agent directory.
162
+
148
163
  ## File Structure
149
164
 
150
165
  After `guild agent init`, you get:
@@ -89,6 +89,21 @@ guild agent test --ephemeral
89
89
  guild agent chat "Hello, can you help me?"
90
90
  ```
91
91
 
92
+ ### Chatting with Agents
93
+
94
+ ```bash
95
+ # Chat with any published agent by name
96
+ guild chat --agent owner/agent-name
97
+
98
+ # Chat with a specific agent in a specific workspace
99
+ guild chat --agent owner/agent-name --workspace owner/workspace-name
100
+
101
+ # One-shot mode (send prompt, get response, exit)
102
+ guild chat --agent owner/agent-name --once "What can you do?"
103
+ ```
104
+
105
+ To chat with the agent you are developing locally, use `guild agent chat` from within the agent directory.
106
+
92
107
  ## Guild CLI Is the ONLY Tool for Agent Operations
93
108
 
94
109
  **ALL agent work — creating, saving, testing, debugging, investigating — goes through Guild CLI.**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guildai/cli",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Guild.ai CLI - Build, test, and deploy AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -56,6 +56,7 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@inquirer/search": "^4.1.7",
59
+ "@modelcontextprotocol/sdk": "^1.12.1",
59
60
  "@napi-rs/canvas": "^0.1.85",
60
61
  "@napi-rs/keyring": "^1.2.0",
61
62
  "axios": "^1.13.2",
@@ -76,11 +77,11 @@
76
77
  "sharp": "^0.34.5",
77
78
  "shell-quote": "^1.8.2",
78
79
  "string-width": "^7.2.0",
80
+ "strip-ansi": "^7.2.0",
79
81
  "svg-pathdata": "^8.0.0",
80
82
  "svgdom": "^0.1.22",
81
83
  "ws": "^8.18.0",
82
- "zod": "^3.24.4",
83
- "@modelcontextprotocol/sdk": "^1.12.1"
84
+ "zod": "^3.24.4"
84
85
  },
85
86
  "devDependencies": {
86
87
  "@types/inquirer": "^8.2.10",