@guildai/cli 0.10.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/agent/logs.d.ts +3 -0
- package/dist/commands/setup.d.ts +16 -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 +8231 -253
- package/dist/index.js.map +7 -0
- package/dist/lib/api-types.d.ts +44 -0
- package/dist/lib/auth.d.ts +1 -1
- package/dist/lib/config.d.ts +9 -0
- package/dist/lib/errors.d.ts +1 -1
- package/dist/lib/output-mode.d.ts +9 -2
- package/dist/lib/output.d.ts +17 -1
- package/dist/lib/session-events.d.ts +14 -3
- package/dist/lib/session-polling.d.ts +24 -1
- package/dist/lib/session-resume.d.ts +15 -1
- package/dist/lib/stdin.d.ts +5 -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 -278
- package/dist/commands/agent/clone.js +0 -116
- package/dist/commands/agent/code.js +0 -87
- package/dist/commands/agent/fork.js +0 -218
- package/dist/commands/agent/get.js +0 -37
- package/dist/commands/agent/grep.js +0 -107
- package/dist/commands/agent/init.js +0 -390
- package/dist/commands/agent/list.js +0 -110
- package/dist/commands/agent/owners.js +0 -74
- package/dist/commands/agent/publish.js +0 -91
- package/dist/commands/agent/pull.js +0 -198
- package/dist/commands/agent/revalidate.js +0 -56
- package/dist/commands/agent/save.js +0 -346
- 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 -486
- package/dist/commands/agent/unpublish.js +0 -64
- package/dist/commands/agent/update.js +0 -110
- package/dist/commands/agent/versions.js +0 -55
- package/dist/commands/agent/workspaces.js +0 -54
- package/dist/commands/auth/login.js +0 -33
- 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 -1345
- package/dist/commands/config/get.js +0 -64
- package/dist/commands/config/list.js +0 -47
- package/dist/commands/config/path.js +0 -38
- 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 -230
- 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 -33
- package/dist/lib/output.js +0 -591
- 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 -112
- package/dist/lib/session-polling.js +0 -160
- package/dist/lib/session-resume.js +0 -96
- package/dist/lib/spinners.js +0 -770
- package/dist/lib/splash.js +0 -41
- package/dist/lib/stdin.js +0 -84
- 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 -121
- 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
|
@@ -0,0 +1,692 @@
|
|
|
1
|
+
import { createRequire as _cjsReq } from 'module'; if(typeof require === 'undefined') var require = _cjsReq(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
ChatApp,
|
|
4
|
+
ensureAuthenticated,
|
|
5
|
+
fetchSession,
|
|
6
|
+
fetchSessionEvents,
|
|
7
|
+
render_default,
|
|
8
|
+
require_react,
|
|
9
|
+
suppressScrollbackClear
|
|
10
|
+
} from "./chunk-IBRKVGMZ.js";
|
|
11
|
+
import {
|
|
12
|
+
BuildFailedError,
|
|
13
|
+
BuildTimeoutError,
|
|
14
|
+
BundleNotFoundError,
|
|
15
|
+
GitError,
|
|
16
|
+
buildBundledVersion,
|
|
17
|
+
buildEphemeralVersion,
|
|
18
|
+
formatGitError,
|
|
19
|
+
readAgentFiles
|
|
20
|
+
} from "./chunk-B7VAF5UG.js";
|
|
21
|
+
import {
|
|
22
|
+
Command,
|
|
23
|
+
Option,
|
|
24
|
+
getOutputMode,
|
|
25
|
+
isQuietMode
|
|
26
|
+
} from "./chunk-DOIYVBNY.js";
|
|
27
|
+
import {
|
|
28
|
+
open_default
|
|
29
|
+
} from "./chunk-56YCMGL3.js";
|
|
30
|
+
import "./chunk-6EX6E7WP.js";
|
|
31
|
+
import {
|
|
32
|
+
pollForResponse,
|
|
33
|
+
pollForResponseWithEvents
|
|
34
|
+
} from "./chunk-SPZPZXUN.js";
|
|
35
|
+
import {
|
|
36
|
+
GuildAPIClient,
|
|
37
|
+
getWorkspaceId,
|
|
38
|
+
getWorkspaceSourceLabel,
|
|
39
|
+
loadLocalConfig,
|
|
40
|
+
parseEventFilter
|
|
41
|
+
} from "./chunk-RIG2HZWM.js";
|
|
42
|
+
import {
|
|
43
|
+
ErrorCodes,
|
|
44
|
+
debug,
|
|
45
|
+
ensureInteractiveStdin,
|
|
46
|
+
format,
|
|
47
|
+
getCliVersion,
|
|
48
|
+
handleAxiosError,
|
|
49
|
+
hyperlink,
|
|
50
|
+
readStdinAsJSON,
|
|
51
|
+
readStdinAsText
|
|
52
|
+
} from "./chunk-LFMQJOKC.js";
|
|
53
|
+
import "./chunk-M347HP6M.js";
|
|
54
|
+
import "./chunk-ENKEEJ45.js";
|
|
55
|
+
import "./chunk-VVSOU6ON.js";
|
|
56
|
+
import "./chunk-PNCUR4OB.js";
|
|
57
|
+
import "./chunk-X3ADGWOF.js";
|
|
58
|
+
import {
|
|
59
|
+
__toESM
|
|
60
|
+
} from "./chunk-OYQ476FQ.js";
|
|
61
|
+
|
|
62
|
+
// src/commands/agent/test.ts
|
|
63
|
+
var import_react = __toESM(require_react(), 1);
|
|
64
|
+
import { access as access2 } from "fs/promises";
|
|
65
|
+
import path2 from "path";
|
|
66
|
+
|
|
67
|
+
// src/lib/validate-input-schema.ts
|
|
68
|
+
import * as fs from "fs/promises";
|
|
69
|
+
import * as path from "path";
|
|
70
|
+
import * as os from "os";
|
|
71
|
+
import { execFile } from "child_process";
|
|
72
|
+
import { promisify } from "util";
|
|
73
|
+
var execFileAsync = promisify(execFile);
|
|
74
|
+
function resolveSourceEntryPoint(agentDir, packageJson) {
|
|
75
|
+
const exports = packageJson.exports;
|
|
76
|
+
if (exports?.["."]) {
|
|
77
|
+
const distPath = exports["."];
|
|
78
|
+
const sourcePath = distPath.replace(/^\.\/dist\//, "").replace(/\.compiled\.js$/, ".ts").replace(/\.js$/, ".ts");
|
|
79
|
+
return path.join(agentDir, sourcePath);
|
|
80
|
+
}
|
|
81
|
+
return path.join(agentDir, "agent.ts");
|
|
82
|
+
}
|
|
83
|
+
async function fileExists(filePath) {
|
|
84
|
+
return fs.access(filePath).then(() => true).catch(() => false);
|
|
85
|
+
}
|
|
86
|
+
function extractZodDeclaration(source, match) {
|
|
87
|
+
const startIndex = match.index;
|
|
88
|
+
const afterEquals = match.index + match[0].length;
|
|
89
|
+
let depth = 0;
|
|
90
|
+
let foundOpen = false;
|
|
91
|
+
let endIndex = afterEquals;
|
|
92
|
+
let inString = null;
|
|
93
|
+
for (let charIndex = afterEquals; charIndex < source.length; charIndex++) {
|
|
94
|
+
const char = source[charIndex];
|
|
95
|
+
if (inString) {
|
|
96
|
+
if (char === "\\") {
|
|
97
|
+
charIndex++;
|
|
98
|
+
} else if (char === inString) {
|
|
99
|
+
inString = null;
|
|
100
|
+
}
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
if (char === '"' || char === "'" || char === "`") {
|
|
104
|
+
inString = char;
|
|
105
|
+
} else if (char === "(") {
|
|
106
|
+
depth++;
|
|
107
|
+
foundOpen = true;
|
|
108
|
+
} else if (char === ")") {
|
|
109
|
+
depth--;
|
|
110
|
+
if (foundOpen && depth === 0) {
|
|
111
|
+
endIndex = charIndex + 1;
|
|
112
|
+
if (source[endIndex] === ";") endIndex++;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (!foundOpen) return null;
|
|
118
|
+
return source.substring(startIndex, endIndex);
|
|
119
|
+
}
|
|
120
|
+
function extractInputSchema(source) {
|
|
121
|
+
const inputPattern = /const\s+inputSchema\s*=\s*/;
|
|
122
|
+
const inputMatch = inputPattern.exec(source);
|
|
123
|
+
if (!inputMatch) return null;
|
|
124
|
+
const inputBlock = extractZodDeclaration(source, inputMatch);
|
|
125
|
+
if (!inputBlock) return null;
|
|
126
|
+
const blocks = [];
|
|
127
|
+
const zodDeclPattern = /const\s+\w+\s*=\s*z\s*\.\s*/g;
|
|
128
|
+
let declMatch;
|
|
129
|
+
while ((declMatch = zodDeclPattern.exec(source)) !== null) {
|
|
130
|
+
if (declMatch.index >= inputMatch.index) break;
|
|
131
|
+
const block = extractZodDeclaration(source, declMatch);
|
|
132
|
+
if (block) blocks.push(block);
|
|
133
|
+
}
|
|
134
|
+
blocks.push(inputBlock);
|
|
135
|
+
return blocks.join("\n");
|
|
136
|
+
}
|
|
137
|
+
async function validateInputSchema(agentDir, inputs) {
|
|
138
|
+
const nodeModulesPath = path.join(agentDir, "node_modules");
|
|
139
|
+
if (!await fileExists(nodeModulesPath)) {
|
|
140
|
+
return {
|
|
141
|
+
valid: true,
|
|
142
|
+
skipped: true,
|
|
143
|
+
reason: "run npm install for pre-build input validation"
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const pkgJsonPath = path.join(agentDir, "package.json");
|
|
147
|
+
if (!await fileExists(pkgJsonPath)) {
|
|
148
|
+
return {
|
|
149
|
+
valid: true,
|
|
150
|
+
skipped: true,
|
|
151
|
+
reason: "no package.json found"
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
const pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, "utf-8"));
|
|
155
|
+
let entryPoint = resolveSourceEntryPoint(agentDir, pkgJson);
|
|
156
|
+
if (!await fileExists(entryPoint)) {
|
|
157
|
+
const fallback = path.join(agentDir, "agent.ts");
|
|
158
|
+
if (await fileExists(fallback)) {
|
|
159
|
+
entryPoint = fallback;
|
|
160
|
+
} else {
|
|
161
|
+
return {
|
|
162
|
+
valid: true,
|
|
163
|
+
skipped: true,
|
|
164
|
+
reason: `could not find agent source file (tried ${path.basename(entryPoint)})`
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const agentSource = await fs.readFile(entryPoint, "utf-8");
|
|
169
|
+
const schemaBlock = extractInputSchema(agentSource);
|
|
170
|
+
if (!schemaBlock) {
|
|
171
|
+
return {
|
|
172
|
+
valid: true,
|
|
173
|
+
skipped: true,
|
|
174
|
+
reason: "could not find inputSchema definition in agent source"
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "guild-validate-"));
|
|
178
|
+
try {
|
|
179
|
+
const extractorSource = [
|
|
180
|
+
`import { z } from "zod";`,
|
|
181
|
+
schemaBlock,
|
|
182
|
+
`const inputs = JSON.parse(process.argv[2]);`,
|
|
183
|
+
`const errors = [];`,
|
|
184
|
+
`for (let i = 0; i < inputs.length; i++) {`,
|
|
185
|
+
` try {`,
|
|
186
|
+
` inputSchema.parse(inputs[i]);`,
|
|
187
|
+
` } catch (e) {`,
|
|
188
|
+
` const issues = e.issues || [{ message: e.message }];`,
|
|
189
|
+
` errors.push({ index: i, issues: issues.map(iss => ({ message: iss.message, path: iss.path })) });`,
|
|
190
|
+
` }`,
|
|
191
|
+
`}`,
|
|
192
|
+
`if (errors.length > 0) {`,
|
|
193
|
+
` console.log(JSON.stringify({ valid: false, errors }));`,
|
|
194
|
+
`} else {`,
|
|
195
|
+
` console.log(JSON.stringify({ valid: true }));`,
|
|
196
|
+
`}`
|
|
197
|
+
].join("\n");
|
|
198
|
+
const extractorPath = path.join(tmpDir, "validate.mjs");
|
|
199
|
+
await fs.writeFile(extractorPath, extractorSource);
|
|
200
|
+
const { build } = await import("esbuild");
|
|
201
|
+
const bundlePath = path.join(tmpDir, "validate-bundle.mjs");
|
|
202
|
+
await build({
|
|
203
|
+
entryPoints: [extractorPath],
|
|
204
|
+
bundle: true,
|
|
205
|
+
format: "esm",
|
|
206
|
+
target: "esnext",
|
|
207
|
+
platform: "node",
|
|
208
|
+
outfile: bundlePath,
|
|
209
|
+
logLevel: "silent",
|
|
210
|
+
nodePaths: [path.join(agentDir, "node_modules")]
|
|
211
|
+
});
|
|
212
|
+
const inputArg = JSON.stringify(inputs);
|
|
213
|
+
const { stdout } = await execFileAsync("node", [bundlePath, inputArg], {
|
|
214
|
+
cwd: agentDir,
|
|
215
|
+
timeout: 1e4
|
|
216
|
+
});
|
|
217
|
+
const result = JSON.parse(stdout.trim());
|
|
218
|
+
if (result.valid) {
|
|
219
|
+
return { valid: true };
|
|
220
|
+
}
|
|
221
|
+
const flatErrors = [];
|
|
222
|
+
for (const entry of result.errors) {
|
|
223
|
+
for (const issue of entry.issues) {
|
|
224
|
+
const prefix = inputs.length > 1 ? `Line ${entry.index + 1}: ` : "";
|
|
225
|
+
flatErrors.push({
|
|
226
|
+
message: `${prefix}${issue.message}`,
|
|
227
|
+
path: issue.path
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return { valid: false, errors: flatErrors };
|
|
232
|
+
} catch (error) {
|
|
233
|
+
debug("Local input validation failed: %s", error);
|
|
234
|
+
return {
|
|
235
|
+
valid: true,
|
|
236
|
+
skipped: true,
|
|
237
|
+
reason: "local validation encountered an error (server-side validation will still run)"
|
|
238
|
+
};
|
|
239
|
+
} finally {
|
|
240
|
+
await fs.rm(tmpDir, { recursive: true, force: true }).catch(() => {
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// src/commands/agent/test.ts
|
|
246
|
+
var cliVersion = getCliVersion();
|
|
247
|
+
function createAgentTestCommand() {
|
|
248
|
+
const cmd = new Command("test");
|
|
249
|
+
cmd.description("Test agent in interactive REPL session").option(
|
|
250
|
+
"--workspace <identifier>",
|
|
251
|
+
"Workspace ID or full name (e.g., owner/workspace-name)"
|
|
252
|
+
).option("--agent-version <id>", "Test a specific version (UUID or version number)").option("--resume <session-id>", "Resume an existing test session").option("--open", "Open session in web dashboard").option(
|
|
253
|
+
"--events <types>",
|
|
254
|
+
"Event types to stream (default: user). Shorthands: none, user, system, all, or comma-separated type names"
|
|
255
|
+
).option("--bundle <file>", "Path to a pre-built gzip+base64 bundle file").option("--no-cache", "Skip ephemeral build cache (force a fresh build)").addOption(new Option("--mode <format>").hideHelp()).action(
|
|
256
|
+
async (options) => {
|
|
257
|
+
const cwd = process.cwd();
|
|
258
|
+
const eventFilter = options.events ? parseEventFilter(options.events) : void 0;
|
|
259
|
+
try {
|
|
260
|
+
if (options.resume) {
|
|
261
|
+
await ensureAuthenticated();
|
|
262
|
+
const client2 = new GuildAPIClient();
|
|
263
|
+
const resumeSession = await fetchSession(client2, options.resume);
|
|
264
|
+
const resumeEvents = await fetchSessionEvents(client2, options.resume);
|
|
265
|
+
const resumeCommand2 = "guild agent test";
|
|
266
|
+
const isInteractive2 = getOutputMode() === "interactive" && !isQuietMode();
|
|
267
|
+
if (isInteractive2) {
|
|
268
|
+
suppressScrollbackClear();
|
|
269
|
+
}
|
|
270
|
+
const { waitUntilExit: waitUntilExit2 } = render_default(
|
|
271
|
+
import_react.default.createElement(ChatApp, {
|
|
272
|
+
initialPrompt: "",
|
|
273
|
+
version: cliVersion,
|
|
274
|
+
showSplash: false,
|
|
275
|
+
resumeSession,
|
|
276
|
+
resumeEvents,
|
|
277
|
+
resumeCommand: resumeCommand2,
|
|
278
|
+
eventFilter
|
|
279
|
+
}),
|
|
280
|
+
{ exitOnCtrlC: false }
|
|
281
|
+
);
|
|
282
|
+
await waitUntilExit2();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const guildConfig = await loadLocalConfig(cwd);
|
|
286
|
+
if (!guildConfig) {
|
|
287
|
+
console.error("Error: Not in an agent directory");
|
|
288
|
+
console.error("");
|
|
289
|
+
console.error("guild.json not found in current directory.");
|
|
290
|
+
console.error("");
|
|
291
|
+
console.error("Initialize an agent directory:");
|
|
292
|
+
console.error(" guild agent init --name my-agent");
|
|
293
|
+
console.error("");
|
|
294
|
+
console.error("Or clone an existing agent:");
|
|
295
|
+
console.error(" guild agent clone <agent-id>");
|
|
296
|
+
process.exit(1);
|
|
297
|
+
}
|
|
298
|
+
const outputMode = getOutputMode();
|
|
299
|
+
let inputData;
|
|
300
|
+
let jsonlInputs;
|
|
301
|
+
if (outputMode === "json") {
|
|
302
|
+
try {
|
|
303
|
+
inputData = await readStdinAsJSON();
|
|
304
|
+
} catch (error) {
|
|
305
|
+
const err = error;
|
|
306
|
+
console.error(`Error: ${err.message}`);
|
|
307
|
+
console.error("");
|
|
308
|
+
console.error("Example usage:");
|
|
309
|
+
console.error(
|
|
310
|
+
` echo '{"prompt": "test"}' | guild agent test --mode json`
|
|
311
|
+
);
|
|
312
|
+
console.error(" guild agent test --mode json < input.json");
|
|
313
|
+
process.exit(1);
|
|
314
|
+
}
|
|
315
|
+
} else if (outputMode === "jsonl") {
|
|
316
|
+
try {
|
|
317
|
+
const stdinContent = await readStdinAsText();
|
|
318
|
+
jsonlInputs = [];
|
|
319
|
+
const lines = stdinContent.split("\n");
|
|
320
|
+
for (let i = 0; i < lines.length; i++) {
|
|
321
|
+
const line = lines[i].trim();
|
|
322
|
+
if (!line) continue;
|
|
323
|
+
try {
|
|
324
|
+
jsonlInputs.push(JSON.parse(line));
|
|
325
|
+
} catch {
|
|
326
|
+
console.error(`Error: Invalid JSON on line ${i + 1}`);
|
|
327
|
+
console.error("");
|
|
328
|
+
console.error("Each line must be valid JSON.");
|
|
329
|
+
console.error(" cat inputs.jsonl | guild agent test --mode jsonl");
|
|
330
|
+
process.exit(1);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if (jsonlInputs.length === 0) {
|
|
334
|
+
console.error("Error: No JSON input provided");
|
|
335
|
+
console.error("");
|
|
336
|
+
console.error("Example usage:");
|
|
337
|
+
console.error(" cat inputs.jsonl | guild agent test --mode jsonl");
|
|
338
|
+
process.exit(1);
|
|
339
|
+
}
|
|
340
|
+
} catch (error) {
|
|
341
|
+
const err = error;
|
|
342
|
+
console.error(`Error: ${err.message}`);
|
|
343
|
+
process.exit(1);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const inputsToValidate = inputData !== void 0 ? [inputData] : jsonlInputs ?? [];
|
|
347
|
+
if (inputsToValidate.length > 0 && !options.agentVersion) {
|
|
348
|
+
const validationResult = await validateInputSchema(cwd, inputsToValidate);
|
|
349
|
+
if (!validationResult.valid) {
|
|
350
|
+
console.error("Input validation failed:");
|
|
351
|
+
for (const err of validationResult.errors) {
|
|
352
|
+
const pathStr = err.path?.length ? ` (at ${err.path.join(".")})` : "";
|
|
353
|
+
console.error(` - ${err.message}${pathStr}`);
|
|
354
|
+
}
|
|
355
|
+
process.exit(1);
|
|
356
|
+
}
|
|
357
|
+
if ("skipped" in validationResult && validationResult.skipped) {
|
|
358
|
+
format.warn(`Skipping local validation: ${validationResult.reason}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (options.bundle) {
|
|
362
|
+
try {
|
|
363
|
+
await access2(options.bundle);
|
|
364
|
+
} catch {
|
|
365
|
+
console.error(`Error: Bundle file not found: ${options.bundle}`);
|
|
366
|
+
console.error("");
|
|
367
|
+
console.error("Ensure the bundle file exists and the path is correct:");
|
|
368
|
+
console.error(" npm run build");
|
|
369
|
+
console.error(" guild agent test --bundle agent.js.gz");
|
|
370
|
+
process.exit(1);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
let workspaceId = options.workspace;
|
|
374
|
+
let workspaceSourceLabel;
|
|
375
|
+
if (!workspaceId) {
|
|
376
|
+
const resolved = await getWorkspaceId(cwd);
|
|
377
|
+
workspaceId = resolved?.workspaceId;
|
|
378
|
+
workspaceSourceLabel = resolved ? getWorkspaceSourceLabel(resolved.source) : void 0;
|
|
379
|
+
if (!workspaceId) {
|
|
380
|
+
console.error("Error: No default workspace configured");
|
|
381
|
+
console.error("");
|
|
382
|
+
console.error("Set a default workspace interactively:");
|
|
383
|
+
console.error(" guild workspace select");
|
|
384
|
+
console.error("");
|
|
385
|
+
console.error("Or specify a workspace for this test:");
|
|
386
|
+
console.error(" guild agent test --workspace <workspace-id>");
|
|
387
|
+
console.error("");
|
|
388
|
+
console.error("List available workspaces:");
|
|
389
|
+
console.error(" guild workspace list");
|
|
390
|
+
process.exit(1);
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
await ensureAuthenticated();
|
|
394
|
+
const client = new GuildAPIClient();
|
|
395
|
+
let version;
|
|
396
|
+
let ephemeralCached = false;
|
|
397
|
+
try {
|
|
398
|
+
if (options.agentVersion) {
|
|
399
|
+
const existingVersions = await client.get(
|
|
400
|
+
`/agents/${guildConfig.agent_id}/versions`
|
|
401
|
+
);
|
|
402
|
+
const match = existingVersions.items.find(
|
|
403
|
+
(v) => v.id === options.agentVersion || v.version_number === options.agentVersion
|
|
404
|
+
);
|
|
405
|
+
if (!match) {
|
|
406
|
+
console.error(`Error: Version not found: ${options.agentVersion}`);
|
|
407
|
+
console.error("");
|
|
408
|
+
console.error("List available versions:");
|
|
409
|
+
console.error(` guild agent versions ${guildConfig.agent_id}`);
|
|
410
|
+
process.exit(1);
|
|
411
|
+
}
|
|
412
|
+
version = match;
|
|
413
|
+
} else if (options.bundle) {
|
|
414
|
+
const result = await buildBundledVersion(
|
|
415
|
+
client,
|
|
416
|
+
guildConfig.agent_id,
|
|
417
|
+
options.bundle,
|
|
418
|
+
cwd,
|
|
419
|
+
"[Test] Pre-built bundle"
|
|
420
|
+
);
|
|
421
|
+
version = result.version;
|
|
422
|
+
} else {
|
|
423
|
+
const agentFiles = await readAgentFiles(cwd);
|
|
424
|
+
const noCache = options.cache === false;
|
|
425
|
+
const result = await buildEphemeralVersion(
|
|
426
|
+
client,
|
|
427
|
+
guildConfig.agent_id,
|
|
428
|
+
agentFiles,
|
|
429
|
+
cwd,
|
|
430
|
+
"[Test] Ephemeral development version",
|
|
431
|
+
{ noCache }
|
|
432
|
+
);
|
|
433
|
+
version = result.version;
|
|
434
|
+
ephemeralCached = result.cached;
|
|
435
|
+
}
|
|
436
|
+
} catch (error) {
|
|
437
|
+
if (error instanceof BundleNotFoundError) {
|
|
438
|
+
console.error(`Error: ${error.message}`);
|
|
439
|
+
console.error("");
|
|
440
|
+
console.error("Ensure the bundle file exists and the path is correct:");
|
|
441
|
+
console.error(" npm run build");
|
|
442
|
+
console.error(" guild agent test --bundle agent.js.gz");
|
|
443
|
+
process.exit(1);
|
|
444
|
+
}
|
|
445
|
+
if (error instanceof BuildTimeoutError) {
|
|
446
|
+
console.error("Error: Build did not complete");
|
|
447
|
+
console.error("");
|
|
448
|
+
console.error(error.message);
|
|
449
|
+
console.error("");
|
|
450
|
+
console.error("Check build status:");
|
|
451
|
+
console.error(" guild agent versions");
|
|
452
|
+
process.exit(1);
|
|
453
|
+
}
|
|
454
|
+
if (error instanceof BuildFailedError) {
|
|
455
|
+
console.error(`Error: ${error.message}`);
|
|
456
|
+
process.exit(1);
|
|
457
|
+
}
|
|
458
|
+
if (error instanceof Error && error.message.startsWith("Missing required")) {
|
|
459
|
+
console.error("Error: Could not read agent files");
|
|
460
|
+
console.error("");
|
|
461
|
+
console.error(error.message);
|
|
462
|
+
console.error("");
|
|
463
|
+
console.error("Ensure you are in an agent directory with:");
|
|
464
|
+
console.error(" - agent.ts (required)");
|
|
465
|
+
console.error(" - package.json (required)");
|
|
466
|
+
process.exit(1);
|
|
467
|
+
}
|
|
468
|
+
const formattedError = handleAxiosError(error);
|
|
469
|
+
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
470
|
+
console.error(`Error: Agent not found: ${guildConfig.agent_id}`);
|
|
471
|
+
console.error("");
|
|
472
|
+
console.error("This agent may have been deleted from the backend.");
|
|
473
|
+
console.error("");
|
|
474
|
+
console.error("Verify the agent exists:");
|
|
475
|
+
console.error(` guild agent get ${guildConfig.agent_id}`);
|
|
476
|
+
console.error("");
|
|
477
|
+
console.error("Or initialize a new agent:");
|
|
478
|
+
console.error(" guild agent init --name my-agent");
|
|
479
|
+
process.exit(1);
|
|
480
|
+
}
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
let session;
|
|
484
|
+
try {
|
|
485
|
+
session = await client.post(`/workspaces/${workspaceId}/sessions`, {
|
|
486
|
+
session_type: "agent_test",
|
|
487
|
+
agent_version_id: version.id
|
|
488
|
+
});
|
|
489
|
+
} catch (error) {
|
|
490
|
+
const formattedError = handleAxiosError(error);
|
|
491
|
+
if (formattedError.code === ErrorCodes.NOT_FOUND) {
|
|
492
|
+
console.error(`Error: Workspace not found: ${workspaceId}`);
|
|
493
|
+
console.error("");
|
|
494
|
+
console.error("Set a different default workspace:");
|
|
495
|
+
console.error(" guild workspace select");
|
|
496
|
+
console.error("");
|
|
497
|
+
console.error("Or list available workspaces:");
|
|
498
|
+
console.error(" guild workspace list");
|
|
499
|
+
process.exit(1);
|
|
500
|
+
}
|
|
501
|
+
throw error;
|
|
502
|
+
}
|
|
503
|
+
const quiet = isQuietMode();
|
|
504
|
+
if (!quiet) {
|
|
505
|
+
console.log(`\u2713 Agent: ${guildConfig.name} (${guildConfig.agent_id})`);
|
|
506
|
+
const versionDisplay = options.agentVersion ? options.agentVersion : options.bundle ? `bundle (${path2.basename(options.bundle)})` : ephemeralCached ? "ephemeral (cached, no changes)" : "ephemeral (working directory)";
|
|
507
|
+
console.log(`\u2713 Version: ${versionDisplay}`);
|
|
508
|
+
const workspaceDisplay = workspaceSourceLabel ? `${workspaceId} (from ${workspaceSourceLabel})` : workspaceId;
|
|
509
|
+
console.log(`\u2713 Workspace: ${workspaceDisplay}`);
|
|
510
|
+
const sessionLink = session.session_url ? hyperlink(session.id, session.session_url) : session.id;
|
|
511
|
+
console.log(`\u2713 Session: ${sessionLink}`);
|
|
512
|
+
console.log("");
|
|
513
|
+
}
|
|
514
|
+
if (options.open && session.session_url) {
|
|
515
|
+
await open_default(session.session_url);
|
|
516
|
+
}
|
|
517
|
+
if (outputMode === "json" && inputData) {
|
|
518
|
+
try {
|
|
519
|
+
await client.post(`/sessions/${session.id}/events`, {
|
|
520
|
+
mode: "json",
|
|
521
|
+
content: inputData
|
|
522
|
+
});
|
|
523
|
+
const { response } = eventFilter ? await pollForResponseWithEvents(
|
|
524
|
+
client,
|
|
525
|
+
session.id,
|
|
526
|
+
eventFilter,
|
|
527
|
+
void 0,
|
|
528
|
+
18e4
|
|
529
|
+
) : await pollForResponse(client, session.id, void 0, 18e4);
|
|
530
|
+
if (!response) {
|
|
531
|
+
console.error("Error: No response received from agent within timeout");
|
|
532
|
+
console.error("");
|
|
533
|
+
console.error("The agent did not produce a response in time.");
|
|
534
|
+
console.error("");
|
|
535
|
+
console.error("Possible causes:");
|
|
536
|
+
console.error(
|
|
537
|
+
" - The agent is still processing (try a longer timeout)"
|
|
538
|
+
);
|
|
539
|
+
console.error(" - The agent encountered an error during execution");
|
|
540
|
+
console.error(
|
|
541
|
+
" - The input format does not match the agent's input schema"
|
|
542
|
+
);
|
|
543
|
+
console.error("");
|
|
544
|
+
console.error(
|
|
545
|
+
"Check agent logs in the web UI or try interactive mode:"
|
|
546
|
+
);
|
|
547
|
+
console.error(" guild agent test");
|
|
548
|
+
process.exit(1);
|
|
549
|
+
}
|
|
550
|
+
if (quiet) {
|
|
551
|
+
console.log(response);
|
|
552
|
+
} else {
|
|
553
|
+
console.log(`< ${response}`);
|
|
554
|
+
console.log("");
|
|
555
|
+
}
|
|
556
|
+
if (!quiet) {
|
|
557
|
+
console.log("\u2713 Test complete");
|
|
558
|
+
}
|
|
559
|
+
process.exit(0);
|
|
560
|
+
} catch (error) {
|
|
561
|
+
const formattedErr = handleAxiosError(error);
|
|
562
|
+
console.error(`Error: ${formattedErr.details}`);
|
|
563
|
+
console.error("");
|
|
564
|
+
if (formattedErr.code === ErrorCodes.SERVER_ERROR) {
|
|
565
|
+
console.error(
|
|
566
|
+
"The server returned an error while processing the event."
|
|
567
|
+
);
|
|
568
|
+
console.error("");
|
|
569
|
+
console.error("Possible causes:");
|
|
570
|
+
console.error(
|
|
571
|
+
" - The input format does not match the agent's input schema"
|
|
572
|
+
);
|
|
573
|
+
console.error(" - The agent runtime encountered an error");
|
|
574
|
+
console.error("");
|
|
575
|
+
console.error("Try testing interactively to see more detail:");
|
|
576
|
+
console.error(" guild agent test");
|
|
577
|
+
} else {
|
|
578
|
+
console.error("Failed to send event to agent session.");
|
|
579
|
+
console.error("");
|
|
580
|
+
console.error("Example usage:");
|
|
581
|
+
console.error(
|
|
582
|
+
` echo '{"type":"text","text":"hello"}' | guild agent test --mode json`
|
|
583
|
+
);
|
|
584
|
+
console.error(" guild agent test --mode json < input.json");
|
|
585
|
+
}
|
|
586
|
+
process.exit(1);
|
|
587
|
+
}
|
|
588
|
+
} else if (outputMode === "jsonl" && jsonlInputs) {
|
|
589
|
+
let processedCount = 0;
|
|
590
|
+
let lastEventId;
|
|
591
|
+
for (let inputIndex = 0; inputIndex < jsonlInputs.length; inputIndex++) {
|
|
592
|
+
const jsonInput = jsonlInputs[inputIndex];
|
|
593
|
+
if (!quiet) {
|
|
594
|
+
console.error(
|
|
595
|
+
`Processing input ${inputIndex + 1}/${jsonlInputs.length}...`
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
try {
|
|
599
|
+
await client.post(`/sessions/${session.id}/events`, {
|
|
600
|
+
mode: "json",
|
|
601
|
+
content: jsonInput
|
|
602
|
+
});
|
|
603
|
+
const result = eventFilter ? await pollForResponseWithEvents(
|
|
604
|
+
client,
|
|
605
|
+
session.id,
|
|
606
|
+
eventFilter,
|
|
607
|
+
lastEventId,
|
|
608
|
+
18e4
|
|
609
|
+
) : await pollForResponse(client, session.id, lastEventId, 18e4);
|
|
610
|
+
lastEventId = result.lastEventId;
|
|
611
|
+
if (!result.response) {
|
|
612
|
+
console.error(`Timeout: No response for input ${inputIndex + 1}`);
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
const response = result.response;
|
|
616
|
+
if (quiet) {
|
|
617
|
+
console.log(response);
|
|
618
|
+
} else {
|
|
619
|
+
console.log(`< ${response}`);
|
|
620
|
+
console.log("");
|
|
621
|
+
}
|
|
622
|
+
processedCount++;
|
|
623
|
+
} catch (error) {
|
|
624
|
+
const formattedErr = handleAxiosError(error);
|
|
625
|
+
console.error(
|
|
626
|
+
`Error processing input ${inputIndex + 1}: ${formattedErr.details}`
|
|
627
|
+
);
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
if (!quiet) {
|
|
631
|
+
console.log(`
|
|
632
|
+
\u2713 Processed ${processedCount} messages`);
|
|
633
|
+
}
|
|
634
|
+
process.exit(0);
|
|
635
|
+
}
|
|
636
|
+
ensureInteractiveStdin("guild agent test");
|
|
637
|
+
const resumeCommand = "guild agent test";
|
|
638
|
+
const isInteractive = getOutputMode() === "interactive" && !isQuietMode();
|
|
639
|
+
if (isInteractive) {
|
|
640
|
+
suppressScrollbackClear();
|
|
641
|
+
}
|
|
642
|
+
const { waitUntilExit } = render_default(
|
|
643
|
+
import_react.default.createElement(ChatApp, {
|
|
644
|
+
initialPrompt: "",
|
|
645
|
+
version: cliVersion,
|
|
646
|
+
workspaceId,
|
|
647
|
+
versionId: version.id,
|
|
648
|
+
agentName: guildConfig.name,
|
|
649
|
+
showSplash: false,
|
|
650
|
+
resumeSession: session,
|
|
651
|
+
resumeEvents: [],
|
|
652
|
+
resumeCommand,
|
|
653
|
+
eventFilter
|
|
654
|
+
}),
|
|
655
|
+
{ exitOnCtrlC: false }
|
|
656
|
+
);
|
|
657
|
+
await waitUntilExit();
|
|
658
|
+
} catch (error) {
|
|
659
|
+
if (error instanceof GitError) {
|
|
660
|
+
console.error("Error: Git operation failed");
|
|
661
|
+
console.error("");
|
|
662
|
+
console.error(formatGitError(error));
|
|
663
|
+
process.exit(1);
|
|
664
|
+
}
|
|
665
|
+
const formattedError = handleAxiosError(error);
|
|
666
|
+
if (formattedError.code === ErrorCodes.AUTH_REQUIRED || formattedError.code === ErrorCodes.AUTH_TOKEN_INVALID) {
|
|
667
|
+
format.error("Not authenticated. Run: guild auth login");
|
|
668
|
+
process.exit(1);
|
|
669
|
+
}
|
|
670
|
+
console.error(`Error: ${formattedError.details}`);
|
|
671
|
+
console.error("");
|
|
672
|
+
console.error("Failed to start test session. Troubleshooting:");
|
|
673
|
+
console.error(" - Verify the agent exists: guild agent get");
|
|
674
|
+
console.error(" - Check your workspace: guild workspace list");
|
|
675
|
+
if (formattedError.code) {
|
|
676
|
+
console.error(` - Error code: ${formattedError.code}`);
|
|
677
|
+
}
|
|
678
|
+
process.exit(1);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
);
|
|
682
|
+
return cmd;
|
|
683
|
+
}
|
|
684
|
+
async function handleAgentTestAction(_options) {
|
|
685
|
+
const cmd = createAgentTestCommand();
|
|
686
|
+
await cmd.parseAsync(process.argv.slice(3), { from: "user" });
|
|
687
|
+
}
|
|
688
|
+
export {
|
|
689
|
+
createAgentTestCommand,
|
|
690
|
+
handleAgentTestAction
|
|
691
|
+
};
|
|
692
|
+
//# sourceMappingURL=test-SNIYRJ32.js.map
|