@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.
- package/README.md +152 -30
- package/dist/GhostSpeakClient-CWmGaM9Q.d.ts +1007 -0
- package/dist/StakingModule-C5rzuOWb.d.ts +2526 -0
- package/dist/{agent-M74TCRON.js → agent-5YLZ7DAC.js} +4 -4
- package/dist/{agent-M74TCRON.js.map → agent-5YLZ7DAC.js.map} +1 -1
- package/dist/batch-operations-45CQFEID.js +4 -0
- package/dist/batch-operations-45CQFEID.js.map +1 -0
- package/dist/browser.d.ts +45 -554
- package/dist/browser.js +15 -842
- package/dist/browser.js.map +1 -1
- package/dist/chunk-AL3HQN73.js +754 -0
- package/dist/chunk-AL3HQN73.js.map +1 -0
- package/dist/chunk-BF3IQ35I.js +284 -0
- package/dist/chunk-BF3IQ35I.js.map +1 -0
- package/dist/chunk-BQDGRTVP.js +168 -0
- package/dist/chunk-BQDGRTVP.js.map +1 -0
- package/dist/chunk-C5CDA3WX.js +7314 -0
- package/dist/chunk-C5CDA3WX.js.map +1 -0
- package/dist/chunk-E3FD2CNY.js +1869 -0
- package/dist/chunk-E3FD2CNY.js.map +1 -0
- package/dist/{chunk-F3DZMBUA.js → chunk-G7S6B6WB.js} +327 -493
- package/dist/chunk-G7S6B6WB.js.map +1 -0
- package/dist/chunk-IHVDQ4YI.js +4231 -0
- package/dist/chunk-IHVDQ4YI.js.map +1 -0
- package/dist/chunk-JV2SWONF.js +98 -0
- package/dist/chunk-JV2SWONF.js.map +1 -0
- package/dist/chunk-KB6CKIUK.js +231 -0
- package/dist/chunk-KB6CKIUK.js.map +1 -0
- package/dist/chunk-S74EH3KD.js +7890 -0
- package/dist/chunk-S74EH3KD.js.map +1 -0
- package/dist/chunk-SFTSZ3LC.js +156 -0
- package/dist/chunk-SFTSZ3LC.js.map +1 -0
- package/dist/chunk-SKMJJ3Q6.js +125 -0
- package/dist/chunk-SKMJJ3Q6.js.map +1 -0
- package/dist/chunk-SZGFSCNU.js +3682 -0
- package/dist/chunk-SZGFSCNU.js.map +1 -0
- package/dist/chunk-TTB4OS2D.js +69 -0
- package/dist/chunk-TTB4OS2D.js.map +1 -0
- package/dist/chunk-UP2VWCW5.js +33 -0
- package/dist/{chunk-NSBPE2FW.js.map → chunk-UP2VWCW5.js.map} +1 -1
- package/dist/{chunk-UJUGGLMT.js → chunk-VQZQCHUT.js} +5 -5
- package/dist/{chunk-UJUGGLMT.js.map → chunk-VQZQCHUT.js.map} +1 -1
- package/dist/client.d.ts +5 -4
- package/dist/client.js +11 -10
- package/dist/createAgentAuthorization-ULG47ZJI.js +5 -0
- package/dist/createAgentAuthorization-ULG47ZJI.js.map +1 -0
- package/dist/credentials.js +1 -1
- package/dist/crypto.js +2 -2
- package/dist/errors.js +1 -1
- package/dist/feature-flags-B1g0DCPe.d.ts +1181 -0
- package/dist/generated-EG5USUFG.js +9 -0
- package/dist/{generated-VNLHMR6Y.js.map → generated-EG5USUFG.js.map} +1 -1
- package/dist/{ghostspeak_wasm-SB2RPJ3D.js → ghostspeak_wasm-F227HOSM.js} +3 -3
- package/dist/{ghostspeak_wasm-SB2RPJ3D.js.map → ghostspeak_wasm-F227HOSM.js.map} +1 -1
- package/dist/index.d.ts +1209 -1506
- package/dist/index.js +600 -3532
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/minimal/core-minimal.d.ts +2383 -1264
- package/dist/minimal/core-minimal.js +9 -9
- package/dist/minimal/core-minimal.js.map +1 -1
- package/dist/nacl-fast-W5BJ3KZ2.js +2229 -0
- package/dist/nacl-fast-W5BJ3KZ2.js.map +1 -0
- package/dist/pda-4KP7CURF.js +4 -0
- package/dist/pda-4KP7CURF.js.map +1 -0
- package/dist/pda-Ce7VYg4T.d.ts +25 -0
- package/dist/reputation-types-Yebf0Rm_.d.ts +1071 -0
- package/dist/revokeAuthorization-OK7E7OK3.js +5 -0
- package/dist/revokeAuthorization-OK7E7OK3.js.map +1 -0
- package/dist/signature-verification-DGxR4aYQ.d.ts +448 -0
- package/dist/types.js +1 -1
- package/dist/updateReputationWithAuth-Y4ONEVSP.js +5 -0
- package/dist/updateReputationWithAuth-Y4ONEVSP.js.map +1 -0
- package/dist/utils.d.ts +69 -203
- package/dist/utils.js +15 -153
- package/dist/utils.js.map +1 -1
- package/package.json +24 -31
- package/dist/.tsbuildinfo +0 -1
- package/dist/GhostSpeakClient-D_66Uzsf.d.ts +0 -707
- package/dist/GovernanceModule-DQYYys-H.d.ts +0 -1766
- package/dist/chunk-APCKGD23.js +0 -1328
- package/dist/chunk-APCKGD23.js.map +0 -1
- package/dist/chunk-ASQXX4IT.js +0 -572
- package/dist/chunk-ASQXX4IT.js.map +0 -1
- package/dist/chunk-COGZFWOT.js +0 -19657
- package/dist/chunk-COGZFWOT.js.map +0 -1
- package/dist/chunk-F3DZMBUA.js.map +0 -1
- package/dist/chunk-GMHIUK2R.js +0 -7526
- package/dist/chunk-GMHIUK2R.js.map +0 -1
- package/dist/chunk-IAWBZYPE.js +0 -356
- package/dist/chunk-IAWBZYPE.js.map +0 -1
- package/dist/chunk-NSBPE2FW.js +0 -15
- package/dist/chunk-OWYHJG6H.js +0 -13311
- package/dist/chunk-OWYHJG6H.js.map +0 -1
- package/dist/chunk-RDDPOFR5.js +0 -3
- package/dist/chunk-RDDPOFR5.js.map +0 -1
- package/dist/chunk-RERCHKZP.js +0 -35
- package/dist/chunk-RERCHKZP.js.map +0 -1
- package/dist/chunk-TVVGXYCI.js +0 -2887
- package/dist/chunk-TVVGXYCI.js.map +0 -1
- package/dist/chunk-ZGP5552B.js +0 -377
- package/dist/chunk-ZGP5552B.js.map +0 -1
- package/dist/chunk-ZWOYNHVK.js +0 -196
- package/dist/chunk-ZWOYNHVK.js.map +0 -1
- package/dist/dist/.tsbuildinfo +0 -1
- package/dist/elgamal-VZLWB3XK.js +0 -5
- package/dist/elgamal-VZLWB3XK.js.map +0 -1
- package/dist/feature-flags-V722ZuXO.d.ts +0 -3512
- package/dist/generated-VNLHMR6Y.js +0 -5
- package/dist/ipfs-types-BOt9ZNg4.d.ts +0 -592
- package/dist/multisigConfig-BzEhy6jy.d.ts +0 -58
- package/dist/pda-B_nS8SbD.d.ts +0 -114
- package/dist/pda-S4BFJVGE.js +0 -4
- package/dist/pda-S4BFJVGE.js.map +0 -1
- package/dist/system-addresses-BFNLEbFx.d.ts +0 -857
- package/dist/token-2022-rpc-RALH4RK7.js +0 -593
- package/dist/token-2022-rpc-RALH4RK7.js.map +0 -1
|
@@ -0,0 +1,2526 @@
|
|
|
1
|
+
import { Address as Address$1 } from '@solana/addresses';
|
|
2
|
+
import { ReadonlyUint8Array, Address, Option, Decoder, FixedSizeDecoder, AccountMeta, Instruction, InstructionWithData, InstructionWithAccounts, WritableAccount, WritableSignerAccount, AccountSignerMeta, ReadonlyAccount, Commitment as Commitment$1, Rpc, GetLatestBlockhashApi, SendTransactionApi, GetAccountInfoApi, SimulateTransactionApi, GetFeeForMessageApi, GetProgramAccountsApi, GetEpochInfoApi, GetSignatureStatusesApi, GetMultipleAccountsApi, RpcSubscriptions, SignatureNotificationsApi, SlotNotificationsApi, AccountRole, TransactionSigner, Signature as Signature$1 } from '@solana/kit';
|
|
3
|
+
import { I as IPFSConfig, G as GovernanceProposal, n as ProposalTypeArgs, E as ExecutionParamsArgs, o as CategoryReputation, B as BadgeType, J as JobPerformance, a as ReputationCalculationResult, p as ReputationTier, b as ReputationMetrics, c as TagScore, q as TagCategory, d as TagFilters, e as TagQueryResult } from './reputation-types-Yebf0Rm_.js';
|
|
4
|
+
import { EventEmitter } from 'node:events';
|
|
5
|
+
import { ParticipantType } from './types.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
9
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
10
|
+
* to add features, then rerun Codama to update it.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/codama-idl/codama
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Access tiers based on GHOST token stake amount */
|
|
16
|
+
declare enum AccessTier {
|
|
17
|
+
None = 0,
|
|
18
|
+
Basic = 1,
|
|
19
|
+
Verified = 2,
|
|
20
|
+
Pro = 3,
|
|
21
|
+
Whale = 4
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
26
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
27
|
+
* to add features, then rerun Codama to update it.
|
|
28
|
+
*
|
|
29
|
+
* @see https://github.com/codama-idl/codama
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* MultisigType defines the governance layer a multisig belongs to.
|
|
34
|
+
* Different types have different permissions and requirements.
|
|
35
|
+
*/
|
|
36
|
+
declare enum MultisigType {
|
|
37
|
+
Protocol = 0,
|
|
38
|
+
Dao = 1,
|
|
39
|
+
Dispute = 2,
|
|
40
|
+
AgentConsortium = 3,
|
|
41
|
+
AgentTreasury = 4,
|
|
42
|
+
Custom = 5
|
|
43
|
+
}
|
|
44
|
+
type MultisigTypeArgs = MultisigType;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
48
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
49
|
+
* to add features, then rerun Codama to update it.
|
|
50
|
+
*
|
|
51
|
+
* @see https://github.com/codama-idl/codama
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
type MultisigTypeConfigArgs = {
|
|
55
|
+
/** The multisig type */
|
|
56
|
+
multisigType: MultisigTypeArgs;
|
|
57
|
+
/** Required timelock duration in seconds (0 = no timelock) */
|
|
58
|
+
timelockSeconds: number | bigint;
|
|
59
|
+
/** Minimum number of signers allowed */
|
|
60
|
+
minSigners: number;
|
|
61
|
+
/** Maximum number of signers allowed */
|
|
62
|
+
maxSigners: number;
|
|
63
|
+
/** Minimum reputation score required (0-10000 basis points) */
|
|
64
|
+
minReputationScore: number;
|
|
65
|
+
/** Whether signers must hold governance tokens */
|
|
66
|
+
requiresTokenHoldings: boolean;
|
|
67
|
+
/** Minimum token balance required (if requires_token_holdings) */
|
|
68
|
+
minTokenBalance: number | bigint;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
73
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
74
|
+
* to add features, then rerun Codama to update it.
|
|
75
|
+
*
|
|
76
|
+
* @see https://github.com/codama-idl/codama
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
declare enum PricingModel$1 {
|
|
80
|
+
Fixed = 0,
|
|
81
|
+
Hourly = 1,
|
|
82
|
+
PerTask = 2,
|
|
83
|
+
Subscription = 3,
|
|
84
|
+
Auction = 4,
|
|
85
|
+
Dynamic = 5,
|
|
86
|
+
RevenueShare = 6,
|
|
87
|
+
Tiered = 7
|
|
88
|
+
}
|
|
89
|
+
type PricingModelArgs = PricingModel$1;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
93
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
94
|
+
* to add features, then rerun Codama to update it.
|
|
95
|
+
*
|
|
96
|
+
* @see https://github.com/codama-idl/codama
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
type Agent = {
|
|
100
|
+
discriminator: ReadonlyUint8Array;
|
|
101
|
+
owner: Address;
|
|
102
|
+
agentId: string;
|
|
103
|
+
agentType: number;
|
|
104
|
+
name: string;
|
|
105
|
+
description: string;
|
|
106
|
+
capabilities: Array<string>;
|
|
107
|
+
pricingModel: PricingModel$1;
|
|
108
|
+
reputationScore: number;
|
|
109
|
+
totalJobsCompleted: number;
|
|
110
|
+
totalEarnings: bigint;
|
|
111
|
+
isActive: boolean;
|
|
112
|
+
createdAt: bigint;
|
|
113
|
+
updatedAt: bigint;
|
|
114
|
+
originalPrice: bigint;
|
|
115
|
+
genomeHash: string;
|
|
116
|
+
isReplicable: boolean;
|
|
117
|
+
replicationFee: bigint;
|
|
118
|
+
serviceEndpoint: string;
|
|
119
|
+
isVerified: boolean;
|
|
120
|
+
verificationTimestamp: bigint;
|
|
121
|
+
metadataUri: string;
|
|
122
|
+
frameworkOrigin: string;
|
|
123
|
+
supportedTokens: Array<Address>;
|
|
124
|
+
cnftMint: Option<Address>;
|
|
125
|
+
merkleTree: Option<Address>;
|
|
126
|
+
supportsA2a: boolean;
|
|
127
|
+
transferHook: Option<Address>;
|
|
128
|
+
parentAgent: Option<Address>;
|
|
129
|
+
generation: number;
|
|
130
|
+
x402Enabled: boolean;
|
|
131
|
+
x402PaymentAddress: Address;
|
|
132
|
+
x402AcceptedTokens: Array<Address>;
|
|
133
|
+
x402PricePerCall: bigint;
|
|
134
|
+
x402ServiceEndpoint: string;
|
|
135
|
+
x402TotalPayments: bigint;
|
|
136
|
+
x402TotalCalls: bigint;
|
|
137
|
+
lastPaymentTimestamp: bigint;
|
|
138
|
+
apiSpecUri: string;
|
|
139
|
+
apiVersion: string;
|
|
140
|
+
bump: number;
|
|
141
|
+
};
|
|
142
|
+
/** Gets the decoder for {@link Agent} account data. */
|
|
143
|
+
declare function getAgentDecoder(): Decoder<Agent>;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
147
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
148
|
+
* to add features, then rerun Codama to update it.
|
|
149
|
+
*
|
|
150
|
+
* @see https://github.com/codama-idl/codama
|
|
151
|
+
*/
|
|
152
|
+
|
|
153
|
+
type StakingAccount = {
|
|
154
|
+
discriminator: ReadonlyUint8Array;
|
|
155
|
+
/** Owner of this staking account (can register multiple agents) */
|
|
156
|
+
owner: Address;
|
|
157
|
+
/** Amount of GHOST tokens staked */
|
|
158
|
+
amountStaked: bigint;
|
|
159
|
+
/** Timestamp when staking started */
|
|
160
|
+
stakedAt: bigint;
|
|
161
|
+
/** Lock duration in seconds (minimum 30 days) */
|
|
162
|
+
lockDuration: bigint;
|
|
163
|
+
/** Timestamp when unlock is available */
|
|
164
|
+
unlockAt: bigint;
|
|
165
|
+
/** Reputation boost percentage (in basis points, e.g., 500 = 5%) */
|
|
166
|
+
reputationBoostBps: number;
|
|
167
|
+
/** Whether agent has "Verified" badge */
|
|
168
|
+
hasVerifiedBadge: boolean;
|
|
169
|
+
/** Whether agent has premium listing benefits */
|
|
170
|
+
hasPremiumBenefits: boolean;
|
|
171
|
+
/** Total slashed amount (never recoverable) */
|
|
172
|
+
totalSlashed: bigint;
|
|
173
|
+
/** Current access tier based on stake amount */
|
|
174
|
+
tier: AccessTier;
|
|
175
|
+
/** Daily API calls remaining (resets every 24h) */
|
|
176
|
+
apiCallsRemaining: number;
|
|
177
|
+
/** Last API quota reset timestamp */
|
|
178
|
+
lastQuotaReset: bigint;
|
|
179
|
+
/** Voting power for governance (equals amount_staked) */
|
|
180
|
+
votingPower: bigint;
|
|
181
|
+
/** Bump for PDA */
|
|
182
|
+
bump: number;
|
|
183
|
+
};
|
|
184
|
+
/** Gets the decoder for {@link StakingAccount} account data. */
|
|
185
|
+
declare function getStakingAccountDecoder(): FixedSizeDecoder<StakingAccount>;
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
189
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
190
|
+
* to add features, then rerun Codama to update it.
|
|
191
|
+
*
|
|
192
|
+
* @see https://github.com/codama-idl/codama
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
type StakingConfig = {
|
|
196
|
+
discriminator: ReadonlyUint8Array;
|
|
197
|
+
/** Authority who can update staking parameters */
|
|
198
|
+
authority: Address;
|
|
199
|
+
/** Minimum stake amount (1,000 GHOST) */
|
|
200
|
+
minStake: bigint;
|
|
201
|
+
/** Minimum lock duration (30 days in seconds) */
|
|
202
|
+
minLockDuration: bigint;
|
|
203
|
+
/** Slash percentage for fraud (50% = 5000 bps) */
|
|
204
|
+
fraudSlashBps: number;
|
|
205
|
+
/** Slash percentage for dispute loss (10% = 1000 bps) */
|
|
206
|
+
disputeSlashBps: number;
|
|
207
|
+
/** Treasury account for slashed tokens */
|
|
208
|
+
treasury: Address;
|
|
209
|
+
bump: number;
|
|
210
|
+
};
|
|
211
|
+
/** Gets the decoder for {@link StakingConfig} account data. */
|
|
212
|
+
declare function getStakingConfigDecoder(): FixedSizeDecoder<StakingConfig>;
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
216
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
217
|
+
* to add features, then rerun Codama to update it.
|
|
218
|
+
*
|
|
219
|
+
* @see https://github.com/codama-idl/codama
|
|
220
|
+
*/
|
|
221
|
+
|
|
222
|
+
declare const GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS: Address<"4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB">;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
226
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
227
|
+
* to add features, then rerun Codama to update it.
|
|
228
|
+
*
|
|
229
|
+
* @see https://github.com/codama-idl/codama
|
|
230
|
+
*/
|
|
231
|
+
|
|
232
|
+
type InitializeGovernanceProposalInstruction<TProgram extends string = typeof GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS, TAccountProposal extends string | AccountMeta<string> = string, TAccountProposer extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> = Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[
|
|
233
|
+
TAccountProposal extends string ? WritableAccount<TAccountProposal> : TAccountProposal,
|
|
234
|
+
TAccountProposer extends string ? WritableSignerAccount<TAccountProposer> & AccountSignerMeta<TAccountProposer> : TAccountProposer,
|
|
235
|
+
TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram,
|
|
236
|
+
...TRemainingAccounts
|
|
237
|
+
]>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* PayAI Integration Types
|
|
241
|
+
*
|
|
242
|
+
* Type definitions for PayAI x402 facilitator integration,
|
|
243
|
+
* including webhook payloads and client configuration.
|
|
244
|
+
*
|
|
245
|
+
* @module payai/types
|
|
246
|
+
* @see https://docs.payai.network/x402/introduction
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* PayAI webhook event types
|
|
251
|
+
*/
|
|
252
|
+
type PayAIWebhookEventType = 'payment.verified' | 'payment.settled' | 'payment.failed' | 'payment.refunded';
|
|
253
|
+
/**
|
|
254
|
+
* PayAI payment status
|
|
255
|
+
*/
|
|
256
|
+
type PayAIPaymentStatus = 'pending' | 'verified' | 'settled' | 'failed' | 'refunded';
|
|
257
|
+
/**
|
|
258
|
+
* PayAI supported networks
|
|
259
|
+
*/
|
|
260
|
+
type PayAINetwork = 'solana' | 'base' | 'ethereum' | 'polygon' | 'arbitrum';
|
|
261
|
+
/**
|
|
262
|
+
* PayAI webhook payload for payment events
|
|
263
|
+
* This is sent to your webhook endpoint after payment verification/settlement
|
|
264
|
+
*/
|
|
265
|
+
interface PayAIWebhookPayload {
|
|
266
|
+
/** Unique event ID */
|
|
267
|
+
id: string;
|
|
268
|
+
/** Event type */
|
|
269
|
+
type: PayAIWebhookEventType;
|
|
270
|
+
/** Timestamp of the event (ISO 8601) */
|
|
271
|
+
timestamp: string;
|
|
272
|
+
/** Payment data */
|
|
273
|
+
data: PayAIPaymentData;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Payment data included in webhook payload
|
|
277
|
+
*/
|
|
278
|
+
interface PayAIPaymentData {
|
|
279
|
+
/** Unique payment ID from PayAI */
|
|
280
|
+
paymentId: string;
|
|
281
|
+
/** Transaction signature on-chain */
|
|
282
|
+
transactionSignature: string;
|
|
283
|
+
/** Blockchain network */
|
|
284
|
+
network: PayAINetwork;
|
|
285
|
+
/** Payer wallet address */
|
|
286
|
+
payer: string;
|
|
287
|
+
/** Merchant/Agent wallet address (payTo) */
|
|
288
|
+
merchant: string;
|
|
289
|
+
/** Payment amount in smallest unit (e.g., lamports for SOL, base units for USDC) */
|
|
290
|
+
amount: string;
|
|
291
|
+
/** Token/asset address */
|
|
292
|
+
asset: string;
|
|
293
|
+
/** Token symbol (e.g., 'USDC') */
|
|
294
|
+
assetSymbol: string;
|
|
295
|
+
/** Payment status */
|
|
296
|
+
status: PayAIPaymentStatus;
|
|
297
|
+
/** Resource URL that was paid for */
|
|
298
|
+
resource: string;
|
|
299
|
+
/** Response time in milliseconds (from request to response) */
|
|
300
|
+
responseTimeMs?: number;
|
|
301
|
+
/** HTTP status code of the resource response */
|
|
302
|
+
httpStatusCode?: number;
|
|
303
|
+
/** Whether the resource request was successful */
|
|
304
|
+
success?: boolean;
|
|
305
|
+
/** Timestamp when payment was verified */
|
|
306
|
+
verifiedAt?: string;
|
|
307
|
+
/** Timestamp when payment was settled */
|
|
308
|
+
settledAt?: string;
|
|
309
|
+
/** Additional metadata from the payment request */
|
|
310
|
+
metadata?: Record<string, unknown>;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* Webhook verification result
|
|
314
|
+
*/
|
|
315
|
+
interface PayAIWebhookVerification {
|
|
316
|
+
valid: boolean;
|
|
317
|
+
error?: string;
|
|
318
|
+
payload?: PayAIWebhookPayload;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* PayAI client configuration
|
|
322
|
+
*/
|
|
323
|
+
interface PayAIClientConfig {
|
|
324
|
+
/** PayAI facilitator URL (default: https://facilitator.payai.network) */
|
|
325
|
+
facilitatorUrl?: string;
|
|
326
|
+
/** Solana RPC endpoint */
|
|
327
|
+
rpcUrl: string;
|
|
328
|
+
/** User wallet for signing payments */
|
|
329
|
+
wallet?: {
|
|
330
|
+
publicKey: string;
|
|
331
|
+
signTransaction: (tx: unknown) => Promise<unknown>;
|
|
332
|
+
};
|
|
333
|
+
/** Request timeout in milliseconds */
|
|
334
|
+
timeout?: number;
|
|
335
|
+
/** Retry configuration */
|
|
336
|
+
retry?: {
|
|
337
|
+
attempts: number;
|
|
338
|
+
delayMs: number;
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* x402 payment requirement from a resource
|
|
343
|
+
*/
|
|
344
|
+
interface PayAIPaymentRequirement {
|
|
345
|
+
/** Payment scheme (e.g., 'exact') */
|
|
346
|
+
scheme: string;
|
|
347
|
+
/** Blockchain network */
|
|
348
|
+
network: PayAINetwork;
|
|
349
|
+
/** Maximum amount required in smallest unit */
|
|
350
|
+
maxAmountRequired: string;
|
|
351
|
+
/** Resource URL */
|
|
352
|
+
resource: string;
|
|
353
|
+
/** Description of the resource */
|
|
354
|
+
description?: string;
|
|
355
|
+
/** MIME type of the response */
|
|
356
|
+
mimeType?: string;
|
|
357
|
+
/** Recipient address */
|
|
358
|
+
payTo: string;
|
|
359
|
+
/** Token/asset address */
|
|
360
|
+
asset: string;
|
|
361
|
+
/** Maximum timeout in seconds */
|
|
362
|
+
maxTimeoutSeconds?: number;
|
|
363
|
+
/** Additional data */
|
|
364
|
+
extra?: Record<string, unknown>;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Payment response from PayAI facilitator
|
|
368
|
+
*/
|
|
369
|
+
interface PayAIPaymentResponse {
|
|
370
|
+
/** Whether payment was successful */
|
|
371
|
+
success: boolean;
|
|
372
|
+
/** Transaction signature */
|
|
373
|
+
transactionSignature?: string;
|
|
374
|
+
/** Error message if failed */
|
|
375
|
+
error?: string;
|
|
376
|
+
/** Payment ID for tracking */
|
|
377
|
+
paymentId?: string;
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Data to record for reputation tracking
|
|
381
|
+
* Extracted from PayAI webhook payloads
|
|
382
|
+
*/
|
|
383
|
+
interface PayAIReputationRecord {
|
|
384
|
+
/** Agent/Merchant address on Solana */
|
|
385
|
+
agentAddress: Address$1;
|
|
386
|
+
/** Payment signature for verification */
|
|
387
|
+
paymentSignature: string;
|
|
388
|
+
/** Payment amount */
|
|
389
|
+
amount: bigint;
|
|
390
|
+
/** Whether the service was successful */
|
|
391
|
+
success: boolean;
|
|
392
|
+
/** Response time in milliseconds */
|
|
393
|
+
responseTimeMs: number;
|
|
394
|
+
/** Payer address */
|
|
395
|
+
payerAddress: string;
|
|
396
|
+
/** Timestamp of payment */
|
|
397
|
+
timestamp: Date;
|
|
398
|
+
/** Network the payment was on */
|
|
399
|
+
network: PayAINetwork;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Agent registration data for PayAI marketplace sync
|
|
403
|
+
*/
|
|
404
|
+
interface PayAIAgentRegistration {
|
|
405
|
+
/** Agent's Solana address */
|
|
406
|
+
agentAddress: Address$1;
|
|
407
|
+
/** Service endpoint URL (x402-enabled) */
|
|
408
|
+
serviceEndpoint: string;
|
|
409
|
+
/** Agent capabilities/tags */
|
|
410
|
+
capabilities: string[];
|
|
411
|
+
/** Accepted payment tokens */
|
|
412
|
+
acceptedTokens: string[];
|
|
413
|
+
/** Pricing information */
|
|
414
|
+
pricing?: {
|
|
415
|
+
minPrice: string;
|
|
416
|
+
maxPrice: string;
|
|
417
|
+
currency: string;
|
|
418
|
+
};
|
|
419
|
+
/** Agent metadata */
|
|
420
|
+
metadata?: {
|
|
421
|
+
name?: string;
|
|
422
|
+
description?: string;
|
|
423
|
+
logo?: string;
|
|
424
|
+
website?: string;
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Webhook handler options
|
|
429
|
+
*/
|
|
430
|
+
interface PayAIWebhookHandlerOptions {
|
|
431
|
+
/** Secret for verifying webhook signatures */
|
|
432
|
+
webhookSecret?: string;
|
|
433
|
+
/** Whether to verify webhook signatures (default: true in production) */
|
|
434
|
+
verifySignatures?: boolean;
|
|
435
|
+
/** Callback for handling verified payment events */
|
|
436
|
+
onPaymentVerified?: (data: PayAIPaymentData) => Promise<void>;
|
|
437
|
+
/** Callback for handling settled payment events */
|
|
438
|
+
onPaymentSettled?: (data: PayAIPaymentData) => Promise<void>;
|
|
439
|
+
/** Callback for handling failed payment events */
|
|
440
|
+
onPaymentFailed?: (data: PayAIPaymentData) => Promise<void>;
|
|
441
|
+
/** Callback for recording to reputation */
|
|
442
|
+
onRecordReputation?: (record: PayAIReputationRecord) => Promise<void>;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Webhook processing result
|
|
446
|
+
*/
|
|
447
|
+
interface PayAIWebhookResult {
|
|
448
|
+
/** Whether processing was successful */
|
|
449
|
+
success: boolean;
|
|
450
|
+
/** Event type that was processed */
|
|
451
|
+
eventType?: PayAIWebhookEventType;
|
|
452
|
+
/** Error message if failed */
|
|
453
|
+
error?: string;
|
|
454
|
+
/** Whether reputation was recorded */
|
|
455
|
+
reputationRecorded?: boolean;
|
|
456
|
+
/** Processed payment ID */
|
|
457
|
+
paymentId?: string;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* CacheManager - Slot-aware RPC result caching
|
|
462
|
+
*
|
|
463
|
+
* Reduces RPC calls by caching account data and PDA derivations
|
|
464
|
+
* with commitment-level aware TTLs.
|
|
465
|
+
*
|
|
466
|
+
* @module CacheManager
|
|
467
|
+
*/
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Cache configuration options
|
|
471
|
+
*/
|
|
472
|
+
interface CacheConfig {
|
|
473
|
+
/** Enable caching (default: false, opt-in) */
|
|
474
|
+
enabled?: boolean;
|
|
475
|
+
/** Maximum cache entries (default: 1000) */
|
|
476
|
+
maxSize?: number;
|
|
477
|
+
/** Custom TTL overrides (milliseconds) */
|
|
478
|
+
ttlOverrides?: {
|
|
479
|
+
processed?: number;
|
|
480
|
+
confirmed?: number;
|
|
481
|
+
finalized?: number;
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* CacheManager handles slot-aware caching for RPC results
|
|
486
|
+
*
|
|
487
|
+
* Features:
|
|
488
|
+
* - Commitment-level TTLs (finalized=30s, confirmed=2s, processed=500ms)
|
|
489
|
+
* - Indefinite PDA caching (deterministic addresses)
|
|
490
|
+
* - LRU eviction policy
|
|
491
|
+
* - Opt-in (disabled by default)
|
|
492
|
+
*/
|
|
493
|
+
declare class CacheManager {
|
|
494
|
+
private accountCache;
|
|
495
|
+
private pdaCache;
|
|
496
|
+
private config;
|
|
497
|
+
private ttls;
|
|
498
|
+
constructor(config?: CacheConfig);
|
|
499
|
+
/**
|
|
500
|
+
* Check if caching is enabled
|
|
501
|
+
*/
|
|
502
|
+
isEnabled(): boolean;
|
|
503
|
+
/**
|
|
504
|
+
* Get cached account data
|
|
505
|
+
*
|
|
506
|
+
* @param address - Account address
|
|
507
|
+
* @param commitment - Commitment level
|
|
508
|
+
* @param currentSlot - Current blockchain slot (for staleness check)
|
|
509
|
+
* @returns Cached data or undefined
|
|
510
|
+
*/
|
|
511
|
+
getAccount<T>(address: Address$1, commitment: Commitment$1, currentSlot?: number): T | undefined;
|
|
512
|
+
/**
|
|
513
|
+
* Cache account data
|
|
514
|
+
*
|
|
515
|
+
* @param address - Account address
|
|
516
|
+
* @param data - Account data to cache
|
|
517
|
+
* @param commitment - Commitment level
|
|
518
|
+
* @param slot - Blockchain slot when data was fetched
|
|
519
|
+
*/
|
|
520
|
+
setAccount<T>(address: Address$1, data: T, commitment: Commitment$1, slot: number): void;
|
|
521
|
+
/**
|
|
522
|
+
* Get cached PDA
|
|
523
|
+
*
|
|
524
|
+
* PDAs are cached indefinitely as they're deterministic.
|
|
525
|
+
*
|
|
526
|
+
* @param seeds - Serialized seed components
|
|
527
|
+
* @returns Cached PDA or undefined
|
|
528
|
+
*/
|
|
529
|
+
getPDA(seeds: string): Address$1 | undefined;
|
|
530
|
+
/**
|
|
531
|
+
* Cache PDA derivation
|
|
532
|
+
*
|
|
533
|
+
* @param seeds - Serialized seed components (use JSON.stringify for consistency)
|
|
534
|
+
* @param pda - Derived PDA address
|
|
535
|
+
*/
|
|
536
|
+
setPDA(seeds: string, pda: Address$1): void;
|
|
537
|
+
/**
|
|
538
|
+
* Invalidate account cache entry
|
|
539
|
+
*
|
|
540
|
+
* @param address - Account address to invalidate
|
|
541
|
+
* @param commitment - Optional commitment level (invalidates all if not specified)
|
|
542
|
+
*/
|
|
543
|
+
invalidateAccount(address: Address$1, commitment?: Commitment$1): void;
|
|
544
|
+
/**
|
|
545
|
+
* Clear all caches
|
|
546
|
+
*/
|
|
547
|
+
clear(): void;
|
|
548
|
+
/**
|
|
549
|
+
* Get cache statistics
|
|
550
|
+
*
|
|
551
|
+
* @returns Cache size and hit/miss stats
|
|
552
|
+
*/
|
|
553
|
+
getStats(): {
|
|
554
|
+
accountCache: {
|
|
555
|
+
size: number;
|
|
556
|
+
max: number;
|
|
557
|
+
};
|
|
558
|
+
pdaCache: {
|
|
559
|
+
size: number;
|
|
560
|
+
max: number;
|
|
561
|
+
};
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
type RpcApi = Rpc<GetLatestBlockhashApi & SendTransactionApi & GetAccountInfoApi & SimulateTransactionApi & GetFeeForMessageApi & GetProgramAccountsApi>;
|
|
566
|
+
type ExtendedRpcApi = RpcApi & Rpc<GetEpochInfoApi & GetSignatureStatusesApi & GetMultipleAccountsApi>;
|
|
567
|
+
type RpcSubscriptionApi = RpcSubscriptions<SignatureNotificationsApi & SlotNotificationsApi>;
|
|
568
|
+
type Commitment = 'processed' | 'confirmed' | 'finalized';
|
|
569
|
+
|
|
570
|
+
interface GhostSpeakConfig {
|
|
571
|
+
programId?: Address$1;
|
|
572
|
+
rpc: ExtendedRpcApi;
|
|
573
|
+
rpcSubscriptions?: RpcSubscriptionApi;
|
|
574
|
+
commitment?: Commitment;
|
|
575
|
+
transactionTimeout?: number;
|
|
576
|
+
defaultFeePayer?: Address$1;
|
|
577
|
+
retryConfig?: RetryConfig;
|
|
578
|
+
cluster?: 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';
|
|
579
|
+
rpcEndpoint?: string;
|
|
580
|
+
wsEndpoint?: string;
|
|
581
|
+
/** Optional logger for debug output */
|
|
582
|
+
logger?: {
|
|
583
|
+
info: (...args: unknown[]) => void;
|
|
584
|
+
error: (...args: unknown[]) => void;
|
|
585
|
+
};
|
|
586
|
+
/** Cache configuration for RPC result caching */
|
|
587
|
+
cache?: CacheConfig;
|
|
588
|
+
/** Token 2022 configuration options */
|
|
589
|
+
token2022?: Token2022Config;
|
|
590
|
+
/** IPFS configuration for large content storage */
|
|
591
|
+
ipfsConfig?: IPFSConfig;
|
|
592
|
+
/** Credential configuration for Crossmint sync */
|
|
593
|
+
credentials?: CredentialConfig;
|
|
594
|
+
/** PayAI configuration */
|
|
595
|
+
payai?: Partial<PayAIClientConfig>;
|
|
596
|
+
}
|
|
597
|
+
interface CredentialConfig {
|
|
598
|
+
crossmintApiKey?: string;
|
|
599
|
+
crossmintEnvironment?: 'staging' | 'production';
|
|
600
|
+
crossmintChain?: 'base-sepolia' | 'polygon-amoy' | 'base' | 'polygon';
|
|
601
|
+
templates?: {
|
|
602
|
+
agentIdentity?: string;
|
|
603
|
+
reputation?: string;
|
|
604
|
+
jobCompletion?: string;
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
interface Token2022Config {
|
|
608
|
+
/** Enable Token 2022 features by default */
|
|
609
|
+
enabled?: boolean;
|
|
610
|
+
/** Default behavior for transfer fees */
|
|
611
|
+
defaultExpectTransferFees?: boolean;
|
|
612
|
+
/** Maximum transfer fee slippage (basis points) */
|
|
613
|
+
maxFeeSlippageBasisPoints?: number;
|
|
614
|
+
/** Enable confidential transfers by default */
|
|
615
|
+
enableConfidentialTransfers?: boolean;
|
|
616
|
+
/** Default Token 2022 program address (for custom deployments) */
|
|
617
|
+
programAddress?: Address$1;
|
|
618
|
+
/** Cache token program detection results for this many seconds */
|
|
619
|
+
tokenProgramCacheTtl?: number;
|
|
620
|
+
}
|
|
621
|
+
interface RetryConfig {
|
|
622
|
+
maxRetries?: number;
|
|
623
|
+
baseDelay?: number;
|
|
624
|
+
maxDelay?: number;
|
|
625
|
+
backoffMultiplier?: number;
|
|
626
|
+
retryableErrors?: string[];
|
|
627
|
+
}
|
|
628
|
+
interface AgentWithAddress {
|
|
629
|
+
address: Address$1;
|
|
630
|
+
data: Agent;
|
|
631
|
+
}
|
|
632
|
+
interface AgentRegistrationData {
|
|
633
|
+
agentId: string;
|
|
634
|
+
name: string;
|
|
635
|
+
description: string;
|
|
636
|
+
metadataUri: string;
|
|
637
|
+
agentType: number;
|
|
638
|
+
}
|
|
639
|
+
interface AgentAccount {
|
|
640
|
+
owner: Address$1;
|
|
641
|
+
name: string;
|
|
642
|
+
description: string;
|
|
643
|
+
capabilities: string[];
|
|
644
|
+
metadataUri: string;
|
|
645
|
+
serviceEndpoint: string;
|
|
646
|
+
isActive: boolean;
|
|
647
|
+
registeredAt: bigint;
|
|
648
|
+
reputation: number;
|
|
649
|
+
totalEarnings: bigint;
|
|
650
|
+
totalJobs: number;
|
|
651
|
+
successRate: number;
|
|
652
|
+
bump: number;
|
|
653
|
+
}
|
|
654
|
+
declare enum PricingModel {
|
|
655
|
+
Fixed = "Fixed",
|
|
656
|
+
Hourly = "Hourly",
|
|
657
|
+
PerTask = "PerTask",
|
|
658
|
+
Subscription = "Subscription",
|
|
659
|
+
Auction = "Auction"
|
|
660
|
+
}
|
|
661
|
+
declare class GhostSpeakError extends Error {
|
|
662
|
+
code?: string | undefined;
|
|
663
|
+
constructor(message: string, code?: string | undefined);
|
|
664
|
+
}
|
|
665
|
+
interface RegisterAgentParams {
|
|
666
|
+
agentData: AgentRegistrationData;
|
|
667
|
+
}
|
|
668
|
+
interface RpcResponse<T> {
|
|
669
|
+
value: T | null;
|
|
670
|
+
}
|
|
671
|
+
interface RpcAccountInfo {
|
|
672
|
+
executable: boolean;
|
|
673
|
+
lamports: bigint;
|
|
674
|
+
owner: Address$1;
|
|
675
|
+
rentEpoch: bigint;
|
|
676
|
+
space: bigint;
|
|
677
|
+
data: string | Uint8Array;
|
|
678
|
+
}
|
|
679
|
+
interface RpcProgramAccount {
|
|
680
|
+
pubkey: Address$1;
|
|
681
|
+
account: RpcAccountInfo;
|
|
682
|
+
}
|
|
683
|
+
interface RpcProgramAccountsResponse {
|
|
684
|
+
value: RpcProgramAccount[] | null;
|
|
685
|
+
}
|
|
686
|
+
interface RpcAccountInfoResponse {
|
|
687
|
+
value: RpcAccountInfo | null;
|
|
688
|
+
}
|
|
689
|
+
interface RpcMultipleAccountsResponse {
|
|
690
|
+
value: (RpcAccountInfo | null)[];
|
|
691
|
+
}
|
|
692
|
+
interface TransactionResponse {
|
|
693
|
+
signature: string;
|
|
694
|
+
confirmationStatus?: Commitment;
|
|
695
|
+
err?: unknown | null;
|
|
696
|
+
}
|
|
697
|
+
interface SimulatedTransactionResponse {
|
|
698
|
+
value: {
|
|
699
|
+
err?: unknown | null;
|
|
700
|
+
logs?: string[];
|
|
701
|
+
unitsConsumed?: number;
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
interface SolanaRpcClient {
|
|
705
|
+
getAccountInfo(address: Address$1, options?: {
|
|
706
|
+
commitment?: Commitment;
|
|
707
|
+
encoding?: string;
|
|
708
|
+
}): Promise<RpcAccountInfoResponse>;
|
|
709
|
+
getMultipleAccounts(addresses: Address$1[], options?: {
|
|
710
|
+
commitment?: Commitment;
|
|
711
|
+
encoding?: string;
|
|
712
|
+
}): Promise<RpcMultipleAccountsResponse>;
|
|
713
|
+
getProgramAccounts(programId: Address$1, options?: {
|
|
714
|
+
commitment?: Commitment;
|
|
715
|
+
encoding?: string;
|
|
716
|
+
filters?: unknown[];
|
|
717
|
+
}): Promise<RpcProgramAccountsResponse>;
|
|
718
|
+
sendTransaction(transaction: unknown, options?: {
|
|
719
|
+
commitment?: Commitment;
|
|
720
|
+
}): Promise<TransactionResponse>;
|
|
721
|
+
simulateTransaction(transaction: unknown, options?: {
|
|
722
|
+
commitment?: Commitment;
|
|
723
|
+
}): Promise<SimulatedTransactionResponse>;
|
|
724
|
+
}
|
|
725
|
+
interface EmergencyConfig {
|
|
726
|
+
emergencyDelay?: bigint;
|
|
727
|
+
emergencyThreshold?: number;
|
|
728
|
+
emergencySigners?: Address$1[];
|
|
729
|
+
canEmergencyPause?: boolean;
|
|
730
|
+
emergencyContact?: string;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Developer Tools for GhostSpeak SDK
|
|
735
|
+
*
|
|
736
|
+
* Provides debugging, inspection, and development utilities
|
|
737
|
+
*/
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Transaction analysis result
|
|
741
|
+
*/
|
|
742
|
+
interface TransactionAnalysis {
|
|
743
|
+
instructions: InstructionAnalysis[];
|
|
744
|
+
totalAccounts: number;
|
|
745
|
+
signerCount: number;
|
|
746
|
+
writableAccounts: Address$1[];
|
|
747
|
+
readonlyAccounts: Address$1[];
|
|
748
|
+
estimatedSize: number;
|
|
749
|
+
estimatedComputeUnits: bigint;
|
|
750
|
+
estimatedFee: bigint;
|
|
751
|
+
warnings: string[];
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Individual instruction analysis
|
|
755
|
+
*/
|
|
756
|
+
interface InstructionAnalysis {
|
|
757
|
+
index: number;
|
|
758
|
+
programId: Address$1;
|
|
759
|
+
accountCount: number;
|
|
760
|
+
dataSize: number;
|
|
761
|
+
humanReadable: string;
|
|
762
|
+
accounts: AccountInfo[];
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Account information in instruction
|
|
766
|
+
*/
|
|
767
|
+
interface AccountInfo {
|
|
768
|
+
address: Address$1;
|
|
769
|
+
isWritable: boolean;
|
|
770
|
+
isSigner: boolean;
|
|
771
|
+
role: AccountRole;
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Type for instruction-like objects from generated code
|
|
776
|
+
*/
|
|
777
|
+
type InstructionLike = {
|
|
778
|
+
programAddress: Address$1;
|
|
779
|
+
accounts?: readonly unknown[];
|
|
780
|
+
data?: unknown;
|
|
781
|
+
};
|
|
782
|
+
/**
|
|
783
|
+
* Unified instruction builder that eliminates duplication across all instruction classes.
|
|
784
|
+
* This is the single source of truth for instruction execution patterns.
|
|
785
|
+
*/
|
|
786
|
+
declare class InstructionBuilder {
|
|
787
|
+
private rpcClient;
|
|
788
|
+
private config;
|
|
789
|
+
private devTools;
|
|
790
|
+
private debugMode;
|
|
791
|
+
constructor(config: GhostSpeakConfig);
|
|
792
|
+
/**
|
|
793
|
+
* Execute a single instruction with unified error handling and transaction patterns
|
|
794
|
+
*/
|
|
795
|
+
execute<T = string>(instructionName: string, instructionGetter: () => Promise<InstructionLike> | InstructionLike, signers: TransactionSigner[], options?: {
|
|
796
|
+
simulate?: boolean;
|
|
797
|
+
returnDetails?: boolean;
|
|
798
|
+
skipPreflight?: boolean;
|
|
799
|
+
maxRetries?: number;
|
|
800
|
+
}): Promise<T>;
|
|
801
|
+
/**
|
|
802
|
+
* Execute multiple instructions in a single transaction
|
|
803
|
+
*/
|
|
804
|
+
executeBatch<T = string>(batchName: string, instructionGetters: (() => Promise<InstructionLike> | InstructionLike)[], signers: TransactionSigner[], options?: {
|
|
805
|
+
simulate?: boolean;
|
|
806
|
+
returnDetails?: boolean;
|
|
807
|
+
skipPreflight?: boolean;
|
|
808
|
+
}): Promise<T>;
|
|
809
|
+
/**
|
|
810
|
+
* Get and decode account data with unified error handling
|
|
811
|
+
*/
|
|
812
|
+
getAccount<T>(address: Address$1, decoderImportName: string): Promise<T | null>;
|
|
813
|
+
/**
|
|
814
|
+
* Get multiple accounts with unified pattern
|
|
815
|
+
*/
|
|
816
|
+
getAccounts<T>(addresses: Address$1[], decoderImportName: string): Promise<(T | null)[]>;
|
|
817
|
+
/**
|
|
818
|
+
* Get program accounts with filters
|
|
819
|
+
*/
|
|
820
|
+
getProgramAccounts<T>(decoderImportName: string, filters?: ({
|
|
821
|
+
dataSize: bigint;
|
|
822
|
+
} | {
|
|
823
|
+
memcmp: {
|
|
824
|
+
offset: bigint;
|
|
825
|
+
bytes: string;
|
|
826
|
+
encoding?: 'base58' | 'base64';
|
|
827
|
+
};
|
|
828
|
+
})[]): Promise<{
|
|
829
|
+
address: Address$1;
|
|
830
|
+
data: T;
|
|
831
|
+
}[]>;
|
|
832
|
+
/**
|
|
833
|
+
* Enable debug mode for next transaction
|
|
834
|
+
*/
|
|
835
|
+
enableDebug(): this;
|
|
836
|
+
/**
|
|
837
|
+
* Debug transaction - analyze without executing
|
|
838
|
+
*/
|
|
839
|
+
debug(instructionName: string, instructionGetters: (() => Promise<InstructionLike> | InstructionLike)[]): Promise<TransactionAnalysis>;
|
|
840
|
+
/**
|
|
841
|
+
* Get human-readable explanation of transaction
|
|
842
|
+
*/
|
|
843
|
+
explain(instructionName: string, instructionGetters: (() => Promise<InstructionLike> | InstructionLike)[]): Promise<string>;
|
|
844
|
+
/**
|
|
845
|
+
* Estimate transaction cost
|
|
846
|
+
*/
|
|
847
|
+
estimateCost(instructionGetters: (() => Promise<InstructionLike> | InstructionLike)[]): Promise<bigint>;
|
|
848
|
+
private sendAndConfirm;
|
|
849
|
+
private simulateInstruction;
|
|
850
|
+
private simulateBatch;
|
|
851
|
+
private estimateTransactionSize;
|
|
852
|
+
private extractRawData;
|
|
853
|
+
/**
|
|
854
|
+
* Create a communication session instruction
|
|
855
|
+
*/
|
|
856
|
+
createCommunicationSession(_params: {
|
|
857
|
+
sessionId: bigint;
|
|
858
|
+
initiator: Address$1;
|
|
859
|
+
initiatorType: ParticipantType;
|
|
860
|
+
responder: Address$1;
|
|
861
|
+
responderType: ParticipantType;
|
|
862
|
+
sessionType: string;
|
|
863
|
+
metadata: string;
|
|
864
|
+
expiresAt: bigint;
|
|
865
|
+
}): Promise<InstructionLike>;
|
|
866
|
+
/**
|
|
867
|
+
* Send a communication message instruction
|
|
868
|
+
*/
|
|
869
|
+
sendCommunicationMessage(_sessionAddress: Address$1, _params: {
|
|
870
|
+
messageId: bigint;
|
|
871
|
+
senderType: unknown;
|
|
872
|
+
content: string;
|
|
873
|
+
messageType: string;
|
|
874
|
+
attachments: string[];
|
|
875
|
+
}): Promise<InstructionLike>;
|
|
876
|
+
/**
|
|
877
|
+
* Update participant status instruction
|
|
878
|
+
*/
|
|
879
|
+
updateParticipantStatus(_params: {
|
|
880
|
+
participant: Address$1;
|
|
881
|
+
participantType: unknown;
|
|
882
|
+
servicesOffered: string[];
|
|
883
|
+
availability: boolean;
|
|
884
|
+
reputationScore: number;
|
|
885
|
+
}): Promise<InstructionLike>;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
/**
|
|
889
|
+
* Solana cluster types for URL generation
|
|
890
|
+
*/
|
|
891
|
+
type SolanaCluster = 'mainnet-beta' | 'devnet' | 'testnet' | 'localnet';
|
|
892
|
+
/**
|
|
893
|
+
* Transaction result with verification URLs
|
|
894
|
+
*/
|
|
895
|
+
interface TransactionResult {
|
|
896
|
+
signature: string | Signature$1;
|
|
897
|
+
cluster: SolanaCluster;
|
|
898
|
+
urls: {
|
|
899
|
+
solanaExplorer: string;
|
|
900
|
+
solscan: string;
|
|
901
|
+
solanaFM: string;
|
|
902
|
+
xray: string;
|
|
903
|
+
};
|
|
904
|
+
commitment: Commitment;
|
|
905
|
+
timestamp: number;
|
|
906
|
+
}
|
|
907
|
+
|
|
908
|
+
type Signature = string;
|
|
909
|
+
type IInstruction = Instruction;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Base class for all instruction modules using the unified InstructionBuilder.
|
|
913
|
+
* This replaces the old BaseInstructions class with a much simpler pattern.
|
|
914
|
+
*/
|
|
915
|
+
declare abstract class BaseModule {
|
|
916
|
+
protected builder: InstructionBuilder;
|
|
917
|
+
protected config: GhostSpeakConfig;
|
|
918
|
+
protected logger?: {
|
|
919
|
+
info: (...args: unknown[]) => void;
|
|
920
|
+
error: (...args: unknown[]) => void;
|
|
921
|
+
};
|
|
922
|
+
protected cacheManager: CacheManager;
|
|
923
|
+
private _debugMode;
|
|
924
|
+
constructor(config: GhostSpeakConfig);
|
|
925
|
+
/**
|
|
926
|
+
* Enable debug mode for next operation
|
|
927
|
+
*/
|
|
928
|
+
debug(): this;
|
|
929
|
+
/**
|
|
930
|
+
* Execute a single instruction
|
|
931
|
+
*/
|
|
932
|
+
protected execute(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction, signers: TransactionSigner[]): Promise<string>;
|
|
933
|
+
/**
|
|
934
|
+
* Execute a single instruction with detailed result
|
|
935
|
+
*/
|
|
936
|
+
protected executeWithDetails(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction, signers: TransactionSigner[]): Promise<TransactionResult>;
|
|
937
|
+
/**
|
|
938
|
+
* Execute multiple instructions in a batch
|
|
939
|
+
*/
|
|
940
|
+
protected executeBatch(batchName: string, instructionGetters: (() => Promise<IInstruction> | IInstruction)[], signers: TransactionSigner[]): Promise<Signature>;
|
|
941
|
+
/**
|
|
942
|
+
* Simulate an instruction
|
|
943
|
+
*/
|
|
944
|
+
protected simulate(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction, signers: TransactionSigner[]): Promise<unknown>;
|
|
945
|
+
/**
|
|
946
|
+
* Simulate an instruction (public accessor)
|
|
947
|
+
*/
|
|
948
|
+
simulateInstruction(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction, signers: TransactionSigner[]): Promise<unknown>;
|
|
949
|
+
/**
|
|
950
|
+
* Estimate transaction cost
|
|
951
|
+
*/
|
|
952
|
+
protected estimateCost(instructionGetters: (() => Promise<IInstruction> | IInstruction)[]): Promise<bigint>;
|
|
953
|
+
/**
|
|
954
|
+
* Get cost estimation for an instruction
|
|
955
|
+
*/
|
|
956
|
+
getCost(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction): Promise<bigint>;
|
|
957
|
+
/**
|
|
958
|
+
* Get human-readable explanation
|
|
959
|
+
*/
|
|
960
|
+
explain(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction): Promise<string>;
|
|
961
|
+
/**
|
|
962
|
+
* Debug analyze without executing
|
|
963
|
+
*/
|
|
964
|
+
analyze(instructionName: string, instructionGetter: () => Promise<IInstruction> | IInstruction): Promise<unknown>;
|
|
965
|
+
/**
|
|
966
|
+
* Get decoded account (with optional caching)
|
|
967
|
+
*/
|
|
968
|
+
protected getAccount<T>(address: Address$1, decoderImportName: string): Promise<T | null>;
|
|
969
|
+
/**
|
|
970
|
+
* Get multiple decoded accounts (with optional caching)
|
|
971
|
+
*/
|
|
972
|
+
protected getAccounts<T>(addresses: Address$1[], decoderImportName: string): Promise<(T | null)[]>;
|
|
973
|
+
/**
|
|
974
|
+
* Get program accounts
|
|
975
|
+
*/
|
|
976
|
+
protected getProgramAccounts<T>(decoderImportName: string, filters?: ({
|
|
977
|
+
dataSize: bigint;
|
|
978
|
+
} | {
|
|
979
|
+
memcmp: {
|
|
980
|
+
offset: bigint;
|
|
981
|
+
bytes: string;
|
|
982
|
+
encoding?: 'base58' | 'base64';
|
|
983
|
+
};
|
|
984
|
+
})[]): Promise<{
|
|
985
|
+
address: Address$1;
|
|
986
|
+
data: T;
|
|
987
|
+
}[]>;
|
|
988
|
+
/**
|
|
989
|
+
* Get program ID
|
|
990
|
+
*/
|
|
991
|
+
protected get programId(): Address$1;
|
|
992
|
+
/**
|
|
993
|
+
* Get program ID (public accessor)
|
|
994
|
+
*/
|
|
995
|
+
getProgramId(): Address$1;
|
|
996
|
+
/**
|
|
997
|
+
* Get commitment level
|
|
998
|
+
*/
|
|
999
|
+
protected get commitment(): Commitment;
|
|
1000
|
+
/**
|
|
1001
|
+
* Get commitment level (public accessor)
|
|
1002
|
+
*/
|
|
1003
|
+
getCommitment(): Commitment;
|
|
1004
|
+
/**
|
|
1005
|
+
* Invalidate cache for specific account
|
|
1006
|
+
*/
|
|
1007
|
+
invalidateCache(address: Address$1): void;
|
|
1008
|
+
/**
|
|
1009
|
+
* Clear all caches
|
|
1010
|
+
*/
|
|
1011
|
+
clearCache(): void;
|
|
1012
|
+
/**
|
|
1013
|
+
* Get cache statistics
|
|
1014
|
+
*/
|
|
1015
|
+
getCacheStats(): {
|
|
1016
|
+
accountCache: {
|
|
1017
|
+
size: number;
|
|
1018
|
+
max: number;
|
|
1019
|
+
};
|
|
1020
|
+
pdaCache: {
|
|
1021
|
+
size: number;
|
|
1022
|
+
max: number;
|
|
1023
|
+
};
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Simplified agent management using unified instruction pattern
|
|
1029
|
+
*/
|
|
1030
|
+
declare class AgentModule extends BaseModule {
|
|
1031
|
+
private ipfsUtils;
|
|
1032
|
+
constructor(config: GhostSpeakConfig & {
|
|
1033
|
+
ipfsConfig?: IPFSConfig;
|
|
1034
|
+
});
|
|
1035
|
+
/**
|
|
1036
|
+
* Register a new agent
|
|
1037
|
+
*/
|
|
1038
|
+
register(signer: TransactionSigner, params: {
|
|
1039
|
+
agentType: number;
|
|
1040
|
+
name: string;
|
|
1041
|
+
description: string;
|
|
1042
|
+
metadataUri: string;
|
|
1043
|
+
agentId: string;
|
|
1044
|
+
pricingModel?: PricingModel$1;
|
|
1045
|
+
skipSimulation?: boolean;
|
|
1046
|
+
}): Promise<string>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Register a compressed agent (5000x cheaper)
|
|
1049
|
+
*/
|
|
1050
|
+
registerCompressed(signer: TransactionSigner, params: {
|
|
1051
|
+
agentType: number;
|
|
1052
|
+
name: string;
|
|
1053
|
+
description: string;
|
|
1054
|
+
metadataUri: string;
|
|
1055
|
+
agentId: string;
|
|
1056
|
+
merkleTree: Address$1;
|
|
1057
|
+
treeConfig?: Address$1;
|
|
1058
|
+
pricingModel?: PricingModel$1;
|
|
1059
|
+
}): Promise<string>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Update agent metadata
|
|
1062
|
+
*/
|
|
1063
|
+
update(signer: TransactionSigner, params: {
|
|
1064
|
+
agentAddress: Address$1;
|
|
1065
|
+
metadataUri: string;
|
|
1066
|
+
agentType: number;
|
|
1067
|
+
agentId: string;
|
|
1068
|
+
name?: string | null;
|
|
1069
|
+
description?: string | null;
|
|
1070
|
+
pricingModel?: PricingModel$1;
|
|
1071
|
+
}): Promise<string>;
|
|
1072
|
+
/**
|
|
1073
|
+
* Verify an agent
|
|
1074
|
+
*/
|
|
1075
|
+
verify(signer: TransactionSigner, params: {
|
|
1076
|
+
agentAddress: Address$1;
|
|
1077
|
+
agentPubkey: Address$1;
|
|
1078
|
+
serviceEndpoint: string;
|
|
1079
|
+
supportedCapabilities: Array<number | bigint>;
|
|
1080
|
+
verifiedAt: number | bigint;
|
|
1081
|
+
}): Promise<string>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Deactivate an agent
|
|
1084
|
+
*/
|
|
1085
|
+
deactivate(signer: TransactionSigner, params: {
|
|
1086
|
+
agentAddress: Address$1;
|
|
1087
|
+
agentId: string;
|
|
1088
|
+
}): Promise<string>;
|
|
1089
|
+
/**
|
|
1090
|
+
* Activate an agent
|
|
1091
|
+
*/
|
|
1092
|
+
activate(signer: TransactionSigner, params: {
|
|
1093
|
+
agentAddress: Address$1;
|
|
1094
|
+
agentId: string;
|
|
1095
|
+
}): Promise<string>;
|
|
1096
|
+
/**
|
|
1097
|
+
* Get agent account
|
|
1098
|
+
*/
|
|
1099
|
+
getAgentAccount(address: Address$1): Promise<Agent | null>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Get all agents
|
|
1102
|
+
*/
|
|
1103
|
+
getAllAgents(): Promise<{
|
|
1104
|
+
address: Address$1;
|
|
1105
|
+
data: Agent;
|
|
1106
|
+
}[]>;
|
|
1107
|
+
/**
|
|
1108
|
+
* Get agents by type
|
|
1109
|
+
*/
|
|
1110
|
+
getAgentsByType(agentType: number): Promise<{
|
|
1111
|
+
address: Address$1;
|
|
1112
|
+
data: Agent;
|
|
1113
|
+
}[]>;
|
|
1114
|
+
/**
|
|
1115
|
+
* Get user's agents
|
|
1116
|
+
*/
|
|
1117
|
+
getUserAgents(authority: Address$1): Promise<{
|
|
1118
|
+
address: Address$1;
|
|
1119
|
+
data: Agent;
|
|
1120
|
+
}[]>;
|
|
1121
|
+
/**
|
|
1122
|
+
* Batch get multiple agent accounts
|
|
1123
|
+
*
|
|
1124
|
+
* Uses efficient batching (100 accounts per RPC call) with optional caching.
|
|
1125
|
+
*
|
|
1126
|
+
* @param addresses - Agent addresses to fetch
|
|
1127
|
+
* @param onProgress - Optional progress callback
|
|
1128
|
+
* @returns Array of agent accounts (null for non-existent)
|
|
1129
|
+
*
|
|
1130
|
+
* @example
|
|
1131
|
+
* ```typescript
|
|
1132
|
+
* const agents = await client.agents.batchGetAgents(
|
|
1133
|
+
* ['agent1...', 'agent2...', 'agent3...'],
|
|
1134
|
+
* (completed, total) => console.log(`${completed}/${total}`)
|
|
1135
|
+
* )
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
batchGetAgents(addresses: Address$1[], onProgress?: (completed: number, total: number) => void): Promise<(Agent | null)[]>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Batch get only existing agent accounts
|
|
1141
|
+
*
|
|
1142
|
+
* Filters out non-existent addresses.
|
|
1143
|
+
*
|
|
1144
|
+
* @param addresses - Agent addresses to fetch
|
|
1145
|
+
* @param onProgress - Optional progress callback
|
|
1146
|
+
* @returns Array of existing agents with their addresses
|
|
1147
|
+
*
|
|
1148
|
+
* @example
|
|
1149
|
+
* ```typescript
|
|
1150
|
+
* const existingAgents = await client.agents.batchGetExistingAgents(['addr1', 'addr2'])
|
|
1151
|
+
* // Returns: [{ address: 'addr1', account: Agent }, ...]
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
batchGetExistingAgents(addresses: Address$1[], onProgress?: (completed: number, total: number) => void): Promise<Array<{
|
|
1155
|
+
address: Address$1;
|
|
1156
|
+
account: Agent;
|
|
1157
|
+
}>>;
|
|
1158
|
+
/**
|
|
1159
|
+
* Batch get and map agents to a simplified format
|
|
1160
|
+
*
|
|
1161
|
+
* Useful for creating agent summaries or lists.
|
|
1162
|
+
*
|
|
1163
|
+
* @param addresses - Agent addresses to fetch
|
|
1164
|
+
* @param mapper - Transform function
|
|
1165
|
+
* @returns Array of mapped results
|
|
1166
|
+
*
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```typescript
|
|
1169
|
+
* const summaries = await client.agents.batchGetAndMapAgents(
|
|
1170
|
+
* addresses,
|
|
1171
|
+
* (agent, address) => agent ? {
|
|
1172
|
+
* address,
|
|
1173
|
+
* name: agent.name,
|
|
1174
|
+
* type: agent.agentType,
|
|
1175
|
+
* active: agent.isActive
|
|
1176
|
+
* } : null
|
|
1177
|
+
* )
|
|
1178
|
+
* ```
|
|
1179
|
+
*/
|
|
1180
|
+
batchGetAndMapAgents<R>(addresses: Address$1[], mapper: (agent: Agent | null, address: Address$1, index: number) => R): Promise<R[]>;
|
|
1181
|
+
private deriveAgentPda;
|
|
1182
|
+
private deriveUserRegistryPda;
|
|
1183
|
+
private deriveTreeConfigPda;
|
|
1184
|
+
private get systemProgramId();
|
|
1185
|
+
private get compressionProgramId();
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
interface ProposalType {
|
|
1189
|
+
kind: 'ConfigChange' | 'Treasury' | 'Protocol' | 'Emergency';
|
|
1190
|
+
data?: Record<string, unknown>;
|
|
1191
|
+
}
|
|
1192
|
+
interface ExecutionParams {
|
|
1193
|
+
instructions: string[];
|
|
1194
|
+
accounts: Address$1[];
|
|
1195
|
+
targetProgram: Address$1;
|
|
1196
|
+
executeAfter?: bigint;
|
|
1197
|
+
}
|
|
1198
|
+
interface CreateProposalParams {
|
|
1199
|
+
title: string;
|
|
1200
|
+
description: string;
|
|
1201
|
+
proposalType: ProposalType;
|
|
1202
|
+
executionParams: ExecutionParams;
|
|
1203
|
+
proposalId: bigint;
|
|
1204
|
+
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Governance management module
|
|
1207
|
+
*
|
|
1208
|
+
* Provides high-level access to governance operations including:
|
|
1209
|
+
* - Proposal creation and management
|
|
1210
|
+
*
|
|
1211
|
+
* NOTE: Voting, delegation, and execution are handled through protocol_config + multisig
|
|
1212
|
+
*/
|
|
1213
|
+
declare class GovernanceModule extends BaseModule {
|
|
1214
|
+
/**
|
|
1215
|
+
* Get initialize governance proposal instruction
|
|
1216
|
+
*/
|
|
1217
|
+
getInitializeGovernanceProposalInstruction(params: {
|
|
1218
|
+
proposal?: Address$1;
|
|
1219
|
+
proposer: TransactionSigner;
|
|
1220
|
+
title: string;
|
|
1221
|
+
description: string;
|
|
1222
|
+
proposalType: any;
|
|
1223
|
+
executionParams: any;
|
|
1224
|
+
proposalId: number | bigint;
|
|
1225
|
+
}): Promise<InitializeGovernanceProposalInstruction<Address$1<"4wHjA2a5YC4twZb4NQpwZpixo5FgxxzuJUrCG7UnF9pB">, string, string, string, []>>;
|
|
1226
|
+
/**
|
|
1227
|
+
* Create a new governance proposal
|
|
1228
|
+
*/
|
|
1229
|
+
createProposal(params: {
|
|
1230
|
+
signer: TransactionSigner;
|
|
1231
|
+
title: string;
|
|
1232
|
+
description: string;
|
|
1233
|
+
proposalType: 'parameter_change' | 'upgrade' | 'treasury';
|
|
1234
|
+
votingDuration: number;
|
|
1235
|
+
executionDelay?: number;
|
|
1236
|
+
}): Promise<string>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Get governance proposal account
|
|
1239
|
+
*/
|
|
1240
|
+
getProposal(address: Address$1): Promise<GovernanceProposal | null>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Get all active proposals
|
|
1243
|
+
*/
|
|
1244
|
+
getActiveProposals(): Promise<{
|
|
1245
|
+
address: Address$1;
|
|
1246
|
+
data: GovernanceProposal;
|
|
1247
|
+
}[]>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Get proposals by proposer
|
|
1250
|
+
*/
|
|
1251
|
+
getProposalsByProposer(proposer: Address$1): Promise<{
|
|
1252
|
+
address: Address$1;
|
|
1253
|
+
data: GovernanceProposal;
|
|
1254
|
+
}[]>;
|
|
1255
|
+
/**
|
|
1256
|
+
* Get proposals by status
|
|
1257
|
+
*/
|
|
1258
|
+
getProposalsByStatus(_status: 'draft' | 'voting' | 'succeeded' | 'defeated' | 'executed'): Promise<{
|
|
1259
|
+
address: Address$1;
|
|
1260
|
+
data: GovernanceProposal;
|
|
1261
|
+
}[]>;
|
|
1262
|
+
private deriveProposalPda;
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
interface CreateMultisigParams {
|
|
1266
|
+
multisigId: bigint;
|
|
1267
|
+
threshold: number;
|
|
1268
|
+
signers: Address$1[];
|
|
1269
|
+
config?: Partial<MultisigTypeConfigArgs>;
|
|
1270
|
+
owner: TransactionSigner;
|
|
1271
|
+
}
|
|
1272
|
+
interface MultisigProposalParams {
|
|
1273
|
+
multisigAddress: Address$1;
|
|
1274
|
+
title: string;
|
|
1275
|
+
description: string;
|
|
1276
|
+
proposalType: ProposalTypeArgs;
|
|
1277
|
+
executionParams: ExecutionParamsArgs;
|
|
1278
|
+
proposalId: bigint;
|
|
1279
|
+
proposer: TransactionSigner;
|
|
1280
|
+
}
|
|
1281
|
+
interface ExecuteProposalParams {
|
|
1282
|
+
proposalAddress: Address$1;
|
|
1283
|
+
executor: TransactionSigner;
|
|
1284
|
+
targetProgram: Address$1;
|
|
1285
|
+
}
|
|
1286
|
+
declare class MultisigModule extends BaseModule {
|
|
1287
|
+
/**
|
|
1288
|
+
* Create a new multisig account
|
|
1289
|
+
*/
|
|
1290
|
+
createMultisig(params: CreateMultisigParams): Promise<string>;
|
|
1291
|
+
/**
|
|
1292
|
+
* Create a proposal (Uses Governance Protocol)
|
|
1293
|
+
*
|
|
1294
|
+
* Note: This creates a GovernanceProposal. The proposer must be a signer.
|
|
1295
|
+
*/
|
|
1296
|
+
createProposal(params: MultisigProposalParams): Promise<string>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Execute a proposal (Note: Approval/voting removed, use protocol_config instead)
|
|
1299
|
+
*/
|
|
1300
|
+
executeProposal(params: ExecuteProposalParams): Promise<string>;
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
/**
|
|
1304
|
+
* GhostSpeak DID (Decentralized Identifier) Types
|
|
1305
|
+
*
|
|
1306
|
+
* Implements the did:sol method for Solana-based DIDs following W3C standards.
|
|
1307
|
+
* Based on Identity.com's did:sol specification v3.0.
|
|
1308
|
+
*/
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Verification method type for DIDs
|
|
1312
|
+
*/
|
|
1313
|
+
declare enum VerificationMethodType {
|
|
1314
|
+
/** Ed25519 verification key (Solana native) */
|
|
1315
|
+
Ed25519VerificationKey2020 = "Ed25519VerificationKey2020",
|
|
1316
|
+
/** X25519 key agreement for encryption */
|
|
1317
|
+
X25519KeyAgreementKey2020 = "X25519KeyAgreementKey2020",
|
|
1318
|
+
/** Secp256k1 verification key (Ethereum compatibility) */
|
|
1319
|
+
EcdsaSecp256k1VerificationKey2019 = "EcdsaSecp256k1VerificationKey2019"
|
|
1320
|
+
}
|
|
1321
|
+
/**
|
|
1322
|
+
* Verification relationship types
|
|
1323
|
+
*/
|
|
1324
|
+
declare enum VerificationRelationship {
|
|
1325
|
+
/** Key can authenticate as the DID */
|
|
1326
|
+
Authentication = "authentication",
|
|
1327
|
+
/** Key can assert claims (issue credentials) */
|
|
1328
|
+
AssertionMethod = "assertionMethod",
|
|
1329
|
+
/** Key can perform key agreement (encryption) */
|
|
1330
|
+
KeyAgreement = "keyAgreement",
|
|
1331
|
+
/** Key can invoke capabilities (update DID document) */
|
|
1332
|
+
CapabilityInvocation = "capabilityInvocation",
|
|
1333
|
+
/** Key can delegate capabilities */
|
|
1334
|
+
CapabilityDelegation = "capabilityDelegation"
|
|
1335
|
+
}
|
|
1336
|
+
/**
|
|
1337
|
+
* Service endpoint type
|
|
1338
|
+
*/
|
|
1339
|
+
declare enum ServiceEndpointType {
|
|
1340
|
+
/** AI agent service endpoint */
|
|
1341
|
+
AIAgentService = "AIAgentService",
|
|
1342
|
+
/** Messaging service endpoint (DIDComm) */
|
|
1343
|
+
DIDCommMessaging = "DIDCommMessaging",
|
|
1344
|
+
/** Credential repository */
|
|
1345
|
+
CredentialRepository = "CredentialRepository",
|
|
1346
|
+
/** Linked domains verification */
|
|
1347
|
+
LinkedDomains = "LinkedDomains",
|
|
1348
|
+
/** Custom service type */
|
|
1349
|
+
Custom = "Custom"
|
|
1350
|
+
}
|
|
1351
|
+
/**
|
|
1352
|
+
* Verification method for DID document
|
|
1353
|
+
*
|
|
1354
|
+
* Represents a cryptographic key that can be used to verify
|
|
1355
|
+
* signatures or perform other cryptographic operations
|
|
1356
|
+
*/
|
|
1357
|
+
interface VerificationMethod {
|
|
1358
|
+
/** Method identifier (e.g., "key-1") */
|
|
1359
|
+
id: string;
|
|
1360
|
+
/** Type of verification method */
|
|
1361
|
+
methodType: VerificationMethodType;
|
|
1362
|
+
/** DID of the controller (usually the DID itself) */
|
|
1363
|
+
controller: string;
|
|
1364
|
+
/** Public key in multibase format (base58btc) */
|
|
1365
|
+
publicKeyMultibase: string;
|
|
1366
|
+
/** Verification relationships this key has */
|
|
1367
|
+
relationships: VerificationRelationship[];
|
|
1368
|
+
/** Creation timestamp */
|
|
1369
|
+
createdAt: number;
|
|
1370
|
+
/** Revoked flag */
|
|
1371
|
+
revoked: boolean;
|
|
1372
|
+
}
|
|
1373
|
+
/**
|
|
1374
|
+
* Service endpoint in DID document
|
|
1375
|
+
*/
|
|
1376
|
+
interface ServiceEndpoint {
|
|
1377
|
+
/** Service identifier (e.g., "agent-api") */
|
|
1378
|
+
id: string;
|
|
1379
|
+
/** Type of service */
|
|
1380
|
+
serviceType: ServiceEndpointType;
|
|
1381
|
+
/** Service endpoint URI */
|
|
1382
|
+
serviceEndpoint: string;
|
|
1383
|
+
/** Optional description */
|
|
1384
|
+
description: string;
|
|
1385
|
+
}
|
|
1386
|
+
/**
|
|
1387
|
+
* DID Document - main account for storing decentralized identifiers
|
|
1388
|
+
*
|
|
1389
|
+
* Follows W3C DID Core specification and did:sol method
|
|
1390
|
+
*/
|
|
1391
|
+
interface DidDocument {
|
|
1392
|
+
/** The DID string (e.g., "did:sol:devnet:HN7cABqLq46Es1jh92dQQisAq662SmxELLLsHHe4YWrH") */
|
|
1393
|
+
did: string;
|
|
1394
|
+
/** Controller of the DID (can update the document) */
|
|
1395
|
+
controller: Address$1;
|
|
1396
|
+
/** Verification methods (public keys) */
|
|
1397
|
+
verificationMethods: VerificationMethod[];
|
|
1398
|
+
/** Service endpoints */
|
|
1399
|
+
serviceEndpoints: ServiceEndpoint[];
|
|
1400
|
+
/** Context URIs (for W3C compatibility) */
|
|
1401
|
+
context: string[];
|
|
1402
|
+
/** Also known as (alternative DIDs) */
|
|
1403
|
+
alsoKnownAs: string[];
|
|
1404
|
+
/** DID document creation timestamp */
|
|
1405
|
+
createdAt: number;
|
|
1406
|
+
/** Last update timestamp */
|
|
1407
|
+
updatedAt: number;
|
|
1408
|
+
/** Version number (incremented on each update) */
|
|
1409
|
+
version: number;
|
|
1410
|
+
/** Deactivated flag */
|
|
1411
|
+
deactivated: boolean;
|
|
1412
|
+
/** Deactivation timestamp (if deactivated) */
|
|
1413
|
+
deactivatedAt?: number;
|
|
1414
|
+
/** PDA bump */
|
|
1415
|
+
bump: number;
|
|
1416
|
+
}
|
|
1417
|
+
/**
|
|
1418
|
+
* DID Resolution Metadata
|
|
1419
|
+
*
|
|
1420
|
+
* Additional metadata for DID resolution
|
|
1421
|
+
*/
|
|
1422
|
+
interface DidResolutionMetadata {
|
|
1423
|
+
/** DID being resolved */
|
|
1424
|
+
did: string;
|
|
1425
|
+
/** Pointer to the DID document account */
|
|
1426
|
+
didDocument: Address$1;
|
|
1427
|
+
/** Resolution timestamp */
|
|
1428
|
+
resolvedAt: number;
|
|
1429
|
+
/** Content type (application/did+json) */
|
|
1430
|
+
contentType: string;
|
|
1431
|
+
/** DID document version at resolution time */
|
|
1432
|
+
version: number;
|
|
1433
|
+
/** PDA bump */
|
|
1434
|
+
bump: number;
|
|
1435
|
+
}
|
|
1436
|
+
/**
|
|
1437
|
+
* W3C DID Document format for export
|
|
1438
|
+
* Compliant with W3C DID Core specification
|
|
1439
|
+
*/
|
|
1440
|
+
interface W3CDidDocument {
|
|
1441
|
+
'@context': string[];
|
|
1442
|
+
id: string;
|
|
1443
|
+
controller?: string | string[];
|
|
1444
|
+
verificationMethod: Array<{
|
|
1445
|
+
id: string;
|
|
1446
|
+
type: string;
|
|
1447
|
+
controller: string;
|
|
1448
|
+
publicKeyMultibase: string;
|
|
1449
|
+
}>;
|
|
1450
|
+
authentication?: Array<string | {
|
|
1451
|
+
id: string;
|
|
1452
|
+
type: string;
|
|
1453
|
+
controller: string;
|
|
1454
|
+
publicKeyMultibase: string;
|
|
1455
|
+
}>;
|
|
1456
|
+
assertionMethod?: string[];
|
|
1457
|
+
keyAgreement?: string[];
|
|
1458
|
+
capabilityInvocation?: string[];
|
|
1459
|
+
capabilityDelegation?: string[];
|
|
1460
|
+
service?: Array<{
|
|
1461
|
+
id: string;
|
|
1462
|
+
type: string;
|
|
1463
|
+
serviceEndpoint: string;
|
|
1464
|
+
description?: string;
|
|
1465
|
+
}>;
|
|
1466
|
+
alsoKnownAs?: string[];
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Parameters for creating a DID document
|
|
1470
|
+
*/
|
|
1471
|
+
interface CreateDidDocumentParams {
|
|
1472
|
+
/** Controller public key */
|
|
1473
|
+
controller: Address$1;
|
|
1474
|
+
/** Initial verification methods */
|
|
1475
|
+
verificationMethods?: VerificationMethod[];
|
|
1476
|
+
/** Initial service endpoints */
|
|
1477
|
+
serviceEndpoints?: ServiceEndpoint[];
|
|
1478
|
+
/** Network (mainnet, devnet, testnet) */
|
|
1479
|
+
network?: 'mainnet' | 'devnet' | 'testnet';
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Parameters for updating a DID document
|
|
1483
|
+
*/
|
|
1484
|
+
interface UpdateDidDocumentParams {
|
|
1485
|
+
/** DID document address */
|
|
1486
|
+
didDocument: Address$1;
|
|
1487
|
+
/** Verification method to add */
|
|
1488
|
+
addVerificationMethod?: VerificationMethod;
|
|
1489
|
+
/** Verification method ID to remove */
|
|
1490
|
+
removeVerificationMethodId?: string;
|
|
1491
|
+
/** Service endpoint to add */
|
|
1492
|
+
addServiceEndpoint?: ServiceEndpoint;
|
|
1493
|
+
/** Service endpoint ID to remove */
|
|
1494
|
+
removeServiceEndpointId?: string;
|
|
1495
|
+
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Parameters for deactivating a DID document
|
|
1498
|
+
*/
|
|
1499
|
+
interface DeactivateDidDocumentParams {
|
|
1500
|
+
/** DID document address */
|
|
1501
|
+
didDocument: Address$1;
|
|
1502
|
+
}
|
|
1503
|
+
/**
|
|
1504
|
+
* Parameters for resolving a DID document
|
|
1505
|
+
*/
|
|
1506
|
+
interface ResolveDidDocumentParams {
|
|
1507
|
+
/** DID string or controller address */
|
|
1508
|
+
did: string | Address$1;
|
|
1509
|
+
}
|
|
1510
|
+
/**
|
|
1511
|
+
* DID-related errors
|
|
1512
|
+
*/
|
|
1513
|
+
declare enum DidError {
|
|
1514
|
+
AlreadyDeactivated = "AlreadyDeactivated",
|
|
1515
|
+
TooManyVerificationMethods = "TooManyVerificationMethods",
|
|
1516
|
+
TooManyServiceEndpoints = "TooManyServiceEndpoints",
|
|
1517
|
+
DuplicateMethodId = "DuplicateMethodId",
|
|
1518
|
+
DuplicateServiceId = "DuplicateServiceId",
|
|
1519
|
+
MethodNotFound = "MethodNotFound",
|
|
1520
|
+
ServiceNotFound = "ServiceNotFound",
|
|
1521
|
+
InvalidDidFormat = "InvalidDidFormat",
|
|
1522
|
+
UnauthorizedDidOperation = "UnauthorizedDidOperation",
|
|
1523
|
+
DidDeactivated = "DidDeactivated"
|
|
1524
|
+
}
|
|
1525
|
+
/**
|
|
1526
|
+
* DID Error class
|
|
1527
|
+
*/
|
|
1528
|
+
declare class DidErrorClass extends Error {
|
|
1529
|
+
code: DidError;
|
|
1530
|
+
constructor(code: DidError, message?: string);
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1533
|
+
/**
|
|
1534
|
+
* GhostSpeak DID Helpers
|
|
1535
|
+
*
|
|
1536
|
+
* Utility functions for DID operations, validation, and W3C export
|
|
1537
|
+
*/
|
|
1538
|
+
|
|
1539
|
+
/**
|
|
1540
|
+
* Derive DID document PDA
|
|
1541
|
+
* Pattern: ['did_document', controller]
|
|
1542
|
+
*/
|
|
1543
|
+
declare function deriveDidDocumentPda(programId: Address$1, controller: Address$1): Promise<[Address$1, number]>;
|
|
1544
|
+
/**
|
|
1545
|
+
* Generate a did:sol string from network and public key
|
|
1546
|
+
*
|
|
1547
|
+
* @param network - Solana network (mainnet, devnet, testnet, localnet)
|
|
1548
|
+
* @param pubkey - Public key to use as the DID identifier
|
|
1549
|
+
* @returns DID string in the format "did:sol:network:pubkey"
|
|
1550
|
+
*
|
|
1551
|
+
* @example
|
|
1552
|
+
* ```typescript
|
|
1553
|
+
* const did = generateDidString('devnet', '5VKz...')
|
|
1554
|
+
* // Returns: "did:sol:devnet:5VKz..."
|
|
1555
|
+
* ```
|
|
1556
|
+
*/
|
|
1557
|
+
declare function generateDidString(network: 'mainnet' | 'devnet' | 'testnet' | 'localnet', pubkey: Address$1 | string): string;
|
|
1558
|
+
/**
|
|
1559
|
+
* Validate DID string format
|
|
1560
|
+
*
|
|
1561
|
+
* @param did - DID string to validate
|
|
1562
|
+
* @throws {DidErrorClass} If DID format is invalid
|
|
1563
|
+
*
|
|
1564
|
+
* @example
|
|
1565
|
+
* ```typescript
|
|
1566
|
+
* validateDidString('did:sol:devnet:5VKz...')
|
|
1567
|
+
* // Returns: void (no error)
|
|
1568
|
+
*
|
|
1569
|
+
* validateDidString('invalid:did')
|
|
1570
|
+
* // Throws: DidErrorClass
|
|
1571
|
+
* ```
|
|
1572
|
+
*/
|
|
1573
|
+
declare function validateDidString(did: string): void;
|
|
1574
|
+
/**
|
|
1575
|
+
* Parse a DID string into its components
|
|
1576
|
+
*
|
|
1577
|
+
* @param did - DID string to parse
|
|
1578
|
+
* @returns Object with method, network, and identifier
|
|
1579
|
+
*
|
|
1580
|
+
* @example
|
|
1581
|
+
* ```typescript
|
|
1582
|
+
* const parts = parseDidString('did:sol:devnet:5VKz...')
|
|
1583
|
+
* // Returns: { method: 'sol', network: 'devnet', identifier: '5VKz...' }
|
|
1584
|
+
* ```
|
|
1585
|
+
*/
|
|
1586
|
+
declare function parseDidString(did: string): {
|
|
1587
|
+
method: string;
|
|
1588
|
+
network: string;
|
|
1589
|
+
identifier: string;
|
|
1590
|
+
};
|
|
1591
|
+
/**
|
|
1592
|
+
* Export a DID document as W3C-compliant format
|
|
1593
|
+
*
|
|
1594
|
+
* @param didDocument - DID document to export
|
|
1595
|
+
* @returns W3C-compliant DID document
|
|
1596
|
+
*
|
|
1597
|
+
* @example
|
|
1598
|
+
* ```typescript
|
|
1599
|
+
* const w3cDoc = exportAsW3CDidDocument(didDocument)
|
|
1600
|
+
* console.log(JSON.stringify(w3cDoc, null, 2))
|
|
1601
|
+
* ```
|
|
1602
|
+
*/
|
|
1603
|
+
declare function exportAsW3CDidDocument(didDocument: DidDocument): W3CDidDocument;
|
|
1604
|
+
/**
|
|
1605
|
+
* Create a default Ed25519 verification method
|
|
1606
|
+
*
|
|
1607
|
+
* @param id - Method identifier (e.g., "key-1")
|
|
1608
|
+
* @param controller - Controller DID
|
|
1609
|
+
* @param publicKey - Public key (Address or base58 string)
|
|
1610
|
+
* @param relationships - Verification relationships
|
|
1611
|
+
* @returns Verification method object
|
|
1612
|
+
*/
|
|
1613
|
+
declare function createEd25519VerificationMethod(id: string, controller: string, publicKey: Address$1 | string, relationships?: VerificationRelationship[]): VerificationMethod;
|
|
1614
|
+
/**
|
|
1615
|
+
* Create a service endpoint
|
|
1616
|
+
*
|
|
1617
|
+
* @param id - Service identifier (e.g., "agent-api")
|
|
1618
|
+
* @param serviceType - Type of service
|
|
1619
|
+
* @param serviceEndpoint - Service endpoint URI
|
|
1620
|
+
* @param description - Optional description
|
|
1621
|
+
* @returns Service endpoint object
|
|
1622
|
+
*/
|
|
1623
|
+
declare function createServiceEndpoint(id: string, serviceType: string, serviceEndpoint: string, description?: string): ServiceEndpoint;
|
|
1624
|
+
/**
|
|
1625
|
+
* Check if a DID document is active and can be used
|
|
1626
|
+
*
|
|
1627
|
+
* @param didDocument - DID document to check
|
|
1628
|
+
* @returns True if active, false if deactivated
|
|
1629
|
+
*/
|
|
1630
|
+
declare function isDidActive(didDocument: DidDocument): boolean;
|
|
1631
|
+
/**
|
|
1632
|
+
* Get verification methods for a specific relationship
|
|
1633
|
+
*
|
|
1634
|
+
* @param didDocument - DID document
|
|
1635
|
+
* @param relationship - Verification relationship to filter by
|
|
1636
|
+
* @returns Array of verification methods with the specified relationship
|
|
1637
|
+
*/
|
|
1638
|
+
declare function getMethodsForRelationship(didDocument: DidDocument, relationship: VerificationRelationship): VerificationMethod[];
|
|
1639
|
+
/**
|
|
1640
|
+
* Check if a public key can perform a specific action
|
|
1641
|
+
*
|
|
1642
|
+
* @param didDocument - DID document
|
|
1643
|
+
* @param publicKey - Public key to check
|
|
1644
|
+
* @param relationship - Required verification relationship
|
|
1645
|
+
* @returns True if the public key has the required relationship
|
|
1646
|
+
*/
|
|
1647
|
+
declare function canPerformAction(didDocument: DidDocument, publicKey: Address$1, relationship: VerificationRelationship): boolean;
|
|
1648
|
+
/**
|
|
1649
|
+
* Convert a DID document to JSON string
|
|
1650
|
+
*
|
|
1651
|
+
* @param didDocument - DID document to convert
|
|
1652
|
+
* @param pretty - Whether to pretty-print the JSON
|
|
1653
|
+
* @returns JSON string representation
|
|
1654
|
+
*/
|
|
1655
|
+
declare function didDocumentToJson(didDocument: DidDocument, pretty?: boolean): string;
|
|
1656
|
+
/**
|
|
1657
|
+
* Extract network from DID string
|
|
1658
|
+
*
|
|
1659
|
+
* @param did - DID string
|
|
1660
|
+
* @returns Network identifier
|
|
1661
|
+
*/
|
|
1662
|
+
declare function getNetworkFromDid(did: string): string;
|
|
1663
|
+
/**
|
|
1664
|
+
* Extract identifier (public key) from DID string
|
|
1665
|
+
*
|
|
1666
|
+
* @param did - DID string
|
|
1667
|
+
* @returns Public key identifier
|
|
1668
|
+
*/
|
|
1669
|
+
declare function getIdentifierFromDid(did: string): string;
|
|
1670
|
+
|
|
1671
|
+
/**
|
|
1672
|
+
* GhostSpeak DID Module
|
|
1673
|
+
*
|
|
1674
|
+
* Provides functionality for managing Decentralized Identifiers (DIDs)
|
|
1675
|
+
* following the W3C DID Core specification and did:sol method.
|
|
1676
|
+
*/
|
|
1677
|
+
|
|
1678
|
+
/**
|
|
1679
|
+
* DidModule - Manage decentralized identifiers on Solana
|
|
1680
|
+
*
|
|
1681
|
+
* @example
|
|
1682
|
+
* ```typescript
|
|
1683
|
+
* const client = new GhostSpeakClient({ cluster: 'devnet' })
|
|
1684
|
+
* const did = client.did
|
|
1685
|
+
*
|
|
1686
|
+
* // Create a DID
|
|
1687
|
+
* const signature = await did.create(signer, {
|
|
1688
|
+
* controller: signer.address,
|
|
1689
|
+
* network: 'devnet'
|
|
1690
|
+
* })
|
|
1691
|
+
*
|
|
1692
|
+
* // Resolve a DID
|
|
1693
|
+
* const didDoc = await did.resolve(signer.address)
|
|
1694
|
+
*
|
|
1695
|
+
* // Export as W3C format
|
|
1696
|
+
* const w3c = await did.exportW3C(signer.address)
|
|
1697
|
+
* ```
|
|
1698
|
+
*/
|
|
1699
|
+
declare class DidModule extends BaseModule {
|
|
1700
|
+
constructor(config: GhostSpeakConfig);
|
|
1701
|
+
/**
|
|
1702
|
+
* Create a new DID document
|
|
1703
|
+
*
|
|
1704
|
+
* @param signer - Transaction signer (will be the controller)
|
|
1705
|
+
* @param params - DID creation parameters
|
|
1706
|
+
* @returns Transaction signature
|
|
1707
|
+
*
|
|
1708
|
+
* @example
|
|
1709
|
+
* ```typescript
|
|
1710
|
+
* const signature = await didModule.create(signer, {
|
|
1711
|
+
* controller: signer.address,
|
|
1712
|
+
* network: 'devnet',
|
|
1713
|
+
* verificationMethods: [{
|
|
1714
|
+
* id: 'key-1',
|
|
1715
|
+
* methodType: VerificationMethodType.Ed25519VerificationKey2020,
|
|
1716
|
+
* controller: 'did:sol:devnet:...',
|
|
1717
|
+
* publicKeyMultibase: 'z...',
|
|
1718
|
+
* relationships: [VerificationRelationship.Authentication],
|
|
1719
|
+
* createdAt: Date.now() / 1000,
|
|
1720
|
+
* revoked: false
|
|
1721
|
+
* }]
|
|
1722
|
+
* })
|
|
1723
|
+
* ```
|
|
1724
|
+
*/
|
|
1725
|
+
create(signer: TransactionSigner, params: CreateDidDocumentParams): Promise<string>;
|
|
1726
|
+
/**
|
|
1727
|
+
* Update an existing DID document
|
|
1728
|
+
*
|
|
1729
|
+
* @param signer - Transaction signer (must be the controller)
|
|
1730
|
+
* @param params - Update parameters
|
|
1731
|
+
* @returns Transaction signature
|
|
1732
|
+
*
|
|
1733
|
+
* @example
|
|
1734
|
+
* ```typescript
|
|
1735
|
+
* const signature = await didModule.update(signer, {
|
|
1736
|
+
* didDocument: didPda,
|
|
1737
|
+
* addVerificationMethod: {
|
|
1738
|
+
* id: 'key-2',
|
|
1739
|
+
* methodType: VerificationMethodType.X25519KeyAgreementKey2020,
|
|
1740
|
+
* controller: 'did:sol:devnet:...',
|
|
1741
|
+
* publicKeyMultibase: 'z...',
|
|
1742
|
+
* relationships: [VerificationRelationship.KeyAgreement],
|
|
1743
|
+
* createdAt: Date.now() / 1000,
|
|
1744
|
+
* revoked: false
|
|
1745
|
+
* }
|
|
1746
|
+
* })
|
|
1747
|
+
* ```
|
|
1748
|
+
*/
|
|
1749
|
+
update(signer: TransactionSigner, params: UpdateDidDocumentParams): Promise<string>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Deactivate a DID document (irreversible)
|
|
1752
|
+
*
|
|
1753
|
+
* @param signer - Transaction signer (must be the controller)
|
|
1754
|
+
* @param params - Deactivation parameters
|
|
1755
|
+
* @returns Transaction signature
|
|
1756
|
+
*
|
|
1757
|
+
* @example
|
|
1758
|
+
* ```typescript
|
|
1759
|
+
* const signature = await didModule.deactivate(signer, {
|
|
1760
|
+
* didDocument: didPda
|
|
1761
|
+
* })
|
|
1762
|
+
* ```
|
|
1763
|
+
*/
|
|
1764
|
+
deactivate(signer: TransactionSigner, params: DeactivateDidDocumentParams): Promise<string>;
|
|
1765
|
+
/**
|
|
1766
|
+
* Resolve a DID document
|
|
1767
|
+
*
|
|
1768
|
+
* @param didOrController - DID string or controller address
|
|
1769
|
+
* @returns DID document or null if not found
|
|
1770
|
+
*
|
|
1771
|
+
* @example
|
|
1772
|
+
* ```typescript
|
|
1773
|
+
* // Resolve by controller address
|
|
1774
|
+
* const didDoc = await didModule.resolve(controllerAddress)
|
|
1775
|
+
*
|
|
1776
|
+
* // Resolve by DID string
|
|
1777
|
+
* const didDoc = await didModule.resolve('did:sol:devnet:5VKz...')
|
|
1778
|
+
* ```
|
|
1779
|
+
*/
|
|
1780
|
+
resolve(didOrController: string | Address$1): Promise<DidDocument | null>;
|
|
1781
|
+
/**
|
|
1782
|
+
* Export a DID document as W3C-compliant JSON
|
|
1783
|
+
*
|
|
1784
|
+
* @param didOrController - DID string or controller address
|
|
1785
|
+
* @param pretty - Whether to pretty-print the JSON
|
|
1786
|
+
* @returns W3C DID document JSON string
|
|
1787
|
+
*
|
|
1788
|
+
* @example
|
|
1789
|
+
* ```typescript
|
|
1790
|
+
* const json = await didModule.exportW3C(controllerAddress, true)
|
|
1791
|
+
* console.log(json)
|
|
1792
|
+
* ```
|
|
1793
|
+
*/
|
|
1794
|
+
exportW3C(didOrController: string | Address$1, pretty?: boolean): Promise<string | null>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Get W3C DID document object
|
|
1797
|
+
*
|
|
1798
|
+
* @param didOrController - DID string or controller address
|
|
1799
|
+
* @returns W3C DID document object or null
|
|
1800
|
+
*/
|
|
1801
|
+
getW3CDocument(didOrController: string | Address$1): Promise<W3CDidDocument | null>;
|
|
1802
|
+
/**
|
|
1803
|
+
* Derive DID document PDA for a controller
|
|
1804
|
+
*
|
|
1805
|
+
* @param controller - Controller address
|
|
1806
|
+
* @returns DID document PDA and bump
|
|
1807
|
+
*/
|
|
1808
|
+
deriveDidPda(controller: Address$1): Promise<[Address$1, number]>;
|
|
1809
|
+
/**
|
|
1810
|
+
* Generate a DID string for a controller
|
|
1811
|
+
*
|
|
1812
|
+
* @param controller - Controller address
|
|
1813
|
+
* @param network - Network identifier
|
|
1814
|
+
* @returns DID string
|
|
1815
|
+
*/
|
|
1816
|
+
generateDid(controller: Address$1, network?: 'mainnet' | 'devnet' | 'testnet'): string;
|
|
1817
|
+
/**
|
|
1818
|
+
* Validate a DID string
|
|
1819
|
+
*
|
|
1820
|
+
* @param did - DID string to validate
|
|
1821
|
+
* @returns True if valid, throws error if invalid
|
|
1822
|
+
*/
|
|
1823
|
+
validateDid(did: string): boolean;
|
|
1824
|
+
/**
|
|
1825
|
+
* Check if a DID is active
|
|
1826
|
+
*
|
|
1827
|
+
* @param didOrController - DID string or controller address
|
|
1828
|
+
* @returns True if active, false if deactivated or not found
|
|
1829
|
+
*/
|
|
1830
|
+
isActive(didOrController: string | Address$1): Promise<boolean>;
|
|
1831
|
+
/**
|
|
1832
|
+
* Build create DID instruction manually
|
|
1833
|
+
* Note: This is temporary until DID instructions are generated from IDL
|
|
1834
|
+
*/
|
|
1835
|
+
private buildCreateDidInstruction;
|
|
1836
|
+
/**
|
|
1837
|
+
* Build update DID instruction manually
|
|
1838
|
+
* Note: This is temporary until DID instructions are generated from IDL
|
|
1839
|
+
*/
|
|
1840
|
+
private buildUpdateDidInstruction;
|
|
1841
|
+
/**
|
|
1842
|
+
* Build deactivate DID instruction manually
|
|
1843
|
+
* Note: This is temporary until DID instructions are generated from IDL
|
|
1844
|
+
*/
|
|
1845
|
+
private buildDeactivateDidInstruction;
|
|
1846
|
+
/**
|
|
1847
|
+
* Create an Ed25519 verification method
|
|
1848
|
+
*/
|
|
1849
|
+
static createVerificationMethod: typeof createEd25519VerificationMethod;
|
|
1850
|
+
/**
|
|
1851
|
+
* Create a service endpoint
|
|
1852
|
+
*/
|
|
1853
|
+
static createServiceEndpoint: typeof createServiceEndpoint;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
/**
|
|
1857
|
+
* GhostSpeak Credential Module
|
|
1858
|
+
*
|
|
1859
|
+
* Provides functionality for creating, signing, and exporting
|
|
1860
|
+
* W3C-compatible Verifiable Credentials with DID integration.
|
|
1861
|
+
*/
|
|
1862
|
+
|
|
1863
|
+
declare enum CredentialKind {
|
|
1864
|
+
AgentIdentity = "AgentIdentity",
|
|
1865
|
+
ReputationScore = "ReputationScore",
|
|
1866
|
+
JobCompletion = "JobCompletion",
|
|
1867
|
+
DelegatedSigner = "DelegatedSigner",
|
|
1868
|
+
Custom = "Custom"
|
|
1869
|
+
}
|
|
1870
|
+
declare enum CredentialStatus {
|
|
1871
|
+
Pending = "Pending",
|
|
1872
|
+
Active = "Active",
|
|
1873
|
+
Revoked = "Revoked",
|
|
1874
|
+
Expired = "Expired"
|
|
1875
|
+
}
|
|
1876
|
+
interface CredentialType {
|
|
1877
|
+
authority: string;
|
|
1878
|
+
name: string;
|
|
1879
|
+
kind: CredentialKind;
|
|
1880
|
+
schemaUri: string;
|
|
1881
|
+
description: string;
|
|
1882
|
+
isActive: boolean;
|
|
1883
|
+
totalIssued: number;
|
|
1884
|
+
createdAt: number;
|
|
1885
|
+
}
|
|
1886
|
+
interface CredentialTemplate {
|
|
1887
|
+
credentialType: string;
|
|
1888
|
+
name: string;
|
|
1889
|
+
imageUri: string;
|
|
1890
|
+
issuer: string;
|
|
1891
|
+
isActive: boolean;
|
|
1892
|
+
totalIssued: number;
|
|
1893
|
+
createdAt: number;
|
|
1894
|
+
crossmintTemplateId?: string;
|
|
1895
|
+
}
|
|
1896
|
+
interface Credential {
|
|
1897
|
+
template: string;
|
|
1898
|
+
subject: string;
|
|
1899
|
+
issuer: string;
|
|
1900
|
+
credentialId: string;
|
|
1901
|
+
subjectDataHash: Uint8Array;
|
|
1902
|
+
subjectDataUri: string;
|
|
1903
|
+
status: CredentialStatus;
|
|
1904
|
+
signature: Uint8Array;
|
|
1905
|
+
issuedAt: number;
|
|
1906
|
+
expiresAt?: number;
|
|
1907
|
+
revokedAt?: number;
|
|
1908
|
+
crossmintCredentialId?: string;
|
|
1909
|
+
}
|
|
1910
|
+
interface W3CVerifiableCredential {
|
|
1911
|
+
'@context': string[];
|
|
1912
|
+
type: string[];
|
|
1913
|
+
id: string;
|
|
1914
|
+
issuer: {
|
|
1915
|
+
id: string;
|
|
1916
|
+
name?: string;
|
|
1917
|
+
} | string;
|
|
1918
|
+
validFrom: string;
|
|
1919
|
+
validUntil?: string;
|
|
1920
|
+
credentialSubject: {
|
|
1921
|
+
id?: string;
|
|
1922
|
+
[key: string]: unknown;
|
|
1923
|
+
};
|
|
1924
|
+
credentialSchema?: {
|
|
1925
|
+
id: string;
|
|
1926
|
+
type: 'JsonSchema';
|
|
1927
|
+
};
|
|
1928
|
+
credentialStatus?: {
|
|
1929
|
+
id: string;
|
|
1930
|
+
type: string;
|
|
1931
|
+
statusPurpose: 'revocation' | 'suspension';
|
|
1932
|
+
};
|
|
1933
|
+
relatedResource?: Array<{
|
|
1934
|
+
id: string;
|
|
1935
|
+
digestMultibase?: string;
|
|
1936
|
+
}>;
|
|
1937
|
+
proof: {
|
|
1938
|
+
type: 'DataIntegrityProof';
|
|
1939
|
+
created: string;
|
|
1940
|
+
verificationMethod: string;
|
|
1941
|
+
cryptosuite: 'eddsa-rdfc-2022';
|
|
1942
|
+
proofPurpose: 'assertionMethod';
|
|
1943
|
+
proofValue: string;
|
|
1944
|
+
};
|
|
1945
|
+
}
|
|
1946
|
+
declare class CredentialModule {
|
|
1947
|
+
private programId;
|
|
1948
|
+
private didModule?;
|
|
1949
|
+
constructor(programId?: Address$1, didModule?: DidModule);
|
|
1950
|
+
/**
|
|
1951
|
+
* Set the DID module for enhanced DID resolution
|
|
1952
|
+
* This enables automatic DID creation and resolution for credentials
|
|
1953
|
+
*/
|
|
1954
|
+
setDidModule(didModule: DidModule): void;
|
|
1955
|
+
hashSubjectData(subjectData: Record<string, unknown>): Uint8Array;
|
|
1956
|
+
generateCredentialId(kind: CredentialKind, subject: string): string;
|
|
1957
|
+
exportAsW3CCredential(credential: Credential, template: CredentialTemplate, credentialType: CredentialType, subjectData: Record<string, unknown>, options?: {
|
|
1958
|
+
network?: 'mainnet' | 'devnet' | 'testnet';
|
|
1959
|
+
includeRelatedResource?: boolean;
|
|
1960
|
+
}): W3CVerifiableCredential;
|
|
1961
|
+
/**
|
|
1962
|
+
* Export credential with DID resolution
|
|
1963
|
+
* Resolves DIDs for issuer and subject to get full DID documents
|
|
1964
|
+
*
|
|
1965
|
+
* @param credential - Credential to export
|
|
1966
|
+
* @param template - Credential template
|
|
1967
|
+
* @param credentialType - Credential type
|
|
1968
|
+
* @param subjectData - Subject data
|
|
1969
|
+
* @param options - Export options
|
|
1970
|
+
* @returns W3C credential with resolved DIDs
|
|
1971
|
+
*/
|
|
1972
|
+
exportWithDidResolution(credential: Credential, template: CredentialTemplate, credentialType: CredentialType, subjectData: Record<string, unknown>, options?: {
|
|
1973
|
+
network?: 'mainnet' | 'devnet' | 'testnet';
|
|
1974
|
+
includeRelatedResource?: boolean;
|
|
1975
|
+
}): Promise<W3CVerifiableCredential>;
|
|
1976
|
+
static buildAgentIdentitySubject(params: {
|
|
1977
|
+
agentId: string;
|
|
1978
|
+
owner: string;
|
|
1979
|
+
name: string;
|
|
1980
|
+
capabilities: string[];
|
|
1981
|
+
serviceEndpoint: string;
|
|
1982
|
+
frameworkOrigin: string;
|
|
1983
|
+
x402Enabled: boolean;
|
|
1984
|
+
registeredAt: number;
|
|
1985
|
+
verifiedAt: number;
|
|
1986
|
+
}): {
|
|
1987
|
+
agentId: string;
|
|
1988
|
+
owner: string;
|
|
1989
|
+
name: string;
|
|
1990
|
+
capabilities: string[];
|
|
1991
|
+
serviceEndpoint: string;
|
|
1992
|
+
frameworkOrigin: string;
|
|
1993
|
+
x402Enabled: boolean;
|
|
1994
|
+
registeredAt: number;
|
|
1995
|
+
verifiedAt: number;
|
|
1996
|
+
};
|
|
1997
|
+
/**
|
|
1998
|
+
* Issue an AgentIdentity credential for a newly registered x402 agent
|
|
1999
|
+
*
|
|
2000
|
+
* This creates a W3C Verifiable Credential that can be:
|
|
2001
|
+
* - Stored on-chain for reputation
|
|
2002
|
+
* - Exported as standard W3C VC JSON
|
|
2003
|
+
* - Verified by third parties
|
|
2004
|
+
*
|
|
2005
|
+
* @example
|
|
2006
|
+
* ```typescript
|
|
2007
|
+
* const result = await credentialModule.issueX402AgentCredential({
|
|
2008
|
+
* agentAddress: 'EPjFWdd5...',
|
|
2009
|
+
* agentId: 'x402-abc123',
|
|
2010
|
+
* owner: 'HN7cAB...',
|
|
2011
|
+
* name: 'My Coinbase Agent',
|
|
2012
|
+
* serviceEndpoint: 'https://my-agent.com/api',
|
|
2013
|
+
* frameworkOrigin: 'coinbase-x402',
|
|
2014
|
+
* x402PaymentAddress: 'EPjFWdd5...',
|
|
2015
|
+
* x402AcceptedTokens: ['EPjFWdd5...'],
|
|
2016
|
+
* x402PricePerCall: '1000000'
|
|
2017
|
+
* })
|
|
2018
|
+
* ```
|
|
2019
|
+
*/
|
|
2020
|
+
issueX402AgentCredential(params: {
|
|
2021
|
+
agentAddress: string;
|
|
2022
|
+
agentId: string;
|
|
2023
|
+
owner: string;
|
|
2024
|
+
name: string;
|
|
2025
|
+
serviceEndpoint: string;
|
|
2026
|
+
frameworkOrigin: string;
|
|
2027
|
+
x402PaymentAddress: string;
|
|
2028
|
+
x402AcceptedTokens: string[];
|
|
2029
|
+
x402PricePerCall: string;
|
|
2030
|
+
capabilities?: string[];
|
|
2031
|
+
description?: string;
|
|
2032
|
+
verificationResponseTimeMs?: number;
|
|
2033
|
+
network?: 'mainnet' | 'devnet' | 'testnet';
|
|
2034
|
+
}): {
|
|
2035
|
+
credentialId: string;
|
|
2036
|
+
credential: Credential;
|
|
2037
|
+
w3cCredential: W3CVerifiableCredential;
|
|
2038
|
+
subjectData: Record<string, unknown>;
|
|
2039
|
+
};
|
|
2040
|
+
/**
|
|
2041
|
+
* Export an existing credential to W3C JSON format
|
|
2042
|
+
*/
|
|
2043
|
+
exportCredentialToJSON(credential: Credential, subjectData: Record<string, unknown>, options?: {
|
|
2044
|
+
network?: 'mainnet' | 'devnet' | 'testnet';
|
|
2045
|
+
pretty?: boolean;
|
|
2046
|
+
}): string;
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
/**
|
|
2050
|
+
* PayAI x402 Client
|
|
2051
|
+
*
|
|
2052
|
+
* Client for making x402 payments through the PayAI facilitator.
|
|
2053
|
+
* Wraps the standard fetch API with automatic payment handling.
|
|
2054
|
+
*
|
|
2055
|
+
* @module payai/PayAIClient
|
|
2056
|
+
* @see https://docs.payai.network/x402/introduction
|
|
2057
|
+
*/
|
|
2058
|
+
|
|
2059
|
+
/**
|
|
2060
|
+
* Check if a response requires payment
|
|
2061
|
+
*/
|
|
2062
|
+
declare function isPaymentRequired(response: Response): boolean;
|
|
2063
|
+
/**
|
|
2064
|
+
* Extract payment requirements from a 402 response
|
|
2065
|
+
*/
|
|
2066
|
+
declare function extractPaymentRequirements(response: Response): Promise<PayAIPaymentRequirement[]>;
|
|
2067
|
+
declare class PayAIClient extends EventEmitter {
|
|
2068
|
+
private readonly config;
|
|
2069
|
+
private readonly localRecords;
|
|
2070
|
+
constructor(config: PayAIClientConfig);
|
|
2071
|
+
/**
|
|
2072
|
+
* Make a fetch request with automatic x402 payment handling
|
|
2073
|
+
*
|
|
2074
|
+
* @param url - The resource URL
|
|
2075
|
+
* @param init - Fetch options
|
|
2076
|
+
* @returns Response from the resource
|
|
2077
|
+
*/
|
|
2078
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
2079
|
+
/**
|
|
2080
|
+
* Verify a payment through the PayAI facilitator
|
|
2081
|
+
*
|
|
2082
|
+
* @param paymentHeader - The payment header/payload
|
|
2083
|
+
* @param requirement - The payment requirement
|
|
2084
|
+
* @returns Verification result
|
|
2085
|
+
*/
|
|
2086
|
+
verifyPayment(paymentHeader: string, requirement: PayAIPaymentRequirement): Promise<{
|
|
2087
|
+
valid: boolean;
|
|
2088
|
+
payer?: string;
|
|
2089
|
+
error?: string;
|
|
2090
|
+
}>;
|
|
2091
|
+
/**
|
|
2092
|
+
* Settle a payment through the PayAI facilitator
|
|
2093
|
+
*
|
|
2094
|
+
* @param paymentHeader - The payment header/payload
|
|
2095
|
+
* @param requirement - The payment requirement
|
|
2096
|
+
* @returns Settlement result
|
|
2097
|
+
*/
|
|
2098
|
+
settlePayment(paymentHeader: string, requirement: PayAIPaymentRequirement): Promise<{
|
|
2099
|
+
success: boolean;
|
|
2100
|
+
transaction?: string;
|
|
2101
|
+
error?: string;
|
|
2102
|
+
}>;
|
|
2103
|
+
/**
|
|
2104
|
+
* List available resources from the PayAI facilitator
|
|
2105
|
+
*
|
|
2106
|
+
* @param options - Filter options
|
|
2107
|
+
* @returns List of available resources
|
|
2108
|
+
*/
|
|
2109
|
+
listResources(options?: {
|
|
2110
|
+
network?: PayAINetwork;
|
|
2111
|
+
capability?: string;
|
|
2112
|
+
maxPrice?: number;
|
|
2113
|
+
}): Promise<{
|
|
2114
|
+
resources: Array<{
|
|
2115
|
+
url: string;
|
|
2116
|
+
description?: string;
|
|
2117
|
+
accepts: PayAIPaymentRequirement[];
|
|
2118
|
+
tags?: string[];
|
|
2119
|
+
}>;
|
|
2120
|
+
}>;
|
|
2121
|
+
/**
|
|
2122
|
+
* Get locally tracked reputation records
|
|
2123
|
+
* (For payments made through this client instance)
|
|
2124
|
+
*/
|
|
2125
|
+
getLocalReputationRecords(): PayAIReputationRecord[];
|
|
2126
|
+
/**
|
|
2127
|
+
* Clear local reputation records
|
|
2128
|
+
*/
|
|
2129
|
+
clearLocalReputationRecords(): void;
|
|
2130
|
+
/**
|
|
2131
|
+
* Select the best payment option from requirements
|
|
2132
|
+
*/
|
|
2133
|
+
private selectPaymentOption;
|
|
2134
|
+
/**
|
|
2135
|
+
* Make payment and retry the original request
|
|
2136
|
+
*/
|
|
2137
|
+
private makePaymentAndRetry;
|
|
2138
|
+
/**
|
|
2139
|
+
* Create a payment header for a requirement
|
|
2140
|
+
* (In production, this would sign a real Solana transaction)
|
|
2141
|
+
*/
|
|
2142
|
+
private createPaymentHeader;
|
|
2143
|
+
/**
|
|
2144
|
+
* Fetch with timeout
|
|
2145
|
+
*/
|
|
2146
|
+
private fetchWithTimeout;
|
|
2147
|
+
}
|
|
2148
|
+
/**
|
|
2149
|
+
* Create a new PayAI client
|
|
2150
|
+
*
|
|
2151
|
+
* @param config - Client configuration
|
|
2152
|
+
* @returns Configured PayAI client
|
|
2153
|
+
*/
|
|
2154
|
+
declare function createPayAIClient(config: PayAIClientConfig): PayAIClient;
|
|
2155
|
+
/**
|
|
2156
|
+
* Make a single x402 payment request through PayAI
|
|
2157
|
+
*
|
|
2158
|
+
* @param url - Resource URL
|
|
2159
|
+
* @param config - Client configuration
|
|
2160
|
+
* @param init - Fetch options
|
|
2161
|
+
* @returns Response from the resource
|
|
2162
|
+
*/
|
|
2163
|
+
declare function payAIFetch(url: string, config: PayAIClientConfig, init?: RequestInit): Promise<Response>;
|
|
2164
|
+
|
|
2165
|
+
/**
|
|
2166
|
+
* Simplified reputation data for module use
|
|
2167
|
+
*/
|
|
2168
|
+
interface ReputationData {
|
|
2169
|
+
agent: Address$1;
|
|
2170
|
+
overallScore: number;
|
|
2171
|
+
totalJobsCompleted: number;
|
|
2172
|
+
totalJobsFailed: number;
|
|
2173
|
+
avgResponseTime: number;
|
|
2174
|
+
disputesAgainst: number;
|
|
2175
|
+
disputesResolved: number;
|
|
2176
|
+
lastUpdated: number;
|
|
2177
|
+
categoryReputations: CategoryReputation[];
|
|
2178
|
+
badges: Array<{
|
|
2179
|
+
badgeType: BadgeType;
|
|
2180
|
+
earnedAt: number;
|
|
2181
|
+
}>;
|
|
2182
|
+
performanceHistory: Array<{
|
|
2183
|
+
timestamp: number;
|
|
2184
|
+
score: number;
|
|
2185
|
+
jobsCompleted: number;
|
|
2186
|
+
avgQuality: number;
|
|
2187
|
+
}>;
|
|
2188
|
+
factors: {
|
|
2189
|
+
completionWeight: number;
|
|
2190
|
+
qualityWeight: number;
|
|
2191
|
+
timelinessWeight: number;
|
|
2192
|
+
satisfactionWeight: number;
|
|
2193
|
+
disputeWeight: number;
|
|
2194
|
+
};
|
|
2195
|
+
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Reputation module for managing reputation calculations
|
|
2198
|
+
*/
|
|
2199
|
+
declare class ReputationModule extends BaseModule {
|
|
2200
|
+
private calculator;
|
|
2201
|
+
private tagEngine;
|
|
2202
|
+
constructor(config: GhostSpeakConfig);
|
|
2203
|
+
/**
|
|
2204
|
+
* Calculate reputation change for a job
|
|
2205
|
+
*/
|
|
2206
|
+
calculateReputationChange(currentData: ReputationData, jobPerformance: JobPerformance): ReputationCalculationResult;
|
|
2207
|
+
/**
|
|
2208
|
+
* Get tier name from tier enum
|
|
2209
|
+
*/
|
|
2210
|
+
getTierName(tier: ReputationTier): string;
|
|
2211
|
+
/**
|
|
2212
|
+
* Get tier from score
|
|
2213
|
+
*/
|
|
2214
|
+
getTierFromScore(score: number): ReputationTier;
|
|
2215
|
+
/**
|
|
2216
|
+
* Get badge display name
|
|
2217
|
+
*/
|
|
2218
|
+
getBadgeName(badge: BadgeType): string;
|
|
2219
|
+
/**
|
|
2220
|
+
* Calculate estimated APY boost from reputation
|
|
2221
|
+
*/
|
|
2222
|
+
calculateApyBoost(score: number): number;
|
|
2223
|
+
/**
|
|
2224
|
+
* Get reputation tier color for UI
|
|
2225
|
+
*/
|
|
2226
|
+
getTierColor(tier: ReputationTier): string;
|
|
2227
|
+
/**
|
|
2228
|
+
* Create default reputation data for new agents
|
|
2229
|
+
*/
|
|
2230
|
+
createDefaultReputationData(agentAddress: Address$1): ReputationData;
|
|
2231
|
+
/**
|
|
2232
|
+
* Check if agent qualifies for a specific tier
|
|
2233
|
+
*/
|
|
2234
|
+
qualifiesForTier(score: number, tier: ReputationTier): boolean;
|
|
2235
|
+
/**
|
|
2236
|
+
* Calculate points needed for next tier
|
|
2237
|
+
*/
|
|
2238
|
+
pointsToNextTier(score: number): {
|
|
2239
|
+
nextTier: ReputationTier;
|
|
2240
|
+
pointsNeeded: number;
|
|
2241
|
+
} | null;
|
|
2242
|
+
/**
|
|
2243
|
+
* Record a PayAI payment event to update reputation
|
|
2244
|
+
*
|
|
2245
|
+
* Converts PayAI webhook data to JobPerformance format and
|
|
2246
|
+
* calculates reputation change.
|
|
2247
|
+
*
|
|
2248
|
+
* @param record - PayAI reputation record from webhook
|
|
2249
|
+
* @param currentData - Current agent reputation data (fetched from on-chain or cache)
|
|
2250
|
+
* @returns Reputation calculation result
|
|
2251
|
+
*/
|
|
2252
|
+
recordPayAIPayment(record: PayAIReputationRecordInput, currentData: ReputationData): ReputationCalculationResult;
|
|
2253
|
+
/**
|
|
2254
|
+
* Convert a PayAI reputation record to JobPerformance format
|
|
2255
|
+
*
|
|
2256
|
+
* PayAI provides basic payment data, so we derive quality metrics
|
|
2257
|
+
* from response time and success status.
|
|
2258
|
+
*/
|
|
2259
|
+
payAIRecordToJobPerformance(record: PayAIReputationRecordInput): JobPerformance;
|
|
2260
|
+
/**
|
|
2261
|
+
* Estimate quality rating from response time
|
|
2262
|
+
*
|
|
2263
|
+
* Fast responses (< 500ms) = 100 quality
|
|
2264
|
+
* Average responses (500ms-2s) = 70-90 quality
|
|
2265
|
+
* Slow responses (2s-10s) = 40-70 quality
|
|
2266
|
+
* Very slow responses (> 10s) = 20-40 quality
|
|
2267
|
+
*/
|
|
2268
|
+
private estimateQualityFromResponseTime;
|
|
2269
|
+
/**
|
|
2270
|
+
* Estimate expected duration based on payment amount
|
|
2271
|
+
*
|
|
2272
|
+
* Larger payments = longer expected processing time
|
|
2273
|
+
*/
|
|
2274
|
+
private estimateExpectedDuration;
|
|
2275
|
+
/**
|
|
2276
|
+
* Categorize payment by network
|
|
2277
|
+
*/
|
|
2278
|
+
private categorizeFromNetwork;
|
|
2279
|
+
/**
|
|
2280
|
+
* Create a PayAI-compatible performance snapshot
|
|
2281
|
+
* Useful for tracking payment patterns
|
|
2282
|
+
*/
|
|
2283
|
+
createPayAIPerformanceSnapshot(record: PayAIReputationRecordInput, reputationResult: ReputationCalculationResult): {
|
|
2284
|
+
timestamp: number;
|
|
2285
|
+
paymentId: string;
|
|
2286
|
+
network: string;
|
|
2287
|
+
amount: string;
|
|
2288
|
+
success: boolean;
|
|
2289
|
+
responseTimeMs: number;
|
|
2290
|
+
reputationChange: number;
|
|
2291
|
+
newScore: number;
|
|
2292
|
+
tier: string;
|
|
2293
|
+
};
|
|
2294
|
+
/**
|
|
2295
|
+
* Calculate tags for an agent based on metrics
|
|
2296
|
+
*
|
|
2297
|
+
* Automatically evaluates all tag criteria and assigns tags
|
|
2298
|
+
* with appropriate confidence scores.
|
|
2299
|
+
*
|
|
2300
|
+
* @param metrics - Agent reputation metrics
|
|
2301
|
+
* @returns Array of tag scores
|
|
2302
|
+
*/
|
|
2303
|
+
calculateTagsForAgent(metrics: ReputationMetrics): Promise<TagScore[]>;
|
|
2304
|
+
/**
|
|
2305
|
+
* Get tags by category
|
|
2306
|
+
*
|
|
2307
|
+
* Filters tags to only those in the specified category.
|
|
2308
|
+
*
|
|
2309
|
+
* @param tags - All tag scores
|
|
2310
|
+
* @param category - Category to filter by
|
|
2311
|
+
* @returns Filtered tag scores
|
|
2312
|
+
*/
|
|
2313
|
+
getTagsByCategory(tags: TagScore[], category: TagCategory): TagScore[];
|
|
2314
|
+
/**
|
|
2315
|
+
* Check if agent has a specific tag
|
|
2316
|
+
*
|
|
2317
|
+
* @param tags - Agent's tag scores
|
|
2318
|
+
* @param tagName - Tag to check for
|
|
2319
|
+
* @returns Whether the tag exists
|
|
2320
|
+
*/
|
|
2321
|
+
hasTag(tags: TagScore[], tagName: string): boolean;
|
|
2322
|
+
/**
|
|
2323
|
+
* Get tag confidence score
|
|
2324
|
+
*
|
|
2325
|
+
* @param tags - Agent's tag scores
|
|
2326
|
+
* @param tagName - Tag to check
|
|
2327
|
+
* @returns Confidence score or undefined if tag doesn't exist
|
|
2328
|
+
*/
|
|
2329
|
+
getTagConfidence(tags: TagScore[], tagName: string): number | undefined;
|
|
2330
|
+
/**
|
|
2331
|
+
* Filter tags by criteria
|
|
2332
|
+
*
|
|
2333
|
+
* @param tags - Tags to filter
|
|
2334
|
+
* @param filters - Filter criteria
|
|
2335
|
+
* @returns Filtered tags
|
|
2336
|
+
*/
|
|
2337
|
+
filterTags(tags: TagScore[], filters: TagFilters): TagScore[];
|
|
2338
|
+
/**
|
|
2339
|
+
* Apply tag decay based on age
|
|
2340
|
+
*
|
|
2341
|
+
* Reduces confidence scores for old tags and removes stale tags.
|
|
2342
|
+
*
|
|
2343
|
+
* @param tags - Current tag scores
|
|
2344
|
+
* @param currentTimestamp - Current Unix timestamp (optional)
|
|
2345
|
+
* @returns Tags with decay applied
|
|
2346
|
+
*/
|
|
2347
|
+
applyTagDecay(tags: TagScore[], currentTimestamp?: number): TagScore[];
|
|
2348
|
+
/**
|
|
2349
|
+
* Merge new tags with existing tags
|
|
2350
|
+
*
|
|
2351
|
+
* Updates existing tags or adds new ones, preferring higher confidence.
|
|
2352
|
+
*
|
|
2353
|
+
* @param existingTags - Current tags
|
|
2354
|
+
* @param newTags - New tags to merge
|
|
2355
|
+
* @returns Merged tag list
|
|
2356
|
+
*/
|
|
2357
|
+
mergeTags(existingTags: TagScore[], newTags: TagScore[]): TagScore[];
|
|
2358
|
+
/**
|
|
2359
|
+
* Categorize tags by type
|
|
2360
|
+
*
|
|
2361
|
+
* Organizes tags into skill, behavior, and compliance categories.
|
|
2362
|
+
*
|
|
2363
|
+
* @param tags - Tags to categorize
|
|
2364
|
+
* @returns Categorized tag result
|
|
2365
|
+
*/
|
|
2366
|
+
categorizeTags(tags: TagScore[]): TagQueryResult;
|
|
2367
|
+
/**
|
|
2368
|
+
* Get top N tags by confidence
|
|
2369
|
+
*
|
|
2370
|
+
* @param tags - Tags to sort
|
|
2371
|
+
* @param count - Number of tags to return
|
|
2372
|
+
* @returns Top tags
|
|
2373
|
+
*/
|
|
2374
|
+
getTopTags(tags: TagScore[], count: number): TagScore[];
|
|
2375
|
+
/**
|
|
2376
|
+
* Sort tags by confidence (descending)
|
|
2377
|
+
*
|
|
2378
|
+
* @param tags - Tags to sort
|
|
2379
|
+
* @returns Sorted tags
|
|
2380
|
+
*/
|
|
2381
|
+
sortTagsByConfidence(tags: TagScore[]): TagScore[];
|
|
2382
|
+
/**
|
|
2383
|
+
* Sort tags by evidence count (descending)
|
|
2384
|
+
*
|
|
2385
|
+
* @param tags - Tags to sort
|
|
2386
|
+
* @returns Sorted tags
|
|
2387
|
+
*/
|
|
2388
|
+
sortTagsByEvidence(tags: TagScore[]): TagScore[];
|
|
2389
|
+
/**
|
|
2390
|
+
* Sort tags by most recently updated
|
|
2391
|
+
*
|
|
2392
|
+
* @param tags - Tags to sort
|
|
2393
|
+
* @returns Sorted tags
|
|
2394
|
+
*/
|
|
2395
|
+
sortTagsByRecent(tags: TagScore[]): TagScore[];
|
|
2396
|
+
/**
|
|
2397
|
+
* Get confidence level description
|
|
2398
|
+
*
|
|
2399
|
+
* @param confidence - Confidence score (0-10000)
|
|
2400
|
+
* @returns Human-readable confidence level
|
|
2401
|
+
*/
|
|
2402
|
+
getConfidenceLevel(confidence: number): string;
|
|
2403
|
+
/**
|
|
2404
|
+
* Validate tag name length
|
|
2405
|
+
*
|
|
2406
|
+
* @param tagName - Tag name to validate
|
|
2407
|
+
* @returns Whether tag name is valid
|
|
2408
|
+
*/
|
|
2409
|
+
validateTagName(tagName: string): boolean;
|
|
2410
|
+
/**
|
|
2411
|
+
* Validate confidence score
|
|
2412
|
+
*
|
|
2413
|
+
* @param confidence - Confidence to validate
|
|
2414
|
+
* @returns Whether confidence is valid (0-10000)
|
|
2415
|
+
*/
|
|
2416
|
+
validateConfidence(confidence: number): boolean;
|
|
2417
|
+
/**
|
|
2418
|
+
* Convert on-chain ReputationMetrics to TagEngine format
|
|
2419
|
+
*
|
|
2420
|
+
* Helper to convert blockchain data to the format needed for tag calculation.
|
|
2421
|
+
*
|
|
2422
|
+
* @param onChainMetrics - Metrics from blockchain
|
|
2423
|
+
* @returns Metrics in TagEngine format
|
|
2424
|
+
*/
|
|
2425
|
+
convertMetricsForTagging(onChainMetrics: {
|
|
2426
|
+
successfulPayments: bigint;
|
|
2427
|
+
failedPayments: bigint;
|
|
2428
|
+
totalResponseTime: bigint;
|
|
2429
|
+
responseTimeCount: bigint;
|
|
2430
|
+
totalDisputes: number;
|
|
2431
|
+
disputesResolved: number;
|
|
2432
|
+
totalRating: number;
|
|
2433
|
+
totalRatingsCount: number;
|
|
2434
|
+
createdAt: number;
|
|
2435
|
+
updatedAt: number;
|
|
2436
|
+
}): ReputationMetrics;
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Interface for PayAI reputation record input
|
|
2440
|
+
* Matches the PayAIReputationRecord from payai module
|
|
2441
|
+
*/
|
|
2442
|
+
interface PayAIReputationRecordInput {
|
|
2443
|
+
agentAddress: Address$1;
|
|
2444
|
+
paymentSignature: string;
|
|
2445
|
+
amount: bigint;
|
|
2446
|
+
success: boolean;
|
|
2447
|
+
responseTimeMs: number;
|
|
2448
|
+
payerAddress: string;
|
|
2449
|
+
timestamp: Date;
|
|
2450
|
+
network: string;
|
|
2451
|
+
}
|
|
2452
|
+
|
|
2453
|
+
interface StakeParams {
|
|
2454
|
+
/** Agent address to stake for */
|
|
2455
|
+
agent: Address$1;
|
|
2456
|
+
/** Agent's token account holding GHOST tokens */
|
|
2457
|
+
agentTokenAccount: Address$1;
|
|
2458
|
+
/** Staking vault to receive tokens */
|
|
2459
|
+
stakingVault: Address$1;
|
|
2460
|
+
/** Global staking config account */
|
|
2461
|
+
stakingConfig: Address$1;
|
|
2462
|
+
/** GHOST token mint address */
|
|
2463
|
+
ghostMint: Address$1;
|
|
2464
|
+
/** Amount of GHOST tokens to stake (in lamports) */
|
|
2465
|
+
amount: bigint;
|
|
2466
|
+
/** Lock duration in seconds */
|
|
2467
|
+
lockDuration: bigint;
|
|
2468
|
+
/** The agent owner's transaction signer */
|
|
2469
|
+
agentOwner: TransactionSigner;
|
|
2470
|
+
}
|
|
2471
|
+
interface UnstakeParams {
|
|
2472
|
+
/** Staking account to unstake from */
|
|
2473
|
+
stakingAccount: Address$1;
|
|
2474
|
+
/** Agent address */
|
|
2475
|
+
agent: Address$1;
|
|
2476
|
+
/** Staking vault holding the tokens */
|
|
2477
|
+
stakingVault: Address$1;
|
|
2478
|
+
/** Agent's token account to receive tokens */
|
|
2479
|
+
agentTokenAccount: Address$1;
|
|
2480
|
+
/** The agent owner's transaction signer */
|
|
2481
|
+
agentOwner: TransactionSigner;
|
|
2482
|
+
}
|
|
2483
|
+
interface InitializeStakingConfigParams {
|
|
2484
|
+
/** Admin who can modify staking config */
|
|
2485
|
+
authority: TransactionSigner;
|
|
2486
|
+
/** Minimum stake amount */
|
|
2487
|
+
minStake: bigint;
|
|
2488
|
+
/** Treasury address to receive fees */
|
|
2489
|
+
treasury: Address$1;
|
|
2490
|
+
}
|
|
2491
|
+
declare class StakingModule extends BaseModule {
|
|
2492
|
+
/**
|
|
2493
|
+
* Initialize the global staking configuration (admin only)
|
|
2494
|
+
*/
|
|
2495
|
+
initializeStakingConfig(params: InitializeStakingConfigParams): Promise<string>;
|
|
2496
|
+
/**
|
|
2497
|
+
* Stake GHOST tokens for an agent
|
|
2498
|
+
*
|
|
2499
|
+
* @param params - Staking parameters
|
|
2500
|
+
* @returns Transaction signature
|
|
2501
|
+
*/
|
|
2502
|
+
stake(params: StakeParams): Promise<string>;
|
|
2503
|
+
/**
|
|
2504
|
+
* Unstake GHOST tokens from an agent
|
|
2505
|
+
*
|
|
2506
|
+
* @param params - Unstaking parameters
|
|
2507
|
+
* @returns Transaction signature
|
|
2508
|
+
*/
|
|
2509
|
+
unstake(params: UnstakeParams): Promise<string>;
|
|
2510
|
+
/**
|
|
2511
|
+
* Get staking account for an agent
|
|
2512
|
+
*
|
|
2513
|
+
* @param stakingAccountAddress - The staking account address
|
|
2514
|
+
* @returns Staking account data or null if not found
|
|
2515
|
+
*/
|
|
2516
|
+
getStakingAccount(stakingAccountAddress: Address$1): Promise<StakingAccount | null>;
|
|
2517
|
+
/**
|
|
2518
|
+
* Get the global staking configuration
|
|
2519
|
+
*
|
|
2520
|
+
* @param stakingConfigAddress - The staking config account address
|
|
2521
|
+
* @returns Staking config data or null if not initialized
|
|
2522
|
+
*/
|
|
2523
|
+
getStakingConfig(stakingConfigAddress: Address$1): Promise<StakingConfig | null>;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
export { type ServiceEndpoint as $, AgentModule as A, BaseModule as B, CacheManager as C, DidModule as D, type ExtendedRpcApi as E, generateDidString as F, type GhostSpeakConfig as G, validateDidString as H, InstructionBuilder as I, parseDidString as J, exportAsW3CDidDocument as K, createEd25519VerificationMethod as L, MultisigModule as M, createServiceEndpoint as N, isDidActive as O, PayAIClient as P, getMethodsForRelationship as Q, ReputationModule as R, StakingModule as S, canPerformAction as T, didDocumentToJson as U, VerificationMethodType as V, type W3CVerifiableCredential as W, getNetworkFromDid as X, getIdentifierFromDid as Y, type DidDocument as Z, type VerificationMethod as _, GovernanceModule as a, type DidResolutionMetadata as a0, type W3CDidDocument as a1, type CreateDidDocumentParams as a2, type UpdateDidDocumentParams as a3, type DeactivateDidDocumentParams as a4, type ResolveDidDocumentParams as a5, type ReputationData as a6, type PayAIReputationRecordInput as a7, createPayAIClient as a8, payAIFetch as a9, type RpcSubscriptionApi as aA, type StakingAccount as aB, type StakingConfig as aC, getAgentDecoder as aD, getStakingAccountDecoder as aE, getStakingConfigDecoder as aF, type Agent as aG, isPaymentRequired as aa, extractPaymentRequirements as ab, type PayAIWebhookEventType as ac, type PayAIPaymentStatus as ad, type PayAIClientConfig as ae, type PayAIPaymentRequirement as af, type PayAIPaymentResponse as ag, type AgentWithAddress as ah, type AgentRegistrationData as ai, type AgentAccount as aj, PricingModel as ak, GhostSpeakError as al, type RegisterAgentParams as am, type RpcResponse as an, type RpcAccountInfo as ao, type RpcProgramAccount as ap, type RpcProgramAccountsResponse as aq, type RpcAccountInfoResponse as ar, type RpcMultipleAccountsResponse as as, type TransactionResponse as at, type SimulatedTransactionResponse as au, type SolanaRpcClient as av, type EmergencyConfig as aw, type Commitment as ax, type RetryConfig as ay, type RpcApi as az, AccessTier as b, GHOSTSPEAK_MARKETPLACE_PROGRAM_ADDRESS as c, type PricingModelArgs as d, type PayAIWebhookHandlerOptions as e, type PayAIWebhookPayload as f, type PayAIWebhookResult as g, type PayAIWebhookVerification as h, type PayAIPaymentData as i, type PayAIReputationRecord as j, type PayAINetwork as k, type PayAIAgentRegistration as l, type CacheConfig as m, type CreateProposalParams as n, type ProposalType as o, type ExecutionParams as p, CredentialModule as q, CredentialKind as r, CredentialStatus as s, type Credential as t, type CredentialTemplate as u, VerificationRelationship as v, ServiceEndpointType as w, DidError as x, DidErrorClass as y, deriveDidDocumentPda as z };
|