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.
Files changed (97) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +195 -0
  4. package/dist/packages/contracts/src/deployer-investigation.d.ts +1015 -0
  5. package/dist/packages/contracts/src/deployer-investigation.js +101 -0
  6. package/dist/packages/contracts/src/index.d.ts +1701 -0
  7. package/dist/packages/contracts/src/index.js +380 -0
  8. package/dist/packages/contracts/src/indexed-activity.d.ts +684 -0
  9. package/dist/packages/contracts/src/indexed-activity.js +71 -0
  10. package/dist/packages/contracts/src/indexed-agents.d.ts +299 -0
  11. package/dist/packages/contracts/src/indexed-agents.js +131 -0
  12. package/dist/packages/contracts/src/inspection.d.ts +906 -0
  13. package/dist/packages/contracts/src/inspection.js +114 -0
  14. package/dist/packages/contracts/src/kinds.d.ts +5398 -0
  15. package/dist/packages/contracts/src/kinds.js +156 -0
  16. package/dist/packages/contracts/src/report-presentation.d.ts +346 -0
  17. package/dist/packages/contracts/src/report-presentation.js +120 -0
  18. package/dist/packages/contracts/src/solana-inspection.d.ts +451 -0
  19. package/dist/packages/contracts/src/solana-inspection.js +94 -0
  20. package/dist/packages/contracts/src/token-market.d.ts +193 -0
  21. package/dist/packages/contracts/src/token-market.js +335 -0
  22. package/dist/packages/contracts/src/wallet-analysis.d.ts +866 -0
  23. package/dist/packages/contracts/src/wallet-analysis.js +89 -0
  24. package/dist/packages/contracts/src/watchtower.d.ts +1141 -0
  25. package/dist/packages/contracts/src/watchtower.js +196 -0
  26. package/dist/packages/contracts/src/workflow.d.ts +1568 -0
  27. package/dist/packages/contracts/src/workflow.js +651 -0
  28. package/dist/packages/inspector/src/decode.d.ts +23 -0
  29. package/dist/packages/inspector/src/decode.js +150 -0
  30. package/dist/packages/inspector/src/scope.d.ts +87 -0
  31. package/dist/packages/inspector/src/scope.js +64 -0
  32. package/dist/packages/model/src/analysis.d.ts +149 -0
  33. package/dist/packages/model/src/analysis.js +387 -0
  34. package/dist/packages/model/src/pricing.d.ts +38 -0
  35. package/dist/packages/model/src/pricing.js +49 -0
  36. package/dist/packages/model/src/retry.d.ts +20 -0
  37. package/dist/packages/model/src/retry.js +31 -0
  38. package/dist/packages/model/src/schema.d.ts +10 -0
  39. package/dist/packages/model/src/schema.js +51 -0
  40. package/dist/packages/model/src/summary.d.ts +91 -0
  41. package/dist/packages/model/src/summary.js +177 -0
  42. package/dist/packages/model/src/types.d.ts +81 -0
  43. package/dist/packages/model/src/types.js +19 -0
  44. package/dist/packages/monitoring/src/delivery.d.ts +32 -0
  45. package/dist/packages/monitoring/src/delivery.js +53 -0
  46. package/dist/packages/providers/src/chain-transport.d.ts +42 -0
  47. package/dist/packages/providers/src/chain-transport.js +57 -0
  48. package/dist/packages/providers/src/coverage.d.ts +105 -0
  49. package/dist/packages/providers/src/coverage.js +260 -0
  50. package/dist/packages/providers/src/health.d.ts +273 -0
  51. package/dist/packages/providers/src/health.js +505 -0
  52. package/dist/packages/providers/src/keyed.d.ts +96 -0
  53. package/dist/packages/providers/src/keyed.js +240 -0
  54. package/dist/packages/providers/src/snapshot.d.ts +61 -0
  55. package/dist/packages/providers/src/snapshot.js +77 -0
  56. package/dist/packages/publication/src/fixtures.d.ts +45 -0
  57. package/dist/packages/publication/src/fixtures.js +350 -0
  58. package/dist/packages/research/src/index.d.ts +188 -0
  59. package/dist/packages/research/src/index.js +829 -0
  60. package/dist/packages/runtime/src/checkpoints.d.ts +65 -0
  61. package/dist/packages/runtime/src/checkpoints.js +214 -0
  62. package/dist/packages/runtime/src/policy.d.ts +57 -0
  63. package/dist/packages/runtime/src/policy.js +296 -0
  64. package/dist/packages/sdk/src/bin/agentex-buyer.d.ts +2 -0
  65. package/dist/packages/sdk/src/bin/agentex-buyer.js +4 -0
  66. package/dist/packages/sdk/src/bin/agentex.d.ts +2 -0
  67. package/dist/packages/sdk/src/bin/agentex.js +3 -0
  68. package/dist/packages/sdk/src/buyer-cli.d.ts +10 -0
  69. package/dist/packages/sdk/src/buyer-cli.js +210 -0
  70. package/dist/packages/sdk/src/buyer.d.ts +534 -0
  71. package/dist/packages/sdk/src/buyer.js +441 -0
  72. package/dist/packages/sdk/src/cli.d.ts +14 -0
  73. package/dist/packages/sdk/src/cli.js +149 -0
  74. package/dist/packages/sdk/src/errors.d.ts +31 -0
  75. package/dist/packages/sdk/src/errors.js +24 -0
  76. package/dist/packages/sdk/src/index.d.ts +236 -0
  77. package/dist/packages/sdk/src/index.js +150 -0
  78. package/dist/packages/sdk/src/local.d.ts +11 -0
  79. package/dist/packages/sdk/src/local.js +110 -0
  80. package/dist/packages/sdk/src/rails.d.ts +59 -0
  81. package/dist/packages/sdk/src/rails.js +96 -0
  82. package/dist/packages/sdk/src/report.d.ts +121 -0
  83. package/dist/packages/sdk/src/report.js +114 -0
  84. package/dist/packages/sdk/src/version.d.ts +2 -0
  85. package/dist/packages/sdk/src/version.js +2 -0
  86. package/dist/packages/watchtower/src/index.d.ts +150 -0
  87. package/dist/packages/watchtower/src/index.js +786 -0
  88. package/dist/packages/workflow/src/registry.d.ts +61 -0
  89. package/dist/packages/workflow/src/registry.js +76 -0
  90. package/examples/README.md +34 -0
  91. package/examples/cli-usage.sh +30 -0
  92. package/examples/fixtures/base-weth-input.json +4 -0
  93. package/examples/focused-researcher.json +127 -0
  94. package/examples/pay-with-eth-robinhood.mts +37 -0
  95. package/examples/pay-with-usdc.mts +41 -0
  96. package/examples/quickstart.mts +73 -0
  97. package/package.json +50 -0
@@ -0,0 +1,273 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * E04 provider health: stale-head detection, bounded retries, semantics-preserving failover, a public-data cache and operator
4
+ * telemetry. Owner rule: nothing waits for or gates on finality. Freshness compares the provider's head (the `latest` block time
5
+ * on EVM, the `confirmed` slot's block time on Solana) with the wall clock; a head that stops advancing is stale. There is no
6
+ * finality-lag check. Endpoints are identified by host only; URLs with paths, queries or credentials never leave this module.
7
+ */
8
+ export interface RpcRequestTransport {
9
+ request(method: string, params: readonly unknown[], signal: AbortSignal): Promise<unknown>;
10
+ }
11
+ export declare const ProviderHealthCategorySchema: z.ZodEnum<{
12
+ "provider-unavailable": "provider-unavailable";
13
+ "history-unavailable": "history-unavailable";
14
+ "rate-limited": "rate-limited";
15
+ timeout: "timeout";
16
+ cancelled: "cancelled";
17
+ "invalid-response": "invalid-response";
18
+ "chain-mismatch": "chain-mismatch";
19
+ "provider-stale": "provider-stale";
20
+ "snapshot-mismatch": "snapshot-mismatch";
21
+ "request-rejected": "request-rejected";
22
+ "execution-result": "execution-result";
23
+ }>;
24
+ export type ProviderHealthCategory = z.infer<typeof ProviderHealthCategorySchema>;
25
+ export declare class ProviderHealthError extends Error {
26
+ readonly category: ProviderHealthCategory;
27
+ constructor(category: ProviderHealthCategory, message: string);
28
+ }
29
+ /** The caller's `beforeAttempt` permit refused an attempt. It is never retried or failed over; `original` is the caller's error. */
30
+ export declare class AttemptRefusedError extends ProviderHealthError {
31
+ readonly original: unknown;
32
+ constructor(original: unknown);
33
+ }
34
+ /**
35
+ * Optionally returned by a `beforeAttempt` permit for hidden provider work (retries, identity checks, cross-checks, freshness probes). It is
36
+ * called once with the attempt's observed outcome, so the runtime can settle that permit; hidden work produces no tool evidence of its own.
37
+ * Primary requests return nothing: the tool records their result as evidence.
38
+ */
39
+ export type AttemptCompletion = (result: {
40
+ outcome: 'success' | ProviderHealthCategory;
41
+ }) => void | Promise<void>;
42
+ /** `headTag` is the head runs read; `maximumHeadAgeSeconds` bounds that head's age against the wall clock. */
43
+ export interface HeadFreshnessPolicy {
44
+ family: 'evm' | 'solana';
45
+ identity: string;
46
+ headTag: 'latest' | 'confirmed';
47
+ maximumHeadAgeSeconds: number;
48
+ observedTypicalHeadAge: string;
49
+ observedAt: string;
50
+ }
51
+ /** Thresholds leave wide margin over each chain's block interval so a merely slow endpoint is not excluded; only a head that stopped advancing is. */
52
+ export declare const HEAD_FRESHNESS_POLICIES: Readonly<Record<string, HeadFreshnessPolicy>>;
53
+ export declare const endpointHost: (url: string) => string;
54
+ export declare function categorizeProviderError(error: unknown, signal?: AbortSignal): ProviderHealthCategory;
55
+ /** Relative request weight for budgeting. It is not a price: every free public source remains unpriced. */
56
+ export declare const methodCostUnits: (method: string) => number;
57
+ export type AttemptPurpose = 'request' | 'identity' | 'cross-check' | 'freshness-probe';
58
+ interface EndpointStats {
59
+ id: string;
60
+ chain: string;
61
+ host: string;
62
+ status: 'unobserved' | 'healthy' | 'degraded' | 'provider-stale' | 'excluded';
63
+ lastCategory: ProviderHealthCategory | null;
64
+ lastObservedAt: string | null;
65
+ requests: number;
66
+ successes: number;
67
+ failures: Partial<Record<ProviderHealthCategory, number>>;
68
+ retries: number;
69
+ failovers: number;
70
+ identityChecks: number;
71
+ crossChecks: number;
72
+ crossCheckMismatches: number;
73
+ cacheHits: number;
74
+ costUnits: number;
75
+ latencyTotalMs: number;
76
+ latencyMaxMs: number;
77
+ lastLatencyMs: number | null;
78
+ freshness: {
79
+ headAgeSeconds: number | null;
80
+ thresholdSeconds: number | null;
81
+ observedAt: string;
82
+ } | null;
83
+ }
84
+ export declare class ProviderTelemetry {
85
+ #private;
86
+ attempt(endpoint: {
87
+ id: string;
88
+ chain: string;
89
+ host: string;
90
+ }, event: {
91
+ method: string;
92
+ outcome: 'success' | ProviderHealthCategory;
93
+ latencyMs: number;
94
+ purpose: AttemptPurpose;
95
+ retry?: boolean;
96
+ at?: Date;
97
+ }): void;
98
+ mark(endpoint: {
99
+ id: string;
100
+ chain: string;
101
+ host: string;
102
+ }, status: EndpointStats['status'], category: ProviderHealthCategory | null): void;
103
+ failover(endpoint: {
104
+ id: string;
105
+ chain: string;
106
+ host: string;
107
+ }): void;
108
+ crossCheckMismatch(endpoint: {
109
+ id: string;
110
+ chain: string;
111
+ host: string;
112
+ }): void;
113
+ cacheHit(endpoint: {
114
+ id: string;
115
+ chain: string;
116
+ host: string;
117
+ } | null): void;
118
+ cacheMiss(): void;
119
+ cacheStore(): void;
120
+ cachePrivateRefusal(): void;
121
+ freshness(endpoint: {
122
+ id: string;
123
+ chain: string;
124
+ host: string;
125
+ }, observation: NonNullable<EndpointStats['freshness']> & {
126
+ stale: boolean;
127
+ }): void;
128
+ snapshot(now?: Date): {
129
+ schemaVersion: "agentex.provider-health.v1";
130
+ generatedAt: string;
131
+ costStatus: "unpriced";
132
+ note: string;
133
+ cache: {
134
+ hits: number;
135
+ misses: number;
136
+ stores: number;
137
+ rejectedPrivate: number;
138
+ scope: "public-chain-data-only";
139
+ };
140
+ endpoints: {
141
+ meanLatencyMs: number | null;
142
+ id: string;
143
+ chain: string;
144
+ host: string;
145
+ status: "unobserved" | "healthy" | "degraded" | "provider-stale" | "excluded";
146
+ lastCategory: ProviderHealthCategory | null;
147
+ lastObservedAt: string | null;
148
+ requests: number;
149
+ successes: number;
150
+ failures: Partial<Record<ProviderHealthCategory, number>>;
151
+ retries: number;
152
+ failovers: number;
153
+ identityChecks: number;
154
+ crossChecks: number;
155
+ crossCheckMismatches: number;
156
+ cacheHits: number;
157
+ costUnits: number;
158
+ latencyTotalMs: number;
159
+ latencyMaxMs: number;
160
+ lastLatencyMs: number | null;
161
+ freshness: {
162
+ headAgeSeconds: number | null;
163
+ thresholdSeconds: number | null;
164
+ observedAt: string;
165
+ } | null;
166
+ }[];
167
+ };
168
+ reset(): void;
169
+ }
170
+ /** Process-wide operator telemetry. It holds hosts, counters and freshness only: no request parameters, results or tenant identifiers. */
171
+ export declare const PROVIDER_TELEMETRY: ProviderTelemetry;
172
+ /** The block number a state request is pinned to, or null for moving tags and unpinned requests. */
173
+ export declare function referencedBlockNumber(method: string, params: readonly unknown[]): bigint | null;
174
+ export interface CacheContext {
175
+ chain: string;
176
+ family: 'evm' | 'solana';
177
+ identity: string;
178
+ anchors: ReadonlyMap<string, {
179
+ hash: string;
180
+ }>;
181
+ }
182
+ /**
183
+ * Shared cache key for public chain data only. Reads are not final, so a key always binds the exact block hash this transport observed
184
+ * at the referenced height: a reorg changes the hash and therefore the key. Block headers are never cached (they are the reorg check),
185
+ * Solana data is never cached (confirmed data can still roll back), and proposed payloads, sender-context calls, moving tags and unpinned
186
+ * reads are never cacheable, so one tenant's private request cannot be served to another.
187
+ */
188
+ export declare function publicCacheKey(context: CacheContext, method: string, params: readonly unknown[]): string | null;
189
+ export declare class PublicDataCache {
190
+ #private;
191
+ readonly maximumEntries: number;
192
+ readonly maximumBytes: number;
193
+ readonly maximumEntryBytes: number;
194
+ constructor(maximumEntries?: number, maximumBytes?: number, maximumEntryBytes?: number);
195
+ get(key: string): unknown;
196
+ set(key: string, value: unknown): boolean;
197
+ get size(): number;
198
+ clear(): void;
199
+ }
200
+ export declare const PUBLIC_DATA_CACHE: PublicDataCache;
201
+ export interface ResilientEndpoint {
202
+ id: string;
203
+ url: string;
204
+ transport: RpcRequestTransport;
205
+ /** Methods this endpoint serves; others never reach it (a keyless node that serves no debug namespace, for example). Defaults to all. */
206
+ serves?: (method: string, params: readonly unknown[]) => boolean;
207
+ /** Requests this endpoint should answer first (a trace, or a log range wider than public nodes serve), before the usual order. */
208
+ prefers?: (method: string, params: readonly unknown[]) => boolean;
209
+ }
210
+ export interface ResilientTransportOptions {
211
+ chain: string;
212
+ endpoints: readonly ResilientEndpoint[];
213
+ /** Attempts per logical request across endpoints (1-3). Defaults to 1 for one endpoint and 2 with failover. */
214
+ maximumAttempts?: number;
215
+ /** Extra attempts, identity checks and snapshot cross-checks shared by the transport's lifetime (0-16). */
216
+ retryBudget?: number;
217
+ cache?: PublicDataCache | null;
218
+ telemetry?: ProviderTelemetry;
219
+ now?: () => Date;
220
+ backoffMs?: number;
221
+ /** Runtime permit hook for every network attempt, including retries and cross-checks, so hidden work cannot bypass run budgets. */
222
+ beforeAttempt?: (operation: {
223
+ endpointId: string;
224
+ method: string;
225
+ purpose: AttemptPurpose;
226
+ attempt: number;
227
+ }) => void | AttemptCompletion | Promise<void | AttemptCompletion>;
228
+ categorize?: (error: unknown, signal: AbortSignal) => ProviderHealthCategory;
229
+ }
230
+ export interface ResilientTransport extends RpcRequestTransport {
231
+ health(): {
232
+ id: string;
233
+ host: string;
234
+ excluded: ProviderHealthCategory | null;
235
+ identity: 'unverified' | 'verified' | 'mismatch';
236
+ }[];
237
+ readonly retryBudgetRemaining: number;
238
+ /** The endpoint that answered the most recent successful request (a cache hit names the endpoint that first served it), for evidence attribution. */
239
+ servedBy(): {
240
+ id: string;
241
+ host: string;
242
+ } | null;
243
+ }
244
+ export declare function createResilientTransport(options: ResilientTransportOptions): ResilientTransport;
245
+ export interface FreshnessObservation {
246
+ chain: string;
247
+ host: string;
248
+ observedAt: string;
249
+ status: 'healthy' | ProviderHealthCategory;
250
+ identity: string | null;
251
+ expectedIdentity: string;
252
+ /** The head runs read: `latest` on EVM, the `confirmed` slot on Solana. */
253
+ tag: 'latest' | 'confirmed';
254
+ head: {
255
+ number: string;
256
+ hash: string | null;
257
+ timestamp: string | null;
258
+ } | null;
259
+ headAgeSeconds: number | null;
260
+ thresholdSeconds: number;
261
+ requests: number;
262
+ }
263
+ /** Active three-call head freshness probe for operators and verification scripts: identity, the head and its age. No finality is read. */
264
+ export declare function probeFreshness(chain: string, endpoint: {
265
+ id: string;
266
+ url: string;
267
+ transport: RpcRequestTransport;
268
+ }, options?: {
269
+ signal?: AbortSignal;
270
+ now?: () => Date;
271
+ telemetry?: ProviderTelemetry;
272
+ }): Promise<FreshnessObservation>;
273
+ export {};