@caplets/core 0.18.9 → 0.20.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 (132) hide show
  1. package/dist/attach/options.d.ts +10 -0
  2. package/dist/attach/server.d.ts +5 -0
  3. package/dist/caplet-files-bundle.d.ts +430 -0
  4. package/dist/caplet-files.d.ts +3 -266
  5. package/dist/caplet-source/bundle.d.ts +7 -0
  6. package/dist/caplet-source/filesystem.d.ts +7 -0
  7. package/dist/caplet-source/filesystem.js +2 -0
  8. package/dist/caplet-source/index.d.ts +4 -0
  9. package/dist/caplet-source/parse.d.ts +35 -0
  10. package/dist/caplet-source/types.d.ts +9 -0
  11. package/dist/caplet-source.js +7011 -0
  12. package/dist/cli/auth.d.ts +40 -2
  13. package/dist/cli/cloud-add.d.ts +8 -0
  14. package/dist/cli/code-mode.d.ts +16 -0
  15. package/dist/cli/commands.d.ts +8 -1
  16. package/dist/cli/doctor.d.ts +21 -0
  17. package/dist/cli/setup-caplet.d.ts +12 -0
  18. package/dist/cli/setup.d.ts +11 -0
  19. package/dist/cli-tools.d.ts +1 -1
  20. package/dist/cli.d.ts +8 -1
  21. package/dist/cloud/apply.d.ts +36 -0
  22. package/dist/cloud/client.d.ts +30 -0
  23. package/dist/cloud/presence.d.ts +29 -0
  24. package/dist/cloud/project-root.d.ts +2 -0
  25. package/dist/cloud/runtime-adapter.d.ts +23 -0
  26. package/dist/cloud/runtime-http.d.ts +6 -0
  27. package/dist/cloud/sync.d.ts +10 -0
  28. package/dist/cloud-auth/client.d.ts +57 -0
  29. package/dist/cloud-auth/errors.d.ts +11 -0
  30. package/dist/cloud-auth/open-url.d.ts +7 -0
  31. package/dist/cloud-auth/store.d.ts +35 -0
  32. package/dist/cloud-auth/types.d.ts +67 -0
  33. package/dist/code-mode/api.d.ts +32 -0
  34. package/dist/code-mode/declarations.d.ts +5 -0
  35. package/dist/code-mode/diagnostics.d.ts +8 -0
  36. package/dist/code-mode/index.d.ts +4 -0
  37. package/dist/code-mode/logs.d.ts +21 -0
  38. package/dist/code-mode/runner.d.ts +15 -0
  39. package/dist/code-mode/runtime-api.generated.d.ts +1 -0
  40. package/dist/code-mode/sandbox.d.ts +28 -0
  41. package/dist/code-mode/static-analysis.d.ts +2 -0
  42. package/dist/code-mode/tool.d.ts +11 -0
  43. package/dist/code-mode/types.d.ts +120 -0
  44. package/dist/code-mode.js +147855 -0
  45. package/dist/{completion-RqzHpHRY.js → completion-CbazRAiL.js} +20 -1
  46. package/dist/config/paths.d.ts +2 -0
  47. package/dist/config-runtime.d.ts +183 -0
  48. package/dist/config-runtime.js +421 -0
  49. package/dist/config.d.ts +76 -9
  50. package/dist/downstream.d.ts +20 -2
  51. package/dist/engine.d.ts +20 -0
  52. package/dist/exposure/direct-names.d.ts +9 -0
  53. package/dist/exposure/discovery.d.ts +75 -0
  54. package/dist/exposure/policy.d.ts +8 -0
  55. package/dist/filesystem-Kkg32TOJ.js +66 -0
  56. package/dist/generated-tool-input-schema.d.ts +89 -59
  57. package/dist/generated-tool-input-schema.js +172 -1
  58. package/dist/graphql.d.ts +1 -1
  59. package/dist/http-actions.d.ts +1 -1
  60. package/dist/index.d.ts +48 -0
  61. package/dist/index.js +4176 -501
  62. package/dist/native/options.d.ts +22 -3
  63. package/dist/native/remote.d.ts +2 -1
  64. package/dist/native/service.d.ts +13 -3
  65. package/dist/native/tools.d.ts +2 -0
  66. package/dist/native.d.ts +1 -1
  67. package/dist/native.js +3 -431
  68. package/dist/observed-output-shapes/extract.d.ts +5 -0
  69. package/dist/observed-output-shapes/file-store.d.ts +17 -0
  70. package/dist/observed-output-shapes/index.d.ts +7 -0
  71. package/dist/observed-output-shapes/key.d.ts +14 -0
  72. package/dist/observed-output-shapes/merge.d.ts +2 -0
  73. package/dist/observed-output-shapes/pure.d.ts +5 -0
  74. package/dist/observed-output-shapes/pure.js +241 -0
  75. package/dist/observed-output-shapes/schema.d.ts +1 -0
  76. package/dist/observed-output-shapes/types.d.ts +84 -0
  77. package/dist/observed-output-shapes/typescript.d.ts +7 -0
  78. package/dist/observed-output-shapes-uzAMQPhg.js +485 -0
  79. package/dist/observed-output-shapes.js +2 -0
  80. package/dist/openapi.d.ts +1 -1
  81. package/dist/project-binding/attach.d.ts +46 -0
  82. package/dist/project-binding/errors.d.ts +17 -0
  83. package/dist/project-binding/gitignore.d.ts +5 -0
  84. package/dist/project-binding/index.d.ts +2 -0
  85. package/dist/project-binding/mutagen.d.ts +65 -0
  86. package/dist/project-binding/routes.d.ts +9 -0
  87. package/dist/project-binding/session.d.ts +82 -0
  88. package/dist/project-binding/sync-filter.d.ts +19 -0
  89. package/dist/project-binding/sync-size.d.ts +27 -0
  90. package/dist/project-binding/transport.d.ts +21 -0
  91. package/dist/project-binding/types.d.ts +31 -0
  92. package/dist/project-binding/workspaces.d.ts +60 -0
  93. package/dist/project-binding.js +22 -0
  94. package/dist/redaction.d.ts +14 -0
  95. package/dist/redaction.js +30 -0
  96. package/dist/registry.d.ts +4 -0
  97. package/dist/remote/options.d.ts +44 -0
  98. package/dist/remote/selection.d.ts +26 -0
  99. package/dist/remote-control/types.d.ts +1 -1
  100. package/dist/runtime-plan/features.d.ts +7 -0
  101. package/dist/runtime-plan/index.d.ts +4 -0
  102. package/dist/runtime-plan/planner.d.ts +5 -0
  103. package/dist/runtime-plan/resources.d.ts +13 -0
  104. package/dist/runtime-plan/types.d.ts +82 -0
  105. package/dist/runtime-plan.js +281 -0
  106. package/dist/schemas-1HZ0kFpx.js +4270 -0
  107. package/dist/{generated-tool-input-schema--kVuUNc5.js → schemas-BZ6BBrh7.js} +1 -161
  108. package/dist/serve/daemon/config.d.ts +8 -0
  109. package/dist/serve/daemon/index.d.ts +16 -0
  110. package/dist/serve/daemon/paths.d.ts +3 -0
  111. package/dist/serve/daemon/platform-darwin.d.ts +2 -0
  112. package/dist/serve/daemon/platform-linux.d.ts +2 -0
  113. package/dist/serve/daemon/platform-windows.d.ts +2 -0
  114. package/dist/serve/daemon/platform.d.ts +9 -0
  115. package/dist/serve/daemon/process.d.ts +5 -0
  116. package/dist/serve/daemon/types.d.ts +86 -0
  117. package/dist/serve/http.d.ts +8 -0
  118. package/dist/serve/index.d.ts +5 -1
  119. package/dist/serve/native-session.d.ts +19 -0
  120. package/dist/serve/options.d.ts +1 -0
  121. package/dist/serve/session.d.ts +15 -3
  122. package/dist/server/options.d.ts +1 -1
  123. package/dist/{options-DnOUjft1.js → service-D0MwLNyb.js} +38003 -27618
  124. package/dist/setup/hash.d.ts +3 -0
  125. package/dist/setup/local-store.d.ts +34 -0
  126. package/dist/setup/runner.d.ts +40 -0
  127. package/dist/setup/types.d.ts +52 -0
  128. package/dist/stable-json.d.ts +3 -0
  129. package/dist/stable-json.js +26 -0
  130. package/dist/tools.d.ts +38 -12
  131. package/dist/validation-CdqbI2zN.js +174 -0
  132. package/package.json +48 -6
@@ -1,5 +1,5 @@
1
1
  import { type GenericAuthTarget } from "../auth";
2
- import { loadConfig, type CapletsConfig, type GraphQlEndpointConfig, type HttpApiConfig } from "../config";
2
+ import { loadConfig, type CapletsConfig } from "../config";
3
3
  type AuthTarget = ReturnType<typeof authTargets>[number];
4
4
  type AuthListFormat = "plain" | "markdown" | "json";
5
5
  export type AuthSource = "project" | "global" | "remote";
@@ -63,6 +63,44 @@ export declare function localAuthConfigForTarget(options: {
63
63
  }): CapletsConfig;
64
64
  export declare function formatAuthRows(rows: AuthStatusRow[], format: Exclude<AuthListFormat, "json">): string;
65
65
  export declare function findAuthTarget(serverId: string, config?: CapletsConfig): AuthTarget | undefined;
66
- declare function authTargets(config: ReturnType<typeof loadConfig>): (import("../config").CapletServerConfig | import("../config").OpenApiEndpointConfig | (GraphQlEndpointConfig & GenericAuthTarget) | (HttpApiConfig & GenericAuthTarget))[];
66
+ declare function authTargets(config: ReturnType<typeof loadConfig>): (import("../config").CapletServerConfig | import("../config").OpenApiEndpointConfig | (import("../config").AgentSelectionHintsConfig & {
67
+ server: string;
68
+ backend: "graphql";
69
+ name: string;
70
+ description: string;
71
+ exposure?: import("../config").CapletExposure | undefined;
72
+ tags?: string[] | undefined;
73
+ body?: string | undefined;
74
+ endpointUrl: string;
75
+ schemaPath?: string | undefined;
76
+ schemaUrl?: string | undefined;
77
+ introspection?: true | undefined;
78
+ operations?: Record<string, import("../config").GraphQlOperationConfig> | undefined;
79
+ auth: import("../config").OpenApiAuthConfig;
80
+ requestTimeoutMs: number;
81
+ operationCacheTtlMs: number;
82
+ selectionDepth: number;
83
+ disabled: boolean;
84
+ setup?: import("..").CapletSetupConfig | undefined;
85
+ projectBinding?: import("../config").ProjectBindingConfig | undefined;
86
+ runtime?: import("../config").RuntimeRequirementsConfig | undefined;
87
+ } & GenericAuthTarget) | (import("../config").AgentSelectionHintsConfig & {
88
+ server: string;
89
+ backend: "http";
90
+ name: string;
91
+ description: string;
92
+ exposure?: import("../config").CapletExposure | undefined;
93
+ tags?: string[] | undefined;
94
+ body?: string | undefined;
95
+ baseUrl: string;
96
+ auth: import("../config").OpenApiAuthConfig;
97
+ actions: Record<string, import("../config").HttpActionConfig>;
98
+ requestTimeoutMs: number;
99
+ maxResponseBytes: number;
100
+ disabled: boolean;
101
+ setup?: import("..").CapletSetupConfig | undefined;
102
+ projectBinding?: import("../config").ProjectBindingConfig | undefined;
103
+ runtime?: import("../config").RuntimeRequirementsConfig | undefined;
104
+ } & GenericAuthTarget))[];
67
105
  export declare function assertLoginTarget(target: AuthTarget | undefined, serverId: string): asserts target is AuthTarget;
68
106
  export {};
@@ -0,0 +1,8 @@
1
+ export type CloudCapletBundleFile = {
2
+ path: string;
3
+ content: string;
4
+ };
5
+ export type CloudCapletBundle = {
6
+ files: CloudCapletBundleFile[];
7
+ };
8
+ export declare function buildCloudCapletBundle(rootInput: string): CloudCapletBundle;
@@ -0,0 +1,16 @@
1
+ export type CodeModeCliOptions = {
2
+ env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
3
+ configPath?: string | undefined;
4
+ projectConfigPath?: string | undefined;
5
+ authDir?: string | undefined;
6
+ inlineCode?: string | undefined;
7
+ file?: string | undefined;
8
+ timeoutMs?: number | undefined;
9
+ json?: boolean | undefined;
10
+ readStdin?: (() => Promise<string>) | undefined;
11
+ writeOut: (value: string) => void;
12
+ setExitCode: (code: number) => void;
13
+ };
14
+ export declare function runCodeModeCli(options: CodeModeCliOptions): Promise<void>;
15
+ export declare function codeModeTypesCli(options: Pick<CodeModeCliOptions, "env" | "configPath" | "projectConfigPath" | "authDir" | "json" | "writeOut">): Promise<void>;
16
+ export declare function readCodeModeCliCode(options: Pick<CodeModeCliOptions, "inlineCode" | "file" | "readStdin">): Promise<string>;
@@ -3,9 +3,13 @@ export type CompletionShell = (typeof completionShells)[number];
3
3
  export declare const cliCommands: {
4
4
  readonly completion: "completion";
5
5
  readonly completeHidden: "__complete";
6
+ readonly codeMode: "code-mode";
6
7
  readonly serve: "serve";
8
+ readonly attach: "attach";
9
+ readonly cloud: "cloud";
7
10
  readonly init: "init";
8
11
  readonly setup: "setup";
12
+ readonly doctor: "doctor";
9
13
  readonly list: "list";
10
14
  readonly install: "install";
11
15
  readonly add: "add";
@@ -26,12 +30,15 @@ export declare const cliCommands: {
26
30
  readonly config: "config";
27
31
  readonly auth: "auth";
28
32
  };
29
- export declare const topLevelCommandNames: readonly ["serve", "init", "setup", "list", "install", "add", "inspect", "check-backend", "list-tools", "search-tools", "get-tool", "call-tool", "list-resources", "search-resources", "list-resource-templates", "read-resource", "list-prompts", "search-prompts", "get-prompt", "complete", "config", "auth", "completion"];
33
+ export declare const topLevelCommandNames: readonly ["serve", "code-mode", "attach", "cloud", "init", "setup", "doctor", "list", "install", "add", "inspect", "check-backend", "list-tools", "search-tools", "get-tool", "call-tool", "list-resources", "search-resources", "list-resource-templates", "read-resource", "list-prompts", "search-prompts", "get-prompt", "complete", "config", "auth", "completion"];
30
34
  export declare const cliSubcommands: {
31
35
  readonly add: readonly ["cli", "mcp", "openapi", "graphql", "http"];
32
36
  readonly auth: readonly ["login", "logout", "list"];
37
+ readonly cloud: readonly ["auth"];
38
+ readonly "code-mode": readonly ["types"];
33
39
  readonly completion: readonly ["bash", "zsh", "fish", "powershell", "cmd"];
34
40
  readonly config: readonly ["path", "paths"];
41
+ readonly serve: readonly ["start", "stop", "status", "restart", "enable", "disable"];
35
42
  readonly setup: readonly ["codex", "claude-code", "opencode", "pi", "mcp-client"];
36
43
  };
37
44
  export declare const capletIdCommands: Set<string>;
@@ -0,0 +1,21 @@
1
+ import { CloudAuthStore } from "../cloud-auth/store";
2
+ import type { MutagenProjectSyncDoctorData } from "../project-binding/mutagen";
3
+ export type DoctorOptions = {
4
+ env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
5
+ cwd?: string;
6
+ syncStatus?: MutagenProjectSyncDoctorData;
7
+ cloudAuthStore?: CloudAuthStore;
8
+ observedOutputShapeCacheDir?: string;
9
+ };
10
+ export type DoctorJsonReport = {
11
+ server: Record<string, unknown>;
12
+ remote: Record<string, unknown>;
13
+ projectBinding: Record<string, unknown>;
14
+ sync: Record<string, unknown>;
15
+ daemon: Record<string, unknown>;
16
+ cloudAuth: Record<string, unknown>;
17
+ exposure: Record<string, unknown>;
18
+ codeMode: Record<string, unknown>;
19
+ };
20
+ export declare function doctorJsonReport(options?: DoctorOptions): Promise<DoctorJsonReport>;
21
+ export declare function formatDoctorReport(options?: DoctorOptions): Promise<string>;
@@ -0,0 +1,12 @@
1
+ import { type SetupSpawn } from "../setup/runner";
2
+ import type { SetupTargetKind } from "../setup/types";
3
+ export type CapletSetupCliOptions = {
4
+ yes?: boolean;
5
+ target?: SetupTargetKind;
6
+ remote?: boolean;
7
+ configPath?: string | undefined;
8
+ projectConfigPath?: string | undefined;
9
+ baseDir?: string | undefined;
10
+ spawn?: SetupSpawn;
11
+ };
12
+ export declare function runCapletSetupCli(capletId: string, options?: CapletSetupCliOptions): Promise<string>;
@@ -1,19 +1,30 @@
1
+ import { type SetupTargetKind } from "../setup/types";
1
2
  export declare const setupIntegrationIds: readonly ["codex", "claude-code", "opencode", "pi", "mcp-client"];
2
3
  export type SetupIntegrationId = (typeof setupIntegrationIds)[number];
3
4
  export type SetupFormat = "plain" | "json";
5
+ export type SetupTargetOption = SetupTargetKind | "local" | "remote" | "cloud" | "hosted_worker";
4
6
  export type SetupCommandResult = {
5
7
  stdout: string;
6
8
  stderr: string;
7
9
  };
8
10
  export type SetupCommandRunner = (command: string, args: string[]) => Promise<SetupCommandResult>;
11
+ export type SetupPromptReader = (prompt: string) => Promise<string>;
9
12
  export type SetupOptions = {
10
13
  remote?: boolean;
14
+ remoteUrl?: string;
11
15
  serverUrl?: string;
12
16
  output?: string;
13
17
  dryRun?: boolean;
14
18
  env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
15
19
  format?: SetupFormat;
16
20
  runCommand?: SetupCommandRunner;
21
+ yes?: boolean;
22
+ target?: SetupTargetOption;
23
+ };
24
+ export type InteractiveSetupOptions = SetupOptions & {
25
+ readPrompt: SetupPromptReader;
17
26
  };
18
27
  export declare function formatSetupMenu(): string;
28
+ export declare function formatSetupPrompt(): string;
29
+ export declare function runInteractiveSetup(options: InteractiveSetupOptions): Promise<string>;
19
30
  export declare function runSetup(integration: string, options?: SetupOptions): Promise<string>;
@@ -1,6 +1,6 @@
1
1
  import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
2
2
  import type { CliToolsConfig } from "./config";
3
- import type { CompactTool } from "./downstream";
3
+ import { type CompactTool } from "./downstream";
4
4
  import type { ServerRegistry } from "./registry";
5
5
  export declare class CliToolsManager {
6
6
  private registry;
package/dist/cli.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { Command } from "commander";
2
2
  import { type SetupCommandRunner } from "./cli/setup";
3
- import { type ServeOptions } from "./serve";
3
+ import { type AttachServeOptions } from "./attach/options";
4
+ import type { ProjectBindingWebSocketFactory } from "./project-binding/transport";
5
+ import { type ServeDaemonOperationOptions, type ServeOptions } from "./serve";
4
6
  export { initConfig, starterConfig } from "./cli/init";
5
7
  export { installCaplets, normalizeGitRepo } from "./cli/install";
6
8
  export { addCliCaplet, addGraphqlCaplet, addHttpCaplet, addMcpCaplet, addOpenApiCaplet, } from "./cli/add";
@@ -9,11 +11,16 @@ type CliIO = {
9
11
  writeErr?: (value: string) => void;
10
12
  env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
11
13
  fetch?: typeof fetch;
14
+ signal?: AbortSignal;
15
+ projectBindingWebSocketFactory?: ProjectBindingWebSocketFactory;
12
16
  authDir?: string;
13
17
  version?: string;
14
18
  setExitCode?: (code: number) => void;
15
19
  serve?: (options: ServeOptions) => Promise<void>;
20
+ attachServe?: (options: AttachServeOptions) => Promise<void>;
21
+ daemon?: ServeDaemonOperationOptions;
16
22
  runSetupCommand?: SetupCommandRunner;
23
+ readStdin?: () => Promise<string>;
17
24
  };
18
25
  export declare function runCli(args: string[], io?: CliIO): Promise<void>;
19
26
  export declare function createProgram(io?: CliIO): Command;
@@ -0,0 +1,36 @@
1
+ export type ApplyReceiptInput = {
2
+ projectFingerprint: string;
3
+ filesChanged: string[];
4
+ skipped: string[];
5
+ policyWarnings: string[];
6
+ };
7
+ export type ApplyReceipt = ApplyReceiptInput & {
8
+ status: "applied";
9
+ };
10
+ export type ApplyConflict = {
11
+ path: string;
12
+ kind: "content" | "delete_modify" | "binary";
13
+ message?: string;
14
+ };
15
+ export type RemoteFileChange = {
16
+ path: string;
17
+ baseSha256?: string;
18
+ content: string;
19
+ };
20
+ export declare function createApplyReceipt(input: ApplyReceiptInput): ApplyReceipt;
21
+ export declare function classifyApplyResult(input: {
22
+ conflicts: ApplyConflict[];
23
+ }): {
24
+ status: "applied";
25
+ recoverable: false;
26
+ } | {
27
+ status: "apply_conflict";
28
+ recoverable: true;
29
+ conflicts: ApplyConflict[];
30
+ };
31
+ export declare function applyRemoteFileChanges(projectRoot: string, changes: RemoteFileChange[]): ApplyReceipt | {
32
+ status: "apply_conflict";
33
+ recoverable: true;
34
+ conflicts: ApplyConflict[];
35
+ };
36
+ export declare function sha256(value: string): string;
@@ -0,0 +1,30 @@
1
+ import type { ProjectSyncFile } from "./sync";
2
+ export type CapletsCloudClientOptions = {
3
+ baseUrl: URL;
4
+ accessToken: string;
5
+ fetch?: typeof fetch;
6
+ };
7
+ export type RegisterPresenceInput = {
8
+ workspaceId: string;
9
+ projectRoot: string;
10
+ projectFingerprint: string;
11
+ allowedCapletIds: string[];
12
+ projectFiles?: ProjectSyncFile[] | undefined;
13
+ fallbackConsent?: "allow" | "deny" | undefined;
14
+ };
15
+ export type RegisterPresenceResult = {
16
+ presenceId: string;
17
+ expiresAt: string;
18
+ };
19
+ export type HeartbeatPresenceResult = RegisterPresenceResult;
20
+ export declare class CapletsCloudClient {
21
+ private readonly options;
22
+ private readonly fetchImpl;
23
+ constructor(options: CapletsCloudClientOptions);
24
+ registerPresence(input: RegisterPresenceInput): Promise<RegisterPresenceResult>;
25
+ stopPresence(presenceId: string): Promise<void>;
26
+ heartbeatPresence(presenceId: string): Promise<HeartbeatPresenceResult>;
27
+ updatePresenceCaplets(presenceId: string, allowedCapletIds: string[]): Promise<void>;
28
+ private headers;
29
+ private endpoint;
30
+ }
@@ -0,0 +1,29 @@
1
+ import type { CapletsCloudClient, RegisterPresenceInput } from "./client";
2
+ type PresenceClient = Pick<CapletsCloudClient, "registerPresence"> & {
3
+ heartbeatPresence?: (presenceId: string) => Promise<unknown>;
4
+ stopPresence?: (presenceId: string) => Promise<void>;
5
+ updatePresenceCaplets?: (presenceId: string, allowedCapletIds: string[]) => Promise<void>;
6
+ };
7
+ export type ProjectBindingSessionManagerOptions = RegisterPresenceInput & {
8
+ client: PresenceClient;
9
+ heartbeatIntervalMs?: number;
10
+ setInterval?: typeof setInterval;
11
+ clearInterval?: typeof clearInterval;
12
+ onError?: (error: unknown) => void;
13
+ };
14
+ export declare class ProjectBindingSessionManager {
15
+ private readonly options;
16
+ private presenceId;
17
+ private heartbeatTimer;
18
+ private startPromise;
19
+ constructor(options: ProjectBindingSessionManagerOptions);
20
+ start(): Promise<void>;
21
+ private register;
22
+ close(): Promise<void>;
23
+ updateAllowedCapletIds(allowedCapletIds: string[]): Promise<void>;
24
+ private startHeartbeat;
25
+ private stopHeartbeat;
26
+ }
27
+ export type LocalPresenceManagerOptions = ProjectBindingSessionManagerOptions;
28
+ export declare const LocalPresenceManager: typeof ProjectBindingSessionManager;
29
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function findProjectRoot(start?: string): string;
2
+ export declare function fingerprintProjectRoot(root: string): string;
@@ -0,0 +1,23 @@
1
+ import { LocalSetupStore } from "../setup/local-store";
2
+ import type { SetupActor, SetupAttempt, SetupPlan } from "../setup/types";
3
+ export type CloudRuntimeAdapterOptions = {
4
+ configPath?: string;
5
+ projectConfigPath?: string;
6
+ authDir?: string;
7
+ runtimeId: string;
8
+ sandboxId?: string;
9
+ executionKind: "cloud" | "local-fallback";
10
+ setupStore?: LocalSetupStore;
11
+ };
12
+ export type CloudRuntimeAdapter = {
13
+ listTools(): Promise<unknown>;
14
+ callTool(name: string, args: unknown): Promise<unknown>;
15
+ checkBackend(capletId: string): Promise<unknown>;
16
+ setupPlan(capletId: string): Promise<SetupPlan>;
17
+ runSetup(capletId: string, input: {
18
+ approved: boolean;
19
+ actor: SetupActor;
20
+ }): Promise<SetupAttempt[]>;
21
+ close(): Promise<void>;
22
+ };
23
+ export declare function createCloudRuntimeAdapter(options: CloudRuntimeAdapterOptions): CloudRuntimeAdapter;
@@ -0,0 +1,6 @@
1
+ import { Hono } from "hono";
2
+ import { type CloudRuntimeAdapterOptions } from "./runtime-adapter";
3
+ export type RuntimeHttpOptions = CloudRuntimeAdapterOptions & {
4
+ token: string;
5
+ };
6
+ export declare function createRuntimeHttpApp(options: RuntimeHttpOptions): Hono;
@@ -0,0 +1,10 @@
1
+ export type ProjectSyncFile = {
2
+ path: string;
3
+ content: string;
4
+ };
5
+ export declare class ProjectSyncCoordinator {
6
+ private readonly queues;
7
+ runMutating<T>(projectId: string, task: () => Promise<T>): Promise<T>;
8
+ }
9
+ export declare function projectSyncManifest(projectRoot: string): string[];
10
+ export declare function projectSyncFiles(projectRoot: string): ProjectSyncFile[];
@@ -0,0 +1,57 @@
1
+ import type { CloudAuthLoginPollResult, CloudAuthLoginStart, CloudAuthTokenResponse, CloudAuthWorkspace } from "./types";
2
+ export type CloudAuthClientOptions = {
3
+ cloudUrl: string;
4
+ fetch?: typeof fetch;
5
+ };
6
+ export type StartLoginInput = {
7
+ requestedWorkspace?: string | undefined;
8
+ deviceName?: string | undefined;
9
+ scope?: string[] | undefined;
10
+ };
11
+ export type ExchangeTokenInput = {
12
+ loginId: string;
13
+ oneTimeCode: string;
14
+ };
15
+ export type RefreshTokenInput = {
16
+ refreshToken: string;
17
+ };
18
+ export type CloudAddCapletsInput = {
19
+ accessToken: string;
20
+ workspace: string;
21
+ bundle: {
22
+ files: Array<{
23
+ path: string;
24
+ content: string;
25
+ }>;
26
+ };
27
+ };
28
+ export type CloudAddCapletsResult = {
29
+ caplet?: unknown;
30
+ caplets: unknown[];
31
+ };
32
+ export type CloudAuthClientCredentials = Required<Pick<CloudAuthTokenResponse, "workspaceId" | "accessToken" | "expiresAt" | "tokenType" | "credentialFamilyId">> & Pick<CloudAuthTokenResponse, "workspaceSlug" | "refreshToken" | "deviceName" | "requestId"> & {
33
+ cloudUrl: string;
34
+ scope: string[];
35
+ redacted: Record<string, unknown>;
36
+ };
37
+ export declare class CloudAuthClient {
38
+ private readonly cloudUrl;
39
+ private readonly fetchImpl;
40
+ constructor(options: CloudAuthClientOptions);
41
+ startLogin(input?: StartLoginInput): Promise<CloudAuthLoginStart>;
42
+ pollLogin(loginId: string): Promise<CloudAuthLoginPollResult>;
43
+ exchangeToken(input: ExchangeTokenInput): Promise<CloudAuthClientCredentials>;
44
+ refresh(input: RefreshTokenInput): Promise<CloudAuthClientCredentials>;
45
+ logout(refreshToken: string): Promise<void>;
46
+ workspaces(accessToken: string): Promise<{
47
+ workspaces: CloudAuthWorkspace[];
48
+ }>;
49
+ switchWorkspace(input: {
50
+ accessToken: string;
51
+ workspace: string;
52
+ refreshToken?: string | undefined;
53
+ deviceName?: string | undefined;
54
+ }): Promise<CloudAuthClientCredentials>;
55
+ addCaplets(input: CloudAddCapletsInput): Promise<CloudAddCapletsResult>;
56
+ private requestJson;
57
+ }
@@ -0,0 +1,11 @@
1
+ import { CapletsError } from "../errors";
2
+ export type CloudAuthErrorCode = "cloud_auth_required" | "cloud_auth_expired" | "cloud_auth_revoked" | "workspace_selection_required" | "workspace_switch_required" | "workspace_forbidden" | "endpoint_unavailable";
3
+ export type CloudAuthRecovery = {
4
+ code: CloudAuthErrorCode;
5
+ message: string;
6
+ recoveryCommand: string;
7
+ requestId?: string | undefined;
8
+ };
9
+ export declare function redactCloudAuthSecrets(value: unknown): unknown;
10
+ export declare function cloudAuthRecovery(code: CloudAuthErrorCode, detail?: string): CloudAuthRecovery;
11
+ export declare function cloudAuthError(code: CloudAuthErrorCode, detail?: string): CapletsError;
@@ -0,0 +1,7 @@
1
+ export type OpenUrlResult = {
2
+ opened: boolean;
3
+ command?: string | undefined;
4
+ };
5
+ export declare function openBrowserUrl(url: string, options?: {
6
+ opener?: (url: string) => Promise<OpenUrlResult> | OpenUrlResult;
7
+ }): Promise<OpenUrlResult>;
@@ -0,0 +1,35 @@
1
+ import type { RedactedCloudAuthStatus } from "./types";
2
+ type CloudAuthPathEnv = Partial<Record<"CAPLETS_CLOUD_AUTH_PATH" | "XDG_CONFIG_HOME" | "APPDATA", string>>;
3
+ export type CloudAuthCredentials = {
4
+ version?: 1 | 2 | undefined;
5
+ cloudUrl: string;
6
+ workspaceId: string;
7
+ workspaceSlug?: string | undefined;
8
+ accessToken: string;
9
+ refreshToken: string;
10
+ expiresAt: string;
11
+ scope?: string[] | undefined;
12
+ tokenType?: string | undefined;
13
+ credentialFamilyId?: string | undefined;
14
+ deviceName?: string | undefined;
15
+ createdAt?: string | undefined;
16
+ lastRefreshAt?: string | undefined;
17
+ selectedWorkspaceSwitchedAt?: string | undefined;
18
+ };
19
+ export type CloudAuthStoreOptions = {
20
+ path?: string;
21
+ env?: CloudAuthPathEnv;
22
+ home?: string;
23
+ platform?: NodeJS.Platform;
24
+ };
25
+ export declare class CloudAuthStore {
26
+ readonly path: string;
27
+ constructor(options?: CloudAuthStoreOptions);
28
+ load(): Promise<CloudAuthCredentials | undefined>;
29
+ save(credentials: CloudAuthCredentials): Promise<void>;
30
+ clear(): Promise<void>;
31
+ }
32
+ export declare function migrateCredentials(value: unknown): CloudAuthCredentials;
33
+ export declare function redactedCloudAuthStatus(credentials: CloudAuthCredentials | undefined, now?: Date): RedactedCloudAuthStatus;
34
+ export declare function cloudAuthPath(options?: CloudAuthStoreOptions): string;
35
+ export {};
@@ -0,0 +1,67 @@
1
+ export declare const CLOUD_AUTH_STATES: readonly ["unauthenticated", "login_pending", "workspace_selection_required", "authenticated", "refreshable", "switch_required", "expired", "revoked"];
2
+ export type CloudAuthState = (typeof CLOUD_AUTH_STATES)[number];
3
+ export declare const HOSTED_CLOUD_AUTH_SCOPES: readonly ["project_binding:read", "project_binding:write", "mcp:tools"];
4
+ export type CloudAuthScope = (typeof HOSTED_CLOUD_AUTH_SCOPES)[number] | string;
5
+ export type CloudAuthWorkspace = {
6
+ workspaceId: string;
7
+ slug?: string | undefined;
8
+ displayName?: string | undefined;
9
+ name?: string | undefined;
10
+ role?: string | undefined;
11
+ selected?: boolean | undefined;
12
+ };
13
+ export type CloudAuthLoginStart = {
14
+ loginId: string;
15
+ loginUrl: string;
16
+ userCode: string;
17
+ expiresAt: string;
18
+ requestId?: string | undefined;
19
+ };
20
+ export type CloudAuthLoginPollResult = {
21
+ status: "pending";
22
+ expiresAt?: string | undefined;
23
+ requestId?: string | undefined;
24
+ } | {
25
+ status: "workspace_selection_required";
26
+ workspaces: CloudAuthWorkspace[];
27
+ expiresAt?: string | undefined;
28
+ requestId?: string | undefined;
29
+ } | {
30
+ status: "completed";
31
+ selectedWorkspace?: Pick<CloudAuthWorkspace, "workspaceId" | "slug"> | undefined;
32
+ oneTimeCode: string;
33
+ requestId?: string | undefined;
34
+ } | {
35
+ status: "expired" | "denied" | "consumed";
36
+ message?: string | undefined;
37
+ requestId?: string | undefined;
38
+ };
39
+ export type CloudAuthTokenResponse = {
40
+ status?: "authenticated" | undefined;
41
+ cloudUrl?: string | undefined;
42
+ workspaceId: string;
43
+ workspaceSlug?: string | undefined;
44
+ accessToken: string;
45
+ refreshToken?: string | undefined;
46
+ expiresAt: string;
47
+ scope?: CloudAuthScope[] | string | undefined;
48
+ tokenType?: "Bearer" | string | undefined;
49
+ credentialFamilyId?: string | undefined;
50
+ deviceName?: string | undefined;
51
+ requestId?: string | undefined;
52
+ };
53
+ export type RedactedCloudAuthStatus = {
54
+ authenticated: boolean;
55
+ status: CloudAuthState;
56
+ cloudUrl?: string | undefined;
57
+ workspaceId?: string | undefined;
58
+ workspaceSlug?: string | undefined;
59
+ expiresAt?: string | undefined;
60
+ scope?: CloudAuthScope[] | undefined;
61
+ tokenType?: string | undefined;
62
+ credentialFamilyId?: string | undefined;
63
+ deviceName?: string | undefined;
64
+ createdAt?: string | undefined;
65
+ lastRefreshAt?: string | undefined;
66
+ selectedWorkspaceSwitchedAt?: string | undefined;
67
+ };
@@ -0,0 +1,32 @@
1
+ import type { NativeCapletsService } from "../native/service";
2
+ import type { CapletsResult, CodeModeCallableCaplet, Page, PageInput, ReadLogsInput, ReadLogsResult, ToolCallResult } from "./types";
3
+ export type CodeModeCapletHandle = {
4
+ readonly id: string;
5
+ inspect(): Promise<unknown>;
6
+ check(): Promise<CapletsResult<unknown>>;
7
+ tools(input?: PageInput): Promise<Page<unknown>>;
8
+ searchTools(query: string, input?: PageInput): Promise<Page<unknown>>;
9
+ describeTool(name: string): Promise<CapletsResult<unknown>>;
10
+ callTool(name: string, args?: unknown): Promise<ToolCallResult>;
11
+ resources(input?: PageInput): Promise<Page<unknown>>;
12
+ searchResources(query: string, input?: PageInput): Promise<Page<unknown>>;
13
+ resourceTemplates(input?: PageInput): Promise<Page<unknown>>;
14
+ readResource(uri: string): Promise<CapletsResult<unknown>>;
15
+ prompts(input?: PageInput): Promise<Page<unknown>>;
16
+ searchPrompts(query: string, input?: PageInput): Promise<Page<unknown>>;
17
+ getPrompt(name: string, args?: unknown): Promise<CapletsResult<unknown>>;
18
+ complete(input: unknown): Promise<CapletsResult<unknown>>;
19
+ };
20
+ export type CodeModeDebugApi = {
21
+ readLogs(input: ReadLogsInput): Promise<ReadLogsResult>;
22
+ };
23
+ export type CodeModeCapletsApi = {
24
+ [capletId: string]: CodeModeCapletHandle | CodeModeDebugApi | (CodeModeCapletHandle & CodeModeDebugApi);
25
+ debug: CodeModeDebugApi | (CodeModeCapletHandle & CodeModeDebugApi);
26
+ };
27
+ export type CreateCodeModeCapletsApiInput = {
28
+ service: NativeCapletsService;
29
+ readLogs?: (input: ReadLogsInput) => Promise<ReadLogsResult>;
30
+ };
31
+ export declare function listCodeModeCallableCaplets(service: NativeCapletsService): CodeModeCallableCaplet[];
32
+ export declare function createCodeModeCapletsApi(input: CreateCodeModeCapletsApiInput): CodeModeCapletsApi;
@@ -0,0 +1,5 @@
1
+ import type { CodeModeDeclarationInput } from "./types";
2
+ export declare function generateCodeModeDeclarations(input: CodeModeDeclarationInput): string;
3
+ export declare function generateCodeModeRunToolDescription(declaration: string): string;
4
+ export declare function minifyCodeModeDeclarationText(value: string): string;
5
+ export declare function codeModeDeclarationHash(declaration: string): string;
@@ -0,0 +1,8 @@
1
+ import type { CodeModeDiagnostic } from "./types";
2
+ export type DiagnoseCodeModeTypeScriptInput = {
3
+ code: string;
4
+ declaration: string;
5
+ maxDiagnostics?: number;
6
+ timeoutMs?: number;
7
+ };
8
+ export declare function diagnoseCodeModeTypeScript(input: DiagnoseCodeModeTypeScriptInput): CodeModeDiagnostic[];
@@ -0,0 +1,4 @@
1
+ export { codeModeDeclarationHash, generateCodeModeDeclarations, generateCodeModeRunToolDescription, minifyCodeModeDeclarationText, } from "./declarations";
2
+ export { codeModeRunInputJsonSchema, codeModeRunInputSchema, codeModeRunParamsSchema, isCodeModeRunRequest, } from "./tool";
3
+ export { hasDirectFetchCall, hasExecutableImport } from "./static-analysis";
4
+ export type { CodeModeCallableCaplet, CodeModeDeclarationInput, CodeModeDiagnostic, CodeModeLogEntry, CodeModeLogs, CodeModeRunEnvelope, CodeModeRunError, CodeModeRunMeta, CodeModeTypesJson, JsonPrimitive, JsonValue, ReadLogsInput, ReadLogsResult, ToolCallError, ToolCallMeta, ToolCallResult, } from "./types";
@@ -0,0 +1,21 @@
1
+ import type { CodeModeLogEntry, ReadLogsInput, ReadLogsResult } from "./types";
2
+ export type CodeModeLogStoreOptions = {
3
+ stateDir?: string;
4
+ now?: () => Date;
5
+ logRefTtlMs?: number;
6
+ };
7
+ export type StoreCodeModeLogsResult = {
8
+ logRef: string;
9
+ expiresAt: string;
10
+ };
11
+ export declare class CodeModeLogStore {
12
+ private readonly stateDir;
13
+ private readonly now;
14
+ private readonly logRefTtlMs;
15
+ constructor(options?: CodeModeLogStoreOptions);
16
+ store(entries: CodeModeLogEntry[]): Promise<StoreCodeModeLogsResult>;
17
+ read(input: ReadLogsInput): Promise<ReadLogsResult>;
18
+ private logsDir;
19
+ private logPath;
20
+ }
21
+ export declare function redactCodeModeLogText(text: string): string;
@@ -0,0 +1,15 @@
1
+ import type { NativeCapletsService } from "../native/service";
2
+ import { CodeModeLogStore } from "./logs";
3
+ import { type CodeModeSandbox } from "./sandbox";
4
+ import type { CodeModeRunEnvelope } from "./types";
5
+ export type RunCodeModeInput = {
6
+ code: string;
7
+ service: NativeCapletsService;
8
+ timeoutMs?: number;
9
+ maxTimeoutMs?: number;
10
+ runtimeScope?: string;
11
+ logStore?: CodeModeLogStore;
12
+ sandbox?: CodeModeSandbox;
13
+ returnedLogBytes?: number;
14
+ };
15
+ export declare function runCodeMode(input: RunCodeModeInput): Promise<CodeModeRunEnvelope>;