opentool 0.10.3 → 0.10.5

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,176 @@
1
+ declare const DEFAULT_OPENPOND_GATEWAY_URL = "https://gateway.openpond.dev";
2
+ type NewsEventState = "monitoring" | "escalation" | "de_escalation" | "resolved" | "contradiction";
3
+ type NewsSignalValue = "none" | "escalation" | "de_escalation" | "resolved" | "contradiction";
4
+ type NewsPropositionAnswer = "yes" | "no" | "unclear";
5
+ type NewsPropositionStatus = NewsPropositionAnswer | "no_matching_event";
6
+ type NewsContinuationAction = "continue" | "skip" | "pause";
7
+ type NewsPredictionMarketMatchedMarket = {
8
+ marketId: string;
9
+ conditionId?: string | null;
10
+ title: string;
11
+ slug?: string | null;
12
+ category?: string | null;
13
+ yesProbability?: number | null;
14
+ noProbability?: number | null;
15
+ leadingOutcome?: string | null;
16
+ leadingProbability?: number | null;
17
+ volume?: number | null;
18
+ liquidity?: number | null;
19
+ openInterest?: number | null;
20
+ probabilityDelta1h?: number | null;
21
+ probabilityDelta24h?: number | null;
22
+ fetchedAt: string;
23
+ };
24
+ type NewsPredictionMarketContext = {
25
+ matchedMarkets: NewsPredictionMarketMatchedMarket[];
26
+ consensusProbability?: number | null;
27
+ probabilityDelta1h?: number | null;
28
+ probabilityDelta24h?: number | null;
29
+ liquidityWeightedScore?: number | null;
30
+ predictionDisagreementScore?: number | null;
31
+ dataAgeMs?: number | null;
32
+ } | null;
33
+ type NewsSignalEvidence = {
34
+ articleId: string;
35
+ sourceId: string;
36
+ sourceName: string;
37
+ title: string;
38
+ canonicalUrl: string;
39
+ claimType: string;
40
+ claimPolarity: string;
41
+ evidenceConfidence: number;
42
+ evidenceAt: string;
43
+ summary?: string | null;
44
+ contentPreview?: string | null;
45
+ };
46
+ type NewsSignalConfidenceBreakdown = {
47
+ baseScore: number;
48
+ winningBucketScore: number;
49
+ opposingPenalty: number;
50
+ contradictionPenalty: number;
51
+ stateBonus: number;
52
+ finalScore: number;
53
+ };
54
+ type NewsEventSignalPolicy = {
55
+ minConfidence: number;
56
+ minIndependentSources: number;
57
+ minTierASources: number;
58
+ cooldownMinutes: number;
59
+ allowedSourceIds?: string[];
60
+ };
61
+ type NewsEventSignal = {
62
+ eventId: string;
63
+ eventKey: string;
64
+ title: string | null;
65
+ eventState: NewsEventState;
66
+ eventConfidence: number;
67
+ confidenceBreakdown: NewsSignalConfidenceBreakdown;
68
+ signal: NewsSignalValue;
69
+ triggerPassed: boolean;
70
+ policyRisk: "low" | "medium" | "high";
71
+ effectivePolicy: NewsEventSignalPolicy;
72
+ whyNotTriggered: string | null;
73
+ warnings: string[];
74
+ contradictionCount: number;
75
+ supportingSourceCount: number;
76
+ tierASourceCount: number;
77
+ rebuttingSourceSummary: Array<{
78
+ sourceId: string;
79
+ sourceName: string;
80
+ title: string;
81
+ }>;
82
+ evidence: NewsSignalEvidence[];
83
+ dataAgeMs: number | null;
84
+ predictionMarketContext: NewsPredictionMarketContext;
85
+ };
86
+ type NewsPropositionSignal = {
87
+ question: string;
88
+ query: string | null;
89
+ propositionType: string | null;
90
+ propositionStatus: NewsPropositionStatus;
91
+ answer: NewsPropositionAnswer;
92
+ propositionConfidence: number;
93
+ reasoning: string;
94
+ evidenceWindowSummary: string;
95
+ resolvedEventId: string | null;
96
+ resolvedEventKey: string | null;
97
+ resolvedEventTitle: string | null;
98
+ eventState: NewsEventState | null;
99
+ eventConfidence: number | null;
100
+ confidenceBreakdown: NewsSignalConfidenceBreakdown | null;
101
+ supportingEvidence: NewsSignalEvidence[];
102
+ rebuttingEvidence: NewsSignalEvidence[];
103
+ supportingEvidenceArticleIds: string[];
104
+ rebuttingEvidenceArticleIds: string[];
105
+ operatorReviewRecommended: boolean;
106
+ dataAgeMs: number | null;
107
+ predictionMarketContext: NewsPredictionMarketContext;
108
+ };
109
+ type NewsEventSignalRequest = {
110
+ gatewayBase?: string | null;
111
+ fetchImplementation?: typeof fetch;
112
+ query?: string;
113
+ eventKey?: string;
114
+ asOf?: string | Date | null;
115
+ includePredictionMarkets?: boolean;
116
+ ingestOnRequest?: boolean;
117
+ maxAgeHours?: number;
118
+ minConfidence?: number;
119
+ minIndependentSources?: number;
120
+ minTierASources?: number;
121
+ };
122
+ type NewsPropositionSignalRequest = {
123
+ gatewayBase?: string | null;
124
+ fetchImplementation?: typeof fetch;
125
+ question: string;
126
+ query?: string;
127
+ eventKey?: string;
128
+ propositionType?: string;
129
+ asOf?: string | Date | null;
130
+ includePredictionMarkets?: boolean;
131
+ ingestOnRequest?: boolean;
132
+ maxAgeHours?: number;
133
+ candidateLimit?: number;
134
+ };
135
+ type NewsSignalClientConfig = {
136
+ gatewayBase?: string | null;
137
+ fetchImplementation?: typeof fetch;
138
+ };
139
+ type NewsEventContinuationGate = {
140
+ mode: "event";
141
+ minConfidence?: number;
142
+ maxDataAgeMs?: number;
143
+ minIndependentSources?: number;
144
+ minTierASources?: number;
145
+ requireTriggerPassed?: boolean;
146
+ onBlocked?: Exclude<NewsContinuationAction, "continue">;
147
+ };
148
+ type NewsPropositionContinuationGate = {
149
+ mode: "proposition";
150
+ expectedAnswer?: NewsPropositionAnswer;
151
+ minConfidence?: number;
152
+ maxDataAgeMs?: number;
153
+ requireResolvedEvent?: boolean;
154
+ onBlocked?: Exclude<NewsContinuationAction, "continue">;
155
+ };
156
+ type NewsContinuationGate = NewsEventContinuationGate | NewsPropositionContinuationGate;
157
+ type NewsContinuationGateResult = {
158
+ allowed: boolean;
159
+ action: NewsContinuationAction;
160
+ reason: string;
161
+ matchedRule: NewsContinuationGate["mode"];
162
+ blockingFactors: string[];
163
+ };
164
+ declare function resolveNewsGatewayBase(override?: string | null): string;
165
+ declare function fetchNewsEventSignal(params: NewsEventSignalRequest): Promise<NewsEventSignal>;
166
+ declare function fetchNewsPropositionSignal(params: NewsPropositionSignalRequest): Promise<NewsPropositionSignal>;
167
+ declare function evaluateNewsContinuationGate(signal: NewsEventSignal | NewsPropositionSignal, gate: NewsContinuationGate): NewsContinuationGateResult;
168
+ declare class NewsSignalClient {
169
+ private readonly gatewayBase;
170
+ private readonly fetchImplementation;
171
+ constructor(config?: NewsSignalClientConfig);
172
+ eventSignal(params: Omit<NewsEventSignalRequest, "gatewayBase" | "fetchImplementation">): Promise<NewsEventSignal>;
173
+ propositionSignal(params: Omit<NewsPropositionSignalRequest, "gatewayBase" | "fetchImplementation">): Promise<NewsPropositionSignal>;
174
+ }
175
+
176
+ export { DEFAULT_OPENPOND_GATEWAY_URL, type NewsContinuationAction, type NewsContinuationGate, type NewsContinuationGateResult, type NewsEventContinuationGate, type NewsEventSignal, type NewsEventSignalPolicy, type NewsEventSignalRequest, type NewsEventState, type NewsPredictionMarketContext, type NewsPredictionMarketMatchedMarket, type NewsPropositionAnswer, type NewsPropositionContinuationGate, type NewsPropositionSignal, type NewsPropositionSignalRequest, type NewsPropositionStatus, NewsSignalClient, type NewsSignalConfidenceBreakdown, type NewsSignalEvidence, type NewsSignalValue, evaluateNewsContinuationGate, fetchNewsEventSignal, fetchNewsPropositionSignal, resolveNewsGatewayBase };
@@ -0,0 +1,173 @@
1
+ // src/adapters/news/signals.ts
2
+ var DEFAULT_OPENPOND_GATEWAY_URL = "https://gateway.openpond.dev";
3
+ function resolveFetchImplementation(override) {
4
+ const fetchImplementation = override ?? globalThis.fetch;
5
+ if (!fetchImplementation) {
6
+ throw new Error(
7
+ "No fetch implementation available. Provide one via NewsSignalClientConfig.fetchImplementation."
8
+ );
9
+ }
10
+ return fetchImplementation;
11
+ }
12
+ function resolveNewsGatewayBase(override) {
13
+ const value = override ?? process.env.OPENPOND_GATEWAY_URL ?? DEFAULT_OPENPOND_GATEWAY_URL;
14
+ if (typeof value !== "string") {
15
+ throw new Error("OPENPOND_GATEWAY_URL is required.");
16
+ }
17
+ const trimmed = value.trim();
18
+ if (!trimmed) {
19
+ throw new Error("OPENPOND_GATEWAY_URL is required.");
20
+ }
21
+ return trimmed.replace(/\/$/, "");
22
+ }
23
+ function normalizeAsOf(value) {
24
+ if (value == null) return void 0;
25
+ const date = value instanceof Date ? value : new Date(value);
26
+ if (Number.isNaN(date.getTime())) {
27
+ throw new Error("asOf must be a valid ISO-8601 datetime or Date.");
28
+ }
29
+ return date.toISOString();
30
+ }
31
+ async function postGatewayJson(params) {
32
+ const gatewayBase = resolveNewsGatewayBase(params.gatewayBase);
33
+ const fetchImplementation = resolveFetchImplementation(params.fetchImplementation);
34
+ const response = await fetchImplementation(`${gatewayBase}${params.path}`, {
35
+ method: "POST",
36
+ headers: { "content-type": "application/json" },
37
+ body: JSON.stringify(params.body)
38
+ });
39
+ const text = await response.text().catch(() => "");
40
+ let payload = null;
41
+ try {
42
+ payload = text ? JSON.parse(text) : null;
43
+ } catch {
44
+ payload = text;
45
+ }
46
+ if (!response.ok) {
47
+ throw new Error(
48
+ `Gateway request failed (${response.status}) for ${params.path}: ${typeof payload === "string" && payload ? payload : "no_body"}`
49
+ );
50
+ }
51
+ return payload;
52
+ }
53
+ async function fetchNewsEventSignal(params) {
54
+ if (!params.query?.trim() && !params.eventKey?.trim()) {
55
+ throw new Error("query or eventKey is required.");
56
+ }
57
+ return postGatewayJson({
58
+ path: "/v1/news/event-signal",
59
+ gatewayBase: params.gatewayBase,
60
+ fetchImplementation: params.fetchImplementation,
61
+ body: {
62
+ ...params.query?.trim() ? { query: params.query.trim() } : {},
63
+ ...params.eventKey?.trim() ? { eventKey: params.eventKey.trim() } : {},
64
+ ...normalizeAsOf(params.asOf) ? { asOf: normalizeAsOf(params.asOf) } : {},
65
+ ...typeof params.includePredictionMarkets === "boolean" ? { includePredictionMarkets: params.includePredictionMarkets } : {},
66
+ ...typeof params.ingestOnRequest === "boolean" ? { ingestOnRequest: params.ingestOnRequest } : {},
67
+ ...typeof params.maxAgeHours === "number" ? { maxAgeHours: params.maxAgeHours } : {},
68
+ policy: {
69
+ ...typeof params.minConfidence === "number" ? { minConfidence: params.minConfidence } : {},
70
+ ...typeof params.minIndependentSources === "number" ? { minIndependentSources: params.minIndependentSources } : {},
71
+ ...typeof params.minTierASources === "number" ? { minTierASources: params.minTierASources } : {}
72
+ }
73
+ }
74
+ });
75
+ }
76
+ async function fetchNewsPropositionSignal(params) {
77
+ const question = params.question.trim();
78
+ if (!question) {
79
+ throw new Error("question is required.");
80
+ }
81
+ return postGatewayJson({
82
+ path: "/v1/news/event-proposition-signal",
83
+ gatewayBase: params.gatewayBase,
84
+ fetchImplementation: params.fetchImplementation,
85
+ body: {
86
+ question,
87
+ ...params.query?.trim() ? { query: params.query.trim() } : {},
88
+ ...params.eventKey?.trim() ? { eventKey: params.eventKey.trim() } : {},
89
+ ...params.propositionType?.trim() ? { propositionType: params.propositionType.trim() } : {},
90
+ ...normalizeAsOf(params.asOf) ? { asOf: normalizeAsOf(params.asOf) } : {},
91
+ ...typeof params.includePredictionMarkets === "boolean" ? { includePredictionMarkets: params.includePredictionMarkets } : {},
92
+ ...typeof params.ingestOnRequest === "boolean" ? { ingestOnRequest: params.ingestOnRequest } : {},
93
+ ...typeof params.maxAgeHours === "number" ? { maxAgeHours: params.maxAgeHours } : {},
94
+ ...typeof params.candidateLimit === "number" ? { candidateLimit: params.candidateLimit } : {}
95
+ }
96
+ });
97
+ }
98
+ function evaluateNewsContinuationGate(signal, gate) {
99
+ const blockedAction = gate.onBlocked ?? "skip";
100
+ const blockingFactors = [];
101
+ if (gate.mode === "event") {
102
+ const eventSignal = signal;
103
+ if (gate.requireTriggerPassed !== false && !eventSignal.triggerPassed) {
104
+ blockingFactors.push("trigger_not_passed");
105
+ }
106
+ if (typeof gate.minConfidence === "number" && eventSignal.eventConfidence < gate.minConfidence) {
107
+ blockingFactors.push("confidence_below_threshold");
108
+ }
109
+ if (typeof gate.maxDataAgeMs === "number" && typeof eventSignal.dataAgeMs === "number" && eventSignal.dataAgeMs > gate.maxDataAgeMs) {
110
+ blockingFactors.push("signal_too_stale");
111
+ }
112
+ if (typeof gate.minIndependentSources === "number" && eventSignal.supportingSourceCount < gate.minIndependentSources) {
113
+ blockingFactors.push("insufficient_supporting_sources");
114
+ }
115
+ if (typeof gate.minTierASources === "number" && eventSignal.tierASourceCount < gate.minTierASources) {
116
+ blockingFactors.push("insufficient_tier_a_sources");
117
+ }
118
+ } else {
119
+ const propositionSignal = signal;
120
+ if (gate.requireResolvedEvent !== false && propositionSignal.propositionStatus === "no_matching_event") {
121
+ blockingFactors.push("no_matching_event");
122
+ }
123
+ if (gate.expectedAnswer && propositionSignal.answer !== gate.expectedAnswer) {
124
+ blockingFactors.push("unexpected_answer");
125
+ }
126
+ if (typeof gate.minConfidence === "number" && propositionSignal.propositionConfidence < gate.minConfidence) {
127
+ blockingFactors.push("confidence_below_threshold");
128
+ }
129
+ if (typeof gate.maxDataAgeMs === "number" && typeof propositionSignal.dataAgeMs === "number" && propositionSignal.dataAgeMs > gate.maxDataAgeMs) {
130
+ blockingFactors.push("signal_too_stale");
131
+ }
132
+ }
133
+ if (blockingFactors.length === 0) {
134
+ return {
135
+ allowed: true,
136
+ action: "continue",
137
+ reason: "All continuation gate checks passed.",
138
+ matchedRule: gate.mode,
139
+ blockingFactors: []
140
+ };
141
+ }
142
+ return {
143
+ allowed: false,
144
+ action: blockedAction,
145
+ reason: `Blocked by continuation gate: ${blockingFactors.join(", ")}.`,
146
+ matchedRule: gate.mode,
147
+ blockingFactors
148
+ };
149
+ }
150
+ var NewsSignalClient = class {
151
+ constructor(config = {}) {
152
+ this.gatewayBase = resolveNewsGatewayBase(config.gatewayBase);
153
+ this.fetchImplementation = resolveFetchImplementation(config.fetchImplementation);
154
+ }
155
+ eventSignal(params) {
156
+ return fetchNewsEventSignal({
157
+ ...params,
158
+ gatewayBase: this.gatewayBase,
159
+ fetchImplementation: this.fetchImplementation
160
+ });
161
+ }
162
+ propositionSignal(params) {
163
+ return fetchNewsPropositionSignal({
164
+ ...params,
165
+ gatewayBase: this.gatewayBase,
166
+ fetchImplementation: this.fetchImplementation
167
+ });
168
+ }
169
+ };
170
+
171
+ export { DEFAULT_OPENPOND_GATEWAY_URL, NewsSignalClient, evaluateNewsContinuationGate, fetchNewsEventSignal, fetchNewsPropositionSignal, resolveNewsGatewayBase };
172
+ //# sourceMappingURL=index.js.map
173
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/news/signals.ts"],"names":[],"mappings":";AAAA,IAAM,4BAAA,GAA+B;AAiMrC,SAAS,2BAA2B,QAAA,EAAuC;AACzE,EAAA,MAAM,mBAAA,GAAsB,YAAY,UAAA,CAAW,KAAA;AACnD,EAAA,IAAI,CAAC,mBAAA,EAAqB;AACxB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AACA,EAAA,OAAO,mBAAA;AACT;AAEO,SAAS,uBAAuB,QAAA,EAAkC;AACvE,EAAA,MAAM,KAAA,GAAQ,QAAA,IAAY,OAAA,CAAQ,GAAA,CAAI,oBAAA,IAAwB,4BAAA;AAC9D,EAAA,IAAI,OAAO,UAAU,QAAA,EAAU;AAC7B,IAAA,MAAM,IAAI,MAAM,mCAAmC,CAAA;AAAA,EACrD;AACA,EAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAC3B,EAAA,IAAI,CAAC,OAAA,EAAS;AACZ,IAAA,MAAM,IAAI,MAAM,mCAAmC,CAAA;AAAA,EACrD;AACA,EAAA,OAAO,OAAA,CAAQ,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAClC;AAEA,SAAS,cAAc,KAAA,EAAkD;AACvE,EAAA,IAAI,KAAA,IAAS,MAAM,OAAO,MAAA;AAC1B,EAAA,MAAM,OAAO,KAAA,YAAiB,IAAA,GAAO,KAAA,GAAQ,IAAI,KAAK,KAAK,CAAA;AAC3D,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,IAAA,CAAK,OAAA,EAAS,CAAA,EAAG;AAChC,IAAA,MAAM,IAAI,MAAM,iDAAiD,CAAA;AAAA,EACnE;AACA,EAAA,OAAO,KAAK,WAAA,EAA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,aAAa,IAAA,CAAK,IAAA;AAAA,IAClB;AAAA,GACF;AACF;AAEO,IAAM,mBAAN,MAAuB;AAAA,EAI5B,WAAA,CAAY,MAAA,GAAiC,EAAC,EAAG;AAC/C,IAAA,IAAA,CAAK,WAAA,GAAc,sBAAA,CAAuB,MAAA,CAAO,WAAW,CAAA;AAC5D,IAAA,IAAA,CAAK,mBAAA,GAAsB,0BAAA,CAA2B,MAAA,CAAO,mBAAmB,CAAA;AAAA,EAClF;AAAA,EAEA,YACE,MAAA,EACA;AACA,IAAA,OAAO,oBAAA,CAAqB;AAAA,MAC1B,GAAG,MAAA;AAAA,MACH,aAAa,IAAA,CAAK,WAAA;AAAA,MAClB,qBAAqB,IAAA,CAAK;AAAA,KAC3B,CAAA;AAAA,EACH;AAAA,EAEA,kBACE,MAAA,EACA;AACA,IAAA,OAAO,0BAAA,CAA2B;AAAA,MAChC,GAAG,MAAA;AAAA,MACH,aAAa,IAAA,CAAK,WAAA;AAAA,MAClB,qBAAqB,IAAA,CAAK;AAAA,KAC3B,CAAA;AAAA,EACH;AACF","file":"index.js","sourcesContent":["const DEFAULT_OPENPOND_GATEWAY_URL = \"https://gateway.openpond.dev\";\n\nexport type NewsEventState =\n | \"monitoring\"\n | \"escalation\"\n | \"de_escalation\"\n | \"resolved\"\n | \"contradiction\";\n\nexport type NewsSignalValue =\n | \"none\"\n | \"escalation\"\n | \"de_escalation\"\n | \"resolved\"\n | \"contradiction\";\n\nexport type NewsPropositionAnswer = \"yes\" | \"no\" | \"unclear\";\nexport type NewsPropositionStatus = NewsPropositionAnswer | \"no_matching_event\";\nexport type NewsContinuationAction = \"continue\" | \"skip\" | \"pause\";\n\nexport type NewsPredictionMarketMatchedMarket = {\n marketId: string;\n conditionId?: string | null;\n title: string;\n slug?: string | null;\n category?: string | null;\n yesProbability?: number | null;\n noProbability?: number | null;\n leadingOutcome?: string | null;\n leadingProbability?: number | null;\n volume?: number | null;\n liquidity?: number | null;\n openInterest?: number | null;\n probabilityDelta1h?: number | null;\n probabilityDelta24h?: number | null;\n fetchedAt: string;\n};\n\nexport type NewsPredictionMarketContext = {\n matchedMarkets: NewsPredictionMarketMatchedMarket[];\n consensusProbability?: number | null;\n probabilityDelta1h?: number | null;\n probabilityDelta24h?: number | null;\n liquidityWeightedScore?: number | null;\n predictionDisagreementScore?: number | null;\n dataAgeMs?: number | null;\n} | null;\n\nexport type NewsSignalEvidence = {\n articleId: string;\n sourceId: string;\n sourceName: string;\n title: string;\n canonicalUrl: string;\n claimType: string;\n claimPolarity: string;\n evidenceConfidence: number;\n evidenceAt: string;\n summary?: string | null;\n contentPreview?: string | null;\n};\n\nexport type NewsSignalConfidenceBreakdown = {\n baseScore: number;\n winningBucketScore: number;\n opposingPenalty: number;\n contradictionPenalty: number;\n stateBonus: number;\n finalScore: number;\n};\n\nexport type NewsEventSignalPolicy = {\n minConfidence: number;\n minIndependentSources: number;\n minTierASources: number;\n cooldownMinutes: number;\n allowedSourceIds?: string[];\n};\n\nexport type NewsEventSignal = {\n eventId: string;\n eventKey: string;\n title: string | null;\n eventState: NewsEventState;\n eventConfidence: number;\n confidenceBreakdown: NewsSignalConfidenceBreakdown;\n signal: NewsSignalValue;\n triggerPassed: boolean;\n policyRisk: \"low\" | \"medium\" | \"high\";\n effectivePolicy: NewsEventSignalPolicy;\n whyNotTriggered: string | null;\n warnings: string[];\n contradictionCount: number;\n supportingSourceCount: number;\n tierASourceCount: number;\n rebuttingSourceSummary: Array<{\n sourceId: string;\n sourceName: string;\n title: string;\n }>;\n evidence: NewsSignalEvidence[];\n dataAgeMs: number | null;\n predictionMarketContext: NewsPredictionMarketContext;\n};\n\nexport type NewsPropositionSignal = {\n question: string;\n query: string | null;\n propositionType: string | null;\n propositionStatus: NewsPropositionStatus;\n answer: NewsPropositionAnswer;\n propositionConfidence: number;\n reasoning: string;\n evidenceWindowSummary: string;\n resolvedEventId: string | null;\n resolvedEventKey: string | null;\n resolvedEventTitle: string | null;\n eventState: NewsEventState | null;\n eventConfidence: number | null;\n confidenceBreakdown: NewsSignalConfidenceBreakdown | null;\n supportingEvidence: NewsSignalEvidence[];\n rebuttingEvidence: NewsSignalEvidence[];\n supportingEvidenceArticleIds: string[];\n rebuttingEvidenceArticleIds: string[];\n operatorReviewRecommended: boolean;\n dataAgeMs: number | null;\n predictionMarketContext: NewsPredictionMarketContext;\n};\n\nexport type NewsEventSignalRequest = {\n gatewayBase?: string | null;\n fetchImplementation?: typeof fetch;\n query?: string;\n eventKey?: string;\n asOf?: string | Date | null;\n includePredictionMarkets?: boolean;\n ingestOnRequest?: boolean;\n maxAgeHours?: number;\n minConfidence?: number;\n minIndependentSources?: number;\n minTierASources?: number;\n};\n\nexport type NewsPropositionSignalRequest = {\n gatewayBase?: string | null;\n fetchImplementation?: typeof fetch;\n question: string;\n query?: string;\n eventKey?: string;\n propositionType?: string;\n asOf?: string | Date | null;\n includePredictionMarkets?: boolean;\n ingestOnRequest?: boolean;\n maxAgeHours?: number;\n candidateLimit?: number;\n};\n\nexport type NewsSignalClientConfig = {\n gatewayBase?: string | null;\n fetchImplementation?: typeof fetch;\n};\n\nexport type NewsEventContinuationGate = {\n mode: \"event\";\n minConfidence?: number;\n maxDataAgeMs?: number;\n minIndependentSources?: number;\n minTierASources?: number;\n requireTriggerPassed?: boolean;\n onBlocked?: Exclude<NewsContinuationAction, \"continue\">;\n};\n\nexport type NewsPropositionContinuationGate = {\n mode: \"proposition\";\n expectedAnswer?: NewsPropositionAnswer;\n minConfidence?: number;\n maxDataAgeMs?: number;\n requireResolvedEvent?: boolean;\n onBlocked?: Exclude<NewsContinuationAction, \"continue\">;\n};\n\nexport type NewsContinuationGate =\n | NewsEventContinuationGate\n | NewsPropositionContinuationGate;\n\nexport type NewsContinuationGateResult = {\n allowed: boolean;\n action: NewsContinuationAction;\n reason: string;\n matchedRule: NewsContinuationGate[\"mode\"];\n blockingFactors: string[];\n};\n\nfunction resolveFetchImplementation(override?: typeof fetch): typeof fetch {\n const fetchImplementation = override ?? globalThis.fetch;\n if (!fetchImplementation) {\n throw new Error(\n \"No fetch implementation available. Provide one via NewsSignalClientConfig.fetchImplementation.\",\n );\n }\n return fetchImplementation;\n}\n\nexport function resolveNewsGatewayBase(override?: string | null): string {\n const value = override ?? process.env.OPENPOND_GATEWAY_URL ?? DEFAULT_OPENPOND_GATEWAY_URL;\n if (typeof value !== \"string\") {\n throw new Error(\"OPENPOND_GATEWAY_URL is required.\");\n }\n const trimmed = value.trim();\n if (!trimmed) {\n throw new Error(\"OPENPOND_GATEWAY_URL is required.\");\n }\n return trimmed.replace(/\\/$/, \"\");\n}\n\nfunction normalizeAsOf(value?: string | Date | null): string | undefined {\n if (value == null) return undefined;\n const date = value instanceof Date ? value : new Date(value);\n if (Number.isNaN(date.getTime())) {\n throw new Error(\"asOf must be a valid ISO-8601 datetime or Date.\");\n }\n return date.toISOString();\n}\n\nasync function postGatewayJson<T>(params: {\n path: string;\n body: Record<string, unknown>;\n gatewayBase?: string | null | undefined;\n fetchImplementation?: typeof fetch | undefined;\n}): Promise<T> {\n const gatewayBase = resolveNewsGatewayBase(params.gatewayBase);\n const fetchImplementation = resolveFetchImplementation(params.fetchImplementation);\n const response = await fetchImplementation(`${gatewayBase}${params.path}`, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify(params.body),\n });\n const text = await response.text().catch(() => \"\");\n let payload: unknown = null;\n try {\n payload = text ? (JSON.parse(text) as unknown) : null;\n } catch {\n payload = text;\n }\n if (!response.ok) {\n throw new Error(\n `Gateway request failed (${response.status}) for ${params.path}: ${\n typeof payload === \"string\" && payload ? payload : \"no_body\"\n }`,\n );\n }\n return payload as T;\n}\n\nexport async function fetchNewsEventSignal(\n params: NewsEventSignalRequest,\n): Promise<NewsEventSignal> {\n if (!params.query?.trim() && !params.eventKey?.trim()) {\n throw new Error(\"query or eventKey is required.\");\n }\n\n return postGatewayJson<NewsEventSignal>({\n path: \"/v1/news/event-signal\",\n gatewayBase: params.gatewayBase,\n fetchImplementation: params.fetchImplementation,\n body: {\n ...(params.query?.trim() ? { query: params.query.trim() } : {}),\n ...(params.eventKey?.trim() ? { eventKey: params.eventKey.trim() } : {}),\n ...(normalizeAsOf(params.asOf) ? { asOf: normalizeAsOf(params.asOf) } : {}),\n ...(typeof params.includePredictionMarkets === \"boolean\"\n ? { includePredictionMarkets: params.includePredictionMarkets }\n : {}),\n ...(typeof params.ingestOnRequest === \"boolean\"\n ? { ingestOnRequest: params.ingestOnRequest }\n : {}),\n ...(typeof params.maxAgeHours === \"number\" ? { maxAgeHours: params.maxAgeHours } : {}),\n policy: {\n ...(typeof params.minConfidence === \"number\"\n ? { minConfidence: params.minConfidence }\n : {}),\n ...(typeof params.minIndependentSources === \"number\"\n ? { minIndependentSources: params.minIndependentSources }\n : {}),\n ...(typeof params.minTierASources === \"number\"\n ? { minTierASources: params.minTierASources }\n : {}),\n },\n },\n });\n}\n\nexport async function fetchNewsPropositionSignal(\n params: NewsPropositionSignalRequest,\n): Promise<NewsPropositionSignal> {\n const question = params.question.trim();\n if (!question) {\n throw new Error(\"question is required.\");\n }\n\n return postGatewayJson<NewsPropositionSignal>({\n path: \"/v1/news/event-proposition-signal\",\n gatewayBase: params.gatewayBase,\n fetchImplementation: params.fetchImplementation,\n body: {\n question,\n ...(params.query?.trim() ? { query: params.query.trim() } : {}),\n ...(params.eventKey?.trim() ? { eventKey: params.eventKey.trim() } : {}),\n ...(params.propositionType?.trim()\n ? { propositionType: params.propositionType.trim() }\n : {}),\n ...(normalizeAsOf(params.asOf) ? { asOf: normalizeAsOf(params.asOf) } : {}),\n ...(typeof params.includePredictionMarkets === \"boolean\"\n ? { includePredictionMarkets: params.includePredictionMarkets }\n : {}),\n ...(typeof params.ingestOnRequest === \"boolean\"\n ? { ingestOnRequest: params.ingestOnRequest }\n : {}),\n ...(typeof params.maxAgeHours === \"number\" ? { maxAgeHours: params.maxAgeHours } : {}),\n ...(typeof params.candidateLimit === \"number\"\n ? { candidateLimit: params.candidateLimit }\n : {}),\n },\n });\n}\n\nexport function evaluateNewsContinuationGate(\n signal: NewsEventSignal | NewsPropositionSignal,\n gate: NewsContinuationGate,\n): NewsContinuationGateResult {\n const blockedAction = gate.onBlocked ?? \"skip\";\n const blockingFactors: string[] = [];\n\n if (gate.mode === \"event\") {\n const eventSignal = signal as NewsEventSignal;\n if (gate.requireTriggerPassed !== false && !eventSignal.triggerPassed) {\n blockingFactors.push(\"trigger_not_passed\");\n }\n if (\n typeof gate.minConfidence === \"number\" &&\n eventSignal.eventConfidence < gate.minConfidence\n ) {\n blockingFactors.push(\"confidence_below_threshold\");\n }\n if (\n typeof gate.maxDataAgeMs === \"number\" &&\n typeof eventSignal.dataAgeMs === \"number\" &&\n eventSignal.dataAgeMs > gate.maxDataAgeMs\n ) {\n blockingFactors.push(\"signal_too_stale\");\n }\n if (\n typeof gate.minIndependentSources === \"number\" &&\n eventSignal.supportingSourceCount < gate.minIndependentSources\n ) {\n blockingFactors.push(\"insufficient_supporting_sources\");\n }\n if (\n typeof gate.minTierASources === \"number\" &&\n eventSignal.tierASourceCount < gate.minTierASources\n ) {\n blockingFactors.push(\"insufficient_tier_a_sources\");\n }\n } else {\n const propositionSignal = signal as NewsPropositionSignal;\n if (\n gate.requireResolvedEvent !== false &&\n propositionSignal.propositionStatus === \"no_matching_event\"\n ) {\n blockingFactors.push(\"no_matching_event\");\n }\n if (\n gate.expectedAnswer &&\n propositionSignal.answer !== gate.expectedAnswer\n ) {\n blockingFactors.push(\"unexpected_answer\");\n }\n if (\n typeof gate.minConfidence === \"number\" &&\n propositionSignal.propositionConfidence < gate.minConfidence\n ) {\n blockingFactors.push(\"confidence_below_threshold\");\n }\n if (\n typeof gate.maxDataAgeMs === \"number\" &&\n typeof propositionSignal.dataAgeMs === \"number\" &&\n propositionSignal.dataAgeMs > gate.maxDataAgeMs\n ) {\n blockingFactors.push(\"signal_too_stale\");\n }\n }\n\n if (blockingFactors.length === 0) {\n return {\n allowed: true,\n action: \"continue\",\n reason: \"All continuation gate checks passed.\",\n matchedRule: gate.mode,\n blockingFactors: [],\n };\n }\n\n return {\n allowed: false,\n action: blockedAction,\n reason: `Blocked by continuation gate: ${blockingFactors.join(\", \")}.`,\n matchedRule: gate.mode,\n blockingFactors,\n };\n}\n\nexport class NewsSignalClient {\n private readonly gatewayBase: string;\n private readonly fetchImplementation: typeof fetch;\n\n constructor(config: NewsSignalClientConfig = {}) {\n this.gatewayBase = resolveNewsGatewayBase(config.gatewayBase);\n this.fetchImplementation = resolveFetchImplementation(config.fetchImplementation);\n }\n\n eventSignal(\n params: Omit<NewsEventSignalRequest, \"gatewayBase\" | \"fetchImplementation\">,\n ) {\n return fetchNewsEventSignal({\n ...params,\n gatewayBase: this.gatewayBase,\n fetchImplementation: this.fetchImplementation,\n });\n }\n\n propositionSignal(\n params: Omit<NewsPropositionSignalRequest, \"gatewayBase\" | \"fetchImplementation\">,\n ) {\n return fetchNewsPropositionSignal({\n ...params,\n gatewayBase: this.gatewayBase,\n fetchImplementation: this.fetchImplementation,\n });\n }\n}\n\nexport { DEFAULT_OPENPOND_GATEWAY_URL };\n"]}
package/dist/index.d.ts CHANGED
@@ -4,9 +4,10 @@ export { B as BuildConfig, d as BuildMetadata, C as ConnectedApp, e as CronSpec,
4
4
  export { C as CurrencySpec, D as DEFAULT_FACILITATOR, a as DefineX402PaymentConfig, P as PAYMENT_HEADERS, R as RequireX402PaymentOptions, b as RequireX402PaymentOutcome, c as RequireX402PaymentSuccess, S as SUPPORTED_CURRENCIES, d as X402FacilitatorConfig, X as X402Payment, e as X402PaymentContext, f as X402PaymentDefinition, g as X402PaymentRequiredError, h as X402VerificationResult, i as defineX402Payment, j as getX402PaymentContext, r as requireX402Payment, w as withX402Payment } from './payment-orkZA9se.js';
5
5
  export { EIP3009Authorization, X402BrowserClient, X402BrowserClientConfig, X402Client, X402ClientConfig, X402PayRequest, X402PayResult, payX402, payX402WithWallet } from './x402/index.js';
6
6
  export { DEFAULT_CHAIN, DEFAULT_TOKENS, chains, getRpcUrl, registry, tokens, wallet, walletToolkit } from './wallet/index.js';
7
- export { DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, HyperliquidAbstraction, HyperliquidAccountMode, HyperliquidApiError, HyperliquidApproveBuilderFeeOptions, HyperliquidApproveBuilderFeeResponse, HyperliquidBar, HyperliquidBarResolution, HyperliquidBuilderApprovalError, HyperliquidBuilderApprovalRecordInput, HyperliquidBuilderFee, HyperliquidChain, HyperliquidClearinghouseState, HyperliquidDepositResult, HyperliquidEnvironment, HyperliquidExchangeClient, HyperliquidExchangeResponse, HyperliquidGrouping, HyperliquidGuardError, HyperliquidInfoClient, HyperliquidMarketIdentityInput, HyperliquidMarketType, HyperliquidOrderIntent, HyperliquidOrderOptions, HyperliquidOrderResponse, HyperliquidOrderStatus, HyperliquidPerpMarketInfo, HyperliquidProfileAsset, HyperliquidProfileAssetInput, HyperliquidProfileChain, HyperliquidSpotMarketInfo, HyperliquidStoreNetwork, HyperliquidTermsError, HyperliquidTermsRecordInput, HyperliquidTickSize, HyperliquidTimeInForce, HyperliquidTriggerOptions, HyperliquidTriggerType, HyperliquidWithdrawResult, MarketIdentity, NonceSource, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidBars, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, getHyperliquidMaxBuilderFee, isHyperliquidSpotSymbol, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidMetaSymbol, normalizeSpotTokenName, parseSpotPairSymbol, placeHyperliquidOrder, placeHyperliquidTwapOrder, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, resolveHyperliquidAbstractionFromMode, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidErrorDetail, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolveSpotMidCandidates, resolveSpotTokenCandidates, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid } from './adapters/hyperliquid/index.js';
8
- import { c as WalletFullContext } from './types-3w880w_t.js';
9
- export { C as ChainMetadata, g as ChainReference, a as ChainTokenMap, H as Hex, h as HexAddress, R as RpcProviderOptions, i as RpcUrlResolver, T as TokenMetadata, j as TurnkeyOptions, k as TurnkeySignWith, l as WalletBaseContext, m as WalletContext, n as WalletOptions, o as WalletOptionsBase, b as WalletPrivateKeyOptions, p as WalletProviderType, f as WalletReadonlyContext, e as WalletReadonlyOptions, W as WalletRegistry, q as WalletSendTransactionParams, r as WalletSignerContext, s as WalletTransferParams, d as WalletTurnkeyOptions } from './types-3w880w_t.js';
7
+ export { DEFAULT_HYPERLIQUID_CADENCE_CRON, DEFAULT_HYPERLIQUID_MARKET_SLIPPAGE_BPS, HyperliquidAbstraction, HyperliquidAccountMode, HyperliquidApiError, HyperliquidApproveBuilderFeeOptions, HyperliquidApproveBuilderFeeResponse, HyperliquidBar, HyperliquidBarResolution, HyperliquidBuilderApprovalError, HyperliquidBuilderApprovalRecordInput, HyperliquidBuilderFee, HyperliquidCadence, HyperliquidChain, HyperliquidClearinghouseState, HyperliquidDcaNormalizedEntry, HyperliquidDcaSymbolEntry, HyperliquidDcaSymbolInput, HyperliquidDepositResult, HyperliquidEnvironment, HyperliquidExchangeClient, HyperliquidExchangeResponse, HyperliquidExecutionMode, HyperliquidGrouping, HyperliquidGuardError, HyperliquidIndicatorBar, HyperliquidInfoClient, HyperliquidMarketIdentityInput, HyperliquidMarketType, HyperliquidOrderIntent, HyperliquidOrderOptions, HyperliquidOrderResponse, HyperliquidOrderStatus, HyperliquidPerpMarketInfo, HyperliquidProfileAsset, HyperliquidProfileAssetInput, HyperliquidProfileChain, HyperliquidResolution, HyperliquidScheduleUnit, HyperliquidSpotMarketInfo, HyperliquidStoreNetwork, HyperliquidTargetSizeConfig, HyperliquidTargetSizeExecution, HyperliquidTermsError, HyperliquidTermsRecordInput, HyperliquidTickSize, HyperliquidTimeInForce, HyperliquidTradePlan, HyperliquidTradeSignal, HyperliquidTriggerOptions, HyperliquidTriggerType, HyperliquidWithdrawResult, MarketIdentity, __hyperliquidInternals, __hyperliquidMarketDataInternals, approveHyperliquidBuilderFee, batchModifyHyperliquidOrders, buildHyperliquidMarketIdentity, buildHyperliquidProfileAssets, buildHyperliquidSpotUsdPriceMap, cancelAllHyperliquidOrders, cancelHyperliquidOrders, cancelHyperliquidOrdersByCloid, cancelHyperliquidTwapOrder, clampHyperliquidAbs, clampHyperliquidFloat, clampHyperliquidInt, computeHyperliquidMarketIocLimitPrice, createHyperliquidSubAccount, createMonotonicNonceFactory, depositToHyperliquidBridge, extractHyperliquidDex, extractHyperliquidOrderIds, fetchHyperliquidAllMids, fetchHyperliquidAssetCtxs, fetchHyperliquidBars, fetchHyperliquidClearinghouseState, fetchHyperliquidFrontendOpenOrders, fetchHyperliquidHistoricalOrders, fetchHyperliquidMeta, fetchHyperliquidMetaAndAssetCtxs, fetchHyperliquidOpenOrders, fetchHyperliquidOrderStatus, fetchHyperliquidPerpMarketInfo, fetchHyperliquidPreTransferCheck, fetchHyperliquidSizeDecimals, fetchHyperliquidSpotAccountValue, fetchHyperliquidSpotAssetCtxs, fetchHyperliquidSpotClearinghouseState, fetchHyperliquidSpotMarketInfo, fetchHyperliquidSpotMeta, fetchHyperliquidSpotMetaAndAssetCtxs, fetchHyperliquidSpotTickSize, fetchHyperliquidSpotUsdPriceMap, fetchHyperliquidTickSize, fetchHyperliquidUserFills, fetchHyperliquidUserFillsByTime, fetchHyperliquidUserRateLimit, formatHyperliquidMarketablePrice, formatHyperliquidOrderSize, formatHyperliquidPrice, formatHyperliquidSize, getHyperliquidMaxBuilderFee, isHyperliquidSpotSymbol, modifyHyperliquidOrder, normalizeHyperliquidBaseSymbol, normalizeHyperliquidDcaEntries, normalizeHyperliquidIndicatorBars, normalizeHyperliquidMetaSymbol, normalizeSpotTokenName, parseHyperliquidJson, parseSpotPairSymbol, placeHyperliquidOrder, placeHyperliquidTwapOrder, planHyperliquidTrade, readHyperliquidAccountValue, readHyperliquidNumber, readHyperliquidPerpPosition, readHyperliquidPerpPositionSize, readHyperliquidSpotAccountValue, readHyperliquidSpotBalance, readHyperliquidSpotBalanceSize, recordHyperliquidBuilderApproval, recordHyperliquidTermsAcceptance, reserveHyperliquidRequestWeight, resolveHyperliquidAbstractionFromMode, resolveHyperliquidBudgetUsd, resolveHyperliquidCadenceCron, resolveHyperliquidCadenceFromResolution, resolveHyperliquidChain, resolveHyperliquidChainConfig, resolveHyperliquidDcaSymbolEntries, resolveHyperliquidErrorDetail, resolveHyperliquidHourlyInterval, resolveHyperliquidIntervalCron, resolveHyperliquidLeverageMode, resolveHyperliquidMaxPerRunUsd, resolveHyperliquidOrderRef, resolveHyperliquidOrderSymbol, resolveHyperliquidPair, resolveHyperliquidPerpSymbol, resolveHyperliquidProfileChain, resolveHyperliquidRpcEnvVar, resolveHyperliquidScheduleEvery, resolveHyperliquidScheduleUnit, resolveHyperliquidSpotSymbol, resolveHyperliquidStoreNetwork, resolveHyperliquidSymbol, resolveHyperliquidTargetSize, resolveSpotMidCandidates, resolveSpotTokenCandidates, roundHyperliquidPriceToTick, scheduleHyperliquidCancel, sendHyperliquidSpot, setHyperliquidAccountAbstractionMode, setHyperliquidDexAbstraction, setHyperliquidPortfolioMargin, transferHyperliquidSubAccount, updateHyperliquidIsolatedMargin, updateHyperliquidLeverage, withdrawFromHyperliquid } from './adapters/hyperliquid/index.js';
8
+ import { b as WalletFullContext } from './types-rAQrDrah.js';
9
+ export { a as ChainMetadata, C as ChainReference, c as ChainTokenMap, i as Hex, H as HexAddress, N as NonceSource, R as RpcProviderOptions, j as RpcUrlResolver, k as TokenMetadata, l as TurnkeyOptions, T as TurnkeySignWith, m as WalletBaseContext, n as WalletContext, o as WalletOptions, p as WalletOptionsBase, e as WalletPrivateKeyOptions, W as WalletProviderType, h as WalletReadonlyContext, g as WalletReadonlyOptions, d as WalletRegistry, q as WalletSendTransactionParams, r as WalletSignerContext, s as WalletTransferParams, f as WalletTurnkeyOptions } from './types-rAQrDrah.js';
10
+ export { DEFAULT_OPENPOND_GATEWAY_URL, NewsContinuationAction, NewsContinuationGate, NewsContinuationGateResult, NewsEventContinuationGate, NewsEventSignal, NewsEventSignalPolicy, NewsEventSignalRequest, NewsEventState, NewsPredictionMarketContext, NewsPredictionMarketMatchedMarket, NewsPropositionAnswer, NewsPropositionContinuationGate, NewsPropositionSignal, NewsPropositionSignalRequest, NewsPropositionStatus, NewsSignalClient, NewsSignalConfidenceBreakdown, NewsSignalEvidence, NewsSignalValue, evaluateNewsContinuationGate, fetchNewsEventSignal, fetchNewsPropositionSignal, resolveNewsGatewayBase } from './adapters/news/index.js';
10
11
  export { AIAbortError, AIClientConfig, AIError, AIFetchError, AIRequestMetadata, AIResponseError, ChatCompletionChoice, ChatCompletionLogProbs, ChatCompletionResponse, ChatCompletionUsage, ChatMessage, ChatMessageContentPart, ChatMessageContentPartImageUrl, ChatMessageContentPartText, ChatMessageRole, DEFAULT_BASE_URL, DEFAULT_MODEL, DEFAULT_TIMEOUT_MS, FunctionToolDefinition, GenerateTextOptions, GenerateTextResult, GenerationParameters, JsonSchema, ResolvedAIClientConfig, ResponseErrorDetails, StreamTextOptions, StreamTextResult, StreamingEventHandlers, ToolChoice, ToolDefinition, ToolExecutionPolicy, WEBSEARCH_TOOL_DEFINITION, WEBSEARCH_TOOL_NAME, WebSearchOptions, createAIClient, ensureTextContent, flattenMessageContent, generateText, getModelConfig, isStreamingSupported, isToolCallingSupported, listModels, normalizeModelName, resolveConfig, resolveToolset, streamText } from './ai/index.js';
11
12
  export { AgentDigestRequest, MyToolsResponse, StoreAction, StoreError, StoreEventInput, StoreEventLevel, StoreMode, StoreOptions, StoreResponse, StoreRetrieveParams, StoreRetrieveResult, StoreSimulationConfig, ToolExecuteRequest, ToolExecuteResponse, executeTool, getMyPerformance, getMyTools, postAgentDigest, retrieve, store } from './store/index.js';
12
13
  import { z, ZodSchema } from 'zod';
@@ -337,6 +338,8 @@ declare function fetchPolymarketPriceHistory(params: {
337
338
  environment?: PolymarketEnvironment;
338
339
  }): Promise<PolymarketPriceHistoryPoint[]>;
339
340
 
341
+ declare const BACKTEST_DECISION_MODE: "backtest_decisions";
342
+ type BacktestMode = typeof BACKTEST_DECISION_MODE;
340
343
  declare const backtestDecisionRequestSchema: z.ZodObject<{
341
344
  mode: z.ZodLiteral<"backtest_decisions">;
342
345
  source: z.ZodOptional<z.ZodString>;
@@ -361,6 +364,34 @@ declare function estimateCountBack(params: {
361
364
  minCountBack?: number;
362
365
  bufferBars?: number;
363
366
  }): number;
367
+ declare function resolveBacktestMode(value: unknown): BacktestMode | null;
368
+ type ResolvedBacktestWindow = {
369
+ fromSeconds?: number;
370
+ toSeconds?: number;
371
+ countBack: number;
372
+ };
373
+ declare function resolveBacktestWindow(params: {
374
+ fallbackCountBack: number;
375
+ lookbackDays?: unknown;
376
+ resolution: BacktestResolution;
377
+ from?: unknown;
378
+ to?: unknown;
379
+ timeframeStart?: unknown;
380
+ timeframeEnd?: unknown;
381
+ minCountBack?: number;
382
+ bufferBars?: number;
383
+ }): ResolvedBacktestWindow;
384
+ declare function resolveBacktestAccountValueUsd(value: unknown): number | undefined;
385
+ type BacktestDecisionSeriesInput = {
386
+ symbol?: string;
387
+ timeframeStart?: string;
388
+ timeframeEnd?: string;
389
+ from?: number;
390
+ to?: number;
391
+ lookbackDays?: number;
392
+ accountValueUsd?: number;
393
+ };
394
+ declare function buildBacktestDecisionSeriesInput(request: Partial<BacktestDecisionRequest>): BacktestDecisionSeriesInput;
364
395
 
365
396
  interface CreateMcpAdapterOptions {
366
397
  name: string;
@@ -374,4 +405,4 @@ interface CreateMcpAdapterOptions {
374
405
  declare function createMcpAdapter(options: CreateMcpAdapterOptions): (rawArguments: unknown) => Promise<ToolResponse>;
375
406
  declare function responseToToolResponse(response: Response): Promise<ToolResponse>;
376
407
 
377
- export { type BacktestDecisionRequest, type BacktestResolution, InternalToolDefinition, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, type PolymarketApiCredentials, PolymarketApiError, type PolymarketApiKeyResponse, PolymarketAuthError, type PolymarketEnvironment, PolymarketExchangeClient, PolymarketInfoClient, type PolymarketMarket, type PolymarketOrderIntent, type PolymarketOrderType, type PolymarketOrderbook, type PolymarketPlaceOrderResponse, type PolymarketPriceHistoryPoint, type PolymarketSide, type PolymarketSignatureType, type PolymarketSignedOrderPayload, ToolResponse, WalletFullContext, backtestDecisionRequestSchema, buildHmacSignature, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllPolymarketOrders, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, createDevServer, createMcpAdapter, createPolymarketApiKey, createStdioServer, derivePolymarketApiKey, estimateCountBack, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, normalizeNumberArrayish, normalizeStringArrayish, parseTimeToSeconds, placePolymarketOrder, resolutionToSeconds, resolveExchangeAddress, resolvePolymarketBaseUrl, resolveRuntimePath, responseToToolResponse };
408
+ export { BACKTEST_DECISION_MODE, type BacktestDecisionRequest, type BacktestDecisionSeriesInput, type BacktestMode, type BacktestResolution, InternalToolDefinition, POLYMARKET_CHAIN_ID, POLYMARKET_CLOB_AUTH_DOMAIN, POLYMARKET_CLOB_DOMAIN, POLYMARKET_ENDPOINTS, POLYMARKET_EXCHANGE_ADDRESSES, type PolymarketApiCredentials, PolymarketApiError, type PolymarketApiKeyResponse, PolymarketAuthError, type PolymarketEnvironment, PolymarketExchangeClient, PolymarketInfoClient, type PolymarketMarket, type PolymarketOrderIntent, type PolymarketOrderType, type PolymarketOrderbook, type PolymarketPlaceOrderResponse, type PolymarketPriceHistoryPoint, type PolymarketSide, type PolymarketSignatureType, type PolymarketSignedOrderPayload, type ResolvedBacktestWindow, ToolResponse, WalletFullContext, backtestDecisionRequestSchema, buildBacktestDecisionSeriesInput, buildHmacSignature, buildL1Headers, buildL2Headers, buildPolymarketOrderAmounts, buildSignedOrderPayload, cancelAllPolymarketOrders, cancelMarketPolymarketOrders, cancelPolymarketOrder, cancelPolymarketOrders, createDevServer, createMcpAdapter, createPolymarketApiKey, createStdioServer, derivePolymarketApiKey, estimateCountBack, fetchPolymarketMarket, fetchPolymarketMarkets, fetchPolymarketMidpoint, fetchPolymarketOrderbook, fetchPolymarketPrice, fetchPolymarketPriceHistory, normalizeNumberArrayish, normalizeStringArrayish, parseTimeToSeconds, placePolymarketOrder, resolutionToSeconds, resolveBacktestAccountValueUsd, resolveBacktestMode, resolveBacktestWindow, resolveExchangeAddress, resolvePolymarketBaseUrl, resolveRuntimePath, responseToToolResponse };