@guildai/cli 0.5.3 → 0.5.4
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 +190 -42
- package/dist/commands/agent/chat.js +5 -5
- package/dist/commands/agent/save.js +57 -5
- package/dist/commands/agent/test.js +5 -5
- package/dist/commands/chat.js +15 -1
- package/dist/commands/config/set.js +19 -27
- package/dist/commands/session/list.js +1 -1
- package/dist/lib/api-client.d.ts +0 -3
- package/dist/lib/api-client.js +0 -2
- package/dist/lib/owner-helpers.d.ts +5 -0
- package/dist/lib/owner-helpers.js +31 -25
- package/docs/DESIGN.md +27 -61
- package/package.json +3 -3
- package/dist/lib/formatters.d.ts +0 -44
- package/dist/lib/formatters.js +0 -51
- package/docs/getting-started.md +0 -440
- package/docs/output-format.md +0 -126
- package/docs/session-events.md +0 -143
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Command-line interface for [Guild.ai](https://guild.ai) — build, test, and deploy AI agents.
|
|
4
4
|
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- **Node.js 18+** and **npm** — [nodejs.org](https://nodejs.org)
|
|
8
|
+
- **A Guild account** — Guild.ai is in closed beta. Request an invitation at hello@guild.ai
|
|
9
|
+
|
|
5
10
|
## Installation
|
|
6
11
|
|
|
7
12
|
```bash
|
|
@@ -16,68 +21,126 @@ npm install -g @guildai/cli
|
|
|
16
21
|
guild auth login
|
|
17
22
|
```
|
|
18
23
|
|
|
19
|
-
|
|
24
|
+
This opens your browser to complete sign-in at [app.guild.ai](https://app.guild.ai). It also configures your local npm registry so the CLI can install Guild packages.
|
|
25
|
+
|
|
26
|
+
Verify:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
guild auth status
|
|
30
|
+
```
|
|
20
31
|
|
|
21
|
-
### 2.
|
|
32
|
+
### 2. Select a workspace
|
|
22
33
|
|
|
23
34
|
```bash
|
|
24
|
-
|
|
25
|
-
guild agent init --name my-agent
|
|
35
|
+
guild workspace select
|
|
26
36
|
```
|
|
27
37
|
|
|
28
|
-
|
|
38
|
+
If you have one workspace, it's selected automatically. If you have several, pick one from the list.
|
|
39
|
+
|
|
40
|
+
### 3. Create an agent
|
|
29
41
|
|
|
30
42
|
```bash
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
mkdir hello-agent && cd hello-agent
|
|
44
|
+
guild agent init --name hello-agent --template LLM
|
|
45
|
+
```
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
This creates the agent in the Guild backend, initializes a local git repo, and pulls starter files:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
hello-agent/
|
|
51
|
+
├── agent.ts # Your agent code
|
|
52
|
+
├── package.json # Dependencies
|
|
53
|
+
├── tsconfig.json # TypeScript config
|
|
54
|
+
├── guild.json # Local config (managed by the CLI, don't edit)
|
|
55
|
+
└── .gitignore
|
|
37
56
|
```
|
|
38
57
|
|
|
39
|
-
### 4.
|
|
58
|
+
### 4. Edit the agent
|
|
59
|
+
|
|
60
|
+
Open `agent.ts` and replace the contents:
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { llmAgent, guildTools, userInterfaceTools } from '@guildai/agents-sdk';
|
|
64
|
+
|
|
65
|
+
export default llmAgent({
|
|
66
|
+
description: 'A friendly greeting agent',
|
|
67
|
+
tools: { ...guildTools, ...userInterfaceTools },
|
|
68
|
+
systemPrompt: `You are a friendly assistant. Greet users warmly and answer their questions.`,
|
|
69
|
+
mode: 'multi-turn',
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 5. Test it
|
|
40
74
|
|
|
41
75
|
```bash
|
|
42
|
-
guild agent test
|
|
76
|
+
guild agent test --ephemeral
|
|
43
77
|
```
|
|
44
78
|
|
|
45
|
-
|
|
79
|
+
Type a message and press Enter. Press `Ctrl+C` to exit.
|
|
80
|
+
|
|
81
|
+
### 6. Save and publish
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
guild agent save --message "First version" --wait --publish
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
- `--wait` blocks until validation passes
|
|
88
|
+
- `--publish` makes the agent available in the Guild catalog
|
|
89
|
+
|
|
90
|
+
## Templates
|
|
91
|
+
|
|
92
|
+
| Template | Use when |
|
|
93
|
+
| -------------------- | -------------------------------------------------------------------- |
|
|
94
|
+
| `LLM` | The LLM is the logic. You write a prompt and pick tools. Start here. |
|
|
95
|
+
| `AUTO_MANAGED_STATE` | You write procedural TypeScript that calls tools inline. |
|
|
96
|
+
| `BLANK` | You want full control over the agent lifecycle. |
|
|
97
|
+
|
|
98
|
+
## Development Loop
|
|
99
|
+
|
|
100
|
+
The typical workflow: pull → edit → test → save.
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
guild agent pull # Sync remote changes
|
|
104
|
+
# ... edit agent.ts ...
|
|
105
|
+
guild agent test # Interactive test session
|
|
106
|
+
guild agent save --message "Add Slack notifications" # Save as draft
|
|
107
|
+
guild agent save --message "Ready" --wait --publish # Save + validate + publish
|
|
108
|
+
```
|
|
46
109
|
|
|
47
110
|
## Commands
|
|
48
111
|
|
|
49
112
|
### Authentication
|
|
50
113
|
|
|
51
114
|
```bash
|
|
52
|
-
guild auth login
|
|
53
|
-
guild auth logout
|
|
54
|
-
guild auth status
|
|
115
|
+
guild auth login # OAuth device flow login
|
|
116
|
+
guild auth logout # Remove stored token
|
|
117
|
+
guild auth status # Check authentication status
|
|
118
|
+
guild auth token # Print auth token to stdout (for scripting)
|
|
55
119
|
```
|
|
56
120
|
|
|
57
121
|
### Agents
|
|
58
122
|
|
|
59
123
|
```bash
|
|
60
124
|
guild agent init --name my-agent # Initialize a new agent
|
|
61
|
-
guild agent clone <
|
|
62
|
-
guild agent save # Push commits and create a version
|
|
63
|
-
guild agent save -A --message "..." # Stage+commit+push in one step
|
|
125
|
+
guild agent clone <identifier> # Clone an existing agent
|
|
64
126
|
guild agent pull # Pull remote changes
|
|
65
|
-
guild agent
|
|
66
|
-
guild agent
|
|
67
|
-
guild agent chat "message" # Send a single message
|
|
68
|
-
guild agent get [agent-id] # Get agent details
|
|
69
|
-
guild agent versions [agent-id] # List versions
|
|
70
|
-
guild agent code [agent-id] # View latest published source
|
|
71
|
-
guild agent list # List all agents
|
|
72
|
-
guild agent grep <pattern> # Search agent source code
|
|
127
|
+
guild agent save --message "..." # Save changes (creates draft version)
|
|
128
|
+
guild agent save --message "..." --wait --publish # Save + validate + publish
|
|
73
129
|
guild agent publish # Publish latest draft version
|
|
74
|
-
guild agent unpublish #
|
|
75
|
-
guild agent
|
|
76
|
-
guild agent
|
|
130
|
+
guild agent unpublish # Unpublish latest published version
|
|
131
|
+
guild agent test # Interactive test session
|
|
132
|
+
guild agent test --ephemeral # Test uncommitted changes
|
|
133
|
+
guild agent chat "Hello" # Send a single message
|
|
134
|
+
guild agent get [identifier] # Get agent details
|
|
135
|
+
guild agent versions [identifier] # List version history
|
|
136
|
+
guild agent code [identifier] # Fetch latest published code
|
|
137
|
+
guild agent list # List all agents
|
|
138
|
+
guild agent search <query> # Search published agents
|
|
139
|
+
guild agent grep <pattern> # Search agent code files
|
|
140
|
+
guild agent fork <agent-id>:<version> # Fork an existing agent version
|
|
77
141
|
guild agent owners # List accounts that can own agents
|
|
78
|
-
guild agent tags list
|
|
79
|
-
guild agent
|
|
80
|
-
guild agent tags remove <tag...> # Remove tags
|
|
142
|
+
guild agent tags list|add|remove # Manage agent tags
|
|
143
|
+
guild agent revalidate # Re-run validation
|
|
81
144
|
```
|
|
82
145
|
|
|
83
146
|
### Workspaces
|
|
@@ -97,6 +160,29 @@ guild workspace context edit # Edit context (opens editor)
|
|
|
97
160
|
guild workspace context publish # Publish draft context
|
|
98
161
|
```
|
|
99
162
|
|
|
163
|
+
### Sessions
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
guild session list # List sessions in a workspace
|
|
167
|
+
guild session get <session-id> # Get session details
|
|
168
|
+
guild session events <session-id> # List events in a session
|
|
169
|
+
guild session tasks <session-id> # List tasks in a session
|
|
170
|
+
guild session create # Create a new session
|
|
171
|
+
guild session send <session-id> # Send a message to a session
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Triggers
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
guild trigger list # List triggers in a workspace
|
|
178
|
+
guild trigger get <trigger-id> # Get trigger details
|
|
179
|
+
guild trigger create # Create a new trigger
|
|
180
|
+
guild trigger update <trigger-id> # Update a trigger
|
|
181
|
+
guild trigger activate <trigger-id> # Activate a trigger
|
|
182
|
+
guild trigger deactivate <trigger-id> # Deactivate a trigger
|
|
183
|
+
guild trigger sessions <trigger-id> # List sessions spawned by a trigger
|
|
184
|
+
```
|
|
185
|
+
|
|
100
186
|
### Chat
|
|
101
187
|
|
|
102
188
|
```bash
|
|
@@ -105,6 +191,29 @@ guild chat "your message" # One-shot message
|
|
|
105
191
|
guild chat --agent <agent-id> # Chat with specific agent
|
|
106
192
|
```
|
|
107
193
|
|
|
194
|
+
### Configuration
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
guild config list # Show all configuration values
|
|
198
|
+
guild config get <key> # Get a configuration value
|
|
199
|
+
guild config set <key> <value> # Set a global configuration value
|
|
200
|
+
guild config path # Show configuration file paths
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Diagnostics
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
guild doctor # Check CLI setup and diagnose issues
|
|
207
|
+
guild version # Show version info
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Coding Assistant Skills
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
guild setup # Install Guild skills for coding assistants
|
|
214
|
+
guild setup --claude-md # Also create a CLAUDE.md template
|
|
215
|
+
```
|
|
216
|
+
|
|
108
217
|
## Configuration
|
|
109
218
|
|
|
110
219
|
**Global config** (`~/.guild/config.json`):
|
|
@@ -134,28 +243,67 @@ OAuth tokens are stored in your system's secure credential store:
|
|
|
134
243
|
|
|
135
244
|
## Troubleshooting
|
|
136
245
|
|
|
137
|
-
###
|
|
246
|
+
### "Connection refused" or "Cannot connect to server"
|
|
247
|
+
|
|
248
|
+
1. Check your internet connection
|
|
249
|
+
2. Run `guild doctor` to see which check is failing
|
|
250
|
+
|
|
251
|
+
### "Not authenticated"
|
|
138
252
|
|
|
139
253
|
```bash
|
|
140
|
-
guild auth
|
|
141
|
-
guild auth
|
|
142
|
-
guild auth login # Re-authenticate
|
|
254
|
+
guild auth login
|
|
255
|
+
guild auth status
|
|
143
256
|
```
|
|
144
257
|
|
|
145
|
-
###
|
|
258
|
+
### "Workspace not found" or wrong workspace
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
guild workspace select
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Or override for a single command:
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
GUILD_WORKSPACE_ID=<workspace-id> guild agent test
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### "No agent ID provided and not in an agent directory"
|
|
271
|
+
|
|
272
|
+
Either run from inside an agent directory (one with a `guild.json` file), or pass the agent ID explicitly:
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
guild agent get <agent-id>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### "No changes to commit"
|
|
279
|
+
|
|
280
|
+
All changes are already committed. Make a code change first, then run `guild agent save` again.
|
|
281
|
+
|
|
282
|
+
### Validation failures
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
guild agent versions --limit 1 # Check for errors
|
|
286
|
+
# Fix the issue, then:
|
|
287
|
+
guild agent save --message "Fix" --wait
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Agent test not responding
|
|
291
|
+
|
|
292
|
+
1. Check your agent code compiles — look for TypeScript errors in `agent.ts`
|
|
293
|
+
2. Make sure you've saved at least once: `guild agent save --message "initial"`
|
|
294
|
+
3. Try a single message instead: `guild agent chat "hello"`
|
|
146
295
|
|
|
147
|
-
|
|
296
|
+
### Keychain issues
|
|
148
297
|
|
|
149
298
|
- **macOS**: Ensure Keychain Access is working and not locked
|
|
150
299
|
- **Linux**: Install and configure libsecret (e.g., `gnome-keyring`)
|
|
151
300
|
- **Windows**: Check Credential Manager is accessible
|
|
152
301
|
|
|
153
|
-
### Command
|
|
302
|
+
### Command not found
|
|
154
303
|
|
|
155
304
|
Ensure npm global bin directory is in your PATH:
|
|
156
305
|
|
|
157
306
|
```bash
|
|
158
|
-
npm config get prefix
|
|
159
307
|
export PATH="$(npm config get prefix)/bin:$PATH"
|
|
160
308
|
```
|
|
161
309
|
|
|
@@ -166,4 +314,4 @@ export PATH="$(npm config get prefix)/bin:$PATH"
|
|
|
166
314
|
|
|
167
315
|
## License
|
|
168
316
|
|
|
169
|
-
|
|
317
|
+
MIT
|
|
@@ -3,7 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import { render } from 'ink';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import open from 'open';
|
|
6
|
-
import
|
|
6
|
+
import { hyperlink } from '../../lib/colors.js';
|
|
7
7
|
import { getAgentId, readAgentFiles } from '../../lib/agent-helpers.js';
|
|
8
8
|
import { ChatApp, createSession, ensureAuthenticated } from '../chat.js';
|
|
9
9
|
import { readFileSync } from 'fs';
|
|
@@ -172,10 +172,10 @@ export function createAgentChatCommand() {
|
|
|
172
172
|
const session = await createSession(client, options.workspace, initialPrompt, version.id);
|
|
173
173
|
if (!quiet) {
|
|
174
174
|
console.log(`✓ Agent: ${config?.name || agentId}`);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
175
|
+
const sessionLink = session.session_url
|
|
176
|
+
? hyperlink(session.id, session.session_url)
|
|
177
|
+
: session.id;
|
|
178
|
+
console.log(`✓ Session: ${sessionLink}`);
|
|
179
179
|
console.log('');
|
|
180
180
|
}
|
|
181
181
|
if (options.open && session.session_url) {
|
|
@@ -17,13 +17,29 @@ export function createAgentSaveCommand() {
|
|
|
17
17
|
.option('--message <text>', 'Commit message (required with --all)')
|
|
18
18
|
.option('--wait', 'Wait for validation to complete before returning', false)
|
|
19
19
|
.option('--publish', 'Publish after validation passes (implies --wait)', false)
|
|
20
|
+
.option('--bump [level]', 'Bump package.json version before saving (patch, or minor/major)', 'patch')
|
|
21
|
+
.option('--no-bump', 'Skip automatic version bump')
|
|
20
22
|
.option('--json', 'Output JSON only (no progress messages)', false)
|
|
21
23
|
.action(async (options) => {
|
|
22
24
|
const cwd = process.cwd();
|
|
23
25
|
let guildConfig = null;
|
|
24
26
|
const output = createOutputWriter();
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
+
// Resolve bump level: bare --bump defaults to 'patch', --no-bump skips
|
|
28
|
+
const bumpLevel = options.bump === true || options.bump === 'patch'
|
|
29
|
+
? 'patch'
|
|
30
|
+
: options.bump === 'minor'
|
|
31
|
+
? 'minor'
|
|
32
|
+
: options.bump === 'major'
|
|
33
|
+
? 'major'
|
|
34
|
+
: options.bump === false
|
|
35
|
+
? null
|
|
36
|
+
: null;
|
|
37
|
+
if (options.bump !== false && bumpLevel === null) {
|
|
38
|
+
output.error(`Invalid bump level: ${String(options.bump)}`, 'Valid levels are: patch, minor, major\n guild agent save --bump minor');
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
// With --all, a commit message is required (unless bump auto-generates one)
|
|
42
|
+
if (options.all && !options.message && !bumpLevel) {
|
|
27
43
|
output.error('Commit message is required with --all', 'Provide a message describing your changes:\n guild agent save -A --message "Add new feature"');
|
|
28
44
|
process.exit(1);
|
|
29
45
|
}
|
|
@@ -40,6 +56,39 @@ export function createAgentSaveCommand() {
|
|
|
40
56
|
}
|
|
41
57
|
// Read guild.json
|
|
42
58
|
guildConfig = JSON.parse(await fs.readFile(guildJsonPath, 'utf-8'));
|
|
59
|
+
// Handle --bump: bump package.json version before git operations
|
|
60
|
+
if (bumpLevel) {
|
|
61
|
+
const packageJsonPath = path.join(cwd, 'package.json');
|
|
62
|
+
let packageJsonContent;
|
|
63
|
+
try {
|
|
64
|
+
packageJsonContent = await fs.readFile(packageJsonPath, 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
output.error('package.json not found', 'A package.json file is required in the agent directory to use --bump.');
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
71
|
+
const currentVersion = packageJson.version || '0.0.0';
|
|
72
|
+
const parts = currentVersion.split('.').map(Number);
|
|
73
|
+
if (parts.length !== 3 || parts.some((p) => isNaN(p))) {
|
|
74
|
+
output.error(`Cannot bump invalid version: ${currentVersion}`, 'package.json version must be in MAJOR.MINOR.PATCH format (e.g. 1.0.0)');
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
const [major, minor, patch] = parts;
|
|
78
|
+
let newVersion;
|
|
79
|
+
if (bumpLevel === 'major') {
|
|
80
|
+
newVersion = `${major + 1}.0.0`;
|
|
81
|
+
}
|
|
82
|
+
else if (bumpLevel === 'minor') {
|
|
83
|
+
newVersion = `${major}.${minor + 1}.0`;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
newVersion = `${major}.${minor}.${patch + 1}`;
|
|
87
|
+
}
|
|
88
|
+
packageJson.version = newVersion;
|
|
89
|
+
await fs.writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2) + '\n');
|
|
90
|
+
output.progress(`✓ Bumped version: ${currentVersion} → ${newVersion}`);
|
|
91
|
+
}
|
|
43
92
|
// Check for uncommitted changes and unpushed commits
|
|
44
93
|
const { stdout: statusOutput } = await runGit(['status', '--porcelain'], {
|
|
45
94
|
cwd,
|
|
@@ -65,12 +114,15 @@ export function createAgentSaveCommand() {
|
|
|
65
114
|
hasUnpushedCommits = false;
|
|
66
115
|
}
|
|
67
116
|
}
|
|
68
|
-
|
|
69
|
-
|
|
117
|
+
// --bump implies --all (the version change needs to be committed)
|
|
118
|
+
const shouldStageAll = options.all || !!bumpLevel;
|
|
119
|
+
if (shouldStageAll) {
|
|
120
|
+
// Stage and commit before pushing
|
|
70
121
|
if (hasUncommittedChanges) {
|
|
71
122
|
await runGit(['add', '-A'], { cwd });
|
|
72
123
|
output.progress('✓ Staged changes');
|
|
73
|
-
|
|
124
|
+
const commitMsg = options.message || (bumpLevel ? `Bump version` : '');
|
|
125
|
+
await runGit(['commit', '-m', commitMsg], { cwd });
|
|
74
126
|
output.progress('✓ Committed locally');
|
|
75
127
|
hasUnpushedCommits = true;
|
|
76
128
|
}
|
|
@@ -6,7 +6,7 @@ import { readFileSync } from 'fs';
|
|
|
6
6
|
import path from 'path';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
8
|
import open from 'open';
|
|
9
|
-
import
|
|
9
|
+
import { hyperlink } from '../../lib/colors.js';
|
|
10
10
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
11
11
|
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
12
12
|
import { format } from '../../lib/progress.js';
|
|
@@ -284,10 +284,10 @@ export function createAgentTestCommand() {
|
|
|
284
284
|
: commitSha?.substring(0, 12) || 'unknown';
|
|
285
285
|
console.log(`✓ Version: ${versionDisplay}`);
|
|
286
286
|
console.log(`✓ Workspace: ${workspaceId}`);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
287
|
+
const sessionLink = session.session_url
|
|
288
|
+
? hyperlink(session.id, session.session_url)
|
|
289
|
+
: session.id;
|
|
290
|
+
console.log(`✓ Session: ${sessionLink}`);
|
|
291
291
|
console.log('');
|
|
292
292
|
}
|
|
293
293
|
if (options.open && session.session_url) {
|
package/dist/commands/chat.js
CHANGED
|
@@ -17,7 +17,7 @@ import { printResumeHint, fetchSession, fetchSessionEvents, eventsToDisplayMessa
|
|
|
17
17
|
import { AgentInstallPrompt } from '../components/AgentInstallPrompt.js';
|
|
18
18
|
import { getWorkspaceId } from '../lib/guild-config.js';
|
|
19
19
|
import { ensureInteractiveStdin } from '../lib/stdin.js';
|
|
20
|
-
import { brand, BRAND_COLOR, code as codeColor } from '../lib/colors.js';
|
|
20
|
+
import { brand, BRAND_COLOR, code as codeColor, hyperlink } from '../lib/colors.js';
|
|
21
21
|
import { SplashAnimation } from '../components/SplashAnimation.js';
|
|
22
22
|
import { LOADING_TIMINGS } from '../lib/loading-messages.js';
|
|
23
23
|
import { suppressScrollbackClear } from '../lib/alternate-screen.js';
|
|
@@ -222,10 +222,20 @@ function ChatUIWithConnection({ initialPrompt, version: _version, versionId: _ve
|
|
|
222
222
|
const resumeDisplayMessages = resumeEvents
|
|
223
223
|
? eventsToDisplayMessages(resumeEvents)
|
|
224
224
|
: null;
|
|
225
|
+
const sessionLinkMessage = isActive && preConnectedSession?.session_url
|
|
226
|
+
? [
|
|
227
|
+
{
|
|
228
|
+
key: 'session-link',
|
|
229
|
+
content: chalk.dim(`Session: ${hyperlink(preConnectedSession.id, preConnectedSession.session_url)}`),
|
|
230
|
+
type: 'progress',
|
|
231
|
+
},
|
|
232
|
+
]
|
|
233
|
+
: [];
|
|
225
234
|
const [messages, setMessages] = useState(resumeDisplayMessages
|
|
226
235
|
? resumeDisplayMessages
|
|
227
236
|
: isActive
|
|
228
237
|
? [
|
|
238
|
+
...sessionLinkMessage,
|
|
229
239
|
{
|
|
230
240
|
key: 'initial',
|
|
231
241
|
content: `${brand('>')} ${initialPrompt}`,
|
|
@@ -920,6 +930,10 @@ export function createChatCommand() {
|
|
|
920
930
|
const client = new GuildAPIClient();
|
|
921
931
|
const session = await createSession(client, options.workspace, initialPrompt, options.agent);
|
|
922
932
|
spinner.succeed('Connected');
|
|
933
|
+
if (session.session_url) {
|
|
934
|
+
const sessionLink = hyperlink(session.id, session.session_url);
|
|
935
|
+
console.error(chalk.dim(`Session: ${sessionLink}`));
|
|
936
|
+
}
|
|
923
937
|
console.error('');
|
|
924
938
|
// Non-interactive mode: send message, wait for response, output JSON
|
|
925
939
|
// Poll for messages until we get an agent MESSAGE response
|
|
@@ -6,6 +6,7 @@ import { getOutputMode } from '../../lib/output-mode.js';
|
|
|
6
6
|
import { createOutputWriter } from '../../lib/output.js';
|
|
7
7
|
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
8
8
|
import { debug } from '../../lib/errors.js';
|
|
9
|
+
import { lookupOwner } from '../../lib/owner-helpers.js';
|
|
9
10
|
/**
|
|
10
11
|
* Valid keys for global config (~/.guild/config.json).
|
|
11
12
|
* Note: default_workspace_name is internal (auto-resolved from API).
|
|
@@ -44,27 +45,6 @@ async function resolveWorkspaceName(workspaceId) {
|
|
|
44
45
|
return undefined;
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Fetch owner name by ID from the API.
|
|
49
|
-
* Checks current user first, then organizations.
|
|
50
|
-
* Returns undefined if the lookup fails.
|
|
51
|
-
*/
|
|
52
|
-
async function resolveOwnerName(ownerId) {
|
|
53
|
-
try {
|
|
54
|
-
const client = new GuildAPIClient();
|
|
55
|
-
const me = await client.get('/me');
|
|
56
|
-
if (me.id === ownerId) {
|
|
57
|
-
return me.name;
|
|
58
|
-
}
|
|
59
|
-
const orgs = await client.fetchAll('/me/organizations');
|
|
60
|
-
const org = orgs.find((o) => o.id === ownerId);
|
|
61
|
-
return org?.name;
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
debug('Could not resolve owner name for %s: %s', ownerId, error);
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
48
|
function printResult(key, value, mode, output) {
|
|
69
49
|
if (mode === 'json') {
|
|
70
50
|
output.data({ key, value });
|
|
@@ -113,15 +93,27 @@ export function createConfigSetCommand() {
|
|
|
113
93
|
return;
|
|
114
94
|
}
|
|
115
95
|
if (typedKey === 'default_owner') {
|
|
116
|
-
|
|
96
|
+
let ownerId = value;
|
|
97
|
+
let ownerName;
|
|
98
|
+
try {
|
|
99
|
+
const client = new GuildAPIClient();
|
|
100
|
+
const resolved = await lookupOwner(client, value);
|
|
101
|
+
if (resolved) {
|
|
102
|
+
ownerId = resolved.id;
|
|
103
|
+
ownerName = resolved.name;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
debug('Could not resolve owner for %s: %s', value, error);
|
|
108
|
+
}
|
|
117
109
|
await saveGlobalConfig({
|
|
118
|
-
default_owner:
|
|
119
|
-
default_owner_name:
|
|
110
|
+
default_owner: ownerId,
|
|
111
|
+
default_owner_name: ownerName,
|
|
120
112
|
});
|
|
121
|
-
printResult(key,
|
|
122
|
-
if (
|
|
113
|
+
printResult(key, ownerId, mode, output);
|
|
114
|
+
if (ownerName) {
|
|
123
115
|
if (mode !== 'json') {
|
|
124
|
-
output.progress(` Owner name: ${
|
|
116
|
+
output.progress(` Owner name: ${ownerName}`);
|
|
125
117
|
}
|
|
126
118
|
}
|
|
127
119
|
else {
|
|
@@ -36,7 +36,7 @@ export function createSessionListCommand() {
|
|
|
36
36
|
params.append('limit', options.limit);
|
|
37
37
|
params.append('offset', options.offset);
|
|
38
38
|
if (options.type) {
|
|
39
|
-
params.append('types', options.type);
|
|
39
|
+
params.append('types', options.type.toLowerCase());
|
|
40
40
|
}
|
|
41
41
|
const response = await client.get(`/workspaces/${workspaceId}/sessions?${params.toString()}`);
|
|
42
42
|
if (getOutputMode() === 'json') {
|
package/dist/lib/api-client.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
import { OutputFormatter } from './formatters.js';
|
|
3
2
|
/**
|
|
4
3
|
* Options for configuring the API client
|
|
5
4
|
*/
|
|
6
5
|
export interface APIClientOptions {
|
|
7
6
|
baseUrl?: string;
|
|
8
|
-
formatter?: OutputFormatter;
|
|
9
7
|
defaultTimeout?: number;
|
|
10
8
|
enableRetry?: boolean;
|
|
11
9
|
maxRetries?: number;
|
|
@@ -17,7 +15,6 @@ export interface APIClientOptions {
|
|
|
17
15
|
export declare class GuildAPIClient {
|
|
18
16
|
private client;
|
|
19
17
|
private baseUrl;
|
|
20
|
-
private formatter?;
|
|
21
18
|
private enableRetry;
|
|
22
19
|
private maxRetries;
|
|
23
20
|
constructor(options?: APIClientOptions);
|
package/dist/lib/api-client.js
CHANGED
|
@@ -11,12 +11,10 @@ import { getIapHeaders } from './iap.js';
|
|
|
11
11
|
export class GuildAPIClient {
|
|
12
12
|
client;
|
|
13
13
|
baseUrl;
|
|
14
|
-
formatter;
|
|
15
14
|
enableRetry;
|
|
16
15
|
maxRetries;
|
|
17
16
|
constructor(options = {}) {
|
|
18
17
|
this.baseUrl = options.baseUrl || getGuildcoreUrl();
|
|
19
|
-
this.formatter = options.formatter;
|
|
20
18
|
this.enableRetry = options.enableRetry !== false; // Default: enabled
|
|
21
19
|
this.maxRetries = options.maxRetries || 3;
|
|
22
20
|
this.client = axios.create({
|
|
@@ -4,6 +4,11 @@ export interface OwnerChoice {
|
|
|
4
4
|
name: string;
|
|
5
5
|
type: 'user' | 'organization';
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Look up an owner by ID or name against the current user and their organizations.
|
|
9
|
+
* Returns the resolved owner, or undefined if no match is found.
|
|
10
|
+
*/
|
|
11
|
+
export declare function lookupOwner(client: GuildAPIClient, val: string): Promise<OwnerChoice | undefined>;
|
|
7
12
|
export interface ResolveOwnerOptions {
|
|
8
13
|
ownerFlag?: string;
|
|
9
14
|
client: GuildAPIClient;
|