@jinn-network/sdk 0.1.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.
@@ -0,0 +1,223 @@
1
+ import { z } from 'zod';
2
+ export declare const PredictionV1RestorationPayloadSchema: z.ZodObject<{
3
+ probabilityYes: z.ZodString;
4
+ submittedAt: z.ZodString;
5
+ format: z.ZodLiteral<"decimal">;
6
+ modelId: z.ZodString;
7
+ confidence: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
8
+ methodology: z.ZodOptional<z.ZodString>;
9
+ evidenceCids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
10
+ reasoningCid: z.ZodOptional<z.ZodString>;
11
+ sourceRefs: z.ZodOptional<z.ZodArray<z.ZodObject<{
12
+ title: z.ZodString;
13
+ url: z.ZodString;
14
+ }, "strip", z.ZodTypeAny, {
15
+ url: string;
16
+ title: string;
17
+ }, {
18
+ url: string;
19
+ title: string;
20
+ }>, "many">>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ probabilityYes: string;
23
+ submittedAt: string;
24
+ format: "decimal";
25
+ modelId: string;
26
+ confidence?: "low" | "medium" | "high" | undefined;
27
+ methodology?: string | undefined;
28
+ evidenceCids?: string[] | undefined;
29
+ reasoningCid?: string | undefined;
30
+ sourceRefs?: {
31
+ url: string;
32
+ title: string;
33
+ }[] | undefined;
34
+ }, {
35
+ probabilityYes: string;
36
+ submittedAt: string;
37
+ format: "decimal";
38
+ modelId: string;
39
+ confidence?: "low" | "medium" | "high" | undefined;
40
+ methodology?: string | undefined;
41
+ evidenceCids?: string[] | undefined;
42
+ reasoningCid?: string | undefined;
43
+ sourceRefs?: {
44
+ url: string;
45
+ title: string;
46
+ }[] | undefined;
47
+ }>;
48
+ export type PredictionV1RestorationPayload = z.infer<typeof PredictionV1RestorationPayloadSchema>;
49
+ export declare const PredictionV1VerdictPayloadSchema: z.ZodObject<{
50
+ verdict: z.ZodEnum<["SCORED", "REJECTED", "INVALID", "INDETERMINATE"]>;
51
+ outcome: z.ZodOptional<z.ZodEnum<["YES", "NO", "INVALID"]>>;
52
+ resolvedAt: z.ZodOptional<z.ZodString>;
53
+ resolutionSource: z.ZodObject<{
54
+ venue: z.ZodLiteral<"polymarket">;
55
+ url: z.ZodString;
56
+ marketId: z.ZodString;
57
+ conditionId: z.ZodString;
58
+ }, "strip", z.ZodTypeAny, {
59
+ venue: "polymarket";
60
+ url: string;
61
+ marketId: string;
62
+ conditionId: string;
63
+ }, {
64
+ venue: "polymarket";
65
+ url: string;
66
+ marketId: string;
67
+ conditionId: string;
68
+ }>;
69
+ task: z.ZodObject<{
70
+ cid: z.ZodString;
71
+ id: z.ZodString;
72
+ }, "strip", z.ZodTypeAny, {
73
+ cid: string;
74
+ id: string;
75
+ }, {
76
+ cid: string;
77
+ id: string;
78
+ }>;
79
+ solutionEnvelope: z.ZodObject<{
80
+ cid: z.ZodString;
81
+ sha256: z.ZodString;
82
+ }, "strip", z.ZodTypeAny, {
83
+ cid: string;
84
+ sha256: string;
85
+ }, {
86
+ cid: string;
87
+ sha256: string;
88
+ }>;
89
+ claimed: z.ZodOptional<z.ZodObject<{
90
+ probabilityYes: z.ZodString;
91
+ submittedAt: z.ZodString;
92
+ modelId: z.ZodString;
93
+ }, "strip", z.ZodTypeAny, {
94
+ probabilityYes: string;
95
+ submittedAt: string;
96
+ modelId: string;
97
+ }, {
98
+ probabilityYes: string;
99
+ submittedAt: string;
100
+ modelId: string;
101
+ }>>;
102
+ benchmark: z.ZodObject<{
103
+ probabilityYes: z.ZodString;
104
+ sampledAt: z.ZodString;
105
+ method: z.ZodLiteral<"best-bid-ask-midpoint">;
106
+ }, "strip", z.ZodTypeAny, {
107
+ sampledAt: string;
108
+ probabilityYes: string;
109
+ method: "best-bid-ask-midpoint";
110
+ }, {
111
+ sampledAt: string;
112
+ probabilityYes: string;
113
+ method: "best-bid-ask-midpoint";
114
+ }>;
115
+ scores: z.ZodOptional<z.ZodObject<{
116
+ scoreBasis: z.ZodLiteral<"brier-loss.v1">;
117
+ solverBrier: z.ZodString;
118
+ consensusBrier: z.ZodString;
119
+ brierSpread: z.ZodString;
120
+ }, "strip", z.ZodTypeAny, {
121
+ scoreBasis: "brier-loss.v1";
122
+ solverBrier: string;
123
+ consensusBrier: string;
124
+ brierSpread: string;
125
+ }, {
126
+ scoreBasis: "brier-loss.v1";
127
+ solverBrier: string;
128
+ consensusBrier: string;
129
+ brierSpread: string;
130
+ }>>;
131
+ checks: z.ZodArray<z.ZodObject<{
132
+ name: z.ZodString;
133
+ status: z.ZodEnum<["PASS", "FAIL", "SKIP", "INDETERMINATE"]>;
134
+ detail: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>]>>;
135
+ }, "strip", z.ZodTypeAny, {
136
+ status: "PASS" | "FAIL" | "SKIP" | "INDETERMINATE";
137
+ name: string;
138
+ detail?: string | Record<string, unknown> | undefined;
139
+ }, {
140
+ status: "PASS" | "FAIL" | "SKIP" | "INDETERMINATE";
141
+ name: string;
142
+ detail?: string | Record<string, unknown> | undefined;
143
+ }>, "many">;
144
+ }, "strip", z.ZodTypeAny, {
145
+ verdict: "INDETERMINATE" | "SCORED" | "REJECTED" | "INVALID";
146
+ resolutionSource: {
147
+ venue: "polymarket";
148
+ url: string;
149
+ marketId: string;
150
+ conditionId: string;
151
+ };
152
+ task: {
153
+ cid: string;
154
+ id: string;
155
+ };
156
+ solutionEnvelope: {
157
+ cid: string;
158
+ sha256: string;
159
+ };
160
+ benchmark: {
161
+ sampledAt: string;
162
+ probabilityYes: string;
163
+ method: "best-bid-ask-midpoint";
164
+ };
165
+ checks: {
166
+ status: "PASS" | "FAIL" | "SKIP" | "INDETERMINATE";
167
+ name: string;
168
+ detail?: string | Record<string, unknown> | undefined;
169
+ }[];
170
+ outcome?: "YES" | "NO" | "INVALID" | undefined;
171
+ resolvedAt?: string | undefined;
172
+ claimed?: {
173
+ probabilityYes: string;
174
+ submittedAt: string;
175
+ modelId: string;
176
+ } | undefined;
177
+ scores?: {
178
+ scoreBasis: "brier-loss.v1";
179
+ solverBrier: string;
180
+ consensusBrier: string;
181
+ brierSpread: string;
182
+ } | undefined;
183
+ }, {
184
+ verdict: "INDETERMINATE" | "SCORED" | "REJECTED" | "INVALID";
185
+ resolutionSource: {
186
+ venue: "polymarket";
187
+ url: string;
188
+ marketId: string;
189
+ conditionId: string;
190
+ };
191
+ task: {
192
+ cid: string;
193
+ id: string;
194
+ };
195
+ solutionEnvelope: {
196
+ cid: string;
197
+ sha256: string;
198
+ };
199
+ benchmark: {
200
+ sampledAt: string;
201
+ probabilityYes: string;
202
+ method: "best-bid-ask-midpoint";
203
+ };
204
+ checks: {
205
+ status: "PASS" | "FAIL" | "SKIP" | "INDETERMINATE";
206
+ name: string;
207
+ detail?: string | Record<string, unknown> | undefined;
208
+ }[];
209
+ outcome?: "YES" | "NO" | "INVALID" | undefined;
210
+ resolvedAt?: string | undefined;
211
+ claimed?: {
212
+ probabilityYes: string;
213
+ submittedAt: string;
214
+ modelId: string;
215
+ } | undefined;
216
+ scores?: {
217
+ scoreBasis: "brier-loss.v1";
218
+ solverBrier: string;
219
+ consensusBrier: string;
220
+ brierSpread: string;
221
+ } | undefined;
222
+ }>;
223
+ export type PredictionV1VerdictPayload = z.infer<typeof PredictionV1VerdictPayloadSchema>;
@@ -0,0 +1,64 @@
1
+ import { z } from 'zod';
2
+ import { DecimalProbabilitySchema, IsoDateTimeSchema } from '../prediction-v1.js';
3
+ const Sha256Schema = z.string().regex(/^[0-9a-f]{64}$/);
4
+ const CheckSchema = z.object({
5
+ name: z.string().min(1),
6
+ status: z.enum(['PASS', 'FAIL', 'SKIP', 'INDETERMINATE']),
7
+ detail: z.union([z.string(), z.record(z.unknown())]).optional(),
8
+ });
9
+ export const PredictionV1RestorationPayloadSchema = z.object({
10
+ probabilityYes: DecimalProbabilitySchema,
11
+ submittedAt: IsoDateTimeSchema,
12
+ format: z.literal('decimal'),
13
+ modelId: z.string().min(1),
14
+ confidence: z.enum(['low', 'medium', 'high']).optional(),
15
+ methodology: z.string().optional(),
16
+ evidenceCids: z.array(z.string().min(1)).optional(),
17
+ reasoningCid: z.string().min(1).optional(),
18
+ sourceRefs: z
19
+ .array(z.object({
20
+ title: z.string().min(1),
21
+ url: z.string().url(),
22
+ }))
23
+ .optional(),
24
+ });
25
+ export const PredictionV1VerdictPayloadSchema = z.object({
26
+ verdict: z.enum(['SCORED', 'REJECTED', 'INVALID', 'INDETERMINATE']),
27
+ outcome: z.enum(['YES', 'NO', 'INVALID']).optional(),
28
+ resolvedAt: IsoDateTimeSchema.optional(),
29
+ resolutionSource: z.object({
30
+ venue: z.literal('polymarket'),
31
+ url: z.string().url(),
32
+ marketId: z.string().min(1),
33
+ conditionId: z.string().min(1),
34
+ }),
35
+ task: z.object({
36
+ cid: z.string(),
37
+ id: z.string().min(1),
38
+ }),
39
+ solutionEnvelope: z.object({
40
+ cid: z.string(),
41
+ sha256: Sha256Schema,
42
+ }),
43
+ claimed: z
44
+ .object({
45
+ probabilityYes: DecimalProbabilitySchema,
46
+ submittedAt: IsoDateTimeSchema,
47
+ modelId: z.string().min(1),
48
+ })
49
+ .optional(),
50
+ benchmark: z.object({
51
+ probabilityYes: DecimalProbabilitySchema,
52
+ sampledAt: IsoDateTimeSchema,
53
+ method: z.literal('best-bid-ask-midpoint'),
54
+ }),
55
+ scores: z
56
+ .object({
57
+ scoreBasis: z.literal('brier-loss.v1'),
58
+ solverBrier: z.string(),
59
+ consensusBrier: z.string(),
60
+ brierSpread: z.string(),
61
+ })
62
+ .optional(),
63
+ checks: z.array(CheckSchema),
64
+ });
@@ -0,0 +1,36 @@
1
+ export type SolverPluginSourceKind = 'bundled' | 'local' | 'npm' | 'git' | 'github' | 'claude';
2
+ export type SolverPluginEntry = string | {
3
+ name?: string;
4
+ source: string;
5
+ version?: string;
6
+ };
7
+ export interface SolverPluginManifest {
8
+ name: string;
9
+ version: string;
10
+ description?: string;
11
+ jinn?: {
12
+ supports?: string[];
13
+ capabilities?: Record<string, unknown>;
14
+ mcpServers?: Record<string, unknown>;
15
+ skills?: string[];
16
+ [key: string]: unknown;
17
+ };
18
+ [key: string]: unknown;
19
+ }
20
+ export interface LoadedSolverPlugin {
21
+ name: string;
22
+ version: string;
23
+ supports: string[];
24
+ source: string;
25
+ sourceKind: SolverPluginSourceKind;
26
+ root: string;
27
+ manifestPath: string;
28
+ manifest: SolverPluginManifest;
29
+ sha256: string;
30
+ cid?: string;
31
+ }
32
+ export interface ResolveSolverPluginOptions {
33
+ bundledRoot?: string;
34
+ vendorRoot?: string;
35
+ }
36
+ export declare function validateSolverPluginManifest(input: unknown): SolverPluginManifest;
@@ -0,0 +1,54 @@
1
+ function assertRecord(value, label) {
2
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
3
+ throw new Error(`${label} must be an object`);
4
+ }
5
+ }
6
+ export function validateSolverPluginManifest(input) {
7
+ assertRecord(input, 'manifest');
8
+ for (const key of Object.keys(input)) {
9
+ if (key.startsWith('jinn.')) {
10
+ throw new Error(`unknown top-level jinn extension key: ${key}; use manifest.jinn`);
11
+ }
12
+ }
13
+ if (typeof input['name'] !== 'string' || input['name'].length === 0) {
14
+ throw new Error('manifest.name is required');
15
+ }
16
+ if (typeof input['version'] !== 'string' || input['version'].length === 0) {
17
+ throw new Error('manifest.version is required');
18
+ }
19
+ const jinn = input['jinn'];
20
+ if (jinn !== undefined) {
21
+ assertRecord(jinn, 'manifest.jinn');
22
+ if ('solverType' in jinn) {
23
+ throw new Error('manifest.jinn.solverType is no longer supported; SolverNet contracts define solverType authority');
24
+ }
25
+ if ('schemas' in jinn) {
26
+ throw new Error('manifest.jinn.schemas is no longer supported; SolverNet contracts define canonical schemas');
27
+ }
28
+ const supports = jinn['supports'];
29
+ if (supports !== undefined) {
30
+ if (!Array.isArray(supports))
31
+ throw new Error('manifest.jinn.supports must be an array');
32
+ for (const [idx, value] of supports.entries()) {
33
+ if (typeof value !== 'string' || value.length === 0) {
34
+ throw new Error(`manifest.jinn.supports[${idx}] must be a non-empty string`);
35
+ }
36
+ }
37
+ }
38
+ if (jinn['capabilities'] !== undefined)
39
+ assertRecord(jinn['capabilities'], 'manifest.jinn.capabilities');
40
+ if (jinn['mcpServers'] !== undefined)
41
+ assertRecord(jinn['mcpServers'], 'manifest.jinn.mcpServers');
42
+ const skills = jinn['skills'];
43
+ if (skills !== undefined) {
44
+ if (!Array.isArray(skills))
45
+ throw new Error('manifest.jinn.skills must be an array');
46
+ for (const [idx, value] of skills.entries()) {
47
+ if (typeof value !== 'string' || value.length === 0) {
48
+ throw new Error(`manifest.jinn.skills[${idx}] must be a non-empty string`);
49
+ }
50
+ }
51
+ }
52
+ }
53
+ return input;
54
+ }