@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/app.cjs
CHANGED
|
@@ -506,7 +506,7 @@ var require_cross_spawn = __commonJS({
|
|
|
506
506
|
var cp = require("child_process");
|
|
507
507
|
var parse2 = require_parse();
|
|
508
508
|
var enoent = require_enoent();
|
|
509
|
-
function
|
|
509
|
+
function spawn3(command, args, options) {
|
|
510
510
|
const parsed = parse2(command, args, options);
|
|
511
511
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
512
512
|
enoent.hookChildProcess(spawned, parsed);
|
|
@@ -518,8 +518,8 @@ var require_cross_spawn = __commonJS({
|
|
|
518
518
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
519
519
|
return result;
|
|
520
520
|
}
|
|
521
|
-
module2.exports =
|
|
522
|
-
module2.exports.spawn =
|
|
521
|
+
module2.exports = spawn3;
|
|
522
|
+
module2.exports.spawn = spawn3;
|
|
523
523
|
module2.exports.sync = spawnSync;
|
|
524
524
|
module2.exports._parse = parse2;
|
|
525
525
|
module2.exports._enoent = enoent;
|
|
@@ -3499,6 +3499,147 @@ var ExperimentalServerTasks = class {
|
|
|
3499
3499
|
requestStream(request, resultSchema, options) {
|
|
3500
3500
|
return this._server.requestStream(request, resultSchema, options);
|
|
3501
3501
|
}
|
|
3502
|
+
/**
|
|
3503
|
+
* Sends a sampling request and returns an AsyncGenerator that yields response messages.
|
|
3504
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
3505
|
+
*
|
|
3506
|
+
* For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
|
|
3507
|
+
* before the final result.
|
|
3508
|
+
*
|
|
3509
|
+
* @example
|
|
3510
|
+
* ```typescript
|
|
3511
|
+
* const stream = server.experimental.tasks.createMessageStream({
|
|
3512
|
+
* messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
|
|
3513
|
+
* maxTokens: 100
|
|
3514
|
+
* }, {
|
|
3515
|
+
* onprogress: (progress) => {
|
|
3516
|
+
* // Handle streaming tokens via progress notifications
|
|
3517
|
+
* console.log('Progress:', progress.message);
|
|
3518
|
+
* }
|
|
3519
|
+
* });
|
|
3520
|
+
*
|
|
3521
|
+
* for await (const message of stream) {
|
|
3522
|
+
* switch (message.type) {
|
|
3523
|
+
* case 'taskCreated':
|
|
3524
|
+
* console.log('Task created:', message.task.taskId);
|
|
3525
|
+
* break;
|
|
3526
|
+
* case 'taskStatus':
|
|
3527
|
+
* console.log('Task status:', message.task.status);
|
|
3528
|
+
* break;
|
|
3529
|
+
* case 'result':
|
|
3530
|
+
* console.log('Final result:', message.result);
|
|
3531
|
+
* break;
|
|
3532
|
+
* case 'error':
|
|
3533
|
+
* console.error('Error:', message.error);
|
|
3534
|
+
* break;
|
|
3535
|
+
* }
|
|
3536
|
+
* }
|
|
3537
|
+
* ```
|
|
3538
|
+
*
|
|
3539
|
+
* @param params - The sampling request parameters
|
|
3540
|
+
* @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
|
|
3541
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
3542
|
+
*
|
|
3543
|
+
* @experimental
|
|
3544
|
+
*/
|
|
3545
|
+
createMessageStream(params, options) {
|
|
3546
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
3547
|
+
if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) {
|
|
3548
|
+
throw new Error("Client does not support sampling tools capability.");
|
|
3549
|
+
}
|
|
3550
|
+
if (params.messages.length > 0) {
|
|
3551
|
+
const lastMessage = params.messages[params.messages.length - 1];
|
|
3552
|
+
const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
|
|
3553
|
+
const hasToolResults = lastContent.some((c) => c.type === "tool_result");
|
|
3554
|
+
const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
|
|
3555
|
+
const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
|
|
3556
|
+
const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
|
|
3557
|
+
if (hasToolResults) {
|
|
3558
|
+
if (lastContent.some((c) => c.type !== "tool_result")) {
|
|
3559
|
+
throw new Error("The last message must contain only tool_result content if any is present");
|
|
3560
|
+
}
|
|
3561
|
+
if (!hasPreviousToolUse) {
|
|
3562
|
+
throw new Error("tool_result blocks are not matching any tool_use from the previous message");
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
if (hasPreviousToolUse) {
|
|
3566
|
+
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
3567
|
+
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
3568
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) {
|
|
3569
|
+
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
}
|
|
3573
|
+
return this.requestStream({
|
|
3574
|
+
method: "sampling/createMessage",
|
|
3575
|
+
params
|
|
3576
|
+
}, CreateMessageResultSchema, options);
|
|
3577
|
+
}
|
|
3578
|
+
/**
|
|
3579
|
+
* Sends an elicitation request and returns an AsyncGenerator that yields response messages.
|
|
3580
|
+
* The generator is guaranteed to end with either a 'result' or 'error' message.
|
|
3581
|
+
*
|
|
3582
|
+
* For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
|
|
3583
|
+
* and 'taskStatus' messages before the final result.
|
|
3584
|
+
*
|
|
3585
|
+
* @example
|
|
3586
|
+
* ```typescript
|
|
3587
|
+
* const stream = server.experimental.tasks.elicitInputStream({
|
|
3588
|
+
* mode: 'url',
|
|
3589
|
+
* message: 'Please authenticate',
|
|
3590
|
+
* elicitationId: 'auth-123',
|
|
3591
|
+
* url: 'https://example.com/auth'
|
|
3592
|
+
* }, {
|
|
3593
|
+
* task: { ttl: 300000 } // Task-augmented for long-running auth flow
|
|
3594
|
+
* });
|
|
3595
|
+
*
|
|
3596
|
+
* for await (const message of stream) {
|
|
3597
|
+
* switch (message.type) {
|
|
3598
|
+
* case 'taskCreated':
|
|
3599
|
+
* console.log('Task created:', message.task.taskId);
|
|
3600
|
+
* break;
|
|
3601
|
+
* case 'taskStatus':
|
|
3602
|
+
* console.log('Task status:', message.task.status);
|
|
3603
|
+
* break;
|
|
3604
|
+
* case 'result':
|
|
3605
|
+
* console.log('User action:', message.result.action);
|
|
3606
|
+
* break;
|
|
3607
|
+
* case 'error':
|
|
3608
|
+
* console.error('Error:', message.error);
|
|
3609
|
+
* break;
|
|
3610
|
+
* }
|
|
3611
|
+
* }
|
|
3612
|
+
* ```
|
|
3613
|
+
*
|
|
3614
|
+
* @param params - The elicitation request parameters
|
|
3615
|
+
* @param options - Optional request options (timeout, signal, task creation params, etc.)
|
|
3616
|
+
* @returns AsyncGenerator that yields ResponseMessage objects
|
|
3617
|
+
*
|
|
3618
|
+
* @experimental
|
|
3619
|
+
*/
|
|
3620
|
+
elicitInputStream(params, options) {
|
|
3621
|
+
const clientCapabilities = this._server.getClientCapabilities();
|
|
3622
|
+
const mode = params.mode ?? "form";
|
|
3623
|
+
switch (mode) {
|
|
3624
|
+
case "url": {
|
|
3625
|
+
if (!clientCapabilities?.elicitation?.url) {
|
|
3626
|
+
throw new Error("Client does not support url elicitation.");
|
|
3627
|
+
}
|
|
3628
|
+
break;
|
|
3629
|
+
}
|
|
3630
|
+
case "form": {
|
|
3631
|
+
if (!clientCapabilities?.elicitation?.form) {
|
|
3632
|
+
throw new Error("Client does not support form elicitation.");
|
|
3633
|
+
}
|
|
3634
|
+
break;
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
const normalizedParams = mode === "form" && params.mode === void 0 ? { ...params, mode: "form" } : params;
|
|
3638
|
+
return this.requestStream({
|
|
3639
|
+
method: "elicitation/create",
|
|
3640
|
+
params: normalizedParams
|
|
3641
|
+
}, ElicitResultSchema, options);
|
|
3642
|
+
}
|
|
3502
3643
|
/**
|
|
3503
3644
|
* Gets the current status of a task.
|
|
3504
3645
|
*
|
|
@@ -5717,22 +5858,45 @@ async function auth(provider, options) {
|
|
|
5717
5858
|
}
|
|
5718
5859
|
}
|
|
5719
5860
|
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
5861
|
+
const cachedState = await provider.discoveryState?.();
|
|
5720
5862
|
let resourceMetadata;
|
|
5721
5863
|
let authorizationServerUrl;
|
|
5722
|
-
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5864
|
+
let metadata;
|
|
5865
|
+
let effectiveResourceMetadataUrl = resourceMetadataUrl;
|
|
5866
|
+
if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl) {
|
|
5867
|
+
effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl);
|
|
5868
|
+
}
|
|
5869
|
+
if (cachedState?.authorizationServerUrl) {
|
|
5870
|
+
authorizationServerUrl = cachedState.authorizationServerUrl;
|
|
5871
|
+
resourceMetadata = cachedState.resourceMetadata;
|
|
5872
|
+
metadata = cachedState.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn });
|
|
5873
|
+
if (!resourceMetadata) {
|
|
5874
|
+
try {
|
|
5875
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
|
|
5876
|
+
} catch {
|
|
5877
|
+
}
|
|
5726
5878
|
}
|
|
5727
|
-
|
|
5728
|
-
|
|
5729
|
-
|
|
5730
|
-
|
|
5879
|
+
if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
|
|
5880
|
+
await provider.saveDiscoveryState?.({
|
|
5881
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
5882
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
5883
|
+
resourceMetadata,
|
|
5884
|
+
authorizationServerMetadata: metadata
|
|
5885
|
+
});
|
|
5886
|
+
}
|
|
5887
|
+
} else {
|
|
5888
|
+
const serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
|
|
5889
|
+
authorizationServerUrl = serverInfo.authorizationServerUrl;
|
|
5890
|
+
metadata = serverInfo.authorizationServerMetadata;
|
|
5891
|
+
resourceMetadata = serverInfo.resourceMetadata;
|
|
5892
|
+
await provider.saveDiscoveryState?.({
|
|
5893
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
5894
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
5895
|
+
resourceMetadata,
|
|
5896
|
+
authorizationServerMetadata: metadata
|
|
5897
|
+
});
|
|
5731
5898
|
}
|
|
5732
5899
|
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
5733
|
-
const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, {
|
|
5734
|
-
fetchFn
|
|
5735
|
-
});
|
|
5736
5900
|
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
5737
5901
|
if (!clientInformation) {
|
|
5738
5902
|
if (authorizationCode !== void 0) {
|
|
@@ -5987,6 +6151,26 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
5987
6151
|
}
|
|
5988
6152
|
return void 0;
|
|
5989
6153
|
}
|
|
6154
|
+
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
6155
|
+
let resourceMetadata;
|
|
6156
|
+
let authorizationServerUrl;
|
|
6157
|
+
try {
|
|
6158
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
|
|
6159
|
+
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
6160
|
+
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
6161
|
+
}
|
|
6162
|
+
} catch {
|
|
6163
|
+
}
|
|
6164
|
+
if (!authorizationServerUrl) {
|
|
6165
|
+
authorizationServerUrl = String(new URL("/", serverUrl));
|
|
6166
|
+
}
|
|
6167
|
+
const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
6168
|
+
return {
|
|
6169
|
+
authorizationServerUrl,
|
|
6170
|
+
authorizationServerMetadata,
|
|
6171
|
+
resourceMetadata
|
|
6172
|
+
};
|
|
6173
|
+
}
|
|
5990
6174
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
5991
6175
|
let authorizationUrl;
|
|
5992
6176
|
if (metadata) {
|
|
@@ -6851,18 +7035,6 @@ var cleanToolSchema = (schema) => {
|
|
|
6851
7035
|
var import_node_process3 = require("node:process");
|
|
6852
7036
|
var import_node_process4 = __toESM(require("node:process"), 1);
|
|
6853
7037
|
var import_node_crypto = require("node:crypto");
|
|
6854
|
-
var mcpClientPool = /* @__PURE__ */ new Map();
|
|
6855
|
-
var mcpClientConnecting = /* @__PURE__ */ new Map();
|
|
6856
|
-
var shortHash = (s) => (0, import_node_crypto.createHash)("sha256").update(s).digest("hex").slice(0, 8);
|
|
6857
|
-
function defSignature(def) {
|
|
6858
|
-
const defCopy = {
|
|
6859
|
-
...def
|
|
6860
|
-
};
|
|
6861
|
-
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
6862
|
-
return `memory:${Date.now()}:${Math.random()}`;
|
|
6863
|
-
}
|
|
6864
|
-
return JSON.stringify(defCopy);
|
|
6865
|
-
}
|
|
6866
7038
|
function createTransport(def) {
|
|
6867
7039
|
const defAny = def;
|
|
6868
7040
|
const explicitType = defAny.transportType || defAny.type;
|
|
@@ -6910,90 +7082,43 @@ function createTransport(def) {
|
|
|
6910
7082
|
}
|
|
6911
7083
|
throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
|
|
6912
7084
|
}
|
|
6913
|
-
|
|
6914
|
-
const
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6918
|
-
|
|
6919
|
-
const existingConnecting = mcpClientConnecting.get(defKey);
|
|
6920
|
-
if (existingConnecting) {
|
|
6921
|
-
const client = await existingConnecting;
|
|
6922
|
-
const entry = mcpClientPool.get(defKey);
|
|
6923
|
-
if (entry) entry.refCount += 1;
|
|
6924
|
-
return client;
|
|
6925
|
-
}
|
|
6926
|
-
const transport = createTransport(def);
|
|
6927
|
-
const connecting = (async () => {
|
|
6928
|
-
const client = new Client({
|
|
6929
|
-
name: `mcp_${shortHash(defSignature(def))}`,
|
|
6930
|
-
version: "1.0.0"
|
|
6931
|
-
});
|
|
6932
|
-
await client.connect(transport, {
|
|
6933
|
-
timeout: 6e4 * 10
|
|
6934
|
-
});
|
|
6935
|
-
return client;
|
|
6936
|
-
})();
|
|
6937
|
-
mcpClientConnecting.set(defKey, connecting);
|
|
6938
|
-
try {
|
|
6939
|
-
const client = await connecting;
|
|
6940
|
-
mcpClientPool.set(defKey, {
|
|
6941
|
-
client,
|
|
6942
|
-
refCount: 1
|
|
6943
|
-
});
|
|
6944
|
-
return client;
|
|
6945
|
-
} finally {
|
|
6946
|
-
mcpClientConnecting.delete(defKey);
|
|
7085
|
+
function defSignature(def) {
|
|
7086
|
+
const defCopy = {
|
|
7087
|
+
...def
|
|
7088
|
+
};
|
|
7089
|
+
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
7090
|
+
return `memory:${Date.now()}:${Math.random()}`;
|
|
6947
7091
|
}
|
|
7092
|
+
return JSON.stringify(defCopy);
|
|
6948
7093
|
}
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
|
|
6958
|
-
|
|
6959
|
-
|
|
6960
|
-
}
|
|
7094
|
+
var shortHash = (s) => (0, import_node_crypto.createHash)("sha256").update(s).digest("hex").slice(0, 8);
|
|
7095
|
+
async function createMcpClient(def) {
|
|
7096
|
+
const transport = createTransport(def);
|
|
7097
|
+
const client = new Client({
|
|
7098
|
+
name: `mcp_${shortHash(defSignature(def))}`,
|
|
7099
|
+
version: "1.0.0"
|
|
7100
|
+
});
|
|
7101
|
+
await client.connect(transport, {
|
|
7102
|
+
timeout: 6e4 * 10
|
|
7103
|
+
});
|
|
7104
|
+
return client;
|
|
6961
7105
|
}
|
|
6962
|
-
var cleanupAllPooledClients = async () => {
|
|
6963
|
-
const entries = Array.from(mcpClientPool.entries());
|
|
6964
|
-
mcpClientPool.clear();
|
|
6965
|
-
await Promise.all(entries.map(async ([, { client }]) => {
|
|
6966
|
-
try {
|
|
6967
|
-
await client.close();
|
|
6968
|
-
} catch (err) {
|
|
6969
|
-
console.error("Error closing MCP client:", err);
|
|
6970
|
-
}
|
|
6971
|
-
}));
|
|
6972
|
-
};
|
|
6973
|
-
import_node_process4.default.once?.("exit", () => {
|
|
6974
|
-
cleanupAllPooledClients();
|
|
6975
|
-
});
|
|
6976
|
-
import_node_process4.default.once?.("SIGINT", () => {
|
|
6977
|
-
cleanupAllPooledClients().finally(() => import_node_process4.default.exit(0));
|
|
6978
|
-
});
|
|
6979
7106
|
async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
6980
7107
|
const allTools = {};
|
|
6981
7108
|
const allClients = {};
|
|
6982
|
-
const
|
|
7109
|
+
const clientsToClose = [];
|
|
6983
7110
|
for (const [name, definition] of Object.entries(mcpConfig.mcpServers)) {
|
|
6984
7111
|
const def = definition;
|
|
6985
7112
|
if (def.disabled) continue;
|
|
6986
|
-
const defKey = shortHash(defSignature(def));
|
|
6987
|
-
const serverId = name;
|
|
6988
7113
|
try {
|
|
6989
|
-
const client = await
|
|
6990
|
-
|
|
6991
|
-
allClients[
|
|
7114
|
+
const client = await createMcpClient(def);
|
|
7115
|
+
clientsToClose.push(client);
|
|
7116
|
+
allClients[name] = client;
|
|
6992
7117
|
const { tools } = await client.listTools();
|
|
6993
7118
|
tools.forEach((tool2) => {
|
|
6994
7119
|
const toolNameWithScope = `${name}.${tool2.name}`;
|
|
6995
7120
|
const internalToolName = tool2.name;
|
|
6996
|
-
const rawToolId = `${
|
|
7121
|
+
const rawToolId = `${name}_${internalToolName}`;
|
|
6997
7122
|
const toolId = sanitizePropertyKey(rawToolId);
|
|
6998
7123
|
if (filterIn && !filterIn({
|
|
6999
7124
|
action: internalToolName,
|
|
@@ -7005,7 +7130,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
7005
7130
|
})) {
|
|
7006
7131
|
return;
|
|
7007
7132
|
}
|
|
7008
|
-
const execute = (args) => allClients[
|
|
7133
|
+
const execute = (args) => allClients[name].callTool({
|
|
7009
7134
|
name: internalToolName,
|
|
7010
7135
|
arguments: args
|
|
7011
7136
|
}, void 0, {
|
|
@@ -7022,10 +7147,12 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
7022
7147
|
}
|
|
7023
7148
|
}
|
|
7024
7149
|
const cleanupClients = async () => {
|
|
7025
|
-
await Promise.all(
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7150
|
+
await Promise.all(clientsToClose.map((client) => {
|
|
7151
|
+
try {
|
|
7152
|
+
return client.close();
|
|
7153
|
+
} catch {
|
|
7154
|
+
}
|
|
7155
|
+
}));
|
|
7029
7156
|
};
|
|
7030
7157
|
return {
|
|
7031
7158
|
tools: allTools,
|
|
@@ -10782,7 +10909,7 @@ Usage:
|
|
|
10782
10909
|
- ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
|
|
10783
10910
|
- ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
|
|
10784
10911
|
|
|
10785
|
-
Note: For scripts
|
|
10912
|
+
Note: For scripts/, use the bash tool with the script path to execute.`;
|
|
10786
10913
|
}
|
|
10787
10914
|
function createSkillsPlugin(options) {
|
|
10788
10915
|
const { paths } = options;
|
|
@@ -10890,11 +11017,15 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
10890
11017
|
try {
|
|
10891
11018
|
const content = await (0, import_promises2.readFile)((0, import_node_path4.join)(meta.basePath, "SKILL.md"), "utf-8");
|
|
10892
11019
|
const body = extractBody(content);
|
|
11020
|
+
const skillPathInfo = `
|
|
11021
|
+
---
|
|
11022
|
+
Skill path: ${meta.basePath}
|
|
11023
|
+
`;
|
|
10893
11024
|
return {
|
|
10894
11025
|
content: [
|
|
10895
11026
|
{
|
|
10896
11027
|
type: "text",
|
|
10897
|
-
text: body
|
|
11028
|
+
text: body + skillPathInfo
|
|
10898
11029
|
}
|
|
10899
11030
|
]
|
|
10900
11031
|
};
|
|
@@ -10921,6 +11052,152 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
10921
11052
|
};
|
|
10922
11053
|
}
|
|
10923
11054
|
|
|
11055
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/bash.js
|
|
11056
|
+
var import_node_child_process = require("node:child_process");
|
|
11057
|
+
var import_node_process7 = __toESM(require("node:process"), 1);
|
|
11058
|
+
var DEFAULT_MAX_BYTES = 1e5;
|
|
11059
|
+
var DEFAULT_MAX_LINES = 2e3;
|
|
11060
|
+
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
11061
|
+
function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
|
|
11062
|
+
const fullOutput = (stderr ? `STDERR:
|
|
11063
|
+
${stderr}
|
|
11064
|
+
|
|
11065
|
+
STDOUT:
|
|
11066
|
+
` : "") + stdout;
|
|
11067
|
+
const lines = fullOutput.split("\n");
|
|
11068
|
+
if (lines.length > maxLines) {
|
|
11069
|
+
const truncatedLines = lines.slice(-maxLines);
|
|
11070
|
+
return {
|
|
11071
|
+
output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
|
|
11072
|
+
|
|
11073
|
+
` + truncatedLines.join("\n"),
|
|
11074
|
+
truncated: true
|
|
11075
|
+
};
|
|
11076
|
+
}
|
|
11077
|
+
if (fullOutput.length > maxBytes) {
|
|
11078
|
+
const truncatedBytes = fullOutput.slice(-maxBytes);
|
|
11079
|
+
return {
|
|
11080
|
+
output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
|
|
11081
|
+
|
|
11082
|
+
` + truncatedBytes,
|
|
11083
|
+
truncated: true
|
|
11084
|
+
};
|
|
11085
|
+
}
|
|
11086
|
+
return {
|
|
11087
|
+
output: fullOutput,
|
|
11088
|
+
truncated: false
|
|
11089
|
+
};
|
|
11090
|
+
}
|
|
11091
|
+
function executeBash(command, cwd2, timeoutMs) {
|
|
11092
|
+
return new Promise((resolve5) => {
|
|
11093
|
+
const stdout = [];
|
|
11094
|
+
const stderr = [];
|
|
11095
|
+
const proc = (0, import_node_child_process.spawn)("bash", [
|
|
11096
|
+
"-c",
|
|
11097
|
+
command
|
|
11098
|
+
], {
|
|
11099
|
+
cwd: cwd2,
|
|
11100
|
+
stdio: [
|
|
11101
|
+
"ignore",
|
|
11102
|
+
"pipe",
|
|
11103
|
+
"pipe"
|
|
11104
|
+
]
|
|
11105
|
+
});
|
|
11106
|
+
proc.stdout?.on("data", (data) => {
|
|
11107
|
+
stdout.push(data.toString());
|
|
11108
|
+
});
|
|
11109
|
+
proc.stderr?.on("data", (data) => {
|
|
11110
|
+
stderr.push(data.toString());
|
|
11111
|
+
});
|
|
11112
|
+
proc.on("close", (code) => {
|
|
11113
|
+
resolve5({
|
|
11114
|
+
stdout: stdout.join(""),
|
|
11115
|
+
stderr: stderr.join(""),
|
|
11116
|
+
exitCode: code
|
|
11117
|
+
});
|
|
11118
|
+
});
|
|
11119
|
+
proc.on("error", (err) => {
|
|
11120
|
+
resolve5({
|
|
11121
|
+
stdout: "",
|
|
11122
|
+
stderr: err.message,
|
|
11123
|
+
exitCode: null
|
|
11124
|
+
});
|
|
11125
|
+
});
|
|
11126
|
+
setTimeout(() => {
|
|
11127
|
+
proc.kill("SIGTERM");
|
|
11128
|
+
resolve5({
|
|
11129
|
+
stdout: stdout.join(""),
|
|
11130
|
+
stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
|
|
11131
|
+
exitCode: null
|
|
11132
|
+
});
|
|
11133
|
+
}, timeoutMs);
|
|
11134
|
+
});
|
|
11135
|
+
}
|
|
11136
|
+
function createBashPlugin(options = {}) {
|
|
11137
|
+
const { maxBytes, maxLines, timeoutMs } = {
|
|
11138
|
+
maxBytes: DEFAULT_MAX_BYTES,
|
|
11139
|
+
maxLines: DEFAULT_MAX_LINES,
|
|
11140
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
11141
|
+
...options
|
|
11142
|
+
};
|
|
11143
|
+
let serverRef = null;
|
|
11144
|
+
return {
|
|
11145
|
+
name: "plugin-bash",
|
|
11146
|
+
version: "1.0.0",
|
|
11147
|
+
// Store server reference for tool registration
|
|
11148
|
+
configureServer: (server) => {
|
|
11149
|
+
serverRef = server;
|
|
11150
|
+
},
|
|
11151
|
+
// Register bash tool with agent name prefix
|
|
11152
|
+
composeStart: (context2) => {
|
|
11153
|
+
if (!serverRef) return;
|
|
11154
|
+
const agentName = context2.serverName;
|
|
11155
|
+
const toolName = `${agentName}__bash`;
|
|
11156
|
+
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.", {
|
|
11157
|
+
type: "object",
|
|
11158
|
+
properties: {
|
|
11159
|
+
command: {
|
|
11160
|
+
type: "string",
|
|
11161
|
+
description: "The bash command to execute"
|
|
11162
|
+
},
|
|
11163
|
+
cwd: {
|
|
11164
|
+
type: "string",
|
|
11165
|
+
description: "Optional: Working directory for the command (defaults to current directory)"
|
|
11166
|
+
}
|
|
11167
|
+
},
|
|
11168
|
+
required: [
|
|
11169
|
+
"command"
|
|
11170
|
+
]
|
|
11171
|
+
}, async (args) => {
|
|
11172
|
+
const cwd2 = args.cwd || import_node_process7.default.cwd();
|
|
11173
|
+
const result = await executeBash(args.command, cwd2, timeoutMs);
|
|
11174
|
+
const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
|
|
11175
|
+
let finalOutput = output;
|
|
11176
|
+
if (result.exitCode !== null && result.exitCode !== 0) {
|
|
11177
|
+
finalOutput = `[EXIT CODE: ${result.exitCode}]
|
|
11178
|
+
` + finalOutput;
|
|
11179
|
+
}
|
|
11180
|
+
if (truncated) {
|
|
11181
|
+
finalOutput += `
|
|
11182
|
+
|
|
11183
|
+
[Note: Output was truncated]`;
|
|
11184
|
+
}
|
|
11185
|
+
return {
|
|
11186
|
+
content: [
|
|
11187
|
+
{
|
|
11188
|
+
type: "text",
|
|
11189
|
+
text: finalOutput
|
|
11190
|
+
}
|
|
11191
|
+
],
|
|
11192
|
+
isError: result.exitCode !== null && result.exitCode !== 0
|
|
11193
|
+
};
|
|
11194
|
+
}, {
|
|
11195
|
+
internal: true
|
|
11196
|
+
});
|
|
11197
|
+
}
|
|
11198
|
+
};
|
|
11199
|
+
}
|
|
11200
|
+
|
|
10924
11201
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
10925
11202
|
var import_plugin_code_execution = require("@mcpc-tech/plugin-code-execution");
|
|
10926
11203
|
|
|
@@ -11765,12 +12042,29 @@ function writeFoldedLines(count) {
|
|
|
11765
12042
|
if (count > 1) return "\n".repeat(count - 1);
|
|
11766
12043
|
return "";
|
|
11767
12044
|
}
|
|
12045
|
+
var Scanner = class {
|
|
12046
|
+
source;
|
|
12047
|
+
#length;
|
|
12048
|
+
position = 0;
|
|
12049
|
+
constructor(source) {
|
|
12050
|
+
source += "\0";
|
|
12051
|
+
this.source = source;
|
|
12052
|
+
this.#length = source.length;
|
|
12053
|
+
}
|
|
12054
|
+
peek(offset = 0) {
|
|
12055
|
+
return this.source.charCodeAt(this.position + offset);
|
|
12056
|
+
}
|
|
12057
|
+
next() {
|
|
12058
|
+
this.position += 1;
|
|
12059
|
+
}
|
|
12060
|
+
eof() {
|
|
12061
|
+
return this.position >= this.#length - 1;
|
|
12062
|
+
}
|
|
12063
|
+
};
|
|
11768
12064
|
var LoaderState = class {
|
|
11769
|
-
|
|
11770
|
-
length;
|
|
12065
|
+
#scanner;
|
|
11771
12066
|
lineIndent = 0;
|
|
11772
12067
|
lineStart = 0;
|
|
11773
|
-
position = 0;
|
|
11774
12068
|
line = 0;
|
|
11775
12069
|
onWarning;
|
|
11776
12070
|
allowDuplicateKeys;
|
|
@@ -11780,44 +12074,40 @@ var LoaderState = class {
|
|
|
11780
12074
|
tagMap = /* @__PURE__ */ new Map();
|
|
11781
12075
|
anchorMap = /* @__PURE__ */ new Map();
|
|
11782
12076
|
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
11783
|
-
this
|
|
12077
|
+
this.#scanner = new Scanner(input);
|
|
11784
12078
|
this.onWarning = onWarning;
|
|
11785
12079
|
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
11786
12080
|
this.implicitTypes = schema.implicitTypes;
|
|
11787
12081
|
this.typeMap = schema.typeMap;
|
|
11788
|
-
this.length = input.length;
|
|
11789
12082
|
this.readIndent();
|
|
11790
12083
|
}
|
|
11791
12084
|
skipWhitespaces() {
|
|
11792
|
-
let ch = this.peek();
|
|
12085
|
+
let ch = this.#scanner.peek();
|
|
11793
12086
|
while (isWhiteSpace(ch)) {
|
|
11794
|
-
|
|
12087
|
+
this.#scanner.next();
|
|
12088
|
+
ch = this.#scanner.peek();
|
|
11795
12089
|
}
|
|
11796
12090
|
}
|
|
11797
12091
|
skipComment() {
|
|
11798
|
-
let ch = this.peek();
|
|
12092
|
+
let ch = this.#scanner.peek();
|
|
11799
12093
|
if (ch !== SHARP) return;
|
|
11800
|
-
|
|
12094
|
+
this.#scanner.next();
|
|
12095
|
+
ch = this.#scanner.peek();
|
|
11801
12096
|
while (ch !== 0 && !isEOL(ch)) {
|
|
11802
|
-
|
|
12097
|
+
this.#scanner.next();
|
|
12098
|
+
ch = this.#scanner.peek();
|
|
11803
12099
|
}
|
|
11804
12100
|
}
|
|
11805
12101
|
readIndent() {
|
|
11806
|
-
let
|
|
11807
|
-
while (
|
|
12102
|
+
let ch = this.#scanner.peek();
|
|
12103
|
+
while (ch === SPACE) {
|
|
11808
12104
|
this.lineIndent += 1;
|
|
11809
|
-
|
|
12105
|
+
this.#scanner.next();
|
|
12106
|
+
ch = this.#scanner.peek();
|
|
11810
12107
|
}
|
|
11811
12108
|
}
|
|
11812
|
-
peek(offset = 0) {
|
|
11813
|
-
return this.input.charCodeAt(this.position + offset);
|
|
11814
|
-
}
|
|
11815
|
-
next() {
|
|
11816
|
-
this.position += 1;
|
|
11817
|
-
return this.peek();
|
|
11818
|
-
}
|
|
11819
12109
|
#createError(message) {
|
|
11820
|
-
const mark = markToString(this.
|
|
12110
|
+
const mark = markToString(this.#scanner.source, this.#scanner.position, this.line, this.#scanner.position - this.lineStart);
|
|
11821
12111
|
return new SyntaxError(`${message} ${mark}`);
|
|
11822
12112
|
}
|
|
11823
12113
|
dispatchWarning(message) {
|
|
@@ -11862,7 +12152,7 @@ var LoaderState = class {
|
|
|
11862
12152
|
}
|
|
11863
12153
|
captureSegment(start, end, checkJson) {
|
|
11864
12154
|
if (start < end) {
|
|
11865
|
-
const result = this.
|
|
12155
|
+
const result = this.#scanner.source.slice(start, end);
|
|
11866
12156
|
if (checkJson) {
|
|
11867
12157
|
for (let position = 0; position < result.length; position++) {
|
|
11868
12158
|
const character = result.charCodeAt(position);
|
|
@@ -11880,21 +12170,21 @@ var LoaderState = class {
|
|
|
11880
12170
|
let detected = false;
|
|
11881
12171
|
const result = [];
|
|
11882
12172
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
11883
|
-
let ch = this.peek();
|
|
12173
|
+
let ch = this.#scanner.peek();
|
|
11884
12174
|
while (ch !== 0) {
|
|
11885
12175
|
if (ch !== MINUS) {
|
|
11886
12176
|
break;
|
|
11887
12177
|
}
|
|
11888
|
-
const following = this.peek(1);
|
|
12178
|
+
const following = this.#scanner.peek(1);
|
|
11889
12179
|
if (!isWhiteSpaceOrEOL(following)) {
|
|
11890
12180
|
break;
|
|
11891
12181
|
}
|
|
11892
12182
|
detected = true;
|
|
11893
|
-
this.
|
|
12183
|
+
this.#scanner.next();
|
|
11894
12184
|
if (this.skipSeparationSpace(true, -1)) {
|
|
11895
12185
|
if (this.lineIndent <= nodeIndent) {
|
|
11896
12186
|
result.push(null);
|
|
11897
|
-
ch = this.peek();
|
|
12187
|
+
ch = this.#scanner.peek();
|
|
11898
12188
|
continue;
|
|
11899
12189
|
}
|
|
11900
12190
|
}
|
|
@@ -11907,7 +12197,7 @@ var LoaderState = class {
|
|
|
11907
12197
|
});
|
|
11908
12198
|
if (newState) result.push(newState.result);
|
|
11909
12199
|
this.skipSeparationSpace(true, -1);
|
|
11910
|
-
ch = this.peek();
|
|
12200
|
+
ch = this.#scanner.peek();
|
|
11911
12201
|
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
|
|
11912
12202
|
throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
11913
12203
|
} else if (this.lineIndent < nodeIndent) {
|
|
@@ -11963,7 +12253,7 @@ var LoaderState = class {
|
|
|
11963
12253
|
} else {
|
|
11964
12254
|
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
11965
12255
|
this.line = startLine || this.line;
|
|
11966
|
-
this.position = startPos || this.position;
|
|
12256
|
+
this.#scanner.position = startPos || this.#scanner.position;
|
|
11967
12257
|
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
11968
12258
|
}
|
|
11969
12259
|
Object.defineProperty(result, keyNode, {
|
|
@@ -11977,37 +12267,37 @@ var LoaderState = class {
|
|
|
11977
12267
|
return result;
|
|
11978
12268
|
}
|
|
11979
12269
|
readLineBreak() {
|
|
11980
|
-
const ch = this.peek();
|
|
12270
|
+
const ch = this.#scanner.peek();
|
|
11981
12271
|
if (ch === LINE_FEED) {
|
|
11982
|
-
this.
|
|
12272
|
+
this.#scanner.next();
|
|
11983
12273
|
} else if (ch === CARRIAGE_RETURN) {
|
|
11984
|
-
this.
|
|
11985
|
-
if (this.peek() === LINE_FEED) {
|
|
11986
|
-
this.
|
|
12274
|
+
this.#scanner.next();
|
|
12275
|
+
if (this.#scanner.peek() === LINE_FEED) {
|
|
12276
|
+
this.#scanner.next();
|
|
11987
12277
|
}
|
|
11988
12278
|
} else {
|
|
11989
12279
|
throw this.#createError("Cannot read line: line break not found");
|
|
11990
12280
|
}
|
|
11991
12281
|
this.line += 1;
|
|
11992
|
-
this.lineStart = this.position;
|
|
12282
|
+
this.lineStart = this.#scanner.position;
|
|
11993
12283
|
}
|
|
11994
12284
|
skipSeparationSpace(allowComments, checkIndent) {
|
|
11995
12285
|
let lineBreaks = 0;
|
|
11996
|
-
let ch = this.peek();
|
|
12286
|
+
let ch = this.#scanner.peek();
|
|
11997
12287
|
while (ch !== 0) {
|
|
11998
12288
|
this.skipWhitespaces();
|
|
11999
|
-
ch = this.peek();
|
|
12289
|
+
ch = this.#scanner.peek();
|
|
12000
12290
|
if (allowComments) {
|
|
12001
12291
|
this.skipComment();
|
|
12002
|
-
ch = this.peek();
|
|
12292
|
+
ch = this.#scanner.peek();
|
|
12003
12293
|
}
|
|
12004
12294
|
if (isEOL(ch)) {
|
|
12005
12295
|
this.readLineBreak();
|
|
12006
|
-
ch = this.peek();
|
|
12296
|
+
ch = this.#scanner.peek();
|
|
12007
12297
|
lineBreaks++;
|
|
12008
12298
|
this.lineIndent = 0;
|
|
12009
12299
|
this.readIndent();
|
|
12010
|
-
ch = this.peek();
|
|
12300
|
+
ch = this.#scanner.peek();
|
|
12011
12301
|
} else {
|
|
12012
12302
|
break;
|
|
12013
12303
|
}
|
|
@@ -12018,9 +12308,9 @@ var LoaderState = class {
|
|
|
12018
12308
|
return lineBreaks;
|
|
12019
12309
|
}
|
|
12020
12310
|
testDocumentSeparator() {
|
|
12021
|
-
let ch = this.peek();
|
|
12022
|
-
if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) {
|
|
12023
|
-
ch = this.peek(3);
|
|
12311
|
+
let ch = this.#scanner.peek();
|
|
12312
|
+
if ((ch === MINUS || ch === DOT) && ch === this.#scanner.peek(1) && ch === this.#scanner.peek(2)) {
|
|
12313
|
+
ch = this.#scanner.peek(3);
|
|
12024
12314
|
if (ch === 0 || isWhiteSpaceOrEOL(ch)) {
|
|
12025
12315
|
return true;
|
|
12026
12316
|
}
|
|
@@ -12028,34 +12318,34 @@ var LoaderState = class {
|
|
|
12028
12318
|
return false;
|
|
12029
12319
|
}
|
|
12030
12320
|
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
12031
|
-
let ch = this.peek();
|
|
12321
|
+
let ch = this.#scanner.peek();
|
|
12032
12322
|
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) {
|
|
12033
12323
|
return;
|
|
12034
12324
|
}
|
|
12035
12325
|
let following;
|
|
12036
12326
|
if (ch === QUESTION || ch === MINUS) {
|
|
12037
|
-
following = this.peek(1);
|
|
12327
|
+
following = this.#scanner.peek(1);
|
|
12038
12328
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
12039
12329
|
return;
|
|
12040
12330
|
}
|
|
12041
12331
|
}
|
|
12042
12332
|
let result = "";
|
|
12043
|
-
let captureEnd = this.position;
|
|
12044
|
-
let captureStart = this.position;
|
|
12333
|
+
let captureEnd = this.#scanner.position;
|
|
12334
|
+
let captureStart = this.#scanner.position;
|
|
12045
12335
|
let hasPendingContent = false;
|
|
12046
12336
|
let line = 0;
|
|
12047
12337
|
while (ch !== 0) {
|
|
12048
12338
|
if (ch === COLON) {
|
|
12049
|
-
following = this.peek(1);
|
|
12339
|
+
following = this.#scanner.peek(1);
|
|
12050
12340
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
12051
12341
|
break;
|
|
12052
12342
|
}
|
|
12053
12343
|
} else if (ch === SHARP) {
|
|
12054
|
-
const preceding = this.peek(-1);
|
|
12344
|
+
const preceding = this.#scanner.peek(-1);
|
|
12055
12345
|
if (isWhiteSpaceOrEOL(preceding)) {
|
|
12056
12346
|
break;
|
|
12057
12347
|
}
|
|
12058
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
12348
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
12059
12349
|
break;
|
|
12060
12350
|
} else if (isEOL(ch)) {
|
|
12061
12351
|
line = this.line;
|
|
@@ -12064,10 +12354,10 @@ var LoaderState = class {
|
|
|
12064
12354
|
this.skipSeparationSpace(false, -1);
|
|
12065
12355
|
if (this.lineIndent >= nodeIndent) {
|
|
12066
12356
|
hasPendingContent = true;
|
|
12067
|
-
ch = this.peek();
|
|
12357
|
+
ch = this.#scanner.peek();
|
|
12068
12358
|
continue;
|
|
12069
12359
|
} else {
|
|
12070
|
-
this.position = captureEnd;
|
|
12360
|
+
this.#scanner.position = captureEnd;
|
|
12071
12361
|
this.line = line;
|
|
12072
12362
|
this.lineStart = lineStart;
|
|
12073
12363
|
this.lineIndent = lineIndent;
|
|
@@ -12078,13 +12368,14 @@ var LoaderState = class {
|
|
|
12078
12368
|
const segment2 = this.captureSegment(captureStart, captureEnd, false);
|
|
12079
12369
|
if (segment2) result += segment2;
|
|
12080
12370
|
result += writeFoldedLines(this.line - line);
|
|
12081
|
-
captureStart = captureEnd = this.position;
|
|
12371
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12082
12372
|
hasPendingContent = false;
|
|
12083
12373
|
}
|
|
12084
12374
|
if (!isWhiteSpace(ch)) {
|
|
12085
|
-
captureEnd = this.position + 1;
|
|
12375
|
+
captureEnd = this.#scanner.position + 1;
|
|
12086
12376
|
}
|
|
12087
|
-
|
|
12377
|
+
this.#scanner.next();
|
|
12378
|
+
ch = this.#scanner.peek();
|
|
12088
12379
|
}
|
|
12089
12380
|
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
12090
12381
|
if (segment) result += segment;
|
|
@@ -12097,22 +12388,23 @@ var LoaderState = class {
|
|
|
12097
12388
|
};
|
|
12098
12389
|
}
|
|
12099
12390
|
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
12100
|
-
let ch = this.peek();
|
|
12391
|
+
let ch = this.#scanner.peek();
|
|
12101
12392
|
if (ch !== SINGLE_QUOTE) return;
|
|
12102
12393
|
let result = "";
|
|
12103
|
-
this.
|
|
12104
|
-
let captureStart = this.position;
|
|
12105
|
-
let captureEnd = this.position;
|
|
12106
|
-
ch = this.peek();
|
|
12394
|
+
this.#scanner.next();
|
|
12395
|
+
let captureStart = this.#scanner.position;
|
|
12396
|
+
let captureEnd = this.#scanner.position;
|
|
12397
|
+
ch = this.#scanner.peek();
|
|
12107
12398
|
while (ch !== 0) {
|
|
12108
12399
|
if (ch === SINGLE_QUOTE) {
|
|
12109
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12400
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12110
12401
|
if (segment) result += segment;
|
|
12111
|
-
|
|
12402
|
+
this.#scanner.next();
|
|
12403
|
+
ch = this.#scanner.peek();
|
|
12112
12404
|
if (ch === SINGLE_QUOTE) {
|
|
12113
|
-
captureStart = this.position;
|
|
12114
|
-
this.
|
|
12115
|
-
captureEnd = this.position;
|
|
12405
|
+
captureStart = this.#scanner.position;
|
|
12406
|
+
this.#scanner.next();
|
|
12407
|
+
captureEnd = this.#scanner.position;
|
|
12116
12408
|
} else {
|
|
12117
12409
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12118
12410
|
return {
|
|
@@ -12126,31 +12418,31 @@ var LoaderState = class {
|
|
|
12126
12418
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
12127
12419
|
if (segment) result += segment;
|
|
12128
12420
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
12129
|
-
captureStart = captureEnd = this.position;
|
|
12130
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12421
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12422
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12131
12423
|
throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
12132
12424
|
} else {
|
|
12133
|
-
this.
|
|
12134
|
-
captureEnd = this.position;
|
|
12425
|
+
this.#scanner.next();
|
|
12426
|
+
captureEnd = this.#scanner.position;
|
|
12135
12427
|
}
|
|
12136
|
-
ch = this.peek();
|
|
12428
|
+
ch = this.#scanner.peek();
|
|
12137
12429
|
}
|
|
12138
12430
|
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
12139
12431
|
}
|
|
12140
12432
|
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
12141
|
-
let ch = this.peek();
|
|
12433
|
+
let ch = this.#scanner.peek();
|
|
12142
12434
|
if (ch !== DOUBLE_QUOTE) return;
|
|
12143
12435
|
let result = "";
|
|
12144
|
-
this.
|
|
12145
|
-
let captureEnd = this.position;
|
|
12146
|
-
let captureStart = this.position;
|
|
12436
|
+
this.#scanner.next();
|
|
12437
|
+
let captureEnd = this.#scanner.position;
|
|
12438
|
+
let captureStart = this.#scanner.position;
|
|
12147
12439
|
let tmp;
|
|
12148
|
-
ch = this.peek();
|
|
12440
|
+
ch = this.#scanner.peek();
|
|
12149
12441
|
while (ch !== 0) {
|
|
12150
12442
|
if (ch === DOUBLE_QUOTE) {
|
|
12151
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12443
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12152
12444
|
if (segment) result += segment;
|
|
12153
|
-
this.
|
|
12445
|
+
this.#scanner.next();
|
|
12154
12446
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12155
12447
|
return {
|
|
12156
12448
|
tag,
|
|
@@ -12160,19 +12452,21 @@ var LoaderState = class {
|
|
|
12160
12452
|
};
|
|
12161
12453
|
}
|
|
12162
12454
|
if (ch === BACKSLASH) {
|
|
12163
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12455
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12164
12456
|
if (segment) result += segment;
|
|
12165
|
-
|
|
12457
|
+
this.#scanner.next();
|
|
12458
|
+
ch = this.#scanner.peek();
|
|
12166
12459
|
if (isEOL(ch)) {
|
|
12167
12460
|
this.skipSeparationSpace(false, nodeIndent);
|
|
12168
12461
|
} else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
12169
12462
|
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
12170
|
-
this.
|
|
12463
|
+
this.#scanner.next();
|
|
12171
12464
|
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
12172
12465
|
let hexLength = tmp;
|
|
12173
12466
|
let hexResult = 0;
|
|
12174
12467
|
for (; hexLength > 0; hexLength--) {
|
|
12175
|
-
|
|
12468
|
+
this.#scanner.next();
|
|
12469
|
+
ch = this.#scanner.peek();
|
|
12176
12470
|
if ((tmp = hexCharCodeToNumber(ch)) >= 0) {
|
|
12177
12471
|
hexResult = (hexResult << 4) + tmp;
|
|
12178
12472
|
} else {
|
|
@@ -12180,28 +12474,28 @@ var LoaderState = class {
|
|
|
12180
12474
|
}
|
|
12181
12475
|
}
|
|
12182
12476
|
result += codepointToChar(hexResult);
|
|
12183
|
-
this.
|
|
12477
|
+
this.#scanner.next();
|
|
12184
12478
|
} else {
|
|
12185
12479
|
throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
12186
12480
|
}
|
|
12187
|
-
captureStart = captureEnd = this.position;
|
|
12481
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12188
12482
|
} else if (isEOL(ch)) {
|
|
12189
12483
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
12190
12484
|
if (segment) result += segment;
|
|
12191
12485
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
12192
|
-
captureStart = captureEnd = this.position;
|
|
12193
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12486
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12487
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12194
12488
|
throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
12195
12489
|
} else {
|
|
12196
|
-
this.
|
|
12197
|
-
captureEnd = this.position;
|
|
12490
|
+
this.#scanner.next();
|
|
12491
|
+
captureEnd = this.#scanner.position;
|
|
12198
12492
|
}
|
|
12199
|
-
ch = this.peek();
|
|
12493
|
+
ch = this.#scanner.peek();
|
|
12200
12494
|
}
|
|
12201
12495
|
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
12202
12496
|
}
|
|
12203
12497
|
readFlowCollection(tag, anchor, nodeIndent) {
|
|
12204
|
-
let ch = this.peek();
|
|
12498
|
+
let ch = this.#scanner.peek();
|
|
12205
12499
|
let terminator;
|
|
12206
12500
|
let isMapping = true;
|
|
12207
12501
|
let result = {};
|
|
@@ -12215,7 +12509,8 @@ var LoaderState = class {
|
|
|
12215
12509
|
return;
|
|
12216
12510
|
}
|
|
12217
12511
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12218
|
-
|
|
12512
|
+
this.#scanner.next();
|
|
12513
|
+
ch = this.#scanner.peek();
|
|
12219
12514
|
let readNext = true;
|
|
12220
12515
|
let valueNode = null;
|
|
12221
12516
|
let keyNode = null;
|
|
@@ -12227,9 +12522,9 @@ var LoaderState = class {
|
|
|
12227
12522
|
const overridableKeys = /* @__PURE__ */ new Set();
|
|
12228
12523
|
while (ch !== 0) {
|
|
12229
12524
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12230
|
-
ch = this.peek();
|
|
12525
|
+
ch = this.#scanner.peek();
|
|
12231
12526
|
if (ch === terminator) {
|
|
12232
|
-
this.
|
|
12527
|
+
this.#scanner.next();
|
|
12233
12528
|
const kind = isMapping ? "mapping" : "sequence";
|
|
12234
12529
|
return {
|
|
12235
12530
|
tag,
|
|
@@ -12244,10 +12539,10 @@ var LoaderState = class {
|
|
|
12244
12539
|
keyTag = keyNode = valueNode = null;
|
|
12245
12540
|
isPair = isExplicitPair = false;
|
|
12246
12541
|
if (ch === QUESTION) {
|
|
12247
|
-
following = this.peek(1);
|
|
12542
|
+
following = this.#scanner.peek(1);
|
|
12248
12543
|
if (isWhiteSpaceOrEOL(following)) {
|
|
12249
12544
|
isPair = isExplicitPair = true;
|
|
12250
|
-
this.
|
|
12545
|
+
this.#scanner.next();
|
|
12251
12546
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12252
12547
|
}
|
|
12253
12548
|
}
|
|
@@ -12263,10 +12558,11 @@ var LoaderState = class {
|
|
|
12263
12558
|
keyNode = newState.result;
|
|
12264
12559
|
}
|
|
12265
12560
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12266
|
-
ch = this.peek();
|
|
12561
|
+
ch = this.#scanner.peek();
|
|
12267
12562
|
if ((isExplicitPair || this.line === line) && ch === COLON) {
|
|
12268
12563
|
isPair = true;
|
|
12269
|
-
|
|
12564
|
+
this.#scanner.next();
|
|
12565
|
+
ch = this.#scanner.peek();
|
|
12270
12566
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12271
12567
|
const newState2 = this.composeNode({
|
|
12272
12568
|
parentIndent: nodeIndent,
|
|
@@ -12284,10 +12580,11 @@ var LoaderState = class {
|
|
|
12284
12580
|
result.push(keyNode);
|
|
12285
12581
|
}
|
|
12286
12582
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12287
|
-
ch = this.peek();
|
|
12583
|
+
ch = this.#scanner.peek();
|
|
12288
12584
|
if (ch === COMMA) {
|
|
12289
12585
|
readNext = true;
|
|
12290
|
-
|
|
12586
|
+
this.#scanner.next();
|
|
12587
|
+
ch = this.#scanner.peek();
|
|
12291
12588
|
} else {
|
|
12292
12589
|
readNext = false;
|
|
12293
12590
|
}
|
|
@@ -12303,7 +12600,7 @@ var LoaderState = class {
|
|
|
12303
12600
|
let textIndent = nodeIndent;
|
|
12304
12601
|
let emptyLines = 0;
|
|
12305
12602
|
let atMoreIndented = false;
|
|
12306
|
-
let ch = this.peek();
|
|
12603
|
+
let ch = this.#scanner.peek();
|
|
12307
12604
|
let folding = false;
|
|
12308
12605
|
if (ch === VERTICAL_LINE) {
|
|
12309
12606
|
folding = false;
|
|
@@ -12315,7 +12612,8 @@ var LoaderState = class {
|
|
|
12315
12612
|
let result = "";
|
|
12316
12613
|
let tmp = 0;
|
|
12317
12614
|
while (ch !== 0) {
|
|
12318
|
-
|
|
12615
|
+
this.#scanner.next();
|
|
12616
|
+
ch = this.#scanner.peek();
|
|
12319
12617
|
if (ch === PLUS || ch === MINUS) {
|
|
12320
12618
|
if (CHOMPING_CLIP === chomping) {
|
|
12321
12619
|
chomping = ch === PLUS ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
@@ -12338,15 +12636,16 @@ var LoaderState = class {
|
|
|
12338
12636
|
if (isWhiteSpace(ch)) {
|
|
12339
12637
|
this.skipWhitespaces();
|
|
12340
12638
|
this.skipComment();
|
|
12341
|
-
ch = this.peek();
|
|
12639
|
+
ch = this.#scanner.peek();
|
|
12342
12640
|
}
|
|
12343
12641
|
while (ch !== 0) {
|
|
12344
12642
|
this.readLineBreak();
|
|
12345
12643
|
this.lineIndent = 0;
|
|
12346
|
-
ch = this.peek();
|
|
12644
|
+
ch = this.#scanner.peek();
|
|
12347
12645
|
while ((!detectedIndent || this.lineIndent < textIndent) && ch === SPACE) {
|
|
12348
12646
|
this.lineIndent++;
|
|
12349
|
-
|
|
12647
|
+
this.#scanner.next();
|
|
12648
|
+
ch = this.#scanner.peek();
|
|
12350
12649
|
}
|
|
12351
12650
|
if (!detectedIndent && this.lineIndent > textIndent) {
|
|
12352
12651
|
textIndent = this.lineIndent;
|
|
@@ -12385,11 +12684,12 @@ var LoaderState = class {
|
|
|
12385
12684
|
didReadContent = true;
|
|
12386
12685
|
detectedIndent = true;
|
|
12387
12686
|
emptyLines = 0;
|
|
12388
|
-
const captureStart = this.position;
|
|
12687
|
+
const captureStart = this.#scanner.position;
|
|
12389
12688
|
while (!isEOL(ch) && ch !== 0) {
|
|
12390
|
-
|
|
12689
|
+
this.#scanner.next();
|
|
12690
|
+
ch = this.#scanner.peek();
|
|
12391
12691
|
}
|
|
12392
|
-
const segment = this.captureSegment(captureStart, this.position, false);
|
|
12692
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, false);
|
|
12393
12693
|
if (segment) result += segment;
|
|
12394
12694
|
}
|
|
12395
12695
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
@@ -12412,11 +12712,11 @@ var LoaderState = class {
|
|
|
12412
12712
|
let atExplicitKey = false;
|
|
12413
12713
|
let detected = false;
|
|
12414
12714
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12415
|
-
let ch = this.peek();
|
|
12715
|
+
let ch = this.#scanner.peek();
|
|
12416
12716
|
while (ch !== 0) {
|
|
12417
|
-
const following = this.peek(1);
|
|
12717
|
+
const following = this.#scanner.peek(1);
|
|
12418
12718
|
line = this.line;
|
|
12419
|
-
pos = this.position;
|
|
12719
|
+
pos = this.#scanner.position;
|
|
12420
12720
|
if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) {
|
|
12421
12721
|
if (ch === QUESTION) {
|
|
12422
12722
|
if (atExplicitKey) {
|
|
@@ -12434,7 +12734,7 @@ var LoaderState = class {
|
|
|
12434
12734
|
} else {
|
|
12435
12735
|
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");
|
|
12436
12736
|
}
|
|
12437
|
-
this.
|
|
12737
|
+
this.#scanner.next();
|
|
12438
12738
|
ch = following;
|
|
12439
12739
|
} else {
|
|
12440
12740
|
const newState = this.composeNode({
|
|
@@ -12445,11 +12745,12 @@ var LoaderState = class {
|
|
|
12445
12745
|
});
|
|
12446
12746
|
if (!newState) break;
|
|
12447
12747
|
if (this.line === line) {
|
|
12448
|
-
ch = this.peek();
|
|
12748
|
+
ch = this.#scanner.peek();
|
|
12449
12749
|
this.skipWhitespaces();
|
|
12450
|
-
ch = this.peek();
|
|
12750
|
+
ch = this.#scanner.peek();
|
|
12451
12751
|
if (ch === COLON) {
|
|
12452
|
-
|
|
12752
|
+
this.#scanner.next();
|
|
12753
|
+
ch = this.#scanner.peek();
|
|
12453
12754
|
if (!isWhiteSpaceOrEOL(ch)) {
|
|
12454
12755
|
throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
12455
12756
|
}
|
|
@@ -12506,7 +12807,7 @@ var LoaderState = class {
|
|
|
12506
12807
|
keyTag = keyNode = valueNode = null;
|
|
12507
12808
|
}
|
|
12508
12809
|
this.skipSeparationSpace(true, -1);
|
|
12509
|
-
ch = this.peek();
|
|
12810
|
+
ch = this.#scanner.peek();
|
|
12510
12811
|
}
|
|
12511
12812
|
if (this.lineIndent > nodeIndent && ch !== 0) {
|
|
12512
12813
|
throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
@@ -12529,30 +12830,35 @@ var LoaderState = class {
|
|
|
12529
12830
|
let isNamed = false;
|
|
12530
12831
|
let tagHandle = "";
|
|
12531
12832
|
let tagName;
|
|
12532
|
-
let ch = this.peek();
|
|
12833
|
+
let ch = this.#scanner.peek();
|
|
12533
12834
|
if (ch !== EXCLAMATION) return;
|
|
12534
12835
|
if (tag !== null) {
|
|
12535
12836
|
throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
12536
12837
|
}
|
|
12537
|
-
|
|
12838
|
+
this.#scanner.next();
|
|
12839
|
+
ch = this.#scanner.peek();
|
|
12538
12840
|
if (ch === SMALLER_THAN) {
|
|
12539
12841
|
isVerbatim = true;
|
|
12540
|
-
|
|
12842
|
+
this.#scanner.next();
|
|
12843
|
+
ch = this.#scanner.peek();
|
|
12541
12844
|
} else if (ch === EXCLAMATION) {
|
|
12542
12845
|
isNamed = true;
|
|
12543
12846
|
tagHandle = "!!";
|
|
12544
|
-
|
|
12847
|
+
this.#scanner.next();
|
|
12848
|
+
ch = this.#scanner.peek();
|
|
12545
12849
|
} else {
|
|
12546
12850
|
tagHandle = "!";
|
|
12547
12851
|
}
|
|
12548
|
-
let position = this.position;
|
|
12852
|
+
let position = this.#scanner.position;
|
|
12549
12853
|
if (isVerbatim) {
|
|
12550
12854
|
do {
|
|
12551
|
-
|
|
12855
|
+
this.#scanner.next();
|
|
12856
|
+
ch = this.#scanner.peek();
|
|
12552
12857
|
} while (ch !== 0 && ch !== GREATER_THAN);
|
|
12553
|
-
if (this.
|
|
12554
|
-
tagName = this.
|
|
12555
|
-
|
|
12858
|
+
if (!this.#scanner.eof()) {
|
|
12859
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12860
|
+
this.#scanner.next();
|
|
12861
|
+
ch = this.#scanner.peek();
|
|
12556
12862
|
} else {
|
|
12557
12863
|
throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
12558
12864
|
}
|
|
@@ -12560,19 +12866,20 @@ var LoaderState = class {
|
|
|
12560
12866
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12561
12867
|
if (ch === EXCLAMATION) {
|
|
12562
12868
|
if (!isNamed) {
|
|
12563
|
-
tagHandle = this.
|
|
12869
|
+
tagHandle = this.#scanner.source.slice(position - 1, this.#scanner.position + 1);
|
|
12564
12870
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
12565
12871
|
throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
12566
12872
|
}
|
|
12567
12873
|
isNamed = true;
|
|
12568
|
-
position = this.position + 1;
|
|
12874
|
+
position = this.#scanner.position + 1;
|
|
12569
12875
|
} else {
|
|
12570
12876
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
12571
12877
|
}
|
|
12572
12878
|
}
|
|
12573
|
-
|
|
12879
|
+
this.#scanner.next();
|
|
12880
|
+
ch = this.#scanner.peek();
|
|
12574
12881
|
}
|
|
12575
|
-
tagName = this.
|
|
12882
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12576
12883
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
12577
12884
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
12578
12885
|
}
|
|
@@ -12592,32 +12899,36 @@ var LoaderState = class {
|
|
|
12592
12899
|
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
12593
12900
|
}
|
|
12594
12901
|
readAnchorProperty(anchor) {
|
|
12595
|
-
let ch = this.peek();
|
|
12902
|
+
let ch = this.#scanner.peek();
|
|
12596
12903
|
if (ch !== AMPERSAND) return;
|
|
12597
12904
|
if (anchor !== null) {
|
|
12598
12905
|
throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
12599
12906
|
}
|
|
12600
|
-
|
|
12601
|
-
|
|
12907
|
+
this.#scanner.next();
|
|
12908
|
+
ch = this.#scanner.peek();
|
|
12909
|
+
const position = this.#scanner.position;
|
|
12602
12910
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
12603
|
-
|
|
12911
|
+
this.#scanner.next();
|
|
12912
|
+
ch = this.#scanner.peek();
|
|
12604
12913
|
}
|
|
12605
|
-
if (this.position === position) {
|
|
12914
|
+
if (this.#scanner.position === position) {
|
|
12606
12915
|
throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
12607
12916
|
}
|
|
12608
|
-
return this.
|
|
12917
|
+
return this.#scanner.source.slice(position, this.#scanner.position);
|
|
12609
12918
|
}
|
|
12610
12919
|
readAlias() {
|
|
12611
|
-
if (this.peek() !== ASTERISK) return;
|
|
12612
|
-
|
|
12613
|
-
|
|
12920
|
+
if (this.#scanner.peek() !== ASTERISK) return;
|
|
12921
|
+
this.#scanner.next();
|
|
12922
|
+
let ch = this.#scanner.peek();
|
|
12923
|
+
const position = this.#scanner.position;
|
|
12614
12924
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
12615
|
-
|
|
12925
|
+
this.#scanner.next();
|
|
12926
|
+
ch = this.#scanner.peek();
|
|
12616
12927
|
}
|
|
12617
|
-
if (this.position === position) {
|
|
12928
|
+
if (this.#scanner.position === position) {
|
|
12618
12929
|
throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
12619
12930
|
}
|
|
12620
|
-
const alias = this.
|
|
12931
|
+
const alias = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12621
12932
|
if (!this.anchorMap.has(alias)) {
|
|
12622
12933
|
throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
12623
12934
|
}
|
|
@@ -12700,7 +13011,7 @@ var LoaderState = class {
|
|
|
12700
13011
|
const cond = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
|
|
12701
13012
|
const flowIndent = cond ? parentIndent : parentIndent + 1;
|
|
12702
13013
|
if (allowBlockCollections) {
|
|
12703
|
-
const blockIndent = this.position - this.lineStart;
|
|
13014
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
12704
13015
|
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
12705
13016
|
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
12706
13017
|
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
@@ -12734,7 +13045,7 @@ var LoaderState = class {
|
|
|
12734
13045
|
return this.resolveTag(plainScalarState);
|
|
12735
13046
|
}
|
|
12736
13047
|
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
12737
|
-
const blockIndent = this.position - this.lineStart;
|
|
13048
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
12738
13049
|
const newState2 = this.readBlockSequence(tag, anchor, blockIndent);
|
|
12739
13050
|
if (newState2) return this.resolveTag(newState2);
|
|
12740
13051
|
}
|
|
@@ -12749,20 +13060,22 @@ var LoaderState = class {
|
|
|
12749
13060
|
readDirectives() {
|
|
12750
13061
|
let hasDirectives = false;
|
|
12751
13062
|
let version = null;
|
|
12752
|
-
let ch = this.peek();
|
|
13063
|
+
let ch = this.#scanner.peek();
|
|
12753
13064
|
while (ch !== 0) {
|
|
12754
13065
|
this.skipSeparationSpace(true, -1);
|
|
12755
|
-
ch = this.peek();
|
|
13066
|
+
ch = this.#scanner.peek();
|
|
12756
13067
|
if (this.lineIndent > 0 || ch !== PERCENT) {
|
|
12757
13068
|
break;
|
|
12758
13069
|
}
|
|
12759
13070
|
hasDirectives = true;
|
|
12760
|
-
|
|
12761
|
-
|
|
13071
|
+
this.#scanner.next();
|
|
13072
|
+
ch = this.#scanner.peek();
|
|
13073
|
+
let position = this.#scanner.position;
|
|
12762
13074
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12763
|
-
|
|
13075
|
+
this.#scanner.next();
|
|
13076
|
+
ch = this.#scanner.peek();
|
|
12764
13077
|
}
|
|
12765
|
-
const directiveName = this.
|
|
13078
|
+
const directiveName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12766
13079
|
const directiveArgs = [];
|
|
12767
13080
|
if (directiveName.length < 1) {
|
|
12768
13081
|
throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
@@ -12770,13 +13083,14 @@ var LoaderState = class {
|
|
|
12770
13083
|
while (ch !== 0) {
|
|
12771
13084
|
this.skipWhitespaces();
|
|
12772
13085
|
this.skipComment();
|
|
12773
|
-
ch = this.peek();
|
|
13086
|
+
ch = this.#scanner.peek();
|
|
12774
13087
|
if (isEOL(ch)) break;
|
|
12775
|
-
position = this.position;
|
|
13088
|
+
position = this.#scanner.position;
|
|
12776
13089
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12777
|
-
|
|
13090
|
+
this.#scanner.next();
|
|
13091
|
+
ch = this.#scanner.peek();
|
|
12778
13092
|
}
|
|
12779
|
-
directiveArgs.push(this.
|
|
13093
|
+
directiveArgs.push(this.#scanner.source.slice(position, this.#scanner.position));
|
|
12780
13094
|
}
|
|
12781
13095
|
if (ch !== 0) this.readLineBreak();
|
|
12782
13096
|
switch (directiveName) {
|
|
@@ -12793,20 +13107,20 @@ var LoaderState = class {
|
|
|
12793
13107
|
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
12794
13108
|
break;
|
|
12795
13109
|
}
|
|
12796
|
-
ch = this.peek();
|
|
13110
|
+
ch = this.#scanner.peek();
|
|
12797
13111
|
}
|
|
12798
13112
|
return hasDirectives;
|
|
12799
13113
|
}
|
|
12800
13114
|
readDocument() {
|
|
12801
|
-
const documentStart = this.position;
|
|
13115
|
+
const documentStart = this.#scanner.position;
|
|
12802
13116
|
this.checkLineBreaks = false;
|
|
12803
13117
|
this.tagMap = /* @__PURE__ */ new Map();
|
|
12804
13118
|
this.anchorMap = /* @__PURE__ */ new Map();
|
|
12805
13119
|
const hasDirectives = this.readDirectives();
|
|
12806
13120
|
this.skipSeparationSpace(true, -1);
|
|
12807
13121
|
let result = null;
|
|
12808
|
-
if (this.lineIndent === 0 && this.peek() === MINUS && this.peek(1) === MINUS && this.peek(2) === MINUS) {
|
|
12809
|
-
this.position += 3;
|
|
13122
|
+
if (this.lineIndent === 0 && this.#scanner.peek() === MINUS && this.#scanner.peek(1) === MINUS && this.#scanner.peek(2) === MINUS) {
|
|
13123
|
+
this.#scanner.position += 3;
|
|
12810
13124
|
this.skipSeparationSpace(true, -1);
|
|
12811
13125
|
} else if (hasDirectives) {
|
|
12812
13126
|
throw this.#createError("Cannot read document: directives end mark is expected");
|
|
@@ -12819,21 +13133,21 @@ var LoaderState = class {
|
|
|
12819
13133
|
});
|
|
12820
13134
|
if (newState) result = newState.result;
|
|
12821
13135
|
this.skipSeparationSpace(true, -1);
|
|
12822
|
-
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.
|
|
13136
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.#scanner.source.slice(documentStart, this.#scanner.position))) {
|
|
12823
13137
|
this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
12824
13138
|
}
|
|
12825
|
-
if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12826
|
-
if (this.peek() === DOT) {
|
|
12827
|
-
this.position += 3;
|
|
13139
|
+
if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
13140
|
+
if (this.#scanner.peek() === DOT) {
|
|
13141
|
+
this.#scanner.position += 3;
|
|
12828
13142
|
this.skipSeparationSpace(true, -1);
|
|
12829
13143
|
}
|
|
12830
|
-
} else if (this.
|
|
13144
|
+
} else if (!this.#scanner.eof()) {
|
|
12831
13145
|
throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
12832
13146
|
}
|
|
12833
13147
|
return result;
|
|
12834
13148
|
}
|
|
12835
13149
|
*readDocuments() {
|
|
12836
|
-
while (this.
|
|
13150
|
+
while (!this.#scanner.eof()) {
|
|
12837
13151
|
yield this.readDocument();
|
|
12838
13152
|
}
|
|
12839
13153
|
}
|
|
@@ -12846,7 +13160,6 @@ function sanitizeInput(input) {
|
|
|
12846
13160
|
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
12847
13161
|
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
12848
13162
|
}
|
|
12849
|
-
input += "\0";
|
|
12850
13163
|
return input;
|
|
12851
13164
|
}
|
|
12852
13165
|
function parse(content, options = {}) {
|
|
@@ -12864,10 +13177,10 @@ function parse(content, options = {}) {
|
|
|
12864
13177
|
}
|
|
12865
13178
|
|
|
12866
13179
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
|
|
12867
|
-
var
|
|
13180
|
+
var import_node_process8 = __toESM(require("node:process"), 1);
|
|
12868
13181
|
function replaceEnvVars(str2) {
|
|
12869
13182
|
return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
|
|
12870
|
-
const value =
|
|
13183
|
+
const value = import_node_process8.default.env[varName];
|
|
12871
13184
|
if (value !== void 0) {
|
|
12872
13185
|
return value;
|
|
12873
13186
|
}
|
|
@@ -12966,17 +13279,18 @@ var defaultPlugin = markdownLoaderPlugin();
|
|
|
12966
13279
|
|
|
12967
13280
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
12968
13281
|
var import_node_path5 = require("node:path");
|
|
12969
|
-
var
|
|
13282
|
+
var import_node_process9 = __toESM(require("node:process"), 1);
|
|
12970
13283
|
var DEFAULT_SKILLS_PATHS = [
|
|
12971
13284
|
".agent/skills"
|
|
12972
13285
|
];
|
|
12973
13286
|
function getGlobalPlugins(skillsPaths) {
|
|
12974
|
-
const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(
|
|
13287
|
+
const resolvedPaths = skillsPaths.map((p2) => (0, import_node_path5.resolve)(import_node_process9.default.cwd(), p2));
|
|
12975
13288
|
return [
|
|
12976
13289
|
markdownLoaderPlugin(),
|
|
12977
13290
|
createSkillsPlugin({
|
|
12978
13291
|
paths: resolvedPaths
|
|
12979
|
-
})
|
|
13292
|
+
}),
|
|
13293
|
+
createBashPlugin()
|
|
12980
13294
|
];
|
|
12981
13295
|
}
|
|
12982
13296
|
function getDefaultAgents() {
|
|
@@ -13732,6 +14046,7 @@ data:
|
|
|
13732
14046
|
async handleGetRequest(req) {
|
|
13733
14047
|
const acceptHeader = req.headers.get("accept");
|
|
13734
14048
|
if (!acceptHeader?.includes("text/event-stream")) {
|
|
14049
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream"));
|
|
13735
14050
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept text/event-stream");
|
|
13736
14051
|
}
|
|
13737
14052
|
const sessionError = this.validateSession(req);
|
|
@@ -13749,6 +14064,7 @@ data:
|
|
|
13749
14064
|
}
|
|
13750
14065
|
}
|
|
13751
14066
|
if (this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
14067
|
+
this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session"));
|
|
13752
14068
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Only one SSE stream is allowed per session");
|
|
13753
14069
|
}
|
|
13754
14070
|
const encoder2 = new TextEncoder();
|
|
@@ -13788,6 +14104,7 @@ data:
|
|
|
13788
14104
|
*/
|
|
13789
14105
|
async replayEvents(lastEventId) {
|
|
13790
14106
|
if (!this._eventStore) {
|
|
14107
|
+
this.onerror?.(new Error("Event store not configured"));
|
|
13791
14108
|
return this.createJsonErrorResponse(400, -32e3, "Event store not configured");
|
|
13792
14109
|
}
|
|
13793
14110
|
try {
|
|
@@ -13795,9 +14112,11 @@ data:
|
|
|
13795
14112
|
if (this._eventStore.getStreamIdForEventId) {
|
|
13796
14113
|
streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
|
|
13797
14114
|
if (!streamId) {
|
|
14115
|
+
this.onerror?.(new Error("Invalid event ID format"));
|
|
13798
14116
|
return this.createJsonErrorResponse(400, -32e3, "Invalid event ID format");
|
|
13799
14117
|
}
|
|
13800
14118
|
if (this._streamMapping.get(streamId) !== void 0) {
|
|
14119
|
+
this.onerror?.(new Error("Conflict: Stream already has an active connection"));
|
|
13801
14120
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Stream already has an active connection");
|
|
13802
14121
|
}
|
|
13803
14122
|
}
|
|
@@ -13863,7 +14182,8 @@ data:
|
|
|
13863
14182
|
`;
|
|
13864
14183
|
controller.enqueue(encoder2.encode(eventData));
|
|
13865
14184
|
return true;
|
|
13866
|
-
} catch {
|
|
14185
|
+
} catch (error) {
|
|
14186
|
+
this.onerror?.(error);
|
|
13867
14187
|
return false;
|
|
13868
14188
|
}
|
|
13869
14189
|
}
|
|
@@ -13871,6 +14191,7 @@ data:
|
|
|
13871
14191
|
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
13872
14192
|
*/
|
|
13873
14193
|
handleUnsupportedRequest() {
|
|
14194
|
+
this.onerror?.(new Error("Method not allowed."));
|
|
13874
14195
|
return new Response(JSON.stringify({
|
|
13875
14196
|
jsonrpc: "2.0",
|
|
13876
14197
|
error: {
|
|
@@ -13893,14 +14214,17 @@ data:
|
|
|
13893
14214
|
try {
|
|
13894
14215
|
const acceptHeader = req.headers.get("accept");
|
|
13895
14216
|
if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
|
|
14217
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
|
|
13896
14218
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept both application/json and text/event-stream");
|
|
13897
14219
|
}
|
|
13898
14220
|
const ct = req.headers.get("content-type");
|
|
13899
14221
|
if (!ct || !ct.includes("application/json")) {
|
|
14222
|
+
this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
|
|
13900
14223
|
return this.createJsonErrorResponse(415, -32e3, "Unsupported Media Type: Content-Type must be application/json");
|
|
13901
14224
|
}
|
|
13902
14225
|
const requestInfo = {
|
|
13903
|
-
headers: Object.fromEntries(req.headers.entries())
|
|
14226
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
14227
|
+
url: new URL(req.url)
|
|
13904
14228
|
};
|
|
13905
14229
|
let rawMessage;
|
|
13906
14230
|
if (options?.parsedBody !== void 0) {
|
|
@@ -13909,6 +14233,7 @@ data:
|
|
|
13909
14233
|
try {
|
|
13910
14234
|
rawMessage = await req.json();
|
|
13911
14235
|
} catch {
|
|
14236
|
+
this.onerror?.(new Error("Parse error: Invalid JSON"));
|
|
13912
14237
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
|
|
13913
14238
|
}
|
|
13914
14239
|
}
|
|
@@ -13920,14 +14245,17 @@ data:
|
|
|
13920
14245
|
messages = [JSONRPCMessageSchema.parse(rawMessage)];
|
|
13921
14246
|
}
|
|
13922
14247
|
} catch {
|
|
14248
|
+
this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
|
|
13923
14249
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
|
|
13924
14250
|
}
|
|
13925
14251
|
const isInitializationRequest = messages.some(isInitializeRequest);
|
|
13926
14252
|
if (isInitializationRequest) {
|
|
13927
14253
|
if (this._initialized && this.sessionId !== void 0) {
|
|
14254
|
+
this.onerror?.(new Error("Invalid Request: Server already initialized"));
|
|
13928
14255
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
|
|
13929
14256
|
}
|
|
13930
14257
|
if (messages.length > 1) {
|
|
14258
|
+
this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed"));
|
|
13931
14259
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
|
|
13932
14260
|
}
|
|
13933
14261
|
this.sessionId = this.sessionIdGenerator?.();
|
|
@@ -14053,13 +14381,16 @@ data:
|
|
|
14053
14381
|
return void 0;
|
|
14054
14382
|
}
|
|
14055
14383
|
if (!this._initialized) {
|
|
14384
|
+
this.onerror?.(new Error("Bad Request: Server not initialized"));
|
|
14056
14385
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Server not initialized");
|
|
14057
14386
|
}
|
|
14058
14387
|
const sessionId = req.headers.get("mcp-session-id");
|
|
14059
14388
|
if (!sessionId) {
|
|
14389
|
+
this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required"));
|
|
14060
14390
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
14061
14391
|
}
|
|
14062
14392
|
if (sessionId !== this.sessionId) {
|
|
14393
|
+
this.onerror?.(new Error("Session not found"));
|
|
14063
14394
|
return this.createJsonErrorResponse(404, -32001, "Session not found");
|
|
14064
14395
|
}
|
|
14065
14396
|
return void 0;
|
|
@@ -14080,6 +14411,7 @@ data:
|
|
|
14080
14411
|
validateProtocolVersion(req) {
|
|
14081
14412
|
const protocolVersion = req.headers.get("mcp-protocol-version");
|
|
14082
14413
|
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
|
|
14414
|
+
this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
|
|
14083
14415
|
return this.createJsonErrorResponse(400, -32e3, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
|
|
14084
14416
|
}
|
|
14085
14417
|
return void 0;
|
|
@@ -14286,7 +14618,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
14286
14618
|
};
|
|
14287
14619
|
|
|
14288
14620
|
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
14289
|
-
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value
|
|
14621
|
+
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
14290
14622
|
var LETTER_REGEXP = /[A-Za-z]/;
|
|
14291
14623
|
var NUMBER_REGEXP = /-?\d+(\.\d*)?(e-?\d+)?$/;
|
|
14292
14624
|
var HYPHEN_REGEXP = /^(-|--)[^-]/;
|
|
@@ -14297,12 +14629,19 @@ var NON_WHITESPACE_REGEXP = /\S/;
|
|
|
14297
14629
|
function isNumber(string3) {
|
|
14298
14630
|
return NON_WHITESPACE_REGEXP.test(string3) && Number.isFinite(Number(string3));
|
|
14299
14631
|
}
|
|
14632
|
+
function isConstructorOrProto(obj, key) {
|
|
14633
|
+
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
|
|
14634
|
+
}
|
|
14300
14635
|
function setNested(object5, keys, value, collect = false) {
|
|
14301
14636
|
keys = [
|
|
14302
14637
|
...keys
|
|
14303
14638
|
];
|
|
14304
14639
|
const key = keys.pop();
|
|
14305
|
-
|
|
14640
|
+
for (const k of keys) {
|
|
14641
|
+
if (isConstructorOrProto(object5, k)) return;
|
|
14642
|
+
object5 = object5[k] ??= {};
|
|
14643
|
+
}
|
|
14644
|
+
if (isConstructorOrProto(object5, key)) return;
|
|
14306
14645
|
if (collect) {
|
|
14307
14646
|
const v = object5[key];
|
|
14308
14647
|
if (Array.isArray(v)) {
|
|
@@ -14433,7 +14772,7 @@ function parseArgs(args, options) {
|
|
|
14433
14772
|
let key = groups.key;
|
|
14434
14773
|
let value = groups.value;
|
|
14435
14774
|
if (doubleDash2) {
|
|
14436
|
-
if (value) {
|
|
14775
|
+
if (value != null) {
|
|
14437
14776
|
if (booleanSet.has(key)) value = parseBooleanString(value);
|
|
14438
14777
|
setArgument(key, value, arg, true);
|
|
14439
14778
|
continue;
|
|
@@ -14471,6 +14810,10 @@ function parseArgs(args, options) {
|
|
|
14471
14810
|
setArgument(letter, next, arg, true);
|
|
14472
14811
|
continue;
|
|
14473
14812
|
}
|
|
14813
|
+
if (next === "=") {
|
|
14814
|
+
setArgument(letter, "", arg, true);
|
|
14815
|
+
continue argsLoop;
|
|
14816
|
+
}
|
|
14474
14817
|
if (LETTER_REGEXP.test(letter)) {
|
|
14475
14818
|
const groups2 = VALUE_REGEXP.exec(next)?.groups;
|
|
14476
14819
|
if (groups2) {
|
|
@@ -14547,8 +14890,8 @@ function parseArgs(args, options) {
|
|
|
14547
14890
|
var import_promises4 = require("node:fs/promises");
|
|
14548
14891
|
var import_node_os3 = require("node:os");
|
|
14549
14892
|
var import_node_path6 = require("node:path");
|
|
14550
|
-
var
|
|
14551
|
-
var CLI_VERSION = "0.1.
|
|
14893
|
+
var import_node_process10 = __toESM(require("node:process"), 1);
|
|
14894
|
+
var CLI_VERSION = "0.1.52";
|
|
14552
14895
|
function extractServerName(command, commandArgs) {
|
|
14553
14896
|
for (const arg of commandArgs) {
|
|
14554
14897
|
if (!arg.startsWith("-")) {
|
|
@@ -14608,7 +14951,7 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
14608
14951
|
async function createWrapConfig(args) {
|
|
14609
14952
|
if (!args.mcpServers || args.mcpServers.length === 0) {
|
|
14610
14953
|
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'");
|
|
14611
|
-
|
|
14954
|
+
import_node_process10.default.exit(1);
|
|
14612
14955
|
}
|
|
14613
14956
|
const mcpServers = {};
|
|
14614
14957
|
const serverNames = [];
|
|
@@ -14731,7 +15074,7 @@ function parseMcpServer(cmdString, transportType) {
|
|
|
14731
15074
|
};
|
|
14732
15075
|
}
|
|
14733
15076
|
function parseCLIArgs() {
|
|
14734
|
-
const args = parseArgs(
|
|
15077
|
+
const args = parseArgs(import_node_process10.default.argv.slice(2), {
|
|
14735
15078
|
boolean: [
|
|
14736
15079
|
"help",
|
|
14737
15080
|
"version",
|
|
@@ -14820,15 +15163,15 @@ async function loadConfig() {
|
|
|
14820
15163
|
const args = parseCLIArgs();
|
|
14821
15164
|
if (args.version) {
|
|
14822
15165
|
printVersion();
|
|
14823
|
-
|
|
15166
|
+
import_node_process10.default.exit(0);
|
|
14824
15167
|
}
|
|
14825
15168
|
if (args.help) {
|
|
14826
15169
|
printHelp();
|
|
14827
|
-
|
|
15170
|
+
import_node_process10.default.exit(0);
|
|
14828
15171
|
}
|
|
14829
15172
|
if (args.cwd) {
|
|
14830
|
-
const targetCwd = (0, import_node_path6.resolve)(
|
|
14831
|
-
|
|
15173
|
+
const targetCwd = (0, import_node_path6.resolve)(import_node_process10.default.cwd(), args.cwd);
|
|
15174
|
+
import_node_process10.default.chdir(targetCwd);
|
|
14832
15175
|
console.error(`Changed working directory to: ${targetCwd}`);
|
|
14833
15176
|
}
|
|
14834
15177
|
const mergeSkills = (config) => {
|
|
@@ -14840,7 +15183,7 @@ async function loadConfig() {
|
|
|
14840
15183
|
...args,
|
|
14841
15184
|
saveConfig: true
|
|
14842
15185
|
});
|
|
14843
|
-
|
|
15186
|
+
import_node_process10.default.exit(0);
|
|
14844
15187
|
}
|
|
14845
15188
|
if (args.wrap) {
|
|
14846
15189
|
return mergeSkills(await createWrapConfig({
|
|
@@ -14857,16 +15200,16 @@ async function loadConfig() {
|
|
|
14857
15200
|
throw error;
|
|
14858
15201
|
}
|
|
14859
15202
|
}
|
|
14860
|
-
if (
|
|
15203
|
+
if (import_node_process10.default.env.MCPC_CONFIG) {
|
|
14861
15204
|
try {
|
|
14862
|
-
const parsed = JSON.parse(
|
|
15205
|
+
const parsed = JSON.parse(import_node_process10.default.env.MCPC_CONFIG);
|
|
14863
15206
|
return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
|
|
14864
15207
|
} catch (error) {
|
|
14865
15208
|
console.error("Failed to parse MCPC_CONFIG environment variable:", error);
|
|
14866
15209
|
throw error;
|
|
14867
15210
|
}
|
|
14868
15211
|
}
|
|
14869
|
-
const configUrl = args.configUrl ||
|
|
15212
|
+
const configUrl = args.configUrl || import_node_process10.default.env.MCPC_CONFIG_URL;
|
|
14870
15213
|
if (configUrl) {
|
|
14871
15214
|
try {
|
|
14872
15215
|
const headers = {
|
|
@@ -14887,7 +15230,7 @@ async function loadConfig() {
|
|
|
14887
15230
|
throw error;
|
|
14888
15231
|
}
|
|
14889
15232
|
}
|
|
14890
|
-
const configFile = args.configFile ||
|
|
15233
|
+
const configFile = args.configFile || import_node_process10.default.env.MCPC_CONFIG_FILE;
|
|
14891
15234
|
if (configFile) {
|
|
14892
15235
|
try {
|
|
14893
15236
|
const config = await loadConfigFromFile(configFile);
|
|
@@ -14912,7 +15255,7 @@ async function loadConfig() {
|
|
|
14912
15255
|
throw error;
|
|
14913
15256
|
}
|
|
14914
15257
|
}
|
|
14915
|
-
const defaultJsonConfigPath = (0, import_node_path6.resolve)(
|
|
15258
|
+
const defaultJsonConfigPath = (0, import_node_path6.resolve)(import_node_process10.default.cwd(), "mcpc.config.json");
|
|
14916
15259
|
try {
|
|
14917
15260
|
const config = await loadConfigFromFile(defaultJsonConfigPath);
|
|
14918
15261
|
return mergeSkills(applyModeOverride(config, args.mode));
|
|
@@ -14927,7 +15270,7 @@ async function loadConfig() {
|
|
|
14927
15270
|
}
|
|
14928
15271
|
function replaceEnvVars2(str2) {
|
|
14929
15272
|
return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
|
|
14930
|
-
return
|
|
15273
|
+
return import_node_process10.default.env[varName] || "";
|
|
14931
15274
|
});
|
|
14932
15275
|
}
|
|
14933
15276
|
function isMarkdownFile2(path) {
|