@guildai/cli 0.6.0 → 0.6.2

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 (59) 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/publish.js +13 -53
  6. package/dist/commands/agent/pull.js +36 -21
  7. package/dist/commands/agent/save.js +16 -52
  8. package/dist/commands/agent/test.js +8 -12
  9. package/dist/commands/auth/login.js +3 -3
  10. package/dist/commands/chat.js +68 -106
  11. package/dist/commands/credentials/endpoint-list.js +1 -1
  12. package/dist/commands/integration/connect.d.ts +3 -0
  13. package/dist/commands/integration/connect.js +76 -0
  14. package/dist/commands/integration/create.d.ts +3 -0
  15. package/dist/commands/integration/create.js +298 -0
  16. package/dist/commands/integration/get.d.ts +3 -0
  17. package/dist/commands/integration/get.js +95 -0
  18. package/dist/commands/integration/list.d.ts +3 -0
  19. package/dist/commands/integration/list.js +61 -0
  20. package/dist/commands/integration/operation/create.d.ts +3 -0
  21. package/dist/commands/integration/operation/create.js +163 -0
  22. package/dist/commands/integration/operation/list.d.ts +3 -0
  23. package/dist/commands/integration/operation/list.js +83 -0
  24. package/dist/commands/integration/update.d.ts +3 -0
  25. package/dist/commands/integration/update.js +139 -0
  26. package/dist/commands/integration/version/build.d.ts +3 -0
  27. package/dist/commands/integration/version/build.js +86 -0
  28. package/dist/commands/integration/version/create.d.ts +3 -0
  29. package/dist/commands/integration/version/create.js +45 -0
  30. package/dist/commands/integration/version/get.d.ts +3 -0
  31. package/dist/commands/integration/version/get.js +72 -0
  32. package/dist/commands/integration/version/list.d.ts +3 -0
  33. package/dist/commands/integration/version/list.js +44 -0
  34. package/dist/commands/integration/version/publish.d.ts +3 -0
  35. package/dist/commands/integration/version/publish.js +79 -0
  36. package/dist/commands/integration/version/test.d.ts +3 -0
  37. package/dist/commands/integration/version/test.js +104 -0
  38. package/dist/commands/workspace/create.js +10 -4
  39. package/dist/index.js +38 -0
  40. package/dist/lib/api-types.d.ts +69 -12
  41. package/dist/lib/auth.d.ts +1 -1
  42. package/dist/lib/auth.js +3 -2
  43. package/dist/lib/integration-helpers.d.ts +15 -0
  44. package/dist/lib/integration-helpers.js +38 -0
  45. package/dist/lib/output.d.ts +11 -1
  46. package/dist/lib/output.js +94 -0
  47. package/dist/lib/session-events-fetch.d.ts +27 -0
  48. package/dist/lib/session-events-fetch.js +25 -0
  49. package/dist/lib/session-polling.d.ts +7 -2
  50. package/dist/lib/session-polling.js +19 -12
  51. package/dist/lib/session-resume.js +2 -5
  52. package/dist/lib/table.d.ts +0 -1
  53. package/dist/lib/table.js +0 -1
  54. package/dist/lib/version-helpers.d.ts +15 -0
  55. package/dist/lib/version-helpers.js +83 -0
  56. package/dist/mcp/tools.js +6 -12
  57. package/docs/CLI_WORKFLOW.md +15 -0
  58. package/docs/skills/agent-dev.md +15 -0
  59. package/package.json +4 -3
@@ -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;
@@ -0,0 +1,15 @@
1
+ import type { OutputWriter } from './output.js';
2
+ import type { AgentVersion } from './api-types.js';
3
+ /**
4
+ * Poll until a version's validation completes, then check the result.
5
+ * Exits the process on timeout or validation failure.
6
+ * Returns the updated version on success.
7
+ */
8
+ export declare function waitForValidation(versionId: string, output: OutputWriter): Promise<AgentVersion>;
9
+ /**
10
+ * Poll until a version's publish completes (PUBLISHING → PUBLISHED).
11
+ * Exits the process on timeout or failure.
12
+ * Returns the updated version on success.
13
+ */
14
+ export declare function waitForPublish(versionId: string, output: OutputWriter): Promise<AgentVersion>;
15
+ //# sourceMappingURL=version-helpers.d.ts.map
@@ -0,0 +1,83 @@
1
+ // Copyright 2026 Guild.ai
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { GuildAPIClient } from './api-client.js';
4
+ import { pollUntilComplete } from './polling.js';
5
+ /**
6
+ * Poll until a version's validation completes, then check the result.
7
+ * Exits the process on timeout or validation failure.
8
+ * Returns the updated version on success.
9
+ */
10
+ export async function waitForValidation(versionId, output) {
11
+ const pollResult = await pollUntilComplete({
12
+ resourceId: versionId,
13
+ endpoint: `/versions/${versionId}`,
14
+ isComplete: (response) => response.validation_status !== 'PENDING' &&
15
+ response.validation_status !== 'RUNNING',
16
+ message: 'Waiting for validation to complete...',
17
+ successMessage: 'Validation complete',
18
+ timeoutMessage: 'Validation timed out',
19
+ maxAttempts: 120,
20
+ delayMs: 1000,
21
+ });
22
+ if (!pollResult.success || !pollResult.response) {
23
+ output.error('Validation did not complete in time', 'Check status manually:\n guild agent versions');
24
+ process.exit(1);
25
+ }
26
+ const version = pollResult.response;
27
+ if (version.validation_status === 'FAILED') {
28
+ const details = await fetchValidationFailureDetails(version.id);
29
+ output.error('Validation failed', details);
30
+ process.exit(1);
31
+ }
32
+ return version;
33
+ }
34
+ /**
35
+ * Fetch validation step details for a failed version.
36
+ */
37
+ async function fetchValidationFailureDetails(versionId) {
38
+ const client = new GuildAPIClient();
39
+ let failureDetails = '';
40
+ try {
41
+ const stepsResponse = await client.get(`/versions/${versionId}/validation/steps`);
42
+ const failedSteps = stepsResponse.steps.filter((step) => step.status === 'FAILED');
43
+ if (failedSteps.length > 0) {
44
+ failureDetails = failedSteps
45
+ .map((step) => step.content
46
+ ? `Step "${step.name}" failed: ${step.content}`
47
+ : `Step "${step.name}" failed`)
48
+ .join('\n');
49
+ }
50
+ else {
51
+ failureDetails = 'No failed steps found. Check validation logs for details.';
52
+ }
53
+ }
54
+ catch {
55
+ failureDetails = 'Could not fetch validation details.';
56
+ }
57
+ failureDetails +=
58
+ '\n\nFix the issues, then save a new version:\n guild agent save --message "Fix validation errors"';
59
+ return failureDetails;
60
+ }
61
+ /**
62
+ * Poll until a version's publish completes (PUBLISHING → PUBLISHED).
63
+ * Exits the process on timeout or failure.
64
+ * Returns the updated version on success.
65
+ */
66
+ export async function waitForPublish(versionId, output) {
67
+ const pollResult = await pollUntilComplete({
68
+ resourceId: versionId,
69
+ endpoint: `/versions/${versionId}`,
70
+ isComplete: (response) => response.status === 'PUBLISHED' || response.status === 'FAILED',
71
+ message: 'Waiting for publish to complete...',
72
+ successMessage: 'Published',
73
+ timeoutMessage: 'Publish timed out',
74
+ maxAttempts: 60,
75
+ delayMs: 1000,
76
+ });
77
+ if (!pollResult.success || pollResult.response?.status !== 'PUBLISHED') {
78
+ output.error('Publish did not complete in time', 'Check status manually:\n guild agent versions');
79
+ process.exit(1);
80
+ }
81
+ return pollResult.response;
82
+ }
83
+ //# sourceMappingURL=version-helpers.js.map
package/dist/mcp/tools.js CHANGED
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  // ---------------------------------------------------------------------------
5
5
  // Constants
6
6
  // ---------------------------------------------------------------------------
7
- const POLL_INTERVAL_MS = 500;
7
+ const POLL_INTERVAL_MS = 2000;
8
8
  const POLL_TIMEOUT_MS = 120_000;
9
9
  // ---------------------------------------------------------------------------
10
10
  // Helpers
@@ -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.2",
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",