@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,78 @@
1
+ import { z } from 'zod';
2
+ const WindowSchema = z.object({
3
+ startTs: z.number().int().nonnegative(),
4
+ endTs: z.number().int().nonnegative(),
5
+ });
6
+ export const DecimalProbabilitySchema = z
7
+ .string()
8
+ .regex(/^(0(\.\d+)?|1(\.0+)?)$/, 'must be a decimal string in [0,1]');
9
+ export const IsoDateTimeSchema = z.string().datetime({ offset: true });
10
+ export const PredictionV1ClaimPolicySchema = z.object({
11
+ kind: z.literal('parallel'),
12
+ maxClaims: z.number().int().positive(),
13
+ maxClaimsPerSolver: z.number().int().positive(),
14
+ claimWindow: z.literal('task-window'),
15
+ selection: z.literal('all-valid-solutions-scored'),
16
+ economics: z.literal('testnet-flat'),
17
+ });
18
+ export const PredictionV1SpecSchema = z.object({
19
+ question: z.object({
20
+ kind: z.literal('binary'),
21
+ text: z.string().min(1),
22
+ yesLabel: z.literal('YES'),
23
+ noLabel: z.literal('NO'),
24
+ }),
25
+ source: z.object({
26
+ type: z.literal('prediction-market'),
27
+ venue: z.literal('polymarket'),
28
+ url: z.string().url(),
29
+ identifiers: z.object({
30
+ marketId: z.string().min(1),
31
+ conditionId: z.string().min(1),
32
+ yesTokenId: z.string().min(1),
33
+ noTokenId: z.string().min(1),
34
+ }),
35
+ }),
36
+ resolution: z.object({
37
+ expectedResolutionTime: IsoDateTimeSchema,
38
+ rulesText: z.string().min(1),
39
+ rulesUrl: z.string().url(),
40
+ timezone: z.string().optional(),
41
+ }),
42
+ consensusSnapshot: z.object({
43
+ sampledAt: IsoDateTimeSchema,
44
+ probabilityYes: DecimalProbabilitySchema,
45
+ method: z.literal('best-bid-ask-midpoint'),
46
+ bestBidYes: DecimalProbabilitySchema,
47
+ bestAskYes: DecimalProbabilitySchema,
48
+ spread: DecimalProbabilitySchema,
49
+ source: z.literal('polymarket-clob'),
50
+ }),
51
+ eligibilitySnapshot: z.object({
52
+ sampledAt: IsoDateTimeSchema,
53
+ timeToResolutionHours: z.number(),
54
+ liquidityUsd: z.string().min(1),
55
+ volume24hUsd: z.string().min(1),
56
+ orderbookAgeSeconds: z.number().nonnegative(),
57
+ selectionReason: z.string().min(1),
58
+ }),
59
+ });
60
+ export const PredictionV1TaskSchema = z
61
+ .object({
62
+ id: z.string().min(1),
63
+ description: z.string().min(1),
64
+ solverType: z.literal('prediction.v1'),
65
+ role: z.enum(['restoration', 'evaluation']).optional(),
66
+ window: WindowSchema,
67
+ claimPolicy: PredictionV1ClaimPolicySchema,
68
+ spec: PredictionV1SpecSchema,
69
+ eligibility: z.record(z.unknown()).default({}),
70
+ })
71
+ .refine((d) => d.window.endTs > d.window.startTs, {
72
+ message: 'window.endTs must be > window.startTs',
73
+ path: ['window'],
74
+ })
75
+ .refine((d) => Date.parse(d.spec.resolution.expectedResolutionTime) > d.window.startTs, {
76
+ message: 'expectedResolutionTime must be after window.startTs',
77
+ path: ['spec', 'resolution', 'expectedResolutionTime'],
78
+ });
@@ -0,0 +1,2 @@
1
+ export { PREDICTION_V1_SOLVER_NET_CONTRACT, SOLVER_NET_CONTRACTS, PayloadValidationException, getSolverNetContract, validateTask, assertTask, validateSolutionPayload, assertSolutionPayload, validateVerdictPayload, assertVerdictPayload, buildSolutionOutput, buildVerdictOutput, } from '../contracts.js';
2
+ export type { SolverNetContractRole, PayloadKind, SupportedSolverType, CredentialRequirement, SolverNetEvaluationFunction, SolverNetAggregationFunction, SolverNetClaimPolicyDefaults, SolverNetContract, SolverNetContractMap, PayloadValidationIssue, PayloadValidationFailure, PayloadValidationSuccess, PayloadValidationResult, BuildSolutionOutputArgs, BuildVerdictOutputArgs, } from '../contracts.js';
@@ -0,0 +1 @@
1
+ export { PREDICTION_V1_SOLVER_NET_CONTRACT, SOLVER_NET_CONTRACTS, PayloadValidationException, getSolverNetContract, validateTask, assertTask, validateSolutionPayload, assertSolutionPayload, validateVerdictPayload, assertVerdictPayload, buildSolutionOutput, buildVerdictOutput, } from '../contracts.js';
@@ -0,0 +1,6 @@
1
+ export { DecimalProbabilitySchema, IsoDateTimeSchema, PredictionV1ClaimPolicySchema, PredictionV1SpecSchema, PredictionV1TaskSchema, } from '../prediction-v1.js';
2
+ export type { PredictionV1Spec, PredictionV1Task } from '../prediction-v1.js';
3
+ export { PredictionV1RestorationPayloadSchema, PredictionV1VerdictPayloadSchema, } from '../payloads/prediction-v1.js';
4
+ export type { PredictionV1RestorationPayload, PredictionV1VerdictPayload, } from '../payloads/prediction-v1.js';
5
+ export { PREDICTION_V1_SOLVER_NET_CONTRACT, PayloadValidationException, getSolverNetContract, validateTask, assertTask, validateSolutionPayload, assertSolutionPayload, validateVerdictPayload, assertVerdictPayload, buildSolutionOutput, buildVerdictOutput, } from '../contracts.js';
6
+ export type { PayloadValidationIssue, PayloadValidationFailure, PayloadValidationSuccess, PayloadValidationResult, BuildSolutionOutputArgs, BuildVerdictOutputArgs, } from '../contracts.js';
@@ -0,0 +1,3 @@
1
+ export { DecimalProbabilitySchema, IsoDateTimeSchema, PredictionV1ClaimPolicySchema, PredictionV1SpecSchema, PredictionV1TaskSchema, } from '../prediction-v1.js';
2
+ export { PredictionV1RestorationPayloadSchema, PredictionV1VerdictPayloadSchema, } from '../payloads/prediction-v1.js';
3
+ export { PREDICTION_V1_SOLVER_NET_CONTRACT, PayloadValidationException, getSolverNetContract, validateTask, assertTask, validateSolutionPayload, assertSolutionPayload, validateVerdictPayload, assertVerdictPayload, buildSolutionOutput, buildVerdictOutput, } from '../contracts.js';
@@ -0,0 +1,116 @@
1
+ export type Hex = `0x${string}`;
2
+ export type Address = Hex;
3
+ export interface IntentWindow {
4
+ startTs: number;
5
+ endTs: number;
6
+ }
7
+ export interface Task {
8
+ id: string;
9
+ description: string;
10
+ solverType: string;
11
+ role?: 'restoration' | 'evaluation';
12
+ context?: Record<string, unknown>;
13
+ spec?: Record<string, unknown>;
14
+ window?: IntentWindow;
15
+ eligibility?: Record<string, unknown>;
16
+ attemptId?: string;
17
+ attemptNumber?: number;
18
+ restorationRequestId?: string;
19
+ }
20
+ export interface OutputArtifact {
21
+ artifactType: string;
22
+ type?: string;
23
+ path?: string;
24
+ cid?: string;
25
+ [key: string]: unknown;
26
+ }
27
+ export interface RationaleEntry {
28
+ message: string;
29
+ [key: string]: unknown;
30
+ }
31
+ export interface Solution {
32
+ venueRef: {
33
+ name: string;
34
+ };
35
+ preSnapshot?: Record<string, unknown>;
36
+ postSnapshot?: Record<string, unknown>;
37
+ fills?: unknown[];
38
+ gating: Record<string, unknown>;
39
+ informational?: Record<string, unknown>;
40
+ solutionPayload?: Record<string, unknown>;
41
+ verdictPayload?: Record<string, unknown>;
42
+ artifacts?: OutputArtifact[];
43
+ rationale?: RationaleEntry[];
44
+ }
45
+ export interface TrajectorySpanInput {
46
+ name: string;
47
+ kind: string;
48
+ startTimeUnixNano: string;
49
+ endTimeUnixNano: string;
50
+ attributes: Record<string, unknown>;
51
+ events: Array<{
52
+ name: string;
53
+ timeUnixNano: string;
54
+ attributes?: Record<string, unknown>;
55
+ }>;
56
+ status: {
57
+ code: 'OK' | 'ERROR' | 'UNSET';
58
+ message?: string;
59
+ };
60
+ parentSpanId?: string | null;
61
+ }
62
+ export interface TrajectoryCollector {
63
+ addSpan(input: TrajectorySpanInput): unknown;
64
+ }
65
+ export interface ReadyStatus {
66
+ ready: boolean;
67
+ reason?: string;
68
+ nextStep?: {
69
+ description: string;
70
+ cli?: string;
71
+ url?: string;
72
+ };
73
+ }
74
+ export declare const REQUIRES_LIVE_DAEMON_READINESS: ReadyStatus;
75
+ export interface EnableArgDef {
76
+ name: string;
77
+ description: string;
78
+ required: boolean;
79
+ }
80
+ export interface IntentEnableMetadata {
81
+ description: string;
82
+ requiredArgs?: EnableArgDef[];
83
+ externalResources?: Array<{
84
+ name: string;
85
+ url: string;
86
+ }>;
87
+ }
88
+ export type EnableResult = {
89
+ status: 'ready';
90
+ details?: Record<string, unknown>;
91
+ } | {
92
+ status: 'waiting_for_external_action';
93
+ action: {
94
+ description: string;
95
+ url?: string;
96
+ };
97
+ details?: Record<string, unknown>;
98
+ nextInvocation: {
99
+ cli: string;
100
+ purpose: string;
101
+ };
102
+ } | {
103
+ status: 'missing_args';
104
+ required: EnableArgDef[];
105
+ example: {
106
+ cli: string;
107
+ };
108
+ } | {
109
+ status: 'error';
110
+ message: string;
111
+ details?: Record<string, unknown>;
112
+ };
113
+ export declare class SkippableError extends Error {
114
+ readonly reason: string;
115
+ constructor(reason: string, message?: string);
116
+ }
package/dist/types.js ADDED
@@ -0,0 +1,21 @@
1
+ // Public contract surface for Jinn external Harness authors.
2
+ //
3
+ // These types are mirrored from `client/src/harnesses/types.ts` at SDK
4
+ // publish time. The SDK is the stable boundary; @jinn-network/client
5
+ // internals are not.
6
+ export const REQUIRES_LIVE_DAEMON_READINESS = {
7
+ ready: false,
8
+ reason: 'requires live daemon',
9
+ nextStep: {
10
+ description: 'Run the daemon with a configured fleet and wallet',
11
+ cli: 'jinn run',
12
+ },
13
+ };
14
+ export class SkippableError extends Error {
15
+ reason;
16
+ constructor(reason, message) {
17
+ super(message ?? reason);
18
+ this.name = 'SkippableError';
19
+ this.reason = reason;
20
+ }
21
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@jinn-network/sdk",
3
+ "version": "0.1.0",
4
+ "description": "Stable SDK surface for Jinn SolverNets, Harnesses, plugins, and typed payloads.",
5
+ "type": "module",
6
+ "packageManager": "yarn@4.13.0",
7
+ "license": "MIT",
8
+ "main": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./harness": {
16
+ "import": "./dist/harness.js",
17
+ "types": "./dist/harness.d.ts"
18
+ },
19
+ "./plugins": {
20
+ "import": "./dist/plugins.js",
21
+ "types": "./dist/plugins.d.ts"
22
+ },
23
+ "./solvernets": {
24
+ "import": "./dist/solvernets/index.js",
25
+ "types": "./dist/solvernets/index.d.ts"
26
+ },
27
+ "./solvernets/prediction-v1": {
28
+ "import": "./dist/solvernets/prediction-v1.js",
29
+ "types": "./dist/solvernets/prediction-v1.d.ts"
30
+ }
31
+ },
32
+ "files": [
33
+ "dist/",
34
+ "README.md"
35
+ ],
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "scripts": {
40
+ "build": "tsc -p tsconfig.json",
41
+ "typecheck": "tsc --noEmit -p tsconfig.json",
42
+ "test": "vitest run",
43
+ "prepublishOnly": "yarn build && yarn test",
44
+ "pack:smoke": "yarn pack -o jinn-sdk.tgz && node scripts/smoke-test-pack.mjs",
45
+ "release:sdk": "node scripts/release-sdk.mjs"
46
+ },
47
+ "dependencies": {
48
+ "zod": "^3.22.0"
49
+ },
50
+ "devDependencies": {
51
+ "typescript": "^5.4.0",
52
+ "vitest": "^2.1.9"
53
+ }
54
+ }