fmp-ai-tools 0.0.4 → 0.0.6
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 +104 -4
- package/dist/providers/openai/index.d.mts +56 -0
- package/dist/providers/openai/index.d.ts +56 -0
- package/dist/providers/openai/index.js +739 -0
- package/dist/providers/openai/index.js.map +1 -0
- package/dist/providers/openai/index.mjs +698 -0
- package/dist/providers/openai/index.mjs.map +1 -0
- package/dist/providers/vercel-ai/index.d.mts +29 -1
- package/dist/providers/vercel-ai/index.d.ts +29 -1
- package/dist/providers/vercel-ai/index.js +222 -1
- package/dist/providers/vercel-ai/index.js.map +1 -1
- package/dist/providers/vercel-ai/index.mjs +195 -2
- package/dist/providers/vercel-ai/index.mjs.map +1 -1
- package/package.json +8 -10
- package/dist/index.d.mts +0 -19
- package/dist/index.d.ts +0 -19
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -3
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,739 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zod = require('zod');
|
|
4
|
+
var agents = require('@openai/agents');
|
|
5
|
+
var fmpNodeApi = require('fmp-node-api');
|
|
6
|
+
|
|
7
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
+
}) : x)(function(x) {
|
|
10
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// src/utils/version-check.ts
|
|
15
|
+
function checkOpenAIAgentsVersion() {
|
|
16
|
+
try {
|
|
17
|
+
const { tool: tool2 } = __require("@openai/agents");
|
|
18
|
+
tool2({
|
|
19
|
+
name: "test",
|
|
20
|
+
description: "test",
|
|
21
|
+
parameters: { type: "object", properties: {} },
|
|
22
|
+
strict: true,
|
|
23
|
+
execute: async () => "test"
|
|
24
|
+
});
|
|
25
|
+
} catch (error) {
|
|
26
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Incompatible @openai/agents version detected. This package requires version ^0.0.17 or higher due to breaking changes in the API. Please upgrade with: npm install @openai/agents@latest
|
|
29
|
+
|
|
30
|
+
Error details: ${errorMessage}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/utils/logger.ts
|
|
36
|
+
function isApiLoggingEnabled() {
|
|
37
|
+
return process.env.FMP_TOOLS_LOG_API_RESULTS === "true";
|
|
38
|
+
}
|
|
39
|
+
function isDataOnlyLoggingEnabled() {
|
|
40
|
+
return process.env.FMP_TOOLS_LOG_DATA_ONLY === "true";
|
|
41
|
+
}
|
|
42
|
+
function estimateTokenCount(text) {
|
|
43
|
+
try {
|
|
44
|
+
const parsed = JSON.parse(text);
|
|
45
|
+
return estimateTokenCountForData(parsed);
|
|
46
|
+
} catch {
|
|
47
|
+
return estimateTokenCountForText(text);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
function estimateTokenCountForData(data) {
|
|
51
|
+
if (data === null || data === void 0) {
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
if (typeof data === "string") {
|
|
55
|
+
return Math.ceil(data.length / 3);
|
|
56
|
+
}
|
|
57
|
+
if (typeof data === "number") {
|
|
58
|
+
return data.toString().length > 10 ? 2 : 1;
|
|
59
|
+
}
|
|
60
|
+
if (typeof data === "boolean") {
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(data)) {
|
|
64
|
+
let tokens = 2;
|
|
65
|
+
for (const item of data) {
|
|
66
|
+
tokens += estimateTokenCountForData(item);
|
|
67
|
+
if (data.indexOf(item) < data.length - 1) {
|
|
68
|
+
tokens += 1;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return tokens;
|
|
72
|
+
}
|
|
73
|
+
if (typeof data === "object") {
|
|
74
|
+
let tokens = 2;
|
|
75
|
+
const keys = Object.keys(data);
|
|
76
|
+
for (let i = 0; i < keys.length; i++) {
|
|
77
|
+
const key = keys[i];
|
|
78
|
+
const value = data[key];
|
|
79
|
+
tokens += Math.ceil(key.length / 3);
|
|
80
|
+
tokens += 2;
|
|
81
|
+
tokens += 1;
|
|
82
|
+
tokens += estimateTokenCountForData(value);
|
|
83
|
+
if (i < keys.length - 1) {
|
|
84
|
+
tokens += 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return tokens;
|
|
88
|
+
}
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
function estimateTokenCountForText(text) {
|
|
92
|
+
const words = text.split(/\s+/).filter((word) => word.length > 0);
|
|
93
|
+
let tokens = 0;
|
|
94
|
+
for (const word of words) {
|
|
95
|
+
if (/^\d+$/.test(word)) {
|
|
96
|
+
tokens += word.length > 8 ? 2 : 1;
|
|
97
|
+
} else if (/^[A-Z]+$/.test(word)) {
|
|
98
|
+
tokens += 1;
|
|
99
|
+
} else if (/^\$[\d,]+\.?\d*$/.test(word)) {
|
|
100
|
+
tokens += 3;
|
|
101
|
+
} else {
|
|
102
|
+
tokens += Math.ceil(word.length / 3.5);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return tokens;
|
|
106
|
+
}
|
|
107
|
+
function getResultInfo(result) {
|
|
108
|
+
if (result === null || result === void 0) {
|
|
109
|
+
return "null/undefined";
|
|
110
|
+
}
|
|
111
|
+
if (typeof result === "string") {
|
|
112
|
+
const tokenCount = estimateTokenCount(result);
|
|
113
|
+
try {
|
|
114
|
+
const parsed = JSON.parse(result);
|
|
115
|
+
if (Array.isArray(parsed)) {
|
|
116
|
+
return `JSON string (array of ${parsed.length} items, ~${tokenCount} tokens)`;
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
}
|
|
120
|
+
return `string (${result.length} chars, ~${tokenCount} tokens)`;
|
|
121
|
+
}
|
|
122
|
+
if (Array.isArray(result)) {
|
|
123
|
+
const jsonStr = JSON.stringify(result);
|
|
124
|
+
const tokenCount = estimateTokenCount(jsonStr);
|
|
125
|
+
return `array (${result.length} items, ~${tokenCount} tokens)`;
|
|
126
|
+
}
|
|
127
|
+
if (typeof result === "object") {
|
|
128
|
+
const jsonStr = JSON.stringify(result);
|
|
129
|
+
const tokenCount = estimateTokenCount(jsonStr);
|
|
130
|
+
return `object (~${tokenCount} tokens)`;
|
|
131
|
+
}
|
|
132
|
+
return typeof result;
|
|
133
|
+
}
|
|
134
|
+
function logApiExecution(options) {
|
|
135
|
+
if (!isApiLoggingEnabled()) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const { toolName, input, result, executionTime } = options;
|
|
139
|
+
console.log("\n" + "=".repeat(80));
|
|
140
|
+
console.log(`\u{1F527} FMP Tool Execution: ${toolName}`);
|
|
141
|
+
console.log("=".repeat(80));
|
|
142
|
+
console.log("\n\u{1F4E5} Input:");
|
|
143
|
+
console.log(JSON.stringify(input, null, 2));
|
|
144
|
+
const resultInfo = getResultInfo(result);
|
|
145
|
+
console.log(`\u{1F527} ${toolName}: ${resultInfo}`);
|
|
146
|
+
if (executionTime !== void 0) {
|
|
147
|
+
console.log(`
|
|
148
|
+
\u23F1\uFE0F Execution Time: ${executionTime}ms`);
|
|
149
|
+
}
|
|
150
|
+
console.log("=".repeat(80) + "\n");
|
|
151
|
+
}
|
|
152
|
+
function logDataOnly(options) {
|
|
153
|
+
if (!isDataOnlyLoggingEnabled()) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const { result } = options;
|
|
157
|
+
console.log("\n\u{1F4E4} Result:");
|
|
158
|
+
if (typeof result === "string") {
|
|
159
|
+
try {
|
|
160
|
+
const parsed = JSON.parse(result);
|
|
161
|
+
console.log(JSON.stringify(parsed, null, 2));
|
|
162
|
+
} catch {
|
|
163
|
+
console.log(result);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
console.log(JSON.stringify(result, null, 2));
|
|
167
|
+
}
|
|
168
|
+
console.log("=".repeat(80) + "\n");
|
|
169
|
+
}
|
|
170
|
+
async function logApiExecutionWithTiming(toolName, input, executeFn) {
|
|
171
|
+
const startTime = Date.now();
|
|
172
|
+
try {
|
|
173
|
+
const result = await executeFn();
|
|
174
|
+
const executionTime = Date.now() - startTime;
|
|
175
|
+
logApiExecution({
|
|
176
|
+
toolName,
|
|
177
|
+
input,
|
|
178
|
+
result,
|
|
179
|
+
executionTime
|
|
180
|
+
});
|
|
181
|
+
logDataOnly({
|
|
182
|
+
toolName,
|
|
183
|
+
input,
|
|
184
|
+
result,
|
|
185
|
+
executionTime
|
|
186
|
+
});
|
|
187
|
+
return result;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
const executionTime = Date.now() - startTime;
|
|
190
|
+
if (isApiLoggingEnabled()) {
|
|
191
|
+
console.log("\n" + "=".repeat(80));
|
|
192
|
+
console.log(`\u274C FMP Tool Execution Error: ${toolName}`);
|
|
193
|
+
console.log("=".repeat(80));
|
|
194
|
+
console.log("\n\u{1F4E5} Input:");
|
|
195
|
+
console.log(JSON.stringify(input, null, 2));
|
|
196
|
+
console.log("\n\u274C Error:");
|
|
197
|
+
console.log(error instanceof Error ? error.message : String(error));
|
|
198
|
+
console.log(`
|
|
199
|
+
\u23F1\uFE0F Execution Time: ${executionTime}ms`);
|
|
200
|
+
console.log("=".repeat(80) + "\n");
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// src/utils/openai-tool-wrapper.ts
|
|
207
|
+
function createOpenAITool(config) {
|
|
208
|
+
const { name, description, inputSchema, execute } = config;
|
|
209
|
+
if (inputSchema instanceof zod.z.ZodObject) {
|
|
210
|
+
const shape = inputSchema.shape;
|
|
211
|
+
Object.entries(shape).forEach(([key, schema]) => {
|
|
212
|
+
let actualSchema = schema;
|
|
213
|
+
let fieldDescription = "";
|
|
214
|
+
if (schema && typeof schema === "object" && "description" in schema) {
|
|
215
|
+
const desc = schema.description;
|
|
216
|
+
if (typeof desc === "string") {
|
|
217
|
+
fieldDescription = desc;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (schema instanceof zod.z.ZodOptional) {
|
|
221
|
+
actualSchema = schema.unwrap();
|
|
222
|
+
if (!fieldDescription && actualSchema.description) {
|
|
223
|
+
fieldDescription = actualSchema.description;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
if (schema instanceof zod.z.ZodDefault) {
|
|
227
|
+
actualSchema = schema.removeDefault();
|
|
228
|
+
if (!fieldDescription && actualSchema.description) {
|
|
229
|
+
fieldDescription = actualSchema.description;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (actualSchema instanceof zod.z.ZodString) ; else if (actualSchema instanceof zod.z.ZodEnum) {
|
|
233
|
+
({
|
|
234
|
+
type: "string",
|
|
235
|
+
enum: actualSchema._def.values,
|
|
236
|
+
description: fieldDescription || `${key} parameter`
|
|
237
|
+
});
|
|
238
|
+
} else if (actualSchema instanceof zod.z.ZodNumber) ; else if (actualSchema instanceof zod.z.ZodBoolean) ; else if (actualSchema instanceof zod.z.ZodArray) ; else ;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
return agents.tool({
|
|
242
|
+
name,
|
|
243
|
+
description,
|
|
244
|
+
parameters: inputSchema,
|
|
245
|
+
strict: true,
|
|
246
|
+
execute: async (input) => {
|
|
247
|
+
try {
|
|
248
|
+
const validatedInput = inputSchema.parse(input);
|
|
249
|
+
return await logApiExecutionWithTiming(name, validatedInput, () => execute(validatedInput));
|
|
250
|
+
} catch (error) {
|
|
251
|
+
if (error instanceof zod.z.ZodError) {
|
|
252
|
+
return `Invalid input: ${error.errors.map((e) => e.message).join(", ")}`;
|
|
253
|
+
}
|
|
254
|
+
return `Error executing ${name}: ${error instanceof Error ? error.message : String(error)}`;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function getFMPClient() {
|
|
260
|
+
return new fmpNodeApi.FMP();
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// src/providers/openai/company.ts
|
|
264
|
+
var getCompanyProfile = createOpenAITool({
|
|
265
|
+
name: "getCompanyProfile",
|
|
266
|
+
description: "Get the company profile for a company",
|
|
267
|
+
inputSchema: zod.z.object({
|
|
268
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("The stock symbol (e.g., AAPL, MSFT, GOOGL)")
|
|
269
|
+
}),
|
|
270
|
+
execute: async ({ symbol }) => {
|
|
271
|
+
const fmp = getFMPClient();
|
|
272
|
+
const companyProfile = await fmp.company.getCompanyProfile(symbol);
|
|
273
|
+
return JSON.stringify(companyProfile.data, null, 2);
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
var calendarInputSchema = zod.z.object({
|
|
277
|
+
from: zod.z.string().optional().nullable().describe("Start date in YYYY-MM-DD format (optional)"),
|
|
278
|
+
to: zod.z.string().optional().nullable().describe("End date in YYYY-MM-DD format (optional)")
|
|
279
|
+
});
|
|
280
|
+
var getEarningsCalendar = createOpenAITool({
|
|
281
|
+
name: "getEarningsCalendar",
|
|
282
|
+
description: "Get earnings calendar showing upcoming and recent earnings announcements",
|
|
283
|
+
inputSchema: calendarInputSchema,
|
|
284
|
+
execute: async ({ from, to }) => {
|
|
285
|
+
const fmp = getFMPClient();
|
|
286
|
+
const earningsCalendar = await fmp.calendar.getEarningsCalendar({
|
|
287
|
+
from: from ?? void 0,
|
|
288
|
+
to: to ?? void 0
|
|
289
|
+
});
|
|
290
|
+
return JSON.stringify(earningsCalendar.data, null, 2);
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
var getEconomicCalendar = createOpenAITool({
|
|
294
|
+
name: "getEconomicCalendar",
|
|
295
|
+
description: "Get economic calendar showing upcoming and recent economic events and indicators",
|
|
296
|
+
inputSchema: calendarInputSchema,
|
|
297
|
+
execute: async ({ from, to }) => {
|
|
298
|
+
const fmp = getFMPClient();
|
|
299
|
+
const economicCalendar = await fmp.calendar.getEconomicsCalendar({
|
|
300
|
+
from: from ?? void 0,
|
|
301
|
+
to: to ?? void 0
|
|
302
|
+
});
|
|
303
|
+
return JSON.stringify(economicCalendar.data, null, 2);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
var treasuryRatesInputSchema = zod.z.object({
|
|
307
|
+
from: zod.z.string().optional().nullable().describe("Start date in YYYY-MM-DD format (optional)"),
|
|
308
|
+
to: zod.z.string().optional().nullable().describe("End date in YYYY-MM-DD format (optional)")
|
|
309
|
+
});
|
|
310
|
+
var economicIndicatorNames = [
|
|
311
|
+
"GDP",
|
|
312
|
+
"realGDP",
|
|
313
|
+
"nominalPotentialGDP",
|
|
314
|
+
"realGDPPerCapita",
|
|
315
|
+
"federalFunds",
|
|
316
|
+
"CPI",
|
|
317
|
+
"inflationRate",
|
|
318
|
+
"inflation",
|
|
319
|
+
"retailSales",
|
|
320
|
+
"consumerSentiment",
|
|
321
|
+
"durableGoods",
|
|
322
|
+
"unemploymentRate",
|
|
323
|
+
"totalNonfarmPayroll",
|
|
324
|
+
"initialClaims",
|
|
325
|
+
"industrialProductionTotalIndex",
|
|
326
|
+
"newPrivatelyOwnedHousingUnitsStartedTotalUnits",
|
|
327
|
+
"totalVehicleSales",
|
|
328
|
+
"retailMoneyFunds",
|
|
329
|
+
"smoothedUSRecessionProbabilities",
|
|
330
|
+
"3MonthOr90DayRatesAndYieldsCertificatesOfDeposit",
|
|
331
|
+
"commercialBankInterestRateOnCreditCardPlansAllAccounts",
|
|
332
|
+
"30YearFixedRateMortgageAverage",
|
|
333
|
+
"15YearFixedRateMortgageAverage"
|
|
334
|
+
];
|
|
335
|
+
var economicIndicatorsInputSchema = zod.z.object({
|
|
336
|
+
name: zod.z.enum(economicIndicatorNames).describe("The name of the economic indicator"),
|
|
337
|
+
from: zod.z.string().optional().nullable().describe("Start date in YYYY-MM-DD format (optional)"),
|
|
338
|
+
to: zod.z.string().optional().nullable().describe("End date in YYYY-MM-DD format (optional)")
|
|
339
|
+
});
|
|
340
|
+
var getTreasuryRates = createOpenAITool({
|
|
341
|
+
name: "getTreasuryRates",
|
|
342
|
+
description: "Get treasury rates for different maturities over time",
|
|
343
|
+
inputSchema: treasuryRatesInputSchema,
|
|
344
|
+
execute: async ({ from, to }) => {
|
|
345
|
+
const fmp = getFMPClient();
|
|
346
|
+
const treasuryRates = await fmp.economic.getTreasuryRates({
|
|
347
|
+
from: from ?? void 0,
|
|
348
|
+
to: to ?? void 0
|
|
349
|
+
});
|
|
350
|
+
return JSON.stringify(treasuryRates.data, null, 2);
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
var getEconomicIndicators = createOpenAITool({
|
|
354
|
+
name: "getEconomicIndicators",
|
|
355
|
+
description: "Get economic indicators like GDP, unemployment rate, inflation, etc.",
|
|
356
|
+
inputSchema: economicIndicatorsInputSchema,
|
|
357
|
+
execute: async ({ name, from, to }) => {
|
|
358
|
+
const fmp = getFMPClient();
|
|
359
|
+
const economicIndicators = await fmp.economic.getEconomicIndicators({
|
|
360
|
+
name,
|
|
361
|
+
from: from ?? void 0,
|
|
362
|
+
to: to ?? void 0
|
|
363
|
+
});
|
|
364
|
+
return JSON.stringify(economicIndicators.data, null, 2);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
var etfHoldingsInputSchema = zod.z.object({
|
|
368
|
+
symbol: zod.z.string().min(1, "ETF symbol is required").describe("ETF symbol (e.g., SPY, QQQ, VTI)"),
|
|
369
|
+
date: zod.z.string().optional().nullable().describe("Date for holdings in YYYY-MM-DD format (optional)")
|
|
370
|
+
});
|
|
371
|
+
var etfProfileInputSchema = zod.z.object({
|
|
372
|
+
symbol: zod.z.string().min(1, "ETF symbol is required").describe("ETF symbol (e.g., SPY, QQQ, VTI)")
|
|
373
|
+
});
|
|
374
|
+
var getETFHoldings = createOpenAITool({
|
|
375
|
+
name: "getETFHoldings",
|
|
376
|
+
description: "Get ETF holdings for a specific ETF symbol, showing the underlying assets and their weights",
|
|
377
|
+
inputSchema: etfHoldingsInputSchema,
|
|
378
|
+
execute: async ({ symbol, date }) => {
|
|
379
|
+
const fmp = getFMPClient();
|
|
380
|
+
const params = { symbol };
|
|
381
|
+
if (date) {
|
|
382
|
+
params.date = date;
|
|
383
|
+
}
|
|
384
|
+
const etfHoldings = await fmp.etf.getHoldings(params);
|
|
385
|
+
return JSON.stringify(etfHoldings.data, null, 2);
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
var getETFProfile = createOpenAITool({
|
|
389
|
+
name: "getETFProfile",
|
|
390
|
+
description: "Get ETF profile information including fund details, expense ratio, and key metrics",
|
|
391
|
+
inputSchema: etfProfileInputSchema,
|
|
392
|
+
execute: async ({ symbol }) => {
|
|
393
|
+
const fmp = getFMPClient();
|
|
394
|
+
const etfProfile = await fmp.etf.getProfile(symbol);
|
|
395
|
+
return JSON.stringify(etfProfile.data, null, 2);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
var financialStatementInputSchema = zod.z.object({
|
|
399
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("The stock symbol (e.g., AAPL, MSFT, GOOGL)"),
|
|
400
|
+
period: zod.z.enum(["annual", "quarter"]).default("annual").describe("The period type (annual or quarter)")
|
|
401
|
+
});
|
|
402
|
+
var getBalanceSheet = createOpenAITool({
|
|
403
|
+
name: "getBalanceSheet",
|
|
404
|
+
description: "Get balance sheet for a company showing assets, liabilities, and equity",
|
|
405
|
+
inputSchema: financialStatementInputSchema,
|
|
406
|
+
execute: async ({ symbol, period }) => {
|
|
407
|
+
const fmp = getFMPClient();
|
|
408
|
+
const balanceSheet = await fmp.financial.getBalanceSheet({ symbol, period });
|
|
409
|
+
return JSON.stringify(balanceSheet.data, null, 2);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
var getIncomeStatement = createOpenAITool({
|
|
413
|
+
name: "getIncomeStatement",
|
|
414
|
+
description: "Get income statement for a company showing revenue, expenses, and profit",
|
|
415
|
+
inputSchema: financialStatementInputSchema,
|
|
416
|
+
execute: async ({ symbol, period }) => {
|
|
417
|
+
const fmp = getFMPClient();
|
|
418
|
+
const incomeStatement = await fmp.financial.getIncomeStatement({ symbol, period });
|
|
419
|
+
return JSON.stringify(incomeStatement.data, null, 2);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
var getCashFlowStatement = createOpenAITool({
|
|
423
|
+
name: "getCashFlowStatement",
|
|
424
|
+
description: "Get cash flow statement for a company showing operating, investing, and financing cash flows",
|
|
425
|
+
inputSchema: financialStatementInputSchema,
|
|
426
|
+
execute: async ({ symbol, period }) => {
|
|
427
|
+
const fmp = getFMPClient();
|
|
428
|
+
const cashFlowStatement = await fmp.financial.getCashFlowStatement({ symbol, period });
|
|
429
|
+
return JSON.stringify(cashFlowStatement.data, null, 2);
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
var getFinancialRatios = createOpenAITool({
|
|
433
|
+
name: "getFinancialRatios",
|
|
434
|
+
description: "Get financial ratios for a company including profitability, liquidity, and efficiency metrics",
|
|
435
|
+
inputSchema: financialStatementInputSchema,
|
|
436
|
+
execute: async ({ symbol, period }) => {
|
|
437
|
+
const fmp = getFMPClient();
|
|
438
|
+
const financialRatios = await fmp.financial.getFinancialRatios({ symbol, period });
|
|
439
|
+
return JSON.stringify(financialRatios.data, null, 2);
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
var insiderTradingInputSchema = zod.z.object({
|
|
443
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("Stock symbol (e.g., AAPL, MSFT, GOOGL)"),
|
|
444
|
+
page: zod.z.number().int().min(0).default(0).describe("Page number for pagination (optional, defaults to 0)")
|
|
445
|
+
});
|
|
446
|
+
var getInsiderTrading = createOpenAITool({
|
|
447
|
+
name: "getInsiderTrading",
|
|
448
|
+
description: "Get insider trading data for a specific stock symbol showing buy/sell transactions by company insiders",
|
|
449
|
+
inputSchema: insiderTradingInputSchema,
|
|
450
|
+
execute: async ({ symbol, page }) => {
|
|
451
|
+
const fmp = getFMPClient();
|
|
452
|
+
const insiderTrading = await fmp.insider.getInsiderTradesBySymbol(symbol, page);
|
|
453
|
+
return JSON.stringify(insiderTrading.data, null, 2);
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
var institutionalHoldersInputSchema = zod.z.object({
|
|
457
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("Stock symbol (e.g., AAPL, MSFT, GOOGL)")
|
|
458
|
+
});
|
|
459
|
+
var getInstitutionalHolders = createOpenAITool({
|
|
460
|
+
name: "getInstitutionalHolders",
|
|
461
|
+
description: "Get institutional holders for a specific stock symbol showing which institutions own shares and their holdings",
|
|
462
|
+
inputSchema: institutionalHoldersInputSchema,
|
|
463
|
+
execute: async ({ symbol }) => {
|
|
464
|
+
const fmp = getFMPClient();
|
|
465
|
+
const institutionalHolders = await fmp.institutional.getInstitutionalHolders({ symbol });
|
|
466
|
+
return JSON.stringify(institutionalHolders.data, null, 2);
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
var emptyInputSchema = zod.z.object({});
|
|
470
|
+
var getMarketPerformance = createOpenAITool({
|
|
471
|
+
name: "getMarketPerformance",
|
|
472
|
+
description: "Get overall market performance data including major indices performance",
|
|
473
|
+
inputSchema: emptyInputSchema,
|
|
474
|
+
execute: async () => {
|
|
475
|
+
const fmp = getFMPClient();
|
|
476
|
+
const marketPerformance = await fmp.market.getMarketPerformance();
|
|
477
|
+
return JSON.stringify(marketPerformance.data, null, 2);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
var getSectorPerformance = createOpenAITool({
|
|
481
|
+
name: "getSectorPerformance",
|
|
482
|
+
description: "Get sector performance data showing how different market sectors are performing",
|
|
483
|
+
inputSchema: emptyInputSchema,
|
|
484
|
+
execute: async () => {
|
|
485
|
+
const fmp = getFMPClient();
|
|
486
|
+
const sectorPerformance = await fmp.market.getSectorPerformance();
|
|
487
|
+
return JSON.stringify(sectorPerformance.data, null, 2);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
var getGainers = createOpenAITool({
|
|
491
|
+
name: "getGainers",
|
|
492
|
+
description: "Get top gaining stocks showing the best performing stocks of the day",
|
|
493
|
+
inputSchema: emptyInputSchema,
|
|
494
|
+
execute: async () => {
|
|
495
|
+
const fmp = getFMPClient();
|
|
496
|
+
const gainers = await fmp.market.getGainers();
|
|
497
|
+
return JSON.stringify(gainers.data, null, 2);
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
var getLosers = createOpenAITool({
|
|
501
|
+
name: "getLosers",
|
|
502
|
+
description: "Get top losing stocks showing the worst performing stocks of the day",
|
|
503
|
+
inputSchema: emptyInputSchema,
|
|
504
|
+
execute: async () => {
|
|
505
|
+
const fmp = getFMPClient();
|
|
506
|
+
const losers = await fmp.market.getLosers();
|
|
507
|
+
return JSON.stringify(losers.data, null, 2);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
var getMostActive = createOpenAITool({
|
|
511
|
+
name: "getMostActive",
|
|
512
|
+
description: "Get most active stocks showing stocks with the highest trading volume",
|
|
513
|
+
inputSchema: emptyInputSchema,
|
|
514
|
+
execute: async () => {
|
|
515
|
+
const fmp = getFMPClient();
|
|
516
|
+
const mostActive = await fmp.market.getMostActive();
|
|
517
|
+
return JSON.stringify(mostActive.data, null, 2);
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
var stockQuoteInputSchema = zod.z.object({
|
|
521
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("The symbol of the company to get the stock quote for")
|
|
522
|
+
});
|
|
523
|
+
var getStockQuote = createOpenAITool({
|
|
524
|
+
name: "getStockQuote",
|
|
525
|
+
description: "Get the real-time stock quote for a company including price, volume, and market data",
|
|
526
|
+
inputSchema: stockQuoteInputSchema,
|
|
527
|
+
execute: async ({ symbol }) => {
|
|
528
|
+
const fmp = getFMPClient();
|
|
529
|
+
const stockQuote = await fmp.quote.getQuote(symbol);
|
|
530
|
+
return JSON.stringify(stockQuote.data, null, 2);
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
var symbolInputSchema = zod.z.object({
|
|
534
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("Stock symbol (e.g., AAPL, MSFT, GOOGL)")
|
|
535
|
+
});
|
|
536
|
+
var nameInputSchema = zod.z.object({
|
|
537
|
+
name: zod.z.string().min(1, "Name is required").describe("The name of the senator or representative")
|
|
538
|
+
});
|
|
539
|
+
var rssFeedInputSchema = zod.z.object({
|
|
540
|
+
page: zod.z.number().int().min(0).default(0).describe("Page number for pagination (optional, defaults to 0)")
|
|
541
|
+
});
|
|
542
|
+
var getSenateTrading = createOpenAITool({
|
|
543
|
+
name: "getSenateTrading",
|
|
544
|
+
description: "Get senate trading data for a specific stock symbol showing senator transactions",
|
|
545
|
+
inputSchema: symbolInputSchema,
|
|
546
|
+
execute: async ({ symbol }) => {
|
|
547
|
+
const fmp = getFMPClient();
|
|
548
|
+
const senateTrading = await fmp.senateHouse.getSenateTrading({ symbol });
|
|
549
|
+
return JSON.stringify(senateTrading.data, null, 2);
|
|
550
|
+
}
|
|
551
|
+
});
|
|
552
|
+
var getHouseTrading = createOpenAITool({
|
|
553
|
+
name: "getHouseTrading",
|
|
554
|
+
description: "Get house trading data for a specific stock symbol showing representative transactions",
|
|
555
|
+
inputSchema: symbolInputSchema,
|
|
556
|
+
execute: async ({ symbol }) => {
|
|
557
|
+
const fmp = getFMPClient();
|
|
558
|
+
const houseTrading = await fmp.senateHouse.getHouseTrading({ symbol });
|
|
559
|
+
return JSON.stringify(houseTrading.data, null, 2);
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
var getSenateTradingByName = createOpenAITool({
|
|
563
|
+
name: "getSenateTradingByName",
|
|
564
|
+
description: "Get senate trading data for a specific senator by name showing their trading activity",
|
|
565
|
+
inputSchema: nameInputSchema,
|
|
566
|
+
execute: async ({ name }) => {
|
|
567
|
+
const fmp = getFMPClient();
|
|
568
|
+
const senateTradingByName = await fmp.senateHouse.getSenateTradingByName({ name });
|
|
569
|
+
return JSON.stringify(senateTradingByName.data, null, 2);
|
|
570
|
+
}
|
|
571
|
+
});
|
|
572
|
+
var getHouseTradingByName = createOpenAITool({
|
|
573
|
+
name: "getHouseTradingByName",
|
|
574
|
+
description: "Get house trading data for a specific representative by name showing their trading activity",
|
|
575
|
+
inputSchema: nameInputSchema,
|
|
576
|
+
execute: async ({ name }) => {
|
|
577
|
+
const fmp = getFMPClient();
|
|
578
|
+
const houseTradingByName = await fmp.senateHouse.getHouseTradingByName({ name });
|
|
579
|
+
return JSON.stringify(houseTradingByName.data, null, 2);
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
var getSenateTradingRSSFeed = createOpenAITool({
|
|
583
|
+
name: "getSenateTradingRSSFeed",
|
|
584
|
+
description: "Get senate trading data through RSS feed with pagination showing recent senate transactions",
|
|
585
|
+
inputSchema: rssFeedInputSchema,
|
|
586
|
+
execute: async ({ page }) => {
|
|
587
|
+
const fmp = getFMPClient();
|
|
588
|
+
const senateTradingRSSFeed = await fmp.senateHouse.getSenateTradingRSSFeed({ page });
|
|
589
|
+
return JSON.stringify(senateTradingRSSFeed.data, null, 2);
|
|
590
|
+
}
|
|
591
|
+
});
|
|
592
|
+
var getHouseTradingRSSFeed = createOpenAITool({
|
|
593
|
+
name: "getHouseTradingRSSFeed",
|
|
594
|
+
description: "Get house trading data through RSS feed with pagination showing recent house transactions",
|
|
595
|
+
inputSchema: rssFeedInputSchema,
|
|
596
|
+
execute: async ({ page }) => {
|
|
597
|
+
const fmp = getFMPClient();
|
|
598
|
+
const houseTradingRSSFeed = await fmp.senateHouse.getHouseTradingRSSFeed({ page });
|
|
599
|
+
return JSON.stringify(houseTradingRSSFeed.data, null, 2);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
var symbolInputSchema2 = zod.z.object({
|
|
603
|
+
symbol: zod.z.string().min(1, "Stock symbol is required").describe("The stock symbol (e.g., AAPL, MSFT, GOOGL)")
|
|
604
|
+
});
|
|
605
|
+
var getMarketCap = createOpenAITool({
|
|
606
|
+
name: "getMarketCap",
|
|
607
|
+
description: "Get market capitalization for a company showing current market value",
|
|
608
|
+
inputSchema: symbolInputSchema2,
|
|
609
|
+
execute: async ({ symbol }) => {
|
|
610
|
+
const fmp = getFMPClient();
|
|
611
|
+
const marketCap = await fmp.stock.getMarketCap(symbol);
|
|
612
|
+
return JSON.stringify(marketCap.data, null, 2);
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
var getStockSplits = createOpenAITool({
|
|
616
|
+
name: "getStockSplits",
|
|
617
|
+
description: "Get stock splits history for a company showing all historical stock split events",
|
|
618
|
+
inputSchema: symbolInputSchema2,
|
|
619
|
+
execute: async ({ symbol }) => {
|
|
620
|
+
const fmp = getFMPClient();
|
|
621
|
+
const stockSplits = await fmp.stock.getStockSplits(symbol);
|
|
622
|
+
return JSON.stringify(stockSplits.data, null, 2);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
var getDividendHistory = createOpenAITool({
|
|
626
|
+
name: "getDividendHistory",
|
|
627
|
+
description: "Get dividend history for a company showing all historical dividend payments",
|
|
628
|
+
inputSchema: symbolInputSchema2,
|
|
629
|
+
execute: async ({ symbol }) => {
|
|
630
|
+
const fmp = getFMPClient();
|
|
631
|
+
const dividendHistory = await fmp.stock.getDividendHistory(symbol);
|
|
632
|
+
return JSON.stringify(dividendHistory.data, null, 2);
|
|
633
|
+
}
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
// src/providers/openai/index.ts
|
|
637
|
+
var companyTools = [getCompanyProfile];
|
|
638
|
+
var calendarTools = [getEarningsCalendar, getEconomicCalendar];
|
|
639
|
+
var economicTools = [getTreasuryRates, getEconomicIndicators];
|
|
640
|
+
var etfTools = [getETFHoldings, getETFProfile];
|
|
641
|
+
var financialTools = [
|
|
642
|
+
getBalanceSheet,
|
|
643
|
+
getIncomeStatement,
|
|
644
|
+
getCashFlowStatement,
|
|
645
|
+
getFinancialRatios
|
|
646
|
+
];
|
|
647
|
+
var insiderTools = [getInsiderTrading];
|
|
648
|
+
var institutionalTools = [getInstitutionalHolders];
|
|
649
|
+
var marketTools = [
|
|
650
|
+
getMarketPerformance,
|
|
651
|
+
getSectorPerformance,
|
|
652
|
+
getGainers,
|
|
653
|
+
getLosers,
|
|
654
|
+
getMostActive
|
|
655
|
+
];
|
|
656
|
+
var quoteTools = [getStockQuote];
|
|
657
|
+
var senateHouseTools = [
|
|
658
|
+
getSenateTrading,
|
|
659
|
+
getHouseTrading,
|
|
660
|
+
getSenateTradingByName,
|
|
661
|
+
getHouseTradingByName,
|
|
662
|
+
getSenateTradingRSSFeed,
|
|
663
|
+
getHouseTradingRSSFeed
|
|
664
|
+
];
|
|
665
|
+
var stockTools = [getMarketCap, getStockSplits, getDividendHistory];
|
|
666
|
+
var fmpTools = [
|
|
667
|
+
getCompanyProfile,
|
|
668
|
+
getEarningsCalendar,
|
|
669
|
+
getEconomicCalendar,
|
|
670
|
+
getTreasuryRates,
|
|
671
|
+
getEconomicIndicators,
|
|
672
|
+
getETFHoldings,
|
|
673
|
+
getETFProfile,
|
|
674
|
+
getBalanceSheet,
|
|
675
|
+
getIncomeStatement,
|
|
676
|
+
getCashFlowStatement,
|
|
677
|
+
getFinancialRatios,
|
|
678
|
+
getInsiderTrading,
|
|
679
|
+
getInstitutionalHolders,
|
|
680
|
+
getMarketPerformance,
|
|
681
|
+
getSectorPerformance,
|
|
682
|
+
getGainers,
|
|
683
|
+
getLosers,
|
|
684
|
+
getMostActive,
|
|
685
|
+
getStockQuote,
|
|
686
|
+
getSenateTrading,
|
|
687
|
+
getHouseTrading,
|
|
688
|
+
getSenateTradingByName,
|
|
689
|
+
getHouseTradingByName,
|
|
690
|
+
getSenateTradingRSSFeed,
|
|
691
|
+
getHouseTradingRSSFeed,
|
|
692
|
+
getMarketCap,
|
|
693
|
+
getStockSplits,
|
|
694
|
+
getDividendHistory
|
|
695
|
+
];
|
|
696
|
+
checkOpenAIAgentsVersion();
|
|
697
|
+
|
|
698
|
+
exports.calendarTools = calendarTools;
|
|
699
|
+
exports.companyTools = companyTools;
|
|
700
|
+
exports.economicTools = economicTools;
|
|
701
|
+
exports.etfTools = etfTools;
|
|
702
|
+
exports.financialTools = financialTools;
|
|
703
|
+
exports.fmpTools = fmpTools;
|
|
704
|
+
exports.getBalanceSheet = getBalanceSheet;
|
|
705
|
+
exports.getCashFlowStatement = getCashFlowStatement;
|
|
706
|
+
exports.getCompanyProfile = getCompanyProfile;
|
|
707
|
+
exports.getDividendHistory = getDividendHistory;
|
|
708
|
+
exports.getETFHoldings = getETFHoldings;
|
|
709
|
+
exports.getETFProfile = getETFProfile;
|
|
710
|
+
exports.getEarningsCalendar = getEarningsCalendar;
|
|
711
|
+
exports.getEconomicCalendar = getEconomicCalendar;
|
|
712
|
+
exports.getEconomicIndicators = getEconomicIndicators;
|
|
713
|
+
exports.getFinancialRatios = getFinancialRatios;
|
|
714
|
+
exports.getGainers = getGainers;
|
|
715
|
+
exports.getHouseTrading = getHouseTrading;
|
|
716
|
+
exports.getHouseTradingByName = getHouseTradingByName;
|
|
717
|
+
exports.getHouseTradingRSSFeed = getHouseTradingRSSFeed;
|
|
718
|
+
exports.getIncomeStatement = getIncomeStatement;
|
|
719
|
+
exports.getInsiderTrading = getInsiderTrading;
|
|
720
|
+
exports.getInstitutionalHolders = getInstitutionalHolders;
|
|
721
|
+
exports.getLosers = getLosers;
|
|
722
|
+
exports.getMarketCap = getMarketCap;
|
|
723
|
+
exports.getMarketPerformance = getMarketPerformance;
|
|
724
|
+
exports.getMostActive = getMostActive;
|
|
725
|
+
exports.getSectorPerformance = getSectorPerformance;
|
|
726
|
+
exports.getSenateTrading = getSenateTrading;
|
|
727
|
+
exports.getSenateTradingByName = getSenateTradingByName;
|
|
728
|
+
exports.getSenateTradingRSSFeed = getSenateTradingRSSFeed;
|
|
729
|
+
exports.getStockQuote = getStockQuote;
|
|
730
|
+
exports.getStockSplits = getStockSplits;
|
|
731
|
+
exports.getTreasuryRates = getTreasuryRates;
|
|
732
|
+
exports.insiderTools = insiderTools;
|
|
733
|
+
exports.institutionalTools = institutionalTools;
|
|
734
|
+
exports.marketTools = marketTools;
|
|
735
|
+
exports.quoteTools = quoteTools;
|
|
736
|
+
exports.senateHouseTools = senateHouseTools;
|
|
737
|
+
exports.stockTools = stockTools;
|
|
738
|
+
//# sourceMappingURL=index.js.map
|
|
739
|
+
//# sourceMappingURL=index.js.map
|