@escro/plugin-sak 0.0.0-stage → 0.1.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.
@@ -0,0 +1,91 @@
1
+ import { Keypair } from '@solana/web3.js';
2
+ import { EscroOptions, SpendCap, X402SpendCap } from '@escro/sdk';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Minimal vendored type surface for `solana-agent-kit`, Apache-2.0.
7
+ *
8
+ * `solana-agent-kit` is provided by the host agent and declared in no dependency list; this plugin imports no runtime
9
+ * value from it, and its dependency tree is out of proportion to a handful of erased types. Each declaration below is a consume-only structural subset of the published declarations of:
10
+ *
11
+ * solana-agent-kit@2.0.10 dist/index.d.ts
12
+ *
13
+ * The kit spells `any` where this file spells `unknown`. A real `SolanaAgentKit` remains assignable to `SakAgent` and
14
+ * the plugin to the kit's `Plugin`. If a later kit major changes these shapes, re-verify against its declarations.
15
+ */
16
+
17
+ /** The part of `SolanaAgentKit` this plugin reads: `BaseWallet.publicKey`, and no signing method. */
18
+ interface SakAgent {
19
+ wallet: {
20
+ publicKey: {
21
+ toBase58(): string;
22
+ };
23
+ };
24
+ }
25
+ type Handler = (agent: SakAgent, input: Record<string, unknown>) => Promise<Record<string, unknown>>;
26
+ interface ActionExample {
27
+ input: Record<string, unknown>;
28
+ output: Record<string, unknown>;
29
+ explanation: string;
30
+ }
31
+ interface Action {
32
+ name: string;
33
+ similes: string[];
34
+ description: string;
35
+ examples: ActionExample[][];
36
+ schema: z.ZodType<unknown>;
37
+ handler: Handler;
38
+ }
39
+ interface Plugin {
40
+ name: string;
41
+ methods: Record<string, unknown>;
42
+ actions: Action[];
43
+ initialize(agent: SakAgent): void;
44
+ }
45
+
46
+ type EscroActionName = "escro_commission" | "escro_claim" | "escro_submit" | "escro_release" | "escro_read_escrow" | "escro_find_workers" | "escro_reputation" | "escro_pay_402";
47
+
48
+ /** A set-up refusal, or a failure after money may have moved. */
49
+ declare class EscroPluginError extends Error {
50
+ /** The SDK's code on a failure after money may have moved; absent on a set-up refusal. */
51
+ readonly code?: string;
52
+ constructor(message: string, options?: {
53
+ code?: string;
54
+ cause?: unknown;
55
+ });
56
+ }
57
+
58
+ interface EscroSakPluginOptions {
59
+ /** The agent wallet's own keypair; passed only to the SDK, which alone signs. */
60
+ wallet: Keypair;
61
+ /** Required; a missing cluster never defaults to devnet. */
62
+ cluster: EscroOptions["cluster"];
63
+ /** Passed through unchanged; the SDK refuses a mainnet commission without it. */
64
+ spendCap?: SpendCap;
65
+ /** Passed through unchanged; the SDK refuses a mainnet `exact` payment without it. */
66
+ x402SpendCap?: X402SpendCap;
67
+ /** Defaults to the cluster's public Escro API. */
68
+ apiUrl?: string;
69
+ /** Defaults to the cluster's public RPC endpoint. */
70
+ rpcUrl?: string;
71
+ /**
72
+ * Lets escro_pay_402 pay a URL whose host is a loopback, link-local or private address (a local
73
+ * worker). Off by default. On mainnet a public host is still paid only over https:.
74
+ */
75
+ allowPrivateHosts?: boolean;
76
+ }
77
+ interface EscroSakPlugin {
78
+ name: "escro";
79
+ methods: Record<EscroActionName, Handler>;
80
+ actions: Action[];
81
+ initialize(agent: SakAgent): void;
82
+ }
83
+ /**
84
+ * The Solana Agent Kit plugin: `agent.use(createEscroPlugin({ wallet, cluster, ... }))`.
85
+ *
86
+ * The keypair lives only in this closure and the SDK client, so no dump of the plugin can show it.
87
+ */
88
+ declare function createEscroPlugin(options: EscroSakPluginOptions): EscroSakPlugin;
89
+
90
+ export { EscroPluginError, createEscroPlugin };
91
+ export type { Action, ActionExample, EscroActionName, EscroSakPlugin, EscroSakPluginOptions, Handler, Plugin, SakAgent };
@@ -0,0 +1,91 @@
1
+ import { Keypair } from '@solana/web3.js';
2
+ import { EscroOptions, SpendCap, X402SpendCap } from '@escro/sdk';
3
+ import { z } from 'zod';
4
+
5
+ /**
6
+ * Minimal vendored type surface for `solana-agent-kit`, Apache-2.0.
7
+ *
8
+ * `solana-agent-kit` is provided by the host agent and declared in no dependency list; this plugin imports no runtime
9
+ * value from it, and its dependency tree is out of proportion to a handful of erased types. Each declaration below is a consume-only structural subset of the published declarations of:
10
+ *
11
+ * solana-agent-kit@2.0.10 dist/index.d.ts
12
+ *
13
+ * The kit spells `any` where this file spells `unknown`. A real `SolanaAgentKit` remains assignable to `SakAgent` and
14
+ * the plugin to the kit's `Plugin`. If a later kit major changes these shapes, re-verify against its declarations.
15
+ */
16
+
17
+ /** The part of `SolanaAgentKit` this plugin reads: `BaseWallet.publicKey`, and no signing method. */
18
+ interface SakAgent {
19
+ wallet: {
20
+ publicKey: {
21
+ toBase58(): string;
22
+ };
23
+ };
24
+ }
25
+ type Handler = (agent: SakAgent, input: Record<string, unknown>) => Promise<Record<string, unknown>>;
26
+ interface ActionExample {
27
+ input: Record<string, unknown>;
28
+ output: Record<string, unknown>;
29
+ explanation: string;
30
+ }
31
+ interface Action {
32
+ name: string;
33
+ similes: string[];
34
+ description: string;
35
+ examples: ActionExample[][];
36
+ schema: z.ZodType<unknown>;
37
+ handler: Handler;
38
+ }
39
+ interface Plugin {
40
+ name: string;
41
+ methods: Record<string, unknown>;
42
+ actions: Action[];
43
+ initialize(agent: SakAgent): void;
44
+ }
45
+
46
+ type EscroActionName = "escro_commission" | "escro_claim" | "escro_submit" | "escro_release" | "escro_read_escrow" | "escro_find_workers" | "escro_reputation" | "escro_pay_402";
47
+
48
+ /** A set-up refusal, or a failure after money may have moved. */
49
+ declare class EscroPluginError extends Error {
50
+ /** The SDK's code on a failure after money may have moved; absent on a set-up refusal. */
51
+ readonly code?: string;
52
+ constructor(message: string, options?: {
53
+ code?: string;
54
+ cause?: unknown;
55
+ });
56
+ }
57
+
58
+ interface EscroSakPluginOptions {
59
+ /** The agent wallet's own keypair; passed only to the SDK, which alone signs. */
60
+ wallet: Keypair;
61
+ /** Required; a missing cluster never defaults to devnet. */
62
+ cluster: EscroOptions["cluster"];
63
+ /** Passed through unchanged; the SDK refuses a mainnet commission without it. */
64
+ spendCap?: SpendCap;
65
+ /** Passed through unchanged; the SDK refuses a mainnet `exact` payment without it. */
66
+ x402SpendCap?: X402SpendCap;
67
+ /** Defaults to the cluster's public Escro API. */
68
+ apiUrl?: string;
69
+ /** Defaults to the cluster's public RPC endpoint. */
70
+ rpcUrl?: string;
71
+ /**
72
+ * Lets escro_pay_402 pay a URL whose host is a loopback, link-local or private address (a local
73
+ * worker). Off by default. On mainnet a public host is still paid only over https:.
74
+ */
75
+ allowPrivateHosts?: boolean;
76
+ }
77
+ interface EscroSakPlugin {
78
+ name: "escro";
79
+ methods: Record<EscroActionName, Handler>;
80
+ actions: Action[];
81
+ initialize(agent: SakAgent): void;
82
+ }
83
+ /**
84
+ * The Solana Agent Kit plugin: `agent.use(createEscroPlugin({ wallet, cluster, ... }))`.
85
+ *
86
+ * The keypair lives only in this closure and the SDK client, so no dump of the plugin can show it.
87
+ */
88
+ declare function createEscroPlugin(options: EscroSakPluginOptions): EscroSakPlugin;
89
+
90
+ export { EscroPluginError, createEscroPlugin };
91
+ export type { Action, ActionExample, EscroActionName, EscroSakPlugin, EscroSakPluginOptions, Handler, Plugin, SakAgent };