linkque-cli-v2 1.6.7 → 1.6.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/linkquejs.js +95 -25
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-SICWMO5Y.js → chunk-DNTEEBEH.js} +0 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-Y2STWI2J.js → chunk-OYT6HQOV.js} +140 -59
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-Z2A5GMVJ.js → chunk-U6OH2FQV.js} +1 -26
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-C2TN5LPS.js → chunk-UAOFFEXJ.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-bsd-NYGVHXGN.js → getMachineId-bsd-JGCLGHFY.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-darwin-OPTJOAYC.js → getMachineId-darwin-COHLFNXH.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-linux-5SQRYTUJ.js → getMachineId-linux-XV3Z5FQG.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-unsupported-OJE7WPEH.js → getMachineId-unsupported-FCRKLIZL.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-win-SLTTCNXU.js → getMachineId-win-A4WRNVV6.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-C43A6QIS.js → mistral-conversations-OEOTQWE5.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{otel-RUUFBBFE.js → otel-WGS5CC2J.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +28 -58
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +3 -3
- package/worker.js +119 -73
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-Y2STWI2J.js → chunk-OYT6HQOV.js}
RENAMED
|
@@ -388,9 +388,8 @@ import {
|
|
|
388
388
|
esm_exports,
|
|
389
389
|
init_esm,
|
|
390
390
|
isSpanContextValid,
|
|
391
|
-
isValidTraceId,
|
|
392
391
|
trace
|
|
393
|
-
} from "./chunk-
|
|
392
|
+
} from "./chunk-DNTEEBEH.js";
|
|
394
393
|
import {
|
|
395
394
|
__commonJS,
|
|
396
395
|
__esm,
|
|
@@ -3704,6 +3703,37 @@ var require_utils = __commonJS({
|
|
|
3704
3703
|
}
|
|
3705
3704
|
return output.join("");
|
|
3706
3705
|
}
|
|
3706
|
+
function removeDotSegmentsRelative(path2) {
|
|
3707
|
+
if (path2 === "" || path2[0] === "/") {
|
|
3708
|
+
return removeDotSegments(path2);
|
|
3709
|
+
}
|
|
3710
|
+
const segments = path2.split("/");
|
|
3711
|
+
const last = segments.length - 1;
|
|
3712
|
+
const output = [];
|
|
3713
|
+
let trailingDirectory = false;
|
|
3714
|
+
for (let i = 0; i <= last; i++) {
|
|
3715
|
+
const segment = segments[i];
|
|
3716
|
+
if (segment === "." || segment === "..") {
|
|
3717
|
+
if (segment === "..") {
|
|
3718
|
+
if (output.length !== 0 && output[output.length - 1] !== "..") {
|
|
3719
|
+
output.pop();
|
|
3720
|
+
} else {
|
|
3721
|
+
output.push("..");
|
|
3722
|
+
}
|
|
3723
|
+
}
|
|
3724
|
+
trailingDirectory = i === last;
|
|
3725
|
+
} else {
|
|
3726
|
+
output.push(segment);
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
if (trailingDirectory && output[output.length - 1] !== "..") {
|
|
3730
|
+
output.push("");
|
|
3731
|
+
}
|
|
3732
|
+
if (output.length === 0 || output[0] === "" || output[0].includes(":")) {
|
|
3733
|
+
output.unshift(".");
|
|
3734
|
+
}
|
|
3735
|
+
return output.join("/");
|
|
3736
|
+
}
|
|
3707
3737
|
var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
3708
3738
|
var HOST_DELIM_RE = /[@/?#:]/g;
|
|
3709
3739
|
var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
@@ -3964,6 +3994,7 @@ var require_utils = __commonJS({
|
|
|
3964
3994
|
encodeFragment,
|
|
3965
3995
|
escapePreservingEscapes,
|
|
3966
3996
|
removeDotSegments,
|
|
3997
|
+
removeDotSegmentsRelative,
|
|
3967
3998
|
isIPv4,
|
|
3968
3999
|
isUUID,
|
|
3969
4000
|
normalizeIPv6,
|
|
@@ -4187,16 +4218,18 @@ var require_schemes = __commonJS({
|
|
|
4187
4218
|
var require_fast_uri = __commonJS({
|
|
4188
4219
|
"../../node_modules/fast-uri/index.js"(exports, module) {
|
|
4189
4220
|
"use strict";
|
|
4190
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4221
|
+
var { normalizeIPv6, removeDotSegments, removeDotSegmentsRelative, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4191
4222
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
4192
4223
|
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
4193
4224
|
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4225
|
+
var MALFORMED_HOST_ERROR = "URI host is malformed.";
|
|
4226
|
+
var FORBIDDEN_DOMAIN_HOST_CHARACTER = /[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;
|
|
4227
|
+
function validateScheme(scheme) {
|
|
4228
|
+
const stringScheme = String(scheme);
|
|
4229
|
+
if (!VALID_SCHEME.test(stringScheme)) {
|
|
4197
4230
|
throw new TypeError(MALFORMED_SCHEME_ERROR);
|
|
4198
4231
|
}
|
|
4199
|
-
return
|
|
4232
|
+
return stringScheme;
|
|
4200
4233
|
}
|
|
4201
4234
|
function normalize(uri, options) {
|
|
4202
4235
|
if (typeof uri === "string") {
|
|
@@ -4233,6 +4266,9 @@ var require_fast_uri = __commonJS({
|
|
|
4233
4266
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
4234
4267
|
const resolvedHost = resolved.host;
|
|
4235
4268
|
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
4269
|
+
if (hasForbiddenDomainHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP)) {
|
|
4270
|
+
throw new Error(MALFORMED_HOST_ERROR);
|
|
4271
|
+
}
|
|
4236
4272
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
4237
4273
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
|
|
4238
4274
|
if (resolved.error && !encodedASCIIHost) {
|
|
@@ -4274,14 +4310,15 @@ var require_fast_uri = __commonJS({
|
|
|
4274
4310
|
if (relative.path[0] === "/") {
|
|
4275
4311
|
target.path = removeDotSegments(relative.path);
|
|
4276
4312
|
} else {
|
|
4277
|
-
|
|
4313
|
+
const baseHasAuthority = base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0;
|
|
4314
|
+
if (baseHasAuthority && !base.path) {
|
|
4278
4315
|
target.path = "/" + relative.path;
|
|
4279
4316
|
} else if (!base.path) {
|
|
4280
4317
|
target.path = relative.path;
|
|
4281
4318
|
} else {
|
|
4282
4319
|
target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
|
|
4283
4320
|
}
|
|
4284
|
-
target.path = removeDotSegments(target.path);
|
|
4321
|
+
target.path = base.scheme === void 0 && !baseHasAuthority && target.path[0] !== "/" ? removeDotSegmentsRelative(target.path) : removeDotSegments(target.path);
|
|
4285
4322
|
}
|
|
4286
4323
|
target.query = relative.query;
|
|
4287
4324
|
}
|
|
@@ -4319,12 +4356,13 @@ var require_fast_uri = __commonJS({
|
|
|
4319
4356
|
const options = Object.assign({}, opts);
|
|
4320
4357
|
const uriTokens = [];
|
|
4321
4358
|
if (component.scheme) {
|
|
4322
|
-
component.scheme =
|
|
4359
|
+
component.scheme = validateScheme(component.scheme);
|
|
4323
4360
|
}
|
|
4324
4361
|
const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
|
|
4325
4362
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
4326
4363
|
const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
|
|
4327
|
-
const
|
|
4364
|
+
const schemelessReference = (component.scheme === void 0 || options.reference === "suffix") && !hasAuthority;
|
|
4365
|
+
const pathNoScheme = !options.skipEscape && schemelessReference;
|
|
4328
4366
|
if (component.path !== void 0) {
|
|
4329
4367
|
if (!options.skipEscape) {
|
|
4330
4368
|
component.path = serializePathEncoding(component.path, pathNoScheme);
|
|
@@ -4333,7 +4371,7 @@ var require_fast_uri = __commonJS({
|
|
|
4333
4371
|
}
|
|
4334
4372
|
}
|
|
4335
4373
|
if (options.reference !== "suffix" && component.scheme) {
|
|
4336
|
-
component.scheme =
|
|
4374
|
+
component.scheme = validateScheme(component.scheme);
|
|
4337
4375
|
uriTokens.push(component.scheme, ":");
|
|
4338
4376
|
}
|
|
4339
4377
|
const authority = recomposeAuthority(component);
|
|
@@ -4349,9 +4387,9 @@ var require_fast_uri = __commonJS({
|
|
|
4349
4387
|
if (component.path !== void 0) {
|
|
4350
4388
|
let s = component.path;
|
|
4351
4389
|
if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
|
|
4352
|
-
s = removeDotSegments(s);
|
|
4390
|
+
s = schemelessReference && s[0] !== "/" ? removeDotSegmentsRelative(s) : removeDotSegments(s);
|
|
4353
4391
|
}
|
|
4354
|
-
if (
|
|
4392
|
+
if (schemelessReference) {
|
|
4355
4393
|
s = serializePathEncoding(s, true);
|
|
4356
4394
|
}
|
|
4357
4395
|
if (authority === void 0 && s[0] === "/" && s[1] === "/") {
|
|
@@ -4398,16 +4436,34 @@ var require_fast_uri = __commonJS({
|
|
|
4398
4436
|
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
4399
4437
|
}
|
|
4400
4438
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
4439
|
+
if (hasForbiddenDomainHost(parsed, options, schemeHandler, isIP)) {
|
|
4440
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4441
|
+
return true;
|
|
4442
|
+
}
|
|
4401
4443
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
4444
|
+
let url2;
|
|
4402
4445
|
try {
|
|
4403
|
-
|
|
4446
|
+
url2 = new URL("http://" + parsed.host);
|
|
4404
4447
|
} catch (e) {
|
|
4405
4448
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
4406
4449
|
return true;
|
|
4407
4450
|
}
|
|
4451
|
+
if (!isHostOnlyURL(url2)) {
|
|
4452
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4453
|
+
return true;
|
|
4454
|
+
}
|
|
4455
|
+
parsed.host = url2.hostname;
|
|
4408
4456
|
}
|
|
4409
4457
|
return false;
|
|
4410
4458
|
}
|
|
4459
|
+
function hasForbiddenDomainHost(parsed, options, schemeHandler, isIP) {
|
|
4460
|
+
return Boolean(
|
|
4461
|
+
parsed.host && isIP === false && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && FORBIDDEN_DOMAIN_HOST_CHARACTER.test(parsed.host)
|
|
4462
|
+
);
|
|
4463
|
+
}
|
|
4464
|
+
function isHostOnlyURL(url2) {
|
|
4465
|
+
return url2.username === "" && url2.password === "" && url2.port === "" && url2.pathname === "/" && url2.search === "" && url2.hash === "" && url2.hostname !== "";
|
|
4466
|
+
}
|
|
4411
4467
|
function parseWithStatus(uri, opts) {
|
|
4412
4468
|
const options = Object.assign({}, opts);
|
|
4413
4469
|
const parsed = {
|
|
@@ -4462,9 +4518,8 @@ var require_fast_uri = __commonJS({
|
|
|
4462
4518
|
parsed.query = matches[7];
|
|
4463
4519
|
parsed.fragment = matches[8];
|
|
4464
4520
|
if (parsed.scheme !== void 0) {
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
parsed.scheme = decodedScheme.toLowerCase();
|
|
4521
|
+
if (VALID_SCHEME.test(parsed.scheme)) {
|
|
4522
|
+
parsed.scheme = parsed.scheme.toLowerCase();
|
|
4468
4523
|
} else {
|
|
4469
4524
|
parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
|
|
4470
4525
|
malformedScheme = true;
|
|
@@ -4492,7 +4547,7 @@ var require_fast_uri = __commonJS({
|
|
|
4492
4547
|
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
4493
4548
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
4494
4549
|
if (malformedIPLiteral) {
|
|
4495
|
-
parsed.error = parsed.error ||
|
|
4550
|
+
parsed.error = parsed.error || MALFORMED_HOST_ERROR;
|
|
4496
4551
|
malformedAuthorityOrPort = true;
|
|
4497
4552
|
}
|
|
4498
4553
|
} else {
|
|
@@ -4520,7 +4575,7 @@ var require_fast_uri = __commonJS({
|
|
|
4520
4575
|
if (!isIP) {
|
|
4521
4576
|
host = normalizePercentEncoding(host.toLowerCase());
|
|
4522
4577
|
}
|
|
4523
|
-
parsed.host = reescapeHostDelimiters(host, isIP);
|
|
4578
|
+
parsed.host = isIP || options.scheme !== "null" ? reescapeHostDelimiters(host, isIP) : host;
|
|
4524
4579
|
}
|
|
4525
4580
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
4526
4581
|
if (parsed.path) {
|
|
@@ -12859,19 +12914,19 @@ var require_getMachineId = __commonJS({
|
|
|
12859
12914
|
if (!getMachineIdImpl) {
|
|
12860
12915
|
switch (process2.platform) {
|
|
12861
12916
|
case "darwin":
|
|
12862
|
-
getMachineIdImpl = (await import("./getMachineId-darwin-
|
|
12917
|
+
getMachineIdImpl = (await import("./getMachineId-darwin-COHLFNXH.js")).getMachineId;
|
|
12863
12918
|
break;
|
|
12864
12919
|
case "linux":
|
|
12865
|
-
getMachineIdImpl = (await import("./getMachineId-linux-
|
|
12920
|
+
getMachineIdImpl = (await import("./getMachineId-linux-XV3Z5FQG.js")).getMachineId;
|
|
12866
12921
|
break;
|
|
12867
12922
|
case "freebsd":
|
|
12868
|
-
getMachineIdImpl = (await import("./getMachineId-bsd-
|
|
12923
|
+
getMachineIdImpl = (await import("./getMachineId-bsd-JGCLGHFY.js")).getMachineId;
|
|
12869
12924
|
break;
|
|
12870
12925
|
case "win32":
|
|
12871
|
-
getMachineIdImpl = (await import("./getMachineId-win-
|
|
12926
|
+
getMachineIdImpl = (await import("./getMachineId-win-A4WRNVV6.js")).getMachineId;
|
|
12872
12927
|
break;
|
|
12873
12928
|
default:
|
|
12874
|
-
getMachineIdImpl = (await import("./getMachineId-unsupported-
|
|
12929
|
+
getMachineIdImpl = (await import("./getMachineId-unsupported-FCRKLIZL.js")).getMachineId;
|
|
12875
12930
|
break;
|
|
12876
12931
|
}
|
|
12877
12932
|
}
|
|
@@ -14263,7 +14318,7 @@ var require_RandomIdGenerator = __commonJS({
|
|
|
14263
14318
|
exports.RandomIdGenerator = void 0;
|
|
14264
14319
|
var SPAN_ID_BYTES = 8;
|
|
14265
14320
|
var TRACE_ID_BYTES = 16;
|
|
14266
|
-
var
|
|
14321
|
+
var RandomIdGenerator = class {
|
|
14267
14322
|
/**
|
|
14268
14323
|
* Returns a random 16-byte trace ID formatted/encoded as a 32 lowercase hex
|
|
14269
14324
|
* characters corresponding to 128 bits.
|
|
@@ -14275,7 +14330,7 @@ var require_RandomIdGenerator = __commonJS({
|
|
|
14275
14330
|
*/
|
|
14276
14331
|
generateSpanId = getIdGenerator(SPAN_ID_BYTES);
|
|
14277
14332
|
};
|
|
14278
|
-
exports.RandomIdGenerator =
|
|
14333
|
+
exports.RandomIdGenerator = RandomIdGenerator;
|
|
14279
14334
|
var SHARED_BUFFER = Buffer.allocUnsafe(TRACE_ID_BYTES);
|
|
14280
14335
|
function getIdGenerator(bytes2) {
|
|
14281
14336
|
return function generateId() {
|
|
@@ -31250,6 +31305,37 @@ function encodeConversationSseEvent(event) {
|
|
|
31250
31305
|
// ../linkque-agent-runtime/dist/esm/impl/scenario/gatewayRunAuthorization.js
|
|
31251
31306
|
import { hkdfSync, randomBytes } from "node:crypto";
|
|
31252
31307
|
|
|
31308
|
+
// ../linkque-agent-runtime/dist/esm/core/scenarioRunAuthorization.js
|
|
31309
|
+
var SCENARIO_RUN_ERROR_CODES = [
|
|
31310
|
+
"SCENARIO_TURN_LIMIT",
|
|
31311
|
+
"SCENARIO_TURN_ID_CONFLICT",
|
|
31312
|
+
"SCENARIO_CIPHER_TIMEOUT",
|
|
31313
|
+
"SCENARIO_CIPHER_UNAVAILABLE",
|
|
31314
|
+
"SCENARIO_TURN_CONFIG_UNAVAILABLE",
|
|
31315
|
+
"SCENARIO_RUNTIME_AUTH_INVALID",
|
|
31316
|
+
"SCENARIO_RUNTIME_REPLAY",
|
|
31317
|
+
"SCENARIO_RUN_UNAVAILABLE"
|
|
31318
|
+
];
|
|
31319
|
+
function normalizeScenarioRunErrorCode(value) {
|
|
31320
|
+
return typeof value === "string" && SCENARIO_RUN_ERROR_CODES.includes(value) ? value : "SCENARIO_RUN_UNAVAILABLE";
|
|
31321
|
+
}
|
|
31322
|
+
async function authorizeAgentRun(runId, identity, port) {
|
|
31323
|
+
if (typeof runId !== "string" || !/^[\x21-\x7e]{1,64}$/u.test(runId) || typeof identity?.userId !== "string" || !/^[\x21-\x7e]{1,128}$/u.test(identity.userId) || typeof identity.agentId !== "string" || !/^[A-Za-z0-9_-]{1,128}$/u.test(identity.agentId)) {
|
|
31324
|
+
throw new Error("SCENARIO_RUNTIME_AUTH_INVALID");
|
|
31325
|
+
}
|
|
31326
|
+
const result = await port.authorizeRun({
|
|
31327
|
+
runId,
|
|
31328
|
+
agentId: identity.agentId,
|
|
31329
|
+
appbaseUserId: identity.userId
|
|
31330
|
+
});
|
|
31331
|
+
if (result?.quotaMode === "NORMAL")
|
|
31332
|
+
return { quotaMode: "NORMAL" };
|
|
31333
|
+
if (result?.quotaMode !== "LIMITED" && result?.quotaMode !== "AUTH_ONLY" || typeof result.modelFetch !== "function") {
|
|
31334
|
+
throw new Error("SCENARIO_RUN_UNAVAILABLE");
|
|
31335
|
+
}
|
|
31336
|
+
return result;
|
|
31337
|
+
}
|
|
31338
|
+
|
|
31253
31339
|
// ../linkque-agent-runtime/dist/esm/impl/scenario/runtimeMac.js
|
|
31254
31340
|
import { createHash as createHash3, createHmac, timingSafeEqual } from "node:crypto";
|
|
31255
31341
|
function invalid() {
|
|
@@ -31296,6 +31382,7 @@ function signRuntimeRequest(input, key) {
|
|
|
31296
31382
|
// ../linkque-agent-runtime/dist/esm/impl/scenario/gatewayRunAuthorization.js
|
|
31297
31383
|
var SCENARIO_RUNTIME_CALLER = "appbase-agent-function";
|
|
31298
31384
|
var SCENARIO_RUNTIME_KEY_ID = "agent-aak-v1";
|
|
31385
|
+
var SCENARIO_AUTH_REQUEST_TIMEOUT_MS = 3e4;
|
|
31299
31386
|
function deriveScenarioRuntimeMacKey(accessKey) {
|
|
31300
31387
|
const normalized = accessKey.trim();
|
|
31301
31388
|
if (!normalized)
|
|
@@ -31313,6 +31400,7 @@ function createGatewayRunAuthorization(options) {
|
|
|
31313
31400
|
}
|
|
31314
31401
|
const modelPath = `${base.pathname.replace(/\/$/u, "")}/v1/messages`;
|
|
31315
31402
|
const baseFetch = options.fetch ?? globalThis.fetch;
|
|
31403
|
+
const log = (...args) => options.debugLog?.("[scenario-run-auth]", ...args);
|
|
31316
31404
|
return {
|
|
31317
31405
|
async authorizeRun(identity) {
|
|
31318
31406
|
const signedHeaders = (url2, body, proof) => {
|
|
@@ -31340,6 +31428,8 @@ function createGatewayRunAuthorization(options) {
|
|
|
31340
31428
|
};
|
|
31341
31429
|
};
|
|
31342
31430
|
const invoke = async (path2, previousProof) => {
|
|
31431
|
+
const startedAt = Date.now();
|
|
31432
|
+
const operation = previousProof ? "renew" : "authorize";
|
|
31343
31433
|
const url2 = new URL(path2, base.origin);
|
|
31344
31434
|
const body = {
|
|
31345
31435
|
agentId: identity.agentId,
|
|
@@ -31347,11 +31437,12 @@ function createGatewayRunAuthorization(options) {
|
|
|
31347
31437
|
...previousProof ? { proof: previousProof } : {}
|
|
31348
31438
|
};
|
|
31349
31439
|
let response;
|
|
31440
|
+
log(`event=request.start operation=${operation} runId=${identity.runId} agentId=${identity.agentId}`);
|
|
31350
31441
|
try {
|
|
31351
31442
|
response = await baseFetch(url2, {
|
|
31352
31443
|
method: "POST",
|
|
31353
31444
|
redirect: "error",
|
|
31354
|
-
signal: AbortSignal.timeout(
|
|
31445
|
+
signal: AbortSignal.timeout(SCENARIO_AUTH_REQUEST_TIMEOUT_MS),
|
|
31355
31446
|
headers: {
|
|
31356
31447
|
authorization: options.authorizationHeader,
|
|
31357
31448
|
"content-type": "application/json",
|
|
@@ -31360,31 +31451,39 @@ function createGatewayRunAuthorization(options) {
|
|
|
31360
31451
|
body: JSON.stringify(body)
|
|
31361
31452
|
});
|
|
31362
31453
|
} catch {
|
|
31454
|
+
log(`event=request.error operation=${operation} runId=${identity.runId} agentId=${identity.agentId} reason=network durationMs=${Date.now() - startedAt}`);
|
|
31363
31455
|
throw new Error("SCENARIO_RUN_UNAVAILABLE");
|
|
31364
31456
|
}
|
|
31365
|
-
|
|
31457
|
+
const gatewayRequestId = response.headers.get("request-id") ?? response.headers.get("x-request-id") ?? "-";
|
|
31458
|
+
const rejectResponse = (reason) => {
|
|
31459
|
+
log(`event=request.rejected operation=${operation} runId=${identity.runId} agentId=${identity.agentId} status=${response.status} requestId=${gatewayRequestId} reason=${reason} durationMs=${Date.now() - startedAt}`);
|
|
31366
31460
|
throw new Error("SCENARIO_RUN_UNAVAILABLE");
|
|
31461
|
+
};
|
|
31462
|
+
if (!response.ok) {
|
|
31463
|
+
return rejectResponse("http");
|
|
31464
|
+
}
|
|
31367
31465
|
const raw = await response.text();
|
|
31368
31466
|
if (raw.length > 16384)
|
|
31369
|
-
|
|
31467
|
+
return rejectResponse("response_too_large");
|
|
31370
31468
|
let result;
|
|
31371
31469
|
try {
|
|
31372
31470
|
result = JSON.parse(raw);
|
|
31373
31471
|
} catch {
|
|
31374
|
-
|
|
31472
|
+
return rejectResponse("invalid_json");
|
|
31375
31473
|
}
|
|
31376
31474
|
if (result?.success !== true) {
|
|
31377
|
-
|
|
31378
|
-
|
|
31379
|
-
|
|
31380
|
-
"SCENARIO_RUNTIME_REPLAY"
|
|
31381
|
-
].includes(result?.errorCode) ? result.errorCode : "SCENARIO_RUN_UNAVAILABLE");
|
|
31475
|
+
const errorCode = normalizeScenarioRunErrorCode(result?.errorCode);
|
|
31476
|
+
log(`event=request.rejected operation=${operation} runId=${identity.runId} agentId=${identity.agentId} status=${response.status} requestId=${gatewayRequestId} reason=${errorCode} durationMs=${Date.now() - startedAt}`);
|
|
31477
|
+
throw new Error(errorCode);
|
|
31382
31478
|
}
|
|
31383
31479
|
const data = result.data;
|
|
31384
|
-
if (data?.quotaMode === "NORMAL" && !previousProof)
|
|
31480
|
+
if (data?.quotaMode === "NORMAL" && !previousProof) {
|
|
31481
|
+
log(`event=request.completed operation=${operation} runId=${identity.runId} agentId=${identity.agentId} quotaMode=NORMAL requestId=${gatewayRequestId} durationMs=${Date.now() - startedAt}`);
|
|
31385
31482
|
return { quotaMode: "NORMAL" };
|
|
31483
|
+
}
|
|
31386
31484
|
if (!["LIMITED", "AUTH_ONLY"].includes(data?.quotaMode) || typeof data.proof !== "string" || !data.proof || data.proof.length > 4200 || !Number.isSafeInteger(data.expiresAt) || data.expiresAt <= Date.now())
|
|
31387
|
-
|
|
31485
|
+
return rejectResponse("invalid_response");
|
|
31486
|
+
log(`event=request.completed operation=${operation} runId=${identity.runId} agentId=${identity.agentId} quotaMode=${data.quotaMode} requestId=${gatewayRequestId} durationMs=${Date.now() - startedAt}`);
|
|
31388
31487
|
return data;
|
|
31389
31488
|
};
|
|
31390
31489
|
let grant = await invoke("/api/scenario/authorize-run");
|
|
@@ -39205,24 +39304,6 @@ function sanitizeAttributeValue(value) {
|
|
|
39205
39304
|
}
|
|
39206
39305
|
|
|
39207
39306
|
// ../linkque-agent-runtime/dist/esm/impl/telemetry/otelRuntimeTelemetry.js
|
|
39208
|
-
var InitialRootTraceIdGenerator = class {
|
|
39209
|
-
initialRootTraceId;
|
|
39210
|
-
fallback = new import_sdk_trace_base.RandomIdGenerator();
|
|
39211
|
-
constructor(initialRootTraceId) {
|
|
39212
|
-
this.initialRootTraceId = initialRootTraceId;
|
|
39213
|
-
}
|
|
39214
|
-
generateTraceId() {
|
|
39215
|
-
if (this.initialRootTraceId) {
|
|
39216
|
-
const traceId = this.initialRootTraceId;
|
|
39217
|
-
this.initialRootTraceId = void 0;
|
|
39218
|
-
return traceId;
|
|
39219
|
-
}
|
|
39220
|
-
return this.fallback.generateTraceId();
|
|
39221
|
-
}
|
|
39222
|
-
generateSpanId() {
|
|
39223
|
-
return this.fallback.generateSpanId();
|
|
39224
|
-
}
|
|
39225
|
-
};
|
|
39226
39307
|
var OtelRuntimeTelemetry = class {
|
|
39227
39308
|
options;
|
|
39228
39309
|
queue;
|
|
@@ -39242,10 +39323,9 @@ var OtelRuntimeTelemetry = class {
|
|
|
39242
39323
|
this.options = options;
|
|
39243
39324
|
this.queue = new IdentityQueue(options);
|
|
39244
39325
|
const ratio = options.sampleRatio ?? 1;
|
|
39245
|
-
const initialRootTraceId = options.initialRootTraceId?.toLowerCase();
|
|
39246
39326
|
this.maxActive = options.maxActiveOperations ?? 4096;
|
|
39247
39327
|
this.maxAge = options.operationMaxAgeMs ?? 24 * 60 * 60 * 1e3;
|
|
39248
|
-
if (!options.serviceName || !options.serviceVersion || !options.environment || !Number.isFinite(ratio) || ratio < 0 || ratio > 1 || !Number.isSafeInteger(this.maxActive) || this.maxActive < 1 || !Number.isSafeInteger(this.maxAge) || this.maxAge < 1
|
|
39328
|
+
if (!options.serviceName || !options.serviceVersion || !options.environment || !Number.isFinite(ratio) || ratio < 0 || ratio > 1 || !Number.isSafeInteger(this.maxActive) || this.maxActive < 1 || !Number.isSafeInteger(this.maxAge) || this.maxAge < 1)
|
|
39249
39329
|
throw new Error("\u975E\u6CD5\u9065\u6D4B\u5B9E\u4F8B\u914D\u7F6E");
|
|
39250
39330
|
const resource = (0, import_resources.resourceFromAttributes)({
|
|
39251
39331
|
[ETelemetryAttribute.SERVICE_NAME]: options.serviceName,
|
|
@@ -39256,7 +39336,6 @@ var OtelRuntimeTelemetry = class {
|
|
|
39256
39336
|
});
|
|
39257
39337
|
this.tracerProvider = new import_sdk_trace_base.BasicTracerProvider({
|
|
39258
39338
|
resource,
|
|
39259
|
-
idGenerator: new InitialRootTraceIdGenerator(initialRootTraceId),
|
|
39260
39339
|
sampler: new import_sdk_trace_base.ParentBasedSampler({
|
|
39261
39340
|
root: new import_sdk_trace_base.TraceIdRatioBasedSampler(ratio)
|
|
39262
39341
|
}),
|
|
@@ -39749,6 +39828,8 @@ export {
|
|
|
39749
39828
|
createKnowledgeTools,
|
|
39750
39829
|
NoopWebSearchPort,
|
|
39751
39830
|
EventObservationRegistry,
|
|
39831
|
+
normalizeScenarioRunErrorCode,
|
|
39832
|
+
authorizeAgentRun,
|
|
39752
39833
|
createGatewayRunAuthorization,
|
|
39753
39834
|
abortableDelay,
|
|
39754
39835
|
RemoteGatewayMcpServerProvider,
|
package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-Z2A5GMVJ.js → chunk-U6OH2FQV.js}
RENAMED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
RUNTIME_CONFIG_DEFAULTS,
|
|
23
23
|
RuntimeConfigProvider,
|
|
24
24
|
isDebugLoggingEnabled
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-OYT6HQOV.js";
|
|
26
26
|
import {
|
|
27
27
|
__commonJS,
|
|
28
28
|
__require,
|
|
@@ -15663,7 +15663,6 @@ var API_KEY_HEADER = "x-appwrite-key";
|
|
|
15663
15663
|
var TRIGGER_HEADER = "x-appwrite-trigger";
|
|
15664
15664
|
var ENV_SELECTOR_HEADER = "x-linkque-env";
|
|
15665
15665
|
var TRACE_ID_HEADER = "x-trace-id";
|
|
15666
|
-
var OTEL_TRACE_ID_HEADER = "x-linkque-otel-trace-id";
|
|
15667
15666
|
var TEMPORARY_FRONTEND_APP_ID_HEADER = "x-linkque-alipay-app-id";
|
|
15668
15667
|
var ALIPAY_AUTH_CODE_HEADER = "x-alipay-authcode";
|
|
15669
15668
|
var AUTH_UNAVAILABLE_HEADER = "x-linkque-phone-auth-unavailable";
|
|
@@ -15743,28 +15742,6 @@ function readTraceId(headers) {
|
|
|
15743
15742
|
}
|
|
15744
15743
|
return void 0;
|
|
15745
15744
|
}
|
|
15746
|
-
function readOtelTraceId(headers) {
|
|
15747
|
-
if (!headers)
|
|
15748
|
-
return { kind: "missing" };
|
|
15749
|
-
let found = Object.prototype.hasOwnProperty.call(headers, OTEL_TRACE_ID_HEADER);
|
|
15750
|
-
let value = found ? headers[OTEL_TRACE_ID_HEADER] : void 0;
|
|
15751
|
-
if (!found) {
|
|
15752
|
-
for (const [key, candidate] of Object.entries(headers)) {
|
|
15753
|
-
if (key.toLowerCase() === OTEL_TRACE_ID_HEADER) {
|
|
15754
|
-
found = true;
|
|
15755
|
-
value = candidate;
|
|
15756
|
-
break;
|
|
15757
|
-
}
|
|
15758
|
-
}
|
|
15759
|
-
}
|
|
15760
|
-
if (!found)
|
|
15761
|
-
return { kind: "missing" };
|
|
15762
|
-
const raw = headValue(value);
|
|
15763
|
-
if (!raw)
|
|
15764
|
-
return { kind: "invalid" };
|
|
15765
|
-
const traceId = raw.toLowerCase();
|
|
15766
|
-
return /^[0-9a-f]{32}$/u.test(traceId) && traceId !== "00000000000000000000000000000000" ? { kind: "valid", traceId } : { kind: "invalid" };
|
|
15767
|
-
}
|
|
15768
15745
|
function readTemporaryFrontendAppId(headers) {
|
|
15769
15746
|
if (!headers)
|
|
15770
15747
|
return void 0;
|
|
@@ -15931,7 +15908,6 @@ export {
|
|
|
15931
15908
|
LinkqueGatewayAuthError,
|
|
15932
15909
|
LinkqueGatewayAuthUnconfiguredError,
|
|
15933
15910
|
resolveLinkqueGatewayRequestAuth,
|
|
15934
|
-
resolveLinkqueGatewayAuth,
|
|
15935
15911
|
resolveGatewayAuthContext,
|
|
15936
15912
|
resolveBodyJSON,
|
|
15937
15913
|
toAgentRunMessages,
|
|
@@ -15940,7 +15916,6 @@ export {
|
|
|
15940
15916
|
mcpPhoneAuthorizationChallenge,
|
|
15941
15917
|
readEnvSelector,
|
|
15942
15918
|
readTraceId,
|
|
15943
|
-
readOtelTraceId,
|
|
15944
15919
|
readTemporaryFrontendAppId,
|
|
15945
15920
|
readAuthenticatedUserId,
|
|
15946
15921
|
readAppwriteApiKey,
|
|
@@ -388,7 +388,7 @@ async function getObservabilityModule() {
|
|
|
388
388
|
return observabilityModule;
|
|
389
389
|
}
|
|
390
390
|
try {
|
|
391
|
-
observabilityModule = await import("./otel-
|
|
391
|
+
observabilityModule = await import("./otel-WGS5CC2J.js");
|
|
392
392
|
} catch {
|
|
393
393
|
observabilityModule = null;
|
|
394
394
|
}
|