linkque-cli-v2 1.6.19 → 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/dev/worker.js +11 -37
- package/linkquejs.js +858 -756
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-ZVFW6DFO.js → chunk-22EQ6RXO.js} +1 -2845
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-SGKJHCSV.js → chunk-5MR5ICJ4.js} +1825 -2551
- 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-RL3OKTKX.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-KIOTOF73.js → mistral-conversations-5EI6JQBZ.js} +1 -1
- 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 +1623 -2006
- 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 +3529 -4989
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
|
}
|
|
@@ -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
|
}
|
|
@@ -53379,7 +53454,7 @@ var APPBASE_RUNTIME_CONFIG_DEFAULTS = Object.freeze({
|
|
|
53379
53454
|
});
|
|
53380
53455
|
|
|
53381
53456
|
// src/commands/agentbuild/configTemplate.ts
|
|
53382
|
-
var
|
|
53457
|
+
var import_path8 = __toESM(require("path"));
|
|
53383
53458
|
var APPWRITE_CONFIG_NAME = "appwrite.config.json";
|
|
53384
53459
|
var CLIENT_CAPABILITY_TABLE_COLUMNS = [
|
|
53385
53460
|
...["ownerId", "agentId", "threadId", "runId", "toolCallId"].map((key) => ({
|
|
@@ -54098,7 +54173,7 @@ function mergeVars(vars, overrides) {
|
|
|
54098
54173
|
return merged;
|
|
54099
54174
|
}
|
|
54100
54175
|
var writeAppwriteConfigTemplate = async (outDir, envOverrides = {}) => {
|
|
54101
|
-
const configPath =
|
|
54176
|
+
const configPath = import_path8.default.join(outDir, APPWRITE_CONFIG_NAME);
|
|
54102
54177
|
try {
|
|
54103
54178
|
await ensureParentDir(configPath);
|
|
54104
54179
|
await writeJsonAtomically(
|
|
@@ -54116,7 +54191,7 @@ var writeAppwriteConfigTemplate = async (outDir, envOverrides = {}) => {
|
|
|
54116
54191
|
};
|
|
54117
54192
|
|
|
54118
54193
|
// src/commands/agentbuild/envOverrides.ts
|
|
54119
|
-
var
|
|
54194
|
+
var import_path9 = __toESM(require("path"));
|
|
54120
54195
|
var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
54121
54196
|
async function resolveEnvOverrides(env, envFile, cwd) {
|
|
54122
54197
|
const overrides = {};
|
|
@@ -54125,7 +54200,7 @@ async function resolveEnvOverrides(env, envFile, cwd) {
|
|
|
54125
54200
|
if (parsed) overrides[parsed.key] = parsed.value;
|
|
54126
54201
|
}
|
|
54127
54202
|
if (envFile && envFile.trim()) {
|
|
54128
|
-
const filePath =
|
|
54203
|
+
const filePath = import_path9.default.resolve(cwd, envFile);
|
|
54129
54204
|
const content = await readUtf8IfExists(filePath);
|
|
54130
54205
|
if (content === null) {
|
|
54131
54206
|
throw new LinkqueCliError(
|
|
@@ -54158,12 +54233,12 @@ function parseEnvEntry(raw) {
|
|
|
54158
54233
|
|
|
54159
54234
|
// src/commands/agentbuild/pkgResolver.ts
|
|
54160
54235
|
var import_fs6 = require("fs");
|
|
54161
|
-
var
|
|
54236
|
+
var import_path10 = require("path");
|
|
54162
54237
|
var INTEGRATE_PKG = "@alipay/linkque-agent-appwrite-integrate";
|
|
54163
54238
|
var resolveIntegrateRoot = () => resolvePortableIntegrateRoot() ?? resolveInstalledIntegrateRoot();
|
|
54164
54239
|
var resolveInstalledIntegrateRoot = () => {
|
|
54165
54240
|
try {
|
|
54166
|
-
return (0,
|
|
54241
|
+
return (0, import_path10.dirname)(require.resolve(`${INTEGRATE_PKG}/package.json`));
|
|
54167
54242
|
} catch {
|
|
54168
54243
|
throw new LinkqueCliError(
|
|
54169
54244
|
"AGENTBUILD_INTEGRATE_NOT_BUILT",
|
|
@@ -54174,16 +54249,16 @@ var resolveInstalledIntegrateRoot = () => {
|
|
|
54174
54249
|
var resolvePortableIntegrateRoot = () => {
|
|
54175
54250
|
let dir = __dirname;
|
|
54176
54251
|
while (true) {
|
|
54177
|
-
const candidate = (0,
|
|
54178
|
-
if ((0, import_fs6.existsSync)((0,
|
|
54179
|
-
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);
|
|
54180
54255
|
if (parent === dir) break;
|
|
54181
54256
|
dir = parent;
|
|
54182
54257
|
}
|
|
54183
54258
|
return void 0;
|
|
54184
54259
|
};
|
|
54185
54260
|
var assertIntegrateBuilt = (pkgRoot) => {
|
|
54186
|
-
const distEsm = (0,
|
|
54261
|
+
const distEsm = (0, import_path10.join)(pkgRoot, "dist", "esm");
|
|
54187
54262
|
if (!(0, import_fs6.existsSync)(distEsm)) {
|
|
54188
54263
|
throw new LinkqueCliError(
|
|
54189
54264
|
"AGENTBUILD_INTEGRATE_NOT_BUILT",
|
|
@@ -54194,13 +54269,13 @@ var assertIntegrateBuilt = (pkgRoot) => {
|
|
|
54194
54269
|
|
|
54195
54270
|
// src/commands/agentbuild/buildCommand.ts
|
|
54196
54271
|
var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveOutDir, envOverrides) => {
|
|
54197
|
-
const outDir =
|
|
54272
|
+
const outDir = import_path11.default.join(cwd, AGENT_BUNDLE_DIR);
|
|
54198
54273
|
const start = Date.now();
|
|
54199
|
-
await (0,
|
|
54274
|
+
await (0, import_promises6.rm)(outDir, { force: true, recursive: true });
|
|
54200
54275
|
const stats = [];
|
|
54201
54276
|
try {
|
|
54202
54277
|
for (const def of FUNCTION_DEFS) {
|
|
54203
|
-
const fnOutDir =
|
|
54278
|
+
const fnOutDir = import_path11.default.join(outDir, def.$id);
|
|
54204
54279
|
const result = await bundleAgentInstallation({
|
|
54205
54280
|
// loadAgentProtocol 仅做最小校验(可读+JSON 对象+不含 apiKey),返回 Record;
|
|
54206
54281
|
// bundler 的 assertProtocolValid 会做运行时 IAgentProtocol 字段校验,这里 cast。
|
|
@@ -54225,14 +54300,14 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54225
54300
|
);
|
|
54226
54301
|
}
|
|
54227
54302
|
const configAbsPath = await writeAppwriteConfigTemplate(outDir, envOverrides);
|
|
54228
|
-
await (0,
|
|
54229
|
-
|
|
54303
|
+
await (0, import_promises6.writeFile)(
|
|
54304
|
+
import_path11.default.join(outDir, AGENT_DEPLOY_META_NAME),
|
|
54230
54305
|
`${JSON.stringify({ agentId: protocol.agentId }, null, 2)}
|
|
54231
54306
|
`,
|
|
54232
54307
|
"utf8"
|
|
54233
54308
|
);
|
|
54234
|
-
const configPath =
|
|
54235
|
-
const bundleDir =
|
|
54309
|
+
const configPath = import_path11.default.relative(cwd, configAbsPath);
|
|
54310
|
+
const bundleDir = import_path11.default.relative(cwd, outDir) || AGENT_BUNDLE_DIR;
|
|
54236
54311
|
const totalBytes = stats.reduce((sum, s4) => sum + s4.bytes, 0);
|
|
54237
54312
|
const durationMs = Date.now() - start;
|
|
54238
54313
|
await writePerFunctionArchives(outDir);
|
|
@@ -54253,7 +54328,7 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54253
54328
|
// archive 模式:对外交付物是 code.tar,bundle 目录是中间态。
|
|
54254
54329
|
bundleDir: "",
|
|
54255
54330
|
configPath,
|
|
54256
|
-
archivePath:
|
|
54331
|
+
archivePath: import_path11.default.relative(cwd, archiveAbsPath),
|
|
54257
54332
|
functions: stats,
|
|
54258
54333
|
totalBytes,
|
|
54259
54334
|
durationMs
|
|
@@ -54262,8 +54337,8 @@ var bundleWhileLocked = async (cwd, protocol, minify, pkgRoot, archive, archiveO
|
|
|
54262
54337
|
var writePerFunctionArchives = async (outDir) => {
|
|
54263
54338
|
try {
|
|
54264
54339
|
for (const def of FUNCTION_DEFS) {
|
|
54265
|
-
const fnOutDir =
|
|
54266
|
-
const fnArchive =
|
|
54340
|
+
const fnOutDir = import_path11.default.join(outDir, def.$id);
|
|
54341
|
+
const fnArchive = import_path11.default.join(outDir, `${def.$id}.tar.gz`);
|
|
54267
54342
|
await Qn(
|
|
54268
54343
|
{ gzip: true, cwd: fnOutDir, file: fnArchive, portable: true },
|
|
54269
54344
|
["."]
|
|
@@ -54278,11 +54353,11 @@ var writePerFunctionArchives = async (outDir) => {
|
|
|
54278
54353
|
}
|
|
54279
54354
|
};
|
|
54280
54355
|
var writeCodeTar = async (cwd, outDir, archiveOutDir) => {
|
|
54281
|
-
const archiveDirAbs =
|
|
54356
|
+
const archiveDirAbs = import_path11.default.resolve(
|
|
54282
54357
|
cwd,
|
|
54283
54358
|
archiveOutDir === "" ? DEFAULT_ARCHIVE_DIR : archiveOutDir
|
|
54284
54359
|
);
|
|
54285
|
-
const archiveAbsPath =
|
|
54360
|
+
const archiveAbsPath = import_path11.default.join(archiveDirAbs, AGENT_ARCHIVE_NAME);
|
|
54286
54361
|
await ensureParentDir(archiveAbsPath);
|
|
54287
54362
|
try {
|
|
54288
54363
|
await Qn(
|
|
@@ -54309,7 +54384,7 @@ var agentBuild = async (cwd, rawConfigPath, minify, archive, archiveOutDir, env,
|
|
|
54309
54384
|
const envOverrides = await resolveEnvOverrides(env, envFile, cwd);
|
|
54310
54385
|
return withWorkspaceLock(
|
|
54311
54386
|
{
|
|
54312
|
-
path:
|
|
54387
|
+
path: import_path11.default.join(cwd, AGENTBUILD_LOCK),
|
|
54313
54388
|
name: "agentbuild",
|
|
54314
54389
|
acquireErrorCode: "AGENTBUILD_LOCK_TIMEOUT",
|
|
54315
54390
|
releaseErrorCode: "AGENTBUILD_STATE_WRITE_FAILED",
|
|
@@ -54330,12 +54405,12 @@ var agentBuild = async (cwd, rawConfigPath, minify, archive, archiveOutDir, env,
|
|
|
54330
54405
|
|
|
54331
54406
|
// src/commands/agentdeploy/deployCommand.ts
|
|
54332
54407
|
var import_fs7 = require("fs");
|
|
54333
|
-
var
|
|
54408
|
+
var import_path13 = __toESM(require("path"));
|
|
54334
54409
|
|
|
54335
54410
|
// src/commands/agentdeploy/configLoader.ts
|
|
54336
|
-
var
|
|
54411
|
+
var import_promises7 = require("fs/promises");
|
|
54337
54412
|
var import_os2 = require("os");
|
|
54338
|
-
var
|
|
54413
|
+
var import_path12 = __toESM(require("path"));
|
|
54339
54414
|
|
|
54340
54415
|
// src/commands/agentdeploy/types.ts
|
|
54341
54416
|
var AGENTDEPLOY_LOCK = ".linkque/runtime/agentdeploy.lock";
|
|
@@ -54354,24 +54429,24 @@ var BUNDLE_CONFIG_NAME = "appwrite.config.json";
|
|
|
54354
54429
|
var readBundleAgentId = async (bundlePath) => {
|
|
54355
54430
|
let content;
|
|
54356
54431
|
if (await pathHasKind(bundlePath, "dir")) {
|
|
54357
|
-
content = await (0,
|
|
54358
|
-
|
|
54432
|
+
content = await (0, import_promises7.readFile)(
|
|
54433
|
+
import_path12.default.join(bundlePath, AGENT_DEPLOY_META_NAME),
|
|
54359
54434
|
"utf8"
|
|
54360
54435
|
).catch(() => "");
|
|
54361
54436
|
} else if (isArchivePath(bundlePath)) {
|
|
54362
|
-
const tmpDir = await (0,
|
|
54437
|
+
const tmpDir = await (0, import_promises7.mkdtemp)(import_path12.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-meta-"));
|
|
54363
54438
|
try {
|
|
54364
54439
|
await So({
|
|
54365
54440
|
file: bundlePath,
|
|
54366
54441
|
cwd: tmpDir,
|
|
54367
54442
|
filter: (entryPath) => entryPath.replace(/^\.\//, "") === AGENT_DEPLOY_META_NAME
|
|
54368
54443
|
});
|
|
54369
|
-
content = await (0,
|
|
54370
|
-
|
|
54444
|
+
content = await (0, import_promises7.readFile)(
|
|
54445
|
+
import_path12.default.join(tmpDir, AGENT_DEPLOY_META_NAME),
|
|
54371
54446
|
"utf8"
|
|
54372
54447
|
).catch(() => "");
|
|
54373
54448
|
} finally {
|
|
54374
|
-
await (0,
|
|
54449
|
+
await (0, import_promises7.rm)(tmpDir, { force: true, recursive: true });
|
|
54375
54450
|
}
|
|
54376
54451
|
} else {
|
|
54377
54452
|
content = "";
|
|
@@ -54390,7 +54465,7 @@ var readBundleAgentId = async (bundlePath) => {
|
|
|
54390
54465
|
};
|
|
54391
54466
|
var isArchivePath = (bundlePath) => bundlePath.endsWith(".tar") || bundlePath.endsWith(".tar.gz") || bundlePath.endsWith(".tgz");
|
|
54392
54467
|
var readConfigFromTar = async (tarPath) => {
|
|
54393
|
-
const tmpDir = await (0,
|
|
54468
|
+
const tmpDir = await (0, import_promises7.mkdtemp)(import_path12.default.join((0, import_os2.tmpdir)(), "linkquejs-bundle-cfg-"));
|
|
54394
54469
|
try {
|
|
54395
54470
|
await So({
|
|
54396
54471
|
file: tarPath,
|
|
@@ -54399,7 +54474,7 @@ var readConfigFromTar = async (tarPath) => {
|
|
|
54399
54474
|
filter: (entryPath) => entryPath.replace(/^\.\//, "") === BUNDLE_CONFIG_NAME
|
|
54400
54475
|
});
|
|
54401
54476
|
const content = await readUtf8IfExists(
|
|
54402
|
-
|
|
54477
|
+
import_path12.default.join(tmpDir, BUNDLE_CONFIG_NAME)
|
|
54403
54478
|
);
|
|
54404
54479
|
if (content === null) {
|
|
54405
54480
|
throw new LinkqueCliError(
|
|
@@ -54415,12 +54490,12 @@ var readConfigFromTar = async (tarPath) => {
|
|
|
54415
54490
|
`failed to read appwrite config from bundle archive ${tarPath}: ${error2 instanceof Error ? error2.message : String(error2)}`
|
|
54416
54491
|
);
|
|
54417
54492
|
} finally {
|
|
54418
|
-
await (0,
|
|
54493
|
+
await (0, import_promises7.rm)(tmpDir, { force: true, recursive: true });
|
|
54419
54494
|
}
|
|
54420
54495
|
};
|
|
54421
54496
|
var readBundleConfigContent = async (bundlePath) => {
|
|
54422
54497
|
if (await pathHasKind(bundlePath, "dir")) {
|
|
54423
|
-
const configPath =
|
|
54498
|
+
const configPath = import_path12.default.join(bundlePath, BUNDLE_CONFIG_NAME);
|
|
54424
54499
|
const content = await readUtf8IfExists(configPath);
|
|
54425
54500
|
if (content === null) {
|
|
54426
54501
|
throw new LinkqueCliError(
|
|
@@ -54488,7 +54563,7 @@ var parseAppwriteConfig = (content, configPath) => {
|
|
|
54488
54563
|
};
|
|
54489
54564
|
};
|
|
54490
54565
|
var loadDeployManifest = async (rawPath, cwd) => {
|
|
54491
|
-
const manifestPath =
|
|
54566
|
+
const manifestPath = import_path12.default.resolve(
|
|
54492
54567
|
cwd,
|
|
54493
54568
|
rawPath === "" ? DEFAULT_MANIFEST_NAME : rawPath
|
|
54494
54569
|
);
|
|
@@ -54740,7 +54815,7 @@ var deployWhileLocked = async (cwd, cfg, apiKey, agentId, bundlePath, options) =
|
|
|
54740
54815
|
{ cause: error2 }
|
|
54741
54816
|
);
|
|
54742
54817
|
}
|
|
54743
|
-
const statePath =
|
|
54818
|
+
const statePath = import_path13.default.join(cwd, AGENTDEPLOY_STATE);
|
|
54744
54819
|
await ensureParentDir(statePath);
|
|
54745
54820
|
try {
|
|
54746
54821
|
await writeJsonAtomically(statePath, { deployedAt: Date.now(), results });
|
|
@@ -54763,7 +54838,7 @@ var deployWhileLocked = async (cwd, cfg, apiKey, agentId, bundlePath, options) =
|
|
|
54763
54838
|
return { results, okCount, totalCount, allOk: true };
|
|
54764
54839
|
};
|
|
54765
54840
|
var agentDeploy = async (cwd, options) => {
|
|
54766
|
-
const bundlePath = options.bundlePath ??
|
|
54841
|
+
const bundlePath = options.bundlePath ?? import_path13.default.join(cwd, AGENT_BUNDLE_DIR);
|
|
54767
54842
|
if (!(0, import_fs7.existsSync)(bundlePath)) {
|
|
54768
54843
|
throw new LinkqueCliError(
|
|
54769
54844
|
"AGENTDEPLOY_BUNDLE_NOT_FOUND",
|
|
@@ -54800,7 +54875,7 @@ var agentDeploy = async (cwd, options) => {
|
|
|
54800
54875
|
}
|
|
54801
54876
|
return withWorkspaceLock(
|
|
54802
54877
|
{
|
|
54803
|
-
path:
|
|
54878
|
+
path: import_path13.default.join(cwd, AGENTDEPLOY_LOCK),
|
|
54804
54879
|
name: "agentdeploy",
|
|
54805
54880
|
acquireErrorCode: "AGENTDEPLOY_LOCK_TIMEOUT",
|
|
54806
54881
|
releaseErrorCode: "AGENTDEPLOY_STATE_WRITE_FAILED",
|
|
@@ -54847,7 +54922,7 @@ var SandboxRuntimeConfigProvider = class extends RuntimeConfigProvider {
|
|
|
54847
54922
|
|
|
54848
54923
|
// src/commands/agentdev/configLoader.ts
|
|
54849
54924
|
var import_crypto3 = require("crypto");
|
|
54850
|
-
var
|
|
54925
|
+
var import_path14 = __toESM(require("path"));
|
|
54851
54926
|
|
|
54852
54927
|
// src/commands/agentdev/types.ts
|
|
54853
54928
|
var MODEL_PROVIDER_BY_GATEWAY = Object.freeze({ LINKQUE: "LINKQUE", TEST: "TEST" });
|
|
@@ -54884,7 +54959,7 @@ var stopped = (health) => ({
|
|
|
54884
54959
|
// src/commands/agentdev/configLoader.ts
|
|
54885
54960
|
var DEFAULT_CONFIG_NAME2 = "agent_config.json";
|
|
54886
54961
|
var loadAgentConfig = async (rawConfigPath, cwd) => {
|
|
54887
|
-
const configPath =
|
|
54962
|
+
const configPath = import_path14.default.resolve(
|
|
54888
54963
|
cwd,
|
|
54889
54964
|
rawConfigPath === "" ? DEFAULT_CONFIG_NAME2 : rawConfigPath
|
|
54890
54965
|
);
|
|
@@ -54992,9 +55067,9 @@ var normalizeModelProvider = (provider, configPath) => {
|
|
|
54992
55067
|
};
|
|
54993
55068
|
|
|
54994
55069
|
// src/commands/agentdev/ownerState.ts
|
|
54995
|
-
var
|
|
55070
|
+
var import_promises8 = require("fs/promises");
|
|
54996
55071
|
var import_net = require("net");
|
|
54997
|
-
var
|
|
55072
|
+
var import_path15 = __toESM(require("path"));
|
|
54998
55073
|
var isAgentHttpHealthy = async (port) => {
|
|
54999
55074
|
const probeUrl = new URL(`http://127.0.0.1:${port}${HEALTH_PATH}`);
|
|
55000
55075
|
try {
|
|
@@ -55040,7 +55115,7 @@ var readOwnedAgentState = async (statePath) => {
|
|
|
55040
55115
|
};
|
|
55041
55116
|
async function removeMatchingState(statePath, pid) {
|
|
55042
55117
|
const owned = await readOwnedAgentState(statePath);
|
|
55043
|
-
if (owned?.state.pid === pid) await (0,
|
|
55118
|
+
if (owned?.state.pid === pid) await (0, import_promises8.rm)(statePath, { force: true });
|
|
55044
55119
|
}
|
|
55045
55120
|
async function terminateOwner(statePath, pid) {
|
|
55046
55121
|
if (!isProcessAlive(pid)) {
|
|
@@ -55086,14 +55161,14 @@ var statusFromState = async (state) => ({
|
|
|
55086
55161
|
startedAt: state.startedAt
|
|
55087
55162
|
});
|
|
55088
55163
|
var inspectRecordedAgentServer = async (cwd, legacyFailureCode = "AGENTDEV_STOP_FAILED") => {
|
|
55089
|
-
const statePath =
|
|
55164
|
+
const statePath = import_path15.default.join(cwd, RUNTIME_DIR, AGENT_STATE);
|
|
55090
55165
|
const content = await readUtf8IfExists(statePath);
|
|
55091
55166
|
if (content === null) {
|
|
55092
55167
|
return { state: null, status: stopped("STOPPED") };
|
|
55093
55168
|
}
|
|
55094
55169
|
const owned = parseOwnedAgentState(content);
|
|
55095
55170
|
if (owned === null) {
|
|
55096
|
-
await (0,
|
|
55171
|
+
await (0, import_promises8.rm)(statePath, { force: true });
|
|
55097
55172
|
return { state: null, status: stopped("STALE") };
|
|
55098
55173
|
}
|
|
55099
55174
|
if (owned.kind === "legacy") {
|
|
@@ -55122,9 +55197,9 @@ var inspectAgentServer = async (cwd) => (await inspectRecordedAgentServer(cwd)).
|
|
|
55122
55197
|
|
|
55123
55198
|
// src/commands/agentdev/startCommand.ts
|
|
55124
55199
|
var import_child_process = require("child_process");
|
|
55125
|
-
var
|
|
55200
|
+
var import_path16 = __toESM(require("path"));
|
|
55126
55201
|
var spawnAgentOwner = (cwd, config3, port, apiKey, statePath) => {
|
|
55127
|
-
const workerPath =
|
|
55202
|
+
const workerPath = import_path16.default.resolve(__dirname, "worker.js");
|
|
55128
55203
|
const input = Buffer.from(
|
|
55129
55204
|
JSON.stringify({
|
|
55130
55205
|
agentId: config3.agentId,
|
|
@@ -55133,7 +55208,7 @@ var spawnAgentOwner = (cwd, config3, port, apiKey, statePath) => {
|
|
|
55133
55208
|
healthPath: HEALTH_PATH,
|
|
55134
55209
|
homeDataPath: HOME_DATA_PATH,
|
|
55135
55210
|
functionActionMcpPath: FUNCTION_ACTION_MCP_PATH,
|
|
55136
|
-
logPath:
|
|
55211
|
+
logPath: import_path16.default.join(cwd, AGENT_LOG),
|
|
55137
55212
|
port,
|
|
55138
55213
|
runsPath: RUNS_PATH,
|
|
55139
55214
|
statePath
|
|
@@ -55232,9 +55307,9 @@ var startAgentServerWhileLocked = async (cwd, config3, apiKey, port, statePath)
|
|
|
55232
55307
|
var startAgentServer = async (cwd, rawConfigPath, port) => {
|
|
55233
55308
|
const config3 = await loadAgentConfig(rawConfigPath, cwd);
|
|
55234
55309
|
const { apiKey } = resolveAuth(config3);
|
|
55235
|
-
const runtimeDir =
|
|
55236
|
-
const lockPath =
|
|
55237
|
-
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);
|
|
55238
55313
|
await ensureParentDir(statePath);
|
|
55239
55314
|
return withWorkspaceLock(
|
|
55240
55315
|
{
|
|
@@ -55250,11 +55325,11 @@ var startAgentServer = async (cwd, rawConfigPath, port) => {
|
|
|
55250
55325
|
};
|
|
55251
55326
|
|
|
55252
55327
|
// src/commands/agentdev/stopCommand.ts
|
|
55253
|
-
var
|
|
55254
|
-
var
|
|
55328
|
+
var import_promises9 = require("fs/promises");
|
|
55329
|
+
var import_path17 = __toESM(require("path"));
|
|
55255
55330
|
var stopAgentServer = async (cwd) => {
|
|
55256
|
-
const lockPath =
|
|
55257
|
-
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);
|
|
55258
55333
|
await ensureParentDir(statePath);
|
|
55259
55334
|
return withWorkspaceLock(
|
|
55260
55335
|
{
|
|
@@ -55268,7 +55343,7 @@ var stopAgentServer = async (cwd) => {
|
|
|
55268
55343
|
async () => {
|
|
55269
55344
|
const owned = await readOwnedAgentState(statePath);
|
|
55270
55345
|
if (owned !== null) await terminateOwner(statePath, owned.state.pid);
|
|
55271
|
-
await (0,
|
|
55346
|
+
await (0, import_promises9.rm)(statePath, { force: true });
|
|
55272
55347
|
return { stopped: true };
|
|
55273
55348
|
}
|
|
55274
55349
|
);
|
|
@@ -55276,15 +55351,15 @@ var stopAgentServer = async (cwd) => {
|
|
|
55276
55351
|
|
|
55277
55352
|
// src/commands/build/dist.ts
|
|
55278
55353
|
var import_crypto7 = require("crypto");
|
|
55279
|
-
var
|
|
55280
|
-
var
|
|
55354
|
+
var import_promises14 = require("fs/promises");
|
|
55355
|
+
var import_path21 = __toESM(require("path"));
|
|
55281
55356
|
|
|
55282
55357
|
// src/utils/spawn.ts
|
|
55283
55358
|
var import_child_process2 = require("child_process");
|
|
55284
|
-
var
|
|
55359
|
+
var import_promises10 = require("fs/promises");
|
|
55285
55360
|
var spawnManaged = async (options) => {
|
|
55286
55361
|
await ensureParentDir(options.logPath);
|
|
55287
|
-
const log = await (0,
|
|
55362
|
+
const log = await (0, import_promises10.open)(options.logPath, "a");
|
|
55288
55363
|
try {
|
|
55289
55364
|
await log.writeFile(
|
|
55290
55365
|
`
|
|
@@ -55349,8 +55424,8 @@ var spawnManaged = async (options) => {
|
|
|
55349
55424
|
// src/commands/install.ts
|
|
55350
55425
|
var import_child_process3 = require("child_process");
|
|
55351
55426
|
var import_crypto4 = require("crypto");
|
|
55352
|
-
var
|
|
55353
|
-
var
|
|
55427
|
+
var import_promises11 = require("fs/promises");
|
|
55428
|
+
var import_path18 = __toESM(require("path"));
|
|
55354
55429
|
var RUNTIME_DIR2 = ".linkque/runtime";
|
|
55355
55430
|
var LOG_DIR = ".linkque/logs";
|
|
55356
55431
|
var INSTALL_LOCK = "install.lock";
|
|
@@ -55403,7 +55478,7 @@ var readLockfiles = async (cwd) => {
|
|
|
55403
55478
|
const lockfiles = /* @__PURE__ */ new Map();
|
|
55404
55479
|
await Promise.all(
|
|
55405
55480
|
LOCKFILES.map(async (name) => {
|
|
55406
|
-
const content = await readUtf8IfExists(
|
|
55481
|
+
const content = await readUtf8IfExists(import_path18.default.join(cwd, name));
|
|
55407
55482
|
if (content !== null) lockfiles.set(name, content);
|
|
55408
55483
|
})
|
|
55409
55484
|
);
|
|
@@ -55424,7 +55499,7 @@ var readDependencyInputs = async (cwd) => {
|
|
|
55424
55499
|
let lockfiles;
|
|
55425
55500
|
try {
|
|
55426
55501
|
[packageJson, lockfiles] = await Promise.all([
|
|
55427
|
-
(0,
|
|
55502
|
+
(0, import_promises11.readFile)(import_path18.default.join(cwd, "package.json"), "utf8"),
|
|
55428
55503
|
readLockfiles(cwd)
|
|
55429
55504
|
]);
|
|
55430
55505
|
} catch (error2) {
|
|
@@ -55451,10 +55526,10 @@ var readInstallState = async (statePath) => {
|
|
|
55451
55526
|
}
|
|
55452
55527
|
};
|
|
55453
55528
|
var hasInstalledDependencies = async (cwd) => {
|
|
55454
|
-
if (await pathHasKind(
|
|
55529
|
+
if (await pathHasKind(import_path18.default.join(cwd, "node_modules"), "dir")) return true;
|
|
55455
55530
|
const [pnpCjs, pnpJs] = await Promise.all([
|
|
55456
|
-
pathHasKind(
|
|
55457
|
-
pathHasKind(
|
|
55531
|
+
pathHasKind(import_path18.default.join(cwd, ".pnp.cjs"), "file"),
|
|
55532
|
+
pathHasKind(import_path18.default.join(cwd, ".pnp.js"), "file")
|
|
55458
55533
|
]);
|
|
55459
55534
|
return pnpCjs || pnpJs;
|
|
55460
55535
|
};
|
|
@@ -55482,9 +55557,9 @@ var writeInstallState = async (statePath, fingerprint, toolchain) => {
|
|
|
55482
55557
|
);
|
|
55483
55558
|
}
|
|
55484
55559
|
};
|
|
55485
|
-
var installLockPath = (cwd) =>
|
|
55486
|
-
var installStatePath = (cwd) =>
|
|
55487
|
-
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);
|
|
55488
55563
|
var inspectInstallation = async (cwd) => {
|
|
55489
55564
|
if (await pathExists(installLockPath(cwd))) {
|
|
55490
55565
|
return {
|
|
@@ -55536,7 +55611,7 @@ var installDependenciesWhileLocked = async (cwd, { force }) => {
|
|
|
55536
55611
|
}
|
|
55537
55612
|
if (previousState?.fingerprint === fingerprint) {
|
|
55538
55613
|
try {
|
|
55539
|
-
await (0,
|
|
55614
|
+
await (0, import_promises11.rm)(statePath, { force: true });
|
|
55540
55615
|
} catch (error2) {
|
|
55541
55616
|
throw new LinkqueCliError(
|
|
55542
55617
|
"INSTALL_STATE_WRITE_FAILED",
|
|
@@ -55584,14 +55659,14 @@ var installDependencies = async (cwd, { force = false } = {}) => withWorkspaceLo
|
|
|
55584
55659
|
);
|
|
55585
55660
|
|
|
55586
55661
|
// src/commands/setup.ts
|
|
55587
|
-
var
|
|
55662
|
+
var import_path19 = __toESM(require("path"));
|
|
55588
55663
|
var CONFIG_FILE = "linkque.config.json";
|
|
55589
55664
|
var INITIAL_CONFIG = {
|
|
55590
55665
|
managedBy: "linkquejs",
|
|
55591
55666
|
schemaVersion: 1
|
|
55592
55667
|
};
|
|
55593
55668
|
var assertSupportedProject = async (cwd) => {
|
|
55594
|
-
const packageJson = await readUtf8IfExists(
|
|
55669
|
+
const packageJson = await readUtf8IfExists(import_path19.default.join(cwd, "package.json"));
|
|
55595
55670
|
if (packageJson === null) {
|
|
55596
55671
|
throw new LinkqueCliError(
|
|
55597
55672
|
"SETUP_PROJECT_UNSUPPORTED",
|
|
@@ -55630,11 +55705,11 @@ var inspectExistingConfig = async (configPath) => {
|
|
|
55630
55705
|
};
|
|
55631
55706
|
var inspectProjectSetup = async (cwd) => {
|
|
55632
55707
|
await assertSupportedProject(cwd);
|
|
55633
|
-
return await inspectExistingConfig(
|
|
55708
|
+
return await inspectExistingConfig(import_path19.default.join(cwd, CONFIG_FILE));
|
|
55634
55709
|
};
|
|
55635
55710
|
var setupProject = async (cwd) => {
|
|
55636
55711
|
await assertSupportedProject(cwd);
|
|
55637
|
-
const configPath =
|
|
55712
|
+
const configPath = import_path19.default.join(cwd, CONFIG_FILE);
|
|
55638
55713
|
if (await inspectExistingConfig(configPath)) {
|
|
55639
55714
|
return { changed: false, managedFiles: [] };
|
|
55640
55715
|
}
|
|
@@ -55681,10 +55756,10 @@ var inspectWorkspaceStatus = async (cwd) => {
|
|
|
55681
55756
|
|
|
55682
55757
|
// src/commands/build/archive.ts
|
|
55683
55758
|
var import_crypto6 = require("crypto");
|
|
55684
|
-
var
|
|
55685
|
-
var
|
|
55759
|
+
var import_promises12 = require("fs/promises");
|
|
55760
|
+
var import_path20 = __toESM(require("path"));
|
|
55686
55761
|
var import_stream = require("stream");
|
|
55687
|
-
var
|
|
55762
|
+
var import_promises13 = require("stream/promises");
|
|
55688
55763
|
|
|
55689
55764
|
// ../../node_modules/@zip.js/zip.js/lib/zip-fs-wasm.js
|
|
55690
55765
|
init_configuration();
|
|
@@ -59020,7 +59095,7 @@ var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
|
|
|
59020
59095
|
const visit = async (current) => {
|
|
59021
59096
|
let entries;
|
|
59022
59097
|
try {
|
|
59023
|
-
entries = await (0,
|
|
59098
|
+
entries = await (0, import_promises12.readdir)(current, { withFileTypes: true });
|
|
59024
59099
|
} catch (error2) {
|
|
59025
59100
|
if (isNodeError(error2, "ENOENT")) return [];
|
|
59026
59101
|
throw error2;
|
|
@@ -59028,13 +59103,13 @@ var walkFiles = async (root, exclude = /* @__PURE__ */ new Set()) => {
|
|
|
59028
59103
|
const files = [];
|
|
59029
59104
|
for (const entry of entries) {
|
|
59030
59105
|
if (exclude.has(entry.name)) continue;
|
|
59031
|
-
const absolutePath =
|
|
59106
|
+
const absolutePath = import_path20.default.join(current, entry.name);
|
|
59032
59107
|
if (entry.isDirectory()) {
|
|
59033
59108
|
files.push(...await visit(absolutePath));
|
|
59034
59109
|
} else if (entry.isFile()) {
|
|
59035
59110
|
files.push({
|
|
59036
59111
|
absolutePath,
|
|
59037
|
-
archivePath:
|
|
59112
|
+
archivePath: import_path20.default.relative(root, absolutePath).split(import_path20.default.sep).join("/")
|
|
59038
59113
|
});
|
|
59039
59114
|
}
|
|
59040
59115
|
}
|
|
@@ -59053,7 +59128,7 @@ var HashingArchiveWriter = class extends import_stream.Writable {
|
|
|
59053
59128
|
handle;
|
|
59054
59129
|
size = 0;
|
|
59055
59130
|
async initialize() {
|
|
59056
|
-
this.handle = await (0,
|
|
59131
|
+
this.handle = await (0, import_promises12.open)(this.archivePath, "wx");
|
|
59057
59132
|
}
|
|
59058
59133
|
identity() {
|
|
59059
59134
|
return { sha256: this.hash.digest("hex"), size: this.size };
|
|
@@ -59115,7 +59190,7 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
|
|
|
59115
59190
|
try {
|
|
59116
59191
|
for (const file of files) {
|
|
59117
59192
|
const frozen = frozenContents.get(file.archivePath);
|
|
59118
|
-
const content = frozen ?? await (0,
|
|
59193
|
+
const content = frozen ?? await (0, import_promises12.readFile)(file.absolutePath);
|
|
59119
59194
|
await appendFile(file.archivePath, content);
|
|
59120
59195
|
}
|
|
59121
59196
|
await zip.close();
|
|
@@ -59129,7 +59204,7 @@ var writeArchive = async (files, tempPath, options = {}, frozenContents = /* @__
|
|
|
59129
59204
|
};
|
|
59130
59205
|
} catch (error2) {
|
|
59131
59206
|
output.destroy();
|
|
59132
|
-
await (0,
|
|
59207
|
+
await (0, import_promises13.finished)(output).catch(() => void 0);
|
|
59133
59208
|
if (error2 instanceof LinkqueCliError) throw error2;
|
|
59134
59209
|
throw new LinkqueCliError(
|
|
59135
59210
|
"BUILD_ARCHIVE_FAILED",
|
|
@@ -59152,14 +59227,14 @@ var runBuild = async (cwd) => {
|
|
|
59152
59227
|
command: TOOLCHAIN2,
|
|
59153
59228
|
args: ["run", "build"],
|
|
59154
59229
|
cwd,
|
|
59155
|
-
logPath:
|
|
59230
|
+
logPath: import_path21.default.join(cwd, LOG_PATH),
|
|
59156
59231
|
logHeader: `${TOOLCHAIN2} run build`
|
|
59157
59232
|
});
|
|
59158
59233
|
return exitCode;
|
|
59159
59234
|
};
|
|
59160
59235
|
var assertBuildCommand = async (cwd) => {
|
|
59161
59236
|
const packageJson = parseJsonObject(
|
|
59162
|
-
await (0,
|
|
59237
|
+
await (0, import_promises14.readFile)(import_path21.default.join(cwd, "package.json"), "utf8").catch((error2) => {
|
|
59163
59238
|
throw new LinkqueCliError(
|
|
59164
59239
|
"BUILD_COMMAND_NOT_FOUND",
|
|
59165
59240
|
"workspace package.json must contain a build script",
|
|
@@ -59189,10 +59264,10 @@ var assertBuildOutput = (files) => {
|
|
|
59189
59264
|
}
|
|
59190
59265
|
};
|
|
59191
59266
|
var buildDistWhileLocked = async (cwd) => {
|
|
59192
|
-
const outputPath =
|
|
59193
|
-
const finalPath =
|
|
59267
|
+
const outputPath = import_path21.default.join(cwd, OUTPUT_DIR);
|
|
59268
|
+
const finalPath = import_path21.default.join(cwd, ARCHIVE_PATH);
|
|
59194
59269
|
const tempPath = `${finalPath}.${process.pid}.${(0, import_crypto7.randomUUID)()}.tmp`;
|
|
59195
|
-
await (0,
|
|
59270
|
+
await (0, import_promises14.rm)(finalPath, { force: true }).catch((error2) => {
|
|
59196
59271
|
throw new LinkqueCliError(
|
|
59197
59272
|
"BUILD_ARCHIVE_FAILED",
|
|
59198
59273
|
"stale build archive could not be removed",
|
|
@@ -59217,7 +59292,7 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59217
59292
|
);
|
|
59218
59293
|
}
|
|
59219
59294
|
await assertBuildCommand(cwd);
|
|
59220
|
-
await (0,
|
|
59295
|
+
await (0, import_promises14.rm)(outputPath, { force: true, recursive: true }).catch(
|
|
59221
59296
|
(error2) => {
|
|
59222
59297
|
throw new LinkqueCliError(
|
|
59223
59298
|
"BUILD_FAILED",
|
|
@@ -59252,7 +59327,7 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59252
59327
|
);
|
|
59253
59328
|
}
|
|
59254
59329
|
);
|
|
59255
|
-
await (0,
|
|
59330
|
+
await (0, import_promises14.rename)(tempPath, finalPath).catch((error2) => {
|
|
59256
59331
|
throw new LinkqueCliError(
|
|
59257
59332
|
"BUILD_ARCHIVE_FAILED",
|
|
59258
59333
|
"build archive could not be finalized",
|
|
@@ -59269,8 +59344,8 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59269
59344
|
} catch (error2) {
|
|
59270
59345
|
try {
|
|
59271
59346
|
await Promise.all([
|
|
59272
|
-
(0,
|
|
59273
|
-
(0,
|
|
59347
|
+
(0, import_promises14.rm)(finalPath, { force: true }),
|
|
59348
|
+
(0, import_promises14.rm)(tempPath, { force: true })
|
|
59274
59349
|
]);
|
|
59275
59350
|
} catch (cleanupError) {
|
|
59276
59351
|
throw preservePrimaryFailure(error2, cleanupError);
|
|
@@ -59280,21 +59355,22 @@ var buildDistWhileLocked = async (cwd) => {
|
|
|
59280
59355
|
};
|
|
59281
59356
|
var buildDist = async (cwd) => withWorkspaceLock(
|
|
59282
59357
|
{
|
|
59283
|
-
path:
|
|
59358
|
+
path: import_path21.default.join(cwd, LOCK_PATH),
|
|
59284
59359
|
name: "build",
|
|
59285
59360
|
acquireErrorCode: "BUILD_LOCK_TIMEOUT",
|
|
59286
59361
|
releaseErrorCode: "BUILD_ARCHIVE_FAILED",
|
|
59287
59362
|
retryMs: LOCK_RETRY_MS3,
|
|
59288
59363
|
timeoutMs: LOCK_TIMEOUT_MS4,
|
|
59289
|
-
onReleaseFailure: () => (0,
|
|
59364
|
+
onReleaseFailure: () => (0, import_promises14.rm)(import_path21.default.join(cwd, ARCHIVE_PATH), { force: true })
|
|
59290
59365
|
},
|
|
59291
59366
|
() => buildDistWhileLocked(cwd)
|
|
59292
59367
|
);
|
|
59293
59368
|
|
|
59294
59369
|
// src/commands/build/snapshot.ts
|
|
59295
59370
|
var import_crypto8 = require("crypto");
|
|
59296
|
-
var
|
|
59297
|
-
var
|
|
59371
|
+
var import_promises15 = require("fs/promises");
|
|
59372
|
+
var import_path22 = __toESM(require("path"));
|
|
59373
|
+
var import_promises16 = require("fs/promises");
|
|
59298
59374
|
var ARTIFACTS_DIR = ".linkque/artifacts";
|
|
59299
59375
|
var AGENT_CONFIG_SOURCE_PATH = "agent_config.json";
|
|
59300
59376
|
var TEMPLATE_ARTIFACT_SOURCE_PATH = "template-artifact.json";
|
|
@@ -59314,8 +59390,8 @@ var snapshotFailure = (message, cause) => cause instanceof LinkqueCliError ? cau
|
|
|
59314
59390
|
var readTemplateVersion = async (cwd) => {
|
|
59315
59391
|
let content;
|
|
59316
59392
|
try {
|
|
59317
|
-
content = await (0,
|
|
59318
|
-
|
|
59393
|
+
content = await (0, import_promises15.readFile)(
|
|
59394
|
+
import_path22.default.join(cwd, TEMPLATE_ARTIFACT_SOURCE_PATH),
|
|
59319
59395
|
"utf8"
|
|
59320
59396
|
);
|
|
59321
59397
|
} catch (error2) {
|
|
@@ -59335,15 +59411,15 @@ var readTemplateVersion = async (cwd) => {
|
|
|
59335
59411
|
};
|
|
59336
59412
|
var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
59337
59413
|
const snapshotDir = `snapshot-${(0, import_crypto8.randomUUID)()}`;
|
|
59338
|
-
const relDir =
|
|
59339
|
-
const dirPath =
|
|
59340
|
-
const archiveRel =
|
|
59341
|
-
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);
|
|
59342
59418
|
const tempPath = `${finalPath}.${process.pid}.tmp`;
|
|
59343
59419
|
try {
|
|
59344
59420
|
let rootStat;
|
|
59345
59421
|
try {
|
|
59346
|
-
rootStat = await (0,
|
|
59422
|
+
rootStat = await (0, import_promises15.lstat)(cwd, { bigint: true });
|
|
59347
59423
|
} catch (error2) {
|
|
59348
59424
|
throw snapshotFailure("workspace source could not be inspected", error2);
|
|
59349
59425
|
}
|
|
@@ -59353,32 +59429,45 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
|
59353
59429
|
"snapshot root must be a directory"
|
|
59354
59430
|
);
|
|
59355
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));
|
|
59356
59438
|
const excludedComponents = new Set(BASE_EXCLUDED_COMPONENTS);
|
|
59357
59439
|
if (options.excludePlatformSdk) excludedComponents.add(".platform-sdk");
|
|
59358
|
-
const
|
|
59440
|
+
const walkedFiles = await walkFiles(cwd, excludedComponents).catch(
|
|
59359
59441
|
(error2) => {
|
|
59360
59442
|
throw snapshotFailure("workspace source could not be inspected", error2);
|
|
59361
59443
|
}
|
|
59362
59444
|
);
|
|
59363
|
-
const
|
|
59364
|
-
|
|
59365
|
-
|
|
59366
|
-
|
|
59367
|
-
|
|
59368
|
-
|
|
59369
|
-
|
|
59370
|
-
|
|
59371
|
-
|
|
59372
|
-
|
|
59373
|
-
|
|
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
|
+
);
|
|
59374
59457
|
if (!files.some((file) => file.archivePath === AGENT_CONFIG_SOURCE_PATH)) {
|
|
59375
59458
|
throw new LinkqueCliError(
|
|
59376
59459
|
"SNAPSHOT_FAILED",
|
|
59377
59460
|
"agent_config.json is not part of the walked source tree"
|
|
59378
59461
|
);
|
|
59379
59462
|
}
|
|
59380
|
-
const frozenContents =
|
|
59381
|
-
[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
|
+
)
|
|
59382
59471
|
]);
|
|
59383
59472
|
const templateVersion = await readTemplateVersion(cwd);
|
|
59384
59473
|
await ensureParentDir(finalPath);
|
|
@@ -59394,7 +59483,7 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
|
59394
59483
|
error2
|
|
59395
59484
|
);
|
|
59396
59485
|
});
|
|
59397
|
-
await (0,
|
|
59486
|
+
await (0, import_promises15.rename)(tempPath, finalPath).catch((error2) => {
|
|
59398
59487
|
throw new LinkqueCliError(
|
|
59399
59488
|
"SNAPSHOT_FAILED",
|
|
59400
59489
|
"source archive could not be finalized",
|
|
@@ -59409,20 +59498,21 @@ var buildSnapshotWhileLocked = async (cwd, options) => {
|
|
|
59409
59498
|
totalBytes: identity.sourceBytes,
|
|
59410
59499
|
sourceChecksum: identity.sourceChecksum,
|
|
59411
59500
|
agentConfigBase64: agentConfigContent.toString("base64"),
|
|
59501
|
+
cardFilesPath,
|
|
59412
59502
|
...templateVersion ? { templateVersion } : {}
|
|
59413
59503
|
};
|
|
59414
59504
|
} catch (error2) {
|
|
59415
59505
|
try {
|
|
59416
|
-
await (0,
|
|
59506
|
+
await (0, import_promises15.rm)(dirPath, { force: true, recursive: true });
|
|
59417
59507
|
} catch (cleanupError) {
|
|
59418
59508
|
throw preservePrimaryFailure(error2, cleanupError);
|
|
59419
59509
|
}
|
|
59420
|
-
throw error2;
|
|
59510
|
+
throw snapshotFailure("workspace snapshot could not be created", error2);
|
|
59421
59511
|
}
|
|
59422
59512
|
};
|
|
59423
59513
|
var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
|
|
59424
59514
|
{
|
|
59425
|
-
path:
|
|
59515
|
+
path: import_path22.default.join(cwd, LOCK_PATH2),
|
|
59426
59516
|
name: "snapshot",
|
|
59427
59517
|
acquireErrorCode: "SNAPSHOT_FAILED",
|
|
59428
59518
|
releaseErrorCode: "SNAPSHOT_FAILED",
|
|
@@ -59435,12 +59525,12 @@ var buildSnapshot = async (cwd, options = {}) => withWorkspaceLock(
|
|
|
59435
59525
|
|
|
59436
59526
|
// src/commands/card/index.ts
|
|
59437
59527
|
var import_crypto9 = require("crypto");
|
|
59438
|
-
var
|
|
59439
|
-
var
|
|
59528
|
+
var import_promises18 = require("fs/promises");
|
|
59529
|
+
var import_path24 = __toESM(require("path"));
|
|
59440
59530
|
|
|
59441
59531
|
// src/commands/mcpDescribe.ts
|
|
59442
|
-
var
|
|
59443
|
-
var
|
|
59532
|
+
var import_promises17 = require("fs/promises");
|
|
59533
|
+
var import_path23 = __toESM(require("path"));
|
|
59444
59534
|
var MCP_DETAIL_ENDPOINT_ENV = "LINKQUE_MCP_DETAIL_ENDPOINT";
|
|
59445
59535
|
var MCP_DETAIL_ENABLED_ENV = "LINKQUE_MCP_DETAIL_ENABLED";
|
|
59446
59536
|
var TIMEOUT_MS = 15e3;
|
|
@@ -59509,7 +59599,7 @@ function requireEnabled(env) {
|
|
|
59509
59599
|
async function readMountedMcp(cwd, resourceId) {
|
|
59510
59600
|
let content;
|
|
59511
59601
|
try {
|
|
59512
|
-
content = await (0,
|
|
59602
|
+
content = await (0, import_promises17.readFile)(import_path23.default.join(cwd, "agent_config.json"));
|
|
59513
59603
|
} catch {
|
|
59514
59604
|
throw new LinkqueCliError(
|
|
59515
59605
|
"MCP_CONFIG_READ_FAILED",
|
|
@@ -59790,7 +59880,7 @@ var SHA256_PATTERN = /^[0-9a-f]{64}$/u;
|
|
|
59790
59880
|
async function listCardDrafts(cwd) {
|
|
59791
59881
|
const [directories, configModifiedAt, runtimeSupportedSchemaVersions] = await Promise.all([
|
|
59792
59882
|
listDraftDirectories(cwd),
|
|
59793
|
-
readModifiedAt(
|
|
59883
|
+
readModifiedAt(import_path24.default.join(cwd, AGENT_CONFIG_PATH)),
|
|
59794
59884
|
readRuntimeSupportedSchemaVersions(cwd)
|
|
59795
59885
|
]);
|
|
59796
59886
|
const drafts = await Promise.all(
|
|
@@ -59802,7 +59892,7 @@ async function readCardDraft(cwd, draftId) {
|
|
|
59802
59892
|
assertDraftId(draftId);
|
|
59803
59893
|
const directory = draftDirectory(cwd, draftId);
|
|
59804
59894
|
const stateValue = await readRequiredJson(
|
|
59805
|
-
|
|
59895
|
+
import_path24.default.join(directory, "state.json"),
|
|
59806
59896
|
"CARD_DRAFT_NOT_FOUND"
|
|
59807
59897
|
);
|
|
59808
59898
|
const state = parseCardDraftState(stateValue);
|
|
@@ -59814,8 +59904,8 @@ async function readCardDraft(cwd, draftId) {
|
|
|
59814
59904
|
}
|
|
59815
59905
|
const [bundle, savedValue, theme] = await Promise.all([
|
|
59816
59906
|
readBundle(directory, draftId),
|
|
59817
|
-
readOptionalJson(
|
|
59818
|
-
readOptionalJsonObject(
|
|
59907
|
+
readOptionalJson(import_path24.default.join(directory, "saved.json")),
|
|
59908
|
+
readOptionalJsonObject(import_path24.default.join(cwd, THEME_PATH))
|
|
59819
59909
|
]);
|
|
59820
59910
|
const saved = parseSavedMarker(savedValue);
|
|
59821
59911
|
return {
|
|
@@ -59843,13 +59933,13 @@ async function prepareCardBindingContext(cwd, draftId, resourceIds, env = proces
|
|
|
59843
59933
|
}
|
|
59844
59934
|
const selectedIds = [...new Set(resourceIds)];
|
|
59845
59935
|
const directory = draftDirectory(cwd, draftId);
|
|
59846
|
-
const contextPath =
|
|
59847
|
-
const file =
|
|
59936
|
+
const contextPath = import_path24.default.join(DRAFT_ROOT, draftId, "binding-context.json");
|
|
59937
|
+
const file = import_path24.default.join(cwd, contextPath);
|
|
59848
59938
|
await assertBindingContextDirectory(cwd, directory);
|
|
59849
59939
|
const bundle = await readBundle(directory, draftId);
|
|
59850
59940
|
const readConfig = async () => parseAgentConfig(
|
|
59851
59941
|
await readRequiredJsonWithLimit(
|
|
59852
|
-
|
|
59942
|
+
import_path24.default.join(cwd, AGENT_CONFIG_PATH),
|
|
59853
59943
|
AGENT_CONFIG_MAX_BYTES
|
|
59854
59944
|
)
|
|
59855
59945
|
);
|
|
@@ -59953,15 +60043,15 @@ async function prepareCardBindingContext(cwd, draftId, resourceIds, env = proces
|
|
|
59953
60043
|
}
|
|
59954
60044
|
async function assertBindingContextDirectory(cwd, directory) {
|
|
59955
60045
|
try {
|
|
59956
|
-
const canonicalWorkspace = await (0,
|
|
59957
|
-
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))) {
|
|
59958
60048
|
throw new LinkqueCliError(
|
|
59959
60049
|
"CARD_DRAFT_INVALID",
|
|
59960
60050
|
"\u7ED1\u5B9A\u4E0A\u4E0B\u6587\u4E0D\u80FD\u4F4D\u4E8E\u7B26\u53F7\u94FE\u63A5\u76EE\u5F55"
|
|
59961
60051
|
);
|
|
59962
60052
|
}
|
|
59963
|
-
const entry = await (0,
|
|
59964
|
-
|
|
60053
|
+
const entry = await (0, import_promises18.lstat)(
|
|
60054
|
+
import_path24.default.join(directory, "binding-context.json")
|
|
59965
60055
|
).catch((cause) => {
|
|
59966
60056
|
if (isNodeError(cause, "ENOENT")) return void 0;
|
|
59967
60057
|
throw cause;
|
|
@@ -59986,7 +60076,7 @@ async function finalizeCard(cwd, draftId, expectedDraftChecksum, _contextChecksu
|
|
|
59986
60076
|
assertChecksum(expectedDraftChecksum, "\u8349\u7A3F checksum");
|
|
59987
60077
|
return withWorkspaceLock(
|
|
59988
60078
|
{
|
|
59989
|
-
path:
|
|
60079
|
+
path: import_path24.default.join(cwd, FINALIZE_LOCK_PATH),
|
|
59990
60080
|
name: "card finalize",
|
|
59991
60081
|
acquireErrorCode: "CARD_FINALIZE_LOCK_TIMEOUT",
|
|
59992
60082
|
releaseErrorCode: "CARD_FINALIZE_LOCK_RELEASE_FAILED",
|
|
@@ -59997,7 +60087,7 @@ async function finalizeCard(cwd, draftId, expectedDraftChecksum, _contextChecksu
|
|
|
59997
60087
|
);
|
|
59998
60088
|
}
|
|
59999
60089
|
async function finalizeCardFromRequest(cwd, requestFile) {
|
|
60000
|
-
const value = await readRequiredJson(
|
|
60090
|
+
const value = await readRequiredJson(import_path24.default.resolve(cwd, requestFile));
|
|
60001
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(
|
|
60002
60092
|
(key) => ![
|
|
60003
60093
|
"version",
|
|
@@ -60021,7 +60111,7 @@ async function finalizeCardFromRequest(cwd, requestFile) {
|
|
|
60021
60111
|
}
|
|
60022
60112
|
async function previewCardTransformFromRequest(cwd, requestFile) {
|
|
60023
60113
|
const value = await readRequiredJsonWithLimit(
|
|
60024
|
-
|
|
60114
|
+
import_path24.default.resolve(cwd, requestFile),
|
|
60025
60115
|
TRANSFORM_PREVIEW_REQUEST_MAX_BYTES
|
|
60026
60116
|
);
|
|
60027
60117
|
if (!isCardTransformPreviewRequest(value)) {
|
|
@@ -60070,7 +60160,7 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
|
|
|
60070
60160
|
const payload = parseRollbackToken(rollbackToken);
|
|
60071
60161
|
return withWorkspaceLock(
|
|
60072
60162
|
{
|
|
60073
|
-
path:
|
|
60163
|
+
path: import_path24.default.join(cwd, FINALIZE_LOCK_PATH),
|
|
60074
60164
|
name: "card rollback",
|
|
60075
60165
|
acquireErrorCode: "CARD_FINALIZE_LOCK_TIMEOUT",
|
|
60076
60166
|
releaseErrorCode: "CARD_FINALIZE_LOCK_RELEASE_FAILED",
|
|
@@ -60078,8 +60168,8 @@ async function rollbackCardFinalize(cwd, rollbackToken) {
|
|
|
60078
60168
|
timeoutMs: FINALIZE_LOCK_TIMEOUT_MS
|
|
60079
60169
|
},
|
|
60080
60170
|
async () => {
|
|
60081
|
-
const configPath =
|
|
60082
|
-
const current = await (0,
|
|
60171
|
+
const configPath = import_path24.default.join(cwd, AGENT_CONFIG_PATH);
|
|
60172
|
+
const current = await (0, import_promises18.readFile)(configPath);
|
|
60083
60173
|
if (checksumBytes(current) !== payload.expectedConfigChecksum) {
|
|
60084
60174
|
throw new LinkqueCliError(
|
|
60085
60175
|
"CARD_FINALIZE_CONFLICT",
|
|
@@ -60106,8 +60196,8 @@ async function validateCardBindingsFromDisk(cwd, draftId, fieldId) {
|
|
|
60106
60196
|
async function validateCardBindingsForBundle(cwd, draftId, bundle, fieldId) {
|
|
60107
60197
|
const directory = draftDirectory(cwd, draftId);
|
|
60108
60198
|
const [contextValue, configValue] = await Promise.all([
|
|
60109
|
-
readOptionalJson(
|
|
60110
|
-
|
|
60199
|
+
readOptionalJson(import_path24.default.join(directory, "binding-context.json")),
|
|
60200
|
+
readAgentCards(import_path24.default.join(cwd, AGENT_CONFIG_PATH))
|
|
60111
60201
|
]);
|
|
60112
60202
|
const context = parseOptionalBindingContext(contextValue);
|
|
60113
60203
|
const draftStructureChecksum = createA2UICardDraftStructureChecksum(bundle);
|
|
@@ -60215,13 +60305,11 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60215
60305
|
}
|
|
60216
60306
|
}
|
|
60217
60307
|
const context = parseOptionalBindingContext(
|
|
60218
|
-
await readOptionalJson(
|
|
60219
|
-
);
|
|
60220
|
-
const configPath = import_path23.default.join(cwd, AGENT_CONFIG_PATH);
|
|
60221
|
-
const oldConfigBytes = await (0, import_promises16.readFile)(configPath);
|
|
60222
|
-
const config3 = parseAgentConfig(
|
|
60223
|
-
JSON.parse(oldConfigBytes.toString("utf8"))
|
|
60308
|
+
await readOptionalJson(import_path24.default.join(directory, "binding-context.json"))
|
|
60224
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));
|
|
60225
60313
|
const resources = config3.agent.resources;
|
|
60226
60314
|
const existingIndex = resources.findIndex(
|
|
60227
60315
|
(resource) => resource.resourceType === "CARD" && resource.resourceId === bundle.manifest.resourceId
|
|
@@ -60255,7 +60343,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60255
60343
|
agent: { ...config3.agent, resources: nextResources }
|
|
60256
60344
|
};
|
|
60257
60345
|
const nextConfigBytes = Buffer.from(
|
|
60258
|
-
`${JSON.stringify(nextConfig, null, 2)}
|
|
60346
|
+
`${JSON.stringify(splitAgentCards(nextConfig).config, null, 2)}
|
|
60259
60347
|
`,
|
|
60260
60348
|
"utf8"
|
|
60261
60349
|
);
|
|
@@ -60272,12 +60360,15 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60272
60360
|
manifest: { ...bundle.manifest, baseRevision: cardRevision }
|
|
60273
60361
|
};
|
|
60274
60362
|
const rebasedDraftChecksum = draftChecksum(rebasedBundle);
|
|
60275
|
-
await
|
|
60363
|
+
await writeAgentCards(
|
|
60364
|
+
configPath,
|
|
60365
|
+
nextConfig
|
|
60366
|
+
);
|
|
60276
60367
|
const savedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
60277
60368
|
try {
|
|
60278
60369
|
await Promise.all([
|
|
60279
60370
|
atomicWrite(
|
|
60280
|
-
|
|
60371
|
+
import_path24.default.join(directory, "saved.json"),
|
|
60281
60372
|
Buffer.from(
|
|
60282
60373
|
`${JSON.stringify(
|
|
60283
60374
|
{
|
|
@@ -60294,7 +60385,7 @@ async function finalizeCardWhileLocked(cwd, draftId, expectedDraftChecksum) {
|
|
|
60294
60385
|
)
|
|
60295
60386
|
),
|
|
60296
60387
|
atomicWrite(
|
|
60297
|
-
|
|
60388
|
+
import_path24.default.join(directory, "state.json"),
|
|
60298
60389
|
Buffer.from(
|
|
60299
60390
|
`${JSON.stringify(
|
|
60300
60391
|
{ version: 1, status: "ready", updatedAt: savedAt },
|
|
@@ -60339,7 +60430,7 @@ async function inspectDraft(cwd, directory) {
|
|
|
60339
60430
|
);
|
|
60340
60431
|
}
|
|
60341
60432
|
const root = draftDirectory(cwd, draftId);
|
|
60342
|
-
const stateValue = await readOptionalJson(
|
|
60433
|
+
const stateValue = await readOptionalJson(import_path24.default.join(root, "state.json"));
|
|
60343
60434
|
if (stateValue === void 0) {
|
|
60344
60435
|
return invalidDraft(
|
|
60345
60436
|
draftId,
|
|
@@ -60370,7 +60461,7 @@ async function inspectDraft(cwd, directory) {
|
|
|
60370
60461
|
try {
|
|
60371
60462
|
const bundle = await readBundle(root, draftId);
|
|
60372
60463
|
const saved = parseSavedMarker(
|
|
60373
|
-
await readOptionalJson(
|
|
60464
|
+
await readOptionalJson(import_path24.default.join(root, "saved.json"))
|
|
60374
60465
|
);
|
|
60375
60466
|
return {
|
|
60376
60467
|
checksum: draftChecksum(bundle),
|
|
@@ -60391,9 +60482,9 @@ async function inspectDraft(cwd, directory) {
|
|
|
60391
60482
|
}
|
|
60392
60483
|
async function readBundle(directory, draftId) {
|
|
60393
60484
|
const [manifest, card, fixture] = await Promise.all([
|
|
60394
|
-
readRequiredJson(
|
|
60395
|
-
readRequiredJson(
|
|
60396
|
-
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"))
|
|
60397
60488
|
]);
|
|
60398
60489
|
const parsed = parseA2UICardDraftBundle({ manifest, card, fixture });
|
|
60399
60490
|
if (!parsed.success || parsed.data.manifest.draftId !== draftId) {
|
|
@@ -60405,10 +60496,10 @@ async function readBundle(directory, draftId) {
|
|
|
60405
60496
|
return parsed.data;
|
|
60406
60497
|
}
|
|
60407
60498
|
async function listDraftDirectories(cwd) {
|
|
60408
|
-
const root =
|
|
60499
|
+
const root = import_path24.default.join(cwd, DRAFT_ROOT);
|
|
60409
60500
|
let entries;
|
|
60410
60501
|
try {
|
|
60411
|
-
entries = await (0,
|
|
60502
|
+
entries = await (0, import_promises18.readdir)(root, { withFileTypes: true });
|
|
60412
60503
|
} catch (cause) {
|
|
60413
60504
|
if (isNodeError(cause, "ENOENT")) return [];
|
|
60414
60505
|
throw new LinkqueCliError(
|
|
@@ -60420,7 +60511,7 @@ async function listDraftDirectories(cwd) {
|
|
|
60420
60511
|
const directories = await Promise.all(
|
|
60421
60512
|
entries.filter((entry) => entry.isDirectory()).map(async (entry) => ({
|
|
60422
60513
|
draftId: entry.name,
|
|
60423
|
-
modifiedAt: await readModifiedAt(
|
|
60514
|
+
modifiedAt: await readModifiedAt(import_path24.default.join(root, entry.name))
|
|
60424
60515
|
}))
|
|
60425
60516
|
);
|
|
60426
60517
|
if (directories.length > DRAFT_LIST_LIMIT) {
|
|
@@ -60447,11 +60538,11 @@ function draftIssue(code, message, recoverable, severity) {
|
|
|
60447
60538
|
}
|
|
60448
60539
|
async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
|
|
60449
60540
|
try {
|
|
60450
|
-
const content = await (0,
|
|
60541
|
+
const content = await (0, import_promises18.readFile)(file, "utf8");
|
|
60451
60542
|
if (Buffer.byteLength(content, "utf8") > DRAFT_FILE_MAX_BYTES) {
|
|
60452
60543
|
throw new LinkqueCliError(
|
|
60453
60544
|
"CARD_DRAFT_INVALID",
|
|
60454
|
-
`${
|
|
60545
|
+
`${import_path24.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
|
|
60455
60546
|
);
|
|
60456
60547
|
}
|
|
60457
60548
|
return JSON.parse(content);
|
|
@@ -60460,31 +60551,31 @@ async function readRequiredJson(file, missingCode = "CARD_DRAFT_INVALID") {
|
|
|
60460
60551
|
if (isNodeError(cause, "ENOENT")) {
|
|
60461
60552
|
throw new LinkqueCliError(
|
|
60462
60553
|
missingCode,
|
|
60463
|
-
`\u8349\u7A3F\u6587\u4EF6\u7F3A\u5931: ${
|
|
60554
|
+
`\u8349\u7A3F\u6587\u4EF6\u7F3A\u5931: ${import_path24.default.basename(file)}`,
|
|
60464
60555
|
{ cause }
|
|
60465
60556
|
);
|
|
60466
60557
|
}
|
|
60467
60558
|
if (cause instanceof SyntaxError) {
|
|
60468
60559
|
throw new LinkqueCliError(
|
|
60469
60560
|
"CARD_DRAFT_INVALID",
|
|
60470
|
-
`\u8349\u7A3F\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${
|
|
60561
|
+
`\u8349\u7A3F\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path24.default.basename(file)}`,
|
|
60471
60562
|
{ cause }
|
|
60472
60563
|
);
|
|
60473
60564
|
}
|
|
60474
60565
|
throw new LinkqueCliError(
|
|
60475
60566
|
"CARD_DRAFT_READ_FAILED",
|
|
60476
|
-
`\u8349\u7A3F\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${
|
|
60567
|
+
`\u8349\u7A3F\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path24.default.basename(file)}`,
|
|
60477
60568
|
{ cause: cause instanceof Error ? cause : void 0 }
|
|
60478
60569
|
);
|
|
60479
60570
|
}
|
|
60480
60571
|
}
|
|
60481
60572
|
async function readRequiredJsonWithLimit(file, maxBytes) {
|
|
60482
60573
|
try {
|
|
60483
|
-
const content = await (0,
|
|
60574
|
+
const content = await (0, import_promises18.readFile)(file, "utf8");
|
|
60484
60575
|
if (Buffer.byteLength(content, "utf8") > maxBytes) {
|
|
60485
60576
|
throw new LinkqueCliError(
|
|
60486
60577
|
"CARD_DRAFT_INVALID",
|
|
60487
|
-
`${
|
|
60578
|
+
`${import_path24.default.basename(file)} \u8D85\u8FC7\u5927\u5C0F\u9650\u5236`
|
|
60488
60579
|
);
|
|
60489
60580
|
}
|
|
60490
60581
|
return JSON.parse(content);
|
|
@@ -60493,20 +60584,20 @@ async function readRequiredJsonWithLimit(file, maxBytes) {
|
|
|
60493
60584
|
if (isNodeError(cause, "ENOENT")) {
|
|
60494
60585
|
throw new LinkqueCliError(
|
|
60495
60586
|
"CARD_DRAFT_NOT_FOUND",
|
|
60496
|
-
`\u8BF7\u6C42\u6587\u4EF6\u7F3A\u5931: ${
|
|
60587
|
+
`\u8BF7\u6C42\u6587\u4EF6\u7F3A\u5931: ${import_path24.default.basename(file)}`,
|
|
60497
60588
|
{ cause }
|
|
60498
60589
|
);
|
|
60499
60590
|
}
|
|
60500
60591
|
if (cause instanceof SyntaxError) {
|
|
60501
60592
|
throw new LinkqueCliError(
|
|
60502
60593
|
"CARD_DRAFT_INVALID",
|
|
60503
|
-
`\u8BF7\u6C42\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${
|
|
60594
|
+
`\u8BF7\u6C42\u6587\u4EF6\u4E0D\u662F\u6709\u6548 JSON: ${import_path24.default.basename(file)}`,
|
|
60504
60595
|
{ cause }
|
|
60505
60596
|
);
|
|
60506
60597
|
}
|
|
60507
60598
|
throw new LinkqueCliError(
|
|
60508
60599
|
"CARD_DRAFT_READ_FAILED",
|
|
60509
|
-
`\u8BF7\u6C42\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${
|
|
60600
|
+
`\u8BF7\u6C42\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25: ${import_path24.default.basename(file)}`,
|
|
60510
60601
|
{ cause: cause instanceof Error ? cause : void 0 }
|
|
60511
60602
|
);
|
|
60512
60603
|
}
|
|
@@ -60530,7 +60621,7 @@ async function readOptionalJson(file) {
|
|
|
60530
60621
|
}
|
|
60531
60622
|
async function readRuntimeSupportedSchemaVersions(cwd) {
|
|
60532
60623
|
const value = await readOptionalJson(
|
|
60533
|
-
|
|
60624
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60534
60625
|
).catch(() => void 0);
|
|
60535
60626
|
if (!isJsonObject(value) || value.schemaVersion !== 1) {
|
|
60536
60627
|
return [...LEGACY_RUNTIME_CARD_SCHEMA_VERSIONS];
|
|
@@ -60549,19 +60640,19 @@ async function readRuntimeSupportedSchemaVersions(cwd) {
|
|
|
60549
60640
|
}
|
|
60550
60641
|
async function readRuntimeSupportsFunctionActions(cwd) {
|
|
60551
60642
|
const value = await readOptionalJson(
|
|
60552
|
-
|
|
60643
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60553
60644
|
).catch(() => void 0);
|
|
60554
60645
|
return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.frontendFunctionActions === true;
|
|
60555
60646
|
}
|
|
60556
60647
|
async function readRuntimeSupportsDataPipeline(cwd) {
|
|
60557
60648
|
const value = await readOptionalJson(
|
|
60558
|
-
|
|
60649
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60559
60650
|
).catch(() => void 0);
|
|
60560
60651
|
return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.serverDataPipeline === true;
|
|
60561
60652
|
}
|
|
60562
60653
|
async function readRuntimeSupportsModelFilledPipelineArguments(cwd) {
|
|
60563
60654
|
const value = await readOptionalJson(
|
|
60564
|
-
|
|
60655
|
+
import_path24.default.join(cwd, RUNTIME_CAPABILITIES_PATH)
|
|
60565
60656
|
).catch(() => void 0);
|
|
60566
60657
|
return isJsonObject(value) && value.schemaVersion === 1 && isJsonObject(value.a2uiCard) && value.a2uiCard.serverDataPipeline === true && value.a2uiCard.modelFilledPipelineArguments === true;
|
|
60567
60658
|
}
|
|
@@ -60579,7 +60670,7 @@ async function readOptionalJsonObject(file) {
|
|
|
60579
60670
|
}
|
|
60580
60671
|
async function readModifiedAt(file) {
|
|
60581
60672
|
try {
|
|
60582
|
-
return (await (0,
|
|
60673
|
+
return (await (0, import_promises18.stat)(file)).mtime.toISOString();
|
|
60583
60674
|
} catch {
|
|
60584
60675
|
return "";
|
|
60585
60676
|
}
|
|
@@ -60619,7 +60710,7 @@ function assertDraftId(draftId) {
|
|
|
60619
60710
|
}
|
|
60620
60711
|
}
|
|
60621
60712
|
function draftDirectory(cwd, draftId) {
|
|
60622
|
-
return
|
|
60713
|
+
return import_path24.default.join(cwd, DRAFT_ROOT, draftId);
|
|
60623
60714
|
}
|
|
60624
60715
|
function assertChecksum(value, label) {
|
|
60625
60716
|
if (!SHA256_PATTERN.test(value)) {
|
|
@@ -60700,13 +60791,13 @@ async function atomicWrite(file, content) {
|
|
|
60700
60791
|
const temporary = `${file}.${process.pid}.${(0, import_crypto9.randomUUID)()}.tmp`;
|
|
60701
60792
|
let handle;
|
|
60702
60793
|
try {
|
|
60703
|
-
handle = await (0,
|
|
60794
|
+
handle = await (0, import_promises18.open)(temporary, "wx", 384);
|
|
60704
60795
|
await handle.writeFile(content);
|
|
60705
60796
|
await handle.sync();
|
|
60706
60797
|
await handle.close();
|
|
60707
60798
|
handle = void 0;
|
|
60708
|
-
await (0,
|
|
60709
|
-
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");
|
|
60710
60801
|
try {
|
|
60711
60802
|
await directoryHandle.sync();
|
|
60712
60803
|
} finally {
|
|
@@ -60714,10 +60805,10 @@ async function atomicWrite(file, content) {
|
|
|
60714
60805
|
}
|
|
60715
60806
|
} catch (cause) {
|
|
60716
60807
|
await handle?.close().catch(() => void 0);
|
|
60717
|
-
await (0,
|
|
60808
|
+
await (0, import_promises18.unlink)(temporary).catch(() => void 0);
|
|
60718
60809
|
throw new LinkqueCliError(
|
|
60719
60810
|
"CARD_FINALIZE_WRITE_FAILED",
|
|
60720
|
-
`\u539F\u5B50\u5199\u5165\u5931\u8D25: ${
|
|
60811
|
+
`\u539F\u5B50\u5199\u5165\u5931\u8D25: ${import_path24.default.basename(file)}`,
|
|
60721
60812
|
{ cause: cause instanceof Error ? cause : void 0 }
|
|
60722
60813
|
);
|
|
60723
60814
|
}
|
|
@@ -60743,15 +60834,15 @@ function parseRollbackToken(token) {
|
|
|
60743
60834
|
|
|
60744
60835
|
// src/commands/dev.ts
|
|
60745
60836
|
var import_child_process4 = require("child_process");
|
|
60746
|
-
var
|
|
60837
|
+
var import_promises20 = require("fs/promises");
|
|
60747
60838
|
var import_net2 = require("net");
|
|
60748
|
-
var
|
|
60839
|
+
var import_path26 = __toESM(require("path"));
|
|
60749
60840
|
|
|
60750
60841
|
// src/commands/inspector.ts
|
|
60751
60842
|
var import_module = require("module");
|
|
60752
|
-
var
|
|
60843
|
+
var import_promises19 = require("fs/promises");
|
|
60753
60844
|
var import_os3 = require("os");
|
|
60754
|
-
var
|
|
60845
|
+
var import_path25 = __toESM(require("path"));
|
|
60755
60846
|
var import_url = require("url");
|
|
60756
60847
|
var INSPECTOR_PACKAGES = [
|
|
60757
60848
|
"@alipay/agent-inspector-workspace",
|
|
@@ -60774,7 +60865,7 @@ var importInspectorModule = async (resolvedPath) => {
|
|
|
60774
60865
|
};
|
|
60775
60866
|
var loadInspectorWorkspaceEngine = async (cwd) => {
|
|
60776
60867
|
try {
|
|
60777
|
-
const workspaceRequire = (0, import_module.createRequire)(
|
|
60868
|
+
const workspaceRequire = (0, import_module.createRequire)(import_path25.default.join(cwd, "package.json"));
|
|
60778
60869
|
const resolved = /* @__PURE__ */ new Map();
|
|
60779
60870
|
for (const packageName of INSPECTOR_PACKAGES) {
|
|
60780
60871
|
resolved.set(packageName, workspaceRequire.resolve(packageName));
|
|
@@ -60791,16 +60882,16 @@ var loadInspectorWorkspaceEngine = async (cwd) => {
|
|
|
60791
60882
|
);
|
|
60792
60883
|
}
|
|
60793
60884
|
};
|
|
60794
|
-
var managedRequestDirectory = () =>
|
|
60885
|
+
var managedRequestDirectory = () => import_path25.default.join((0, import_os3.homedir)(), ".linkque/inspector-requests");
|
|
60795
60886
|
var assertManagedRequestFile = async (requestFile) => {
|
|
60796
|
-
if (!
|
|
60887
|
+
if (!import_path25.default.isAbsolute(requestFile) || !REQUEST_FILE_PATTERN.test(import_path25.default.basename(requestFile)) || import_path25.default.dirname(requestFile) !== managedRequestDirectory()) {
|
|
60797
60888
|
throw new LinkqueCliError(
|
|
60798
60889
|
"INSPECTOR_PATH_FORBIDDEN",
|
|
60799
60890
|
"Inspector \u8BF7\u6C42\u6587\u4EF6\u4E0D\u5728\u53D7\u7BA1\u76EE\u5F55\u5185"
|
|
60800
60891
|
);
|
|
60801
60892
|
}
|
|
60802
60893
|
try {
|
|
60803
|
-
const fileStat = await (0,
|
|
60894
|
+
const fileStat = await (0, import_promises19.lstat)(requestFile);
|
|
60804
60895
|
if (fileStat.isSymbolicLink() || !fileStat.isFile()) {
|
|
60805
60896
|
throw new LinkqueCliError(
|
|
60806
60897
|
"INSPECTOR_PATH_FORBIDDEN",
|
|
@@ -60814,11 +60905,11 @@ var assertManagedRequestFile = async (requestFile) => {
|
|
|
60814
60905
|
);
|
|
60815
60906
|
}
|
|
60816
60907
|
const [directoryRealPath, fileRealPath] = await Promise.all([
|
|
60817
|
-
(0,
|
|
60818
|
-
(0,
|
|
60908
|
+
(0, import_promises19.realpath)(managedRequestDirectory()),
|
|
60909
|
+
(0, import_promises19.realpath)(requestFile)
|
|
60819
60910
|
]);
|
|
60820
|
-
const relative =
|
|
60821
|
-
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)) {
|
|
60822
60913
|
throw new LinkqueCliError(
|
|
60823
60914
|
"INSPECTOR_PATH_FORBIDDEN",
|
|
60824
60915
|
"Inspector \u8BF7\u6C42\u6587\u4EF6\u89E3\u6790\u540E\u8D8A\u51FA\u53D7\u7BA1\u76EE\u5F55"
|
|
@@ -60843,7 +60934,7 @@ var assertManagedRequestFile = async (requestFile) => {
|
|
|
60843
60934
|
var readInspectorRequest = async (requestFile) => {
|
|
60844
60935
|
await assertManagedRequestFile(requestFile);
|
|
60845
60936
|
try {
|
|
60846
|
-
const content = await (0,
|
|
60937
|
+
const content = await (0, import_promises19.readFile)(requestFile, "utf8");
|
|
60847
60938
|
if (Buffer.byteLength(content, "utf8") > REQUEST_MAX_BYTES) {
|
|
60848
60939
|
throw new LinkqueCliError(
|
|
60849
60940
|
"INSPECTOR_REQUEST_INVALID",
|
|
@@ -60917,7 +61008,7 @@ var normalizeRevision = (value) => {
|
|
|
60917
61008
|
};
|
|
60918
61009
|
var withInspectorLock = (cwd, operation) => withWorkspaceLock(
|
|
60919
61010
|
{
|
|
60920
|
-
path:
|
|
61011
|
+
path: import_path25.default.join(cwd, INSPECTOR_LOCK),
|
|
60921
61012
|
name: "inspector",
|
|
60922
61013
|
acquireErrorCode: "INSPECTOR_LOCK_TIMEOUT",
|
|
60923
61014
|
releaseErrorCode: "INSPECTOR_INTERNAL_ERROR",
|
|
@@ -61046,7 +61137,7 @@ var isPortListening2 = (port) => new Promise((resolve2) => {
|
|
|
61046
61137
|
});
|
|
61047
61138
|
async function removeMatchingState2(statePath, pid) {
|
|
61048
61139
|
const owned = await readOwnedDevState(statePath);
|
|
61049
|
-
if (owned?.pid === pid) await (0,
|
|
61140
|
+
if (owned?.pid === pid) await (0, import_promises20.rm)(statePath, { force: true });
|
|
61050
61141
|
}
|
|
61051
61142
|
async function terminateOwner2(statePath, pid) {
|
|
61052
61143
|
if (!isProcessAlive(pid)) {
|
|
@@ -61079,14 +61170,14 @@ async function terminateOwner2(statePath, pid) {
|
|
|
61079
61170
|
await removeMatchingState2(statePath, pid);
|
|
61080
61171
|
}
|
|
61081
61172
|
var inspectRecordedDevServer = async (cwd) => {
|
|
61082
|
-
const statePath =
|
|
61173
|
+
const statePath = import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE);
|
|
61083
61174
|
const content = await readUtf8IfExists(statePath);
|
|
61084
61175
|
if (content === null) {
|
|
61085
61176
|
return { state: null, status: stopped2("STOPPED") };
|
|
61086
61177
|
}
|
|
61087
61178
|
const owned = parseOwnedDevState(content);
|
|
61088
61179
|
if (owned === null) {
|
|
61089
|
-
await (0,
|
|
61180
|
+
await (0, import_promises20.rm)(statePath, { force: true });
|
|
61090
61181
|
return { state: null, status: stopped2("STALE") };
|
|
61091
61182
|
}
|
|
61092
61183
|
const state = owned;
|
|
@@ -61152,17 +61243,17 @@ var inspectReadyWorkspace = async (cwd) => {
|
|
|
61152
61243
|
}
|
|
61153
61244
|
};
|
|
61154
61245
|
var spawnDevOwner = (cwd, port, proxyPort, cardPreviewPort, basePath, inspectorEnabled) => {
|
|
61155
|
-
const workerPath =
|
|
61246
|
+
const workerPath = import_path26.default.resolve(__dirname, "dev/worker.js");
|
|
61156
61247
|
const input = Buffer.from(
|
|
61157
61248
|
JSON.stringify({
|
|
61158
61249
|
basePath,
|
|
61159
61250
|
cardPreviewPort,
|
|
61160
61251
|
cwd,
|
|
61161
61252
|
inspectorEnabled,
|
|
61162
|
-
logPath:
|
|
61253
|
+
logPath: import_path26.default.join(cwd, DEV_LOG),
|
|
61163
61254
|
port,
|
|
61164
61255
|
proxyPort,
|
|
61165
|
-
statePath:
|
|
61256
|
+
statePath: import_path26.default.join(cwd, RUNTIME_DIR3, DEV_STATE)
|
|
61166
61257
|
})
|
|
61167
61258
|
).toString("base64url");
|
|
61168
61259
|
const owner = (0, import_child_process4.spawn)(process.execPath, [workerPath, input], {
|
|
@@ -61277,9 +61368,9 @@ var startDevServer = async (cwd, port, proxyPort, cardPreviewPort, basePath, ins
|
|
|
61277
61368
|
"dev, proxy and card preview ports must be different"
|
|
61278
61369
|
);
|
|
61279
61370
|
}
|
|
61280
|
-
const runtimeDir =
|
|
61281
|
-
const lockPath =
|
|
61282
|
-
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);
|
|
61283
61374
|
return withWorkspaceLock(
|
|
61284
61375
|
{
|
|
61285
61376
|
path: lockPath,
|
|
@@ -61301,8 +61392,8 @@ var startDevServer = async (cwd, port, proxyPort, cardPreviewPort, basePath, ins
|
|
|
61301
61392
|
);
|
|
61302
61393
|
};
|
|
61303
61394
|
var stopDevServer = async (cwd) => {
|
|
61304
|
-
const lockPath =
|
|
61305
|
-
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);
|
|
61306
61397
|
return withWorkspaceLock(
|
|
61307
61398
|
{
|
|
61308
61399
|
path: lockPath,
|
|
@@ -61315,7 +61406,7 @@ var stopDevServer = async (cwd) => {
|
|
|
61315
61406
|
async () => {
|
|
61316
61407
|
const owned = await readOwnedDevState(statePath);
|
|
61317
61408
|
if (owned !== null) await terminateOwner2(statePath, owned.pid);
|
|
61318
|
-
await (0,
|
|
61409
|
+
await (0, import_promises20.rm)(statePath, { force: true });
|
|
61319
61410
|
return { stopped: true };
|
|
61320
61411
|
}
|
|
61321
61412
|
);
|
|
@@ -61323,8 +61414,8 @@ var stopDevServer = async (cwd) => {
|
|
|
61323
61414
|
|
|
61324
61415
|
// src/commands/platformSdk/apply.ts
|
|
61325
61416
|
var import_crypto10 = require("crypto");
|
|
61326
|
-
var
|
|
61327
|
-
var
|
|
61417
|
+
var import_promises21 = require("fs/promises");
|
|
61418
|
+
var import_path27 = __toESM(require("path"));
|
|
61328
61419
|
var PLATFORM_SDK_DIR = ".platform-sdk";
|
|
61329
61420
|
var PLATFORM_SDK_VERSION_FILE = `${PLATFORM_SDK_DIR}/version.json`;
|
|
61330
61421
|
var PLATFORM_SDK_STATE = ".linkque/runtime/platform-sdk-state.json";
|
|
@@ -61336,10 +61427,10 @@ var failManifest = (message) => {
|
|
|
61336
61427
|
var isRecord2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
61337
61428
|
var isSha256 = (value) => typeof value === "string" && /^sha256:[a-f0-9]{64}$/u.test(value);
|
|
61338
61429
|
var isSafePlatformPath = (value) => {
|
|
61339
|
-
if (value.includes("\\") || value.includes("\0") ||
|
|
61430
|
+
if (value.includes("\\") || value.includes("\0") || import_path27.default.posix.isAbsolute(value)) {
|
|
61340
61431
|
return false;
|
|
61341
61432
|
}
|
|
61342
|
-
const normalized =
|
|
61433
|
+
const normalized = import_path27.default.posix.normalize(value);
|
|
61343
61434
|
return normalized === value && normalized.startsWith(`${PLATFORM_SDK_DIR}/`) && !normalized.split("/").includes("..");
|
|
61344
61435
|
};
|
|
61345
61436
|
var parseManifest = (content) => {
|
|
@@ -61382,14 +61473,14 @@ var extractArchive = async (cwd, archive, manifest) => {
|
|
|
61382
61473
|
`platform SDK archive contains an unsafe path: ${entry.filename}`
|
|
61383
61474
|
);
|
|
61384
61475
|
}
|
|
61385
|
-
const destination =
|
|
61476
|
+
const destination = import_path27.default.join(cwd, ...entryPath.split("/"));
|
|
61386
61477
|
if (entry.directory) {
|
|
61387
|
-
await (0,
|
|
61478
|
+
await (0, import_promises21.mkdir)(destination, { recursive: true });
|
|
61388
61479
|
continue;
|
|
61389
61480
|
}
|
|
61390
61481
|
const bytes = await entry.getData(new Uint8ArrayWriter());
|
|
61391
|
-
await (0,
|
|
61392
|
-
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" });
|
|
61393
61484
|
extractedFiles.set(entryPath, sha256(bytes));
|
|
61394
61485
|
}
|
|
61395
61486
|
} finally {
|
|
@@ -61408,7 +61499,7 @@ var validateVersionMarker = async (cwd, manifest) => {
|
|
|
61408
61499
|
let value;
|
|
61409
61500
|
try {
|
|
61410
61501
|
value = JSON.parse(
|
|
61411
|
-
await (0,
|
|
61502
|
+
await (0, import_promises21.readFile)(import_path27.default.join(cwd, PLATFORM_SDK_VERSION_FILE), "utf8")
|
|
61412
61503
|
);
|
|
61413
61504
|
} catch (error2) {
|
|
61414
61505
|
throw new LinkqueCliError(
|
|
@@ -61425,10 +61516,10 @@ var validateVersionMarker = async (cwd, manifest) => {
|
|
|
61425
61516
|
}
|
|
61426
61517
|
};
|
|
61427
61518
|
var rewritePackageJson = async (cwd, manifest) => {
|
|
61428
|
-
const packageJsonPath =
|
|
61519
|
+
const packageJsonPath = import_path27.default.join(cwd, "package.json");
|
|
61429
61520
|
let packageJson;
|
|
61430
61521
|
try {
|
|
61431
|
-
packageJson = JSON.parse(await (0,
|
|
61522
|
+
packageJson = JSON.parse(await (0, import_promises21.readFile)(packageJsonPath, "utf8"));
|
|
61432
61523
|
} catch (error2) {
|
|
61433
61524
|
throw new LinkqueCliError(
|
|
61434
61525
|
"PLATFORM_SDK_APPLY_FAILED",
|
|
@@ -61468,8 +61559,8 @@ var rewritePackageJson = async (cwd, manifest) => {
|
|
|
61468
61559
|
};
|
|
61469
61560
|
var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
61470
61561
|
const [manifestContent, archive] = await Promise.all([
|
|
61471
|
-
(0,
|
|
61472
|
-
(0,
|
|
61562
|
+
(0, import_promises21.readFile)(import_path27.default.resolve(cwd, manifestPath), "utf8"),
|
|
61563
|
+
(0, import_promises21.readFile)(import_path27.default.resolve(cwd, archivePath))
|
|
61473
61564
|
]).catch((error2) => {
|
|
61474
61565
|
throw new LinkqueCliError(
|
|
61475
61566
|
"PLATFORM_SDK_APPLY_FAILED",
|
|
@@ -61484,7 +61575,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
|
61484
61575
|
"platform SDK archive identity does not match the manifest"
|
|
61485
61576
|
);
|
|
61486
61577
|
}
|
|
61487
|
-
await (0,
|
|
61578
|
+
await (0, import_promises21.rm)(import_path27.default.join(cwd, PLATFORM_SDK_DIR), { force: true, recursive: true });
|
|
61488
61579
|
try {
|
|
61489
61580
|
await extractArchive(cwd, archive, manifest);
|
|
61490
61581
|
await validateVersionMarker(cwd, manifest);
|
|
@@ -61496,12 +61587,12 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
|
61496
61587
|
let templateVersion;
|
|
61497
61588
|
try {
|
|
61498
61589
|
const artifact = JSON.parse(
|
|
61499
|
-
await (0,
|
|
61590
|
+
await (0, import_promises21.readFile)(import_path27.default.join(cwd, "template-artifact.json"), "utf8")
|
|
61500
61591
|
);
|
|
61501
61592
|
templateVersion = typeof artifact.templateVersion === "string" ? artifact.templateVersion : void 0;
|
|
61502
61593
|
} catch {
|
|
61503
61594
|
}
|
|
61504
|
-
await writeJsonAtomically(
|
|
61595
|
+
await writeJsonAtomically(import_path27.default.join(cwd, PLATFORM_SDK_STATE), {
|
|
61505
61596
|
schemaVersion: 1,
|
|
61506
61597
|
bundleVersion: manifest.bundleVersion,
|
|
61507
61598
|
platformSdkRef: manifest.archive.ossKey,
|
|
@@ -61525,7 +61616,7 @@ var applyWhileLocked = async (cwd, manifestPath, archivePath, options) => {
|
|
|
61525
61616
|
};
|
|
61526
61617
|
var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => withWorkspaceLock(
|
|
61527
61618
|
{
|
|
61528
|
-
path:
|
|
61619
|
+
path: import_path27.default.join(cwd, PLATFORM_SDK_LOCK),
|
|
61529
61620
|
name: "platform SDK",
|
|
61530
61621
|
acquireErrorCode: "PLATFORM_SDK_LOCK_TIMEOUT",
|
|
61531
61622
|
releaseErrorCode: "PLATFORM_SDK_LOCK_RELEASE_FAILED",
|
|
@@ -61536,8 +61627,8 @@ var applyPlatformSdk = async (cwd, manifestPath, archivePath, options = {}) => w
|
|
|
61536
61627
|
);
|
|
61537
61628
|
|
|
61538
61629
|
// src/commands/unzip.ts
|
|
61539
|
-
var
|
|
61540
|
-
var
|
|
61630
|
+
var import_promises22 = require("fs/promises");
|
|
61631
|
+
var import_path28 = __toESM(require("path"));
|
|
61541
61632
|
var MAX_ZIP_BYTES = 70 * 1024 * 1024;
|
|
61542
61633
|
var MAX_FILE_COUNT = 5e3;
|
|
61543
61634
|
var MAX_TOTAL_BYTES = 50 * 1024 * 1024;
|
|
@@ -61563,12 +61654,12 @@ var SourceArchiveExtractor = class {
|
|
|
61563
61654
|
constructor(cwd, input, output) {
|
|
61564
61655
|
if (!input) this.invalid("unzip input path must not be empty");
|
|
61565
61656
|
if (!output) this.invalid("unzip output path must not be empty");
|
|
61566
|
-
this.inputPath =
|
|
61567
|
-
this.outputPath =
|
|
61657
|
+
this.inputPath = import_path28.default.resolve(cwd, input);
|
|
61658
|
+
this.outputPath = import_path28.default.resolve(cwd, output);
|
|
61568
61659
|
}
|
|
61569
61660
|
async extract() {
|
|
61570
61661
|
await this.assertInputs();
|
|
61571
|
-
const handle = await (0,
|
|
61662
|
+
const handle = await (0, import_promises22.open)(this.inputPath, "r").catch((error2) => {
|
|
61572
61663
|
throw new LinkqueCliError(
|
|
61573
61664
|
"UNZIP_INPUT_INVALID",
|
|
61574
61665
|
"unzip input archive could not be opened",
|
|
@@ -61604,7 +61695,7 @@ var SourceArchiveExtractor = class {
|
|
|
61604
61695
|
}
|
|
61605
61696
|
let inputStat;
|
|
61606
61697
|
try {
|
|
61607
|
-
inputStat = await (0,
|
|
61698
|
+
inputStat = await (0, import_promises22.stat)(this.inputPath);
|
|
61608
61699
|
} catch (error2) {
|
|
61609
61700
|
throw new LinkqueCliError(
|
|
61610
61701
|
"UNZIP_INPUT_INVALID",
|
|
@@ -61618,7 +61709,7 @@ var SourceArchiveExtractor = class {
|
|
|
61618
61709
|
}
|
|
61619
61710
|
let outputStat;
|
|
61620
61711
|
try {
|
|
61621
|
-
outputStat = await (0,
|
|
61712
|
+
outputStat = await (0, import_promises22.lstat)(this.outputPath);
|
|
61622
61713
|
} catch (error2) {
|
|
61623
61714
|
throw new LinkqueCliError(
|
|
61624
61715
|
"UNZIP_INPUT_INVALID",
|
|
@@ -61629,7 +61720,7 @@ var SourceArchiveExtractor = class {
|
|
|
61629
61720
|
if (outputStat.isSymbolicLink() || !outputStat.isDirectory()) {
|
|
61630
61721
|
this.invalid("unzip output must be an existing directory");
|
|
61631
61722
|
}
|
|
61632
|
-
if ((await (0,
|
|
61723
|
+
if ((await (0, import_promises22.readdir)(this.outputPath)).length > 0) {
|
|
61633
61724
|
this.invalid("unzip output directory must be empty");
|
|
61634
61725
|
}
|
|
61635
61726
|
}
|
|
@@ -61660,16 +61751,16 @@ var SourceArchiveExtractor = class {
|
|
|
61660
61751
|
}
|
|
61661
61752
|
normalizeEntryPath(filename) {
|
|
61662
61753
|
const normalized = filename.replace(/\/$/u, "");
|
|
61663
|
-
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 === "..")) {
|
|
61664
61755
|
this.invalid(`unzip archive contains an unsafe path: ${filename}`);
|
|
61665
61756
|
}
|
|
61666
61757
|
return normalized;
|
|
61667
61758
|
}
|
|
61668
61759
|
async extractFile(file) {
|
|
61669
61760
|
const destination = this.resolveDestination(file.filename);
|
|
61670
|
-
await (0,
|
|
61761
|
+
await (0, import_promises22.mkdir)(import_path28.default.dirname(destination), { recursive: true });
|
|
61671
61762
|
this.sourceChecksum.appendFileHeader(file.filename, file.size);
|
|
61672
|
-
const handle = await (0,
|
|
61763
|
+
const handle = await (0, import_promises22.open)(destination, "wx");
|
|
61673
61764
|
let written = 0;
|
|
61674
61765
|
try {
|
|
61675
61766
|
await file.entry.getData(
|
|
@@ -61701,9 +61792,9 @@ var SourceArchiveExtractor = class {
|
|
|
61701
61792
|
}
|
|
61702
61793
|
}
|
|
61703
61794
|
resolveDestination(filename) {
|
|
61704
|
-
const destination =
|
|
61705
|
-
const relative =
|
|
61706
|
-
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)) {
|
|
61707
61798
|
this.invalid(`unzip archive escapes output directory: ${filename}`);
|
|
61708
61799
|
}
|
|
61709
61800
|
return destination;
|
|
@@ -62036,7 +62127,7 @@ function decodeOtlpRecords(line, source) {
|
|
|
62036
62127
|
}
|
|
62037
62128
|
|
|
62038
62129
|
// ../linkque-agent-runtime-trace/dist/esm/summarize.js
|
|
62039
|
-
var
|
|
62130
|
+
var import_node_crypto4 = require("node:crypto");
|
|
62040
62131
|
var dedupKey = (advanceId, suffix) => `${advanceId ?? ""}
|
|
62041
62132
|
${suffix ?? ""}`;
|
|
62042
62133
|
var extractQueryInput = (facts) => {
|
|
@@ -62210,7 +62301,7 @@ ${body.section}`;
|
|
|
62210
62301
|
section: body.section,
|
|
62211
62302
|
contentRef,
|
|
62212
62303
|
...body.reason === "content_limit" ? { reason: "content_limit" } : {},
|
|
62213
|
-
valueDigest: (0,
|
|
62304
|
+
valueDigest: (0, import_node_crypto4.createHash)("sha256").update(JSON.stringify(body.value) ?? "").digest("hex"),
|
|
62214
62305
|
...body.value && typeof body.value === "object" && (body.section.endsWith(".output") || body.section === "knowledge.input") ? {
|
|
62215
62306
|
result: Object.fromEntries(Object.entries(body.value).filter(([key, value]) => [
|
|
62216
62307
|
"status",
|
|
@@ -62406,7 +62497,7 @@ function readTraceContent(input) {
|
|
|
62406
62497
|
const pageBytes = Math.min(maxBytes, remaining);
|
|
62407
62498
|
const isFullContent = offset === 0 && totalBytes <= maxBytes;
|
|
62408
62499
|
const titles = body.fieldTitles;
|
|
62409
|
-
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;
|
|
62410
62501
|
const evidence = {
|
|
62411
62502
|
...body.originalBytes !== void 0 ? { originalBytes: body.originalBytes } : {},
|
|
62412
62503
|
...body.storedBytes !== void 0 ? { storedBytes: body.storedBytes } : {},
|
|
@@ -62445,8 +62536,8 @@ function readTraceContent(input) {
|
|
|
62445
62536
|
|
|
62446
62537
|
// src/utils/otlpScanner.ts
|
|
62447
62538
|
var import_node_path13 = __toESM(require("node:path"));
|
|
62448
|
-
var
|
|
62449
|
-
var
|
|
62539
|
+
var import_node_crypto5 = require("node:crypto");
|
|
62540
|
+
var import_promises23 = require("node:fs/promises");
|
|
62450
62541
|
|
|
62451
62542
|
// src/commands/runs/types.ts
|
|
62452
62543
|
var OTLP_LOG_FILES = {
|
|
@@ -62502,7 +62593,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62502
62593
|
const dir = import_node_path13.default.join(cwd, LOGS_ROOT);
|
|
62503
62594
|
let files;
|
|
62504
62595
|
try {
|
|
62505
|
-
files = await (0,
|
|
62596
|
+
files = await (0, import_promises23.readdir)(dir);
|
|
62506
62597
|
} catch (error2) {
|
|
62507
62598
|
if (isNodeError(error2, "ENOENT"))
|
|
62508
62599
|
return { facts: [], warnings: ["source_unavailable"], readWindow: [] };
|
|
@@ -62525,14 +62616,14 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62525
62616
|
try {
|
|
62526
62617
|
const source = retainedFiles.get(file);
|
|
62527
62618
|
const filePath = import_node_path13.default.join(dir, file);
|
|
62528
|
-
const before = await (0,
|
|
62619
|
+
const before = await (0, import_promises23.stat)(filePath);
|
|
62529
62620
|
if (options && scannedBytes + before.size > options.maxBytes)
|
|
62530
62621
|
throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
|
|
62531
|
-
const content = await (0,
|
|
62622
|
+
const content = await (0, import_promises23.readFile)(filePath);
|
|
62532
62623
|
scannedBytes += content.length;
|
|
62533
62624
|
if (options && scannedBytes > options.maxBytes)
|
|
62534
62625
|
throw new RangeError("\u539F\u59CB\u65E5\u5FD7\u8D85\u8FC7\u5F52\u6863\u8BFB\u53D6\u4E0A\u9650");
|
|
62535
|
-
const after = await (0,
|
|
62626
|
+
const after = await (0, import_promises23.stat)(filePath);
|
|
62536
62627
|
if (before.ino !== after.ino || after.size < before.size) {
|
|
62537
62628
|
warnings.push("log_rotated_during_read");
|
|
62538
62629
|
continue;
|
|
@@ -62541,7 +62632,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62541
62632
|
let window;
|
|
62542
62633
|
if (pinned) {
|
|
62543
62634
|
window = [...remaining].find(
|
|
62544
|
-
(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
|
|
62545
62636
|
);
|
|
62546
62637
|
if (!window) continue;
|
|
62547
62638
|
remaining.delete(window);
|
|
@@ -62552,7 +62643,7 @@ async function scanRetainedLogs(cwd, pinned, options) {
|
|
|
62552
62643
|
window = {
|
|
62553
62644
|
source,
|
|
62554
62645
|
bytes: complete.length,
|
|
62555
|
-
digest: (0,
|
|
62646
|
+
digest: (0, import_node_crypto5.createHash)("sha256").update(complete).digest("hex")
|
|
62556
62647
|
};
|
|
62557
62648
|
}
|
|
62558
62649
|
readWindow.push(window);
|
|
@@ -62758,9 +62849,9 @@ var scanContent = async (input) => {
|
|
|
62758
62849
|
var import_node_path14 = __toESM(require("node:path"));
|
|
62759
62850
|
var import_node_fs9 = require("node:fs");
|
|
62760
62851
|
var import_node_stream2 = require("node:stream");
|
|
62761
|
-
var
|
|
62852
|
+
var import_promises24 = require("node:stream/promises");
|
|
62762
62853
|
var import_node_zlib2 = require("node:zlib");
|
|
62763
|
-
var
|
|
62854
|
+
var import_promises25 = require("node:fs/promises");
|
|
62764
62855
|
var TURN_ARCHIVE_MAX_BYTES = 16 * 1024 * 1024;
|
|
62765
62856
|
var TURN_SOURCE_MAX_BYTES = 64 * 1024 * 1024;
|
|
62766
62857
|
var TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES = 64 * 1024 * 1024;
|
|
@@ -62787,8 +62878,8 @@ async function exportTurn(cwd, identity) {
|
|
|
62787
62878
|
"\u76EE\u6807\u8F6E\u6B21\u65E5\u5FD7\u4E0D\u53EF\u7528"
|
|
62788
62879
|
);
|
|
62789
62880
|
const root = import_node_path14.default.join(cwd, ".linkque", "tmp");
|
|
62790
|
-
await (0,
|
|
62791
|
-
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-"));
|
|
62792
62883
|
const archivePath = import_node_path14.default.join(directory, "logs.tar.gz");
|
|
62793
62884
|
let result;
|
|
62794
62885
|
try {
|
|
@@ -62809,7 +62900,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62809
62900
|
if (payloadBytes > TURN_UNCOMPRESSED_ARCHIVE_MAX_BYTES)
|
|
62810
62901
|
throw new RangeError("\u672A\u538B\u7F29\u5F52\u6863\u5185\u5BB9\u8D85\u8FC7\u4E0A\u9650");
|
|
62811
62902
|
for (const [name, value] of Object.entries(files))
|
|
62812
|
-
await (0,
|
|
62903
|
+
await (0, import_promises25.writeFile)(import_node_path14.default.join(directory, name), value, { flag: "wx" });
|
|
62813
62904
|
let uncompressedBytes = 0;
|
|
62814
62905
|
let compressedBytes = 0;
|
|
62815
62906
|
const rawBudget = new import_node_stream2.Transform({
|
|
@@ -62830,7 +62921,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62830
62921
|
);
|
|
62831
62922
|
}
|
|
62832
62923
|
});
|
|
62833
|
-
await (0,
|
|
62924
|
+
await (0, import_promises24.pipeline)(
|
|
62834
62925
|
Qn(
|
|
62835
62926
|
{ cwd: directory, portable: true },
|
|
62836
62927
|
Object.keys(files)
|
|
@@ -62842,7 +62933,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62842
62933
|
);
|
|
62843
62934
|
result = { archivePath, compressedBytes, uncompressedBytes };
|
|
62844
62935
|
} catch (cause) {
|
|
62845
|
-
await (0,
|
|
62936
|
+
await (0, import_promises25.rm)(directory, { recursive: true, force: true }).catch(
|
|
62846
62937
|
() => void 0
|
|
62847
62938
|
);
|
|
62848
62939
|
throw new LinkqueCliError(
|
|
@@ -62852,7 +62943,7 @@ async function exportTurn(cwd, identity) {
|
|
|
62852
62943
|
);
|
|
62853
62944
|
}
|
|
62854
62945
|
for (const name of ["manifest.json", "logs.jsonl", "traces.jsonl"]) {
|
|
62855
|
-
await (0,
|
|
62946
|
+
await (0, import_promises25.rm)(import_node_path14.default.join(directory, name), { force: true }).catch(
|
|
62856
62947
|
() => void 0
|
|
62857
62948
|
);
|
|
62858
62949
|
}
|
|
@@ -63243,6 +63334,16 @@ var cardList = {
|
|
|
63243
63334
|
`,
|
|
63244
63335
|
run: (cwd) => listCardDrafts(cwd)
|
|
63245
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
|
+
};
|
|
63246
63347
|
var cardRead = {
|
|
63247
63348
|
name: "card.read",
|
|
63248
63349
|
description: "read one validated A2UI card draft bundle",
|
|
@@ -63726,6 +63827,7 @@ var COMMANDS = [
|
|
|
63726
63827
|
inspectorApply,
|
|
63727
63828
|
mcpDescribe,
|
|
63728
63829
|
cardList,
|
|
63830
|
+
cardMigrate,
|
|
63729
63831
|
cardRead,
|
|
63730
63832
|
cardPrepareBindingContext,
|
|
63731
63833
|
cardValidateBindings,
|