@ghostspeak/sdk 2.0.6 → 2.0.7

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 (117) hide show
  1. package/README.md +152 -30
  2. package/dist/GhostSpeakClient-CWmGaM9Q.d.ts +1007 -0
  3. package/dist/StakingModule-C5rzuOWb.d.ts +2526 -0
  4. package/dist/{agent-M74TCRON.js → agent-5YLZ7DAC.js} +4 -4
  5. package/dist/{agent-M74TCRON.js.map → agent-5YLZ7DAC.js.map} +1 -1
  6. package/dist/batch-operations-45CQFEID.js +4 -0
  7. package/dist/batch-operations-45CQFEID.js.map +1 -0
  8. package/dist/browser.d.ts +45 -554
  9. package/dist/browser.js +15 -842
  10. package/dist/browser.js.map +1 -1
  11. package/dist/chunk-AL3HQN73.js +754 -0
  12. package/dist/chunk-AL3HQN73.js.map +1 -0
  13. package/dist/chunk-BF3IQ35I.js +284 -0
  14. package/dist/chunk-BF3IQ35I.js.map +1 -0
  15. package/dist/chunk-BQDGRTVP.js +168 -0
  16. package/dist/chunk-BQDGRTVP.js.map +1 -0
  17. package/dist/chunk-C5CDA3WX.js +7314 -0
  18. package/dist/chunk-C5CDA3WX.js.map +1 -0
  19. package/dist/chunk-E3FD2CNY.js +1869 -0
  20. package/dist/chunk-E3FD2CNY.js.map +1 -0
  21. package/dist/{chunk-F3DZMBUA.js → chunk-G7S6B6WB.js} +327 -493
  22. package/dist/chunk-G7S6B6WB.js.map +1 -0
  23. package/dist/chunk-IHVDQ4YI.js +4231 -0
  24. package/dist/chunk-IHVDQ4YI.js.map +1 -0
  25. package/dist/chunk-JV2SWONF.js +98 -0
  26. package/dist/chunk-JV2SWONF.js.map +1 -0
  27. package/dist/chunk-KB6CKIUK.js +231 -0
  28. package/dist/chunk-KB6CKIUK.js.map +1 -0
  29. package/dist/chunk-S74EH3KD.js +7890 -0
  30. package/dist/chunk-S74EH3KD.js.map +1 -0
  31. package/dist/chunk-SFTSZ3LC.js +156 -0
  32. package/dist/chunk-SFTSZ3LC.js.map +1 -0
  33. package/dist/chunk-SKMJJ3Q6.js +125 -0
  34. package/dist/chunk-SKMJJ3Q6.js.map +1 -0
  35. package/dist/chunk-SZGFSCNU.js +3682 -0
  36. package/dist/chunk-SZGFSCNU.js.map +1 -0
  37. package/dist/chunk-TTB4OS2D.js +69 -0
  38. package/dist/chunk-TTB4OS2D.js.map +1 -0
  39. package/dist/chunk-UP2VWCW5.js +33 -0
  40. package/dist/{chunk-NSBPE2FW.js.map → chunk-UP2VWCW5.js.map} +1 -1
  41. package/dist/{chunk-UJUGGLMT.js → chunk-VQZQCHUT.js} +5 -5
  42. package/dist/{chunk-UJUGGLMT.js.map → chunk-VQZQCHUT.js.map} +1 -1
  43. package/dist/client.d.ts +5 -4
  44. package/dist/client.js +11 -10
  45. package/dist/createAgentAuthorization-ULG47ZJI.js +5 -0
  46. package/dist/createAgentAuthorization-ULG47ZJI.js.map +1 -0
  47. package/dist/credentials.js +1 -1
  48. package/dist/crypto.js +2 -2
  49. package/dist/errors.js +1 -1
  50. package/dist/feature-flags-B1g0DCPe.d.ts +1181 -0
  51. package/dist/generated-EG5USUFG.js +9 -0
  52. package/dist/{generated-VNLHMR6Y.js.map → generated-EG5USUFG.js.map} +1 -1
  53. package/dist/{ghostspeak_wasm-SB2RPJ3D.js → ghostspeak_wasm-F227HOSM.js} +3 -3
  54. package/dist/{ghostspeak_wasm-SB2RPJ3D.js.map → ghostspeak_wasm-F227HOSM.js.map} +1 -1
  55. package/dist/index.d.ts +1209 -1506
  56. package/dist/index.js +600 -3532
  57. package/dist/index.js.map +1 -1
  58. package/dist/metafile-esm.json +1 -1
  59. package/dist/minimal/core-minimal.d.ts +2383 -1264
  60. package/dist/minimal/core-minimal.js +9 -9
  61. package/dist/minimal/core-minimal.js.map +1 -1
  62. package/dist/nacl-fast-W5BJ3KZ2.js +2229 -0
  63. package/dist/nacl-fast-W5BJ3KZ2.js.map +1 -0
  64. package/dist/pda-4KP7CURF.js +4 -0
  65. package/dist/pda-4KP7CURF.js.map +1 -0
  66. package/dist/pda-Ce7VYg4T.d.ts +25 -0
  67. package/dist/reputation-types-Yebf0Rm_.d.ts +1071 -0
  68. package/dist/revokeAuthorization-OK7E7OK3.js +5 -0
  69. package/dist/revokeAuthorization-OK7E7OK3.js.map +1 -0
  70. package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
  71. package/dist/types.js +1 -1
  72. package/dist/updateReputationWithAuth-Y4ONEVSP.js +5 -0
  73. package/dist/updateReputationWithAuth-Y4ONEVSP.js.map +1 -0
  74. package/dist/utils.d.ts +69 -203
  75. package/dist/utils.js +15 -153
  76. package/dist/utils.js.map +1 -1
  77. package/package.json +24 -31
  78. package/dist/.tsbuildinfo +0 -1
  79. package/dist/GhostSpeakClient-D_66Uzsf.d.ts +0 -707
  80. package/dist/GovernanceModule-DQYYys-H.d.ts +0 -1766
  81. package/dist/chunk-APCKGD23.js +0 -1328
  82. package/dist/chunk-APCKGD23.js.map +0 -1
  83. package/dist/chunk-ASQXX4IT.js +0 -572
  84. package/dist/chunk-ASQXX4IT.js.map +0 -1
  85. package/dist/chunk-COGZFWOT.js +0 -19657
  86. package/dist/chunk-COGZFWOT.js.map +0 -1
  87. package/dist/chunk-F3DZMBUA.js.map +0 -1
  88. package/dist/chunk-GMHIUK2R.js +0 -7526
  89. package/dist/chunk-GMHIUK2R.js.map +0 -1
  90. package/dist/chunk-IAWBZYPE.js +0 -356
  91. package/dist/chunk-IAWBZYPE.js.map +0 -1
  92. package/dist/chunk-NSBPE2FW.js +0 -15
  93. package/dist/chunk-OWYHJG6H.js +0 -13311
  94. package/dist/chunk-OWYHJG6H.js.map +0 -1
  95. package/dist/chunk-RDDPOFR5.js +0 -3
  96. package/dist/chunk-RDDPOFR5.js.map +0 -1
  97. package/dist/chunk-RERCHKZP.js +0 -35
  98. package/dist/chunk-RERCHKZP.js.map +0 -1
  99. package/dist/chunk-TVVGXYCI.js +0 -2887
  100. package/dist/chunk-TVVGXYCI.js.map +0 -1
  101. package/dist/chunk-ZGP5552B.js +0 -377
  102. package/dist/chunk-ZGP5552B.js.map +0 -1
  103. package/dist/chunk-ZWOYNHVK.js +0 -196
  104. package/dist/chunk-ZWOYNHVK.js.map +0 -1
  105. package/dist/dist/.tsbuildinfo +0 -1
  106. package/dist/elgamal-VZLWB3XK.js +0 -5
  107. package/dist/elgamal-VZLWB3XK.js.map +0 -1
  108. package/dist/feature-flags-V722ZuXO.d.ts +0 -3512
  109. package/dist/generated-VNLHMR6Y.js +0 -5
  110. package/dist/ipfs-types-BOt9ZNg4.d.ts +0 -592
  111. package/dist/multisigConfig-BzEhy6jy.d.ts +0 -58
  112. package/dist/pda-B_nS8SbD.d.ts +0 -114
  113. package/dist/pda-S4BFJVGE.js +0 -4
  114. package/dist/pda-S4BFJVGE.js.map +0 -1
  115. package/dist/system-addresses-BFNLEbFx.d.ts +0 -857
  116. package/dist/token-2022-rpc-RALH4RK7.js +0 -593
  117. package/dist/token-2022-rpc-RALH4RK7.js.map +0 -1
package/dist/utils.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- export { d as deriveAgentPda, a as deriveListingPda, f as findProgramDerivedAddress } from './pda-B_nS8SbD.js';
2
- import { A as Agent } from './feature-flags-V722ZuXO.js';
3
- export { E as ErrorContext, G as GhostSpeakSDKError, T as TokenProgram, j as accounts, c as createErrorContext, d as deriveAssociatedTokenAddress, a as detectTokenProgram, e as enhanceTransactionError, l as features, f as formatTokenAmount, g as getTokenProgramType, k as governance, b as ipfs, i as isToken2022Mint, p as parseTokenAmount, h as privacy, t as token2022, w as withEnhancedErrors } from './feature-flags-V722ZuXO.js';
1
+ export { d as deriveAgentPda, f as findProgramDerivedAddress } from './pda-Ce7VYg4T.js';
2
+ export { E as ErrorContext, G as GhostSpeakSDKError, R as ReputationTagEngine, T as TokenProgram, j as accounts, c as createErrorContext, d as deriveAssociatedTokenAddress, a as detectTokenProgram, e as enhanceTransactionError, l as features, f as formatTokenAmount, g as getTokenProgramType, k as governance, b as ipfs, i as isToken2022Mint, p as parseTokenAmount, h as privacy, w as withEnhancedErrors } from './feature-flags-B1g0DCPe.js';
3
+ export { s as authSignatures, c as createAuthorizationMessage, b as createSignedAuthorization, e as deserializeAuthorization, g as generateNonce, f as getAuthorizationId, h as isAuthorizationExhausted, i as isAuthorizationExpired, d as serializeAuthorization, a as signAuthorizationMessage, j as validateAuthorizationNetwork, v as verifyAuthorizationSignature } from './signature-verification-DGxR4aYQ.js';
4
+ import { R as ReputationData, J as JobPerformance, a as ReputationCalculationResult, P as PerformanceSnapshot } from './reputation-types-Yebf0Rm_.js';
4
5
  import '@solana/addresses';
5
6
  import '@solana/kit';
6
- import './ipfs-types-BOt9ZNg4.js';
7
- import './multisigConfig-BzEhy6jy.js';
8
7
 
9
8
  /**
10
9
  * Common utility functions for GhostSpeak SDK
@@ -19,203 +18,70 @@ declare function sol(amount: number): bigint;
19
18
  declare function lamportsToSol(lamports: bigint): number;
20
19
 
21
20
  /**
22
- * Agent Status Utilities for Proof-of-Agent Verification
23
- *
24
- * Provides functions to determine agent activity status based on x402 payment history.
25
- * Uses snake_case field names to match the AgentDiscoveryClient.Agent interface.
26
- *
27
- * @module utils/agent-status
28
- */
29
-
30
- /**
31
- * Agent status enumeration
32
- */
33
- declare enum AgentStatus {
34
- /** Agent has never completed a paid x402 transaction */
35
- Unverified = "unverified",
36
- /** Agent has received payment within the activity threshold */
37
- Active = "active",
38
- /** Agent has payment history but no recent activity */
39
- Inactive = "inactive",
40
- /** Agent is inactive beyond recovery threshold (deprecated - use Inactive) */
41
- Dead = "dead"
21
+ * Advanced reputation calculation engine
22
+ */
23
+ declare class ReputationCalculator {
24
+ private fraudPatterns;
25
+ constructor();
26
+ /**
27
+ * Initialize fraud detection patterns
28
+ */
29
+ private initializeFraudPatterns;
30
+ /**
31
+ * Calculate reputation update based on job performance
32
+ */
33
+ calculateReputation(currentData: ReputationData, jobPerformance: JobPerformance): ReputationCalculationResult;
34
+ /**
35
+ * Apply time-based reputation decay
36
+ */
37
+ private applyTimeDecay;
38
+ /**
39
+ * Calculate weighted score based on job performance
40
+ */
41
+ private calculateWeightedScore;
42
+ /**
43
+ * Calculate timeliness score based on expected vs actual duration
44
+ */
45
+ private calculateTimelinessScore;
46
+ /**
47
+ * Calculate dispute score
48
+ */
49
+ private calculateDisputeScore;
50
+ /**
51
+ * Update category-specific reputation
52
+ */
53
+ private updateCategoryReputation;
54
+ /**
55
+ * Calculate overall score from category reputations
56
+ */
57
+ private calculateOverallScore;
58
+ /**
59
+ * Get reputation tier from score
60
+ */
61
+ private getTierFromScore;
62
+ /**
63
+ * Check for badge achievements
64
+ */
65
+ private checkBadgeAchievements;
66
+ /**
67
+ * Detect potential fraud patterns
68
+ */
69
+ private detectFraud;
70
+ /**
71
+ * Create performance snapshot
72
+ */
73
+ createPerformanceSnapshot(data: ReputationData, newScore: number): PerformanceSnapshot;
74
+ /**
75
+ * Calculate reputation slash amount
76
+ */
77
+ calculateSlashAmount(currentScore: number, slashPercentage: number): {
78
+ newScore: number;
79
+ slashAmount: number;
80
+ };
81
+ /**
82
+ * Calculate staking bonus
83
+ */
84
+ calculateStakingBonus(stakeAmount: number): number;
42
85
  }
43
- /**
44
- * Configuration options for agent status checks
45
- */
46
- interface AgentStatusConfig {
47
- /** Activity threshold in seconds (default: 30 days) */
48
- activityThresholdSeconds?: number;
49
- /** Current timestamp in seconds (default: Date.now() / 1000) */
50
- currentTimestamp?: number;
51
- }
52
- /**
53
- * Check if an agent is verified (has completed at least 1 paid x402 transaction)
54
- *
55
- * @param agent - Agent object with x402_total_calls field
56
- * @returns true if agent has at least 1 x402 call
57
- *
58
- * @example
59
- * ```typescript
60
- * const agent = await discoveryClient.getAgent(address)
61
- * if (isAgentVerified(agent)) {
62
- * console.log('Agent has completed paid work')
63
- * }
64
- * ```
65
- */
66
- declare function isAgentVerified(agent: Pick<Agent, 'x402_total_calls'>): boolean;
67
- /**
68
- * Check if an agent is active (received payment within threshold)
69
- *
70
- * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields
71
- * @param config - Optional configuration for thresholds
72
- * @returns true if agent is verified AND has recent activity
73
- *
74
- * @example
75
- * ```typescript
76
- * const agent = await discoveryClient.getAgent(address)
77
- * if (isAgentActive(agent)) {
78
- * console.log('Agent is actively providing services')
79
- * }
80
- * ```
81
- */
82
- declare function isAgentActive(agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>, config?: AgentStatusConfig): boolean;
83
- /**
84
- * Check if an agent is inactive (has payment history but no recent activity)
85
- *
86
- * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields
87
- * @param config - Optional configuration for thresholds
88
- * @returns true if agent is verified but has not had recent activity
89
- *
90
- * @example
91
- * ```typescript
92
- * const agent = await discoveryClient.getAgent(address)
93
- * if (isAgentInactive(agent)) {
94
- * console.log('Agent has gone dormant')
95
- * }
96
- * ```
97
- */
98
- declare function isAgentInactive(agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>, config?: AgentStatusConfig): boolean;
99
- /**
100
- * Check if an agent is dead (alias for isAgentInactive for backwards compatibility)
101
- *
102
- * @deprecated Use isAgentInactive instead. "Dead" and "Inactive" are semantically identical.
103
- *
104
- * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields
105
- * @param config - Optional configuration for thresholds
106
- * @returns true if agent is verified but has not had recent activity
107
- */
108
- declare function isAgentDead(agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>, config?: AgentStatusConfig): boolean;
109
- /**
110
- * Get the comprehensive status of an agent
111
- *
112
- * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields
113
- * @param config - Optional configuration for thresholds
114
- * @returns AgentStatus enum value
115
- *
116
- * @example
117
- * ```typescript
118
- * const agent = await discoveryClient.getAgent(address)
119
- * const status = getAgentStatus(agent)
120
- * switch (status) {
121
- * case AgentStatus.Active:
122
- * console.log('Agent is actively serving')
123
- * break
124
- * case AgentStatus.Inactive:
125
- * console.log('Agent has gone dormant')
126
- * break
127
- * case AgentStatus.Unverified:
128
- * console.log('Agent has not completed paid work')
129
- * break
130
- * }
131
- * ```
132
- */
133
- declare function getAgentStatus(agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>, config?: AgentStatusConfig): AgentStatus;
134
- /**
135
- * Filter options for agent status filtering
136
- */
137
- interface AgentStatusFilterOptions {
138
- /** Exclude agents that have never completed an x402 transaction */
139
- excludeUnverified?: boolean;
140
- /** Exclude agents that have not been active within the threshold */
141
- excludeInactive?: boolean;
142
- /** Alias for excludeInactive for backwards compatibility */
143
- excludeDead?: boolean;
144
- /** Configuration for status checks */
145
- config?: AgentStatusConfig;
146
- }
147
- /**
148
- * Filter agents by their activity status
149
- *
150
- * @param agents - Array of agents to filter
151
- * @param options - Filter options
152
- * @returns Filtered array of agents
153
- *
154
- * @example
155
- * ```typescript
156
- * const allAgents = await discoveryClient.searchAgents()
157
- * const activeAgents = filterAgentsByStatus(allAgents.agents, {
158
- * excludeUnverified: true,
159
- * excludeInactive: true
160
- * })
161
- * ```
162
- */
163
- declare function filterAgentsByStatus<T extends Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>>(agents: T[], options?: AgentStatusFilterOptions): T[];
164
- /**
165
- * Sort agents by their activity (most recently active first)
166
- *
167
- * @param agents - Array of agents to sort
168
- * @returns Sorted array of agents (descending by last_payment_timestamp)
169
- *
170
- * @example
171
- * ```typescript
172
- * const agents = await discoveryClient.searchAgents()
173
- * const sortedAgents = sortAgentsByActivity(agents.agents)
174
- * // sortedAgents[0] is the agent with most recent last_payment_timestamp
175
- * ```
176
- */
177
- declare function sortAgentsByActivity<T extends Pick<Agent, 'last_payment_timestamp'>>(agents: T[]): T[];
178
- /**
179
- * Get time since last payment in a human-readable format
180
- *
181
- * @param agent - Agent object with last_payment_timestamp field
182
- * @param config - Optional configuration
183
- * @returns Human-readable time string (e.g., "2 days ago", "1 month ago")
184
- *
185
- * @example
186
- * ```typescript
187
- * const agent = await discoveryClient.getAgent(address)
188
- * console.log(`Last active: ${getTimeSinceLastPayment(agent)}`)
189
- * // Output: "Last active: 5 days ago"
190
- * ```
191
- */
192
- declare function getTimeSinceLastPayment(agent: Pick<Agent, 'last_payment_timestamp'>, config?: AgentStatusConfig): string;
193
- /**
194
- * Summary statistics for a collection of agents
195
- */
196
- interface AgentStatusSummary {
197
- total: number;
198
- verified: number;
199
- active: number;
200
- inactive: number;
201
- unverified: number;
202
- activePercentage: number;
203
- verifiedPercentage: number;
204
- }
205
- /**
206
- * Get summary statistics for a collection of agents
207
- *
208
- * @param agents - Array of agents to summarize
209
- * @param config - Optional configuration for status checks
210
- * @returns Summary statistics object
211
- *
212
- * @example
213
- * ```typescript
214
- * const allAgents = await discoveryClient.searchAgents()
215
- * const summary = getAgentStatusSummary(allAgents.agents)
216
- * console.log(`${summary.activePercentage}% of agents are active`)
217
- * ```
218
- */
219
- declare function getAgentStatusSummary<T extends Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>>(agents: T[], config?: AgentStatusConfig): AgentStatusSummary;
220
86
 
221
- export { AgentStatus, type AgentStatusConfig, type AgentStatusFilterOptions, type AgentStatusSummary, filterAgentsByStatus, getAgentStatus, getAgentStatusSummary, getTimeSinceLastPayment, isAgentActive, isAgentDead, isAgentInactive, isAgentVerified, lamportsToSol, sol, sortAgentsByActivity };
87
+ export { ReputationCalculator, lamportsToSol, sol };
package/dist/utils.js CHANGED
@@ -1,14 +1,16 @@
1
- export { account_diagnostics_exports as accounts, deriveAssociatedTokenAddress, detectTokenProgram, feature_flags_exports as features, formatTokenAmount, getTokenProgramType, isToken2022Mint, parseTokenAmount, client_encryption_exports as privacy, token_2022_extensions_exports as token2022 } from './chunk-F3DZMBUA.js';
2
- import './chunk-IAWBZYPE.js';
3
- export { governance_helpers_exports as governance } from './chunk-ZGP5552B.js';
4
- export { GhostSpeakSDKError, createErrorContext, enhanceTransactionError, ipfs_client_exports as ipfs, withEnhancedErrors } from './chunk-OWYHJG6H.js';
5
- import './chunk-COGZFWOT.js';
6
- import './chunk-GMHIUK2R.js';
7
- export { deriveAgentPda, deriveServiceListingPda as deriveListingPda, findProgramDerivedAddress } from './chunk-ASQXX4IT.js';
8
- import './chunk-RERCHKZP.js';
9
- import './chunk-RDDPOFR5.js';
1
+ export { account_diagnostics_exports as accounts, deriveAssociatedTokenAddress, detectTokenProgram, feature_flags_exports as features, formatTokenAmount, getTokenProgramType, governance_helpers_exports as governance, isToken2022Mint, parseTokenAmount, client_encryption_exports as privacy } from './chunk-G7S6B6WB.js';
2
+ export { deriveAgentPda, findProgramDerivedAddress } from './chunk-BF3IQ35I.js';
3
+ export { signature_verification_exports as authSignatures, createAuthorizationMessage, createSignedAuthorization, deserializeAuthorization, generateNonce, getAuthorizationId, isAuthorizationExhausted, isAuthorizationExpired, serializeAuthorization, signAuthorizationMessage, validateAuthorizationNetwork, verifyAuthorizationSignature } from './chunk-BQDGRTVP.js';
4
+ import { init_reputation_tag_engine } from './chunk-C5CDA3WX.js';
5
+ export { GhostSpeakSDKError, ReputationCalculator, ReputationTagEngine, createErrorContext, enhanceTransactionError, ipfs_client_exports as ipfs, withEnhancedErrors } from './chunk-C5CDA3WX.js';
6
+ import './chunk-S74EH3KD.js';
7
+ import './chunk-IHVDQ4YI.js';
8
+ import './chunk-SFTSZ3LC.js';
9
+ import './chunk-JV2SWONF.js';
10
+ import './chunk-KB6CKIUK.js';
11
+ import './chunk-AL3HQN73.js';
10
12
  import './chunk-SRS2SKFS.js';
11
- import './chunk-NSBPE2FW.js';
13
+ import './chunk-UP2VWCW5.js';
12
14
 
13
15
  // src/utils/common.ts
14
16
  function sol(amount) {
@@ -18,149 +20,9 @@ function lamportsToSol(lamports) {
18
20
  return Number(lamports) / 1e9;
19
21
  }
20
22
 
21
- // src/utils/agent-status.ts
22
- var AgentStatus = /* @__PURE__ */ ((AgentStatus2) => {
23
- AgentStatus2["Unverified"] = "unverified";
24
- AgentStatus2["Active"] = "active";
25
- AgentStatus2["Inactive"] = "inactive";
26
- AgentStatus2["Dead"] = "dead";
27
- return AgentStatus2;
28
- })(AgentStatus || {});
29
- var DEFAULT_ACTIVITY_THRESHOLD = 30 * 24 * 60 * 60;
30
- function getCurrentTimestamp(config) {
31
- return config.currentTimestamp ?? Math.floor(Date.now() / 1e3);
32
- }
33
- function getActivityThreshold(config) {
34
- return config.activityThresholdSeconds ?? DEFAULT_ACTIVITY_THRESHOLD;
35
- }
36
- function isAgentVerified(agent) {
37
- return agent.x402_total_calls > 0n;
38
- }
39
- function isAgentActive(agent, config = {}) {
40
- if (!isAgentVerified(agent)) {
41
- return false;
42
- }
43
- const currentTimestamp = getCurrentTimestamp(config);
44
- const threshold = getActivityThreshold(config);
45
- const lastPayment = Number(agent.last_payment_timestamp);
46
- const timeSinceLastPayment = currentTimestamp - lastPayment;
47
- return timeSinceLastPayment <= threshold;
48
- }
49
- function isAgentInactive(agent, config = {}) {
50
- if (!isAgentVerified(agent)) {
51
- return false;
52
- }
53
- const currentTimestamp = getCurrentTimestamp(config);
54
- const threshold = getActivityThreshold(config);
55
- const lastPayment = Number(agent.last_payment_timestamp);
56
- const timeSinceLastPayment = currentTimestamp - lastPayment;
57
- return timeSinceLastPayment > threshold;
58
- }
59
- function isAgentDead(agent, config = {}) {
60
- return isAgentInactive(agent, config);
61
- }
62
- function getAgentStatus(agent, config = {}) {
63
- if (!isAgentVerified(agent)) {
64
- return "unverified" /* Unverified */;
65
- }
66
- if (isAgentActive(agent, config)) {
67
- return "active" /* Active */;
68
- }
69
- return "inactive" /* Inactive */;
70
- }
71
- function filterAgentsByStatus(agents, options = {}) {
72
- const config = options.config ?? {};
73
- const excludeInactive = options.excludeInactive ?? options.excludeDead ?? false;
74
- return agents.filter((agent) => {
75
- if (options.excludeUnverified && !isAgentVerified(agent)) {
76
- return false;
77
- }
78
- if (excludeInactive && isAgentInactive(agent, config)) {
79
- return false;
80
- }
81
- return true;
82
- });
83
- }
84
- function sortAgentsByActivity(agents) {
85
- return [...agents].sort((a, b) => {
86
- const timestampA = Number(a.last_payment_timestamp);
87
- const timestampB = Number(b.last_payment_timestamp);
88
- return timestampB - timestampA;
89
- });
90
- }
91
- function getTimeSinceLastPayment(agent, config = {}) {
92
- const lastPayment = Number(agent.last_payment_timestamp);
93
- if (lastPayment === 0) {
94
- return "Never";
95
- }
96
- const currentTimestamp = getCurrentTimestamp(config);
97
- const seconds = currentTimestamp - lastPayment;
98
- if (seconds < 60) {
99
- return "Just now";
100
- }
101
- const minutes = Math.floor(seconds / 60);
102
- if (minutes < 60) {
103
- return `${minutes} minute${minutes !== 1 ? "s" : ""} ago`;
104
- }
105
- const hours = Math.floor(minutes / 60);
106
- if (hours < 24) {
107
- return `${hours} hour${hours !== 1 ? "s" : ""} ago`;
108
- }
109
- const days = Math.floor(hours / 24);
110
- if (days < 30) {
111
- return `${days} day${days !== 1 ? "s" : ""} ago`;
112
- }
113
- const months = Math.floor(days / 30);
114
- if (months < 12) {
115
- return `${months} month${months !== 1 ? "s" : ""} ago`;
116
- }
117
- const years = Math.floor(months / 12);
118
- return `${years} year${years !== 1 ? "s" : ""} ago`;
119
- }
120
- function getAgentStatusSummary(agents, config = {}) {
121
- const total = agents.length;
122
- if (total === 0) {
123
- return {
124
- total: 0,
125
- verified: 0,
126
- active: 0,
127
- inactive: 0,
128
- unverified: 0,
129
- activePercentage: 0,
130
- verifiedPercentage: 0
131
- };
132
- }
133
- let verified = 0;
134
- let active = 0;
135
- let inactive = 0;
136
- let unverified = 0;
137
- for (const agent of agents) {
138
- const status = getAgentStatus(agent, config);
139
- switch (status) {
140
- case "active" /* Active */:
141
- verified++;
142
- active++;
143
- break;
144
- case "inactive" /* Inactive */:
145
- verified++;
146
- inactive++;
147
- break;
148
- case "unverified" /* Unverified */:
149
- unverified++;
150
- break;
151
- }
152
- }
153
- return {
154
- total,
155
- verified,
156
- active,
157
- inactive,
158
- unverified,
159
- activePercentage: Math.round(active / total * 100),
160
- verifiedPercentage: Math.round(verified / total * 100)
161
- };
162
- }
23
+ // src/utils/index.ts
24
+ init_reputation_tag_engine();
163
25
 
164
- export { AgentStatus, filterAgentsByStatus, getAgentStatus, getAgentStatusSummary, getTimeSinceLastPayment, isAgentActive, isAgentDead, isAgentInactive, isAgentVerified, lamportsToSol, sol, sortAgentsByActivity };
26
+ export { lamportsToSol, sol };
165
27
  //# sourceMappingURL=utils.js.map
166
28
  //# sourceMappingURL=utils.js.map
package/dist/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/utils/common.ts","../src/utils/agent-status.ts"],"names":["AgentStatus"],"mappings":";;;;;;;;;;;;;AAOO,SAAS,IAAI,MAAA,EAAwB;AAC1C,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,MAAA,GAAS,GAAa,CAAC,CAAA;AAClD;AAKO,SAAS,cAAc,QAAA,EAA0B;AACtD,EAAA,OAAO,MAAA,CAAO,QAAQ,CAAA,GAAI,GAAA;AAC5B;;;ACFO,IAAK,WAAA,qBAAAA,YAAAA,KAAL;AAEL,EAAAA,aAAA,YAAA,CAAA,GAAa,YAAA;AAEb,EAAAA,aAAA,QAAA,CAAA,GAAS,QAAA;AAET,EAAAA,aAAA,UAAA,CAAA,GAAW,UAAA;AAEX,EAAAA,aAAA,MAAA,CAAA,GAAO,MAAA;AARG,EAAA,OAAAA,YAAAA;AAAA,CAAA,EAAA,WAAA,IAAA,EAAA;AAsBZ,IAAM,0BAAA,GAA6B,EAAA,GAAK,EAAA,GAAK,EAAA,GAAK,EAAA;AAKlD,SAAS,oBAAoB,MAAA,EAAmC;AAC9D,EAAA,OAAO,OAAO,gBAAA,IAAoB,IAAA,CAAK,MAAM,IAAA,CAAK,GAAA,KAAQ,GAAI,CAAA;AAChE;AAKA,SAAS,qBAAqB,MAAA,EAAmC;AAC/D,EAAA,OAAO,OAAO,wBAAA,IAA4B,0BAAA;AAC5C;AAgBO,SAAS,gBACd,KAAA,EACS;AACT,EAAA,OAAO,MAAM,gBAAA,GAAmB,EAAA;AAClC;AAiBO,SAAS,aAAA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G;AACf,IAAA,OAAO;AAAA,MACL,KAAA,EAAO,CAAA;AAAA,MACP,QAAA,EAAU,CAAA;AAAA,MACV,MAAA,EAAQ,CAAA;AAAA,MACR,QAAA,EAAU,CAAA;AAAA,MACV,UAAA,EAAY,CAAA;AAAA,MACZ,gBAAA,EAAkB,CAAA;AAAA,MAClB,kBAAA,EAAoB;AAAA,KACtB;AAAA,EACF;AAEA,EAAA,IAAI,QAAA,GAAW,CAAA;AACf,EAAA,IAAI,MAAA,GAAS,CAAA;AACb,EAAA,IAAI,QAAA,GAAW,CAAA;AACf,EAAA,IAAI,UAAA,GAAa,CAAA;AAEjB,EAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AAC1B,IAAA,MAAM,MAAA,GAAS,cAAA,CAAe,KAAA,EAAO,MAAM,CAAA;AAC3C,IAAA,QAAQ,MAAA;AAAQ,MACd,KAAK,QAAA;AACH,QAAA,QAAA,EAAA;AACA,QAAA,MAAA,EAAA;AACA,QAAA;AAAA,MACF,KAAK,UAAA;AACH,QAAA,QAAA,EAAA;AACA,QAAA,QAAA,EAAA;AACA,QAAA;AAAA,MACF,KAAK,YAAA;AACH,QAAA,UAAA,EAAA;AACA,QAAA;AAAA;AACJ,EACF;AAEA,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,QAAA;AAAA,IACA,MAAA;AAAA,IACA,QAAA;AAAA,IACA,UAAA;AAAA,IACA,gBAAA,EAAkB,IAAA,CAAK,KAAA,CAAO,MAAA,GAAS,QAAS,GAAG,CAAA;AAAA,IACnD,kBAAA,EAAoB,IAAA,CAAK,KAAA,CAAO,QAAA,GAAW,QAAS,GAAG;AAAA,GACzD;AACF","file":"utils.js","sourcesContent":["/**\n * Common utility functions for GhostSpeak SDK\n */\n\n/**\n * Convert SOL to lamports\n */\nexport function sol(amount: number): bigint {\n return BigInt(Math.round(amount * 1_000_000_000))\n}\n\n/**\n * Convert lamports to SOL\n */\nexport function lamportsToSol(lamports: bigint): number {\n return Number(lamports) / 1_000_000_000\n}","/**\n * Agent Status Utilities for Proof-of-Agent Verification\n *\n * Provides functions to determine agent activity status based on x402 payment history.\n * Uses snake_case field names to match the AgentDiscoveryClient.Agent interface.\n *\n * @module utils/agent-status\n */\n\nimport type { Agent } from '../x402/AgentDiscoveryClient.js'\n\n/**\n * Agent status enumeration\n */\nexport enum AgentStatus {\n /** Agent has never completed a paid x402 transaction */\n Unverified = 'unverified',\n /** Agent has received payment within the activity threshold */\n Active = 'active',\n /** Agent has payment history but no recent activity */\n Inactive = 'inactive',\n /** Agent is inactive beyond recovery threshold (deprecated - use Inactive) */\n Dead = 'dead'\n}\n\n/**\n * Configuration options for agent status checks\n */\nexport interface AgentStatusConfig {\n /** Activity threshold in seconds (default: 30 days) */\n activityThresholdSeconds?: number\n /** Current timestamp in seconds (default: Date.now() / 1000) */\n currentTimestamp?: number\n}\n\n/** Default activity threshold: 30 days in seconds */\nconst DEFAULT_ACTIVITY_THRESHOLD = 30 * 24 * 60 * 60\n\n/**\n * Get the current timestamp in seconds\n */\nfunction getCurrentTimestamp(config: AgentStatusConfig): number {\n return config.currentTimestamp ?? Math.floor(Date.now() / 1000)\n}\n\n/**\n * Get the activity threshold in seconds\n */\nfunction getActivityThreshold(config: AgentStatusConfig): number {\n return config.activityThresholdSeconds ?? DEFAULT_ACTIVITY_THRESHOLD\n}\n\n/**\n * Check if an agent is verified (has completed at least 1 paid x402 transaction)\n *\n * @param agent - Agent object with x402_total_calls field\n * @returns true if agent has at least 1 x402 call\n *\n * @example\n * ```typescript\n * const agent = await discoveryClient.getAgent(address)\n * if (isAgentVerified(agent)) {\n * console.log('Agent has completed paid work')\n * }\n * ```\n */\nexport function isAgentVerified(\n agent: Pick<Agent, 'x402_total_calls'>\n): boolean {\n return agent.x402_total_calls > 0n\n}\n\n/**\n * Check if an agent is active (received payment within threshold)\n *\n * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields\n * @param config - Optional configuration for thresholds\n * @returns true if agent is verified AND has recent activity\n *\n * @example\n * ```typescript\n * const agent = await discoveryClient.getAgent(address)\n * if (isAgentActive(agent)) {\n * console.log('Agent is actively providing services')\n * }\n * ```\n */\nexport function isAgentActive(\n agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>,\n config: AgentStatusConfig = {}\n): boolean {\n if (!isAgentVerified(agent)) {\n return false\n }\n\n const currentTimestamp = getCurrentTimestamp(config)\n const threshold = getActivityThreshold(config)\n const lastPayment = Number(agent.last_payment_timestamp)\n const timeSinceLastPayment = currentTimestamp - lastPayment\n\n return timeSinceLastPayment <= threshold\n}\n\n/**\n * Check if an agent is inactive (has payment history but no recent activity)\n *\n * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields\n * @param config - Optional configuration for thresholds\n * @returns true if agent is verified but has not had recent activity\n *\n * @example\n * ```typescript\n * const agent = await discoveryClient.getAgent(address)\n * if (isAgentInactive(agent)) {\n * console.log('Agent has gone dormant')\n * }\n * ```\n */\nexport function isAgentInactive(\n agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>,\n config: AgentStatusConfig = {}\n): boolean {\n if (!isAgentVerified(agent)) {\n return false // Unverified agents are not \"inactive\", just unverified\n }\n\n const currentTimestamp = getCurrentTimestamp(config)\n const threshold = getActivityThreshold(config)\n const lastPayment = Number(agent.last_payment_timestamp)\n const timeSinceLastPayment = currentTimestamp - lastPayment\n\n return timeSinceLastPayment > threshold\n}\n\n/**\n * Check if an agent is dead (alias for isAgentInactive for backwards compatibility)\n *\n * @deprecated Use isAgentInactive instead. \"Dead\" and \"Inactive\" are semantically identical.\n *\n * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields\n * @param config - Optional configuration for thresholds\n * @returns true if agent is verified but has not had recent activity\n */\nexport function isAgentDead(\n agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>,\n config: AgentStatusConfig = {}\n): boolean {\n return isAgentInactive(agent, config)\n}\n\n/**\n * Get the comprehensive status of an agent\n *\n * @param agent - Agent object with x402_total_calls and last_payment_timestamp fields\n * @param config - Optional configuration for thresholds\n * @returns AgentStatus enum value\n *\n * @example\n * ```typescript\n * const agent = await discoveryClient.getAgent(address)\n * const status = getAgentStatus(agent)\n * switch (status) {\n * case AgentStatus.Active:\n * console.log('Agent is actively serving')\n * break\n * case AgentStatus.Inactive:\n * console.log('Agent has gone dormant')\n * break\n * case AgentStatus.Unverified:\n * console.log('Agent has not completed paid work')\n * break\n * }\n * ```\n */\nexport function getAgentStatus(\n agent: Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>,\n config: AgentStatusConfig = {}\n): AgentStatus {\n if (!isAgentVerified(agent)) {\n return AgentStatus.Unverified\n }\n\n if (isAgentActive(agent, config)) {\n return AgentStatus.Active\n }\n\n return AgentStatus.Inactive\n}\n\n/**\n * Filter options for agent status filtering\n */\nexport interface AgentStatusFilterOptions {\n /** Exclude agents that have never completed an x402 transaction */\n excludeUnverified?: boolean\n /** Exclude agents that have not been active within the threshold */\n excludeInactive?: boolean\n /** Alias for excludeInactive for backwards compatibility */\n excludeDead?: boolean\n /** Configuration for status checks */\n config?: AgentStatusConfig\n}\n\n/**\n * Filter agents by their activity status\n *\n * @param agents - Array of agents to filter\n * @param options - Filter options\n * @returns Filtered array of agents\n *\n * @example\n * ```typescript\n * const allAgents = await discoveryClient.searchAgents()\n * const activeAgents = filterAgentsByStatus(allAgents.agents, {\n * excludeUnverified: true,\n * excludeInactive: true\n * })\n * ```\n */\nexport function filterAgentsByStatus<\n T extends Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>\n>(agents: T[], options: AgentStatusFilterOptions = {}): T[] {\n const config = options.config ?? {}\n const excludeInactive = options.excludeInactive ?? options.excludeDead ?? false\n\n return agents.filter((agent) => {\n // Check unverified filter\n if (options.excludeUnverified && !isAgentVerified(agent)) {\n return false\n }\n\n // Check inactive filter\n if (excludeInactive && isAgentInactive(agent, config)) {\n return false\n }\n\n return true\n })\n}\n\n/**\n * Sort agents by their activity (most recently active first)\n *\n * @param agents - Array of agents to sort\n * @returns Sorted array of agents (descending by last_payment_timestamp)\n *\n * @example\n * ```typescript\n * const agents = await discoveryClient.searchAgents()\n * const sortedAgents = sortAgentsByActivity(agents.agents)\n * // sortedAgents[0] is the agent with most recent last_payment_timestamp\n * ```\n */\nexport function sortAgentsByActivity<\n T extends Pick<Agent, 'last_payment_timestamp'>\n>(agents: T[]): T[] {\n return [...agents].sort((a, b) => {\n const timestampA = Number(a.last_payment_timestamp)\n const timestampB = Number(b.last_payment_timestamp)\n return timestampB - timestampA // Descending order (most recent first)\n })\n}\n\n/**\n * Get time since last payment in a human-readable format\n *\n * @param agent - Agent object with last_payment_timestamp field\n * @param config - Optional configuration\n * @returns Human-readable time string (e.g., \"2 days ago\", \"1 month ago\")\n *\n * @example\n * ```typescript\n * const agent = await discoveryClient.getAgent(address)\n * console.log(`Last active: ${getTimeSinceLastPayment(agent)}`)\n * // Output: \"Last active: 5 days ago\"\n * ```\n */\nexport function getTimeSinceLastPayment(\n agent: Pick<Agent, 'last_payment_timestamp'>,\n config: AgentStatusConfig = {}\n): string {\n const lastPayment = Number(agent.last_payment_timestamp)\n\n if (lastPayment === 0) {\n return 'Never'\n }\n\n const currentTimestamp = getCurrentTimestamp(config)\n const seconds = currentTimestamp - lastPayment\n\n if (seconds < 60) {\n return 'Just now'\n }\n\n const minutes = Math.floor(seconds / 60)\n if (minutes < 60) {\n return `${minutes} minute${minutes !== 1 ? 's' : ''} ago`\n }\n\n const hours = Math.floor(minutes / 60)\n if (hours < 24) {\n return `${hours} hour${hours !== 1 ? 's' : ''} ago`\n }\n\n const days = Math.floor(hours / 24)\n if (days < 30) {\n return `${days} day${days !== 1 ? 's' : ''} ago`\n }\n\n const months = Math.floor(days / 30)\n if (months < 12) {\n return `${months} month${months !== 1 ? 's' : ''} ago`\n }\n\n const years = Math.floor(months / 12)\n return `${years} year${years !== 1 ? 's' : ''} ago`\n}\n\n/**\n * Summary statistics for a collection of agents\n */\nexport interface AgentStatusSummary {\n total: number\n verified: number\n active: number\n inactive: number\n unverified: number\n activePercentage: number\n verifiedPercentage: number\n}\n\n/**\n * Get summary statistics for a collection of agents\n *\n * @param agents - Array of agents to summarize\n * @param config - Optional configuration for status checks\n * @returns Summary statistics object\n *\n * @example\n * ```typescript\n * const allAgents = await discoveryClient.searchAgents()\n * const summary = getAgentStatusSummary(allAgents.agents)\n * console.log(`${summary.activePercentage}% of agents are active`)\n * ```\n */\nexport function getAgentStatusSummary<\n T extends Pick<Agent, 'x402_total_calls' | 'last_payment_timestamp'>\n>(agents: T[], config: AgentStatusConfig = {}): AgentStatusSummary {\n const total = agents.length\n\n if (total === 0) {\n return {\n total: 0,\n verified: 0,\n active: 0,\n inactive: 0,\n unverified: 0,\n activePercentage: 0,\n verifiedPercentage: 0\n }\n }\n\n let verified = 0\n let active = 0\n let inactive = 0\n let unverified = 0\n\n for (const agent of agents) {\n const status = getAgentStatus(agent, config)\n switch (status) {\n case AgentStatus.Active:\n verified++\n active++\n break\n case AgentStatus.Inactive:\n verified++\n inactive++\n break\n case AgentStatus.Unverified:\n unverified++\n break\n }\n }\n\n return {\n total,\n verified,\n active,\n inactive,\n unverified,\n activePercentage: Math.round((active / total) * 100),\n verifiedPercentage: Math.round((verified / total) * 100)\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/utils/common.ts","../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAOO,SAAS,IAAI,MAAA,EAAwB;AAC1C,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,MAAA,GAAS,GAAa,CAAC,CAAA;AAClD;AAKO,SAAS,cAAc,QAAA,EAA0B;AACtD,EAAA,OAAO,MAAA,CAAO,QAAQ,CAAA,GAAI,GAAA;AAC5B;;;AC4DA,0BAAA,EAAA","file":"utils.js","sourcesContent":["/**\n * Common utility functions for GhostSpeak SDK\n */\n\n/**\n * Convert SOL to lamports\n */\nexport function sol(amount: number): bigint {\n return BigInt(Math.round(amount * 1_000_000_000))\n}\n\n/**\n * Convert lamports to SOL\n */\nexport function lamportsToSol(lamports: bigint): number {\n return Number(lamports) / 1_000_000_000\n}","/**\n * Utilities Index - Tree-shakeable Exports\n * \n * Import only the utilities you need for optimal bundle size.\n */\n\n// Most commonly used utilities\nexport { sol, lamportsToSol } from './common.js'\n\n// PDA derivation (frequently used)\nexport {\n deriveAgentPda,\n findProgramDerivedAddress\n} from './pda.js'\n\n// Token operations (moderate usage)\nexport {\n deriveAssociatedTokenAddress,\n detectTokenProgram,\n isToken2022Mint,\n getTokenProgramType,\n formatTokenAmount,\n parseTokenAmount,\n type TokenProgram\n} from './token-utils.js'\n\n// Error handling (essential for good UX)\nexport {\n GhostSpeakSDKError,\n withEnhancedErrors,\n enhanceTransactionError,\n createErrorContext,\n type ErrorContext\n} from './enhanced-client-errors.js'\n\n// Advanced utilities (tree-shakeable bulk exports)\n// Only import specific modules if needed to avoid bundle bloat\n\n// Token-2022 extensions removed - not aligned with pivot\n\n// IPFS operations (for large content)\nexport * as ipfs from './ipfs-client.js'\n\n// Privacy and encryption (specialized usage)\nexport * as privacy from './client-encryption.js'\n\n// Agent authorization signatures - GhostSpeak trustless delegation\nexport * as authSignatures from './signature-verification.js'\nexport {\n createAuthorizationMessage,\n signAuthorizationMessage,\n verifyAuthorizationSignature,\n createSignedAuthorization,\n generateNonce,\n serializeAuthorization,\n deserializeAuthorization,\n getAuthorizationId,\n isAuthorizationExpired,\n isAuthorizationExhausted,\n validateAuthorizationNetwork,\n} from './signature-verification.js'\n\n// Confidential transfers removed - x402 payment protocol focus\n// export * as confidential from './confidential-transfer-manager.js'\n\n// Account management (diagnostic and migration)\nexport * as accounts from './account-diagnostics.js'\n\n// Governance helpers (DAO functionality)\nexport * as governance from './governance-helpers.js'\n\n// Feature flags and gates (configuration)\nexport * as features from './feature-flags.js'\n\n// Reputation calculation and tagging (reputation layer)\nexport { ReputationCalculator } from './reputation-calculator.js'\nexport { ReputationTagEngine } from './reputation-tag-engine.js'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghostspeak/sdk",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "TypeScript SDK for GhostSpeak AI Agent Commerce Protocol - Production Ready Beta",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -56,8 +56,9 @@
56
56
  "dist"
57
57
  ],
58
58
  "scripts": {
59
- "generate": "codama run --config codama.config.js js && bun scripts/generate-mappings.ts && bun scripts/generate-missing-types.ts",
60
- "build": "bun run build:wasm && tsup",
59
+ "generate": "codama run --config codama.config.js js && bun scripts/generate-mappings.ts",
60
+ "build": "tsup",
61
+ "build:full": "bun run build:wasm && tsup",
61
62
  "build:wasm": "bun run wasm:build",
62
63
  "build:dev": "tsup --watch",
63
64
  "dev": "tsup --watch",
@@ -75,10 +76,6 @@
75
76
  "wasm:build": "cd src/wasm/crypto-wasm && wasm-pack build --target web --out-dir ../../../dist/wasm --scope ghostspeak",
76
77
  "wasm:clean": "rm -rf dist/wasm src/wasm/crypto-wasm/pkg",
77
78
  "wasm:install": "cargo install wasm-pack",
78
- "db:generate": "drizzle-kit generate",
79
- "db:migrate": "drizzle-kit migrate",
80
- "db:push": "drizzle-kit push",
81
- "db:studio": "drizzle-kit studio",
82
79
  "lint": "eslint src --no-error-on-unmatched-pattern --ignore-pattern 'src/generated/**' && eslint src/generated --no-error-on-unmatched-pattern --config .eslintrc.generated.js",
83
80
  "lint:fix": "eslint src --fix --ignore-pattern 'src/generated/**' && eslint src/generated --fix --config .eslintrc.generated.js",
84
81
  "clean": "rm -rf dist coverage && bun run wasm:clean"
@@ -116,29 +113,28 @@
116
113
  "@noble/curves": "^1.9.4",
117
114
  "@noble/hashes": "^1.8.0",
118
115
  "@solana-program/system": "^0.10.0",
119
- "@solana-program/token-2022": "^0.4.2",
120
- "@solana/accounts": "^5.0.0",
121
- "@solana/addresses": "^5.0.0",
122
- "@solana/codecs-core": "^5.0.0",
123
- "@solana/codecs-data-structures": "^5.0.0",
124
- "@solana/codecs-numbers": "^5.0.0",
125
- "@solana/codecs-strings": "^5.0.0",
126
- "@solana/errors": "^5.0.0",
127
- "@solana/instructions": "^5.0.0",
128
- "@solana/kit": "^5.0.0",
129
- "@solana/options": "^5.0.0",
130
- "@solana/programs": "^5.0.0",
131
- "@solana/rpc": "^5.0.0",
132
- "@solana/rpc-spec": "^5.0.0",
133
- "@solana/rpc-types": "^5.0.0",
134
- "@solana/signers": "^5.0.0",
116
+ "@solana-program/token": "^0.9.0",
117
+ "@solana-program/token-2022": "^0.6.1",
118
+ "@solana/accounts": "^5.1.0",
119
+ "@solana/addresses": "^5.1.0",
120
+ "@solana/codecs-core": "^5.1.0",
121
+ "@solana/codecs-data-structures": "^5.1.0",
122
+ "@solana/codecs-numbers": "^5.1.0",
123
+ "@solana/codecs-strings": "^5.1.0",
124
+ "@solana/errors": "^5.1.0",
125
+ "@solana/instructions": "^5.1.0",
126
+ "@solana/kit": "^5.1.0",
127
+ "@solana/options": "^5.1.0",
128
+ "@solana/programs": "^5.1.0",
129
+ "@solana/rpc": "^5.1.0",
130
+ "@solana/rpc-spec": "^5.1.0",
131
+ "@solana/rpc-types": "^5.1.0",
132
+ "@solana/signers": "^5.1.0",
135
133
  "@solana/spl-account-compression": "^0.4.1",
136
- "@solana/spl-token": "^0.4.13",
137
- "@solana/sysvars": "^5.0.0",
138
- "@solana/transactions": "^5.0.0",
134
+ "@solana/sysvars": "^5.1.0",
139
135
  "bs58": "^6.0.0",
140
- "drizzle-orm": "^0.36.0",
141
- "kubo-rpc-client": "^5.2.0"
136
+ "kubo-rpc-client": "^5.2.0",
137
+ "lru-cache": "^11.2.4"
142
138
  },
143
139
  "devDependencies": {
144
140
  "@codama/cli": "^1.2.1",
@@ -147,11 +143,8 @@
147
143
  "@codama/renderers-js": "^1.3.2",
148
144
  "@codama/visitors": "^1.3.1",
149
145
  "@types/node": "^24.0.15",
150
- "@typescript-eslint/eslint-plugin": "^8.37.0",
151
- "@typescript-eslint/parser": "^8.37.0",
152
146
  "@vitest/coverage-v8": "^3.2.4",
153
147
  "@vitest/ui": "^3.2.4",
154
- "drizzle-kit": "^0.28.0",
155
148
  "eslint": "^9.31.0",
156
149
  "glob": "^10.4.5",
157
150
  "tsup": "^8.0.0",