@firefunc-agent/runner 0.9.34 → 0.9.36
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/README.md +56 -0
- package/dist/api.d.ts +2 -1
- package/dist/brief-file.d.ts +1 -0
- package/dist/brief-file.js +6 -0
- package/dist/build-info.json +2 -2
- package/dist/config.d.ts +1 -0
- package/dist/daemon.js +3 -4
- package/dist/engine-account.js +1 -1
- package/dist/engine-login.js +4 -2
- package/dist/engine-models.js +4 -2
- package/dist/engines/antigravity.d.ts +2 -0
- package/dist/engines/antigravity.js +55 -0
- package/dist/engines/claude.js +12 -0
- package/dist/engines/index.js +4 -2
- package/dist/exec.js +5 -2
- package/dist/firefunc/automations.d.ts +2 -0
- package/dist/firefunc/automations.js +312 -0
- package/dist/firefunc/catalog.js +8 -1
- package/dist/firefunc/machines.d.ts +2 -0
- package/dist/firefunc/machines.js +65 -0
- package/dist/firefunc/main.js +35 -1
- package/dist/firefunc/tasks.js +2 -0
- package/dist/firefunc/webhooks.d.ts +2 -0
- package/dist/firefunc/webhooks.js +78 -0
- package/dist/job.js +28 -4
- package/dist/keep-local.d.ts +1 -0
- package/dist/keep-local.js +6 -1
- package/dist/mcp-login.d.ts +1 -0
- package/dist/mcp-login.js +42 -5
- package/dist/mcp.d.ts +4 -1
- package/dist/mcp.js +61 -6
- package/dist/openrouter.d.ts +15 -0
- package/dist/openrouter.js +39 -0
- package/dist/pool.d.ts +2 -0
- package/dist/pool.js +12 -1
- package/dist/sign-in.d.ts +1 -0
- package/dist/sign-in.js +6 -2
- package/dist/win-shell.d.ts +14 -0
- package/dist/win-shell.js +51 -0
- package/package.json +1 -1
- package/skill/firefunc/SKILL.md +18 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import { bool, str, UsageError } from './args.js';
|
|
2
|
+
import { listIn, resolveProjectId } from './catalog.js';
|
|
3
|
+
import { enc, readInputFile } from './command.js';
|
|
4
|
+
import { Refusal } from './io.js';
|
|
5
|
+
import { printJson, table, text, wrap } from './output.js';
|
|
6
|
+
const MODES = ['live', 'dry', 'test'];
|
|
7
|
+
const FINAL = new Set(['succeeded', 'failed', 'canceled', 'skipped']);
|
|
8
|
+
function problemLines(problems) {
|
|
9
|
+
const list = Array.isArray(problems) ? problems : [];
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const p of list) {
|
|
12
|
+
out.push(...wrap(`${text(p.level)}: ${text(p.text)}`, 78, ' ', ' '));
|
|
13
|
+
if (p.fix)
|
|
14
|
+
out.push(...wrap(`fix: ${text(p.fix)}`, 78, ' ', ' '));
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
function parseJsonFlag(raw, flag) {
|
|
19
|
+
try {
|
|
20
|
+
return JSON.parse(raw);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
throw new Refusal(`--${flag} is not JSON (${e.message}).`, `Write it as a JSON object, for example --${flag} '{"name": "value"}'.`, 'bad_json');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function runLine(r) {
|
|
27
|
+
const err = r.error;
|
|
28
|
+
return `run #${text(r.number)} ${text(r.state)} ${text(r.id)}${err ? ` ${text(err.reason)}` : ''}`;
|
|
29
|
+
}
|
|
30
|
+
async function printRun(ctx, body) {
|
|
31
|
+
const r = body.run ?? body;
|
|
32
|
+
const lines = [runLine(r)];
|
|
33
|
+
const err = r.error;
|
|
34
|
+
if (err?.fix)
|
|
35
|
+
lines.push(...wrap(`fix: ${text(err.fix)}`, 78, ' ', ' '));
|
|
36
|
+
const steps = Array.isArray(body.steps) ? body.steps : [];
|
|
37
|
+
for (const s of steps) {
|
|
38
|
+
const e = s.error;
|
|
39
|
+
lines.push(` ${text(s.nodeId ?? s.key)} ${text(s.state)} ${text(s.name)}${e ? ` ${text(e.reason ?? e.message)}` : ''}`);
|
|
40
|
+
}
|
|
41
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
42
|
+
}
|
|
43
|
+
export const automationCommands = [
|
|
44
|
+
{
|
|
45
|
+
path: ['automations', 'list'],
|
|
46
|
+
summary: 'The workflows and orchestrations in this workspace',
|
|
47
|
+
usage: 'automations list [--project <id or name>]',
|
|
48
|
+
flags: { project: 'string' },
|
|
49
|
+
flagHelp: [['--project <id or name>', "only this project's automations"]],
|
|
50
|
+
async run(ctx) {
|
|
51
|
+
const project = str(ctx.args, 'project');
|
|
52
|
+
const query = project ? { project: await resolveProjectId(ctx, project) } : undefined;
|
|
53
|
+
const body = await ctx.api().get('/api/v1/automations', query);
|
|
54
|
+
if (ctx.json)
|
|
55
|
+
return printJson(ctx.io, body);
|
|
56
|
+
const rows = listIn(body, 'automations');
|
|
57
|
+
if (!rows.length) {
|
|
58
|
+
ctx.io.stdout.write('No automations here yet. Make one: firefunc automations create\n');
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
table(ctx.io, rows, [
|
|
62
|
+
{ head: 'ID', get: (r) => r.id },
|
|
63
|
+
{ head: 'NAME', get: (r) => r.name, max: 40 },
|
|
64
|
+
{ head: 'KIND', get: (r) => r.kind },
|
|
65
|
+
{ head: 'STATUS', get: (r) => r.status },
|
|
66
|
+
{ head: 'PROJECT', get: (r) => r.project?.name ?? 'whole workspace' },
|
|
67
|
+
]);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
path: ['automations', 'templates'],
|
|
72
|
+
summary: 'Automations to start from, and the agents each brings',
|
|
73
|
+
usage: 'automations templates',
|
|
74
|
+
async run(ctx) {
|
|
75
|
+
const body = await ctx.api().get('/api/v1/automations/templates');
|
|
76
|
+
if (ctx.json)
|
|
77
|
+
return printJson(ctx.io, body);
|
|
78
|
+
table(ctx.io, listIn(body, 'templates'), [
|
|
79
|
+
{ head: 'ID', get: (r) => r.id },
|
|
80
|
+
{ head: 'KIND', get: (r) => r.kind },
|
|
81
|
+
{ head: 'NAME', get: (r) => r.name, max: 40 },
|
|
82
|
+
{
|
|
83
|
+
head: 'BRINGS',
|
|
84
|
+
get: (r) => (Array.isArray(r.brings) ? r.brings : []).map((b) => b.name).join(', '),
|
|
85
|
+
max: 50,
|
|
86
|
+
},
|
|
87
|
+
]);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
path: ['automations', 'get'],
|
|
92
|
+
summary: 'One automation: how it starts, its inputs and its problems',
|
|
93
|
+
usage: 'automations get <id>',
|
|
94
|
+
positional: { min: 1, max: 1 },
|
|
95
|
+
async run(ctx) {
|
|
96
|
+
const id = ctx.args.positional[0];
|
|
97
|
+
const body = await ctx.api().get(`/api/v1/automations/${enc(id)}`);
|
|
98
|
+
if (ctx.json)
|
|
99
|
+
return printJson(ctx.io, body);
|
|
100
|
+
const a = body.automation ?? {};
|
|
101
|
+
const lines = [
|
|
102
|
+
`${text(a.name)}`,
|
|
103
|
+
` id: ${text(a.id)}`,
|
|
104
|
+
` kind: ${text(a.kind)}`,
|
|
105
|
+
` status: ${text(a.status)}`,
|
|
106
|
+
];
|
|
107
|
+
const problems = problemLines(body.problems);
|
|
108
|
+
lines.push(problems.length ? ' problems:' : ' problems: none', ...problems);
|
|
109
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: ['automations', 'create'],
|
|
114
|
+
summary: 'Make a workflow or orchestration as a DRAFT (nothing runs until it is published)',
|
|
115
|
+
usage: 'automations create --name <name> (--spec <file.json> | --from-template <id> | --kind workflow|orchestration) [--project <id or name>]',
|
|
116
|
+
flags: {
|
|
117
|
+
name: 'string',
|
|
118
|
+
spec: 'string',
|
|
119
|
+
'from-template': 'string',
|
|
120
|
+
kind: 'string',
|
|
121
|
+
project: 'string',
|
|
122
|
+
},
|
|
123
|
+
flagHelp: [
|
|
124
|
+
['--name <name>', 'what people call it'],
|
|
125
|
+
['--spec <file.json>', 'the whole definition as JSON ("-" for stdin)'],
|
|
126
|
+
[
|
|
127
|
+
'--from-template <id>',
|
|
128
|
+
'start from a template (automations templates); it brings its agents, paused',
|
|
129
|
+
],
|
|
130
|
+
['--kind <kind>', 'an empty workflow or orchestration'],
|
|
131
|
+
['--project <id or name>', 'the project it belongs to; left out: the whole workspace'],
|
|
132
|
+
],
|
|
133
|
+
async run(ctx) {
|
|
134
|
+
const name = str(ctx.args, 'name');
|
|
135
|
+
if (!name)
|
|
136
|
+
throw new UsageError('--name is required.', ctx.command);
|
|
137
|
+
const spec = str(ctx.args, 'spec');
|
|
138
|
+
const fromTemplate = str(ctx.args, 'from-template');
|
|
139
|
+
const kind = str(ctx.args, 'kind');
|
|
140
|
+
if (!spec && !fromTemplate && !kind)
|
|
141
|
+
throw new UsageError('Give --spec, --from-template or --kind.', ctx.command);
|
|
142
|
+
const project = str(ctx.args, 'project');
|
|
143
|
+
const body = {
|
|
144
|
+
name,
|
|
145
|
+
...(project ? { projectId: await resolveProjectId(ctx, project) } : {}),
|
|
146
|
+
...(spec ? { spec: parseJsonFlag(await readInputFile(ctx.io, spec, 'spec'), 'spec') } : {}),
|
|
147
|
+
...(fromTemplate ? { fromTemplate } : {}),
|
|
148
|
+
...(kind ? { kind } : {}),
|
|
149
|
+
};
|
|
150
|
+
const answer = await ctx.api().post('/api/v1/automations', body);
|
|
151
|
+
if (ctx.json)
|
|
152
|
+
return printJson(ctx.io, answer);
|
|
153
|
+
const a = answer.automation ?? {};
|
|
154
|
+
const lines = [`Made "${text(a.name)}" as a draft: ${text(a.id)}`];
|
|
155
|
+
const brought = Array.isArray(answer.brought) ? answer.brought : [];
|
|
156
|
+
for (const b of brought)
|
|
157
|
+
lines.push(` brought ${text(b.name)} (${text(b.how)}, ${text(b.status)})`);
|
|
158
|
+
const problems = problemLines(answer.problems);
|
|
159
|
+
if (problems.length)
|
|
160
|
+
lines.push(' problems before it can be published:', ...problems);
|
|
161
|
+
lines.push(`Next: firefunc automations publish ${text(a.id)}`);
|
|
162
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
path: ['automations', 'check'],
|
|
167
|
+
summary: 'The checks behind Publish, on the saved draft',
|
|
168
|
+
usage: 'automations check <id>',
|
|
169
|
+
positional: { min: 1, max: 1 },
|
|
170
|
+
async run(ctx) {
|
|
171
|
+
const id = ctx.args.positional[0];
|
|
172
|
+
const body = await ctx.api().post(`/api/v1/automations/${enc(id)}/check`, {});
|
|
173
|
+
if (ctx.json)
|
|
174
|
+
return printJson(ctx.io, body);
|
|
175
|
+
const problems = problemLines(body.problems);
|
|
176
|
+
ctx.io.stdout.write(`${problems.length ? problems.join('\n') : 'No problems.'}\n`);
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
path: ['automations', 'publish'],
|
|
181
|
+
summary: 'Publish the draft: from then on its triggers start REAL runs',
|
|
182
|
+
usage: 'automations publish <id> [--note <text>] --yes',
|
|
183
|
+
details: 'Publishing makes it live at once: a tool trigger takes the next real event, a schedule its\n' +
|
|
184
|
+
'next time. It asks for --yes so a script never does it by accident. The answer says where it\n' +
|
|
185
|
+
'went live and names the agents a run would wait at (a template brings its agents paused).',
|
|
186
|
+
positional: { min: 1, max: 1 },
|
|
187
|
+
flags: { note: 'string', yes: 'boolean' },
|
|
188
|
+
flagHelp: [
|
|
189
|
+
['--note <text>', 'what changed, for the version list'],
|
|
190
|
+
['--yes', 'yes, make it live now'],
|
|
191
|
+
],
|
|
192
|
+
async run(ctx) {
|
|
193
|
+
const id = ctx.args.positional[0];
|
|
194
|
+
if (!bool(ctx.args, 'yes')) {
|
|
195
|
+
const a = await ctx.api().get(`/api/v1/automations/${enc(id)}`);
|
|
196
|
+
const auto = a.automation ?? {};
|
|
197
|
+
throw new Refusal(`Publishing "${text(auto.name)}" makes it live at once: its triggers start real runs.`, `Read it first (firefunc automations get ${id}), then run this again with --yes.`, 'needs_yes');
|
|
198
|
+
}
|
|
199
|
+
const note = str(ctx.args, 'note');
|
|
200
|
+
const body = await ctx
|
|
201
|
+
.api()
|
|
202
|
+
.post(`/api/v1/automations/${enc(id)}/publish`, note ? { note } : {});
|
|
203
|
+
if (ctx.json)
|
|
204
|
+
return printJson(ctx.io, body);
|
|
205
|
+
const v = body.version ?? {};
|
|
206
|
+
const lines = [`Published version ${text(v.number)}.`];
|
|
207
|
+
if (body.goesLive)
|
|
208
|
+
lines.push(...wrap(text(body.goesLive), 78, ' ', ' '));
|
|
209
|
+
const held = Array.isArray(body.heldAgents) ? body.heldAgents : [];
|
|
210
|
+
if (held.length)
|
|
211
|
+
lines.push(...wrap(`Runs wait at ${held.map((h) => `${text(h.name)} (${text(h.status)})`).join(', ')} until each is switched on: firefunc agents resume <id>.`, 78, ' ', ' '));
|
|
212
|
+
const tokens = body.webhookTokens ?? {};
|
|
213
|
+
for (const [t, token] of Object.entries(tokens))
|
|
214
|
+
lines.push(` webhook token for ${t} (shown once): ${token}`);
|
|
215
|
+
lines.push(...problemLines(body.warnings));
|
|
216
|
+
ctx.io.stdout.write(`${lines.join('\n')}\n`);
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
path: ['automations', 'run'],
|
|
221
|
+
summary: 'Start a run of the published version by hand',
|
|
222
|
+
usage: 'automations run <id> [--inputs <json>] [--mode live|dry|test] [--watch]',
|
|
223
|
+
positional: { min: 1, max: 1 },
|
|
224
|
+
flags: { inputs: 'string', mode: 'string', watch: 'boolean' },
|
|
225
|
+
flagHelp: [
|
|
226
|
+
['--inputs <json>', 'the run’s inputs by name, as a JSON object'],
|
|
227
|
+
['--mode <mode>', 'live (default); dry starts nothing; test records writes without sending'],
|
|
228
|
+
['--watch', 'follow the run until it ends'],
|
|
229
|
+
],
|
|
230
|
+
async run(ctx) {
|
|
231
|
+
const id = ctx.args.positional[0];
|
|
232
|
+
const mode = str(ctx.args, 'mode');
|
|
233
|
+
if (mode && !MODES.includes(mode))
|
|
234
|
+
throw new UsageError(`--mode is one of ${MODES.join(', ')}.`, ctx.command);
|
|
235
|
+
const inputs = str(ctx.args, 'inputs');
|
|
236
|
+
const started = await ctx.api().post(`/api/v1/automations/${enc(id)}/runs`, {
|
|
237
|
+
...(inputs ? { inputs: parseJsonFlag(inputs, 'inputs') } : {}),
|
|
238
|
+
...(mode ? { mode } : {}),
|
|
239
|
+
});
|
|
240
|
+
const run = started.run ?? {};
|
|
241
|
+
if (!bool(ctx.args, 'watch')) {
|
|
242
|
+
if (ctx.json)
|
|
243
|
+
return printJson(ctx.io, started);
|
|
244
|
+
ctx.io.stdout.write(`Started ${runLine(run)}\nFollow it: firefunc automations run-get ${text(run.id)}\n`);
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
let body = started;
|
|
248
|
+
for (let i = 0; i < 300; i++) {
|
|
249
|
+
body = await ctx.api().get(`/api/v1/automation-runs/${enc(String(run.id))}`);
|
|
250
|
+
const state = String((body.run ?? {}).state ?? '');
|
|
251
|
+
if (FINAL.has(state) || state === 'waiting')
|
|
252
|
+
break;
|
|
253
|
+
await ctx.io.sleep(2000);
|
|
254
|
+
}
|
|
255
|
+
if (ctx.json)
|
|
256
|
+
return printJson(ctx.io, body);
|
|
257
|
+
await printRun(ctx, body);
|
|
258
|
+
const state = String((body.run ?? {}).state ?? '');
|
|
259
|
+
return state === 'failed' ? 1 : 0;
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
path: ['automations', 'runs'],
|
|
264
|
+
summary: "An automation's recent runs",
|
|
265
|
+
usage: 'automations runs <id>',
|
|
266
|
+
positional: { min: 1, max: 1 },
|
|
267
|
+
async run(ctx) {
|
|
268
|
+
const id = ctx.args.positional[0];
|
|
269
|
+
const body = await ctx.api().get(`/api/v1/automations/${enc(id)}/runs`);
|
|
270
|
+
if (ctx.json)
|
|
271
|
+
return printJson(ctx.io, body);
|
|
272
|
+
const rows = listIn(body, 'runs');
|
|
273
|
+
ctx.io.stdout.write(rows.length ? `${rows.map(runLine).join('\n')}\n` : 'No runs yet.\n');
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
path: ['automations', 'retry-from'],
|
|
278
|
+
summary: 'Start an ended run again from one of its steps',
|
|
279
|
+
usage: 'automations retry-from <run id> --step <key>',
|
|
280
|
+
details: 'The steps before it keep their results. The run uses the version published now when that version still has the step, so a fix you published is used. Needs a role that may edit the automation.',
|
|
281
|
+
positional: { min: 1, max: 1 },
|
|
282
|
+
flags: { step: 'string' },
|
|
283
|
+
flagHelp: [['--step <key>', "the step's key, as `automations run-get` lists it"]],
|
|
284
|
+
async run(ctx) {
|
|
285
|
+
const id = ctx.args.positional[0];
|
|
286
|
+
const step = str(ctx.args, 'step');
|
|
287
|
+
if (!step)
|
|
288
|
+
throw new UsageError('--step <key> is required: the step to start from.');
|
|
289
|
+
const body = await ctx.api().post(`/api/v1/automation-runs/${enc(id)}/retry-from`, {
|
|
290
|
+
step,
|
|
291
|
+
});
|
|
292
|
+
if (ctx.json)
|
|
293
|
+
return printJson(ctx.io, body);
|
|
294
|
+
const r = body.run ?? body;
|
|
295
|
+
ctx.io.stdout.write(`Run #${text(r.number)} starts again from ${step}. Follow it: firefunc automations run-get ${text(r.id ?? id)}\n`);
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
path: ['automations', 'run-get'],
|
|
300
|
+
summary: 'One run: its state and each step',
|
|
301
|
+
usage: 'automations run-get <run id>',
|
|
302
|
+
positional: { min: 1, max: 1 },
|
|
303
|
+
async run(ctx) {
|
|
304
|
+
const id = ctx.args.positional[0];
|
|
305
|
+
const body = await ctx.api().get(`/api/v1/automation-runs/${enc(id)}`);
|
|
306
|
+
if (ctx.json)
|
|
307
|
+
return printJson(ctx.io, body);
|
|
308
|
+
await printRun(ctx, body);
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
];
|
|
312
|
+
//# sourceMappingURL=automations.js.map
|
package/dist/firefunc/catalog.js
CHANGED
|
@@ -75,7 +75,7 @@ function printConnections(ctx, body) {
|
|
|
75
75
|
head: 'ACCOUNTS',
|
|
76
76
|
get: (r) => (r.accounts ?? []).map((a) => {
|
|
77
77
|
const where = (a.boundTo ?? []).map((b) => b.projectName).filter(Boolean);
|
|
78
|
-
return `${text(a.label)}${where.length ? ` (${where.join(', ')})` : ''}`;
|
|
78
|
+
return `${text(a.label)}${a.failing ? ' [sign-in failing]' : ''}${where.length ? ` (${where.join(', ')})` : ''}`;
|
|
79
79
|
}),
|
|
80
80
|
max: 45,
|
|
81
81
|
},
|
|
@@ -84,6 +84,13 @@ function printConnections(ctx, body) {
|
|
|
84
84
|
];
|
|
85
85
|
if (tools.length)
|
|
86
86
|
table(io, tools, cols);
|
|
87
|
+
const failing = tools.flatMap((t) => (t.accounts ?? []).filter((a) => a.failing).map((a) => ({ tool: t, a })));
|
|
88
|
+
if (failing.length) {
|
|
89
|
+
io.stdout.write('\nSign-in failing:\n');
|
|
90
|
+
for (const { tool, a } of failing) {
|
|
91
|
+
io.stdout.write(` ${text(tool.label ?? tool.tool)} · ${text(a.label)}${a.failing?.since ? ` (since ${text(a.failing.since).slice(0, 10)})` : ''}: ${text(a.failing?.reason)}\n Fix: ${text(a.failing?.fix)}\n`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
87
94
|
const servers = listIn(body, 'mcpServers');
|
|
88
95
|
if (servers.length) {
|
|
89
96
|
io.stdout.write('\nMCP servers lent to this workspace (grant one by its slug in tool_grants):\n');
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { str } from './args.js';
|
|
2
|
+
import { listIn } from './catalog.js';
|
|
3
|
+
import { enc } from './command.js';
|
|
4
|
+
import { printJson, table, text } from './output.js';
|
|
5
|
+
export const machineCommands = [
|
|
6
|
+
{
|
|
7
|
+
path: ['machines', 'list'],
|
|
8
|
+
summary: 'The machines paired to this workspace: status, OS, labels, engines',
|
|
9
|
+
usage: 'machines list',
|
|
10
|
+
async run(ctx) {
|
|
11
|
+
const body = await ctx.api().get('/api/v1/machines');
|
|
12
|
+
if (ctx.json)
|
|
13
|
+
return printJson(ctx.io, body);
|
|
14
|
+
const rows = listIn(body, 'machines');
|
|
15
|
+
if (!rows.length) {
|
|
16
|
+
ctx.io.stdout.write('No machine is paired yet. Add one in FireFunc: Machines > Add a machine.\n');
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
table(ctx.io, rows, [
|
|
20
|
+
{ head: 'ID', get: (m) => m.id },
|
|
21
|
+
{ head: 'NAME', get: (m) => m.name },
|
|
22
|
+
{ head: 'STATUS', get: (m) => m.status },
|
|
23
|
+
{ head: 'OS', get: (m) => m.os },
|
|
24
|
+
{ head: 'RUNNING', get: (m) => `${text(m.running)}/${text(m.maxParallel)}` },
|
|
25
|
+
{
|
|
26
|
+
head: 'LABELS',
|
|
27
|
+
get: (m) => (Array.isArray(m.labels) ? m.labels : []).join(',') || '-',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
head: 'ENGINES',
|
|
31
|
+
get: (m) => (Array.isArray(m.engines) ? m.engines : [])
|
|
32
|
+
.map((e) => text(e.engine).replace(/_channel$/, ''))
|
|
33
|
+
.join(','),
|
|
34
|
+
},
|
|
35
|
+
]);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
path: ['machines', 'labels'],
|
|
40
|
+
summary: "A machine's labels, or set them",
|
|
41
|
+
usage: 'machines labels <machine id> [--set <label,label,…>]',
|
|
42
|
+
details: 'With --set, the whole list it carries afterwards ("" removes them all); needs workspace:configure and a role that may connect machines. Agents, tasks and steps route to machines by label.',
|
|
43
|
+
positional: { min: 1, max: 1 },
|
|
44
|
+
flags: { set: 'string' },
|
|
45
|
+
flagHelp: [['--set <labels>', 'comma-separated: replaces every label it carries']],
|
|
46
|
+
async run(ctx) {
|
|
47
|
+
const id = ctx.args.positional[0];
|
|
48
|
+
const set = str(ctx.args, 'set');
|
|
49
|
+
const path = `/api/v1/machines/${enc(id)}/labels`;
|
|
50
|
+
const body = set === undefined
|
|
51
|
+
? await ctx.api().get(path)
|
|
52
|
+
: await ctx.api().put(path, {
|
|
53
|
+
labels: set
|
|
54
|
+
.split(',')
|
|
55
|
+
.map((l) => l.trim())
|
|
56
|
+
.filter(Boolean),
|
|
57
|
+
});
|
|
58
|
+
if (ctx.json)
|
|
59
|
+
return printJson(ctx.io, body);
|
|
60
|
+
const labels = Array.isArray(body.labels) ? body.labels : [];
|
|
61
|
+
ctx.io.stdout.write(`${text(body.name)}: ${labels.length ? labels.join(', ') : 'no label'}\n`);
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
//# sourceMappingURL=machines.js.map
|
package/dist/firefunc/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GLOBAL_FLAGS, parseArgs, str, UsageError } from './args.js';
|
|
2
2
|
import { agentCommands } from './agents.js';
|
|
3
3
|
import { authCommands } from './auth.js';
|
|
4
|
+
import { automationCommands } from './automations.js';
|
|
4
5
|
import { catalogCommands } from './catalog.js';
|
|
5
6
|
import { freshAccessToken } from './oauth-login.js';
|
|
6
7
|
import { ApiClient } from './client.js';
|
|
@@ -11,16 +12,32 @@ import { printError } from './output.js';
|
|
|
11
12
|
import { PromptCancelled } from './prompt.js';
|
|
12
13
|
import { skillCommands } from './skill.js';
|
|
13
14
|
import { taskCommands } from './tasks.js';
|
|
15
|
+
import { machineCommands } from './machines.js';
|
|
16
|
+
import { webhookCommands } from './webhooks.js';
|
|
14
17
|
import { CLI_VERSION } from './version.js';
|
|
15
18
|
export const COMMANDS = [
|
|
16
19
|
...authCommands,
|
|
17
20
|
...catalogCommands,
|
|
18
21
|
...agentCommands,
|
|
19
22
|
...taskCommands,
|
|
23
|
+
...automationCommands,
|
|
24
|
+
...machineCommands,
|
|
25
|
+
...webhookCommands,
|
|
20
26
|
...configureCommands,
|
|
21
27
|
...skillCommands,
|
|
22
28
|
];
|
|
23
|
-
const GROUPS = [
|
|
29
|
+
const GROUPS = [
|
|
30
|
+
'templates',
|
|
31
|
+
'projects',
|
|
32
|
+
'connections',
|
|
33
|
+
'skills',
|
|
34
|
+
'agents',
|
|
35
|
+
'tasks',
|
|
36
|
+
'automations',
|
|
37
|
+
'machines',
|
|
38
|
+
'webhooks',
|
|
39
|
+
'skill',
|
|
40
|
+
];
|
|
24
41
|
const SECTIONS = [
|
|
25
42
|
['Sign in', ['login', 'logout', 'whoami']],
|
|
26
43
|
[
|
|
@@ -40,6 +57,23 @@ const SECTIONS = [
|
|
|
40
57
|
],
|
|
41
58
|
],
|
|
42
59
|
['Tasks', ['run', 'tasks list', 'tasks get', 'tasks watch', 'tasks states']],
|
|
60
|
+
[
|
|
61
|
+
'Automations (workflows and orchestrations)',
|
|
62
|
+
[
|
|
63
|
+
'automations list',
|
|
64
|
+
'automations templates',
|
|
65
|
+
'automations get',
|
|
66
|
+
'automations create',
|
|
67
|
+
'automations check',
|
|
68
|
+
'automations publish',
|
|
69
|
+
'automations run',
|
|
70
|
+
'automations runs',
|
|
71
|
+
'automations run-get',
|
|
72
|
+
'automations retry-from',
|
|
73
|
+
],
|
|
74
|
+
],
|
|
75
|
+
['Machines', ['machines list', 'machines labels']],
|
|
76
|
+
['Inbound webhooks', ['webhooks list', 'webhooks create', 'webhooks rotate']],
|
|
43
77
|
[
|
|
44
78
|
'Configure the workspace (writes need workspace:configure)',
|
|
45
79
|
[
|
package/dist/firefunc/tasks.js
CHANGED
|
@@ -81,6 +81,8 @@ function printTask(ctx, t) {
|
|
|
81
81
|
lines.push(` outputs: ${outputs.length}`);
|
|
82
82
|
for (const o of outputs) {
|
|
83
83
|
lines.push(...wrap(outputWords(o), 76, ' - ', ' '));
|
|
84
|
+
if (o.status === 'succeeded' && typeof o.answer === 'string' && o.answer)
|
|
85
|
+
lines.push(...wrap(o.answer, 74, ' answered: ', ' '));
|
|
84
86
|
if (o.status !== 'succeeded' && typeof o.reason === 'string' && o.reason)
|
|
85
87
|
lines.push(...wrap(o.reason, 74, ' why: ', ' '));
|
|
86
88
|
if (o.status !== 'succeeded' && typeof o.fix === 'string' && o.fix)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { str, UsageError } from './args.js';
|
|
2
|
+
import { listIn, resolveProjectId } from './catalog.js';
|
|
3
|
+
import { enc } from './command.js';
|
|
4
|
+
import { printJson, table, text } from './output.js';
|
|
5
|
+
function printToken(ctx, body, what) {
|
|
6
|
+
const h = body.webhook ?? {};
|
|
7
|
+
ctx.io.stdout.write([
|
|
8
|
+
`${what} "${text(h.name)}" (${text(h.id)}).`,
|
|
9
|
+
`Send deliveries to: ${ctx.credentials().apiUrl}${text(h.path)}`,
|
|
10
|
+
`Token (shown this once, keep it): ${text(body.token)}`,
|
|
11
|
+
'Send it as "Authorization: Bearer <token>" or ?token=<token>.',
|
|
12
|
+
].join('\n') + '\n');
|
|
13
|
+
}
|
|
14
|
+
export const webhookCommands = [
|
|
15
|
+
{
|
|
16
|
+
path: ['webhooks', 'list'],
|
|
17
|
+
summary: "The workspace's inbound webhooks",
|
|
18
|
+
usage: 'webhooks list',
|
|
19
|
+
async run(ctx) {
|
|
20
|
+
const body = await ctx.api().get('/api/v1/webhooks');
|
|
21
|
+
if (ctx.json)
|
|
22
|
+
return printJson(ctx.io, body);
|
|
23
|
+
const rows = listIn(body, 'webhooks');
|
|
24
|
+
if (!rows.length) {
|
|
25
|
+
ctx.io.stdout.write('No inbound webhook yet. Make one: firefunc webhooks create\n');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
table(ctx.io, rows, [
|
|
29
|
+
{ head: 'ID', get: (h) => h.id },
|
|
30
|
+
{ head: 'NAME', get: (h) => h.name },
|
|
31
|
+
{ head: 'ON', get: (h) => (h.enabled ? 'yes' : 'no') },
|
|
32
|
+
{ head: 'DELIVERIES', get: (h) => h.receivedCount },
|
|
33
|
+
{ head: 'TOKEN STARTS', get: (h) => `${text(h.tokenPrefix)}…` },
|
|
34
|
+
{ head: 'PATH', get: (h) => h.path, max: 90 },
|
|
35
|
+
]);
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
path: ['webhooks', 'create'],
|
|
40
|
+
summary: 'Make an inbound webhook in a project (prints its token once)',
|
|
41
|
+
usage: 'webhooks create --name <name> --project <id or name> [--vendor <catalogue slug>]',
|
|
42
|
+
flags: { name: 'string', project: 'string', vendor: 'string' },
|
|
43
|
+
flagHelp: [
|
|
44
|
+
['--name <name>', 'what people call it'],
|
|
45
|
+
['--project <id or name>', 'the project its tasks belong to'],
|
|
46
|
+
['--vendor <slug>', "start from a catalogue vendor's mapping (pagerduty, …)"],
|
|
47
|
+
],
|
|
48
|
+
async run(ctx) {
|
|
49
|
+
const name = str(ctx.args, 'name');
|
|
50
|
+
const project = str(ctx.args, 'project');
|
|
51
|
+
if (!name || !project)
|
|
52
|
+
throw new UsageError('--name and --project are both required.');
|
|
53
|
+
const vendor = str(ctx.args, 'vendor');
|
|
54
|
+
const body = await ctx.api().post('/api/v1/webhooks', {
|
|
55
|
+
name,
|
|
56
|
+
projectId: await resolveProjectId(ctx, project),
|
|
57
|
+
...(vendor ? { catalogueSlug: vendor } : {}),
|
|
58
|
+
});
|
|
59
|
+
if (ctx.json)
|
|
60
|
+
return printJson(ctx.io, body);
|
|
61
|
+
printToken(ctx, body, 'Made');
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
path: ['webhooks', 'rotate'],
|
|
66
|
+
summary: 'Give a webhook a new token (the old one stops working)',
|
|
67
|
+
usage: 'webhooks rotate <webhook id>',
|
|
68
|
+
positional: { min: 1, max: 1 },
|
|
69
|
+
async run(ctx) {
|
|
70
|
+
const id = ctx.args.positional[0];
|
|
71
|
+
const body = await ctx.api().post(`/api/v1/webhooks/${enc(id)}/rotate`, {});
|
|
72
|
+
if (ctx.json)
|
|
73
|
+
return printJson(ctx.io, body);
|
|
74
|
+
printToken(ctx, body, 'Rotated');
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
//# sourceMappingURL=webhooks.js.map
|
package/dist/job.js
CHANGED
|
@@ -36,12 +36,13 @@ import { REFERENCE_FOLDER, mergeWritten, writeReferenceFiles, } from './referenc
|
|
|
36
36
|
import { blankSecrets, heldSecretValues, blankSecretsDeep, blankingApi, registerSecretValues, releaseSecretValues, } from './secret-values.js';
|
|
37
37
|
import { claudeApiKeyNow, fallbackKey, startFallback, startKeySpent } from './api-fallback.js';
|
|
38
38
|
import { ENGINE_KEY_VARS, jobSignIn, keySourceOf } from './sign-in.js';
|
|
39
|
+
import { jobClaudeEndpoint } from './openrouter.js';
|
|
39
40
|
import { ACCOUNT_RETRY_FIRST_MS, accountBlock, accountProblemOf, cannotWorkSentence, } from './engine-account.js';
|
|
40
41
|
import { createKeyedMutex, deviceLockDir, ensureDeviceScript, ensureHeavyScript, heavyLockDir, heavySlots, heavyTag, withHeavyLock, } from './locks.js';
|
|
41
42
|
import { getAdapter, stripForeignEngineCreds } from './engines/index.js';
|
|
42
|
-
import { mcpFormatForEngine, prepareMcp } from './mcp.js';
|
|
43
|
+
import { mcpFormatForEngine, mcpServerIdsOf, prepareMcp } from './mcp.js';
|
|
43
44
|
import { continueToFinishBrief, engineRules } from './brief.js';
|
|
44
|
-
import { BRIEF_FOLDER, fenceBrief, prepareBriefFolder } from './brief-file.js';
|
|
45
|
+
import { BRIEF_FOLDER, fenceBrief, prepareBriefFolder, refuseExposedOnWindows, } from './brief-file.js';
|
|
45
46
|
import { prepareReleaseFolder, stageDraftRelease } from './release-draft.js';
|
|
46
47
|
import { limitSentence } from './limit.js';
|
|
47
48
|
import { cannotRunUnattendedSentence, unattendedContext } from './unattended.js';
|
|
@@ -454,6 +455,16 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
454
455
|
if (how.note)
|
|
455
456
|
log(`${job.runId}: signs in with ${how.note}`);
|
|
456
457
|
}
|
|
458
|
+
if (job.claudeEndpoint === 'openrouter') {
|
|
459
|
+
const how = jobClaudeEndpoint(adapter.id, job.claudeEndpoint, cfg, cfg.name ?? hostname());
|
|
460
|
+
if (!how.ok) {
|
|
461
|
+
log(`${job.runId}: ${how.reason}`);
|
|
462
|
+
return await report({ status: 'failed', error: `${how.reason} ${how.fix}` });
|
|
463
|
+
}
|
|
464
|
+
cfg = how.cfg;
|
|
465
|
+
if (how.note)
|
|
466
|
+
log(`${job.runId}: Claude Code sends its requests to ${how.note}`);
|
|
467
|
+
}
|
|
457
468
|
const unattended = adapter.unattendedBlock?.({
|
|
458
469
|
...unattendedContext(cfg, job.permissionMode),
|
|
459
470
|
...opts?.unattended,
|
|
@@ -1355,7 +1366,7 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1355
1366
|
const heavyHelper = heavyLock ? ensureHeavyScript(rdir) : null;
|
|
1356
1367
|
let briefSeq = 0;
|
|
1357
1368
|
let briefDir;
|
|
1358
|
-
const buildInvocation = (c) => fenceBrief(adapter.buildInvocation(c), c.prompt, {
|
|
1369
|
+
const buildInvocation = (c) => refuseExposedOnWindows(fenceBrief(adapter.buildInvocation(c), c.prompt, {
|
|
1359
1370
|
seq: ++briefSeq,
|
|
1360
1371
|
log,
|
|
1361
1372
|
folder: () => {
|
|
@@ -1367,7 +1378,7 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1367
1378
|
}
|
|
1368
1379
|
return briefDir;
|
|
1369
1380
|
},
|
|
1370
|
-
}).
|
|
1381
|
+
}), adapter.displayName);
|
|
1371
1382
|
const slots = heavySlots(cfg.heavySlots);
|
|
1372
1383
|
const deviceHelper = heavyHelper ? ensureDeviceScript(rdir) : null;
|
|
1373
1384
|
const heavily = (fn) => heavyLock
|
|
@@ -1444,6 +1455,7 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1444
1455
|
const isWin = process.platform === 'win32';
|
|
1445
1456
|
if (job.mcpConfig != null) {
|
|
1446
1457
|
const format = mcpFormatForEngine(adapter.id);
|
|
1458
|
+
const dropped = [];
|
|
1447
1459
|
if (format) {
|
|
1448
1460
|
mcp = await prepareMcp({
|
|
1449
1461
|
raw: job.mcpConfig,
|
|
@@ -1453,9 +1465,21 @@ async function runJobBody(job, cfg, api, viewer, opts) {
|
|
|
1453
1465
|
api,
|
|
1454
1466
|
log,
|
|
1455
1467
|
relay: cfg.mcpRelay !== false,
|
|
1468
|
+
onDrop: (id, code) => dropped.push({ id, code }),
|
|
1456
1469
|
});
|
|
1457
1470
|
}
|
|
1471
|
+
else {
|
|
1472
|
+
for (const id of mcpServerIdsOf(job.mcpConfig))
|
|
1473
|
+
dropped.push({ id, code: 'engine_has_no_mcp' });
|
|
1474
|
+
log(`mcp: ${adapter.displayName} has no MCP client this runner can configure, so FireFunc's tools are off for this run. Fix: run this agent on Claude Code, Codex, Gemini, Copilot, OpenCode, Cursor or Antigravity.`);
|
|
1475
|
+
}
|
|
1458
1476
|
log(mcp ? `mcp: ${mcp.logLine}` : 'mcp: no server was injected for this run');
|
|
1477
|
+
await api.event(job.runId, 'mcp_setup', {
|
|
1478
|
+
engine: adapter.id,
|
|
1479
|
+
platform: process.platform,
|
|
1480
|
+
injected: mcp?.serverIds ?? [],
|
|
1481
|
+
dropped: dropped.slice(0, 20),
|
|
1482
|
+
});
|
|
1459
1483
|
}
|
|
1460
1484
|
const temp = makeRunTemp(job.runId);
|
|
1461
1485
|
if (temp) {
|
package/dist/keep-local.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const CODE_NOTE = "code kept on the machine";
|
|
2
2
|
export declare function codeNote(ref: string | null): string;
|
|
3
|
+
export declare const FORMATTED_NOTE = "[formatted text kept on the machine: read it in the run's session log there]";
|
|
3
4
|
export declare function textCarriesSecret(text: string): boolean;
|
|
4
5
|
export declare function stripCode(text: string): string;
|
|
5
6
|
export declare const UNNAMED_COMMAND = "a command";
|