@amalgm/tools 0.1.5 → 0.1.7-main.34175698435
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/PURPOSE.md +78 -26
- package/README.md +63 -10
- package/dist/apply-definition.d.ts +12 -0
- package/dist/apply-definition.js +33 -0
- package/dist/artifact-files.d.ts +3 -1
- package/dist/artifact-files.js +11 -3
- package/dist/artifacts.d.ts +8 -6
- package/dist/artifacts.js +19 -6
- package/dist/definition.js +10 -0
- package/dist/deployment-files.d.ts +10 -0
- package/dist/deployment-files.js +38 -0
- package/dist/deployment-types.d.ts +32 -0
- package/dist/deployment-types.js +1 -0
- package/dist/deployments.d.ts +19 -0
- package/dist/deployments.js +98 -0
- package/dist/host-mcp-tool.d.ts +8 -0
- package/dist/host-mcp-tool.js +40 -0
- package/dist/http.js +6 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/mcp-server.d.ts +2 -1
- package/dist/mcp-server.js +3 -2
- package/dist/mcp.d.ts +2 -1
- package/dist/mcp.js +33 -21
- package/dist/notifications.js +4 -3
- package/dist/schema.js +15 -0
- package/dist/store.d.ts +17 -4
- package/dist/store.js +105 -41
- package/dist/toolbox-deployments.d.ts +30 -0
- package/dist/toolbox-deployments.js +125 -0
- package/dist/toolbox-projection.d.ts +13 -0
- package/dist/toolbox-projection.js +41 -0
- package/dist/toolbox-view.d.ts +35 -0
- package/dist/toolbox-view.js +75 -0
- package/dist/toolbox.d.ts +13 -5
- package/dist/toolbox.js +90 -114
- package/dist/types.d.ts +30 -1
- package/dist/updates.d.ts +2 -1
- package/dist/updates.js +12 -1
- package/docs/ENGINE_INTEGRATION.md +10 -54
- package/docs/SHELL_INTEGRATION.md +44 -0
- package/package.json +40 -4
- package/skills/tools/SKILL.md +185 -0
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Writable } from 'node:stream';
|
|
2
|
+
import type { ToolDeploymentActivation } from './deployment-types.js';
|
|
2
3
|
type JsonSchema = {
|
|
3
4
|
type: 'object';
|
|
4
5
|
properties?: Record<string, {
|
|
@@ -41,6 +42,8 @@ interface McpSource extends BaseSource {
|
|
|
41
42
|
args?: string[];
|
|
42
43
|
cwd?: string;
|
|
43
44
|
serverName?: string;
|
|
45
|
+
/** Absolute path mounted by the composing host for `transport: host`. */
|
|
46
|
+
route?: string;
|
|
44
47
|
secretHeaders?: SecretReferences;
|
|
45
48
|
secretEnv?: SecretReferences;
|
|
46
49
|
}
|
|
@@ -109,7 +112,12 @@ interface ActionRecord extends Omit<ActionDefinition, 'id' | 'status' | 'inputSc
|
|
|
109
112
|
}
|
|
110
113
|
interface Catalog {
|
|
111
114
|
version: 1;
|
|
115
|
+
/** Local materialization counter. Never used as immutable authority. */
|
|
112
116
|
revision: number;
|
|
117
|
+
/** Exact digest of current user deployments and system projections. */
|
|
118
|
+
revisionId: string;
|
|
119
|
+
/** Current deployment id per stable user tool, including tombstones. */
|
|
120
|
+
deployments: Record<string, string>;
|
|
113
121
|
tools: ToolRecord[];
|
|
114
122
|
actions: ActionRecord[];
|
|
115
123
|
}
|
|
@@ -151,9 +159,13 @@ interface ToolDriver {
|
|
|
151
159
|
interface ToolboxOptions {
|
|
152
160
|
stateDir?: string;
|
|
153
161
|
databaseFile?: string;
|
|
162
|
+
/** Portable immutable deployment documents; may differ from databaseFile. */
|
|
163
|
+
deploymentDir?: string;
|
|
154
164
|
systemTools?: ToolDefinition[];
|
|
155
165
|
drivers?: ToolDriver[];
|
|
156
166
|
onChange?: (catalog: Catalog) => void | Promise<void>;
|
|
167
|
+
/** Outbound local Live operation. Remote application never calls it. */
|
|
168
|
+
onDeployment?: (activation: ToolDeploymentActivation) => void | Promise<void>;
|
|
157
169
|
}
|
|
158
170
|
interface McpTool {
|
|
159
171
|
name: string;
|
|
@@ -164,9 +176,26 @@ interface McpTool {
|
|
|
164
176
|
interface McpOptions extends CallOptions {
|
|
165
177
|
includeManagement?: boolean;
|
|
166
178
|
}
|
|
179
|
+
interface HostMcpToolDescriptor {
|
|
180
|
+
name: string;
|
|
181
|
+
description?: string;
|
|
182
|
+
inputSchema?: JsonSchema;
|
|
183
|
+
}
|
|
184
|
+
interface HostMcpToolDefinitionInput {
|
|
185
|
+
id: string;
|
|
186
|
+
name: string;
|
|
187
|
+
description?: string;
|
|
188
|
+
serverName: string;
|
|
189
|
+
route: string;
|
|
190
|
+
tools: readonly HostMcpToolDescriptor[];
|
|
191
|
+
owner?: string;
|
|
192
|
+
display?: Record<string, unknown>;
|
|
193
|
+
metadata?: Record<string, unknown>;
|
|
194
|
+
}
|
|
167
195
|
interface CliIo {
|
|
168
196
|
stdout?: Writable;
|
|
169
197
|
stderr?: Writable;
|
|
170
198
|
toolbox?: import('./toolbox.js').Toolbox;
|
|
171
199
|
}
|
|
172
|
-
export type { ActionDefinition, ActionRecord, ActionTarget, ApiSource, ApiTarget, ApplyResult, CallOptions, Catalog, CliIo, CliSource, CliTarget, DriverCall, JsonSchema, Loadout, LoadoutInput, McpOptions, McpSource, McpTarget, McpTool, Origin, SecretResolver, Status, ToolDefinition, ToolDriver, ToolboxOptions, ToolRecord, ToolResult, ToolPatch, ActionPatch, ToolQuery, ToolSource, ToolType, };
|
|
200
|
+
export type { ActionDefinition, ActionRecord, ActionTarget, ApiSource, ApiTarget, ApplyResult, CallOptions, Catalog, CliIo, CliSource, CliTarget, DriverCall, HostMcpToolDefinitionInput, HostMcpToolDescriptor, JsonSchema, Loadout, LoadoutInput, McpOptions, McpSource, McpTarget, McpTool, Origin, SecretResolver, Status, ToolDefinition, ToolDriver, ToolboxOptions, ToolRecord, ToolResult, ToolPatch, ActionPatch, ToolQuery, ToolSource, ToolType, };
|
|
201
|
+
export type { ToolDeployment, ToolDeploymentActivation, ToolDeploymentSnapshot, ToolDeploymentSurface, } from './deployment-types.js';
|
package/dist/updates.d.ts
CHANGED
|
@@ -4,4 +4,5 @@ type UpdatePort = Pick<Toolbox, 'action' | 'apply' | 'get'>;
|
|
|
4
4
|
declare function updateTool(toolbox: UpdatePort, toolId: string, patch: ToolPatch): Promise<ApplyResult>;
|
|
5
5
|
declare function upsertAction(toolbox: UpdatePort, toolId: string, definition: ActionDefinition): Promise<ActionRecord>;
|
|
6
6
|
declare function updateAction(toolbox: UpdatePort, actionId: string, patch: ActionPatch): Promise<ActionRecord>;
|
|
7
|
-
|
|
7
|
+
declare function removeAction(toolbox: UpdatePort, actionId: string): Promise<ActionRecord>;
|
|
8
|
+
export { removeAction, updateAction, updateTool, upsertAction };
|
package/dist/updates.js
CHANGED
|
@@ -54,4 +54,15 @@ async function updateAction(toolbox, actionId, patch) {
|
|
|
54
54
|
metadata: mergedObject(definition.metadata, patch.metadata),
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
async function removeAction(toolbox, actionId) {
|
|
58
|
+
const action = toolbox.action(actionId);
|
|
59
|
+
if (!action)
|
|
60
|
+
throw new Error(`Unknown action: ${actionId}`);
|
|
61
|
+
const current = toolbox.get(action.toolId);
|
|
62
|
+
await toolbox.apply({
|
|
63
|
+
...toolDefinition(current),
|
|
64
|
+
actions: current.actions.filter((candidate) => candidate.id !== actionId).map(actionDefinition),
|
|
65
|
+
});
|
|
66
|
+
return action;
|
|
67
|
+
}
|
|
68
|
+
export { removeAction, updateAction, updateTool, upsertAction };
|
|
@@ -1,57 +1,13 @@
|
|
|
1
|
-
# Engine integration
|
|
1
|
+
# Historical Engine integration
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Amalgm Engine is deprecated. Its Toolbox tables, MCP-connection registry,
|
|
4
|
+
notification adapter, and copied product output are read-only migration and
|
|
5
|
+
parity evidence. They are not active persistence, a source-flow destination,
|
|
6
|
+
or a runtime fallback.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
The old workflow copied generated Tools output into Engine and imported legacy
|
|
9
|
+
records. Active composition now installs the published package in
|
|
10
|
+
`@amalgm/shell`, which supplies host effects and projects other products
|
|
11
|
+
through their official MCP descriptors.
|
|
8
12
|
|
|
9
|
-
|
|
10
|
-
- atomic apply, enable, disable, and removal behavior;
|
|
11
|
-
- loadout selection semantics and deterministic MCP action names;
|
|
12
|
-
- CLI and HTTP API execution drivers and output bounds;
|
|
13
|
-
- SDK, CLI, Toolbox management MCP tools, and action MCP projection;
|
|
14
|
-
- the connection projection consumed by an MCP session host.
|
|
15
|
-
|
|
16
|
-
## Engine owns
|
|
17
|
-
|
|
18
|
-
- first-party action implementations supplied as `systemTools` and drivers;
|
|
19
|
-
- authenticated capability context and the execution-time secret resolver;
|
|
20
|
-
- the long-lived MCP connection/session host;
|
|
21
|
-
- state-event projection, REST shape translation, UI composition, and one-time
|
|
22
|
-
import from Engine's superseded Toolbox tables or JSON file.
|
|
23
|
-
|
|
24
|
-
Agents owns agent records and their loadout ids. Tools treats those ids as
|
|
25
|
-
input to product-owned selection. Neither product is allowed to rewrite the
|
|
26
|
-
other through a Core adapter.
|
|
27
|
-
|
|
28
|
-
Engine adapters call one `Toolbox` instance. They do not write its SQLite
|
|
29
|
-
database or independently normalize, select, name, or execute tool actions.
|
|
30
|
-
An absent loadout must be passed as `undefined`; an explicitly empty loadout
|
|
31
|
-
must be passed as `[]`.
|
|
32
|
-
|
|
33
|
-
For external MCP tools, Engine supplies a `ToolDriver` with type `mcp`. That
|
|
34
|
-
driver delegates to Engine's existing MCP session owner. The Toolbox exposes
|
|
35
|
-
connection definitions through `connections(loadout)` but never starts a
|
|
36
|
-
parallel client or owns the same remote session twice.
|
|
37
|
-
|
|
38
|
-
System tools are injected at construction and remain outside user storage.
|
|
39
|
-
Engine can therefore update its built-in catalog with its own release while
|
|
40
|
-
all standalone Toolbox behavior remains canonical in this package.
|
|
41
|
-
|
|
42
|
-
## Source flow and completed cutover
|
|
43
|
-
|
|
44
|
-
Engine now consumes Tools as follows:
|
|
45
|
-
|
|
46
|
-
1. Build this repository.
|
|
47
|
-
2. Copy generated `dist/`, `PURPOSE.md`, and package metadata into
|
|
48
|
-
`runtime/products/tools/` with a deterministic source manifest.
|
|
49
|
-
3. Mount the package CLI and MCP definitions over Engine's single Toolbox
|
|
50
|
-
service.
|
|
51
|
-
4. Import existing records once, preserving canonical ids and status.
|
|
52
|
-
5. Remove Engine's superseded Toolbox tables after successful import.
|
|
53
|
-
|
|
54
|
-
Product changes begin here. Generated Engine copies are never edited by hand.
|
|
55
|
-
Engine runtime readers and writers use only this product database. The importer
|
|
56
|
-
is the only module allowed to understand the superseded storage shapes, and
|
|
57
|
-
malformed source data blocks destructive cleanup.
|
|
13
|
+
See [SHELL_INTEGRATION.md](./SHELL_INTEGRATION.md) for the current boundary.
|
|
@@ -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.
|
|
3
|
+
"version": "0.1.7-main.34175698435",
|
|
4
4
|
"description": "Local-first tool definitions, Toolbox registry, and agent execution surfaces.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"private": false,
|
|
@@ -36,20 +36,27 @@
|
|
|
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",
|
|
43
44
|
"check": "tsx scripts/check-tree.ts && tsc -p tsconfig.json && tsc -p tsconfig.test.json",
|
|
44
45
|
"test": "tsx --test --test-concurrency=1 --test-timeout=30000 test/*.test.ts",
|
|
45
46
|
"verify": "npm run check && npm run build && npm test",
|
|
46
|
-
"prepack": "npm run build"
|
|
47
|
+
"prepack": "npm run build",
|
|
48
|
+
"release:admit": "node scripts/release/package.mjs admit",
|
|
49
|
+
"release:prepare": "node scripts/release/package.mjs prepare",
|
|
50
|
+
"release:examine": "node scripts/release/package.mjs examine",
|
|
51
|
+
"release:publish": "node scripts/release/package.mjs publish",
|
|
52
|
+
"release:compose": "node scripts/release/compose.mjs",
|
|
53
|
+
"test:release": "node --test scripts/release/*.test.mjs"
|
|
47
54
|
},
|
|
48
55
|
"engines": {
|
|
49
56
|
"node": ">=24"
|
|
50
57
|
},
|
|
51
58
|
"dependencies": {
|
|
52
|
-
"@amalgm/core": "0.4.
|
|
59
|
+
"@amalgm/core": "0.4.8-main.34168902443",
|
|
53
60
|
"better-sqlite3": "^12.6.2"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
@@ -57,5 +64,34 @@
|
|
|
57
64
|
"@types/node": "^20.19.43",
|
|
58
65
|
"tsx": "^4.23.1",
|
|
59
66
|
"typescript": "^5.9.3"
|
|
67
|
+
},
|
|
68
|
+
"amalgmRelease": {
|
|
69
|
+
"schema": 1,
|
|
70
|
+
"workflow": "verify.yml",
|
|
71
|
+
"jobs": [
|
|
72
|
+
"verify"
|
|
73
|
+
],
|
|
74
|
+
"verify": "verify",
|
|
75
|
+
"cli": [
|
|
76
|
+
"amalgm-tools"
|
|
77
|
+
]
|
|
78
|
+
},
|
|
79
|
+
"allowScripts": {
|
|
80
|
+
"better-sqlite3@12.11.1": true,
|
|
81
|
+
"esbuild@0.28.1": true,
|
|
82
|
+
"fsevents@2.3.3": false
|
|
83
|
+
},
|
|
84
|
+
"amalgmComposition": {
|
|
85
|
+
"schema": 1,
|
|
86
|
+
"manifests": [
|
|
87
|
+
"package.json"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"gitHead": "ab131c0ae46724efb84318568125193a8432d233",
|
|
91
|
+
"amalgmSource": {
|
|
92
|
+
"repository": "amalgm-inc/amalgm-tools",
|
|
93
|
+
"branch": "main",
|
|
94
|
+
"commit": "ab131c0ae46724efb84318568125193a8432d233",
|
|
95
|
+
"occurrence": "34175698435"
|
|
60
96
|
}
|
|
61
97
|
}
|
|
@@ -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.
|