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,101 @@
1
+ import { z } from 'zod';
2
+ import { AddressSchema, contentHash } from './index.js';
3
+ import { ACTIVITY_TOOL_REFS, ActivityEvidenceIdSchema, ActivityFindingSchema, AddressFundingBodySchema, ContractOriginBodySchema, DeployerLaunchesBodySchema } from './indexed-activity.js';
4
+ import { Hex32Schema, IndexedAnalysisSchema, IndexedEvidenceSchema, indexedManifestIssues, indexedManifestSchema, IndexedAgentChainSchema, IndexedReportErrorSchema, indexedReportIssues, IndexedSnapshotSchema, IndexedUsageSchema, validateIndexedReceipt } from './indexed-agents.js';
5
+ /**
6
+ * P02 Deployer Investigator contract. Input: an explicit chain and contract, an optional creation transaction (verified, never trusted) and
7
+ * bounds for the funding and related-deployment sections. Output: how the contract was created, the observed sender/factory roles, the
8
+ * sender's earliest indexed funding, its other top-level creations, a chronological timeline and an evidence-linked relationship graph.
9
+ * Roles never identify people; a funding link or a shared sender is an observed relationship, not proof of common ownership or intent.
10
+ */
11
+ export const DEPLOYER_SCHEMA_ID = 'agentex.deployer-investigation.v1';
12
+ export const DEPLOYER_TOOLS = Object.freeze([ACTIVITY_TOOL_REFS.origin, ACTIVITY_TOOL_REFS.funding, ACTIVITY_TOOL_REFS.launches]);
13
+ /** Pin (2) + code + one anchor + receipt + recheck: the least budget that can confirm a creation. */
14
+ export const DEPLOYER_MINIMUM_RPC_CALLS = 6;
15
+ export const DeployerInvestigationInputSchema = z.strictObject({
16
+ chain: IndexedAgentChainSchema, contract: AddressSchema, creationTransaction: Hex32Schema.optional(),
17
+ maximumFundingTransfers: z.number().int().min(1).max(25).default(10),
18
+ maximumRelatedTransactions: z.number().int().min(1).max(50).default(25),
19
+ maximumRelatedReceipts: z.number().int().min(0).max(4).default(2),
20
+ });
21
+ const ManifestSchema = indexedManifestSchema(DEPLOYER_SCHEMA_ID);
22
+ const TOOL = (id) => ({ id, version: '0.1.0', capability: 'evm.read', chains: ['ethereum', 'base'], addressScope: 'input-address', maximumCalls: 16 });
23
+ export const DEPLOYER_INVESTIGATOR_MANIFEST = Object.freeze(ManifestSchema.parse({
24
+ schemaVersion: '1.0', id: 'deployer-investigator', version: '0.1.0', name: 'Deployer Investigator',
25
+ description: 'Find how a contract was created (a creation receipt, or archive code checks around its first indexed activity), the account that sent the creation transaction or the factory that announced it, that account\'s earliest indexed funding and its other top-level contract creations, all at one latest block (sequencer-confirmed) pinned for the run. Relationships are observed transactions: they never identify a person or prove ownership, control or intent.',
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', 'contract'], properties: {
28
+ chain: { type: 'string', description: 'Explicit analysis network', enum: ['ethereum', 'base'] }, contract: { type: 'string', description: 'Contract address to investigate' },
29
+ creationTransaction: { type: 'string', description: 'Optional creation transaction hash; it is verified before use' },
30
+ maximumFundingTransfers: { type: 'integer', description: 'Earliest inbound transfers to the creation sender (1-25)' },
31
+ maximumRelatedTransactions: { type: 'integer', description: 'Sender transactions examined for other contract creations (1-50)' },
32
+ maximumRelatedReceipts: { type: 'integer', description: 'Other creation receipts resolved to contract addresses (0-4)' }
33
+ } },
34
+ outputSchemaId: DEPLOYER_SCHEMA_ID, tools: [TOOL('evm.contract-origin'), TOOL('evm.address-funding'), TOOL('evm.deployer-launches')],
35
+ modelPolicy: { mode: 'deterministic', maximumModelTokens: 0 },
36
+ limits: { maximumRpcCalls: 16, maximumDurationMs: 60000, maximumOutputBytes: 262144, maximumGraphDepth: 5, maximumPages: 1, maximumExecutionAtomic: '0' },
37
+ workflow: [
38
+ { id: 'input', type: 'input', dependsOn: [] },
39
+ { id: 'origin', type: 'tool', tool: 'evm.contract-origin', dependsOn: ['input'], arguments: { contract: { source: 'input', path: 'contract' }, creationTransaction: { source: 'input', path: 'creationTransaction' } } },
40
+ { id: 'funding', type: 'tool', tool: 'evm.address-funding', dependsOn: ['origin'], arguments: { address: { source: 'node', nodeId: 'origin', path: 'initiator' }, maximumTransfers: { source: 'input', path: 'maximumFundingTransfers' } } },
41
+ { id: 'launches', type: 'tool', tool: 'evm.deployer-launches', dependsOn: ['origin', 'funding'], arguments: { deployer: { source: 'node', nodeId: 'origin', path: 'initiator' }, maximumTransactions: { source: 'input', path: 'maximumRelatedTransactions' }, maximumReceipts: { source: 'input', path: 'maximumRelatedReceipts' } } },
42
+ { id: 'report', type: 'output', dependsOn: ['launches'], from: 'launches' },
43
+ ],
44
+ testCases: ['direct-deployment', 'factory-deployment', 'creation-not-indexed', 'infrastructure-funded-sender', 'truncated-history', 'provider-failure', 'chain-mismatch'],
45
+ }));
46
+ export const SupportedDeployerInvestigatorManifestSchema = ManifestSchema.superRefine((manifest, ctx) => {
47
+ for (const item of indexedManifestIssues(manifest, DEPLOYER_INVESTIGATOR_MANIFEST, DEPLOYER_MINIMUM_RPC_CALLS))
48
+ ctx.addIssue({ code: 'custom', path: item.path, message: item.message });
49
+ });
50
+ const Section = (body) => z.strictObject({ status: z.enum(['observed', 'not-read', 'unavailable']), reason: z.string().max(600), subject: AddressSchema.nullable(), body: body.nullable() });
51
+ const Node = z.strictObject({ id: z.string().max(80), kind: z.enum(['account', 'contract', 'transaction']), label: z.string().max(100).nullable(), isPerson: z.literal(false) });
52
+ const Edge = z.strictObject({ from: z.string().max(80), to: z.string().max(80), relation: z.enum(['sent-creation-transaction', 'created-contract', 'called-in-creation-transaction', 'emitted-creation-event', 'funded', 'sent-other-creation']),
53
+ basis: z.enum(['direct-transaction-evidence', 'heuristic-association', 'provider-index-assertion']), evidenceIds: z.array(ActivityEvidenceIdSchema).min(1) });
54
+ export const DeployerInvestigationReportSchema = z.strictObject({
55
+ schemaVersion: z.literal(DEPLOYER_SCHEMA_ID), agentVersion: z.string().regex(/^\d+\.\d+\.\d+$/), manifestHash: z.string().regex(/^[a-f0-9]{64}$/),
56
+ input: DeployerInvestigationInputSchema, status: z.enum(['complete', 'partial', 'failed']), generatedAt: z.iso.datetime(), chainId: z.number().int().positive().nullable(), snapshot: IndexedSnapshotSchema.nullable(),
57
+ origin: ContractOriginBodySchema.omit({ errors: true }).nullable(),
58
+ funding: Section(AddressFundingBodySchema.omit({ errors: true })), relatedDeployments: Section(DeployerLaunchesBodySchema.omit({ errors: true })),
59
+ timeline: z.array(z.strictObject({ blockNumber: z.string().regex(/^(0|[1-9][0-9]{0,77})$/), transactionHash: Hex32Schema.nullable(), kind: z.enum(['funding-transfer', 'contract-creation', 'related-creation']), summary: z.string().max(400), evidenceIds: z.array(ActivityEvidenceIdSchema).min(1) })).max(128),
60
+ graph: z.strictObject({ nodes: z.array(Node).max(96), edges: z.array(Edge).max(160) }),
61
+ findings: z.array(ActivityFindingSchema).max(64), alternativeExplanations: z.array(z.string().max(600)).max(12), unknowns: z.array(z.string().max(600)).max(24),
62
+ limitations: z.array(z.string().max(1000)).max(24), errors: z.array(IndexedReportErrorSchema).max(40), evidence: IndexedEvidenceSchema,
63
+ analysis: IndexedAnalysisSchema.optional(), usage: IndexedUsageSchema,
64
+ }).superRefine((report, ctx) => {
65
+ indexedReportIssues(report, DEPLOYER_TOOLS, ctx);
66
+ const nodes = new Set(report.graph.nodes.map((node) => node.id));
67
+ for (const edge of report.graph.edges)
68
+ if (!nodes.has(edge.from) || !nodes.has(edge.to))
69
+ ctx.addIssue({ code: 'custom', path: ['graph'], message: 'Every relationship edge must connect declared nodes.' });
70
+ if (report.origin && report.origin.contract.toLowerCase() !== report.input.contract.toLowerCase())
71
+ ctx.addIssue({ code: 'custom', path: ['origin'], message: 'The origin section must describe the accepted contract.' });
72
+ if (report.status === 'complete' && (!report.origin || !['confirmed-by-receipt', 'block-located'].includes(report.origin.creation.status) || report.funding.status !== 'observed' || report.relatedDeployments.status !== 'observed' || report.errors.length))
73
+ ctx.addIssue({ code: 'custom', path: ['status'], message: 'A complete investigation locates the creation and reads both relationship sections without errors.' });
74
+ });
75
+ export const DEPLOYER_RESULT_CONTRACT = { id: 'deployer-investigation-observed-v1', description: 'Charge only for a complete investigation read at one pinned latest block (sequencer-confirmed) that is still canonical at completion: contract code observed, the creation block located with a captured receipt or archive code checks, and the funding and related-deployment sections read with their index coverage stated. A reorganization, an unlocated creation or any read error makes the report partial or failed and charges nothing. No identity, ownership, fraud or safety claim is made.' };
76
+ export function deployerResultContractIssues(raw, manifest) {
77
+ const parsed = DeployerInvestigationReportSchema.safeParse(raw);
78
+ if (!parsed.success)
79
+ return [`The report does not match ${DEPLOYER_SCHEMA_ID}.`];
80
+ const report = parsed.data;
81
+ const issues = [];
82
+ const evidence = new Map(report.evidence.map((item) => [item.id, item]));
83
+ if (manifest && (report.agentVersion !== manifest.version || report.manifestHash !== contentHash(manifest)))
84
+ issues.push('The report is bound to another version.');
85
+ if (report.status !== 'complete')
86
+ issues.push(`The investigation is ${report.status}.`);
87
+ if (report.snapshot?.canonicality !== 'verified-at-completion')
88
+ issues.push('The pinned block was not rechecked as canonical.');
89
+ const creation = report.origin?.creation;
90
+ if (!creation || !['confirmed-by-receipt', 'block-located'].includes(creation.status) || creation.blockNumber.status !== 'observed')
91
+ issues.push('The creation block was not located.');
92
+ else if (creation.blockNumber.evidenceIds.some((id) => evidence.get(id)?.completeness !== 'complete-for-request'))
93
+ issues.push('The creation block is not backed by complete captured reads.');
94
+ if (!report.evidence.some((item) => item.source.method === 'eth_chainId' && item.completeness === 'complete-for-request'))
95
+ issues.push('Chain identity was not captured.');
96
+ if (report.funding.status !== 'observed' || report.relatedDeployments.status !== 'observed')
97
+ issues.push('A relationship section was not read.');
98
+ return issues;
99
+ }
100
+ export const satisfiesDeployerResultContract = (raw, manifest) => deployerResultContractIssues(raw, manifest).length === 0;
101
+ export const validateDeployerReceipt = (evidence, input) => validateIndexedReceipt(evidence, input, DEPLOYER_TOOLS);