netlify 23.8.1 → 23.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/agents/agents-create.d.ts +12 -0
- package/dist/commands/agents/agents-create.d.ts.map +1 -0
- package/dist/commands/agents/agents-create.js +131 -0
- package/dist/commands/agents/agents-create.js.map +1 -0
- package/dist/commands/agents/agents-list.d.ts +10 -0
- package/dist/commands/agents/agents-list.d.ts.map +1 -0
- package/dist/commands/agents/agents-list.js +115 -0
- package/dist/commands/agents/agents-list.js.map +1 -0
- package/dist/commands/agents/agents-show.d.ts +9 -0
- package/dist/commands/agents/agents-show.d.ts.map +1 -0
- package/dist/commands/agents/agents-show.js +127 -0
- package/dist/commands/agents/agents-show.js.map +1 -0
- package/dist/commands/agents/agents-stop.d.ts +11 -0
- package/dist/commands/agents/agents-stop.d.ts.map +1 -0
- package/dist/commands/agents/agents-stop.js +75 -0
- package/dist/commands/agents/agents-stop.js.map +1 -0
- package/dist/commands/agents/agents.d.ts +3 -0
- package/dist/commands/agents/agents.d.ts.map +1 -0
- package/dist/commands/agents/agents.js +83 -0
- package/dist/commands/agents/agents.js.map +1 -0
- package/dist/commands/agents/constants.d.ts +39 -0
- package/dist/commands/agents/constants.d.ts.map +1 -0
- package/dist/commands/agents/constants.js +29 -0
- package/dist/commands/agents/constants.js.map +1 -0
- package/dist/commands/agents/index.d.ts +2 -0
- package/dist/commands/agents/index.d.ts.map +1 -0
- package/dist/commands/agents/index.js +2 -0
- package/dist/commands/agents/index.js.map +1 -0
- package/dist/commands/agents/types.d.ts +48 -0
- package/dist/commands/agents/types.d.ts.map +1 -0
- package/dist/commands/agents/types.js +2 -0
- package/dist/commands/agents/types.js.map +1 -0
- package/dist/commands/agents/utils.d.ts +8 -0
- package/dist/commands/agents/utils.d.ts.map +1 -0
- package/dist/commands/agents/utils.js +51 -0
- package/dist/commands/agents/utils.js.map +1 -0
- package/dist/commands/database/utils.d.ts.map +1 -1
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +2 -0
- package/dist/commands/main.js.map +1 -1
- package/dist/lib/extensions.d.ts.map +1 -1
- package/dist/lib/extensions.js +0 -1
- package/dist/lib/extensions.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/command-helpers.d.ts +4 -2
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +1 -1
- package/dist/utils/command-helpers.js.map +1 -1
- package/dist/utils/hooks/requires-site-info-with-project.d.ts +8 -0
- package/dist/utils/hooks/requires-site-info-with-project.d.ts.map +1 -0
- package/dist/utils/hooks/requires-site-info-with-project.js +83 -0
- package/dist/utils/hooks/requires-site-info-with-project.js.map +1 -0
- package/dist/utils/init/utils.d.ts.map +1 -1
- package/functions-templates/typescript/hello-world/package-lock.json +6 -6
- package/npm-shrinkwrap.json +153 -171
- package/package.json +6 -6
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OptionValues } from 'commander';
|
|
2
|
+
import type BaseCommand from '../base-command.js';
|
|
3
|
+
import type { AgentRunner } from './types.js';
|
|
4
|
+
interface AgentCreateOptions extends OptionValues {
|
|
5
|
+
prompt?: string;
|
|
6
|
+
agent?: string;
|
|
7
|
+
branch?: string;
|
|
8
|
+
model?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const agentsCreate: (promptArg: string, options: AgentCreateOptions, command: BaseCommand) => Promise<AgentRunner>;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=agents-create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-create.d.ts","sourceRoot":"","sources":["../../../src/commands/agents/agents-create.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAK7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAI7C,UAAU,kBAAmB,SAAQ,YAAY;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,YAAY,GAAU,WAAW,MAAM,EAAE,SAAS,kBAAkB,EAAE,SAAS,WAAW,yBA4JtG,CAAA"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import inquirer from 'inquirer';
|
|
2
|
+
import { chalk, logAndThrowError, log, logJson } from '../../utils/command-helpers.js';
|
|
3
|
+
import { startSpinner, stopSpinner } from '../../lib/spinner.js';
|
|
4
|
+
import { validatePrompt, validateAgent, formatStatus, getAgentName } from './utils.js';
|
|
5
|
+
import { AVAILABLE_AGENTS } from './constants.js';
|
|
6
|
+
export const agentsCreate = async (promptArg, options, command) => {
|
|
7
|
+
const { api, site, siteInfo, apiOpts } = command.netlify;
|
|
8
|
+
await command.authenticate();
|
|
9
|
+
const { prompt, agent: initialAgent, branch: initialBranch, model } = options;
|
|
10
|
+
let finalPrompt;
|
|
11
|
+
let agent = initialAgent;
|
|
12
|
+
let branch = initialBranch;
|
|
13
|
+
const isGitBased = Boolean(siteInfo.build_settings?.repo_branch);
|
|
14
|
+
// Interactive prompt if not provided
|
|
15
|
+
if (!prompt && !promptArg) {
|
|
16
|
+
const { promptInput } = await inquirer.prompt([
|
|
17
|
+
{
|
|
18
|
+
type: 'input',
|
|
19
|
+
name: 'promptInput',
|
|
20
|
+
message: 'What would you like the agent to do?',
|
|
21
|
+
validate: validatePrompt,
|
|
22
|
+
},
|
|
23
|
+
]);
|
|
24
|
+
finalPrompt = promptInput;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
finalPrompt = (promptArg || prompt) ?? '';
|
|
28
|
+
}
|
|
29
|
+
const promptIsValid = validatePrompt(finalPrompt);
|
|
30
|
+
if (promptIsValid !== true) {
|
|
31
|
+
return logAndThrowError(promptIsValid);
|
|
32
|
+
}
|
|
33
|
+
// Agent selection if not provided
|
|
34
|
+
if (!agent) {
|
|
35
|
+
const { agentInput } = await inquirer.prompt([
|
|
36
|
+
{
|
|
37
|
+
type: 'list',
|
|
38
|
+
name: 'agentInput',
|
|
39
|
+
message: 'Which agent would you like to use?',
|
|
40
|
+
choices: AVAILABLE_AGENTS,
|
|
41
|
+
default: 'claude',
|
|
42
|
+
},
|
|
43
|
+
]);
|
|
44
|
+
agent = agentInput;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const agentIsValid = validateAgent(agent);
|
|
48
|
+
if (agentIsValid !== true) {
|
|
49
|
+
return logAndThrowError(agentIsValid);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (isGitBased) {
|
|
53
|
+
if (!branch) {
|
|
54
|
+
const defaultBranch = siteInfo.build_settings?.repo_branch;
|
|
55
|
+
const { branchInput } = await inquirer.prompt([
|
|
56
|
+
{
|
|
57
|
+
type: 'input',
|
|
58
|
+
name: 'branchInput',
|
|
59
|
+
message: 'Which branch would you like to work on?',
|
|
60
|
+
default: defaultBranch,
|
|
61
|
+
validate: (input) => {
|
|
62
|
+
if (!input || input.trim().length === 0) {
|
|
63
|
+
return 'Branch name is required';
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
branch = branchInput.trim();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
branch = undefined;
|
|
74
|
+
}
|
|
75
|
+
const createSpinner = startSpinner({ text: 'Creating agent task...' });
|
|
76
|
+
try {
|
|
77
|
+
// Create the agent runner using the same API format as the React UI
|
|
78
|
+
const createParams = new URLSearchParams();
|
|
79
|
+
createParams.set('site_id', site.id ?? '');
|
|
80
|
+
const response = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners?${createParams.toString()}`, {
|
|
81
|
+
method: 'POST',
|
|
82
|
+
headers: {
|
|
83
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
84
|
+
'Content-Type': 'application/json',
|
|
85
|
+
'User-Agent': apiOpts.userAgent,
|
|
86
|
+
},
|
|
87
|
+
body: JSON.stringify({
|
|
88
|
+
...(branch ? { branch } : {}),
|
|
89
|
+
prompt: finalPrompt,
|
|
90
|
+
agent,
|
|
91
|
+
model,
|
|
92
|
+
}),
|
|
93
|
+
});
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
const errorData = (await response.json().catch(() => ({})));
|
|
96
|
+
throw new Error(errorData.error ?? `HTTP ${response.status.toString()}: ${response.statusText}`);
|
|
97
|
+
}
|
|
98
|
+
const agentRunner = (await response.json());
|
|
99
|
+
stopSpinner({ spinner: createSpinner });
|
|
100
|
+
if (options.json) {
|
|
101
|
+
logJson(agentRunner);
|
|
102
|
+
return agentRunner;
|
|
103
|
+
}
|
|
104
|
+
log(`${chalk.green('✓')} Agent task created successfully!`);
|
|
105
|
+
log(``);
|
|
106
|
+
log(chalk.bold('Details:'));
|
|
107
|
+
log(` Task ID: ${chalk.cyan(agentRunner.id)}`);
|
|
108
|
+
log(` Prompt: ${chalk.dim(finalPrompt)}`);
|
|
109
|
+
log(` Agent: ${chalk.cyan(getAgentName(agent))}${model ? ` (${model})` : ''}`);
|
|
110
|
+
if (isGitBased && branch) {
|
|
111
|
+
log(` Branch: ${chalk.cyan(branch)}`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
log(` Base: ${chalk.cyan('Latest production deployment')}`);
|
|
115
|
+
}
|
|
116
|
+
log(` Status: ${formatStatus(agentRunner.state ?? 'new')}`);
|
|
117
|
+
log(``);
|
|
118
|
+
log(chalk.bold('Monitor progress:'));
|
|
119
|
+
log(` CLI: ${chalk.cyan(`netlify agents:show ${agentRunner.id}`)}`);
|
|
120
|
+
log(` View in browser: ${chalk.blue(`https://app.netlify.com/projects/${siteInfo.name}/agent-runs/${agentRunner.id}`)}`);
|
|
121
|
+
log(``);
|
|
122
|
+
log(chalk.dim('Note: The agent task will run remotely on Netlify infrastructure and may take a few minutes to complete.'));
|
|
123
|
+
return agentRunner;
|
|
124
|
+
}
|
|
125
|
+
catch (error_) {
|
|
126
|
+
const error = error_;
|
|
127
|
+
stopSpinner({ spinner: createSpinner, error: true });
|
|
128
|
+
return logAndThrowError(`Failed to create agent task: ${error.message}`);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=agents-create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-create.js","sourceRoot":"","sources":["../../../src/commands/agents/agents-create.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AASjD,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,SAAiB,EAAE,OAA2B,EAAE,OAAoB,EAAE,EAAE;IACzG,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;IAExD,MAAM,OAAO,CAAC,YAAY,EAAE,CAAA;IAE5B,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,OAAO,CAAA;IAE7E,IAAI,WAAmB,CAAA;IACvB,IAAI,KAAK,GAAG,YAAY,CAAA;IACxB,IAAI,MAAM,GAAG,aAAa,CAAA;IAE1B,MAAM,UAAU,G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AAI,UAAU,IAAI,MAAM,EAAE,CAAC;YACzB,GAAG,CAAC,aAAa,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACxC,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,WAAW,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,EAAE,CAAC,CAAA;QAC9D,CAAC;QACD,GAAG,CAAC,aAAa,YAAY,CAAC,WAAW,CAAC,KAAK,IAAI,KAAK,CAAC,EAAE,CAAC,CAAA;QAC5D,GAAG,CAAC,EAAE,CAAC,CAAA;QACP,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAA;QACpC,GAAG,CAAC,UAAU,KAAK,CAAC,IAAI,CAAC,uBAAuB,WAAW,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAA;QACpE,GAAG,CACD,sBAAsB,KAAK,CAAC,IAAI,CAC9B,oCAAoC,QAAQ,CAAC,IAAI,eAAe,WAAW,CAAC,EAAE,EAAE,CACjF,EAAE,CACJ,CAAA;QACD,GAAG,CAAC,EAAE,CAAC,CAAA;QACP,GAAG,CACD,KAAK,CAAC,GAAG,CACP,0GAA0G,CAC3G,CACF,CAAA;QAED,OAAO,WAAW,CAAA;IACpB,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,MAAM,KAAK,GAAG,MAAe,CAAA;QAE7B,WAAW,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAEpD,OAAO,gBAAgB,CAAC,gCAAgC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IAC1E,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { OptionValues } from 'commander';
|
|
2
|
+
import type BaseCommand from '../base-command.js';
|
|
3
|
+
import type { AgentRunner } from './types.js';
|
|
4
|
+
interface AgentListOptions extends OptionValues {
|
|
5
|
+
status?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const agentsList: (options: AgentListOptions, command: BaseCommand) => Promise<AgentRunner[] | null | undefined>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=agents-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-list.d.ts","sourceRoot":"","sources":["../../../src/commands/agents/agents-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAK7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAGjE,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,UAAU,GAAU,SAAS,gBAAgB,EAAE,SAAS,WAAW,8CAmJ/E,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import AsciiTable from 'ascii-table';
|
|
2
|
+
import { chalk, logAndThrowError, log, logJson } from '../../utils/command-helpers.js';
|
|
3
|
+
import { startSpinner, stopSpinner } from '../../lib/spinner.js';
|
|
4
|
+
import { formatDuration, formatStatus, truncateText, getAgentName } from './utils.js';
|
|
5
|
+
export const agentsList = async (options, command) => {
|
|
6
|
+
const { api, site, siteInfo, apiOpts } = command.netlify;
|
|
7
|
+
await command.authenticate();
|
|
8
|
+
const listSpinner = startSpinner({ text: 'Fetching agent tasks...' });
|
|
9
|
+
try {
|
|
10
|
+
const params = new URLSearchParams();
|
|
11
|
+
params.set('site_id', site.id ?? '');
|
|
12
|
+
params.set('page', '1');
|
|
13
|
+
params.set('per_page', '15');
|
|
14
|
+
if (options.status) {
|
|
15
|
+
params.set('state', options.status);
|
|
16
|
+
}
|
|
17
|
+
const response = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners?${params.toString()}`, {
|
|
18
|
+
method: 'GET',
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
21
|
+
'User-Agent': apiOpts.userAgent,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
const errorData = (await response.json().catch(() => ({})));
|
|
26
|
+
throw new Error(errorData.error ?? `HTTP ${response.status.toString()}: ${response.statusText}`);
|
|
27
|
+
}
|
|
28
|
+
const agentRunners = (await response.json());
|
|
29
|
+
stopSpinner({ spinner: listSpinner });
|
|
30
|
+
if (options.json) {
|
|
31
|
+
logJson(agentRunners);
|
|
32
|
+
return agentRunners;
|
|
33
|
+
}
|
|
34
|
+
if (!agentRunners || agentRunners.length === 0) {
|
|
35
|
+
log(chalk.yellow('No agent tasks found for this site.'));
|
|
36
|
+
log(``);
|
|
37
|
+
log(`Create your first agent task with:`);
|
|
38
|
+
log(` ${chalk.cyan('netlify agents:create')}`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
// Fetch agent info for each runner
|
|
42
|
+
const agentInfo = new Map();
|
|
43
|
+
const agentSpinner = startSpinner({ text: 'Loading agent information...' });
|
|
44
|
+
try {
|
|
45
|
+
// Fetch latest session for each runner in parallel to get agent info
|
|
46
|
+
const sessionPromises = agentRunners.map(async (runner) => {
|
|
47
|
+
try {
|
|
48
|
+
const sessionsResponse = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners/${runner.id}/sessions?page=1&per_page=1`, {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
headers: {
|
|
51
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
52
|
+
'User-Agent': apiOpts.userAgent,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
if (sessionsResponse.ok) {
|
|
56
|
+
const sessions = (await sessionsResponse.json());
|
|
57
|
+
if (sessions && sessions.length > 0 && sessions[0].agent_config) {
|
|
58
|
+
const { agent } = sessions[0].agent_config;
|
|
59
|
+
if (agent) {
|
|
60
|
+
agentInfo.set(runner.id, agent);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Failed to fetch session for this runner, continue without agent info
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
// Wait for all session fetches to complete
|
|
70
|
+
await Promise.allSettled(sessionPromises);
|
|
71
|
+
stopSpinner({ spinner: agentSpinner });
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
// If parallel fetch fails entirely, continue without agent info
|
|
75
|
+
stopSpinner({ spinner: agentSpinner, error: true });
|
|
76
|
+
}
|
|
77
|
+
const isGitBased = Boolean(siteInfo.build_settings?.repo_branch);
|
|
78
|
+
// Create and populate table without colors for proper formatting
|
|
79
|
+
const table = new AsciiTable(`Agent Tasks for ${siteInfo.name}`);
|
|
80
|
+
const baseColumnLabel = isGitBased ? 'BRANCH' : 'BASE';
|
|
81
|
+
table.setHeading('ID', 'STATUS', 'AGENT', 'PROMPT', baseColumnLabel, 'DURATION', 'CREATED');
|
|
82
|
+
agentRunners.forEach((runner) => {
|
|
83
|
+
const baseValue = isGitBased ? truncateText(runner.branch ?? 'unknown', 12) : 'Production';
|
|
84
|
+
table.addRow(runner.id, (runner.state ?? 'unknown').toUpperCase(), getAgentName(agentInfo.get(runner.id) ?? 'unknown'), truncateText(runner.title ?? 'No title', 35), baseValue, runner.done_at ? formatDuration(runner.created_at, runner.done_at) : formatDuration(runner.created_at), new Date(runner.created_at).toLocaleDateString());
|
|
85
|
+
});
|
|
86
|
+
// Apply colors to the table output
|
|
87
|
+
let tableOutput = table.toString();
|
|
88
|
+
// Create unique status mappings to avoid replacement conflicts
|
|
89
|
+
const statusReplacements = new Set();
|
|
90
|
+
agentRunners.forEach((runner) => {
|
|
91
|
+
const status = runner.state ?? 'unknown';
|
|
92
|
+
statusReplacements.add(status);
|
|
93
|
+
});
|
|
94
|
+
// Apply color replacements
|
|
95
|
+
statusReplacements.forEach((status) => {
|
|
96
|
+
const plainStatus = status.toUpperCase();
|
|
97
|
+
const coloredStatus = formatStatus(status);
|
|
98
|
+
// Use word boundary regex to avoid partial matches
|
|
99
|
+
const regex = new RegExp(`\\b${plainStatus}\\b`, 'g');
|
|
100
|
+
tableOutput = tableOutput.replace(regex, coloredStatus);
|
|
101
|
+
});
|
|
102
|
+
log(tableOutput);
|
|
103
|
+
log('');
|
|
104
|
+
log(chalk.dim(`Total: ${agentRunners.length.toString()} agent task(s)`));
|
|
105
|
+
log('');
|
|
106
|
+
log(`${chalk.dim('Use')} ${chalk.cyan('netlify agents:show <id>')} ${chalk.dim('to view details')}`);
|
|
107
|
+
return agentRunners;
|
|
108
|
+
}
|
|
109
|
+
catch (error_) {
|
|
110
|
+
const error = error_;
|
|
111
|
+
stopSpinner({ spinner: listSpinner, error: true });
|
|
112
|
+
return logAndThrowError(`Failed to list agent tasks: ${error.message}`);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=agents-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-list.js","sourceRoot":"","sources":["../../../src/commands/agents/agents-list.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAOrF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,OAAyB,EAAE,OAAoB,EAAE,EAAE;IAClF,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,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AA;YACrD,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAA;QACzD,CAAC,CAAC,CAAA;QAEF,GAAG,CAAC,WAAW,CAAC,CAAA;QAEhB,GAAG,CAAC,EAAE,CAAC,CAAA;QACP,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,YAAY,CAAC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAA;QACxE,GAAG,CAAC,EAAE,CAAC,CAAA;QACP,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,0BAA0B,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;QAEpG,OAAO,YAAY,CAAA;IACrB,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,MAAM,KAAK,GAAG,MAAe,CAAA;QAE7B,WAAW,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;QAElD,OAAO,gBAAgB,CAAC,+BAA+B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACzE,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { OptionValues } from 'commander';
|
|
2
|
+
import type BaseCommand from '../base-command.js';
|
|
3
|
+
import type { AgentRunner } from './types.js';
|
|
4
|
+
interface AgentShowOptions extends OptionValues {
|
|
5
|
+
json?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const agentsShow: (id: string, options: AgentShowOptions, command: BaseCommand) => Promise<AgentRunner>;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=agents-show.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-show.d.ts","sourceRoot":"","sources":["../../../src/commands/agents/agents-show.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAI7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAsB,MAAM,YAAY,CAAA;AAGjE,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,UAAU,GAAU,IAAI,MAAM,EAAE,SAAS,gBAAgB,EAAE,SAAS,WAAW,yBA+J3F,CAAA"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { chalk, logAndThrowError, log, logJson } from '../../utils/command-helpers.js';
|
|
2
|
+
import { startSpinner, stopSpinner } from '../../lib/spinner.js';
|
|
3
|
+
import { formatDate, formatDuration, formatStatus, getAgentName } from './utils.js';
|
|
4
|
+
export const agentsShow = async (id, options, command) => {
|
|
5
|
+
const { api, site, siteInfo, apiOpts } = command.netlify;
|
|
6
|
+
await command.authenticate();
|
|
7
|
+
if (!id) {
|
|
8
|
+
return logAndThrowError('Agent task ID is required');
|
|
9
|
+
}
|
|
10
|
+
const showSpinner = startSpinner({ text: 'Fetching agent task details...' });
|
|
11
|
+
try {
|
|
12
|
+
const response = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners/${id}`, {
|
|
13
|
+
method: 'GET',
|
|
14
|
+
headers: {
|
|
15
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
16
|
+
'User-Agent': apiOpts.userAgent,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
if (!response.ok) {
|
|
20
|
+
const errorData = (await response.json().catch(() => ({})));
|
|
21
|
+
throw new Error(errorData.error ?? `HTTP ${response.status.toString()}: ${response.statusText}`);
|
|
22
|
+
}
|
|
23
|
+
const agentRunner = (await response.json());
|
|
24
|
+
stopSpinner({ spinner: showSpinner });
|
|
25
|
+
if (options.json) {
|
|
26
|
+
logJson(agentRunner);
|
|
27
|
+
return agentRunner;
|
|
28
|
+
}
|
|
29
|
+
// Display detailed information
|
|
30
|
+
log(chalk.bold('Agent Task Details'));
|
|
31
|
+
log(``);
|
|
32
|
+
log(chalk.bold('Basic Information:'));
|
|
33
|
+
log(` Task ID: ${chalk.cyan(agentRunner.id)}`);
|
|
34
|
+
log(` Status: ${formatStatus(agentRunner.state ?? 'unknown')}`);
|
|
35
|
+
log(` Site: ${chalk.cyan(siteInfo.name)} (${site.id ?? ''})`);
|
|
36
|
+
if (agentRunner.user) {
|
|
37
|
+
log(` Created by: ${agentRunner.user.full_name ?? 'Anonymous'}`);
|
|
38
|
+
}
|
|
39
|
+
// Fetch sessions to get agent information
|
|
40
|
+
let sessions;
|
|
41
|
+
try {
|
|
42
|
+
const sessionsResponse = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners/${id}/sessions?page=1&per_page=5`, {
|
|
43
|
+
method: 'GET',
|
|
44
|
+
headers: {
|
|
45
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
46
|
+
'User-Agent': apiOpts.userAgent,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (sessionsResponse.ok) {
|
|
50
|
+
sessions = (await sessionsResponse.json());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// Sessions fetch failed, but continue without session data
|
|
55
|
+
}
|
|
56
|
+
log(``);
|
|
57
|
+
log(chalk.bold('Configuration:'));
|
|
58
|
+
// Display agent information from latest session
|
|
59
|
+
if (sessions && sessions.length > 0) {
|
|
60
|
+
const latestSession = sessions[0];
|
|
61
|
+
if (latestSession.agent_config) {
|
|
62
|
+
const { agent, model } = latestSession.agent_config;
|
|
63
|
+
if (agent) {
|
|
64
|
+
log(` Agent: ${chalk.cyan(getAgentName(agent))}`);
|
|
65
|
+
}
|
|
66
|
+
if (model) {
|
|
67
|
+
log(` Model: ${chalk.cyan(model)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const isGitBased = Boolean(siteInfo.build_settings?.repo_branch);
|
|
72
|
+
if (isGitBased) {
|
|
73
|
+
log(` Branch: ${chalk.cyan(agentRunner.branch ?? 'unknown')}`);
|
|
74
|
+
if (agentRunner.result_branch) {
|
|
75
|
+
log(` Result Branch: ${chalk.green(agentRunner.result_branch)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
log(` Base: ${chalk.cyan('Latest production deployment')}`);
|
|
80
|
+
}
|
|
81
|
+
log(``);
|
|
82
|
+
log(chalk.bold('Task:'));
|
|
83
|
+
log(` Prompt: ${chalk.dim(agentRunner.title ?? 'No title')}`);
|
|
84
|
+
if (agentRunner.current_task) {
|
|
85
|
+
log(` Current Task: ${chalk.yellow(agentRunner.current_task)}`);
|
|
86
|
+
}
|
|
87
|
+
log(``);
|
|
88
|
+
log(chalk.bold('Timeline:'));
|
|
89
|
+
log(` Created: ${formatDate(agentRunner.created_at)}`);
|
|
90
|
+
log(` Updated: ${formatDate(agentRunner.updated_at)}`);
|
|
91
|
+
if (agentRunner.done_at) {
|
|
92
|
+
log(` Completed: ${formatDate(agentRunner.done_at)}`);
|
|
93
|
+
log(` Duration: ${formatDuration(agentRunner.created_at, agentRunner.done_at)}`);
|
|
94
|
+
}
|
|
95
|
+
else if (agentRunner.state === 'running') {
|
|
96
|
+
log(` Running for: ${formatDuration(agentRunner.created_at)}`);
|
|
97
|
+
}
|
|
98
|
+
// Show recent runs if available
|
|
99
|
+
if (sessions && sessions.length > 0) {
|
|
100
|
+
log(``);
|
|
101
|
+
log(chalk.bold('Recent Runs:'));
|
|
102
|
+
sessions.slice(0, 3).forEach((session, index) => {
|
|
103
|
+
log(` ${(index + 1).toString()}. ${formatStatus(session.state)} - ${session.title ?? 'No title'}`);
|
|
104
|
+
if (session.result && session.state === 'done') {
|
|
105
|
+
const resultPreview = session.result.length > 100 ? session.result.substring(0, 100) + '...' : session.result;
|
|
106
|
+
log(` ${chalk.dim(resultPreview)}`);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
if (sessions.length > 3) {
|
|
110
|
+
log(` ${chalk.dim(`... and ${(sessions.length - 3).toString()} more runs`)}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
log(``);
|
|
114
|
+
log(chalk.bold('Actions:'));
|
|
115
|
+
if (agentRunner.state === 'running' || agentRunner.state === 'new') {
|
|
116
|
+
log(` Stop: ${chalk.cyan(`netlify agents:stop ${agentRunner.id}`)}`);
|
|
117
|
+
}
|
|
118
|
+
log(` View in browser: ${chalk.blue(`https://app.netlify.com/projects/${siteInfo.name}/agent-runs/${agentRunner.id}`)}`);
|
|
119
|
+
return agentRunner;
|
|
120
|
+
}
|
|
121
|
+
catch (error_) {
|
|
122
|
+
const error = error_;
|
|
123
|
+
stopSpinner({ spinner: showSpinner, error: true });
|
|
124
|
+
return logAndThrowError(`Failed to show agent task: ${error.message}`);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=agents-show.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-show.js","sourceRoot":"","sources":["../../../src/commands/agents/agents-show.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAMnF,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAU,EAAE,OAAyB,EAAE,OAAoB,EAAE,EAAE;IAC9F,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,CAAA;IAExD,MAAM,OAAO,CAAC,YAAY,EAAE,CAA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8B,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IACxE,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OptionValues } from 'commander';
|
|
2
|
+
import type BaseCommand from '../base-command.js';
|
|
3
|
+
import type { AgentRunner } from './types.js';
|
|
4
|
+
interface AgentStopOptions extends OptionValues {
|
|
5
|
+
json?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const agentsStop: (id: string, options: AgentStopOptions, command: BaseCommand) => Promise<AgentRunner | {
|
|
8
|
+
success: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=agents-stop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-stop.d.ts","sourceRoot":"","sources":["../../../src/commands/agents/agents-stop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAI7C,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAG7C,UAAU,gBAAiB,SAAQ,YAAY;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,eAAO,MAAM,UAAU,GAAU,IAAI,MAAM,EAAE,SAAS,gBAAgB,EAAE,SAAS,WAAW;;EA8F3F,CAAA"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { chalk, logAndThrowError, log, logJson } from '../../utils/command-helpers.js';
|
|
2
|
+
import { startSpinner, stopSpinner } from '../../lib/spinner.js';
|
|
3
|
+
import { formatStatus } from './utils.js';
|
|
4
|
+
export const agentsStop = async (id, options, command) => {
|
|
5
|
+
const { api, apiOpts } = command.netlify;
|
|
6
|
+
await command.authenticate();
|
|
7
|
+
if (!id) {
|
|
8
|
+
return logAndThrowError('Agent task ID is required');
|
|
9
|
+
}
|
|
10
|
+
const statusSpinner = startSpinner({ text: 'Checking agent task status...' });
|
|
11
|
+
try {
|
|
12
|
+
// First check if the agent runner exists and is stoppable
|
|
13
|
+
const statusResponse = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners/${id}`, {
|
|
14
|
+
method: 'GET',
|
|
15
|
+
headers: {
|
|
16
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
17
|
+
'User-Agent': apiOpts.userAgent,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
if (!statusResponse.ok) {
|
|
21
|
+
const errorData = (await statusResponse.json().catch(() => ({})));
|
|
22
|
+
throw new Error(errorData.error ?? `HTTP ${statusResponse.status.toString()}: ${statusResponse.statusText}`);
|
|
23
|
+
}
|
|
24
|
+
const agentRunner = (await statusResponse.json());
|
|
25
|
+
stopSpinner({ spinner: statusSpinner });
|
|
26
|
+
// Check if agent task can be stopped
|
|
27
|
+
if (agentRunner.state === 'done') {
|
|
28
|
+
log(chalk.yellow('Agent task is already completed.'));
|
|
29
|
+
return agentRunner;
|
|
30
|
+
}
|
|
31
|
+
if (agentRunner.state === 'cancelled') {
|
|
32
|
+
log(chalk.yellow('Agent task is already cancelled.'));
|
|
33
|
+
return agentRunner;
|
|
34
|
+
}
|
|
35
|
+
if (agentRunner.state === 'error') {
|
|
36
|
+
log(chalk.yellow('Agent task has already errored.'));
|
|
37
|
+
return agentRunner;
|
|
38
|
+
}
|
|
39
|
+
// Stop the agent task
|
|
40
|
+
const stopSpinnerInstance = startSpinner({ text: 'Stopping agent task...' });
|
|
41
|
+
const response = await fetch(`${apiOpts.scheme ?? 'https'}://${apiOpts.host ?? api.host}/api/v1/agent_runners/${id}`, {
|
|
42
|
+
method: 'DELETE',
|
|
43
|
+
headers: {
|
|
44
|
+
Authorization: `Bearer ${api.accessToken ?? ''}`,
|
|
45
|
+
'User-Agent': apiOpts.userAgent,
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
stopSpinner({ spinner: stopSpinnerInstance });
|
|
49
|
+
if (!response.ok) {
|
|
50
|
+
const errorData = (await response.json().catch(() => ({})));
|
|
51
|
+
throw new Error(errorData.error ?? `HTTP ${response.status.toString()}: ${response.statusText}`);
|
|
52
|
+
}
|
|
53
|
+
// Success case, 202 with empty body
|
|
54
|
+
const result = { success: true };
|
|
55
|
+
if (options.json) {
|
|
56
|
+
logJson(result);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
log(`${chalk.green('✓')} Agent task stopped successfully!`);
|
|
60
|
+
log(``);
|
|
61
|
+
log(chalk.bold('Details:'));
|
|
62
|
+
log(` Task ID: ${chalk.cyan(id)}`);
|
|
63
|
+
log(` Previous Status: ${formatStatus(agentRunner.state ?? 'unknown')}`);
|
|
64
|
+
log(` New Status: ${formatStatus('cancelled')}`);
|
|
65
|
+
log(``);
|
|
66
|
+
log(chalk.dim('The agent task has been stopped and will not continue processing.'));
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
catch (error_) {
|
|
70
|
+
const error = error_;
|
|
71
|
+
stopSpinner({ spinner: statusSpinner, error: true });
|
|
72
|
+
return logAndThrowError(`Failed to stop agent task: ${error.message}`);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=agents-stop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents-stop.js","sourceRoot":"","sources":["../../../src/commands/agents/agents-stop.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAA;AACtF,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAMzC,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,EAAE,EAAU,EAAE,OAAyB,EAAE,OAAoB,EAAE,EAAE;IAC9F,MAAM,EAAE,GAAG,EAAE,OAAO,E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