@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,51 @@
|
|
|
1
1
|
# @amodalai/amodal
|
|
2
2
|
|
|
3
|
+
## 0.3.91
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 382a16d: Prune cloud-owned setup, draft, marketplace, and hosted deploy implementation details from the OSS packages while keeping Studio source browsing read-only and using product-neutral runtime, source, and auth contracts.
|
|
8
|
+
- Updated dependencies [382a16d]
|
|
9
|
+
- @amodalai/core@0.3.91
|
|
10
|
+
- @amodalai/db@0.3.91
|
|
11
|
+
- @amodalai/runtime@0.3.91
|
|
12
|
+
- @amodalai/studio@0.3.91
|
|
13
|
+
- @amodalai/types@0.3.91
|
|
14
|
+
- @amodalai/runtime-app@0.3.91
|
|
15
|
+
|
|
16
|
+
## 0.3.90
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- e31c71f: **Hosted runtime now loads agents from disk like OSS does** — same code path, same bundle hydration, same driver discovery. The standalone deploy-snapshot abstraction is gone.
|
|
21
|
+
|
|
22
|
+
Removed:
|
|
23
|
+
- `@amodalai/core` exports `buildSnapshot`, `snapshotToBundle`, `loadSnapshotFromFile`, `serializeSnapshot`, `snapshotSizeBytes`, `parseSurfaceFromSnapshot`, and the entire `packages/core/src/snapshot/` module.
|
|
24
|
+
- `@amodalai/types` exports `DeploySnapshot`, `SnapshotConnection`, `SnapshotSkill`, `SnapshotAutomation`, `SnapshotKnowledge`, `SnapshotTool`, `SnapshotSubagent`, `SnapshotEval`, `BuildSnapshotOptions`.
|
|
25
|
+
- `@amodalai/runtime` exports `createSnapshotServer` / `SnapshotServerConfig`.
|
|
26
|
+
- `@amodalai/amodal` `getActiveSnapshot` / `uploadSnapshot` methods on `PlatformClient`. `SnapshotDeploymentMeta` renamed to `DeploymentMeta`.
|
|
27
|
+
|
|
28
|
+
Added / renamed:
|
|
29
|
+
- `@amodalai/types` `ToolBuildManifest` and `ToolBuildManifestEntry` (moved from `snapshot-types.ts` into `tool-types.ts`; renamed from `SnapshotBuildManifest` / `SnapshotToolManifestEntry`). These describe tool sandbox snapshots, which are a distinct concept from deploy snapshots and survive the deletion.
|
|
30
|
+
- `@amodalai/runtime` `createBundleServer` / `BundleServerConfig` — drop-in replacement for the old snapshot-server, loads from a repo directory (or extracted tarball) via `loadRepoFromDisk`.
|
|
31
|
+
- `@amodalai/types` `RepoLoadOptions.resolvedCredentials?: Record<string, string>` — pre-resolved credentials passed to every `ConnectionDriver.loadConnection()` call as `LoadConnectionOptions.credentials`, and stamped onto the returned `AgentBundle.resolvedCredentials`. Community drivers (SQL, GraphQL, etc.) can resolve `env:KEY` references in their spec.json against deploy-time secrets, not just `process.env`.
|
|
32
|
+
|
|
33
|
+
Changed CLI behavior:
|
|
34
|
+
- `amodal build` now writes `<output>/agent.tar.gz` (the bundle) and `<output>/manifest.json` (audit metadata: deployId, commitSha, branch, agentName, source, optional toolBuildManifest). Default output dir is `./build/` (was `resolved-config.json`).
|
|
35
|
+
- `amodal serve --config <path>` now accepts a bundle directory or a `.tar.gz` (auto-extracted). `--platform` mode dropped; equivalent flow is to download the tarball and pass `--config`.
|
|
36
|
+
- `amodal chat --config <path>` likewise accepts a bundle directory.
|
|
37
|
+
- Deployment-listing endpoints in `PlatformClient` (`listDeployments`, `rollback`, `promote`, `getStatus`) now hit `/api/deployments` (was `/api/snapshot-deployments`). Cloud-side rename to follow.
|
|
38
|
+
|
|
39
|
+
This is the OSS half of a coordinated change. Cloud-side (build-server, platform-api, hosted-runtime) follows: hosted-runtime fetches `repo.tar.gz` from R2 at boot and calls `loadRepoFromDisk`; `CHANNEL_CONFIG` env injection is dropped (channels are read from `bundle.channels`); the deployments table stops storing `snapshot` JSONB.
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [e31c71f]
|
|
42
|
+
- @amodalai/types@0.3.90
|
|
43
|
+
- @amodalai/core@0.3.90
|
|
44
|
+
- @amodalai/runtime@0.3.90
|
|
45
|
+
- @amodalai/db@0.3.90
|
|
46
|
+
- @amodalai/runtime-app@0.3.90
|
|
47
|
+
- @amodalai/studio@0.3.90
|
|
48
|
+
|
|
3
49
|
## 0.3.89
|
|
4
50
|
|
|
5
51
|
### Patch Changes
|
|
@@ -7,11 +7,9 @@ import type { CommandModule } from 'yargs';
|
|
|
7
7
|
export interface AuditOptions {
|
|
8
8
|
sessionId: string;
|
|
9
9
|
format?: 'json' | 'table';
|
|
10
|
-
platformUrl?: string;
|
|
11
|
-
platformApiKey?: string;
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
12
|
+
* Hosted audit trails are not available from the OSS CLI.
|
|
15
13
|
*/
|
|
16
14
|
export declare function runAudit(options: AuditOptions): Promise<void>;
|
|
17
15
|
export declare const auditCommand: CommandModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAInE;AAED,eAAO,MAAM,YAAY,EAAE,aAuB1B,CAAC"}
|
|
@@ -3,62 +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
|
+
* Hosted audit trails are not available from the OSS CLI.
|
|
9
8
|
*/
|
|
10
9
|
export async function runAudit(options) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const config = await resolvePlatformConfig({
|
|
15
|
-
url: options.platformUrl,
|
|
16
|
-
apiKey: options.platformApiKey,
|
|
17
|
-
});
|
|
18
|
-
platformUrl = config.url;
|
|
19
|
-
apiKey = config.apiKey;
|
|
20
|
-
}
|
|
21
|
-
catch (err) {
|
|
22
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
23
|
-
process.stderr.write(`[audit] ${msg}\n`);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
const response = await fetch(`${platformUrl}/api/audit/sessions/${options.sessionId}`, {
|
|
28
|
-
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
29
|
-
});
|
|
30
|
-
if (!response.ok) {
|
|
31
|
-
process.stderr.write(`[audit] HTTP ${response.status}: ${await response.text()}\n`);
|
|
32
|
-
process.exit(1);
|
|
33
|
-
}
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- platform response
|
|
35
|
-
const data = await response.json();
|
|
36
|
-
if (options.format === 'json') {
|
|
37
|
-
process.stdout.write(JSON.stringify(data, null, 2) + '\n');
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
// Table format
|
|
41
|
-
const events = data.events;
|
|
42
|
-
if (events.length === 0) {
|
|
43
|
-
process.stdout.write('No audit events found for this session.\n');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const typeWidth = Math.max(10, ...events.map((e) => e.eventType.length));
|
|
47
|
-
process.stdout.write(`\nSession: ${data.sessionId}\n`);
|
|
48
|
-
process.stdout.write(`${'Type'.padEnd(typeWidth)} ${'Time'.padEnd(24)} Details\n`);
|
|
49
|
-
process.stdout.write('-'.repeat(typeWidth + 50) + '\n');
|
|
50
|
-
for (const event of events) {
|
|
51
|
-
const time = event.createdAt.slice(0, 24);
|
|
52
|
-
const details = event.durationMs ? `${event.durationMs}ms` : '';
|
|
53
|
-
process.stdout.write(`${event.eventType.padEnd(typeWidth)} ${time.padEnd(24)} ${details}\n`);
|
|
54
|
-
}
|
|
55
|
-
process.stdout.write(`\nTotal: ${events.length} events\n`);
|
|
56
|
-
}
|
|
57
|
-
catch (err) {
|
|
58
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
59
|
-
process.stderr.write(`[audit] Error: ${msg}\n`);
|
|
60
|
-
process.exit(1);
|
|
61
|
-
}
|
|
10
|
+
void options;
|
|
11
|
+
process.stderr.write('[audit] Hosted audit retrieval is not included in the OSS CLI.\n');
|
|
12
|
+
process.exit(1);
|
|
62
13
|
}
|
|
63
14
|
export const auditCommand = {
|
|
64
15
|
command: 'audit <session-id>',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../src/commands/audit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAqB;IAClD,KAAK,OAAO,CAAC;IACb,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACzF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,OAAO,EAAE,oBAAoB;IAC7B,QAAQ,EAAE,gCAAgC;IAC1C,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,UAAU,CAAC,YAAY,EAAE;QACxB,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;QAClB,QAAQ,EAAE,6CAA6C;KACxD,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,CAAU;QACnC,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,eAAe;KAC1B,CAAC;IACN,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,uEAAuE;QACvE,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAW,CAAC;QAC9C,uEAAuE;QACvE,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAqB,CAAC;QAClD,MAAM,QAAQ,CAAC,EAAC,SAAS,EAAE,MAAM,EAAC,CAAC,CAAC;IACtC,CAAC;CACF,CAAC"}
|
|
@@ -8,7 +8,7 @@ import { z } from 'zod';
|
|
|
8
8
|
* Schema for a single tool entry in the build manifest.
|
|
9
9
|
*/
|
|
10
10
|
export const BuildManifestToolSchema = z.object({
|
|
11
|
-
/**
|
|
11
|
+
/** Sandbox snapshot ID for fast workspace creation */
|
|
12
12
|
snapshotId: z.string().min(1),
|
|
13
13
|
/** Content hash of the tool's source files */
|
|
14
14
|
imageHash: z.string().min(1),
|
|
@@ -11,20 +11,13 @@ import type { BuildManifest } from './build-manifest-types.js';
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function listFilesRecursive(dir: string, root?: string): string[];
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
* Excludes node_modules, .git, __pycache__, etc.
|
|
16
|
-
*/
|
|
17
|
-
export declare function createToolArchive(tool: LoadedTool): Buffer;
|
|
18
|
-
/**
|
|
19
|
-
* Build Daytona sandbox snapshots for custom tools.
|
|
14
|
+
* Build local custom-tool manifest entries.
|
|
20
15
|
*
|
|
21
16
|
* For each tool:
|
|
22
17
|
* 1. Compute a content hash of all files in the tool directory
|
|
23
18
|
* 2. If hash matches existing manifest entry, skip (cached)
|
|
24
|
-
* 3. Otherwise,
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* The ISV never touches Daytona directly. The platform owns the infra.
|
|
19
|
+
* 3. Otherwise, generate a local placeholder snapshot id. Hosted control
|
|
20
|
+
* planes own sandbox image builds outside the OSS CLI.
|
|
28
21
|
*
|
|
29
22
|
* Writes .amodal/build-manifest.json locally for caching.
|
|
30
23
|
* The manifest is also included in the deploy snapshot.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-tools.d.ts","sourceRoot":"","sources":["../../../src/commands/build-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"build-tools.d.ts","sourceRoot":"","sources":["../../../src/commands/build-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAE7D;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAoBvE;AAwCD;;;;;;;;;;;GAWG;AACH,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,UAAU,EAAE,GAClB,OAAO,CAAC,aAAa,CAAC,CAoDxB"}
|
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
import { createHash } from 'node:crypto';
|
|
7
7
|
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from 'node:fs';
|
|
8
8
|
import { join, relative } from 'node:path';
|
|
9
|
-
import { execSync } from 'node:child_process';
|
|
10
9
|
/**
|
|
11
10
|
* Recursively list all files in a directory, returning paths relative to root.
|
|
12
11
|
* Skips node_modules, .git, __pycache__.
|
|
@@ -70,115 +69,13 @@ function loadExistingManifest(repoPath) {
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
/**
|
|
73
|
-
*
|
|
74
|
-
*/
|
|
75
|
-
function getPlatformConfig(repoPath) {
|
|
76
|
-
try {
|
|
77
|
-
const configPath = join(repoPath, 'amodal.json');
|
|
78
|
-
const raw = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
80
|
-
const config = raw;
|
|
81
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
82
|
-
const platform = config['platform'];
|
|
83
|
-
if (!platform?.apiKey)
|
|
84
|
-
return null;
|
|
85
|
-
const apiUrl = (process.env['PLATFORM_API_URL'] ?? 'https://api.amodal.dev').replace(/\/$/, '');
|
|
86
|
-
return { apiUrl, apiKey: platform.apiKey };
|
|
87
|
-
}
|
|
88
|
-
catch {
|
|
89
|
-
return null;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Create a tar.gz archive of the tool directory.
|
|
94
|
-
* Excludes node_modules, .git, __pycache__, etc.
|
|
95
|
-
*/
|
|
96
|
-
export function createToolArchive(tool) {
|
|
97
|
-
// Use system tar — available on macOS and Linux
|
|
98
|
-
const tarOutput = execSync('tar -czf - ' +
|
|
99
|
-
'--exclude=node_modules --exclude=.git --exclude=__pycache__ ' +
|
|
100
|
-
'--exclude=.venv --exclude=dist ' +
|
|
101
|
-
'-C ' + JSON.stringify(tool.location) + ' .', { maxBuffer: 50 * 1024 * 1024 });
|
|
102
|
-
return Buffer.from(tarOutput);
|
|
103
|
-
}
|
|
104
|
-
const POLL_INTERVAL_MS = 3000;
|
|
105
|
-
const POLL_TIMEOUT_MS = 5 * 60 * 1000; // 5 minutes max
|
|
106
|
-
/**
|
|
107
|
-
* Upload a tool bundle to the platform API and wait for the build to complete.
|
|
108
|
-
*
|
|
109
|
-
* 1. POST /api/tools/build — starts the build (Vercel creates a Daytona
|
|
110
|
-
* sandbox, uploads files, kicks off setup commands asynchronously)
|
|
111
|
-
* 2. Poll GET /api/tools/build/:id — waits for setup to finish, then
|
|
112
|
-
* the platform snapshots the sandbox and returns the snapshotId
|
|
113
|
-
*
|
|
114
|
-
* The ISV never needs Daytona credentials. The platform owns the infra.
|
|
115
|
-
*/
|
|
116
|
-
async function buildToolOnPlatform(platformUrl, apiKey, tool, imageHash) {
|
|
117
|
-
const archive = createToolArchive(tool);
|
|
118
|
-
const fileCount = listFilesRecursive(tool.location).length;
|
|
119
|
-
process.stderr.write(`[build-tools] ${tool.name}: uploading ${fileCount} files (${(archive.length / 1024).toFixed(1)} KB)\n`);
|
|
120
|
-
// 1. Start the build
|
|
121
|
-
const startResponse = await fetch(`${platformUrl}/api/tools/build`, {
|
|
122
|
-
method: 'POST',
|
|
123
|
-
headers: {
|
|
124
|
-
'Authorization': `Bearer ${apiKey}`,
|
|
125
|
-
'Content-Type': 'application/gzip',
|
|
126
|
-
'X-Tool-Name': tool.name,
|
|
127
|
-
'X-Tool-Hash': imageHash,
|
|
128
|
-
'X-Sandbox-Language': tool.sandboxLanguage,
|
|
129
|
-
'X-Has-Setup-Script': String(tool.hasSetupScript),
|
|
130
|
-
'X-Has-Requirements-Txt': String(tool.hasRequirementsTxt),
|
|
131
|
-
'X-Has-Dockerfile': String(tool.hasDockerfile),
|
|
132
|
-
'X-Has-Package-Json': String(tool.hasPackageJson),
|
|
133
|
-
},
|
|
134
|
-
body: archive,
|
|
135
|
-
});
|
|
136
|
-
if (!startResponse.ok) {
|
|
137
|
-
const text = await startResponse.text().catch(() => '');
|
|
138
|
-
throw new Error(`Platform tool build failed to start (${startResponse.status}): ${text}`);
|
|
139
|
-
}
|
|
140
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
141
|
-
const buildResult = await startResponse.json();
|
|
142
|
-
// If already complete (no setup needed), return immediately
|
|
143
|
-
if (buildResult.status === 'complete' && buildResult.snapshotId) {
|
|
144
|
-
return buildResult.snapshotId;
|
|
145
|
-
}
|
|
146
|
-
if (buildResult.status === 'failed') {
|
|
147
|
-
throw new Error(`Tool build failed: ${buildResult.error ?? 'unknown error'}`);
|
|
148
|
-
}
|
|
149
|
-
// 2. Poll until complete
|
|
150
|
-
const buildId = buildResult.id;
|
|
151
|
-
const startTime = Date.now();
|
|
152
|
-
while (Date.now() - startTime < POLL_TIMEOUT_MS) {
|
|
153
|
-
await new Promise((r) => setTimeout(r, POLL_INTERVAL_MS));
|
|
154
|
-
const pollResponse = await fetch(`${platformUrl}/api/tools/build/${buildId}`, {
|
|
155
|
-
headers: { 'Authorization': `Bearer ${apiKey}` },
|
|
156
|
-
});
|
|
157
|
-
if (!pollResponse.ok) {
|
|
158
|
-
throw new Error(`Failed to poll build status (${pollResponse.status})`);
|
|
159
|
-
}
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
161
|
-
const poll = await pollResponse.json();
|
|
162
|
-
if (poll.status === 'complete' && poll.snapshotId) {
|
|
163
|
-
return poll.snapshotId;
|
|
164
|
-
}
|
|
165
|
-
if (poll.status === 'failed') {
|
|
166
|
-
throw new Error(`Tool build failed: ${poll.error ?? 'unknown error'}`);
|
|
167
|
-
}
|
|
168
|
-
process.stderr.write(`[build-tools] ${tool.name}: ${poll.status}...\n`);
|
|
169
|
-
}
|
|
170
|
-
throw new Error(`Tool build timed out after ${POLL_TIMEOUT_MS / 1000}s`);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Build Daytona sandbox snapshots for custom tools.
|
|
72
|
+
* Build local custom-tool manifest entries.
|
|
174
73
|
*
|
|
175
74
|
* For each tool:
|
|
176
75
|
* 1. Compute a content hash of all files in the tool directory
|
|
177
76
|
* 2. If hash matches existing manifest entry, skip (cached)
|
|
178
|
-
* 3. Otherwise,
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
* The ISV never touches Daytona directly. The platform owns the infra.
|
|
77
|
+
* 3. Otherwise, generate a local placeholder snapshot id. Hosted control
|
|
78
|
+
* planes own sandbox image builds outside the OSS CLI.
|
|
182
79
|
*
|
|
183
80
|
* Writes .amodal/build-manifest.json locally for caching.
|
|
184
81
|
* The manifest is also included in the deploy snapshot.
|
|
@@ -186,7 +83,6 @@ async function buildToolOnPlatform(platformUrl, apiKey, tool, imageHash) {
|
|
|
186
83
|
export async function buildToolTemplates(repoPath, tools) {
|
|
187
84
|
const existing = loadExistingManifest(repoPath);
|
|
188
85
|
const existingTools = existing?.tools ?? {};
|
|
189
|
-
const platform = getPlatformConfig(repoPath);
|
|
190
86
|
const builtTools = {};
|
|
191
87
|
let skipped = 0;
|
|
192
88
|
let built = 0;
|
|
@@ -205,17 +101,8 @@ export async function buildToolTemplates(repoPath, tools) {
|
|
|
205
101
|
else {
|
|
206
102
|
process.stderr.write(`[build-tools] ${tool.name}: building (${tool.sandboxLanguage})\n`);
|
|
207
103
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// Upload to platform API → platform builds on Daytona
|
|
211
|
-
snapshotId = await buildToolOnPlatform(platform.apiUrl, platform.apiKey, tool, imageHash);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
// No platform configured — generate a placeholder
|
|
215
|
-
// (local dev mode — tools run in-process, snapshots not needed)
|
|
216
|
-
snapshotId = `local-${imageHash.slice(0, 16)}`;
|
|
217
|
-
process.stderr.write(`[build-tools] ${tool.name}: no platform configured, using local placeholder\n`);
|
|
218
|
-
}
|
|
104
|
+
const snapshotId = `local-${imageHash.slice(0, 16)}`;
|
|
105
|
+
process.stderr.write(`[build-tools] ${tool.name}: using local placeholder\n`);
|
|
219
106
|
builtTools[tool.name] = { snapshotId, imageHash, sandboxLanguage: tool.sandboxLanguage, hasDockerfile: tool.hasDockerfile, hasSetupScript: tool.hasSetupScript };
|
|
220
107
|
built++;
|
|
221
108
|
process.stderr.write(`[build-tools] ${tool.name}: snapshot ${snapshotId}\n`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-tools.js","sourceRoot":"","sources":["../../../src/commands/build-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,SAAS,CAAC;AACxF,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"build-tools.js","sourceRoot":"","sources":["../../../src/commands/build-tools.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAA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EAAE,IAAI,CAAC,cAAc,EAAC,CAAC;QAC/J,KAAK,EAAE,CAAC;QACR,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,IAAI,cAAc,UAAU,IAAI,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,QAAQ,GAAkB;QAC9B,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACjC,KAAK,EAAE,UAAU;KAClB,CAAC;IAEF,qCAAqC;IACrC,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5C,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,SAAS,CAAC,SAAS,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAC1C,CAAC;IACD,aAAa,CACX,IAAI,CAAC,SAAS,EAAE,qBAAqB,CAAC,EACtC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAClC,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,KAAK,WAAW,OAAO,WAAW,CAAC,CAAC;IAEhF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -1,22 +1,40 @@
|
|
|
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 { ToolBuildManifest } from '@amodalai/types';
|
|
7
8
|
export interface BuildOptions {
|
|
8
9
|
cwd?: string;
|
|
9
10
|
output?: string;
|
|
10
11
|
tools?: boolean;
|
|
11
12
|
}
|
|
12
13
|
/**
|
|
13
|
-
*
|
|
14
|
+
* Audit + handoff metadata `amodal build` emits alongside the bundle
|
|
15
|
+
* tarball. Captures who built it, from where, against which commit —
|
|
16
|
+
* the minimum a runtime / platform needs without re-parsing the bundle.
|
|
17
|
+
*/
|
|
18
|
+
export interface DeployManifest {
|
|
19
|
+
deployId: string;
|
|
20
|
+
createdAt: string;
|
|
21
|
+
createdBy: string;
|
|
22
|
+
source: 'cli' | 'github' | 'admin-ui';
|
|
23
|
+
commitSha?: string;
|
|
24
|
+
branch?: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
agentName: string;
|
|
27
|
+
toolBuildManifest?: ToolBuildManifest;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Build a deploy artifact (tarball + manifest) from the local repo.
|
|
14
31
|
*
|
|
15
32
|
* 1. Find repo root
|
|
16
33
|
* 2. Validate configuration
|
|
17
|
-
* 3. Load and resolve repo
|
|
18
|
-
* 4.
|
|
19
|
-
* 5.
|
|
34
|
+
* 3. Load and resolve repo (verifies it parses)
|
|
35
|
+
* 4. Optionally build tool sandbox snapshots
|
|
36
|
+
* 5. Pack the repo (including `node_modules`) into a tarball
|
|
37
|
+
* 6. Write a manifest describing the build
|
|
20
38
|
*/
|
|
21
39
|
export declare function runBuild(options?: BuildOptions): Promise<number>;
|
|
22
40
|
export declare const buildCommand: CommandModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,OAAO,CAAC;AAEzC,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,iBAAiB,CAAC;AAKvD,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,KAAK,GAAG,QAAQ,GAAG,UAAU,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AA0BD;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8E1E;AAED,eAAO,MAAM,YAAY,EAAE,aAoB1B,CAAC"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* Copyright
|
|
3
|
+
* Copyright 2026 Amodal Labs, Inc.
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
-
import { writeFileSync } from 'node:fs';
|
|
6
|
+
import { writeFileSync, mkdirSync } from 'node:fs';
|
|
7
7
|
import { join, resolve } from 'node:path';
|
|
8
8
|
import { execSync } from 'node:child_process';
|
|
9
|
-
import {
|
|
9
|
+
import { randomUUID } from 'node:crypto';
|
|
10
|
+
import { loadRepo } from '@amodalai/core';
|
|
10
11
|
import { buildToolTemplates } from './build-tools.js';
|
|
11
12
|
import { findRepoRoot } from '../shared/repo-discovery.js';
|
|
12
13
|
import { runValidate } from './validate.js';
|
|
13
|
-
/**
|
|
14
|
-
* Get the current user from git config or fallback.
|
|
15
|
-
*/
|
|
16
14
|
function getCurrentUser() {
|
|
17
15
|
try {
|
|
18
16
|
return execSync('git config user.email', { encoding: 'utf-8' }).trim();
|
|
@@ -21,9 +19,6 @@ function getCurrentUser() {
|
|
|
21
19
|
return process.env['USER'] ?? 'unknown';
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Get the current git commit SHA, or undefined if not in a git repo.
|
|
26
|
-
*/
|
|
27
22
|
function getGitSha() {
|
|
28
23
|
try {
|
|
29
24
|
return execSync('git rev-parse HEAD', { encoding: 'utf-8' }).trim();
|
|
@@ -32,14 +27,23 @@ function getGitSha() {
|
|
|
32
27
|
return undefined;
|
|
33
28
|
}
|
|
34
29
|
}
|
|
30
|
+
function getGitBranch() {
|
|
31
|
+
try {
|
|
32
|
+
return execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' }).trim();
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
35
38
|
/**
|
|
36
|
-
* Build a deploy
|
|
39
|
+
* Build a deploy artifact (tarball + manifest) from the local repo.
|
|
37
40
|
*
|
|
38
41
|
* 1. Find repo root
|
|
39
42
|
* 2. Validate configuration
|
|
40
|
-
* 3. Load and resolve repo
|
|
41
|
-
* 4.
|
|
42
|
-
* 5.
|
|
43
|
+
* 3. Load and resolve repo (verifies it parses)
|
|
44
|
+
* 4. Optionally build tool sandbox snapshots
|
|
45
|
+
* 5. Pack the repo (including `node_modules`) into a tarball
|
|
46
|
+
* 6. Write a manifest describing the build
|
|
43
47
|
*/
|
|
44
48
|
export async function runBuild(options = {}) {
|
|
45
49
|
let repoPath;
|
|
@@ -58,7 +62,7 @@ export async function runBuild(options = {}) {
|
|
|
58
62
|
process.stderr.write(`[build] Validation failed with ${errors} error(s). Fix errors before building.\n`);
|
|
59
63
|
return 1;
|
|
60
64
|
}
|
|
61
|
-
// Load repo
|
|
65
|
+
// Load repo to verify it parses cleanly
|
|
62
66
|
process.stderr.write('[build] Loading repo...\n');
|
|
63
67
|
let repo;
|
|
64
68
|
try {
|
|
@@ -70,45 +74,60 @@ export async function runBuild(options = {}) {
|
|
|
70
74
|
return 1;
|
|
71
75
|
}
|
|
72
76
|
// Build tool sandbox snapshots if requested
|
|
73
|
-
let
|
|
77
|
+
let toolBuildManifest;
|
|
74
78
|
if (options.tools && repo.tools.length > 0) {
|
|
75
79
|
process.stderr.write(`[build] Building ${repo.tools.length} tool sandbox(es)...\n`);
|
|
76
|
-
|
|
80
|
+
toolBuildManifest = await buildToolTemplates(repoPath, repo.tools);
|
|
77
81
|
}
|
|
78
82
|
else if (options.tools && repo.tools.length === 0) {
|
|
79
83
|
process.stderr.write('[build] No tools found in tools/ directory\n');
|
|
80
84
|
}
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
const outDir = options.output ? resolve(options.output) : join(repoPath, 'build');
|
|
86
|
+
mkdirSync(outDir, { recursive: true });
|
|
87
|
+
// Pack the repo into a tarball. Excludes things that don't belong in
|
|
88
|
+
// a deploy artifact: VCS dir, prior build output, environment files.
|
|
89
|
+
const tarballPath = join(outDir, 'agent.tar.gz');
|
|
90
|
+
process.stderr.write(`[build] Packing ${repoPath} → ${tarballPath}\n`);
|
|
91
|
+
try {
|
|
92
|
+
execSync(`tar -czf "${tarballPath}" ` +
|
|
93
|
+
`--exclude='.git' --exclude='build' --exclude='.env' --exclude='.env.local' ` +
|
|
94
|
+
`-C "${repoPath}" .`, { stdio: 'pipe' });
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
98
|
+
process.stderr.write(`[build] tar failed: ${msg}\n`);
|
|
99
|
+
return 1;
|
|
100
|
+
}
|
|
101
|
+
const manifest = {
|
|
102
|
+
deployId: randomUUID(),
|
|
103
|
+
createdAt: new Date().toISOString(),
|
|
83
104
|
createdBy: getCurrentUser(),
|
|
84
105
|
source: 'cli',
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
process.stderr.write(`[build]
|
|
96
|
-
process.stderr.write(`[build] Size: ${(size / 1024).toFixed(1)} KB\n`);
|
|
97
|
-
process.stderr.write(`[build] Connections: ${Object.keys(snapshot.connections).length}, Skills: ${snapshot.skills.length}, Automations: ${snapshot.automations.length}, Knowledge: ${snapshot.knowledge.length}, Tools: ${repo.tools.length}\n`);
|
|
106
|
+
agentName: repo.config.name,
|
|
107
|
+
...(getGitSha() ? { commitSha: getGitSha() } : {}),
|
|
108
|
+
...(getGitBranch() ? { branch: getGitBranch() } : {}),
|
|
109
|
+
...(toolBuildManifest ? { toolBuildManifest } : {}),
|
|
110
|
+
};
|
|
111
|
+
const manifestPath = join(outDir, 'manifest.json');
|
|
112
|
+
writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
113
|
+
process.stderr.write(`[build] Wrote tarball ${tarballPath}\n`);
|
|
114
|
+
process.stderr.write(`[build] Wrote manifest ${manifestPath}\n`);
|
|
115
|
+
process.stderr.write(`[build] deployId=${manifest.deployId} commit=${manifest.commitSha ?? '(no git)'} branch=${manifest.branch ?? '-'}\n`);
|
|
116
|
+
process.stderr.write(`[build] Bundle: connections=${repo.connections.size + repo.externalConnections.size}, skills=${repo.skills.length}, automations=${repo.automations.length}, knowledge=${repo.knowledge.length}, tools=${repo.tools.length}\n`);
|
|
98
117
|
return 0;
|
|
99
118
|
}
|
|
100
119
|
export const buildCommand = {
|
|
101
120
|
command: 'build',
|
|
102
|
-
describe: '
|
|
121
|
+
describe: 'Pack a deploy artifact (tarball + manifest) from the local repo',
|
|
103
122
|
builder: (yargs) => yargs
|
|
104
123
|
.option('output', {
|
|
105
124
|
type: 'string',
|
|
106
125
|
alias: 'o',
|
|
107
|
-
describe: 'Output
|
|
126
|
+
describe: 'Output directory (default: ./build)',
|
|
108
127
|
})
|
|
109
128
|
.option('tools', {
|
|
110
129
|
type: 'boolean',
|
|
111
|
-
describe: '
|
|
130
|
+
describe: 'Include local custom-tool build metadata',
|
|
112
131
|
default: false,
|
|
113
132
|
}),
|
|
114
133
|
handler: async (argv) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,aAAa,EAAE,SAAS,EAAC,MAAM,SAAS,CAAC;AACjD,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AACxC,OAAO,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAC,kBAAkB,EAAC,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAyB1C,SAAS,cAAc;IACrB,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,uBAAuB,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,SAAS,SAAS;IAChB,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,oBAAoB,EAAE,EAAC,QAAQ,EAAE,OAAO,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,OAAO,QAAQ,CAAC,iCAAiC,EAAE,EAAC,QAAQ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W,QAAQ,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC;IAC5I,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,+BAA+B,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,YAAY,IAAI,CAAC,MAAM,CAAC,MAAM,iBAAiB,IAAI,CAAC,WAAW,CAAC,MAAM,eAAe,IAAI,CAAC,SAAS,CAAC,MAAM,WAAW,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAErP,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAkB;IACzC,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,iEAAiE;IAC3E,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,QAAQ,EAAE;QAChB,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,QAAQ,EAAE,qCAAqC;KAChD,CAAC;SACD,MAAM,CAAC,OAAO,EAAE;QACf,IAAI,EAAE,SAAS;QACf,QAAQ,EAAE,0CAA0C;QACpD,OAAO,EAAE,KAAK;KACf,CAAC;IACN,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACtB,uEAAuE;QACvE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,EAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAuB,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAwB,EAAC,CAAC,CAAC;QACzH,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF,CAAC"}
|
|
@@ -18,7 +18,7 @@ export interface ChatOptions {
|
|
|
18
18
|
*
|
|
19
19
|
* Three modes:
|
|
20
20
|
* --url <remote> → connect to an already-running server (no local boot)
|
|
21
|
-
* --config <
|
|
21
|
+
* --config <dir> → boot from an extracted bundle directory (offline replay)
|
|
22
22
|
* (default) → boot from the local repo
|
|
23
23
|
*/
|
|
24
24
|
export declare function runChat(options: ChatOptions): Promise<void>;
|