@caplets/core 0.18.1 → 0.18.2
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as resolveProjectConfigPath, Mt as __exportAll, Ot as CapletsError, St as resolveProjectCapletsRoot, bt as resolveCapletsRoot, gt as loadConfigWithSources, vt as DEFAULT_AUTH_DIR, xt as resolveConfigPath, yt as DEFAULT_COMPLETION_CACHE_DIR } from "./options-
|
|
1
|
+
import { Ct as resolveProjectConfigPath, Mt as __exportAll, Ot as CapletsError, St as resolveProjectCapletsRoot, bt as resolveCapletsRoot, gt as loadConfigWithSources, vt as DEFAULT_AUTH_DIR, xt as resolveConfigPath, yt as DEFAULT_COMPLETION_CACHE_DIR } from "./options-bnsSREid.js";
|
|
2
2
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
@@ -469,9 +469,17 @@ async function completeCliWords(words, options = {}) {
|
|
|
469
469
|
if (normalized.length === 1) return prefixFilter([...topLevelCommandNames], current);
|
|
470
470
|
if (normalized.length === 2 && command in cliSubcommands) return prefixFilter(cliSubcommands[command], current);
|
|
471
471
|
if (normalized.length === 2 && capletIdCommands.has(command)) return prefixFilter(promptResourceCommands.has(command) ? configuredCapletIds(options, { backend: "mcp" }) : configuredCapletIds(options), current);
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
if (qualifiedToolCommands.has(command) || qualifiedPromptCommands.has(command)) {
|
|
473
|
+
const kind = qualifiedToolCommands.has(command) ? "tools" : "prompts";
|
|
474
|
+
const idFilter = qualifiedPromptCommands.has(command) ? { backend: "mcp" } : void 0;
|
|
475
|
+
if (normalized.length === 2) {
|
|
476
|
+
if (current.includes(".")) return prefixFilter((await discoverCompletionCandidates(current.slice(0, current.indexOf(".")), kind, discoveryOptions(options))).map((candidate) => candidate.value), current);
|
|
477
|
+
return prefixFilter(configuredCapletIds(options, idFilter), current);
|
|
478
|
+
}
|
|
479
|
+
if (normalized.length === 3 && subcommand && !subcommand.includes(".")) {
|
|
480
|
+
if (current.startsWith("-")) return [];
|
|
481
|
+
return prefixFilter((await discoverCompletionCandidates(subcommand, kind, discoveryOptions(options))).map((candidate) => candidate.value.replace(`${subcommand}.`, "")), current);
|
|
482
|
+
}
|
|
475
483
|
}
|
|
476
484
|
if (command === cliCommands.readResource && normalized.length === 3) return prefixFilter((await discoverCompletionCandidates(subcommand, "resources", discoveryOptions(options))).map((candidate) => candidate.value), current);
|
|
477
485
|
if (command === cliCommands.auth && ["login", "logout"].includes(subcommand) && normalized.length === 3) return prefixFilter(configuredCapletIds(options), current);
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $ as assertCompleteRequestPrompt, A as CreateMessageResultSchema, At as toSafeError, B as JSONRPCMessageSchema, C as AjvJsonSchemaValidator, D as CallToolRequestSchema, Dt as CAPLETS_ERROR_CODES, E as toJsonSchemaCompat, Et as SERVER_ID_PATTERN, F as EmptyResultSchema, G as ListRootsResultSchema, H as ListPromptsRequestSchema, I as ErrorCode, J as McpError, K as ListToolsRequestSchema, L as GetPromptRequestSchema, M as CreateTaskResultSchema, Nt as __require, O as CallToolResultSchema, Ot as CapletsError, P as ElicitResultSchema, Pt as __toESM, R as InitializeRequestSchema, S as assertToolsCallTaskCapability, St as resolveProjectCapletsRoot, T as mergeCapabilities, Tt as validateCapletFile, U as ListResourceTemplatesRequestSchema, V as LATEST_PROTOCOL_VERSION, W as ListResourcesRequestSchema, X as SUPPORTED_PROTOCOL_VERSIONS, Y as ReadResourceRequestSchema, Z as SetLevelRequestSchema, _t as parseConfig, a as resolveCapletsServer, at as getLiteralValue, bt as resolveCapletsRoot, c as ServerRegistry, ct as getSchemaDescription, d as runOAuthFlow, dt as normalizeObjectSchema, et as assertCompleteRequestResourceTemplate, f as startGenericOAuthFlow, ft as objectFromShape, g as readTokenBundle, gt as loadConfigWithSources, h as isTokenBundleExpired, ht as loadConfig, i as resolveCapletsMode, it as isJSONRPCResultResponse, j as CreateMessageResultWithToolsSchema, jt as __commonJSMin, k as CompleteRequestSchema, kt as redactSecrets, l as capabilityDescription, lt as isSchemaOptional, m as deleteTokenBundle, mt as safeParseAsync, nt as isJSONRPCErrorResponse, o as CapletsEngine, ot as getObjectShape, p as startOAuthFlow, pt as safeParse, q as LoggingLevelSchema, r as parseServerBaseUrl, rt as isJSONRPCRequest, s as handleServerTool, st as getParseErrorMessage, t as controlUrlForBase, tt as isInitializeRequest, u as runGenericOAuthFlow, ut as isZ4Schema, v as ReadBuffer, w as Protocol, wt as discoverCapletFiles, x as assertClientRequestTaskCapability, xt as resolveConfigPath, y as serializeMessage, z as InitializedNotificationSchema } from "./options-
|
|
1
|
+
import { $ as assertCompleteRequestPrompt, A as CreateMessageResultSchema, At as toSafeError, B as JSONRPCMessageSchema, C as AjvJsonSchemaValidator, D as CallToolRequestSchema, Dt as CAPLETS_ERROR_CODES, E as toJsonSchemaCompat, Et as SERVER_ID_PATTERN, F as EmptyResultSchema, G as ListRootsResultSchema, H as ListPromptsRequestSchema, I as ErrorCode, J as McpError, K as ListToolsRequestSchema, L as GetPromptRequestSchema, M as CreateTaskResultSchema, Nt as __require, O as CallToolResultSchema, Ot as CapletsError, P as ElicitResultSchema, Pt as __toESM, R as InitializeRequestSchema, S as assertToolsCallTaskCapability, St as resolveProjectCapletsRoot, T as mergeCapabilities, Tt as validateCapletFile, U as ListResourceTemplatesRequestSchema, V as LATEST_PROTOCOL_VERSION, W as ListResourcesRequestSchema, X as SUPPORTED_PROTOCOL_VERSIONS, Y as ReadResourceRequestSchema, Z as SetLevelRequestSchema, _t as parseConfig, a as resolveCapletsServer, at as getLiteralValue, bt as resolveCapletsRoot, c as ServerRegistry, ct as getSchemaDescription, d as runOAuthFlow, dt as normalizeObjectSchema, et as assertCompleteRequestResourceTemplate, f as startGenericOAuthFlow, ft as objectFromShape, g as readTokenBundle, gt as loadConfigWithSources, h as isTokenBundleExpired, ht as loadConfig, i as resolveCapletsMode, it as isJSONRPCResultResponse, j as CreateMessageResultWithToolsSchema, jt as __commonJSMin, k as CompleteRequestSchema, kt as redactSecrets, l as capabilityDescription, lt as isSchemaOptional, m as deleteTokenBundle, mt as safeParseAsync, nt as isJSONRPCErrorResponse, o as CapletsEngine, ot as getObjectShape, p as startOAuthFlow, pt as safeParse, q as LoggingLevelSchema, r as parseServerBaseUrl, rt as isJSONRPCRequest, s as handleServerTool, st as getParseErrorMessage, t as controlUrlForBase, tt as isInitializeRequest, u as runGenericOAuthFlow, ut as isZ4Schema, v as ReadBuffer, w as Protocol, wt as discoverCapletFiles, x as assertClientRequestTaskCapability, xt as resolveConfigPath, y as serializeMessage, z as InitializedNotificationSchema } from "./options-bnsSREid.js";
|
|
2
2
|
import { A as url, C as object, D as string, b as literal, d as ZodOptional, o as generatedToolInputSchema, s as generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema-BYoyY-l-.js";
|
|
3
|
-
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-
|
|
3
|
+
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-L23s2FGB.js";
|
|
4
4
|
import { accessSync, chmodSync, closeSync, constants, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
5
5
|
import { basename, dirname, join, parse, relative, resolve } from "node:path";
|
|
6
6
|
import { execFileSync } from "node:child_process";
|
|
@@ -1320,7 +1320,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
1320
1320
|
} };
|
|
1321
1321
|
//#endregion
|
|
1322
1322
|
//#region package.json
|
|
1323
|
-
var version = "0.18.
|
|
1323
|
+
var version = "0.18.2";
|
|
1324
1324
|
//#endregion
|
|
1325
1325
|
//#region src/serve/session.ts
|
|
1326
1326
|
var CapletsMcpSession = class {
|
|
@@ -9123,7 +9123,7 @@ function createHttpServeApp(options, engine, io = {}) {
|
|
|
9123
9123
|
}
|
|
9124
9124
|
});
|
|
9125
9125
|
}
|
|
9126
|
-
return c.json(await dispatchRemoteCliRequest(request, controlContext(io, writeErr, authFlowStore, c.req.url, paths.control, options.trustProxy, (name) => c.req.header(name))));
|
|
9126
|
+
return c.json(await dispatchRemoteCliRequest(request, controlContext(io, writeErr, authFlowStore, c.req.url, paths.control, options.publicOrigin, options.trustProxy, (name) => c.req.header(name))));
|
|
9127
9127
|
});
|
|
9128
9128
|
app.get(routePath(paths.control, "auth/callback/:flowId"), async (c) => {
|
|
9129
9129
|
const flowId = c.req.param("flowId");
|
|
@@ -9133,7 +9133,7 @@ function createHttpServeApp(options, engine, io = {}) {
|
|
|
9133
9133
|
flowId,
|
|
9134
9134
|
callbackUrl: c.req.url
|
|
9135
9135
|
}
|
|
9136
|
-
}, controlContext(io, writeErr, authFlowStore, c.req.url, paths.control, options.trustProxy, (name) => c.req.header(name)));
|
|
9136
|
+
}, controlContext(io, writeErr, authFlowStore, c.req.url, paths.control, options.publicOrigin, options.trustProxy, (name) => c.req.header(name)));
|
|
9137
9137
|
if (!result.ok) writeErr(`Caplets authentication failed for flow ${flowId}: ${result.error.message}\n`);
|
|
9138
9138
|
return result.ok ? c.text("Caplets authentication complete. You can return to your terminal.") : c.text("Caplets authentication failed. Check server logs for details.", 400);
|
|
9139
9139
|
});
|
|
@@ -9147,12 +9147,12 @@ function createHttpServeApp(options, engine, io = {}) {
|
|
|
9147
9147
|
if (options.warnUnauthenticatedNetwork) writeErr(`Warning: Caplets MCP HTTP server is listening on ${options.host} without authentication.\n`);
|
|
9148
9148
|
return app;
|
|
9149
9149
|
}
|
|
9150
|
-
function controlContext(io, writeErr, authFlowStore, requestUrl, controlPath, trustProxy, header) {
|
|
9150
|
+
function controlContext(io, writeErr, authFlowStore, requestUrl, controlPath, publicOrigin, trustProxy, header) {
|
|
9151
9151
|
return {
|
|
9152
9152
|
...io.control,
|
|
9153
9153
|
projectCapletsRoot: io.control?.projectCapletsRoot ?? resolveProjectCapletsRoot(),
|
|
9154
9154
|
authFlowStore,
|
|
9155
|
-
controlCallbackBaseUrl: new URL(controlPath, publicRequestOrigin(requestUrl, trustProxy, header)).toString(),
|
|
9155
|
+
controlCallbackBaseUrl: new URL(controlPath, publicOrigin ?? publicRequestOrigin(requestUrl, trustProxy, header)).toString(),
|
|
9156
9156
|
writeErr
|
|
9157
9157
|
};
|
|
9158
9158
|
}
|
|
@@ -9319,6 +9319,7 @@ function resolveServeOptions(raw, env = process.env) {
|
|
|
9319
9319
|
host,
|
|
9320
9320
|
port,
|
|
9321
9321
|
path,
|
|
9322
|
+
...serverUrl ? { publicOrigin: serverUrl.origin } : {},
|
|
9322
9323
|
auth,
|
|
9323
9324
|
warnUnauthenticatedNetwork: !loopback && !auth.enabled,
|
|
9324
9325
|
loopback,
|
|
@@ -9519,9 +9520,12 @@ function createProgram(io = {}) {
|
|
|
9519
9520
|
suggestions = remote ? await remote.request("complete_cli", {
|
|
9520
9521
|
shell,
|
|
9521
9522
|
words: completionWords
|
|
9522
|
-
}) : await
|
|
9523
|
+
}) : await completeCliWordsLocally(completionWords, {
|
|
9524
|
+
...configPath ? { configPath } : {},
|
|
9525
|
+
...io.authDir ? { authDir: io.authDir } : {}
|
|
9526
|
+
});
|
|
9523
9527
|
} catch {
|
|
9524
|
-
suggestions = [];
|
|
9528
|
+
suggestions = remote ? [] : await completeCliWords(completionWords, configPath ? { configPath } : {});
|
|
9525
9529
|
}
|
|
9526
9530
|
if (suggestions.length > 0) writeOut(`${suggestions.join("\n")}\n`);
|
|
9527
9531
|
});
|
|
@@ -9715,8 +9719,8 @@ function createProgram(io = {}) {
|
|
|
9715
9719
|
format: options.format
|
|
9716
9720
|
});
|
|
9717
9721
|
});
|
|
9718
|
-
program.command(cliCommands.getTool).description("Print one downstream tool schema.").argument("<caplet
|
|
9719
|
-
const { caplet, tool } = parseQualifiedTarget(
|
|
9722
|
+
program.command(cliCommands.getTool).description("Print one downstream tool schema.").argument("<caplet-or-target>", "Caplet ID or qualified <caplet.tool> target").argument("[tool]", "downstream tool name when caplet is provided separately").option("--format <format>", "output format: markdown, md, plain, or json", parseOutputFormat).action(async (capletOrTarget, toolArgument, options) => {
|
|
9723
|
+
const { caplet, tool } = parseQualifiedTarget(capletOrTarget, toolArgument);
|
|
9720
9724
|
await executeOperation(caplet, {
|
|
9721
9725
|
operation: "get_tool",
|
|
9722
9726
|
tool
|
|
@@ -9730,8 +9734,8 @@ function createProgram(io = {}) {
|
|
|
9730
9734
|
format: options.format
|
|
9731
9735
|
});
|
|
9732
9736
|
});
|
|
9733
|
-
program.command(cliCommands.callTool).description("Call one downstream tool.").argument("<caplet
|
|
9734
|
-
const { caplet, tool } = parseQualifiedTarget(
|
|
9737
|
+
program.command(cliCommands.callTool).description("Call one downstream tool.").argument("<caplet-or-target>", "Caplet ID or qualified <caplet.tool> target").argument("[tool]", "downstream tool name when caplet is provided separately").option("--args <json-object>", "JSON object of downstream tool arguments").option("--field <path>", "project a field from structured output", collect, []).option("--format <format>", "output format: markdown, md, plain, or json", parseOutputFormat).action(async (capletOrTarget, toolArgument, options) => {
|
|
9738
|
+
const { caplet, tool } = parseQualifiedTarget(capletOrTarget, toolArgument);
|
|
9735
9739
|
await executeOperation(caplet, {
|
|
9736
9740
|
operation: "call_tool",
|
|
9737
9741
|
tool,
|
|
@@ -9827,8 +9831,8 @@ function createProgram(io = {}) {
|
|
|
9827
9831
|
remote: remoteClientForCli(io),
|
|
9828
9832
|
format: options.format
|
|
9829
9833
|
}));
|
|
9830
|
-
program.command(cliCommands.getPrompt).description("Get one MCP prompt by name.").argument("<caplet
|
|
9831
|
-
const { caplet, tool: prompt } = parseQualifiedTarget(
|
|
9834
|
+
program.command(cliCommands.getPrompt).description("Get one MCP prompt by name.").argument("<caplet-or-target>", "MCP Caplet ID or qualified <caplet.prompt> target").argument("[prompt]", "prompt name when caplet is provided separately").option("--args <json-object>", "JSON object of prompt arguments").option("--format <format>", "output format: markdown, md, plain, or json", parseOutputFormat).action(async (capletOrTarget, promptArgument, options) => {
|
|
9835
|
+
const { caplet, tool: prompt } = parseQualifiedTarget(capletOrTarget, promptArgument);
|
|
9832
9836
|
await executeOperation(caplet, {
|
|
9833
9837
|
operation: "get_prompt",
|
|
9834
9838
|
prompt,
|
|
@@ -9993,14 +9997,33 @@ function parseOutputFormat(value) {
|
|
|
9993
9997
|
default: throw new CapletsError("REQUEST_INVALID", `Expected output format markdown, md, plain, or json; got ${value}`);
|
|
9994
9998
|
}
|
|
9995
9999
|
}
|
|
9996
|
-
function parseQualifiedTarget(
|
|
9997
|
-
|
|
9998
|
-
|
|
10000
|
+
function parseQualifiedTarget(capletOrTarget, toolArgument) {
|
|
10001
|
+
if (toolArgument !== void 0) {
|
|
10002
|
+
if (capletOrTarget.length === 0 || toolArgument.length === 0) throw new CapletsError("REQUEST_INVALID", "Expected target in the form <caplet> <tool> or <caplet>.<tool>");
|
|
10003
|
+
return {
|
|
10004
|
+
caplet: capletOrTarget,
|
|
10005
|
+
tool: toolArgument
|
|
10006
|
+
};
|
|
10007
|
+
}
|
|
10008
|
+
const dot = capletOrTarget.indexOf(".");
|
|
10009
|
+
if (dot <= 0 || dot === capletOrTarget.length - 1) throw new CapletsError("REQUEST_INVALID", "Expected target in the form <caplet> <tool> or <caplet>.<tool>");
|
|
9999
10010
|
return {
|
|
10000
|
-
caplet:
|
|
10001
|
-
tool:
|
|
10011
|
+
caplet: capletOrTarget.slice(0, dot),
|
|
10012
|
+
tool: capletOrTarget.slice(dot + 1)
|
|
10002
10013
|
};
|
|
10003
10014
|
}
|
|
10015
|
+
async function completeCliWordsLocally(words, options) {
|
|
10016
|
+
const engine = new CapletsEngine({
|
|
10017
|
+
...options.configPath ? { configPath: options.configPath } : {},
|
|
10018
|
+
...options.authDir ? { authDir: options.authDir } : {},
|
|
10019
|
+
watch: false
|
|
10020
|
+
});
|
|
10021
|
+
try {
|
|
10022
|
+
return await engine.completeCliWords(words);
|
|
10023
|
+
} finally {
|
|
10024
|
+
await engine.close();
|
|
10025
|
+
}
|
|
10026
|
+
}
|
|
10004
10027
|
function parseCallToolArgs(value) {
|
|
10005
10028
|
if (value === void 0) return {};
|
|
10006
10029
|
let parsed;
|
package/dist/native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ot as CapletsError, Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, i as resolveCapletsMode, l as capabilityDescription, n as mcpUrlForBase, o as CapletsEngine } from "./options-
|
|
1
|
+
import { Ot as CapletsError, Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, i as resolveCapletsMode, l as capabilityDescription, n as mcpUrlForBase, o as CapletsEngine } from "./options-bnsSREid.js";
|
|
2
2
|
import { a as generatedToolInputJsonSchemaForCaplet, i as generatedToolInputJsonSchema, l as operations, o as generatedToolInputSchema } from "./generated-tool-input-schema-BYoyY-l-.js";
|
|
3
3
|
//#region src/native/options.ts
|
|
4
4
|
const DEFAULT_POLL_INTERVAL_MS = 3e4;
|
|
@@ -53853,7 +53853,7 @@ var CapletsEngine = class {
|
|
|
53853
53853
|
}
|
|
53854
53854
|
}
|
|
53855
53855
|
async completeCliWords(words) {
|
|
53856
|
-
const { completeCliWords } = await import("./completion-
|
|
53856
|
+
const { completeCliWords } = await import("./completion-L23s2FGB.js").then((n) => n.r);
|
|
53857
53857
|
return await completeCliWords(words, {
|
|
53858
53858
|
config: this.registry.config,
|
|
53859
53859
|
managers: {
|
package/dist/serve/options.d.ts
CHANGED