@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.
Files changed (203) 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/agent/logs.d.ts +3 -0
  36. package/dist/commands/setup.d.ts +16 -0
  37. package/dist/commands/skill/create.d.ts +3 -0
  38. package/dist/commands/skill/get.d.ts +3 -0
  39. package/dist/commands/skill/list.d.ts +3 -0
  40. package/dist/commands/skill/update.d.ts +3 -0
  41. package/dist/commands/skill/version/create.d.ts +3 -0
  42. package/dist/commands/skill/version/get.d.ts +3 -0
  43. package/dist/commands/skill/version/list.d.ts +3 -0
  44. package/dist/devtools-AO7YSDOD.js +67 -0
  45. package/dist/devtools-AO7YSDOD.js.map +7 -0
  46. package/dist/dist-4CBK6X5H.js +1566 -0
  47. package/dist/dist-4CBK6X5H.js.map +7 -0
  48. package/dist/esm-FRAVZP4J.js +13 -0
  49. package/dist/esm-FRAVZP4J.js.map +7 -0
  50. package/dist/execa-XQMWSABC.js +35 -0
  51. package/dist/execa-XQMWSABC.js.map +7 -0
  52. package/dist/index.js +8231 -253
  53. package/dist/index.js.map +7 -0
  54. package/dist/lib/api-types.d.ts +44 -0
  55. package/dist/lib/auth.d.ts +1 -1
  56. package/dist/lib/config.d.ts +9 -0
  57. package/dist/lib/errors.d.ts +1 -1
  58. package/dist/lib/output-mode.d.ts +9 -2
  59. package/dist/lib/output.d.ts +17 -1
  60. package/dist/lib/session-events.d.ts +14 -3
  61. package/dist/lib/session-polling.d.ts +24 -1
  62. package/dist/lib/session-resume.d.ts +15 -1
  63. package/dist/lib/stdin.d.ts +5 -1
  64. package/dist/lib/websocket-client.d.ts +46 -0
  65. package/dist/open-RF4X5MOP.js +13 -0
  66. package/dist/open-RF4X5MOP.js.map +7 -0
  67. package/dist/server-JYVH64FD.js +27659 -0
  68. package/dist/server-JYVH64FD.js.map +7 -0
  69. package/dist/test-SNIYRJ32.js +692 -0
  70. package/dist/test-SNIYRJ32.js.map +7 -0
  71. package/docs/skills/codex-agent-dev.md +2 -2
  72. package/package.json +8 -12
  73. package/dist/commands/agent/chat.js +0 -278
  74. package/dist/commands/agent/clone.js +0 -116
  75. package/dist/commands/agent/code.js +0 -87
  76. package/dist/commands/agent/fork.js +0 -218
  77. package/dist/commands/agent/get.js +0 -37
  78. package/dist/commands/agent/grep.js +0 -107
  79. package/dist/commands/agent/init.js +0 -390
  80. package/dist/commands/agent/list.js +0 -110
  81. package/dist/commands/agent/owners.js +0 -74
  82. package/dist/commands/agent/publish.js +0 -91
  83. package/dist/commands/agent/pull.js +0 -198
  84. package/dist/commands/agent/revalidate.js +0 -56
  85. package/dist/commands/agent/save.js +0 -346
  86. package/dist/commands/agent/search.js +0 -61
  87. package/dist/commands/agent/tags/add.js +0 -73
  88. package/dist/commands/agent/tags/list.js +0 -43
  89. package/dist/commands/agent/tags/remove.js +0 -84
  90. package/dist/commands/agent/tags/set.js +0 -71
  91. package/dist/commands/agent/test.js +0 -486
  92. package/dist/commands/agent/unpublish.js +0 -64
  93. package/dist/commands/agent/update.js +0 -110
  94. package/dist/commands/agent/versions.js +0 -55
  95. package/dist/commands/agent/workspaces.js +0 -54
  96. package/dist/commands/auth/login.js +0 -33
  97. package/dist/commands/auth/logout.js +0 -24
  98. package/dist/commands/auth/status.js +0 -38
  99. package/dist/commands/auth/token.js +0 -19
  100. package/dist/commands/chat.js +0 -1345
  101. package/dist/commands/config/get.js +0 -64
  102. package/dist/commands/config/list.js +0 -47
  103. package/dist/commands/config/path.js +0 -38
  104. package/dist/commands/config/set.js +0 -132
  105. package/dist/commands/credentials/endpoint-list.js +0 -88
  106. package/dist/commands/credentials/list.js +0 -50
  107. package/dist/commands/credentials/policy-create.js +0 -66
  108. package/dist/commands/credentials/policy-delete.js +0 -33
  109. package/dist/commands/credentials/policy-list.js +0 -45
  110. package/dist/commands/credentials/policy-update.js +0 -66
  111. package/dist/commands/doctor.js +0 -233
  112. package/dist/commands/integration/connect.js +0 -76
  113. package/dist/commands/integration/create.js +0 -298
  114. package/dist/commands/integration/get.js +0 -95
  115. package/dist/commands/integration/list.js +0 -62
  116. package/dist/commands/integration/operation/create.js +0 -164
  117. package/dist/commands/integration/operation/list.js +0 -92
  118. package/dist/commands/integration/update.js +0 -139
  119. package/dist/commands/integration/version/build.js +0 -86
  120. package/dist/commands/integration/version/create.js +0 -45
  121. package/dist/commands/integration/version/get.js +0 -72
  122. package/dist/commands/integration/version/list.js +0 -45
  123. package/dist/commands/integration/version/publish.js +0 -79
  124. package/dist/commands/integration/version/test.js +0 -104
  125. package/dist/commands/job/get-step.js +0 -40
  126. package/dist/commands/job/get.js +0 -44
  127. package/dist/commands/mcp.js +0 -34
  128. package/dist/commands/session/create.js +0 -59
  129. package/dist/commands/session/events.js +0 -56
  130. package/dist/commands/session/get.js +0 -33
  131. package/dist/commands/session/interrupt.js +0 -33
  132. package/dist/commands/session/list.js +0 -59
  133. package/dist/commands/session/send.js +0 -54
  134. package/dist/commands/session/tasks.js +0 -45
  135. package/dist/commands/setup.js +0 -230
  136. package/dist/commands/trigger/activate.js +0 -41
  137. package/dist/commands/trigger/create.js +0 -197
  138. package/dist/commands/trigger/deactivate.js +0 -41
  139. package/dist/commands/trigger/get.js +0 -33
  140. package/dist/commands/trigger/list.js +0 -57
  141. package/dist/commands/trigger/sessions.js +0 -48
  142. package/dist/commands/trigger/update.js +0 -128
  143. package/dist/commands/version.js +0 -24
  144. package/dist/commands/workspace/agent/add.js +0 -114
  145. package/dist/commands/workspace/agent/list.js +0 -78
  146. package/dist/commands/workspace/agent/remove.js +0 -78
  147. package/dist/commands/workspace/clear.js +0 -45
  148. package/dist/commands/workspace/context/edit.js +0 -107
  149. package/dist/commands/workspace/context/get.js +0 -47
  150. package/dist/commands/workspace/context/list.js +0 -51
  151. package/dist/commands/workspace/context/publish.js +0 -42
  152. package/dist/commands/workspace/create.js +0 -51
  153. package/dist/commands/workspace/current.js +0 -63
  154. package/dist/commands/workspace/get.js +0 -39
  155. package/dist/commands/workspace/list.js +0 -70
  156. package/dist/commands/workspace/select.js +0 -184
  157. package/dist/components/AgentInstallPrompt.js +0 -97
  158. package/dist/components/SplashAnimation.js +0 -321
  159. package/dist/components/TaskView.js +0 -268
  160. package/dist/lib/agent-helpers.js +0 -306
  161. package/dist/lib/alternate-screen.js +0 -59
  162. package/dist/lib/api-client.js +0 -154
  163. package/dist/lib/api-types.js +0 -10
  164. package/dist/lib/auth.js +0 -284
  165. package/dist/lib/braille-canvas.js +0 -321
  166. package/dist/lib/colors.js +0 -46
  167. package/dist/lib/config-cache.js +0 -45
  168. package/dist/lib/config.js +0 -153
  169. package/dist/lib/did-you-mean.js +0 -144
  170. package/dist/lib/errors.js +0 -375
  171. package/dist/lib/event-filter.js +0 -91
  172. package/dist/lib/generated-types.js +0 -56
  173. package/dist/lib/git.js +0 -176
  174. package/dist/lib/gk.js +0 -91
  175. package/dist/lib/guild-config.js +0 -178
  176. package/dist/lib/iap.js +0 -117
  177. package/dist/lib/integration-helpers.js +0 -38
  178. package/dist/lib/loading-messages.js +0 -72
  179. package/dist/lib/logo.js +0 -141
  180. package/dist/lib/lottie-serverside.js +0 -181
  181. package/dist/lib/markdown.js +0 -38
  182. package/dist/lib/npmrc.js +0 -59
  183. package/dist/lib/output-mode.js +0 -33
  184. package/dist/lib/output.js +0 -591
  185. package/dist/lib/owner-helpers.js +0 -112
  186. package/dist/lib/polling.js +0 -76
  187. package/dist/lib/progress.js +0 -324
  188. package/dist/lib/session-events-fetch.js +0 -25
  189. package/dist/lib/session-events.js +0 -112
  190. package/dist/lib/session-polling.js +0 -160
  191. package/dist/lib/session-resume.js +0 -96
  192. package/dist/lib/spinners.js +0 -770
  193. package/dist/lib/splash.js +0 -41
  194. package/dist/lib/stdin.js +0 -84
  195. package/dist/lib/svg-to-braille.js +0 -76
  196. package/dist/lib/table.js +0 -59
  197. package/dist/lib/update-check.js +0 -65
  198. package/dist/lib/validate-input-schema.js +0 -208
  199. package/dist/lib/version-helpers.js +0 -121
  200. package/dist/lib/workspace-helpers.js +0 -49
  201. package/dist/mcp/resources.js +0 -67
  202. package/dist/mcp/server.js +0 -64
  203. package/dist/mcp/tools.js +0 -753
@@ -1,41 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import chalk from 'chalk';
4
- import LOGO from './logo.js';
5
- import { brand } from './colors.js';
6
- /**
7
- * Show splash screen with logo
8
- */
9
- export function showSplashScreen(options) {
10
- console.log('');
11
- LOGO.forEach((line) => console.log(brand(line)));
12
- console.log('');
13
- console.log('Guild.ai CLI');
14
- console.log(chalk.dim(`v${options.version}`));
15
- console.log('');
16
- }
17
- /**
18
- * Determine if splash screen should be shown
19
- *
20
- * Show for: help, version, interactive chat
21
- * Never for: --json, data commands, action commands
22
- */
23
- export function shouldShowSplash() {
24
- // Never in JSON mode
25
- if (process.argv.includes('--json')) {
26
- return false;
27
- }
28
- const args = process.argv.slice(2);
29
- // Show for top-level help/version only
30
- // Don't show for subcommand help (e.g., 'guild chat --help')
31
- // Note: chat command renders its own header, so we skip splash for it
32
- if (args.length === 0 || args[0] === 'version') {
33
- return true;
34
- }
35
- // Only show splash for top-level --help (no other commands before it)
36
- if ((args[0] === '--help' || args[0] === '-h') && args.length === 1) {
37
- return true;
38
- }
39
- return false;
40
- }
41
- //# sourceMappingURL=splash.js.map
package/dist/lib/stdin.js DELETED
@@ -1,84 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Check if stdin is connected to an interactive terminal (TTY).
5
- */
6
- export function isInteractive() {
7
- return process.stdin.isTTY === true;
8
- }
9
- /**
10
- * Exit with a helpful error when stdin is piped but no --mode flag was given.
11
- * Call this before rendering an interactive UI (Ink render()) so users who
12
- * accidentally pipe input without --mode get clear guidance instead of a hang.
13
- */
14
- export function ensureInteractiveStdin(command) {
15
- if (!process.stdin.isTTY) {
16
- console.error('Error: stdin is piped but --mode was not specified');
17
- console.error('');
18
- console.error('When piping input, use --mode to set the input format:');
19
- console.error(` echo '{"prompt":"hello"}' | ${command} --mode json`);
20
- console.error(` cat inputs.jsonl | ${command} --mode jsonl`);
21
- console.error('');
22
- console.error('Or run interactively (no pipe):');
23
- console.error(` ${command}`);
24
- process.exit(1);
25
- }
26
- }
27
- /**
28
- * Read raw text from stdin with a timeout.
29
- */
30
- export function readStdinAsText() {
31
- return new Promise((resolve, reject) => {
32
- let input = '';
33
- const timeout = setTimeout(() => {
34
- reject(new Error('Timeout waiting for stdin'));
35
- }, 5000);
36
- process.stdin.setEncoding('utf8');
37
- process.stdin.on('data', (chunk) => {
38
- input += chunk;
39
- });
40
- process.stdin.on('end', () => {
41
- clearTimeout(timeout);
42
- resolve(input);
43
- });
44
- process.stdin.on('error', (error) => {
45
- clearTimeout(timeout);
46
- reject(error);
47
- });
48
- });
49
- }
50
- /**
51
- * Read JSON from stdin with a timeout.
52
- */
53
- export function readStdinAsJSON() {
54
- return new Promise((resolve, reject) => {
55
- let input = '';
56
- const timeout = setTimeout(() => {
57
- reject(new Error('Timeout waiting for stdin'));
58
- }, 5000);
59
- process.stdin.setEncoding('utf8');
60
- process.stdin.on('data', (chunk) => {
61
- input += chunk;
62
- });
63
- process.stdin.on('end', () => {
64
- clearTimeout(timeout);
65
- if (!input.trim()) {
66
- reject(new Error('No JSON input provided'));
67
- return;
68
- }
69
- try {
70
- const parsed = JSON.parse(input);
71
- resolve(parsed);
72
- }
73
- catch (error) {
74
- const err = error;
75
- reject(new Error(`Invalid JSON: ${err.message}`));
76
- }
77
- });
78
- process.stdin.on('error', (error) => {
79
- clearTimeout(timeout);
80
- reject(error);
81
- });
82
- });
83
- }
84
- //# sourceMappingURL=stdin.js.map
@@ -1,76 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- /**
4
- * Simple SVG to Braille converter using proper SVG rendering
5
- * Uses sharp to render SVG to bitmap, then samples pixels for braille
6
- */
7
- import sharp from 'sharp';
8
- // Braille Unicode range: U+2800 to U+28FF
9
- // Each braille character represents an 8-pixel grid (2x4)
10
- // Bit positions (0-indexed):
11
- // 0 3
12
- // 1 4
13
- // 2 5
14
- // 6 7
15
- /**
16
- * Convert SVG string to braille text representation
17
- */
18
- export async function svgToBraille(svgString, widthChars, heightChars) {
19
- // Each braille char is 2 pixels wide, 4 pixels tall
20
- const pixelWidth = widthChars * 2;
21
- const pixelHeight = heightChars * 4;
22
- // Single-pass pipeline: render SVG to bitmap and get raw pixel data
23
- const { data, info } = await sharp(Buffer.from(svgString))
24
- .resize(pixelWidth, pixelHeight, {
25
- fit: 'contain',
26
- background: { r: 255, g: 255, b: 255, alpha: 1 },
27
- })
28
- .flatten({ background: { r: 255, g: 255, b: 255 } })
29
- .greyscale()
30
- .raw()
31
- .toBuffer({ resolveWithObject: true });
32
- // Convert pixels to braille
33
- const lines = [];
34
- for (let row = 0; row < heightChars; row++) {
35
- let line = '';
36
- for (let col = 0; col < widthChars; col++) {
37
- // Sample 2x4 pixel grid for this braille character
38
- let brailleBits = 0;
39
- for (let dy = 0; dy < 4; dy++) {
40
- for (let dx = 0; dx < 2; dx++) {
41
- const pixelX = col * 2 + dx;
42
- const pixelY = row * 4 + dy;
43
- // Get pixel value (grayscale: black = 0, white = 255)
44
- const pixelIndex = (pixelY * info.width + pixelX) * info.channels;
45
- const pixelValue = data[pixelIndex]; // R channel (they're all the same for grayscale)
46
- // If pixel is dark (< 128), set the corresponding braille bit
47
- if (pixelValue < 128) {
48
- // Map pixel position to braille bit position
49
- // dx=0,dy=0 -> bit 0
50
- // dx=0,dy=1 -> bit 1
51
- // dx=0,dy=2 -> bit 2
52
- // dx=0,dy=3 -> bit 6
53
- // dx=1,dy=0 -> bit 3
54
- // dx=1,dy=1 -> bit 4
55
- // dx=1,dy=2 -> bit 5
56
- // dx=1,dy=3 -> bit 7
57
- let bitPos;
58
- if (dx === 0) {
59
- bitPos = dy < 3 ? dy : 6;
60
- }
61
- else {
62
- bitPos = dy < 3 ? dy + 3 : 7;
63
- }
64
- brailleBits |= 1 << bitPos;
65
- }
66
- }
67
- }
68
- // Convert bit pattern to braille Unicode character
69
- const brailleChar = String.fromCharCode(0x2800 + brailleBits);
70
- line += brailleChar;
71
- }
72
- lines.push(line);
73
- }
74
- return lines;
75
- }
76
- //# sourceMappingURL=svg-to-braille.js.map
package/dist/lib/table.js DELETED
@@ -1,59 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import chalk from 'chalk';
4
- import stringWidth from 'string-width';
5
- /**
6
- * Minimal table renderer using string-width@7 for ANSI-aware column sizing.
7
- */
8
- export class Table {
9
- columns;
10
- rows = [];
11
- constructor(config) {
12
- this.columns = config.columns;
13
- }
14
- addRow(row) {
15
- const sanitized = {};
16
- for (const [k, v] of Object.entries(row)) {
17
- sanitized[k] = v.replace(/[\r\n]+/g, ' ').trim();
18
- }
19
- this.rows.push(sanitized);
20
- }
21
- render() {
22
- const widths = this.columns.map((col) => {
23
- const headerWidth = stringWidth(col.title);
24
- const maxData = this.rows.reduce((max, row) => Math.max(max, stringWidth(row[col.name] ?? '')), 0);
25
- return Math.max(headerWidth, maxData);
26
- });
27
- const pad = (text, width) => {
28
- const visible = stringWidth(text);
29
- return visible >= width ? text : text + ' '.repeat(width - visible);
30
- };
31
- const top = '┌' + widths.map((w) => '─'.repeat(w + 2)).join('┬') + '┐';
32
- const mid = '├' + widths.map((w) => '─'.repeat(w + 2)).join('┼') + '┤';
33
- const bot = '└' + widths.map((w) => '─'.repeat(w + 2)).join('┴') + '┘';
34
- const header = '│' +
35
- this.columns
36
- .map((col, i) => ' ' + chalk.bold(pad(col.title, widths[i])) + ' ')
37
- .join('│') +
38
- '│';
39
- const dataRows = this.rows.map((row) => '│' +
40
- this.columns
41
- .map((col, i) => {
42
- const val = row[col.name] ?? '';
43
- const padded = pad(val, widths[i]);
44
- if (col.color && col.color in chalk) {
45
- return (' ' +
46
- chalk[col.color](padded) +
47
- ' ');
48
- }
49
- return ' ' + padded + ' ';
50
- })
51
- .join('│') +
52
- '│');
53
- return [top, header, mid, ...dataRows, bot].join('\n');
54
- }
55
- printTable() {
56
- console.log(this.render());
57
- }
58
- }
59
- //# sourceMappingURL=table.js.map
@@ -1,65 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import https from 'https';
4
- import { getOutputMode, isQuietMode } from './output-mode.js';
5
- /**
6
- * Fire-and-forget check for a newer version on npm.
7
- * Prints a one-liner to stderr if an update is available.
8
- * Network failures are silently ignored.
9
- */
10
- export function checkForUpdate(currentVersion) {
11
- // Suppress in JSON mode, quiet mode, or non-TTY stderr
12
- if (getOutputMode() === 'json' || isQuietMode() || !process.stderr.isTTY) {
13
- return;
14
- }
15
- const req = https.get('https://registry.npmjs.org/@guildai/cli/latest', { timeout: 3000 }, (res) => {
16
- let data = '';
17
- res.on('data', (chunk) => {
18
- data += chunk.toString();
19
- });
20
- res.on('end', () => {
21
- try {
22
- const pkg = JSON.parse(data);
23
- if (pkg.version && isNewer(pkg.version, currentVersion)) {
24
- process.stderr.write(`\nUpdate available: ${currentVersion} → ${pkg.version} Run: npm install -g @guildai/cli\n`);
25
- }
26
- }
27
- catch {
28
- // malformed JSON — ignore
29
- }
30
- });
31
- });
32
- req.on('error', () => {
33
- // network failure — ignore
34
- });
35
- req.on('timeout', () => {
36
- req.destroy();
37
- });
38
- // Don't let this request keep the process alive
39
- if (req.socket) {
40
- req.socket.unref();
41
- }
42
- else {
43
- req.on('socket', (socket) => {
44
- socket.unref();
45
- });
46
- }
47
- }
48
- /**
49
- * Simple numeric version comparison (major.minor.patch).
50
- * Returns true if `latest` is strictly newer than `current`.
51
- */
52
- export function isNewer(latest, current) {
53
- const l = latest.split('.').map(Number);
54
- const c = current.split('.').map(Number);
55
- for (let i = 0; i < Math.max(l.length, c.length); i++) {
56
- const lv = l[i] ?? 0;
57
- const cv = c[i] ?? 0;
58
- if (lv > cv)
59
- return true;
60
- if (lv < cv)
61
- return false;
62
- }
63
- return false;
64
- }
65
- //# sourceMappingURL=update-check.js.map
@@ -1,208 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import * as fs from 'fs/promises';
4
- import * as path from 'path';
5
- import * as os from 'os';
6
- import { execFile } from 'child_process';
7
- import { promisify } from 'util';
8
- import { debug } from './errors.js';
9
- const execFileAsync = promisify(execFile);
10
- function resolveSourceEntryPoint(agentDir, packageJson) {
11
- const exports = packageJson.exports;
12
- if (exports?.['.']) {
13
- const distPath = exports['.'];
14
- const sourcePath = distPath
15
- .replace(/^\.\/dist\//, '')
16
- .replace(/\.compiled\.js$/, '.ts')
17
- .replace(/\.js$/, '.ts');
18
- return path.join(agentDir, sourcePath);
19
- }
20
- return path.join(agentDir, 'agent.ts');
21
- }
22
- async function fileExists(filePath) {
23
- return fs
24
- .access(filePath)
25
- .then(() => true)
26
- .catch(() => false);
27
- }
28
- /**
29
- * Extract a single `const <name> = z.<call>(...)` declaration from source,
30
- * starting at the given regex match. Uses balanced parenthesis matching
31
- * with string literal awareness.
32
- */
33
- function extractZodDeclaration(source, match) {
34
- const startIndex = match.index;
35
- const afterEquals = match.index + match[0].length;
36
- let depth = 0;
37
- let foundOpen = false;
38
- let endIndex = afterEquals;
39
- let inString = null;
40
- for (let charIndex = afterEquals; charIndex < source.length; charIndex++) {
41
- const char = source[charIndex];
42
- if (inString) {
43
- if (char === '\\') {
44
- charIndex++;
45
- }
46
- else if (char === inString) {
47
- inString = null;
48
- }
49
- continue;
50
- }
51
- if (char === '"' || char === "'" || char === '`') {
52
- inString = char;
53
- }
54
- else if (char === '(') {
55
- depth++;
56
- foundOpen = true;
57
- }
58
- else if (char === ')') {
59
- depth--;
60
- if (foundOpen && depth === 0) {
61
- endIndex = charIndex + 1;
62
- if (source[endIndex] === ';')
63
- endIndex++;
64
- break;
65
- }
66
- }
67
- }
68
- if (!foundOpen)
69
- return null;
70
- return source.substring(startIndex, endIndex);
71
- }
72
- /**
73
- * Extract inputSchema and any Zod schema dependencies from agent source.
74
- * Finds all `const <name> = z.<call>(...)` declarations that appear before
75
- * inputSchema (which may be referenced inside it), plus inputSchema itself.
76
- * Returns them in source order so dependencies are defined before use.
77
- */
78
- function extractInputSchema(source) {
79
- const inputPattern = /const\s+inputSchema\s*=\s*/;
80
- const inputMatch = inputPattern.exec(source);
81
- if (!inputMatch)
82
- return null;
83
- const inputBlock = extractZodDeclaration(source, inputMatch);
84
- if (!inputBlock)
85
- return null;
86
- const blocks = [];
87
- const zodDeclPattern = /const\s+\w+\s*=\s*z\s*\.\s*/g;
88
- let declMatch;
89
- while ((declMatch = zodDeclPattern.exec(source)) !== null) {
90
- if (declMatch.index >= inputMatch.index)
91
- break;
92
- const block = extractZodDeclaration(source, declMatch);
93
- if (block)
94
- blocks.push(block);
95
- }
96
- blocks.push(inputBlock);
97
- return blocks.join('\n');
98
- }
99
- export async function validateInputSchema(agentDir, inputs) {
100
- const nodeModulesPath = path.join(agentDir, 'node_modules');
101
- if (!(await fileExists(nodeModulesPath))) {
102
- return {
103
- valid: true,
104
- skipped: true,
105
- reason: 'run npm install for pre-build input validation',
106
- };
107
- }
108
- const pkgJsonPath = path.join(agentDir, 'package.json');
109
- if (!(await fileExists(pkgJsonPath))) {
110
- return {
111
- valid: true,
112
- skipped: true,
113
- reason: 'no package.json found',
114
- };
115
- }
116
- const pkgJson = JSON.parse(await fs.readFile(pkgJsonPath, 'utf-8'));
117
- let entryPoint = resolveSourceEntryPoint(agentDir, pkgJson);
118
- if (!(await fileExists(entryPoint))) {
119
- const fallback = path.join(agentDir, 'agent.ts');
120
- if (await fileExists(fallback)) {
121
- entryPoint = fallback;
122
- }
123
- else {
124
- return {
125
- valid: true,
126
- skipped: true,
127
- reason: `could not find agent source file (tried ${path.basename(entryPoint)})`,
128
- };
129
- }
130
- }
131
- const agentSource = await fs.readFile(entryPoint, 'utf-8');
132
- const schemaBlock = extractInputSchema(agentSource);
133
- if (!schemaBlock) {
134
- return {
135
- valid: true,
136
- skipped: true,
137
- reason: 'could not find inputSchema definition in agent source',
138
- };
139
- }
140
- const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'guild-validate-'));
141
- try {
142
- const extractorSource = [
143
- `import { z } from "zod";`,
144
- schemaBlock,
145
- `const inputs = JSON.parse(process.argv[2]);`,
146
- `const errors = [];`,
147
- `for (let i = 0; i < inputs.length; i++) {`,
148
- ` try {`,
149
- ` inputSchema.parse(inputs[i]);`,
150
- ` } catch (e) {`,
151
- ` const issues = e.issues || [{ message: e.message }];`,
152
- ` errors.push({ index: i, issues: issues.map(iss => ({ message: iss.message, path: iss.path })) });`,
153
- ` }`,
154
- `}`,
155
- `if (errors.length > 0) {`,
156
- ` console.log(JSON.stringify({ valid: false, errors }));`,
157
- `} else {`,
158
- ` console.log(JSON.stringify({ valid: true }));`,
159
- `}`,
160
- ].join('\n');
161
- const extractorPath = path.join(tmpDir, 'validate.mjs');
162
- await fs.writeFile(extractorPath, extractorSource);
163
- const { build } = await import('esbuild');
164
- const bundlePath = path.join(tmpDir, 'validate-bundle.mjs');
165
- await build({
166
- entryPoints: [extractorPath],
167
- bundle: true,
168
- format: 'esm',
169
- target: 'esnext',
170
- platform: 'node',
171
- outfile: bundlePath,
172
- logLevel: 'silent',
173
- nodePaths: [path.join(agentDir, 'node_modules')],
174
- });
175
- const inputArg = JSON.stringify(inputs);
176
- const { stdout } = await execFileAsync('node', [bundlePath, inputArg], {
177
- cwd: agentDir,
178
- timeout: 10000,
179
- });
180
- const result = JSON.parse(stdout.trim());
181
- if (result.valid) {
182
- return { valid: true };
183
- }
184
- const flatErrors = [];
185
- for (const entry of result.errors) {
186
- for (const issue of entry.issues) {
187
- const prefix = inputs.length > 1 ? `Line ${entry.index + 1}: ` : '';
188
- flatErrors.push({
189
- message: `${prefix}${issue.message}`,
190
- path: issue.path,
191
- });
192
- }
193
- }
194
- return { valid: false, errors: flatErrors };
195
- }
196
- catch (error) {
197
- debug('Local input validation failed: %s', error);
198
- return {
199
- valid: true,
200
- skipped: true,
201
- reason: 'local validation encountered an error (server-side validation will still run)',
202
- };
203
- }
204
- finally {
205
- await fs.rm(tmpDir, { recursive: true, force: true }).catch(() => { });
206
- }
207
- }
208
- //# sourceMappingURL=validate-input-schema.js.map
@@ -1,121 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { GuildAPIClient } from './api-client.js';
4
- import { pollUntilComplete } from './polling.js';
5
- /**
6
- * Format a list of validation steps into a compact single-line status string
7
- * suitable for spinner text, e.g. `✓ build ⟳ test ○ deploy`.
8
- * Returns null when the steps array is empty so callers can fall back to the
9
- * default attempt-counter text.
10
- */
11
- function formatStepProgress(steps) {
12
- if (steps.length === 0)
13
- return null;
14
- const tokens = steps.map((step) => {
15
- let prefix;
16
- switch (step.status) {
17
- case 'SUCCEEDED':
18
- prefix = '✓';
19
- break;
20
- case 'RUNNING':
21
- prefix = '⟳';
22
- break;
23
- case 'FAILED':
24
- prefix = '✗';
25
- break;
26
- default:
27
- prefix = '○';
28
- }
29
- return `${prefix} ${step.name}`;
30
- });
31
- return tokens.join(' ');
32
- }
33
- /**
34
- * Poll until a version's validation completes, then check the result.
35
- * Exits the process on timeout or validation failure.
36
- * Returns the updated version on success.
37
- */
38
- export async function waitForValidation(versionId, output) {
39
- const client = new GuildAPIClient();
40
- const pollResult = await pollUntilComplete({
41
- resourceId: versionId,
42
- endpoint: `/versions/${versionId}`,
43
- isComplete: (response) => response.validation_status !== 'PENDING' &&
44
- response.validation_status !== 'RUNNING',
45
- message: 'Waiting for validation to complete...',
46
- successMessage: 'Validation complete',
47
- timeoutMessage: 'Validation timed out',
48
- maxAttempts: 120,
49
- delayMs: 1000,
50
- onPoll: async () => {
51
- const r = await client.get(`/versions/${versionId}/validation/steps`);
52
- return formatStepProgress(r.steps);
53
- },
54
- });
55
- if (!pollResult.success || !pollResult.response) {
56
- output.error('Validation did not complete in time', 'Check status manually:\n guild agent versions');
57
- process.exit(1);
58
- }
59
- const version = pollResult.response;
60
- if (version.validation_status === 'FAILED') {
61
- const details = await fetchValidationFailureDetails(version.id);
62
- output.error('Validation failed', details);
63
- process.exit(1);
64
- }
65
- return version;
66
- }
67
- /**
68
- * Fetch validation step details for a failed version.
69
- */
70
- async function fetchValidationFailureDetails(versionId) {
71
- const client = new GuildAPIClient();
72
- let failureDetails = '';
73
- try {
74
- const stepsResponse = await client.get(`/versions/${versionId}/validation/steps`);
75
- const failedSteps = stepsResponse.steps.filter((step) => step.status === 'FAILED');
76
- if (failedSteps.length > 0) {
77
- failureDetails = failedSteps
78
- .map((step) => step.content
79
- ? `Step "${step.name}" failed: ${step.content}`
80
- : `Step "${step.name}" failed`)
81
- .join('\n');
82
- }
83
- else {
84
- failureDetails = 'No failed steps found. Check validation logs for details.';
85
- }
86
- }
87
- catch {
88
- failureDetails = 'Could not fetch validation details.';
89
- }
90
- failureDetails +=
91
- '\n\nFix the issues, then save a new version:\n guild agent save --message "Fix validation errors"';
92
- return failureDetails;
93
- }
94
- /**
95
- * Poll until a version's publish completes (PUBLISHING → PUBLISHED).
96
- * Exits the process on timeout or failure.
97
- * Returns the updated version on success.
98
- */
99
- export async function waitForPublish(versionId, output) {
100
- const client = new GuildAPIClient();
101
- const pollResult = await pollUntilComplete({
102
- resourceId: versionId,
103
- endpoint: `/versions/${versionId}`,
104
- isComplete: (response) => response.status === 'PUBLISHED' || response.status === 'FAILED',
105
- message: 'Waiting for publish to complete...',
106
- successMessage: 'Published',
107
- timeoutMessage: 'Publish timed out',
108
- maxAttempts: 60,
109
- delayMs: 1000,
110
- onPoll: async () => {
111
- const r = await client.get(`/versions/${versionId}/publish/steps`);
112
- return formatStepProgress(r.steps);
113
- },
114
- });
115
- if (!pollResult.success || pollResult.response?.status !== 'PUBLISHED') {
116
- output.error('Publish did not complete in time', 'Check status manually:\n guild agent versions');
117
- process.exit(1);
118
- }
119
- return pollResult.response;
120
- }
121
- //# sourceMappingURL=version-helpers.js.map