@caplets/core 0.25.1 → 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/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { $ as decodeDirectResourceUri, $t as ElicitResultSchema, A as nativeCapletToolDescription, An as objectFromShape, At as defaultCacheBaseDir, B as QuickJsCodeModeSandbox, Bt as assertClientRequestTaskCapability, C as resolveRemoteMode, Cn as getLiteralValue, Ct as startOAuthFlow, D as parseServerBaseUrl, Dn as isSchemaOptional, Dt as DEFAULT_AUTH_DIR, E as isLoopbackHost, En as getSchemaDescription, Et as readTokenBundle, F as codeModeRunInputSchema, Ft as resolveConfigPath, G as CodeModeLogStore, Gt as toJsonSchemaCompat, H as createCodeModeCapletsApi, Ht as AjvJsonSchemaValidator, I as codeModeRunParamsSchema, It as resolveProjectCapletsRoot, J as generateCodeModeDeclarations, Jt as CompleteRequestSchema, K as redactCodeModeLogText, Kt as CallToolRequestSchema, L as emptyCodeModeRunMeta, Lt as resolveProjectConfigPath, Mn as safeParseAsync, Mt as defaultConfigPath, Nt as defaultStateBaseDir, O as resolveCapletsServer, On as isZ4Schema, Pt as resolveCapletsRoot, Q as resolveExposure, R as runCodeMode, Rt as ReadBuffer, S as resolveHostedCloudRemote, Sn as isJSONRPCResultResponse, St as startGenericOAuthFlow, T as controlUrlForBase, Tn as getParseErrorMessage, Tt as isTokenBundleExpired, U as listCodeModeCallableCaplets, Ut as Protocol, V as diagnoseCodeModeTypeScript, Vt as assertToolsCallTaskCapability, W as CodeModeJournalStore, Wt as mergeCapabilities, X as minifyCodeModeDeclarationText, Xt as CreateMessageResultWithToolsSchema, Y as generateCodeModeRunToolDescription, Yt as CreateMessageResultSchema, Z as CapletsEngine, Zt as CreateTaskResultSchema, _n as assertCompleteRequestPrompt, _t as markdownCallToolResultContent, a as CloudAuthStore, an as JSONRPCMessageSchema, at as capabilityDescription, b as normalizeRemoteProfileHostUrl, bn as isJSONRPCErrorResponse, bt as runGenericOAuthFlow, c as redactedCloudAuthStatus, cn as ListResourceTemplatesRequestSchema, ct as loadConfigWithSources, d as projectBindingError, dn as ListToolsRequestSchema, dt as loadProjectConfig, en as EmptyResultSchema, et as directResourceUriMatchesTemplate, f as projectBindingRecovery, fn as LoggingLevelSchema, ft as parseConfig, g as buildProjectSyncManifest, gn as SetLevelRequestSchema, gt as hasRenderableStructuredContent, hn as SUPPORTED_PROTOCOL_VERSIONS, ht as loadCapletFilesFromMap, i as createRemoteProfileStore, in as InitializedNotificationSchema, it as ServerRegistry, j as nativeCapletToolName, jn as safeParse, jt as defaultConfigBaseDir, k as nativeCapletPromptGuidance, kn as normalizeObjectSchema, kt as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, l as PROJECT_BINDING_ERROR_CODES, ln as ListResourcesRequestSchema, lt as loadGlobalConfig, mn as ReadResourceRequestSchema, mt as validateCapletFile, n as resolveRemoteSelection, nn as GetPromptRequestSchema, nt as fingerprintProjectRoot, o as cloudAuthPath, on as LATEST_PROTOCOL_VERSION, ot as GoogleDiscoveryManager, p as CloudAuthClient, pn as McpError, pt as discoverCapletFiles, q as codeModeDeclarationHash, qt as CallToolResultSchema, r as cloudCredentialsFromRemoteProfile, rn as InitializeRequestSchema, rt as handleServerTool, s as migrateCredentials, sn as ListPromptsRequestSchema, st as loadConfig, t as createNativeCapletsService, tn as ErrorCode, tt as findProjectRoot, u as ProjectBindingError, un as ListRootsResultSchema, ut as loadLocalOverlayConfigWithSources, v as hostedCloudWorkspaceFromRemoteUrl, vn as assertCompleteRequestResourceTemplate, vt as markdownStructuredContent, w as appendBasePath, wn as getObjectShape, wt as deleteTokenBundle, x as resolveCapletsRemote, xn as isJSONRPCRequest, xt as runOAuthFlow, y as isCapletsCloudUrl, yn as isInitializeRequest, yt as refreshOAuthTokenBundle, z as CodeModeSessionManager, zt as serializeMessage } from "./service-Ut6dN9M8.js";
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
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
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
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-De4t5MtT.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.25.1";
1556
+ var version = "0.26.0";
1557
1557
  //#endregion
1558
1558
  //#region src/serve/session.ts
1559
1559
  var CapletsMcpSession = class {
@@ -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 ?? loadConfig(options.configPath), options.authDir);
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 ?? loadConfig(options.configPath), options.authDir);
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) => {
@@ -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);
@@ -12857,6 +12929,7 @@ async function doctorJsonReport(options = {}) {
12857
12929
  },
12858
12930
  daemon: await resolveDaemonSection(env, options.daemon),
12859
12931
  remoteLogin: remoteLogin.report,
12932
+ vault: resolveVaultSection(env, root),
12860
12933
  exposure: await resolveExposureSection(env),
12861
12934
  codeMode: await resolveCodeModeSection(options, env)
12862
12935
  };
@@ -12907,6 +12980,11 @@ async function formatDoctorReport(options = {}) {
12907
12980
  ...report.remoteLogin.workspaceSlug || report.remoteLogin.workspaceId ? [` Selected Workspace: ${report.remoteLogin.workspaceSlug ?? report.remoteLogin.workspaceId}`] : [],
12908
12981
  ...report.remoteLogin.clientId ? [` Client: ${report.remoteLogin.clientId}`] : [],
12909
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
+ "",
12910
12988
  "Exposure",
12911
12989
  ` Default: ${report.exposure.default ?? "unknown"}`,
12912
12990
  ` Discovery timeout: ${report.exposure.discoveryTimeoutMs ?? "unknown"}ms`,
@@ -12924,6 +13002,37 @@ async function formatDoctorReport(options = {}) {
12924
13002
  ...observedOutputShapePath(report.codeMode.observedOutputShapes) ? [` Observed output shape cache: ${observedOutputShapePath(report.codeMode.observedOutputShapes)}`] : []
12925
13003
  ].join("\n")}\n`;
12926
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
+ }
12927
13036
  async function resolveDaemonSection(env, options) {
12928
13037
  try {
12929
13038
  const status = await daemonStatus({
@@ -13258,6 +13367,42 @@ async function openBrowserUrl(url, options = {}) {
13258
13367
  });
13259
13368
  }
13260
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
13261
13406
  //#region src/setup/hash.ts
13262
13407
  function capletSetupContentHash(caplet) {
13263
13408
  return createHash("sha256").update(stableJson(stableCapletForHash(caplet))).digest("hex");
@@ -14627,7 +14772,7 @@ var RemoteControlClient = class {
14627
14772
  if (response.status === 401 || response.status === 403) throw new CapletsError("AUTH_FAILED", `Caplets remote authentication failed. Run caplets remote login ${safeBaseUrl(resolved.baseUrl)}.`);
14628
14773
  if (!response.ok) throw new CapletsError("SERVER_UNAVAILABLE", `Caplets server at ${safeBaseUrl(resolved.baseUrl)} returned HTTP ${response.status}.`);
14629
14774
  const payload = await parseRemoteCliResponse(response);
14630
- 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 });
14631
14776
  return payload.result;
14632
14777
  }
14633
14778
  };
@@ -14684,8 +14829,17 @@ function isRecord$1(value) {
14684
14829
  function isCapletsErrorCode(value) {
14685
14830
  return CAPLETS_ERROR_CODES.includes(value);
14686
14831
  }
14687
- function redactRemoteMessage(message) {
14688
- return String(redactSecrets$1(message)).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]");
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 [];
14689
14843
  }
14690
14844
  //#endregion
14691
14845
  //#region src/serve/stdio.ts
@@ -15617,6 +15771,135 @@ function createProgram(io = {}) {
15617
15771
  ...io.daemon ? { daemon: io.daemon } : {}
15618
15772
  }));
15619
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
+ });
15620
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) => {
15621
15904
  const includeDisabled = Boolean(options.all);
15622
15905
  const remote = remoteClientForCli(io);
@@ -15632,7 +15915,7 @@ function createProgram(io = {}) {
15632
15915
  writeOut(formatCapletList(rows, options.format ?? "plain"));
15633
15916
  return;
15634
15917
  }
15635
- const rows = listCaplets(loadConfigWithSources(currentConfigPath(), envProjectConfigPath(env)), { includeDisabled });
15918
+ const rows = listCaplets(loadConfigWithSources(currentConfigPath(), envProjectConfigPath(env), { vaultResolver: vaultBootstrapResolver }), { includeDisabled });
15636
15919
  if (options.json || options.format === "json") {
15637
15920
  writeOut(`${JSON.stringify(rows, null, 2)}\n`);
15638
15921
  return;
@@ -15982,6 +16265,7 @@ function createProgram(io = {}) {
15982
16265
  ...projectConfigPath ? { projectConfigPath } : {},
15983
16266
  config: localAuthConfigForTarget({
15984
16267
  serverId,
16268
+ ...io.authDir ? { authDir: io.authDir } : {},
15985
16269
  ...configPath ? { configPath } : {},
15986
16270
  ...projectConfigPath ? { projectConfigPath } : {},
15987
16271
  source: target
@@ -16002,6 +16286,7 @@ function createProgram(io = {}) {
16002
16286
  ...configPath ? { configPath } : {},
16003
16287
  config: localAuthConfigForTarget({
16004
16288
  serverId,
16289
+ ...io.authDir ? { authDir: io.authDir } : {},
16005
16290
  ...configPath ? { configPath } : {},
16006
16291
  ...projectConfigPath ? { projectConfigPath } : {},
16007
16292
  source: target
@@ -16023,6 +16308,7 @@ function createProgram(io = {}) {
16023
16308
  ...configPath ? { configPath } : {},
16024
16309
  config: localAuthConfigForTarget({
16025
16310
  serverId,
16311
+ ...io.authDir ? { authDir: io.authDir } : {},
16026
16312
  ...configPath ? { configPath } : {},
16027
16313
  ...projectConfigPath ? { projectConfigPath } : {},
16028
16314
  source: target
@@ -16117,6 +16403,136 @@ function parseMutationTarget(options) {
16117
16403
  if (options.remote) return "remote";
16118
16404
  return "project";
16119
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
+ }
16120
16536
  function localMutationTargetLabel(target, io) {
16121
16537
  return remoteClientForCli(io) ? `${target} ` : "";
16122
16538
  }
@@ -16387,7 +16803,8 @@ function mergePartialLocalOverlays(globalOverlay, projectOverlay) {
16387
16803
  config,
16388
16804
  sources,
16389
16805
  shadows,
16390
- warnings: [...globalOverlay.warnings, ...projectOverlay.warnings]
16806
+ warnings: [...globalOverlay.warnings, ...projectOverlay.warnings],
16807
+ sourceFound: globalOverlay.sourceFound || projectOverlay.sourceFound
16391
16808
  };
16392
16809
  }
16393
16810
  const capletConfigKinds = [
package/dist/native.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as nativeCapletToolDescription, M as nativeCapletsSystemGuidance, N as nativeCodeModeToolId, P as nativeCodeModeToolName, _ as resolveNativeCapletsServiceOptions, h as createSdkRemoteCapletsClient, j as nativeCapletToolName, k as nativeCapletPromptGuidance, m as RemoteNativeCapletsService, t as createNativeCapletsService } from "./service-Ut6dN9M8.js";
1
+ import { A as nativeCapletPromptGuidance, F as nativeCodeModeToolName, M as nativeCapletToolName, N as nativeCapletsSystemGuidance, P as nativeCodeModeToolId, h as createSdkRemoteCapletsClient, j as nativeCapletToolDescription, m as RemoteNativeCapletsService, t as createNativeCapletsService, v as resolveNativeCapletsServiceOptions } from "./service-rvZ7z6FI.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 = {}) {