@mcpc-tech/cli 0.1.49 → 0.1.51
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 +463 -267
- package/app.mjs +465 -267
- package/bin/mcpc.cjs +443 -265
- package/bin/mcpc.mjs +443 -265
- package/bin.cjs +443 -265
- package/bin.mjs +445 -265
- package/index.cjs +463 -267
- package/index.mjs +465 -267
- package/package.json +1 -1
- package/server.cjs +463 -267
- package/server.mjs +465 -267
package/app.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
1
3
|
var __create = Object.create;
|
|
2
4
|
var __defProp = Object.defineProperty;
|
|
3
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3494,6 +3496,147 @@ var ExperimentalServerTasks = class {
|
|
|
3494
3496
|
requestStream(request, resultSchema, options) {
|
|
3495
3497
|
return this._server.requestStream(request, resultSchema, options);
|
|
3496
3498
|
}
|
|
3499
|
+
/**
|
|
3500
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
3501
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
3502
|
+
*
|
|
3503
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
3504
|
+
* before the final result.
|
|
3505
|
+
*
|
|
3506
|
+
* @example
|
|
3507
|
+
* ```typescript
|
|
3508
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
3509
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
3510
|
+
* maxTokens: 100
|
|
3511
|
+
* }, {
|
|
3512
|
+
* onprogress: (progress) => {
|
|
3513
|
+
* // Handle streaming tokens via progress notifications
|
|
3514
|
+
* console.log('Progress:', progress.message);
|
|
3515
|
+
* }
|
|
3516
|
+
* });
|
|
3517
|
+
*
|
|
3518
|
+
* for await (const message of stream) {
|
|
3519
|
+
* switch (message.type) {
|
|
3520
|
+
* case 'taskCreated':
|
|
3521
|
+
* console.log('Task created:', message.task.taskId);
|
|
3522
|
+
* break;
|
|
3523
|
+
* case 'taskStatus':
|
|
3524
|
+
* console.log('Task status:', message.task.status);
|
|
3525
|
+
* break;
|
|
3526
|
+
* case 'result':
|
|
3527
|
+
* console.log('Final result:', message.result);
|
|
3528
|
+
* break;
|
|
3529
|
+
* case 'error':
|
|
3530
|
+
* console.error('Error:', message.error);
|
|
3531
|
+
* break;
|
|
3532
|
+
* }
|
|
3533
|
+
* }
|
|
3534
|
+
* ```
|
|
3535
|
+
*
|
|
3536
|
+
* @param params - The sampling request parameters
|
|
3537
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
3538
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
3539
|
+
*
|
|
3540
|
+
* @experimental
|
|
3541
|
+
*/
|
|
3542
|
+
createMessageStream(params, options) {
|
|
3543
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
3544
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
3545
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
3546
|
+
}
|
|
3547
|
+
if (params.messages.length > 0) {
|
|
3548
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
3549
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
3550
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
3551
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
3552
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
3553
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
3554
|
+
if (hasToolResults) {
|
|
3555
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
3556
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
3557
|
+
}
|
|
3558
|
+
if (!hasPreviousToolUse) {
|
|
3559
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
if (hasPreviousToolUse) {
|
|
3563
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
3564
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
3565
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
3566
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
return this.requestStream({
|
|
3571
|
+
method: "sampling/createMessage",
|
|
3572
|
+
params
|
|
3573
|
+
}, CreateMessageResultSchema, options);
|
|
3574
|
+
}
|
|
3575
|
+
/**
|
|
3576
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
3577
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
3578
|
+
*
|
|
3579
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
3580
|
+
* and 'taskStatus' messages before the final result.
|
|
3581
|
+
*
|
|
3582
|
+
* @example
|
|
3583
|
+
* ```typescript
|
|
3584
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
3585
|
+
* mode: 'url',
|
|
3586
|
+
* message: 'Please authenticate',
|
|
3587
|
+
* elicitationId: 'auth-123',
|
|
3588
|
+
* url: 'https://example.com/auth'
|
|
3589
|
+
* }, {
|
|
3590
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
3591
|
+
* });
|
|
3592
|
+
*
|
|
3593
|
+
* for await (const message of stream) {
|
|
3594
|
+
* switch (message.type) {
|
|
3595
|
+
* case 'taskCreated':
|
|
3596
|
+
* console.log('Task created:', message.task.taskId);
|
|
3597
|
+
* break;
|
|
3598
|
+
* case 'taskStatus':
|
|
3599
|
+
* console.log('Task status:', message.task.status);
|
|
3600
|
+
* break;
|
|
3601
|
+
* case 'result':
|
|
3602
|
+
* console.log('User action:', message.result.action);
|
|
3603
|
+
* break;
|
|
3604
|
+
* case 'error':
|
|
3605
|
+
* console.error('Error:', message.error);
|
|
3606
|
+
* break;
|
|
3607
|
+
* }
|
|
3608
|
+
* }
|
|
3609
|
+
* ```
|
|
3610
|
+
*
|
|
3611
|
+
* @param params - The elicitation request parameters
|
|
3612
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
3613
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
3614
|
+
*
|
|
3615
|
+
* @experimental
|
|
3616
|
+
*/
|
|
3617
|
+
elicitInputStream(params, options) {
|
|
3618
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
3619
|
+
const mode = params.mode ?? "form";
|
|
3620
|
+
switch (mode) {
|
|
3621
|
+
case "url": {
|
|
3622
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
3623
|
+
throw new Error("Client does not support url elicitation.");
|
|
3624
|
+
}
|
|
3625
|
+
break;
|
|
3626
|
+
}
|
|
3627
|
+
case "form": {
|
|
3628
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
3629
|
+
throw new Error("Client does not support form elicitation.");
|
|
3630
|
+
}
|
|
3631
|
+
break;
|
|
3632
|
+
}
|
|
3633
|
+
}
|
|
3634
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
3635
|
+
return this.requestStream({
|
|
3636
|
+
method: "elicitation/create",
|
|
3637
|
+
params: normalizedParams
|
|
3638
|
+
}, ElicitResultSchema, options);
|
|
3639
|
+
}
|
|
3497
3640
|
/**
|
|
3498
3641
|
* Gets the current status of a task.
|
|
3499
3642
|
*
|
|
@@ -5712,22 +5855,45 @@ async function auth(provider, options) {
|
|
|
5712
5855
|
}
|
|
5713
5856
|
}
|
|
5714
5857
|
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
5858
|
+
const cachedState = await provider.discoveryState?.();
|
|
5715
5859
|
let resourceMetadata;
|
|
5716
5860
|
let authorizationServerUrl;
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5861
|
+
let metadata;
|
|
5862
|
+
let effectiveResourceMetadataUrl = resourceMetadataUrl;
|
|
5863
|
+
if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl) {
|
|
5864
|
+
effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl);
|
|
5865
|
+
}
|
|
5866
|
+
if (cachedState?.authorizationServerUrl) {
|
|
5867
|
+
authorizationServerUrl = cachedState.authorizationServerUrl;
|
|
5868
|
+
resourceMetadata = cachedState.resourceMetadata;
|
|
5869
|
+
metadata = cachedState.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn });
|
|
5870
|
+
if (!resourceMetadata) {
|
|
5871
|
+
try {
|
|
5872
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
|
|
5873
|
+
} catch {
|
|
5874
|
+
}
|
|
5721
5875
|
}
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5876
|
+
if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
|
|
5877
|
+
await provider.saveDiscoveryState?.({
|
|
5878
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
5879
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
5880
|
+
resourceMetadata,
|
|
5881
|
+
authorizationServerMetadata: metadata
|
|
5882
|
+
});
|
|
5883
|
+
}
|
|
5884
|
+
} else {
|
|
5885
|
+
const serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
|
|
5886
|
+
authorizationServerUrl = serverInfo.authorizationServerUrl;
|
|
5887
|
+
metadata = serverInfo.authorizationServerMetadata;
|
|
5888
|
+
resourceMetadata = serverInfo.resourceMetadata;
|
|
5889
|
+
await provider.saveDiscoveryState?.({
|
|
5890
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
5891
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
5892
|
+
resourceMetadata,
|
|
5893
|
+
authorizationServerMetadata: metadata
|
|
5894
|
+
});
|
|
5726
5895
|
}
|
|
5727
5896
|
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
5728
|
-
const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, {
|
|
5729
|
-
fetchFn
|
|
5730
|
-
});
|
|
5731
5897
|
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
5732
5898
|
if (!clientInformation) {
|
|
5733
5899
|
if (authorizationCode !== void 0) {
|
|
@@ -5982,6 +6148,26 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
5982
6148
|
}
|
|
5983
6149
|
return void 0;
|
|
5984
6150
|
}
|
|
6151
|
+
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
6152
|
+
let resourceMetadata;
|
|
6153
|
+
let authorizationServerUrl;
|
|
6154
|
+
try {
|
|
6155
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
|
|
6156
|
+
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
6157
|
+
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
6158
|
+
}
|
|
6159
|
+
} catch {
|
|
6160
|
+
}
|
|
6161
|
+
if (!authorizationServerUrl) {
|
|
6162
|
+
authorizationServerUrl = String(new URL("/", serverUrl));
|
|
6163
|
+
}
|
|
6164
|
+
const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
6165
|
+
return {
|
|
6166
|
+
authorizationServerUrl,
|
|
6167
|
+
authorizationServerMetadata,
|
|
6168
|
+
resourceMetadata
|
|
6169
|
+
};
|
|
6170
|
+
}
|
|
5985
6171
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
5986
6172
|
let authorizationUrl;
|
|
5987
6173
|
if (metadata) {
|
|
@@ -6846,18 +7032,6 @@ var cleanToolSchema = (schema) => {
|
|
|
6846
7032
|
import { cwd } from "node:process";
|
|
6847
7033
|
import process4 from "node:process";
|
|
6848
7034
|
import { createHash } from "node:crypto";
|
|
6849
|
-
var mcpClientPool = /* @__PURE__ */ new Map();
|
|
6850
|
-
var mcpClientConnecting = /* @__PURE__ */ new Map();
|
|
6851
|
-
var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
|
|
6852
|
-
function defSignature(def) {
|
|
6853
|
-
const defCopy = {
|
|
6854
|
-
...def
|
|
6855
|
-
};
|
|
6856
|
-
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
6857
|
-
return `memory:${Date.now()}:${Math.random()}`;
|
|
6858
|
-
}
|
|
6859
|
-
return JSON.stringify(defCopy);
|
|
6860
|
-
}
|
|
6861
7035
|
function createTransport(def) {
|
|
6862
7036
|
const defAny = def;
|
|
6863
7037
|
const explicitType = defAny.transportType || defAny.type;
|
|
@@ -6905,90 +7079,43 @@ function createTransport(def) {
|
|
|
6905
7079
|
}
|
|
6906
7080
|
throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
|
|
6907
7081
|
}
|
|
6908
|
-
|
|
6909
|
-
const
|
|
6910
|
-
|
|
6911
|
-
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
const existingConnecting = mcpClientConnecting.get(defKey);
|
|
6915
|
-
if (existingConnecting) {
|
|
6916
|
-
const client = await existingConnecting;
|
|
6917
|
-
const entry = mcpClientPool.get(defKey);
|
|
6918
|
-
if (entry) entry.refCount += 1;
|
|
6919
|
-
return client;
|
|
6920
|
-
}
|
|
6921
|
-
const transport = createTransport(def);
|
|
6922
|
-
const connecting = (async () => {
|
|
6923
|
-
const client = new Client({
|
|
6924
|
-
name: `mcp_${shortHash(defSignature(def))}`,
|
|
6925
|
-
version: "1.0.0"
|
|
6926
|
-
});
|
|
6927
|
-
await client.connect(transport, {
|
|
6928
|
-
timeout: 6e4 * 10
|
|
6929
|
-
});
|
|
6930
|
-
return client;
|
|
6931
|
-
})();
|
|
6932
|
-
mcpClientConnecting.set(defKey, connecting);
|
|
6933
|
-
try {
|
|
6934
|
-
const client = await connecting;
|
|
6935
|
-
mcpClientPool.set(defKey, {
|
|
6936
|
-
client,
|
|
6937
|
-
refCount: 1
|
|
6938
|
-
});
|
|
6939
|
-
return client;
|
|
6940
|
-
} finally {
|
|
6941
|
-
mcpClientConnecting.delete(defKey);
|
|
7082
|
+
function defSignature(def) {
|
|
7083
|
+
const defCopy = {
|
|
7084
|
+
...def
|
|
7085
|
+
};
|
|
7086
|
+
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
7087
|
+
return `memory:${Date.now()}:${Math.random()}`;
|
|
6942
7088
|
}
|
|
7089
|
+
return JSON.stringify(defCopy);
|
|
6943
7090
|
}
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
}
|
|
7091
|
+
var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
|
|
7092
|
+
async function createMcpClient(def) {
|
|
7093
|
+
const transport = createTransport(def);
|
|
7094
|
+
const client = new Client({
|
|
7095
|
+
name: `mcp_${shortHash(defSignature(def))}`,
|
|
7096
|
+
version: "1.0.0"
|
|
7097
|
+
});
|
|
7098
|
+
await client.connect(transport, {
|
|
7099
|
+
timeout: 6e4 * 10
|
|
7100
|
+
});
|
|
7101
|
+
return client;
|
|
6956
7102
|
}
|
|
6957
|
-
var cleanupAllPooledClients = async () => {
|
|
6958
|
-
const entries = Array.from(mcpClientPool.entries());
|
|
6959
|
-
mcpClientPool.clear();
|
|
6960
|
-
await Promise.all(entries.map(async ([, { client }]) => {
|
|
6961
|
-
try {
|
|
6962
|
-
await client.close();
|
|
6963
|
-
} catch (err) {
|
|
6964
|
-
console.error("Error closing MCP client:", err);
|
|
6965
|
-
}
|
|
6966
|
-
}));
|
|
6967
|
-
};
|
|
6968
|
-
process4.once?.("exit", () => {
|
|
6969
|
-
cleanupAllPooledClients();
|
|
6970
|
-
});
|
|
6971
|
-
process4.once?.("SIGINT", () => {
|
|
6972
|
-
cleanupAllPooledClients().finally(() => process4.exit(0));
|
|
6973
|
-
});
|
|
6974
7103
|
async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
6975
7104
|
const allTools = {};
|
|
6976
7105
|
const allClients = {};
|
|
6977
|
-
const
|
|
7106
|
+
const clientsToClose = [];
|
|
6978
7107
|
for (const [name, definition] of Object.entries(mcpConfig.mcpServers)) {
|
|
6979
7108
|
const def = definition;
|
|
6980
7109
|
if (def.disabled) continue;
|
|
6981
|
-
const defKey = shortHash(defSignature(def));
|
|
6982
|
-
const serverId = name;
|
|
6983
7110
|
try {
|
|
6984
|
-
const client = await
|
|
6985
|
-
|
|
6986
|
-
allClients[
|
|
7111
|
+
const client = await createMcpClient(def);
|
|
7112
|
+
clientsToClose.push(client);
|
|
7113
|
+
allClients[name] = client;
|
|
6987
7114
|
const { tools } = await client.listTools();
|
|
6988
7115
|
tools.forEach((tool2) => {
|
|
6989
7116
|
const toolNameWithScope = `${name}.${tool2.name}`;
|
|
6990
7117
|
const internalToolName = tool2.name;
|
|
6991
|
-
const rawToolId = `${
|
|
7118
|
+
const rawToolId = `${name}_${internalToolName}`;
|
|
6992
7119
|
const toolId = sanitizePropertyKey(rawToolId);
|
|
6993
7120
|
if (filterIn && !filterIn({
|
|
6994
7121
|
action: internalToolName,
|
|
@@ -7000,7 +7127,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
7000
7127
|
})) {
|
|
7001
7128
|
return;
|
|
7002
7129
|
}
|
|
7003
|
-
const execute = (args) => allClients[
|
|
7130
|
+
const execute = (args) => allClients[name].callTool({
|
|
7004
7131
|
name: internalToolName,
|
|
7005
7132
|
arguments: args
|
|
7006
7133
|
}, void 0, {
|
|
@@ -7017,10 +7144,12 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
7017
7144
|
}
|
|
7018
7145
|
}
|
|
7019
7146
|
const cleanupClients = async () => {
|
|
7020
|
-
await Promise.all(
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7147
|
+
await Promise.all(clientsToClose.map((client) => {
|
|
7148
|
+
try {
|
|
7149
|
+
return client.close();
|
|
7150
|
+
} catch {
|
|
7151
|
+
}
|
|
7152
|
+
}));
|
|
7024
7153
|
};
|
|
7025
7154
|
return {
|
|
7026
7155
|
tools: allTools,
|
|
@@ -10776,7 +10905,7 @@ Usage:
|
|
|
10776
10905
|
- ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
|
|
10777
10906
|
- ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
|
|
10778
10907
|
|
|
10779
|
-
Note: For scripts
|
|
10908
|
+
Note: For scripts/, use the bash tool with the script path to execute.`;
|
|
10780
10909
|
}
|
|
10781
10910
|
function createSkillsPlugin(options) {
|
|
10782
10911
|
const { paths } = options;
|
|
@@ -10884,11 +11013,15 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
10884
11013
|
try {
|
|
10885
11014
|
const content = await readFile(join2(meta.basePath, "SKILL.md"), "utf-8");
|
|
10886
11015
|
const body = extractBody(content);
|
|
11016
|
+
const skillPathInfo = `
|
|
11017
|
+
---
|
|
11018
|
+
Skill path: ${meta.basePath}
|
|
11019
|
+
`;
|
|
10887
11020
|
return {
|
|
10888
11021
|
content: [
|
|
10889
11022
|
{
|
|
10890
11023
|
type: "text",
|
|
10891
|
-
text: body
|
|
11024
|
+
text: body + skillPathInfo
|
|
10892
11025
|
}
|
|
10893
11026
|
]
|
|
10894
11027
|
};
|
|
@@ -11759,12 +11892,29 @@ function writeFoldedLines(count) {
|
|
|
11759
11892
|
if (count > 1) return "\n".repeat(count - 1);
|
|
11760
11893
|
return "";
|
|
11761
11894
|
}
|
|
11895
|
+
var Scanner = class {
|
|
11896
|
+
source;
|
|
11897
|
+
#length;
|
|
11898
|
+
position = 0;
|
|
11899
|
+
constructor(source) {
|
|
11900
|
+
source += "\0";
|
|
11901
|
+
this.source = source;
|
|
11902
|
+
this.#length = source.length;
|
|
11903
|
+
}
|
|
11904
|
+
peek(offset = 0) {
|
|
11905
|
+
return this.source.charCodeAt(this.position + offset);
|
|
11906
|
+
}
|
|
11907
|
+
next() {
|
|
11908
|
+
this.position += 1;
|
|
11909
|
+
}
|
|
11910
|
+
eof() {
|
|
11911
|
+
return this.position >= this.#length - 1;
|
|
11912
|
+
}
|
|
11913
|
+
};
|
|
11762
11914
|
var LoaderState = class {
|
|
11763
|
-
|
|
11764
|
-
length;
|
|
11915
|
+
#scanner;
|
|
11765
11916
|
lineIndent = 0;
|
|
11766
11917
|
lineStart = 0;
|
|
11767
|
-
position = 0;
|
|
11768
11918
|
line = 0;
|
|
11769
11919
|
onWarning;
|
|
11770
11920
|
allowDuplicateKeys;
|
|
@@ -11774,44 +11924,40 @@ var LoaderState = class {
|
|
|
11774
11924
|
tagMap = /* @__PURE__ */ new Map();
|
|
11775
11925
|
anchorMap = /* @__PURE__ */ new Map();
|
|
11776
11926
|
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
11777
|
-
this
|
|
11927
|
+
this.#scanner = new Scanner(input);
|
|
11778
11928
|
this.onWarning = onWarning;
|
|
11779
11929
|
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
11780
11930
|
this.implicitTypes = schema.implicitTypes;
|
|
11781
11931
|
this.typeMap = schema.typeMap;
|
|
11782
|
-
this.length = input.length;
|
|
11783
11932
|
this.readIndent();
|
|
11784
11933
|
}
|
|
11785
11934
|
skipWhitespaces() {
|
|
11786
|
-
let ch = this.peek();
|
|
11935
|
+
let ch = this.#scanner.peek();
|
|
11787
11936
|
while (isWhiteSpace(ch)) {
|
|
11788
|
-
|
|
11937
|
+
this.#scanner.next();
|
|
11938
|
+
ch = this.#scanner.peek();
|
|
11789
11939
|
}
|
|
11790
11940
|
}
|
|
11791
11941
|
skipComment() {
|
|
11792
|
-
let ch = this.peek();
|
|
11942
|
+
let ch = this.#scanner.peek();
|
|
11793
11943
|
if (ch !== SHARP) return;
|
|
11794
|
-
|
|
11944
|
+
this.#scanner.next();
|
|
11945
|
+
ch = this.#scanner.peek();
|
|
11795
11946
|
while (ch !== 0 && !isEOL(ch)) {
|
|
11796
|
-
|
|
11947
|
+
this.#scanner.next();
|
|
11948
|
+
ch = this.#scanner.peek();
|
|
11797
11949
|
}
|
|
11798
11950
|
}
|
|
11799
11951
|
readIndent() {
|
|
11800
|
-
let
|
|
11801
|
-
while (
|
|
11952
|
+
let ch = this.#scanner.peek();
|
|
11953
|
+
while (ch === SPACE) {
|
|
11802
11954
|
this.lineIndent += 1;
|
|
11803
|
-
|
|
11955
|
+
this.#scanner.next();
|
|
11956
|
+
ch = this.#scanner.peek();
|
|
11804
11957
|
}
|
|
11805
11958
|
}
|
|
11806
|
-
peek(offset = 0) {
|
|
11807
|
-
return this.input.charCodeAt(this.position + offset);
|
|
11808
|
-
}
|
|
11809
|
-
next() {
|
|
11810
|
-
this.position += 1;
|
|
11811
|
-
return this.peek();
|
|
11812
|
-
}
|
|
11813
11959
|
#createError(message) {
|
|
11814
|
-
const mark = markToString(this.
|
|
11960
|
+
const mark = markToString(this.#scanner.source, this.#scanner.position, this.line, this.#scanner.position - this.lineStart);
|
|
11815
11961
|
return new SyntaxError(`${message} ${mark}`);
|
|
11816
11962
|
}
|
|
11817
11963
|
dispatchWarning(message) {
|
|
@@ -11856,7 +12002,7 @@ var LoaderState = class {
|
|
|
11856
12002
|
}
|
|
11857
12003
|
captureSegment(start, end, checkJson) {
|
|
11858
12004
|
if (start < end) {
|
|
11859
|
-
const result = this.
|
|
12005
|
+
const result = this.#scanner.source.slice(start, end);
|
|
11860
12006
|
if (checkJson) {
|
|
11861
12007
|
for (let position = 0; position < result.length; position++) {
|
|
11862
12008
|
const character = result.charCodeAt(position);
|
|
@@ -11874,21 +12020,21 @@ var LoaderState = class {
|
|
|
11874
12020
|
let detected = false;
|
|
11875
12021
|
const result = [];
|
|
11876
12022
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
11877
|
-
let ch = this.peek();
|
|
12023
|
+
let ch = this.#scanner.peek();
|
|
11878
12024
|
while (ch !== 0) {
|
|
11879
12025
|
if (ch !== MINUS) {
|
|
11880
12026
|
break;
|
|
11881
12027
|
}
|
|
11882
|
-
const following = this.peek(1);
|
|
12028
|
+
const following = this.#scanner.peek(1);
|
|
11883
12029
|
if (!isWhiteSpaceOrEOL(following)) {
|
|
11884
12030
|
break;
|
|
11885
12031
|
}
|
|
11886
12032
|
detected = true;
|
|
11887
|
-
this.
|
|
12033
|
+
this.#scanner.next();
|
|
11888
12034
|
if (this.skipSeparationSpace(true, -1)) {
|
|
11889
12035
|
if (this.lineIndent <= nodeIndent) {
|
|
11890
12036
|
result.push(null);
|
|
11891
|
-
ch = this.peek();
|
|
12037
|
+
ch = this.#scanner.peek();
|
|
11892
12038
|
continue;
|
|
11893
12039
|
}
|
|
11894
12040
|
}
|
|
@@ -11901,7 +12047,7 @@ var LoaderState = class {
|
|
|
11901
12047
|
});
|
|
11902
12048
|
if (newState) result.push(newState.result);
|
|
11903
12049
|
this.skipSeparationSpace(true, -1);
|
|
11904
|
-
ch = this.peek();
|
|
12050
|
+
ch = this.#scanner.peek();
|
|
11905
12051
|
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
|
|
11906
12052
|
throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
11907
12053
|
} else if (this.lineIndent < nodeIndent) {
|
|
@@ -11957,7 +12103,7 @@ var LoaderState = class {
|
|
|
11957
12103
|
} else {
|
|
11958
12104
|
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
11959
12105
|
this.line = startLine || this.line;
|
|
11960
|
-
this.position = startPos || this.position;
|
|
12106
|
+
this.#scanner.position = startPos || this.#scanner.position;
|
|
11961
12107
|
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
11962
12108
|
}
|
|
11963
12109
|
Object.defineProperty(result, keyNode, {
|
|
@@ -11971,37 +12117,37 @@ var LoaderState = class {
|
|
|
11971
12117
|
return result;
|
|
11972
12118
|
}
|
|
11973
12119
|
readLineBreak() {
|
|
11974
|
-
const ch = this.peek();
|
|
12120
|
+
const ch = this.#scanner.peek();
|
|
11975
12121
|
if (ch === LINE_FEED) {
|
|
11976
|
-
this.
|
|
12122
|
+
this.#scanner.next();
|
|
11977
12123
|
} else if (ch === CARRIAGE_RETURN) {
|
|
11978
|
-
this.
|
|
11979
|
-
if (this.peek() === LINE_FEED) {
|
|
11980
|
-
this.
|
|
12124
|
+
this.#scanner.next();
|
|
12125
|
+
if (this.#scanner.peek() === LINE_FEED) {
|
|
12126
|
+
this.#scanner.next();
|
|
11981
12127
|
}
|
|
11982
12128
|
} else {
|
|
11983
12129
|
throw this.#createError("Cannot read line: line break not found");
|
|
11984
12130
|
}
|
|
11985
12131
|
this.line += 1;
|
|
11986
|
-
this.lineStart = this.position;
|
|
12132
|
+
this.lineStart = this.#scanner.position;
|
|
11987
12133
|
}
|
|
11988
12134
|
skipSeparationSpace(allowComments, checkIndent) {
|
|
11989
12135
|
let lineBreaks = 0;
|
|
11990
|
-
let ch = this.peek();
|
|
12136
|
+
let ch = this.#scanner.peek();
|
|
11991
12137
|
while (ch !== 0) {
|
|
11992
12138
|
this.skipWhitespaces();
|
|
11993
|
-
ch = this.peek();
|
|
12139
|
+
ch = this.#scanner.peek();
|
|
11994
12140
|
if (allowComments) {
|
|
11995
12141
|
this.skipComment();
|
|
11996
|
-
ch = this.peek();
|
|
12142
|
+
ch = this.#scanner.peek();
|
|
11997
12143
|
}
|
|
11998
12144
|
if (isEOL(ch)) {
|
|
11999
12145
|
this.readLineBreak();
|
|
12000
|
-
ch = this.peek();
|
|
12146
|
+
ch = this.#scanner.peek();
|
|
12001
12147
|
lineBreaks++;
|
|
12002
12148
|
this.lineIndent = 0;
|
|
12003
12149
|
this.readIndent();
|
|
12004
|
-
ch = this.peek();
|
|
12150
|
+
ch = this.#scanner.peek();
|
|
12005
12151
|
} else {
|
|
12006
12152
|
break;
|
|
12007
12153
|
}
|
|
@@ -12012,9 +12158,9 @@ var LoaderState = class {
|
|
|
12012
12158
|
return lineBreaks;
|
|
12013
12159
|
}
|
|
12014
12160
|
testDocumentSeparator() {
|
|
12015
|
-
let ch = this.peek();
|
|
12016
|
-
if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) {
|
|
12017
|
-
ch = this.peek(3);
|
|
12161
|
+
let ch = this.#scanner.peek();
|
|
12162
|
+
if ((ch === MINUS || ch === DOT) && ch === this.#scanner.peek(1) && ch === this.#scanner.peek(2)) {
|
|
12163
|
+
ch = this.#scanner.peek(3);
|
|
12018
12164
|
if (ch === 0 || isWhiteSpaceOrEOL(ch)) {
|
|
12019
12165
|
return true;
|
|
12020
12166
|
}
|
|
@@ -12022,34 +12168,34 @@ var LoaderState = class {
|
|
|
12022
12168
|
return false;
|
|
12023
12169
|
}
|
|
12024
12170
|
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
12025
|
-
let ch = this.peek();
|
|
12171
|
+
let ch = this.#scanner.peek();
|
|
12026
12172
|
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) {
|
|
12027
12173
|
return;
|
|
12028
12174
|
}
|
|
12029
12175
|
let following;
|
|
12030
12176
|
if (ch === QUESTION || ch === MINUS) {
|
|
12031
|
-
following = this.peek(1);
|
|
12177
|
+
following = this.#scanner.peek(1);
|
|
12032
12178
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
12033
12179
|
return;
|
|
12034
12180
|
}
|
|
12035
12181
|
}
|
|
12036
12182
|
let result = "";
|
|
12037
|
-
let captureEnd = this.position;
|
|
12038
|
-
let captureStart = this.position;
|
|
12183
|
+
let captureEnd = this.#scanner.position;
|
|
12184
|
+
let captureStart = this.#scanner.position;
|
|
12039
12185
|
let hasPendingContent = false;
|
|
12040
12186
|
let line = 0;
|
|
12041
12187
|
while (ch !== 0) {
|
|
12042
12188
|
if (ch === COLON) {
|
|
12043
|
-
following = this.peek(1);
|
|
12189
|
+
following = this.#scanner.peek(1);
|
|
12044
12190
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
12045
12191
|
break;
|
|
12046
12192
|
}
|
|
12047
12193
|
} else if (ch === SHARP) {
|
|
12048
|
-
const preceding = this.peek(-1);
|
|
12194
|
+
const preceding = this.#scanner.peek(-1);
|
|
12049
12195
|
if (isWhiteSpaceOrEOL(preceding)) {
|
|
12050
12196
|
break;
|
|
12051
12197
|
}
|
|
12052
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
12198
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
12053
12199
|
break;
|
|
12054
12200
|
} else if (isEOL(ch)) {
|
|
12055
12201
|
line = this.line;
|
|
@@ -12058,10 +12204,10 @@ var LoaderState = class {
|
|
|
12058
12204
|
this.skipSeparationSpace(false, -1);
|
|
12059
12205
|
if (this.lineIndent >= nodeIndent) {
|
|
12060
12206
|
hasPendingContent = true;
|
|
12061
|
-
ch = this.peek();
|
|
12207
|
+
ch = this.#scanner.peek();
|
|
12062
12208
|
continue;
|
|
12063
12209
|
} else {
|
|
12064
|
-
this.position = captureEnd;
|
|
12210
|
+
this.#scanner.position = captureEnd;
|
|
12065
12211
|
this.line = line;
|
|
12066
12212
|
this.lineStart = lineStart;
|
|
12067
12213
|
this.lineIndent = lineIndent;
|
|
@@ -12072,13 +12218,14 @@ var LoaderState = class {
|
|
|
12072
12218
|
const segment2 = this.captureSegment(captureStart, captureEnd, false);
|
|
12073
12219
|
if (segment2) result += segment2;
|
|
12074
12220
|
result += writeFoldedLines(this.line - line);
|
|
12075
|
-
captureStart = captureEnd = this.position;
|
|
12221
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12076
12222
|
hasPendingContent = false;
|
|
12077
12223
|
}
|
|
12078
12224
|
if (!isWhiteSpace(ch)) {
|
|
12079
|
-
captureEnd = this.position + 1;
|
|
12225
|
+
captureEnd = this.#scanner.position + 1;
|
|
12080
12226
|
}
|
|
12081
|
-
|
|
12227
|
+
this.#scanner.next();
|
|
12228
|
+
ch = this.#scanner.peek();
|
|
12082
12229
|
}
|
|
12083
12230
|
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
12084
12231
|
if (segment) result += segment;
|
|
@@ -12091,22 +12238,23 @@ var LoaderState = class {
|
|
|
12091
12238
|
};
|
|
12092
12239
|
}
|
|
12093
12240
|
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
12094
|
-
let ch = this.peek();
|
|
12241
|
+
let ch = this.#scanner.peek();
|
|
12095
12242
|
if (ch !== SINGLE_QUOTE) return;
|
|
12096
12243
|
let result = "";
|
|
12097
|
-
this.
|
|
12098
|
-
let captureStart = this.position;
|
|
12099
|
-
let captureEnd = this.position;
|
|
12100
|
-
ch = this.peek();
|
|
12244
|
+
this.#scanner.next();
|
|
12245
|
+
let captureStart = this.#scanner.position;
|
|
12246
|
+
let captureEnd = this.#scanner.position;
|
|
12247
|
+
ch = this.#scanner.peek();
|
|
12101
12248
|
while (ch !== 0) {
|
|
12102
12249
|
if (ch === SINGLE_QUOTE) {
|
|
12103
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12250
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12104
12251
|
if (segment) result += segment;
|
|
12105
|
-
|
|
12252
|
+
this.#scanner.next();
|
|
12253
|
+
ch = this.#scanner.peek();
|
|
12106
12254
|
if (ch === SINGLE_QUOTE) {
|
|
12107
|
-
captureStart = this.position;
|
|
12108
|
-
this.
|
|
12109
|
-
captureEnd = this.position;
|
|
12255
|
+
captureStart = this.#scanner.position;
|
|
12256
|
+
this.#scanner.next();
|
|
12257
|
+
captureEnd = this.#scanner.position;
|
|
12110
12258
|
} else {
|
|
12111
12259
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12112
12260
|
return {
|
|
@@ -12120,31 +12268,31 @@ var LoaderState = class {
|
|
|
12120
12268
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
12121
12269
|
if (segment) result += segment;
|
|
12122
12270
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
12123
|
-
captureStart = captureEnd = this.position;
|
|
12124
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12271
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12272
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12125
12273
|
throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
12126
12274
|
} else {
|
|
12127
|
-
this.
|
|
12128
|
-
captureEnd = this.position;
|
|
12275
|
+
this.#scanner.next();
|
|
12276
|
+
captureEnd = this.#scanner.position;
|
|
12129
12277
|
}
|
|
12130
|
-
ch = this.peek();
|
|
12278
|
+
ch = this.#scanner.peek();
|
|
12131
12279
|
}
|
|
12132
12280
|
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
12133
12281
|
}
|
|
12134
12282
|
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
12135
|
-
let ch = this.peek();
|
|
12283
|
+
let ch = this.#scanner.peek();
|
|
12136
12284
|
if (ch !== DOUBLE_QUOTE) return;
|
|
12137
12285
|
let result = "";
|
|
12138
|
-
this.
|
|
12139
|
-
let captureEnd = this.position;
|
|
12140
|
-
let captureStart = this.position;
|
|
12286
|
+
this.#scanner.next();
|
|
12287
|
+
let captureEnd = this.#scanner.position;
|
|
12288
|
+
let captureStart = this.#scanner.position;
|
|
12141
12289
|
let tmp;
|
|
12142
|
-
ch = this.peek();
|
|
12290
|
+
ch = this.#scanner.peek();
|
|
12143
12291
|
while (ch !== 0) {
|
|
12144
12292
|
if (ch === DOUBLE_QUOTE) {
|
|
12145
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12293
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12146
12294
|
if (segment) result += segment;
|
|
12147
|
-
this.
|
|
12295
|
+
this.#scanner.next();
|
|
12148
12296
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12149
12297
|
return {
|
|
12150
12298
|
tag,
|
|
@@ -12154,19 +12302,21 @@ var LoaderState = class {
|
|
|
12154
12302
|
};
|
|
12155
12303
|
}
|
|
12156
12304
|
if (ch === BACKSLASH) {
|
|
12157
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12305
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12158
12306
|
if (segment) result += segment;
|
|
12159
|
-
|
|
12307
|
+
this.#scanner.next();
|
|
12308
|
+
ch = this.#scanner.peek();
|
|
12160
12309
|
if (isEOL(ch)) {
|
|
12161
12310
|
this.skipSeparationSpace(false, nodeIndent);
|
|
12162
12311
|
} else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
12163
12312
|
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
12164
|
-
this.
|
|
12313
|
+
this.#scanner.next();
|
|
12165
12314
|
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
12166
12315
|
let hexLength = tmp;
|
|
12167
12316
|
let hexResult = 0;
|
|
12168
12317
|
for (; hexLength > 0; hexLength--) {
|
|
12169
|
-
|
|
12318
|
+
this.#scanner.next();
|
|
12319
|
+
ch = this.#scanner.peek();
|
|
12170
12320
|
if ((tmp = hexCharCodeToNumber(ch)) >= 0) {
|
|
12171
12321
|
hexResult = (hexResult << 4) + tmp;
|
|
12172
12322
|
} else {
|
|
@@ -12174,28 +12324,28 @@ var LoaderState = class {
|
|
|
12174
12324
|
}
|
|
12175
12325
|
}
|
|
12176
12326
|
result += codepointToChar(hexResult);
|
|
12177
|
-
this.
|
|
12327
|
+
this.#scanner.next();
|
|
12178
12328
|
} else {
|
|
12179
12329
|
throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
12180
12330
|
}
|
|
12181
|
-
captureStart = captureEnd = this.position;
|
|
12331
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12182
12332
|
} else if (isEOL(ch)) {
|
|
12183
12333
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
12184
12334
|
if (segment) result += segment;
|
|
12185
12335
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
12186
|
-
captureStart = captureEnd = this.position;
|
|
12187
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12336
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12337
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12188
12338
|
throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
12189
12339
|
} else {
|
|
12190
|
-
this.
|
|
12191
|
-
captureEnd = this.position;
|
|
12340
|
+
this.#scanner.next();
|
|
12341
|
+
captureEnd = this.#scanner.position;
|
|
12192
12342
|
}
|
|
12193
|
-
ch = this.peek();
|
|
12343
|
+
ch = this.#scanner.peek();
|
|
12194
12344
|
}
|
|
12195
12345
|
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
12196
12346
|
}
|
|
12197
12347
|
readFlowCollection(tag, anchor, nodeIndent) {
|
|
12198
|
-
let ch = this.peek();
|
|
12348
|
+
let ch = this.#scanner.peek();
|
|
12199
12349
|
let terminator;
|
|
12200
12350
|
let isMapping = true;
|
|
12201
12351
|
let result = {};
|
|
@@ -12209,7 +12359,8 @@ var LoaderState = class {
|
|
|
12209
12359
|
return;
|
|
12210
12360
|
}
|
|
12211
12361
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12212
|
-
|
|
12362
|
+
this.#scanner.next();
|
|
12363
|
+
ch = this.#scanner.peek();
|
|
12213
12364
|
let readNext = true;
|
|
12214
12365
|
let valueNode = null;
|
|
12215
12366
|
let keyNode = null;
|
|
@@ -12221,9 +12372,9 @@ var LoaderState = class {
|
|
|
12221
12372
|
const overridableKeys = /* @__PURE__ */ new Set();
|
|
12222
12373
|
while (ch !== 0) {
|
|
12223
12374
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12224
|
-
ch = this.peek();
|
|
12375
|
+
ch = this.#scanner.peek();
|
|
12225
12376
|
if (ch === terminator) {
|
|
12226
|
-
this.
|
|
12377
|
+
this.#scanner.next();
|
|
12227
12378
|
const kind = isMapping ? "mapping" : "sequence";
|
|
12228
12379
|
return {
|
|
12229
12380
|
tag,
|
|
@@ -12238,10 +12389,10 @@ var LoaderState = class {
|
|
|
12238
12389
|
keyTag = keyNode = valueNode = null;
|
|
12239
12390
|
isPair = isExplicitPair = false;
|
|
12240
12391
|
if (ch === QUESTION) {
|
|
12241
|
-
following = this.peek(1);
|
|
12392
|
+
following = this.#scanner.peek(1);
|
|
12242
12393
|
if (isWhiteSpaceOrEOL(following)) {
|
|
12243
12394
|
isPair = isExplicitPair = true;
|
|
12244
|
-
this.
|
|
12395
|
+
this.#scanner.next();
|
|
12245
12396
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12246
12397
|
}
|
|
12247
12398
|
}
|
|
@@ -12257,10 +12408,11 @@ var LoaderState = class {
|
|
|
12257
12408
|
keyNode = newState.result;
|
|
12258
12409
|
}
|
|
12259
12410
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12260
|
-
ch = this.peek();
|
|
12411
|
+
ch = this.#scanner.peek();
|
|
12261
12412
|
if ((isExplicitPair || this.line === line) && ch === COLON) {
|
|
12262
12413
|
isPair = true;
|
|
12263
|
-
|
|
12414
|
+
this.#scanner.next();
|
|
12415
|
+
ch = this.#scanner.peek();
|
|
12264
12416
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12265
12417
|
const newState2 = this.composeNode({
|
|
12266
12418
|
parentIndent: nodeIndent,
|
|
@@ -12278,10 +12430,11 @@ var LoaderState = class {
|
|
|
12278
12430
|
result.push(keyNode);
|
|
12279
12431
|
}
|
|
12280
12432
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12281
|
-
ch = this.peek();
|
|
12433
|
+
ch = this.#scanner.peek();
|
|
12282
12434
|
if (ch === COMMA) {
|
|
12283
12435
|
readNext = true;
|
|
12284
|
-
|
|
12436
|
+
this.#scanner.next();
|
|
12437
|
+
ch = this.#scanner.peek();
|
|
12285
12438
|
} else {
|
|
12286
12439
|
readNext = false;
|
|
12287
12440
|
}
|
|
@@ -12297,7 +12450,7 @@ var LoaderState = class {
|
|
|
12297
12450
|
let textIndent = nodeIndent;
|
|
12298
12451
|
let emptyLines = 0;
|
|
12299
12452
|
let atMoreIndented = false;
|
|
12300
|
-
let ch = this.peek();
|
|
12453
|
+
let ch = this.#scanner.peek();
|
|
12301
12454
|
let folding = false;
|
|
12302
12455
|
if (ch === VERTICAL_LINE) {
|
|
12303
12456
|
folding = false;
|
|
@@ -12309,7 +12462,8 @@ var LoaderState = class {
|
|
|
12309
12462
|
let result = "";
|
|
12310
12463
|
let tmp = 0;
|
|
12311
12464
|
while (ch !== 0) {
|
|
12312
|
-
|
|
12465
|
+
this.#scanner.next();
|
|
12466
|
+
ch = this.#scanner.peek();
|
|
12313
12467
|
if (ch === PLUS || ch === MINUS) {
|
|
12314
12468
|
if (CHOMPING_CLIP === chomping) {
|
|
12315
12469
|
chomping = ch === PLUS ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
@@ -12332,15 +12486,16 @@ var LoaderState = class {
|
|
|
12332
12486
|
if (isWhiteSpace(ch)) {
|
|
12333
12487
|
this.skipWhitespaces();
|
|
12334
12488
|
this.skipComment();
|
|
12335
|
-
ch = this.peek();
|
|
12489
|
+
ch = this.#scanner.peek();
|
|
12336
12490
|
}
|
|
12337
12491
|
while (ch !== 0) {
|
|
12338
12492
|
this.readLineBreak();
|
|
12339
12493
|
this.lineIndent = 0;
|
|
12340
|
-
ch = this.peek();
|
|
12494
|
+
ch = this.#scanner.peek();
|
|
12341
12495
|
while ((!detectedIndent || this.lineIndent < textIndent) && ch === SPACE) {
|
|
12342
12496
|
this.lineIndent++;
|
|
12343
|
-
|
|
12497
|
+
this.#scanner.next();
|
|
12498
|
+
ch = this.#scanner.peek();
|
|
12344
12499
|
}
|
|
12345
12500
|
if (!detectedIndent && this.lineIndent > textIndent) {
|
|
12346
12501
|
textIndent = this.lineIndent;
|
|
@@ -12379,11 +12534,12 @@ var LoaderState = class {
|
|
|
12379
12534
|
didReadContent = true;
|
|
12380
12535
|
detectedIndent = true;
|
|
12381
12536
|
emptyLines = 0;
|
|
12382
|
-
const captureStart = this.position;
|
|
12537
|
+
const captureStart = this.#scanner.position;
|
|
12383
12538
|
while (!isEOL(ch) && ch !== 0) {
|
|
12384
|
-
|
|
12539
|
+
this.#scanner.next();
|
|
12540
|
+
ch = this.#scanner.peek();
|
|
12385
12541
|
}
|
|
12386
|
-
const segment = this.captureSegment(captureStart, this.position, false);
|
|
12542
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, false);
|
|
12387
12543
|
if (segment) result += segment;
|
|
12388
12544
|
}
|
|
12389
12545
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
@@ -12406,11 +12562,11 @@ var LoaderState = class {
|
|
|
12406
12562
|
let atExplicitKey = false;
|
|
12407
12563
|
let detected = false;
|
|
12408
12564
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12409
|
-
let ch = this.peek();
|
|
12565
|
+
let ch = this.#scanner.peek();
|
|
12410
12566
|
while (ch !== 0) {
|
|
12411
|
-
const following = this.peek(1);
|
|
12567
|
+
const following = this.#scanner.peek(1);
|
|
12412
12568
|
line = this.line;
|
|
12413
|
-
pos = this.position;
|
|
12569
|
+
pos = this.#scanner.position;
|
|
12414
12570
|
if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) {
|
|
12415
12571
|
if (ch === QUESTION) {
|
|
12416
12572
|
if (atExplicitKey) {
|
|
@@ -12428,7 +12584,7 @@ var LoaderState = class {
|
|
|
12428
12584
|
} else {
|
|
12429
12585
|
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");
|
|
12430
12586
|
}
|
|
12431
|
-
this.
|
|
12587
|
+
this.#scanner.next();
|
|
12432
12588
|
ch = following;
|
|
12433
12589
|
} else {
|
|
12434
12590
|
const newState = this.composeNode({
|
|
@@ -12439,11 +12595,12 @@ var LoaderState = class {
|
|
|
12439
12595
|
});
|
|
12440
12596
|
if (!newState) break;
|
|
12441
12597
|
if (this.line === line) {
|
|
12442
|
-
ch = this.peek();
|
|
12598
|
+
ch = this.#scanner.peek();
|
|
12443
12599
|
this.skipWhitespaces();
|
|
12444
|
-
ch = this.peek();
|
|
12600
|
+
ch = this.#scanner.peek();
|
|
12445
12601
|
if (ch === COLON) {
|
|
12446
|
-
|
|
12602
|
+
this.#scanner.next();
|
|
12603
|
+
ch = this.#scanner.peek();
|
|
12447
12604
|
if (!isWhiteSpaceOrEOL(ch)) {
|
|
12448
12605
|
throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
12449
12606
|
}
|
|
@@ -12500,7 +12657,7 @@ var LoaderState = class {
|
|
|
12500
12657
|
keyTag = keyNode = valueNode = null;
|
|
12501
12658
|
}
|
|
12502
12659
|
this.skipSeparationSpace(true, -1);
|
|
12503
|
-
ch = this.peek();
|
|
12660
|
+
ch = this.#scanner.peek();
|
|
12504
12661
|
}
|
|
12505
12662
|
if (this.lineIndent > nodeIndent && ch !== 0) {
|
|
12506
12663
|
throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
@@ -12523,30 +12680,35 @@ var LoaderState = class {
|
|
|
12523
12680
|
let isNamed = false;
|
|
12524
12681
|
let tagHandle = "";
|
|
12525
12682
|
let tagName;
|
|
12526
|
-
let ch = this.peek();
|
|
12683
|
+
let ch = this.#scanner.peek();
|
|
12527
12684
|
if (ch !== EXCLAMATION) return;
|
|
12528
12685
|
if (tag !== null) {
|
|
12529
12686
|
throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
12530
12687
|
}
|
|
12531
|
-
|
|
12688
|
+
this.#scanner.next();
|
|
12689
|
+
ch = this.#scanner.peek();
|
|
12532
12690
|
if (ch === SMALLER_THAN) {
|
|
12533
12691
|
isVerbatim = true;
|
|
12534
|
-
|
|
12692
|
+
this.#scanner.next();
|
|
12693
|
+
ch = this.#scanner.peek();
|
|
12535
12694
|
} else if (ch === EXCLAMATION) {
|
|
12536
12695
|
isNamed = true;
|
|
12537
12696
|
tagHandle = "!!";
|
|
12538
|
-
|
|
12697
|
+
this.#scanner.next();
|
|
12698
|
+
ch = this.#scanner.peek();
|
|
12539
12699
|
} else {
|
|
12540
12700
|
tagHandle = "!";
|
|
12541
12701
|
}
|
|
12542
|
-
let position = this.position;
|
|
12702
|
+
let position = this.#scanner.position;
|
|
12543
12703
|
if (isVerbatim) {
|
|
12544
12704
|
do {
|
|
12545
|
-
|
|
12705
|
+
this.#scanner.next();
|
|
12706
|
+
ch = this.#scanner.peek();
|
|
12546
12707
|
} while (ch !== 0 && ch !== GREATER_THAN);
|
|
12547
|
-
if (this.
|
|
12548
|
-
tagName = this.
|
|
12549
|
-
|
|
12708
|
+
if (!this.#scanner.eof()) {
|
|
12709
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12710
|
+
this.#scanner.next();
|
|
12711
|
+
ch = this.#scanner.peek();
|
|
12550
12712
|
} else {
|
|
12551
12713
|
throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
12552
12714
|
}
|
|
@@ -12554,19 +12716,20 @@ var LoaderState = class {
|
|
|
12554
12716
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12555
12717
|
if (ch === EXCLAMATION) {
|
|
12556
12718
|
if (!isNamed) {
|
|
12557
|
-
tagHandle = this.
|
|
12719
|
+
tagHandle = this.#scanner.source.slice(position - 1, this.#scanner.position + 1);
|
|
12558
12720
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
12559
12721
|
throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
12560
12722
|
}
|
|
12561
12723
|
isNamed = true;
|
|
12562
|
-
position = this.position + 1;
|
|
12724
|
+
position = this.#scanner.position + 1;
|
|
12563
12725
|
} else {
|
|
12564
12726
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
12565
12727
|
}
|
|
12566
12728
|
}
|
|
12567
|
-
|
|
12729
|
+
this.#scanner.next();
|
|
12730
|
+
ch = this.#scanner.peek();
|
|
12568
12731
|
}
|
|
12569
|
-
tagName = this.
|
|
12732
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12570
12733
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
12571
12734
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
12572
12735
|
}
|
|
@@ -12586,32 +12749,36 @@ var LoaderState = class {
|
|
|
12586
12749
|
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
12587
12750
|
}
|
|
12588
12751
|
readAnchorProperty(anchor) {
|
|
12589
|
-
let ch = this.peek();
|
|
12752
|
+
let ch = this.#scanner.peek();
|
|
12590
12753
|
if (ch !== AMPERSAND) return;
|
|
12591
12754
|
if (anchor !== null) {
|
|
12592
12755
|
throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
12593
12756
|
}
|
|
12594
|
-
|
|
12595
|
-
|
|
12757
|
+
this.#scanner.next();
|
|
12758
|
+
ch = this.#scanner.peek();
|
|
12759
|
+
const position = this.#scanner.position;
|
|
12596
12760
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
12597
|
-
|
|
12761
|
+
this.#scanner.next();
|
|
12762
|
+
ch = this.#scanner.peek();
|
|
12598
12763
|
}
|
|
12599
|
-
if (this.position === position) {
|
|
12764
|
+
if (this.#scanner.position === position) {
|
|
12600
12765
|
throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
12601
12766
|
}
|
|
12602
|
-
return this.
|
|
12767
|
+
return this.#scanner.source.slice(position, this.#scanner.position);
|
|
12603
12768
|
}
|
|
12604
12769
|
readAlias() {
|
|
12605
|
-
if (this.peek() !== ASTERISK) return;
|
|
12606
|
-
|
|
12607
|
-
|
|
12770
|
+
if (this.#scanner.peek() !== ASTERISK) return;
|
|
12771
|
+
this.#scanner.next();
|
|
12772
|
+
let ch = this.#scanner.peek();
|
|
12773
|
+
const position = this.#scanner.position;
|
|
12608
12774
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
12609
|
-
|
|
12775
|
+
this.#scanner.next();
|
|
12776
|
+
ch = this.#scanner.peek();
|
|
12610
12777
|
}
|
|
12611
|
-
if (this.position === position) {
|
|
12778
|
+
if (this.#scanner.position === position) {
|
|
12612
12779
|
throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
12613
12780
|
}
|
|
12614
|
-
const alias = this.
|
|
12781
|
+
const alias = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12615
12782
|
if (!this.anchorMap.has(alias)) {
|
|
12616
12783
|
throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
12617
12784
|
}
|
|
@@ -12694,7 +12861,7 @@ var LoaderState = class {
|
|
|
12694
12861
|
const cond = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
|
|
12695
12862
|
const flowIndent = cond ? parentIndent : parentIndent + 1;
|
|
12696
12863
|
if (allowBlockCollections) {
|
|
12697
|
-
const blockIndent = this.position - this.lineStart;
|
|
12864
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
12698
12865
|
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
12699
12866
|
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
12700
12867
|
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
@@ -12728,7 +12895,7 @@ var LoaderState = class {
|
|
|
12728
12895
|
return this.resolveTag(plainScalarState);
|
|
12729
12896
|
}
|
|
12730
12897
|
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
12731
|
-
const blockIndent = this.position - this.lineStart;
|
|
12898
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
12732
12899
|
const newState2 = this.readBlockSequence(tag, anchor, blockIndent);
|
|
12733
12900
|
if (newState2) return this.resolveTag(newState2);
|
|
12734
12901
|
}
|
|
@@ -12743,20 +12910,22 @@ var LoaderState = class {
|
|
|
12743
12910
|
readDirectives() {
|
|
12744
12911
|
let hasDirectives = false;
|
|
12745
12912
|
let version = null;
|
|
12746
|
-
let ch = this.peek();
|
|
12913
|
+
let ch = this.#scanner.peek();
|
|
12747
12914
|
while (ch !== 0) {
|
|
12748
12915
|
this.skipSeparationSpace(true, -1);
|
|
12749
|
-
ch = this.peek();
|
|
12916
|
+
ch = this.#scanner.peek();
|
|
12750
12917
|
if (this.lineIndent > 0 || ch !== PERCENT) {
|
|
12751
12918
|
break;
|
|
12752
12919
|
}
|
|
12753
12920
|
hasDirectives = true;
|
|
12754
|
-
|
|
12755
|
-
|
|
12921
|
+
this.#scanner.next();
|
|
12922
|
+
ch = this.#scanner.peek();
|
|
12923
|
+
let position = this.#scanner.position;
|
|
12756
12924
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12757
|
-
|
|
12925
|
+
this.#scanner.next();
|
|
12926
|
+
ch = this.#scanner.peek();
|
|
12758
12927
|
}
|
|
12759
|
-
const directiveName = this.
|
|
12928
|
+
const directiveName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12760
12929
|
const directiveArgs = [];
|
|
12761
12930
|
if (directiveName.length < 1) {
|
|
12762
12931
|
throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
@@ -12764,13 +12933,14 @@ var LoaderState = class {
|
|
|
12764
12933
|
while (ch !== 0) {
|
|
12765
12934
|
this.skipWhitespaces();
|
|
12766
12935
|
this.skipComment();
|
|
12767
|
-
ch = this.peek();
|
|
12936
|
+
ch = this.#scanner.peek();
|
|
12768
12937
|
if (isEOL(ch)) break;
|
|
12769
|
-
position = this.position;
|
|
12938
|
+
position = this.#scanner.position;
|
|
12770
12939
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12771
|
-
|
|
12940
|
+
this.#scanner.next();
|
|
12941
|
+
ch = this.#scanner.peek();
|
|
12772
12942
|
}
|
|
12773
|
-
directiveArgs.push(this.
|
|
12943
|
+
directiveArgs.push(this.#scanner.source.slice(position, this.#scanner.position));
|
|
12774
12944
|
}
|
|
12775
12945
|
if (ch !== 0) this.readLineBreak();
|
|
12776
12946
|
switch (directiveName) {
|
|
@@ -12787,20 +12957,20 @@ var LoaderState = class {
|
|
|
12787
12957
|
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
12788
12958
|
break;
|
|
12789
12959
|
}
|
|
12790
|
-
ch = this.peek();
|
|
12960
|
+
ch = this.#scanner.peek();
|
|
12791
12961
|
}
|
|
12792
12962
|
return hasDirectives;
|
|
12793
12963
|
}
|
|
12794
12964
|
readDocument() {
|
|
12795
|
-
const documentStart = this.position;
|
|
12965
|
+
const documentStart = this.#scanner.position;
|
|
12796
12966
|
this.checkLineBreaks = false;
|
|
12797
12967
|
this.tagMap = /* @__PURE__ */ new Map();
|
|
12798
12968
|
this.anchorMap = /* @__PURE__ */ new Map();
|
|
12799
12969
|
const hasDirectives = this.readDirectives();
|
|
12800
12970
|
this.skipSeparationSpace(true, -1);
|
|
12801
12971
|
let result = null;
|
|
12802
|
-
if (this.lineIndent === 0 && this.peek() === MINUS && this.peek(1) === MINUS && this.peek(2) === MINUS) {
|
|
12803
|
-
this.position += 3;
|
|
12972
|
+
if (this.lineIndent === 0 && this.#scanner.peek() === MINUS && this.#scanner.peek(1) === MINUS && this.#scanner.peek(2) === MINUS) {
|
|
12973
|
+
this.#scanner.position += 3;
|
|
12804
12974
|
this.skipSeparationSpace(true, -1);
|
|
12805
12975
|
} else if (hasDirectives) {
|
|
12806
12976
|
throw this.#createError("Cannot read document: directives end mark is expected");
|
|
@@ -12813,21 +12983,21 @@ var LoaderState = class {
|
|
|
12813
12983
|
});
|
|
12814
12984
|
if (newState) result = newState.result;
|
|
12815
12985
|
this.skipSeparationSpace(true, -1);
|
|
12816
|
-
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.
|
|
12986
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.#scanner.source.slice(documentStart, this.#scanner.position))) {
|
|
12817
12987
|
this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
12818
12988
|
}
|
|
12819
|
-
if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12820
|
-
if (this.peek() === DOT) {
|
|
12821
|
-
this.position += 3;
|
|
12989
|
+
if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12990
|
+
if (this.#scanner.peek() === DOT) {
|
|
12991
|
+
this.#scanner.position += 3;
|
|
12822
12992
|
this.skipSeparationSpace(true, -1);
|
|
12823
12993
|
}
|
|
12824
|
-
} else if (this.
|
|
12994
|
+
} else if (!this.#scanner.eof()) {
|
|
12825
12995
|
throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
12826
12996
|
}
|
|
12827
12997
|
return result;
|
|
12828
12998
|
}
|
|
12829
12999
|
*readDocuments() {
|
|
12830
|
-
while (this.
|
|
13000
|
+
while (!this.#scanner.eof()) {
|
|
12831
13001
|
yield this.readDocument();
|
|
12832
13002
|
}
|
|
12833
13003
|
}
|
|
@@ -12840,7 +13010,6 @@ function sanitizeInput(input) {
|
|
|
12840
13010
|
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
12841
13011
|
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
12842
13012
|
}
|
|
12843
|
-
input += "\0";
|
|
12844
13013
|
return input;
|
|
12845
13014
|
}
|
|
12846
13015
|
function parse(content, options = {}) {
|
|
@@ -13726,6 +13895,7 @@ data:
|
|
|
13726
13895
|
async handleGetRequest(req) {
|
|
13727
13896
|
const acceptHeader = req.headers.get("accept");
|
|
13728
13897
|
if (!acceptHeader?.includes("text/event-stream")) {
|
|
13898
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream"));
|
|
13729
13899
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept text/event-stream");
|
|
13730
13900
|
}
|
|
13731
13901
|
const sessionError = this.validateSession(req);
|
|
@@ -13743,6 +13913,7 @@ data:
|
|
|
13743
13913
|
}
|
|
13744
13914
|
}
|
|
13745
13915
|
if (this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
13916
|
+
this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session"));
|
|
13746
13917
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Only one SSE stream is allowed per session");
|
|
13747
13918
|
}
|
|
13748
13919
|
const encoder2 = new TextEncoder();
|
|
@@ -13782,6 +13953,7 @@ data:
|
|
|
13782
13953
|
*/
|
|
13783
13954
|
async replayEvents(lastEventId) {
|
|
13784
13955
|
if (!this._eventStore) {
|
|
13956
|
+
this.onerror?.(new Error("Event store not configured"));
|
|
13785
13957
|
return this.createJsonErrorResponse(400, -32e3, "Event store not configured");
|
|
13786
13958
|
}
|
|
13787
13959
|
try {
|
|
@@ -13789,9 +13961,11 @@ data:
|
|
|
13789
13961
|
if (this._eventStore.getStreamIdForEventId) {
|
|
13790
13962
|
streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
|
|
13791
13963
|
if (!streamId) {
|
|
13964
|
+
this.onerror?.(new Error("Invalid event ID format"));
|
|
13792
13965
|
return this.createJsonErrorResponse(400, -32e3, "Invalid event ID format");
|
|
13793
13966
|
}
|
|
13794
13967
|
if (this._streamMapping.get(streamId) !== void 0) {
|
|
13968
|
+
this.onerror?.(new Error("Conflict: Stream already has an active connection"));
|
|
13795
13969
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Stream already has an active connection");
|
|
13796
13970
|
}
|
|
13797
13971
|
}
|
|
@@ -13857,7 +14031,8 @@ data:
|
|
|
13857
14031
|
`;
|
|
13858
14032
|
controller.enqueue(encoder2.encode(eventData));
|
|
13859
14033
|
return true;
|
|
13860
|
-
} catch {
|
|
14034
|
+
} catch (error) {
|
|
14035
|
+
this.onerror?.(error);
|
|
13861
14036
|
return false;
|
|
13862
14037
|
}
|
|
13863
14038
|
}
|
|
@@ -13865,6 +14040,7 @@ data:
|
|
|
13865
14040
|
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
13866
14041
|
*/
|
|
13867
14042
|
handleUnsupportedRequest() {
|
|
14043
|
+
this.onerror?.(new Error("Method not allowed."));
|
|
13868
14044
|
return new Response(JSON.stringify({
|
|
13869
14045
|
jsonrpc: "2.0",
|
|
13870
14046
|
error: {
|
|
@@ -13887,14 +14063,17 @@ data:
|
|
|
13887
14063
|
try {
|
|
13888
14064
|
const acceptHeader = req.headers.get("accept");
|
|
13889
14065
|
if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
|
|
14066
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
|
|
13890
14067
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept both application/json and text/event-stream");
|
|
13891
14068
|
}
|
|
13892
14069
|
const ct = req.headers.get("content-type");
|
|
13893
14070
|
if (!ct || !ct.includes("application/json")) {
|
|
14071
|
+
this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
|
|
13894
14072
|
return this.createJsonErrorResponse(415, -32e3, "Unsupported Media Type: Content-Type must be application/json");
|
|
13895
14073
|
}
|
|
13896
14074
|
const requestInfo = {
|
|
13897
|
-
headers: Object.fromEntries(req.headers.entries())
|
|
14075
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
14076
|
+
url: new URL(req.url)
|
|
13898
14077
|
};
|
|
13899
14078
|
let rawMessage;
|
|
13900
14079
|
if (options?.parsedBody !== void 0) {
|
|
@@ -13903,6 +14082,7 @@ data:
|
|
|
13903
14082
|
try {
|
|
13904
14083
|
rawMessage = await req.json();
|
|
13905
14084
|
} catch {
|
|
14085
|
+
this.onerror?.(new Error("Parse error: Invalid JSON"));
|
|
13906
14086
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
|
|
13907
14087
|
}
|
|
13908
14088
|
}
|
|
@@ -13914,14 +14094,17 @@ data:
|
|
|
13914
14094
|
messages = [JSONRPCMessageSchema.parse(rawMessage)];
|
|
13915
14095
|
}
|
|
13916
14096
|
} catch {
|
|
14097
|
+
this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
|
|
13917
14098
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
|
|
13918
14099
|
}
|
|
13919
14100
|
const isInitializationRequest = messages.some(isInitializeRequest);
|
|
13920
14101
|
if (isInitializationRequest) {
|
|
13921
14102
|
if (this._initialized && this.sessionId !== void 0) {
|
|
14103
|
+
this.onerror?.(new Error("Invalid Request: Server already initialized"));
|
|
13922
14104
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
|
|
13923
14105
|
}
|
|
13924
14106
|
if (messages.length > 1) {
|
|
14107
|
+
this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed"));
|
|
13925
14108
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
|
|
13926
14109
|
}
|
|
13927
14110
|
this.sessionId = this.sessionIdGenerator?.();
|
|
@@ -14047,13 +14230,16 @@ data:
|
|
|
14047
14230
|
return void 0;
|
|
14048
14231
|
}
|
|
14049
14232
|
if (!this._initialized) {
|
|
14233
|
+
this.onerror?.(new Error("Bad Request: Server not initialized"));
|
|
14050
14234
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Server not initialized");
|
|
14051
14235
|
}
|
|
14052
14236
|
const sessionId = req.headers.get("mcp-session-id");
|
|
14053
14237
|
if (!sessionId) {
|
|
14238
|
+
this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required"));
|
|
14054
14239
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
14055
14240
|
}
|
|
14056
14241
|
if (sessionId !== this.sessionId) {
|
|
14242
|
+
this.onerror?.(new Error("Session not found"));
|
|
14057
14243
|
return this.createJsonErrorResponse(404, -32001, "Session not found");
|
|
14058
14244
|
}
|
|
14059
14245
|
return void 0;
|
|
@@ -14074,6 +14260,7 @@ data:
|
|
|
14074
14260
|
validateProtocolVersion(req) {
|
|
14075
14261
|
const protocolVersion = req.headers.get("mcp-protocol-version");
|
|
14076
14262
|
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
|
|
14263
|
+
this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
|
|
14077
14264
|
return this.createJsonErrorResponse(400, -32e3, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
|
|
14078
14265
|
}
|
|
14079
14266
|
return void 0;
|
|
@@ -14280,7 +14467,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
14280
14467
|
};
|
|
14281
14468
|
|
|
14282
14469
|
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
14283
|
-
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value
|
|
14470
|
+
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
14284
14471
|
var LETTER_REGEXP = /[A-Za-z]/;
|
|
14285
14472
|
var NUMBER_REGEXP = /-?\d+(\.\d*)?(e-?\d+)?$/;
|
|
14286
14473
|
var HYPHEN_REGEXP = /^(-|--)[^-]/;
|
|
@@ -14291,12 +14478,19 @@ var NON_WHITESPACE_REGEXP = /\S/;
|
|
|
14291
14478
|
function isNumber(string3) {
|
|
14292
14479
|
return NON_WHITESPACE_REGEXP.test(string3) && Number.isFinite(Number(string3));
|
|
14293
14480
|
}
|
|
14481
|
+
function isConstructorOrProto(obj, key) {
|
|
14482
|
+
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
|
|
14483
|
+
}
|
|
14294
14484
|
function setNested(object5, keys, value, collect = false) {
|
|
14295
14485
|
keys = [
|
|
14296
14486
|
...keys
|
|
14297
14487
|
];
|
|
14298
14488
|
const key = keys.pop();
|
|
14299
|
-
|
|
14489
|
+
for (const k of keys) {
|
|
14490
|
+
if (isConstructorOrProto(object5, k)) return;
|
|
14491
|
+
object5 = object5[k] ??= {};
|
|
14492
|
+
}
|
|
14493
|
+
if (isConstructorOrProto(object5, key)) return;
|
|
14300
14494
|
if (collect) {
|
|
14301
14495
|
const v = object5[key];
|
|
14302
14496
|
if (Array.isArray(v)) {
|
|
@@ -14427,7 +14621,7 @@ function parseArgs(args, options) {
|
|
|
14427
14621
|
let key = groups.key;
|
|
14428
14622
|
let value = groups.value;
|
|
14429
14623
|
if (doubleDash2) {
|
|
14430
|
-
if (value) {
|
|
14624
|
+
if (value != null) {
|
|
14431
14625
|
if (booleanSet.has(key)) value = parseBooleanString(value);
|
|
14432
14626
|
setArgument(key, value, arg, true);
|
|
14433
14627
|
continue;
|
|
@@ -14465,6 +14659,10 @@ function parseArgs(args, options) {
|
|
|
14465
14659
|
setArgument(letter, next, arg, true);
|
|
14466
14660
|
continue;
|
|
14467
14661
|
}
|
|
14662
|
+
if (next === "=") {
|
|
14663
|
+
setArgument(letter, "", arg, true);
|
|
14664
|
+
continue argsLoop;
|
|
14665
|
+
}
|
|
14468
14666
|
if (LETTER_REGEXP.test(letter)) {
|
|
14469
14667
|
const groups2 = VALUE_REGEXP.exec(next)?.groups;
|
|
14470
14668
|
if (groups2) {
|
|
@@ -14542,7 +14740,7 @@ import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/p
|
|
|
14542
14740
|
import { homedir } from "node:os";
|
|
14543
14741
|
import { dirname, join as join3, resolve as resolve4 } from "node:path";
|
|
14544
14742
|
import process9 from "node:process";
|
|
14545
|
-
var CLI_VERSION = "0.1.
|
|
14743
|
+
var CLI_VERSION = "0.1.51";
|
|
14546
14744
|
function extractServerName(command, commandArgs) {
|
|
14547
14745
|
for (const arg of commandArgs) {
|
|
14548
14746
|
if (!arg.startsWith("-")) {
|