marona 0.14.0 → 1.0.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/README.md CHANGED
@@ -1,832 +1,91 @@
1
1
  # Marona TypeScript SDK
2
2
 
3
- Provider-neutral AI agent runtime and MCP/Skill gateway for Marona Hub
4
- connections, managed agents, and bring-your-own-agent integrations.
3
+ Universal Model Gateway and MCP/Skill SDK for Node.js 18+.
4
+
5
+ ## Install
5
6
 
6
7
  ```bash
7
- npm install marona
8
+ npm install marona@1.0.0
8
9
  ```
9
10
 
10
- ## 1. Marona Hub
11
+ ## Authentication
11
12
 
12
- Connect Apps and governed Skills as one neutral MCP tool collection.
13
+ A project-scoped Marona Developer Key is mandatory for every client and runtime
14
+ mode. Pass `apiKey` explicitly or set `MARONA_API_KEY`.
13
15
 
14
16
  ```ts
15
17
  import { Marona } from "marona";
16
18
 
17
- const marona = new Marona({
18
- apiKey: process.env.MARONA_API_KEY,
19
- });
20
-
21
- // Connect every App and Skill available to this developer key.
22
- const connection = await marona.hub.connect();
23
- ```
24
-
25
- An unscoped connection exposes two stable provider-neutral tools:
26
- `marona__discover_capabilities` and `marona__call_capability`. The agent first
27
- discovers the compact App/Skill catalog, then Marona reveals only the exact
28
- schemas it selects. This keeps external agents reliable as the Hub grows.
29
-
30
- Select a smaller capability set when needed:
31
-
32
- ```ts
33
- const connection = await marona.hub.connect({
34
- apps: ["group-fund"],
35
- skills: ["create-group-fund"],
36
- });
37
- ```
38
-
39
- Use a selected connection directly:
40
-
41
- ```ts
42
- const tools = connection.listTools();
43
- const result = await connection.callTool("skill__create_group_fund", {
44
- request: "Create a family savings group fund",
45
- });
46
- ```
47
-
48
- `MCPConnection` is not tied to OpenAI, LangGraph, CrewAI, or another model
49
- vendor. It exposes:
50
-
51
- ```ts
52
- connection.listTools();
53
- connection.listCapabilities();
54
- await connection.callTool(name, argumentsValue);
55
- connection.serverUrl;
56
- connection.serverUrls;
57
- connection.warnings;
58
- connection.session;
59
- ```
60
-
61
- An unresolved App or Skill name does not discard valid tools. Check
62
- `connection.warnings` for its `code`, `selector_type`, `slug`, and corrective
63
- message. Authentication, permission, and configured-server failures
64
- remain blocking errors.
65
-
66
- Marona Hub owns discovery, identity, permissions, App and Skill resolution,
67
- approvals, governed execution, and online, offline, or hybrid availability.
68
- With no selectors, the gateway discovers every capability available to the
69
- developer key; offline discovery covers every capability installed on the
70
- device. `listCapabilities()` is available to framework adapters that explicitly
71
- need the underlying exact catalog.
72
-
73
- Connected Apps execute through Marona governance. When an App such as Google
74
- Contacts or Calendar needs sign-in, the tool result includes
75
- `structuredContent.authorization_url` and a `link` artifact. Pass `userId`
76
- when calling a tool directly so the resulting service connection belongs to
77
- the correct end user:
78
-
79
- ```ts
80
- const result = await connection.callTool(
81
- "contacts__search_contacts",
82
- { query: "John" },
83
- { userId: "customer_482", conversationId: "chat_91a7" },
84
- );
85
- ```
86
-
87
- ## 2. Marona Agent
88
-
89
- Use Marona's `Agent` and `Runner` when you want one simple managed agent API.
90
-
91
- ```ts
92
- import { Agent, Marona, Runner } from "marona";
93
-
94
- const marona = new Marona({
95
- apiKey: process.env.MARONA_API_KEY,
96
- });
97
-
98
- const tools = await marona.hub.connect({
99
- apps: ["sda-books"],
100
- });
101
-
102
- const agent = new Agent({
103
- name: "Customer Assistant",
104
- model: "marona/gpt-5.6",
105
- instructions: "Help the customer.",
106
- tools,
107
- toolChoice: "auto",
108
- });
109
-
110
- const result = await Runner.run(agent, "Download Steps to Christ", {
111
- userId: "customer_482",
112
- sessionId: "chat_91a7",
113
- });
114
-
115
- console.log(result.output);
19
+ const marona = new Marona({ apiKey: maronaDeveloperKey });
116
20
  ```
117
21
 
118
- `userId` is optional. `sessionId` is also optional and defaults to `default`.
119
- Marona derives the developer scope from the authenticated API key and keeps
120
- conversation history isolated by developer, user, and session.
121
-
122
- `toolChoice` defaults to `"auto"`. Use `"required"` when the first model turn
123
- must select a connected capability, or `"none"` to disable tools for the
124
- Agent. After discovery Marona requires one exact capability call, then returns
125
- to automatic selection so multi-step requests can continue.
22
+ Missing, invalid, revoked, and expired keys throw typed
23
+ `MaronaAuthenticationError` subclasses. Create and rotate keys in the Marona
24
+ Developer Portal.
126
25
 
127
- ### Automatic Model And Provider Routing
128
-
129
- Use `marona/auto` when Marona should select an allowed model and provider for
130
- each request:
26
+ ## Universal Model Gateway
131
27
 
132
28
  ```ts
133
- import { Agent, Marona, Runner } from "marona";
134
-
135
- const marona = new Marona({
136
- apiKey: process.env.MARONA_API_KEY,
137
- });
138
- const tools = await marona.hub.connect();
139
-
140
- const agent = new Agent({
141
- name: "Customer Assistant",
29
+ const response = await marona.responses.create({
142
30
  model: "marona/auto",
143
- instructions: "Help the customer.",
144
- tools,
145
- voice: {
146
- output_voice: "ash",
147
- language: "en",
148
- turn_detection: "semantic_vad",
149
- interruptible: true,
150
- input_format: "pcm16",
151
- output_format: "pcm16",
152
- },
153
- modalities: ["text", "image", "audio"],
154
- outputModalities: ["text", "audio"],
31
+ input: "Review this architecture.",
155
32
  routing: {
156
33
  strategy: "balanced",
157
- maxCostUsd: 0.02,
158
- targetLatencyMs: 3000,
159
- timeoutMs: 30000,
160
- allowedModels: ["marona/gpt-5-mini", "marona/gemini-2.5-pro"],
161
- allowedProviders: ["openai", "google", "openrouter"],
162
- fallback: true,
163
- },
164
- });
165
-
166
- const result = await Runner.run(agent, [
167
- {
168
- role: "user",
169
- content: [
170
- { type: "input_text", text: "Describe the problem shown in this image." },
171
- { type: "input_image", image_url: "https://example.com/damaged-package.jpg" },
34
+ allowedModels: [
35
+ "marona/auto",
36
+ "marona/company-assistant",
172
37
  ],
173
38
  },
174
- ], {
175
- userId: "customer_482",
176
- sessionId: "chat_91a7",
177
39
  });
178
40
 
179
- console.log(result.output);
41
+ console.log(response.output);
180
42
  ```
181
43
 
182
- Tools are optional. `new Agent({ name: "Customer Assistant" })` supports an
183
- ordinary conversation after creating `Marona`.
184
-
185
- ### Streaming
186
-
187
- ```ts
188
- for await (const event of Runner.stream(agent, "Explain this document.", {
189
- userId: "customer_482",
190
- sessionId: "chat_91a7",
191
- })) {
192
- if (event.type === "output_text.delta") process.stdout.write(event.delta ?? "");
193
- }
194
- ```
44
+ Every model name must use the `marona/*` namespace. `marona/auto` delegates
45
+ selection to the project-scoped Model Registry; named aliases such as
46
+ `marona/company-assistant` resolve there. Provider credentials and custom
47
+ endpoints are configured once through the Marona Developer Portal or Model
48
+ Registry API. They are write-only and never exposed through this package.
195
49
 
196
- `Runner.stream(...)` forwards provider output incrementally. It also emits
197
- provider-neutral `tool.started`, `tool.completed`, agent transition, and final
198
- `run.completed` events. Structured output is validated only when complete.
50
+ All calls—including registered Edge models—go through authenticated Marona
51
+ Runtime. There is no direct-provider, local-executor, credential-cache, or public
52
+ model-registration bypass.
199
53
 
200
- ### Realtime
54
+ ## Agents and Hub tools
201
55
 
202
56
  ```ts
203
- import { RealtimeRunner } from "marona";
57
+ import { Agent, Runner } from "marona";
204
58
 
205
- const session = await RealtimeRunner.connect(agent, {
206
- userId: "customer_482",
207
- sessionId: "voice_91a7",
208
- });
209
-
210
- try {
211
- await session.sendMessage("List my notes");
212
- for await (const event of session) {
213
- if (event.type === "transcript.delta") process.stdout.write(event.delta ?? "");
214
- if (event.type === "response.completed") break;
215
- }
216
- } finally {
217
- await session.close();
218
- }
219
- ```
220
-
221
- The persistent session also supports `sendAudio(...)`. Provider events, tool
222
- discovery, MCP/Skill execution, and function results stay internal.
223
-
224
- ### Typed Input And Output
225
-
226
- Use JSON Schema when an Agent needs a validated input or output contract:
227
-
228
- ```ts
59
+ const tools = await marona.hub.connect({ apps: ["sda-books"] });
229
60
  const agent = new Agent({
230
61
  name: "Customer Assistant",
231
- model: "marona/gpt-5-mini",
232
- instructions: "Answer the customer's question.",
233
- inputSchema: {
234
- type: "object",
235
- required: ["question"],
236
- properties: { question: { type: "string" } },
237
- },
238
- outputSchema: {
239
- type: "object",
240
- required: ["answer", "needs_follow_up"],
241
- properties: {
242
- answer: { type: "string" },
243
- needs_follow_up: { type: "boolean" },
244
- },
245
- },
246
- });
247
-
248
- const result = await Runner.run(agent, {
249
- question: "When will my order arrive?",
250
- });
251
-
252
- console.log(result.output);
253
- ```
254
-
255
- ### Multi-Agent
256
-
257
- Use `agent.asTool()` for bounded delegation. The parent remains active and
258
- combines the specialist result. Use `handoff(...)` when the destination should
259
- own the conversation:
260
-
261
- ```ts
262
- import { Agent, Marona, Runner, handoff } from "marona";
263
-
264
- const marona = new Marona({ apiKey: process.env.MARONA_API_KEY });
265
- const tools = await marona.hub.connect();
266
-
267
- const researcher = new Agent({
268
- name: "Research Specialist",
269
- description: "Researches bounded customer questions.",
270
- model: "marona/gpt-5-mini",
271
- tools,
272
- });
273
-
274
- const billing = new Agent({
275
- name: "Billing Specialist",
276
- description: "Owns billing and payment conversations.",
277
- model: "marona/gpt-5-mini",
278
- tools,
279
- });
280
-
281
- const manager = new Agent({
282
- name: "Customer Assistant",
283
- model: "marona/gpt-5.6",
284
- tools: [researcher.asTool({ name: "research" })],
285
- handoffs: [handoff(billing, { name: "transfer_to_billing" })],
286
- });
287
-
288
- const result = await Runner.run(
289
- manager,
290
- "I was charged twice and need help.",
291
- { userId: "customer_482", sessionId: "support_91a7" },
292
- );
293
-
294
- console.log(result.output);
295
- console.log(result.activeAgent.name);
296
- console.log(result.agentRuns);
297
- ```
298
-
299
- The same graph works with `Runner.stream(...)` and
300
- `RealtimeRunner.connect(...)`. Marona rejects graph cycles, limits delegation
301
- and handoff depth, and never puts provider credentials in model context.
302
-
303
- ### Function Tools
304
-
305
- ```ts
306
- import { Agent, Runner, functionTool } from "marona";
307
-
308
- const checkRefund = functionTool({
309
- name: "check_refund",
310
- description: "Check whether a duplicate charge qualifies for a refund.",
311
- inputSchema: {
312
- type: "object",
313
- properties: {
314
- amount: { type: "number" },
315
- duplicate_charge: { type: "boolean" },
316
- },
317
- required: ["amount", "duplicate_charge"],
318
- additionalProperties: false,
319
- },
320
- permissions: ["billing.refund"],
321
- execute: async ({ amount, duplicate_charge }, context) => ({
322
- eligible: duplicate_charge && amount > 0,
323
- refund_amount: duplicate_charge ? amount : 0,
324
- customer_id: context.userId,
325
- }),
326
- });
327
-
328
- const billing = new Agent({
329
- name: "Billing Specialist",
330
- model: "marona/gpt-5-mini",
331
- tools: [checkRefund],
332
- metadata: { permissions: ["billing.refund"] },
333
- });
334
-
335
- const result = await Runner.run(
336
- billing,
337
- "I was charged twice for USD 24. Check whether I qualify for a refund.",
338
- { userId: "customer_482", sessionId: "support_91a7" },
339
- );
340
-
341
- console.log(result.output);
342
- ```
343
-
344
- The executor stays in the SDK process. Marona sends only its neutral JSON
345
- schema to the selected model and applies input, output, permission, approval,
346
- and timeout checks before and after execution.
347
-
348
- #### Realtime Multi-Agent
349
-
350
- Define the complete Agent graph, then pass its manager to
351
- `RealtimeRunner.connect(...)`. Delegation tools and handoffs remain available
352
- throughout the persistent realtime session:
353
-
354
- ```ts
355
- import { Agent, Marona, RealtimeRunner, handoff } from "marona";
356
-
357
- const marona = new Marona({ apiKey: process.env.MARONA_API_KEY });
358
- const tools = await marona.hub.connect();
359
-
360
- const researcher = new Agent({
361
- name: "Research Specialist",
362
- description: "Researches bounded customer questions.",
363
- model: "marona/gpt-5-mini",
364
- tools,
365
- });
366
-
367
- const billing = new Agent({
368
- name: "Billing Specialist",
369
- description: "Owns billing and payment conversations.",
370
- model: "marona/gpt-5-mini",
371
- tools,
372
- });
373
-
374
- const manager = new Agent({
375
- name: "Customer Assistant",
376
- model: "marona/gpt-5.6",
377
- tools: [
378
- researcher.asTool({
379
- name: "research",
380
- description: "Research one bounded question and return the result.",
381
- }),
382
- ],
383
- handoffs: [
384
- handoff(billing, {
385
- name: "transfer_to_billing",
386
- description: "Transfer billing and payment requests.",
387
- }),
388
- ],
389
- });
390
-
391
- const session = await RealtimeRunner.connect(manager, {
392
- userId: "customer_482",
393
- sessionId: "support_voice_91a7",
394
- });
395
-
396
- try {
397
- await session.sendMessage("I was charged twice and need help.");
398
-
399
- for await (const event of session) {
400
- if (event.type === "agent.handoff.completed") {
401
- console.log(event.data.target_agent);
402
- } else if (event.type === "response.completed") {
403
- console.log(event.output);
404
- break;
405
- }
406
- }
407
- } finally {
408
- await session.close();
409
- }
410
- ```
411
-
412
- Marona keeps provider events internal and emits one provider-neutral event
413
- stream. After a handoff, the destination Agent owns the following turns.
414
-
415
- ## 3. Marona Runtime
416
-
417
- Use `responses.create(...)` when Marona should manage model reasoning, tool
418
- selection, permission and approval checks, execution, and the final response.
419
-
420
- ```ts
421
- import { Marona } from "marona";
422
-
423
- const marona = new Marona({
424
- apiKey: process.env.MARONA_API_KEY,
425
- });
426
-
427
- const tools = await marona.hub.connect({
428
- apps: ["group-fund"],
429
- skills: ["create-group-fund"],
430
- });
431
-
432
- const lifecycleHooks = {
433
- onStart: async (context) => console.log(context.agentName),
434
- };
435
-
436
- const response = await marona.responses.create({
437
- model: "marona/gpt-5.6",
438
- tools,
439
- input: "Create a family savings group fund",
440
- toolChoice: "auto",
441
- hooks: lifecycleHooks, // optional provider-neutral lifecycle hooks
442
- });
443
-
444
- console.log(response.output);
445
- ```
446
-
447
- The same lifecycle hook object works with `Runner.run(...)`,
448
- `Runner.stream(...)`, `RealtimeRunner.connect(...)`, and
449
- `marona.responses.create(...)`. The runtime supplies the active model, provider,
450
- user, and session; do not repeat them in hook configuration.
451
-
452
- ```ts
453
- model: "marona/auto"
454
- model: "marona/gpt-5.6"
455
- model: "marona/gpt-5-mini"
456
- model: "marona/gpt-5-nano"
457
- model: "marona/claude-sonnet"
458
- model: "marona/gemini-2.5-pro"
459
- model: "marona/deepseek-chat"
460
- ```
461
-
462
- Use `marona/auto` when Marona should select both model and provider:
463
-
464
- ```ts
465
- import { Marona } from "marona";
466
-
467
- const marona = new Marona({
468
- apiKey: process.env.MARONA_API_KEY,
469
- });
470
-
471
- const lifecycleHooks = {
472
- onComplete: async (_context, result) => {
473
- console.log(result.model, result.routing);
474
- },
475
- };
476
-
477
- const response = await marona.responses.create({
478
- model: "marona/auto",
479
- routing: {
480
- strategy: "balanced", // balanced | quality | cost | latency
481
- maxCostUsd: 0.02,
482
- targetLatencyMs: 3000,
483
- timeoutMs: 30000,
484
- allowedModels: ["marona/gpt-5-mini", "marona/claude-sonnet"],
485
- allowedProviders: ["openai", "anthropic", "openrouter"],
486
- fallback: true,
487
- },
488
- input: "Review this distributed system design.",
489
- hooks: lifecycleHooks,
490
- });
491
-
492
- console.log(response.output);
493
- console.log(response.model);
494
- console.log(response.routing);
495
- ```
496
-
497
- The completion hook receives this same normalized response, including the
498
- requested `model` contract and complete `routing` decision. An observer can
499
- record the selected model from `routing`, provider, fallback, latency, cost,
500
- and failure information without duplicate model configuration in the hook.
501
-
502
- With a specific `marona/...` model, Marona keeps that exact model and may only
503
- change provider. Direct-provider routes are never rerouted.
504
-
505
- The same request also supports direct-provider, private, and local models:
506
-
507
- ```ts
508
- model: "openai/gpt-5.6" // Marona key + OpenAI key
509
- model: "openrouter/anthropic/claude-sonnet" // OpenRouter
510
- model: "anthropic/claude-sonnet" // Anthropic directly
511
- model: "google/gemini" // Google directly
512
- model: "ollama/qwen3" // Ollama
513
- model: "litellm/local-qwen" // LiteLLM gateway
514
- model: "local/qwen" // Downloaded/in-process model
515
- ```
516
-
517
- Direct provider routes resolve credentials from their standard environment
518
- variables. For OpenRouter, set `OPENROUTER_API_KEY`; Marona automatically uses
519
- `https://openrouter.ai/api/v1` and preserves the remaining OpenRouter model
520
- slug:
521
-
522
- ```ts
523
- const response = await marona.responses.create({
524
- model: "openrouter/anthropic/claude-sonnet",
525
- input: "Help me with this request",
526
- });
527
-
528
- console.log(response.output);
529
- ```
530
-
531
- Register only custom providers or downloaded in-process models:
532
-
533
- ```ts
534
- import { Marona } from "marona";
535
-
536
- // A Marona developer key is optional for an explicitly registered model.
537
- const marona = new Marona();
538
-
539
- await marona.models.register({
540
- name: "office/company-assistant",
541
- provider: "custom",
542
- endpoint: "https://models.office.example/v1",
543
- model: "company-assistant-v2",
544
- apiKey: process.env.OFFICE_MODEL_API_KEY,
545
- adapter: officeNativeAdapter,
546
- });
547
-
548
- await marona.models.register({
549
- name: "local/qwen",
550
- executor: qwenExecutor,
551
- contextWindow: 8192,
552
- maxOutputTokens: 512,
553
- });
554
- ```
555
-
556
- Managed `marona/...` routes, Hub, Skills, and unregistered remote model routes
557
- still require `MARONA_API_KEY`.
558
-
559
- ### Images
560
-
561
- ```ts
562
- import { Marona } from "marona";
563
-
564
- const marona = new Marona({
565
- apiKey: process.env.MARONA_API_KEY,
566
- });
567
-
568
- const response = await marona.responses.create({
569
- model: "openai/gpt-5.6",
570
- input: [
571
- {
572
- role: "user",
573
- content: [
574
- { type: "input_text", text: "Summarize this image." },
575
- { type: "input_image", image_url: "https://example.com/image.jpg" },
576
- ],
577
- },
578
- ],
579
- });
580
-
581
- console.log(response.output);
582
- ```
583
-
584
- ### Files
585
-
586
- ```ts
587
- import { Marona } from "marona";
588
-
589
- const marona = new Marona({
590
- apiKey: process.env.MARONA_API_KEY,
591
- });
592
-
593
- const response = await marona.responses.create({
594
- model: "openai/gpt-5.6",
595
- input: [
596
- {
597
- role: "user",
598
- content: [
599
- { type: "input_text", text: "Summarize this file." },
600
- {
601
- type: "input_file",
602
- filename: "report.pdf",
603
- file_data: "data:application/pdf;base64,...",
604
- detail: "high",
605
- },
606
- ],
607
- },
608
- ],
609
- });
610
-
611
- console.log(response.output);
612
- ```
613
-
614
- ## 4. Bring Your Own Agent
615
-
616
- The external framework owns its Agent, reasoning, and orchestration. Marona
617
- supplies neutral MCP tools and retains authorization, approvals, and execution.
618
-
619
- ```ts
620
- const connection = await marona.hub.connect({
621
- apps: ["group-fund"],
622
- skills: ["create-group-fund"],
623
- });
624
-
625
- const frameworkTools = yourFrameworkMcpAdapter(connection);
626
-
627
- const agent = new YourAgent({
628
- name: "Group Fund Assistant",
629
- model: "marona/gpt-5.6",
630
- instructions: "Help users create and manage group funds.",
631
- tools: frameworkTools,
632
- });
633
-
634
- const result = await agent.run("Create a family savings group fund");
635
- ```
636
-
637
- An MCP-compatible framework can map its standard list-tools and call-tool hooks
638
- directly to `connection.listTools()` and `connection.callTool(...)`. One
639
- JavaScript object cannot automatically satisfy every framework's proprietary
640
- tool interface, so any framework-specific conversion belongs at that boundary.
641
-
642
- ### OpenAI Agents SDK Example
643
-
644
- The OpenAI Agents SDK example uses the Python Marona package and keeps the
645
- OpenAI-specific adapter at the framework boundary:
646
-
647
- ```python
648
- from agents import Agent, Runner
649
- from marona import Marona
650
-
651
- marona = Marona(api_key="YOUR_MARONA_API_KEY")
652
- connection = marona.hub.connect(
653
- apps=["group-fund"],
654
- skills=["create-group-fund"],
655
- )
656
-
657
- framework_tools = your_openai_agents_mcp_adapter(connection)
658
-
659
- agent = Agent(
660
- name="Group Fund Assistant",
661
- model="marona/gpt-5.6",
662
- instructions="Help users create and manage group funds.",
663
- tools=framework_tools,
664
- )
665
-
666
- result = Runner.run_sync(agent, "Create a family savings group fund")
667
- print(result.final_output)
668
- ```
669
-
670
- `your_openai_agents_mcp_adapter(...)` represents the OpenAI-specific adapter;
671
- it is not part of Marona's vendor-neutral core API.
672
-
673
- ## 8. Publish A Skill
674
-
675
- Every workflow entry uses `step()`; `type` selects reasoning, approval, or App
676
- execution. New Skills default to private.
677
-
678
- ```ts
679
- import { Marona, SkillDefinition, step } from "marona";
680
-
681
- const marona = new Marona({ apiKey: process.env.MARONA_API_KEY });
682
- const request = step({
683
- id: "understand-request",
684
- type: "reasoning",
685
- instruction: "Extract the group name and currency.",
686
- inputs: { message: "{{ context.user_message }}" },
687
- outputs: { name: "string", currency: "string" },
688
- });
689
- const permission = step({
690
- id: "confirm-create",
691
- type: "approval",
692
- message: "Create the requested group fund?",
693
- outputs: { approved: "boolean" },
694
- });
695
- const definition = new SkillDefinition({
696
- name: "create-group-fund",
697
- description: "Create a group fund after explicit user approval.",
698
- visibility: "public",
699
- governs: ["group-fund.create_group"],
700
- steps: [
701
- request,
702
- permission,
703
- step({
704
- id: "create-group",
705
- type: "app",
706
- app: "group-fund",
707
- capability: "group-fund.create_group",
708
- instruction: "Create the approved group.",
709
- condition: permission.output("approved"),
710
- inputs: {
711
- name: request.output("name"),
712
- currency: request.output("currency"),
713
- },
714
- outputs: { group_id: "string", name: "string" },
715
- }),
716
- ],
717
- });
718
-
719
- await marona.skills.publish(definition, { version: "1.0.0" });
720
- ```
721
-
722
- ## Agent-to-Agent (A2A)
723
-
724
- Use `peers` for independently deployed agents that implement the open A2A
725
- protocol. Agent Card discovery, credentials, task execution, and artifacts stay
726
- provider-neutral.
727
-
728
- ```typescript
729
- import {
730
- A2APeer,
731
- Agent,
732
- Marona,
733
- RealtimeRunner,
734
- Runner,
735
- } from "marona";
736
-
737
- const marona = new Marona({
738
- apiKey: process.env.MARONA_API_KEY,
739
- });
740
-
741
- const flightAgent = new A2APeer({
742
- name: "flight_agent",
743
- url: "https://flight-agent.example.com",
744
- authentication: {
745
- type: "bearer",
746
- token: process.env.FLIGHT_AGENT_TOKEN,
747
- },
748
- permissions: ["travel.route.read", "travel.dates.read"],
749
- policy: {
750
- deniedFields: ["payment_credentials", "identity_document"],
751
- },
752
- });
753
-
754
- const tripReviewTeam = new A2APeer({
755
- name: "trip_review_team",
756
- url: "https://trip-review.example.com",
757
- description:
758
- "An independent multi-agent team that validates itineraries and budgets.",
759
- authentication: {
760
- type: "bearer",
761
- token: process.env.TRIP_REVIEW_AGENT_TOKEN,
762
- },
763
- permissions: ["travel.itinerary.read", "travel.budget.read"],
764
- });
765
-
766
- const travelAgent = new Agent({
767
- name: "Travel Manager",
768
62
  model: "marona/auto",
769
- instructions:
770
- "Find travel options and ask the review team to validate the itinerary and budget.",
771
- peers: [flightAgent, tripReviewTeam],
772
- metadata: {
773
- permissions: [
774
- "travel.route.read",
775
- "travel.dates.read",
776
- "travel.itinerary.read",
777
- "travel.budget.read",
778
- ],
779
- },
63
+ instructions: "Help clearly.",
64
+ tools,
780
65
  });
781
66
 
782
67
  const result = await Runner.run(
783
- travelAgent,
784
- "Find a return flight from Harare to Cape Town and validate it against USD 1,500.",
785
- { userId: "customer_482", sessionId: "travel_91a7" },
68
+ agent,
69
+ "Download Steps to Christ",
70
+ { userId: "customer_482", sessionId: "chat_91a7" },
786
71
  );
787
-
788
72
  console.log(result.output);
789
73
  ```
790
74
 
791
- Use the same peers in a persistent realtime session:
75
+ The SDK also supports streaming, realtime, handoffs, delegation, A2A peers,
76
+ validated function tools, lifecycle hooks, and published Marona Skills while
77
+ keeping every model invocation behind the Universal Model Gateway.
792
78
 
793
- ```typescript
794
- const session = await RealtimeRunner.connect(travelAgent, {
795
- userId: "customer_482",
796
- sessionId: "travel_voice_91a7",
797
- });
79
+ ## Errors
798
80
 
799
- try {
800
- await session.sendMessage(
801
- "Find a direct flight to Cape Town and have the review team validate it.",
802
- );
803
-
804
- for await (const event of session) {
805
- if (event.type === "response.completed") {
806
- console.log(event.output);
807
- break;
808
- }
809
- }
810
- } finally {
811
- await session.close();
812
- }
813
- ```
814
-
815
- An A2A peer may be a single agent or an independently deployed multi-agent
816
- runtime. The coordinator uses the same Agent Card, task, event, and artifact
817
- contract. The same peers also work with `Runner.stream(...)`.
818
-
819
- ## Execution Modes
820
-
821
- ```ts
822
- const marona = new Marona({
823
- apiKey: process.env.MARONA_API_KEY,
824
- mode: "hybrid",
825
- });
826
- ```
81
+ `MaronaError` exposes `code`, `requestId`, `retryable`,
82
+ `requiredAction`, `retryAfterMs`, and safe `details`. Typed subclasses
83
+ cover authentication, namespace/model, credits, upstream service, custom model,
84
+ billing, and Marona availability failures. Responses expose only safe routing
85
+ fields, never upstream endpoints or raw provider payloads.
827
86
 
828
- - `online`: network models and online MCP targets are allowed.
829
- - `hybrid`: local/private execution may fall back to online execution.
830
- - `offline`: only installed local Apps, Skills, data, and local models run.
87
+ ## Release
831
88
 
832
- Changing `model` never changes App, Skill, permission, approval, or MCP rules.
89
+ Version `1.0.0` is published to npm from tag `typescript-v1.0.0` only after
90
+ build, tests, package validation, and coordinated release checks succeed on
91
+ `main`.