@adaptic/lumic-utils 1.0.23 → 1.0.25
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/dist/{apollo-client.client-FeVPHV0i.js → apollo-client.client-D6jG5B1n.js} +3 -3
- package/dist/{apollo-client.client-FeVPHV0i.js.map → apollo-client.client-D6jG5B1n.js.map} +1 -1
- package/dist/{apollo-client.client-DrSy1wz-.js → apollo-client.client-DLW-p46Y.js} +4 -4
- package/dist/{apollo-client.client-DrSy1wz-.js.map → apollo-client.client-DLW-p46Y.js.map} +1 -1
- package/dist/{apollo-client.server-CJ6iRLa2.js → apollo-client.server-CXLiLmSz.js} +3 -3
- package/dist/{apollo-client.server-CJ6iRLa2.js.map → apollo-client.server-CXLiLmSz.js.map} +1 -1
- package/dist/{apollo-client.server-BEGHAF48.js → apollo-client.server-Cx30LaNh.js} +3 -3
- package/dist/{apollo-client.server-BEGHAF48.js.map → apollo-client.server-Cx30LaNh.js.map} +1 -1
- package/dist/{index-CWoI2dXN.js → index-Bvc61lYS.js} +76 -18
- package/dist/{index-WGzi__C5.js.map → index-Bvc61lYS.js.map} +1 -1
- package/dist/{index-WGzi__C5.js → index-ChygDqeG.js} +76 -18
- package/dist/{index-CWoI2dXN.js.map → index-ChygDqeG.js.map} +1 -1
- package/dist/{index-Dz0wKyTF.js → index-CqnZ-XiI.js} +2 -2
- package/dist/{index-Dz0wKyTF.js.map → index-CqnZ-XiI.js.map} +1 -1
- package/dist/{index-vRskhk1H.js → index-D2TPDKw0.js} +2 -2
- package/dist/{index-vRskhk1H.js.map → index-D2TPDKw0.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/test.cjs +1 -1
- package/dist/test.mjs +1 -1
- package/dist/types/functions/llm-openai.d.ts +5 -0
- package/dist/types/types/openai-types.d.ts +25 -0
- package/dist/types/utils/retry.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1983,11 +1983,19 @@ const DEFAULT_RETRY_CONFIG = {
|
|
|
1983
1983
|
* @throws The last error encountered if all retry attempts fail or if a non-retryable error occurs
|
|
1984
1984
|
*/
|
|
1985
1985
|
async function withRetry(fn, config = {}, label = 'unknown') {
|
|
1986
|
-
const { maxRetries, baseDelayMs, maxDelayMs, retryableErrors, circuitBreaker } = {
|
|
1986
|
+
const { maxRetries, baseDelayMs, maxDelayMs, retryableErrors, circuitBreaker, signal } = {
|
|
1987
1987
|
...DEFAULT_RETRY_CONFIG,
|
|
1988
1988
|
...config,
|
|
1989
1989
|
};
|
|
1990
1990
|
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
1991
|
+
// Short-circuit on cancellation BEFORE starting a fresh attempt so
|
|
1992
|
+
// the caller does not pay the cost of issuing a request whose result
|
|
1993
|
+
// they have already discarded.
|
|
1994
|
+
if (signal?.aborted) {
|
|
1995
|
+
throw signal.reason instanceof Error
|
|
1996
|
+
? signal.reason
|
|
1997
|
+
: new Error('Aborted');
|
|
1998
|
+
}
|
|
1991
1999
|
try {
|
|
1992
2000
|
// If a circuit breaker is provided, execute through it
|
|
1993
2001
|
const result = circuitBreaker
|
|
@@ -2000,6 +2008,13 @@ async function withRetry(fn, config = {}, label = 'unknown') {
|
|
|
2000
2008
|
if (error instanceof CircuitBreakerOpenError) {
|
|
2001
2009
|
throw error;
|
|
2002
2010
|
}
|
|
2011
|
+
// Do not retry on cooperative cancellation — the caller has
|
|
2012
|
+
// explicitly asked us to stop.
|
|
2013
|
+
if (signal?.aborted) {
|
|
2014
|
+
throw signal.reason instanceof Error
|
|
2015
|
+
? signal.reason
|
|
2016
|
+
: new Error('Aborted');
|
|
2017
|
+
}
|
|
2003
2018
|
// Don't retry if we've exhausted all attempts
|
|
2004
2019
|
if (attempt === maxRetries) {
|
|
2005
2020
|
throw error;
|
|
@@ -2013,7 +2028,26 @@ async function withRetry(fn, config = {}, label = 'unknown') {
|
|
|
2013
2028
|
const jitter = Math.random() * 1000;
|
|
2014
2029
|
const delay = Math.min(exponentialDelay + jitter, maxDelayMs);
|
|
2015
2030
|
getLumicLogger().warn(`[${label}] Attempt ${attempt + 1} failed, retrying in ${Math.round(delay)}ms`);
|
|
2016
|
-
|
|
2031
|
+
// Sleep but bail early if signal aborts mid-backoff.
|
|
2032
|
+
await new Promise((resolve, reject) => {
|
|
2033
|
+
const timer = setTimeout(() => {
|
|
2034
|
+
if (signal)
|
|
2035
|
+
signal.removeEventListener('abort', onAbort);
|
|
2036
|
+
resolve();
|
|
2037
|
+
}, delay);
|
|
2038
|
+
const onAbort = () => {
|
|
2039
|
+
clearTimeout(timer);
|
|
2040
|
+
reject(signal?.reason instanceof Error ? signal.reason : new Error('Aborted'));
|
|
2041
|
+
};
|
|
2042
|
+
if (signal) {
|
|
2043
|
+
if (signal.aborted) {
|
|
2044
|
+
clearTimeout(timer);
|
|
2045
|
+
reject(signal.reason instanceof Error ? signal.reason : new Error('Aborted'));
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2017
2051
|
}
|
|
2018
2052
|
}
|
|
2019
2053
|
// This should never be reached, but TypeScript needs it for type safety
|
|
@@ -2506,11 +2540,20 @@ async function createCompletion(content, responseFormat, options = DEFAULT_OPTIO
|
|
|
2506
2540
|
}
|
|
2507
2541
|
let completion;
|
|
2508
2542
|
try {
|
|
2509
|
-
completion = await withRetry(
|
|
2543
|
+
completion = await withRetry(
|
|
2544
|
+
// Pass the AbortSignal into the OpenAI SDK request-options object.
|
|
2545
|
+
// The OpenAI SDK honours `signal` to cancel the in-flight fetch
|
|
2546
|
+
// immediately when it fires — this is what makes caller-driven
|
|
2547
|
+
// cancel-and-restart (e.g. signal-monitoring's materiality
|
|
2548
|
+
// re-trigger path in the engine) actually release the HTTP
|
|
2549
|
+
// connection and response-body buffer rather than just discarding
|
|
2550
|
+
// the resolved value at the engine boundary.
|
|
2551
|
+
() => openai.chat.completions.create(queryOptions, options.signal ? { signal: options.signal } : undefined), {
|
|
2510
2552
|
maxRetries: 3,
|
|
2511
2553
|
baseDelayMs: 2000,
|
|
2512
2554
|
maxDelayMs: 30000,
|
|
2513
2555
|
retryableErrors: isRetryableLLMError,
|
|
2556
|
+
signal: options.signal,
|
|
2514
2557
|
}, `OpenAI:${normalizedModel}`);
|
|
2515
2558
|
}
|
|
2516
2559
|
catch (error) {
|
|
@@ -2668,19 +2711,20 @@ const makeResponsesAPICall = async (input, options = {}) => {
|
|
|
2668
2711
|
apiKey: apiKey,
|
|
2669
2712
|
timeout: options.timeout ?? LLM_TIMEOUT_MS,
|
|
2670
2713
|
});
|
|
2671
|
-
// Remove apiKey, model, and
|
|
2672
|
-
const { apiKey: _, model: __, timeout: ___, ...cleanOptions } = options;
|
|
2714
|
+
// Remove apiKey, model, timeout, and signal from options before creating request body
|
|
2715
|
+
const { apiKey: _, model: __, timeout: ___, signal: ____, ...cleanOptions } = options;
|
|
2673
2716
|
const requestBody = {
|
|
2674
2717
|
model: normalizedModel,
|
|
2675
2718
|
input,
|
|
2676
2719
|
...cleanOptions,
|
|
2677
2720
|
};
|
|
2678
2721
|
// Make the API call to the Responses endpoint
|
|
2679
|
-
const response = await withRetry(() => openai.responses.create(requestBody), {
|
|
2722
|
+
const response = await withRetry(() => openai.responses.create(requestBody, options.signal ? { signal: options.signal } : undefined), {
|
|
2680
2723
|
maxRetries: 3,
|
|
2681
2724
|
baseDelayMs: 2000,
|
|
2682
2725
|
maxDelayMs: 30000,
|
|
2683
2726
|
retryableErrors: isRetryableLLMError,
|
|
2727
|
+
signal: options.signal,
|
|
2684
2728
|
}, `OpenAI-Responses:${normalizedModel}`);
|
|
2685
2729
|
// Responses API exposes cached input tokens under `input_tokens_details.cached_tokens`
|
|
2686
2730
|
// (the equivalent of Chat Completions' `prompt_tokens_details.cached_tokens`).
|
|
@@ -8253,23 +8297,32 @@ async function makeAnthropicCall(content, responseFormat = 'text', options = {})
|
|
|
8253
8297
|
if (systemParts.length > 0) {
|
|
8254
8298
|
requestParams.system = systemParts.join('\n\n');
|
|
8255
8299
|
}
|
|
8256
|
-
//
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8300
|
+
// Sampling controls are intentionally disabled for the Anthropic provider.
|
|
8301
|
+
//
|
|
8302
|
+
// The claude-*-4.x model family rejects any request that specifies BOTH
|
|
8303
|
+
// `temperature` and `top_p` ("`temperature` and `top_p` cannot both be
|
|
8304
|
+
// specified for this model. Please use only one." — HTTP 400), which aborts
|
|
8305
|
+
// the entire caller flow (e.g. the engine's account decision session).
|
|
8306
|
+
// Callers across the org pass both knobs generically, so rather than make
|
|
8307
|
+
// each one provider-aware we drop both here and let Anthropic use its model
|
|
8308
|
+
// defaults. `options.temperature` / `options.top_p` are intentionally not
|
|
8309
|
+
// forwarded. This is the Anthropic adapter only — the OpenAI, DeepSeek, and
|
|
8310
|
+
// OpenAI-compatible adapters still honor `temperature` and `top_p`.
|
|
8263
8311
|
// Translate and add tools if present
|
|
8264
8312
|
if (options.tools && options.tools.length > 0) {
|
|
8265
8313
|
requestParams.tools = translateToolsToAnthropic(options.tools);
|
|
8266
8314
|
}
|
|
8267
8315
|
try {
|
|
8268
|
-
const response = await withRetry(
|
|
8316
|
+
const response = await withRetry(
|
|
8317
|
+
// Pass AbortSignal into the Anthropic SDK request-options object
|
|
8318
|
+
// so caller-driven cancellation interrupts the in-flight HTTP
|
|
8319
|
+
// request immediately. See LLMOptions.signal JSDoc for context.
|
|
8320
|
+
() => client.messages.create(requestParams, options.signal ? { signal: options.signal } : undefined), {
|
|
8269
8321
|
maxRetries: 3,
|
|
8270
8322
|
baseDelayMs: 2000,
|
|
8271
8323
|
maxDelayMs: 30000,
|
|
8272
8324
|
retryableErrors: isRetryableAnthropicError,
|
|
8325
|
+
signal: options.signal,
|
|
8273
8326
|
}, `Anthropic:${model}`);
|
|
8274
8327
|
const inputTokens = response.usage.input_tokens;
|
|
8275
8328
|
const outputTokens = response.usage.output_tokens;
|
|
@@ -8462,11 +8515,16 @@ async function makeOpenAICompatibleCall(content, responseFormat = 'text', option
|
|
|
8462
8515
|
queryOptions.tools = options.tools;
|
|
8463
8516
|
}
|
|
8464
8517
|
try {
|
|
8465
|
-
const completion = await withRetry(
|
|
8518
|
+
const completion = await withRetry(
|
|
8519
|
+
// Pass AbortSignal into the SDK request-options object so
|
|
8520
|
+
// caller-driven cancellation interrupts the in-flight HTTP
|
|
8521
|
+
// request immediately. See LLMOptions.signal JSDoc for context.
|
|
8522
|
+
() => openai.chat.completions.create(queryOptions, options.signal ? { signal: options.signal } : undefined), {
|
|
8466
8523
|
maxRetries: 3,
|
|
8467
8524
|
baseDelayMs: 2000,
|
|
8468
8525
|
maxDelayMs: 30000,
|
|
8469
8526
|
retryableErrors: isRetryableError,
|
|
8527
|
+
signal: options.signal,
|
|
8470
8528
|
}, `${providerConfig.name}:${model}`);
|
|
8471
8529
|
const promptTokens = completion.usage?.prompt_tokens || 0;
|
|
8472
8530
|
const completionTokens = completion.usage?.completion_tokens || 0;
|
|
@@ -22997,11 +23055,11 @@ let poolConfig = DEFAULT_POOL_CONFIG;
|
|
|
22997
23055
|
async function loadApolloModules() {
|
|
22998
23056
|
if (typeof window === "undefined" || process.env.AWS_EXECUTION_ENV) {
|
|
22999
23057
|
// Server-side (or Lambda): load the CommonJS‑based implementation.
|
|
23000
|
-
return (await import('./apollo-client.server-
|
|
23058
|
+
return (await import('./apollo-client.server-CXLiLmSz.js'));
|
|
23001
23059
|
}
|
|
23002
23060
|
else {
|
|
23003
23061
|
// Client-side: load the ESM‑based implementation.
|
|
23004
|
-
return (await import('./apollo-client.client-
|
|
23062
|
+
return (await import('./apollo-client.client-DLW-p46Y.js'));
|
|
23005
23063
|
}
|
|
23006
23064
|
}
|
|
23007
23065
|
/**
|
|
@@ -81525,4 +81583,4 @@ const lumic = {
|
|
|
81525
81583
|
};
|
|
81526
81584
|
|
|
81527
81585
|
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 };
|
|
81528
|
-
//# sourceMappingURL=index-
|
|
81586
|
+
//# sourceMappingURL=index-Bvc61lYS.js.map
|