@amalgm/tools 0.1.5 → 0.1.6

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 (43) hide show
  1. package/PURPOSE.md +58 -26
  2. package/README.md +36 -10
  3. package/dist/apply-definition.d.ts +12 -0
  4. package/dist/apply-definition.js +33 -0
  5. package/dist/artifact-files.d.ts +3 -1
  6. package/dist/artifact-files.js +11 -3
  7. package/dist/artifacts.d.ts +8 -6
  8. package/dist/artifacts.js +19 -6
  9. package/dist/definition.js +10 -0
  10. package/dist/deployment-files.d.ts +10 -0
  11. package/dist/deployment-files.js +38 -0
  12. package/dist/deployment-types.d.ts +32 -0
  13. package/dist/deployment-types.js +1 -0
  14. package/dist/deployments.d.ts +19 -0
  15. package/dist/deployments.js +98 -0
  16. package/dist/host-mcp-tool.d.ts +8 -0
  17. package/dist/host-mcp-tool.js +40 -0
  18. package/dist/http.js +6 -1
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.js +3 -1
  21. package/dist/mcp-server.d.ts +2 -1
  22. package/dist/mcp-server.js +3 -2
  23. package/dist/mcp.d.ts +2 -1
  24. package/dist/mcp.js +33 -21
  25. package/dist/notifications.js +4 -3
  26. package/dist/schema.js +15 -0
  27. package/dist/store.d.ts +17 -4
  28. package/dist/store.js +105 -41
  29. package/dist/toolbox-deployments.d.ts +30 -0
  30. package/dist/toolbox-deployments.js +125 -0
  31. package/dist/toolbox-projection.d.ts +13 -0
  32. package/dist/toolbox-projection.js +41 -0
  33. package/dist/toolbox-view.d.ts +35 -0
  34. package/dist/toolbox-view.js +75 -0
  35. package/dist/toolbox.d.ts +13 -5
  36. package/dist/toolbox.js +90 -114
  37. package/dist/types.d.ts +30 -1
  38. package/dist/updates.d.ts +2 -1
  39. package/dist/updates.js +12 -1
  40. package/docs/ENGINE_INTEGRATION.md +10 -54
  41. package/docs/SHELL_INTEGRATION.md +44 -0
  42. package/package.json +3 -2
  43. package/skills/tools/SKILL.md +185 -0
@@ -0,0 +1,44 @@
1
+ # Shell integration
2
+
3
+ `@amalgm/tools` is the canonical Toolbox product. `@amalgm/shell` constructs
4
+ one Toolbox for a machine user, supplies its machine-local SQLite path and
5
+ portable deployment directory, and mounts the product's public HTTP and MCP
6
+ adapters.
7
+
8
+ ## Tools owns
9
+
10
+ - stable tool and action identity;
11
+ - immutable deployment history and current deployment heads;
12
+ - loadout selection and deterministic MCP names;
13
+ - CLI and API drivers, validation, cancellation, and output bounds;
14
+ - the Toolbox management MCP surface; and
15
+ - the versioned `deployment.activate` Live surface.
16
+
17
+ ## Shell owns
18
+
19
+ - the exact `@amalgm/tools` package version in the Shell release;
20
+ - the one host MCP driver and authenticated loopback routes;
21
+ - machine-local SQLite placement and the portable deployment directory;
22
+ - execution-time credential resolution;
23
+ - projection of owning products' official MCP descriptors as immutable system
24
+ tools; and
25
+ - binding Tools' deployment surface to broader product state when enabled.
26
+
27
+ Agents stores loadout identifiers; Chat pins the exact Toolbox `revisionId`
28
+ during preparation. Neither product writes Tools persistence.
29
+
30
+ ## First-party products and Channels
31
+
32
+ Shell builds first-party records from the official MCP descriptors exported by
33
+ Agents, Apps, Automations, Browser, Channels, Chat, and Tools. Selecting a
34
+ record controls capability; it does not transfer ownership of the underlying
35
+ product to Tools.
36
+
37
+ Channels owns current notification validation and durable delivery. The
38
+ `Notifications` class still exported by Tools is a legacy compatibility
39
+ adapter and is not the path Shell uses for the Channels product.
40
+
41
+ ## Engine evidence
42
+
43
+ Engine may be read to compare legacy Toolbox, MCP-connection, `/email`, or
44
+ notification shapes. It is never composed or copied into the active runtime.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amalgm/tools",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Local-first tool definitions, Toolbox registry, and agent execution surfaces.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
@@ -36,7 +36,8 @@
36
36
  "docs",
37
37
  "dist",
38
38
  "PURPOSE.md",
39
- "README.md"
39
+ "README.md",
40
+ "skills"
40
41
  ],
41
42
  "scripts": {
42
43
  "build": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && tsx scripts/mark-executables.ts",
@@ -0,0 +1,185 @@
1
+ ---
2
+ name: tools
3
+ description: Define, deploy, select, and execute stable Amalgm tools through @amalgm/tools. Use when creating CLI, API, or MCP tool definitions; managing immutable tool deployments and loadouts; projecting tools into MCP; resolving secrets at call time; or inspecting the local Toolbox catalog.
4
+ ---
5
+
6
+ # Amalgm Tools
7
+
8
+ Tools is the capability layer between an agent and the things it can do. It
9
+ gives every tool and action a stable identity, stores user-authored tools as
10
+ immutable deployments, selects bounded loadouts for a run, and executes CLI,
11
+ HTTP API, or MCP actions through one result contract. It works as a standalone
12
+ ESM package and is also composed into the Amalgm machine runtime.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @amalgm/tools
18
+ ```
19
+
20
+ Node.js 20 or newer is required. The package exposes:
21
+
22
+ - `@amalgm/tools` for definitions, the `Toolbox`, deployments, MCP projection,
23
+ ids, and driver contracts.
24
+ - `@amalgm/tools/mcp` for MCP helpers.
25
+ - `@amalgm/tools/http` for the read-only Toolbox HTTP adapter.
26
+ - `amalgm-tools` for local catalog management and execution.
27
+ - `amalgm-tools-mcp` for a newline-delimited stdio MCP server.
28
+
29
+ ## Define and run a tool
30
+
31
+ ```js
32
+ import { defineTool, Toolbox } from '@amalgm/tools';
33
+
34
+ const toolbox = new Toolbox({ stateDir: './.tools' });
35
+
36
+ await toolbox.apply(defineTool({
37
+ id: 'hello',
38
+ name: 'Hello',
39
+ source: {
40
+ type: 'cli',
41
+ command: 'node',
42
+ inputMode: 'json-stdin',
43
+ outputMode: 'json',
44
+ },
45
+ actions: [{
46
+ name: 'say',
47
+ target: { args: ['./hello.mjs'] },
48
+ inputSchema: {
49
+ type: 'object',
50
+ required: ['name'],
51
+ properties: { name: { type: 'string' } },
52
+ additionalProperties: false,
53
+ },
54
+ }],
55
+ }));
56
+
57
+ const result = await toolbox.call('hello.say', { name: 'Ada' });
58
+ toolbox.close();
59
+ ```
60
+
61
+ The tool id is `hello`; the derived action id is `hello.say`. Those ids are the
62
+ references agents, loadouts, and callers keep. Display names and implementations
63
+ can evolve without changing identity.
64
+
65
+ ## Tool sources
66
+
67
+ Every definition has exactly one source type:
68
+
69
+ - `cli` executes a command directly with `spawn`; no shell is inserted. Choose
70
+ JSON stdin, argv, or no input, and JSON or text output.
71
+ - `api` calls a path beneath one declared same-origin `baseUrl`; redirects are
72
+ refused.
73
+ - `mcp` projects actions from an HTTP, SSE, stdio, or host-mounted MCP server.
74
+ A composing host supplies the MCP driver that owns discovery, sessions, and
75
+ calls.
76
+
77
+ Sources may set `timeoutMs` and `maxOutputBytes`. These bounds travel with the
78
+ definition, so execution policy is visible before the call begins.
79
+
80
+ ## Immutable deployments and state
81
+
82
+ Applying an intentional semantic change creates an immutable deployment
83
+ document and advances the tool's local head atomically. Reapplying equivalent
84
+ bytes resolves to the same content identity. `catalog()` exposes both:
85
+
86
+ - `revision`, a local numeric freshness counter for presentation.
87
+ - `revisionId`, the digest of the exact current user deployments and system
88
+ projections. Use this immutable id when preparing an agent run.
89
+
90
+ By default state resolves through the shared Amalgm state-dir law:
91
+ `AMALGM_TOOLS_DIR`, then `AMALGM_DIR/toolbox`, then the current user's scoped
92
+ Toolbox directory. Pass `stateDir` for a self-contained Toolbox, or separate
93
+ portable deployments from machine-local coordination state:
94
+
95
+ ```js
96
+ const toolbox = new Toolbox({
97
+ deploymentDir: '/amalgm/users/person@example.com/toolbox',
98
+ databaseFile: '/machine-state/services/tools/tools.db',
99
+ });
100
+ ```
101
+
102
+ Deployment documents are portable. The SQLite database, WAL, local index, and
103
+ legacy flat artifacts are projections and should not be synchronized.
104
+
105
+ ## Loadouts
106
+
107
+ A loadout is a list of tool ids that bounds which enabled actions are visible
108
+ and callable for one context:
109
+
110
+ ```js
111
+ const loadout = { toolIds: ['hello', 'browser'] };
112
+ const visible = toolbox.list(loadout);
113
+ const result = await toolbox.call('hello.say', { name: 'Ada' }, { loadout });
114
+ ```
115
+
116
+ Passing no loadout uses the enabled catalog. Passing a loadout makes exclusion
117
+ explicit: an action outside it cannot be reached merely because it exists in
118
+ the Toolbox.
119
+
120
+ ## Secrets
121
+
122
+ Definitions never contain secret values. `secretEnv` and `secretHeaders` hold
123
+ opaque references, and the caller resolves them only for the duration of an
124
+ execution:
125
+
126
+ ```js
127
+ await toolbox.call('billing.lookup', { customerId: 'cus_123' }, {
128
+ resolveSecret: async (reference) => secretStore.get(reference),
129
+ });
130
+ ```
131
+
132
+ This keeps portable definitions and deployment documents safe to inspect and
133
+ synchronize.
134
+
135
+ ## CLI
136
+
137
+ The CLI prints JSON and exits non-zero on failure:
138
+
139
+ ```bash
140
+ amalgm-tools apply ./tool.mjs
141
+ amalgm-tools list
142
+ amalgm-tools catalog
143
+ amalgm-tools show hello.say
144
+ amalgm-tools enable hello.say
145
+ amalgm-tools disable hello.say
146
+ amalgm-tools remove hello
147
+ amalgm-tools run hello.say --input '{"name":"Ada"}'
148
+ amalgm-tools connections
149
+ ```
150
+
151
+ Use `--state-dir DIR` to select a Toolbox and `--loadout one,two` to bound
152
+ `list`, `run`, or connection projection.
153
+
154
+ ## MCP and HTTP surfaces
155
+
156
+ `createMcpTools(toolbox)` projects management operations and enabled actions,
157
+ while `createMcpServer()` creates a complete stdio server. A machine host can
158
+ also use `defineHostMcpTool` to represent another product's official MCP
159
+ descriptors as one system-owned Toolbox record.
160
+
161
+ For read-only dashboards, mount the HTTP adapter:
162
+
163
+ ```js
164
+ import { Toolbox } from '@amalgm/tools';
165
+ import { createToolboxHttpServer } from '@amalgm/tools/http';
166
+
167
+ const toolbox = new Toolbox({ stateDir: './.tools' });
168
+ const server = createToolboxHttpServer({ toolbox });
169
+ await server.listen(8083);
170
+ ```
171
+
172
+ It serves the legacy-compatible `GET /toolbox`, `GET /toolbox/tools?id=...`,
173
+ and `GET /toolbox/actions?id=...` catalog routes. Mutations belong through the
174
+ SDK, CLI, or MCP surface.
175
+
176
+ ## How Tools fits into Amalgam
177
+
178
+ The machine runtime projects the official capabilities from Agents, Apps,
179
+ Automations, Browser, Channels, Chat, and Tools into one Toolbox without moving
180
+ their ownership into Tools. Tools owns identity, deployment, selection, and
181
+ execution; each product continues to own its own behavior and state.
182
+
183
+ Channels is the current owner of durable notifications. The notification
184
+ exports retained by `@amalgm/tools` are compatibility adapters for retired
185
+ notification shapes, not a second delivery system.