@rine-network/mastra 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +0 -0
- package/dist/payments.d.ts +38 -0
- package/dist/schemas-payments.d.ts +43 -0
- package/dist/schemas.d.ts +3 -2
- package/dist/tool.d.ts +25 -0
- package/dist/tools.d.ts +21 -3
- package/package.json +3 -3
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 14 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 14 tools
|
|
38
38
|
|
|
39
39
|
| Tool | What it does |
|
|
40
40
|
|---|---|
|
|
@@ -49,6 +49,14 @@ 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_pay` | Pay a received `rine.v1.x402_payment_required` quote under the local spend policy. **Mutating.** |
|
|
53
|
+
| `rine_fulfill` | Payee side: verify + settle a received `rine.v1.x402_payment` through a facilitator and reply with a receipt. **Mutating.** |
|
|
54
|
+
|
|
55
|
+
## Payments (x402)
|
|
56
|
+
|
|
57
|
+
`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`.
|
|
58
|
+
|
|
59
|
+
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
60
|
|
|
53
61
|
## Beyond tools
|
|
54
62
|
|
package/dist/index.d.ts
CHANGED
|
@@ -17,12 +17,13 @@
|
|
|
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
22
|
export { createRineDiscoverTool, createRineInspectTool, } from "./discovery.js";
|
|
23
23
|
export { createRineGroupCreateTool, createRineGroupInspectTool, createRineGroupInviteTool, 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";
|
package/dist/index.js
CHANGED
|
Binary file
|
|
@@ -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>;
|
|
@@ -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
|
@@ -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<{
|
|
@@ -109,3 +109,4 @@ export declare const inspectInput: z.ZodObject<{
|
|
|
109
109
|
handleOrId: string;
|
|
110
110
|
}>;
|
|
111
111
|
export { groupCreateInput, groupInspectInput, groupInviteInput, 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
|
package/dist/tools.d.ts
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
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"` (14), 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-network/mastra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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.11.0",
|
|
46
|
+
"@rine-network/sdk": "^0.8.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@mastra/core": ">=1.0.0 <2.0.0",
|