@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.mjs
CHANGED
|
@@ -509,7 +509,7 @@ var require_cross_spawn = __commonJS({
|
|
|
509
509
|
var cp = __require("child_process");
|
|
510
510
|
var parse2 = require_parse();
|
|
511
511
|
var enoent = require_enoent();
|
|
512
|
-
function
|
|
512
|
+
function spawn3(command, args, options) {
|
|
513
513
|
const parsed = parse2(command, args, options);
|
|
514
514
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
515
515
|
enoent.hookChildProcess(spawned, parsed);
|
|
@@ -521,8 +521,8 @@ var require_cross_spawn = __commonJS({
|
|
|
521
521
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
522
522
|
return result;
|
|
523
523
|
}
|
|
524
|
-
module.exports =
|
|
525
|
-
module.exports.spawn =
|
|
524
|
+
module.exports = spawn3;
|
|
525
|
+
module.exports.spawn = spawn3;
|
|
526
526
|
module.exports.sync = spawnSync;
|
|
527
527
|
module.exports._parse = parse2;
|
|
528
528
|
module.exports._enoent = enoent;
|
|
@@ -3496,6 +3496,147 @@ var ExperimentalServerTasks = class {
|
|
|
3496
3496
|
requestStream(request, resultSchema, options) {
|
|
3497
3497
|
return this._server.requestStream(request, resultSchema, options);
|
|
3498
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
|
+
}
|
|
3499
3640
|
/**
|
|
3500
3641
|
* Gets the current status of a task.
|
|
3501
3642
|
*
|
|
@@ -5714,22 +5855,45 @@ async function auth(provider, options) {
|
|
|
5714
5855
|
}
|
|
5715
5856
|
}
|
|
5716
5857
|
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
5858
|
+
const cachedState = await provider.discoveryState?.();
|
|
5717
5859
|
let resourceMetadata;
|
|
5718
5860
|
let authorizationServerUrl;
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
|
|
5722
|
-
|
|
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
|
+
}
|
|
5723
5875
|
}
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
|
|
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
|
+
});
|
|
5728
5895
|
}
|
|
5729
5896
|
const resource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
5730
|
-
const metadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, {
|
|
5731
|
-
fetchFn
|
|
5732
|
-
});
|
|
5733
5897
|
let clientInformation = await Promise.resolve(provider.clientInformation());
|
|
5734
5898
|
if (!clientInformation) {
|
|
5735
5899
|
if (authorizationCode !== void 0) {
|
|
@@ -5984,6 +6148,26 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
5984
6148
|
}
|
|
5985
6149
|
return void 0;
|
|
5986
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
|
+
}
|
|
5987
6171
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
5988
6172
|
let authorizationUrl;
|
|
5989
6173
|
if (metadata) {
|
|
@@ -6848,18 +7032,6 @@ var cleanToolSchema = (schema) => {
|
|
|
6848
7032
|
import { cwd } from "node:process";
|
|
6849
7033
|
import process4 from "node:process";
|
|
6850
7034
|
import { createHash } from "node:crypto";
|
|
6851
|
-
var mcpClientPool = /* @__PURE__ */ new Map();
|
|
6852
|
-
var mcpClientConnecting = /* @__PURE__ */ new Map();
|
|
6853
|
-
var shortHash = (s) => createHash("sha256").update(s).digest("hex").slice(0, 8);
|
|
6854
|
-
function defSignature(def) {
|
|
6855
|
-
const defCopy = {
|
|
6856
|
-
...def
|
|
6857
|
-
};
|
|
6858
|
-
if (defCopy.transportType === "memory" || defCopy.transport) {
|
|
6859
|
-
return `memory:${Date.now()}:${Math.random()}`;
|
|
6860
|
-
}
|
|
6861
|
-
return JSON.stringify(defCopy);
|
|
6862
|
-
}
|
|
6863
7035
|
function createTransport(def) {
|
|
6864
7036
|
const defAny = def;
|
|
6865
7037
|
const explicitType = defAny.transportType || defAny.type;
|
|
@@ -6907,90 +7079,43 @@ function createTransport(def) {
|
|
|
6907
7079
|
}
|
|
6908
7080
|
throw new Error(`Unsupported transport configuration: ${JSON.stringify(def)}`);
|
|
6909
7081
|
}
|
|
6910
|
-
|
|
6911
|
-
const
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
const existingConnecting = mcpClientConnecting.get(defKey);
|
|
6917
|
-
if (existingConnecting) {
|
|
6918
|
-
const client = await existingConnecting;
|
|
6919
|
-
const entry = mcpClientPool.get(defKey);
|
|
6920
|
-
if (entry) entry.refCount += 1;
|
|
6921
|
-
return client;
|
|
6922
|
-
}
|
|
6923
|
-
const transport = createTransport(def);
|
|
6924
|
-
const connecting = (async () => {
|
|
6925
|
-
const client = new Client({
|
|
6926
|
-
name: `mcp_${shortHash(defSignature(def))}`,
|
|
6927
|
-
version: "1.0.0"
|
|
6928
|
-
});
|
|
6929
|
-
await client.connect(transport, {
|
|
6930
|
-
timeout: 6e4 * 10
|
|
6931
|
-
});
|
|
6932
|
-
return client;
|
|
6933
|
-
})();
|
|
6934
|
-
mcpClientConnecting.set(defKey, connecting);
|
|
6935
|
-
try {
|
|
6936
|
-
const client = await connecting;
|
|
6937
|
-
mcpClientPool.set(defKey, {
|
|
6938
|
-
client,
|
|
6939
|
-
refCount: 1
|
|
6940
|
-
});
|
|
6941
|
-
return client;
|
|
6942
|
-
} finally {
|
|
6943
|
-
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()}`;
|
|
6944
7088
|
}
|
|
7089
|
+
return JSON.stringify(defCopy);
|
|
6945
7090
|
}
|
|
6946
|
-
|
|
6947
|
-
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
|
|
6956
|
-
|
|
6957
|
-
}
|
|
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;
|
|
6958
7102
|
}
|
|
6959
|
-
var cleanupAllPooledClients = async () => {
|
|
6960
|
-
const entries = Array.from(mcpClientPool.entries());
|
|
6961
|
-
mcpClientPool.clear();
|
|
6962
|
-
await Promise.all(entries.map(async ([, { client }]) => {
|
|
6963
|
-
try {
|
|
6964
|
-
await client.close();
|
|
6965
|
-
} catch (err) {
|
|
6966
|
-
console.error("Error closing MCP client:", err);
|
|
6967
|
-
}
|
|
6968
|
-
}));
|
|
6969
|
-
};
|
|
6970
|
-
process4.once?.("exit", () => {
|
|
6971
|
-
cleanupAllPooledClients();
|
|
6972
|
-
});
|
|
6973
|
-
process4.once?.("SIGINT", () => {
|
|
6974
|
-
cleanupAllPooledClients().finally(() => process4.exit(0));
|
|
6975
|
-
});
|
|
6976
7103
|
async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
6977
7104
|
const allTools = {};
|
|
6978
7105
|
const allClients = {};
|
|
6979
|
-
const
|
|
7106
|
+
const clientsToClose = [];
|
|
6980
7107
|
for (const [name, definition] of Object.entries(mcpConfig.mcpServers)) {
|
|
6981
7108
|
const def = definition;
|
|
6982
7109
|
if (def.disabled) continue;
|
|
6983
|
-
const defKey = shortHash(defSignature(def));
|
|
6984
|
-
const serverId = name;
|
|
6985
7110
|
try {
|
|
6986
|
-
const client = await
|
|
6987
|
-
|
|
6988
|
-
allClients[
|
|
7111
|
+
const client = await createMcpClient(def);
|
|
7112
|
+
clientsToClose.push(client);
|
|
7113
|
+
allClients[name] = client;
|
|
6989
7114
|
const { tools } = await client.listTools();
|
|
6990
7115
|
tools.forEach((tool2) => {
|
|
6991
7116
|
const toolNameWithScope = `${name}.${tool2.name}`;
|
|
6992
7117
|
const internalToolName = tool2.name;
|
|
6993
|
-
const rawToolId = `${
|
|
7118
|
+
const rawToolId = `${name}_${internalToolName}`;
|
|
6994
7119
|
const toolId = sanitizePropertyKey(rawToolId);
|
|
6995
7120
|
if (filterIn && !filterIn({
|
|
6996
7121
|
action: internalToolName,
|
|
@@ -7002,7 +7127,7 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
7002
7127
|
})) {
|
|
7003
7128
|
return;
|
|
7004
7129
|
}
|
|
7005
|
-
const execute = (args) => allClients[
|
|
7130
|
+
const execute = (args) => allClients[name].callTool({
|
|
7006
7131
|
name: internalToolName,
|
|
7007
7132
|
arguments: args
|
|
7008
7133
|
}, void 0, {
|
|
@@ -7019,10 +7144,12 @@ async function composeMcpDepTools(mcpConfig, filterIn) {
|
|
|
7019
7144
|
}
|
|
7020
7145
|
}
|
|
7021
7146
|
const cleanupClients = async () => {
|
|
7022
|
-
await Promise.all(
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7147
|
+
await Promise.all(clientsToClose.map((client) => {
|
|
7148
|
+
try {
|
|
7149
|
+
return client.close();
|
|
7150
|
+
} catch {
|
|
7151
|
+
}
|
|
7152
|
+
}));
|
|
7026
7153
|
};
|
|
7027
7154
|
return {
|
|
7028
7155
|
tools: allTools,
|
|
@@ -10778,7 +10905,7 @@ Usage:
|
|
|
10778
10905
|
- ${toolName}({ skill: "skill-name" }) - Load main SKILL.md content
|
|
10779
10906
|
- ${toolName}({ skill: "skill-name", ref: "path/to/file" }) - Load reference file
|
|
10780
10907
|
|
|
10781
|
-
Note: For scripts
|
|
10908
|
+
Note: For scripts/, use the bash tool with the script path to execute.`;
|
|
10782
10909
|
}
|
|
10783
10910
|
function createSkillsPlugin(options) {
|
|
10784
10911
|
const { paths } = options;
|
|
@@ -10886,11 +11013,15 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
10886
11013
|
try {
|
|
10887
11014
|
const content = await readFile(join2(meta.basePath, "SKILL.md"), "utf-8");
|
|
10888
11015
|
const body = extractBody(content);
|
|
11016
|
+
const skillPathInfo = `
|
|
11017
|
+
---
|
|
11018
|
+
Skill path: ${meta.basePath}
|
|
11019
|
+
`;
|
|
10889
11020
|
return {
|
|
10890
11021
|
content: [
|
|
10891
11022
|
{
|
|
10892
11023
|
type: "text",
|
|
10893
|
-
text: body
|
|
11024
|
+
text: body + skillPathInfo
|
|
10894
11025
|
}
|
|
10895
11026
|
]
|
|
10896
11027
|
};
|
|
@@ -10917,6 +11048,152 @@ Available skills: ${available.join(", ")}` : "\n\nNo skills available.";
|
|
|
10917
11048
|
};
|
|
10918
11049
|
}
|
|
10919
11050
|
|
|
11051
|
+
// __mcpc__cli_latest/node_modules/@jsr/mcpc__core/src/plugins/bash.js
|
|
11052
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
11053
|
+
import process7 from "node:process";
|
|
11054
|
+
var DEFAULT_MAX_BYTES = 1e5;
|
|
11055
|
+
var DEFAULT_MAX_LINES = 2e3;
|
|
11056
|
+
var DEFAULT_TIMEOUT_MS = 6e4;
|
|
11057
|
+
function truncateOutput(stdout, stderr, maxBytes = DEFAULT_MAX_BYTES, maxLines = DEFAULT_MAX_LINES) {
|
|
11058
|
+
const fullOutput = (stderr ? `STDERR:
|
|
11059
|
+
${stderr}
|
|
11060
|
+
|
|
11061
|
+
STDOUT:
|
|
11062
|
+
` : "") + stdout;
|
|
11063
|
+
const lines = fullOutput.split("\n");
|
|
11064
|
+
if (lines.length > maxLines) {
|
|
11065
|
+
const truncatedLines = lines.slice(-maxLines);
|
|
11066
|
+
return {
|
|
11067
|
+
output: `[OUTPUT TRUNCATED] Showing last ${maxLines} lines of ${lines.length} total
|
|
11068
|
+
|
|
11069
|
+
` + truncatedLines.join("\n"),
|
|
11070
|
+
truncated: true
|
|
11071
|
+
};
|
|
11072
|
+
}
|
|
11073
|
+
if (fullOutput.length > maxBytes) {
|
|
11074
|
+
const truncatedBytes = fullOutput.slice(-maxBytes);
|
|
11075
|
+
return {
|
|
11076
|
+
output: `[OUTPUT TRUNCATED] Showing last ${maxBytes} bytes of ${fullOutput.length} total
|
|
11077
|
+
|
|
11078
|
+
` + truncatedBytes,
|
|
11079
|
+
truncated: true
|
|
11080
|
+
};
|
|
11081
|
+
}
|
|
11082
|
+
return {
|
|
11083
|
+
output: fullOutput,
|
|
11084
|
+
truncated: false
|
|
11085
|
+
};
|
|
11086
|
+
}
|
|
11087
|
+
function executeBash(command, cwd2, timeoutMs) {
|
|
11088
|
+
return new Promise((resolve5) => {
|
|
11089
|
+
const stdout = [];
|
|
11090
|
+
const stderr = [];
|
|
11091
|
+
const proc = spawn2("bash", [
|
|
11092
|
+
"-c",
|
|
11093
|
+
command
|
|
11094
|
+
], {
|
|
11095
|
+
cwd: cwd2,
|
|
11096
|
+
stdio: [
|
|
11097
|
+
"ignore",
|
|
11098
|
+
"pipe",
|
|
11099
|
+
"pipe"
|
|
11100
|
+
]
|
|
11101
|
+
});
|
|
11102
|
+
proc.stdout?.on("data", (data) => {
|
|
11103
|
+
stdout.push(data.toString());
|
|
11104
|
+
});
|
|
11105
|
+
proc.stderr?.on("data", (data) => {
|
|
11106
|
+
stderr.push(data.toString());
|
|
11107
|
+
});
|
|
11108
|
+
proc.on("close", (code) => {
|
|
11109
|
+
resolve5({
|
|
11110
|
+
stdout: stdout.join(""),
|
|
11111
|
+
stderr: stderr.join(""),
|
|
11112
|
+
exitCode: code
|
|
11113
|
+
});
|
|
11114
|
+
});
|
|
11115
|
+
proc.on("error", (err) => {
|
|
11116
|
+
resolve5({
|
|
11117
|
+
stdout: "",
|
|
11118
|
+
stderr: err.message,
|
|
11119
|
+
exitCode: null
|
|
11120
|
+
});
|
|
11121
|
+
});
|
|
11122
|
+
setTimeout(() => {
|
|
11123
|
+
proc.kill("SIGTERM");
|
|
11124
|
+
resolve5({
|
|
11125
|
+
stdout: stdout.join(""),
|
|
11126
|
+
stderr: stderr.join("") + "\n\n[TIMEOUT] Command execution timed out",
|
|
11127
|
+
exitCode: null
|
|
11128
|
+
});
|
|
11129
|
+
}, timeoutMs);
|
|
11130
|
+
});
|
|
11131
|
+
}
|
|
11132
|
+
function createBashPlugin(options = {}) {
|
|
11133
|
+
const { maxBytes, maxLines, timeoutMs } = {
|
|
11134
|
+
maxBytes: DEFAULT_MAX_BYTES,
|
|
11135
|
+
maxLines: DEFAULT_MAX_LINES,
|
|
11136
|
+
timeoutMs: DEFAULT_TIMEOUT_MS,
|
|
11137
|
+
...options
|
|
11138
|
+
};
|
|
11139
|
+
let serverRef = null;
|
|
11140
|
+
return {
|
|
11141
|
+
name: "plugin-bash",
|
|
11142
|
+
version: "1.0.0",
|
|
11143
|
+
// Store server reference for tool registration
|
|
11144
|
+
configureServer: (server) => {
|
|
11145
|
+
serverRef = server;
|
|
11146
|
+
},
|
|
11147
|
+
// Register bash tool with agent name prefix
|
|
11148
|
+
composeStart: (context2) => {
|
|
11149
|
+
if (!serverRef) return;
|
|
11150
|
+
const agentName = context2.serverName;
|
|
11151
|
+
const toolName = `${agentName}__bash`;
|
|
11152
|
+
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.", {
|
|
11153
|
+
type: "object",
|
|
11154
|
+
properties: {
|
|
11155
|
+
command: {
|
|
11156
|
+
type: "string",
|
|
11157
|
+
description: "The bash command to execute"
|
|
11158
|
+
},
|
|
11159
|
+
cwd: {
|
|
11160
|
+
type: "string",
|
|
11161
|
+
description: "Optional: Working directory for the command (defaults to current directory)"
|
|
11162
|
+
}
|
|
11163
|
+
},
|
|
11164
|
+
required: [
|
|
11165
|
+
"command"
|
|
11166
|
+
]
|
|
11167
|
+
}, async (args) => {
|
|
11168
|
+
const cwd2 = args.cwd || process7.cwd();
|
|
11169
|
+
const result = await executeBash(args.command, cwd2, timeoutMs);
|
|
11170
|
+
const { output, truncated } = truncateOutput(result.stdout, result.stderr, maxBytes, maxLines);
|
|
11171
|
+
let finalOutput = output;
|
|
11172
|
+
if (result.exitCode !== null && result.exitCode !== 0) {
|
|
11173
|
+
finalOutput = `[EXIT CODE: ${result.exitCode}]
|
|
11174
|
+
` + finalOutput;
|
|
11175
|
+
}
|
|
11176
|
+
if (truncated) {
|
|
11177
|
+
finalOutput += `
|
|
11178
|
+
|
|
11179
|
+
[Note: Output was truncated]`;
|
|
11180
|
+
}
|
|
11181
|
+
return {
|
|
11182
|
+
content: [
|
|
11183
|
+
{
|
|
11184
|
+
type: "text",
|
|
11185
|
+
text: finalOutput
|
|
11186
|
+
}
|
|
11187
|
+
],
|
|
11188
|
+
isError: result.exitCode !== null && result.exitCode !== 0
|
|
11189
|
+
};
|
|
11190
|
+
}, {
|
|
11191
|
+
internal: true
|
|
11192
|
+
});
|
|
11193
|
+
}
|
|
11194
|
+
};
|
|
11195
|
+
}
|
|
11196
|
+
|
|
10920
11197
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
10921
11198
|
import { createCodeExecutionPlugin } from "@mcpc-tech/plugin-code-execution";
|
|
10922
11199
|
|
|
@@ -11761,12 +12038,29 @@ function writeFoldedLines(count) {
|
|
|
11761
12038
|
if (count > 1) return "\n".repeat(count - 1);
|
|
11762
12039
|
return "";
|
|
11763
12040
|
}
|
|
12041
|
+
var Scanner = class {
|
|
12042
|
+
source;
|
|
12043
|
+
#length;
|
|
12044
|
+
position = 0;
|
|
12045
|
+
constructor(source) {
|
|
12046
|
+
source += "\0";
|
|
12047
|
+
this.source = source;
|
|
12048
|
+
this.#length = source.length;
|
|
12049
|
+
}
|
|
12050
|
+
peek(offset = 0) {
|
|
12051
|
+
return this.source.charCodeAt(this.position + offset);
|
|
12052
|
+
}
|
|
12053
|
+
next() {
|
|
12054
|
+
this.position += 1;
|
|
12055
|
+
}
|
|
12056
|
+
eof() {
|
|
12057
|
+
return this.position >= this.#length - 1;
|
|
12058
|
+
}
|
|
12059
|
+
};
|
|
11764
12060
|
var LoaderState = class {
|
|
11765
|
-
|
|
11766
|
-
length;
|
|
12061
|
+
#scanner;
|
|
11767
12062
|
lineIndent = 0;
|
|
11768
12063
|
lineStart = 0;
|
|
11769
|
-
position = 0;
|
|
11770
12064
|
line = 0;
|
|
11771
12065
|
onWarning;
|
|
11772
12066
|
allowDuplicateKeys;
|
|
@@ -11776,44 +12070,40 @@ var LoaderState = class {
|
|
|
11776
12070
|
tagMap = /* @__PURE__ */ new Map();
|
|
11777
12071
|
anchorMap = /* @__PURE__ */ new Map();
|
|
11778
12072
|
constructor(input, { schema = DEFAULT_SCHEMA, onWarning, allowDuplicateKeys = false }) {
|
|
11779
|
-
this
|
|
12073
|
+
this.#scanner = new Scanner(input);
|
|
11780
12074
|
this.onWarning = onWarning;
|
|
11781
12075
|
this.allowDuplicateKeys = allowDuplicateKeys;
|
|
11782
12076
|
this.implicitTypes = schema.implicitTypes;
|
|
11783
12077
|
this.typeMap = schema.typeMap;
|
|
11784
|
-
this.length = input.length;
|
|
11785
12078
|
this.readIndent();
|
|
11786
12079
|
}
|
|
11787
12080
|
skipWhitespaces() {
|
|
11788
|
-
let ch = this.peek();
|
|
12081
|
+
let ch = this.#scanner.peek();
|
|
11789
12082
|
while (isWhiteSpace(ch)) {
|
|
11790
|
-
|
|
12083
|
+
this.#scanner.next();
|
|
12084
|
+
ch = this.#scanner.peek();
|
|
11791
12085
|
}
|
|
11792
12086
|
}
|
|
11793
12087
|
skipComment() {
|
|
11794
|
-
let ch = this.peek();
|
|
12088
|
+
let ch = this.#scanner.peek();
|
|
11795
12089
|
if (ch !== SHARP) return;
|
|
11796
|
-
|
|
12090
|
+
this.#scanner.next();
|
|
12091
|
+
ch = this.#scanner.peek();
|
|
11797
12092
|
while (ch !== 0 && !isEOL(ch)) {
|
|
11798
|
-
|
|
12093
|
+
this.#scanner.next();
|
|
12094
|
+
ch = this.#scanner.peek();
|
|
11799
12095
|
}
|
|
11800
12096
|
}
|
|
11801
12097
|
readIndent() {
|
|
11802
|
-
let
|
|
11803
|
-
while (
|
|
12098
|
+
let ch = this.#scanner.peek();
|
|
12099
|
+
while (ch === SPACE) {
|
|
11804
12100
|
this.lineIndent += 1;
|
|
11805
|
-
|
|
12101
|
+
this.#scanner.next();
|
|
12102
|
+
ch = this.#scanner.peek();
|
|
11806
12103
|
}
|
|
11807
12104
|
}
|
|
11808
|
-
peek(offset = 0) {
|
|
11809
|
-
return this.input.charCodeAt(this.position + offset);
|
|
11810
|
-
}
|
|
11811
|
-
next() {
|
|
11812
|
-
this.position += 1;
|
|
11813
|
-
return this.peek();
|
|
11814
|
-
}
|
|
11815
12105
|
#createError(message) {
|
|
11816
|
-
const mark = markToString(this.
|
|
12106
|
+
const mark = markToString(this.#scanner.source, this.#scanner.position, this.line, this.#scanner.position - this.lineStart);
|
|
11817
12107
|
return new SyntaxError(`${message} ${mark}`);
|
|
11818
12108
|
}
|
|
11819
12109
|
dispatchWarning(message) {
|
|
@@ -11858,7 +12148,7 @@ var LoaderState = class {
|
|
|
11858
12148
|
}
|
|
11859
12149
|
captureSegment(start, end, checkJson) {
|
|
11860
12150
|
if (start < end) {
|
|
11861
|
-
const result = this.
|
|
12151
|
+
const result = this.#scanner.source.slice(start, end);
|
|
11862
12152
|
if (checkJson) {
|
|
11863
12153
|
for (let position = 0; position < result.length; position++) {
|
|
11864
12154
|
const character = result.charCodeAt(position);
|
|
@@ -11876,21 +12166,21 @@ var LoaderState = class {
|
|
|
11876
12166
|
let detected = false;
|
|
11877
12167
|
const result = [];
|
|
11878
12168
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
11879
|
-
let ch = this.peek();
|
|
12169
|
+
let ch = this.#scanner.peek();
|
|
11880
12170
|
while (ch !== 0) {
|
|
11881
12171
|
if (ch !== MINUS) {
|
|
11882
12172
|
break;
|
|
11883
12173
|
}
|
|
11884
|
-
const following = this.peek(1);
|
|
12174
|
+
const following = this.#scanner.peek(1);
|
|
11885
12175
|
if (!isWhiteSpaceOrEOL(following)) {
|
|
11886
12176
|
break;
|
|
11887
12177
|
}
|
|
11888
12178
|
detected = true;
|
|
11889
|
-
this.
|
|
12179
|
+
this.#scanner.next();
|
|
11890
12180
|
if (this.skipSeparationSpace(true, -1)) {
|
|
11891
12181
|
if (this.lineIndent <= nodeIndent) {
|
|
11892
12182
|
result.push(null);
|
|
11893
|
-
ch = this.peek();
|
|
12183
|
+
ch = this.#scanner.peek();
|
|
11894
12184
|
continue;
|
|
11895
12185
|
}
|
|
11896
12186
|
}
|
|
@@ -11903,7 +12193,7 @@ var LoaderState = class {
|
|
|
11903
12193
|
});
|
|
11904
12194
|
if (newState) result.push(newState.result);
|
|
11905
12195
|
this.skipSeparationSpace(true, -1);
|
|
11906
|
-
ch = this.peek();
|
|
12196
|
+
ch = this.#scanner.peek();
|
|
11907
12197
|
if ((this.line === line || this.lineIndent > nodeIndent) && ch !== 0) {
|
|
11908
12198
|
throw this.#createError("Cannot read block sequence: bad indentation of a sequence entry");
|
|
11909
12199
|
} else if (this.lineIndent < nodeIndent) {
|
|
@@ -11959,7 +12249,7 @@ var LoaderState = class {
|
|
|
11959
12249
|
} else {
|
|
11960
12250
|
if (!this.allowDuplicateKeys && !overridableKeys.has(keyNode) && Object.hasOwn(result, keyNode)) {
|
|
11961
12251
|
this.line = startLine || this.line;
|
|
11962
|
-
this.position = startPos || this.position;
|
|
12252
|
+
this.#scanner.position = startPos || this.#scanner.position;
|
|
11963
12253
|
throw this.#createError("Cannot store mapping pair: duplicated key");
|
|
11964
12254
|
}
|
|
11965
12255
|
Object.defineProperty(result, keyNode, {
|
|
@@ -11973,37 +12263,37 @@ var LoaderState = class {
|
|
|
11973
12263
|
return result;
|
|
11974
12264
|
}
|
|
11975
12265
|
readLineBreak() {
|
|
11976
|
-
const ch = this.peek();
|
|
12266
|
+
const ch = this.#scanner.peek();
|
|
11977
12267
|
if (ch === LINE_FEED) {
|
|
11978
|
-
this.
|
|
12268
|
+
this.#scanner.next();
|
|
11979
12269
|
} else if (ch === CARRIAGE_RETURN) {
|
|
11980
|
-
this.
|
|
11981
|
-
if (this.peek() === LINE_FEED) {
|
|
11982
|
-
this.
|
|
12270
|
+
this.#scanner.next();
|
|
12271
|
+
if (this.#scanner.peek() === LINE_FEED) {
|
|
12272
|
+
this.#scanner.next();
|
|
11983
12273
|
}
|
|
11984
12274
|
} else {
|
|
11985
12275
|
throw this.#createError("Cannot read line: line break not found");
|
|
11986
12276
|
}
|
|
11987
12277
|
this.line += 1;
|
|
11988
|
-
this.lineStart = this.position;
|
|
12278
|
+
this.lineStart = this.#scanner.position;
|
|
11989
12279
|
}
|
|
11990
12280
|
skipSeparationSpace(allowComments, checkIndent) {
|
|
11991
12281
|
let lineBreaks = 0;
|
|
11992
|
-
let ch = this.peek();
|
|
12282
|
+
let ch = this.#scanner.peek();
|
|
11993
12283
|
while (ch !== 0) {
|
|
11994
12284
|
this.skipWhitespaces();
|
|
11995
|
-
ch = this.peek();
|
|
12285
|
+
ch = this.#scanner.peek();
|
|
11996
12286
|
if (allowComments) {
|
|
11997
12287
|
this.skipComment();
|
|
11998
|
-
ch = this.peek();
|
|
12288
|
+
ch = this.#scanner.peek();
|
|
11999
12289
|
}
|
|
12000
12290
|
if (isEOL(ch)) {
|
|
12001
12291
|
this.readLineBreak();
|
|
12002
|
-
ch = this.peek();
|
|
12292
|
+
ch = this.#scanner.peek();
|
|
12003
12293
|
lineBreaks++;
|
|
12004
12294
|
this.lineIndent = 0;
|
|
12005
12295
|
this.readIndent();
|
|
12006
|
-
ch = this.peek();
|
|
12296
|
+
ch = this.#scanner.peek();
|
|
12007
12297
|
} else {
|
|
12008
12298
|
break;
|
|
12009
12299
|
}
|
|
@@ -12014,9 +12304,9 @@ var LoaderState = class {
|
|
|
12014
12304
|
return lineBreaks;
|
|
12015
12305
|
}
|
|
12016
12306
|
testDocumentSeparator() {
|
|
12017
|
-
let ch = this.peek();
|
|
12018
|
-
if ((ch === MINUS || ch === DOT) && ch === this.peek(1) && ch === this.peek(2)) {
|
|
12019
|
-
ch = this.peek(3);
|
|
12307
|
+
let ch = this.#scanner.peek();
|
|
12308
|
+
if ((ch === MINUS || ch === DOT) && ch === this.#scanner.peek(1) && ch === this.#scanner.peek(2)) {
|
|
12309
|
+
ch = this.#scanner.peek(3);
|
|
12020
12310
|
if (ch === 0 || isWhiteSpaceOrEOL(ch)) {
|
|
12021
12311
|
return true;
|
|
12022
12312
|
}
|
|
@@ -12024,34 +12314,34 @@ var LoaderState = class {
|
|
|
12024
12314
|
return false;
|
|
12025
12315
|
}
|
|
12026
12316
|
readPlainScalar(tag, anchor, nodeIndent, withinFlowCollection) {
|
|
12027
|
-
let ch = this.peek();
|
|
12317
|
+
let ch = this.#scanner.peek();
|
|
12028
12318
|
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) {
|
|
12029
12319
|
return;
|
|
12030
12320
|
}
|
|
12031
12321
|
let following;
|
|
12032
12322
|
if (ch === QUESTION || ch === MINUS) {
|
|
12033
|
-
following = this.peek(1);
|
|
12323
|
+
following = this.#scanner.peek(1);
|
|
12034
12324
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
12035
12325
|
return;
|
|
12036
12326
|
}
|
|
12037
12327
|
}
|
|
12038
12328
|
let result = "";
|
|
12039
|
-
let captureEnd = this.position;
|
|
12040
|
-
let captureStart = this.position;
|
|
12329
|
+
let captureEnd = this.#scanner.position;
|
|
12330
|
+
let captureStart = this.#scanner.position;
|
|
12041
12331
|
let hasPendingContent = false;
|
|
12042
12332
|
let line = 0;
|
|
12043
12333
|
while (ch !== 0) {
|
|
12044
12334
|
if (ch === COLON) {
|
|
12045
|
-
following = this.peek(1);
|
|
12335
|
+
following = this.#scanner.peek(1);
|
|
12046
12336
|
if (isWhiteSpaceOrEOL(following) || withinFlowCollection && isFlowIndicator(following)) {
|
|
12047
12337
|
break;
|
|
12048
12338
|
}
|
|
12049
12339
|
} else if (ch === SHARP) {
|
|
12050
|
-
const preceding = this.peek(-1);
|
|
12340
|
+
const preceding = this.#scanner.peek(-1);
|
|
12051
12341
|
if (isWhiteSpaceOrEOL(preceding)) {
|
|
12052
12342
|
break;
|
|
12053
12343
|
}
|
|
12054
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
12344
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator() || withinFlowCollection && isFlowIndicator(ch)) {
|
|
12055
12345
|
break;
|
|
12056
12346
|
} else if (isEOL(ch)) {
|
|
12057
12347
|
line = this.line;
|
|
@@ -12060,10 +12350,10 @@ var LoaderState = class {
|
|
|
12060
12350
|
this.skipSeparationSpace(false, -1);
|
|
12061
12351
|
if (this.lineIndent >= nodeIndent) {
|
|
12062
12352
|
hasPendingContent = true;
|
|
12063
|
-
ch = this.peek();
|
|
12353
|
+
ch = this.#scanner.peek();
|
|
12064
12354
|
continue;
|
|
12065
12355
|
} else {
|
|
12066
|
-
this.position = captureEnd;
|
|
12356
|
+
this.#scanner.position = captureEnd;
|
|
12067
12357
|
this.line = line;
|
|
12068
12358
|
this.lineStart = lineStart;
|
|
12069
12359
|
this.lineIndent = lineIndent;
|
|
@@ -12074,13 +12364,14 @@ var LoaderState = class {
|
|
|
12074
12364
|
const segment2 = this.captureSegment(captureStart, captureEnd, false);
|
|
12075
12365
|
if (segment2) result += segment2;
|
|
12076
12366
|
result += writeFoldedLines(this.line - line);
|
|
12077
|
-
captureStart = captureEnd = this.position;
|
|
12367
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12078
12368
|
hasPendingContent = false;
|
|
12079
12369
|
}
|
|
12080
12370
|
if (!isWhiteSpace(ch)) {
|
|
12081
|
-
captureEnd = this.position + 1;
|
|
12371
|
+
captureEnd = this.#scanner.position + 1;
|
|
12082
12372
|
}
|
|
12083
|
-
|
|
12373
|
+
this.#scanner.next();
|
|
12374
|
+
ch = this.#scanner.peek();
|
|
12084
12375
|
}
|
|
12085
12376
|
const segment = this.captureSegment(captureStart, captureEnd, false);
|
|
12086
12377
|
if (segment) result += segment;
|
|
@@ -12093,22 +12384,23 @@ var LoaderState = class {
|
|
|
12093
12384
|
};
|
|
12094
12385
|
}
|
|
12095
12386
|
readSingleQuotedScalar(tag, anchor, nodeIndent) {
|
|
12096
|
-
let ch = this.peek();
|
|
12387
|
+
let ch = this.#scanner.peek();
|
|
12097
12388
|
if (ch !== SINGLE_QUOTE) return;
|
|
12098
12389
|
let result = "";
|
|
12099
|
-
this.
|
|
12100
|
-
let captureStart = this.position;
|
|
12101
|
-
let captureEnd = this.position;
|
|
12102
|
-
ch = this.peek();
|
|
12390
|
+
this.#scanner.next();
|
|
12391
|
+
let captureStart = this.#scanner.position;
|
|
12392
|
+
let captureEnd = this.#scanner.position;
|
|
12393
|
+
ch = this.#scanner.peek();
|
|
12103
12394
|
while (ch !== 0) {
|
|
12104
12395
|
if (ch === SINGLE_QUOTE) {
|
|
12105
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12396
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12106
12397
|
if (segment) result += segment;
|
|
12107
|
-
|
|
12398
|
+
this.#scanner.next();
|
|
12399
|
+
ch = this.#scanner.peek();
|
|
12108
12400
|
if (ch === SINGLE_QUOTE) {
|
|
12109
|
-
captureStart = this.position;
|
|
12110
|
-
this.
|
|
12111
|
-
captureEnd = this.position;
|
|
12401
|
+
captureStart = this.#scanner.position;
|
|
12402
|
+
this.#scanner.next();
|
|
12403
|
+
captureEnd = this.#scanner.position;
|
|
12112
12404
|
} else {
|
|
12113
12405
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12114
12406
|
return {
|
|
@@ -12122,31 +12414,31 @@ var LoaderState = class {
|
|
|
12122
12414
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
12123
12415
|
if (segment) result += segment;
|
|
12124
12416
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
12125
|
-
captureStart = captureEnd = this.position;
|
|
12126
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12417
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12418
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12127
12419
|
throw this.#createError("Unexpected end of the document within a single quoted scalar");
|
|
12128
12420
|
} else {
|
|
12129
|
-
this.
|
|
12130
|
-
captureEnd = this.position;
|
|
12421
|
+
this.#scanner.next();
|
|
12422
|
+
captureEnd = this.#scanner.position;
|
|
12131
12423
|
}
|
|
12132
|
-
ch = this.peek();
|
|
12424
|
+
ch = this.#scanner.peek();
|
|
12133
12425
|
}
|
|
12134
12426
|
throw this.#createError("Unexpected end of the stream within a single quoted scalar");
|
|
12135
12427
|
}
|
|
12136
12428
|
readDoubleQuotedScalar(tag, anchor, nodeIndent) {
|
|
12137
|
-
let ch = this.peek();
|
|
12429
|
+
let ch = this.#scanner.peek();
|
|
12138
12430
|
if (ch !== DOUBLE_QUOTE) return;
|
|
12139
12431
|
let result = "";
|
|
12140
|
-
this.
|
|
12141
|
-
let captureEnd = this.position;
|
|
12142
|
-
let captureStart = this.position;
|
|
12432
|
+
this.#scanner.next();
|
|
12433
|
+
let captureEnd = this.#scanner.position;
|
|
12434
|
+
let captureStart = this.#scanner.position;
|
|
12143
12435
|
let tmp;
|
|
12144
|
-
ch = this.peek();
|
|
12436
|
+
ch = this.#scanner.peek();
|
|
12145
12437
|
while (ch !== 0) {
|
|
12146
12438
|
if (ch === DOUBLE_QUOTE) {
|
|
12147
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12439
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12148
12440
|
if (segment) result += segment;
|
|
12149
|
-
this.
|
|
12441
|
+
this.#scanner.next();
|
|
12150
12442
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12151
12443
|
return {
|
|
12152
12444
|
tag,
|
|
@@ -12156,19 +12448,21 @@ var LoaderState = class {
|
|
|
12156
12448
|
};
|
|
12157
12449
|
}
|
|
12158
12450
|
if (ch === BACKSLASH) {
|
|
12159
|
-
const segment = this.captureSegment(captureStart, this.position, true);
|
|
12451
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, true);
|
|
12160
12452
|
if (segment) result += segment;
|
|
12161
|
-
|
|
12453
|
+
this.#scanner.next();
|
|
12454
|
+
ch = this.#scanner.peek();
|
|
12162
12455
|
if (isEOL(ch)) {
|
|
12163
12456
|
this.skipSeparationSpace(false, nodeIndent);
|
|
12164
12457
|
} else if (ch < 256 && SIMPLE_ESCAPE_SEQUENCES.has(ch)) {
|
|
12165
12458
|
result += SIMPLE_ESCAPE_SEQUENCES.get(ch);
|
|
12166
|
-
this.
|
|
12459
|
+
this.#scanner.next();
|
|
12167
12460
|
} else if ((tmp = ESCAPED_HEX_LENGTHS.get(ch) ?? 0) > 0) {
|
|
12168
12461
|
let hexLength = tmp;
|
|
12169
12462
|
let hexResult = 0;
|
|
12170
12463
|
for (; hexLength > 0; hexLength--) {
|
|
12171
|
-
|
|
12464
|
+
this.#scanner.next();
|
|
12465
|
+
ch = this.#scanner.peek();
|
|
12172
12466
|
if ((tmp = hexCharCodeToNumber(ch)) >= 0) {
|
|
12173
12467
|
hexResult = (hexResult << 4) + tmp;
|
|
12174
12468
|
} else {
|
|
@@ -12176,28 +12470,28 @@ var LoaderState = class {
|
|
|
12176
12470
|
}
|
|
12177
12471
|
}
|
|
12178
12472
|
result += codepointToChar(hexResult);
|
|
12179
|
-
this.
|
|
12473
|
+
this.#scanner.next();
|
|
12180
12474
|
} else {
|
|
12181
12475
|
throw this.#createError("Cannot read double quoted scalar: unknown escape sequence");
|
|
12182
12476
|
}
|
|
12183
|
-
captureStart = captureEnd = this.position;
|
|
12477
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12184
12478
|
} else if (isEOL(ch)) {
|
|
12185
12479
|
const segment = this.captureSegment(captureStart, captureEnd, true);
|
|
12186
12480
|
if (segment) result += segment;
|
|
12187
12481
|
result += writeFoldedLines(this.skipSeparationSpace(false, nodeIndent));
|
|
12188
|
-
captureStart = captureEnd = this.position;
|
|
12189
|
-
} else if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12482
|
+
captureStart = captureEnd = this.#scanner.position;
|
|
12483
|
+
} else if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12190
12484
|
throw this.#createError("Unexpected end of the document within a double quoted scalar");
|
|
12191
12485
|
} else {
|
|
12192
|
-
this.
|
|
12193
|
-
captureEnd = this.position;
|
|
12486
|
+
this.#scanner.next();
|
|
12487
|
+
captureEnd = this.#scanner.position;
|
|
12194
12488
|
}
|
|
12195
|
-
ch = this.peek();
|
|
12489
|
+
ch = this.#scanner.peek();
|
|
12196
12490
|
}
|
|
12197
12491
|
throw this.#createError("Unexpected end of the stream within a double quoted scalar");
|
|
12198
12492
|
}
|
|
12199
12493
|
readFlowCollection(tag, anchor, nodeIndent) {
|
|
12200
|
-
let ch = this.peek();
|
|
12494
|
+
let ch = this.#scanner.peek();
|
|
12201
12495
|
let terminator;
|
|
12202
12496
|
let isMapping = true;
|
|
12203
12497
|
let result = {};
|
|
@@ -12211,7 +12505,8 @@ var LoaderState = class {
|
|
|
12211
12505
|
return;
|
|
12212
12506
|
}
|
|
12213
12507
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12214
|
-
|
|
12508
|
+
this.#scanner.next();
|
|
12509
|
+
ch = this.#scanner.peek();
|
|
12215
12510
|
let readNext = true;
|
|
12216
12511
|
let valueNode = null;
|
|
12217
12512
|
let keyNode = null;
|
|
@@ -12223,9 +12518,9 @@ var LoaderState = class {
|
|
|
12223
12518
|
const overridableKeys = /* @__PURE__ */ new Set();
|
|
12224
12519
|
while (ch !== 0) {
|
|
12225
12520
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12226
|
-
ch = this.peek();
|
|
12521
|
+
ch = this.#scanner.peek();
|
|
12227
12522
|
if (ch === terminator) {
|
|
12228
|
-
this.
|
|
12523
|
+
this.#scanner.next();
|
|
12229
12524
|
const kind = isMapping ? "mapping" : "sequence";
|
|
12230
12525
|
return {
|
|
12231
12526
|
tag,
|
|
@@ -12240,10 +12535,10 @@ var LoaderState = class {
|
|
|
12240
12535
|
keyTag = keyNode = valueNode = null;
|
|
12241
12536
|
isPair = isExplicitPair = false;
|
|
12242
12537
|
if (ch === QUESTION) {
|
|
12243
|
-
following = this.peek(1);
|
|
12538
|
+
following = this.#scanner.peek(1);
|
|
12244
12539
|
if (isWhiteSpaceOrEOL(following)) {
|
|
12245
12540
|
isPair = isExplicitPair = true;
|
|
12246
|
-
this.
|
|
12541
|
+
this.#scanner.next();
|
|
12247
12542
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12248
12543
|
}
|
|
12249
12544
|
}
|
|
@@ -12259,10 +12554,11 @@ var LoaderState = class {
|
|
|
12259
12554
|
keyNode = newState.result;
|
|
12260
12555
|
}
|
|
12261
12556
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12262
|
-
ch = this.peek();
|
|
12557
|
+
ch = this.#scanner.peek();
|
|
12263
12558
|
if ((isExplicitPair || this.line === line) && ch === COLON) {
|
|
12264
12559
|
isPair = true;
|
|
12265
|
-
|
|
12560
|
+
this.#scanner.next();
|
|
12561
|
+
ch = this.#scanner.peek();
|
|
12266
12562
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12267
12563
|
const newState2 = this.composeNode({
|
|
12268
12564
|
parentIndent: nodeIndent,
|
|
@@ -12280,10 +12576,11 @@ var LoaderState = class {
|
|
|
12280
12576
|
result.push(keyNode);
|
|
12281
12577
|
}
|
|
12282
12578
|
this.skipSeparationSpace(true, nodeIndent);
|
|
12283
|
-
ch = this.peek();
|
|
12579
|
+
ch = this.#scanner.peek();
|
|
12284
12580
|
if (ch === COMMA) {
|
|
12285
12581
|
readNext = true;
|
|
12286
|
-
|
|
12582
|
+
this.#scanner.next();
|
|
12583
|
+
ch = this.#scanner.peek();
|
|
12287
12584
|
} else {
|
|
12288
12585
|
readNext = false;
|
|
12289
12586
|
}
|
|
@@ -12299,7 +12596,7 @@ var LoaderState = class {
|
|
|
12299
12596
|
let textIndent = nodeIndent;
|
|
12300
12597
|
let emptyLines = 0;
|
|
12301
12598
|
let atMoreIndented = false;
|
|
12302
|
-
let ch = this.peek();
|
|
12599
|
+
let ch = this.#scanner.peek();
|
|
12303
12600
|
let folding = false;
|
|
12304
12601
|
if (ch === VERTICAL_LINE) {
|
|
12305
12602
|
folding = false;
|
|
@@ -12311,7 +12608,8 @@ var LoaderState = class {
|
|
|
12311
12608
|
let result = "";
|
|
12312
12609
|
let tmp = 0;
|
|
12313
12610
|
while (ch !== 0) {
|
|
12314
|
-
|
|
12611
|
+
this.#scanner.next();
|
|
12612
|
+
ch = this.#scanner.peek();
|
|
12315
12613
|
if (ch === PLUS || ch === MINUS) {
|
|
12316
12614
|
if (CHOMPING_CLIP === chomping) {
|
|
12317
12615
|
chomping = ch === PLUS ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
@@ -12334,15 +12632,16 @@ var LoaderState = class {
|
|
|
12334
12632
|
if (isWhiteSpace(ch)) {
|
|
12335
12633
|
this.skipWhitespaces();
|
|
12336
12634
|
this.skipComment();
|
|
12337
|
-
ch = this.peek();
|
|
12635
|
+
ch = this.#scanner.peek();
|
|
12338
12636
|
}
|
|
12339
12637
|
while (ch !== 0) {
|
|
12340
12638
|
this.readLineBreak();
|
|
12341
12639
|
this.lineIndent = 0;
|
|
12342
|
-
ch = this.peek();
|
|
12640
|
+
ch = this.#scanner.peek();
|
|
12343
12641
|
while ((!detectedIndent || this.lineIndent < textIndent) && ch === SPACE) {
|
|
12344
12642
|
this.lineIndent++;
|
|
12345
|
-
|
|
12643
|
+
this.#scanner.next();
|
|
12644
|
+
ch = this.#scanner.peek();
|
|
12346
12645
|
}
|
|
12347
12646
|
if (!detectedIndent && this.lineIndent > textIndent) {
|
|
12348
12647
|
textIndent = this.lineIndent;
|
|
@@ -12381,11 +12680,12 @@ var LoaderState = class {
|
|
|
12381
12680
|
didReadContent = true;
|
|
12382
12681
|
detectedIndent = true;
|
|
12383
12682
|
emptyLines = 0;
|
|
12384
|
-
const captureStart = this.position;
|
|
12683
|
+
const captureStart = this.#scanner.position;
|
|
12385
12684
|
while (!isEOL(ch) && ch !== 0) {
|
|
12386
|
-
|
|
12685
|
+
this.#scanner.next();
|
|
12686
|
+
ch = this.#scanner.peek();
|
|
12387
12687
|
}
|
|
12388
|
-
const segment = this.captureSegment(captureStart, this.position, false);
|
|
12688
|
+
const segment = this.captureSegment(captureStart, this.#scanner.position, false);
|
|
12389
12689
|
if (segment) result += segment;
|
|
12390
12690
|
}
|
|
12391
12691
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
@@ -12408,11 +12708,11 @@ var LoaderState = class {
|
|
|
12408
12708
|
let atExplicitKey = false;
|
|
12409
12709
|
let detected = false;
|
|
12410
12710
|
if (anchor !== null) this.anchorMap.set(anchor, result);
|
|
12411
|
-
let ch = this.peek();
|
|
12711
|
+
let ch = this.#scanner.peek();
|
|
12412
12712
|
while (ch !== 0) {
|
|
12413
|
-
const following = this.peek(1);
|
|
12713
|
+
const following = this.#scanner.peek(1);
|
|
12414
12714
|
line = this.line;
|
|
12415
|
-
pos = this.position;
|
|
12715
|
+
pos = this.#scanner.position;
|
|
12416
12716
|
if ((ch === QUESTION || ch === COLON) && isWhiteSpaceOrEOL(following)) {
|
|
12417
12717
|
if (ch === QUESTION) {
|
|
12418
12718
|
if (atExplicitKey) {
|
|
@@ -12430,7 +12730,7 @@ var LoaderState = class {
|
|
|
12430
12730
|
} else {
|
|
12431
12731
|
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");
|
|
12432
12732
|
}
|
|
12433
|
-
this.
|
|
12733
|
+
this.#scanner.next();
|
|
12434
12734
|
ch = following;
|
|
12435
12735
|
} else {
|
|
12436
12736
|
const newState = this.composeNode({
|
|
@@ -12441,11 +12741,12 @@ var LoaderState = class {
|
|
|
12441
12741
|
});
|
|
12442
12742
|
if (!newState) break;
|
|
12443
12743
|
if (this.line === line) {
|
|
12444
|
-
ch = this.peek();
|
|
12744
|
+
ch = this.#scanner.peek();
|
|
12445
12745
|
this.skipWhitespaces();
|
|
12446
|
-
ch = this.peek();
|
|
12746
|
+
ch = this.#scanner.peek();
|
|
12447
12747
|
if (ch === COLON) {
|
|
12448
|
-
|
|
12748
|
+
this.#scanner.next();
|
|
12749
|
+
ch = this.#scanner.peek();
|
|
12449
12750
|
if (!isWhiteSpaceOrEOL(ch)) {
|
|
12450
12751
|
throw this.#createError("Cannot read block: a whitespace character is expected after the key-value separator within a block mapping");
|
|
12451
12752
|
}
|
|
@@ -12502,7 +12803,7 @@ var LoaderState = class {
|
|
|
12502
12803
|
keyTag = keyNode = valueNode = null;
|
|
12503
12804
|
}
|
|
12504
12805
|
this.skipSeparationSpace(true, -1);
|
|
12505
|
-
ch = this.peek();
|
|
12806
|
+
ch = this.#scanner.peek();
|
|
12506
12807
|
}
|
|
12507
12808
|
if (this.lineIndent > nodeIndent && ch !== 0) {
|
|
12508
12809
|
throw this.#createError("Cannot read block: bad indentation of a mapping entry");
|
|
@@ -12525,30 +12826,35 @@ var LoaderState = class {
|
|
|
12525
12826
|
let isNamed = false;
|
|
12526
12827
|
let tagHandle = "";
|
|
12527
12828
|
let tagName;
|
|
12528
|
-
let ch = this.peek();
|
|
12829
|
+
let ch = this.#scanner.peek();
|
|
12529
12830
|
if (ch !== EXCLAMATION) return;
|
|
12530
12831
|
if (tag !== null) {
|
|
12531
12832
|
throw this.#createError("Cannot read tag property: duplication of a tag property");
|
|
12532
12833
|
}
|
|
12533
|
-
|
|
12834
|
+
this.#scanner.next();
|
|
12835
|
+
ch = this.#scanner.peek();
|
|
12534
12836
|
if (ch === SMALLER_THAN) {
|
|
12535
12837
|
isVerbatim = true;
|
|
12536
|
-
|
|
12838
|
+
this.#scanner.next();
|
|
12839
|
+
ch = this.#scanner.peek();
|
|
12537
12840
|
} else if (ch === EXCLAMATION) {
|
|
12538
12841
|
isNamed = true;
|
|
12539
12842
|
tagHandle = "!!";
|
|
12540
|
-
|
|
12843
|
+
this.#scanner.next();
|
|
12844
|
+
ch = this.#scanner.peek();
|
|
12541
12845
|
} else {
|
|
12542
12846
|
tagHandle = "!";
|
|
12543
12847
|
}
|
|
12544
|
-
let position = this.position;
|
|
12848
|
+
let position = this.#scanner.position;
|
|
12545
12849
|
if (isVerbatim) {
|
|
12546
12850
|
do {
|
|
12547
|
-
|
|
12851
|
+
this.#scanner.next();
|
|
12852
|
+
ch = this.#scanner.peek();
|
|
12548
12853
|
} while (ch !== 0 && ch !== GREATER_THAN);
|
|
12549
|
-
if (this.
|
|
12550
|
-
tagName = this.
|
|
12551
|
-
|
|
12854
|
+
if (!this.#scanner.eof()) {
|
|
12855
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12856
|
+
this.#scanner.next();
|
|
12857
|
+
ch = this.#scanner.peek();
|
|
12552
12858
|
} else {
|
|
12553
12859
|
throw this.#createError("Cannot read tag property: unexpected end of stream");
|
|
12554
12860
|
}
|
|
@@ -12556,19 +12862,20 @@ var LoaderState = class {
|
|
|
12556
12862
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12557
12863
|
if (ch === EXCLAMATION) {
|
|
12558
12864
|
if (!isNamed) {
|
|
12559
|
-
tagHandle = this.
|
|
12865
|
+
tagHandle = this.#scanner.source.slice(position - 1, this.#scanner.position + 1);
|
|
12560
12866
|
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
12561
12867
|
throw this.#createError("Cannot read tag property: named tag handle contains invalid characters");
|
|
12562
12868
|
}
|
|
12563
12869
|
isNamed = true;
|
|
12564
|
-
position = this.position + 1;
|
|
12870
|
+
position = this.#scanner.position + 1;
|
|
12565
12871
|
} else {
|
|
12566
12872
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain an exclamation mark");
|
|
12567
12873
|
}
|
|
12568
12874
|
}
|
|
12569
|
-
|
|
12875
|
+
this.#scanner.next();
|
|
12876
|
+
ch = this.#scanner.peek();
|
|
12570
12877
|
}
|
|
12571
|
-
tagName = this.
|
|
12878
|
+
tagName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12572
12879
|
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
12573
12880
|
throw this.#createError("Cannot read tag property: tag suffix cannot contain flow indicator characters");
|
|
12574
12881
|
}
|
|
@@ -12588,32 +12895,36 @@ var LoaderState = class {
|
|
|
12588
12895
|
throw this.#createError(`Cannot read tag property: undeclared tag handle "${tagHandle}"`);
|
|
12589
12896
|
}
|
|
12590
12897
|
readAnchorProperty(anchor) {
|
|
12591
|
-
let ch = this.peek();
|
|
12898
|
+
let ch = this.#scanner.peek();
|
|
12592
12899
|
if (ch !== AMPERSAND) return;
|
|
12593
12900
|
if (anchor !== null) {
|
|
12594
12901
|
throw this.#createError("Cannot read anchor property: duplicate anchor property");
|
|
12595
12902
|
}
|
|
12596
|
-
|
|
12597
|
-
|
|
12903
|
+
this.#scanner.next();
|
|
12904
|
+
ch = this.#scanner.peek();
|
|
12905
|
+
const position = this.#scanner.position;
|
|
12598
12906
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
12599
|
-
|
|
12907
|
+
this.#scanner.next();
|
|
12908
|
+
ch = this.#scanner.peek();
|
|
12600
12909
|
}
|
|
12601
|
-
if (this.position === position) {
|
|
12910
|
+
if (this.#scanner.position === position) {
|
|
12602
12911
|
throw this.#createError("Cannot read anchor property: name of an anchor node must contain at least one character");
|
|
12603
12912
|
}
|
|
12604
|
-
return this.
|
|
12913
|
+
return this.#scanner.source.slice(position, this.#scanner.position);
|
|
12605
12914
|
}
|
|
12606
12915
|
readAlias() {
|
|
12607
|
-
if (this.peek() !== ASTERISK) return;
|
|
12608
|
-
|
|
12609
|
-
|
|
12916
|
+
if (this.#scanner.peek() !== ASTERISK) return;
|
|
12917
|
+
this.#scanner.next();
|
|
12918
|
+
let ch = this.#scanner.peek();
|
|
12919
|
+
const position = this.#scanner.position;
|
|
12610
12920
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
12611
|
-
|
|
12921
|
+
this.#scanner.next();
|
|
12922
|
+
ch = this.#scanner.peek();
|
|
12612
12923
|
}
|
|
12613
|
-
if (this.position === position) {
|
|
12924
|
+
if (this.#scanner.position === position) {
|
|
12614
12925
|
throw this.#createError("Cannot read alias: alias name must contain at least one character");
|
|
12615
12926
|
}
|
|
12616
|
-
const alias = this.
|
|
12927
|
+
const alias = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12617
12928
|
if (!this.anchorMap.has(alias)) {
|
|
12618
12929
|
throw this.#createError(`Cannot read alias: unidentified alias "${alias}"`);
|
|
12619
12930
|
}
|
|
@@ -12696,7 +13007,7 @@ var LoaderState = class {
|
|
|
12696
13007
|
const cond = CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext;
|
|
12697
13008
|
const flowIndent = cond ? parentIndent : parentIndent + 1;
|
|
12698
13009
|
if (allowBlockCollections) {
|
|
12699
|
-
const blockIndent = this.position - this.lineStart;
|
|
13010
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
12700
13011
|
const blockSequenceState = this.readBlockSequence(tag, anchor, blockIndent);
|
|
12701
13012
|
if (blockSequenceState) return this.resolveTag(blockSequenceState);
|
|
12702
13013
|
const blockMappingState = this.readBlockMapping(tag, anchor, blockIndent, flowIndent);
|
|
@@ -12730,7 +13041,7 @@ var LoaderState = class {
|
|
|
12730
13041
|
return this.resolveTag(plainScalarState);
|
|
12731
13042
|
}
|
|
12732
13043
|
} else if (indentStatus === 0 && CONTEXT_BLOCK_OUT === nodeContext && allowBlockCollections) {
|
|
12733
|
-
const blockIndent = this.position - this.lineStart;
|
|
13044
|
+
const blockIndent = this.#scanner.position - this.lineStart;
|
|
12734
13045
|
const newState2 = this.readBlockSequence(tag, anchor, blockIndent);
|
|
12735
13046
|
if (newState2) return this.resolveTag(newState2);
|
|
12736
13047
|
}
|
|
@@ -12745,20 +13056,22 @@ var LoaderState = class {
|
|
|
12745
13056
|
readDirectives() {
|
|
12746
13057
|
let hasDirectives = false;
|
|
12747
13058
|
let version = null;
|
|
12748
|
-
let ch = this.peek();
|
|
13059
|
+
let ch = this.#scanner.peek();
|
|
12749
13060
|
while (ch !== 0) {
|
|
12750
13061
|
this.skipSeparationSpace(true, -1);
|
|
12751
|
-
ch = this.peek();
|
|
13062
|
+
ch = this.#scanner.peek();
|
|
12752
13063
|
if (this.lineIndent > 0 || ch !== PERCENT) {
|
|
12753
13064
|
break;
|
|
12754
13065
|
}
|
|
12755
13066
|
hasDirectives = true;
|
|
12756
|
-
|
|
12757
|
-
|
|
13067
|
+
this.#scanner.next();
|
|
13068
|
+
ch = this.#scanner.peek();
|
|
13069
|
+
let position = this.#scanner.position;
|
|
12758
13070
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12759
|
-
|
|
13071
|
+
this.#scanner.next();
|
|
13072
|
+
ch = this.#scanner.peek();
|
|
12760
13073
|
}
|
|
12761
|
-
const directiveName = this.
|
|
13074
|
+
const directiveName = this.#scanner.source.slice(position, this.#scanner.position);
|
|
12762
13075
|
const directiveArgs = [];
|
|
12763
13076
|
if (directiveName.length < 1) {
|
|
12764
13077
|
throw this.#createError("Cannot read document: directive name length must be greater than zero");
|
|
@@ -12766,13 +13079,14 @@ var LoaderState = class {
|
|
|
12766
13079
|
while (ch !== 0) {
|
|
12767
13080
|
this.skipWhitespaces();
|
|
12768
13081
|
this.skipComment();
|
|
12769
|
-
ch = this.peek();
|
|
13082
|
+
ch = this.#scanner.peek();
|
|
12770
13083
|
if (isEOL(ch)) break;
|
|
12771
|
-
position = this.position;
|
|
13084
|
+
position = this.#scanner.position;
|
|
12772
13085
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch)) {
|
|
12773
|
-
|
|
13086
|
+
this.#scanner.next();
|
|
13087
|
+
ch = this.#scanner.peek();
|
|
12774
13088
|
}
|
|
12775
|
-
directiveArgs.push(this.
|
|
13089
|
+
directiveArgs.push(this.#scanner.source.slice(position, this.#scanner.position));
|
|
12776
13090
|
}
|
|
12777
13091
|
if (ch !== 0) this.readLineBreak();
|
|
12778
13092
|
switch (directiveName) {
|
|
@@ -12789,20 +13103,20 @@ var LoaderState = class {
|
|
|
12789
13103
|
this.dispatchWarning(`unknown document directive "${directiveName}"`);
|
|
12790
13104
|
break;
|
|
12791
13105
|
}
|
|
12792
|
-
ch = this.peek();
|
|
13106
|
+
ch = this.#scanner.peek();
|
|
12793
13107
|
}
|
|
12794
13108
|
return hasDirectives;
|
|
12795
13109
|
}
|
|
12796
13110
|
readDocument() {
|
|
12797
|
-
const documentStart = this.position;
|
|
13111
|
+
const documentStart = this.#scanner.position;
|
|
12798
13112
|
this.checkLineBreaks = false;
|
|
12799
13113
|
this.tagMap = /* @__PURE__ */ new Map();
|
|
12800
13114
|
this.anchorMap = /* @__PURE__ */ new Map();
|
|
12801
13115
|
const hasDirectives = this.readDirectives();
|
|
12802
13116
|
this.skipSeparationSpace(true, -1);
|
|
12803
13117
|
let result = null;
|
|
12804
|
-
if (this.lineIndent === 0 && this.peek() === MINUS && this.peek(1) === MINUS && this.peek(2) === MINUS) {
|
|
12805
|
-
this.position += 3;
|
|
13118
|
+
if (this.lineIndent === 0 && this.#scanner.peek() === MINUS && this.#scanner.peek(1) === MINUS && this.#scanner.peek(2) === MINUS) {
|
|
13119
|
+
this.#scanner.position += 3;
|
|
12806
13120
|
this.skipSeparationSpace(true, -1);
|
|
12807
13121
|
} else if (hasDirectives) {
|
|
12808
13122
|
throw this.#createError("Cannot read document: directives end mark is expected");
|
|
@@ -12815,21 +13129,21 @@ var LoaderState = class {
|
|
|
12815
13129
|
});
|
|
12816
13130
|
if (newState) result = newState.result;
|
|
12817
13131
|
this.skipSeparationSpace(true, -1);
|
|
12818
|
-
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.
|
|
13132
|
+
if (this.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(this.#scanner.source.slice(documentStart, this.#scanner.position))) {
|
|
12819
13133
|
this.dispatchWarning("non-ASCII line breaks are interpreted as content");
|
|
12820
13134
|
}
|
|
12821
|
-
if (this.position === this.lineStart && this.testDocumentSeparator()) {
|
|
12822
|
-
if (this.peek() === DOT) {
|
|
12823
|
-
this.position += 3;
|
|
13135
|
+
if (this.#scanner.position === this.lineStart && this.testDocumentSeparator()) {
|
|
13136
|
+
if (this.#scanner.peek() === DOT) {
|
|
13137
|
+
this.#scanner.position += 3;
|
|
12824
13138
|
this.skipSeparationSpace(true, -1);
|
|
12825
13139
|
}
|
|
12826
|
-
} else if (this.
|
|
13140
|
+
} else if (!this.#scanner.eof()) {
|
|
12827
13141
|
throw this.#createError("Cannot read document: end of the stream or a document separator is expected");
|
|
12828
13142
|
}
|
|
12829
13143
|
return result;
|
|
12830
13144
|
}
|
|
12831
13145
|
*readDocuments() {
|
|
12832
|
-
while (this.
|
|
13146
|
+
while (!this.#scanner.eof()) {
|
|
12833
13147
|
yield this.readDocument();
|
|
12834
13148
|
}
|
|
12835
13149
|
}
|
|
@@ -12842,7 +13156,6 @@ function sanitizeInput(input) {
|
|
|
12842
13156
|
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
12843
13157
|
if (input.charCodeAt(0) === 65279) input = input.slice(1);
|
|
12844
13158
|
}
|
|
12845
|
-
input += "\0";
|
|
12846
13159
|
return input;
|
|
12847
13160
|
}
|
|
12848
13161
|
function parse(content, options = {}) {
|
|
@@ -12860,10 +13173,10 @@ function parse(content, options = {}) {
|
|
|
12860
13173
|
}
|
|
12861
13174
|
|
|
12862
13175
|
// __mcpc__cli_latest/node_modules/@jsr/mcpc__plugin-markdown-loader/src/markdown-loader.js
|
|
12863
|
-
import
|
|
13176
|
+
import process8 from "node:process";
|
|
12864
13177
|
function replaceEnvVars(str2) {
|
|
12865
13178
|
return str2.replace(/\$([A-Za-z_][A-Za-z0-9_]*)(?!\s*\()/g, (match, varName) => {
|
|
12866
|
-
const value =
|
|
13179
|
+
const value = process8.env[varName];
|
|
12867
13180
|
if (value !== void 0) {
|
|
12868
13181
|
return value;
|
|
12869
13182
|
}
|
|
@@ -12962,17 +13275,18 @@ var defaultPlugin = markdownLoaderPlugin();
|
|
|
12962
13275
|
|
|
12963
13276
|
// __mcpc__cli_latest/node_modules/@mcpc/cli/src/defaults.js
|
|
12964
13277
|
import { resolve as resolve3 } from "node:path";
|
|
12965
|
-
import
|
|
13278
|
+
import process9 from "node:process";
|
|
12966
13279
|
var DEFAULT_SKILLS_PATHS = [
|
|
12967
13280
|
".agent/skills"
|
|
12968
13281
|
];
|
|
12969
13282
|
function getGlobalPlugins(skillsPaths) {
|
|
12970
|
-
const resolvedPaths = skillsPaths.map((p2) => resolve3(
|
|
13283
|
+
const resolvedPaths = skillsPaths.map((p2) => resolve3(process9.cwd(), p2));
|
|
12971
13284
|
return [
|
|
12972
13285
|
markdownLoaderPlugin(),
|
|
12973
13286
|
createSkillsPlugin({
|
|
12974
13287
|
paths: resolvedPaths
|
|
12975
|
-
})
|
|
13288
|
+
}),
|
|
13289
|
+
createBashPlugin()
|
|
12976
13290
|
];
|
|
12977
13291
|
}
|
|
12978
13292
|
function getDefaultAgents() {
|
|
@@ -13728,6 +14042,7 @@ data:
|
|
|
13728
14042
|
async handleGetRequest(req) {
|
|
13729
14043
|
const acceptHeader = req.headers.get("accept");
|
|
13730
14044
|
if (!acceptHeader?.includes("text/event-stream")) {
|
|
14045
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept text/event-stream"));
|
|
13731
14046
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept text/event-stream");
|
|
13732
14047
|
}
|
|
13733
14048
|
const sessionError = this.validateSession(req);
|
|
@@ -13745,6 +14060,7 @@ data:
|
|
|
13745
14060
|
}
|
|
13746
14061
|
}
|
|
13747
14062
|
if (this._streamMapping.get(this._standaloneSseStreamId) !== void 0) {
|
|
14063
|
+
this.onerror?.(new Error("Conflict: Only one SSE stream is allowed per session"));
|
|
13748
14064
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Only one SSE stream is allowed per session");
|
|
13749
14065
|
}
|
|
13750
14066
|
const encoder2 = new TextEncoder();
|
|
@@ -13784,6 +14100,7 @@ data:
|
|
|
13784
14100
|
*/
|
|
13785
14101
|
async replayEvents(lastEventId) {
|
|
13786
14102
|
if (!this._eventStore) {
|
|
14103
|
+
this.onerror?.(new Error("Event store not configured"));
|
|
13787
14104
|
return this.createJsonErrorResponse(400, -32e3, "Event store not configured");
|
|
13788
14105
|
}
|
|
13789
14106
|
try {
|
|
@@ -13791,9 +14108,11 @@ data:
|
|
|
13791
14108
|
if (this._eventStore.getStreamIdForEventId) {
|
|
13792
14109
|
streamId = await this._eventStore.getStreamIdForEventId(lastEventId);
|
|
13793
14110
|
if (!streamId) {
|
|
14111
|
+
this.onerror?.(new Error("Invalid event ID format"));
|
|
13794
14112
|
return this.createJsonErrorResponse(400, -32e3, "Invalid event ID format");
|
|
13795
14113
|
}
|
|
13796
14114
|
if (this._streamMapping.get(streamId) !== void 0) {
|
|
14115
|
+
this.onerror?.(new Error("Conflict: Stream already has an active connection"));
|
|
13797
14116
|
return this.createJsonErrorResponse(409, -32e3, "Conflict: Stream already has an active connection");
|
|
13798
14117
|
}
|
|
13799
14118
|
}
|
|
@@ -13859,7 +14178,8 @@ data:
|
|
|
13859
14178
|
`;
|
|
13860
14179
|
controller.enqueue(encoder2.encode(eventData));
|
|
13861
14180
|
return true;
|
|
13862
|
-
} catch {
|
|
14181
|
+
} catch (error) {
|
|
14182
|
+
this.onerror?.(error);
|
|
13863
14183
|
return false;
|
|
13864
14184
|
}
|
|
13865
14185
|
}
|
|
@@ -13867,6 +14187,7 @@ data:
|
|
|
13867
14187
|
* Handles unsupported requests (PUT, PATCH, etc.)
|
|
13868
14188
|
*/
|
|
13869
14189
|
handleUnsupportedRequest() {
|
|
14190
|
+
this.onerror?.(new Error("Method not allowed."));
|
|
13870
14191
|
return new Response(JSON.stringify({
|
|
13871
14192
|
jsonrpc: "2.0",
|
|
13872
14193
|
error: {
|
|
@@ -13889,14 +14210,17 @@ data:
|
|
|
13889
14210
|
try {
|
|
13890
14211
|
const acceptHeader = req.headers.get("accept");
|
|
13891
14212
|
if (!acceptHeader?.includes("application/json") || !acceptHeader.includes("text/event-stream")) {
|
|
14213
|
+
this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream"));
|
|
13892
14214
|
return this.createJsonErrorResponse(406, -32e3, "Not Acceptable: Client must accept both application/json and text/event-stream");
|
|
13893
14215
|
}
|
|
13894
14216
|
const ct = req.headers.get("content-type");
|
|
13895
14217
|
if (!ct || !ct.includes("application/json")) {
|
|
14218
|
+
this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json"));
|
|
13896
14219
|
return this.createJsonErrorResponse(415, -32e3, "Unsupported Media Type: Content-Type must be application/json");
|
|
13897
14220
|
}
|
|
13898
14221
|
const requestInfo = {
|
|
13899
|
-
headers: Object.fromEntries(req.headers.entries())
|
|
14222
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
14223
|
+
url: new URL(req.url)
|
|
13900
14224
|
};
|
|
13901
14225
|
let rawMessage;
|
|
13902
14226
|
if (options?.parsedBody !== void 0) {
|
|
@@ -13905,6 +14229,7 @@ data:
|
|
|
13905
14229
|
try {
|
|
13906
14230
|
rawMessage = await req.json();
|
|
13907
14231
|
} catch {
|
|
14232
|
+
this.onerror?.(new Error("Parse error: Invalid JSON"));
|
|
13908
14233
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
|
|
13909
14234
|
}
|
|
13910
14235
|
}
|
|
@@ -13916,14 +14241,17 @@ data:
|
|
|
13916
14241
|
messages = [JSONRPCMessageSchema.parse(rawMessage)];
|
|
13917
14242
|
}
|
|
13918
14243
|
} catch {
|
|
14244
|
+
this.onerror?.(new Error("Parse error: Invalid JSON-RPC message"));
|
|
13919
14245
|
return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON-RPC message");
|
|
13920
14246
|
}
|
|
13921
14247
|
const isInitializationRequest = messages.some(isInitializeRequest);
|
|
13922
14248
|
if (isInitializationRequest) {
|
|
13923
14249
|
if (this._initialized && this.sessionId !== void 0) {
|
|
14250
|
+
this.onerror?.(new Error("Invalid Request: Server already initialized"));
|
|
13924
14251
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Server already initialized");
|
|
13925
14252
|
}
|
|
13926
14253
|
if (messages.length > 1) {
|
|
14254
|
+
this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed"));
|
|
13927
14255
|
return this.createJsonErrorResponse(400, -32600, "Invalid Request: Only one initialization request is allowed");
|
|
13928
14256
|
}
|
|
13929
14257
|
this.sessionId = this.sessionIdGenerator?.();
|
|
@@ -14049,13 +14377,16 @@ data:
|
|
|
14049
14377
|
return void 0;
|
|
14050
14378
|
}
|
|
14051
14379
|
if (!this._initialized) {
|
|
14380
|
+
this.onerror?.(new Error("Bad Request: Server not initialized"));
|
|
14052
14381
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Server not initialized");
|
|
14053
14382
|
}
|
|
14054
14383
|
const sessionId = req.headers.get("mcp-session-id");
|
|
14055
14384
|
if (!sessionId) {
|
|
14385
|
+
this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required"));
|
|
14056
14386
|
return this.createJsonErrorResponse(400, -32e3, "Bad Request: Mcp-Session-Id header is required");
|
|
14057
14387
|
}
|
|
14058
14388
|
if (sessionId !== this.sessionId) {
|
|
14389
|
+
this.onerror?.(new Error("Session not found"));
|
|
14059
14390
|
return this.createJsonErrorResponse(404, -32001, "Session not found");
|
|
14060
14391
|
}
|
|
14061
14392
|
return void 0;
|
|
@@ -14076,6 +14407,7 @@ data:
|
|
|
14076
14407
|
validateProtocolVersion(req) {
|
|
14077
14408
|
const protocolVersion = req.headers.get("mcp-protocol-version");
|
|
14078
14409
|
if (protocolVersion !== null && !SUPPORTED_PROTOCOL_VERSIONS.includes(protocolVersion)) {
|
|
14410
|
+
this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`));
|
|
14079
14411
|
return this.createJsonErrorResponse(400, -32e3, `Bad Request: Unsupported protocol version: ${protocolVersion} (supported versions: ${SUPPORTED_PROTOCOL_VERSIONS.join(", ")})`);
|
|
14080
14412
|
}
|
|
14081
14413
|
return void 0;
|
|
@@ -14282,7 +14614,7 @@ var StreamableHTTPServerTransport = class {
|
|
|
14282
14614
|
};
|
|
14283
14615
|
|
|
14284
14616
|
// __mcpc__cli_latest/node_modules/@jsr/std__cli/parse_args.js
|
|
14285
|
-
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value
|
|
14617
|
+
var FLAG_REGEXP = /^(?:-(?:(?<doubleDash>-)(?<negated>no-)?)?)(?<key>.+?)(?:=(?<value>.*))?$/s;
|
|
14286
14618
|
var LETTER_REGEXP = /[A-Za-z]/;
|
|
14287
14619
|
var NUMBER_REGEXP = /-?\d+(\.\d*)?(e-?\d+)?$/;
|
|
14288
14620
|
var HYPHEN_REGEXP = /^(-|--)[^-]/;
|
|
@@ -14293,12 +14625,19 @@ var NON_WHITESPACE_REGEXP = /\S/;
|
|
|
14293
14625
|
function isNumber(string3) {
|
|
14294
14626
|
return NON_WHITESPACE_REGEXP.test(string3) && Number.isFinite(Number(string3));
|
|
14295
14627
|
}
|
|
14628
|
+
function isConstructorOrProto(obj, key) {
|
|
14629
|
+
return key === "constructor" && typeof obj[key] === "function" || key === "__proto__";
|
|
14630
|
+
}
|
|
14296
14631
|
function setNested(object5, keys, value, collect = false) {
|
|
14297
14632
|
keys = [
|
|
14298
14633
|
...keys
|
|
14299
14634
|
];
|
|
14300
14635
|
const key = keys.pop();
|
|
14301
|
-
|
|
14636
|
+
for (const k of keys) {
|
|
14637
|
+
if (isConstructorOrProto(object5, k)) return;
|
|
14638
|
+
object5 = object5[k] ??= {};
|
|
14639
|
+
}
|
|
14640
|
+
if (isConstructorOrProto(object5, key)) return;
|
|
14302
14641
|
if (collect) {
|
|
14303
14642
|
const v = object5[key];
|
|
14304
14643
|
if (Array.isArray(v)) {
|
|
@@ -14429,7 +14768,7 @@ function parseArgs(args, options) {
|
|
|
14429
14768
|
let key = groups.key;
|
|
14430
14769
|
let value = groups.value;
|
|
14431
14770
|
if (doubleDash2) {
|
|
14432
|
-
if (value) {
|
|
14771
|
+
if (value != null) {
|
|
14433
14772
|
if (booleanSet.has(key)) value = parseBooleanString(value);
|
|
14434
14773
|
setArgument(key, value, arg, true);
|
|
14435
14774
|
continue;
|
|
@@ -14467,6 +14806,10 @@ function parseArgs(args, options) {
|
|
|
14467
14806
|
setArgument(letter, next, arg, true);
|
|
14468
14807
|
continue;
|
|
14469
14808
|
}
|
|
14809
|
+
if (next === "=") {
|
|
14810
|
+
setArgument(letter, "", arg, true);
|
|
14811
|
+
continue argsLoop;
|
|
14812
|
+
}
|
|
14470
14813
|
if (LETTER_REGEXP.test(letter)) {
|
|
14471
14814
|
const groups2 = VALUE_REGEXP.exec(next)?.groups;
|
|
14472
14815
|
if (groups2) {
|
|
@@ -14543,8 +14886,8 @@ function parseArgs(args, options) {
|
|
|
14543
14886
|
import { mkdir, readFile as readFile3, writeFile as writeFile2 } from "node:fs/promises";
|
|
14544
14887
|
import { homedir } from "node:os";
|
|
14545
14888
|
import { dirname, join as join3, resolve as resolve4 } from "node:path";
|
|
14546
|
-
import
|
|
14547
|
-
var CLI_VERSION = "0.1.
|
|
14889
|
+
import process10 from "node:process";
|
|
14890
|
+
var CLI_VERSION = "0.1.52";
|
|
14548
14891
|
function extractServerName(command, commandArgs) {
|
|
14549
14892
|
for (const arg of commandArgs) {
|
|
14550
14893
|
if (!arg.startsWith("-")) {
|
|
@@ -14604,7 +14947,7 @@ async function saveUserConfig(config, newAgentName) {
|
|
|
14604
14947
|
async function createWrapConfig(args) {
|
|
14605
14948
|
if (!args.mcpServers || args.mcpServers.length === 0) {
|
|
14606
14949
|
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'");
|
|
14607
|
-
|
|
14950
|
+
process10.exit(1);
|
|
14608
14951
|
}
|
|
14609
14952
|
const mcpServers = {};
|
|
14610
14953
|
const serverNames = [];
|
|
@@ -14727,7 +15070,7 @@ function parseMcpServer(cmdString, transportType) {
|
|
|
14727
15070
|
};
|
|
14728
15071
|
}
|
|
14729
15072
|
function parseCLIArgs() {
|
|
14730
|
-
const args = parseArgs(
|
|
15073
|
+
const args = parseArgs(process10.argv.slice(2), {
|
|
14731
15074
|
boolean: [
|
|
14732
15075
|
"help",
|
|
14733
15076
|
"version",
|
|
@@ -14816,15 +15159,15 @@ async function loadConfig() {
|
|
|
14816
15159
|
const args = parseCLIArgs();
|
|
14817
15160
|
if (args.version) {
|
|
14818
15161
|
printVersion();
|
|
14819
|
-
|
|
15162
|
+
process10.exit(0);
|
|
14820
15163
|
}
|
|
14821
15164
|
if (args.help) {
|
|
14822
15165
|
printHelp();
|
|
14823
|
-
|
|
15166
|
+
process10.exit(0);
|
|
14824
15167
|
}
|
|
14825
15168
|
if (args.cwd) {
|
|
14826
|
-
const targetCwd = resolve4(
|
|
14827
|
-
|
|
15169
|
+
const targetCwd = resolve4(process10.cwd(), args.cwd);
|
|
15170
|
+
process10.chdir(targetCwd);
|
|
14828
15171
|
console.error(`Changed working directory to: ${targetCwd}`);
|
|
14829
15172
|
}
|
|
14830
15173
|
const mergeSkills = (config) => {
|
|
@@ -14836,7 +15179,7 @@ async function loadConfig() {
|
|
|
14836
15179
|
...args,
|
|
14837
15180
|
saveConfig: true
|
|
14838
15181
|
});
|
|
14839
|
-
|
|
15182
|
+
process10.exit(0);
|
|
14840
15183
|
}
|
|
14841
15184
|
if (args.wrap) {
|
|
14842
15185
|
return mergeSkills(await createWrapConfig({
|
|
@@ -14853,16 +15196,16 @@ async function loadConfig() {
|
|
|
14853
15196
|
throw error;
|
|
14854
15197
|
}
|
|
14855
15198
|
}
|
|
14856
|
-
if (
|
|
15199
|
+
if (process10.env.MCPC_CONFIG) {
|
|
14857
15200
|
try {
|
|
14858
|
-
const parsed = JSON.parse(
|
|
15201
|
+
const parsed = JSON.parse(process10.env.MCPC_CONFIG);
|
|
14859
15202
|
return mergeSkills(applyModeOverride(normalizeConfig(parsed), args.mode));
|
|
14860
15203
|
} catch (error) {
|
|
14861
15204
|
console.error("Failed to parse MCPC_CONFIG environment variable:", error);
|
|
14862
15205
|
throw error;
|
|
14863
15206
|
}
|
|
14864
15207
|
}
|
|
14865
|
-
const configUrl = args.configUrl ||
|
|
15208
|
+
const configUrl = args.configUrl || process10.env.MCPC_CONFIG_URL;
|
|
14866
15209
|
if (configUrl) {
|
|
14867
15210
|
try {
|
|
14868
15211
|
const headers = {
|
|
@@ -14883,7 +15226,7 @@ async function loadConfig() {
|
|
|
14883
15226
|
throw error;
|
|
14884
15227
|
}
|
|
14885
15228
|
}
|
|
14886
|
-
const configFile = args.configFile ||
|
|
15229
|
+
const configFile = args.configFile || process10.env.MCPC_CONFIG_FILE;
|
|
14887
15230
|
if (configFile) {
|
|
14888
15231
|
try {
|
|
14889
15232
|
const config = await loadConfigFromFile(configFile);
|
|
@@ -14908,7 +15251,7 @@ async function loadConfig() {
|
|
|
14908
15251
|
throw error;
|
|
14909
15252
|
}
|
|
14910
15253
|
}
|
|
14911
|
-
const defaultJsonConfigPath = resolve4(
|
|
15254
|
+
const defaultJsonConfigPath = resolve4(process10.cwd(), "mcpc.config.json");
|
|
14912
15255
|
try {
|
|
14913
15256
|
const config = await loadConfigFromFile(defaultJsonConfigPath);
|
|
14914
15257
|
return mergeSkills(applyModeOverride(config, args.mode));
|
|
@@ -14923,7 +15266,7 @@ async function loadConfig() {
|
|
|
14923
15266
|
}
|
|
14924
15267
|
function replaceEnvVars2(str2) {
|
|
14925
15268
|
return str2.replace(/\$([A-Z_][A-Z0-9_]*)/g, (_match, varName) => {
|
|
14926
|
-
return
|
|
15269
|
+
return process10.env[varName] || "";
|
|
14927
15270
|
});
|
|
14928
15271
|
}
|
|
14929
15272
|
function isMarkdownFile2(path) {
|