@mcpc-tech/cli 0.1.50 → 0.1.52
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/app.cjs +632 -289
- package/app.mjs +632 -289
- package/bin/mcpc.cjs +630 -305
- package/bin/mcpc.mjs +628 -303
- package/bin.cjs +630 -305
- package/bin.mjs +628 -303
- package/index.cjs +652 -309
- package/index.mjs +650 -307
- package/package.json +1 -1
- package/server.cjs +652 -309
- package/server.mjs +650 -307
package/server.mjs
CHANGED
|
@@ -509,7 +509,7 @@ var require_cross_spawn = __commonJS({
|
|
|
509
509
|
var cp = __require("child_process");
|
|
510
510
|
var parse2 = require_parse();
|
|
511
511
|
var enoent = require_enoent();
|
|
512
|
-
function
|
|
512
|
+
function spawn3(command, args, options) {
|
|
513
513
|
const parsed = parse2(command, args, options);
|
|
514
514
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
515
515
|
enoent.hookChildProcess(spawned, parsed);
|
|
@@ -521,8 +521,8 @@ var require_cross_spawn = __commonJS({
|
|
|
521
521
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
522
522
|
return result;
|
|
523
523
|
}
|
|
524
|
-
module.exports =
|
|
525
|
-
module.exports.spawn =
|
|
524
|
+
module.exports = spawn3;
|
|
525
|
+
module.exports.spawn = spawn3;
|
|
526
526
|
module.exports.sync = spawnSync;
|
|
527
527
|
module.exports._parse = parse2;
|
|
528
528
|
module.exports._enoent = enoent;
|
|
@@ -3033,6 +3033,7 @@ data:
|
|
|
3033
3033
|
async handleGetRequest(req) {
|
|
3034
3034
|
const acceptHeader = req.headers.get("accept");
|
|
3035
3035
|
if (!acceptHeader?.includes("text/event-stream")) {
|
|
3036
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream"));
|
|
3036
3037
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept text/event-stream");
|
|
3037
3038
|
}
|
|
3038
3039
|
const sessionError = this.validateSession(req);
|
|
@@ -3050,6 +3051,7 @@ data:
|
|
|
3050
3051
|
}
|
|
3051
3052
|
}
|
|
3052
3053
|
if (this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
3054
|
+
this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session"));
|
|
3053
3055
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Only one SSE stream is allowed per session");
|
|
3054
3056
|
}
|
|
3055
3057
|
const encoder2 = new TextEncoder();
|
|
@@ -3089,6 +3091,7 @@ data:
|
|
|
3089
3091
|
*/
|
|
3090
3092
|
async replayEvents(lastEventId) {
|
|
3091
3093
|
if (!this._eventStore) {
|
|
3094
|
+
this.onerror?.(new Error("Event store not configured"));
|
|
3092
3095
|
return this.createJsonErrorResponse(400, -32e3, "Event store not configured");
|
|
3093
3096
|
}
|
|
3094
3097
|
try {
|
|
@@ -3096,9 +3099,11 @@ data:
|
|
|
3096
3099
|
if (this._eventStore.getStreamIdForEventId) {
|
|
3097
3100
|
streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
|
|
3098
3101
|
if (!streamId) {
|
|
3102
|
+
this.onerror?.(new Error("Invalid event ID format"));
|
|
3099
3103
|
return this.createJsonErrorResponse(400, -32e3, "Invalid event ID format");
|
|
3100
3104
|
}
|
|
3101
3105
|
if (this._streamMapping.get(streamId) !== void 0) {
|
|
3106
|
+
this.onerror?.(new Error("Conflict: Stream already has an active connection"));
|
|
3102
3107
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Stream already has an active connection");
|
|
3103
3108
|
}
|
|
3104
3109
|
}
|
|
@@ -3164,7 +3169,8 @@ data:
|
|
|
3164
3169
|
`;
|
|
3165
3170
|
controller.enqueue(encoder2.encode(eventData));
|
|
3166
3171
|
return true;
|
|
3167
|
-
} catch {
|
|
3172
|
+
} catch (error) {
|
|
3173
|
+
this.onerror?.(error);
|
|
3168
3174
|
return false;
|
|
3169
3175
|
}
|
|
3170
3176
|
}
|
|
@@ -3172,6 +3178,7 @@ data:
|
|
|
3172
3178
|
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
3173
3179
|
*/
|
|
3174
3180
|
handleUnsupportedRequest() {
|
|
3181
|
+
this.onerror?.(new Error("Method not allowed."));
|
|
3175
3182
|
return new Response(JSON.stringify({
|
|
3176
3183
|
jsonrpc: "2.0",
|
|
3177
3184
|
error: {
|
|
@@ -3194,14 +3201,17 @@ data:
|
|
|
3194
3201
|
try {
|
|
3195
3202
|
const acceptHeader = req.headers.get("accept");
|
|
3196
3203
|
if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
|
|
3204
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
|
|
3197
3205
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept both application/json and text/event-stream");
|
|
3198
3206
|
}
|
|
3199
3207
|
const ct = req.headers.get("content-type");
|
|
3200
3208
|
if (!ct || !ct.includes("application/json")) {
|
|
3209
|
+
this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
|
|
3201
3210
|
return this.createJsonErrorResponse(415, -32e3, "Unsupported Media Type: Content-Type must be application/json");
|
|
3202
3211
|
}
|
|
3203
3212
|
const requestInfo = {
|
|
3204
|
-
headers: Object.fromEntries(req.headers.entries())
|
|
3213
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
3214
|
+
url: new URL(req.url)
|
|
3205
3215
|
};
|
|
3206
3216
|
let rawMessage;
|
|
3207
3217
|
if (options?.parsedBody !== void 0) {
|
|
@@ -3210,6 +3220,7 @@ data:
|
|
|
3210
3220
|
try {
|
|
3211
3221
|
rawMessage = await req.json();
|
|
3212
3222
|
} catch {
|
|
3223
|
+
this.onerror?.(new Error("Parse error: Invalid JSON"));
|
|
3213
3224
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
|
|
3214
3225
|
}
|
|
3215
3226
|
}
|
|
@@ -3221,14 +3232,17 @@ data:
|
|
|
3221
3232
|
messages = [JSONRPCMessageSchema.parse(rawMessage)];
|
|
3222
3233
|
}
|
|
3223
3234
|
} catch {
|
|
3235
|
+
this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
|
|
3224
3236
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
|
|
3225
3237
|
}
|
|
3226
3238
|
const isInitializationRequest = messages.some(isInitializeRequest);
|
|
3227
3239
|
if (isInitializationRequest) {
|
|
3228
3240
|
if (this._initialized && this.sessionId !== void 0) {
|
|
3241
|
+
this.onerror?.(new Error("Invalid Request: Server already initialized"));
|
|
3229
3242
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
|
|
3230
3243
|
}
|
|
3231
3244
|
if (messages.length > 1) {
|
|
3245
|
+
this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed"));
|
|
3232
3246
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
|
|
3233
3247
|
}
|
|
3234
3248
|
this.sessionId = this.sessionIdGenerator?.();
|
|
@@ -3354,13 +3368,16 @@ data:
|
|
|
3354
3368
|
return void 0;
|
|
3355
3369
|
}
|
|
3356
3370
|
if (!this._initialized) {
|
|
3371
|
+
this.onerror?.(new Error("Bad Request: Server not initialized"));
|
|
3357
3372
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Server not initialized");
|
|
3358
3373
|
}
|
|
3359
3374
|
const sessionId = req.headers.get("mcp-session-id");
|
|
3360
3375
|
if (!sessionId) {
|
|
3376
|
+
this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required"));
|
|
3361
3377
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
3362
3378
|
}
|
|
3363
3379
|
if (sessionId !== this.sessionId) {
|
|
3380
|
+
this.onerror?.(new Error("Session not found"));
|
|
3364
3381
|
return this.createJsonErrorResponse(404, -32001, "Session not found");
|
|
3365
3382
|
}
|
|
3366
3383
|
return void 0;
|
|
@@ -3381,6 +3398,7 @@ data:
|
|
|
3381
3398
|
validateProtocolVersion(req) {
|
|
3382
3399
|
const protocolVersion = req.headers.get("mcp-protocol-version");
|
|
3383
3400
|
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
|
|
3401
|
+
this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
|
|
3384
3402
|
return this.createJsonErrorResponse(400, -32e3, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
|
|
3385
3403
|
}
|
|
3386
3404
|
return void 0;
|
|
@@ -3587,7 +3605,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
3587
3605
|
};
|
|
3588
3606
|
|
|
3589
3607
|
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
3590
|
-
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value
|
|
3608
|
+
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
3591
3609
|
var LETTER_REGEXP = /[A-Za-z]/;
|
|
3592
3610
|
var NUMBER_REGEXP = /-?\d+(\.\d*)?(e-?\d+)?$/;
|
|
3593
3611
|
var HYPHEN_REGEXP = /^(-|--)[^-]/;
|
|
@@ -3598,12 +3616,19 @@ var NON_WHITESPACE_REGEXP = /\S/;
|
|
|
3598
3616
|
function isNumber(string3) {
|
|
3599
3617
|
return NON_WHITESPACE_REGEXP.test(string3) && Number.isFinite(Number(string3));
|
|
3600
3618
|
}
|
|
3619
|
+
function isConstructorOrProto(obj, key) {
|
|
3620
|
+
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
|
|
3621
|
+
}
|
|
3601
3622
|
function setNested(object5, keys, value, collect = false) {
|
|
3602
3623
|
keys = [
|
|
3603
3624
|
...keys
|
|
3604
3625
|
];
|
|
3605
3626
|
const key = keys.pop();
|
|
3606
|
-
|
|
3627
|
+
for (const k of keys) {
|
|
3628
|
+
if (isConstructorOrProto(object5, k)) return;
|
|
3629
|
+
object5 = object5[k] ??= {};
|
|
3630
|
+
}
|
|
3631
|
+
if (isConstructorOrProto(object5, key)) return;
|
|
3607
3632
|
if (collect) {
|
|
3608
3633
|
const v = object5[key];
|
|
3609
3634
|
if (Array.isArray(v)) {
|
|
@@ -3734,7 +3759,7 @@ function parseArgs(args, options) {
|
|
|
3734
3759
|
let key = groups.key;
|
|
3735
3760
|
let value = groups.value;
|
|
3736
3761
|
if (doubleDash2) {
|
|
3737
|
-
if (value) {
|
|
3762
|
+
if (value != null) {
|
|
3738
3763
|
if (booleanSet.has(key)) value = parseBooleanString(value);
|
|
3739
3764
|
setArgument(key, value, arg, true);
|
|
3740
3765
|
continue;
|
|
@@ -3772,6 +3797,10 @@ function parseArgs(args, options) {
|
|
|
3772
3797
|
setArgument(letter, next, arg, true);
|
|
3773
3798
|
continue;
|
|
3774
3799
|
}
|
|
3800
|
+
if (next === "=") {
|
|
3801
|
+
setArgument(letter, "", arg, true);
|
|
3802
|
+
continue argsLoop;
|
|
3803
|
+
}
|
|
3775
3804
|
if (LETTER_REGEXP.test(letter)) {
|
|
3776
3805
|
const groups2 = VALUE_REGEXP.exec(next)?.groups;
|
|
3777
3806
|
if (groups2) {
|
|
@@ -3848,7 +3877,7 @@ function parseArgs(args, options) {
|
|
|
3848
3877
|
import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
3849
3878
|
import { homedir } from "node:os";
|
|
3850
3879
|
import { dirname, join as join3, resolve as resolve4 } from "node:path";
|
|
3851
|
-
import
|
|
3880
|
+
import process5 from "node:process";
|
|
3852
3881
|
|
|
3853
3882
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/large-result.js
|
|
3854
3883
|
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
@@ -4266,7 +4295,7 @@ Usage:
|
|
|
4266
4295
|
- ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
|
|
4267
4296
|
- ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
|
|
4268
4297
|
|
|
4269
|
-
Note: For scripts
|
|
4298
|
+
Note: For scripts/, use the bash tool with the script path to execute.`;
|
|
4270
4299
|
}
|
|
4271
4300
|
function createSkillsPlugin(options) {
|
|
4272
4301
|
const { paths } = options;
|
|
@@ -4374,11 +4403,15 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
4374
4403
|
try {
|
|
4375
4404
|
const content = await readFile(join2(meta.basePath, "SKILL.md"), "utf-8");
|
|
4376
4405
|
const body = extractBody(content);
|
|
4406
|
+
const skillPathInfo = `
|
|
4407
|
+
---
|
|
4408
|
+
Skill path: ${meta.basePath}
|
|
4409
|
+
`;
|
|
4377
4410
|
return {
|
|
4378
4411
|
content: [
|
|
4379
4412
|
{
|
|
4380
4413
|
type: "text",
|
|
4381
|
-
text: body
|
|
4414
|
+
text: body + skillPathInfo
|
|
4382
4415
|
}
|
|
4383
4416
|
]
|
|
4384
4417
|
};
|
|
@@ -4405,6 +4438,152 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
4405
4438
|
};
|
|
4406
4439
|
}
|
|
4407
4440
|
|
|
4441
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/bash.js
|
|
4442
|
+
import { spawn } from "node:child_process";
|
|
4443
|
+
import process2 from "node:process";
|
|
4444
|
+
var DEFAULT_MAX_BYTES = 1e5;
|
|
4445
|
+
var DEFAULT_MAX_LINES = 2e3;
|
|
4446
|
+
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
4447
|
+
function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
|
|
4448
|
+
const fullOutput = (stderr ? `STDERR:
|
|
4449
|
+
${stderr}
|
|
4450
|
+
|
|
4451
|
+
STDOUT:
|
|
4452
|
+
` : "") + stdout;
|
|
4453
|
+
const lines = fullOutput.split("\n");
|
|
4454
|
+
if (lines.length > maxLines) {
|
|
4455
|
+
const truncatedLines = lines.slice(-maxLines);
|
|
4456
|
+
return {
|
|
4457
|
+
output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
|
|
4458
|
+
|
|
4459
|
+
` + truncatedLines.join("\n"),
|
|
4460
|
+
truncated: true
|
|
4461
|
+
};
|
|
4462
|
+
}
|
|
4463
|
+
if (fullOutput.length > maxBytes) {
|
|
4464
|
+
const truncatedBytes = fullOutput.slice(-maxBytes);
|
|
4465
|
+
return {
|
|
4466
|
+
output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
|
|
4467
|
+
|
|
4468
|
+
` + truncatedBytes,
|
|
4469
|
+
truncated: true
|
|
4470
|
+
};
|
|
4471
|
+
}
|
|
4472
|
+
return {
|
|
4473
|
+
output: fullOutput,
|
|
4474
|
+
truncated: false
|
|
4475
|
+
};
|
|
4476
|
+
}
|
|
4477
|
+
function executeBash(command, cwd2, timeoutMs) {
|
|
4478
|
+
return new Promise((resolve5) => {
|
|
4479
|
+
const stdout = [];
|
|
4480
|
+
const stderr = [];
|
|
4481
|
+
const proc = spawn("bash", [
|
|
4482
|
+
"-c",
|
|
4483
|
+
command
|
|
4484
|
+
], {
|
|
4485
|
+
cwd: cwd2,
|
|
4486
|
+
stdio: [
|
|
4487
|
+
"ignore",
|
|
4488
|
+
"pipe",
|
|
4489
|
+
"pipe"
|
|
4490
|
+
]
|
|
4491
|
+
});
|
|
4492
|
+
proc.stdout?.on("data", (data) => {
|
|
4493
|
+
stdout.push(data.toString());
|
|
4494
|
+
});
|
|
4495
|
+
proc.stderr?.on("data", (data) => {
|
|
4496
|
+
stderr.push(data.toString());
|
|
4497
|
+
});
|
|
4498
|
+
proc.on("close", (code) => {
|
|
4499
|
+
resolve5({
|
|
4500
|
+
stdout: stdout.join(""),
|
|
4501
|
+
stderr: stderr.join(""),
|
|
4502
|
+
exitCode: code
|
|
4503
|
+
});
|
|
4504
|
+
});
|
|
4505
|
+
proc.on("error", (err) => {
|
|
4506
|
+
resolve5({
|
|
4507
|
+
stdout: "",
|
|
4508
|
+
stderr: err.message,
|
|
4509
|
+
exitCode: null
|
|
4510
|
+
});
|
|
4511
|
+
});
|
|
4512
|
+
setTimeout(() => {
|
|
4513
|
+
proc.kill("SIGTERM");
|
|
4514
|
+
resolve5({
|
|
4515
|
+
stdout: stdout.join(""),
|
|
4516
|
+
stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
|
|
4517
|
+
exitCode: null
|
|
4518
|
+
});
|
|
4519
|
+
}, timeoutMs);
|
|
4520
|
+
});
|
|
4521
|
+
}
|
|
4522
|
+
function createBashPlugin(options = {}) {
|
|
4523
|
+
const { maxBytes, maxLines, timeoutMs } = {
|
|
4524
|
+
maxBytes: DEFAULT_MAX_BYTES,
|
|
4525
|
+
maxLines: DEFAULT_MAX_LINES,
|
|
4526
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
4527
|
+
...options
|
|
4528
|
+
};
|
|
4529
|
+
let serverRef = null;
|
|
4530
|
+
return {
|
|
4531
|
+
name: "plugin-bash",
|
|
4532
|
+
version: "1.0.0",
|
|
4533
|
+
// Store server reference for tool registration
|
|
4534
|
+
configureServer: (server) => {
|
|
4535
|
+
serverRef = server;
|
|
4536
|
+
},
|
|
4537
|
+
// Register bash tool with agent name prefix
|
|
4538
|
+
composeStart: (context2) => {
|
|
4539
|
+
if (!serverRef) return;
|
|
4540
|
+
const agentName = context2.serverName;
|
|
4541
|
+
const toolName = `${agentName}__bash`;
|
|
4542
|
+
serverRef.tool(toolName, "Execute a bash command and return its output.\n\nUse this for:\n- Running shell commands\n- Executing scripts\n- System operations\n\nNote: Output is truncated if too large.", {
|
|
4543
|
+
type: "object",
|
|
4544
|
+
properties: {
|
|
4545
|
+
command: {
|
|
4546
|
+
type: "string",
|
|
4547
|
+
description: "The bash command to execute"
|
|
4548
|
+
},
|
|
4549
|
+
cwd: {
|
|
4550
|
+
type: "string",
|
|
4551
|
+
description: "Optional: Working directory for the command (defaults to current directory)"
|
|
4552
|
+
}
|
|
4553
|
+
},
|
|
4554
|
+
required: [
|
|
4555
|
+
"command"
|
|
4556
|
+
]
|
|
4557
|
+
}, async (args) => {
|
|
4558
|
+
const cwd2 = args.cwd || process2.cwd();
|
|
4559
|
+
const result = await executeBash(args.command, cwd2, timeoutMs);
|
|
4560
|
+
const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
|
|
4561
|
+
let finalOutput = output;
|
|
4562
|
+
if (result.exitCode !== null && result.exitCode !== 0) {
|
|
4563
|
+
finalOutput = `[EXIT CODE: ${result.exitCode}]
|
|
4564
|
+
` + finalOutput;
|
|
4565
|
+
}
|
|
4566
|
+
if (truncated) {
|
|
4567
|
+
finalOutput += `
|
|
4568
|
+
|
|
4569
|
+
[Note: Output was truncated]`;
|
|
4570
|
+
}
|
|
4571
|
+
return {
|
|
4572
|
+
content: [
|
|
4573
|
+
{
|
|
4574
|
+
type: "text",
|
|
4575
|
+
text: finalOutput
|
|
4576
|
+
}
|
|
4577
|
+
],
|
|
4578
|
+
isError: result.exitCode !== null && result.exitCode !== 0
|
|
4579
|
+
};
|
|
4580
|
+
}, {
|
|
4581
|
+
internal: true
|
|
4582
|
+
});
|
|
4583
|
+
}
|
|
4584
|
+
};
|
|
4585
|
+
}
|
|
4586
|
+
|
|
4408
4587
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
4409
4588
|
import { createCodeExecutionPlugin } from "@mcpc-tech/plugin-code-execution";
|
|
4410
4589
|
|
|
@@ -5249,12 +5428,29 @@ function writeFoldedLines(count) {
|
|
|
5249
5428
|
if (count > 1) return "\n".repeat(count - 1);
|
|
5250
5429
|
return "";
|
|
5251
5430
|
}
|
|
5431
|
+
var Scanner = class {
|
|
5432
|
+
source;
|
|
5433
|
+
#length;
|
|
5434
|
+
position = 0;
|
|
5435
|
+
constructor(source) {
|
|
5436
|
+
source += "\0";
|
|
5437
|
+
this.source = source;
|
|
5438
|
+
this.#length = source.length;
|
|
5439
|
+
}
|
|
5440
|
+
peek(offset = 0) {
|
|
5441
|
+
return this.source.charCodeAt(this.position + offset);
|
|
5442
|
+
}
|
|
5443
|
+
next() {
|
|
5444
|
+
this.position += 1;
|
|
5445
|
+
}
|
|
5446
|
+
eof() {
|
|
5447
|
+
return this.position >= this.#length - 1;
|
|
5448
|
+
}
|
|
5449
|
+
};
|
|
5252
5450
|
var LoaderState = class {
|
|
5253
|
-
|
|
5254
|
-
length;
|
|
5451
|
+
#scanner;
|
|
5255
5452
|
lineIndent = 0;
|
|
5256
5453
|
lineStart = 0;
|
|
5257
|
-
position = 0;
|
|
5258
5454
|
line = 0;
|
|
5259
5455
|
onWarning;
|
|
5260
5456
|
allowDuplicateKeys;
|
|
@@ -5264,44 +5460,40 @@ var LoaderState = class {
|
|
|
5264
5460
|
tagMap = /* @__PURE__ */ new Map();
|
|
5265
5461
|
anchorMap = /* @__PURE__ */ new Map();
|
|
5266
5462
|
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
5267
|
-
this
|
|
5463
|
+
this.#scanner = new Scanner(input);
|
|
5268
5464
|
this.onWarning = onWarning;
|
|
5269
5465
|
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
5270
5466
|
this.implicitTypes = schema.implicitTypes;
|
|
5271
5467
|
this.typeMap = schema.typeMap;
|
|
5272
|
-
this.length = input.length;
|
|
5273
5468
|
this.readIndent();
|
|
5274
5469
|
}
|
|
5275
5470
|
skipWhitespaces() {
|
|
5276
|
-
let ch = this.peek();
|
|
5471
|
+
let ch = this.#scanner.peek();
|
|
5277
5472
|
while (isWhiteSpace(ch)) {
|
|
5278
|
-
|
|
5473
|
+
this.#scanner.next();
|
|
5474
|
+
ch = this.#scanner.peek();
|
|
5279
5475
|
}
|
|
5280
5476
|
}
|
|
5281
5477
|
skipComment() {
|
|
5282
|
-
let ch = this.peek();
|
|
5478
|
+
let ch = this.#scanner.peek();
|
|
5283
5479
|
if (ch !== SHARP) return;
|
|
5284
|
-
|
|
5480
|
+
this.#scanner.next();
|
|
5481
|
+
ch = this.#scanner.peek();
|
|
5285
5482
|
while (ch !== 0 && !isEOL(ch)) {
|
|
5286
|
-
|
|
5483
|
+
this.#scanner.next();
|
|
5484
|
+
ch = this.#scanner.peek();
|
|
5287
5485
|
}
|
|
5288
5486
|
}
|
|
5289
5487
|
readIndent() {
|
|
5290
|
-
let
|
|
5291
|
-
while (
|
|
5488
|
+
let ch = this.#scanner.peek();
|
|
5489
|
+
while (ch === SPACE) {
|
|
5292
5490
|
this.lineIndent += 1;
|
|
5293
|
-
|
|
5491
|
+
this.#scanner.next();
|
|
5492
|
+
ch = this.#scanner.peek();
|
|
5294
5493
|
}
|
|
5295
5494
|
}
|
|
5296
|
-
peek(offset = 0) {
|
|
5297
|
-
return this.input.charCodeAt(this.position + offset);
|
|
5298
|
-
}
|
|
5299
|
-
next() {
|
|
5300
|
-
this.position += 1;
|
|
5301
|
-
return this.peek();
|
|
5302
|
-
}
|
|
5303
5495
|
#createError(message) {
|
|
5304
|
-
const mark = markToString(this.
|
|
5496
|
+
const mark = markToString(this.#scanner.source, this.#scanner.position, this.line, this.#scanner.position - this.lineStart);
|
|
5305
5497
|
return new SyntaxError(`${message} ${mark}`);
|
|
5306
5498
|
}
|
|
5307
5499
|
dispatchWarning(message) {
|
|
@@ -5346,7 +5538,7 @@ var LoaderState = class {
|
|
|
5346
5538
|
}
|
|
5347
5539
|
captureSegment(start, end, checkJson) {
|
|
5348
5540
|
if (start < end) {
|
|
5349
|
-
const result = this.
|
|
5541
|
+
const result = this.#scanner.source.slice(start, end);
|
|
5350
5542
|
if (checkJson) {
|
|
5351
5543
|
for (let position = 0; position < result.length; position++) {
|
|
5352
5544
|
const character = result.charCodeAt(position);
|
|
@@ -5364,21 +5556,21 @@ var LoaderState = class {
|
|
|
5364
5556
|
let detected = false;
|
|
5365
5557
|
const result = [];
|
|
5366
5558
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
5367
|
-
let ch = this.peek();
|
|
5559
|
+
let ch = this.#scanner.peek();
|
|
5368
5560
|
while (ch !== 0) {
|
|
5369
5561
|
if (ch !== MINUS) {
|
|
5370
5562
|
break;
|
|
5371
5563
|
}
|
|
5372
|
-
const following = this.peek(1);
|
|
5564
|
+
const following = this.#scanner.peek(1);
|
|
5373
5565
|
if (!isWhiteSpaceOrEOL(following)) {
|
|
5374
5566
|
break;
|
|
5375
5567
|
}
|
|
5376
5568
|
detected = true;
|
|
5377
|
-
this.
|
|
5569
|
+
this.#scanner.next();
|
|
5378
5570
|
if (this.skipSeparationSpace(true, -1)) {
|
|
5379
5571
|
if (this.lineIndent <= nodeIndent) {
|
|
5380
5572
|
result.push(null);
|
|
5381
|
-
ch = this.peek();
|
|
5573
|
+
ch = this.#scanner.peek();
|
|
5382
5574
|
continue;
|
|
5383
5575
|
}
|
|
5384
5576
|
}
|
|
@@ -5391,7 +5583,7 @@ var LoaderState = class {
|
|
|
5391
5583
|
});
|
|
5392
5584
|
if (newState) result.push(newState.result);
|
|
5393
5585
|
this.skipSeparationSpace(true, -1);
|
|
5394
|
-
ch = this.peek();
|
|
5586
|
+
ch = this.#scanner.peek();
|
|
5395
5587
|
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
|
|
5396
5588
|
throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
5397
5589
|
} else if (this.lineIndent < nodeIndent) {
|
|
@@ -5447,7 +5639,7 @@ var LoaderState = class {
|
|
|
5447
5639
|
} else {
|
|
5448
5640
|
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
5449
5641
|
this.line = startLine || this.line;
|
|
5450
|
-
this.position = startPos || this.position;
|
|
5642
|
+
this.#scanner.position = startPos || this.#scanner.position;
|
|
5451
5643
|
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
5452
5644
|
}
|
|
5453
5645
|
Object.defineProperty(result, keyNode, {
|
|
@@ -5461,37 +5653,37 @@ var LoaderState = class {
|
|
|
5461
5653
|
return result;
|
|
5462
5654
|
}
|
|
5463
5655
|
readLineBreak() {
|
|
5464
|
-
const ch = this.peek();
|
|
5656
|
+
const ch = this.#scanner.peek();
|
|
5465
5657
|
if (ch === LINE_FEED) {
|
|
5466
|
-
this.
|
|
5658
|
+
this.#scanner.next();
|
|
5467
5659
|
} else if (ch === CARRIAGE_RETURN) {
|
|
5468
|
-
this.
|
|
5469
|
-
if (this.peek() === LINE_FEED) {
|
|
5470
|
-
this.
|
|
5660
|
+
this.#scanner.next();
|
|
5661
|
+
if (this.#scanner.peek() === LINE_FEED) {
|
|
5662
|
+
this.#scanner.next();
|
|
5471
5663
|
}
|
|
5472
5664
|
} else {
|
|
5473
5665
|
throw this.#createError("Cannot read line: line break not found");
|
|
5474
5666
|
}
|
|
5475
5667
|
this.line += 1;
|
|
5476
|
-
this.lineStart = this.position;
|
|
5668
|
+
this.lineStart = this.#scanner.position;
|
|
5477
5669
|
}
|
|
5478
5670
|
skipSeparationSpace(allowComments, checkIndent) {
|
|
5479
5671
|
let lineBreaks = 0;
|
|
5480
|
-
let ch = this.peek();
|
|
5672
|
+
let ch = this.#scanner.peek();
|
|
5481
5673
|
while (ch !== 0) {
|
|
5482
5674
|
this.skipWhitespaces();
|
|
5483
|
-
ch = this.peek();
|
|
5675
|
+
ch = this.#scanner.peek();
|
|
5484
5676
|
if (allowComments) {
|
|
5485
5677
|
this.skipComment();
|
|
5486
|
-
ch = this.peek();
|
|
5678
|
+
ch = this.#scanner.peek();
|
|
5487
5679
|
}
|
|
5488
5680
|
if (isEOL(ch)) {
|
|
5489
5681
|
this.readLineBreak();
|
|
5490
|
-
ch = this.peek();
|
|
5682
|
+
ch = this.#scanner.peek();
|
|
5491
5683
|
lineBreaks++;
|
|
5492
5684
|
this.lineIndent = 0;
|
|
5493
5685
|
this.readIndent();
|
|
5494
|
-
ch = this.peek();
|
|
5686
|
+
ch = this.#scanner.peek();
|
|
5495
5687
|
} else {
|
|
5496
5688
|
break;
|
|
5497
5689
|
}
|
|
@@ -5502,9 +5694,9 @@ var LoaderState = class {
|
|
|
5502
5694
|
return lineBreaks;
|
|
5503
5695
|
}
|
|
5504
5696
|
testDocumentSeparator() {
|
|
5505
|
-
let ch = this.peek();
|
|
5506
|
-
if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) {
|
|
5507
|
-
ch = this.peek(3);
|
|
5697
|
+
let ch = this.#scanner.peek();
|
|
5698
|
+
if ((ch === MINUS || ch === DOT) && ch === this.#scanner.peek(1) && ch === this.#scanner.peek(2)) {
|
|
5699
|
+
ch = this.#scanner.peek(3);
|
|
5508
5700
|
if (ch === 0 || isWhiteSpaceOrEOL(ch)) {
|
|
5509
5701
|
return true;
|
|
5510
5702
|
}
|
|
@@ -5512,34 +5704,34 @@ var LoaderState = class {
|
|
|
5512
5704
|
return false;
|
|
5513
5705
|
}
|
|
5514
5706
|
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
5515
|
-
let ch = this.peek();
|
|
5707
|
+
let ch = this.#scanner.peek();
|
|
5516
5708
|
if (isWhiteSpaceOrEOL(ch) || isFlowIndicator(ch) || ch === SHARP || ch === AMPERSAND || ch === ASTERISK || ch === EXCLAMATION || ch === VERTICAL_LINE || ch === GREATER_THAN || ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE || ch === PERCENT || ch === COMMERCIAL_AT || ch === GRAVE_ACCENT) {
|
|
5517
5709
|
return;
|
|
5518
5710
|
}
|
|
5519
5711
|
let following;
|
|
5520
5712
|
if (ch === QUESTION || ch === MINUS) {
|
|
5521
|
-
following = this.peek(1);
|
|
5713
|
+
following = this.#scanner.peek(1);
|
|
5522
5714
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
5523
5715
|
return;
|
|
5524
5716
|
}
|
|
5525
5717
|
}
|
|
5526
5718
|
let result = "";
|
|
5527
|
-
let captureEnd = this.position;
|
|
5528
|
-
let captureStart = this.position;
|
|
5719
|
+
let captureEnd = this.#scanner.position;
|
|
5720
|
+
let captureStart = this.#scanner.position;
|
|
5529
5721
|
let hasPendingContent = false;
|
|
5530
5722
|
let line = 0;
|
|
5531
5723
|
while (ch !== 0) {
|
|
5532
5724
|
if (ch === COLON) {
|
|
5533
|
-
following = this.peek(1);
|
|
5725
|
+
following = this.#scanner.peek(1);
|
|
5534
5726
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
5535
5727
|
break;
|
|
5536
5728
|
}
|
|
5537
5729
|
} else if (ch === SHARP) {
|
|
5538
|
-
const preceding = this.peek(-1);
|
|
5730
|
+
const preceding = this.#scanner.peek(-1);
|
|
5539
5731
|
if (isWhiteSpaceOrEOL(preceding)) {
|
|
5540
5732
|
break;
|
|
5541
5733
|
}
|
|
5542
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
5734
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
5543
5735
|
break;
|
|
5544
5736
|
} else if (isEOL(ch)) {
|
|
5545
5737
|
line = this.line;
|
|
@@ -5548,10 +5740,10 @@ var LoaderState = class {
|
|
|
5548
5740
|
this.skipSeparationSpace(false, -1);
|
|
5549
5741
|
if (this.lineIndent >= nodeIndent) {
|
|
5550
5742
|
hasPendingContent = true;
|
|
5551
|
-
ch = this.peek();
|
|
5743
|
+
ch = this.#scanner.peek();
|
|
5552
5744
|
continue;
|
|
5553
5745
|
} else {
|
|
5554
|
-
this.position = captureEnd;
|
|
5746
|
+
this.#scanner.position = captureEnd;
|
|
5555
5747
|
this.line = line;
|
|
5556
5748
|
this.lineStart = lineStart;
|
|
5557
5749
|
this.lineIndent = lineIndent;
|
|
@@ -5562,13 +5754,14 @@ var LoaderState = class {
|
|
|
5562
5754
|
const segment2 = this.captureSegment(captureStart, captureEnd, false);
|
|
5563
5755
|
if (segment2) result += segment2;
|
|
5564
5756
|
result += writeFoldedLines(this.line - line);
|
|
5565
|
-
captureStart = captureEnd = this.position;
|
|
5757
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
5566
5758
|
hasPendingContent = false;
|
|
5567
5759
|
}
|
|
5568
5760
|
if (!isWhiteSpace(ch)) {
|
|
5569
|
-
captureEnd = this.position + 1;
|
|
5761
|
+
captureEnd = this.#scanner.position + 1;
|
|
5570
5762
|
}
|
|
5571
|
-
|
|
5763
|
+
this.#scanner.next();
|
|
5764
|
+
ch = this.#scanner.peek();
|
|
5572
5765
|
}
|
|
5573
5766
|
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
5574
5767
|
if (segment) result += segment;
|
|
@@ -5581,22 +5774,23 @@ var LoaderState = class {
|
|
|
5581
5774
|
};
|
|
5582
5775
|
}
|
|
5583
5776
|
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
5584
|
-
let ch = this.peek();
|
|
5777
|
+
let ch = this.#scanner.peek();
|
|
5585
5778
|
if (ch !== SINGLE_QUOTE) return;
|
|
5586
5779
|
let result = "";
|
|
5587
|
-
this.
|
|
5588
|
-
let captureStart = this.position;
|
|
5589
|
-
let captureEnd = this.position;
|
|
5590
|
-
ch = this.peek();
|
|
5780
|
+
this.#scanner.next();
|
|
5781
|
+
let captureStart = this.#scanner.position;
|
|
5782
|
+
let captureEnd = this.#scanner.position;
|
|
5783
|
+
ch = this.#scanner.peek();
|
|
5591
5784
|
while (ch !== 0) {
|
|
5592
5785
|
if (ch === SINGLE_QUOTE) {
|
|
5593
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
5786
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
5594
5787
|
if (segment) result += segment;
|
|
5595
|
-
|
|
5788
|
+
this.#scanner.next();
|
|
5789
|
+
ch = this.#scanner.peek();
|
|
5596
5790
|
if (ch === SINGLE_QUOTE) {
|
|
5597
|
-
captureStart = this.position;
|
|
5598
|
-
this.
|
|
5599
|
-
captureEnd = this.position;
|
|
5791
|
+
captureStart = this.#scanner.position;
|
|
5792
|
+
this.#scanner.next();
|
|
5793
|
+
captureEnd = this.#scanner.position;
|
|
5600
5794
|
} else {
|
|
5601
5795
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
5602
5796
|
return {
|
|
@@ -5610,31 +5804,31 @@ var LoaderState = class {
|
|
|
5610
5804
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
5611
5805
|
if (segment) result += segment;
|
|
5612
5806
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
5613
|
-
captureStart = captureEnd = this.position;
|
|
5614
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
5807
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
5808
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
5615
5809
|
throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
5616
5810
|
} else {
|
|
5617
|
-
this.
|
|
5618
|
-
captureEnd = this.position;
|
|
5811
|
+
this.#scanner.next();
|
|
5812
|
+
captureEnd = this.#scanner.position;
|
|
5619
5813
|
}
|
|
5620
|
-
ch = this.peek();
|
|
5814
|
+
ch = this.#scanner.peek();
|
|
5621
5815
|
}
|
|
5622
5816
|
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
5623
5817
|
}
|
|
5624
5818
|
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
5625
|
-
let ch = this.peek();
|
|
5819
|
+
let ch = this.#scanner.peek();
|
|
5626
5820
|
if (ch !== DOUBLE_QUOTE) return;
|
|
5627
5821
|
let result = "";
|
|
5628
|
-
this.
|
|
5629
|
-
let captureEnd = this.position;
|
|
5630
|
-
let captureStart = this.position;
|
|
5822
|
+
this.#scanner.next();
|
|
5823
|
+
let captureEnd = this.#scanner.position;
|
|
5824
|
+
let captureStart = this.#scanner.position;
|
|
5631
5825
|
let tmp;
|
|
5632
|
-
ch = this.peek();
|
|
5826
|
+
ch = this.#scanner.peek();
|
|
5633
5827
|
while (ch !== 0) {
|
|
5634
5828
|
if (ch === DOUBLE_QUOTE) {
|
|
5635
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
5829
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
5636
5830
|
if (segment) result += segment;
|
|
5637
|
-
this.
|
|
5831
|
+
this.#scanner.next();
|
|
5638
5832
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
5639
5833
|
return {
|
|
5640
5834
|
tag,
|
|
@@ -5644,19 +5838,21 @@ var LoaderState = class {
|
|
|
5644
5838
|
};
|
|
5645
5839
|
}
|
|
5646
5840
|
if (ch === BACKSLASH) {
|
|
5647
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
5841
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
5648
5842
|
if (segment) result += segment;
|
|
5649
|
-
|
|
5843
|
+
this.#scanner.next();
|
|
5844
|
+
ch = this.#scanner.peek();
|
|
5650
5845
|
if (isEOL(ch)) {
|
|
5651
5846
|
this.skipSeparationSpace(false, nodeIndent);
|
|
5652
5847
|
} else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
5653
5848
|
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
5654
|
-
this.
|
|
5849
|
+
this.#scanner.next();
|
|
5655
5850
|
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
5656
5851
|
let hexLength = tmp;
|
|
5657
5852
|
let hexResult = 0;
|
|
5658
5853
|
for (; hexLength > 0; hexLength--) {
|
|
5659
|
-
|
|
5854
|
+
this.#scanner.next();
|
|
5855
|
+
ch = this.#scanner.peek();
|
|
5660
5856
|
if ((tmp = hexCharCodeToNumber(ch)) >= 0) {
|
|
5661
5857
|
hexResult = (hexResult << 4) + tmp;
|
|
5662
5858
|
} else {
|
|
@@ -5664,28 +5860,28 @@ var LoaderState = class {
|
|
|
5664
5860
|
}
|
|
5665
5861
|
}
|
|
5666
5862
|
result += codepointToChar(hexResult);
|
|
5667
|
-
this.
|
|
5863
|
+
this.#scanner.next();
|
|
5668
5864
|
} else {
|
|
5669
5865
|
throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
5670
5866
|
}
|
|
5671
|
-
captureStart = captureEnd = this.position;
|
|
5867
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
5672
5868
|
} else if (isEOL(ch)) {
|
|
5673
5869
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
5674
5870
|
if (segment) result += segment;
|
|
5675
5871
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
5676
|
-
captureStart = captureEnd = this.position;
|
|
5677
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
5872
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
5873
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
5678
5874
|
throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
5679
5875
|
} else {
|
|
5680
|
-
this.
|
|
5681
|
-
captureEnd = this.position;
|
|
5876
|
+
this.#scanner.next();
|
|
5877
|
+
captureEnd = this.#scanner.position;
|
|
5682
5878
|
}
|
|
5683
|
-
ch = this.peek();
|
|
5879
|
+
ch = this.#scanner.peek();
|
|
5684
5880
|
}
|
|
5685
5881
|
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
5686
5882
|
}
|
|
5687
5883
|
readFlowCollection(tag, anchor, nodeIndent) {
|
|
5688
|
-
let ch = this.peek();
|
|
5884
|
+
let ch = this.#scanner.peek();
|
|
5689
5885
|
let terminator;
|
|
5690
5886
|
let isMapping = true;
|
|
5691
5887
|
let result = {};
|
|
@@ -5699,7 +5895,8 @@ var LoaderState = class {
|
|
|
5699
5895
|
return;
|
|
5700
5896
|
}
|
|
5701
5897
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
5702
|
-
|
|
5898
|
+
this.#scanner.next();
|
|
5899
|
+
ch = this.#scanner.peek();
|
|
5703
5900
|
let readNext = true;
|
|
5704
5901
|
let valueNode = null;
|
|
5705
5902
|
let keyNode = null;
|
|
@@ -5711,9 +5908,9 @@ var LoaderState = class {
|
|
|
5711
5908
|
const overridableKeys = /* @__PURE__ */ new Set();
|
|
5712
5909
|
while (ch !== 0) {
|
|
5713
5910
|
this.skipSeparationSpace(true, nodeIndent);
|
|
5714
|
-
ch = this.peek();
|
|
5911
|
+
ch = this.#scanner.peek();
|
|
5715
5912
|
if (ch === terminator) {
|
|
5716
|
-
this.
|
|
5913
|
+
this.#scanner.next();
|
|
5717
5914
|
const kind = isMapping ? "mapping" : "sequence";
|
|
5718
5915
|
return {
|
|
5719
5916
|
tag,
|
|
@@ -5728,10 +5925,10 @@ var LoaderState = class {
|
|
|
5728
5925
|
keyTag = keyNode = valueNode = null;
|
|
5729
5926
|
isPair = isExplicitPair = false;
|
|
5730
5927
|
if (ch === QUESTION) {
|
|
5731
|
-
following = this.peek(1);
|
|
5928
|
+
following = this.#scanner.peek(1);
|
|
5732
5929
|
if (isWhiteSpaceOrEOL(following)) {
|
|
5733
5930
|
isPair = isExplicitPair = true;
|
|
5734
|
-
this.
|
|
5931
|
+
this.#scanner.next();
|
|
5735
5932
|
this.skipSeparationSpace(true, nodeIndent);
|
|
5736
5933
|
}
|
|
5737
5934
|
}
|
|
@@ -5747,10 +5944,11 @@ var LoaderState = class {
|
|
|
5747
5944
|
keyNode = newState.result;
|
|
5748
5945
|
}
|
|
5749
5946
|
this.skipSeparationSpace(true, nodeIndent);
|
|
5750
|
-
ch = this.peek();
|
|
5947
|
+
ch = this.#scanner.peek();
|
|
5751
5948
|
if ((isExplicitPair || this.line === line) && ch === COLON) {
|
|
5752
5949
|
isPair = true;
|
|
5753
|
-
|
|
5950
|
+
this.#scanner.next();
|
|
5951
|
+
ch = this.#scanner.peek();
|
|
5754
5952
|
this.skipSeparationSpace(true, nodeIndent);
|
|
5755
5953
|
const newState2 = this.composeNode({
|
|
5756
5954
|
parentIndent: nodeIndent,
|
|
@@ -5768,10 +5966,11 @@ var LoaderState = class {
|
|
|
5768
5966
|
result.push(keyNode);
|
|
5769
5967
|
}
|
|
5770
5968
|
this.skipSeparationSpace(true, nodeIndent);
|
|
5771
|
-
ch = this.peek();
|
|
5969
|
+
ch = this.#scanner.peek();
|
|
5772
5970
|
if (ch === COMMA) {
|
|
5773
5971
|
readNext = true;
|
|
5774
|
-
|
|
5972
|
+
this.#scanner.next();
|
|
5973
|
+
ch = this.#scanner.peek();
|
|
5775
5974
|
} else {
|
|
5776
5975
|
readNext = false;
|
|
5777
5976
|
}
|
|
@@ -5787,7 +5986,7 @@ var LoaderState = class {
|
|
|
5787
5986
|
let textIndent = nodeIndent;
|
|
5788
5987
|
let emptyLines = 0;
|
|
5789
5988
|
let atMoreIndented = false;
|
|
5790
|
-
let ch = this.peek();
|
|
5989
|
+
let ch = this.#scanner.peek();
|
|
5791
5990
|
let folding = false;
|
|
5792
5991
|
if (ch === VERTICAL_LINE) {
|
|
5793
5992
|
folding = false;
|
|
@@ -5799,7 +5998,8 @@ var LoaderState = class {
|
|
|
5799
5998
|
let result = "";
|
|
5800
5999
|
let tmp = 0;
|
|
5801
6000
|
while (ch !== 0) {
|
|
5802
|
-
|
|
6001
|
+
this.#scanner.next();
|
|
6002
|
+
ch = this.#scanner.peek();
|
|
5803
6003
|
if (ch === PLUS || ch === MINUS) {
|
|
5804
6004
|
if (CHOMPING_CLIP === chomping) {
|
|
5805
6005
|
chomping = ch === PLUS ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
@@ -5822,15 +6022,16 @@ var LoaderState = class {
|
|
|
5822
6022
|
if (isWhiteSpace(ch)) {
|
|
5823
6023
|
this.skipWhitespaces();
|
|
5824
6024
|
this.skipComment();
|
|
5825
|
-
ch = this.peek();
|
|
6025
|
+
ch = this.#scanner.peek();
|
|
5826
6026
|
}
|
|
5827
6027
|
while (ch !== 0) {
|
|
5828
6028
|
this.readLineBreak();
|
|
5829
6029
|
this.lineIndent = 0;
|
|
5830
|
-
ch = this.peek();
|
|
6030
|
+
ch = this.#scanner.peek();
|
|
5831
6031
|
while ((!detectedIndent || this.lineIndent < textIndent) && ch === SPACE) {
|
|
5832
6032
|
this.lineIndent++;
|
|
5833
|
-
|
|
6033
|
+
this.#scanner.next();
|
|
6034
|
+
ch = this.#scanner.peek();
|
|
5834
6035
|
}
|
|
5835
6036
|
if (!detectedIndent && this.lineIndent > textIndent) {
|
|
5836
6037
|
textIndent = this.lineIndent;
|
|
@@ -5869,11 +6070,12 @@ var LoaderState = class {
|
|
|
5869
6070
|
didReadContent = true;
|
|
5870
6071
|
detectedIndent = true;
|
|
5871
6072
|
emptyLines = 0;
|
|
5872
|
-
const captureStart = this.position;
|
|
6073
|
+
const captureStart = this.#scanner.position;
|
|
5873
6074
|
while (!isEOL(ch) && ch !== 0) {
|
|
5874
|
-
|
|
6075
|
+
this.#scanner.next();
|
|
6076
|
+
ch = this.#scanner.peek();
|
|
5875
6077
|
}
|
|
5876
|
-
const segment = this.captureSegment(captureStart, this.position, false);
|
|
6078
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, false);
|
|
5877
6079
|
if (segment) result += segment;
|
|
5878
6080
|
}
|
|
5879
6081
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
@@ -5896,11 +6098,11 @@ var LoaderState = class {
|
|
|
5896
6098
|
let atExplicitKey = false;
|
|
5897
6099
|
let detected = false;
|
|
5898
6100
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
5899
|
-
let ch = this.peek();
|
|
6101
|
+
let ch = this.#scanner.peek();
|
|
5900
6102
|
while (ch !== 0) {
|
|
5901
|
-
const following = this.peek(1);
|
|
6103
|
+
const following = this.#scanner.peek(1);
|
|
5902
6104
|
line = this.line;
|
|
5903
|
-
pos = this.position;
|
|
6105
|
+
pos = this.#scanner.position;
|
|
5904
6106
|
if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) {
|
|
5905
6107
|
if (ch === QUESTION) {
|
|
5906
6108
|
if (atExplicitKey) {
|
|
@@ -5918,7 +6120,7 @@ var LoaderState = class {
|
|
|
5918
6120
|
} else {
|
|
5919
6121
|
throw this.#createError("Cannot read block as explicit mapping pair is incomplete: a key node is missed or followed by a non-tabulated empty line");
|
|
5920
6122
|
}
|
|
5921
|
-
this.
|
|
6123
|
+
this.#scanner.next();
|
|
5922
6124
|
ch = following;
|
|
5923
6125
|
} else {
|
|
5924
6126
|
const newState = this.composeNode({
|
|
@@ -5929,11 +6131,12 @@ var LoaderState = class {
|
|
|
5929
6131
|
});
|
|
5930
6132
|
if (!newState) break;
|
|
5931
6133
|
if (this.line === line) {
|
|
5932
|
-
ch = this.peek();
|
|
6134
|
+
ch = this.#scanner.peek();
|
|
5933
6135
|
this.skipWhitespaces();
|
|
5934
|
-
ch = this.peek();
|
|
6136
|
+
ch = this.#scanner.peek();
|
|
5935
6137
|
if (ch === COLON) {
|
|
5936
|
-
|
|
6138
|
+
this.#scanner.next();
|
|
6139
|
+
ch = this.#scanner.peek();
|
|
5937
6140
|
if (!isWhiteSpaceOrEOL(ch)) {
|
|
5938
6141
|
throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
5939
6142
|
}
|
|
@@ -5990,7 +6193,7 @@ var LoaderState = class {
|
|
|
5990
6193
|
keyTag = keyNode = valueNode = null;
|
|
5991
6194
|
}
|
|
5992
6195
|
this.skipSeparationSpace(true, -1);
|
|
5993
|
-
ch = this.peek();
|
|
6196
|
+
ch = this.#scanner.peek();
|
|
5994
6197
|
}
|
|
5995
6198
|
if (this.lineIndent > nodeIndent && ch !== 0) {
|
|
5996
6199
|
throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
@@ -6013,30 +6216,35 @@ var LoaderState = class {
|
|
|
6013
6216
|
let isNamed = false;
|
|
6014
6217
|
let tagHandle = "";
|
|
6015
6218
|
let tagName;
|
|
6016
|
-
let ch = this.peek();
|
|
6219
|
+
let ch = this.#scanner.peek();
|
|
6017
6220
|
if (ch !== EXCLAMATION) return;
|
|
6018
6221
|
if (tag !== null) {
|
|
6019
6222
|
throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
6020
6223
|
}
|
|
6021
|
-
|
|
6224
|
+
this.#scanner.next();
|
|
6225
|
+
ch = this.#scanner.peek();
|
|
6022
6226
|
if (ch === SMALLER_THAN) {
|
|
6023
6227
|
isVerbatim = true;
|
|
6024
|
-
|
|
6228
|
+
this.#scanner.next();
|
|
6229
|
+
ch = this.#scanner.peek();
|
|
6025
6230
|
} else if (ch === EXCLAMATION) {
|
|
6026
6231
|
isNamed = true;
|
|
6027
6232
|
tagHandle = "!!";
|
|
6028
|
-
|
|
6233
|
+
this.#scanner.next();
|
|
6234
|
+
ch = this.#scanner.peek();
|
|
6029
6235
|
} else {
|
|
6030
6236
|
tagHandle = "!";
|
|
6031
6237
|
}
|
|
6032
|
-
let position = this.position;
|
|
6238
|
+
let position = this.#scanner.position;
|
|
6033
6239
|
if (isVerbatim) {
|
|
6034
6240
|
do {
|
|
6035
|
-
|
|
6241
|
+
this.#scanner.next();
|
|
6242
|
+
ch = this.#scanner.peek();
|
|
6036
6243
|
} while (ch !== 0 && ch !== GREATER_THAN);
|
|
6037
|
-
if (this.
|
|
6038
|
-
tagName = this.
|
|
6039
|
-
|
|
6244
|
+
if (!this.#scanner.eof()) {
|
|
6245
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
6246
|
+
this.#scanner.next();
|
|
6247
|
+
ch = this.#scanner.peek();
|
|
6040
6248
|
} else {
|
|
6041
6249
|
throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
6042
6250
|
}
|
|
@@ -6044,19 +6252,20 @@ var LoaderState = class {
|
|
|
6044
6252
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
6045
6253
|
if (ch === EXCLAMATION) {
|
|
6046
6254
|
if (!isNamed) {
|
|
6047
|
-
tagHandle = this.
|
|
6255
|
+
tagHandle = this.#scanner.source.slice(position - 1, this.#scanner.position + 1);
|
|
6048
6256
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
6049
6257
|
throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
6050
6258
|
}
|
|
6051
6259
|
isNamed = true;
|
|
6052
|
-
position = this.position + 1;
|
|
6260
|
+
position = this.#scanner.position + 1;
|
|
6053
6261
|
} else {
|
|
6054
6262
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
6055
6263
|
}
|
|
6056
6264
|
}
|
|
6057
|
-
|
|
6265
|
+
this.#scanner.next();
|
|
6266
|
+
ch = this.#scanner.peek();
|
|
6058
6267
|
}
|
|
6059
|
-
tagName = this.
|
|
6268
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
6060
6269
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
6061
6270
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
6062
6271
|
}
|
|
@@ -6076,32 +6285,36 @@ var LoaderState = class {
|
|
|
6076
6285
|
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
6077
6286
|
}
|
|
6078
6287
|
readAnchorProperty(anchor) {
|
|
6079
|
-
let ch = this.peek();
|
|
6288
|
+
let ch = this.#scanner.peek();
|
|
6080
6289
|
if (ch !== AMPERSAND) return;
|
|
6081
6290
|
if (anchor !== null) {
|
|
6082
6291
|
throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
6083
6292
|
}
|
|
6084
|
-
|
|
6085
|
-
|
|
6293
|
+
this.#scanner.next();
|
|
6294
|
+
ch = this.#scanner.peek();
|
|
6295
|
+
const position = this.#scanner.position;
|
|
6086
6296
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
6087
|
-
|
|
6297
|
+
this.#scanner.next();
|
|
6298
|
+
ch = this.#scanner.peek();
|
|
6088
6299
|
}
|
|
6089
|
-
if (this.position === position) {
|
|
6300
|
+
if (this.#scanner.position === position) {
|
|
6090
6301
|
throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
6091
6302
|
}
|
|
6092
|
-
return this.
|
|
6303
|
+
return this.#scanner.source.slice(position, this.#scanner.position);
|
|
6093
6304
|
}
|
|
6094
6305
|
readAlias() {
|
|
6095
|
-
if (this.peek() !== ASTERISK) return;
|
|
6096
|
-
|
|
6097
|
-
|
|
6306
|
+
if (this.#scanner.peek() !== ASTERISK) return;
|
|
6307
|
+
this.#scanner.next();
|
|
6308
|
+
let ch = this.#scanner.peek();
|
|
6309
|
+
const position = this.#scanner.position;
|
|
6098
6310
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
6099
|
-
|
|
6311
|
+
this.#scanner.next();
|
|
6312
|
+
ch = this.#scanner.peek();
|
|
6100
6313
|
}
|
|
6101
|
-
if (this.position === position) {
|
|
6314
|
+
if (this.#scanner.position === position) {
|
|
6102
6315
|
throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
6103
6316
|
}
|
|
6104
|
-
const alias = this.
|
|
6317
|
+
const alias = this.#scanner.source.slice(position, this.#scanner.position);
|
|
6105
6318
|
if (!this.anchorMap.has(alias)) {
|
|
6106
6319
|
throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
6107
6320
|
}
|
|
@@ -6184,7 +6397,7 @@ var LoaderState = class {
|
|
|
6184
6397
|
const cond = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
|
|
6185
6398
|
const flowIndent = cond ? parentIndent : parentIndent + 1;
|
|
6186
6399
|
if (allowBlockCollections) {
|
|
6187
|
-
const blockIndent = this.position - this.lineStart;
|
|
6400
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
6188
6401
|
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
6189
6402
|
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
6190
6403
|
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
@@ -6218,7 +6431,7 @@ var LoaderState = class {
|
|
|
6218
6431
|
return this.resolveTag(plainScalarState);
|
|
6219
6432
|
}
|
|
6220
6433
|
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
6221
|
-
const blockIndent = this.position - this.lineStart;
|
|
6434
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
6222
6435
|
const newState2 = this.readBlockSequence(tag, anchor, blockIndent);
|
|
6223
6436
|
if (newState2) return this.resolveTag(newState2);
|
|
6224
6437
|
}
|
|
@@ -6233,20 +6446,22 @@ var LoaderState = class {
|
|
|
6233
6446
|
readDirectives() {
|
|
6234
6447
|
let hasDirectives = false;
|
|
6235
6448
|
let version = null;
|
|
6236
|
-
let ch = this.peek();
|
|
6449
|
+
let ch = this.#scanner.peek();
|
|
6237
6450
|
while (ch !== 0) {
|
|
6238
6451
|
this.skipSeparationSpace(true, -1);
|
|
6239
|
-
ch = this.peek();
|
|
6452
|
+
ch = this.#scanner.peek();
|
|
6240
6453
|
if (this.lineIndent > 0 || ch !== PERCENT) {
|
|
6241
6454
|
break;
|
|
6242
6455
|
}
|
|
6243
6456
|
hasDirectives = true;
|
|
6244
|
-
|
|
6245
|
-
|
|
6457
|
+
this.#scanner.next();
|
|
6458
|
+
ch = this.#scanner.peek();
|
|
6459
|
+
let position = this.#scanner.position;
|
|
6246
6460
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
6247
|
-
|
|
6461
|
+
this.#scanner.next();
|
|
6462
|
+
ch = this.#scanner.peek();
|
|
6248
6463
|
}
|
|
6249
|
-
const directiveName = this.
|
|
6464
|
+
const directiveName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
6250
6465
|
const directiveArgs = [];
|
|
6251
6466
|
if (directiveName.length < 1) {
|
|
6252
6467
|
throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
@@ -6254,13 +6469,14 @@ var LoaderState = class {
|
|
|
6254
6469
|
while (ch !== 0) {
|
|
6255
6470
|
this.skipWhitespaces();
|
|
6256
6471
|
this.skipComment();
|
|
6257
|
-
ch = this.peek();
|
|
6472
|
+
ch = this.#scanner.peek();
|
|
6258
6473
|
if (isEOL(ch)) break;
|
|
6259
|
-
position = this.position;
|
|
6474
|
+
position = this.#scanner.position;
|
|
6260
6475
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
6261
|
-
|
|
6476
|
+
this.#scanner.next();
|
|
6477
|
+
ch = this.#scanner.peek();
|
|
6262
6478
|
}
|
|
6263
|
-
directiveArgs.push(this.
|
|
6479
|
+
directiveArgs.push(this.#scanner.source.slice(position, this.#scanner.position));
|
|
6264
6480
|
}
|
|
6265
6481
|
if (ch !== 0) this.readLineBreak();
|
|
6266
6482
|
switch (directiveName) {
|
|
@@ -6277,20 +6493,20 @@ var LoaderState = class {
|
|
|
6277
6493
|
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
6278
6494
|
break;
|
|
6279
6495
|
}
|
|
6280
|
-
ch = this.peek();
|
|
6496
|
+
ch = this.#scanner.peek();
|
|
6281
6497
|
}
|
|
6282
6498
|
return hasDirectives;
|
|
6283
6499
|
}
|
|
6284
6500
|
readDocument() {
|
|
6285
|
-
const documentStart = this.position;
|
|
6501
|
+
const documentStart = this.#scanner.position;
|
|
6286
6502
|
this.checkLineBreaks = false;
|
|
6287
6503
|
this.tagMap = /* @__PURE__ */ new Map();
|
|
6288
6504
|
this.anchorMap = /* @__PURE__ */ new Map();
|
|
6289
6505
|
const hasDirectives = this.readDirectives();
|
|
6290
6506
|
this.skipSeparationSpace(true, -1);
|
|
6291
6507
|
let result = null;
|
|
6292
|
-
if (this.lineIndent === 0 && this.peek() === MINUS && this.peek(1) === MINUS && this.peek(2) === MINUS) {
|
|
6293
|
-
this.position += 3;
|
|
6508
|
+
if (this.lineIndent === 0 && this.#scanner.peek() === MINUS && this.#scanner.peek(1) === MINUS && this.#scanner.peek(2) === MINUS) {
|
|
6509
|
+
this.#scanner.position += 3;
|
|
6294
6510
|
this.skipSeparationSpace(true, -1);
|
|
6295
6511
|
} else if (hasDirectives) {
|
|
6296
6512
|
throw this.#createError("Cannot read document: directives end mark is expected");
|
|
@@ -6303,21 +6519,21 @@ var LoaderState = class {
|
|
|
6303
6519
|
});
|
|
6304
6520
|
if (newState) result = newState.result;
|
|
6305
6521
|
this.skipSeparationSpace(true, -1);
|
|
6306
|
-
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.
|
|
6522
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.#scanner.source.slice(documentStart, this.#scanner.position))) {
|
|
6307
6523
|
this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
6308
6524
|
}
|
|
6309
|
-
if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
6310
|
-
if (this.peek() === DOT) {
|
|
6311
|
-
this.position += 3;
|
|
6525
|
+
if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
6526
|
+
if (this.#scanner.peek() === DOT) {
|
|
6527
|
+
this.#scanner.position += 3;
|
|
6312
6528
|
this.skipSeparationSpace(true, -1);
|
|
6313
6529
|
}
|
|
6314
|
-
} else if (this.
|
|
6530
|
+
} else if (!this.#scanner.eof()) {
|
|
6315
6531
|
throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
6316
6532
|
}
|
|
6317
6533
|
return result;
|
|
6318
6534
|
}
|
|
6319
6535
|
*readDocuments() {
|
|
6320
|
-
while (this.
|
|
6536
|
+
while (!this.#scanner.eof()) {
|
|
6321
6537
|
yield this.readDocument();
|
|
6322
6538
|
}
|
|
6323
6539
|
}
|
|
@@ -6330,7 +6546,6 @@ function sanitizeInput(input) {
|
|
|
6330
6546
|
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
6331
6547
|
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
6332
6548
|
}
|
|
6333
|
-
input += "\0";
|
|
6334
6549
|
return input;
|
|
6335
6550
|
}
|
|
6336
6551
|
function parse(content, options = {}) {
|
|
@@ -6348,10 +6563,10 @@ function parse(content, options = {}) {
|
|
|
6348
6563
|
}
|
|
6349
6564
|
|
|
6350
6565
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
|
|
6351
|
-
import
|
|
6566
|
+
import process3 from "node:process";
|
|
6352
6567
|
function replaceEnvVars(str2) {
|
|
6353
6568
|
return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
|
|
6354
|
-
const value =
|
|
6569
|
+
const value = process3.env[varName];
|
|
6355
6570
|
if (value !== void 0) {
|
|
6356
6571
|
return value;
|
|
6357
6572
|
}
|
|
@@ -6450,18 +6665,19 @@ var defaultPlugin = markdownLoaderPlugin();
|
|
|
6450
6665
|
|
|
6451
6666
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
6452
6667
|
import { resolve as resolve3 } from "node:path";
|
|
6453
|
-
import
|
|
6668
|
+
import process4 from "node:process";
|
|
6454
6669
|
var DEFAULT_SKILLS_PATHS = [
|
|
6455
6670
|
".agent/skills"
|
|
6456
6671
|
];
|
|
6457
6672
|
var DEFAULT_CODE_EXECUTION_TIMEOUT = 3e5;
|
|
6458
6673
|
function getGlobalPlugins(skillsPaths) {
|
|
6459
|
-
const resolvedPaths = skillsPaths.map((p2) => resolve3(
|
|
6674
|
+
const resolvedPaths = skillsPaths.map((p2) => resolve3(process4.cwd(), p2));
|
|
6460
6675
|
return [
|
|
6461
6676
|
markdownLoaderPlugin(),
|
|
6462
6677
|
createSkillsPlugin({
|
|
6463
6678
|
paths: resolvedPaths
|
|
6464
|
-
})
|
|
6679
|
+
}),
|
|
6680
|
+
createBashPlugin()
|
|
6465
6681
|
];
|
|
6466
6682
|
}
|
|
6467
6683
|
function getAgentPlugins() {
|
|
@@ -6490,7 +6706,7 @@ function getDefaultAgents() {
|
|
|
6490
6706
|
}
|
|
6491
6707
|
|
|
6492
6708
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/config/loader.js
|
|
6493
|
-
var CLI_VERSION = "0.1.
|
|
6709
|
+
var CLI_VERSION = "0.1.52";
|
|
6494
6710
|
function extractServerName(command, commandArgs) {
|
|
6495
6711
|
for (const arg of commandArgs) {
|
|
6496
6712
|
if (!arg.startsWith("-")) {
|
|
@@ -6550,7 +6766,7 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
6550
6766
|
async function createWrapConfig(args) {
|
|
6551
6767
|
if (!args.mcpServers || args.mcpServers.length === 0) {
|
|
6552
6768
|
console.error("Error: --wrap/--add requires at least one MCP server\nExample: mcpc --wrap --mcp-stdio 'npx -y @wonderwhy-er/desktop-commander'\nMultiple: mcpc --add --mcp-stdio 'npx -y server1' --mcp-http 'https://api.example.com'");
|
|
6553
|
-
|
|
6769
|
+
process5.exit(1);
|
|
6554
6770
|
}
|
|
6555
6771
|
const mcpServers = {};
|
|
6556
6772
|
const serverNames = [];
|
|
@@ -6673,7 +6889,7 @@ function parseMcpServer(cmdString, transportType) {
|
|
|
6673
6889
|
};
|
|
6674
6890
|
}
|
|
6675
6891
|
function parseCLIArgs() {
|
|
6676
|
-
const args = parseArgs(
|
|
6892
|
+
const args = parseArgs(process5.argv.slice(2), {
|
|
6677
6893
|
boolean: [
|
|
6678
6894
|
"help",
|
|
6679
6895
|
"version",
|
|
@@ -6762,15 +6978,15 @@ async function loadConfig() {
|
|
|
6762
6978
|
const args = parseCLIArgs();
|
|
6763
6979
|
if (args.version) {
|
|
6764
6980
|
printVersion();
|
|
6765
|
-
|
|
6981
|
+
process5.exit(0);
|
|
6766
6982
|
}
|
|
6767
6983
|
if (args.help) {
|
|
6768
6984
|
printHelp();
|
|
6769
|
-
|
|
6985
|
+
process5.exit(0);
|
|
6770
6986
|
}
|
|
6771
6987
|
if (args.cwd) {
|
|
6772
|
-
const targetCwd = resolve4(
|
|
6773
|
-
|
|
6988
|
+
const targetCwd = resolve4(process5.cwd(), args.cwd);
|
|
6989
|
+
process5.chdir(targetCwd);
|
|
6774
6990
|
console.error(`Changed working directory to: ${targetCwd}`);
|
|
6775
6991
|
}
|
|
6776
6992
|
const mergeSkills = (config) => {
|
|
@@ -6782,7 +6998,7 @@ async function loadConfig() {
|
|
|
6782
6998
|
...args,
|
|
6783
6999
|
saveConfig: true
|
|
6784
7000
|
});
|
|
6785
|
-
|
|
7001
|
+
process5.exit(0);
|
|
6786
7002
|
}
|
|
6787
7003
|
if (args.wrap) {
|
|
6788
7004
|
return mergeSkills(await createWrapConfig({
|
|
@@ -6799,16 +7015,16 @@ async function loadConfig() {
|
|
|
6799
7015
|
throw error;
|
|
6800
7016
|
}
|
|
6801
7017
|
}
|
|
6802
|
-
if (
|
|
7018
|
+
if (process5.env.MCPC_CONFIG) {
|
|
6803
7019
|
try {
|
|
6804
|
-
const parsed = JSON.parse(
|
|
7020
|
+
const parsed = JSON.parse(process5.env.MCPC_CONFIG);
|
|
6805
7021
|
return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
|
|
6806
7022
|
} catch (error) {
|
|
6807
7023
|
console.error("Failed to parse MCPC_CONFIG environment variable:", error);
|
|
6808
7024
|
throw error;
|
|
6809
7025
|
}
|
|
6810
7026
|
}
|
|
6811
|
-
const configUrl = args.configUrl ||
|
|
7027
|
+
const configUrl = args.configUrl || process5.env.MCPC_CONFIG_URL;
|
|
6812
7028
|
if (configUrl) {
|
|
6813
7029
|
try {
|
|
6814
7030
|
const headers = {
|
|
@@ -6829,7 +7045,7 @@ async function loadConfig() {
|
|
|
6829
7045
|
throw error;
|
|
6830
7046
|
}
|
|
6831
7047
|
}
|
|
6832
|
-
const configFile = args.configFile ||
|
|
7048
|
+
const configFile = args.configFile || process5.env.MCPC_CONFIG_FILE;
|
|
6833
7049
|
if (configFile) {
|
|
6834
7050
|
try {
|
|
6835
7051
|
const config = await loadConfigFromFile(configFile);
|
|
@@ -6854,7 +7070,7 @@ async function loadConfig() {
|
|
|
6854
7070
|
throw error;
|
|
6855
7071
|
}
|
|
6856
7072
|
}
|
|
6857
|
-
const defaultJsonConfigPath = resolve4(
|
|
7073
|
+
const defaultJsonConfigPath = resolve4(process5.cwd(), "mcpc.config.json");
|
|
6858
7074
|
try {
|
|
6859
7075
|
const config = await loadConfigFromFile(defaultJsonConfigPath);
|
|
6860
7076
|
return mergeSkills(applyModeOverride(config, args.mode));
|
|
@@ -6869,7 +7085,7 @@ async function loadConfig() {
|
|
|
6869
7085
|
}
|
|
6870
7086
|
function replaceEnvVars2(str2) {
|
|
6871
7087
|
return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
|
|
6872
|
-
return
|
|
7088
|
+
return process5.env[varName] || "";
|
|
6873
7089
|
});
|
|
6874
7090
|
}
|
|
6875
7091
|
function isMarkdownFile2(path) {
|
|
@@ -8160,6 +8376,147 @@ var ExperimentalServerTasks = class {
|
|
|
8160
8376
|
requestStream(request, resultSchema, options) {
|
|
8161
8377
|
return this._server.requestStream(request, resultSchema, options);
|
|
8162
8378
|
}
|
|
8379
|
+
/**
|
|
8380
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
8381
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
8382
|
+
*
|
|
8383
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
8384
|
+
* before the final result.
|
|
8385
|
+
*
|
|
8386
|
+
* @example
|
|
8387
|
+
* ```typescript
|
|
8388
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
8389
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
8390
|
+
* maxTokens: 100
|
|
8391
|
+
* }, {
|
|
8392
|
+
* onprogress: (progress) => {
|
|
8393
|
+
* // Handle streaming tokens via progress notifications
|
|
8394
|
+
* console.log('Progress:', progress.message);
|
|
8395
|
+
* }
|
|
8396
|
+
* });
|
|
8397
|
+
*
|
|
8398
|
+
* for await (const message of stream) {
|
|
8399
|
+
* switch (message.type) {
|
|
8400
|
+
* case 'taskCreated':
|
|
8401
|
+
* console.log('Task created:', message.task.taskId);
|
|
8402
|
+
* break;
|
|
8403
|
+
* case 'taskStatus':
|
|
8404
|
+
* console.log('Task status:', message.task.status);
|
|
8405
|
+
* break;
|
|
8406
|
+
* case 'result':
|
|
8407
|
+
* console.log('Final result:', message.result);
|
|
8408
|
+
* break;
|
|
8409
|
+
* case 'error':
|
|
8410
|
+
* console.error('Error:', message.error);
|
|
8411
|
+
* break;
|
|
8412
|
+
* }
|
|
8413
|
+
* }
|
|
8414
|
+
* ```
|
|
8415
|
+
*
|
|
8416
|
+
* @param params - The sampling request parameters
|
|
8417
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
8418
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
8419
|
+
*
|
|
8420
|
+
* @experimental
|
|
8421
|
+
*/
|
|
8422
|
+
createMessageStream(params, options) {
|
|
8423
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
8424
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
8425
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
8426
|
+
}
|
|
8427
|
+
if (params.messages.length > 0) {
|
|
8428
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
8429
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
8430
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
8431
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
8432
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
8433
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
8434
|
+
if (hasToolResults) {
|
|
8435
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
8436
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
8437
|
+
}
|
|
8438
|
+
if (!hasPreviousToolUse) {
|
|
8439
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
8440
|
+
}
|
|
8441
|
+
}
|
|
8442
|
+
if (hasPreviousToolUse) {
|
|
8443
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
8444
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
8445
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
8446
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
8447
|
+
}
|
|
8448
|
+
}
|
|
8449
|
+
}
|
|
8450
|
+
return this.requestStream({
|
|
8451
|
+
method: "sampling/createMessage",
|
|
8452
|
+
params
|
|
8453
|
+
}, CreateMessageResultSchema, options);
|
|
8454
|
+
}
|
|
8455
|
+
/**
|
|
8456
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
8457
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
8458
|
+
*
|
|
8459
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
8460
|
+
* and 'taskStatus' messages before the final result.
|
|
8461
|
+
*
|
|
8462
|
+
* @example
|
|
8463
|
+
* ```typescript
|
|
8464
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
8465
|
+
* mode: 'url',
|
|
8466
|
+
* message: 'Please authenticate',
|
|
8467
|
+
* elicitationId: 'auth-123',
|
|
8468
|
+
* url: 'https://example.com/auth'
|
|
8469
|
+
* }, {
|
|
8470
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
8471
|
+
* });
|
|
8472
|
+
*
|
|
8473
|
+
* for await (const message of stream) {
|
|
8474
|
+
* switch (message.type) {
|
|
8475
|
+
* case 'taskCreated':
|
|
8476
|
+
* console.log('Task created:', message.task.taskId);
|
|
8477
|
+
* break;
|
|
8478
|
+
* case 'taskStatus':
|
|
8479
|
+
* console.log('Task status:', message.task.status);
|
|
8480
|
+
* break;
|
|
8481
|
+
* case 'result':
|
|
8482
|
+
* console.log('User action:', message.result.action);
|
|
8483
|
+
* break;
|
|
8484
|
+
* case 'error':
|
|
8485
|
+
* console.error('Error:', message.error);
|
|
8486
|
+
* break;
|
|
8487
|
+
* }
|
|
8488
|
+
* }
|
|
8489
|
+
* ```
|
|
8490
|
+
*
|
|
8491
|
+
* @param params - The elicitation request parameters
|
|
8492
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
8493
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
8494
|
+
*
|
|
8495
|
+
* @experimental
|
|
8496
|
+
*/
|
|
8497
|
+
elicitInputStream(params, options) {
|
|
8498
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
8499
|
+
const mode = params.mode ?? "form";
|
|
8500
|
+
switch (mode) {
|
|
8501
|
+
case "url": {
|
|
8502
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
8503
|
+
throw new Error("Client does not support url elicitation.");
|
|
8504
|
+
}
|
|
8505
|
+
break;
|
|
8506
|
+
}
|
|
8507
|
+
case "form": {
|
|
8508
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
8509
|
+
throw new Error("Client does not support form elicitation.");
|
|
8510
|
+
}
|
|
8511
|
+
break;
|
|
8512
|
+
}
|
|
8513
|
+
}
|
|
8514
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
8515
|
+
return this.requestStream({
|
|
8516
|
+
method: "elicitation/create",
|
|
8517
|
+
params: normalizedParams
|
|
8518
|
+
}, ElicitResultSchema, options);
|
|
8519
|
+
}
|
|
8163
8520
|
/**
|
|
8164
8521
|
* Gets the current status of a task.
|
|
8165
8522
|
*
|
|
@@ -9359,7 +9716,7 @@ var Client = class extends Protocol {
|
|
|
9359
9716
|
|
|
9360
9717
|
// __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
|
|
9361
9718
|
var import_cross_spawn = __toESM(require_cross_spawn(), 1);
|
|
9362
|
-
import
|
|
9719
|
+
import process6 from "node:process";
|
|
9363
9720
|
import { PassThrough } from "node:stream";
|
|
9364
9721
|
|
|
9365
9722
|
// __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
@@ -9391,7 +9748,7 @@ function serializeMessage(message) {
|
|
|
9391
9748
|
}
|
|
9392
9749
|
|
|
9393
9750
|
// __mcpc__cli_latest/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js
|
|
9394
|
-
var DEFAULT_INHERITED_ENV_VARS =
|
|
9751
|
+
var DEFAULT_INHERITED_ENV_VARS = process6.platform === "win32" ? [
|
|
9395
9752
|
"APPDATA",
|
|
9396
9753
|
"HOMEDRIVE",
|
|
9397
9754
|
"HOMEPATH",
|
|
@@ -9411,7 +9768,7 @@ var DEFAULT_INHERITED_ENV_VARS = process5.platform === "win32" ? [
|
|
|
9411
9768
|
function getDefaultEnvironment() {
|
|
9412
9769
|
const env = {};
|
|
9413
9770
|
for (const key of DEFAULT_INHERITED_ENV_VARS) {
|
|
9414
|
-
const value =
|
|
9771
|
+
const value = process6.env[key];
|
|
9415
9772
|
if (value === void 0) {
|
|
9416
9773
|
continue;
|
|
9417
9774
|
}
|
|
@@ -9447,7 +9804,7 @@ var StdioClientTransport = class {
|
|
|
9447
9804
|
},
|
|
9448
9805
|
stdio: ["pipe", "pipe", this._serverParams.stderr ?? "inherit"],
|
|
9449
9806
|
shell: false,
|
|
9450
|
-
windowsHide:
|
|
9807
|
+
windowsHide: process6.platform === "win32" && isElectron(),
|
|
9451
9808
|
cwd: this._serverParams.cwd
|
|
9452
9809
|
});
|
|
9453
9810
|
this._process.on("error", (error) => {
|
|
@@ -9555,7 +9912,7 @@ var StdioClientTransport = class {
|
|
|
9555
9912
|
}
|
|
9556
9913
|
};
|
|
9557
9914
|
function isElectron() {
|
|
9558
|
-
return "type" in
|
|
9915
|
+
return "type" in process6;
|
|
9559
9916
|
}
|
|
9560
9917
|
|
|
9561
9918
|
// __mcpc__cli_latest/node_modules/eventsource-parser/dist/index.js
|
|
@@ -10378,22 +10735,45 @@ async function auth(provider, options) {
|
|
|
10378
10735
|
}
|
|
10379
10736
|
}
|
|
10380
10737
|
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
10738
|
+
const cachedState = await provider.discoveryState?.();
|
|
10381
10739
|
let resourceMetadata;
|
|
10382
10740
|
let authorizationServerUrl;
|
|
10383
|
-
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10741
|
+
let metadata;
|
|
10742
|
+
let effectiveResourceMetadataUrl = resourceMetadataUrl;
|
|
10743
|
+
if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl) {
|
|
10744
|
+
effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl);
|
|
10745
|
+
}
|
|
10746
|
+
if (cachedState?.authorizationServerUrl) {
|
|
10747
|
+
authorizationServerUrl = cachedState.authorizationServerUrl;
|
|
10748
|
+
resourceMetadata = cachedState.resourceMetadata;
|
|
10749
|
+
metadata = cachedState.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn });
|
|
10750
|
+
if (!resourceMetadata) {
|
|
10751
|
+
try {
|
|
10752
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
|
|
10753
|
+
} catch {
|
|
10754
|
+
}
|
|
10387
10755
|
}
|
|
10388
|
-
|
|
10389
|
-
|
|
10390
|
-
|
|
10391
|
-
|
|
10756
|
+
if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
|
|
10757
|
+
await provider.saveDiscoveryState?.({
|
|
10758
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
10759
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
10760
|
+
resourceMetadata,
|
|
10761
|
+
authorizationServerMetadata: metadata
|
|
10762
|
+
});
|
|
10763
|
+
}
|
|
10764
|
+
} else {
|
|
10765
|
+
const serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
|
|
10766
|
+
authorizationServerUrl = serverInfo.authorizationServerUrl;
|
|
10767
|
+
metadata = serverInfo.authorizationServerMetadata;
|
|
10768
|
+
resourceMetadata = serverInfo.resourceMetadata;
|
|
10769
|
+
await provider.saveDiscoveryState?.({
|
|
10770
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
10771
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
10772
|
+
resourceMetadata,
|
|
10773
|
+
authorizationServerMetadata: metadata
|
|
10774
|
+
});
|
|
10392
10775
|
}
|
|
10393
10776
|
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
10394
|
-
const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, {
|
|
10395
|
-
fetchFn
|
|
10396
|
-
});
|
|
10397
10777
|
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
10398
10778
|
if (!clientInformation) {
|
|
10399
10779
|
if (authorizationCode !== void 0) {
|
|
@@ -10648,6 +11028,26 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
10648
11028
|
}
|
|
10649
11029
|
return void 0;
|
|
10650
11030
|
}
|
|
11031
|
+
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
11032
|
+
let resourceMetadata;
|
|
11033
|
+
let authorizationServerUrl;
|
|
11034
|
+
try {
|
|
11035
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
|
|
11036
|
+
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
11037
|
+
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
11038
|
+
}
|
|
11039
|
+
} catch {
|
|
11040
|
+
}
|
|
11041
|
+
if (!authorizationServerUrl) {
|
|
11042
|
+
authorizationServerUrl = String(new URL("/", serverUrl));
|
|
11043
|
+
}
|
|
11044
|
+
const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
11045
|
+
return {
|
|
11046
|
+
authorizationServerUrl,
|
|
11047
|
+
authorizationServerMetadata,
|
|
11048
|
+
resourceMetadata
|
|
11049
|
+
};
|
|
11050
|
+
}
|
|
10651
11051
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
10652
11052
|
let authorizationUrl;
|
|
10653
11053
|
if (metadata) {
|
|
@@ -11436,8 +11836,8 @@ var InMemoryTransport = class _InMemoryTransport {
|
|
|
11436
11836
|
};
|
|
11437
11837
|
|
|
11438
11838
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/config.js
|
|
11439
|
-
import
|
|
11440
|
-
var GEMINI_PREFERRED_FORMAT =
|
|
11839
|
+
import process7 from "node:process";
|
|
11840
|
+
var GEMINI_PREFERRED_FORMAT = process7.env.GEMINI_PREFERRED_FORMAT === "0" ? false : true;
|
|
11441
11841
|
|
|
11442
11842
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/json.js
|
|
11443
11843
|
import { jsonrepair as jsonrepair2 } from "jsonrepair";
|
|
@@ -11510,20 +11910,8 @@ var cleanToolSchema = (schema) => {
|
|
|
11510
11910
|
|
|
11511
11911
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/mcp.js
|
|
11512
11912
|
import { cwd } from "node:process";
|
|
11513
|
-
import
|
|
11913
|
+
import process8 from "node:process";
|
|
11514
11914
|
import { createHash } from "node:crypto";
|
|
11515
|
-
var mcpClientPool = /* @__PURE__ */ new Map();
|
|
11516
|
-
var mcpClientConnecting = /* @__PURE__ */ new Map();
|
|
11517
|
-
var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
|
|
11518
|
-
function defSignature(def) {
|
|
11519
|
-
const defCopy = {
|
|
11520
|
-
...def
|
|
11521
|
-
};
|
|
11522
|
-
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
11523
|
-
return `memory:${Date.now()}:${Math.random()}`;
|
|
11524
|
-
}
|
|
11525
|
-
return JSON.stringify(defCopy);
|
|
11526
|
-
}
|
|
11527
11915
|
function createTransport(def) {
|
|
11528
11916
|
const defAny = def;
|
|
11529
11917
|
const explicitType = defAny.transportType || defAny.type;
|
|
@@ -11563,7 +11951,7 @@ function createTransport(def) {
|
|
|
11563
11951
|
command: defAny.command,
|
|
11564
11952
|
args: defAny.args,
|
|
11565
11953
|
env: {
|
|
11566
|
-
...
|
|
11954
|
+
...process8.env,
|
|
11567
11955
|
...defAny.env ?? {}
|
|
11568
11956
|
},
|
|
11569
11957
|
cwd: cwd()
|
|
@@ -11571,90 +11959,43 @@ function createTransport(def) {
|
|
|
11571
11959
|
}
|
|
11572
11960
|
throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
|
|
11573
11961
|
}
|
|
11574
|
-
|
|
11575
|
-
const
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
const existingConnecting = mcpClientConnecting.get(defKey);
|
|
11581
|
-
if (existingConnecting) {
|
|
11582
|
-
const client = await existingConnecting;
|
|
11583
|
-
const entry = mcpClientPool.get(defKey);
|
|
11584
|
-
if (entry) entry.refCount += 1;
|
|
11585
|
-
return client;
|
|
11586
|
-
}
|
|
11587
|
-
const transport = createTransport(def);
|
|
11588
|
-
const connecting = (async () => {
|
|
11589
|
-
const client = new Client({
|
|
11590
|
-
name: `mcp_${shortHash(defSignature(def))}`,
|
|
11591
|
-
version: "1.0.0"
|
|
11592
|
-
});
|
|
11593
|
-
await client.connect(transport, {
|
|
11594
|
-
timeout: 6e4 * 10
|
|
11595
|
-
});
|
|
11596
|
-
return client;
|
|
11597
|
-
})();
|
|
11598
|
-
mcpClientConnecting.set(defKey, connecting);
|
|
11599
|
-
try {
|
|
11600
|
-
const client = await connecting;
|
|
11601
|
-
mcpClientPool.set(defKey, {
|
|
11602
|
-
client,
|
|
11603
|
-
refCount: 1
|
|
11604
|
-
});
|
|
11605
|
-
return client;
|
|
11606
|
-
} finally {
|
|
11607
|
-
mcpClientConnecting.delete(defKey);
|
|
11962
|
+
function defSignature(def) {
|
|
11963
|
+
const defCopy = {
|
|
11964
|
+
...def
|
|
11965
|
+
};
|
|
11966
|
+
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
11967
|
+
return `memory:${Date.now()}:${Math.random()}`;
|
|
11608
11968
|
}
|
|
11969
|
+
return JSON.stringify(defCopy);
|
|
11609
11970
|
}
|
|
11610
|
-
|
|
11611
|
-
|
|
11612
|
-
|
|
11613
|
-
|
|
11614
|
-
|
|
11615
|
-
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
}
|
|
11971
|
+
var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
|
|
11972
|
+
async function createMcpClient(def) {
|
|
11973
|
+
const transport = createTransport(def);
|
|
11974
|
+
const client = new Client({
|
|
11975
|
+
name: `mcp_${shortHash(defSignature(def))}`,
|
|
11976
|
+
version: "1.0.0"
|
|
11977
|
+
});
|
|
11978
|
+
await client.connect(transport, {
|
|
11979
|
+
timeout: 6e4 * 10
|
|
11980
|
+
});
|
|
11981
|
+
return client;
|
|
11622
11982
|
}
|
|
11623
|
-
var cleanupAllPooledClients = async () => {
|
|
11624
|
-
const entries = Array.from(mcpClientPool.entries());
|
|
11625
|
-
mcpClientPool.clear();
|
|
11626
|
-
await Promise.all(entries.map(async ([, { client }]) => {
|
|
11627
|
-
try {
|
|
11628
|
-
await client.close();
|
|
11629
|
-
} catch (err) {
|
|
11630
|
-
console.error("Error closing MCP client:", err);
|
|
11631
|
-
}
|
|
11632
|
-
}));
|
|
11633
|
-
};
|
|
11634
|
-
process7.once?.("exit", () => {
|
|
11635
|
-
cleanupAllPooledClients();
|
|
11636
|
-
});
|
|
11637
|
-
process7.once?.("SIGINT", () => {
|
|
11638
|
-
cleanupAllPooledClients().finally(() => process7.exit(0));
|
|
11639
|
-
});
|
|
11640
11983
|
async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
11641
11984
|
const allTools = {};
|
|
11642
11985
|
const allClients = {};
|
|
11643
|
-
const
|
|
11986
|
+
const clientsToClose = [];
|
|
11644
11987
|
for (const [name, definition] of Object.entries(mcpConfig.mcpServers)) {
|
|
11645
11988
|
const def = definition;
|
|
11646
11989
|
if (def.disabled) continue;
|
|
11647
|
-
const defKey = shortHash(defSignature(def));
|
|
11648
|
-
const serverId = name;
|
|
11649
11990
|
try {
|
|
11650
|
-
const client = await
|
|
11651
|
-
|
|
11652
|
-
allClients[
|
|
11991
|
+
const client = await createMcpClient(def);
|
|
11992
|
+
clientsToClose.push(client);
|
|
11993
|
+
allClients[name] = client;
|
|
11653
11994
|
const { tools } = await client.listTools();
|
|
11654
11995
|
tools.forEach((tool2) => {
|
|
11655
11996
|
const toolNameWithScope = `${name}.${tool2.name}`;
|
|
11656
11997
|
const internalToolName = tool2.name;
|
|
11657
|
-
const rawToolId = `${
|
|
11998
|
+
const rawToolId = `${name}_${internalToolName}`;
|
|
11658
11999
|
const toolId = sanitizePropertyKey(rawToolId);
|
|
11659
12000
|
if (filterIn && !filterIn({
|
|
11660
12001
|
action: internalToolName,
|
|
@@ -11666,7 +12007,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
11666
12007
|
})) {
|
|
11667
12008
|
return;
|
|
11668
12009
|
}
|
|
11669
|
-
const execute = (args) => allClients[
|
|
12010
|
+
const execute = (args) => allClients[name].callTool({
|
|
11670
12011
|
name: internalToolName,
|
|
11671
12012
|
arguments: args
|
|
11672
12013
|
}, void 0, {
|
|
@@ -11683,10 +12024,12 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
11683
12024
|
}
|
|
11684
12025
|
}
|
|
11685
12026
|
const cleanupClients = async () => {
|
|
11686
|
-
await Promise.all(
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
12027
|
+
await Promise.all(clientsToClose.map((client) => {
|
|
12028
|
+
try {
|
|
12029
|
+
return client.close();
|
|
12030
|
+
} catch {
|
|
12031
|
+
}
|
|
12032
|
+
}));
|
|
11690
12033
|
};
|
|
11691
12034
|
return {
|
|
11692
12035
|
tools: allTools,
|
|
@@ -12258,7 +12601,7 @@ function endSpan(span, error) {
|
|
|
12258
12601
|
}
|
|
12259
12602
|
|
|
12260
12603
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/executors/agentic/agentic-executor.js
|
|
12261
|
-
import
|
|
12604
|
+
import process9 from "node:process";
|
|
12262
12605
|
var AgenticExecutor = class {
|
|
12263
12606
|
name;
|
|
12264
12607
|
allToolNames;
|
|
@@ -12278,13 +12621,13 @@ var AgenticExecutor = class {
|
|
|
12278
12621
|
this.logger = createLogger(`mcpc.agentic.${name}`, server);
|
|
12279
12622
|
this.toolSchemaMap = new Map(toolNameToDetailList);
|
|
12280
12623
|
try {
|
|
12281
|
-
this.tracingEnabled =
|
|
12624
|
+
this.tracingEnabled = process9.env.MCPC_TRACING_ENABLED === "true";
|
|
12282
12625
|
if (this.tracingEnabled) {
|
|
12283
12626
|
initializeTracing({
|
|
12284
12627
|
enabled: true,
|
|
12285
12628
|
serviceName: `mcpc-agentic-${name}`,
|
|
12286
|
-
exportTo:
|
|
12287
|
-
otlpEndpoint:
|
|
12629
|
+
exportTo: process9.env.MCPC_TRACING_EXPORT ?? "otlp",
|
|
12630
|
+
otlpEndpoint: process9.env.MCPC_TRACING_OTLP_ENDPOINT ?? "http://localhost:4318/v1/traces"
|
|
12288
12631
|
});
|
|
12289
12632
|
}
|
|
12290
12633
|
} catch {
|
|
@@ -14998,12 +15341,12 @@ var ComposableMCPServer = class extends Server {
|
|
|
14998
15341
|
};
|
|
14999
15342
|
|
|
15000
15343
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/utils/common/env.js
|
|
15001
|
-
import
|
|
15002
|
-
var isSCF = () => Boolean(
|
|
15344
|
+
import process10 from "node:process";
|
|
15345
|
+
var isSCF = () => Boolean(process10.env.SCF_RUNTIME || process10.env.PROD_SCF);
|
|
15003
15346
|
if (isSCF()) {
|
|
15004
15347
|
console.log({
|
|
15005
15348
|
isSCF: isSCF(),
|
|
15006
|
-
SCF_RUNTIME:
|
|
15349
|
+
SCF_RUNTIME: process10.env.SCF_RUNTIME
|
|
15007
15350
|
});
|
|
15008
15351
|
}
|
|
15009
15352
|
|
|
@@ -15085,8 +15428,8 @@ var createApp = (config) => {
|
|
|
15085
15428
|
};
|
|
15086
15429
|
|
|
15087
15430
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/server.ts
|
|
15088
|
-
import
|
|
15089
|
-
var port = Number(
|
|
15431
|
+
import process11 from "node:process";
|
|
15432
|
+
var port = Number(process11.env.PORT || "3002");
|
|
15090
15433
|
var hostname = "0.0.0.0";
|
|
15091
15434
|
async function main() {
|
|
15092
15435
|
const config = await loadConfig();
|