@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
@@ -0,0 +1,82 @@
1
+ import type { ResolvedCapletsRemote } from "../remote/options";
2
+ import type { BindingTerminalReason, ProjectBindingState, ProjectBindingSyncState } from "./types";
3
+ import { type ProjectBindingWebSocketFactory } from "./transport";
4
+ export type ProjectBindingSessionEvent = {
5
+ type: "state";
6
+ state: ProjectBindingState;
7
+ message?: string | undefined;
8
+ requestId?: string;
9
+ } | {
10
+ type: "ready";
11
+ bindingId: string;
12
+ sessionId: string;
13
+ projectRoot: string;
14
+ projectFingerprint: string;
15
+ webSocketUrl: string;
16
+ requestId?: string | undefined;
17
+ } | {
18
+ type: "reconnecting";
19
+ bindingId: string;
20
+ sessionId: string;
21
+ attempt: number;
22
+ reason: string;
23
+ requestId?: string | undefined;
24
+ } | {
25
+ type: "heartbeat";
26
+ bindingId: string;
27
+ sessionId: string;
28
+ state: ProjectBindingState;
29
+ } | {
30
+ type: "ended";
31
+ bindingId?: string;
32
+ sessionId?: string;
33
+ reason: BindingTerminalReason;
34
+ };
35
+ export type ProjectBindingSocketServerMessage = {
36
+ type: "state";
37
+ state: ProjectBindingState;
38
+ syncState: ProjectBindingSyncState;
39
+ requestId?: string | undefined;
40
+ } | {
41
+ type: "ready";
42
+ bindingId: string;
43
+ sessionId: string;
44
+ syncState: ProjectBindingSyncState;
45
+ requestId?: string | undefined;
46
+ } | {
47
+ type: "blocked";
48
+ reason: BindingTerminalReason;
49
+ } | {
50
+ type: "ended";
51
+ reason: BindingTerminalReason;
52
+ };
53
+ export type ProjectBindingSocketClientMessage = {
54
+ type: "heartbeat";
55
+ bindingId: string;
56
+ sessionId: string;
57
+ state: ProjectBindingState;
58
+ syncState: ProjectBindingSyncState;
59
+ } | {
60
+ type: "end";
61
+ bindingId: string;
62
+ sessionId: string;
63
+ reason: BindingTerminalReason;
64
+ };
65
+ export type RunProjectBindingSessionInput = {
66
+ projectRoot: string;
67
+ remote: ResolvedCapletsRemote;
68
+ fetch?: typeof fetch | undefined;
69
+ webSocketFactory?: ProjectBindingWebSocketFactory | undefined;
70
+ signal?: AbortSignal | undefined;
71
+ heartbeatIntervalMs?: number | undefined;
72
+ onEvent?: ((event: ProjectBindingSessionEvent) => void) | undefined;
73
+ };
74
+ export declare function runProjectBindingSession(input: RunProjectBindingSessionInput): Promise<{
75
+ ok: true;
76
+ bindingId: string;
77
+ sessionId: string;
78
+ projectRoot: string;
79
+ projectFingerprint: string;
80
+ webSocketUrl: string;
81
+ ended: true;
82
+ }>;
@@ -0,0 +1,19 @@
1
+ export type ProjectSyncExclusionSource = "hard_denylist" | "gitignore" | "capletsignore";
2
+ export type ProjectSyncExclusionSummary = {
3
+ source: ProjectSyncExclusionSource;
4
+ pattern: string;
5
+ count: number;
6
+ };
7
+ export type ProjectSyncManifestFile = {
8
+ relativePath: string;
9
+ sizeBytes: number;
10
+ };
11
+ export type ProjectSyncManifest = {
12
+ projectRoot: string;
13
+ files: ProjectSyncManifestFile[];
14
+ totalBytes: number;
15
+ exclusionSummary: ProjectSyncExclusionSummary[];
16
+ };
17
+ export declare function buildProjectSyncManifest(input: {
18
+ projectRoot: string;
19
+ }): ProjectSyncManifest;
@@ -0,0 +1,27 @@
1
+ import type { ProjectBindingErrorCode } from "./errors";
2
+ import type { ProjectSyncManifestFile } from "./sync-filter";
3
+ export type ProjectSyncTier = "free" | "plus" | "pro" | "enterprise" | "self_hosted";
4
+ export type ProjectSyncLimits = {
5
+ maxSingleFileBytes: number;
6
+ maxProjectBytes: number;
7
+ };
8
+ export declare const DEFAULT_SYNC_LIMITS: Record<ProjectSyncTier, ProjectSyncLimits>;
9
+ export type ProjectSyncSizeResult = {
10
+ ok: true;
11
+ totalBytes: number;
12
+ maxSingleFileBytes: number;
13
+ maxProjectBytes: number;
14
+ } | {
15
+ ok: false;
16
+ code: ProjectBindingErrorCode;
17
+ totalBytes: number;
18
+ maxSingleFileBytes: number;
19
+ maxProjectBytes: number;
20
+ largestFileBytes?: number | undefined;
21
+ recoveryCommand: string;
22
+ };
23
+ export declare function enforceProjectSyncSizeLimits(input: {
24
+ tier: ProjectSyncTier;
25
+ files: ProjectSyncManifestFile[];
26
+ limits?: Partial<ProjectSyncLimits> | undefined;
27
+ }): ProjectSyncSizeResult;
@@ -0,0 +1,21 @@
1
+ export type ProjectBindingSocketEvent = {
2
+ data?: unknown;
3
+ code?: number | undefined;
4
+ reason?: string | undefined;
5
+ };
6
+ export type ProjectBindingWebSocket = {
7
+ readonly readyState?: number;
8
+ send(data: string): void;
9
+ close(code?: number, reason?: string): void;
10
+ addEventListener?: (type: "open" | "message" | "close" | "error", listener: (event: ProjectBindingSocketEvent) => void, options?: {
11
+ once?: boolean;
12
+ }) => void;
13
+ removeEventListener?: (type: "open" | "message" | "close" | "error", listener: (event: ProjectBindingSocketEvent) => void) => void;
14
+ onopen?: ((event: ProjectBindingSocketEvent) => void) | null;
15
+ onmessage?: ((event: ProjectBindingSocketEvent) => void) | null;
16
+ onclose?: ((event: ProjectBindingSocketEvent) => void) | null;
17
+ onerror?: ((event: ProjectBindingSocketEvent) => void) | null;
18
+ };
19
+ export type ProjectBindingWebSocketFactory = (url: string, protocols?: string | string[] | undefined) => ProjectBindingWebSocket;
20
+ export declare const PROJECT_BINDING_SOCKET_OPEN = 1;
21
+ export declare function defaultProjectBindingWebSocketFactory(url: string, protocols?: string | string[] | undefined): ProjectBindingWebSocket;
@@ -0,0 +1,31 @@
1
+ export type ProjectBindingState = "not_attached" | "attaching" | "syncing" | "ready" | "degraded" | "blocked" | "offline" | "cleaning_up" | "ended" | "expired";
2
+ export declare const PROJECT_BINDING_STATES: readonly ProjectBindingState[];
3
+ export declare const PROJECT_BINDING_SYNC_STATES: readonly ["not_started", "pending", "syncing", "idle", "failed"];
4
+ export type ProjectBindingSyncState = (typeof PROJECT_BINDING_SYNC_STATES)[number];
5
+ export type BindingTerminalReason = {
6
+ code: import("./errors").ProjectBindingErrorCode | "interrupted" | "completed";
7
+ message: string;
8
+ recoveryCommand?: string | undefined;
9
+ requestId?: string | undefined;
10
+ };
11
+ export type ProjectBindingLease = {
12
+ bindingId: string;
13
+ projectFingerprint: string;
14
+ state: ProjectBindingState;
15
+ active: boolean;
16
+ updatedAt: string;
17
+ expiresAt?: string;
18
+ diagnosticCode?: string;
19
+ };
20
+ export type ProjectBindingWorkspaceMetadata = {
21
+ projectFingerprint: string;
22
+ projectRoot: string;
23
+ createdAt: string;
24
+ lastActiveAt: string;
25
+ };
26
+ export type ProjectBindingSetupReceipt = {
27
+ capletId: string;
28
+ status: "succeeded" | "failed" | "skipped";
29
+ recordedAt?: string;
30
+ contentHash?: string;
31
+ };
@@ -0,0 +1,60 @@
1
+ import type { ProjectBindingLease, ProjectBindingSetupReceipt } from "./types";
2
+ type PathEnv = Partial<Record<"XDG_STATE_HOME" | "LOCALAPPDATA", string>>;
3
+ export type ProjectBindingWorkspaceRootOptions = {
4
+ env?: PathEnv;
5
+ platform?: NodeJS.Platform;
6
+ homedir?: string;
7
+ root?: string;
8
+ };
9
+ export type ProjectBindingWorkspacePaths = {
10
+ projectFingerprint: string;
11
+ root: string;
12
+ project: string;
13
+ metadata: string;
14
+ leases: string;
15
+ setup: string;
16
+ setupReceipts: string;
17
+ lease(bindingId: string): string;
18
+ };
19
+ export type ProjectBindingWorkspaceStoreOptions = ProjectBindingWorkspaceRootOptions & {
20
+ now?: () => Date;
21
+ staleLeaseTtlMs?: number;
22
+ inactiveWorkspaceTtlMs?: number;
23
+ softDiskCapBytes?: number;
24
+ workspaceSizeBytes?: (paths: ProjectBindingWorkspacePaths) => number;
25
+ };
26
+ export type EnsureProjectBindingWorkspaceInput = {
27
+ projectFingerprint: string;
28
+ projectRoot: string;
29
+ lastActiveAt?: string;
30
+ createdAt?: string;
31
+ };
32
+ export type ProjectBindingCleanupResult = {
33
+ expiredLeases: string[];
34
+ deletedWorkspaces: string[];
35
+ retainedWorkspaces: string[];
36
+ };
37
+ export declare function projectBindingWorkspaceRoot(options?: ProjectBindingWorkspaceRootOptions): string;
38
+ export declare function projectBindingWorkspacePaths(projectFingerprint: string, options?: ProjectBindingWorkspaceRootOptions): ProjectBindingWorkspacePaths;
39
+ export declare class ProjectBindingWorkspaceStore {
40
+ private readonly options;
41
+ private readonly root;
42
+ private readonly now;
43
+ private readonly staleLeaseTtlMs;
44
+ private readonly inactiveWorkspaceTtlMs;
45
+ private readonly softDiskCapBytes;
46
+ private readonly workspaceSizeBytes;
47
+ constructor(options?: ProjectBindingWorkspaceStoreOptions);
48
+ paths(projectFingerprint: string): ProjectBindingWorkspacePaths;
49
+ ensureWorkspace(input: EnsureProjectBindingWorkspaceInput): Promise<ProjectBindingWorkspacePaths>;
50
+ writeLease(lease: ProjectBindingLease): Promise<void>;
51
+ listLeases(projectFingerprint: string): Promise<ProjectBindingLease[]>;
52
+ writeSetupReceipts(projectFingerprint: string, receipts: ProjectBindingSetupReceipt[]): Promise<void>;
53
+ cleanup(): Promise<ProjectBindingCleanupResult>;
54
+ private readMetadata;
55
+ private workspacePaths;
56
+ private leasesFor;
57
+ private isStaleLease;
58
+ private isInactiveWorkspace;
59
+ }
60
+ export {};
@@ -0,0 +1,22 @@
1
+ //#region src/project-binding/types.ts
2
+ const PROJECT_BINDING_STATES = [
3
+ "not_attached",
4
+ "attaching",
5
+ "syncing",
6
+ "ready",
7
+ "degraded",
8
+ "blocked",
9
+ "offline",
10
+ "cleaning_up",
11
+ "ended",
12
+ "expired"
13
+ ];
14
+ const PROJECT_BINDING_SYNC_STATES = [
15
+ "not_started",
16
+ "pending",
17
+ "syncing",
18
+ "idle",
19
+ "failed"
20
+ ];
21
+ //#endregion
22
+ export { PROJECT_BINDING_STATES, PROJECT_BINDING_SYNC_STATES };
@@ -0,0 +1,14 @@
1
+ export declare const SECRET_KEY_PATTERN: RegExp;
2
+ export declare const SECRET_TEXT_PATTERNS: readonly [RegExp, RegExp, RegExp];
3
+ export type RedactionResult = {
4
+ text: string;
5
+ redacted: boolean;
6
+ };
7
+ export type RedactionOptions = {
8
+ patterns?: readonly RegExp[] | undefined;
9
+ additionalSecrets?: readonly string[] | undefined;
10
+ replacement?: string | undefined;
11
+ };
12
+ export declare function isSecretKey(key: string): boolean;
13
+ export declare function redactSecretText(value: string, options?: RedactionOptions): RedactionResult;
14
+ export declare function redactUnknownSecrets<T>(value: T, options?: RedactionOptions): T;
@@ -0,0 +1,30 @@
1
+ //#region src/redaction.ts
2
+ const SECRET_KEY_PATTERN = /(token|secret|authorization|auth|api[-_]?key|password|credential|clientsecret|client_secret|code|refresh)/iu;
3
+ const SECRET_TEXT_PATTERNS = [
4
+ /(Authorization:\s*Bearer\s+)[0-9A-Za-z._~+/=-]+/giu,
5
+ /(bearer\s+)[a-z0-9._~+/=-]+/giu,
6
+ /([?&](?:access_token|refresh_token|token|code)=)[^&\s]+/giu
7
+ ];
8
+ function isSecretKey(key) {
9
+ return SECRET_KEY_PATTERN.test(key);
10
+ }
11
+ function redactSecretText(value, options = {}) {
12
+ const replacement = options.replacement ?? "[REDACTED]";
13
+ let text = value;
14
+ for (const pattern of [...options.patterns ?? [], ...SECRET_TEXT_PATTERNS]) text = text.replace(pattern, (...args) => {
15
+ return `${typeof args[1] === "string" ? args[1] : ""}${replacement}`;
16
+ });
17
+ for (const secret of options.additionalSecrets?.filter(Boolean) ?? []) text = text.split(secret).join(replacement);
18
+ return {
19
+ text,
20
+ redacted: text !== value
21
+ };
22
+ }
23
+ function redactUnknownSecrets(value, options = {}) {
24
+ if (typeof value === "string") return redactSecretText(value, options).text;
25
+ if (Array.isArray(value)) return value.map((item) => redactUnknownSecrets(item, options));
26
+ if (!value || typeof value !== "object") return value;
27
+ return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, isSecretKey(key) ? "[REDACTED]" : redactUnknownSecrets(entry, options)]));
28
+ }
29
+ //#endregion
30
+ export { SECRET_KEY_PATTERN, SECRET_TEXT_PATTERNS, isSecretKey, redactSecretText, redactUnknownSecrets };
@@ -6,6 +6,8 @@ export type CapletServerSummary = {
6
6
  id: string;
7
7
  name: string;
8
8
  description: string;
9
+ useWhen?: string;
10
+ avoidWhen?: string;
9
11
  disabled?: boolean;
10
12
  status: ServerStatus;
11
13
  lastError?: SafeErrorSummary;
@@ -14,6 +16,8 @@ export type CapletServerDetail = {
14
16
  id: string;
15
17
  name: string;
16
18
  description: string;
19
+ useWhen?: string;
20
+ avoidWhen?: string;
17
21
  tags?: string[];
18
22
  backend: {
19
23
  type: "mcp";
@@ -0,0 +1,44 @@
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>>;
2
+ export type CapletsRemoteModeInput = {
3
+ mode?: string;
4
+ remoteUrl?: string;
5
+ };
6
+ export type CapletsRemoteMode = "local" | "remote" | "cloud";
7
+ export type CapletsRemoteInput = {
8
+ url?: string;
9
+ user?: string;
10
+ password?: string;
11
+ token?: string;
12
+ workspace?: string;
13
+ fetch?: typeof fetch;
14
+ };
15
+ export type CapletsRemoteAuth = {
16
+ type: "none";
17
+ user: string;
18
+ } | {
19
+ type: "basic";
20
+ user: string;
21
+ password: string;
22
+ } | {
23
+ type: "bearer";
24
+ token: string;
25
+ };
26
+ export type ResolvedCapletsRemote = {
27
+ baseUrl: URL;
28
+ mcpUrl: URL;
29
+ controlUrl: URL;
30
+ healthUrl: URL;
31
+ projectBindingWebSocketUrl: URL;
32
+ auth: CapletsRemoteAuth;
33
+ requestInit: RequestInit;
34
+ workspace?: string | undefined;
35
+ fetch?: typeof fetch;
36
+ };
37
+ export declare function resolveRemoteMode(input?: CapletsRemoteModeInput, env?: CapletsRemoteEnv): {
38
+ mode: CapletsRemoteMode;
39
+ };
40
+ export declare function resolveCapletsRemote(input?: CapletsRemoteInput, env?: CapletsRemoteEnv): ResolvedCapletsRemote;
41
+ export declare function resolveHostedCloudRemote(input?: CapletsRemoteInput, env?: CapletsRemoteEnv): ResolvedCapletsRemote;
42
+ export declare function hostedCloudWorkspaceFromRemoteUrl(value: string): string | undefined;
43
+ export declare function projectBindingWebSocketUrlForBase(baseUrl: URL): URL;
44
+ export declare function isCapletsCloudUrl(value: string): boolean;
@@ -0,0 +1,26 @@
1
+ import { type CloudAuthCredentials } from "../cloud-auth/store";
2
+ import { type ResolvedCapletsRemote } from "./options";
3
+ export type RemoteSelectionInput = {
4
+ mode?: string;
5
+ remoteUrl?: string;
6
+ user?: string;
7
+ password?: string;
8
+ token?: string;
9
+ workspace?: string;
10
+ fetch?: typeof fetch;
11
+ };
12
+ export type ResolvedRemoteSelection = {
13
+ kind: "self_hosted_remote";
14
+ remote: ResolvedCapletsRemote;
15
+ } | {
16
+ kind: "hosted_cloud";
17
+ remote: ResolvedCapletsRemote;
18
+ selectedWorkspace: string;
19
+ credentials: CloudAuthCredentials;
20
+ cloudPresence: {
21
+ url: URL;
22
+ accessToken: string;
23
+ workspaceId: string;
24
+ };
25
+ };
26
+ export declare function resolveRemoteSelection(input?: RemoteSelectionInput, env?: Record<string, string | undefined>): Promise<ResolvedRemoteSelection>;
@@ -1,5 +1,5 @@
1
1
  import type { CapletsErrorCode } from "../errors";
2
- export type RemoteCliCommand = "list" | "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" | "init" | "add" | "install" | "complete_cli" | "auth_login_start" | "auth_login_complete" | "auth_logout" | "auth_list";
2
+ export type RemoteCliCommand = "list" | "inspect" | "check" | "tools" | "search_tools" | "describe_tool" | "call_tool" | "resources" | "search_resources" | "resource_templates" | "read_resource" | "prompts" | "search_prompts" | "get_prompt" | "complete" | "init" | "add" | "install" | "complete_cli" | "auth_login_start" | "auth_login_complete" | "auth_logout" | "auth_list";
3
3
  export type RemoteCliRequest = {
4
4
  command: RemoteCliCommand;
5
5
  arguments: Record<string, unknown>;
@@ -0,0 +1,7 @@
1
+ import type { CapletConfig, RuntimeFeature } from "../config-runtime";
2
+ import type { RuntimeFeatureProvenance } from "./types";
3
+ export type RuntimeFeatureInference = {
4
+ features: RuntimeFeature[];
5
+ provenance: RuntimeFeatureProvenance[];
6
+ };
7
+ export declare function inferRuntimeFeatures(caplet: CapletConfig | Record<string, unknown>): RuntimeFeatureInference;
@@ -0,0 +1,4 @@
1
+ export * from "./types";
2
+ export * from "./features";
3
+ export * from "./resources";
4
+ export * from "./planner";
@@ -0,0 +1,5 @@
1
+ import type { CapletConfig } from "../config-runtime";
2
+ import type { CapletRuntimePlan, RuntimePlanOptions, RuntimeRouteKind } from "./types";
3
+ export declare function planCapletRuntimeRoutes(caplets: Array<CapletConfig | Record<string, unknown>>, options?: RuntimePlanOptions): CapletRuntimePlan[];
4
+ export declare function planCapletRuntimeRoute(caplet: CapletConfig | Record<string, unknown>, options?: RuntimePlanOptions): CapletRuntimePlan;
5
+ export declare function classifyCapletRuntimeRoute(caplet: Record<string, unknown>): RuntimeRouteKind;
@@ -0,0 +1,13 @@
1
+ import type { HostedRuntimeResourceClass, RuntimeResourcePolicy, RuntimeResourceResolution } from "./types";
2
+ export declare function resourceClassRank(value: string): number;
3
+ export declare function isRuntimeResourceClassAllowed(requested: string, maximum: string): boolean;
4
+ type ResourceInput = {
5
+ backend?: string | undefined;
6
+ features: string[];
7
+ explicitClass?: HostedRuntimeResourceClass | undefined;
8
+ setupRequired?: boolean | undefined;
9
+ policy?: RuntimeResourcePolicy | undefined;
10
+ };
11
+ export declare function resolveRuntimeResources(input: ResourceInput): RuntimeResourceResolution;
12
+ export declare function resolveRuntimeResources(caplet: Record<string, unknown>, features: string[], policy?: RuntimeResourcePolicy | undefined): RuntimeResourceResolution;
13
+ export {};
@@ -0,0 +1,82 @@
1
+ import type { CapletConfig, RuntimeFeature, RuntimeResourceClass } from "../config-runtime";
2
+ export type HostedRuntimeResourceClass = RuntimeResourceClass | "small" | "medium";
3
+ export type { RuntimeFeature, RuntimeResourceClass };
4
+ export type RuntimeRouteKind = "worker_safe" | "process" | "project_bound_process" | "local_only";
5
+ export type SetupTargetKind = "local_host" | "remote_host" | "hosted_sandbox";
6
+ export type HostedSetupState = "not_required" | "approval_required" | "approved" | "queued" | "running" | "verifying" | "ready" | "failed" | "expired";
7
+ export type HostedBackendCheckState = "not_run" | "queued" | "running" | "passed" | "failed" | "stale";
8
+ export type HostedSandboxState = "not_started" | "preparing" | "uploading_bundle" | "running_setup" | "starting_adapter" | "ready" | "busy" | "degraded" | "stopping" | "stopped" | "failed";
9
+ export declare const HIDDEN_REASON_CODES: readonly ["setup_required", "setup_running", "setup_failed", "verify_failed", "backend_auth_required", "backend_check_failed", "project_binding_required", "project_binding_syncing", "project_binding_blocked", "project_binding_stale", "provider_unavailable", "provider_capacity_exhausted", "provider_queue_timeout", "policy_denied", "billing_required", "subscription_past_due", "usage_limit_reached", "email_verification_required", "docker_required", "docker_denied", "browser_required", "browser_denied", "resource_class_denied", "local_only", "invalid_bundle", "unsupported_backend"];
10
+ export type HiddenReasonCode = (typeof HIDDEN_REASON_CODES)[number];
11
+ export type RuntimePlanDeployment = "hosted" | "self_hosted" | "local";
12
+ export type RuntimePlanOptions = {
13
+ deployment?: RuntimePlanDeployment | undefined;
14
+ resourcePolicy?: RuntimeResourcePolicy | undefined;
15
+ };
16
+ export type RuntimeFeatureProvenanceSource = "explicit" | "setup.commands" | "setup.verify" | "mcp.command" | "cli.command" | "cli.action";
17
+ export type RuntimeFeatureProvenance = {
18
+ feature: RuntimeFeature;
19
+ source: RuntimeFeatureProvenanceSource;
20
+ matched: string;
21
+ command?: string | undefined;
22
+ };
23
+ export type RuntimeResourcePolicy = {
24
+ maxClass?: HostedRuntimeResourceClass | undefined;
25
+ };
26
+ export type RuntimeResourceResolution = {
27
+ class: HostedRuntimeResourceClass;
28
+ cpu: number;
29
+ memoryMb: number;
30
+ diskMb: number;
31
+ cappedByPolicy?: HostedRuntimeResourceClass | undefined;
32
+ };
33
+ export type RuntimeRequirementsResolution = {
34
+ features: RuntimeFeature[];
35
+ featureProvenance: RuntimeFeatureProvenance[];
36
+ resources: RuntimeResourceResolution;
37
+ };
38
+ export type CapletRuntimePlan = {
39
+ id: string;
40
+ backend: CapletConfig["backend"] | string;
41
+ route: RuntimeRouteKind;
42
+ setupTarget?: SetupTargetKind | undefined;
43
+ setupRequired: boolean;
44
+ authRequired: boolean;
45
+ projectBindingRequired: boolean;
46
+ runtime: RuntimeRequirementsResolution;
47
+ caplet: CapletConfig | Record<string, unknown>;
48
+ };
49
+ export type HostedRoutePlan = {
50
+ workspaceId: string;
51
+ capletId: string;
52
+ contentHash: string;
53
+ bundleRevision: string;
54
+ route: RuntimeRouteKind;
55
+ backend: string;
56
+ runtimeFeatures: string[];
57
+ resourceClass: HostedRuntimeResourceClass;
58
+ setupState: HostedSetupState;
59
+ checkState: HostedBackendCheckState;
60
+ projectBindingRequired: boolean;
61
+ projectFingerprint?: string | undefined;
62
+ hiddenReasons: HiddenReasonCode[];
63
+ primaryHiddenReason?: HiddenReasonCode | undefined;
64
+ policyDecision: "allowed" | "denied" | "not_evaluated";
65
+ provenanceSource: "bundle_validation" | "install" | "runtime_refresh" | "call";
66
+ updatedAt: string;
67
+ };
68
+ export type HostedCallProvenance = {
69
+ requestId: string;
70
+ workspaceId: string;
71
+ capletId: string;
72
+ contentHash: string;
73
+ route: RuntimeRouteKind;
74
+ backend: string;
75
+ provider?: "daytona" | undefined;
76
+ sandboxId?: string | undefined;
77
+ snapshotId?: string | undefined;
78
+ runtimeFeatures: string[];
79
+ projectFingerprint?: string | undefined;
80
+ usageEventIds: string[];
81
+ auditEventId?: string | undefined;
82
+ };