@caplets/core 0.20.1 → 0.20.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 { St as resolveProjectConfigPath, Y as loadConfigWithSources, bt as resolveConfigPath, mt as DEFAULT_COMPLETION_CACHE_DIR, pt as DEFAULT_AUTH_DIR, vn as __exportAll, yt as resolveCapletsRoot } from "./service-
|
|
1
|
+
import { St as resolveProjectConfigPath, Y as loadConfigWithSources, bt as resolveConfigPath, mt as DEFAULT_COMPLETION_CACHE_DIR, pt as DEFAULT_AUTH_DIR, vn as __exportAll, yt as resolveCapletsRoot } from "./service-D3W-LuOx.js";
|
|
2
2
|
import { u as CapletsError } from "./validation-CdqbI2zN.js";
|
|
3
3
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as parseConfig, $t as ReadResourceRequestSchema, A as QuickJsCodeModeSandbox, At as toJsonSchemaCompat, B as CapletsEngine, Bt as ErrorCode, C as nativeCapletToolName, Ct as ReadBuffer, D as codeModeRunInputSchema, Dt as AjvJsonSchemaValidator, Et as assertToolsCallTaskCapability, F as redactCodeModeLogText, Ft as CreateMessageResultWithToolsSchema, G as handleServerTool, Gt as LATEST_PROTOCOL_VERSION, H as decodeDirectResourceUri, Ht as InitializeRequestSchema, I as codeModeDeclarationHash, It as CreateTaskResultSchema, J as loadConfig, Jt as ListResourcesRequestSchema, K as ServerRegistry, Kt as ListPromptsRequestSchema, L as generateCodeModeDeclarations, M as createCodeModeCapletsApi, Mt as CallToolResultSchema, N as listCodeModeCallableCaplets, Nt as CompleteRequestSchema, O as codeModeRunParamsSchema, Ot as Protocol, P as CodeModeLogStore, Pt as CreateMessageResultSchema, Q as loadProjectConfig, Qt as McpError, R as generateCodeModeRunToolDescription, Rt as ElicitResultSchema, S as nativeCapletToolDescription, St as resolveProjectConfigPath, T as nativeCodeModeToolId, Tt as assertClientRequestTaskCapability, U as findProjectRoot, Ut as InitializedNotificationSchema, V as resolveExposure, Vt as GetPromptRequestSchema, W as fingerprintProjectRoot, Wt as JSONRPCMessageSchema, X as loadGlobalConfig, Xt as ListToolsRequestSchema, Y as loadConfigWithSources, Yt as ListRootsResultSchema, Z as loadLocalOverlayConfigWithSources, Zt as LoggingLevelSchema, _ as controlUrlForBase, _n as safeParseAsync, _t as defaultConfigBaseDir, a as projectBindingError, an as isJSONRPCErrorResponse, at as markdownStructuredContent, b as resolveCapletsServer, bt as resolveConfigPath, c as cloudAuthPath, cn as getLiteralValue, ct as startGenericOAuthFlow, d as CloudAuthClient, dn as getSchemaDescription, dt as isTokenBundleExpired, en as SUPPORTED_PROTOCOL_VERSIONS, et as discoverCapletFiles, fn as isSchemaOptional, ft as readTokenBundle, g as resolveCapletsRemote, gn as safeParse, gt as defaultCacheBaseDir, hn as objectFromShape, ht as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, i as ProjectBindingError, in as isInitializeRequest, it as markdownCallToolResultContent, j as diagnoseCodeModeTypeScript, jt as CallToolRequestSchema, k as runCodeMode, kt as mergeCapabilities, l as migrateCredentials, ln as getObjectShape, lt as startOAuthFlow, m as buildProjectSyncManifest, mn as normalizeObjectSchema, n as resolveRemoteSelection, nn as assertCompleteRequestPrompt, nt as loadCapletFilesFromMap, o as projectBindingRecovery, on as isJSONRPCRequest, ot as runGenericOAuthFlow, p as createSdkRemoteCapletsClient, pn as isZ4Schema, q as capabilityDescription, qt as ListResourceTemplatesRequestSchema, r as PROJECT_BINDING_ERROR_CODES, rn as assertCompleteRequestResourceTemplate, rt as hasRenderableStructuredContent, s as CloudAuthStore, sn as isJSONRPCResultResponse, st as runOAuthFlow, t as createNativeCapletsService, tn as SetLevelRequestSchema, tt as validateCapletFile, u as redactedCloudAuthStatus, un as getParseErrorMessage, ut as deleteTokenBundle, v as parseServerBaseUrl, vt as defaultStateBaseDir, wt as serializeMessage, x as nativeCapletPromptGuidance, xt as resolveProjectCapletsRoot, y as resolveCapletsMode, yt as resolveCapletsRoot, z as minifyCodeModeDeclarationText, zt as EmptyResultSchema } from "./service-
|
|
1
|
+
import { $ as parseConfig, $t as ReadResourceRequestSchema, A as QuickJsCodeModeSandbox, At as toJsonSchemaCompat, B as CapletsEngine, Bt as ErrorCode, C as nativeCapletToolName, Ct as ReadBuffer, D as codeModeRunInputSchema, Dt as AjvJsonSchemaValidator, Et as assertToolsCallTaskCapability, F as redactCodeModeLogText, Ft as CreateMessageResultWithToolsSchema, G as handleServerTool, Gt as LATEST_PROTOCOL_VERSION, H as decodeDirectResourceUri, Ht as InitializeRequestSchema, I as codeModeDeclarationHash, It as CreateTaskResultSchema, J as loadConfig, Jt as ListResourcesRequestSchema, K as ServerRegistry, Kt as ListPromptsRequestSchema, L as generateCodeModeDeclarations, M as createCodeModeCapletsApi, Mt as CallToolResultSchema, N as listCodeModeCallableCaplets, Nt as CompleteRequestSchema, O as codeModeRunParamsSchema, Ot as Protocol, P as CodeModeLogStore, Pt as CreateMessageResultSchema, Q as loadProjectConfig, Qt as McpError, R as generateCodeModeRunToolDescription, Rt as ElicitResultSchema, S as nativeCapletToolDescription, St as resolveProjectConfigPath, T as nativeCodeModeToolId, Tt as assertClientRequestTaskCapability, U as findProjectRoot, Ut as InitializedNotificationSchema, V as resolveExposure, Vt as GetPromptRequestSchema, W as fingerprintProjectRoot, Wt as JSONRPCMessageSchema, X as loadGlobalConfig, Xt as ListToolsRequestSchema, Y as loadConfigWithSources, Yt as ListRootsResultSchema, Z as loadLocalOverlayConfigWithSources, Zt as LoggingLevelSchema, _ as controlUrlForBase, _n as safeParseAsync, _t as defaultConfigBaseDir, a as projectBindingError, an as isJSONRPCErrorResponse, at as markdownStructuredContent, b as resolveCapletsServer, bt as resolveConfigPath, c as cloudAuthPath, cn as getLiteralValue, ct as startGenericOAuthFlow, d as CloudAuthClient, dn as getSchemaDescription, dt as isTokenBundleExpired, en as SUPPORTED_PROTOCOL_VERSIONS, et as discoverCapletFiles, fn as isSchemaOptional, ft as readTokenBundle, g as resolveCapletsRemote, gn as safeParse, gt as defaultCacheBaseDir, hn as objectFromShape, ht as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, i as ProjectBindingError, in as isInitializeRequest, it as markdownCallToolResultContent, j as diagnoseCodeModeTypeScript, jt as CallToolRequestSchema, k as runCodeMode, kt as mergeCapabilities, l as migrateCredentials, ln as getObjectShape, lt as startOAuthFlow, m as buildProjectSyncManifest, mn as normalizeObjectSchema, n as resolveRemoteSelection, nn as assertCompleteRequestPrompt, nt as loadCapletFilesFromMap, o as projectBindingRecovery, on as isJSONRPCRequest, ot as runGenericOAuthFlow, p as createSdkRemoteCapletsClient, pn as isZ4Schema, q as capabilityDescription, qt as ListResourceTemplatesRequestSchema, r as PROJECT_BINDING_ERROR_CODES, rn as assertCompleteRequestResourceTemplate, rt as hasRenderableStructuredContent, s as CloudAuthStore, sn as isJSONRPCResultResponse, st as runOAuthFlow, t as createNativeCapletsService, tn as SetLevelRequestSchema, tt as validateCapletFile, u as redactedCloudAuthStatus, un as getParseErrorMessage, ut as deleteTokenBundle, v as parseServerBaseUrl, vt as defaultStateBaseDir, wt as serializeMessage, x as nativeCapletPromptGuidance, xt as resolveProjectCapletsRoot, y as resolveCapletsMode, yt as resolveCapletsRoot, z as minifyCodeModeDeclarationText, zt as EmptyResultSchema } from "./service-D3W-LuOx.js";
|
|
2
2
|
import { _ as record, b as unknown, d as literal, m as object, n as ZodOptional, o as array, p as number, r as _enum, s as boolean, v as string, x as url } from "./schemas-BZ6BBrh7.js";
|
|
3
3
|
import { f as redactSecrets, i as SERVER_ID_PATTERN, l as CAPLETS_ERROR_CODES, p as toSafeError, u as CapletsError } from "./validation-CdqbI2zN.js";
|
|
4
4
|
import { generatedToolInputSchema, generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema.js";
|
|
5
5
|
import { f as observedOutputShapeKey, i as observeOutputShape, u as FileObservedOutputShapeStore } from "./observed-output-shapes-uzAMQPhg.js";
|
|
6
|
-
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands$1, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-
|
|
6
|
+
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands$1, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-DZg_TWiX.js";
|
|
7
7
|
import { n as normalizeCapletSourcePath, t as FilesystemCapletSource } from "./filesystem-Kkg32TOJ.js";
|
|
8
8
|
import { parseConfig as parseConfig$1 } from "./config-runtime.js";
|
|
9
9
|
import fs, { accessSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
@@ -1553,7 +1553,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
1553
1553
|
} };
|
|
1554
1554
|
//#endregion
|
|
1555
1555
|
//#region package.json
|
|
1556
|
-
var version = "0.20.
|
|
1556
|
+
var version = "0.20.2";
|
|
1557
1557
|
//#endregion
|
|
1558
1558
|
//#region src/serve/session.ts
|
|
1559
1559
|
var CapletsMcpSession = class {
|
|
@@ -7110,6 +7110,7 @@ function resolveServeOptions(raw, env = process.env) {
|
|
|
7110
7110
|
path,
|
|
7111
7111
|
...serverUrl ? { publicOrigin: serverUrl.origin } : {},
|
|
7112
7112
|
auth,
|
|
7113
|
+
allowUnauthenticatedHttp: raw.allowUnauthenticatedHttp === true,
|
|
7113
7114
|
warnUnauthenticatedNetwork: !loopback && !auth.enabled,
|
|
7114
7115
|
loopback,
|
|
7115
7116
|
trustProxy: raw.trustProxy === true
|
|
@@ -11135,13 +11136,16 @@ function safeEqual(left, right) {
|
|
|
11135
11136
|
}
|
|
11136
11137
|
function dnsRebindingOptions(options) {
|
|
11137
11138
|
const hostForHeader = options.host === "::1" ? "[::1]" : options.host;
|
|
11139
|
+
const publicUrl = options.publicOrigin ? new URL(options.publicOrigin) : void 0;
|
|
11140
|
+
const publicHosts = publicUrl && (options.auth.enabled || options.allowUnauthenticatedHttp) ? [publicUrl.hostname, publicUrl.host] : [];
|
|
11138
11141
|
return {
|
|
11139
11142
|
enableDnsRebindingProtection: true,
|
|
11140
11143
|
allowedHosts: [
|
|
11141
11144
|
options.host,
|
|
11142
11145
|
hostForHeader,
|
|
11143
11146
|
`${hostForHeader}:${options.port}`,
|
|
11144
|
-
`localhost:${options.port}
|
|
11147
|
+
`localhost:${options.port}`,
|
|
11148
|
+
...publicHosts
|
|
11145
11149
|
]
|
|
11146
11150
|
};
|
|
11147
11151
|
}
|
package/dist/native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as nativeCapletToolName, E as nativeCodeModeToolName, S as nativeCapletToolDescription, T as nativeCodeModeToolId, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletsSystemGuidance, x as nativeCapletPromptGuidance } from "./service-
|
|
1
|
+
import { C as nativeCapletToolName, E as nativeCodeModeToolName, S as nativeCapletToolDescription, T as nativeCodeModeToolId, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletsSystemGuidance, x as nativeCapletPromptGuidance } from "./service-D3W-LuOx.js";
|
|
2
2
|
import { generatedToolInputJsonSchema, generatedToolInputSchema } from "./generated-tool-input-schema.js";
|
|
3
3
|
//#region src/native/process-cleanup.ts
|
|
4
4
|
function registerNativeCapletsProcessCleanup(service, options = {}) {
|
package/dist/serve/options.d.ts
CHANGED
|
@@ -17442,7 +17442,7 @@ async function startOAuthFlow(server, options) {
|
|
|
17442
17442
|
complete: async (callbackUrl) => {
|
|
17443
17443
|
assertNoOAuthCallbackError(server, callbackUrl);
|
|
17444
17444
|
const completion = extractCompletion(callbackUrl);
|
|
17445
|
-
if (completion.state !== provider.state()) throw
|
|
17445
|
+
if (completion.state !== provider.state()) throw oauthStateMismatchError(server.server);
|
|
17446
17446
|
try {
|
|
17447
17447
|
await auth(provider, {
|
|
17448
17448
|
serverUrl: server.url,
|
|
@@ -17536,7 +17536,7 @@ async function startGenericOAuthFlow(target, options) {
|
|
|
17536
17536
|
complete: async (callbackUrl) => {
|
|
17537
17537
|
assertNoOAuthCallbackError(target, callbackUrl);
|
|
17538
17538
|
const completion = extractCompletion(callbackUrl);
|
|
17539
|
-
if (completion.state !== state) throw
|
|
17539
|
+
if (completion.state !== state) throw oauthStateMismatchError(target.server);
|
|
17540
17540
|
const params = new URLSearchParams({
|
|
17541
17541
|
grant_type: "authorization_code",
|
|
17542
17542
|
code: completion.code,
|
|
@@ -17614,7 +17614,7 @@ async function runGenericOAuthFlow(target, options = {}) {
|
|
|
17614
17614
|
code: callbackCode,
|
|
17615
17615
|
...callbackState ? { state: callbackState } : {}
|
|
17616
17616
|
} : void 0);
|
|
17617
|
-
if (completion.state !== state) throw
|
|
17617
|
+
if (completion.state !== state) throw oauthStateMismatchError(target.server);
|
|
17618
17618
|
const params = new URLSearchParams({
|
|
17619
17619
|
grant_type: "authorization_code",
|
|
17620
17620
|
code: completion.code,
|
|
@@ -17659,9 +17659,9 @@ async function runGenericOAuthFlow(target, options = {}) {
|
|
|
17659
17659
|
}
|
|
17660
17660
|
function extractCompletion(input) {
|
|
17661
17661
|
try {
|
|
17662
|
-
const url = new URL(input);
|
|
17663
|
-
const code = url
|
|
17664
|
-
const state = url
|
|
17662
|
+
const url = new URL(stripOAuthCallbackUrlWrapping(input));
|
|
17663
|
+
const code = extractOAuthCallbackParam(url, "code");
|
|
17664
|
+
const state = extractOAuthCallbackParam(url, "state");
|
|
17665
17665
|
if (!code) throw new Error("missing code");
|
|
17666
17666
|
return state ? {
|
|
17667
17667
|
code,
|
|
@@ -17671,6 +17671,27 @@ function extractCompletion(input) {
|
|
|
17671
17671
|
return { code: input.trim() };
|
|
17672
17672
|
}
|
|
17673
17673
|
}
|
|
17674
|
+
function stripOAuthCallbackUrlWrapping(input) {
|
|
17675
|
+
return input.replace(/\s+/g, "");
|
|
17676
|
+
}
|
|
17677
|
+
function extractOAuthCallbackParam(url, name) {
|
|
17678
|
+
const query = url.search.startsWith("?") ? url.search.slice(1) : url.search;
|
|
17679
|
+
for (const part of query.split("&")) {
|
|
17680
|
+
const separator = part.indexOf("=");
|
|
17681
|
+
const rawName = separator < 0 ? part : part.slice(0, separator);
|
|
17682
|
+
const rawValue = separator < 0 ? "" : part.slice(separator + 1);
|
|
17683
|
+
if (decodeOAuthCallbackQueryValue(rawName) === name) return decodeOAuthCallbackQueryValue(rawValue) || void 0;
|
|
17684
|
+
}
|
|
17685
|
+
}
|
|
17686
|
+
function decodeOAuthCallbackQueryValue(value) {
|
|
17687
|
+
return decodeURIComponent(value);
|
|
17688
|
+
}
|
|
17689
|
+
function oauthStateMismatchError(server) {
|
|
17690
|
+
return new CapletsError("AUTH_FAILED", "OAuth callback state did not match. Re-run auth login and use the authorization URL and callback URL from the same attempt.", {
|
|
17691
|
+
server,
|
|
17692
|
+
nextAction: "rerun_caplets_auth_login"
|
|
17693
|
+
});
|
|
17694
|
+
}
|
|
17674
17695
|
function classifyRemoteAuthError(server, response) {
|
|
17675
17696
|
if (response.status !== 401 && response.status !== 403) return;
|
|
17676
17697
|
const challenge = extractWWWAuthenticateParams(response);
|
|
@@ -61779,7 +61800,7 @@ var CapletsEngine = class {
|
|
|
61779
61800
|
}
|
|
61780
61801
|
}
|
|
61781
61802
|
async completeCliWords(words) {
|
|
61782
|
-
const { completeCliWords } = await import("./completion-
|
|
61803
|
+
const { completeCliWords } = await import("./completion-DZg_TWiX.js").then((n) => n.r);
|
|
61783
61804
|
return await completeCliWords(words, {
|
|
61784
61805
|
config: this.registry.config,
|
|
61785
61806
|
managers: {
|