@arcproof/sdk-elizaos 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.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @arcproof/sdk-elizaos
2
+
3
+ ElizaOS plugin adapter for [`@arcproof/sdk`](../sdk): expose a bonded, independently-verified, real-payment flow as a real ElizaOS `Action`/`Plugin`.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @arcproof/sdk @arcproof/sdk-elizaos @elizaos/core
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { createArcProofAction, createArcProofPlugin } from "@arcproof/sdk-elizaos";
15
+ import { VerifierRegistry, ARC_TESTNET } from "@arcproof/sdk";
16
+
17
+ const action = createArcProofAction({
18
+ name: "CHECK_TRUE_APR",
19
+ description: "Independently verifies a loan's true APR before answering, paying the specialist only if it checks out.",
20
+ trustedAgentConfig: { network: ARC_TESTNET, contractAddress, verifiers: myVerifierRegistry },
21
+ requester, // WalletCredential
22
+ settler, // WalletCredential
23
+ providerAddresses: { "lending-apr-agent-v1": "0x...", "lending-eligibility-agent-v1": "0x..." },
24
+ budgetAmount: 0.05,
25
+ // gatherClaims can be a single @arcproof/sdk-langchain gatherer, or a full
26
+ // orchestrator (createLangChainOrchestrator) that itself decides which
27
+ // specialists this specific request needs -- ElizaOS never has to know
28
+ // the difference, it just sees the natural-language reply either way.
29
+ gatherClaims: myOrchestratorOrGatherer,
30
+ buildContext: (message) => ({ loanId: extractLoanId(message.content.text), requestText: message.content.text }),
31
+ });
32
+
33
+ const plugin = createArcProofPlugin({
34
+ name: "arcproof-trust-layer",
35
+ description: "Bonded, independently-verified agent actions with real on-chain payment.",
36
+ actions: [action],
37
+ });
38
+
39
+ // register `plugin` with your ElizaOS character/project as you would any other plugin
40
+ ```
41
+
42
+ ## Why this doesn't import types from `@elizaos/core`
43
+
44
+ `@elizaos/core`'s top-level barrel (`dist/index.d.ts`) re-exports both `./types` (which defines `Action`/`Plugin` as types) and `./actions` (a same-named runtime export) via `export *`. TypeScript silently drops an ambiguous re-exported name rather than erroring, so `import type { Action } from "@elizaos/core"` fails at typecheck time even though the type genuinely exists in the package (confirmed against `@elizaos/core@1.7.2`'s actual `.d.ts` files).
45
+
46
+ This package defines structurally-identical local types (`ElizaAction`, `ElizaPlugin`, etc.) instead of depending on that fragile export path. TypeScript's structural typing makes the objects this package builds assignable to the real `Action`/`Plugin` types wherever your actual ElizaOS runtime code expects them -- `@elizaos/core` is still a declared peer dependency because you need the real package installed to run an agent at all.
47
+
48
+ ## License
49
+
50
+ MIT
@@ -0,0 +1,75 @@
1
+ import { type TrustedAgentConfig, type SettlementResult, type Claim, type WalletCredential } from "@arcproof/sdk";
2
+ export interface ElizaContent {
3
+ text?: string;
4
+ [key: string]: unknown;
5
+ }
6
+ export interface ElizaMemory {
7
+ content: ElizaContent;
8
+ [key: string]: unknown;
9
+ }
10
+ export interface ElizaState {
11
+ values: Record<string, unknown>;
12
+ [key: string]: unknown;
13
+ }
14
+ export interface ElizaActionExample {
15
+ name: string;
16
+ content: ElizaContent;
17
+ }
18
+ export interface ElizaActionResult {
19
+ text?: string;
20
+ values?: Record<string, unknown>;
21
+ data?: Record<string, unknown>;
22
+ success: boolean;
23
+ error?: string | Error;
24
+ }
25
+ export type ElizaHandlerCallback = (response: ElizaContent) => Promise<unknown>;
26
+ export type ElizaValidator = (runtime: unknown, message: ElizaMemory, state?: ElizaState) => Promise<boolean>;
27
+ export type ElizaHandler = (runtime: unknown, message: ElizaMemory, state?: ElizaState, options?: unknown, callback?: ElizaHandlerCallback, responses?: ElizaMemory[]) => Promise<ElizaActionResult | void | undefined>;
28
+ export interface ElizaAction {
29
+ name: string;
30
+ description: string;
31
+ similes?: string[];
32
+ examples?: ElizaActionExample[][];
33
+ validate: ElizaValidator;
34
+ handler: ElizaHandler;
35
+ [key: string]: unknown;
36
+ }
37
+ export interface ElizaPlugin {
38
+ name: string;
39
+ description: string;
40
+ actions?: ElizaAction[];
41
+ [key: string]: unknown;
42
+ }
43
+ export interface ArcProofActionOptions {
44
+ /** ElizaOS action name, e.g. "CHECK_TRUE_APR" -- convention is SCREAMING_SNAKE_CASE. */
45
+ name: string;
46
+ description: string;
47
+ similes?: string[];
48
+ examples?: ElizaActionExample[][];
49
+ trustedAgentConfig: TrustedAgentConfig;
50
+ requester: WalletCredential;
51
+ settler: WalletCredential;
52
+ providerAddresses: Record<string, string>;
53
+ budgetAmount: number;
54
+ gatherClaims: (context: Record<string, unknown>) => Promise<Claim[]>;
55
+ /** Extracts job context (e.g. a loan id, an account, a protocol slug) from the incoming message. */
56
+ buildContext: (message: ElizaMemory, state?: ElizaState) => Record<string, unknown>;
57
+ /** Custom trigger condition -- defaults to "always applies" (ElizaOS's own routing/prompting decides whether to invoke this action at all). */
58
+ validate?: ElizaValidator;
59
+ /** Formats the settlement result into the text ElizaOS sends back to the user. */
60
+ formatResponse?: (result: SettlementResult) => string;
61
+ }
62
+ /**
63
+ * Builds a real ElizaOS Action that runs a full bonded job (lock -> gather
64
+ * -> verify -> settle/refund) whenever ElizaOS decides to invoke it.
65
+ * Every payment is a real Arc transaction -- nothing here is simulated
66
+ * just because it's running inside an agent framework instead of a
67
+ * standalone script.
68
+ */
69
+ export declare function createArcProofAction(options: ArcProofActionOptions): ElizaAction;
70
+ /** Bundles one or more ArcProof actions into a real, installable ElizaOS Plugin. */
71
+ export declare function createArcProofPlugin(options: {
72
+ name: string;
73
+ description: string;
74
+ actions: ElizaAction[];
75
+ }): ElizaPlugin;
package/dist/index.js ADDED
@@ -0,0 +1,88 @@
1
+ /**
2
+ * ElizaOS plugin adapter for @arcproof/sdk: exposes a bonded,
3
+ * independently-verified, real-payment flow as an ElizaOS Action.
4
+ *
5
+ * Shapes below (ElizaAction/ElizaPlugin/etc.) are structurally verified
6
+ * against @elizaos/core@1.7.2's actual dist/types/*.d.ts definitions
7
+ * (Action, Plugin, Handler, Validator, Memory, State, Content,
8
+ * ActionResult, ActionExample), not guessed from memory -- but
9
+ * deliberately NOT imported from "@elizaos/core" directly: that
10
+ * package's top-level barrel (dist/index.d.ts) re-exports both
11
+ * ./types (which defines `Action`/`Plugin` as types) and ./actions
12
+ * (which defines a same-named runtime export), and TypeScript silently
13
+ * drops an ambiguous `export *` name rather than erroring -- confirmed
14
+ * live (`Module has no exported member 'Action'` etc. even though the
15
+ * type genuinely exists in the package). Defining structurally-identical
16
+ * local types sidesteps that import ambiguity entirely; TypeScript's
17
+ * structural typing makes the object this module builds assignable to
18
+ * the real Plugin/Action types wherever a consumer's actual ElizaOS
19
+ * runtime code expects them.
20
+ *
21
+ * The action's handler calls runTrustedJob() under the hood: lock a real
22
+ * budget, run your gatherClaims() step (any framework -- often
23
+ * @arcproof/sdk-langchain wrapping the same LangChain.js agent this
24
+ * ElizaOS character already uses for its model calls), independently
25
+ * verify every claim, then release/refund real on-chain payment based on
26
+ * the verdict. ElizaOS only ever sees the natural-language in and out;
27
+ * the trust mechanics are identical to the LangChain.js-only path.
28
+ */
29
+ import { randomUUID } from "node:crypto";
30
+ import { runTrustedJob } from "@arcproof/sdk";
31
+ function defaultFormatResponse(result) {
32
+ const lines = [`Verdict: ${result.overall_verdict.toUpperCase()} (paid ${result.total_paid_usdc.toFixed(4)})`, ""];
33
+ for (const c of result.claims) {
34
+ lines.push(`- [${c.claim_type}] ${c.claim_text} -> ${c.verification_status}${c.verification_note ? ` (${c.verification_note})` : ""}`);
35
+ }
36
+ return lines.join("\n");
37
+ }
38
+ /**
39
+ * Builds a real ElizaOS Action that runs a full bonded job (lock -> gather
40
+ * -> verify -> settle/refund) whenever ElizaOS decides to invoke it.
41
+ * Every payment is a real Arc transaction -- nothing here is simulated
42
+ * just because it's running inside an agent framework instead of a
43
+ * standalone script.
44
+ */
45
+ export function createArcProofAction(options) {
46
+ return {
47
+ name: options.name,
48
+ description: options.description,
49
+ similes: options.similes ?? [],
50
+ examples: options.examples ?? [],
51
+ validate: options.validate ?? (async () => true),
52
+ handler: async (_runtime, message, state, _handlerOptions, callback) => {
53
+ const jobId = randomUUID();
54
+ const context = { jobId, ...options.buildContext(message, state) };
55
+ try {
56
+ const params = {
57
+ jobId,
58
+ budgetAmount: options.budgetAmount,
59
+ requester: options.requester,
60
+ settler: options.settler,
61
+ providerAddresses: options.providerAddresses,
62
+ gatherClaims: options.gatherClaims,
63
+ context,
64
+ };
65
+ const result = await runTrustedJob(options.trustedAgentConfig, params);
66
+ const text = (options.formatResponse ?? defaultFormatResponse)(result);
67
+ if (callback)
68
+ await callback({ text });
69
+ return { text, success: true, data: { settlement: result } };
70
+ }
71
+ catch (e) {
72
+ const text = `Couldn't complete that verified request: ${e}`;
73
+ if (callback)
74
+ await callback({ text });
75
+ return { text, success: false, error: e instanceof Error ? e : String(e) };
76
+ }
77
+ },
78
+ };
79
+ }
80
+ /** Bundles one or more ArcProof actions into a real, installable ElizaOS Plugin. */
81
+ export function createArcProofPlugin(options) {
82
+ return {
83
+ name: options.name,
84
+ description: options.description,
85
+ actions: options.actions,
86
+ };
87
+ }
88
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,aAAa,EAAwG,MAAM,eAAe,CAAC;AAyEpJ,SAAS,qBAAqB,CAAC,MAAwB;IACrD,MAAM,KAAK,GAAG,CAAC,YAAY,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,UAAU,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACnH,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU,OAA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C,MAAM,CAAC,CAAC;gBAEvE,IAAI,QAAQ;oBAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,MAA4C,EAAE,EAAE,CAAC;YACrG,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,IAAI,GAAG,4CAA4C,CAAC,EAAE,CAAC;gBAC7D,IAAI,QAAQ;oBAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,oBAAoB,CAAC,OAAsE;IACzG,OAAO;QACL,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@arcproof/sdk-elizaos",
3
+ "version": "0.1.0",
4
+ "description": "ElizaOS plugin for @arcproof/sdk -- expose a bonded, independently-verified, real-payment action inside an ElizaOS agent.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": ["dist", "README.md"],
15
+ "publishConfig": { "access": "public" },
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "typecheck": "tsc --noEmit"
19
+ },
20
+ "keywords": ["arcproof", "elizaos", "ai-agents", "verification", "plugin"],
21
+ "license": "MIT",
22
+ "peerDependencies": {
23
+ "@arcproof/sdk": "^0.1.0",
24
+ "@elizaos/core": "^1.0.0"
25
+ },
26
+ "devDependencies": {
27
+ "@arcproof/sdk": "*",
28
+ "typescript": "^5.7.3",
29
+ "@types/node": "^22.10.5"
30
+ }
31
+ }