@caplets/core 0.23.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.
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { $ as loadConfigWithSources, $t as ListResourcesRequestSchema, A as codeModeRunParamsSchema, At as assertClientRequestTaskCapability, B as generateCodeModeRunToolDescription, Bt as CreateMessageResultWithToolsSchema, C as nativeCapletPromptGuidance, Ct as defaultStateBaseDir, D as nativeCodeModeToolId, Dt as resolveProjectConfigPath, Et as resolveProjectCapletsRoot, F as listCodeModeCallableCaplets, Ft as toJsonSchemaCompat, G as directResourceUriMatchesTemplate, Gt as ErrorCode, H as CapletsEngine, I as CodeModeLogStore, It as CallToolRequestSchema, J as handleServerTool, Jt as InitializedNotificationSchema, K as findProjectRoot, Kt as GetPromptRequestSchema, L as redactCodeModeLogText, Lt as CallToolResultSchema, M as QuickJsCodeModeSandbox, Mt as AjvJsonSchemaValidator, N as diagnoseCodeModeTypeScript, Nt as Protocol, Ot as ReadBuffer, P as createCodeModeCapletsApi, Pt as mergeCapabilities, Q as loadConfig, Qt as ListResourceTemplatesRequestSchema, R as codeModeDeclarationHash, Rt as CompleteRequestSchema, S as resolveCapletsServer, Sn as safeParseAsync, St as defaultConfigBaseDir, T as nativeCapletToolName, Tt as resolveConfigPath, U as resolveExposure, Ut as ElicitResultSchema, V as minifyCodeModeDeclarationText, Vt as CreateTaskResultSchema, W as decodeDirectResourceUri, Wt as EmptyResultSchema, X as capabilityDescription, Xt as LATEST_PROTOCOL_VERSION, Y as ServerRegistry, Yt as JSONRPCMessageSchema, Z as GoogleDiscoveryManager, Zt as ListPromptsRequestSchema, _ as resolveHostedCloudRemote, _n as isSchemaOptional, _t as readTokenBundle, a as projectBindingError, an as SUPPORTED_PROTOCOL_VERSIONS, at as validateCapletFile, b as parseServerBaseUrl, bn as objectFromShape, bt as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, c as cloudAuthPath, cn as assertCompleteRequestResourceTemplate, ct as markdownCallToolResultContent, d as CloudAuthClient, dn as isJSONRPCRequest, dt as runGenericOAuthFlow, en as ListRootsResultSchema, et as loadGlobalConfig, fn as isJSONRPCResultResponse, ft as runOAuthFlow, g as resolveCapletsRemote, gn as getSchemaDescription, gt as isTokenBundleExpired, hn as getParseErrorMessage, ht as deleteTokenBundle, i as ProjectBindingError, in as ReadResourceRequestSchema, it as discoverCapletFiles, j as runCodeMode, jt as assertToolsCallTaskCapability, k as codeModeRunInputSchema, kt as serializeMessage, l as migrateCredentials, ln as isInitializeRequest, lt as markdownStructuredContent, m as buildProjectSyncManifest, mn as getObjectShape, mt as startOAuthFlow, n as resolveRemoteSelection, nn as LoggingLevelSchema, nt as loadProjectConfig, o as projectBindingRecovery, on as SetLevelRequestSchema, ot as loadCapletFilesFromMap, p as createSdkRemoteCapletsClient, pn as getLiteralValue, pt as startGenericOAuthFlow, q as fingerprintProjectRoot, qt as InitializeRequestSchema, r as PROJECT_BINDING_ERROR_CODES, rn as McpError, rt as parseConfig, s as CloudAuthStore, sn as assertCompleteRequestPrompt, st as hasRenderableStructuredContent, t as createNativeCapletsService, tn as ListToolsRequestSchema, tt as loadLocalOverlayConfigWithSources, u as redactedCloudAuthStatus, un as isJSONRPCErrorResponse, ut as refreshOAuthTokenBundle, v as resolveRemoteMode, vn as isZ4Schema, w as nativeCapletToolDescription, wt as resolveCapletsRoot, x as resolveCapletsMode, xn as safeParse, xt as defaultCacheBaseDir, y as controlUrlForBase, yn as normalizeObjectSchema, z as generateCodeModeDeclarations, zt as CreateMessageResultSchema } from "./service-CSRCJfpA.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
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-BC4BNWo0.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.23.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: [{
@@ -5525,10 +5524,31 @@ async function runCodeModeCli(options) {
5525
5524
  ...options.authDir ? { authDir: options.authDir } : {}
5526
5525
  });
5527
5526
  try {
5528
- const code = await readCodeModeCliCode(options);
5529
- const result = await service.execute(nativeCodeModeToolId, {
5530
- code,
5531
- ...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"
5532
5552
  });
5533
5553
  if (options.json) options.writeOut(`${JSON.stringify(result, null, 2)}\n`);
5534
5554
  else if (result.ok) options.writeOut(`${formatHumanValue(result.value)}\n`);
@@ -5541,6 +5561,25 @@ async function runCodeModeCli(options) {
5541
5561
  await service.close();
5542
5562
  }
5543
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
+ }
5544
5583
  async function codeModeTypesCli(options) {
5545
5584
  const engine = new CapletsEngine({
5546
5585
  ...options.configPath ? { configPath: options.configPath } : {},
@@ -6968,7 +7007,7 @@ function setupDefinition(id, options) {
6968
7007
  }
6969
7008
  }
6970
7009
  function remoteSetupDefinition(id, options) {
6971
- 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";
6972
7011
  if (id === "opencode") return {
6973
7012
  name: "OpenCode",
6974
7013
  actions: [{
@@ -6981,7 +7020,7 @@ function remoteSetupDefinition(id, options) {
6981
7020
  "--global"
6982
7021
  ]
6983
7022
  }],
6984
- 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."]
6985
7024
  };
6986
7025
  if (id === "pi") return {
6987
7026
  name: "Pi",
@@ -6991,7 +7030,7 @@ function remoteSetupDefinition(id, options) {
6991
7030
  command: "pi",
6992
7031
  args: ["install", "npm:@caplets/pi"]
6993
7032
  }],
6994
- 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."]
6995
7034
  };
6996
7035
  if (id === "codex") return {
6997
7036
  name: "Codex",
@@ -7030,7 +7069,7 @@ function remoteSetupDefinition(id, options) {
7030
7069
  path: options.output,
7031
7070
  content: `${JSON.stringify({ mcpServers: { caplets: { url: `${serverUrl.replace(/\/$/, "")}/v1/mcp` } } }, null, 2)}\n`
7032
7071
  }],
7033
- 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."]
7034
7073
  };
7035
7074
  }
7036
7075
  function parseSetupIntegrationId(value) {
@@ -11791,11 +11830,8 @@ function createAttachNativeService(options, io) {
11791
11830
  mode: options.selection.kind === "hosted_cloud" ? "cloud" : "remote",
11792
11831
  configPath: options.configPath,
11793
11832
  projectConfigPath: options.projectConfigPath,
11794
- server: {
11795
- url: options.selection.remote.baseUrl.toString(),
11796
- ...options.selection.remote.fetch ? { fetch: options.selection.remote.fetch } : {}
11797
- },
11798
11833
  remote: {
11834
+ url: options.selection.remote.baseUrl.toString(),
11799
11835
  ...options.selection.remote.fetch ? { fetch: options.selection.remote.fetch } : {},
11800
11836
  ...options.selection.kind === "hosted_cloud" ? { cloud: {
11801
11837
  url: options.selection.cloudPresence.url.toString(),
@@ -12958,7 +12994,35 @@ function createProgram(io = {}) {
12958
12994
  }
12959
12995
  if (suggestions.length > 0) writeOut(`${suggestions.join("\n")}\n`);
12960
12996
  });
12961
- 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
+ }
12962
13026
  await runCodeModeCli({
12963
13027
  env,
12964
13028
  ...currentConfigPath() ? { configPath: currentConfigPath() } : {},
@@ -12966,6 +13030,7 @@ function createProgram(io = {}) {
12966
13030
  ...io.authDir ? { authDir: io.authDir } : {},
12967
13031
  ...code === void 0 ? {} : { inlineCode: code },
12968
13032
  ...options.file === void 0 ? {} : { file: options.file },
13033
+ ...options.sessionId === void 0 ? {} : { sessionId: options.sessionId },
12969
13034
  ...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
12970
13035
  ...options.json === void 0 ? {} : { json: options.json },
12971
13036
  ...io.readStdin ? { readStdin: io.readStdin } : {},
@@ -13715,8 +13780,8 @@ function envConfigPath(env) {
13715
13780
  }
13716
13781
  function remoteClientForCli(io) {
13717
13782
  const env = io.env ?? process.env;
13718
- if (resolveCapletsMode({}, env).mode !== "remote") return;
13719
- 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));
13720
13785
  }
13721
13786
  async function openBrowser(url) {
13722
13787
  const { spawn } = await import("node:child_process");
@@ -13831,7 +13896,7 @@ async function remoteAuthLogin(remote, serverId, open, writeOut) {
13831
13896
  }
13832
13897
  function requireRemoteClientForTarget(io) {
13833
13898
  const remote = remoteClientForCli(io);
13834
- 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");
13835
13900
  return remote;
13836
13901
  }
13837
13902
  function collect(value, previous) {
@@ -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>;
@@ -36,6 +36,7 @@ export type NativeCapletsToolsChangedListener = (tools: NativeCapletTool[]) => v
36
36
  export type NativeCapletsService = {
37
37
  listTools(): NativeCapletTool[];
38
38
  execute(capletId: string, request: unknown): Promise<unknown>;
39
+ codeModeService?(): NativeCapletsService;
39
40
  reload(): Promise<boolean>;
40
41
  onToolsChanged(listener: NativeCapletsToolsChangedListener): () => void;
41
42
  close(): Promise<void>;
@@ -3,5 +3,6 @@ export declare const nativeCodeModeToolId = "code_mode";
3
3
  export declare const nativeCodeModeToolName = "caplets__code_mode";
4
4
  export declare function nativeCapletToolName(capletId: string): string;
5
5
  export declare function nativeCapletsSystemGuidance(toolNames: string[]): string;
6
+ export declare function nativeCodeModePromptGuidance(): string[];
6
7
  export declare function nativeCapletPromptGuidance(toolName: string, caplet: CapletConfig): string[];
7
8
  export declare function nativeCapletToolDescription(toolName: string, caplet: CapletConfig): string;
package/dist/native.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as nativeCapletPromptGuidance, D as nativeCodeModeToolId, E as nativeCapletsSystemGuidance, O as nativeCodeModeToolName, T as nativeCapletToolName, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletToolDescription } from "./service-CSRCJfpA.js";
1
+ import { C as nativeCapletToolDescription, D as nativeCodeModeToolName, E as nativeCodeModeToolId, S as nativeCapletPromptGuidance, T as nativeCapletsSystemGuidance, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletToolName } from "./service-BCT_Ls_3.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 = {}) {
@@ -1,4 +1,4 @@
1
- export type CapletsRemoteEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_REMOTE_URL" | "CAPLETS_REMOTE_USER" | "CAPLETS_REMOTE_PASSWORD" | "CAPLETS_REMOTE_TOKEN" | "CAPLETS_REMOTE_WORKSPACE" | "CAPLETS_SERVER_URL", string>>;
1
+ export type CapletsRemoteEnv = Partial<Record<"CAPLETS_MODE" | "CAPLETS_REMOTE_URL" | "CAPLETS_REMOTE_USER" | "CAPLETS_REMOTE_PASSWORD" | "CAPLETS_REMOTE_TOKEN" | "CAPLETS_REMOTE_WORKSPACE", string>>;
2
2
  export type CapletsRemoteModeInput = {
3
3
  mode?: string;
4
4
  remoteUrl?: string;
@@ -13,6 +13,7 @@ export declare class CapletsMcpSession {
13
13
  private readonly resources;
14
14
  private readonly prompts;
15
15
  private codeModeTool;
16
+ private readonly codeModeSessions;
16
17
  private readonly unsubscribeReload;
17
18
  private closed;
18
19
  constructor(engine: CapletsEngine, options?: CapletsMcpSessionOptions);