@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.
Files changed (198) hide show
  1. package/dist/auth-CRMO5O3N.js +29 -0
  2. package/dist/auth-CRMO5O3N.js.map +7 -0
  3. package/dist/chat-5VX2WJH2.js +303 -0
  4. package/dist/chat-5VX2WJH2.js.map +7 -0
  5. package/dist/chat-SIKDYZQK.js +31 -0
  6. package/dist/chat-SIKDYZQK.js.map +7 -0
  7. package/dist/chunk-56YCMGL3.js +522 -0
  8. package/dist/chunk-56YCMGL3.js.map +7 -0
  9. package/dist/chunk-6EX6E7WP.js +7042 -0
  10. package/dist/chunk-6EX6E7WP.js.map +7 -0
  11. package/dist/chunk-B7VAF5UG.js +532 -0
  12. package/dist/chunk-B7VAF5UG.js.map +7 -0
  13. package/dist/chunk-DOIYVBNY.js +3057 -0
  14. package/dist/chunk-DOIYVBNY.js.map +7 -0
  15. package/dist/chunk-ENKEEJ45.js +17 -0
  16. package/dist/chunk-ENKEEJ45.js.map +7 -0
  17. package/dist/chunk-IBRKVGMZ.js +97041 -0
  18. package/dist/chunk-IBRKVGMZ.js.map +7 -0
  19. package/dist/chunk-LFMQJOKC.js +19778 -0
  20. package/dist/chunk-LFMQJOKC.js.map +7 -0
  21. package/dist/chunk-M347HP6M.js +22896 -0
  22. package/dist/chunk-M347HP6M.js.map +7 -0
  23. package/dist/chunk-OYQ476FQ.js +44 -0
  24. package/dist/chunk-OYQ476FQ.js.map +7 -0
  25. package/dist/chunk-PNCUR4OB.js +257 -0
  26. package/dist/chunk-PNCUR4OB.js.map +7 -0
  27. package/dist/chunk-RIG2HZWM.js +317 -0
  28. package/dist/chunk-RIG2HZWM.js.map +7 -0
  29. package/dist/chunk-SPZPZXUN.js +826 -0
  30. package/dist/chunk-SPZPZXUN.js.map +7 -0
  31. package/dist/chunk-VVSOU6ON.js +53 -0
  32. package/dist/chunk-VVSOU6ON.js.map +7 -0
  33. package/dist/chunk-X3ADGWOF.js +3643 -0
  34. package/dist/chunk-X3ADGWOF.js.map +7 -0
  35. package/dist/commands/skill/create.d.ts +3 -0
  36. package/dist/commands/skill/get.d.ts +3 -0
  37. package/dist/commands/skill/list.d.ts +3 -0
  38. package/dist/commands/skill/update.d.ts +3 -0
  39. package/dist/commands/skill/version/create.d.ts +3 -0
  40. package/dist/commands/skill/version/get.d.ts +3 -0
  41. package/dist/commands/skill/version/list.d.ts +3 -0
  42. package/dist/devtools-AO7YSDOD.js +67 -0
  43. package/dist/devtools-AO7YSDOD.js.map +7 -0
  44. package/dist/dist-4CBK6X5H.js +1566 -0
  45. package/dist/dist-4CBK6X5H.js.map +7 -0
  46. package/dist/esm-FRAVZP4J.js +13 -0
  47. package/dist/esm-FRAVZP4J.js.map +7 -0
  48. package/dist/execa-XQMWSABC.js +35 -0
  49. package/dist/execa-XQMWSABC.js.map +7 -0
  50. package/dist/index.js +8230 -263
  51. package/dist/index.js.map +7 -0
  52. package/dist/lib/api-types.d.ts +44 -0
  53. package/dist/lib/config.d.ts +9 -0
  54. package/dist/lib/errors.d.ts +1 -1
  55. package/dist/lib/output.d.ts +11 -1
  56. package/dist/lib/session-events.d.ts +1 -1
  57. package/dist/lib/session-polling.d.ts +24 -1
  58. package/dist/lib/websocket-client.d.ts +46 -0
  59. package/dist/open-RF4X5MOP.js +13 -0
  60. package/dist/open-RF4X5MOP.js.map +7 -0
  61. package/dist/server-JYVH64FD.js +27659 -0
  62. package/dist/server-JYVH64FD.js.map +7 -0
  63. package/dist/test-SNIYRJ32.js +692 -0
  64. package/dist/test-SNIYRJ32.js.map +7 -0
  65. package/docs/skills/codex-agent-dev.md +2 -2
  66. package/package.json +8 -12
  67. package/dist/commands/agent/chat.js +0 -281
  68. package/dist/commands/agent/clone.js +0 -118
  69. package/dist/commands/agent/code.js +0 -87
  70. package/dist/commands/agent/fork.js +0 -220
  71. package/dist/commands/agent/get.js +0 -37
  72. package/dist/commands/agent/grep.js +0 -107
  73. package/dist/commands/agent/init.js +0 -403
  74. package/dist/commands/agent/list.js +0 -110
  75. package/dist/commands/agent/logs.js +0 -62
  76. package/dist/commands/agent/owners.js +0 -74
  77. package/dist/commands/agent/publish.js +0 -91
  78. package/dist/commands/agent/pull.js +0 -194
  79. package/dist/commands/agent/revalidate.js +0 -56
  80. package/dist/commands/agent/save.js +0 -345
  81. package/dist/commands/agent/search.js +0 -61
  82. package/dist/commands/agent/tags/add.js +0 -73
  83. package/dist/commands/agent/tags/list.js +0 -43
  84. package/dist/commands/agent/tags/remove.js +0 -84
  85. package/dist/commands/agent/tags/set.js +0 -71
  86. package/dist/commands/agent/test.js +0 -489
  87. package/dist/commands/agent/unpublish.js +0 -64
  88. package/dist/commands/agent/update.js +0 -118
  89. package/dist/commands/agent/versions.js +0 -55
  90. package/dist/commands/agent/workspaces.js +0 -54
  91. package/dist/commands/auth/login.js +0 -31
  92. package/dist/commands/auth/logout.js +0 -24
  93. package/dist/commands/auth/status.js +0 -38
  94. package/dist/commands/auth/token.js +0 -19
  95. package/dist/commands/chat.js +0 -1416
  96. package/dist/commands/config/get.js +0 -64
  97. package/dist/commands/config/list.js +0 -46
  98. package/dist/commands/config/path.js +0 -37
  99. package/dist/commands/config/set.js +0 -132
  100. package/dist/commands/credentials/endpoint-list.js +0 -88
  101. package/dist/commands/credentials/list.js +0 -50
  102. package/dist/commands/credentials/policy-create.js +0 -66
  103. package/dist/commands/credentials/policy-delete.js +0 -33
  104. package/dist/commands/credentials/policy-list.js +0 -45
  105. package/dist/commands/credentials/policy-update.js +0 -66
  106. package/dist/commands/doctor.js +0 -233
  107. package/dist/commands/integration/connect.js +0 -76
  108. package/dist/commands/integration/create.js +0 -298
  109. package/dist/commands/integration/get.js +0 -95
  110. package/dist/commands/integration/list.js +0 -62
  111. package/dist/commands/integration/operation/create.js +0 -164
  112. package/dist/commands/integration/operation/list.js +0 -92
  113. package/dist/commands/integration/update.js +0 -139
  114. package/dist/commands/integration/version/build.js +0 -86
  115. package/dist/commands/integration/version/create.js +0 -45
  116. package/dist/commands/integration/version/get.js +0 -72
  117. package/dist/commands/integration/version/list.js +0 -45
  118. package/dist/commands/integration/version/publish.js +0 -79
  119. package/dist/commands/integration/version/test.js +0 -104
  120. package/dist/commands/job/get-step.js +0 -40
  121. package/dist/commands/job/get.js +0 -44
  122. package/dist/commands/mcp.js +0 -34
  123. package/dist/commands/session/create.js +0 -59
  124. package/dist/commands/session/events.js +0 -56
  125. package/dist/commands/session/get.js +0 -33
  126. package/dist/commands/session/interrupt.js +0 -33
  127. package/dist/commands/session/list.js +0 -59
  128. package/dist/commands/session/send.js +0 -54
  129. package/dist/commands/session/tasks.js +0 -45
  130. package/dist/commands/setup.js +0 -260
  131. package/dist/commands/trigger/activate.js +0 -41
  132. package/dist/commands/trigger/create.js +0 -197
  133. package/dist/commands/trigger/deactivate.js +0 -41
  134. package/dist/commands/trigger/get.js +0 -33
  135. package/dist/commands/trigger/list.js +0 -57
  136. package/dist/commands/trigger/sessions.js +0 -48
  137. package/dist/commands/trigger/update.js +0 -128
  138. package/dist/commands/version.js +0 -24
  139. package/dist/commands/workspace/agent/add.js +0 -114
  140. package/dist/commands/workspace/agent/list.js +0 -78
  141. package/dist/commands/workspace/agent/remove.js +0 -78
  142. package/dist/commands/workspace/clear.js +0 -45
  143. package/dist/commands/workspace/context/edit.js +0 -107
  144. package/dist/commands/workspace/context/get.js +0 -47
  145. package/dist/commands/workspace/context/list.js +0 -51
  146. package/dist/commands/workspace/context/publish.js +0 -42
  147. package/dist/commands/workspace/create.js +0 -51
  148. package/dist/commands/workspace/current.js +0 -63
  149. package/dist/commands/workspace/get.js +0 -39
  150. package/dist/commands/workspace/list.js +0 -70
  151. package/dist/commands/workspace/select.js +0 -184
  152. package/dist/components/AgentInstallPrompt.js +0 -97
  153. package/dist/components/SplashAnimation.js +0 -321
  154. package/dist/components/TaskView.js +0 -268
  155. package/dist/lib/agent-helpers.js +0 -306
  156. package/dist/lib/alternate-screen.js +0 -59
  157. package/dist/lib/api-client.js +0 -154
  158. package/dist/lib/api-types.js +0 -10
  159. package/dist/lib/auth.js +0 -284
  160. package/dist/lib/braille-canvas.js +0 -321
  161. package/dist/lib/colors.js +0 -46
  162. package/dist/lib/config-cache.js +0 -45
  163. package/dist/lib/config.js +0 -153
  164. package/dist/lib/did-you-mean.js +0 -144
  165. package/dist/lib/errors.js +0 -375
  166. package/dist/lib/event-filter.js +0 -91
  167. package/dist/lib/generated-types.js +0 -56
  168. package/dist/lib/git.js +0 -176
  169. package/dist/lib/gk.js +0 -91
  170. package/dist/lib/guild-config.js +0 -178
  171. package/dist/lib/iap.js +0 -117
  172. package/dist/lib/integration-helpers.js +0 -38
  173. package/dist/lib/loading-messages.js +0 -72
  174. package/dist/lib/logo.js +0 -141
  175. package/dist/lib/lottie-serverside.js +0 -181
  176. package/dist/lib/markdown.js +0 -38
  177. package/dist/lib/npmrc.js +0 -59
  178. package/dist/lib/output-mode.js +0 -54
  179. package/dist/lib/output.js +0 -622
  180. package/dist/lib/owner-helpers.js +0 -112
  181. package/dist/lib/polling.js +0 -76
  182. package/dist/lib/progress.js +0 -324
  183. package/dist/lib/session-events-fetch.js +0 -25
  184. package/dist/lib/session-events.js +0 -126
  185. package/dist/lib/session-polling.js +0 -166
  186. package/dist/lib/session-resume.js +0 -229
  187. package/dist/lib/spinners.js +0 -770
  188. package/dist/lib/splash.js +0 -42
  189. package/dist/lib/stdin.js +0 -91
  190. package/dist/lib/svg-to-braille.js +0 -76
  191. package/dist/lib/table.js +0 -59
  192. package/dist/lib/update-check.js +0 -65
  193. package/dist/lib/validate-input-schema.js +0 -208
  194. package/dist/lib/version-helpers.js +0 -137
  195. package/dist/lib/workspace-helpers.js +0 -49
  196. package/dist/mcp/resources.js +0 -67
  197. package/dist/mcp/server.js +0 -64
  198. package/dist/mcp/tools.js +0 -753
@@ -1,306 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { createHash } from 'crypto';
4
- import * as fs from 'fs/promises';
5
- import * as path from 'path';
6
- import { loadLocalConfig } from './guild-config.js';
7
- import { runGit } from './git.js';
8
- import { resolveOwnerId } from './owner-helpers.js';
9
- import { pollUntilComplete } from './polling.js';
10
- // ---------------------------------------------------------------------------
11
- // Build error types
12
- // ---------------------------------------------------------------------------
13
- /** Thrown when the ephemeral version build times out or polling fails. */
14
- export class BuildTimeoutError extends Error {
15
- constructor(message = 'The agent version build timed out or failed to report status.') {
16
- super(message);
17
- this.name = 'BuildTimeoutError';
18
- }
19
- }
20
- /** Thrown when the ephemeral version build fails validation. */
21
- export class BuildFailedError extends Error {
22
- failedSteps;
23
- constructor(failedSteps) {
24
- const stepSummary = failedSteps.length > 0
25
- ? failedSteps
26
- .map((s) => `Step "${s.name}" failed:${s.content ? `\n${s.content}` : ''}`)
27
- .join('\n')
28
- : 'No failed steps found. Check validation logs for details.';
29
- super(`Build failed\n\n${stepSummary}\n\nFix the issues and retry.`);
30
- this.name = 'BuildFailedError';
31
- this.failedSteps = failedSteps;
32
- }
33
- }
34
- const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
35
- /**
36
- * Resolve an agent identifier to a fully-qualified form.
37
- *
38
- * If the identifier already contains `~` or is a UUID, return it verbatim.
39
- * Otherwise, resolve the default owner and prepend `owner.name~`.
40
- */
41
- export async function resolveAgentRef(client, identifier) {
42
- if (identifier.includes('~') || UUID_RE.test(identifier)) {
43
- return identifier;
44
- }
45
- if (identifier.includes('/')) {
46
- return identifier.replace('/', '~');
47
- }
48
- const owner = await resolveOwnerId({ client, interactive: false });
49
- return `${owner.name}~${identifier}`;
50
- }
51
- /**
52
- * Get agent ID from argument or guild.json in current directory
53
- * @param agentIdArg - Optional agent ID from command argument
54
- * @param cwd - Current working directory (defaults to process.cwd())
55
- * @returns Agent ID and config (if from guild.json)
56
- * @throws Error if neither argument nor guild.json provides an agent ID
57
- */
58
- export async function getAgentId(agentIdArg, cwd = process.cwd()) {
59
- // If agent ID provided as argument, use it
60
- if (agentIdArg) {
61
- return { agentId: agentIdArg };
62
- }
63
- // Try to read from guild.json
64
- const config = await loadLocalConfig(cwd);
65
- if (!config) {
66
- console.error('Error: No agent ID provided and not in an agent directory');
67
- console.error('');
68
- console.error('Either provide an agent ID:');
69
- console.error(' guild agent <command> <agent-id>');
70
- console.error('');
71
- console.error('Or run from an agent directory with guild.json:');
72
- console.error(' cd <agent-directory>');
73
- console.error(' guild agent <command>');
74
- console.error('');
75
- console.error('To initialize an agent directory:');
76
- console.error(' guild agent init --name my-agent');
77
- console.error('');
78
- console.error('Or clone an existing agent:');
79
- console.error(' guild agent clone <agent-id>');
80
- process.exit(1);
81
- }
82
- if (!config.agent_id) {
83
- console.error('Error: guild.json is missing agent_id field');
84
- console.error('');
85
- console.error('Your guild.json file appears to be corrupted.');
86
- console.error('Expected format:');
87
- console.error(' {');
88
- console.error(' "agent_id": "...",');
89
- console.error(' "name": "..."');
90
- console.error(' }');
91
- process.exit(1);
92
- }
93
- return { agentId: config.agent_id, config };
94
- }
95
- const REQUIRED_AGENT_FILES = ['agent.ts', 'package.json'];
96
- /**
97
- * Read agent files from disk for ephemeral version creation.
98
- * Uses git ls-files to respect .gitignore.
99
- * @returns Array of {path, content} objects
100
- */
101
- export async function readAgentFiles(cwd) {
102
- const { stdout } = await runGit(['ls-files', '--cached', '--others', '--exclude-standard'], { cwd });
103
- const gitFiles = stdout.split('\n').filter((f) => f.trim().length > 0);
104
- const relevantFiles = gitFiles.filter((f) => !f.startsWith('.guild/'));
105
- const files = [];
106
- for (const filePath of relevantFiles) {
107
- const fullPath = path.join(cwd, filePath);
108
- const content = await fs.readFile(fullPath, 'utf-8');
109
- files.push({ path: filePath, content });
110
- }
111
- const filePaths = files.map((f) => f.path);
112
- const missing = REQUIRED_AGENT_FILES.filter((req) => !filePaths.some((fp) => fp === req || fp.endsWith(`/${req}`)));
113
- if (missing.length > 0) {
114
- throw new Error(`Missing required files: ${missing.join(', ')}`);
115
- }
116
- return files;
117
- }
118
- const CACHE_DIR = path.join('.guild', 'cache');
119
- const CACHE_FILE = 'last-ephemeral.json';
120
- /**
121
- * Compute a deterministic hash of agent files.
122
- * Sorts by path to ensure consistent ordering.
123
- */
124
- export function hashAgentFiles(files) {
125
- const sorted = [...files].sort((a, b) => a.path.localeCompare(b.path));
126
- const hash = createHash('sha256');
127
- for (const file of sorted) {
128
- hash.update(file.path);
129
- hash.update('\0');
130
- hash.update(file.content);
131
- hash.update('\0');
132
- }
133
- return hash.digest('hex');
134
- }
135
- async function readEphemeralCache(cwd) {
136
- try {
137
- const cachePath = path.join(cwd, CACHE_DIR, CACHE_FILE);
138
- const raw = await fs.readFile(cachePath, 'utf-8');
139
- const parsed = JSON.parse(raw);
140
- if (typeof parsed.hash === 'string' && typeof parsed.version_id === 'string') {
141
- return { hash: parsed.hash, version_id: parsed.version_id };
142
- }
143
- return null;
144
- }
145
- catch {
146
- return null;
147
- }
148
- }
149
- async function writeEphemeralCache(cwd, cache) {
150
- const dir = path.join(cwd, CACHE_DIR);
151
- await fs.mkdir(dir, { recursive: true });
152
- await fs.writeFile(path.join(dir, CACHE_FILE), JSON.stringify(cache, null, 2) + '\n');
153
- }
154
- /**
155
- * Get or create an ephemeral version, skipping the build if files haven't
156
- * changed since the last successful ephemeral build.
157
- *
158
- * Returns the version (cached or newly created), a cache hit flag, and the
159
- * computed hash (used by buildEphemeralVersion to write the cache on success).
160
- */
161
- export async function getOrCreateEphemeral(client, agentId, files, cwd, summary, options) {
162
- const hash = hashAgentFiles(files);
163
- if (options?.noCache) {
164
- const version = (await client.post(`/agents/${agentId}/versions`, {
165
- files,
166
- summary,
167
- version_type: 'EPHEMERAL',
168
- }));
169
- return { version, cached: false, hash };
170
- }
171
- const cache = await readEphemeralCache(cwd);
172
- if (cache && cache.hash === hash) {
173
- // Verify the cached version still exists on the server
174
- try {
175
- const version = (await client.get(`/versions/${cache.version_id}`));
176
- if (version.validation_status === 'PASSED') {
177
- return { version, cached: true, hash };
178
- }
179
- }
180
- catch {
181
- // Version gone or inaccessible — fall through to create new one
182
- }
183
- }
184
- const version = (await client.post(`/agents/${agentId}/versions`, {
185
- files,
186
- summary,
187
- version_type: 'EPHEMERAL',
188
- }));
189
- return { version, cached: false, hash };
190
- }
191
- /**
192
- * Build an ephemeral version end-to-end: get-or-create, poll for validation,
193
- * cache on success, and report build failures.
194
- *
195
- * Consolidates the build/poll/cache pattern used by both `guild agent test`
196
- * and `guild agent chat`.
197
- */
198
- export async function buildEphemeralVersion(client, agentId, files, cwd, summary, options) {
199
- const { version: initial, cached, hash, } = await getOrCreateEphemeral(client, agentId, files, cwd, summary, options);
200
- if (cached) {
201
- return { version: initial, cached: true };
202
- }
203
- // Poll for validation to complete
204
- const pollResult = await pollUntilComplete({
205
- resourceId: initial.id,
206
- endpoint: `/versions/${initial.id}`,
207
- isComplete: (r) => r.validation_status !== 'PENDING' && r.validation_status !== 'RUNNING',
208
- message: 'Building...',
209
- successMessage: 'Build finished',
210
- timeoutMessage: 'Build timed out',
211
- maxAttempts: 120,
212
- delayMs: 1000,
213
- });
214
- if (!pollResult.success || !pollResult.response) {
215
- throw new BuildTimeoutError();
216
- }
217
- const version = pollResult.response;
218
- // Cache the successful build so we can skip it next time
219
- if (version.validation_status === 'PASSED') {
220
- await writeEphemeralCache(cwd, { hash, version_id: version.id });
221
- }
222
- if (version.validation_status === 'FAILED') {
223
- let failedSteps = [];
224
- try {
225
- const stepsResponse = await client.get(`/versions/${version.id}/validation/steps`);
226
- failedSteps = stepsResponse.steps
227
- .filter((step) => step.status === 'FAILED')
228
- .map((step) => ({ name: step.name, content: step.content ?? undefined }));
229
- }
230
- catch {
231
- // Could not fetch validation details — throw with empty steps
232
- }
233
- throw new BuildFailedError(failedSteps);
234
- }
235
- return { version, cached: false };
236
- }
237
- // ---------------------------------------------------------------------------
238
- // Bundle version
239
- // ---------------------------------------------------------------------------
240
- /** Thrown when the specified bundle file cannot be found on disk. */
241
- export class BundleNotFoundError extends Error {
242
- constructor(filePath) {
243
- super(`Bundle file not found: ${filePath}`);
244
- this.name = 'BundleNotFoundError';
245
- }
246
- }
247
- /**
248
- * Upload a pre-built bundle as an ephemeral version.
249
- *
250
- * The bundle file must be gzip+base64 encoded (the output of
251
- * `esbuild ... | gzip | base64`). Source files are included for
252
- * dashboard viewing, but the server skips its own build step because
253
- * the ready-to-run artifact is already provided.
254
- */
255
- export async function buildBundledVersion(client, agentId, bundlePath, cwd, summary) {
256
- try {
257
- await fs.access(bundlePath);
258
- }
259
- catch {
260
- throw new BundleNotFoundError(bundlePath);
261
- }
262
- const bundle = (await fs.readFile(bundlePath, 'utf-8')).trim();
263
- let files = [];
264
- try {
265
- files = await readAgentFiles(cwd);
266
- }
267
- catch {
268
- // No git or missing required files — proceed with bundle-only upload
269
- }
270
- const initial = (await client.post(`/agents/${agentId}/versions`, {
271
- version_type: 'EPHEMERAL',
272
- bundle,
273
- encoding: 'gzip;base64',
274
- files,
275
- summary,
276
- }));
277
- const pollResult = await pollUntilComplete({
278
- resourceId: initial.id,
279
- endpoint: `/versions/${initial.id}`,
280
- isComplete: (r) => r.validation_status !== 'PENDING' && r.validation_status !== 'RUNNING',
281
- message: 'Validating bundle...',
282
- successMessage: 'Bundle validated',
283
- timeoutMessage: 'Bundle validation timed out',
284
- maxAttempts: 120,
285
- delayMs: 1000,
286
- });
287
- if (!pollResult.success || !pollResult.response) {
288
- throw new BuildTimeoutError('Bundle validation timed out.');
289
- }
290
- const version = pollResult.response;
291
- if (version.validation_status === 'FAILED') {
292
- let failedSteps = [];
293
- try {
294
- const stepsResponse = await client.get(`/versions/${version.id}/validation/steps`);
295
- failedSteps = stepsResponse.steps
296
- .filter((step) => step.status === 'FAILED')
297
- .map((step) => ({ name: step.name, content: step.content ?? undefined }));
298
- }
299
- catch {
300
- // Could not fetch validation details — throw with empty steps
301
- }
302
- throw new BuildFailedError(failedSteps);
303
- }
304
- return { version };
305
- }
306
- //# sourceMappingURL=agent-helpers.js.map
@@ -1,59 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Suppress Ink's clearTerminal (ESC[2J + ESC[3J + ESC[H]) during splash.
5
- *
6
- * When Ink's output fills the terminal, it uses ansi-escapes clearTerminal
7
- * on every frame. This sequence:
8
- * ESC[2J - erase display (iTerm2 pushes content to scrollback)
9
- * ESC[3J - erase scrollback (triggers iTerm2 warning)
10
- * ESC[H - cursor home
11
- *
12
- * We handle this in two phases:
13
- *
14
- * First frame: ESC[2J + ESC[H (push current screen to scrollback, then clear)
15
- * This preserves the user's terminal history in scrollback.
16
- *
17
- * Later frames: ESC[H + ESC[J (cursor home + erase to end of display)
18
- * Overwrites in-place without pushing frames to scrollback.
19
- *
20
- * ESC[3J is always stripped — it's never needed and triggers iTerm2 warnings.
21
- */
22
- /**
23
- * The full clearTerminal sequence that Ink emits via ansi-escapes.
24
- * ESC[2J (erase display) + ESC[3J (erase scrollback) + ESC[H (cursor home)
25
- */
26
- const CLEAR_TERMINAL = '\x1b[2J\x1b[3J\x1b[H';
27
- /** First frame: push visible screen to scrollback, clear, cursor home. */
28
- const CLEAR_FIRST = '\x1b[2J\x1b[H';
29
- /** Later frames: cursor home, erase from cursor to end of display. */
30
- const CLEAR_SUBSEQUENT = '\x1b[H\x1b[J';
31
- let originalWrite = null;
32
- let firstFrame = true;
33
- /**
34
- * Patch stdout.write to replace clearTerminal with a scrollback-safe clear.
35
- * Safe to call multiple times — only patches once.
36
- */
37
- export function suppressScrollbackClear() {
38
- if (originalWrite)
39
- return; // Already patched
40
- originalWrite = process.stdout.write;
41
- const patched = function (chunk, ...args) {
42
- if (typeof chunk === 'string' && chunk.includes(CLEAR_TERMINAL)) {
43
- if (firstFrame) {
44
- // First frame: use ESC[2J to push current screen to scrollback
45
- firstFrame = false;
46
- chunk = chunk.replace(CLEAR_TERMINAL, CLEAR_FIRST);
47
- }
48
- else {
49
- // Subsequent frames: overwrite in-place, no scrollback push
50
- chunk = chunk.replace(CLEAR_TERMINAL, CLEAR_SUBSEQUENT);
51
- }
52
- }
53
- if (!originalWrite)
54
- return false;
55
- return originalWrite.apply(this, [chunk, ...args]);
56
- };
57
- process.stdout.write = patched;
58
- }
59
- //# sourceMappingURL=alternate-screen.js.map
@@ -1,154 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import axios from 'axios';
4
- import { getAuthToken, clearAuthToken } from './auth.js';
5
- import { retry, debug, GuildCLIError, ErrorCodes, shouldClearAuthToken, } from './errors.js';
6
- import { getUserAgent, getGuildcoreUrl } from './config.js';
7
- import { getIapHeaders } from './iap.js';
8
- /**
9
- * HTTP client for Guild API
10
- * Handles authentication, error handling, and request formatting
11
- */
12
- export class GuildAPIClient {
13
- client;
14
- baseUrl;
15
- enableRetry;
16
- maxRetries;
17
- constructor(options = {}) {
18
- this.baseUrl = options.baseUrl || getGuildcoreUrl();
19
- this.enableRetry = options.enableRetry !== false; // Default: enabled
20
- this.maxRetries = options.maxRetries || 3;
21
- this.client = axios.create({
22
- baseURL: this.baseUrl,
23
- timeout: options.defaultTimeout || 30000,
24
- headers: {
25
- 'Content-Type': 'application/json',
26
- Accept: 'application/json',
27
- 'User-Agent': getUserAgent(),
28
- },
29
- });
30
- debug(`API Client initialized: ${this.baseUrl}, retry: ${this.enableRetry}, max retries: ${this.maxRetries}`);
31
- }
32
- /**
33
- * Make an HTTP request with automatic auth header injection
34
- * @param method - HTTP method
35
- * @param endpoint - API endpoint path
36
- * @param config - Axios request configuration
37
- * @returns Response data
38
- * @throws Error with specific error codes for proper error handling
39
- */
40
- async request(method, endpoint, config = {}) {
41
- const makeRequest = async () => {
42
- // Add IAP headers for IAP-protected hosts (*.guildai.dev)
43
- // Uses Proxy-Authorization header so Authorization can be used for GuildCore auth
44
- const iapHeaders = await getIapHeaders(this.baseUrl);
45
- config.headers = {
46
- ...config.headers,
47
- ...iapHeaders,
48
- };
49
- // Add authentication header for authenticated endpoints
50
- const requiresAuth = !endpoint.startsWith('/oauth/') && !endpoint.startsWith('/hello');
51
- if (requiresAuth) {
52
- const token = await getAuthToken();
53
- if (!token) {
54
- throw new GuildCLIError(ErrorCodes.AUTH_REQUIRED, 'Authentication required. Please run: guild auth login');
55
- }
56
- config.headers = {
57
- ...config.headers,
58
- Authorization: `Bearer ${token}`,
59
- };
60
- }
61
- debug(`Making ${method} request to ${endpoint}`);
62
- try {
63
- const response = await this.client.request({
64
- method,
65
- url: endpoint,
66
- ...config,
67
- });
68
- debug(`Request successful: ${method} ${endpoint}`);
69
- return response.data;
70
- }
71
- catch (error) {
72
- if (error &&
73
- typeof error === 'object' &&
74
- 'response' in error &&
75
- error.response?.status === 401) {
76
- const resp = error.response;
77
- const data = resp?.data;
78
- const message = typeof data === 'object' && data && 'message' in data
79
- ? data.message
80
- : undefined;
81
- if (shouldClearAuthToken(message)) {
82
- debug('Guild auth failure (401), clearing token');
83
- await clearAuthToken();
84
- throw new GuildCLIError(ErrorCodes.AUTH_TOKEN_INVALID, 'Your authentication token is invalid or expired. Please run: guild auth login');
85
- }
86
- debug(`Non-auth 401: ${message ?? 'no message'}`);
87
- }
88
- throw error;
89
- }
90
- };
91
- // Use retry logic if enabled
92
- if (this.enableRetry) {
93
- return await retry(makeRequest, {
94
- maxAttempts: this.maxRetries,
95
- });
96
- }
97
- else {
98
- return await makeRequest();
99
- }
100
- }
101
- /**
102
- * Make a GET request
103
- */
104
- async get(endpoint, config) {
105
- return this.request('GET', endpoint, config);
106
- }
107
- /**
108
- * Make a POST request
109
- */
110
- async post(endpoint, data, config) {
111
- return this.request('POST', endpoint, { ...config, data });
112
- }
113
- /**
114
- * Make a PUT request
115
- */
116
- async put(endpoint, data, config) {
117
- return this.request('PUT', endpoint, { ...config, data });
118
- }
119
- /**
120
- * Make a PATCH request
121
- */
122
- async patch(endpoint, data, config) {
123
- return this.request('PATCH', endpoint, { ...config, data });
124
- }
125
- /**
126
- * Make a DELETE request
127
- */
128
- async delete(endpoint, config) {
129
- return this.request('DELETE', endpoint, config);
130
- }
131
- /**
132
- * Fetch all items from a paginated endpoint by paging through results.
133
- * Use for display commands or ID-based lookups where you need the complete list.
134
- *
135
- * @param endpoint - API endpoint path (may include query params)
136
- * @returns Flat array of all items across all pages
137
- */
138
- async fetchAll(endpoint) {
139
- const PAGE_SIZE = 100;
140
- const allItems = [];
141
- let offset = 0;
142
- while (true) {
143
- const separator = endpoint.includes('?') ? '&' : '?';
144
- const url = `${endpoint}${separator}limit=${PAGE_SIZE}&offset=${offset}`;
145
- const response = await this.get(url);
146
- allItems.push(...response.items);
147
- offset += response.pagination.limit;
148
- if (!response.pagination.has_more)
149
- break;
150
- }
151
- return allItems;
152
- }
153
- }
154
- //# sourceMappingURL=api-client.js.map
@@ -1,10 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- /** Default page size for standard list endpoints (matches backend). */
4
- export const DEFAULT_PAGE_LIMIT = 20;
5
- /** Default page size for high-volume endpoints (events, tasks, operations). */
6
- export const DEFAULT_PAGE_LIMIT_LARGE = 100;
7
- // Import and re-export generated types (from cli/scripts/sync-types-from-python.py)
8
- import { WEBHOOK_SERVICES, TIME_TRIGGER_FREQUENCIES, } from './generated-types.js';
9
- export { WEBHOOK_SERVICES, TIME_TRIGGER_FREQUENCIES, };
10
- //# sourceMappingURL=api-types.js.map