@guildai/cli 0.11.0 → 0.12.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/dist/auth-CRMO5O3N.js +29 -0
- package/dist/auth-CRMO5O3N.js.map +7 -0
- package/dist/chat-5VX2WJH2.js +303 -0
- package/dist/chat-5VX2WJH2.js.map +7 -0
- package/dist/chat-SIKDYZQK.js +31 -0
- package/dist/chat-SIKDYZQK.js.map +7 -0
- package/dist/chunk-56YCMGL3.js +522 -0
- package/dist/chunk-56YCMGL3.js.map +7 -0
- package/dist/chunk-6EX6E7WP.js +7042 -0
- package/dist/chunk-6EX6E7WP.js.map +7 -0
- package/dist/chunk-B7VAF5UG.js +532 -0
- package/dist/chunk-B7VAF5UG.js.map +7 -0
- package/dist/chunk-DOIYVBNY.js +3057 -0
- package/dist/chunk-DOIYVBNY.js.map +7 -0
- package/dist/chunk-ENKEEJ45.js +17 -0
- package/dist/chunk-ENKEEJ45.js.map +7 -0
- package/dist/chunk-IBRKVGMZ.js +97041 -0
- package/dist/chunk-IBRKVGMZ.js.map +7 -0
- package/dist/chunk-LFMQJOKC.js +19778 -0
- package/dist/chunk-LFMQJOKC.js.map +7 -0
- package/dist/chunk-M347HP6M.js +22896 -0
- package/dist/chunk-M347HP6M.js.map +7 -0
- package/dist/chunk-OYQ476FQ.js +44 -0
- package/dist/chunk-OYQ476FQ.js.map +7 -0
- package/dist/chunk-PNCUR4OB.js +257 -0
- package/dist/chunk-PNCUR4OB.js.map +7 -0
- package/dist/chunk-RIG2HZWM.js +317 -0
- package/dist/chunk-RIG2HZWM.js.map +7 -0
- package/dist/chunk-SPZPZXUN.js +826 -0
- package/dist/chunk-SPZPZXUN.js.map +7 -0
- package/dist/chunk-VVSOU6ON.js +53 -0
- package/dist/chunk-VVSOU6ON.js.map +7 -0
- package/dist/chunk-X3ADGWOF.js +3643 -0
- package/dist/chunk-X3ADGWOF.js.map +7 -0
- package/dist/commands/skill/create.d.ts +3 -0
- package/dist/commands/skill/get.d.ts +3 -0
- package/dist/commands/skill/list.d.ts +3 -0
- package/dist/commands/skill/update.d.ts +3 -0
- package/dist/commands/skill/version/create.d.ts +3 -0
- package/dist/commands/skill/version/get.d.ts +3 -0
- package/dist/commands/skill/version/list.d.ts +3 -0
- package/dist/devtools-AO7YSDOD.js +67 -0
- package/dist/devtools-AO7YSDOD.js.map +7 -0
- package/dist/dist-4CBK6X5H.js +1566 -0
- package/dist/dist-4CBK6X5H.js.map +7 -0
- package/dist/esm-FRAVZP4J.js +13 -0
- package/dist/esm-FRAVZP4J.js.map +7 -0
- package/dist/execa-XQMWSABC.js +35 -0
- package/dist/execa-XQMWSABC.js.map +7 -0
- package/dist/index.js +8230 -263
- package/dist/index.js.map +7 -0
- package/dist/lib/api-types.d.ts +44 -0
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/errors.d.ts +1 -1
- package/dist/lib/output.d.ts +11 -1
- package/dist/lib/session-events.d.ts +1 -1
- package/dist/lib/session-polling.d.ts +24 -1
- package/dist/lib/websocket-client.d.ts +46 -0
- package/dist/open-RF4X5MOP.js +13 -0
- package/dist/open-RF4X5MOP.js.map +7 -0
- package/dist/server-JYVH64FD.js +27659 -0
- package/dist/server-JYVH64FD.js.map +7 -0
- package/dist/test-SNIYRJ32.js +692 -0
- package/dist/test-SNIYRJ32.js.map +7 -0
- package/docs/skills/codex-agent-dev.md +2 -2
- package/package.json +8 -12
- package/dist/commands/agent/chat.js +0 -281
- package/dist/commands/agent/clone.js +0 -118
- package/dist/commands/agent/code.js +0 -87
- package/dist/commands/agent/fork.js +0 -220
- package/dist/commands/agent/get.js +0 -37
- package/dist/commands/agent/grep.js +0 -107
- package/dist/commands/agent/init.js +0 -403
- package/dist/commands/agent/list.js +0 -110
- package/dist/commands/agent/logs.js +0 -62
- package/dist/commands/agent/owners.js +0 -74
- package/dist/commands/agent/publish.js +0 -91
- package/dist/commands/agent/pull.js +0 -194
- package/dist/commands/agent/revalidate.js +0 -56
- package/dist/commands/agent/save.js +0 -345
- package/dist/commands/agent/search.js +0 -61
- package/dist/commands/agent/tags/add.js +0 -73
- package/dist/commands/agent/tags/list.js +0 -43
- package/dist/commands/agent/tags/remove.js +0 -84
- package/dist/commands/agent/tags/set.js +0 -71
- package/dist/commands/agent/test.js +0 -489
- package/dist/commands/agent/unpublish.js +0 -64
- package/dist/commands/agent/update.js +0 -118
- package/dist/commands/agent/versions.js +0 -55
- package/dist/commands/agent/workspaces.js +0 -54
- package/dist/commands/auth/login.js +0 -31
- package/dist/commands/auth/logout.js +0 -24
- package/dist/commands/auth/status.js +0 -38
- package/dist/commands/auth/token.js +0 -19
- package/dist/commands/chat.js +0 -1416
- package/dist/commands/config/get.js +0 -64
- package/dist/commands/config/list.js +0 -46
- package/dist/commands/config/path.js +0 -37
- package/dist/commands/config/set.js +0 -132
- package/dist/commands/credentials/endpoint-list.js +0 -88
- package/dist/commands/credentials/list.js +0 -50
- package/dist/commands/credentials/policy-create.js +0 -66
- package/dist/commands/credentials/policy-delete.js +0 -33
- package/dist/commands/credentials/policy-list.js +0 -45
- package/dist/commands/credentials/policy-update.js +0 -66
- package/dist/commands/doctor.js +0 -233
- package/dist/commands/integration/connect.js +0 -76
- package/dist/commands/integration/create.js +0 -298
- package/dist/commands/integration/get.js +0 -95
- package/dist/commands/integration/list.js +0 -62
- package/dist/commands/integration/operation/create.js +0 -164
- package/dist/commands/integration/operation/list.js +0 -92
- package/dist/commands/integration/update.js +0 -139
- package/dist/commands/integration/version/build.js +0 -86
- package/dist/commands/integration/version/create.js +0 -45
- package/dist/commands/integration/version/get.js +0 -72
- package/dist/commands/integration/version/list.js +0 -45
- package/dist/commands/integration/version/publish.js +0 -79
- package/dist/commands/integration/version/test.js +0 -104
- package/dist/commands/job/get-step.js +0 -40
- package/dist/commands/job/get.js +0 -44
- package/dist/commands/mcp.js +0 -34
- package/dist/commands/session/create.js +0 -59
- package/dist/commands/session/events.js +0 -56
- package/dist/commands/session/get.js +0 -33
- package/dist/commands/session/interrupt.js +0 -33
- package/dist/commands/session/list.js +0 -59
- package/dist/commands/session/send.js +0 -54
- package/dist/commands/session/tasks.js +0 -45
- package/dist/commands/setup.js +0 -260
- package/dist/commands/trigger/activate.js +0 -41
- package/dist/commands/trigger/create.js +0 -197
- package/dist/commands/trigger/deactivate.js +0 -41
- package/dist/commands/trigger/get.js +0 -33
- package/dist/commands/trigger/list.js +0 -57
- package/dist/commands/trigger/sessions.js +0 -48
- package/dist/commands/trigger/update.js +0 -128
- package/dist/commands/version.js +0 -24
- package/dist/commands/workspace/agent/add.js +0 -114
- package/dist/commands/workspace/agent/list.js +0 -78
- package/dist/commands/workspace/agent/remove.js +0 -78
- package/dist/commands/workspace/clear.js +0 -45
- package/dist/commands/workspace/context/edit.js +0 -107
- package/dist/commands/workspace/context/get.js +0 -47
- package/dist/commands/workspace/context/list.js +0 -51
- package/dist/commands/workspace/context/publish.js +0 -42
- package/dist/commands/workspace/create.js +0 -51
- package/dist/commands/workspace/current.js +0 -63
- package/dist/commands/workspace/get.js +0 -39
- package/dist/commands/workspace/list.js +0 -70
- package/dist/commands/workspace/select.js +0 -184
- package/dist/components/AgentInstallPrompt.js +0 -97
- package/dist/components/SplashAnimation.js +0 -321
- package/dist/components/TaskView.js +0 -268
- package/dist/lib/agent-helpers.js +0 -306
- package/dist/lib/alternate-screen.js +0 -59
- package/dist/lib/api-client.js +0 -154
- package/dist/lib/api-types.js +0 -10
- package/dist/lib/auth.js +0 -284
- package/dist/lib/braille-canvas.js +0 -321
- package/dist/lib/colors.js +0 -46
- package/dist/lib/config-cache.js +0 -45
- package/dist/lib/config.js +0 -153
- package/dist/lib/did-you-mean.js +0 -144
- package/dist/lib/errors.js +0 -375
- package/dist/lib/event-filter.js +0 -91
- package/dist/lib/generated-types.js +0 -56
- package/dist/lib/git.js +0 -176
- package/dist/lib/gk.js +0 -91
- package/dist/lib/guild-config.js +0 -178
- package/dist/lib/iap.js +0 -117
- package/dist/lib/integration-helpers.js +0 -38
- package/dist/lib/loading-messages.js +0 -72
- package/dist/lib/logo.js +0 -141
- package/dist/lib/lottie-serverside.js +0 -181
- package/dist/lib/markdown.js +0 -38
- package/dist/lib/npmrc.js +0 -59
- package/dist/lib/output-mode.js +0 -54
- package/dist/lib/output.js +0 -622
- package/dist/lib/owner-helpers.js +0 -112
- package/dist/lib/polling.js +0 -76
- package/dist/lib/progress.js +0 -324
- package/dist/lib/session-events-fetch.js +0 -25
- package/dist/lib/session-events.js +0 -126
- package/dist/lib/session-polling.js +0 -166
- package/dist/lib/session-resume.js +0 -229
- package/dist/lib/spinners.js +0 -770
- package/dist/lib/splash.js +0 -42
- package/dist/lib/stdin.js +0 -91
- package/dist/lib/svg-to-braille.js +0 -76
- package/dist/lib/table.js +0 -59
- package/dist/lib/update-check.js +0 -65
- package/dist/lib/validate-input-schema.js +0 -208
- package/dist/lib/version-helpers.js +0 -137
- package/dist/lib/workspace-helpers.js +0 -49
- package/dist/mcp/resources.js +0 -67
- package/dist/mcp/server.js +0 -64
- package/dist/mcp/tools.js +0 -753
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Guild.ai
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { GuildAPIClient } from '../../../lib/api-client.js';
|
|
5
|
-
import { getAgentId, resolveAgentRef } from '../../../lib/agent-helpers.js';
|
|
6
|
-
import { handleAxiosError, ErrorCodes } from '../../../lib/errors.js';
|
|
7
|
-
import { createOutputWriter } from '../../../lib/output.js';
|
|
8
|
-
export function createAgentTagsSetCommand() {
|
|
9
|
-
const cmd = new Command('set');
|
|
10
|
-
cmd
|
|
11
|
-
.description('Set tags for an agent (replaces all existing tags)')
|
|
12
|
-
.argument('[agent-id]', 'Agent ID (optional if in agent directory)')
|
|
13
|
-
.argument('[tags...]', 'Tags to set (omit to clear all tags)')
|
|
14
|
-
.action(async (agentIdOrFirstTag, remainingTags) => {
|
|
15
|
-
const output = createOutputWriter();
|
|
16
|
-
try {
|
|
17
|
-
const client = new GuildAPIClient();
|
|
18
|
-
// Parse arguments - need to determine if first arg is agent-id or tag
|
|
19
|
-
let agentIdArg;
|
|
20
|
-
let tagsToSet;
|
|
21
|
-
// Try to resolve agent ID from first argument
|
|
22
|
-
try {
|
|
23
|
-
await getAgentId(agentIdOrFirstTag);
|
|
24
|
-
// If successful, first arg was agent-id
|
|
25
|
-
agentIdArg = agentIdOrFirstTag;
|
|
26
|
-
tagsToSet = remainingTags;
|
|
27
|
-
}
|
|
28
|
-
catch {
|
|
29
|
-
// First arg is not agent-id, must be a tag (or undefined for clearing)
|
|
30
|
-
// Try to get agent-id from guild.json
|
|
31
|
-
await getAgentId(undefined);
|
|
32
|
-
agentIdArg = undefined;
|
|
33
|
-
tagsToSet = agentIdOrFirstTag
|
|
34
|
-
? [agentIdOrFirstTag, ...remainingTags]
|
|
35
|
-
: [];
|
|
36
|
-
}
|
|
37
|
-
// Now resolve agent ID properly
|
|
38
|
-
const { agentId, config } = await getAgentId(agentIdArg);
|
|
39
|
-
const resolvedId = await resolveAgentRef(client, agentId);
|
|
40
|
-
// Update tags (direct replacement)
|
|
41
|
-
await client.post(`/agents/${resolvedId}/tags`, { names: tagsToSet });
|
|
42
|
-
const agentName = config?.name || `agent ${agentId}`;
|
|
43
|
-
const label = `${agentName}${config ? '' : ` (${agentId})`}`;
|
|
44
|
-
if (tagsToSet.length === 0) {
|
|
45
|
-
output.success(`Cleared all tags for agent: ${label}`);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
output.success(`Updated tags for agent: ${label}`);
|
|
49
|
-
}
|
|
50
|
-
output.data({ names: tagsToSet });
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
const formattedError = handleAxiosError(error);
|
|
54
|
-
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
55
|
-
output.error('Not authenticated.', 'Run: guild auth login');
|
|
56
|
-
}
|
|
57
|
-
else if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
58
|
-
output.error('Agent not found.', 'Run: guild agent list');
|
|
59
|
-
}
|
|
60
|
-
else if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
61
|
-
output.error('Cannot connect to Guild servers');
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
output.error(`Failed to set tags: ${formattedError.details}`);
|
|
65
|
-
}
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return cmd;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=set.js.map
|
|
@@ -1,489 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Guild.ai
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Command, Option } from 'commander';
|
|
4
|
-
import { render } from 'ink';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { readFileSync } from 'fs';
|
|
7
|
-
import { access } from 'fs/promises';
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import { fileURLToPath } from 'url';
|
|
10
|
-
import open from 'open';
|
|
11
|
-
import { hyperlink } from '../../lib/colors.js';
|
|
12
|
-
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
13
|
-
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
14
|
-
import { format } from '../../lib/progress.js';
|
|
15
|
-
import { parseEventFilter } from '../../lib/event-filter.js';
|
|
16
|
-
import { isQuietMode, getOutputMode } from '../../lib/output-mode.js';
|
|
17
|
-
import { pollForResponse, pollForResponseWithEvents, } from '../../lib/session-polling.js';
|
|
18
|
-
import { readStdinAsJSON, readStdinAsText, ensureInteractiveStdin, } from '../../lib/stdin.js';
|
|
19
|
-
import { loadLocalConfig, getWorkspaceId, getWorkspaceSourceLabel, } from '../../lib/guild-config.js';
|
|
20
|
-
import { GitError, formatGitError } from '../../lib/git.js';
|
|
21
|
-
import { readAgentFiles, buildEphemeralVersion, buildBundledVersion, BundleNotFoundError, BuildTimeoutError, BuildFailedError, } from '../../lib/agent-helpers.js';
|
|
22
|
-
import { validateInputSchema } from '../../lib/validate-input-schema.js';
|
|
23
|
-
import { fetchSession, fetchSessionEvents } from '../../lib/session-resume.js';
|
|
24
|
-
import { ChatApp, ensureAuthenticated } from '../chat.js';
|
|
25
|
-
import { suppressScrollbackClear } from '../../lib/alternate-screen.js';
|
|
26
|
-
// ESM equivalent of __dirname
|
|
27
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
28
|
-
// Read version from package.json
|
|
29
|
-
const packageJson = JSON.parse(readFileSync(path.join(__dirname, '../../../package.json'), 'utf-8'));
|
|
30
|
-
export function createAgentTestCommand() {
|
|
31
|
-
const cmd = new Command('test');
|
|
32
|
-
cmd
|
|
33
|
-
.description('Test agent in interactive REPL session')
|
|
34
|
-
.option('--workspace <identifier>', 'Workspace ID or full name (e.g., owner/workspace-name)')
|
|
35
|
-
.option('--agent-version <id>', 'Test a specific version (UUID or version number)')
|
|
36
|
-
.option('--resume <session-id>', 'Resume an existing test session')
|
|
37
|
-
.option('--open', 'Open session in web dashboard')
|
|
38
|
-
.option('--events <types>', 'Event types to stream (default: user). Shorthands: none, user, system, all, or comma-separated type names')
|
|
39
|
-
.option('--bundle <file>', 'Path to a pre-built gzip+base64 bundle file')
|
|
40
|
-
.option('--no-cache', 'Skip ephemeral build cache (force a fresh build)')
|
|
41
|
-
// Accept --mode so `guild agent test --mode json` works when re-parsed.
|
|
42
|
-
// The actual value is read from process.argv by getOutputMode().
|
|
43
|
-
.addOption(new Option('--mode <format>').hideHelp())
|
|
44
|
-
.action(async (options) => {
|
|
45
|
-
const cwd = process.cwd();
|
|
46
|
-
// Parse --events filter once, before any branching
|
|
47
|
-
const eventFilter = options.events
|
|
48
|
-
? parseEventFilter(options.events)
|
|
49
|
-
: undefined;
|
|
50
|
-
try {
|
|
51
|
-
// Handle --resume: skip build, fetch existing session, hand off to ChatApp
|
|
52
|
-
if (options.resume) {
|
|
53
|
-
await ensureAuthenticated();
|
|
54
|
-
const client = new GuildAPIClient();
|
|
55
|
-
const resumeSession = await fetchSession(client, options.resume);
|
|
56
|
-
const resumeEvents = await fetchSessionEvents(client, options.resume);
|
|
57
|
-
const resumeCommand = 'guild agent test';
|
|
58
|
-
const isInteractive = getOutputMode() === 'interactive' && !isQuietMode();
|
|
59
|
-
if (isInteractive) {
|
|
60
|
-
suppressScrollbackClear();
|
|
61
|
-
}
|
|
62
|
-
const { waitUntilExit } = render(React.createElement(ChatApp, {
|
|
63
|
-
initialPrompt: '',
|
|
64
|
-
version: packageJson.version,
|
|
65
|
-
showSplash: false,
|
|
66
|
-
resumeSession,
|
|
67
|
-
resumeEvents,
|
|
68
|
-
resumeCommand,
|
|
69
|
-
eventFilter,
|
|
70
|
-
}), { exitOnCtrlC: false });
|
|
71
|
-
await waitUntilExit();
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
// Load local config (guild.json)
|
|
75
|
-
const guildConfig = await loadLocalConfig(cwd);
|
|
76
|
-
if (!guildConfig) {
|
|
77
|
-
console.error('Error: Not in an agent directory');
|
|
78
|
-
console.error('');
|
|
79
|
-
console.error('guild.json not found in current directory.');
|
|
80
|
-
console.error('');
|
|
81
|
-
console.error('Initialize an agent directory:');
|
|
82
|
-
console.error(' guild agent init --name my-agent');
|
|
83
|
-
console.error('');
|
|
84
|
-
console.error('Or clone an existing agent:');
|
|
85
|
-
console.error(' guild agent clone <agent-id>');
|
|
86
|
-
process.exit(1);
|
|
87
|
-
}
|
|
88
|
-
// If using JSON/JSONL input, read and validate it early (before auth/session creation)
|
|
89
|
-
// This provides better UX - fail fast on bad input without needing auth
|
|
90
|
-
const outputMode = getOutputMode();
|
|
91
|
-
let inputData;
|
|
92
|
-
let jsonlInputs;
|
|
93
|
-
if (outputMode === 'json') {
|
|
94
|
-
try {
|
|
95
|
-
inputData = await readStdinAsJSON();
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
const err = error;
|
|
99
|
-
console.error(`Error: ${err.message}`);
|
|
100
|
-
console.error('');
|
|
101
|
-
console.error('Example usage:');
|
|
102
|
-
console.error(' echo \'{"prompt": "test"}\' | guild agent test --mode json');
|
|
103
|
-
console.error(' guild agent test --mode json < input.json');
|
|
104
|
-
process.exit(1);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else if (outputMode === 'jsonl') {
|
|
108
|
-
try {
|
|
109
|
-
const stdinContent = await readStdinAsText();
|
|
110
|
-
jsonlInputs = [];
|
|
111
|
-
const lines = stdinContent.split('\n');
|
|
112
|
-
for (let i = 0; i < lines.length; i++) {
|
|
113
|
-
const line = lines[i].trim();
|
|
114
|
-
if (!line)
|
|
115
|
-
continue;
|
|
116
|
-
try {
|
|
117
|
-
jsonlInputs.push(JSON.parse(line));
|
|
118
|
-
}
|
|
119
|
-
catch {
|
|
120
|
-
console.error(`Error: Invalid JSON on line ${i + 1}`);
|
|
121
|
-
console.error('');
|
|
122
|
-
console.error('Each line must be valid JSON.');
|
|
123
|
-
console.error(' cat inputs.jsonl | guild agent test --mode jsonl');
|
|
124
|
-
process.exit(1);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
if (jsonlInputs.length === 0) {
|
|
128
|
-
console.error('Error: No JSON input provided');
|
|
129
|
-
console.error('');
|
|
130
|
-
console.error('Example usage:');
|
|
131
|
-
console.error(' cat inputs.jsonl | guild agent test --mode jsonl');
|
|
132
|
-
process.exit(1);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
const err = error;
|
|
137
|
-
console.error(`Error: ${err.message}`);
|
|
138
|
-
process.exit(1);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
// Validate input against agent's schema locally (before build)
|
|
142
|
-
// Skip when --agent-version is set since local source may differ from that version
|
|
143
|
-
const inputsToValidate = inputData !== undefined ? [inputData] : (jsonlInputs ?? []);
|
|
144
|
-
if (inputsToValidate.length > 0 && !options.agentVersion) {
|
|
145
|
-
const validationResult = await validateInputSchema(cwd, inputsToValidate);
|
|
146
|
-
if (!validationResult.valid) {
|
|
147
|
-
console.error('Input validation failed:');
|
|
148
|
-
for (const err of validationResult.errors) {
|
|
149
|
-
const pathStr = err.path?.length ? ` (at ${err.path.join('.')})` : '';
|
|
150
|
-
console.error(` - ${err.message}${pathStr}`);
|
|
151
|
-
}
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
154
|
-
if ('skipped' in validationResult && validationResult.skipped) {
|
|
155
|
-
format.warn(`Skipping local validation: ${validationResult.reason}`);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
// If using bundle, verify the file exists early (before auth/session creation)
|
|
159
|
-
// so we fail fast without needing auth if the path is wrong.
|
|
160
|
-
if (options.bundle) {
|
|
161
|
-
try {
|
|
162
|
-
await access(options.bundle);
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
console.error(`Error: Bundle file not found: ${options.bundle}`);
|
|
166
|
-
console.error('');
|
|
167
|
-
console.error('Ensure the bundle file exists and the path is correct:');
|
|
168
|
-
console.error(' npm run build');
|
|
169
|
-
console.error(' guild agent test --bundle agent.js.gz');
|
|
170
|
-
process.exit(1);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// Determine workspace (priority: flag > local config > global config)
|
|
174
|
-
let workspaceId = options.workspace;
|
|
175
|
-
let workspaceSourceLabel;
|
|
176
|
-
if (!workspaceId) {
|
|
177
|
-
const resolved = await getWorkspaceId(cwd);
|
|
178
|
-
workspaceId = resolved?.workspaceId;
|
|
179
|
-
workspaceSourceLabel = resolved
|
|
180
|
-
? getWorkspaceSourceLabel(resolved.source)
|
|
181
|
-
: undefined;
|
|
182
|
-
if (!workspaceId) {
|
|
183
|
-
console.error('Error: No default workspace configured');
|
|
184
|
-
console.error('');
|
|
185
|
-
console.error('Set a default workspace interactively:');
|
|
186
|
-
console.error(' guild workspace select');
|
|
187
|
-
console.error('');
|
|
188
|
-
console.error('Or specify a workspace for this test:');
|
|
189
|
-
console.error(' guild agent test --workspace <workspace-id>');
|
|
190
|
-
console.error('');
|
|
191
|
-
console.error('List available workspaces:');
|
|
192
|
-
console.error(' guild workspace list');
|
|
193
|
-
process.exit(1);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
// Validate auth before any API calls or UI rendering
|
|
197
|
-
await ensureAuthenticated();
|
|
198
|
-
// Resolve version for testing
|
|
199
|
-
const client = new GuildAPIClient();
|
|
200
|
-
let version;
|
|
201
|
-
let ephemeralCached = false;
|
|
202
|
-
try {
|
|
203
|
-
if (options.agentVersion) {
|
|
204
|
-
// Explicit version: look it up by ID or version number
|
|
205
|
-
const existingVersions = (await client.get(`/agents/${guildConfig.agent_id}/versions`));
|
|
206
|
-
const match = existingVersions.items.find((v) => v.id === options.agentVersion ||
|
|
207
|
-
v.version_number === options.agentVersion);
|
|
208
|
-
if (!match) {
|
|
209
|
-
console.error(`Error: Version not found: ${options.agentVersion}`);
|
|
210
|
-
console.error('');
|
|
211
|
-
console.error('List available versions:');
|
|
212
|
-
console.error(` guild agent versions ${guildConfig.agent_id}`);
|
|
213
|
-
process.exit(1);
|
|
214
|
-
}
|
|
215
|
-
version = match;
|
|
216
|
-
}
|
|
217
|
-
else if (options.bundle) {
|
|
218
|
-
// Pre-built bundle: skip server-side compilation entirely.
|
|
219
|
-
const result = await buildBundledVersion(client, guildConfig.agent_id, options.bundle, cwd, '[Test] Pre-built bundle');
|
|
220
|
-
version = result.version;
|
|
221
|
-
}
|
|
222
|
-
else {
|
|
223
|
-
// Default: build ephemeral version from working directory,
|
|
224
|
-
// reusing the last build if files haven't changed.
|
|
225
|
-
const agentFiles = await readAgentFiles(cwd);
|
|
226
|
-
const noCache = options.cache === false;
|
|
227
|
-
const result = await buildEphemeralVersion(client, guildConfig.agent_id, agentFiles, cwd, '[Test] Ephemeral development version', { noCache });
|
|
228
|
-
version = result.version;
|
|
229
|
-
ephemeralCached = result.cached;
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
catch (error) {
|
|
233
|
-
if (error instanceof BundleNotFoundError) {
|
|
234
|
-
console.error(`Error: ${error.message}`);
|
|
235
|
-
console.error('');
|
|
236
|
-
console.error('Ensure the bundle file exists and the path is correct:');
|
|
237
|
-
console.error(' npm run build');
|
|
238
|
-
console.error(' guild agent test --bundle agent.js.gz');
|
|
239
|
-
process.exit(1);
|
|
240
|
-
}
|
|
241
|
-
if (error instanceof BuildTimeoutError) {
|
|
242
|
-
console.error('Error: Build did not complete');
|
|
243
|
-
console.error('');
|
|
244
|
-
console.error(error.message);
|
|
245
|
-
console.error('');
|
|
246
|
-
console.error('Check build status:');
|
|
247
|
-
console.error(' guild agent versions');
|
|
248
|
-
process.exit(1);
|
|
249
|
-
}
|
|
250
|
-
if (error instanceof BuildFailedError) {
|
|
251
|
-
console.error(`Error: ${error.message}`);
|
|
252
|
-
process.exit(1);
|
|
253
|
-
}
|
|
254
|
-
if (error instanceof Error &&
|
|
255
|
-
error.message.startsWith('Missing required')) {
|
|
256
|
-
console.error('Error: Could not read agent files');
|
|
257
|
-
console.error('');
|
|
258
|
-
console.error(error.message);
|
|
259
|
-
console.error('');
|
|
260
|
-
console.error('Ensure you are in an agent directory with:');
|
|
261
|
-
console.error(' - agent.ts (required)');
|
|
262
|
-
console.error(' - package.json (required)');
|
|
263
|
-
process.exit(1);
|
|
264
|
-
}
|
|
265
|
-
const formattedError = handleAxiosError(error);
|
|
266
|
-
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
267
|
-
console.error(`Error: Agent not found: ${guildConfig.agent_id}`);
|
|
268
|
-
console.error('');
|
|
269
|
-
console.error('This agent may have been deleted from the backend.');
|
|
270
|
-
console.error('');
|
|
271
|
-
console.error('Verify the agent exists:');
|
|
272
|
-
console.error(` guild agent get ${guildConfig.agent_id}`);
|
|
273
|
-
console.error('');
|
|
274
|
-
console.error('Or initialize a new agent:');
|
|
275
|
-
console.error(' guild agent init --name my-agent');
|
|
276
|
-
process.exit(1);
|
|
277
|
-
}
|
|
278
|
-
throw error;
|
|
279
|
-
}
|
|
280
|
-
// Create test session
|
|
281
|
-
let session;
|
|
282
|
-
try {
|
|
283
|
-
session = (await client.post(`/workspaces/${workspaceId}/sessions`, {
|
|
284
|
-
session_type: 'agent_test',
|
|
285
|
-
agent_version_id: version.id,
|
|
286
|
-
}));
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
const formattedError = handleAxiosError(error);
|
|
290
|
-
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
291
|
-
console.error(`Error: Workspace not found: ${workspaceId}`);
|
|
292
|
-
console.error('');
|
|
293
|
-
console.error('Set a different default workspace:');
|
|
294
|
-
console.error(' guild workspace select');
|
|
295
|
-
console.error('');
|
|
296
|
-
console.error('Or list available workspaces:');
|
|
297
|
-
console.error(' guild workspace list');
|
|
298
|
-
process.exit(1);
|
|
299
|
-
}
|
|
300
|
-
throw error;
|
|
301
|
-
}
|
|
302
|
-
const quiet = isQuietMode();
|
|
303
|
-
if (!quiet) {
|
|
304
|
-
console.log(`✓ Agent: ${guildConfig.name} (${guildConfig.agent_id})`);
|
|
305
|
-
const versionDisplay = options.agentVersion
|
|
306
|
-
? options.agentVersion
|
|
307
|
-
: options.bundle
|
|
308
|
-
? `bundle (${path.basename(options.bundle)})`
|
|
309
|
-
: ephemeralCached
|
|
310
|
-
? 'ephemeral (cached, no changes)'
|
|
311
|
-
: 'ephemeral (working directory)';
|
|
312
|
-
console.log(`✓ Version: ${versionDisplay}`);
|
|
313
|
-
const workspaceDisplay = workspaceSourceLabel
|
|
314
|
-
? `${workspaceId} (from ${workspaceSourceLabel})`
|
|
315
|
-
: workspaceId;
|
|
316
|
-
console.log(`✓ Workspace: ${workspaceDisplay}`);
|
|
317
|
-
const sessionLink = session.session_url
|
|
318
|
-
? hyperlink(session.id, session.session_url)
|
|
319
|
-
: session.id;
|
|
320
|
-
console.log(`✓ Session: ${sessionLink}`);
|
|
321
|
-
console.log('');
|
|
322
|
-
}
|
|
323
|
-
if (options.open && session.session_url) {
|
|
324
|
-
await open(session.session_url);
|
|
325
|
-
}
|
|
326
|
-
// Branch: JSON input mode vs interactive REPL
|
|
327
|
-
if (outputMode === 'json' && inputData) {
|
|
328
|
-
// JSON input mode: one-shot test
|
|
329
|
-
try {
|
|
330
|
-
// Send JSON as event content (inputData already read earlier)
|
|
331
|
-
await client.post(`/sessions/${session.id}/events`, {
|
|
332
|
-
mode: 'json',
|
|
333
|
-
content: inputData,
|
|
334
|
-
});
|
|
335
|
-
// Poll for response (starting from beginning)
|
|
336
|
-
// 3 minutes - allow time for agents that use LLM calls for input parsing
|
|
337
|
-
const { response } = eventFilter
|
|
338
|
-
? await pollForResponseWithEvents(client, session.id, eventFilter, undefined, 180000)
|
|
339
|
-
: await pollForResponse(client, session.id, undefined, 180000);
|
|
340
|
-
if (!response) {
|
|
341
|
-
console.error('Error: No response received from agent within timeout');
|
|
342
|
-
console.error('');
|
|
343
|
-
console.error('The agent did not produce a response in time.');
|
|
344
|
-
console.error('');
|
|
345
|
-
console.error('Possible causes:');
|
|
346
|
-
console.error(' - The agent is still processing (try a longer timeout)');
|
|
347
|
-
console.error(' - The agent encountered an error during execution');
|
|
348
|
-
console.error(" - The input format does not match the agent's input schema");
|
|
349
|
-
console.error('');
|
|
350
|
-
console.error('Check agent logs in the web UI or try interactive mode:');
|
|
351
|
-
console.error(' guild agent test');
|
|
352
|
-
process.exit(1);
|
|
353
|
-
}
|
|
354
|
-
if (quiet) {
|
|
355
|
-
console.log(response);
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
console.log(`< ${response}`);
|
|
359
|
-
console.log('');
|
|
360
|
-
}
|
|
361
|
-
if (!quiet) {
|
|
362
|
-
console.log('✓ Test complete');
|
|
363
|
-
}
|
|
364
|
-
process.exit(0);
|
|
365
|
-
}
|
|
366
|
-
catch (error) {
|
|
367
|
-
const formattedErr = handleAxiosError(error);
|
|
368
|
-
console.error(`Error: ${formattedErr.details}`);
|
|
369
|
-
console.error('');
|
|
370
|
-
if (formattedErr.code === ErrorCodes.SERVER_ERROR) {
|
|
371
|
-
console.error('The server returned an error while processing the event.');
|
|
372
|
-
console.error('');
|
|
373
|
-
console.error('Possible causes:');
|
|
374
|
-
console.error(" - The input format does not match the agent's input schema");
|
|
375
|
-
console.error(' - The agent runtime encountered an error');
|
|
376
|
-
console.error('');
|
|
377
|
-
console.error('Try testing interactively to see more detail:');
|
|
378
|
-
console.error(' guild agent test');
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
console.error('Failed to send event to agent session.');
|
|
382
|
-
console.error('');
|
|
383
|
-
console.error('Example usage:');
|
|
384
|
-
console.error(' echo \'{"type":"text","text":"hello"}\' | guild agent test --mode json');
|
|
385
|
-
console.error(' guild agent test --mode json < input.json');
|
|
386
|
-
}
|
|
387
|
-
process.exit(1);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
else if (outputMode === 'jsonl' && jsonlInputs) {
|
|
391
|
-
// JSONL input mode: line-by-line processing (inputs already parsed and validated)
|
|
392
|
-
let processedCount = 0;
|
|
393
|
-
let lastEventId;
|
|
394
|
-
for (let inputIndex = 0; inputIndex < jsonlInputs.length; inputIndex++) {
|
|
395
|
-
const jsonInput = jsonlInputs[inputIndex];
|
|
396
|
-
if (!quiet) {
|
|
397
|
-
console.error(`Processing input ${inputIndex + 1}/${jsonlInputs.length}...`);
|
|
398
|
-
}
|
|
399
|
-
try {
|
|
400
|
-
// Send message
|
|
401
|
-
await client.post(`/sessions/${session.id}/events`, {
|
|
402
|
-
mode: 'json',
|
|
403
|
-
content: jsonInput,
|
|
404
|
-
});
|
|
405
|
-
// Wait for response (looking for events after last seen)
|
|
406
|
-
const result = eventFilter
|
|
407
|
-
? await pollForResponseWithEvents(client, session.id, eventFilter, lastEventId, 180000)
|
|
408
|
-
: await pollForResponse(client, session.id, lastEventId, 180000);
|
|
409
|
-
lastEventId = result.lastEventId;
|
|
410
|
-
if (!result.response) {
|
|
411
|
-
console.error(`Timeout: No response for input ${inputIndex + 1}`);
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
const response = result.response;
|
|
415
|
-
// Output response
|
|
416
|
-
if (quiet) {
|
|
417
|
-
console.log(response);
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
console.log(`< ${response}`);
|
|
421
|
-
console.log('');
|
|
422
|
-
}
|
|
423
|
-
processedCount++;
|
|
424
|
-
}
|
|
425
|
-
catch (error) {
|
|
426
|
-
const formattedErr = handleAxiosError(error);
|
|
427
|
-
console.error(`Error processing input ${inputIndex + 1}: ${formattedErr.details}`);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
if (!quiet) {
|
|
431
|
-
console.log(`\n✓ Processed ${processedCount} messages`);
|
|
432
|
-
}
|
|
433
|
-
process.exit(0);
|
|
434
|
-
}
|
|
435
|
-
// Interactive mode: use shared ChatApp (spinner, progress, prompt)
|
|
436
|
-
ensureInteractiveStdin('guild agent test');
|
|
437
|
-
const resumeCommand = 'guild agent test';
|
|
438
|
-
const isInteractive = getOutputMode() === 'interactive' && !isQuietMode();
|
|
439
|
-
if (isInteractive) {
|
|
440
|
-
suppressScrollbackClear();
|
|
441
|
-
}
|
|
442
|
-
// Pass the already-created test session as resumeSession so ChatApp
|
|
443
|
-
// skips its own session creation and uses our agent_test session.
|
|
444
|
-
const { waitUntilExit } = render(React.createElement(ChatApp, {
|
|
445
|
-
initialPrompt: '',
|
|
446
|
-
version: packageJson.version,
|
|
447
|
-
workspaceId,
|
|
448
|
-
versionId: version.id,
|
|
449
|
-
agentName: guildConfig.name,
|
|
450
|
-
showSplash: false,
|
|
451
|
-
resumeSession: session,
|
|
452
|
-
resumeEvents: [],
|
|
453
|
-
resumeCommand,
|
|
454
|
-
eventFilter,
|
|
455
|
-
}), { exitOnCtrlC: false });
|
|
456
|
-
await waitUntilExit();
|
|
457
|
-
}
|
|
458
|
-
catch (error) {
|
|
459
|
-
if (error instanceof GitError) {
|
|
460
|
-
console.error('Error: Git operation failed');
|
|
461
|
-
console.error('');
|
|
462
|
-
console.error(formatGitError(error));
|
|
463
|
-
process.exit(1);
|
|
464
|
-
}
|
|
465
|
-
const formattedError = handleAxiosError(error);
|
|
466
|
-
if (formattedError.code === ErrorCodes.AUTH_REQUIRED ||
|
|
467
|
-
formattedError.code === ErrorCodes.AUTH_TOKEN_INVALID) {
|
|
468
|
-
format.error('Not authenticated. Run: guild auth login');
|
|
469
|
-
process.exit(1);
|
|
470
|
-
}
|
|
471
|
-
console.error(`Error: ${formattedError.details}`);
|
|
472
|
-
console.error('');
|
|
473
|
-
console.error('Failed to start test session. Troubleshooting:');
|
|
474
|
-
console.error(' - Verify the agent exists: guild agent get');
|
|
475
|
-
console.error(' - Check your workspace: guild workspace list');
|
|
476
|
-
if (formattedError.code) {
|
|
477
|
-
console.error(` - Error code: ${formattedError.code}`);
|
|
478
|
-
}
|
|
479
|
-
process.exit(1);
|
|
480
|
-
}
|
|
481
|
-
});
|
|
482
|
-
return cmd;
|
|
483
|
-
}
|
|
484
|
-
// Thin wrapper for lazy-loading from index.ts (avoids importing React at startup)
|
|
485
|
-
export async function handleAgentTestAction(_options) {
|
|
486
|
-
const cmd = createAgentTestCommand();
|
|
487
|
-
await cmd.parseAsync(process.argv.slice(3), { from: 'user' });
|
|
488
|
-
}
|
|
489
|
-
//# sourceMappingURL=test.js.map
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// Copyright 2026 Guild.ai
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { Command } from 'commander';
|
|
4
|
-
import { GuildAPIClient } from '../../lib/api-client.js';
|
|
5
|
-
import { getAgentId, resolveAgentRef } from '../../lib/agent-helpers.js';
|
|
6
|
-
import { handleAxiosError, ErrorCodes } from '../../lib/errors.js';
|
|
7
|
-
import { createOutputWriter } from '../../lib/output.js';
|
|
8
|
-
export function createAgentUnpublishCommand() {
|
|
9
|
-
const cmd = new Command('unpublish');
|
|
10
|
-
cmd
|
|
11
|
-
.description('Unpublish the latest published version of an agent')
|
|
12
|
-
.argument('[identifier]', 'Agent ID or full name (e.g., owner~agent-name)')
|
|
13
|
-
.action(async (agentIdArg) => {
|
|
14
|
-
const output = createOutputWriter();
|
|
15
|
-
try {
|
|
16
|
-
const client = new GuildAPIClient();
|
|
17
|
-
// Resolve agent ID
|
|
18
|
-
const { agentId, config } = await getAgentId(agentIdArg);
|
|
19
|
-
const resolvedId = await resolveAgentRef(client, agentId);
|
|
20
|
-
// Fetch all versions
|
|
21
|
-
const response = await client.get(`/agents/${resolvedId}/versions`);
|
|
22
|
-
// Find latest PUBLISHED version
|
|
23
|
-
const publishedVersions = response.items
|
|
24
|
-
.filter((v) => v.status === 'PUBLISHED')
|
|
25
|
-
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
26
|
-
if (publishedVersions.length === 0) {
|
|
27
|
-
const agentName = config?.name || agentId;
|
|
28
|
-
output.error(`No published versions available for agent: ${agentName}`, 'Publish a draft version:\n guild agent publish');
|
|
29
|
-
process.exit(1);
|
|
30
|
-
}
|
|
31
|
-
const versionToUnpublish = publishedVersions[0];
|
|
32
|
-
// Check if already draft
|
|
33
|
-
if (versionToUnpublish.status === 'DRAFT') {
|
|
34
|
-
output.error(`Version ${versionToUnpublish.id} is already a draft`, 'To publish:\n guild agent publish');
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
// Unpublish version
|
|
38
|
-
await client.post(`/versions/${versionToUnpublish.id}/unpublish`, {});
|
|
39
|
-
output.success(`Unpublished version ${versionToUnpublish.id}`, {
|
|
40
|
-
agent: `${versionToUnpublish.agent?.name || config?.name || agentId}${config ? '' : ` (${agentId})`}`,
|
|
41
|
-
status: 'PUBLISHED → DRAFT',
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
catch (error) {
|
|
45
|
-
const formattedError = handleAxiosError(error);
|
|
46
|
-
if (formattedError.code === ErrorCodes.AUTH_REQUIRED) {
|
|
47
|
-
output.error('Not authenticated. Run: guild auth login');
|
|
48
|
-
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
51
|
-
output.error('Agent not found', 'Run: guild agent list');
|
|
52
|
-
process.exit(1);
|
|
53
|
-
}
|
|
54
|
-
if (formattedError.code === ErrorCodes.CONN_REFUSED) {
|
|
55
|
-
output.error('Cannot connect to Guild servers');
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
output.error(`Failed to unpublish version: ${formattedError.details}`);
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return cmd;
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=unpublish.js.map
|