agentex-creator-sdk 1.0.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/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +195 -0
- package/dist/packages/contracts/src/deployer-investigation.d.ts +1015 -0
- package/dist/packages/contracts/src/deployer-investigation.js +101 -0
- package/dist/packages/contracts/src/index.d.ts +1701 -0
- package/dist/packages/contracts/src/index.js +380 -0
- package/dist/packages/contracts/src/indexed-activity.d.ts +684 -0
- package/dist/packages/contracts/src/indexed-activity.js +71 -0
- package/dist/packages/contracts/src/indexed-agents.d.ts +299 -0
- package/dist/packages/contracts/src/indexed-agents.js +131 -0
- package/dist/packages/contracts/src/inspection.d.ts +906 -0
- package/dist/packages/contracts/src/inspection.js +114 -0
- package/dist/packages/contracts/src/kinds.d.ts +5398 -0
- package/dist/packages/contracts/src/kinds.js +156 -0
- package/dist/packages/contracts/src/report-presentation.d.ts +346 -0
- package/dist/packages/contracts/src/report-presentation.js +120 -0
- package/dist/packages/contracts/src/solana-inspection.d.ts +451 -0
- package/dist/packages/contracts/src/solana-inspection.js +94 -0
- package/dist/packages/contracts/src/token-market.d.ts +193 -0
- package/dist/packages/contracts/src/token-market.js +335 -0
- package/dist/packages/contracts/src/wallet-analysis.d.ts +866 -0
- package/dist/packages/contracts/src/wallet-analysis.js +89 -0
- package/dist/packages/contracts/src/watchtower.d.ts +1141 -0
- package/dist/packages/contracts/src/watchtower.js +196 -0
- package/dist/packages/contracts/src/workflow.d.ts +1568 -0
- package/dist/packages/contracts/src/workflow.js +651 -0
- package/dist/packages/inspector/src/decode.d.ts +23 -0
- package/dist/packages/inspector/src/decode.js +150 -0
- package/dist/packages/inspector/src/scope.d.ts +87 -0
- package/dist/packages/inspector/src/scope.js +64 -0
- package/dist/packages/model/src/analysis.d.ts +149 -0
- package/dist/packages/model/src/analysis.js +387 -0
- package/dist/packages/model/src/pricing.d.ts +38 -0
- package/dist/packages/model/src/pricing.js +49 -0
- package/dist/packages/model/src/retry.d.ts +20 -0
- package/dist/packages/model/src/retry.js +31 -0
- package/dist/packages/model/src/schema.d.ts +10 -0
- package/dist/packages/model/src/schema.js +51 -0
- package/dist/packages/model/src/summary.d.ts +91 -0
- package/dist/packages/model/src/summary.js +177 -0
- package/dist/packages/model/src/types.d.ts +81 -0
- package/dist/packages/model/src/types.js +19 -0
- package/dist/packages/monitoring/src/delivery.d.ts +32 -0
- package/dist/packages/monitoring/src/delivery.js +53 -0
- package/dist/packages/providers/src/chain-transport.d.ts +42 -0
- package/dist/packages/providers/src/chain-transport.js +57 -0
- package/dist/packages/providers/src/coverage.d.ts +105 -0
- package/dist/packages/providers/src/coverage.js +260 -0
- package/dist/packages/providers/src/health.d.ts +273 -0
- package/dist/packages/providers/src/health.js +505 -0
- package/dist/packages/providers/src/keyed.d.ts +96 -0
- package/dist/packages/providers/src/keyed.js +240 -0
- package/dist/packages/providers/src/snapshot.d.ts +61 -0
- package/dist/packages/providers/src/snapshot.js +77 -0
- package/dist/packages/publication/src/fixtures.d.ts +45 -0
- package/dist/packages/publication/src/fixtures.js +350 -0
- package/dist/packages/research/src/index.d.ts +188 -0
- package/dist/packages/research/src/index.js +829 -0
- package/dist/packages/runtime/src/checkpoints.d.ts +65 -0
- package/dist/packages/runtime/src/checkpoints.js +214 -0
- package/dist/packages/runtime/src/policy.d.ts +57 -0
- package/dist/packages/runtime/src/policy.js +296 -0
- package/dist/packages/sdk/src/bin/agentex-buyer.d.ts +2 -0
- package/dist/packages/sdk/src/bin/agentex-buyer.js +4 -0
- package/dist/packages/sdk/src/bin/agentex.d.ts +2 -0
- package/dist/packages/sdk/src/bin/agentex.js +3 -0
- package/dist/packages/sdk/src/buyer-cli.d.ts +10 -0
- package/dist/packages/sdk/src/buyer-cli.js +210 -0
- package/dist/packages/sdk/src/buyer.d.ts +534 -0
- package/dist/packages/sdk/src/buyer.js +441 -0
- package/dist/packages/sdk/src/cli.d.ts +14 -0
- package/dist/packages/sdk/src/cli.js +149 -0
- package/dist/packages/sdk/src/errors.d.ts +31 -0
- package/dist/packages/sdk/src/errors.js +24 -0
- package/dist/packages/sdk/src/index.d.ts +236 -0
- package/dist/packages/sdk/src/index.js +150 -0
- package/dist/packages/sdk/src/local.d.ts +11 -0
- package/dist/packages/sdk/src/local.js +110 -0
- package/dist/packages/sdk/src/rails.d.ts +59 -0
- package/dist/packages/sdk/src/rails.js +96 -0
- package/dist/packages/sdk/src/report.d.ts +121 -0
- package/dist/packages/sdk/src/report.js +114 -0
- package/dist/packages/sdk/src/version.d.ts +2 -0
- package/dist/packages/sdk/src/version.js +2 -0
- package/dist/packages/watchtower/src/index.d.ts +150 -0
- package/dist/packages/watchtower/src/index.js +786 -0
- package/dist/packages/workflow/src/registry.d.ts +61 -0
- package/dist/packages/workflow/src/registry.js +76 -0
- package/examples/README.md +34 -0
- package/examples/cli-usage.sh +30 -0
- package/examples/fixtures/base-weth-input.json +4 -0
- package/examples/focused-researcher.json +127 -0
- package/examples/pay-with-eth-robinhood.mts +37 -0
- package/examples/pay-with-usdc.mts +41 -0
- package/examples/quickstart.mts +73 -0
- package/package.json +50 -0
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type BuyerProfile, type PaymentAsset } from './rails.js';
|
|
3
|
+
import { type ResearchReport } from './report.js';
|
|
4
|
+
export { AgentexApiError, isAgentexApiError, type BuyerErrorKind } from './errors.js';
|
|
5
|
+
export * from './rails.js';
|
|
6
|
+
export * from './report.js';
|
|
7
|
+
/**
|
|
8
|
+
* Typed buyer SDK for the AGENTEX buyer API (https://agentex.sh). It sends only `Authorization: Bearer <key>`, never cookies, never follows
|
|
9
|
+
* redirects and never includes the API key in an error. Plain HTTP is allowed only to loopback origins. Payment rails are chosen by asset id
|
|
10
|
+
* (SOL first; USDC on Solana; ETH on Robinhood Chain), and an API key is bound to one of them.
|
|
11
|
+
*/
|
|
12
|
+
export declare const BUYER_SDK_VERSION = "1.0.0";
|
|
13
|
+
/** The production API origin. The buyer API is served from the site's own origin. */
|
|
14
|
+
export declare const DEFAULT_API_ORIGIN = "https://agentex.sh";
|
|
15
|
+
export declare const API_KEY_PATTERN: RegExp;
|
|
16
|
+
export declare const IdempotencyKeySchema: z.ZodString;
|
|
17
|
+
/** The public catalog's offer filter: SOL or USDC on the Solana rail, ETH custody, or SIM on local rehearsal servers. */
|
|
18
|
+
export type CatalogProfile = BuyerProfile;
|
|
19
|
+
/** Chains an agent can analyse. The payment rail is independent of the analysed chain. */
|
|
20
|
+
export type ChainKey = 'ethereum' | 'base' | 'robinhood' | 'solana';
|
|
21
|
+
/** Marketplace topics (the catalog's controlled vocabulary; `topic` filter). */
|
|
22
|
+
export declare const CATALOG_TOPICS: readonly ["token-intelligence", "contract-forensics", "wallet-intelligence", "transaction-safety", "monitoring", "defi", "liquidity", "lending-yield", "staking", "stablecoins", "governance", "treasuries", "rwa", "bridges", "chain-activity", "launches", "nfts", "security"];
|
|
23
|
+
export type CatalogTopic = typeof CATALOG_TOPICS[number];
|
|
24
|
+
export type AgentCategory = 'token_research' | 'transaction_inspection' | 'monitoring' | 'custom_workflow' | 'deployer_investigation' | 'wallet_analysis';
|
|
25
|
+
/** Research workflows (most catalog agents) take named values. Read `getAgent(id).inputFields` for the names, types and options. */
|
|
26
|
+
export interface WorkflowQuoteInput {
|
|
27
|
+
workflow: 'agentex.workflow.v1';
|
|
28
|
+
chain: ChainKey;
|
|
29
|
+
values: Record<string, string | number | boolean>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Run input. Research workflows: `workflowInput(chain, values)`. Token Researcher and the other EVM kinds: `{ chain, address }` (or their named
|
|
33
|
+
* fields such as `contract` or `wallet`). The Solana Transaction Inspector: `{ analysisChain: 'solana', ... }`.
|
|
34
|
+
*/
|
|
35
|
+
export type QuoteInput = WorkflowQuoteInput | {
|
|
36
|
+
chain: string;
|
|
37
|
+
[field: string]: unknown;
|
|
38
|
+
} | {
|
|
39
|
+
analysisChain: 'solana';
|
|
40
|
+
[field: string]: unknown;
|
|
41
|
+
};
|
|
42
|
+
/** Builds a research-workflow input: `workflowInput('solana', { mint })`. */
|
|
43
|
+
export declare function workflowInput(chain: ChainKey, values: Record<string, string | number | boolean>): WorkflowQuoteInput;
|
|
44
|
+
export type BuyerScope = 'catalog:read' | 'quotes:write' | 'runs:read' | 'runs:cancel' | 'billing:read' | 'monitors:read' | 'monitors:write';
|
|
45
|
+
export interface BuyerKey {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
prefix: string;
|
|
49
|
+
last4: string;
|
|
50
|
+
scopes: BuyerScope[];
|
|
51
|
+
profile: BuyerProfile;
|
|
52
|
+
assetId: string;
|
|
53
|
+
listingIds: string[] | null;
|
|
54
|
+
spendLimitAtomic: string;
|
|
55
|
+
spendUsedAtomic: string;
|
|
56
|
+
remainingSpendAtomic: string;
|
|
57
|
+
rateLimitPerMinute: number;
|
|
58
|
+
requestsLast24h: number;
|
|
59
|
+
createdAt: string;
|
|
60
|
+
expiresAt: string;
|
|
61
|
+
lastUsedAt: string | null;
|
|
62
|
+
revokedAt: string | null;
|
|
63
|
+
status: 'active' | 'expired' | 'revoked';
|
|
64
|
+
}
|
|
65
|
+
export interface OfferPricing {
|
|
66
|
+
/** The per-run price cap: the most one run can reserve, in the offer's asset. */
|
|
67
|
+
maximumBuyerDebitAtomic: string;
|
|
68
|
+
grossCreatorFeeAtomic: string;
|
|
69
|
+
maxExecutionChargeAtomic: string;
|
|
70
|
+
platformFeeAtomic: string;
|
|
71
|
+
creatorCreditAtomic: string;
|
|
72
|
+
assetId: string;
|
|
73
|
+
currencyLabel?: string;
|
|
74
|
+
revision?: number;
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
}
|
|
77
|
+
/** One payment rail a listing accepts. A listing can accept SOL, USDC and ETH at once. */
|
|
78
|
+
export interface AgentOffer {
|
|
79
|
+
profile: BuyerProfile;
|
|
80
|
+
label: string;
|
|
81
|
+
currencyLabel: string;
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
purchasePath: string;
|
|
84
|
+
pricing: OfferPricing;
|
|
85
|
+
}
|
|
86
|
+
export interface AgentSummary {
|
|
87
|
+
listingId: string;
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
/** Chains this server covers for the agent (declared chains it cannot run are in `availability.unavailableChains`). */
|
|
91
|
+
chains: string[];
|
|
92
|
+
ownership: 'first-party' | 'independent';
|
|
93
|
+
creatorLabel: string;
|
|
94
|
+
creator?: {
|
|
95
|
+
profileId: string;
|
|
96
|
+
displayName: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
category?: {
|
|
100
|
+
id: AgentCategory;
|
|
101
|
+
label: string;
|
|
102
|
+
};
|
|
103
|
+
priceStructure?: {
|
|
104
|
+
id: 'per_run' | 'per_monitoring_window';
|
|
105
|
+
label: string;
|
|
106
|
+
};
|
|
107
|
+
permissionLevel?: {
|
|
108
|
+
id: 'read_only' | 'proposes_transactions' | 'sends_notifications';
|
|
109
|
+
label: string;
|
|
110
|
+
};
|
|
111
|
+
topics?: {
|
|
112
|
+
id: string;
|
|
113
|
+
label: string;
|
|
114
|
+
}[];
|
|
115
|
+
topicsDeclared?: boolean;
|
|
116
|
+
/** Set for listings bought as something other than a run (a Watchtower monitor, created on the website). */
|
|
117
|
+
action?: {
|
|
118
|
+
kind: 'monitor';
|
|
119
|
+
label: string;
|
|
120
|
+
href: string;
|
|
121
|
+
};
|
|
122
|
+
review: {
|
|
123
|
+
status: string;
|
|
124
|
+
label: string;
|
|
125
|
+
scope: string;
|
|
126
|
+
[key: string]: unknown;
|
|
127
|
+
};
|
|
128
|
+
offers: AgentOffer[];
|
|
129
|
+
availability: {
|
|
130
|
+
available: boolean;
|
|
131
|
+
reasons: string[];
|
|
132
|
+
unavailableChains?: {
|
|
133
|
+
chain: string;
|
|
134
|
+
label: string;
|
|
135
|
+
reason: string;
|
|
136
|
+
}[];
|
|
137
|
+
};
|
|
138
|
+
versionNumber: number;
|
|
139
|
+
createdAt: string;
|
|
140
|
+
ratings?: Record<string, unknown>;
|
|
141
|
+
}
|
|
142
|
+
export interface AgentInputField {
|
|
143
|
+
name: string;
|
|
144
|
+
type: string;
|
|
145
|
+
description: string;
|
|
146
|
+
required: boolean;
|
|
147
|
+
options: (string | number | boolean)[] | null;
|
|
148
|
+
}
|
|
149
|
+
export interface AgentDetail extends AgentSummary {
|
|
150
|
+
task: {
|
|
151
|
+
description: string;
|
|
152
|
+
scope: string;
|
|
153
|
+
output: string;
|
|
154
|
+
};
|
|
155
|
+
permissions: {
|
|
156
|
+
id: string;
|
|
157
|
+
label: string;
|
|
158
|
+
detail: string;
|
|
159
|
+
}[];
|
|
160
|
+
limits: {
|
|
161
|
+
maximumRpcCalls: number;
|
|
162
|
+
maximumDurationMs: number;
|
|
163
|
+
maximumOutputBytes: number;
|
|
164
|
+
};
|
|
165
|
+
inputFields: AgentInputField[];
|
|
166
|
+
resultPolicies: {
|
|
167
|
+
policy: string;
|
|
168
|
+
id: string;
|
|
169
|
+
description: string;
|
|
170
|
+
default: boolean;
|
|
171
|
+
}[];
|
|
172
|
+
refundPolicy: string[];
|
|
173
|
+
limitations: string[];
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
}
|
|
176
|
+
export interface AgentPage {
|
|
177
|
+
agents: AgentSummary[];
|
|
178
|
+
nextCursor: string | null;
|
|
179
|
+
/** Listings matching the query across every page. */ total?: number;
|
|
180
|
+
/** True when the query reached the server's scan bound (newest 1,000 public listings). */ truncated?: boolean;
|
|
181
|
+
sort?: 'newest' | 'name' | 'price';
|
|
182
|
+
environment?: {
|
|
183
|
+
kind: string;
|
|
184
|
+
notice: string;
|
|
185
|
+
[key: string]: unknown;
|
|
186
|
+
};
|
|
187
|
+
[key: string]: unknown;
|
|
188
|
+
}
|
|
189
|
+
export interface AgentQuery {
|
|
190
|
+
/** Searches names and descriptions; a topic name also matches by topic. */ q?: string;
|
|
191
|
+
chain?: ChainKey | (string & {});
|
|
192
|
+
ownership?: 'first-party' | 'independent';
|
|
193
|
+
review?: 'reviewed' | 'any';
|
|
194
|
+
/** Only listings that offer this payment profile. */ profile?: CatalogProfile;
|
|
195
|
+
/** Only listings that accept this asset (sets `profile`). */ assetId?: string;
|
|
196
|
+
available?: 'true' | 'false' | boolean;
|
|
197
|
+
category?: AgentCategory | (string & {});
|
|
198
|
+
priceStructure?: 'per_run' | 'per_monitoring_window';
|
|
199
|
+
permission?: 'read_only' | 'proposes_transactions' | 'sends_notifications';
|
|
200
|
+
topic?: CatalogTopic | (string & {});
|
|
201
|
+
/** Server-side order over every matching listing. */ sort?: 'newest' | 'name' | 'price';
|
|
202
|
+
/** 1 to 50 (default 20). */ limit?: number;
|
|
203
|
+
cursor?: string;
|
|
204
|
+
}
|
|
205
|
+
export interface Quote {
|
|
206
|
+
id: string;
|
|
207
|
+
contractHash: string;
|
|
208
|
+
/** The most this run can reserve, in atomic units of `asset`. */ maximumBuyerDebitAtomic: string;
|
|
209
|
+
expiresAt: string;
|
|
210
|
+
/** The ledger asset the quote is priced in; `assetIdOf(quote.asset)` gives its asset id. */ asset?: Record<string, unknown>;
|
|
211
|
+
currencyLabel?: string;
|
|
212
|
+
grossCreatorFeeAtomic?: string;
|
|
213
|
+
platformFeeAtomic?: string;
|
|
214
|
+
creatorCreditAtomic?: string;
|
|
215
|
+
maxExecutionChargeAtomic?: string;
|
|
216
|
+
feeBps?: number;
|
|
217
|
+
resultPolicy?: string;
|
|
218
|
+
resultContract?: {
|
|
219
|
+
id: string;
|
|
220
|
+
description: string;
|
|
221
|
+
[key: string]: unknown;
|
|
222
|
+
};
|
|
223
|
+
input?: unknown;
|
|
224
|
+
notice?: string;
|
|
225
|
+
agentKind?: string;
|
|
226
|
+
[key: string]: unknown;
|
|
227
|
+
}
|
|
228
|
+
export type RunStatus = 'queued' | 'running' | 'succeeded' | 'partial' | 'failed' | 'cancelled';
|
|
229
|
+
export interface Run {
|
|
230
|
+
id: string;
|
|
231
|
+
versionId: string;
|
|
232
|
+
status: RunStatus;
|
|
233
|
+
input: unknown;
|
|
234
|
+
output: Record<string, unknown> | null;
|
|
235
|
+
error: unknown;
|
|
236
|
+
mode: string;
|
|
237
|
+
rpcUsed: number;
|
|
238
|
+
createdAt: string;
|
|
239
|
+
updatedAt: string;
|
|
240
|
+
[key: string]: unknown;
|
|
241
|
+
}
|
|
242
|
+
export interface RunEvent {
|
|
243
|
+
id: string;
|
|
244
|
+
step: string;
|
|
245
|
+
message: string;
|
|
246
|
+
createdAt: string;
|
|
247
|
+
}
|
|
248
|
+
export interface RunState {
|
|
249
|
+
run: Run;
|
|
250
|
+
events: RunEvent[];
|
|
251
|
+
}
|
|
252
|
+
export interface Acceptance {
|
|
253
|
+
run: Run;
|
|
254
|
+
reservation: {
|
|
255
|
+
id: string;
|
|
256
|
+
maximumAtomic: string;
|
|
257
|
+
[key: string]: unknown;
|
|
258
|
+
};
|
|
259
|
+
notice: string;
|
|
260
|
+
idempotencyKey: string;
|
|
261
|
+
}
|
|
262
|
+
export interface Settlement {
|
|
263
|
+
reservationId: string;
|
|
264
|
+
outcome: 'succeeded' | 'partial' | 'failed' | 'cancelled' | 'expired';
|
|
265
|
+
chargedAtomic: string;
|
|
266
|
+
creatorFeeAtomic: string;
|
|
267
|
+
platformFeeAtomic: string;
|
|
268
|
+
executionChargeAtomic: string;
|
|
269
|
+
[key: string]: unknown;
|
|
270
|
+
}
|
|
271
|
+
export interface Billing {
|
|
272
|
+
runId: string;
|
|
273
|
+
reservationId: string;
|
|
274
|
+
quoteId: string;
|
|
275
|
+
status: 'reserved' | 'pending' | 'settled';
|
|
276
|
+
settlement: Settlement | null;
|
|
277
|
+
pendingReason: string | null;
|
|
278
|
+
modelCost?: Record<string, unknown> | null;
|
|
279
|
+
authorizedRpcCalls?: number;
|
|
280
|
+
reconciledRpcCalls?: number;
|
|
281
|
+
unresolvedRpcCalls?: number;
|
|
282
|
+
notice?: string;
|
|
283
|
+
[key: string]: unknown;
|
|
284
|
+
}
|
|
285
|
+
export interface RunResult {
|
|
286
|
+
artifactId: string | null;
|
|
287
|
+
run: Run;
|
|
288
|
+
version: Record<string, unknown>;
|
|
289
|
+
events: RunEvent[];
|
|
290
|
+
}
|
|
291
|
+
/** A buyer-side receipt: the run's billing with its payment asset. Amounts are exact atomic strings plus a formatted `charged`. */
|
|
292
|
+
export interface BuyerReceipt {
|
|
293
|
+
runId: string;
|
|
294
|
+
quoteId: string;
|
|
295
|
+
reservationId: string;
|
|
296
|
+
status: Billing['status'];
|
|
297
|
+
outcome: Settlement['outcome'] | null;
|
|
298
|
+
payment: PaymentAsset;
|
|
299
|
+
/** The quote's maximum, when the quote was passed in. */ maximumDebitAtomic: string | null;
|
|
300
|
+
chargedAtomic: string | null; /** For example "0.0022 SOL", once settled. */
|
|
301
|
+
charged: string | null;
|
|
302
|
+
fees: {
|
|
303
|
+
creatorFeeAtomic: string;
|
|
304
|
+
platformFeeAtomic: string;
|
|
305
|
+
executionChargeAtomic: string;
|
|
306
|
+
} | null;
|
|
307
|
+
pendingReason: string | null;
|
|
308
|
+
billing: Billing;
|
|
309
|
+
}
|
|
310
|
+
export interface Monitor {
|
|
311
|
+
id: string;
|
|
312
|
+
name: string;
|
|
313
|
+
versionId: string;
|
|
314
|
+
chain: string;
|
|
315
|
+
status: 'active' | 'paused' | 'stopped' | 'expired' | 'exhausted';
|
|
316
|
+
statusReason: string | null;
|
|
317
|
+
webhook: {
|
|
318
|
+
url: string;
|
|
319
|
+
signature: string;
|
|
320
|
+
} | null;
|
|
321
|
+
[key: string]: unknown;
|
|
322
|
+
}
|
|
323
|
+
export interface MonitorDetail {
|
|
324
|
+
monitor: Monitor;
|
|
325
|
+
windows: Record<string, unknown>[];
|
|
326
|
+
missedWindows: Record<string, unknown>[];
|
|
327
|
+
events: Record<string, unknown>[];
|
|
328
|
+
retractedEvents: Record<string, unknown>[];
|
|
329
|
+
deliveries: Record<string, unknown>[];
|
|
330
|
+
}
|
|
331
|
+
export interface Notification {
|
|
332
|
+
id: string;
|
|
333
|
+
monitorId: string;
|
|
334
|
+
kind: string;
|
|
335
|
+
title: string;
|
|
336
|
+
body: string;
|
|
337
|
+
event: Record<string, unknown>;
|
|
338
|
+
createdAt: string;
|
|
339
|
+
acknowledgedAt: string | null;
|
|
340
|
+
}
|
|
341
|
+
export interface MonitorRequest {
|
|
342
|
+
versionId: string;
|
|
343
|
+
name: string;
|
|
344
|
+
chain: string;
|
|
345
|
+
rules: Record<string, unknown>[];
|
|
346
|
+
windowBlocks?: number;
|
|
347
|
+
maximumLogs?: number;
|
|
348
|
+
durationSeconds: number;
|
|
349
|
+
tickBudget: number;
|
|
350
|
+
rpcBudget: number;
|
|
351
|
+
startBlock?: string;
|
|
352
|
+
webhookUrl?: string;
|
|
353
|
+
idempotencyKey?: string;
|
|
354
|
+
}
|
|
355
|
+
/** Polling for `waitForRun` and settled receipts: exponential backoff from `intervalMs` to `maxIntervalMs`, bounded by `timeoutMs`. */
|
|
356
|
+
export interface WaitOptions {
|
|
357
|
+
/** First poll interval (default 1,000 ms). */ intervalMs?: number;
|
|
358
|
+
/** Longest poll interval (default 10,000 ms). */ maxIntervalMs?: number;
|
|
359
|
+
/** Interval multiplier per poll (default 1.5; 1 polls at a fixed interval). */ backoff?: number;
|
|
360
|
+
/** Give up after this long (default 300,000 ms) with a retryable `timeout` error. */ timeoutMs?: number;
|
|
361
|
+
signal?: AbortSignal;
|
|
362
|
+
/** Called with every run state read while waiting. */ onStatus?: (state: RunState) => void;
|
|
363
|
+
}
|
|
364
|
+
export interface CallOptions {
|
|
365
|
+
signal?: AbortSignal;
|
|
366
|
+
}
|
|
367
|
+
export interface ResearchRequest {
|
|
368
|
+
listingId: string;
|
|
369
|
+
input: QuoteInput;
|
|
370
|
+
/** Payment asset (an asset id or `sol`, `usdc`, `eth`). Defaults to the client's `assetId`, else the API key's own asset. */ assetId?: string;
|
|
371
|
+
resultPolicy?: 'complete_only' | 'canonical_metadata';
|
|
372
|
+
/** Consent bound: refuse (without accepting) a quote that could reserve more than this, in the asset's atomic units. */ maxDebitAtomic?: string;
|
|
373
|
+
/** Consent callback: return true to accept this exact quote. Runs after the `maxDebitAtomic` check. */ approve?: (quote: Quote) => boolean | Promise<boolean>;
|
|
374
|
+
/** Reuse the same key to retry an uncertain acceptance without reserving twice. Generated when omitted. */ idempotencyKey?: string;
|
|
375
|
+
wait?: WaitOptions;
|
|
376
|
+
signal?: AbortSignal;
|
|
377
|
+
}
|
|
378
|
+
export interface ResearchOutcome {
|
|
379
|
+
quote: Quote;
|
|
380
|
+
acceptance: Acceptance;
|
|
381
|
+
idempotencyKey: string;
|
|
382
|
+
run: Run;
|
|
383
|
+
events: RunEvent[];
|
|
384
|
+
/** Typed findings, evidence and sources of the finished run (empty when the run produced no report). */ report: ResearchReport;
|
|
385
|
+
/** The asset the run was paid in, when known. */ payment: PaymentAsset | null;
|
|
386
|
+
}
|
|
387
|
+
/** An exact origin. HTTPS anywhere; plain HTTP only on loopback, so a bearer key never crosses a network in clear text. */
|
|
388
|
+
export declare function buyerApiOrigin(raw: string): string;
|
|
389
|
+
/** The offer a listing makes in one asset (an asset id or `sol`, `usdc`, `eth`), or undefined when it does not accept that asset. */
|
|
390
|
+
export declare function offerFor(agent: Pick<AgentSummary, 'offers'>, assetId: string): AgentOffer | undefined;
|
|
391
|
+
export interface BuyerClientOptions {
|
|
392
|
+
/** A buyer API key from https://agentex.sh/developers (`agx_live_...`). It is sent only as a bearer header and never printed. */
|
|
393
|
+
apiKey: string;
|
|
394
|
+
/** API origin. Default `https://agentex.sh`. HTTPS, or HTTP on loopback only. */
|
|
395
|
+
origin?: string;
|
|
396
|
+
/** Payment profile. Omit it (recommended) to use the key's own profile, read once from `GET /v1/buyer/key`. */
|
|
397
|
+
profile?: BuyerProfile;
|
|
398
|
+
/** Default payment asset for quotes and billing (an asset id or `sol`, `usdc`, `eth`). It implies the profile. */
|
|
399
|
+
assetId?: string;
|
|
400
|
+
/** A fetch implementation (default: the global fetch). */
|
|
401
|
+
fetch?: typeof fetch;
|
|
402
|
+
/** Per-request timeout (default 15,000 ms). */ timeoutMs?: number;
|
|
403
|
+
/** Retries for idempotent calls (default 2, at most 5). Quote creation is never retried. */ maxRetries?: number;
|
|
404
|
+
/** First retry delay (default 250 ms), doubling per attempt up to 8 s; a server `Retry-After` up to 30 s is honoured. */ retryDelayMs?: number;
|
|
405
|
+
}
|
|
406
|
+
export declare function createBuyerClient(options: BuyerClientOptions): {
|
|
407
|
+
origin: string;
|
|
408
|
+
/** The explicit or derived payment profile; undefined until the key's own profile has been read. */
|
|
409
|
+
readonly profile: BuyerProfile | undefined;
|
|
410
|
+
/** The profile this client quotes and pays with: the explicit one, the asset's, or the key's own (one `GET /v1/buyer/key`). */
|
|
411
|
+
resolveProfile: () => Promise<BuyerProfile>;
|
|
412
|
+
/** The asset this client pays in: the client's `assetId`, else the key's own asset. */
|
|
413
|
+
paymentAsset(): Promise<PaymentAsset>;
|
|
414
|
+
/** The key's own scopes, asset, expiry and `remainingSpendAtomic`. Any valid key may read it. */
|
|
415
|
+
key(call?: CallOptions): Promise<BuyerKey>;
|
|
416
|
+
/** One page of public agents. Pass `nextCursor` back as `cursor`; `null` means the last page. Needs `catalog:read`. */
|
|
417
|
+
listAgents(input?: AgentQuery, call?: CallOptions): Promise<AgentPage>;
|
|
418
|
+
/** Iterates pages until `nextCursor` is null, bounded by `maxPages` (default 20). */
|
|
419
|
+
agents(input?: Omit<AgentQuery, "cursor">, maxPages?: number): AsyncGenerator<AgentSummary>;
|
|
420
|
+
/** Permissions, limits, input fields, offers (one per payment rail) and limitations of one listing. */
|
|
421
|
+
getAgent(listingId: string, call?: CallOptions): Promise<AgentDetail>;
|
|
422
|
+
/** The listings this key can buy with its rail (full manifests and tariffs), with the rail's pricing policy. */
|
|
423
|
+
listings(input?: {
|
|
424
|
+
assetId?: string;
|
|
425
|
+
} & CallOptions): Promise<{
|
|
426
|
+
listings: Record<string, unknown>[];
|
|
427
|
+
pricingPolicy: unknown;
|
|
428
|
+
}>;
|
|
429
|
+
/**
|
|
430
|
+
* Creates a server-priced quote on the rail of `assetId` (or the client's default, or the key's own asset). It reserves nothing and expires
|
|
431
|
+
* after 240 seconds. Never retried. When an asset was named, a quote priced in any other asset is refused with `asset_mismatch`.
|
|
432
|
+
*/
|
|
433
|
+
createQuote(input: {
|
|
434
|
+
listingId: string;
|
|
435
|
+
input: QuoteInput;
|
|
436
|
+
resultPolicy?: "complete_only" | "canonical_metadata";
|
|
437
|
+
assetId?: string;
|
|
438
|
+
} & CallOptions): Promise<Quote>;
|
|
439
|
+
/**
|
|
440
|
+
* Consents to one exact quote. The contract hash must be the one returned by createQuote. One idempotency key is used for all retries
|
|
441
|
+
* of this call (generated if omitted and returned), so a lost response never reserves twice. Pass the quote's `assetId` when the client
|
|
442
|
+
* has no default asset and the key's rail is not the quote's.
|
|
443
|
+
*/
|
|
444
|
+
acceptQuote(input: {
|
|
445
|
+
quoteId: string;
|
|
446
|
+
contractHash: string;
|
|
447
|
+
idempotencyKey?: string;
|
|
448
|
+
assetId?: string;
|
|
449
|
+
} & CallOptions): Promise<Acceptance>;
|
|
450
|
+
/** Run status and its latest events (at most 250). */
|
|
451
|
+
getRun(runId: string, call?: CallOptions): Promise<RunState>;
|
|
452
|
+
/**
|
|
453
|
+
* Polls until the run leaves queued/running, with backoff (1 s growing to 10 s by default). Transient failures keep polling; a timeout
|
|
454
|
+
* throws a retryable `timeout` error (`wait_timeout`) and an aborted signal throws `aborted`. The run itself is never affected.
|
|
455
|
+
*/
|
|
456
|
+
waitForRun(runId: string, wait?: WaitOptions): Promise<RunState>;
|
|
457
|
+
/** Typed findings, evidence and sources of a finished run. A run without a report yet is a `conflict` (`report_unavailable`). */
|
|
458
|
+
getReport(runId: string, call?: CallOptions): Promise<ResearchReport>;
|
|
459
|
+
/** The canonical stored export (run, immutable version, events). A run without a report yet is a 409 `conflict`. */
|
|
460
|
+
getResult(runId: string, call?: CallOptions): Promise<RunResult>;
|
|
461
|
+
/** Cancels a run; repeating it returns the current state. Cancellation charges only execution already incurred. */
|
|
462
|
+
cancelRun(runId: string, call?: CallOptions): Promise<Run>;
|
|
463
|
+
/** Reservation and settlement of a run on its rail (the client's default asset or the key's own). */
|
|
464
|
+
getBilling(runId: string, input?: {
|
|
465
|
+
assetId?: string;
|
|
466
|
+
} & CallOptions): Promise<Billing>;
|
|
467
|
+
/**
|
|
468
|
+
* The run's billing with its payment asset and a formatted charge. The asset comes from `quote` when given, else `assetId`, else the key's
|
|
469
|
+
* own asset (a key only sees runs paid in its asset). `waitForSettlement` polls until the reservation settles.
|
|
470
|
+
*/
|
|
471
|
+
getReceipt(runId: string, input?: {
|
|
472
|
+
quote?: Pick<Quote, "asset" | "maximumBuyerDebitAtomic">;
|
|
473
|
+
assetId?: string;
|
|
474
|
+
waitForSettlement?: boolean | Omit<WaitOptions, "onStatus">;
|
|
475
|
+
} & CallOptions): Promise<BuyerReceipt>;
|
|
476
|
+
/**
|
|
477
|
+
* Quote, consent check, accept and wait in one call. It needs a consent bound (`maxDebitAtomic`, `approve`, or both) and refuses, without
|
|
478
|
+
* accepting, a quote above it. A wait failure after acceptance carries `runId` so you can resume with `waitForRun`.
|
|
479
|
+
*/
|
|
480
|
+
research(input: ResearchRequest): Promise<ResearchOutcome>;
|
|
481
|
+
/** Creates a monitor on your own Watchtower version. The webhook secret is returned only on first creation (null on replay). */
|
|
482
|
+
createMonitor(input: MonitorRequest, call?: CallOptions): Promise<{
|
|
483
|
+
idempotencyKey: string;
|
|
484
|
+
monitor: Monitor;
|
|
485
|
+
webhookSecret: string | null;
|
|
486
|
+
replayed: boolean;
|
|
487
|
+
}>;
|
|
488
|
+
listMonitors(call?: CallOptions): Promise<Monitor[]>;
|
|
489
|
+
getMonitor(monitorId: string, call?: CallOptions): Promise<MonitorDetail>;
|
|
490
|
+
stopMonitor(monitorId: string, call?: CallOptions): Promise<Monitor>;
|
|
491
|
+
listNotifications(call?: CallOptions): Promise<Notification[]>;
|
|
492
|
+
acknowledgeNotification(notificationId: string, call?: CallOptions): Promise<Notification>;
|
|
493
|
+
};
|
|
494
|
+
export type BuyerClient = ReturnType<typeof createBuyerClient>;
|
|
495
|
+
/** Records delivery IDs already processed. `claim` must be atomic: true only for the first caller of an ID. */
|
|
496
|
+
export interface WebhookReplayStore {
|
|
497
|
+
claim(deliveryId: string, expiresAt: Date): boolean | Promise<boolean>;
|
|
498
|
+
}
|
|
499
|
+
export declare function createMemoryReplayStore(maximumEntries?: number): WebhookReplayStore;
|
|
500
|
+
export declare const WebhookPayloadSchema: z.ZodObject<{
|
|
501
|
+
type: z.ZodEnum<{
|
|
502
|
+
"monitor.event": "monitor.event";
|
|
503
|
+
"monitor.event.retracted": "monitor.event.retracted";
|
|
504
|
+
}>;
|
|
505
|
+
eventId: z.ZodUUID;
|
|
506
|
+
monitorId: z.ZodUUID;
|
|
507
|
+
chain: z.ZodString;
|
|
508
|
+
status: z.ZodEnum<{
|
|
509
|
+
active: "active";
|
|
510
|
+
retracted: "retracted";
|
|
511
|
+
}>;
|
|
512
|
+
}, z.core.$loose>;
|
|
513
|
+
export type WebhookPayload = z.infer<typeof WebhookPayloadSchema>;
|
|
514
|
+
export type WebhookVerification = {
|
|
515
|
+
ok: true;
|
|
516
|
+
deliveryId: string;
|
|
517
|
+
payload: WebhookPayload;
|
|
518
|
+
} | {
|
|
519
|
+
ok: false;
|
|
520
|
+
reason: 'invalid_signature' | 'duplicate' | 'invalid_payload';
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* Verifies a monitor webhook with the monitoring package's HMAC check (signature, event ID and a 5-minute timestamp window), then
|
|
524
|
+
* claims the delivery ID in `replay` so a duplicate callback is rejected. Pass the raw request body exactly as received.
|
|
525
|
+
* Signature failure is checked first, so a forged request can never consume a genuine delivery ID.
|
|
526
|
+
*/
|
|
527
|
+
export declare function verifyWebhook(input: {
|
|
528
|
+
secret: string;
|
|
529
|
+
headers: Record<string, string | string[] | undefined>;
|
|
530
|
+
body: string;
|
|
531
|
+
replay: WebhookReplayStore;
|
|
532
|
+
now?: Date;
|
|
533
|
+
toleranceSeconds?: number;
|
|
534
|
+
}): Promise<WebhookVerification>;
|