@discomedia/utils 1.0.45 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +10 -1
  2. package/dist/index-frontend.cjs +83 -7
  3. package/dist/index-frontend.cjs.map +1 -1
  4. package/dist/index-frontend.mjs +83 -7
  5. package/dist/index-frontend.mjs.map +1 -1
  6. package/dist/index.cjs +83 -7
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.mjs +83 -7
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/package.json +3 -3
  11. package/dist/test.js +1029 -6085
  12. package/dist/test.js.map +1 -1
  13. package/dist/types/alpaca-trading-api.d.ts +2 -13
  14. package/dist/types/alpaca-trading-api.d.ts.map +1 -1
  15. package/dist/types/llm-config.d.ts.map +1 -1
  16. package/dist/types/llm-images.d.ts +2 -1
  17. package/dist/types/llm-images.d.ts.map +1 -1
  18. package/dist/types/llm-openai.d.ts.map +1 -1
  19. package/dist/types/market-time.d.ts.map +1 -1
  20. package/dist/types/types/alpaca-types.d.ts +13 -0
  21. package/dist/types/types/alpaca-types.d.ts.map +1 -1
  22. package/dist/types/types/llm-types.d.ts +7 -3
  23. package/dist/types/types/llm-types.d.ts.map +1 -1
  24. package/dist/types-frontend/alpaca-trading-api.d.ts +2 -13
  25. package/dist/types-frontend/alpaca-trading-api.d.ts.map +1 -1
  26. package/dist/types-frontend/llm-config.d.ts.map +1 -1
  27. package/dist/types-frontend/llm-images.d.ts +2 -1
  28. package/dist/types-frontend/llm-images.d.ts.map +1 -1
  29. package/dist/types-frontend/llm-openai.d.ts.map +1 -1
  30. package/dist/types-frontend/market-time.d.ts.map +1 -1
  31. package/dist/types-frontend/types/alpaca-types.d.ts +13 -0
  32. package/dist/types-frontend/types/alpaca-types.d.ts.map +1 -1
  33. package/dist/types-frontend/types/llm-types.d.ts +7 -3
  34. package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
  35. package/package.json +3 -3
package/dist/index.cjs CHANGED
@@ -449,9 +449,10 @@ function getLastFullTradingDateImpl(currentDate = new Date()) {
449
449
  if (calendar.isEarlyCloseDay(prevMarketDay)) {
450
450
  prevCloseMinutes = MARKET_CONFIG.TIMES.EARLY_CLOSE.hour * 60 + MARKET_CONFIG.TIMES.EARLY_CLOSE.minute;
451
451
  }
452
- const year = prevMarketDay.getUTCFullYear();
453
- const month = prevMarketDay.getUTCMonth();
454
- const day = prevMarketDay.getUTCDate();
452
+ const prevNYDate = toNYTime(prevMarketDay);
453
+ const year = prevNYDate.getUTCFullYear();
454
+ const month = prevNYDate.getUTCMonth();
455
+ const day = prevNYDate.getUTCDate();
455
456
  const closeHour = Math.floor(prevCloseMinutes / 60);
456
457
  const closeMinute = prevCloseMinutes % 60;
457
458
  return fromNYTime(new Date(Date.UTC(year, month, day, closeHour, closeMinute, 0, 0)));
@@ -1087,6 +1088,10 @@ function isOpenRouterModel(model) {
1087
1088
  'openai/gpt-5-mini',
1088
1089
  'openai/gpt-5-nano',
1089
1090
  'openai/gpt-5.1',
1091
+ 'openai/gpt-5.2',
1092
+ 'openai/gpt-5.2-pro',
1093
+ 'openai/gpt-5.1-codex',
1094
+ 'openai/gpt-5.1-codex-max',
1090
1095
  'openai/gpt-oss-120b',
1091
1096
  'z.ai/glm-4.5',
1092
1097
  'z.ai/glm-4.5-air',
@@ -2452,7 +2457,7 @@ const safeJSON = (text) => {
2452
2457
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2453
2458
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2454
2459
 
2455
- const VERSION = '6.9.1'; // x-release-please-version
2460
+ const VERSION = '6.10.0'; // x-release-please-version
2456
2461
 
2457
2462
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2458
2463
  const isRunningInBrowser = () => {
@@ -8293,6 +8298,17 @@ class Responses extends APIResource {
8293
8298
  cancel(responseID, options) {
8294
8299
  return this._client.post(path `/responses/${responseID}/cancel`, options);
8295
8300
  }
8301
+ /**
8302
+ * Compact conversation
8303
+ *
8304
+ * @example
8305
+ * ```ts
8306
+ * const compactedResponse = await client.responses.compact();
8307
+ * ```
8308
+ */
8309
+ compact(body = {}, options) {
8310
+ return this._client.post('/responses/compact', { body, ...options });
8311
+ }
8296
8312
  }
8297
8313
  Responses.InputItems = InputItems;
8298
8314
  Responses.InputTokens = InputTokens;
@@ -9435,6 +9451,22 @@ const openAiModelCosts = {
9435
9451
  inputCost: 1.25 / 1_000_000,
9436
9452
  outputCost: 10 / 1_000_000,
9437
9453
  },
9454
+ 'gpt-5.2': {
9455
+ inputCost: 1.5 / 1_000_000,
9456
+ outputCost: 12 / 1_000_000,
9457
+ },
9458
+ 'gpt-5.2-pro': {
9459
+ inputCost: 3 / 1_000_000,
9460
+ outputCost: 24 / 1_000_000,
9461
+ },
9462
+ 'gpt-5.1-codex': {
9463
+ inputCost: 1.1 / 1_000_000,
9464
+ outputCost: 8.8 / 1_000_000,
9465
+ },
9466
+ 'gpt-5.1-codex-max': {
9467
+ inputCost: 1.8 / 1_000_000,
9468
+ outputCost: 14.4 / 1_000_000,
9469
+ },
9438
9470
  'o4-mini': {
9439
9471
  inputCost: 1.1 / 1_000_000,
9440
9472
  outputCost: 4.4 / 1_000_000,
@@ -9896,6 +9928,10 @@ const isSupportedModel = (model) => {
9896
9928
  'gpt-5-mini',
9897
9929
  'gpt-5-nano',
9898
9930
  'gpt-5.1',
9931
+ 'gpt-5.2',
9932
+ 'gpt-5.2-pro',
9933
+ 'gpt-5.1-codex',
9934
+ 'gpt-5.1-codex-max',
9899
9935
  'o4-mini',
9900
9936
  'o3',
9901
9937
  ].includes(model);
@@ -9908,7 +9944,21 @@ const isSupportedModel = (model) => {
9908
9944
  function supportsTemperature(model) {
9909
9945
  // Reasoning models don't support temperature
9910
9946
  // GPT-5 models also do not support temperature
9911
- const reasoningAndGPT5Models = ['o1', 'o1-mini', 'o3-mini', 'o4-mini', 'o3', 'gpt-5', 'gpt-5-mini', 'gpt-5-nano', 'gpt-5.1'];
9947
+ const reasoningAndGPT5Models = [
9948
+ 'o1',
9949
+ 'o1-mini',
9950
+ 'o3-mini',
9951
+ 'o4-mini',
9952
+ 'o3',
9953
+ 'gpt-5',
9954
+ 'gpt-5-mini',
9955
+ 'gpt-5-nano',
9956
+ 'gpt-5.1',
9957
+ 'gpt-5.2',
9958
+ 'gpt-5.2-pro',
9959
+ 'gpt-5.1-codex',
9960
+ 'gpt-5.1-codex-max',
9961
+ ];
9912
9962
  return !reasoningAndGPT5Models.includes(model);
9913
9963
  }
9914
9964
  /**
@@ -9926,7 +9976,16 @@ function isReasoningModel(model) {
9926
9976
  * @returns True if the model is a GPT-5 model, false otherwise.
9927
9977
  */
9928
9978
  function isGPT5Model(model) {
9929
- const gpt5Models = ['gpt-5', 'gpt-5-mini', 'gpt-5-nano', 'gpt-5.1'];
9979
+ const gpt5Models = [
9980
+ 'gpt-5',
9981
+ 'gpt-5-mini',
9982
+ 'gpt-5-nano',
9983
+ 'gpt-5.1',
9984
+ 'gpt-5.2',
9985
+ 'gpt-5.2-pro',
9986
+ 'gpt-5.1-codex',
9987
+ 'gpt-5.1-codex-max',
9988
+ ];
9930
9989
  return gpt5Models.includes(model);
9931
9990
  }
9932
9991
  /**
@@ -10167,6 +10226,18 @@ async function makeLLMCall(input, options = {}) {
10167
10226
  return await makeResponsesAPICall(processedInput, responsesOptions);
10168
10227
  }
10169
10228
 
10229
+ const MULTIMODAL_VISION_MODELS = new Set([
10230
+ 'gpt-4o-mini',
10231
+ 'gpt-4o',
10232
+ 'gpt-5',
10233
+ 'gpt-5-mini',
10234
+ 'gpt-5-nano',
10235
+ 'gpt-5.1',
10236
+ 'gpt-5.2',
10237
+ 'gpt-5.2-pro',
10238
+ 'gpt-5.1-codex',
10239
+ 'gpt-5.1-codex-max',
10240
+ ]);
10170
10241
  /**
10171
10242
  * Makes a call to the OpenAI Images API to generate images based on a text prompt.
10172
10243
  *
@@ -10203,7 +10274,11 @@ async function makeLLMCall(input, options = {}) {
10203
10274
  * @throws Error if the API call fails or invalid parameters are provided
10204
10275
  */
10205
10276
  async function makeImagesCall(prompt, options = {}) {
10206
- const { size = 'auto', outputFormat = 'webp', compression = 50, quality = 'high', count = 1, background = 'auto', moderation = 'auto', apiKey } = options;
10277
+ const { size = 'auto', outputFormat = 'webp', compression = 50, quality = 'high', count = 1, background = 'auto', moderation = 'auto', apiKey, visionModel, } = options;
10278
+ const supportedVisionModel = visionModel && MULTIMODAL_VISION_MODELS.has(visionModel) ? visionModel : undefined;
10279
+ if (visionModel && !supportedVisionModel) {
10280
+ console.warn(`Vision model ${visionModel} is not recognized as a multimodal OpenAI model. Ignoring for image usage metadata.`);
10281
+ }
10207
10282
  // Get API key
10208
10283
  const effectiveApiKey = apiKey || process.env.OPENAI_API_KEY;
10209
10284
  if (!effectiveApiKey) {
@@ -10263,6 +10338,7 @@ async function makeImagesCall(prompt, options = {}) {
10263
10338
  provider: 'openai',
10264
10339
  model: 'gpt-image-1',
10265
10340
  cost,
10341
+ ...(supportedVisionModel ? { visionModel: supportedVisionModel } : {}),
10266
10342
  },
10267
10343
  };
10268
10344
  return enhancedResponse;