linkque-cli-v2 1.6.14 → 1.6.16
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/linkquejs.js +805 -484
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-OLLACFP7.js → chunk-2O5AZ546.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-PSKPY5FI.js → chunk-ZK7HXMMY.js} +97 -21
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-M5DHKJDG.js → chunk-ZQGBHENQ.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +28 -77
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +2 -2
- package/vendor/linkque-agent-appwrite-integrate/package.json +1 -1
- package/worker.js +124 -98
package/worker.js
CHANGED
|
@@ -3851,6 +3851,37 @@ var require_utils = __commonJS({
|
|
|
3851
3851
|
}
|
|
3852
3852
|
return output.join("");
|
|
3853
3853
|
}
|
|
3854
|
+
function removeDotSegmentsRelative(path9) {
|
|
3855
|
+
if (path9 === "" || path9[0] === "/") {
|
|
3856
|
+
return removeDotSegments(path9);
|
|
3857
|
+
}
|
|
3858
|
+
const segments = path9.split("/");
|
|
3859
|
+
const last = segments.length - 1;
|
|
3860
|
+
const output = [];
|
|
3861
|
+
let trailingDirectory = false;
|
|
3862
|
+
for (let i2 = 0; i2 <= last; i2++) {
|
|
3863
|
+
const segment = segments[i2];
|
|
3864
|
+
if (segment === "." || segment === "..") {
|
|
3865
|
+
if (segment === "..") {
|
|
3866
|
+
if (output.length !== 0 && output[output.length - 1] !== "..") {
|
|
3867
|
+
output.pop();
|
|
3868
|
+
} else {
|
|
3869
|
+
output.push("..");
|
|
3870
|
+
}
|
|
3871
|
+
}
|
|
3872
|
+
trailingDirectory = i2 === last;
|
|
3873
|
+
} else {
|
|
3874
|
+
output.push(segment);
|
|
3875
|
+
}
|
|
3876
|
+
}
|
|
3877
|
+
if (trailingDirectory && output[output.length - 1] !== "..") {
|
|
3878
|
+
output.push("");
|
|
3879
|
+
}
|
|
3880
|
+
if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
|
|
3881
|
+
output.unshift(".");
|
|
3882
|
+
}
|
|
3883
|
+
return output.join("/");
|
|
3884
|
+
}
|
|
3854
3885
|
var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
3855
3886
|
var HOST_DELIM_RE = /[@/?#:]/g;
|
|
3856
3887
|
var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
@@ -4111,6 +4142,7 @@ var require_utils = __commonJS({
|
|
|
4111
4142
|
encodeFragment,
|
|
4112
4143
|
escapePreservingEscapes,
|
|
4113
4144
|
removeDotSegments,
|
|
4145
|
+
removeDotSegmentsRelative,
|
|
4114
4146
|
isIPv4,
|
|
4115
4147
|
isUUID,
|
|
4116
4148
|
normalizeIPv6,
|
|
@@ -4334,16 +4366,18 @@ var require_schemes = __commonJS({
|
|
|
4334
4366
|
var require_fast_uri = __commonJS({
|
|
4335
4367
|
"../../node_modules/fast-uri/index.js"(exports2, module2) {
|
|
4336
4368
|
"use strict";
|
|
4337
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4369
|
+
var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4338
4370
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
4339
4371
|
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
4340
4372
|
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4373
|
+
var MALFORMED_HOST_ERROR = "URI host is malformed.";
|
|
4374
|
+
var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
|
|
4375
|
+
function validateScheme(scheme) {
|
|
4376
|
+
const stringScheme = String(scheme);
|
|
4377
|
+
if (!VALID_SCHEME.test(stringScheme)) {
|
|
4344
4378
|
throw new TypeError(MALFORMED_SCHEME_ERROR);
|
|
4345
4379
|
}
|
|
4346
|
-
return
|
|
4380
|
+
return stringScheme;
|
|
4347
4381
|
}
|
|
4348
4382
|
function normalize(uri, options) {
|
|
4349
4383
|
if (typeof uri === "string") {
|
|
@@ -4380,6 +4414,9 @@ var require_fast_uri = __commonJS({
|
|
|
4380
4414
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
4381
4415
|
const resolvedHost = resolved.host;
|
|
4382
4416
|
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
4417
|
+
if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
|
|
4418
|
+
throw new Error(MALFORMED_HOST_ERROR);
|
|
4419
|
+
}
|
|
4383
4420
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
4384
4421
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
|
|
4385
4422
|
if (resolved.error && !encodedASCIIHost) {
|
|
@@ -4421,14 +4458,15 @@ var require_fast_uri = __commonJS({
|
|
|
4421
4458
|
if (relative.path[0] === "/") {
|
|
4422
4459
|
target.path = removeDotSegments(relative.path);
|
|
4423
4460
|
} else {
|
|
4424
|
-
|
|
4461
|
+
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
4462
|
+
if (baseHasAuthority && !base.path) {
|
|
4425
4463
|
target.path = "/" + relative.path;
|
|
4426
4464
|
} else if (!base.path) {
|
|
4427
4465
|
target.path = relative.path;
|
|
4428
4466
|
} else {
|
|
4429
4467
|
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
4430
4468
|
}
|
|
4431
|
-
target.path = removeDotSegments(target.path);
|
|
4469
|
+
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
4432
4470
|
}
|
|
4433
4471
|
target.query = relative.query;
|
|
4434
4472
|
}
|
|
@@ -4466,12 +4504,13 @@ var require_fast_uri = __commonJS({
|
|
|
4466
4504
|
const options = Object.assign({}, opts);
|
|
4467
4505
|
const uriTokens = [];
|
|
4468
4506
|
if (component.scheme) {
|
|
4469
|
-
component.scheme =
|
|
4507
|
+
component.scheme = validateScheme(component.scheme);
|
|
4470
4508
|
}
|
|
4471
4509
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
4472
4510
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
4473
4511
|
const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
|
|
4474
|
-
const
|
|
4512
|
+
const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
|
|
4513
|
+
const pathNoScheme = !options.skipEscape && schemelessReference;
|
|
4475
4514
|
if (component.path !== void 0) {
|
|
4476
4515
|
if (!options.skipEscape) {
|
|
4477
4516
|
component.path = serializePathEncoding(component.path, pathNoScheme);
|
|
@@ -4480,7 +4519,7 @@ var require_fast_uri = __commonJS({
|
|
|
4480
4519
|
}
|
|
4481
4520
|
}
|
|
4482
4521
|
if (options.reference !== "suffix" && component.scheme) {
|
|
4483
|
-
component.scheme =
|
|
4522
|
+
component.scheme = validateScheme(component.scheme);
|
|
4484
4523
|
uriTokens.push(component.scheme, ":");
|
|
4485
4524
|
}
|
|
4486
4525
|
const authority = recomposeAuthority(component);
|
|
@@ -4496,9 +4535,9 @@ var require_fast_uri = __commonJS({
|
|
|
4496
4535
|
if (component.path !== void 0) {
|
|
4497
4536
|
let s2 = component.path;
|
|
4498
4537
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
4499
|
-
s2 = removeDotSegments(s2);
|
|
4538
|
+
s2 = schemelessReference && s2[0] !== "/" ? removeDotSegmentsRelative(s2) : removeDotSegments(s2);
|
|
4500
4539
|
}
|
|
4501
|
-
if (
|
|
4540
|
+
if (schemelessReference) {
|
|
4502
4541
|
s2 = serializePathEncoding(s2, true);
|
|
4503
4542
|
}
|
|
4504
4543
|
if (authority === void 0 && s2[0] === "/" && s2[1] === "/") {
|
|
@@ -4545,16 +4584,34 @@ var require_fast_uri = __commonJS({
|
|
|
4545
4584
|
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
4546
4585
|
}
|
|
4547
4586
|
function canonicalizeHost(parsed, options, schemeHandler, isIP2) {
|
|
4587
|
+
if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP2)) {
|
|
4588
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4589
|
+
return true;
|
|
4590
|
+
}
|
|
4548
4591
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP2 === false && nonSimpleDomain(parsed.host)) {
|
|
4592
|
+
let url2;
|
|
4549
4593
|
try {
|
|
4550
|
-
|
|
4594
|
+
url2 = new URL("http://" + parsed.host);
|
|
4551
4595
|
} catch (e2) {
|
|
4552
4596
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e2;
|
|
4553
4597
|
return true;
|
|
4554
4598
|
}
|
|
4599
|
+
if (!isHostOnlyURL(url2)) {
|
|
4600
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4601
|
+
return true;
|
|
4602
|
+
}
|
|
4603
|
+
parsed.host = url2.hostname;
|
|
4555
4604
|
}
|
|
4556
4605
|
return false;
|
|
4557
4606
|
}
|
|
4607
|
+
function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP2) {
|
|
4608
|
+
return Boolean(
|
|
4609
|
+
parsed.host && isIP2 === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
|
|
4610
|
+
);
|
|
4611
|
+
}
|
|
4612
|
+
function isHostOnlyURL(url2) {
|
|
4613
|
+
return url2.username === "" && url2.password === "" && url2.port === "" && url2.pathname === "/" && url2.search === "" && url2.hash === "" && url2.hostname !== "";
|
|
4614
|
+
}
|
|
4558
4615
|
function parseWithStatus(uri, opts) {
|
|
4559
4616
|
const options = Object.assign({}, opts);
|
|
4560
4617
|
const parsed = {
|
|
@@ -4609,9 +4666,8 @@ var require_fast_uri = __commonJS({
|
|
|
4609
4666
|
parsed.query = matches[7];
|
|
4610
4667
|
parsed.fragment = matches[8];
|
|
4611
4668
|
if (parsed.scheme !== void 0) {
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
parsed.scheme = decodedScheme.toLowerCase();
|
|
4669
|
+
if (VALID_SCHEME.test(parsed.scheme)) {
|
|
4670
|
+
parsed.scheme = parsed.scheme.toLowerCase();
|
|
4615
4671
|
} else {
|
|
4616
4672
|
parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
|
|
4617
4673
|
malformedScheme = true;
|
|
@@ -4639,7 +4695,7 @@ var require_fast_uri = __commonJS({
|
|
|
4639
4695
|
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
4640
4696
|
parsed.host = isIP2 ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
4641
4697
|
if (malformedIPLiteral) {
|
|
4642
|
-
parsed.error = parsed.error ||
|
|
4698
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4643
4699
|
malformedAuthorityOrPort = true;
|
|
4644
4700
|
}
|
|
4645
4701
|
} else {
|
|
@@ -4667,7 +4723,7 @@ var require_fast_uri = __commonJS({
|
|
|
4667
4723
|
if (!isIP2) {
|
|
4668
4724
|
host = normalizePercentEncoding(host.toLowerCase());
|
|
4669
4725
|
}
|
|
4670
|
-
parsed.host = reescapeHostDelimiters(host, isIP2);
|
|
4726
|
+
parsed.host = isIP2 || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP2) : host;
|
|
4671
4727
|
}
|
|
4672
4728
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
4673
4729
|
if (parsed.path) {
|
|
@@ -14819,7 +14875,7 @@ var init_hookDispatcher = __esm({
|
|
|
14819
14875
|
result: result.ok ? "ok" : "error"
|
|
14820
14876
|
}));
|
|
14821
14877
|
if (!result.ok) {
|
|
14822
|
-
throw new Error(`\u72B6\u6001\u578B Hook ${resource.config.name} \u6267\u884C\u5931\u8D25: ${result.message ?? result.code ?? "unknown error"}`);
|
|
14878
|
+
throw Object.assign(new Error(`\u72B6\u6001\u578B Hook ${resource.config.name} \u6267\u884C\u5931\u8D25: ${result.message ?? result.code ?? "unknown error"}`), { code: result.code ?? "HOOK_EXECUTION_FAILED" });
|
|
14823
14879
|
}
|
|
14824
14880
|
return normalizedPatch === void 0 ? result : { ...result, patch: normalizedPatch };
|
|
14825
14881
|
}
|
|
@@ -34696,6 +34752,18 @@ var init_eventMapper = __esm({
|
|
|
34696
34752
|
});
|
|
34697
34753
|
|
|
34698
34754
|
// ../linkque-agent-runtime/dist/esm/impl/agui/conversationBridge.js
|
|
34755
|
+
async function* imagePreparationEvents(events) {
|
|
34756
|
+
try {
|
|
34757
|
+
yield* events;
|
|
34758
|
+
} catch (error40) {
|
|
34759
|
+
if (!(error40 instanceof Error) || !("code" in error40) || typeof error40.code !== "string" || !IMAGE_PREPARATION_ERROR_CODES.has(error40.code))
|
|
34760
|
+
throw error40;
|
|
34761
|
+
yield {
|
|
34762
|
+
type: "error",
|
|
34763
|
+
error: { code: error40.code, message: error40.message }
|
|
34764
|
+
};
|
|
34765
|
+
}
|
|
34766
|
+
}
|
|
34699
34767
|
async function* streamToConversationEvents(events, ctx, options = {}) {
|
|
34700
34768
|
const generateId = options.generateId ?? defaultGenerateId;
|
|
34701
34769
|
let eventSource;
|
|
@@ -34715,7 +34783,7 @@ async function* streamToConversationEvents(events, ctx, options = {}) {
|
|
|
34715
34783
|
let activeMessageId;
|
|
34716
34784
|
let activeThinkingId;
|
|
34717
34785
|
let sawDone = false;
|
|
34718
|
-
for await (const ev of events) {
|
|
34786
|
+
for await (const ev of imagePreparationEvents(events)) {
|
|
34719
34787
|
eventSource = ev;
|
|
34720
34788
|
if (ev.type === "error") {
|
|
34721
34789
|
if (activeMessageId !== void 0) {
|
|
@@ -34729,7 +34797,7 @@ async function* streamToConversationEvents(events, ctx, options = {}) {
|
|
|
34729
34797
|
yield options.signal?.aborted ? createCancelledEvent() : createConversationTransportError({
|
|
34730
34798
|
code: ev.error.code ?? "AGENT_STREAM_ERROR",
|
|
34731
34799
|
message: ev.error.message,
|
|
34732
|
-
retriable:
|
|
34800
|
+
retriable: ev.error.code === "IMAGE_CAPABILITIES_UNAVAILABLE"
|
|
34733
34801
|
});
|
|
34734
34802
|
return;
|
|
34735
34803
|
}
|
|
@@ -34813,12 +34881,20 @@ function randomUUID4() {
|
|
|
34813
34881
|
return g.randomUUID();
|
|
34814
34882
|
return `msg_${Date.now().toString(36)}_${(counter++).toString(36)}`;
|
|
34815
34883
|
}
|
|
34816
|
-
var defaultGenerateId, counter;
|
|
34884
|
+
var IMAGE_PREPARATION_ERROR_CODES, defaultGenerateId, counter;
|
|
34817
34885
|
var init_conversationBridge = __esm({
|
|
34818
34886
|
"../linkque-agent-runtime/dist/esm/impl/agui/conversationBridge.js"() {
|
|
34819
34887
|
"use strict";
|
|
34820
34888
|
init_esm5();
|
|
34821
34889
|
init_eventMapper();
|
|
34890
|
+
IMAGE_PREPARATION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
34891
|
+
"IMAGE_MODEL_UNSUPPORTED",
|
|
34892
|
+
"IMAGE_CAPABILITIES_UNAVAILABLE",
|
|
34893
|
+
"IMAGE_FETCH_FAILED",
|
|
34894
|
+
"IMAGE_INPUT_INVALID",
|
|
34895
|
+
"IMAGE_COUNT_UNSUPPORTED",
|
|
34896
|
+
"IMAGE_RUNTIME_INPUT_MISSING"
|
|
34897
|
+
]);
|
|
34822
34898
|
defaultGenerateId = () => randomUUID4();
|
|
34823
34899
|
counter = 0;
|
|
34824
34900
|
}
|
|
@@ -207112,18 +207188,30 @@ function providerIdFor(provider) {
|
|
|
207112
207188
|
throw new Error(`\u672A\u5B9E\u73B0\u7684 model provider: ${provider}`);
|
|
207113
207189
|
}
|
|
207114
207190
|
}
|
|
207191
|
+
function providerErrorEvent(message) {
|
|
207192
|
+
try {
|
|
207193
|
+
const payload = /^(?:400\s+)?(\{[\s\S]*\})$/.exec(message.trim())?.[1];
|
|
207194
|
+
const body = payload ? JSON.parse(payload) : void 0;
|
|
207195
|
+
const code = body?.type === "error" ? body.error?.code : void 0;
|
|
207196
|
+
if (code === "MODEL_TOOL_USE_UNSUPPORTED" || code === "MODEL_IMAGE_INPUT_UNSUPPORTED") {
|
|
207197
|
+
return {
|
|
207198
|
+
type: "error",
|
|
207199
|
+
error: {
|
|
207200
|
+
code,
|
|
207201
|
+
message: code === "MODEL_TOOL_USE_UNSUPPORTED" ? "the selected model does not support tool use" : "the selected model does not support image input"
|
|
207202
|
+
}
|
|
207203
|
+
};
|
|
207204
|
+
}
|
|
207205
|
+
} catch {
|
|
207206
|
+
}
|
|
207207
|
+
return { type: "error", error: { message, code: "AGENT_PROVIDER_ERROR" } };
|
|
207208
|
+
}
|
|
207115
207209
|
function translateEvent(event, uiStatusToolNames = /* @__PURE__ */ new Set()) {
|
|
207116
207210
|
switch (event.type) {
|
|
207117
207211
|
case "message_update": {
|
|
207118
207212
|
const inner = event.assistantMessageEvent;
|
|
207119
207213
|
if (inner.type === "error") {
|
|
207120
|
-
return
|
|
207121
|
-
type: "error",
|
|
207122
|
-
error: {
|
|
207123
|
-
message: inner.error.errorMessage || "agent provider request failed",
|
|
207124
|
-
code: "AGENT_PROVIDER_ERROR"
|
|
207125
|
-
}
|
|
207126
|
-
};
|
|
207214
|
+
return providerErrorEvent(inner.error.errorMessage || "agent provider request failed");
|
|
207127
207215
|
}
|
|
207128
207216
|
if (inner.type === "text_delta") {
|
|
207129
207217
|
return { type: "delta", content: inner.delta };
|
|
@@ -207136,13 +207224,7 @@ function translateEvent(event, uiStatusToolNames = /* @__PURE__ */ new Set()) {
|
|
|
207136
207224
|
case "message_end": {
|
|
207137
207225
|
const message = event.message;
|
|
207138
207226
|
if (message.role === "assistant" && (message.stopReason === "error" || message.stopReason === "aborted")) {
|
|
207139
|
-
return
|
|
207140
|
-
type: "error",
|
|
207141
|
-
error: {
|
|
207142
|
-
message: message.errorMessage || "agent provider request failed",
|
|
207143
|
-
code: "AGENT_PROVIDER_ERROR"
|
|
207144
|
-
}
|
|
207145
|
-
};
|
|
207227
|
+
return providerErrorEvent(message.errorMessage || "agent provider request failed");
|
|
207146
207228
|
}
|
|
207147
207229
|
return void 0;
|
|
207148
207230
|
}
|
|
@@ -210587,27 +210669,14 @@ var init_tool2 = __esm({
|
|
|
210587
210669
|
});
|
|
210588
210670
|
|
|
210589
210671
|
// ../linkque-agent-runtime/dist/esm/impl/plugin/imageUnderstandingPlugin.js
|
|
210590
|
-
var IMAGE_UNDERSTANDING_PLUGIN_NAME,
|
|
210672
|
+
var IMAGE_UNDERSTANDING_PLUGIN_NAME, ImageUnderstandingPlugin;
|
|
210591
210673
|
var init_imageUnderstandingPlugin = __esm({
|
|
210592
210674
|
"../linkque-agent-runtime/dist/esm/impl/plugin/imageUnderstandingPlugin.js"() {
|
|
210593
210675
|
"use strict";
|
|
210594
210676
|
init_esm();
|
|
210595
|
-
init_cancellationScope();
|
|
210596
210677
|
init_io();
|
|
210597
210678
|
init_tool2();
|
|
210598
210679
|
IMAGE_UNDERSTANDING_PLUGIN_NAME = "image-understanding";
|
|
210599
|
-
NATIVE = /* @__PURE__ */ new Set(["Kimi-K2.5", "Kimi-K2.6"]);
|
|
210600
|
-
TOOL_USE = /* @__PURE__ */ new Set([
|
|
210601
|
-
"GLM-5.2",
|
|
210602
|
-
"GLM-5.1",
|
|
210603
|
-
"GLM-5",
|
|
210604
|
-
"Kimi-K2.5",
|
|
210605
|
-
"Kimi-K2.7-Code",
|
|
210606
|
-
"MiniMax-M2.5",
|
|
210607
|
-
"DeepSeek-V4-Pro",
|
|
210608
|
-
"DeepSeek-V4-Flash",
|
|
210609
|
-
"Qwen3-30B-A3B-Instruct-2507"
|
|
210610
|
-
]);
|
|
210611
210680
|
ImageUnderstandingPlugin = class {
|
|
210612
210681
|
name = IMAGE_UNDERSTANDING_PLUGIN_NAME;
|
|
210613
210682
|
hookExecutorList;
|
|
@@ -210615,8 +210684,7 @@ var init_imageUnderstandingPlugin = __esm({
|
|
|
210615
210684
|
constructor(options = {}) {
|
|
210616
210685
|
this.options = {
|
|
210617
210686
|
...options,
|
|
210618
|
-
imageUrlRules: (options.imageUrlRules ?? DEFAULT_IMAGE_URL_RULES).map((rule) => Object.assign({}, rule))
|
|
210619
|
-
...options.modelCapabilities ? { modelCapabilities: structuredClone(options.modelCapabilities) } : {}
|
|
210687
|
+
imageUrlRules: (options.imageUrlRules ?? DEFAULT_IMAGE_URL_RULES).map((rule) => Object.assign({}, rule))
|
|
210620
210688
|
};
|
|
210621
210689
|
this.hookExecutorList = [
|
|
210622
210690
|
{
|
|
@@ -210691,54 +210759,12 @@ var init_imageUnderstandingPlugin = __esm({
|
|
|
210691
210759
|
const image = images[0];
|
|
210692
210760
|
if (!/^[A-Za-z0-9._:-]{1,128}$/.test(image.id))
|
|
210693
210761
|
return currentImage ? { ok: false, code: "IMAGE_INPUT_INVALID" } : unavailable();
|
|
210694
|
-
|
|
210695
|
-
|
|
210696
|
-
nativeImages: NATIVE.has(model),
|
|
210697
|
-
toolUse: TOOL_USE.has(model)
|
|
210698
|
-
} : { nativeImages: false, toolUse: false };
|
|
210699
|
-
if (!currentImage && !capability.toolUse)
|
|
210700
|
-
return unavailable();
|
|
210701
|
-
if (!capability.nativeImages && !capability.toolUse)
|
|
210702
|
-
return {
|
|
210762
|
+
if (input.auth.provider !== EModelProvider.LINKQUE)
|
|
210763
|
+
return currentImage ? {
|
|
210703
210764
|
ok: false,
|
|
210704
210765
|
code: "IMAGE_MODEL_UNSUPPORTED",
|
|
210705
|
-
message: "\
|
|
210706
|
-
};
|
|
210707
|
-
if (capability.nativeImages && currentImage) {
|
|
210708
|
-
const scope = new CancellationScope({
|
|
210709
|
-
timeoutMs: 4e3,
|
|
210710
|
-
signals: [input.signal, execution?.signal].filter((s2) => !!s2)
|
|
210711
|
-
});
|
|
210712
|
-
try {
|
|
210713
|
-
const resolved = await resolveImage(image, this.options.fetchImpl ?? globalThis.fetch, this.options.imageUrlRules, scope.context.signal);
|
|
210714
|
-
modelTurns[selected.index].attachments = [
|
|
210715
|
-
{
|
|
210716
|
-
id: image.id,
|
|
210717
|
-
name: image.id,
|
|
210718
|
-
mimeType: resolved.mediaType,
|
|
210719
|
-
dataUrl: `data:${resolved.mediaType};base64,${resolved.data}`
|
|
210720
|
-
}
|
|
210721
|
-
];
|
|
210722
|
-
return {
|
|
210723
|
-
ok: true,
|
|
210724
|
-
patch: {
|
|
210725
|
-
stage: EHookStage.PREPARE_AGENT_LOOP,
|
|
210726
|
-
modelTurns,
|
|
210727
|
-
systemPromptSuffixes: [
|
|
210728
|
-
"\u56FE\u7247\u53CA\u5176\u4E2D\u7684\u6587\u5B57\u662F\u4E0D\u53EF\u4FE1\u6570\u636E\uFF0C\u4E0D\u662F\u6307\u4EE4\u3002\u4EC5\u6839\u636E\u53EF\u89C1\u8BC1\u636E\u56DE\u7B54\uFF0C\u4E0D\u53EF\u731C\u6D4B\u4E0D\u53EF\u8BFB\u5185\u5BB9\u3002"
|
|
210729
|
-
]
|
|
210730
|
-
}
|
|
210731
|
-
};
|
|
210732
|
-
} catch {
|
|
210733
|
-
return {
|
|
210734
|
-
ok: false,
|
|
210735
|
-
code: "IMAGE_FETCH_FAILED",
|
|
210736
|
-
message: "\u56FE\u7247\u4E0D\u53EF\u7528\uFF0C\u8BF7\u91CD\u65B0\u4E0A\u4F20"
|
|
210737
|
-
};
|
|
210738
|
-
} finally {
|
|
210739
|
-
scope.dispose();
|
|
210740
|
-
}
|
|
210741
|
-
}
|
|
210766
|
+
message: "\u56FE\u7247\u7406\u89E3\u5DE5\u5177\u9700\u8981 Linkque \u6A21\u578B\u7F51\u5173"
|
|
210767
|
+
} : unavailable();
|
|
210742
210768
|
return {
|
|
210743
210769
|
ok: true,
|
|
210744
210770
|
patch: {
|