suprafx-agent-sdk 0.3.1
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 +21 -0
- package/README.md +452 -0
- package/dist/bin/suprafx-mcp.d.ts +15 -0
- package/dist/bin/suprafx-mcp.js +238 -0
- package/dist/bin/suprafx-mcp.js.map +1 -0
- package/dist/src/asset-registry.d.ts +61 -0
- package/dist/src/asset-registry.js +118 -0
- package/dist/src/asset-registry.js.map +1 -0
- package/dist/src/client.d.ts +227 -0
- package/dist/src/client.js +282 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/derive-ids.d.ts +112 -0
- package/dist/src/derive-ids.js +361 -0
- package/dist/src/derive-ids.js.map +1 -0
- package/dist/src/event-bcs.d.ts +341 -0
- package/dist/src/event-bcs.js +767 -0
- package/dist/src/event-bcs.js.map +1 -0
- package/dist/src/index.d.ts +26 -0
- package/dist/src/index.js +26 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/mcp/config.d.ts +32 -0
- package/dist/src/mcp/config.js +101 -0
- package/dist/src/mcp/config.js.map +1 -0
- package/dist/src/mcp/lifecycle.d.ts +109 -0
- package/dist/src/mcp/lifecycle.js +170 -0
- package/dist/src/mcp/lifecycle.js.map +1 -0
- package/dist/src/mcp/preflight.d.ts +36 -0
- package/dist/src/mcp/preflight.js +291 -0
- package/dist/src/mcp/preflight.js.map +1 -0
- package/dist/src/mcp/server.d.ts +20 -0
- package/dist/src/mcp/server.js +235 -0
- package/dist/src/mcp/server.js.map +1 -0
- package/dist/src/mcp/tools.d.ts +51 -0
- package/dist/src/mcp/tools.js +1022 -0
- package/dist/src/mcp/tools.js.map +1 -0
- package/dist/src/sign-event.d.ts +185 -0
- package/dist/src/sign-event.js +331 -0
- package/dist/src/sign-event.js.map +1 -0
- package/dist/src/signer.d.ts +89 -0
- package/dist/src/signer.js +226 -0
- package/dist/src/signer.js.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegate signer: encapsulates the ed25519 key + sequence counter,
|
|
3
|
+
* encodes a SupraFX event, signs it, and submits to the dApp ingress.
|
|
4
|
+
*
|
|
5
|
+
* Designed for an agent process that holds ONE delegate key. To run
|
|
6
|
+
* multiple delegates (e.g. one per pair) instantiate one Signer each.
|
|
7
|
+
*
|
|
8
|
+
* Sequence management:
|
|
9
|
+
* - On construct, takeOff with `loadSequenceFromChain()` to align
|
|
10
|
+
* the counter to the chain's current expectation
|
|
11
|
+
* - On a `body.ok === true` submit: counter advances by 1
|
|
12
|
+
* - On `body.ok === false` with code in `CHAIN_SAW_IT_CODES`:
|
|
13
|
+
* counter advances (the chain saw the bad envelope and consumed
|
|
14
|
+
* the seq slot for replay protection)
|
|
15
|
+
* - On `body.ok === false` with ingress codes (decode_error,
|
|
16
|
+
* rate_limited, missing_envelope): counter unchanged, safe to retry
|
|
17
|
+
*
|
|
18
|
+
* The chain rejects sequence-number replays at vote time silently —
|
|
19
|
+
* the dApp's submit returns HTTP 200 from mempool but the trade
|
|
20
|
+
* never commits. Re-fetch via `loadSequenceFromChain()` on any
|
|
21
|
+
* suspected drift to recover.
|
|
22
|
+
*/
|
|
23
|
+
import { type UserEvent } from "./event-bcs.js";
|
|
24
|
+
import { SupraFxClient, type SubmitResult } from "./client.js";
|
|
25
|
+
export interface DelegateSignerOptions {
|
|
26
|
+
/** 32-byte ed25519 private key as hex (with or without 0x prefix). */
|
|
27
|
+
delegatePrivKeyHex: string;
|
|
28
|
+
/** The dApp HTTP client. Reused for reads + writes. */
|
|
29
|
+
client: SupraFxClient;
|
|
30
|
+
}
|
|
31
|
+
export declare class DelegateSigner {
|
|
32
|
+
private readonly priv;
|
|
33
|
+
private readonly pub;
|
|
34
|
+
/** 32-byte Supra address = sha3_256(pubkey || 0x00). */
|
|
35
|
+
readonly address: Uint8Array;
|
|
36
|
+
/** Address as `0x`-prefixed lowercase hex. */
|
|
37
|
+
readonly addressHex: string;
|
|
38
|
+
private readonly client;
|
|
39
|
+
private nextSeq;
|
|
40
|
+
private chainIdHash;
|
|
41
|
+
constructor(opts: DelegateSignerOptions);
|
|
42
|
+
/** Re-anchor the local sequence counter to the chain's expectation.
|
|
43
|
+
* Call on startup, on uncertainty, and after long network gaps. */
|
|
44
|
+
loadSequenceFromChain(): Promise<bigint>;
|
|
45
|
+
/** Cached lookup of the chain id hash (constant per genesis). */
|
|
46
|
+
private ensureChainIdHash;
|
|
47
|
+
/** Current next-sequence-number this signer would use. Exposed
|
|
48
|
+
* for diagnostics and for adapters that need to forward seq into
|
|
49
|
+
* custom event payloads. */
|
|
50
|
+
getNextSeq(): bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Build a signed envelope from `event` and submit it to the
|
|
53
|
+
* matching dApp endpoint. Returns the raw `SubmitResult` plus the
|
|
54
|
+
* envelope bytes (handy for logging or replaying).
|
|
55
|
+
*
|
|
56
|
+
* The caller MUST pass an event whose `payload.*sequence_number*`
|
|
57
|
+
* matches `this.getNextSeq()` — we don't mutate the payload here
|
|
58
|
+
* because the field name differs by event type (`user_sequence_number`
|
|
59
|
+
* on most, etc.). Helper methods below (`placeQuote`, `submitRfq`,
|
|
60
|
+
* etc.) handle this for you.
|
|
61
|
+
*/
|
|
62
|
+
sendEnvelope(event: UserEvent): Promise<SubmitResult & {
|
|
63
|
+
envelopeBcsHex: string;
|
|
64
|
+
}>;
|
|
65
|
+
submitRfq(payload: Omit<Extract<UserEvent, {
|
|
66
|
+
kind: "SubmitRfq";
|
|
67
|
+
}>["payload"], "user_sequence_number" | "user">): Promise<SubmitResult>;
|
|
68
|
+
placeQuote(payload: Omit<Extract<UserEvent, {
|
|
69
|
+
kind: "PlaceQuote";
|
|
70
|
+
}>["payload"], "user_sequence_number" | "maker">): Promise<SubmitResult>;
|
|
71
|
+
/** CancelRfq has no `user_sequence_number` — rfq_id uniqueness is
|
|
72
|
+
* the replay-protection invariant. The signer doesn't advance the
|
|
73
|
+
* seq counter for this event type. */
|
|
74
|
+
cancelRfq(args: {
|
|
75
|
+
rfq_id: Uint8Array;
|
|
76
|
+
reason: string;
|
|
77
|
+
}): Promise<SubmitResult>;
|
|
78
|
+
/** AcceptQuote: takes `quote_id` + `trade_id` (caller-supplied, used
|
|
79
|
+
* as the on-chain trade identity). Does NOT take `rfq_id`. */
|
|
80
|
+
acceptQuote(args: {
|
|
81
|
+
quote_id: Uint8Array;
|
|
82
|
+
trade_id: Uint8Array;
|
|
83
|
+
}): Promise<SubmitResult>;
|
|
84
|
+
/** WithdrawQuote takes only `quote_id`. No sequence number — quote_id
|
|
85
|
+
* uniqueness is the replay-protection invariant. */
|
|
86
|
+
withdrawQuote(args: {
|
|
87
|
+
quote_id: Uint8Array;
|
|
88
|
+
}): Promise<SubmitResult>;
|
|
89
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delegate signer: encapsulates the ed25519 key + sequence counter,
|
|
3
|
+
* encodes a SupraFX event, signs it, and submits to the dApp ingress.
|
|
4
|
+
*
|
|
5
|
+
* Designed for an agent process that holds ONE delegate key. To run
|
|
6
|
+
* multiple delegates (e.g. one per pair) instantiate one Signer each.
|
|
7
|
+
*
|
|
8
|
+
* Sequence management:
|
|
9
|
+
* - On construct, takeOff with `loadSequenceFromChain()` to align
|
|
10
|
+
* the counter to the chain's current expectation
|
|
11
|
+
* - On a `body.ok === true` submit: counter advances by 1
|
|
12
|
+
* - On `body.ok === false` with code in `CHAIN_SAW_IT_CODES`:
|
|
13
|
+
* counter advances (the chain saw the bad envelope and consumed
|
|
14
|
+
* the seq slot for replay protection)
|
|
15
|
+
* - On `body.ok === false` with ingress codes (decode_error,
|
|
16
|
+
* rate_limited, missing_envelope): counter unchanged, safe to retry
|
|
17
|
+
*
|
|
18
|
+
* The chain rejects sequence-number replays at vote time silently —
|
|
19
|
+
* the dApp's submit returns HTTP 200 from mempool but the trade
|
|
20
|
+
* never commits. Re-fetch via `loadSequenceFromChain()` on any
|
|
21
|
+
* suspected drift to recover.
|
|
22
|
+
*/
|
|
23
|
+
import { ed25519 } from "@noble/curves/ed25519.js";
|
|
24
|
+
import { sha3_256 } from "@noble/hashes/sha3.js";
|
|
25
|
+
import { encodeUserEvent, } from "./event-bcs.js";
|
|
26
|
+
import { composeSignBytes, encodeEnvelopeBcs, } from "./sign-event.js";
|
|
27
|
+
/** Codes that mean the chain accepted the envelope at mempool but
|
|
28
|
+
* rejected it at apply-time. The seq slot is consumed either way. */
|
|
29
|
+
const CHAIN_SAW_IT_CODES = new Set([
|
|
30
|
+
"gate_rejected",
|
|
31
|
+
"auth_failed",
|
|
32
|
+
]);
|
|
33
|
+
/**
|
|
34
|
+
* The event kinds that actually CARRY a `user_sequence_number` in their
|
|
35
|
+
* BCS payload, and therefore consume a sequence slot on chain.
|
|
36
|
+
*
|
|
37
|
+
* WHY THIS GATE EXISTS. `CancelRfq` and `WithdrawQuote` have no
|
|
38
|
+
* `user_sequence_number` field at all (see `event-bcs.ts`
|
|
39
|
+
* `CancelRfqEvent` / `WithdrawQuoteEvent`) — their replay protection is
|
|
40
|
+
* the uniqueness of `rfq_id` / `quote_id`. But `sendEnvelope` used to
|
|
41
|
+
* advance `nextSeq` on ANY `ok === true`, so a single cancel or quote
|
|
42
|
+
* withdrawal pushed the local counter one ahead of the chain's. Every
|
|
43
|
+
* later trade then signed a seq the chain had already consumed, and the
|
|
44
|
+
* chain drops a replayed seq SILENTLY — `ok:true` at ingress, never
|
|
45
|
+
* committed. One cancel desynced every trade after it until reconnect.
|
|
46
|
+
*/
|
|
47
|
+
const CONSUMES_SEQ = new Set([
|
|
48
|
+
"SubmitRfq",
|
|
49
|
+
"PlaceQuote",
|
|
50
|
+
"AcceptQuote",
|
|
51
|
+
]);
|
|
52
|
+
export class DelegateSigner {
|
|
53
|
+
priv;
|
|
54
|
+
pub;
|
|
55
|
+
/** 32-byte Supra address = sha3_256(pubkey || 0x00). */
|
|
56
|
+
address;
|
|
57
|
+
/** Address as `0x`-prefixed lowercase hex. */
|
|
58
|
+
addressHex;
|
|
59
|
+
client;
|
|
60
|
+
nextSeq;
|
|
61
|
+
chainIdHash = null;
|
|
62
|
+
constructor(opts) {
|
|
63
|
+
this.priv = hexToBytes(stripHex(opts.delegatePrivKeyHex));
|
|
64
|
+
if (this.priv.length !== 32) {
|
|
65
|
+
throw new Error(`delegatePrivKeyHex must be 32 bytes (got ${this.priv.length})`);
|
|
66
|
+
}
|
|
67
|
+
this.pub = ed25519.getPublicKey(this.priv);
|
|
68
|
+
const addrInput = new Uint8Array(this.pub.length + 1);
|
|
69
|
+
addrInput.set(this.pub, 0);
|
|
70
|
+
addrInput[this.pub.length] = 0x00;
|
|
71
|
+
this.address = sha3_256(addrInput);
|
|
72
|
+
this.addressHex = "0x" + bytesToHex(this.address);
|
|
73
|
+
this.client = opts.client;
|
|
74
|
+
this.nextSeq = BigInt(0); // overwritten by loadSequenceFromChain()
|
|
75
|
+
}
|
|
76
|
+
/** Re-anchor the local sequence counter to the chain's expectation.
|
|
77
|
+
* Call on startup, on uncertainty, and after long network gaps. */
|
|
78
|
+
async loadSequenceFromChain() {
|
|
79
|
+
const next = await this.client.getSequenceNumber(this.addressHex);
|
|
80
|
+
this.nextSeq = BigInt(next);
|
|
81
|
+
return this.nextSeq;
|
|
82
|
+
}
|
|
83
|
+
/** Cached lookup of the chain id hash (constant per genesis). */
|
|
84
|
+
async ensureChainIdHash() {
|
|
85
|
+
if (this.chainIdHash)
|
|
86
|
+
return this.chainIdHash;
|
|
87
|
+
const ci = await this.client.getChainInfo();
|
|
88
|
+
this.chainIdHash = hexToBytes(stripHex(ci.chainIdHashHex));
|
|
89
|
+
return this.chainIdHash;
|
|
90
|
+
}
|
|
91
|
+
/** Current next-sequence-number this signer would use. Exposed
|
|
92
|
+
* for diagnostics and for adapters that need to forward seq into
|
|
93
|
+
* custom event payloads. */
|
|
94
|
+
getNextSeq() {
|
|
95
|
+
return this.nextSeq;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build a signed envelope from `event` and submit it to the
|
|
99
|
+
* matching dApp endpoint. Returns the raw `SubmitResult` plus the
|
|
100
|
+
* envelope bytes (handy for logging or replaying).
|
|
101
|
+
*
|
|
102
|
+
* The caller MUST pass an event whose `payload.*sequence_number*`
|
|
103
|
+
* matches `this.getNextSeq()` — we don't mutate the payload here
|
|
104
|
+
* because the field name differs by event type (`user_sequence_number`
|
|
105
|
+
* on most, etc.). Helper methods below (`placeQuote`, `submitRfq`,
|
|
106
|
+
* etc.) handle this for you.
|
|
107
|
+
*/
|
|
108
|
+
async sendEnvelope(event) {
|
|
109
|
+
const chainIdHash = await this.ensureChainIdHash();
|
|
110
|
+
const eventBcs = encodeUserEvent(event);
|
|
111
|
+
const signBytes = composeSignBytes(chainIdHash, eventBcs);
|
|
112
|
+
const sig = ed25519.sign(signBytes, this.priv);
|
|
113
|
+
const envelopeBcs = encodeEnvelopeBcs({
|
|
114
|
+
event_bcs: eventBcs,
|
|
115
|
+
signer_pubkey: this.pub,
|
|
116
|
+
signer_sig: sig,
|
|
117
|
+
});
|
|
118
|
+
const envelopeBcsHex = bytesToHex(envelopeBcs);
|
|
119
|
+
const { endpoint, bodyField } = routeForEvent(event.kind);
|
|
120
|
+
const res = await this.client.submitEnvelope(endpoint, bodyField, envelopeBcsHex);
|
|
121
|
+
// Only seq-BEARING events may move the counter. A cancel/withdraw
|
|
122
|
+
// returning ok:true must leave it exactly where it was.
|
|
123
|
+
if (CONSUMES_SEQ.has(event.kind)) {
|
|
124
|
+
if (res.ok === true) {
|
|
125
|
+
this.nextSeq = this.nextSeq + 1n;
|
|
126
|
+
}
|
|
127
|
+
else if (res.code && CHAIN_SAW_IT_CODES.has(res.code)) {
|
|
128
|
+
// Chain saw the envelope but rejected. Seq slot is consumed.
|
|
129
|
+
this.nextSeq = this.nextSeq + 1n;
|
|
130
|
+
}
|
|
131
|
+
// Otherwise (ingress-level reject): seq unchanged.
|
|
132
|
+
}
|
|
133
|
+
return { ...res, envelopeBcsHex };
|
|
134
|
+
}
|
|
135
|
+
// ─── Convenience methods that build the event + send ──────────
|
|
136
|
+
async submitRfq(payload) {
|
|
137
|
+
return await this.sendEnvelope({
|
|
138
|
+
kind: "SubmitRfq",
|
|
139
|
+
payload: {
|
|
140
|
+
user: this.address,
|
|
141
|
+
...payload,
|
|
142
|
+
user_sequence_number: this.nextSeq,
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async placeQuote(payload) {
|
|
147
|
+
return await this.sendEnvelope({
|
|
148
|
+
kind: "PlaceQuote",
|
|
149
|
+
payload: {
|
|
150
|
+
maker: this.address,
|
|
151
|
+
...payload,
|
|
152
|
+
user_sequence_number: this.nextSeq,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/** CancelRfq has no `user_sequence_number` — rfq_id uniqueness is
|
|
157
|
+
* the replay-protection invariant. The signer doesn't advance the
|
|
158
|
+
* seq counter for this event type. */
|
|
159
|
+
async cancelRfq(args) {
|
|
160
|
+
return await this.sendEnvelope({
|
|
161
|
+
kind: "CancelRfq",
|
|
162
|
+
payload: {
|
|
163
|
+
user: this.address,
|
|
164
|
+
rfq_id: args.rfq_id,
|
|
165
|
+
reason: args.reason,
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/** AcceptQuote: takes `quote_id` + `trade_id` (caller-supplied, used
|
|
170
|
+
* as the on-chain trade identity). Does NOT take `rfq_id`. */
|
|
171
|
+
async acceptQuote(args) {
|
|
172
|
+
return await this.sendEnvelope({
|
|
173
|
+
kind: "AcceptQuote",
|
|
174
|
+
payload: {
|
|
175
|
+
taker: this.address,
|
|
176
|
+
quote_id: args.quote_id,
|
|
177
|
+
trade_id: args.trade_id,
|
|
178
|
+
user_sequence_number: this.nextSeq,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
/** WithdrawQuote takes only `quote_id`. No sequence number — quote_id
|
|
183
|
+
* uniqueness is the replay-protection invariant. */
|
|
184
|
+
async withdrawQuote(args) {
|
|
185
|
+
return await this.sendEnvelope({
|
|
186
|
+
kind: "WithdrawQuote",
|
|
187
|
+
payload: {
|
|
188
|
+
maker: this.address,
|
|
189
|
+
quote_id: args.quote_id,
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
function routeForEvent(kind) {
|
|
195
|
+
switch (kind) {
|
|
196
|
+
case "SubmitRfq":
|
|
197
|
+
return { endpoint: "submit-rfq", bodyField: "submit_rfq_envelope_bcs_hex" };
|
|
198
|
+
case "PlaceQuote":
|
|
199
|
+
return { endpoint: "place-quote", bodyField: "place_quote_envelope_bcs_hex" };
|
|
200
|
+
case "AcceptQuote":
|
|
201
|
+
return { endpoint: "accept-quote", bodyField: "accept_quote_envelope_bcs_hex" };
|
|
202
|
+
case "WithdrawQuote":
|
|
203
|
+
return { endpoint: "withdraw-quote", bodyField: "withdraw_quote_envelope_bcs_hex" };
|
|
204
|
+
case "CancelRfq":
|
|
205
|
+
return { endpoint: "cancel-rfq", bodyField: "cancel_rfq_envelope_bcs_hex" };
|
|
206
|
+
default:
|
|
207
|
+
throw new Error(`routeForEvent: no endpoint for event kind ${kind}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function stripHex(s) {
|
|
211
|
+
return (s.startsWith("0x") || s.startsWith("0X") ? s.slice(2) : s).toLowerCase();
|
|
212
|
+
}
|
|
213
|
+
function hexToBytes(s) {
|
|
214
|
+
const stripped = stripHex(s);
|
|
215
|
+
if (stripped.length % 2 !== 0)
|
|
216
|
+
throw new Error("hex length must be even");
|
|
217
|
+
const out = new Uint8Array(stripped.length / 2);
|
|
218
|
+
for (let i = 0; i < out.length; i++) {
|
|
219
|
+
out[i] = parseInt(stripped.slice(i * 2, i * 2 + 2), 16);
|
|
220
|
+
}
|
|
221
|
+
return out;
|
|
222
|
+
}
|
|
223
|
+
function bytesToHex(b) {
|
|
224
|
+
return Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=signer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EACL,eAAe,GAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AAGzB;sEACsE;AACtE,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,eAAe;IACf,aAAa;CACd,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,YAAY,GAAmC,IAAI,GAAG,CAAC;IAC3D,WAAW;IACX,YAAY;IACZ,aAAa;CACd,CAAC,CAAC;AASH,MAAM,OAAO,cAAc;IACR,IAAI,CAAa;IACjB,GAAG,CAAa;IACjC,wDAAwD;IAC/C,OAAO,CAAa;IAC7B,8CAA8C;IACrC,UAAU,CAAS;IACX,MAAM,CAAgB;IAC/B,OAAO,CAAS;IAChB,WAAW,GAAsB,IAAI,CAAC;IAE9C,YAAY,IAA2B;QACrC,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC;QAC1D,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,EAAE,EAAE,CAAC;YAC5B,MAAM,IAAI,KAAK,CACb,4CAA4C,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAChE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3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,CAAC,CAAC,CAAC;IAChD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,GAAG,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,UAAU,CAAC,CAAa;IAC/B,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "suprafx-agent-sdk",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "SDK + MCP server for building autonomous agents on SupraFX",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/jtobkin/suprafx-agent-sdk.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://suprafx.ai/agents",
|
|
11
|
+
"bin": {
|
|
12
|
+
"suprafx-mcp": "dist/bin/suprafx-mcp.js"
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/src/index.js",
|
|
15
|
+
"types": "./dist/src/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": "./dist/src/index.js",
|
|
19
|
+
"types": "./dist/src/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./signer": {
|
|
22
|
+
"import": "./dist/src/signer.js",
|
|
23
|
+
"types": "./dist/src/signer.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./client": {
|
|
26
|
+
"import": "./dist/src/client.js",
|
|
27
|
+
"types": "./dist/src/client.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"prepublishOnly": "npm run build",
|
|
38
|
+
"mcp": "node dist/bin/suprafx-mcp.js",
|
|
39
|
+
"test": "npx tsx --test test/*.test.ts src/mcp/*.test.ts"
|
|
40
|
+
},
|
|
41
|
+
"type": "module",
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=18"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
47
|
+
"@noble/curves": "^1.6.0",
|
|
48
|
+
"@noble/hashes": "^1.5.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^22.0.0",
|
|
52
|
+
"eventsource": "^3.0.7",
|
|
53
|
+
"tsx": "^4.19.0",
|
|
54
|
+
"typescript": "^5.6.0"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [
|
|
57
|
+
"suprafx",
|
|
58
|
+
"mcp",
|
|
59
|
+
"model-context-protocol",
|
|
60
|
+
"trading",
|
|
61
|
+
"ai-agent",
|
|
62
|
+
"market-maker",
|
|
63
|
+
"bft"
|
|
64
|
+
]
|
|
65
|
+
}
|