@amalgm/agents 0.1.3 → 0.2.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 (55) hide show
  1. package/PURPOSE.md +25 -24
  2. package/README.md +19 -46
  3. package/dist/agents.d.ts +4 -26
  4. package/dist/agents.js +4 -87
  5. package/dist/bin/mcp.js +1 -1
  6. package/dist/cli/help.d.ts +1 -1
  7. package/dist/cli/help.js +2 -13
  8. package/dist/cli/open.d.ts +1 -1
  9. package/dist/cli/open.js +1 -5
  10. package/dist/cli/run.js +3 -8
  11. package/dist/errors.d.ts +1 -1
  12. package/dist/errors.js +0 -2
  13. package/dist/http/server.js +1 -7
  14. package/dist/index.d.ts +0 -2
  15. package/dist/index.js +0 -2
  16. package/dist/mcp/agent-tools.js +1 -1
  17. package/dist/mcp/tools.js +1 -2
  18. package/dist/rows.d.ts +1 -4
  19. package/dist/rows.js +0 -39
  20. package/dist/schema.js +53 -101
  21. package/dist/types.d.ts +0 -106
  22. package/docs/ARCHITECTURE.md +21 -33
  23. package/docs/CLI.md +3 -43
  24. package/docs/DATA_MODEL.md +7 -46
  25. package/docs/DEFINITIONS.md +4 -4
  26. package/docs/ENGINE_INTEGRATION.md +22 -67
  27. package/docs/MCP.md +3 -19
  28. package/docs/REST.md +14 -97
  29. package/docs/SDK.md +12 -61
  30. package/docs/SECURITY.md +6 -35
  31. package/examples/basic.ts +8 -22
  32. package/package.json +2 -2
  33. package/skills/amalgm-agents/SKILL.md +3 -12
  34. package/skills/amalgm-agents/agents/openai.yaml +2 -2
  35. package/dist/cli/session-commands.d.ts +0 -4
  36. package/dist/cli/session-commands.js +0 -54
  37. package/dist/drivers.d.ts +0 -4
  38. package/dist/drivers.js +0 -25
  39. package/dist/event-store.d.ts +0 -13
  40. package/dist/event-store.js +0 -50
  41. package/dist/http/session-routes.d.ts +0 -2
  42. package/dist/http/session-routes.js +0 -67
  43. package/dist/http/stream.d.ts +0 -3
  44. package/dist/http/stream.js +0 -30
  45. package/dist/mcp/session-tools.d.ts +0 -3
  46. package/dist/mcp/session-tools.js +0 -81
  47. package/dist/messages.d.ts +0 -3
  48. package/dist/messages.js +0 -56
  49. package/dist/runtime.d.ts +0 -29
  50. package/dist/runtime.js +0 -176
  51. package/dist/session-store.d.ts +0 -15
  52. package/dist/session-store.js +0 -83
  53. package/dist/turn-store.d.ts +0 -31
  54. package/dist/turn-store.js +0 -164
  55. package/docs/DRIVERS.md +0 -72
package/PURPOSE.md CHANGED
@@ -2,15 +2,14 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
- Amalgm Agents is the small, standalone product for defining agents and talking
6
- to them. A user can create, inspect, edit, and delete an agent, then start or
7
- continue a durable session with it through the SDK, CLI, REST, or MCP. Agents
8
- are not chats: Chat may present a session, but the agent definition and session
9
- remain usable without Chat or Amalgm Engine.
10
-
11
- Engine composes Agents with harnesses, credentials, Toolbox, files, Realtime,
12
- and UI. This package stores references to those products and delegates
13
- execution to an injected driver; it does not duplicate their state.
5
+ Amalgm Agents is the small, standalone registry for agent identities,
6
+ installations, and immutable revisions. A user or another agent can create,
7
+ register, install, list, inspect, edit, and delete an available agent, then
8
+ resolve one exact revision for execution by Chat.
9
+
10
+ Shell composes Agents with Chat, harnesses, credentials, Toolbox, files, Live,
11
+ and UI. This package stores references to those products; it does not duplicate
12
+ their state or execute a conversation.
14
13
  It also discovers installed agent skills across the canonical project and
15
14
  harness roots so every transport presents the same available skill catalog.
16
15
  Rich harness configuration is stored inside the same immutable definition and
@@ -21,22 +20,22 @@ hosts supply explicit ports for resources owned by other products.
21
20
  ## Primitives
22
21
 
23
22
  - An **agent** is a stable identity with a complete current definition.
24
- - A **session** is a durable conversation with one agent definition.
25
- - A **turn** is one accepted input and its driver result.
26
- - A **driver** runs the agent using a host-provided harness.
23
+ - An **installation** is one locally available agent identity and its Agent
24
+ Home descriptor.
25
+ - A **resolved agent** is one exact immutable revision selected for execution.
27
26
  - The **Agents service** is the behavior shared by every public surface.
28
27
 
29
28
  ## Axioms
30
29
 
31
30
  1. A user can create, list, inspect, edit, and delete agents.
32
- 2. A user or another agent can start, inspect, and continue an agent session
33
- without creating or depending on a Chat conversation.
31
+ 2. A user or another agent can resolve an available agent to one exact
32
+ immutable revision without starting a conversation.
34
33
  3. An agent definition can reference its harness, model, instructions, tools,
35
34
  skills, files, credentials, and subagents without Agents owning those
36
35
  products.
37
- 4. Any compatible agent harness can be used through the same driver contract.
38
- 5. Agent definitions and sessions survive restart, while uncertain interrupted
39
- execution is never silently replayed.
36
+ 4. Harness identity is part of an agent revision; provider execution belongs
37
+ to Chat behind a host runtime port.
38
+ 5. Agent definitions, installations, and revisions survive restart.
40
39
  6. SDK, CLI, REST, MCP, and skill workflows expose the same Agents behavior;
41
40
  none is a second implementation.
42
41
  7. An unchanged current definition is idempotent; every actual change creates
@@ -48,10 +47,12 @@ hosts supply explicit ports for resources owned by other products.
48
47
 
49
48
  ## Consequences
50
49
 
51
- The package needs no cloud command inbox, scheduler, trigger relay, Chat
52
- record, or general event-routing system. Engine and other hosts may call the
53
- SDK whenever they need to route work, but routing is outside the Agents
54
- product. Bundle ports call Apps, Automations, and Toolbox public APIs; Agents
55
- never imports their stores or duplicates their lifecycle behavior. Internal
56
- revisions, ordered events, idempotency, and cancellation exist only to make
57
- the behaviors above durable and predictable.
50
+ The package needs no conversation, turn, transcript, stream, reconnect,
51
+ interrupt, cloud command inbox, scheduler, trigger relay, or general
52
+ event-routing system. Shell and other hosts resolve Agents revisions while
53
+ preparing a Chat execution. Bundle ports call Apps, Automations, and Toolbox
54
+ public APIs; Agents never imports their stores or duplicates their lifecycle
55
+ behavior.
56
+
57
+ There is no execution subsystem in Agents. Chat is the single owner of every
58
+ conversation and turn.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Amalgm Agents
2
2
 
3
3
  `@amalgm/agents` is a local-first TypeScript SDK for persistent agent
4
- definitions and durable multi-turn sessions. The same service powers its CLI,
5
- REST API, and MCP server.
4
+ identities, installations, and immutable revisions. The same registry powers
5
+ its CLI, REST API, and MCP server.
6
6
 
7
- It is intentionally not Chat. Chat may present an agent session, but Agents
8
- owns the agent definition, the pinned execution revision, turns, and ordered
9
- events.
7
+ It is intentionally not Chat. Agents resolves the exact installed revision;
8
+ `@amalgm/chat` owns the durable conversation, turns, stream, reconnect, and
9
+ interrupt lifecycle that executes it.
10
10
 
11
11
  ## Install
12
12
 
@@ -19,25 +19,9 @@ Node 20 or newer is required.
19
19
  ## First agent
20
20
 
21
21
  ```ts
22
- import { Agents, defineDriver } from '@amalgm/agents';
23
-
24
- const echo = defineDriver({
25
- id: 'echo',
26
- async run(request) {
27
- const text = request.input.parts
28
- .filter((part) => part.type === 'text')
29
- .map((part) => part.text)
30
- .join('');
31
- return {
32
- message: {
33
- role: 'assistant',
34
- parts: [{ type: 'text', text: `Received: ${text}` }],
35
- },
36
- };
37
- },
38
- });
22
+ import { Agents } from '@amalgm/agents';
39
23
 
40
- const agents = new Agents({ stateDir: './state', drivers: [echo] });
24
+ const agents = new Agents({ stateDir: './state' });
41
25
 
42
26
  agents.createAgent({
43
27
  id: 'reviewer',
@@ -47,28 +31,22 @@ agents.createAgent({
47
31
  toolbox: { toolIds: ['git'], actionIds: ['git.diff'] },
48
32
  });
49
33
 
50
- const session = agents.startSession({ agentId: 'reviewer' });
51
- const turn = await agents.send(session.id, {
52
- message: 'Review the current diff.',
53
- idempotencyKey: 'review-001',
54
- });
55
-
56
- console.log(turn.status);
57
- console.log(agents.listEvents(session.id));
58
- await agents.close();
34
+ const revision = agents.getAgentRevision('reviewer');
35
+ console.log(revision.id, revision.definition.driver.id);
36
+ agents.close();
59
37
  ```
60
38
 
61
- An agent definition is normalized into a complete immutable revision. A
62
- session stays pinned to that revision even after the agent is edited.
39
+ An agent definition is normalized into a complete immutable revision. Chat
40
+ records the resolved revision id in every prepared execution.
63
41
 
64
42
  ## Product surfaces
65
43
 
66
44
  | Surface | Entry point | Purpose |
67
45
  |---|---|---|
68
- | SDK | `@amalgm/agents` | Embed the canonical service and supply drivers |
69
- | CLI | `amalgm-agents` | Manage definitions and sessions |
70
- | REST | `@amalgm/agents/http`, `amalgm-agents-rest` | Local HTTP and SSE integration |
71
- | MCP | `@amalgm/agents/mcp`, `amalgm-agents-mcp` | Agent CRUD and agent-to-agent calls |
46
+ | SDK | `@amalgm/agents` | Embed the canonical registry and resolve revisions |
47
+ | CLI | `amalgm-agents` | Manage agent identities and installations |
48
+ | REST | `@amalgm/agents/http`, `amalgm-agents-rest` | Local registry integration |
49
+ | MCP | `@amalgm/agents/mcp`, `amalgm-agents-mcp` | Agent registry tools |
72
50
  | Skill | `skills/amalgm-agents` | Minimal workflow over the Agents tools |
73
51
 
74
52
  Installed skills are available from the REST surface without introducing a
@@ -122,13 +100,9 @@ explicitly; dependencies are never omitted to make a bundle look portable.
122
100
  ```bash
123
101
  amalgm-agents agent create ./agent.json
124
102
  amalgm-agents agent list
125
- amalgm-agents session start reviewer
126
- amalgm-agents session send <session-id> "Review the diff"
127
- amalgm-agents talk reviewer "Review the diff"
128
103
  ```
129
104
 
130
- The CLI reads the same SQLite database as the SDK. Driver modules are loaded
131
- with `--drivers ./dist/codex-driver.js` or `AMALGM_AGENT_DRIVERS`.
105
+ The CLI reads the same SQLite registry as the SDK.
132
106
 
133
107
  ## Documentation
134
108
 
@@ -136,11 +110,10 @@ with `--drivers ./dist/codex-driver.js` or `AMALGM_AGENT_DRIVERS`.
136
110
  - [Architecture and boundaries](./docs/ARCHITECTURE.md)
137
111
  - [Agent definitions](./docs/DEFINITIONS.md)
138
112
  - [SDK reference](./docs/SDK.md)
139
- - [Driver contract](./docs/DRIVERS.md)
140
113
  - [CLI reference](./docs/CLI.md)
141
114
  - [REST API](./docs/REST.md)
142
115
  - [MCP server](./docs/MCP.md)
143
- - [Persistence and recovery](./docs/DATA_MODEL.md)
116
+ - [Persistence](./docs/DATA_MODEL.md)
144
117
  - [Security model](./docs/SECURITY.md)
145
118
  - [Engine integration](./docs/ENGINE_INTEGRATION.md)
146
119
 
@@ -153,4 +126,4 @@ npm run verify
153
126
 
154
127
  `verify` runs strict typechecking for source, tests, and examples; enforces the
155
128
  220-line source-file limit; builds JavaScript and declarations; and runs the
156
- real SQLite, process-restart, TCP/SSE, stdio MCP, and CLI tests.
129
+ real SQLite, TCP, stdio MCP, and CLI tests.
package/dist/agents.d.ts CHANGED
@@ -1,14 +1,8 @@
1
- import type { AgentDefinitionInput, AgentDriver, AgentPatch, AgentRecord, AgentSession, AgentsOptions, AgentTurn, EnqueuedTurn, EventListener, JsonObject, SendInput, SessionEvent, StartSessionInput } from './types.js';
1
+ import type { AgentDefinitionInput, AgentPatch, AgentRecord, AgentRevision, AgentsOptions, JsonObject } from './types.js';
2
2
  export declare class Agents {
3
3
  readonly databasePath: string;
4
- readonly recoveredTurns: number;
5
4
  private readonly opened;
6
5
  private readonly agentStore;
7
- private readonly eventStore;
8
- private readonly sessionStore;
9
- private readonly turnStore;
10
- private readonly runtime;
11
- private readonly listeners;
12
6
  private closed;
13
7
  constructor(options?: AgentsOptions);
14
8
  createAgent(input: AgentDefinitionInput): AgentRecord;
@@ -16,24 +10,8 @@ export declare class Agents {
16
10
  deleteAgent(id: string): AgentRecord;
17
11
  getAgent(id: string, includeDeleted?: boolean): AgentRecord | null;
18
12
  listAgents(includeDeleted?: boolean): AgentRecord[];
19
- startSession(input: StartSessionInput): AgentSession;
20
- getSession(id: string): AgentSession | null;
21
- listSessions(agentId?: string, includeArchived?: boolean): AgentSession[];
22
- archiveSession(id: string): AgentSession;
23
- enqueue(id: string, input: SendInput): EnqueuedTurn;
24
- send(id: string, input: SendInput): Promise<AgentTurn>;
25
- talk(agentId: string, input: SendInput & {
26
- sessionId?: string;
27
- }): EnqueuedTurn & {
28
- session: AgentSession;
29
- };
30
- cancelSession(id: string): AgentTurn;
31
- listTurns(sessionId: string): AgentTurn[];
32
- listEvents(sessionId: string, after?: number, limit?: number): SessionEvent[];
33
- registerDriver(driver: AgentDriver): void;
34
- driverIds(): string[];
35
- subscribe(sessionId: string, listener: EventListener): () => void;
13
+ /** Resolve one exact immutable revision for a host such as Chat. */
14
+ getAgentRevision(agentId: string, revisionId?: string): AgentRevision;
36
15
  health(): JsonObject;
37
- close(): Promise<void>;
38
- private publish;
16
+ close(): void;
39
17
  }
package/dist/agents.js CHANGED
@@ -1,36 +1,16 @@
1
1
  import path from 'node:path';
2
2
  import { AgentStore } from './agent-store.js';
3
3
  import { openDatabase } from './database.js';
4
- import { EventStore } from './event-store.js';
5
- import { AgentError } from './errors.js';
6
- import { AgentRuntime } from './runtime.js';
7
- import { SessionStore } from './session-store.js';
8
- import { TurnStore } from './turn-store.js';
9
4
  export class Agents {
10
5
  databasePath;
11
- recoveredTurns;
12
6
  opened;
13
7
  agentStore;
14
- eventStore;
15
- sessionStore;
16
- turnStore;
17
- runtime;
18
- listeners = new Map();
19
8
  closed = false;
20
9
  constructor(options = {}) {
21
10
  this.opened = openDatabase(options);
22
11
  this.databasePath = this.opened.databasePath;
23
12
  const now = options.now || (() => new Date().toISOString());
24
- this.eventStore = new EventStore(this.opened.database, now, (event) => this.publish(event));
25
13
  this.agentStore = new AgentStore(this.opened.database, now);
26
- this.sessionStore = new SessionStore(this.opened.database, this.eventStore, now);
27
- this.turnStore = new TurnStore(this.opened.database, this.sessionStore, this.eventStore, now);
28
- this.recoveredTurns = this.turnStore.recoverInterrupted();
29
- this.runtime = new AgentRuntime(this.agentStore, this.sessionStore, this.turnStore, this.eventStore, {
30
- maxInputBytes: options.maxInputBytes || 256_000,
31
- maxEventBytes: options.maxEventBytes || 256_000,
32
- turnTimeoutMs: options.turnTimeoutMs ?? 600_000,
33
- }, options.drivers);
34
14
  }
35
15
  createAgent(input) {
36
16
  return this.agentStore.create(input);
@@ -47,83 +27,20 @@ export class Agents {
47
27
  listAgents(includeDeleted = false) {
48
28
  return this.agentStore.list(includeDeleted);
49
29
  }
50
- startSession(input) {
51
- const agent = this.agentStore.require(input.agentId);
52
- const revision = this.agentStore.revision(agent.id, input.revisionId);
53
- return this.sessionStore.create(revision, input.sessionId, input.metadata || {});
54
- }
55
- getSession(id) {
56
- return this.sessionStore.get(id);
57
- }
58
- listSessions(agentId, includeArchived = false) {
59
- return this.sessionStore.list(agentId, includeArchived);
60
- }
61
- archiveSession(id) {
62
- return this.sessionStore.archive(id, Boolean(this.turnStore.active(id)));
63
- }
64
- enqueue(id, input) {
65
- this.sessionStore.require(id);
66
- return this.runtime.enqueue(id, input);
67
- }
68
- send(id, input) {
69
- this.sessionStore.require(id);
70
- return this.runtime.send(id, input);
71
- }
72
- talk(agentId, input) {
73
- const session = input.sessionId
74
- ? this.sessionStore.require(input.sessionId)
75
- : this.startSession({ agentId });
76
- if (session.agentId !== agentId) {
77
- throw new AgentError('conflict', `Session ${session.id} belongs to agent ${session.agentId}.`);
78
- }
79
- return { session, ...this.enqueue(session.id, input) };
80
- }
81
- cancelSession(id) {
82
- this.sessionStore.require(id);
83
- return this.runtime.cancel(id);
84
- }
85
- listTurns(sessionId) {
86
- return this.turnStore.list(sessionId);
87
- }
88
- listEvents(sessionId, after = 0, limit = 200) {
89
- this.sessionStore.require(sessionId);
90
- return this.eventStore.list(sessionId, after, limit);
91
- }
92
- registerDriver(driver) {
93
- this.runtime.register(driver);
94
- }
95
- driverIds() {
96
- return this.runtime.driverIds();
97
- }
98
- subscribe(sessionId, listener) {
99
- this.sessionStore.require(sessionId);
100
- const listeners = this.listeners.get(sessionId) || new Set();
101
- listeners.add(listener);
102
- this.listeners.set(sessionId, listeners);
103
- return () => {
104
- listeners.delete(listener);
105
- if (listeners.size === 0)
106
- this.listeners.delete(sessionId);
107
- };
30
+ /** Resolve one exact immutable revision for a host such as Chat. */
31
+ getAgentRevision(agentId, revisionId) {
32
+ return this.agentStore.revision(agentId, revisionId);
108
33
  }
109
34
  health() {
110
35
  return {
111
36
  ok: !this.closed,
112
37
  database: path.basename(this.databasePath),
113
- recoveredTurns: this.recoveredTurns,
114
- drivers: this.driverIds(),
115
38
  };
116
39
  }
117
- async close() {
40
+ close() {
118
41
  if (this.closed)
119
42
  return;
120
43
  this.closed = true;
121
- await this.runtime.shutdown();
122
- this.listeners.clear();
123
44
  this.opened.close();
124
45
  }
125
- publish(event) {
126
- for (const listener of this.listeners.get(event.sessionId) || [])
127
- listener(event);
128
- }
129
46
  }
package/dist/bin/mcp.js CHANGED
@@ -6,7 +6,7 @@ import { fatal } from './fatal.js';
6
6
  async function main() {
7
7
  const args = parseArgs(process.argv.slice(2));
8
8
  if (args.flags.has('help')) {
9
- process.stdout.write('Usage: amalgm-agents-mcp [--state-dir <path>] [--drivers <a.js,b.js>]\n');
9
+ process.stdout.write('Usage: amalgm-agents-mcp [--state-dir <path>]\n');
10
10
  return;
11
11
  }
12
12
  const agents = await openAgents(args);
@@ -1 +1 @@
1
- export declare const HELP = "amalgm-agents \u2014 local agent definitions and durable sessions\n\nAgent definitions:\n amalgm-agents agent list [--include-deleted]\n amalgm-agents agent show <id>\n amalgm-agents agent create <definition.json>\n amalgm-agents agent update <id> <patch.json>\n amalgm-agents agent delete <id>\n\nSessions:\n amalgm-agents session list [--agent <id>] [--include-archived]\n amalgm-agents session start <agent-id> [--id <id>] [--revision <id>]\n amalgm-agents session show <id>\n amalgm-agents session events <id> [--after <sequence>]\n amalgm-agents session send <id> <message> [--key <idempotency-key>]\n amalgm-agents session cancel <id>\n amalgm-agents session archive <id>\n amalgm-agents talk <agent-id> <message> [--session <id>] [--background]\n\nGlobal options:\n --state-dir <path> Agents state directory\n --drivers <a.js,b.js> Driver modules (or AMALGM_AGENT_DRIVERS)\n --help Show this help\n";
1
+ export declare const HELP = "amalgm-agents \u2014 local agent identities and immutable revisions\n\nAgents:\n amalgm-agents agent list [--include-deleted]\n amalgm-agents agent show <id>\n amalgm-agents agent create <definition.json>\n amalgm-agents agent update <id> <patch.json>\n amalgm-agents agent delete <id>\n\nGlobal options:\n --state-dir <path> Agents state directory\n --help Show this help\n";
package/dist/cli/help.js CHANGED
@@ -1,24 +1,13 @@
1
- export const HELP = `amalgm-agents — local agent definitions and durable sessions
1
+ export const HELP = `amalgm-agents — local agent identities and immutable revisions
2
2
 
3
- Agent definitions:
3
+ Agents:
4
4
  amalgm-agents agent list [--include-deleted]
5
5
  amalgm-agents agent show <id>
6
6
  amalgm-agents agent create <definition.json>
7
7
  amalgm-agents agent update <id> <patch.json>
8
8
  amalgm-agents agent delete <id>
9
9
 
10
- Sessions:
11
- amalgm-agents session list [--agent <id>] [--include-archived]
12
- amalgm-agents session start <agent-id> [--id <id>] [--revision <id>]
13
- amalgm-agents session show <id>
14
- amalgm-agents session events <id> [--after <sequence>]
15
- amalgm-agents session send <id> <message> [--key <idempotency-key>]
16
- amalgm-agents session cancel <id>
17
- amalgm-agents session archive <id>
18
- amalgm-agents talk <agent-id> <message> [--session <id>] [--background]
19
-
20
10
  Global options:
21
11
  --state-dir <path> Agents state directory
22
- --drivers <a.js,b.js> Driver modules (or AMALGM_AGENT_DRIVERS)
23
12
  --help Show this help
24
13
  `;
@@ -1,3 +1,3 @@
1
1
  import { Agents } from '../agents.js';
2
2
  import type { ParsedArgs } from './args.js';
3
- export declare function openAgents(args: ParsedArgs): Promise<Agents>;
3
+ export declare function openAgents(args: ParsedArgs): Agents;
package/dist/cli/open.js CHANGED
@@ -1,12 +1,8 @@
1
1
  import { Agents } from '../agents.js';
2
- import { driverSpecifiers, loadDriverModules } from '../drivers.js';
3
2
  import { flag } from './args.js';
4
- export async function openAgents(args) {
5
- const modules = flag(args, 'drivers');
3
+ export function openAgents(args) {
6
4
  const stateDir = flag(args, 'state-dir');
7
- const drivers = await loadDriverModules(driverSpecifiers(modules));
8
5
  return new Agents({
9
- drivers,
10
6
  ...(stateDir ? { stateDir } : {}),
11
7
  });
12
8
  }
package/dist/cli/run.js CHANGED
@@ -4,7 +4,6 @@ import { runAgentCommand } from './agent-commands.js';
4
4
  import { writeJson } from './files.js';
5
5
  import { HELP } from './help.js';
6
6
  import { openAgents } from './open.js';
7
- import { runSessionCommand, runTalkCommand } from './session-commands.js';
8
7
  export async function runCli(argv = process.argv.slice(2)) {
9
8
  const args = parseArgs(argv);
10
9
  if (args.flags.has('help') || args.words.length === 0) {
@@ -13,15 +12,11 @@ export async function runCli(argv = process.argv.slice(2)) {
13
12
  }
14
13
  let agents;
15
14
  try {
16
- agents = await openAgents(args);
15
+ agents = openAgents(args);
17
16
  const command = args.words[0];
18
17
  const value = command === 'agent'
19
18
  ? runAgentCommand(agents, args)
20
- : command === 'session'
21
- ? await runSessionCommand(agents, args)
22
- : command === 'talk'
23
- ? await runTalkCommand(agents, args)
24
- : undefined;
19
+ : undefined;
25
20
  if (value === undefined)
26
21
  throw new Error(`Unknown command: ${String(command)}`);
27
22
  writeJson(value);
@@ -33,6 +28,6 @@ export async function runCli(argv = process.argv.slice(2)) {
33
28
  return 1;
34
29
  }
35
30
  finally {
36
- await agents?.close();
31
+ agents?.close();
37
32
  }
38
33
  }
package/dist/errors.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { JsonObject } from './types.js';
2
- export type AgentErrorCode = 'invalid_input' | 'not_found' | 'conflict' | 'deleted' | 'driver_unavailable' | 'too_large' | 'cancelled' | 'internal';
2
+ export type AgentErrorCode = 'invalid_input' | 'not_found' | 'conflict' | 'deleted' | 'too_large' | 'internal';
3
3
  export declare class AgentError extends Error {
4
4
  readonly code: AgentErrorCode;
5
5
  readonly details: JsonObject;
package/dist/errors.js CHANGED
@@ -3,9 +3,7 @@ const statusByCode = {
3
3
  not_found: 404,
4
4
  conflict: 409,
5
5
  deleted: 410,
6
- driver_unavailable: 503,
7
6
  too_large: 413,
8
- cancelled: 409,
9
7
  internal: 500,
10
8
  };
11
9
  export class AgentError extends Error {
@@ -5,9 +5,7 @@ import { routeAgentConfig } from './config-routes.js';
5
5
  import { routeAgentBundles } from './bundle-routes.js';
6
6
  import { routeAgents } from './agent-routes.js';
7
7
  import { guardRequest, readJson, sendJson } from './request.js';
8
- import { routeSessions } from './session-routes.js';
9
8
  import { routeSkills } from './skill-routes.js';
10
- import { streamEvents } from './stream.js';
11
9
  export function createRestServer(options = {}) {
12
10
  const agents = options.agents || new Agents(options);
13
11
  const owned = !options.agents;
@@ -57,11 +55,7 @@ export function createRestServer(options = {}) {
57
55
  sendJson(response, 404, { error: { code: 'not_found', message: 'Route not found.' } });
58
56
  return;
59
57
  }
60
- if (path[0] === 'sessions' && path[2] === 'events' && path[3] === 'stream' && request.method === 'GET') {
61
- streamEvents(agents, path[1] || '', request, response, Number(url.searchParams.get('after') || 0));
62
- return;
63
- }
64
- if (await routeAgents(context) || await routeSessions(context))
58
+ if (await routeAgents(context))
65
59
  return;
66
60
  sendJson(response, 404, { error: { code: 'not_found', message: 'Route not found.' } });
67
61
  }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  export { Agents } from './agents.js';
2
2
  export { AgentError, asAgentError } from './errors.js';
3
- export { defineDriver, driverSpecifiers, loadDriverModules } from './drivers.js';
4
3
  export { definitionHash, normalizeDefinition, patchDefinition } from './definition.js';
5
- export { messageText, normalizeMessage } from './messages.js';
6
4
  export type * from './types.js';
7
5
  export { buildCanonicalSkillRoots, classifySkillRoot } from './skills/roots.js';
8
6
  export type { SkillRootClassification, SkillRootOptions } from './skills/roots.js';
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  export { Agents } from './agents.js';
2
2
  export { AgentError, asAgentError } from './errors.js';
3
- export { defineDriver, driverSpecifiers, loadDriverModules } from './drivers.js';
4
3
  export { definitionHash, normalizeDefinition, patchDefinition } from './definition.js';
5
- export { messageText, normalizeMessage } from './messages.js';
6
4
  export { buildCanonicalSkillRoots, classifySkillRoot } from './skills/roots.js';
7
5
  export { parseSkillFrontmatter, scanInstalledSkills } from './skills/scanner.js';
8
6
  export { normalizeAgentConfig, stableConfigId } from './config/schema.js';
@@ -41,7 +41,7 @@ export function agentTools(agents) {
41
41
  },
42
42
  {
43
43
  name: 'agents_delete',
44
- description: 'Delete an agent while retaining immutable session history.',
44
+ description: 'Tombstone an agent identity while retaining its immutable revisions.',
45
45
  inputSchema: objectSchema({ agent_id: string }, ['agent_id']),
46
46
  handler(input) {
47
47
  return toolResult({ agent: agents.deleteAgent(stringArg(input, 'agent_id')) });
package/dist/mcp/tools.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { agentTools } from './agent-tools.js';
2
- import { sessionTools } from './session-tools.js';
3
2
  export function createMcpTools(agents) {
4
- return [...agentTools(agents), ...sessionTools(agents)];
3
+ return agentTools(agents);
5
4
  }
package/dist/rows.d.ts CHANGED
@@ -1,7 +1,4 @@
1
- import type { AgentRecord, AgentRevision, AgentSession, AgentTurn, SessionEvent } from './types.js';
1
+ import type { AgentRecord, AgentRevision } from './types.js';
2
2
  export type Row = Record<string, unknown>;
3
3
  export declare function revisionFromRow(row: Row): AgentRevision;
4
4
  export declare function agentFromRow(row: Row): AgentRecord;
5
- export declare function sessionFromRow(row: Row): AgentSession;
6
- export declare function turnFromRow(row: Row): AgentTurn;
7
- export declare function eventFromRow(row: Row): SessionEvent;
package/dist/rows.js CHANGED
@@ -24,42 +24,3 @@ export function agentFromRow(row) {
24
24
  deletedAt: nullable(row.deleted_at),
25
25
  };
26
26
  }
27
- export function sessionFromRow(row) {
28
- return {
29
- id: String(row.id),
30
- agentId: String(row.agent_id),
31
- agentRevisionId: String(row.agent_revision_id),
32
- agentRevision: Number(row.agent_revision_number),
33
- status: String(row.status),
34
- driverSessionId: nullable(row.driver_session_id),
35
- metadata: parseObject(String(row.metadata_json)),
36
- createdAt: String(row.created_at),
37
- updatedAt: String(row.updated_at),
38
- archivedAt: nullable(row.archived_at),
39
- };
40
- }
41
- export function turnFromRow(row) {
42
- return {
43
- id: String(row.id),
44
- sessionId: String(row.session_id),
45
- idempotencyKey: String(row.idempotency_key),
46
- status: String(row.status),
47
- input: JSON.parse(String(row.input_json)),
48
- result: row.result_json ? parseObject(String(row.result_json)) : null,
49
- error: row.error_json ? parseObject(String(row.error_json)) : null,
50
- createdAt: String(row.created_at),
51
- startedAt: nullable(row.started_at),
52
- completedAt: nullable(row.completed_at),
53
- };
54
- }
55
- export function eventFromRow(row) {
56
- return {
57
- id: String(row.id),
58
- sessionId: String(row.session_id),
59
- turnId: nullable(row.turn_id),
60
- sequence: Number(row.sequence),
61
- type: String(row.type),
62
- data: parseObject(String(row.data_json)),
63
- createdAt: String(row.created_at),
64
- };
65
- }