@halot/sdk 1.0.2 → 1.0.3

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 CHANGED
@@ -45,7 +45,7 @@ against the Halot facilitator endpoints.
45
45
 
46
46
  ### Before you use it
47
47
 
48
- The route must use a real registered `serviceId`.
48
+ The route must use a real registered `serviceId` and provider-signed report headers.
49
49
 
50
50
  The actual order is:
51
51
 
@@ -59,18 +59,37 @@ If you are using middleware for a service, you do not need `halot provider run`
59
59
 
60
60
  ```ts
61
61
  import express from 'express';
62
- import { halot } from '@halot/sdk';
62
+ import { Wallet } from 'ethers';
63
+ import { createActorAuthHeaders, halot, nowIso } from '@halot/sdk';
63
64
 
64
65
  const app = express();
65
66
  app.use(express.json());
66
67
 
68
+ const providerId = process.env.HALOT_PROVIDER_ID!;
69
+ const providerWallet = new Wallet(process.env.HALOT_PROVIDER_PRIVATE_KEY!);
70
+
71
+ const providerHeaders = async (_req, context) => {
72
+ if (context.providerId !== providerId) {
73
+ throw new Error(`Assigned provider ${context.providerId} does not match configured provider ${providerId}`);
74
+ }
75
+
76
+ return createActorAuthHeaders(providerWallet, {
77
+ actorId: providerId,
78
+ role: 'provider',
79
+ method: 'POST',
80
+ path: '/facilitator/report',
81
+ timestamp: nowIso(),
82
+ });
83
+ };
84
+
67
85
  app.post('/text', halot({
68
86
  serviceId: 'svc_text_gpt54',
87
+ providerHeaders,
69
88
  }), async (req, res) => {
70
- const { jobId, providerId, requesterAddress } = req.halot;
89
+ const { jobId, providerId: assignedProviderId, requesterAddress } = req.halot;
71
90
  const text = await runProviderLogic(req.body.message, {
72
91
  jobId,
73
- providerId,
92
+ providerId: assignedProviderId,
74
93
  requesterAddress,
75
94
  });
76
95
 
@@ -78,6 +97,8 @@ app.post('/text', halot({
78
97
  });
79
98
  ```
80
99
 
100
+ `HALOT_PROVIDER_ID` is the provider ID returned by provider registration. `HALOT_PROVIDER_PRIVATE_KEY` is the private key for that provider actor authority. You can load those values from a secret manager or the CLI-generated authority file instead of env; the important part is that `/facilitator/report` is signed by the same provider actor that owns the registered service.
101
+
81
102
  ### One route, multiple services
82
103
 
83
104
  If one route fronts multiple registered services, resolve `serviceId` from the request:
@@ -90,47 +111,19 @@ app.post('/text', halot({
90
111
  return 'svc_text_gpt54';
91
112
  case 'gpt-5.4-mini':
92
113
  return 'svc_text_gpt54mini';
114
+ case 'gpt-5.4-nano':
115
+ return 'svc_text_gpt54nano';
93
116
  default:
94
117
  throw new Error('Unsupported model');
95
118
  }
96
119
  },
120
+ providerHeaders,
97
121
  }), async (req, res) => {
98
122
  const text = await runProviderLogic(req.body.message);
99
123
  res.json({ text, model: req.body.model });
100
124
  });
101
125
  ```
102
126
 
103
- ### Signing facilitator report requests
104
-
105
- Use `providerHeaders` when your provider app needs to sign `/facilitator/report` as the registered provider:
106
-
107
- ```ts
108
- import express from 'express';
109
- import { createActorAuthHeaders, halot } from '@halot/sdk';
110
-
111
- const app = express();
112
- app.use(express.json());
113
-
114
- const providerWallet = {
115
- address: process.env.PROVIDER_ADDRESS!,
116
- signMessage: async (message: string) => signWithWallet(message),
117
- };
118
-
119
- app.post('/text', halot({
120
- serviceId: 'svc_text_gpt54',
121
- providerHeaders: async (_req, context) => createActorAuthHeaders(providerWallet, {
122
- actorId: context.providerId,
123
- role: 'provider',
124
- method: 'POST',
125
- path: '/facilitator/report',
126
- timestamp: new Date().toISOString(),
127
- }),
128
- }), async (req, res) => {
129
- const text = await runProviderLogic(req.body.message);
130
- res.json({ text });
131
- });
132
- ```
133
-
134
127
  ### Middleware flow
135
128
 
136
129
  When a requester calls your middleware route:
@@ -35,12 +35,31 @@ export declare const VerifierConfigSchema: z.ZodObject<{
35
35
  computeBudgetPerJob: z.ZodString;
36
36
  }, z.core.$strip>;
37
37
  }, z.core.$strip>;
38
+ export declare const EvaluationModelConfigSchema: z.ZodPipe<z.ZodObject<{
39
+ zeroGComputeProviderAddress: z.ZodOptional<z.ZodString>;
40
+ providerAddress: z.ZodOptional<z.ZodString>;
41
+ model: z.ZodOptional<z.ZodString>;
42
+ }, z.core.$strip>, z.ZodTransform<{
43
+ model?: string | undefined;
44
+ zeroGComputeProviderAddress: string;
45
+ }, {
46
+ zeroGComputeProviderAddress?: string | undefined;
47
+ providerAddress?: string | undefined;
48
+ model?: string | undefined;
49
+ }>>;
38
50
  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>;
51
+ evaluationModel: z.ZodPipe<z.ZodObject<{
52
+ zeroGComputeProviderAddress: z.ZodOptional<z.ZodString>;
53
+ providerAddress: z.ZodOptional<z.ZodString>;
54
+ model: z.ZodOptional<z.ZodString>;
55
+ }, z.core.$strip>, z.ZodTransform<{
56
+ model?: string | undefined;
57
+ zeroGComputeProviderAddress: string;
58
+ }, {
59
+ zeroGComputeProviderAddress?: string | undefined;
60
+ providerAddress?: string | undefined;
61
+ model?: string | undefined;
62
+ }>>;
44
63
  sdk: z.ZodObject<{
45
64
  network: z.ZodString;
46
65
  rpcUrl: z.ZodOptional<z.ZodString>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VerifierStatsSchema = exports.RegisteredVerifierSchema = exports.SpecializationsSchema = exports.InferenceTemplateSchema = exports.ModelConfigSchema = exports.VerifierConfigSchema = void 0;
3
+ exports.VerifierStatsSchema = exports.RegisteredVerifierSchema = exports.SpecializationsSchema = exports.InferenceTemplateSchema = exports.ModelConfigSchema = exports.EvaluationModelConfigSchema = exports.VerifierConfigSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const common_1 = require("./common");
6
6
  exports.VerifierConfigSchema = zod_1.z.object({
@@ -31,12 +31,16 @@ exports.VerifierConfigSchema = zod_1.z.object({
31
31
  computeBudgetPerJob: zod_1.z.string(),
32
32
  }),
33
33
  });
34
+ exports.EvaluationModelConfigSchema = zod_1.z.object({
35
+ zeroGComputeProviderAddress: zod_1.z.string().optional(),
36
+ providerAddress: zod_1.z.string().optional(),
37
+ model: zod_1.z.string().optional(),
38
+ }).transform((config) => ({
39
+ zeroGComputeProviderAddress: config.zeroGComputeProviderAddress ?? config.providerAddress ?? '',
40
+ ...(config.model && config.model.trim() ? { model: config.model.trim() } : {}),
41
+ }));
34
42
  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
- }),
43
+ evaluationModel: exports.EvaluationModelConfigSchema,
40
44
  sdk: zod_1.z.object({
41
45
  network: zod_1.z.string(),
42
46
  rpcUrl: zod_1.z.string().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@halot/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Shared Halot protocol SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",