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,89 @@
1
+ import { z } from 'zod';
2
+ import { AddressSchema, contentHash } from './index.js';
3
+ import { ACTIVITY_TOOL_REFS, ActivityFindingSchema, WalletActivityBodySchema } from './indexed-activity.js';
4
+ import { BlockNumberInputSchema, IndexedAnalysisSchema, IndexedEvidenceSchema, indexedManifestIssues, indexedManifestSchema, IndexedAgentChainSchema, IndexedReportErrorSchema, indexedReportIssues, IndexedSnapshotSchema, IndexedUsageSchema, NotComputedSchema, validateIndexedReceipt } from './indexed-agents.js';
5
+ /**
6
+ * P03 Wallet Analyst contract. Input: an explicit chain and wallet, an optional block window and a transfer bound. Output: the native balance
7
+ * at the pinned block, bounded inbound and outbound transfers by category with exact amounts, per-asset flows without double-counted
8
+ * self-transfers, current token balances, and a transaction ledger (CSV in the run export). Trades are not classified, fees are not computed
9
+ * and realised or unrealised results, cost basis and win rate are reported as not computed because no verified price or trade source exists.
10
+ */
11
+ export const WALLET_SCHEMA_ID = 'agentex.wallet-analysis.v1';
12
+ export const WALLET_TOOLS = Object.freeze([ACTIVITY_TOOL_REFS.wallet]);
13
+ /** Pin (2) + balance + two transfer pages + recheck. */
14
+ export const WALLET_MINIMUM_RPC_CALLS = 6;
15
+ export const WalletAnalysisInputSchema = z.strictObject({
16
+ chain: IndexedAgentChainSchema, wallet: AddressSchema, fromBlock: BlockNumberInputSchema.optional(), toBlock: BlockNumberInputSchema.optional(),
17
+ maximumTransfers: z.number().int().min(1).max(50).default(25),
18
+ /** Requested valuation currency. Valuations are not computed until a verified historical price source exists; the report says so. */
19
+ pricingDenomination: z.enum(['usd']).optional(),
20
+ }).superRefine((input, ctx) => { if (input.fromBlock !== undefined && input.toBlock !== undefined && BigInt(input.fromBlock) > BigInt(input.toBlock))
21
+ ctx.addIssue({ code: 'custom', path: ['toBlock'], message: 'toBlock must not precede fromBlock' }); });
22
+ const ManifestSchema = indexedManifestSchema(WALLET_SCHEMA_ID);
23
+ export const WALLET_ANALYST_MANIFEST = Object.freeze(ManifestSchema.parse({
24
+ schemaVersion: '1.0', id: 'wallet-analyst', version: '0.1.0', name: 'Wallet Analyst',
25
+ description: 'Read a wallet\'s native balance at one latest block (sequencer-confirmed) pinned for the run, its bounded inbound and outbound transfers (native, internal, ERC-20, ERC-721 and ERC-1155) with exact amounts, per-asset flows without double-counted self-transfers and its current token balances, with a downloadable transaction ledger. Trades are not labelled; fees, cost basis, realised and unrealised results and win rate are reported as not computed.',
26
+ author: { id: 'agentex', name: 'AGENTEX', ownership: 'first-party' }, license: 'Proprietary', visibility: 'source-visible', chains: ['ethereum', 'base'],
27
+ inputSchema: { type: 'object', additionalProperties: false, required: ['chain', 'wallet'], properties: {
28
+ chain: { type: 'string', description: 'Explicit analysis network', enum: ['ethereum', 'base'] }, wallet: { type: 'string', description: 'Wallet address to analyse' },
29
+ fromBlock: { type: 'string', description: 'Optional first block of the activity window' }, toBlock: { type: 'string', description: 'Optional last block, at or before the latest block' },
30
+ maximumTransfers: { type: 'integer', description: 'Most recent transfers read per direction (1-50)' }, pricingDenomination: { type: 'string', description: 'Requested valuation currency; valuations are not computed yet', enum: ['usd'] }
31
+ } },
32
+ outputSchemaId: WALLET_SCHEMA_ID, tools: [{ id: 'evm.wallet-activity', version: '0.1.0', capability: 'evm.read', chains: ['ethereum', 'base'], addressScope: 'input-address', maximumCalls: 16 }],
33
+ modelPolicy: { mode: 'deterministic', maximumModelTokens: 0 },
34
+ limits: { maximumRpcCalls: 16, maximumDurationMs: 60000, maximumOutputBytes: 262144, maximumGraphDepth: 3, maximumPages: 1, maximumExecutionAtomic: '0' },
35
+ workflow: [
36
+ { id: 'input', type: 'input', dependsOn: [] },
37
+ { id: 'activity', type: 'tool', tool: 'evm.wallet-activity', dependsOn: ['input'], arguments: { wallet: { source: 'input', path: 'wallet' }, fromBlock: { source: 'input', path: 'fromBlock' }, toBlock: { source: 'input', path: 'toBlock' }, maximumTransfers: { source: 'input', path: 'maximumTransfers' } } },
38
+ { id: 'report', type: 'output', dependsOn: ['activity'], from: 'activity' },
39
+ ],
40
+ testCases: ['transfers-and-balances', 'in-and-out-not-a-trade', 'self-transfer-counted-once', 'truncated-history', 'missing-token-metadata', 'provider-failure', 'chain-mismatch'],
41
+ }));
42
+ export const SupportedWalletAnalystManifestSchema = ManifestSchema.superRefine((manifest, ctx) => {
43
+ for (const item of indexedManifestIssues(manifest, WALLET_ANALYST_MANIFEST, WALLET_MINIMUM_RPC_CALLS))
44
+ ctx.addIssue({ code: 'custom', path: item.path, message: item.message });
45
+ });
46
+ /** Columns of the transaction ledger rows in the CSV run export (one row per transfer leg). */
47
+ export const WALLET_LEDGER_COLUMNS = Object.freeze(['direction', 'category', 'blockNumber', 'blockTimestamp', 'transactionHash', 'from', 'to', 'contract', 'asset', 'tokenId', 'valueAtomic', 'decimals', 'valueFormatted', 'selfTransfer', 'classification', 'evidenceId']);
48
+ export const WalletAnalysisReportSchema = z.strictObject({
49
+ schemaVersion: z.literal(WALLET_SCHEMA_ID), agentVersion: z.string().regex(/^\d+\.\d+\.\d+$/), manifestHash: z.string().regex(/^[a-f0-9]{64}$/),
50
+ input: WalletAnalysisInputSchema, status: z.enum(['complete', 'partial', 'failed']), generatedAt: z.iso.datetime(), chainId: z.number().int().positive().nullable(), snapshot: IndexedSnapshotSchema.nullable(),
51
+ activity: WalletActivityBodySchema.omit({ errors: true }).nullable(),
52
+ trades: z.strictObject({ status: z.literal('not-classified'), reason: z.string().max(600) }),
53
+ fees: NotComputedSchema,
54
+ results: z.strictObject({ realised: NotComputedSchema, unrealised: NotComputedSchema, costBasis: NotComputedSchema, winRate: NotComputedSchema, valuationDenomination: z.enum(['usd']).nullable() }),
55
+ ledger: z.strictObject({ format: z.literal('csv-in-run-export'), rows: z.number().int().nonnegative().max(200), columns: z.array(z.string().max(32)).max(24) }),
56
+ findings: z.array(ActivityFindingSchema).max(64), unknowns: z.array(z.string().max(600)).max(24), limitations: z.array(z.string().max(1000)).max(24),
57
+ errors: z.array(IndexedReportErrorSchema).max(40), evidence: IndexedEvidenceSchema, analysis: IndexedAnalysisSchema.optional(), usage: IndexedUsageSchema,
58
+ }).superRefine((report, ctx) => {
59
+ indexedReportIssues(report, WALLET_TOOLS, ctx);
60
+ if (report.activity && report.activity.wallet.toLowerCase() !== report.input.wallet.toLowerCase())
61
+ ctx.addIssue({ code: 'custom', path: ['activity'], message: 'The activity section must describe the accepted wallet.' });
62
+ if (report.ledger.rows !== (report.activity?.transfers.length ?? 0))
63
+ ctx.addIssue({ code: 'custom', path: ['ledger', 'rows'], message: 'The ledger row count must equal the returned transfer legs.' });
64
+ if (report.status === 'complete' && (!report.activity || report.errors.length || report.activity.nativeBalance.balanceAtomic.status !== 'observed' || [report.activity.coverage.inbound, report.activity.coverage.outbound].some((status) => status === 'unavailable' || status === 'not-read-call-bound')))
65
+ ctx.addIssue({ code: 'custom', path: ['status'], message: 'A complete analysis observes the native balance and reads both transfer directions without errors.' });
66
+ });
67
+ export const WALLET_RESULT_CONTRACT = { id: 'wallet-analysis-observed-v1', description: 'Charge only for a complete analysis read at one pinned latest block (sequencer-confirmed) that is still canonical at completion: the native balance observed, both inbound and outbound transfer pages read with exact amounts and their index coverage stated, and the transaction ledger included. Trades, fees, cost basis, realised and unrealised results and win rate are never claimed. A reorganization or any read error makes the report partial or failed and charges nothing.' };
68
+ export function walletResultContractIssues(raw, manifest) {
69
+ const parsed = WalletAnalysisReportSchema.safeParse(raw);
70
+ if (!parsed.success)
71
+ return [`The report does not match ${WALLET_SCHEMA_ID}.`];
72
+ const report = parsed.data;
73
+ const issues = [];
74
+ if (manifest && (report.agentVersion !== manifest.version || report.manifestHash !== contentHash(manifest)))
75
+ issues.push('The report is bound to another version.');
76
+ if (report.status !== 'complete')
77
+ issues.push(`The analysis is ${report.status}.`);
78
+ if (report.snapshot?.canonicality !== 'verified-at-completion')
79
+ issues.push('The pinned block was not rechecked as canonical.');
80
+ if (!report.activity || report.activity.nativeBalance.balanceAtomic.status !== 'observed')
81
+ issues.push('The native balance was not observed.');
82
+ if (!report.evidence.some((item) => item.source.method === 'eth_chainId' && item.completeness === 'complete-for-request'))
83
+ issues.push('Chain identity was not captured.');
84
+ if (report.activity && !['in', 'out'].every((direction) => report.activity.pages.some((page) => page.direction === direction && (page.status === 'provider-exhausted' || page.status === 'truncated-with-cursor'))))
85
+ issues.push('Both transfer directions were not read.');
86
+ return issues;
87
+ }
88
+ export const satisfiesWalletResultContract = (raw, manifest) => walletResultContractIssues(raw, manifest).length === 0;
89
+ export const validateWalletReceipt = (evidence, input) => validateIndexedReceipt(evidence, input, WALLET_TOOLS);