@mantle-agent/client 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.
package/dist/http.js ADDED
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A failure with the Mantle Agent API's stable error code (or a local one such as NOT_CONNECTED or
3
+ * API_UNREACHABLE). React to `code`, not to the message.
4
+ */
5
+ export class ClientError extends Error {
6
+ code;
7
+ details;
8
+ status;
9
+ constructor(code, message, details, status) {
10
+ super(message);
11
+ this.code = code;
12
+ this.details = details;
13
+ this.status = status;
14
+ }
15
+ }
16
+ /** JSON request against the API; non-2xx responses become ClientError with the API's code. */
17
+ export async function request(fetchImpl, baseUrl, method, path, opts = {}) {
18
+ const headers = { ...opts.headers };
19
+ if (opts.body !== undefined)
20
+ headers["content-type"] = "application/json";
21
+ if (opts.token)
22
+ headers["authorization"] = `Bearer ${opts.token}`;
23
+ let res;
24
+ try {
25
+ res = await fetchImpl(`${baseUrl}${path}`, {
26
+ method,
27
+ headers,
28
+ ...(opts.body === undefined ? {} : { body: JSON.stringify(opts.body, (_k, v) => (typeof v === "bigint" ? v.toString() : v)) }),
29
+ });
30
+ }
31
+ catch (err) {
32
+ throw new ClientError("API_UNREACHABLE", `cannot reach ${baseUrl}`, { reason: String(err) });
33
+ }
34
+ const body = (await res.json().catch(() => ({})));
35
+ if (res.status >= 400) {
36
+ throw new ClientError(body.code ?? `HTTP_${res.status}`, body.message ?? res.statusText, body.details, res.status);
37
+ }
38
+ return { status: res.status, body };
39
+ }
40
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAEzB;IAEA;IACA;IAJX,YACW,IAAY,EACrB,OAAe,EACN,OAAiB,EACjB,MAAe;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QALN,SA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,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAA+D,CAAC;IAChH,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,QAAQ,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,OAAO,IAAI,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;AACtC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./http.js";
2
+ export * from "./agent.js";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Agent side (no Turnkey, no custody). Owner flows: "@mantle-agent/client/owner"; browser passkey: "@mantle-agent/client/browser".
2
+ export * from "./http.js";
3
+ export * from "./agent.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mIAAmI;AACnI,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,199 @@
1
+ import { type Address, type Hex, type SignedAuthorization } from "viem";
2
+ import { type RootSigner, type CallJson, type TransactionJson } from "@mantle-agent/core";
3
+ import { type OwnerApi, type PolicyIntent, type SignedTurnkeyRequest } from "@mantle-agent/custody/owner";
4
+ import type { OwnerRequest, RuntimeStatus } from "./agent.js";
5
+ export type { OwnerRequest, OwnerRequestKind, RuntimeStatus } from "./agent.js";
6
+ import { type Fetch } from "./http.js";
7
+ export { ClientError } from "./http.js";
8
+ /**
9
+ * Everything the owner does with Turnkey, on their own device and with their own credential (passkey in
10
+ * production). The platform is never involved in these calls. See `@mantle-agent/client/browser` for the passkey
11
+ * implementation.
12
+ */
13
+ export interface OwnerTurnkey {
14
+ readonly kind: "passkey" | "dev-key";
15
+ /** Creates the owner's credential for signup (passkey prompt in production). */
16
+ register(ownerName: string): Promise<SignupCredential>;
17
+ /** A whoami stamped against the parent org, so login works from any device. */
18
+ stampWhoami(): Promise<SignedTurnkeyRequest>;
19
+ /** The owner acting inside their sub-org (wallets, users, policies). */
20
+ owner(subOrgId: string): OwnerApi;
21
+ /** The agent EOA's root key, for the owner's signatures. */
22
+ rootSigner(subOrgId: string, address: Address): RootSigner;
23
+ }
24
+ /** What signup sends to the API: a passkey attestation, or (dev only) an API public key. */
25
+ export type SignupCredential = {
26
+ passkey: {
27
+ authenticatorName: string;
28
+ challenge: string;
29
+ attestation: unknown;
30
+ };
31
+ } | {
32
+ apiPublicKey: string;
33
+ };
34
+ /**
35
+ * The owner's side of the Mantle Agent API (the confirmation page backend). Holds the owner session once logged
36
+ * in; pass it to the flow functions below.
37
+ */
38
+ export declare class OwnerClient {
39
+ readonly baseUrl: string;
40
+ token: string | null;
41
+ private readonly fetchImpl;
42
+ constructor(baseUrl: string, fetchImpl?: Fetch);
43
+ call<T>(method: "GET" | "POST", path: string, body?: unknown): Promise<T>;
44
+ }
45
+ export type Platform = {
46
+ chainId: number;
47
+ caliburEntry: Address;
48
+ hook: Address;
49
+ targets: Address[];
50
+ executor: Address;
51
+ platformApiPublicKey: string;
52
+ turnkeyOrganizationId: string;
53
+ };
54
+ export type Owner = {
55
+ ownerId: string;
56
+ subOrgId: string;
57
+ turnkeyUserId: string;
58
+ daUserId: string | null;
59
+ custodyVerified: boolean;
60
+ };
61
+ export type Session = {
62
+ token: string;
63
+ expiresAt: string;
64
+ owner: Owner;
65
+ };
66
+ export declare const platform: (api: OwnerClient) => Promise<Platform>;
67
+ export declare function logIn(api: OwnerClient, tk: OwnerTurnkey): Promise<Session>;
68
+ /** New owner: create the credential (passkey prompt), let the API create the owner's Turnkey space, log in. */
69
+ export declare function signUp(api: OwnerClient, tk: OwnerTurnkey, ownerName: string): Promise<Session>;
70
+ /**
71
+ * One-time custody setup from the owner's own session: add the platform as a non-root user that can only sign
72
+ * what later policies allow, then have the API verify it with Turnkey.
73
+ */
74
+ export declare function ensureCustody(api: OwnerClient, tk: OwnerTurnkey, session: Session): Promise<Session>;
75
+ export type PendingClaim = {
76
+ claimId: string;
77
+ userCode: string;
78
+ agentName: string;
79
+ host: string;
80
+ fingerprint: string;
81
+ expiresAt: string;
82
+ /** Limits the agent proposed; after approval they come back as an authorize request (`requestId`). */
83
+ proposal: string[] | null;
84
+ };
85
+ export declare const lookupClaim: (api: OwnerClient, code: string) => Promise<PendingClaim>;
86
+ /**
87
+ * The owner checked the fingerprint against the CLI's: create the agent's own wallet in their space and approve.
88
+ * The API reads the wallet back from Turnkey before accepting it.
89
+ */
90
+ export declare function approveClaim(api: OwnerClient, tk: OwnerTurnkey, session: Session, claim: PendingClaim): Promise<{
91
+ agentId: string;
92
+ requestId: string | null;
93
+ }>;
94
+ export declare const getRequest: (api: OwnerClient, requestId: string) => Promise<OwnerRequest>;
95
+ export declare const pendingRequests: (api: OwnerClient) => Promise<OwnerRequest[]>;
96
+ export declare const rejectRequest: (api: OwnerClient, requestId: string) => Promise<OwnerRequest>;
97
+ /**
98
+ * The owner confirmed the summary. Signing kinds return the operation to run with `runOperation` (the same one
99
+ * again if the page was reloaded before it finished); auto-run kinds take effect right away (`prepared: null`).
100
+ */
101
+ export declare const approveRequest: (api: OwnerClient, requestId: string) => Promise<{
102
+ request: OwnerRequest;
103
+ prepared: PreparedOperation | null;
104
+ }>;
105
+ export type AgentSummary = {
106
+ agent_id: string;
107
+ name: string;
108
+ status: "pending" | "active" | "stopped";
109
+ account: Address | null;
110
+ balanceWei: string | null;
111
+ };
112
+ export declare const listAgents: (api: OwnerClient) => Promise<AgentSummary[]>;
113
+ /** PRD WAL-02 step 2 inputs for UIs that start an authorization themselves (MNT amounts in whole units). */
114
+ export type AuthorizeForm = {
115
+ perTradeMnt: string;
116
+ periodMnt: string;
117
+ totalMnt: string;
118
+ periodHours: number;
119
+ durationDays: number;
120
+ maxSlippagePercent: number;
121
+ };
122
+ export declare const DEFAULT_LIMITS: AuthorizeForm;
123
+ export type PreparedOperation = {
124
+ operationId: string;
125
+ kind: "authorize" | "renew" | "revoke" | "withdraw";
126
+ status: "prepared" | "submitted" | "confirmed" | "failed";
127
+ account: Address;
128
+ chainId: number;
129
+ call?: CallJson;
130
+ /** withdraw: a plain transaction from the agent account, paid by it. */
131
+ transaction?: TransactionJson;
132
+ authorization?: {
133
+ contractAddress: Address;
134
+ chainId: number;
135
+ nonce: number;
136
+ };
137
+ turnkeyPolicy?: PolicyIntent;
138
+ retirePolicyId?: string | null;
139
+ error: string | null;
140
+ };
141
+ export declare const prepareAuthorize: (api: OwnerClient, agentId: string, f: AuthorizeForm) => Promise<PreparedOperation>;
142
+ export declare const prepareRenew: (api: OwnerClient, agentId: string, durationDays: number) => Promise<PreparedOperation>;
143
+ export declare const prepareRevoke: (api: OwnerClient, agentId: string) => Promise<PreparedOperation>;
144
+ /** PRD WAL-06: MNT or a token, an exact amount (whole units, 18 decimals) or everything. */
145
+ export declare const prepareWithdraw: (api: OwnerClient, agentId: string, p: {
146
+ to: Address;
147
+ asset: "MNT" | Address;
148
+ amount: string | "max";
149
+ }) => Promise<PreparedOperation>;
150
+ /** Emergency stop: everything server-side now, plus the on-chain revoke to sign (null if no session). */
151
+ export declare const emergencyStop: (api: OwnerClient, agentId: string) => Promise<{
152
+ stopped: true;
153
+ revokedCredentials: number;
154
+ revoke: PreparedOperation | null;
155
+ }>;
156
+ export type StepName = "policy" | "authorization" | "signature" | "transaction" | "submit" | "confirm" | "cleanup";
157
+ export type StepState = {
158
+ name: StepName;
159
+ status: "todo" | "running" | "done" | "failed" | "skipped";
160
+ error?: string;
161
+ };
162
+ /** Progress of one operation; pass it back to `runOperation` to retry from the step that failed (PRD WEB-01). */
163
+ export type OperationRun = {
164
+ prepared: PreparedOperation;
165
+ steps: StepState[];
166
+ policyId?: string;
167
+ authorization?: SignedAuthorization;
168
+ signature?: Hex;
169
+ signedTransaction?: Hex;
170
+ };
171
+ export declare function startRun(prepared: PreparedOperation): OperationRun;
172
+ /**
173
+ * Executes the owner's part of an operation step by step. Completed steps are never repeated, so a retry after a
174
+ * failure does not create a second Turnkey policy or a second signature.
175
+ */
176
+ export declare function runOperation(api: OwnerClient, tk: OwnerTurnkey, session: Session, run: OperationRun, opts?: {
177
+ onChange?: (run: OperationRun) => void;
178
+ pollMs?: number;
179
+ timeoutMs?: number;
180
+ }): Promise<OperationRun>;
181
+ export declare const runSucceeded: (run: OperationRun) => boolean;
182
+ /** Human summary of what the owner is about to sign (PRD WAL-02 step 4: show before confirming). */
183
+ export declare function describeLimits(f: AuthorizeForm): string[];
184
+ export declare const formatMnt: (weiValue: string | bigint) => string;
185
+ /** Wizard step 3 inputs for scheduled runs. */
186
+ export type RuntimeForm = {
187
+ enabled: boolean;
188
+ intervalHours: number;
189
+ maxTradesPerRun: number;
190
+ maxTradesPerDay: number;
191
+ maxSpendPerDayMnt: string;
192
+ maxLlmCostPerDayUsd: number;
193
+ };
194
+ export declare const DEFAULT_RUNTIME_FORM: RuntimeForm;
195
+ export declare const getRuntime: (api: OwnerClient, agentId: string) => Promise<RuntimeStatus>;
196
+ export declare const configureRuntime: (api: OwnerClient, agentId: string, f: RuntimeForm) => Promise<RuntimeStatus>;
197
+ export declare const runtimeCommand: (api: OwnerClient, agentId: string, kind: "pause" | "resume" | "run_now") => Promise<{
198
+ commandId: string;
199
+ }>;
package/dist/owner.js ADDED
@@ -0,0 +1,237 @@
1
+ import { formatEther } from "viem";
2
+ import { callFromJson, sign7702Authorization, signedBatchedCallTypedData, transactionFromJson, } from "@mantle-agent/core";
3
+ import { addPlatformDelegate, createAgentWallet, } from "@mantle-agent/custody/owner";
4
+ import { request } from "./http.js";
5
+ export { ClientError } from "./http.js";
6
+ /**
7
+ * The owner's side of the Mantle Agent API (the confirmation page backend). Holds the owner session once logged
8
+ * in; pass it to the flow functions below.
9
+ */
10
+ export class OwnerClient {
11
+ baseUrl;
12
+ token = null;
13
+ fetchImpl;
14
+ constructor(baseUrl, fetchImpl) {
15
+ this.baseUrl = baseUrl;
16
+ this.fetchImpl = fetchImpl ?? ((...a) => fetch(...a));
17
+ }
18
+ async call(method, path, body) {
19
+ return (await request(this.fetchImpl, this.baseUrl, method, path, { token: this.token, body })).body;
20
+ }
21
+ }
22
+ export const platform = (api) => api.call("GET", "/v1/platform");
23
+ // ---------------------------------------------------------------------------------------------------------------
24
+ // Sign up / log in / custody
25
+ // ---------------------------------------------------------------------------------------------------------------
26
+ export async function logIn(api, tk) {
27
+ const session = await api.call("POST", "/v1/owner/login", await tk.stampWhoami());
28
+ api.token = session.token;
29
+ return session;
30
+ }
31
+ /** New owner: create the credential (passkey prompt), let the API create the owner's Turnkey space, log in. */
32
+ export async function signUp(api, tk, ownerName) {
33
+ const credential = await tk.register(ownerName);
34
+ await api.call("POST", "/v1/owner/signup", { ownerName, ...credential });
35
+ return logIn(api, tk);
36
+ }
37
+ /**
38
+ * One-time custody setup from the owner's own session: add the platform as a non-root user that can only sign
39
+ * what later policies allow, then have the API verify it with Turnkey.
40
+ */
41
+ export async function ensureCustody(api, tk, session) {
42
+ if (session.owner.custodyVerified)
43
+ return session;
44
+ const { platformApiPublicKey } = await platform(api);
45
+ const { daUserId } = await addPlatformDelegate(tk.owner(session.owner.subOrgId), {
46
+ subOrgId: session.owner.subOrgId,
47
+ platformApiPublicKey,
48
+ });
49
+ const owner = await api.call("POST", "/v1/owner/custody", { daUserId });
50
+ return { ...session, owner };
51
+ }
52
+ export const lookupClaim = (api, code) => api.call("GET", `/v1/owner/claims/${encodeURIComponent(code.trim().toUpperCase())}`);
53
+ /**
54
+ * The owner checked the fingerprint against the CLI's: create the agent's own wallet in their space and approve.
55
+ * The API reads the wallet back from Turnkey before accepting it.
56
+ */
57
+ export async function approveClaim(api, tk, session, claim) {
58
+ const wallet = await createAgentWallet(tk.owner(session.owner.subOrgId), {
59
+ subOrgId: session.owner.subOrgId,
60
+ agentId: claim.claimId,
61
+ });
62
+ return api.call("POST", `/v1/owner/claims/${claim.claimId}/approve`, { walletId: wallet.walletId, fingerprint: claim.fingerprint });
63
+ }
64
+ // ---------------------------------------------------------------------------------------------------------------
65
+ // Owner requests: the agent asks in chat, the owner confirms here (PRD WEB-01/03)
66
+ // ---------------------------------------------------------------------------------------------------------------
67
+ export const getRequest = (api, requestId) => api.call("GET", `/v1/owner/requests/${requestId}`);
68
+ export const pendingRequests = (api) => api.call("GET", "/v1/owner/requests");
69
+ export const rejectRequest = (api, requestId) => api.call("POST", `/v1/owner/requests/${requestId}/reject`);
70
+ /**
71
+ * The owner confirmed the summary. Signing kinds return the operation to run with `runOperation` (the same one
72
+ * again if the page was reloaded before it finished); auto-run kinds take effect right away (`prepared: null`).
73
+ */
74
+ export const approveRequest = (api, requestId) => api.call("POST", `/v1/owner/requests/${requestId}/approve`);
75
+ export const listAgents = (api) => api.call("GET", "/v1/owner/agents");
76
+ export const DEFAULT_LIMITS = {
77
+ perTradeMnt: "2",
78
+ periodMnt: "10",
79
+ totalMnt: "20",
80
+ periodHours: 24,
81
+ durationDays: 7,
82
+ maxSlippagePercent: 2,
83
+ };
84
+ const wei = (mnt) => {
85
+ if (!/^\d+(\.\d{1,18})?$/.test(mnt))
86
+ throw new Error(`invalid MNT amount: ${mnt}`);
87
+ const [whole, frac = ""] = mnt.split(".");
88
+ return (BigInt(whole) * 10n ** 18n + BigInt(frac.padEnd(18, "0"))).toString();
89
+ };
90
+ export const prepareAuthorize = (api, agentId, f) => api.call("POST", `/v1/owner/agents/${agentId}/authorize`, {
91
+ perTradeCap: wei(f.perTradeMnt),
92
+ periodCap: wei(f.periodMnt),
93
+ totalCap: wei(f.totalMnt),
94
+ periodSeconds: Math.round(f.periodHours * 3600),
95
+ durationSeconds: Math.round(f.durationDays * 86_400),
96
+ maxSlippageBps: Math.round(f.maxSlippagePercent * 100),
97
+ });
98
+ export const prepareRenew = (api, agentId, durationDays) => api.call("POST", `/v1/owner/agents/${agentId}/renew`, { durationSeconds: Math.round(durationDays * 86_400) });
99
+ export const prepareRevoke = (api, agentId) => api.call("POST", `/v1/owner/agents/${agentId}/revoke`);
100
+ /** PRD WAL-06: MNT or a token, an exact amount (whole units, 18 decimals) or everything. */
101
+ export const prepareWithdraw = (api, agentId, p) => api.call("POST", `/v1/owner/agents/${agentId}/withdraw`, {
102
+ to: p.to,
103
+ asset: p.asset,
104
+ amount: p.amount === "max" ? "max" : wei(p.amount),
105
+ });
106
+ /** Emergency stop: everything server-side now, plus the on-chain revoke to sign (null if no session). */
107
+ export const emergencyStop = (api, agentId) => api.call("POST", `/v1/owner/agents/${agentId}/stop`);
108
+ export function startRun(prepared) {
109
+ if (prepared.transaction) {
110
+ return {
111
+ prepared,
112
+ steps: [
113
+ { name: "transaction", status: "todo" },
114
+ { name: "submit", status: "todo" },
115
+ { name: "confirm", status: "todo" },
116
+ ],
117
+ };
118
+ }
119
+ const steps = [
120
+ { name: "policy", status: prepared.turnkeyPolicy ? "todo" : "skipped" },
121
+ { name: "authorization", status: prepared.authorization ? "todo" : "skipped" },
122
+ { name: "signature", status: "todo" },
123
+ { name: "submit", status: "todo" },
124
+ { name: "confirm", status: "todo" },
125
+ { name: "cleanup", status: prepared.retirePolicyId ? "todo" : "skipped" },
126
+ ];
127
+ return { prepared, steps };
128
+ }
129
+ /**
130
+ * Executes the owner's part of an operation step by step. Completed steps are never repeated, so a retry after a
131
+ * failure does not create a second Turnkey policy or a second signature.
132
+ */
133
+ export async function runOperation(api, tk, session, run, opts = {}) {
134
+ const { prepared } = run;
135
+ const subOrgId = session.owner.subOrgId;
136
+ const root = () => tk.rootSigner(subOrgId, prepared.account);
137
+ const owner = tk.owner(subOrgId);
138
+ let state = { ...run, steps: run.steps.map((s) => ({ ...s })) };
139
+ const set = (name, patch) => {
140
+ state = { ...state, steps: state.steps.map((s) => (s.name === name ? { ...s, ...patch } : s)) };
141
+ opts.onChange?.(state);
142
+ };
143
+ const actions = {
144
+ policy: async () => {
145
+ const { policyIds } = await owner.createPolicies({ organizationId: subOrgId, policies: [prepared.turnkeyPolicy] });
146
+ state = { ...state, policyId: policyIds[0] };
147
+ },
148
+ authorization: async () => {
149
+ const a = prepared.authorization;
150
+ state = { ...state, authorization: await sign7702Authorization(root(), { chainId: a.chainId, nonce: a.nonce }) };
151
+ },
152
+ signature: async () => {
153
+ const typed = signedBatchedCallTypedData({ account: prepared.account, chainId: prepared.chainId }, callFromJson(prepared.call));
154
+ state = { ...state, signature: await root().signTypedData(typed) };
155
+ },
156
+ transaction: async () => {
157
+ state = { ...state, signedTransaction: await root().signTransaction(transactionFromJson(prepared.transaction)) };
158
+ },
159
+ submit: async () => {
160
+ if (state.signedTransaction) {
161
+ await api.call("POST", `/v1/owner/operations/${prepared.operationId}/submit`, { signedTransaction: state.signedTransaction });
162
+ return;
163
+ }
164
+ const a = state.authorization;
165
+ await api.call("POST", `/v1/owner/operations/${prepared.operationId}/submit`, {
166
+ signature: state.signature,
167
+ ...(state.policyId ? { policyId: state.policyId } : {}),
168
+ ...(a ? { authorization: { address: a.address, chainId: a.chainId, nonce: a.nonce, r: a.r, s: a.s, yParity: a.yParity } } : {}),
169
+ });
170
+ },
171
+ confirm: async () => {
172
+ const deadline = Date.now() + (opts.timeoutMs ?? 120_000);
173
+ for (;;) {
174
+ const op = await api.call("GET", `/v1/owner/operations/${prepared.operationId}`);
175
+ if (op.status === "confirmed")
176
+ return;
177
+ if (op.status === "failed")
178
+ throw new Error(op.error ?? "operation failed on chain");
179
+ if (Date.now() > deadline)
180
+ throw new Error("still waiting for the chain; check again shortly");
181
+ await new Promise((r) => setTimeout(r, opts.pollMs ?? 1_500));
182
+ }
183
+ },
184
+ // Renew: drop the policy the new one replaced. Revoke: drop the session policy so Turnkey stops signing too.
185
+ cleanup: async () => {
186
+ await owner.deletePolicies({ organizationId: subOrgId, policyIds: [prepared.retirePolicyId] });
187
+ },
188
+ };
189
+ for (const step of state.steps) {
190
+ if (step.status === "done" || step.status === "skipped")
191
+ continue;
192
+ set(step.name, { status: "running", error: undefined });
193
+ try {
194
+ await actions[step.name]();
195
+ set(step.name, { status: "done" });
196
+ }
197
+ catch (err) {
198
+ set(step.name, { status: "failed", error: err instanceof Error ? err.message : String(err) });
199
+ return state;
200
+ }
201
+ }
202
+ return state;
203
+ }
204
+ export const runSucceeded = (run) => run.steps.every((s) => s.status === "done" || s.status === "skipped");
205
+ /** Human summary of what the owner is about to sign (PRD WAL-02 step 4: show before confirming). */
206
+ export function describeLimits(f) {
207
+ return [
208
+ `每笔最多 ${f.perTradeMnt} MNT`,
209
+ `每 ${f.periodHours} 小时最多 ${f.periodMnt} MNT`,
210
+ `总共最多 ${f.totalMnt} MNT(卖出不会恢复额度)`,
211
+ `有效期 ${f.durationDays} 天`,
212
+ `最大滑点 ${f.maxSlippagePercent}%`,
213
+ "只能买卖白名单协议上的代币,只能卖出本次授权期间买入的代币",
214
+ "不能提现、不能修改权限",
215
+ ];
216
+ }
217
+ export const formatMnt = (weiValue) => `${formatEther(BigInt(weiValue))} MNT`;
218
+ export const DEFAULT_RUNTIME_FORM = {
219
+ enabled: false,
220
+ intervalHours: 1,
221
+ maxTradesPerRun: 2,
222
+ maxTradesPerDay: 10,
223
+ maxSpendPerDayMnt: "5",
224
+ maxLlmCostPerDayUsd: 5,
225
+ };
226
+ export const getRuntime = (api, agentId) => api.call("GET", `/v1/owner/agents/${agentId}/runtime`);
227
+ export const configureRuntime = (api, agentId, f) => api.call("POST", `/v1/owner/agents/${agentId}/runtime`, {
228
+ enabled: f.enabled,
229
+ intervalSeconds: Math.round(f.intervalHours * 3600),
230
+ maxRunSeconds: Math.min(600, Math.round(f.intervalHours * 3600)),
231
+ maxTradesPerRun: f.maxTradesPerRun,
232
+ maxTradesPerDay: f.maxTradesPerDay,
233
+ maxSpendPerDay: wei(f.maxSpendPerDayMnt),
234
+ maxLlmCostPerDayUsd: f.maxLlmCostPerDayUsd,
235
+ });
236
+ export const runtimeCommand = (api, agentId, kind) => api.call("POST", `/v1/owner/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ED
@@ -1,6 +1,85 @@
1
1
  {
2
2
  "name": "@mantle-agent/client",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Client SDK for Mantle Agent Accounts: the agent side (trade, status, scheduled runs) and the owner side (passkey custody, claims, authorize/renew/revoke/withdraw).",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mantle-xyz/mantle-agentic-meme-launchpad-account.git"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "source": "./src/index.ts",
16
+ "types": "./dist/index.d.ts",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./owner": {
20
+ "source": "./src/owner.ts",
21
+ "types": "./dist/owner.d.ts",
22
+ "default": "./dist/owner.js"
23
+ },
24
+ "./browser": {
25
+ "source": "./src/browser.ts",
26
+ "types": "./dist/browser.d.ts",
27
+ "default": "./dist/browser.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist",
32
+ "src",
33
+ "README.md"
34
+ ],
35
+ "sideEffects": false,
36
+ "engines": {
37
+ "node": ">=20"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "dependencies": {},
43
+ "peerDependencies": {
44
+ "viem": "^2.57.14",
45
+ "@turnkey/api-key-stamper": "^0.6.18",
46
+ "@turnkey/crypto": "^2.13.3",
47
+ "@turnkey/sdk-browser": "^8.7.1",
48
+ "@mantle-agent/core": "0.1.0",
49
+ "@mantle-agent/custody": "0.1.0"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "@mantle-agent/core": {
53
+ "optional": true
54
+ },
55
+ "@mantle-agent/custody": {
56
+ "optional": true
57
+ },
58
+ "viem": {
59
+ "optional": true
60
+ },
61
+ "@turnkey/sdk-browser": {
62
+ "optional": true
63
+ },
64
+ "@turnkey/api-key-stamper": {
65
+ "optional": true
66
+ },
67
+ "@turnkey/crypto": {
68
+ "optional": true
69
+ }
70
+ },
71
+ "devDependencies": {
72
+ "@turnkey/api-key-stamper": "^0.6.18",
73
+ "@turnkey/crypto": "^2.13.3",
74
+ "@turnkey/sdk-browser": "^8.7.1",
75
+ "@types/node": "^22.20.5",
76
+ "typescript": "^5.9.3",
77
+ "viem": "^2.57.14",
78
+ "@mantle-agent/core": "0.1.0",
79
+ "@mantle-agent/custody": "0.1.0"
80
+ },
81
+ "scripts": {
82
+ "build": "tsc -p tsconfig.json",
83
+ "typecheck": "tsc -p tsconfig.json --noEmit"
84
+ }
6
85
  }