@caplets/core 0.22.0 → 0.24.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.
Files changed (58) hide show
  1. package/dist/auth.d.ts +2 -1
  2. package/dist/caplet-files-bundle.d.ts +62 -0
  3. package/dist/caplet-sets.d.ts +2 -0
  4. package/dist/caplet-source.js +96 -4
  5. package/dist/cli/add.d.ts +10 -0
  6. package/dist/cli/auth.d.ts +22 -0
  7. package/dist/cli/code-mode.d.ts +3 -0
  8. package/dist/cli/commands.d.ts +1 -1
  9. package/dist/cli.d.ts +1 -1
  10. package/dist/code-mode/api.d.ts +3 -1
  11. package/dist/code-mode/diagnostics-builtins.generated.d.ts +1 -0
  12. package/dist/code-mode/diagnostics.d.ts +8 -0
  13. package/dist/code-mode/index.d.ts +1 -1
  14. package/dist/code-mode/journal.d.ts +103 -0
  15. package/dist/code-mode/platform-entry.d.ts +1 -0
  16. package/dist/code-mode/platform-host.d.ts +6 -0
  17. package/dist/code-mode/platform-runtime.generated.d.ts +1 -0
  18. package/dist/code-mode/runner.d.ts +5 -0
  19. package/dist/code-mode/runtime-api.generated.d.ts +1 -1
  20. package/dist/code-mode/sandbox.d.ts +14 -1
  21. package/dist/code-mode/sessions.d.ts +53 -0
  22. package/dist/code-mode/tool.d.ts +5 -0
  23. package/dist/code-mode/types.d.ts +30 -0
  24. package/dist/code-mode.js +21 -14
  25. package/dist/{completion-DnQujlrc.js → completion-CzHdM9B_.js} +14 -2
  26. package/dist/config/paths.d.ts +2 -0
  27. package/dist/config-runtime.d.ts +13 -1
  28. package/dist/config-runtime.js +44 -0
  29. package/dist/config.d.ts +25 -1
  30. package/dist/engine.d.ts +3 -0
  31. package/dist/google-discovery/index.d.ts +5 -0
  32. package/dist/google-discovery/manager.d.ts +37 -0
  33. package/dist/google-discovery/operations.d.ts +32 -0
  34. package/dist/google-discovery/request.d.ts +5 -0
  35. package/dist/google-discovery/schema.d.ts +2 -0
  36. package/dist/google-discovery/types.d.ts +70 -0
  37. package/dist/http/response.d.ts +14 -0
  38. package/dist/http-actions.d.ts +3 -0
  39. package/dist/index.js +190 -43
  40. package/dist/media/artifacts.d.ts +24 -0
  41. package/dist/media/index.d.ts +2 -0
  42. package/dist/media/input.d.ts +29 -0
  43. package/dist/native/options.d.ts +3 -6
  44. package/dist/native/remote.d.ts +2 -0
  45. package/dist/native/service.d.ts +2 -0
  46. package/dist/native/tools.d.ts +1 -0
  47. package/dist/native.js +1 -1
  48. package/dist/{observed-output-shapes-CL5MFXwM.js → observed-output-shapes-D2k2-q8K.js} +9 -0
  49. package/dist/observed-output-shapes.js +1 -1
  50. package/dist/openapi.d.ts +2 -0
  51. package/dist/registry.d.ts +6 -0
  52. package/dist/remote/options.d.ts +1 -1
  53. package/dist/runtime-plan.js +1 -1
  54. package/dist/runtime.d.ts +2 -0
  55. package/dist/serve/session.d.ts +1 -0
  56. package/dist/{service-4_chB2wu.js → service-BCT_Ls_3.js} +3878 -361
  57. package/dist/tools.d.ts +2 -1
  58. package/package.json +9 -2
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { $ as loadGlobalConfig, $t as ListRootsResultSchema, A as codeModeRunParamsSchema, At as assertToolsCallTaskCapability, B as generateCodeModeRunToolDescription, Bt as CreateTaskResultSchema, C as nativeCapletPromptGuidance, Ct as resolveCapletsRoot, D as nativeCodeModeToolId, Dt as ReadBuffer, Et as resolveProjectConfigPath, F as listCodeModeCallableCaplets, Ft as CallToolRequestSchema, G as directResourceUriMatchesTemplate, Gt as GetPromptRequestSchema, H as CapletsEngine, Ht as ElicitResultSchema, I as CodeModeLogStore, It as CallToolResultSchema, J as handleServerTool, Jt as JSONRPCMessageSchema, K as findProjectRoot, Kt as InitializeRequestSchema, L as redactCodeModeLogText, Lt as CompleteRequestSchema, M as QuickJsCodeModeSandbox, Mt as Protocol, N as diagnoseCodeModeTypeScript, Nt as mergeCapabilities, Ot as serializeMessage, P as createCodeModeCapletsApi, Pt as toJsonSchemaCompat, Q as loadConfigWithSources, Qt as ListResourcesRequestSchema, R as codeModeDeclarationHash, Rt as CreateMessageResultSchema, S as resolveCapletsServer, St as defaultStateBaseDir, T as nativeCapletToolName, Tt as resolveProjectCapletsRoot, U as resolveExposure, Ut as EmptyResultSchema, V as minifyCodeModeDeclarationText, W as decodeDirectResourceUri, Wt as ErrorCode, X as capabilityDescription, Xt as ListPromptsRequestSchema, Y as ServerRegistry, Yt as LATEST_PROTOCOL_VERSION, Z as loadConfig, Zt as ListResourceTemplatesRequestSchema, _ as resolveHostedCloudRemote, _n as isZ4Schema, a as projectBindingError, an as SetLevelRequestSchema, at as loadCapletFilesFromMap, b as parseServerBaseUrl, bn as safeParse, bt as defaultCacheBaseDir, c as cloudAuthPath, cn as isInitializeRequest, ct as markdownStructuredContent, d as CloudAuthClient, dn as isJSONRPCResultResponse, dt as runOAuthFlow, en as ListToolsRequestSchema, et as loadLocalOverlayConfigWithSources, fn as getLiteralValue, ft as startGenericOAuthFlow, g as resolveCapletsRemote, gn as isSchemaOptional, gt as readTokenBundle, hn as getSchemaDescription, ht as isTokenBundleExpired, i as ProjectBindingError, in as SUPPORTED_PROTOCOL_VERSIONS, it as validateCapletFile, j as runCodeMode, jt as AjvJsonSchemaValidator, k as codeModeRunInputSchema, kt as assertClientRequestTaskCapability, l as migrateCredentials, ln as isJSONRPCErrorResponse, lt as refreshOAuthTokenBundle, m as buildProjectSyncManifest, mn as getParseErrorMessage, mt as deleteTokenBundle, n as resolveRemoteSelection, nn as McpError, nt as parseConfig, o as projectBindingRecovery, on as assertCompleteRequestPrompt, ot as hasRenderableStructuredContent, p as createSdkRemoteCapletsClient, pn as getObjectShape, pt as startOAuthFlow, q as fingerprintProjectRoot, qt as InitializedNotificationSchema, r as PROJECT_BINDING_ERROR_CODES, rn as ReadResourceRequestSchema, rt as discoverCapletFiles, s as CloudAuthStore, sn as assertCompleteRequestResourceTemplate, st as markdownCallToolResultContent, t as createNativeCapletsService, tn as LoggingLevelSchema, tt as loadProjectConfig, u as redactedCloudAuthStatus, un as isJSONRPCRequest, ut as runGenericOAuthFlow, v as resolveRemoteMode, vn as normalizeObjectSchema, w as nativeCapletToolDescription, wt as resolveConfigPath, x as resolveCapletsMode, xn as safeParseAsync, xt as defaultConfigBaseDir, y as controlUrlForBase, yn as objectFromShape, yt as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, z as generateCodeModeDeclarations, zt as CreateMessageResultWithToolsSchema } from "./service-4_chB2wu.js";
1
+ import { $ as GoogleDiscoveryManager, $t as ListPromptsRequestSchema, A as emptyCodeModeRunMeta, At as ReadBuffer, B as codeModeDeclarationHash, Bt as CompleteRequestSchema, C as nativeCapletToolDescription, Cn as safeParse, Ct as defaultCacheBaseDir, Dt as resolveConfigPath, Et as resolveCapletsRoot, F as createCodeModeCapletsApi, Ft as Protocol, G as resolveExposure, Gt as ElicitResultSchema, H as generateCodeModeRunToolDescription, Ht as CreateMessageResultWithToolsSchema, I as listCodeModeCallableCaplets, It as mergeCapabilities, J as findProjectRoot, Jt as GetPromptRequestSchema, K as decodeDirectResourceUri, Kt as EmptyResultSchema, L as CodeModeJournalStore, Lt as toJsonSchemaCompat, M as CodeModeSessionManager, Mt as assertClientRequestTaskCapability, N as QuickJsCodeModeSandbox, Nt as assertToolsCallTaskCapability, O as codeModeRunInputSchema, Ot as resolveProjectCapletsRoot, P as diagnoseCodeModeTypeScript, Pt as AjvJsonSchemaValidator, Q as capabilityDescription, Qt as LATEST_PROTOCOL_VERSION, R as CodeModeLogStore, Rt as CallToolRequestSchema, S as nativeCapletPromptGuidance, Sn as objectFromShape, St as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, Tt as defaultStateBaseDir, U as minifyCodeModeDeclarationText, Ut as CreateTaskResultSchema, V as generateCodeModeDeclarations, Vt as CreateMessageResultSchema, W as CapletsEngine, X as handleServerTool, Xt as InitializedNotificationSchema, Y as fingerprintProjectRoot, Yt as InitializeRequestSchema, Z as ServerRegistry, Zt as JSONRPCMessageSchema, _ as resolveHostedCloudRemote, _n as getParseErrorMessage, _t as deleteTokenBundle, a as projectBindingError, an as McpError, at as parseConfig, b as parseServerBaseUrl, bn as isZ4Schema, c as cloudAuthPath, cn as SetLevelRequestSchema, ct as loadCapletFilesFromMap, d as CloudAuthClient, dn as isInitializeRequest, dt as markdownStructuredContent, en as ListResourceTemplatesRequestSchema, et as loadConfig, fn as isJSONRPCErrorResponse, ft as refreshOAuthTokenBundle, g as resolveCapletsRemote, gn as getObjectShape, gt as startOAuthFlow, hn as getLiteralValue, ht as startGenericOAuthFlow, i as ProjectBindingError, in as LoggingLevelSchema, it as loadProjectConfig, j as runCodeMode, jt as serializeMessage, k as codeModeRunParamsSchema, kt as resolveProjectConfigPath, l as migrateCredentials, ln as assertCompleteRequestPrompt, lt as hasRenderableStructuredContent, m as buildProjectSyncManifest, mn as isJSONRPCResultResponse, mt as runOAuthFlow, n as resolveRemoteSelection, nn as ListRootsResultSchema, nt as loadGlobalConfig, o as projectBindingRecovery, on as ReadResourceRequestSchema, ot as discoverCapletFiles, p as createSdkRemoteCapletsClient, pn as isJSONRPCRequest, pt as runGenericOAuthFlow, q as directResourceUriMatchesTemplate, qt as ErrorCode, r as PROJECT_BINDING_ERROR_CODES, rn as ListToolsRequestSchema, rt as loadLocalOverlayConfigWithSources, s as CloudAuthStore, sn as SUPPORTED_PROTOCOL_VERSIONS, st as validateCapletFile, t as createNativeCapletsService, tn as ListResourcesRequestSchema, tt as loadConfigWithSources, u as redactedCloudAuthStatus, un as assertCompleteRequestResourceTemplate, ut as markdownCallToolResultContent, v as resolveRemoteMode, vn as getSchemaDescription, vt as isTokenBundleExpired, w as nativeCapletToolName, wn as safeParseAsync, wt as defaultConfigBaseDir, x as resolveCapletsServer, xn as normalizeObjectSchema, y as controlUrlForBase, yn as isSchemaOptional, yt as readTokenBundle, z as redactCodeModeLogText, zt as CallToolResultSchema } from "./service-BCT_Ls_3.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-C0PNPwjS.js";
3
3
  import { f as redactSecrets, i as SERVER_ID_PATTERN, l as CAPLETS_ERROR_CODES, p as toSafeError, u as CapletsError } from "./validation-DgxCzt-A.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-CL5MFXwM.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-DnQujlrc.js";
5
+ import { f as observedOutputShapeKey, g as stableJsonStringify, h as schemaHash, i as observeOutputShape, u as FileObservedOutputShapeStore } from "./observed-output-shapes-D2k2-q8K.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-CzHdM9B_.js";
7
7
  import { n as normalizeCapletSourcePath, t as FilesystemCapletSource } from "./filesystem-Kkg32TOJ.js";
8
8
  import { parseConfig as parseConfig$1 } from "./config-runtime.js";
9
9
  import fs, { accessSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
@@ -1553,7 +1553,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
1553
1553
  } };
1554
1554
  //#endregion
1555
1555
  //#region package.json
1556
- var version = "0.22.0";
1556
+ var version = "0.24.0";
1557
1557
  //#endregion
1558
1558
  //#region src/serve/session.ts
1559
1559
  var CapletsMcpSession = class {
@@ -1563,6 +1563,7 @@ var CapletsMcpSession = class {
1563
1563
  resources = /* @__PURE__ */ new Map();
1564
1564
  prompts = /* @__PURE__ */ new Map();
1565
1565
  codeModeTool;
1566
+ codeModeSessions = new CodeModeSessionManager();
1566
1567
  unsubscribeReload;
1567
1568
  closed = false;
1568
1569
  constructor(engine, options = {}) {
@@ -1592,6 +1593,7 @@ var CapletsMcpSession = class {
1592
1593
  if (this.closed) return;
1593
1594
  this.closed = true;
1594
1595
  this.unsubscribeReload();
1596
+ this.codeModeSessions.close();
1595
1597
  this.clearRegistrations();
1596
1598
  await this.server.close();
1597
1599
  }
@@ -1675,7 +1677,11 @@ var CapletsMcpSession = class {
1675
1677
  code: parsed.data.code,
1676
1678
  service: new EngineNativeCapletsService(this.engine),
1677
1679
  ...parsed.data.timeoutMs === void 0 ? {} : { timeoutMs: parsed.data.timeoutMs },
1678
- logStore: new CodeModeLogStore()
1680
+ ...parsed.data.sessionId === void 0 ? {} : { sessionId: parsed.data.sessionId },
1681
+ logStore: new CodeModeLogStore(),
1682
+ journalStore: new CodeModeJournalStore(),
1683
+ sessionManager: this.codeModeSessions,
1684
+ runtimeScope: "mcp"
1679
1685
  }) : {
1680
1686
  ok: false,
1681
1687
  error: {
@@ -1689,14 +1695,7 @@ var CapletsMcpSession = class {
1689
1695
  truncated: false,
1690
1696
  stored: false
1691
1697
  },
1692
- meta: {
1693
- runId: "",
1694
- traceId: "",
1695
- declarationHash: "",
1696
- durationMs: 0,
1697
- timeoutMs: 0,
1698
- maxTimeoutMs: 0
1699
- }
1698
+ meta: emptyCodeModeRunMeta()
1700
1699
  };
1701
1700
  return {
1702
1701
  content: [{
@@ -1895,6 +1894,8 @@ function engineOptions(options) {
1895
1894
  if (options.configPath !== void 0) engineOptions.configPath = options.configPath;
1896
1895
  if (options.projectConfigPath !== void 0) engineOptions.projectConfigPath = options.projectConfigPath;
1897
1896
  if (options.authDir !== void 0) engineOptions.authDir = options.authDir;
1897
+ if (options.artifactDir !== void 0) engineOptions.artifactDir = options.artifactDir;
1898
+ if (options.exposeLocalArtifactPaths !== void 0) engineOptions.exposeLocalArtifactPaths = options.exposeLocalArtifactPaths;
1898
1899
  if (options.watchDebounceMs !== void 0) engineOptions.watchDebounceMs = options.watchDebounceMs;
1899
1900
  if (options.writeErr !== void 0) engineOptions.writeErr = options.writeErr;
1900
1901
  return engineOptions;
@@ -4994,7 +4995,7 @@ function isPackageCommand(command) {
4994
4995
  function renderCaplet(input) {
4995
4996
  const lines = [
4996
4997
  "---",
4997
- "$schema: https://caplets.dev/caplet-frontmatter.schema.json",
4998
+ "# yaml-language-server: $schema=https://caplets.dev/caplet.schema.json",
4998
4999
  `name: ${yamlString$1(input.name)}`,
4999
5000
  `description: ${yamlString$1(input.description)}`,
5000
5001
  "tags:",
@@ -5081,6 +5082,15 @@ function addOpenApiCaplet(id, options) {
5081
5082
  ["auth", authFromTokenEnv(options.tokenEnv) ?? { type: "none" }]
5082
5083
  ], options);
5083
5084
  }
5085
+ function addGoogleDiscoveryCaplet(id, options) {
5086
+ const discovery = options.discovery ?? options.discoveryUrl;
5087
+ if (!discovery) throw new CapletsError("REQUEST_INVALID", "Google Discovery Caplet requires --discovery or --discovery-url");
5088
+ return writeGeneratedCaplet(id, "Google Discovery", "googleDiscoveryApi", [
5089
+ [options.discoveryUrl ? "discoveryUrl" : isUrlLike(discovery) ? "discoveryUrl" : "discoveryPath", discovery],
5090
+ ["baseUrl", options.baseUrl],
5091
+ ["auth", authFromTokenEnv(options.tokenEnv) ?? { type: "none" }]
5092
+ ], options);
5093
+ }
5084
5094
  function addGraphqlCaplet(id, options) {
5085
5095
  if (!options.endpointUrl) throw new CapletsError("REQUEST_INVALID", "GraphQL Caplet requires --endpoint-url");
5086
5096
  if (Boolean(options.schema) === Boolean(options.introspection)) throw new CapletsError("REQUEST_INVALID", "GraphQL Caplet requires exactly one of --schema or --introspection");
@@ -5183,7 +5193,7 @@ function resolvePrintOutputPath(id, options) {
5183
5193
  }
5184
5194
  function renderLocalPaths(fields, outputDir) {
5185
5195
  return fields.map(([key, value]) => {
5186
- if (key !== "specPath" && key !== "schemaPath" || typeof value !== "string") return [key, value];
5196
+ if (key !== "specPath" && key !== "schemaPath" && key !== "discoveryPath" || typeof value !== "string") return [key, value];
5187
5197
  return [key, localPathRelativeToOutput(value, outputDir)];
5188
5198
  });
5189
5199
  }
@@ -5234,7 +5244,7 @@ function renderBackendCaplet(id, label, backend, fields) {
5234
5244
  const description = `${label} backend Caplet generated by caplets add.`;
5235
5245
  const lines = [
5236
5246
  "---",
5237
- "$schema: https://caplets.dev/caplet-frontmatter.schema.json",
5247
+ "$schema: https://caplets.dev/caplet.schema.json",
5238
5248
  `name: ${yamlString(name)}`,
5239
5249
  `description: ${yamlString(description)}`,
5240
5250
  "tags:",
@@ -5343,7 +5353,7 @@ function collectFiles(root) {
5343
5353
  //#endregion
5344
5354
  //#region src/cli/auth.ts
5345
5355
  async function loginAuth(serverId, options) {
5346
- const server = findAuthTarget(serverId, options.config ?? loadConfig(options.configPath));
5356
+ const server = await resolveAuthTarget$1(serverId, options.config ?? loadConfig(options.configPath), options.authDir);
5347
5357
  assertLoginTarget(server, serverId);
5348
5358
  try {
5349
5359
  const flowOptions = {
@@ -5376,7 +5386,7 @@ async function refreshAuth(serverId, options) {
5376
5386
  options.writeOut(`Refreshed OAuth credentials for \`${serverId}\`.\n`);
5377
5387
  }
5378
5388
  async function refreshAuthResult(serverId, options) {
5379
- const target = findAuthTarget(serverId, options.config ?? loadConfig(options.configPath));
5389
+ const target = await resolveAuthTarget$1(serverId, options.config ?? loadConfig(options.configPath), options.authDir);
5380
5390
  assertLoginTarget(target, serverId);
5381
5391
  await refreshOAuthTokenBundle(target, options.authDir);
5382
5392
  return { server: serverId };
@@ -5450,14 +5460,35 @@ function formatAuthRows(rows, format) {
5450
5460
  function findAuthTarget(serverId, config = loadConfig()) {
5451
5461
  return authTargets(config).find((server) => server.server === serverId);
5452
5462
  }
5463
+ async function resolveAuthTarget$1(serverId, config, authDir) {
5464
+ const target = findAuthTarget(serverId, config);
5465
+ if (target?.backend !== "googleDiscovery") return target;
5466
+ const api = config.googleDiscoveryApis[serverId];
5467
+ if (!api || api.auth.type !== "oauth2" && api.auth.type !== "oidc") return target;
5468
+ const manager = new GoogleDiscoveryManager(new ServerRegistry(config), authDir ? { authDir } : {});
5469
+ const baseUrl = api.baseUrl ?? await manager.resolveBaseUrl(api).catch(() => void 0) ?? api.discoveryUrl;
5470
+ return {
5471
+ ...target,
5472
+ ...baseUrl ? { baseUrl } : {},
5473
+ ...api.auth.scopes?.length ? {} : { resolvedScopes: await manager.resolveAuthScopes(api) }
5474
+ };
5475
+ }
5453
5476
  function authTargets(config) {
5454
5477
  return [
5455
5478
  ...Object.values(config.mcpServers).filter((server) => server.transport !== "stdio" && (server.auth?.type === "oauth2" || server.auth?.type === "oidc")),
5456
5479
  ...Object.values(config.openapiEndpoints).filter((endpoint) => endpoint.auth?.type === "oauth2" || endpoint.auth?.type === "oidc"),
5480
+ ...Object.values(config.googleDiscoveryApis).filter((api) => api.auth?.type === "oauth2" || api.auth?.type === "oidc").map(googleDiscoveryAuthTarget),
5457
5481
  ...Object.values(config.graphqlEndpoints).filter((endpoint) => endpoint.auth?.type === "oauth2" || endpoint.auth?.type === "oidc").map(graphQlAuthTarget),
5458
5482
  ...Object.values(config.httpApis).filter((api) => api.auth?.type === "oauth2" || api.auth?.type === "oidc").map(httpAuthTarget)
5459
5483
  ];
5460
5484
  }
5485
+ function googleDiscoveryAuthTarget(api) {
5486
+ const baseUrl = api.baseUrl ?? api.discoveryUrl;
5487
+ return {
5488
+ ...api,
5489
+ ...baseUrl ? { baseUrl } : {}
5490
+ };
5491
+ }
5461
5492
  function graphQlAuthTarget(endpoint) {
5462
5493
  return {
5463
5494
  ...endpoint,
@@ -5493,10 +5524,31 @@ async function runCodeModeCli(options) {
5493
5524
  ...options.authDir ? { authDir: options.authDir } : {}
5494
5525
  });
5495
5526
  try {
5496
- const code = await readCodeModeCliCode(options);
5497
- const result = await service.execute(nativeCodeModeToolId, {
5498
- code,
5499
- ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs }
5527
+ if (options.sessionId !== void 0) {
5528
+ const result = {
5529
+ ok: false,
5530
+ error: {
5531
+ code: "SESSION_NOT_FOUND",
5532
+ message: "Code Mode one-shot CLI runs do not support --session-id. Omit --session-id to start a fresh one-shot run."
5533
+ },
5534
+ diagnostics: [],
5535
+ logs: {
5536
+ entries: [],
5537
+ truncated: false,
5538
+ stored: false
5539
+ },
5540
+ meta: emptyCodeModeRunMeta()
5541
+ };
5542
+ if (options.json) options.writeOut(`${JSON.stringify(result, null, 2)}\n`);
5543
+ else options.writeOut(`${result.error.code}: ${result.error.message}\n`);
5544
+ options.setExitCode(1);
5545
+ return;
5546
+ }
5547
+ const result = await runCodeMode({
5548
+ code: await readCodeModeCliCode(options),
5549
+ service: service.codeModeService?.() ?? service,
5550
+ ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
5551
+ runtimeScope: "cli-one-shot"
5500
5552
  });
5501
5553
  if (options.json) options.writeOut(`${JSON.stringify(result, null, 2)}\n`);
5502
5554
  else if (result.ok) options.writeOut(`${formatHumanValue(result.value)}\n`);
@@ -5509,6 +5561,25 @@ async function runCodeModeCli(options) {
5509
5561
  await service.close();
5510
5562
  }
5511
5563
  }
5564
+ async function runCodeModeReplCli(options) {
5565
+ const envelope = {
5566
+ ok: false,
5567
+ error: {
5568
+ code: "UNSUPPORTED_OPERATION",
5569
+ message: "Code Mode REPL sessions are not available in this build. Use `caplets code-mode` for one-shot runs."
5570
+ },
5571
+ diagnostics: [],
5572
+ logs: {
5573
+ entries: [],
5574
+ truncated: false,
5575
+ stored: false
5576
+ },
5577
+ meta: emptyCodeModeRunMeta()
5578
+ };
5579
+ if (options.json) options.writeOut(`${JSON.stringify(envelope, null, 2)}\n`);
5580
+ else options.writeOut(`${envelope.error.code}: ${envelope.error.message}\n`);
5581
+ options.setExitCode(1);
5582
+ }
5512
5583
  async function codeModeTypesCli(options) {
5513
5584
  const engine = new CapletsEngine({
5514
5585
  ...options.configPath ? { configPath: options.configPath } : {},
@@ -6090,6 +6161,7 @@ function allCaplets(config) {
6090
6161
  return [
6091
6162
  ...Object.values(typed.mcpServers ?? {}),
6092
6163
  ...Object.values(typed.openapiEndpoints ?? {}),
6164
+ ...Object.values(typed.googleDiscoveryApis ?? {}),
6093
6165
  ...Object.values(typed.graphqlEndpoints ?? {}),
6094
6166
  ...Object.values(typed.httpApis ?? {}),
6095
6167
  ...Object.values(typed.cliTools ?? {}),
@@ -6690,6 +6762,7 @@ async function runCapletSetupCli(capletId, options = {}) {
6690
6762
  const caplet = Object.values({
6691
6763
  ...config.mcpServers,
6692
6764
  ...config.openapiEndpoints,
6765
+ ...config.googleDiscoveryApis,
6693
6766
  ...config.graphqlEndpoints,
6694
6767
  ...config.httpApis,
6695
6768
  ...config.cliTools,
@@ -6815,6 +6888,8 @@ async function runSetup(integration, options = {}) {
6815
6888
  if (!setupIntegrationIds.includes(integration)) return await runCapletSetupCli(integration, {
6816
6889
  ...options.yes === void 0 ? {} : { yes: options.yes },
6817
6890
  target: resolveSetupTargetKind(options),
6891
+ ...options.env?.CAPLETS_CONFIG ? { configPath: options.env.CAPLETS_CONFIG } : {},
6892
+ ...options.env?.CAPLETS_PROJECT_CONFIG ? { projectConfigPath: options.env.CAPLETS_PROJECT_CONFIG } : {},
6818
6893
  ...options.remote === void 0 && !isRemoteSetup(options) ? {} : { remote: isRemoteSetup(options) }
6819
6894
  });
6820
6895
  const result = await executeSetup(integration, options);
@@ -6932,7 +7007,7 @@ function setupDefinition(id, options) {
6932
7007
  }
6933
7008
  }
6934
7009
  function remoteSetupDefinition(id, options) {
6935
- const serverUrl = nonEmpty$1(options.remoteUrl) ?? nonEmpty$1(options.serverUrl) ?? nonEmpty$1(options.env?.CAPLETS_REMOTE_URL) ?? nonEmpty$1(options.env?.CAPLETS_SERVER_URL) ?? "https://caplets.example.com/caplets";
7010
+ const serverUrl = nonEmpty$1(options.remoteUrl) ?? nonEmpty$1(options.serverUrl) ?? nonEmpty$1(options.env?.CAPLETS_REMOTE_URL) ?? "https://caplets.example.com/caplets";
6936
7011
  if (id === "opencode") return {
6937
7012
  name: "OpenCode",
6938
7013
  actions: [{
@@ -6945,7 +7020,7 @@ function remoteSetupDefinition(id, options) {
6945
7020
  "--global"
6946
7021
  ]
6947
7022
  }],
6948
- nextSteps: [`Run OpenCode with CAPLETS_MODE=remote and CAPLETS_SERVER_URL=${serverUrl}.`, "Keep CAPLETS_SERVER_PASSWORD in your shell or secret manager."]
7023
+ nextSteps: [`Run OpenCode with CAPLETS_MODE=remote and CAPLETS_REMOTE_URL=${serverUrl}.`, "Keep CAPLETS_REMOTE_TOKEN or CAPLETS_REMOTE_PASSWORD in your shell or secret manager."]
6949
7024
  };
6950
7025
  if (id === "pi") return {
6951
7026
  name: "Pi",
@@ -6955,7 +7030,7 @@ function remoteSetupDefinition(id, options) {
6955
7030
  command: "pi",
6956
7031
  args: ["install", "npm:@caplets/pi"]
6957
7032
  }],
6958
- nextSteps: [`Start Pi with CAPLETS_MODE=remote and CAPLETS_SERVER_URL=${serverUrl}.`, "Keep CAPLETS_SERVER_PASSWORD in your shell or secret manager."]
7033
+ nextSteps: [`Start Pi with CAPLETS_MODE=remote and CAPLETS_REMOTE_URL=${serverUrl}.`, "Keep CAPLETS_REMOTE_TOKEN or CAPLETS_REMOTE_PASSWORD in your shell or secret manager."]
6959
7034
  };
6960
7035
  if (id === "codex") return {
6961
7036
  name: "Codex",
@@ -6994,7 +7069,7 @@ function remoteSetupDefinition(id, options) {
6994
7069
  path: options.output,
6995
7070
  content: `${JSON.stringify({ mcpServers: { caplets: { url: `${serverUrl.replace(/\/$/, "")}/v1/mcp` } } }, null, 2)}\n`
6996
7071
  }],
6997
- nextSteps: ["Add Basic Auth credentials through your agent's secret mechanism.", "Do not hardcode CAPLETS_SERVER_PASSWORD in a committed config file."]
7072
+ nextSteps: ["Add Basic Auth credentials through your agent's secret mechanism.", "Do not hardcode CAPLETS_REMOTE_TOKEN or CAPLETS_REMOTE_PASSWORD in a committed config file."]
6998
7073
  };
6999
7074
  }
7000
7075
  function parseSetupIntegrationId(value) {
@@ -10974,7 +11049,7 @@ async function dispatch(request, context) {
10974
11049
  async function startRemoteAuthLogin(serverId, context) {
10975
11050
  if (!context.authFlowStore || !context.controlCallbackBaseUrl) throw new CapletsError("REQUEST_INVALID", "Remote auth login is not available on this server");
10976
11051
  const config = loadConfigWithSources(context.configPath, context.projectConfigPath).config;
10977
- const target = findAuthTarget(serverId, config);
11052
+ const target = await resolveAuthTarget$1(serverId, config, context.authDir);
10978
11053
  assertLoginTarget(target, serverId);
10979
11054
  const flowId = randomUUID();
10980
11055
  const baseUrl = context.controlCallbackBaseUrl.endsWith("/") ? context.controlCallbackBaseUrl : `${context.controlCallbackBaseUrl}/`;
@@ -11043,6 +11118,16 @@ function dispatchAdd(args, context) {
11043
11118
  print: false
11044
11119
  })
11045
11120
  };
11121
+ case "google-discovery":
11122
+ case "googleDiscovery": return {
11123
+ remote: true,
11124
+ label: "Google Discovery",
11125
+ ...addGoogleDiscoveryCaplet(id, {
11126
+ ...options,
11127
+ destinationRoot: context.projectCapletsRoot,
11128
+ print: false
11129
+ })
11130
+ };
11046
11131
  case "graphql": return {
11047
11132
  remote: true,
11048
11133
  label: "GraphQL",
@@ -11061,7 +11146,7 @@ function dispatchAdd(args, context) {
11061
11146
  print: false
11062
11147
  })
11063
11148
  };
11064
- default: throw new CapletsError("REQUEST_INVALID", "add.kind must be cli, mcp, openapi, graphql, or http");
11149
+ default: throw new CapletsError("REQUEST_INVALID", "add.kind must be cli, mcp, openapi, google-discovery, googleDiscovery, graphql, or http");
11065
11150
  }
11066
11151
  }
11067
11152
  function optionalProp(key, value) {
@@ -11118,6 +11203,14 @@ function remoteAddOptions$1(kind, options) {
11118
11203
  tokenEnv: "string",
11119
11204
  force: "boolean"
11120
11205
  });
11206
+ case "google-discovery":
11207
+ case "googleDiscovery": return pickOptions(options, {
11208
+ discovery: "string",
11209
+ discoveryUrl: "string",
11210
+ baseUrl: "string",
11211
+ tokenEnv: "string",
11212
+ force: "boolean"
11213
+ });
11121
11214
  case "graphql": return pickOptions(options, {
11122
11215
  endpointUrl: "string",
11123
11216
  schema: "string",
@@ -11458,12 +11551,16 @@ function attachEventsResponse(engine, activeStreams) {
11458
11551
  } });
11459
11552
  }
11460
11553
  async function serveHttp(options, engineOptions = {}, writeErr = (value) => process.stderr.write(value)) {
11461
- const engine = new CapletsEngine(engineOptions);
11554
+ const resolvedEngineOptions = {
11555
+ exposeLocalArtifactPaths: false,
11556
+ ...engineOptions
11557
+ };
11558
+ const engine = new CapletsEngine(resolvedEngineOptions);
11462
11559
  const app = createHttpServeApp(options, engine, {
11463
11560
  writeErr,
11464
11561
  control: {
11465
- ...engineOptions,
11466
- projectCapletsRoot: projectCapletsRootForEngineOptions(engineOptions)
11562
+ ...resolvedEngineOptions,
11563
+ projectCapletsRoot: projectCapletsRootForEngineOptions(resolvedEngineOptions)
11467
11564
  }
11468
11565
  });
11469
11566
  const paths = servicePaths(options.path);
@@ -11483,12 +11580,16 @@ async function serveHttp(options, engineOptions = {}, writeErr = (value) => proc
11483
11580
  }), app, engine, writeErr);
11484
11581
  }
11485
11582
  async function serveHttpWithSessionFactory(options, createSession, writeErr = (value) => process.stderr.write(value)) {
11486
- const engine = new CapletsEngine({});
11583
+ const resolvedEngineOptions = { exposeLocalArtifactPaths: false };
11584
+ const engine = new CapletsEngine(resolvedEngineOptions);
11487
11585
  const app = createHttpServeApp(options, engine, {
11488
11586
  writeErr,
11489
11587
  exposeAttach: false,
11490
11588
  sessionFactory: createSession,
11491
- control: { projectCapletsRoot: resolveProjectCapletsRoot() }
11589
+ control: {
11590
+ ...resolvedEngineOptions,
11591
+ projectCapletsRoot: resolveProjectCapletsRoot()
11592
+ }
11492
11593
  });
11493
11594
  const paths = servicePaths(options.path);
11494
11595
  const origin = `http://${formatHost(options.host)}:${options.port}`;
@@ -11729,11 +11830,8 @@ function createAttachNativeService(options, io) {
11729
11830
  mode: options.selection.kind === "hosted_cloud" ? "cloud" : "remote",
11730
11831
  configPath: options.configPath,
11731
11832
  projectConfigPath: options.projectConfigPath,
11732
- server: {
11733
- url: options.selection.remote.baseUrl.toString(),
11734
- ...options.selection.remote.fetch ? { fetch: options.selection.remote.fetch } : {}
11735
- },
11736
11833
  remote: {
11834
+ url: options.selection.remote.baseUrl.toString(),
11737
11835
  ...options.selection.remote.fetch ? { fetch: options.selection.remote.fetch } : {},
11738
11836
  ...options.selection.kind === "hosted_cloud" ? { cloud: {
11739
11837
  url: options.selection.cloudPresence.url.toString(),
@@ -11749,6 +11847,7 @@ function createAttachNativeService(options, io) {
11749
11847
  url: options.selection.remote.attachUrl,
11750
11848
  ...options.selection.remote.fetch ? { fetch: options.selection.remote.fetch } : {}
11751
11849
  }),
11850
+ exposeLocalArtifactPaths: false,
11752
11851
  ...io.writeErr ? { writeErr: io.writeErr } : {}
11753
11852
  });
11754
11853
  }
@@ -12895,7 +12994,35 @@ function createProgram(io = {}) {
12895
12994
  }
12896
12995
  if (suggestions.length > 0) writeOut(`${suggestions.join("\n")}\n`);
12897
12996
  });
12898
- program.command(cliCommands$1.codeMode).description("Run, inspect, and debug Caplets Code Mode.").argument("[code]", "inline TypeScript code to run").option("--file <path>", "read TypeScript code from a file relative to the current directory").option("--timeout-ms <ms>", "execution timeout in milliseconds", parsePositiveInteger).option("--json", "print the structured run envelope").action(async (code, options) => {
12997
+ program.command(cliCommands$1.codeMode).description("Run, inspect, and debug Caplets Code Mode.").argument("[code]", "inline TypeScript code to run").option("--file <path>", "read TypeScript code from a file relative to the current directory").option("--session-id <id>", "optional Code Mode session identifier").option("--recover <ref>", "recover a prior Code Mode REPL session when supported").option("--timeout-ms <ms>", "execution timeout in milliseconds", parsePositiveInteger).option("--json", "print the structured run envelope").action(async (code, options) => {
12998
+ if (code === "repl" && options.file === void 0) {
12999
+ await runCodeModeReplCli({
13000
+ env,
13001
+ ...currentConfigPath() ? { configPath: currentConfigPath() } : {},
13002
+ projectConfigPath: envProjectConfigPath(env),
13003
+ ...io.authDir ? { authDir: io.authDir } : {},
13004
+ ...options.sessionId === void 0 ? {} : { sessionId: options.sessionId },
13005
+ ...options.recover === void 0 ? {} : { recoveryRef: options.recover },
13006
+ ...options.json === void 0 ? {} : { json: options.json },
13007
+ writeOut,
13008
+ setExitCode
13009
+ });
13010
+ return;
13011
+ }
13012
+ if (options.recover !== void 0) {
13013
+ await runCodeModeReplCli({
13014
+ env,
13015
+ ...currentConfigPath() ? { configPath: currentConfigPath() } : {},
13016
+ projectConfigPath: envProjectConfigPath(env),
13017
+ ...io.authDir ? { authDir: io.authDir } : {},
13018
+ ...options.sessionId === void 0 ? {} : { sessionId: options.sessionId },
13019
+ recoveryRef: options.recover,
13020
+ ...options.json === void 0 ? {} : { json: options.json },
13021
+ writeOut,
13022
+ setExitCode
13023
+ });
13024
+ return;
13025
+ }
12899
13026
  await runCodeModeCli({
12900
13027
  env,
12901
13028
  ...currentConfigPath() ? { configPath: currentConfigPath() } : {},
@@ -12903,6 +13030,7 @@ function createProgram(io = {}) {
12903
13030
  ...io.authDir ? { authDir: io.authDir } : {},
12904
13031
  ...code === void 0 ? {} : { inlineCode: code },
12905
13032
  ...options.file === void 0 ? {} : { file: options.file },
13033
+ ...options.sessionId === void 0 ? {} : { sessionId: options.sessionId },
12906
13034
  ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
12907
13035
  ...options.json === void 0 ? {} : { json: options.json },
12908
13036
  ...io.readStdin ? { readStdin: io.readStdin } : {},
@@ -13314,6 +13442,22 @@ function createProgram(io = {}) {
13314
13442
  });
13315
13443
  writeAddResult(writeOut, `${localMutationTargetLabel(target, io)}OpenAPI`, result);
13316
13444
  });
13445
+ add.command("google-discovery").description("Add a Google Discovery API backend Caplet.").argument("<id>", "Caplet ID/display seed").option("--discovery <path-or-url>", "Google Discovery document path or URL").option("--discovery-url <url>", "remote Google Discovery document URL").option("--base-url <url>", "request base URL override").option("--token-env <ENV>", "bearer token environment variable reference").option("--project", "write to the project Caplets root").option("-g, --global", "write to the user Caplets root").option("--remote", "add through remote control").option("--print", "print generated Caplet text without writing a file").option("--output <path>", "output path").option("--force", "overwrite an existing destination file").action(async (id, options) => {
13446
+ const target = parseMutationTarget(options);
13447
+ if (target === "remote") {
13448
+ writeAddResult(writeOut, "Google Discovery", await requireRemoteClientForTarget(io).request("add", {
13449
+ kind: "googleDiscovery",
13450
+ id,
13451
+ options: remoteAddOptions(options)
13452
+ }));
13453
+ return;
13454
+ }
13455
+ const result = addGoogleDiscoveryCaplet(id, {
13456
+ ...options,
13457
+ destinationRoot: addDestinationRoot(target, currentConfigPath(), env)
13458
+ });
13459
+ writeAddResult(writeOut, `${localMutationTargetLabel(target, io)}Google Discovery`, result);
13460
+ });
13317
13461
  add.command("graphql").description("Add a GraphQL backend Caplet.").argument("<id>", "Caplet ID/display seed").option("--endpoint-url <url>", "GraphQL endpoint URL").option("--schema <path-or-url>", "GraphQL schema path or URL").option("--introspection", "load schema through endpoint introspection").option("--token-env <ENV>", "bearer token environment variable reference").option("--project", "write to the project Caplets root").option("-g, --global", "write to the user Caplets root").option("--remote", "add through remote control").option("--print", "print generated Caplet text without writing a file").option("--output <path>", "output path").option("--force", "overwrite an existing destination file").action(async (id, options) => {
13318
13462
  const target = parseMutationTarget(options);
13319
13463
  if (target === "remote") {
@@ -13636,8 +13780,8 @@ function envConfigPath(env) {
13636
13780
  }
13637
13781
  function remoteClientForCli(io) {
13638
13782
  const env = io.env ?? process.env;
13639
- if (resolveCapletsMode({}, env).mode !== "remote") return;
13640
- return new RemoteControlClient(resolveCapletsServer(io.fetch ? { fetch: io.fetch } : {}, env));
13783
+ if (resolveRemoteMode({}, env).mode !== "remote") return;
13784
+ return new RemoteControlClient(resolveCapletsRemote(io.fetch ? { fetch: io.fetch } : {}, env));
13641
13785
  }
13642
13786
  async function openBrowser(url) {
13643
13787
  const { spawn } = await import("node:child_process");
@@ -13752,7 +13896,7 @@ async function remoteAuthLogin(remote, serverId, open, writeOut) {
13752
13896
  }
13753
13897
  function requireRemoteClientForTarget(io) {
13754
13898
  const remote = remoteClientForCli(io);
13755
- if (!remote) throw new CapletsError("REQUEST_INVALID", "--remote requires CAPLETS_MODE=remote and CAPLETS_SERVER_URL");
13899
+ if (!remote) throw new CapletsError("REQUEST_INVALID", "--remote requires CAPLETS_MODE=remote and CAPLETS_REMOTE_URL");
13756
13900
  return remote;
13757
13901
  }
13758
13902
  function collect(value, previous) {
@@ -13954,6 +14098,7 @@ function mergePartialLocalOverlays(globalOverlay, projectOverlay) {
13954
14098
  const capletConfigKinds = [
13955
14099
  "mcpServers",
13956
14100
  "openapiEndpoints",
14101
+ "googleDiscoveryApis",
13957
14102
  "graphqlEndpoints",
13958
14103
  "httpApis",
13959
14104
  "cliTools",
@@ -13996,7 +14141,7 @@ function formatOverlaySource(kind) {
13996
14141
  return kind;
13997
14142
  }
13998
14143
  function hasEnabledCaplet(config, id) {
13999
- const caplet = config.mcpServers[id] ?? config.openapiEndpoints[id] ?? config.graphqlEndpoints[id] ?? config.httpApis[id] ?? config.cliTools[id] ?? config.capletSets[id];
14144
+ const caplet = config.mcpServers[id] ?? config.openapiEndpoints[id] ?? config.googleDiscoveryApis[id] ?? config.graphqlEndpoints[id] ?? config.httpApis[id] ?? config.cliTools[id] ?? config.capletSets[id];
14000
14145
  return Boolean(caplet && !caplet.disabled);
14001
14146
  }
14002
14147
  async function executeLocalOperation(caplet, request, io, config) {
@@ -14631,7 +14776,7 @@ function classifyCapletRuntimeRoute(caplet) {
14631
14776
  if (caplet.setup) return "process";
14632
14777
  if (caplet.backend === "cli") return "process";
14633
14778
  if (caplet.backend === "mcp") return caplet.transport === "stdio" || Boolean(caplet.command) ? "process" : "worker_safe";
14634
- if (caplet.backend === "openapi" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
14779
+ if (caplet.backend === "openapi" || caplet.backend === "googleDiscovery" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
14635
14780
  if (caplet.backend === "caplets") return "worker_safe";
14636
14781
  return "local_only";
14637
14782
  }
@@ -14740,6 +14885,7 @@ function capletsFromConfig(config) {
14740
14885
  return [
14741
14886
  ...Object.values(config.mcpServers),
14742
14887
  ...Object.values(config.openapiEndpoints),
14888
+ ...Object.values(config.googleDiscoveryApis ?? {}),
14743
14889
  ...Object.values(config.graphqlEndpoints),
14744
14890
  ...Object.values(config.httpApis),
14745
14891
  ...Object.values(config.cliTools),
@@ -14748,6 +14894,7 @@ function capletsFromConfig(config) {
14748
14894
  }
14749
14895
  function localReferencePaths(caplet) {
14750
14896
  if (caplet.backend === "openapi") return filterLocalReferences([caplet.specPath]);
14897
+ if (caplet.backend === "googleDiscovery") return filterLocalReferences([caplet.discoveryPath]);
14751
14898
  if (caplet.backend === "graphql") return filterLocalReferences([caplet.schemaPath, ...Object.values(caplet.operations ?? {}).map((operation) => operation.documentPath)]);
14752
14899
  if (caplet.backend === "caplets") return filterLocalReferences([caplet.configPath]);
14753
14900
  return [];
@@ -0,0 +1,24 @@
1
+ export type MediaArtifact = {
2
+ uri: string;
3
+ path?: string;
4
+ filename: string;
5
+ mimeType?: string;
6
+ byteLength: number;
7
+ sha256: string;
8
+ };
9
+ export type WriteMediaArtifactInput = {
10
+ rootDir?: string;
11
+ capletId: string;
12
+ callId?: string;
13
+ suggestedFilename?: string;
14
+ outputPath?: string;
15
+ mimeType?: string;
16
+ bytes: Uint8Array | Buffer;
17
+ exposeLocalPath?: boolean;
18
+ };
19
+ export declare function artifactUri(capletId: string, callId: string, filename: string): string;
20
+ export declare function writeMediaArtifact(input: WriteMediaArtifactInput): Promise<MediaArtifact>;
21
+ export declare function resolveMediaArtifact(uri: string, options?: {
22
+ artifactRoot?: string;
23
+ maxBytes?: number;
24
+ }): MediaArtifact;
@@ -0,0 +1,2 @@
1
+ export * from "./artifacts";
2
+ export * from "./input";
@@ -0,0 +1,29 @@
1
+ export type MediaInput = {
2
+ path: string;
3
+ artifact?: never;
4
+ dataUrl?: never;
5
+ filename?: string;
6
+ mimeType?: string;
7
+ } | {
8
+ artifact: string;
9
+ path?: never;
10
+ dataUrl?: never;
11
+ filename?: string;
12
+ mimeType?: string;
13
+ } | {
14
+ dataUrl: string;
15
+ path?: never;
16
+ artifact?: never;
17
+ filename?: string;
18
+ mimeType?: string;
19
+ };
20
+ export type ResolvedMediaInput = {
21
+ bytes: Buffer;
22
+ filename: string;
23
+ mimeType?: string;
24
+ };
25
+ export declare function readMediaInput(input: unknown, options?: {
26
+ artifactRoot?: string;
27
+ maxBytes?: number;
28
+ allowLocalPaths?: boolean;
29
+ }): Promise<ResolvedMediaInput>;
@@ -1,10 +1,8 @@
1
- import type { CapletsServerEnv, CapletsServerInput } from "../server/options";
2
- import { type CapletsRemoteEnv } from "../remote/options";
1
+ import { type CapletsRemoteEnv, type CapletsRemoteInput } from "../remote/options";
3
2
  type CapletsMode = "auto" | "local" | "remote" | "cloud";
4
3
  export type NativeCapletsMode = CapletsMode;
5
- export type NativeRemoteCapletsOptions = {
4
+ export type NativeRemoteCapletsOptions = CapletsRemoteInput & {
6
5
  pollIntervalMs?: number;
7
- fetch?: typeof fetch;
8
6
  cloud?: NativeCloudPresenceInput;
9
7
  };
10
8
  export type NativeCloudPresenceInput = {
@@ -16,10 +14,9 @@ export type NativeCloudPresenceInput = {
16
14
  };
17
15
  export type NativeCapletsServiceResolutionInput = {
18
16
  mode?: NativeCapletsMode;
19
- server?: CapletsServerInput;
20
17
  remote?: NativeRemoteCapletsOptions;
21
18
  };
22
- export type NativeCapletsEnv = CapletsServerEnv & CapletsRemoteEnv;
19
+ export type NativeCapletsEnv = CapletsRemoteEnv & Partial<Record<"CAPLETS_CLOUD_URL" | "CAPLETS_CLOUD_TOKEN" | "CAPLETS_CLOUD_WORKSPACE_ID" | "CAPLETS_PROJECT_ROOT", string>>;
23
20
  export type NativeRemoteAuthOptions = {
24
21
  enabled: false;
25
22
  user: string;
@@ -40,11 +40,13 @@ export declare class RemoteNativeCapletsService implements NativeCapletsService
40
40
  private client;
41
41
  private unsubscribeRemote;
42
42
  private readonly pollTimer;
43
+ private readonly codeModeSessions;
43
44
  private closed;
44
45
  private resetInFlight;
45
46
  constructor(options: RemoteNativeCapletsServiceOptions);
46
47
  listTools(): NativeCapletTool[];
47
48
  execute(capletId: string, request: unknown): Promise<unknown>;
49
+ codeModeService(): NativeCapletsService;
48
50
  reload(): Promise<boolean>;
49
51
  onToolsChanged(listener: NativeCapletsToolsChangedListener): () => void;
50
52
  close(): Promise<void>;
@@ -8,6 +8,7 @@ export type NativeCapletsServiceOptions = NativeCapletsServiceResolutionInput &
8
8
  configPath?: string;
9
9
  projectConfigPath?: string;
10
10
  authDir?: string;
11
+ exposeLocalArtifactPaths?: boolean;
11
12
  watchDebounceMs?: number;
12
13
  watch?: boolean;
13
14
  writeErr?: (value: string) => void;
@@ -35,6 +36,7 @@ export type NativeCapletsToolsChangedListener = (tools: NativeCapletTool[]) => v
35
36
  export type NativeCapletsService = {
36
37
  listTools(): NativeCapletTool[];
37
38
  execute(capletId: string, request: unknown): Promise<unknown>;
39
+ codeModeService?(): NativeCapletsService;
38
40
  reload(): Promise<boolean>;
39
41
  onToolsChanged(listener: NativeCapletsToolsChangedListener): () => void;
40
42
  close(): Promise<void>;