@opentiny/next-sdk 0.2.9 → 0.3.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -53
- package/agent/AgentModelProvider.ts +77 -25
- package/agent/type.ts +3 -3
- package/core.ts +28 -0
- package/dist/AgentModelProvider-BIOOEdcN.js +4068 -0
- package/dist/agent/AgentModelProvider.d.ts +2 -0
- package/dist/agent/type.d.ts +3 -0
- package/dist/core.d.ts +24 -0
- package/dist/core.js +35 -0
- package/dist/index.es.dev.js +1475 -240
- package/dist/index.es.js +17007 -15999
- package/dist/index.js +894 -4475
- package/dist/index.umd.dev.js +1475 -240
- package/dist/index.umd.js +57 -58
- package/dist/page-tools/bridge.d.ts +94 -7
- package/dist/remoter/createRemoter.d.ts +3 -2
- package/dist/transport/ExtensionPageServerTransport.d.ts +0 -1
- package/dist/webagent.dev.js +1467 -789
- package/dist/webagent.es.dev.js +1467 -789
- package/dist/webagent.es.js +13644 -13046
- package/dist/webagent.js +58 -59
- package/dist/webmcp-full.dev.js +0 -12
- package/dist/webmcp-full.es.dev.js +0 -12
- package/dist/webmcp-full.es.js +1050 -1058
- package/dist/webmcp-full.js +9 -9
- package/dist/webmcp.dev.js +0 -12
- package/dist/webmcp.es.dev.js +0 -12
- package/dist/webmcp.es.js +78 -86
- package/dist/webmcp.js +1 -1
- package/package.json +11 -1
- package/page-tools/bridge.ts +907 -102
- package/remoter/createRemoter.ts +44 -23
- package/transport/ExtensionClientTransport.ts +15 -5
- package/transport/ExtensionContentServerTransport.ts +4 -15
- package/transport/ExtensionPageServerTransport.ts +3 -13
- package/vite-build-tsc.ts +5 -2
package/dist/webagent.dev.js
CHANGED
|
@@ -8486,6 +8486,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8486
8486
|
const response = await fetch(url2, {
|
|
8487
8487
|
signal: options == null ? void 0 : options.abortSignal
|
|
8488
8488
|
});
|
|
8489
|
+
if (response.redirected) {
|
|
8490
|
+
validateDownloadUrl(response.url);
|
|
8491
|
+
}
|
|
8489
8492
|
if (!response.ok) {
|
|
8490
8493
|
throw new DownloadError({
|
|
8491
8494
|
url: url2,
|
|
@@ -8647,7 +8650,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8647
8650
|
);
|
|
8648
8651
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
8649
8652
|
}
|
|
8650
|
-
var VERSION$7 = "4.0.
|
|
8653
|
+
var VERSION$7 = "4.0.21";
|
|
8651
8654
|
var getOriginalFetch = () => globalThis.fetch;
|
|
8652
8655
|
var getFromApi = async ({
|
|
8653
8656
|
url: url2,
|
|
@@ -8871,7 +8874,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8871
8874
|
if (typeof def === "boolean") return def;
|
|
8872
8875
|
return addAdditionalPropertiesToJsonSchema(def);
|
|
8873
8876
|
}
|
|
8874
|
-
var ignoreOverride = Symbol(
|
|
8877
|
+
var ignoreOverride = /* @__PURE__ */ Symbol(
|
|
8875
8878
|
"Let zodToJsonSchema decide on which parser to use"
|
|
8876
8879
|
);
|
|
8877
8880
|
var defaultOptions = {
|
|
@@ -9963,7 +9966,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
9963
9966
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
9964
9967
|
return combined;
|
|
9965
9968
|
};
|
|
9966
|
-
var schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
9969
|
+
var schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
9967
9970
|
function lazySchema(createSchema) {
|
|
9968
9971
|
let schema;
|
|
9969
9972
|
return () => {
|
|
@@ -11074,6 +11077,187 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11074
11077
|
}))
|
|
11075
11078
|
)
|
|
11076
11079
|
);
|
|
11080
|
+
var GatewaySpendReport = class {
|
|
11081
|
+
constructor(config2) {
|
|
11082
|
+
this.config = config2;
|
|
11083
|
+
}
|
|
11084
|
+
async getSpendReport(params) {
|
|
11085
|
+
try {
|
|
11086
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
11087
|
+
const searchParams = new URLSearchParams();
|
|
11088
|
+
searchParams.set("start_date", params.startDate);
|
|
11089
|
+
searchParams.set("end_date", params.endDate);
|
|
11090
|
+
if (params.groupBy) {
|
|
11091
|
+
searchParams.set("group_by", params.groupBy);
|
|
11092
|
+
}
|
|
11093
|
+
if (params.datePart) {
|
|
11094
|
+
searchParams.set("date_part", params.datePart);
|
|
11095
|
+
}
|
|
11096
|
+
if (params.userId) {
|
|
11097
|
+
searchParams.set("user_id", params.userId);
|
|
11098
|
+
}
|
|
11099
|
+
if (params.model) {
|
|
11100
|
+
searchParams.set("model", params.model);
|
|
11101
|
+
}
|
|
11102
|
+
if (params.provider) {
|
|
11103
|
+
searchParams.set("provider", params.provider);
|
|
11104
|
+
}
|
|
11105
|
+
if (params.credentialType) {
|
|
11106
|
+
searchParams.set("credential_type", params.credentialType);
|
|
11107
|
+
}
|
|
11108
|
+
if (params.tags && params.tags.length > 0) {
|
|
11109
|
+
searchParams.set("tags", params.tags.join(","));
|
|
11110
|
+
}
|
|
11111
|
+
const { value } = await getFromApi({
|
|
11112
|
+
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
11113
|
+
headers: await resolve$1(this.config.headers()),
|
|
11114
|
+
successfulResponseHandler: createJsonResponseHandler$1(
|
|
11115
|
+
gatewaySpendReportResponseSchema
|
|
11116
|
+
),
|
|
11117
|
+
failedResponseHandler: createJsonErrorResponseHandler$1({
|
|
11118
|
+
errorSchema: any(),
|
|
11119
|
+
errorToMessage: (data) => data
|
|
11120
|
+
}),
|
|
11121
|
+
fetch: this.config.fetch
|
|
11122
|
+
});
|
|
11123
|
+
return value;
|
|
11124
|
+
} catch (error) {
|
|
11125
|
+
throw await asGatewayError(error);
|
|
11126
|
+
}
|
|
11127
|
+
}
|
|
11128
|
+
};
|
|
11129
|
+
var gatewaySpendReportResponseSchema = lazySchema(
|
|
11130
|
+
() => zodSchema(
|
|
11131
|
+
object$1({
|
|
11132
|
+
results: array$1(
|
|
11133
|
+
object$1({
|
|
11134
|
+
day: string().optional(),
|
|
11135
|
+
hour: string().optional(),
|
|
11136
|
+
user: string().optional(),
|
|
11137
|
+
model: string().optional(),
|
|
11138
|
+
tag: string().optional(),
|
|
11139
|
+
provider: string().optional(),
|
|
11140
|
+
credential_type: _enum$1(["byok", "system"]).optional(),
|
|
11141
|
+
total_cost: number$1(),
|
|
11142
|
+
market_cost: number$1().optional(),
|
|
11143
|
+
input_tokens: number$1().optional(),
|
|
11144
|
+
output_tokens: number$1().optional(),
|
|
11145
|
+
cached_input_tokens: number$1().optional(),
|
|
11146
|
+
cache_creation_input_tokens: number$1().optional(),
|
|
11147
|
+
reasoning_tokens: number$1().optional(),
|
|
11148
|
+
request_count: number$1().optional()
|
|
11149
|
+
}).transform(
|
|
11150
|
+
({
|
|
11151
|
+
credential_type,
|
|
11152
|
+
total_cost,
|
|
11153
|
+
market_cost,
|
|
11154
|
+
input_tokens,
|
|
11155
|
+
output_tokens,
|
|
11156
|
+
cached_input_tokens,
|
|
11157
|
+
cache_creation_input_tokens,
|
|
11158
|
+
reasoning_tokens,
|
|
11159
|
+
request_count,
|
|
11160
|
+
...rest
|
|
11161
|
+
}) => ({
|
|
11162
|
+
...rest,
|
|
11163
|
+
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
11164
|
+
totalCost: total_cost,
|
|
11165
|
+
...market_cost !== void 0 ? { marketCost: market_cost } : {},
|
|
11166
|
+
...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
|
|
11167
|
+
...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
|
|
11168
|
+
...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
|
|
11169
|
+
...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
|
|
11170
|
+
...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
|
|
11171
|
+
...request_count !== void 0 ? { requestCount: request_count } : {}
|
|
11172
|
+
})
|
|
11173
|
+
)
|
|
11174
|
+
)
|
|
11175
|
+
})
|
|
11176
|
+
)
|
|
11177
|
+
);
|
|
11178
|
+
var GatewayGenerationInfoFetcher = class {
|
|
11179
|
+
constructor(config2) {
|
|
11180
|
+
this.config = config2;
|
|
11181
|
+
}
|
|
11182
|
+
async getGenerationInfo(params) {
|
|
11183
|
+
try {
|
|
11184
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
11185
|
+
const { value } = await getFromApi({
|
|
11186
|
+
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
11187
|
+
headers: await resolve$1(this.config.headers()),
|
|
11188
|
+
successfulResponseHandler: createJsonResponseHandler$1(
|
|
11189
|
+
gatewayGenerationInfoResponseSchema
|
|
11190
|
+
),
|
|
11191
|
+
failedResponseHandler: createJsonErrorResponseHandler$1({
|
|
11192
|
+
errorSchema: any(),
|
|
11193
|
+
errorToMessage: (data) => data
|
|
11194
|
+
}),
|
|
11195
|
+
fetch: this.config.fetch
|
|
11196
|
+
});
|
|
11197
|
+
return value;
|
|
11198
|
+
} catch (error) {
|
|
11199
|
+
throw await asGatewayError(error);
|
|
11200
|
+
}
|
|
11201
|
+
}
|
|
11202
|
+
};
|
|
11203
|
+
var gatewayGenerationInfoResponseSchema = lazySchema(
|
|
11204
|
+
() => zodSchema(
|
|
11205
|
+
object$1({
|
|
11206
|
+
data: object$1({
|
|
11207
|
+
id: string(),
|
|
11208
|
+
total_cost: number$1(),
|
|
11209
|
+
upstream_inference_cost: number$1(),
|
|
11210
|
+
usage: number$1(),
|
|
11211
|
+
created_at: string(),
|
|
11212
|
+
model: string(),
|
|
11213
|
+
is_byok: boolean(),
|
|
11214
|
+
provider_name: string(),
|
|
11215
|
+
streamed: boolean(),
|
|
11216
|
+
finish_reason: string(),
|
|
11217
|
+
latency: number$1(),
|
|
11218
|
+
generation_time: number$1(),
|
|
11219
|
+
native_tokens_prompt: number$1(),
|
|
11220
|
+
native_tokens_completion: number$1(),
|
|
11221
|
+
native_tokens_reasoning: number$1(),
|
|
11222
|
+
native_tokens_cached: number$1(),
|
|
11223
|
+
native_tokens_cache_creation: number$1(),
|
|
11224
|
+
billable_web_search_calls: number$1()
|
|
11225
|
+
}).transform(
|
|
11226
|
+
({
|
|
11227
|
+
total_cost,
|
|
11228
|
+
upstream_inference_cost,
|
|
11229
|
+
created_at,
|
|
11230
|
+
is_byok,
|
|
11231
|
+
provider_name,
|
|
11232
|
+
finish_reason,
|
|
11233
|
+
generation_time,
|
|
11234
|
+
native_tokens_prompt,
|
|
11235
|
+
native_tokens_completion,
|
|
11236
|
+
native_tokens_reasoning,
|
|
11237
|
+
native_tokens_cached,
|
|
11238
|
+
native_tokens_cache_creation,
|
|
11239
|
+
billable_web_search_calls,
|
|
11240
|
+
...rest
|
|
11241
|
+
}) => ({
|
|
11242
|
+
...rest,
|
|
11243
|
+
totalCost: total_cost,
|
|
11244
|
+
upstreamInferenceCost: upstream_inference_cost,
|
|
11245
|
+
createdAt: created_at,
|
|
11246
|
+
isByok: is_byok,
|
|
11247
|
+
providerName: provider_name,
|
|
11248
|
+
finishReason: finish_reason,
|
|
11249
|
+
generationTime: generation_time,
|
|
11250
|
+
promptTokens: native_tokens_prompt,
|
|
11251
|
+
completionTokens: native_tokens_completion,
|
|
11252
|
+
reasoningTokens: native_tokens_reasoning,
|
|
11253
|
+
cachedTokens: native_tokens_cached,
|
|
11254
|
+
cacheCreationTokens: native_tokens_cache_creation,
|
|
11255
|
+
billableWebSearchCalls: billable_web_search_calls
|
|
11256
|
+
})
|
|
11257
|
+
)
|
|
11258
|
+
}).transform(({ data }) => data)
|
|
11259
|
+
)
|
|
11260
|
+
);
|
|
11077
11261
|
var GatewayLanguageModel = class {
|
|
11078
11262
|
constructor(modelId, config2) {
|
|
11079
11263
|
this.modelId = modelId;
|
|
@@ -11798,7 +11982,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11798
11982
|
var _a92;
|
|
11799
11983
|
return (_a92 = indexBrowserExports.getContext().headers) == null ? void 0 : _a92["x-vercel-id"];
|
|
11800
11984
|
}
|
|
11801
|
-
var VERSION$6 = "3.0.
|
|
11985
|
+
var VERSION$6 = "3.0.83";
|
|
11802
11986
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
11803
11987
|
function createGatewayProvider(options = {}) {
|
|
11804
11988
|
var _a92, _b9;
|
|
@@ -11898,6 +12082,30 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11898
12082
|
);
|
|
11899
12083
|
});
|
|
11900
12084
|
};
|
|
12085
|
+
const getSpendReport = async (params) => {
|
|
12086
|
+
return new GatewaySpendReport({
|
|
12087
|
+
baseURL,
|
|
12088
|
+
headers: getHeaders,
|
|
12089
|
+
fetch: options.fetch
|
|
12090
|
+
}).getSpendReport(params).catch(async (error) => {
|
|
12091
|
+
throw await asGatewayError(
|
|
12092
|
+
error,
|
|
12093
|
+
await parseAuthMethod(await getHeaders())
|
|
12094
|
+
);
|
|
12095
|
+
});
|
|
12096
|
+
};
|
|
12097
|
+
const getGenerationInfo = async (params) => {
|
|
12098
|
+
return new GatewayGenerationInfoFetcher({
|
|
12099
|
+
baseURL,
|
|
12100
|
+
headers: getHeaders,
|
|
12101
|
+
fetch: options.fetch
|
|
12102
|
+
}).getGenerationInfo(params).catch(async (error) => {
|
|
12103
|
+
throw await asGatewayError(
|
|
12104
|
+
error,
|
|
12105
|
+
await parseAuthMethod(await getHeaders())
|
|
12106
|
+
);
|
|
12107
|
+
});
|
|
12108
|
+
};
|
|
11901
12109
|
const provider = function(modelId) {
|
|
11902
12110
|
if (new.target) {
|
|
11903
12111
|
throw new Error(
|
|
@@ -11909,6 +12117,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11909
12117
|
provider.specificationVersion = "v3";
|
|
11910
12118
|
provider.getAvailableModels = getAvailableModels;
|
|
11911
12119
|
provider.getCredits = getCredits;
|
|
12120
|
+
provider.getSpendReport = getSpendReport;
|
|
12121
|
+
provider.getGenerationInfo = getGenerationInfo;
|
|
11912
12122
|
provider.imageModel = (modelId) => {
|
|
11913
12123
|
return new GatewayImageModel(modelId, {
|
|
11914
12124
|
provider: "gateway",
|
|
@@ -13633,7 +13843,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
13633
13843
|
}
|
|
13634
13844
|
return void 0;
|
|
13635
13845
|
}
|
|
13636
|
-
var VERSION$4 = "6.0.
|
|
13846
|
+
var VERSION$4 = "6.0.141";
|
|
13637
13847
|
var download = async ({
|
|
13638
13848
|
url: url2,
|
|
13639
13849
|
maxBytes,
|
|
@@ -13651,6 +13861,9 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
13651
13861
|
),
|
|
13652
13862
|
signal: abortSignal
|
|
13653
13863
|
});
|
|
13864
|
+
if (response.redirected) {
|
|
13865
|
+
validateDownloadUrl(response.url);
|
|
13866
|
+
}
|
|
13654
13867
|
if (!response.ok) {
|
|
13655
13868
|
throw new DownloadError({
|
|
13656
13869
|
url: urlText,
|
|
@@ -16424,7 +16637,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16424
16637
|
}),
|
|
16425
16638
|
tracer,
|
|
16426
16639
|
fn: async (span) => {
|
|
16427
|
-
var _a21, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
16640
|
+
var _a21, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
16428
16641
|
const initialMessages = initialPrompt.messages;
|
|
16429
16642
|
const responseMessages = [];
|
|
16430
16643
|
const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
|
|
@@ -16641,6 +16854,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16641
16854
|
headers: (_g2 = result.response) == null ? void 0 : _g2.headers,
|
|
16642
16855
|
body: (_h2 = result.response) == null ? void 0 : _h2.body
|
|
16643
16856
|
};
|
|
16857
|
+
const usage = asLanguageModelUsage(result.usage);
|
|
16644
16858
|
span2.setAttributes(
|
|
16645
16859
|
await selectTelemetryAttributes({
|
|
16646
16860
|
telemetry,
|
|
@@ -16664,9 +16878,16 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16664
16878
|
"ai.response.providerMetadata": JSON.stringify(
|
|
16665
16879
|
result.providerMetadata
|
|
16666
16880
|
),
|
|
16667
|
-
|
|
16668
|
-
"ai.usage.
|
|
16669
|
-
"ai.usage.
|
|
16881
|
+
"ai.usage.inputTokens": result.usage.inputTokens.total,
|
|
16882
|
+
"ai.usage.inputTokenDetails.noCacheTokens": result.usage.inputTokens.noCache,
|
|
16883
|
+
"ai.usage.inputTokenDetails.cacheReadTokens": result.usage.inputTokens.cacheRead,
|
|
16884
|
+
"ai.usage.inputTokenDetails.cacheWriteTokens": result.usage.inputTokens.cacheWrite,
|
|
16885
|
+
"ai.usage.outputTokens": result.usage.outputTokens.total,
|
|
16886
|
+
"ai.usage.outputTokenDetails.textTokens": result.usage.outputTokens.text,
|
|
16887
|
+
"ai.usage.outputTokenDetails.reasoningTokens": result.usage.outputTokens.reasoning,
|
|
16888
|
+
"ai.usage.totalTokens": usage.totalTokens,
|
|
16889
|
+
"ai.usage.reasoningTokens": result.usage.outputTokens.reasoning,
|
|
16890
|
+
"ai.usage.cachedInputTokens": result.usage.inputTokens.cacheRead,
|
|
16670
16891
|
// standardized gen-ai llm span attributes:
|
|
16671
16892
|
"gen_ai.response.finish_reasons": [
|
|
16672
16893
|
result.finishReason.unified
|
|
@@ -16867,10 +17088,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16867
17088
|
},
|
|
16868
17089
|
"ai.response.providerMetadata": JSON.stringify(
|
|
16869
17090
|
currentModelResponse.providerMetadata
|
|
16870
|
-
)
|
|
16871
|
-
// TODO rename telemetry attributes to inputTokens and outputTokens
|
|
16872
|
-
"ai.usage.promptTokens": currentModelResponse.usage.inputTokens.total,
|
|
16873
|
-
"ai.usage.completionTokens": currentModelResponse.usage.outputTokens.total
|
|
17091
|
+
)
|
|
16874
17092
|
}
|
|
16875
17093
|
})
|
|
16876
17094
|
);
|
|
@@ -16887,6 +17105,23 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16887
17105
|
cachedInputTokens: void 0
|
|
16888
17106
|
}
|
|
16889
17107
|
);
|
|
17108
|
+
span.setAttributes(
|
|
17109
|
+
await selectTelemetryAttributes({
|
|
17110
|
+
telemetry,
|
|
17111
|
+
attributes: {
|
|
17112
|
+
"ai.usage.inputTokens": totalUsage.inputTokens,
|
|
17113
|
+
"ai.usage.inputTokenDetails.noCacheTokens": (_n = totalUsage.inputTokenDetails) == null ? void 0 : _n.noCacheTokens,
|
|
17114
|
+
"ai.usage.inputTokenDetails.cacheReadTokens": (_o = totalUsage.inputTokenDetails) == null ? void 0 : _o.cacheReadTokens,
|
|
17115
|
+
"ai.usage.inputTokenDetails.cacheWriteTokens": (_p = totalUsage.inputTokenDetails) == null ? void 0 : _p.cacheWriteTokens,
|
|
17116
|
+
"ai.usage.outputTokens": totalUsage.outputTokens,
|
|
17117
|
+
"ai.usage.outputTokenDetails.textTokens": (_q = totalUsage.outputTokenDetails) == null ? void 0 : _q.textTokens,
|
|
17118
|
+
"ai.usage.outputTokenDetails.reasoningTokens": (_r = totalUsage.outputTokenDetails) == null ? void 0 : _r.reasoningTokens,
|
|
17119
|
+
"ai.usage.totalTokens": totalUsage.totalTokens,
|
|
17120
|
+
"ai.usage.reasoningTokens": (_s = totalUsage.outputTokenDetails) == null ? void 0 : _s.reasoningTokens,
|
|
17121
|
+
"ai.usage.cachedInputTokens": (_t = totalUsage.inputTokenDetails) == null ? void 0 : _t.cacheReadTokens
|
|
17122
|
+
}
|
|
17123
|
+
})
|
|
17124
|
+
);
|
|
16890
17125
|
await notify({
|
|
16891
17126
|
event: {
|
|
16892
17127
|
stepNumber: lastStep.stepNumber,
|
|
@@ -17114,7 +17349,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17114
17349
|
input: void 0,
|
|
17115
17350
|
error: part.result,
|
|
17116
17351
|
providerExecuted: true,
|
|
17117
|
-
dynamic: part.dynamic
|
|
17352
|
+
dynamic: part.dynamic,
|
|
17353
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
17118
17354
|
});
|
|
17119
17355
|
} else {
|
|
17120
17356
|
contentParts.push({
|
|
@@ -17124,7 +17360,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17124
17360
|
input: void 0,
|
|
17125
17361
|
output: part.result,
|
|
17126
17362
|
providerExecuted: true,
|
|
17127
|
-
dynamic: part.dynamic
|
|
17363
|
+
dynamic: part.dynamic,
|
|
17364
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
17128
17365
|
});
|
|
17129
17366
|
}
|
|
17130
17367
|
break;
|
|
@@ -17137,7 +17374,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17137
17374
|
input: toolCall.input,
|
|
17138
17375
|
error: part.result,
|
|
17139
17376
|
providerExecuted: true,
|
|
17140
|
-
dynamic: toolCall.dynamic
|
|
17377
|
+
dynamic: toolCall.dynamic,
|
|
17378
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
17141
17379
|
});
|
|
17142
17380
|
} else {
|
|
17143
17381
|
contentParts.push({
|
|
@@ -17147,7 +17385,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17147
17385
|
input: toolCall.input,
|
|
17148
17386
|
output: part.result,
|
|
17149
17387
|
providerExecuted: true,
|
|
17150
|
-
dynamic: toolCall.dynamic
|
|
17388
|
+
dynamic: toolCall.dynamic,
|
|
17389
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
17151
17390
|
});
|
|
17152
17391
|
}
|
|
17153
17392
|
break;
|
|
@@ -17378,8 +17617,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17378
17617
|
anyPart.title = options.title;
|
|
17379
17618
|
}
|
|
17380
17619
|
anyPart.providerExecuted = (_a22 = anyOptions.providerExecuted) != null ? _a22 : part.providerExecuted;
|
|
17381
|
-
|
|
17382
|
-
|
|
17620
|
+
const providerMetadata = anyOptions.providerMetadata;
|
|
17621
|
+
if (providerMetadata != null) {
|
|
17622
|
+
if (options.state === "output-available" || options.state === "output-error") {
|
|
17623
|
+
const resultPart = part;
|
|
17624
|
+
resultPart.resultProviderMetadata = providerMetadata;
|
|
17625
|
+
} else {
|
|
17626
|
+
part.callProviderMetadata = providerMetadata;
|
|
17627
|
+
}
|
|
17383
17628
|
}
|
|
17384
17629
|
} else {
|
|
17385
17630
|
state.message.parts.push({
|
|
@@ -17393,7 +17638,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17393
17638
|
errorText: anyOptions.errorText,
|
|
17394
17639
|
providerExecuted: anyOptions.providerExecuted,
|
|
17395
17640
|
preliminary: anyOptions.preliminary,
|
|
17396
|
-
...anyOptions.providerMetadata != null ? {
|
|
17641
|
+
...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
|
|
17642
|
+
...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
17397
17643
|
});
|
|
17398
17644
|
}
|
|
17399
17645
|
}
|
|
@@ -17416,8 +17662,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17416
17662
|
anyPart.title = options.title;
|
|
17417
17663
|
}
|
|
17418
17664
|
anyPart.providerExecuted = (_b22 = anyOptions.providerExecuted) != null ? _b22 : part.providerExecuted;
|
|
17419
|
-
|
|
17420
|
-
|
|
17665
|
+
const providerMetadata = anyOptions.providerMetadata;
|
|
17666
|
+
if (providerMetadata != null) {
|
|
17667
|
+
if (options.state === "output-available" || options.state === "output-error") {
|
|
17668
|
+
const resultPart = part;
|
|
17669
|
+
resultPart.resultProviderMetadata = providerMetadata;
|
|
17670
|
+
} else {
|
|
17671
|
+
part.callProviderMetadata = providerMetadata;
|
|
17672
|
+
}
|
|
17421
17673
|
}
|
|
17422
17674
|
} else {
|
|
17423
17675
|
state.message.parts.push({
|
|
@@ -17431,7 +17683,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17431
17683
|
preliminary: anyOptions.preliminary,
|
|
17432
17684
|
providerExecuted: anyOptions.providerExecuted,
|
|
17433
17685
|
title: options.title,
|
|
17434
|
-
...anyOptions.providerMetadata != null ? {
|
|
17686
|
+
...anyOptions.providerMetadata != null && (options.state === "output-available" || options.state === "output-error") ? { resultProviderMetadata: anyOptions.providerMetadata } : {},
|
|
17687
|
+
...anyOptions.providerMetadata != null && !(options.state === "output-available" || options.state === "output-error") ? { callProviderMetadata: anyOptions.providerMetadata } : {}
|
|
17435
17688
|
});
|
|
17436
17689
|
}
|
|
17437
17690
|
}
|
|
@@ -17715,6 +17968,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17715
17968
|
output: chunk.output,
|
|
17716
17969
|
preliminary: chunk.preliminary,
|
|
17717
17970
|
providerExecuted: chunk.providerExecuted,
|
|
17971
|
+
providerMetadata: chunk.providerMetadata,
|
|
17718
17972
|
title: toolInvocation.title
|
|
17719
17973
|
});
|
|
17720
17974
|
} else {
|
|
@@ -17726,6 +17980,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17726
17980
|
output: chunk.output,
|
|
17727
17981
|
providerExecuted: chunk.providerExecuted,
|
|
17728
17982
|
preliminary: chunk.preliminary,
|
|
17983
|
+
providerMetadata: chunk.providerMetadata,
|
|
17729
17984
|
title: toolInvocation.title
|
|
17730
17985
|
});
|
|
17731
17986
|
}
|
|
@@ -17742,6 +17997,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17742
17997
|
input: toolInvocation.input,
|
|
17743
17998
|
errorText: chunk.errorText,
|
|
17744
17999
|
providerExecuted: chunk.providerExecuted,
|
|
18000
|
+
providerMetadata: chunk.providerMetadata,
|
|
17745
18001
|
title: toolInvocation.title
|
|
17746
18002
|
});
|
|
17747
18003
|
} else {
|
|
@@ -17753,6 +18009,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17753
18009
|
rawInput: toolInvocation.rawInput,
|
|
17754
18010
|
errorText: chunk.errorText,
|
|
17755
18011
|
providerExecuted: chunk.providerExecuted,
|
|
18012
|
+
providerMetadata: chunk.providerMetadata,
|
|
17756
18013
|
title: toolInvocation.title
|
|
17757
18014
|
});
|
|
17758
18015
|
}
|
|
@@ -18325,7 +18582,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18325
18582
|
input: toolInputs.get(chunk.toolCallId),
|
|
18326
18583
|
providerExecuted: true,
|
|
18327
18584
|
error: chunk.result,
|
|
18328
|
-
dynamic: chunk.dynamic
|
|
18585
|
+
dynamic: chunk.dynamic,
|
|
18586
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
18329
18587
|
});
|
|
18330
18588
|
} else {
|
|
18331
18589
|
controller.enqueue({
|
|
@@ -18335,7 +18593,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18335
18593
|
input: toolInputs.get(chunk.toolCallId),
|
|
18336
18594
|
output: chunk.result,
|
|
18337
18595
|
providerExecuted: true,
|
|
18338
|
-
dynamic: chunk.dynamic
|
|
18596
|
+
dynamic: chunk.dynamic,
|
|
18597
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
18339
18598
|
});
|
|
18340
18599
|
}
|
|
18341
18600
|
break;
|
|
@@ -18758,6 +19017,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18758
19017
|
}
|
|
18759
19018
|
},
|
|
18760
19019
|
async flush(controller) {
|
|
19020
|
+
var _a21, _b9, _c, _d, _e, _f, _g;
|
|
18761
19021
|
try {
|
|
18762
19022
|
if (recordedSteps.length === 0) {
|
|
18763
19023
|
const error = (abortSignal == null ? void 0 : abortSignal.aborted) ? abortSignal.reason : new NoOutputGeneratedError({
|
|
@@ -18821,18 +19081,23 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18821
19081
|
},
|
|
18822
19082
|
"ai.response.toolCalls": {
|
|
18823
19083
|
output: () => {
|
|
18824
|
-
var
|
|
18825
|
-
return ((
|
|
19084
|
+
var _a22;
|
|
19085
|
+
return ((_a22 = finalStep.toolCalls) == null ? void 0 : _a22.length) ? JSON.stringify(finalStep.toolCalls) : void 0;
|
|
18826
19086
|
}
|
|
18827
19087
|
},
|
|
18828
19088
|
"ai.response.providerMetadata": JSON.stringify(
|
|
18829
19089
|
finalStep.providerMetadata
|
|
18830
19090
|
),
|
|
18831
19091
|
"ai.usage.inputTokens": totalUsage.inputTokens,
|
|
19092
|
+
"ai.usage.inputTokenDetails.noCacheTokens": (_a21 = totalUsage.inputTokenDetails) == null ? void 0 : _a21.noCacheTokens,
|
|
19093
|
+
"ai.usage.inputTokenDetails.cacheReadTokens": (_b9 = totalUsage.inputTokenDetails) == null ? void 0 : _b9.cacheReadTokens,
|
|
19094
|
+
"ai.usage.inputTokenDetails.cacheWriteTokens": (_c = totalUsage.inputTokenDetails) == null ? void 0 : _c.cacheWriteTokens,
|
|
18832
19095
|
"ai.usage.outputTokens": totalUsage.outputTokens,
|
|
19096
|
+
"ai.usage.outputTokenDetails.textTokens": (_d = totalUsage.outputTokenDetails) == null ? void 0 : _d.textTokens,
|
|
19097
|
+
"ai.usage.outputTokenDetails.reasoningTokens": (_e = totalUsage.outputTokenDetails) == null ? void 0 : _e.reasoningTokens,
|
|
18833
19098
|
"ai.usage.totalTokens": totalUsage.totalTokens,
|
|
18834
|
-
"ai.usage.reasoningTokens": totalUsage.reasoningTokens,
|
|
18835
|
-
"ai.usage.cachedInputTokens": totalUsage.
|
|
19099
|
+
"ai.usage.reasoningTokens": (_f = totalUsage.outputTokenDetails) == null ? void 0 : _f.reasoningTokens,
|
|
19100
|
+
"ai.usage.cachedInputTokens": (_g = totalUsage.inputTokenDetails) == null ? void 0 : _g.cacheReadTokens
|
|
18836
19101
|
}
|
|
18837
19102
|
})
|
|
18838
19103
|
);
|
|
@@ -19444,6 +19709,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19444
19709
|
},
|
|
19445
19710
|
// invoke onFinish callback and resolve toolResults promise when the stream is about to close:
|
|
19446
19711
|
async flush(controller) {
|
|
19712
|
+
var _a22, _b22, _c2, _d2, _e2, _f2, _g2;
|
|
19447
19713
|
const stepToolCallsJson = stepToolCalls.length > 0 ? JSON.stringify(stepToolCalls) : void 0;
|
|
19448
19714
|
try {
|
|
19449
19715
|
doStreamSpan.setAttributes(
|
|
@@ -19451,29 +19717,22 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19451
19717
|
telemetry,
|
|
19452
19718
|
attributes: {
|
|
19453
19719
|
"ai.response.finishReason": stepFinishReason,
|
|
19454
|
-
"ai.response.text": {
|
|
19455
|
-
output: () => activeText
|
|
19456
|
-
},
|
|
19457
|
-
"ai.response.reasoning": {
|
|
19458
|
-
output: () => {
|
|
19459
|
-
const reasoningParts = recordedContent.filter(
|
|
19460
|
-
(c) => c.type === "reasoning"
|
|
19461
|
-
);
|
|
19462
|
-
return reasoningParts.length > 0 ? reasoningParts.map((r) => r.text).join("\n") : void 0;
|
|
19463
|
-
}
|
|
19464
|
-
},
|
|
19465
19720
|
"ai.response.toolCalls": {
|
|
19466
19721
|
output: () => stepToolCallsJson
|
|
19467
19722
|
},
|
|
19468
19723
|
"ai.response.id": stepResponse.id,
|
|
19469
19724
|
"ai.response.model": stepResponse.modelId,
|
|
19470
19725
|
"ai.response.timestamp": stepResponse.timestamp.toISOString(),
|
|
19471
|
-
"ai.response.providerMetadata": JSON.stringify(stepProviderMetadata),
|
|
19472
19726
|
"ai.usage.inputTokens": stepUsage.inputTokens,
|
|
19727
|
+
"ai.usage.inputTokenDetails.noCacheTokens": (_a22 = stepUsage.inputTokenDetails) == null ? void 0 : _a22.noCacheTokens,
|
|
19728
|
+
"ai.usage.inputTokenDetails.cacheReadTokens": (_b22 = stepUsage.inputTokenDetails) == null ? void 0 : _b22.cacheReadTokens,
|
|
19729
|
+
"ai.usage.inputTokenDetails.cacheWriteTokens": (_c2 = stepUsage.inputTokenDetails) == null ? void 0 : _c2.cacheWriteTokens,
|
|
19473
19730
|
"ai.usage.outputTokens": stepUsage.outputTokens,
|
|
19731
|
+
"ai.usage.outputTokenDetails.textTokens": (_d2 = stepUsage.outputTokenDetails) == null ? void 0 : _d2.textTokens,
|
|
19732
|
+
"ai.usage.outputTokenDetails.reasoningTokens": (_e2 = stepUsage.outputTokenDetails) == null ? void 0 : _e2.reasoningTokens,
|
|
19474
19733
|
"ai.usage.totalTokens": stepUsage.totalTokens,
|
|
19475
|
-
"ai.usage.reasoningTokens": stepUsage.reasoningTokens,
|
|
19476
|
-
"ai.usage.cachedInputTokens": stepUsage.
|
|
19734
|
+
"ai.usage.reasoningTokens": (_f2 = stepUsage.outputTokenDetails) == null ? void 0 : _f2.reasoningTokens,
|
|
19735
|
+
"ai.usage.cachedInputTokens": (_g2 = stepUsage.inputTokenDetails) == null ? void 0 : _g2.cacheReadTokens,
|
|
19477
19736
|
// standardized gen-ai llm span attributes:
|
|
19478
19737
|
"gen_ai.response.finish_reasons": [
|
|
19479
19738
|
stepFinishReason
|
|
@@ -19486,8 +19745,6 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19486
19745
|
})
|
|
19487
19746
|
);
|
|
19488
19747
|
} catch (error) {
|
|
19489
|
-
} finally {
|
|
19490
|
-
doStreamSpan.end();
|
|
19491
19748
|
}
|
|
19492
19749
|
controller.enqueue({
|
|
19493
19750
|
type: "finish-step",
|
|
@@ -19505,6 +19762,28 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19505
19762
|
stepUsage
|
|
19506
19763
|
);
|
|
19507
19764
|
await stepFinish.promise;
|
|
19765
|
+
const processedStep = recordedSteps[recordedSteps.length - 1];
|
|
19766
|
+
try {
|
|
19767
|
+
doStreamSpan.setAttributes(
|
|
19768
|
+
await selectTelemetryAttributes({
|
|
19769
|
+
telemetry,
|
|
19770
|
+
attributes: {
|
|
19771
|
+
"ai.response.text": {
|
|
19772
|
+
output: () => processedStep.text
|
|
19773
|
+
},
|
|
19774
|
+
"ai.response.reasoning": {
|
|
19775
|
+
output: () => processedStep.reasoningText
|
|
19776
|
+
},
|
|
19777
|
+
"ai.response.providerMetadata": JSON.stringify(
|
|
19778
|
+
processedStep.providerMetadata
|
|
19779
|
+
)
|
|
19780
|
+
}
|
|
19781
|
+
})
|
|
19782
|
+
);
|
|
19783
|
+
} catch (error) {
|
|
19784
|
+
} finally {
|
|
19785
|
+
doStreamSpan.end();
|
|
19786
|
+
}
|
|
19508
19787
|
const clientToolCalls = stepToolCalls.filter(
|
|
19509
19788
|
(toolCall) => toolCall.providerExecuted !== true
|
|
19510
19789
|
);
|
|
@@ -19935,6 +20214,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19935
20214
|
toolCallId: part.toolCallId,
|
|
19936
20215
|
output: part.output,
|
|
19937
20216
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
20217
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
19938
20218
|
...part.preliminary != null ? { preliminary: part.preliminary } : {},
|
|
19939
20219
|
...dynamic != null ? { dynamic } : {}
|
|
19940
20220
|
});
|
|
@@ -19945,8 +20225,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19945
20225
|
controller.enqueue({
|
|
19946
20226
|
type: "tool-output-error",
|
|
19947
20227
|
toolCallId: part.toolCallId,
|
|
19948
|
-
errorText: onError(part.error),
|
|
20228
|
+
errorText: part.providerExecuted ? typeof part.error === "string" ? part.error : JSON.stringify(part.error) : onError(part.error),
|
|
19949
20229
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
20230
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
19950
20231
|
...dynamic != null ? { dynamic } : {}
|
|
19951
20232
|
});
|
|
19952
20233
|
break;
|
|
@@ -20158,9 +20439,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
20158
20439
|
return AISDKError$1.hasMarker(error, marker$1);
|
|
20159
20440
|
}
|
|
20160
20441
|
};
|
|
20161
|
-
var LATEST_PROTOCOL_VERSION$1 = "2025-
|
|
20442
|
+
var LATEST_PROTOCOL_VERSION$1 = "2025-11-25";
|
|
20162
20443
|
var SUPPORTED_PROTOCOL_VERSIONS$1 = [
|
|
20163
20444
|
LATEST_PROTOCOL_VERSION$1,
|
|
20445
|
+
"2025-06-18",
|
|
20164
20446
|
"2025-03-26",
|
|
20165
20447
|
"2024-11-05"
|
|
20166
20448
|
];
|
|
@@ -21015,6 +21297,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21015
21297
|
async function authInternal$1(provider, {
|
|
21016
21298
|
serverUrl,
|
|
21017
21299
|
authorizationCode,
|
|
21300
|
+
callbackState,
|
|
21018
21301
|
scope: scope2,
|
|
21019
21302
|
resourceMetadataUrl,
|
|
21020
21303
|
fetchFn
|
|
@@ -21067,6 +21350,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21067
21350
|
clientInformation = fullInformation;
|
|
21068
21351
|
}
|
|
21069
21352
|
if (authorizationCode !== void 0) {
|
|
21353
|
+
if (provider.storedState) {
|
|
21354
|
+
const expectedState = await provider.storedState();
|
|
21355
|
+
if (expectedState !== void 0 && expectedState !== callbackState) {
|
|
21356
|
+
throw new Error(
|
|
21357
|
+
"OAuth state parameter mismatch - possible CSRF attack"
|
|
21358
|
+
);
|
|
21359
|
+
}
|
|
21360
|
+
}
|
|
21070
21361
|
const codeVerifier2 = await provider.codeVerifier();
|
|
21071
21362
|
const tokens2 = await exchangeAuthorization(authorizationServerUrl, {
|
|
21072
21363
|
metadata: metadata2,
|
|
@@ -21105,6 +21396,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21105
21396
|
}
|
|
21106
21397
|
}
|
|
21107
21398
|
const state = provider.state ? await provider.state() : void 0;
|
|
21399
|
+
if (state && provider.saveState) {
|
|
21400
|
+
await provider.saveState(state);
|
|
21401
|
+
}
|
|
21108
21402
|
const { authorizationUrl, codeVerifier } = await startAuthorization$1(
|
|
21109
21403
|
authorizationServerUrl,
|
|
21110
21404
|
{
|
|
@@ -21124,12 +21418,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21124
21418
|
constructor({
|
|
21125
21419
|
url: url2,
|
|
21126
21420
|
headers,
|
|
21127
|
-
authProvider
|
|
21421
|
+
authProvider,
|
|
21422
|
+
redirect = "follow"
|
|
21128
21423
|
}) {
|
|
21129
21424
|
this.connected = false;
|
|
21130
21425
|
this.url = new URL(url2);
|
|
21131
21426
|
this.headers = headers;
|
|
21132
21427
|
this.authProvider = authProvider;
|
|
21428
|
+
this.redirectMode = redirect;
|
|
21133
21429
|
}
|
|
21134
21430
|
async commonHeaders(base) {
|
|
21135
21431
|
const headers = {
|
|
@@ -21163,7 +21459,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21163
21459
|
});
|
|
21164
21460
|
const response = await fetch(this.url.href, {
|
|
21165
21461
|
headers,
|
|
21166
|
-
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal
|
|
21462
|
+
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal,
|
|
21463
|
+
redirect: this.redirectMode
|
|
21167
21464
|
});
|
|
21168
21465
|
if (response.status === 401 && this.authProvider && !triedAuth) {
|
|
21169
21466
|
this.resourceMetadataUrl = extractResourceMetadataUrl(response);
|
|
@@ -21282,7 +21579,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21282
21579
|
method: "POST",
|
|
21283
21580
|
headers,
|
|
21284
21581
|
body: JSON.stringify(message),
|
|
21285
|
-
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal
|
|
21582
|
+
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal,
|
|
21583
|
+
redirect: this.redirectMode
|
|
21286
21584
|
};
|
|
21287
21585
|
const response = await fetch(endpoint, init);
|
|
21288
21586
|
if (response.status === 401 && this.authProvider && !triedAuth) {
|
|
@@ -21323,7 +21621,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21323
21621
|
constructor({
|
|
21324
21622
|
url: url2,
|
|
21325
21623
|
headers,
|
|
21326
|
-
authProvider
|
|
21624
|
+
authProvider,
|
|
21625
|
+
redirect = "follow"
|
|
21327
21626
|
}) {
|
|
21328
21627
|
this.inboundReconnectAttempts = 0;
|
|
21329
21628
|
this.reconnectionOptions = {
|
|
@@ -21335,6 +21634,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21335
21634
|
this.url = new URL(url2);
|
|
21336
21635
|
this.headers = headers;
|
|
21337
21636
|
this.authProvider = authProvider;
|
|
21637
|
+
this.redirectMode = redirect;
|
|
21338
21638
|
}
|
|
21339
21639
|
async commonHeaders(base) {
|
|
21340
21640
|
const headers = {
|
|
@@ -21375,7 +21675,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21375
21675
|
await fetch(this.url, {
|
|
21376
21676
|
method: "DELETE",
|
|
21377
21677
|
headers,
|
|
21378
|
-
signal: this.abortController.signal
|
|
21678
|
+
signal: this.abortController.signal,
|
|
21679
|
+
redirect: this.redirectMode
|
|
21379
21680
|
}).catch(() => void 0);
|
|
21380
21681
|
}
|
|
21381
21682
|
} catch (e) {
|
|
@@ -21395,7 +21696,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21395
21696
|
method: "POST",
|
|
21396
21697
|
headers,
|
|
21397
21698
|
body: JSON.stringify(message),
|
|
21398
|
-
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal
|
|
21699
|
+
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal,
|
|
21700
|
+
redirect: this.redirectMode
|
|
21399
21701
|
};
|
|
21400
21702
|
const response = await fetch(this.url, init);
|
|
21401
21703
|
const sessionId = response.headers.get("mcp-session-id");
|
|
@@ -21544,7 +21846,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
21544
21846
|
const response = await fetch(this.url.href, {
|
|
21545
21847
|
method: "GET",
|
|
21546
21848
|
headers,
|
|
21547
|
-
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal
|
|
21849
|
+
signal: (_a32 = this.abortController) == null ? void 0 : _a32.signal,
|
|
21850
|
+
redirect: this.redirectMode
|
|
21548
21851
|
});
|
|
21549
21852
|
const sessionId = response.headers.get("mcp-session-id");
|
|
21550
21853
|
if (sessionId) {
|
|
@@ -24856,6 +25159,462 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
24856
25159
|
});
|
|
24857
25160
|
}
|
|
24858
25161
|
}
|
|
25162
|
+
class ErrorEvent extends Event {
|
|
25163
|
+
/**
|
|
25164
|
+
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
|
25165
|
+
* but rather emitted by the `EventSource` object when an error occurs.
|
|
25166
|
+
*
|
|
25167
|
+
* @param type - The type of the event (should be "error")
|
|
25168
|
+
* @param errorEventInitDict - Optional properties to include in the error event
|
|
25169
|
+
*/
|
|
25170
|
+
constructor(type2, errorEventInitDict) {
|
|
25171
|
+
var _a10, _b9;
|
|
25172
|
+
super(type2), this.code = (_a10 = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a10 : void 0, this.message = (_b9 = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b9 : void 0;
|
|
25173
|
+
}
|
|
25174
|
+
/**
|
|
25175
|
+
* Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
|
25176
|
+
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
|
25177
|
+
* we explicitly include the properties in the `inspect` method.
|
|
25178
|
+
*
|
|
25179
|
+
* This is automatically called by Node.js when you `console.log` an instance of this class.
|
|
25180
|
+
*
|
|
25181
|
+
* @param _depth - The current depth
|
|
25182
|
+
* @param options - The options passed to `util.inspect`
|
|
25183
|
+
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
|
25184
|
+
* @returns A string representation of the error
|
|
25185
|
+
*/
|
|
25186
|
+
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
|
25187
|
+
return inspect(inspectableError(this), options);
|
|
25188
|
+
}
|
|
25189
|
+
/**
|
|
25190
|
+
* Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
|
25191
|
+
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
|
25192
|
+
* we explicitly include the properties in the `inspect` method.
|
|
25193
|
+
*
|
|
25194
|
+
* This is automatically called by Deno when you `console.log` an instance of this class.
|
|
25195
|
+
*
|
|
25196
|
+
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
|
25197
|
+
* @param options - The options passed to `Deno.inspect`
|
|
25198
|
+
* @returns A string representation of the error
|
|
25199
|
+
*/
|
|
25200
|
+
[Symbol.for("Deno.customInspect")](inspect, options) {
|
|
25201
|
+
return inspect(inspectableError(this), options);
|
|
25202
|
+
}
|
|
25203
|
+
}
|
|
25204
|
+
function syntaxError(message) {
|
|
25205
|
+
const DomException = globalThis.DOMException;
|
|
25206
|
+
return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);
|
|
25207
|
+
}
|
|
25208
|
+
function flattenError(err) {
|
|
25209
|
+
return err instanceof Error ? "errors" in err && Array.isArray(err.errors) ? err.errors.map(flattenError).join(", ") : "cause" in err && err.cause instanceof Error ? `${err}: ${flattenError(err.cause)}` : err.message : `${err}`;
|
|
25210
|
+
}
|
|
25211
|
+
function inspectableError(err) {
|
|
25212
|
+
return {
|
|
25213
|
+
type: err.type,
|
|
25214
|
+
message: err.message,
|
|
25215
|
+
code: err.code,
|
|
25216
|
+
defaultPrevented: err.defaultPrevented,
|
|
25217
|
+
cancelable: err.cancelable,
|
|
25218
|
+
timeStamp: err.timeStamp
|
|
25219
|
+
};
|
|
25220
|
+
}
|
|
25221
|
+
var __typeError = (msg) => {
|
|
25222
|
+
throw TypeError(msg);
|
|
25223
|
+
}, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method), _readyState, _url, _redirectUrl, _withCredentials, _fetch, _reconnectInterval, _reconnectTimer, _lastEventId, _controller, _parser, _onError, _onMessage, _onOpen, _EventSource_instances, connect_fn, _onFetchResponse, _onFetchError, getRequestOptions_fn, _onEvent, _onRetryChange, failConnection_fn, scheduleReconnect_fn, _reconnect;
|
|
25224
|
+
class EventSource extends EventTarget {
|
|
25225
|
+
constructor(url2, eventSourceInitDict) {
|
|
25226
|
+
var _a10, _b9;
|
|
25227
|
+
super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
|
|
25228
|
+
var _a22;
|
|
25229
|
+
__privateGet(this, _parser).reset();
|
|
25230
|
+
const { body, redirected, status, headers } = response;
|
|
25231
|
+
if (status === 204) {
|
|
25232
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
25233
|
+
return;
|
|
25234
|
+
}
|
|
25235
|
+
if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
|
|
25236
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
|
|
25237
|
+
return;
|
|
25238
|
+
}
|
|
25239
|
+
if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
|
|
25240
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
|
|
25241
|
+
return;
|
|
25242
|
+
}
|
|
25243
|
+
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
25244
|
+
return;
|
|
25245
|
+
__privateSet(this, _readyState, this.OPEN);
|
|
25246
|
+
const openEvent = new Event("open");
|
|
25247
|
+
if ((_a22 = __privateGet(this, _onOpen)) == null || _a22.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
|
|
25248
|
+
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
|
25249
|
+
return;
|
|
25250
|
+
}
|
|
25251
|
+
const decoder = new TextDecoder(), reader = body.getReader();
|
|
25252
|
+
let open = true;
|
|
25253
|
+
do {
|
|
25254
|
+
const { done, value } = await reader.read();
|
|
25255
|
+
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
|
|
25256
|
+
} while (open);
|
|
25257
|
+
}), __privateAdd(this, _onFetchError, (err) => {
|
|
25258
|
+
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
|
|
25259
|
+
}), __privateAdd(this, _onEvent, (event) => {
|
|
25260
|
+
typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
|
|
25261
|
+
const messageEvent = new MessageEvent(event.event || "message", {
|
|
25262
|
+
data: event.data,
|
|
25263
|
+
origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,
|
|
25264
|
+
lastEventId: event.id || ""
|
|
25265
|
+
});
|
|
25266
|
+
__privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
|
|
25267
|
+
}), __privateAdd(this, _onRetryChange, (value) => {
|
|
25268
|
+
__privateSet(this, _reconnectInterval, value);
|
|
25269
|
+
}), __privateAdd(this, _reconnect, () => {
|
|
25270
|
+
__privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
25271
|
+
});
|
|
25272
|
+
try {
|
|
25273
|
+
if (url2 instanceof URL)
|
|
25274
|
+
__privateSet(this, _url, url2);
|
|
25275
|
+
else if (typeof url2 == "string")
|
|
25276
|
+
__privateSet(this, _url, new URL(url2, getBaseURL()));
|
|
25277
|
+
else
|
|
25278
|
+
throw new Error("Invalid URL");
|
|
25279
|
+
} catch {
|
|
25280
|
+
throw syntaxError("An invalid or illegal string was specified");
|
|
25281
|
+
}
|
|
25282
|
+
__privateSet(this, _parser, createParser({
|
|
25283
|
+
onEvent: __privateGet(this, _onEvent),
|
|
25284
|
+
onRetry: __privateGet(this, _onRetryChange)
|
|
25285
|
+
})), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a10 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a10 : globalThis.fetch), __privateSet(this, _withCredentials, (_b9 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b9 : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
25286
|
+
}
|
|
25287
|
+
/**
|
|
25288
|
+
* Returns the state of this EventSource object's connection. It can have the values described below.
|
|
25289
|
+
*
|
|
25290
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
25291
|
+
*
|
|
25292
|
+
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
|
25293
|
+
* defined in the TypeScript `dom` library.
|
|
25294
|
+
*
|
|
25295
|
+
* @public
|
|
25296
|
+
*/
|
|
25297
|
+
get readyState() {
|
|
25298
|
+
return __privateGet(this, _readyState);
|
|
25299
|
+
}
|
|
25300
|
+
/**
|
|
25301
|
+
* Returns the URL providing the event stream.
|
|
25302
|
+
*
|
|
25303
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
25304
|
+
*
|
|
25305
|
+
* @public
|
|
25306
|
+
*/
|
|
25307
|
+
get url() {
|
|
25308
|
+
return __privateGet(this, _url).href;
|
|
25309
|
+
}
|
|
25310
|
+
/**
|
|
25311
|
+
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
|
25312
|
+
*
|
|
25313
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
25314
|
+
*/
|
|
25315
|
+
get withCredentials() {
|
|
25316
|
+
return __privateGet(this, _withCredentials);
|
|
25317
|
+
}
|
|
25318
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
25319
|
+
get onerror() {
|
|
25320
|
+
return __privateGet(this, _onError);
|
|
25321
|
+
}
|
|
25322
|
+
set onerror(value) {
|
|
25323
|
+
__privateSet(this, _onError, value);
|
|
25324
|
+
}
|
|
25325
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
25326
|
+
get onmessage() {
|
|
25327
|
+
return __privateGet(this, _onMessage);
|
|
25328
|
+
}
|
|
25329
|
+
set onmessage(value) {
|
|
25330
|
+
__privateSet(this, _onMessage, value);
|
|
25331
|
+
}
|
|
25332
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
25333
|
+
get onopen() {
|
|
25334
|
+
return __privateGet(this, _onOpen);
|
|
25335
|
+
}
|
|
25336
|
+
set onopen(value) {
|
|
25337
|
+
__privateSet(this, _onOpen, value);
|
|
25338
|
+
}
|
|
25339
|
+
addEventListener(type2, listener, options) {
|
|
25340
|
+
const listen = listener;
|
|
25341
|
+
super.addEventListener(type2, listen, options);
|
|
25342
|
+
}
|
|
25343
|
+
removeEventListener(type2, listener, options) {
|
|
25344
|
+
const listen = listener;
|
|
25345
|
+
super.removeEventListener(type2, listen, options);
|
|
25346
|
+
}
|
|
25347
|
+
/**
|
|
25348
|
+
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
25349
|
+
*
|
|
25350
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
25351
|
+
*
|
|
25352
|
+
* @public
|
|
25353
|
+
*/
|
|
25354
|
+
close() {
|
|
25355
|
+
__privateGet(this, _reconnectTimer) && clearTimeout(__privateGet(this, _reconnectTimer)), __privateGet(this, _readyState) !== this.CLOSED && (__privateGet(this, _controller) && __privateGet(this, _controller).abort(), __privateSet(this, _readyState, this.CLOSED), __privateSet(this, _controller, void 0));
|
|
25356
|
+
}
|
|
25357
|
+
}
|
|
25358
|
+
_readyState = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _redirectUrl = /* @__PURE__ */ new WeakMap(), _withCredentials = /* @__PURE__ */ new WeakMap(), _fetch = /* @__PURE__ */ new WeakMap(), _reconnectInterval = /* @__PURE__ */ new WeakMap(), _reconnectTimer = /* @__PURE__ */ new WeakMap(), _lastEventId = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _parser = /* @__PURE__ */ new WeakMap(), _onError = /* @__PURE__ */ new WeakMap(), _onMessage = /* @__PURE__ */ new WeakMap(), _onOpen = /* @__PURE__ */ new WeakMap(), _EventSource_instances = /* @__PURE__ */ new WeakSet(), /**
|
|
25359
|
+
* Connect to the given URL and start receiving events
|
|
25360
|
+
*
|
|
25361
|
+
* @internal
|
|
25362
|
+
*/
|
|
25363
|
+
connect_fn = function() {
|
|
25364
|
+
__privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _controller, new AbortController()), __privateGet(this, _fetch)(__privateGet(this, _url), __privateMethod(this, _EventSource_instances, getRequestOptions_fn).call(this)).then(__privateGet(this, _onFetchResponse)).catch(__privateGet(this, _onFetchError));
|
|
25365
|
+
}, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
|
|
25366
|
+
* Get request options for the `fetch()` request
|
|
25367
|
+
*
|
|
25368
|
+
* @returns The request options
|
|
25369
|
+
* @internal
|
|
25370
|
+
*/
|
|
25371
|
+
getRequestOptions_fn = function() {
|
|
25372
|
+
var _a10;
|
|
25373
|
+
const init = {
|
|
25374
|
+
// [spec] Let `corsAttributeState` be `Anonymous`…
|
|
25375
|
+
// [spec] …will have their mode set to "cors"…
|
|
25376
|
+
mode: "cors",
|
|
25377
|
+
redirect: "follow",
|
|
25378
|
+
headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
|
|
25379
|
+
cache: "no-store",
|
|
25380
|
+
signal: (_a10 = __privateGet(this, _controller)) == null ? void 0 : _a10.signal
|
|
25381
|
+
};
|
|
25382
|
+
return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
|
|
25383
|
+
}, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
|
|
25384
|
+
* Handles the process referred to in the EventSource specification as "failing a connection".
|
|
25385
|
+
*
|
|
25386
|
+
* @param error - The error causing the connection to fail
|
|
25387
|
+
* @param code - The HTTP status code, if available
|
|
25388
|
+
* @internal
|
|
25389
|
+
*/
|
|
25390
|
+
failConnection_fn = function(message, code2) {
|
|
25391
|
+
var _a10;
|
|
25392
|
+
__privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
|
|
25393
|
+
const errorEvent = new ErrorEvent("error", { code: code2, message });
|
|
25394
|
+
(_a10 = __privateGet(this, _onError)) == null || _a10.call(this, errorEvent), this.dispatchEvent(errorEvent);
|
|
25395
|
+
}, /**
|
|
25396
|
+
* Schedules a reconnection attempt against the EventSource endpoint.
|
|
25397
|
+
*
|
|
25398
|
+
* @param message - The error causing the connection to fail
|
|
25399
|
+
* @param code - The HTTP status code, if available
|
|
25400
|
+
* @internal
|
|
25401
|
+
*/
|
|
25402
|
+
scheduleReconnect_fn = function(message, code2) {
|
|
25403
|
+
var _a10;
|
|
25404
|
+
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
25405
|
+
return;
|
|
25406
|
+
__privateSet(this, _readyState, this.CONNECTING);
|
|
25407
|
+
const errorEvent = new ErrorEvent("error", { code: code2, message });
|
|
25408
|
+
(_a10 = __privateGet(this, _onError)) == null || _a10.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
|
|
25409
|
+
}, _reconnect = /* @__PURE__ */ new WeakMap(), /**
|
|
25410
|
+
* ReadyState representing an EventSource currently trying to connect
|
|
25411
|
+
*
|
|
25412
|
+
* @public
|
|
25413
|
+
*/
|
|
25414
|
+
EventSource.CONNECTING = 0, /**
|
|
25415
|
+
* ReadyState representing an EventSource connection that is open (eg connected)
|
|
25416
|
+
*
|
|
25417
|
+
* @public
|
|
25418
|
+
*/
|
|
25419
|
+
EventSource.OPEN = 1, /**
|
|
25420
|
+
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
|
25421
|
+
*
|
|
25422
|
+
* @public
|
|
25423
|
+
*/
|
|
25424
|
+
EventSource.CLOSED = 2;
|
|
25425
|
+
function getBaseURL() {
|
|
25426
|
+
const doc = "document" in globalThis ? globalThis.document : void 0;
|
|
25427
|
+
return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
|
|
25428
|
+
}
|
|
25429
|
+
class SseError extends Error {
|
|
25430
|
+
constructor(code2, message, event) {
|
|
25431
|
+
super(`SSE error: ${message}`);
|
|
25432
|
+
this.code = code2;
|
|
25433
|
+
this.event = event;
|
|
25434
|
+
}
|
|
25435
|
+
}
|
|
25436
|
+
class SSEClientTransport {
|
|
25437
|
+
constructor(url2, opts) {
|
|
25438
|
+
this._url = url2;
|
|
25439
|
+
this._resourceMetadataUrl = void 0;
|
|
25440
|
+
this._scope = void 0;
|
|
25441
|
+
this._eventSourceInit = opts?.eventSourceInit;
|
|
25442
|
+
this._requestInit = opts?.requestInit;
|
|
25443
|
+
this._authProvider = opts?.authProvider;
|
|
25444
|
+
this._fetch = opts?.fetch;
|
|
25445
|
+
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
25446
|
+
}
|
|
25447
|
+
async _authThenStart() {
|
|
25448
|
+
if (!this._authProvider) {
|
|
25449
|
+
throw new UnauthorizedError("No auth provider");
|
|
25450
|
+
}
|
|
25451
|
+
let result;
|
|
25452
|
+
try {
|
|
25453
|
+
result = await auth(this._authProvider, {
|
|
25454
|
+
serverUrl: this._url,
|
|
25455
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
25456
|
+
scope: this._scope,
|
|
25457
|
+
fetchFn: this._fetchWithInit
|
|
25458
|
+
});
|
|
25459
|
+
} catch (error) {
|
|
25460
|
+
this.onerror?.(error);
|
|
25461
|
+
throw error;
|
|
25462
|
+
}
|
|
25463
|
+
if (result !== "AUTHORIZED") {
|
|
25464
|
+
throw new UnauthorizedError();
|
|
25465
|
+
}
|
|
25466
|
+
return await this._startOrAuth();
|
|
25467
|
+
}
|
|
25468
|
+
async _commonHeaders() {
|
|
25469
|
+
const headers = {};
|
|
25470
|
+
if (this._authProvider) {
|
|
25471
|
+
const tokens = await this._authProvider.tokens();
|
|
25472
|
+
if (tokens) {
|
|
25473
|
+
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
25474
|
+
}
|
|
25475
|
+
}
|
|
25476
|
+
if (this._protocolVersion) {
|
|
25477
|
+
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
25478
|
+
}
|
|
25479
|
+
const extraHeaders = normalizeHeaders$1(this._requestInit?.headers);
|
|
25480
|
+
return new Headers({
|
|
25481
|
+
...headers,
|
|
25482
|
+
...extraHeaders
|
|
25483
|
+
});
|
|
25484
|
+
}
|
|
25485
|
+
_startOrAuth() {
|
|
25486
|
+
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
25487
|
+
return new Promise((resolve2, reject) => {
|
|
25488
|
+
this._eventSource = new EventSource(this._url.href, {
|
|
25489
|
+
...this._eventSourceInit,
|
|
25490
|
+
fetch: async (url2, init) => {
|
|
25491
|
+
const headers = await this._commonHeaders();
|
|
25492
|
+
headers.set("Accept", "text/event-stream");
|
|
25493
|
+
const response = await fetchImpl(url2, {
|
|
25494
|
+
...init,
|
|
25495
|
+
headers
|
|
25496
|
+
});
|
|
25497
|
+
if (response.status === 401 && response.headers.has("www-authenticate")) {
|
|
25498
|
+
const { resourceMetadataUrl, scope: scope2 } = extractWWWAuthenticateParams(response);
|
|
25499
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
25500
|
+
this._scope = scope2;
|
|
25501
|
+
}
|
|
25502
|
+
return response;
|
|
25503
|
+
}
|
|
25504
|
+
});
|
|
25505
|
+
this._abortController = new AbortController();
|
|
25506
|
+
this._eventSource.onerror = (event) => {
|
|
25507
|
+
if (event.code === 401 && this._authProvider) {
|
|
25508
|
+
this._authThenStart().then(resolve2, reject);
|
|
25509
|
+
return;
|
|
25510
|
+
}
|
|
25511
|
+
const error = new SseError(event.code, event.message, event);
|
|
25512
|
+
reject(error);
|
|
25513
|
+
this.onerror?.(error);
|
|
25514
|
+
};
|
|
25515
|
+
this._eventSource.onopen = () => {
|
|
25516
|
+
};
|
|
25517
|
+
this._eventSource.addEventListener("endpoint", (event) => {
|
|
25518
|
+
const messageEvent = event;
|
|
25519
|
+
try {
|
|
25520
|
+
this._endpoint = new URL(messageEvent.data, this._url);
|
|
25521
|
+
if (this._endpoint.origin !== this._url.origin) {
|
|
25522
|
+
throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
|
|
25523
|
+
}
|
|
25524
|
+
} catch (error) {
|
|
25525
|
+
reject(error);
|
|
25526
|
+
this.onerror?.(error);
|
|
25527
|
+
void this.close();
|
|
25528
|
+
return;
|
|
25529
|
+
}
|
|
25530
|
+
resolve2();
|
|
25531
|
+
});
|
|
25532
|
+
this._eventSource.onmessage = (event) => {
|
|
25533
|
+
const messageEvent = event;
|
|
25534
|
+
let message;
|
|
25535
|
+
try {
|
|
25536
|
+
message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
|
|
25537
|
+
} catch (error) {
|
|
25538
|
+
this.onerror?.(error);
|
|
25539
|
+
return;
|
|
25540
|
+
}
|
|
25541
|
+
this.onmessage?.(message);
|
|
25542
|
+
};
|
|
25543
|
+
});
|
|
25544
|
+
}
|
|
25545
|
+
async start() {
|
|
25546
|
+
if (this._eventSource) {
|
|
25547
|
+
throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
25548
|
+
}
|
|
25549
|
+
return await this._startOrAuth();
|
|
25550
|
+
}
|
|
25551
|
+
/**
|
|
25552
|
+
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
25553
|
+
*/
|
|
25554
|
+
async finishAuth(authorizationCode) {
|
|
25555
|
+
if (!this._authProvider) {
|
|
25556
|
+
throw new UnauthorizedError("No auth provider");
|
|
25557
|
+
}
|
|
25558
|
+
const result = await auth(this._authProvider, {
|
|
25559
|
+
serverUrl: this._url,
|
|
25560
|
+
authorizationCode,
|
|
25561
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
25562
|
+
scope: this._scope,
|
|
25563
|
+
fetchFn: this._fetchWithInit
|
|
25564
|
+
});
|
|
25565
|
+
if (result !== "AUTHORIZED") {
|
|
25566
|
+
throw new UnauthorizedError("Failed to authorize");
|
|
25567
|
+
}
|
|
25568
|
+
}
|
|
25569
|
+
async close() {
|
|
25570
|
+
this._abortController?.abort();
|
|
25571
|
+
this._eventSource?.close();
|
|
25572
|
+
this.onclose?.();
|
|
25573
|
+
}
|
|
25574
|
+
async send(message) {
|
|
25575
|
+
if (!this._endpoint) {
|
|
25576
|
+
throw new Error("Not connected");
|
|
25577
|
+
}
|
|
25578
|
+
try {
|
|
25579
|
+
const headers = await this._commonHeaders();
|
|
25580
|
+
headers.set("content-type", "application/json");
|
|
25581
|
+
const init = {
|
|
25582
|
+
...this._requestInit,
|
|
25583
|
+
method: "POST",
|
|
25584
|
+
headers,
|
|
25585
|
+
body: JSON.stringify(message),
|
|
25586
|
+
signal: this._abortController?.signal
|
|
25587
|
+
};
|
|
25588
|
+
const response = await (this._fetch ?? fetch)(this._endpoint, init);
|
|
25589
|
+
if (!response.ok) {
|
|
25590
|
+
const text2 = await response.text().catch(() => null);
|
|
25591
|
+
if (response.status === 401 && this._authProvider) {
|
|
25592
|
+
const { resourceMetadataUrl, scope: scope2 } = extractWWWAuthenticateParams(response);
|
|
25593
|
+
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
25594
|
+
this._scope = scope2;
|
|
25595
|
+
const result = await auth(this._authProvider, {
|
|
25596
|
+
serverUrl: this._url,
|
|
25597
|
+
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
25598
|
+
scope: this._scope,
|
|
25599
|
+
fetchFn: this._fetchWithInit
|
|
25600
|
+
});
|
|
25601
|
+
if (result !== "AUTHORIZED") {
|
|
25602
|
+
throw new UnauthorizedError();
|
|
25603
|
+
}
|
|
25604
|
+
return this.send(message);
|
|
25605
|
+
}
|
|
25606
|
+
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text2}`);
|
|
25607
|
+
}
|
|
25608
|
+
await response.body?.cancel();
|
|
25609
|
+
} catch (error) {
|
|
25610
|
+
this.onerror?.(error);
|
|
25611
|
+
throw error;
|
|
25612
|
+
}
|
|
25613
|
+
}
|
|
25614
|
+
setProtocolVersion(version2) {
|
|
25615
|
+
this._protocolVersion = version2;
|
|
25616
|
+
}
|
|
25617
|
+
}
|
|
24859
25618
|
class InMemoryTransport {
|
|
24860
25619
|
constructor() {
|
|
24861
25620
|
this._messageQueue = [];
|
|
@@ -24914,9 +25673,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
24914
25673
|
});
|
|
24915
25674
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
24916
25675
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
24917
|
-
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5
|
|
25676
|
+
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
24918
25677
|
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
24919
|
-
const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2");
|
|
25678
|
+
const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4");
|
|
24920
25679
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
24921
25680
|
return {
|
|
24922
25681
|
supportsFlexProcessing,
|
|
@@ -27037,6 +27796,36 @@ ${user}:`]
|
|
|
27037
27796
|
inputSchema: shellInputSchema,
|
|
27038
27797
|
outputSchema: shellOutputSchema
|
|
27039
27798
|
});
|
|
27799
|
+
var toolSearchArgsSchema = lazySchema(
|
|
27800
|
+
() => zodSchema(
|
|
27801
|
+
object$1({
|
|
27802
|
+
execution: _enum$1(["server", "client"]).optional(),
|
|
27803
|
+
description: string().optional(),
|
|
27804
|
+
parameters: record(string(), unknown()).optional()
|
|
27805
|
+
})
|
|
27806
|
+
)
|
|
27807
|
+
);
|
|
27808
|
+
var toolSearchInputSchema = lazySchema(
|
|
27809
|
+
() => zodSchema(
|
|
27810
|
+
object$1({
|
|
27811
|
+
arguments: unknown().optional(),
|
|
27812
|
+
call_id: string().nullish()
|
|
27813
|
+
})
|
|
27814
|
+
)
|
|
27815
|
+
);
|
|
27816
|
+
var toolSearchOutputSchema = lazySchema(
|
|
27817
|
+
() => zodSchema(
|
|
27818
|
+
object$1({
|
|
27819
|
+
tools: array$1(record(string(), unknown()))
|
|
27820
|
+
})
|
|
27821
|
+
)
|
|
27822
|
+
);
|
|
27823
|
+
var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
27824
|
+
id: "openai.tool_search",
|
|
27825
|
+
inputSchema: toolSearchInputSchema,
|
|
27826
|
+
outputSchema: toolSearchOutputSchema
|
|
27827
|
+
});
|
|
27828
|
+
var toolSearch = (args = {}) => toolSearchToolFactory(args);
|
|
27040
27829
|
var webSearchArgsSchema = lazySchema(
|
|
27041
27830
|
() => zodSchema(
|
|
27042
27831
|
object$1({
|
|
@@ -27293,7 +28082,17 @@ ${user}:`]
|
|
|
27293
28082
|
* @param serverDescription - Optional description of the server.
|
|
27294
28083
|
* @param serverUrl - URL for the MCP server.
|
|
27295
28084
|
*/
|
|
27296
|
-
mcp
|
|
28085
|
+
mcp,
|
|
28086
|
+
/**
|
|
28087
|
+
* Tool search allows the model to dynamically search for and load deferred
|
|
28088
|
+
* tools into the model's context as needed. This helps reduce overall token
|
|
28089
|
+
* usage, cost, and latency by only loading tools when the model needs them.
|
|
28090
|
+
*
|
|
28091
|
+
* To use tool search, mark functions or namespaces with `defer_loading: true`
|
|
28092
|
+
* in the tools array. The model will use tool search to load these tools
|
|
28093
|
+
* when it determines they are needed.
|
|
28094
|
+
*/
|
|
28095
|
+
toolSearch
|
|
27297
28096
|
};
|
|
27298
28097
|
function convertOpenAIResponsesUsage(usage) {
|
|
27299
28098
|
var _a10, _b9, _c, _d;
|
|
@@ -27349,8 +28148,8 @@ ${user}:`]
|
|
|
27349
28148
|
hasApplyPatchTool = false,
|
|
27350
28149
|
customProviderToolNames
|
|
27351
28150
|
}) {
|
|
27352
|
-
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
27353
|
-
|
|
28151
|
+
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
28152
|
+
let input = [];
|
|
27354
28153
|
const warnings = [];
|
|
27355
28154
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
27356
28155
|
for (const { role, content } of prompt) {
|
|
@@ -27453,6 +28252,32 @@ ${user}:`]
|
|
|
27453
28252
|
if (hasConversation && id2 != null) {
|
|
27454
28253
|
break;
|
|
27455
28254
|
}
|
|
28255
|
+
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
28256
|
+
part.toolName
|
|
28257
|
+
);
|
|
28258
|
+
if (resolvedToolName === "tool_search") {
|
|
28259
|
+
if (store && id2 != null) {
|
|
28260
|
+
input.push({ type: "item_reference", id: id2 });
|
|
28261
|
+
break;
|
|
28262
|
+
}
|
|
28263
|
+
const parsedInput = typeof part.input === "string" ? await parseJSON$1({
|
|
28264
|
+
text: part.input,
|
|
28265
|
+
schema: toolSearchInputSchema
|
|
28266
|
+
}) : await validateTypes$1({
|
|
28267
|
+
value: part.input,
|
|
28268
|
+
schema: toolSearchInputSchema
|
|
28269
|
+
});
|
|
28270
|
+
const execution = parsedInput.call_id != null ? "client" : "server";
|
|
28271
|
+
input.push({
|
|
28272
|
+
type: "tool_search_call",
|
|
28273
|
+
id: id2 != null ? id2 : part.toolCallId,
|
|
28274
|
+
execution,
|
|
28275
|
+
call_id: (_g = parsedInput.call_id) != null ? _g : null,
|
|
28276
|
+
status: "completed",
|
|
28277
|
+
arguments: parsedInput.arguments
|
|
28278
|
+
});
|
|
28279
|
+
break;
|
|
28280
|
+
}
|
|
27456
28281
|
if (part.providerExecuted) {
|
|
27457
28282
|
if (store && id2 != null) {
|
|
27458
28283
|
input.push({ type: "item_reference", id: id2 });
|
|
@@ -27463,9 +28288,6 @@ ${user}:`]
|
|
|
27463
28288
|
input.push({ type: "item_reference", id: id2 });
|
|
27464
28289
|
break;
|
|
27465
28290
|
}
|
|
27466
|
-
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
27467
|
-
part.toolName
|
|
27468
|
-
);
|
|
27469
28291
|
if (hasLocalShellTool && resolvedToolName === "local_shell") {
|
|
27470
28292
|
const parsedInput = await validateTypes$1({
|
|
27471
28293
|
value: part.input,
|
|
@@ -27548,6 +28370,26 @@ ${user}:`]
|
|
|
27548
28370
|
const resolvedResultToolName = toolNameMapping.toProviderToolName(
|
|
27549
28371
|
part.toolName
|
|
27550
28372
|
);
|
|
28373
|
+
if (resolvedResultToolName === "tool_search") {
|
|
28374
|
+
const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
28375
|
+
if (store) {
|
|
28376
|
+
input.push({ type: "item_reference", id: itemId });
|
|
28377
|
+
} else if (part.output.type === "json") {
|
|
28378
|
+
const parsedOutput = await validateTypes$1({
|
|
28379
|
+
value: part.output.value,
|
|
28380
|
+
schema: toolSearchOutputSchema
|
|
28381
|
+
});
|
|
28382
|
+
input.push({
|
|
28383
|
+
type: "tool_search_output",
|
|
28384
|
+
id: itemId,
|
|
28385
|
+
execution: "server",
|
|
28386
|
+
call_id: null,
|
|
28387
|
+
status: "completed",
|
|
28388
|
+
tools: parsedOutput.tools
|
|
28389
|
+
});
|
|
28390
|
+
}
|
|
28391
|
+
break;
|
|
28392
|
+
}
|
|
27551
28393
|
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
27552
28394
|
if (part.output.type === "json") {
|
|
27553
28395
|
const parsedOutput = await validateTypes$1({
|
|
@@ -27570,7 +28412,7 @@ ${user}:`]
|
|
|
27570
28412
|
break;
|
|
27571
28413
|
}
|
|
27572
28414
|
if (store) {
|
|
27573
|
-
const itemId = (
|
|
28415
|
+
const itemId = (_m = (_l = (_k = part.providerOptions) == null ? void 0 : _k[providerOptionsName]) == null ? void 0 : _l.itemId) != null ? _m : part.toolCallId;
|
|
27574
28416
|
input.push({ type: "item_reference", id: itemId });
|
|
27575
28417
|
} else {
|
|
27576
28418
|
warnings.push({
|
|
@@ -27680,7 +28522,7 @@ ${user}:`]
|
|
|
27680
28522
|
}
|
|
27681
28523
|
const output = part.output;
|
|
27682
28524
|
if (output.type === "execution-denied") {
|
|
27683
|
-
const approvalId = (
|
|
28525
|
+
const approvalId = (_o = (_n = output.providerOptions) == null ? void 0 : _n.openai) == null ? void 0 : _o.approvalId;
|
|
27684
28526
|
if (approvalId) {
|
|
27685
28527
|
continue;
|
|
27686
28528
|
}
|
|
@@ -27688,6 +28530,20 @@ ${user}:`]
|
|
|
27688
28530
|
const resolvedToolName = toolNameMapping.toProviderToolName(
|
|
27689
28531
|
part.toolName
|
|
27690
28532
|
);
|
|
28533
|
+
if (resolvedToolName === "tool_search" && output.type === "json") {
|
|
28534
|
+
const parsedOutput = await validateTypes$1({
|
|
28535
|
+
value: output.value,
|
|
28536
|
+
schema: toolSearchOutputSchema
|
|
28537
|
+
});
|
|
28538
|
+
input.push({
|
|
28539
|
+
type: "tool_search_output",
|
|
28540
|
+
execution: "client",
|
|
28541
|
+
call_id: part.toolCallId,
|
|
28542
|
+
status: "completed",
|
|
28543
|
+
tools: parsedOutput.tools
|
|
28544
|
+
});
|
|
28545
|
+
continue;
|
|
28546
|
+
}
|
|
27691
28547
|
if (hasLocalShellTool && resolvedToolName === "local_shell" && output.type === "json") {
|
|
27692
28548
|
const parsedOutput = await validateTypes$1({
|
|
27693
28549
|
value: output.value,
|
|
@@ -27740,7 +28596,7 @@ ${user}:`]
|
|
|
27740
28596
|
outputValue = output.value;
|
|
27741
28597
|
break;
|
|
27742
28598
|
case "execution-denied":
|
|
27743
|
-
outputValue = (
|
|
28599
|
+
outputValue = (_p = output.reason) != null ? _p : "Tool execution denied.";
|
|
27744
28600
|
break;
|
|
27745
28601
|
case "json":
|
|
27746
28602
|
case "error-json":
|
|
@@ -27794,7 +28650,7 @@ ${user}:`]
|
|
|
27794
28650
|
contentValue = output.value;
|
|
27795
28651
|
break;
|
|
27796
28652
|
case "execution-denied":
|
|
27797
|
-
contentValue = (
|
|
28653
|
+
contentValue = (_q = output.reason) != null ? _q : "Tool execution denied.";
|
|
27798
28654
|
break;
|
|
27799
28655
|
case "json":
|
|
27800
28656
|
case "error-json":
|
|
@@ -27851,6 +28707,17 @@ ${user}:`]
|
|
|
27851
28707
|
}
|
|
27852
28708
|
}
|
|
27853
28709
|
}
|
|
28710
|
+
if (!store && input.some(
|
|
28711
|
+
(item) => "type" in item && item.type === "reasoning" && item.encrypted_content == null
|
|
28712
|
+
)) {
|
|
28713
|
+
warnings.push({
|
|
28714
|
+
type: "other",
|
|
28715
|
+
message: "Reasoning parts without encrypted content are not supported when store is false. Skipping reasoning parts."
|
|
28716
|
+
});
|
|
28717
|
+
input = input.filter(
|
|
28718
|
+
(item) => !("type" in item) || item.type !== "reasoning" || item.encrypted_content != null
|
|
28719
|
+
);
|
|
28720
|
+
}
|
|
27854
28721
|
return { input, warnings };
|
|
27855
28722
|
}
|
|
27856
28723
|
var openaiResponsesReasoningProviderOptionsSchema = object$1({
|
|
@@ -27873,6 +28740,16 @@ ${user}:`]
|
|
|
27873
28740
|
return hasFunctionCall ? "tool-calls" : "other";
|
|
27874
28741
|
}
|
|
27875
28742
|
}
|
|
28743
|
+
var jsonValueSchema2 = lazy(
|
|
28744
|
+
() => union([
|
|
28745
|
+
string(),
|
|
28746
|
+
number$1(),
|
|
28747
|
+
boolean(),
|
|
28748
|
+
_null(),
|
|
28749
|
+
array$1(jsonValueSchema2),
|
|
28750
|
+
record(string(), jsonValueSchema2.optional())
|
|
28751
|
+
])
|
|
28752
|
+
);
|
|
27876
28753
|
var openaiResponsesChunkSchema = lazySchema(
|
|
27877
28754
|
() => zodSchema(
|
|
27878
28755
|
union([
|
|
@@ -27906,6 +28783,23 @@ ${user}:`]
|
|
|
27906
28783
|
service_tier: string().nullish()
|
|
27907
28784
|
})
|
|
27908
28785
|
}),
|
|
28786
|
+
object$1({
|
|
28787
|
+
type: literal("response.failed"),
|
|
28788
|
+
response: object$1({
|
|
28789
|
+
error: object$1({
|
|
28790
|
+
code: string().nullish(),
|
|
28791
|
+
message: string()
|
|
28792
|
+
}).nullish(),
|
|
28793
|
+
incomplete_details: object$1({ reason: string() }).nullish(),
|
|
28794
|
+
usage: object$1({
|
|
28795
|
+
input_tokens: number$1(),
|
|
28796
|
+
input_tokens_details: object$1({ cached_tokens: number$1().nullish() }).nullish(),
|
|
28797
|
+
output_tokens: number$1(),
|
|
28798
|
+
output_tokens_details: object$1({ reasoning_tokens: number$1().nullish() }).nullish()
|
|
28799
|
+
}).nullish(),
|
|
28800
|
+
service_tier: string().nullish()
|
|
28801
|
+
})
|
|
28802
|
+
}),
|
|
27909
28803
|
object$1({
|
|
27910
28804
|
type: literal("response.created"),
|
|
27911
28805
|
response: object$1({
|
|
@@ -28037,213 +28931,245 @@ ${user}:`]
|
|
|
28037
28931
|
])
|
|
28038
28932
|
})
|
|
28039
28933
|
)
|
|
28040
|
-
})
|
|
28041
|
-
])
|
|
28042
|
-
}),
|
|
28043
|
-
object$1({
|
|
28044
|
-
type: literal("response.output_item.done"),
|
|
28045
|
-
output_index: number$1(),
|
|
28046
|
-
item: discriminatedUnion("type", [
|
|
28047
|
-
object$1({
|
|
28048
|
-
type: literal("message"),
|
|
28049
|
-
id: string(),
|
|
28050
|
-
phase: _enum$1(["commentary", "final_answer"]).nullish()
|
|
28051
|
-
}),
|
|
28052
|
-
object$1({
|
|
28053
|
-
type: literal("reasoning"),
|
|
28054
|
-
id: string(),
|
|
28055
|
-
encrypted_content: string().nullish()
|
|
28056
|
-
}),
|
|
28057
|
-
object$1({
|
|
28058
|
-
type: literal("function_call"),
|
|
28059
|
-
id: string(),
|
|
28060
|
-
call_id: string(),
|
|
28061
|
-
name: string(),
|
|
28062
|
-
arguments: string(),
|
|
28063
|
-
status: literal("completed")
|
|
28064
|
-
}),
|
|
28065
|
-
object$1({
|
|
28066
|
-
type: literal("custom_tool_call"),
|
|
28067
|
-
id: string(),
|
|
28068
|
-
call_id: string(),
|
|
28069
|
-
name: string(),
|
|
28070
|
-
input: string(),
|
|
28071
|
-
status: literal("completed")
|
|
28072
|
-
}),
|
|
28073
|
-
object$1({
|
|
28074
|
-
type: literal("code_interpreter_call"),
|
|
28075
|
-
id: string(),
|
|
28076
|
-
code: string().nullable(),
|
|
28077
|
-
container_id: string(),
|
|
28078
|
-
outputs: array$1(
|
|
28079
|
-
discriminatedUnion("type", [
|
|
28080
|
-
object$1({ type: literal("logs"), logs: string() }),
|
|
28081
|
-
object$1({ type: literal("image"), url: string() })
|
|
28082
|
-
])
|
|
28083
|
-
).nullable()
|
|
28084
|
-
}),
|
|
28085
|
-
object$1({
|
|
28086
|
-
type: literal("image_generation_call"),
|
|
28087
|
-
id: string(),
|
|
28088
|
-
result: string()
|
|
28089
|
-
}),
|
|
28090
|
-
object$1({
|
|
28091
|
-
type: literal("web_search_call"),
|
|
28092
|
-
id: string(),
|
|
28093
|
-
status: string(),
|
|
28094
|
-
action: discriminatedUnion("type", [
|
|
28095
|
-
object$1({
|
|
28096
|
-
type: literal("search"),
|
|
28097
|
-
query: string().nullish(),
|
|
28098
|
-
sources: array$1(
|
|
28099
|
-
discriminatedUnion("type", [
|
|
28100
|
-
object$1({ type: literal("url"), url: string() }),
|
|
28101
|
-
object$1({ type: literal("api"), name: string() })
|
|
28102
|
-
])
|
|
28103
|
-
).nullish()
|
|
28104
|
-
}),
|
|
28105
|
-
object$1({
|
|
28106
|
-
type: literal("open_page"),
|
|
28107
|
-
url: string().nullish()
|
|
28108
|
-
}),
|
|
28109
|
-
object$1({
|
|
28110
|
-
type: literal("find_in_page"),
|
|
28111
|
-
url: string().nullish(),
|
|
28112
|
-
pattern: string().nullish()
|
|
28113
|
-
})
|
|
28114
|
-
]).nullish()
|
|
28115
|
-
}),
|
|
28116
|
-
object$1({
|
|
28117
|
-
type: literal("file_search_call"),
|
|
28118
|
-
id: string(),
|
|
28119
|
-
queries: array$1(string()),
|
|
28120
|
-
results: array$1(
|
|
28121
|
-
object$1({
|
|
28122
|
-
attributes: record(
|
|
28123
|
-
string(),
|
|
28124
|
-
union([string(), number$1(), boolean()])
|
|
28125
|
-
),
|
|
28126
|
-
file_id: string(),
|
|
28127
|
-
filename: string(),
|
|
28128
|
-
score: number$1(),
|
|
28129
|
-
text: string()
|
|
28130
|
-
})
|
|
28131
|
-
).nullish()
|
|
28132
|
-
}),
|
|
28133
|
-
object$1({
|
|
28134
|
-
type: literal("local_shell_call"),
|
|
28135
|
-
id: string(),
|
|
28136
|
-
call_id: string(),
|
|
28137
|
-
action: object$1({
|
|
28138
|
-
type: literal("exec"),
|
|
28139
|
-
command: array$1(string()),
|
|
28140
|
-
timeout_ms: number$1().optional(),
|
|
28141
|
-
user: string().optional(),
|
|
28142
|
-
working_directory: string().optional(),
|
|
28143
|
-
env: record(string(), string()).optional()
|
|
28144
|
-
})
|
|
28145
|
-
}),
|
|
28146
|
-
object$1({
|
|
28147
|
-
type: literal("computer_call"),
|
|
28148
|
-
id: string(),
|
|
28149
|
-
status: literal("completed")
|
|
28150
|
-
}),
|
|
28151
|
-
object$1({
|
|
28152
|
-
type: literal("mcp_call"),
|
|
28153
|
-
id: string(),
|
|
28154
|
-
status: string(),
|
|
28155
|
-
arguments: string(),
|
|
28156
|
-
name: string(),
|
|
28157
|
-
server_label: string(),
|
|
28158
|
-
output: string().nullish(),
|
|
28159
|
-
error: union([
|
|
28160
|
-
string(),
|
|
28161
|
-
object$1({
|
|
28162
|
-
type: string().optional(),
|
|
28163
|
-
code: union([number$1(), string()]).optional(),
|
|
28164
|
-
message: string().optional()
|
|
28165
|
-
}).loose()
|
|
28166
|
-
]).nullish(),
|
|
28167
|
-
approval_request_id: string().nullish()
|
|
28168
|
-
}),
|
|
28169
|
-
object$1({
|
|
28170
|
-
type: literal("mcp_list_tools"),
|
|
28171
|
-
id: string(),
|
|
28172
|
-
server_label: string(),
|
|
28173
|
-
tools: array$1(
|
|
28174
|
-
object$1({
|
|
28175
|
-
name: string(),
|
|
28176
|
-
description: string().optional(),
|
|
28177
|
-
input_schema: any(),
|
|
28178
|
-
annotations: record(string(), unknown()).optional()
|
|
28179
|
-
})
|
|
28180
|
-
),
|
|
28181
|
-
error: union([
|
|
28182
|
-
string(),
|
|
28183
|
-
object$1({
|
|
28184
|
-
type: string().optional(),
|
|
28185
|
-
code: union([number$1(), string()]).optional(),
|
|
28186
|
-
message: string().optional()
|
|
28187
|
-
}).loose()
|
|
28188
|
-
]).optional()
|
|
28189
|
-
}),
|
|
28190
|
-
object$1({
|
|
28191
|
-
type: literal("mcp_approval_request"),
|
|
28192
|
-
id: string(),
|
|
28193
|
-
server_label: string(),
|
|
28194
|
-
name: string(),
|
|
28195
|
-
arguments: string(),
|
|
28196
|
-
approval_request_id: string().optional()
|
|
28197
|
-
}),
|
|
28198
|
-
object$1({
|
|
28199
|
-
type: literal("apply_patch_call"),
|
|
28200
|
-
id: string(),
|
|
28201
|
-
call_id: string(),
|
|
28202
|
-
status: _enum$1(["in_progress", "completed"]),
|
|
28203
|
-
operation: discriminatedUnion("type", [
|
|
28204
|
-
object$1({
|
|
28205
|
-
type: literal("create_file"),
|
|
28206
|
-
path: string(),
|
|
28207
|
-
diff: string()
|
|
28208
|
-
}),
|
|
28209
|
-
object$1({
|
|
28210
|
-
type: literal("delete_file"),
|
|
28211
|
-
path: string()
|
|
28212
|
-
}),
|
|
28213
|
-
object$1({
|
|
28214
|
-
type: literal("update_file"),
|
|
28215
|
-
path: string(),
|
|
28216
|
-
diff: string()
|
|
28217
|
-
})
|
|
28218
|
-
])
|
|
28219
28934
|
}),
|
|
28220
28935
|
object$1({
|
|
28221
|
-
type: literal("
|
|
28936
|
+
type: literal("tool_search_call"),
|
|
28937
|
+
id: string(),
|
|
28938
|
+
execution: _enum$1(["server", "client"]),
|
|
28939
|
+
call_id: string().nullable(),
|
|
28940
|
+
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
28941
|
+
arguments: unknown()
|
|
28942
|
+
}),
|
|
28943
|
+
object$1({
|
|
28944
|
+
type: literal("tool_search_output"),
|
|
28945
|
+
id: string(),
|
|
28946
|
+
execution: _enum$1(["server", "client"]),
|
|
28947
|
+
call_id: string().nullable(),
|
|
28948
|
+
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
28949
|
+
tools: array$1(record(string(), jsonValueSchema2.optional()))
|
|
28950
|
+
})
|
|
28951
|
+
])
|
|
28952
|
+
}),
|
|
28953
|
+
object$1({
|
|
28954
|
+
type: literal("response.output_item.done"),
|
|
28955
|
+
output_index: number$1(),
|
|
28956
|
+
item: discriminatedUnion("type", [
|
|
28957
|
+
object$1({
|
|
28958
|
+
type: literal("message"),
|
|
28959
|
+
id: string(),
|
|
28960
|
+
phase: _enum$1(["commentary", "final_answer"]).nullish()
|
|
28961
|
+
}),
|
|
28962
|
+
object$1({
|
|
28963
|
+
type: literal("reasoning"),
|
|
28964
|
+
id: string(),
|
|
28965
|
+
encrypted_content: string().nullish()
|
|
28966
|
+
}),
|
|
28967
|
+
object$1({
|
|
28968
|
+
type: literal("function_call"),
|
|
28969
|
+
id: string(),
|
|
28970
|
+
call_id: string(),
|
|
28971
|
+
name: string(),
|
|
28972
|
+
arguments: string(),
|
|
28973
|
+
status: literal("completed")
|
|
28974
|
+
}),
|
|
28975
|
+
object$1({
|
|
28976
|
+
type: literal("custom_tool_call"),
|
|
28977
|
+
id: string(),
|
|
28978
|
+
call_id: string(),
|
|
28979
|
+
name: string(),
|
|
28980
|
+
input: string(),
|
|
28981
|
+
status: literal("completed")
|
|
28982
|
+
}),
|
|
28983
|
+
object$1({
|
|
28984
|
+
type: literal("code_interpreter_call"),
|
|
28985
|
+
id: string(),
|
|
28986
|
+
code: string().nullable(),
|
|
28987
|
+
container_id: string(),
|
|
28988
|
+
outputs: array$1(
|
|
28989
|
+
discriminatedUnion("type", [
|
|
28990
|
+
object$1({ type: literal("logs"), logs: string() }),
|
|
28991
|
+
object$1({ type: literal("image"), url: string() })
|
|
28992
|
+
])
|
|
28993
|
+
).nullable()
|
|
28994
|
+
}),
|
|
28995
|
+
object$1({
|
|
28996
|
+
type: literal("image_generation_call"),
|
|
28997
|
+
id: string(),
|
|
28998
|
+
result: string()
|
|
28999
|
+
}),
|
|
29000
|
+
object$1({
|
|
29001
|
+
type: literal("web_search_call"),
|
|
29002
|
+
id: string(),
|
|
29003
|
+
status: string(),
|
|
29004
|
+
action: discriminatedUnion("type", [
|
|
29005
|
+
object$1({
|
|
29006
|
+
type: literal("search"),
|
|
29007
|
+
query: string().nullish(),
|
|
29008
|
+
sources: array$1(
|
|
29009
|
+
discriminatedUnion("type", [
|
|
29010
|
+
object$1({ type: literal("url"), url: string() }),
|
|
29011
|
+
object$1({ type: literal("api"), name: string() })
|
|
29012
|
+
])
|
|
29013
|
+
).nullish()
|
|
29014
|
+
}),
|
|
29015
|
+
object$1({
|
|
29016
|
+
type: literal("open_page"),
|
|
29017
|
+
url: string().nullish()
|
|
29018
|
+
}),
|
|
29019
|
+
object$1({
|
|
29020
|
+
type: literal("find_in_page"),
|
|
29021
|
+
url: string().nullish(),
|
|
29022
|
+
pattern: string().nullish()
|
|
29023
|
+
})
|
|
29024
|
+
]).nullish()
|
|
29025
|
+
}),
|
|
29026
|
+
object$1({
|
|
29027
|
+
type: literal("file_search_call"),
|
|
29028
|
+
id: string(),
|
|
29029
|
+
queries: array$1(string()),
|
|
29030
|
+
results: array$1(
|
|
29031
|
+
object$1({
|
|
29032
|
+
attributes: record(
|
|
29033
|
+
string(),
|
|
29034
|
+
union([string(), number$1(), boolean()])
|
|
29035
|
+
),
|
|
29036
|
+
file_id: string(),
|
|
29037
|
+
filename: string(),
|
|
29038
|
+
score: number$1(),
|
|
29039
|
+
text: string()
|
|
29040
|
+
})
|
|
29041
|
+
).nullish()
|
|
29042
|
+
}),
|
|
29043
|
+
object$1({
|
|
29044
|
+
type: literal("local_shell_call"),
|
|
29045
|
+
id: string(),
|
|
29046
|
+
call_id: string(),
|
|
29047
|
+
action: object$1({
|
|
29048
|
+
type: literal("exec"),
|
|
29049
|
+
command: array$1(string()),
|
|
29050
|
+
timeout_ms: number$1().optional(),
|
|
29051
|
+
user: string().optional(),
|
|
29052
|
+
working_directory: string().optional(),
|
|
29053
|
+
env: record(string(), string()).optional()
|
|
29054
|
+
})
|
|
29055
|
+
}),
|
|
29056
|
+
object$1({
|
|
29057
|
+
type: literal("computer_call"),
|
|
29058
|
+
id: string(),
|
|
29059
|
+
status: literal("completed")
|
|
29060
|
+
}),
|
|
29061
|
+
object$1({
|
|
29062
|
+
type: literal("mcp_call"),
|
|
29063
|
+
id: string(),
|
|
29064
|
+
status: string(),
|
|
29065
|
+
arguments: string(),
|
|
29066
|
+
name: string(),
|
|
29067
|
+
server_label: string(),
|
|
29068
|
+
output: string().nullish(),
|
|
29069
|
+
error: union([
|
|
29070
|
+
string(),
|
|
29071
|
+
object$1({
|
|
29072
|
+
type: string().optional(),
|
|
29073
|
+
code: union([number$1(), string()]).optional(),
|
|
29074
|
+
message: string().optional()
|
|
29075
|
+
}).loose()
|
|
29076
|
+
]).nullish(),
|
|
29077
|
+
approval_request_id: string().nullish()
|
|
29078
|
+
}),
|
|
29079
|
+
object$1({
|
|
29080
|
+
type: literal("mcp_list_tools"),
|
|
29081
|
+
id: string(),
|
|
29082
|
+
server_label: string(),
|
|
29083
|
+
tools: array$1(
|
|
29084
|
+
object$1({
|
|
29085
|
+
name: string(),
|
|
29086
|
+
description: string().optional(),
|
|
29087
|
+
input_schema: any(),
|
|
29088
|
+
annotations: record(string(), unknown()).optional()
|
|
29089
|
+
})
|
|
29090
|
+
),
|
|
29091
|
+
error: union([
|
|
29092
|
+
string(),
|
|
29093
|
+
object$1({
|
|
29094
|
+
type: string().optional(),
|
|
29095
|
+
code: union([number$1(), string()]).optional(),
|
|
29096
|
+
message: string().optional()
|
|
29097
|
+
}).loose()
|
|
29098
|
+
]).optional()
|
|
29099
|
+
}),
|
|
29100
|
+
object$1({
|
|
29101
|
+
type: literal("mcp_approval_request"),
|
|
29102
|
+
id: string(),
|
|
29103
|
+
server_label: string(),
|
|
29104
|
+
name: string(),
|
|
29105
|
+
arguments: string(),
|
|
29106
|
+
approval_request_id: string().optional()
|
|
29107
|
+
}),
|
|
29108
|
+
object$1({
|
|
29109
|
+
type: literal("apply_patch_call"),
|
|
29110
|
+
id: string(),
|
|
29111
|
+
call_id: string(),
|
|
29112
|
+
status: _enum$1(["in_progress", "completed"]),
|
|
29113
|
+
operation: discriminatedUnion("type", [
|
|
29114
|
+
object$1({
|
|
29115
|
+
type: literal("create_file"),
|
|
29116
|
+
path: string(),
|
|
29117
|
+
diff: string()
|
|
29118
|
+
}),
|
|
29119
|
+
object$1({
|
|
29120
|
+
type: literal("delete_file"),
|
|
29121
|
+
path: string()
|
|
29122
|
+
}),
|
|
29123
|
+
object$1({
|
|
29124
|
+
type: literal("update_file"),
|
|
29125
|
+
path: string(),
|
|
29126
|
+
diff: string()
|
|
29127
|
+
})
|
|
29128
|
+
])
|
|
29129
|
+
}),
|
|
29130
|
+
object$1({
|
|
29131
|
+
type: literal("shell_call"),
|
|
29132
|
+
id: string(),
|
|
29133
|
+
call_id: string(),
|
|
29134
|
+
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
29135
|
+
action: object$1({
|
|
29136
|
+
commands: array$1(string())
|
|
29137
|
+
})
|
|
29138
|
+
}),
|
|
29139
|
+
object$1({
|
|
29140
|
+
type: literal("shell_call_output"),
|
|
29141
|
+
id: string(),
|
|
29142
|
+
call_id: string(),
|
|
29143
|
+
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
29144
|
+
output: array$1(
|
|
29145
|
+
object$1({
|
|
29146
|
+
stdout: string(),
|
|
29147
|
+
stderr: string(),
|
|
29148
|
+
outcome: discriminatedUnion("type", [
|
|
29149
|
+
object$1({ type: literal("timeout") }),
|
|
29150
|
+
object$1({
|
|
29151
|
+
type: literal("exit"),
|
|
29152
|
+
exit_code: number$1()
|
|
29153
|
+
})
|
|
29154
|
+
])
|
|
29155
|
+
})
|
|
29156
|
+
)
|
|
29157
|
+
}),
|
|
29158
|
+
object$1({
|
|
29159
|
+
type: literal("tool_search_call"),
|
|
28222
29160
|
id: string(),
|
|
28223
|
-
|
|
29161
|
+
execution: _enum$1(["server", "client"]),
|
|
29162
|
+
call_id: string().nullable(),
|
|
28224
29163
|
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
28225
|
-
|
|
28226
|
-
commands: array$1(string())
|
|
28227
|
-
})
|
|
29164
|
+
arguments: unknown()
|
|
28228
29165
|
}),
|
|
28229
29166
|
object$1({
|
|
28230
|
-
type: literal("
|
|
29167
|
+
type: literal("tool_search_output"),
|
|
28231
29168
|
id: string(),
|
|
28232
|
-
|
|
29169
|
+
execution: _enum$1(["server", "client"]),
|
|
29170
|
+
call_id: string().nullable(),
|
|
28233
29171
|
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
28234
|
-
|
|
28235
|
-
object$1({
|
|
28236
|
-
stdout: string(),
|
|
28237
|
-
stderr: string(),
|
|
28238
|
-
outcome: discriminatedUnion("type", [
|
|
28239
|
-
object$1({ type: literal("timeout") }),
|
|
28240
|
-
object$1({
|
|
28241
|
-
type: literal("exit"),
|
|
28242
|
-
exit_code: number$1()
|
|
28243
|
-
})
|
|
28244
|
-
])
|
|
28245
|
-
})
|
|
28246
|
-
)
|
|
29172
|
+
tools: array$1(record(string(), jsonValueSchema2.optional()))
|
|
28247
29173
|
})
|
|
28248
29174
|
])
|
|
28249
29175
|
}),
|
|
@@ -28625,6 +29551,22 @@ ${user}:`]
|
|
|
28625
29551
|
])
|
|
28626
29552
|
})
|
|
28627
29553
|
)
|
|
29554
|
+
}),
|
|
29555
|
+
object$1({
|
|
29556
|
+
type: literal("tool_search_call"),
|
|
29557
|
+
id: string(),
|
|
29558
|
+
execution: _enum$1(["server", "client"]),
|
|
29559
|
+
call_id: string().nullable(),
|
|
29560
|
+
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
29561
|
+
arguments: unknown()
|
|
29562
|
+
}),
|
|
29563
|
+
object$1({
|
|
29564
|
+
type: literal("tool_search_output"),
|
|
29565
|
+
id: string(),
|
|
29566
|
+
execution: _enum$1(["server", "client"]),
|
|
29567
|
+
call_id: string().nullable(),
|
|
29568
|
+
status: _enum$1(["in_progress", "completed", "incomplete"]),
|
|
29569
|
+
tools: array$1(record(string(), jsonValueSchema2.optional()))
|
|
28628
29570
|
})
|
|
28629
29571
|
])
|
|
28630
29572
|
).optional(),
|
|
@@ -28800,7 +29742,7 @@ ${user}:`]
|
|
|
28800
29742
|
toolNameMapping,
|
|
28801
29743
|
customProviderToolNames
|
|
28802
29744
|
}) {
|
|
28803
|
-
var _a10;
|
|
29745
|
+
var _a10, _b9;
|
|
28804
29746
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
28805
29747
|
const toolWarnings = [];
|
|
28806
29748
|
if (tools == null) {
|
|
@@ -28810,15 +29752,19 @@ ${user}:`]
|
|
|
28810
29752
|
const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
|
|
28811
29753
|
for (const tool2 of tools) {
|
|
28812
29754
|
switch (tool2.type) {
|
|
28813
|
-
case "function":
|
|
29755
|
+
case "function": {
|
|
29756
|
+
const openaiOptions = (_a10 = tool2.providerOptions) == null ? void 0 : _a10.openai;
|
|
29757
|
+
const deferLoading = openaiOptions == null ? void 0 : openaiOptions.deferLoading;
|
|
28814
29758
|
openaiTools2.push({
|
|
28815
29759
|
type: "function",
|
|
28816
29760
|
name: tool2.name,
|
|
28817
29761
|
description: tool2.description,
|
|
28818
29762
|
parameters: tool2.inputSchema,
|
|
28819
|
-
...tool2.strict != null ? { strict: tool2.strict } : {}
|
|
29763
|
+
...tool2.strict != null ? { strict: tool2.strict } : {},
|
|
29764
|
+
...deferLoading != null ? { defer_loading: deferLoading } : {}
|
|
28820
29765
|
});
|
|
28821
29766
|
break;
|
|
29767
|
+
}
|
|
28822
29768
|
case "provider": {
|
|
28823
29769
|
switch (tool2.id) {
|
|
28824
29770
|
case "openai.file_search": {
|
|
@@ -28963,6 +29909,19 @@ ${user}:`]
|
|
|
28963
29909
|
resolvedCustomProviderToolNames.add(args.name);
|
|
28964
29910
|
break;
|
|
28965
29911
|
}
|
|
29912
|
+
case "openai.tool_search": {
|
|
29913
|
+
const args = await validateTypes$1({
|
|
29914
|
+
value: tool2.args,
|
|
29915
|
+
schema: toolSearchArgsSchema
|
|
29916
|
+
});
|
|
29917
|
+
openaiTools2.push({
|
|
29918
|
+
type: "tool_search",
|
|
29919
|
+
...args.execution != null ? { execution: args.execution } : {},
|
|
29920
|
+
...args.description != null ? { description: args.description } : {},
|
|
29921
|
+
...args.parameters != null ? { parameters: args.parameters } : {}
|
|
29922
|
+
});
|
|
29923
|
+
break;
|
|
29924
|
+
}
|
|
28966
29925
|
}
|
|
28967
29926
|
break;
|
|
28968
29927
|
}
|
|
@@ -28984,7 +29943,7 @@ ${user}:`]
|
|
|
28984
29943
|
case "required":
|
|
28985
29944
|
return { tools: openaiTools2, toolChoice: type2, toolWarnings };
|
|
28986
29945
|
case "tool": {
|
|
28987
|
-
const resolvedToolName = (
|
|
29946
|
+
const resolvedToolName = (_b9 = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _b9 : toolChoice.toolName;
|
|
28988
29947
|
return {
|
|
28989
29948
|
tools: openaiTools2,
|
|
28990
29949
|
toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
|
|
@@ -29138,7 +30097,8 @@ ${user}:`]
|
|
|
29138
30097
|
"openai.web_search": "web_search",
|
|
29139
30098
|
"openai.web_search_preview": "web_search_preview",
|
|
29140
30099
|
"openai.mcp": "mcp",
|
|
29141
|
-
"openai.apply_patch": "apply_patch"
|
|
30100
|
+
"openai.apply_patch": "apply_patch",
|
|
30101
|
+
"openai.tool_search": "tool_search"
|
|
29142
30102
|
},
|
|
29143
30103
|
resolveProviderToolName: (tool2) => tool2.id === "openai.custom" ? tool2.args.name : void 0
|
|
29144
30104
|
});
|
|
@@ -29316,7 +30276,7 @@ ${user}:`]
|
|
|
29316
30276
|
};
|
|
29317
30277
|
}
|
|
29318
30278
|
async doGenerate(options) {
|
|
29319
|
-
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
30279
|
+
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B;
|
|
29320
30280
|
const {
|
|
29321
30281
|
args: body,
|
|
29322
30282
|
warnings,
|
|
@@ -29359,6 +30319,7 @@ ${user}:`]
|
|
|
29359
30319
|
const content = [];
|
|
29360
30320
|
const logprobs = [];
|
|
29361
30321
|
let hasFunctionCall = false;
|
|
30322
|
+
const hostedToolSearchCallIds = [];
|
|
29362
30323
|
for (const part of response.output) {
|
|
29363
30324
|
switch (part.type) {
|
|
29364
30325
|
case "reasoning": {
|
|
@@ -29397,6 +30358,46 @@ ${user}:`]
|
|
|
29397
30358
|
});
|
|
29398
30359
|
break;
|
|
29399
30360
|
}
|
|
30361
|
+
case "tool_search_call": {
|
|
30362
|
+
const toolCallId = (_b9 = part.call_id) != null ? _b9 : part.id;
|
|
30363
|
+
const isHosted = part.execution === "server";
|
|
30364
|
+
if (isHosted) {
|
|
30365
|
+
hostedToolSearchCallIds.push(toolCallId);
|
|
30366
|
+
}
|
|
30367
|
+
content.push({
|
|
30368
|
+
type: "tool-call",
|
|
30369
|
+
toolCallId,
|
|
30370
|
+
toolName: toolNameMapping.toCustomToolName("tool_search"),
|
|
30371
|
+
input: JSON.stringify({
|
|
30372
|
+
arguments: part.arguments,
|
|
30373
|
+
call_id: part.call_id
|
|
30374
|
+
}),
|
|
30375
|
+
...isHosted ? { providerExecuted: true } : {},
|
|
30376
|
+
providerMetadata: {
|
|
30377
|
+
[providerOptionsName]: {
|
|
30378
|
+
itemId: part.id
|
|
30379
|
+
}
|
|
30380
|
+
}
|
|
30381
|
+
});
|
|
30382
|
+
break;
|
|
30383
|
+
}
|
|
30384
|
+
case "tool_search_output": {
|
|
30385
|
+
const toolCallId = (_d = (_c = part.call_id) != null ? _c : hostedToolSearchCallIds.shift()) != null ? _d : part.id;
|
|
30386
|
+
content.push({
|
|
30387
|
+
type: "tool-result",
|
|
30388
|
+
toolCallId,
|
|
30389
|
+
toolName: toolNameMapping.toCustomToolName("tool_search"),
|
|
30390
|
+
result: {
|
|
30391
|
+
tools: part.tools
|
|
30392
|
+
},
|
|
30393
|
+
providerMetadata: {
|
|
30394
|
+
[providerOptionsName]: {
|
|
30395
|
+
itemId: part.id
|
|
30396
|
+
}
|
|
30397
|
+
}
|
|
30398
|
+
});
|
|
30399
|
+
break;
|
|
30400
|
+
}
|
|
29400
30401
|
case "local_shell_call": {
|
|
29401
30402
|
content.push({
|
|
29402
30403
|
type: "tool-call",
|
|
@@ -29452,7 +30453,7 @@ ${user}:`]
|
|
|
29452
30453
|
}
|
|
29453
30454
|
case "message": {
|
|
29454
30455
|
for (const contentPart of part.content) {
|
|
29455
|
-
if (((
|
|
30456
|
+
if (((_f = (_e = options.providerOptions) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.logprobs) && contentPart.logprobs) {
|
|
29456
30457
|
logprobs.push(contentPart.logprobs);
|
|
29457
30458
|
}
|
|
29458
30459
|
const providerMetadata2 = {
|
|
@@ -29474,7 +30475,7 @@ ${user}:`]
|
|
|
29474
30475
|
content.push({
|
|
29475
30476
|
type: "source",
|
|
29476
30477
|
sourceType: "url",
|
|
29477
|
-
id: (
|
|
30478
|
+
id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId$1(),
|
|
29478
30479
|
url: annotation.url,
|
|
29479
30480
|
title: annotation.title
|
|
29480
30481
|
});
|
|
@@ -29482,7 +30483,7 @@ ${user}:`]
|
|
|
29482
30483
|
content.push({
|
|
29483
30484
|
type: "source",
|
|
29484
30485
|
sourceType: "document",
|
|
29485
|
-
id: (
|
|
30486
|
+
id: (_l = (_k = (_j = this.config).generateId) == null ? void 0 : _k.call(_j)) != null ? _l : generateId$1(),
|
|
29486
30487
|
mediaType: "text/plain",
|
|
29487
30488
|
title: annotation.filename,
|
|
29488
30489
|
filename: annotation.filename,
|
|
@@ -29498,7 +30499,7 @@ ${user}:`]
|
|
|
29498
30499
|
content.push({
|
|
29499
30500
|
type: "source",
|
|
29500
30501
|
sourceType: "document",
|
|
29501
|
-
id: (
|
|
30502
|
+
id: (_o = (_n = (_m = this.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId$1(),
|
|
29502
30503
|
mediaType: "text/plain",
|
|
29503
30504
|
title: annotation.filename,
|
|
29504
30505
|
filename: annotation.filename,
|
|
@@ -29514,7 +30515,7 @@ ${user}:`]
|
|
|
29514
30515
|
content.push({
|
|
29515
30516
|
type: "source",
|
|
29516
30517
|
sourceType: "document",
|
|
29517
|
-
id: (
|
|
30518
|
+
id: (_r = (_q = (_p = this.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId$1(),
|
|
29518
30519
|
mediaType: "application/octet-stream",
|
|
29519
30520
|
title: annotation.file_id,
|
|
29520
30521
|
filename: annotation.file_id,
|
|
@@ -29583,7 +30584,7 @@ ${user}:`]
|
|
|
29583
30584
|
break;
|
|
29584
30585
|
}
|
|
29585
30586
|
case "mcp_call": {
|
|
29586
|
-
const toolCallId = part.approval_request_id != null ? (
|
|
30587
|
+
const toolCallId = part.approval_request_id != null ? (_s = approvalRequestIdToDummyToolCallIdFromPrompt[part.approval_request_id]) != null ? _s : part.id : part.id;
|
|
29587
30588
|
const toolName = `mcp.${part.name}`;
|
|
29588
30589
|
content.push({
|
|
29589
30590
|
type: "tool-call",
|
|
@@ -29617,8 +30618,8 @@ ${user}:`]
|
|
|
29617
30618
|
break;
|
|
29618
30619
|
}
|
|
29619
30620
|
case "mcp_approval_request": {
|
|
29620
|
-
const approvalRequestId = (
|
|
29621
|
-
const dummyToolCallId = (
|
|
30621
|
+
const approvalRequestId = (_t = part.approval_request_id) != null ? _t : part.id;
|
|
30622
|
+
const dummyToolCallId = (_w = (_v = (_u = this.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId$1();
|
|
29622
30623
|
const toolName = `mcp.${part.name}`;
|
|
29623
30624
|
content.push({
|
|
29624
30625
|
type: "tool-call",
|
|
@@ -29668,13 +30669,13 @@ ${user}:`]
|
|
|
29668
30669
|
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
29669
30670
|
result: {
|
|
29670
30671
|
queries: part.queries,
|
|
29671
|
-
results: (
|
|
30672
|
+
results: (_y = (_x = part.results) == null ? void 0 : _x.map((result) => ({
|
|
29672
30673
|
attributes: result.attributes,
|
|
29673
30674
|
fileId: result.file_id,
|
|
29674
30675
|
filename: result.filename,
|
|
29675
30676
|
score: result.score,
|
|
29676
30677
|
text: result.text
|
|
29677
|
-
}))) != null ?
|
|
30678
|
+
}))) != null ? _y : null
|
|
29678
30679
|
}
|
|
29679
30680
|
});
|
|
29680
30681
|
break;
|
|
@@ -29731,10 +30732,10 @@ ${user}:`]
|
|
|
29731
30732
|
content,
|
|
29732
30733
|
finishReason: {
|
|
29733
30734
|
unified: mapOpenAIResponseFinishReason({
|
|
29734
|
-
finishReason: (
|
|
30735
|
+
finishReason: (_z = response.incomplete_details) == null ? void 0 : _z.reason,
|
|
29735
30736
|
hasFunctionCall
|
|
29736
30737
|
}),
|
|
29737
|
-
raw: (
|
|
30738
|
+
raw: (_B = (_A = response.incomplete_details) == null ? void 0 : _A.reason) != null ? _B : void 0
|
|
29738
30739
|
},
|
|
29739
30740
|
usage: convertOpenAIResponsesUsage(usage),
|
|
29740
30741
|
request: { body },
|
|
@@ -29792,6 +30793,7 @@ ${user}:`]
|
|
|
29792
30793
|
let hasFunctionCall = false;
|
|
29793
30794
|
const activeReasoning = {};
|
|
29794
30795
|
let serviceTier;
|
|
30796
|
+
const hostedToolSearchCallIds = [];
|
|
29795
30797
|
return {
|
|
29796
30798
|
stream: response.pipeThrough(
|
|
29797
30799
|
new TransformStream({
|
|
@@ -29799,7 +30801,7 @@ ${user}:`]
|
|
|
29799
30801
|
controller.enqueue({ type: "stream-start", warnings });
|
|
29800
30802
|
},
|
|
29801
30803
|
transform(chunk, controller) {
|
|
29802
|
-
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
|
|
30804
|
+
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L;
|
|
29803
30805
|
if (options.includeRawChunks) {
|
|
29804
30806
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
29805
30807
|
}
|
|
@@ -29907,7 +30909,25 @@ ${user}:`]
|
|
|
29907
30909
|
input: "{}",
|
|
29908
30910
|
providerExecuted: true
|
|
29909
30911
|
});
|
|
29910
|
-
} else if (value.item.type === "
|
|
30912
|
+
} else if (value.item.type === "tool_search_call") {
|
|
30913
|
+
const toolCallId = value.item.id;
|
|
30914
|
+
const toolName = toolNameMapping.toCustomToolName("tool_search");
|
|
30915
|
+
const isHosted = value.item.execution === "server";
|
|
30916
|
+
ongoingToolCalls[value.output_index] = {
|
|
30917
|
+
toolName,
|
|
30918
|
+
toolCallId,
|
|
30919
|
+
toolSearchExecution: (_a10 = value.item.execution) != null ? _a10 : "server"
|
|
30920
|
+
};
|
|
30921
|
+
if (isHosted) {
|
|
30922
|
+
controller.enqueue({
|
|
30923
|
+
type: "tool-input-start",
|
|
30924
|
+
id: toolCallId,
|
|
30925
|
+
toolName,
|
|
30926
|
+
providerExecuted: true
|
|
30927
|
+
});
|
|
30928
|
+
}
|
|
30929
|
+
} else if (value.item.type === "tool_search_output") ;
|
|
30930
|
+
else if (value.item.type === "mcp_call" || value.item.type === "mcp_list_tools" || value.item.type === "mcp_approval_request") ;
|
|
29911
30931
|
else if (value.item.type === "apply_patch_call") {
|
|
29912
30932
|
const { call_id: callId, operation } = value.item;
|
|
29913
30933
|
ongoingToolCalls[value.output_index] = {
|
|
@@ -29953,7 +30973,7 @@ ${user}:`]
|
|
|
29953
30973
|
} else if (value.item.type === "shell_call_output") ;
|
|
29954
30974
|
else if (value.item.type === "message") {
|
|
29955
30975
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
29956
|
-
activeMessagePhase = (
|
|
30976
|
+
activeMessagePhase = (_b9 = value.item.phase) != null ? _b9 : void 0;
|
|
29957
30977
|
controller.enqueue({
|
|
29958
30978
|
type: "text-start",
|
|
29959
30979
|
id: value.item.id,
|
|
@@ -29977,14 +30997,14 @@ ${user}:`]
|
|
|
29977
30997
|
providerMetadata: {
|
|
29978
30998
|
[providerOptionsName]: {
|
|
29979
30999
|
itemId: value.item.id,
|
|
29980
|
-
reasoningEncryptedContent: (
|
|
31000
|
+
reasoningEncryptedContent: (_c = value.item.encrypted_content) != null ? _c : null
|
|
29981
31001
|
}
|
|
29982
31002
|
}
|
|
29983
31003
|
});
|
|
29984
31004
|
}
|
|
29985
31005
|
} else if (isResponseOutputItemDoneChunk(value)) {
|
|
29986
31006
|
if (value.item.type === "message") {
|
|
29987
|
-
const phase = (
|
|
31007
|
+
const phase = (_d = value.item.phase) != null ? _d : activeMessagePhase;
|
|
29988
31008
|
activeMessagePhase = void 0;
|
|
29989
31009
|
controller.enqueue({
|
|
29990
31010
|
type: "text-end",
|
|
@@ -30078,13 +31098,13 @@ ${user}:`]
|
|
|
30078
31098
|
toolName: toolNameMapping.toCustomToolName("file_search"),
|
|
30079
31099
|
result: {
|
|
30080
31100
|
queries: value.item.queries,
|
|
30081
|
-
results: (
|
|
31101
|
+
results: (_f = (_e = value.item.results) == null ? void 0 : _e.map((result) => ({
|
|
30082
31102
|
attributes: result.attributes,
|
|
30083
31103
|
fileId: result.file_id,
|
|
30084
31104
|
filename: result.filename,
|
|
30085
31105
|
score: result.score,
|
|
30086
31106
|
text: result.text
|
|
30087
|
-
}))) != null ?
|
|
31107
|
+
}))) != null ? _f : null
|
|
30088
31108
|
}
|
|
30089
31109
|
});
|
|
30090
31110
|
} else if (value.item.type === "code_interpreter_call") {
|
|
@@ -30106,12 +31126,62 @@ ${user}:`]
|
|
|
30106
31126
|
result: value.item.result
|
|
30107
31127
|
}
|
|
30108
31128
|
});
|
|
31129
|
+
} else if (value.item.type === "tool_search_call") {
|
|
31130
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
31131
|
+
const isHosted = value.item.execution === "server";
|
|
31132
|
+
if (toolCall != null) {
|
|
31133
|
+
const toolCallId = isHosted ? toolCall.toolCallId : (_g = value.item.call_id) != null ? _g : value.item.id;
|
|
31134
|
+
if (isHosted) {
|
|
31135
|
+
hostedToolSearchCallIds.push(toolCallId);
|
|
31136
|
+
} else {
|
|
31137
|
+
controller.enqueue({
|
|
31138
|
+
type: "tool-input-start",
|
|
31139
|
+
id: toolCallId,
|
|
31140
|
+
toolName: toolCall.toolName
|
|
31141
|
+
});
|
|
31142
|
+
}
|
|
31143
|
+
controller.enqueue({
|
|
31144
|
+
type: "tool-input-end",
|
|
31145
|
+
id: toolCallId
|
|
31146
|
+
});
|
|
31147
|
+
controller.enqueue({
|
|
31148
|
+
type: "tool-call",
|
|
31149
|
+
toolCallId,
|
|
31150
|
+
toolName: toolCall.toolName,
|
|
31151
|
+
input: JSON.stringify({
|
|
31152
|
+
arguments: value.item.arguments,
|
|
31153
|
+
call_id: isHosted ? null : toolCallId
|
|
31154
|
+
}),
|
|
31155
|
+
...isHosted ? { providerExecuted: true } : {},
|
|
31156
|
+
providerMetadata: {
|
|
31157
|
+
[providerOptionsName]: {
|
|
31158
|
+
itemId: value.item.id
|
|
31159
|
+
}
|
|
31160
|
+
}
|
|
31161
|
+
});
|
|
31162
|
+
}
|
|
31163
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
31164
|
+
} else if (value.item.type === "tool_search_output") {
|
|
31165
|
+
const toolCallId = (_i = (_h = value.item.call_id) != null ? _h : hostedToolSearchCallIds.shift()) != null ? _i : value.item.id;
|
|
31166
|
+
controller.enqueue({
|
|
31167
|
+
type: "tool-result",
|
|
31168
|
+
toolCallId,
|
|
31169
|
+
toolName: toolNameMapping.toCustomToolName("tool_search"),
|
|
31170
|
+
result: {
|
|
31171
|
+
tools: value.item.tools
|
|
31172
|
+
},
|
|
31173
|
+
providerMetadata: {
|
|
31174
|
+
[providerOptionsName]: {
|
|
31175
|
+
itemId: value.item.id
|
|
31176
|
+
}
|
|
31177
|
+
}
|
|
31178
|
+
});
|
|
30109
31179
|
} else if (value.item.type === "mcp_call") {
|
|
30110
31180
|
ongoingToolCalls[value.output_index] = void 0;
|
|
30111
|
-
const approvalRequestId = (
|
|
30112
|
-
const aliasedToolCallId = approvalRequestId != null ? (
|
|
31181
|
+
const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : void 0;
|
|
31182
|
+
const aliasedToolCallId = approvalRequestId != null ? (_l = (_k = approvalRequestIdToDummyToolCallIdFromStream.get(
|
|
30113
31183
|
approvalRequestId
|
|
30114
|
-
)) != null ?
|
|
31184
|
+
)) != null ? _k : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _l : value.item.id : value.item.id;
|
|
30115
31185
|
const toolName = `mcp.${value.item.name}`;
|
|
30116
31186
|
controller.enqueue({
|
|
30117
31187
|
type: "tool-call",
|
|
@@ -30181,8 +31251,8 @@ ${user}:`]
|
|
|
30181
31251
|
ongoingToolCalls[value.output_index] = void 0;
|
|
30182
31252
|
} else if (value.item.type === "mcp_approval_request") {
|
|
30183
31253
|
ongoingToolCalls[value.output_index] = void 0;
|
|
30184
|
-
const dummyToolCallId = (
|
|
30185
|
-
const approvalRequestId = (
|
|
31254
|
+
const dummyToolCallId = (_o = (_n = (_m = self2.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId$1();
|
|
31255
|
+
const approvalRequestId = (_p = value.item.approval_request_id) != null ? _p : value.item.id;
|
|
30186
31256
|
approvalRequestIdToDummyToolCallIdFromStream.set(
|
|
30187
31257
|
approvalRequestId,
|
|
30188
31258
|
dummyToolCallId
|
|
@@ -30271,7 +31341,7 @@ ${user}:`]
|
|
|
30271
31341
|
providerMetadata: {
|
|
30272
31342
|
[providerOptionsName]: {
|
|
30273
31343
|
itemId: value.item.id,
|
|
30274
|
-
reasoningEncryptedContent: (
|
|
31344
|
+
reasoningEncryptedContent: (_q = value.item.encrypted_content) != null ? _q : null
|
|
30275
31345
|
}
|
|
30276
31346
|
}
|
|
30277
31347
|
});
|
|
@@ -30384,7 +31454,7 @@ ${user}:`]
|
|
|
30384
31454
|
id: value.item_id,
|
|
30385
31455
|
delta: value.delta
|
|
30386
31456
|
});
|
|
30387
|
-
if (((
|
|
31457
|
+
if (((_s = (_r = options.providerOptions) == null ? void 0 : _r[providerOptionsName]) == null ? void 0 : _s.logprobs) && value.logprobs) {
|
|
30388
31458
|
logprobs.push(value.logprobs);
|
|
30389
31459
|
}
|
|
30390
31460
|
} else if (value.type === "response.reasoning_summary_part.added") {
|
|
@@ -30413,7 +31483,7 @@ ${user}:`]
|
|
|
30413
31483
|
providerMetadata: {
|
|
30414
31484
|
[providerOptionsName]: {
|
|
30415
31485
|
itemId: value.item_id,
|
|
30416
|
-
reasoningEncryptedContent: (
|
|
31486
|
+
reasoningEncryptedContent: (_u = (_t = activeReasoning[value.item_id]) == null ? void 0 : _t.encryptedContent) != null ? _u : null
|
|
30417
31487
|
}
|
|
30418
31488
|
}
|
|
30419
31489
|
});
|
|
@@ -30447,22 +31517,32 @@ ${user}:`]
|
|
|
30447
31517
|
} else if (isResponseFinishedChunk(value)) {
|
|
30448
31518
|
finishReason = {
|
|
30449
31519
|
unified: mapOpenAIResponseFinishReason({
|
|
30450
|
-
finishReason: (
|
|
31520
|
+
finishReason: (_v = value.response.incomplete_details) == null ? void 0 : _v.reason,
|
|
30451
31521
|
hasFunctionCall
|
|
30452
31522
|
}),
|
|
30453
|
-
raw: (
|
|
31523
|
+
raw: (_x = (_w = value.response.incomplete_details) == null ? void 0 : _w.reason) != null ? _x : void 0
|
|
30454
31524
|
};
|
|
30455
31525
|
usage = value.response.usage;
|
|
30456
31526
|
if (typeof value.response.service_tier === "string") {
|
|
30457
31527
|
serviceTier = value.response.service_tier;
|
|
30458
31528
|
}
|
|
31529
|
+
} else if (isResponseFailedChunk(value)) {
|
|
31530
|
+
const incompleteReason = (_y = value.response.incomplete_details) == null ? void 0 : _y.reason;
|
|
31531
|
+
finishReason = {
|
|
31532
|
+
unified: incompleteReason ? mapOpenAIResponseFinishReason({
|
|
31533
|
+
finishReason: incompleteReason,
|
|
31534
|
+
hasFunctionCall
|
|
31535
|
+
}) : "error",
|
|
31536
|
+
raw: incompleteReason != null ? incompleteReason : "error"
|
|
31537
|
+
};
|
|
31538
|
+
usage = (_z = value.response.usage) != null ? _z : void 0;
|
|
30459
31539
|
} else if (isResponseAnnotationAddedChunk(value)) {
|
|
30460
31540
|
ongoingAnnotations.push(value.annotation);
|
|
30461
31541
|
if (value.annotation.type === "url_citation") {
|
|
30462
31542
|
controller.enqueue({
|
|
30463
31543
|
type: "source",
|
|
30464
31544
|
sourceType: "url",
|
|
30465
|
-
id: (
|
|
31545
|
+
id: (_C = (_B = (_A = self2.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId$1(),
|
|
30466
31546
|
url: value.annotation.url,
|
|
30467
31547
|
title: value.annotation.title
|
|
30468
31548
|
});
|
|
@@ -30470,7 +31550,7 @@ ${user}:`]
|
|
|
30470
31550
|
controller.enqueue({
|
|
30471
31551
|
type: "source",
|
|
30472
31552
|
sourceType: "document",
|
|
30473
|
-
id: (
|
|
31553
|
+
id: (_F = (_E = (_D = self2.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId$1(),
|
|
30474
31554
|
mediaType: "text/plain",
|
|
30475
31555
|
title: value.annotation.filename,
|
|
30476
31556
|
filename: value.annotation.filename,
|
|
@@ -30486,7 +31566,7 @@ ${user}:`]
|
|
|
30486
31566
|
controller.enqueue({
|
|
30487
31567
|
type: "source",
|
|
30488
31568
|
sourceType: "document",
|
|
30489
|
-
id: (
|
|
31569
|
+
id: (_I = (_H = (_G = self2.config).generateId) == null ? void 0 : _H.call(_G)) != null ? _I : generateId$1(),
|
|
30490
31570
|
mediaType: "text/plain",
|
|
30491
31571
|
title: value.annotation.filename,
|
|
30492
31572
|
filename: value.annotation.filename,
|
|
@@ -30502,7 +31582,7 @@ ${user}:`]
|
|
|
30502
31582
|
controller.enqueue({
|
|
30503
31583
|
type: "source",
|
|
30504
31584
|
sourceType: "document",
|
|
30505
|
-
id: (
|
|
31585
|
+
id: (_L = (_K = (_J = self2.config).generateId) == null ? void 0 : _K.call(_J)) != null ? _L : generateId$1(),
|
|
30506
31586
|
mediaType: "application/octet-stream",
|
|
30507
31587
|
title: value.annotation.file_id,
|
|
30508
31588
|
filename: value.annotation.file_id,
|
|
@@ -30550,6 +31630,9 @@ ${user}:`]
|
|
|
30550
31630
|
function isResponseFinishedChunk(chunk) {
|
|
30551
31631
|
return chunk.type === "response.completed" || chunk.type === "response.incomplete";
|
|
30552
31632
|
}
|
|
31633
|
+
function isResponseFailedChunk(chunk) {
|
|
31634
|
+
return chunk.type === "response.failed";
|
|
31635
|
+
}
|
|
30553
31636
|
function isResponseCreatedChunk(chunk) {
|
|
30554
31637
|
return chunk.type === "response.created";
|
|
30555
31638
|
}
|
|
@@ -30940,7 +32023,7 @@ ${user}:`]
|
|
|
30940
32023
|
};
|
|
30941
32024
|
}
|
|
30942
32025
|
};
|
|
30943
|
-
var VERSION$2 = "3.0.
|
|
32026
|
+
var VERSION$2 = "3.0.48";
|
|
30944
32027
|
function createOpenAI(options = {}) {
|
|
30945
32028
|
var _a10, _b9;
|
|
30946
32029
|
const baseURL = (_a10 = withoutTrailingSlash$1(
|
|
@@ -32772,7 +33855,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
32772
33855
|
console.log("【Client Transport】处理server消息错误:", error);
|
|
32773
33856
|
}
|
|
32774
33857
|
},
|
|
32775
|
-
"content->
|
|
33858
|
+
"content->bg"
|
|
32776
33859
|
);
|
|
32777
33860
|
}
|
|
32778
33861
|
// 是否已关闭
|
|
@@ -32795,13 +33878,21 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
32795
33878
|
async send(message, _options) {
|
|
32796
33879
|
this._throwError(() => !this._isStarted, "【Client Transport】 未启动,无法发送消息");
|
|
32797
33880
|
this._throwError(() => this._isClosed, "【Client Transport】 已关闭,无法发送消息");
|
|
32798
|
-
|
|
32799
|
-
|
|
32800
|
-
|
|
33881
|
+
let tabId;
|
|
33882
|
+
if (chrome.sessionRegistry) {
|
|
33883
|
+
const sessionInfo = chrome.sessionRegistry.get(this.targetSessionId);
|
|
33884
|
+
if (sessionInfo && sessionInfo.tabIds.length > 0) {
|
|
33885
|
+
tabId = sessionInfo.tabIds[sessionInfo.tabIds.length - 1];
|
|
33886
|
+
}
|
|
33887
|
+
}
|
|
33888
|
+
if (tabId == null) {
|
|
33889
|
+
tabId = await chrome.runtime.sendMessage({ type: "get-session-tab-id", sessionId: this.targetSessionId });
|
|
33890
|
+
}
|
|
33891
|
+
this._throwError(() => tabId == null, `【Client Transport】后台未找到活动的tabId用于${this.targetSessionId}`);
|
|
32801
33892
|
sendRuntimeMessage(
|
|
32802
33893
|
"mcp-client-to-server",
|
|
32803
33894
|
{ sessionId: this.targetSessionId, tabId, mcpMessage: message },
|
|
32804
|
-
"
|
|
33895
|
+
"bg->content"
|
|
32805
33896
|
);
|
|
32806
33897
|
}
|
|
32807
33898
|
/** 关闭 transport */
|
|
@@ -41231,462 +42322,6 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
41231
42322
|
return this.notification({ method: "notifications/roots/list_changed" });
|
|
41232
42323
|
}
|
|
41233
42324
|
}
|
|
41234
|
-
class ErrorEvent extends Event {
|
|
41235
|
-
/**
|
|
41236
|
-
* Constructs a new `ErrorEvent` instance. This is typically not called directly,
|
|
41237
|
-
* but rather emitted by the `EventSource` object when an error occurs.
|
|
41238
|
-
*
|
|
41239
|
-
* @param type - The type of the event (should be "error")
|
|
41240
|
-
* @param errorEventInitDict - Optional properties to include in the error event
|
|
41241
|
-
*/
|
|
41242
|
-
constructor(type2, errorEventInitDict) {
|
|
41243
|
-
var _a10, _b9;
|
|
41244
|
-
super(type2), this.code = (_a10 = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a10 : void 0, this.message = (_b9 = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b9 : void 0;
|
|
41245
|
-
}
|
|
41246
|
-
/**
|
|
41247
|
-
* Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
|
41248
|
-
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
|
41249
|
-
* we explicitly include the properties in the `inspect` method.
|
|
41250
|
-
*
|
|
41251
|
-
* This is automatically called by Node.js when you `console.log` an instance of this class.
|
|
41252
|
-
*
|
|
41253
|
-
* @param _depth - The current depth
|
|
41254
|
-
* @param options - The options passed to `util.inspect`
|
|
41255
|
-
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
|
41256
|
-
* @returns A string representation of the error
|
|
41257
|
-
*/
|
|
41258
|
-
[Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
|
|
41259
|
-
return inspect(inspectableError(this), options);
|
|
41260
|
-
}
|
|
41261
|
-
/**
|
|
41262
|
-
* Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
|
|
41263
|
-
* when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
|
|
41264
|
-
* we explicitly include the properties in the `inspect` method.
|
|
41265
|
-
*
|
|
41266
|
-
* This is automatically called by Deno when you `console.log` an instance of this class.
|
|
41267
|
-
*
|
|
41268
|
-
* @param inspect - The inspect function to use (prevents having to import it from `util`)
|
|
41269
|
-
* @param options - The options passed to `Deno.inspect`
|
|
41270
|
-
* @returns A string representation of the error
|
|
41271
|
-
*/
|
|
41272
|
-
[Symbol.for("Deno.customInspect")](inspect, options) {
|
|
41273
|
-
return inspect(inspectableError(this), options);
|
|
41274
|
-
}
|
|
41275
|
-
}
|
|
41276
|
-
function syntaxError(message) {
|
|
41277
|
-
const DomException = globalThis.DOMException;
|
|
41278
|
-
return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);
|
|
41279
|
-
}
|
|
41280
|
-
function flattenError(err) {
|
|
41281
|
-
return err instanceof Error ? "errors" in err && Array.isArray(err.errors) ? err.errors.map(flattenError).join(", ") : "cause" in err && err.cause instanceof Error ? `${err}: ${flattenError(err.cause)}` : err.message : `${err}`;
|
|
41282
|
-
}
|
|
41283
|
-
function inspectableError(err) {
|
|
41284
|
-
return {
|
|
41285
|
-
type: err.type,
|
|
41286
|
-
message: err.message,
|
|
41287
|
-
code: err.code,
|
|
41288
|
-
defaultPrevented: err.defaultPrevented,
|
|
41289
|
-
cancelable: err.cancelable,
|
|
41290
|
-
timeStamp: err.timeStamp
|
|
41291
|
-
};
|
|
41292
|
-
}
|
|
41293
|
-
var __typeError = (msg) => {
|
|
41294
|
-
throw TypeError(msg);
|
|
41295
|
-
}, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method), _readyState, _url, _redirectUrl, _withCredentials, _fetch, _reconnectInterval, _reconnectTimer, _lastEventId, _controller, _parser, _onError, _onMessage, _onOpen, _EventSource_instances, connect_fn, _onFetchResponse, _onFetchError, getRequestOptions_fn, _onEvent, _onRetryChange, failConnection_fn, scheduleReconnect_fn, _reconnect;
|
|
41296
|
-
class EventSource extends EventTarget {
|
|
41297
|
-
constructor(url2, eventSourceInitDict) {
|
|
41298
|
-
var _a10, _b9;
|
|
41299
|
-
super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
|
|
41300
|
-
var _a22;
|
|
41301
|
-
__privateGet(this, _parser).reset();
|
|
41302
|
-
const { body, redirected, status, headers } = response;
|
|
41303
|
-
if (status === 204) {
|
|
41304
|
-
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
|
|
41305
|
-
return;
|
|
41306
|
-
}
|
|
41307
|
-
if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
|
|
41308
|
-
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
|
|
41309
|
-
return;
|
|
41310
|
-
}
|
|
41311
|
-
if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
|
|
41312
|
-
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
|
|
41313
|
-
return;
|
|
41314
|
-
}
|
|
41315
|
-
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
41316
|
-
return;
|
|
41317
|
-
__privateSet(this, _readyState, this.OPEN);
|
|
41318
|
-
const openEvent = new Event("open");
|
|
41319
|
-
if ((_a22 = __privateGet(this, _onOpen)) == null || _a22.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
|
|
41320
|
-
__privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
|
|
41321
|
-
return;
|
|
41322
|
-
}
|
|
41323
|
-
const decoder = new TextDecoder(), reader = body.getReader();
|
|
41324
|
-
let open = true;
|
|
41325
|
-
do {
|
|
41326
|
-
const { done, value } = await reader.read();
|
|
41327
|
-
value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
|
|
41328
|
-
} while (open);
|
|
41329
|
-
}), __privateAdd(this, _onFetchError, (err) => {
|
|
41330
|
-
__privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
|
|
41331
|
-
}), __privateAdd(this, _onEvent, (event) => {
|
|
41332
|
-
typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
|
|
41333
|
-
const messageEvent = new MessageEvent(event.event || "message", {
|
|
41334
|
-
data: event.data,
|
|
41335
|
-
origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,
|
|
41336
|
-
lastEventId: event.id || ""
|
|
41337
|
-
});
|
|
41338
|
-
__privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
|
|
41339
|
-
}), __privateAdd(this, _onRetryChange, (value) => {
|
|
41340
|
-
__privateSet(this, _reconnectInterval, value);
|
|
41341
|
-
}), __privateAdd(this, _reconnect, () => {
|
|
41342
|
-
__privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
41343
|
-
});
|
|
41344
|
-
try {
|
|
41345
|
-
if (url2 instanceof URL)
|
|
41346
|
-
__privateSet(this, _url, url2);
|
|
41347
|
-
else if (typeof url2 == "string")
|
|
41348
|
-
__privateSet(this, _url, new URL(url2, getBaseURL()));
|
|
41349
|
-
else
|
|
41350
|
-
throw new Error("Invalid URL");
|
|
41351
|
-
} catch {
|
|
41352
|
-
throw syntaxError("An invalid or illegal string was specified");
|
|
41353
|
-
}
|
|
41354
|
-
__privateSet(this, _parser, createParser({
|
|
41355
|
-
onEvent: __privateGet(this, _onEvent),
|
|
41356
|
-
onRetry: __privateGet(this, _onRetryChange)
|
|
41357
|
-
})), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a10 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a10 : globalThis.fetch), __privateSet(this, _withCredentials, (_b9 = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b9 : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
|
|
41358
|
-
}
|
|
41359
|
-
/**
|
|
41360
|
-
* Returns the state of this EventSource object's connection. It can have the values described below.
|
|
41361
|
-
*
|
|
41362
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
|
|
41363
|
-
*
|
|
41364
|
-
* Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
|
|
41365
|
-
* defined in the TypeScript `dom` library.
|
|
41366
|
-
*
|
|
41367
|
-
* @public
|
|
41368
|
-
*/
|
|
41369
|
-
get readyState() {
|
|
41370
|
-
return __privateGet(this, _readyState);
|
|
41371
|
-
}
|
|
41372
|
-
/**
|
|
41373
|
-
* Returns the URL providing the event stream.
|
|
41374
|
-
*
|
|
41375
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
|
|
41376
|
-
*
|
|
41377
|
-
* @public
|
|
41378
|
-
*/
|
|
41379
|
-
get url() {
|
|
41380
|
-
return __privateGet(this, _url).href;
|
|
41381
|
-
}
|
|
41382
|
-
/**
|
|
41383
|
-
* Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
|
|
41384
|
-
*
|
|
41385
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
|
|
41386
|
-
*/
|
|
41387
|
-
get withCredentials() {
|
|
41388
|
-
return __privateGet(this, _withCredentials);
|
|
41389
|
-
}
|
|
41390
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
|
|
41391
|
-
get onerror() {
|
|
41392
|
-
return __privateGet(this, _onError);
|
|
41393
|
-
}
|
|
41394
|
-
set onerror(value) {
|
|
41395
|
-
__privateSet(this, _onError, value);
|
|
41396
|
-
}
|
|
41397
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
|
|
41398
|
-
get onmessage() {
|
|
41399
|
-
return __privateGet(this, _onMessage);
|
|
41400
|
-
}
|
|
41401
|
-
set onmessage(value) {
|
|
41402
|
-
__privateSet(this, _onMessage, value);
|
|
41403
|
-
}
|
|
41404
|
-
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
|
|
41405
|
-
get onopen() {
|
|
41406
|
-
return __privateGet(this, _onOpen);
|
|
41407
|
-
}
|
|
41408
|
-
set onopen(value) {
|
|
41409
|
-
__privateSet(this, _onOpen, value);
|
|
41410
|
-
}
|
|
41411
|
-
addEventListener(type2, listener, options) {
|
|
41412
|
-
const listen = listener;
|
|
41413
|
-
super.addEventListener(type2, listen, options);
|
|
41414
|
-
}
|
|
41415
|
-
removeEventListener(type2, listener, options) {
|
|
41416
|
-
const listen = listener;
|
|
41417
|
-
super.removeEventListener(type2, listen, options);
|
|
41418
|
-
}
|
|
41419
|
-
/**
|
|
41420
|
-
* Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
|
|
41421
|
-
*
|
|
41422
|
-
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
|
|
41423
|
-
*
|
|
41424
|
-
* @public
|
|
41425
|
-
*/
|
|
41426
|
-
close() {
|
|
41427
|
-
__privateGet(this, _reconnectTimer) && clearTimeout(__privateGet(this, _reconnectTimer)), __privateGet(this, _readyState) !== this.CLOSED && (__privateGet(this, _controller) && __privateGet(this, _controller).abort(), __privateSet(this, _readyState, this.CLOSED), __privateSet(this, _controller, void 0));
|
|
41428
|
-
}
|
|
41429
|
-
}
|
|
41430
|
-
_readyState = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _redirectUrl = /* @__PURE__ */ new WeakMap(), _withCredentials = /* @__PURE__ */ new WeakMap(), _fetch = /* @__PURE__ */ new WeakMap(), _reconnectInterval = /* @__PURE__ */ new WeakMap(), _reconnectTimer = /* @__PURE__ */ new WeakMap(), _lastEventId = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _parser = /* @__PURE__ */ new WeakMap(), _onError = /* @__PURE__ */ new WeakMap(), _onMessage = /* @__PURE__ */ new WeakMap(), _onOpen = /* @__PURE__ */ new WeakMap(), _EventSource_instances = /* @__PURE__ */ new WeakSet(), /**
|
|
41431
|
-
* Connect to the given URL and start receiving events
|
|
41432
|
-
*
|
|
41433
|
-
* @internal
|
|
41434
|
-
*/
|
|
41435
|
-
connect_fn = function() {
|
|
41436
|
-
__privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _controller, new AbortController()), __privateGet(this, _fetch)(__privateGet(this, _url), __privateMethod(this, _EventSource_instances, getRequestOptions_fn).call(this)).then(__privateGet(this, _onFetchResponse)).catch(__privateGet(this, _onFetchError));
|
|
41437
|
-
}, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
|
|
41438
|
-
* Get request options for the `fetch()` request
|
|
41439
|
-
*
|
|
41440
|
-
* @returns The request options
|
|
41441
|
-
* @internal
|
|
41442
|
-
*/
|
|
41443
|
-
getRequestOptions_fn = function() {
|
|
41444
|
-
var _a10;
|
|
41445
|
-
const init = {
|
|
41446
|
-
// [spec] Let `corsAttributeState` be `Anonymous`…
|
|
41447
|
-
// [spec] …will have their mode set to "cors"…
|
|
41448
|
-
mode: "cors",
|
|
41449
|
-
redirect: "follow",
|
|
41450
|
-
headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
|
|
41451
|
-
cache: "no-store",
|
|
41452
|
-
signal: (_a10 = __privateGet(this, _controller)) == null ? void 0 : _a10.signal
|
|
41453
|
-
};
|
|
41454
|
-
return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
|
|
41455
|
-
}, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
|
|
41456
|
-
* Handles the process referred to in the EventSource specification as "failing a connection".
|
|
41457
|
-
*
|
|
41458
|
-
* @param error - The error causing the connection to fail
|
|
41459
|
-
* @param code - The HTTP status code, if available
|
|
41460
|
-
* @internal
|
|
41461
|
-
*/
|
|
41462
|
-
failConnection_fn = function(message, code2) {
|
|
41463
|
-
var _a10;
|
|
41464
|
-
__privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
|
|
41465
|
-
const errorEvent = new ErrorEvent("error", { code: code2, message });
|
|
41466
|
-
(_a10 = __privateGet(this, _onError)) == null || _a10.call(this, errorEvent), this.dispatchEvent(errorEvent);
|
|
41467
|
-
}, /**
|
|
41468
|
-
* Schedules a reconnection attempt against the EventSource endpoint.
|
|
41469
|
-
*
|
|
41470
|
-
* @param message - The error causing the connection to fail
|
|
41471
|
-
* @param code - The HTTP status code, if available
|
|
41472
|
-
* @internal
|
|
41473
|
-
*/
|
|
41474
|
-
scheduleReconnect_fn = function(message, code2) {
|
|
41475
|
-
var _a10;
|
|
41476
|
-
if (__privateGet(this, _readyState) === this.CLOSED)
|
|
41477
|
-
return;
|
|
41478
|
-
__privateSet(this, _readyState, this.CONNECTING);
|
|
41479
|
-
const errorEvent = new ErrorEvent("error", { code: code2, message });
|
|
41480
|
-
(_a10 = __privateGet(this, _onError)) == null || _a10.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
|
|
41481
|
-
}, _reconnect = /* @__PURE__ */ new WeakMap(), /**
|
|
41482
|
-
* ReadyState representing an EventSource currently trying to connect
|
|
41483
|
-
*
|
|
41484
|
-
* @public
|
|
41485
|
-
*/
|
|
41486
|
-
EventSource.CONNECTING = 0, /**
|
|
41487
|
-
* ReadyState representing an EventSource connection that is open (eg connected)
|
|
41488
|
-
*
|
|
41489
|
-
* @public
|
|
41490
|
-
*/
|
|
41491
|
-
EventSource.OPEN = 1, /**
|
|
41492
|
-
* ReadyState representing an EventSource connection that is closed (eg disconnected)
|
|
41493
|
-
*
|
|
41494
|
-
* @public
|
|
41495
|
-
*/
|
|
41496
|
-
EventSource.CLOSED = 2;
|
|
41497
|
-
function getBaseURL() {
|
|
41498
|
-
const doc = "document" in globalThis ? globalThis.document : void 0;
|
|
41499
|
-
return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
|
|
41500
|
-
}
|
|
41501
|
-
class SseError extends Error {
|
|
41502
|
-
constructor(code2, message, event) {
|
|
41503
|
-
super(`SSE error: ${message}`);
|
|
41504
|
-
this.code = code2;
|
|
41505
|
-
this.event = event;
|
|
41506
|
-
}
|
|
41507
|
-
}
|
|
41508
|
-
class SSEClientTransport {
|
|
41509
|
-
constructor(url2, opts) {
|
|
41510
|
-
this._url = url2;
|
|
41511
|
-
this._resourceMetadataUrl = void 0;
|
|
41512
|
-
this._scope = void 0;
|
|
41513
|
-
this._eventSourceInit = opts?.eventSourceInit;
|
|
41514
|
-
this._requestInit = opts?.requestInit;
|
|
41515
|
-
this._authProvider = opts?.authProvider;
|
|
41516
|
-
this._fetch = opts?.fetch;
|
|
41517
|
-
this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
|
|
41518
|
-
}
|
|
41519
|
-
async _authThenStart() {
|
|
41520
|
-
if (!this._authProvider) {
|
|
41521
|
-
throw new UnauthorizedError("No auth provider");
|
|
41522
|
-
}
|
|
41523
|
-
let result;
|
|
41524
|
-
try {
|
|
41525
|
-
result = await auth(this._authProvider, {
|
|
41526
|
-
serverUrl: this._url,
|
|
41527
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
41528
|
-
scope: this._scope,
|
|
41529
|
-
fetchFn: this._fetchWithInit
|
|
41530
|
-
});
|
|
41531
|
-
} catch (error) {
|
|
41532
|
-
this.onerror?.(error);
|
|
41533
|
-
throw error;
|
|
41534
|
-
}
|
|
41535
|
-
if (result !== "AUTHORIZED") {
|
|
41536
|
-
throw new UnauthorizedError();
|
|
41537
|
-
}
|
|
41538
|
-
return await this._startOrAuth();
|
|
41539
|
-
}
|
|
41540
|
-
async _commonHeaders() {
|
|
41541
|
-
const headers = {};
|
|
41542
|
-
if (this._authProvider) {
|
|
41543
|
-
const tokens = await this._authProvider.tokens();
|
|
41544
|
-
if (tokens) {
|
|
41545
|
-
headers["Authorization"] = `Bearer ${tokens.access_token}`;
|
|
41546
|
-
}
|
|
41547
|
-
}
|
|
41548
|
-
if (this._protocolVersion) {
|
|
41549
|
-
headers["mcp-protocol-version"] = this._protocolVersion;
|
|
41550
|
-
}
|
|
41551
|
-
const extraHeaders = normalizeHeaders$1(this._requestInit?.headers);
|
|
41552
|
-
return new Headers({
|
|
41553
|
-
...headers,
|
|
41554
|
-
...extraHeaders
|
|
41555
|
-
});
|
|
41556
|
-
}
|
|
41557
|
-
_startOrAuth() {
|
|
41558
|
-
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
41559
|
-
return new Promise((resolve2, reject) => {
|
|
41560
|
-
this._eventSource = new EventSource(this._url.href, {
|
|
41561
|
-
...this._eventSourceInit,
|
|
41562
|
-
fetch: async (url2, init) => {
|
|
41563
|
-
const headers = await this._commonHeaders();
|
|
41564
|
-
headers.set("Accept", "text/event-stream");
|
|
41565
|
-
const response = await fetchImpl(url2, {
|
|
41566
|
-
...init,
|
|
41567
|
-
headers
|
|
41568
|
-
});
|
|
41569
|
-
if (response.status === 401 && response.headers.has("www-authenticate")) {
|
|
41570
|
-
const { resourceMetadataUrl, scope: scope2 } = extractWWWAuthenticateParams(response);
|
|
41571
|
-
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
41572
|
-
this._scope = scope2;
|
|
41573
|
-
}
|
|
41574
|
-
return response;
|
|
41575
|
-
}
|
|
41576
|
-
});
|
|
41577
|
-
this._abortController = new AbortController();
|
|
41578
|
-
this._eventSource.onerror = (event) => {
|
|
41579
|
-
if (event.code === 401 && this._authProvider) {
|
|
41580
|
-
this._authThenStart().then(resolve2, reject);
|
|
41581
|
-
return;
|
|
41582
|
-
}
|
|
41583
|
-
const error = new SseError(event.code, event.message, event);
|
|
41584
|
-
reject(error);
|
|
41585
|
-
this.onerror?.(error);
|
|
41586
|
-
};
|
|
41587
|
-
this._eventSource.onopen = () => {
|
|
41588
|
-
};
|
|
41589
|
-
this._eventSource.addEventListener("endpoint", (event) => {
|
|
41590
|
-
const messageEvent = event;
|
|
41591
|
-
try {
|
|
41592
|
-
this._endpoint = new URL(messageEvent.data, this._url);
|
|
41593
|
-
if (this._endpoint.origin !== this._url.origin) {
|
|
41594
|
-
throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
|
|
41595
|
-
}
|
|
41596
|
-
} catch (error) {
|
|
41597
|
-
reject(error);
|
|
41598
|
-
this.onerror?.(error);
|
|
41599
|
-
void this.close();
|
|
41600
|
-
return;
|
|
41601
|
-
}
|
|
41602
|
-
resolve2();
|
|
41603
|
-
});
|
|
41604
|
-
this._eventSource.onmessage = (event) => {
|
|
41605
|
-
const messageEvent = event;
|
|
41606
|
-
let message;
|
|
41607
|
-
try {
|
|
41608
|
-
message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
|
|
41609
|
-
} catch (error) {
|
|
41610
|
-
this.onerror?.(error);
|
|
41611
|
-
return;
|
|
41612
|
-
}
|
|
41613
|
-
this.onmessage?.(message);
|
|
41614
|
-
};
|
|
41615
|
-
});
|
|
41616
|
-
}
|
|
41617
|
-
async start() {
|
|
41618
|
-
if (this._eventSource) {
|
|
41619
|
-
throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
41620
|
-
}
|
|
41621
|
-
return await this._startOrAuth();
|
|
41622
|
-
}
|
|
41623
|
-
/**
|
|
41624
|
-
* Call this method after the user has finished authorizing via their user agent and is redirected back to the MCP client application. This will exchange the authorization code for an access token, enabling the next connection attempt to successfully auth.
|
|
41625
|
-
*/
|
|
41626
|
-
async finishAuth(authorizationCode) {
|
|
41627
|
-
if (!this._authProvider) {
|
|
41628
|
-
throw new UnauthorizedError("No auth provider");
|
|
41629
|
-
}
|
|
41630
|
-
const result = await auth(this._authProvider, {
|
|
41631
|
-
serverUrl: this._url,
|
|
41632
|
-
authorizationCode,
|
|
41633
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
41634
|
-
scope: this._scope,
|
|
41635
|
-
fetchFn: this._fetchWithInit
|
|
41636
|
-
});
|
|
41637
|
-
if (result !== "AUTHORIZED") {
|
|
41638
|
-
throw new UnauthorizedError("Failed to authorize");
|
|
41639
|
-
}
|
|
41640
|
-
}
|
|
41641
|
-
async close() {
|
|
41642
|
-
this._abortController?.abort();
|
|
41643
|
-
this._eventSource?.close();
|
|
41644
|
-
this.onclose?.();
|
|
41645
|
-
}
|
|
41646
|
-
async send(message) {
|
|
41647
|
-
if (!this._endpoint) {
|
|
41648
|
-
throw new Error("Not connected");
|
|
41649
|
-
}
|
|
41650
|
-
try {
|
|
41651
|
-
const headers = await this._commonHeaders();
|
|
41652
|
-
headers.set("content-type", "application/json");
|
|
41653
|
-
const init = {
|
|
41654
|
-
...this._requestInit,
|
|
41655
|
-
method: "POST",
|
|
41656
|
-
headers,
|
|
41657
|
-
body: JSON.stringify(message),
|
|
41658
|
-
signal: this._abortController?.signal
|
|
41659
|
-
};
|
|
41660
|
-
const response = await (this._fetch ?? fetch)(this._endpoint, init);
|
|
41661
|
-
if (!response.ok) {
|
|
41662
|
-
const text2 = await response.text().catch(() => null);
|
|
41663
|
-
if (response.status === 401 && this._authProvider) {
|
|
41664
|
-
const { resourceMetadataUrl, scope: scope2 } = extractWWWAuthenticateParams(response);
|
|
41665
|
-
this._resourceMetadataUrl = resourceMetadataUrl;
|
|
41666
|
-
this._scope = scope2;
|
|
41667
|
-
const result = await auth(this._authProvider, {
|
|
41668
|
-
serverUrl: this._url,
|
|
41669
|
-
resourceMetadataUrl: this._resourceMetadataUrl,
|
|
41670
|
-
scope: this._scope,
|
|
41671
|
-
fetchFn: this._fetchWithInit
|
|
41672
|
-
});
|
|
41673
|
-
if (result !== "AUTHORIZED") {
|
|
41674
|
-
throw new UnauthorizedError();
|
|
41675
|
-
}
|
|
41676
|
-
return this.send(message);
|
|
41677
|
-
}
|
|
41678
|
-
throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text2}`);
|
|
41679
|
-
}
|
|
41680
|
-
await response.body?.cancel();
|
|
41681
|
-
} catch (error) {
|
|
41682
|
-
this.onerror?.(error);
|
|
41683
|
-
throw error;
|
|
41684
|
-
}
|
|
41685
|
-
}
|
|
41686
|
-
setProtocolVersion(version2) {
|
|
41687
|
-
this._protocolVersion = version2;
|
|
41688
|
-
}
|
|
41689
|
-
}
|
|
41690
42325
|
const SUBPROTOCOL = "mcp";
|
|
41691
42326
|
class WebSocketClientTransport {
|
|
41692
42327
|
constructor(url2) {
|
|
@@ -42938,7 +43573,13 @@ Thought: 用户想要获取今天的日期,我需要调用日期相关的工
|
|
|
42938
43573
|
try {
|
|
42939
43574
|
let transport;
|
|
42940
43575
|
if ("type" in serverConfig && serverConfig.type.toLocaleLowerCase() === "streamablehttp") {
|
|
42941
|
-
|
|
43576
|
+
const configWithHeaders = serverConfig;
|
|
43577
|
+
const requestInit = configWithHeaders.headers ? { headers: configWithHeaders.headers } : void 0;
|
|
43578
|
+
transport = new StreamableHTTPClientTransport(new URL(configWithHeaders.url), { requestInit });
|
|
43579
|
+
} else if ("type" in serverConfig && serverConfig.type === "sse") {
|
|
43580
|
+
const configWithHeaders = serverConfig;
|
|
43581
|
+
const requestInit = configWithHeaders.headers ? { headers: configWithHeaders.headers } : void 0;
|
|
43582
|
+
transport = new SSEClientTransport(new URL(configWithHeaders.url), { requestInit });
|
|
42942
43583
|
} else if ("type" in serverConfig && serverConfig.type === "extension") {
|
|
42943
43584
|
transport = new ExtensionClientTransport(serverConfig.sessionId);
|
|
42944
43585
|
} else if ("transport" in serverConfig) {
|
|
@@ -43050,6 +43691,11 @@ Thought: 用户想要获取今天的日期,我需要调用日期相关的工
|
|
|
43050
43691
|
await this._createMpcTools();
|
|
43051
43692
|
this.onUpdatedTools?.();
|
|
43052
43693
|
}
|
|
43694
|
+
/** 仅刷新已连接 clients 的 tools(不重建 client,适合工具目录动态变化场景) */
|
|
43695
|
+
async refreshTools() {
|
|
43696
|
+
await this._createMpcTools();
|
|
43697
|
+
this.onUpdatedTools?.();
|
|
43698
|
+
}
|
|
43053
43699
|
/** 全量更新所有的 mcpServers */
|
|
43054
43700
|
async updateMcpServers(mcpServers) {
|
|
43055
43701
|
await this.closeAll();
|
|
@@ -43455,13 +44101,37 @@ ${observationText}
|
|
|
43455
44101
|
throw new Error("LLM is not initialized");
|
|
43456
44102
|
}
|
|
43457
44103
|
await this.initClientsAndTools();
|
|
43458
|
-
const
|
|
44104
|
+
const extraTools = options.tools || {};
|
|
44105
|
+
const allTools = this._tempMergeTools(extraTools, false);
|
|
44106
|
+
const syncToolsForStep = () => {
|
|
44107
|
+
const latestTools = this._tempMergeTools(extraTools, false);
|
|
44108
|
+
Object.entries(latestTools).forEach(([name16, tool2]) => {
|
|
44109
|
+
allTools[name16] = tool2;
|
|
44110
|
+
});
|
|
44111
|
+
Object.keys(allTools).forEach((name16) => {
|
|
44112
|
+
if (!(name16 in latestTools)) {
|
|
44113
|
+
delete allTools[name16];
|
|
44114
|
+
}
|
|
44115
|
+
});
|
|
44116
|
+
};
|
|
44117
|
+
const userPrepareStep = options.prepareStep;
|
|
44118
|
+
const wrappedPrepareStep = async (stepOptions) => {
|
|
44119
|
+
syncToolsForStep();
|
|
44120
|
+
const latestActiveTools = this._getActiveToolNames(allTools);
|
|
44121
|
+
const userStepPatch = typeof userPrepareStep === "function" ? await userPrepareStep(stepOptions) : void 0;
|
|
44122
|
+
const safeUserStepPatch = userStepPatch && typeof userStepPatch === "object" ? userStepPatch : {};
|
|
44123
|
+
return {
|
|
44124
|
+
...safeUserStepPatch,
|
|
44125
|
+
activeTools: Array.isArray(safeUserStepPatch.activeTools) ? safeUserStepPatch.activeTools.filter((name16) => latestActiveTools.includes(name16)) : latestActiveTools
|
|
44126
|
+
};
|
|
44127
|
+
};
|
|
43459
44128
|
const chatOptions = {
|
|
43460
44129
|
// @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
|
|
43461
44130
|
model: this.llm(model),
|
|
43462
44131
|
stopWhen: stepCountIs(maxSteps),
|
|
43463
44132
|
...options,
|
|
43464
44133
|
tools: allTools,
|
|
44134
|
+
prepareStep: wrappedPrepareStep,
|
|
43465
44135
|
activeTools: this._getActiveToolNames(allTools)
|
|
43466
44136
|
};
|
|
43467
44137
|
let lastUserMessage = null;
|
|
@@ -45960,27 +46630,27 @@ ${observationText}
|
|
|
45960
46630
|
}
|
|
45961
46631
|
/**
|
|
45962
46632
|
* 合并菜单项配置。
|
|
45963
|
-
* -
|
|
45964
|
-
* -
|
|
46633
|
+
* - 用户明确传入 menuItems:直接使用用户配置,不受 sessionId 限制;未传 icon 时自动补充默认图标
|
|
46634
|
+
* - 有 sessionId 且未传 menuItems:使用默认菜单
|
|
46635
|
+
* - 无 sessionId 且未传 menuItems:不渲染任何下拉菜单,仅保留点击浮标打开对话框的能力
|
|
45965
46636
|
*/
|
|
45966
46637
|
mergeMenuItems(userMenuItems) {
|
|
46638
|
+
const defaultIcons = {
|
|
46639
|
+
"qr-code": qrCode,
|
|
46640
|
+
"ai-chat": chat,
|
|
46641
|
+
"remote-url": link,
|
|
46642
|
+
"remote-control": scan
|
|
46643
|
+
};
|
|
46644
|
+
if (userMenuItems) {
|
|
46645
|
+
return userMenuItems.map((item) => ({
|
|
46646
|
+
...item,
|
|
46647
|
+
icon: item.icon ?? defaultIcons[item.action]
|
|
46648
|
+
}));
|
|
46649
|
+
}
|
|
45967
46650
|
if (!this.options.sessionId) {
|
|
45968
46651
|
return [];
|
|
45969
46652
|
}
|
|
45970
|
-
|
|
45971
|
-
return getDefaultMenuItems(this.options);
|
|
45972
|
-
}
|
|
45973
|
-
return getDefaultMenuItems(this.options).map((defaultItem) => {
|
|
45974
|
-
const userItem = userMenuItems.find((item) => item.action === defaultItem.action);
|
|
45975
|
-
if (userItem) {
|
|
45976
|
-
return {
|
|
45977
|
-
...defaultItem,
|
|
45978
|
-
...userItem,
|
|
45979
|
-
show: userItem.show !== void 0 ? userItem.show : defaultItem.show
|
|
45980
|
-
};
|
|
45981
|
-
}
|
|
45982
|
-
return defaultItem;
|
|
45983
|
-
});
|
|
46653
|
+
return getDefaultMenuItems(this.options);
|
|
45984
46654
|
}
|
|
45985
46655
|
init() {
|
|
45986
46656
|
this.createFloatingBlock();
|
|
@@ -46011,7 +46681,7 @@ ${observationText}
|
|
|
46011
46681
|
<div class="tiny-remoter-dropdown-item__content">
|
|
46012
46682
|
<div title="${item.tip}">${item.text}</div>
|
|
46013
46683
|
<div class="tiny-remoter-dropdown-item__desc-wrapper">
|
|
46014
|
-
<div class="tiny-remoter-dropdown-item__desc ${item.active ? "tiny-remoter-dropdown-item__desc--active" : ""} ${item.know ? "tiny-remoter-dropdown-item__desc--know" : ""}">${item.desc}</div>
|
|
46684
|
+
<div class="tiny-remoter-dropdown-item__desc ${item.active ? "tiny-remoter-dropdown-item__desc--active" : ""} ${item.know ? "tiny-remoter-dropdown-item__desc--know" : ""}">${item.desc ?? ""}</div>
|
|
46015
46685
|
<div>
|
|
46016
46686
|
${item.showCopyIcon ? `
|
|
46017
46687
|
<div class="tiny-remoter-copy-icon" id="${item.action}" data-action="${item.action}">
|
|
@@ -46119,12 +46789,20 @@ ${observationText}
|
|
|
46119
46789
|
this.closeDropdown();
|
|
46120
46790
|
}
|
|
46121
46791
|
copyRemoteControl() {
|
|
46122
|
-
|
|
46123
|
-
this.
|
|
46792
|
+
const menuItem = this.menuItems.find((item) => item.action === "remote-control");
|
|
46793
|
+
const codeToCopy = menuItem?.desc || menuItem?.text || (this.options.sessionId ? this.options.sessionId.slice(-6) : "");
|
|
46794
|
+
if (codeToCopy) {
|
|
46795
|
+
this.copyToClipboard(codeToCopy);
|
|
46796
|
+
}
|
|
46124
46797
|
}
|
|
46125
46798
|
copyRemoteURL() {
|
|
46126
|
-
|
|
46127
|
-
this.
|
|
46799
|
+
const menuItem = this.menuItems.find((item) => item.action === "remote-url");
|
|
46800
|
+
const sessionUrl = this.options.sessionId ? this.options.remoteUrl + this.sessionPrefix + this.options.sessionId : "";
|
|
46801
|
+
const customDesc = menuItem?.desc && menuItem.desc !== this.options.remoteUrl ? menuItem.desc : void 0;
|
|
46802
|
+
const urlToCopy = customDesc || sessionUrl || menuItem?.text || "";
|
|
46803
|
+
if (urlToCopy) {
|
|
46804
|
+
this.copyToClipboard(urlToCopy);
|
|
46805
|
+
}
|
|
46128
46806
|
}
|
|
46129
46807
|
// 实现复制到剪贴板功能
|
|
46130
46808
|
async copyToClipboard(text2) {
|