marona 1.1.4 → 2.0.1
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 +11 -0
- package/README.md +128 -72
- package/dist/a2a-server.d.ts +38 -0
- package/dist/a2a-server.d.ts.map +1 -0
- package/dist/a2a-server.js +249 -0
- package/dist/a2a-server.js.map +1 -0
- package/dist/a2a.d.ts +65 -0
- package/dist/a2a.d.ts.map +1 -0
- package/dist/a2a.js +276 -0
- package/dist/a2a.js.map +1 -0
- package/dist/index.d.ts +62 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +341 -197
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +26 -0
- package/dist/schema.js.map +1 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
# 2.0.1 — 2026-10-24
|
|
2
|
+
|
|
3
|
+
- Match Python output-error recovery and connected-tool behavior; preserve schemas, guardrails and streaming checks.
|
|
4
|
+
|
|
1
5
|
# Changelog
|
|
2
6
|
|
|
7
|
+
## 2.0.0
|
|
8
|
+
|
|
9
|
+
- Add public Apps list/connect/disconnect and explicit provider strict output.
|
|
10
|
+
- Add durable A2A servers, task lifecycle, REST/JSON-RPC and streaming events.
|
|
11
|
+
- Use full JSON Schema validation and reject invalid attachment Base64.
|
|
12
|
+
- Complete realtime guardrails, hooks, handoffs and per-run A2A events. Node.js 20 or newer is required.
|
|
13
|
+
|
|
3
14
|
## 1.1.4
|
|
4
15
|
|
|
5
16
|
- Remove the retired device activation and device credential flow.
|
package/README.md
CHANGED
|
@@ -1,109 +1,165 @@
|
|
|
1
1
|
# Marona TypeScript SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run Agents through one managed API, with structured output, local tools,
|
|
4
|
+
Hub capabilities, streaming, realtime and A2A collaboration.
|
|
4
5
|
|
|
5
6
|
## Install
|
|
6
7
|
|
|
8
|
+
Version **2.0.1**. [Package registry](https://www.npmjs.com/package/marona/v/2.0.1).
|
|
9
|
+
|
|
10
|
+
Node.js 20+; run this server example with tsx.
|
|
11
|
+
|
|
7
12
|
```bash
|
|
8
|
-
npm install marona@
|
|
13
|
+
npm install marona@2.0.1
|
|
14
|
+
npm install --save-dev typescript tsx @types/node
|
|
9
15
|
```
|
|
10
16
|
|
|
11
|
-
|
|
17
|
+
Set `MARONA_API_KEY` in your backend environment. Never commit it, log it,
|
|
18
|
+
or embed a developer key in browser or mobile code. Use an exact accessible
|
|
19
|
+
`marona/*` model alias from [Marona Platform](https://platform.marona.ai/).
|
|
12
20
|
|
|
13
|
-
|
|
14
|
-
mode. Pass `apiKey` explicitly or set `MARONA_API_KEY`.
|
|
21
|
+
## Agent quickstart
|
|
15
22
|
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
Save as `examples/agent_example.mts`. Run without arguments for text, or with a real
|
|
24
|
+
PNG/JPEG path for document extraction. Use stable application user IDs and a
|
|
25
|
+
distinct session ID for each conversation.
|
|
18
26
|
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
```typescript
|
|
28
|
+
import { readFile } from "node:fs/promises";
|
|
29
|
+
import { extname } from "node:path";
|
|
30
|
+
import { Agent, Marona, Runner } from "marona";
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
const marona = new Marona({
|
|
33
|
+
apiKey: process.env.MARONA_API_KEY,
|
|
34
|
+
baseUrl: process.env.MARONA_RUNTIME_URL ?? "https://edge.marona.ai",
|
|
35
|
+
});
|
|
36
|
+
const agent = new Agent({
|
|
37
|
+
name: "Document Assistant",
|
|
38
|
+
model: process.env.MARONA_MODEL ?? "marona/qwen-qwen3.8-max-0902",
|
|
39
|
+
instructions: "Answer clearly and concisely.",
|
|
40
|
+
toolChoice: "none",
|
|
41
|
+
});
|
|
42
|
+
const path = process.argv[2];
|
|
43
|
+
const mimeTypes: Record<string, string> = {
|
|
44
|
+
".png": "image/png", ".jpg": "image/jpeg", ".jpeg": "image/jpeg",
|
|
45
|
+
};
|
|
46
|
+
const mime = path ? mimeTypes[extname(path).toLowerCase()] : undefined;
|
|
47
|
+
if (path && !mime) throw new Error("Use a PNG or JPEG image.");
|
|
48
|
+
const input = path ? [{
|
|
49
|
+
role: "user",
|
|
50
|
+
content: [
|
|
51
|
+
{ type: "input_text", text: "Describe this image and transcribe any visible text." },
|
|
52
|
+
{ type: "input_image", image_url: `data:${mime};base64,${(await readFile(path)).toString("base64")}` },
|
|
53
|
+
],
|
|
54
|
+
}] : "Reply with exactly OK.";
|
|
55
|
+
const result = await Runner.run(agent, input, {
|
|
56
|
+
userId: "example-user", sessionId: "example-session",
|
|
39
57
|
});
|
|
58
|
+
console.log(result.output);
|
|
59
|
+
```
|
|
40
60
|
|
|
41
|
-
|
|
61
|
+
```bash
|
|
62
|
+
npx tsx examples/agent_example.mts
|
|
63
|
+
npx tsx examples/agent_example.mts image.png
|
|
42
64
|
```
|
|
43
65
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
66
|
+
Encode actual file bytes with standard Base64. Image and file blocks accept
|
|
67
|
+
raw Base64 in `image_data` / `file_data`, or complete matching data URLs.
|
|
68
|
+
Do not encode a path, encode twice, or send placeholder data. Remote URLs must
|
|
69
|
+
be reachable by the runtime. PDF, audio and realtime support depend on the
|
|
70
|
+
selected model; render PDF pages to images when native PDF is unavailable.
|
|
49
71
|
|
|
50
|
-
|
|
51
|
-
Runtime. There is no direct-provider, local-executor, credential-cache, or public
|
|
52
|
-
model-registration bypass.
|
|
72
|
+
## Structured output through Agent
|
|
53
73
|
|
|
54
|
-
|
|
74
|
+
The following fragment uses the authenticated client from the quickstart.
|
|
75
|
+
`documentInput` is your text or document message input.
|
|
55
76
|
|
|
56
|
-
```
|
|
77
|
+
```typescript
|
|
57
78
|
import { Agent, Runner } from "marona";
|
|
58
79
|
|
|
59
|
-
const tools = await marona.hub.connect({ apps: ["sda-books"] });
|
|
60
80
|
const agent = new Agent({
|
|
61
|
-
name: "
|
|
62
|
-
model: "marona/
|
|
63
|
-
instructions: "
|
|
64
|
-
|
|
81
|
+
name: "Document Reader",
|
|
82
|
+
model: "marona/qwen-qwen3.8-max-0902",
|
|
83
|
+
instructions: "Extract the document text.",
|
|
84
|
+
outputSchemaStrict: true,
|
|
85
|
+
outputSchema: {
|
|
86
|
+
type: "object",
|
|
87
|
+
properties: { text: { type: "string" } },
|
|
88
|
+
required: ["text"],
|
|
89
|
+
additionalProperties: false,
|
|
90
|
+
},
|
|
65
91
|
});
|
|
66
|
-
|
|
67
|
-
const result = await Runner.run(
|
|
68
|
-
agent,
|
|
69
|
-
"Download Steps to Christ",
|
|
70
|
-
{ userId: "customer_482", sessionId: "chat_91a7" },
|
|
71
|
-
);
|
|
92
|
+
const result = await Runner.run(agent, documentInput, { userId: "user-123" });
|
|
72
93
|
console.log(result.output);
|
|
73
94
|
```
|
|
74
95
|
|
|
75
|
-
The
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
The explicit strict option asks the provider to enforce the supplied schema;
|
|
97
|
+
the SDK also validates the final result before returning it. Strict mode requires
|
|
98
|
+
a compatible model and schema. Declare every object property as required, use
|
|
99
|
+
nullable values for optional fields, and set additionalProperties to false.
|
|
100
|
+
Unsupported model capabilities or invalid output produce errors; they do not silently fall
|
|
101
|
+
back to unstructured text. Input schemas, function tool schemas, guardrails,
|
|
102
|
+
dynamic instructions and lifecycle hooks are also supported.
|
|
78
103
|
|
|
79
|
-
##
|
|
104
|
+
## Apps and user connections
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
const page = await marona.apps.list({ userId: "user-123", limit: 20 });
|
|
108
|
+
const action = await marona.apps.connect("calendar", { userId: "user-123" });
|
|
109
|
+
// Complete any returned authorization_url before calling protected tools.
|
|
110
|
+
await marona.apps.disconnect("calendar");
|
|
111
|
+
```
|
|
80
112
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fields, never upstream endpoints or raw provider payloads.
|
|
113
|
+
Listing an App does not authorize its protected operations. Follow the returned
|
|
114
|
+
connection action for the end user. Use `hub.connect` to expose a scoped set of
|
|
115
|
+
App or Skill capabilities to an Agent; Apps authorization and Hub tool discovery
|
|
116
|
+
are separate operations.
|
|
86
117
|
|
|
87
|
-
##
|
|
118
|
+
## A2A collaboration and serving
|
|
88
119
|
|
|
89
120
|
```typescript
|
|
90
|
-
|
|
91
|
-
|
|
121
|
+
import { A2APeer, A2AServer, A2ATaskStore, Agent } from "marona";
|
|
122
|
+
|
|
123
|
+
const peer = new A2APeer({ name: "reviewer", url: "https://reviewer.example.com" });
|
|
124
|
+
const agent = new Agent({ name: "Coordinator", peers: [peer] });
|
|
125
|
+
const server = new A2AServer({
|
|
126
|
+
agent,
|
|
127
|
+
url: "https://coordinator.example.com",
|
|
128
|
+
skills: [{ id: "review", name: "Review", description: "Review a document" }],
|
|
129
|
+
apiKey: process.env.A2A_SERVER_KEY,
|
|
130
|
+
taskStore: new A2ATaskStore("./data/a2a-tasks"),
|
|
92
131
|
});
|
|
132
|
+
await server.listen({ host: "127.0.0.1", port: 8100 });
|
|
133
|
+
// Call await server.close() during graceful shutdown.
|
|
93
134
|
```
|
|
94
135
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
Use
|
|
98
|
-
|
|
99
|
-
|
|
136
|
+
Peers support Agent Card discovery, REST/JSON-RPC messages, task retrieval,
|
|
137
|
+
cancellation, continuation and streamed task events. Servers persist task state.
|
|
138
|
+
Use explicit credentials, restricted skills, HTTPS, and an appropriate durable
|
|
139
|
+
task directory for production. Local JSON stores are for a single service
|
|
140
|
+
instance; multi-instance deployments require coordinated task storage.
|
|
141
|
+
|
|
142
|
+
The listener and durable file store require Node. Fetch handlers can use an injected platform task store.
|
|
143
|
+
Push notifications are not implemented.
|
|
144
|
+
|
|
145
|
+
## Execution and errors
|
|
146
|
+
|
|
147
|
+
Use `Runner.stream` for streamed Agent events and
|
|
148
|
+
`RealtimeRunner` for a live session. Delegation and handoffs use explicit Agent
|
|
149
|
+
graphs. Set execution limits and validate permissions before tools with side
|
|
150
|
+
effects; cancellation cannot roll back an operation that has already executed.
|
|
151
|
+
|
|
152
|
+
Inspect the canonical error code, HTTP status, request ID and retry metadata.
|
|
153
|
+
Correct invalid input and authorization errors before retrying. Use bounded
|
|
154
|
+
retries for transient failures. Never include credentials or document content
|
|
155
|
+
in error reports.
|
|
100
156
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
157
|
+
See [Platform documentation](https://platform.marona.ai/docs) for language
|
|
158
|
+
specific examples and migration guidance. These files are generated from
|
|
159
|
+
`docs/client-sdk-guides.json`; verify them with
|
|
160
|
+
`python scripts/sync_client_sdk_docs.py --check`.
|
|
104
161
|
|
|
105
|
-
##
|
|
162
|
+
## 2.0.1 changes
|
|
106
163
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
`main`.
|
|
164
|
+
- Output validation errors expose the agent name, original output and safe validation details for controlled recovery.
|
|
165
|
+
- Connected-tool and streaming behavior is covered by the Python parity fixtures.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Agent, type JsonMap } from "./index.js";
|
|
2
|
+
import { type A2ARequestContext, type A2ATaskStorage } from "./a2a.js";
|
|
3
|
+
export interface A2AServerOptions {
|
|
4
|
+
agent: Agent;
|
|
5
|
+
skills: JsonMap[];
|
|
6
|
+
url?: string;
|
|
7
|
+
apiKey?: string;
|
|
8
|
+
executor?: (input: unknown, context: A2ARequestContext) => unknown | Promise<unknown>;
|
|
9
|
+
taskStore?: A2ATaskStorage;
|
|
10
|
+
maxRequestBytes?: number;
|
|
11
|
+
metadata?: JsonMap;
|
|
12
|
+
}
|
|
13
|
+
/** Fetch-compatible handler plus an optional Node HTTP listener for A2A 1.0. */
|
|
14
|
+
export declare class A2AServer {
|
|
15
|
+
private readonly options;
|
|
16
|
+
private server?;
|
|
17
|
+
private url;
|
|
18
|
+
private readonly store;
|
|
19
|
+
private readonly skills;
|
|
20
|
+
private storeQueue;
|
|
21
|
+
private locked;
|
|
22
|
+
constructor(options: A2AServerOptions);
|
|
23
|
+
get card(): JsonMap;
|
|
24
|
+
handle(request: Request): Promise<Response>;
|
|
25
|
+
listen(options?: {
|
|
26
|
+
host?: string;
|
|
27
|
+
port?: number;
|
|
28
|
+
}): Promise<string>;
|
|
29
|
+
close(): Promise<void>;
|
|
30
|
+
private namespace;
|
|
31
|
+
private taskResponse;
|
|
32
|
+
private execute;
|
|
33
|
+
private stream;
|
|
34
|
+
private task;
|
|
35
|
+
private envelope;
|
|
36
|
+
private json;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=a2a-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-server.d.ts","sourceRoot":"","sources":["../src/a2a-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAA6F,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5I,OAAO,EACL,KAAK,iBAAiB,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAGhE,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,iBAAiB,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACtF,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,gFAAgF;AAChF,qBAAa,SAAS;IAWR,OAAO,CAAC,QAAQ,CAAC,OAAO;IAVpC,OAAO,CAAC,MAAM,CAAC,CAAS;IACxB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiB;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,UAAU,CAAuC;IACzD,OAAO,CAAC,MAAM;gBAKe,OAAO,EAAE,gBAAgB;IAOtD,IAAI,IAAI,IAAI,OAAO,CAQlB;IACK,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IA+B3C,MAAM,CAAC,OAAO,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BvE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,OAAO,CAAC,SAAS;YACH,YAAY;YAQZ,OAAO;IA2BrB,OAAO,CAAC,MAAM;IAgBd,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,IAAI;CACb"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Runner, MaronaPermissionRequired, MaronaApprovalRequired, MaronaServiceConnectionRequired } from "./index.js";
|
|
2
|
+
import { A2ATaskStore, a2aParts, a2aPartsOutput, a2aRecord, parseA2ATask } from "./a2a.js";
|
|
3
|
+
/** Fetch-compatible handler plus an optional Node HTTP listener for A2A 1.0. */
|
|
4
|
+
export class A2AServer {
|
|
5
|
+
options;
|
|
6
|
+
server;
|
|
7
|
+
url;
|
|
8
|
+
store;
|
|
9
|
+
skills;
|
|
10
|
+
storeQueue = Promise.resolve();
|
|
11
|
+
locked(action) {
|
|
12
|
+
const result = this.storeQueue.then(action);
|
|
13
|
+
this.storeQueue = result.catch(() => { });
|
|
14
|
+
return result;
|
|
15
|
+
}
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = options;
|
|
18
|
+
if (!options.skills.length || options.skills.some(skill => typeof skill.id !== "string" || !skill.id.trim()))
|
|
19
|
+
throw new Error("A2A server requires published skills with IDs");
|
|
20
|
+
if ((options.maxRequestBytes ?? 1_000_000) <= 0)
|
|
21
|
+
throw new Error("A2A request limit must be positive");
|
|
22
|
+
if (options.apiKey !== undefined && !options.apiKey.trim())
|
|
23
|
+
throw new Error("A2A API key cannot be empty");
|
|
24
|
+
this.skills = structuredClone(options.skills);
|
|
25
|
+
this.url = (options.url ?? "http://127.0.0.1:8100").replace(/\/+$/, "");
|
|
26
|
+
this.store = options.taskStore ?? new A2ATaskStore();
|
|
27
|
+
}
|
|
28
|
+
get card() {
|
|
29
|
+
return { name: this.options.agent.name, description: this.options.agent.description ?? this.options.agent.name,
|
|
30
|
+
version: this.options.metadata?.version ?? "1.0.0", protocolVersion: "1.0", url: this.url,
|
|
31
|
+
supportedInterfaces: [{ url: this.url, protocolBinding: "HTTP+JSON", protocolVersion: "1.0" }, { url: `${this.url}/rpc`, protocolBinding: "JSONRPC", protocolVersion: "1.0" }],
|
|
32
|
+
capabilities: { streaming: true, pushNotifications: false, extendedAgentCard: false },
|
|
33
|
+
defaultInputModes: ["text/plain", "application/json"], defaultOutputModes: ["text/plain", "application/json"], skills: structuredClone(this.skills),
|
|
34
|
+
...(this.options.apiKey ? { securitySchemes: { bearerAuth: { type: "http", scheme: "bearer" } }, securityRequirements: [{ bearerAuth: [] }] } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
async handle(request) {
|
|
38
|
+
const path = new URL(request.url).pathname;
|
|
39
|
+
if (request.method === "GET" && ["/.well-known/agent-card.json", "/.well-known/agent.json"].includes(path))
|
|
40
|
+
return this.json(this.card);
|
|
41
|
+
if (this.options.apiKey && request.headers.get("Authorization") !== `Bearer ${this.options.apiKey}`)
|
|
42
|
+
return this.json({ error: { message: "A2A authentication required" } }, 401);
|
|
43
|
+
const rpc = path === "/rpc";
|
|
44
|
+
let id = null;
|
|
45
|
+
try {
|
|
46
|
+
if (request.method === "GET" && path.startsWith("/tasks/"))
|
|
47
|
+
return this.taskResponse(decodeURIComponent(path.slice(7)), false, false, id);
|
|
48
|
+
if (request.method !== "POST")
|
|
49
|
+
return this.json({ error: { message: "Method not allowed" } }, 405);
|
|
50
|
+
const limit = this.options.maxRequestBytes ?? 1_000_000;
|
|
51
|
+
const reader = request.body?.getReader();
|
|
52
|
+
let size = 0;
|
|
53
|
+
let body = "";
|
|
54
|
+
const decoder = new TextDecoder();
|
|
55
|
+
if (reader)
|
|
56
|
+
try {
|
|
57
|
+
while (true) {
|
|
58
|
+
const next = await reader.read();
|
|
59
|
+
if (next.done)
|
|
60
|
+
break;
|
|
61
|
+
size += next.value.length;
|
|
62
|
+
if (size > limit)
|
|
63
|
+
return this.json({ error: { message: "Request exceeds byte limit" } }, 413);
|
|
64
|
+
body += decoder.decode(next.value, { stream: true });
|
|
65
|
+
}
|
|
66
|
+
body += decoder.decode();
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
await reader.cancel();
|
|
70
|
+
reader.releaseLock();
|
|
71
|
+
}
|
|
72
|
+
const payload = a2aRecord(JSON.parse(body));
|
|
73
|
+
id = payload.id ?? null;
|
|
74
|
+
const params = rpc ? a2aRecord(payload.params) : payload;
|
|
75
|
+
const operation = rpc ? payload.method : undefined;
|
|
76
|
+
if (rpc && ["GetTask", "CancelTask"].includes(String(operation)))
|
|
77
|
+
return this.taskResponse(String(params.id ?? ""), operation === "CancelTask", rpc, id);
|
|
78
|
+
if (!rpc && path.startsWith("/tasks/") && path.endsWith(":cancel"))
|
|
79
|
+
return this.taskResponse(decodeURIComponent(path.slice(7, -7)), true, false, id);
|
|
80
|
+
const streaming = path === "/message:stream" || (rpc && operation === "SendStreamingMessage");
|
|
81
|
+
if (streaming || path === "/message:send" || (rpc && operation === "SendMessage")) {
|
|
82
|
+
const message = a2aRecord(params.message);
|
|
83
|
+
if (!Array.isArray(message.parts))
|
|
84
|
+
throw new Error("Missing message parts");
|
|
85
|
+
if (streaming)
|
|
86
|
+
return this.stream(params, rpc, id);
|
|
87
|
+
return this.json(this.envelope(await this.execute(params), rpc, id));
|
|
88
|
+
}
|
|
89
|
+
return this.json(rpc ? { jsonrpc: "2.0", id, error: { code: -32601, message: "Method not found" } } : { error: { message: "Not found" } }, rpc ? 200 : 404);
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
return this.json(rpc ? { jsonrpc: "2.0", id, error: { code: -32602, message: "Invalid A2A request" } } : { error: { message: "Invalid A2A request" } }, rpc ? 200 : 400);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
async listen(options = {}) {
|
|
96
|
+
if (this.server)
|
|
97
|
+
throw new Error("A2A server is already listening");
|
|
98
|
+
const { createServer } = await import("node:http");
|
|
99
|
+
const server = createServer(async (incoming, outgoing) => {
|
|
100
|
+
try {
|
|
101
|
+
const headers = new Headers();
|
|
102
|
+
for (const [key, value] of Object.entries(incoming.headers))
|
|
103
|
+
if (value !== undefined)
|
|
104
|
+
headers.set(key, Array.isArray(value) ? value.join(", ") : value);
|
|
105
|
+
const chunks = [];
|
|
106
|
+
let size = 0;
|
|
107
|
+
for await (const chunk of incoming) {
|
|
108
|
+
size += chunk.length;
|
|
109
|
+
if (size > (this.options.maxRequestBytes ?? 1_000_000)) {
|
|
110
|
+
outgoing.writeHead(413).end();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
chunks.push(chunk);
|
|
114
|
+
}
|
|
115
|
+
const request = new Request(new URL(incoming.url ?? "/", this.url), { method: incoming.method, headers, body: ["GET", "HEAD"].includes(incoming.method ?? "GET") ? undefined : Buffer.concat(chunks) });
|
|
116
|
+
const response = await this.handle(request);
|
|
117
|
+
const responseHeaders = {};
|
|
118
|
+
response.headers.forEach((value, key) => { responseHeaders[key] = value; });
|
|
119
|
+
outgoing.writeHead(response.status, responseHeaders);
|
|
120
|
+
const reader = response.body?.getReader();
|
|
121
|
+
if (reader) {
|
|
122
|
+
const cancel = () => { void reader.cancel().catch(() => { }); };
|
|
123
|
+
outgoing.on("close", cancel);
|
|
124
|
+
try {
|
|
125
|
+
while (!outgoing.destroyed) {
|
|
126
|
+
const { done, value } = await reader.read();
|
|
127
|
+
if (done)
|
|
128
|
+
break;
|
|
129
|
+
if (!outgoing.write(value))
|
|
130
|
+
await new Promise(resolve => { outgoing.once("drain", resolve); outgoing.once("close", resolve); });
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
outgoing.off("close", cancel);
|
|
135
|
+
await reader.cancel();
|
|
136
|
+
reader.releaseLock();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
outgoing.end();
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
if (!outgoing.headersSent)
|
|
143
|
+
outgoing.writeHead(500);
|
|
144
|
+
outgoing.end();
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
this.server = server;
|
|
148
|
+
await new Promise((resolve, reject) => { server.once("error", reject); server.listen(options.port ?? 8100, options.host ?? "127.0.0.1", resolve); });
|
|
149
|
+
const address = server.address();
|
|
150
|
+
if (!address || typeof address === "string")
|
|
151
|
+
throw new Error("Missing A2A listen address");
|
|
152
|
+
if (options.port === 0 || !this.options.url)
|
|
153
|
+
this.url = `http://${address.address.includes(":") ? `[${address.address}]` : address.address}:${address.port}`;
|
|
154
|
+
return this.url;
|
|
155
|
+
}
|
|
156
|
+
async close() {
|
|
157
|
+
const server = this.server;
|
|
158
|
+
this.server = undefined;
|
|
159
|
+
if (!server)
|
|
160
|
+
return;
|
|
161
|
+
server.closeIdleConnections();
|
|
162
|
+
await new Promise((resolve, reject) => server.close(error => error ? reject(error) : resolve()));
|
|
163
|
+
}
|
|
164
|
+
namespace() { return `server:${this.options.agent.name}`; }
|
|
165
|
+
async taskResponse(taskId, cancel, rpc, id) {
|
|
166
|
+
return this.locked(async () => {
|
|
167
|
+
const task = await this.store.latest(this.namespace(), taskId);
|
|
168
|
+
if (!task)
|
|
169
|
+
return this.json(rpc ? { jsonrpc: "2.0", id, error: { code: -32001, message: "Task not found" } } : { error: { message: "Task not found" } }, rpc ? 200 : 404);
|
|
170
|
+
if (cancel) {
|
|
171
|
+
task.raw.status = { state: "TASK_STATE_CANCELED", timestamp: new Date().toISOString() };
|
|
172
|
+
await this.store.save(this.namespace(), taskId, parseA2ATask(task.raw));
|
|
173
|
+
}
|
|
174
|
+
return this.json(this.envelope({ task: task.raw }, rpc, id));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
async execute(params) {
|
|
178
|
+
const message = a2aRecord(params.message);
|
|
179
|
+
const taskId = String(message.taskId ?? crypto.randomUUID());
|
|
180
|
+
const contextId = String(message.contextId ?? taskId);
|
|
181
|
+
const metadata = message.metadata ? a2aRecord(message.metadata) : {};
|
|
182
|
+
const marona = metadata.marona ? a2aRecord(metadata.marona) : {};
|
|
183
|
+
const skill = metadata.requested_skill ? String(metadata.requested_skill) : undefined;
|
|
184
|
+
const previous = await this.locked(async () => {
|
|
185
|
+
const previous = await this.store.latest(this.namespace(), taskId);
|
|
186
|
+
if (previous?.state !== "TASK_STATE_CANCELED")
|
|
187
|
+
await this.store.save(this.namespace(), taskId, parseA2ATask(this.task(taskId, contextId, "TASK_STATE_WORKING")));
|
|
188
|
+
return previous;
|
|
189
|
+
});
|
|
190
|
+
if (previous?.state === "TASK_STATE_CANCELED")
|
|
191
|
+
return { task: previous.raw };
|
|
192
|
+
let task;
|
|
193
|
+
if (skill && !this.skills.some(value => value.id === skill))
|
|
194
|
+
task = this.task(taskId, contextId, "TASK_STATE_REJECTED", undefined, "Requested skill is not published");
|
|
195
|
+
else
|
|
196
|
+
try {
|
|
197
|
+
const context = { taskId, contextId, skill, userId: typeof marona.user_id === "string" ? marona.user_id : undefined, sessionId: String(marona.session_id ?? contextId), metadata };
|
|
198
|
+
const input = a2aPartsOutput(message.parts);
|
|
199
|
+
const output = this.options.executor ? await this.options.executor(input, context)
|
|
200
|
+
: (await Runner.run(this.options.agent, input, { userId: context.userId, sessionId: context.sessionId })).output;
|
|
201
|
+
task = this.task(taskId, contextId, "TASK_STATE_COMPLETED", output);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
const interrupted = error instanceof MaronaPermissionRequired || error instanceof MaronaApprovalRequired || error instanceof MaronaServiceConnectionRequired;
|
|
205
|
+
task = this.task(taskId, contextId, interrupted ? "TASK_STATE_INPUT_REQUIRED" : "TASK_STATE_FAILED", undefined, interrupted ? "Agent requires additional authorization or input" : "Agent execution failed");
|
|
206
|
+
}
|
|
207
|
+
return this.locked(async () => {
|
|
208
|
+
const current = await this.store.latest(this.namespace(), taskId);
|
|
209
|
+
if (current?.state === "TASK_STATE_CANCELED")
|
|
210
|
+
return { task: current.raw };
|
|
211
|
+
await this.store.save(this.namespace(), taskId, parseA2ATask(task));
|
|
212
|
+
return { task };
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
stream(params, rpc, rpcId) {
|
|
216
|
+
const message = a2aRecord(params.message);
|
|
217
|
+
const taskId = String(message.taskId ?? crypto.randomUUID());
|
|
218
|
+
const contextId = String(message.contextId ?? taskId);
|
|
219
|
+
params = { ...params, message: { ...message, taskId, contextId } };
|
|
220
|
+
let canceled = false;
|
|
221
|
+
const stream = new ReadableStream({
|
|
222
|
+
start: async (controller) => {
|
|
223
|
+
const emit = (value) => { if (!canceled)
|
|
224
|
+
controller.enqueue(new TextEncoder().encode(`data: ${JSON.stringify(this.envelope(value, rpc, rpcId))}\n\n`)); };
|
|
225
|
+
try {
|
|
226
|
+
emit({ task: this.task(taskId, contextId, "TASK_STATE_WORKING") });
|
|
227
|
+
const result = a2aRecord((await this.execute(params)).task);
|
|
228
|
+
for (const artifact of (result.artifacts ?? []))
|
|
229
|
+
emit({ artifactUpdate: { taskId, contextId, artifact } });
|
|
230
|
+
emit({ statusUpdate: { taskId, contextId, status: result.status } });
|
|
231
|
+
if (!canceled)
|
|
232
|
+
controller.close();
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
if (!canceled)
|
|
236
|
+
controller.error(error);
|
|
237
|
+
}
|
|
238
|
+
}, cancel: () => { canceled = true; },
|
|
239
|
+
});
|
|
240
|
+
return new Response(stream, { headers: { "Content-Type": "text/event-stream", "Cache-Control": "no-cache" } });
|
|
241
|
+
}
|
|
242
|
+
task(id, contextId, state, output, message) {
|
|
243
|
+
return { id, contextId, status: { state, timestamp: new Date().toISOString(), ...(message ? { message: { messageId: crypto.randomUUID(), role: "ROLE_AGENT", parts: a2aParts(message) } } : {}) },
|
|
244
|
+
...(output !== undefined ? { artifacts: [{ artifactId: crypto.randomUUID(), name: "result", parts: a2aParts(output) }] } : {}), metadata: { framework: "marona", ...this.options.metadata } };
|
|
245
|
+
}
|
|
246
|
+
envelope(value, rpc, id) { return rpc ? { jsonrpc: "2.0", id, result: value } : value; }
|
|
247
|
+
json(value, status = 200) { return new Response(JSON.stringify(value), { status, headers: { "Content-Type": "application/json" } }); }
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=a2a-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a-server.js","sourceRoot":"","sources":["../src/a2a-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,+BAA+B,EAAgB,MAAM,YAAY,CAAC;AAC5I,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EACzB,MAAM,UAAU,CAAC;AAchE,gFAAgF;AAChF,MAAM,OAAO,SAAS;IAWS;IAVrB,MAAM,CAAU;IAChB,GAAG,CAAS;IACH,KAAK,CAAiB;IACtB,MAAM,CAAY;IAC3B,UAAU,GAA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