marona 2.1.0 → 2.3.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 +6 -0
- package/README.md +38 -39
- package/dist/b2a-codec.d.ts +44 -0
- package/dist/b2a-codec.d.ts.map +1 -0
- package/dist/b2a-codec.js +194 -0
- package/dist/b2a-codec.js.map +1 -0
- package/dist/b2a-runner.d.ts +60 -0
- package/dist/b2a-runner.d.ts.map +1 -0
- package/dist/b2a-runner.js +175 -0
- package/dist/b2a-runner.js.map +1 -0
- package/dist/b2a.d.ts +1 -0
- package/dist/b2a.d.ts.map +1 -1
- package/dist/b2a.js +1 -0
- package/dist/b2a.js.map +1 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 2.3.0 — 2026-11-11
|
|
2
|
+
|
|
3
|
+
- Add Agent-bound B2A configuration and B2ARunner persistent sessions with user/session identity.
|
|
4
|
+
- Add independent HTTP/MCP codec providers, typed feedback events, delivery acknowledgment, and automatic protocol state management.
|
|
5
|
+
- Replace manual B2A workflow examples with the runner API.
|
|
6
|
+
|
|
1
7
|
# 2.0.1 — 2026-10-24
|
|
2
8
|
|
|
3
9
|
## 2.1.0 — 2026-11-11
|
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@ Hub capabilities, streaming, realtime and A2A collaboration.
|
|
|
5
5
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
|
-
Version **2.
|
|
8
|
+
Version **2.3.0**. [Package registry](https://www.npmjs.com/package/marona/v/2.1.0).
|
|
9
9
|
|
|
10
10
|
Node.js 20+; run this server example with tsx.
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
npm install marona@2.
|
|
13
|
+
npm install marona@2.3.0
|
|
14
14
|
npm install --save-dev typescript tsx @types/node
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -147,51 +147,50 @@ Push notifications are not implemented.
|
|
|
147
147
|
Native B2A v0.1 exchanges decoded semantic intent and agent responses. The
|
|
148
148
|
independent neural service owns signal decoding and feedback encoding, with
|
|
149
149
|
vendor-hosted MCP, HTTP or local plugin backends. Models and device drivers
|
|
150
|
-
are supplied by the interface provider
|
|
150
|
+
are supplied by the interface provider. Configure `Agent.b2a` and connect with
|
|
151
|
+
`B2ARunner`, following the persistent realtime session lifecycle. These examples
|
|
152
|
+
read one captured signal file using your configured provider.
|
|
151
153
|
|
|
152
154
|
Save as `examples/b2a_example.mts`:
|
|
153
155
|
|
|
154
156
|
```typescript
|
|
155
|
-
import { readFile } from
|
|
156
|
-
import {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
consent: { granted: true, scopes: ["intent", "feedback", "context"] },
|
|
169
|
-
capabilities: { input: ["semantic.intent"], output: ["application/json"] },
|
|
170
|
-
agent: { name: "B2A Assistant", model: process.env.MARONA_MODEL ?? "marona/auto",
|
|
171
|
-
instructions: "Interpret the decoded intent in context. Preserve uncertainty and ask when clarification is needed." },
|
|
172
|
-
context: { source: "decoder-output-example" },
|
|
157
|
+
import { readFile } from 'node:fs/promises';
|
|
158
|
+
import { Agent, B2A, B2ACodec, B2ARunner, Marona } from 'marona';
|
|
159
|
+
const env = process.env;
|
|
160
|
+
const signal = JSON.parse(await readFile(process.argv[2]!, 'utf8'));
|
|
161
|
+
const client = new Marona({ apiKey: env.MARONA_API_KEY });
|
|
162
|
+
const neuralService = new B2ACodec(env.B2A_CODEC_URL!, {
|
|
163
|
+
token: env.B2A_NEURAL_TOKEN!, transport: (env.B2A_CODEC_TRANSPORT ?? 'mcp') as 'mcp' | 'http',
|
|
164
|
+
});
|
|
165
|
+
const agent = new Agent({
|
|
166
|
+
name: 'B2A Intent Agent', model: env.MARONA_MODEL ?? 'marona/auto',
|
|
167
|
+
instructions: 'Interpret decoded intent in context. Preserve uncertainty and use connected tools under Marona permissions.',
|
|
168
|
+
tools: await client.hub.connect(),
|
|
169
|
+
b2a: new B2A({ provider: neuralService, outputProfile: env.B2A_OUTPUT_PROFILE! }),
|
|
173
170
|
});
|
|
171
|
+
const session = await B2ARunner.connect(agent, { userId: env.B2A_USER_ID!, sessionId: env.B2A_SESSION_ID! });
|
|
174
172
|
try {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const exchange = await client.b2a.sendMessage(session.session_id, message);
|
|
182
|
-
// Forward agent.response payloads to your independent encoder. Its delivery result
|
|
183
|
-
// determines whether to send feedback.ack; simply receiving JSON is not presentation.
|
|
184
|
-
console.log(JSON.stringify(exchange, null, 2));
|
|
185
|
-
} finally {
|
|
186
|
-
await client.b2a.closeSession(session.session_id);
|
|
187
|
-
}
|
|
173
|
+
await session.sendSignal(signal);
|
|
174
|
+
for await (const event of session) {
|
|
175
|
+
console.log(event);
|
|
176
|
+
if (['feedback', 'signal.status', 'error'].includes(event.type)) break;
|
|
177
|
+
}
|
|
178
|
+
} finally { await session.close(); }
|
|
188
179
|
```
|
|
189
180
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
181
|
+
The SDK manages protocol messages, sequencing, event cursors, decoding and encoding.
|
|
182
|
+
Set B2A_CODEC_URL, B2A_NEURAL_TOKEN, B2A_OUTPUT_PROFILE, B2A_USER_ID and
|
|
183
|
+
B2A_SESSION_ID. Use B2A_CODEC_TRANSPORT=mcp or http. `session_id` identifies
|
|
184
|
+
an application conversation; each connection gets a separate native transport
|
|
185
|
+
session. The application authorizes processing before connecting; device and
|
|
186
|
+
protocol scope fields are supplied internally. Closing revokes those scopes.
|
|
187
|
+
|
|
188
|
+
Keep the session open to send more signals. Feedback events contain encoded
|
|
189
|
+
output; printing them does not deliver feedback. An interface driver acknowledges
|
|
190
|
+
presentation only after delivery. Failed or uncertain sends are never replayed
|
|
191
|
+
automatically. Native B2A supports server-hosted Hub tools and agent graphs;
|
|
192
|
+
SDK-local functions, callbacks and peer callbacks require server-hosted equivalents.
|
|
193
|
+
B2A v0.1 uses HTTP JSON and retained cursor events, not WebSocket transport.
|
|
195
194
|
See the repository's `docs/b2a-protocol.md` for the complete wire contract.
|
|
196
195
|
|
|
197
196
|
## Execution and errors
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { B2AIntent, type B2AJsonObject } from "./b2a.js";
|
|
2
|
+
export type B2ADecodeStatus = "decoded" | "abstain" | "poor_signal" | "calibration_required";
|
|
3
|
+
export interface B2ADecodeResult {
|
|
4
|
+
status: B2ADecodeStatus;
|
|
5
|
+
intent: B2AIntent | null;
|
|
6
|
+
provenance: B2AJsonObject;
|
|
7
|
+
uncertainty: B2AJsonObject;
|
|
8
|
+
}
|
|
9
|
+
export interface B2AEncodedFeedback {
|
|
10
|
+
feedbackId: string;
|
|
11
|
+
profile: string;
|
|
12
|
+
mediaType: string;
|
|
13
|
+
content: B2AJsonObject;
|
|
14
|
+
provenance: B2AJsonObject;
|
|
15
|
+
}
|
|
16
|
+
export interface B2ACodecOptions {
|
|
17
|
+
token: string;
|
|
18
|
+
transport?: "http" | "mcp";
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
decodeTool?: string;
|
|
21
|
+
encodeTool?: string;
|
|
22
|
+
decodePath?: string;
|
|
23
|
+
encodePath?: string;
|
|
24
|
+
allowSimulation?: boolean;
|
|
25
|
+
fetch?: typeof globalThis.fetch;
|
|
26
|
+
}
|
|
27
|
+
/** Typed client for independent neural services; does not run neural models. */
|
|
28
|
+
export declare class B2ACodec {
|
|
29
|
+
private readonly url;
|
|
30
|
+
private readonly options;
|
|
31
|
+
constructor(url: string, options: B2ACodecOptions);
|
|
32
|
+
decode(signal: B2AJsonObject, options: {
|
|
33
|
+
consent: boolean;
|
|
34
|
+
}): Promise<B2ADecodeResult>;
|
|
35
|
+
encode(response: B2AJsonObject, options: {
|
|
36
|
+
profile: string;
|
|
37
|
+
consent: boolean;
|
|
38
|
+
context?: B2AJsonObject;
|
|
39
|
+
mediaTypes?: string[];
|
|
40
|
+
}): Promise<B2AEncodedFeedback>;
|
|
41
|
+
private provenance;
|
|
42
|
+
private call;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=b2a-codec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2a-codec.d.ts","sourceRoot":"","sources":["../src/b2a-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AAE3E,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,aAAa,GAAG,sBAAsB,CAAC;AAC7F,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAC;IACxB,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,UAAU,EAAE,aAAa,CAAC;IAC1B,WAAW,EAAE,aAAa,CAAC;CAC5B;AACD,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,aAAa,CAAC;CAC3B;AACD,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,gFAAgF;AAChF,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAS;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA4B;gBACxC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe;IAiB3C,MAAM,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAuBtF,MAAM,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAUlK,OAAO,CAAC,UAAU;YAKJ,IAAI;CAwCnB"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { B2AIntent, B2AProtocolError } from "./b2a.js";
|
|
2
|
+
/** Typed client for independent neural services; does not run neural models. */
|
|
3
|
+
export class B2ACodec {
|
|
4
|
+
url;
|
|
5
|
+
options;
|
|
6
|
+
constructor(url, options) {
|
|
7
|
+
const parsed = new URL(url);
|
|
8
|
+
if (!["http:", "https:"].includes(parsed.protocol) || parsed.username || parsed.password || parsed.search || parsed.hash)
|
|
9
|
+
throw new B2AProtocolError("Codec URL must be HTTP(S) without credentials, query, or fragment");
|
|
10
|
+
if (parsed.protocol === "http:" && !["localhost", "127.0.0.1", "[::1]"].includes(parsed.hostname))
|
|
11
|
+
throw new B2AProtocolError("Remote codec endpoints require HTTPS");
|
|
12
|
+
this.url = parsed.toString().replace(/\/$/, "");
|
|
13
|
+
this.options = { transport: "http", timeoutMs: 60_000, decodeTool: "decode", encodeTool: "encode",
|
|
14
|
+
decodePath: "/v1/decode", encodePath: "/v1/encode", allowSimulation: false, fetch: globalThis.fetch, ...options };
|
|
15
|
+
for (const value of [this.options.token, this.options.decodeTool, this.options.encodeTool])
|
|
16
|
+
text(value);
|
|
17
|
+
for (const path of [this.options.decodePath, this.options.encodePath]) {
|
|
18
|
+
if (!path.startsWith("/") || path.startsWith("//") || /[?#\\]/.test(path))
|
|
19
|
+
throw new B2AProtocolError("Invalid codec path");
|
|
20
|
+
}
|
|
21
|
+
if (!["http", "mcp"].includes(this.options.transport) || typeof this.options.allowSimulation !== "boolean" ||
|
|
22
|
+
!Number.isFinite(this.options.timeoutMs) || this.options.timeoutMs <= 0)
|
|
23
|
+
throw new B2AProtocolError("Invalid codec configuration");
|
|
24
|
+
}
|
|
25
|
+
async decode(signal, options) {
|
|
26
|
+
consent(options.consent);
|
|
27
|
+
const input = object(signal);
|
|
28
|
+
const data = await this.call("decode", { signal: input, consent: true });
|
|
29
|
+
const status = data.status;
|
|
30
|
+
if (!["decoded", "abstain", "poor_signal", "calibration_required"].includes(status))
|
|
31
|
+
throw new B2AProtocolError("Invalid decoder status");
|
|
32
|
+
const provenance = this.provenance(data.provenance ?? {});
|
|
33
|
+
const uncertainty = object(data.uncertainty ?? {});
|
|
34
|
+
let intent = null;
|
|
35
|
+
if (status === "decoded") {
|
|
36
|
+
const metadata = { ...provenance, uncertainty };
|
|
37
|
+
if (input.signal_id != null)
|
|
38
|
+
metadata.signal_id = text(input.signal_id);
|
|
39
|
+
const decoder = {};
|
|
40
|
+
if (provenance.backend != null)
|
|
41
|
+
decoder.id = text(provenance.backend);
|
|
42
|
+
if (provenance.version != null)
|
|
43
|
+
decoder.version = text(provenance.version);
|
|
44
|
+
if (data.confidence != null && typeof data.confidence !== "number")
|
|
45
|
+
throw new B2AProtocolError("Invalid decoder confidence");
|
|
46
|
+
intent = new B2AIntent(data.intent, {
|
|
47
|
+
confidence: data.confidence == null ? undefined : data.confidence,
|
|
48
|
+
provenance: metadata, ...(Object.keys(decoder).length ? { decoder } : {}),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else if (data.intent != null)
|
|
52
|
+
throw new B2AProtocolError("Abstaining decoder returned actionable intent");
|
|
53
|
+
return { status, intent, provenance, uncertainty };
|
|
54
|
+
}
|
|
55
|
+
async encode(response, options) {
|
|
56
|
+
consent(options.consent);
|
|
57
|
+
const profile = text(options.profile), media = options.mediaTypes ?? ["application/json"];
|
|
58
|
+
if (!media.length)
|
|
59
|
+
throw new B2AProtocolError("At least one interface media type is required");
|
|
60
|
+
media.forEach(text);
|
|
61
|
+
const data = await this.call("encode", { request: { response: object(response), profile, context: object(options.context ?? {}) }, consent: true });
|
|
62
|
+
if (data.profile !== profile || !media.includes(data.media_type))
|
|
63
|
+
throw new B2AProtocolError("Encoder output does not match interface capabilities");
|
|
64
|
+
return { feedbackId: text(data.feedback_id), profile, mediaType: text(data.media_type),
|
|
65
|
+
content: object(data.content), provenance: this.provenance(data.provenance ?? {}) };
|
|
66
|
+
}
|
|
67
|
+
provenance(value) {
|
|
68
|
+
const result = object(value), flag = Object.hasOwn(result, "simulation") ? result.simulation : false;
|
|
69
|
+
if (typeof flag !== "boolean" || (flag && !this.options.allowSimulation))
|
|
70
|
+
throw new B2AProtocolError("Neural output failed provenance validation");
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
async call(operation, arguments_) {
|
|
74
|
+
const controller = new AbortController();
|
|
75
|
+
const timer = setTimeout(() => controller.abort(), this.options.timeoutMs);
|
|
76
|
+
const headers = { Authorization: `Bearer ${this.options.token}`, "Content-Type": "application/json", Accept: "application/json, text/event-stream" };
|
|
77
|
+
let sessionId = null;
|
|
78
|
+
const post = async (body, path = "") => {
|
|
79
|
+
const response = await this.options.fetch(this.url + path, { method: "POST", headers, body: JSON.stringify(body), redirect: "error", signal: controller.signal });
|
|
80
|
+
if (!response.ok)
|
|
81
|
+
throw new B2AProtocolError(`Neural service returned HTTP ${response.status}`);
|
|
82
|
+
return response;
|
|
83
|
+
};
|
|
84
|
+
try {
|
|
85
|
+
if (this.options.transport === "http") {
|
|
86
|
+
const response = await post(arguments_, operation === "decode" ? this.options.decodePath : this.options.encodePath);
|
|
87
|
+
return object(await response.json());
|
|
88
|
+
}
|
|
89
|
+
const initialization = await post({ jsonrpc: "2.0", id: 1, method: "initialize", params: {
|
|
90
|
+
protocolVersion: "2025-11-25", capabilities: {}, clientInfo: { name: "marona", version: "2.3.0" },
|
|
91
|
+
} });
|
|
92
|
+
sessionId = initialization.headers.get("mcp-session-id");
|
|
93
|
+
if (sessionId)
|
|
94
|
+
headers["Mcp-Session-Id"] = sessionId;
|
|
95
|
+
const initialized = await rpc(initialization, 1);
|
|
96
|
+
const version = text(initialized.protocolVersion);
|
|
97
|
+
if (!["2025-11-25", "2025-06-18", "2025-03-26"].includes(version))
|
|
98
|
+
throw new B2AProtocolError("Unsupported MCP protocol version");
|
|
99
|
+
headers["MCP-Protocol-Version"] = version;
|
|
100
|
+
const notification = await post({ jsonrpc: "2.0", method: "notifications/initialized" });
|
|
101
|
+
await notification.body?.cancel();
|
|
102
|
+
const result = await rpc(await post({ jsonrpc: "2.0", id: 2, method: "tools/call", params: {
|
|
103
|
+
name: operation === "decode" ? this.options.decodeTool : this.options.encodeTool, arguments: arguments_,
|
|
104
|
+
} }), 2);
|
|
105
|
+
const structured = object(result.structuredContent);
|
|
106
|
+
if (result.isError === true || structured.success !== true)
|
|
107
|
+
throw new B2AProtocolError("Neural MCP tool failed");
|
|
108
|
+
return object(structured.data);
|
|
109
|
+
}
|
|
110
|
+
finally {
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
if (sessionId) {
|
|
113
|
+
try {
|
|
114
|
+
const response = await this.options.fetch(this.url, { method: "DELETE", headers, redirect: "error", signal: AbortSignal.timeout(1000) });
|
|
115
|
+
await response.body?.cancel();
|
|
116
|
+
}
|
|
117
|
+
catch { /* Best-effort session cleanup only. */ }
|
|
118
|
+
}
|
|
119
|
+
controller.abort();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function consent(value) { if (value !== true)
|
|
124
|
+
throw new B2AProtocolError("Neural processing requires explicit consent"); }
|
|
125
|
+
function text(value) { if (typeof value !== "string" || !value.trim())
|
|
126
|
+
throw new B2AProtocolError("Expected nonempty codec text"); return value; }
|
|
127
|
+
function object(value) {
|
|
128
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
129
|
+
throw new B2AProtocolError("Expected a codec JSON object");
|
|
130
|
+
const seen = new Set();
|
|
131
|
+
const visit = (v) => {
|
|
132
|
+
if (v === null || typeof v === "string" || typeof v === "boolean" || (typeof v === "number" && Number.isFinite(v)))
|
|
133
|
+
return;
|
|
134
|
+
if (typeof v !== "object" || !v || seen.has(v))
|
|
135
|
+
throw new B2AProtocolError("Codec values must be finite JSON");
|
|
136
|
+
if (!Array.isArray(v) && Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null)
|
|
137
|
+
throw new B2AProtocolError("Codec values must be plain JSON");
|
|
138
|
+
seen.add(v);
|
|
139
|
+
Object.values(v).forEach(visit);
|
|
140
|
+
seen.delete(v);
|
|
141
|
+
};
|
|
142
|
+
visit(value);
|
|
143
|
+
return JSON.parse(JSON.stringify(value));
|
|
144
|
+
}
|
|
145
|
+
async function rpc(response, id) {
|
|
146
|
+
const check = (value) => {
|
|
147
|
+
const message = object(value);
|
|
148
|
+
if (message.id !== id)
|
|
149
|
+
return null;
|
|
150
|
+
if (message.jsonrpc !== "2.0" || message.error !== undefined)
|
|
151
|
+
throw new B2AProtocolError("Neural MCP request failed");
|
|
152
|
+
return object(message.result);
|
|
153
|
+
};
|
|
154
|
+
if (!response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
155
|
+
const result = check(await response.json());
|
|
156
|
+
if (result)
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
else if (response.body) {
|
|
160
|
+
const reader = response.body.getReader(), decoder = new TextDecoder();
|
|
161
|
+
let buffer = "", data = [], size = 0;
|
|
162
|
+
try {
|
|
163
|
+
while (true) {
|
|
164
|
+
const chunk = await reader.read();
|
|
165
|
+
if (chunk.done)
|
|
166
|
+
break;
|
|
167
|
+
size += chunk.value.length;
|
|
168
|
+
if (size > 2_097_152)
|
|
169
|
+
throw new B2AProtocolError("MCP response exceeds size limit");
|
|
170
|
+
buffer += decoder.decode(chunk.value, { stream: true });
|
|
171
|
+
let newline;
|
|
172
|
+
while ((newline = buffer.indexOf("\n")) >= 0) {
|
|
173
|
+
const line = buffer.slice(0, newline).replace(/\r$/, "");
|
|
174
|
+
buffer = buffer.slice(newline + 1);
|
|
175
|
+
if (!line) {
|
|
176
|
+
if (data.length && data.join("\n").trim()) {
|
|
177
|
+
const result = check(JSON.parse(data.join("\n")));
|
|
178
|
+
if (result)
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
data = [];
|
|
182
|
+
}
|
|
183
|
+
else if (line.startsWith("data:"))
|
|
184
|
+
data.push(line.slice(5).replace(/^ /, ""));
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
finally {
|
|
189
|
+
await reader.cancel();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
throw new B2AProtocolError("MCP response did not match the request");
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=b2a-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2a-codec.js","sourceRoot":"","sources":["../src/b2a-codec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAsB,MAAM,UAAU,CAAC;AA4B3E,gFAAgF;AAChF,MAAM,OAAO,QAAQ;IACF,GAAG,CAAS;IACZ,OAAO,CAA4B;IACpD,YAAY,GAAW,EAAE,OAAwB;QAC/C,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ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,IAAI,EAAE,CAAC,CAAC;gBACxD,IAAI,OAAe,CAAC;gBACpB,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;oBAC7C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBAAC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC;oBAC7F,IAAI,CAAC,IAAI,EAAE,CAAC;wBACV,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;4BAAC,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;4BAAC,IAAI,MAAM;gCAAE,OAAO,MAAM,CAAC;wBAAC,CAAC;wBAC5H,IAAI,GAAG,EAAE,CAAC;oBACZ,CAAC;yBAAM,IAAI,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;wBAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;gBAClF,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YAAC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QAAC,CAAC;IACtC,CAAC;IACD,MAAM,IAAI,gBAAgB,CAAC,wCAAwC,CAAC,CAAC;AACvE,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { B2AClient, type B2AJsonObject, type B2ASession } from './b2a.js';
|
|
2
|
+
import type { B2ACodec, B2AEncodedFeedback } from './b2a-codec.js';
|
|
3
|
+
import { type Agent } from './index.js';
|
|
4
|
+
export type B2AProvider = Pick<B2ACodec, 'decode' | 'encode'>;
|
|
5
|
+
export declare class B2A {
|
|
6
|
+
readonly provider: B2AProvider;
|
|
7
|
+
readonly outputProfile: string;
|
|
8
|
+
readonly outputMediaTypes: string[];
|
|
9
|
+
readonly context: B2AJsonObject;
|
|
10
|
+
readonly execute: boolean;
|
|
11
|
+
constructor(options: {
|
|
12
|
+
provider: B2AProvider;
|
|
13
|
+
outputProfile: string;
|
|
14
|
+
outputMediaTypes?: string[];
|
|
15
|
+
context?: B2AJsonObject;
|
|
16
|
+
execute?: boolean;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export interface B2ASessionEvent {
|
|
20
|
+
type: string;
|
|
21
|
+
data: B2AJsonObject;
|
|
22
|
+
responseId?: string;
|
|
23
|
+
feedback?: B2AEncodedFeedback;
|
|
24
|
+
}
|
|
25
|
+
/** Persistent SDK connection; native session identity remains separate from conversation identity. */
|
|
26
|
+
export declare class B2AConnection implements AsyncIterableIterator<B2ASessionEvent> {
|
|
27
|
+
private client;
|
|
28
|
+
private config;
|
|
29
|
+
private snapshot;
|
|
30
|
+
readonly sessionId: string;
|
|
31
|
+
readonly protocolSessionId: string;
|
|
32
|
+
private cursor;
|
|
33
|
+
private queue;
|
|
34
|
+
private closed;
|
|
35
|
+
private failed;
|
|
36
|
+
private pending;
|
|
37
|
+
private tail;
|
|
38
|
+
constructor(client: B2AClient, config: B2A, snapshot: B2ASession, sessionId: string);
|
|
39
|
+
get status(): string;
|
|
40
|
+
private serial;
|
|
41
|
+
private active;
|
|
42
|
+
sendSignal(signal: B2AJsonObject): Promise<void>;
|
|
43
|
+
private send;
|
|
44
|
+
private poll;
|
|
45
|
+
private accept;
|
|
46
|
+
updateContext(context: B2AJsonObject): Promise<void>;
|
|
47
|
+
respondToApproval(approvalId: string, approved: boolean): Promise<void>;
|
|
48
|
+
acknowledgeFeedback(responseId: string, status: 'presented' | 'failed'): Promise<void>;
|
|
49
|
+
close(): Promise<void>;
|
|
50
|
+
[Symbol.asyncIterator](): AsyncIterableIterator<B2ASessionEvent>;
|
|
51
|
+
return(): Promise<IteratorResult<B2ASessionEvent>>;
|
|
52
|
+
next(): Promise<IteratorResult<B2ASessionEvent>>;
|
|
53
|
+
}
|
|
54
|
+
export declare class B2ARunner {
|
|
55
|
+
static connect(agent: Agent, options: {
|
|
56
|
+
userId: string;
|
|
57
|
+
sessionId: string;
|
|
58
|
+
}): Promise<B2AConnection>;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=b2a-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2a-runner.d.ts","sourceRoot":"","sources":["../src/b2a-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAgC,KAAK,aAAa,EAAE,KAAK,UAAU,EAAiB,MAAM,UAAU,CAAC;AACvH,OAAO,KAAK,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAc,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpD,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAC9D,qBAAa,GAAG;IACd,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;gBACd,OAAO,EAAE;QAAE,QAAQ,EAAE,WAAW,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,CAAC,EAAE,aAAa,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;CAU/I;AACD,MAAM,WAAW,eAAe;IAC9B,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,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAClD,IAAI,IAAI,OAAO,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;CAUvD;AACD,qBAAa,SAAS;WACP,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,aAAa,CAAC;CAQ3G"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { B2AMessage, B2AProtocolError } from './b2a.js';
|
|
2
|
+
import { b2aBinding } from './index.js';
|
|
3
|
+
export class B2A {
|
|
4
|
+
provider;
|
|
5
|
+
outputProfile;
|
|
6
|
+
outputMediaTypes;
|
|
7
|
+
context;
|
|
8
|
+
execute;
|
|
9
|
+
constructor(options) {
|
|
10
|
+
this.provider = options.provider;
|
|
11
|
+
this.outputProfile = options.outputProfile;
|
|
12
|
+
this.outputMediaTypes = [...(options.outputMediaTypes ?? ['application/json'])];
|
|
13
|
+
this.context = structuredClone(options.context ?? {});
|
|
14
|
+
this.execute = options.execute ?? true;
|
|
15
|
+
if (!this.outputProfile?.trim() || !this.outputMediaTypes.length || this.outputMediaTypes.some(v => !v.trim()) ||
|
|
16
|
+
typeof this.provider?.decode !== 'function' || typeof this.provider?.encode !== 'function' || typeof this.execute !== 'boolean')
|
|
17
|
+
throw new B2AProtocolError('Invalid B2A provider configuration');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Persistent SDK connection; native session identity remains separate from conversation identity. */
|
|
21
|
+
export class B2AConnection {
|
|
22
|
+
client;
|
|
23
|
+
config;
|
|
24
|
+
snapshot;
|
|
25
|
+
sessionId;
|
|
26
|
+
protocolSessionId;
|
|
27
|
+
cursor = 0;
|
|
28
|
+
queue = [];
|
|
29
|
+
closed = false;
|
|
30
|
+
failed = false;
|
|
31
|
+
pending = new Set();
|
|
32
|
+
tail = Promise.resolve();
|
|
33
|
+
constructor(client, config, snapshot, sessionId) {
|
|
34
|
+
this.client = client;
|
|
35
|
+
this.config = config;
|
|
36
|
+
this.snapshot = snapshot;
|
|
37
|
+
this.sessionId = sessionId;
|
|
38
|
+
this.protocolSessionId = snapshot.session_id;
|
|
39
|
+
}
|
|
40
|
+
get status() { return this.closed ? 'closed' : this.failed ? 'failed' : this.snapshot.state; }
|
|
41
|
+
serial(operation) {
|
|
42
|
+
const task = this.tail.then(operation);
|
|
43
|
+
this.tail = task.catch(() => { });
|
|
44
|
+
return task;
|
|
45
|
+
}
|
|
46
|
+
async active() {
|
|
47
|
+
if (this.closed || this.failed)
|
|
48
|
+
throw new B2AProtocolError('B2A connection is inactive');
|
|
49
|
+
this.snapshot = await this.client.getSession(this.protocolSessionId);
|
|
50
|
+
const consent = this.snapshot.consent;
|
|
51
|
+
const scopes = consent?.scopes;
|
|
52
|
+
if (this.snapshot.state !== 'active' || consent?.granted !== true || !['intent', 'feedback'].every(v => scopes?.includes(v)))
|
|
53
|
+
throw new B2AProtocolError('B2A session is inactive or authorization was revoked');
|
|
54
|
+
}
|
|
55
|
+
sendSignal(signal) {
|
|
56
|
+
return this.serial(async () => {
|
|
57
|
+
await this.active();
|
|
58
|
+
const decoded = await this.config.provider.decode(signal, { consent: true });
|
|
59
|
+
if (!decoded.intent) {
|
|
60
|
+
if (decoded.status === 'decoded')
|
|
61
|
+
throw new B2AProtocolError('Decoder returned no intent');
|
|
62
|
+
this.queue.push({ type: 'signal.status', data: { status: decoded.status, uncertainty: decoded.uncertainty } });
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (decoded.status !== 'decoded')
|
|
66
|
+
throw new B2AProtocolError('Abstaining decoder returned an intent');
|
|
67
|
+
await this.active();
|
|
68
|
+
await this.send(B2AMessage.intent(this.protocolSessionId, this.snapshot.next_sequence, decoded.intent, { contextRevision: this.snapshot.context_revision, execute: this.config.execute }));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async send(message) {
|
|
72
|
+
try {
|
|
73
|
+
this.snapshot = (await this.client.sendMessage(this.protocolSessionId, message)).session;
|
|
74
|
+
await this.poll();
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.failed = true;
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async poll() {
|
|
82
|
+
const page = await this.client.events(this.protocolSessionId, { after: this.cursor });
|
|
83
|
+
for (const event of page.events) {
|
|
84
|
+
if (event.sequence <= this.cursor)
|
|
85
|
+
continue;
|
|
86
|
+
await this.accept(event);
|
|
87
|
+
this.cursor = event.sequence;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async accept(event) {
|
|
91
|
+
if (event.type === 'agent.response') {
|
|
92
|
+
await this.active();
|
|
93
|
+
const feedback = await this.config.provider.encode(event.payload, { consent: true, profile: this.config.outputProfile,
|
|
94
|
+
mediaTypes: this.config.outputMediaTypes, context: this.snapshot.context });
|
|
95
|
+
if (feedback.profile !== this.config.outputProfile || !this.config.outputMediaTypes.includes(feedback.mediaType))
|
|
96
|
+
throw new B2AProtocolError('Encoder output does not match the interface');
|
|
97
|
+
await this.active();
|
|
98
|
+
this.pending.add(event.event_id);
|
|
99
|
+
this.queue.push({ type: 'feedback', data: event.payload, responseId: event.event_id, feedback });
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.queue.push({ type: event.type, data: event.payload, responseId: event.event_id });
|
|
103
|
+
if (event.type === 'session.closed')
|
|
104
|
+
this.closed = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
updateContext(context) {
|
|
108
|
+
return this.serial(async () => {
|
|
109
|
+
await this.active();
|
|
110
|
+
await this.send(new B2AMessage({ sessionId: this.protocolSessionId, sequence: this.snapshot.next_sequence,
|
|
111
|
+
type: 'context.update', payload: { base_revision: this.snapshot.context_revision, context } }));
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
respondToApproval(approvalId, approved) {
|
|
115
|
+
return this.serial(async () => {
|
|
116
|
+
if (!approvalId?.trim() || typeof approved !== 'boolean')
|
|
117
|
+
throw new B2AProtocolError('Invalid approval response');
|
|
118
|
+
await this.active();
|
|
119
|
+
await this.send(new B2AMessage({ sessionId: this.protocolSessionId, sequence: this.snapshot.next_sequence,
|
|
120
|
+
type: 'approval.respond', payload: { approval_id: approvalId, decision: approved ? 'approve' : 'reject' } }));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
acknowledgeFeedback(responseId, status) {
|
|
124
|
+
return this.serial(async () => {
|
|
125
|
+
await this.active();
|
|
126
|
+
if (!this.pending.has(responseId) || !['presented', 'failed'].includes(status))
|
|
127
|
+
throw new B2AProtocolError('Invalid feedback acknowledgment');
|
|
128
|
+
await this.send(new B2AMessage({ sessionId: this.protocolSessionId, sequence: this.snapshot.next_sequence, type: 'feedback.ack', payload: { response_id: responseId, status } }));
|
|
129
|
+
this.pending.delete(responseId);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
async close() {
|
|
133
|
+
if (this.closed)
|
|
134
|
+
return;
|
|
135
|
+
this.closed = true;
|
|
136
|
+
await this.serial(() => this.client.closeSession(this.protocolSessionId));
|
|
137
|
+
}
|
|
138
|
+
[Symbol.asyncIterator]() { return this; }
|
|
139
|
+
async return() { await this.close(); return { done: true, value: undefined }; }
|
|
140
|
+
async next() {
|
|
141
|
+
while (true) {
|
|
142
|
+
if (this.closed)
|
|
143
|
+
return { done: true, value: undefined };
|
|
144
|
+
const event = this.queue.shift();
|
|
145
|
+
if (event) {
|
|
146
|
+
if (event.feedback)
|
|
147
|
+
await this.serial(() => this.active());
|
|
148
|
+
return { done: false, value: event };
|
|
149
|
+
}
|
|
150
|
+
if (this.failed)
|
|
151
|
+
throw new B2AProtocolError('B2A connection failed; no automatic replay was attempted');
|
|
152
|
+
await this.serial(async () => { try {
|
|
153
|
+
await this.poll();
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
this.failed = true;
|
|
157
|
+
throw error;
|
|
158
|
+
} });
|
|
159
|
+
if (!this.queue.length)
|
|
160
|
+
await new Promise(resolve => setTimeout(resolve, 250));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
export class B2ARunner {
|
|
165
|
+
static async connect(agent, options) {
|
|
166
|
+
if (!(agent.b2a instanceof B2A) || !options.userId?.trim() || !options.sessionId?.trim())
|
|
167
|
+
throw new B2AProtocolError('Configure Agent.b2a and provide userId/sessionId');
|
|
168
|
+
const { client, configuration } = b2aBinding(agent, options);
|
|
169
|
+
const snapshot = await client.openSession({ userId: options.userId, conversationId: options.sessionId,
|
|
170
|
+
deviceId: globalThis.crypto.randomUUID(), consent: { granted: true, scopes: ['intent', 'feedback', 'context'] },
|
|
171
|
+
capabilities: { input: ['semantic.intent'], output: agent.b2a.outputMediaTypes }, agent: configuration, context: agent.b2a.context });
|
|
172
|
+
return new B2AConnection(client, agent.b2a, snapshot, options.sessionId);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=b2a-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2a-runner.js","sourceRoot":"","sources":["../src/b2a-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,gBAAgB,EAAsD,MAAM,UAAU,CAAC;AAEvH,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAC;AAGpD,MAAM,OAAO,GAAG;IACL,QAAQ,CAAc;IACtB,aAAa,CAAS;IACtB,gBAAgB,CAAW;IAC3B,OAAO,CAAgB;IACvB,OAAO,CAAU;IAC1B,YAAY,OAAkI;QAC5I,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;QAC3C,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,gBAAgB,IAAI,CAAC,kBAAkB,CAAC,C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