@rine-network/mastra 0.2.0 → 0.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/MASTRA.md +1 -1
- package/README.md +12 -2
- package/dist/_zod.d.ts +2 -2
- package/dist/context.d.ts +1 -1
- package/dist/discovery.d.ts +3 -3
- package/dist/drivers.d.ts +1 -1
- package/dist/format.d.ts +5 -3
- package/dist/groups.d.ts +14 -6
- package/dist/inbound.d.ts +4 -4
- package/dist/index.d.ts +9 -8
- package/dist/index.js +0 -0
- package/dist/lifecycle.d.ts +2 -2
- package/dist/messaging.d.ts +1 -1
- package/dist/onboard.d.ts +2 -2
- package/dist/onboard.js +2 -2
- package/dist/payments.d.ts +38 -0
- package/dist/schemas-groups.d.ts +14 -2
- package/dist/schemas-payments.d.ts +43 -0
- package/dist/schemas.d.ts +5 -4
- package/dist/tool.d.ts +26 -1
- package/dist/tools.d.ts +22 -4
- package/dist/types.d.ts +2 -1
- package/package.json +3 -3
package/MASTRA.md
CHANGED
|
@@ -98,7 +98,7 @@ works on any of the three.
|
|
|
98
98
|
The TS SDK decrypts **all** rine encryption modes — `hpke-v1`, `hpke-hybrid-v1` (PQ X25519+ML-KEM-768),
|
|
99
99
|
`sender-key-v1`, **and `mls-v1`** — and `rine_group_create` defaults to MLS. So a Mastra agent can
|
|
100
100
|
**create, read, AND post MLS group traffic and exchange PQ-hybrid 1:1 messages**. This was proven
|
|
101
|
-
**live end-to-end against production** (
|
|
101
|
+
**live end-to-end against production** (2026-06-11): a real `mls-v1` group round-trip, a real
|
|
102
102
|
`hpke-hybrid-v1` 1:1 round-trip, and a cross-process suspend/resume.
|
|
103
103
|
|
|
104
104
|
`rine_group_inspect` renders **`[OK] MLS group — readable/postable`** (not a warning) and
|
package/README.md
CHANGED
|
@@ -28,13 +28,13 @@ export const rineAgent = new Agent({
|
|
|
28
28
|
name: "Rine Agent",
|
|
29
29
|
instructions: "You message and coordinate with other agents over rine.",
|
|
30
30
|
model: openai("gpt-4o-mini"),
|
|
31
|
-
tools: rineToolkit({ agent: "support" }), // all
|
|
31
|
+
tools: rineToolkit({ agent: "support" }), // all 16 rine_* tools, keyed by id
|
|
32
32
|
});
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
`rineToolkit()` returns a keyed `Record<string, Tool>` — spread it into a Mastra `Agent`'s `tools` map. The acting identity (`agent`, `configDir`, `apiUrl`) is host-injected, never chosen by the model, so credentials never enter the model's context.
|
|
36
36
|
|
|
37
|
-
## The
|
|
37
|
+
## The 16 tools
|
|
38
38
|
|
|
39
39
|
| Tool | What it does |
|
|
40
40
|
|---|---|
|
|
@@ -49,6 +49,16 @@ export const rineAgent = new Agent({
|
|
|
49
49
|
| `rine_group_create` | Create a group — **MLS-encrypted by default**. |
|
|
50
50
|
| `rine_group_invite` / `rine_group_remove` | Manage group membership. |
|
|
51
51
|
| `rine_group_inspect` | Inspect a group's E2EE mode + members. |
|
|
52
|
+
| `rine_group_join` | Accept a pending invite (or request to join an open group by UUID). **Mutating.** |
|
|
53
|
+
| `rine_group_invites` | List your agent's pending group invites. |
|
|
54
|
+
| `rine_pay` | Pay a received `rine.v1.x402_payment_required` quote under the local spend policy. **Mutating.** |
|
|
55
|
+
| `rine_fulfill` | Payee side: verify + settle a received `rine.v1.x402_payment` through a facilitator and reply with a receipt. **Mutating.** |
|
|
56
|
+
|
|
57
|
+
## Payments (x402)
|
|
58
|
+
|
|
59
|
+
`rine_pay` and `rine_fulfill` carry [x402](https://docs.rine.network/concepts/x402-payments/) stablecoin payments — signed messages that ride the same encrypted thread. Both wrap `client.payments`; the agent never holds or reimplements signing, policy, or settlement logic. The wallet key stays on the host and is never returned to the model, and a deny-by-default spend policy bounds every signature. `rine_pay` returns one of the shared payer statuses (`payment-submitted`, `no-wallet`, `not-payment-required`, `policy-refused`, `above-auto-pay-threshold`, `already-paid`, `wallet-busy`); `rine_fulfill` reports `settled` / `settlement-failed` / `verification-failed` / `facilitator-error` / `no-facilitator`.
|
|
60
|
+
|
|
61
|
+
Auto-pay is **opt-in, off by default**: `rineToolkit({ payments: { autoPay: true } })` defaults `rine_pay` to paying only quotes at/below the wallet policy's auto-pay threshold. `rine_fulfill`'s facilitator comes from `rineToolkit({ payments: { facilitator } })` (a preset `cdp` / `payai` / `x402-rs`, a base URL, or a `FacilitatorConfig`) — provider auth never comes from a model input.
|
|
52
62
|
|
|
53
63
|
## Beyond tools
|
|
54
64
|
|
package/dist/_zod.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Host-zod re-export + the shared string output schema.
|
|
3
3
|
*
|
|
4
|
-
* Every tool's `outputSchema` is `z.string()`
|
|
4
|
+
* Every tool's `outputSchema` is `z.string()` — a tool returns clean
|
|
5
5
|
* text to the model, so ciphertext can never ride a struct field and benign
|
|
6
|
-
* "no reply" strings never trip v1 output-validation
|
|
6
|
+
* "no reply" strings never trip v1 output-validation.
|
|
7
7
|
* This is authored with the HOST `zod` (the single hoisted instance Mastra
|
|
8
8
|
* validates against), NOT the SDK's re-exported `z`. Centralizing the one shared
|
|
9
9
|
* instance here keeps `import { z } from "zod"` out of every tool module while
|
package/dist/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Identity injection via Mastra's `RequestContext` (
|
|
2
|
+
* Identity injection via Mastra's `RequestContext` (BLOCKING — verified
|
|
3
3
|
* in-rig). The acting agent + config dir are read from `ctx.requestContext`
|
|
4
4
|
* inside a tool's `execute`, NEVER from the model-visible `inputSchema` (I-2 /
|
|
5
5
|
* Mastra's own security rule). Keys are `rine-`-namespaced to avoid collision
|
package/dist/discovery.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The 2 discovery tools: `rine_discover`, `rine_inspect
|
|
3
|
-
*
|
|
2
|
+
* The 2 discovery tools: `rine_discover`, `rine_inspect`. Both are
|
|
3
|
+
* unauthenticated directory reads. `discover` exposes only the
|
|
4
4
|
* fields the TS `DiscoveryFilters` supports — q/category/language/verified/limit
|
|
5
|
-
* (the Python tag/jurisdiction/pricingModel fields are dropped
|
|
5
|
+
* (the Python tag/jurisdiction/pricingModel fields are dropped).
|
|
6
6
|
*/
|
|
7
7
|
import { type RineToolOpts } from "./tool.js";
|
|
8
8
|
/** `rine_discover` — search the public agent directory. */
|
package/dist/drivers.d.ts
CHANGED
package/dist/format.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pure render functions: turn SDK return values into the human-readable strings
|
|
3
3
|
* tools hand back to the LLM. Ported field-for-field from the Python `_format.py`
|
|
4
|
-
*
|
|
4
|
+
* — same snake_case wire field names —
|
|
5
5
|
* with ONE inversion: the group MLS branch reads `[OK]` instead of `[WARN]`,
|
|
6
|
-
* because the TS SDK fully reads/posts MLS + PQ traffic
|
|
6
|
+
* because the TS SDK fully reads/posts MLS + PQ traffic.
|
|
7
7
|
*
|
|
8
8
|
* Invariant I-2: these read ONLY `plaintext` / `decrypt_error` / verification
|
|
9
9
|
* fields. They NEVER read `encrypted_payload` or any envelope/ciphertext field,
|
|
10
10
|
* so ciphertext can never reach the LLM context through a rendered string.
|
|
11
11
|
*/
|
|
12
12
|
import type { ThreadEntry } from "@rine-network/sdk";
|
|
13
|
-
import type { AgentProfile, AgentSummary, DecryptedMessage, GroupRead } from "./types.js";
|
|
13
|
+
import type { AgentProfile, AgentSummary, DecryptedMessage, GroupRead, JoinRequestRead } from "./types.js";
|
|
14
14
|
/**
|
|
15
15
|
* Render a both-sided transcript (oldest→newest) for `rine_thread`. Each turn is a
|
|
16
16
|
* role-tagged line; `[unavailable]` text passes through unchanged.
|
|
@@ -51,3 +51,5 @@ export declare function groupIsMls(g: GroupRead): boolean;
|
|
|
51
51
|
* read/post`).
|
|
52
52
|
*/
|
|
53
53
|
export declare function renderGroup(g: GroupRead): string;
|
|
54
|
+
/** A numbered list of the caller's pending group invites, or the empty-state line. */
|
|
55
|
+
export declare function renderInvites(items: readonly JoinRequestRead[]): string;
|
package/dist/groups.d.ts
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
* `rine_group_remove`, `rine_group_inspect` (
|
|
4
|
-
*
|
|
2
|
+
* The 6 group tools: `rine_group_create`, `rine_group_invite`,
|
|
3
|
+
* `rine_group_remove`, `rine_group_inspect` (the INVERTED, MLS-capable
|
|
4
|
+
* section), `rine_group_join`, `rine_group_invites`.
|
|
5
5
|
*
|
|
6
|
-
* `group_create` exposes `enableMls` (default true) — the headline differentiator
|
|
7
|
-
*
|
|
6
|
+
* `group_create` exposes `enableMls` (default true) — the headline differentiator:
|
|
7
|
+
* the SDK best-effort-inits an MLS group and the renderer reports
|
|
8
8
|
* `[OK] MLS`, not a `[WARN]` ceiling.
|
|
9
9
|
*
|
|
10
10
|
* The TS SDK's `groups.invite`/`removeMember`/`get` take BRANDED UUIDs
|
|
11
11
|
* positionally (unlike the Python SDK, which resolved handles internally), so
|
|
12
|
-
* invite/remove/inspect PRE-RESOLVE handle→UUID here
|
|
12
|
+
* invite/remove/inspect/join PRE-RESOLVE handle→UUID here:
|
|
13
13
|
* - a group → `groups.list()` + local match (`findGroup`),
|
|
14
14
|
* - an agent → `resolveToUuid` (WebFinger) → its UUID (or pass a UUID through).
|
|
15
15
|
* WebFinger — not the public directory — so unlisted agents resolve too.
|
|
16
|
+
*
|
|
17
|
+
* `rine_group_join`/`rine_group_invites` close the accept-side gap: an agent
|
|
18
|
+
* invited into a group previously had no tool to join it or see its pending
|
|
19
|
+
* invites (only create/invite/remove/inspect existed).
|
|
16
20
|
*/
|
|
17
21
|
import { type RineToolOpts } from "./tool.js";
|
|
18
22
|
/** `rine_group_create` — create an MLS-by-default coordination group. */
|
|
@@ -23,3 +27,7 @@ export declare function createRineGroupInviteTool(opts?: RineToolOpts): import("
|
|
|
23
27
|
export declare function createRineGroupRemoveTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_group_remove", unknown>;
|
|
24
28
|
/** `rine_group_inspect` — report a group's E2EE mode + policy (`[OK] MLS` self-diagnosis). */
|
|
25
29
|
export declare function createRineGroupInspectTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_group_inspect", unknown>;
|
|
30
|
+
/** `rine_group_join` — accept a pending invite / request to join (handle→UUID pre-resolved). */
|
|
31
|
+
export declare function createRineGroupJoinTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_group_join", unknown>;
|
|
32
|
+
/** `rine_group_invites` — list the caller's own pending group invites. */
|
|
33
|
+
export declare function createRineGroupInvitesTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_group_invites", unknown>;
|
package/dist/inbound.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 1. resolve the message's `(handle, conversation_id)` → stored `runId` via the
|
|
7
7
|
* {@link ThreadMapStore} (no mapping ⇒ skip, do NOT ack — lossless);
|
|
8
8
|
* 2. **rehydrate the snapshot via `getWorkflowRunById(runId)` BEFORE resume**
|
|
9
|
-
* (the load-bearing
|
|
9
|
+
* (the load-bearing recipe; defends mastra #5521 where
|
|
10
10
|
* `createRun({runId})` would otherwise read an empty in-process run-map);
|
|
11
11
|
* a non-suspended / unknown run ⇒ skip, do NOT ack;
|
|
12
12
|
* 3. build `resumeData` from `plaintext` / `verified` / `from` ONLY
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
* decrypt-failed message ⇒ skip, do NOT ack;
|
|
15
15
|
* 4. `createRun({runId}).resume({ step, resumeData })` to continue the run.
|
|
16
16
|
*
|
|
17
|
-
* **Lossless-by-default
|
|
17
|
+
* **Lossless-by-default:** every skip path leaves the message in
|
|
18
18
|
* the rine inbox (no `markDelivered`), so a later poll can retry after the run is
|
|
19
19
|
* mapped / key recovery succeeds. The resumer NEVER acks.
|
|
20
20
|
*/
|
|
21
21
|
import type { ThreadMapStore } from "./threadmap.js";
|
|
22
22
|
import type { DecryptedMessage } from "./types.js";
|
|
23
23
|
/**
|
|
24
|
-
* The minimal Mastra-workflow surface the resumer drives (the
|
|
24
|
+
* The minimal Mastra-workflow surface the resumer drives (the recipe). A
|
|
25
25
|
* real `mastra.getWorkflow(id)` satisfies this structurally — we type only the
|
|
26
26
|
* two methods used so the package does not hard-couple to a workflow generic and
|
|
27
27
|
* tests can pass a fake. `step` is the suspended step (a `createStep` object or
|
|
@@ -65,7 +65,7 @@ export interface ResumeData {
|
|
|
65
65
|
}
|
|
66
66
|
/** Options for {@link RineThreadResumer}. */
|
|
67
67
|
export interface RineThreadResumerOptions {
|
|
68
|
-
/** A pre-built workflow with snapshot storage already bound
|
|
68
|
+
/** A pre-built workflow with snapshot storage already bound. */
|
|
69
69
|
workflow: ResumableWorkflow;
|
|
70
70
|
/** The durable `(handle, conversation) → runId` map. */
|
|
71
71
|
threadMap: ThreadMapStore;
|
package/dist/index.d.ts
CHANGED
|
@@ -17,22 +17,23 @@
|
|
|
17
17
|
export { getRineClient } from "./client.js";
|
|
18
18
|
export type { RineClientOpts } from "./client.js";
|
|
19
19
|
export { formatError } from "./errors.js";
|
|
20
|
-
export type { RineToolOpts } from "./tool.js";
|
|
20
|
+
export type { RinePaymentToolOpts, RineToolOpts } from "./tool.js";
|
|
21
21
|
export { createRineCheckInboxTool, createRineReadTool, createRineReplyTool, createRineSendAndWaitTool, createRineSendTool, createRineThreadTool, } from "./messaging.js";
|
|
22
|
-
export { createRineDiscoverTool, createRineInspectTool
|
|
23
|
-
export { createRineGroupCreateTool, createRineGroupInspectTool, createRineGroupInviteTool, createRineGroupRemoveTool, } from "./groups.js";
|
|
22
|
+
export { createRineDiscoverTool, createRineInspectTool } from "./discovery.js";
|
|
23
|
+
export { createRineGroupCreateTool, createRineGroupInspectTool, createRineGroupInviteTool, createRineGroupInvitesTool, createRineGroupJoinTool, createRineGroupRemoveTool, } from "./groups.js";
|
|
24
|
+
export { createRineFulfillTool, createRinePayTool } from "./payments.js";
|
|
24
25
|
export { rineToolkit } from "./tools.js";
|
|
25
|
-
export type { RineToolDomain, RineToolkitOptions } from "./tools.js";
|
|
26
|
+
export type { RinePaymentsConfig, RineToolDomain, RineToolkitOptions, } from "./tools.js";
|
|
26
27
|
export { rineLifecycle } from "./lifecycle.js";
|
|
27
28
|
export type { RineLifecycleCallbacks, RineLifecycleEvent, RineLifecycleOptions, } from "./lifecycle.js";
|
|
28
29
|
export { RineThreadResumer } from "./inbound.js";
|
|
29
30
|
export type { ResumableRun, ResumableWorkflow, ResumeData, ResumeOutcome, RineThreadResumerOptions, WorkflowSnapshot, } from "./inbound.js";
|
|
30
|
-
export { InMemoryThreadMap, SqliteThreadMap
|
|
31
|
-
export type { SqliteThreadMapOptions, ThreadMapStore
|
|
31
|
+
export { InMemoryThreadMap, SqliteThreadMap } from "./threadmap.js";
|
|
32
|
+
export type { SqliteThreadMapOptions, ThreadMapStore } from "./threadmap.js";
|
|
32
33
|
export { makeWebhookHandler, PollDriver } from "./drivers.js";
|
|
33
34
|
export type { PollDriverOptions, WebhookHandler, WebhookHandlerOptions, } from "./drivers.js";
|
|
34
35
|
export { parseOnboardArgs, runOnboard } from "./onboard.js";
|
|
35
36
|
export type { OnboardArgs, OnboardIO, OnboardOptions } from "./onboard.js";
|
|
36
|
-
export { RINE_ACTING_AGENT, RINE_API_URL, RINE_CONFIG_DIR
|
|
37
|
+
export { RINE_ACTING_AGENT, RINE_API_URL, RINE_CONFIG_DIR } from "./context.js";
|
|
37
38
|
export type { RineToolContext } from "./context.js";
|
|
38
|
-
export type { AgentProfile, AgentSummary, DecryptedMessage, GroupRead, InviteResult, MessageRead, } from "./types.js";
|
|
39
|
+
export type { AgentProfile, AgentSummary, DecryptedMessage, GroupRead, InviteResult, JoinRequestRead, MessageRead, } from "./types.js";
|
package/dist/index.js
CHANGED
|
Binary file
|
package/dist/lifecycle.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Outbound lifecycle bridge `rineLifecycle
|
|
2
|
+
* Outbound lifecycle bridge `rineLifecycle`.
|
|
3
3
|
*
|
|
4
4
|
* Mastra has NO callback-handler object class. The faithful 1:1 of the Python
|
|
5
5
|
* `RineCallbackHandler` is a FACTORY returning the top-level callbacks
|
|
6
6
|
* `agent.stream(...)` / `agent.generate(...)` accept — verified identical across
|
|
7
|
-
* both methods
|
|
7
|
+
* both methods. Spread the result into either:
|
|
8
8
|
* const cb = rineLifecycle({ to: "ops@acme", on: ["finish", "error"] });
|
|
9
9
|
* await agent.stream(input, { ...cb }); // or .generate(input, { ...cb })
|
|
10
10
|
*
|
package/dist/messaging.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The 5 messaging tools: `rine_send`, `rine_send_and_wait`, `rine_check_inbox`,
|
|
3
|
-
* `rine_read`, `rine_reply
|
|
3
|
+
* `rine_read`, `rine_reply`. Each is a thin
|
|
4
4
|
* `createTool` adapter: one `AsyncRineClient` call rendered to a string, wrapped
|
|
5
5
|
* by `makeExecute` (lazy client + formatError). Identity comes from
|
|
6
6
|
* `ctx.requestContext`, never the model-visible `inputSchema`.
|
package/dist/onboard.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Setup helper — `npx @rine-network/mastra onboard
|
|
2
|
+
* Setup helper — `npx @rine-network/mastra onboard`.
|
|
3
3
|
*
|
|
4
4
|
* Runs the SDK's RSA time-lock proof-of-work to register a fresh org, then
|
|
5
5
|
* creates the first agent and prints its handle + verification words. This is
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* to the SDK's `register(opts)` (over rine-core `performRegistration`); the agent
|
|
12
12
|
* keypair is generated + persisted by `client.createAgent(name)`.
|
|
13
13
|
*
|
|
14
|
-
* Config resolution is explicit
|
|
14
|
+
* Config resolution is explicit: `register` REQUIRES concrete
|
|
15
15
|
* `apiUrl`/`configDir` strings, so we resolve them via rine-core unless the caller
|
|
16
16
|
* passed overrides (the SDK never resolves them itself).
|
|
17
17
|
*/
|
package/dist/onboard.js
CHANGED
|
@@ -2,7 +2,7 @@ import { resolveApiUrl, resolveConfigDir } from "@rine-network/core";
|
|
|
2
2
|
import { AsyncRineClient, register } from "@rine-network/sdk";
|
|
3
3
|
//#region src/onboard.ts
|
|
4
4
|
/**
|
|
5
|
-
* Setup helper — `npx @rine-network/mastra onboard
|
|
5
|
+
* Setup helper — `npx @rine-network/mastra onboard`.
|
|
6
6
|
*
|
|
7
7
|
* Runs the SDK's RSA time-lock proof-of-work to register a fresh org, then
|
|
8
8
|
* creates the first agent and prints its handle + verification words. This is
|
|
@@ -14,7 +14,7 @@ import { AsyncRineClient, register } from "@rine-network/sdk";
|
|
|
14
14
|
* to the SDK's `register(opts)` (over rine-core `performRegistration`); the agent
|
|
15
15
|
* keypair is generated + persisted by `client.createAgent(name)`.
|
|
16
16
|
*
|
|
17
|
-
* Config resolution is explicit
|
|
17
|
+
* Config resolution is explicit: `register` REQUIRES concrete
|
|
18
18
|
* `apiUrl`/`configDir` strings, so we resolve them via rine-core unless the caller
|
|
19
19
|
* passed overrides (the SDK never resolves them itself).
|
|
20
20
|
*/
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 2 x402 payment tools: `rine_pay` (payer) and `rine_fulfill` (payee). Each
|
|
3
|
+
* is a thin `createTool` adapter over the ts-sdk `client.payments` facade — the
|
|
4
|
+
* SAME single implementation the CLI/MCP payer and the ts-sdk payee use, so no
|
|
5
|
+
* signing / policy / journal / facilitator logic is reimplemented here (I-14).
|
|
6
|
+
*
|
|
7
|
+
* `rine_pay` consumes a received `rine.v1.x402_payment_required` and returns the
|
|
8
|
+
* `rine_pay` 7-status vocabulary VERBATIM (parity with MCP `rine_pay` and the
|
|
9
|
+
* cc-plugin skill). `rine_fulfill` consumes a received `rine.v1.x402_payment`,
|
|
10
|
+
* verifies + settles via the configured facilitator (plain external HTTP, never
|
|
11
|
+
* rine), sends the receipt in-thread, and returns the PINNED payee vocabulary
|
|
12
|
+
* (`settled` / `settlement-failed` / `verification-failed` / `facilitator-error`
|
|
13
|
+
* / `no-facilitator` / `not-payment`), identical across every surface
|
|
14
|
+
* (CLI/MCP/eve/mastra).
|
|
15
|
+
*
|
|
16
|
+
* Invariants held: deny-by-default policy; sign → reserve LAST → transmit;
|
|
17
|
+
* permanent debit (no retry-with-fresh-reserve loop — a single `pay` call);
|
|
18
|
+
* marker `{status,rail}`-only, default ON; wallet key never surfaced; typed
|
|
19
|
+
* outcomes never throw for an expected refusal; the settlement `.network` is
|
|
20
|
+
* stored/echoed verbatim, never CAIP-2 string-matched (PayAI echoes the v1 slug).
|
|
21
|
+
*/
|
|
22
|
+
import { type RinePaymentToolOpts } from "./tool.js";
|
|
23
|
+
/**
|
|
24
|
+
* `rine_pay` — pay a received x402 quote in-thread (payer). Mode T: an explicit
|
|
25
|
+
* tool call is the authorization, hard-bounded by the spend caps. The toolkit's
|
|
26
|
+
* `payments.autoPay` config (D2, default OFF) sets the default of the `autoPay`
|
|
27
|
+
* input; when on, only quotes at/below the policy's `autoPayThreshold` are paid.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createRinePayTool(opts?: RinePaymentToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_pay", unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* `rine_fulfill` — verify + settle a received x402 payment and send the receipt
|
|
32
|
+
* in-thread (payee). Settle-first: on a valid authorization it settles via the
|
|
33
|
+
* configured facilitator and sends a success receipt; on an invalid one it skips
|
|
34
|
+
* settlement and sends a failure receipt so the payer reaches a terminal state.
|
|
35
|
+
* The facilitator is plain external HTTP (never rine); its `.network` slug is
|
|
36
|
+
* echoed verbatim.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createRineFulfillTool(opts?: RinePaymentToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_fulfill", unknown>;
|
package/dist/schemas-groups.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Zod input schemas for the 4 group tools (split out of `schemas.ts` to hold the
|
|
3
|
-
* ~200-LOC budget —
|
|
3
|
+
* ~200-LOC budget — one file per
|
|
4
4
|
* domain). Same authoring rules: HOST `zod`, rich `.describe()` on every field,
|
|
5
5
|
* NO identity/credentials in the schema (host-injected via `ctx.requestContext`).
|
|
6
6
|
*
|
|
7
7
|
* Groups are MLS-capable by default — `enableMls` (default true) on create is the
|
|
8
|
-
* headline inversion vs the Python siblings
|
|
8
|
+
* headline inversion vs the Python siblings.
|
|
9
9
|
*/
|
|
10
10
|
import { z } from "zod";
|
|
11
11
|
export declare const groupCreateInput: z.ZodObject<{
|
|
@@ -57,3 +57,15 @@ export declare const groupInspectInput: z.ZodObject<{
|
|
|
57
57
|
}, {
|
|
58
58
|
group: string;
|
|
59
59
|
}>;
|
|
60
|
+
export declare const groupJoinInput: z.ZodObject<{
|
|
61
|
+
group: z.ZodString;
|
|
62
|
+
message: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, "strip", z.ZodTypeAny, {
|
|
64
|
+
group: string;
|
|
65
|
+
message?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
group: string;
|
|
68
|
+
message?: string | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
/** `rine_group_invites` takes no input — it lists the caller's own pending invites. */
|
|
71
|
+
export declare const groupInvitesInput: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod input schemas for the two x402 payment tools (`rine_pay`, `rine_fulfill`).
|
|
3
|
+
*
|
|
4
|
+
* One file per domain (mirrors `schemas-groups.ts`) to keep `schemas.ts` within
|
|
5
|
+
* the ~200-LOC budget; re-exported from `schemas.ts` so the schema entry point
|
|
6
|
+
* stays single. Authored with the HOST `zod` (`import { z } from "zod"`) — the
|
|
7
|
+
* one hoisted instance Mastra validates against. Identity/credentials NEVER
|
|
8
|
+
* appear here (I-2): the acting agent + config dir come from `ctx.requestContext`.
|
|
9
|
+
*
|
|
10
|
+
* The wallet key, spend policy, caps, and facilitator auth are NEVER model
|
|
11
|
+
* inputs — they live on disk / in the toolkit config. A tool input can name a
|
|
12
|
+
* facilitator PRESET or base URL, but never carries key material or provider auth.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
export declare const payInput: z.ZodObject<{
|
|
16
|
+
messageId: z.ZodString;
|
|
17
|
+
autoPay: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
emitMarker: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
allowRepay: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
messageId: string;
|
|
22
|
+
autoPay?: boolean | undefined;
|
|
23
|
+
emitMarker?: boolean | undefined;
|
|
24
|
+
allowRepay?: boolean | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
messageId: string;
|
|
27
|
+
autoPay?: boolean | undefined;
|
|
28
|
+
emitMarker?: boolean | undefined;
|
|
29
|
+
allowRepay?: boolean | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const fulfillInput: z.ZodObject<{
|
|
32
|
+
messageId: z.ZodString;
|
|
33
|
+
facilitator: z.ZodOptional<z.ZodString>;
|
|
34
|
+
emitMarker: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
}, "strip", z.ZodTypeAny, {
|
|
36
|
+
messageId: string;
|
|
37
|
+
emitMarker?: boolean | undefined;
|
|
38
|
+
facilitator?: string | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
messageId: string;
|
|
41
|
+
emitMarker?: boolean | undefined;
|
|
42
|
+
facilitator?: string | undefined;
|
|
43
|
+
}>;
|
package/dist/schemas.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* `messageType`/`idempotencyKey`/etc. ports drop the Python `tag`/`jurisdiction`/
|
|
12
12
|
* `pricingModel` discover fields (the TS `DiscoveryFilters` lacks them) and add
|
|
13
|
-
* `enableMls` (default true) on group_create — the headline inversion
|
|
13
|
+
* `enableMls` (default true) on group_create — the headline inversion.
|
|
14
14
|
*/
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
export declare const threadInput: z.ZodObject<{
|
|
@@ -74,12 +74,12 @@ export declare const replyInput: z.ZodObject<{
|
|
|
74
74
|
body: z.ZodString;
|
|
75
75
|
messageType: z.ZodDefault<z.ZodString>;
|
|
76
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
messageId: string;
|
|
77
78
|
body: string;
|
|
78
79
|
messageType: string;
|
|
79
|
-
messageId: string;
|
|
80
80
|
}, {
|
|
81
|
-
body: string;
|
|
82
81
|
messageId: string;
|
|
82
|
+
body: string;
|
|
83
83
|
messageType?: string | undefined;
|
|
84
84
|
}>;
|
|
85
85
|
export declare const discoverInput: z.ZodObject<{
|
|
@@ -108,4 +108,5 @@ export declare const inspectInput: z.ZodObject<{
|
|
|
108
108
|
}, {
|
|
109
109
|
handleOrId: string;
|
|
110
110
|
}>;
|
|
111
|
-
export { groupCreateInput, groupInspectInput, groupInviteInput, groupRemoveInput, } from "./schemas-groups.js";
|
|
111
|
+
export { groupCreateInput, groupInspectInput, groupInviteInput, groupInvitesInput, groupJoinInput, groupRemoveInput, } from "./schemas-groups.js";
|
|
112
|
+
export { fulfillInput, payInput } from "./schemas-payments.js";
|
package/dist/tool.d.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* `createTool` from `@mastra/core/tools` is invoked by each domain module; this
|
|
16
16
|
* file only builds the `execute` closure and the shared option/ctx types.
|
|
17
17
|
*/
|
|
18
|
+
import type { FacilitatorConfig } from "@rine-network/core";
|
|
18
19
|
import type { AgentHandle, AgentUuid, AsyncRineClient, GroupHandle, GroupUuid } from "@rine-network/sdk";
|
|
19
20
|
import { type RineClientOpts } from "./client.js";
|
|
20
21
|
import { type RineToolContext } from "./context.js";
|
|
@@ -28,6 +29,30 @@ export interface RineToolOpts extends RineClientOpts {
|
|
|
28
29
|
/** A shared client to reuse (set by `rineToolkit` for AC-11). */
|
|
29
30
|
client?: AsyncRineClient;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Extra options the two x402 payment tools (`rine_pay`, `rine_fulfill`) accept
|
|
34
|
+
* on top of {@link RineToolOpts}, threaded from `rineToolkit({ payments })`.
|
|
35
|
+
* None carry key material: the wallet key and spend policy stay on disk, and a
|
|
36
|
+
* facilitator config carries only a URL (+ optional provider-auth headers the
|
|
37
|
+
* HOST supplies, never the model).
|
|
38
|
+
*/
|
|
39
|
+
export interface RinePaymentToolOpts extends RineToolOpts {
|
|
40
|
+
/**
|
|
41
|
+
* D2 auto-pay default (default OFF). When true, `rine_pay` defaults to paying
|
|
42
|
+
* ONLY quotes at/below the policy's `autoPayThreshold`; a per-call `autoPay`
|
|
43
|
+
* input still overrides it. Caps + deny-by-default + reserve-lock bound it
|
|
44
|
+
* regardless.
|
|
45
|
+
*/
|
|
46
|
+
autoPay?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The facilitator `rine_fulfill` verifies/settles through — a `FacilitatorConfig`
|
|
49
|
+
* (URL + optional auth headers) or a preset key / base-URL string. A per-call
|
|
50
|
+
* `facilitator` input overrides it.
|
|
51
|
+
*/
|
|
52
|
+
facilitator?: FacilitatorConfig | string;
|
|
53
|
+
/** Default for the payment/receipt cleartext marker (default ON). */
|
|
54
|
+
emitMarker?: boolean;
|
|
55
|
+
}
|
|
31
56
|
/**
|
|
32
57
|
* Resolve the effective `AsyncRineClient` for one `execute` call: prefer a
|
|
33
58
|
* shared client from the toolkit, else build one from the ctx-injected identity
|
|
@@ -53,7 +78,7 @@ type Recipient = AgentHandle | AgentUuid | GroupHandle | GroupUuid;
|
|
|
53
78
|
export declare function asRecipient(to: string): Recipient;
|
|
54
79
|
/**
|
|
55
80
|
* I-2 layer (c): the belt-and-suspenders ciphertext redactor for `read` /
|
|
56
|
-
* `check_inbox
|
|
81
|
+
* `check_inbox`. Layers (a) plaintext-only renderers and
|
|
57
82
|
* (b) `outputSchema: z.string()` already guarantee the `execute` return is a
|
|
58
83
|
* redacted string; this coerces ANY value to plain text content before it can
|
|
59
84
|
* reach the model, so even a regression that returned a richer object containing
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `rineToolkit(opts)` — the aggregator
|
|
2
|
+
* `rineToolkit(opts)` — the aggregator. Returns a plain keyed
|
|
3
3
|
* `Record<string, Tool>` (Mastra has no `BaseToolkit` class). The object KEY is
|
|
4
4
|
* the model-facing tool name, so each entry is keyed by its `id`
|
|
5
5
|
* (`toolName === id`). Drop the record straight into a Mastra `Agent`'s
|
|
6
6
|
* `tools: {}` map.
|
|
7
7
|
*
|
|
8
|
-
* `include` curates the surface: `"all"` (
|
|
9
|
-
* (`"messaging"`/`"discovery"`/`"groups"`), or an array union of
|
|
8
|
+
* `include` curates the surface: `"all"` (16), one domain
|
|
9
|
+
* (`"messaging"`/`"discovery"`/`"groups"`/`"payments"`), or an array union of
|
|
10
|
+
* domains. The `"payments"` domain (`rine_pay`, `rine_fulfill`) moves funds —
|
|
11
|
+
* bounded by the on-disk spend policy (deny-by-default) and D2 auto-pay OFF.
|
|
10
12
|
*
|
|
11
13
|
* AC-11 shared client: ONE lazily-built `AsyncRineClient` is created per
|
|
12
14
|
* `rineToolkit(...)` call and threaded into every tool's `opts.client`, so all
|
|
@@ -17,8 +19,22 @@
|
|
|
17
19
|
* "attach only what you need" ergonomic.
|
|
18
20
|
*/
|
|
19
21
|
import type { Tool } from "@mastra/core/tools";
|
|
22
|
+
import type { RinePaymentToolOpts } from "./tool.js";
|
|
20
23
|
/** The domains a toolkit can be filtered to. */
|
|
21
|
-
export type RineToolDomain = "messaging" | "discovery" | "groups";
|
|
24
|
+
export type RineToolDomain = "messaging" | "discovery" | "groups" | "payments";
|
|
25
|
+
/**
|
|
26
|
+
* Payment configuration for the `"payments"` domain tools (`rine_pay`,
|
|
27
|
+
* `rine_fulfill`). All optional; the tools work with sensible defaults (auto-pay
|
|
28
|
+
* OFF, marker ON) and a facilitator is only needed to `rine_fulfill`.
|
|
29
|
+
*/
|
|
30
|
+
export interface RinePaymentsConfig {
|
|
31
|
+
/** D2 auto-pay default (default OFF). See {@link RinePaymentToolOpts.autoPay}. */
|
|
32
|
+
autoPay?: RinePaymentToolOpts["autoPay"];
|
|
33
|
+
/** Facilitator for `rine_fulfill`. See {@link RinePaymentToolOpts.facilitator}. */
|
|
34
|
+
facilitator?: RinePaymentToolOpts["facilitator"];
|
|
35
|
+
/** Default for the cleartext marker (default ON). */
|
|
36
|
+
emitMarker?: RinePaymentToolOpts["emitMarker"];
|
|
37
|
+
}
|
|
22
38
|
/** Options for {@link rineToolkit}. */
|
|
23
39
|
export interface RineToolkitOptions {
|
|
24
40
|
/** Explicit config dir; when omitted, `resolveConfigDir()` is used. */
|
|
@@ -29,6 +45,8 @@ export interface RineToolkitOptions {
|
|
|
29
45
|
agent?: string;
|
|
30
46
|
/** Which tools to include. Default `"all"`. */
|
|
31
47
|
include?: "all" | RineToolDomain | readonly RineToolDomain[];
|
|
48
|
+
/** Config for the `"payments"` domain tools (auto-pay OFF by default). */
|
|
49
|
+
payments?: RinePaymentsConfig;
|
|
32
50
|
}
|
|
33
51
|
/**
|
|
34
52
|
* Build the rine tool record. The returned object is keyed by each tool's `id`
|
package/dist/types.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* type-only re-derivations; runtime tool schemas are authored with the host
|
|
9
9
|
* `zod` in `schemas.ts`.
|
|
10
10
|
*/
|
|
11
|
-
import type { AgentProfileSchema, AgentSummarySchema, DecryptedMessageSchema, GroupReadSchema, InviteResultSchema, MessageReadSchema } from "@rine-network/sdk";
|
|
11
|
+
import type { AgentProfileSchema, AgentSummarySchema, DecryptedMessageSchema, GroupReadSchema, InviteResultSchema, JoinRequestReadSchema, MessageReadSchema } from "@rine-network/sdk";
|
|
12
12
|
/** Project a Zod schema's output type without importing the SDK's `z` instance. */
|
|
13
13
|
type Infer<S> = S extends {
|
|
14
14
|
_output: infer O;
|
|
@@ -19,4 +19,5 @@ export type GroupRead = Infer<typeof GroupReadSchema>;
|
|
|
19
19
|
export type InviteResult = Infer<typeof InviteResultSchema>;
|
|
20
20
|
export type AgentSummary = Infer<typeof AgentSummarySchema>;
|
|
21
21
|
export type AgentProfile = Infer<typeof AgentProfileSchema>;
|
|
22
|
+
export type JoinRequestRead = Infer<typeof JoinRequestReadSchema>;
|
|
22
23
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-network/mastra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Native Mastra.ai tools for the rine network \u2014 E2E-encrypted (HPKE 1:1, MLS groups, PQ-hybrid) agent-to-agent messaging, discovery, and coordination as createTool tools, a toolkit aggregator, a lifecycle bridge, a Tier-3 workflow-resume bridge, and a setup CLI.",
|
|
5
5
|
"author": "mmmbs <mmmbs@proton.me>",
|
|
6
6
|
"license": "EUPL-1.2",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@libsql/client": "^0.15.0",
|
|
45
|
-
"@rine-network/core": "^0.
|
|
46
|
-
"@rine-network/sdk": "^0.
|
|
45
|
+
"@rine-network/core": "^0.12.0",
|
|
46
|
+
"@rine-network/sdk": "^0.9.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@mastra/core": ">=1.0.0 <2.0.0",
|