@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,233 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import axios from 'axios';
6
- import { getAuthToken } from '../lib/auth.js';
7
- import { getGuildcoreUrl } from '../lib/config.js';
8
- import { loadGlobalConfig, isAgentDirectory, getGlobalConfigPath, loadLocalConfig, } from '../lib/guild-config.js';
9
- import { getOutputMode } from '../lib/output-mode.js';
10
- import { createOutputWriter } from '../lib/output.js';
11
- async function checkAuth() {
12
- const token = await getAuthToken();
13
- if (token) {
14
- return { name: 'Authentication', status: 'pass', message: 'Logged in' };
15
- }
16
- return {
17
- name: 'Authentication',
18
- status: 'fail',
19
- message: 'Not logged in',
20
- suggestion: 'Run: guild auth login',
21
- };
22
- }
23
- async function checkServer() {
24
- const url = getGuildcoreUrl();
25
- const token = await getAuthToken();
26
- const headers = {};
27
- if (token) {
28
- headers['Authorization'] = `Bearer ${token}`;
29
- }
30
- const start = Date.now();
31
- try {
32
- const response = await axios.get(`${url}/me`, {
33
- timeout: 10000,
34
- headers,
35
- validateStatus: () => true,
36
- });
37
- const elapsed = Date.now() - start;
38
- if (response.status >= 200 && response.status < 300) {
39
- return {
40
- name: 'Server',
41
- status: 'pass',
42
- message: `Connected to ${url} (${elapsed}ms)`,
43
- };
44
- }
45
- if (response.status === 401) {
46
- // Server is up but auth failed — still a successful connectivity check.
47
- // checkAuth handles the auth failure separately.
48
- return {
49
- name: 'Server',
50
- status: 'pass',
51
- message: `Connected to ${url} (${elapsed}ms, auth required)`,
52
- };
53
- }
54
- return {
55
- name: 'Server',
56
- status: 'pass',
57
- message: `Connected to ${url} (${elapsed}ms, HTTP ${response.status})`,
58
- };
59
- }
60
- catch {
61
- return {
62
- name: 'Server',
63
- status: 'fail',
64
- message: `Cannot connect to ${url}`,
65
- suggestion: 'Check your network connection',
66
- };
67
- }
68
- }
69
- async function checkGlobalConfig() {
70
- const config = await loadGlobalConfig();
71
- const configPath = getGlobalConfigPath();
72
- if (config) {
73
- return {
74
- name: 'Global config',
75
- status: 'pass',
76
- message: configPath.replace(process.env.HOME || '', '~'),
77
- };
78
- }
79
- return {
80
- name: 'Global config',
81
- status: 'fail',
82
- message: 'Not found',
83
- suggestion: `Expected at ${configPath.replace(process.env.HOME || '', '~')}`,
84
- };
85
- }
86
- async function checkDefaultWorkspace() {
87
- const config = await loadGlobalConfig();
88
- if (config?.default_workspace) {
89
- const display = config.default_workspace_name || config.default_workspace;
90
- return {
91
- name: 'Default workspace',
92
- status: 'pass',
93
- message: display,
94
- };
95
- }
96
- return {
97
- name: 'Default workspace',
98
- status: 'fail',
99
- message: 'Not configured',
100
- suggestion: 'Run: guild workspace select',
101
- };
102
- }
103
- async function checkLocalConfig() {
104
- const isAgent = await isAgentDirectory();
105
- if (!isAgent) {
106
- return {
107
- name: 'Local config',
108
- status: 'skip',
109
- message: 'Not in an agent directory',
110
- };
111
- }
112
- const config = await loadLocalConfig();
113
- if (config) {
114
- return {
115
- name: 'Local config',
116
- status: 'pass',
117
- message: `Agent: ${config.name || config.agent_id}`,
118
- };
119
- }
120
- return {
121
- name: 'Local config',
122
- status: 'fail',
123
- message: 'guild.json found but could not be parsed',
124
- suggestion: 'Check guild.json for valid JSON',
125
- };
126
- }
127
- async function checkConfigFlags() {
128
- const config = await loadGlobalConfig();
129
- const flags = ['debug', 'json', 'quiet'];
130
- const enabled = flags.filter((f) => config?.[f] === true);
131
- if (enabled.length > 0) {
132
- return {
133
- name: 'Config flags',
134
- status: 'pass',
135
- message: `Enabled: ${enabled.join(', ')}`,
136
- };
137
- }
138
- return {
139
- name: 'Config flags',
140
- status: 'skip',
141
- message: 'No persistent flags set',
142
- };
143
- }
144
- async function checkGit() {
145
- const isAgent = await isAgentDirectory();
146
- if (!isAgent) {
147
- return {
148
- name: 'Git',
149
- status: 'skip',
150
- message: 'Not in an agent directory',
151
- };
152
- }
153
- try {
154
- const { execa } = await import('execa');
155
- await execa('git', ['--version']);
156
- // Check for remote
157
- const { stdout } = await execa('git', ['remote', '-v'], { reject: false });
158
- if (stdout && stdout.includes('origin')) {
159
- return { name: 'Git', status: 'pass', message: 'Installed, remote configured' };
160
- }
161
- return {
162
- name: 'Git',
163
- status: 'fail',
164
- message: 'Installed but no remote configured',
165
- suggestion: 'Run: git remote add origin <url>',
166
- };
167
- }
168
- catch {
169
- return {
170
- name: 'Git',
171
- status: 'fail',
172
- message: 'Git not found',
173
- suggestion: 'Install git: https://git-scm.com',
174
- };
175
- }
176
- }
177
- export function createDoctorCommand() {
178
- const cmd = new Command('doctor');
179
- cmd.description('Check CLI setup and diagnose issues').action(async () => {
180
- const output = createOutputWriter();
181
- const mode = getOutputMode();
182
- const checks = [];
183
- if (mode !== 'json') {
184
- output.progress('\nChecking Guild CLI setup...\n');
185
- }
186
- const runners = [
187
- checkAuth,
188
- checkServer,
189
- checkGlobalConfig,
190
- checkDefaultWorkspace,
191
- checkConfigFlags,
192
- checkLocalConfig,
193
- checkGit,
194
- ];
195
- for (const runner of runners) {
196
- const result = await runner();
197
- checks.push(result);
198
- if (mode !== 'json') {
199
- const icon = result.status === 'pass'
200
- ? chalk.green('✓')
201
- : result.status === 'fail'
202
- ? chalk.red('✗')
203
- : chalk.dim('-');
204
- const nameCol = result.name.padEnd(20);
205
- output.progress(` ${icon} ${chalk.bold(nameCol)} ${result.message}`);
206
- if (result.suggestion) {
207
- output.progress(` ${chalk.dim(result.suggestion)}`);
208
- output.progress('');
209
- }
210
- }
211
- }
212
- const passed = checks.filter((c) => c.status === 'pass').length;
213
- const failed = checks.filter((c) => c.status === 'fail').length;
214
- const skipped = checks.filter((c) => c.status === 'skip').length;
215
- if (mode === 'json') {
216
- output.data({ checks, passed, failed, skipped });
217
- }
218
- else {
219
- output.progress('');
220
- const parts = [];
221
- if (passed > 0)
222
- parts.push(chalk.green(`${passed} passed`));
223
- if (failed > 0)
224
- parts.push(chalk.red(`${failed} failed`));
225
- if (skipped > 0)
226
- parts.push(chalk.dim(`${skipped} skipped`));
227
- output.progress(parts.join(', '));
228
- }
229
- process.exit(failed > 0 ? 1 : 0);
230
- });
231
- return cmd;
232
- }
233
- //# sourceMappingURL=doctor.js.map
@@ -1,76 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import { GuildAPIClient } from '../../lib/api-client.js';
6
- import { getAuthToken } from '../../lib/auth.js';
7
- import { handleAxiosError } from '../../lib/errors.js';
8
- import { getOutputMode } from '../../lib/output-mode.js';
9
- import { createOutputWriter } from '../../lib/output.js';
10
- import { isInteractive } from '../../lib/stdin.js';
11
- export function createIntegrationConnectCommand() {
12
- const cmd = new Command('connect');
13
- cmd
14
- .description('Connect credentials to an integration')
15
- .argument('<id_or_name>', 'Integration ID (UUID) or name in owner~name format (e.g. myorg~my-integration)')
16
- .option('--token <value>', 'API key value (required in non-interactive mode)')
17
- .requiredOption('--owner <id_or_name>', 'Account to own the credential — username, org name, or account ID')
18
- .action(async (identifier, options) => {
19
- const output = createOutputWriter();
20
- try {
21
- const token = await getAuthToken();
22
- if (!token) {
23
- output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
24
- process.exit(1);
25
- }
26
- if (!options.token && !isInteractive()) {
27
- output.error('--token is required in non-interactive mode');
28
- process.exit(1);
29
- }
30
- const client = new GuildAPIClient();
31
- const integration = await client.get(`/integrations/${identifier}`);
32
- if (!integration.auth_config) {
33
- output.error('This integration has no authentication configured.');
34
- process.exit(1);
35
- }
36
- if (integration.auth_config.entity_type !== 'EntIntegrationAuthConfigApiKey') {
37
- output.error('OAuth integrations must be connected via the dashboard.');
38
- process.exit(1);
39
- }
40
- let apiKey = options.token;
41
- if (!apiKey) {
42
- const { default: inquirer } = await import('inquirer');
43
- const answer = await inquirer.prompt([
44
- {
45
- type: 'password',
46
- name: 'apiKey',
47
- message: 'API Key:',
48
- validate: (input) => input.length > 0 || 'API key cannot be empty',
49
- },
50
- ]);
51
- apiKey = answer.apiKey;
52
- }
53
- const params = new URLSearchParams();
54
- params.append('auth_config_id', integration.auth_config.id);
55
- params.append('owner_id', options.owner);
56
- const credential = await client.post(`/credentials/api-key?${params.toString()}`, { tokens: { token: apiKey } });
57
- if (getOutputMode() === 'json') {
58
- output.data(credential);
59
- }
60
- else {
61
- console.log(chalk.green('Connected to ') + chalk.bold(integration.name));
62
- console.log();
63
- console.log(` ${'Credential ID'.padEnd(15)}${credential.id}`);
64
- console.log(` ${'Integration'.padEnd(15)}${integration.owner.name}~${integration.name}`);
65
- console.log(` ${'Owner'.padEnd(15)}${options.owner}`);
66
- }
67
- }
68
- catch (error) {
69
- const formattedError = handleAxiosError(error);
70
- output.error(`Failed to connect: ${formattedError.details}`);
71
- process.exit(1);
72
- }
73
- });
74
- return cmd;
75
- }
76
- //# sourceMappingURL=connect.js.map
@@ -1,298 +0,0 @@
1
- // Copyright 2026 Guild.ai
2
- // SPDX-License-Identifier: Apache-2.0
3
- import { Command } from 'commander';
4
- import chalk from 'chalk';
5
- import { GuildAPIClient } from '../../lib/api-client.js';
6
- import { getAuthToken } from '../../lib/auth.js';
7
- import { handleAxiosError } from '../../lib/errors.js';
8
- import { getOutputMode } from '../../lib/output-mode.js';
9
- import { createOutputWriter } from '../../lib/output.js';
10
- import { resolveOwnerId } from '../../lib/owner-helpers.js';
11
- import { isInteractive } from '../../lib/stdin.js';
12
- function formatCreatedIntegration(integration) {
13
- console.log(chalk.green('Integration created successfully'));
14
- console.log();
15
- console.log(` ${'Name'.padEnd(15)}${integration.name}`);
16
- console.log(` ${'Description'.padEnd(15)}${integration.description || chalk.dim('—')}`);
17
- console.log(` ${'Visibility'.padEnd(15)}${integration.is_public ? 'public' : 'internal'}`);
18
- console.log(` ${'Owner'.padEnd(15)}${integration.owner?.name || chalk.dim('—')}`);
19
- console.log(` ${'Base URL'.padEnd(15)}${integration.protocol_config.base_url}`);
20
- const scheme = integration.auth_config.auth_scheme === 'API_KEY' ? 'API Key' : 'OAuth 2.0';
21
- console.log(` ${'Auth Scheme'.padEnd(15)}${scheme}`);
22
- if (integration.auth_config.token_header_template) {
23
- console.log(` ${'Header'.padEnd(15)}${integration.auth_config.token_header_template}`);
24
- }
25
- if (integration.webhook_config) {
26
- console.log(` ${'Webhooks'.padEnd(15)}Enabled`);
27
- }
28
- else {
29
- console.log(` ${'Webhooks'.padEnd(15)}${chalk.dim('Not configured')}`);
30
- }
31
- }
32
- export function createIntegrationCreateCommand() {
33
- const cmd = new Command('create');
34
- cmd
35
- .description('Create a new integration')
36
- .argument('<name>', 'Integration name')
37
- .option('--description <text>', 'What this integration does')
38
- .option('--base-url <url>', 'Base URL for all API requests')
39
- .option('--owner <account>', 'Owner account name or ID (default: current user)')
40
- .option('--public', 'Make this integration visible to all users')
41
- .option('--auth-scheme <scheme>', 'Authentication scheme: api-key or oauth')
42
- .option('--header-template <template>', 'Header template for API Key auth (default: "X-API-Key: {token}")')
43
- .option('--install-url <url>', 'OAuth authorization endpoint')
44
- .option('--token-url <url>', 'OAuth token exchange endpoint')
45
- .option('--client-id <id>', 'OAuth client ID')
46
- .option('--client-secret <secret>', 'OAuth client secret')
47
- .option('--scopes <scopes>', 'Comma-separated OAuth scopes')
48
- .option('--token-content-type <type>', 'Content-Type for OAuth token request')
49
- .option('--webhook-events <events>', 'Enable webhooks with events as JSON')
50
- .action(async (name, options) => {
51
- const output = createOutputWriter();
52
- try {
53
- const token = await getAuthToken();
54
- if (!token) {
55
- output.error('Not authenticated. Please log in first.', 'Run: guild auth login');
56
- process.exit(1);
57
- }
58
- const client = new GuildAPIClient();
59
- const interactive = isInteractive();
60
- // Resolve owner
61
- const owner = await resolveOwnerId({
62
- ownerFlag: options.owner,
63
- client,
64
- interactive,
65
- });
66
- // Resolve description
67
- let description = options.description;
68
- if (!description && interactive) {
69
- const { default: inquirer } = await import('inquirer');
70
- const answer = await inquirer.prompt([
71
- { type: 'input', name: 'description', message: 'Description:' },
72
- ]);
73
- description = answer.description;
74
- }
75
- // Resolve base URL
76
- let baseUrl = options.baseUrl;
77
- if (!baseUrl && interactive) {
78
- const { default: inquirer } = await import('inquirer');
79
- const answer = await inquirer.prompt([
80
- { type: 'input', name: 'baseUrl', message: 'Base URL:' },
81
- ]);
82
- baseUrl = answer.baseUrl;
83
- }
84
- // Resolve auth scheme
85
- let authScheme = options.authScheme;
86
- if (!authScheme && interactive) {
87
- const { default: inquirer } = await import('inquirer');
88
- const answer = await inquirer.prompt([
89
- {
90
- type: 'list',
91
- name: 'authScheme',
92
- message: 'Select authentication scheme:',
93
- choices: [
94
- {
95
- name: 'API Key - Static token sent in request headers',
96
- value: 'api-key',
97
- },
98
- {
99
- name: 'OAuth 2.0 - User grants access via authorization flow',
100
- value: 'oauth',
101
- },
102
- ],
103
- },
104
- ]);
105
- authScheme = answer.authScheme;
106
- }
107
- // Validate required fields in non-interactive mode
108
- const missing = [];
109
- if (!description)
110
- missing.push('--description <text>');
111
- if (!baseUrl)
112
- missing.push('--base-url <url>');
113
- if (!authScheme)
114
- missing.push('--auth-scheme <scheme>');
115
- if (missing.length > 0) {
116
- output.error(`Error: The following options are required in non-interactive mode:\n ${missing.join('\n ')}`, 'Provide all required options, or run interactively (in a TTY) to be prompted.');
117
- process.exit(1);
118
- }
119
- // Build auth config
120
- let authConfig;
121
- const normalizedScheme = authScheme.toLowerCase();
122
- if (normalizedScheme === 'api-key') {
123
- let headerTemplate = options.headerTemplate || 'X-API-Key: {token}';
124
- if (interactive && !options.headerTemplate) {
125
- const { default: inquirer } = await import('inquirer');
126
- const answer = await inquirer.prompt([
127
- {
128
- type: 'input',
129
- name: 'headerTemplate',
130
- message: 'Header template:',
131
- default: 'X-API-Key: {token}',
132
- },
133
- ]);
134
- headerTemplate = answer.headerTemplate;
135
- }
136
- if (!headerTemplate.includes('{token}')) {
137
- output.error('Error: --header-template must contain {token} placeholder');
138
- process.exit(1);
139
- }
140
- authConfig = {
141
- auth_scheme: 'API_KEY',
142
- token_header_template: headerTemplate,
143
- };
144
- }
145
- else if (normalizedScheme === 'oauth') {
146
- let installUrl = options.installUrl;
147
- let tokenUrl = options.tokenUrl;
148
- let clientId = options.clientId;
149
- let clientSecret = options.clientSecret;
150
- if (interactive) {
151
- const { default: inquirer } = await import('inquirer');
152
- if (!installUrl) {
153
- const a = await inquirer.prompt([
154
- { type: 'input', name: 'val', message: 'Install URL:' },
155
- ]);
156
- installUrl = a.val;
157
- }
158
- if (!tokenUrl) {
159
- const a = await inquirer.prompt([
160
- { type: 'input', name: 'val', message: 'Token URL:' },
161
- ]);
162
- tokenUrl = a.val;
163
- }
164
- if (!clientId) {
165
- const a = await inquirer.prompt([
166
- { type: 'input', name: 'val', message: 'Client ID:' },
167
- ]);
168
- clientId = a.val;
169
- }
170
- if (!clientSecret) {
171
- const a = await inquirer.prompt([
172
- {
173
- type: 'password',
174
- name: 'val',
175
- message: 'Client Secret:',
176
- },
177
- ]);
178
- clientSecret = a.val;
179
- }
180
- }
181
- const oauthMissing = [];
182
- if (!installUrl)
183
- oauthMissing.push('--install-url');
184
- if (!tokenUrl)
185
- oauthMissing.push('--token-url');
186
- if (!clientId)
187
- oauthMissing.push('--client-id');
188
- if (!clientSecret)
189
- oauthMissing.push('--client-secret');
190
- if (oauthMissing.length > 0) {
191
- output.error(`Error: ${oauthMissing.join(', ')}, and --client-secret are required when --auth-scheme is oauth`);
192
- process.exit(1);
193
- }
194
- authConfig = {
195
- auth_scheme: 'OAUTH',
196
- install_url: installUrl,
197
- token_url: tokenUrl,
198
- client_id: clientId,
199
- client_secret: clientSecret,
200
- token_url_content_type: options.tokenContentType || 'application/x-www-form-urlencoded',
201
- };
202
- if (options.scopes) {
203
- authConfig.scopes = options.scopes.split(',').map((s) => s.trim());
204
- }
205
- else if (interactive) {
206
- const { default: inquirer } = await import('inquirer');
207
- const answer = await inquirer.prompt([
208
- {
209
- type: 'input',
210
- name: 'scopes',
211
- message: 'Scopes (comma-separated, optional):',
212
- },
213
- ]);
214
- if (answer.scopes) {
215
- authConfig.scopes = answer.scopes
216
- .split(',')
217
- .map((s) => s.trim())
218
- .filter(Boolean);
219
- }
220
- }
221
- }
222
- else {
223
- output.error(`Error: Invalid auth scheme '${authScheme}'`, 'Valid schemes: api-key, oauth');
224
- process.exit(1);
225
- }
226
- // Build webhook config
227
- let webhookConfig;
228
- if (options.webhookEvents) {
229
- try {
230
- const events = JSON.parse(options.webhookEvents);
231
- webhookConfig = { events };
232
- }
233
- catch {
234
- output.error(`Error: Invalid JSON for --webhook-events: ${options.webhookEvents}`);
235
- process.exit(1);
236
- }
237
- }
238
- else if (interactive) {
239
- const { default: inquirer } = await import('inquirer');
240
- const answer = await inquirer.prompt([
241
- {
242
- type: 'confirm',
243
- name: 'configureWebhooks',
244
- message: 'Configure webhooks?',
245
- default: false,
246
- },
247
- ]);
248
- if (answer.configureWebhooks) {
249
- const eventsAnswer = await inquirer.prompt([
250
- {
251
- type: 'input',
252
- name: 'events',
253
- message: 'Webhook events (JSON):',
254
- },
255
- ]);
256
- if (eventsAnswer.events) {
257
- try {
258
- const events = JSON.parse(eventsAnswer.events);
259
- webhookConfig = { events };
260
- }
261
- catch {
262
- output.error('Error: Invalid JSON for webhook events');
263
- process.exit(1);
264
- }
265
- }
266
- }
267
- }
268
- // Build request body
269
- const body = {
270
- name,
271
- description: description,
272
- is_public: options.public || false,
273
- protocol_config: {
274
- protocol: 'REST',
275
- base_url: baseUrl,
276
- },
277
- auth_config: authConfig,
278
- };
279
- if (webhookConfig) {
280
- body.webhook_config = webhookConfig;
281
- }
282
- const response = await client.post(`/accounts/${owner.name}/integrations`, body);
283
- if (getOutputMode() === 'json') {
284
- output.data(response);
285
- }
286
- else {
287
- formatCreatedIntegration(response);
288
- }
289
- }
290
- catch (error) {
291
- const formattedError = handleAxiosError(error);
292
- output.error(`Failed to create integration: ${formattedError.details}`);
293
- process.exit(1);
294
- }
295
- });
296
- return cmd;
297
- }
298
- //# sourceMappingURL=create.js.map