@synadia-ai/agent-fabric 0.1.0 → 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.
- package/CHANGELOG.md +14 -1
- package/README.md +104 -0
- package/dist/cli.cjs +681 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +679 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +973 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +258 -9
- package/dist/index.d.ts +258 -9
- package/dist/index.js +962 -67
- package/dist/index.js.map +1 -1
- package/examples/answer-questions.mjs +33 -0
- package/examples/ask.mjs +22 -0
- package/examples/every.mjs +28 -0
- package/examples/list-agents.mjs +21 -0
- package/examples/prompt.mjs +25 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,19 @@ All notable changes to `@synadia-ai/agent-fabric` are recorded here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the
|
|
5
5
|
package follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
## [0.
|
|
7
|
+
## [0.2.0] — Unreleased
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- A caller: `fabricCaller()` and `fabricCallerFromEnv()` prompt your agents with the creds file the console gave you and nothing else. Every prompt is signed and starts a task of its own; `prompt()` returns the SDK's stream with the task's root id, `ask()` the whole reply with it. `list()`, `find()`, `close()`, `pickAgent()` and `FabricCallerError`.
|
|
12
|
+
- The `agent-fabric` command: `agent-fabric agents` and `agent-fabric prompt <address or kind> "<text>"`, with `--creds`, `--url`, `--timeout` and `--json`. Run it with `npx @synadia-ai/agent-fabric`.
|
|
13
|
+
- Five examples in the package's `examples/`: one prompt, a reply in a script, questions answered, the agents listed, topics prompted on an interval.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- `@nats-io/transport-node` is a dependency: the caller opens its own connection.
|
|
18
|
+
|
|
19
|
+
## [0.1.0] — 2026-10-06
|
|
8
20
|
|
|
9
21
|
### Added
|
|
10
22
|
|
|
@@ -17,4 +29,5 @@ package follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
17
29
|
- Short artifact references: `sp-r1:` tokens accepted alongside `sp-ref:`.
|
|
18
30
|
- The harness plugins' shared pieces: the extension contract's types, `loopGuard()`, `resolveEdgeSubject()` and ScratchPad's plugin settings.
|
|
19
31
|
|
|
32
|
+
[0.2.0]: https://github.com/synadia-ai/agent-fabric-sdk/tree/main/typescript
|
|
20
33
|
[0.1.0]: https://github.com/synadia-ai/agent-fabric-sdk/tree/main/typescript
|
package/README.md
CHANGED
|
@@ -19,6 +19,8 @@ Node 20 or later; the native ScratchPad writer needs Node 22.13+.
|
|
|
19
19
|
|
|
20
20
|
## What it gives
|
|
21
21
|
|
|
22
|
+
- **A caller:** `fabricCaller()` and the `agent-fabric` command, to prompt
|
|
23
|
+
your agents with the creds file the console gave you (below).
|
|
22
24
|
- **Tracing:** `fabricTracing()` and `traceHeaders()`.
|
|
23
25
|
- **Durable runs** joined to the task that started them:
|
|
24
26
|
`durableRunId(toolCallId)`, `durableTrace()`, `durableHeaders(trace)` and
|
|
@@ -43,6 +45,108 @@ Node 20 or later; the native ScratchPad writer needs Node 22.13+.
|
|
|
43
45
|
brings its ScratchPad client behind the `ScratchPad` port, or takes the
|
|
44
46
|
ready one below.
|
|
45
47
|
|
|
48
|
+
## Prompt your agents
|
|
49
|
+
|
|
50
|
+
All a caller needs is the creds file the console gave you and the URL it
|
|
51
|
+
showed next to that file. The command and the helper below connect with that
|
|
52
|
+
file and sign every prompt with its key. Each prompt is traced as a task of its
|
|
53
|
+
own, so the console shows it with everything the agent did for it.
|
|
54
|
+
|
|
55
|
+
### From the command line
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
export NATS_URL=<the URL the console showed>
|
|
59
|
+
npx @synadia-ai/agent-fabric agents --creds ./my.creds
|
|
60
|
+
npx @synadia-ai/agent-fabric prompt writer "Write two lines about the sea." --creds ./my.creds
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- `agents` lists the agents your creds file can reach: the address, the kind
|
|
64
|
+
and the agent's own registered identity (`agent identity: none` when it
|
|
65
|
+
registered none; your prompts are signed either way).
|
|
66
|
+
- `prompt <address or kind> "<text>"` streams the reply to stdout. An agent
|
|
67
|
+
is named by its address, or by its kind when exactly one agent has it.
|
|
68
|
+
- On stderr: the URL, the agent and its identity, `root <id>` (the task's root id, which is
|
|
69
|
+
how the console finds the task), and `reference: <token>` when the reply
|
|
70
|
+
hands back a ScratchPad reference.
|
|
71
|
+
- A question the agent asks mid-reply is printed on stderr, prefixed `? `.
|
|
72
|
+
The next line on stdin answers it. With no input, the agent is told the
|
|
73
|
+
caller cannot answer and goes on.
|
|
74
|
+
|
|
75
|
+
| Flag | What |
|
|
76
|
+
| ---------------- | ---------------------------------------------------------------------------- |
|
|
77
|
+
| `--creds <file>` | the creds file; default `NATS_CREDS` |
|
|
78
|
+
| `--url <url>` | the URL the console showed; default `NATS_URL`. There is no built-in default |
|
|
79
|
+
| `--timeout <s>` | how long to wait for the whole reply; default 600 seconds |
|
|
80
|
+
| `--json` | one JSON object, `{"root", "text", "references"}`, instead of the stream |
|
|
81
|
+
|
|
82
|
+
Exit codes: `0` done; `1` no such agent, a refused prompt, or no connection;
|
|
83
|
+
`2` a usage error, or no creds file or URL.
|
|
84
|
+
|
|
85
|
+
### From code
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { fabricCaller } from "@synadia-ai/agent-fabric";
|
|
89
|
+
|
|
90
|
+
const caller = await fabricCaller({ creds: "./my.creds", url: process.env.NATS_URL });
|
|
91
|
+
try {
|
|
92
|
+
// The whole reply as a string.
|
|
93
|
+
const { text, rootId } = await caller.ask("writer", "Name three rivers.");
|
|
94
|
+
|
|
95
|
+
// Or streamed: the SDK's messages, unchanged.
|
|
96
|
+
const prompt = await caller.prompt("writer", "Write two lines about the sea.");
|
|
97
|
+
for await (const msg of prompt.stream) {
|
|
98
|
+
if (msg.type === "response") process.stdout.write(msg.text);
|
|
99
|
+
}
|
|
100
|
+
console.log(`root ${await prompt.rootId}`);
|
|
101
|
+
} finally {
|
|
102
|
+
await caller.close();
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `fabricCaller({ creds, url?, name?, edgeSubject? })` connects. `url`
|
|
107
|
+
defaults to `NATS_URL`. `fabricCallerFromEnv()` reads `NATS_CREDS` and
|
|
108
|
+
`NATS_URL`.
|
|
109
|
+
- `list()` returns the agents. `find(who)` returns one by address, or by
|
|
110
|
+
kind when exactly one agent has it. `agents` is the protocol SDK's client,
|
|
111
|
+
for anything else.
|
|
112
|
+
- `prompt(who, text, options?)` returns `{ stream, rootId }`. `rootId`
|
|
113
|
+
resolves once you start iterating the stream, before the first chunk.
|
|
114
|
+
Await it after iteration has begun, never before. If the prompt never goes
|
|
115
|
+
out (the stream is cancelled, or fails first), `rootId` rejects instead.
|
|
116
|
+
`stream` passes the SDK's `PromptStream` through, with its `subject` and
|
|
117
|
+
`cancel()`.
|
|
118
|
+
- `ask(who, text, { onQuery? })` returns `{ text, rootId }`. `onQuery`
|
|
119
|
+
answers a question the agent asks. Without it, the agent is told the
|
|
120
|
+
caller cannot answer.
|
|
121
|
+
- `close()` closes the connection and wipes the credentials from memory.
|
|
122
|
+
|
|
123
|
+
Errors are `FabricCallerError`s with a `reason`:
|
|
124
|
+
|
|
125
|
+
| `reason` | When |
|
|
126
|
+
| ----------- | --------------------------------------------------------------------------------------------------------------------- |
|
|
127
|
+
| `config` | no creds file, or no URL |
|
|
128
|
+
| `connect` | the server at the URL cannot be reached, or refuses the creds file; the message names the URL and the server's reason |
|
|
129
|
+
| `identity` | the server will not tell the creds file's identity, which signing needs |
|
|
130
|
+
| `not-found` | no agent by that address or kind; the message lists the agents there |
|
|
131
|
+
| `ambiguous` | more than one agent of that kind; the message lists their addresses |
|
|
132
|
+
| `not-sent` | the prompt never went out, so it has no root (from `rootId`) |
|
|
133
|
+
|
|
134
|
+
A prompt the agent refuses fails the stream with the protocol SDK's error.
|
|
135
|
+
|
|
136
|
+
### Examples
|
|
137
|
+
|
|
138
|
+
The package ships five examples in `node_modules/@synadia-ai/agent-fabric/examples/`.
|
|
139
|
+
Each runs alone with `NATS_URL` and `NATS_CREDS` set, and its first lines
|
|
140
|
+
name the command to run:
|
|
141
|
+
|
|
142
|
+
| File | What |
|
|
143
|
+
| ---------------------- | ------------------------------------------------ |
|
|
144
|
+
| `prompt.mjs` | one prompt, streamed, its root printed |
|
|
145
|
+
| `ask.mjs` | a reply as a string, in a script |
|
|
146
|
+
| `answer-questions.mjs` | the agent's questions answered from the terminal |
|
|
147
|
+
| `list-agents.mjs` | the agents your creds file can reach |
|
|
148
|
+
| `every.mjs` | a list of topics prompted on an interval |
|
|
149
|
+
|
|
46
150
|
## Tracing
|
|
47
151
|
|
|
48
152
|
`fabricTracing()` returns the three hooks the protocol SDK takes: the prompt
|