@amalgm/agents 0.2.3-preview.37556574617 → 0.2.3-preview.39017157677
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 +21 -19
- package/README.md +25 -36
- package/dist/agent-folder.d.ts +32 -0
- package/dist/agent-folder.js +100 -0
- package/dist/agent-store.d.ts +23 -12
- package/dist/agent-store.js +144 -117
- package/dist/agents.d.ts +10 -10
- package/dist/agents.js +14 -26
- package/dist/bundles/create.d.ts +1 -0
- package/dist/bundles/create.js +1 -1
- package/dist/bundles/graph.d.ts +1 -0
- package/dist/bundles/graph.js +1 -1
- package/dist/bundles/install.d.ts +1 -0
- package/dist/bundles/install.js +1 -2
- package/dist/bundles/validate.d.ts +1 -0
- package/dist/bundles/validate.js +1 -1
- package/dist/config/import.d.ts +1 -1
- package/dist/config/import.js +2 -2
- package/dist/config/native.d.ts +5 -1
- package/dist/config/native.js +12 -11
- package/dist/config/schema.d.ts +1 -0
- package/dist/config/schema.js +1 -1
- package/dist/config/store.js +7 -7
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +0 -1
- package/dist/http/agent-routes.js +2 -4
- package/dist/http/bundle-routes.js +2 -23
- package/dist/http/config-routes.js +1 -4
- package/dist/http/server.d.ts +1 -1
- package/dist/http/server.js +3 -9
- package/dist/http/skill-routes.d.ts +0 -1
- package/dist/http/skill-routes.js +2 -3
- package/dist/http-types.d.ts +2 -8
- package/dist/ids.d.ts +0 -4
- package/dist/ids.js +0 -23
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -1
- package/dist/json.d.ts +1 -4
- package/dist/json.js +0 -23
- package/dist/mcp/agent-tools.js +11 -12
- package/dist/mcp/server.d.ts +3 -4
- package/dist/mcp/server.js +3 -41
- package/dist/mcp/types.d.ts +0 -1
- package/dist/revisions.d.ts +9 -0
- package/dist/revisions.js +39 -0
- package/dist/skills/roots.d.ts +6 -7
- package/dist/skills/roots.js +16 -29
- package/dist/skills/scanner.d.ts +2 -2
- package/dist/skills/scanner.js +2 -2
- package/dist/types.d.ts +9 -6
- package/docs/ARCHITECTURE.md +24 -25
- package/docs/DATA_MODEL.md +27 -21
- package/docs/DEFINITIONS.md +11 -9
- package/docs/MCP.md +5 -5
- package/docs/REST.md +7 -7
- package/docs/SDK.md +17 -13
- package/docs/SECURITY.md +4 -3
- package/docs/SHELL_INTEGRATION.md +22 -2
- package/examples/basic.ts +15 -11
- package/package.json +9 -20
- package/skills/amalgm-agents/SKILL.md +69 -171
- package/dist/bin/agents.d.ts +0 -2
- package/dist/bin/agents.js +0 -5
- package/dist/bin/fatal.d.ts +0 -1
- package/dist/bin/fatal.js +0 -5
- package/dist/bin/mcp.d.ts +0 -2
- package/dist/bin/mcp.js +0 -19
- package/dist/bin/rest.d.ts +0 -2
- package/dist/bin/rest.js +0 -26
- package/dist/bundles/copy.d.ts +0 -12
- package/dist/bundles/copy.js +0 -144
- package/dist/cli/agent-commands.d.ts +0 -3
- package/dist/cli/agent-commands.js +0 -27
- package/dist/cli/args.d.ts +0 -7
- package/dist/cli/args.js +0 -31
- package/dist/cli/files.d.ts +0 -2
- package/dist/cli/files.js +0 -21
- package/dist/cli/help.d.ts +0 -1
- package/dist/cli/help.js +0 -15
- package/dist/cli/open.d.ts +0 -3
- package/dist/cli/open.js +0 -8
- package/dist/cli/run.d.ts +0 -1
- package/dist/cli/run.js +0 -33
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -2
- package/dist/database.d.ts +0 -9
- package/dist/database.js +0 -35
- package/dist/rows.d.ts +0 -4
- package/dist/rows.js +0 -28
- package/dist/schema.d.ts +0 -2
- package/dist/schema.js +0 -162
- package/docs/CLI.md +0 -23
- package/docs/ENGINE_INTEGRATION.md +0 -12
package/PURPOSE.md
CHANGED
|
@@ -2,27 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
## Purpose
|
|
4
4
|
|
|
5
|
-
Amalgm Agents
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
resolve one exact revision for execution by Chat.
|
|
5
|
+
Amalgm Agents keeps the user's agents, each as one folder in the agents folder
|
|
6
|
+
its host hands it. A user or another agent can create, list, inspect, edit,
|
|
7
|
+
and delete an agent, then resolve one exact revision for execution by Chat.
|
|
9
8
|
|
|
10
9
|
Shell composes Agents with Chat, harnesses, credentials, Toolbox, files, Live,
|
|
11
10
|
and UI. This package stores references to those products; it does not duplicate
|
|
12
11
|
their state or execute a conversation.
|
|
13
12
|
It also discovers installed agent skills across the canonical project and
|
|
14
13
|
harness roots so every transport presents the same available skill catalog.
|
|
15
|
-
Rich harness configuration is stored inside the same
|
|
16
|
-
|
|
14
|
+
Rich harness configuration is stored inside the same definition and projected
|
|
15
|
+
onto its executable fields; it is not a second agent store.
|
|
17
16
|
Portable bundle-v2 documents close an agent's subagent, skill, and tool graph;
|
|
18
17
|
hosts supply explicit ports for resources owned by other products.
|
|
19
18
|
|
|
20
19
|
## Primitives
|
|
21
20
|
|
|
22
|
-
- An **agent** is a stable identity with a complete current definition
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- A **
|
|
21
|
+
- An **agent** is a stable identity with a complete current definition, kept
|
|
22
|
+
as one folder: `.amalgm-agent.json`, `instructions.md`, `skills/`, and a
|
|
23
|
+
computer-only `.private/`.
|
|
24
|
+
- A **harness home** is one harness's home for one agent and auth, inside the
|
|
25
|
+
agent's `.private/`.
|
|
26
|
+
- A **resolved agent** is one exact revision selected for execution.
|
|
26
27
|
- The **Agents service** is the behavior shared by every public surface.
|
|
27
28
|
|
|
28
29
|
## Axioms
|
|
@@ -51,20 +52,21 @@ Managed releases bind to one exact published Core version and build from the
|
|
|
51
52
|
locked dependency graph on the supported Node toolchain.
|
|
52
53
|
|
|
53
54
|
1. A user can create, list, inspect, edit, and delete agents.
|
|
54
|
-
2. A user or another agent can resolve an
|
|
55
|
-
|
|
55
|
+
2. A user or another agent can resolve an agent to one exact revision without
|
|
56
|
+
starting a conversation.
|
|
56
57
|
3. An agent definition can reference its harness, model, instructions, tools,
|
|
57
58
|
skills, files, credentials, and subagents without Agents owning those
|
|
58
59
|
products.
|
|
59
60
|
4. Harness identity is part of an agent revision; provider execution belongs
|
|
60
61
|
to Chat behind a host runtime port.
|
|
61
|
-
5.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
5. The agent's folder is its only copy. Hand edits to it are the agent, and
|
|
63
|
+
Agents reads and writes no other location for agents.
|
|
64
|
+
6. SDK, REST, MCP, the `amalgm agents` CLI, and skill workflows expose the same
|
|
65
|
+
Agents behavior through one instance; none is a second implementation.
|
|
66
|
+
7. A revision is named by its definition: an unchanged definition keeps its
|
|
67
|
+
revision, and returning to an earlier definition returns to its revision.
|
|
68
|
+
8. Agent configuration and its executable projection are one definition,
|
|
69
|
+
written together; native imports never ingest credentials or MCP config.
|
|
68
70
|
9. A portable bundle is accepted only when its flat graph is derivable from
|
|
69
71
|
its canonical records and every element is reachable from a declared head.
|
|
70
72
|
10. An agent revision owns its exact tool/action selection and direct, search,
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Amalgm Agents
|
|
2
2
|
|
|
3
|
-
`@amalgm/agents` is a
|
|
4
|
-
|
|
5
|
-
its
|
|
3
|
+
`@amalgm/agents` is a TypeScript SDK that keeps each agent as one folder in
|
|
4
|
+
the user's agents folder and resolves the exact revision Chat runs. The same
|
|
5
|
+
`Agents` instance powers its REST API and MCP server.
|
|
6
6
|
|
|
7
|
-
It is intentionally not Chat. Agents resolves the exact
|
|
7
|
+
It is intentionally not Chat. Agents resolves the exact revision;
|
|
8
8
|
`@amalgm/chat` owns the durable conversation, turns, stream, reconnect, and
|
|
9
9
|
interrupt lifecycle that executes it.
|
|
10
10
|
|
|
@@ -21,47 +21,47 @@ Node 20 or newer is required.
|
|
|
21
21
|
```ts
|
|
22
22
|
import { Agents } from '@amalgm/agents';
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
// The host hands over every folder; Agents has no defaults.
|
|
25
|
+
const agents = new Agents({ root, parked, osHome, isBusy: () => false });
|
|
25
26
|
|
|
26
|
-
agents.createAgent({
|
|
27
|
-
id: 'reviewer',
|
|
27
|
+
const reviewer = agents.createAgent({
|
|
28
28
|
name: 'Reviewer',
|
|
29
29
|
driver: { id: 'echo' },
|
|
30
30
|
instructions: 'Review work carefully.',
|
|
31
31
|
toolbox: { toolIds: ['git'], actionIds: ['git.diff'] },
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
const revision = agents.getAgentRevision(
|
|
34
|
+
const revision = agents.getAgentRevision(reviewer.id);
|
|
35
35
|
console.log(revision.id, revision.definition.driver.id);
|
|
36
|
-
agents.close();
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
The agent is now `<root>/Reviewer/`: `.amalgm-agent.json` (its id and
|
|
39
|
+
definition), `instructions.md`, a `SKILL.md` per config skill, and a
|
|
40
|
+
computer-only `.private/` for harness homes and revisions. A revision is named
|
|
41
|
+
by its definition's hash; Chat records the resolved revision id in every
|
|
42
|
+
prepared execution.
|
|
41
43
|
|
|
42
44
|
## Product surfaces
|
|
43
45
|
|
|
44
46
|
| Surface | Entry point | Purpose |
|
|
45
47
|
|---|---|---|
|
|
46
|
-
| SDK | `@amalgm/agents` |
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
48
|
+
| SDK | `@amalgm/agents` | Read and write agent folders and resolve revisions |
|
|
49
|
+
| REST | `@amalgm/agents/http` | HTTP routes over the host's `Agents` |
|
|
50
|
+
| MCP | `@amalgm/agents/mcp` | Agent tools, mounted by the runtime at `/mcp/agents` |
|
|
51
|
+
| CLI | `amalgm agents …` in `@amalgm/shell` | Calls the running runtime's `/mcp/agents` |
|
|
50
52
|
| Skill | `skills/amalgm-agents` | Minimal workflow over the Agents tools |
|
|
51
53
|
|
|
52
|
-
Installed skills are available from the REST surface
|
|
53
|
-
second registry:
|
|
54
|
+
Installed skills are available from the REST surface:
|
|
54
55
|
|
|
55
56
|
```bash
|
|
56
57
|
curl http://127.0.0.1:PORT/skills
|
|
57
58
|
curl 'http://127.0.0.1:PORT/skills/list?include_content=true'
|
|
58
59
|
```
|
|
59
60
|
|
|
60
|
-
The scanner reads the
|
|
61
|
-
OpenCode
|
|
62
|
-
project or an isolated home.
|
|
61
|
+
The scanner reads the project's `.agents/skills` folders and the shared, Codex,
|
|
62
|
+
Claude Code, and OpenCode skill folders in the `osHome` the host handed over.
|
|
63
63
|
|
|
64
|
-
Rich harness configuration
|
|
64
|
+
Rich harness configuration is part of the agent's definition:
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
import { updateAgentConfig } from '@amalgm/agents';
|
|
@@ -80,8 +80,8 @@ the agent it names.
|
|
|
80
80
|
|
|
81
81
|
The REST adapter also serves `/agent-config`, `/agent-config/get`,
|
|
82
82
|
`/agent-config/update`, and `/agent-config/import-native`. Native import reads
|
|
83
|
-
only instructions, skills, command hooks, and agent markdown from
|
|
84
|
-
|
|
83
|
+
only instructions, skills, command hooks, and agent markdown from `osHome`;
|
|
84
|
+
credentials and MCP configuration never enter Agents.
|
|
85
85
|
|
|
86
86
|
Portable bundle-v2 documents use the same SDK law as the REST surface:
|
|
87
87
|
|
|
@@ -100,28 +100,17 @@ graph. The injected port exports and installs Apps, Automations, and Toolbox
|
|
|
100
100
|
records through their owning SDKs. A missing port or graph mismatch fails
|
|
101
101
|
explicitly; dependencies are never omitted to make a bundle look portable.
|
|
102
102
|
|
|
103
|
-
## CLI
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
amalgm-agents agent create ./agent.json
|
|
107
|
-
amalgm-agents agent list
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
The CLI reads the same SQLite registry as the SDK.
|
|
111
|
-
|
|
112
103
|
## Documentation
|
|
113
104
|
|
|
114
105
|
- [Purpose and axioms](./PURPOSE.md)
|
|
115
106
|
- [Architecture and boundaries](./docs/ARCHITECTURE.md)
|
|
116
107
|
- [Agent definitions](./docs/DEFINITIONS.md)
|
|
117
108
|
- [SDK reference](./docs/SDK.md)
|
|
118
|
-
- [CLI reference](./docs/CLI.md)
|
|
119
109
|
- [REST API](./docs/REST.md)
|
|
120
110
|
- [MCP server](./docs/MCP.md)
|
|
121
111
|
- [Persistence](./docs/DATA_MODEL.md)
|
|
122
112
|
- [Security model](./docs/SECURITY.md)
|
|
123
113
|
- [Shell integration](./docs/SHELL_INTEGRATION.md)
|
|
124
|
-
- [Historical Engine integration](./docs/ENGINE_INTEGRATION.md)
|
|
125
114
|
|
|
126
115
|
## Development
|
|
127
116
|
|
|
@@ -132,7 +121,7 @@ npm run verify
|
|
|
132
121
|
|
|
133
122
|
`verify` runs strict typechecking for source, tests, and examples; enforces the
|
|
134
123
|
220-line source-file limit; builds JavaScript and declarations; and runs the
|
|
135
|
-
|
|
124
|
+
tests against real temporary folders and TCP servers.
|
|
136
125
|
|
|
137
126
|
## Managed package delivery
|
|
138
127
|
|
|
@@ -143,7 +132,7 @@ once, and installs that tarball on Linux, macOS and Windows before publication.
|
|
|
143
132
|
`preview` has no checks: a push to it builds, packs and publishes directly.
|
|
144
133
|
The `candidate-main`/`candidate-preview` tags are release-assembly inputs and
|
|
145
134
|
never select installed runtimes. `package.json` declares this owner's gates,
|
|
146
|
-
|
|
135
|
+
peer-only exports and lifecycle permissions. The standalone runner
|
|
147
136
|
under `scripts/release/` is intentionally copied across owners to preserve
|
|
148
137
|
private repository access boundaries. The final publish step uses the `NPM_TOKEN`
|
|
149
138
|
secret in the `npm-release` environment. Where npm trusted publishing is
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One agent on disk. Its folder is the only copy of the agent:
|
|
3
|
+
*
|
|
4
|
+
* .amalgm-agent.json id, the definition (minus the texts below), pinned and built-in state
|
|
5
|
+
* instructions.md the definition's instructions
|
|
6
|
+
* skills/<skill>/SKILL.md the text of each skill in metadata.agentConfig.skills
|
|
7
|
+
* .private/ computer-only: harness homes and resolved revisions
|
|
8
|
+
*/
|
|
9
|
+
import { entityLayout } from '@amalgm/core/identity';
|
|
10
|
+
import type { AgentDefinition } from './types.js';
|
|
11
|
+
export type AgentLayout = ReturnType<typeof entityLayout>;
|
|
12
|
+
/** What the identity file keeps beside the definition. */
|
|
13
|
+
export interface AgentState {
|
|
14
|
+
definition: AgentDefinition;
|
|
15
|
+
pinned: boolean;
|
|
16
|
+
builtin: boolean;
|
|
17
|
+
/** The stock definition hash a built-in was last installed with. */
|
|
18
|
+
builtinHash: string | null;
|
|
19
|
+
createdAt: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
}
|
|
22
|
+
export interface AgentFolder extends AgentState {
|
|
23
|
+
folder: string;
|
|
24
|
+
}
|
|
25
|
+
export declare function agentLayout(root: string, folder: string): AgentLayout;
|
|
26
|
+
/** The agent in `<root>/<folder>`, or null when the folder holds no readable agent. */
|
|
27
|
+
export declare function readAgentFolder(root: string, folder: string): AgentFolder | null;
|
|
28
|
+
/**
|
|
29
|
+
* Writes an agent's files. `previous` is the definition the folder held, so a
|
|
30
|
+
* skill dropped from the config loses its folder too.
|
|
31
|
+
*/
|
|
32
|
+
export declare function writeAgentFolder(layout: AgentLayout, state: AgentState, previous?: AgentDefinition): void;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One agent on disk. Its folder is the only copy of the agent:
|
|
3
|
+
*
|
|
4
|
+
* .amalgm-agent.json id, the definition (minus the texts below), pinned and built-in state
|
|
5
|
+
* instructions.md the definition's instructions
|
|
6
|
+
* skills/<skill>/SKILL.md the text of each skill in metadata.agentConfig.skills
|
|
7
|
+
* .private/ computer-only: harness homes and resolved revisions
|
|
8
|
+
*/
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
import fs from 'node:fs';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
import { entityFolderName, entityLayout } from '@amalgm/core/identity';
|
|
13
|
+
import { normalizeDefinition } from './definition.js';
|
|
14
|
+
import { isObject, jsonClone } from './json.js';
|
|
15
|
+
const INSTRUCTIONS_FILE = 'instructions.md';
|
|
16
|
+
const SKILLS_DIR = 'skills';
|
|
17
|
+
const SKILL_FILE = 'SKILL.md';
|
|
18
|
+
export function agentLayout(root, folder) {
|
|
19
|
+
return entityLayout('agent', root, folder);
|
|
20
|
+
}
|
|
21
|
+
function readText(file) {
|
|
22
|
+
try {
|
|
23
|
+
return fs.readFileSync(file, 'utf8');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Writes through a temporary file in `.private/`, and only when the text changed. */
|
|
30
|
+
function writeText(layout, file, text) {
|
|
31
|
+
if (readText(file) === text)
|
|
32
|
+
return;
|
|
33
|
+
const temp = path.join(layout.private, `.write-${crypto.randomUUID()}`);
|
|
34
|
+
fs.mkdirSync(layout.private, { recursive: true });
|
|
35
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
36
|
+
fs.writeFileSync(temp, text);
|
|
37
|
+
fs.renameSync(temp, file);
|
|
38
|
+
}
|
|
39
|
+
/** Each skill object in the config, with the folder its text lives in. */
|
|
40
|
+
function skillFolders(metadata) {
|
|
41
|
+
const config = isObject(metadata) ? metadata.agentConfig : null;
|
|
42
|
+
const skills = isObject(config) && Array.isArray(config.skills) ? config.skills : [];
|
|
43
|
+
const taken = [];
|
|
44
|
+
return skills.filter(isObject).map((skill) => {
|
|
45
|
+
const folder = entityFolderName(String(skill.name || skill.id || ''), taken);
|
|
46
|
+
taken.push(folder);
|
|
47
|
+
return { skill, folder };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** The agent in `<root>/<folder>`, or null when the folder holds no readable agent. */
|
|
51
|
+
export function readAgentFolder(root, folder) {
|
|
52
|
+
const layout = agentLayout(root, folder);
|
|
53
|
+
try {
|
|
54
|
+
const { pinned, builtin, builtinHash, createdAt, updatedAt, ...stored } = JSON.parse(fs.readFileSync(layout.identity, 'utf8'));
|
|
55
|
+
const metadata = isObject(stored.metadata) ? stored.metadata : {};
|
|
56
|
+
for (const { skill, folder: skillFolder } of skillFolders(metadata)) {
|
|
57
|
+
const text = readText(path.join(layout.dir, SKILLS_DIR, skillFolder, SKILL_FILE));
|
|
58
|
+
if (text !== null)
|
|
59
|
+
skill.content = text;
|
|
60
|
+
}
|
|
61
|
+
const instructions = readText(path.join(layout.dir, INSTRUCTIONS_FILE)) ?? '';
|
|
62
|
+
return {
|
|
63
|
+
folder,
|
|
64
|
+
definition: normalizeDefinition({ ...stored, instructions, metadata }),
|
|
65
|
+
pinned: pinned !== false,
|
|
66
|
+
builtin: builtin === true,
|
|
67
|
+
builtinHash: typeof builtinHash === 'string' ? builtinHash : null,
|
|
68
|
+
createdAt: String(createdAt || ''),
|
|
69
|
+
updatedAt: String(updatedAt || ''),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Writes an agent's files. `previous` is the definition the folder held, so a
|
|
78
|
+
* skill dropped from the config loses its folder too.
|
|
79
|
+
*/
|
|
80
|
+
export function writeAgentFolder(layout, state, previous) {
|
|
81
|
+
const { instructions, ...stored } = state.definition;
|
|
82
|
+
const metadata = jsonClone(stored.metadata);
|
|
83
|
+
const kept = new Set();
|
|
84
|
+
for (const { skill, folder } of skillFolders(metadata)) {
|
|
85
|
+
if (typeof skill.content !== 'string' || !skill.content)
|
|
86
|
+
continue;
|
|
87
|
+
writeText(layout, path.join(layout.dir, SKILLS_DIR, folder, SKILL_FILE), skill.content);
|
|
88
|
+
delete skill.content;
|
|
89
|
+
kept.add(folder);
|
|
90
|
+
}
|
|
91
|
+
for (const { folder } of previous ? skillFolders(previous.metadata) : []) {
|
|
92
|
+
if (!kept.has(folder))
|
|
93
|
+
fs.rmSync(path.join(layout.dir, SKILLS_DIR, folder), { recursive: true, force: true });
|
|
94
|
+
}
|
|
95
|
+
writeText(layout, path.join(layout.dir, INSTRUCTIONS_FILE), instructions ? `${instructions}\n` : '');
|
|
96
|
+
const { pinned, builtin, builtinHash, createdAt, updatedAt } = state;
|
|
97
|
+
writeText(layout, layout.identity, `${JSON.stringify({
|
|
98
|
+
...stored, metadata, pinned, builtin, builtinHash, createdAt, updatedAt,
|
|
99
|
+
}, null, 2)}\n`);
|
|
100
|
+
}
|
package/dist/agent-store.d.ts
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import type { AgentDefinitionInput, AgentPatch, AgentRecord, AgentRevision, AgentsOptions, CreateAgentOptions } from './types.js';
|
|
2
|
+
/** The agents in the folder Shell hands over: one folder per agent, read fresh on every call. */
|
|
3
3
|
export declare class AgentStore {
|
|
4
|
-
private readonly
|
|
5
|
-
|
|
6
|
-
constructor(database: Database.Database, now: () => string);
|
|
4
|
+
private readonly options;
|
|
5
|
+
constructor(options: AgentsOptions);
|
|
7
6
|
create(input: AgentDefinitionInput, options?: CreateAgentOptions): AgentRecord;
|
|
8
|
-
apply(input: AgentDefinitionInput): AgentRecord;
|
|
9
7
|
update(id: string, patch: AgentPatch): AgentRecord;
|
|
10
8
|
/** Pinning is identity state, so it never mints a revision. */
|
|
11
9
|
setPinned(id: string, pinned: boolean): AgentRecord;
|
|
12
10
|
/**
|
|
13
11
|
* Install or advance one platform agent. The stock definition replaces the
|
|
14
|
-
* current one only while the current
|
|
12
|
+
* current one only while the current one is still the stock definition this
|
|
15
13
|
* installer last wrote, so a user's edit always survives.
|
|
16
14
|
*/
|
|
17
15
|
installBuiltin(input: AgentDefinitionInput): AgentRecord;
|
|
16
|
+
/** Moves the agent's `.private/` to the parked folder, then removes its folder. */
|
|
18
17
|
delete(id: string): AgentRecord;
|
|
19
|
-
get(id: string
|
|
20
|
-
|
|
21
|
-
list(includeDeleted?: boolean): AgentRecord[];
|
|
18
|
+
get(id: string): AgentRecord | null;
|
|
19
|
+
list(): AgentRecord[];
|
|
22
20
|
revision(agentId: string, revisionId?: string): AgentRevision;
|
|
23
|
-
private
|
|
21
|
+
/** `<agent folder>/.private/<harness>-<authKey>`, made on first use. */
|
|
22
|
+
harnessHome(agentId: string, harness: string, authKey: string): string;
|
|
23
|
+
private find;
|
|
24
|
+
private require;
|
|
25
|
+
/** Every readable agent folder; a copied folder whose id is already taken is skipped. */
|
|
26
|
+
private agents;
|
|
27
|
+
private entries;
|
|
28
|
+
/**
|
|
29
|
+
* Moves each idle agent to the folder its name asks for. A running agent
|
|
30
|
+
* keeps its folder until a later call finds it idle.
|
|
31
|
+
*/
|
|
32
|
+
private settle;
|
|
24
33
|
private insert;
|
|
25
|
-
private
|
|
34
|
+
private write;
|
|
35
|
+
/** The agent as callers see it. Its current revision is kept so its id stays resolvable. */
|
|
36
|
+
private record;
|
|
26
37
|
}
|