@jinn-network/client 0.1.3-canary.8e61ba74 → 0.1.3-canary.941614bc

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.
Files changed (183) hide show
  1. package/README.md +2 -8
  2. package/deployments/deployment-task-coordinator-router-v3-baseSepolia-fast.json +38 -0
  3. package/dist/agent/agent-ws.d.ts +2 -1
  4. package/dist/agent/agent-ws.js +2 -1
  5. package/dist/agent/agent-ws.js.map +1 -1
  6. package/dist/api/agent-binding-endpoint.d.ts +26 -0
  7. package/dist/api/agent-binding-endpoint.js +28 -0
  8. package/dist/api/agent-binding-endpoint.js.map +1 -0
  9. package/dist/api/bootstrap-endpoint.d.ts +8 -0
  10. package/dist/api/bootstrap-endpoint.js +27 -2
  11. package/dist/api/bootstrap-endpoint.js.map +1 -1
  12. package/dist/api/gather-status.d.ts +4 -0
  13. package/dist/api/gather-status.js +99 -0
  14. package/dist/api/gather-status.js.map +1 -1
  15. package/dist/api/prediction-v1-build.d.ts +47 -0
  16. package/dist/api/prediction-v1-build.js +73 -0
  17. package/dist/api/prediction-v1-build.js.map +1 -0
  18. package/dist/api/server.d.ts +16 -7
  19. package/dist/api/server.js +59 -12
  20. package/dist/api/server.js.map +1 -1
  21. package/dist/api/setup-endpoints.d.ts +8 -0
  22. package/dist/api/setup-endpoints.js +193 -3
  23. package/dist/api/setup-endpoints.js.map +1 -1
  24. package/dist/api/solvernets-catalog-build.d.ts +37 -0
  25. package/dist/api/solvernets-catalog-build.js +19 -0
  26. package/dist/api/solvernets-catalog-build.js.map +1 -0
  27. package/dist/api/solvernets-endpoint.d.ts +15 -0
  28. package/dist/api/solvernets-endpoint.js +5 -0
  29. package/dist/api/solvernets-endpoint.js.map +1 -0
  30. package/dist/api/status-build.d.ts +5 -0
  31. package/dist/api/status-build.js +1 -0
  32. package/dist/api/status-build.js.map +1 -1
  33. package/dist/build-info.json +4 -4
  34. package/dist/build-meta.json +1 -1
  35. package/dist/cli/commands/doctor.d.ts +15 -0
  36. package/dist/cli/commands/doctor.js +21 -0
  37. package/dist/cli/commands/doctor.js.map +1 -1
  38. package/dist/cli/commands/prediction-scoreboard.d.ts +10 -0
  39. package/dist/cli/commands/prediction-scoreboard.js +136 -0
  40. package/dist/cli/commands/prediction-scoreboard.js.map +1 -0
  41. package/dist/cli/commands/run.js +10 -0
  42. package/dist/cli/commands/run.js.map +1 -1
  43. package/dist/cli/commands/solver-nets.js +27 -5
  44. package/dist/cli/commands/solver-nets.js.map +1 -1
  45. package/dist/cli/commands/status.d.ts +3 -0
  46. package/dist/cli/commands/status.js +11 -3
  47. package/dist/cli/commands/status.js.map +1 -1
  48. package/dist/cli/commands/update.d.ts +8 -1
  49. package/dist/cli/commands/update.js +232 -7
  50. package/dist/cli/commands/update.js.map +1 -1
  51. package/dist/cli/index.js +2 -0
  52. package/dist/cli/index.js.map +1 -1
  53. package/dist/cli/task-native-readiness.d.ts +27 -0
  54. package/dist/cli/task-native-readiness.js +170 -0
  55. package/dist/cli/task-native-readiness.js.map +1 -0
  56. package/dist/config.d.ts +92 -48
  57. package/dist/config.js +91 -124
  58. package/dist/config.js.map +1 -1
  59. package/dist/corpus/envelope-projection.d.ts +12 -0
  60. package/dist/corpus/envelope-projection.js +110 -0
  61. package/dist/corpus/envelope-projection.js.map +1 -0
  62. package/dist/corpus/index.d.ts +3 -0
  63. package/dist/corpus/index.js +3 -0
  64. package/dist/corpus/index.js.map +1 -1
  65. package/dist/corpus/prediction-brier-scoreboard-report.d.ts +17 -0
  66. package/dist/corpus/prediction-brier-scoreboard-report.js +148 -0
  67. package/dist/corpus/prediction-brier-scoreboard-report.js.map +1 -0
  68. package/dist/corpus/prediction-brier-scoreboard.d.ts +56 -0
  69. package/dist/corpus/prediction-brier-scoreboard.js +269 -0
  70. package/dist/corpus/prediction-brier-scoreboard.js.map +1 -0
  71. package/dist/corpus/prediction-scoreable-verdicts.d.ts +4 -0
  72. package/dist/corpus/prediction-scoreable-verdicts.js +23 -0
  73. package/dist/corpus/prediction-scoreable-verdicts.js.map +1 -0
  74. package/dist/corpus/types.d.ts +43 -1
  75. package/dist/corpus/types.js.map +1 -1
  76. package/dist/daemon/daemon.js +1 -1
  77. package/dist/daemon/daemon.js.map +1 -1
  78. package/dist/dashboard/assets/index-5ArwpmyK.js +76 -0
  79. package/dist/dashboard/assets/{index-DQ3u_vP5.css → index-Bx5KH3YV.css} +1 -1
  80. package/dist/dashboard/index.html +2 -2
  81. package/dist/earning/bootstrap.d.ts +24 -0
  82. package/dist/earning/bootstrap.js +84 -23
  83. package/dist/earning/bootstrap.js.map +1 -1
  84. package/dist/earning/contracts.d.ts +1 -0
  85. package/dist/earning/contracts.js +16 -0
  86. package/dist/earning/contracts.js.map +1 -1
  87. package/dist/earning/faucet.d.ts +31 -0
  88. package/dist/earning/faucet.js +37 -0
  89. package/dist/earning/faucet.js.map +1 -1
  90. package/dist/earning/safe-adapter.js +45 -3
  91. package/dist/earning/safe-adapter.js.map +1 -1
  92. package/dist/earning/store.d.ts +8 -0
  93. package/dist/earning/store.js +41 -0
  94. package/dist/earning/store.js.map +1 -1
  95. package/dist/earning/types.d.ts +4 -0
  96. package/dist/events/types.d.ts +2 -2
  97. package/dist/harnesses/engine/engine.d.ts +5 -3
  98. package/dist/harnesses/engine/engine.js +33 -11
  99. package/dist/harnesses/engine/engine.js.map +1 -1
  100. package/dist/harnesses/engine/registry.d.ts +2 -0
  101. package/dist/harnesses/engine/registry.js +3 -0
  102. package/dist/harnesses/engine/registry.js.map +1 -1
  103. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.d.ts +19 -0
  104. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js +37 -2
  105. package/dist/harnesses/impls/claude-code-learner/adapters/claude-code.js.map +1 -1
  106. package/dist/harnesses/impls/claude-code-learner/harness.js +2 -0
  107. package/dist/harnesses/impls/claude-code-learner/harness.js.map +1 -1
  108. package/dist/harnesses/impls/claude-code-learner/harvest.js +132 -2
  109. package/dist/harnesses/impls/claude-code-learner/harvest.js.map +1 -1
  110. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.d.ts +20 -0
  111. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js +65 -0
  112. package/dist/harnesses/impls/claude-code-learner/test-utils/fake-plugin-outputs.js.map +1 -1
  113. package/dist/harnesses/impls/claude-code-learner/types.d.ts +5 -0
  114. package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js +4 -3
  115. package/dist/harnesses/impls/claude-mcp-hyperliquid/index.js.map +1 -1
  116. package/dist/harnesses/impls/claude-mcp-prediction/index.js +6 -5
  117. package/dist/harnesses/impls/claude-mcp-prediction/index.js.map +1 -1
  118. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js +6 -5
  119. package/dist/harnesses/impls/claude-mcp-prediction-apy/index.js.map +1 -1
  120. package/dist/harnesses/impls/index.d.ts +2 -2
  121. package/dist/harnesses/impls/index.js +8 -9
  122. package/dist/harnesses/impls/index.js.map +1 -1
  123. package/dist/harnesses/impls/legacy-claude/index.d.ts +2 -2
  124. package/dist/harnesses/impls/prediction-v1-evaluator/index.js +33 -12
  125. package/dist/harnesses/impls/prediction-v1-evaluator/index.js.map +1 -1
  126. package/dist/harnesses/types.d.ts +6 -1
  127. package/dist/harnesses/types.js.map +1 -1
  128. package/dist/main.d.ts +13 -1
  129. package/dist/main.js +178 -18
  130. package/dist/main.js.map +1 -1
  131. package/dist/mcp/search-records.d.ts +92 -0
  132. package/dist/mcp/search-records.js +393 -0
  133. package/dist/mcp/search-records.js.map +1 -0
  134. package/dist/mcp/server.js +56 -15
  135. package/dist/mcp/server.js.map +1 -1
  136. package/dist/operator-errors.d.ts +14 -0
  137. package/dist/operator-errors.js +35 -5
  138. package/dist/operator-errors.js.map +1 -1
  139. package/dist/plugins/resolvers.js +45 -7
  140. package/dist/plugins/resolvers.js.map +1 -1
  141. package/dist/plugins/validator.js +8 -0
  142. package/dist/plugins/validator.js.map +1 -1
  143. package/dist/runner/runner.d.ts +6 -6
  144. package/dist/solver-nets/prediction-operator-ux.d.ts +105 -0
  145. package/dist/solver-nets/prediction-operator-ux.js +438 -0
  146. package/dist/solver-nets/prediction-operator-ux.js.map +1 -0
  147. package/dist/solver-nets/registry.d.ts +13 -6
  148. package/dist/solver-nets/registry.js +50 -16
  149. package/dist/solver-nets/registry.js.map +1 -1
  150. package/dist/solver-types/index.d.ts +11 -0
  151. package/dist/solver-types/index.js +8 -1
  152. package/dist/solver-types/index.js.map +1 -1
  153. package/dist/solver-types/prediction-v0.d.ts +1 -1
  154. package/dist/solver-types/prediction-v0.js +1 -1
  155. package/dist/solver-types/prediction-v0.js.map +1 -1
  156. package/dist/solver-types/prediction-v1-auto.d.ts +2 -0
  157. package/dist/solver-types/prediction-v1-auto.js +56 -7
  158. package/dist/solver-types/prediction-v1-auto.js.map +1 -1
  159. package/dist/solver-types/prediction-v1.js +25 -1
  160. package/dist/solver-types/prediction-v1.js.map +1 -1
  161. package/dist/solver-types/solver-type.d.ts +18 -5
  162. package/dist/store/store.d.ts +44 -2
  163. package/dist/store/store.js +387 -8
  164. package/dist/store/store.js.map +1 -1
  165. package/dist/tx-retry.js +11 -0
  166. package/dist/tx-retry.js.map +1 -1
  167. package/dist/vendor/@jinn-network/sdk/dist/contracts.d.ts +1 -1
  168. package/dist/vendor/@jinn-network/sdk/dist/contracts.js +1 -1
  169. package/package.json +1 -1
  170. package/plugins/jinn-prediction-plugin/.claude-plugin/plugin.json +4 -1
  171. package/plugins/jinn-prediction-plugin/GEMINI.md +5 -1
  172. package/plugins/jinn-prediction-plugin/jinn.plugin.json +5 -2
  173. package/plugins/jinn-prediction-plugin/mcp/polymarket-server.mjs +321 -1
  174. package/plugins/jinn-prediction-plugin/skills/common-biases/SKILL.md +3 -0
  175. package/plugins/jinn-prediction-plugin/skills/polymarket-task-handling/SKILL.md +5 -0
  176. package/plugins/jinn-prediction-plugin/skills/prediction-corpus-retrieval/SKILL.md +35 -0
  177. package/plugins/network-tools/.claude-plugin/plugin.json +12 -0
  178. package/plugins/network-tools/jinn.plugin.json +29 -0
  179. package/plugins/network-tools/mcp/jinn-client-server.mjs +110 -0
  180. package/dist/dashboard/assets/index-CaUOdCs6.js +0 -68
  181. package/dist/mcp/search-artifacts.d.ts +0 -31
  182. package/dist/mcp/search-artifacts.js +0 -40
  183. package/dist/mcp/search-artifacts.js.map +0 -1
@@ -43,7 +43,7 @@ export interface SolverNetContract {
43
43
  credentialRequirements: Record<SolverNetContractRole, CredentialRequirement[]>;
44
44
  evaluationFunction: SolverNetEvaluationFunction;
45
45
  aggregationFunction: SolverNetAggregationFunction;
46
- referencePlugins: string[];
46
+ defaultRuntimePlugins: string[];
47
47
  }
48
48
  export type SolverNetContractMap = Record<SupportedSolverType, SolverNetContract>;
49
49
  export declare const PREDICTION_V1_SOLVER_NET_CONTRACT: SolverNetContract;
@@ -47,7 +47,7 @@ export const PREDICTION_V1_SOLVER_NET_CONTRACT = {
47
47
  output: 'trailing mean brierSpread',
48
48
  windowDays: 84,
49
49
  },
50
- referencePlugins: ['bundled:jinn-prediction-plugin'],
50
+ defaultRuntimePlugins: ['bundled:jinn-prediction-plugin'],
51
51
  };
52
52
  export const SOLVER_NET_CONTRACTS = {
53
53
  'prediction.v1': PREDICTION_V1_SOLVER_NET_CONTRACT,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinn-network/client",
3
- "version": "0.1.3-canary.8e61ba74",
3
+ "version": "0.1.3-canary.941614bc",
4
4
  "description": "Jinn protocol client — headless daemon for the restoration training loop",
5
5
  "type": "module",
6
6
  "packageManager": "yarn@4.13.0",
@@ -11,6 +11,9 @@
11
11
  },
12
12
  "skills": [
13
13
  "skills/base-rate-forecasting/SKILL.md",
14
- "skills/calibration/SKILL.md"
14
+ "skills/calibration/SKILL.md",
15
+ "skills/common-biases/SKILL.md",
16
+ "skills/prediction-corpus-retrieval/SKILL.md",
17
+ "skills/polymarket-task-handling/SKILL.md"
15
18
  ]
16
19
  }
@@ -1,3 +1,7 @@
1
- # Jinn Prediction Reference Pack
1
+ # Jinn Prediction Plugin
2
2
 
3
3
  Use the Polymarket tools only to inspect the market and orderbook named by the current Task. Submit probabilities only. Do not trade, sign orders, or ask for wallet credentials.
4
+
5
+ Before forecasting, check base rates, calibration, common forecasting biases, and the exact Polymarket resolution rules for the task market.
6
+
7
+ When Network Tools are available, call get_task first, search_records for relevant prior prediction.v1 records, inspect_record before relying on refs, and use acquire_artifact only as an explicit, optional, price-aware acquisition/payment path. Search and inspect are read-only. Prefer current task matches, exact conditionId, same venue, scored Verdicts, cited records, and recent useful examples; treat failures and rejected/invalid examples as possible warnings. Cite record or envelope refs that affected the forecast.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jinn-network/prediction-plugin",
3
3
  "version": "0.2.0",
4
- "description": "Reference Prediction plugin pack for prediction.v1 Polymarket forecasting tasks.",
4
+ "description": "Prediction plugin pack for prediction.v1 Polymarket forecasting tasks.",
5
5
  "jinn": {
6
6
  "supports": ["prediction.v1"],
7
7
  "capabilities": {
@@ -17,7 +17,10 @@
17
17
  },
18
18
  "skills": [
19
19
  "skills/base-rate-forecasting/SKILL.md",
20
- "skills/calibration/SKILL.md"
20
+ "skills/calibration/SKILL.md",
21
+ "skills/common-biases/SKILL.md",
22
+ "skills/prediction-corpus-retrieval/SKILL.md",
23
+ "skills/polymarket-task-handling/SKILL.md"
21
24
  ]
22
25
  }
23
26
  }
@@ -1,2 +1,322 @@
1
1
  #!/usr/bin/env node
2
- process.stdin.resume();
2
+ import { pathToFileURL } from 'node:url';
3
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
4
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
5
+ import { z } from 'zod';
6
+
7
+ const DEFAULT_GAMMA_BASE_URL = 'https://gamma-api.polymarket.com';
8
+ const DEFAULT_CLOB_BASE_URL = 'https://clob.polymarket.com';
9
+
10
+ const MarketArgsShape = {
11
+ marketId: z.string().min(1).optional().describe('Exact Polymarket market id from the current prediction task.'),
12
+ slug: z.string().min(1).optional().describe('Exact Polymarket market slug from the current prediction task URL.'),
13
+ conditionId: z.string().min(1).optional().describe('Expected condition id from the current prediction task, used only to verify the returned market.'),
14
+ };
15
+
16
+ const OrderbookArgsShape = {
17
+ marketId: z.string().min(1).describe('Exact Polymarket market id from the current prediction task.'),
18
+ conditionId: z.string().min(1).describe('Exact condition id from the current prediction task.'),
19
+ yesTokenId: z.string().min(1).describe('YES outcome CLOB token id from the current prediction task.'),
20
+ };
21
+
22
+ const MarketArgsSchema = z.object(MarketArgsShape).strict().refine((args) => args.marketId || args.slug, {
23
+ message: 'marketId or slug is required',
24
+ });
25
+
26
+ const OrderbookArgsSchema = z.object(OrderbookArgsShape).strict();
27
+
28
+ export function listToolDeclarations() {
29
+ return [
30
+ {
31
+ name: 'polymarket_get_market',
32
+ description:
33
+ 'Read one exact Polymarket binary market named by the current prediction task. Requires marketId or slug and never performs broad market search.',
34
+ inputSchema: {
35
+ type: 'object',
36
+ additionalProperties: false,
37
+ properties: {
38
+ marketId: { type: 'string', description: 'Exact Polymarket market id from the current prediction task.' },
39
+ slug: { type: 'string', description: 'Exact Polymarket market slug from the current prediction task URL.' },
40
+ conditionId: { type: 'string', description: 'Expected task condition id for verification.' },
41
+ },
42
+ },
43
+ },
44
+ {
45
+ name: 'polymarket_get_orderbook',
46
+ description:
47
+ 'Read the YES orderbook for the exact market/condition/token identifiers in the current prediction task. Read-only CLOB market data only.',
48
+ inputSchema: {
49
+ type: 'object',
50
+ additionalProperties: false,
51
+ required: ['marketId', 'conditionId', 'yesTokenId'],
52
+ properties: {
53
+ marketId: { type: 'string', description: 'Exact Polymarket market id from the current prediction task.' },
54
+ conditionId: { type: 'string', description: 'Exact condition id from the current prediction task.' },
55
+ yesTokenId: { type: 'string', description: 'YES outcome CLOB token id from the current prediction task.' },
56
+ },
57
+ },
58
+ },
59
+ ];
60
+ }
61
+
62
+ function configWithDefaults(config = {}) {
63
+ return {
64
+ gammaBaseUrl: config.gammaBaseUrl ?? process.env.POLYMARKET_GAMMA_BASE_URL ?? DEFAULT_GAMMA_BASE_URL,
65
+ clobBaseUrl: config.clobBaseUrl ?? process.env.POLYMARKET_CLOB_BASE_URL ?? DEFAULT_CLOB_BASE_URL,
66
+ fetchImpl: config.fetchImpl ?? fetch,
67
+ };
68
+ }
69
+
70
+ function apiUrl(baseUrl, path, params = {}) {
71
+ const url = new URL(path, baseUrl);
72
+ for (const [key, value] of Object.entries(params)) {
73
+ if (value !== undefined) url.searchParams.set(key, String(value));
74
+ }
75
+ return url.toString();
76
+ }
77
+
78
+ async function readJson(url, fetchImpl) {
79
+ const response = await fetchImpl(url, { method: 'GET' });
80
+ if (!response.ok) {
81
+ throw new Error(`Polymarket request failed ${response.status}: ${url}`);
82
+ }
83
+ return response.json();
84
+ }
85
+
86
+ function asRecord(value) {
87
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
88
+ }
89
+
90
+ function firstString(record, keys) {
91
+ for (const key of keys) {
92
+ const value = record[key];
93
+ if (typeof value === 'string' && value.trim()) return value.trim();
94
+ if (typeof value === 'number' && Number.isFinite(value)) return String(value);
95
+ }
96
+ return undefined;
97
+ }
98
+
99
+ function firstBoolean(record, keys, fallback = false) {
100
+ for (const key of keys) {
101
+ const value = record[key];
102
+ if (typeof value === 'boolean') return value;
103
+ if (typeof value === 'string') {
104
+ if (value.toLowerCase() === 'true') return true;
105
+ if (value.toLowerCase() === 'false') return false;
106
+ }
107
+ }
108
+ return fallback;
109
+ }
110
+
111
+ function parseStringArray(value) {
112
+ if (Array.isArray(value)) return value.map(String);
113
+ if (typeof value !== 'string') return [];
114
+ try {
115
+ const parsed = JSON.parse(value);
116
+ return Array.isArray(parsed) ? parsed.map(String) : [];
117
+ } catch {
118
+ return value.split(',').map((part) => part.trim()).filter(Boolean);
119
+ }
120
+ }
121
+
122
+ function normalizeOutcome(value) {
123
+ return value.trim().toUpperCase();
124
+ }
125
+
126
+ function decimalString(value, fallback = '0') {
127
+ if (typeof value === 'number' && Number.isFinite(value)) return value.toFixed(2);
128
+ if (typeof value === 'string' && value.trim()) return value.trim();
129
+ return fallback;
130
+ }
131
+
132
+ function buildMarketUrl(slug) {
133
+ return slug ? `https://polymarket.com/event/${slug}` : 'https://polymarket.com';
134
+ }
135
+
136
+ function rulesTextOf(record) {
137
+ return firstString(record, [
138
+ 'rules',
139
+ 'resolutionRules',
140
+ 'resolution_rules',
141
+ 'description',
142
+ 'question',
143
+ ]) ?? '';
144
+ }
145
+
146
+ function endTimeOf(record) {
147
+ return firstString(record, ['endDateIso', 'endDate', 'end_date', 'endTime', 'end_time']) ?? '';
148
+ }
149
+
150
+ function tokenIdsFor(record, outcomes) {
151
+ const ids = parseStringArray(record.clobTokenIds ?? record.clob_token_ids ?? record.tokenIds);
152
+ if (ids.length < 2) return null;
153
+ const yesIndex = outcomes.findIndex((outcome) => normalizeOutcome(outcome) === 'YES');
154
+ const noIndex = outcomes.findIndex((outcome) => normalizeOutcome(outcome) === 'NO');
155
+ if (yesIndex < 0 || noIndex < 0) return null;
156
+ const yes = ids[yesIndex];
157
+ const no = ids[noIndex];
158
+ return yes && no ? { yes, no } : null;
159
+ }
160
+
161
+ export function normalizeMarketCandidate(raw) {
162
+ const record = asRecord(raw);
163
+ const marketId = firstString(record, ['id', 'marketId', 'market_id']);
164
+ const conditionId = firstString(record, ['conditionId', 'condition_id']);
165
+ const slug = firstString(record, ['slug', 'marketSlug', 'eventSlug']) ?? '';
166
+ const question = firstString(record, ['question', 'title']) ?? '';
167
+ const outcomes = parseStringArray(record.outcomes).map(normalizeOutcome);
168
+ const binary = outcomes.length === 2 && outcomes.includes('YES') && outcomes.includes('NO');
169
+ const tokenIds = binary ? tokenIdsFor(record, outcomes) : null;
170
+ const endTime = endTimeOf(record);
171
+
172
+ if (!marketId || !conditionId || !question || !binary || !tokenIds || !endTime) {
173
+ return null;
174
+ }
175
+
176
+ const description = firstString(record, ['description']);
177
+ return {
178
+ venue: 'polymarket',
179
+ marketId,
180
+ conditionId,
181
+ slug,
182
+ url: firstString(record, ['url']) ?? buildMarketUrl(slug),
183
+ question,
184
+ ...(description ? { description } : {}),
185
+ rulesText: rulesTextOf(record),
186
+ endTime,
187
+ active: firstBoolean(record, ['active'], true),
188
+ closed: firstBoolean(record, ['closed'], false),
189
+ archived: firstBoolean(record, ['archived'], false),
190
+ outcomes: ['YES', 'NO'],
191
+ tokenIds,
192
+ liquidityUsd: decimalString(record.liquidity ?? record.liquidityNum ?? record.liquidity_usd),
193
+ volume24hUsd: decimalString(record.volume24hr ?? record.volume24h ?? record.volume24hUsd ?? record.volume_24h),
194
+ };
195
+ }
196
+
197
+ export async function getMarket(args, config = {}) {
198
+ const parsed = MarketArgsSchema.parse(args);
199
+ const { gammaBaseUrl, fetchImpl } = configWithDefaults(config);
200
+ const raw = parsed.marketId
201
+ ? await readJson(apiUrl(gammaBaseUrl, `/markets/${encodeURIComponent(parsed.marketId)}`), fetchImpl)
202
+ : await readJson(apiUrl(gammaBaseUrl, `/markets/slug/${encodeURIComponent(parsed.slug)}`), fetchImpl);
203
+
204
+ const market = normalizeMarketCandidate(raw);
205
+ if (!market) throw new Error('Polymarket market response is not an eligible binary market');
206
+ if (parsed.conditionId && market.conditionId !== parsed.conditionId) {
207
+ throw new Error(`Polymarket conditionId mismatch: expected ${parsed.conditionId}, got ${market.conditionId}`);
208
+ }
209
+ return market;
210
+ }
211
+
212
+ function timestampToIso(value) {
213
+ if (typeof value === 'number' && Number.isFinite(value)) {
214
+ return new Date(value > 10_000_000_000 ? value : value * 1000).toISOString();
215
+ }
216
+ if (typeof value === 'string' && value.trim()) {
217
+ const numeric = Number(value);
218
+ if (Number.isFinite(numeric)) return timestampToIso(numeric);
219
+ const parsed = Date.parse(value);
220
+ if (Number.isFinite(parsed)) return new Date(parsed).toISOString();
221
+ }
222
+ return new Date().toISOString();
223
+ }
224
+
225
+ function bestBidAsk(book) {
226
+ const bids = Array.isArray(book.bids) ? book.bids : [];
227
+ const asks = Array.isArray(book.asks) ? book.asks : [];
228
+ const bid = Math.max(...bids.map((row) => Number(asRecord(row).price)).filter(Number.isFinite));
229
+ const ask = Math.min(...asks.map((row) => Number(asRecord(row).price)).filter(Number.isFinite));
230
+ if (!Number.isFinite(bid) || !Number.isFinite(ask)) return null;
231
+ return { bid, ask };
232
+ }
233
+
234
+ function probability(value) {
235
+ return Math.max(0, Math.min(1, value)).toFixed(4);
236
+ }
237
+
238
+ export async function getOrderbook(args, config = {}) {
239
+ const parsed = OrderbookArgsSchema.parse(args);
240
+ const { clobBaseUrl, fetchImpl } = configWithDefaults(config);
241
+ const raw = await readJson(apiUrl(clobBaseUrl, '/book', { token_id: parsed.yesTokenId }), fetchImpl);
242
+ const book = asRecord(raw);
243
+ const best = bestBidAsk(book);
244
+ if (!best) {
245
+ throw new Error(`Polymarket orderbook has no usable YES bid/ask for token ${parsed.yesTokenId}`);
246
+ }
247
+ const midpoint = (best.bid + best.ask) / 2;
248
+ return {
249
+ venue: 'polymarket',
250
+ marketId: parsed.marketId,
251
+ conditionId: parsed.conditionId,
252
+ sampledAt: timestampToIso(book.timestamp),
253
+ bestBidYes: probability(best.bid),
254
+ bestAskYes: probability(best.ask),
255
+ midpointYes: probability(midpoint),
256
+ spread: probability(best.ask - best.bid),
257
+ source: 'polymarket-clob',
258
+ };
259
+ }
260
+
261
+ function ok(data) {
262
+ return {
263
+ content: [{ type: 'text', text: JSON.stringify(data, null, 2) }],
264
+ };
265
+ }
266
+
267
+ function toolErr(code, message) {
268
+ return {
269
+ content: [{ type: 'text', text: JSON.stringify({ error: true, code, message }) }],
270
+ isError: true,
271
+ };
272
+ }
273
+
274
+ export function createPolymarketServer(config = {}) {
275
+ const server = new McpServer({ name: 'jinn-prediction-polymarket', version: '0.2.0' });
276
+ const registerTool = server.tool.bind(server);
277
+
278
+ registerTool(
279
+ 'polymarket_get_market',
280
+ listToolDeclarations()[0].description,
281
+ MarketArgsShape,
282
+ async (args) => {
283
+ try {
284
+ return ok(await getMarket(args, config));
285
+ } catch (err) {
286
+ return toolErr('POLYMARKET_MARKET_READ_FAILED', err instanceof Error ? err.message : String(err));
287
+ }
288
+ },
289
+ );
290
+
291
+ registerTool(
292
+ 'polymarket_get_orderbook',
293
+ listToolDeclarations()[1].description,
294
+ OrderbookArgsShape,
295
+ async (args) => {
296
+ try {
297
+ return ok(await getOrderbook(args, config));
298
+ } catch (err) {
299
+ return toolErr('POLYMARKET_ORDERBOOK_READ_FAILED', err instanceof Error ? err.message : String(err));
300
+ }
301
+ },
302
+ );
303
+
304
+ return server;
305
+ }
306
+
307
+ export async function startMcpServer(config = {}) {
308
+ const server = createPolymarketServer(config);
309
+ const transport = new StdioServerTransport();
310
+ await server.connect(transport);
311
+ await new Promise((resolve) => {
312
+ process.stdin.on('close', resolve);
313
+ process.stdin.on('end', resolve);
314
+ });
315
+ }
316
+
317
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
318
+ startMcpServer().catch((err) => {
319
+ console.error(err instanceof Error ? err.stack ?? err.message : String(err));
320
+ process.exit(1);
321
+ });
322
+ }
@@ -0,0 +1,3 @@
1
+ # Common Forecasting Biases
2
+
3
+ Check for recency bias, availability bias, anchoring on the market price, motivated reasoning, and overreaction to thin evidence. Name the adjustment only when it changes the final probability.
@@ -0,0 +1,5 @@
1
+ # Polymarket Task Handling
2
+
3
+ Use only the market and orderbook identifiers in the current prediction task. Verify the question text, resolution rules, expected close time, spread, and liquidity before adjusting from the consensus snapshot.
4
+
5
+ Do not search for unrelated markets, infer from ticker-like names alone, trade, sign orders, use wallet credentials, or post externally. The Polymarket MCP tools are read-only references for task-scoped market data.
@@ -0,0 +1,35 @@
1
+ # Prediction Corpus Retrieval
2
+
3
+ Use this skill when forecasting a `prediction.v1` Task with Network Tools available. The Prediction plugin supplies Polymarket market/orderbook tools; Network Tools supplies generic Jinn task, record, and artifact tools.
4
+
5
+ ## Workflow
6
+
7
+ 1. Call `get_task` first and anchor every lookup to the current Task. Extract the `solverType`, venue, question text, `conditionId`, `marketId`, token ids, expected resolution time, and consensus snapshot.
8
+ 2. Call `polymarket_get_market` and `polymarket_get_orderbook` for the task's own market identifiers. Use them to verify the current market state, liquidity, spread, rules, and consensus probability.
9
+ 3. Use `search_records` to look for prior Jinn corpus records relevant to the current Task. Prefer queries that include `prediction.v1`, the exact `conditionId`, the Polymarket venue, the market/question text, and resolution or category terms from the task.
10
+ 4. Use `inspect_record` on the most promising record, envelope, or projection refs before relying on them. Search and inspect are read-only; they do not acquire artifacts and they do not create a payment.
11
+ 5. Consider `acquire_artifact` only when the inspected record shows that full artifact contents are necessary for the forecast. Treat acquisition as explicit, optional, and price-aware. `acquire_artifact` is the only acquisition/payment path; search and inspect never buy or fetch full paid artifacts. Check the quoted price first, avoid paid acquisition unless the expected forecast value justifies it, and record why it was worth acquiring.
12
+ 6. Forecast normally using task facts, Polymarket data, base rates, calibration, and the useful corpus evidence. Do not copy a prior probability blindly.
13
+
14
+ ## Ranking Guidance
15
+
16
+ Prefer records that match the current task directly:
17
+
18
+ - exact `conditionId` match
19
+ - same venue/source, especially Polymarket
20
+ - same or very similar market/question text
21
+ - scored Verdicts with known outcomes and Brier results
22
+ - Solutions that cite their evidence clearly
23
+ - recent examples with comparable resolution windows, liquidity, spread, or market category
24
+
25
+ Also inspect failures, rejections, invalid Verdicts, and underperforming forecasts when they are task-relevant. They can warn about ambiguous rules, stale consensus snapshots, thin liquidity, bad search terms, or reasoning patterns that should not be repeated.
26
+
27
+ ## Output Expectations
28
+
29
+ When corpus evidence affects the forecast, cite the relevant record, envelope, projection, or artifact refs in the reasoning. Separate current Polymarket evidence from prior Jinn corpus evidence, and state whether each prior record raised confidence, lowered confidence, or served as a warning.
30
+
31
+ Write `.execute/prediction-corpus-retrieval.json` when retrieval is attempted. Keep it as transparent run evidence, not hidden policy. Include the search intents or queries tried, records considered, refs inspected, records cited or used, acquired artifacts with price/payment metadata, forecast probability, consensus snapshot reference, and a short self-assessment of whether retrieval affected the forecast. Search and inspect remain read-only; only `acquire_artifact` should appear for explicit artifact acquisition.
32
+
33
+ When a later Debrief can connect the run to a Verdict, write `.debrief/learner-feedback.json` with the same retrieval/tool/skill usage plus Verdict or Brier feedback. Do not implement local optimization, ELO, hill-climbing, or strategy mutation inside this skill; the artifact is for future learners and builder-specific improvement systems.
34
+
35
+ Do not treat any plugin as protocol authority. Task schemas, Solution schemas, Verdict schemas, evaluation, and aggregation semantics come from the SolverNet contract registry. Plugins provide runtime tools and skills only.
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "network-tools",
3
+ "version": "0.1.0",
4
+ "description": "Network Tools for agent Harnesses. Exposes the Jinn client MCP tools as a Claude Code plugin.",
5
+ "mcpServers": {
6
+ "jinn-client": {
7
+ "command": "node",
8
+ "args": ["${CLAUDE_PLUGIN_ROOT}/mcp/jinn-client-server.mjs"],
9
+ "cwd": "${CLAUDE_PLUGIN_ROOT}"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@jinn-network/network-tools",
3
+ "version": "0.1.0",
4
+ "description": "Network Tools for agent Harnesses. Declares shared runtime MCP tooling provided by the client runtime; SolverNet contracts remain the canonical protocol and schema authority.",
5
+ "jinn": {
6
+ "supports": ["jinn.runtime"],
7
+ "capabilities": {
8
+ "tools": {
9
+ "jinn-runtime": [
10
+ "search_records",
11
+ "inspect_record",
12
+ "acquire_artifact",
13
+ "get_task"
14
+ ]
15
+ }
16
+ },
17
+ "mcpServers": {
18
+ "jinn-runtime": {
19
+ "providedBy": "jinn-client-runtime",
20
+ "tools": [
21
+ "search_records",
22
+ "inspect_record",
23
+ "acquire_artifact",
24
+ "get_task"
25
+ ]
26
+ }
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ import { dirname, isAbsolute, join, resolve } from 'node:path';
5
+ import { fileURLToPath, pathToFileURL } from 'node:url';
6
+
7
+ const here = dirname(fileURLToPath(import.meta.url));
8
+ const pluginRoot = resolve(here, '..');
9
+
10
+ function envPath(name, env) {
11
+ const value = env[name];
12
+ return value && value.trim() ? value.trim() : undefined;
13
+ }
14
+
15
+ function absolutePath(path, base = process.cwd()) {
16
+ return isAbsolute(path) ? path : resolve(base, path);
17
+ }
18
+
19
+ function launcherForServerPath(serverPath, cwd) {
20
+ const args = serverPath.endsWith('.ts')
21
+ ? ['--import', 'tsx', serverPath]
22
+ : [serverPath];
23
+ return { command: process.execPath, args, cwd };
24
+ }
25
+
26
+ function firstExistingServer(root) {
27
+ const distServer = join(root, 'dist', 'mcp', 'server.js');
28
+ if (existsSync(distServer)) return distServer;
29
+
30
+ const sourceServer = join(root, 'src', 'mcp', 'server.ts');
31
+ if (existsSync(sourceServer)) return sourceServer;
32
+
33
+ return undefined;
34
+ }
35
+
36
+ export function resolveJinnClientMcpLauncher(env = process.env, root = pluginRoot) {
37
+ const explicitServerPath =
38
+ envPath('JINN_NETWORK_TOOLS_MCP_SERVER_PATH', env) ??
39
+ envPath('JINN_CLIENT_MCP_SERVER_PATH', env);
40
+ const explicitClientRoot =
41
+ envPath('JINN_NETWORK_TOOLS_CLIENT_ROOT', env) ??
42
+ envPath('JINN_CLIENT_ROOT', env);
43
+
44
+ if (explicitServerPath) {
45
+ const cwd = explicitClientRoot
46
+ ? absolutePath(explicitClientRoot, root)
47
+ : dirname(absolutePath(explicitServerPath, root));
48
+ return launcherForServerPath(absolutePath(explicitServerPath, cwd), cwd);
49
+ }
50
+
51
+ const candidateRoots = [
52
+ explicitClientRoot ? absolutePath(explicitClientRoot, root) : undefined,
53
+ // Normal source/package layout: <client>/plugins/network-tools.
54
+ resolve(root, '..', '..'),
55
+ // Allow launching from an unpacked client root or a caller-provided cwd.
56
+ absolutePath(envPath('PWD', env) ?? process.cwd(), root),
57
+ ].filter(Boolean);
58
+
59
+ for (const candidateRoot of candidateRoots) {
60
+ const serverPath = firstExistingServer(candidateRoot);
61
+ if (serverPath) return launcherForServerPath(serverPath, candidateRoot);
62
+ }
63
+
64
+ const searched = candidateRoots.join(', ');
65
+ throw new Error(
66
+ `Unable to find the Jinn client MCP server. Set JINN_NETWORK_TOOLS_MCP_SERVER_PATH or JINN_NETWORK_TOOLS_CLIENT_ROOT. Searched: ${searched}`,
67
+ );
68
+ }
69
+
70
+ export function startJinnClientMcpServer(env = process.env, root = pluginRoot) {
71
+ const launcher = resolveJinnClientMcpLauncher(env, root);
72
+ const child = spawn(launcher.command, launcher.args, {
73
+ cwd: launcher.cwd,
74
+ env,
75
+ stdio: 'inherit',
76
+ });
77
+
78
+ const forwardSignal = (signal) => {
79
+ if (!child.killed) child.kill(signal);
80
+ };
81
+ const forwardSigint = () => forwardSignal('SIGINT');
82
+ const forwardSigterm = () => forwardSignal('SIGTERM');
83
+ process.once('SIGINT', forwardSigint);
84
+ process.once('SIGTERM', forwardSigterm);
85
+
86
+ child.on('exit', (code, signal) => {
87
+ process.off('SIGINT', forwardSigint);
88
+ process.off('SIGTERM', forwardSigterm);
89
+ if (signal) {
90
+ process.kill(process.pid, signal);
91
+ return;
92
+ }
93
+ process.exit(code ?? 1);
94
+ });
95
+
96
+ child.on('error', (err) => {
97
+ console.error(`[network-tools] Failed to launch Jinn client MCP server: ${err.message}`);
98
+ process.exit(1);
99
+ });
100
+ }
101
+
102
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
103
+ try {
104
+ startJinnClientMcpServer();
105
+ } catch (err) {
106
+ const message = err instanceof Error ? err.message : String(err);
107
+ console.error(`[network-tools] ${message}`);
108
+ process.exit(1);
109
+ }
110
+ }