@caplets/core 0.25.0 → 0.26.0
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/dist/caplet-source.js +26 -23
- package/dist/cli/auth.d.ts +1 -0
- package/dist/cli/commands.d.ts +6 -1
- package/dist/cli/doctor.d.ts +1 -0
- package/dist/cli/vault.d.ts +7 -0
- package/dist/cloud/client.d.ts +59 -0
- package/dist/code-mode/platform-runtime.generated.d.ts +1 -1
- package/dist/code-mode.js +6 -6
- package/dist/{completion-DrPr2vYw.js → completion-DaYL-XQN.js} +28 -12
- package/dist/config-runtime.js +2 -2
- package/dist/config.d.ts +39 -6
- package/dist/daemon/validation.d.ts +1 -0
- package/dist/engine.d.ts +6 -2
- package/dist/generated-tool-input-schema.js +1 -1
- package/dist/index.js +517 -58
- package/dist/native.js +1 -1
- package/dist/observed-output-shapes/pure.js +1 -1
- package/dist/{observed-output-shapes-D2k2-q8K.js → observed-output-shapes-DuP7mJQf.js} +1 -1
- package/dist/observed-output-shapes.js +1 -1
- package/dist/remote-control/types.d.ts +1 -1
- package/dist/{schemas-C0PNPwjS.js → schemas-BoqMu4MG.js} +11 -8
- package/dist/{service-DjwB8aiW.js → service-rvZ7z6FI.js} +790 -110
- package/dist/{validation-DgxCzt-A.js → validation-C4tYXw6G.js} +1 -1
- package/dist/vault/access.d.ts +5 -0
- package/dist/vault/crypto.d.ts +19 -0
- package/dist/vault/index.d.ts +40 -0
- package/dist/vault/keys.d.ts +15 -0
- package/dist/vault/store.d.ts +4 -0
- package/dist/vault/types.d.ts +68 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as
|
|
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-
|
|
3
|
-
import { f as redactSecrets$1, i as SERVER_ID_PATTERN, l as CAPLETS_ERROR_CODES, p as toSafeError, u as CapletsError } from "./validation-
|
|
1
|
+
import { $ as resolveExposure, $t as CallToolRequestSchema, A as nativeCapletPromptGuidance, An as getLiteralValue, At as startOAuthFlow, B as CodeModeSessionManager, Bt as defaultStateBaseDir, C as resolveHostedCloudRemote, Cn as SetLevelRequestSchema, Ct as hasRenderableStructuredContent, D as isLoopbackHost, Dn as isJSONRPCErrorResponse, Dt as runGenericOAuthFlow, E as controlUrlForBase, En as isInitializeRequest, Et as refreshOAuthTokenBundle, Fn as isZ4Schema, G as CodeModeJournalStore, Gt as ReadBuffer, H as diagnoseCodeModeTypeScript, Ht as resolveConfigPath, I as codeModeRunInputSchema, In as normalizeObjectSchema, It as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, J as codeModeDeclarationHash, Jt as assertToolsCallTaskCapability, K as CodeModeLogStore, Kt as serializeMessage, L as codeModeRunParamsSchema, Ln as objectFromShape, Lt as defaultCacheBaseDir, M as nativeCapletToolName, Mn as getParseErrorMessage, Mt as isTokenBundleExpired, Nn as getSchemaDescription, Nt as readTokenBundle, O as parseServerBaseUrl, On as isJSONRPCRequest, Ot as runOAuthFlow, Pn as isSchemaOptional, Pt as DEFAULT_AUTH_DIR, Q as CapletsEngine, Qt as toJsonSchemaCompat, R as emptyCodeModeRunMeta, Rn as safeParse, Rt as defaultConfigBaseDir, S as resolveCapletsRemote, Sn as SUPPORTED_PROTOCOL_VERSIONS, St as loadCapletFilesFromMap, T as appendBasePath, Tn as assertCompleteRequestResourceTemplate, Tt as markdownStructuredContent, U as createCodeModeCapletsApi, Ut as resolveProjectCapletsRoot, V as QuickJsCodeModeSandbox, Vt as resolveCapletsRoot, W as listCodeModeCallableCaplets, Wt as resolveProjectConfigPath, X as generateCodeModeRunToolDescription, Xt as Protocol, Y as generateCodeModeDeclarations, Yt as AjvJsonSchemaValidator, Z as minifyCodeModeDeclarationText, Zt as mergeCapabilities, _ as CapletsCloudClient, _n as ListRootsResultSchema, _t as FileVaultStore, a as CloudAuthStore, at as ServerRegistry, b as isCapletsCloudUrl, bn as McpError, bt as discoverCapletFiles, c as redactedCloudAuthStatus, cn as ErrorCode, ct as loadConfig, d as projectBindingError, dn as InitializedNotificationSchema, dt as loadLocalOverlayConfigWithSources, en as CallToolResultSchema, et as decodeDirectResourceUri, f as projectBindingRecovery, fn as JSONRPCMessageSchema, ft as loadProjectConfig, g as buildProjectSyncManifest, gn as ListResourcesRequestSchema, gt as vaultStoreForAuthDir, hn as ListResourceTemplatesRequestSchema, ht as vaultResolverForAuthDir, i as createRemoteProfileStore, in as CreateTaskResultSchema, it as handleServerTool, j as nativeCapletToolDescription, jn as getObjectShape, jt as deleteTokenBundle, k as resolveCapletsServer, kn as isJSONRPCResultResponse, kt as startGenericOAuthFlow, l as PROJECT_BINDING_ERROR_CODES, ln as GetPromptRequestSchema, lt as loadConfigWithSources, mn as ListPromptsRequestSchema, mt as vaultBootstrapResolver, n as resolveRemoteSelection, nn as CreateMessageResultSchema, nt as findProjectRoot, o as cloudAuthPath, on as ElicitResultSchema, ot as capabilityDescription, p as CloudAuthClient, pn as LATEST_PROTOCOL_VERSION, pt as parseConfig, q as redactCodeModeLogText, qt as assertClientRequestTaskCapability, r as cloudCredentialsFromRemoteProfile, rn as CreateMessageResultWithToolsSchema, rt as fingerprintProjectRoot, s as migrateCredentials, sn as EmptyResultSchema, st as GoogleDiscoveryManager, t as createNativeCapletsService, tn as CompleteRequestSchema, tt as directResourceUriMatchesTemplate, u as ProjectBindingError, un as InitializeRequestSchema, ut as loadGlobalConfig, vn as ListToolsRequestSchema, vt as VAULT_MAX_VALUE_BYTES, w as resolveRemoteMode, wn as assertCompleteRequestPrompt, wt as markdownCallToolResultContent, x as normalizeRemoteProfileHostUrl, xn as ReadResourceRequestSchema, xt as validateCapletFile, y as hostedCloudWorkspaceFromRemoteUrl, yn as LoggingLevelSchema, yt as validateVaultKeyName, z as runCodeMode, zn as safeParseAsync, zt as defaultConfigPath } from "./service-rvZ7z6FI.js";
|
|
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-BoqMu4MG.js";
|
|
3
|
+
import { f as redactSecrets$1, i as SERVER_ID_PATTERN, l as CAPLETS_ERROR_CODES, p as toSafeError, u as CapletsError } from "./validation-C4tYXw6G.js";
|
|
4
4
|
import { generatedToolInputJsonSchemaForCaplet, generatedToolInputSchema, generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema.js";
|
|
5
|
-
import { f as observedOutputShapeKey, g as stableJsonStringify, h as schemaHash, i as observeOutputShape, u as FileObservedOutputShapeStore } from "./observed-output-shapes-
|
|
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-
|
|
5
|
+
import { f as observedOutputShapeKey, g as stableJsonStringify, h as schemaHash, i as observeOutputShape, u as FileObservedOutputShapeStore } from "./observed-output-shapes-DuP7mJQf.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-DaYL-XQN.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, fstatSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, readdirSync, readlinkSync, realpathSync, renameSync, rmSync, statSync, watch, writeFileSync, writeSync } from "node:fs";
|
|
@@ -14,9 +14,9 @@ import { Readable, Writable } from "node:stream";
|
|
|
14
14
|
import { STATUS_CODES, createServer } from "node:http";
|
|
15
15
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
16
16
|
import { homedir, tmpdir, userInfo } from "node:os";
|
|
17
|
+
import { Buffer as Buffer$1 } from "node:buffer";
|
|
17
18
|
import { EventEmitter } from "node:events";
|
|
18
19
|
import { promisify, stripVTControlCharacters } from "node:util";
|
|
19
|
-
import { Buffer as Buffer$1 } from "node:buffer";
|
|
20
20
|
import { createInterface } from "node:readline/promises";
|
|
21
21
|
import { Http2ServerRequest, constants as constants$1 } from "node:http2";
|
|
22
22
|
//#region ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_zod@4.4.3/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
|
|
@@ -1553,7 +1553,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
1553
1553
|
} };
|
|
1554
1554
|
//#endregion
|
|
1555
1555
|
//#region package.json
|
|
1556
|
-
var version = "0.
|
|
1556
|
+
var version = "0.26.0";
|
|
1557
1557
|
//#endregion
|
|
1558
1558
|
//#region src/serve/session.ts
|
|
1559
1559
|
var CapletsMcpSession = class {
|
|
@@ -4853,7 +4853,7 @@ new Command();
|
|
|
4853
4853
|
//#region src/cli/author.ts
|
|
4854
4854
|
function authorCliCaplet(id, options = {}) {
|
|
4855
4855
|
const repo = resolve(options.repo ?? process.cwd());
|
|
4856
|
-
const include = options.include !== void 0 ? parseInclude(options.include) : options.command ? /* @__PURE__ */ new Set() : new Set([
|
|
4856
|
+
const include = options.include !== void 0 ? parseInclude(options.include) : options.command ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([
|
|
4857
4857
|
"git",
|
|
4858
4858
|
"gh",
|
|
4859
4859
|
"package"
|
|
@@ -5317,7 +5317,7 @@ function isUrlLike(value) {
|
|
|
5317
5317
|
//#endregion
|
|
5318
5318
|
//#region src/cli/cloud-add.ts
|
|
5319
5319
|
const MAX_CLOUD_CAPLET_BUNDLE_BYTES = 2 * 1024 * 1024;
|
|
5320
|
-
const SKIPPED_DIRECTORY_NAMES = new Set([
|
|
5320
|
+
const SKIPPED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
|
|
5321
5321
|
".git",
|
|
5322
5322
|
"node_modules",
|
|
5323
5323
|
"auth"
|
|
@@ -5353,7 +5353,7 @@ function collectFiles(root) {
|
|
|
5353
5353
|
//#endregion
|
|
5354
5354
|
//#region src/cli/auth.ts
|
|
5355
5355
|
async function loginAuth(serverId, options) {
|
|
5356
|
-
const server = await resolveAuthTarget$1(serverId, options.config ??
|
|
5356
|
+
const server = await resolveAuthTarget$1(serverId, options.config ?? loadAuthResolvedConfig(options), options.authDir);
|
|
5357
5357
|
assertLoginTarget(server, serverId);
|
|
5358
5358
|
try {
|
|
5359
5359
|
const flowOptions = {
|
|
@@ -5375,7 +5375,7 @@ function logoutAuth(serverId, options) {
|
|
|
5375
5375
|
else options.writeOut(`No OAuth credentials found for \`${serverId}\`.\n`);
|
|
5376
5376
|
}
|
|
5377
5377
|
function logoutAuthResult(serverId, options) {
|
|
5378
|
-
assertLoginTarget(findAuthTarget(serverId, options.config ?? loadConfig(options.configPath)), serverId);
|
|
5378
|
+
assertLoginTarget(findAuthTarget(serverId, options.config ?? loadConfig(options.configPath, void 0, { vaultResolver: vaultBootstrapResolver })), serverId);
|
|
5379
5379
|
return {
|
|
5380
5380
|
server: serverId,
|
|
5381
5381
|
deleted: deleteTokenBundle(serverId, options.authDir)
|
|
@@ -5386,13 +5386,16 @@ async function refreshAuth(serverId, options) {
|
|
|
5386
5386
|
options.writeOut(`Refreshed OAuth credentials for \`${serverId}\`.\n`);
|
|
5387
5387
|
}
|
|
5388
5388
|
async function refreshAuthResult(serverId, options) {
|
|
5389
|
-
const target = await resolveAuthTarget$1(serverId, options.config ??
|
|
5389
|
+
const target = await resolveAuthTarget$1(serverId, options.config ?? loadAuthResolvedConfig(options), options.authDir);
|
|
5390
5390
|
assertLoginTarget(target, serverId);
|
|
5391
5391
|
await refreshOAuthTokenBundle(target, options.authDir);
|
|
5392
5392
|
return { server: serverId };
|
|
5393
5393
|
}
|
|
5394
5394
|
function listAuthRows(options) {
|
|
5395
|
-
return authRowsForTargets(authTargets(loadConfig(options.configPath)), options.authDir);
|
|
5395
|
+
return authRowsForTargets(authTargets(loadConfig(options.configPath, void 0, { vaultResolver: vaultBootstrapResolver })), options.authDir);
|
|
5396
|
+
}
|
|
5397
|
+
function loadAuthResolvedConfig(options) {
|
|
5398
|
+
return loadConfig(options.configPath, void 0, { vaultResolver: vaultResolverForAuthDir(options.authDir) });
|
|
5396
5399
|
}
|
|
5397
5400
|
function listLocalAuthRows(options) {
|
|
5398
5401
|
return authRowsForTargets(localAuthTargets(options), options.authDir);
|
|
@@ -5402,7 +5405,7 @@ function localAuthTargets(options) {
|
|
|
5402
5405
|
}
|
|
5403
5406
|
function localAuthConfigForTarget(options) {
|
|
5404
5407
|
assertLoginTarget(localAuthTargets(options).find((candidate) => candidate.server === options.serverId), options.serverId);
|
|
5405
|
-
return loadConfigForSource(options.source, options);
|
|
5408
|
+
return loadConfigForSource(options.source, options, { vaultResolver: vaultResolverForAuthDir(options.authDir) });
|
|
5406
5409
|
}
|
|
5407
5410
|
function authTargetsForSource(source, options) {
|
|
5408
5411
|
try {
|
|
@@ -5415,9 +5418,9 @@ function authTargetsForSource(source, options) {
|
|
|
5415
5418
|
throw error;
|
|
5416
5419
|
}
|
|
5417
5420
|
}
|
|
5418
|
-
function loadConfigForSource(source, options) {
|
|
5419
|
-
if (source === "global") return loadGlobalConfig(options.configPath);
|
|
5420
|
-
return loadProjectConfig(options.projectConfigPath);
|
|
5421
|
+
function loadConfigForSource(source, options, loadOptions = { vaultResolver: vaultBootstrapResolver }) {
|
|
5422
|
+
if (source === "global") return loadGlobalConfig(options.configPath, loadOptions);
|
|
5423
|
+
return loadProjectConfig(options.projectConfigPath, loadOptions);
|
|
5421
5424
|
}
|
|
5422
5425
|
function authRowsForTargets(targets, authDir) {
|
|
5423
5426
|
return targets.sort((left, right) => left.server.localeCompare(right.server)).map((server) => {
|
|
@@ -6166,7 +6169,7 @@ Description=Caplets daemon
|
|
|
6166
6169
|
|
|
6167
6170
|
[Service]
|
|
6168
6171
|
Type=simple
|
|
6169
|
-
WorkingDirectory=${
|
|
6172
|
+
WorkingDirectory=${systemdEscape(config.command.workingDirectory, true)}
|
|
6170
6173
|
${env ? `${env}\n` : ""}ExecStart=${[command.executable, ...command.args].map((value) => systemdQuote(value)).join(" ")}
|
|
6171
6174
|
Restart=on-failure
|
|
6172
6175
|
StandardOutput=append:${systemdEscape(config.paths.stdoutLog, true)}
|
|
@@ -7109,7 +7112,7 @@ function isTransientRunnerPath(path) {
|
|
|
7109
7112
|
return /(?:^|\/)_npx(?:\/|$)/u.test(normalized) || /(?:^|\/)dlx-[^/]+(?:\/|$)/u.test(normalized);
|
|
7110
7113
|
}
|
|
7111
7114
|
//#endregion
|
|
7112
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7115
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/compose.js
|
|
7113
7116
|
var compose = (middleware, onError, onNotFound) => {
|
|
7114
7117
|
return (context, next) => {
|
|
7115
7118
|
let index = -1;
|
|
@@ -7140,7 +7143,7 @@ var compose = (middleware, onError, onNotFound) => {
|
|
|
7140
7143
|
};
|
|
7141
7144
|
};
|
|
7142
7145
|
//#endregion
|
|
7143
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7146
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/http-exception.js
|
|
7144
7147
|
var HTTPException = class extends Error {
|
|
7145
7148
|
res;
|
|
7146
7149
|
status;
|
|
@@ -7168,10 +7171,10 @@ var HTTPException = class extends Error {
|
|
|
7168
7171
|
}
|
|
7169
7172
|
};
|
|
7170
7173
|
//#endregion
|
|
7171
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7174
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/request/constants.js
|
|
7172
7175
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
7173
7176
|
//#endregion
|
|
7174
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7177
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/utils/body.js
|
|
7175
7178
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
7176
7179
|
const { all = false, dot = false } = options;
|
|
7177
7180
|
const contentType = (request instanceof HonoRequest ? request.raw.headers : request.headers).get("Content-Type");
|
|
@@ -7219,7 +7222,7 @@ var handleParsingNestedValues = (form, key, value) => {
|
|
|
7219
7222
|
});
|
|
7220
7223
|
};
|
|
7221
7224
|
//#endregion
|
|
7222
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7225
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/utils/url.js
|
|
7223
7226
|
var splitPath = (path) => {
|
|
7224
7227
|
const paths = path.split("/");
|
|
7225
7228
|
if (paths[0] === "") paths.shift();
|
|
@@ -7383,7 +7386,7 @@ var getQueryParams = (url, key) => {
|
|
|
7383
7386
|
};
|
|
7384
7387
|
var decodeURIComponent_ = decodeURIComponent;
|
|
7385
7388
|
//#endregion
|
|
7386
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7389
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/request.js
|
|
7387
7390
|
var tryDecodeURIComponent = (str) => tryDecode(str, decodeURIComponent_);
|
|
7388
7391
|
var HonoRequest = class {
|
|
7389
7392
|
/**
|
|
@@ -7655,7 +7658,7 @@ var HonoRequest = class {
|
|
|
7655
7658
|
}
|
|
7656
7659
|
};
|
|
7657
7660
|
//#endregion
|
|
7658
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7661
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/utils/html.js
|
|
7659
7662
|
var HtmlEscapedCallbackPhase = {
|
|
7660
7663
|
Stringify: 1,
|
|
7661
7664
|
BeforeStream: 2,
|
|
@@ -7685,7 +7688,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
7685
7688
|
else return resStr;
|
|
7686
7689
|
};
|
|
7687
7690
|
//#endregion
|
|
7688
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
7691
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/context.js
|
|
7689
7692
|
var TEXT_PLAIN = "text/plain; charset=UTF-8";
|
|
7690
7693
|
var setDefaultContentType = (contentType, headers) => {
|
|
7691
7694
|
return {
|
|
@@ -8046,7 +8049,7 @@ var Context = class {
|
|
|
8046
8049
|
};
|
|
8047
8050
|
};
|
|
8048
8051
|
//#endregion
|
|
8049
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8052
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router.js
|
|
8050
8053
|
var METHODS = [
|
|
8051
8054
|
"get",
|
|
8052
8055
|
"post",
|
|
@@ -8058,10 +8061,10 @@ var METHODS = [
|
|
|
8058
8061
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
8059
8062
|
var UnsupportedPathError = class extends Error {};
|
|
8060
8063
|
//#endregion
|
|
8061
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8064
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/utils/constants.js
|
|
8062
8065
|
var COMPOSED_HANDLER = "__COMPOSED_HANDLER";
|
|
8063
8066
|
//#endregion
|
|
8064
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8067
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/hono-base.js
|
|
8065
8068
|
var notFoundHandler = (c) => {
|
|
8066
8069
|
return c.text("404 Not Found", 404);
|
|
8067
8070
|
};
|
|
@@ -8395,7 +8398,7 @@ var Hono$1 = class _Hono {
|
|
|
8395
8398
|
};
|
|
8396
8399
|
};
|
|
8397
8400
|
//#endregion
|
|
8398
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8401
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/reg-exp-router/matcher.js
|
|
8399
8402
|
var emptyParam = [];
|
|
8400
8403
|
function match(method, path) {
|
|
8401
8404
|
const matchers = this.buildAllMatchers();
|
|
@@ -8412,7 +8415,7 @@ function match(method, path) {
|
|
|
8412
8415
|
return match2(method, path);
|
|
8413
8416
|
}
|
|
8414
8417
|
//#endregion
|
|
8415
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8418
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/reg-exp-router/node.js
|
|
8416
8419
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
8417
8420
|
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
8418
8421
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
@@ -8491,7 +8494,7 @@ var Node$1 = class _Node {
|
|
|
8491
8494
|
}
|
|
8492
8495
|
};
|
|
8493
8496
|
//#endregion
|
|
8494
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8497
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/reg-exp-router/trie.js
|
|
8495
8498
|
var Trie = class {
|
|
8496
8499
|
#context = { varIndex: 0 };
|
|
8497
8500
|
#root = new Node$1();
|
|
@@ -8549,7 +8552,7 @@ var Trie = class {
|
|
|
8549
8552
|
}
|
|
8550
8553
|
};
|
|
8551
8554
|
//#endregion
|
|
8552
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8555
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/reg-exp-router/router.js
|
|
8553
8556
|
var nullMatcher = [
|
|
8554
8557
|
/^$/,
|
|
8555
8558
|
[],
|
|
@@ -8680,7 +8683,7 @@ var RegExpRouter = class {
|
|
|
8680
8683
|
}
|
|
8681
8684
|
};
|
|
8682
8685
|
//#endregion
|
|
8683
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8686
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/smart-router/router.js
|
|
8684
8687
|
var SmartRouter = class {
|
|
8685
8688
|
name = "SmartRouter";
|
|
8686
8689
|
#routers = [];
|
|
@@ -8727,7 +8730,7 @@ var SmartRouter = class {
|
|
|
8727
8730
|
}
|
|
8728
8731
|
};
|
|
8729
8732
|
//#endregion
|
|
8730
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8733
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/trie-router/node.js
|
|
8731
8734
|
var emptyParams = /* @__PURE__ */ Object.create(null);
|
|
8732
8735
|
var hasChildren = (children) => {
|
|
8733
8736
|
for (const _ in children) return true;
|
|
@@ -8880,7 +8883,7 @@ var Node = class _Node {
|
|
|
8880
8883
|
}
|
|
8881
8884
|
};
|
|
8882
8885
|
//#endregion
|
|
8883
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8886
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/trie-router/router.js
|
|
8884
8887
|
var TrieRouter = class {
|
|
8885
8888
|
name = "TrieRouter";
|
|
8886
8889
|
#node;
|
|
@@ -8900,7 +8903,7 @@ var TrieRouter = class {
|
|
|
8900
8903
|
}
|
|
8901
8904
|
};
|
|
8902
8905
|
//#endregion
|
|
8903
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8906
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/hono.js
|
|
8904
8907
|
var Hono = class extends Hono$1 {
|
|
8905
8908
|
/**
|
|
8906
8909
|
* Creates an instance of the Hono class.
|
|
@@ -8941,7 +8944,7 @@ object({
|
|
|
8941
8944
|
client_secret: string().optional()
|
|
8942
8945
|
});
|
|
8943
8946
|
//#endregion
|
|
8944
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
8947
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/utils/stream.js
|
|
8945
8948
|
var StreamingApi = class {
|
|
8946
8949
|
writer;
|
|
8947
8950
|
encoder;
|
|
@@ -9014,7 +9017,7 @@ var StreamingApi = class {
|
|
|
9014
9017
|
}
|
|
9015
9018
|
};
|
|
9016
9019
|
//#endregion
|
|
9017
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
9020
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/helper/streaming/sse.js
|
|
9018
9021
|
var SSEStreamingApi = class extends StreamingApi {
|
|
9019
9022
|
constructor(writable, readable) {
|
|
9020
9023
|
super(writable, readable);
|
|
@@ -9038,7 +9041,7 @@ var SSEStreamingApi = class extends StreamingApi {
|
|
|
9038
9041
|
}
|
|
9039
9042
|
};
|
|
9040
9043
|
//#endregion
|
|
9041
|
-
//#region ../../node_modules/.pnpm/@hono+mcp@0.3.0_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__hono-rate-limiter@0.5.
|
|
9044
|
+
//#region ../../node_modules/.pnpm/@hono+mcp@0.3.0_@modelcontextprotocol+sdk@1.29.0_zod@4.4.3__hono-rate-limiter@0.5.3_hon_a02bf6202dadf168876634e2ff64c917/node_modules/@hono/mcp/dist/index.js
|
|
9042
9045
|
let isOldBunVersion = () => {
|
|
9043
9046
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
9044
9047
|
if (version === void 0) return false;
|
|
@@ -9479,7 +9482,7 @@ var StreamableHTTPTransport = class {
|
|
|
9479
9482
|
}
|
|
9480
9483
|
};
|
|
9481
9484
|
//#endregion
|
|
9482
|
-
//#region ../../node_modules/.pnpm/@hono+node-server@2.0.
|
|
9485
|
+
//#region ../../node_modules/.pnpm/@hono+node-server@2.0.5_hono@4.12.26/node_modules/@hono/node-server/dist/index.mjs
|
|
9483
9486
|
var RequestError = class extends Error {
|
|
9484
9487
|
constructor(message, options) {
|
|
9485
9488
|
super(message, options);
|
|
@@ -9952,7 +9955,7 @@ const parseRedirectUrl = (url) => {
|
|
|
9952
9955
|
if (validRedirectUrl.test(url)) return url;
|
|
9953
9956
|
return new URL(url).href;
|
|
9954
9957
|
};
|
|
9955
|
-
const validRedirectStatuses = new Set([
|
|
9958
|
+
const validRedirectStatuses = /* @__PURE__ */ new Set([
|
|
9956
9959
|
301,
|
|
9957
9960
|
302,
|
|
9958
9961
|
303,
|
|
@@ -10277,7 +10280,7 @@ const getRequestListener = (fetchCallback, options = {}) => {
|
|
|
10277
10280
|
globalThis.CloseEvent;
|
|
10278
10281
|
const CONNECTION_SYMBOL_KEY = Symbol("CONNECTION_SYMBOL_KEY");
|
|
10279
10282
|
const WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
|
|
10280
|
-
const responseHeadersToSkip = new Set([
|
|
10283
|
+
const responseHeadersToSkip = /* @__PURE__ */ new Set([
|
|
10281
10284
|
"connection",
|
|
10282
10285
|
"content-length",
|
|
10283
10286
|
"keep-alive",
|
|
@@ -10402,7 +10405,7 @@ const serve = (options, listeningListener) => {
|
|
|
10402
10405
|
return server;
|
|
10403
10406
|
};
|
|
10404
10407
|
//#endregion
|
|
10405
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
10408
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/utils/color.js
|
|
10406
10409
|
function getColorEnabled() {
|
|
10407
10410
|
const { process, Deno } = globalThis;
|
|
10408
10411
|
return !(typeof Deno?.noColor === "boolean" ? Deno.noColor : process !== void 0 ? "NO_COLOR" in process?.env : false);
|
|
@@ -10419,7 +10422,7 @@ async function getColorEnabledAsync() {
|
|
|
10419
10422
|
})() : !getColorEnabled());
|
|
10420
10423
|
}
|
|
10421
10424
|
//#endregion
|
|
10422
|
-
//#region ../../node_modules/.pnpm/hono@4.12.
|
|
10425
|
+
//#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/middleware/logger/index.js
|
|
10423
10426
|
var humanize = (times) => {
|
|
10424
10427
|
const [delimiter, separator] = [",", "."];
|
|
10425
10428
|
return times.map((v) => v.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1" + delimiter)).join(separator);
|
|
@@ -11010,7 +11013,7 @@ function nearestExistingParent(path) {
|
|
|
11010
11013
|
}
|
|
11011
11014
|
//#endregion
|
|
11012
11015
|
//#region src/remote-control/dispatch.ts
|
|
11013
|
-
const ENGINE_COMMANDS = new Set([
|
|
11016
|
+
const ENGINE_COMMANDS = /* @__PURE__ */ new Set([
|
|
11014
11017
|
"inspect",
|
|
11015
11018
|
"check",
|
|
11016
11019
|
"tools",
|
|
@@ -11048,7 +11051,7 @@ async function dispatchRemoteCliRequest(request, context) {
|
|
|
11048
11051
|
async function dispatch(request, context) {
|
|
11049
11052
|
assertObject(request, "remote control request");
|
|
11050
11053
|
assertObject(request.arguments, "remote control request arguments");
|
|
11051
|
-
if (request.command === "list") return listCaplets(loadConfigWithSources(context.configPath, context.projectConfigPath), { includeDisabled: optionalBoolean(request.arguments, "includeDisabled") ?? false });
|
|
11054
|
+
if (request.command === "list") return listCaplets(loadConfigWithSources(context.configPath, context.projectConfigPath, { vaultResolver: vaultBootstrapResolver }), { includeDisabled: optionalBoolean(request.arguments, "includeDisabled") ?? false });
|
|
11052
11055
|
if (ENGINE_COMMANDS.has(request.command)) {
|
|
11053
11056
|
const caplet = requiredString(request.arguments, "caplet");
|
|
11054
11057
|
const toolRequest = requiredEngineRequest(request.arguments, request.command);
|
|
@@ -11089,6 +11092,7 @@ async function dispatch(request, context) {
|
|
|
11089
11092
|
...optionalProp("configPath", context.configPath),
|
|
11090
11093
|
...optionalProp("authDir", context.authDir)
|
|
11091
11094
|
});
|
|
11095
|
+
if (request.command.startsWith("vault_")) return dispatchVault(request, context);
|
|
11092
11096
|
if (request.command === "auth_logout") return logoutAuthResult(requiredString(request.arguments, "server"), {
|
|
11093
11097
|
...optionalProp("configPath", context.configPath),
|
|
11094
11098
|
...optionalProp("authDir", context.authDir)
|
|
@@ -11101,9 +11105,76 @@ async function dispatch(request, context) {
|
|
|
11101
11105
|
if (request.command === "auth_login_complete") return completeRemoteAuthLogin(requiredString(request.arguments, "flowId"), requiredString(request.arguments, "callbackUrl"), context);
|
|
11102
11106
|
throw new CapletsError("UNKNOWN_OPERATION", `Unsupported remote control command ${request.command}`);
|
|
11103
11107
|
}
|
|
11108
|
+
function dispatchVault(request, context) {
|
|
11109
|
+
const store = remoteVaultStore(context);
|
|
11110
|
+
switch (request.command) {
|
|
11111
|
+
case "vault_set": {
|
|
11112
|
+
const name = requiredString(request.arguments, "name");
|
|
11113
|
+
const value = requiredString(request.arguments, "value");
|
|
11114
|
+
const grant = optionalString(request.arguments, "grant");
|
|
11115
|
+
const grantInput = grant ? {
|
|
11116
|
+
storedKey: validateVaultKeyName(name),
|
|
11117
|
+
referenceName: validateVaultKeyName(optionalString(request.arguments, "referenceName") ?? name),
|
|
11118
|
+
capletId: grant,
|
|
11119
|
+
origin: remoteVaultAccessOrigin(grant, context)
|
|
11120
|
+
} : void 0;
|
|
11121
|
+
const existed = store.getStatus(name).present;
|
|
11122
|
+
const previousValue = existed && grantInput ? store.resolveValue(name) : void 0;
|
|
11123
|
+
const status = store.set(name, value, { force: optionalBoolean(request.arguments, "force") ?? false });
|
|
11124
|
+
try {
|
|
11125
|
+
if (grantInput) store.grantAccess(grantInput);
|
|
11126
|
+
} catch (error) {
|
|
11127
|
+
if (existed && previousValue !== void 0) store.set(name, previousValue, { force: true });
|
|
11128
|
+
else store.delete(name);
|
|
11129
|
+
throw error;
|
|
11130
|
+
}
|
|
11131
|
+
return {
|
|
11132
|
+
remote: true,
|
|
11133
|
+
...status
|
|
11134
|
+
};
|
|
11135
|
+
}
|
|
11136
|
+
case "vault_list": return store.listValues();
|
|
11137
|
+
case "vault_get": {
|
|
11138
|
+
const name = requiredString(request.arguments, "name");
|
|
11139
|
+
if (optionalBoolean(request.arguments, "reveal") ?? false) throw new CapletsError("REQUEST_INVALID", "Self-hosted remote Vault reveal is not supported through remote control.");
|
|
11140
|
+
return store.getStatus(name);
|
|
11141
|
+
}
|
|
11142
|
+
case "vault_delete": return store.delete(requiredString(request.arguments, "name"));
|
|
11143
|
+
case "vault_access_grant": {
|
|
11144
|
+
const storedKey = requiredString(request.arguments, "name");
|
|
11145
|
+
const capletId = requiredString(request.arguments, "capletId");
|
|
11146
|
+
return store.grantAccess({
|
|
11147
|
+
storedKey,
|
|
11148
|
+
referenceName: optionalString(request.arguments, "referenceName") ?? storedKey,
|
|
11149
|
+
capletId,
|
|
11150
|
+
origin: remoteVaultAccessOrigin(capletId, context)
|
|
11151
|
+
});
|
|
11152
|
+
}
|
|
11153
|
+
case "vault_access_revoke": return store.revokeAccess({
|
|
11154
|
+
storedKey: requiredString(request.arguments, "name"),
|
|
11155
|
+
capletId: requiredString(request.arguments, "capletId"),
|
|
11156
|
+
...optionalProp("referenceName", optionalString(request.arguments, "referenceName"))
|
|
11157
|
+
});
|
|
11158
|
+
case "vault_access_list": return store.listAccess({
|
|
11159
|
+
...optionalProp("storedKey", optionalString(request.arguments, "name")),
|
|
11160
|
+
...optionalProp("capletId", optionalString(request.arguments, "capletId"))
|
|
11161
|
+
});
|
|
11162
|
+
default: throw new CapletsError("UNKNOWN_OPERATION", `Unsupported remote control command ${request.command}`);
|
|
11163
|
+
}
|
|
11164
|
+
}
|
|
11165
|
+
function remoteVaultStore(context) {
|
|
11166
|
+
return vaultStoreForAuthDir(context.authDir);
|
|
11167
|
+
}
|
|
11168
|
+
function remoteVaultAccessOrigin(capletId, context) {
|
|
11169
|
+
const overlay = loadLocalOverlayConfigWithSources(context.configPath, context.projectConfigPath, { vaultResolver: vaultBootstrapResolver });
|
|
11170
|
+
const origin = overlay.sources[capletId];
|
|
11171
|
+
if (!origin) throw new CapletsError("SERVER_NOT_FOUND", `Caplet ${capletId} is not configured.`);
|
|
11172
|
+
if (overlay.shadows[capletId]?.length) throw new CapletsError("REQUEST_INVALID", `Caplet ${capletId} is shadowed in multiple config sources; resolve the active config before granting Vault access.`);
|
|
11173
|
+
return origin;
|
|
11174
|
+
}
|
|
11104
11175
|
async function startRemoteAuthLogin(serverId, context) {
|
|
11105
11176
|
if (!context.authFlowStore || !context.controlCallbackBaseUrl) throw new CapletsError("REQUEST_INVALID", "Remote auth login is not available on this server");
|
|
11106
|
-
const config = loadConfigWithSources(context.configPath, context.projectConfigPath).config;
|
|
11177
|
+
const config = loadConfigWithSources(context.configPath, context.projectConfigPath, { vaultResolver: vaultResolverForAuthDir(context.authDir) }).config;
|
|
11107
11178
|
const target = await resolveAuthTarget$1(serverId, config, context.authDir);
|
|
11108
11179
|
assertLoginTarget(target, serverId);
|
|
11109
11180
|
const flowId = randomUUID();
|
|
@@ -11978,6 +12049,7 @@ function attachEventsResponse(engine, activeStreams) {
|
|
|
11978
12049
|
async function serveHttp(options, engineOptions = {}, writeErr = (value) => process.stderr.write(value)) {
|
|
11979
12050
|
const resolvedEngineOptions = {
|
|
11980
12051
|
exposeLocalArtifactPaths: false,
|
|
12052
|
+
vaultRecoveryTarget: "remote",
|
|
11981
12053
|
...engineOptions
|
|
11982
12054
|
};
|
|
11983
12055
|
const engine = new CapletsEngine(resolvedEngineOptions);
|
|
@@ -12190,6 +12262,8 @@ function formatHost$1(host) {
|
|
|
12190
12262
|
//#endregion
|
|
12191
12263
|
//#region src/daemon/validation.ts
|
|
12192
12264
|
async function validateDaemonCommand(config, options = {}) {
|
|
12265
|
+
const bindHost = await validateBindHost(config);
|
|
12266
|
+
if (!bindHost.ok) return bindHost;
|
|
12193
12267
|
const { spawn } = await import("node:child_process");
|
|
12194
12268
|
const command = validationSpawnCommand(config);
|
|
12195
12269
|
const child = spawn(command.command, command.args, {
|
|
@@ -12230,6 +12304,7 @@ async function validateDaemonCommand(config, options = {}) {
|
|
|
12230
12304
|
if (processDone) break;
|
|
12231
12305
|
last = await Promise.race([probeDaemonHealth(config, {
|
|
12232
12306
|
...options.fetch ? { fetch: options.fetch } : {},
|
|
12307
|
+
skipBindHostValidation: true,
|
|
12233
12308
|
timeoutMs: 750
|
|
12234
12309
|
}), processFailure]);
|
|
12235
12310
|
if (last.ok) return await Promise.race([processFailure, sleep$2(options.successSettleMs ?? 1e3).then(() => void 0)]) ?? last;
|
|
@@ -12249,7 +12324,35 @@ async function validateDaemonCommand(config, options = {}) {
|
|
|
12249
12324
|
}
|
|
12250
12325
|
}
|
|
12251
12326
|
}
|
|
12327
|
+
async function validateBindHost(config) {
|
|
12328
|
+
const { createServer } = await import("node:net");
|
|
12329
|
+
const server = createServer();
|
|
12330
|
+
try {
|
|
12331
|
+
await new Promise((resolve, reject) => {
|
|
12332
|
+
server.once("error", reject);
|
|
12333
|
+
server.listen(0, config.serve.host, () => resolve());
|
|
12334
|
+
});
|
|
12335
|
+
return {
|
|
12336
|
+
ok: true,
|
|
12337
|
+
url: healthUrl(config)
|
|
12338
|
+
};
|
|
12339
|
+
} catch (error) {
|
|
12340
|
+
return {
|
|
12341
|
+
ok: false,
|
|
12342
|
+
url: healthUrl(config),
|
|
12343
|
+
error: `bind host validation failed: ${error instanceof Error ? error.message : String(error)}`
|
|
12344
|
+
};
|
|
12345
|
+
} finally {
|
|
12346
|
+
if (server.listening) await new Promise((resolve, reject) => {
|
|
12347
|
+
server.close((error) => error ? reject(error) : resolve());
|
|
12348
|
+
});
|
|
12349
|
+
}
|
|
12350
|
+
}
|
|
12252
12351
|
async function probeDaemonHealth(config, options = {}) {
|
|
12352
|
+
if (options.skipBindHostValidation !== true) {
|
|
12353
|
+
const bindHost = await validateBindHost(config);
|
|
12354
|
+
if (!bindHost.ok) return bindHost;
|
|
12355
|
+
}
|
|
12253
12356
|
const fetchImpl = options.fetch ?? fetch;
|
|
12254
12357
|
const url = healthUrl(config, options.port);
|
|
12255
12358
|
try {
|
|
@@ -12441,7 +12544,7 @@ async function temporaryValidationConfig(config, options) {
|
|
|
12441
12544
|
};
|
|
12442
12545
|
}
|
|
12443
12546
|
async function validateInstallCommand(input) {
|
|
12444
|
-
const useTemporaryPort = input.existingNativeRunning && (
|
|
12547
|
+
const useTemporaryPort = input.existingNativeRunning && runningDaemonMayOccupyRequestedAddress(input.existing, input.config);
|
|
12445
12548
|
const attempts = useTemporaryPort ? 3 : 1;
|
|
12446
12549
|
let last;
|
|
12447
12550
|
for (let attempt = 0; attempt < attempts; attempt += 1) {
|
|
@@ -12455,6 +12558,17 @@ async function validateInstallCommand(input) {
|
|
|
12455
12558
|
error: "daemon install validation did not run"
|
|
12456
12559
|
};
|
|
12457
12560
|
}
|
|
12561
|
+
function runningDaemonMayOccupyRequestedAddress(existing, config) {
|
|
12562
|
+
if (!existing) return true;
|
|
12563
|
+
return existing.serve.port === config.serve.port && bindHostsMayOverlap(existing.serve.host, config.serve.host);
|
|
12564
|
+
}
|
|
12565
|
+
function bindHostsMayOverlap(left, right) {
|
|
12566
|
+
return left === right || isWildcardBindHost(left) || isWildcardBindHost(right);
|
|
12567
|
+
}
|
|
12568
|
+
function isWildcardBindHost(host) {
|
|
12569
|
+
const normalized = host.toLowerCase();
|
|
12570
|
+
return normalized === "0.0.0.0" || normalized === "::" || normalized === "[::]";
|
|
12571
|
+
}
|
|
12458
12572
|
async function waitForDaemonHealth(config, options) {
|
|
12459
12573
|
const deadline = Date.now() + (options.healthTimeoutMs ?? 1e4);
|
|
12460
12574
|
const intervalMs = options.healthIntervalMs ?? 200;
|
|
@@ -12815,6 +12929,7 @@ async function doctorJsonReport(options = {}) {
|
|
|
12815
12929
|
},
|
|
12816
12930
|
daemon: await resolveDaemonSection(env, options.daemon),
|
|
12817
12931
|
remoteLogin: remoteLogin.report,
|
|
12932
|
+
vault: resolveVaultSection(env, root),
|
|
12818
12933
|
exposure: await resolveExposureSection(env),
|
|
12819
12934
|
codeMode: await resolveCodeModeSection(options, env)
|
|
12820
12935
|
};
|
|
@@ -12865,6 +12980,11 @@ async function formatDoctorReport(options = {}) {
|
|
|
12865
12980
|
...report.remoteLogin.workspaceSlug || report.remoteLogin.workspaceId ? [` Selected Workspace: ${report.remoteLogin.workspaceSlug ?? report.remoteLogin.workspaceId}`] : [],
|
|
12866
12981
|
...report.remoteLogin.clientId ? [` Client: ${report.remoteLogin.clientId}`] : [],
|
|
12867
12982
|
"",
|
|
12983
|
+
"Vault",
|
|
12984
|
+
` OK: ${yesNo(Boolean(report.vault.ok))}`,
|
|
12985
|
+
...!report.vault.ok && typeof report.vault.message === "string" ? [` Error: ${report.vault.message}`] : [],
|
|
12986
|
+
...Array.isArray(report.vault.issues) ? report.vault.issues.map((issue) => ` ${issue.capletId}: ${issue.reason} ${issue.key} (${issue.recoveryCommand})`) : [],
|
|
12987
|
+
"",
|
|
12868
12988
|
"Exposure",
|
|
12869
12989
|
` Default: ${report.exposure.default ?? "unknown"}`,
|
|
12870
12990
|
` Discovery timeout: ${report.exposure.discoveryTimeoutMs ?? "unknown"}ms`,
|
|
@@ -12882,6 +13002,37 @@ async function formatDoctorReport(options = {}) {
|
|
|
12882
13002
|
...observedOutputShapePath(report.codeMode.observedOutputShapes) ? [` Observed output shape cache: ${observedOutputShapePath(report.codeMode.observedOutputShapes)}`] : []
|
|
12883
13003
|
].join("\n")}\n`;
|
|
12884
13004
|
}
|
|
13005
|
+
function resolveVaultSection(env, cwd = process.cwd()) {
|
|
13006
|
+
const configPath = env.CAPLETS_CONFIG?.trim() ? env.CAPLETS_CONFIG.trim() : resolveConfigPath();
|
|
13007
|
+
const projectConfigPath = env.CAPLETS_PROJECT_CONFIG?.trim() ? env.CAPLETS_PROJECT_CONFIG.trim() : resolveProjectConfigPath(cwd);
|
|
13008
|
+
try {
|
|
13009
|
+
const issues = loadLocalOverlayConfigWithSources(configPath, projectConfigPath).warnings.filter((warning) => warning.message.includes("Vault key")).map((warning) => vaultIssueFromWarning(warning.message, warning.path)).filter((issue) => issue !== void 0);
|
|
13010
|
+
return {
|
|
13011
|
+
ok: issues.length === 0,
|
|
13012
|
+
issues
|
|
13013
|
+
};
|
|
13014
|
+
} catch (error) {
|
|
13015
|
+
return {
|
|
13016
|
+
ok: false,
|
|
13017
|
+
issues: [],
|
|
13018
|
+
message: error instanceof Error ? error.message : String(error)
|
|
13019
|
+
};
|
|
13020
|
+
}
|
|
13021
|
+
}
|
|
13022
|
+
function vaultIssueFromWarning(message, path) {
|
|
13023
|
+
const match = message.match(/^Caplet ([^ ]+) references ([^ ]+) Vault key ([^ ]+) at ([^;]+); run `([^`]+)`/u);
|
|
13024
|
+
if (!match) return void 0;
|
|
13025
|
+
const recoveryCommand = match[5] ?? "";
|
|
13026
|
+
return {
|
|
13027
|
+
capletId: match[1],
|
|
13028
|
+
reason: match[2],
|
|
13029
|
+
key: match[3],
|
|
13030
|
+
configPath: path,
|
|
13031
|
+
referencePath: match[4],
|
|
13032
|
+
target: recoveryCommand.includes("--remote") ? "remote" : "global",
|
|
13033
|
+
recoveryCommand
|
|
13034
|
+
};
|
|
13035
|
+
}
|
|
12885
13036
|
async function resolveDaemonSection(env, options) {
|
|
12886
13037
|
try {
|
|
12887
13038
|
const status = await daemonStatus({
|
|
@@ -13216,6 +13367,42 @@ async function openBrowserUrl(url, options = {}) {
|
|
|
13216
13367
|
});
|
|
13217
13368
|
}
|
|
13218
13369
|
//#endregion
|
|
13370
|
+
//#region src/cli/vault.ts
|
|
13371
|
+
function formatVaultValueStatus(status, json = false) {
|
|
13372
|
+
if (json) return `${JSON.stringify(status, null, 2)}\n`;
|
|
13373
|
+
if (!status.present) return `Vault key ${status.key} is not set.\n`;
|
|
13374
|
+
return [
|
|
13375
|
+
`Vault key ${status.key} is set.`,
|
|
13376
|
+
status.valueBytes === void 0 ? void 0 : `Value bytes: ${status.valueBytes}`,
|
|
13377
|
+
status.updatedAt === void 0 ? void 0 : `Updated: ${status.updatedAt}`
|
|
13378
|
+
].filter((line) => line !== void 0).join("\n").concat("\n");
|
|
13379
|
+
}
|
|
13380
|
+
function formatVaultValueList(statuses, json = false) {
|
|
13381
|
+
if (json) return `${JSON.stringify(statuses, null, 2)}\n`;
|
|
13382
|
+
if (statuses.length === 0) return "No Vault keys set.\n";
|
|
13383
|
+
return `${statuses.map((status) => status.key).join("\n")}\n`;
|
|
13384
|
+
}
|
|
13385
|
+
function formatVaultDeleteStatus(status, json = false) {
|
|
13386
|
+
if (json) return `${JSON.stringify(status, null, 2)}\n`;
|
|
13387
|
+
return status.deleted ? `Deleted Vault key ${status.key}. ${status.grantsRetained} access grant${status.grantsRetained === 1 ? "" : "s"} retained.\n` : `No Vault key ${status.key} found.\n`;
|
|
13388
|
+
}
|
|
13389
|
+
function formatVaultAccessGrant(grant, json = false) {
|
|
13390
|
+
if (json) return `${JSON.stringify(grant, null, 2)}\n`;
|
|
13391
|
+
return `Granted Vault key ${grant.storedKey} to ${grant.capletId} as ${grant.referenceName}.\n`;
|
|
13392
|
+
}
|
|
13393
|
+
function formatVaultAccessList(grants, json = false) {
|
|
13394
|
+
if (json) return `${JSON.stringify(grants, null, 2)}\n`;
|
|
13395
|
+
if (grants.length === 0) return "No Vault access grants.\n";
|
|
13396
|
+
return `${grants.map((grant) => {
|
|
13397
|
+
const origin = grant.origin ? ` (${grant.origin.kind} ${grant.origin.path})` : "";
|
|
13398
|
+
return `${grant.storedKey} -> ${grant.capletId}:${grant.referenceName}${origin}`;
|
|
13399
|
+
}).join("\n")}\n`;
|
|
13400
|
+
}
|
|
13401
|
+
function formatVaultAccessRevoke(count, json = false) {
|
|
13402
|
+
if (json) return `${JSON.stringify({ revoked: count }, null, 2)}\n`;
|
|
13403
|
+
return `Revoked ${count} Vault access grant${count === 1 ? "" : "s"}.\n`;
|
|
13404
|
+
}
|
|
13405
|
+
//#endregion
|
|
13219
13406
|
//#region src/setup/hash.ts
|
|
13220
13407
|
function capletSetupContentHash(caplet) {
|
|
13221
13408
|
return createHash("sha256").update(stableJson(stableCapletForHash(caplet))).digest("hex");
|
|
@@ -14585,7 +14772,7 @@ var RemoteControlClient = class {
|
|
|
14585
14772
|
if (response.status === 401 || response.status === 403) throw new CapletsError("AUTH_FAILED", `Caplets remote authentication failed. Run caplets remote login ${safeBaseUrl(resolved.baseUrl)}.`);
|
|
14586
14773
|
if (!response.ok) throw new CapletsError("SERVER_UNAVAILABLE", `Caplets server at ${safeBaseUrl(resolved.baseUrl)} returned HTTP ${response.status}.`);
|
|
14587
14774
|
const payload = await parseRemoteCliResponse(response);
|
|
14588
|
-
if (!payload.ok) throw new CapletsError(payload.error.code, redactRemoteMessage(payload.error.message), payload.error.nextAction === void 0 ? void 0 : { nextAction: payload.error.nextAction });
|
|
14775
|
+
if (!payload.ok) throw new CapletsError(payload.error.code, redactRemoteMessage(payload.error.message, sensitiveValues(command, args)), payload.error.nextAction === void 0 ? void 0 : { nextAction: payload.error.nextAction });
|
|
14589
14776
|
return payload.result;
|
|
14590
14777
|
}
|
|
14591
14778
|
};
|
|
@@ -14642,8 +14829,17 @@ function isRecord$1(value) {
|
|
|
14642
14829
|
function isCapletsErrorCode(value) {
|
|
14643
14830
|
return CAPLETS_ERROR_CODES.includes(value);
|
|
14644
14831
|
}
|
|
14645
|
-
function redactRemoteMessage(message) {
|
|
14646
|
-
|
|
14832
|
+
function redactRemoteMessage(message, values = []) {
|
|
14833
|
+
let redacted = String(redactSecrets$1(message));
|
|
14834
|
+
for (const value of values) {
|
|
14835
|
+
if (value.length === 0) continue;
|
|
14836
|
+
redacted = redacted.split(value).join("[REDACTED]");
|
|
14837
|
+
}
|
|
14838
|
+
return redacted.replace(/\b(authorization\s*:\s*(?:basic|bearer)\s+)[^\s,;]+/giu, "$1[REDACTED]").replace(/\b((?:access_)?token=)[^\s,;]+/giu, "$1[REDACTED]").replace(/\b((?:token|secret|authorization|auth|api[-_]?key|password|credential|clientsecret|client_secret|code|refresh(?:_token)?)\s*[=:]\s*)[^\s,;]+/giu, "$1[REDACTED]");
|
|
14839
|
+
}
|
|
14840
|
+
function sensitiveValues(command, args) {
|
|
14841
|
+
if (command === "vault_set" && typeof args.value === "string") return [args.value];
|
|
14842
|
+
return [];
|
|
14647
14843
|
}
|
|
14648
14844
|
//#endregion
|
|
14649
14845
|
//#region src/serve/stdio.ts
|
|
@@ -15575,6 +15771,135 @@ function createProgram(io = {}) {
|
|
|
15575
15771
|
...io.daemon ? { daemon: io.daemon } : {}
|
|
15576
15772
|
}));
|
|
15577
15773
|
});
|
|
15774
|
+
const vault = program.command(cliCommands$1.vault).description("Manage Caplets Vault values.");
|
|
15775
|
+
vault.command("set").description("Set a local/global Vault value.").argument("<name>", "Vault key name").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--force", "overwrite an existing Vault value").option("--grant <capletId>", "grant this key to a configured Caplet after setting it").option("--as <referenceName>", "reference name the Caplet uses in config").option("--json", "print JSON output").action(async (name, options) => {
|
|
15776
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15777
|
+
const value = await readVaultValue(io);
|
|
15778
|
+
assertVaultTransportValueSize(value);
|
|
15779
|
+
const status = await remoteVaultSet(io, {
|
|
15780
|
+
name,
|
|
15781
|
+
value,
|
|
15782
|
+
force: Boolean(options.force),
|
|
15783
|
+
...options.grant ? { grant: options.grant } : {},
|
|
15784
|
+
...options.as ?? options.grant ? { referenceName: options.as ?? name } : {}
|
|
15785
|
+
});
|
|
15786
|
+
if (options.json) {
|
|
15787
|
+
writeOut(`${JSON.stringify(status, null, 2)}\n`);
|
|
15788
|
+
return;
|
|
15789
|
+
}
|
|
15790
|
+
writeOut(`Set remote Vault key ${validateVaultKeyName(name)}.\n`);
|
|
15791
|
+
if (options.grant) writeOut(`Granted remote Vault key ${validateVaultKeyName(name)} to ${options.grant} as ${validateVaultKeyName(options.as ?? name)}.\n`);
|
|
15792
|
+
return;
|
|
15793
|
+
}
|
|
15794
|
+
const value = await readVaultValue(io);
|
|
15795
|
+
const store = new FileVaultStore({ env });
|
|
15796
|
+
const existed = store.getStatus(name).present;
|
|
15797
|
+
const previousValue = existed && options.grant ? store.resolveValue(name) : void 0;
|
|
15798
|
+
const status = store.set(name, value, { force: Boolean(options.force) });
|
|
15799
|
+
try {
|
|
15800
|
+
if (options.grant) {
|
|
15801
|
+
const origin = resolveVaultAccessOrigin(options.grant, io);
|
|
15802
|
+
store.grantAccess({
|
|
15803
|
+
storedKey: name,
|
|
15804
|
+
referenceName: options.as ?? name,
|
|
15805
|
+
capletId: options.grant,
|
|
15806
|
+
origin
|
|
15807
|
+
});
|
|
15808
|
+
}
|
|
15809
|
+
} catch (error) {
|
|
15810
|
+
if (existed && previousValue !== void 0) store.set(name, previousValue, { force: true });
|
|
15811
|
+
else store.delete(name);
|
|
15812
|
+
throw error;
|
|
15813
|
+
}
|
|
15814
|
+
if (options.json) {
|
|
15815
|
+
writeOut(`${JSON.stringify(status, null, 2)}\n`);
|
|
15816
|
+
return;
|
|
15817
|
+
}
|
|
15818
|
+
writeOut(`Set Vault key ${validateVaultKeyName(name)}.\n`);
|
|
15819
|
+
if (options.grant) writeOut(`Granted Vault key ${validateVaultKeyName(name)} to ${options.grant} as ${validateVaultKeyName(options.as ?? name)}.\n`);
|
|
15820
|
+
});
|
|
15821
|
+
vault.command("get").description("Show local/global Vault metadata, or reveal with --show.").argument("<name>", "Vault key name").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--show", "reveal the raw Vault value").option("--json", "print JSON output").action(async (name, options) => {
|
|
15822
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15823
|
+
const result = await remoteVaultGet(io, {
|
|
15824
|
+
name,
|
|
15825
|
+
reveal: Boolean(options.show)
|
|
15826
|
+
});
|
|
15827
|
+
if (options.show) {
|
|
15828
|
+
const value = result && typeof result === "object" && "value" in result ? String(result.value) : "";
|
|
15829
|
+
writeOut(options.json ? `${JSON.stringify(result, null, 2)}\n` : `${value}\n`);
|
|
15830
|
+
return;
|
|
15831
|
+
}
|
|
15832
|
+
writeOut(formatVaultValueStatus(result, Boolean(options.json)));
|
|
15833
|
+
return;
|
|
15834
|
+
}
|
|
15835
|
+
const store = new FileVaultStore({ env });
|
|
15836
|
+
if (options.show) {
|
|
15837
|
+
const value = store.resolveValue(name);
|
|
15838
|
+
writeOut(options.json ? `${JSON.stringify({
|
|
15839
|
+
key: name,
|
|
15840
|
+
value
|
|
15841
|
+
}, null, 2)}\n` : `${value}\n`);
|
|
15842
|
+
return;
|
|
15843
|
+
}
|
|
15844
|
+
writeOut(formatVaultValueStatus(store.getStatus(name), Boolean(options.json)));
|
|
15845
|
+
});
|
|
15846
|
+
vault.command("list").description("List local/global Vault keys without revealing values.").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--json", "print JSON output").action(async (options) => {
|
|
15847
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15848
|
+
writeOut(formatVaultValueList(await remoteVaultList(io), Boolean(options.json)));
|
|
15849
|
+
return;
|
|
15850
|
+
}
|
|
15851
|
+
writeOut(formatVaultValueList(new FileVaultStore({ env }).listValues(), Boolean(options.json)));
|
|
15852
|
+
});
|
|
15853
|
+
vault.command("delete").description("Delete a local/global Vault value without revealing it.").argument("<name>", "Vault key name").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--json", "print JSON output").action(async (name, options) => {
|
|
15854
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15855
|
+
writeOut(formatVaultDeleteStatus(await remoteVaultDelete(io, name), Boolean(options.json)));
|
|
15856
|
+
return;
|
|
15857
|
+
}
|
|
15858
|
+
writeOut(formatVaultDeleteStatus(new FileVaultStore({ env }).delete(name), Boolean(options.json)));
|
|
15859
|
+
});
|
|
15860
|
+
const vaultAccess = vault.command("access").description("Manage Vault access grants.");
|
|
15861
|
+
vaultAccess.command("grant").description("Grant a Vault key to a configured Caplet.").argument("<name>", "stored Vault key name").argument("<capletId>", "configured Caplet ID").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--as <referenceName>", "reference name the Caplet uses in config").option("--json", "print JSON output").action(async (name, capletId, options) => {
|
|
15862
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15863
|
+
writeOut(formatVaultAccessGrant(await remoteVaultAccessGrant(io, {
|
|
15864
|
+
name,
|
|
15865
|
+
capletId,
|
|
15866
|
+
referenceName: options.as ?? name
|
|
15867
|
+
}), Boolean(options.json)));
|
|
15868
|
+
return;
|
|
15869
|
+
}
|
|
15870
|
+
const origin = resolveVaultAccessOrigin(capletId, io);
|
|
15871
|
+
writeOut(formatVaultAccessGrant(new FileVaultStore({ env }).grantAccess({
|
|
15872
|
+
storedKey: name,
|
|
15873
|
+
referenceName: options.as ?? name,
|
|
15874
|
+
capletId,
|
|
15875
|
+
origin
|
|
15876
|
+
}), Boolean(options.json)));
|
|
15877
|
+
});
|
|
15878
|
+
vaultAccess.command("list").description("List Vault access grants without revealing values.").argument("[name]", "optional stored Vault key name").argument("[capletId]", "optional configured Caplet ID").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--caplet <capletId>", "filter by configured Caplet ID").option("--json", "print JSON output").action(async (name, capletId, options) => {
|
|
15879
|
+
if (options.caplet && capletId && options.caplet !== capletId) throw new CapletsError("REQUEST_INVALID", "Use either positional capletId or --caplet, not both.");
|
|
15880
|
+
const capletFilter = options.caplet ?? capletId;
|
|
15881
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15882
|
+
writeOut(formatVaultAccessList(await remoteVaultAccessList(io, {
|
|
15883
|
+
...name ? { name } : {},
|
|
15884
|
+
...capletFilter ? { capletId: capletFilter } : {}
|
|
15885
|
+
}), Boolean(options.json)));
|
|
15886
|
+
return;
|
|
15887
|
+
}
|
|
15888
|
+
writeOut(formatVaultAccessList(new FileVaultStore({ env }).listAccess(vaultAccessFilter(name, capletFilter)), Boolean(options.json)));
|
|
15889
|
+
});
|
|
15890
|
+
vaultAccess.command("revoke").description("Revoke Vault access grants.").argument("<name>", "stored Vault key name").argument("<capletId>", "configured Caplet ID").option("-g, --global", "target the local/global Vault").option("--remote", "target the selected remote Vault").option("--as <referenceName>", "reference name the Caplet uses in config").option("--json", "print JSON output").action(async (name, capletId, options) => {
|
|
15891
|
+
if (parseVaultTarget(options) === "remote") {
|
|
15892
|
+
const revoked = await remoteVaultAccessRevoke(io, {
|
|
15893
|
+
name,
|
|
15894
|
+
capletId,
|
|
15895
|
+
...options.as ? { referenceName: options.as } : {}
|
|
15896
|
+
});
|
|
15897
|
+
writeOut(formatVaultAccessRevoke(Array.isArray(revoked) ? revoked.length : 0, Boolean(options.json)));
|
|
15898
|
+
return;
|
|
15899
|
+
}
|
|
15900
|
+
const filter = vaultAccessFilter(name, capletId, options.as);
|
|
15901
|
+
writeOut(formatVaultAccessRevoke(new FileVaultStore({ env }).revokeAccess(filter).length, Boolean(options.json)));
|
|
15902
|
+
});
|
|
15578
15903
|
program.command(cliCommands$1.list).description("List configured Caplets.").option("--all", "include disabled Caplets").option("--json", "print JSON output").option("--format <format>", "output format: plain, markdown, md, or json", parseOutputFormat).action(async (options) => {
|
|
15579
15904
|
const includeDisabled = Boolean(options.all);
|
|
15580
15905
|
const remote = remoteClientForCli(io);
|
|
@@ -15590,7 +15915,7 @@ function createProgram(io = {}) {
|
|
|
15590
15915
|
writeOut(formatCapletList(rows, options.format ?? "plain"));
|
|
15591
15916
|
return;
|
|
15592
15917
|
}
|
|
15593
|
-
const rows = listCaplets(loadConfigWithSources(currentConfigPath(), envProjectConfigPath(env)), { includeDisabled });
|
|
15918
|
+
const rows = listCaplets(loadConfigWithSources(currentConfigPath(), envProjectConfigPath(env), { vaultResolver: vaultBootstrapResolver }), { includeDisabled });
|
|
15594
15919
|
if (options.json || options.format === "json") {
|
|
15595
15920
|
writeOut(`${JSON.stringify(rows, null, 2)}\n`);
|
|
15596
15921
|
return;
|
|
@@ -15940,6 +16265,7 @@ function createProgram(io = {}) {
|
|
|
15940
16265
|
...projectConfigPath ? { projectConfigPath } : {},
|
|
15941
16266
|
config: localAuthConfigForTarget({
|
|
15942
16267
|
serverId,
|
|
16268
|
+
...io.authDir ? { authDir: io.authDir } : {},
|
|
15943
16269
|
...configPath ? { configPath } : {},
|
|
15944
16270
|
...projectConfigPath ? { projectConfigPath } : {},
|
|
15945
16271
|
source: target
|
|
@@ -15960,6 +16286,7 @@ function createProgram(io = {}) {
|
|
|
15960
16286
|
...configPath ? { configPath } : {},
|
|
15961
16287
|
config: localAuthConfigForTarget({
|
|
15962
16288
|
serverId,
|
|
16289
|
+
...io.authDir ? { authDir: io.authDir } : {},
|
|
15963
16290
|
...configPath ? { configPath } : {},
|
|
15964
16291
|
...projectConfigPath ? { projectConfigPath } : {},
|
|
15965
16292
|
source: target
|
|
@@ -15981,6 +16308,7 @@ function createProgram(io = {}) {
|
|
|
15981
16308
|
...configPath ? { configPath } : {},
|
|
15982
16309
|
config: localAuthConfigForTarget({
|
|
15983
16310
|
serverId,
|
|
16311
|
+
...io.authDir ? { authDir: io.authDir } : {},
|
|
15984
16312
|
...configPath ? { configPath } : {},
|
|
15985
16313
|
...projectConfigPath ? { projectConfigPath } : {},
|
|
15986
16314
|
source: target
|
|
@@ -16075,6 +16403,136 @@ function parseMutationTarget(options) {
|
|
|
16075
16403
|
if (options.remote) return "remote";
|
|
16076
16404
|
return "project";
|
|
16077
16405
|
}
|
|
16406
|
+
function parseVaultTarget(options) {
|
|
16407
|
+
const selected = [options.global ? "--global" : void 0, options.remote ? "--remote" : void 0].filter((value) => value !== void 0);
|
|
16408
|
+
if (selected.length > 1) throw new CapletsError("REQUEST_INVALID", `Cannot combine Vault target flags: ${selected.join(", ")}`);
|
|
16409
|
+
if (options.remote) return "remote";
|
|
16410
|
+
return "global";
|
|
16411
|
+
}
|
|
16412
|
+
async function resolveVaultRemoteTarget(io) {
|
|
16413
|
+
const env = io.env ?? process.env;
|
|
16414
|
+
const mode = resolveRemoteMode({}, env).mode;
|
|
16415
|
+
if (mode === "remote") return {
|
|
16416
|
+
kind: "self_hosted",
|
|
16417
|
+
client: requireRemoteClientForTarget(io)
|
|
16418
|
+
};
|
|
16419
|
+
if (mode !== "cloud") throw new CapletsError("REQUEST_INVALID", "--remote requires CAPLETS_MODE=remote or CAPLETS_MODE=cloud and CAPLETS_REMOTE_URL");
|
|
16420
|
+
const selection = await resolveRemoteSelection({
|
|
16421
|
+
mode: "cloud",
|
|
16422
|
+
...io.authDir ? { authDir: io.authDir } : {},
|
|
16423
|
+
...io.fetch ? { fetch: io.fetch } : {}
|
|
16424
|
+
}, env);
|
|
16425
|
+
if (selection.kind !== "hosted_cloud") throw new CapletsError("REQUEST_INVALID", "--remote Vault target did not resolve to Cloud.");
|
|
16426
|
+
return {
|
|
16427
|
+
kind: "cloud",
|
|
16428
|
+
workspace: selection.selectedWorkspace,
|
|
16429
|
+
client: new CapletsCloudClient({
|
|
16430
|
+
baseUrl: selection.remote.baseUrl,
|
|
16431
|
+
accessToken: selection.credentials.accessToken,
|
|
16432
|
+
...selection.remote.fetch ? { fetch: selection.remote.fetch } : {}
|
|
16433
|
+
})
|
|
16434
|
+
};
|
|
16435
|
+
}
|
|
16436
|
+
async function remoteVaultSet(io, input) {
|
|
16437
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16438
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_set", input);
|
|
16439
|
+
return await target.client.setVaultValue({
|
|
16440
|
+
workspace: target.workspace,
|
|
16441
|
+
...input
|
|
16442
|
+
});
|
|
16443
|
+
}
|
|
16444
|
+
async function remoteVaultGet(io, input) {
|
|
16445
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16446
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_get", {
|
|
16447
|
+
name: input.name,
|
|
16448
|
+
reveal: input.reveal
|
|
16449
|
+
});
|
|
16450
|
+
return await target.client.getVaultValue({
|
|
16451
|
+
workspace: target.workspace,
|
|
16452
|
+
name: input.name,
|
|
16453
|
+
reveal: input.reveal
|
|
16454
|
+
});
|
|
16455
|
+
}
|
|
16456
|
+
async function remoteVaultList(io) {
|
|
16457
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16458
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_list", {});
|
|
16459
|
+
return await target.client.listVaultValues({ workspace: target.workspace });
|
|
16460
|
+
}
|
|
16461
|
+
async function remoteVaultDelete(io, name) {
|
|
16462
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16463
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_delete", { name });
|
|
16464
|
+
return await target.client.deleteVaultValue({
|
|
16465
|
+
workspace: target.workspace,
|
|
16466
|
+
name
|
|
16467
|
+
});
|
|
16468
|
+
}
|
|
16469
|
+
async function remoteVaultAccessGrant(io, input) {
|
|
16470
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16471
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_access_grant", input);
|
|
16472
|
+
return await target.client.grantVaultAccess({
|
|
16473
|
+
workspace: target.workspace,
|
|
16474
|
+
...input
|
|
16475
|
+
});
|
|
16476
|
+
}
|
|
16477
|
+
async function remoteVaultAccessList(io, input) {
|
|
16478
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16479
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_access_list", input);
|
|
16480
|
+
return await target.client.listVaultAccess({
|
|
16481
|
+
workspace: target.workspace,
|
|
16482
|
+
...input
|
|
16483
|
+
});
|
|
16484
|
+
}
|
|
16485
|
+
async function remoteVaultAccessRevoke(io, input) {
|
|
16486
|
+
const target = await resolveVaultRemoteTarget(io);
|
|
16487
|
+
if (target.kind === "self_hosted") return await target.client.request("vault_access_revoke", input);
|
|
16488
|
+
return await target.client.revokeVaultAccess({
|
|
16489
|
+
workspace: target.workspace,
|
|
16490
|
+
...input
|
|
16491
|
+
});
|
|
16492
|
+
}
|
|
16493
|
+
async function readVaultValue(io) {
|
|
16494
|
+
let value;
|
|
16495
|
+
if (io.readStdin) value = stripOneTrailingNewline(await io.readStdin());
|
|
16496
|
+
else if (!process.stdin.isTTY && !io.writeOut && !io.writeErr) value = stripOneTrailingNewline(await readAllStdin());
|
|
16497
|
+
else if (io.writeOut || io.writeErr || !process.stdin.isTTY || !process.stdout.isTTY) throw new CapletsError("REQUEST_INVALID", "Vault value input is required. Run interactively or provide stdin.");
|
|
16498
|
+
else {
|
|
16499
|
+
const output = new HiddenPromptOutput(process.stdout);
|
|
16500
|
+
const readline = createInterface({
|
|
16501
|
+
input: process.stdin,
|
|
16502
|
+
output,
|
|
16503
|
+
terminal: true
|
|
16504
|
+
});
|
|
16505
|
+
try {
|
|
16506
|
+
value = await readline.question("Vault value: ");
|
|
16507
|
+
} finally {
|
|
16508
|
+
readline.close();
|
|
16509
|
+
process.stdout.write("\n");
|
|
16510
|
+
}
|
|
16511
|
+
}
|
|
16512
|
+
if (value.length === 0) throw new CapletsError("REQUEST_INVALID", "Vault value input is required.");
|
|
16513
|
+
return value;
|
|
16514
|
+
}
|
|
16515
|
+
function stripOneTrailingNewline(value) {
|
|
16516
|
+
return value.replace(/\r?\n$/u, "");
|
|
16517
|
+
}
|
|
16518
|
+
function assertVaultTransportValueSize(value) {
|
|
16519
|
+
if (Buffer$1.byteLength(value, "utf8") > 65536) throw new CapletsError("REQUEST_INVALID", `Vault values must be ${VAULT_MAX_VALUE_BYTES} bytes or smaller.`);
|
|
16520
|
+
}
|
|
16521
|
+
function resolveVaultAccessOrigin(capletId, io) {
|
|
16522
|
+
const env = io.env ?? process.env;
|
|
16523
|
+
const config = loadConfigWithSources(envConfigPath(env), envProjectConfigPath(env), { vaultResolver: vaultBootstrapResolver });
|
|
16524
|
+
if (config.shadows[capletId]?.length) throw new CapletsError("REQUEST_INVALID", `Caplet ${capletId} is shadowed in multiple config sources; resolve the active config before granting Vault access.`);
|
|
16525
|
+
const origin = config.sources[capletId];
|
|
16526
|
+
if (!origin) throw new CapletsError("SERVER_NOT_FOUND", `Caplet ${capletId} is not configured.`);
|
|
16527
|
+
return origin;
|
|
16528
|
+
}
|
|
16529
|
+
function vaultAccessFilter(storedKey, capletId, referenceName) {
|
|
16530
|
+
return {
|
|
16531
|
+
...storedKey ? { storedKey: validateVaultKeyName(storedKey) } : {},
|
|
16532
|
+
...capletId ? { capletId } : {},
|
|
16533
|
+
...referenceName ? { referenceName: validateVaultKeyName(referenceName) } : {}
|
|
16534
|
+
};
|
|
16535
|
+
}
|
|
16078
16536
|
function localMutationTargetLabel(target, io) {
|
|
16079
16537
|
return remoteClientForCli(io) ? `${target} ` : "";
|
|
16080
16538
|
}
|
|
@@ -16214,12 +16672,12 @@ function localShadowedCompletionTarget(words, config) {
|
|
|
16214
16672
|
const command = words[0];
|
|
16215
16673
|
const target = words[1];
|
|
16216
16674
|
if (!command || !target || target.startsWith("-")) return;
|
|
16217
|
-
const qualifiedCommands = new Set([
|
|
16675
|
+
const qualifiedCommands = /* @__PURE__ */ new Set([
|
|
16218
16676
|
cliCommands$1.getTool,
|
|
16219
16677
|
cliCommands$1.callTool,
|
|
16220
16678
|
cliCommands$1.getPrompt
|
|
16221
16679
|
]);
|
|
16222
|
-
const capletCommands = new Set([
|
|
16680
|
+
const capletCommands = /* @__PURE__ */ new Set([
|
|
16223
16681
|
cliCommands$1.inspect,
|
|
16224
16682
|
cliCommands$1.checkBackend,
|
|
16225
16683
|
cliCommands$1.listTools,
|
|
@@ -16345,7 +16803,8 @@ function mergePartialLocalOverlays(globalOverlay, projectOverlay) {
|
|
|
16345
16803
|
config,
|
|
16346
16804
|
sources,
|
|
16347
16805
|
shadows,
|
|
16348
|
-
warnings: [...globalOverlay.warnings, ...projectOverlay.warnings]
|
|
16806
|
+
warnings: [...globalOverlay.warnings, ...projectOverlay.warnings],
|
|
16807
|
+
sourceFound: globalOverlay.sourceFound || projectOverlay.sourceFound
|
|
16349
16808
|
};
|
|
16350
16809
|
}
|
|
16351
16810
|
const capletConfigKinds = [
|
|
@@ -17214,12 +17673,12 @@ function trimTrailingSlash(pathname) {
|
|
|
17214
17673
|
}
|
|
17215
17674
|
//#endregion
|
|
17216
17675
|
//#region src/project-binding/mutagen.ts
|
|
17217
|
-
const readyStatuses = new Set([
|
|
17676
|
+
const readyStatuses = /* @__PURE__ */ new Set([
|
|
17218
17677
|
"watching",
|
|
17219
17678
|
"ready",
|
|
17220
17679
|
"ok"
|
|
17221
17680
|
]);
|
|
17222
|
-
const syncingStatuses = new Set([
|
|
17681
|
+
const syncingStatuses = /* @__PURE__ */ new Set([
|
|
17223
17682
|
"connecting",
|
|
17224
17683
|
"halted on root",
|
|
17225
17684
|
"reconciling",
|