@caplets/core 0.19.0 → 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 (74) hide show
  1. package/dist/caplet-files-bundle.d.ts +24 -9
  2. package/dist/caplet-source.js +368 -4588
  3. package/dist/cli/auth.d.ts +40 -2
  4. package/dist/cli/cloud-add.d.ts +8 -0
  5. package/dist/cli/code-mode.d.ts +16 -0
  6. package/dist/cli/commands.d.ts +3 -1
  7. package/dist/cli/doctor.d.ts +3 -0
  8. package/dist/cli/setup.d.ts +7 -0
  9. package/dist/cli-tools.d.ts +1 -1
  10. package/dist/cli.d.ts +1 -0
  11. package/dist/cloud-auth/client.d.ts +15 -0
  12. package/dist/cloud-auth/types.d.ts +2 -1
  13. package/dist/code-mode/api.d.ts +32 -0
  14. package/dist/code-mode/declarations.d.ts +5 -0
  15. package/dist/code-mode/diagnostics.d.ts +8 -0
  16. package/dist/code-mode/index.d.ts +4 -0
  17. package/dist/code-mode/logs.d.ts +21 -0
  18. package/dist/code-mode/runner.d.ts +15 -0
  19. package/dist/code-mode/runtime-api.generated.d.ts +1 -0
  20. package/dist/code-mode/sandbox.d.ts +28 -0
  21. package/dist/code-mode/static-analysis.d.ts +2 -0
  22. package/dist/code-mode/tool.d.ts +11 -0
  23. package/dist/code-mode/types.d.ts +120 -0
  24. package/dist/code-mode.js +147855 -0
  25. package/dist/{completion-brgziz4L.js → completion-CbazRAiL.js} +5 -2
  26. package/dist/config/paths.d.ts +2 -0
  27. package/dist/config-runtime.d.ts +13 -4
  28. package/dist/config-runtime.js +31 -2
  29. package/dist/config.d.ts +34 -9
  30. package/dist/downstream.d.ts +20 -2
  31. package/dist/engine.d.ts +20 -0
  32. package/dist/exposure/direct-names.d.ts +9 -0
  33. package/dist/exposure/discovery.d.ts +75 -0
  34. package/dist/exposure/policy.d.ts +8 -0
  35. package/dist/generated-tool-input-schema.d.ts +89 -59
  36. package/dist/generated-tool-input-schema.js +38 -27
  37. package/dist/graphql.d.ts +1 -1
  38. package/dist/http-actions.d.ts +1 -1
  39. package/dist/index.d.ts +13 -0
  40. package/dist/index.js +1096 -154
  41. package/dist/native/service.d.ts +6 -0
  42. package/dist/native/tools.d.ts +2 -0
  43. package/dist/native.d.ts +1 -1
  44. package/dist/native.js +2 -2
  45. package/dist/observed-output-shapes/extract.d.ts +5 -0
  46. package/dist/observed-output-shapes/file-store.d.ts +17 -0
  47. package/dist/observed-output-shapes/index.d.ts +7 -0
  48. package/dist/observed-output-shapes/key.d.ts +14 -0
  49. package/dist/observed-output-shapes/merge.d.ts +2 -0
  50. package/dist/observed-output-shapes/pure.d.ts +5 -0
  51. package/dist/observed-output-shapes/pure.js +241 -0
  52. package/dist/observed-output-shapes/schema.d.ts +1 -0
  53. package/dist/observed-output-shapes/types.d.ts +84 -0
  54. package/dist/observed-output-shapes/typescript.d.ts +7 -0
  55. package/dist/observed-output-shapes-uzAMQPhg.js +485 -0
  56. package/dist/observed-output-shapes.js +2 -0
  57. package/dist/openapi.d.ts +1 -1
  58. package/dist/project-binding/index.d.ts +2 -0
  59. package/dist/project-binding.js +22 -0
  60. package/dist/redaction.d.ts +14 -0
  61. package/dist/redaction.js +30 -0
  62. package/dist/registry.d.ts +4 -0
  63. package/dist/remote/options.d.ts +2 -0
  64. package/dist/remote-control/types.d.ts +1 -1
  65. package/dist/runtime-plan/resources.d.ts +2 -0
  66. package/dist/runtime-plan.js +8 -2
  67. package/dist/schemas-1HZ0kFpx.js +4270 -0
  68. package/dist/serve/session.d.ts +15 -3
  69. package/dist/{service-BXcE4Rv8.js → service-D0MwLNyb.js} +29175 -26499
  70. package/dist/stable-json.d.ts +3 -0
  71. package/dist/stable-json.js +26 -0
  72. package/dist/tools.d.ts +22 -11
  73. package/dist/{validation-BBG4skZf.js → validation-CdqbI2zN.js} +25 -4
  74. package/package.json +29 -3
@@ -1,5 +1,5 @@
1
- import { Bt as DEFAULT_COMPLETION_CACHE_DIR, Gt as resolveConfigPath, Pt as loadConfigWithSources, Wt as resolveCapletsRoot, en as __exportAll, qt as resolveProjectConfigPath, zt as DEFAULT_AUTH_DIR } from "./service-BXcE4Rv8.js";
2
- import { u as CapletsError } from "./validation-BBG4skZf.js";
1
+ import { St as resolveProjectConfigPath, Y as loadConfigWithSources, bt as resolveConfigPath, mt as DEFAULT_COMPLETION_CACHE_DIR, pt as DEFAULT_AUTH_DIR, vn as __exportAll, yt as resolveCapletsRoot } from "./service-D0MwLNyb.js";
2
+ import { u as CapletsError } from "./validation-CdqbI2zN.js";
3
3
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join } from "node:path";
5
5
  import { createHash } from "node:crypto";
@@ -14,6 +14,7 @@ const completionShells = [
14
14
  const cliCommands = {
15
15
  completion: "completion",
16
16
  completeHidden: "__complete",
17
+ codeMode: "code-mode",
17
18
  serve: "serve",
18
19
  attach: "attach",
19
20
  cloud: "cloud",
@@ -42,6 +43,7 @@ const cliCommands = {
42
43
  };
43
44
  const topLevelCommandNames = [
44
45
  cliCommands.serve,
46
+ cliCommands.codeMode,
45
47
  cliCommands.attach,
46
48
  cliCommands.cloud,
47
49
  cliCommands.init,
@@ -82,6 +84,7 @@ const cliSubcommands = {
82
84
  "list"
83
85
  ],
84
86
  [cliCommands.cloud]: ["auth"],
87
+ [cliCommands.codeMode]: ["types"],
85
88
  [cliCommands.completion]: [...completionShells],
86
89
  [cliCommands.config]: ["path", "paths"],
87
90
  [cliCommands.serve]: [
@@ -6,9 +6,11 @@ export declare function defaultCacheBaseDir(env?: PathEnv, home?: string, platfo
6
6
  export declare function defaultConfigPath(env?: PathEnv, home?: string, platform?: Platform): string;
7
7
  export declare function defaultAuthDir(env?: PathEnv, home?: string, platform?: Platform): string;
8
8
  export declare function defaultCompletionCacheDir(env?: PathEnv, home?: string, platform?: Platform): string;
9
+ export declare function defaultObservedOutputShapeCacheDir(env?: PathEnv, home?: string, platform?: Platform): string;
9
10
  export declare const DEFAULT_CONFIG_PATH: string;
10
11
  export declare const DEFAULT_AUTH_DIR: string;
11
12
  export declare const DEFAULT_COMPLETION_CACHE_DIR: string;
13
+ export declare const DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR: string;
12
14
  export declare const PROJECT_CONFIG_FILE: string;
13
15
  export declare function resolveConfigPath(path?: string): string;
14
16
  export declare function resolveProjectConfigPath(cwd?: string): string;
@@ -44,6 +44,11 @@ export type RuntimeRequirementsConfig = {
44
44
  class?: RuntimeResourceClass | undefined;
45
45
  } | undefined;
46
46
  };
47
+ export type AgentSelectionHintsConfig = {
48
+ useWhen?: string | undefined;
49
+ avoidWhen?: string | undefined;
50
+ };
51
+ export type CapletExposure = "direct" | "progressive" | "code_mode" | "direct_and_code_mode" | "progressive_and_code_mode";
47
52
  export type CapletServerConfig = CommonCapletConfig & {
48
53
  backend: "mcp";
49
54
  transport: "stdio" | "http" | "sse";
@@ -67,7 +72,7 @@ export type OpenApiEndpointConfig = CommonCapletConfig & {
67
72
  requestTimeoutMs: number;
68
73
  operationCacheTtlMs: number;
69
74
  };
70
- export type GraphQlOperationConfig = {
75
+ export type GraphQlOperationConfig = AgentSelectionHintsConfig & {
71
76
  document?: string | undefined;
72
77
  documentPath?: string | undefined;
73
78
  operationName?: string | undefined;
@@ -85,7 +90,7 @@ export type GraphQlEndpointConfig = CommonCapletConfig & {
85
90
  operationCacheTtlMs: number;
86
91
  selectionDepth: number;
87
92
  };
88
- export type HttpActionConfig = {
93
+ export type HttpActionConfig = AgentSelectionHintsConfig & {
89
94
  method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
90
95
  path: string;
91
96
  description?: string | undefined;
@@ -103,7 +108,7 @@ export type HttpApiConfig = CommonCapletConfig & {
103
108
  requestTimeoutMs: number;
104
109
  maxResponseBytes: number;
105
110
  };
106
- export type CliToolActionConfig = {
111
+ export type CliToolActionConfig = AgentSelectionHintsConfig & {
107
112
  description?: string | undefined;
108
113
  inputSchema?: Record<string, unknown> | undefined;
109
114
  outputSchema?: Record<string, unknown> | undefined;
@@ -145,6 +150,9 @@ export type CapletsConfig = {
145
150
  options: {
146
151
  defaultSearchLimit: number;
147
152
  maxSearchLimit: number;
153
+ exposure: CapletExposure;
154
+ exposureDiscoveryTimeoutMs: number;
155
+ exposureDiscoveryConcurrency: number;
148
156
  completion: {
149
157
  discoveryTimeoutMs: number;
150
158
  overallTimeoutMs: number;
@@ -159,10 +167,11 @@ export type CapletsConfig = {
159
167
  cliTools: Record<string, CliToolsConfig>;
160
168
  capletSets: Record<string, CapletSetConfig>;
161
169
  };
162
- type CommonCapletConfig = {
170
+ type CommonCapletConfig = AgentSelectionHintsConfig & {
163
171
  server: string;
164
172
  name: string;
165
173
  description: string;
174
+ exposure?: CapletExposure | undefined;
166
175
  tags?: string[] | undefined;
167
176
  body?: string | undefined;
168
177
  setup?: CapletSetupConfig | undefined;
@@ -1,5 +1,5 @@
1
- import { a as isAllowedHttpBaseUrl, c as validateHttpActionHeaders, i as SERVER_ID_PATTERN, n as HEADER_NAME_PATTERN, o as isAllowedRemoteUrl, r as HTTP_BASE_URL_PATTERN, s as isUrl, t as FORBIDDEN_HEADERS, u as CapletsError } from "./validation-BBG4skZf.js";
2
1
  import { _ as record, b as unknown, d as literal, l as discriminatedUnion, m as object, o as array, p as number, r as _enum, s as boolean, v as string, y as union } from "./schemas-BZ6BBrh7.js";
2
+ import { a as isAllowedHttpBaseUrl, c as validateHttpActionHeaders, i as SERVER_ID_PATTERN, n as HEADER_NAME_PATTERN, o as isAllowedRemoteUrl, r as HTTP_BASE_URL_PATTERN, s as isUrl, t as FORBIDDEN_HEADERS, u as CapletsError } from "./validation-CdqbI2zN.js";
3
3
  //#region src/config-runtime.ts
4
4
  const stringMapSchema = record(string(), string());
5
5
  const authSchema = discriminatedUnion("type", [
@@ -37,10 +37,24 @@ const runtimeRequirementsSchema = object({
37
37
  "heavy"
38
38
  ]).optional() }).strict().optional()
39
39
  }).strict();
40
+ const agentSelectionHintSchema = string().trim().min(1).max(500);
41
+ const agentSelectionHintsSchema = {
42
+ useWhen: agentSelectionHintSchema.optional(),
43
+ avoidWhen: agentSelectionHintSchema.optional()
44
+ };
45
+ const exposureSchema = _enum([
46
+ "direct",
47
+ "progressive",
48
+ "code_mode",
49
+ "direct_and_code_mode",
50
+ "progressive_and_code_mode"
51
+ ]);
40
52
  const commonSchema = {
41
53
  name: string().trim().min(1).max(80),
42
54
  description: string().refine((value) => value.trim().length >= 10, "description must contain at least 10 non-whitespace characters").refine((value) => value.length <= 1500, "description must be at most 1500 characters"),
43
55
  tags: array(string().trim().min(1).max(80)).optional(),
56
+ exposure: exposureSchema.optional(),
57
+ ...agentSelectionHintsSchema,
44
58
  body: string().optional(),
45
59
  setup: setupSchema.optional(),
46
60
  projectBinding: projectBindingSchema.optional(),
@@ -77,7 +91,8 @@ const graphQlOperationSchema = object({
77
91
  document: string().min(1).optional(),
78
92
  documentPath: string().min(1).optional(),
79
93
  operationName: string().min(1).optional(),
80
- description: string().min(1).optional()
94
+ description: string().min(1).optional(),
95
+ ...agentSelectionHintsSchema
81
96
  }).strict().refine((operation) => Boolean(operation.document) !== Boolean(operation.documentPath), { message: "GraphQL operation must define exactly one document source" });
82
97
  const graphQlEndpointSchema = object({
83
98
  ...commonSchema,
@@ -106,6 +121,7 @@ const httpActionSchema = object({
106
121
  ]),
107
122
  path: string().min(1).regex(/^\//, "HTTP action path must start with /").refine((value) => !value.startsWith("//"), "HTTP action path must not start with //").refine((value) => !isUrl(value), "HTTP action path must be a URL path, not a URL"),
108
123
  description: string().min(1).optional(),
124
+ ...agentSelectionHintsSchema,
109
125
  inputSchema: record(string(), unknown()).optional(),
110
126
  outputSchema: record(string(), unknown()).optional(),
111
127
  query: scalarMapSchema.optional(),
@@ -125,6 +141,7 @@ const httpApiSchema = object({
125
141
  }).strict();
126
142
  const cliActionSchema = object({
127
143
  description: string().min(1).optional(),
144
+ ...agentSelectionHintsSchema,
128
145
  inputSchema: record(string(), unknown()).optional(),
129
146
  outputSchema: record(string(), unknown()).optional(),
130
147
  command: string().min(1),
@@ -172,6 +189,15 @@ const configSchema = object({
172
189
  cacheTtlMs: 3e5,
173
190
  negativeCacheTtlMs: 3e4
174
191
  }),
192
+ options: object({
193
+ exposure: exposureSchema.default("code_mode"),
194
+ exposureDiscoveryTimeoutMs: number().int().positive().default(15e3),
195
+ exposureDiscoveryConcurrency: number().int().positive().max(32).default(4)
196
+ }).strict().default({
197
+ exposure: "code_mode",
198
+ exposureDiscoveryTimeoutMs: 15e3,
199
+ exposureDiscoveryConcurrency: 4
200
+ }),
175
201
  mcpServers: record(string().regex(SERVER_ID_PATTERN), mcpServerSchema).default({}),
176
202
  openapiEndpoints: record(string().regex(SERVER_ID_PATTERN), openApiEndpointSchema).default({}),
177
203
  graphqlEndpoints: record(string().regex(SERVER_ID_PATTERN), graphQlEndpointSchema).default({}),
@@ -195,6 +221,9 @@ function parseConfig(input) {
195
221
  options: {
196
222
  defaultSearchLimit: config.defaultSearchLimit,
197
223
  maxSearchLimit: config.maxSearchLimit,
224
+ exposure: config.options.exposure,
225
+ exposureDiscoveryTimeoutMs: config.options.exposureDiscoveryTimeoutMs,
226
+ exposureDiscoveryConcurrency: config.options.exposureDiscoveryConcurrency,
198
227
  completion: config.completion
199
228
  },
200
229
  mcpServers: mapBackend(config.mcpServers, "mcp", (id, raw) => {
package/dist/config.d.ts CHANGED
@@ -59,11 +59,17 @@ export type RuntimeRequirementsConfig = {
59
59
  class?: RuntimeResourceClass | undefined;
60
60
  } | undefined;
61
61
  };
62
- export type CapletServerConfig = {
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 & {
63
68
  server: string;
64
69
  backend: "mcp";
65
70
  name: string;
66
71
  description: string;
72
+ exposure?: CapletExposure | undefined;
67
73
  tags?: string[] | undefined;
68
74
  body?: string | undefined;
69
75
  transport: "stdio" | "http" | "sse";
@@ -92,11 +98,12 @@ export type OpenApiAuthConfig = {
92
98
  } | Extract<RemoteAuthConfig, {
93
99
  type: "oauth2" | "oidc";
94
100
  }>;
95
- export type OpenApiEndpointConfig = {
101
+ export type OpenApiEndpointConfig = AgentSelectionHintsConfig & {
96
102
  server: string;
97
103
  backend: "openapi";
98
104
  name: string;
99
105
  description: string;
106
+ exposure?: CapletExposure | undefined;
100
107
  tags?: string[] | undefined;
101
108
  body?: string | undefined;
102
109
  specPath?: string | undefined;
@@ -110,17 +117,18 @@ export type OpenApiEndpointConfig = {
110
117
  projectBinding?: ProjectBindingConfig | undefined;
111
118
  runtime?: RuntimeRequirementsConfig | undefined;
112
119
  };
113
- export type GraphQlOperationConfig = {
120
+ export type GraphQlOperationConfig = AgentSelectionHintsConfig & {
114
121
  document?: string | undefined;
115
122
  documentPath?: string | undefined;
116
123
  operationName?: string | undefined;
117
124
  description?: string | undefined;
118
125
  };
119
- export type GraphQlEndpointConfig = {
126
+ export type GraphQlEndpointConfig = AgentSelectionHintsConfig & {
120
127
  server: string;
121
128
  backend: "graphql";
122
129
  name: string;
123
130
  description: string;
131
+ exposure?: CapletExposure | undefined;
124
132
  tags?: string[] | undefined;
125
133
  body?: string | undefined;
126
134
  endpointUrl: string;
@@ -137,7 +145,7 @@ export type GraphQlEndpointConfig = {
137
145
  projectBinding?: ProjectBindingConfig | undefined;
138
146
  runtime?: RuntimeRequirementsConfig | undefined;
139
147
  };
140
- export type HttpActionConfig = {
148
+ export type HttpActionConfig = AgentSelectionHintsConfig & {
141
149
  method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
142
150
  path: string;
143
151
  description?: string | undefined;
@@ -147,11 +155,12 @@ export type HttpActionConfig = {
147
155
  headers?: Record<string, string | number | boolean> | undefined;
148
156
  jsonBody?: unknown;
149
157
  };
150
- export type HttpApiConfig = {
158
+ export type HttpApiConfig = AgentSelectionHintsConfig & {
151
159
  server: string;
152
160
  backend: "http";
153
161
  name: string;
154
162
  description: string;
163
+ exposure?: CapletExposure | undefined;
155
164
  tags?: string[] | undefined;
156
165
  body?: string | undefined;
157
166
  baseUrl: string;
@@ -167,7 +176,7 @@ export type HttpApiConfig = {
167
176
  export type CliToolOutputConfig = {
168
177
  type: "text" | "json";
169
178
  };
170
- export type CliToolActionConfig = {
179
+ export type CliToolActionConfig = AgentSelectionHintsConfig & {
171
180
  description?: string | undefined;
172
181
  inputSchema?: Record<string, unknown> | undefined;
173
182
  outputSchema?: Record<string, unknown> | undefined;
@@ -185,11 +194,12 @@ export type CliToolActionConfig = {
185
194
  openWorldHint?: boolean | undefined;
186
195
  } | undefined;
187
196
  };
188
- export type CliToolsConfig = {
197
+ export type CliToolsConfig = AgentSelectionHintsConfig & {
189
198
  server: string;
190
199
  backend: "cli";
191
200
  name: string;
192
201
  description: string;
202
+ exposure?: CapletExposure | undefined;
193
203
  tags?: string[] | undefined;
194
204
  body?: string | undefined;
195
205
  actions: Record<string, CliToolActionConfig>;
@@ -202,11 +212,12 @@ export type CliToolsConfig = {
202
212
  projectBinding?: ProjectBindingConfig | undefined;
203
213
  runtime?: RuntimeRequirementsConfig | undefined;
204
214
  };
205
- export type CapletSetConfig = {
215
+ export type CapletSetConfig = AgentSelectionHintsConfig & {
206
216
  server: string;
207
217
  backend: "caplets";
208
218
  name: string;
209
219
  description: string;
220
+ exposure?: CapletExposure | undefined;
210
221
  tags?: string[] | undefined;
211
222
  body?: string | undefined;
212
223
  configPath?: string | undefined;
@@ -223,6 +234,9 @@ export type CapletConfig = CapletServerConfig | OpenApiEndpointConfig | GraphQlE
223
234
  export type CapletsOptions = {
224
235
  defaultSearchLimit: number;
225
236
  maxSearchLimit: number;
237
+ exposure: CapletExposure;
238
+ exposureDiscoveryTimeoutMs: number;
239
+ exposureDiscoveryConcurrency: number;
226
240
  completion: CompletionConfig;
227
241
  };
228
242
  export type CompletionConfig = {
@@ -270,6 +284,17 @@ export declare const configFileSchema: z.ZodObject<{
270
284
  cacheTtlMs: z.ZodDefault<z.ZodNumber>;
271
285
  negativeCacheTtlMs: z.ZodDefault<z.ZodNumber>;
272
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>>;
273
298
  mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
274
299
  openapiEndpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
275
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;