@synadia-ai/agent-fabric 0.0.0-stage → 0.1.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 +20 -0
- package/LICENSE +201 -0
- package/README.md +184 -2
- package/THIRD_PARTY_NOTICES +23 -0
- package/dist/index.cjs +4821 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1529 -0
- package/dist/index.d.ts +1529 -0
- package/dist/index.js +4733 -0
- package/dist/index.js.map +1 -0
- package/package.json +83 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@synadia-ai/agent-fabric` are recorded here. The format
|
|
4
|
+
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the
|
|
5
|
+
package follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] — unreleased
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Tracing: `fabricTracing()`, the protocol SDK's three hooks, and `traceHeaders()` for model calls.
|
|
12
|
+
- Durable runs joined to the task that started them: `durableRunId`, `durableTrace`, `durableHeaders` and `withDurableTrace`.
|
|
13
|
+
- The `served` record for a harness plugin's add-on: `buildServedRecord`, `servedPublisher` and `validHarnessThreadId`.
|
|
14
|
+
- The ScratchPad extension for the agent tools, `scratchPadExtension`, with the grant request's two sides, `requestGrant` and `grantRequestEndpoint`.
|
|
15
|
+
- The native ScratchPad client: `nativeScratchPad`, `nativeScratchPadFromEnv` and `scratchPadReader`.
|
|
16
|
+
- The ScratchPad CLI adapter over `sp`: `spCliScratchPad` and `scratchPadFromEnv`.
|
|
17
|
+
- Short artifact references: `sp-r1:` tokens accepted alongside `sp-ref:`.
|
|
18
|
+
- The harness plugins' shared pieces: the extension contract's types, `loopGuard()`, `resolveEdgeSubject()` and ScratchPad's plugin settings.
|
|
19
|
+
|
|
20
|
+
[0.1.0]: https://github.com/synadia-ai/agent-fabric-sdk/tree/main/typescript
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a fee
|
|
167
|
+
for, acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf and
|
|
170
|
+
on Your sole responsibility, not on behalf of any other Contributor,
|
|
171
|
+
and only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Synadia Communications
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,185 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @synadia-ai/agent-fabric
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The SDK for agents on the Synadia Agent Fabric, for TypeScript, built on the
|
|
4
|
+
hooks of the Synadia Agent Protocol SDK (`@synadia-ai/agents`,
|
|
5
|
+
`@synadia-ai/agent-service`). The
|
|
6
|
+
[repository](https://github.com/synadia-ai/agent-fabric-sdk#readme) has the
|
|
7
|
+
Python twin, the reference agents and the design notes.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @synadia-ai/agent-fabric
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The package needs the protocol SDK's two packages, `@synadia-ai/agents` (the
|
|
16
|
+
client) and `@synadia-ai/agent-service` (the host). They are its dependencies
|
|
17
|
+
and install with it; your agent imports `Agents` and `AgentService` from them.
|
|
18
|
+
Node 20 or later; the native ScratchPad writer needs Node 22.13+.
|
|
19
|
+
|
|
20
|
+
## What it gives
|
|
21
|
+
|
|
22
|
+
- **Tracing:** `fabricTracing()` and `traceHeaders()`.
|
|
23
|
+
- **Durable runs** joined to the task that started them:
|
|
24
|
+
`durableRunId(toolCallId)`, `durableTrace()`, `durableHeaders(trace)` and
|
|
25
|
+
`withDurableTrace(trace, turnCount, fn)`,
|
|
26
|
+
with no dependency on a durable-execution library
|
|
27
|
+
([`docs/durable.md`](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/docs/durable.md)).
|
|
28
|
+
- **The `served` record**, for a harness plugin's add-on: the plugin's
|
|
29
|
+
binding of a served thread to the harness's own thread id, two records
|
|
30
|
+
per prompt (`served.json`). `buildServedRecord(…)` writes one, from the
|
|
31
|
+
agent, the thread and root, the harness, its thread id, the phase and, on
|
|
32
|
+
`end`, the status; `servedPublisher({ agents, subject? })` publishes a
|
|
33
|
+
prompt's pair through the plugin's own client, signed with the record id
|
|
34
|
+
as nonce, in the order the records were due, counted with the edges:
|
|
35
|
+
`beginTurn(scope, harness)` when the prompt arrives, then
|
|
36
|
+
`bind(harnessThreadId)` for `start` and `settle(status, atMs?)` for
|
|
37
|
+
`end`; `flush()` before stopping. `validHarnessThreadId` is the rule an
|
|
38
|
+
id must pass. PI writes none: the fabric's headers go on its own calls.
|
|
39
|
+
- **The ScratchPad extension** for the agent tools:
|
|
40
|
+
`scratchPadExtension({ scratchPad, agents })` in `AgentTools`'
|
|
41
|
+
`extensions`, with the grant request's two sides, `requestGrant` and
|
|
42
|
+
`grantRequestEndpoint` (an `AgentService` extra endpoint). The agent
|
|
43
|
+
brings its ScratchPad client behind the `ScratchPad` port, or takes the
|
|
44
|
+
ready one below.
|
|
45
|
+
|
|
46
|
+
## Tracing
|
|
47
|
+
|
|
48
|
+
`fabricTracing()` returns the three hooks the protocol SDK takes: the prompt
|
|
49
|
+
interceptor for the client, the request interceptor and the heartbeat extras
|
|
50
|
+
for the host. Every served prompt then runs inside a trace scope, every prompt
|
|
51
|
+
the agent sends to another agent becomes a child thread with a signed `edge`
|
|
52
|
+
record on `TRACE.edges`, and `traceHeaders()` gives the two headers the model
|
|
53
|
+
proxy files a model call by.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { Agents } from "@synadia-ai/agents";
|
|
57
|
+
import { AgentService } from "@synadia-ai/agent-service";
|
|
58
|
+
import { fabricTracing, traceHeaders } from "@synadia-ai/agent-fabric";
|
|
59
|
+
|
|
60
|
+
const tracing = fabricTracing(); // edges to TRACE.edges; { edgeSubject: null } only propagates
|
|
61
|
+
const agents = new Agents({ nc, identity: { signer }, interceptors: [tracing.promptInterceptor] });
|
|
62
|
+
const svc = new AgentService({
|
|
63
|
+
nc,
|
|
64
|
+
agent: "triage",
|
|
65
|
+
owner: "acme",
|
|
66
|
+
name: "main",
|
|
67
|
+
interceptors: [tracing.requestInterceptor],
|
|
68
|
+
heartbeatExtras: tracing.heartbeatExtras,
|
|
69
|
+
});
|
|
70
|
+
svc.onPrompt(async (envelope, response) => {
|
|
71
|
+
const answer = await callModel(envelope.prompt, { headers: traceHeaders() });
|
|
72
|
+
const [lookup] = await agents.discover({ filter: { agent: "lookup" } }); // a child thread:
|
|
73
|
+
for await (const m of await lookup!.prompt(answer, { context: { toolCallId: "toolu_01" } }))
|
|
74
|
+
if (m.type === "response") await response.send(m.text);
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Records are signed, so the agent needs a signed identity; the tool-call ID in
|
|
79
|
+
the prompt's `context` hangs the child thread under the model's tool call.
|
|
80
|
+
|
|
81
|
+
## Durable runs
|
|
82
|
+
|
|
83
|
+
A workflow started from a prompt, usually by a tool call of the agent's
|
|
84
|
+
model, belongs to that prompt's task. The helpers make the join one line; none
|
|
85
|
+
of them depends on a durable-execution SDK.
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import {
|
|
89
|
+
durableHeaders,
|
|
90
|
+
durableRunId,
|
|
91
|
+
durableTrace,
|
|
92
|
+
withDurableTrace,
|
|
93
|
+
} from "@synadia-ai/agent-fabric";
|
|
94
|
+
|
|
95
|
+
// In the prompt's handler: the run id names the served thread and the tool call.
|
|
96
|
+
const runId = durableRunId(toolCallId); // "<thread_id>-<tool call id>", undefined outside a traced handler
|
|
97
|
+
const handle = await client.start(workflow, { task, trace: durableTrace() }, { runId });
|
|
98
|
+
|
|
99
|
+
// Inside a step, on the worker: the trace comes back from the run's input.
|
|
100
|
+
const reply = await model.complete(messages, [], durableHeaders(input.trace));
|
|
101
|
+
const result = await withDurableTrace(input.trace, turnsSoFar, () =>
|
|
102
|
+
tools.execute(name, args, { toolCallId }),
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- `durableRunId(toolCallId)`: `<thread_id>-<tool call id>`, the tool-call id
|
|
107
|
+
held to `[A-Za-z0-9_-]`; use it as the start's idempotency key too.
|
|
108
|
+
- `durableTrace()`: `{ thread_id, root_id }` of the active trace, for the
|
|
109
|
+
run's input.
|
|
110
|
+
- `durableHeaders(trace)`: the proxy's two headers from that trace, for a
|
|
111
|
+
model call inside a step; `{}` for a missing or malformed trace.
|
|
112
|
+
- `withDurableTrace(trace, turnCount, fn)`: binds the trace around code inside
|
|
113
|
+
a step, so a prompt it sends to another agent is filed under the task.
|
|
114
|
+
|
|
115
|
+
See [`docs/durable.md`](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/docs/durable.md)
|
|
116
|
+
for the run id's rules, durable agents, and what is exactly-once.
|
|
117
|
+
|
|
118
|
+
## ScratchPad without writing ScratchPad code
|
|
119
|
+
|
|
120
|
+
Use the native client for SDK agents without a shell or installed binary:
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { nativeScratchPadFromEnv, scratchPadExtension } from "@synadia-ai/agent-fabric";
|
|
124
|
+
|
|
125
|
+
const scratchPad = await nativeScratchPadFromEnv(process.env, { nc, creator: address });
|
|
126
|
+
const references = scratchPad && scratchPadExtension({ scratchPad, agents });
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
The writer needs Node 22.13+, a configured `SCRATCHPAD_VOLUME`, and a private,
|
|
130
|
+
persistent `SCRATCHPAD_DIR`. It borrows the agent's authenticated connection.
|
|
131
|
+
Use `nativeScratchPad` for explicit options and `scratchPadReader` for a consumer
|
|
132
|
+
that needs no writer workspace. Native clients need no private ScratchPad source.
|
|
133
|
+
See [the native contract](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/docs/scratchpad-native.md)
|
|
134
|
+
for binary artifacts, streamed transfers, error handling, recovery, and qualification scope.
|
|
135
|
+
|
|
136
|
+
### CLI adapter
|
|
137
|
+
|
|
138
|
+
An agent gets ScratchPad by configuration. Two lines: build it from the
|
|
139
|
+
environment, then hand the object to the extension (and the grant request's
|
|
140
|
+
endpoint) and commit and read with it yourself.
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
import { scratchPadFromEnv, scratchPadExtension } from "@synadia-ai/agent-fabric";
|
|
144
|
+
|
|
145
|
+
const scratchPad = scratchPadFromEnv(process.env, { creator: address }); // undefined: ScratchPad off
|
|
146
|
+
const references = scratchPad && scratchPadExtension({ scratchPad, agents });
|
|
147
|
+
// in the handler: const ref = await scratchPad.commit(answer, `/replies/${threadId}.md`, trace);
|
|
148
|
+
// const text = await scratchPad.read(ref, trace);
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
| Variable | Default | |
|
|
152
|
+
| ------------------------ | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
|
|
153
|
+
| `SCRATCHPAD_VOLUME` | unset: ScratchPad off | the volume the agent commits to, by name: letters and digits only, provisioned for the agent's account and user; created on first commit |
|
|
154
|
+
| `SCRATCHPAD_BIN` | `sp` on PATH | the `sp` binary |
|
|
155
|
+
| `SCRATCHPAD_DIR` | `scratchpad-<volume>` under the temp directory | a private directory for the CLI's workspace, used by its real path; keep it across restarts |
|
|
156
|
+
| `SCRATCHPAD_GRANT_TTL_S` | `600` | how long a read grant lasts, in seconds; at most ten minutes, and never past the reference |
|
|
157
|
+
|
|
158
|
+
`sp` connects as the agent does, with `NATS_CREDS` and `NATS_URL` (or pass
|
|
159
|
+
`{ nats }`, the SDK's `NatsConnectionSource`); it reads no NATS context, so a
|
|
160
|
+
`NATS_CONTEXT` without `NATS_CREDS` is refused. The same
|
|
161
|
+
from code: `spCliScratchPad({ volume, nats, bin?, dir?, grantTtlS?, creator? })`,
|
|
162
|
+
both returning a `ScratchPadClient` — the `ScratchPad` port plus
|
|
163
|
+
`commit(text, path, trace)` and `read(reference, trace)`.
|
|
164
|
+
|
|
165
|
+
The CLI adapter drives the sp v2 command line, `sp`, which must be on the
|
|
166
|
+
machine (the [binary guide](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/docs/scratchpad-binaries.md)
|
|
167
|
+
installs a pinned release) and connects with the agent's own credentials. Each
|
|
168
|
+
commit publishes the reply
|
|
169
|
+
retained for ten minutes, and its reference is valid as long; a grant goes
|
|
170
|
+
only to an agent in the reference's own account, as `sp` refuses any other; ScratchPad must be reachable in the tenant's
|
|
171
|
+
account. Both native and CLI clients implement the existing `ScratchPadClient`
|
|
172
|
+
interface; the Fabric reference policy uses that interface.
|
|
173
|
+
|
|
174
|
+
## Short artifact references
|
|
175
|
+
|
|
176
|
+
The client accepts `sp-r1:` short tokens and existing `sp-ref:` tokens.
|
|
177
|
+
Publication uses the short form when the service and the selected client support it.
|
|
178
|
+
Copy the returned token unchanged into prompts and replies.
|
|
179
|
+
The token survives client restarts; each content read still requires current authorization.
|
|
180
|
+
See the [native client contract](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/docs/scratchpad-native.md) for recovery and capability fallback.
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
Apache-2.0. See [LICENSE](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/typescript/LICENSE)
|
|
185
|
+
and [THIRD_PARTY_NOTICES](https://github.com/synadia-ai/agent-fabric-sdk/blob/main/typescript/THIRD_PARTY_NOTICES).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The compiled package includes the Unassigned-category regular expression from
|
|
2
|
+
@unicode/unicode-15.0.0 version 2.0.7 (MIT).
|
|
3
|
+
Source: https://github.com/node-unicode/unicode-15.0.0
|
|
4
|
+
License: https://github.com/node-unicode/node-unicode-data/blob/main/LICENSE-MIT.txt
|
|
5
|
+
|
|
6
|
+
Copyright Mathias Bynens <https://mathiasbynens.be/>
|
|
7
|
+
|
|
8
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
|
+
a copy of this software and associated documentation files (the
|
|
10
|
+
"Software"), to deal in the Software without restriction, including
|
|
11
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
14
|
+
the following conditions:
|
|
15
|
+
The above copyright notice and this permission notice shall be
|
|
16
|
+
included in all copies or substantial portions of the Software.
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|