@halot/sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +243 -0
- package/dist/auth/actor.d.ts +17 -0
- package/dist/auth/actor.js +33 -0
- package/dist/auth/attestation.d.ts +24 -0
- package/dist/auth/attestation.js +47 -0
- package/dist/client/halot-client.d.ts +37 -0
- package/dist/client/halot-client.js +89 -0
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +5 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +11 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +43 -0
- package/dist/middleware/aggregator-client.d.ts +8 -0
- package/dist/middleware/aggregator-client.js +49 -0
- package/dist/middleware/halot.d.ts +4 -0
- package/dist/middleware/halot.js +142 -0
- package/dist/middleware/index.d.ts +2 -0
- package/dist/middleware/index.js +5 -0
- package/dist/middleware/types.d.ts +45 -0
- package/dist/middleware/types.js +2 -0
- package/dist/types/common.d.ts +90 -0
- package/dist/types/common.js +66 -0
- package/dist/types/job.d.ts +232 -0
- package/dist/types/job.js +125 -0
- package/dist/types/provider.d.ts +160 -0
- package/dist/types/provider.js +45 -0
- package/dist/types/quote.d.ts +43 -0
- package/dist/types/quote.js +31 -0
- package/dist/types/requester.d.ts +15 -0
- package/dist/types/requester.js +15 -0
- package/dist/types/service.d.ts +140 -0
- package/dist/types/service.js +48 -0
- package/dist/types/verifier.d.ts +144 -0
- package/dist/types/verifier.js +78 -0
- package/dist/types/x402.d.ts +31 -0
- package/dist/types/x402.js +27 -0
- package/dist/utils/amount.d.ts +2 -0
- package/dist/utils/amount.js +11 -0
- package/dist/utils/artifacts.d.ts +42 -0
- package/dist/utils/artifacts.js +378 -0
- package/dist/utils/category.d.ts +4 -0
- package/dist/utils/category.js +25 -0
- package/dist/utils/date.d.ts +2 -0
- package/dist/utils/date.js +10 -0
- package/dist/utils/hash.d.ts +4 -0
- package/dist/utils/hash.js +27 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +7 -0
- package/dist/utils/json-file.d.ts +3 -0
- package/dist/utils/json-file.js +20 -0
- package/dist/utils/schema.d.ts +5 -0
- package/dist/utils/schema.js +66 -0
- package/dist/x402/payment.d.ts +11 -0
- package/dist/x402/payment.js +68 -0
- package/dist/zero-g/compute.d.ts +53 -0
- package/dist/zero-g/compute.js +249 -0
- package/dist/zero-g/storage.d.ts +28 -0
- package/dist/zero-g/storage.js +93 -0
- package/package.json +66 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const VerifierConfigSchema: z.ZodObject<{
|
|
3
|
+
verifierId: z.ZodDefault<z.ZodString>;
|
|
4
|
+
displayName: z.ZodString;
|
|
5
|
+
description: z.ZodString;
|
|
6
|
+
identity: z.ZodObject<{
|
|
7
|
+
erc8004TokenId: z.ZodDefault<z.ZodString>;
|
|
8
|
+
agentRegistry: z.ZodDefault<z.ZodString>;
|
|
9
|
+
agentUri: z.ZodDefault<z.ZodString>;
|
|
10
|
+
ownerAddress: z.ZodDefault<z.ZodString>;
|
|
11
|
+
domain: z.ZodString;
|
|
12
|
+
domainType: z.ZodDefault<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
authority: z.ZodObject<{
|
|
15
|
+
path: z.ZodDefault<z.ZodString>;
|
|
16
|
+
actor: z.ZodEnum<{
|
|
17
|
+
"0g:testnet": "0g:testnet";
|
|
18
|
+
"0g:mainnet": "0g:mainnet";
|
|
19
|
+
"stellar:testnet": "stellar:testnet";
|
|
20
|
+
"stellar:mainnet": "stellar:mainnet";
|
|
21
|
+
}>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
settlementWallets: z.ZodObject<{
|
|
24
|
+
'0g:testnet': z.ZodDefault<z.ZodString>;
|
|
25
|
+
'0g:mainnet': z.ZodDefault<z.ZodString>;
|
|
26
|
+
'stellar:testnet': z.ZodDefault<z.ZodString>;
|
|
27
|
+
'stellar:mainnet': z.ZodDefault<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
stake: z.ZodObject<{
|
|
30
|
+
amount: z.ZodString;
|
|
31
|
+
token: z.ZodDefault<z.ZodString>;
|
|
32
|
+
status: z.ZodDefault<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
fees: z.ZodObject<{
|
|
35
|
+
computeBudgetPerJob: z.ZodString;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
export declare const ModelConfigSchema: z.ZodObject<{
|
|
39
|
+
evaluationModel: z.ZodObject<{
|
|
40
|
+
providerAddress: z.ZodDefault<z.ZodString>;
|
|
41
|
+
serviceType: z.ZodDefault<z.ZodString>;
|
|
42
|
+
verifiability: z.ZodDefault<z.ZodString>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
sdk: z.ZodObject<{
|
|
45
|
+
network: z.ZodString;
|
|
46
|
+
rpcUrl: z.ZodOptional<z.ZodString>;
|
|
47
|
+
ledgerContractAddress: z.ZodOptional<z.ZodString>;
|
|
48
|
+
inferenceContractAddress: z.ZodOptional<z.ZodString>;
|
|
49
|
+
fineTuningContractAddress: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
timeout: z.ZodNumber;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
export declare const InferenceTemplateSchema: z.ZodObject<{
|
|
54
|
+
systemPrompt: z.ZodString;
|
|
55
|
+
promptTemplate: z.ZodString;
|
|
56
|
+
outputSchema: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
57
|
+
maxTokens: z.ZodNumber;
|
|
58
|
+
temperature: z.ZodNumber;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
export declare const SpecializationsSchema: z.ZodObject<{
|
|
61
|
+
categories: z.ZodArray<z.ZodEnum<{
|
|
62
|
+
text: "text";
|
|
63
|
+
code: "code";
|
|
64
|
+
image: "image";
|
|
65
|
+
audio: "audio";
|
|
66
|
+
video: "video";
|
|
67
|
+
document: "document";
|
|
68
|
+
tool: "tool";
|
|
69
|
+
workflow: "workflow";
|
|
70
|
+
}>>;
|
|
71
|
+
serviceIds: z.ZodArray<z.ZodString>;
|
|
72
|
+
maxConcurrentJobs: z.ZodNumber;
|
|
73
|
+
minConfidenceThreshold: z.ZodNumber;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export declare const RegisteredVerifierSchema: z.ZodObject<{
|
|
76
|
+
displayName: z.ZodString;
|
|
77
|
+
description: z.ZodString;
|
|
78
|
+
identity: z.ZodObject<{
|
|
79
|
+
erc8004TokenId: z.ZodDefault<z.ZodString>;
|
|
80
|
+
agentRegistry: z.ZodDefault<z.ZodString>;
|
|
81
|
+
agentUri: z.ZodDefault<z.ZodString>;
|
|
82
|
+
ownerAddress: z.ZodDefault<z.ZodString>;
|
|
83
|
+
domain: z.ZodString;
|
|
84
|
+
domainType: z.ZodDefault<z.ZodString>;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
authority: z.ZodObject<{
|
|
87
|
+
path: z.ZodDefault<z.ZodString>;
|
|
88
|
+
actor: z.ZodEnum<{
|
|
89
|
+
"0g:testnet": "0g:testnet";
|
|
90
|
+
"0g:mainnet": "0g:mainnet";
|
|
91
|
+
"stellar:testnet": "stellar:testnet";
|
|
92
|
+
"stellar:mainnet": "stellar:mainnet";
|
|
93
|
+
}>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
settlementWallets: z.ZodObject<{
|
|
96
|
+
'0g:testnet': z.ZodDefault<z.ZodString>;
|
|
97
|
+
'0g:mainnet': z.ZodDefault<z.ZodString>;
|
|
98
|
+
'stellar:testnet': z.ZodDefault<z.ZodString>;
|
|
99
|
+
'stellar:mainnet': z.ZodDefault<z.ZodString>;
|
|
100
|
+
}, z.core.$strip>;
|
|
101
|
+
stake: z.ZodObject<{
|
|
102
|
+
amount: z.ZodString;
|
|
103
|
+
token: z.ZodDefault<z.ZodString>;
|
|
104
|
+
status: z.ZodDefault<z.ZodString>;
|
|
105
|
+
}, z.core.$strip>;
|
|
106
|
+
fees: z.ZodObject<{
|
|
107
|
+
computeBudgetPerJob: z.ZodString;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
verifierId: z.ZodString;
|
|
110
|
+
signingPublicKey: z.ZodString;
|
|
111
|
+
ownerAddress: z.ZodString;
|
|
112
|
+
rootHash: z.ZodString;
|
|
113
|
+
createdAt: z.ZodString;
|
|
114
|
+
updatedAt: z.ZodString;
|
|
115
|
+
specializations: z.ZodObject<{
|
|
116
|
+
categories: z.ZodArray<z.ZodEnum<{
|
|
117
|
+
text: "text";
|
|
118
|
+
code: "code";
|
|
119
|
+
image: "image";
|
|
120
|
+
audio: "audio";
|
|
121
|
+
video: "video";
|
|
122
|
+
document: "document";
|
|
123
|
+
tool: "tool";
|
|
124
|
+
workflow: "workflow";
|
|
125
|
+
}>>;
|
|
126
|
+
serviceIds: z.ZodArray<z.ZodString>;
|
|
127
|
+
maxConcurrentJobs: z.ZodNumber;
|
|
128
|
+
minConfidenceThreshold: z.ZodNumber;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
export declare const VerifierStatsSchema: z.ZodObject<{
|
|
132
|
+
verifierId: z.ZodString;
|
|
133
|
+
totalAssignments: z.ZodNumber;
|
|
134
|
+
completedAttestations: z.ZodNumber;
|
|
135
|
+
approvals: z.ZodNumber;
|
|
136
|
+
rejections: z.ZodNumber;
|
|
137
|
+
totalEarned: z.ZodString;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
export type VerifierConfig = z.infer<typeof VerifierConfigSchema>;
|
|
140
|
+
export type ModelConfig = z.infer<typeof ModelConfigSchema>;
|
|
141
|
+
export type InferenceTemplate = z.infer<typeof InferenceTemplateSchema>;
|
|
142
|
+
export type Specializations = z.infer<typeof SpecializationsSchema>;
|
|
143
|
+
export type RegisteredVerifier = z.infer<typeof RegisteredVerifierSchema>;
|
|
144
|
+
export type VerifierStats = z.infer<typeof VerifierStatsSchema>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerifierStatsSchema = exports.RegisteredVerifierSchema = exports.SpecializationsSchema = exports.InferenceTemplateSchema = exports.ModelConfigSchema = exports.VerifierConfigSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const common_1 = require("./common");
|
|
6
|
+
exports.VerifierConfigSchema = zod_1.z.object({
|
|
7
|
+
verifierId: zod_1.z.string().default(''),
|
|
8
|
+
displayName: zod_1.z.string().min(1),
|
|
9
|
+
description: zod_1.z.string().min(1),
|
|
10
|
+
identity: zod_1.z.object({
|
|
11
|
+
erc8004TokenId: zod_1.z.string().default(''),
|
|
12
|
+
agentRegistry: zod_1.z.string().default(''),
|
|
13
|
+
agentUri: zod_1.z.string().default(''),
|
|
14
|
+
ownerAddress: zod_1.z.string().default(''),
|
|
15
|
+
domain: zod_1.z.string(),
|
|
16
|
+
domainType: zod_1.z.string().default('space-id'),
|
|
17
|
+
}),
|
|
18
|
+
authority: zod_1.z.object({
|
|
19
|
+
path: zod_1.z.string().default('./wallets.json'),
|
|
20
|
+
actor: common_1.SettlementNetworkSchema.refine((value) => value.startsWith('0g:'), {
|
|
21
|
+
message: 'Verifier actor authority must use a 0G authority',
|
|
22
|
+
}),
|
|
23
|
+
}),
|
|
24
|
+
settlementWallets: common_1.SettlementWalletsSchema,
|
|
25
|
+
stake: zod_1.z.object({
|
|
26
|
+
amount: zod_1.z.string(),
|
|
27
|
+
token: zod_1.z.string().default('0G'),
|
|
28
|
+
status: zod_1.z.string().default('unlocked'),
|
|
29
|
+
}),
|
|
30
|
+
fees: zod_1.z.object({
|
|
31
|
+
computeBudgetPerJob: zod_1.z.string(),
|
|
32
|
+
}),
|
|
33
|
+
});
|
|
34
|
+
exports.ModelConfigSchema = zod_1.z.object({
|
|
35
|
+
evaluationModel: zod_1.z.object({
|
|
36
|
+
providerAddress: zod_1.z.string().default(''),
|
|
37
|
+
serviceType: zod_1.z.string().default('chatbot'),
|
|
38
|
+
verifiability: zod_1.z.string().default('TeeML'),
|
|
39
|
+
}),
|
|
40
|
+
sdk: zod_1.z.object({
|
|
41
|
+
network: zod_1.z.string(),
|
|
42
|
+
rpcUrl: zod_1.z.string().optional(),
|
|
43
|
+
ledgerContractAddress: zod_1.z.string().optional(),
|
|
44
|
+
inferenceContractAddress: zod_1.z.string().optional(),
|
|
45
|
+
fineTuningContractAddress: zod_1.z.string().optional(),
|
|
46
|
+
}),
|
|
47
|
+
timeout: zod_1.z.number().int().positive(),
|
|
48
|
+
});
|
|
49
|
+
exports.InferenceTemplateSchema = zod_1.z.object({
|
|
50
|
+
systemPrompt: zod_1.z.string(),
|
|
51
|
+
promptTemplate: zod_1.z.string(),
|
|
52
|
+
outputSchema: zod_1.z.record(zod_1.z.string(), zod_1.z.string()),
|
|
53
|
+
maxTokens: zod_1.z.number().int().positive(),
|
|
54
|
+
temperature: zod_1.z.number(),
|
|
55
|
+
});
|
|
56
|
+
exports.SpecializationsSchema = zod_1.z.object({
|
|
57
|
+
categories: zod_1.z.array(common_1.ServiceCategorySchema).min(1),
|
|
58
|
+
serviceIds: zod_1.z.array(zod_1.z.string()),
|
|
59
|
+
maxConcurrentJobs: zod_1.z.number().int().positive(),
|
|
60
|
+
minConfidenceThreshold: zod_1.z.number().min(0).max(1),
|
|
61
|
+
});
|
|
62
|
+
exports.RegisteredVerifierSchema = exports.VerifierConfigSchema.extend({
|
|
63
|
+
verifierId: zod_1.z.string(),
|
|
64
|
+
signingPublicKey: zod_1.z.string(),
|
|
65
|
+
ownerAddress: zod_1.z.string(),
|
|
66
|
+
rootHash: zod_1.z.string(),
|
|
67
|
+
createdAt: zod_1.z.string(),
|
|
68
|
+
updatedAt: zod_1.z.string(),
|
|
69
|
+
specializations: exports.SpecializationsSchema,
|
|
70
|
+
});
|
|
71
|
+
exports.VerifierStatsSchema = zod_1.z.object({
|
|
72
|
+
verifierId: zod_1.z.string(),
|
|
73
|
+
totalAssignments: zod_1.z.number().int().nonnegative(),
|
|
74
|
+
completedAttestations: zod_1.z.number().int().nonnegative(),
|
|
75
|
+
approvals: zod_1.z.number().int().nonnegative(),
|
|
76
|
+
rejections: zod_1.z.number().int().nonnegative(),
|
|
77
|
+
totalEarned: zod_1.z.string(),
|
|
78
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const PaymentRequirementSchema: z.ZodObject<{
|
|
3
|
+
x402Version: z.ZodLiteral<2>;
|
|
4
|
+
scheme: z.ZodLiteral<"exact">;
|
|
5
|
+
serviceId: z.ZodOptional<z.ZodString>;
|
|
6
|
+
quoteId: z.ZodString;
|
|
7
|
+
accepts: z.ZodArray<z.ZodObject<{
|
|
8
|
+
network: z.ZodString;
|
|
9
|
+
token: z.ZodString;
|
|
10
|
+
amount: z.ZodString;
|
|
11
|
+
payTo: z.ZodString;
|
|
12
|
+
memo: z.ZodString;
|
|
13
|
+
}, z.core.$strip>>;
|
|
14
|
+
expiresAt: z.ZodString;
|
|
15
|
+
resource: z.ZodString;
|
|
16
|
+
description: z.ZodString;
|
|
17
|
+
aggregatorUrl: z.ZodOptional<z.ZodString>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
export declare const PaymentAuthorizationSchema: z.ZodObject<{
|
|
20
|
+
quoteId: z.ZodString;
|
|
21
|
+
network: z.ZodString;
|
|
22
|
+
amount: z.ZodString;
|
|
23
|
+
token: z.ZodString;
|
|
24
|
+
payTo: z.ZodString;
|
|
25
|
+
memo: z.ZodString;
|
|
26
|
+
expiresAt: z.ZodString;
|
|
27
|
+
requesterAddress: z.ZodString;
|
|
28
|
+
signature: z.ZodString;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type PaymentRequirement = z.infer<typeof PaymentRequirementSchema>;
|
|
31
|
+
export type PaymentAuthorization = z.infer<typeof PaymentAuthorizationSchema>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PaymentAuthorizationSchema = exports.PaymentRequirementSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const quote_1 = require("./quote");
|
|
6
|
+
exports.PaymentRequirementSchema = zod_1.z.object({
|
|
7
|
+
x402Version: zod_1.z.literal(2),
|
|
8
|
+
scheme: zod_1.z.literal('exact'),
|
|
9
|
+
serviceId: zod_1.z.string().optional(),
|
|
10
|
+
quoteId: zod_1.z.string(),
|
|
11
|
+
accepts: zod_1.z.array(quote_1.QuoteAcceptOptionSchema).min(1),
|
|
12
|
+
expiresAt: zod_1.z.string(),
|
|
13
|
+
resource: zod_1.z.string(),
|
|
14
|
+
description: zod_1.z.string(),
|
|
15
|
+
aggregatorUrl: zod_1.z.string().optional(),
|
|
16
|
+
});
|
|
17
|
+
exports.PaymentAuthorizationSchema = zod_1.z.object({
|
|
18
|
+
quoteId: zod_1.z.string(),
|
|
19
|
+
network: zod_1.z.string(),
|
|
20
|
+
amount: zod_1.z.string(),
|
|
21
|
+
token: zod_1.z.string(),
|
|
22
|
+
payTo: zod_1.z.string(),
|
|
23
|
+
memo: zod_1.z.string(),
|
|
24
|
+
expiresAt: zod_1.z.string(),
|
|
25
|
+
requesterAddress: zod_1.z.string(),
|
|
26
|
+
signature: zod_1.z.string(),
|
|
27
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decimalToUnits = decimalToUnits;
|
|
4
|
+
exports.unitsToDecimal = unitsToDecimal;
|
|
5
|
+
const ethers_1 = require("ethers");
|
|
6
|
+
function decimalToUnits(amount, decimals) {
|
|
7
|
+
return (0, ethers_1.parseUnits)(amount, decimals).toString();
|
|
8
|
+
}
|
|
9
|
+
function unitsToDecimal(amount, decimals) {
|
|
10
|
+
return (0, ethers_1.formatUnits)(amount, decimals);
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type ArtifactOrigin = 'input' | 'result';
|
|
2
|
+
export type ArtifactFetch = typeof fetch;
|
|
3
|
+
export type ImageArtifactCandidate = {
|
|
4
|
+
origin: ArtifactOrigin;
|
|
5
|
+
path: string;
|
|
6
|
+
url: string;
|
|
7
|
+
mimeType?: string;
|
|
8
|
+
sha256?: string;
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
};
|
|
12
|
+
export type ResolvedImageArtifact = {
|
|
13
|
+
origin: ArtifactOrigin;
|
|
14
|
+
path: string;
|
|
15
|
+
url: string;
|
|
16
|
+
mimeType: string;
|
|
17
|
+
sha256: string;
|
|
18
|
+
byteLength: number;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
dataUrl: string;
|
|
22
|
+
};
|
|
23
|
+
export type ArtifactResolutionFailure = {
|
|
24
|
+
origin: ArtifactOrigin;
|
|
25
|
+
path: string;
|
|
26
|
+
url: string;
|
|
27
|
+
errors: string[];
|
|
28
|
+
};
|
|
29
|
+
export type ArtifactInspection = {
|
|
30
|
+
inputImages: ResolvedImageArtifact[];
|
|
31
|
+
resultImages: ResolvedImageArtifact[];
|
|
32
|
+
issues: string[];
|
|
33
|
+
};
|
|
34
|
+
type ArtifactResolutionOptions = {
|
|
35
|
+
fetchImplementation?: ArtifactFetch;
|
|
36
|
+
maxImageBytes?: number;
|
|
37
|
+
maxImagesPerOrigin?: number;
|
|
38
|
+
outputFormat?: string;
|
|
39
|
+
};
|
|
40
|
+
export declare function resolveImageArtifacts(input: unknown, result: unknown, options?: ArtifactResolutionOptions): Promise<ArtifactInspection>;
|
|
41
|
+
export declare function buildArtifactSummary(artifacts: ResolvedImageArtifact[]): string;
|
|
42
|
+
export {};
|