marona 2.1.0 → 2.4.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 +13 -0
- package/README.md +81 -43
- 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 +74 -0
- package/dist/b2a-runner.d.ts.map +1 -0
- package/dist/b2a-runner.js +218 -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 +30 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +77 -1
- package/dist/index.js.map +1 -1
- package/dist/protocols.d.ts +18 -0
- package/dist/protocols.d.ts.map +1 -0
- package/dist/protocols.js +24 -0
- package/dist/protocols.js.map +1 -0
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { selectProtocol, validateProtocols } from "./protocols.js";
|
|
2
|
+
export { B2A, B2ARunner, B2AConnection, B2ARunError } from "./b2a-runner.js";
|
|
3
|
+
export { B2ACodec } from "./b2a-codec.js";
|
|
1
4
|
import { matchesSchema } from "./schema.js";
|
|
2
5
|
import { B2AClient } from "./b2a.js";
|
|
3
6
|
export { B2AClient, B2AIntent, B2AMessage, B2AProtocolError, B2A_VERSION } from "./b2a.js";
|
|
4
7
|
import { A2ATaskStore, AgentCardResolver, A2AProtocolError, A2ASecurityError, A2ATaskError, a2aParts, parseA2ATask, parseA2AEvent, readA2AResponse, readA2AStream, unwrapA2A, validateA2AHost } from "./a2a.js";
|
|
5
8
|
export { A2ATaskStore, AgentCardResolver, A2AError, A2ADiscoveryError, A2AProtocolError, A2ASecurityError, A2ATaskError } from "./a2a.js";
|
|
6
9
|
export { A2AServer } from "./a2a-server.js";
|
|
7
|
-
export const packageVersion = "2.
|
|
10
|
+
export const packageVersion = "2.4.0";
|
|
8
11
|
const maronaApiKeyRequired = "Marona Developer Key is required.\n\n" +
|
|
9
12
|
"Provide it through the SDK configuration or set the MARONA_API_KEY environment variable.\n\n" +
|
|
10
13
|
"Create/manage developer keys from the Marona Developer Portal.";
|
|
@@ -898,6 +901,8 @@ export function handoff(targetAgent, options = {}) {
|
|
|
898
901
|
let activeRuntime;
|
|
899
902
|
const supportedModalities = new Set(["text", "image", "audio", "video", "file"]);
|
|
900
903
|
export class Agent {
|
|
904
|
+
b2a;
|
|
905
|
+
protocols;
|
|
901
906
|
name;
|
|
902
907
|
description;
|
|
903
908
|
model;
|
|
@@ -921,6 +926,9 @@ export class Agent {
|
|
|
921
926
|
metadata;
|
|
922
927
|
/** @internal */ runtime;
|
|
923
928
|
constructor(options) {
|
|
929
|
+
this.b2a = options.b2a;
|
|
930
|
+
this.protocols = Object.freeze([...(options.protocols ?? [])]);
|
|
931
|
+
validateProtocols([...this.protocols, ...(this.b2a ? [this.b2a] : [])]);
|
|
924
932
|
this.name = options.name.trim();
|
|
925
933
|
this.description = cleanString(options.description);
|
|
926
934
|
this.model = validateModelNamespace(options.model);
|
|
@@ -966,7 +974,19 @@ export class Agent {
|
|
|
966
974
|
}
|
|
967
975
|
}
|
|
968
976
|
export class Runner {
|
|
977
|
+
static async connect(agent, options) {
|
|
978
|
+
const selected = selectProtocol(agent, options.protocol);
|
|
979
|
+
if (!selected)
|
|
980
|
+
throw new EdgeRuntimeError('Configure Agent.protocols before connecting');
|
|
981
|
+
return selected.connect(agent, options);
|
|
982
|
+
}
|
|
969
983
|
static async run(agent, input, options = {}) {
|
|
984
|
+
const selected = selectProtocol(agent, options.protocol);
|
|
985
|
+
if (selected) {
|
|
986
|
+
if (!options.userId?.trim() || !options.sessionId?.trim())
|
|
987
|
+
throw new EdgeRuntimeError('Protocol runs require userId and sessionId');
|
|
988
|
+
return await selected.run(agent, input, { ...options, userId: options.userId, sessionId: options.sessionId });
|
|
989
|
+
}
|
|
970
990
|
const userId = cleanString(options.userId);
|
|
971
991
|
const sessionId = cleanString(options.sessionId) ?? "default";
|
|
972
992
|
const context = agentContext(agent, userId, sessionId);
|
|
@@ -1053,6 +1073,8 @@ export class Runner {
|
|
|
1053
1073
|
}
|
|
1054
1074
|
}
|
|
1055
1075
|
static async *stream(agent, input, options = {}) {
|
|
1076
|
+
if (selectProtocol(agent, options.protocol))
|
|
1077
|
+
throw new EdgeRuntimeError('Use Runner.connect for protocol event streams');
|
|
1056
1078
|
const userId = cleanString(options.userId);
|
|
1057
1079
|
const sessionId = cleanString(options.sessionId) ?? "default";
|
|
1058
1080
|
const context = agentContext(agent, userId, sessionId);
|
|
@@ -4943,4 +4965,58 @@ function base64Encode(bytes) {
|
|
|
4943
4965
|
}
|
|
4944
4966
|
return btoa(binary);
|
|
4945
4967
|
}
|
|
4968
|
+
/** @internal Shared Agent serialization for native B2A execution. */
|
|
4969
|
+
export function b2aBinding(agent, options) {
|
|
4970
|
+
const seen = new Set(), connections = [];
|
|
4971
|
+
const visit = (current) => {
|
|
4972
|
+
if (seen.has(current))
|
|
4973
|
+
return;
|
|
4974
|
+
seen.add(current);
|
|
4975
|
+
if (current.hooks || current.inputGuardrails.length || current.outputGuardrails.length || current.peers.length || typeof current.instructions === 'function')
|
|
4976
|
+
throw new EdgeRuntimeError('Native B2A requires server-hosted agent capabilities; SDK callbacks are unsupported');
|
|
4977
|
+
for (const tool of agentTools(current)) {
|
|
4978
|
+
if (tool instanceof MCPConnection)
|
|
4979
|
+
connections.push(tool);
|
|
4980
|
+
else if (tool instanceof AgentTool)
|
|
4981
|
+
visit(tool.targetAgent);
|
|
4982
|
+
else
|
|
4983
|
+
throw new EdgeRuntimeError('Native B2A requires server-hosted tools');
|
|
4984
|
+
}
|
|
4985
|
+
for (const handoff of agentHandoffs(current)) {
|
|
4986
|
+
if (handoff.inputFilter)
|
|
4987
|
+
throw new EdgeRuntimeError('Native B2A cannot execute local input filters');
|
|
4988
|
+
visit(handoff.targetAgent);
|
|
4989
|
+
}
|
|
4990
|
+
};
|
|
4991
|
+
visit(agent);
|
|
4992
|
+
const runtime = agentConnection(agent)?.agentRuntime() ?? agent.runtime ?? activeRuntime;
|
|
4993
|
+
if (!runtime)
|
|
4994
|
+
throw new EdgeRuntimeError('Create Marona before connecting B2A');
|
|
4995
|
+
const scopes = connections.map(connection => connection.realtimeScope());
|
|
4996
|
+
const configuration = { name: agent.name, model: agent.model, instructions: agent.instructions,
|
|
4997
|
+
tool_choice: agent.toolChoice, tools_enabled: agentHasTools(agent), max_turns: options.maxTurns ?? agent.maxTurns ?? 20,
|
|
4998
|
+
model_settings: agent.modelSettings ?? {}, multi_agent: agentGraph(agent, agentContext(agent, options.userId, options.sessionId), options),
|
|
4999
|
+
output: normalizeAgentOutputRequest(agent, options.output), ...(agent.routing ? { routing: agent.routing } : {}),
|
|
5000
|
+
connection_scope: { all_apps: scopes.some(s => s.all_apps === true),
|
|
5001
|
+
apps: [...new Set(scopes.flatMap(s => (s.apps ?? [])))], skills: [...new Set(scopes.flatMap(s => (s.skills ?? [])))] } };
|
|
5002
|
+
return { client: new B2AClient((method, path, body) => runtime.b2aRequest(method, path, body)), configuration: JSON.parse(JSON.stringify(configuration)) };
|
|
5003
|
+
}
|
|
5004
|
+
/** @internal Validate completed protocol output before encoding or returning it. */
|
|
5005
|
+
export function protocolResult(agent, payload) {
|
|
5006
|
+
if (payload.status !== 'completed')
|
|
5007
|
+
return undefined;
|
|
5008
|
+
const raw = asRecord(payload.response);
|
|
5009
|
+
if (!raw)
|
|
5010
|
+
throw new EdgeRuntimeError('Completed protocol response is missing');
|
|
5011
|
+
const response = parseRuntimeMessageResponse(raw);
|
|
5012
|
+
raiseAgentInterruption(response);
|
|
5013
|
+
if (raw.status !== undefined && raw.status !== 'completed')
|
|
5014
|
+
throw new EdgeRuntimeError('Protocol response did not complete');
|
|
5015
|
+
const metadata = response.agent ?? {};
|
|
5016
|
+
const activeAgent = agentByName(agent, cleanString(metadata.active_agent) ?? agent.name);
|
|
5017
|
+
return { output: parseTypedOutput(activeAgent, raw.output ?? response.output), activeAgent,
|
|
5018
|
+
lastAgent: agentByName(agent, cleanString(metadata.last_agent) ?? activeAgent.name),
|
|
5019
|
+
agentRuns: normalizeAgentRuns(metadata, agent), usage: asRecord(raw.usage) ?? {}, routing: response.routing,
|
|
5020
|
+
traceId: cleanString(metadata.trace_id), a2aEvents: [] };
|
|
5021
|
+
}
|
|
4946
5022
|
//# sourceMappingURL=index.js.map
|