@amalgm/shell 0.1.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.
Files changed (105) hide show
  1. package/PURPOSE.md +73 -0
  2. package/README.md +33 -0
  3. package/dist/automations-host.d.ts +19 -0
  4. package/dist/automations-host.js +41 -0
  5. package/dist/automations-host.js.map +1 -0
  6. package/dist/boot.d.ts +53 -0
  7. package/dist/boot.js +249 -0
  8. package/dist/boot.js.map +1 -0
  9. package/dist/bundle-apps.d.ts +12 -0
  10. package/dist/bundle-apps.js +71 -0
  11. package/dist/bundle-apps.js.map +1 -0
  12. package/dist/bundle-automations.d.ts +8 -0
  13. package/dist/bundle-automations.js +106 -0
  14. package/dist/bundle-automations.js.map +1 -0
  15. package/dist/bundle-bindings.d.ts +8 -0
  16. package/dist/bundle-bindings.js +101 -0
  17. package/dist/bundle-bindings.js.map +1 -0
  18. package/dist/bundle-port.d.ts +14 -0
  19. package/dist/bundle-port.js +166 -0
  20. package/dist/bundle-port.js.map +1 -0
  21. package/dist/chat-host.d.ts +32 -0
  22. package/dist/chat-host.js +167 -0
  23. package/dist/chat-host.js.map +1 -0
  24. package/dist/chat-payloads-host.d.ts +8 -0
  25. package/dist/chat-payloads-host.js +76 -0
  26. package/dist/chat-payloads-host.js.map +1 -0
  27. package/dist/chat-relay-host.d.ts +24 -0
  28. package/dist/chat-relay-host.js +90 -0
  29. package/dist/chat-relay-host.js.map +1 -0
  30. package/dist/cli.d.ts +1 -0
  31. package/dist/cli.js +157 -0
  32. package/dist/cli.js.map +1 -0
  33. package/dist/compose.d.ts +32 -0
  34. package/dist/compose.js +35 -0
  35. package/dist/compose.js.map +1 -0
  36. package/dist/credentials-host.d.ts +7 -0
  37. package/dist/credentials-host.js +143 -0
  38. package/dist/credentials-host.js.map +1 -0
  39. package/dist/diagnostics-host.d.ts +3 -0
  40. package/dist/diagnostics-host.js +92 -0
  41. package/dist/diagnostics-host.js.map +1 -0
  42. package/dist/drivers/claude-code.d.ts +27 -0
  43. package/dist/drivers/claude-code.js +72 -0
  44. package/dist/drivers/claude-code.js.map +1 -0
  45. package/dist/event-triggers-host.d.ts +4 -0
  46. package/dist/event-triggers-host.js +48 -0
  47. package/dist/event-triggers-host.js.map +1 -0
  48. package/dist/events-host.d.ts +9 -0
  49. package/dist/events-host.js +34 -0
  50. package/dist/events-host.js.map +1 -0
  51. package/dist/external-proxy-host.d.ts +15 -0
  52. package/dist/external-proxy-host.js +166 -0
  53. package/dist/external-proxy-host.js.map +1 -0
  54. package/dist/filesystem.d.ts +7 -0
  55. package/dist/filesystem.js +71 -0
  56. package/dist/filesystem.js.map +1 -0
  57. package/dist/forward.d.ts +11 -0
  58. package/dist/forward.js +36 -0
  59. package/dist/forward.js.map +1 -0
  60. package/dist/gateway.d.ts +33 -0
  61. package/dist/gateway.js +85 -0
  62. package/dist/gateway.js.map +1 -0
  63. package/dist/index.d.ts +23 -0
  64. package/dist/index.js +14 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/local-host.d.ts +8 -0
  67. package/dist/local-host.js +101 -0
  68. package/dist/local-host.js.map +1 -0
  69. package/dist/machine-host.d.ts +56 -0
  70. package/dist/machine-host.js +340 -0
  71. package/dist/machine-host.js.map +1 -0
  72. package/dist/main.d.ts +2 -0
  73. package/dist/main.js +4 -0
  74. package/dist/main.js.map +1 -0
  75. package/dist/parity.d.ts +40 -0
  76. package/dist/parity.js +108 -0
  77. package/dist/parity.js.map +1 -0
  78. package/dist/ports-host.d.ts +8 -0
  79. package/dist/ports-host.js +26 -0
  80. package/dist/ports-host.js.map +1 -0
  81. package/dist/pty-host.d.ts +14 -0
  82. package/dist/pty-host.js +141 -0
  83. package/dist/pty-host.js.map +1 -0
  84. package/dist/release-catalog.d.ts +5 -0
  85. package/dist/release-catalog.js +23 -0
  86. package/dist/release-catalog.js.map +1 -0
  87. package/dist/state-host.d.ts +4 -0
  88. package/dist/state-host.js +67 -0
  89. package/dist/state-host.js.map +1 -0
  90. package/dist/state-store.d.ts +15 -0
  91. package/dist/state-store.js +63 -0
  92. package/dist/state-store.js.map +1 -0
  93. package/dist/user-ground-host.d.ts +58 -0
  94. package/dist/user-ground-host.js +809 -0
  95. package/dist/user-ground-host.js.map +1 -0
  96. package/dist/wire-client.d.ts +44 -0
  97. package/dist/wire-client.js +235 -0
  98. package/dist/wire-client.js.map +1 -0
  99. package/dist/workspace-host.d.ts +5 -0
  100. package/dist/workspace-host.js +73 -0
  101. package/dist/workspace-host.js.map +1 -0
  102. package/dist/workspace-store.d.ts +10 -0
  103. package/dist/workspace-store.js +47 -0
  104. package/dist/workspace-store.js.map +1 -0
  105. package/package.json +55 -0
package/PURPOSE.md ADDED
@@ -0,0 +1,73 @@
1
+ # @amalgm/shell — Purpose
2
+
3
+ The boot shell is the runtime rebuilt from lego bricks. It owns nothing but
4
+ composition: process boot, host adapters, and the wiring that hands each
5
+ published `@amalgm/*` SDK its dependencies. Every law lives in a brick; the
6
+ shell only assembles.
7
+
8
+ ## Axioms
9
+
10
+ 1. **The shell composes; it never implements.** If the shell needs a behavior,
11
+ that behavior belongs in a brick (or in `@amalgm/core` if it is kernel law).
12
+ The shell may only wire adapters, pass configuration, and mount routes.
13
+
14
+ 2. **Bricks arrive through the registry.** Every `@amalgm/*` dependency is a
15
+ published npm version — never a `file:` link, never a copied source tree.
16
+ Upgrading the runtime means bumping a version, not merging code.
17
+
18
+ 3. **Parity gates each released service.** The target begins with
19
+ `amalgm-engine`'s runtime surface, then subtracts only owner-approved
20
+ retirements. A service enters the signed Shell release only when its active
21
+ surface answers the same requests the same way. Unreleased services may
22
+ remain in the Engine, but they never run as a fallback beside a released
23
+ Shell service.
24
+
25
+ 4. **One host, injected once.** Filesystem, sqlite, clock, network — the shell
26
+ builds each host adapter a single time at boot and threads it down. No brick
27
+ reaches for `process` or the disk on its own.
28
+
29
+ 5. **Bricks never update themselves; the shell updates.** Every `@amalgm/*`
30
+ dependency is pinned to an exact version — no ranges. Publishing a brick
31
+ changes nothing on any user machine until the shell bumps its pin and ships
32
+ a new release through the existing npm dist-tag rail (one runtime label, one
33
+ tag). One version number, one atomic update, one combination that was
34
+ actually tested together — never a per-brick drift of versions in the wild.
35
+
36
+ 6. **Authentication exemptions transfer authority; they do not remove it.**
37
+ Every exempt prefix is explicit and narrow, and the mounted brick must
38
+ authenticate the request with its own session-scoped credential before any
39
+ effect runs.
40
+
41
+ 7. **Retirement is measured, not hidden.** A retired Engine surface stays in
42
+ the committed retirement ledger and is excluded from both routing and the
43
+ active parity denominator. Removing a dead contract must never look like
44
+ serving it.
45
+
46
+ 8. **The shell is the production runtime for its signed release.** The `amalgm`
47
+ bootstrap may install, supervise, and update the shell, but it never starts
48
+ an Engine implementation of Core or Files beside it or falls back to copied
49
+ Engine behavior. The current release is deliberately Core + Files only.
50
+
51
+ 9. **Login is Core followed by Live.** Core owns authentication, credential
52
+ separation, installation verification, restart proof, and readiness. Its
53
+ mandatory Files step is one `@amalgm/live` user-ground convergence call;
54
+ the shell supplies filesystem, SQLite, Watch, and cloud-wire effects only.
55
+
56
+ 10. **One wire reaches the existing authority.** The shell's Live adapter uses
57
+ the authenticated `/wire` private-resource protocol already backed by
58
+ Postgres and R2. A test-only bucket, local cloud, or parallel HTTP authority
59
+ cannot become the production path.
60
+
61
+ 11. **A clean account is the cutover examination.** Two isolated Fly machines
62
+ log into the same previously unused account. Machine A conditionally
63
+ publishes the complete user ground; machine B materializes the same UUID
64
+ graph and bytes into a different local SQLite database before Watch. No
65
+ legacy Amalgm directory is mounted into either machine.
66
+
67
+ ## Relationship to amalgm-engine
68
+
69
+ Stage 1 cut the bricks out of the engine. Stage 2 proves them here, composed.
70
+ Stage 3 ships each signed service from this shell and retires its Engine copy.
71
+ The first production release is the closed Core + Files login/registration
72
+ slice; later services cross the same parity gate without creating a second
73
+ runtime for anything already released.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # amalgm-shell
2
+
3
+ The Amalgm runtime, assembled from published `@amalgm/*` SDK bricks instead of
4
+ the monolith. This repo is the composition and parity ground for the
5
+ lego-driven rewrite of `amalgm-engine` — see [PURPOSE.md](PURPOSE.md) for the
6
+ axioms.
7
+
8
+ The first signed production release is intentionally Core + Files: Core owns
9
+ machine login and readiness, Live owns the portable entity graph, and Shell
10
+ injects the real filesystem, SQLite, watcher, and authenticated cloud wire.
11
+
12
+ ## Layout
13
+
14
+ - `src/boot.ts` — assembles the HTTP/MCP runtime from bricks.
15
+ - `src/machine-host.ts` — production effects injected into Core's machine setup.
16
+ - `src/user-ground-host.ts` — production effects injected into Live registration.
17
+ - `src/wire-client.ts` — the single authenticated gateway/R2 authority path.
18
+ - `tests/` — parity, adapter, restart, watcher, and two-device examinations.
19
+
20
+ ## Run
21
+
22
+ ```bash
23
+ npm install
24
+ npm test
25
+
26
+ # First machine: browser approval or a setup code
27
+ npx amalgm-shell login --no-open
28
+
29
+ # Resume one user on a machine that has several
30
+ npx amalgm-shell run --user person@example.com
31
+ ```
32
+
33
+ Requires Node ≥ 20.19 (native `require(esm)` support; all bricks are ESM).
@@ -0,0 +1,19 @@
1
+ import type { AutomationCrudService, AutomationPrincipal } from "@amalgm/automations";
2
+ import type { BrickMount } from "./gateway.js";
3
+ export interface AutomationsHostConfig {
4
+ service: AutomationCrudService;
5
+ /** Identity resolution — a host capability. Defaults to the local single user. */
6
+ principal?: (request: Request) => Promise<AutomationPrincipal>;
7
+ /** Fixed identity used only for portable bundle export/install. */
8
+ bundlePrincipal?: AutomationPrincipal;
9
+ /** Recipient target for installed bundle automations; never inferred. */
10
+ bundleTargetId?: string;
11
+ }
12
+ export declare function automationPrincipal(config: AutomationsHostConfig, request: Request): Promise<AutomationPrincipal>;
13
+ /**
14
+ * The automations control plane on the engine's /automations prefix.
15
+ * The brick's API speaks fetch (Request → Response) rooted at
16
+ * /v1/automations; this mount adapts node sockets and re-roots the
17
+ * engine prefix onto the brick's, nothing more.
18
+ */
19
+ export declare function automationsMount(config: AutomationsHostConfig): BrickMount;
@@ -0,0 +1,41 @@
1
+ import { createAutomationApi } from "@amalgm/automations";
2
+ const LOCAL_PRINCIPAL = { userId: "local", scopes: ["*"] };
3
+ export function automationPrincipal(config, request) {
4
+ return config.principal ? config.principal(request) : Promise.resolve(LOCAL_PRINCIPAL);
5
+ }
6
+ /**
7
+ * The automations control plane on the engine's /automations prefix.
8
+ * The brick's API speaks fetch (Request → Response) rooted at
9
+ * /v1/automations; this mount adapts node sockets and re-roots the
10
+ * engine prefix onto the brick's, nothing more.
11
+ */
12
+ export function automationsMount(config) {
13
+ const api = createAutomationApi({
14
+ service: config.service,
15
+ authenticate: (request) => automationPrincipal(config, request),
16
+ });
17
+ return {
18
+ prefix: "/automations",
19
+ stream: async (req, res, pathname) => {
20
+ const url = new URL(req.url ?? "/", "http://localhost");
21
+ const headers = {};
22
+ for (const [name, value] of Object.entries(req.headers)) {
23
+ if (typeof value === "string")
24
+ headers[name] = value;
25
+ }
26
+ const chunks = [];
27
+ for await (const chunk of req)
28
+ chunks.push(chunk);
29
+ const method = req.method ?? "GET";
30
+ const request = new Request(`http://automations.local/v1${pathname}${url.search}`, {
31
+ method,
32
+ headers,
33
+ body: chunks.length && method !== "GET" && method !== "HEAD" ? Buffer.concat(chunks) : undefined,
34
+ });
35
+ const response = await api(request);
36
+ res.writeHead(response.status, Object.fromEntries(response.headers.entries()));
37
+ res.end(Buffer.from(await response.arrayBuffer()));
38
+ },
39
+ };
40
+ }
41
+ //# sourceMappingURL=automations-host.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automations-host.js","sourceRoot":"","sources":["../src/automations-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAe1D,MAAM,eAAe,GAAwB,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC;AAEhF,MAAM,UAAU,mBAAmB,CACjC,MAA6B,EAC7B,OAAgB;IAEhB,OAAO,MAAM,CAAC,SAAS,CAAC,C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AAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;aACjG,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC;YACpC,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAC/E,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QACrD,CAAC;KACF,CAAC;AACJ,CAAC"}
package/dist/boot.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import type { Server } from "node:http";
2
+ import { Agents } from "@amalgm/agents";
3
+ import type { Apps } from "@amalgm/apps";
4
+ import { StateRail } from "@amalgm/core/state";
5
+ import { Notifications } from "@amalgm/tools";
6
+ import type { EmailDelivery, Toolbox } from "@amalgm/tools";
7
+ import type { PtySessionManager } from "@amalgm/core/pty";
8
+ import { WorkspaceRegistry } from "@amalgm/live/workspace";
9
+ import type { AutomationsHostConfig } from "./automations-host.js";
10
+ import { ChatHost } from "./chat-host.js";
11
+ import type { ChatDriver } from "./chat-host.js";
12
+ import type { ChatRelayHostConfig } from "./chat-relay-host.js";
13
+ import type { ShellConfig } from "./compose.js";
14
+ import type { AutomationEventsHostConfig } from "./events-host.js";
15
+ import type { BrickMount } from "./gateway.js";
16
+ export interface BootConfig extends ShellConfig {
17
+ /** Turn execution capability; when present the chat service mounts. */
18
+ chatDriver?: ChatDriver;
19
+ /** Chat relay contract/network ports; destinations remain contract-bound. */
20
+ chatRelay?: Partial<Omit<ChatRelayHostConfig, "turnForSession">>;
21
+ /** Automations storage capability; when present /automations mounts. */
22
+ automations?: AutomationsHostConfig;
23
+ /** Automations delivery capability; when present /events mounts. */
24
+ automationEvents?: AutomationEventsHostConfig;
25
+ /** Outbound notification channels; proxy email env is the default adapter. */
26
+ notifications?: {
27
+ email?: EmailDelivery;
28
+ };
29
+ }
30
+ export interface BootedShell {
31
+ readonly gateway: Server;
32
+ readonly stateDirs: Record<string, string>;
33
+ readonly mounts: readonly BrickMount[];
34
+ readonly chat: ChatHost | null;
35
+ readonly agents: Agents;
36
+ readonly apps: Apps;
37
+ readonly toolbox: Toolbox;
38
+ readonly notifications: Notifications;
39
+ readonly state: StateRail;
40
+ readonly workspace: WorkspaceRegistry;
41
+ readonly pty: PtySessionManager;
42
+ /** Close the gateway and every internal brick server. */
43
+ close(): Promise<void>;
44
+ }
45
+ /**
46
+ * Boot the shell: identity law hands every brick its state dir, each
47
+ * brick's surface mounts on its engine prefix, and kernel law guards
48
+ * the door. Bricks that ship their own HTTP server (agents, browser)
49
+ * run on loopback and are forwarded to — the engine's own
50
+ * prefix-to-service-port architecture, applied in-process.
51
+ * Composition only — no brick behavior is defined here.
52
+ */
53
+ export declare function bootShell(config?: BootConfig): Promise<BootedShell>;
package/dist/boot.js ADDED
@@ -0,0 +1,249 @@
1
+ import { randomBytes } from "node:crypto";
2
+ import { homedir } from "node:os";
3
+ import { join } from "node:path";
4
+ import { Agents, listAgentConfigs } from "@amalgm/agents";
5
+ import { createRestServer } from "@amalgm/agents/http";
6
+ import { createMcpServer as createAgentsMcp } from "@amalgm/agents/mcp";
7
+ import { createMcpServer as createAppsMcp } from "@amalgm/apps";
8
+ import { createAppsHttpServer } from "@amalgm/apps/http";
9
+ import { createBrowser } from "@amalgm/browser";
10
+ import { createBrowserHttpServer } from "@amalgm/browser/http";
11
+ import { createBrowserMcpServer } from "@amalgm/browser/mcp";
12
+ import { runtimeTokenFromEnv } from "@amalgm/core/transport";
13
+ import { coerceRuntimeLabel, runtimeLogDir, runtimeStateDir, userMachineDir } from "@amalgm/core/identity";
14
+ import { StateRail } from "@amalgm/core/state";
15
+ import { Notifications, createMcpServer as createToolsMcp, createNotificationsDriver, createProxyEmailDelivery, notificationToolDefinition, } from "@amalgm/tools";
16
+ import { createNotificationsHttpServer, createToolboxHttpServer } from "@amalgm/tools/http";
17
+ import { WorkspaceRegistry } from "@amalgm/live/workspace";
18
+ import { automationsMount } from "./automations-host.js";
19
+ import { ChatHost } from "./chat-host.js";
20
+ import { createShellBundlePort } from "./bundle-port.js";
21
+ import { chatPayloadsMount } from "./chat-payloads-host.js";
22
+ import { composeShell } from "./compose.js";
23
+ import { credentialsMounts } from "./credentials-host.js";
24
+ import { forwardMount } from "./forward.js";
25
+ import { eventTriggersMount } from "./event-triggers-host.js";
26
+ import { diagnosticsMount } from "./diagnostics-host.js";
27
+ import { automationEventsMount } from "./events-host.js";
28
+ import { createExternalProxyHost } from "./external-proxy-host.js";
29
+ import { createGateway } from "./gateway.js";
30
+ import { createPtyHost } from "./pty-host.js";
31
+ import { portsMounts } from "./ports-host.js";
32
+ import { localMount } from "./local-host.js";
33
+ import { stateMount } from "./state-host.js";
34
+ import { FileStateEventStore } from "./state-store.js";
35
+ import { workspaceMount, workspacePathHost } from "./workspace-host.js";
36
+ import { FileWorkspaceStore } from "./workspace-store.js";
37
+ /**
38
+ * Boot the shell: identity law hands every brick its state dir, each
39
+ * brick's surface mounts on its engine prefix, and kernel law guards
40
+ * the door. Bricks that ship their own HTTP server (agents, browser)
41
+ * run on loopback and are forwarded to — the engine's own
42
+ * prefix-to-service-port architecture, applied in-process.
43
+ * Composition only — no brick behavior is defined here.
44
+ */
45
+ export async function bootShell(config = {}) {
46
+ const { stateDirs, userDir, deviceId } = composeShell(config);
47
+ const env = config.env ?? process.env;
48
+ const token = config.runtimeToken ?? runtimeTokenFromEnv(env) ?? "shell-internal";
49
+ const home = config.homedir ?? homedir();
50
+ const pty = createPtyHost({ env, defaultCwd: home });
51
+ const runtimeDir = env.AMALGM_RUNTIME_STATE_DIR || runtimeStateDir(userDir, deviceId, coerceRuntimeLabel(env.AMALGM_RUNTIME_LABEL || env.AMALGM_BRANCH));
52
+ const logDir = env.AMALGM_LOG_DIR || runtimeLogDir(runtimeDir);
53
+ const state = new StateRail({
54
+ store: new FileStateEventStore(`${stateDirs.system}/state-events.jsonl`),
55
+ });
56
+ const workspaceRoot = env.AMALGM_WORKSPACES_DIR
57
+ ? workspacePathHost.resolve(env.AMALGM_WORKSPACES_DIR)
58
+ : stateDirs.workspaces;
59
+ const workspace = new WorkspaceRegistry({
60
+ store: new FileWorkspaceStore(`${stateDirs.system}/workspaces.json`),
61
+ paths: workspacePathHost,
62
+ computerId: env.AMALGM_COMPUTER_ID || "local-computer",
63
+ workspaceRoot,
64
+ now: () => new Date(),
65
+ randomBytes,
66
+ onEvent: (event) => state.append(event),
67
+ });
68
+ const emailDelivery = config.notifications?.email ?? emailDeliveryFromEnv(env);
69
+ const notifications = new Notifications(emailDelivery ? { email: emailDelivery } : {});
70
+ const tools = createToolsMcp({
71
+ stateDir: stateDirs.toolbox,
72
+ systemTools: [notificationToolDefinition()],
73
+ drivers: [createNotificationsDriver(notifications)],
74
+ onChange: (catalog) => {
75
+ state.append({ resource: "toolbox", op: "replace", value: catalog, source: "toolbox" });
76
+ state.append({ resource: "tools", op: "replace", value: catalog.tools, source: "toolbox" });
77
+ state.append({ resource: "tool_actions", op: "replace", value: catalog.actions, source: "toolbox" });
78
+ },
79
+ });
80
+ const apps = createAppsMcp({
81
+ stateDir: stateDirs.apps,
82
+ onChange: (app) => state.append({
83
+ resource: "apps",
84
+ op: "deleted" in app ? "delete" : "update",
85
+ id: app.id,
86
+ ...("deleted" in app ? {} : { value: app }),
87
+ source: "apps",
88
+ }),
89
+ });
90
+ const agentsService = new Agents({ stateDir: stateDirs.agents });
91
+ const agents = createAgentsMcp({ agents: agentsService });
92
+ const browserService = createBrowser({ root: stateDirs.browser });
93
+ const browser = createBrowserMcpServer(browserService);
94
+ state.registerResource("agents", {
95
+ snapshotDefault: true,
96
+ read: () => agentsService.listAgents(),
97
+ });
98
+ state.registerResource("agent_configs", {
99
+ snapshotDefault: true,
100
+ read: () => listAgentConfigs(agentsService),
101
+ });
102
+ state.registerResource("apps", { snapshotDefault: true, read: () => apps.apps.list() });
103
+ const toolboxCatalog = (context) => {
104
+ context.toolboxCatalog ??= tools.toolbox.catalog();
105
+ return context.toolboxCatalog;
106
+ };
107
+ state.registerResource("toolbox", { snapshotDefault: true, read: toolboxCatalog });
108
+ state.registerResource("tools", {
109
+ snapshotDefault: true,
110
+ read: (context) => toolboxCatalog(context).tools,
111
+ });
112
+ state.registerResource("tool_actions", {
113
+ snapshotDefault: true,
114
+ read: (context) => toolboxCatalog(context).actions,
115
+ });
116
+ state.registerResource("projects", { snapshotDefault: true, read: () => workspace.list() });
117
+ state.registerResource("workspaces", { snapshotDefault: true, read: () => workspace.list() });
118
+ const bundlePrincipal = config.automations?.bundlePrincipal
119
+ ?? (config.automations && !config.automations.principal
120
+ ? { userId: "local", scopes: ["*"] }
121
+ : null);
122
+ const bundlePort = createShellBundlePort({
123
+ apps: apps.apps,
124
+ toolbox: tools.toolbox,
125
+ ...(config.automations && bundlePrincipal ? {
126
+ automations: {
127
+ crud: config.automations.service.for(bundlePrincipal),
128
+ ...(config.automations.bundleTargetId ? { targetId: config.automations.bundleTargetId } : {}),
129
+ },
130
+ } : {}),
131
+ });
132
+ const agentsRest = createRestServer({
133
+ agents: agentsService,
134
+ ...(config.homedir ? { skillRoots: { homeDir: config.homedir } } : {}),
135
+ ...(config.homedir ? { nativeHomeDir: config.homedir } : {}),
136
+ bundlePort,
137
+ });
138
+ const agentsAddr = await agentsRest.listen(0, "127.0.0.1");
139
+ const appsHttp = createAppsHttpServer(apps.apps);
140
+ const appsAddr = await appsHttp.listen(0, "127.0.0.1");
141
+ const browserHttp = createBrowserHttpServer({ browser: browserService, token });
142
+ const browserAddr = await browserHttp.listen(0, "127.0.0.1");
143
+ const toolsHttp = createToolboxHttpServer({ toolbox: tools.toolbox });
144
+ const toolsAddr = await toolsHttp.listen(0, "127.0.0.1");
145
+ const notificationsHttp = createNotificationsHttpServer({ notifications });
146
+ const notificationsAddr = await notificationsHttp.listen(0, "127.0.0.1");
147
+ const chat = config.chatDriver ? new ChatHost({
148
+ driver: config.chatDriver,
149
+ relay: {
150
+ ...config.chatRelay,
151
+ proxyCredentials: config.chatRelay?.proxyCredentials ?? (async () => {
152
+ const baseUrl = String(env.AMALGM_PROXY_URL || "").trim();
153
+ const proxyToken = String(env.AMALGM_PROXY_TOKEN || "").trim();
154
+ if (!baseUrl || !proxyToken)
155
+ throw new Error("Chat egress proxy credentials are not configured");
156
+ return { baseUrl, token: proxyToken };
157
+ }),
158
+ },
159
+ }) : null;
160
+ // The gateway port is only known after listen(); mounts read it lazily.
161
+ const ref = { gateway: null };
162
+ const gatewayPort = () => {
163
+ const address = ref.gateway?.address();
164
+ return address && typeof address === "object" ? address.port : null;
165
+ };
166
+ const externalProxy = createExternalProxyHost({
167
+ apps: apps.apps,
168
+ gatewayPort,
169
+ localAgentAppPort: optionalPort(env.AMALGM_LOCAL_APP_PORT),
170
+ });
171
+ const mounts = [
172
+ { prefix: "/mcp/tools", handle: (request) => tools.handle(request) },
173
+ { prefix: "/mcp/apps", handle: (request) => apps.handle(request) },
174
+ { prefix: "/mcp/agents", handle: (request) => agents.handle(request) },
175
+ { prefix: "/mcp/browser", handle: (request) => browser.handle(request) },
176
+ forwardMount("/agents", () => agentsAddr.port, { root: "/v1" }),
177
+ forwardMount("/agent-config", () => agentsAddr.port, { root: "/agent-config" }),
178
+ forwardMount("/agent-bundles", () => agentsAddr.port, { root: "/agent-bundles" }),
179
+ forwardMount("/skills", () => agentsAddr.port, { root: "/skills" }),
180
+ forwardMount("/browser", () => browserAddr.port, { root: "/v1" }),
181
+ forwardMount("/toolbox", () => toolsAddr.port, { root: "/toolbox" }),
182
+ forwardMount("/email", () => notificationsAddr.port, { root: "/email" }),
183
+ forwardMount("/apps", () => appsAddr.port, { root: "/apps" }),
184
+ forwardMount("/artifacts", () => appsAddr.port, { root: "/artifacts" }),
185
+ chatPayloadsMount(stateDirs.system),
186
+ ...portsMounts(gatewayPort),
187
+ ...(chat ? chat.mounts() : []),
188
+ ...(config.automations ? [automationsMount(config.automations)] : []),
189
+ ...(config.automations ? [eventTriggersMount(config.automations)] : []),
190
+ ...(config.automationEvents ? [automationEventsMount(config.automationEvents)] : []),
191
+ stateMount(state),
192
+ workspaceMount(workspace, workspaceRoot),
193
+ localMount({ home, env, amalgmPath: userDir, workspaceRoot }),
194
+ ...credentialsMounts(join(userMachineDir(userDir, deviceId), "credentials")),
195
+ pty.mount,
196
+ diagnosticsMount(logDir),
197
+ externalProxy.mount,
198
+ ];
199
+ const gateway = createGateway({
200
+ env,
201
+ mounts,
202
+ upgrades: [pty.upgrade, externalProxy.upgrade],
203
+ exemptPrefixes: ["/egress/"],
204
+ });
205
+ ref.gateway = gateway;
206
+ return {
207
+ gateway,
208
+ stateDirs,
209
+ mounts,
210
+ chat,
211
+ agents: agentsService,
212
+ apps: apps.apps,
213
+ toolbox: tools.toolbox,
214
+ notifications,
215
+ state,
216
+ workspace,
217
+ pty: pty.manager,
218
+ async close() {
219
+ pty.close();
220
+ externalProxy.close();
221
+ const gatewayClosed = new Promise((resolve) => gateway.close(() => resolve()));
222
+ gateway.closeAllConnections();
223
+ await Promise.all([
224
+ gatewayClosed,
225
+ agentsRest.close(),
226
+ appsHttp.close(),
227
+ browserHttp.close(),
228
+ toolsHttp.close(),
229
+ notificationsHttp.close(),
230
+ ]);
231
+ await agentsService.close();
232
+ await apps.apps.close();
233
+ tools.toolbox.close();
234
+ },
235
+ };
236
+ }
237
+ function optionalPort(value) {
238
+ const raw = String(value || "").trim();
239
+ if (!raw)
240
+ return null;
241
+ const port = Number.parseInt(raw, 10);
242
+ return Number.isInteger(port) && port > 0 && port <= 65535 ? port : null;
243
+ }
244
+ function emailDeliveryFromEnv(env) {
245
+ const baseUrl = String(env.AMALGM_PROXY_URL || "").trim();
246
+ const token = String(env.AMALGM_PROXY_TOKEN || "").trim();
247
+ return baseUrl && token ? createProxyEmailDelivery({ baseUrl, token }) : undefined;
248
+ }
249
+ //# sourceMappingURL=boot.js.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IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC3E,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAsB;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,OAAO,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,wBAAwB,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACrF,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { Apps } from "@amalgm/apps";
2
+ type Json = Record<string, any>;
3
+ export declare function exportBundleApp(apps: Apps, appId: string): {
4
+ entry: Json;
5
+ sourceDir: string;
6
+ };
7
+ export declare function installBundleApps(apps: Apps, entries: Json[]): Promise<{
8
+ installed: Json[];
9
+ directories: Map<string, string>;
10
+ ids: Map<string, string>;
11
+ }>;
12
+ export {};
@@ -0,0 +1,71 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { unpackPackage } from "@amalgm/apps";
4
+ function slug(value) {
5
+ return String(value || "app").toLowerCase().replace(/[^a-z0-9._-]+/g, "-")
6
+ .replace(/^-+|-+$/g, "").slice(0, 60) || "app";
7
+ }
8
+ function allocate(root, name) {
9
+ fs.mkdirSync(root, { recursive: true });
10
+ const base = slug(name);
11
+ for (let index = 0; index < 1000; index += 1) {
12
+ const candidate = path.join(root, index ? `${base}-${index + 1}` : base);
13
+ if (!fs.existsSync(candidate))
14
+ return candidate;
15
+ }
16
+ throw new Error(`Could not allocate an install directory for app: ${String(name)}`);
17
+ }
18
+ export function exportBundleApp(apps, appId) {
19
+ const app = apps.get(appId);
20
+ if (!app)
21
+ throw new Error(`App not found: ${appId}`);
22
+ const packed = apps.pack(app.sourceDir);
23
+ return {
24
+ entry: {
25
+ sourceAppId: app.id,
26
+ manifest: packed.manifest,
27
+ app: {
28
+ name: packed.manifest.name,
29
+ description: packed.manifest.description,
30
+ buildCommand: packed.manifest.buildCommand,
31
+ startCommand: packed.manifest.startCommand,
32
+ autostart: true,
33
+ keepAlive: true,
34
+ },
35
+ toolIds: packed.manifest.toolIds,
36
+ files: packed.files,
37
+ totalBytes: packed.totalBytes,
38
+ skipped: packed.excluded,
39
+ },
40
+ sourceDir: app.sourceDir,
41
+ };
42
+ }
43
+ export async function installBundleApps(apps, entries) {
44
+ const installed = [];
45
+ const directories = new Map();
46
+ const ids = new Map();
47
+ const root = path.join(apps.stateDir, "imports");
48
+ for (const entry of entries) {
49
+ if (!Array.isArray(entry.files) || !entry.files.length)
50
+ throw new Error("app entry must include files");
51
+ const directory = allocate(root, entry.manifest?.name || entry.app?.name);
52
+ try {
53
+ unpackPackage({ files: entry.files }, directory);
54
+ const inspected = apps.validate(directory);
55
+ if (entry.manifest && JSON.stringify(inspected.manifest) !== JSON.stringify(entry.manifest)) {
56
+ throw new Error("App bundle manifest summary does not match amalgm.app.json");
57
+ }
58
+ const app = await apps.register({ cwd: directory, autostart: true, keepAlive: true });
59
+ const sourceId = String(entry.sourceAppId || "");
60
+ directories.set(sourceId, directory);
61
+ ids.set(sourceId, app.id);
62
+ installed.push(JSON.parse(JSON.stringify(app)));
63
+ }
64
+ catch (error) {
65
+ fs.rmSync(directory, { recursive: true, force: true });
66
+ throw error;
67
+ }
68
+ }
69
+ return { installed, directories, ids };
70
+ }
71
+ //# sourceMappingURL=bundle-apps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle-apps.js","sourceRoot":"","sources":["../src/bundle-apps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAK7C,SAAS,IA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,CAAC,CAAC;YAClE,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YAC3C,IAAI,KAAK,CAAC,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAuB,CAAC,EAAE,CAAC;gBAC3G,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;YAChF,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YACtF,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;YACjD,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YACrC,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;YAC1B,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACvD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;AACzC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { AutomationCrud } from "@amalgm/automations";
2
+ type Json = Record<string, any>;
3
+ export declare function exportBundleAutomation(crud: AutomationCrud, automationId: string): Promise<{
4
+ entry: Json;
5
+ toolIds: string[];
6
+ }>;
7
+ export declare function installBundleAutomations(crud: AutomationCrud, entries: Json[], targetId: string): Promise<Json[]>;
8
+ export {};