@rine-network/mastra 0.4.0 → 0.6.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/AGENTS.md +12 -11
- package/MASTRA.md +85 -58
- package/README.md +20 -11
- package/dist/client.d.ts +6 -4
- package/dist/context.d.ts +3 -2
- package/dist/discovery.d.ts +8 -2
- package/dist/drivers.d.ts +4 -3
- package/dist/errors.d.ts +12 -5
- package/dist/format-groups-list.d.ts +143 -0
- package/dist/format-groups.d.ts +81 -0
- package/dist/format.d.ts +51 -15
- package/dist/groups-admin.d.ts +25 -0
- package/dist/groups-admission.d.ts +56 -0
- package/dist/groups-list.d.ts +21 -0
- package/dist/groups-resolve.d.ts +81 -0
- package/dist/groups.d.ts +19 -13
- package/dist/inbound.d.ts +11 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +0 -0
- package/dist/lifecycle.d.ts +9 -7
- package/dist/messaging.d.ts +14 -12
- package/dist/onboard.d.ts +1 -1
- package/dist/onboard.js +3 -3
- package/dist/payments.d.ts +2 -2
- package/dist/schemas-discovery.d.ts +46 -0
- package/dist/schemas-groups-list.d.ts +29 -0
- package/dist/schemas-groups.d.ts +86 -12
- package/dist/schemas-payments.d.ts +2 -1
- package/dist/schemas.d.ts +27 -33
- package/dist/threadmap.d.ts +2 -2
- package/dist/tool.d.ts +15 -12
- package/dist/tools.d.ts +5 -4
- package/dist/types.d.ts +2 -1
- package/package.json +3 -3
package/dist/lifecycle.d.ts
CHANGED
|
@@ -14,21 +14,22 @@
|
|
|
14
14
|
* step → onStepFinish ({toolCalls,…}) → "step: {toolName}"
|
|
15
15
|
*
|
|
16
16
|
* Invariants:
|
|
17
|
-
* -
|
|
18
|
-
* FIRST fired callback (never at module load or in this factory body)
|
|
19
|
-
*
|
|
17
|
+
* - Opt-in by instantiation; the `AsyncRineClient` is built lazily on the
|
|
18
|
+
* FIRST fired callback (never at module load or in this factory body), so
|
|
19
|
+
* importing the package stays side-effect-free.
|
|
20
|
+
* - Only the model-visible `text` / tool name / error message is summarized
|
|
20
21
|
* into the notify body — never ciphertext (these callbacks never see an
|
|
21
22
|
* envelope).
|
|
22
|
-
* - Best-effort: each fired callback attempts EXACTLY ONE `client.send
|
|
23
|
+
* - Best-effort: each fired callback attempts EXACTLY ONE `client.send`;
|
|
23
24
|
* a send failure is swallowed + debug-logged and never thrown out of the
|
|
24
|
-
* callback
|
|
25
|
+
* callback — a notify failure must not crash the agent run.
|
|
25
26
|
*/
|
|
26
27
|
import { type RineClientOpts } from "./client.js";
|
|
27
28
|
/** The lifecycle selectors a caller can opt into. */
|
|
28
29
|
export type RineLifecycleEvent = "finish" | "error" | "step";
|
|
29
30
|
/** Options for {@link rineLifecycle}. */
|
|
30
31
|
export interface RineLifecycleOptions extends RineClientOpts {
|
|
31
|
-
/** Recipient handle/UUID every notify is sent to (`name@org`, `#
|
|
32
|
+
/** Recipient handle/UUID every notify is sent to (`name@org`, `#logistics@acme.rine.network`). */
|
|
32
33
|
to: string;
|
|
33
34
|
/** Which lifecycle events fire a notify. Defaults to `["finish", "error"]`. */
|
|
34
35
|
on?: readonly RineLifecycleEvent[];
|
|
@@ -42,6 +43,7 @@ export interface RineLifecycleCallbacks {
|
|
|
42
43
|
/**
|
|
43
44
|
* Build the opt-in outbound lifecycle bridge. Returns ONLY the callbacks for the
|
|
44
45
|
* selected events (so `{ ...cb }` never installs a no-op for an unselected one).
|
|
45
|
-
* The client is resolved lazily on the first fired callback
|
|
46
|
+
* The client is resolved lazily on the first fired callback — this factory
|
|
47
|
+
* builds nothing.
|
|
46
48
|
*/
|
|
47
49
|
export declare function rineLifecycle(opts: RineLifecycleOptions): RineLifecycleCallbacks;
|
package/dist/messaging.d.ts
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
* `rine_read`, `rine_reply`. Each is a thin
|
|
2
|
+
* The 6 messaging tools: `rine_send`, `rine_send_and_wait`, `rine_inbox`,
|
|
3
|
+
* `rine_read`, `rine_thread`, `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`.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
* (`format.ts`), never the ciphertext
|
|
10
|
-
*
|
|
8
|
+
* Ciphertext never reaches the model through any of them: renderers read only
|
|
9
|
+
* plaintext/decrypt_error/verification (`format.ts`), never the ciphertext
|
|
10
|
+
* envelope. `rine_inbox` on its default
|
|
11
|
+
* `new` status is the Track-0 poll+ack receive primitive (Tier-1).
|
|
11
12
|
*/
|
|
12
13
|
import { type RineToolOpts } from "./tool.js";
|
|
13
|
-
/** `rine_send` — send a 1:1 or
|
|
14
|
+
/** `rine_send` — send a 1:1 or group message (the SDK auto-routes groups). */
|
|
14
15
|
export declare function createRineSendTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_send", unknown>;
|
|
15
16
|
/** `rine_send_and_wait` — 1:1 send that blocks for a reply (Tier-2, ms timeout). */
|
|
16
17
|
export declare function createRineSendAndWaitTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_send_and_wait", unknown>;
|
|
17
18
|
/**
|
|
18
|
-
* `
|
|
19
|
-
* best-effort `markDelivered` the decryptable
|
|
20
|
-
* newer mail (Track-0 poll+ack, Tier-1). On
|
|
21
|
-
* messages "may reappear" but still return the
|
|
19
|
+
* `rine_inbox` — poll the inbox under one status filter, decrypt what it
|
|
20
|
+
* returns, and on the `new` path best-effort `markDelivered` the decryptable
|
|
21
|
+
* ids so a later check returns only newer mail (Track-0 poll+ack, Tier-1). On
|
|
22
|
+
* ack failure: warn + note the messages "may reappear" but still return the
|
|
23
|
+
* reads.
|
|
22
24
|
*/
|
|
23
|
-
export declare function
|
|
25
|
+
export declare function createRineInboxTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_inbox", unknown>;
|
|
24
26
|
/** `rine_read` — fetch + decrypt one message by id. */
|
|
25
27
|
export declare function createRineReadTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_read", unknown>;
|
|
26
|
-
/** `rine_thread` — fetch the both-sided, decrypted transcript of a conversation. */
|
|
28
|
+
/** `rine_thread` — fetch the both-sided, decrypted transcript of a conversation or a group. */
|
|
27
29
|
export declare function createRineThreadTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_thread", unknown>;
|
|
28
30
|
/** `rine_reply` — reply to a message, threading into the same conversation. */
|
|
29
31
|
export declare function createRineReplyTool(opts?: RineToolOpts): import("@mastra/core/tools").Tool<any, any, any, any, import("@mastra/core/tools").ToolExecutionContext<any, any, unknown>, "rine_reply", unknown>;
|
package/dist/onboard.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* NEVER a `createTool` — a ~30–60 s PoW does not belong in an LLM turn; it is an
|
|
7
7
|
* out-of-band CLI a human runs once.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* No client is built at module load — `runOnboard` constructs the client
|
|
10
10
|
* lazily, only when invoked. The PoW + credential write are delegated wholesale
|
|
11
11
|
* to the SDK's `register(opts)` (over rine-core `performRegistration`); the agent
|
|
12
12
|
* keypair is generated + persisted by `client.createAgent(name)`.
|
package/dist/onboard.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveApiUrl, resolveConfigDir } from "@rine-network/core";
|
|
1
|
+
import { compareVerificationWordsForAgent, resolveApiUrl, resolveConfigDir, verificationWordsLines } from "@rine-network/core";
|
|
2
2
|
import { AsyncRineClient, register } from "@rine-network/sdk";
|
|
3
3
|
//#region src/onboard.ts
|
|
4
4
|
/**
|
|
@@ -9,7 +9,7 @@ import { AsyncRineClient, register } from "@rine-network/sdk";
|
|
|
9
9
|
* NEVER a `createTool` — a ~30–60 s PoW does not belong in an LLM turn; it is an
|
|
10
10
|
* out-of-band CLI a human runs once.
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* No client is built at module load — `runOnboard` constructs the client
|
|
13
13
|
* lazily, only when invoked. The PoW + credential write are delegated wholesale
|
|
14
14
|
* to the SDK's `register(opts)` (over rine-core `performRegistration`); the agent
|
|
15
15
|
* keypair is generated + persisted by `client.createAgent(name)`.
|
|
@@ -62,7 +62,7 @@ async function runOnboard(opts, io = stdoutIO) {
|
|
|
62
62
|
const agent = await client.createAgent(agentName);
|
|
63
63
|
io.log("");
|
|
64
64
|
io.log(`Agent ready: ${agent.handle}`);
|
|
65
|
-
|
|
65
|
+
for (const line of verificationWordsLines(compareVerificationWordsForAgent(configDir, agent.id, agent.verification_words))) io.log(line);
|
|
66
66
|
io.log(`Config dir: ${configDir}`);
|
|
67
67
|
io.log("Set RINE_CONFIG_DIR to this path (or RINE_CLIENT_ID/RINE_CLIENT_SECRET) so your Mastra tools authenticate.");
|
|
68
68
|
return agent.handle;
|
package/dist/payments.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The 2 x402 payment tools: `rine_pay` (payer) and `rine_fulfill` (payee). Each
|
|
3
3
|
* is a thin `createTool` adapter over the ts-sdk `client.payments` facade — the
|
|
4
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
|
|
5
|
+
* signing / policy / journal / facilitator logic is reimplemented here.
|
|
6
6
|
*
|
|
7
7
|
* `rine_pay` consumes a received `rine.v1.x402_payment_required` and returns the
|
|
8
8
|
* `rine_pay` 7-status vocabulary VERBATIM (parity with MCP `rine_pay` and the
|
|
@@ -23,7 +23,7 @@ import { type RinePaymentToolOpts } from "./tool.js";
|
|
|
23
23
|
/**
|
|
24
24
|
* `rine_pay` — pay a received x402 quote in-thread (payer). Mode T: an explicit
|
|
25
25
|
* tool call is the authorization, hard-bounded by the spend caps. The toolkit's
|
|
26
|
-
* `payments.autoPay` config (
|
|
26
|
+
* `payments.autoPay` config (default OFF) sets the default of the `autoPay`
|
|
27
27
|
* input; when on, only quotes at/below the policy's `autoPayThreshold` are paid.
|
|
28
28
|
*/
|
|
29
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>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod input schemas for the three discovery tools (`rine_discover`,
|
|
3
|
+
* `rine_inspect`, `rine_whoami`).
|
|
4
|
+
*
|
|
5
|
+
* One file per domain (mirrors `schemas-groups.ts` and `schemas-payments.ts`)
|
|
6
|
+
* to keep `schemas.ts` within the ~200-LOC budget; re-exported from
|
|
7
|
+
* `schemas.ts` so the schema entry point stays single. Authored with the HOST
|
|
8
|
+
* `zod` (`import { z } from "zod"`) — the one hoisted instance Mastra
|
|
9
|
+
* validates against. Identity/credentials NEVER appear here — an input schema
|
|
10
|
+
* is model-visible and model-controllable, so the acting agent + config dir
|
|
11
|
+
* come from `ctx.requestContext` instead.
|
|
12
|
+
*
|
|
13
|
+
* `rine_discover` and `rine_discover_groups` are unauthenticated reads of the
|
|
14
|
+
* public directory; `rine_inspect` and `rine_whoami` are not, and the split is
|
|
15
|
+
* by tool DOMAIN, not by auth. The group-directory schema lives beside the
|
|
16
|
+
* other group reads in `schemas-groups-list.ts`.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from "zod";
|
|
19
|
+
export declare const discoverInput: z.ZodObject<{
|
|
20
|
+
q: z.ZodOptional<z.ZodString>;
|
|
21
|
+
category: z.ZodOptional<z.ZodString>;
|
|
22
|
+
language: z.ZodOptional<z.ZodString>;
|
|
23
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
limit: number;
|
|
27
|
+
verified?: boolean | undefined;
|
|
28
|
+
q?: string | undefined;
|
|
29
|
+
category?: string | undefined;
|
|
30
|
+
language?: string | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
verified?: boolean | undefined;
|
|
33
|
+
q?: string | undefined;
|
|
34
|
+
category?: string | undefined;
|
|
35
|
+
language?: string | undefined;
|
|
36
|
+
limit?: number | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const inspectInput: z.ZodObject<{
|
|
39
|
+
handleOrId: z.ZodString;
|
|
40
|
+
}, "strip", z.ZodTypeAny, {
|
|
41
|
+
handleOrId: string;
|
|
42
|
+
}, {
|
|
43
|
+
handleOrId: string;
|
|
44
|
+
}>;
|
|
45
|
+
/** No input: reports this agent's OWN org, trust tier, and live handles. */
|
|
46
|
+
export declare const whoamiInput: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod input schemas for the three group READ tools (`groups-list.ts`):
|
|
3
|
+
* `rine_groups`, `rine_discover_groups`, `rine_group_roster`.
|
|
4
|
+
*
|
|
5
|
+
* Their own module because `schemas-groups.ts` already carries the ten write
|
|
6
|
+
* and admission verbs at its ~200-LOC budget. Same authoring rules as the rest:
|
|
7
|
+
* the HOST `zod`, rich `.describe()` on every field, and NO identity or
|
|
8
|
+
* credentials in a model-visible schema (both come from `ctx.requestContext`).
|
|
9
|
+
*/
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
/** No input: lists the groups this agent's ORG belongs to, never one agent's own. */
|
|
12
|
+
export declare const groupsInput: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
13
|
+
export declare const discoverGroupsInput: z.ZodObject<{
|
|
14
|
+
q: z.ZodOptional<z.ZodString>;
|
|
15
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
limit: number;
|
|
18
|
+
q?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
q?: string | undefined;
|
|
21
|
+
limit?: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const groupRosterInput: z.ZodObject<{
|
|
24
|
+
group: z.ZodString;
|
|
25
|
+
}, "strip", z.ZodTypeAny, {
|
|
26
|
+
group: string;
|
|
27
|
+
}, {
|
|
28
|
+
group: string;
|
|
29
|
+
}>;
|
package/dist/schemas-groups.d.ts
CHANGED
|
@@ -1,44 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Zod input schemas for the
|
|
3
|
-
* ~200-LOC budget — one file per
|
|
4
|
-
*
|
|
5
|
-
* NO identity/credentials in the
|
|
2
|
+
* Zod input schemas for the 11 group WRITE and admission tools (split out of
|
|
3
|
+
* `schemas.ts` to hold the ~200-LOC budget — one file per domain; the three
|
|
4
|
+
* group READ schemas are in `schemas-groups-list.ts`). Same authoring rules:
|
|
5
|
+
* HOST `zod`, rich `.describe()` on every field, NO identity/credentials in the
|
|
6
|
+
* schema (host-injected via `ctx.requestContext`).
|
|
6
7
|
*
|
|
7
|
-
* Groups are MLS-capable by default — `enableMls` (default true) on create
|
|
8
|
-
*
|
|
8
|
+
* Groups are MLS-capable by default — `enableMls` (default true) on create.
|
|
9
|
+
*
|
|
10
|
+
* `visibility` carries no default and never will. Every surface used to invent
|
|
11
|
+
* one and they disagreed, so the same call produced a group listed at
|
|
12
|
+
* dir.rine.network from here and an unlisted one from the CLI — and the listing
|
|
13
|
+
* also flips the member-joined signal, so the two differed in who gets told
|
|
14
|
+
* about a join as well as in who can find the group. The description states
|
|
15
|
+
* both choices and that coupling, so a model picks at the point of choice
|
|
16
|
+
* rather than after being refused.
|
|
17
|
+
*
|
|
18
|
+
* Admission is plural: `members` on create and `agentsToInvite` on invite each
|
|
19
|
+
* take a batch and report one outcome per requested agent.
|
|
9
20
|
*/
|
|
10
21
|
import { z } from "zod";
|
|
22
|
+
/**
|
|
23
|
+
* The refusal when no visibility was named.
|
|
24
|
+
*
|
|
25
|
+
* It sits on the schema rather than in the handler because Mastra validates
|
|
26
|
+
* `inputSchema` before `execute` ever runs, so the handler could never speak
|
|
27
|
+
* here — and a bare zod "Required" would be the dump this obligation exists to
|
|
28
|
+
* replace. It names both choices and what each one does, so a model that reads
|
|
29
|
+
* it can pick without consulting docs.
|
|
30
|
+
*/
|
|
31
|
+
export declare const VISIBILITY_REQUIRED = "visibility is required and has no default. Choose \"public\" \u2014 the group is listed at dir.rine.network for anyone to find, and the member-joined signal is off \u2014 or \"private\" \u2014 it is not listed, and members are signalled when someone joins.";
|
|
11
32
|
export declare const groupCreateInput: z.ZodObject<{
|
|
12
33
|
name: z.ZodString;
|
|
13
34
|
enrollment: z.ZodDefault<z.ZodEnum<["open", "closed", "majority", "unanimity"]>>;
|
|
14
|
-
visibility: z.
|
|
35
|
+
visibility: z.ZodEnum<["public", "private"]>;
|
|
15
36
|
description: z.ZodOptional<z.ZodString>;
|
|
37
|
+
voteDurationHours: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
members: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
16
39
|
enableMls: z.ZodDefault<z.ZodBoolean>;
|
|
17
40
|
}, "strip", z.ZodTypeAny, {
|
|
18
41
|
name: string;
|
|
19
|
-
enrollment: "open" | "closed" | "majority" | "unanimity";
|
|
20
42
|
visibility: "public" | "private";
|
|
43
|
+
enrollment: "open" | "closed" | "majority" | "unanimity";
|
|
21
44
|
enableMls: boolean;
|
|
22
45
|
description?: string | undefined;
|
|
46
|
+
voteDurationHours?: number | undefined;
|
|
47
|
+
members?: string[] | undefined;
|
|
23
48
|
}, {
|
|
24
49
|
name: string;
|
|
50
|
+
visibility: "public" | "private";
|
|
25
51
|
enrollment?: "open" | "closed" | "majority" | "unanimity" | undefined;
|
|
26
|
-
visibility?: "public" | "private" | undefined;
|
|
27
52
|
description?: string | undefined;
|
|
53
|
+
voteDurationHours?: number | undefined;
|
|
54
|
+
members?: string[] | undefined;
|
|
28
55
|
enableMls?: boolean | undefined;
|
|
29
56
|
}>;
|
|
30
57
|
export declare const groupInviteInput: z.ZodObject<{
|
|
31
58
|
group: z.ZodString;
|
|
32
|
-
agentToInvite: z.ZodString
|
|
59
|
+
agentToInvite: z.ZodOptional<z.ZodString>;
|
|
60
|
+
agentsToInvite: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
33
61
|
message: z.ZodOptional<z.ZodString>;
|
|
34
62
|
}, "strip", z.ZodTypeAny, {
|
|
35
63
|
group: string;
|
|
36
|
-
agentToInvite: string;
|
|
37
64
|
message?: string | undefined;
|
|
65
|
+
agentToInvite?: string | undefined;
|
|
66
|
+
agentsToInvite?: string[] | undefined;
|
|
38
67
|
}, {
|
|
39
68
|
group: string;
|
|
40
|
-
agentToInvite: string;
|
|
41
69
|
message?: string | undefined;
|
|
70
|
+
agentToInvite?: string | undefined;
|
|
71
|
+
agentsToInvite?: string[] | undefined;
|
|
42
72
|
}>;
|
|
43
73
|
export declare const groupRemoveInput: z.ZodObject<{
|
|
44
74
|
group: z.ZodString;
|
|
@@ -69,3 +99,47 @@ export declare const groupJoinInput: z.ZodObject<{
|
|
|
69
99
|
}>;
|
|
70
100
|
/** `rine_group_invites` takes no input — it lists the caller's own pending invites. */
|
|
71
101
|
export declare const groupInvitesInput: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
102
|
+
export declare const groupRequestsInput: z.ZodObject<{
|
|
103
|
+
group: z.ZodString;
|
|
104
|
+
outstanding: z.ZodDefault<z.ZodEnum<["pending", "invited", "live"]>>;
|
|
105
|
+
}, "strip", z.ZodTypeAny, {
|
|
106
|
+
group: string;
|
|
107
|
+
outstanding: "pending" | "invited" | "live";
|
|
108
|
+
}, {
|
|
109
|
+
group: string;
|
|
110
|
+
outstanding?: "pending" | "invited" | "live" | undefined;
|
|
111
|
+
}>;
|
|
112
|
+
export declare const groupVoteInput: z.ZodObject<{
|
|
113
|
+
group: z.ZodString;
|
|
114
|
+
requestId: z.ZodString;
|
|
115
|
+
vote: z.ZodEnum<["approve", "deny"]>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
group: string;
|
|
118
|
+
requestId: string;
|
|
119
|
+
vote: "approve" | "deny";
|
|
120
|
+
}, {
|
|
121
|
+
group: string;
|
|
122
|
+
requestId: string;
|
|
123
|
+
vote: "approve" | "deny";
|
|
124
|
+
}>;
|
|
125
|
+
export declare const groupLeaveInput: z.ZodObject<{
|
|
126
|
+
group: z.ZodString;
|
|
127
|
+
}, "strip", z.ZodTypeAny, {
|
|
128
|
+
group: string;
|
|
129
|
+
}, {
|
|
130
|
+
group: string;
|
|
131
|
+
}>;
|
|
132
|
+
export declare const groupSyncInput: z.ZodObject<{
|
|
133
|
+
group: z.ZodString;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
group: string;
|
|
136
|
+
}, {
|
|
137
|
+
group: string;
|
|
138
|
+
}>;
|
|
139
|
+
export declare const groupReclaimInput: z.ZodObject<{
|
|
140
|
+
group: z.ZodString;
|
|
141
|
+
}, "strip", z.ZodTypeAny, {
|
|
142
|
+
group: string;
|
|
143
|
+
}, {
|
|
144
|
+
group: string;
|
|
145
|
+
}>;
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* the ~200-LOC budget; re-exported from `schemas.ts` so the schema entry point
|
|
6
6
|
* stays single. Authored with the HOST `zod` (`import { z } from "zod"`) — the
|
|
7
7
|
* one hoisted instance Mastra validates against. Identity/credentials NEVER
|
|
8
|
-
* appear here
|
|
8
|
+
* appear here — an input schema is model-visible and model-controllable, so the
|
|
9
|
+
* acting agent + config dir come from `ctx.requestContext` instead.
|
|
9
10
|
*
|
|
10
11
|
* The wallet key, spend policy, caps, and facilitator auth are NEVER model
|
|
11
12
|
* inputs — they live on disk / in the toolkit config. A tool input can name a
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,27 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shared Zod input schemas for the
|
|
2
|
+
* Shared Zod input schemas for the 25 rine tools.
|
|
3
3
|
*
|
|
4
4
|
* Authored with the HOST `zod` (`import { z } from "zod"`) — the single hoisted
|
|
5
5
|
* instance Mastra validates against — NOT the SDK's re-exported `z`. Rich
|
|
6
6
|
* `.describe()` on EVERY field: the field descriptions are the #1 lever on
|
|
7
7
|
* tool-call accuracy (the AI-DX). Identity/credentials NEVER appear here — the
|
|
8
8
|
* acting agent + config dir are read from `ctx.requestContext`, never the model-
|
|
9
|
-
* visible input schema (
|
|
9
|
+
* visible input schema, which the model both sees and controls (also Mastra's
|
|
10
|
+
* own security rule).
|
|
10
11
|
*
|
|
11
12
|
* `messageType`/`idempotencyKey`/etc. ports drop the Python `tag`/`jurisdiction`/
|
|
12
13
|
* `pricingModel` discover fields (the TS `DiscoveryFilters` lacks them) and add
|
|
13
14
|
* `enableMls` (default true) on group_create — the headline inversion.
|
|
14
15
|
*/
|
|
15
16
|
import { z } from "zod";
|
|
17
|
+
/**
|
|
18
|
+
* The exactly-one-of rule for `rine_thread`'s two references, in the words the
|
|
19
|
+
* refusal will use if it is broken.
|
|
20
|
+
*
|
|
21
|
+
* One string teaches the schema and answers the mistake, so the model can never
|
|
22
|
+
* be told a rule the product does not enforce. Its spellings come from
|
|
23
|
+
* `rine-core` — these tools name the two references exactly as the TypeScript
|
|
24
|
+
* SDK does (`group` / `conversationId`), which is what `THREAD_REF_SURFACES.sdk`
|
|
25
|
+
* holds.
|
|
26
|
+
*/
|
|
27
|
+
export declare const THREAD_REF_RULE: string;
|
|
16
28
|
export declare const threadInput: z.ZodObject<{
|
|
17
|
-
|
|
29
|
+
group: z.ZodOptional<z.ZodString>;
|
|
30
|
+
conversationId: z.ZodOptional<z.ZodString>;
|
|
18
31
|
limit: z.ZodOptional<z.ZodNumber>;
|
|
19
32
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
conversationId: string;
|
|
21
33
|
limit?: number | undefined;
|
|
34
|
+
group?: string | undefined;
|
|
35
|
+
conversationId?: string | undefined;
|
|
22
36
|
}, {
|
|
23
|
-
conversationId: string;
|
|
24
37
|
limit?: number | undefined;
|
|
38
|
+
group?: string | undefined;
|
|
39
|
+
conversationId?: string | undefined;
|
|
25
40
|
}>;
|
|
26
41
|
export declare const sendInput: z.ZodObject<{
|
|
27
42
|
to: z.ZodString;
|
|
@@ -55,11 +70,14 @@ export declare const sendAndWaitInput: z.ZodObject<{
|
|
|
55
70
|
messageType?: string | undefined;
|
|
56
71
|
waitSeconds?: number | undefined;
|
|
57
72
|
}>;
|
|
58
|
-
export declare const
|
|
73
|
+
export declare const inboxInput: z.ZodObject<{
|
|
74
|
+
status: z.ZodDefault<z.ZodEnum<["new", "delivered", "read", "all"]>>;
|
|
59
75
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
60
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
status: "delivered" | "new" | "read" | "all";
|
|
61
78
|
limit: number;
|
|
62
79
|
}, {
|
|
80
|
+
status?: "delivered" | "new" | "read" | "all" | undefined;
|
|
63
81
|
limit?: number | undefined;
|
|
64
82
|
}>;
|
|
65
83
|
export declare const readInput: z.ZodObject<{
|
|
@@ -82,31 +100,7 @@ export declare const replyInput: z.ZodObject<{
|
|
|
82
100
|
body: string;
|
|
83
101
|
messageType?: string | undefined;
|
|
84
102
|
}>;
|
|
85
|
-
export
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
language: z.ZodOptional<z.ZodString>;
|
|
89
|
-
verified: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
-
limit: z.ZodDefault<z.ZodNumber>;
|
|
91
|
-
}, "strip", z.ZodTypeAny, {
|
|
92
|
-
limit: number;
|
|
93
|
-
verified?: boolean | undefined;
|
|
94
|
-
q?: string | undefined;
|
|
95
|
-
category?: string | undefined;
|
|
96
|
-
language?: string | undefined;
|
|
97
|
-
}, {
|
|
98
|
-
verified?: boolean | undefined;
|
|
99
|
-
limit?: number | undefined;
|
|
100
|
-
q?: string | undefined;
|
|
101
|
-
category?: string | undefined;
|
|
102
|
-
language?: string | undefined;
|
|
103
|
-
}>;
|
|
104
|
-
export declare const inspectInput: z.ZodObject<{
|
|
105
|
-
handleOrId: z.ZodString;
|
|
106
|
-
}, "strip", z.ZodTypeAny, {
|
|
107
|
-
handleOrId: string;
|
|
108
|
-
}, {
|
|
109
|
-
handleOrId: string;
|
|
110
|
-
}>;
|
|
111
|
-
export { groupCreateInput, groupInspectInput, groupInviteInput, groupInvitesInput, groupJoinInput, groupRemoveInput, } from "./schemas-groups.js";
|
|
103
|
+
export { discoverInput, inspectInput, whoamiInput, } from "./schemas-discovery.js";
|
|
104
|
+
export { discoverGroupsInput, groupRosterInput, groupsInput, } from "./schemas-groups-list.js";
|
|
105
|
+
export { groupCreateInput, groupInspectInput, groupInviteInput, groupInvitesInput, groupJoinInput, groupLeaveInput, groupReclaimInput, groupRemoveInput, groupRequestsInput, groupSyncInput, groupVoteInput, } from "./schemas-groups.js";
|
|
112
106
|
export { fulfillInput, payInput } from "./schemas-payments.js";
|
package/dist/threadmap.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tier-3 thread map
|
|
2
|
+
* Tier-3 thread map: a durable `(handle, conversation_id) →
|
|
3
3
|
* runId` map. This is OUR responsibility — the LangGraph `thread_id` analog —
|
|
4
4
|
* and is SEPARATE from Mastra's own workflow-snapshot storage (`@mastra/libsql`/
|
|
5
5
|
* `@mastra/pg`). The snapshot is Mastra's; this map tells the resumer WHICH
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* - {@link SqliteThreadMap} — the documented production default; libsql-backed
|
|
11
11
|
* (file URL for durability across restarts, `:memory:` for a throwaway).
|
|
12
12
|
*
|
|
13
|
-
*
|
|
13
|
+
* Building a `SqliteThreadMap` opens a libsql handle, so do it where the
|
|
14
14
|
* driver/resumer is wired (a long-lived host start), never at module import.
|
|
15
15
|
*/
|
|
16
16
|
/**
|
package/dist/tool.d.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared `createTool` plumbing every rine tool reuses (no duplicated logic):
|
|
3
|
-
* identity injection (
|
|
4
|
-
* try/catch → `formatError` wrapper
|
|
3
|
+
* identity injection (a lazily built client, and no credentials in any
|
|
4
|
+
* model-visible schema) and the try/catch → `formatError` wrapper that turns
|
|
5
|
+
* every error into a readable string instead of a rejected promise.
|
|
5
6
|
*
|
|
6
7
|
* A tool's per-tool body is just `(client, inputData) => string`; this helper
|
|
7
8
|
* supplies the surrounding contract:
|
|
8
9
|
* 1. read the acting agent + config-dir/api-url overrides from
|
|
9
10
|
* `ctx.requestContext` (NEVER `inputSchema`), falling back to the
|
|
10
11
|
* `rineToolkit(opts)` overrides closed over at factory time,
|
|
11
|
-
* 2. lazily build/get the shared `AsyncRineClient` (
|
|
12
|
+
* 2. lazily build/get the shared `AsyncRineClient` (first call only, so that
|
|
13
|
+
* importing the package builds nothing),
|
|
12
14
|
* 3. run the body, and on any thrown SDK error return `formatError(err)` so
|
|
13
|
-
* the tool RESOLVES a readable string and never rejects
|
|
15
|
+
* the tool RESOLVES a readable string and never rejects.
|
|
14
16
|
*
|
|
15
17
|
* `createTool` from `@mastra/core/tools` is invoked by each domain module; this
|
|
16
18
|
* file only builds the `execute` closure and the shared option/ctx types.
|
|
@@ -22,11 +24,11 @@ import { type RineToolContext } from "./context.js";
|
|
|
22
24
|
/**
|
|
23
25
|
* Per-factory overrides threaded from `rineToolkit(opts)` / an individual
|
|
24
26
|
* `createRine<X>Tool(opts)` call. A live `client` may be passed so every tool in
|
|
25
|
-
* one `rineToolkit(...)` call shares ONE lazily-built client
|
|
27
|
+
* one `rineToolkit(...)` call shares ONE lazily-built client; when
|
|
26
28
|
* omitted, each tool resolves its own client lazily on first `execute`.
|
|
27
29
|
*/
|
|
28
30
|
export interface RineToolOpts extends RineClientOpts {
|
|
29
|
-
/** A shared client to reuse
|
|
31
|
+
/** A shared client to reuse, set by `rineToolkit` so all its tools share one. */
|
|
30
32
|
client?: AsyncRineClient;
|
|
31
33
|
}
|
|
32
34
|
/**
|
|
@@ -38,7 +40,7 @@ export interface RineToolOpts extends RineClientOpts {
|
|
|
38
40
|
*/
|
|
39
41
|
export interface RinePaymentToolOpts extends RineToolOpts {
|
|
40
42
|
/**
|
|
41
|
-
*
|
|
43
|
+
* Auto-pay default (default OFF). When true, `rine_pay` defaults to paying
|
|
42
44
|
* ONLY quotes at/below the policy's `autoPayThreshold`; a per-call `autoPay`
|
|
43
45
|
* input still overrides it. Caps + deny-by-default + reserve-lock bound it
|
|
44
46
|
* regardless.
|
|
@@ -57,7 +59,7 @@ export interface RinePaymentToolOpts extends RineToolOpts {
|
|
|
57
59
|
* Resolve the effective `AsyncRineClient` for one `execute` call: prefer a
|
|
58
60
|
* shared client from the toolkit, else build one from the ctx-injected identity
|
|
59
61
|
* layered over the factory defaults. Lazy by construction — only runs inside
|
|
60
|
-
* `execute
|
|
62
|
+
* `execute`, never at import or in a factory body.
|
|
61
63
|
*/
|
|
62
64
|
export declare function resolveClient(opts: RineToolOpts, ctx: RineToolContext | undefined): AsyncRineClient;
|
|
63
65
|
/**
|
|
@@ -69,7 +71,7 @@ export declare function resolveClient(opts: RineToolOpts, ctx: RineToolContext |
|
|
|
69
71
|
export declare function resolveApiUrlFor(opts: RineToolOpts, ctx: RineToolContext | undefined): string;
|
|
70
72
|
/**
|
|
71
73
|
* The recipient union `client.send`/`sendAndWait` accept. The model supplies a
|
|
72
|
-
* free-form `to` string (a `name@org` handle, a `#
|
|
74
|
+
* free-form `to` string (a `name@org` handle, a `#logistics@acme.rine.network` handle, or a UUID);
|
|
73
75
|
* the SDK normalizes + validates it at runtime, so this brands the string once,
|
|
74
76
|
* in one documented place, rather than scattering casts.
|
|
75
77
|
*/
|
|
@@ -77,9 +79,10 @@ type Recipient = AgentHandle | AgentUuid | GroupHandle | GroupUuid;
|
|
|
77
79
|
/** Brand a model-supplied recipient string for the SDK send surface. */
|
|
78
80
|
export declare function asRecipient(to: string): Recipient;
|
|
79
81
|
/**
|
|
80
|
-
*
|
|
81
|
-
* `
|
|
82
|
-
*
|
|
82
|
+
* The third and last defence against ciphertext reaching the model: a
|
|
83
|
+
* belt-and-suspenders redactor for `read` / `inbox` / `thread`. The first two —
|
|
84
|
+
* plaintext-only renderers, and `outputSchema: z.string()` so no structured
|
|
85
|
+
* field can carry an envelope — already guarantee the `execute` return is a
|
|
83
86
|
* redacted string; this coerces ANY value to plain text content before it can
|
|
84
87
|
* reach the model, so even a regression that returned a richer object containing
|
|
85
88
|
* ciphertext could not surface it. Returns Mastra's default text-content shape.
|
package/dist/tools.d.ts
CHANGED
|
@@ -5,12 +5,13 @@
|
|
|
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"` (
|
|
8
|
+
* `include` curates the surface: `"all"` (25), one domain
|
|
9
9
|
* (`"messaging"`/`"discovery"`/`"groups"`/`"payments"`), or an array union of
|
|
10
10
|
* domains. The `"payments"` domain (`rine_pay`, `rine_fulfill`) moves funds —
|
|
11
|
-
* bounded by the on-disk spend policy (deny-by-default) and
|
|
11
|
+
* bounded by the on-disk spend policy (deny-by-default) and by auto-pay, OFF
|
|
12
|
+
* unless the toolkit turns it on.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
+
* Shared client: ONE lazily-built `AsyncRineClient` is created per
|
|
14
15
|
* `rineToolkit(...)` call and threaded into every tool's `opts.client`, so all
|
|
15
16
|
* tools share a client (and the warm OAuth token cache). Per-acting-agent
|
|
16
17
|
* variants derive cheaply via `client.withAgent(...)` inside each `execute`.
|
|
@@ -28,7 +29,7 @@ export type RineToolDomain = "messaging" | "discovery" | "groups" | "payments";
|
|
|
28
29
|
* OFF, marker ON) and a facilitator is only needed to `rine_fulfill`.
|
|
29
30
|
*/
|
|
30
31
|
export interface RinePaymentsConfig {
|
|
31
|
-
/**
|
|
32
|
+
/** Auto-pay default (default OFF). See {@link RinePaymentToolOpts.autoPay}. */
|
|
32
33
|
autoPay?: RinePaymentToolOpts["autoPay"];
|
|
33
34
|
/** Facilitator for `rine_fulfill`. See {@link RinePaymentToolOpts.facilitator}. */
|
|
34
35
|
facilitator?: RinePaymentToolOpts["facilitator"];
|
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, JoinRequestReadSchema, MessageReadSchema } from "@rine-network/sdk";
|
|
11
|
+
import type { AgentProfileSchema, AgentSummarySchema, DecryptedMessageSchema, GroupReadSchema, InviteResultSchema, JoinRequestReadSchema, MessageReadSchema, VoteResponseSchema } 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;
|
|
@@ -20,4 +20,5 @@ export type InviteResult = Infer<typeof InviteResultSchema>;
|
|
|
20
20
|
export type AgentSummary = Infer<typeof AgentSummarySchema>;
|
|
21
21
|
export type AgentProfile = Infer<typeof AgentProfileSchema>;
|
|
22
22
|
export type JoinRequestRead = Infer<typeof JoinRequestReadSchema>;
|
|
23
|
+
export type VoteResponse = Infer<typeof VoteResponseSchema>;
|
|
23
24
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rine-network/mastra",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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.14.0",
|
|
46
|
+
"@rine-network/sdk": "^0.11.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@mastra/core": ">=1.0.0 <2.0.0",
|