@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.
- package/README.md +3 -1
- package/dist/commands/agent/chat.js +17 -42
- package/dist/commands/agent/publish.js +13 -53
- package/dist/commands/agent/save.js +14 -50
- package/dist/commands/agent/test.js +24 -51
- package/dist/commands/chat.d.ts +2 -1
- package/dist/commands/chat.js +165 -77
- package/dist/commands/session/interrupt.d.ts +3 -0
- package/dist/commands/session/interrupt.js +33 -0
- package/dist/commands/setup.js +70 -11
- package/dist/index.js +2 -0
- package/dist/lib/event-filter.d.ts +50 -0
- package/dist/lib/event-filter.js +91 -0
- package/dist/lib/generated-types.d.ts +2 -0
- package/dist/lib/generated-types.js +20 -0
- package/dist/lib/session-events.d.ts +26 -1
- package/dist/lib/session-polling.js +1 -1
- package/dist/lib/version-helpers.d.ts +15 -0
- package/dist/lib/version-helpers.js +83 -0
- package/dist/mcp/tools.js +1 -1
- package/docs/CLI_WORKFLOW.md +7 -1
- package/docs/DESIGN.md +1 -1
- package/docs/skills/codex-agent-dev.md +155 -0
- package/docs/skills/integrations.md +338 -0
- package/package.json +1 -1
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Guild Integrations
|
|
3
|
+
description: Build custom integrations that connect external APIs to Guild agents. Activated when user mentions custom integrations, OpenAPI specs, connecting APIs via CLI, guild integration commands, or building service tools for agents.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Guild Integrations
|
|
7
|
+
|
|
8
|
+
Connect external APIs to Guild agents. Integrations are defined by an OpenAPI spec, managed entirely through the CLI, and require no code deployment — tools are generated automatically.
|
|
9
|
+
|
|
10
|
+
## When to Use This
|
|
11
|
+
|
|
12
|
+
Activate when user:
|
|
13
|
+
|
|
14
|
+
- Mentions `guild integration` commands
|
|
15
|
+
- Wants to connect an external API to agents
|
|
16
|
+
- Has an OpenAPI spec they want to use
|
|
17
|
+
- Asks about building custom service tools
|
|
18
|
+
- Mentions integration versions, operations, or publishing
|
|
19
|
+
- Wants to configure auth (API key or OAuth) for an integration
|
|
20
|
+
|
|
21
|
+
## Lifecycle Overview
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
Create integration → Create version → Add operations → Build → Publish → Connect → Use in agent
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Each step is a CLI command. The integration exists in Guild's backend — no local files or npm packages to manage.
|
|
28
|
+
|
|
29
|
+
## CLI Commands
|
|
30
|
+
|
|
31
|
+
### Create an Integration
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
guild integration create <name> \
|
|
35
|
+
--description "What this integration does" \
|
|
36
|
+
--base-url "https://api.example.com" \
|
|
37
|
+
--auth-scheme api-key \
|
|
38
|
+
--header-template "Authorization: Bearer {token}"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Auth schemes (pick one):**
|
|
42
|
+
|
|
43
|
+
**API Key** (simpler, most common):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
guild integration create my-service \
|
|
47
|
+
--auth-scheme api-key \
|
|
48
|
+
--header-template "X-API-Key: {token}"
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The `{token}` placeholder is replaced with the user's stored credential at runtime. Common header templates:
|
|
52
|
+
|
|
53
|
+
- `Authorization: Bearer {token}` — Bearer token
|
|
54
|
+
- `X-API-Key: {token}` — Custom header
|
|
55
|
+
- `Authorization: Token {token}` — Token prefix
|
|
56
|
+
|
|
57
|
+
**OAuth 2.0:**
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
guild integration create my-service \
|
|
61
|
+
--auth-scheme oauth \
|
|
62
|
+
--install-url "https://provider.com/oauth/authorize" \
|
|
63
|
+
--token-url "https://provider.com/oauth/token" \
|
|
64
|
+
--client-id "your-client-id" \
|
|
65
|
+
--client-secret "your-client-secret" \
|
|
66
|
+
--scopes "read,write"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Other options:**
|
|
70
|
+
|
|
71
|
+
- `--owner <org-id>` — Assign to an organization (default: your user account)
|
|
72
|
+
- `--public` — Make visible to all users
|
|
73
|
+
|
|
74
|
+
### Create a Version
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
guild integration version create <integration-id-or-name>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Creates a new draft version. All operation changes happen on a draft before building.
|
|
81
|
+
|
|
82
|
+
### Add Operations from OpenAPI
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
guild integration operation create <integration-id-or-name> <version-id> \
|
|
86
|
+
--openapi spec.yaml
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
The OpenAPI spec defines what API endpoints become available as agent tools. Each operation in the spec becomes one tool.
|
|
90
|
+
|
|
91
|
+
### Build a Version
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
guild integration version build <integration-id-or-name> \
|
|
95
|
+
--version-number 1.0.0
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Assigns a semver version number and triggers validation. The CLI polls until validation completes. Exit code 0 means passed, 1 means failed.
|
|
99
|
+
|
|
100
|
+
Use `--no-wait` to return immediately without polling.
|
|
101
|
+
|
|
102
|
+
### Publish a Version
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
guild integration version publish <integration-id-or-name> \
|
|
106
|
+
--version 1.0.0
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Makes the version available to agents. Only versions that passed validation can be published.
|
|
110
|
+
|
|
111
|
+
### Connect Credentials
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
guild integration connect <integration-id-or-name>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Configures credentials (API key or OAuth tokens) so agents can make authenticated requests.
|
|
118
|
+
|
|
119
|
+
### Test a Version
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
guild integration version test <integration-id-or-name> \
|
|
123
|
+
--version 1.0.0
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### List and Inspect
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
guild integration list # List all integrations
|
|
130
|
+
guild integration get <id-or-name> # Get integration details
|
|
131
|
+
guild integration version list <id-or-name> # List versions
|
|
132
|
+
guild integration operation list <id-or-name> # List operations (tools)
|
|
133
|
+
guild integration operation list <id-or-name> --json # Full schemas in JSON
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## OpenAPI Spec Requirements
|
|
137
|
+
|
|
138
|
+
The parser accepts OpenAPI 3.0 YAML specs. Each qualifying HTTP operation becomes a tool.
|
|
139
|
+
|
|
140
|
+
### Supported HTTP Methods
|
|
141
|
+
|
|
142
|
+
GET, POST, PUT, PATCH, DELETE.
|
|
143
|
+
|
|
144
|
+
### What Gets Extracted
|
|
145
|
+
|
|
146
|
+
For each operation:
|
|
147
|
+
|
|
148
|
+
| OpenAPI field | Maps to |
|
|
149
|
+
| ----------------------------------- | -------------------------------- |
|
|
150
|
+
| `operationId` | Tool name (snake_case) |
|
|
151
|
+
| `summary` | Tool description (max 255 chars) |
|
|
152
|
+
| Path parameters | `input_path_type` schema |
|
|
153
|
+
| Query parameters | `input_query_type` schema |
|
|
154
|
+
| Request body (`application/json`) | `input_body_type` schema |
|
|
155
|
+
| Response body (200/201/204/default) | `output_body_type` schema |
|
|
156
|
+
| `components/schemas` | Reusable type references |
|
|
157
|
+
|
|
158
|
+
### What Gets Skipped
|
|
159
|
+
|
|
160
|
+
- Operations without `application/json` request body (if body is required)
|
|
161
|
+
- Operations without a parseable response schema
|
|
162
|
+
- Non-JSON content types (file uploads, XML, etc.)
|
|
163
|
+
|
|
164
|
+
### Best Practices
|
|
165
|
+
|
|
166
|
+
- Always set `operationId` — otherwise one is synthesized from method+path
|
|
167
|
+
- Define response schemas in `components/schemas` and reference with `$ref` — bare `type: object` produces untyped output
|
|
168
|
+
- Keep `summary` under 255 characters
|
|
169
|
+
- Use `description` for longer explanations
|
|
170
|
+
|
|
171
|
+
### Example Spec
|
|
172
|
+
|
|
173
|
+
```yaml
|
|
174
|
+
openapi: 3.0.3
|
|
175
|
+
info:
|
|
176
|
+
title: Acme API
|
|
177
|
+
version: 1.0.0
|
|
178
|
+
servers:
|
|
179
|
+
- url: https://api.acme.com/v1
|
|
180
|
+
|
|
181
|
+
paths:
|
|
182
|
+
/tickets:
|
|
183
|
+
get:
|
|
184
|
+
operationId: list_tickets
|
|
185
|
+
summary: List all tickets
|
|
186
|
+
parameters:
|
|
187
|
+
- name: status
|
|
188
|
+
in: query
|
|
189
|
+
schema:
|
|
190
|
+
type: string
|
|
191
|
+
enum: [open, closed, pending]
|
|
192
|
+
responses:
|
|
193
|
+
'200':
|
|
194
|
+
content:
|
|
195
|
+
application/json:
|
|
196
|
+
schema:
|
|
197
|
+
$ref: '#/components/schemas/TicketListResponse'
|
|
198
|
+
|
|
199
|
+
/tickets/{ticket_id}:
|
|
200
|
+
get:
|
|
201
|
+
operationId: get_ticket
|
|
202
|
+
summary: Get a ticket by ID
|
|
203
|
+
parameters:
|
|
204
|
+
- name: ticket_id
|
|
205
|
+
in: path
|
|
206
|
+
required: true
|
|
207
|
+
schema:
|
|
208
|
+
type: integer
|
|
209
|
+
responses:
|
|
210
|
+
'200':
|
|
211
|
+
content:
|
|
212
|
+
application/json:
|
|
213
|
+
schema:
|
|
214
|
+
$ref: '#/components/schemas/Ticket'
|
|
215
|
+
|
|
216
|
+
components:
|
|
217
|
+
schemas:
|
|
218
|
+
Ticket:
|
|
219
|
+
type: object
|
|
220
|
+
properties:
|
|
221
|
+
id:
|
|
222
|
+
type: integer
|
|
223
|
+
subject:
|
|
224
|
+
type: string
|
|
225
|
+
status:
|
|
226
|
+
type: string
|
|
227
|
+
enum: [open, closed, pending]
|
|
228
|
+
TicketListResponse:
|
|
229
|
+
type: object
|
|
230
|
+
properties:
|
|
231
|
+
tickets:
|
|
232
|
+
type: array
|
|
233
|
+
items:
|
|
234
|
+
$ref: '#/components/schemas/Ticket'
|
|
235
|
+
total:
|
|
236
|
+
type: integer
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Using Integrations in an Agent
|
|
240
|
+
|
|
241
|
+
After publishing, the integration's tools are available as an npm package:
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
import { AcmeTools } from '@guildai-services/owner~acme';
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Where `owner` is the integration owner's username or org, and `acme` is the integration name.
|
|
248
|
+
|
|
249
|
+
### Selecting Specific Tools
|
|
250
|
+
|
|
251
|
+
Use `pick()` to select only the tools your agent needs:
|
|
252
|
+
|
|
253
|
+
```typescript
|
|
254
|
+
import { pick } from '@guildai/agents-sdk';
|
|
255
|
+
import { AcmeTools } from '@guildai-services/owner~acme';
|
|
256
|
+
|
|
257
|
+
const tools = pick(AcmeTools, ['acme_list_tickets', 'acme_get_ticket']);
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Tool names follow the pattern `{integration}_{operation_id}`.
|
|
261
|
+
|
|
262
|
+
### Requesting Credentials
|
|
263
|
+
|
|
264
|
+
Agents request credentials at runtime via the SDK. The runtime injects stored credentials server-side — agents never see raw API keys or tokens.
|
|
265
|
+
|
|
266
|
+
### Agent package.json
|
|
267
|
+
|
|
268
|
+
Add the integration as a dependency:
|
|
269
|
+
|
|
270
|
+
```json
|
|
271
|
+
{
|
|
272
|
+
"dependencies": {
|
|
273
|
+
"@guildai-services/owner~acme": "*"
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## Webhooks
|
|
279
|
+
|
|
280
|
+
Mark operations as webhook-triggered by adding `x-guild-hook: true` in the OpenAPI spec:
|
|
281
|
+
|
|
282
|
+
```yaml
|
|
283
|
+
paths:
|
|
284
|
+
/tickets/webhook:
|
|
285
|
+
post:
|
|
286
|
+
operationId: receive_ticket_event
|
|
287
|
+
x-guild-hook: true
|
|
288
|
+
summary: Receive ticket webhook events
|
|
289
|
+
requestBody:
|
|
290
|
+
content:
|
|
291
|
+
application/json:
|
|
292
|
+
schema:
|
|
293
|
+
$ref: '#/components/schemas/TicketEvent'
|
|
294
|
+
responses:
|
|
295
|
+
'200':
|
|
296
|
+
content:
|
|
297
|
+
application/json:
|
|
298
|
+
schema:
|
|
299
|
+
type: object
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
Webhook operations deliver responses asynchronously via callback instead of synchronous HTTP response.
|
|
303
|
+
|
|
304
|
+
## Troubleshooting
|
|
305
|
+
|
|
306
|
+
### Validation Failed
|
|
307
|
+
|
|
308
|
+
After `guild integration version build`, check the validation status:
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
guild integration version get <id-or-name> --version 1.0.0 --json
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
Common causes:
|
|
315
|
+
|
|
316
|
+
- Invalid OpenAPI spec syntax
|
|
317
|
+
- Missing required schema references (`$ref` pointing to undefined schemas)
|
|
318
|
+
- Operations with no parseable request/response content types
|
|
319
|
+
|
|
320
|
+
### Operations Not Appearing
|
|
321
|
+
|
|
322
|
+
Run `guild integration operation list <id-or-name> --json` to see what was parsed. Endpoints are skipped when:
|
|
323
|
+
|
|
324
|
+
- No `application/json` content type is available
|
|
325
|
+
- Response schema can't be extracted
|
|
326
|
+
- The operation has no `operationId` and path synthesis failed
|
|
327
|
+
|
|
328
|
+
### Auth Failures at Runtime
|
|
329
|
+
|
|
330
|
+
- **API Key:** Verify `guild integration connect` was run and the token is valid
|
|
331
|
+
- **OAuth:** Check that `install_url`, `token_url`, `client_id`, and `client_secret` are correct
|
|
332
|
+
- Re-run `guild integration connect` to refresh credentials
|
|
333
|
+
|
|
334
|
+
### Package Not Found in Agent
|
|
335
|
+
|
|
336
|
+
- Verify the version is published: `guild integration version list <id-or-name>`
|
|
337
|
+
- Check the import path matches: `@guildai-services/{owner}~{name}`
|
|
338
|
+
- Ensure the agent's `package.json` includes the dependency
|