@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
package/dist/config.d.ts CHANGED
@@ -35,11 +35,41 @@ export type RemoteAuthConfig = {
35
35
  scopes?: string[] | undefined;
36
36
  redirectUri?: string | undefined;
37
37
  };
38
- export type CapletServerConfig = {
38
+ export type CapletSetupCommandConfig = {
39
+ label: string;
40
+ command: string;
41
+ args?: string[] | undefined;
42
+ env?: Record<string, string> | undefined;
43
+ cwd?: string | undefined;
44
+ timeoutMs?: number | undefined;
45
+ maxOutputBytes?: number | undefined;
46
+ };
47
+ export type CapletSetupConfig = {
48
+ commands?: CapletSetupCommandConfig[] | undefined;
49
+ verify?: CapletSetupCommandConfig[] | undefined;
50
+ };
51
+ export type ProjectBindingConfig = {
52
+ required: true;
53
+ };
54
+ export type RuntimeFeature = "docker" | "browser";
55
+ export type RuntimeResourceClass = "standard" | "large" | "heavy";
56
+ export type RuntimeRequirementsConfig = {
57
+ features?: RuntimeFeature[] | undefined;
58
+ resources?: {
59
+ class?: RuntimeResourceClass | undefined;
60
+ } | undefined;
61
+ };
62
+ export type AgentSelectionHintsConfig = {
63
+ useWhen?: string | undefined;
64
+ avoidWhen?: string | undefined;
65
+ };
66
+ export type CapletExposure = "direct" | "progressive" | "code_mode" | "direct_and_code_mode" | "progressive_and_code_mode";
67
+ export type CapletServerConfig = AgentSelectionHintsConfig & {
39
68
  server: string;
40
69
  backend: "mcp";
41
70
  name: string;
42
71
  description: string;
72
+ exposure?: CapletExposure | undefined;
43
73
  tags?: string[] | undefined;
44
74
  body?: string | undefined;
45
75
  transport: "stdio" | "http" | "sse";
@@ -53,6 +83,9 @@ export type CapletServerConfig = {
53
83
  callTimeoutMs: number;
54
84
  toolCacheTtlMs: number;
55
85
  disabled: boolean;
86
+ setup?: CapletSetupConfig | undefined;
87
+ projectBinding?: ProjectBindingConfig | undefined;
88
+ runtime?: RuntimeRequirementsConfig | undefined;
56
89
  };
57
90
  export type OpenApiAuthConfig = {
58
91
  type: "none";
@@ -65,11 +98,12 @@ export type OpenApiAuthConfig = {
65
98
  } | Extract<RemoteAuthConfig, {
66
99
  type: "oauth2" | "oidc";
67
100
  }>;
68
- export type OpenApiEndpointConfig = {
101
+ export type OpenApiEndpointConfig = AgentSelectionHintsConfig & {
69
102
  server: string;
70
103
  backend: "openapi";
71
104
  name: string;
72
105
  description: string;
106
+ exposure?: CapletExposure | undefined;
73
107
  tags?: string[] | undefined;
74
108
  body?: string | undefined;
75
109
  specPath?: string | undefined;
@@ -79,18 +113,22 @@ export type OpenApiEndpointConfig = {
79
113
  requestTimeoutMs: number;
80
114
  operationCacheTtlMs: number;
81
115
  disabled: boolean;
116
+ setup?: CapletSetupConfig | undefined;
117
+ projectBinding?: ProjectBindingConfig | undefined;
118
+ runtime?: RuntimeRequirementsConfig | undefined;
82
119
  };
83
- export type GraphQlOperationConfig = {
120
+ export type GraphQlOperationConfig = AgentSelectionHintsConfig & {
84
121
  document?: string | undefined;
85
122
  documentPath?: string | undefined;
86
123
  operationName?: string | undefined;
87
124
  description?: string | undefined;
88
125
  };
89
- export type GraphQlEndpointConfig = {
126
+ export type GraphQlEndpointConfig = AgentSelectionHintsConfig & {
90
127
  server: string;
91
128
  backend: "graphql";
92
129
  name: string;
93
130
  description: string;
131
+ exposure?: CapletExposure | undefined;
94
132
  tags?: string[] | undefined;
95
133
  body?: string | undefined;
96
134
  endpointUrl: string;
@@ -103,8 +141,11 @@ export type GraphQlEndpointConfig = {
103
141
  operationCacheTtlMs: number;
104
142
  selectionDepth: number;
105
143
  disabled: boolean;
144
+ setup?: CapletSetupConfig | undefined;
145
+ projectBinding?: ProjectBindingConfig | undefined;
146
+ runtime?: RuntimeRequirementsConfig | undefined;
106
147
  };
107
- export type HttpActionConfig = {
148
+ export type HttpActionConfig = AgentSelectionHintsConfig & {
108
149
  method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
109
150
  path: string;
110
151
  description?: string | undefined;
@@ -114,11 +155,12 @@ export type HttpActionConfig = {
114
155
  headers?: Record<string, string | number | boolean> | undefined;
115
156
  jsonBody?: unknown;
116
157
  };
117
- export type HttpApiConfig = {
158
+ export type HttpApiConfig = AgentSelectionHintsConfig & {
118
159
  server: string;
119
160
  backend: "http";
120
161
  name: string;
121
162
  description: string;
163
+ exposure?: CapletExposure | undefined;
122
164
  tags?: string[] | undefined;
123
165
  body?: string | undefined;
124
166
  baseUrl: string;
@@ -127,11 +169,14 @@ export type HttpApiConfig = {
127
169
  requestTimeoutMs: number;
128
170
  maxResponseBytes: number;
129
171
  disabled: boolean;
172
+ setup?: CapletSetupConfig | undefined;
173
+ projectBinding?: ProjectBindingConfig | undefined;
174
+ runtime?: RuntimeRequirementsConfig | undefined;
130
175
  };
131
176
  export type CliToolOutputConfig = {
132
177
  type: "text" | "json";
133
178
  };
134
- export type CliToolActionConfig = {
179
+ export type CliToolActionConfig = AgentSelectionHintsConfig & {
135
180
  description?: string | undefined;
136
181
  inputSchema?: Record<string, unknown> | undefined;
137
182
  outputSchema?: Record<string, unknown> | undefined;
@@ -149,11 +194,12 @@ export type CliToolActionConfig = {
149
194
  openWorldHint?: boolean | undefined;
150
195
  } | undefined;
151
196
  };
152
- export type CliToolsConfig = {
197
+ export type CliToolsConfig = AgentSelectionHintsConfig & {
153
198
  server: string;
154
199
  backend: "cli";
155
200
  name: string;
156
201
  description: string;
202
+ exposure?: CapletExposure | undefined;
157
203
  tags?: string[] | undefined;
158
204
  body?: string | undefined;
159
205
  actions: Record<string, CliToolActionConfig>;
@@ -162,12 +208,16 @@ export type CliToolsConfig = {
162
208
  timeoutMs: number;
163
209
  maxOutputBytes: number;
164
210
  disabled: boolean;
211
+ setup?: CapletSetupConfig | undefined;
212
+ projectBinding?: ProjectBindingConfig | undefined;
213
+ runtime?: RuntimeRequirementsConfig | undefined;
165
214
  };
166
- export type CapletSetConfig = {
215
+ export type CapletSetConfig = AgentSelectionHintsConfig & {
167
216
  server: string;
168
217
  backend: "caplets";
169
218
  name: string;
170
219
  description: string;
220
+ exposure?: CapletExposure | undefined;
171
221
  tags?: string[] | undefined;
172
222
  body?: string | undefined;
173
223
  configPath?: string | undefined;
@@ -176,11 +226,17 @@ export type CapletSetConfig = {
176
226
  maxSearchLimit: number;
177
227
  toolCacheTtlMs: number;
178
228
  disabled: boolean;
229
+ setup?: CapletSetupConfig | undefined;
230
+ projectBinding?: ProjectBindingConfig | undefined;
231
+ runtime?: RuntimeRequirementsConfig | undefined;
179
232
  };
180
233
  export type CapletConfig = CapletServerConfig | OpenApiEndpointConfig | GraphQlEndpointConfig | HttpApiConfig | CliToolsConfig | CapletSetConfig;
181
234
  export type CapletsOptions = {
182
235
  defaultSearchLimit: number;
183
236
  maxSearchLimit: number;
237
+ exposure: CapletExposure;
238
+ exposureDiscoveryTimeoutMs: number;
239
+ exposureDiscoveryConcurrency: number;
184
240
  completion: CompletionConfig;
185
241
  };
186
242
  export type CompletionConfig = {
@@ -228,6 +284,17 @@ export declare const configFileSchema: z.ZodObject<{
228
284
  cacheTtlMs: z.ZodDefault<z.ZodNumber>;
229
285
  negativeCacheTtlMs: z.ZodDefault<z.ZodNumber>;
230
286
  }, z.core.$strict>>;
287
+ options: z.ZodDefault<z.ZodObject<{
288
+ exposure: z.ZodDefault<z.ZodEnum<{
289
+ direct: "direct";
290
+ progressive: "progressive";
291
+ code_mode: "code_mode";
292
+ direct_and_code_mode: "direct_and_code_mode";
293
+ progressive_and_code_mode: "progressive_and_code_mode";
294
+ }>>;
295
+ exposureDiscoveryTimeoutMs: z.ZodDefault<z.ZodNumber>;
296
+ exposureDiscoveryConcurrency: z.ZodDefault<z.ZodNumber>;
297
+ }, z.core.$strict>>;
231
298
  mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
232
299
  openapiEndpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
233
300
  graphqlEndpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
@@ -2,11 +2,23 @@ import { type Prompt, type Resource, type ResourceTemplate as McpResourceTemplat
2
2
  import type { CapletServerConfig } from "./config";
3
3
  import type { ServerRegistry } from "./registry";
4
4
  export type CompactTool = {
5
- id: string;
6
- tool: string;
5
+ name: string;
7
6
  description?: string;
7
+ useWhen?: string;
8
+ avoidWhen?: string;
8
9
  hasInputSchema: boolean;
9
10
  hasOutputSchema: boolean;
11
+ supportsFields: boolean;
12
+ requiredArgs?: string[];
13
+ acceptedArgs?: string[];
14
+ argsTemplate?: Record<string, unknown>;
15
+ callTemplate?: {
16
+ operation: "call_tool";
17
+ name: string;
18
+ args: Record<string, unknown>;
19
+ };
20
+ readOnlyHint?: boolean;
21
+ destructiveHint?: boolean;
10
22
  };
11
23
  export type CompactResource = {
12
24
  id: string;
@@ -202,8 +214,14 @@ export declare class DownstreamManager {
202
214
  private isCacheFresh;
203
215
  private refreshTools;
204
216
  private connect;
217
+ private connectionStartError;
218
+ private markConnectionStartUnavailable;
219
+ private startConnection;
205
220
  private createTransport;
206
221
  private oauthProvider;
207
222
  private currentServer;
208
223
  private currentServerFingerprint;
209
224
  }
225
+ export declare function compactToolSafetyHints(tool: Tool): Pick<CompactTool, "readOnlyHint" | "destructiveHint">;
226
+ export declare function compactToolSchemaHints(tool: Tool): Pick<CompactTool, "requiredArgs" | "acceptedArgs" | "argsTemplate" | "callTemplate">;
227
+ export declare function compactToolSelectionHints(tool: unknown): Pick<CompactTool, "useWhen" | "avoidWhen">;
package/dist/engine.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { type CapletConfig, type CapletsConfig } from "./config";
2
+ import { type ObservedOutputShapeKey, type ObservedOutputShapeStore } from "./observed-output-shapes";
3
+ import { type ExposureSnapshot } from "./exposure/discovery";
2
4
  export type CapletsEngineOptions = {
3
5
  configPath?: string;
4
6
  projectConfigPath?: string;
@@ -7,6 +9,10 @@ export type CapletsEngineOptions = {
7
9
  watch?: boolean;
8
10
  writeErr?: (value: string) => void;
9
11
  configLoader?: (configPath: string, projectConfigPath: string) => CapletsConfig;
12
+ observedOutputShapeStore?: ObservedOutputShapeStore | undefined;
13
+ observedOutputShapeScope?: ObservedOutputShapeKey["scope"] | undefined;
14
+ observedOutputShapeCacheDir?: string | undefined;
15
+ projectFingerprint?: string | undefined;
10
16
  };
11
17
  export type CapletsEngineReloadEvent = {
12
18
  previous: CapletsConfig;
@@ -26,7 +32,11 @@ export declare class CapletsEngine {
26
32
  private readonly watchEnabled;
27
33
  private readonly writeErr;
28
34
  private readonly configLoader;
35
+ private readonly observedOutputShapeStore;
36
+ private readonly observedOutputShapeScope;
37
+ private readonly projectFingerprint;
29
38
  private readonly reloadListeners;
39
+ private lastExposureSnapshot;
30
40
  private watchers;
31
41
  private reloadTimer;
32
42
  private watcherRefreshTimer;
@@ -36,14 +46,24 @@ export declare class CapletsEngine {
36
46
  constructor(options?: CapletsEngineOptions);
37
47
  currentConfig(): CapletsConfig;
38
48
  enabledServers(): CapletConfig[];
49
+ exposureSnapshot(options?: {
50
+ discoverNonDirectMcpSurfaces?: boolean | undefined;
51
+ }): Promise<ExposureSnapshot>;
52
+ currentExposureSnapshot(): ExposureSnapshot | undefined;
39
53
  watchedPaths(): string[];
40
54
  onReload(listener: (event: CapletsEngineReloadEvent) => void): () => void;
41
55
  scheduleReload(): void;
42
56
  reload(): Promise<boolean>;
43
57
  execute(serverId: string, request: unknown): Promise<unknown>;
58
+ executeDirectTool(serverId: string, toolName: string, args: Record<string, unknown>): Promise<unknown>;
59
+ readDirectResource(serverId: string, downstreamUri: string): Promise<unknown>;
60
+ getDirectPrompt(serverId: string, promptName: string, args: Record<string, unknown>): Promise<unknown>;
44
61
  completeCliWords(words: string[]): Promise<string[]>;
45
62
  close(): Promise<void>;
46
63
  private listCompletionTools;
64
+ private listTools;
65
+ private callTool;
66
+ private optionalMcpList;
47
67
  private reloadOnce;
48
68
  private reloadUntilSettled;
49
69
  private emitReload;
@@ -0,0 +1,9 @@
1
+ export declare function directToolName(capletId: string, operationName: string): string;
2
+ export declare function directPromptName(capletId: string, promptName: string): string;
3
+ export declare function nativeDirectToolName(capletId: string, operationName: string): string;
4
+ export declare function directResourceUri(capletId: string, downstreamUri: string): string;
5
+ export declare function directResourceTemplateUri(capletId: string, downstreamUriTemplate: string): string;
6
+ export declare function decodeDirectResourceUri(uri: string): {
7
+ capletId: string;
8
+ downstreamUri: string;
9
+ };
@@ -0,0 +1,75 @@
1
+ import type { Prompt, Resource, ResourceTemplate, Tool } from "@modelcontextprotocol/sdk/types";
2
+ import type { CapletConfig, CapletsConfig } from "../config";
3
+ import { type SafeErrorSummary } from "../errors";
4
+ import { type ResolvedExposure } from "./policy";
5
+ export type HiddenCapletReason = "disabled" | "setup_required" | "project_binding_required" | "discovery_failed" | "empty_surface";
6
+ export type HiddenCaplet = {
7
+ capletId: string;
8
+ reason: HiddenCapletReason;
9
+ error?: SafeErrorSummary | undefined;
10
+ };
11
+ export type CallableCaplet = {
12
+ caplet: CapletConfig;
13
+ exposure: ResolvedExposure;
14
+ tools: Tool[];
15
+ resources: Resource[];
16
+ resourceTemplates: ResourceTemplate[];
17
+ prompts: Prompt[];
18
+ discoveredAt: number;
19
+ };
20
+ export type DirectToolRegistration = {
21
+ caplet: CapletConfig;
22
+ downstreamName: string;
23
+ name: string;
24
+ tool: Tool;
25
+ };
26
+ export type DirectResourceRegistration = {
27
+ caplet: Extract<CapletConfig, {
28
+ backend: "mcp";
29
+ }>;
30
+ downstreamUri: string;
31
+ uri: string;
32
+ resource: Resource;
33
+ };
34
+ export type DirectResourceTemplateRegistration = {
35
+ caplet: Extract<CapletConfig, {
36
+ backend: "mcp";
37
+ }>;
38
+ downstreamUriTemplate: string;
39
+ uriTemplate: string;
40
+ resourceTemplate: ResourceTemplate;
41
+ };
42
+ export type DirectPromptRegistration = {
43
+ caplet: Extract<CapletConfig, {
44
+ backend: "mcp";
45
+ }>;
46
+ downstreamName: string;
47
+ name: string;
48
+ prompt: Prompt;
49
+ };
50
+ export type ExposureSnapshot = {
51
+ callableCaplets: CallableCaplet[];
52
+ progressiveCaplets: CallableCaplet[];
53
+ codeModeCaplets: CallableCaplet[];
54
+ directTools: DirectToolRegistration[];
55
+ directResources: DirectResourceRegistration[];
56
+ directResourceTemplates: DirectResourceTemplateRegistration[];
57
+ directPrompts: DirectPromptRegistration[];
58
+ hiddenCaplets: HiddenCaplet[];
59
+ };
60
+ export type DiscoverExposureSnapshotOptions = {
61
+ config: CapletsConfig;
62
+ caplets: CapletConfig[];
63
+ discoverNonDirectMcpSurfaces?: boolean | undefined;
64
+ listTools(caplet: CapletConfig): Promise<Tool[]>;
65
+ listResources?(caplet: Extract<CapletConfig, {
66
+ backend: "mcp";
67
+ }>): Promise<Resource[]>;
68
+ listResourceTemplates?(caplet: Extract<CapletConfig, {
69
+ backend: "mcp";
70
+ }>): Promise<ResourceTemplate[]>;
71
+ listPrompts?(caplet: Extract<CapletConfig, {
72
+ backend: "mcp";
73
+ }>): Promise<Prompt[]>;
74
+ };
75
+ export declare function discoverExposureSnapshot(options: DiscoverExposureSnapshotOptions): Promise<ExposureSnapshot>;
@@ -0,0 +1,8 @@
1
+ import type { CapletExposure } from "../config";
2
+ export type ResolvedExposure = {
3
+ value: CapletExposure;
4
+ direct: boolean;
5
+ progressive: boolean;
6
+ codeMode: boolean;
7
+ };
8
+ export declare function resolveExposure(capletExposure: CapletExposure | undefined, globalExposure: CapletExposure): ResolvedExposure;
@@ -0,0 +1,66 @@
1
+ import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
2
+ import { isAbsolute, join, relative, resolve, sep } from "node:path";
3
+ //#region src/caplet-source/types.ts
4
+ function normalizeCapletSourcePath(path) {
5
+ const normalized = path.trim().replace(/\\/g, "/").replace(/^\.\//u, "");
6
+ if (!normalized || normalized.startsWith("/") || /^[A-Za-z]:\//u.test(normalized)) return;
7
+ const stack = [];
8
+ for (const segment of normalized.split("/")) {
9
+ if (!segment || segment === ".") continue;
10
+ if (segment === "..") {
11
+ if (stack.length === 0) return;
12
+ stack.pop();
13
+ continue;
14
+ }
15
+ stack.push(segment);
16
+ }
17
+ return stack.length > 0 ? stack.join("/") : void 0;
18
+ }
19
+ //#endregion
20
+ //#region src/caplet-source/filesystem.ts
21
+ var FilesystemCapletSource = class {
22
+ root;
23
+ constructor(root) {
24
+ this.root = resolve(root);
25
+ }
26
+ async listFiles() {
27
+ if (!existsSync(this.root) || !statSync(this.root).isDirectory()) return [];
28
+ return walkFiles(this.root, this.root).sort((left, right) => left.path.localeCompare(right.path));
29
+ }
30
+ async readFile(path) {
31
+ const normalized = normalizeCapletSourcePath(path);
32
+ if (!normalized) return;
33
+ const absolute = resolve(this.root, normalized);
34
+ if (!isWithinRoot(this.root, absolute) || !existsSync(absolute) || !statSync(absolute).isFile()) return;
35
+ return {
36
+ path: normalized,
37
+ content: readFileSync(absolute, "utf8")
38
+ };
39
+ }
40
+ };
41
+ function walkFiles(root, dir) {
42
+ const files = [];
43
+ for (const entry of readdirSync(dir, { withFileTypes: true }).sort(compareDirents)) {
44
+ const absolute = join(dir, entry.name);
45
+ if (entry.isDirectory()) {
46
+ files.push(...walkFiles(root, absolute));
47
+ continue;
48
+ }
49
+ if (!entry.isFile()) continue;
50
+ const normalized = normalizeCapletSourcePath(relative(root, absolute));
51
+ if (normalized) files.push({
52
+ path: normalized,
53
+ content: readFileSync(absolute, "utf8")
54
+ });
55
+ }
56
+ return files;
57
+ }
58
+ function compareDirents(left, right) {
59
+ return left.name.localeCompare(right.name);
60
+ }
61
+ function isWithinRoot(root, absolute) {
62
+ const rel = relative(root, absolute);
63
+ return rel === "" || !rel.startsWith(`..${sep}`) && rel !== ".." && !isAbsolute(rel);
64
+ }
65
+ //#endregion
66
+ export { normalizeCapletSourcePath as n, FilesystemCapletSource as t };