@pulseai/sdk 0.1.0 → 0.1.1
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/dist/index.d.ts +69 -4
- package/dist/index.js +594 -41
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ type PulseAddresses = {
|
|
|
12
12
|
};
|
|
13
13
|
/** Full Pulse contract addresses on MegaETH Testnet. */
|
|
14
14
|
declare const TESTNET_ADDRESSES: PulseAddresses;
|
|
15
|
-
/** Full Pulse contract addresses on MegaETH Mainnet
|
|
15
|
+
/** Full Pulse contract addresses on MegaETH Mainnet. */
|
|
16
16
|
declare const MAINNET_ADDRESSES: PulseAddresses;
|
|
17
17
|
/** Default indexer URLs by network. */
|
|
18
18
|
declare const DEFAULT_INDEXER_URLS: {
|
|
@@ -171,8 +171,12 @@ declare function createJob(client: PulseClient, params: CreateJobParams): Promis
|
|
|
171
171
|
* Accept a job as provider: generate EIP-712 signature + call acceptJob.
|
|
172
172
|
*/
|
|
173
173
|
declare function acceptJob(client: PulseClient, jobId: bigint, warrenTermsHash: Hex): Promise<Hash>;
|
|
174
|
-
/** Submit a deliverable hash for an in-progress job.
|
|
175
|
-
|
|
174
|
+
/** Submit a deliverable hash for an in-progress job.
|
|
175
|
+
* Optionally store the deliverable content in the indexer. */
|
|
176
|
+
declare function submitDeliverable(client: PulseClient, jobId: bigint, deliverableHash: Hex, options?: {
|
|
177
|
+
content?: string;
|
|
178
|
+
indexerUrl?: string;
|
|
179
|
+
}): Promise<Hash>;
|
|
176
180
|
/** Evaluate a delivered job. */
|
|
177
181
|
declare function evaluate(client: PulseClient, jobId: bigint, approved: boolean, feedback: string): Promise<Hash>;
|
|
178
182
|
/** Settle an evaluated (or auto-approved) job. */
|
|
@@ -183,6 +187,10 @@ declare function cancelJob(client: PulseClient, jobId: bigint): Promise<Hash>;
|
|
|
183
187
|
declare function getJob(client: PulseClient, jobId: bigint): Promise<Job>;
|
|
184
188
|
/** Get the total number of jobs. */
|
|
185
189
|
declare function getJobCount(client: PulseClient): Promise<bigint>;
|
|
190
|
+
/** Reject a delivered job (raises dispute). */
|
|
191
|
+
declare function rejectJob(client: PulseClient, jobId: bigint, feedback: string): Promise<Hash>;
|
|
192
|
+
/** Resolve a dispute (owner only). */
|
|
193
|
+
declare function resolveDispute(client: PulseClient, jobId: bigint, favorBuyer: boolean): Promise<Hash>;
|
|
186
194
|
|
|
187
195
|
/** Deploy raw content to a SSTORE2 Page contract. */
|
|
188
196
|
declare function deployWarrenPage(client: PulseClient, content: string): Promise<{
|
|
@@ -318,6 +326,7 @@ type JobContext = {
|
|
|
318
326
|
priceUsdm: string;
|
|
319
327
|
slaMinutes: number;
|
|
320
328
|
requirements?: Record<string, unknown>;
|
|
329
|
+
abortSignal?: AbortSignal;
|
|
321
330
|
};
|
|
322
331
|
type ExecuteJobResult = {
|
|
323
332
|
type: 'inline' | 'url';
|
|
@@ -336,6 +345,28 @@ interface OfferingHandler {
|
|
|
336
345
|
executeJob(context: JobContext): Promise<ExecuteJobResult>;
|
|
337
346
|
}
|
|
338
347
|
|
|
348
|
+
type SiteModifierConfig = {
|
|
349
|
+
defaultProvider?: 'anthropic' | 'google' | 'openai';
|
|
350
|
+
defaultModel?: string;
|
|
351
|
+
maxTokens?: number;
|
|
352
|
+
systemPrompt?: string;
|
|
353
|
+
indexerUrl: string;
|
|
354
|
+
getApiKey: (provider: string) => Promise<string | null>;
|
|
355
|
+
allowedDomains?: string[];
|
|
356
|
+
};
|
|
357
|
+
declare class SiteModifierHandler implements OfferingHandler {
|
|
358
|
+
readonly offeringId: number;
|
|
359
|
+
readonly autoAccept?: boolean;
|
|
360
|
+
private readonly config;
|
|
361
|
+
constructor(offeringId: number, config: SiteModifierConfig, options?: {
|
|
362
|
+
autoAccept?: boolean;
|
|
363
|
+
});
|
|
364
|
+
validateRequirements(context: JobContext): Promise<ValidationResult>;
|
|
365
|
+
executeJob(context: JobContext): Promise<ExecuteJobResult>;
|
|
366
|
+
private parseRequirements;
|
|
367
|
+
private fetchHtmlWithTimeout;
|
|
368
|
+
}
|
|
369
|
+
|
|
339
370
|
/**
|
|
340
371
|
* EIP-712 type definition matching MemoLib.sol MEMO_TYPEHASH:
|
|
341
372
|
* "Memo(uint256 jobId,address signer,bytes32 contentHash,uint64 timestamp,uint256 nonce)"
|
|
@@ -495,6 +526,27 @@ declare const megaethMainnet: {
|
|
|
495
526
|
verifyHash?: ((client: viem.Client, parameters: viem.VerifyHashActionParameters) => Promise<viem.VerifyHashActionReturnType>) | undefined;
|
|
496
527
|
};
|
|
497
528
|
|
|
529
|
+
type AIProvider = 'anthropic' | 'google' | 'openai';
|
|
530
|
+
type AIMessage = {
|
|
531
|
+
role: 'system' | 'user' | 'assistant';
|
|
532
|
+
content: string;
|
|
533
|
+
};
|
|
534
|
+
type CallAIParams = {
|
|
535
|
+
provider: AIProvider;
|
|
536
|
+
model: string;
|
|
537
|
+
apiKey: string;
|
|
538
|
+
messages: AIMessage[];
|
|
539
|
+
maxTokens?: number;
|
|
540
|
+
signal?: AbortSignal;
|
|
541
|
+
};
|
|
542
|
+
type CallAIResult = {
|
|
543
|
+
content: string;
|
|
544
|
+
raw: unknown;
|
|
545
|
+
};
|
|
546
|
+
type AICallOptions = CallAIParams;
|
|
547
|
+
type AICallResult = CallAIResult;
|
|
548
|
+
declare function callAI(params: CallAIParams): Promise<CallAIResult>;
|
|
549
|
+
|
|
498
550
|
type IndexerClientOptions = {
|
|
499
551
|
baseUrl: string;
|
|
500
552
|
timeoutMs?: number;
|
|
@@ -577,6 +629,11 @@ declare class IndexerClient {
|
|
|
577
629
|
getAgent(agentId: number): Promise<IndexerAgent>;
|
|
578
630
|
registerWarrenLink(jobId: number, linkType: string, masterAddress: string, contentHash: string): Promise<void>;
|
|
579
631
|
getWarrenLinks(jobId: number): Promise<IndexerWarrenLinks>;
|
|
632
|
+
postDeliverable(jobId: number, content: string, contentHash: string, storageType?: string): Promise<void>;
|
|
633
|
+
getDeliverable(jobId: number): Promise<{
|
|
634
|
+
content: string;
|
|
635
|
+
storageType: string;
|
|
636
|
+
} | null>;
|
|
580
637
|
private request;
|
|
581
638
|
private requestJson;
|
|
582
639
|
private parseResponse;
|
|
@@ -646,6 +703,7 @@ declare class BuyerRuntime {
|
|
|
646
703
|
type HandlerProviderRuntimeOptions = {
|
|
647
704
|
pollInterval?: number;
|
|
648
705
|
indexerUrl: string;
|
|
706
|
+
executionTimeoutMs?: number;
|
|
649
707
|
};
|
|
650
708
|
declare class HandlerProviderRuntime {
|
|
651
709
|
private client;
|
|
@@ -654,8 +712,11 @@ declare class HandlerProviderRuntime {
|
|
|
654
712
|
private indexer;
|
|
655
713
|
private indexerUrl;
|
|
656
714
|
private pollInterval;
|
|
715
|
+
private executionTimeoutMs;
|
|
657
716
|
private running;
|
|
658
717
|
private processedJobs;
|
|
718
|
+
private failedJobs;
|
|
719
|
+
private readonly maxRetries;
|
|
659
720
|
private onError?;
|
|
660
721
|
constructor(client: PulseClient, agentId: bigint, options: HandlerProviderRuntimeOptions);
|
|
661
722
|
registerHandler(handler: OfferingHandler): void;
|
|
@@ -665,6 +726,10 @@ declare class HandlerProviderRuntime {
|
|
|
665
726
|
private poll;
|
|
666
727
|
private checkNewJobs;
|
|
667
728
|
private checkInProgressJobs;
|
|
729
|
+
private canProcess;
|
|
730
|
+
private markProcessed;
|
|
731
|
+
private markFailed;
|
|
732
|
+
private getRemainingSlaMs;
|
|
668
733
|
}
|
|
669
734
|
|
|
670
735
|
declare const pulseExtensionAbi: readonly [{
|
|
@@ -3158,4 +3223,4 @@ declare const masterAbi: readonly [{
|
|
|
3158
3223
|
readonly anonymous: false;
|
|
3159
3224
|
}];
|
|
3160
3225
|
|
|
3161
|
-
export { ACCEPT_TIMEOUT, type AgentCardParams, BPS_DENOMINATOR, type BuyerCallbacks, BuyerRuntime, type BuyerRuntimeOptions, type CreateJobParams, type CreatePresetPulseClientOptions, type CreatePulseClientOptions, DEFAULT_INDEXER_URLS, type DeliverableData, type DeliverableParams, EVALUATION_TIMEOUT, type ExecuteJobResult, FEE_BPS, HandlerProviderRuntime, type HandlerProviderRuntimeOptions, type IndexerAgent, IndexerClient, IndexerClientError, type IndexerClientOptions, type IndexerJob, type IndexerJobsFilter, type IndexerOffering, type IndexerOfferingsFilter, type IndexerWarrenLink, type IndexerWarrenLinks, type Job, type JobContext, type JobOffering, JobStatus, type JobTermsParams, type ListOfferingParams, MAINNET_ADDRESSES, MEMO_TYPES, type OfferingHandler, PULSE_DOMAIN, type PresetPulseClient, type ProviderCallbacks, ProviderRuntime, type ProviderRuntimeOptions, type PulseAddresses, type PulseAgentData, type PulseClient, RISK_POOL_BPS, type RequirementsData, type RequirementsParams, ServiceType, type SignMemoParams, TESTNET_ADDRESSES, TREASURY_BPS, USDM_MAINNET, type ValidationResult, acceptJob, activateOffering, cancelJob, createAgentCard, createDeliverable, createJob, createJobTerms, createMainnetClient, createPulseClient, createRequirements, createTestnetClient, deactivateOffering, deployAgentCard, deployDeliverable, deployJobTerms, deployRequirements, deployWarrenMaster, deployWarrenPage, erc20Abi, erc8004IdentityAbi, erc8004ReputationAbi, evaluate, feeDistributorAbi, formatUsdm, getAgent, getJob, getJobCount, getOffering, getOfferingCount, initAgent, jobEngineAbi, listOffering, mainnetERC8004, masterAbi, megaethMainnet, megaethTestnet, pageAbi, parseUsdm, pulseExtensionAbi, readDeliverable, readRequirements, readWarrenMaster, readWarrenPage, registerAgent, serviceMarketplaceAbi, setOperator, setWarrenContract, settle, signMemo, submitDeliverable, testnetERC8004, updateOffering, verifyContentHash };
|
|
3226
|
+
export { ACCEPT_TIMEOUT, type AICallOptions, type AICallResult, type AIMessage, type AIProvider, type AgentCardParams, BPS_DENOMINATOR, type BuyerCallbacks, BuyerRuntime, type BuyerRuntimeOptions, type CreateJobParams, type CreatePresetPulseClientOptions, type CreatePulseClientOptions, DEFAULT_INDEXER_URLS, type DeliverableData, type DeliverableParams, EVALUATION_TIMEOUT, type ExecuteJobResult, FEE_BPS, HandlerProviderRuntime, type HandlerProviderRuntimeOptions, type IndexerAgent, IndexerClient, IndexerClientError, type IndexerClientOptions, type IndexerJob, type IndexerJobsFilter, type IndexerOffering, type IndexerOfferingsFilter, type IndexerWarrenLink, type IndexerWarrenLinks, type Job, type JobContext, type JobOffering, JobStatus, type JobTermsParams, type ListOfferingParams, MAINNET_ADDRESSES, MEMO_TYPES, type OfferingHandler, PULSE_DOMAIN, type PresetPulseClient, type ProviderCallbacks, ProviderRuntime, type ProviderRuntimeOptions, type PulseAddresses, type PulseAgentData, type PulseClient, RISK_POOL_BPS, type RequirementsData, type RequirementsParams, ServiceType, type SignMemoParams, type SiteModifierConfig, SiteModifierHandler, TESTNET_ADDRESSES, TREASURY_BPS, USDM_MAINNET, type ValidationResult, acceptJob, activateOffering, callAI, cancelJob, createAgentCard, createDeliverable, createJob, createJobTerms, createMainnetClient, createPulseClient, createRequirements, createTestnetClient, deactivateOffering, deployAgentCard, deployDeliverable, deployJobTerms, deployRequirements, deployWarrenMaster, deployWarrenPage, erc20Abi, erc8004IdentityAbi, erc8004ReputationAbi, evaluate, feeDistributorAbi, formatUsdm, getAgent, getJob, getJobCount, getOffering, getOfferingCount, initAgent, jobEngineAbi, listOffering, mainnetERC8004, masterAbi, megaethMainnet, megaethTestnet, pageAbi, parseUsdm, pulseExtensionAbi, readDeliverable, readRequirements, readWarrenMaster, readWarrenPage, registerAgent, rejectJob, resolveDispute, serviceMarketplaceAbi, setOperator, setWarrenContract, settle, signMemo, submitDeliverable, testnetERC8004, updateOffering, verifyContentHash };
|