@hivemind-os/collective-types 0.2.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.
@@ -0,0 +1,573 @@
1
+ declare enum PaymentRail {
2
+ SUI_ESCROW = "SUI_ESCROW",
3
+ SUI_TRANSFER = "SUI_TRANSFER",
4
+ X402_BASE = "X402_BASE"
5
+ }
6
+ interface SpendingLimit {
7
+ amount: bigint;
8
+ interval: 'transaction' | 'hour' | 'day' | 'month' | 'lifetime';
9
+ rail?: PaymentRail;
10
+ currency?: string;
11
+ scope?: string;
12
+ }
13
+ interface SpendingPolicy {
14
+ defaultRail?: PaymentRail;
15
+ requireConfirmationAbove?: bigint;
16
+ limits: SpendingLimit[];
17
+ allowlist?: string[];
18
+ denylist?: string[];
19
+ }
20
+ interface PricingInfo {
21
+ rail: PaymentRail;
22
+ amount: bigint;
23
+ currency: 'MIST' | 'USDC' | (string & {});
24
+ cadence?: 'flat' | 'per-task' | 'per-second';
25
+ quoteExpiresAt?: number;
26
+ }
27
+
28
+ declare const didBrand: unique symbol;
29
+ type DID = `did:mesh:${string}` & {
30
+ readonly [didBrand]: 'DID';
31
+ };
32
+ interface RelayEndpoint {
33
+ relayDid?: DID;
34
+ endpoint: string;
35
+ modes?: Array<'sync' | 'streaming' | 'fallback' | 'negotiation'>;
36
+ }
37
+ interface Capability {
38
+ name: string;
39
+ description: string;
40
+ version: string;
41
+ pricing: PricingInfo;
42
+ executionMode?: 'sync' | 'async';
43
+ paymentRails?: PaymentRail[];
44
+ }
45
+ declare enum AgentStatus {
46
+ ACTIVE = "ACTIVE",
47
+ INACTIVE = "INACTIVE"
48
+ }
49
+ interface AgentCard {
50
+ id: string;
51
+ owner: string;
52
+ did: DID;
53
+ name: string;
54
+ description: string;
55
+ capabilities: Capability[];
56
+ endpoint?: string;
57
+ relayEndpoints?: RelayEndpoint[];
58
+ encryptionPublicKey?: string;
59
+ active: boolean;
60
+ version: number;
61
+ registeredAt: number;
62
+ updatedAt: number;
63
+ totalTasksCompleted?: number;
64
+ totalTasksFailed?: number;
65
+ totalTasksDisputed?: number;
66
+ totalEarningsMist?: bigint;
67
+ hasStake?: boolean;
68
+ stakeMist?: bigint;
69
+ stakeType?: 'agent' | 'relay';
70
+ }
71
+
72
+ declare enum PaymentScheme {
73
+ EXACT = "exact",
74
+ UPTO = "upto",
75
+ STREAM = "stream"
76
+ }
77
+ interface MeteringConfig {
78
+ scheme: PaymentScheme;
79
+ unitPrice: bigint;
80
+ maxPrice: bigint;
81
+ estimatedUnits?: number;
82
+ }
83
+ interface MeteringReport {
84
+ taskId: string;
85
+ actualUnits: number;
86
+ actualCost: bigint;
87
+ maxPrice: bigint;
88
+ refundAmount: bigint;
89
+ verificationHash: string;
90
+ }
91
+ interface HashChainProof {
92
+ root: string;
93
+ intermediateHashes: string[];
94
+ unitCount: number;
95
+ }
96
+ interface StreamingPaymentState {
97
+ taskId: string;
98
+ totalPaid: bigint;
99
+ maxBudget: bigint;
100
+ currentUnit: number;
101
+ lastPaymentTimestamp: number;
102
+ }
103
+
104
+ declare enum BidStatus {
105
+ ACTIVE = 0,
106
+ ACCEPTED = 1,
107
+ REJECTED = 2,
108
+ WITHDRAWN = 3
109
+ }
110
+ type TaskCategory = string;
111
+ declare const TaskCategories: {
112
+ readonly GENERAL: "general";
113
+ readonly ANALYSIS: "analysis";
114
+ readonly CODE: "code";
115
+ readonly DATA: "data";
116
+ readonly RESEARCH: "research";
117
+ };
118
+ interface Bid {
119
+ id: string;
120
+ taskId: string;
121
+ bidder: string;
122
+ bidPrice: bigint;
123
+ reputationScore: bigint;
124
+ evidenceBlob?: string;
125
+ createdAt: number;
126
+ status: BidStatus;
127
+ }
128
+ interface BidRecommendation {
129
+ bid: Bid;
130
+ score: bigint;
131
+ reputationWeight: bigint;
132
+ priceWeight: bigint;
133
+ }
134
+
135
+ declare enum TaskStatus {
136
+ OPEN = 0,
137
+ ACCEPTED = 1,
138
+ COMPLETED = 2,
139
+ RELEASED = 3,
140
+ DISPUTED = 4,
141
+ CANCELLED = 5
142
+ }
143
+ interface TaskInput {
144
+ blobId: string;
145
+ contentType?: string;
146
+ encoding?: string;
147
+ checksum?: string;
148
+ sizeBytes?: number;
149
+ metadata?: Record<string, string>;
150
+ }
151
+ interface TaskResult {
152
+ blobId: string;
153
+ contentType?: string;
154
+ encoding?: string;
155
+ checksum?: string;
156
+ sizeBytes?: number;
157
+ metadata?: Record<string, string>;
158
+ }
159
+ interface EscrowInfo {
160
+ amount: bigint;
161
+ disputeWindowMs: number;
162
+ createdAt: number;
163
+ expiresAt: number;
164
+ releasedAt?: number;
165
+ disputedAt?: number;
166
+ }
167
+ interface Task {
168
+ id: string;
169
+ requester: string;
170
+ provider?: string;
171
+ capability: string;
172
+ category: TaskCategory;
173
+ inputBlobId: string;
174
+ resultBlobId?: string;
175
+ price: bigint;
176
+ paymentScheme?: PaymentScheme;
177
+ maxPrice?: bigint;
178
+ meteredUnits?: number;
179
+ unitPrice?: bigint;
180
+ verificationHash?: string;
181
+ status: TaskStatus;
182
+ disputeWindowMs: number;
183
+ createdAt: number;
184
+ acceptedAt?: number;
185
+ completedAt?: number;
186
+ expiresAt: number;
187
+ agreementHash?: string;
188
+ }
189
+
190
+ declare enum RelayNodeStatus {
191
+ ACTIVE = 0,
192
+ INACTIVE = 1,
193
+ SLASHED = 2
194
+ }
195
+ interface RelayNode {
196
+ id: string;
197
+ operator: string;
198
+ endpoint: string;
199
+ stakePositionId: string;
200
+ capabilities: string[];
201
+ region: string;
202
+ status: RelayNodeStatus;
203
+ registeredAt: number;
204
+ lastHeartbeat: number;
205
+ routingFeeBps: number;
206
+ totalRouted: number;
207
+ totalFeesEarnedMist: bigint;
208
+ stakeAmountMist?: bigint;
209
+ heartbeatAgeMs?: number;
210
+ isHeartbeatFresh?: boolean;
211
+ }
212
+ interface RelayListFilters {
213
+ status?: RelayNodeStatus | RelayNodeStatus[];
214
+ activeOnly?: boolean;
215
+ capability?: string;
216
+ region?: string;
217
+ operator?: string;
218
+ stakePositionId?: string;
219
+ endpoint?: string;
220
+ heartbeatWithinMs?: number;
221
+ }
222
+
223
+ interface MeshEventBase<TType extends string> {
224
+ type: TType;
225
+ packageId: string;
226
+ txDigest: string;
227
+ timestampMs: number;
228
+ }
229
+ interface AgentRegisteredEvent extends MeshEventBase<'agent.registered'> {
230
+ registryId: string;
231
+ agent: AgentCard;
232
+ }
233
+ interface AgentUpdatedEvent extends MeshEventBase<'agent.updated'> {
234
+ agent: AgentCard;
235
+ previousVersion: number;
236
+ }
237
+ interface AgentDeactivatedEvent extends MeshEventBase<'agent.deactivated'> {
238
+ agentId: string;
239
+ owner: string;
240
+ deactivatedAt: number;
241
+ }
242
+ interface TaskPostedEvent extends MeshEventBase<'task.posted'> {
243
+ task: Task;
244
+ }
245
+ interface TaskAcceptedEvent extends MeshEventBase<'task.accepted'> {
246
+ taskId: string;
247
+ requester: string;
248
+ provider: string;
249
+ price: bigint;
250
+ acceptedAt: number;
251
+ status: TaskStatus.ACCEPTED;
252
+ }
253
+ interface TaskCompletedEvent extends MeshEventBase<'task.completed'> {
254
+ taskId: string;
255
+ provider: string;
256
+ resultBlobId: string;
257
+ price: bigint;
258
+ paymentScheme?: Task['paymentScheme'];
259
+ meteredUnits?: number;
260
+ verificationHash?: string;
261
+ completedAt: number;
262
+ status: TaskStatus.COMPLETED;
263
+ }
264
+ interface TaskReleasedEvent extends MeshEventBase<'task.released'> {
265
+ taskId: string;
266
+ requester: string;
267
+ provider: string;
268
+ price: bigint;
269
+ refundAmount?: bigint;
270
+ releasedAt: number;
271
+ status: TaskStatus.RELEASED;
272
+ }
273
+ interface TaskDisputedEvent extends MeshEventBase<'task.disputed'> {
274
+ taskId: string;
275
+ requester: string;
276
+ provider?: string;
277
+ disputedAt: number;
278
+ status: TaskStatus.DISPUTED;
279
+ }
280
+ interface TaskCancelledEvent extends MeshEventBase<'task.cancelled'> {
281
+ taskId: string;
282
+ requester: string;
283
+ cancelledAt: number;
284
+ status: TaskStatus.CANCELLED;
285
+ }
286
+ interface BidPlacedEvent extends MeshEventBase<'bid.placed'> {
287
+ bid: Bid;
288
+ }
289
+ interface BidAcceptedEvent extends MeshEventBase<'bid.accepted'> {
290
+ bidId: string;
291
+ taskId: string;
292
+ requester: string;
293
+ bidder: string;
294
+ bidPrice: bigint;
295
+ refundedAmount: bigint;
296
+ acceptedAt: number;
297
+ status: BidStatus.ACCEPTED;
298
+ }
299
+ interface BidWithdrawnEvent extends MeshEventBase<'bid.withdrawn'> {
300
+ bidId: string;
301
+ taskId: string;
302
+ bidder: string;
303
+ withdrawnAt: number;
304
+ status: BidStatus.WITHDRAWN;
305
+ }
306
+ interface BidRejectedEvent extends MeshEventBase<'bid.rejected'> {
307
+ bidId: string;
308
+ taskId: string;
309
+ requester: string;
310
+ bidder: string;
311
+ rejectedAt: number;
312
+ status: BidStatus.REJECTED;
313
+ }
314
+ interface RelayRegisteredEvent extends MeshEventBase<'relay.registered'> {
315
+ relay: RelayNode;
316
+ }
317
+ interface RelayHeartbeatEvent extends MeshEventBase<'relay.heartbeat'> {
318
+ relayId: string;
319
+ operator: string;
320
+ lastHeartbeat: number;
321
+ }
322
+ interface RelayDeactivatedEvent extends MeshEventBase<'relay.deactivated'> {
323
+ relayId: string;
324
+ operator: string;
325
+ status: RelayNodeStatus.INACTIVE;
326
+ }
327
+ interface RelaySlashedEvent extends MeshEventBase<'relay.slashed'> {
328
+ relayId: string;
329
+ operator: string;
330
+ status: RelayNodeStatus.SLASHED;
331
+ }
332
+ type MeshEvent = AgentRegisteredEvent | AgentUpdatedEvent | AgentDeactivatedEvent | TaskPostedEvent | TaskAcceptedEvent | TaskCompletedEvent | TaskReleasedEvent | TaskDisputedEvent | TaskCancelledEvent | BidPlacedEvent | BidAcceptedEvent | BidWithdrawnEvent | BidRejectedEvent | RelayRegisteredEvent | RelayHeartbeatEvent | RelayDeactivatedEvent | RelaySlashedEvent;
333
+
334
+ interface RelayEndpointConfig {
335
+ url: string;
336
+ relayDid?: DID;
337
+ }
338
+ interface RelayClientConfig {
339
+ enabled: boolean;
340
+ endpoints: RelayEndpointConfig[];
341
+ autoConnect: boolean;
342
+ providerMode: boolean;
343
+ reconnectIntervalMs?: number;
344
+ heartbeatIntervalMs?: number;
345
+ }
346
+ interface NetworkConfig {
347
+ rpcUrl: string;
348
+ faucetUrl: string;
349
+ packageId: string;
350
+ registryId: string;
351
+ }
352
+ interface IdentityConfig {
353
+ did: DID;
354
+ keystorePath?: string;
355
+ keyAlias?: string;
356
+ }
357
+ interface AuthConfig {
358
+ mode: 'ed25519' | 'zklogin';
359
+ google?: {
360
+ clientId: string;
361
+ };
362
+ apple?: {
363
+ clientId: string;
364
+ };
365
+ portal?: {
366
+ port: number;
367
+ };
368
+ }
369
+ interface BlobStoreConfig {
370
+ mode: 'filesystem' | 'walrus' | 'hybrid';
371
+ filesystem?: {
372
+ dataDir: string;
373
+ };
374
+ walrus?: {
375
+ publisherUrl: string;
376
+ aggregatorUrl: string;
377
+ epochs?: number;
378
+ maxBlobSize?: number;
379
+ retryAttempts?: number;
380
+ retryDelayMs?: number;
381
+ timeoutMs?: number;
382
+ };
383
+ hybrid?: {
384
+ cacheLocally: boolean;
385
+ preferWalrus: boolean;
386
+ };
387
+ }
388
+ interface EvmConfig {
389
+ enabled: boolean;
390
+ network: 'base' | 'base-sepolia' | 'localhost';
391
+ rpcUrl?: string;
392
+ }
393
+ interface PaymentConfig {
394
+ preferredRail: 'auto' | 'sui' | 'x402';
395
+ evm?: EvmConfig;
396
+ }
397
+ interface EncryptionConfig {
398
+ enabled: boolean;
399
+ requireEncryption: boolean;
400
+ }
401
+ interface DaemonConfig {
402
+ autoStart: boolean;
403
+ ipcPath: string;
404
+ dataDir: string;
405
+ logLevel?: 'debug' | 'info' | 'warn' | 'error';
406
+ }
407
+ interface MeshConfig {
408
+ network: NetworkConfig;
409
+ identity: IdentityConfig;
410
+ auth?: AuthConfig;
411
+ spending: SpendingPolicy;
412
+ payment?: PaymentConfig;
413
+ daemon: DaemonConfig;
414
+ relay?: RelayClientConfig;
415
+ blobstore?: BlobStoreConfig;
416
+ encryption?: EncryptionConfig;
417
+ }
418
+
419
+ interface ReputationEvent {
420
+ eventId: string;
421
+ type: ReputationEventType;
422
+ subject: string;
423
+ author: string;
424
+ taskId: string;
425
+ outcome: 'success' | 'failure' | 'timeout' | 'cancelled' | 'disputed';
426
+ rating?: number;
427
+ capability: string;
428
+ paymentAmount?: {
429
+ amount: string;
430
+ currency: string;
431
+ };
432
+ latencyMs?: number;
433
+ timestamp: string;
434
+ nonce: string;
435
+ signature: string;
436
+ }
437
+ type ReputationEventType = 'task_completion' | 'task_failure' | 'task_timeout' | 'task_cancellation' | 'dispute_opened' | 'dispute_resolved' | 'payment_confirmed';
438
+ interface ReputationScore {
439
+ did: string;
440
+ successRate: number;
441
+ totalTasks: number;
442
+ totalDisputes: number;
443
+ averageLatencyMs: number;
444
+ totalEarningsMist: bigint;
445
+ stakeAmount: bigint;
446
+ registeredAt: number;
447
+ lastActiveAt: number;
448
+ capabilityScores: Record<string, {
449
+ successRate: number;
450
+ taskCount: number;
451
+ averageLatencyMs: number;
452
+ }>;
453
+ }
454
+ interface ReputationAnchor {
455
+ anchorId: string;
456
+ author: string;
457
+ merkleRoot: string;
458
+ eventCount: number;
459
+ blobId: string;
460
+ fromTimestamp: number;
461
+ toTimestamp: number;
462
+ }
463
+
464
+ interface StakePosition {
465
+ id: string;
466
+ owner: string;
467
+ stakeType: 'agent' | 'relay';
468
+ balanceMist: bigint;
469
+ stakedAt: number;
470
+ deactivatedAt: number;
471
+ slashedAmount: bigint;
472
+ isActive?: boolean;
473
+ meetsMinium?: boolean;
474
+ meetsMinimum?: boolean;
475
+ }
476
+ interface SlashRecord {
477
+ id: string;
478
+ target: string;
479
+ evidenceType: 'expired_escrow' | 'non_delivery';
480
+ taskId: string;
481
+ amount: bigint;
482
+ timestamp: number;
483
+ }
484
+
485
+ declare enum DisputeStatus {
486
+ OPEN = 0,
487
+ RESPONDED = 1,
488
+ MUTUAL_RESOLVED = 2,
489
+ ARBITRATED = 3,
490
+ EXPIRED = 4
491
+ }
492
+ interface Dispute {
493
+ id: string;
494
+ taskId: string;
495
+ requester: string;
496
+ provider: string;
497
+ escrowAmount: bigint;
498
+ status: DisputeStatus;
499
+ requesterEvidenceBlob: string;
500
+ providerEvidenceBlob?: string;
501
+ requesterProposedSplit: bigint;
502
+ providerProposedSplit: bigint;
503
+ arbitrator?: string;
504
+ rulingSplit: bigint;
505
+ openedAt: number;
506
+ respondedAt?: number;
507
+ resolvedAt?: number;
508
+ resolutionDeadline: number;
509
+ }
510
+
511
+ declare enum ProviderSelectionStrategy {
512
+ CHEAPEST = "cheapest",
513
+ FASTEST = "fastest",
514
+ HIGHEST_REPUTATION = "highest_reputation",
515
+ ROUND_ROBIN = "round_robin",
516
+ WEIGHTED = "weighted"
517
+ }
518
+ interface MultiProviderRequest {
519
+ capability: string;
520
+ input: unknown;
521
+ fanOutCount: number;
522
+ strategy: ProviderSelectionStrategy;
523
+ aggregation: AggregationMode;
524
+ timeout?: number;
525
+ maxPricePerProvider?: bigint;
526
+ }
527
+ declare enum AggregationMode {
528
+ FIRST_SUCCESS = "first_success",
529
+ ALL = "all",
530
+ MAJORITY = "majority",
531
+ BEST = "best"
532
+ }
533
+ interface ProviderScore {
534
+ did: DID;
535
+ price: bigint;
536
+ reputation: number;
537
+ estimatedLatency?: number;
538
+ circuitBreakerOpen: boolean;
539
+ compositeScore: number;
540
+ }
541
+ interface MultiProviderResult {
542
+ results: Array<{
543
+ provider: DID;
544
+ status: 'success' | 'failure' | 'timeout';
545
+ result?: unknown;
546
+ durationMs: number;
547
+ error?: string;
548
+ }>;
549
+ aggregatedResult?: unknown;
550
+ totalCost: bigint;
551
+ }
552
+
553
+ type NetworkName = 'testnet' | 'mainnet' | 'devnet' | 'local';
554
+ interface NetworkPreset extends NetworkConfig {
555
+ name: NetworkName;
556
+ explorerUrl: string;
557
+ }
558
+ /**
559
+ * Well-known contract deployments for each Sui network.
560
+ * Updated after each deploy-contracts.yml run.
561
+ */
562
+ declare const NETWORK_PRESETS: Record<NetworkName, NetworkPreset>;
563
+ /**
564
+ * Resolve a network name to its preset configuration.
565
+ * Returns undefined if the name is not recognized.
566
+ */
567
+ declare function getNetworkPreset(name: string): NetworkPreset | undefined;
568
+ /**
569
+ * List all available network preset names.
570
+ */
571
+ declare function getNetworkNames(): NetworkName[];
572
+
573
+ export { type AgentCard, type AgentDeactivatedEvent, type AgentRegisteredEvent, AgentStatus, type AgentUpdatedEvent, AggregationMode, type AuthConfig, type Bid, type BidAcceptedEvent, type BidPlacedEvent, type BidRecommendation, type BidRejectedEvent, BidStatus, type BidWithdrawnEvent, type BlobStoreConfig, type Capability, type DID, type DaemonConfig, type Dispute, DisputeStatus, type EncryptionConfig, type EscrowInfo, type EvmConfig, type HashChainProof, type IdentityConfig, type MeshConfig, type MeshEvent, type MeteringConfig, type MeteringReport, type MultiProviderRequest, type MultiProviderResult, NETWORK_PRESETS, type NetworkConfig, type NetworkName, type NetworkPreset, type PaymentConfig, PaymentRail, PaymentScheme, type PricingInfo, type ProviderScore, ProviderSelectionStrategy, type RelayClientConfig, type RelayDeactivatedEvent, type RelayEndpoint, type RelayEndpointConfig, type RelayHeartbeatEvent, type RelayListFilters, type RelayNode, RelayNodeStatus, type RelayRegisteredEvent, type RelaySlashedEvent, type ReputationAnchor, type ReputationEvent, type ReputationEventType, type ReputationScore, type SlashRecord, type SpendingLimit, type SpendingPolicy, type StakePosition, type StreamingPaymentState, type Task, type TaskAcceptedEvent, type TaskCancelledEvent, TaskCategories, type TaskCategory, type TaskCompletedEvent, type TaskDisputedEvent, type TaskInput, type TaskPostedEvent, type TaskReleasedEvent, type TaskResult, TaskStatus, getNetworkNames, getNetworkPreset };
package/dist/index.js ADDED
@@ -0,0 +1,142 @@
1
+ // src/agent.ts
2
+ var AgentStatus = /* @__PURE__ */ ((AgentStatus2) => {
3
+ AgentStatus2["ACTIVE"] = "ACTIVE";
4
+ AgentStatus2["INACTIVE"] = "INACTIVE";
5
+ return AgentStatus2;
6
+ })(AgentStatus || {});
7
+
8
+ // src/task.ts
9
+ var TaskStatus = /* @__PURE__ */ ((TaskStatus3) => {
10
+ TaskStatus3[TaskStatus3["OPEN"] = 0] = "OPEN";
11
+ TaskStatus3[TaskStatus3["ACCEPTED"] = 1] = "ACCEPTED";
12
+ TaskStatus3[TaskStatus3["COMPLETED"] = 2] = "COMPLETED";
13
+ TaskStatus3[TaskStatus3["RELEASED"] = 3] = "RELEASED";
14
+ TaskStatus3[TaskStatus3["DISPUTED"] = 4] = "DISPUTED";
15
+ TaskStatus3[TaskStatus3["CANCELLED"] = 5] = "CANCELLED";
16
+ return TaskStatus3;
17
+ })(TaskStatus || {});
18
+
19
+ // src/marketplace.ts
20
+ var BidStatus = /* @__PURE__ */ ((BidStatus3) => {
21
+ BidStatus3[BidStatus3["ACTIVE"] = 0] = "ACTIVE";
22
+ BidStatus3[BidStatus3["ACCEPTED"] = 1] = "ACCEPTED";
23
+ BidStatus3[BidStatus3["REJECTED"] = 2] = "REJECTED";
24
+ BidStatus3[BidStatus3["WITHDRAWN"] = 3] = "WITHDRAWN";
25
+ return BidStatus3;
26
+ })(BidStatus || {});
27
+ var TaskCategories = {
28
+ GENERAL: "general",
29
+ ANALYSIS: "analysis",
30
+ CODE: "code",
31
+ DATA: "data",
32
+ RESEARCH: "research"
33
+ };
34
+
35
+ // src/relay.ts
36
+ var RelayNodeStatus = /* @__PURE__ */ ((RelayNodeStatus3) => {
37
+ RelayNodeStatus3[RelayNodeStatus3["ACTIVE"] = 0] = "ACTIVE";
38
+ RelayNodeStatus3[RelayNodeStatus3["INACTIVE"] = 1] = "INACTIVE";
39
+ RelayNodeStatus3[RelayNodeStatus3["SLASHED"] = 2] = "SLASHED";
40
+ return RelayNodeStatus3;
41
+ })(RelayNodeStatus || {});
42
+
43
+ // src/payment.ts
44
+ var PaymentRail = /* @__PURE__ */ ((PaymentRail2) => {
45
+ PaymentRail2["SUI_ESCROW"] = "SUI_ESCROW";
46
+ PaymentRail2["SUI_TRANSFER"] = "SUI_TRANSFER";
47
+ PaymentRail2["X402_BASE"] = "X402_BASE";
48
+ return PaymentRail2;
49
+ })(PaymentRail || {});
50
+
51
+ // src/metering.ts
52
+ var PaymentScheme = /* @__PURE__ */ ((PaymentScheme2) => {
53
+ PaymentScheme2["EXACT"] = "exact";
54
+ PaymentScheme2["UPTO"] = "upto";
55
+ PaymentScheme2["STREAM"] = "stream";
56
+ return PaymentScheme2;
57
+ })(PaymentScheme || {});
58
+
59
+ // src/dispute.ts
60
+ var DisputeStatus = /* @__PURE__ */ ((DisputeStatus2) => {
61
+ DisputeStatus2[DisputeStatus2["OPEN"] = 0] = "OPEN";
62
+ DisputeStatus2[DisputeStatus2["RESPONDED"] = 1] = "RESPONDED";
63
+ DisputeStatus2[DisputeStatus2["MUTUAL_RESOLVED"] = 2] = "MUTUAL_RESOLVED";
64
+ DisputeStatus2[DisputeStatus2["ARBITRATED"] = 3] = "ARBITRATED";
65
+ DisputeStatus2[DisputeStatus2["EXPIRED"] = 4] = "EXPIRED";
66
+ return DisputeStatus2;
67
+ })(DisputeStatus || {});
68
+
69
+ // src/routing.ts
70
+ var ProviderSelectionStrategy = /* @__PURE__ */ ((ProviderSelectionStrategy2) => {
71
+ ProviderSelectionStrategy2["CHEAPEST"] = "cheapest";
72
+ ProviderSelectionStrategy2["FASTEST"] = "fastest";
73
+ ProviderSelectionStrategy2["HIGHEST_REPUTATION"] = "highest_reputation";
74
+ ProviderSelectionStrategy2["ROUND_ROBIN"] = "round_robin";
75
+ ProviderSelectionStrategy2["WEIGHTED"] = "weighted";
76
+ return ProviderSelectionStrategy2;
77
+ })(ProviderSelectionStrategy || {});
78
+ var AggregationMode = /* @__PURE__ */ ((AggregationMode2) => {
79
+ AggregationMode2["FIRST_SUCCESS"] = "first_success";
80
+ AggregationMode2["ALL"] = "all";
81
+ AggregationMode2["MAJORITY"] = "majority";
82
+ AggregationMode2["BEST"] = "best";
83
+ return AggregationMode2;
84
+ })(AggregationMode || {});
85
+
86
+ // src/networks.ts
87
+ var NETWORK_PRESETS = {
88
+ testnet: {
89
+ name: "testnet",
90
+ rpcUrl: "https://fullnode.testnet.sui.io:443",
91
+ faucetUrl: "https://faucet.testnet.sui.io",
92
+ packageId: "0xad62fa133e2ad67889f6452fb8b8303a369be1c762e94f18896307202229c61f",
93
+ registryId: "0x1d595fe6ac6be0d86ca233b2029ecaf3e1aed110ff947f3335aaddef7a7fec9d",
94
+ explorerUrl: "https://suiscan.xyz/testnet"
95
+ },
96
+ mainnet: {
97
+ name: "mainnet",
98
+ rpcUrl: "https://fullnode.mainnet.sui.io:443",
99
+ faucetUrl: "",
100
+ packageId: "",
101
+ registryId: "",
102
+ explorerUrl: "https://suiscan.xyz/mainnet"
103
+ },
104
+ devnet: {
105
+ name: "devnet",
106
+ rpcUrl: "https://fullnode.devnet.sui.io:443",
107
+ faucetUrl: "https://faucet.devnet.sui.io",
108
+ packageId: "",
109
+ registryId: "",
110
+ explorerUrl: "https://suiscan.xyz/devnet"
111
+ },
112
+ local: {
113
+ name: "local",
114
+ rpcUrl: "http://127.0.0.1:9000",
115
+ faucetUrl: "http://127.0.0.1:9123",
116
+ packageId: "",
117
+ registryId: "",
118
+ explorerUrl: ""
119
+ }
120
+ };
121
+ function getNetworkPreset(name) {
122
+ return NETWORK_PRESETS[name];
123
+ }
124
+ function getNetworkNames() {
125
+ return Object.keys(NETWORK_PRESETS);
126
+ }
127
+ export {
128
+ AgentStatus,
129
+ AggregationMode,
130
+ BidStatus,
131
+ DisputeStatus,
132
+ NETWORK_PRESETS,
133
+ PaymentRail,
134
+ PaymentScheme,
135
+ ProviderSelectionStrategy,
136
+ RelayNodeStatus,
137
+ TaskCategories,
138
+ TaskStatus,
139
+ getNetworkNames,
140
+ getNetworkPreset
141
+ };
142
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/agent.ts","../src/task.ts","../src/marketplace.ts","../src/relay.ts","../src/payment.ts","../src/metering.ts","../src/dispute.ts","../src/routing.ts","../src/networks.ts"],"sourcesContent":["import type { PaymentRail, PricingInfo } from './payment.js';\n\ndeclare const didBrand: unique symbol;\n\nexport type DID = `did:mesh:${string}` & {\n readonly [didBrand]: 'DID';\n};\n\nexport interface RelayEndpoint {\n relayDid?: DID;\n endpoint: string;\n modes?: Array<'sync' | 'streaming' | 'fallback' | 'negotiation'>;\n}\n\nexport interface Capability {\n name: string;\n description: string;\n version: string;\n pricing: PricingInfo;\n executionMode?: 'sync' | 'async';\n paymentRails?: PaymentRail[];\n}\n\nexport enum AgentStatus {\n ACTIVE = 'ACTIVE',\n INACTIVE = 'INACTIVE',\n}\n\nexport interface AgentCard {\n id: string;\n owner: string;\n did: DID;\n name: string;\n description: string;\n capabilities: Capability[];\n endpoint?: string;\n relayEndpoints?: RelayEndpoint[];\n encryptionPublicKey?: string;\n active: boolean;\n version: number;\n registeredAt: number;\n updatedAt: number;\n totalTasksCompleted?: number;\n totalTasksFailed?: number;\n totalTasksDisputed?: number;\n totalEarningsMist?: bigint;\n hasStake?: boolean;\n stakeMist?: bigint;\n stakeType?: 'agent' | 'relay';\n}\n","import type { PaymentScheme } from './metering.js';\nimport type { TaskCategory } from './marketplace.js';\n\nexport enum TaskStatus {\n OPEN = 0,\n ACCEPTED = 1,\n COMPLETED = 2,\n RELEASED = 3,\n DISPUTED = 4,\n CANCELLED = 5,\n}\n\nexport interface TaskInput {\n blobId: string;\n contentType?: string;\n encoding?: string;\n checksum?: string;\n sizeBytes?: number;\n metadata?: Record<string, string>;\n}\n\nexport interface TaskResult {\n blobId: string;\n contentType?: string;\n encoding?: string;\n checksum?: string;\n sizeBytes?: number;\n metadata?: Record<string, string>;\n}\n\nexport interface EscrowInfo {\n amount: bigint;\n disputeWindowMs: number;\n createdAt: number;\n expiresAt: number;\n releasedAt?: number;\n disputedAt?: number;\n}\n\nexport interface Task {\n id: string;\n requester: string;\n provider?: string;\n capability: string;\n category: TaskCategory;\n inputBlobId: string;\n resultBlobId?: string;\n price: bigint;\n paymentScheme?: PaymentScheme;\n maxPrice?: bigint;\n meteredUnits?: number;\n unitPrice?: bigint;\n verificationHash?: string;\n status: TaskStatus;\n disputeWindowMs: number;\n createdAt: number;\n acceptedAt?: number;\n completedAt?: number;\n expiresAt: number;\n agreementHash?: string;\n}\n","export enum BidStatus {\n ACTIVE = 0,\n ACCEPTED = 1,\n REJECTED = 2,\n WITHDRAWN = 3,\n}\n\nexport type TaskCategory = string;\n\nexport const TaskCategories = {\n GENERAL: 'general',\n ANALYSIS: 'analysis',\n CODE: 'code',\n DATA: 'data',\n RESEARCH: 'research',\n} as const;\n\nexport interface Bid {\n id: string;\n taskId: string;\n bidder: string;\n bidPrice: bigint;\n reputationScore: bigint;\n evidenceBlob?: string;\n createdAt: number;\n status: BidStatus;\n}\n\nexport interface BidRecommendation {\n bid: Bid;\n score: bigint;\n reputationWeight: bigint;\n priceWeight: bigint;\n}\n","export enum RelayNodeStatus {\n ACTIVE = 0,\n INACTIVE = 1,\n SLASHED = 2,\n}\n\nexport interface RelayNode {\n id: string;\n operator: string;\n endpoint: string;\n stakePositionId: string;\n capabilities: string[];\n region: string;\n status: RelayNodeStatus;\n registeredAt: number;\n lastHeartbeat: number;\n routingFeeBps: number;\n totalRouted: number;\n totalFeesEarnedMist: bigint;\n stakeAmountMist?: bigint;\n heartbeatAgeMs?: number;\n isHeartbeatFresh?: boolean;\n}\n\nexport interface RelayListFilters {\n status?: RelayNodeStatus | RelayNodeStatus[];\n activeOnly?: boolean;\n capability?: string;\n region?: string;\n operator?: string;\n stakePositionId?: string;\n endpoint?: string;\n heartbeatWithinMs?: number;\n}\n","export enum PaymentRail {\n SUI_ESCROW = 'SUI_ESCROW',\n SUI_TRANSFER = 'SUI_TRANSFER',\n X402_BASE = 'X402_BASE',\n}\n\nexport interface SpendingLimit {\n amount: bigint;\n interval: 'transaction' | 'hour' | 'day' | 'month' | 'lifetime';\n rail?: PaymentRail;\n currency?: string;\n scope?: string;\n}\n\nexport interface SpendingPolicy {\n defaultRail?: PaymentRail;\n requireConfirmationAbove?: bigint;\n limits: SpendingLimit[];\n allowlist?: string[];\n denylist?: string[];\n}\n\nexport interface PricingInfo {\n rail: PaymentRail;\n amount: bigint;\n currency: 'MIST' | 'USDC' | (string & {});\n cadence?: 'flat' | 'per-task' | 'per-second';\n quoteExpiresAt?: number;\n}\n","export enum PaymentScheme {\n EXACT = 'exact',\n UPTO = 'upto',\n STREAM = 'stream',\n}\n\nexport interface MeteringConfig {\n scheme: PaymentScheme;\n unitPrice: bigint;\n maxPrice: bigint;\n estimatedUnits?: number;\n}\n\nexport interface MeteringReport {\n taskId: string;\n actualUnits: number;\n actualCost: bigint;\n maxPrice: bigint;\n refundAmount: bigint;\n verificationHash: string;\n}\n\nexport interface HashChainProof {\n root: string;\n intermediateHashes: string[];\n unitCount: number;\n}\n\nexport interface StreamingPaymentState {\n taskId: string;\n totalPaid: bigint;\n maxBudget: bigint;\n currentUnit: number;\n lastPaymentTimestamp: number;\n}\n","export enum DisputeStatus {\n OPEN = 0,\n RESPONDED = 1,\n MUTUAL_RESOLVED = 2,\n ARBITRATED = 3,\n EXPIRED = 4,\n}\n\nexport interface Dispute {\n id: string;\n taskId: string;\n requester: string;\n provider: string;\n escrowAmount: bigint;\n status: DisputeStatus;\n requesterEvidenceBlob: string;\n providerEvidenceBlob?: string;\n requesterProposedSplit: bigint;\n providerProposedSplit: bigint;\n arbitrator?: string;\n rulingSplit: bigint;\n openedAt: number;\n respondedAt?: number;\n resolvedAt?: number;\n resolutionDeadline: number;\n}\n","import type { DID } from './agent.js';\n\nexport enum ProviderSelectionStrategy {\n CHEAPEST = 'cheapest',\n FASTEST = 'fastest',\n HIGHEST_REPUTATION = 'highest_reputation',\n ROUND_ROBIN = 'round_robin',\n WEIGHTED = 'weighted',\n}\n\nexport interface MultiProviderRequest {\n capability: string;\n input: unknown;\n fanOutCount: number;\n strategy: ProviderSelectionStrategy;\n aggregation: AggregationMode;\n timeout?: number;\n maxPricePerProvider?: bigint;\n}\n\nexport enum AggregationMode {\n FIRST_SUCCESS = 'first_success',\n ALL = 'all',\n MAJORITY = 'majority',\n BEST = 'best',\n}\n\nexport interface ProviderScore {\n did: DID;\n price: bigint;\n reputation: number;\n estimatedLatency?: number;\n circuitBreakerOpen: boolean;\n compositeScore: number;\n}\n\nexport interface MultiProviderResult {\n results: Array<{\n provider: DID;\n status: 'success' | 'failure' | 'timeout';\n result?: unknown;\n durationMs: number;\n error?: string;\n }>;\n aggregatedResult?: unknown;\n totalCost: bigint;\n}\n","import type { NetworkConfig } from './config.js';\n\nexport type NetworkName = 'testnet' | 'mainnet' | 'devnet' | 'local';\n\nexport interface NetworkPreset extends NetworkConfig {\n name: NetworkName;\n explorerUrl: string;\n}\n\n/**\n * Well-known contract deployments for each Sui network.\n * Updated after each deploy-contracts.yml run.\n */\nexport const NETWORK_PRESETS: Record<NetworkName, NetworkPreset> = {\n testnet: {\n name: 'testnet',\n rpcUrl: 'https://fullnode.testnet.sui.io:443',\n faucetUrl: 'https://faucet.testnet.sui.io',\n packageId: '0xad62fa133e2ad67889f6452fb8b8303a369be1c762e94f18896307202229c61f',\n registryId: '0x1d595fe6ac6be0d86ca233b2029ecaf3e1aed110ff947f3335aaddef7a7fec9d',\n explorerUrl: 'https://suiscan.xyz/testnet',\n },\n mainnet: {\n name: 'mainnet',\n rpcUrl: 'https://fullnode.mainnet.sui.io:443',\n faucetUrl: '',\n packageId: '',\n registryId: '',\n explorerUrl: 'https://suiscan.xyz/mainnet',\n },\n devnet: {\n name: 'devnet',\n rpcUrl: 'https://fullnode.devnet.sui.io:443',\n faucetUrl: 'https://faucet.devnet.sui.io',\n packageId: '',\n registryId: '',\n explorerUrl: 'https://suiscan.xyz/devnet',\n },\n local: {\n name: 'local',\n rpcUrl: 'http://127.0.0.1:9000',\n faucetUrl: 'http://127.0.0.1:9123',\n packageId: '',\n registryId: '',\n explorerUrl: '',\n },\n};\n\n/**\n * Resolve a network name to its preset configuration.\n * Returns undefined if the name is not recognized.\n */\nexport function getNetworkPreset(name: string): NetworkPreset | undefined {\n return NETWORK_PRESETS[name as NetworkName];\n}\n\n/**\n * List all available network preset names.\n */\nexport function getNetworkNames(): NetworkName[] {\n return Object.keys(NETWORK_PRESETS) as NetworkName[];\n}\n"],"mappings":"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","names":["AgentStatus","TaskStatus","BidStatus","RelayNodeStatus","PaymentRail","PaymentScheme","DisputeStatus","ProviderSelectionStrategy","AggregationMode"]}
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@hivemind-os/collective-types",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsup --config tsup.config.ts",
18
+ "lint": "eslint src",
19
+ "clean": "rimraf dist"
20
+ }
21
+ }