@oakagentkit/gloam 0.0.0-stage → 0.2.6
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/LICENSE +18 -0
- package/README.md +17 -2
- package/build/dist/chunks/3ST44SAG.js +1 -0
- package/build/dist/chunks/VPWLWYYS.js +1 -0
- package/build/dist/engine.d.ts +7 -0
- package/build/dist/engine.js +1 -0
- package/build/dist/index.d.ts +3 -0
- package/build/dist/index.js +1 -0
- package/build/dist/prover.d.ts +7 -0
- package/build/dist/prover.js +1 -0
- package/package.json +36 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Oak — Free to use, no copying
|
|
2
|
+
Copyright (c) 2026 Oak. All rights reserved.
|
|
3
|
+
|
|
4
|
+
Anyone may install and use this package, including in their own agents and
|
|
5
|
+
commercial products, free of charge. You may make the copies technically
|
|
6
|
+
necessary to install, run and back up the package for that use.
|
|
7
|
+
|
|
8
|
+
You may not otherwise copy, modify, distribute, resell, sublicense or rehost
|
|
9
|
+
the package code, whether in original, minified or derived form. Products
|
|
10
|
+
may depend on the official package; this does not permit redistributing its
|
|
11
|
+
code inside another package, bundle, service download or hosted mirror.
|
|
12
|
+
|
|
13
|
+
Keep this license with permitted copies. Third-party dependencies are
|
|
14
|
+
separate works governed by their own licenses; these restrictions do not
|
|
15
|
+
replace their terms. This license grants no trademark rights.
|
|
16
|
+
|
|
17
|
+
The package is provided as is, without warranty. To the extent permitted
|
|
18
|
+
by law, Oak is not liable for claims or damages arising from its use.
|
package/README.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @oakagentkit/gloam
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This is Oak's optional local Gloam engine. It provides the Gloam SDK builders,
|
|
4
|
+
receiving helpers, tree reconstruction, and Groth16 proving to the Oak add-on.
|
|
5
|
+
The add-on keeps notes and circuit files on the person's computer. This package
|
|
6
|
+
does not store notes or use a wallet key.
|
|
7
|
+
|
|
8
|
+
Install it beside Oak when you want Gloam tools:
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
npx -y -p @oakagentkit/addon@0.2.7 -p @oakagentkit/gloam@0.2.7 oak mcp
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The engine supports Robinhood Chain mainnet (chain 4663) and USDG only. Its
|
|
15
|
+
prover opens local circuit files once, checks their SHA-256 against the production
|
|
16
|
+
key hashes in the installed Gloam SDK, and proves from those same bytes. Oak's
|
|
17
|
+
add-on gives back path and hash records after checking the same files against its
|
|
18
|
+
independently pinned hashes. Cache hits are checked again before use.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as w}from"node:crypto";import{constants as n}from"node:fs";import{open as f}from"node:fs/promises";import{isAbsolute as u}from"node:path";import{CIRCUIT_SHA256 as e,packGroth16Proof as h}from"@gloamtrade/sdk";async function l(o,a){if(!u(o)||/^https?:\/\//i.test(o))throw new Error("A local circuit path is required. Nothing was proved.");let r=await f(o,n.O_RDONLY|n.O_NOFOLLOW);try{if(!(await r.stat()).isFile())throw new Error("A local circuit file is required. Nothing was proved.");let t=await r.readFile();if(w("sha256").update(t).digest("hex")!==a)throw new Error("Circuit SHA-256 mismatch. Nothing was proved.");return t}finally{await r.close()}}async function C(o,a,r){if(r.wasm.sha256!==e.wasm[o]||r.zkey.sha256!==e.zkey.production[o])throw new Error("Circuit SHA-256 pin mismatch. Nothing was proved.");let[t,m]=await Promise.all([l(r.wasm.path,e.wasm[o]),l(r.zkey.path,e.zkey.production[o])]),i=await import("snarkjs");if(!i||typeof i!="object"||!("groth16"in i))throw new Error("Gloam prover is unavailable. Nothing was proved.");let s=i.groth16;if(typeof s?.fullProve!="function")throw new Error("Gloam prover is unavailable. Nothing was proved.");let{proof:p,publicSignals:c}=await s.fullProve(a,t,m);return{proofBytes:h(p),publicSignals:c}}export{C as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as k}from"./3ST44SAG.js";import{CIRCUIT_SHA256 as O,IncrementalMerkleTreePoseidon as N,agentSigningAllowlist as F,assertDepositWithinLiveLimit as K,buildPrivateSendIntent as U,buildShieldBoundIntent as H,buildUnshieldIntent as M,cashOutFeeLive as W,circuitArtifactUrls as q,decodeNotePackage as z,encodeNotePackage as j,fieldToHex as P,generateReceiveKey as J,hexToField as R,isReceiveTag as Q,mainnetNetwork as V,notePackageToExport as X,openIncomingPayment as Y,openSealedTicket as Z,readCashOutFeeBps as $,readDepositLimit as ee,relayIntent as T,relayMemo as oe,scanIncomingPayments as ne,sealToReceiveTag as te,sweepReceivedNote as re,syncTree as ae}from"@gloamtrade/sdk";var r=4663,s="0x39E28Cde55CAB798874746ac52cb4B5Cc99a0194",h="0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",y=V("robinhood");if(!y||y.chainId!==r||y.pool.toLowerCase()!==s.toLowerCase())throw new Error("Installed Gloam SDK has no matching Robinhood mainnet pool.");function L(){if(!y)throw new Error("Installed Gloam SDK has no Robinhood mainnet network.");return y}function l(t){if(t!==void 0&&t!==r)throw new Error("Gloam supports chain 4663 only. Nothing was done.")}function c(t){if(t!==void 0&&t.toLowerCase()!==s.toLowerCase())throw new Error("Gloam pool does not match the pinned vault. Nothing was done.")}function w(t){if(t!==void 0&&t.toLowerCase()!==h.toLowerCase())throw new Error("Gloam supports USDG only. Nothing was done.")}var se=[{type:"function",name:"isKnownRoot",stateMutability:"view",inputs:[{name:"root",type:"bytes32"}],outputs:[{type:"bool"}]}];async function b(t){if(t.leafCount!==t.leaves.length)throw new Error("Gloam tree snapshot leaf count mismatch.");let e=new N;await e.init();for(let o of t.leaves){if(o.leafIndex!==e.nextIndex)throw new Error("Gloam tree snapshot leaf order mismatch.");await e.insert(R(o.commitment))}if(P(e.currentRoot).toLowerCase()!==t.root.toLowerCase())throw new Error("Gloam tree snapshot root mismatch.");return e}async function S(t,e){return t.readContract({address:s,abi:se,functionName:"isKnownRoot",args:[e]})}function de(){return structuredClone(O)}function le(){return F({chainId:r,assets:[{symbol:"USDG",address:h}]})}function ue(){return{api:1,async buildShieldBoundIntent(e){return l(e.chainId),c(e.poolAddress),w(e.asset),H({...e,chainId:r,poolAddress:s,asset:h})},async buildPrivateSendIntent(e){return l(e.chainId),c(e.poolAddress),w(e.asset),U({...e,chainId:r,poolAddress:s,asset:h})},async buildUnshieldIntent(e){return l(e.chainId),c(e.poolAddress),w(e.asset),M({...e,chainId:r,poolAddress:s,asset:h})},async sweepReceivedNote(e){return l(e.chainId),c(e.poolAddress),w(e.note.asset),re(e)},async scanIncomingPayments(e){if(await e.client.getChainId()!==r)throw new Error("Gloam chain reads must use chain 4663. Nothing was done.");return ne({...e,network:L()})},async openIncomingPayment(e){if(await e.client.getChainId()!==r)throw new Error("Gloam chain reads must use chain 4663. Nothing was done.");return Y({...e,network:L()})},isReceiveTag:Q,sealToReceiveTag:te,openSealedTicket:Z,generateReceiveKey:J,encodeNotePackage:j,decodeNotePackage:z,notePackageToExport:X,async syncTree(e,o){if(c(o.pool),await e.getChainId()!==r)throw new Error("Gloam chain reads must use chain 4663. Nothing was done.");let i=await e.getBlockNumber({cacheTime:0}),a=o.toBlock!==void 0&&o.toBlock<i?o.toBlock:i,n=o.previous,x=n?n.syncedTo+1n:94194599n;if(o.fromBlock!==void 0&&o.fromBlock!==x)throw new Error("Gloam tree sync range is not contiguous.");if(a<94194599n||n&&n.syncedTo>a)throw new Error("Gloam tree sync head is before the saved tree.");let f=n?await b(n):new N;if(n||await f.init(),n&&n.syncedTo<94194599n)throw new Error("Gloam tree snapshot is before pool deployment.");if(x>a){let d=await S(e,n.root);return{...n,rootKnown:d}}let m=!1,p,g=new Set,B=new Proxy(e,{get(d,u,v){return u==="getBlockNumber"?async()=>a:u==="getLogs"?async _=>{if(m)throw p;let G=d.getLogs(_);g.add(G);try{return await G}catch(E){throw m||(p=E),m=!0,E}finally{g.delete(G)}}:Reflect.get(d,u,v)}}),I;try{I=await ae(B,{pool:s,fromBlock:x,chunkSize:o.chunkSize})}catch(d){throw await Promise.allSettled([...g]),m?p:d}if(await Promise.allSettled([...g]),m)throw p;if(I.leafCount!==I.leaves.length)throw new Error("Gloam tree sync leaf count mismatch.");let C=n?[...n.leaves]:[];for(let[d,u]of I.leaves.entries()){if(u.leafIndex!==d)throw new Error("Gloam tree sync leaf order mismatch.");let v=f.nextIndex;await f.insert(R(u.commitment)),C.push({...u,leafIndex:v})}let A=P(f.currentRoot),D=await S(e,A);return{leaves:C,root:A,leafCount:f.nextIndex,syncedTo:a,rootKnown:D}},async pathForCommitment(e,o){let i=await b(e),a=-1;for(let n of e.leaves)n.commitment.toLowerCase()===o.toLowerCase()&&(a=n.leafIndex);return a<0?null:i.path(a)},async relayIntent(e,o){if(l(e.chainId),c(e.exec?.poolAddress),e.intent==="private_send"&&e.exec?.fn==="transfer")return T({intent:"private_send",chainId:r,agentAddress:e.agentAddress,plan:e.plan,privacy:e.privacy,execution:e.execution,exec:{...e.exec,fn:"transfer"}},o);if(e.intent==="unshield"&&e.exec?.fn==="unshield"&&e.plan.to)return T({intent:"unshield",chainId:r,agentAddress:e.agentAddress,plan:{...e.plan,to:e.plan.to},privacy:e.privacy,execution:e.execution,exec:{...e.exec,fn:"unshield"}},o);throw new Error("Only validated private sends and cash outs may use the Gloam relay.")},async relayMemo(e,o){return l(e.chainId),oe(e,o)},async readCashOutFeeBps(e,o){return c(o),$(e,s)},async cashOutFeeLive(e,o,i){return c(o),W(e,s,i)},async readDepositLimit(e,o,i){return c(o),w(i),ee(e,s,h)},async assertDepositWithinLiveLimit(e,o,i,a,n){return l(o),c(n),w(i),K(e,r,h,a,s)},circuitArtifactUrls(e,o){return l(o),q(e,r)},prove:k}}export{de as a,le as b,ue as c};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GloamEngine } from '@oakagentkit/core/modules/gloam/types';
|
|
2
|
+
export declare function sdkCircuitSha256(): {
|
|
3
|
+
wasm: Record<import("@gloamtrade/sdk").GloamCircuit, string>;
|
|
4
|
+
zkey: Record<import("@gloamtrade/sdk").CeremonyKind, Record<import("@gloamtrade/sdk").GloamCircuit, string>>;
|
|
5
|
+
};
|
|
6
|
+
export declare function sdkSigningAllowlist(): import("@gloamtrade/sdk").AgentSigningEntry[];
|
|
7
|
+
export declare function createGloamEngine(): GloamEngine;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./chunks/VPWLWYYS.js";import"./chunks/3ST44SAG.js";export{c as createGloamEngine,a as sdkCircuitSha256,b as sdkSigningAllowlist};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as r,c as e}from"./chunks/VPWLWYYS.js";import{a as o}from"./chunks/3ST44SAG.js";var t=1;export{t as GLOAM_ENGINE_API,e as createGloamEngine,o as proveGloam,r as sdkCircuitSha256};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PoolCircuit } from '@gloamtrade/sdk';
|
|
2
|
+
import type { VerifiedCircuitPaths } from '@oakagentkit/core/modules/gloam/types';
|
|
3
|
+
export type CircomInput = Record<string, string | string[]>;
|
|
4
|
+
export declare function proveGloam(circuit: PoolCircuit, input: CircomInput, paths: VerifiedCircuitPaths): Promise<{
|
|
5
|
+
proofBytes: `0x${string}`;
|
|
6
|
+
publicSignals: string[];
|
|
7
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunks/3ST44SAG.js";export{a as proveGloam};
|
package/package.json
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oakagentkit/gloam",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.6",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=22.12.0"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"lint": "eslint \"src/**/*.{js,mjs,cjs,ts,mts,cts,tsx}\" \"test/**/*.{js,mjs,cjs,ts,mts,cts,tsx}\" --no-error-on-unmatched-pattern --max-warnings 0",
|
|
11
|
+
"typecheck": "pnpm --workspace-root run typecheck:package packages/gloam/tsconfig.json",
|
|
12
|
+
"test": "vitest run --passWithNoTests --config ../../scripts/release/vitest-addon.config.mjs test",
|
|
13
|
+
"build": "node ../../scripts/release/build.mjs gloam",
|
|
14
|
+
"prepublishOnly": "node ../../scripts/release/prepare.mjs gloam --verify"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"build/dist/**/*.js",
|
|
18
|
+
"build/dist/**/*.d.ts",
|
|
19
|
+
"LICENSE"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@gloamtrade/sdk": "0.5.1",
|
|
23
|
+
"snarkjs": "0.7.5"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@oakagentkit/core": "workspace:*"
|
|
27
|
+
},
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./build/dist/index.d.ts",
|
|
31
|
+
"default": "./build/dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./*": {
|
|
34
|
+
"types": "./build/dist/*.d.ts",
|
|
35
|
+
"default": "./build/dist/*.js"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|