@amodalai/amodal 0.3.89 → 0.3.91
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/CHANGELOG.md +46 -0
- package/dist/src/commands/audit.d.ts +1 -3
- package/dist/src/commands/audit.d.ts.map +1 -1
- package/dist/src/commands/audit.js +4 -53
- package/dist/src/commands/audit.js.map +1 -1
- package/dist/src/commands/build-manifest-types.js +1 -1
- package/dist/src/commands/build-tools.d.ts +3 -10
- package/dist/src/commands/build-tools.d.ts.map +1 -1
- package/dist/src/commands/build-tools.js +5 -118
- package/dist/src/commands/build-tools.js.map +1 -1
- package/dist/src/commands/build.d.ts +23 -5
- package/dist/src/commands/build.d.ts.map +1 -1
- package/dist/src/commands/build.js +53 -34
- package/dist/src/commands/build.js.map +1 -1
- package/dist/src/commands/chat.d.ts +1 -1
- package/dist/src/commands/chat.js +5 -5
- package/dist/src/commands/chat.js.map +1 -1
- package/dist/src/commands/deploy.d.ts +1 -1
- package/dist/src/commands/deploy.d.ts.map +1 -1
- package/dist/src/commands/deploy.js +3 -61
- package/dist/src/commands/deploy.js.map +1 -1
- package/dist/src/commands/deployments.d.ts.map +1 -1
- package/dist/src/commands/deployments.js +3 -36
- package/dist/src/commands/deployments.js.map +1 -1
- package/dist/src/commands/dev.d.ts.map +1 -1
- package/dist/src/commands/dev.js +7 -10
- package/dist/src/commands/dev.js.map +1 -1
- package/dist/src/commands/experiment.d.ts +1 -3
- package/dist/src/commands/experiment.d.ts.map +1 -1
- package/dist/src/commands/experiment.js +4 -102
- package/dist/src/commands/experiment.js.map +1 -1
- package/dist/src/commands/promote.d.ts.map +1 -1
- package/dist/src/commands/promote.js +3 -21
- package/dist/src/commands/promote.js.map +1 -1
- package/dist/src/commands/rollback.d.ts.map +1 -1
- package/dist/src/commands/rollback.js +3 -24
- package/dist/src/commands/rollback.js.map +1 -1
- package/dist/src/commands/secrets.d.ts.map +1 -1
- package/dist/src/commands/secrets.js +2 -102
- package/dist/src/commands/secrets.js.map +1 -1
- package/dist/src/commands/serve.d.ts +2 -11
- package/dist/src/commands/serve.d.ts.map +1 -1
- package/dist/src/commands/serve.js +44 -87
- package/dist/src/commands/serve.js.map +1 -1
- package/dist/src/commands/status.d.ts.map +1 -1
- package/dist/src/commands/status.js +3 -49
- package/dist/src/commands/status.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -8
- package/src/commands/audit.ts +4 -71
- package/src/commands/build-manifest-types.ts +1 -1
- package/src/commands/build-tools.ts +5 -142
- package/src/commands/build.test.ts +14 -9
- package/src/commands/build.ts +73 -33
- package/src/commands/chat.ts +5 -5
- package/src/commands/deploy.test.ts +2 -13
- package/src/commands/deploy.ts +5 -67
- package/src/commands/deployments.ts +3 -39
- package/src/commands/dev.ts +7 -10
- package/src/commands/experiment.ts +4 -110
- package/src/commands/promote.ts +3 -21
- package/src/commands/rollback.ts +3 -24
- package/src/commands/secrets.test.ts +12 -134
- package/src/commands/secrets.ts +2 -116
- package/src/commands/serve.ts +46 -93
- package/src/commands/status.ts +3 -51
- package/src/e2e-commands.test.ts +18 -17
- package/dist/src/shared/platform-client.d.ts +0 -123
- package/dist/src/shared/platform-client.d.ts.map +0 -1
- package/dist/src/shared/platform-client.js +0 -280
- package/dist/src/shared/platform-client.js.map +0 -1
- package/src/commands/audit.test.ts +0 -92
- package/src/commands/experiment.test.ts +0 -125
- package/src/shared/platform-client.test.ts +0 -106
- package/src/shared/platform-client.ts +0 -367
|
@@ -3,34 +3,13 @@
|
|
|
3
3
|
* Copyright 2025 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { PlatformClient } from '../shared/platform-client.js';
|
|
7
6
|
/**
|
|
8
7
|
* Rollback to a previous deployment.
|
|
9
8
|
*/
|
|
10
9
|
export async function runRollback(options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
17
|
-
process.stderr.write(`[rollback] ${msg}\n`);
|
|
18
|
-
return 1;
|
|
19
|
-
}
|
|
20
|
-
const environment = options.env ?? 'production';
|
|
21
|
-
try {
|
|
22
|
-
const result = await client.rollback({
|
|
23
|
-
deployId: options.deployId,
|
|
24
|
-
environment,
|
|
25
|
-
});
|
|
26
|
-
process.stderr.write(`[rollback] Rolled back to ${result.id} in ${result.environment}\n`);
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
catch (err) {
|
|
30
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
31
|
-
process.stderr.write(`[rollback] Failed: ${msg}\n`);
|
|
32
|
-
return 1;
|
|
33
|
-
}
|
|
10
|
+
void options;
|
|
11
|
+
process.stderr.write('[rollback] Hosted deployment rollback is not included in the OSS CLI.\n');
|
|
12
|
+
return 1;
|
|
34
13
|
}
|
|
35
14
|
export const rollbackCommand = {
|
|
36
15
|
command: 'rollback [deploy-id]',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollback.js","sourceRoot":"","sources":["../../../src/commands/rollback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"rollback.js","sourceRoot":"","sources":["../../../src/commands/rollback.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAUH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,UAA2B,EAAE;IAC7D,KAAK,OAAO,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,yEAAyE,CAAC,CAAC;IAChG,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,CAAC,MAAM,eAAe,GAAkB;IAC5C,OAAO,EAAE,sBAAsB;IAC/B,QAAQ,EAAE,mCAAmC;IAC7C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,UAAU,CAAC,WAAW,EAAE;QACvB,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,8CAA8C;KACzD,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,iCAAiC;QAC3C,OAAO,EAAE,KAAK;KACf,CAAC;SACD,MAAM,CAAC,KAAK,EAAE;QACb,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,0CAA0C;KACrD,CAAC;IACN,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,uEAAuE;YACvE,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAuB;YAChD,uEAAuE;YACvE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAuB;SACvC,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../src/commands/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAIzE;AAED,eAAO,MAAM,cAAc,EAAE,aAsB5B,CAAC"}
|
|
@@ -3,113 +3,13 @@
|
|
|
3
3
|
* Copyright 2025 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { resolvePlatformConfig } from '../shared/platform-client.js';
|
|
7
6
|
/**
|
|
8
7
|
* Manage platform secrets.
|
|
9
8
|
* Returns 0 on success, 1 on error.
|
|
10
9
|
*/
|
|
11
10
|
export async function runSecrets(options) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
config = await resolvePlatformConfig();
|
|
15
|
-
}
|
|
16
|
-
catch (err) {
|
|
17
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
18
|
-
process.stderr.write(`[secrets] ${msg}\n`);
|
|
19
|
-
return 1;
|
|
20
|
-
}
|
|
21
|
-
const headers = {
|
|
22
|
-
'Authorization': `Bearer ${config.apiKey}`,
|
|
23
|
-
'Content-Type': 'application/json',
|
|
24
|
-
};
|
|
25
|
-
switch (options.subcommand) {
|
|
26
|
-
case 'set': {
|
|
27
|
-
if (!options.key) {
|
|
28
|
-
process.stderr.write('[secrets] Missing key. Usage: amodal secrets set <key> <value>\n');
|
|
29
|
-
return 1;
|
|
30
|
-
}
|
|
31
|
-
if (options.value === undefined) {
|
|
32
|
-
process.stderr.write('[secrets] Missing value. Usage: amodal secrets set <key> <value>\n');
|
|
33
|
-
return 1;
|
|
34
|
-
}
|
|
35
|
-
try {
|
|
36
|
-
const response = await fetch(`${config.url}/api/secrets`, {
|
|
37
|
-
method: 'PUT',
|
|
38
|
-
headers,
|
|
39
|
-
body: JSON.stringify({ key: options.key, value: options.value }),
|
|
40
|
-
});
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
process.stderr.write(`[secrets] Failed to set secret: ${response.status} ${response.statusText}\n`);
|
|
43
|
-
return 1;
|
|
44
|
-
}
|
|
45
|
-
process.stderr.write(`[secrets] Secret "${options.key}" set successfully.\n`);
|
|
46
|
-
return 0;
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
50
|
-
process.stderr.write(`[secrets] Failed to set secret: ${msg}\n`);
|
|
51
|
-
return 1;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
case 'list': {
|
|
55
|
-
try {
|
|
56
|
-
const response = await fetch(`${config.url}/api/secrets`, {
|
|
57
|
-
method: 'GET',
|
|
58
|
-
headers,
|
|
59
|
-
});
|
|
60
|
-
if (!response.ok) {
|
|
61
|
-
process.stderr.write(`[secrets] Failed to list secrets: ${response.status} ${response.statusText}\n`);
|
|
62
|
-
return 1;
|
|
63
|
-
}
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
65
|
-
const secrets = (await response.json());
|
|
66
|
-
if (secrets.length === 0) {
|
|
67
|
-
process.stderr.write('[secrets] No secrets configured.\n');
|
|
68
|
-
return 0;
|
|
69
|
-
}
|
|
70
|
-
if (options.json) {
|
|
71
|
-
process.stdout.write(JSON.stringify(secrets, null, 2) + '\n');
|
|
72
|
-
return 0;
|
|
73
|
-
}
|
|
74
|
-
process.stdout.write('KEY\n');
|
|
75
|
-
for (const secret of secrets) {
|
|
76
|
-
process.stdout.write(`${secret.key}\n`);
|
|
77
|
-
}
|
|
78
|
-
process.stderr.write(`[secrets] ${secrets.length} secret${secrets.length === 1 ? '' : 's'} configured.\n`);
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
83
|
-
process.stderr.write(`[secrets] Failed to list secrets: ${msg}\n`);
|
|
84
|
-
return 1;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
case 'delete': {
|
|
88
|
-
if (!options.key) {
|
|
89
|
-
process.stderr.write('[secrets] Missing key. Usage: amodal secrets delete <key>\n');
|
|
90
|
-
return 1;
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
const response = await fetch(`${config.url}/api/secrets/${encodeURIComponent(options.key)}`, {
|
|
94
|
-
method: 'DELETE',
|
|
95
|
-
headers,
|
|
96
|
-
});
|
|
97
|
-
if (!response.ok) {
|
|
98
|
-
process.stderr.write(`[secrets] Failed to delete secret: ${response.status} ${response.statusText}\n`);
|
|
99
|
-
return 1;
|
|
100
|
-
}
|
|
101
|
-
process.stderr.write(`[secrets] Secret "${options.key}" deleted.\n`);
|
|
102
|
-
return 0;
|
|
103
|
-
}
|
|
104
|
-
catch (err) {
|
|
105
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
106
|
-
process.stderr.write(`[secrets] Failed to delete secret: ${msg}\n`);
|
|
107
|
-
return 1;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
default:
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
11
|
+
void options;
|
|
12
|
+
process.stderr.write('[secrets] Hosted secret management is not included in the OSS CLI.\n');
|
|
113
13
|
return 1;
|
|
114
14
|
}
|
|
115
15
|
export const secretsCommand = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../src/commands/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../src/commands/secrets.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAYH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAuB;IACtD,KAAK,OAAO,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,sEAAsE,CAAC,CAAC;IAC7F,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,OAAO,EAAE,oCAAoC;IAC7C,QAAQ,EAAE,yBAAyB;IACnC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,UAAU,CAAC,YAAY,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAU,EAAE,QAAQ,EAAE,QAAQ,EAAC,CAAC;SAC/H,UAAU,CAAC,KAAK,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAC,CAAC;SAC3D,UAAU,CAAC,OAAO,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,EAAC,CAAC;SACzE,MAAM,CAAC,MAAM,EAAE,EAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAC,CAAC;IAClF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC;YAC5B,uEAAuE;YACvE,UAAU,EAAE,IAAI,CAAC,YAAY,CAA8B;YAC3D,uEAAuE;YACvE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAuB;YACtC,uEAAuE;YACvE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAuB;YAC1C,uEAAuE;YACvE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAY;SAC9B,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF,CAAC"}
|
|
@@ -1,25 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
6
|
import type { CommandModule } from 'yargs';
|
|
7
|
-
import type { AgentBundle } from '@amodalai/core';
|
|
8
7
|
export interface ServeOptions {
|
|
9
8
|
config?: string;
|
|
10
|
-
platform?: boolean;
|
|
11
|
-
project?: string;
|
|
12
|
-
env?: string;
|
|
13
9
|
port?: number;
|
|
14
10
|
host?: string;
|
|
15
11
|
verbose?: number;
|
|
16
12
|
quiet?: boolean;
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
* Load an agent runtime from a snapshot (file or platform) and start the server.
|
|
20
|
-
*
|
|
21
|
-
* Returns the loaded repo, or exits with error.
|
|
22
|
-
*/
|
|
23
|
-
export declare function runServe(options: ServeOptions): Promise<AgentBundle | null>;
|
|
14
|
+
export declare function runServe(options: ServeOptions): Promise<boolean>;
|
|
24
15
|
export declare const serveCommand: CommandModule;
|
|
25
16
|
//# sourceMappingURL=serve.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAGzC,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAwBD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAiDtE;AAED,eAAO,MAAM,YAAY,EAAE,aA6C1B,CAAC"}
|
|
@@ -1,83 +1,60 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { execSync } from 'node:child_process';
|
|
7
|
+
import { mkdtempSync, statSync } from 'node:fs';
|
|
8
|
+
import { tmpdir } from 'node:os';
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
import { createBundleServer, initLogLevel, interceptConsole } from '@amodalai/runtime';
|
|
9
11
|
const DEFAULT_PORT = 3847;
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* Resolve the `--config` argument to a directory `createBundleServer`
|
|
14
|
+
* can load via `loadRepoFromDisk`. Accepts either a directory or a
|
|
15
|
+
* `.tar.gz` tarball produced by `amodal build` (extracted to a tempdir).
|
|
12
16
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
24
|
-
process.stderr.write(`[serve] Failed to load snapshot: ${msg}\n`);
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
17
|
+
function resolveBundlePath(configArg) {
|
|
18
|
+
const absolute = resolve(configArg);
|
|
19
|
+
const stat = statSync(absolute);
|
|
20
|
+
if (stat.isDirectory())
|
|
21
|
+
return absolute;
|
|
22
|
+
if (absolute.endsWith('.tar.gz') || absolute.endsWith('.tgz')) {
|
|
23
|
+
const dir = mkdtempSync(join(tmpdir(), 'amodal-serve-'));
|
|
24
|
+
process.stderr.write(`[serve] Extracting ${absolute} → ${dir}\n`);
|
|
25
|
+
execSync(`tar -xzf "${absolute}" -C "${dir}"`, { stdio: 'pipe' });
|
|
26
|
+
return dir;
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
process.stderr.write('[serve] Fetching active snapshot from platform...\n');
|
|
30
|
-
let client;
|
|
31
|
-
try {
|
|
32
|
-
client = await PlatformClient.create();
|
|
33
|
-
}
|
|
34
|
-
catch (err) {
|
|
35
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
36
|
-
process.stderr.write(`[serve] ${msg}\n`);
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const environment = options.env ?? 'production';
|
|
40
|
-
try {
|
|
41
|
-
const snapshot = await client.getActiveSnapshot(environment);
|
|
42
|
-
const repo = snapshotToBundle(snapshot, `platform:${environment}`);
|
|
43
|
-
process.stderr.write(`[serve] Loaded ${snapshot.deployId} from ${environment}\n`);
|
|
44
|
-
return repo;
|
|
45
|
-
}
|
|
46
|
-
catch (err) {
|
|
47
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
48
|
-
process.stderr.write(`[serve] Failed to fetch snapshot: ${msg}\n`);
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
process.stderr.write('[serve] Specify --config <file> or --platform to load a snapshot.\n');
|
|
53
|
-
return null;
|
|
28
|
+
throw new Error(`Unsupported --config target: ${absolute} (expected a directory or .tar.gz tarball)`);
|
|
54
29
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Load an agent runtime from a snapshot (file or platform) and start the server.
|
|
57
|
-
*
|
|
58
|
-
* Returns the loaded repo, or exits with error.
|
|
59
|
-
*/
|
|
60
30
|
export async function runServe(options) {
|
|
61
31
|
initLogLevel({ verbosity: options.verbose ?? 0, quiet: options.quiet ?? false });
|
|
62
32
|
interceptConsole();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return
|
|
66
|
-
|
|
33
|
+
if (!options.config) {
|
|
34
|
+
process.stderr.write('[serve] --config <dir-or-tarball> is required.\n');
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
let bundlePath;
|
|
38
|
+
try {
|
|
39
|
+
bundlePath = resolveBundlePath(options.config);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
43
|
+
process.stderr.write(`[serve] ${msg}\n`);
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
67
46
|
const port = options.port ?? DEFAULT_PORT;
|
|
68
47
|
const host = options.host ?? '0.0.0.0';
|
|
69
|
-
process.stderr.write(`[serve] Starting server on ${host}:${port}...\n`);
|
|
48
|
+
process.stderr.write(`[serve] Starting bundle server from ${bundlePath} on ${host}:${port}...\n`);
|
|
70
49
|
try {
|
|
71
|
-
const server = await
|
|
72
|
-
|
|
50
|
+
const server = await createBundleServer({
|
|
51
|
+
bundlePath,
|
|
73
52
|
port,
|
|
74
53
|
host,
|
|
75
|
-
hotReload: false,
|
|
76
54
|
corsOrigin: '*',
|
|
77
55
|
});
|
|
78
56
|
await server.start();
|
|
79
|
-
process.stderr.write(`[serve]
|
|
80
|
-
// Graceful shutdown
|
|
57
|
+
process.stderr.write(`[serve] Serving at http://${host}:${port}\n`);
|
|
81
58
|
const shutdown = async (signal) => {
|
|
82
59
|
process.stderr.write(`\n[serve] Received ${signal}, shutting down...\n`);
|
|
83
60
|
await server.stop();
|
|
@@ -89,30 +66,18 @@ export async function runServe(options) {
|
|
|
89
66
|
catch (err) {
|
|
90
67
|
const msg = err instanceof Error ? err.message : String(err);
|
|
91
68
|
process.stderr.write(`[serve] Failed to start server: ${msg}\n`);
|
|
92
|
-
return
|
|
69
|
+
return false;
|
|
93
70
|
}
|
|
94
|
-
return
|
|
71
|
+
return true;
|
|
95
72
|
}
|
|
96
73
|
export const serveCommand = {
|
|
97
74
|
command: 'serve',
|
|
98
|
-
describe: '
|
|
75
|
+
describe: 'Serve an agent from a built bundle (directory or .tar.gz from `amodal build`)',
|
|
99
76
|
builder: (yargs) => yargs
|
|
100
77
|
.option('config', {
|
|
101
78
|
type: 'string',
|
|
102
|
-
describe: 'Path to
|
|
103
|
-
|
|
104
|
-
.option('platform', {
|
|
105
|
-
type: 'boolean',
|
|
106
|
-
describe: 'Fetch active snapshot from platform',
|
|
107
|
-
default: false,
|
|
108
|
-
})
|
|
109
|
-
.option('project', {
|
|
110
|
-
type: 'string',
|
|
111
|
-
describe: 'Platform project name',
|
|
112
|
-
})
|
|
113
|
-
.option('env', {
|
|
114
|
-
type: 'string',
|
|
115
|
-
describe: 'Platform environment (default: production)',
|
|
79
|
+
describe: 'Path to a bundle directory or .tar.gz tarball',
|
|
80
|
+
demandOption: true,
|
|
116
81
|
})
|
|
117
82
|
.option('port', {
|
|
118
83
|
type: 'number',
|
|
@@ -135,16 +100,10 @@ export const serveCommand = {
|
|
|
135
100
|
default: false,
|
|
136
101
|
}),
|
|
137
102
|
handler: async (argv) => {
|
|
138
|
-
const
|
|
103
|
+
const ok = await runServe({
|
|
139
104
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
140
105
|
config: argv['config'],
|
|
141
106
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
142
|
-
platform: argv['platform'],
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
144
|
-
project: argv['project'],
|
|
145
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
146
|
-
env: argv['env'],
|
|
147
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
148
107
|
port: argv['port'],
|
|
149
108
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
150
109
|
host: argv['host'],
|
|
@@ -153,10 +112,8 @@ export const serveCommand = {
|
|
|
153
112
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
154
113
|
quiet: argv['quiet'],
|
|
155
114
|
});
|
|
156
|
-
if (!
|
|
115
|
+
if (!ok)
|
|
157
116
|
process.exit(1);
|
|
158
|
-
}
|
|
159
|
-
// Server is running — process stays alive until SIGTERM/SIGINT
|
|
160
117
|
},
|
|
161
118
|
};
|
|
162
119
|
//# sourceMappingURL=serve.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"serve.js","sourceRoot":"","sources":["../../../src/commands/serve.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,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S;QACf,QAAQ,EAAE,kBAAkB;QAC5B,OAAO,EAAE,KAAK;KACf,CAAC;IACN,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,EAAE,GAAG,MAAM,QAAQ,CAAC;YACxB,uEAAuE;YACvE,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAW;YAChC,uEAAuE;YACvE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAuB;YACxC,uEAAuE;YACvE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAuB;YACxC,uEAAuE;YACvE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAW;YAClC,uEAAuE;YACvE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAY;SAChC,CAAC,CAAC;QACH,IAAI,CAAC,EAAE;YAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,CAI5E;AAED,eAAO,MAAM,aAAa,EAAE,aAuB3B,CAAC"}
|
|
@@ -3,59 +3,13 @@
|
|
|
3
3
|
* Copyright 2025 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { PlatformClient } from '../shared/platform-client.js';
|
|
7
6
|
/**
|
|
8
7
|
* Show current deployment status per environment.
|
|
9
8
|
*/
|
|
10
9
|
export async function runStatus(options = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
catch (err) {
|
|
16
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
17
|
-
process.stderr.write(`[status] ${msg}\n`);
|
|
18
|
-
return 1;
|
|
19
|
-
}
|
|
20
|
-
const environments = options.env ? [options.env] : ['production', 'staging'];
|
|
21
|
-
try {
|
|
22
|
-
const results = [];
|
|
23
|
-
for (const env of environments) {
|
|
24
|
-
const deployments = await client.listDeployments({ environment: env, limit: 1 });
|
|
25
|
-
const active = deployments.find((d) => d.isActive);
|
|
26
|
-
if (active) {
|
|
27
|
-
results.push({
|
|
28
|
-
environment: env,
|
|
29
|
-
id: active.id,
|
|
30
|
-
createdAt: active.createdAt,
|
|
31
|
-
createdBy: active.createdBy ?? undefined,
|
|
32
|
-
commitSha: active.commitSha ?? undefined,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
results.push({ environment: env });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
if (options.json) {
|
|
40
|
-
process.stdout.write(JSON.stringify(results, null, 2) + '\n');
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
for (const r of results) {
|
|
44
|
-
if (r.id) {
|
|
45
|
-
const sha = r.commitSha ? ` (${r.commitSha.slice(0, 7)})` : '';
|
|
46
|
-
process.stdout.write(`${r.environment}: ${r.id}${sha} — ${r.createdBy ?? 'unknown'} at ${r.createdAt}\n`);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
process.stdout.write(`${r.environment}: no active deployment\n`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return 0;
|
|
53
|
-
}
|
|
54
|
-
catch (err) {
|
|
55
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
56
|
-
process.stderr.write(`[status] Failed: ${msg}\n`);
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
10
|
+
void options;
|
|
11
|
+
process.stderr.write('[status] Hosted deployment status is not included in the OSS CLI.\n');
|
|
12
|
+
return 1;
|
|
59
13
|
}
|
|
60
14
|
export const statusCommand = {
|
|
61
15
|
command: 'status',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,UAAyB,EAAE;IACzD,KAAK,OAAO,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,qEAAqE,CAAC,CAAC;IAC5F,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,OAAO,EAAE,QAAQ;IACjB,QAAQ,EAAE,gCAAgC;IAC1C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,KAAK,EAAE;QACb,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,4BAA4B;KACvC,CAAC;SACD,MAAM,CAAC,MAAM,EAAE;QACd,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,gBAAgB;QAC1B,OAAO,EAAE,KAAK;KACf,CAAC;IACN,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,MAAM,IAAI,GAAG,MAAM,SAAS,CAAC;YAC3B,uEAAuE;YACvE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAuB;YACtC,uEAAuE;YACvE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAwB;SAC1C,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF,CAAC"}
|