@guildai/cli 0.6.1 → 0.7.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.
@@ -0,0 +1,91 @@
1
+ // Copyright 2026 Guild.ai
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * User-facing event types — shown by default (mirrors web UI defaults).
5
+ */
6
+ export const USER_EVENT_TYPES = [
7
+ 'user_message',
8
+ 'agent_notification_message',
9
+ 'agent_notification_progress',
10
+ 'agent_notification_error',
11
+ 'credentials_request',
12
+ 'agent_install_request',
13
+ 'trigger_message',
14
+ 'system_error',
15
+ ];
16
+ /**
17
+ * System / debug event types — hidden by default (mirrors web UI defaults).
18
+ */
19
+ export const SYSTEM_EVENT_TYPES = [
20
+ 'agent_console',
21
+ 'runtime_start',
22
+ 'runtime_running',
23
+ 'runtime_waiting',
24
+ 'runtime_error',
25
+ 'runtime_done',
26
+ 'llm_start',
27
+ 'llm_done',
28
+ ];
29
+ /**
30
+ * Default active filter: all user-facing types, no system types.
31
+ */
32
+ export const DEFAULT_EVENT_TYPES = new Set(USER_EVENT_TYPES);
33
+ /**
34
+ * Parse the value of the `--events` flag into a Set of event type names.
35
+ *
36
+ * Whatever you pass replaces the defaults entirely:
37
+ * - `none` → empty set (no event types shown)
38
+ * - `user` → all USER_EVENT_TYPES (same as default)
39
+ * - `system` → only SYSTEM_EVENT_TYPES
40
+ * - `all` → both USER_EVENT_TYPES + SYSTEM_EVENT_TYPES
41
+ *
42
+ * Comma-separated for fine-grained control:
43
+ * - `agent_console,llm_start` → only those two types
44
+ * - `user,system` → same as `all`
45
+ */
46
+ export function parseEventFilter(raw) {
47
+ const tokens = raw
48
+ .split(',')
49
+ .map((t) => t.trim())
50
+ .filter(Boolean);
51
+ // `none` returns an empty set — no event types shown
52
+ if (tokens.length === 1 && tokens[0] === 'none') {
53
+ return new Set();
54
+ }
55
+ const result = new Set();
56
+ for (const token of tokens) {
57
+ switch (token) {
58
+ case 'all':
59
+ for (const t of USER_EVENT_TYPES)
60
+ result.add(t);
61
+ for (const t of SYSTEM_EVENT_TYPES)
62
+ result.add(t);
63
+ break;
64
+ case 'user':
65
+ for (const t of USER_EVENT_TYPES)
66
+ result.add(t);
67
+ break;
68
+ case 'system':
69
+ for (const t of SYSTEM_EVENT_TYPES)
70
+ result.add(t);
71
+ break;
72
+ default:
73
+ result.add(token);
74
+ }
75
+ }
76
+ return result;
77
+ }
78
+ /**
79
+ * Check whether an event should be shown given the active filter.
80
+ *
81
+ * Returns `true` when the event type is in the filter set.
82
+ *
83
+ * Note: certain event types (e.g. `agent_notification_progress`,
84
+ * `agent_notification_message`) drive core UI state (spinner, chat history)
85
+ * and are always processed regardless of the filter; only their *display* is
86
+ * gated here for new/optional event types.
87
+ */
88
+ export function shouldShowEvent(type, filter) {
89
+ return filter.has(type);
90
+ }
91
+ //# sourceMappingURL=event-filter.js.map
@@ -2,4 +2,6 @@ export declare const WEBHOOK_SERVICES: readonly ["AZURE_DEVOPS", "BITBUCKET", "C
2
2
  export type WebhookService = (typeof WEBHOOK_SERVICES)[number];
3
3
  export declare const TIME_TRIGGER_FREQUENCIES: readonly ["HOURLY", "DAILY", "WEEKLY", "MONTHLY", "CRON"];
4
4
  export type TimeTriggerFrequency = (typeof TIME_TRIGGER_FREQUENCIES)[number];
5
+ export declare const EVENT_TYPES: readonly ["user_message", "agent_console", "runtime_start", "runtime_running", "runtime_waiting", "runtime_error", "runtime_done", "credentials_request", "agent_install_request", "agent_notification_message", "agent_notification_progress", "agent_notification_error", "system_error", "trigger_message", "interrupted", "llm_start", "llm_done"];
6
+ export type EventType = (typeof EVENT_TYPES)[number];
5
7
  //# sourceMappingURL=generated-types.d.ts.map
@@ -32,4 +32,24 @@ export const TIME_TRIGGER_FREQUENCIES = [
32
32
  'MONTHLY',
33
33
  'CRON',
34
34
  ];
35
+ // Source: python/guildcore/routes/serializers.py -> EventType
36
+ export const EVENT_TYPES = [
37
+ 'user_message',
38
+ 'agent_console',
39
+ 'runtime_start',
40
+ 'runtime_running',
41
+ 'runtime_waiting',
42
+ 'runtime_error',
43
+ 'runtime_done',
44
+ 'credentials_request',
45
+ 'agent_install_request',
46
+ 'agent_notification_message',
47
+ 'agent_notification_progress',
48
+ 'agent_notification_error',
49
+ 'system_error',
50
+ 'trigger_message',
51
+ 'interrupted',
52
+ 'llm_start',
53
+ 'llm_done',
54
+ ];
35
55
  //# sourceMappingURL=generated-types.js.map
@@ -117,6 +117,31 @@ export interface AgentConsoleEvent extends BaseEvent {
117
117
  level: 'debug' | 'info' | 'warn' | 'error';
118
118
  content: string;
119
119
  }
120
+ export interface TriggerMessageEvent extends BaseEvent {
121
+ type: 'trigger_message';
122
+ content: {
123
+ type: 'text';
124
+ data: string;
125
+ };
126
+ }
127
+ export interface SystemErrorEvent extends BaseEvent {
128
+ type: 'system_error';
129
+ content: {
130
+ type: 'text';
131
+ data: string;
132
+ };
133
+ details?: Record<string, unknown>;
134
+ }
135
+ export interface LlmStartEvent extends BaseEvent {
136
+ type: 'llm_start';
137
+ provider: string;
138
+ payload: Record<string, unknown>;
139
+ }
140
+ export interface LlmDoneEvent extends BaseEvent {
141
+ type: 'llm_done';
142
+ status_code: number;
143
+ body: string;
144
+ }
120
145
  /** Agent info as returned in install request */
121
146
  export interface RequestedAgent {
122
147
  id: string;
@@ -149,7 +174,7 @@ export interface InterruptedEvent extends BaseEvent {
149
174
  interrupted_at: string;
150
175
  interrupted_by_id: string;
151
176
  }
152
- export type SessionEvent = UserMessageEvent | RuntimeStartEvent | RuntimeRunningEvent | RuntimeWaitingEvent | RuntimeErrorEvent | RuntimeDoneEvent | AgentNotificationMessageEvent | AgentNotificationProgressEvent | AgentNotificationErrorEvent | AgentConsoleEvent | AgentInstallRequestEvent | CredentialsRequestEvent | InterruptedEvent;
177
+ export type SessionEvent = UserMessageEvent | RuntimeStartEvent | RuntimeRunningEvent | RuntimeWaitingEvent | RuntimeErrorEvent | RuntimeDoneEvent | AgentNotificationMessageEvent | AgentNotificationProgressEvent | AgentNotificationErrorEvent | AgentConsoleEvent | TriggerMessageEvent | SystemErrorEvent | LlmStartEvent | LlmDoneEvent | AgentInstallRequestEvent | CredentialsRequestEvent | InterruptedEvent;
153
178
  export interface Session {
154
179
  id: string;
155
180
  workspace_id?: string;
@@ -46,7 +46,7 @@ export async function pollForResponse(client, sessionId, afterEventId, maxWaitTi
46
46
  if (lastAgentRuntimeDone !== null) {
47
47
  return { response: lastAgentRuntimeDone, lastEventId: fromId };
48
48
  }
49
- await new Promise((resolve) => setTimeout(resolve, 500));
49
+ await new Promise((resolve) => setTimeout(resolve, 2000));
50
50
  }
51
51
  return { response: null, lastEventId: fromId };
52
52
  }
@@ -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
@@ -57,11 +57,17 @@ guild agent save --message "Description" --wait --publish
57
57
  ### Project Setup
58
58
 
59
59
  ```bash
60
- # Install Guild CLI skills for coding assistants (Claude Code, etc.)
60
+ # Install Guild CLI skills for coding assistants (Claude Code, Codex, etc.)
61
61
  guild setup
62
62
 
63
63
  # Also create a CLAUDE.md template
64
64
  guild setup --claude-md
65
+
66
+ # Install Codex skill files
67
+ guild setup --codex
68
+
69
+ # Also create an AGENTS.md template for Codex
70
+ guild setup --codex --agents-md
65
71
  ```
66
72
 
67
73
  ### Creating Agents
package/docs/DESIGN.md CHANGED
@@ -188,7 +188,7 @@ Environments are Docker containers managed by GuildCore. The CLI provides a simp
188
188
 
189
189
  ## Integration with Developer Tools
190
190
 
191
- The CLI integrates with AI coding assistants like Claude Code, Cursor, and others. Run `guild setup` to install Guild skills into your project.
191
+ The CLI integrates with AI coding assistants like Claude Code, Cursor, and others. Run `guild setup` to install Claude Code skills into your project, or `guild setup --codex` to install Codex skills.
192
192
 
193
193
  The CLI also exposes a [Model Context Protocol](https://modelcontextprotocol.io/) (MCP) server via `guild mcp`. This gives coding assistants direct access to Guild's API — searching agents, managing workspaces, reading contexts, and starting sessions — without leaving the editor. `guild setup` configures it by default; use `--no-mcp` to skip.
194
194
 
@@ -0,0 +1,155 @@
1
+ ---
2
+ name: guild-agent-dev
3
+ description: Use when working on Guild agents with Codex: creating agents, editing agent code, testing with the Guild CLI, saving versions, publishing, debugging sessions, or answering questions about Guild agent development.
4
+ ---
5
+
6
+ # Guild Agent Development
7
+
8
+ Use the Guild CLI for local agent development. Prefer commands that are scriptable and safe for a coding agent to run.
9
+
10
+ ## First Checks
11
+
12
+ Before changing an agent, establish the local context:
13
+
14
+ ```bash
15
+ guild --version
16
+ guild auth status
17
+ guild workspace current
18
+ ```
19
+
20
+ If authentication or workspace selection is missing, tell the user the exact command to run:
21
+
22
+ ```bash
23
+ guild auth login
24
+ guild workspace select
25
+ ```
26
+
27
+ ## Core Rules
28
+
29
+ - Use `guild agent init`, `guild agent clone`, `guild agent pull`, `guild agent test`, `guild agent chat`, and `guild agent save` for agent lifecycle work.
30
+ - Do not edit `guild.json`; it is managed by the CLI.
31
+ - Prefer `guild agent save -A --message "..."` instead of raw `git add`, `git commit`, or `git push`.
32
+ - Do not use `git push` directly for agent repositories; use `guild agent save`.
33
+ - Keep edits scoped to the agent files requested by the user.
34
+ - Surface command output that matters, especially validation errors, session links, workspace IDs, and next commands.
35
+
36
+ ## Common Workflows
37
+
38
+ Create a new agent:
39
+
40
+ ```bash
41
+ mkdir my-agent && cd my-agent
42
+ guild agent init --name my-agent --template LLM
43
+ ```
44
+
45
+ Clone an existing agent:
46
+
47
+ ```bash
48
+ guild agent clone owner/agent-name
49
+ cd agent-name
50
+ ```
51
+
52
+ Sync before editing when collaborating:
53
+
54
+ ```bash
55
+ guild agent pull
56
+ ```
57
+
58
+ Test unsaved local changes:
59
+
60
+ ```bash
61
+ guild agent test --ephemeral
62
+ ```
63
+
64
+ For non-interactive Codex test loops, prefer JSON input:
65
+
66
+ ```bash
67
+ printf '{"type":"text","text":"hello"}\n' | guild agent test --ephemeral --mode json
68
+ ```
69
+
70
+ Send a single message to the agent in the current directory:
71
+
72
+ ```bash
73
+ guild agent chat --ephemeral "Hello"
74
+ ```
75
+
76
+ Save a draft version:
77
+
78
+ ```bash
79
+ guild agent save -A --message "Describe the change"
80
+ ```
81
+
82
+ Save, validate, and publish:
83
+
84
+ ```bash
85
+ guild agent save -A --message "Ready" --wait --publish
86
+ ```
87
+
88
+ ## Debugging
89
+
90
+ If a test fails or stalls:
91
+
92
+ ```bash
93
+ guild doctor
94
+ guild agent versions
95
+ guild session events <session-id>
96
+ guild session tasks <session-id>
97
+ ```
98
+
99
+ Use `--debug` when command output is too sparse:
100
+
101
+ ```bash
102
+ guild --debug agent test --ephemeral
103
+ ```
104
+
105
+ ## Agent Code Patterns
106
+
107
+ LLM agents use a prompt and tools:
108
+
109
+ ```typescript
110
+ import { llmAgent, guildTools } from '@guildai/agents-sdk';
111
+
112
+ export default llmAgent({
113
+ description: 'Helps users with Guild workspaces',
114
+ tools: { ...guildTools },
115
+ systemPrompt: `You are a helpful Guild workspace assistant.`,
116
+ mode: 'multi-turn',
117
+ });
118
+ ```
119
+
120
+ Code-first agents call tools through `task.tools`:
121
+
122
+ ```typescript
123
+ 'use agent';
124
+
125
+ import { agent, guildTools, type Task } from '@guildai/agents-sdk';
126
+ import { z } from 'zod';
127
+
128
+ const tools = { ...guildTools };
129
+ type Tools = typeof tools;
130
+
131
+ const inputSchema = z.object({
132
+ type: z.literal('text'),
133
+ text: z.string(),
134
+ });
135
+
136
+ const outputSchema = z.object({
137
+ type: z.literal('text'),
138
+ text: z.string(),
139
+ });
140
+
141
+ async function run(input: z.infer<typeof inputSchema>, task: Task<Tools>) {
142
+ await task.tools.guild_debug_log({ message: input.text });
143
+ return { type: 'text' as const, text: input.text };
144
+ }
145
+
146
+ export default agent({
147
+ description: 'Echoes user text',
148
+ inputSchema,
149
+ outputSchema,
150
+ tools,
151
+ run,
152
+ });
153
+ ```
154
+
155
+ All tool calls go through `task.tools.<toolName>(args)`.