@adaptic/lumic-utils 1.0.13 → 1.0.15

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.
@@ -1874,7 +1874,7 @@ class LLMCostTracker {
1874
1874
  timestamp: Date.now(),
1875
1875
  };
1876
1876
  this.usageRecords.push(record);
1877
- getLumicLogger().debug(`LLM cost tracked: ${provider}/${model} - $${cost.toFixed(6)}`, { provider, model, inputTokens, outputTokens, cost });
1877
+ getLumicLogger().info(`LLM cost tracked: ${provider}/${model} - $${cost.toFixed(6)}`, { provider, model, inputTokens, outputTokens, cost });
1878
1878
  }
1879
1879
  /**
1880
1880
  * Records usage from an image generation call.
@@ -1891,7 +1891,7 @@ class LLMCostTracker {
1891
1891
  timestamp: Date.now(),
1892
1892
  };
1893
1893
  this.imageRecords.push(record);
1894
- getLumicLogger().debug(`Image cost tracked: ${model} x${imageCount} - $${cost.toFixed(6)}`, { model, imageCount, cost });
1894
+ getLumicLogger().info(`Image cost tracked: ${model} x${imageCount} - $${cost.toFixed(6)}`, { model, imageCount, cost });
1895
1895
  }
1896
1896
  /**
1897
1897
  * Returns accumulated costs aggregated by model.
@@ -2330,14 +2330,15 @@ const makeOpenAIChatCompletionCall = async (content, responseFormat = 'text', op
2330
2330
  getLLMCostTracker().trackUsage('openai', completion.model, completion.usage.prompt_tokens, completion.usage.completion_tokens);
2331
2331
  // Handle tool calls differently
2332
2332
  if (completion.tool_calls && completion.tool_calls.length > 0) {
2333
+ const toolCallResponse = {
2334
+ tool_calls: completion.tool_calls.map((tc) => ({
2335
+ id: tc.id,
2336
+ name: tc.function.name,
2337
+ arguments: JSON.parse(tc.function.arguments),
2338
+ })),
2339
+ };
2333
2340
  return {
2334
- response: {
2335
- tool_calls: completion.tool_calls.map((tc) => ({
2336
- id: tc.id,
2337
- name: tc.function.name,
2338
- arguments: JSON.parse(tc.function.arguments),
2339
- })),
2340
- },
2341
+ response: toolCallResponse,
2341
2342
  usage: {
2342
2343
  prompt_tokens: completion.usage.prompt_tokens,
2343
2344
  completion_tokens: completion.usage.completion_tokens,
@@ -2444,14 +2445,15 @@ const makeResponsesAPICall = async (input, options = {}) => {
2444
2445
  }
2445
2446
  // Handle tool calls differently
2446
2447
  if (toolCalls && toolCalls.length > 0) {
2448
+ const toolCallResponse = {
2449
+ tool_calls: toolCalls.map((tc) => ({
2450
+ id: tc.id,
2451
+ name: tc.function.name,
2452
+ arguments: JSON.parse(tc.function.arguments),
2453
+ })),
2454
+ };
2447
2455
  return {
2448
- response: {
2449
- tool_calls: toolCalls.map((tc) => ({
2450
- id: tc.id,
2451
- name: tc.function.name,
2452
- arguments: JSON.parse(tc.function.arguments),
2453
- })),
2454
- },
2456
+ response: toolCallResponse,
2455
2457
  usage: {
2456
2458
  prompt_tokens: response.usage?.input_tokens || 0,
2457
2459
  completion_tokens: response.usage?.output_tokens || 0,
@@ -7953,14 +7955,15 @@ async function makeAnthropicCall(content, responseFormat = 'text', options = {})
7953
7955
  arguments: JSON.stringify(block.input),
7954
7956
  },
7955
7957
  }));
7958
+ const toolCallResponse = {
7959
+ tool_calls: toolCalls.map((tc) => ({
7960
+ id: tc.id,
7961
+ name: tc.function.name,
7962
+ arguments: JSON.parse(tc.function.arguments),
7963
+ })),
7964
+ };
7956
7965
  return {
7957
- response: {
7958
- tool_calls: toolCalls.map((tc) => ({
7959
- id: tc.id,
7960
- name: tc.function.name,
7961
- arguments: JSON.parse(tc.function.arguments),
7962
- })),
7963
- },
7966
+ response: toolCallResponse,
7964
7967
  usage: {
7965
7968
  prompt_tokens: inputTokens,
7966
7969
  completion_tokens: outputTokens,
@@ -8140,14 +8143,15 @@ async function makeOpenAICompatibleCall(content, responseFormat = 'text', option
8140
8143
  // Handle tool calls
8141
8144
  const toolCalls = completion.choices[0]?.message?.tool_calls;
8142
8145
  if (toolCalls && toolCalls.length > 0) {
8146
+ const toolCallResponse = {
8147
+ tool_calls: toolCalls.map((tc) => ({
8148
+ id: tc.id,
8149
+ name: tc.function.name,
8150
+ arguments: JSON.parse(tc.function.arguments),
8151
+ })),
8152
+ };
8143
8153
  return {
8144
- response: {
8145
- tool_calls: toolCalls.map((tc) => ({
8146
- id: tc.id,
8147
- name: tc.function.name,
8148
- arguments: JSON.parse(tc.function.arguments),
8149
- })),
8150
- },
8154
+ response: toolCallResponse,
8151
8155
  usage: {
8152
8156
  prompt_tokens: promptTokens,
8153
8157
  completion_tokens: completionTokens,
@@ -8697,14 +8701,15 @@ const makeDeepseekCall = async (content, responseFormat = 'json', options = {})
8697
8701
  getLLMCostTracker().trackUsage('deepseek', completion.model, completion.usage.prompt_tokens, completion.usage.completion_tokens);
8698
8702
  // Handle tool calls similarly to OpenAI
8699
8703
  if (completion.tool_calls && completion.tool_calls.length > 0) {
8704
+ const toolCallResponse = {
8705
+ tool_calls: completion.tool_calls.map((tc) => ({
8706
+ id: tc.id,
8707
+ name: tc.function.name,
8708
+ arguments: JSON.parse(tc.function.arguments),
8709
+ })),
8710
+ };
8700
8711
  return {
8701
- response: {
8702
- tool_calls: completion.tool_calls.map((tc) => ({
8703
- id: tc.id,
8704
- name: tc.function.name,
8705
- arguments: JSON.parse(tc.function.arguments),
8706
- })),
8707
- },
8712
+ response: toolCallResponse,
8708
8713
  usage: {
8709
8714
  prompt_tokens: completion.usage.prompt_tokens,
8710
8715
  completion_tokens: completion.usage.completion_tokens,
@@ -8880,7 +8885,7 @@ const validateEnvironmentVars = () => {
8880
8885
  return {
8881
8886
  isValid: true,
8882
8887
  source: 'lambda',
8883
- vars: {} // No need for explicit credentials in Lambda
8888
+ vars: { accessKeyId: '', secretAccessKey: '', region: '' } // No need for explicit credentials in Lambda
8884
8889
  };
8885
8890
  }
8886
8891
  else if (areVarsComplete(secrets.aws.myAccessKeyId, secrets.aws.mySecretAccessKey, secrets.aws.myRegion)) {
@@ -9689,7 +9694,7 @@ async function downloadFile(s3Client, bucketName, s3Key, localFilePath) {
9689
9694
  async function unzipFile(zipPath, destPath) {
9690
9695
  const zip = new AdmZip(zipPath);
9691
9696
  try {
9692
- await zip.extractAllToAsync(destPath, true);
9697
+ zip.extractAllToAsync(destPath, true);
9693
9698
  const stats = await getDirectoryStats(destPath);
9694
9699
  return stats;
9695
9700
  }
@@ -22650,11 +22655,11 @@ let poolConfig = DEFAULT_POOL_CONFIG;
22650
22655
  async function loadApolloModules() {
22651
22656
  if (typeof window === "undefined" || process.env.AWS_EXECUTION_ENV) {
22652
22657
  // Server-side (or Lambda): load the CommonJS‑based implementation.
22653
- return (await import('./apollo-client.server-CsF1Ouw2.js'));
22658
+ return (await import('./apollo-client.server-D9uTrgax.js'));
22654
22659
  }
22655
22660
  else {
22656
22661
  // Client-side: load the ESM‑based implementation.
22657
- return (await import('./apollo-client.client-DU-axkDV.js'));
22662
+ return (await import('./apollo-client.client-DLlWTxt5.js'));
22658
22663
  }
22659
22664
  }
22660
22665
  /**
@@ -81178,4 +81183,4 @@ const lumic = {
81178
81183
  };
81179
81184
 
81180
81185
  export { GraphQLInterfaceType as $, print as A, getNamedType as B, isInputType as C, isRequiredArgument as D, isNamedType as E, GraphQLError as F, GraphQLNonNull as G, isOutputType as H, isRequiredInputField as I, isCompositeType as J, Kind as K, getNullableType as L, getEnterLeaveForKind as M, isNode as N, OperationTypeNode as O, didYouMean as P, naturalCompare as Q, suggestionList as R, specifiedScalarTypes as S, keyMap as T, isType as U, isNullableType as V, visit as W, visitInParallel as X, keyValMap as Y, assertObjectType as Z, GraphQLScalarType as _, isListType as a, validateGoogleSheetsRange as a$, GraphQLUnionType as a0, GraphQLInputObjectType as a1, assertNullableType as a2, assertInterfaceType as a3, mapValue as a4, isSpecifiedScalarType as a5, isPrintableAsBlockString as a6, printBlockString as a7, BREAK as a8, GRAPHQL_MAX_INT as a9, printSourceLocation as aA, resolveObjMapThunk as aB, resolveReadonlyArrayThunk as aC, valueFromASTUntyped as aD, version$4 as aE, versionInfo as aF, getAugmentedNamespace as aG, isDigit$1 as aH, isNameStart as aI, dedentBlockStringLines as aJ, isNameContinue as aK, setLumicLogger as aL, getLumicLogger as aM, sanitizeForLog as aN, sanitizeError as aO, sanitizeAWSAuth as aP, sanitizeObject as aQ, getSecrets as aR, resetSecrets as aS, requireSecret as aT, withRetry as aU, CircuitBreaker as aV, CircuitBreakerState as aW, CircuitBreakerOpenError as aX, DEFAULT_CIRCUIT_BREAKER_CONFIG as aY, validateSlackChannel as aZ, validateS3Key as a_, GRAPHQL_MIN_INT as aa, GraphQLFloat as ab, GraphQLInt as ac, Location as ad, Token as ae, assertAbstractType as af, assertCompositeType as ag, assertEnumType as ah, assertEnumValueName as ai, assertInputObjectType as aj, assertInputType as ak, assertLeafType as al, assertListType as am, assertNamedType as an, assertNonNullType as ao, assertOutputType as ap, assertScalarType as aq, assertType as ar, assertUnionType as as, assertWrappingType as at, formatError as au, getLocation as av, getVisitFn as aw, isWrappingType as ax, printError as ay, printLocation as az, isAbstractType as b, PDFError as b$, LLMCostTracker as b0, getLLMCostTracker as b1, setLLMCostTracker as b2, resetLLMCostTracker as b3, setMetricsCollector as b4, getMetricsCollector as b5, resetMetricsCollector as b6, withMetrics as b7, generateCorrelationId as b8, getCorrelationId as b9, openAIChatCompletionSchema as bA, openAIImageResponseSchema as bB, validateOpenAIChatCompletion as bC, safeValidateOpenAIChatCompletion as bD, perplexityResponseSchema as bE, validatePerplexityResponse as bF, safeValidatePerplexityResponse as bG, googleSheetsValueRangeSchema as bH, validateGoogleSheetsResponse as bI, safeValidateGoogleSheetsResponse as bJ, s3ListObjectsSchema as bK, s3GetObjectSchema as bL, lambdaInvokeResponseSchema as bM, validateS3ListObjects as bN, safeValidateS3ListObjects as bO, validateLambdaResponse as bP, safeValidateLambdaResponse as bQ, createValidator as bR, createSafeValidator as bS, LumicError as bT, SlackError as bU, LLMError as bV, AWSLambdaError as bW, AWSS3Error as bX, GoogleSheetsError as bY, PerplexityError as bZ, JsonParseError as b_, getCorrelationContext as ba, withCorrelationId as bb, getCorrelationHeaders as bc, TokenBucketRateLimiter as bd, RATE_LIMIT_PROFILES as be, getRateLimiter as bf, resetAllRateLimiters as bg, withRateLimit as bh, checkIntegrationHealth as bi, SUPPORTED_MODELS as bj, isValidModel as bk, getModelCapabilities as bl, getModelProvider as bm, MODEL_ALIASES as bn, OPENAI_COMPATIBLE_PROVIDERS as bo, PROVIDER_DEFAULT_MODELS as bp, LLM_DEFAULT_PROVIDER as bq, LLM_MINI_PROVIDER as br, LLM_NORMAL_PROVIDER as bs, LLM_ADVANCED_PROVIDER as bt, LLM_PROVIDER as bu, LLM_MODEL_MINI as bv, LLM_MODEL_NORMAL as bw, LLM_MODEL_ADVANCED as bx, makeAnthropicCall as by, makeOpenAICompatibleCall as bz, isInterfaceType as c, ZipError as c0, SLACK_TIMEOUT_MS as c1, PERPLEXITY_TIMEOUT_MS as c2, GOOGLE_SHEETS_TIMEOUT_MS as c3, LLM_TIMEOUT_MS as c4, AWS_LAMBDA_TIMEOUT_MS as c5, AWS_S3_TIMEOUT_MS as c6, OPENWEATHER_TIMEOUT_MS as c7, GENERIC_FETCH_TIMEOUT_MS as c8, isObjectType as d, assertName as e, devAssert as f, isObjectLike as g, defineArguments as h, isNonNullType as i, argsToArgsConfig as j, GraphQLBoolean as k, lumic as l, GraphQLString as m, instanceOf as n, inspect as o, isInputObjectType as p, isLeafType as q, isEnumType as r, GraphQLID as s, toObjMap as t, invariant as u, GraphQLObjectType as v, GraphQLEnumType as w, GraphQLList as x, isScalarType as y, isUnionType as z };
81181
- //# sourceMappingURL=index-FzTQZ3fX.js.map
81186
+ //# sourceMappingURL=index-CwQjKm5M.js.map