@faable/faable 4.50.0 → 4.51.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.
- package/dist/api/FaableApi.js +7 -2
- package/dist/commands/deploy/inspect/cancel.js +2 -2
- package/dist/commands/deploy/inspect/inspect.js +2 -2
- package/dist/commands/deploy/inspect/list.js +20 -3
- package/dist/commands/deploy/inspect/logs.js +2 -2
- package/dist/commands/deploy/inspect/redeploy.js +2 -2
- package/dist/commands/deploy/resolve_app_id.js +16 -2
- package/dist/mcp/tools.js +28 -5
- package/package.json +1 -1
package/dist/api/FaableApi.js
CHANGED
|
@@ -174,9 +174,14 @@ class FaableApi {
|
|
|
174
174
|
// One page of apps, scoped to `project` (default: the active project).
|
|
175
175
|
// `null` = unscoped. The api filters by the header, so an admin session
|
|
176
176
|
// doesn't page through the whole platform.
|
|
177
|
-
|
|
177
|
+
// `latest`: each app with its newest deployment, serving or not
|
|
178
|
+
// (`?expand=latest_deployment`, api ≥ the release that added it).
|
|
179
|
+
async listApps(params, project = this.project ?? null, { latest = false } = {}) {
|
|
178
180
|
return data(this.client.get(`/app`, {
|
|
179
|
-
params:
|
|
181
|
+
params: {
|
|
182
|
+
...page_params(params),
|
|
183
|
+
...(latest ? { expand: 'latest_deployment' } : {})
|
|
184
|
+
},
|
|
180
185
|
...(project ? { headers: projectHeader(project) } : {})
|
|
181
186
|
}));
|
|
182
187
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { requireApi } from '../../../api/context.js';
|
|
2
2
|
import { print_noop, print_json, json_option } from '../../../lib/listing.js';
|
|
3
3
|
import { log } from '../../../log.js';
|
|
4
|
-
import {
|
|
4
|
+
import { resolve_app_for_deployment } from '../resolve_app_id.js';
|
|
5
5
|
|
|
6
6
|
// Mirrors CANCELABLE_PHASES in the api (deployment/api/cancel.ts). Used only
|
|
7
7
|
// to pick a default target; the api is the one that enforces it, so a phase
|
|
@@ -24,7 +24,7 @@ const cancel = {
|
|
|
24
24
|
.showHelpOnFail(false),
|
|
25
25
|
handler: async (args) => {
|
|
26
26
|
const ctx = await requireApi();
|
|
27
|
-
const app_id = await
|
|
27
|
+
const app_id = await resolve_app_for_deployment(args.app, args.deployment, ctx.appId, ctx.api);
|
|
28
28
|
const app = await ctx.api.getApp(app_id);
|
|
29
29
|
let deployment_id = args.deployment;
|
|
30
30
|
if (!deployment_id) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { requireApi } from '../../../api/context.js';
|
|
2
2
|
import { log } from '../../../log.js';
|
|
3
|
-
import {
|
|
3
|
+
import { resolve_app_for_deployment } from '../resolve_app_id.js';
|
|
4
4
|
import { deployment_detail } from './detail.js';
|
|
5
5
|
|
|
6
6
|
const inspect = {
|
|
@@ -26,7 +26,7 @@ const inspect = {
|
|
|
26
26
|
.showHelpOnFail(false),
|
|
27
27
|
handler: async (args) => {
|
|
28
28
|
const ctx = await requireApi();
|
|
29
|
-
const app_id = await
|
|
29
|
+
const app_id = await resolve_app_for_deployment(args.app, args.deployment, ctx.appId, ctx.api);
|
|
30
30
|
const app = await ctx.api.getApp(app_id);
|
|
31
31
|
let deployment_id = args.deployment;
|
|
32
32
|
if (!deployment_id) {
|
|
@@ -7,7 +7,14 @@ import { phase_badge } from './format.js';
|
|
|
7
7
|
const apps_list = {
|
|
8
8
|
command: 'list',
|
|
9
9
|
describe: 'List the apps of the active project',
|
|
10
|
-
builder: yargs => list_options(yargs)
|
|
10
|
+
builder: yargs => list_options(yargs)
|
|
11
|
+
.option('latest', {
|
|
12
|
+
type: 'boolean',
|
|
13
|
+
default: false,
|
|
14
|
+
description: "Also each app's newest deployment, serving or not (`latest_deployment` with --json): which apps' last deploy failed, in one call"
|
|
15
|
+
})
|
|
16
|
+
.example("$0 deploy apps list --latest --json | jq -r '.data[] | select(.latest_deployment.status.phase == \"BUILD_ERROR\") | .name'", 'The apps whose last deploy failed to build')
|
|
17
|
+
.showHelpOnFail(false),
|
|
11
18
|
handler: async (args) => {
|
|
12
19
|
const ctx = await requireApi();
|
|
13
20
|
// Scoped to the active project when there is one (--project,
|
|
@@ -15,7 +22,7 @@ const apps_list = {
|
|
|
15
22
|
// which the api only allows a token with a global scope. Anyone else gets
|
|
16
23
|
// `team_or_scope_required`: then, like `whoami`, the only project they
|
|
17
24
|
// belong to, or an error that says how to pick one (backlog §374).
|
|
18
|
-
const list = () => fetch_page(p => ctx.api.listApps(p), args);
|
|
25
|
+
const list = () => fetch_page(p => ctx.api.listApps(p, undefined, { latest: args.latest }), args);
|
|
19
26
|
let page;
|
|
20
27
|
try {
|
|
21
28
|
page = await list();
|
|
@@ -36,7 +43,17 @@ const apps_list = {
|
|
|
36
43
|
log.info(`📦 ${page.data.length} app(s)${scope}:`);
|
|
37
44
|
const width = Math.max(...page.data.map(a => a.name.length));
|
|
38
45
|
for (const app of page.data) {
|
|
39
|
-
|
|
46
|
+
// The newest deployment, when asked for and when it is not what serves:
|
|
47
|
+
// a failed build behind a live older version.
|
|
48
|
+
const latest = app.latest_deployment;
|
|
49
|
+
const last = args.latest && latest
|
|
50
|
+
? latest.id === app.status?.deployment
|
|
51
|
+
? ' last deploy: live'
|
|
52
|
+
: ` last deploy: ${latest.status?.phase ?? '?'} (${latest.id})`
|
|
53
|
+
: args.latest
|
|
54
|
+
? ' last deploy: none'
|
|
55
|
+
: '';
|
|
56
|
+
print(` ${app.name.padEnd(width)} ${phase_badge(app.status?.phase)} ${app.id} https://${app.url}${last}`);
|
|
40
57
|
}
|
|
41
58
|
const hint = more_hint(page);
|
|
42
59
|
if (hint)
|
|
@@ -3,7 +3,7 @@ import { CliError } from '../../../lib/errors.js';
|
|
|
3
3
|
import { print_json, as_list, json_option } from '../../../lib/listing.js';
|
|
4
4
|
import { log } from '../../../log.js';
|
|
5
5
|
import { follow_remote_build } from '../remote/follow.js';
|
|
6
|
-
import {
|
|
6
|
+
import { resolve_app_for_deployment } from '../resolve_app_id.js';
|
|
7
7
|
import { tail_lines, log_entries, format_log_lines } from './format.js';
|
|
8
8
|
|
|
9
9
|
// Phases where the build is still producing output; anything else is a frozen
|
|
@@ -58,7 +58,7 @@ const logs = {
|
|
|
58
58
|
throw new CliError('usage', '--tail must be a positive integer');
|
|
59
59
|
}
|
|
60
60
|
const ctx = await requireApi();
|
|
61
|
-
const app_id = await
|
|
61
|
+
const app_id = await resolve_app_for_deployment(args.app, args.deployment, ctx.appId, ctx.api);
|
|
62
62
|
const app = await ctx.api.getApp(app_id);
|
|
63
63
|
if (args.build) {
|
|
64
64
|
// Build output lives on the deployment. Default to the newest one that
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { requireApi } from '../../../api/context.js';
|
|
2
2
|
import { print_noop, print_json, json_option } from '../../../lib/listing.js';
|
|
3
3
|
import { log } from '../../../log.js';
|
|
4
|
-
import {
|
|
4
|
+
import { resolve_app_for_deployment } from '../resolve_app_id.js';
|
|
5
5
|
|
|
6
6
|
const FAILED_PHASES = new Set(['ERROR', 'BUILD_ERROR']);
|
|
7
7
|
const redeploy = {
|
|
@@ -21,7 +21,7 @@ const redeploy = {
|
|
|
21
21
|
.showHelpOnFail(false),
|
|
22
22
|
handler: async (args) => {
|
|
23
23
|
const ctx = await requireApi();
|
|
24
|
-
const app_id = await
|
|
24
|
+
const app_id = await resolve_app_for_deployment(args.app, args.deployment, ctx.appId, ctx.api);
|
|
25
25
|
const app = await ctx.api.getApp(app_id);
|
|
26
26
|
let deployment_id = args.deployment;
|
|
27
27
|
if (!deployment_id) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { requireProject } from '../../api/project.js';
|
|
2
2
|
import { Configuration } from '../../lib/Configuration.js';
|
|
3
3
|
import { CliError } from '../../lib/errors.js';
|
|
4
|
+
import { getGitRemoteUrl } from '../../lib/git_remote.js';
|
|
4
5
|
import { is_non_interactive } from '../../lib/interactive.js';
|
|
5
6
|
import { fetch_page } from '../../lib/listing.js';
|
|
6
|
-
import { getGitRemoteUrl } from '../../lib/git_remote.js';
|
|
7
7
|
import { log } from '../../log.js';
|
|
8
8
|
|
|
9
9
|
// --app takes an id, a name or a slug. An id (`app_…`) is used as-is — the
|
|
@@ -82,5 +82,19 @@ const resolve_app_id = async (explicit, ctxAppId, api, workdir = process.cwd())
|
|
|
82
82
|
? 'Pass the app with --app <app_id> (non-interactive mode never infers it from the working directory).'
|
|
83
83
|
: 'No app linked to this repository. Link it from the dashboard (or run "faable deploy link"), or pass one with --app <app_id>.');
|
|
84
84
|
};
|
|
85
|
+
// The app of a command that names one deployment (`inspect`, `logs --build
|
|
86
|
+
// -d`, `redeploy`, `cancel`): a deployment id is globally unique and says
|
|
87
|
+
// whose it is, so without --app the app is the deployment's own — not the
|
|
88
|
+
// linked one, and no app_required. With --app the usual resolution applies,
|
|
89
|
+
// and the caller still checks the two agree. Measured in §555 F0: agents
|
|
90
|
+
// passed a deployment id and paid an extra round trip to learn --app.
|
|
91
|
+
const resolve_app_for_deployment = async (app_ref, deployment_id, linked, api) => {
|
|
92
|
+
if (deployment_id && !app_ref) {
|
|
93
|
+
const deployment = await api.getDeployment(deployment_id);
|
|
94
|
+
if (deployment?.app_id)
|
|
95
|
+
return deployment.app_id;
|
|
96
|
+
}
|
|
97
|
+
return resolve_app_id(app_ref, linked, api);
|
|
98
|
+
};
|
|
85
99
|
|
|
86
|
-
export { find_app_id, resolve_app_id, resolve_app_ref };
|
|
100
|
+
export { find_app_id, resolve_app_for_deployment, resolve_app_id, resolve_app_ref };
|
package/dist/mcp/tools.js
CHANGED
|
@@ -233,18 +233,41 @@ const TOOLS = [
|
|
|
233
233
|
{
|
|
234
234
|
name: 'list_apps',
|
|
235
235
|
title: 'List apps',
|
|
236
|
-
description:
|
|
237
|
-
input: {
|
|
236
|
+
description: "The apps of a project, with their live phase, URL and linked repository. Start here to find the app the user means. With latest, also each app's newest deployment (serving or not): which apps' last deploy failed, in one call.",
|
|
237
|
+
input: {
|
|
238
|
+
project,
|
|
239
|
+
cursor,
|
|
240
|
+
latest: z
|
|
241
|
+
.boolean()
|
|
242
|
+
.optional()
|
|
243
|
+
.describe("Also each app's newest deployment — id, phase, when — even when an older one is what serves")
|
|
244
|
+
},
|
|
238
245
|
command: ['deploy', 'apps', 'list'],
|
|
239
246
|
flags: a => [
|
|
240
247
|
'--limit',
|
|
241
248
|
'100',
|
|
242
249
|
...scope(a),
|
|
243
|
-
...opt('--starting-after', a.cursor)
|
|
250
|
+
...opt('--starting-after', a.cursor),
|
|
251
|
+
...(a.latest ? ['--latest'] : [])
|
|
244
252
|
],
|
|
245
|
-
|
|
253
|
+
// No failure message: that text is the deployer's (get_deployment).
|
|
254
|
+
shape: page((a) => ({
|
|
255
|
+
...app_row(a),
|
|
256
|
+
...(a.latest_deployment !== undefined
|
|
257
|
+
? {
|
|
258
|
+
latest_deployment: a.latest_deployment
|
|
259
|
+
? {
|
|
260
|
+
id: a.latest_deployment.id,
|
|
261
|
+
phase: a.latest_deployment.status?.phase,
|
|
262
|
+
created_at: a.latest_deployment.createdAt,
|
|
263
|
+
commit: a.latest_deployment.github_commit
|
|
264
|
+
}
|
|
265
|
+
: null
|
|
266
|
+
}
|
|
267
|
+
: {})
|
|
268
|
+
})),
|
|
246
269
|
annotations: READ,
|
|
247
|
-
example: { project: 'p', cursor: 'abc' }
|
|
270
|
+
example: { project: 'p', cursor: 'abc', latest: true }
|
|
248
271
|
},
|
|
249
272
|
{
|
|
250
273
|
name: 'list_blueprints',
|