linkque-cli-v2 1.6.18 → 1.6.20
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/dataTransformWorker.js +17 -3
- package/dev/worker.js +11 -37
- package/linkquejs.js +884 -813
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/data-transform/dataTransformWorker.js +17 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{anthropic-messages-GSYNBLMR.js → anthropic-messages-TBZKK7UX.js} +2 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-L5WNKJ4W.js → chunk-22EQ6RXO.js} +253 -3078
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-M6E4Y5HY.js → chunk-5MR5ICJ4.js} +1916 -2642
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-EAODRPW4.js +518 -0
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-KRE5FADB.js → chunk-JMBJJF7P.js} +11 -37
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-3BH2PDL3.js → chunk-WHXLLQZR.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{google-generative-ai-YD5ZGNXC.js → google-generative-ai-KD7MXONK.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{google-vertex-M34UDW4J.js → google-vertex-TREYA472.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-EIVAJAMW.js → mistral-conversations-5EI6JQBZ.js} +4 -4
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{otel-LQR5KPZ3.js → otel-RUUFBBFE.js} +266 -578
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +1562 -1888
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +3 -2
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +3 -2
- package/worker.js +3544 -4996
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{azure-openai-responses-NPKMM3LF.js → azure-openai-responses-IYC43YOB.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-KDHBKVSL.js → chunk-FCD4O3BT.js} +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-codex-responses-GEFKSNVN.js → openai-codex-responses-HYLTKNTN.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-completions-TAACO6T5.js → openai-completions-CS3OYESP.js} +3 -3
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{openai-responses-4DDTXIGI.js → openai-responses-IYAGUHY7.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{pi-messages-7JN3W3BC.js → pi-messages-XGBW55RS.js} +3 -3
package/linkquejs.js
CHANGED
|
@@ -1196,7 +1196,7 @@ var require_command = __commonJS({
|
|
|
1196
1196
|
"../../node_modules/commander/lib/command.js"(exports2) {
|
|
1197
1197
|
var EventEmitter = require("node:events").EventEmitter;
|
|
1198
1198
|
var childProcess = require("node:child_process");
|
|
1199
|
-
var
|
|
1199
|
+
var path28 = require("node:path");
|
|
1200
1200
|
var fs2 = require("node:fs");
|
|
1201
1201
|
var process2 = require("node:process");
|
|
1202
1202
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -2209,9 +2209,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2209
2209
|
let launchWithNode = false;
|
|
2210
2210
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
2211
2211
|
function findFile(baseDir, baseName) {
|
|
2212
|
-
const localBin =
|
|
2212
|
+
const localBin = path28.resolve(baseDir, baseName);
|
|
2213
2213
|
if (fs2.existsSync(localBin)) return localBin;
|
|
2214
|
-
if (sourceExt.includes(
|
|
2214
|
+
if (sourceExt.includes(path28.extname(baseName))) return void 0;
|
|
2215
2215
|
const foundExt = sourceExt.find(
|
|
2216
2216
|
(ext) => fs2.existsSync(`${localBin}${ext}`)
|
|
2217
2217
|
);
|
|
@@ -2229,17 +2229,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2229
2229
|
} catch {
|
|
2230
2230
|
resolvedScriptPath = this._scriptPath;
|
|
2231
2231
|
}
|
|
2232
|
-
executableDir =
|
|
2233
|
-
|
|
2232
|
+
executableDir = path28.resolve(
|
|
2233
|
+
path28.dirname(resolvedScriptPath),
|
|
2234
2234
|
executableDir
|
|
2235
2235
|
);
|
|
2236
2236
|
}
|
|
2237
2237
|
if (executableDir) {
|
|
2238
2238
|
let localFile = findFile(executableDir, executableFile);
|
|
2239
2239
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
2240
|
-
const legacyName =
|
|
2240
|
+
const legacyName = path28.basename(
|
|
2241
2241
|
this._scriptPath,
|
|
2242
|
-
|
|
2242
|
+
path28.extname(this._scriptPath)
|
|
2243
2243
|
);
|
|
2244
2244
|
if (legacyName !== this._name) {
|
|
2245
2245
|
localFile = findFile(
|
|
@@ -2250,7 +2250,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2250
2250
|
}
|
|
2251
2251
|
executableFile = localFile || executableFile;
|
|
2252
2252
|
}
|
|
2253
|
-
launchWithNode = sourceExt.includes(
|
|
2253
|
+
launchWithNode = sourceExt.includes(path28.extname(executableFile));
|
|
2254
2254
|
let proc;
|
|
2255
2255
|
if (process2.platform !== "win32") {
|
|
2256
2256
|
if (launchWithNode) {
|
|
@@ -3165,7 +3165,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3165
3165
|
* @return {Command}
|
|
3166
3166
|
*/
|
|
3167
3167
|
nameFromFilename(filename) {
|
|
3168
|
-
this._name =
|
|
3168
|
+
this._name = path28.basename(filename, path28.extname(filename));
|
|
3169
3169
|
return this;
|
|
3170
3170
|
}
|
|
3171
3171
|
/**
|
|
@@ -3179,9 +3179,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3179
3179
|
* @param {string} [path]
|
|
3180
3180
|
* @return {(string|null|Command)}
|
|
3181
3181
|
*/
|
|
3182
|
-
executableDir(
|
|
3183
|
-
if (
|
|
3184
|
-
this._executableDir =
|
|
3182
|
+
executableDir(path29) {
|
|
3183
|
+
if (path29 === void 0) return this._executableDir;
|
|
3184
|
+
this._executableDir = path29;
|
|
3185
3185
|
return this;
|
|
3186
3186
|
}
|
|
3187
3187
|
/**
|
|
@@ -6688,8 +6688,8 @@ var require_utils = __commonJS({
|
|
|
6688
6688
|
}
|
|
6689
6689
|
return ind;
|
|
6690
6690
|
}
|
|
6691
|
-
function removeDotSegments(
|
|
6692
|
-
let input =
|
|
6691
|
+
function removeDotSegments(path28) {
|
|
6692
|
+
let input = path28;
|
|
6693
6693
|
const output = [];
|
|
6694
6694
|
let nextSlash = -1;
|
|
6695
6695
|
let len = 0;
|
|
@@ -6763,11 +6763,11 @@ var require_utils = __commonJS({
|
|
|
6763
6763
|
}
|
|
6764
6764
|
return output.join("");
|
|
6765
6765
|
}
|
|
6766
|
-
function removeDotSegmentsRelative(
|
|
6767
|
-
if (
|
|
6768
|
-
return removeDotSegments(
|
|
6766
|
+
function removeDotSegmentsRelative(path28) {
|
|
6767
|
+
if (path28 === "" || path28[0] === "/") {
|
|
6768
|
+
return removeDotSegments(path28);
|
|
6769
6769
|
}
|
|
6770
|
-
const segments =
|
|
6770
|
+
const segments = path28.split("/");
|
|
6771
6771
|
const last = segments.length - 1;
|
|
6772
6772
|
const output = [];
|
|
6773
6773
|
let trailingDirectory = false;
|
|
@@ -7130,8 +7130,8 @@ var require_schemes = __commonJS({
|
|
|
7130
7130
|
}
|
|
7131
7131
|
if (wsComponent.resourceName) {
|
|
7132
7132
|
const queryIndex = wsComponent.resourceName.indexOf("?");
|
|
7133
|
-
const
|
|
7134
|
-
wsComponent.path =
|
|
7133
|
+
const path28 = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
|
|
7134
|
+
wsComponent.path = path28 && path28 !== "/" ? path28 : void 0;
|
|
7135
7135
|
wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
|
|
7136
7136
|
wsComponent.resourceName = void 0;
|
|
7137
7137
|
}
|
|
@@ -8045,8 +8045,8 @@ var require_core = __commonJS({
|
|
|
8045
8045
|
}
|
|
8046
8046
|
}
|
|
8047
8047
|
// add "vocabulary" - a collection of keywords
|
|
8048
|
-
addVocabulary(
|
|
8049
|
-
for (const def of
|
|
8048
|
+
addVocabulary(definitions2) {
|
|
8049
|
+
for (const def of definitions2)
|
|
8050
8050
|
this.addKeyword(def);
|
|
8051
8051
|
return this;
|
|
8052
8052
|
}
|
|
@@ -12848,14 +12848,14 @@ var require_util2 = __commonJS({
|
|
|
12848
12848
|
}
|
|
12849
12849
|
const port = url2.port != null ? url2.port : url2.protocol === "https:" ? 443 : 80;
|
|
12850
12850
|
let origin = url2.origin != null ? url2.origin : `${url2.protocol || ""}//${url2.hostname || ""}:${port}`;
|
|
12851
|
-
let
|
|
12851
|
+
let path28 = url2.path != null ? url2.path : `${url2.pathname || ""}${url2.search || ""}`;
|
|
12852
12852
|
if (origin[origin.length - 1] === "/") {
|
|
12853
12853
|
origin = origin.slice(0, origin.length - 1);
|
|
12854
12854
|
}
|
|
12855
|
-
if (
|
|
12856
|
-
|
|
12855
|
+
if (path28 && path28[0] !== "/") {
|
|
12856
|
+
path28 = `/${path28}`;
|
|
12857
12857
|
}
|
|
12858
|
-
return new URL(`${origin}${
|
|
12858
|
+
return new URL(`${origin}${path28}`);
|
|
12859
12859
|
}
|
|
12860
12860
|
if (!isHttpOrHttpsPrefixed(url2.origin || url2.protocol)) {
|
|
12861
12861
|
throw new InvalidArgumentError2("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
@@ -13306,39 +13306,39 @@ var require_diagnostics = __commonJS({
|
|
|
13306
13306
|
});
|
|
13307
13307
|
diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
|
|
13308
13308
|
const {
|
|
13309
|
-
request: { method, path:
|
|
13309
|
+
request: { method, path: path28, origin }
|
|
13310
13310
|
} = evt;
|
|
13311
|
-
debuglog("sending request to %s %s/%s", method, origin,
|
|
13311
|
+
debuglog("sending request to %s %s/%s", method, origin, path28);
|
|
13312
13312
|
});
|
|
13313
13313
|
diagnosticsChannel.channel("undici:request:headers").subscribe((evt) => {
|
|
13314
13314
|
const {
|
|
13315
|
-
request: { method, path:
|
|
13315
|
+
request: { method, path: path28, origin },
|
|
13316
13316
|
response: { statusCode }
|
|
13317
13317
|
} = evt;
|
|
13318
13318
|
debuglog(
|
|
13319
13319
|
"received response to %s %s/%s - HTTP %d",
|
|
13320
13320
|
method,
|
|
13321
13321
|
origin,
|
|
13322
|
-
|
|
13322
|
+
path28,
|
|
13323
13323
|
statusCode
|
|
13324
13324
|
);
|
|
13325
13325
|
});
|
|
13326
13326
|
diagnosticsChannel.channel("undici:request:trailers").subscribe((evt) => {
|
|
13327
13327
|
const {
|
|
13328
|
-
request: { method, path:
|
|
13328
|
+
request: { method, path: path28, origin }
|
|
13329
13329
|
} = evt;
|
|
13330
|
-
debuglog("trailers received from %s %s/%s", method, origin,
|
|
13330
|
+
debuglog("trailers received from %s %s/%s", method, origin, path28);
|
|
13331
13331
|
});
|
|
13332
13332
|
diagnosticsChannel.channel("undici:request:error").subscribe((evt) => {
|
|
13333
13333
|
const {
|
|
13334
|
-
request: { method, path:
|
|
13334
|
+
request: { method, path: path28, origin },
|
|
13335
13335
|
error: error2
|
|
13336
13336
|
} = evt;
|
|
13337
13337
|
debuglog(
|
|
13338
13338
|
"request to %s %s/%s errored - %s",
|
|
13339
13339
|
method,
|
|
13340
13340
|
origin,
|
|
13341
|
-
|
|
13341
|
+
path28,
|
|
13342
13342
|
error2.message
|
|
13343
13343
|
);
|
|
13344
13344
|
});
|
|
@@ -13387,9 +13387,9 @@ var require_diagnostics = __commonJS({
|
|
|
13387
13387
|
});
|
|
13388
13388
|
diagnosticsChannel.channel("undici:client:sendHeaders").subscribe((evt) => {
|
|
13389
13389
|
const {
|
|
13390
|
-
request: { method, path:
|
|
13390
|
+
request: { method, path: path28, origin }
|
|
13391
13391
|
} = evt;
|
|
13392
|
-
debuglog("sending request to %s %s/%s", method, origin,
|
|
13392
|
+
debuglog("sending request to %s %s/%s", method, origin, path28);
|
|
13393
13393
|
});
|
|
13394
13394
|
}
|
|
13395
13395
|
diagnosticsChannel.channel("undici:websocket:open").subscribe((evt) => {
|
|
@@ -13452,7 +13452,7 @@ var require_request = __commonJS({
|
|
|
13452
13452
|
var kHandler = Symbol("handler");
|
|
13453
13453
|
var Request2 = class {
|
|
13454
13454
|
constructor(origin, {
|
|
13455
|
-
path:
|
|
13455
|
+
path: path28,
|
|
13456
13456
|
method,
|
|
13457
13457
|
body,
|
|
13458
13458
|
headers,
|
|
@@ -13467,11 +13467,11 @@ var require_request = __commonJS({
|
|
|
13467
13467
|
expectContinue,
|
|
13468
13468
|
servername
|
|
13469
13469
|
}, handler) {
|
|
13470
|
-
if (typeof
|
|
13470
|
+
if (typeof path28 !== "string") {
|
|
13471
13471
|
throw new InvalidArgumentError2("path must be a string");
|
|
13472
|
-
} else if (
|
|
13472
|
+
} else if (path28[0] !== "/" && !(path28.startsWith("http://") || path28.startsWith("https://")) && method !== "CONNECT") {
|
|
13473
13473
|
throw new InvalidArgumentError2("path must be an absolute URL or start with a slash");
|
|
13474
|
-
} else if (invalidPathRegex.test(
|
|
13474
|
+
} else if (invalidPathRegex.test(path28)) {
|
|
13475
13475
|
throw new InvalidArgumentError2("invalid request path");
|
|
13476
13476
|
}
|
|
13477
13477
|
if (typeof method !== "string") {
|
|
@@ -13534,7 +13534,7 @@ var require_request = __commonJS({
|
|
|
13534
13534
|
this.completed = false;
|
|
13535
13535
|
this.aborted = false;
|
|
13536
13536
|
this.upgrade = upgrade || null;
|
|
13537
|
-
this.path = query ? buildURL(
|
|
13537
|
+
this.path = query ? buildURL(path28, query) : path28;
|
|
13538
13538
|
this.origin = origin;
|
|
13539
13539
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
13540
13540
|
this.blocking = blocking == null ? false : blocking;
|
|
@@ -17777,7 +17777,7 @@ var require_client_h1 = __commonJS({
|
|
|
17777
17777
|
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && method !== "TRACE" && method !== "CONNECT";
|
|
17778
17778
|
}
|
|
17779
17779
|
function writeH1(client, request2) {
|
|
17780
|
-
const { method, path:
|
|
17780
|
+
const { method, path: path28, host, upgrade, blocking, reset } = request2;
|
|
17781
17781
|
let { body, headers, contentLength } = request2;
|
|
17782
17782
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
17783
17783
|
if (util2.isFormDataLike(body)) {
|
|
@@ -17843,7 +17843,7 @@ var require_client_h1 = __commonJS({
|
|
|
17843
17843
|
if (blocking) {
|
|
17844
17844
|
socket[kBlocking] = true;
|
|
17845
17845
|
}
|
|
17846
|
-
let header = `${method} ${
|
|
17846
|
+
let header = `${method} ${path28} HTTP/1.1\r
|
|
17847
17847
|
`;
|
|
17848
17848
|
if (typeof host === "string") {
|
|
17849
17849
|
header += `host: ${host}\r
|
|
@@ -18340,7 +18340,7 @@ var require_client_h2 = __commonJS({
|
|
|
18340
18340
|
}
|
|
18341
18341
|
function writeH2(client, request2) {
|
|
18342
18342
|
const session = client[kHTTP2Session];
|
|
18343
|
-
const { body, method, path:
|
|
18343
|
+
const { body, method, path: path28, host, upgrade, expectContinue, signal, headers: reqHeaders } = request2;
|
|
18344
18344
|
if (upgrade) {
|
|
18345
18345
|
util2.errorRequest(client, request2, new Error("Upgrade not supported for H2"));
|
|
18346
18346
|
return false;
|
|
@@ -18402,7 +18402,7 @@ var require_client_h2 = __commonJS({
|
|
|
18402
18402
|
});
|
|
18403
18403
|
return true;
|
|
18404
18404
|
}
|
|
18405
|
-
headers[HTTP2_HEADER_PATH] =
|
|
18405
|
+
headers[HTTP2_HEADER_PATH] = path28;
|
|
18406
18406
|
headers[HTTP2_HEADER_SCHEME] = "https";
|
|
18407
18407
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
18408
18408
|
if (body && typeof body.read === "function") {
|
|
@@ -18746,9 +18746,9 @@ var require_redirect_handler = __commonJS({
|
|
|
18746
18746
|
return this.handler.onHeaders(statusCode, headers, resume, statusText);
|
|
18747
18747
|
}
|
|
18748
18748
|
const { origin, pathname, search: search3 } = util2.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
18749
|
-
const
|
|
18749
|
+
const path28 = search3 ? `${pathname}${search3}` : pathname;
|
|
18750
18750
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
18751
|
-
this.opts.path =
|
|
18751
|
+
this.opts.path = path28;
|
|
18752
18752
|
this.opts.origin = origin;
|
|
18753
18753
|
this.opts.maxRedirections = 0;
|
|
18754
18754
|
this.opts.query = null;
|
|
@@ -21793,20 +21793,20 @@ var require_mock_utils = __commonJS({
|
|
|
21793
21793
|
}
|
|
21794
21794
|
return true;
|
|
21795
21795
|
}
|
|
21796
|
-
function safeUrl(
|
|
21797
|
-
if (typeof
|
|
21798
|
-
return
|
|
21796
|
+
function safeUrl(path28) {
|
|
21797
|
+
if (typeof path28 !== "string") {
|
|
21798
|
+
return path28;
|
|
21799
21799
|
}
|
|
21800
|
-
const pathSegments =
|
|
21800
|
+
const pathSegments = path28.split("?");
|
|
21801
21801
|
if (pathSegments.length !== 2) {
|
|
21802
|
-
return
|
|
21802
|
+
return path28;
|
|
21803
21803
|
}
|
|
21804
21804
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
21805
21805
|
qp.sort();
|
|
21806
21806
|
return [...pathSegments, qp.toString()].join("?");
|
|
21807
21807
|
}
|
|
21808
|
-
function matchKey(mockDispatch2, { path:
|
|
21809
|
-
const pathMatch = matchValue(mockDispatch2.path,
|
|
21808
|
+
function matchKey(mockDispatch2, { path: path28, method, body, headers }) {
|
|
21809
|
+
const pathMatch = matchValue(mockDispatch2.path, path28);
|
|
21810
21810
|
const methodMatch = matchValue(mockDispatch2.method, method);
|
|
21811
21811
|
const bodyMatch = typeof mockDispatch2.body !== "undefined" ? matchValue(mockDispatch2.body, body) : true;
|
|
21812
21812
|
const headersMatch = matchHeaders(mockDispatch2, headers);
|
|
@@ -21824,7 +21824,7 @@ var require_mock_utils = __commonJS({
|
|
|
21824
21824
|
function getMockDispatch(mockDispatches, key) {
|
|
21825
21825
|
const basePath = key.query ? buildURL(key.path, key.query) : key.path;
|
|
21826
21826
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
21827
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path:
|
|
21827
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path28 }) => matchValue(safeUrl(path28), resolvedPath));
|
|
21828
21828
|
if (matchedMockDispatches.length === 0) {
|
|
21829
21829
|
throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
21830
21830
|
}
|
|
@@ -21862,9 +21862,9 @@ var require_mock_utils = __commonJS({
|
|
|
21862
21862
|
}
|
|
21863
21863
|
}
|
|
21864
21864
|
function buildKey(opts) {
|
|
21865
|
-
const { path:
|
|
21865
|
+
const { path: path28, method, body, headers, query } = opts;
|
|
21866
21866
|
return {
|
|
21867
|
-
path:
|
|
21867
|
+
path: path28,
|
|
21868
21868
|
method,
|
|
21869
21869
|
body,
|
|
21870
21870
|
headers,
|
|
@@ -22327,10 +22327,10 @@ var require_pending_interceptors_formatter = __commonJS({
|
|
|
22327
22327
|
}
|
|
22328
22328
|
format(pendingInterceptors) {
|
|
22329
22329
|
const withPrettyHeaders = pendingInterceptors.map(
|
|
22330
|
-
({ method, path:
|
|
22330
|
+
({ method, path: path28, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
22331
22331
|
Method: method,
|
|
22332
22332
|
Origin: origin,
|
|
22333
|
-
Path:
|
|
22333
|
+
Path: path28,
|
|
22334
22334
|
"Status code": statusCode,
|
|
22335
22335
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
22336
22336
|
Invocations: timesInvoked,
|
|
@@ -26915,9 +26915,9 @@ var require_util7 = __commonJS({
|
|
|
26915
26915
|
}
|
|
26916
26916
|
}
|
|
26917
26917
|
}
|
|
26918
|
-
function validateCookiePath(
|
|
26919
|
-
for (let i = 0; i <
|
|
26920
|
-
const code =
|
|
26918
|
+
function validateCookiePath(path28) {
|
|
26919
|
+
for (let i = 0; i < path28.length; ++i) {
|
|
26920
|
+
const code = path28.charCodeAt(i);
|
|
26921
26921
|
if (code < 32 || // exclude CTLs (0-31)
|
|
26922
26922
|
code === 127 || // DEL
|
|
26923
26923
|
code === 59) {
|
|
@@ -29504,11 +29504,11 @@ var require_undici = __commonJS({
|
|
|
29504
29504
|
if (typeof opts.path !== "string") {
|
|
29505
29505
|
throw new InvalidArgumentError2("invalid opts.path");
|
|
29506
29506
|
}
|
|
29507
|
-
let
|
|
29507
|
+
let path28 = opts.path;
|
|
29508
29508
|
if (!opts.path.startsWith("/")) {
|
|
29509
|
-
|
|
29509
|
+
path28 = `/${path28}`;
|
|
29510
29510
|
}
|
|
29511
|
-
url2 = new URL(util2.parseOrigin(url2).origin +
|
|
29511
|
+
url2 = new URL(util2.parseOrigin(url2).origin + path28);
|
|
29512
29512
|
} else {
|
|
29513
29513
|
if (!opts) {
|
|
29514
29514
|
opts = typeof url2 === "object" ? url2 : {};
|
|
@@ -34477,24 +34477,184 @@ var {
|
|
|
34477
34477
|
Help
|
|
34478
34478
|
} = import_index.default;
|
|
34479
34479
|
|
|
34480
|
+
// src/utils/cardStorage.ts
|
|
34481
|
+
var import_promises3 = require("fs/promises");
|
|
34482
|
+
var import_path2 = __toESM(require("path"));
|
|
34483
|
+
|
|
34484
|
+
// ../linkque-agent-protocol/dist/esm/cardStorage.js
|
|
34485
|
+
var import_node_crypto = require("node:crypto");
|
|
34486
|
+
function canonicalJson(value) {
|
|
34487
|
+
return JSON.stringify(value, (_key, item) => item !== null && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b3]) => a < b3 ? -1 : a > b3 ? 1 : 0)) : item);
|
|
34488
|
+
}
|
|
34489
|
+
function contentChecksum(value) {
|
|
34490
|
+
return (0, import_node_crypto.createHash)("sha256").update(canonicalJson(value)).digest("hex");
|
|
34491
|
+
}
|
|
34492
|
+
function assertCardPath(value) {
|
|
34493
|
+
if (typeof value !== "string" || !/^cards\/(?!\.{1,2}\/)[A-Za-z0-9%._-]+\/[a-f0-9]{64}\/(card|binding)\.json$/.test(value)) {
|
|
34494
|
+
throw new Error("\u65E0\u6548\u7684\u5361\u7247\u6587\u4EF6\u5F15\u7528");
|
|
34495
|
+
}
|
|
34496
|
+
}
|
|
34497
|
+
function splitAgentCards(input) {
|
|
34498
|
+
const config3 = structuredClone(input);
|
|
34499
|
+
const files = {};
|
|
34500
|
+
for (const resource of config3.agent.resources ?? []) {
|
|
34501
|
+
if (resource.resourceType !== "CARD")
|
|
34502
|
+
continue;
|
|
34503
|
+
if (resource.config.schemaVersion !== "4")
|
|
34504
|
+
throw new Error("\u5361\u7247\u5B58\u50A8\u53EA\u652F\u6301 V4");
|
|
34505
|
+
const directory = `cards/${encodeURIComponent(resource.resourceId)}/${contentChecksum(resource.config)}`;
|
|
34506
|
+
const template = resource.config.a2uiTemplate;
|
|
34507
|
+
const definition = {
|
|
34508
|
+
format: "linkque-a2ui",
|
|
34509
|
+
protocol: JSON.parse(template.content)
|
|
34510
|
+
};
|
|
34511
|
+
const binding = {
|
|
34512
|
+
...resource.config,
|
|
34513
|
+
definitionRef: `${directory}/card.json`,
|
|
34514
|
+
a2uiTemplate: { argsSchema: template.argsSchema }
|
|
34515
|
+
};
|
|
34516
|
+
files[`${directory}/card.json`] = definition;
|
|
34517
|
+
files[`${directory}/binding.json`] = binding;
|
|
34518
|
+
resource.config = { bindingRef: `${directory}/binding.json` };
|
|
34519
|
+
}
|
|
34520
|
+
return { config: config3, files };
|
|
34521
|
+
}
|
|
34522
|
+
async function hydrateAgentCards(input, readJson) {
|
|
34523
|
+
const config3 = structuredClone(input);
|
|
34524
|
+
for (const resource of config3.agent.resources ?? []) {
|
|
34525
|
+
if (resource.resourceType !== "CARD")
|
|
34526
|
+
continue;
|
|
34527
|
+
if (!("bindingRef" in resource.config)) {
|
|
34528
|
+
if (resource.config.schemaVersion !== "4")
|
|
34529
|
+
throw new Error("\u5361\u7247\u5B58\u50A8\u53EA\u652F\u6301 V4");
|
|
34530
|
+
const template = resource.config.a2uiTemplate;
|
|
34531
|
+
template.content = canonicalJson(JSON.parse(template.content));
|
|
34532
|
+
continue;
|
|
34533
|
+
}
|
|
34534
|
+
assertCardPath(resource.config.bindingRef);
|
|
34535
|
+
const binding = await readJson(resource.config.bindingRef);
|
|
34536
|
+
assertCardPath(binding.definitionRef);
|
|
34537
|
+
const definition = await readJson(binding.definitionRef);
|
|
34538
|
+
const { definitionRef: _ref, ...execution } = binding;
|
|
34539
|
+
resource.config = {
|
|
34540
|
+
...execution,
|
|
34541
|
+
a2uiTemplate: {
|
|
34542
|
+
...execution.a2uiTemplate,
|
|
34543
|
+
content: canonicalJson(definition.protocol)
|
|
34544
|
+
}
|
|
34545
|
+
};
|
|
34546
|
+
}
|
|
34547
|
+
return config3;
|
|
34548
|
+
}
|
|
34549
|
+
|
|
34550
|
+
// src/utils/files.ts
|
|
34551
|
+
var import_crypto = require("crypto");
|
|
34552
|
+
var import_promises = require("fs/promises");
|
|
34553
|
+
var import_promises2 = require("fs/promises");
|
|
34554
|
+
var import_path = __toESM(require("path"));
|
|
34555
|
+
var isNodeError = (error2, code) => error2 !== null && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
34556
|
+
var ensureParentDir = (filePath) => (0, import_promises2.mkdir)(import_path.default.dirname(filePath), { recursive: true }).then(() => void 0);
|
|
34557
|
+
var readUtf8IfExists = async (filePath) => {
|
|
34558
|
+
try {
|
|
34559
|
+
return await (0, import_promises2.readFile)(filePath, "utf8");
|
|
34560
|
+
} catch (error2) {
|
|
34561
|
+
if (isNodeError(error2, "ENOENT")) {
|
|
34562
|
+
return null;
|
|
34563
|
+
}
|
|
34564
|
+
throw error2;
|
|
34565
|
+
}
|
|
34566
|
+
};
|
|
34567
|
+
var pathExists = async (filePath) => {
|
|
34568
|
+
try {
|
|
34569
|
+
await (0, import_promises.stat)(filePath);
|
|
34570
|
+
return true;
|
|
34571
|
+
} catch (error2) {
|
|
34572
|
+
if (isNodeError(error2, "ENOENT")) return false;
|
|
34573
|
+
throw error2;
|
|
34574
|
+
}
|
|
34575
|
+
};
|
|
34576
|
+
var pathHasKind = async (filePath, kind) => {
|
|
34577
|
+
try {
|
|
34578
|
+
return (await (0, import_promises.stat)(filePath))[kind === "dir" ? "isDirectory" : "isFile"]();
|
|
34579
|
+
} catch (error2) {
|
|
34580
|
+
if (isNodeError(error2, "ENOENT")) return false;
|
|
34581
|
+
throw error2;
|
|
34582
|
+
}
|
|
34583
|
+
};
|
|
34584
|
+
var parseJsonObject = (content, code, message) => {
|
|
34585
|
+
try {
|
|
34586
|
+
const value = JSON.parse(content);
|
|
34587
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
34588
|
+
return value;
|
|
34589
|
+
}
|
|
34590
|
+
} catch (error2) {
|
|
34591
|
+
throw new LinkqueCliError(code, message, { cause: error2 });
|
|
34592
|
+
}
|
|
34593
|
+
throw new LinkqueCliError(code, message);
|
|
34594
|
+
};
|
|
34595
|
+
var writeJsonAtomically = async (filePath, value, { exclusive = false } = {}) => {
|
|
34596
|
+
await ensureParentDir(filePath);
|
|
34597
|
+
const tempPath = `${filePath}.${process.pid}.${(0, import_crypto.randomUUID)()}.tmp`;
|
|
34598
|
+
try {
|
|
34599
|
+
await (0, import_promises2.writeFile)(
|
|
34600
|
+
tempPath,
|
|
34601
|
+
`${JSON.stringify(value, null, 2)}
|
|
34602
|
+
`,
|
|
34603
|
+
exclusive ? { encoding: "utf8", flag: "wx" } : "utf8"
|
|
34604
|
+
);
|
|
34605
|
+
if (exclusive) {
|
|
34606
|
+
await (0, import_promises2.link)(tempPath, filePath);
|
|
34607
|
+
} else {
|
|
34608
|
+
await (0, import_promises2.rename)(tempPath, filePath);
|
|
34609
|
+
}
|
|
34610
|
+
} finally {
|
|
34611
|
+
await (0, import_promises2.rm)(tempPath, { force: true }).catch(() => void 0);
|
|
34612
|
+
}
|
|
34613
|
+
};
|
|
34614
|
+
|
|
34615
|
+
// src/utils/cardStorage.ts
|
|
34616
|
+
async function readAgentCards(configPath) {
|
|
34617
|
+
const root = import_path2.default.dirname(configPath);
|
|
34618
|
+
return hydrateAgentCards(
|
|
34619
|
+
JSON.parse(await (0, import_promises3.readFile)(configPath, "utf8")),
|
|
34620
|
+
async (file) => JSON.parse(await (0, import_promises3.readFile)(import_path2.default.join(root, file), "utf8"))
|
|
34621
|
+
);
|
|
34622
|
+
}
|
|
34623
|
+
async function writeAgentCards(configPath, config3) {
|
|
34624
|
+
const source = splitAgentCards(config3);
|
|
34625
|
+
const root = import_path2.default.dirname(configPath);
|
|
34626
|
+
for (const [file, value] of Object.entries(source.files)) {
|
|
34627
|
+
await (0, import_promises3.mkdir)(import_path2.default.dirname(import_path2.default.join(root, file)), { recursive: true });
|
|
34628
|
+
await writeJsonAtomically(import_path2.default.join(root, file), value);
|
|
34629
|
+
}
|
|
34630
|
+
await writeJsonAtomically(configPath, source.config);
|
|
34631
|
+
return source;
|
|
34632
|
+
}
|
|
34633
|
+
async function migrateAgentCards(configPath) {
|
|
34634
|
+
return writeAgentCards(configPath, await readAgentCards(configPath));
|
|
34635
|
+
}
|
|
34636
|
+
|
|
34637
|
+
// src/commands/registry.ts
|
|
34638
|
+
var import_path29 = __toESM(require("path"));
|
|
34639
|
+
|
|
34480
34640
|
// src/protocol.ts
|
|
34481
34641
|
var import_fs = require("fs");
|
|
34482
|
-
var
|
|
34642
|
+
var import_path3 = __toESM(require("path"));
|
|
34483
34643
|
var PROTOCOL_VERSION = "1.0";
|
|
34484
34644
|
var readCliVersion = () => {
|
|
34485
34645
|
let dir = __dirname;
|
|
34486
|
-
const root =
|
|
34646
|
+
const root = import_path3.default.parse(dir).root;
|
|
34487
34647
|
while (dir !== root) {
|
|
34488
34648
|
try {
|
|
34489
34649
|
const pkg = JSON.parse(
|
|
34490
|
-
(0, import_fs.readFileSync)(
|
|
34650
|
+
(0, import_fs.readFileSync)(import_path3.default.join(dir, "package.json"), "utf8")
|
|
34491
34651
|
);
|
|
34492
34652
|
if (pkg.name === "@alipay/linkque-cli" || pkg.name === "linkque-cli-v2") {
|
|
34493
34653
|
return pkg.version ?? "0.0.0";
|
|
34494
34654
|
}
|
|
34495
34655
|
} catch {
|
|
34496
34656
|
}
|
|
34497
|
-
dir =
|
|
34657
|
+
dir = import_path3.default.dirname(dir);
|
|
34498
34658
|
}
|
|
34499
34659
|
return "0.0.0";
|
|
34500
34660
|
};
|
|
@@ -34514,8 +34674,8 @@ var failureEnvelope = (command, error2, durationMs) => ({
|
|
|
34514
34674
|
});
|
|
34515
34675
|
|
|
34516
34676
|
// src/commands/agentbuild/buildCommand.ts
|
|
34517
|
-
var
|
|
34518
|
-
var
|
|
34677
|
+
var import_path11 = __toESM(require("path"));
|
|
34678
|
+
var import_promises6 = require("fs/promises");
|
|
34519
34679
|
|
|
34520
34680
|
// ../../node_modules/tar/dist/esm/index.min.js
|
|
34521
34681
|
var import_events = __toESM(require("events"), 1);
|
|
@@ -34525,7 +34685,7 @@ var import_node_stream = __toESM(require("node:stream"), 1);
|
|
|
34525
34685
|
var import_node_string_decoder = require("node:string_decoder");
|
|
34526
34686
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
34527
34687
|
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
34528
|
-
var
|
|
34688
|
+
var import_path4 = require("path");
|
|
34529
34689
|
var import_events2 = require("events");
|
|
34530
34690
|
var import_assert = __toESM(require("assert"), 1);
|
|
34531
34691
|
var import_buffer = require("buffer");
|
|
@@ -34535,19 +34695,19 @@ var import_node_path2 = require("node:path");
|
|
|
34535
34695
|
var import_node_path3 = require("node:path");
|
|
34536
34696
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
34537
34697
|
var import_fs4 = __toESM(require("fs"), 1);
|
|
34538
|
-
var
|
|
34698
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
34539
34699
|
var import_node_path4 = require("node:path");
|
|
34540
|
-
var
|
|
34700
|
+
var import_path6 = __toESM(require("path"), 1);
|
|
34541
34701
|
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
34542
34702
|
var import_node_assert = __toESM(require("node:assert"), 1);
|
|
34543
|
-
var
|
|
34703
|
+
var import_node_crypto2 = require("node:crypto");
|
|
34544
34704
|
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
34545
34705
|
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
34546
34706
|
var import_fs5 = __toESM(require("fs"), 1);
|
|
34547
34707
|
var import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
34548
34708
|
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
34549
34709
|
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
34550
|
-
var
|
|
34710
|
+
var import_promises4 = __toESM(require("node:fs/promises"), 1);
|
|
34551
34711
|
var import_node_path7 = __toESM(require("node:path"), 1);
|
|
34552
34712
|
var import_node_path8 = require("node:path");
|
|
34553
34713
|
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
@@ -35909,11 +36069,11 @@ var vn = (s4) => {
|
|
|
35909
36069
|
var Qi = (s4, t3) => {
|
|
35910
36070
|
let e3 = new Map(t3.map((o2) => [mt(o2), true])), i = s4.filter, r2 = 100, n3 = (o2, h = "", a = 0) => {
|
|
35911
36071
|
if (a >= r2) return e3.set(o2, false), false;
|
|
35912
|
-
let l2 = h || (0,
|
|
36072
|
+
let l2 = h || (0, import_path4.parse)(o2).root || ".", c;
|
|
35913
36073
|
if (o2 === l2) c = false;
|
|
35914
36074
|
else {
|
|
35915
36075
|
let d = e3.get(o2);
|
|
35916
|
-
c = d !== void 0 ? d : n3((0,
|
|
36076
|
+
c = d !== void 0 ? d : n3((0, import_path4.dirname)(o2), l2, a + 1);
|
|
35917
36077
|
}
|
|
35918
36078
|
return e3.set(o2, c), c;
|
|
35919
36079
|
};
|
|
@@ -36033,7 +36193,7 @@ var de = class extends A {
|
|
|
36033
36193
|
let [o2, h] = ce(this.path);
|
|
36034
36194
|
o2 && typeof h == "string" && (this.path = h, r2 = o2);
|
|
36035
36195
|
}
|
|
36036
|
-
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t3 = t3.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute ||
|
|
36196
|
+
this.win32 = !!i.win32 || process.platform === "win32", this.win32 && (this.path = Qs(this.path.replaceAll(/\\/g, "/")), t3 = t3.replaceAll(/\\/g, "/")), this.absolute = f(i.absolute || import_path5.default.resolve(this.cwd, t3)), this.path === "" && (this.path = "./"), r2 && this.warn("TAR_ENTRY_INFO", `stripping ${r2} from absolute path`, { entry: this, path: r2 + this.path });
|
|
36037
36197
|
let n3 = this.statCache.get(this.absolute);
|
|
36038
36198
|
n3 ? this[si](n3) : this[ss]();
|
|
36039
36199
|
}
|
|
@@ -36092,7 +36252,7 @@ var de = class extends A {
|
|
|
36092
36252
|
}
|
|
36093
36253
|
[sr](t3) {
|
|
36094
36254
|
if (!this.stat) throw new Error("cannot create link entry without stat");
|
|
36095
|
-
this.type = "Link", this.linkpath = f(
|
|
36255
|
+
this.type = "Link", this.linkpath = f(import_path5.default.relative(this.cwd, t3)), this.stat.size = 0, this[fe](), this.end();
|
|
36096
36256
|
}
|
|
36097
36257
|
[er]() {
|
|
36098
36258
|
if (!this.stat) throw new Error("cannot create file entry without stat");
|
|
@@ -36506,7 +36666,7 @@ var wt = class extends A {
|
|
|
36506
36666
|
return typeof t3 == "string" ? this[ci](t3) : this[or](t3), this.flowing;
|
|
36507
36667
|
}
|
|
36508
36668
|
[or](t3) {
|
|
36509
|
-
let e3 = f(
|
|
36669
|
+
let e3 = f(import_path6.default.resolve(this.cwd, t3.path));
|
|
36510
36670
|
if (!this.filter(t3.path, t3)) t3.resume();
|
|
36511
36671
|
else {
|
|
36512
36672
|
let i = new pi(t3.path, e3);
|
|
@@ -36515,7 +36675,7 @@ var wt = class extends A {
|
|
|
36515
36675
|
this[Ft]();
|
|
36516
36676
|
}
|
|
36517
36677
|
[ci](t3) {
|
|
36518
|
-
let e3 = f(
|
|
36678
|
+
let e3 = f(import_path6.default.resolve(this.cwd, t3));
|
|
36519
36679
|
this[W].push(new pi(t3, e3)), this[Ft]();
|
|
36520
36680
|
}
|
|
36521
36681
|
[ds](t3) {
|
|
@@ -36786,7 +36946,7 @@ var gr = (s4, t3, e3) => {
|
|
|
36786
36946
|
E ? e3(E) : x && a ? Es(x, o2, h, (Le) => y(Le)) : n3 ? import_node_fs5.default.chmod(s4, r2, e3) : e3();
|
|
36787
36947
|
};
|
|
36788
36948
|
if (s4 === d) return no(s4, y);
|
|
36789
|
-
if (l2) return
|
|
36949
|
+
if (l2) return import_promises4.default.mkdir(s4, { mode: r2, recursive: true }).then((E) => y(null, E ?? void 0), y);
|
|
36790
36950
|
let D = f(import_node_path7.default.relative(d, s4)).split("/");
|
|
36791
36951
|
Ss(d, D, r2, c, d, void 0, y);
|
|
36792
36952
|
};
|
|
@@ -36955,7 +37115,7 @@ var Te = fo === "win32";
|
|
|
36955
37115
|
var uo = 1024;
|
|
36956
37116
|
var mo = (s4, t3) => {
|
|
36957
37117
|
if (!Te) return import_node_fs3.default.unlink(s4, t3);
|
|
36958
|
-
let e3 = s4 + ".DELETE." + (0,
|
|
37118
|
+
let e3 = s4 + ".DELETE." + (0, import_node_crypto2.randomBytes)(16).toString("hex");
|
|
36959
37119
|
import_node_fs3.default.rename(s4, e3, (i) => {
|
|
36960
37120
|
if (i) return t3(i);
|
|
36961
37121
|
import_node_fs3.default.unlink(e3, t3);
|
|
@@ -36963,7 +37123,7 @@ var mo = (s4, t3) => {
|
|
|
36963
37123
|
};
|
|
36964
37124
|
var po = (s4) => {
|
|
36965
37125
|
if (!Te) return import_node_fs3.default.unlinkSync(s4);
|
|
36966
|
-
let t3 = s4 + ".DELETE." + (0,
|
|
37126
|
+
let t3 = s4 + ".DELETE." + (0, import_node_crypto2.randomBytes)(16).toString("hex");
|
|
36967
37127
|
import_node_fs3.default.renameSync(s4, t3), import_node_fs3.default.unlinkSync(t3);
|
|
36968
37128
|
};
|
|
36969
37129
|
var vr = (s4, t3, e3) => s4 !== void 0 && s4 === s4 >>> 0 ? s4 : t3 !== void 0 && t3 === t3 >>> 0 ? t3 : e3;
|
|
@@ -37486,74 +37646,9 @@ var To = (s4) => {
|
|
|
37486
37646
|
s4.mtimeCache || (s4.mtimeCache = /* @__PURE__ */ new Map()), s4.filter = t3 ? (e3, i) => t3(e3, i) && !((s4.mtimeCache?.get(e3) ?? i.mtime ?? 0) > (i.mtime ?? 0)) : (e3, i) => !((s4.mtimeCache?.get(e3) ?? i.mtime ?? 0) > (i.mtime ?? 0));
|
|
37487
37647
|
};
|
|
37488
37648
|
|
|
37489
|
-
// src/utils/files.ts
|
|
37490
|
-
var import_crypto = require("crypto");
|
|
37491
|
-
var import_promises2 = require("fs/promises");
|
|
37492
|
-
var import_promises3 = require("fs/promises");
|
|
37493
|
-
var import_path5 = __toESM(require("path"));
|
|
37494
|
-
var isNodeError = (error2, code) => error2 !== null && typeof error2 === "object" && "code" in error2 && error2.code === code;
|
|
37495
|
-
var ensureParentDir = (filePath) => (0, import_promises3.mkdir)(import_path5.default.dirname(filePath), { recursive: true }).then(() => void 0);
|
|
37496
|
-
var readUtf8IfExists = async (filePath) => {
|
|
37497
|
-
try {
|
|
37498
|
-
return await (0, import_promises3.readFile)(filePath, "utf8");
|
|
37499
|
-
} catch (error2) {
|
|
37500
|
-
if (isNodeError(error2, "ENOENT")) {
|
|
37501
|
-
return null;
|
|
37502
|
-
}
|
|
37503
|
-
throw error2;
|
|
37504
|
-
}
|
|
37505
|
-
};
|
|
37506
|
-
var pathExists = async (filePath) => {
|
|
37507
|
-
try {
|
|
37508
|
-
await (0, import_promises2.stat)(filePath);
|
|
37509
|
-
return true;
|
|
37510
|
-
} catch (error2) {
|
|
37511
|
-
if (isNodeError(error2, "ENOENT")) return false;
|
|
37512
|
-
throw error2;
|
|
37513
|
-
}
|
|
37514
|
-
};
|
|
37515
|
-
var pathHasKind = async (filePath, kind) => {
|
|
37516
|
-
try {
|
|
37517
|
-
return (await (0, import_promises2.stat)(filePath))[kind === "dir" ? "isDirectory" : "isFile"]();
|
|
37518
|
-
} catch (error2) {
|
|
37519
|
-
if (isNodeError(error2, "ENOENT")) return false;
|
|
37520
|
-
throw error2;
|
|
37521
|
-
}
|
|
37522
|
-
};
|
|
37523
|
-
var parseJsonObject = (content, code, message) => {
|
|
37524
|
-
try {
|
|
37525
|
-
const value = JSON.parse(content);
|
|
37526
|
-
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
37527
|
-
return value;
|
|
37528
|
-
}
|
|
37529
|
-
} catch (error2) {
|
|
37530
|
-
throw new LinkqueCliError(code, message, { cause: error2 });
|
|
37531
|
-
}
|
|
37532
|
-
throw new LinkqueCliError(code, message);
|
|
37533
|
-
};
|
|
37534
|
-
var writeJsonAtomically = async (filePath, value, { exclusive = false } = {}) => {
|
|
37535
|
-
await ensureParentDir(filePath);
|
|
37536
|
-
const tempPath = `${filePath}.${process.pid}.${(0, import_crypto.randomUUID)()}.tmp`;
|
|
37537
|
-
try {
|
|
37538
|
-
await (0, import_promises3.writeFile)(
|
|
37539
|
-
tempPath,
|
|
37540
|
-
`${JSON.stringify(value, null, 2)}
|
|
37541
|
-
`,
|
|
37542
|
-
exclusive ? { encoding: "utf8", flag: "wx" } : "utf8"
|
|
37543
|
-
);
|
|
37544
|
-
if (exclusive) {
|
|
37545
|
-
await (0, import_promises3.link)(tempPath, filePath);
|
|
37546
|
-
} else {
|
|
37547
|
-
await (0, import_promises3.rename)(tempPath, filePath);
|
|
37548
|
-
}
|
|
37549
|
-
} finally {
|
|
37550
|
-
await (0, import_promises3.rm)(tempPath, { force: true }).catch(() => void 0);
|
|
37551
|
-
}
|
|
37552
|
-
};
|
|
37553
|
-
|
|
37554
37649
|
// src/utils/workspaceLock.ts
|
|
37555
37650
|
var import_crypto2 = require("crypto");
|
|
37556
|
-
var
|
|
37651
|
+
var import_promises5 = require("fs/promises");
|
|
37557
37652
|
var import_os = require("os");
|
|
37558
37653
|
|
|
37559
37654
|
// src/utils/process.ts
|
|
@@ -37613,19 +37708,19 @@ var describeOwner = (owner) => {
|
|
|
37613
37708
|
};
|
|
37614
37709
|
var publishOwner = async (lockPath, owner) => {
|
|
37615
37710
|
const pendingPath = `${lockPath}.${owner.ownerId}.pending`;
|
|
37616
|
-
await (0,
|
|
37711
|
+
await (0, import_promises5.writeFile)(pendingPath, `${JSON.stringify(owner)}
|
|
37617
37712
|
`, {
|
|
37618
37713
|
encoding: "utf8",
|
|
37619
37714
|
flag: "wx"
|
|
37620
37715
|
});
|
|
37621
37716
|
try {
|
|
37622
|
-
await (0,
|
|
37717
|
+
await (0, import_promises5.link)(pendingPath, lockPath);
|
|
37623
37718
|
return true;
|
|
37624
37719
|
} catch (error2) {
|
|
37625
37720
|
if (isNodeError(error2, "EEXIST")) return false;
|
|
37626
37721
|
throw error2;
|
|
37627
37722
|
} finally {
|
|
37628
|
-
await (0,
|
|
37723
|
+
await (0, import_promises5.rm)(pendingPath, { force: true });
|
|
37629
37724
|
}
|
|
37630
37725
|
};
|
|
37631
37726
|
var releaseOwner = async (lockPath, ownerId, name) => {
|
|
@@ -37634,7 +37729,7 @@ var releaseOwner = async (lockPath, ownerId, name) => {
|
|
|
37634
37729
|
if (owner.ownerId !== ownerId) {
|
|
37635
37730
|
throw new Error(`workspace ${name} lock ownership changed`);
|
|
37636
37731
|
}
|
|
37637
|
-
await (0,
|
|
37732
|
+
await (0, import_promises5.rm)(lockPath);
|
|
37638
37733
|
};
|
|
37639
37734
|
var acquireWorkspaceLock = async (lockPath, options) => {
|
|
37640
37735
|
await ensureParentDir(lockPath);
|
|
@@ -37870,7 +37965,7 @@ async function bundleAgentInstallation(input) {
|
|
|
37870
37965
|
}
|
|
37871
37966
|
|
|
37872
37967
|
// src/commands/agentbuild/configLoader.ts
|
|
37873
|
-
var
|
|
37968
|
+
var import_path7 = __toESM(require("path"));
|
|
37874
37969
|
|
|
37875
37970
|
// src/commands/agentbuild/types.ts
|
|
37876
37971
|
var AGENT_BUNDLE_DIR = ".linkque/artifacts/agent-bundle";
|
|
@@ -37885,7 +37980,7 @@ var DEFAULT_CONFIG_NAME = "agent_config.json";
|
|
|
37885
37980
|
|
|
37886
37981
|
// src/commands/agentbuild/configLoader.ts
|
|
37887
37982
|
var loadAgentProtocol = async (rawConfigPath, cwd) => {
|
|
37888
|
-
const configPath =
|
|
37983
|
+
const configPath = import_path7.default.resolve(
|
|
37889
37984
|
cwd,
|
|
37890
37985
|
rawConfigPath === "" ? DEFAULT_CONFIG_NAME : rawConfigPath
|
|
37891
37986
|
);
|
|
@@ -37931,7 +38026,7 @@ var EModelRequestSource;
|
|
|
37931
38026
|
})(EModelRequestSource || (EModelRequestSource = {}));
|
|
37932
38027
|
|
|
37933
38028
|
// ../linkque-agent-runtime/dist/esm/core/dataTransformExecutor.js
|
|
37934
|
-
var
|
|
38029
|
+
var import_node_crypto3 = require("node:crypto");
|
|
37935
38030
|
var import_node_worker_threads = require("node:worker_threads");
|
|
37936
38031
|
|
|
37937
38032
|
// ../linkque-agent-runtime/dist/esm/core/dataTransformWorkerUrl.js
|
|
@@ -37988,7 +38083,7 @@ var DataTransformExecutor = class {
|
|
|
37988
38083
|
}
|
|
37989
38084
|
execute(source, input, signal, options) {
|
|
37990
38085
|
const sourceBytes = Buffer.byteLength(source, "utf8");
|
|
37991
|
-
const sourceHash = (0,
|
|
38086
|
+
const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
|
|
37992
38087
|
if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
|
|
37993
38088
|
return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
|
|
37994
38089
|
}
|
|
@@ -38044,7 +38139,7 @@ var DataTransformExecutor = class {
|
|
|
38044
38139
|
}
|
|
38045
38140
|
validateSource(source, profile) {
|
|
38046
38141
|
const sourceBytes = Buffer.byteLength(source, "utf8");
|
|
38047
|
-
const sourceHash = (0,
|
|
38142
|
+
const sourceHash = (0, import_node_crypto3.createHash)("sha256").update(source).digest("hex");
|
|
38048
38143
|
if (!source.trim() || sourceBytes > DATA_TRANSFORM_LIMITS.sourceBytes) {
|
|
38049
38144
|
return Promise.reject(new DataTransformError("CARD_TRANSFORM_SOURCE_INVALID", `\u6570\u636E\u8F6C\u6362\u6E90\u7801\u4E3A\u7A7A\u6216\u8D85\u8FC7 ${DATA_TRANSFORM_LIMITS.sourceBytes} \u5B57\u8282`, sourceHash));
|
|
38050
38145
|
}
|
|
@@ -38306,7 +38401,6 @@ var EResourceType;
|
|
|
38306
38401
|
EResourceType2["CARD"] = "CARD";
|
|
38307
38402
|
EResourceType2["TOOL"] = "TOOL";
|
|
38308
38403
|
EResourceType2["WEB_SEARCH"] = "WEB_SEARCH";
|
|
38309
|
-
EResourceType2["MEMORY"] = "MEMORY";
|
|
38310
38404
|
EResourceType2["FOLLOW_UP_QUESTIONS"] = "FOLLOW_UP_QUESTIONS";
|
|
38311
38405
|
EResourceType2["CLIENT_CAPABILITY"] = "CLIENT_CAPABILITY";
|
|
38312
38406
|
EResourceType2["HOOK"] = "HOOK";
|
|
@@ -38343,7 +38437,6 @@ var EHookExecutorName;
|
|
|
38343
38437
|
EHookExecutorName2["ImageUnderstandingHookExecutor"] = "ImageUnderstandingHookExecutor";
|
|
38344
38438
|
EHookExecutorName2["McpDiscoveryHookExecutor"] = "McpDiscoveryHookExecutor";
|
|
38345
38439
|
EHookExecutorName2["CurrentTimeHookExecutor"] = "CurrentTimeHookExecutor";
|
|
38346
|
-
EHookExecutorName2["MemoryHookExecutor"] = "MemoryHookExecutor";
|
|
38347
38440
|
})(EHookExecutorName || (EHookExecutorName = {}));
|
|
38348
38441
|
|
|
38349
38442
|
// ../agent-a2ui-card-contract/dist/esm/protocol.js
|
|
@@ -38449,10 +38542,10 @@ function canonicalizeBindingPath(rawPath, listRoot) {
|
|
|
38449
38542
|
}
|
|
38450
38543
|
return isSafeJsonPointer(candidate, true) ? candidate : void 0;
|
|
38451
38544
|
}
|
|
38452
|
-
function issue2(
|
|
38453
|
-
return { path:
|
|
38545
|
+
function issue2(path28, code, message) {
|
|
38546
|
+
return { path: path28, code, message };
|
|
38454
38547
|
}
|
|
38455
|
-
function exactKeys(value, allowed,
|
|
38548
|
+
function exactKeys(value, allowed, path28, issues) {
|
|
38456
38549
|
}
|
|
38457
38550
|
|
|
38458
38551
|
// ../agent-a2ui-card-contract/dist/esm/binding-analyzer.js
|
|
@@ -38682,9 +38775,9 @@ var SCHEMA_TYPES = /* @__PURE__ */ new Set([
|
|
|
38682
38775
|
"object",
|
|
38683
38776
|
"string"
|
|
38684
38777
|
]);
|
|
38685
|
-
function getJsonSchemaIssues(value,
|
|
38778
|
+
function getJsonSchemaIssues(value, path28 = "schema", options = {}) {
|
|
38686
38779
|
const issues = [];
|
|
38687
|
-
validateSchemaNode(value,
|
|
38780
|
+
validateSchemaNode(value, path28, issues, options);
|
|
38688
38781
|
return issues;
|
|
38689
38782
|
}
|
|
38690
38783
|
var OPAQUE_OBJECT_SCHEMA = {
|
|
@@ -38706,9 +38799,9 @@ function normalizeTargetJsonSchema(schema2) {
|
|
|
38706
38799
|
normalizeObjectDefaults(cloned);
|
|
38707
38800
|
return cloned;
|
|
38708
38801
|
}
|
|
38709
|
-
function validateJsonSchemaValue2(schema2, value,
|
|
38802
|
+
function validateJsonSchemaValue2(schema2, value, path28 = "$") {
|
|
38710
38803
|
const issues = [];
|
|
38711
|
-
validateValue(schema2, value,
|
|
38804
|
+
validateValue(schema2, value, path28, issues);
|
|
38712
38805
|
return issues;
|
|
38713
38806
|
}
|
|
38714
38807
|
function normalizeCardDataValue(schema2, value, required2 = true) {
|
|
@@ -38812,9 +38905,9 @@ function getJsonSchemaAtDataPointer(schema2, pointer) {
|
|
|
38812
38905
|
return schema2;
|
|
38813
38906
|
return getJsonSchemaAtPath(schema2, pointer.slice(1).split("/").map(decodePointerSegment));
|
|
38814
38907
|
}
|
|
38815
|
-
function getJsonSchemaAtPath(schema2,
|
|
38908
|
+
function getJsonSchemaAtPath(schema2, path28) {
|
|
38816
38909
|
let current = schema2;
|
|
38817
|
-
for (const segment of
|
|
38910
|
+
for (const segment of path28) {
|
|
38818
38911
|
if (!current)
|
|
38819
38912
|
return void 0;
|
|
38820
38913
|
if (segment === "*" || current.type === "array") {
|
|
@@ -38832,56 +38925,56 @@ function getJsonSchemaAtPath(schema2, path26) {
|
|
|
38832
38925
|
}
|
|
38833
38926
|
return current;
|
|
38834
38927
|
}
|
|
38835
|
-
function getJsonSchemaCompatibilityIssues(source, target,
|
|
38928
|
+
function getJsonSchemaCompatibilityIssues(source, target, path28 = "$") {
|
|
38836
38929
|
const issues = [];
|
|
38837
|
-
compareSchemas(source, target,
|
|
38930
|
+
compareSchemas(source, target, path28, issues);
|
|
38838
38931
|
return issues;
|
|
38839
38932
|
}
|
|
38840
38933
|
function areJsonSchemaTypesCompatible(sourceType, targetType) {
|
|
38841
38934
|
return sourceType === targetType || sourceType === "integer" && targetType === "number";
|
|
38842
38935
|
}
|
|
38843
|
-
function validateSchemaNode(value,
|
|
38936
|
+
function validateSchemaNode(value, path28, issues, options) {
|
|
38844
38937
|
if (!isPlainRecord(value) || !isJsonValue(value)) {
|
|
38845
|
-
issues.push(issue2(
|
|
38938
|
+
issues.push(issue2(path28, "INVALID_JSON_SCHEMA", `${path28} must be a JSON object`));
|
|
38846
38939
|
return false;
|
|
38847
38940
|
}
|
|
38848
38941
|
if (value.type === void 0 && options.allowMissingType) {
|
|
38849
38942
|
return true;
|
|
38850
38943
|
}
|
|
38851
38944
|
if (typeof value.type !== "string" || !SCHEMA_TYPES.has(value.type)) {
|
|
38852
|
-
issues.push(issue2(`${
|
|
38945
|
+
issues.push(issue2(`${path28}.type`, "INVALID_JSON_SCHEMA_TYPE", `${path28}.type must be a supported scalar, object or array type`));
|
|
38853
38946
|
return false;
|
|
38854
38947
|
}
|
|
38855
38948
|
if (value.required !== void 0 && (!Array.isArray(value.required) || value.required.some((entry) => typeof entry !== "string"))) {
|
|
38856
|
-
issues.push(issue2(`${
|
|
38949
|
+
issues.push(issue2(`${path28}.required`, "INVALID_JSON_SCHEMA_REQUIRED", `${path28}.required must be a string array`));
|
|
38857
38950
|
}
|
|
38858
38951
|
if (value.type === "object") {
|
|
38859
38952
|
if (!isPlainRecord(value.properties)) {
|
|
38860
38953
|
if (options.requireCompleteStructures) {
|
|
38861
|
-
issues.push(issue2(`${
|
|
38954
|
+
issues.push(issue2(`${path28}.properties`, "INCOMPLETE_OBJECT_SCHEMA", "object schemas must declare properties"));
|
|
38862
38955
|
}
|
|
38863
38956
|
} else {
|
|
38864
38957
|
for (const [name, child] of Object.entries(value.properties)) {
|
|
38865
|
-
validateSchemaNode(child, `${
|
|
38958
|
+
validateSchemaNode(child, `${path28}.properties.${name}`, issues, options);
|
|
38866
38959
|
}
|
|
38867
38960
|
const required2 = Array.isArray(value.required) ? value.required.filter((entry) => typeof entry === "string") : [];
|
|
38868
38961
|
for (const name of required2) {
|
|
38869
38962
|
if (!(name in value.properties)) {
|
|
38870
|
-
issues.push(issue2(`${
|
|
38963
|
+
issues.push(issue2(`${path28}.required`, "UNKNOWN_REQUIRED_PROPERTY", `required property ${name} is not declared`));
|
|
38871
38964
|
}
|
|
38872
38965
|
}
|
|
38873
38966
|
}
|
|
38874
38967
|
if (value.additionalProperties !== void 0 && typeof value.additionalProperties !== "boolean" && !isPlainRecord(value.additionalProperties)) {
|
|
38875
|
-
issues.push(issue2(`${
|
|
38968
|
+
issues.push(issue2(`${path28}.additionalProperties`, "INVALID_ADDITIONAL_PROPERTIES", "additionalProperties must be a boolean or schema"));
|
|
38876
38969
|
}
|
|
38877
38970
|
}
|
|
38878
38971
|
if (value.type === "array") {
|
|
38879
38972
|
if (!isPlainRecord(value.items)) {
|
|
38880
38973
|
if (options.requireCompleteStructures) {
|
|
38881
|
-
issues.push(issue2(`${
|
|
38974
|
+
issues.push(issue2(`${path28}.items`, "INCOMPLETE_ARRAY_SCHEMA", "array schemas must declare items"));
|
|
38882
38975
|
}
|
|
38883
38976
|
} else {
|
|
38884
|
-
validateSchemaNode(value.items, `${
|
|
38977
|
+
validateSchemaNode(value.items, `${path28}.items`, issues, options);
|
|
38885
38978
|
}
|
|
38886
38979
|
}
|
|
38887
38980
|
return true;
|
|
@@ -38901,53 +38994,53 @@ function normalizeObjectDefaults(schema2) {
|
|
|
38901
38994
|
normalizeObjectDefaults(schema2.items);
|
|
38902
38995
|
}
|
|
38903
38996
|
}
|
|
38904
|
-
function validateValue(schema2, value,
|
|
38997
|
+
function validateValue(schema2, value, path28, issues) {
|
|
38905
38998
|
if (typeof schema2.type === "string" && !matchesType(schema2.type, value)) {
|
|
38906
|
-
issues.push(issue2(
|
|
38999
|
+
issues.push(issue2(path28, "SCHEMA_TYPE_MISMATCH", `expected ${schema2.type}, received ${valueType(value)}`));
|
|
38907
39000
|
return;
|
|
38908
39001
|
}
|
|
38909
39002
|
if (Array.isArray(schema2.enum) && !schema2.enum.some((entry) => Object.is(entry, value))) {
|
|
38910
|
-
issues.push(issue2(
|
|
39003
|
+
issues.push(issue2(path28, "SCHEMA_ENUM_MISMATCH", "value is not in the declared enum"));
|
|
38911
39004
|
return;
|
|
38912
39005
|
}
|
|
38913
39006
|
if (schema2.const !== void 0 && !Object.is(schema2.const, value)) {
|
|
38914
|
-
issues.push(issue2(
|
|
39007
|
+
issues.push(issue2(path28, "SCHEMA_CONST_MISMATCH", "value does not match const"));
|
|
38915
39008
|
return;
|
|
38916
39009
|
}
|
|
38917
39010
|
if (schema2.type === "object" && isPlainRecord(value)) {
|
|
38918
39011
|
const required2 = Array.isArray(schema2.required) ? schema2.required.filter((entry) => typeof entry === "string") : [];
|
|
38919
39012
|
for (const key of required2) {
|
|
38920
39013
|
if (!(key in value)) {
|
|
38921
|
-
issues.push(issue2(`${
|
|
39014
|
+
issues.push(issue2(`${path28}/${key}`, "SCHEMA_REQUIRED_MISSING", `required property ${key} is missing`));
|
|
38922
39015
|
}
|
|
38923
39016
|
}
|
|
38924
39017
|
const properties = isPlainRecord(schema2.properties) ? schema2.properties : {};
|
|
38925
39018
|
for (const [key, childSchema] of Object.entries(properties)) {
|
|
38926
39019
|
if (!(key in value) || !isPlainRecord(childSchema))
|
|
38927
39020
|
continue;
|
|
38928
|
-
validateValue(childSchema, value[key], `${
|
|
39021
|
+
validateValue(childSchema, value[key], `${path28}/${key}`, issues);
|
|
38929
39022
|
}
|
|
38930
39023
|
if (schema2.additionalProperties === false) {
|
|
38931
39024
|
for (const key of Object.keys(value)) {
|
|
38932
39025
|
if (!(key in properties)) {
|
|
38933
|
-
issues.push(issue2(`${
|
|
39026
|
+
issues.push(issue2(`${path28}/${key}`, "SCHEMA_ADDITIONAL_PROPERTY", `property ${key} is not allowed`));
|
|
38934
39027
|
}
|
|
38935
39028
|
}
|
|
38936
39029
|
}
|
|
38937
39030
|
}
|
|
38938
39031
|
if (schema2.type === "array" && Array.isArray(value) && isPlainRecord(schema2.items)) {
|
|
38939
39032
|
value.forEach((entry, index) => {
|
|
38940
|
-
validateValue(schema2.items, entry, `${
|
|
39033
|
+
validateValue(schema2.items, entry, `${path28}/${index}`, issues);
|
|
38941
39034
|
});
|
|
38942
39035
|
}
|
|
38943
39036
|
}
|
|
38944
|
-
function compareSchemas(source, target,
|
|
39037
|
+
function compareSchemas(source, target, path28, issues) {
|
|
38945
39038
|
if (!areJsonSchemaTypesCompatible(source.type, target.type)) {
|
|
38946
|
-
issues.push(issue2(
|
|
39039
|
+
issues.push(issue2(path28, "SCHEMA_TYPE_INCOMPATIBLE", `source type ${String(source.type)} cannot supply ${String(target.type)}`));
|
|
38947
39040
|
return;
|
|
38948
39041
|
}
|
|
38949
39042
|
if (source.type === "array" && target.type === "array" && isPlainRecord(source.items) && isPlainRecord(target.items)) {
|
|
38950
|
-
compareSchemas(source.items, target.items, `${
|
|
39043
|
+
compareSchemas(source.items, target.items, `${path28}[*]`, issues);
|
|
38951
39044
|
}
|
|
38952
39045
|
if (source.type === "object" && target.type === "object" && isPlainRecord(source.properties) && isPlainRecord(target.properties)) {
|
|
38953
39046
|
const required2 = Array.isArray(target.required) ? target.required.filter((entry) => typeof entry === "string") : [];
|
|
@@ -38955,10 +39048,10 @@ function compareSchemas(source, target, path26, issues) {
|
|
|
38955
39048
|
const sourceChild = source.properties[name];
|
|
38956
39049
|
const targetChild = target.properties[name];
|
|
38957
39050
|
if (!isPlainRecord(sourceChild) || !isPlainRecord(targetChild)) {
|
|
38958
|
-
issues.push(issue2(`${
|
|
39051
|
+
issues.push(issue2(`${path28}.${name}`, "SCHEMA_REQUIRED_MISSING", `source does not provide required property ${name}`));
|
|
38959
39052
|
continue;
|
|
38960
39053
|
}
|
|
38961
|
-
compareSchemas(sourceChild, targetChild, `${
|
|
39054
|
+
compareSchemas(sourceChild, targetChild, `${path28}.${name}`, issues);
|
|
38962
39055
|
}
|
|
38963
39056
|
}
|
|
38964
39057
|
}
|
|
@@ -39047,37 +39140,37 @@ var A2UICardExpressionError = class extends Error {
|
|
|
39047
39140
|
this.fieldId = fieldId;
|
|
39048
39141
|
}
|
|
39049
39142
|
};
|
|
39050
|
-
function getA2UICardTransformIssues(value,
|
|
39143
|
+
function getA2UICardTransformIssues(value, path28 = "transform") {
|
|
39051
39144
|
if (!isPlainRecord(value)) {
|
|
39052
39145
|
return [
|
|
39053
|
-
issue2(
|
|
39146
|
+
issue2(path28, "CARD_EXPRESSION_INVALID", "transform must be an object")
|
|
39054
39147
|
];
|
|
39055
39148
|
}
|
|
39056
39149
|
const issues = [];
|
|
39057
39150
|
const allowedKeys = /* @__PURE__ */ new Set(["language", "profile", "expression"]);
|
|
39058
39151
|
for (const key of Object.keys(value)) {
|
|
39059
39152
|
if (!allowedKeys.has(key)) {
|
|
39060
|
-
issues.push(issue2(`${
|
|
39153
|
+
issues.push(issue2(`${path28}.${key}`, "CARD_EXPRESSION_INVALID", `${key} is not supported by transform`));
|
|
39061
39154
|
}
|
|
39062
39155
|
}
|
|
39063
39156
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
39064
|
-
issues.push(issue2(`${
|
|
39157
|
+
issues.push(issue2(`${path28}.language`, "CARD_EXPRESSION_INVALID", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
39065
39158
|
}
|
|
39066
39159
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
39067
|
-
issues.push(issue2(`${
|
|
39160
|
+
issues.push(issue2(`${path28}.profile`, "CARD_EXPRESSION_INVALID", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
39068
39161
|
}
|
|
39069
39162
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
39070
|
-
issues.push(issue2(`${
|
|
39163
|
+
issues.push(issue2(`${path28}.expression`, "CARD_EXPRESSION_INVALID", "expression must be a non-empty string"));
|
|
39071
39164
|
return issues;
|
|
39072
39165
|
}
|
|
39073
39166
|
if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
39074
|
-
issues.push(issue2(`${
|
|
39167
|
+
issues.push(issue2(`${path28}.expression`, "CARD_EXPRESSION_LIMIT_EXCEEDED", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
39075
39168
|
return issues;
|
|
39076
39169
|
}
|
|
39077
39170
|
try {
|
|
39078
39171
|
validateAst((0, import_jmespath2.compile)(value.expression));
|
|
39079
39172
|
} catch (error2) {
|
|
39080
|
-
issues.push(issue2(`${
|
|
39173
|
+
issues.push(issue2(`${path28}.expression`, error2 instanceof A2UICardExpressionError ? error2.code : "CARD_EXPRESSION_INVALID", error2 instanceof Error ? error2.message : "expression is invalid"));
|
|
39081
39174
|
}
|
|
39082
39175
|
return issues;
|
|
39083
39176
|
}
|
|
@@ -39189,11 +39282,11 @@ function parseA2UICardBindingContext(value) {
|
|
|
39189
39282
|
issues: []
|
|
39190
39283
|
};
|
|
39191
39284
|
}
|
|
39192
|
-
function getA2UICardBindingContextIssues(value,
|
|
39285
|
+
function getA2UICardBindingContextIssues(value, path28 = "bindingContext") {
|
|
39193
39286
|
const issues = [];
|
|
39194
39287
|
if (!isPlainRecord(value)) {
|
|
39195
39288
|
return [
|
|
39196
|
-
issue2(
|
|
39289
|
+
issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "binding context must be an object")
|
|
39197
39290
|
];
|
|
39198
39291
|
}
|
|
39199
39292
|
exactKeys(value, [
|
|
@@ -39205,36 +39298,36 @@ function getA2UICardBindingContextIssues(value, path26 = "bindingContext") {
|
|
|
39205
39298
|
"generatedAt",
|
|
39206
39299
|
"candidates",
|
|
39207
39300
|
"preferredTools"
|
|
39208
|
-
],
|
|
39301
|
+
], path28, issues);
|
|
39209
39302
|
if (value.schemaVersion !== "1") {
|
|
39210
|
-
issues.push(issue2(`${
|
|
39303
|
+
issues.push(issue2(`${path28}.schemaVersion`, "CARD_BINDING_CONTEXT_INVALID", "schemaVersion must be 1"));
|
|
39211
39304
|
}
|
|
39212
39305
|
for (const key of ["draftId", "resourceId"]) {
|
|
39213
39306
|
if (!isSafeIdentifier(value[key])) {
|
|
39214
|
-
issues.push(issue2(`${
|
|
39307
|
+
issues.push(issue2(`${path28}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} is invalid`));
|
|
39215
39308
|
}
|
|
39216
39309
|
}
|
|
39217
39310
|
for (const key of ["draftStructureChecksum", "mcpConfigChecksum"]) {
|
|
39218
39311
|
if (typeof value[key] !== "string" || !/^[0-9a-f]{64}$/u.test(value[key])) {
|
|
39219
|
-
issues.push(issue2(`${
|
|
39312
|
+
issues.push(issue2(`${path28}.${key}`, "CARD_BINDING_CONTEXT_INVALID", `${key} must be a sha256 checksum`));
|
|
39220
39313
|
}
|
|
39221
39314
|
}
|
|
39222
39315
|
if (typeof value.generatedAt !== "string" || !Number.isFinite(Date.parse(value.generatedAt))) {
|
|
39223
|
-
issues.push(issue2(`${
|
|
39316
|
+
issues.push(issue2(`${path28}.generatedAt`, "CARD_BINDING_CONTEXT_INVALID", "generatedAt must be an ISO timestamp"));
|
|
39224
39317
|
}
|
|
39225
|
-
validateCandidates(value.candidates, `${
|
|
39226
|
-
validatePreferences(value.preferredTools, `${
|
|
39318
|
+
validateCandidates(value.candidates, `${path28}.candidates`, issues);
|
|
39319
|
+
validatePreferences(value.preferredTools, `${path28}.preferredTools`, issues);
|
|
39227
39320
|
return issues;
|
|
39228
39321
|
}
|
|
39229
|
-
function getA2UICardBindingSelectionIssues(value,
|
|
39322
|
+
function getA2UICardBindingSelectionIssues(value, path28 = "bindings", fields) {
|
|
39230
39323
|
const issues = [];
|
|
39231
39324
|
if (!Array.isArray(value)) {
|
|
39232
|
-
return [issue2(
|
|
39325
|
+
return [issue2(path28, "CARD_BINDING_INVALID", "bindings must be an array")];
|
|
39233
39326
|
}
|
|
39234
39327
|
const fieldById = new Map(fields?.map((field) => [field.fieldId, field]) ?? []);
|
|
39235
39328
|
const seen = /* @__PURE__ */ new Set();
|
|
39236
39329
|
value.forEach((candidate, index) => {
|
|
39237
|
-
const itemPath = `${
|
|
39330
|
+
const itemPath = `${path28}[${index}]`;
|
|
39238
39331
|
if (!isPlainRecord(candidate)) {
|
|
39239
39332
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "binding must be an object"));
|
|
39240
39333
|
return;
|
|
@@ -39347,14 +39440,14 @@ function validateA2UICardBindings(input, options = {}) {
|
|
|
39347
39440
|
validateConsistencyGroups(input.draft.manifest.fields, bindings, issues, selectedFields);
|
|
39348
39441
|
return issues;
|
|
39349
39442
|
}
|
|
39350
|
-
function validateCandidates(value,
|
|
39443
|
+
function validateCandidates(value, path28, issues) {
|
|
39351
39444
|
if (!Array.isArray(value) || value.length > 200) {
|
|
39352
|
-
issues.push(issue2(
|
|
39445
|
+
issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "candidates must be an array with at most 200 items"));
|
|
39353
39446
|
return;
|
|
39354
39447
|
}
|
|
39355
39448
|
const candidateKeys = /* @__PURE__ */ new Set();
|
|
39356
39449
|
value.forEach((candidate, index) => {
|
|
39357
|
-
const itemPath = `${
|
|
39450
|
+
const itemPath = `${path28}[${index}]`;
|
|
39358
39451
|
if (!isPlainRecord(candidate)) {
|
|
39359
39452
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "candidate must be an object"));
|
|
39360
39453
|
return;
|
|
@@ -39395,9 +39488,9 @@ function validateCandidates(value, path26, issues) {
|
|
|
39395
39488
|
}
|
|
39396
39489
|
});
|
|
39397
39490
|
}
|
|
39398
|
-
function validateTool(value,
|
|
39491
|
+
function validateTool(value, path28, resourceId, issues) {
|
|
39399
39492
|
if (!isPlainRecord(value)) {
|
|
39400
|
-
issues.push(issue2(
|
|
39493
|
+
issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "tool must be an object"));
|
|
39401
39494
|
return;
|
|
39402
39495
|
}
|
|
39403
39496
|
exactKeys(value, [
|
|
@@ -39408,16 +39501,16 @@ function validateTool(value, path26, resourceId, issues) {
|
|
|
39408
39501
|
"outputSchema",
|
|
39409
39502
|
"outputSchemaMode",
|
|
39410
39503
|
"annotations"
|
|
39411
|
-
],
|
|
39504
|
+
], path28, issues);
|
|
39412
39505
|
if (value.resourceId !== resourceId) {
|
|
39413
|
-
issues.push(issue2(`${
|
|
39506
|
+
issues.push(issue2(`${path28}.resourceId`, "CARD_BINDING_CONTEXT_INVALID", "tool resourceId must match candidate"));
|
|
39414
39507
|
}
|
|
39415
39508
|
if (typeof value.toolName !== "string" || !value.toolName.trim()) {
|
|
39416
|
-
issues.push(issue2(`${
|
|
39509
|
+
issues.push(issue2(`${path28}.toolName`, "CARD_BINDING_CONTEXT_INVALID", "toolName is required"));
|
|
39417
39510
|
}
|
|
39418
|
-
issues.push(...getJsonSchemaIssues(value.inputSchema, `${
|
|
39511
|
+
issues.push(...getJsonSchemaIssues(value.inputSchema, `${path28}.inputSchema`));
|
|
39419
39512
|
if (value.outputSchemaMode !== void 0 && value.outputSchemaMode !== "declared" && value.outputSchemaMode !== "opaque") {
|
|
39420
|
-
issues.push(issue2(`${
|
|
39513
|
+
issues.push(issue2(`${path28}.outputSchemaMode`, "CARD_BINDING_CONTEXT_INVALID", "outputSchemaMode must be declared or opaque"));
|
|
39421
39514
|
}
|
|
39422
39515
|
}
|
|
39423
39516
|
function normalizeBindingContext(context) {
|
|
@@ -39438,16 +39531,16 @@ function normalizeBindingContext(context) {
|
|
|
39438
39531
|
});
|
|
39439
39532
|
return cloned;
|
|
39440
39533
|
}
|
|
39441
|
-
function validatePreferences(value,
|
|
39534
|
+
function validatePreferences(value, path28, issues) {
|
|
39442
39535
|
if (value === void 0)
|
|
39443
39536
|
return;
|
|
39444
39537
|
if (!Array.isArray(value) || value.length > 512) {
|
|
39445
|
-
issues.push(issue2(
|
|
39538
|
+
issues.push(issue2(path28, "CARD_BINDING_CONTEXT_INVALID", "preferredTools must be an array"));
|
|
39446
39539
|
return;
|
|
39447
39540
|
}
|
|
39448
39541
|
const fields = /* @__PURE__ */ new Set();
|
|
39449
39542
|
value.forEach((preference, index) => {
|
|
39450
|
-
const itemPath = `${
|
|
39543
|
+
const itemPath = `${path28}[${index}]`;
|
|
39451
39544
|
if (!isPlainRecord(preference)) {
|
|
39452
39545
|
issues.push(issue2(itemPath, "CARD_BINDING_CONTEXT_INVALID", "preference must be an object"));
|
|
39453
39546
|
return;
|
|
@@ -39467,14 +39560,14 @@ function validatePreferences(value, path26, issues) {
|
|
|
39467
39560
|
fields.add(preference.fieldId);
|
|
39468
39561
|
});
|
|
39469
39562
|
}
|
|
39470
|
-
function validateInputBindings(value,
|
|
39563
|
+
function validateInputBindings(value, path28, issues) {
|
|
39471
39564
|
if (!Array.isArray(value) || value.length > 64) {
|
|
39472
|
-
issues.push(issue2(
|
|
39565
|
+
issues.push(issue2(path28, "CARD_BINDING_INVALID", "inputBindings must be an array with at most 64 items"));
|
|
39473
39566
|
return;
|
|
39474
39567
|
}
|
|
39475
39568
|
const inputs = /* @__PURE__ */ new Set();
|
|
39476
39569
|
value.forEach((binding, index) => {
|
|
39477
|
-
const itemPath = `${
|
|
39570
|
+
const itemPath = `${path28}[${index}]`;
|
|
39478
39571
|
if (!isPlainRecord(binding)) {
|
|
39479
39572
|
issues.push(issue2(itemPath, "CARD_BINDING_INVALID", "input binding must be an object"));
|
|
39480
39573
|
return;
|
|
@@ -39505,18 +39598,18 @@ function validateInputBindings(value, path26, issues) {
|
|
|
39505
39598
|
}
|
|
39506
39599
|
});
|
|
39507
39600
|
}
|
|
39508
|
-
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings,
|
|
39601
|
+
function validateRequiredToolInputs(toolSchema, presentationSchema, bindings, path28, issues) {
|
|
39509
39602
|
const byInput = new Map(bindings.map((binding) => [binding.inputPath, binding]));
|
|
39510
39603
|
for (const input of requiredLeafInputs(toolSchema)) {
|
|
39511
39604
|
const binding = byInput.get(input.path);
|
|
39512
39605
|
if (!binding) {
|
|
39513
|
-
issues.push(issue2(
|
|
39606
|
+
issues.push(issue2(path28, "CARD_BINDING_INCOMPLETE", `required Tool input ${input.path} is not bound`));
|
|
39514
39607
|
continue;
|
|
39515
39608
|
}
|
|
39516
39609
|
if (binding.source.kind === "invocation") {
|
|
39517
39610
|
const source = getJsonSchemaAtDataPointer(presentationSchema, binding.source.path);
|
|
39518
39611
|
if (!source || !areJsonSchemaTypesCompatible(source.type, input.schema.type)) {
|
|
39519
|
-
issues.push(issue2(
|
|
39612
|
+
issues.push(issue2(path28, "CARD_BINDING_INVALID", `invocation source ${binding.source.path} is incompatible with ${input.path}`));
|
|
39520
39613
|
}
|
|
39521
39614
|
}
|
|
39522
39615
|
}
|
|
@@ -39528,11 +39621,11 @@ function requiredLeafInputs(schema2, basePath = "", parentRequired = true) {
|
|
|
39528
39621
|
return Object.entries(schema2.properties).flatMap(([name, child]) => {
|
|
39529
39622
|
if (!isPlainRecord(child))
|
|
39530
39623
|
return [];
|
|
39531
|
-
const
|
|
39624
|
+
const path28 = `${basePath}/${name.replace(/~/gu, "~0").replace(/\//gu, "~1")}`;
|
|
39532
39625
|
const isRequired = parentRequired && required2.has(name);
|
|
39533
39626
|
if (child.type === "object")
|
|
39534
|
-
return requiredLeafInputs(child,
|
|
39535
|
-
return isRequired ? [{ path:
|
|
39627
|
+
return requiredLeafInputs(child, path28, isRequired);
|
|
39628
|
+
return isRequired ? [{ path: path28, schema: child }] : [];
|
|
39536
39629
|
});
|
|
39537
39630
|
}
|
|
39538
39631
|
function validateConsistencyGroups(fields, bindings, issues, selectedFields) {
|
|
@@ -39893,16 +39986,16 @@ var A2UI_V4_COMPONENT_CATALOG = Object.freeze({
|
|
|
39893
39986
|
}
|
|
39894
39987
|
}
|
|
39895
39988
|
});
|
|
39896
|
-
function getA2UIV4ProtocolIssues(value,
|
|
39989
|
+
function getA2UIV4ProtocolIssues(value, path28 = "card") {
|
|
39897
39990
|
const issues = [];
|
|
39898
39991
|
if (!Array.isArray(value) || value.length === 0)
|
|
39899
39992
|
return [
|
|
39900
|
-
issue2(
|
|
39993
|
+
issue2(path28, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array")
|
|
39901
39994
|
];
|
|
39902
39995
|
const surfaces = /* @__PURE__ */ new Map();
|
|
39903
39996
|
const createdSurfaces = /* @__PURE__ */ new Set();
|
|
39904
39997
|
for (const [messageIndex, message] of value.entries()) {
|
|
39905
|
-
const messagePath = `${
|
|
39998
|
+
const messagePath = `${path28}[${messageIndex}]`;
|
|
39906
39999
|
if (!isPlainRecord(message) || message.version !== "0.9" || !Array.isArray(message.datas)) {
|
|
39907
40000
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "V4 messages require version 0.9 and a datas array"));
|
|
39908
40001
|
continue;
|
|
@@ -39956,9 +40049,9 @@ function getA2UIV4ProtocolIssues(value, path26 = "card") {
|
|
|
39956
40049
|
}
|
|
39957
40050
|
surfaces.forEach((_components, surfaceId) => {
|
|
39958
40051
|
if (!createdSurfaces.has(surfaceId))
|
|
39959
|
-
issues.push(issue2(`${
|
|
40052
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}`, "MISSING_CREATE_SURFACE", "every V4 surface must declare createSurface with the V4 catalog"));
|
|
39960
40053
|
});
|
|
39961
|
-
validateReferences(surfaces,
|
|
40054
|
+
validateReferences(surfaces, path28, issues);
|
|
39962
40055
|
return issues;
|
|
39963
40056
|
}
|
|
39964
40057
|
function validateV4Component(component, componentPath, issues) {
|
|
@@ -40001,15 +40094,15 @@ function validateV4Component(component, componentPath, issues) {
|
|
|
40001
40094
|
if (component.action !== void 0)
|
|
40002
40095
|
validateAction(component.action, `${componentPath}.action`, issues, 0);
|
|
40003
40096
|
}
|
|
40004
|
-
function validateComponents(payload,
|
|
40097
|
+
function validateComponents(payload, path28, surfaces, issues) {
|
|
40005
40098
|
if (!Array.isArray(payload.components)) {
|
|
40006
|
-
issues.push(issue2(`${
|
|
40099
|
+
issues.push(issue2(`${path28}.updateComponents.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
40007
40100
|
return;
|
|
40008
40101
|
}
|
|
40009
40102
|
const surface = surfaces.get(payload.surfaceId) ?? /* @__PURE__ */ new Map();
|
|
40010
40103
|
surfaces.set(payload.surfaceId, surface);
|
|
40011
40104
|
payload.components.forEach((component, index) => {
|
|
40012
|
-
const componentPath = `${
|
|
40105
|
+
const componentPath = `${path28}.updateComponents.components[${index}]`;
|
|
40013
40106
|
if (!isPlainRecord(component) || !isSafeIdentifier(component.id) || typeof component.component !== "string") {
|
|
40014
40107
|
issues.push(issue2(componentPath, "INVALID_A2UI_COMPONENT", "component requires a safe id and component name"));
|
|
40015
40108
|
return;
|
|
@@ -40020,23 +40113,23 @@ function validateComponents(payload, path26, surfaces, issues) {
|
|
|
40020
40113
|
validateV4Component(component, componentPath, issues);
|
|
40021
40114
|
});
|
|
40022
40115
|
}
|
|
40023
|
-
function validateProperty(value, schema2,
|
|
40116
|
+
function validateProperty(value, schema2, path28, issues, propertyName) {
|
|
40024
40117
|
if (schema2.kind === "binding") {
|
|
40025
40118
|
const stringOnly = propertyName === "label" || propertyName === "src" || propertyName === "alt" || propertyName === "image";
|
|
40026
40119
|
const literalValid = typeof value === "string" || !stringOnly && typeof value === "number" && Number.isFinite(value);
|
|
40027
40120
|
if (!literalValid && !isDisplayBinding(value, stringOnly))
|
|
40028
|
-
issues.push(issue2(
|
|
40121
|
+
issues.push(issue2(path28, "INVALID_DISPLAY_VALUE", `display value must be ${stringOnly ? "a string" : "a string or finite number"}, or a compatible display binding`));
|
|
40029
40122
|
return;
|
|
40030
40123
|
}
|
|
40031
40124
|
if (schema2.kind === "child") {
|
|
40032
40125
|
if (!isSafeIdentifier(value))
|
|
40033
|
-
issues.push(issue2(
|
|
40126
|
+
issues.push(issue2(path28, "INVALID_CHILD", "child must be a safe component id"));
|
|
40034
40127
|
return;
|
|
40035
40128
|
}
|
|
40036
40129
|
if (schema2.kind === "children") {
|
|
40037
40130
|
const valid = Array.isArray(value) ? value.every(isSafeIdentifier) : isPlainRecord(value) && Object.keys(value).length === 2 && isSafeIdentifier(value.componentId) && typeof value.path === "string" && isSafePath(value.path);
|
|
40038
40131
|
if (!valid)
|
|
40039
|
-
issues.push(issue2(
|
|
40132
|
+
issues.push(issue2(path28, "INVALID_CHILDREN", "children must be component ids or one dynamic children binding"));
|
|
40040
40133
|
return;
|
|
40041
40134
|
}
|
|
40042
40135
|
if (schema2.kind === "action")
|
|
@@ -40044,11 +40137,11 @@ function validateProperty(value, schema2, path26, issues, propertyName) {
|
|
|
40044
40137
|
if (schema2.kind === "options" || schema2.kind === "format")
|
|
40045
40138
|
return;
|
|
40046
40139
|
if (schema2.kind === "boolean" && typeof value !== "boolean")
|
|
40047
|
-
issues.push(issue2(
|
|
40140
|
+
issues.push(issue2(path28, "INVALID_COMPONENT_PROP_TYPE", "value must be boolean"));
|
|
40048
40141
|
if (schema2.kind === "number" && !Number.isFinite(value))
|
|
40049
|
-
issues.push(issue2(
|
|
40142
|
+
issues.push(issue2(path28, "INVALID_COMPONENT_PROP_VALUE", "value must be a finite number"));
|
|
40050
40143
|
if (schema2.kind === "string" && typeof value !== "string")
|
|
40051
|
-
issues.push(issue2(
|
|
40144
|
+
issues.push(issue2(path28, "INVALID_COMPONENT_PROP_VALUE", "value must be a string"));
|
|
40052
40145
|
}
|
|
40053
40146
|
function isDisplayBinding(value, stringOnly = false) {
|
|
40054
40147
|
if (!isPlainRecord(value) || typeof value.path !== "string" || !isSafePath(value.path))
|
|
@@ -40062,89 +40155,89 @@ function isStrictBinding(value) {
|
|
|
40062
40155
|
function isSafePath(value) {
|
|
40063
40156
|
return (value === "/" || value.startsWith("/") || value.startsWith("./")) && !value.split("/").some((part) => ["__proto__", "constructor", "prototype"].includes(part));
|
|
40064
40157
|
}
|
|
40065
|
-
function validateAction(value,
|
|
40158
|
+
function validateAction(value, path28, issues, depth) {
|
|
40066
40159
|
if (!isPlainRecord(value) || depth > 4) {
|
|
40067
|
-
issues.push(issue2(
|
|
40160
|
+
issues.push(issue2(path28, "INVALID_ACTION", "action must be an object with at most four nested selects"));
|
|
40068
40161
|
return;
|
|
40069
40162
|
}
|
|
40070
40163
|
const branches = ["event", "function", "local", "client", "select"].filter((key) => key in value);
|
|
40071
40164
|
if (branches.length !== 1 || Object.keys(value).length !== 1) {
|
|
40072
|
-
issues.push(issue2(
|
|
40165
|
+
issues.push(issue2(path28, "INVALID_ACTION", "action must contain exactly one branch"));
|
|
40073
40166
|
return;
|
|
40074
40167
|
}
|
|
40075
40168
|
const branch = branches[0];
|
|
40076
40169
|
const body = value[branch];
|
|
40077
40170
|
if (!isPlainRecord(body))
|
|
40078
|
-
return void issues.push(issue2(`${
|
|
40171
|
+
return void issues.push(issue2(`${path28}.${branch}`, "INVALID_ACTION", `${branch} must be an object`));
|
|
40079
40172
|
if (branch === "event") {
|
|
40080
|
-
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${
|
|
40173
|
+
rejectUnknownKeys(body, ["name", "context", "x2-user-message", "target"], `${path28}.event`, issues);
|
|
40081
40174
|
if (typeof body.name !== "string" || !/^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/.test(body.name) || body.name.length > 96)
|
|
40082
|
-
issues.push(issue2(`${
|
|
40175
|
+
issues.push(issue2(`${path28}.event.name`, "INVALID_ACTION_NAME", "event name is invalid"));
|
|
40083
40176
|
if (body.context !== void 0 && !isPlainRecord(body.context))
|
|
40084
|
-
issues.push(issue2(`${
|
|
40177
|
+
issues.push(issue2(`${path28}.event.context`, "INVALID_ACTION_CONTEXT", "event context must be an object"));
|
|
40085
40178
|
else if (body.context !== void 0)
|
|
40086
|
-
validateActionDynamicValue(body.context, `${
|
|
40179
|
+
validateActionDynamicValue(body.context, `${path28}.event.context`, issues);
|
|
40087
40180
|
if (body["x2-user-message"] !== void 0 && typeof body["x2-user-message"] !== "string" && !isStrictBinding(body["x2-user-message"]))
|
|
40088
|
-
issues.push(issue2(`${
|
|
40181
|
+
issues.push(issue2(`${path28}.event.x2-user-message`, "INVALID_ACTION_CONTEXT", "x2-user-message must be a string or strict binding"));
|
|
40089
40182
|
if (body.target !== void 0)
|
|
40090
|
-
validateOverlayTarget(body.target, `${
|
|
40183
|
+
validateOverlayTarget(body.target, `${path28}.event.target`, issues);
|
|
40091
40184
|
} else if (branch === "function") {
|
|
40092
|
-
rejectUnknownKeys(body, ["ref"], `${
|
|
40185
|
+
rejectUnknownKeys(body, ["ref"], `${path28}.function`, issues);
|
|
40093
40186
|
if (!isFunctionActionRef(body.ref))
|
|
40094
|
-
issues.push(issue2(`${
|
|
40187
|
+
issues.push(issue2(`${path28}.function.ref`, "INVALID_FUNCTION_ACTION_REF", "function ref must be a dot-separated identifier up to 128 characters"));
|
|
40095
40188
|
} else if (branch === "local") {
|
|
40096
|
-
rejectUnknownKeys(body, ["name", "path", "value"], `${
|
|
40189
|
+
rejectUnknownKeys(body, ["name", "path", "value"], `${path28}.local`, issues);
|
|
40097
40190
|
if (body.name !== "data.set" || typeof body.path !== "string" || !isSafePath(body.path) || !Object.prototype.hasOwnProperty.call(body, "value"))
|
|
40098
|
-
issues.push(issue2(`${
|
|
40191
|
+
issues.push(issue2(`${path28}.local`, "INVALID_LOCAL_ACTION", "local action must be data.set with a safe path and value"));
|
|
40099
40192
|
else
|
|
40100
|
-
validateActionDynamicValue(body.value, `${
|
|
40193
|
+
validateActionDynamicValue(body.value, `${path28}.local.value`, issues);
|
|
40101
40194
|
} else if (branch === "client") {
|
|
40102
|
-
validateClientAction(body, `${
|
|
40195
|
+
validateClientAction(body, `${path28}.client`, issues);
|
|
40103
40196
|
} else {
|
|
40104
|
-
rejectUnknownKeys(body, ["value", "cases", "default"], `${
|
|
40197
|
+
rejectUnknownKeys(body, ["value", "cases", "default"], `${path28}.select`, issues);
|
|
40105
40198
|
if (!isStrictBinding(body.value) || !Array.isArray(body.cases) || body.cases.length < 1 || body.cases.length > 16)
|
|
40106
|
-
return void issues.push(issue2(`${
|
|
40199
|
+
return void issues.push(issue2(`${path28}.select`, "INVALID_SELECT_ACTION", "select requires a strict binding and 1-16 cases"));
|
|
40107
40200
|
const seen = /* @__PURE__ */ new Set();
|
|
40108
40201
|
body.cases.forEach((entry, index) => {
|
|
40109
40202
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key2) => key2 !== "equals" && key2 !== "action") || !["string", "number", "boolean"].includes(typeof entry.equals) && entry.equals !== null || !Object.prototype.hasOwnProperty.call(entry, "action"))
|
|
40110
|
-
return void issues.push(issue2(`${
|
|
40203
|
+
return void issues.push(issue2(`${path28}.select.cases[${index}]`, "INVALID_SELECT_CASE", "case requires only a primitive equals and action"));
|
|
40111
40204
|
const key = JSON.stringify([typeof entry.equals, entry.equals]);
|
|
40112
40205
|
if (seen.has(key))
|
|
40113
|
-
issues.push(issue2(`${
|
|
40206
|
+
issues.push(issue2(`${path28}.select.cases[${index}].equals`, "DUPLICATE_SELECT_CASE", "select case values must be unique"));
|
|
40114
40207
|
seen.add(key);
|
|
40115
|
-
validateAction(entry.action, `${
|
|
40208
|
+
validateAction(entry.action, `${path28}.select.cases[${index}].action`, issues, depth + 1);
|
|
40116
40209
|
});
|
|
40117
40210
|
if (body.default !== void 0)
|
|
40118
|
-
validateAction(body.default, `${
|
|
40211
|
+
validateAction(body.default, `${path28}.select.default`, issues, depth + 1);
|
|
40119
40212
|
}
|
|
40120
40213
|
}
|
|
40121
40214
|
function isFunctionActionRef(value) {
|
|
40122
40215
|
return typeof value === "string" && value.length <= 128 && /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)*$/u.test(value);
|
|
40123
40216
|
}
|
|
40124
|
-
function validateClientAction(body,
|
|
40125
|
-
rejectUnknownKeys(body, ["name", "context"],
|
|
40217
|
+
function validateClientAction(body, path28, issues) {
|
|
40218
|
+
rejectUnknownKeys(body, ["name", "context"], path28, issues);
|
|
40126
40219
|
if (body.name === "ui.overlay.close") {
|
|
40127
40220
|
if (body.context !== void 0)
|
|
40128
|
-
issues.push(issue2(`${
|
|
40221
|
+
issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.overlay.close does not accept context"));
|
|
40129
40222
|
return;
|
|
40130
40223
|
}
|
|
40131
40224
|
if (body.name === "ui.surface.open") {
|
|
40132
40225
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.surfaceId !== "string")
|
|
40133
|
-
issues.push(issue2(`${
|
|
40226
|
+
issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", "ui.surface.open requires context.surfaceId"));
|
|
40134
40227
|
return;
|
|
40135
40228
|
}
|
|
40136
40229
|
if (body.name === "ui.page.open" || body.name === "ui.miniprogram.embed") {
|
|
40137
40230
|
if (!isPlainRecord(body.context) || Object.keys(body.context).length !== 1 || typeof body.context.url !== "string" && !isStrictBinding(body.context.url))
|
|
40138
|
-
issues.push(issue2(`${
|
|
40231
|
+
issues.push(issue2(`${path28}.context`, "INVALID_CLIENT_ACTION_CONTEXT", `${body.name} requires one literal or bound URL`));
|
|
40139
40232
|
else if (typeof body.context.url === "string" && !isSafePageUrl(body.context.url, body.name))
|
|
40140
|
-
issues.push(issue2(`${
|
|
40233
|
+
issues.push(issue2(`${path28}.context.url`, "INVALID_PAGE_URL", body.name === "ui.miniprogram.embed" ? "ui.miniprogram.embed URL must include appId parameter" : "ui.page.open URL must use https or the approved Alipay scheme"));
|
|
40141
40234
|
return;
|
|
40142
40235
|
}
|
|
40143
|
-
issues.push(issue2(`${
|
|
40236
|
+
issues.push(issue2(`${path28}.name`, "UNSUPPORTED_CLIENT_ACTION", `unsupported client action ${String(body.name)}`));
|
|
40144
40237
|
}
|
|
40145
|
-
function validateActionDynamicValue(value,
|
|
40238
|
+
function validateActionDynamicValue(value, path28, issues) {
|
|
40146
40239
|
if (Array.isArray(value)) {
|
|
40147
|
-
value.forEach((entry, index) => validateActionDynamicValue(entry, `${
|
|
40240
|
+
value.forEach((entry, index) => validateActionDynamicValue(entry, `${path28}[${index}]`, issues));
|
|
40148
40241
|
return;
|
|
40149
40242
|
}
|
|
40150
40243
|
if (!isPlainRecord(value))
|
|
@@ -40152,96 +40245,96 @@ function validateActionDynamicValue(value, path26, issues) {
|
|
|
40152
40245
|
const keys2 = Object.keys(value);
|
|
40153
40246
|
if (keys2.includes("path") && keys2.every((key) => key === "path" || key === "fallback")) {
|
|
40154
40247
|
if (!isStrictBinding(value))
|
|
40155
|
-
issues.push(issue2(
|
|
40248
|
+
issues.push(issue2(path28, "INVALID_ACTION_BINDING", "action values require a strict binding without fallback"));
|
|
40156
40249
|
return;
|
|
40157
40250
|
}
|
|
40158
|
-
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${
|
|
40251
|
+
Object.entries(value).forEach(([key, entry]) => validateActionDynamicValue(entry, `${path28}.${key}`, issues));
|
|
40159
40252
|
}
|
|
40160
|
-
function validateOverlayTarget(value,
|
|
40253
|
+
function validateOverlayTarget(value, path28, issues) {
|
|
40161
40254
|
if (!isPlainRecord(value) || value.type !== "overlay" || !isPlainRecord(value.presentation) || value.presentation.kind !== "bottom-sheet")
|
|
40162
|
-
issues.push(issue2(
|
|
40255
|
+
issues.push(issue2(path28, "INVALID_EVENT_TARGET", "event target must be an overlay bottom-sheet presentation"));
|
|
40163
40256
|
}
|
|
40164
|
-
function validateOptions(value,
|
|
40257
|
+
function validateOptions(value, path28, issues) {
|
|
40165
40258
|
if (isStrictBinding(value))
|
|
40166
40259
|
return;
|
|
40167
40260
|
if (!Array.isArray(value) || value.length === 0)
|
|
40168
|
-
return void issues.push(issue2(
|
|
40261
|
+
return void issues.push(issue2(path28, "INVALID_OPTIONS", "options must be a non-empty array"));
|
|
40169
40262
|
const seen = /* @__PURE__ */ new Set();
|
|
40170
40263
|
value.forEach((entry, index) => {
|
|
40171
40264
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "label" && key !== "value") || typeof entry.label !== "string" || !entry.label || typeof entry.value !== "string" || !entry.value)
|
|
40172
|
-
issues.push(issue2(`${
|
|
40265
|
+
issues.push(issue2(`${path28}[${index}]`, "INVALID_OPTION", "option requires only non-empty label and value"));
|
|
40173
40266
|
else if (seen.has(entry.value))
|
|
40174
|
-
issues.push(issue2(`${
|
|
40267
|
+
issues.push(issue2(`${path28}[${index}].value`, "DUPLICATE_OPTION_VALUE", "option values must be unique"));
|
|
40175
40268
|
else
|
|
40176
40269
|
seen.add(entry.value);
|
|
40177
40270
|
});
|
|
40178
40271
|
}
|
|
40179
|
-
function validateTextField(component,
|
|
40272
|
+
function validateTextField(component, path28, issues) {
|
|
40180
40273
|
if (!isStrictBinding(component.value))
|
|
40181
|
-
issues.push(issue2(`${
|
|
40274
|
+
issues.push(issue2(`${path28}.value`, "INPUT_REQUIRES_BINDING", "TextField.value must be a strict writable binding"));
|
|
40182
40275
|
if (component["x2-limit"] !== void 0 && (!Number.isInteger(component["x2-limit"]) || Number(component["x2-limit"]) < 1 || Number(component["x2-limit"]) > 1e4))
|
|
40183
|
-
issues.push(issue2(`${
|
|
40276
|
+
issues.push(issue2(`${path28}.x2-limit`, "INVALID_TEXT_LIMIT", "x2-limit must be an integer from 1 to 10000"));
|
|
40184
40277
|
if (typeof component.validationRegexp === "string") {
|
|
40185
40278
|
if (component.validationRegexp.length > 512)
|
|
40186
|
-
issues.push(issue2(`${
|
|
40279
|
+
issues.push(issue2(`${path28}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is too long"));
|
|
40187
40280
|
else
|
|
40188
40281
|
try {
|
|
40189
40282
|
RegExp(component.validationRegexp);
|
|
40190
40283
|
} catch {
|
|
40191
|
-
issues.push(issue2(`${
|
|
40284
|
+
issues.push(issue2(`${path28}.validationRegexp`, "INVALID_VALIDATION_REGEXP", "validationRegexp is invalid"));
|
|
40192
40285
|
}
|
|
40193
40286
|
}
|
|
40194
40287
|
}
|
|
40195
|
-
function validateStepper(component,
|
|
40288
|
+
function validateStepper(component, path28, issues) {
|
|
40196
40289
|
if (!isStrictBinding(component.value))
|
|
40197
|
-
issues.push(issue2(`${
|
|
40290
|
+
issues.push(issue2(`${path28}.value`, "INPUT_REQUIRES_BINDING", "Stepper.value must be a strict writable binding"));
|
|
40198
40291
|
if (component.step !== void 0 && (!Number.isFinite(component.step) || Number(component.step) <= 0))
|
|
40199
|
-
issues.push(issue2(`${
|
|
40292
|
+
issues.push(issue2(`${path28}.step`, "INVALID_STEPPER_RANGE", "step must be greater than zero"));
|
|
40200
40293
|
if (Number.isFinite(component.min) && Number.isFinite(component.max) && Number(component.min) > Number(component.max))
|
|
40201
|
-
issues.push(issue2(`${
|
|
40294
|
+
issues.push(issue2(`${path28}`, "INVALID_STEPPER_RANGE", "min must not exceed max"));
|
|
40202
40295
|
}
|
|
40203
|
-
function validateChecks(value,
|
|
40296
|
+
function validateChecks(value, path28, issues) {
|
|
40204
40297
|
if (!Array.isArray(value))
|
|
40205
|
-
return void issues.push(issue2(
|
|
40298
|
+
return void issues.push(issue2(path28, "INVALID_CHECKS", "checks must be an array"));
|
|
40206
40299
|
value.forEach((entry, index) => {
|
|
40207
40300
|
if (!isPlainRecord(entry) || Object.keys(entry).some((key) => key !== "required" && key !== "value" && key !== "message") || entry.required !== true || !isStrictBinding(entry.value) || entry.message !== void 0 && typeof entry.message !== "string") {
|
|
40208
|
-
issues.push(issue2(`${
|
|
40301
|
+
issues.push(issue2(`${path28}[${index}]`, "INVALID_CHECK", "check must be an implemented required check with a strict binding"));
|
|
40209
40302
|
}
|
|
40210
40303
|
});
|
|
40211
40304
|
}
|
|
40212
|
-
function validateOverflow(component,
|
|
40305
|
+
function validateOverflow(component, path28, issues) {
|
|
40213
40306
|
const value = component["x2-overflow"];
|
|
40214
40307
|
const children = component.children;
|
|
40215
40308
|
if (!isPlainRecord(children) || !isPlainRecord(value)) {
|
|
40216
|
-
issues.push(issue2(`${
|
|
40309
|
+
issues.push(issue2(`${path28}.x2-overflow`, "INVALID_OVERFLOW", "x2-overflow requires dynamic children and an object value"));
|
|
40217
40310
|
return;
|
|
40218
40311
|
}
|
|
40219
|
-
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${
|
|
40312
|
+
rejectUnknownKeys(value, ["mode", "previewCount", "trigger", "overlay"], `${path28}.x2-overflow`, issues);
|
|
40220
40313
|
if (value.mode !== "overlay-all" || !Number.isInteger(value.previewCount) || Number(value.previewCount) < 0 || Number(value.previewCount) > 100) {
|
|
40221
|
-
issues.push(issue2(`${
|
|
40314
|
+
issues.push(issue2(`${path28}.x2-overflow`, "INVALID_OVERFLOW", "overlay-all requires an integer previewCount from 0 to 100"));
|
|
40222
40315
|
}
|
|
40223
40316
|
if (!isPlainRecord(value.trigger)) {
|
|
40224
|
-
issues.push(issue2(`${
|
|
40317
|
+
issues.push(issue2(`${path28}.x2-overflow.trigger`, "INVALID_OVERFLOW_TRIGGER", "trigger must contain display text"));
|
|
40225
40318
|
} else {
|
|
40226
|
-
rejectUnknownKeys(value.trigger, ["text"], `${
|
|
40319
|
+
rejectUnknownKeys(value.trigger, ["text"], `${path28}.x2-overflow.trigger`, issues);
|
|
40227
40320
|
if (!isDisplayBinding(value.trigger.text, true) && typeof value.trigger.text !== "string") {
|
|
40228
|
-
issues.push(issue2(`${
|
|
40321
|
+
issues.push(issue2(`${path28}.x2-overflow.trigger.text`, "INVALID_OVERFLOW_TRIGGER", "trigger.text must be a string or display binding"));
|
|
40229
40322
|
}
|
|
40230
40323
|
}
|
|
40231
40324
|
if (!isPlainRecord(value.overlay)) {
|
|
40232
|
-
issues.push(issue2(`${
|
|
40325
|
+
issues.push(issue2(`${path28}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet presentation"));
|
|
40233
40326
|
} else {
|
|
40234
|
-
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${
|
|
40327
|
+
rejectUnknownKeys(value.overlay, ["kind", "title", "size"], `${path28}.x2-overflow.overlay`, issues);
|
|
40235
40328
|
if (value.overlay.kind !== "bottom-sheet" || value.overlay.title !== void 0 && typeof value.overlay.title !== "string" || value.overlay.size !== void 0 && !["medium", "large", "full"].includes(String(value.overlay.size))) {
|
|
40236
|
-
issues.push(issue2(`${
|
|
40329
|
+
issues.push(issue2(`${path28}.x2-overflow.overlay`, "INVALID_OVERFLOW_PRESENTATION", "overlay must be a bottom-sheet with an optional string title and supported size"));
|
|
40237
40330
|
}
|
|
40238
40331
|
}
|
|
40239
40332
|
}
|
|
40240
|
-
function rejectUnknownKeys(value, allowed,
|
|
40333
|
+
function rejectUnknownKeys(value, allowed, path28, issues) {
|
|
40241
40334
|
const allowedKeys = new Set(allowed);
|
|
40242
40335
|
Object.keys(value).forEach((key) => {
|
|
40243
40336
|
if (!allowedKeys.has(key))
|
|
40244
|
-
issues.push(issue2(`${
|
|
40337
|
+
issues.push(issue2(`${path28}.${key}`, "UNKNOWN_PROTOCOL_FIELD", `unknown field ${key}`));
|
|
40245
40338
|
});
|
|
40246
40339
|
}
|
|
40247
40340
|
function isSafePageUrl(value, actionName) {
|
|
@@ -40256,23 +40349,23 @@ function isSafePageUrl(value, actionName) {
|
|
|
40256
40349
|
}
|
|
40257
40350
|
return value.startsWith("https://") || value.startsWith("alipays://");
|
|
40258
40351
|
}
|
|
40259
|
-
function validateReferences(surfaces,
|
|
40352
|
+
function validateReferences(surfaces, path28, issues) {
|
|
40260
40353
|
for (const [surfaceId, components] of surfaces) {
|
|
40261
40354
|
if (!components.has("root"))
|
|
40262
|
-
issues.push(issue2(`${
|
|
40355
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}`, "MISSING_ROOT_COMPONENT", "surface must define root"));
|
|
40263
40356
|
const edges = /* @__PURE__ */ new Map();
|
|
40264
40357
|
for (const [id2, component] of components) {
|
|
40265
40358
|
const refs = getComponentReferences(component);
|
|
40266
40359
|
edges.set(id2, refs);
|
|
40267
40360
|
refs.forEach((ref) => {
|
|
40268
40361
|
if (!components.has(ref))
|
|
40269
|
-
issues.push(issue2(`${
|
|
40362
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.${component.child !== void 0 ? "child" : "children"}`, "MISSING_COMPONENT_REFERENCE", `component ${ref} does not exist`));
|
|
40270
40363
|
});
|
|
40271
40364
|
if ((component.component === "Button" || component.component === "Card" && component.action !== void 0) && refs.some((ref) => hasInteractiveDescendant(ref, components, /* @__PURE__ */ new Set())))
|
|
40272
|
-
issues.push(issue2(`${
|
|
40365
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.${component.child !== void 0 ? "child" : "children"}`, "NESTED_INTERACTION", "action components cannot contain interactive descendants"));
|
|
40273
40366
|
collectSurfaceOpenReferences(component.action).forEach((targetSurfaceId) => {
|
|
40274
40367
|
if (!surfaces.has(targetSurfaceId))
|
|
40275
|
-
issues.push(issue2(`${
|
|
40368
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.action`, "MISSING_SURFACE_REFERENCE", `surface ${targetSurfaceId} does not exist`));
|
|
40276
40369
|
});
|
|
40277
40370
|
}
|
|
40278
40371
|
components.forEach((component, id2) => {
|
|
@@ -40280,14 +40373,14 @@ function validateReferences(surfaces, path26, issues) {
|
|
|
40280
40373
|
return;
|
|
40281
40374
|
const parents = [...components.values()].filter((parent) => getComponentReferences(parent).includes(id2));
|
|
40282
40375
|
if (id2 === "root" || parents.length === 0 || parents.some((parent) => parent.component !== "Row" && parent.component !== "Column")) {
|
|
40283
|
-
issues.push(issue2(`${
|
|
40376
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}.grow`, "INVALID_LAYOUT_PARENT", "grow requires a direct Row or Column parent in every occurrence"));
|
|
40284
40377
|
}
|
|
40285
40378
|
});
|
|
40286
40379
|
const visiting = /* @__PURE__ */ new Set();
|
|
40287
40380
|
const visited = /* @__PURE__ */ new Set();
|
|
40288
40381
|
const walk = (id2) => {
|
|
40289
40382
|
if (visiting.has(id2))
|
|
40290
|
-
return void issues.push(issue2(`${
|
|
40383
|
+
return void issues.push(issue2(`${path28}.surfaces.${surfaceId}.components.${id2}`, "CIRCULAR_COMPONENT_REFERENCE", "component references must not contain a cycle"));
|
|
40291
40384
|
if (visited.has(id2))
|
|
40292
40385
|
return;
|
|
40293
40386
|
visiting.add(id2);
|
|
@@ -40416,29 +40509,29 @@ function getA2UICardDraftBundleIssues(value) {
|
|
|
40416
40509
|
}
|
|
40417
40510
|
return issues;
|
|
40418
40511
|
}
|
|
40419
|
-
function getPersistedV4ProtocolIssues(card,
|
|
40512
|
+
function getPersistedV4ProtocolIssues(card, path28) {
|
|
40420
40513
|
const issues = [];
|
|
40421
40514
|
if (card.length !== 1) {
|
|
40422
|
-
issues.push(issue2(
|
|
40515
|
+
issues.push(issue2(path28, "INVALID_PERSISTED_V4_MESSAGES", "V4 persisted cards must use exactly one message"));
|
|
40423
40516
|
}
|
|
40424
40517
|
const instructions = card.flatMap((message) => message.datas);
|
|
40425
40518
|
const creates = instructions.filter((instruction) => "createSurface" in instruction);
|
|
40426
40519
|
const updates = instructions.filter((instruction) => "updateComponents" in instruction);
|
|
40427
40520
|
if (creates.length < 1 || creates.length !== updates.length || instructions.length !== creates.length + updates.length) {
|
|
40428
|
-
issues.push(issue2(
|
|
40521
|
+
issues.push(issue2(path28, "INVALID_PERSISTED_V4_INSTRUCTIONS", "V4 persisted cards require one createSurface and one complete updateComponents per Surface"));
|
|
40429
40522
|
}
|
|
40430
40523
|
const createIds = creates.flatMap((instruction) => "createSurface" in instruction ? [instruction.createSurface.surfaceId] : []);
|
|
40431
40524
|
const updateIds = updates.flatMap((instruction) => "updateComponents" in instruction ? [instruction.updateComponents.surfaceId] : []);
|
|
40432
40525
|
for (const surfaceId of /* @__PURE__ */ new Set([...createIds, ...updateIds])) {
|
|
40433
40526
|
if (createIds.filter((id2) => id2 === surfaceId).length !== 1 || updateIds.filter((id2) => id2 === surfaceId).length !== 1) {
|
|
40434
|
-
issues.push(issue2(`${
|
|
40527
|
+
issues.push(issue2(`${path28}.surfaces.${surfaceId}`, "SURFACE_INSTRUCTION_MISMATCH", "each persisted Surface requires exactly one create and one component update"));
|
|
40435
40528
|
}
|
|
40436
40529
|
}
|
|
40437
40530
|
return issues;
|
|
40438
40531
|
}
|
|
40439
|
-
function validateV4Fixture(value, fields,
|
|
40532
|
+
function validateV4Fixture(value, fields, path28, issues) {
|
|
40440
40533
|
if (!isPlainRecord(value)) {
|
|
40441
|
-
issues.push(issue2(
|
|
40534
|
+
issues.push(issue2(path28, "INVALID_FIXTURE", "fixture must be a JSON object"));
|
|
40442
40535
|
return;
|
|
40443
40536
|
}
|
|
40444
40537
|
for (const field of fields) {
|
|
@@ -40447,17 +40540,17 @@ function validateV4Fixture(value, fields, path26, issues) {
|
|
|
40447
40540
|
const resolved = getFixtureValue(value, field.path);
|
|
40448
40541
|
if (!resolved.found) {
|
|
40449
40542
|
if (field.required)
|
|
40450
|
-
issues.push(issue2(`${
|
|
40543
|
+
issues.push(issue2(`${path28}${field.path}`, "REQUIRED_FIXTURE_FIELD_MISSING", `fixture is missing required field ${field.fieldId}`));
|
|
40451
40544
|
continue;
|
|
40452
40545
|
}
|
|
40453
|
-
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${
|
|
40546
|
+
issues.push(...validateJsonSchemaValue2(field.valueSchema, resolved.value, `${path28}${field.path}`));
|
|
40454
40547
|
}
|
|
40455
40548
|
}
|
|
40456
|
-
function validateV4BindingContracts(card, occurrences, fields,
|
|
40549
|
+
function validateV4BindingContracts(card, occurrences, fields, path28, issues, dataModelSchema) {
|
|
40457
40550
|
const ordered = fields.slice().sort((left, right) => right.path.length - left.path.length);
|
|
40458
40551
|
for (const occurrence of occurrences) {
|
|
40459
40552
|
const field = ordered.find((candidate) => occurrence.canonicalPath === candidate.path || occurrence.canonicalPath.startsWith(`${candidate.path}/*/`) || occurrence.canonicalPath.startsWith(`${candidate.path}/`));
|
|
40460
|
-
const issuePath = `${
|
|
40553
|
+
const issuePath = `${path28}.surfaces.${occurrence.surfaceId ?? "unknown"}.components.${occurrence.componentId}.${occurrence.propertyPath}`;
|
|
40461
40554
|
if (!field && !dataModelSchema) {
|
|
40462
40555
|
issues.push(issue2(issuePath, "UNDECLARED_BINDING_PATH", `binding path ${occurrence.rawPath} is not declared by a manifest field`));
|
|
40463
40556
|
continue;
|
|
@@ -40665,14 +40758,14 @@ function getA2UICardResourceConfigV3Issues(value) {
|
|
|
40665
40758
|
}
|
|
40666
40759
|
return issues;
|
|
40667
40760
|
}
|
|
40668
|
-
function validateDataSources(value,
|
|
40761
|
+
function validateDataSources(value, path28, issues, options = {}) {
|
|
40669
40762
|
if (!Array.isArray(value)) {
|
|
40670
|
-
issues.push(issue2(
|
|
40763
|
+
issues.push(issue2(path28, "INVALID_DATA_SOURCES", "dataSources must be a non-empty array"));
|
|
40671
40764
|
return void 0;
|
|
40672
40765
|
}
|
|
40673
40766
|
const ids = /* @__PURE__ */ new Set();
|
|
40674
40767
|
value.forEach((candidate, index) => {
|
|
40675
|
-
const itemPath = `${
|
|
40768
|
+
const itemPath = `${path28}[${index}]`;
|
|
40676
40769
|
if (!isPlainRecord(candidate)) {
|
|
40677
40770
|
issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
|
|
40678
40771
|
return;
|
|
@@ -40710,7 +40803,7 @@ function validateDataSources(value, path26, issues, options = {}) {
|
|
|
40710
40803
|
for (const [index, source] of value.entries()) {
|
|
40711
40804
|
for (const dependency of source.dependsOn ?? []) {
|
|
40712
40805
|
if (!ids.has(dependency) || dependency === source.sourceId) {
|
|
40713
|
-
issues.push(issue2(`${
|
|
40806
|
+
issues.push(issue2(`${path28}[${index}].dependsOn`, "UNKNOWN_SOURCE_DEPENDENCY", `Unknown dependency ${dependency}`));
|
|
40714
40807
|
}
|
|
40715
40808
|
}
|
|
40716
40809
|
}
|
|
@@ -40729,29 +40822,29 @@ function validateDataSources(value, path26, issues, options = {}) {
|
|
|
40729
40822
|
return cyclic;
|
|
40730
40823
|
};
|
|
40731
40824
|
if ([...byId.keys()].some(visit)) {
|
|
40732
|
-
issues.push(issue2(
|
|
40825
|
+
issues.push(issue2(path28, "CYCLIC_SOURCE_DEPENDENCY", "data source dependencies must be acyclic"));
|
|
40733
40826
|
}
|
|
40734
40827
|
return value;
|
|
40735
40828
|
}
|
|
40736
|
-
function validateModelPipelineArguments(value, sources,
|
|
40829
|
+
function validateModelPipelineArguments(value, sources, path28, issues) {
|
|
40737
40830
|
sources.forEach((source, index) => {
|
|
40738
40831
|
if (isPlainRecord(source.fixedInput) && Object.keys(source.fixedInput).length || Array.isArray(source.inputBindings) && source.inputBindings.length) {
|
|
40739
|
-
issues.push(issue2(`${
|
|
40832
|
+
issues.push(issue2(`${path28}.dataSources[${index}]`, "MODEL_ARGUMENTS_CONFLICT", "model arguments cannot be combined with fixedInput or inputBindings"));
|
|
40740
40833
|
}
|
|
40741
40834
|
});
|
|
40742
40835
|
const expected = createA2UICardPipelineModelInputSchema(sources);
|
|
40743
40836
|
if (isJsonValue(value.presentationInputSchema) && stableJsonStringify(value.presentationInputSchema) !== stableJsonStringify(expected)) {
|
|
40744
|
-
issues.push(issue2(`${
|
|
40837
|
+
issues.push(issue2(`${path28}.presentationInputSchema`, "MODEL_ARGUMENT_SCHEMA_MISMATCH", "presentationInputSchema must match the configured MCP input schemas"));
|
|
40745
40838
|
}
|
|
40746
40839
|
}
|
|
40747
|
-
function validatePipelineDataSources(value,
|
|
40840
|
+
function validatePipelineDataSources(value, path28, issues) {
|
|
40748
40841
|
if (!Array.isArray(value) || value.length === 0) {
|
|
40749
|
-
issues.push(issue2(
|
|
40842
|
+
issues.push(issue2(path28, "INVALID_DATA_SOURCES", "pipeline dataSources must be a non-empty array"));
|
|
40750
40843
|
return void 0;
|
|
40751
40844
|
}
|
|
40752
40845
|
const ids = /* @__PURE__ */ new Set();
|
|
40753
40846
|
value.forEach((candidate, index) => {
|
|
40754
|
-
const itemPath = `${
|
|
40847
|
+
const itemPath = `${path28}[${index}]`;
|
|
40755
40848
|
if (!isPlainRecord(candidate)) {
|
|
40756
40849
|
issues.push(issue2(itemPath, "INVALID_DATA_SOURCE", "data source must be an object"));
|
|
40757
40850
|
return;
|
|
@@ -40795,22 +40888,22 @@ function validatePipelineDataSources(value, path26, issues) {
|
|
|
40795
40888
|
});
|
|
40796
40889
|
return value;
|
|
40797
40890
|
}
|
|
40798
|
-
function validateDataTransform(value,
|
|
40891
|
+
function validateDataTransform(value, path28, issues) {
|
|
40799
40892
|
if (!isPlainRecord(value)) {
|
|
40800
|
-
issues.push(issue2(
|
|
40893
|
+
issues.push(issue2(path28, "INVALID_DATA_TRANSFORM", "dataTransform must be an object"));
|
|
40801
40894
|
return;
|
|
40802
40895
|
}
|
|
40803
|
-
exactKeys(value, ["language", "profile", "source"],
|
|
40896
|
+
exactKeys(value, ["language", "profile", "source"], path28, issues);
|
|
40804
40897
|
if (value.language !== A2UI_CARD_DATA_TRANSFORM_LANGUAGE) {
|
|
40805
|
-
issues.push(issue2(`${
|
|
40898
|
+
issues.push(issue2(`${path28}.language`, "INVALID_DATA_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_DATA_TRANSFORM_LANGUAGE}`));
|
|
40806
40899
|
}
|
|
40807
40900
|
if (value.profile !== A2UI_CARD_DATA_TRANSFORM_PROFILE) {
|
|
40808
|
-
issues.push(issue2(`${
|
|
40901
|
+
issues.push(issue2(`${path28}.profile`, "INVALID_DATA_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_DATA_TRANSFORM_PROFILE}`));
|
|
40809
40902
|
}
|
|
40810
40903
|
if (typeof value.source !== "string" || value.source.trim().length === 0) {
|
|
40811
|
-
issues.push(issue2(`${
|
|
40904
|
+
issues.push(issue2(`${path28}.source`, "INVALID_DATA_TRANSFORM_SOURCE", "source must be a non-empty string"));
|
|
40812
40905
|
} else if (new TextEncoder().encode(value.source).byteLength > A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES) {
|
|
40813
|
-
issues.push(issue2(`${
|
|
40906
|
+
issues.push(issue2(`${path28}.source`, "DATA_TRANSFORM_SOURCE_TOO_LARGE", `source exceeds ${A2UI_CARD_DATA_TRANSFORM_MAX_SOURCE_BYTES} bytes`));
|
|
40814
40907
|
}
|
|
40815
40908
|
}
|
|
40816
40909
|
function validatePipelineFieldSchemas(fields, dataModelSchema, issues) {
|
|
@@ -40823,14 +40916,14 @@ function validatePipelineFieldSchemas(fields, dataModelSchema, issues) {
|
|
|
40823
40916
|
}
|
|
40824
40917
|
});
|
|
40825
40918
|
}
|
|
40826
|
-
function validateV3OutputBindings(value,
|
|
40919
|
+
function validateV3OutputBindings(value, path28, issues) {
|
|
40827
40920
|
if (!Array.isArray(value)) {
|
|
40828
|
-
issues.push(issue2(
|
|
40921
|
+
issues.push(issue2(path28, "INVALID_OUTPUT_BINDINGS", "bindings must be an array"));
|
|
40829
40922
|
return void 0;
|
|
40830
40923
|
}
|
|
40831
40924
|
const fields = /* @__PURE__ */ new Set();
|
|
40832
40925
|
value.forEach((candidate, index) => {
|
|
40833
|
-
const itemPath = `${
|
|
40926
|
+
const itemPath = `${path28}[${index}]`;
|
|
40834
40927
|
if (!isPlainRecord(candidate)) {
|
|
40835
40928
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
40836
40929
|
return;
|
|
@@ -40873,9 +40966,9 @@ function validateV3Coverage(fields, dataSources, bindings, issues, options = {})
|
|
|
40873
40966
|
}
|
|
40874
40967
|
}
|
|
40875
40968
|
}
|
|
40876
|
-
function validateV3BindingSelections(value,
|
|
40969
|
+
function validateV3BindingSelections(value, path28, fields, issues) {
|
|
40877
40970
|
if (!Array.isArray(value)) {
|
|
40878
|
-
issues.push(issue2(
|
|
40971
|
+
issues.push(issue2(path28, "INVALID_BINDINGS", "bindings must be an array"));
|
|
40879
40972
|
return;
|
|
40880
40973
|
}
|
|
40881
40974
|
if (value.length === 0)
|
|
@@ -40884,7 +40977,7 @@ function validateV3BindingSelections(value, path26, fields, issues) {
|
|
|
40884
40977
|
const outputBindings = [];
|
|
40885
40978
|
const dataSources = [];
|
|
40886
40979
|
value.forEach((candidate, index) => {
|
|
40887
|
-
const itemPath = `${
|
|
40980
|
+
const itemPath = `${path28}[${index}]`;
|
|
40888
40981
|
if (!isPlainRecord(candidate)) {
|
|
40889
40982
|
issues.push(issue2(itemPath, "INVALID_BINDING", "binding must be an object"));
|
|
40890
40983
|
return;
|
|
@@ -40929,19 +41022,19 @@ function validateV3BindingSelections(value, path26, fields, issues) {
|
|
|
40929
41022
|
});
|
|
40930
41023
|
}
|
|
40931
41024
|
});
|
|
40932
|
-
validateDataSources(dataSources, `${
|
|
41025
|
+
validateDataSources(dataSources, `${path28}.dataSources`, issues, {
|
|
40933
41026
|
validateOutputSchema: false
|
|
40934
41027
|
});
|
|
40935
|
-
validateV3OutputBindings(outputBindings, `${
|
|
41028
|
+
validateV3OutputBindings(outputBindings, `${path28}.outputs`, issues);
|
|
40936
41029
|
if (fields) {
|
|
40937
41030
|
validateV3Coverage(fields, dataSources, outputBindings, issues, {
|
|
40938
41031
|
requireComplete: false
|
|
40939
41032
|
});
|
|
40940
41033
|
}
|
|
40941
41034
|
}
|
|
40942
|
-
function validateManifest(value,
|
|
41035
|
+
function validateManifest(value, path28, issues) {
|
|
40943
41036
|
if (!isPlainRecord(value)) {
|
|
40944
|
-
issues.push(issue2(
|
|
41037
|
+
issues.push(issue2(path28, "INVALID_MANIFEST", `${path28} must be an object`));
|
|
40945
41038
|
return void 0;
|
|
40946
41039
|
}
|
|
40947
41040
|
if (value.schemaVersion === "4" && value.dataMode === "pipeline") {
|
|
@@ -40961,35 +41054,35 @@ function validateManifest(value, path26, issues) {
|
|
|
40961
41054
|
"dataSources",
|
|
40962
41055
|
"dataTransform",
|
|
40963
41056
|
"dataModelSchema"
|
|
40964
|
-
],
|
|
41057
|
+
], path28, issues);
|
|
40965
41058
|
if (!isSafeIdentifier(value.draftId)) {
|
|
40966
|
-
issues.push(issue2(`${
|
|
41059
|
+
issues.push(issue2(`${path28}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
40967
41060
|
}
|
|
40968
41061
|
if (value.argumentMode !== void 0 && value.argumentMode !== "model") {
|
|
40969
|
-
issues.push(issue2(`${
|
|
41062
|
+
issues.push(issue2(`${path28}.argumentMode`, "INVALID_ARGUMENT_MODE", "argumentMode must be model"));
|
|
40970
41063
|
}
|
|
40971
41064
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
40972
|
-
issues.push(issue2(`${
|
|
40973
|
-
}
|
|
40974
|
-
optionalString(value.baseRevision, `${
|
|
40975
|
-
requiredString(value.displayName, `${
|
|
40976
|
-
requiredString(value.description, `${
|
|
40977
|
-
requiredString(value.whenToUse, `${
|
|
40978
|
-
optionalString(value.whenNotToUse, `${
|
|
40979
|
-
validateLooseJsonSchema(value.presentationInputSchema, `${
|
|
40980
|
-
const fields2 = validateFields(value.fields, `${
|
|
40981
|
-
const pipelineSources = validatePipelineDataSources(value.dataSources, `${
|
|
41065
|
+
issues.push(issue2(`${path28}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
41066
|
+
}
|
|
41067
|
+
optionalString(value.baseRevision, `${path28}.baseRevision`, issues);
|
|
41068
|
+
requiredString(value.displayName, `${path28}.displayName`, issues);
|
|
41069
|
+
requiredString(value.description, `${path28}.description`, issues);
|
|
41070
|
+
requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
|
|
41071
|
+
optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
|
|
41072
|
+
validateLooseJsonSchema(value.presentationInputSchema, `${path28}.presentationInputSchema`, issues);
|
|
41073
|
+
const fields2 = validateFields(value.fields, `${path28}.fields`, issues);
|
|
41074
|
+
const pipelineSources = validatePipelineDataSources(value.dataSources, `${path28}.dataSources`, issues);
|
|
40982
41075
|
if (value.argumentMode === "model" && pipelineSources) {
|
|
40983
|
-
validateModelPipelineArguments(value, pipelineSources,
|
|
41076
|
+
validateModelPipelineArguments(value, pipelineSources, path28, issues);
|
|
40984
41077
|
}
|
|
40985
|
-
validateDataTransform(value.dataTransform, `${
|
|
40986
|
-
const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${
|
|
41078
|
+
validateDataTransform(value.dataTransform, `${path28}.dataTransform`, issues);
|
|
41079
|
+
const dataModelSchema = validateLooseJsonSchema(value.dataModelSchema, `${path28}.dataModelSchema`, issues);
|
|
40987
41080
|
if (fields2 && dataModelSchema) {
|
|
40988
41081
|
fields2.forEach((field, index) => {
|
|
40989
41082
|
if (field.source !== "business")
|
|
40990
41083
|
return;
|
|
40991
41084
|
if (!getJsonSchemaAtDataPointer(value.dataModelSchema, field.path)) {
|
|
40992
|
-
issues.push(issue2(`${
|
|
41085
|
+
issues.push(issue2(`${path28}.fields[${index}].path`, "DATA_MODEL_FIELD_MISSING", `dataModelSchema does not define ${field.path}`));
|
|
40993
41086
|
}
|
|
40994
41087
|
});
|
|
40995
41088
|
}
|
|
@@ -40997,10 +41090,10 @@ function validateManifest(value, path26, issues) {
|
|
|
40997
41090
|
}
|
|
40998
41091
|
if (value.schemaVersion === "3" || value.schemaVersion === "4") {
|
|
40999
41092
|
if (value.dataMode !== void 0 && (value.schemaVersion !== "4" || value.dataMode !== "bindings")) {
|
|
41000
|
-
issues.push(issue2(`${
|
|
41093
|
+
issues.push(issue2(`${path28}.dataMode`, "INVALID_DATA_MODE", "bindings dataMode is only available for schemaVersion 4"));
|
|
41001
41094
|
}
|
|
41002
41095
|
if (value.actionBindings !== void 0) {
|
|
41003
|
-
issues.push(issue2(`${
|
|
41096
|
+
issues.push(issue2(`${path28}.actionBindings`, "LEGACY_PAYMENT_ACTION_BINDINGS_UNSUPPORTED", "payment actions must be defined inline in card JSON"));
|
|
41004
41097
|
}
|
|
41005
41098
|
exactKeys(value, [
|
|
41006
41099
|
"schemaVersion",
|
|
@@ -41014,24 +41107,24 @@ function validateManifest(value, path26, issues) {
|
|
|
41014
41107
|
"whenNotToUse",
|
|
41015
41108
|
"fields",
|
|
41016
41109
|
"bindings"
|
|
41017
|
-
],
|
|
41110
|
+
], path28, issues);
|
|
41018
41111
|
if (!isSafeIdentifier(value.draftId)) {
|
|
41019
|
-
issues.push(issue2(`${
|
|
41112
|
+
issues.push(issue2(`${path28}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
41020
41113
|
}
|
|
41021
41114
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
41022
|
-
issues.push(issue2(`${
|
|
41023
|
-
}
|
|
41024
|
-
optionalString(value.baseRevision, `${
|
|
41025
|
-
requiredString(value.displayName, `${
|
|
41026
|
-
requiredString(value.description, `${
|
|
41027
|
-
requiredString(value.whenToUse, `${
|
|
41028
|
-
optionalString(value.whenNotToUse, `${
|
|
41029
|
-
const fields2 = validateFields(value.fields, `${
|
|
41115
|
+
issues.push(issue2(`${path28}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
41116
|
+
}
|
|
41117
|
+
optionalString(value.baseRevision, `${path28}.baseRevision`, issues);
|
|
41118
|
+
requiredString(value.displayName, `${path28}.displayName`, issues);
|
|
41119
|
+
requiredString(value.description, `${path28}.description`, issues);
|
|
41120
|
+
requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
|
|
41121
|
+
optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
|
|
41122
|
+
const fields2 = validateFields(value.fields, `${path28}.fields`, issues);
|
|
41030
41123
|
if (fields2?.some((field) => field.source === "invocation")) {
|
|
41031
|
-
issues.push(issue2(`${
|
|
41124
|
+
issues.push(issue2(`${path28}.fields`, "INVOCATION_FIELD_UNSUPPORTED", `schema v${value.schemaVersion} does not support invocation fields`));
|
|
41032
41125
|
}
|
|
41033
41126
|
if (value.bindings !== void 0) {
|
|
41034
|
-
validateV3BindingSelections(value.bindings, `${
|
|
41127
|
+
validateV3BindingSelections(value.bindings, `${path28}.bindings`, fields2, issues);
|
|
41035
41128
|
}
|
|
41036
41129
|
return fields2 ? value : void 0;
|
|
41037
41130
|
}
|
|
@@ -41047,37 +41140,37 @@ function validateManifest(value, path26, issues) {
|
|
|
41047
41140
|
"presentationInputSchema",
|
|
41048
41141
|
"fields",
|
|
41049
41142
|
"bindings"
|
|
41050
|
-
],
|
|
41143
|
+
], path28, issues);
|
|
41051
41144
|
if (value.schemaVersion !== "2") {
|
|
41052
|
-
issues.push(issue2(`${
|
|
41145
|
+
issues.push(issue2(`${path28}.schemaVersion`, "UNSUPPORTED_DRAFT_VERSION", "schemaVersion must be 2, 3 or 4"));
|
|
41053
41146
|
}
|
|
41054
41147
|
if (!isSafeIdentifier(value.draftId)) {
|
|
41055
|
-
issues.push(issue2(`${
|
|
41148
|
+
issues.push(issue2(`${path28}.draftId`, "INVALID_DRAFT_ID", "draftId is invalid"));
|
|
41056
41149
|
}
|
|
41057
41150
|
if (!isSafeIdentifier(value.resourceId)) {
|
|
41058
|
-
issues.push(issue2(`${
|
|
41059
|
-
}
|
|
41060
|
-
optionalString(value.baseRevision, `${
|
|
41061
|
-
requiredString(value.displayName, `${
|
|
41062
|
-
requiredString(value.description, `${
|
|
41063
|
-
requiredString(value.whenToUse, `${
|
|
41064
|
-
optionalString(value.whenNotToUse, `${
|
|
41065
|
-
const schema2 = validateLooseJsonSchema(value.presentationInputSchema, `${
|
|
41066
|
-
const fields = validateFields(value.fields, `${
|
|
41151
|
+
issues.push(issue2(`${path28}.resourceId`, "INVALID_RESOURCE_ID", "resourceId is invalid"));
|
|
41152
|
+
}
|
|
41153
|
+
optionalString(value.baseRevision, `${path28}.baseRevision`, issues);
|
|
41154
|
+
requiredString(value.displayName, `${path28}.displayName`, issues);
|
|
41155
|
+
requiredString(value.description, `${path28}.description`, issues);
|
|
41156
|
+
requiredString(value.whenToUse, `${path28}.whenToUse`, issues);
|
|
41157
|
+
optionalString(value.whenNotToUse, `${path28}.whenNotToUse`, issues);
|
|
41158
|
+
const schema2 = validateLooseJsonSchema(value.presentationInputSchema, `${path28}.presentationInputSchema`, issues);
|
|
41159
|
+
const fields = validateFields(value.fields, `${path28}.fields`, issues);
|
|
41067
41160
|
if (value.bindings !== void 0) {
|
|
41068
|
-
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${
|
|
41161
|
+
issues.push(...getA2UICardBindingSelectionIssues(value.bindings, `${path28}.bindings`, fields));
|
|
41069
41162
|
}
|
|
41070
41163
|
return schema2 && fields ? value : void 0;
|
|
41071
41164
|
}
|
|
41072
41165
|
function hasOverlappingJsonPointer(fixedInput, inputPath) {
|
|
41073
41166
|
const fixedPaths = [];
|
|
41074
|
-
const visit = (value,
|
|
41075
|
-
fixedPaths.push(
|
|
41167
|
+
const visit = (value, path28) => {
|
|
41168
|
+
fixedPaths.push(path28);
|
|
41076
41169
|
if (!isPlainRecord(value))
|
|
41077
41170
|
return;
|
|
41078
41171
|
for (const [key, child] of Object.entries(value)) {
|
|
41079
41172
|
const escaped = key.replace(/~/gu, "~0").replace(/\//gu, "~1");
|
|
41080
|
-
visit(child, `${
|
|
41173
|
+
visit(child, `${path28}/${escaped}`);
|
|
41081
41174
|
}
|
|
41082
41175
|
};
|
|
41083
41176
|
for (const [key, value] of Object.entries(fixedInput)) {
|
|
@@ -41086,15 +41179,15 @@ function hasOverlappingJsonPointer(fixedInput, inputPath) {
|
|
|
41086
41179
|
}
|
|
41087
41180
|
return fixedPaths.some((fixedPath) => fixedPath === inputPath || fixedPath.startsWith(`${inputPath}/`) || inputPath.startsWith(`${fixedPath}/`));
|
|
41088
41181
|
}
|
|
41089
|
-
function validateFields(value,
|
|
41182
|
+
function validateFields(value, path28, issues) {
|
|
41090
41183
|
if (!Array.isArray(value)) {
|
|
41091
|
-
issues.push(issue2(
|
|
41184
|
+
issues.push(issue2(path28, "INVALID_FIELDS", `${path28} must be an array`));
|
|
41092
41185
|
return void 0;
|
|
41093
41186
|
}
|
|
41094
41187
|
const ids = /* @__PURE__ */ new Set();
|
|
41095
41188
|
const paths = /* @__PURE__ */ new Set();
|
|
41096
41189
|
value.forEach((candidate, index) => {
|
|
41097
|
-
const itemPath = `${
|
|
41190
|
+
const itemPath = `${path28}[${index}]`;
|
|
41098
41191
|
if (!isPlainRecord(candidate)) {
|
|
41099
41192
|
issues.push(issue2(itemPath, "INVALID_FIELD", `${itemPath} must be an object`));
|
|
41100
41193
|
return;
|
|
@@ -41153,24 +41246,24 @@ function validateFields(value, path26, issues) {
|
|
|
41153
41246
|
function validateFieldPresentation(value, itemPath, issues) {
|
|
41154
41247
|
if (value === void 0)
|
|
41155
41248
|
return;
|
|
41156
|
-
const
|
|
41249
|
+
const path28 = `${itemPath}.presentation`;
|
|
41157
41250
|
if (!isPlainRecord(value)) {
|
|
41158
|
-
issues.push(issue2(
|
|
41251
|
+
issues.push(issue2(path28, "INVALID_FIELD_PRESENTATION", `${path28} must be an object`));
|
|
41159
41252
|
return;
|
|
41160
41253
|
}
|
|
41161
41254
|
if (!["echo", "reference-only", "never"].includes(String(value.visibility))) {
|
|
41162
|
-
issues.push(issue2(`${
|
|
41255
|
+
issues.push(issue2(`${path28}.visibility`, "INVALID_PRESENTATION_VISIBILITY", "presentation visibility must be echo, reference-only or never"));
|
|
41163
41256
|
}
|
|
41164
41257
|
if (value.labelPath !== void 0 && !isSafeJsonPointer(value.labelPath)) {
|
|
41165
|
-
issues.push(issue2(`${
|
|
41258
|
+
issues.push(issue2(`${path28}.labelPath`, "INVALID_PRESENTATION_PATH", "labelPath must be a safe JSON pointer"));
|
|
41166
41259
|
}
|
|
41167
41260
|
if (value.attributePaths !== void 0) {
|
|
41168
41261
|
if (!Array.isArray(value.attributePaths) || value.attributePaths.length > 3 || value.attributePaths.some((candidate) => !isSafeJsonPointer(candidate))) {
|
|
41169
|
-
issues.push(issue2(`${
|
|
41262
|
+
issues.push(issue2(`${path28}.attributePaths`, "INVALID_PRESENTATION_PATHS", "attributePaths must contain at most 3 safe JSON pointers"));
|
|
41170
41263
|
}
|
|
41171
41264
|
}
|
|
41172
41265
|
if (value.maxItems !== void 0 && (!Number.isInteger(value.maxItems) || Number(value.maxItems) < 1 || Number(value.maxItems) > 10)) {
|
|
41173
|
-
issues.push(issue2(`${
|
|
41266
|
+
issues.push(issue2(`${path28}.maxItems`, "INVALID_PRESENTATION_MAX_ITEMS", "maxItems must be an integer between 1 and 10"));
|
|
41174
41267
|
}
|
|
41175
41268
|
}
|
|
41176
41269
|
function validateFieldSource(candidate, itemPath, issues) {
|
|
@@ -41189,35 +41282,35 @@ function validateFieldSource(candidate, itemPath, issues) {
|
|
|
41189
41282
|
issues.push(issue2(`${itemPath}.runtimeContextKey`, "UNEXPECTED_RUNTIME_CONTEXT", "runtimeContextKey is only allowed for runtime-context fields"));
|
|
41190
41283
|
}
|
|
41191
41284
|
}
|
|
41192
|
-
function validateResolver(value,
|
|
41285
|
+
function validateResolver(value, path28, issues) {
|
|
41193
41286
|
if (!isPlainRecord(value)) {
|
|
41194
|
-
issues.push(issue2(
|
|
41287
|
+
issues.push(issue2(path28, "INVALID_RESOLVER", "resolver must be an object"));
|
|
41195
41288
|
return void 0;
|
|
41196
41289
|
}
|
|
41197
|
-
exactKeys(value, ["version", "calls", "outputBindings"],
|
|
41290
|
+
exactKeys(value, ["version", "calls", "outputBindings"], path28, issues);
|
|
41198
41291
|
if (value.version !== 2) {
|
|
41199
|
-
issues.push(issue2(`${
|
|
41292
|
+
issues.push(issue2(`${path28}.version`, "UNSUPPORTED_RESOLVER_VERSION", "resolver version must be 2"));
|
|
41200
41293
|
}
|
|
41201
|
-
const calls = validateResolverCalls(value.calls, `${
|
|
41202
|
-
const outputs = validateOutputBindings(value.outputBindings, `${
|
|
41294
|
+
const calls = validateResolverCalls(value.calls, `${path28}.calls`, issues);
|
|
41295
|
+
const outputs = validateOutputBindings(value.outputBindings, `${path28}.outputBindings`, issues);
|
|
41203
41296
|
if (!calls || !outputs)
|
|
41204
41297
|
return void 0;
|
|
41205
41298
|
const callIds = new Set(calls.map((call) => call.callId));
|
|
41206
41299
|
outputs.forEach((binding, index) => {
|
|
41207
41300
|
if (!callIds.has(binding.callId)) {
|
|
41208
|
-
issues.push(issue2(`${
|
|
41301
|
+
issues.push(issue2(`${path28}.outputBindings[${index}].callId`, "UNKNOWN_RESOLVER_CALL", `Unknown resolver call ${binding.callId}`));
|
|
41209
41302
|
}
|
|
41210
41303
|
});
|
|
41211
41304
|
return value;
|
|
41212
41305
|
}
|
|
41213
|
-
function validateResolverCalls(value,
|
|
41306
|
+
function validateResolverCalls(value, path28, issues) {
|
|
41214
41307
|
if (!Array.isArray(value)) {
|
|
41215
|
-
issues.push(issue2(
|
|
41308
|
+
issues.push(issue2(path28, "INVALID_RESOLVER_CALLS", "calls must be an array"));
|
|
41216
41309
|
return void 0;
|
|
41217
41310
|
}
|
|
41218
41311
|
const callIds = /* @__PURE__ */ new Set();
|
|
41219
41312
|
value.forEach((candidate, index) => {
|
|
41220
|
-
const itemPath = `${
|
|
41313
|
+
const itemPath = `${path28}[${index}]`;
|
|
41221
41314
|
if (!isPlainRecord(candidate)) {
|
|
41222
41315
|
issues.push(issue2(itemPath, "INVALID_RESOLVER_CALL", "call must be an object"));
|
|
41223
41316
|
return;
|
|
@@ -41238,14 +41331,14 @@ function validateResolverCalls(value, path26, issues) {
|
|
|
41238
41331
|
});
|
|
41239
41332
|
return value;
|
|
41240
41333
|
}
|
|
41241
|
-
function validateInputBindings2(value,
|
|
41334
|
+
function validateInputBindings2(value, path28, issues) {
|
|
41242
41335
|
if (!Array.isArray(value)) {
|
|
41243
|
-
issues.push(issue2(
|
|
41336
|
+
issues.push(issue2(path28, "INVALID_INPUT_BINDINGS", "inputBindings must be an array"));
|
|
41244
41337
|
return void 0;
|
|
41245
41338
|
}
|
|
41246
41339
|
const paths = /* @__PURE__ */ new Set();
|
|
41247
41340
|
value.forEach((candidate, index) => {
|
|
41248
|
-
const itemPath = `${
|
|
41341
|
+
const itemPath = `${path28}[${index}]`;
|
|
41249
41342
|
if (!isPlainRecord(candidate)) {
|
|
41250
41343
|
issues.push(issue2(itemPath, "INVALID_INPUT_BINDING", "binding must be an object"));
|
|
41251
41344
|
return;
|
|
@@ -41262,35 +41355,35 @@ function validateInputBindings2(value, path26, issues) {
|
|
|
41262
41355
|
});
|
|
41263
41356
|
return value;
|
|
41264
41357
|
}
|
|
41265
|
-
function validateInputSource(value,
|
|
41358
|
+
function validateInputSource(value, path28, issues) {
|
|
41266
41359
|
if (!isPlainRecord(value)) {
|
|
41267
|
-
issues.push(issue2(
|
|
41360
|
+
issues.push(issue2(path28, "INVALID_INPUT_SOURCE", "source must be an object"));
|
|
41268
41361
|
return;
|
|
41269
41362
|
}
|
|
41270
41363
|
if (value.kind === "invocation") {
|
|
41271
|
-
exactKeys(value, ["kind", "path"],
|
|
41364
|
+
exactKeys(value, ["kind", "path"], path28, issues);
|
|
41272
41365
|
if (!isSafeJsonPointer(value.path)) {
|
|
41273
|
-
issues.push(issue2(`${
|
|
41366
|
+
issues.push(issue2(`${path28}.path`, "INVALID_INPUT_SOURCE_PATH", "invocation source path must be a safe JSON pointer"));
|
|
41274
41367
|
}
|
|
41275
41368
|
return;
|
|
41276
41369
|
}
|
|
41277
41370
|
if (value.kind === "runtime-context") {
|
|
41278
|
-
exactKeys(value, ["kind", "key"],
|
|
41371
|
+
exactKeys(value, ["kind", "key"], path28, issues);
|
|
41279
41372
|
if (!RUNTIME_CONTEXT_KEYS2.has(value.key)) {
|
|
41280
|
-
issues.push(issue2(`${
|
|
41373
|
+
issues.push(issue2(`${path28}.key`, "INVALID_RUNTIME_CONTEXT", "runtime context key is invalid"));
|
|
41281
41374
|
}
|
|
41282
41375
|
return;
|
|
41283
41376
|
}
|
|
41284
|
-
issues.push(issue2(`${
|
|
41377
|
+
issues.push(issue2(`${path28}.kind`, "INVALID_INPUT_SOURCE", "source.kind must be invocation or runtime-context"));
|
|
41285
41378
|
}
|
|
41286
|
-
function validateOutputBindings(value,
|
|
41379
|
+
function validateOutputBindings(value, path28, issues) {
|
|
41287
41380
|
if (!Array.isArray(value)) {
|
|
41288
|
-
issues.push(issue2(
|
|
41381
|
+
issues.push(issue2(path28, "INVALID_OUTPUT_BINDINGS", "outputBindings must be an array"));
|
|
41289
41382
|
return void 0;
|
|
41290
41383
|
}
|
|
41291
41384
|
const fields = /* @__PURE__ */ new Set();
|
|
41292
41385
|
value.forEach((candidate, index) => {
|
|
41293
|
-
const itemPath = `${
|
|
41386
|
+
const itemPath = `${path28}[${index}]`;
|
|
41294
41387
|
if (!isPlainRecord(candidate)) {
|
|
41295
41388
|
issues.push(issue2(itemPath, "INVALID_OUTPUT_BINDING", "binding must be an object"));
|
|
41296
41389
|
return;
|
|
@@ -41310,33 +41403,33 @@ function validateOutputBindings(value, path26, issues) {
|
|
|
41310
41403
|
});
|
|
41311
41404
|
return value;
|
|
41312
41405
|
}
|
|
41313
|
-
function validateTransformShape(value,
|
|
41406
|
+
function validateTransformShape(value, path28, issues) {
|
|
41314
41407
|
if (!isPlainRecord(value)) {
|
|
41315
|
-
issues.push(issue2(
|
|
41408
|
+
issues.push(issue2(path28, "INVALID_TRANSFORM", "transform must be an object"));
|
|
41316
41409
|
return false;
|
|
41317
41410
|
}
|
|
41318
|
-
exactKeys(value, ["language", "profile", "expression"],
|
|
41411
|
+
exactKeys(value, ["language", "profile", "expression"], path28, issues);
|
|
41319
41412
|
if (value.language !== A2UI_CARD_TRANSFORM_LANGUAGE) {
|
|
41320
|
-
issues.push(issue2(`${
|
|
41413
|
+
issues.push(issue2(`${path28}.language`, "INVALID_TRANSFORM_LANGUAGE", `language must be ${A2UI_CARD_TRANSFORM_LANGUAGE}`));
|
|
41321
41414
|
}
|
|
41322
41415
|
if (value.profile !== A2UI_CARD_TRANSFORM_PROFILE) {
|
|
41323
|
-
issues.push(issue2(`${
|
|
41416
|
+
issues.push(issue2(`${path28}.profile`, "INVALID_TRANSFORM_PROFILE", `profile must be ${A2UI_CARD_TRANSFORM_PROFILE}`));
|
|
41324
41417
|
}
|
|
41325
41418
|
if (typeof value.expression !== "string" || value.expression.trim().length === 0) {
|
|
41326
|
-
issues.push(issue2(`${
|
|
41419
|
+
issues.push(issue2(`${path28}.expression`, "INVALID_TRANSFORM_EXPRESSION", "expression must be a non-empty string"));
|
|
41327
41420
|
} else if (value.expression.length > A2UI_CARD_EXPRESSION_MAX_LENGTH) {
|
|
41328
|
-
issues.push(issue2(`${
|
|
41421
|
+
issues.push(issue2(`${path28}.expression`, "TRANSFORM_EXPRESSION_TOO_LONG", `expression exceeds ${A2UI_CARD_EXPRESSION_MAX_LENGTH} characters`));
|
|
41329
41422
|
}
|
|
41330
41423
|
return true;
|
|
41331
41424
|
}
|
|
41332
|
-
function validateProtocol(value,
|
|
41425
|
+
function validateProtocol(value, path28, issues) {
|
|
41333
41426
|
if (!Array.isArray(value) || value.length === 0) {
|
|
41334
|
-
issues.push(issue2(
|
|
41427
|
+
issues.push(issue2(path28, "INVALID_A2UI_PROTOCOL", "card must be a non-empty array"));
|
|
41335
41428
|
return void 0;
|
|
41336
41429
|
}
|
|
41337
41430
|
const issueCountBeforeValidation = issues.length;
|
|
41338
41431
|
value.forEach((message, messageIndex) => {
|
|
41339
|
-
const messagePath = `${
|
|
41432
|
+
const messagePath = `${path28}[${messageIndex}]`;
|
|
41340
41433
|
if (!isPlainRecord(message)) {
|
|
41341
41434
|
issues.push(issue2(messagePath, "INVALID_A2UI_MESSAGE", "A2UI message must be an object"));
|
|
41342
41435
|
return;
|
|
@@ -41365,7 +41458,7 @@ function validateProtocol(value, path26, issues) {
|
|
|
41365
41458
|
return void 0;
|
|
41366
41459
|
return value;
|
|
41367
41460
|
}
|
|
41368
|
-
function validateInstructionShape(instruction,
|
|
41461
|
+
function validateInstructionShape(instruction, path28, issues) {
|
|
41369
41462
|
const knownKeys = [
|
|
41370
41463
|
"createSurface",
|
|
41371
41464
|
"updateComponents",
|
|
@@ -41374,31 +41467,31 @@ function validateInstructionShape(instruction, path26, issues) {
|
|
|
41374
41467
|
"x2DeleteComponent"
|
|
41375
41468
|
].filter((key) => key in instruction);
|
|
41376
41469
|
if (knownKeys.length !== 1) {
|
|
41377
|
-
issues.push(issue2(
|
|
41470
|
+
issues.push(issue2(path28, "INVALID_A2UI_INSTRUCTION", "instruction must contain exactly one supported operation"));
|
|
41378
41471
|
return;
|
|
41379
41472
|
}
|
|
41380
41473
|
const operation = knownKeys[0];
|
|
41381
41474
|
const payload = instruction[operation];
|
|
41382
41475
|
if (!isPlainRecord(payload)) {
|
|
41383
|
-
issues.push(issue2(`${
|
|
41476
|
+
issues.push(issue2(`${path28}.${operation}`, "INVALID_A2UI_INSTRUCTION_PAYLOAD", `${operation} must be an object`));
|
|
41384
41477
|
return;
|
|
41385
41478
|
}
|
|
41386
41479
|
if (!isSafeIdentifier(payload.surfaceId)) {
|
|
41387
|
-
issues.push(issue2(`${
|
|
41480
|
+
issues.push(issue2(`${path28}.${operation}.surfaceId`, "INVALID_SURFACE_ID", "surfaceId must be a non-empty safe identifier"));
|
|
41388
41481
|
}
|
|
41389
41482
|
if (operation === "updateComponents") {
|
|
41390
41483
|
if (!Array.isArray(payload.components)) {
|
|
41391
|
-
issues.push(issue2(`${
|
|
41484
|
+
issues.push(issue2(`${path28}.${operation}.components`, "INVALID_A2UI_COMPONENTS", "components must be an array"));
|
|
41392
41485
|
return;
|
|
41393
41486
|
}
|
|
41394
41487
|
payload.components.forEach((component, componentIndex) => {
|
|
41395
41488
|
if (!isPlainRecord(component) || !isJsonValue(component)) {
|
|
41396
|
-
issues.push(issue2(`${
|
|
41489
|
+
issues.push(issue2(`${path28}.${operation}.components[${componentIndex}]`, "INVALID_A2UI_COMPONENT", "component must be a JSON object"));
|
|
41397
41490
|
}
|
|
41398
41491
|
});
|
|
41399
41492
|
}
|
|
41400
41493
|
if (operation === "x2DeleteComponent" && !isSafeIdentifier(payload.componentId)) {
|
|
41401
|
-
issues.push(issue2(`${
|
|
41494
|
+
issues.push(issue2(`${path28}.${operation}.componentId`, "INVALID_COMPONENT_ID", "componentId must be a non-empty safe identifier"));
|
|
41402
41495
|
}
|
|
41403
41496
|
}
|
|
41404
41497
|
function validateTemplate(value, fields, issues) {
|
|
@@ -41424,8 +41517,8 @@ function validateTemplate(value, fields, issues) {
|
|
|
41424
41517
|
}
|
|
41425
41518
|
return void 0;
|
|
41426
41519
|
}
|
|
41427
|
-
function validateLooseJsonSchema(value,
|
|
41428
|
-
const schemaIssues = getJsonSchemaIssues(value,
|
|
41520
|
+
function validateLooseJsonSchema(value, path28, issues) {
|
|
41521
|
+
const schemaIssues = getJsonSchemaIssues(value, path28, {
|
|
41429
41522
|
allowMissingType: true
|
|
41430
41523
|
});
|
|
41431
41524
|
issues.push(...schemaIssues);
|
|
@@ -41447,14 +41540,14 @@ function validateResolverCoverage(fields, resolver, issues, card) {
|
|
|
41447
41540
|
}
|
|
41448
41541
|
}
|
|
41449
41542
|
}
|
|
41450
|
-
function requiredString(value,
|
|
41543
|
+
function requiredString(value, path28, issues) {
|
|
41451
41544
|
if (typeof value !== "string" || value.trim().length === 0) {
|
|
41452
|
-
issues.push(issue2(
|
|
41545
|
+
issues.push(issue2(path28, "REQUIRED_STRING", `${path28} must be a non-empty string`));
|
|
41453
41546
|
}
|
|
41454
41547
|
}
|
|
41455
|
-
function optionalString(value,
|
|
41548
|
+
function optionalString(value, path28, issues) {
|
|
41456
41549
|
if (value !== void 0 && typeof value !== "string") {
|
|
41457
|
-
issues.push(issue2(
|
|
41550
|
+
issues.push(issue2(path28, "INVALID_STRING", `${path28} must be a string`));
|
|
41458
41551
|
}
|
|
41459
41552
|
}
|
|
41460
41553
|
|
|
@@ -41980,8 +42073,8 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
41980
42073
|
const fields = bundle.manifest.fields.filter((field) => field.source === "business");
|
|
41981
42074
|
if (bundle.manifest.schemaVersion === "4" && bundle.manifest.dataMode === "pipeline") {
|
|
41982
42075
|
for (const [key, schema2] of Object.entries(bundle.manifest.dataModelSchema.properties ?? {})) {
|
|
41983
|
-
const
|
|
41984
|
-
if (!isPlainRecord(schema2) || fields.some((field) => field.path ===
|
|
42076
|
+
const path28 = `/${key.replace(/~/g, "~0").replace(/\//g, "~1")}`;
|
|
42077
|
+
if (!isPlainRecord(schema2) || fields.some((field) => field.path === path28))
|
|
41985
42078
|
continue;
|
|
41986
42079
|
if (!["string", "number", "integer", "boolean", "object", "array"].includes(String(schema2.type)))
|
|
41987
42080
|
continue;
|
|
@@ -41990,7 +42083,7 @@ function extractA2UICardAuthoringModel(bundle, options = {}) {
|
|
|
41990
42083
|
idIndex += 1;
|
|
41991
42084
|
fields.push({
|
|
41992
42085
|
fieldId: `pipeline-field-${idIndex}`,
|
|
41993
|
-
path:
|
|
42086
|
+
path: path28,
|
|
41994
42087
|
label: key,
|
|
41995
42088
|
type: schema2.type,
|
|
41996
42089
|
source: "business",
|
|
@@ -42142,8 +42235,8 @@ function isSafePageUrl2(url2, actionName) {
|
|
|
42142
42235
|
tokenCount++;
|
|
42143
42236
|
if (tokenCount > 32)
|
|
42144
42237
|
return false;
|
|
42145
|
-
const
|
|
42146
|
-
if (!(
|
|
42238
|
+
const path28 = match[1]?.trim() ?? "";
|
|
42239
|
+
if (!(path28 === "/" || path28.startsWith("/") || path28.startsWith("./")) || path28.split("/").some((part) => ["..", "__proto__", "constructor", "prototype"].includes(part))) {
|
|
42147
42240
|
return false;
|
|
42148
42241
|
}
|
|
42149
42242
|
}
|
|
@@ -43257,8 +43350,8 @@ function getErrorMap() {
|
|
|
43257
43350
|
|
|
43258
43351
|
// ../../node_modules/zod/v3/helpers/parseUtil.js
|
|
43259
43352
|
var makeIssue = (params) => {
|
|
43260
|
-
const { data, path:
|
|
43261
|
-
const fullPath = [...
|
|
43353
|
+
const { data, path: path28, errorMaps, issueData } = params;
|
|
43354
|
+
const fullPath = [...path28, ...issueData.path || []];
|
|
43262
43355
|
const fullIssue = {
|
|
43263
43356
|
...issueData,
|
|
43264
43357
|
path: fullPath
|
|
@@ -43374,11 +43467,11 @@ var errorUtil;
|
|
|
43374
43467
|
|
|
43375
43468
|
// ../../node_modules/zod/v3/types.js
|
|
43376
43469
|
var ParseInputLazyPath = class {
|
|
43377
|
-
constructor(parent, value,
|
|
43470
|
+
constructor(parent, value, path28, key) {
|
|
43378
43471
|
this._cachedPath = [];
|
|
43379
43472
|
this.parent = parent;
|
|
43380
43473
|
this.data = value;
|
|
43381
|
-
this._path =
|
|
43474
|
+
this._path = path28;
|
|
43382
43475
|
this._key = key;
|
|
43383
43476
|
}
|
|
43384
43477
|
get path() {
|
|
@@ -47431,24 +47524,6 @@ var LINKQUEGW_EVENT_TYPE_BY_STAGE = {
|
|
|
47431
47524
|
[EHookStage.RUN_READ]: "RUN_READ"
|
|
47432
47525
|
};
|
|
47433
47526
|
|
|
47434
|
-
// ../linkque-agent-runtime/dist/esm/core/memoryAdapter.js
|
|
47435
|
-
var EMemoryType;
|
|
47436
|
-
(function(EMemoryType2) {
|
|
47437
|
-
EMemoryType2["CONVERSATION"] = "conversation";
|
|
47438
|
-
EMemoryType2["LONG_TERM"] = "long_term";
|
|
47439
|
-
EMemoryType2["SHORT_TERM"] = "short_term";
|
|
47440
|
-
EMemoryType2["WORKING"] = "working";
|
|
47441
|
-
EMemoryType2["PREFERENCE"] = "preference";
|
|
47442
|
-
EMemoryType2["FACT"] = "fact";
|
|
47443
|
-
EMemoryType2["ACTION"] = "action";
|
|
47444
|
-
})(EMemoryType || (EMemoryType = {}));
|
|
47445
|
-
var EMemorySummaryStatus;
|
|
47446
|
-
(function(EMemorySummaryStatus2) {
|
|
47447
|
-
EMemorySummaryStatus2["COMPLETED"] = "completed";
|
|
47448
|
-
EMemorySummaryStatus2["FAILED"] = "failed";
|
|
47449
|
-
EMemorySummaryStatus2["CANCELLED"] = "cancelled";
|
|
47450
|
-
})(EMemorySummaryStatus || (EMemorySummaryStatus = {}));
|
|
47451
|
-
|
|
47452
47527
|
// ../../node_modules/zod/v4/core/core.js
|
|
47453
47528
|
var NEVER2 = Object.freeze({
|
|
47454
47529
|
status: "aborted"
|
|
@@ -47645,10 +47720,10 @@ function assignProp(target, prop, value) {
|
|
|
47645
47720
|
configurable: true
|
|
47646
47721
|
});
|
|
47647
47722
|
}
|
|
47648
|
-
function getElementAtPath(obj,
|
|
47649
|
-
if (!
|
|
47723
|
+
function getElementAtPath(obj, path28) {
|
|
47724
|
+
if (!path28)
|
|
47650
47725
|
return obj;
|
|
47651
|
-
return
|
|
47726
|
+
return path28.reduce((acc, key) => acc?.[key], obj);
|
|
47652
47727
|
}
|
|
47653
47728
|
function promiseAllObject(promisesObj) {
|
|
47654
47729
|
const keys2 = Object.keys(promisesObj);
|
|
@@ -47968,11 +48043,11 @@ function aborted(x, startIndex = 0) {
|
|
|
47968
48043
|
}
|
|
47969
48044
|
return false;
|
|
47970
48045
|
}
|
|
47971
|
-
function prefixIssues(
|
|
48046
|
+
function prefixIssues(path28, issues) {
|
|
47972
48047
|
return issues.map((iss) => {
|
|
47973
48048
|
var _a;
|
|
47974
48049
|
(_a = iss).path ?? (_a.path = []);
|
|
47975
|
-
iss.path.unshift(
|
|
48050
|
+
iss.path.unshift(path28);
|
|
47976
48051
|
return iss;
|
|
47977
48052
|
});
|
|
47978
48053
|
}
|
|
@@ -53321,6 +53396,24 @@ var AUTHORIZATION_CHECKPOINT_COLUMNS = [
|
|
|
53321
53396
|
}
|
|
53322
53397
|
];
|
|
53323
53398
|
|
|
53399
|
+
// ../linkque-agent-appwrite-integrate/dist/esm/runtime/externalActionSchema.js
|
|
53400
|
+
var definitions = [
|
|
53401
|
+
["state", 16],
|
|
53402
|
+
["digest", 64],
|
|
53403
|
+
["runId", 256],
|
|
53404
|
+
["threadId", 256],
|
|
53405
|
+
["messageId", 256],
|
|
53406
|
+
["createdAt", 64]
|
|
53407
|
+
];
|
|
53408
|
+
var EXTERNAL_ACTION_COLUMNS = definitions.map(([key, size]) => ({
|
|
53409
|
+
key,
|
|
53410
|
+
size,
|
|
53411
|
+
type: "varchar",
|
|
53412
|
+
required: true,
|
|
53413
|
+
array: false,
|
|
53414
|
+
default: null
|
|
53415
|
+
}));
|
|
53416
|
+
|
|
53324
53417
|
// ../linkque-agent-appwrite-integrate/dist/esm/runtime/appbaseRuntimeConfigProvider.js
|
|
53325
53418
|
var LINKQUE_ENDPOINT_PRE = "https://linkquegw-pre.alipay.com";
|
|
53326
53419
|
var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
@@ -53361,7 +53454,7 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
53361
53454
|
});
|
|
53362
53455
|
|
|
53363
53456
|
// src/commands/agentbuild/configTemplate.ts
|
|
53364
|
-
var
|
|
53457
|
+
var import_path8 = __toESM(require("path"));
|
|
53365
53458
|
var APPWRITE_CONFIG_NAME = "appwrite.config.json";
|
|
53366
53459
|
var CLIENT_CAPABILITY_TABLE_COLUMNS = [
|
|
53367
53460
|
...["ownerId", "agentId", "threadId", "runId", "toolCallId"].map((key) => ({
|
|
@@ -53979,56 +54072,7 @@ var TABLES = [
|
|
|
53979
54072
|
enabled: true,
|
|
53980
54073
|
rowSecurity: true,
|
|
53981
54074
|
permissions: [],
|
|
53982
|
-
columns:
|
|
53983
|
-
{
|
|
53984
|
-
key: "state",
|
|
53985
|
-
type: "varchar",
|
|
53986
|
-
array: false,
|
|
53987
|
-
default: null,
|
|
53988
|
-
size: 16,
|
|
53989
|
-
required: true
|
|
53990
|
-
},
|
|
53991
|
-
{
|
|
53992
|
-
key: "digest",
|
|
53993
|
-
type: "varchar",
|
|
53994
|
-
array: false,
|
|
53995
|
-
default: null,
|
|
53996
|
-
size: 64,
|
|
53997
|
-
required: true
|
|
53998
|
-
},
|
|
53999
|
-
{
|
|
54000
|
-
key: "runId",
|
|
54001
|
-
type: "varchar",
|
|
54002
|
-
array: false,
|
|
54003
|
-
default: null,
|
|
54004
|
-
size: 256,
|
|
54005
|
-
required: true
|
|
54006
|
-
},
|
|
54007
|
-
{
|
|
54008
|
-
key: "threadId",
|
|
54009
|
-
type: "varchar",
|
|
54010
|
-
array: false,
|
|
54011
|
-
default: null,
|
|
54012
|
-
size: 256,
|
|
54013
|
-
required: true
|
|
54014
|
-
},
|
|
54015
|
-
{
|
|
54016
|
-
key: "messageId",
|
|
54017
|
-
type: "varchar",
|
|
54018
|
-
array: false,
|
|
54019
|
-
default: null,
|
|
54020
|
-
size: 256,
|
|
54021
|
-
required: true
|
|
54022
|
-
},
|
|
54023
|
-
{
|
|
54024
|
-
key: "createdAt",
|
|
54025
|
-
type: "varchar",
|
|
54026
|
-
array: false,
|
|
54027
|
-
default: null,
|
|
54028
|
-
size: 64,
|
|
54029
|
-
required: true
|
|
54030
|
-
}
|
|
54031
|
-
],
|
|
54075
|
+
columns: EXTERNAL_ACTION_COLUMNS.map((column) => ({ ...column })),
|
|
54032
54076
|
indexes: []
|
|
54033
54077
|
},
|
|
54034
54078
|
{
|
|
@@ -54129,7 +54173,7 @@ function mergeVars(vars, overrides) {
|
|
|
54129
54173
|
return merged;
|
|
54130
54174
|
}
|
|
54131
54175
|
var writeAppwriteConfigTemplate = async (outDir, envOverrides = {}) => {
|
|
54132
|
-
const configPath =
|
|
54176
|
+
const configPath = import_path8.default.join(outDir, APPWRITE_CONFIG_NAME);
|
|
54133
54177
|
try {
|
|
54134
54178
|
await ensureParentDir(configPath);
|
|
54135
54179
|
await writeJsonAtomically(
|
|
@@ -54147,7 +54191,7 @@ var writeAppwriteConfigTemplate = async (outDir, envOverrides = {}) => {
|
|
|
54147
54191
|
};
|
|
54148
54192
|
|
|
54149
54193
|
// src/commands/agentbuild/envOverrides.ts
|
|
54150
|
-
var
|
|
54194
|
+
var import_path9 = __toESM(require("path"));
|
|
54151
54195
|
var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
54152
54196
|
async function resolveEnvOverrides(env, envFile, cwd) {
|
|
54153
54197
|
const overrides = {};
|
|
@@ -54156,7 +54200,7 @@ async function resolveEnvOverrides(env, envFile, cwd) {
|
|
|
54156
54200
|
if (parsed) overrides[parsed.key] = parsed.value;
|
|
54157
54201
|
}
|
|
54158
54202
|
if (envFile && envFile.trim()) {
|
|
54159
|
-
const filePath =
|
|
54203
|
+
const filePath = import_path9.default.resolve(cwd, envFile);
|
|
54160
54204
|
const content = await readUtf8IfExists(filePath);
|
|
54161
54205
|
if (content === null) {
|
|
54162
54206
|
throw new LinkqueCliError(
|
|
@@ -54189,12 +54233,12 @@ function parseEnvEntry(raw) {
|
|
|
54189
54233
|
|
|
54190
54234
|
// src/commands/agentbuild/pkgResolver.ts
|
|
54191
54235
|
var import_fs6 = require("fs");
|
|
54192
|
-
var
|
|
54236
|
+
var import_path10 = require("path");
|
|
54193
54237
|
var INTEGRATE_PKG = "@alipay/linkque-agent-appwrite-integrate";
|
|
54194
54238
|
var resolveIntegrateRoot = () => resolvePortableIntegrateRoot() ?? resolveInstalledIntegrateRoot();
|
|
54195
54239
|
var resolveInstalledIntegrateRoot = () => {
|
|
54196
54240
|
try {
|
|
54197
|
-
return (0,
|
|
54241
|
+
return (0, import_path10.dirname)(require.resolve(`${INTEGRATE_PKG}/package.json`));
|
|
54198
54242
|
} catch {
|
|
54199
54243
|
throw new LinkqueCliError(
|
|
54200
54244
|
"AGENTBUILD_INTEGRATE_NOT_BUILT",
|
|
@@ -54205,16 +54249,16 @@ var resolveInstalledIntegrateRoot = () => {
|
|
|
54205
54249
|
var resolvePortableIntegrateRoot = () => {
|
|
54206
54250
|
let dir = __dirname;
|
|
54207
54251
|
while (true) {
|
|
54208
|
-
const candidate = (0,
|
|
54209
|
-
if ((0, import_fs6.existsSync)((0,
|
|
54210
|
-
const parent = (0,
|
|
54252
|
+
const candidate = (0, import_path10.join)(dir, "vendor", "linkque-agent-appwrite-integrate");
|
|
54253
|
+
if ((0, import_fs6.existsSync)((0, import_path10.join)(candidate, "package.json"))) return candidate;
|
|
54254
|
+
const parent = (0, import_path10.dirname)(dir);
|
|
54211
54255
|
if (parent === dir) break;
|
|
54212
54256
|
dir = parent;
|
|
54213
54257
|
}
|
|
54214
54258
|
return void 0;
|
|
54215
54259
|
};
|
|
54216
54260
|
var assertIntegrateBuilt = (pkgRoot) => {
|
|
54217
|
-
const distEsm = (0,
|
|
54261
|
+
const distEsm = (0, import_path10.join)(pkgRoot, "dist", "esm");
|
|
54218
54262
|
if (!(0, import_fs6.existsSync)(distEsm)) {
|
|
54219
54263
|
throw new LinkqueCliError(
|
|
54220
54264
|
"AGENTBUILD_INTEGRATE_NOT_BUILT",
|
|
@@ -54225,13 +54269,13 @@ var assertIntegrateBuilt = (pkgRoot) => {
|
|
|
54225
54269
|
|
|
54226
54270
|
// src/commands/agentbuild/buildCommand.ts
|
|
54227
54271
|
var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveOutDir, envOverrides) => {
|
|
54228
|
-
const outDir =
|
|
54272
|
+
const outDir = import_path11.default.join(cwd, AGENT_BUNDLE_DIR);
|
|
54229
54273
|
const start = Date.now();
|
|
54230
|
-
await (0,
|
|
54274
|
+
await (0, import_promises6.rm)(outDir, { force: true, recursive: true });
|
|
54231
54275
|
const stats = [];
|
|
54232
54276
|
try {
|
|
54233
54277
|
for (const def of FUNCTION_DEFS) {
|
|
54234
|
-
const fnOutDir =
|
|
54278
|
+
const fnOutDir = import_path11.default.join(outDir, def.$id);
|
|
54235
54279
|
const result = await bundleAgentInstallation({
|
|
54236
54280
|
// loadAgentProtocol 仅做最小校验(可读+JSON 对象+不含 apiKey),返回 Record;
|
|
54237
54281
|
// bundler 的 assertProtocolValid 会做运行时 IAgentProtocol 字段校验,这里 cast。
|
|
@@ -54256,14 +54300,14 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54256
54300
|
);
|
|
54257
54301
|
}
|
|
54258
54302
|
const configAbsPath = await writeAppwriteConfigTemplate(outDir, envOverrides);
|
|
54259
|
-
await (0,
|
|
54260
|
-
|
|
54303
|
+
await (0, import_promises6.writeFile)(
|
|
54304
|
+
import_path11.default.join(outDir, AGENT_DEPLOY_META_NAME),
|
|
54261
54305
|
`${JSON.stringify({ agentId: protocol.agentId }, null, 2)}
|
|
54262
54306
|
`,
|
|
54263
54307
|
"utf8"
|
|
54264
54308
|
);
|
|
54265
|
-
const configPath =
|
|
54266
|
-
const bundleDir =
|
|
54309
|
+
const configPath = import_path11.default.relative(cwd, configAbsPath);
|
|
54310
|
+
const bundleDir = import_path11.default.relative(cwd, outDir) || AGENT_BUNDLE_DIR;
|
|
54267
54311
|
const totalBytes = stats.reduce((sum, s4) => sum + s4.bytes, 0);
|
|
54268
54312
|
const durationMs = Date.now() - start;
|
|
54269
54313
|
await writePerFunctionArchives(outDir);
|
|
@@ -54284,7 +54328,7 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54284
54328
|
// archive 模式:对外交付物是 code.tar,bundle 目录是中间态。
|
|
54285
54329
|
bundleDir: "",
|
|
54286
54330
|
configPath,
|
|
54287
|
-
archivePath:
|
|
54331
|
+
archivePath: import_path11.default.relative(cwd, archiveAbsPath),
|
|
54288
54332
|
functions: stats,
|
|
54289
54333
|
totalBytes,
|
|
54290
54334
|
durationMs
|
|
@@ -54293,8 +54337,8 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54293
54337
|
var writePerFunctionArchives = async (outDir) => {
|
|
54294
54338
|
try {
|
|
54295
54339
|
for (const def of FUNCTION_DEFS) {
|
|
54296
|
-
const fnOutDir =
|
|
54297
|
-
const fnArchive =
|
|
54340
|
+
const fnOutDir = import_path11.default.join(outDir, def.$id);
|
|
54341
|
+
const fnArchive = import_path11.default.join(outDir, `${def.$id}.tar.gz`);
|
|
54298
54342
|
await Qn(
|
|
54299
54343
|
{ gzip: true, cwd: fnOutDir, file: fnArchive, portable: true },
|
|
54300
54344
|
["."]
|
|
@@ -54309,11 +54353,11 @@ var writePerFunctionArchives = async (outDir) => {
|
|
|
54309
54353
|
}
|
|
54310
54354
|
};
|
|
54311
54355
|
var writeCodeTar = async (cwd, outDir, archiveOutDir) => {
|
|
54312
|
-
const archiveDirAbs =
|
|
54356
|
+
const archiveDirAbs = import_path11.default.resolve(
|
|
54313
54357
|
cwd,
|
|
54314
54358
|
archiveOutDir === "" ? DEFAULT_ARCHIVE_DIR : archiveOutDir
|
|
54315
54359
|
);
|
|
54316
|
-
const archiveAbsPath =
|
|
54360
|
+
const archiveAbsPath = import_path11.default.join(archiveDirAbs, AGENT_ARCHIVE_NAME);
|
|
54317
54361
|
await ensureParentDir(archiveAbsPath);
|
|
54318
54362
|
try {
|
|
54319
54363
|
await Qn(
|
|
@@ -54340,7 +54384,7 @@ var agentBuild = async (cwd, rawConfigPath, minify, archive, archiveOutDir, env,
|
|
|
54340
54384
|
const envOverrides = await resolveEnvOverrides(env, envFile, cwd);
|
|
54341
54385
|
return withWorkspaceLock(
|
|
54342
54386
|
{
|
|
54343
|
-
path:
|
|
54387
|
+
path: import_path11.default.join(cwd, AGENTBUILD_LOCK),
|
|
54344
54388
|
name: "agentbuild",
|
|
54345
54389
|
acquireErrorCode: "AGENTBUILD_LOCK_TIMEOUT",
|
|
54346
54390
|
releaseErrorCode: "AGENTBUILD_STATE_WRITE_FAILED",
|
|
@@ -54361,12 +54405,12 @@ var agentBuild = async (cwd, rawConfigPath, minify, archive, archiveOutDir, env,
|
|
|
54361
54405
|
|
|
54362
54406
|
// src/commands/agentdeploy/deployCommand.ts
|
|
54363
54407
|
var import_fs7 = require("fs");
|
|
54364
|
-
var
|
|
54408
|
+
var import_path13 = __toESM(require("path"));
|
|
54365
54409
|
|
|
54366
54410
|
// src/commands/agentdeploy/configLoader.ts
|
|
54367
|
-
var
|
|
54411
|
+
var import_promises7 = require("fs/promises");
|
|
54368
54412
|
var import_os2 = require("os");
|
|
54369
|
-
var
|
|
54413
|
+
var import_path12 = __toESM(require("path"));
|
|
54370
54414
|
|
|
54371
54415
|
// src/commands/agentdeploy/types.ts
|
|
54372
54416
|
var AGENTDEPLOY_LOCK = ".linkque/runtime/agentdeploy.lock";
|
|
@@ -54385,24 +54429,24 @@ var BUNDLE_CONFIG_NAME = "appwrite.config.json";
|
|
|
54385
54429
|
var readBundleAgentId = async (bundlePath) => {
|
|
54386
54430
|
let content;
|
|
54387
54431
|
if (await pathHasKind(bundlePath, "dir")) {
|
|
54388
|
-
content = await (0,
|
|
54389
|
-
|
|
54432
|
+
content = await (0, import_promises7.readFile)(
|
|
54433
|
+
import_path12.default.join(bundlePath, AGENT_DEPLOY_META_NAME),
|
|
54390
54434
|
"utf8"
|
|
54391
54435
|
).catch(() => "");
|
|
54392
54436
|
} else if (isArchivePath(bundlePath)) {
|
|
54393
|
-
const tmpDir = await (0,
|
|
54437
|
+
const tmpDir = await (0, import_promises7.mkdtemp)(import_path12.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-meta-"));
|
|
54394
54438
|
try {
|
|
54395
54439
|
await So({
|
|
54396
54440
|
file: bundlePath,
|
|
54397
54441
|
cwd: tmpDir,
|
|
54398
54442
|
filter: (entryPath) => entryPath.replace(/^\.\//, "") === AGENT_DEPLOY_META_NAME
|
|
54399
54443
|
});
|
|
54400
|
-
content = await (0,
|
|
54401
|
-
|
|
54444
|
+
content = await (0, import_promises7.readFile)(
|
|
54445
|
+
import_path12.default.join(tmpDir, AGENT_DEPLOY_META_NAME),
|
|
54402
54446
|
"utf8"
|
|
54403
54447
|
).catch(() => "");
|
|
54404
54448
|
} finally {
|
|
54405
|
-
await (0,
|
|
54449
|
+
await (0, import_promises7.rm)(tmpDir, { force: true, recursive: true });
|
|
54406
54450
|
}
|
|
54407
54451
|
} else {
|
|
54408
54452
|
content = "";
|
|
@@ -54421,7 +54465,7 @@ var readBundleAgentId = async (bundlePath) => {
|
|
|
54421
54465
|
};
|
|
54422
54466
|
var isArchivePath = (bundlePath) => bundlePath.endsWith(".tar") || bundlePath.endsWith(".tar.gz") || bundlePath.endsWith(".tgz");
|
|
54423
54467
|
var readConfigFromTar = async (tarPath) => {
|
|
54424
|
-
const tmpDir = await (0,
|
|
54468
|
+
const tmpDir = await (0, import_promises7.mkdtemp)(import_path12.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-cfg-"));
|
|
54425
54469
|
try {
|
|
54426
54470
|
await So({
|
|
54427
54471
|
file: tarPath,
|
|
@@ -54430,7 +54474,7 @@ var readConfigFromTar = async (tarPath) => {
|
|
|
54430
54474
|
filter: (entryPath) => entryPath.replace(/^\.\//, "") === BUNDLE_CONFIG_NAME
|
|
54431
54475
|
});
|
|
54432
54476
|
const content = await readUtf8IfExists(
|
|
54433
|
-
|
|
54477
|
+
import_path12.default.join(tmpDir, BUNDLE_CONFIG_NAME)
|
|
54434
54478
|
);
|
|
54435
54479
|
if (content === null) {
|
|
54436
54480
|
throw new LinkqueCliError(
|
|
@@ -54446,12 +54490,12 @@ var readConfigFromTar = async (tarPath) => {
|
|
|
54446
54490
|
`failed to read appwrite config from bundle archive ${tarPath}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
54447
54491
|
);
|
|
54448
54492
|
} finally {
|
|
54449
|
-
await (0,
|
|
54493
|
+
await (0, import_promises7.rm)(tmpDir, { force: true, recursive: true });
|
|
54450
54494
|
}
|
|
54451
54495
|
};
|
|
54452
54496
|
var readBundleConfigContent = async (bundlePath) => {
|
|
54453
54497
|
if (await pathHasKind(bundlePath, "dir")) {
|
|
54454
|
-
const configPath =
|
|
54498
|
+
const configPath = import_path12.default.join(bundlePath, BUNDLE_CONFIG_NAME);
|
|
54455
54499
|
const content = await readUtf8IfExists(configPath);
|
|
54456
54500
|
if (content === null) {
|
|
54457
54501
|
throw new LinkqueCliError(
|
|
@@ -54519,7 +54563,7 @@ var parseAppwriteConfig = (content, configPath) => {
|
|
|
54519
54563
|
};
|
|
54520
54564
|
};
|
|
54521
54565
|
var loadDeployManifest = async (rawPath, cwd) => {
|
|
54522
|
-
const manifestPath =
|
|
54566
|
+
const manifestPath = import_path12.default.resolve(
|
|
54523
54567
|
cwd,
|
|
54524
54568
|
rawPath === "" ? DEFAULT_MANIFEST_NAME : rawPath
|
|
54525
54569
|
);
|
|
@@ -54771,7 +54815,7 @@ var deployWhileLocked = async (cwd, cfg, apiKey, agentId, bundlePath, options) =
|
|
|
54771
54815
|
{ cause: error2 }
|
|
54772
54816
|
);
|
|
54773
54817
|
}
|
|
54774
|
-
const statePath =
|
|
54818
|
+
const statePath = import_path13.default.join(cwd, AGENTDEPLOY_STATE);
|
|
54775
54819
|
await ensureParentDir(statePath);
|
|
54776
54820
|
try {
|
|
54777
54821
|
await writeJsonAtomically(statePath, { deployedAt: Date.now(), results });
|
|
@@ -54794,7 +54838,7 @@ var deployWhileLocked = async (cwd, cfg, apiKey, agentId, bundlePath, options) =
|
|
|
54794
54838
|
return { results, okCount, totalCount, allOk: true };
|
|
54795
54839
|
};
|
|
54796
54840
|
var agentDeploy = async (cwd, options) => {
|
|
54797
|
-
const bundlePath = options.bundlePath ??
|
|
54841
|
+
const bundlePath = options.bundlePath ?? import_path13.default.join(cwd, AGENT_BUNDLE_DIR);
|
|
54798
54842
|
if (!(0, import_fs7.existsSync)(bundlePath)) {
|
|
54799
54843
|
throw new LinkqueCliError(
|
|
54800
54844
|
"AGENTDEPLOY_BUNDLE_NOT_FOUND",
|
|
@@ -54831,7 +54875,7 @@ var agentDeploy = async (cwd, options) => {
|
|
|
54831
54875
|
}
|
|
54832
54876
|
return withWorkspaceLock(
|
|
54833
54877
|
{
|
|
54834
|
-
path:
|
|
54878
|
+
path: import_path13.default.join(cwd, AGENTDEPLOY_LOCK),
|
|
54835
54879
|
name: "agentdeploy",
|
|
54836
54880
|
acquireErrorCode: "AGENTDEPLOY_LOCK_TIMEOUT",
|
|
54837
54881
|
releaseErrorCode: "AGENTDEPLOY_STATE_WRITE_FAILED",
|
|
@@ -54878,7 +54922,7 @@ var SandboxRuntimeConfigProvider = class extends RuntimeConfigProvider {
|
|
|
54878
54922
|
|
|
54879
54923
|
// src/commands/agentdev/configLoader.ts
|
|
54880
54924
|
var import_crypto3 = require("crypto");
|
|
54881
|
-
var
|
|
54925
|
+
var import_path14 = __toESM(require("path"));
|
|
54882
54926
|
|
|
54883
54927
|
// src/commands/agentdev/types.ts
|
|
54884
54928
|
var MODEL_PROVIDER_BY_GATEWAY = Object.freeze({ LINKQUE: "LINKQUE", TEST: "TEST" });
|
|
@@ -54915,7 +54959,7 @@ var stopped = (health) => ({
|
|
|
54915
54959
|
// src/commands/agentdev/configLoader.ts
|
|
54916
54960
|
var DEFAULT_CONFIG_NAME2 = "agent_config.json";
|
|
54917
54961
|
var loadAgentConfig = async (rawConfigPath, cwd) => {
|
|
54918
|
-
const configPath =
|
|
54962
|
+
const configPath = import_path14.default.resolve(
|
|
54919
54963
|
cwd,
|
|
54920
54964
|
rawConfigPath === "" ? DEFAULT_CONFIG_NAME2 : rawConfigPath
|
|
54921
54965
|
);
|
|
@@ -55023,9 +55067,9 @@ var normalizeModelProvider = (provider, configPath) => {
|
|
|
55023
55067
|
};
|
|
55024
55068
|
|
|
55025
55069
|
// src/commands/agentdev/ownerState.ts
|
|
55026
|
-
var
|
|
55070
|
+
var import_promises8 = require("fs/promises");
|
|
55027
55071
|
var import_net = require("net");
|
|
55028
|
-
var
|
|
55072
|
+
var import_path15 = __toESM(require("path"));
|
|
55029
55073
|
var isAgentHttpHealthy = async (port) => {
|
|
55030
55074
|
const probeUrl = new URL(`http://127.0.0.1:${port}${HEALTH_PATH}`);
|
|
55031
55075
|
try {
|
|
@@ -55071,7 +55115,7 @@ var readOwnedAgentState = async (statePath) => {
|
|
|
55071
55115
|
};
|
|
55072
55116
|
async function removeMatchingState(statePath, pid) {
|
|
55073
55117
|
const owned = await readOwnedAgentState(statePath);
|
|
55074
|
-
if (owned?.state.pid === pid) await (0,
|
|
55118
|
+
if (owned?.state.pid === pid) await (0, import_promises8.rm)(statePath, { force: true });
|
|
55075
55119
|
}
|
|
55076
55120
|
async function terminateOwner(statePath, pid) {
|
|
55077
55121
|
if (!isProcessAlive(pid)) {
|
|
@@ -55117,14 +55161,14 @@ var statusFromState = async (state) => ({
|
|
|
55117
55161
|
startedAt: state.startedAt
|
|
55118
55162
|
});
|
|
55119
55163
|
var inspectRecordedAgentServer = async (cwd, legacyFailureCode = "AGENTDEV_STOP_FAILED") => {
|
|
55120
|
-
const statePath =
|
|
55164
|
+
const statePath = import_path15.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
|
|
55121
55165
|
const content = await readUtf8IfExists(statePath);
|
|
55122
55166
|
if (content === null) {
|
|
55123
55167
|
return { state: null, status: stopped("STOPPED") };
|
|
55124
55168
|
}
|
|
55125
55169
|
const owned = parseOwnedAgentState(content);
|
|
55126
55170
|
if (owned === null) {
|
|
55127
|
-
await (0,
|
|
55171
|
+
await (0, import_promises8.rm)(statePath, { force: true });
|
|
55128
55172
|
return { state: null, status: stopped("STALE") };
|
|
55129
55173
|
}
|
|
55130
55174
|
if (owned.kind === "legacy") {
|
|
@@ -55153,9 +55197,9 @@ var inspectAgentServer = async (cwd) => (await inspectRecordedAgentServer(cwd)).
|
|
|
55153
55197
|
|
|
55154
55198
|
// src/commands/agentdev/startCommand.ts
|
|
55155
55199
|
var import_child_process = require("child_process");
|
|
55156
|
-
var
|
|
55200
|
+
var import_path16 = __toESM(require("path"));
|
|
55157
55201
|
var spawnAgentOwner = (cwd, config3, port, apiKey, statePath) => {
|
|
55158
|
-
const workerPath =
|
|
55202
|
+
const workerPath = import_path16.default.resolve(__dirname, "worker.js");
|
|
55159
55203
|
const input = Buffer.from(
|
|
55160
55204
|
JSON.stringify({
|
|
55161
55205
|
agentId: config3.agentId,
|
|
@@ -55164,7 +55208,7 @@ var spawnAgentOwner = (cwd, config3, port, apiKey, statePath) => {
|
|
|
55164
55208
|
healthPath: HEALTH_PATH,
|
|
55165
55209
|
homeDataPath: HOME_DATA_PATH,
|
|
55166
55210
|
functionActionMcpPath: FUNCTION_ACTION_MCP_PATH,
|
|
55167
|
-
logPath:
|
|
55211
|
+
logPath: import_path16.default.join(cwd, AGENT_LOG),
|
|
55168
55212
|
port,
|
|
55169
55213
|
runsPath: RUNS_PATH,
|
|
55170
55214
|
statePath
|
|
@@ -55263,9 +55307,9 @@ var startAgentServerWhileLocked = async (cwd, config3, apiKey, port, statePath)
|
|
|
55263
55307
|
var startAgentServer = async (cwd, rawConfigPath, port) => {
|
|
55264
55308
|
const config3 = await loadAgentConfig(rawConfigPath, cwd);
|
|
55265
55309
|
const { apiKey } = resolveAuth(config3);
|
|
55266
|
-
const runtimeDir =
|
|
55267
|
-
const lockPath =
|
|
55268
|
-
const statePath =
|
|
55310
|
+
const runtimeDir = import_path16.default.join(cwd, RUNTIME_DIR);
|
|
55311
|
+
const lockPath = import_path16.default.join(runtimeDir, AGENT_LOCK);
|
|
55312
|
+
const statePath = import_path16.default.join(runtimeDir, AGENT_STATE);
|
|
55269
55313
|
await ensureParentDir(statePath);
|
|
55270
55314
|
return withWorkspaceLock(
|
|
55271
55315
|
{
|
|
@@ -55281,11 +55325,11 @@ var startAgentServer = async (cwd, rawConfigPath, port) => {
|
|
|
55281
55325
|
};
|
|
55282
55326
|
|
|
55283
55327
|
// src/commands/agentdev/stopCommand.ts
|
|
55284
|
-
var
|
|
55285
|
-
var
|
|
55328
|
+
var import_promises9 = require("fs/promises");
|
|
55329
|
+
var import_path17 = __toESM(require("path"));
|
|
55286
55330
|
var stopAgentServer = async (cwd) => {
|
|
55287
|
-
const lockPath =
|
|
55288
|
-
const statePath =
|
|
55331
|
+
const lockPath = import_path17.default.join(cwd, RUNTIME_DIR, AGENT_LOCK);
|
|
55332
|
+
const statePath = import_path17.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
|
|
55289
55333
|
await ensureParentDir(statePath);
|
|
55290
55334
|
return withWorkspaceLock(
|
|
55291
55335
|
{
|
|
@@ -55299,7 +55343,7 @@ var stopAgentServer = async (cwd) => {
|
|
|
55299
55343
|
async () => {
|
|
55300
55344
|
const owned = await readOwnedAgentState(statePath);
|
|
55301
55345
|
if (owned !== null) await terminateOwner(statePath, owned.state.pid);
|
|
55302
|
-
await (0,
|
|
55346
|
+
await (0, import_promises9.rm)(statePath, { force: true });
|
|
55303
55347
|
return { stopped: true };
|
|
55304
55348
|
}
|
|
55305
55349
|
);
|
|
@@ -55307,15 +55351,15 @@ var stopAgentServer = async (cwd) => {
|
|
|
55307
55351
|
|
|
55308
55352
|
// src/commands/build/dist.ts
|
|
55309
55353
|
var import_crypto7 = require("crypto");
|
|
55310
|
-
var
|
|
55311
|
-
var
|
|
55354
|
+
var import_promises14 = require("fs/promises");
|
|
55355
|
+
var import_path21 = __toESM(require("path"));
|
|
55312
55356
|
|
|
55313
55357
|
// src/utils/spawn.ts
|
|
55314
55358
|
var import_child_process2 = require("child_process");
|
|
55315
|
-
var
|
|
55359
|
+
var import_promises10 = require("fs/promises");
|
|
55316
55360
|
var spawnManaged = async (options) => {
|
|
55317
55361
|
await ensureParentDir(options.logPath);
|
|
55318
|
-
const log = await (0,
|
|
55362
|
+
const log = await (0, import_promises10.open)(options.logPath, "a");
|
|
55319
55363
|
try {
|
|
55320
55364
|
await log.writeFile(
|
|
55321
55365
|
`
|
|
@@ -55380,8 +55424,8 @@ var spawnManaged = async (options) => {
|
|
|
55380
55424
|
// src/commands/install.ts
|
|
55381
55425
|
var import_child_process3 = require("child_process");
|
|
55382
55426
|
var import_crypto4 = require("crypto");
|
|
55383
|
-
var
|
|
55384
|
-
var
|
|
55427
|
+
var import_promises11 = require("fs/promises");
|
|
55428
|
+
var import_path18 = __toESM(require("path"));
|
|
55385
55429
|
var RUNTIME_DIR2 = ".linkque/runtime";
|
|
55386
55430
|
var LOG_DIR = ".linkque/logs";
|
|
55387
55431
|
var INSTALL_LOCK = "install.lock";
|
|
@@ -55434,7 +55478,7 @@ var readLockfiles = async (cwd) => {
|
|
|
55434
55478
|
const lockfiles = /* @__PURE__ */ new Map();
|
|
55435
55479
|
await Promise.all(
|
|
55436
55480
|
LOCKFILES.map(async (name) => {
|
|
55437
|
-
const content = await readUtf8IfExists(
|
|
55481
|
+
const content = await readUtf8IfExists(import_path18.default.join(cwd, name));
|
|
55438
55482
|
if (content !== null) lockfiles.set(name, content);
|
|
55439
55483
|
})
|
|
55440
55484
|
);
|
|
@@ -55455,7 +55499,7 @@ var readDependencyInputs = async (cwd) => {
|
|
|
55455
55499
|
let lockfiles;
|
|
55456
55500
|
try {
|
|
55457
55501
|
[packageJson, lockfiles] = await Promise.all([
|
|
55458
|
-
(0,
|
|
55502
|
+
(0, import_promises11.readFile)(import_path18.default.join(cwd, "package.json"), "utf8"),
|
|
55459
55503
|
readLockfiles(cwd)
|
|
55460
55504
|
]);
|
|
55461
55505
|
} catch (error2) {
|
|
@@ -55482,10 +55526,10 @@ var readInstallState = async (statePath) => {
|
|
|
55482
55526
|
}
|
|
55483
55527
|
};
|
|
55484
55528
|
var hasInstalledDependencies = async (cwd) => {
|
|
55485
|
-
if (await pathHasKind(
|
|
55529
|
+
if (await pathHasKind(import_path18.default.join(cwd, "node_modules"), "dir")) return true;
|
|
55486
55530
|
const [pnpCjs, pnpJs] = await Promise.all([
|
|
55487
|
-
pathHasKind(
|
|
55488
|
-
pathHasKind(
|
|
55531
|
+
pathHasKind(import_path18.default.join(cwd, ".pnp.cjs"), "file"),
|
|
55532
|
+
pathHasKind(import_path18.default.join(cwd, ".pnp.js"), "file")
|
|
55489
55533
|
]);
|
|
55490
55534
|
return pnpCjs || pnpJs;
|
|
55491
55535
|
};
|
|
@@ -55513,9 +55557,9 @@ var writeInstallState = async (statePath, fingerprint, toolchain) => {
|
|
|
55513
55557
|
);
|
|
55514
55558
|
}
|
|
55515
55559
|
};
|
|
55516
|
-
var installLockPath = (cwd) =>
|
|
55517
|
-
var installStatePath = (cwd) =>
|
|
55518
|
-
var installLogPath = (cwd) =>
|
|
55560
|
+
var installLockPath = (cwd) => import_path18.default.join(cwd, RUNTIME_DIR2, INSTALL_LOCK);
|
|
55561
|
+
var installStatePath = (cwd) => import_path18.default.join(cwd, RUNTIME_DIR2, INSTALL_STATE);
|
|
55562
|
+
var installLogPath = (cwd) => import_path18.default.join(cwd, LOG_DIR, INSTALL_LOG);
|
|
55519
55563
|
var inspectInstallation = async (cwd) => {
|
|
55520
55564
|
if (await pathExists(installLockPath(cwd))) {
|
|
55521
55565
|
return {
|
|
@@ -55567,7 +55611,7 @@ var installDependenciesWhileLocked = async (cwd, { force }) => {
|
|
|
55567
55611
|
}
|
|
55568
55612
|
if (previousState?.fingerprint === fingerprint) {
|
|
55569
55613
|
try {
|
|
55570
|
-
await (0,
|
|
55614
|
+
await (0, import_promises11.rm)(statePath, { force: true });
|
|
55571
55615
|
} catch (error2) {
|
|
55572
55616
|
throw new LinkqueCliError(
|
|
55573
55617
|
"INSTALL_STATE_WRITE_FAILED",
|
|
@@ -55615,14 +55659,14 @@ var installDependencies = async (cwd, { force = false } = {}) => withWorkspaceLo
|
|
|
55615
55659
|
);
|
|
55616
55660
|
|
|
55617
55661
|
// src/commands/setup.ts
|
|
55618
|
-
var
|
|
55662
|
+
var import_path19 = __toESM(require("path"));
|
|
55619
55663
|
var CONFIG_FILE = "linkque.config.json";
|
|
55620
55664
|
var INITIAL_CONFIG = {
|
|
55621
55665
|
managedBy: "linkquejs",
|
|
55622
55666
|
schemaVersion: 1
|
|
55623
55667
|
};
|
|
55624
55668
|
var assertSupportedProject = async (cwd) => {
|
|
55625
|
-
const packageJson = await readUtf8IfExists(
|
|
55669
|
+
const packageJson = await readUtf8IfExists(import_path19.default.join(cwd, "package.json"));
|
|
55626
55670
|
if (packageJson === null) {
|
|
55627
55671
|
throw new LinkqueCliError(
|
|
55628
55672
|
"SETUP_PROJECT_UNSUPPORTED",
|
|
@@ -55661,11 +55705,11 @@ var inspectExistingConfig = async (configPath) => {
|
|
|
55661
55705
|
};
|
|
55662
55706
|
var inspectProjectSetup = async (cwd) => {
|
|
55663
55707
|
await assertSupportedProject(cwd);
|
|
55664
|
-
return await inspectExistingConfig(
|
|
55708
|
+
return await inspectExistingConfig(import_path19.default.join(cwd, CONFIG_FILE));
|
|
55665
55709
|
};
|
|
55666
55710
|
var setupProject = async (cwd) => {
|
|
55667
55711
|
await assertSupportedProject(cwd);
|
|
55668
|
-
const configPath =
|
|
55712
|
+
const configPath = import_path19.default.join(cwd, CONFIG_FILE);
|
|
55669
55713
|
if (await inspectExistingConfig(configPath)) {
|
|
55670
55714
|
return { changed: false, managedFiles: [] };
|
|
55671
55715
|
}
|
|
@@ -55712,10 +55756,10 @@ var inspectWorkspaceStatus = async (cwd) => {
|
|
|
55712
55756
|
|
|
55713
55757
|
// src/commands/build/archive.ts
|
|
55714
55758
|
var import_crypto6 = require("crypto");
|
|
55715
|
-
var
|
|
55716
|
-
var
|
|
55759
|
+
var import_promises12 = require("fs/promises");
|
|
55760
|
+
var import_path20 = __toESM(require("path"));
|
|
55717
55761
|
var import_stream = require("stream");
|
|
55718
|
-
var
|
|
55762
|
+
var import_promises13 = require("stream/promises");
|
|
55719
55763
|
|
|
55720
55764
|
// ../../node_modules/@zip.js/zip.js/lib/zip-fs-wasm.js
|
|
55721
55765
|
init_configuration();
|
|
@@ -59051,7 +59095,7 @@ var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
|
|
|
59051
59095
|
const visit = async (current) => {
|
|
59052
59096
|
let entries;
|
|
59053
59097
|
try {
|
|
59054
|
-
entries = await (0,
|
|
59098
|
+
entries = await (0, import_promises12.readdir)(current, { withFileTypes: true });
|
|
59055
59099
|
} catch (error2) {
|
|
59056
59100
|
if (isNodeError(error2, "ENOENT")) return [];
|
|
59057
59101
|
throw error2;
|
|
@@ -59059,13 +59103,13 @@ var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
|
|
|
59059
59103
|
const files = [];
|
|
59060
59104
|
for (const entry of entries) {
|
|
59061
59105
|
if (exclude.has(entry.name)) continue;
|
|
59062
|
-
const absolutePath =
|
|
59106
|
+
const absolutePath = import_path20.default.join(current, entry.name);
|
|
59063
59107
|
if (entry.isDirectory()) {
|
|
59064
59108
|
files.push(...await visit(absolutePath));
|
|
59065
59109
|
} else if (entry.isFile()) {
|
|
59066
59110
|
files.push({
|
|
59067
59111
|
absolutePath,
|
|
59068
|
-
archivePath:
|
|
59112
|
+
archivePath: import_path20.default.relative(root, absolutePath).split(import_path20.default.sep).join("/")
|
|
59069
59113
|
});
|
|
59070
59114
|
}
|
|
59071
59115
|
}
|
|
@@ -59084,7 +59128,7 @@ var HashingArchiveWriter = class extends import_stream.Writable {
|
|
|
59084
59128
|
handle;
|
|
59085
59129
|
size = 0;
|
|
59086
59130
|
async initialize() {
|
|
59087
|
-
this.handle = await (0,
|
|
59131
|
+
this.handle = await (0, import_promises12.open)(this.archivePath, "wx");
|
|
59088
59132
|
}
|
|
59089
59133
|
identity() {
|
|
59090
59134
|
return { sha256: this.hash.digest("hex"), size: this.size };
|
|
@@ -59146,7 +59190,7 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
|
|
|
59146
59190
|
try {
|
|
59147
59191
|
for (const file of files) {
|
|
59148
59192
|
const frozen = frozenContents.get(file.archivePath);
|
|
59149
|
-
const content = frozen ?? await (0,
|
|
59193
|
+
const content = frozen ?? await (0, import_promises12.readFile)(file.absolutePath);
|
|
59150
59194
|
await appendFile(file.archivePath, content);
|
|
59151
59195
|
}
|
|
59152
59196
|
await zip.close();
|
|
@@ -59160,7 +59204,7 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
|
|
|
59160
59204
|
};
|
|
59161
59205
|
} catch (error2) {
|
|
59162
59206
|
output.destroy();
|
|
59163
|
-
await (0,
|
|
59207
|
+
await (0, import_promises13.finished)(output).catch(() => void 0);
|
|
59164
59208
|
if (error2 instanceof LinkqueCliError) throw error2;
|
|
59165
59209
|
throw new LinkqueCliError(
|
|
59166
59210
|
"BUILD_ARCHIVE_FAILED",
|
|
@@ -59183,14 +59227,14 @@ var runBuild = async (cwd) => {
|
|
|
59183
59227
|
command: TOOLCHAIN2,
|
|
59184
59228
|
args: ["run", "build"],
|
|
59185
59229
|
cwd,
|
|
59186
|
-
logPath:
|
|
59230
|
+
logPath: import_path21.default.join(cwd, LOG_PATH),
|
|
59187
59231
|
logHeader: `${TOOLCHAIN2} run build`
|
|
59188
59232
|
});
|
|
59189
59233
|
return exitCode;
|
|
59190
59234
|
};
|
|
59191
59235
|
var assertBuildCommand = async (cwd) => {
|
|
59192
59236
|
const packageJson = parseJsonObject(
|
|
59193
|
-
await (0,
|
|
59237
|
+
await (0, import_promises14.readFile)(import_path21.default.join(cwd, "package.json"), "utf8").catch((error2) => {
|
|
59194
59238
|
throw new LinkqueCliError(
|
|
59195
59239
|
"BUILD_COMMAND_NOT_FOUND",
|
|
59196
59240
|
"workspace package.json must contain a build script",
|
|
@@ -59220,10 +59264,10 @@ var assertBuildOutput = (files) => {
|
|
|
59220
59264
|
}
|
|
59221
59265
|
};
|
|
59222
59266
|
var buildDistWhileLocked = async (cwd) => {
|
|
59223
|
-
const outputPath =
|
|
59224
|
-
const finalPath =
|
|
59267
|
+
const outputPath = import_path21.default.join(cwd, OUTPUT_DIR);
|
|
59268
|
+
const finalPath = import_path21.default.join(cwd, ARCHIVE_PATH);
|
|
59225
59269
|
const tempPath = `${finalPath}.${process.pid}.${(0, import_crypto7.randomUUID)()}.tmp`;
|
|
59226
|
-
await (0,
|
|
59270
|
+
await (0, import_promises14.rm)(finalPath, { force: true }).catch((error2) => {
|
|
59227
59271
|
throw new LinkqueCliError(
|
|
59228
59272
|
"BUILD_ARCHIVE_FAILED",
|
|
59229
59273
|
"stale build archive could not be removed",
|
|
@@ -59248,7 +59292,7 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59248
59292
|
);
|
|
59249
59293
|
}
|
|
59250
59294
|
await assertBuildCommand(cwd);
|
|
59251
|
-
await (0,
|
|
59295
|
+
await (0, import_promises14.rm)(outputPath, { force: true, recursive: true }).catch(
|
|
59252
59296
|
(error2) => {
|
|
59253
59297
|
throw new LinkqueCliError(
|
|
59254
59298
|
"BUILD_FAILED",
|
|
@@ -59283,7 +59327,7 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59283
59327
|
);
|
|
59284
59328
|
}
|
|
59285
59329
|
);
|
|
59286
|
-
await (0,
|
|
59330
|
+
await (0, import_promises14.rename)(tempPath, finalPath).catch((error2) => {
|
|
59287
59331
|
throw new LinkqueCliError(
|
|
59288
59332
|
"BUILD_ARCHIVE_FAILED",
|
|
59289
59333
|
"build archive could not be finalized",
|
|
@@ -59300,8 +59344,8 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59300
59344
|
} catch (error2) {
|
|
59301
59345
|
try {
|
|
59302
59346
|
await Promise.all([
|
|
59303
|
-
(0,
|
|
59304
|
-
(0,
|
|
59347
|
+
(0, import_promises14.rm)(finalPath, { force: true }),
|
|
59348
|
+
(0, import_promises14.rm)(tempPath, { force: true })
|
|
59305
59349
|
]);
|
|
59306
59350
|
} catch (cleanupError) {
|
|
59307
59351
|
throw preservePrimaryFailure(error2, cleanupError);
|
|
@@ -59311,21 +59355,22 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59311
59355
|
};
|
|
59312
59356
|
var buildDist = async (cwd) => withWorkspaceLock(
|
|
59313
59357
|
{
|
|
59314
|
-
path:
|
|
59358
|
+
path: import_path21.default.join(cwd, LOCK_PATH),
|
|
59315
59359
|
name: "build",
|
|
59316
59360
|
acquireErrorCode: "BUILD_LOCK_TIMEOUT",
|
|
59317
59361
|
releaseErrorCode: "BUILD_ARCHIVE_FAILED",
|
|
59318
59362
|
retryMs: LOCK_RETRY_MS3,
|
|
59319
59363
|
timeoutMs: LOCK_TIMEOUT_MS4,
|
|
59320
|
-
onReleaseFailure: () => (0,
|
|
59364
|
+
onReleaseFailure: () => (0, import_promises14.rm)(import_path21.default.join(cwd, ARCHIVE_PATH), { force: true })
|
|
59321
59365
|
},
|
|
59322
59366
|
() => buildDistWhileLocked(cwd)
|
|
59323
59367
|
);
|
|
59324
59368
|
|
|
59325
59369
|
// src/commands/build/snapshot.ts
|
|
59326
59370
|
var import_crypto8 = require("crypto");
|
|
59327
|
-
var
|
|
59328
|
-
var
|
|
59371
|
+
var import_promises15 = require("fs/promises");
|
|
59372
|
+
var import_path22 = __toESM(require("path"));
|
|
59373
|
+
var import_promises16 = require("fs/promises");
|
|
59329
59374
|
var ARTIFACTS_DIR = ".linkque/artifacts";
|
|
59330
59375
|
var AGENT_CONFIG_SOURCE_PATH = "agent_config.json";
|
|
59331
59376
|
var TEMPLATE_ARTIFACT_SOURCE_PATH = "template-artifact.json";
|
|
@@ -59345,8 +59390,8 @@ var snapshotFailure = (message, cause) => cause instanceof LinkqueCliError ? cau
|
|
|
59345
59390
|
var readTemplateVersion = async (cwd) => {
|
|
59346
59391
|
let content;
|
|
59347
59392
|
try {
|
|
59348
|
-
content = await (0,
|
|
59349
|
-
|
|
59393
|
+
content = await (0, import_promises15.readFile)(
|
|
59394
|
+
import_path22.default.join(cwd, TEMPLATE_ARTIFACT_SOURCE_PATH),
|
|
59350
59395
|
"utf8"
|
|
59351
59396
|
);
|
|
59352
59397
|
} catch (error2) {
|
|
@@ -59366,15 +59411,15 @@ var readTemplateVersion = async (cwd) => {
|
|
|
59366
59411
|
};
|
|
59367
59412
|
var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
59368
59413
|
const snapshotDir = `snapshot-${(0, import_crypto8.randomUUID)()}`;
|
|
59369
|
-
const relDir =
|
|
59370
|
-
const dirPath =
|
|
59371
|
-
const archiveRel =
|
|
59372
|
-
const finalPath =
|
|
59414
|
+
const relDir = import_path22.default.join(ARTIFACTS_DIR, snapshotDir);
|
|
59415
|
+
const dirPath = import_path22.default.join(cwd, relDir);
|
|
59416
|
+
const archiveRel = import_path22.default.join(relDir, "source.zip");
|
|
59417
|
+
const finalPath = import_path22.default.join(cwd, archiveRel);
|
|
59373
59418
|
const tempPath = `${finalPath}.${process.pid}.tmp`;
|
|
59374
59419
|
try {
|
|
59375
59420
|
let rootStat;
|
|
59376
59421
|
try {
|
|
59377
|
-
rootStat = await (0,
|
|
59422
|
+
rootStat = await (0, import_promises15.lstat)(cwd, { bigint: true });
|
|
59378
59423
|
} catch (error2) {
|
|
59379
59424
|
throw snapshotFailure("workspace source could not be inspected", error2);
|
|
59380
59425
|
}
|
|
@@ -59384,32 +59429,45 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
|
59384
59429
|
"snapshot root must be a directory"
|
|
59385
59430
|
);
|
|
59386
59431
|
}
|
|
59432
|
+
const cardSource = splitAgentCards(
|
|
59433
|
+
await readAgentCards(import_path22.default.join(cwd, AGENT_CONFIG_SOURCE_PATH))
|
|
59434
|
+
);
|
|
59435
|
+
const cardFilesPath = import_path22.default.join(relDir, "card-files.json");
|
|
59436
|
+
await ensureParentDir(import_path22.default.join(cwd, cardFilesPath));
|
|
59437
|
+
await (0, import_promises16.writeFile)(import_path22.default.join(cwd, cardFilesPath), canonicalJson(cardSource));
|
|
59387
59438
|
const excludedComponents = new Set(BASE_EXCLUDED_COMPONENTS);
|
|
59388
59439
|
if (options.excludePlatformSdk) excludedComponents.add(".platform-sdk");
|
|
59389
|
-
const
|
|
59440
|
+
const walkedFiles = await walkFiles(cwd, excludedComponents).catch(
|
|
59390
59441
|
(error2) => {
|
|
59391
59442
|
throw snapshotFailure("workspace source could not be inspected", error2);
|
|
59392
59443
|
}
|
|
59393
59444
|
);
|
|
59394
|
-
const
|
|
59395
|
-
|
|
59396
|
-
|
|
59397
|
-
|
|
59398
|
-
|
|
59399
|
-
|
|
59400
|
-
|
|
59401
|
-
|
|
59402
|
-
|
|
59403
|
-
|
|
59404
|
-
|
|
59445
|
+
const files = [
|
|
59446
|
+
...walkedFiles.filter((file) => !file.archivePath.startsWith("cards/")),
|
|
59447
|
+
...Object.keys(cardSource.files).map((archivePath) => ({
|
|
59448
|
+
archivePath,
|
|
59449
|
+
absolutePath: import_path22.default.join(cwd, archivePath)
|
|
59450
|
+
}))
|
|
59451
|
+
].sort(
|
|
59452
|
+
(a, b3) => a.archivePath < b3.archivePath ? -1 : a.archivePath > b3.archivePath ? 1 : 0
|
|
59453
|
+
);
|
|
59454
|
+
const agentConfigContent = Buffer.from(
|
|
59455
|
+
JSON.stringify(cardSource.config, null, 2) + "\n"
|
|
59456
|
+
);
|
|
59405
59457
|
if (!files.some((file) => file.archivePath === AGENT_CONFIG_SOURCE_PATH)) {
|
|
59406
59458
|
throw new LinkqueCliError(
|
|
59407
59459
|
"SNAPSHOT_FAILED",
|
|
59408
59460
|
"agent_config.json is not part of the walked source tree"
|
|
59409
59461
|
);
|
|
59410
59462
|
}
|
|
59411
|
-
const frozenContents =
|
|
59412
|
-
[AGENT_CONFIG_SOURCE_PATH, agentConfigContent]
|
|
59463
|
+
const frozenContents = new Map([
|
|
59464
|
+
[AGENT_CONFIG_SOURCE_PATH, agentConfigContent],
|
|
59465
|
+
...Object.entries(cardSource.files).map(
|
|
59466
|
+
([file, value]) => [
|
|
59467
|
+
file,
|
|
59468
|
+
Buffer.from(canonicalJson(value))
|
|
59469
|
+
]
|
|
59470
|
+
)
|
|
59413
59471
|
]);
|
|
59414
59472
|
const templateVersion = await readTemplateVersion(cwd);
|
|
59415
59473
|
await ensureParentDir(finalPath);
|
|
@@ -59425,7 +59483,7 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
|
59425
59483
|
error2
|
|
59426
59484
|
);
|
|
59427
59485
|
});
|
|
59428
|
-
await (0,
|
|
59486
|
+
await (0, import_promises15.rename)(tempPath, finalPath).catch((error2) => {
|
|
59429
59487
|
throw new LinkqueCliError(
|
|
59430
59488
|
"SNAPSHOT_FAILED",
|
|
59431
59489
|
"source archive could not be finalized",
|
|
@@ -59440,20 +59498,21 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
|
59440
59498
|
totalBytes: identity.sourceBytes,
|
|
59441
59499
|
sourceChecksum: identity.sourceChecksum,
|
|
59442
59500
|
agentConfigBase64: agentConfigContent.toString("base64"),
|
|
59501
|
+
cardFilesPath,
|
|
59443
59502
|
...templateVersion ? { templateVersion } : {}
|
|
59444
59503
|
};
|
|
59445
59504
|
} catch (error2) {
|
|
59446
59505
|
try {
|
|
59447
|
-
await (0,
|
|
59506
|
+
await (0, import_promises15.rm)(dirPath, { force: true, recursive: true });
|
|
59448
59507
|
} catch (cleanupError) {
|
|
59449
59508
|
throw preservePrimaryFailure(error2, cleanupError);
|
|
59450
59509
|
}
|
|
59451
|
-
throw error2;
|
|
59510
|
+
throw snapshotFailure("workspace snapshot could not be created", error2);
|
|
59452
59511
|
}
|
|
59453
59512
|
};
|
|
59454
59513
|
var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
|
|
59455
59514
|
{
|
|
59456
|
-
path:
|
|
59515
|
+
path: import_path22.default.join(cwd, LOCK_PATH2),
|
|
59457
59516
|
name: "snapshot",
|
|
59458
59517
|
acquireErrorCode: "SNAPSHOT_FAILED",
|
|
59459
59518
|
releaseErrorCode: "SNAPSHOT_FAILED",
|
|
@@ -59466,12 +59525,12 @@ var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
|
|
|
59466
59525
|
|
|
59467
59526
|
// src/commands/card/index.ts
|
|
59468
59527
|
var import_crypto9 = require("crypto");
|
|
59469
|
-
var
|
|
59470
|
-
var
|
|
59528
|
+
var import_promises18 = require("fs/promises");
|
|
59529
|
+
var import_path24 = __toESM(require("path"));
|
|
59471
59530
|
|
|
59472
59531
|
// src/commands/mcpDescribe.ts
|
|
59473
|
-
var
|
|
59474
|
-
var
|
|
59532
|
+
var import_promises17 = require("fs/promises");
|
|
59533
|
+
var import_path23 = __toESM(require("path"));
|
|
59475
59534
|
var MCP_DETAIL_ENDPOINT_ENV = "LINKQUE_MCP_DETAIL_ENDPOINT";
|
|
59476
59535
|
var MCP_DETAIL_ENABLED_ENV = "LINKQUE_MCP_DETAIL_ENABLED";
|
|
59477
59536
|
var TIMEOUT_MS = 15e3;
|
|
@@ -59540,7 +59599,7 @@ function requireEnabled(env) {
|
|
|
59540
59599
|
async function readMountedMcp(cwd, resourceId) {
|
|
59541
59600
|
let content;
|
|
59542
59601
|
try {
|
|
59543
|
-
content = await (0,
|
|
59602
|
+
content = await (0, import_promises17.readFile)(import_path23.default.join(cwd, "agent_config.json"));
|
|
59544
59603
|
} catch {
|
|
59545
59604
|
throw new LinkqueCliError(
|
|
59546
59605
|
"MCP_CONFIG_READ_FAILED",
|
|
@@ -59821,7 +59880,7 @@ var SHA256_PATTERN = /^[0-9a-f]{64}$/u;
|
|
|
59821
59880
|
async function listCardDrafts(cwd) {
|
|
59822
59881
|
const [directories, configModifiedAt, runtimeSupportedSchemaVersions] = await Promise.all([
|
|
59823
59882
|
listDraftDirectories(cwd),
|
|
59824
|
-
readModifiedAt(
|
|
59883
|
+
readModifiedAt(import_path24.default.join(cwd, AGENT_CONFIG_PATH)),
|
|
59825
59884
|
readRuntimeSupportedSchemaVersions(cwd)
|
|
59826
59885
|
]);
|
|
59827
59886
|
const drafts = await Promise.all(
|
|
@@ -59833,7 +59892,7 @@ async function readCardDraft(cwd, draftId) {
|
|
|
59833
59892
|
assertDraftId(draftId);
|
|
59834
59893
|
const directory = draftDirectory(cwd, draftId);
|
|
59835
59894
|
const stateValue = await readRequiredJson(
|
|
59836
|
-
|
|
59895
|
+
import_path24.default.join(directory, "state.json"),
|
|
59837
59896
|
"CARD_DRAFT_NOT_FOUND"
|
|
59838
59897
|
);
|
|
59839
59898
|
const state = parseCardDraftState(stateValue);
|
|
@@ -59845,8 +59904,8 @@ async function readCardDraft(cwd, draftId) {
|
|
|
59845
59904
|
}
|
|
59846
59905
|
const [bundle, savedValue, theme] = await Promise.all([
|
|
59847
59906
|
readBundle(directory, draftId),
|
|
59848
|
-
readOptionalJson(
|
|
59849
|
-
readOptionalJsonObject(
|
|
59907
|
+
readOptionalJson(import_path24.default.join(directory, "saved.json")),
|
|
59908
|
+
readOptionalJsonObject(import_path24.default.join(cwd, THEME_PATH))
|
|
59850
59909
|
]);
|
|
59851
59910
|
const saved = parseSavedMarker(savedValue);
|
|
59852
59911
|
return {
|
|
@@ -59874,13 +59933,13 @@ async function prepareCardBindingContext(cwd, draftId, resourceIds, env = proces
|
|
|
59874
59933
|
}
|
|
59875
59934
|
const selectedIds = [...new Set(resourceIds)];
|
|
59876
59935
|
const directory = draftDirectory(cwd, draftId);
|
|
59877
|
-
const contextPath =
|
|
59878
|
-
const file =
|
|
59936
|
+
const contextPath = import_path24.default.join(DRAFT_ROOT, draftId, "binding-context.json");
|
|
59937
|
+
const file = import_path24.default.join(cwd, contextPath);
|
|
59879
59938
|
await assertBindingContextDirectory(cwd, directory);
|
|
59880
59939
|
const bundle = await readBundle(directory, draftId);
|
|
59881
59940
|
const readConfig = async () => parseAgentConfig(
|
|
59882
59941
|
await readRequiredJsonWithLimit(
|
|
59883
|
-
|
|
59942
|
+
import_path24.default.join(cwd, AGENT_CONFIG_PATH),
|
|
59884
59943
|
AGENT_CONFIG_MAX_BYTES
|
|
59885
59944
|
)
|
|
59886
59945
|
);
|
|
@@ -59984,15 +60043,15 @@ async function prepareCardBindingContext(cwd, draftId, resourceIds, env = proces
|
|
|
59984
60043
|
}
|
|
59985
60044
|
async function assertBindingContextDirectory(cwd, directory) {
|
|
59986
60045
|
try {
|
|
59987
|
-
const canonicalWorkspace = await (0,
|
|
59988
|
-
if (await (0,
|
|
60046
|
+
const canonicalWorkspace = await (0, import_promises18.realpath)(cwd);
|
|
60047
|
+
if (await (0, import_promises18.realpath)(directory) !== import_path24.default.join(canonicalWorkspace, import_path24.default.relative(cwd, directory))) {
|
|
59989
60048
|
throw new LinkqueCliError(
|
|
59990
60049
|
"CARD_DRAFT_INVALID",
|
|
59991
60050
|
"\u7ED1\u5B9A\u4E0A\u4E0B\u6587\u4E0D\u80FD\u4F4D\u4E8E\u7B26\u53F7\u94FE\u63A5\u76EE\u5F55"
|
|
59992
60051
|
);
|
|
59993
60052
|
}
|
|
59994
|
-
const entry = await (0,
|
|
59995
|
-
|
|
60053
|
+
const entry = await (0, import_promises18.lstat)(
|
|
60054
|
+
import_path24.default.join(directory, "binding-context.json")
|
|
59996
60055
|
).catch((cause) => {
|
|
59997
60056
|
if (isNodeError(cause, "ENOENT")) return void 0;
|
|
59998
60057
|
throw cause;
|
|
@@ -60017,7 +60076,7 @@ async function finalizeCard(cwd, draftId, expectedDraftChecksum, _contextChecksu
|
|
|
60017
60076
|
assertChecksum(expectedDraftChecksum, "\u8349\u7A3F checksum");
|
|
60018
60077
|
return withWorkspaceLock(
|
|
60019
60078
|
{
|
|
60020
|
-
path:
|
|
60079
|
+
path: import_path24.default.join(cwd, FINALIZE_LOCK_PATH),
|
|
60021
60080
|
name: "card finalize",
|
|
60022
60081
|
acquireErrorCode: "CARD_FINALIZE_LOCK_TIMEOUT",
|
|
60023
60082
|
releaseErrorCode: "CARD_FINALIZE_LOCK_RELEASE_FAILED",
|
|
@@ -60028,7 +60087,7 @@ async function finalizeCard(cwd, draftId, expectedDraftChecksum, _contextChecksu
|
|
|
60028
60087
|
);
|
|
60029
60088
|
}
|
|
60030
60089
|
async function finalizeCardFromRequest(cwd, requestFile) {
|
|
60031
|
-
const value = await readRequiredJson(
|
|
60090
|
+
const value = await readRequiredJson(import_path24.default.resolve(cwd, requestFile));
|
|
60032
60091
|
if (!isJsonObject(value) || value.version !== 1 || typeof value.draftId !== "string" || typeof value.expectedDraftChecksum !== "string" || value.contextChecksum !== void 0 && typeof value.contextChecksum !== "string" || Object.keys(value).some(
|
|
60033
60092
|
(key) => ![
|
|
60034
60093
|
"version",
|
|
@@ -60052,7 +60111,7 @@ async function finalizeCardFromRequest(cwd, requestFile) {
|
|
|
60052
60111
|
}
|
|
60053
60112
|
async function previewCardTransformFromRequest(cwd, requestFile) {
|
|
60054
60113
|
const value = await readRequiredJsonWithLimit(
|
|
60055
|
-
|
|
60114
|
+
import_path24.default.resolve(cwd, requestFile),
|
|
60056
60115
|
TRANSFORM_PREVIEW_REQUEST_MAX_BYTES
|
|
60057
60116
|
);
|
|
60058
60117
|
if (!isCardTransformPreviewRequest(value)) {
|
|
@@ -60101,7 +60160,7 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
|
|
|
60101
60160
|
const payload = parseRollbackToken(rollbackToken);
|
|
60102
60161
|
return withWorkspaceLock(
|
|
60103
60162
|
{
|
|
60104
|
-
path:
|
|
60163
|
+
path: import_path24.default.join(cwd, FINALIZE_LOCK_PATH),
|
|
60105
60164
|
name: "card rollback",
|
|
60106
60165
|
acquireErrorCode: "CARD_FINALIZE_LOCK_TIMEOUT",
|
|
60107
60166
|
releaseErrorCode: "CARD_FINALIZE_LOCK_RELEASE_FAILED",
|
|
@@ -60109,8 +60168,8 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
|
|
|
60109
60168
|
timeoutMs: FINALIZE_LOCK_TIMEOUT_MS
|
|
60110
60169
|
},
|
|
60111
60170
|
async () => {
|
|
60112
|
-
const configPath =
|
|
60113
|
-
const current = await (0,
|
|
60171
|
+
const configPath = import_path24.default.join(cwd, AGENT_CONFIG_PATH);
|
|
60172
|
+
const current = await (0, import_promises18.readFile)(configPath);
|
|
60114
60173
|
if (checksumBytes(current) !== payload.expectedConfigChecksum) {
|
|
60115
60174
|
throw new LinkqueCliError(
|
|
60116
60175
|
"CARD_FINALIZE_CONFLICT",
|
|
@@ -60137,8 +60196,8 @@ async function validateCardBindingsFromDisk(cwd, draftId, fieldId) {
|
|
|
60137
60196
|
async function validateCardBindingsForBundle(cwd, draftId, bundle, fieldId) {
|
|
60138
60197
|
const directory = draftDirectory(cwd, draftId);
|
|
60139
60198
|
const [contextValue, configValue] = await Promise.all([
|
|
60140
|
-
readOptionalJson(
|
|
60141
|
-
|
|
60199
|
+
readOptionalJson(import_path24.default.join(directory, "binding-context.json")),
|
|
60200
|
+
readAgentCards(import_path24.default.join(cwd, AGENT_CONFIG_PATH))
|
|
60142
60201
|
]);
|
|
60143
60202
|
const context = parseOptionalBindingContext(contextValue);
|
|
60144
60203
|
const draftStructureChecksum = createA2UICardDraftStructureChecksum(bundle);
|
|
@@ -60246,13 +60305,11 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60246
60305
|
}
|
|
60247
60306
|
}
|
|
60248
60307
|
const context = parseOptionalBindingContext(
|
|
60249
|
-
await readOptionalJson(
|
|
60250
|
-
);
|
|
60251
|
-
const configPath = import_path23.default.join(cwd, AGENT_CONFIG_PATH);
|
|
60252
|
-
const oldConfigBytes = await (0, import_promises16.readFile)(configPath);
|
|
60253
|
-
const config3 = parseAgentConfig(
|
|
60254
|
-
JSON.parse(oldConfigBytes.toString("utf8"))
|
|
60308
|
+
await readOptionalJson(import_path24.default.join(directory, "binding-context.json"))
|
|
60255
60309
|
);
|
|
60310
|
+
const configPath = import_path24.default.join(cwd, AGENT_CONFIG_PATH);
|
|
60311
|
+
const oldConfigBytes = await (0, import_promises18.readFile)(configPath);
|
|
60312
|
+
const config3 = parseAgentConfig(await readAgentCards(configPath));
|
|
60256
60313
|
const resources = config3.agent.resources;
|
|
60257
60314
|
const existingIndex = resources.findIndex(
|
|
60258
60315
|
(resource) => resource.resourceType === "CARD" && resource.resourceId === bundle.manifest.resourceId
|
|
@@ -60286,7 +60343,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60286
60343
|
agent: { ...config3.agent, resources: nextResources }
|
|
60287
60344
|
};
|
|
60288
60345
|
const nextConfigBytes = Buffer.from(
|
|
60289
|
-
`${JSON.stringify(nextConfig, null, 2)}
|
|
60346
|
+
`${JSON.stringify(splitAgentCards(nextConfig).config, null, 2)}
|
|
60290
60347
|
`,
|
|
60291
60348
|
"utf8"
|
|
60292
60349
|
);
|
|
@@ -60303,12 +60360,15 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60303
60360
|
manifest: { ...bundle.manifest, baseRevision: cardRevision }
|
|
60304
60361
|
};
|
|
60305
60362
|
const rebasedDraftChecksum = draftChecksum(rebasedBundle);
|
|
60306
|
-
await
|
|
60363
|
+
await writeAgentCards(
|
|
60364
|
+
configPath,
|
|
60365
|
+
nextConfig
|
|
60366
|
+
);
|
|
60307
60367
|
const savedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
60308
60368
|
try {
|
|
60309
60369
|
await Promise.all([
|
|
60310
60370
|
atomicWrite(
|
|
60311
|
-
|
|
60371
|
+
import_path24.default.join(directory, "saved.json"),
|
|
60312
60372
|
Buffer.from(
|
|
60313
60373
|
`${JSON.stringify(
|
|
60314
60374
|
{
|
|
@@ -60325,7 +60385,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60325
60385
|
)
|
|
60326
60386
|
),
|
|
60327
60387
|
atomicWrite(
|
|
60328
|
-
|
|
60388
|
+
import_path24.default.join(directory, "state.json"),
|
|
60329
60389
|
Buffer.from(
|
|
60330
60390
|
`${JSON.stringify(
|
|
60331
60391
|
{ version: 1, status: "ready", updatedAt: savedAt },
|
|
@@ -60370,7 +60430,7 @@ async function inspectDraft(cwd, directory) {
|
|
|
60370
60430
|
);
|
|
60371
60431
|
}
|
|
60372
60432
|
const root = draftDirectory(cwd, draftId);
|
|
60373
|
-
const stateValue = await readOptionalJson(
|
|
60433
|
+
const stateValue = await readOptionalJson(import_path24.default.join(root, "state.json"));
|
|
60374
60434
|
if (stateValue === void 0) {
|
|
60375
60435
|
return invalidDraft(
|
|
60376
60436
|
draftId,
|
|
@@ -60401,7 +60461,7 @@ async function inspectDraft(cwd, directory) {
|
|
|
60401
60461
|
try {
|
|
60402
60462
|
const bundle = await readBundle(root, draftId);
|
|
60403
60463
|
const saved = parseSavedMarker(
|
|
60404
|
-
await readOptionalJson(
|
|
60464
|
+
await readOptionalJson(import_path24.default.join(root, "saved.json"))
|
|
60405
60465
|
);
|
|
60406
60466
|
return {
|
|
60407
60467
|
checksum: draftChecksum(bundle),
|
|
@@ -60422,9 +60482,9 @@ async function inspectDraft(cwd, directory) {
|
|
|
60422
60482
|
}
|
|
60423
60483
|
async function readBundle(directory, draftId) {
|
|
60424
60484
|
const [manifest, card, fixture] = await Promise.all([
|
|
60425
|
-
readRequiredJson(
|
|
60426
|
-
readRequiredJson(
|
|
60427
|
-
readRequiredJson(
|
|
60485
|
+
readRequiredJson(import_path24.default.join(directory, "manifest.json")),
|
|
60486
|
+
readRequiredJson(import_path24.default.join(directory, "card.json")),
|
|
60487
|
+
readRequiredJson(import_path24.default.join(directory, "fixture.json"))
|
|
60428
60488
|
]);
|
|
60429
60489
|
const parsed = parseA2UICardDraftBundle({ manifest, card, fixture });
|
|
60430
60490
|
if (!parsed.success || parsed.data.manifest.draftId !== draftId) {
|
|
@@ -60436,10 +60496,10 @@ async function readBundle(directory, draftId) {
|
|
|
60436
60496
|
return parsed.data;
|
|
60437
60497
|
}
|
|
60438
60498
|
async function listDraftDirectories(cwd) {
|
|
60439
|
-
const root =
|
|
60499
|
+
const root = import_path24.default.join(cwd, DRAFT_ROOT);
|
|
60440
60500
|
let entries;
|
|
60441
60501
|
try {
|
|
60442
|
-
entries = await (0,
|
|
60502
|
+
entries = await (0, import_promises18.readdir)(root, { withFileTypes: true });
|
|
60443
60503
|
} catch (cause) {
|
|
60444
60504
|
if (isNodeError(cause, "ENOENT")) return [];
|
|
60445
60505
|
throw new LinkqueCliError(
|
|
@@ -60451,7 +60511,7 @@ async function listDraftDirectories(cwd) {
|
|
|
60451
60511
|
const directories = await Promise.all(
|
|
60452
60512
|
entries.filter((entry) => entry.isDirectory()).map(async (entry) => ({
|
|
60453
60513
|
draftId: entry.name,
|
|
60454
|
-
modifiedAt: await readModifiedAt(
|
|
60514
|
+
modifiedAt: await readModifiedAt(import_path24.default.join(root, entry.name))
|
|
60455
60515
|
}))
|
|
60456
60516
|
);
|
|
60457
60517
|
if (directories.length > DRAFT_LIST_LIMIT) {
|
|
@@ -60478,11 +60538,11 @@ function draftIssue(code, message, recoverable, severity) {
|
|
|
60478
60538
|
}
|
|
60479
60539
|
async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
|
|
60480
60540
|
try {
|
|
60481
|
-
const content = await (0,
|
|
60541
|
+
const content = await (0, import_promises18.readFile)(file, "utf8");
|
|
60482
60542
|
if (Buffer.byteLength(content, "utf8") > DRAFT_FILE_MAX_BYTES) {
|
|
60483
60543
|
throw new LinkqueCliError(
|
|
60484
60544
|
"CARD_DRAFT_INVALID",
|
|
60485
|
-
`${
|
|
60545
|
+
`${import_path24.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
|
|
60486
60546
|
);
|
|
60487
60547
|
}
|
|
60488
60548
|
return JSON.parse(content);
|
|
@@ -60491,31 +60551,31 @@ async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
|
|
|
60491
60551
|
if (isNodeError(cause, "ENOENT")) {
|
|
60492
60552
|
throw new LinkqueCliError(
|
|
60493
60553
|
missingCode,
|
|
60494
|
-
`\u8349\u7A3F\u6587\u4EF6\u7F3A\u5931: ${
|
|
60554
|
+
`\u8349\u7A3F\u6587\u4EF6\u7F3A\u5931: ${import_path24.default.basename(file)}`,
|
|
60495
60555
|
{ cause }
|
|
60496
60556
|
);
|
|
60497
60557
|
}
|
|
60498
60558
|
if (cause instanceof SyntaxError) {
|
|
60499
60559
|
throw new LinkqueCliError(
|
|
60500
60560
|
"CARD_DRAFT_INVALID",
|
|
60501
|
-
`\u8349\u7A3F\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${
|
|
60561
|
+
`\u8349\u7A3F\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path24.default.basename(file)}`,
|
|
60502
60562
|
{ cause }
|
|
60503
60563
|
);
|
|
60504
60564
|
}
|
|
60505
60565
|
throw new LinkqueCliError(
|
|
60506
60566
|
"CARD_DRAFT_READ_FAILED",
|
|
60507
|
-
`\u8349\u7A3F\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${
|
|
60567
|
+
`\u8349\u7A3F\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path24.default.basename(file)}`,
|
|
60508
60568
|
{ cause: cause instanceof Error ? cause : void 0 }
|
|
60509
60569
|
);
|
|
60510
60570
|
}
|
|
60511
60571
|
}
|
|
60512
60572
|
async function readRequiredJsonWithLimit(file, maxBytes) {
|
|
60513
60573
|
try {
|
|
60514
|
-
const content = await (0,
|
|
60574
|
+
const content = await (0, import_promises18.readFile)(file, "utf8");
|
|
60515
60575
|
if (Buffer.byteLength(content, "utf8") > maxBytes) {
|
|
60516
60576
|
throw new LinkqueCliError(
|
|
60517
60577
|
"CARD_DRAFT_INVALID",
|
|
60518
|
-
`${
|
|
60578
|
+
`${import_path24.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
|
|
60519
60579
|
);
|
|
60520
60580
|
}
|
|
60521
60581
|
return JSON.parse(content);
|
|
@@ -60524,20 +60584,20 @@ async function readRequiredJsonWithLimit(file, maxBytes) {
|
|
|
60524
60584
|
if (isNodeError(cause, "ENOENT")) {
|
|
60525
60585
|
throw new LinkqueCliError(
|
|
60526
60586
|
"CARD_DRAFT_NOT_FOUND",
|
|
60527
|
-
`\u8BF7\u6C42\u6587\u4EF6\u7F3A\u5931: ${
|
|
60587
|
+
`\u8BF7\u6C42\u6587\u4EF6\u7F3A\u5931: ${import_path24.default.basename(file)}`,
|
|
60528
60588
|
{ cause }
|
|
60529
60589
|
);
|
|
60530
60590
|
}
|
|
60531
60591
|
if (cause instanceof SyntaxError) {
|
|
60532
60592
|
throw new LinkqueCliError(
|
|
60533
60593
|
"CARD_DRAFT_INVALID",
|
|
60534
|
-
`\u8BF7\u6C42\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${
|
|
60594
|
+
`\u8BF7\u6C42\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path24.default.basename(file)}`,
|
|
60535
60595
|
{ cause }
|
|
60536
60596
|
);
|
|
60537
60597
|
}
|
|
60538
60598
|
throw new LinkqueCliError(
|
|
60539
60599
|
"CARD_DRAFT_READ_FAILED",
|
|
60540
|
-
`\u8BF7\u6C42\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${
|
|
60600
|
+
`\u8BF7\u6C42\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path24.default.basename(file)}`,
|
|
60541
60601
|
{ cause: cause instanceof Error ? cause : void 0 }
|
|
60542
60602
|
);
|
|
60543
60603
|
}
|
|
@@ -60561,7 +60621,7 @@ async function readOptionalJson(file) {
|
|
|
60561
60621
|
}
|
|
60562
60622
|
async function readRuntimeSupportedSchemaVersions(cwd) {
|
|
60563
60623
|
const value = await readOptionalJson(
|
|
60564
|
-
|
|
60624
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60565
60625
|
).catch(() => void 0);
|
|
60566
60626
|
if (!isJsonObject(value) || value.schemaVersion !== 1) {
|
|
60567
60627
|
return [...LEGACY_RUNTIME_CARD_SCHEMA_VERSIONS];
|
|
@@ -60580,19 +60640,19 @@ async function readRuntimeSupportedSchemaVersions(cwd) {
|
|
|
60580
60640
|
}
|
|
60581
60641
|
async function readRuntimeSupportsFunctionActions(cwd) {
|
|
60582
60642
|
const value = await readOptionalJson(
|
|
60583
|
-
|
|
60643
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60584
60644
|
).catch(() => void 0);
|
|
60585
60645
|
return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.frontendFunctionActions === true;
|
|
60586
60646
|
}
|
|
60587
60647
|
async function readRuntimeSupportsDataPipeline(cwd) {
|
|
60588
60648
|
const value = await readOptionalJson(
|
|
60589
|
-
|
|
60649
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60590
60650
|
).catch(() => void 0);
|
|
60591
60651
|
return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.serverDataPipeline === true;
|
|
60592
60652
|
}
|
|
60593
60653
|
async function readRuntimeSupportsModelFilledPipelineArguments(cwd) {
|
|
60594
60654
|
const value = await readOptionalJson(
|
|
60595
|
-
|
|
60655
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60596
60656
|
).catch(() => void 0);
|
|
60597
60657
|
return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.serverDataPipeline === true && value.a2uiCard.modelFilledPipelineArguments === true;
|
|
60598
60658
|
}
|
|
@@ -60610,7 +60670,7 @@ async function readOptionalJsonObject(file) {
|
|
|
60610
60670
|
}
|
|
60611
60671
|
async function readModifiedAt(file) {
|
|
60612
60672
|
try {
|
|
60613
|
-
return (await (0,
|
|
60673
|
+
return (await (0, import_promises18.stat)(file)).mtime.toISOString();
|
|
60614
60674
|
} catch {
|
|
60615
60675
|
return "";
|
|
60616
60676
|
}
|
|
@@ -60650,7 +60710,7 @@ function assertDraftId(draftId) {
|
|
|
60650
60710
|
}
|
|
60651
60711
|
}
|
|
60652
60712
|
function draftDirectory(cwd, draftId) {
|
|
60653
|
-
return
|
|
60713
|
+
return import_path24.default.join(cwd, DRAFT_ROOT, draftId);
|
|
60654
60714
|
}
|
|
60655
60715
|
function assertChecksum(value, label) {
|
|
60656
60716
|
if (!SHA256_PATTERN.test(value)) {
|
|
@@ -60731,13 +60791,13 @@ async function atomicWrite(file, content) {
|
|
|
60731
60791
|
const temporary = `${file}.${process.pid}.${(0, import_crypto9.randomUUID)()}.tmp`;
|
|
60732
60792
|
let handle;
|
|
60733
60793
|
try {
|
|
60734
|
-
handle = await (0,
|
|
60794
|
+
handle = await (0, import_promises18.open)(temporary, "wx", 384);
|
|
60735
60795
|
await handle.writeFile(content);
|
|
60736
60796
|
await handle.sync();
|
|
60737
60797
|
await handle.close();
|
|
60738
60798
|
handle = void 0;
|
|
60739
|
-
await (0,
|
|
60740
|
-
const directoryHandle = await (0,
|
|
60799
|
+
await (0, import_promises18.rename)(temporary, file);
|
|
60800
|
+
const directoryHandle = await (0, import_promises18.open)(import_path24.default.dirname(file), "r");
|
|
60741
60801
|
try {
|
|
60742
60802
|
await directoryHandle.sync();
|
|
60743
60803
|
} finally {
|
|
@@ -60745,10 +60805,10 @@ async function atomicWrite(file, content) {
|
|
|
60745
60805
|
}
|
|
60746
60806
|
} catch (cause) {
|
|
60747
60807
|
await handle?.close().catch(() => void 0);
|
|
60748
|
-
await (0,
|
|
60808
|
+
await (0, import_promises18.unlink)(temporary).catch(() => void 0);
|
|
60749
60809
|
throw new LinkqueCliError(
|
|
60750
60810
|
"CARD_FINALIZE_WRITE_FAILED",
|
|
60751
|
-
`\u539F\u5B50\u5199\u5165\u5931\u8D25: ${
|
|
60811
|
+
`\u539F\u5B50\u5199\u5165\u5931\u8D25: ${import_path24.default.basename(file)}`,
|
|
60752
60812
|
{ cause: cause instanceof Error ? cause : void 0 }
|
|
60753
60813
|
);
|
|
60754
60814
|
}
|
|
@@ -60774,15 +60834,15 @@ function parseRollbackToken(token) {
|
|
|
60774
60834
|
|
|
60775
60835
|
// src/commands/dev.ts
|
|
60776
60836
|
var import_child_process4 = require("child_process");
|
|
60777
|
-
var
|
|
60837
|
+
var import_promises20 = require("fs/promises");
|
|
60778
60838
|
var import_net2 = require("net");
|
|
60779
|
-
var
|
|
60839
|
+
var import_path26 = __toESM(require("path"));
|
|
60780
60840
|
|
|
60781
60841
|
// src/commands/inspector.ts
|
|
60782
60842
|
var import_module = require("module");
|
|
60783
|
-
var
|
|
60843
|
+
var import_promises19 = require("fs/promises");
|
|
60784
60844
|
var import_os3 = require("os");
|
|
60785
|
-
var
|
|
60845
|
+
var import_path25 = __toESM(require("path"));
|
|
60786
60846
|
var import_url = require("url");
|
|
60787
60847
|
var INSPECTOR_PACKAGES = [
|
|
60788
60848
|
"@alipay/agent-inspector-workspace",
|
|
@@ -60805,7 +60865,7 @@ var importInspectorModule = async (resolvedPath) => {
|
|
|
60805
60865
|
};
|
|
60806
60866
|
var loadInspectorWorkspaceEngine = async (cwd) => {
|
|
60807
60867
|
try {
|
|
60808
|
-
const workspaceRequire = (0, import_module.createRequire)(
|
|
60868
|
+
const workspaceRequire = (0, import_module.createRequire)(import_path25.default.join(cwd, "package.json"));
|
|
60809
60869
|
const resolved = /* @__PURE__ */ new Map();
|
|
60810
60870
|
for (const packageName of INSPECTOR_PACKAGES) {
|
|
60811
60871
|
resolved.set(packageName, workspaceRequire.resolve(packageName));
|
|
@@ -60822,16 +60882,16 @@ var loadInspectorWorkspaceEngine = async (cwd) => {
|
|
|
60822
60882
|
);
|
|
60823
60883
|
}
|
|
60824
60884
|
};
|
|
60825
|
-
var managedRequestDirectory = () =>
|
|
60885
|
+
var managedRequestDirectory = () => import_path25.default.join((0, import_os3.homedir)(), ".linkque/inspector-requests");
|
|
60826
60886
|
var assertManagedRequestFile = async (requestFile) => {
|
|
60827
|
-
if (!
|
|
60887
|
+
if (!import_path25.default.isAbsolute(requestFile) || !REQUEST_FILE_PATTERN.test(import_path25.default.basename(requestFile)) || import_path25.default.dirname(requestFile) !== managedRequestDirectory()) {
|
|
60828
60888
|
throw new LinkqueCliError(
|
|
60829
60889
|
"INSPECTOR_PATH_FORBIDDEN",
|
|
60830
60890
|
"Inspector \u8BF7\u6C42\u6587\u4EF6\u4E0D\u5728\u53D7\u7BA1\u76EE\u5F55\u5185"
|
|
60831
60891
|
);
|
|
60832
60892
|
}
|
|
60833
60893
|
try {
|
|
60834
|
-
const fileStat = await (0,
|
|
60894
|
+
const fileStat = await (0, import_promises19.lstat)(requestFile);
|
|
60835
60895
|
if (fileStat.isSymbolicLink() || !fileStat.isFile()) {
|
|
60836
60896
|
throw new LinkqueCliError(
|
|
60837
60897
|
"INSPECTOR_PATH_FORBIDDEN",
|
|
@@ -60845,11 +60905,11 @@ var assertManagedRequestFile = async (requestFile) => {
|
|
|
60845
60905
|
);
|
|
60846
60906
|
}
|
|
60847
60907
|
const [directoryRealPath, fileRealPath] = await Promise.all([
|
|
60848
|
-
(0,
|
|
60849
|
-
(0,
|
|
60908
|
+
(0, import_promises19.realpath)(managedRequestDirectory()),
|
|
60909
|
+
(0, import_promises19.realpath)(requestFile)
|
|
60850
60910
|
]);
|
|
60851
|
-
const relative =
|
|
60852
|
-
if (relative === "" || relative.startsWith(`..${
|
|
60911
|
+
const relative = import_path25.default.relative(directoryRealPath, fileRealPath);
|
|
60912
|
+
if (relative === "" || relative.startsWith(`..${import_path25.default.sep}`) || import_path25.default.isAbsolute(relative)) {
|
|
60853
60913
|
throw new LinkqueCliError(
|
|
60854
60914
|
"INSPECTOR_PATH_FORBIDDEN",
|
|
60855
60915
|
"Inspector \u8BF7\u6C42\u6587\u4EF6\u89E3\u6790\u540E\u8D8A\u51FA\u53D7\u7BA1\u76EE\u5F55"
|
|
@@ -60874,7 +60934,7 @@ var assertManagedRequestFile = async (requestFile) => {
|
|
|
60874
60934
|
var readInspectorRequest = async (requestFile) => {
|
|
60875
60935
|
await assertManagedRequestFile(requestFile);
|
|
60876
60936
|
try {
|
|
60877
|
-
const content = await (0,
|
|
60937
|
+
const content = await (0, import_promises19.readFile)(requestFile, "utf8");
|
|
60878
60938
|
if (Buffer.byteLength(content, "utf8") > REQUEST_MAX_BYTES) {
|
|
60879
60939
|
throw new LinkqueCliError(
|
|
60880
60940
|
"INSPECTOR_REQUEST_INVALID",
|
|
@@ -60948,7 +61008,7 @@ var normalizeRevision = (value) => {
|
|
|
60948
61008
|
};
|
|
60949
61009
|
var withInspectorLock = (cwd, operation) => withWorkspaceLock(
|
|
60950
61010
|
{
|
|
60951
|
-
path:
|
|
61011
|
+
path: import_path25.default.join(cwd, INSPECTOR_LOCK),
|
|
60952
61012
|
name: "inspector",
|
|
60953
61013
|
acquireErrorCode: "INSPECTOR_LOCK_TIMEOUT",
|
|
60954
61014
|
releaseErrorCode: "INSPECTOR_INTERNAL_ERROR",
|
|
@@ -61077,7 +61137,7 @@ var isPortListening2 = (port) => new Promise((resolve2) => {
|
|
|
61077
61137
|
});
|
|
61078
61138
|
async function removeMatchingState2(statePath, pid) {
|
|
61079
61139
|
const owned = await readOwnedDevState(statePath);
|
|
61080
|
-
if (owned?.pid === pid) await (0,
|
|
61140
|
+
if (owned?.pid === pid) await (0, import_promises20.rm)(statePath, { force: true });
|
|
61081
61141
|
}
|
|
61082
61142
|
async function terminateOwner2(statePath, pid) {
|
|
61083
61143
|
if (!isProcessAlive(pid)) {
|
|
@@ -61110,14 +61170,14 @@ async function terminateOwner2(statePath, pid) {
|
|
|
61110
61170
|
await removeMatchingState2(statePath, pid);
|
|
61111
61171
|
}
|
|
61112
61172
|
var inspectRecordedDevServer = async (cwd) => {
|
|
61113
|
-
const statePath =
|
|
61173
|
+
const statePath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
|
|
61114
61174
|
const content = await readUtf8IfExists(statePath);
|
|
61115
61175
|
if (content === null) {
|
|
61116
61176
|
return { state: null, status: stopped2("STOPPED") };
|
|
61117
61177
|
}
|
|
61118
61178
|
const owned = parseOwnedDevState(content);
|
|
61119
61179
|
if (owned === null) {
|
|
61120
|
-
await (0,
|
|
61180
|
+
await (0, import_promises20.rm)(statePath, { force: true });
|
|
61121
61181
|
return { state: null, status: stopped2("STALE") };
|
|
61122
61182
|
}
|
|
61123
61183
|
const state = owned;
|
|
@@ -61183,17 +61243,17 @@ var inspectReadyWorkspace = async (cwd) => {
|
|
|
61183
61243
|
}
|
|
61184
61244
|
};
|
|
61185
61245
|
var spawnDevOwner = (cwd, port, proxyPort, cardPreviewPort, basePath, inspectorEnabled) => {
|
|
61186
|
-
const workerPath =
|
|
61246
|
+
const workerPath = import_path26.default.resolve(__dirname, "dev/worker.js");
|
|
61187
61247
|
const input = Buffer.from(
|
|
61188
61248
|
JSON.stringify({
|
|
61189
61249
|
basePath,
|
|
61190
61250
|
cardPreviewPort,
|
|
61191
61251
|
cwd,
|
|
61192
61252
|
inspectorEnabled,
|
|
61193
|
-
logPath:
|
|
61253
|
+
logPath: import_path26.default.join(cwd, DEV_LOG),
|
|
61194
61254
|
port,
|
|
61195
61255
|
proxyPort,
|
|
61196
|
-
statePath:
|
|
61256
|
+
statePath: import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE)
|
|
61197
61257
|
})
|
|
61198
61258
|
).toString("base64url");
|
|
61199
61259
|
const owner = (0, import_child_process4.spawn)(process.execPath, [workerPath, input], {
|
|
@@ -61308,9 +61368,9 @@ var startDevServer = async (cwd, port, proxyPort, cardPreviewPort, basePath, ins
|
|
|
61308
61368
|
"dev, proxy and card preview ports must be different"
|
|
61309
61369
|
);
|
|
61310
61370
|
}
|
|
61311
|
-
const runtimeDir =
|
|
61312
|
-
const lockPath =
|
|
61313
|
-
const statePath =
|
|
61371
|
+
const runtimeDir = import_path26.default.join(cwd, RUNTIME_DIR3);
|
|
61372
|
+
const lockPath = import_path26.default.join(runtimeDir, DEV_LOCK);
|
|
61373
|
+
const statePath = import_path26.default.join(runtimeDir, DEV_STATE);
|
|
61314
61374
|
return withWorkspaceLock(
|
|
61315
61375
|
{
|
|
61316
61376
|
path: lockPath,
|
|
@@ -61332,8 +61392,8 @@ var startDevServer = async (cwd, port, proxyPort, cardPreviewPort, basePath, ins
|
|
|
61332
61392
|
);
|
|
61333
61393
|
};
|
|
61334
61394
|
var stopDevServer = async (cwd) => {
|
|
61335
|
-
const lockPath =
|
|
61336
|
-
const statePath =
|
|
61395
|
+
const lockPath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_LOCK);
|
|
61396
|
+
const statePath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
|
|
61337
61397
|
return withWorkspaceLock(
|
|
61338
61398
|
{
|
|
61339
61399
|
path: lockPath,
|
|
@@ -61346,7 +61406,7 @@ var stopDevServer = async (cwd) => {
|
|
|
61346
61406
|
async () => {
|
|
61347
61407
|
const owned = await readOwnedDevState(statePath);
|
|
61348
61408
|
if (owned !== null) await terminateOwner2(statePath, owned.pid);
|
|
61349
|
-
await (0,
|
|
61409
|
+
await (0, import_promises20.rm)(statePath, { force: true });
|
|
61350
61410
|
return { stopped: true };
|
|
61351
61411
|
}
|
|
61352
61412
|
);
|
|
@@ -61354,8 +61414,8 @@ var stopDevServer = async (cwd) => {
|
|
|
61354
61414
|
|
|
61355
61415
|
// src/commands/platformSdk/apply.ts
|
|
61356
61416
|
var import_crypto10 = require("crypto");
|
|
61357
|
-
var
|
|
61358
|
-
var
|
|
61417
|
+
var import_promises21 = require("fs/promises");
|
|
61418
|
+
var import_path27 = __toESM(require("path"));
|
|
61359
61419
|
var PLATFORM_SDK_DIR = ".platform-sdk";
|
|
61360
61420
|
var PLATFORM_SDK_VERSION_FILE = `${PLATFORM_SDK_DIR}/version.json`;
|
|
61361
61421
|
var PLATFORM_SDK_STATE = ".linkque/runtime/platform-sdk-state.json";
|
|
@@ -61367,10 +61427,10 @@ var failManifest = (message) => {
|
|
|
61367
61427
|
var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61368
61428
|
var isSha256 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/u.test(value);
|
|
61369
61429
|
var isSafePlatformPath = (value) => {
|
|
61370
|
-
if (value.includes("\\") || value.includes("\0") ||
|
|
61430
|
+
if (value.includes("\\") || value.includes("\0") || import_path27.default.posix.isAbsolute(value)) {
|
|
61371
61431
|
return false;
|
|
61372
61432
|
}
|
|
61373
|
-
const normalized =
|
|
61433
|
+
const normalized = import_path27.default.posix.normalize(value);
|
|
61374
61434
|
return normalized === value && normalized.startsWith(`${PLATFORM_SDK_DIR}/`) && !normalized.split("/").includes("..");
|
|
61375
61435
|
};
|
|
61376
61436
|
var parseManifest = (content) => {
|
|
@@ -61413,14 +61473,14 @@ var extractArchive = async (cwd, archive, manifest) => {
|
|
|
61413
61473
|
`platform SDK archive contains an unsafe path: ${entry.filename}`
|
|
61414
61474
|
);
|
|
61415
61475
|
}
|
|
61416
|
-
const destination =
|
|
61476
|
+
const destination = import_path27.default.join(cwd, ...entryPath.split("/"));
|
|
61417
61477
|
if (entry.directory) {
|
|
61418
|
-
await (0,
|
|
61478
|
+
await (0, import_promises21.mkdir)(destination, { recursive: true });
|
|
61419
61479
|
continue;
|
|
61420
61480
|
}
|
|
61421
61481
|
const bytes = await entry.getData(new Uint8ArrayWriter());
|
|
61422
|
-
await (0,
|
|
61423
|
-
await (0,
|
|
61482
|
+
await (0, import_promises21.mkdir)(import_path27.default.dirname(destination), { recursive: true });
|
|
61483
|
+
await (0, import_promises21.writeFile)(destination, bytes, { flag: "wx" });
|
|
61424
61484
|
extractedFiles.set(entryPath, sha256(bytes));
|
|
61425
61485
|
}
|
|
61426
61486
|
} finally {
|
|
@@ -61439,7 +61499,7 @@ var validateVersionMarker = async (cwd, manifest) => {
|
|
|
61439
61499
|
let value;
|
|
61440
61500
|
try {
|
|
61441
61501
|
value = JSON.parse(
|
|
61442
|
-
await (0,
|
|
61502
|
+
await (0, import_promises21.readFile)(import_path27.default.join(cwd, PLATFORM_SDK_VERSION_FILE), "utf8")
|
|
61443
61503
|
);
|
|
61444
61504
|
} catch (error2) {
|
|
61445
61505
|
throw new LinkqueCliError(
|
|
@@ -61456,10 +61516,10 @@ var validateVersionMarker = async (cwd, manifest) => {
|
|
|
61456
61516
|
}
|
|
61457
61517
|
};
|
|
61458
61518
|
var rewritePackageJson = async (cwd, manifest) => {
|
|
61459
|
-
const packageJsonPath =
|
|
61519
|
+
const packageJsonPath = import_path27.default.join(cwd, "package.json");
|
|
61460
61520
|
let packageJson;
|
|
61461
61521
|
try {
|
|
61462
|
-
packageJson = JSON.parse(await (0,
|
|
61522
|
+
packageJson = JSON.parse(await (0, import_promises21.readFile)(packageJsonPath, "utf8"));
|
|
61463
61523
|
} catch (error2) {
|
|
61464
61524
|
throw new LinkqueCliError(
|
|
61465
61525
|
"PLATFORM_SDK_APPLY_FAILED",
|
|
@@ -61499,8 +61559,8 @@ var rewritePackageJson = async (cwd, manifest) => {
|
|
|
61499
61559
|
};
|
|
61500
61560
|
var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
61501
61561
|
const [manifestContent, archive] = await Promise.all([
|
|
61502
|
-
(0,
|
|
61503
|
-
(0,
|
|
61562
|
+
(0, import_promises21.readFile)(import_path27.default.resolve(cwd, manifestPath), "utf8"),
|
|
61563
|
+
(0, import_promises21.readFile)(import_path27.default.resolve(cwd, archivePath))
|
|
61504
61564
|
]).catch((error2) => {
|
|
61505
61565
|
throw new LinkqueCliError(
|
|
61506
61566
|
"PLATFORM_SDK_APPLY_FAILED",
|
|
@@ -61515,7 +61575,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
|
61515
61575
|
"platform SDK archive identity does not match the manifest"
|
|
61516
61576
|
);
|
|
61517
61577
|
}
|
|
61518
|
-
await (0,
|
|
61578
|
+
await (0, import_promises21.rm)(import_path27.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
|
|
61519
61579
|
try {
|
|
61520
61580
|
await extractArchive(cwd, archive, manifest);
|
|
61521
61581
|
await validateVersionMarker(cwd, manifest);
|
|
@@ -61527,12 +61587,12 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
|
61527
61587
|
let templateVersion;
|
|
61528
61588
|
try {
|
|
61529
61589
|
const artifact = JSON.parse(
|
|
61530
|
-
await (0,
|
|
61590
|
+
await (0, import_promises21.readFile)(import_path27.default.join(cwd, "template-artifact.json"), "utf8")
|
|
61531
61591
|
);
|
|
61532
61592
|
templateVersion = typeof artifact.templateVersion === "string" ? artifact.templateVersion : void 0;
|
|
61533
61593
|
} catch {
|
|
61534
61594
|
}
|
|
61535
|
-
await writeJsonAtomically(
|
|
61595
|
+
await writeJsonAtomically(import_path27.default.join(cwd, PLATFORM_SDK_STATE), {
|
|
61536
61596
|
schemaVersion: 1,
|
|
61537
61597
|
bundleVersion: manifest.bundleVersion,
|
|
61538
61598
|
platformSdkRef: manifest.archive.ossKey,
|
|
@@ -61556,7 +61616,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
|
61556
61616
|
};
|
|
61557
61617
|
var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => withWorkspaceLock(
|
|
61558
61618
|
{
|
|
61559
|
-
path:
|
|
61619
|
+
path: import_path27.default.join(cwd, PLATFORM_SDK_LOCK),
|
|
61560
61620
|
name: "platform SDK",
|
|
61561
61621
|
acquireErrorCode: "PLATFORM_SDK_LOCK_TIMEOUT",
|
|
61562
61622
|
releaseErrorCode: "PLATFORM_SDK_LOCK_RELEASE_FAILED",
|
|
@@ -61567,8 +61627,8 @@ var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => w
|
|
|
61567
61627
|
);
|
|
61568
61628
|
|
|
61569
61629
|
// src/commands/unzip.ts
|
|
61570
|
-
var
|
|
61571
|
-
var
|
|
61630
|
+
var import_promises22 = require("fs/promises");
|
|
61631
|
+
var import_path28 = __toESM(require("path"));
|
|
61572
61632
|
var MAX_ZIP_BYTES = 70 * 1024 * 1024;
|
|
61573
61633
|
var MAX_FILE_COUNT = 5e3;
|
|
61574
61634
|
var MAX_TOTAL_BYTES = 50 * 1024 * 1024;
|
|
@@ -61594,12 +61654,12 @@ var SourceArchiveExtractor = class {
|
|
|
61594
61654
|
constructor(cwd, input, output) {
|
|
61595
61655
|
if (!input) this.invalid("unzip input path must not be empty");
|
|
61596
61656
|
if (!output) this.invalid("unzip output path must not be empty");
|
|
61597
|
-
this.inputPath =
|
|
61598
|
-
this.outputPath =
|
|
61657
|
+
this.inputPath = import_path28.default.resolve(cwd, input);
|
|
61658
|
+
this.outputPath = import_path28.default.resolve(cwd, output);
|
|
61599
61659
|
}
|
|
61600
61660
|
async extract() {
|
|
61601
61661
|
await this.assertInputs();
|
|
61602
|
-
const handle = await (0,
|
|
61662
|
+
const handle = await (0, import_promises22.open)(this.inputPath, "r").catch((error2) => {
|
|
61603
61663
|
throw new LinkqueCliError(
|
|
61604
61664
|
"UNZIP_INPUT_INVALID",
|
|
61605
61665
|
"unzip input archive could not be opened",
|
|
@@ -61635,7 +61695,7 @@ var SourceArchiveExtractor = class {
|
|
|
61635
61695
|
}
|
|
61636
61696
|
let inputStat;
|
|
61637
61697
|
try {
|
|
61638
|
-
inputStat = await (0,
|
|
61698
|
+
inputStat = await (0, import_promises22.stat)(this.inputPath);
|
|
61639
61699
|
} catch (error2) {
|
|
61640
61700
|
throw new LinkqueCliError(
|
|
61641
61701
|
"UNZIP_INPUT_INVALID",
|
|
@@ -61649,7 +61709,7 @@ var SourceArchiveExtractor = class {
|
|
|
61649
61709
|
}
|
|
61650
61710
|
let outputStat;
|
|
61651
61711
|
try {
|
|
61652
|
-
outputStat = await (0,
|
|
61712
|
+
outputStat = await (0, import_promises22.lstat)(this.outputPath);
|
|
61653
61713
|
} catch (error2) {
|
|
61654
61714
|
throw new LinkqueCliError(
|
|
61655
61715
|
"UNZIP_INPUT_INVALID",
|
|
@@ -61660,7 +61720,7 @@ var SourceArchiveExtractor = class {
|
|
|
61660
61720
|
if (outputStat.isSymbolicLink() || !outputStat.isDirectory()) {
|
|
61661
61721
|
this.invalid("unzip output must be an existing directory");
|
|
61662
61722
|
}
|
|
61663
|
-
if ((await (0,
|
|
61723
|
+
if ((await (0, import_promises22.readdir)(this.outputPath)).length > 0) {
|
|
61664
61724
|
this.invalid("unzip output directory must be empty");
|
|
61665
61725
|
}
|
|
61666
61726
|
}
|
|
@@ -61691,16 +61751,16 @@ var SourceArchiveExtractor = class {
|
|
|
61691
61751
|
}
|
|
61692
61752
|
normalizeEntryPath(filename) {
|
|
61693
61753
|
const normalized = filename.replace(/\/$/u, "");
|
|
61694
|
-
if (!normalized || filename.includes("\0") || filename.includes("\\") ||
|
|
61754
|
+
if (!normalized || filename.includes("\0") || filename.includes("\\") || import_path28.default.posix.isAbsolute(normalized) || /^[a-zA-Z]:\//u.test(normalized) || normalized.split("/").some((part) => part === "" || part === "." || part === "..")) {
|
|
61695
61755
|
this.invalid(`unzip archive contains an unsafe path: ${filename}`);
|
|
61696
61756
|
}
|
|
61697
61757
|
return normalized;
|
|
61698
61758
|
}
|
|
61699
61759
|
async extractFile(file) {
|
|
61700
61760
|
const destination = this.resolveDestination(file.filename);
|
|
61701
|
-
await (0,
|
|
61761
|
+
await (0, import_promises22.mkdir)(import_path28.default.dirname(destination), { recursive: true });
|
|
61702
61762
|
this.sourceChecksum.appendFileHeader(file.filename, file.size);
|
|
61703
|
-
const handle = await (0,
|
|
61763
|
+
const handle = await (0, import_promises22.open)(destination, "wx");
|
|
61704
61764
|
let written = 0;
|
|
61705
61765
|
try {
|
|
61706
61766
|
await file.entry.getData(
|
|
@@ -61732,9 +61792,9 @@ var SourceArchiveExtractor = class {
|
|
|
61732
61792
|
}
|
|
61733
61793
|
}
|
|
61734
61794
|
resolveDestination(filename) {
|
|
61735
|
-
const destination =
|
|
61736
|
-
const relative =
|
|
61737
|
-
if (relative === "" || relative.startsWith("..") ||
|
|
61795
|
+
const destination = import_path28.default.resolve(this.outputPath, ...filename.split("/"));
|
|
61796
|
+
const relative = import_path28.default.relative(this.outputPath, destination);
|
|
61797
|
+
if (relative === "" || relative.startsWith("..") || import_path28.default.isAbsolute(relative)) {
|
|
61738
61798
|
this.invalid(`unzip archive escapes output directory: ${filename}`);
|
|
61739
61799
|
}
|
|
61740
61800
|
return destination;
|
|
@@ -62067,7 +62127,7 @@ function decodeOtlpRecords(line, source) {
|
|
|
62067
62127
|
}
|
|
62068
62128
|
|
|
62069
62129
|
// ../linkque-agent-runtime-trace/dist/esm/summarize.js
|
|
62070
|
-
var
|
|
62130
|
+
var import_node_crypto4 = require("node:crypto");
|
|
62071
62131
|
var dedupKey = (advanceId, suffix) => `${advanceId ?? ""}
|
|
62072
62132
|
${suffix ?? ""}`;
|
|
62073
62133
|
var extractQueryInput = (facts) => {
|
|
@@ -62241,7 +62301,7 @@ ${body.section}`;
|
|
|
62241
62301
|
section: body.section,
|
|
62242
62302
|
contentRef,
|
|
62243
62303
|
...body.reason === "content_limit" ? { reason: "content_limit" } : {},
|
|
62244
|
-
valueDigest: (0,
|
|
62304
|
+
valueDigest: (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify(body.value) ?? "").digest("hex"),
|
|
62245
62305
|
...body.value && typeof body.value === "object" && (body.section.endsWith(".output") || body.section === "knowledge.input") ? {
|
|
62246
62306
|
result: Object.fromEntries(Object.entries(body.value).filter(([key, value]) => [
|
|
62247
62307
|
"status",
|
|
@@ -62437,7 +62497,7 @@ function readTraceContent(input) {
|
|
|
62437
62497
|
const pageBytes = Math.min(maxBytes, remaining);
|
|
62438
62498
|
const isFullContent = offset === 0 && totalBytes <= maxBytes;
|
|
62439
62499
|
const titles = body.fieldTitles;
|
|
62440
|
-
const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(Object.entries(titles).filter(([
|
|
62500
|
+
const fieldTitles = titles && typeof titles === "object" && !Array.isArray(titles) ? Object.fromEntries(Object.entries(titles).filter(([path28, title]) => path28.startsWith("/") && typeof title === "string")) : void 0;
|
|
62441
62501
|
const evidence = {
|
|
62442
62502
|
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
62443
62503
|
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {},
|
|
@@ -62476,8 +62536,8 @@ function readTraceContent(input) {
|
|
|
62476
62536
|
|
|
62477
62537
|
// src/utils/otlpScanner.ts
|
|
62478
62538
|
var import_node_path13 = __toESM(require("node:path"));
|
|
62479
|
-
var
|
|
62480
|
-
var
|
|
62539
|
+
var import_node_crypto5 = require("node:crypto");
|
|
62540
|
+
var import_promises23 = require("node:fs/promises");
|
|
62481
62541
|
|
|
62482
62542
|
// src/commands/runs/types.ts
|
|
62483
62543
|
var OTLP_LOG_FILES = {
|
|
@@ -62533,7 +62593,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62533
62593
|
const dir = import_node_path13.default.join(cwd, LOGS_ROOT);
|
|
62534
62594
|
let files;
|
|
62535
62595
|
try {
|
|
62536
|
-
files = await (0,
|
|
62596
|
+
files = await (0, import_promises23.readdir)(dir);
|
|
62537
62597
|
} catch (error2) {
|
|
62538
62598
|
if (isNodeError(error2, "ENOENT"))
|
|
62539
62599
|
return { facts: [], warnings: ["source_unavailable"], readWindow: [] };
|
|
@@ -62556,14 +62616,14 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62556
62616
|
try {
|
|
62557
62617
|
const source = retainedFiles.get(file);
|
|
62558
62618
|
const filePath = import_node_path13.default.join(dir, file);
|
|
62559
|
-
const before = await (0,
|
|
62619
|
+
const before = await (0, import_promises23.stat)(filePath);
|
|
62560
62620
|
if (options && scannedBytes + before.size > options.maxBytes)
|
|
62561
62621
|
throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
|
|
62562
|
-
const content = await (0,
|
|
62622
|
+
const content = await (0, import_promises23.readFile)(filePath);
|
|
62563
62623
|
scannedBytes += content.length;
|
|
62564
62624
|
if (options && scannedBytes > options.maxBytes)
|
|
62565
62625
|
throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
|
|
62566
|
-
const after = await (0,
|
|
62626
|
+
const after = await (0, import_promises23.stat)(filePath);
|
|
62567
62627
|
if (before.ino !== after.ino || after.size < before.size) {
|
|
62568
62628
|
warnings.push("log_rotated_during_read");
|
|
62569
62629
|
continue;
|
|
@@ -62572,7 +62632,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62572
62632
|
let window;
|
|
62573
62633
|
if (pinned) {
|
|
62574
62634
|
window = [...remaining].find(
|
|
62575
|
-
(entry) => entry.source === source && content.length >= entry.bytes && (0,
|
|
62635
|
+
(entry) => entry.source === source && content.length >= entry.bytes && (0, import_node_crypto5.createHash)("sha256").update(content.subarray(0, entry.bytes)).digest("hex") === entry.digest
|
|
62576
62636
|
);
|
|
62577
62637
|
if (!window) continue;
|
|
62578
62638
|
remaining.delete(window);
|
|
@@ -62583,7 +62643,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62583
62643
|
window = {
|
|
62584
62644
|
source,
|
|
62585
62645
|
bytes: complete.length,
|
|
62586
|
-
digest: (0,
|
|
62646
|
+
digest: (0, import_node_crypto5.createHash)("sha256").update(complete).digest("hex")
|
|
62587
62647
|
};
|
|
62588
62648
|
}
|
|
62589
62649
|
readWindow.push(window);
|
|
@@ -62789,9 +62849,9 @@ var scanContent = async (input) => {
|
|
|
62789
62849
|
var import_node_path14 = __toESM(require("node:path"));
|
|
62790
62850
|
var import_node_fs9 = require("node:fs");
|
|
62791
62851
|
var import_node_stream2 = require("node:stream");
|
|
62792
|
-
var
|
|
62852
|
+
var import_promises24 = require("node:stream/promises");
|
|
62793
62853
|
var import_node_zlib2 = require("node:zlib");
|
|
62794
|
-
var
|
|
62854
|
+
var import_promises25 = require("node:fs/promises");
|
|
62795
62855
|
var TURN_ARCHIVE_MAX_BYTES = 16 * 1024 * 1024;
|
|
62796
62856
|
var TURN_SOURCE_MAX_BYTES = 64 * 1024 * 1024;
|
|
62797
62857
|
var TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES = 64 * 1024 * 1024;
|
|
@@ -62818,8 +62878,8 @@ async function exportTurn(cwd, identity) {
|
|
|
62818
62878
|
"\u76EE\u6807\u8F6E\u6B21\u65E5\u5FD7\u4E0D\u53EF\u7528"
|
|
62819
62879
|
);
|
|
62820
62880
|
const root = import_node_path14.default.join(cwd, ".linkque", "tmp");
|
|
62821
|
-
await (0,
|
|
62822
|
-
const directory = await (0,
|
|
62881
|
+
await (0, import_promises25.mkdir)(root, { recursive: true });
|
|
62882
|
+
const directory = await (0, import_promises25.mkdtemp)(import_node_path14.default.join(root, "turn-share-"));
|
|
62823
62883
|
const archivePath = import_node_path14.default.join(directory, "logs.tar.gz");
|
|
62824
62884
|
let result;
|
|
62825
62885
|
try {
|
|
@@ -62840,7 +62900,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62840
62900
|
if (payloadBytes > TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES)
|
|
62841
62901
|
throw new RangeError("\u672A\u538B\u7F29\u5F52\u6863\u5185\u5BB9\u8D85\u8FC7\u4E0A\u9650");
|
|
62842
62902
|
for (const [name, value] of Object.entries(files))
|
|
62843
|
-
await (0,
|
|
62903
|
+
await (0, import_promises25.writeFile)(import_node_path14.default.join(directory, name), value, { flag: "wx" });
|
|
62844
62904
|
let uncompressedBytes = 0;
|
|
62845
62905
|
let compressedBytes = 0;
|
|
62846
62906
|
const rawBudget = new import_node_stream2.Transform({
|
|
@@ -62861,7 +62921,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62861
62921
|
);
|
|
62862
62922
|
}
|
|
62863
62923
|
});
|
|
62864
|
-
await (0,
|
|
62924
|
+
await (0, import_promises24.pipeline)(
|
|
62865
62925
|
Qn(
|
|
62866
62926
|
{ cwd: directory, portable: true },
|
|
62867
62927
|
Object.keys(files)
|
|
@@ -62873,7 +62933,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62873
62933
|
);
|
|
62874
62934
|
result = { archivePath, compressedBytes, uncompressedBytes };
|
|
62875
62935
|
} catch (cause) {
|
|
62876
|
-
await (0,
|
|
62936
|
+
await (0, import_promises25.rm)(directory, { recursive: true, force: true }).catch(
|
|
62877
62937
|
() => void 0
|
|
62878
62938
|
);
|
|
62879
62939
|
throw new LinkqueCliError(
|
|
@@ -62883,7 +62943,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62883
62943
|
);
|
|
62884
62944
|
}
|
|
62885
62945
|
for (const name of ["manifest.json", "logs.jsonl", "traces.jsonl"]) {
|
|
62886
|
-
await (0,
|
|
62946
|
+
await (0, import_promises25.rm)(import_node_path14.default.join(directory, name), { force: true }).catch(
|
|
62887
62947
|
() => void 0
|
|
62888
62948
|
);
|
|
62889
62949
|
}
|
|
@@ -63274,6 +63334,16 @@ var cardList = {
|
|
|
63274
63334
|
`,
|
|
63275
63335
|
run: (cwd) => listCardDrafts(cwd)
|
|
63276
63336
|
};
|
|
63337
|
+
var cardMigrate = {
|
|
63338
|
+
name: "card.migrate",
|
|
63339
|
+
description: "\u5C06 V4 \u5361\u7247\u8FC1\u79FB\u4E3A\u72EC\u7ACB\u7ED3\u6784\u548C\u7ED1\u5B9A\u6587\u4EF6",
|
|
63340
|
+
options: [],
|
|
63341
|
+
summarize: () => "V4 card storage migrated.\n",
|
|
63342
|
+
run: async (cwd) => {
|
|
63343
|
+
const source = await migrateAgentCards(import_path29.default.join(cwd, "agent_config.json"));
|
|
63344
|
+
return { cardCount: Object.keys(source.files).length / 2 };
|
|
63345
|
+
}
|
|
63346
|
+
};
|
|
63277
63347
|
var cardRead = {
|
|
63278
63348
|
name: "card.read",
|
|
63279
63349
|
description: "read one validated A2UI card draft bundle",
|
|
@@ -63757,6 +63827,7 @@ var COMMANDS = [
|
|
|
63757
63827
|
inspectorApply,
|
|
63758
63828
|
mcpDescribe,
|
|
63759
63829
|
cardList,
|
|
63830
|
+
cardMigrate,
|
|
63760
63831
|
cardRead,
|
|
63761
63832
|
cardPrepareBindingContext,
|
|
63762
63833
|
cardValidateBindings,
|
|
@@ -63797,8 +63868,8 @@ var GROUP_DESCRIPTIONS = {
|
|
|
63797
63868
|
"platform-sdk": "apply platform-managed SDK bundles",
|
|
63798
63869
|
runs: "query recent Query runs from retained sandbox logs"
|
|
63799
63870
|
};
|
|
63800
|
-
var collectOptions = (target,
|
|
63801
|
-
for (const { flags, key } of
|
|
63871
|
+
var collectOptions = (target, definitions2, values) => {
|
|
63872
|
+
for (const { flags, key } of definitions2) {
|
|
63802
63873
|
const attributeName = new Option(flags).attributeName();
|
|
63803
63874
|
if (values[attributeName] !== void 0) {
|
|
63804
63875
|
target[key] = values[attributeName];
|
|
@@ -63849,12 +63920,12 @@ var bindSubcommand = (program2, command, state) => {
|
|
|
63849
63920
|
});
|
|
63850
63921
|
};
|
|
63851
63922
|
var bindCommandGroup = (program2, prefix, state) => {
|
|
63852
|
-
const
|
|
63923
|
+
const definitions2 = SUBCOMMANDS.filter(
|
|
63853
63924
|
(command) => command.name.startsWith(`${prefix}.`)
|
|
63854
63925
|
);
|
|
63855
|
-
if (
|
|
63926
|
+
if (definitions2.length === 0) return;
|
|
63856
63927
|
const group = program2.command(prefix).description(GROUP_DESCRIPTIONS[prefix] ?? prefix);
|
|
63857
|
-
for (const definition of
|
|
63928
|
+
for (const definition of definitions2) {
|
|
63858
63929
|
const action = definition.name.slice(`${prefix}.`.length);
|
|
63859
63930
|
const sub = group.command(action).description(definition.description).option(JSON_OPTION, "output the machine-readable protocol");
|
|
63860
63931
|
for (const option of definition.options) {
|