investing 0.1.113 → 0.1.114
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -139
- package/dist/{archiver-web.es-fg4bLLZa.cjs → archiver-web.es-BLUo1_F6.cjs} +1 -1
- package/dist/{archiver-web.es-B69gABHP.js → archiver-web.es-xMR6Vwo7.js} +1 -1
- package/dist/db/index.d.ts +17 -0
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/schema.d.ts +17 -0
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/index-Cigf2mm8.cjs +13 -0
- package/dist/index-D3i3mNfo.js +15 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/predictos/index.d.ts +7 -22
- package/dist/predictos/index.d.ts.map +1 -1
- package/dist/stocks/index.d.ts +0 -1
- package/dist/stocks/index.d.ts.map +1 -1
- package/dist/stocks/quote-cache-service.d.ts +11 -2
- package/dist/stocks/quote-cache-service.d.ts.map +1 -1
- package/dist/stocks/unified-quote-service.d.ts +15 -6
- package/dist/stocks/unified-quote-service.d.ts.map +1 -1
- package/package.json +6 -45
- package/dist/bookmakerAnalysis-Bfo1zUVm.js +0 -1
- package/dist/bookmakerAnalysis-CHn1W8uX.cjs +0 -1
- package/dist/callGrok-D0D7zBHK.js +0 -1
- package/dist/callGrok-DWO719mN.cjs +0 -1
- package/dist/events-BJOyGWeU.cjs +0 -1
- package/dist/events-OvBb8rgy.js +0 -1
- package/dist/index-D7fsk2gy.js +0 -15
- package/dist/index-_V1Ql5Es.cjs +0 -13
- package/dist/polymarket-updown-15-limit-order-bot-DCC8HE9Z.cjs +0 -1
- package/dist/polymarket-updown-15-limit-order-bot-Dv5oGAF4.js +0 -1
- package/dist/predictos/agents/bookmaker-agent.d.ts +0 -8
- package/dist/predictos/agents/bookmaker-agent.d.ts.map +0 -1
- package/dist/predictos/agents/event-analysis-agent.d.ts +0 -8
- package/dist/predictos/agents/event-analysis-agent.d.ts.map +0 -1
- package/dist/predictos/agents/index.d.ts +0 -21
- package/dist/predictos/agents/index.d.ts.map +0 -1
- package/dist/predictos/agents/index.js +0 -1
- package/dist/predictos/agents/index.mjs +0 -1
- package/dist/predictos/agents/mapper-agent.d.ts +0 -17
- package/dist/predictos/agents/mapper-agent.d.ts.map +0 -1
- package/dist/predictos/agents/polyfactual-research.d.ts +0 -47
- package/dist/predictos/agents/polyfactual-research.d.ts.map +0 -1
- package/dist/predictos/agents/polymarket-position-tracker.d.ts +0 -31
- package/dist/predictos/agents/polymarket-position-tracker.d.ts.map +0 -1
- package/dist/predictos/agents/polymarket-put-order.d.ts +0 -88
- package/dist/predictos/agents/polymarket-put-order.d.ts.map +0 -1
- package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts +0 -92
- package/dist/predictos/agents/polymarket-updown-15-limit-order-bot.d.ts.map +0 -1
- package/dist/predictos/agents/x402-seller.d.ts +0 -34
- package/dist/predictos/agents/x402-seller.d.ts.map +0 -1
- package/dist/predictos/ai/callBlockRun.d.ts +0 -54
- package/dist/predictos/ai/callBlockRun.d.ts.map +0 -1
- package/dist/predictos/ai/callGrok.d.ts +0 -22
- package/dist/predictos/ai/callGrok.d.ts.map +0 -1
- package/dist/predictos/ai/callOpenAI.d.ts +0 -19
- package/dist/predictos/ai/callOpenAI.d.ts.map +0 -1
- package/dist/predictos/ai/http.d.ts +0 -19
- package/dist/predictos/ai/http.d.ts.map +0 -1
- package/dist/predictos/ai/index.d.ts +0 -19
- package/dist/predictos/ai/index.d.ts.map +0 -1
- package/dist/predictos/ai/index.js +0 -1
- package/dist/predictos/ai/index.mjs +0 -1
- package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts +0 -12
- package/dist/predictos/ai/prompts/analyzeEventMarkets.d.ts.map +0 -1
- package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts +0 -14
- package/dist/predictos/ai/prompts/arbitrageAnalysis.d.ts.map +0 -1
- package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts +0 -17
- package/dist/predictos/ai/prompts/bookmakerAnalysis.d.ts.map +0 -1
- package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts +0 -18
- package/dist/predictos/ai/prompts/searchQueryGenerator.d.ts.map +0 -1
- package/dist/predictos/ai/types.d.ts +0 -214
- package/dist/predictos/ai/types.d.ts.map +0 -1
- package/dist/predictos/arbitrage.d.ts +0 -8
- package/dist/predictos/arbitrage.d.ts.map +0 -1
- package/dist/predictos/arbitrage.js +0 -1
- package/dist/predictos/arbitrage.mjs +0 -1
- package/dist/predictos/clients/polyfactual.d.ts +0 -72
- package/dist/predictos/clients/polyfactual.d.ts.map +0 -1
- package/dist/predictos/clients/polymarket.d.ts +0 -283
- package/dist/predictos/clients/polymarket.d.ts.map +0 -1
- package/dist/predictos/clients/x402.d.ts +0 -213
- package/dist/predictos/clients/x402.d.ts.map +0 -1
- package/dist/predictos/data/kalshi.d.ts +0 -66
- package/dist/predictos/data/kalshi.d.ts.map +0 -1
- package/dist/predictos/data/kalshi.js +0 -1
- package/dist/predictos/data/kalshi.mjs +0 -1
- package/dist/predictos/data/polymarket.d.ts +0 -105
- package/dist/predictos/data/polymarket.d.ts.map +0 -1
- package/dist/predictos/data/polymarket.js +0 -1
- package/dist/predictos/data/polymarket.mjs +0 -1
- package/dist/predictos/events.d.ts +0 -9
- package/dist/predictos/events.d.ts.map +0 -1
- package/dist/predictos/index.js +0 -1
- package/dist/predictos/index.mjs +0 -1
- package/dist/predictos/types.d.ts +0 -408
- package/dist/predictos/types.d.ts.map +0 -1
- package/dist/searchQueryGenerator-DIIs9xw5.js +0 -1
- package/dist/searchQueryGenerator-rCVblXJS.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"x402-seller.d.ts","sourceRoot":"","sources":["../../../src/predictos/agents/x402-seller.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAQH,OAAO,KAAK,EAEV,mBAAmB,EAEnB,sBAAsB,EACvB,MAAM,oBAAoB,CAAC;AAE5B,mDAAmD;AACnD,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iCAAiC;IACjC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAElC,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+BAA+B;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,uCAAuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,uEAAuE;AACvE,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,mBAAmB,GAAG,sBAAsB,GAAG,yBAAyB,CAAC,CAwKnF"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { BlockRunResponseResult } from './types.js';
|
|
2
|
-
export declare const BLOCKRUN_MODELS: {
|
|
3
|
-
readonly "blockrun/gpt-4o": "openai/gpt-4o";
|
|
4
|
-
readonly "blockrun/gpt-4o-mini": "openai/gpt-4o-mini";
|
|
5
|
-
readonly "blockrun/gpt-4.1": "openai/gpt-4.1";
|
|
6
|
-
readonly "blockrun/gpt-5": "openai/gpt-5";
|
|
7
|
-
readonly "blockrun/o1": "openai/o1";
|
|
8
|
-
readonly "blockrun/o3-mini": "openai/o3-mini";
|
|
9
|
-
readonly "blockrun/claude-sonnet-4": "anthropic/claude-sonnet-4";
|
|
10
|
-
readonly "blockrun/claude-opus-4": "anthropic/claude-opus-4";
|
|
11
|
-
readonly "blockrun/claude-haiku": "anthropic/claude-3-5-haiku-latest";
|
|
12
|
-
readonly "blockrun/grok-3": "xai/grok-3";
|
|
13
|
-
readonly "blockrun/grok-3-fast": "xai/grok-3-fast";
|
|
14
|
-
readonly "blockrun/grok-3-mini": "xai/grok-3-mini";
|
|
15
|
-
readonly "blockrun/gemini-2.5-pro": "google/gemini-2.5-pro-preview-06-05";
|
|
16
|
-
readonly "blockrun/gemini-2.5-flash": "google/gemini-2.5-flash-preview-05-20";
|
|
17
|
-
readonly "blockrun/deepseek-chat": "deepseek/deepseek-chat";
|
|
18
|
-
readonly "blockrun/deepseek-reasoner": "deepseek/deepseek-reasoner";
|
|
19
|
-
readonly "blockrun/qwen-max": "qwen/qwen-max";
|
|
20
|
-
readonly "blockrun/qwen-plus": "qwen/qwen-plus";
|
|
21
|
-
};
|
|
22
|
-
/** Options for {@link callBlockRunResponses}. */
|
|
23
|
-
export interface BlockRunCallOptions {
|
|
24
|
-
/** Base-chain wallet private key; falls back to `process.env.BLOCKRUN_WALLET_KEY`. */
|
|
25
|
-
walletKey?: string;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Check if a model name is a BlockRun model
|
|
29
|
-
*/
|
|
30
|
-
export declare function isBlockRunModel(model: string): boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Call BlockRun AI with x402 micropayment.
|
|
33
|
-
*
|
|
34
|
-
* @param message User message to send
|
|
35
|
-
* @param systemPrompt System prompt for the AI
|
|
36
|
-
* @param responseFormat Response format type (e.g., "json_object")
|
|
37
|
-
* @param model BlockRun model to use (e.g., "blockrun/gpt-4o", "blockrun/claude-sonnet-4")
|
|
38
|
-
* @param maxRetries Maximum number of retries on failure
|
|
39
|
-
* @param enableSearch Enable xAI Live Search (for Grok models only)
|
|
40
|
-
* @param options Optional wallet key (falls back to `BLOCKRUN_WALLET_KEY`)
|
|
41
|
-
* @returns BlockRun response result with usage and cost tracking
|
|
42
|
-
*/
|
|
43
|
-
export declare function callBlockRunResponses(message: string, systemPrompt: string, responseFormat: string, model?: string, maxRetries?: number, enableSearch?: boolean, options?: BlockRunCallOptions): Promise<BlockRunResponseResult>;
|
|
44
|
-
/**
|
|
45
|
-
* List available BlockRun models.
|
|
46
|
-
* This is a convenience function - actual model list from BlockRun API.
|
|
47
|
-
*/
|
|
48
|
-
export declare function listBlockRunModels(): Promise<Array<{
|
|
49
|
-
id: string;
|
|
50
|
-
name: string;
|
|
51
|
-
provider: string;
|
|
52
|
-
description: string;
|
|
53
|
-
}>>;
|
|
54
|
-
//# sourceMappingURL=callBlockRun.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callBlockRun.d.ts","sourceRoot":"","sources":["../../../src/predictos/ai/callBlockRun.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AAmBpB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;CAyBlB,CAAC;AAEX,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtD;AA8HD;;;;;;;;;;;GAWG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,MAA0B,EACjC,UAAU,GAAE,MAAU,EACtB,YAAY,GAAE,OAAe,EAC7B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,sBAAsB,CAAC,CAwLjC;AA4DD;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,KAAK,CAAC;IACxD,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC,CAAC,CA4BF"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { GrokResponseResult } from './types.js';
|
|
2
|
-
/** Tool types available for Grok models */
|
|
3
|
-
export type GrokToolType = "x_search" | "web_search";
|
|
4
|
-
/** Options for {@link callGrokResponses}. */
|
|
5
|
-
export interface GrokCallOptions {
|
|
6
|
-
/** API key; falls back to `process.env.XAI_API_KEY`. */
|
|
7
|
-
apiKey?: string;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Call Grok AI with the Responses API.
|
|
11
|
-
*
|
|
12
|
-
* @param message User message to send
|
|
13
|
-
* @param systemPrompt System prompt for the AI
|
|
14
|
-
* @param responseFormat Response format type (e.g., "json_object")
|
|
15
|
-
* @param model Grok model to use
|
|
16
|
-
* @param maxRetries Maximum number of retries on failure
|
|
17
|
-
* @param tools Optional array of tools to enable (x_search, web_search)
|
|
18
|
-
* @param options Optional API key (falls back to `XAI_API_KEY`)
|
|
19
|
-
* @returns Grok response result
|
|
20
|
-
*/
|
|
21
|
-
export declare function callGrokResponses(message: string, systemPrompt: string, responseFormat: string, model?: string, maxRetries?: number, tools?: GrokToolType[], options?: GrokCallOptions): Promise<GrokResponseResult>;
|
|
22
|
-
//# sourceMappingURL=callGrok.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callGrok.d.ts","sourceRoot":"","sources":["../../../src/predictos/ai/callGrok.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGzE,2CAA2C;AAC3C,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,YAAY,CAAC;AAErD,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,MAAkC,EACzC,UAAU,GAAE,MAAU,EACtB,KAAK,CAAC,EAAE,YAAY,EAAE,EACtB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,kBAAkB,CAAC,CA8F7B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { OpenAIResponseResult } from './types.js';
|
|
2
|
-
/** Options for {@link callOpenAIResponses}. */
|
|
3
|
-
export interface OpenAICallOptions {
|
|
4
|
-
/** API key; falls back to `process.env.OPENAI_API_KEY`. */
|
|
5
|
-
apiKey?: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Call OpenAI API with the Responses API.
|
|
9
|
-
*
|
|
10
|
-
* @param message User message to send
|
|
11
|
-
* @param systemPrompt System prompt for the AI
|
|
12
|
-
* @param responseFormat Response format type (e.g., "json_object")
|
|
13
|
-
* @param model OpenAI model to use
|
|
14
|
-
* @param maxRetries Maximum number of retries on failure
|
|
15
|
-
* @param options Optional API key (falls back to `OPENAI_API_KEY`)
|
|
16
|
-
* @returns OpenAI response result
|
|
17
|
-
*/
|
|
18
|
-
export declare function callOpenAIResponses(message: string, systemPrompt: string, responseFormat: string, model?: string, maxRetries?: number, options?: OpenAICallOptions): Promise<OpenAIResponseResult>;
|
|
19
|
-
//# sourceMappingURL=callOpenAI.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callOpenAI.d.ts","sourceRoot":"","sources":["../../../src/predictos/ai/callOpenAI.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAwB,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAG7E,+CAA+C;AAC/C,MAAM,WAAW,iBAAiB;IAChC,2DAA2D;IAC3D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,MAAkB,EACzB,UAAU,GAAE,MAAU,EACtB,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,oBAAoB,CAAC,CA6F/B"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared HTTP helpers used by the AI provider clients: retry classification,
|
|
3
|
-
* sleep, and a fetch wrapper with a timeout.
|
|
4
|
-
*
|
|
5
|
-
* Uses the global `fetch`/`AbortController` available in Node 18+.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Check if an error is retryable (network errors, timeouts, etc.)
|
|
9
|
-
*/
|
|
10
|
-
export declare function isRetryableError(error: unknown): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Sleep for a given number of milliseconds
|
|
13
|
-
*/
|
|
14
|
-
export declare function sleep(ms: number): Promise<void>;
|
|
15
|
-
/**
|
|
16
|
-
* Make a fetch request with a timeout.
|
|
17
|
-
*/
|
|
18
|
-
export declare function fetchWithTimeout(url: string, options: RequestInit, timeoutMs?: number): Promise<Response>;
|
|
19
|
-
//# sourceMappingURL=http.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/predictos/ai/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAaxD;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE/C;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,EACpB,SAAS,GAAE,MAAe,GACzB,OAAO,CAAC,QAAQ,CAAC,CAkBnB"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI provider clients and prompt builders for the PredictOS pipeline.
|
|
3
|
-
*/
|
|
4
|
-
export * from './types.js';
|
|
5
|
-
export * from './http.js';
|
|
6
|
-
export { callOpenAIResponses } from './callOpenAI.js';
|
|
7
|
-
export type { OpenAICallOptions } from './callOpenAI.js';
|
|
8
|
-
export { callGrokResponses } from './callGrok.js';
|
|
9
|
-
export type { GrokToolType, GrokCallOptions } from './callGrok.js';
|
|
10
|
-
export { callBlockRunResponses, isBlockRunModel, listBlockRunModels, BLOCKRUN_MODELS, } from './callBlockRun.js';
|
|
11
|
-
export type { BlockRunCallOptions } from './callBlockRun.js';
|
|
12
|
-
export { analyzeEventMarketsPrompt } from './prompts/analyzeEventMarkets.js';
|
|
13
|
-
export { bookmakerAnalysisPrompt } from './prompts/bookmakerAnalysis.js';
|
|
14
|
-
export type { AgentAnalysis, X402ResultInput as BookmakerX402ResultInput } from './prompts/bookmakerAnalysis.js';
|
|
15
|
-
export { arbitrageAnalysisPrompt } from './prompts/arbitrageAnalysis.js';
|
|
16
|
-
export type { ArbitragePromptInput } from './prompts/arbitrageAnalysis.js';
|
|
17
|
-
export { searchQueryGeneratorPrompt } from './prompts/searchQueryGenerator.js';
|
|
18
|
-
export type { SearchQueryGeneratorInput } from './prompts/searchQueryGenerator.js';
|
|
19
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/predictos/ai/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,eAAe,EACf,kBAAkB,EAClB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EAAE,aAAa,EAAE,eAAe,IAAI,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AACjH,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,YAAY,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAC/E,YAAY,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../callGrok-DWO719mN.cjs"),r=require("../../bookmakerAnalysis-CHn1W8uX.cjs"),s=require("../../searchQueryGenerator-rCVblXJS.cjs");exports.callGrokResponses=e.callGrokResponses,exports.callOpenAIResponses=e.callOpenAIResponses,exports.fetchWithTimeout=e.fetchWithTimeout,exports.isRetryableError=e.isRetryableError,exports.sleep=e.sleep,exports.BLOCKRUN_MODELS=r.BLOCKRUN_MODELS,exports.analyzeEventMarketsPrompt=r.analyzeEventMarketsPrompt,exports.bookmakerAnalysisPrompt=r.bookmakerAnalysisPrompt,exports.callBlockRunResponses=r.callBlockRunResponses,exports.isBlockRunModel=r.isBlockRunModel,exports.listBlockRunModels=r.listBlockRunModels,exports.arbitrageAnalysisPrompt=s.arbitrageAnalysisPrompt,exports.searchQueryGeneratorPrompt=s.searchQueryGeneratorPrompt;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as s,a,f as e,i as r,s as o}from"../../callGrok-D0D7zBHK.js";import{B as l,a as t,b as n,c as i,i as m,l as p}from"../../bookmakerAnalysis-Bfo1zUVm.js";import{a as c,s as k}from"../../searchQueryGenerator-DIIs9xw5.js";export{l as BLOCKRUN_MODELS,t as analyzeEventMarketsPrompt,c as arbitrageAnalysisPrompt,n as bookmakerAnalysisPrompt,i as callBlockRunResponses,s as callGrokResponses,a as callOpenAIResponses,e as fetchWithTimeout,m as isBlockRunModel,r as isRetryableError,p as listBlockRunModels,k as searchQueryGeneratorPrompt,o as sleep};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Tool types for source requirements */
|
|
2
|
-
type ToolType = 'x_search' | 'web_search';
|
|
3
|
-
/**
|
|
4
|
-
* Generates prompts for analyzing event markets from any prediction market platform.
|
|
5
|
-
* Accepts raw market JSON data (Kalshi, Polymarket, etc.) without normalization.
|
|
6
|
-
*/
|
|
7
|
-
export declare function analyzeEventMarketsPrompt(markets: unknown[], eventIdentifier: string, question: string, pmType: string, tools?: ToolType[], userCommand?: string): {
|
|
8
|
-
systemPrompt: string;
|
|
9
|
-
userPrompt: string;
|
|
10
|
-
};
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=analyzeEventMarkets.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"analyzeEventMarkets.d.ts","sourceRoot":"","sources":["../../../../src/predictos/ai/prompts/analyzeEventMarkets.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,KAAK,QAAQ,GAAG,UAAU,GAAG,YAAY,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,yBAAyB,CACrC,OAAO,EAAE,OAAO,EAAE,EAClB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,QAAQ,EAAE,EAClB,WAAW,CAAC,EAAE,MAAM,GACrB;IACC,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACtB,CA4GA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ArbitrageMarketData } from '../../types.js';
|
|
2
|
-
export interface ArbitragePromptInput {
|
|
3
|
-
sourceMarket: ArbitrageMarketData;
|
|
4
|
-
searchResults: unknown[];
|
|
5
|
-
searchPlatform: 'polymarket' | 'kalshi';
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Generates prompts for analyzing potential arbitrage opportunities across prediction markets
|
|
9
|
-
*/
|
|
10
|
-
export declare function arbitrageAnalysisPrompt(input: ArbitragePromptInput): {
|
|
11
|
-
systemPrompt: string;
|
|
12
|
-
userPrompt: string;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=arbitrageAnalysis.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arbitrageAnalysis.d.ts","sourceRoot":"","sources":["../../../../src/predictos/ai/prompts/arbitrageAnalysis.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,mBAAmB,CAAC;IAClC,aAAa,EAAE,OAAO,EAAE,CAAC;IACzB,cAAc,EAAE,YAAY,GAAG,QAAQ,CAAC;CACzC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,GAAG;IACpE,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAmHA"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MarketAnalysis } from '../../types.js';
|
|
2
|
-
export interface AgentAnalysis {
|
|
3
|
-
agentId: string;
|
|
4
|
-
model: string;
|
|
5
|
-
analysis: MarketAnalysis;
|
|
6
|
-
}
|
|
7
|
-
export interface X402ResultInput {
|
|
8
|
-
agentId: string;
|
|
9
|
-
seller: string;
|
|
10
|
-
query: string;
|
|
11
|
-
response: string;
|
|
12
|
-
}
|
|
13
|
-
export declare function bookmakerAnalysisPrompt(analyses: AgentAnalysis[], x402Results: X402ResultInput[], eventIdentifier: string, pmType: string): {
|
|
14
|
-
systemPrompt: string;
|
|
15
|
-
userPrompt: string;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=bookmakerAnalysis.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bookmakerAnalysis.d.ts","sourceRoot":"","sources":["../../../../src/predictos/ai/prompts/bookmakerAnalysis.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAErD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,aAAa,EAAE,EACzB,WAAW,EAAE,eAAe,EAAE,EAC9B,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,GACb;IACD,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAyGA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* AI prompt for generating optimized search queries
|
|
3
|
-
* Takes an event/market title and extracts 1-2 most important keywords for cross-platform search
|
|
4
|
-
*/
|
|
5
|
-
export interface SearchQueryGeneratorInput {
|
|
6
|
-
title: string;
|
|
7
|
-
sourcePlatform: 'polymarket' | 'kalshi';
|
|
8
|
-
targetPlatform: 'polymarket' | 'kalshi';
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Generates a prompt for the search query generator agent
|
|
12
|
-
* The agent should return a 1-2 word search query
|
|
13
|
-
*/
|
|
14
|
-
export declare function searchQueryGeneratorPrompt(input: SearchQueryGeneratorInput): {
|
|
15
|
-
systemPrompt: string;
|
|
16
|
-
userPrompt: string;
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=searchQueryGenerator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"searchQueryGenerator.d.ts","sourceRoot":"","sources":["../../../../src/predictos/ai/prompts/searchQueryGenerator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,YAAY,GAAG,QAAQ,CAAC;IACxC,cAAc,EAAE,YAAY,GAAG,QAAQ,CAAC;CACzC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,yBAAyB,GAAG;IAC5E,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB,CAmCA"}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
export interface BlockRunRequestMessage {
|
|
2
|
-
role: "user" | "assistant" | "system";
|
|
3
|
-
content: string;
|
|
4
|
-
}
|
|
5
|
-
export interface BlockRunRequestPayload {
|
|
6
|
-
model: string;
|
|
7
|
-
messages: BlockRunRequestMessage[];
|
|
8
|
-
temperature?: number | null;
|
|
9
|
-
top_p?: number | null;
|
|
10
|
-
max_tokens?: number | null;
|
|
11
|
-
response_format?: {
|
|
12
|
-
type: string;
|
|
13
|
-
};
|
|
14
|
-
search?: boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface BlockRunPaymentRequirements {
|
|
17
|
-
x402Version?: number;
|
|
18
|
-
scheme: string;
|
|
19
|
-
network: string;
|
|
20
|
-
asset: string;
|
|
21
|
-
amount?: string;
|
|
22
|
-
maxAmountRequired?: string;
|
|
23
|
-
payTo: string;
|
|
24
|
-
maxTimeoutSeconds?: number;
|
|
25
|
-
extra?: {
|
|
26
|
-
name?: string;
|
|
27
|
-
version?: string;
|
|
28
|
-
[key: string]: unknown;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export interface BlockRunUsage {
|
|
32
|
-
input_tokens: number;
|
|
33
|
-
output_tokens: number;
|
|
34
|
-
total_tokens: number;
|
|
35
|
-
}
|
|
36
|
-
export interface BlockRunOutputText {
|
|
37
|
-
type: "output_text";
|
|
38
|
-
text: string;
|
|
39
|
-
}
|
|
40
|
-
export interface BlockRunMessage {
|
|
41
|
-
content: BlockRunOutputText[];
|
|
42
|
-
id: string;
|
|
43
|
-
role: "assistant";
|
|
44
|
-
type: "message";
|
|
45
|
-
status: "completed" | "failed" | "pending";
|
|
46
|
-
}
|
|
47
|
-
export interface BlockRunResponseResult {
|
|
48
|
-
created_at: number;
|
|
49
|
-
id: string;
|
|
50
|
-
model: string;
|
|
51
|
-
object: "response";
|
|
52
|
-
output: BlockRunMessage[];
|
|
53
|
-
temperature: number | null;
|
|
54
|
-
top_p: number | null;
|
|
55
|
-
usage: BlockRunUsage;
|
|
56
|
-
status: "completed" | "failed" | "pending";
|
|
57
|
-
blockrun?: {
|
|
58
|
-
paymentCost?: string;
|
|
59
|
-
citations?: string[];
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export interface GrokRequestInput {
|
|
63
|
-
role: "user" | "assistant" | "system";
|
|
64
|
-
content: string;
|
|
65
|
-
}
|
|
66
|
-
export interface GrokRequestTool {
|
|
67
|
-
type: "web_search" | "x_search";
|
|
68
|
-
}
|
|
69
|
-
export interface GrokRequestPayload {
|
|
70
|
-
model: string;
|
|
71
|
-
input: GrokRequestInput[];
|
|
72
|
-
tools?: GrokRequestTool[];
|
|
73
|
-
tool_choice?: "auto" | "none" | "required";
|
|
74
|
-
temperature?: number | null;
|
|
75
|
-
top_p?: number | null;
|
|
76
|
-
max_output_tokens?: number | null;
|
|
77
|
-
parallel_tool_calls?: boolean;
|
|
78
|
-
store?: boolean;
|
|
79
|
-
previous_response_id?: string | null;
|
|
80
|
-
response_format?: {
|
|
81
|
-
type: string;
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
export interface OpenAIRequestInput {
|
|
85
|
-
role: "user" | "assistant" | "system";
|
|
86
|
-
content: string;
|
|
87
|
-
}
|
|
88
|
-
export interface OpenAIRequestPayload {
|
|
89
|
-
model: string;
|
|
90
|
-
input: OpenAIRequestInput[];
|
|
91
|
-
temperature?: number | null;
|
|
92
|
-
top_p?: number | null;
|
|
93
|
-
max_output_tokens?: number | null;
|
|
94
|
-
store?: boolean;
|
|
95
|
-
text?: {
|
|
96
|
-
format: {
|
|
97
|
-
type: string;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
export interface OpenAIUsage {
|
|
102
|
-
input_tokens: number;
|
|
103
|
-
input_tokens_details?: {
|
|
104
|
-
cached_tokens?: number;
|
|
105
|
-
};
|
|
106
|
-
output_tokens: number;
|
|
107
|
-
output_tokens_details?: {
|
|
108
|
-
reasoning_tokens?: number;
|
|
109
|
-
};
|
|
110
|
-
total_tokens: number;
|
|
111
|
-
}
|
|
112
|
-
export interface OpenAIOutputText {
|
|
113
|
-
type: "output_text";
|
|
114
|
-
text: string;
|
|
115
|
-
annotations?: unknown[];
|
|
116
|
-
}
|
|
117
|
-
export interface OpenAIMessage {
|
|
118
|
-
content: OpenAIOutputText[];
|
|
119
|
-
id: string;
|
|
120
|
-
role: "assistant";
|
|
121
|
-
type: "message";
|
|
122
|
-
status: "completed" | "failed" | "pending";
|
|
123
|
-
}
|
|
124
|
-
export type OpenAIOutputItem = OpenAIMessage;
|
|
125
|
-
export interface OpenAIResponseResult {
|
|
126
|
-
created_at: number;
|
|
127
|
-
id: string;
|
|
128
|
-
model: string;
|
|
129
|
-
object: "response";
|
|
130
|
-
output: OpenAIOutputItem[];
|
|
131
|
-
temperature: number | null;
|
|
132
|
-
top_p: number | null;
|
|
133
|
-
usage: OpenAIUsage;
|
|
134
|
-
status: "completed" | "failed" | "pending";
|
|
135
|
-
}
|
|
136
|
-
export interface GrokUsage {
|
|
137
|
-
input_tokens: number;
|
|
138
|
-
input_tokens_details?: {
|
|
139
|
-
cached_tokens?: number;
|
|
140
|
-
};
|
|
141
|
-
output_tokens: number;
|
|
142
|
-
output_tokens_details?: {
|
|
143
|
-
reasoning_tokens?: number;
|
|
144
|
-
};
|
|
145
|
-
total_tokens: number;
|
|
146
|
-
num_sources_used?: number;
|
|
147
|
-
num_server_side_tools_used?: number;
|
|
148
|
-
server_side_tool_usage_details?: {
|
|
149
|
-
web_search_calls?: number;
|
|
150
|
-
x_search_calls?: number;
|
|
151
|
-
code_interpreter_calls?: number;
|
|
152
|
-
file_search_calls?: number;
|
|
153
|
-
mcp_calls?: number;
|
|
154
|
-
document_search_calls?: number;
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
export interface GrokReasoning {
|
|
158
|
-
effort?: string | null;
|
|
159
|
-
summary?: string | null;
|
|
160
|
-
}
|
|
161
|
-
export interface GrokTextFormat {
|
|
162
|
-
format: {
|
|
163
|
-
type: "text";
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
export interface GrokAnnotation {
|
|
167
|
-
type: "url_citation";
|
|
168
|
-
url: string;
|
|
169
|
-
}
|
|
170
|
-
export interface GrokOutputText {
|
|
171
|
-
type: "output_text";
|
|
172
|
-
text: string;
|
|
173
|
-
logprobs?: unknown[];
|
|
174
|
-
annotations?: GrokAnnotation[];
|
|
175
|
-
}
|
|
176
|
-
export interface GrokCustomToolCall {
|
|
177
|
-
call_id: string;
|
|
178
|
-
input: string;
|
|
179
|
-
name: string;
|
|
180
|
-
type: "custom_tool_call";
|
|
181
|
-
id: string;
|
|
182
|
-
status: "completed" | "failed" | "pending";
|
|
183
|
-
}
|
|
184
|
-
export interface GrokMessage {
|
|
185
|
-
content: GrokOutputText[];
|
|
186
|
-
id: string;
|
|
187
|
-
role: "assistant";
|
|
188
|
-
type: "message";
|
|
189
|
-
status: "completed" | "failed" | "pending";
|
|
190
|
-
}
|
|
191
|
-
export type GrokOutputItem = GrokCustomToolCall | GrokMessage;
|
|
192
|
-
export interface GrokResponseResult {
|
|
193
|
-
created_at: number;
|
|
194
|
-
id: string;
|
|
195
|
-
max_output_tokens: number | null;
|
|
196
|
-
model: string;
|
|
197
|
-
object: "response";
|
|
198
|
-
output: GrokOutputItem[];
|
|
199
|
-
parallel_tool_calls: boolean;
|
|
200
|
-
previous_response_id: string | null;
|
|
201
|
-
reasoning: GrokReasoning;
|
|
202
|
-
temperature: number | null;
|
|
203
|
-
text: GrokTextFormat;
|
|
204
|
-
tool_choice: "auto" | "none" | "required";
|
|
205
|
-
tools: GrokRequestTool[];
|
|
206
|
-
top_p: number | null;
|
|
207
|
-
usage: GrokUsage;
|
|
208
|
-
user: string | null;
|
|
209
|
-
incomplete_details: unknown | null;
|
|
210
|
-
status: "completed" | "failed" | "pending";
|
|
211
|
-
store: boolean;
|
|
212
|
-
metadata: Record<string, unknown>;
|
|
213
|
-
}
|
|
214
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/predictos/ai/types.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,sBAAsB,EAAE,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,eAAe,CAAC,EAAE;QAChB,IAAI,EAAE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.js';
|
|
2
|
-
/**
|
|
3
|
-
* Find a cross-platform arbitrage opportunity for a prediction market URL.
|
|
4
|
-
*
|
|
5
|
-
* @throws Error on invalid input or when the source event cannot be fetched.
|
|
6
|
-
*/
|
|
7
|
-
export declare function findArbitrage(request: ArbitrageRequest, config?: AIConfig & DataConfig): Promise<ArbitrageResult>;
|
|
8
|
-
//# sourceMappingURL=arbitrage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arbitrage.d.ts","sourceRoot":"","sources":["../../src/predictos/arbitrage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAaH,OAAO,KAAK,EACV,QAAQ,EAIR,gBAAgB,EAChB,eAAe,EACf,UAAU,EACX,MAAM,YAAY,CAAC;AA4fpB;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,gBAAgB,EACzB,MAAM,GAAE,QAAQ,GAAG,UAAe,GACjC,OAAO,CAAC,eAAe,CAAC,CA2G1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../searchQueryGenerator-rCVblXJS.cjs"),t=require("../callGrok-DWO719mN.cjs"),r=require("./data/kalshi.js"),s="https://gamma-api.polymarket.com",o=["gpt-5.2","gpt-5.1","gpt-5-nano","gpt-4.1","gpt-4.1-mini"];function a(e){return o.includes(e)||e.startsWith("gpt-")}function n(e,t){return"polymarket"===e?`https://polymarket.com/event/${t}`:`https://kalshi.com/events/${t}`}exports.findArbitrage=async function(o,i={}){const c=Date.now(),{url:l,model:m}=o;if(!l)throw new Error("Missing required parameter: 'url'");if(!m)throw new Error("Missing required parameter: 'model'");const u=function(e){const t=e.toLowerCase();return t.includes("polymarket.com")?"polymarket":t.includes("kalshi.com")?"kalshi":null}(l);if(!u)throw new Error("Invalid URL. Must be a Polymarket or Kalshi market URL.");let p=null;const y="polymarket"===u?"kalshi":"polymarket";if("polymarket"===u){const e=function(e){try{const t=new URL(e).pathname.split("/").filter(e=>e);return"event"===t[0]&&t.length>=2?t[1]:null}catch{return null}}(l);if(!e)throw new Error("Could not extract event slug from Polymarket URL");p=await async function(e){try{const t=`${s}/events/slug/${e}`,r=await fetch(t);if(!r.ok)return console.error("Polymarket event fetch error:",r.status),null;const o=await r.json(),a=[];if(o.markets&&Array.isArray(o.markets))for(const e of o.markets){const t=e.question||e.title||"";let r=50;if(e.outcomePrices)try{const t=JSON.parse(e.outcomePrices);r=100*parseFloat(t[0])}catch{}t&&a.push({title:t,yesPrice:r})}return{eventTitle:o.title||e.replace(/-/g," "),markets:a,source:"polymarket",identifier:o.slug||e}}catch(t){return console.error("Error fetching Polymarket event:",t),null}}(e)}else{const e=function(e){try{const t=new URL(e).pathname.split("/").filter(e=>e);return("markets"===t[0]||"events"===t[0])&&t.length>=2?(t.length>=4?t[t.length-1]:t[1]).toUpperCase():null}catch{return null}}(l);if(!e)throw new Error("Could not extract ticker from Kalshi URL");p=await async function(e,t){try{const s=await r.dflowRequest(`/event/${e}`,{params:{withNestedMarkets:!0},apiKey:t}),o=[];if(s.markets&&Array.isArray(s.markets))for(const e of s.markets){const t=e.yesSubTitle||"";let r=50;if(e.yesBid&&e.yesAsk){r=(parseFloat(e.yesBid)+parseFloat(e.yesAsk))/2*100}else e.yesBid?r=100*parseFloat(e.yesBid):e.yesAsk&&(r=100*parseFloat(e.yesAsk));t&&o.push({title:t,yesPrice:r})}return{eventTitle:s.title||e,markets:o,source:"kalshi",identifier:e}}catch(s){return console.error("Error fetching Kalshi event:",s),null}}(e,i.dflowApiKey)}if(!p||0===p.markets.length)throw new Error(`Could not fetch event data from ${u}. The event may not exist or have no markets.`);const f=await async function(r,s,o,n,i){const{systemPrompt:c,userPrompt:l}=e.searchQueryGeneratorPrompt({title:r,sourcePlatform:s,targetPlatform:o});let m;if(a(n)){const e=await t.callOpenAIResponses(l,c,"text",n,1,{apiKey:i.openaiApiKey}),r=[];for(const t of e.output)if("message"===t.type){const e=t;r.push(...e.content)}m=r.map(e=>e.text).filter(e=>void 0!==e).join("").trim()}else{const e=await t.callGrokResponses(l,c,"text",n,1,void 0,{apiKey:i.xaiApiKey}),r=[];for(const t of e.output)if("message"===t.type){const e=t;r.push(...e.content)}m=r.map(e=>e.text).filter(e=>void 0!==e).join("").trim()}return m.replace(/['"]/g,"").trim().split(/\s+/).slice(0,2).join(" ")}(p.eventTitle,u,y,m,i);let k;if(k="polymarket"===y?await async function(e){try{const t=`${s}/public-search?q=${encodeURIComponent(e)}&events_status=open`,r=await fetch(t);if(!r.ok)return console.error("Polymarket search error:",r.status),[];const o=await r.json(),a=[];if(o.events&&Array.isArray(o.events))for(const e of o.events){const t=e.slug;if(e.markets&&Array.isArray(e.markets))for(const r of e.markets){const e=r.question||r.title||"";let s=50;if(r.outcomePrices)try{const e=JSON.parse(r.outcomePrices);s=100*parseFloat(e[0])}catch{}e&&a.push({title:e,yesPrice:s,identifier:t})}}return a}catch(t){return console.error("Error searching Polymarket:",t),[]}}(f):await async function(e,t){try{const s=await r.dflowRequest("/search",{params:{q:e,event_status:"open",withNestedMarkets:!0},apiKey:t}),o=[];if(s.events&&Array.isArray(s.events))for(const e of s.events){const t=e.ticker;if(e.markets&&Array.isArray(e.markets))for(const r of e.markets){const e=r.yesSubTitle||r.title||"";let s=50;if(r.yesAsk&&r.yesBid){s=(parseFloat(r.yesAsk)+parseFloat(r.yesBid))/2*100}else r.yesAsk?s=100*parseFloat(r.yesAsk):r.yesBid&&(s=100*parseFloat(r.yesBid));e&&o.push({title:e,yesPrice:s,identifier:t})}}return o}catch(s){return console.error("Error searching Kalshi:",s),[]}}(f,i.dflowApiKey),0===k.length){const e={source:u,name:p.eventTitle,identifier:p.identifier,yesPrice:p.markets[0]?.yesPrice||50,noPrice:100-(p.markets[0]?.yesPrice||50),url:n(u,p.identifier),rawData:{eventTitle:p.eventTitle,markets:p.markets}};return{analysis:{isSameMarket:!1,sameMarketConfidence:0,marketComparisonReasoning:`No matching markets found on ${y} for query "${f}"`,polymarketData:"polymarket"===u?e:void 0,kalshiData:"kalshi"===u?e:void 0,arbitrage:{hasArbitrage:!1},summary:`No matching markets found on ${y}. Cannot determine arbitrage opportunity.`,risks:["No matching market found on the other platform"],recommendation:"Try a different event or check if the market exists on both platforms."},model:"none",sourceMarket:u,searchedMarket:y,processingTimeMs:Date.now()-c}}const{analysis:h,modelUsed:d,tokensUsed:g}=await async function(r,s,o,i,c){const l={source:r.source,name:r.eventTitle,identifier:r.identifier,yesPrice:r.markets[0]?.yesPrice||50,noPrice:100-(r.markets[0]?.yesPrice||50),url:n(r.source,r.identifier)};l.rawData={eventTitle:r.eventTitle,markets:r.markets};const{systemPrompt:m,userPrompt:u}=e.arbitrageAnalysisPrompt({sourceMarket:l,searchResults:s,searchPlatform:o});let p,y,f;if(a(i)){const e=await t.callOpenAIResponses(u,m,"json_object",i,3,{apiKey:c.openaiApiKey});y=e.model,f=e.usage?.total_tokens;const r=[];for(const t of e.output)if("message"===t.type){const e=t;r.push(...e.content)}p=r.map(e=>e.text).filter(e=>void 0!==e).join("\n")}else{const e=await t.callGrokResponses(u,m,"json_object",i,3,void 0,{apiKey:c.xaiApiKey});y=e.model,f=e.usage?.total_tokens;const r=[];for(const t of e.output)if("message"===t.type){const e=t;r.push(...e.content)}p=r.map(e=>e.text).filter(e=>void 0!==e).join("\n")}const k=JSON.parse(p);return{analysis:{isSameMarket:k.isSameMarket,sameMarketConfidence:k.sameMarketConfidence,marketComparisonReasoning:k.marketComparisonReasoning,polymarketData:"polymarket"===r.source?l:k.matchedMarket||void 0,kalshiData:"kalshi"===r.source?l:k.matchedMarket||void 0,arbitrage:k.arbitrage,summary:k.summary,risks:k.risks,recommendation:k.recommendation},modelUsed:y,tokensUsed:f}}(p,k,y,m,i);return{analysis:h,model:d,tokensUsed:g,sourceMarket:u,searchedMarket:y,processingTimeMs:Date.now()-c}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{s as e,a as t}from"../searchQueryGenerator-DIIs9xw5.js";import{a as r,c as s}from"../callGrok-D0D7zBHK.js";import{dflowRequest as o}from"./data/kalshi.mjs";const a="https://gamma-api.polymarket.com",n=["gpt-5.2","gpt-5.1","gpt-5-nano","gpt-4.1","gpt-4.1-mini"];function i(e){return n.includes(e)||e.startsWith("gpt-")}function c(e,t){return"polymarket"===e?`https://polymarket.com/event/${t}`:`https://kalshi.com/events/${t}`}async function l(n,l={}){const m=Date.now(),{url:u,model:p}=n;if(!u)throw new Error("Missing required parameter: 'url'");if(!p)throw new Error("Missing required parameter: 'model'");const y=function(e){const t=e.toLowerCase();return t.includes("polymarket.com")?"polymarket":t.includes("kalshi.com")?"kalshi":null}(u);if(!y)throw new Error("Invalid URL. Must be a Polymarket or Kalshi market URL.");let f=null;const k="polymarket"===y?"kalshi":"polymarket";if("polymarket"===y){const e=function(e){try{const t=new URL(e).pathname.split("/").filter(e=>e);return"event"===t[0]&&t.length>=2?t[1]:null}catch{return null}}(u);if(!e)throw new Error("Could not extract event slug from Polymarket URL");f=await async function(e){try{const t=`${a}/events/slug/${e}`,r=await fetch(t);if(!r.ok)return console.error("Polymarket event fetch error:",r.status),null;const s=await r.json(),o=[];if(s.markets&&Array.isArray(s.markets))for(const e of s.markets){const t=e.question||e.title||"";let r=50;if(e.outcomePrices)try{const t=JSON.parse(e.outcomePrices);r=100*parseFloat(t[0])}catch{}t&&o.push({title:t,yesPrice:r})}return{eventTitle:s.title||e.replace(/-/g," "),markets:o,source:"polymarket",identifier:s.slug||e}}catch(t){return console.error("Error fetching Polymarket event:",t),null}}(e)}else{const e=function(e){try{const t=new URL(e).pathname.split("/").filter(e=>e);return("markets"===t[0]||"events"===t[0])&&t.length>=2?(t.length>=4?t[t.length-1]:t[1]).toUpperCase():null}catch{return null}}(u);if(!e)throw new Error("Could not extract ticker from Kalshi URL");f=await async function(e,t){try{const r=await o(`/event/${e}`,{params:{withNestedMarkets:!0},apiKey:t}),s=[];if(r.markets&&Array.isArray(r.markets))for(const e of r.markets){const t=e.yesSubTitle||"";let r=50;if(e.yesBid&&e.yesAsk){r=(parseFloat(e.yesBid)+parseFloat(e.yesAsk))/2*100}else e.yesBid?r=100*parseFloat(e.yesBid):e.yesAsk&&(r=100*parseFloat(e.yesAsk));t&&s.push({title:t,yesPrice:r})}return{eventTitle:r.title||e,markets:s,source:"kalshi",identifier:e}}catch(r){return console.error("Error fetching Kalshi event:",r),null}}(e,l.dflowApiKey)}if(!f||0===f.markets.length)throw new Error(`Could not fetch event data from ${y}. The event may not exist or have no markets.`);const h=await async function(t,o,a,n,c){const{systemPrompt:l,userPrompt:m}=e({title:t,sourcePlatform:o,targetPlatform:a});let u;if(i(n)){const e=await r(m,l,"text",n,1,{apiKey:c.openaiApiKey}),t=[];for(const r of e.output)if("message"===r.type){const e=r;t.push(...e.content)}u=t.map(e=>e.text).filter(e=>void 0!==e).join("").trim()}else{const e=await s(m,l,"text",n,1,void 0,{apiKey:c.xaiApiKey}),t=[];for(const r of e.output)if("message"===r.type){const e=r;t.push(...e.content)}u=t.map(e=>e.text).filter(e=>void 0!==e).join("").trim()}return u.replace(/['"]/g,"").trim().split(/\s+/).slice(0,2).join(" ")}(f.eventTitle,y,k,p,l);let d;if(d="polymarket"===k?await async function(e){try{const t=`${a}/public-search?q=${encodeURIComponent(e)}&events_status=open`,r=await fetch(t);if(!r.ok)return console.error("Polymarket search error:",r.status),[];const s=await r.json(),o=[];if(s.events&&Array.isArray(s.events))for(const e of s.events){const t=e.slug;if(e.markets&&Array.isArray(e.markets))for(const r of e.markets){const e=r.question||r.title||"";let s=50;if(r.outcomePrices)try{const e=JSON.parse(r.outcomePrices);s=100*parseFloat(e[0])}catch{}e&&o.push({title:e,yesPrice:s,identifier:t})}}return o}catch(t){return console.error("Error searching Polymarket:",t),[]}}(h):await async function(e,t){try{const r=await o("/search",{params:{q:e,event_status:"open",withNestedMarkets:!0},apiKey:t}),s=[];if(r.events&&Array.isArray(r.events))for(const e of r.events){const t=e.ticker;if(e.markets&&Array.isArray(e.markets))for(const r of e.markets){const e=r.yesSubTitle||r.title||"";let o=50;if(r.yesAsk&&r.yesBid){o=(parseFloat(r.yesAsk)+parseFloat(r.yesBid))/2*100}else r.yesAsk?o=100*parseFloat(r.yesAsk):r.yesBid&&(o=100*parseFloat(r.yesBid));e&&s.push({title:e,yesPrice:o,identifier:t})}}return s}catch(r){return console.error("Error searching Kalshi:",r),[]}}(h,l.dflowApiKey),0===d.length){const e={source:y,name:f.eventTitle,identifier:f.identifier,yesPrice:f.markets[0]?.yesPrice||50,noPrice:100-(f.markets[0]?.yesPrice||50),url:c(y,f.identifier),rawData:{eventTitle:f.eventTitle,markets:f.markets}};return{analysis:{isSameMarket:!1,sameMarketConfidence:0,marketComparisonReasoning:`No matching markets found on ${k} for query "${h}"`,polymarketData:"polymarket"===y?e:void 0,kalshiData:"kalshi"===y?e:void 0,arbitrage:{hasArbitrage:!1},summary:`No matching markets found on ${k}. Cannot determine arbitrage opportunity.`,risks:["No matching market found on the other platform"],recommendation:"Try a different event or check if the market exists on both platforms."},model:"none",sourceMarket:y,searchedMarket:k,processingTimeMs:Date.now()-m}}const{analysis:g,modelUsed:v,tokensUsed:w}=await async function(e,o,a,n,l){const m={source:e.source,name:e.eventTitle,identifier:e.identifier,yesPrice:e.markets[0]?.yesPrice||50,noPrice:100-(e.markets[0]?.yesPrice||50),url:c(e.source,e.identifier)};m.rawData={eventTitle:e.eventTitle,markets:e.markets};const{systemPrompt:u,userPrompt:p}=t({sourceMarket:m,searchResults:o,searchPlatform:a});let y,f,k;if(i(n)){const e=await r(p,u,"json_object",n,3,{apiKey:l.openaiApiKey});f=e.model,k=e.usage?.total_tokens;const t=[];for(const r of e.output)if("message"===r.type){const e=r;t.push(...e.content)}y=t.map(e=>e.text).filter(e=>void 0!==e).join("\n")}else{const e=await s(p,u,"json_object",n,3,void 0,{apiKey:l.xaiApiKey});f=e.model,k=e.usage?.total_tokens;const t=[];for(const r of e.output)if("message"===r.type){const e=r;t.push(...e.content)}y=t.map(e=>e.text).filter(e=>void 0!==e).join("\n")}const h=JSON.parse(y);return{analysis:{isSameMarket:h.isSameMarket,sameMarketConfidence:h.sameMarketConfidence,marketComparisonReasoning:h.marketComparisonReasoning,polymarketData:"polymarket"===e.source?m:h.matchedMarket||void 0,kalshiData:"kalshi"===e.source?m:h.matchedMarket||void 0,arbitrage:h.arbitrage,summary:h.summary,risks:h.risks,recommendation:h.recommendation},modelUsed:f,tokensUsed:k}}(f,d,k,p,l);return{analysis:g,model:v,tokensUsed:w,sourceMarket:y,searchedMarket:k,processingTimeMs:Date.now()-m}}export{l as findArbitrage};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Polyfactual Deep Research API client.
|
|
3
|
-
*
|
|
4
|
-
* A client for the Polyfactual Deep Research API that provides research
|
|
5
|
-
* capabilities with citations. Ported from the PredictOS `polyfactual` shared
|
|
6
|
-
* client.
|
|
7
|
-
*
|
|
8
|
-
* API Documentation:
|
|
9
|
-
* - Base URL: https://deep-research-api.thekid-solana.workers.dev/
|
|
10
|
-
* - Rate Limit: 60 requests per minute
|
|
11
|
-
* - Query Limit: 1,000 characters
|
|
12
|
-
* - Default Timeout: 5 minutes
|
|
13
|
-
*
|
|
14
|
-
* The API key is read from `process.env.POLYFACTUAL_API_KEY`.
|
|
15
|
-
*/
|
|
16
|
-
/** Request payload for the `/answer` endpoint. */
|
|
17
|
-
export interface PolyfactualAnswerRequest {
|
|
18
|
-
/** The research query (max 1000 characters) */
|
|
19
|
-
query: string;
|
|
20
|
-
/** Whether to return text output (default: true) */
|
|
21
|
-
text?: boolean;
|
|
22
|
-
}
|
|
23
|
-
/** Success response from the Polyfactual API. */
|
|
24
|
-
export interface PolyfactualSuccessResponse {
|
|
25
|
-
success: true;
|
|
26
|
-
/** The generated answer and metadata */
|
|
27
|
-
data: PolyfactualAnswerData;
|
|
28
|
-
/** ISO 8601 timestamp */
|
|
29
|
-
timestamp: string;
|
|
30
|
-
}
|
|
31
|
-
/** Error response from the Polyfactual API. */
|
|
32
|
-
export interface PolyfactualErrorResponse {
|
|
33
|
-
success: false;
|
|
34
|
-
/** Error message */
|
|
35
|
-
error: string;
|
|
36
|
-
/** ISO 8601 timestamp */
|
|
37
|
-
timestamp: string;
|
|
38
|
-
}
|
|
39
|
-
/** Union type for Polyfactual API responses. */
|
|
40
|
-
export type PolyfactualResponse = PolyfactualSuccessResponse | PolyfactualErrorResponse;
|
|
41
|
-
/** Answer data structure from Polyfactual. */
|
|
42
|
-
export interface PolyfactualAnswerData {
|
|
43
|
-
/** The generated answer text */
|
|
44
|
-
answer?: string;
|
|
45
|
-
/** Citation sources */
|
|
46
|
-
citations?: PolyfactualCitation[];
|
|
47
|
-
/** Additional metadata */
|
|
48
|
-
[key: string]: unknown;
|
|
49
|
-
}
|
|
50
|
-
/** Citation structure. */
|
|
51
|
-
export interface PolyfactualCitation {
|
|
52
|
-
/** Source URL */
|
|
53
|
-
url?: string;
|
|
54
|
-
/** Source title */
|
|
55
|
-
title?: string;
|
|
56
|
-
/** Snippet from the source */
|
|
57
|
-
snippet?: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Check the health status of the Polyfactual API.
|
|
61
|
-
*/
|
|
62
|
-
export declare function checkPolyfactualHealth(): Promise<boolean>;
|
|
63
|
-
/**
|
|
64
|
-
* Generate an answer with citations using the Polyfactual Deep Research API.
|
|
65
|
-
*
|
|
66
|
-
* @param query - The research question (max 1000 characters)
|
|
67
|
-
* @param text - Whether to return text output (default: true)
|
|
68
|
-
* @returns The research response with answer and citations
|
|
69
|
-
* @throws Error if the API key is missing, query is too long, or the request fails
|
|
70
|
-
*/
|
|
71
|
-
export declare function generatePolyfactualAnswer(query: string, text?: boolean): Promise<PolyfactualSuccessResponse>;
|
|
72
|
-
//# sourceMappingURL=polyfactual.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polyfactual.d.ts","sourceRoot":"","sources":["../../../src/predictos/cl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