@usabledev/usable-chat 1.162.1 → 1.162.3
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/cli.js +698 -845
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -22773,12 +22773,12 @@ var init_global_utils = __esm({
|
|
|
22773
22773
|
|
|
22774
22774
|
// node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
|
|
22775
22775
|
function logProxy(funcName, namespace, args) {
|
|
22776
|
-
var
|
|
22777
|
-
if (!
|
|
22776
|
+
var logger5 = getGlobal("diag");
|
|
22777
|
+
if (!logger5) {
|
|
22778
22778
|
return;
|
|
22779
22779
|
}
|
|
22780
22780
|
args.unshift(namespace);
|
|
22781
|
-
return
|
|
22781
|
+
return logger5[funcName].apply(logger5, __spreadArray([], __read(args), false));
|
|
22782
22782
|
}
|
|
22783
22783
|
var __read, __spreadArray, DiagComponentLogger;
|
|
22784
22784
|
var init_ComponentLogger = __esm({
|
|
@@ -22874,17 +22874,17 @@ var init_types2 = __esm({
|
|
|
22874
22874
|
});
|
|
22875
22875
|
|
|
22876
22876
|
// node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
|
|
22877
|
-
function createLogLevelDiagLogger(maxLevel,
|
|
22877
|
+
function createLogLevelDiagLogger(maxLevel, logger5) {
|
|
22878
22878
|
if (maxLevel < DiagLogLevel.NONE) {
|
|
22879
22879
|
maxLevel = DiagLogLevel.NONE;
|
|
22880
22880
|
} else if (maxLevel > DiagLogLevel.ALL) {
|
|
22881
22881
|
maxLevel = DiagLogLevel.ALL;
|
|
22882
22882
|
}
|
|
22883
|
-
|
|
22883
|
+
logger5 = logger5 || {};
|
|
22884
22884
|
function _filterFunc(funcName, theLevel) {
|
|
22885
|
-
var theFunc =
|
|
22885
|
+
var theFunc = logger5[funcName];
|
|
22886
22886
|
if (typeof theFunc === "function" && maxLevel >= theLevel) {
|
|
22887
|
-
return theFunc.bind(
|
|
22887
|
+
return theFunc.bind(logger5);
|
|
22888
22888
|
}
|
|
22889
22889
|
return function() {
|
|
22890
22890
|
};
|
|
@@ -22949,19 +22949,19 @@ var init_diag = __esm({
|
|
|
22949
22949
|
for (var _i4 = 0; _i4 < arguments.length; _i4++) {
|
|
22950
22950
|
args[_i4] = arguments[_i4];
|
|
22951
22951
|
}
|
|
22952
|
-
var
|
|
22953
|
-
if (!
|
|
22952
|
+
var logger5 = getGlobal("diag");
|
|
22953
|
+
if (!logger5)
|
|
22954
22954
|
return;
|
|
22955
|
-
return
|
|
22955
|
+
return logger5[funcName].apply(logger5, __spreadArray2([], __read2(args), false));
|
|
22956
22956
|
};
|
|
22957
22957
|
}
|
|
22958
22958
|
var self2 = this;
|
|
22959
|
-
var setLogger = function(
|
|
22959
|
+
var setLogger = function(logger5, optionsOrLogLevel) {
|
|
22960
22960
|
var _a27, _b16, _c7;
|
|
22961
22961
|
if (optionsOrLogLevel === void 0) {
|
|
22962
22962
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
22963
22963
|
}
|
|
22964
|
-
if (
|
|
22964
|
+
if (logger5 === self2) {
|
|
22965
22965
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
22966
22966
|
self2.error((_a27 = err.stack) !== null && _a27 !== void 0 ? _a27 : err.message);
|
|
22967
22967
|
return false;
|
|
@@ -22972,7 +22972,7 @@ var init_diag = __esm({
|
|
|
22972
22972
|
};
|
|
22973
22973
|
}
|
|
22974
22974
|
var oldLogger = getGlobal("diag");
|
|
22975
|
-
var newLogger = createLogLevelDiagLogger((_b16 = optionsOrLogLevel.logLevel) !== null && _b16 !== void 0 ? _b16 : DiagLogLevel.INFO,
|
|
22975
|
+
var newLogger = createLogLevelDiagLogger((_b16 = optionsOrLogLevel.logLevel) !== null && _b16 !== void 0 ? _b16 : DiagLogLevel.INFO, logger5);
|
|
22976
22976
|
if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
|
|
22977
22977
|
var stack = (_c7 = new Error().stack) !== null && _c7 !== void 0 ? _c7 : "<failed to generate stacktrace>";
|
|
22978
22978
|
oldLogger.warn("Current logger will be overwritten from " + stack);
|
|
@@ -25484,12 +25484,12 @@ var init_dist7 = __esm({
|
|
|
25484
25484
|
if (warnings.length === 0) {
|
|
25485
25485
|
return;
|
|
25486
25486
|
}
|
|
25487
|
-
const
|
|
25488
|
-
if (
|
|
25487
|
+
const logger5 = globalThis.AI_SDK_LOG_WARNINGS;
|
|
25488
|
+
if (logger5 === false) {
|
|
25489
25489
|
return;
|
|
25490
25490
|
}
|
|
25491
|
-
if (typeof
|
|
25492
|
-
|
|
25491
|
+
if (typeof logger5 === "function") {
|
|
25492
|
+
logger5(warnings);
|
|
25493
25493
|
return;
|
|
25494
25494
|
}
|
|
25495
25495
|
if (!hasLoggedBefore) {
|
|
@@ -26819,6 +26819,7 @@ function textOf(content) {
|
|
|
26819
26819
|
return "";
|
|
26820
26820
|
}
|
|
26821
26821
|
function toUserContent(content) {
|
|
26822
|
+
if (content === null) return [];
|
|
26822
26823
|
if (typeof content === "string") {
|
|
26823
26824
|
return content ? [{ type: "input_text", text: content }] : [];
|
|
26824
26825
|
}
|
|
@@ -28757,18 +28758,23 @@ async function* parseOpenRouterStream(response) {
|
|
|
28757
28758
|
yield { done: true };
|
|
28758
28759
|
return;
|
|
28759
28760
|
}
|
|
28761
|
+
let chunk2;
|
|
28760
28762
|
try {
|
|
28761
|
-
|
|
28762
|
-
if ("error" in chunk2) {
|
|
28763
|
-
throw new Error(`OpenRouter API Error: ${chunk2.error.message}`);
|
|
28764
|
-
}
|
|
28765
|
-
yield chunk2;
|
|
28763
|
+
chunk2 = JSON.parse(data2);
|
|
28766
28764
|
} catch (e15) {
|
|
28767
28765
|
logger.error("openrouter", "Failed to parse SSE chunk", {
|
|
28768
28766
|
data: data2,
|
|
28769
28767
|
error: e15
|
|
28770
28768
|
});
|
|
28769
|
+
continue;
|
|
28770
|
+
}
|
|
28771
|
+
if ("error" in chunk2) {
|
|
28772
|
+
logger.error("openrouter", "OpenRouter SSE error chunk", {
|
|
28773
|
+
error: chunk2.error
|
|
28774
|
+
});
|
|
28775
|
+
throw new Error(`OpenRouter API Error: ${chunk2.error.message}`);
|
|
28771
28776
|
}
|
|
28777
|
+
yield chunk2;
|
|
28772
28778
|
}
|
|
28773
28779
|
}
|
|
28774
28780
|
}
|
|
@@ -28863,7 +28869,6 @@ function convertToOpenRouterMessages(messages4, modelId) {
|
|
|
28863
28869
|
});
|
|
28864
28870
|
}
|
|
28865
28871
|
}
|
|
28866
|
-
const removedToolCallIds = /* @__PURE__ */ new Set();
|
|
28867
28872
|
return messages4.map((msg) => {
|
|
28868
28873
|
const extMsg = msg;
|
|
28869
28874
|
let content = extMsg.content;
|
|
@@ -28888,93 +28893,15 @@ function convertToOpenRouterMessages(messages4, modelId) {
|
|
|
28888
28893
|
baseMessage.name = extMsg.name;
|
|
28889
28894
|
}
|
|
28890
28895
|
if (extMsg.tool_calls) {
|
|
28891
|
-
|
|
28892
|
-
if (
|
|
28893
|
-
let signature = null;
|
|
28894
|
-
if (extMsg.reasoning_details && Array.isArray(extMsg.reasoning_details) && extMsg.reasoning_details.length > 0) {
|
|
28895
|
-
const reasoningWithSignature = [...extMsg.reasoning_details].reverse().find((rd) => rd.signature);
|
|
28896
|
-
signature = reasoningWithSignature?.signature || null;
|
|
28897
|
-
}
|
|
28898
|
-
if (!signature) {
|
|
28899
|
-
const currentIndex = messages4.indexOf(msg);
|
|
28900
|
-
for (let i19 = currentIndex - 1; i19 >= Math.max(0, currentIndex - 5); i19--) {
|
|
28901
|
-
const prevMsg = messages4[i19];
|
|
28902
|
-
if (prevMsg?.role === "assistant" && prevMsg.reasoning_details && Array.isArray(prevMsg.reasoning_details)) {
|
|
28903
|
-
const prevReasoningWithSignature = [...prevMsg.reasoning_details].reverse().find((rd) => rd.signature);
|
|
28904
|
-
if (prevReasoningWithSignature?.signature) {
|
|
28905
|
-
signature = prevReasoningWithSignature.signature;
|
|
28906
|
-
logger.debug(
|
|
28907
|
-
"openrouter",
|
|
28908
|
-
"Found signature from nearby message for Gemini tool calls",
|
|
28909
|
-
{
|
|
28910
|
-
currentIndex,
|
|
28911
|
-
sourceIndex: i19,
|
|
28912
|
-
signature: signature?.substring(0, 20) + "..."
|
|
28913
|
-
}
|
|
28914
|
-
);
|
|
28915
|
-
break;
|
|
28916
|
-
}
|
|
28917
|
-
}
|
|
28918
|
-
}
|
|
28919
|
-
}
|
|
28920
|
-
if (signature) {
|
|
28921
|
-
toolCalls = extMsg.tool_calls.map((tc) => ({
|
|
28922
|
-
...tc,
|
|
28923
|
-
thought_signature: signature
|
|
28924
|
-
}));
|
|
28925
|
-
logger.debug("openrouter", "Attached thought_signature to tool calls for Gemini", {
|
|
28926
|
-
toolCallsCount: toolCalls.length,
|
|
28927
|
-
signature: signature?.substring(0, 20) + "...",
|
|
28928
|
-
fromSameMessage: !!extMsg.reasoning_details
|
|
28929
|
-
});
|
|
28930
|
-
} else {
|
|
28931
|
-
const messageIndex = messages4.indexOf(msg);
|
|
28932
|
-
logger.warn(
|
|
28933
|
-
"openrouter",
|
|
28934
|
-
"Gemini tool calls missing thought_signature - filtering out to prevent API error",
|
|
28935
|
-
{
|
|
28936
|
-
toolCallsCount: toolCalls.length,
|
|
28937
|
-
toolCallNames: toolCalls.map((tc) => tc.function?.name || "unknown"),
|
|
28938
|
-
hasReasoningDetails: !!extMsg.reasoning_details,
|
|
28939
|
-
messageIndex,
|
|
28940
|
-
totalMessages: messages4.length,
|
|
28941
|
-
// Check nearby messages for reasoning_details
|
|
28942
|
-
nearbyMessagesWithReasoning: messages4.slice(Math.max(0, messageIndex - 3), messageIndex + 1).filter((m33) => m33.role === "assistant" && !!m33.reasoning_details).length,
|
|
28943
|
-
action: "Filtering out tool_calls without thought_signature"
|
|
28944
|
-
}
|
|
28945
|
-
);
|
|
28946
|
-
for (const tc of toolCalls) {
|
|
28947
|
-
if (tc.id) removedToolCallIds.add(tc.id);
|
|
28948
|
-
}
|
|
28949
|
-
toolCalls = [];
|
|
28950
|
-
}
|
|
28951
|
-
}
|
|
28952
|
-
baseMessage.tool_calls = toolCalls.length > 0 ? toolCalls : void 0;
|
|
28953
|
-
if (isGemini && toolCalls.length === 0 && extMsg.role === "assistant") {
|
|
28896
|
+
baseMessage.tool_calls = extMsg.tool_calls;
|
|
28897
|
+
if (extMsg.role === "assistant") {
|
|
28954
28898
|
const isEmptyContent = !content || typeof content === "string" && content.trim() === "" || Array.isArray(content) && content.length === 0;
|
|
28955
28899
|
if (isEmptyContent) {
|
|
28956
|
-
|
|
28957
|
-
const toolNames = originalToolCalls.map((tc) => tc.function?.name || "unknown").join(", ");
|
|
28958
|
-
const summaryText = originalToolCalls.length > 0 ? `[Previous assistant message: Called tools: ${toolNames}. Tool results are available in subsequent messages.]` : `[Previous assistant message with no content]`;
|
|
28959
|
-
logger.debug(
|
|
28960
|
-
"openrouter",
|
|
28961
|
-
"Converting empty assistant message to text summary for Gemini",
|
|
28962
|
-
{
|
|
28963
|
-
messageIndex: messages4.indexOf(msg),
|
|
28964
|
-
hadToolCalls: originalToolCalls.length,
|
|
28965
|
-
hadReasoningDetails: !!extMsg.reasoning_details,
|
|
28966
|
-
summaryText
|
|
28967
|
-
}
|
|
28968
|
-
);
|
|
28969
|
-
baseMessage.content = summaryText;
|
|
28970
|
-
baseMessage.tool_calls = void 0;
|
|
28900
|
+
baseMessage.content = null;
|
|
28971
28901
|
}
|
|
28972
28902
|
}
|
|
28973
28903
|
}
|
|
28974
28904
|
if (extMsg.tool_call_id) {
|
|
28975
|
-
if (removedToolCallIds.has(extMsg.tool_call_id)) {
|
|
28976
|
-
return null;
|
|
28977
|
-
}
|
|
28978
28905
|
baseMessage.tool_call_id = extMsg.tool_call_id;
|
|
28979
28906
|
}
|
|
28980
28907
|
if (extMsg.reasoning_details) {
|
|
@@ -28990,7 +28917,9 @@ function convertToOpenRouterTools(tools) {
|
|
|
28990
28917
|
logger.debug("openrouter", "Converting Zod schema to JSON Schema for tool", {
|
|
28991
28918
|
toolName: name18
|
|
28992
28919
|
});
|
|
28993
|
-
parameters = zodToJsonSchema2(parameters, {
|
|
28920
|
+
parameters = zodToJsonSchema2(parameters, {
|
|
28921
|
+
target: "openApi3"
|
|
28922
|
+
});
|
|
28994
28923
|
if (parameters.$schema) {
|
|
28995
28924
|
delete parameters.$schema;
|
|
28996
28925
|
}
|
|
@@ -29632,30 +29561,30 @@ var init_line = __esm({
|
|
|
29632
29561
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.90.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/internal/utils/log.mjs
|
|
29633
29562
|
function noop3() {
|
|
29634
29563
|
}
|
|
29635
|
-
function makeLogFn(fnLevel,
|
|
29636
|
-
if (!
|
|
29564
|
+
function makeLogFn(fnLevel, logger5, logLevel) {
|
|
29565
|
+
if (!logger5 || levelNumbers[fnLevel] > levelNumbers[logLevel]) {
|
|
29637
29566
|
return noop3;
|
|
29638
29567
|
} else {
|
|
29639
|
-
return
|
|
29568
|
+
return logger5[fnLevel].bind(logger5);
|
|
29640
29569
|
}
|
|
29641
29570
|
}
|
|
29642
29571
|
function loggerFor(client) {
|
|
29643
|
-
const
|
|
29572
|
+
const logger5 = client.logger;
|
|
29644
29573
|
const logLevel = client.logLevel ?? "off";
|
|
29645
|
-
if (!
|
|
29574
|
+
if (!logger5) {
|
|
29646
29575
|
return noopLogger;
|
|
29647
29576
|
}
|
|
29648
|
-
const cachedLogger = cachedLoggers.get(
|
|
29577
|
+
const cachedLogger = cachedLoggers.get(logger5);
|
|
29649
29578
|
if (cachedLogger && cachedLogger[0] === logLevel) {
|
|
29650
29579
|
return cachedLogger[1];
|
|
29651
29580
|
}
|
|
29652
29581
|
const levelLogger = {
|
|
29653
|
-
error: makeLogFn("error",
|
|
29654
|
-
warn: makeLogFn("warn",
|
|
29655
|
-
info: makeLogFn("info",
|
|
29656
|
-
debug: makeLogFn("debug",
|
|
29582
|
+
error: makeLogFn("error", logger5, logLevel),
|
|
29583
|
+
warn: makeLogFn("warn", logger5, logLevel),
|
|
29584
|
+
info: makeLogFn("info", logger5, logLevel),
|
|
29585
|
+
debug: makeLogFn("debug", logger5, logLevel)
|
|
29657
29586
|
};
|
|
29658
|
-
cachedLoggers.set(
|
|
29587
|
+
cachedLoggers.set(logger5, [logLevel, levelLogger]);
|
|
29659
29588
|
return levelLogger;
|
|
29660
29589
|
}
|
|
29661
29590
|
var levelNumbers, parseLogLevel, noopLogger, cachedLoggers, formatRequestDetails;
|
|
@@ -29785,7 +29714,7 @@ var init_streaming = __esm({
|
|
|
29785
29714
|
}
|
|
29786
29715
|
static fromSSEResponse(response, controller, client) {
|
|
29787
29716
|
let consumed = false;
|
|
29788
|
-
const
|
|
29717
|
+
const logger5 = client ? loggerFor(client) : console;
|
|
29789
29718
|
async function* iterator() {
|
|
29790
29719
|
if (consumed) {
|
|
29791
29720
|
throw new AnthropicError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
@@ -29798,8 +29727,8 @@ var init_streaming = __esm({
|
|
|
29798
29727
|
try {
|
|
29799
29728
|
yield JSON.parse(sse.data);
|
|
29800
29729
|
} catch (e15) {
|
|
29801
|
-
|
|
29802
|
-
|
|
29730
|
+
logger5.error(`Could not parse message into JSON:`, sse.data);
|
|
29731
|
+
logger5.error(`From chunk:`, sse.raw);
|
|
29803
29732
|
throw e15;
|
|
29804
29733
|
}
|
|
29805
29734
|
}
|
|
@@ -29807,8 +29736,8 @@ var init_streaming = __esm({
|
|
|
29807
29736
|
try {
|
|
29808
29737
|
yield JSON.parse(sse.data);
|
|
29809
29738
|
} catch (e15) {
|
|
29810
|
-
|
|
29811
|
-
|
|
29739
|
+
logger5.error(`Could not parse message into JSON:`, sse.data);
|
|
29740
|
+
logger5.error(`From chunk:`, sse.raw);
|
|
29812
29741
|
throw e15;
|
|
29813
29742
|
}
|
|
29814
29743
|
}
|
|
@@ -31673,8 +31602,8 @@ var init_BetaMessageStream = __esm({
|
|
|
31673
31602
|
runner._run(() => runner._fromReadableStream(stream));
|
|
31674
31603
|
return runner;
|
|
31675
31604
|
}
|
|
31676
|
-
static createMessage(messages4, params, options2, { logger:
|
|
31677
|
-
const runner = new _BetaMessageStream(params, { logger:
|
|
31605
|
+
static createMessage(messages4, params, options2, { logger: logger5 } = {}) {
|
|
31606
|
+
const runner = new _BetaMessageStream(params, { logger: logger5 });
|
|
31678
31607
|
for (const message of params.messages) {
|
|
31679
31608
|
runner._addMessageParam(message);
|
|
31680
31609
|
}
|
|
@@ -34113,8 +34042,8 @@ var init_MessageStream = __esm({
|
|
|
34113
34042
|
runner._run(() => runner._fromReadableStream(stream));
|
|
34114
34043
|
return runner;
|
|
34115
34044
|
}
|
|
34116
|
-
static createMessage(messages4, params, options2, { logger:
|
|
34117
|
-
const runner = new _MessageStream(params, { logger:
|
|
34045
|
+
static createMessage(messages4, params, options2, { logger: logger5 } = {}) {
|
|
34046
|
+
const runner = new _MessageStream(params, { logger: logger5 });
|
|
34118
34047
|
for (const message of params.messages) {
|
|
34119
34048
|
runner._addMessageParam(message);
|
|
34120
34049
|
}
|
|
@@ -50067,6 +49996,9 @@ var init_model_registry_generated = __esm({
|
|
|
50067
49996
|
});
|
|
50068
49997
|
|
|
50069
49998
|
// src/lib/model-registry.ts
|
|
49999
|
+
function isGoogleDirectModel(modelId) {
|
|
50000
|
+
return modelId in GOOGLE_DIRECT_MODELS;
|
|
50001
|
+
}
|
|
50070
50002
|
function getBedrockRegionPrefix(awsRegion) {
|
|
50071
50003
|
const prefix = awsRegion.split("-")[0];
|
|
50072
50004
|
return prefix || "us";
|
|
@@ -50081,24 +50013,19 @@ function resolveBedrockModelId(anthropicModelId, awsRegion) {
|
|
|
50081
50013
|
}
|
|
50082
50014
|
return `${getBedrockRegionPrefix(awsRegion)}.anthropic.${anthropicModelId}-v1:0`;
|
|
50083
50015
|
}
|
|
50084
|
-
function isGoogleDirectModel(modelId) {
|
|
50085
|
-
return modelId in GOOGLE_DIRECT_MODELS;
|
|
50086
|
-
}
|
|
50087
50016
|
function toModelDefinition(model) {
|
|
50088
|
-
|
|
50089
|
-
if (anthropicModelId) {
|
|
50017
|
+
if (model.vendor === "anthropic") {
|
|
50090
50018
|
return {
|
|
50091
50019
|
...model,
|
|
50092
|
-
provider: "anthropic
|
|
50093
|
-
providerModelId:
|
|
50020
|
+
provider: "anthropic",
|
|
50021
|
+
providerModelId: model.id
|
|
50094
50022
|
};
|
|
50095
50023
|
}
|
|
50096
|
-
|
|
50097
|
-
if (googleModelId) {
|
|
50024
|
+
if (isGoogleDirectModel(model.id)) {
|
|
50098
50025
|
return {
|
|
50099
50026
|
...model,
|
|
50100
50027
|
provider: "google-direct",
|
|
50101
|
-
providerModelId:
|
|
50028
|
+
providerModelId: GOOGLE_DIRECT_MODELS[model.id] ?? model.id
|
|
50102
50029
|
};
|
|
50103
50030
|
}
|
|
50104
50031
|
return {
|
|
@@ -50126,7 +50053,7 @@ function calculateMaxOutputTokens(modelId, inputTokens) {
|
|
|
50126
50053
|
const fits = contextLength - inputTokens - CONTEXT_BUFFER;
|
|
50127
50054
|
return Math.max(0, Math.min(OUTPUT_TOKEN_CEILING, maxOutputTokens, fits));
|
|
50128
50055
|
}
|
|
50129
|
-
var BEDROCK_MODEL_DEFS,
|
|
50056
|
+
var BEDROCK_MODEL_DEFS, GOOGLE_DIRECT_MODELS, MODEL_REGISTRY, CATEGORY_LABELS, DEFAULT_CONTEXT_LENGTH, DEFAULT_MAX_OUTPUT_TOKENS, OUTPUT_TOKEN_CEILING, CONTEXT_BUFFER;
|
|
50130
50057
|
var init_model_registry = __esm({
|
|
50131
50058
|
"src/lib/model-registry.ts"() {
|
|
50132
50059
|
"use strict";
|
|
@@ -50134,35 +50061,50 @@ var init_model_registry = __esm({
|
|
|
50134
50061
|
init_model_registry_generated();
|
|
50135
50062
|
BEDROCK_MODEL_DEFS = {
|
|
50136
50063
|
// Claude 4.x+ — require cross-region inference profiles
|
|
50137
|
-
"claude-haiku-4-5-20251001": {
|
|
50138
|
-
|
|
50139
|
-
|
|
50064
|
+
"claude-haiku-4-5-20251001": {
|
|
50065
|
+
bedrockId: "anthropic.claude-haiku-4-5-20251001-v1:0",
|
|
50066
|
+
crossRegion: true
|
|
50067
|
+
},
|
|
50068
|
+
"claude-sonnet-4-20250514": {
|
|
50069
|
+
bedrockId: "anthropic.claude-sonnet-4-20250514-v1:0",
|
|
50070
|
+
crossRegion: true
|
|
50071
|
+
},
|
|
50072
|
+
"claude-sonnet-4-5-20250929": {
|
|
50073
|
+
bedrockId: "anthropic.claude-sonnet-4-5-20250929-v1:0",
|
|
50074
|
+
crossRegion: true
|
|
50075
|
+
},
|
|
50140
50076
|
"claude-sonnet-4-6": { bedrockId: "anthropic.claude-sonnet-4-6", crossRegion: true },
|
|
50141
50077
|
// Opus 4.7 uses the Global Cross-Region Inference profile (no regional Geo access required)
|
|
50142
50078
|
"claude-opus-4-7": { bedrockId: "global.anthropic.claude-opus-4-7", crossRegion: false },
|
|
50143
|
-
"claude-opus-4-20250514": {
|
|
50144
|
-
|
|
50145
|
-
|
|
50146
|
-
|
|
50079
|
+
"claude-opus-4-20250514": {
|
|
50080
|
+
bedrockId: "anthropic.claude-opus-4-20250514-v1:0",
|
|
50081
|
+
crossRegion: true
|
|
50082
|
+
},
|
|
50083
|
+
"claude-opus-4-1-20250610": {
|
|
50084
|
+
bedrockId: "anthropic.claude-opus-4-1-20250610-v1:0",
|
|
50085
|
+
crossRegion: true
|
|
50086
|
+
},
|
|
50087
|
+
"claude-opus-4-5-20250829": {
|
|
50088
|
+
bedrockId: "anthropic.claude-opus-4-5-20250829-v1:0",
|
|
50089
|
+
crossRegion: true
|
|
50090
|
+
},
|
|
50091
|
+
"claude-3-7-sonnet-20250219": {
|
|
50092
|
+
bedrockId: "anthropic.claude-3-7-sonnet-20250219-v1:0",
|
|
50093
|
+
crossRegion: true
|
|
50094
|
+
},
|
|
50147
50095
|
// Claude 3.5 / 3 — use direct model IDs (no region prefix)
|
|
50148
|
-
"claude-3-5-sonnet-20241022": {
|
|
50149
|
-
|
|
50150
|
-
|
|
50151
|
-
|
|
50152
|
-
|
|
50153
|
-
|
|
50154
|
-
|
|
50155
|
-
|
|
50156
|
-
"
|
|
50157
|
-
|
|
50158
|
-
|
|
50159
|
-
|
|
50160
|
-
"anthropic/claude-opus-4.7": "claude-opus-4-7",
|
|
50161
|
-
"anthropic/claude-3.7-sonnet": "claude-3-7-sonnet-20250219",
|
|
50162
|
-
"anthropic/claude-3.7-sonnet:thinking": "claude-3-7-sonnet-20250219",
|
|
50163
|
-
"anthropic/claude-3.5-sonnet": "claude-3-5-sonnet-20241022",
|
|
50164
|
-
"anthropic/claude-3.5-haiku": "claude-3-5-haiku-20241022",
|
|
50165
|
-
"anthropic/claude-3-haiku": "claude-3-haiku-20240307"
|
|
50096
|
+
"claude-3-5-sonnet-20241022": {
|
|
50097
|
+
bedrockId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
|
|
50098
|
+
crossRegion: false
|
|
50099
|
+
},
|
|
50100
|
+
"claude-3-5-haiku-20241022": {
|
|
50101
|
+
bedrockId: "anthropic.claude-3-5-haiku-20241022-v1:0",
|
|
50102
|
+
crossRegion: false
|
|
50103
|
+
},
|
|
50104
|
+
"claude-3-haiku-20240307": {
|
|
50105
|
+
bedrockId: "anthropic.claude-3-haiku-20240307-v1:0",
|
|
50106
|
+
crossRegion: false
|
|
50107
|
+
}
|
|
50166
50108
|
};
|
|
50167
50109
|
GOOGLE_DIRECT_MODELS = {
|
|
50168
50110
|
"google/gemini-3.1-pro-preview": "gemini-3.1-pro-preview",
|
|
@@ -102747,12 +102689,12 @@ var init_session2 = __esm({
|
|
|
102747
102689
|
init_tracing();
|
|
102748
102690
|
init_utils2();
|
|
102749
102691
|
PostgresJsPreparedQuery = class extends PgPreparedQuery {
|
|
102750
|
-
constructor(client, queryString, params,
|
|
102692
|
+
constructor(client, queryString, params, logger5, cache8, queryMetadata, cacheConfig, fields, _isResponseInArrayMode, customResultMapper) {
|
|
102751
102693
|
super({ sql: queryString, params }, cache8, queryMetadata, cacheConfig);
|
|
102752
102694
|
this.client = client;
|
|
102753
102695
|
this.queryString = queryString;
|
|
102754
102696
|
this.params = params;
|
|
102755
|
-
this.logger =
|
|
102697
|
+
this.logger = logger5;
|
|
102756
102698
|
this.fields = fields;
|
|
102757
102699
|
this._isResponseInArrayMode = _isResponseInArrayMode;
|
|
102758
102700
|
this.customResultMapper = customResultMapper;
|
|
@@ -102893,11 +102835,11 @@ function construct(client, config3 = {}) {
|
|
|
102893
102835
|
client.options.serializers["114"] = transparentParser;
|
|
102894
102836
|
client.options.serializers["3802"] = transparentParser;
|
|
102895
102837
|
const dialect = new PgDialect({ casing: config3.casing });
|
|
102896
|
-
let
|
|
102838
|
+
let logger5;
|
|
102897
102839
|
if (config3.logger === true) {
|
|
102898
|
-
|
|
102840
|
+
logger5 = new DefaultLogger();
|
|
102899
102841
|
} else if (config3.logger !== false) {
|
|
102900
|
-
|
|
102842
|
+
logger5 = config3.logger;
|
|
102901
102843
|
}
|
|
102902
102844
|
let schema;
|
|
102903
102845
|
if (config3.schema) {
|
|
@@ -102911,7 +102853,7 @@ function construct(client, config3 = {}) {
|
|
|
102911
102853
|
tableNamesMap: tablesConfig.tableNamesMap
|
|
102912
102854
|
};
|
|
102913
102855
|
}
|
|
102914
|
-
const session = new PostgresJsSession(client, dialect, schema, { logger:
|
|
102856
|
+
const session = new PostgresJsSession(client, dialect, schema, { logger: logger5, cache: config3.cache });
|
|
102915
102857
|
const db3 = new PostgresJsDatabase(dialect, session, schema);
|
|
102916
102858
|
db3.$client = client;
|
|
102917
102859
|
db3.$cache = config3.cache;
|
|
@@ -105017,30 +104959,30 @@ var init_line3 = __esm({
|
|
|
105017
104959
|
// node_modules/.pnpm/@anthropic-ai+sdk@0.68.0_zod@3.25.76/node_modules/@anthropic-ai/sdk/internal/utils/log.mjs
|
|
105018
104960
|
function noop6() {
|
|
105019
104961
|
}
|
|
105020
|
-
function makeLogFn2(fnLevel,
|
|
105021
|
-
if (!
|
|
104962
|
+
function makeLogFn2(fnLevel, logger5, logLevel) {
|
|
104963
|
+
if (!logger5 || levelNumbers2[fnLevel] > levelNumbers2[logLevel]) {
|
|
105022
104964
|
return noop6;
|
|
105023
104965
|
} else {
|
|
105024
|
-
return
|
|
104966
|
+
return logger5[fnLevel].bind(logger5);
|
|
105025
104967
|
}
|
|
105026
104968
|
}
|
|
105027
104969
|
function loggerFor2(client) {
|
|
105028
|
-
const
|
|
104970
|
+
const logger5 = client.logger;
|
|
105029
104971
|
const logLevel = client.logLevel ?? "off";
|
|
105030
|
-
if (!
|
|
104972
|
+
if (!logger5) {
|
|
105031
104973
|
return noopLogger2;
|
|
105032
104974
|
}
|
|
105033
|
-
const cachedLogger = cachedLoggers2.get(
|
|
104975
|
+
const cachedLogger = cachedLoggers2.get(logger5);
|
|
105034
104976
|
if (cachedLogger && cachedLogger[0] === logLevel) {
|
|
105035
104977
|
return cachedLogger[1];
|
|
105036
104978
|
}
|
|
105037
104979
|
const levelLogger = {
|
|
105038
|
-
error: makeLogFn2("error",
|
|
105039
|
-
warn: makeLogFn2("warn",
|
|
105040
|
-
info: makeLogFn2("info",
|
|
105041
|
-
debug: makeLogFn2("debug",
|
|
104980
|
+
error: makeLogFn2("error", logger5, logLevel),
|
|
104981
|
+
warn: makeLogFn2("warn", logger5, logLevel),
|
|
104982
|
+
info: makeLogFn2("info", logger5, logLevel),
|
|
104983
|
+
debug: makeLogFn2("debug", logger5, logLevel)
|
|
105042
104984
|
};
|
|
105043
|
-
cachedLoggers2.set(
|
|
104985
|
+
cachedLoggers2.set(logger5, [logLevel, levelLogger]);
|
|
105044
104986
|
return levelLogger;
|
|
105045
104987
|
}
|
|
105046
104988
|
var levelNumbers2, parseLogLevel2, noopLogger2, cachedLoggers2, formatRequestDetails2;
|
|
@@ -105170,7 +105112,7 @@ var init_streaming3 = __esm({
|
|
|
105170
105112
|
}
|
|
105171
105113
|
static fromSSEResponse(response, controller, client) {
|
|
105172
105114
|
let consumed = false;
|
|
105173
|
-
const
|
|
105115
|
+
const logger5 = client ? loggerFor2(client) : console;
|
|
105174
105116
|
async function* iterator() {
|
|
105175
105117
|
if (consumed) {
|
|
105176
105118
|
throw new AnthropicError2("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
@@ -105183,8 +105125,8 @@ var init_streaming3 = __esm({
|
|
|
105183
105125
|
try {
|
|
105184
105126
|
yield JSON.parse(sse.data);
|
|
105185
105127
|
} catch (e15) {
|
|
105186
|
-
|
|
105187
|
-
|
|
105128
|
+
logger5.error(`Could not parse message into JSON:`, sse.data);
|
|
105129
|
+
logger5.error(`From chunk:`, sse.raw);
|
|
105188
105130
|
throw e15;
|
|
105189
105131
|
}
|
|
105190
105132
|
}
|
|
@@ -105192,8 +105134,8 @@ var init_streaming3 = __esm({
|
|
|
105192
105134
|
try {
|
|
105193
105135
|
yield JSON.parse(sse.data);
|
|
105194
105136
|
} catch (e15) {
|
|
105195
|
-
|
|
105196
|
-
|
|
105137
|
+
logger5.error(`Could not parse message into JSON:`, sse.data);
|
|
105138
|
+
logger5.error(`From chunk:`, sse.raw);
|
|
105197
105139
|
throw e15;
|
|
105198
105140
|
}
|
|
105199
105141
|
}
|
|
@@ -112472,19 +112414,19 @@ var require_dist_cjs21 = __commonJS({
|
|
|
112472
112414
|
name = "ProviderError";
|
|
112473
112415
|
tryNextLink;
|
|
112474
112416
|
constructor(message, options2 = true) {
|
|
112475
|
-
let
|
|
112417
|
+
let logger5;
|
|
112476
112418
|
let tryNextLink = true;
|
|
112477
112419
|
if (typeof options2 === "boolean") {
|
|
112478
|
-
|
|
112420
|
+
logger5 = void 0;
|
|
112479
112421
|
tryNextLink = options2;
|
|
112480
112422
|
} else if (options2 != null && typeof options2 === "object") {
|
|
112481
|
-
|
|
112423
|
+
logger5 = options2.logger;
|
|
112482
112424
|
tryNextLink = options2.tryNextLink ?? true;
|
|
112483
112425
|
}
|
|
112484
112426
|
super(message);
|
|
112485
112427
|
this.tryNextLink = tryNextLink;
|
|
112486
112428
|
Object.setPrototypeOf(this, _ProviderError.prototype);
|
|
112487
|
-
|
|
112429
|
+
logger5?.debug?.(`@smithy/property-provider ${tryNextLink ? "->" : "(!)"} ${message}`);
|
|
112488
112430
|
}
|
|
112489
112431
|
static from(error41, options2 = true) {
|
|
112490
112432
|
return Object.assign(new this(error41.message, options2), error41);
|
|
@@ -112677,12 +112619,12 @@ var require_dist_cjs23 = __commonJS({
|
|
|
112677
112619
|
var loggerMiddleware = () => (next, context) => async (args) => {
|
|
112678
112620
|
try {
|
|
112679
112621
|
const response = await next(args);
|
|
112680
|
-
const { clientName, commandName, logger:
|
|
112622
|
+
const { clientName, commandName, logger: logger5, dynamoDbDocumentClientOptions = {} } = context;
|
|
112681
112623
|
const { overrideInputFilterSensitiveLog, overrideOutputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
112682
112624
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
112683
112625
|
const outputFilterSensitiveLog = overrideOutputFilterSensitiveLog ?? context.outputFilterSensitiveLog;
|
|
112684
112626
|
const { $metadata, ...outputWithoutMetadata } = response.output;
|
|
112685
|
-
|
|
112627
|
+
logger5?.info?.({
|
|
112686
112628
|
clientName,
|
|
112687
112629
|
commandName,
|
|
112688
112630
|
input: inputFilterSensitiveLog(args.input),
|
|
@@ -112691,10 +112633,10 @@ var require_dist_cjs23 = __commonJS({
|
|
|
112691
112633
|
});
|
|
112692
112634
|
return response;
|
|
112693
112635
|
} catch (error41) {
|
|
112694
|
-
const { clientName, commandName, logger:
|
|
112636
|
+
const { clientName, commandName, logger: logger5, dynamoDbDocumentClientOptions = {} } = context;
|
|
112695
112637
|
const { overrideInputFilterSensitiveLog } = dynamoDbDocumentClientOptions;
|
|
112696
112638
|
const inputFilterSensitiveLog = overrideInputFilterSensitiveLog ?? context.inputFilterSensitiveLog;
|
|
112697
|
-
|
|
112639
|
+
logger5?.error?.({
|
|
112698
112640
|
clientName,
|
|
112699
112641
|
commandName,
|
|
112700
112642
|
input: inputFilterSensitiveLog(args.input),
|
|
@@ -113410,7 +113352,7 @@ var require_createBufferedReadableStream = __commonJS({
|
|
|
113410
113352
|
exports.sizeOf = sizeOf;
|
|
113411
113353
|
exports.modeOf = modeOf;
|
|
113412
113354
|
var ByteArrayCollector_1 = require_ByteArrayCollector();
|
|
113413
|
-
function createBufferedReadableStream(upstream, size2,
|
|
113355
|
+
function createBufferedReadableStream(upstream, size2, logger5) {
|
|
113414
113356
|
const reader = upstream.getReader();
|
|
113415
113357
|
let streamBufferingLoggedWarning = false;
|
|
113416
113358
|
let bytesSeen = 0;
|
|
@@ -113448,7 +113390,7 @@ var require_createBufferedReadableStream = __commonJS({
|
|
|
113448
113390
|
const newSize = merge2(buffers, mode2, chunk2);
|
|
113449
113391
|
if (!streamBufferingLoggedWarning && bytesSeen > size2 * 2) {
|
|
113450
113392
|
streamBufferingLoggedWarning = true;
|
|
113451
|
-
|
|
113393
|
+
logger5?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size2}, automatically buffering.`);
|
|
113452
113394
|
}
|
|
113453
113395
|
if (newSize >= size2) {
|
|
113454
113396
|
controller.enqueue(flush(buffers, mode2));
|
|
@@ -113514,9 +113456,9 @@ var require_createBufferedReadable = __commonJS({
|
|
|
113514
113456
|
var ByteArrayCollector_1 = require_ByteArrayCollector();
|
|
113515
113457
|
var createBufferedReadableStream_1 = require_createBufferedReadableStream();
|
|
113516
113458
|
var stream_type_check_1 = require_stream_type_check();
|
|
113517
|
-
function createBufferedReadable(upstream, size2,
|
|
113459
|
+
function createBufferedReadable(upstream, size2, logger5) {
|
|
113518
113460
|
if ((0, stream_type_check_1.isReadableStream)(upstream)) {
|
|
113519
|
-
return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size2,
|
|
113461
|
+
return (0, createBufferedReadableStream_1.createBufferedReadableStream)(upstream, size2, logger5);
|
|
113520
113462
|
}
|
|
113521
113463
|
const downstream = new node_stream_1.Readable({ read() {
|
|
113522
113464
|
} });
|
|
@@ -113549,7 +113491,7 @@ var require_createBufferedReadable = __commonJS({
|
|
|
113549
113491
|
const newSize = (0, createBufferedReadableStream_1.merge)(buffers, mode2, chunk2);
|
|
113550
113492
|
if (!streamBufferingLoggedWarning && bytesSeen > size2 * 2) {
|
|
113551
113493
|
streamBufferingLoggedWarning = true;
|
|
113552
|
-
|
|
113494
|
+
logger5?.warn(`@smithy/util-stream - stream chunk size ${chunkSize} is below threshold of ${size2}, automatically buffering.`);
|
|
113553
113495
|
}
|
|
113554
113496
|
if (newSize >= size2) {
|
|
113555
113497
|
downstream.push((0, createBufferedReadableStream_1.flush)(buffers, mode2));
|
|
@@ -113816,7 +113758,7 @@ var require_dist_cjs26 = __commonJS({
|
|
|
113816
113758
|
}
|
|
113817
113759
|
return timing.setTimeout(registerTimeout.bind(null, DEFER_EVENT_LISTENER_TIME$2), DEFER_EVENT_LISTENER_TIME$2);
|
|
113818
113760
|
};
|
|
113819
|
-
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout,
|
|
113761
|
+
var setRequestTimeout = (req, reject, timeoutInMs = 0, throwOnRequestTimeout, logger5) => {
|
|
113820
113762
|
if (timeoutInMs) {
|
|
113821
113763
|
return timing.setTimeout(() => {
|
|
113822
113764
|
let msg = `@smithy/node-http-handler - [${throwOnRequestTimeout ? "ERROR" : "WARN"}] a request has exceeded the configured ${timeoutInMs} ms requestTimeout.`;
|
|
@@ -113829,7 +113771,7 @@ var require_dist_cjs26 = __commonJS({
|
|
|
113829
113771
|
reject(error41);
|
|
113830
113772
|
} else {
|
|
113831
113773
|
msg += ` Init client requestHandler with throwOnRequestTimeout=true to turn this into an error.`;
|
|
113832
|
-
|
|
113774
|
+
logger5?.warn?.(msg);
|
|
113833
113775
|
}
|
|
113834
113776
|
}, timeoutInMs);
|
|
113835
113777
|
}
|
|
@@ -113946,7 +113888,7 @@ var require_dist_cjs26 = __commonJS({
|
|
|
113946
113888
|
}
|
|
113947
113889
|
return new _NodeHttpHandler(instanceOrOptions);
|
|
113948
113890
|
}
|
|
113949
|
-
static checkSocketUsage(agent, socketWarningTimestamp,
|
|
113891
|
+
static checkSocketUsage(agent, socketWarningTimestamp, logger5 = console) {
|
|
113950
113892
|
const { sockets, requests, maxSockets } = agent;
|
|
113951
113893
|
if (typeof maxSockets !== "number" || maxSockets === Infinity) {
|
|
113952
113894
|
return socketWarningTimestamp;
|
|
@@ -113960,7 +113902,7 @@ var require_dist_cjs26 = __commonJS({
|
|
|
113960
113902
|
const socketsInUse = sockets[origin]?.length ?? 0;
|
|
113961
113903
|
const requestsEnqueued = requests[origin]?.length ?? 0;
|
|
113962
113904
|
if (socketsInUse >= maxSockets && requestsEnqueued >= 2 * maxSockets) {
|
|
113963
|
-
|
|
113905
|
+
logger5?.warn?.(`@smithy/node-http-handler:WARN - socket usage at capacity=${socketsInUse} and ${requestsEnqueued} additional requests are enqueued.
|
|
113964
113906
|
See https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-configuring-maxsockets.html
|
|
113965
113907
|
or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler config.`);
|
|
113966
113908
|
return Date.now();
|
|
@@ -113981,7 +113923,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
113981
113923
|
});
|
|
113982
113924
|
}
|
|
113983
113925
|
resolveDefaultConfig(options2) {
|
|
113984
|
-
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger:
|
|
113926
|
+
const { requestTimeout, connectionTimeout, socketTimeout, socketAcquisitionWarningTimeout, httpAgent, httpsAgent, throwOnRequestTimeout, logger: logger5 } = options2 || {};
|
|
113985
113927
|
const keepAlive = true;
|
|
113986
113928
|
const maxSockets = 50;
|
|
113987
113929
|
return {
|
|
@@ -114004,7 +113946,7 @@ or increase socketAcquisitionWarningTimeout=(millis) in the NodeHttpHandler conf
|
|
|
114004
113946
|
}
|
|
114005
113947
|
return new https2.Agent({ keepAlive, maxSockets, ...httpsAgent });
|
|
114006
113948
|
})(),
|
|
114007
|
-
logger:
|
|
113949
|
+
logger: logger5
|
|
114008
113950
|
};
|
|
114009
113951
|
}
|
|
114010
113952
|
destroy() {
|
|
@@ -118341,7 +118283,7 @@ var require_dist_cjs32 = __commonJS({
|
|
|
118341
118283
|
evaluateTreeRule
|
|
118342
118284
|
};
|
|
118343
118285
|
var resolveEndpoint7 = (ruleSetObject, options2) => {
|
|
118344
|
-
const { endpointParams, logger:
|
|
118286
|
+
const { endpointParams, logger: logger5 } = options2;
|
|
118345
118287
|
const { parameters, rules } = ruleSetObject;
|
|
118346
118288
|
options2.logger?.debug?.(`${debugId} Initial EndpointParams: ${toDebugString(endpointParams)}`);
|
|
118347
118289
|
const paramsWithDefault = Object.entries(parameters).filter(([, v33]) => v33.default != null).map(([k23, v33]) => [k23, v33.default]);
|
|
@@ -118356,7 +118298,7 @@ var require_dist_cjs32 = __commonJS({
|
|
|
118356
118298
|
throw new EndpointError(`Missing required parameter: '${requiredParam}'`);
|
|
118357
118299
|
}
|
|
118358
118300
|
}
|
|
118359
|
-
const endpoint = evaluateRules(rules, { endpointParams, logger:
|
|
118301
|
+
const endpoint = evaluateRules(rules, { endpointParams, logger: logger5, referenceRecord: {} });
|
|
118360
118302
|
options2.logger?.debug?.(`${debugId} Resolved endpoint: ${toDebugString(endpoint)}`);
|
|
118361
118303
|
return endpoint;
|
|
118362
118304
|
};
|
|
@@ -121193,9 +121135,9 @@ var require_dist_cjs36 = __commonJS({
|
|
|
121193
121135
|
this.middlewareStack.use(mw);
|
|
121194
121136
|
}
|
|
121195
121137
|
const stack = clientStack.concat(this.middlewareStack);
|
|
121196
|
-
const { logger:
|
|
121138
|
+
const { logger: logger5 } = configuration;
|
|
121197
121139
|
const handlerExecutionContext = {
|
|
121198
|
-
logger:
|
|
121140
|
+
logger: logger5,
|
|
121199
121141
|
clientName,
|
|
121200
121142
|
commandName,
|
|
121201
121143
|
inputFilterSensitiveLog,
|
|
@@ -125203,11 +125145,11 @@ var require_dist_cjs40 = __commonJS({
|
|
|
125203
125145
|
userAgentAppId: async () => {
|
|
125204
125146
|
const appId = await normalizedAppIdProvider();
|
|
125205
125147
|
if (!isValidUserAgentAppId(appId)) {
|
|
125206
|
-
const
|
|
125148
|
+
const logger5 = input.logger?.constructor?.name === "NoOpLogger" || !input.logger ? console : input.logger;
|
|
125207
125149
|
if (typeof appId !== "string") {
|
|
125208
|
-
|
|
125150
|
+
logger5?.warn("userAgentAppId must be a string or undefined.");
|
|
125209
125151
|
} else if (appId.length > 50) {
|
|
125210
|
-
|
|
125152
|
+
logger5?.warn("The provided userAgentAppId exceeds the maximum length of 50 characters.");
|
|
125211
125153
|
}
|
|
125212
125154
|
}
|
|
125213
125155
|
return appId;
|
|
@@ -125906,8 +125848,8 @@ var require_dist_cjs45 = __commonJS({
|
|
|
125906
125848
|
var isFunction = (func) => typeof func === "function";
|
|
125907
125849
|
var fromStatic = (defaultValue) => isFunction(defaultValue) ? async () => await defaultValue() : propertyProvider.fromStatic(defaultValue);
|
|
125908
125850
|
var loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => {
|
|
125909
|
-
const { signingName, logger:
|
|
125910
|
-
const envOptions = { signingName, logger:
|
|
125851
|
+
const { signingName, logger: logger5 } = configuration;
|
|
125852
|
+
const envOptions = { signingName, logger: logger5 };
|
|
125911
125853
|
return propertyProvider.memoize(propertyProvider.chain(fromEnv(environmentVariableSelector, envOptions), fromSharedConfigFiles(configFileSelector, configuration), fromStatic(defaultValue)));
|
|
125912
125854
|
};
|
|
125913
125855
|
exports.loadConfig = loadConfig;
|
|
@@ -127006,7 +126948,7 @@ var require_dist_cjs50 = __commonJS({
|
|
|
127006
126948
|
"http:": true,
|
|
127007
126949
|
"https:": true
|
|
127008
126950
|
};
|
|
127009
|
-
var getCmdsUri = async ({ logger:
|
|
126951
|
+
var getCmdsUri = async ({ logger: logger5 }) => {
|
|
127010
126952
|
if (process.env[ENV_CMDS_RELATIVE_URI]) {
|
|
127011
126953
|
return {
|
|
127012
126954
|
hostname: CMDS_IP,
|
|
@@ -127018,13 +126960,13 @@ var require_dist_cjs50 = __commonJS({
|
|
|
127018
126960
|
if (!parsed.hostname || !(parsed.hostname in GREENGRASS_HOSTS)) {
|
|
127019
126961
|
throw new propertyProvider.CredentialsProviderError(`${parsed.hostname} is not a valid container metadata service hostname`, {
|
|
127020
126962
|
tryNextLink: false,
|
|
127021
|
-
logger:
|
|
126963
|
+
logger: logger5
|
|
127022
126964
|
});
|
|
127023
126965
|
}
|
|
127024
126966
|
if (!parsed.protocol || !(parsed.protocol in GREENGRASS_PROTOCOLS)) {
|
|
127025
126967
|
throw new propertyProvider.CredentialsProviderError(`${parsed.protocol} is not a valid container metadata service protocol`, {
|
|
127026
126968
|
tryNextLink: false,
|
|
127027
|
-
logger:
|
|
126969
|
+
logger: logger5
|
|
127028
126970
|
});
|
|
127029
126971
|
}
|
|
127030
126972
|
return {
|
|
@@ -127034,7 +126976,7 @@ var require_dist_cjs50 = __commonJS({
|
|
|
127034
126976
|
}
|
|
127035
126977
|
throw new propertyProvider.CredentialsProviderError(`The container metadata credential provider cannot be used unless the ${ENV_CMDS_RELATIVE_URI} or ${ENV_CMDS_FULL_URI} environment variable is set`, {
|
|
127036
126978
|
tryNextLink: false,
|
|
127037
|
-
logger:
|
|
126979
|
+
logger: logger5
|
|
127038
126980
|
});
|
|
127039
126981
|
};
|
|
127040
126982
|
var InstanceMetadataV1FallbackError = class _InstanceMetadataV1FallbackError extends propertyProvider.CredentialsProviderError {
|
|
@@ -127086,10 +127028,10 @@ var require_dist_cjs50 = __commonJS({
|
|
|
127086
127028
|
var STATIC_STABILITY_REFRESH_INTERVAL_SECONDS = 5 * 60;
|
|
127087
127029
|
var STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS = 5 * 60;
|
|
127088
127030
|
var STATIC_STABILITY_DOC_URL = "https://docs.aws.amazon.com/sdkref/latest/guide/feature-static-credentials.html";
|
|
127089
|
-
var getExtendedInstanceMetadataCredentials = (credentials,
|
|
127031
|
+
var getExtendedInstanceMetadataCredentials = (credentials, logger5) => {
|
|
127090
127032
|
const refreshInterval = STATIC_STABILITY_REFRESH_INTERVAL_SECONDS + Math.floor(Math.random() * STATIC_STABILITY_REFRESH_INTERVAL_JITTER_WINDOW_SECONDS);
|
|
127091
127033
|
const newExpiration = new Date(Date.now() + refreshInterval * 1e3);
|
|
127092
|
-
|
|
127034
|
+
logger5.warn(`Attempting credential expiration extension due to a credential service availability issue. A refresh of these credentials will be attempted after ${new Date(newExpiration)}.
|
|
127093
127035
|
For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
127094
127036
|
const originalExpiration = credentials.originalExpiration ?? credentials.expiration;
|
|
127095
127037
|
return {
|
|
@@ -127099,19 +127041,19 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
127099
127041
|
};
|
|
127100
127042
|
};
|
|
127101
127043
|
var staticStabilityProvider = (provider, options2 = {}) => {
|
|
127102
|
-
const
|
|
127044
|
+
const logger5 = options2?.logger || console;
|
|
127103
127045
|
let pastCredentials;
|
|
127104
127046
|
return async () => {
|
|
127105
127047
|
let credentials;
|
|
127106
127048
|
try {
|
|
127107
127049
|
credentials = await provider();
|
|
127108
127050
|
if (credentials.expiration && credentials.expiration.getTime() < Date.now()) {
|
|
127109
|
-
credentials = getExtendedInstanceMetadataCredentials(credentials,
|
|
127051
|
+
credentials = getExtendedInstanceMetadataCredentials(credentials, logger5);
|
|
127110
127052
|
}
|
|
127111
127053
|
} catch (e15) {
|
|
127112
127054
|
if (pastCredentials) {
|
|
127113
|
-
|
|
127114
|
-
credentials = getExtendedInstanceMetadataCredentials(pastCredentials,
|
|
127055
|
+
logger5.warn("Credential renew failed: ", e15);
|
|
127056
|
+
credentials = getExtendedInstanceMetadataCredentials(pastCredentials, logger5);
|
|
127115
127057
|
} else {
|
|
127116
127058
|
throw e15;
|
|
127117
127059
|
}
|
|
@@ -127128,7 +127070,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
127128
127070
|
var fromInstanceMetadata = (init = {}) => staticStabilityProvider(getInstanceMetadataProvider(init), { logger: init.logger });
|
|
127129
127071
|
var getInstanceMetadataProvider = (init = {}) => {
|
|
127130
127072
|
let disableFetchToken = false;
|
|
127131
|
-
const { logger:
|
|
127073
|
+
const { logger: logger5, profile } = init;
|
|
127132
127074
|
const { timeout, maxRetries } = providerConfigFromInit(init);
|
|
127133
127075
|
const getCredentials = async (maxRetries2, options2) => {
|
|
127134
127076
|
const isImdsV1Fallback = disableFetchToken || options2.headers?.[X_AWS_EC2_METADATA_TOKEN] == null;
|
|
@@ -127192,7 +127134,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
127192
127134
|
return async () => {
|
|
127193
127135
|
const endpoint = await getInstanceMetadataEndpoint();
|
|
127194
127136
|
if (disableFetchToken) {
|
|
127195
|
-
|
|
127137
|
+
logger5?.debug("AWS SDK Instance Metadata", "using v1 fallback (no token fetch)");
|
|
127196
127138
|
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
127197
127139
|
} else {
|
|
127198
127140
|
let token;
|
|
@@ -127206,7 +127148,7 @@ For more information, please visit: ` + STATIC_STABILITY_DOC_URL);
|
|
|
127206
127148
|
} else if (error41.message === "TimeoutError" || [403, 404, 405].includes(error41.statusCode)) {
|
|
127207
127149
|
disableFetchToken = true;
|
|
127208
127150
|
}
|
|
127209
|
-
|
|
127151
|
+
logger5?.debug("AWS SDK Instance Metadata", "using v1 fallback (initial)");
|
|
127210
127152
|
return getCredentials(maxRetries, { ...endpoint, timeout });
|
|
127211
127153
|
}
|
|
127212
127154
|
return getCredentials(maxRetries, {
|
|
@@ -127263,7 +127205,7 @@ var require_checkUrl = __commonJS({
|
|
|
127263
127205
|
var ECS_CONTAINER_HOST = "169.254.170.2";
|
|
127264
127206
|
var EKS_CONTAINER_HOST_IPv4 = "169.254.170.23";
|
|
127265
127207
|
var EKS_CONTAINER_HOST_IPv6 = "[fd00:ec2::23]";
|
|
127266
|
-
var checkUrl = (url2,
|
|
127208
|
+
var checkUrl = (url2, logger5) => {
|
|
127267
127209
|
if (url2.protocol === "https:") {
|
|
127268
127210
|
return;
|
|
127269
127211
|
}
|
|
@@ -127290,7 +127232,7 @@ var require_checkUrl = __commonJS({
|
|
|
127290
127232
|
throw new property_provider_1.CredentialsProviderError(`URL not accepted. It must either be HTTPS or match one of the following:
|
|
127291
127233
|
- loopback CIDR 127.0.0.0/8 or [::1/128]
|
|
127292
127234
|
- ECS container host 169.254.170.2
|
|
127293
|
-
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger:
|
|
127235
|
+
- EKS container host 169.254.170.23 or [fd00:ec2::23]`, { logger: logger5 });
|
|
127294
127236
|
};
|
|
127295
127237
|
exports.checkUrl = checkUrl;
|
|
127296
127238
|
}
|
|
@@ -127320,13 +127262,13 @@ var require_requestHelpers = __commonJS({
|
|
|
127320
127262
|
fragment: url2.hash
|
|
127321
127263
|
});
|
|
127322
127264
|
}
|
|
127323
|
-
async function getCredentials(response,
|
|
127265
|
+
async function getCredentials(response, logger5) {
|
|
127324
127266
|
const stream = (0, util_stream_1.sdkStreamMixin)(response.body);
|
|
127325
127267
|
const str = await stream.transformToString();
|
|
127326
127268
|
if (response.statusCode === 200) {
|
|
127327
127269
|
const parsed = JSON.parse(str);
|
|
127328
127270
|
if (typeof parsed.AccessKeyId !== "string" || typeof parsed.SecretAccessKey !== "string" || typeof parsed.Token !== "string" || typeof parsed.Expiration !== "string") {
|
|
127329
|
-
throw new property_provider_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger:
|
|
127271
|
+
throw new property_provider_1.CredentialsProviderError("HTTP credential provider response not of the required format, an object matching: { AccessKeyId: string, SecretAccessKey: string, Token: string, Expiration: string(rfc3339) }", { logger: logger5 });
|
|
127330
127272
|
}
|
|
127331
127273
|
return {
|
|
127332
127274
|
accessKeyId: parsed.AccessKeyId,
|
|
@@ -127341,12 +127283,12 @@ var require_requestHelpers = __commonJS({
|
|
|
127341
127283
|
parsedBody = JSON.parse(str);
|
|
127342
127284
|
} catch (e15) {
|
|
127343
127285
|
}
|
|
127344
|
-
throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger:
|
|
127286
|
+
throw Object.assign(new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger5 }), {
|
|
127345
127287
|
Code: parsedBody.Code,
|
|
127346
127288
|
Message: parsedBody.Message
|
|
127347
127289
|
});
|
|
127348
127290
|
}
|
|
127349
|
-
throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger:
|
|
127291
|
+
throw new property_provider_1.CredentialsProviderError(`Server responded with status: ${response.statusCode}`, { logger: logger5 });
|
|
127350
127292
|
}
|
|
127351
127293
|
}
|
|
127352
127294
|
});
|
|
@@ -128928,14 +128870,14 @@ var require_dist_cjs57 = __commonJS({
|
|
|
128928
128870
|
var propertyProvider = require_dist_cjs21();
|
|
128929
128871
|
var sharedIniFileLoader = require_dist_cjs44();
|
|
128930
128872
|
var node_fs = __require("node:fs");
|
|
128931
|
-
var fromEnvSigningName = ({ logger:
|
|
128932
|
-
|
|
128873
|
+
var fromEnvSigningName = ({ logger: logger5, signingName } = {}) => async () => {
|
|
128874
|
+
logger5?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
128933
128875
|
if (!signingName) {
|
|
128934
|
-
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger:
|
|
128876
|
+
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger5 });
|
|
128935
128877
|
}
|
|
128936
128878
|
const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
|
|
128937
128879
|
if (!(bearerTokenKey in process.env)) {
|
|
128938
|
-
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger:
|
|
128880
|
+
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger5 });
|
|
128939
128881
|
}
|
|
128940
128882
|
const token = { token: process.env[bearerTokenKey] };
|
|
128941
128883
|
client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
@@ -129049,8 +128991,8 @@ var require_dist_cjs57 = __commonJS({
|
|
|
129049
128991
|
return existingToken;
|
|
129050
128992
|
}
|
|
129051
128993
|
};
|
|
129052
|
-
var fromStatic = ({ token, logger:
|
|
129053
|
-
|
|
128994
|
+
var fromStatic = ({ token, logger: logger5 }) => async () => {
|
|
128995
|
+
logger5?.debug("@aws-sdk/token-providers - fromStatic");
|
|
129054
128996
|
if (!token || !token.token) {
|
|
129055
128997
|
throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
129056
128998
|
}
|
|
@@ -129796,7 +129738,7 @@ var require_dist_cjs58 = __commonJS({
|
|
|
129796
129738
|
var tokenProviders = require_dist_cjs57();
|
|
129797
129739
|
var isSsoProfile = (arg) => arg && (typeof arg.sso_start_url === "string" || typeof arg.sso_account_id === "string" || typeof arg.sso_session === "string" || typeof arg.sso_region === "string" || typeof arg.sso_role_name === "string");
|
|
129798
129740
|
var SHOULD_FAIL_CREDENTIAL_CHAIN = false;
|
|
129799
|
-
var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger:
|
|
129741
|
+
var resolveSSOCredentials = async ({ ssoStartUrl, ssoSession, ssoAccountId, ssoRegion, ssoRoleName, ssoClient, clientConfig, parentClientConfig, callerClientConfig, profile, filepath, configFilepath, ignoreCache, logger: logger5 }) => {
|
|
129800
129742
|
let token;
|
|
129801
129743
|
const refreshMessage = `To refresh this SSO session run aws sso login with the corresponding profile.`;
|
|
129802
129744
|
if (ssoSession) {
|
|
@@ -129814,7 +129756,7 @@ var require_dist_cjs58 = __commonJS({
|
|
|
129814
129756
|
} catch (e15) {
|
|
129815
129757
|
throw new propertyProvider.CredentialsProviderError(e15.message, {
|
|
129816
129758
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
129817
|
-
logger:
|
|
129759
|
+
logger: logger5
|
|
129818
129760
|
});
|
|
129819
129761
|
}
|
|
129820
129762
|
} else {
|
|
@@ -129823,14 +129765,14 @@ var require_dist_cjs58 = __commonJS({
|
|
|
129823
129765
|
} catch (e15) {
|
|
129824
129766
|
throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile is invalid. ${refreshMessage}`, {
|
|
129825
129767
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
129826
|
-
logger:
|
|
129768
|
+
logger: logger5
|
|
129827
129769
|
});
|
|
129828
129770
|
}
|
|
129829
129771
|
}
|
|
129830
129772
|
if (new Date(token.expiresAt).getTime() - Date.now() <= 0) {
|
|
129831
129773
|
throw new propertyProvider.CredentialsProviderError(`The SSO session associated with this profile has expired. ${refreshMessage}`, {
|
|
129832
129774
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
129833
|
-
logger:
|
|
129775
|
+
logger: logger5
|
|
129834
129776
|
});
|
|
129835
129777
|
}
|
|
129836
129778
|
const { accessToken } = token;
|
|
@@ -129852,14 +129794,14 @@ var require_dist_cjs58 = __commonJS({
|
|
|
129852
129794
|
} catch (e15) {
|
|
129853
129795
|
throw new propertyProvider.CredentialsProviderError(e15, {
|
|
129854
129796
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
129855
|
-
logger:
|
|
129797
|
+
logger: logger5
|
|
129856
129798
|
});
|
|
129857
129799
|
}
|
|
129858
129800
|
const { roleCredentials: { accessKeyId, secretAccessKey, sessionToken, expiration, credentialScope, accountId } = {} } = ssoResp;
|
|
129859
129801
|
if (!accessKeyId || !secretAccessKey || !sessionToken || !expiration) {
|
|
129860
129802
|
throw new propertyProvider.CredentialsProviderError("SSO returns an invalid temporary credential.", {
|
|
129861
129803
|
tryNextLink: SHOULD_FAIL_CREDENTIAL_CHAIN,
|
|
129862
|
-
logger:
|
|
129804
|
+
logger: logger5
|
|
129863
129805
|
});
|
|
129864
129806
|
}
|
|
129865
129807
|
const credentials = {
|
|
@@ -129877,11 +129819,11 @@ var require_dist_cjs58 = __commonJS({
|
|
|
129877
129819
|
}
|
|
129878
129820
|
return credentials;
|
|
129879
129821
|
};
|
|
129880
|
-
var validateSsoProfile = (profile,
|
|
129822
|
+
var validateSsoProfile = (profile, logger5) => {
|
|
129881
129823
|
const { sso_start_url, sso_account_id, sso_region, sso_role_name } = profile;
|
|
129882
129824
|
if (!sso_start_url || !sso_account_id || !sso_region || !sso_role_name) {
|
|
129883
129825
|
throw new propertyProvider.CredentialsProviderError(`Profile is configured with invalid SSO credentials. Required parameters "sso_account_id", "sso_region", "sso_role_name", "sso_start_url". Got ${Object.keys(profile).join(", ")}
|
|
129884
|
-
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger:
|
|
129826
|
+
Reference: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html`, { tryNextLink: false, logger: logger5 });
|
|
129885
129827
|
}
|
|
129886
129828
|
return profile;
|
|
129887
129829
|
};
|
|
@@ -130816,7 +130758,7 @@ var require_dist_cjs59 = __commonJS({
|
|
|
130816
130758
|
}
|
|
130817
130759
|
async refresh(token) {
|
|
130818
130760
|
const { SigninClient: SigninClient2, CreateOAuth2TokenCommand: CreateOAuth2TokenCommand2 } = await Promise.resolve().then(() => (init_signin(), signin_exports));
|
|
130819
|
-
const { logger:
|
|
130761
|
+
const { logger: logger5, userAgentAppId } = this.callerClientConfig ?? {};
|
|
130820
130762
|
const isH23 = (requestHandler2) => {
|
|
130821
130763
|
return requestHandler2?.metadata?.handlerProtocol === "h2";
|
|
130822
130764
|
};
|
|
@@ -130829,7 +130771,7 @@ var require_dist_cjs59 = __commonJS({
|
|
|
130829
130771
|
},
|
|
130830
130772
|
region,
|
|
130831
130773
|
requestHandler,
|
|
130832
|
-
logger:
|
|
130774
|
+
logger: logger5,
|
|
130833
130775
|
userAgentAppId,
|
|
130834
130776
|
...this.init?.clientConfig
|
|
130835
130777
|
});
|
|
@@ -131982,9 +131924,9 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
131982
131924
|
return async (sourceCreds, params) => {
|
|
131983
131925
|
closureSourceCreds = sourceCreds;
|
|
131984
131926
|
if (!stsClient) {
|
|
131985
|
-
const { logger:
|
|
131927
|
+
const { logger: logger5 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
131986
131928
|
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
131987
|
-
logger:
|
|
131929
|
+
logger: logger5,
|
|
131988
131930
|
profile
|
|
131989
131931
|
});
|
|
131990
131932
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
@@ -131995,7 +131937,7 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
131995
131937
|
credentialDefaultProvider: () => async () => closureSourceCreds,
|
|
131996
131938
|
region: resolvedRegion,
|
|
131997
131939
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
131998
|
-
logger:
|
|
131940
|
+
logger: logger5
|
|
131999
131941
|
});
|
|
132000
131942
|
}
|
|
132001
131943
|
const { Credentials: Credentials2, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand(params));
|
|
@@ -132019,9 +131961,9 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
132019
131961
|
let stsClient;
|
|
132020
131962
|
return async (params) => {
|
|
132021
131963
|
if (!stsClient) {
|
|
132022
|
-
const { logger:
|
|
131964
|
+
const { logger: logger5 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
132023
131965
|
const resolvedRegion = await resolveRegion(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
132024
|
-
logger:
|
|
131966
|
+
logger: logger5,
|
|
132025
131967
|
profile
|
|
132026
131968
|
});
|
|
132027
131969
|
const isCompatibleRequestHandler = !isH2(requestHandler);
|
|
@@ -132031,7 +131973,7 @@ var init_defaultStsRoleAssumers = __esm({
|
|
|
132031
131973
|
profile,
|
|
132032
131974
|
region: resolvedRegion,
|
|
132033
131975
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
132034
|
-
logger:
|
|
131976
|
+
logger: logger5
|
|
132035
131977
|
});
|
|
132036
131978
|
}
|
|
132037
131979
|
const { Credentials: Credentials2, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand(params));
|
|
@@ -132182,7 +132124,7 @@ var require_dist_cjs60 = __commonJS({
|
|
|
132182
132124
|
client.setCredentialFeature(credentials, "CREDENTIALS_PROCESS", "w");
|
|
132183
132125
|
return credentials;
|
|
132184
132126
|
};
|
|
132185
|
-
var resolveProcessCredentials = async (profileName, profiles,
|
|
132127
|
+
var resolveProcessCredentials = async (profileName, profiles, logger5) => {
|
|
132186
132128
|
const profile = profiles[profileName];
|
|
132187
132129
|
if (profiles[profileName]) {
|
|
132188
132130
|
const credentialProcess = profile["credential_process"];
|
|
@@ -132198,14 +132140,14 @@ var require_dist_cjs60 = __commonJS({
|
|
|
132198
132140
|
}
|
|
132199
132141
|
return getValidatedProcessCredentials(profileName, data2, profiles);
|
|
132200
132142
|
} catch (error41) {
|
|
132201
|
-
throw new propertyProvider.CredentialsProviderError(error41.message, { logger:
|
|
132143
|
+
throw new propertyProvider.CredentialsProviderError(error41.message, { logger: logger5 });
|
|
132202
132144
|
}
|
|
132203
132145
|
} else {
|
|
132204
|
-
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger:
|
|
132146
|
+
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} did not contain credential_process.`, { logger: logger5 });
|
|
132205
132147
|
}
|
|
132206
132148
|
} else {
|
|
132207
132149
|
throw new propertyProvider.CredentialsProviderError(`Profile ${profileName} could not be found in shared credentials file.`, {
|
|
132208
|
-
logger:
|
|
132150
|
+
logger: logger5
|
|
132209
132151
|
});
|
|
132210
132152
|
}
|
|
132211
132153
|
};
|
|
@@ -132362,21 +132304,21 @@ var require_dist_cjs62 = __commonJS({
|
|
|
132362
132304
|
var propertyProvider = require_dist_cjs21();
|
|
132363
132305
|
var client = (init_client4(), __toCommonJS(client_exports2));
|
|
132364
132306
|
var credentialProviderLogin = require_dist_cjs59();
|
|
132365
|
-
var resolveCredentialSource = (credentialSource, profileName,
|
|
132307
|
+
var resolveCredentialSource = (credentialSource, profileName, logger5) => {
|
|
132366
132308
|
const sourceProvidersMap = {
|
|
132367
132309
|
EcsContainer: async (options2) => {
|
|
132368
132310
|
const { fromHttp } = await Promise.resolve().then(() => __toESM(require_dist_cjs51()));
|
|
132369
132311
|
const { fromContainerMetadata } = await Promise.resolve().then(() => __toESM(require_dist_cjs50()));
|
|
132370
|
-
|
|
132312
|
+
logger5?.debug("@aws-sdk/credential-provider-ini - credential_source is EcsContainer");
|
|
132371
132313
|
return async () => propertyProvider.chain(fromHttp(options2 ?? {}), fromContainerMetadata(options2))().then(setNamedProvider);
|
|
132372
132314
|
},
|
|
132373
132315
|
Ec2InstanceMetadata: async (options2) => {
|
|
132374
|
-
|
|
132316
|
+
logger5?.debug("@aws-sdk/credential-provider-ini - credential_source is Ec2InstanceMetadata");
|
|
132375
132317
|
const { fromInstanceMetadata } = await Promise.resolve().then(() => __toESM(require_dist_cjs50()));
|
|
132376
132318
|
return async () => fromInstanceMetadata(options2)().then(setNamedProvider);
|
|
132377
132319
|
},
|
|
132378
132320
|
Environment: async (options2) => {
|
|
132379
|
-
|
|
132321
|
+
logger5?.debug("@aws-sdk/credential-provider-ini - credential_source is Environment");
|
|
132380
132322
|
const { fromEnv } = await Promise.resolve().then(() => __toESM(require_dist_cjs49()));
|
|
132381
132323
|
return async () => fromEnv(options2)().then(setNamedProvider);
|
|
132382
132324
|
}
|
|
@@ -132384,24 +132326,24 @@ var require_dist_cjs62 = __commonJS({
|
|
|
132384
132326
|
if (credentialSource in sourceProvidersMap) {
|
|
132385
132327
|
return sourceProvidersMap[credentialSource];
|
|
132386
132328
|
} else {
|
|
132387
|
-
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger:
|
|
132329
|
+
throw new propertyProvider.CredentialsProviderError(`Unsupported credential source in profile ${profileName}. Got ${credentialSource}, expected EcsContainer or Ec2InstanceMetadata or Environment.`, { logger: logger5 });
|
|
132388
132330
|
}
|
|
132389
132331
|
};
|
|
132390
132332
|
var setNamedProvider = (creds) => client.setCredentialFeature(creds, "CREDENTIALS_PROFILE_NAMED_PROVIDER", "p");
|
|
132391
|
-
var isAssumeRoleProfile = (arg, { profile = "default", logger:
|
|
132392
|
-
return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger:
|
|
132333
|
+
var isAssumeRoleProfile = (arg, { profile = "default", logger: logger5 } = {}) => {
|
|
132334
|
+
return Boolean(arg) && typeof arg === "object" && typeof arg.role_arn === "string" && ["undefined", "string"].indexOf(typeof arg.role_session_name) > -1 && ["undefined", "string"].indexOf(typeof arg.external_id) > -1 && ["undefined", "string"].indexOf(typeof arg.mfa_serial) > -1 && (isAssumeRoleWithSourceProfile(arg, { profile, logger: logger5 }) || isCredentialSourceProfile(arg, { profile, logger: logger5 }));
|
|
132393
132335
|
};
|
|
132394
|
-
var isAssumeRoleWithSourceProfile = (arg, { profile, logger:
|
|
132336
|
+
var isAssumeRoleWithSourceProfile = (arg, { profile, logger: logger5 }) => {
|
|
132395
132337
|
const withSourceProfile = typeof arg.source_profile === "string" && typeof arg.credential_source === "undefined";
|
|
132396
132338
|
if (withSourceProfile) {
|
|
132397
|
-
|
|
132339
|
+
logger5?.debug?.(` ${profile} isAssumeRoleWithSourceProfile source_profile=${arg.source_profile}`);
|
|
132398
132340
|
}
|
|
132399
132341
|
return withSourceProfile;
|
|
132400
132342
|
};
|
|
132401
|
-
var isCredentialSourceProfile = (arg, { profile, logger:
|
|
132343
|
+
var isCredentialSourceProfile = (arg, { profile, logger: logger5 }) => {
|
|
132402
132344
|
const withProviderProfile = typeof arg.credential_source === "string" && typeof arg.source_profile === "undefined";
|
|
132403
132345
|
if (withProviderProfile) {
|
|
132404
|
-
|
|
132346
|
+
logger5?.debug?.(` ${profile} isCredentialSourceProfile credential_source=${arg.credential_source}`);
|
|
132405
132347
|
}
|
|
132406
132348
|
return withProviderProfile;
|
|
132407
132349
|
};
|
|
@@ -134766,14 +134708,14 @@ var require_dist_cjs66 = __commonJS({
|
|
|
134766
134708
|
};
|
|
134767
134709
|
};
|
|
134768
134710
|
}
|
|
134769
|
-
function throwOnMissingAccessKeyId(
|
|
134770
|
-
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no access key ID", { logger:
|
|
134711
|
+
function throwOnMissingAccessKeyId(logger5) {
|
|
134712
|
+
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no access key ID", { logger: logger5 });
|
|
134771
134713
|
}
|
|
134772
|
-
function throwOnMissingCredentials(
|
|
134773
|
-
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no credentials", { logger:
|
|
134714
|
+
function throwOnMissingCredentials(logger5) {
|
|
134715
|
+
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no credentials", { logger: logger5 });
|
|
134774
134716
|
}
|
|
134775
|
-
function throwOnMissingSecretKey(
|
|
134776
|
-
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no secret key", { logger:
|
|
134717
|
+
function throwOnMissingSecretKey(logger5) {
|
|
134718
|
+
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no secret key", { logger: logger5 });
|
|
134777
134719
|
}
|
|
134778
134720
|
var STORE_NAME = "IdentityIds";
|
|
134779
134721
|
var IndexedDbStorage = class {
|
|
@@ -134871,8 +134813,8 @@ var require_dist_cjs66 = __commonJS({
|
|
|
134871
134813
|
}
|
|
134872
134814
|
return inMemoryStorage;
|
|
134873
134815
|
}
|
|
134874
|
-
function fromCognitoIdentityPool({ accountId, cache: cache8 = localStorage2(), client, clientConfig, customRoleArn, identityPoolId, logins, userIdentifier = !logins || Object.keys(logins).length === 0 ? "ANONYMOUS" : void 0, logger:
|
|
134875
|
-
|
|
134816
|
+
function fromCognitoIdentityPool({ accountId, cache: cache8 = localStorage2(), client, clientConfig, customRoleArn, identityPoolId, logins, userIdentifier = !logins || Object.keys(logins).length === 0 ? "ANONYMOUS" : void 0, logger: logger5, parentClientConfig }) {
|
|
134817
|
+
logger5?.debug("@aws-sdk/credential-provider-cognito-identity - fromCognitoIdentity");
|
|
134876
134818
|
const cacheKey2 = userIdentifier ? `aws:cognito-identity-credentials:${identityPoolId}:${userIdentifier}` : void 0;
|
|
134877
134819
|
let provider = async (awsIdentityProperties) => {
|
|
134878
134820
|
const { GetIdCommand, CognitoIdentityClient } = await Promise.resolve().then(function() {
|
|
@@ -134886,7 +134828,7 @@ var require_dist_cjs66 = __commonJS({
|
|
|
134886
134828
|
}));
|
|
134887
134829
|
let identityId = cacheKey2 && await cache8.getItem(cacheKey2);
|
|
134888
134830
|
if (!identityId) {
|
|
134889
|
-
const { IdentityId = throwOnMissingId(
|
|
134831
|
+
const { IdentityId = throwOnMissingId(logger5) } = await _client2.send(new GetIdCommand({
|
|
134890
134832
|
AccountId: accountId,
|
|
134891
134833
|
IdentityPoolId: identityPoolId,
|
|
134892
134834
|
Logins: logins ? await resolveLogins(logins) : void 0
|
|
@@ -134913,8 +134855,8 @@ var require_dist_cjs66 = __commonJS({
|
|
|
134913
134855
|
throw err;
|
|
134914
134856
|
});
|
|
134915
134857
|
}
|
|
134916
|
-
function throwOnMissingId(
|
|
134917
|
-
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no identity ID", { logger:
|
|
134858
|
+
function throwOnMissingId(logger5) {
|
|
134859
|
+
throw new propertyProvider.CredentialsProviderError("Response from Amazon Cognito contained no identity ID", { logger: logger5 });
|
|
134918
134860
|
}
|
|
134919
134861
|
exports.fromCognitoIdentity = fromCognitoIdentity;
|
|
134920
134862
|
exports.fromCognitoIdentityPool = fromCognitoIdentityPool;
|
|
@@ -135988,9 +135930,9 @@ var init_defaultStsRoleAssumers2 = __esm({
|
|
|
135988
135930
|
return async (sourceCreds, params) => {
|
|
135989
135931
|
closureSourceCreds = sourceCreds;
|
|
135990
135932
|
if (!stsClient) {
|
|
135991
|
-
const { logger:
|
|
135933
|
+
const { logger: logger5 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
135992
135934
|
const resolvedRegion = await resolveRegion2(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
135993
|
-
logger:
|
|
135935
|
+
logger: logger5,
|
|
135994
135936
|
profile
|
|
135995
135937
|
});
|
|
135996
135938
|
const isCompatibleRequestHandler = !isH22(requestHandler);
|
|
@@ -136001,7 +135943,7 @@ var init_defaultStsRoleAssumers2 = __esm({
|
|
|
136001
135943
|
credentialDefaultProvider: () => async () => closureSourceCreds,
|
|
136002
135944
|
region: resolvedRegion,
|
|
136003
135945
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
136004
|
-
logger:
|
|
135946
|
+
logger: logger5
|
|
136005
135947
|
});
|
|
136006
135948
|
}
|
|
136007
135949
|
const { Credentials: Credentials2, AssumedRoleUser } = await stsClient.send(new AssumeRoleCommand2(params));
|
|
@@ -136025,9 +135967,9 @@ var init_defaultStsRoleAssumers2 = __esm({
|
|
|
136025
135967
|
let stsClient;
|
|
136026
135968
|
return async (params) => {
|
|
136027
135969
|
if (!stsClient) {
|
|
136028
|
-
const { logger:
|
|
135970
|
+
const { logger: logger5 = stsOptions?.parentClientConfig?.logger, profile = stsOptions?.parentClientConfig?.profile, region, requestHandler = stsOptions?.parentClientConfig?.requestHandler, credentialProviderLogger, userAgentAppId = stsOptions?.parentClientConfig?.userAgentAppId } = stsOptions;
|
|
136029
135971
|
const resolvedRegion = await resolveRegion2(region, stsOptions?.parentClientConfig?.region, credentialProviderLogger, {
|
|
136030
|
-
logger:
|
|
135972
|
+
logger: logger5,
|
|
136031
135973
|
profile
|
|
136032
135974
|
});
|
|
136033
135975
|
const isCompatibleRequestHandler = !isH22(requestHandler);
|
|
@@ -136037,7 +135979,7 @@ var init_defaultStsRoleAssumers2 = __esm({
|
|
|
136037
135979
|
profile,
|
|
136038
135980
|
region: resolvedRegion,
|
|
136039
135981
|
requestHandler: isCompatibleRequestHandler ? requestHandler : void 0,
|
|
136040
|
-
logger:
|
|
135982
|
+
logger: logger5
|
|
136041
135983
|
});
|
|
136042
135984
|
}
|
|
136043
135985
|
const { Credentials: Credentials2, AssumedRoleUser } = await stsClient.send(new AssumeRoleWithWebIdentityCommand2(params));
|
|
@@ -136216,14 +136158,14 @@ var require_fromTemporaryCredentials_base = __commonJS({
|
|
|
136216
136158
|
return async (awsIdentityProperties = {}) => {
|
|
136217
136159
|
const { callerClientConfig } = awsIdentityProperties;
|
|
136218
136160
|
const profile = options2.clientConfig?.profile ?? callerClientConfig?.profile;
|
|
136219
|
-
const
|
|
136220
|
-
|
|
136161
|
+
const logger5 = options2.logger ?? callerClientConfig?.logger;
|
|
136162
|
+
logger5?.debug("@aws-sdk/credential-providers - fromTemporaryCredentials (STS)");
|
|
136221
136163
|
const params = { ...options2.params, RoleSessionName: options2.params.RoleSessionName ?? "aws-sdk-js-" + Date.now() };
|
|
136222
136164
|
if (params?.SerialNumber) {
|
|
136223
136165
|
if (!options2.mfaCodeProvider) {
|
|
136224
136166
|
throw new property_provider_1.CredentialsProviderError(`Temporary credential requires multi-factor authentication, but no MFA code callback was provided.`, {
|
|
136225
136167
|
tryNextLink: false,
|
|
136226
|
-
logger:
|
|
136168
|
+
logger: logger5
|
|
136227
136169
|
});
|
|
136228
136170
|
}
|
|
136229
136171
|
params.TokenCode = await options2.mfaCodeProvider(params?.SerialNumber);
|
|
@@ -136277,12 +136219,12 @@ var require_fromTemporaryCredentials_base = __commonJS({
|
|
|
136277
136219
|
} else if (requestHandlerSources[1]) {
|
|
136278
136220
|
requestHandlerSource = "caller client's requestHandler";
|
|
136279
136221
|
}
|
|
136280
|
-
|
|
136222
|
+
logger5?.debug?.(`@aws-sdk/credential-providers - fromTemporaryCredentials STS client init with ${regionSource}=${await (0, core_1.normalizeProvider)(coalesce(regionSources))()}, ${credentialSource}, ${requestHandlerSource}.`);
|
|
136281
136223
|
stsClient = new STSClient3({
|
|
136282
136224
|
userAgentAppId: callerClientConfig?.userAgentAppId,
|
|
136283
136225
|
...options2.clientConfig,
|
|
136284
136226
|
credentials: coalesce(credentialSources),
|
|
136285
|
-
logger:
|
|
136227
|
+
logger: logger5,
|
|
136286
136228
|
profile,
|
|
136287
136229
|
region: coalesce(regionSources),
|
|
136288
136230
|
requestHandler: coalesce(requestHandlerSources)
|
|
@@ -136296,7 +136238,7 @@ var require_fromTemporaryCredentials_base = __commonJS({
|
|
|
136296
136238
|
const { Credentials: Credentials2 } = await stsClient.send(new AssumeRoleCommand3(params));
|
|
136297
136239
|
if (!Credentials2 || !Credentials2.AccessKeyId || !Credentials2.SecretAccessKey) {
|
|
136298
136240
|
throw new property_provider_1.CredentialsProviderError(`Invalid response from STS.assumeRole call with role ${params.RoleArn}`, {
|
|
136299
|
-
logger:
|
|
136241
|
+
logger: logger5
|
|
136300
136242
|
});
|
|
136301
136243
|
}
|
|
136302
136244
|
return {
|
|
@@ -139184,7 +139126,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
139184
139126
|
limitedParseFloat: () => limitedParseFloat2,
|
|
139185
139127
|
limitedParseFloat32: () => limitedParseFloat322,
|
|
139186
139128
|
loadConfigsForDefaultMode: () => loadConfigsForDefaultMode7,
|
|
139187
|
-
logger: () =>
|
|
139129
|
+
logger: () => logger5,
|
|
139188
139130
|
map: () => map4,
|
|
139189
139131
|
parseBoolean: () => parseBoolean2,
|
|
139190
139132
|
parseEpochTimestamp: () => parseEpochTimestamp2,
|
|
@@ -139477,7 +139419,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
139477
139419
|
}
|
|
139478
139420
|
if (typeof value === "number") {
|
|
139479
139421
|
if (value === 0 || value === 1) {
|
|
139480
|
-
|
|
139422
|
+
logger5.warn(stackTraceWarning2(`Expected boolean, got ${typeof value}: ${value}`));
|
|
139481
139423
|
}
|
|
139482
139424
|
if (value === 0) {
|
|
139483
139425
|
return false;
|
|
@@ -139489,7 +139431,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
139489
139431
|
if (typeof value === "string") {
|
|
139490
139432
|
const lower2 = value.toLowerCase();
|
|
139491
139433
|
if (lower2 === "false" || lower2 === "true") {
|
|
139492
|
-
|
|
139434
|
+
logger5.warn(stackTraceWarning2(`Expected boolean, got ${typeof value}: ${value}`));
|
|
139493
139435
|
}
|
|
139494
139436
|
if (lower2 === "false") {
|
|
139495
139437
|
return false;
|
|
@@ -139511,7 +139453,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
139511
139453
|
const parsed = parseFloat(value);
|
|
139512
139454
|
if (!Number.isNaN(parsed)) {
|
|
139513
139455
|
if (String(parsed) !== String(value)) {
|
|
139514
|
-
|
|
139456
|
+
logger5.warn(stackTraceWarning2(`Expected number but observed string: ${value}`));
|
|
139515
139457
|
}
|
|
139516
139458
|
return parsed;
|
|
139517
139459
|
}
|
|
@@ -139588,7 +139530,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
139588
139530
|
return value;
|
|
139589
139531
|
}
|
|
139590
139532
|
if (["boolean", "number", "bigint"].includes(typeof value)) {
|
|
139591
|
-
|
|
139533
|
+
logger5.warn(stackTraceWarning2(`Expected string, got ${typeof value}: ${value}`));
|
|
139592
139534
|
return String(value);
|
|
139593
139535
|
}
|
|
139594
139536
|
throw new TypeError(`Expected string, got ${typeof value}: ${value}`);
|
|
@@ -139682,7 +139624,7 @@ var require_dist_cjs81 = __commonJS({
|
|
|
139682
139624
|
var stackTraceWarning2 = /* @__PURE__ */ __name((message) => {
|
|
139683
139625
|
return String(new TypeError(message).stack || message).split("\n").slice(0, 5).filter((s18) => !s18.includes("stackTraceWarning")).join("\n");
|
|
139684
139626
|
}, "stackTraceWarning");
|
|
139685
|
-
var
|
|
139627
|
+
var logger5 = {
|
|
139686
139628
|
warn: console.warn
|
|
139687
139629
|
};
|
|
139688
139630
|
var DAYS2 = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
|
@@ -142853,14 +142795,14 @@ var require_dist_cjs90 = __commonJS({
|
|
|
142853
142795
|
var propertyProvider = require_dist_cjs21();
|
|
142854
142796
|
var sharedIniFileLoader = require_dist_cjs44();
|
|
142855
142797
|
var fs11 = __require("fs");
|
|
142856
|
-
var fromEnvSigningName = ({ logger:
|
|
142857
|
-
|
|
142798
|
+
var fromEnvSigningName = ({ logger: logger5, signingName } = {}) => async () => {
|
|
142799
|
+
logger5?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
142858
142800
|
if (!signingName) {
|
|
142859
|
-
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger:
|
|
142801
|
+
throw new propertyProvider.TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger: logger5 });
|
|
142860
142802
|
}
|
|
142861
142803
|
const bearerTokenKey = httpAuthSchemes.getBearerTokenEnvKey(signingName);
|
|
142862
142804
|
if (!(bearerTokenKey in process.env)) {
|
|
142863
|
-
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger:
|
|
142805
|
+
throw new propertyProvider.TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger: logger5 });
|
|
142864
142806
|
}
|
|
142865
142807
|
const token = { token: process.env[bearerTokenKey] };
|
|
142866
142808
|
client.setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
@@ -142974,8 +142916,8 @@ var require_dist_cjs90 = __commonJS({
|
|
|
142974
142916
|
return existingToken;
|
|
142975
142917
|
}
|
|
142976
142918
|
};
|
|
142977
|
-
var fromStatic = ({ token, logger:
|
|
142978
|
-
|
|
142919
|
+
var fromStatic = ({ token, logger: logger5 }) => async () => {
|
|
142920
|
+
logger5?.debug("@aws-sdk/token-providers - fromStatic");
|
|
142979
142921
|
if (!token || !token.token) {
|
|
142980
142922
|
throw new propertyProvider.TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
142981
142923
|
}
|
|
@@ -146543,30 +146485,30 @@ var init_values3 = __esm({
|
|
|
146543
146485
|
// node_modules/.pnpm/@anthropic-ai+bedrock-sdk@0.28.1_zod@3.25.76/node_modules/@anthropic-ai/bedrock-sdk/internal/utils/log.mjs
|
|
146544
146486
|
function noop7() {
|
|
146545
146487
|
}
|
|
146546
|
-
function makeLogFn3(fnLevel,
|
|
146547
|
-
if (!
|
|
146488
|
+
function makeLogFn3(fnLevel, logger5, logLevel) {
|
|
146489
|
+
if (!logger5 || levelNumbers3[fnLevel] > levelNumbers3[logLevel]) {
|
|
146548
146490
|
return noop7;
|
|
146549
146491
|
} else {
|
|
146550
|
-
return
|
|
146492
|
+
return logger5[fnLevel].bind(logger5);
|
|
146551
146493
|
}
|
|
146552
146494
|
}
|
|
146553
146495
|
function loggerFor3(client) {
|
|
146554
|
-
const
|
|
146496
|
+
const logger5 = client.logger;
|
|
146555
146497
|
const logLevel = client.logLevel ?? "off";
|
|
146556
|
-
if (!
|
|
146498
|
+
if (!logger5) {
|
|
146557
146499
|
return noopLogger3;
|
|
146558
146500
|
}
|
|
146559
|
-
const cachedLogger = cachedLoggers3.get(
|
|
146501
|
+
const cachedLogger = cachedLoggers3.get(logger5);
|
|
146560
146502
|
if (cachedLogger && cachedLogger[0] === logLevel) {
|
|
146561
146503
|
return cachedLogger[1];
|
|
146562
146504
|
}
|
|
146563
146505
|
const levelLogger = {
|
|
146564
|
-
error: makeLogFn3("error",
|
|
146565
|
-
warn: makeLogFn3("warn",
|
|
146566
|
-
info: makeLogFn3("info",
|
|
146567
|
-
debug: makeLogFn3("debug",
|
|
146506
|
+
error: makeLogFn3("error", logger5, logLevel),
|
|
146507
|
+
warn: makeLogFn3("warn", logger5, logLevel),
|
|
146508
|
+
info: makeLogFn3("info", logger5, logLevel),
|
|
146509
|
+
debug: makeLogFn3("debug", logger5, logLevel)
|
|
146568
146510
|
};
|
|
146569
|
-
cachedLoggers3.set(
|
|
146511
|
+
cachedLoggers3.set(logger5, [logLevel, levelLogger]);
|
|
146570
146512
|
return levelLogger;
|
|
146571
146513
|
}
|
|
146572
146514
|
var levelNumbers3, noopLogger3, cachedLoggers3;
|
|
@@ -146627,7 +146569,7 @@ var init_streaming5 = __esm({
|
|
|
146627
146569
|
Stream5 = class _Stream extends Stream4 {
|
|
146628
146570
|
static fromSSEResponse(response, controller, client) {
|
|
146629
146571
|
let consumed = false;
|
|
146630
|
-
const
|
|
146572
|
+
const logger5 = client ? loggerFor3(client) : console;
|
|
146631
146573
|
async function* iterMessages() {
|
|
146632
146574
|
if (!response.body) {
|
|
146633
146575
|
controller.abort();
|
|
@@ -146662,8 +146604,8 @@ var init_streaming5 = __esm({
|
|
|
146662
146604
|
try {
|
|
146663
146605
|
yield JSON.parse(sse.data);
|
|
146664
146606
|
} catch (e15) {
|
|
146665
|
-
|
|
146666
|
-
|
|
146607
|
+
logger5.error(`Could not parse message into JSON:`, sse.data);
|
|
146608
|
+
logger5.error(`From chunk:`, sse.raw);
|
|
146667
146609
|
throw e15;
|
|
146668
146610
|
}
|
|
146669
146611
|
}
|
|
@@ -147517,10 +147459,7 @@ function mapModeToModel(modeId) {
|
|
|
147517
147459
|
}
|
|
147518
147460
|
return modeId;
|
|
147519
147461
|
}
|
|
147520
|
-
|
|
147521
|
-
return MODEL_FALLBACKS[modelId];
|
|
147522
|
-
}
|
|
147523
|
-
var MODEL_CAPABILITIES, MODEL_FALLBACKS;
|
|
147462
|
+
var MODEL_CAPABILITIES;
|
|
147524
147463
|
var init_model_config = __esm({
|
|
147525
147464
|
"src/lib/model-config.ts"() {
|
|
147526
147465
|
"use strict";
|
|
@@ -147544,10 +147483,6 @@ var init_model_config = __esm({
|
|
|
147544
147483
|
"openai/gpt-5.5": { vision: true, reasoning: true },
|
|
147545
147484
|
"deepseek/deepseek-r1": { vision: false, reasoning: true }
|
|
147546
147485
|
};
|
|
147547
|
-
MODEL_FALLBACKS = {
|
|
147548
|
-
"google/gemini-3.1-pro-preview": "google/gemini-3-pro-preview",
|
|
147549
|
-
"google/gemini-3-pro-preview": "google/gemini-3-flash-preview"
|
|
147550
|
-
};
|
|
147551
147486
|
}
|
|
147552
147487
|
});
|
|
147553
147488
|
|
|
@@ -147620,7 +147555,7 @@ var init_model_tiers = __esm({
|
|
|
147620
147555
|
provider: "OpenAI",
|
|
147621
147556
|
costTier: "Expensive",
|
|
147622
147557
|
multiLingual: true,
|
|
147623
|
-
zdr:
|
|
147558
|
+
zdr: true,
|
|
147624
147559
|
effort: "medium"
|
|
147625
147560
|
}
|
|
147626
147561
|
]
|
|
@@ -155322,13 +155257,13 @@ var require_core = __commonJS({
|
|
|
155322
155257
|
}, warn() {
|
|
155323
155258
|
}, error() {
|
|
155324
155259
|
} };
|
|
155325
|
-
function getLogger(
|
|
155326
|
-
if (
|
|
155260
|
+
function getLogger(logger5) {
|
|
155261
|
+
if (logger5 === false)
|
|
155327
155262
|
return noLogs;
|
|
155328
|
-
if (
|
|
155263
|
+
if (logger5 === void 0)
|
|
155329
155264
|
return console;
|
|
155330
|
-
if (
|
|
155331
|
-
return
|
|
155265
|
+
if (logger5.log && logger5.warn && logger5.error)
|
|
155266
|
+
return logger5;
|
|
155332
155267
|
throw new Error("logger must implement log, warn and error methods");
|
|
155333
155268
|
}
|
|
155334
155269
|
var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
@@ -160107,7 +160042,7 @@ var init_bridge = __esm({
|
|
|
160107
160042
|
// src/integrations/mcp/schema-adapter.ts
|
|
160108
160043
|
function isOpenAICompatModel(modelId) {
|
|
160109
160044
|
const isClaude = modelId.startsWith("anthropic/") || modelId.includes("claude");
|
|
160110
|
-
const isGemini =
|
|
160045
|
+
const isGemini = modelId.startsWith("google/gemini");
|
|
160111
160046
|
return !isClaude && !isGemini;
|
|
160112
160047
|
}
|
|
160113
160048
|
function adaptToolSchemasForProvider(tools, modelId) {
|
|
@@ -160215,32 +160150,51 @@ function flattenNullUnion(schema) {
|
|
|
160215
160150
|
}
|
|
160216
160151
|
makeNullable(schema);
|
|
160217
160152
|
} else if (nonNull.length > 1) {
|
|
160153
|
+
if (!nonNull.every(isSimpleTypeSchema)) {
|
|
160154
|
+
delete schema.nullable;
|
|
160155
|
+
continue;
|
|
160156
|
+
}
|
|
160218
160157
|
const types5 = nonNull.map((s18) => s18.type).filter(Boolean);
|
|
160219
160158
|
if (!types5.includes("null")) types5.push("null");
|
|
160220
160159
|
delete schema[key];
|
|
160221
|
-
schema.type = types5;
|
|
160160
|
+
schema.type = [...new Set(types5)];
|
|
160161
|
+
delete schema.nullable;
|
|
160222
160162
|
}
|
|
160223
160163
|
}
|
|
160224
160164
|
}
|
|
160165
|
+
function isSimpleTypeSchema(schema) {
|
|
160166
|
+
return typeof schema.type === "string" && !schema.properties && !schema.items && !schema.required && !schema.additionalProperties;
|
|
160167
|
+
}
|
|
160225
160168
|
function makeNullable(schema) {
|
|
160169
|
+
for (const key of ["anyOf", "oneOf"]) {
|
|
160170
|
+
const union3 = schema[key];
|
|
160171
|
+
if (!Array.isArray(union3)) continue;
|
|
160172
|
+
if (!union3.some((s18) => s18.type === "null")) {
|
|
160173
|
+
union3.push({ type: "null" });
|
|
160174
|
+
}
|
|
160175
|
+
delete schema.nullable;
|
|
160176
|
+
return;
|
|
160177
|
+
}
|
|
160226
160178
|
const currentType = schema.type;
|
|
160227
160179
|
if (!currentType) {
|
|
160228
160180
|
schema.type = ["string", "null"];
|
|
160181
|
+
delete schema.nullable;
|
|
160229
160182
|
return;
|
|
160230
160183
|
}
|
|
160231
160184
|
if (Array.isArray(currentType)) {
|
|
160232
160185
|
if (!currentType.includes("null")) {
|
|
160233
160186
|
currentType.push("null");
|
|
160234
160187
|
}
|
|
160188
|
+
delete schema.nullable;
|
|
160235
160189
|
return;
|
|
160236
160190
|
}
|
|
160237
160191
|
schema.type = [currentType, "null"];
|
|
160192
|
+
delete schema.nullable;
|
|
160238
160193
|
}
|
|
160239
160194
|
var UUID_PARAM_HINTS;
|
|
160240
160195
|
var init_schema_adapter = __esm({
|
|
160241
160196
|
"src/integrations/mcp/schema-adapter.ts"() {
|
|
160242
160197
|
"use strict";
|
|
160243
|
-
init_model_registry();
|
|
160244
160198
|
init_logger();
|
|
160245
160199
|
UUID_PARAM_HINTS = {
|
|
160246
160200
|
fragmentId: "WARNING: This is the ID of a specific memory fragment/document, NOT a workspace ID. Do NOT pass a workspaceId here.",
|
|
@@ -161509,216 +161463,6 @@ var init_claude_stream_adapter = __esm({
|
|
|
161509
161463
|
}
|
|
161510
161464
|
});
|
|
161511
161465
|
|
|
161512
|
-
// src/core/ai/scripted-stream-adapter.ts
|
|
161513
|
-
function scriptedMessage(model, extra = {}) {
|
|
161514
|
-
return {
|
|
161515
|
-
id: "msg_scripted",
|
|
161516
|
-
type: "message",
|
|
161517
|
-
role: "assistant",
|
|
161518
|
-
model,
|
|
161519
|
-
content: [],
|
|
161520
|
-
...extra
|
|
161521
|
-
};
|
|
161522
|
-
}
|
|
161523
|
-
function selectScriptedTurn(script, conversationMessages) {
|
|
161524
|
-
if (script.length === 0) return { text: "" };
|
|
161525
|
-
const step = conversationMessages.filter((m33) => m33.role === "assistant").length;
|
|
161526
|
-
return script[step] ?? script[script.length - 1];
|
|
161527
|
-
}
|
|
161528
|
-
function buildScriptedClaudeStream(turn, opts) {
|
|
161529
|
-
const { model } = opts;
|
|
161530
|
-
const hasTools = Boolean(turn.toolCalls && turn.toolCalls.length > 0);
|
|
161531
|
-
const stopReason = hasTools ? "tool_use" : "end_turn";
|
|
161532
|
-
const chunks = [];
|
|
161533
|
-
chunks.push({ type: "message_start", message: scriptedMessage(model) });
|
|
161534
|
-
if (turn.reasoning) {
|
|
161535
|
-
chunks.push({ type: "thinking_delta", delta: { thinking: turn.reasoning } });
|
|
161536
|
-
}
|
|
161537
|
-
if (turn.text) {
|
|
161538
|
-
chunks.push({ type: "content_block_delta", delta: { text: turn.text }, index: 0 });
|
|
161539
|
-
}
|
|
161540
|
-
if (hasTools) {
|
|
161541
|
-
turn.toolCalls.forEach((call, i19) => {
|
|
161542
|
-
const index2 = i19 + 1;
|
|
161543
|
-
const id = call.id ?? `toolu_scripted_${i19}`;
|
|
161544
|
-
chunks.push({
|
|
161545
|
-
type: "content_block_start",
|
|
161546
|
-
content_block: { type: "tool_use", tool_use_id: id, name: call.name },
|
|
161547
|
-
index: index2
|
|
161548
|
-
});
|
|
161549
|
-
chunks.push({
|
|
161550
|
-
type: "content_block_delta",
|
|
161551
|
-
delta: { partial_json: JSON.stringify(call.args) },
|
|
161552
|
-
index: index2
|
|
161553
|
-
});
|
|
161554
|
-
chunks.push({ type: "content_block_stop", index: index2 });
|
|
161555
|
-
});
|
|
161556
|
-
}
|
|
161557
|
-
chunks.push({ type: "message_delta", delta: { stop_reason: stopReason } });
|
|
161558
|
-
chunks.push({
|
|
161559
|
-
type: "message_stop",
|
|
161560
|
-
message: scriptedMessage(model, { usage: SCRIPTED_USAGE, stop_reason: stopReason })
|
|
161561
|
-
});
|
|
161562
|
-
return new ReadableStream({
|
|
161563
|
-
start(controller) {
|
|
161564
|
-
for (const chunk2 of chunks) controller.enqueue(chunk2);
|
|
161565
|
-
controller.close();
|
|
161566
|
-
}
|
|
161567
|
-
});
|
|
161568
|
-
}
|
|
161569
|
-
var SCRIPTED_USAGE;
|
|
161570
|
-
var init_scripted_stream_adapter = __esm({
|
|
161571
|
-
"src/core/ai/scripted-stream-adapter.ts"() {
|
|
161572
|
-
"use strict";
|
|
161573
|
-
SCRIPTED_USAGE = { input_tokens: 11, output_tokens: 7 };
|
|
161574
|
-
}
|
|
161575
|
-
});
|
|
161576
|
-
|
|
161577
|
-
// src/lib/flowcore/utils/logger.ts
|
|
161578
|
-
function createLogger(module) {
|
|
161579
|
-
return {
|
|
161580
|
-
debug: (message, context) => {
|
|
161581
|
-
console.debug(
|
|
161582
|
-
JSON.stringify({
|
|
161583
|
-
level: "debug",
|
|
161584
|
-
module,
|
|
161585
|
-
message,
|
|
161586
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
161587
|
-
...context
|
|
161588
|
-
})
|
|
161589
|
-
);
|
|
161590
|
-
},
|
|
161591
|
-
info: (message, context) => {
|
|
161592
|
-
console.info(
|
|
161593
|
-
JSON.stringify({
|
|
161594
|
-
level: "info",
|
|
161595
|
-
module,
|
|
161596
|
-
message,
|
|
161597
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
161598
|
-
...context
|
|
161599
|
-
})
|
|
161600
|
-
);
|
|
161601
|
-
},
|
|
161602
|
-
warn: (message, context) => {
|
|
161603
|
-
console.warn(
|
|
161604
|
-
JSON.stringify({
|
|
161605
|
-
level: "warn",
|
|
161606
|
-
module,
|
|
161607
|
-
message,
|
|
161608
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
161609
|
-
...context
|
|
161610
|
-
})
|
|
161611
|
-
);
|
|
161612
|
-
},
|
|
161613
|
-
error: (message, context) => {
|
|
161614
|
-
console.error(
|
|
161615
|
-
JSON.stringify({
|
|
161616
|
-
level: "error",
|
|
161617
|
-
module,
|
|
161618
|
-
message,
|
|
161619
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
161620
|
-
...context
|
|
161621
|
-
})
|
|
161622
|
-
);
|
|
161623
|
-
}
|
|
161624
|
-
};
|
|
161625
|
-
}
|
|
161626
|
-
var init_logger3 = __esm({
|
|
161627
|
-
"src/lib/flowcore/utils/logger.ts"() {
|
|
161628
|
-
"use strict";
|
|
161629
|
-
}
|
|
161630
|
-
});
|
|
161631
|
-
|
|
161632
|
-
// src/core/ai/circuit-breaker.ts
|
|
161633
|
-
function getCooldownMs(probeAttempts) {
|
|
161634
|
-
return Math.min(BASE_COOLDOWN_MS * Math.pow(2, probeAttempts), MAX_COOLDOWN_MS);
|
|
161635
|
-
}
|
|
161636
|
-
function getOrCreate(modelId) {
|
|
161637
|
-
let circuit = circuits.get(modelId);
|
|
161638
|
-
if (!circuit) {
|
|
161639
|
-
circuit = { state: "CLOSED", failures: 0, lastFailureAt: 0, openedAt: 0, probeAttempts: 0 };
|
|
161640
|
-
circuits.set(modelId, circuit);
|
|
161641
|
-
}
|
|
161642
|
-
return circuit;
|
|
161643
|
-
}
|
|
161644
|
-
function shouldUseFallback(modelId) {
|
|
161645
|
-
const circuit = getOrCreate(modelId);
|
|
161646
|
-
switch (circuit.state) {
|
|
161647
|
-
case "CLOSED":
|
|
161648
|
-
return false;
|
|
161649
|
-
case "OPEN": {
|
|
161650
|
-
const cooldown = getCooldownMs(circuit.probeAttempts);
|
|
161651
|
-
const elapsed = Date.now() - circuit.openedAt;
|
|
161652
|
-
if (elapsed >= cooldown) {
|
|
161653
|
-
circuit.state = "HALF_OPEN";
|
|
161654
|
-
logger3.info("Circuit breaker cooldown expired, entering HALF_OPEN", {
|
|
161655
|
-
modelId,
|
|
161656
|
-
elapsed,
|
|
161657
|
-
cooldown,
|
|
161658
|
-
probeAttempts: circuit.probeAttempts
|
|
161659
|
-
});
|
|
161660
|
-
return false;
|
|
161661
|
-
}
|
|
161662
|
-
return true;
|
|
161663
|
-
}
|
|
161664
|
-
case "HALF_OPEN":
|
|
161665
|
-
return false;
|
|
161666
|
-
}
|
|
161667
|
-
}
|
|
161668
|
-
function recordSuccess(modelId) {
|
|
161669
|
-
const circuit = getOrCreate(modelId);
|
|
161670
|
-
if (circuit.state !== "CLOSED") {
|
|
161671
|
-
logger3.info("Circuit breaker resetting to CLOSED", {
|
|
161672
|
-
modelId,
|
|
161673
|
-
previousState: circuit.state
|
|
161674
|
-
});
|
|
161675
|
-
}
|
|
161676
|
-
circuit.state = "CLOSED";
|
|
161677
|
-
circuit.failures = 0;
|
|
161678
|
-
circuit.lastFailureAt = 0;
|
|
161679
|
-
circuit.openedAt = 0;
|
|
161680
|
-
circuit.probeAttempts = 0;
|
|
161681
|
-
}
|
|
161682
|
-
function recordFailure(modelId) {
|
|
161683
|
-
const circuit = getOrCreate(modelId);
|
|
161684
|
-
circuit.failures += 1;
|
|
161685
|
-
circuit.lastFailureAt = Date.now();
|
|
161686
|
-
if (circuit.failures >= FAILURE_THRESHOLD && circuit.state !== "OPEN") {
|
|
161687
|
-
circuit.state = "OPEN";
|
|
161688
|
-
circuit.openedAt = Date.now();
|
|
161689
|
-
logger3.warn("Circuit breaker tripped to OPEN", {
|
|
161690
|
-
modelId,
|
|
161691
|
-
failures: circuit.failures,
|
|
161692
|
-
threshold: FAILURE_THRESHOLD
|
|
161693
|
-
});
|
|
161694
|
-
} else if (circuit.state === "HALF_OPEN") {
|
|
161695
|
-
circuit.probeAttempts += 1;
|
|
161696
|
-
circuit.state = "OPEN";
|
|
161697
|
-
circuit.openedAt = Date.now();
|
|
161698
|
-
logger3.warn("Circuit breaker probe failed, back to OPEN", {
|
|
161699
|
-
modelId,
|
|
161700
|
-
failures: circuit.failures,
|
|
161701
|
-
probeAttempts: circuit.probeAttempts,
|
|
161702
|
-
nextCooldownMs: getCooldownMs(circuit.probeAttempts)
|
|
161703
|
-
});
|
|
161704
|
-
}
|
|
161705
|
-
}
|
|
161706
|
-
function getCircuitState(modelId) {
|
|
161707
|
-
return getOrCreate(modelId).state;
|
|
161708
|
-
}
|
|
161709
|
-
var logger3, FAILURE_THRESHOLD, BASE_COOLDOWN_MS, MAX_COOLDOWN_MS, circuits;
|
|
161710
|
-
var init_circuit_breaker = __esm({
|
|
161711
|
-
"src/core/ai/circuit-breaker.ts"() {
|
|
161712
|
-
"use strict";
|
|
161713
|
-
init_logger3();
|
|
161714
|
-
logger3 = createLogger("circuit-breaker");
|
|
161715
|
-
FAILURE_THRESHOLD = 2;
|
|
161716
|
-
BASE_COOLDOWN_MS = 6e4;
|
|
161717
|
-
MAX_COOLDOWN_MS = 36e5;
|
|
161718
|
-
circuits = /* @__PURE__ */ new Map();
|
|
161719
|
-
}
|
|
161720
|
-
});
|
|
161721
|
-
|
|
161722
161466
|
// node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js
|
|
161723
161467
|
var require_extend = __commonJS({
|
|
161724
161468
|
"node_modules/.pnpm/extend@3.0.2/node_modules/extend/index.js"(exports, module) {
|
|
@@ -171783,12 +171527,12 @@ var require_logging_utils = __commonJS({
|
|
|
171783
171527
|
this.setFilters();
|
|
171784
171528
|
this.filtersSet = true;
|
|
171785
171529
|
}
|
|
171786
|
-
let
|
|
171787
|
-
if (!
|
|
171788
|
-
|
|
171789
|
-
this.cached.set(namespace,
|
|
171530
|
+
let logger5 = this.cached.get(namespace);
|
|
171531
|
+
if (!logger5) {
|
|
171532
|
+
logger5 = this.makeLogger(namespace);
|
|
171533
|
+
this.cached.set(namespace, logger5);
|
|
171790
171534
|
}
|
|
171791
|
-
|
|
171535
|
+
logger5(fields, ...args);
|
|
171792
171536
|
} catch (e15) {
|
|
171793
171537
|
console.error(e15);
|
|
171794
171538
|
}
|
|
@@ -171933,7 +171677,7 @@ var require_logging_utils = __commonJS({
|
|
|
171933
171677
|
} else if (cachedBackend === void 0) {
|
|
171934
171678
|
cachedBackend = getNodeBackend();
|
|
171935
171679
|
}
|
|
171936
|
-
const
|
|
171680
|
+
const logger5 = (() => {
|
|
171937
171681
|
let previousBackend = void 0;
|
|
171938
171682
|
const newLogger = new AdhocDebugLogger(namespace, (fields, ...args) => {
|
|
171939
171683
|
if (previousBackend !== cachedBackend) {
|
|
@@ -171948,8 +171692,8 @@ var require_logging_utils = __commonJS({
|
|
|
171948
171692
|
});
|
|
171949
171693
|
return newLogger;
|
|
171950
171694
|
})();
|
|
171951
|
-
loggerCache.set(namespace,
|
|
171952
|
-
return
|
|
171695
|
+
loggerCache.set(namespace, logger5);
|
|
171696
|
+
return logger5.func;
|
|
171953
171697
|
}
|
|
171954
171698
|
}
|
|
171955
171699
|
});
|
|
@@ -172037,14 +171781,14 @@ var require_src5 = __commonJS({
|
|
|
172037
171781
|
var gaxios_1 = require_src3();
|
|
172038
171782
|
var jsonBigint = require_json_bigint();
|
|
172039
171783
|
var gcp_residency_1 = require_gcp_residency();
|
|
172040
|
-
var
|
|
171784
|
+
var logger5 = __importStar3(require_src4());
|
|
172041
171785
|
exports.BASE_PATH = "/computeMetadata/v1";
|
|
172042
171786
|
exports.HOST_ADDRESS = "http://169.254.169.254";
|
|
172043
171787
|
exports.SECONDARY_HOST_ADDRESS = "http://metadata.google.internal.";
|
|
172044
171788
|
exports.HEADER_NAME = "Metadata-Flavor";
|
|
172045
171789
|
exports.HEADER_VALUE = "Google";
|
|
172046
171790
|
exports.HEADERS = Object.freeze({ [exports.HEADER_NAME]: exports.HEADER_VALUE });
|
|
172047
|
-
var log2 =
|
|
171791
|
+
var log2 = logger5.log("gcp-metadata");
|
|
172048
171792
|
exports.METADATA_SERVER_DETECTION = Object.freeze({
|
|
172049
171793
|
"assume-present": "don't try to ping the metadata server, but assume it's present",
|
|
172050
171794
|
none: "don't try to ping the metadata server, but don't try to use it either",
|
|
@@ -191537,31 +191281,31 @@ function findDoubleNewlineIndex3(buffer2) {
|
|
|
191537
191281
|
}
|
|
191538
191282
|
function noop9() {
|
|
191539
191283
|
}
|
|
191540
|
-
function makeLogFn4(fnLevel,
|
|
191541
|
-
if (!
|
|
191284
|
+
function makeLogFn4(fnLevel, logger5, logLevel) {
|
|
191285
|
+
if (!logger5 || levelNumbers4[fnLevel] > levelNumbers4[logLevel]) {
|
|
191542
191286
|
return noop9;
|
|
191543
191287
|
} else {
|
|
191544
|
-
return
|
|
191288
|
+
return logger5[fnLevel].bind(logger5);
|
|
191545
191289
|
}
|
|
191546
191290
|
}
|
|
191547
191291
|
function loggerFor4(client) {
|
|
191548
191292
|
var _a27;
|
|
191549
|
-
const
|
|
191293
|
+
const logger5 = client.logger;
|
|
191550
191294
|
const logLevel = (_a27 = client.logLevel) !== null && _a27 !== void 0 ? _a27 : "off";
|
|
191551
|
-
if (!
|
|
191295
|
+
if (!logger5) {
|
|
191552
191296
|
return noopLogger4;
|
|
191553
191297
|
}
|
|
191554
|
-
const cachedLogger = cachedLoggers4.get(
|
|
191298
|
+
const cachedLogger = cachedLoggers4.get(logger5);
|
|
191555
191299
|
if (cachedLogger && cachedLogger[0] === logLevel) {
|
|
191556
191300
|
return cachedLogger[1];
|
|
191557
191301
|
}
|
|
191558
191302
|
const levelLogger = {
|
|
191559
|
-
error: makeLogFn4("error",
|
|
191560
|
-
warn: makeLogFn4("warn",
|
|
191561
|
-
info: makeLogFn4("info",
|
|
191562
|
-
debug: makeLogFn4("debug",
|
|
191303
|
+
error: makeLogFn4("error", logger5, logLevel),
|
|
191304
|
+
warn: makeLogFn4("warn", logger5, logLevel),
|
|
191305
|
+
info: makeLogFn4("info", logger5, logLevel),
|
|
191306
|
+
debug: makeLogFn4("debug", logger5, logLevel)
|
|
191563
191307
|
};
|
|
191564
|
-
cachedLoggers4.set(
|
|
191308
|
+
cachedLoggers4.set(logger5, [logLevel, levelLogger]);
|
|
191565
191309
|
return levelLogger;
|
|
191566
191310
|
}
|
|
191567
191311
|
function _iterSSEMessages3(response, controller) {
|
|
@@ -198127,7 +197871,7 @@ ${underline2}`);
|
|
|
198127
197871
|
}
|
|
198128
197872
|
static fromSSEResponse(response, controller, client) {
|
|
198129
197873
|
let consumed = false;
|
|
198130
|
-
const
|
|
197874
|
+
const logger5 = client ? loggerFor4(client) : console;
|
|
198131
197875
|
function iterator() {
|
|
198132
197876
|
return __asyncGenerator3(this, arguments, function* iterator_1() {
|
|
198133
197877
|
var _a27, e_1, _b16, _c7;
|
|
@@ -198151,8 +197895,8 @@ ${underline2}`);
|
|
|
198151
197895
|
try {
|
|
198152
197896
|
yield yield __await3(JSON.parse(sse.data));
|
|
198153
197897
|
} catch (e15) {
|
|
198154
|
-
|
|
198155
|
-
|
|
197898
|
+
logger5.error(`Could not parse message into JSON:`, sse.data);
|
|
197899
|
+
logger5.error(`From chunk:`, sse.raw);
|
|
198156
197900
|
throw e15;
|
|
198157
197901
|
}
|
|
198158
197902
|
}
|
|
@@ -200343,6 +200087,71 @@ var init_gemini_direct_stream_adapter = __esm({
|
|
|
200343
200087
|
}
|
|
200344
200088
|
});
|
|
200345
200089
|
|
|
200090
|
+
// src/core/ai/scripted-stream-adapter.ts
|
|
200091
|
+
function scriptedMessage(model, extra = {}) {
|
|
200092
|
+
return {
|
|
200093
|
+
id: "msg_scripted",
|
|
200094
|
+
type: "message",
|
|
200095
|
+
role: "assistant",
|
|
200096
|
+
model,
|
|
200097
|
+
content: [],
|
|
200098
|
+
...extra
|
|
200099
|
+
};
|
|
200100
|
+
}
|
|
200101
|
+
function selectScriptedTurn(script, conversationMessages) {
|
|
200102
|
+
if (script.length === 0) return { text: "" };
|
|
200103
|
+
const step = conversationMessages.filter((m33) => m33.role === "assistant").length;
|
|
200104
|
+
return script[step] ?? script[script.length - 1];
|
|
200105
|
+
}
|
|
200106
|
+
function buildScriptedClaudeStream(turn, opts) {
|
|
200107
|
+
const { model } = opts;
|
|
200108
|
+
const hasTools = Boolean(turn.toolCalls && turn.toolCalls.length > 0);
|
|
200109
|
+
const stopReason = hasTools ? "tool_use" : "end_turn";
|
|
200110
|
+
const chunks = [];
|
|
200111
|
+
chunks.push({ type: "message_start", message: scriptedMessage(model) });
|
|
200112
|
+
if (turn.reasoning) {
|
|
200113
|
+
chunks.push({ type: "thinking_delta", delta: { thinking: turn.reasoning } });
|
|
200114
|
+
}
|
|
200115
|
+
if (turn.text) {
|
|
200116
|
+
chunks.push({ type: "content_block_delta", delta: { text: turn.text }, index: 0 });
|
|
200117
|
+
}
|
|
200118
|
+
if (hasTools) {
|
|
200119
|
+
turn.toolCalls.forEach((call, i19) => {
|
|
200120
|
+
const index2 = i19 + 1;
|
|
200121
|
+
const id = call.id ?? `toolu_scripted_${i19}`;
|
|
200122
|
+
chunks.push({
|
|
200123
|
+
type: "content_block_start",
|
|
200124
|
+
content_block: { type: "tool_use", tool_use_id: id, name: call.name },
|
|
200125
|
+
index: index2
|
|
200126
|
+
});
|
|
200127
|
+
chunks.push({
|
|
200128
|
+
type: "content_block_delta",
|
|
200129
|
+
delta: { partial_json: JSON.stringify(call.args) },
|
|
200130
|
+
index: index2
|
|
200131
|
+
});
|
|
200132
|
+
chunks.push({ type: "content_block_stop", index: index2 });
|
|
200133
|
+
});
|
|
200134
|
+
}
|
|
200135
|
+
chunks.push({ type: "message_delta", delta: { stop_reason: stopReason } });
|
|
200136
|
+
chunks.push({
|
|
200137
|
+
type: "message_stop",
|
|
200138
|
+
message: scriptedMessage(model, { usage: SCRIPTED_USAGE, stop_reason: stopReason })
|
|
200139
|
+
});
|
|
200140
|
+
return new ReadableStream({
|
|
200141
|
+
start(controller) {
|
|
200142
|
+
for (const chunk2 of chunks) controller.enqueue(chunk2);
|
|
200143
|
+
controller.close();
|
|
200144
|
+
}
|
|
200145
|
+
});
|
|
200146
|
+
}
|
|
200147
|
+
var SCRIPTED_USAGE;
|
|
200148
|
+
var init_scripted_stream_adapter = __esm({
|
|
200149
|
+
"src/core/ai/scripted-stream-adapter.ts"() {
|
|
200150
|
+
"use strict";
|
|
200151
|
+
SCRIPTED_USAGE = { input_tokens: 11, output_tokens: 7 };
|
|
200152
|
+
}
|
|
200153
|
+
});
|
|
200154
|
+
|
|
200346
200155
|
// src/core/ai/openrouter-stream-adapter.ts
|
|
200347
200156
|
async function adaptOpenRouterStream(stream, options2) {
|
|
200348
200157
|
const {
|
|
@@ -200814,9 +200623,7 @@ async function adaptOpenRouterStream(stream, options2) {
|
|
|
200814
200623
|
});
|
|
200815
200624
|
multiplexer.send(retrievalEvent);
|
|
200816
200625
|
}
|
|
200817
|
-
toolExecutionPromises.push(
|
|
200818
|
-
executeParsedToolCall(pending.id, pending.name, args)
|
|
200819
|
-
);
|
|
200626
|
+
toolExecutionPromises.push(executeParsedToolCall(pending.id, pending.name, args));
|
|
200820
200627
|
pendingToolCalls.delete(index2);
|
|
200821
200628
|
} catch {
|
|
200822
200629
|
}
|
|
@@ -203950,6 +203757,61 @@ ${imageMarkdown}`;
|
|
|
203950
203757
|
}
|
|
203951
203758
|
});
|
|
203952
203759
|
|
|
203760
|
+
// src/lib/flowcore/utils/logger.ts
|
|
203761
|
+
function createLogger(module) {
|
|
203762
|
+
return {
|
|
203763
|
+
debug: (message, context) => {
|
|
203764
|
+
console.debug(
|
|
203765
|
+
JSON.stringify({
|
|
203766
|
+
level: "debug",
|
|
203767
|
+
module,
|
|
203768
|
+
message,
|
|
203769
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
203770
|
+
...context
|
|
203771
|
+
})
|
|
203772
|
+
);
|
|
203773
|
+
},
|
|
203774
|
+
info: (message, context) => {
|
|
203775
|
+
console.info(
|
|
203776
|
+
JSON.stringify({
|
|
203777
|
+
level: "info",
|
|
203778
|
+
module,
|
|
203779
|
+
message,
|
|
203780
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
203781
|
+
...context
|
|
203782
|
+
})
|
|
203783
|
+
);
|
|
203784
|
+
},
|
|
203785
|
+
warn: (message, context) => {
|
|
203786
|
+
console.warn(
|
|
203787
|
+
JSON.stringify({
|
|
203788
|
+
level: "warn",
|
|
203789
|
+
module,
|
|
203790
|
+
message,
|
|
203791
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
203792
|
+
...context
|
|
203793
|
+
})
|
|
203794
|
+
);
|
|
203795
|
+
},
|
|
203796
|
+
error: (message, context) => {
|
|
203797
|
+
console.error(
|
|
203798
|
+
JSON.stringify({
|
|
203799
|
+
level: "error",
|
|
203800
|
+
module,
|
|
203801
|
+
message,
|
|
203802
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
203803
|
+
...context
|
|
203804
|
+
})
|
|
203805
|
+
);
|
|
203806
|
+
}
|
|
203807
|
+
};
|
|
203808
|
+
}
|
|
203809
|
+
var init_logger3 = __esm({
|
|
203810
|
+
"src/lib/flowcore/utils/logger.ts"() {
|
|
203811
|
+
"use strict";
|
|
203812
|
+
}
|
|
203813
|
+
});
|
|
203814
|
+
|
|
203953
203815
|
// node_modules/.pnpm/@ioredis+commands@1.5.0/node_modules/@ioredis/commands/built/commands.json
|
|
203954
203816
|
var require_commands = __commonJS({
|
|
203955
203817
|
"node_modules/.pnpm/@ioredis+commands@1.5.0/node_modules/@ioredis/commands/built/commands.json"(exports, module) {
|
|
@@ -213386,7 +213248,7 @@ var init_redis_factory = __esm({
|
|
|
213386
213248
|
connectionTimeout,
|
|
213387
213249
|
commandTimeout
|
|
213388
213250
|
}) => {
|
|
213389
|
-
const
|
|
213251
|
+
const logger5 = createLogger(name18 ?? "redis");
|
|
213390
213252
|
let redis;
|
|
213391
213253
|
if (redisUrl.startsWith("redis+sentinel://")) {
|
|
213392
213254
|
const [credentialsAndHost, masterSet] = redisUrl.split("//")[1].split("/");
|
|
@@ -213437,13 +213299,13 @@ var init_redis_factory = __esm({
|
|
|
213437
213299
|
commandTimeout: commandTimeout ?? 5e3
|
|
213438
213300
|
});
|
|
213439
213301
|
}
|
|
213440
|
-
redis.on("connect", () =>
|
|
213441
|
-
redis.on("ready", () =>
|
|
213442
|
-
redis.on("error", (error41) =>
|
|
213443
|
-
redis.on("close", () =>
|
|
213302
|
+
redis.on("connect", () => logger5.info("Connected to Redis server"));
|
|
213303
|
+
redis.on("ready", () => logger5.info("Redis client is ready"));
|
|
213304
|
+
redis.on("error", (error41) => logger5.error(`Redis error: ${error41.message}`, { error: error41 }));
|
|
213305
|
+
redis.on("close", () => logger5.info("Redis connection closed"));
|
|
213444
213306
|
redis.on(
|
|
213445
213307
|
"reconnecting",
|
|
213446
|
-
(timeToReconnect) =>
|
|
213308
|
+
(timeToReconnect) => logger5.info(`Reconnecting to Redis in ${timeToReconnect}ms...`)
|
|
213447
213309
|
);
|
|
213448
213310
|
return redis;
|
|
213449
213311
|
};
|
|
@@ -213500,7 +213362,7 @@ function getRedis() {
|
|
|
213500
213362
|
try {
|
|
213501
213363
|
return getRedisInstance({ redisUrl: getRedisUrl() });
|
|
213502
213364
|
} catch (error41) {
|
|
213503
|
-
|
|
213365
|
+
logger3.error("Failed to get Redis instance", { error: String(error41) });
|
|
213504
213366
|
return null;
|
|
213505
213367
|
}
|
|
213506
213368
|
}
|
|
@@ -213516,19 +213378,19 @@ async function isRedisAvailable() {
|
|
|
213516
213378
|
redisAvailable = true;
|
|
213517
213379
|
return true;
|
|
213518
213380
|
} catch {
|
|
213519
|
-
|
|
213381
|
+
logger3.warn("Redis ping failed - falling back to direct streaming");
|
|
213520
213382
|
redisAvailable = false;
|
|
213521
213383
|
return false;
|
|
213522
213384
|
}
|
|
213523
213385
|
}
|
|
213524
|
-
var
|
|
213386
|
+
var logger3, redisConfigured, redisAvailable;
|
|
213525
213387
|
var init_redis = __esm({
|
|
213526
213388
|
"src/lib/redis/index.ts"() {
|
|
213527
213389
|
"use strict";
|
|
213528
213390
|
init_logger3();
|
|
213529
213391
|
init_redis_factory();
|
|
213530
213392
|
init_redis_factory();
|
|
213531
|
-
|
|
213393
|
+
logger3 = createLogger("redis");
|
|
213532
213394
|
redisConfigured = false;
|
|
213533
213395
|
redisAvailable = null;
|
|
213534
213396
|
}
|
|
@@ -213566,12 +213428,12 @@ function parseRecord(data2) {
|
|
|
213566
213428
|
tokenUsageJson: data2.tokenUsageJson || void 0
|
|
213567
213429
|
};
|
|
213568
213430
|
}
|
|
213569
|
-
var
|
|
213431
|
+
var logger4, TASK_TTL_SECONDS, EVENTS_TTL_SECONDS, STALE_RUNNING_TIMEOUT_MS, EVENTS_STREAM_MAXLEN, STALE_LOCAL_ABORT_TIMEOUT_MS, JANITOR_INTERVAL_MS, POD_ID, SpawnedTaskStore, globalForStore, spawnedTaskStore;
|
|
213570
213432
|
var init_spawned_task_store = __esm({
|
|
213571
213433
|
"src/core/subagents/spawned-task-store.ts"() {
|
|
213572
213434
|
"use strict";
|
|
213573
213435
|
init_logger3();
|
|
213574
|
-
|
|
213436
|
+
logger4 = createLogger("spawned-task-store");
|
|
213575
213437
|
TASK_TTL_SECONDS = 60 * 60;
|
|
213576
213438
|
EVENTS_TTL_SECONDS = 60 * 60;
|
|
213577
213439
|
STALE_RUNNING_TIMEOUT_MS = 60 * 60 * 1e3;
|
|
@@ -213638,7 +213500,7 @@ var init_spawned_task_store = __esm({
|
|
|
213638
213500
|
removed++;
|
|
213639
213501
|
}
|
|
213640
213502
|
if (removed > 0) {
|
|
213641
|
-
|
|
213503
|
+
logger4.info("Janitor removed stale local AbortControllers", { removed });
|
|
213642
213504
|
}
|
|
213643
213505
|
return { removed };
|
|
213644
213506
|
}
|
|
@@ -213651,14 +213513,14 @@ var init_spawned_task_store = __esm({
|
|
|
213651
213513
|
if (g23.__spawnedTaskJanitorInterval) return;
|
|
213652
213514
|
g23.__spawnedTaskJanitorInterval = setInterval(() => {
|
|
213653
213515
|
void this.runJanitor(redis).catch((err) => {
|
|
213654
|
-
|
|
213516
|
+
logger4.error("Janitor run failed", { error: String(err) });
|
|
213655
213517
|
});
|
|
213656
213518
|
}, JANITOR_INTERVAL_MS);
|
|
213657
213519
|
if (typeof g23.__spawnedTaskJanitorInterval === "object" && g23.__spawnedTaskJanitorInterval !== null && "unref" in g23.__spawnedTaskJanitorInterval) {
|
|
213658
213520
|
;
|
|
213659
213521
|
g23.__spawnedTaskJanitorInterval.unref();
|
|
213660
213522
|
}
|
|
213661
|
-
|
|
213523
|
+
logger4.info("Stale-controller janitor scheduled", { intervalMs: JANITOR_INTERVAL_MS });
|
|
213662
213524
|
}
|
|
213663
213525
|
// ---------------------------------------------------------- redis writes
|
|
213664
213526
|
async register(redis, input) {
|
|
@@ -213681,7 +213543,7 @@ var init_spawned_task_store = __esm({
|
|
|
213681
213543
|
await redis.zadd(zsetKey, startedAtMs, input.taskId);
|
|
213682
213544
|
await redis.expire(zsetKey, TASK_TTL_SECONDS);
|
|
213683
213545
|
this.ensureJanitorScheduled(redis);
|
|
213684
|
-
|
|
213546
|
+
logger4.info("Task registered", {
|
|
213685
213547
|
taskId: input.taskId,
|
|
213686
213548
|
conversationId: input.conversationId,
|
|
213687
213549
|
ownerPodId: input.ownerPodId
|
|
@@ -213817,17 +213679,17 @@ data: ${JSON.stringify(envelope)}
|
|
|
213817
213679
|
for (const taskId of ids) {
|
|
213818
213680
|
const ctrl = this.localAborts.get(taskId);
|
|
213819
213681
|
if (ctrl) {
|
|
213820
|
-
|
|
213682
|
+
logger4.info("Aborting local subagent via pubsub", { taskId });
|
|
213821
213683
|
ctrl.abort();
|
|
213822
213684
|
this.localAborts.delete(taskId);
|
|
213823
213685
|
}
|
|
213824
213686
|
}
|
|
213825
213687
|
} catch (err) {
|
|
213826
|
-
|
|
213688
|
+
logger4.error("Failed to parse cancel pubsub message", { error: String(err) });
|
|
213827
213689
|
}
|
|
213828
213690
|
});
|
|
213829
213691
|
subscriber.psubscribe("subagents:cancel:*").catch((err) => {
|
|
213830
|
-
|
|
213692
|
+
logger4.error("Failed to psubscribe to cancel commands", { error: String(err) });
|
|
213831
213693
|
this.cancelSubscriptionActive = false;
|
|
213832
213694
|
});
|
|
213833
213695
|
}
|
|
@@ -286052,6 +285914,14 @@ var init_file_storage_service = __esm({
|
|
|
286052
285914
|
|
|
286053
285915
|
// src/core/orchestrator/index.ts
|
|
286054
285916
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
285917
|
+
function shouldRecoverSilentStop({
|
|
285918
|
+
text: text3,
|
|
285919
|
+
lastStepHadToolErrors,
|
|
285920
|
+
lastStepHadToolActivity,
|
|
285921
|
+
recoveryAttempted
|
|
285922
|
+
}) {
|
|
285923
|
+
return !recoveryAttempted && !text3?.trim() && (lastStepHadToolErrors || lastStepHadToolActivity);
|
|
285924
|
+
}
|
|
286055
285925
|
function getBuiltInDataParentToolName(toolName) {
|
|
286056
285926
|
if (!toolName.startsWith("parent_")) return null;
|
|
286057
285927
|
const parentToolName = toolName.slice("parent_".length);
|
|
@@ -286693,12 +286563,9 @@ async function callLLM({
|
|
|
286693
286563
|
executeToolByName,
|
|
286694
286564
|
context,
|
|
286695
286565
|
onPauseDetected,
|
|
286696
|
-
retryDepth,
|
|
286697
286566
|
scriptedLlm,
|
|
286698
286567
|
providerRouting
|
|
286699
286568
|
}) {
|
|
286700
|
-
const MAX_FALLBACK_DEPTH = 3;
|
|
286701
|
-
const currentDepth = retryDepth ?? 0;
|
|
286702
286569
|
if (process.env.E2E_ALLOW_TEST_SEAMS === "true" && scriptedLlm && scriptedLlm.length > 0) {
|
|
286703
286570
|
const turn = selectScriptedTurn(scriptedLlm, conversationMessages);
|
|
286704
286571
|
const scriptedStream = buildScriptedClaudeStream(turn, { model: selectedModelId });
|
|
@@ -286713,9 +286580,90 @@ async function callLLM({
|
|
|
286713
286580
|
});
|
|
286714
286581
|
}
|
|
286715
286582
|
const forceCompat = providerRouting?.provider === "usable";
|
|
286583
|
+
const forceOpenRouter = providerRouting?.openRouterOnly || providerRouting?.provider === "openrouter";
|
|
286584
|
+
const callOpenRouterRoute = async ({
|
|
286585
|
+
forceDirectOpenRouter = false
|
|
286586
|
+
} = {}) => {
|
|
286587
|
+
const openrouterMessages = convertToOpenRouterMessages(conversationMessages, selectedModelId);
|
|
286588
|
+
const toolMessages = openrouterMessages.filter((msg) => msg.role === "tool");
|
|
286589
|
+
if (toolMessages.length > 0) {
|
|
286590
|
+
orchestrationLogger.debug("Tool messages being sent to OpenRouter", {
|
|
286591
|
+
toolMessageCount: toolMessages.length,
|
|
286592
|
+
toolMessages: toolMessages.map((msg) => ({
|
|
286593
|
+
role: msg.role,
|
|
286594
|
+
name: msg.name,
|
|
286595
|
+
toolCallId: msg.tool_call_id,
|
|
286596
|
+
contentLength: typeof msg.content === "string" ? msg.content.length : "array"
|
|
286597
|
+
}))
|
|
286598
|
+
});
|
|
286599
|
+
} else {
|
|
286600
|
+
orchestrationLogger.debug("No tool messages found in conversation", {
|
|
286601
|
+
totalMessages: openrouterMessages.length,
|
|
286602
|
+
messageRoles: openrouterMessages.map((msg) => msg.role)
|
|
286603
|
+
});
|
|
286604
|
+
}
|
|
286605
|
+
if (systemMessage) {
|
|
286606
|
+
openrouterMessages.unshift({
|
|
286607
|
+
role: "system",
|
|
286608
|
+
content: systemMessage
|
|
286609
|
+
});
|
|
286610
|
+
}
|
|
286611
|
+
const hasRequestTools = shouldEnableTools && Boolean(tools?.length);
|
|
286612
|
+
const reasoning = reasoningConfig.enabled && reasoningConfig.providerOptions?.reasoning ? {
|
|
286613
|
+
...reasoningConfig.providerOptions.reasoning,
|
|
286614
|
+
...selectedModelId === "openai/gpt-5.5" && hasRequestTools ? { exclude: true } : {}
|
|
286615
|
+
} : void 0;
|
|
286616
|
+
const runOpenRouterAttempt = async () => {
|
|
286617
|
+
const openrouterStream = await callOpenRouter(
|
|
286618
|
+
// Usable subscription uses the login JWT; OpenRouter uses the API key.
|
|
286619
|
+
providerRouting?.authToken ?? apiKey,
|
|
286620
|
+
{
|
|
286621
|
+
model: selectedModelId,
|
|
286622
|
+
messages: openrouterMessages,
|
|
286623
|
+
reasoning,
|
|
286624
|
+
stream: true,
|
|
286625
|
+
stream_options: {
|
|
286626
|
+
include_usage: true
|
|
286627
|
+
},
|
|
286628
|
+
tools,
|
|
286629
|
+
tool_choice: shouldEnableTools ? "auto" : void 0,
|
|
286630
|
+
temperature,
|
|
286631
|
+
max_tokens: maxTokens,
|
|
286632
|
+
provider: {
|
|
286633
|
+
allow_fallbacks: true,
|
|
286634
|
+
sort: "throughput",
|
|
286635
|
+
data_collection: "deny",
|
|
286636
|
+
// ZDR: advanced web picker and CLI overrides win; otherwise enable unless
|
|
286637
|
+
// the curated model opts out (zdr: false in model-tiers).
|
|
286638
|
+
...(providerRouting?.zdr ?? getModelEntry(selectedModelId)?.zdr !== false) && {
|
|
286639
|
+
zdr: true
|
|
286640
|
+
}
|
|
286641
|
+
}
|
|
286642
|
+
},
|
|
286643
|
+
{
|
|
286644
|
+
signal: abortSignal,
|
|
286645
|
+
// Usable subscription: point at its OpenAI-compatible endpoint. Anthropic
|
|
286646
|
+
// fallback must go to OpenRouter itself, not the compat driver.
|
|
286647
|
+
baseUrl: forceCompat && !forceDirectOpenRouter ? providerRouting?.baseUrl : void 0
|
|
286648
|
+
}
|
|
286649
|
+
);
|
|
286650
|
+
return await adaptOpenRouterStream(openrouterStream, {
|
|
286651
|
+
emitter,
|
|
286652
|
+
multiplexer,
|
|
286653
|
+
tools: aiTools,
|
|
286654
|
+
executeTool: executeToolByName,
|
|
286655
|
+
context,
|
|
286656
|
+
emitObservations: true,
|
|
286657
|
+
onPauseDetected
|
|
286658
|
+
});
|
|
286659
|
+
};
|
|
286660
|
+
return await runOpenRouterAttempt();
|
|
286661
|
+
};
|
|
286716
286662
|
if (providerRouting?.provider === "codex") {
|
|
286717
286663
|
if (!providerRouting.codexAuth) {
|
|
286718
|
-
throw new Error(
|
|
286664
|
+
throw new Error(
|
|
286665
|
+
"Codex provider selected but no credentials \u2014 run `usable-chat login` and choose Codex."
|
|
286666
|
+
);
|
|
286719
286667
|
}
|
|
286720
286668
|
const codexMessages = convertToOpenRouterMessages(conversationMessages, selectedModelId);
|
|
286721
286669
|
if (systemMessage) {
|
|
@@ -286743,7 +286691,53 @@ async function callLLM({
|
|
|
286743
286691
|
onPauseDetected
|
|
286744
286692
|
});
|
|
286745
286693
|
}
|
|
286746
|
-
if (
|
|
286694
|
+
if (isGoogleDirectModel(selectedModelId) && !forceCompat && !forceOpenRouter) {
|
|
286695
|
+
const geminiApiKey = config2.googleGemini.apiKey;
|
|
286696
|
+
if (geminiApiKey) {
|
|
286697
|
+
try {
|
|
286698
|
+
return await callGeminiDirect({
|
|
286699
|
+
apiKey: geminiApiKey,
|
|
286700
|
+
modelId: selectedModelId,
|
|
286701
|
+
messages: conversationMessages,
|
|
286702
|
+
systemMessage,
|
|
286703
|
+
tools: aiTools,
|
|
286704
|
+
shouldEnableTools,
|
|
286705
|
+
maxTokens,
|
|
286706
|
+
temperature,
|
|
286707
|
+
abortSignal,
|
|
286708
|
+
emitter,
|
|
286709
|
+
multiplexer,
|
|
286710
|
+
aiTools,
|
|
286711
|
+
executeTool: executeToolByName,
|
|
286712
|
+
context,
|
|
286713
|
+
onPauseDetected
|
|
286714
|
+
});
|
|
286715
|
+
} catch (geminiError) {
|
|
286716
|
+
if (abortSignal?.aborted) {
|
|
286717
|
+
throw geminiError;
|
|
286718
|
+
}
|
|
286719
|
+
orchestrationLogger.warn("Gemini direct failed, retrying via OpenRouter", {
|
|
286720
|
+
model: selectedModelId,
|
|
286721
|
+
error: geminiError instanceof Error ? geminiError.message : String(geminiError)
|
|
286722
|
+
});
|
|
286723
|
+
const statusEvent = emitter.emit("plan", {
|
|
286724
|
+
plan: "Retrying Gemini via OpenRouter...",
|
|
286725
|
+
steps: 1
|
|
286726
|
+
});
|
|
286727
|
+
multiplexer.send(statusEvent);
|
|
286728
|
+
return await callOpenRouterRoute({
|
|
286729
|
+
forceDirectOpenRouter: true
|
|
286730
|
+
});
|
|
286731
|
+
}
|
|
286732
|
+
}
|
|
286733
|
+
orchestrationLogger.warn(
|
|
286734
|
+
"Gemini direct selected without GEMINI_IMAGE_GEN_API_KEY, using OpenRouter",
|
|
286735
|
+
{
|
|
286736
|
+
model: selectedModelId
|
|
286737
|
+
}
|
|
286738
|
+
);
|
|
286739
|
+
}
|
|
286740
|
+
if (isClaude && !forceCompat && !forceOpenRouter) {
|
|
286747
286741
|
if (!anthropicApiKey) {
|
|
286748
286742
|
throw new Error("ANTHROPIC_API_KEY is required for Claude models");
|
|
286749
286743
|
}
|
|
@@ -286778,226 +286772,45 @@ ${systemMessage}` : systemMessage : claudeMessages.system;
|
|
|
286778
286772
|
};
|
|
286779
286773
|
}
|
|
286780
286774
|
}
|
|
286781
|
-
|
|
286782
|
-
|
|
286783
|
-
|
|
286784
|
-
|
|
286785
|
-
|
|
286786
|
-
|
|
286787
|
-
|
|
286788
|
-
|
|
286789
|
-
|
|
286790
|
-
|
|
286791
|
-
|
|
286792
|
-
|
|
286793
|
-
|
|
286794
|
-
|
|
286795
|
-
|
|
286796
|
-
|
|
286797
|
-
if (!geminiApiKey) {
|
|
286798
|
-
orchestrationLogger.warn(
|
|
286799
|
-
"GEMINI_IMAGE_GEN_API_KEY not set, falling back to OpenRouter for Gemini Direct model"
|
|
286800
|
-
);
|
|
286801
|
-
} else {
|
|
286802
|
-
const fallbackModelId = getModelFallback(selectedModelId);
|
|
286803
|
-
if (fallbackModelId && currentDepth < MAX_FALLBACK_DEPTH && shouldUseFallback(selectedModelId)) {
|
|
286804
|
-
orchestrationLogger.info("Circuit breaker OPEN, using fallback immediately", {
|
|
286805
|
-
model: selectedModelId,
|
|
286806
|
-
fallback: fallbackModelId,
|
|
286807
|
-
circuitState: getCircuitState(selectedModelId),
|
|
286808
|
-
retryDepth: currentDepth
|
|
286809
|
-
});
|
|
286810
|
-
const statusEvent = emitter.emit("plan", {
|
|
286811
|
-
plan: "Using fallback model...",
|
|
286812
|
-
steps: 1
|
|
286813
|
-
});
|
|
286814
|
-
multiplexer.send(statusEvent);
|
|
286815
|
-
return callLLM({
|
|
286816
|
-
isClaude: false,
|
|
286817
|
-
selectedModelId: fallbackModelId,
|
|
286818
|
-
conversationMessages,
|
|
286819
|
-
systemMessage,
|
|
286820
|
-
tools,
|
|
286821
|
-
shouldEnableTools,
|
|
286822
|
-
reasoningConfig,
|
|
286823
|
-
reasoningEffort,
|
|
286824
|
-
maxTokens,
|
|
286825
|
-
temperature,
|
|
286826
|
-
apiKey,
|
|
286827
|
-
anthropicApiKey,
|
|
286828
|
-
abortSignal,
|
|
286829
|
-
emitter,
|
|
286830
|
-
multiplexer,
|
|
286831
|
-
aiTools,
|
|
286832
|
-
executeToolByName,
|
|
286833
|
-
context,
|
|
286834
|
-
onPauseDetected,
|
|
286835
|
-
retryDepth: currentDepth + 1,
|
|
286836
|
-
providerRouting
|
|
286837
|
-
});
|
|
286775
|
+
try {
|
|
286776
|
+
const claudeStream = await callClaude(anthropicApiKey, claudeRequest, {
|
|
286777
|
+
signal: abortSignal
|
|
286778
|
+
});
|
|
286779
|
+
return await adaptClaudeStream(claudeStream, {
|
|
286780
|
+
emitter,
|
|
286781
|
+
multiplexer,
|
|
286782
|
+
tools: aiTools,
|
|
286783
|
+
executeTool: executeToolByName,
|
|
286784
|
+
context,
|
|
286785
|
+
emitObservations: true,
|
|
286786
|
+
onPauseDetected
|
|
286787
|
+
});
|
|
286788
|
+
} catch (claudeError) {
|
|
286789
|
+
if (abortSignal?.aborted) {
|
|
286790
|
+
throw claudeError;
|
|
286838
286791
|
}
|
|
286839
|
-
orchestrationLogger.
|
|
286792
|
+
orchestrationLogger.warn("Claude direct failed, retrying via OpenRouter", {
|
|
286840
286793
|
model: selectedModelId,
|
|
286841
|
-
|
|
286794
|
+
error: claudeError instanceof Error ? claudeError.message : String(claudeError)
|
|
286795
|
+
});
|
|
286796
|
+
const statusEvent = emitter.emit("plan", {
|
|
286797
|
+
plan: "Retrying Claude via OpenRouter...",
|
|
286798
|
+
steps: 1
|
|
286799
|
+
});
|
|
286800
|
+
multiplexer.send(statusEvent);
|
|
286801
|
+
return await callOpenRouterRoute({
|
|
286802
|
+
forceDirectOpenRouter: true
|
|
286842
286803
|
});
|
|
286843
|
-
const GEMINI_TTFT_TIMEOUT_MS = 15e3;
|
|
286844
|
-
const ttftController = new AbortController();
|
|
286845
|
-
let ttftTimer = setTimeout(
|
|
286846
|
-
() => ttftController.abort(),
|
|
286847
|
-
GEMINI_TTFT_TIMEOUT_MS
|
|
286848
|
-
);
|
|
286849
|
-
const combinedSignal = abortSignal ? AbortSignal.any([abortSignal, ttftController.signal]) : ttftController.signal;
|
|
286850
|
-
try {
|
|
286851
|
-
const result = await callGeminiDirect({
|
|
286852
|
-
apiKey: geminiApiKey,
|
|
286853
|
-
modelId: selectedModelId,
|
|
286854
|
-
messages: conversationMessages,
|
|
286855
|
-
systemMessage,
|
|
286856
|
-
tools: shouldEnableTools ? aiTools : void 0,
|
|
286857
|
-
shouldEnableTools,
|
|
286858
|
-
maxTokens,
|
|
286859
|
-
temperature,
|
|
286860
|
-
abortSignal: combinedSignal,
|
|
286861
|
-
emitter,
|
|
286862
|
-
multiplexer,
|
|
286863
|
-
aiTools,
|
|
286864
|
-
executeTool: executeToolByName,
|
|
286865
|
-
context,
|
|
286866
|
-
onPauseDetected,
|
|
286867
|
-
onFirstChunk: () => {
|
|
286868
|
-
if (ttftTimer) {
|
|
286869
|
-
clearTimeout(ttftTimer);
|
|
286870
|
-
ttftTimer = null;
|
|
286871
|
-
}
|
|
286872
|
-
}
|
|
286873
|
-
});
|
|
286874
|
-
recordSuccess(selectedModelId);
|
|
286875
|
-
return result;
|
|
286876
|
-
} catch (geminiError) {
|
|
286877
|
-
if (ttftTimer) {
|
|
286878
|
-
clearTimeout(ttftTimer);
|
|
286879
|
-
ttftTimer = null;
|
|
286880
|
-
}
|
|
286881
|
-
if (abortSignal?.aborted) {
|
|
286882
|
-
throw geminiError;
|
|
286883
|
-
}
|
|
286884
|
-
recordFailure(selectedModelId);
|
|
286885
|
-
if (fallbackModelId && currentDepth < MAX_FALLBACK_DEPTH) {
|
|
286886
|
-
orchestrationLogger.warn("Gemini direct failed, using fallback model", {
|
|
286887
|
-
error: geminiError instanceof Error ? geminiError.message : String(geminiError),
|
|
286888
|
-
originalModel: selectedModelId,
|
|
286889
|
-
fallbackModel: fallbackModelId,
|
|
286890
|
-
circuitState: getCircuitState(selectedModelId),
|
|
286891
|
-
retryDepth: currentDepth
|
|
286892
|
-
});
|
|
286893
|
-
const statusEvent = emitter.emit("plan", {
|
|
286894
|
-
plan: "Switching to fallback model...",
|
|
286895
|
-
steps: 1
|
|
286896
|
-
});
|
|
286897
|
-
multiplexer.send(statusEvent);
|
|
286898
|
-
return callLLM({
|
|
286899
|
-
isClaude: false,
|
|
286900
|
-
selectedModelId: fallbackModelId,
|
|
286901
|
-
conversationMessages,
|
|
286902
|
-
systemMessage,
|
|
286903
|
-
tools,
|
|
286904
|
-
shouldEnableTools,
|
|
286905
|
-
reasoningConfig,
|
|
286906
|
-
reasoningEffort,
|
|
286907
|
-
maxTokens,
|
|
286908
|
-
temperature,
|
|
286909
|
-
apiKey,
|
|
286910
|
-
anthropicApiKey,
|
|
286911
|
-
abortSignal,
|
|
286912
|
-
emitter,
|
|
286913
|
-
multiplexer,
|
|
286914
|
-
aiTools,
|
|
286915
|
-
executeToolByName,
|
|
286916
|
-
context,
|
|
286917
|
-
retryDepth: currentDepth + 1,
|
|
286918
|
-
providerRouting
|
|
286919
|
-
});
|
|
286920
|
-
}
|
|
286921
|
-
throw geminiError;
|
|
286922
|
-
}
|
|
286923
286804
|
}
|
|
286924
286805
|
}
|
|
286925
|
-
|
|
286926
|
-
const toolMessages = openrouterMessages.filter((msg) => msg.role === "tool");
|
|
286927
|
-
if (toolMessages.length > 0) {
|
|
286928
|
-
orchestrationLogger.debug("Tool messages being sent to OpenRouter", {
|
|
286929
|
-
toolMessageCount: toolMessages.length,
|
|
286930
|
-
toolMessages: toolMessages.map((msg) => ({
|
|
286931
|
-
role: msg.role,
|
|
286932
|
-
name: msg.name,
|
|
286933
|
-
toolCallId: msg.tool_call_id,
|
|
286934
|
-
contentLength: typeof msg.content === "string" ? msg.content.length : "array"
|
|
286935
|
-
}))
|
|
286936
|
-
});
|
|
286937
|
-
} else {
|
|
286938
|
-
orchestrationLogger.debug("No tool messages found in conversation", {
|
|
286939
|
-
totalMessages: openrouterMessages.length,
|
|
286940
|
-
messageRoles: openrouterMessages.map((msg) => msg.role)
|
|
286941
|
-
});
|
|
286942
|
-
}
|
|
286943
|
-
if (systemMessage) {
|
|
286944
|
-
openrouterMessages.unshift({
|
|
286945
|
-
role: "system",
|
|
286946
|
-
content: systemMessage
|
|
286947
|
-
});
|
|
286948
|
-
}
|
|
286949
|
-
const openrouterStream = await callOpenRouter(
|
|
286950
|
-
// Usable subscription uses the login JWT; OpenRouter uses the API key.
|
|
286951
|
-
providerRouting?.authToken ?? apiKey,
|
|
286952
|
-
{
|
|
286953
|
-
model: selectedModelId,
|
|
286954
|
-
messages: openrouterMessages,
|
|
286955
|
-
reasoning: reasoningConfig.enabled ? reasoningConfig.providerOptions?.reasoning : void 0,
|
|
286956
|
-
stream: true,
|
|
286957
|
-
stream_options: {
|
|
286958
|
-
include_usage: true
|
|
286959
|
-
},
|
|
286960
|
-
tools,
|
|
286961
|
-
tool_choice: shouldEnableTools ? "auto" : void 0,
|
|
286962
|
-
temperature,
|
|
286963
|
-
max_tokens: maxTokens,
|
|
286964
|
-
provider: {
|
|
286965
|
-
allow_fallbacks: true,
|
|
286966
|
-
sort: "throughput",
|
|
286967
|
-
data_collection: "deny",
|
|
286968
|
-
// ZDR: a CLI override (providerRouting.zdr) wins; otherwise enable unless
|
|
286969
|
-
// the model opts out (zdr: false in model-tiers). Web passes no override →
|
|
286970
|
-
// unchanged behavior.
|
|
286971
|
-
...(providerRouting?.zdr ?? getModelEntry(selectedModelId)?.zdr !== false) && {
|
|
286972
|
-
zdr: true
|
|
286973
|
-
},
|
|
286974
|
-
order: ["anthropic", "openai", "google", "groq", "deep-infra", "cerebras", "x-ai"],
|
|
286975
|
-
// AtlasCloud rejects our tool-call format (502 InvalidParameter on tool.parameters); skip until they fix it.
|
|
286976
|
-
ignore: ["atlas-cloud"]
|
|
286977
|
-
}
|
|
286978
|
-
},
|
|
286979
|
-
{
|
|
286980
|
-
signal: abortSignal,
|
|
286981
|
-
// Usable subscription: point at its OpenAI-compatible endpoint. It now
|
|
286982
|
-
// accepts tools + the `provider` (ZDR) block, so send the full request.
|
|
286983
|
-
baseUrl: forceCompat ? providerRouting?.baseUrl : void 0
|
|
286984
|
-
}
|
|
286985
|
-
);
|
|
286986
|
-
return await adaptOpenRouterStream(openrouterStream, {
|
|
286987
|
-
emitter,
|
|
286988
|
-
multiplexer,
|
|
286989
|
-
tools: aiTools,
|
|
286990
|
-
executeTool: executeToolByName,
|
|
286991
|
-
context,
|
|
286992
|
-
emitObservations: true,
|
|
286993
|
-
onPauseDetected
|
|
286994
|
-
});
|
|
286806
|
+
return await callOpenRouterRoute();
|
|
286995
286807
|
}
|
|
286996
286808
|
async function orchestrate(request) {
|
|
286997
286809
|
const { messages: messages4, context, config: config3, persona, apiKey, anthropicApiKey, mcpTools } = request;
|
|
286998
|
-
const providerRouting = config3.provider ? {
|
|
286810
|
+
const providerRouting = config3.provider || config3.zdr !== void 0 || config3.openRouterOnly ? {
|
|
286999
286811
|
provider: config3.provider,
|
|
287000
286812
|
zdr: config3.zdr,
|
|
286813
|
+
openRouterOnly: config3.openRouterOnly,
|
|
287001
286814
|
baseUrl: request.providerBaseUrl,
|
|
287002
286815
|
authToken: request.providerAuthToken,
|
|
287003
286816
|
codexAuth: request.codexAuth
|
|
@@ -287398,16 +287211,18 @@ Folder behavior:
|
|
|
287398
287211
|
const modelInfo = getModelById2(selectedModelId);
|
|
287399
287212
|
const hasNativeReasoning = modelInfo?.capabilities?.reasoning || false;
|
|
287400
287213
|
const isClaude = isClaudeModel(selectedModelId);
|
|
287214
|
+
const isGeminiDirect = isGoogleDirectModel(selectedModelId) && !providerRouting?.openRouterOnly && !providerRouting?.provider;
|
|
287215
|
+
const suppressImplicitGpt55Reasoning = selectedModelId === "openai/gpt-5.5" && !config3.reasoningEffortExplicit;
|
|
287401
287216
|
const enableReasoningForAll = process.env.ENABLE_REASONING_FOR_ALL !== "false";
|
|
287402
287217
|
const reasoningConfig = getReasoningConfig(
|
|
287403
287218
|
selectedModelId,
|
|
287404
287219
|
hasNativeReasoning,
|
|
287405
287220
|
enableReasoningForAll,
|
|
287406
|
-
config3.reasoningEffort
|
|
287221
|
+
suppressImplicitGpt55Reasoning ? void 0 : config3.reasoningEffort
|
|
287407
287222
|
);
|
|
287408
287223
|
const userId = context.session?.user?.id || "unknown";
|
|
287409
287224
|
const sessionId2 = emitter.getSequence().toString();
|
|
287410
|
-
const providerName = isClaude ? "Claude (Official SDK)" : "OpenRouter";
|
|
287225
|
+
const providerName = isClaude ? "Claude (Official SDK)" : isGeminiDirect ? "Gemini (Direct Google API)" : "OpenRouter";
|
|
287411
287226
|
orchestrationLogger.info(
|
|
287412
287227
|
`Starting ${providerName} stream`,
|
|
287413
287228
|
{
|
|
@@ -287416,9 +287231,11 @@ Folder behavior:
|
|
|
287416
287231
|
reasoningEnabled: reasoningConfig.enabled,
|
|
287417
287232
|
hasNativeReasoning,
|
|
287418
287233
|
enableReasoningForAll,
|
|
287234
|
+
suppressImplicitGpt55Reasoning,
|
|
287419
287235
|
reasoningConfig: reasoningConfig.providerOptions,
|
|
287420
287236
|
maxSteps: config3.maxSteps,
|
|
287421
|
-
isClaude
|
|
287237
|
+
isClaude,
|
|
287238
|
+
isGeminiDirect
|
|
287422
287239
|
},
|
|
287423
287240
|
{ userId, sessionId: sessionId2 }
|
|
287424
287241
|
);
|
|
@@ -287427,7 +287244,8 @@ Folder behavior:
|
|
|
287427
287244
|
model: selectedModelId,
|
|
287428
287245
|
reasoningEnabled: reasoningConfig.enabled,
|
|
287429
287246
|
reasoningOptions: reasoningConfig.providerOptions || {},
|
|
287430
|
-
isClaude
|
|
287247
|
+
isClaude,
|
|
287248
|
+
isGeminiDirect
|
|
287431
287249
|
});
|
|
287432
287250
|
let conversationMessages = await Promise.all(
|
|
287433
287251
|
messages4.map(async (msg) => {
|
|
@@ -288183,16 +288001,14 @@ Folder behavior:
|
|
|
288183
288001
|
const { dedupeSkillsByName: dedupeSkillsByName2, extractSkillName: extractSkillName2 } = await Promise.resolve().then(() => (init_skill_command(), skill_command_exports));
|
|
288184
288002
|
const dedupedSkills = dedupeSkillsByName2(skillDiscovery.skills);
|
|
288185
288003
|
const parentPromptSkills = await buildParentPromptSkills();
|
|
288186
|
-
const discoverableSkillsSection = buildDiscoverableSkillsPromptSection(
|
|
288187
|
-
|
|
288188
|
-
|
|
288189
|
-
|
|
288190
|
-
|
|
288191
|
-
|
|
288192
|
-
|
|
288193
|
-
|
|
288194
|
-
]
|
|
288195
|
-
);
|
|
288004
|
+
const discoverableSkillsSection = buildDiscoverableSkillsPromptSection([
|
|
288005
|
+
...dedupedSkills.map((skill) => ({
|
|
288006
|
+
source: "workspace",
|
|
288007
|
+
...skill,
|
|
288008
|
+
name: extractSkillName2(skill)
|
|
288009
|
+
})),
|
|
288010
|
+
...parentPromptSkills
|
|
288011
|
+
]);
|
|
288196
288012
|
if (discoverableSkillsSection) {
|
|
288197
288013
|
systemMessageParts.push(discoverableSkillsSection);
|
|
288198
288014
|
discoverableSkillsSectionInjected = true;
|
|
@@ -288239,9 +288055,12 @@ Folder behavior:
|
|
|
288239
288055
|
if (discoverableSkillsSection) {
|
|
288240
288056
|
systemMessageParts.push(discoverableSkillsSection);
|
|
288241
288057
|
discoverableSkillsSectionInjected = true;
|
|
288242
|
-
orchestrationLogger.info(
|
|
288243
|
-
|
|
288244
|
-
|
|
288058
|
+
orchestrationLogger.info(
|
|
288059
|
+
"Parent-local discoverable skills injected into system prompt",
|
|
288060
|
+
{
|
|
288061
|
+
parentSkillCount: parentPromptSkills.length
|
|
288062
|
+
}
|
|
288063
|
+
);
|
|
288245
288064
|
}
|
|
288246
288065
|
} catch (error41) {
|
|
288247
288066
|
orchestrationLogger.warn("Failed to inject parent-local skills into prompt", {
|
|
@@ -288543,12 +288362,14 @@ ${f20.content}`);
|
|
|
288543
288362
|
lines.push(
|
|
288544
288363
|
"Slash commands the user can run (you cannot call these \u2014 suggest them when relevant):"
|
|
288545
288364
|
);
|
|
288546
|
-
for (const c23 of ext2.commands)
|
|
288365
|
+
for (const c23 of ext2.commands)
|
|
288366
|
+
lines.push(`- /${c23.name}${c23.description ? ` \u2014 ${c23.description}` : ""}`);
|
|
288547
288367
|
lines.push("");
|
|
288548
288368
|
}
|
|
288549
288369
|
if (ext2.tools.length) {
|
|
288550
288370
|
lines.push("Extension tools you can call like any other tool:");
|
|
288551
|
-
for (const t14 of ext2.tools)
|
|
288371
|
+
for (const t14 of ext2.tools)
|
|
288372
|
+
lines.push(`- ${t14.name}${t14.description ? ` \u2014 ${t14.description}` : ""}`);
|
|
288552
288373
|
}
|
|
288553
288374
|
systemMessageParts.push(lines.join("\n"));
|
|
288554
288375
|
}
|
|
@@ -289218,7 +289039,16 @@ ${combinedSystemMessage}` : combinedSystemMessage;
|
|
|
289218
289039
|
const maxSteps = config3.maxSteps || 200;
|
|
289219
289040
|
let forceNoTools = false;
|
|
289220
289041
|
let lastStepHadToolErrors = false;
|
|
289042
|
+
let lastStepHadToolActivity = false;
|
|
289221
289043
|
let recoveryAttempted = false;
|
|
289044
|
+
const repeatedToolCallCounts = /* @__PURE__ */ new Map();
|
|
289045
|
+
const MAX_IDENTICAL_TOOL_CALLS = 3;
|
|
289046
|
+
const stableStringify = (value) => {
|
|
289047
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
289048
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
289049
|
+
return `{${Object.entries(value).sort(([a22], [b32]) => a22.localeCompare(b32)).map(([key, nestedValue]) => `${JSON.stringify(key)}:${stableStringify(nestedValue)}`).join(",")}}`;
|
|
289050
|
+
};
|
|
289051
|
+
const toolCallSignature = (toolCall) => `${toolCall.name}:${stableStringify(toolCall.arguments)}`;
|
|
289222
289052
|
orchestrationLogger.info("Starting multi-turn loop", { maxSteps }, { userId, sessionId: sessionId2 });
|
|
289223
289053
|
const pauseSignaled = { current: false };
|
|
289224
289054
|
const pendingPauseRef = { current: null };
|
|
@@ -289742,19 +289572,25 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
289742
289572
|
multiplexer.send(stepFinishEvent);
|
|
289743
289573
|
orchestrationLogger.debug("Emitted step-finish event", { currentStep });
|
|
289744
289574
|
if (result.finishReason === "stop" || result.finishReason === "end_turn") {
|
|
289745
|
-
|
|
289746
|
-
|
|
289575
|
+
if (shouldRecoverSilentStop({
|
|
289576
|
+
text: result.text,
|
|
289577
|
+
lastStepHadToolErrors,
|
|
289578
|
+
lastStepHadToolActivity,
|
|
289579
|
+
recoveryAttempted
|
|
289580
|
+
})) {
|
|
289747
289581
|
recoveryAttempted = true;
|
|
289582
|
+
const recoveryPrompt = lastStepHadToolErrors ? "The previous tool call failed. Briefly summarise to the user what happened, why it likely failed, and any next steps they could take (without retrying the failed tool)." : "The previous step used tools but did not produce a visible final answer. Using the available tool results, answer the user now. Do not call more tools unless absolutely required.";
|
|
289748
289583
|
orchestrationLogger.warn(
|
|
289749
|
-
"Model stopped silently after
|
|
289584
|
+
"Model stopped silently after tool activity \u2014 injecting recovery prompt",
|
|
289750
289585
|
{ step: currentStep, finishReason: result.finishReason },
|
|
289751
289586
|
{ userId, sessionId: sessionId2 }
|
|
289752
289587
|
);
|
|
289753
289588
|
conversationMessages.push({
|
|
289754
289589
|
role: "user",
|
|
289755
|
-
content:
|
|
289590
|
+
content: recoveryPrompt
|
|
289756
289591
|
});
|
|
289757
289592
|
lastStepHadToolErrors = false;
|
|
289593
|
+
lastStepHadToolActivity = false;
|
|
289758
289594
|
continue;
|
|
289759
289595
|
}
|
|
289760
289596
|
const hasOnlyThinking = !result.text?.trim() && result.reasoningDetails?.length;
|
|
@@ -289841,6 +289677,32 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
289841
289677
|
break;
|
|
289842
289678
|
}
|
|
289843
289679
|
if ((result.finishReason === "tool_calls" || result.finishReason === "tool_use" || result.finishReason === "max_tokens" && result.toolCalls.length > 0) && result.toolCalls.length > 0) {
|
|
289680
|
+
const repeatedToolCall = result.toolCalls.find((toolCall) => {
|
|
289681
|
+
const signature = toolCallSignature(toolCall);
|
|
289682
|
+
const nextCount = (repeatedToolCallCounts.get(signature) ?? 0) + 1;
|
|
289683
|
+
repeatedToolCallCounts.set(signature, nextCount);
|
|
289684
|
+
return nextCount >= MAX_IDENTICAL_TOOL_CALLS;
|
|
289685
|
+
});
|
|
289686
|
+
if (repeatedToolCall) {
|
|
289687
|
+
forceNoTools = true;
|
|
289688
|
+
const signature = toolCallSignature(repeatedToolCall);
|
|
289689
|
+
const repeatedCount = repeatedToolCallCounts.get(signature) ?? MAX_IDENTICAL_TOOL_CALLS;
|
|
289690
|
+
orchestrationLogger.warn(
|
|
289691
|
+
"Detected repeated identical tool call, forcing synthesis without more tools",
|
|
289692
|
+
{
|
|
289693
|
+
toolName: repeatedToolCall.name,
|
|
289694
|
+
repeatedCount,
|
|
289695
|
+
step: currentStep,
|
|
289696
|
+
model: selectedModelId
|
|
289697
|
+
},
|
|
289698
|
+
{ userId, sessionId: sessionId2 }
|
|
289699
|
+
);
|
|
289700
|
+
conversationMessages.push({
|
|
289701
|
+
role: "user",
|
|
289702
|
+
content: `[SYSTEM: You already called ${repeatedToolCall.name} with the same arguments ${repeatedCount} times. Do not call more tools. Use the tool results already available in this conversation and answer the user's request now.]`
|
|
289703
|
+
});
|
|
289704
|
+
continue;
|
|
289705
|
+
}
|
|
289844
289706
|
const resultIds = new Set(result.toolResults.map((tr5) => tr5.id));
|
|
289845
289707
|
for (const tc of result.toolCalls) {
|
|
289846
289708
|
if (!resultIds.has(tc.id)) {
|
|
@@ -289898,15 +289760,6 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
289898
289760
|
isClaude
|
|
289899
289761
|
});
|
|
289900
289762
|
}
|
|
289901
|
-
if ("rawModelParts" in result && result.rawModelParts) {
|
|
289902
|
-
assistantMessage._geminiRawParts = result.rawModelParts;
|
|
289903
|
-
orchestrationLogger.debug(
|
|
289904
|
-
"Preserved raw Gemini model parts for thought_signature replay",
|
|
289905
|
-
{
|
|
289906
|
-
partsCount: result.rawModelParts.length
|
|
289907
|
-
}
|
|
289908
|
-
);
|
|
289909
|
-
}
|
|
289910
289763
|
conversationMessages.push(assistantMessage);
|
|
289911
289764
|
if (result.toolResults.length > 0) {
|
|
289912
289765
|
const { summarizeToolResultForHistory: summarizeToolResultForHistory2 } = await Promise.resolve().then(() => (init_tool_result_summarizer(), tool_result_summarizer_exports));
|
|
@@ -290089,6 +289942,7 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
290089
289942
|
messageCount: conversationMessages.length
|
|
290090
289943
|
});
|
|
290091
289944
|
lastStepHadToolErrors = result.toolResults.some((tr5) => tr5.isError === true);
|
|
289945
|
+
lastStepHadToolActivity = result.toolCalls.length > 0;
|
|
290092
289946
|
orchestrationLogger.info(
|
|
290093
289947
|
"Conversation updated, continuing loop",
|
|
290094
289948
|
{
|
|
@@ -290178,10 +290032,7 @@ Re-read them (working_memory on web, bash on the CLI \u2014 grep/sed projection,
|
|
|
290178
290032
|
}
|
|
290179
290033
|
const hasFiles = Object.keys(persistData).length > 0;
|
|
290180
290034
|
if (!context.chatStore) return;
|
|
290181
|
-
await context.chatStore.saveWorkingMemory(
|
|
290182
|
-
conversationId,
|
|
290183
|
-
hasFiles ? persistData : null
|
|
290184
|
-
);
|
|
290035
|
+
await context.chatStore.saveWorkingMemory(conversationId, hasFiles ? persistData : null);
|
|
290185
290036
|
if (hasFiles) {
|
|
290186
290037
|
orchestrationLogger.info(
|
|
290187
290038
|
"Persisted working memory",
|
|
@@ -290326,6 +290177,7 @@ function createOrchestratorRequest(messages4, context, config3, persona, apiKey,
|
|
|
290326
290177
|
toolTimeoutMs: config3.toolTimeoutMs ?? 6e4,
|
|
290327
290178
|
reasoningEffort: config3.reasoningEffort,
|
|
290328
290179
|
// Pass through reasoning effort
|
|
290180
|
+
reasoningEffortExplicit: config3.reasoningEffortExplicit,
|
|
290329
290181
|
isMultilingual: config3.isMultilingual,
|
|
290330
290182
|
// Pass through multilingual flag
|
|
290331
290183
|
__scriptedLlm: config3.__scriptedLlm,
|
|
@@ -290333,7 +290185,9 @@ function createOrchestratorRequest(messages4, context, config3, persona, apiKey,
|
|
|
290333
290185
|
provider: config3.provider,
|
|
290334
290186
|
// CLI provider override (undefined on web)
|
|
290335
290187
|
zdr: config3.zdr,
|
|
290336
|
-
//
|
|
290188
|
+
// ZDR override from advanced web picker or CLI.
|
|
290189
|
+
openRouterOnly: config3.openRouterOnly,
|
|
290190
|
+
// Advanced web picker direct-provider bypass.
|
|
290337
290191
|
localFilesystem: config3.localFilesystem,
|
|
290338
290192
|
// CLI harness real-fs flag (undefined on web)
|
|
290339
290193
|
systemPromptOverride: config3.systemPromptOverride,
|
|
@@ -290379,7 +290233,6 @@ var init_orchestrator = __esm({
|
|
|
290379
290233
|
init_slack_mention_resolver();
|
|
290380
290234
|
init_integration_service();
|
|
290381
290235
|
init_claude_direct();
|
|
290382
|
-
init_config();
|
|
290383
290236
|
init_logger();
|
|
290384
290237
|
init_model_config();
|
|
290385
290238
|
init_model_tiers();
|
|
@@ -290389,9 +290242,8 @@ var init_orchestrator = __esm({
|
|
|
290389
290242
|
init_codex_direct();
|
|
290390
290243
|
init_reasoning_config();
|
|
290391
290244
|
init_claude_stream_adapter();
|
|
290392
|
-
init_scripted_stream_adapter();
|
|
290393
|
-
init_circuit_breaker();
|
|
290394
290245
|
init_gemini_direct_stream_adapter();
|
|
290246
|
+
init_scripted_stream_adapter();
|
|
290395
290247
|
init_openrouter_stream_adapter();
|
|
290396
290248
|
init_provider();
|
|
290397
290249
|
init_emitter();
|
|
@@ -293222,6 +293074,7 @@ async function runCliTurn(options2) {
|
|
|
293222
293074
|
{
|
|
293223
293075
|
model,
|
|
293224
293076
|
reasoningEffort,
|
|
293077
|
+
reasoningEffortExplicit: reasoningEffort !== void 0,
|
|
293225
293078
|
__scriptedLlm: scriptedLlm,
|
|
293226
293079
|
provider: provider?.name,
|
|
293227
293080
|
zdr: provider?.zdr,
|
|
@@ -309083,7 +308936,7 @@ init_tui_select();
|
|
|
309083
308936
|
init_model_registry();
|
|
309084
308937
|
|
|
309085
308938
|
// package.json
|
|
309086
|
-
var version2 = "1.162.
|
|
308939
|
+
var version2 = "1.162.3";
|
|
309087
308940
|
|
|
309088
308941
|
// src/adapters/cli/model-catalog.ts
|
|
309089
308942
|
init_codex_auth();
|