@opentiny/next-sdk 0.2.6 → 0.2.8
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/agent/AgentModelProvider.ts +22 -10
- package/agent/utils/generateReActPrompt.ts +36 -20
- package/dist/agent/AgentModelProvider.d.ts +3 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.es.dev.js +1138 -116
- package/dist/index.es.js +15866 -15040
- package/dist/index.js +2574 -2150
- package/dist/index.umd.dev.js +1138 -116
- package/dist/index.umd.js +254 -84
- package/dist/page-tools/bridge.d.ts +101 -0
- package/dist/page-tools/effects.d.ts +36 -0
- package/dist/remoter/createRemoter.d.ts +7 -5
- package/dist/skills/index.d.ts +7 -1
- package/dist/webagent.dev.js +586 -99
- package/dist/webagent.es.dev.js +586 -99
- package/dist/webagent.es.js +10799 -10378
- package/dist/webagent.js +76 -74
- package/index.ts +3 -0
- package/package.json +1 -1
- package/page-tools/bridge.ts +382 -0
- package/page-tools/effects.ts +343 -0
- package/remoter/createRemoter.ts +37 -16
- package/skills/index.ts +146 -19
package/dist/webagent.dev.js
CHANGED
|
@@ -8169,25 +8169,30 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8169
8169
|
}
|
|
8170
8170
|
function createToolNameMapping({
|
|
8171
8171
|
tools = [],
|
|
8172
|
-
providerToolNames
|
|
8172
|
+
providerToolNames,
|
|
8173
|
+
resolveProviderToolName
|
|
8173
8174
|
}) {
|
|
8175
|
+
var _a22;
|
|
8174
8176
|
const customToolNameToProviderToolName = {};
|
|
8175
8177
|
const providerToolNameToCustomToolName = {};
|
|
8176
8178
|
for (const tool2 of tools) {
|
|
8177
|
-
if (tool2.type === "provider"
|
|
8178
|
-
const providerToolName = providerToolNames[tool2.id];
|
|
8179
|
+
if (tool2.type === "provider") {
|
|
8180
|
+
const providerToolName = (_a22 = resolveProviderToolName == null ? void 0 : resolveProviderToolName(tool2)) != null ? _a22 : tool2.id in providerToolNames ? providerToolNames[tool2.id] : void 0;
|
|
8181
|
+
if (providerToolName == null) {
|
|
8182
|
+
continue;
|
|
8183
|
+
}
|
|
8179
8184
|
customToolNameToProviderToolName[tool2.name] = providerToolName;
|
|
8180
8185
|
providerToolNameToCustomToolName[providerToolName] = tool2.name;
|
|
8181
8186
|
}
|
|
8182
8187
|
}
|
|
8183
8188
|
return {
|
|
8184
8189
|
toProviderToolName: (customToolName) => {
|
|
8185
|
-
var
|
|
8186
|
-
return (
|
|
8190
|
+
var _a32;
|
|
8191
|
+
return (_a32 = customToolNameToProviderToolName[customToolName]) != null ? _a32 : customToolName;
|
|
8187
8192
|
},
|
|
8188
8193
|
toCustomToolName: (providerToolName) => {
|
|
8189
|
-
var
|
|
8190
|
-
return (
|
|
8194
|
+
var _a32;
|
|
8195
|
+
return (_a32 = providerToolNameToCustomToolName[providerToolName]) != null ? _a32 : providerToolName;
|
|
8191
8196
|
}
|
|
8192
8197
|
};
|
|
8193
8198
|
}
|
|
@@ -8380,8 +8385,103 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8380
8385
|
}
|
|
8381
8386
|
return result;
|
|
8382
8387
|
}
|
|
8388
|
+
function validateDownloadUrl(url2) {
|
|
8389
|
+
let parsed;
|
|
8390
|
+
try {
|
|
8391
|
+
parsed = new URL(url2);
|
|
8392
|
+
} catch (e) {
|
|
8393
|
+
throw new DownloadError({
|
|
8394
|
+
url: url2,
|
|
8395
|
+
message: `Invalid URL: ${url2}`
|
|
8396
|
+
});
|
|
8397
|
+
}
|
|
8398
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
8399
|
+
throw new DownloadError({
|
|
8400
|
+
url: url2,
|
|
8401
|
+
message: `URL scheme must be http or https, got ${parsed.protocol}`
|
|
8402
|
+
});
|
|
8403
|
+
}
|
|
8404
|
+
const hostname2 = parsed.hostname;
|
|
8405
|
+
if (!hostname2) {
|
|
8406
|
+
throw new DownloadError({
|
|
8407
|
+
url: url2,
|
|
8408
|
+
message: `URL must have a hostname`
|
|
8409
|
+
});
|
|
8410
|
+
}
|
|
8411
|
+
if (hostname2 === "localhost" || hostname2.endsWith(".local") || hostname2.endsWith(".localhost")) {
|
|
8412
|
+
throw new DownloadError({
|
|
8413
|
+
url: url2,
|
|
8414
|
+
message: `URL with hostname ${hostname2} is not allowed`
|
|
8415
|
+
});
|
|
8416
|
+
}
|
|
8417
|
+
if (hostname2.startsWith("[") && hostname2.endsWith("]")) {
|
|
8418
|
+
const ipv62 = hostname2.slice(1, -1);
|
|
8419
|
+
if (isPrivateIPv6(ipv62)) {
|
|
8420
|
+
throw new DownloadError({
|
|
8421
|
+
url: url2,
|
|
8422
|
+
message: `URL with IPv6 address ${hostname2} is not allowed`
|
|
8423
|
+
});
|
|
8424
|
+
}
|
|
8425
|
+
return;
|
|
8426
|
+
}
|
|
8427
|
+
if (isIPv4(hostname2)) {
|
|
8428
|
+
if (isPrivateIPv4(hostname2)) {
|
|
8429
|
+
throw new DownloadError({
|
|
8430
|
+
url: url2,
|
|
8431
|
+
message: `URL with IP address ${hostname2} is not allowed`
|
|
8432
|
+
});
|
|
8433
|
+
}
|
|
8434
|
+
return;
|
|
8435
|
+
}
|
|
8436
|
+
}
|
|
8437
|
+
function isIPv4(hostname2) {
|
|
8438
|
+
const parts = hostname2.split(".");
|
|
8439
|
+
if (parts.length !== 4) return false;
|
|
8440
|
+
return parts.every((part) => {
|
|
8441
|
+
const num = Number(part);
|
|
8442
|
+
return Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;
|
|
8443
|
+
});
|
|
8444
|
+
}
|
|
8445
|
+
function isPrivateIPv4(ip) {
|
|
8446
|
+
const parts = ip.split(".").map(Number);
|
|
8447
|
+
const [a, b] = parts;
|
|
8448
|
+
if (a === 0) return true;
|
|
8449
|
+
if (a === 10) return true;
|
|
8450
|
+
if (a === 127) return true;
|
|
8451
|
+
if (a === 169 && b === 254) return true;
|
|
8452
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
8453
|
+
if (a === 192 && b === 168) return true;
|
|
8454
|
+
return false;
|
|
8455
|
+
}
|
|
8456
|
+
function isPrivateIPv6(ip) {
|
|
8457
|
+
const normalized = ip.toLowerCase();
|
|
8458
|
+
if (normalized === "::1") return true;
|
|
8459
|
+
if (normalized === "::") return true;
|
|
8460
|
+
if (normalized.startsWith("::ffff:")) {
|
|
8461
|
+
const mappedPart = normalized.slice(7);
|
|
8462
|
+
if (isIPv4(mappedPart)) {
|
|
8463
|
+
return isPrivateIPv4(mappedPart);
|
|
8464
|
+
}
|
|
8465
|
+
const hexParts = mappedPart.split(":");
|
|
8466
|
+
if (hexParts.length === 2) {
|
|
8467
|
+
const high = parseInt(hexParts[0], 16);
|
|
8468
|
+
const low = parseInt(hexParts[1], 16);
|
|
8469
|
+
if (!isNaN(high) && !isNaN(low)) {
|
|
8470
|
+
const a = high >> 8 & 255;
|
|
8471
|
+
const b = high & 255;
|
|
8472
|
+
const c = low >> 8 & 255;
|
|
8473
|
+
const d = low & 255;
|
|
8474
|
+
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
8475
|
+
}
|
|
8476
|
+
}
|
|
8477
|
+
}
|
|
8478
|
+
if (normalized.startsWith("fc") || normalized.startsWith("fd")) return true;
|
|
8479
|
+
if (normalized.startsWith("fe80")) return true;
|
|
8480
|
+
return false;
|
|
8481
|
+
}
|
|
8383
8482
|
async function downloadBlob(url2, options) {
|
|
8384
8483
|
var _a22, _b22;
|
|
8484
|
+
validateDownloadUrl(url2);
|
|
8385
8485
|
try {
|
|
8386
8486
|
const response = await fetch(url2, {
|
|
8387
8487
|
signal: options == null ? void 0 : options.abortSignal
|
|
@@ -8547,7 +8647,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8547
8647
|
);
|
|
8548
8648
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
8549
8649
|
}
|
|
8550
|
-
var VERSION$7 = "4.0.
|
|
8650
|
+
var VERSION$7 = "4.0.19";
|
|
8551
8651
|
var getOriginalFetch = () => globalThis.fetch;
|
|
8552
8652
|
var getFromApi = async ({
|
|
8553
8653
|
url: url2,
|
|
@@ -8690,8 +8790,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8690
8790
|
"x-m4a": "m4a"
|
|
8691
8791
|
}[subtype]) != null ? _a22 : subtype;
|
|
8692
8792
|
}
|
|
8693
|
-
var suspectProtoRx$1 = /"
|
|
8694
|
-
var suspectConstructorRx$1 = /"
|
|
8793
|
+
var suspectProtoRx$1 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
8794
|
+
var suspectConstructorRx$1 = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
8695
8795
|
function _parse$1(text2) {
|
|
8696
8796
|
const obj = JSON.parse(text2);
|
|
8697
8797
|
if (obj === null || typeof obj !== "object") {
|
|
@@ -8711,7 +8811,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
8711
8811
|
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
8712
8812
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
8713
8813
|
}
|
|
8714
|
-
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
8814
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
8715
8815
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
8716
8816
|
}
|
|
8717
8817
|
for (const key in node) {
|
|
@@ -10198,6 +10298,33 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10198
10298
|
function dynamicTool(tool2) {
|
|
10199
10299
|
return { ...tool2, type: "dynamic" };
|
|
10200
10300
|
}
|
|
10301
|
+
function createProviderToolFactory({
|
|
10302
|
+
id: id2,
|
|
10303
|
+
inputSchema
|
|
10304
|
+
}) {
|
|
10305
|
+
return ({
|
|
10306
|
+
execute,
|
|
10307
|
+
outputSchema: outputSchema2,
|
|
10308
|
+
needsApproval,
|
|
10309
|
+
toModelOutput,
|
|
10310
|
+
onInputStart,
|
|
10311
|
+
onInputDelta,
|
|
10312
|
+
onInputAvailable,
|
|
10313
|
+
...args
|
|
10314
|
+
}) => tool({
|
|
10315
|
+
type: "provider",
|
|
10316
|
+
id: id2,
|
|
10317
|
+
args,
|
|
10318
|
+
inputSchema,
|
|
10319
|
+
outputSchema: outputSchema2,
|
|
10320
|
+
execute,
|
|
10321
|
+
needsApproval,
|
|
10322
|
+
toModelOutput,
|
|
10323
|
+
onInputStart,
|
|
10324
|
+
onInputDelta,
|
|
10325
|
+
onInputAvailable
|
|
10326
|
+
});
|
|
10327
|
+
}
|
|
10201
10328
|
function createProviderToolFactoryWithOutputSchema({
|
|
10202
10329
|
id: id2,
|
|
10203
10330
|
inputSchema,
|
|
@@ -11671,7 +11798,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11671
11798
|
var _a92;
|
|
11672
11799
|
return (_a92 = indexBrowserExports.getContext().headers) == null ? void 0 : _a92["x-vercel-id"];
|
|
11673
11800
|
}
|
|
11674
|
-
var VERSION$6 = "3.0.
|
|
11801
|
+
var VERSION$6 = "3.0.66";
|
|
11675
11802
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
11676
11803
|
function createGatewayProvider(options = {}) {
|
|
11677
11804
|
var _a92, _b9;
|
|
@@ -13198,6 +13325,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
13198
13325
|
}
|
|
13199
13326
|
async function notify(options) {
|
|
13200
13327
|
for (const callback of asArray(options.callbacks)) {
|
|
13328
|
+
if (callback == null)
|
|
13329
|
+
continue;
|
|
13201
13330
|
try {
|
|
13202
13331
|
await callback(options.event);
|
|
13203
13332
|
} catch (_ignored) {
|
|
@@ -13504,7 +13633,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
13504
13633
|
}
|
|
13505
13634
|
return void 0;
|
|
13506
13635
|
}
|
|
13507
|
-
var VERSION$4 = "6.0.
|
|
13636
|
+
var VERSION$4 = "6.0.116";
|
|
13508
13637
|
var download = async ({
|
|
13509
13638
|
url: url2,
|
|
13510
13639
|
maxBytes,
|
|
@@ -13512,6 +13641,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
13512
13641
|
}) => {
|
|
13513
13642
|
var _a21;
|
|
13514
13643
|
const urlText = url2.toString();
|
|
13644
|
+
validateDownloadUrl(urlText);
|
|
13515
13645
|
try {
|
|
13516
13646
|
const response = await fetch(urlText, {
|
|
13517
13647
|
headers: withUserAgentSuffix$1(
|
|
@@ -14617,6 +14747,44 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
14617
14747
|
}))
|
|
14618
14748
|
);
|
|
14619
14749
|
}
|
|
14750
|
+
function getGlobalTelemetryIntegrations() {
|
|
14751
|
+
var _a21;
|
|
14752
|
+
return (_a21 = globalThis.AI_SDK_TELEMETRY_INTEGRATIONS) != null ? _a21 : [];
|
|
14753
|
+
}
|
|
14754
|
+
function getGlobalTelemetryIntegration() {
|
|
14755
|
+
const globalIntegrations = getGlobalTelemetryIntegrations();
|
|
14756
|
+
return (integrations) => {
|
|
14757
|
+
const localIntegrations = asArray(integrations);
|
|
14758
|
+
const allIntegrations = [...globalIntegrations, ...localIntegrations];
|
|
14759
|
+
function createTelemetryComposite(getListenerFromIntegration) {
|
|
14760
|
+
const listeners = allIntegrations.map(getListenerFromIntegration).filter(Boolean);
|
|
14761
|
+
return async (event) => {
|
|
14762
|
+
for (const listener of listeners) {
|
|
14763
|
+
try {
|
|
14764
|
+
await listener(event);
|
|
14765
|
+
} catch (_ignored) {
|
|
14766
|
+
}
|
|
14767
|
+
}
|
|
14768
|
+
};
|
|
14769
|
+
}
|
|
14770
|
+
return {
|
|
14771
|
+
onStart: createTelemetryComposite((integration) => integration.onStart),
|
|
14772
|
+
onStepStart: createTelemetryComposite(
|
|
14773
|
+
(integration) => integration.onStepStart
|
|
14774
|
+
),
|
|
14775
|
+
onToolCallStart: createTelemetryComposite(
|
|
14776
|
+
(integration) => integration.onToolCallStart
|
|
14777
|
+
),
|
|
14778
|
+
onToolCallFinish: createTelemetryComposite(
|
|
14779
|
+
(integration) => integration.onToolCallFinish
|
|
14780
|
+
),
|
|
14781
|
+
onStepFinish: createTelemetryComposite(
|
|
14782
|
+
(integration) => integration.onStepFinish
|
|
14783
|
+
),
|
|
14784
|
+
onFinish: createTelemetryComposite((integration) => integration.onFinish)
|
|
14785
|
+
};
|
|
14786
|
+
};
|
|
14787
|
+
}
|
|
14620
14788
|
function asLanguageModelUsage(usage) {
|
|
14621
14789
|
return {
|
|
14622
14790
|
inputTokens: usage.inputTokens.total,
|
|
@@ -16167,6 +16335,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16167
16335
|
...settings
|
|
16168
16336
|
}) {
|
|
16169
16337
|
const model = resolveLanguageModel(modelArg);
|
|
16338
|
+
const createGlobalTelemetry = getGlobalTelemetryIntegration();
|
|
16170
16339
|
const stopConditions = asArray(stopWhen);
|
|
16171
16340
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
16172
16341
|
const stepTimeoutMs = getStepTimeoutMs(timeout);
|
|
@@ -16197,6 +16366,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16197
16366
|
prompt,
|
|
16198
16367
|
messages
|
|
16199
16368
|
});
|
|
16369
|
+
const globalTelemetry = createGlobalTelemetry(telemetry == null ? void 0 : telemetry.integrations);
|
|
16200
16370
|
await notify({
|
|
16201
16371
|
event: {
|
|
16202
16372
|
model: modelInfo,
|
|
@@ -16226,7 +16396,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16226
16396
|
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
16227
16397
|
experimental_context
|
|
16228
16398
|
},
|
|
16229
|
-
callbacks:
|
|
16399
|
+
callbacks: [
|
|
16400
|
+
onStart,
|
|
16401
|
+
globalTelemetry.onStart
|
|
16402
|
+
]
|
|
16230
16403
|
});
|
|
16231
16404
|
const tracer = getTracer(telemetry);
|
|
16232
16405
|
try {
|
|
@@ -16271,8 +16444,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16271
16444
|
experimental_context,
|
|
16272
16445
|
stepNumber: 0,
|
|
16273
16446
|
model: modelInfo,
|
|
16274
|
-
onToolCallStart
|
|
16275
|
-
|
|
16447
|
+
onToolCallStart: [
|
|
16448
|
+
onToolCallStart,
|
|
16449
|
+
globalTelemetry.onToolCallStart
|
|
16450
|
+
],
|
|
16451
|
+
onToolCallFinish: [
|
|
16452
|
+
onToolCallFinish,
|
|
16453
|
+
globalTelemetry.onToolCallFinish
|
|
16454
|
+
]
|
|
16276
16455
|
});
|
|
16277
16456
|
const toolContent = [];
|
|
16278
16457
|
for (const output2 of toolOutputs) {
|
|
@@ -16281,7 +16460,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16281
16460
|
input: output2.input,
|
|
16282
16461
|
tool: tools == null ? void 0 : tools[output2.toolName],
|
|
16283
16462
|
output: output2.type === "tool-result" ? output2.output : output2.error,
|
|
16284
|
-
errorMode: output2.type === "tool-error" ? "
|
|
16463
|
+
errorMode: output2.type === "tool-error" ? "text" : "none"
|
|
16285
16464
|
});
|
|
16286
16465
|
toolContent.push({
|
|
16287
16466
|
type: "tool-result",
|
|
@@ -16398,7 +16577,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16398
16577
|
metadata: telemetry == null ? void 0 : telemetry.metadata,
|
|
16399
16578
|
experimental_context
|
|
16400
16579
|
},
|
|
16401
|
-
callbacks:
|
|
16580
|
+
callbacks: [
|
|
16581
|
+
onStepStart,
|
|
16582
|
+
globalTelemetry.onStepStart
|
|
16583
|
+
]
|
|
16402
16584
|
});
|
|
16403
16585
|
currentModelResponse = await retry(
|
|
16404
16586
|
() => {
|
|
@@ -16576,8 +16758,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16576
16758
|
experimental_context,
|
|
16577
16759
|
stepNumber: steps.length,
|
|
16578
16760
|
model: stepModelInfo,
|
|
16579
|
-
onToolCallStart
|
|
16580
|
-
|
|
16761
|
+
onToolCallStart: [
|
|
16762
|
+
onToolCallStart,
|
|
16763
|
+
globalTelemetry.onToolCallStart
|
|
16764
|
+
],
|
|
16765
|
+
onToolCallFinish: [
|
|
16766
|
+
onToolCallFinish,
|
|
16767
|
+
globalTelemetry.onToolCallFinish
|
|
16768
|
+
]
|
|
16581
16769
|
})
|
|
16582
16770
|
);
|
|
16583
16771
|
}
|
|
@@ -16644,7 +16832,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16644
16832
|
model: stepModelInfo.modelId
|
|
16645
16833
|
});
|
|
16646
16834
|
steps.push(currentStepResult);
|
|
16647
|
-
await notify({
|
|
16835
|
+
await notify({
|
|
16836
|
+
event: currentStepResult,
|
|
16837
|
+
callbacks: [onStepFinish, globalTelemetry.onStepFinish]
|
|
16838
|
+
});
|
|
16648
16839
|
} finally {
|
|
16649
16840
|
if (stepTimeoutId != null) {
|
|
16650
16841
|
clearTimeout(stepTimeoutId);
|
|
@@ -16725,7 +16916,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
16725
16916
|
steps,
|
|
16726
16917
|
totalUsage
|
|
16727
16918
|
},
|
|
16728
|
-
callbacks:
|
|
16919
|
+
callbacks: [
|
|
16920
|
+
onFinish,
|
|
16921
|
+
globalTelemetry.onFinish
|
|
16922
|
+
]
|
|
16729
16923
|
});
|
|
16730
16924
|
let resolvedOutput;
|
|
16731
16925
|
if (lastStep.finishReason === "stop") {
|
|
@@ -17344,7 +17538,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
17344
17538
|
state.message.parts.push({
|
|
17345
17539
|
type: "file",
|
|
17346
17540
|
mediaType: chunk.mediaType,
|
|
17347
|
-
url: chunk.url
|
|
17541
|
+
url: chunk.url,
|
|
17542
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
17348
17543
|
});
|
|
17349
17544
|
write();
|
|
17350
17545
|
break;
|
|
@@ -18001,7 +18196,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18001
18196
|
file: new DefaultGeneratedFileWithType({
|
|
18002
18197
|
data: chunk.data,
|
|
18003
18198
|
mediaType: chunk.mediaType
|
|
18004
|
-
})
|
|
18199
|
+
}),
|
|
18200
|
+
...chunk.providerMetadata != null ? { providerMetadata: chunk.providerMetadata } : {}
|
|
18005
18201
|
});
|
|
18006
18202
|
break;
|
|
18007
18203
|
}
|
|
@@ -18389,6 +18585,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18389
18585
|
this.outputSpecification = output;
|
|
18390
18586
|
this.includeRawChunks = includeRawChunks;
|
|
18391
18587
|
this.tools = tools;
|
|
18588
|
+
const createGlobalTelemetry = getGlobalTelemetryIntegration();
|
|
18589
|
+
const globalTelemetry = createGlobalTelemetry(telemetry == null ? void 0 : telemetry.integrations);
|
|
18392
18590
|
let stepFinish;
|
|
18393
18591
|
let recordedContent = [];
|
|
18394
18592
|
const recordedResponseMessages = [];
|
|
@@ -18490,7 +18688,11 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18490
18688
|
delete activeReasoningContent[part.id];
|
|
18491
18689
|
}
|
|
18492
18690
|
if (part.type === "file") {
|
|
18493
|
-
recordedContent.push({
|
|
18691
|
+
recordedContent.push({
|
|
18692
|
+
type: "file",
|
|
18693
|
+
file: part.file,
|
|
18694
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
18695
|
+
});
|
|
18494
18696
|
}
|
|
18495
18697
|
if (part.type === "source") {
|
|
18496
18698
|
recordedContent.push(part);
|
|
@@ -18536,7 +18738,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18536
18738
|
},
|
|
18537
18739
|
providerMetadata: part.providerMetadata
|
|
18538
18740
|
});
|
|
18539
|
-
await notify({
|
|
18741
|
+
await notify({
|
|
18742
|
+
event: currentStepResult,
|
|
18743
|
+
callbacks: [onStepFinish, globalTelemetry.onStepFinish]
|
|
18744
|
+
});
|
|
18540
18745
|
logWarnings({
|
|
18541
18746
|
warnings: recordedWarnings,
|
|
18542
18747
|
provider: modelInfo.provider,
|
|
@@ -18600,7 +18805,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18600
18805
|
providerMetadata: finalStep.providerMetadata,
|
|
18601
18806
|
steps: recordedSteps
|
|
18602
18807
|
},
|
|
18603
|
-
callbacks:
|
|
18808
|
+
callbacks: [
|
|
18809
|
+
onFinish,
|
|
18810
|
+
globalTelemetry.onFinish
|
|
18811
|
+
]
|
|
18604
18812
|
});
|
|
18605
18813
|
rootSpan.setAttributes(
|
|
18606
18814
|
await selectTelemetryAttributes({
|
|
@@ -18757,7 +18965,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18757
18965
|
...callbackTelemetryProps,
|
|
18758
18966
|
experimental_context
|
|
18759
18967
|
},
|
|
18760
|
-
callbacks:
|
|
18968
|
+
callbacks: [
|
|
18969
|
+
onStart,
|
|
18970
|
+
globalTelemetry.onStart
|
|
18971
|
+
]
|
|
18761
18972
|
});
|
|
18762
18973
|
const initialMessages = initialPrompt.messages;
|
|
18763
18974
|
const initialResponseMessages = [];
|
|
@@ -18807,8 +19018,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18807
19018
|
experimental_context,
|
|
18808
19019
|
stepNumber: recordedSteps.length,
|
|
18809
19020
|
model: modelInfo,
|
|
18810
|
-
onToolCallStart
|
|
18811
|
-
|
|
19021
|
+
onToolCallStart: [
|
|
19022
|
+
onToolCallStart,
|
|
19023
|
+
globalTelemetry.onToolCallStart
|
|
19024
|
+
],
|
|
19025
|
+
onToolCallFinish: [
|
|
19026
|
+
onToolCallFinish,
|
|
19027
|
+
globalTelemetry.onToolCallFinish
|
|
19028
|
+
],
|
|
18812
19029
|
onPreliminaryToolResult: (result2) => {
|
|
18813
19030
|
toolExecutionStepStreamController == null ? void 0 : toolExecutionStepStreamController.enqueue(result2);
|
|
18814
19031
|
}
|
|
@@ -18845,7 +19062,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18845
19062
|
input: output2.input,
|
|
18846
19063
|
tool: tools == null ? void 0 : tools[output2.toolName],
|
|
18847
19064
|
output: output2.type === "tool-result" ? output2.output : output2.error,
|
|
18848
|
-
errorMode: output2.type === "tool-error" ? "
|
|
19065
|
+
errorMode: output2.type === "tool-error" ? "text" : "none"
|
|
18849
19066
|
})
|
|
18850
19067
|
});
|
|
18851
19068
|
}
|
|
@@ -18959,7 +19176,10 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
18959
19176
|
...callbackTelemetryProps,
|
|
18960
19177
|
experimental_context
|
|
18961
19178
|
},
|
|
18962
|
-
callbacks:
|
|
19179
|
+
callbacks: [
|
|
19180
|
+
onStepStart,
|
|
19181
|
+
globalTelemetry.onStepStart
|
|
19182
|
+
]
|
|
18963
19183
|
});
|
|
18964
19184
|
const {
|
|
18965
19185
|
result: { stream: stream2, response, request },
|
|
@@ -19035,8 +19255,14 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19035
19255
|
generateId: generateId2,
|
|
19036
19256
|
stepNumber: recordedSteps.length,
|
|
19037
19257
|
model: stepModelInfo,
|
|
19038
|
-
onToolCallStart
|
|
19039
|
-
|
|
19258
|
+
onToolCallStart: [
|
|
19259
|
+
onToolCallStart,
|
|
19260
|
+
globalTelemetry.onToolCallStart
|
|
19261
|
+
],
|
|
19262
|
+
onToolCallFinish: [
|
|
19263
|
+
onToolCallFinish,
|
|
19264
|
+
globalTelemetry.onToolCallFinish
|
|
19265
|
+
]
|
|
19040
19266
|
});
|
|
19041
19267
|
const stepRequest = ((_i = include == null ? void 0 : include.requestBody) != null ? _i : true) ? request != null ? request : {} : { ...request, body: void 0 };
|
|
19042
19268
|
const stepToolCalls = [];
|
|
@@ -19618,7 +19844,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
19618
19844
|
controller.enqueue({
|
|
19619
19845
|
type: "file",
|
|
19620
19846
|
mediaType: part.file.mediaType,
|
|
19621
|
-
url: `data:${part.file.mediaType};base64,${part.file.base64}
|
|
19847
|
+
url: `data:${part.file.mediaType};base64,${part.file.base64}`,
|
|
19848
|
+
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {}
|
|
19622
19849
|
});
|
|
19623
19850
|
break;
|
|
19624
19851
|
}
|
|
@@ -24688,7 +24915,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
|
|
|
24688
24915
|
function getOpenAILanguageModelCapabilities(modelId) {
|
|
24689
24916
|
const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
24690
24917
|
const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
|
|
24691
|
-
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("
|
|
24918
|
+
const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
|
|
24692
24919
|
const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2");
|
|
24693
24920
|
const systemMessageMode = isReasoningModel ? "developer" : "system";
|
|
24694
24921
|
return {
|
|
@@ -26595,6 +26822,30 @@ ${user}:`]
|
|
|
26595
26822
|
var codeInterpreter = (args = {}) => {
|
|
26596
26823
|
return codeInterpreterToolFactory(args);
|
|
26597
26824
|
};
|
|
26825
|
+
var customArgsSchema = lazySchema(
|
|
26826
|
+
() => zodSchema(
|
|
26827
|
+
object$1({
|
|
26828
|
+
name: string(),
|
|
26829
|
+
description: string().optional(),
|
|
26830
|
+
format: union([
|
|
26831
|
+
object$1({
|
|
26832
|
+
type: literal("grammar"),
|
|
26833
|
+
syntax: _enum$1(["regex", "lark"]),
|
|
26834
|
+
definition: string()
|
|
26835
|
+
}),
|
|
26836
|
+
object$1({
|
|
26837
|
+
type: literal("text")
|
|
26838
|
+
})
|
|
26839
|
+
]).optional()
|
|
26840
|
+
})
|
|
26841
|
+
)
|
|
26842
|
+
);
|
|
26843
|
+
var customInputSchema = lazySchema(() => zodSchema(string()));
|
|
26844
|
+
var customToolFactory = createProviderToolFactory({
|
|
26845
|
+
id: "openai.custom",
|
|
26846
|
+
inputSchema: customInputSchema
|
|
26847
|
+
});
|
|
26848
|
+
var customTool = (args) => customToolFactory(args);
|
|
26598
26849
|
var comparisonFilterSchema = object$1({
|
|
26599
26850
|
key: string(),
|
|
26600
26851
|
type: _enum$1(["eq", "ne", "gt", "gte", "lt", "lte", "in", "nin"]),
|
|
@@ -26947,6 +27198,16 @@ ${user}:`]
|
|
|
26947
27198
|
*
|
|
26948
27199
|
*/
|
|
26949
27200
|
applyPatch,
|
|
27201
|
+
/**
|
|
27202
|
+
* Custom tools let callers constrain model output to a grammar (regex or
|
|
27203
|
+
* Lark syntax). The model returns a `custom_tool_call` output item whose
|
|
27204
|
+
* `input` field is a string matching the specified grammar.
|
|
27205
|
+
*
|
|
27206
|
+
* @param name - The name of the custom tool.
|
|
27207
|
+
* @param description - An optional description of the tool.
|
|
27208
|
+
* @param format - The output format constraint (grammar type, syntax, and definition).
|
|
27209
|
+
*/
|
|
27210
|
+
customTool,
|
|
26950
27211
|
/**
|
|
26951
27212
|
* The Code Interpreter tool allows models to write and run Python code in a
|
|
26952
27213
|
* sandboxed environment to solve complex problems in domains like data analysis,
|
|
@@ -26987,7 +27248,7 @@ ${user}:`]
|
|
|
26987
27248
|
* Local shell is a tool that allows agents to run shell commands locally
|
|
26988
27249
|
* on a machine you or the user provides.
|
|
26989
27250
|
*
|
|
26990
|
-
* Supported models: `gpt-5-codex`
|
|
27251
|
+
* Supported models: `gpt-5-codex`
|
|
26991
27252
|
*/
|
|
26992
27253
|
localShell,
|
|
26993
27254
|
/**
|
|
@@ -27085,9 +27346,10 @@ ${user}:`]
|
|
|
27085
27346
|
hasConversation = false,
|
|
27086
27347
|
hasLocalShellTool = false,
|
|
27087
27348
|
hasShellTool = false,
|
|
27088
|
-
hasApplyPatchTool = false
|
|
27349
|
+
hasApplyPatchTool = false,
|
|
27350
|
+
customProviderToolNames
|
|
27089
27351
|
}) {
|
|
27090
|
-
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
27352
|
+
var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
27091
27353
|
const input = [];
|
|
27092
27354
|
const warnings = [];
|
|
27093
27355
|
const processedApprovalIds = /* @__PURE__ */ new Set();
|
|
@@ -27256,6 +27518,16 @@ ${user}:`]
|
|
|
27256
27518
|
});
|
|
27257
27519
|
break;
|
|
27258
27520
|
}
|
|
27521
|
+
if (customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) {
|
|
27522
|
+
input.push({
|
|
27523
|
+
type: "custom_tool_call",
|
|
27524
|
+
call_id: part.toolCallId,
|
|
27525
|
+
name: resolvedToolName,
|
|
27526
|
+
input: typeof part.input === "string" ? part.input : JSON.stringify(part.input),
|
|
27527
|
+
id: id2
|
|
27528
|
+
});
|
|
27529
|
+
break;
|
|
27530
|
+
}
|
|
27259
27531
|
input.push({
|
|
27260
27532
|
type: "function_call",
|
|
27261
27533
|
call_id: part.toolCallId,
|
|
@@ -27460,6 +27732,61 @@ ${user}:`]
|
|
|
27460
27732
|
});
|
|
27461
27733
|
continue;
|
|
27462
27734
|
}
|
|
27735
|
+
if (customProviderToolNames == null ? void 0 : customProviderToolNames.has(resolvedToolName)) {
|
|
27736
|
+
let outputValue;
|
|
27737
|
+
switch (output.type) {
|
|
27738
|
+
case "text":
|
|
27739
|
+
case "error-text":
|
|
27740
|
+
outputValue = output.value;
|
|
27741
|
+
break;
|
|
27742
|
+
case "execution-denied":
|
|
27743
|
+
outputValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
|
|
27744
|
+
break;
|
|
27745
|
+
case "json":
|
|
27746
|
+
case "error-json":
|
|
27747
|
+
outputValue = JSON.stringify(output.value);
|
|
27748
|
+
break;
|
|
27749
|
+
case "content":
|
|
27750
|
+
outputValue = output.value.map((item) => {
|
|
27751
|
+
var _a22;
|
|
27752
|
+
switch (item.type) {
|
|
27753
|
+
case "text":
|
|
27754
|
+
return { type: "input_text", text: item.text };
|
|
27755
|
+
case "image-data":
|
|
27756
|
+
return {
|
|
27757
|
+
type: "input_image",
|
|
27758
|
+
image_url: `data:${item.mediaType};base64,${item.data}`
|
|
27759
|
+
};
|
|
27760
|
+
case "image-url":
|
|
27761
|
+
return {
|
|
27762
|
+
type: "input_image",
|
|
27763
|
+
image_url: item.url
|
|
27764
|
+
};
|
|
27765
|
+
case "file-data":
|
|
27766
|
+
return {
|
|
27767
|
+
type: "input_file",
|
|
27768
|
+
filename: (_a22 = item.filename) != null ? _a22 : "data",
|
|
27769
|
+
file_data: `data:${item.mediaType};base64,${item.data}`
|
|
27770
|
+
};
|
|
27771
|
+
default:
|
|
27772
|
+
warnings.push({
|
|
27773
|
+
type: "other",
|
|
27774
|
+
message: `unsupported custom tool content part type: ${item.type}`
|
|
27775
|
+
});
|
|
27776
|
+
return void 0;
|
|
27777
|
+
}
|
|
27778
|
+
}).filter(isNonNullable);
|
|
27779
|
+
break;
|
|
27780
|
+
default:
|
|
27781
|
+
outputValue = "";
|
|
27782
|
+
}
|
|
27783
|
+
input.push({
|
|
27784
|
+
type: "custom_tool_call_output",
|
|
27785
|
+
call_id: part.toolCallId,
|
|
27786
|
+
output: outputValue
|
|
27787
|
+
});
|
|
27788
|
+
continue;
|
|
27789
|
+
}
|
|
27463
27790
|
let contentValue;
|
|
27464
27791
|
switch (output.type) {
|
|
27465
27792
|
case "text":
|
|
@@ -27467,7 +27794,7 @@ ${user}:`]
|
|
|
27467
27794
|
contentValue = output.value;
|
|
27468
27795
|
break;
|
|
27469
27796
|
case "execution-denied":
|
|
27470
|
-
contentValue = (
|
|
27797
|
+
contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
|
|
27471
27798
|
break;
|
|
27472
27799
|
case "json":
|
|
27473
27800
|
case "error-json":
|
|
@@ -27676,6 +28003,13 @@ ${user}:`]
|
|
|
27676
28003
|
})
|
|
27677
28004
|
])
|
|
27678
28005
|
}),
|
|
28006
|
+
object$1({
|
|
28007
|
+
type: literal("custom_tool_call"),
|
|
28008
|
+
id: string(),
|
|
28009
|
+
call_id: string(),
|
|
28010
|
+
name: string(),
|
|
28011
|
+
input: string()
|
|
28012
|
+
}),
|
|
27679
28013
|
object$1({
|
|
27680
28014
|
type: literal("shell_call"),
|
|
27681
28015
|
id: string(),
|
|
@@ -27728,6 +28062,14 @@ ${user}:`]
|
|
|
27728
28062
|
arguments: string(),
|
|
27729
28063
|
status: literal("completed")
|
|
27730
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
|
+
}),
|
|
27731
28073
|
object$1({
|
|
27732
28074
|
type: literal("code_interpreter_call"),
|
|
27733
28075
|
id: string(),
|
|
@@ -27911,6 +28253,12 @@ ${user}:`]
|
|
|
27911
28253
|
output_index: number$1(),
|
|
27912
28254
|
delta: string()
|
|
27913
28255
|
}),
|
|
28256
|
+
object$1({
|
|
28257
|
+
type: literal("response.custom_tool_call_input.delta"),
|
|
28258
|
+
item_id: string(),
|
|
28259
|
+
output_index: number$1(),
|
|
28260
|
+
delta: string()
|
|
28261
|
+
}),
|
|
27914
28262
|
object$1({
|
|
27915
28263
|
type: literal("response.image_generation_call.partial_image"),
|
|
27916
28264
|
item_id: string(),
|
|
@@ -28158,6 +28506,13 @@ ${user}:`]
|
|
|
28158
28506
|
arguments: string(),
|
|
28159
28507
|
id: string()
|
|
28160
28508
|
}),
|
|
28509
|
+
object$1({
|
|
28510
|
+
type: literal("custom_tool_call"),
|
|
28511
|
+
call_id: string(),
|
|
28512
|
+
name: string(),
|
|
28513
|
+
input: string(),
|
|
28514
|
+
id: string()
|
|
28515
|
+
}),
|
|
28161
28516
|
object$1({
|
|
28162
28517
|
type: literal("computer_call"),
|
|
28163
28518
|
id: string(),
|
|
@@ -28441,14 +28796,18 @@ ${user}:`]
|
|
|
28441
28796
|
);
|
|
28442
28797
|
async function prepareResponsesTools({
|
|
28443
28798
|
tools,
|
|
28444
|
-
toolChoice
|
|
28799
|
+
toolChoice,
|
|
28800
|
+
toolNameMapping,
|
|
28801
|
+
customProviderToolNames
|
|
28445
28802
|
}) {
|
|
28803
|
+
var _a10;
|
|
28446
28804
|
tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
|
|
28447
28805
|
const toolWarnings = [];
|
|
28448
28806
|
if (tools == null) {
|
|
28449
28807
|
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
28450
28808
|
}
|
|
28451
28809
|
const openaiTools2 = [];
|
|
28810
|
+
const resolvedCustomProviderToolNames = customProviderToolNames != null ? customProviderToolNames : /* @__PURE__ */ new Set();
|
|
28452
28811
|
for (const tool2 of tools) {
|
|
28453
28812
|
switch (tool2.type) {
|
|
28454
28813
|
case "function":
|
|
@@ -28590,6 +28949,20 @@ ${user}:`]
|
|
|
28590
28949
|
});
|
|
28591
28950
|
break;
|
|
28592
28951
|
}
|
|
28952
|
+
case "openai.custom": {
|
|
28953
|
+
const args = await validateTypes$1({
|
|
28954
|
+
value: tool2.args,
|
|
28955
|
+
schema: customArgsSchema
|
|
28956
|
+
});
|
|
28957
|
+
openaiTools2.push({
|
|
28958
|
+
type: "custom",
|
|
28959
|
+
name: args.name,
|
|
28960
|
+
description: args.description,
|
|
28961
|
+
format: args.format
|
|
28962
|
+
});
|
|
28963
|
+
resolvedCustomProviderToolNames.add(args.name);
|
|
28964
|
+
break;
|
|
28965
|
+
}
|
|
28593
28966
|
}
|
|
28594
28967
|
break;
|
|
28595
28968
|
}
|
|
@@ -28610,12 +28983,14 @@ ${user}:`]
|
|
|
28610
28983
|
case "none":
|
|
28611
28984
|
case "required":
|
|
28612
28985
|
return { tools: openaiTools2, toolChoice: type2, toolWarnings };
|
|
28613
|
-
case "tool":
|
|
28986
|
+
case "tool": {
|
|
28987
|
+
const resolvedToolName = (_a10 = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _a10 : toolChoice.toolName;
|
|
28614
28988
|
return {
|
|
28615
28989
|
tools: openaiTools2,
|
|
28616
|
-
toolChoice:
|
|
28990
|
+
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 },
|
|
28617
28991
|
toolWarnings
|
|
28618
28992
|
};
|
|
28993
|
+
}
|
|
28619
28994
|
default: {
|
|
28620
28995
|
const _exhaustiveCheck = type2;
|
|
28621
28996
|
throw new UnsupportedFunctionalityError$1({
|
|
@@ -28764,7 +29139,19 @@ ${user}:`]
|
|
|
28764
29139
|
"openai.web_search_preview": "web_search_preview",
|
|
28765
29140
|
"openai.mcp": "mcp",
|
|
28766
29141
|
"openai.apply_patch": "apply_patch"
|
|
28767
|
-
}
|
|
29142
|
+
},
|
|
29143
|
+
resolveProviderToolName: (tool2) => tool2.id === "openai.custom" ? tool2.args.name : void 0
|
|
29144
|
+
});
|
|
29145
|
+
const customProviderToolNames = /* @__PURE__ */ new Set();
|
|
29146
|
+
const {
|
|
29147
|
+
tools: openaiTools2,
|
|
29148
|
+
toolChoice: openaiToolChoice,
|
|
29149
|
+
toolWarnings
|
|
29150
|
+
} = await prepareResponsesTools({
|
|
29151
|
+
tools,
|
|
29152
|
+
toolChoice,
|
|
29153
|
+
toolNameMapping,
|
|
29154
|
+
customProviderToolNames
|
|
28768
29155
|
});
|
|
28769
29156
|
const { input, warnings: inputWarnings } = await convertToOpenAIResponsesInput({
|
|
28770
29157
|
prompt,
|
|
@@ -28776,7 +29163,8 @@ ${user}:`]
|
|
|
28776
29163
|
hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
|
|
28777
29164
|
hasLocalShellTool: hasOpenAITool("openai.local_shell"),
|
|
28778
29165
|
hasShellTool: hasOpenAITool("openai.shell"),
|
|
28779
|
-
hasApplyPatchTool: hasOpenAITool("openai.apply_patch")
|
|
29166
|
+
hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
|
|
29167
|
+
customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
|
|
28780
29168
|
});
|
|
28781
29169
|
warnings.push(...inputWarnings);
|
|
28782
29170
|
const strictJsonSchema = (_d = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _d : true;
|
|
@@ -28909,14 +29297,6 @@ ${user}:`]
|
|
|
28909
29297
|
});
|
|
28910
29298
|
delete baseArgs.service_tier;
|
|
28911
29299
|
}
|
|
28912
|
-
const {
|
|
28913
|
-
tools: openaiTools2,
|
|
28914
|
-
toolChoice: openaiToolChoice,
|
|
28915
|
-
toolWarnings
|
|
28916
|
-
} = await prepareResponsesTools({
|
|
28917
|
-
tools,
|
|
28918
|
-
toolChoice
|
|
28919
|
-
});
|
|
28920
29300
|
const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
|
|
28921
29301
|
(tool2) => tool2.type === "provider" && tool2.id === "openai.shell"
|
|
28922
29302
|
)) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
|
|
@@ -29166,6 +29546,22 @@ ${user}:`]
|
|
|
29166
29546
|
});
|
|
29167
29547
|
break;
|
|
29168
29548
|
}
|
|
29549
|
+
case "custom_tool_call": {
|
|
29550
|
+
hasFunctionCall = true;
|
|
29551
|
+
const toolName = toolNameMapping.toCustomToolName(part.name);
|
|
29552
|
+
content.push({
|
|
29553
|
+
type: "tool-call",
|
|
29554
|
+
toolCallId: part.call_id,
|
|
29555
|
+
toolName,
|
|
29556
|
+
input: JSON.stringify(part.input),
|
|
29557
|
+
providerMetadata: {
|
|
29558
|
+
[providerOptionsName]: {
|
|
29559
|
+
itemId: part.id
|
|
29560
|
+
}
|
|
29561
|
+
}
|
|
29562
|
+
});
|
|
29563
|
+
break;
|
|
29564
|
+
}
|
|
29169
29565
|
case "web_search_call": {
|
|
29170
29566
|
content.push({
|
|
29171
29567
|
type: "tool-call",
|
|
@@ -29424,6 +29820,19 @@ ${user}:`]
|
|
|
29424
29820
|
id: value.item.call_id,
|
|
29425
29821
|
toolName: value.item.name
|
|
29426
29822
|
});
|
|
29823
|
+
} else if (value.item.type === "custom_tool_call") {
|
|
29824
|
+
const toolName = toolNameMapping.toCustomToolName(
|
|
29825
|
+
value.item.name
|
|
29826
|
+
);
|
|
29827
|
+
ongoingToolCalls[value.output_index] = {
|
|
29828
|
+
toolName,
|
|
29829
|
+
toolCallId: value.item.call_id
|
|
29830
|
+
};
|
|
29831
|
+
controller.enqueue({
|
|
29832
|
+
type: "tool-input-start",
|
|
29833
|
+
id: value.item.call_id,
|
|
29834
|
+
toolName
|
|
29835
|
+
});
|
|
29427
29836
|
} else if (value.item.type === "web_search_call") {
|
|
29428
29837
|
ongoingToolCalls[value.output_index] = {
|
|
29429
29838
|
toolName: toolNameMapping.toCustomToolName(
|
|
@@ -29608,6 +30017,27 @@ ${user}:`]
|
|
|
29608
30017
|
}
|
|
29609
30018
|
}
|
|
29610
30019
|
});
|
|
30020
|
+
} else if (value.item.type === "custom_tool_call") {
|
|
30021
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
30022
|
+
hasFunctionCall = true;
|
|
30023
|
+
const toolName = toolNameMapping.toCustomToolName(
|
|
30024
|
+
value.item.name
|
|
30025
|
+
);
|
|
30026
|
+
controller.enqueue({
|
|
30027
|
+
type: "tool-input-end",
|
|
30028
|
+
id: value.item.call_id
|
|
30029
|
+
});
|
|
30030
|
+
controller.enqueue({
|
|
30031
|
+
type: "tool-call",
|
|
30032
|
+
toolCallId: value.item.call_id,
|
|
30033
|
+
toolName,
|
|
30034
|
+
input: JSON.stringify(value.item.input),
|
|
30035
|
+
providerMetadata: {
|
|
30036
|
+
[providerOptionsName]: {
|
|
30037
|
+
itemId: value.item.id
|
|
30038
|
+
}
|
|
30039
|
+
}
|
|
30040
|
+
});
|
|
29611
30041
|
} else if (value.item.type === "web_search_call") {
|
|
29612
30042
|
ongoingToolCalls[value.output_index] = void 0;
|
|
29613
30043
|
controller.enqueue({
|
|
@@ -29857,6 +30287,15 @@ ${user}:`]
|
|
|
29857
30287
|
delta: value.delta
|
|
29858
30288
|
});
|
|
29859
30289
|
}
|
|
30290
|
+
} else if (isResponseCustomToolCallInputDeltaChunk(value)) {
|
|
30291
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
30292
|
+
if (toolCall != null) {
|
|
30293
|
+
controller.enqueue({
|
|
30294
|
+
type: "tool-input-delta",
|
|
30295
|
+
id: toolCall.toolCallId,
|
|
30296
|
+
delta: value.delta
|
|
30297
|
+
});
|
|
30298
|
+
}
|
|
29860
30299
|
} else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
|
|
29861
30300
|
const toolCall = ongoingToolCalls[value.output_index];
|
|
29862
30301
|
if (toolCall == null ? void 0 : toolCall.applyPatch) {
|
|
@@ -30117,6 +30556,9 @@ ${user}:`]
|
|
|
30117
30556
|
function isResponseFunctionCallArgumentsDeltaChunk(chunk) {
|
|
30118
30557
|
return chunk.type === "response.function_call_arguments.delta";
|
|
30119
30558
|
}
|
|
30559
|
+
function isResponseCustomToolCallInputDeltaChunk(chunk) {
|
|
30560
|
+
return chunk.type === "response.custom_tool_call_input.delta";
|
|
30561
|
+
}
|
|
30120
30562
|
function isResponseImageGenerationCallPartialImageChunk(chunk) {
|
|
30121
30563
|
return chunk.type === "response.image_generation_call.partial_image";
|
|
30122
30564
|
}
|
|
@@ -30498,7 +30940,7 @@ ${user}:`]
|
|
|
30498
30940
|
};
|
|
30499
30941
|
}
|
|
30500
30942
|
};
|
|
30501
|
-
var VERSION$2 = "3.0.
|
|
30943
|
+
var VERSION$2 = "3.0.41";
|
|
30502
30944
|
function createOpenAI(options = {}) {
|
|
30503
30945
|
var _a10, _b9;
|
|
30504
30946
|
const baseURL = (_a10 = withoutTrailingSlash$1(
|
|
@@ -36475,7 +36917,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
36475
36917
|
if (hasRequiredUtils$2) return utils$2;
|
|
36476
36918
|
hasRequiredUtils$2 = 1;
|
|
36477
36919
|
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
36478
|
-
const
|
|
36920
|
+
const isIPv42 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
36479
36921
|
function stringArrayToHexStripped(input) {
|
|
36480
36922
|
let acc = "";
|
|
36481
36923
|
let code2 = 0;
|
|
@@ -36698,7 +37140,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
36698
37140
|
}
|
|
36699
37141
|
if (component.host !== void 0) {
|
|
36700
37142
|
let host = unescape(component.host);
|
|
36701
|
-
if (!
|
|
37143
|
+
if (!isIPv42(host)) {
|
|
36702
37144
|
const ipV6res = normalizeIPv6(host);
|
|
36703
37145
|
if (ipV6res.isIPV6 === true) {
|
|
36704
37146
|
host = `[${ipV6res.escapedHost}]`;
|
|
@@ -36719,7 +37161,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
36719
37161
|
recomposeAuthority,
|
|
36720
37162
|
normalizeComponentEncoding,
|
|
36721
37163
|
removeDotSegments,
|
|
36722
|
-
isIPv4,
|
|
37164
|
+
isIPv4: isIPv42,
|
|
36723
37165
|
isUUID,
|
|
36724
37166
|
normalizeIPv6,
|
|
36725
37167
|
stringArrayToHexStripped
|
|
@@ -36940,7 +37382,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
36940
37382
|
function requireFastUri() {
|
|
36941
37383
|
if (hasRequiredFastUri) return fastUri.exports;
|
|
36942
37384
|
hasRequiredFastUri = 1;
|
|
36943
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = requireUtils$2();
|
|
37385
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4: isIPv42, nonSimpleDomain } = requireUtils$2();
|
|
36944
37386
|
const { SCHEMES, getSchemeHandler } = requireSchemes();
|
|
36945
37387
|
function normalize(uri2, options) {
|
|
36946
37388
|
if (typeof uri2 === "string") {
|
|
@@ -37121,7 +37563,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
37121
37563
|
parsed.port = matches[5];
|
|
37122
37564
|
}
|
|
37123
37565
|
if (parsed.host) {
|
|
37124
|
-
const ipv4result =
|
|
37566
|
+
const ipv4result = isIPv42(parsed.host);
|
|
37125
37567
|
if (ipv4result === false) {
|
|
37126
37568
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
37127
37569
|
parsed.host = ipv6result.host.toLowerCase();
|
|
@@ -42384,9 +42826,13 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
42384
42826
|
if (toolEntries.length === 0) {
|
|
42385
42827
|
return "";
|
|
42386
42828
|
}
|
|
42387
|
-
let prompt =
|
|
42388
|
-
|
|
42389
|
-
|
|
42829
|
+
let prompt = `
|
|
42830
|
+
# 工具调用
|
|
42831
|
+
|
|
42832
|
+
你可以根据需要调用以下工具:
|
|
42833
|
+
|
|
42834
|
+
<tools>
|
|
42835
|
+
`;
|
|
42390
42836
|
toolEntries.forEach(([toolName, tool2]) => {
|
|
42391
42837
|
const toolInfo = tool2;
|
|
42392
42838
|
const description2 = toolInfo.description || "无描述";
|
|
@@ -42399,23 +42845,36 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
42399
42845
|
prompt += `${JSON.stringify(toolJson, null, 2)}
|
|
42400
42846
|
`;
|
|
42401
42847
|
});
|
|
42402
|
-
prompt +=
|
|
42403
|
-
|
|
42404
|
-
|
|
42405
|
-
|
|
42406
|
-
|
|
42407
|
-
|
|
42408
|
-
|
|
42409
|
-
|
|
42410
|
-
|
|
42411
|
-
|
|
42412
|
-
|
|
42413
|
-
|
|
42414
|
-
|
|
42415
|
-
|
|
42416
|
-
|
|
42417
|
-
|
|
42418
|
-
|
|
42848
|
+
prompt += `
|
|
42849
|
+
</tools>
|
|
42850
|
+
|
|
42851
|
+
## 工具调用格式
|
|
42852
|
+
|
|
42853
|
+
要调用工具,请使用以下 XML 格式:
|
|
42854
|
+
Thought: [你的思考过程]
|
|
42855
|
+
<tool_call>
|
|
42856
|
+
{"name": "toolName", "arguments": {"arg1": "value1"}}
|
|
42857
|
+
</tool_call>
|
|
42858
|
+
|
|
42859
|
+
工具执行后,你将收到 <tool_response> 格式的结果。你可以继续思考或调用其他工具。
|
|
42860
|
+
|
|
42861
|
+
## 使用示例
|
|
42862
|
+
|
|
42863
|
+
如果用户要求"获取今天的日期",你可以这样调用工具:
|
|
42864
|
+
Thought: 用户想要获取今天的日期,我需要调用日期相关的工具。
|
|
42865
|
+
<tool_call>{"name": "get-today", "arguments": {}}</tool_call>
|
|
42866
|
+
|
|
42867
|
+
然后等待工具返回结果(Observation),再根据结果给出最终答案。
|
|
42868
|
+
|
|
42869
|
+
## 任务完成
|
|
42870
|
+
|
|
42871
|
+
当任务完成或无法继续时,直接给出最终答案即可。
|
|
42872
|
+
|
|
42873
|
+
**重要提示**:
|
|
42874
|
+
- 必须严格按照 XML 格式调用工具
|
|
42875
|
+
- arguments 必须是有效的 JSON 格式
|
|
42876
|
+
- 如果不需要调用工具,直接给出最终答案即可
|
|
42877
|
+
`;
|
|
42419
42878
|
return prompt;
|
|
42420
42879
|
}
|
|
42421
42880
|
function parseReActAction(text2, availableTools) {
|
|
@@ -42635,15 +43094,24 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
42635
43094
|
}
|
|
42636
43095
|
this.onUpdatedTools?.();
|
|
42637
43096
|
}
|
|
42638
|
-
/** 创建临时允许调用的tools
|
|
42639
|
-
_tempMergeTools(extraTool = {}) {
|
|
42640
|
-
const toolsResult = Object.values(this.mcpTools).reduce(
|
|
43097
|
+
/** 创建临时允许调用的 tools 集合,合并 mcpTools 与 extraTool */
|
|
43098
|
+
_tempMergeTools(extraTool = {}, deleteIgnored = true) {
|
|
43099
|
+
const toolsResult = Object.values(this.mcpTools).reduce(
|
|
43100
|
+
(acc, curr) => ({ ...acc, ...curr }),
|
|
43101
|
+
{}
|
|
43102
|
+
);
|
|
42641
43103
|
Object.assign(toolsResult, extraTool);
|
|
42642
|
-
|
|
42643
|
-
|
|
42644
|
-
|
|
43104
|
+
if (deleteIgnored) {
|
|
43105
|
+
this.ignoreToolnames.forEach((name16) => {
|
|
43106
|
+
delete toolsResult[name16];
|
|
43107
|
+
});
|
|
43108
|
+
}
|
|
42645
43109
|
return toolsResult;
|
|
42646
43110
|
}
|
|
43111
|
+
/** 获取当前激活的 tools 名称列表(过滤 ignoreToolnames) */
|
|
43112
|
+
_getActiveToolNames(tools) {
|
|
43113
|
+
return Object.keys(tools).filter((name16) => !this.ignoreToolnames.includes(name16));
|
|
43114
|
+
}
|
|
42647
43115
|
/** 生成 ReAct 模式的系统提示词(包含工具描述) */
|
|
42648
43116
|
_generateReActSystemPrompt(tools, modelName, baseSystemPrompt) {
|
|
42649
43117
|
const toolsPrompt = generateReActToolsPrompt(tools);
|
|
@@ -42987,12 +43455,14 @@ ${observationText}
|
|
|
42987
43455
|
throw new Error("LLM is not initialized");
|
|
42988
43456
|
}
|
|
42989
43457
|
await this.initClientsAndTools();
|
|
43458
|
+
const allTools = this._tempMergeTools(options.tools, false);
|
|
42990
43459
|
const chatOptions = {
|
|
42991
43460
|
// @ts-ignore ProviderV2 是所有llm的父类, 在每一个具体的llm 类都有一个选择model的函数用法
|
|
42992
43461
|
model: this.llm(model),
|
|
42993
43462
|
stopWhen: stepCountIs(maxSteps),
|
|
42994
43463
|
...options,
|
|
42995
|
-
tools:
|
|
43464
|
+
tools: allTools,
|
|
43465
|
+
activeTools: this._getActiveToolNames(allTools)
|
|
42996
43466
|
};
|
|
42997
43467
|
let lastUserMessage = null;
|
|
42998
43468
|
if (options.message && !options.messages) {
|
|
@@ -45403,10 +45873,11 @@ ${observationText}
|
|
|
45403
45873
|
const DEFAULT_QR_CODE_URL = "https://ai.opentiny.design/next-remoter";
|
|
45404
45874
|
const DEFAULT_LOGO_URL = "https://ai.opentiny.design/next-remoter/svgs/logo-next-no-bg-left.svg";
|
|
45405
45875
|
const getDefaultMenuItems = (options) => {
|
|
45406
|
-
|
|
45876
|
+
const hasSession = !!options.sessionId;
|
|
45877
|
+
const baseItems = [
|
|
45407
45878
|
{
|
|
45408
45879
|
action: "qr-code",
|
|
45409
|
-
show:
|
|
45880
|
+
show: hasSession,
|
|
45410
45881
|
text: "扫码登录",
|
|
45411
45882
|
desc: "使用手机遥控页面",
|
|
45412
45883
|
icon: qrCode
|
|
@@ -45420,7 +45891,7 @@ ${observationText}
|
|
|
45420
45891
|
},
|
|
45421
45892
|
{
|
|
45422
45893
|
action: "remote-url",
|
|
45423
|
-
show:
|
|
45894
|
+
show: hasSession,
|
|
45424
45895
|
text: `遥控器链接`,
|
|
45425
45896
|
desc: `${options.remoteUrl}`,
|
|
45426
45897
|
active: true,
|
|
@@ -45430,14 +45901,15 @@ ${observationText}
|
|
|
45430
45901
|
},
|
|
45431
45902
|
{
|
|
45432
45903
|
action: "remote-control",
|
|
45433
|
-
show:
|
|
45904
|
+
show: hasSession,
|
|
45434
45905
|
text: `识别码`,
|
|
45435
|
-
desc: `${options.sessionId.slice(-6)}
|
|
45906
|
+
desc: hasSession ? `${options.sessionId.slice(-6)}` : "",
|
|
45436
45907
|
know: true,
|
|
45437
45908
|
showCopyIcon: true,
|
|
45438
45909
|
icon: scan
|
|
45439
45910
|
}
|
|
45440
45911
|
];
|
|
45912
|
+
return baseItems;
|
|
45441
45913
|
};
|
|
45442
45914
|
class FloatingBlock {
|
|
45443
45915
|
constructor(options) {
|
|
@@ -45469,9 +45941,6 @@ ${observationText}
|
|
|
45469
45941
|
trigger: "hover"
|
|
45470
45942
|
});
|
|
45471
45943
|
};
|
|
45472
|
-
if (!options.sessionId) {
|
|
45473
|
-
throw new Error("sessionId is required");
|
|
45474
|
-
}
|
|
45475
45944
|
this.options = {
|
|
45476
45945
|
...options,
|
|
45477
45946
|
qrCodeUrl: options.qrCodeUrl || DEFAULT_QR_CODE_URL,
|
|
@@ -45490,11 +45959,14 @@ ${observationText}
|
|
|
45490
45959
|
return this.options.qrCodeUrl?.includes("?") ? "&sessionId=" : "?sessionId=";
|
|
45491
45960
|
}
|
|
45492
45961
|
/**
|
|
45493
|
-
*
|
|
45494
|
-
*
|
|
45495
|
-
*
|
|
45962
|
+
* 合并菜单项配置。
|
|
45963
|
+
* - 有 sessionId:使用默认菜单 + 用户配置(可定制每一项的 show/text/icon 等)
|
|
45964
|
+
* - 无 sessionId:不渲染任何下拉菜单,仅保留点击浮标打开对话框的能力
|
|
45496
45965
|
*/
|
|
45497
45966
|
mergeMenuItems(userMenuItems) {
|
|
45967
|
+
if (!this.options.sessionId) {
|
|
45968
|
+
return [];
|
|
45969
|
+
}
|
|
45498
45970
|
if (!userMenuItems) {
|
|
45499
45971
|
return getDefaultMenuItems(this.options);
|
|
45500
45972
|
}
|
|
@@ -45504,7 +45976,6 @@ ${observationText}
|
|
|
45504
45976
|
return {
|
|
45505
45977
|
...defaultItem,
|
|
45506
45978
|
...userItem,
|
|
45507
|
-
// 确保show属性存在,默认为true
|
|
45508
45979
|
show: userItem.show !== void 0 ? userItem.show : defaultItem.show
|
|
45509
45980
|
};
|
|
45510
45981
|
}
|
|
@@ -45648,9 +46119,11 @@ ${observationText}
|
|
|
45648
46119
|
this.closeDropdown();
|
|
45649
46120
|
}
|
|
45650
46121
|
copyRemoteControl() {
|
|
46122
|
+
if (!this.options.sessionId) return;
|
|
45651
46123
|
this.copyToClipboard(this.options.sessionId.slice(-6));
|
|
45652
46124
|
}
|
|
45653
46125
|
copyRemoteURL() {
|
|
46126
|
+
if (!this.options.sessionId) return;
|
|
45654
46127
|
this.copyToClipboard(this.options.remoteUrl + this.sessionPrefix + this.options.sessionId);
|
|
45655
46128
|
}
|
|
45656
46129
|
// 实现复制到剪贴板功能
|
|
@@ -45698,8 +46171,9 @@ ${observationText}
|
|
|
45698
46171
|
}, 300);
|
|
45699
46172
|
}, 1500);
|
|
45700
46173
|
}
|
|
45701
|
-
//
|
|
46174
|
+
// 创建二维码弹窗(无 sessionId 时不展示)
|
|
45702
46175
|
async showQRCode() {
|
|
46176
|
+
if (!this.options.sessionId) return;
|
|
45703
46177
|
const qrCode2 = new QrCode((this.options.qrCodeUrl || "") + this.sessionPrefix + this.options.sessionId, {});
|
|
45704
46178
|
const base642 = await qrCode2.toDataURL();
|
|
45705
46179
|
const modal = this.createModal(
|
|
@@ -46175,6 +46649,19 @@ ${observationText}
|
|
|
46175
46649
|
this.dropdownMenu.parentNode.removeChild(this.dropdownMenu);
|
|
46176
46650
|
}
|
|
46177
46651
|
}
|
|
46652
|
+
// 隐藏组件
|
|
46653
|
+
hide() {
|
|
46654
|
+
if (this.floatingBlock) {
|
|
46655
|
+
this.floatingBlock.style.display = "none";
|
|
46656
|
+
}
|
|
46657
|
+
this.closeDropdown();
|
|
46658
|
+
}
|
|
46659
|
+
// 显示组件
|
|
46660
|
+
show() {
|
|
46661
|
+
if (this.floatingBlock) {
|
|
46662
|
+
this.floatingBlock.style.display = "flex";
|
|
46663
|
+
}
|
|
46664
|
+
}
|
|
46178
46665
|
}
|
|
46179
46666
|
const createRemoter = (options = {}) => {
|
|
46180
46667
|
return new FloatingBlock(options);
|