@caplets/core 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth.d.ts +2 -1
- package/dist/caplet-files-bundle.d.ts +62 -0
- package/dist/caplet-sets.d.ts +2 -0
- package/dist/caplet-source.js +96 -4
- package/dist/cli/add.d.ts +10 -0
- package/dist/cli/auth.d.ts +22 -0
- package/dist/cli/code-mode.d.ts +3 -0
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/code-mode/api.d.ts +3 -1
- package/dist/code-mode/diagnostics-builtins.generated.d.ts +1 -0
- package/dist/code-mode/diagnostics.d.ts +8 -0
- package/dist/code-mode/index.d.ts +1 -1
- package/dist/code-mode/journal.d.ts +103 -0
- package/dist/code-mode/platform-entry.d.ts +1 -0
- package/dist/code-mode/platform-host.d.ts +6 -0
- package/dist/code-mode/platform-runtime.generated.d.ts +1 -0
- package/dist/code-mode/runner.d.ts +5 -0
- package/dist/code-mode/runtime-api.generated.d.ts +1 -1
- package/dist/code-mode/sandbox.d.ts +14 -1
- package/dist/code-mode/sessions.d.ts +53 -0
- package/dist/code-mode/tool.d.ts +5 -0
- package/dist/code-mode/types.d.ts +30 -0
- package/dist/code-mode.js +21 -14
- package/dist/{completion-DnQujlrc.js → completion-CzHdM9B_.js} +14 -2
- package/dist/config/paths.d.ts +2 -0
- package/dist/config-runtime.d.ts +13 -1
- package/dist/config-runtime.js +44 -0
- package/dist/config.d.ts +25 -1
- package/dist/engine.d.ts +3 -0
- package/dist/google-discovery/index.d.ts +5 -0
- package/dist/google-discovery/manager.d.ts +37 -0
- package/dist/google-discovery/operations.d.ts +32 -0
- package/dist/google-discovery/request.d.ts +5 -0
- package/dist/google-discovery/schema.d.ts +2 -0
- package/dist/google-discovery/types.d.ts +70 -0
- package/dist/http/response.d.ts +14 -0
- package/dist/http-actions.d.ts +3 -0
- package/dist/index.js +190 -43
- package/dist/media/artifacts.d.ts +24 -0
- package/dist/media/index.d.ts +2 -0
- package/dist/media/input.d.ts +29 -0
- package/dist/native/options.d.ts +3 -6
- package/dist/native/remote.d.ts +2 -0
- package/dist/native/service.d.ts +2 -0
- package/dist/native/tools.d.ts +1 -0
- package/dist/native.js +1 -1
- package/dist/{observed-output-shapes-CL5MFXwM.js → observed-output-shapes-D2k2-q8K.js} +9 -0
- package/dist/observed-output-shapes.js +1 -1
- package/dist/openapi.d.ts +2 -0
- package/dist/registry.d.ts +6 -0
- package/dist/remote/options.d.ts +1 -1
- package/dist/runtime-plan.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/serve/session.d.ts +1 -0
- package/dist/{service-4_chB2wu.js → service-BCT_Ls_3.js} +3878 -361
- package/dist/tools.d.ts +2 -1
- package/package.json +9 -2
package/dist/config-runtime.js
CHANGED
|
@@ -89,6 +89,18 @@ const openApiEndpointSchema = object({
|
|
|
89
89
|
requestTimeoutMs: number().int().positive().default(6e4),
|
|
90
90
|
operationCacheTtlMs: number().int().nonnegative().default(3e4)
|
|
91
91
|
}).strict();
|
|
92
|
+
const operationFilterSchema = array(string().trim().min(1).max(160));
|
|
93
|
+
const googleDiscoveryApiSchema = object({
|
|
94
|
+
...commonSchema,
|
|
95
|
+
discoveryPath: string().min(1).optional(),
|
|
96
|
+
discoveryUrl: string().min(1).optional(),
|
|
97
|
+
baseUrl: string().min(1).optional(),
|
|
98
|
+
includeOperations: operationFilterSchema.optional(),
|
|
99
|
+
excludeOperations: operationFilterSchema.optional(),
|
|
100
|
+
auth: authSchema,
|
|
101
|
+
requestTimeoutMs: number().int().positive().default(6e4),
|
|
102
|
+
operationCacheTtlMs: number().int().nonnegative().default(3e4)
|
|
103
|
+
}).strict();
|
|
92
104
|
const graphQlOperationSchema = object({
|
|
93
105
|
document: string().min(1).optional(),
|
|
94
106
|
documentPath: string().min(1).optional(),
|
|
@@ -202,6 +214,7 @@ const configSchema = object({
|
|
|
202
214
|
}),
|
|
203
215
|
mcpServers: record(string().regex(SERVER_ID_PATTERN), mcpServerSchema).default({}),
|
|
204
216
|
openapiEndpoints: record(string().regex(SERVER_ID_PATTERN), openApiEndpointSchema).default({}),
|
|
217
|
+
googleDiscoveryApis: record(string().regex(SERVER_ID_PATTERN), googleDiscoveryApiSchema).default({}),
|
|
205
218
|
graphqlEndpoints: record(string().regex(SERVER_ID_PATTERN), graphQlEndpointSchema).default({}),
|
|
206
219
|
httpApis: record(string().regex(SERVER_ID_PATTERN), httpApiSchema).default({}),
|
|
207
220
|
cliTools: record(string().regex(SERVER_ID_PATTERN), cliToolsSchema).default({}),
|
|
@@ -237,6 +250,7 @@ function parseConfig(input) {
|
|
|
237
250
|
};
|
|
238
251
|
}),
|
|
239
252
|
openapiEndpoints: mapBackend(config.openapiEndpoints, "openapi"),
|
|
253
|
+
googleDiscoveryApis: mapBackend(config.googleDiscoveryApis, "googleDiscovery"),
|
|
240
254
|
graphqlEndpoints: mapBackend(config.graphqlEndpoints, "graphql"),
|
|
241
255
|
httpApis: mapBackend(config.httpApis, "http"),
|
|
242
256
|
cliTools: mapBackend(config.cliTools, "cli"),
|
|
@@ -330,6 +344,36 @@ function validateBackends(config, ctx) {
|
|
|
330
344
|
"auth"
|
|
331
345
|
]);
|
|
332
346
|
}
|
|
347
|
+
for (const [server, raw] of Object.entries(config.googleDiscoveryApis)) {
|
|
348
|
+
if (Boolean(raw.discoveryPath) === Boolean(raw.discoveryUrl)) ctx.addIssue({
|
|
349
|
+
code: "custom",
|
|
350
|
+
path: ["googleDiscoveryApis", server],
|
|
351
|
+
message: "Google Discovery API must define exactly one discovery source"
|
|
352
|
+
});
|
|
353
|
+
if (raw.discoveryUrl && !hasEnvReference(raw.discoveryUrl) && !isAllowedRemoteUrl(raw.discoveryUrl)) ctx.addIssue({
|
|
354
|
+
code: "custom",
|
|
355
|
+
path: [
|
|
356
|
+
"googleDiscoveryApis",
|
|
357
|
+
server,
|
|
358
|
+
"discoveryUrl"
|
|
359
|
+
],
|
|
360
|
+
message: "Google Discovery API discoveryUrl must use https except loopback development urls"
|
|
361
|
+
});
|
|
362
|
+
if (raw.baseUrl && !hasEnvReference(raw.baseUrl) && !isAllowedHttpBaseUrl(raw.baseUrl)) ctx.addIssue({
|
|
363
|
+
code: "custom",
|
|
364
|
+
path: [
|
|
365
|
+
"googleDiscoveryApis",
|
|
366
|
+
server,
|
|
367
|
+
"baseUrl"
|
|
368
|
+
],
|
|
369
|
+
message: "Google Discovery API baseUrl must use https except loopback development urls and must not include credentials, query, or fragment"
|
|
370
|
+
});
|
|
371
|
+
validateAuthHeaders(raw.auth, ctx, [
|
|
372
|
+
"googleDiscoveryApis",
|
|
373
|
+
server,
|
|
374
|
+
"auth"
|
|
375
|
+
]);
|
|
376
|
+
}
|
|
333
377
|
for (const [server, raw] of Object.entries(config.graphqlEndpoints)) {
|
|
334
378
|
if (Number(Boolean(raw.schemaPath)) + Number(Boolean(raw.schemaUrl)) + Number(raw.introspection === true) !== 1) ctx.addIssue({
|
|
335
379
|
code: "custom",
|
package/dist/config.d.ts
CHANGED
|
@@ -178,6 +178,28 @@ export type HttpApiConfig = AgentSelectionHintsConfig & {
|
|
|
178
178
|
projectBinding?: ProjectBindingConfig | undefined;
|
|
179
179
|
runtime?: RuntimeRequirementsConfig | undefined;
|
|
180
180
|
};
|
|
181
|
+
export type GoogleDiscoveryApiConfig = AgentSelectionHintsConfig & {
|
|
182
|
+
server: string;
|
|
183
|
+
backend: "googleDiscovery";
|
|
184
|
+
name: string;
|
|
185
|
+
description: string;
|
|
186
|
+
exposure?: CapletExposure | undefined;
|
|
187
|
+
shadowing?: CapletShadowingPolicy | undefined;
|
|
188
|
+
tags?: string[] | undefined;
|
|
189
|
+
body?: string | undefined;
|
|
190
|
+
discoveryPath?: string | undefined;
|
|
191
|
+
discoveryUrl?: string | undefined;
|
|
192
|
+
baseUrl?: string | undefined;
|
|
193
|
+
includeOperations?: string[] | undefined;
|
|
194
|
+
excludeOperations?: string[] | undefined;
|
|
195
|
+
auth: OpenApiAuthConfig;
|
|
196
|
+
requestTimeoutMs: number;
|
|
197
|
+
operationCacheTtlMs: number;
|
|
198
|
+
disabled: boolean;
|
|
199
|
+
setup?: CapletSetupConfig | undefined;
|
|
200
|
+
projectBinding?: ProjectBindingConfig | undefined;
|
|
201
|
+
runtime?: RuntimeRequirementsConfig | undefined;
|
|
202
|
+
};
|
|
181
203
|
export type CliToolOutputConfig = {
|
|
182
204
|
type: "text" | "json";
|
|
183
205
|
};
|
|
@@ -237,7 +259,7 @@ export type CapletSetConfig = AgentSelectionHintsConfig & {
|
|
|
237
259
|
projectBinding?: ProjectBindingConfig | undefined;
|
|
238
260
|
runtime?: RuntimeRequirementsConfig | undefined;
|
|
239
261
|
};
|
|
240
|
-
export type CapletConfig = CapletServerConfig | OpenApiEndpointConfig | GraphQlEndpointConfig | HttpApiConfig | CliToolsConfig | CapletSetConfig;
|
|
262
|
+
export type CapletConfig = CapletServerConfig | OpenApiEndpointConfig | GoogleDiscoveryApiConfig | GraphQlEndpointConfig | HttpApiConfig | CliToolsConfig | CapletSetConfig;
|
|
241
263
|
export type CapletsOptions = {
|
|
242
264
|
defaultSearchLimit: number;
|
|
243
265
|
maxSearchLimit: number;
|
|
@@ -257,6 +279,7 @@ export type CapletsConfig = {
|
|
|
257
279
|
options: CapletsOptions;
|
|
258
280
|
mcpServers: Record<string, CapletServerConfig>;
|
|
259
281
|
openapiEndpoints: Record<string, OpenApiEndpointConfig>;
|
|
282
|
+
googleDiscoveryApis: Record<string, GoogleDiscoveryApiConfig>;
|
|
260
283
|
graphqlEndpoints: Record<string, GraphQlEndpointConfig>;
|
|
261
284
|
httpApis: Record<string, HttpApiConfig>;
|
|
262
285
|
cliTools: Record<string, CliToolsConfig>;
|
|
@@ -304,6 +327,7 @@ export declare const configFileSchema: z.ZodObject<{
|
|
|
304
327
|
}, z.core.$strict>>;
|
|
305
328
|
mcpServers: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
306
329
|
openapiEndpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
330
|
+
googleDiscoveryApis: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
307
331
|
graphqlEndpoints: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
308
332
|
httpApis: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
309
333
|
cliTools: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
package/dist/engine.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ export type CapletsEngineOptions = {
|
|
|
5
5
|
configPath?: string;
|
|
6
6
|
projectConfigPath?: string;
|
|
7
7
|
authDir?: string;
|
|
8
|
+
artifactDir?: string;
|
|
9
|
+
exposeLocalArtifactPaths?: boolean;
|
|
8
10
|
watchDebounceMs?: number;
|
|
9
11
|
watch?: boolean;
|
|
10
12
|
writeErr?: (value: string) => void;
|
|
@@ -23,6 +25,7 @@ export declare class CapletsEngine {
|
|
|
23
25
|
private registry;
|
|
24
26
|
private readonly downstream;
|
|
25
27
|
private readonly openapi;
|
|
28
|
+
private readonly googleDiscovery;
|
|
26
29
|
private readonly graphql;
|
|
27
30
|
private readonly http;
|
|
28
31
|
private readonly cli;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CompatibilityCallToolResult, Tool } from "@modelcontextprotocol/sdk/types";
|
|
2
|
+
import type { GoogleDiscoveryApiConfig } from "../config";
|
|
3
|
+
import { type CompactTool } from "../downstream";
|
|
4
|
+
import type { ServerRegistry } from "../registry";
|
|
5
|
+
export declare class GoogleDiscoveryManager {
|
|
6
|
+
private registry;
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly cache;
|
|
9
|
+
constructor(registry: ServerRegistry, options?: {
|
|
10
|
+
authDir?: string;
|
|
11
|
+
artifactDir?: string;
|
|
12
|
+
exposeLocalArtifactPaths?: boolean;
|
|
13
|
+
});
|
|
14
|
+
updateRegistry(registry: ServerRegistry): void;
|
|
15
|
+
invalidate(serverId: string): void;
|
|
16
|
+
checkApi(api: GoogleDiscoveryApiConfig): Promise<{
|
|
17
|
+
id: string;
|
|
18
|
+
status: string;
|
|
19
|
+
toolCount?: number;
|
|
20
|
+
elapsedMs: number;
|
|
21
|
+
error?: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
listTools(api: GoogleDiscoveryApiConfig): Promise<Tool[]>;
|
|
24
|
+
getTool(api: GoogleDiscoveryApiConfig, toolName: string): Promise<Tool>;
|
|
25
|
+
callTool(api: GoogleDiscoveryApiConfig, toolName: string, args: Record<string, unknown>): Promise<CompatibilityCallToolResult>;
|
|
26
|
+
private callMediaUpload;
|
|
27
|
+
private callSingleUpload;
|
|
28
|
+
private callResumableUpload;
|
|
29
|
+
compact(_api: GoogleDiscoveryApiConfig, tool: Tool): CompactTool;
|
|
30
|
+
search(api: GoogleDiscoveryApiConfig, tools: Tool[], query: string, limit: number): CompactTool[];
|
|
31
|
+
resolveAuthScopes(api: GoogleDiscoveryApiConfig): Promise<string[]>;
|
|
32
|
+
private getOperation;
|
|
33
|
+
private refreshOperations;
|
|
34
|
+
private toTool;
|
|
35
|
+
resolveBaseUrl(api: GoogleDiscoveryApiConfig): Promise<string | undefined>;
|
|
36
|
+
private resolveRequestApi;
|
|
37
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type GoogleDiscoveryHttpMethod = "get" | "put" | "post" | "delete" | "patch" | "head";
|
|
2
|
+
export type GoogleDiscoveryOperation = {
|
|
3
|
+
name: string;
|
|
4
|
+
method: GoogleDiscoveryHttpMethod;
|
|
5
|
+
path: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
inputSchema: Record<string, unknown>;
|
|
8
|
+
outputSchema?: Record<string, unknown>;
|
|
9
|
+
readOnlyHint: boolean;
|
|
10
|
+
destructiveHint: boolean;
|
|
11
|
+
scopes: string[];
|
|
12
|
+
supportsMediaUpload: boolean;
|
|
13
|
+
supportsMediaDownload: boolean;
|
|
14
|
+
mediaUpload?: {
|
|
15
|
+
accept?: string[];
|
|
16
|
+
maxSize?: string;
|
|
17
|
+
};
|
|
18
|
+
mediaUploadProtocols: Record<string, {
|
|
19
|
+
path?: string;
|
|
20
|
+
multipart?: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
parameterOrder: string[];
|
|
23
|
+
};
|
|
24
|
+
export type DiscoveryOperationsOptions = {
|
|
25
|
+
server: string;
|
|
26
|
+
document: unknown;
|
|
27
|
+
includeOperations?: string[];
|
|
28
|
+
excludeOperations?: string[];
|
|
29
|
+
};
|
|
30
|
+
export declare function discoveryOperations(options: DiscoveryOperationsOptions): GoogleDiscoveryOperation[];
|
|
31
|
+
export declare function googleDiscoveryScopesForOperations(operations: GoogleDiscoveryOperation[]): string[];
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GoogleDiscoveryApiConfig } from "../config";
|
|
2
|
+
import type { GoogleDiscoveryOperation } from "./operations";
|
|
3
|
+
export declare function buildGoogleDiscoveryUrl(api: GoogleDiscoveryApiConfig, operation: GoogleDiscoveryOperation, args: Record<string, unknown>): URL;
|
|
4
|
+
export declare function buildGoogleDiscoveryUploadUrl(api: GoogleDiscoveryApiConfig, operation: GoogleDiscoveryOperation, uploadPath: string, uploadType: "media" | "multipart" | "resumable", args: Record<string, unknown>): URL;
|
|
5
|
+
export declare function buildJsonRequestInit(operation: GoogleDiscoveryOperation, args: Record<string, unknown>, headers: Headers): RequestInit;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type GoogleDiscoveryDocument = {
|
|
2
|
+
kind?: string;
|
|
3
|
+
id?: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
version?: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
rootUrl?: string;
|
|
8
|
+
servicePath?: string;
|
|
9
|
+
baseUrl?: string;
|
|
10
|
+
auth?: {
|
|
11
|
+
oauth2?: {
|
|
12
|
+
scopes?: Record<string, {
|
|
13
|
+
description?: string;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
parameters?: Record<string, GoogleDiscoveryParameter>;
|
|
18
|
+
schemas?: Record<string, GoogleDiscoverySchema>;
|
|
19
|
+
methods?: Record<string, GoogleDiscoveryMethod>;
|
|
20
|
+
resources?: Record<string, GoogleDiscoveryResource>;
|
|
21
|
+
};
|
|
22
|
+
export type GoogleDiscoveryResource = {
|
|
23
|
+
methods?: Record<string, GoogleDiscoveryMethod>;
|
|
24
|
+
resources?: Record<string, GoogleDiscoveryResource>;
|
|
25
|
+
};
|
|
26
|
+
export type GoogleDiscoveryMethod = {
|
|
27
|
+
id?: string;
|
|
28
|
+
path?: string;
|
|
29
|
+
flatPath?: string;
|
|
30
|
+
httpMethod?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
parameters?: Record<string, GoogleDiscoveryParameter>;
|
|
33
|
+
parameterOrder?: string[];
|
|
34
|
+
request?: {
|
|
35
|
+
$ref?: string;
|
|
36
|
+
};
|
|
37
|
+
response?: {
|
|
38
|
+
$ref?: string;
|
|
39
|
+
};
|
|
40
|
+
scopes?: string[];
|
|
41
|
+
supportsMediaUpload?: boolean;
|
|
42
|
+
supportsMediaDownload?: boolean;
|
|
43
|
+
mediaUpload?: {
|
|
44
|
+
accept?: string[];
|
|
45
|
+
maxSize?: string;
|
|
46
|
+
protocols?: Record<string, {
|
|
47
|
+
path?: string;
|
|
48
|
+
multipart?: boolean;
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
export type GoogleDiscoveryParameter = GoogleDiscoverySchema & {
|
|
53
|
+
location?: "path" | "query" | "header" | "body" | "media";
|
|
54
|
+
required?: boolean;
|
|
55
|
+
repeated?: boolean;
|
|
56
|
+
deprecated?: boolean;
|
|
57
|
+
};
|
|
58
|
+
export type GoogleDiscoverySchema = {
|
|
59
|
+
id?: string;
|
|
60
|
+
$ref?: string;
|
|
61
|
+
type?: string;
|
|
62
|
+
format?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
default?: unknown;
|
|
65
|
+
enum?: string[];
|
|
66
|
+
repeated?: boolean;
|
|
67
|
+
properties?: Record<string, GoogleDiscoverySchema>;
|
|
68
|
+
items?: GoogleDiscoverySchema;
|
|
69
|
+
additionalProperties?: GoogleDiscoverySchema | boolean;
|
|
70
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MediaArtifact } from "../media";
|
|
2
|
+
export type ReadHttpLikeResponseOptions = {
|
|
3
|
+
capletId: string;
|
|
4
|
+
method?: string;
|
|
5
|
+
artifactDir?: string;
|
|
6
|
+
outputPath?: string;
|
|
7
|
+
filename?: string;
|
|
8
|
+
maxInlineBytes?: number;
|
|
9
|
+
maxBytes?: number;
|
|
10
|
+
forceArtifact?: boolean;
|
|
11
|
+
exposeLocalPath?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare function readHttpLikeResponse(response: Response, options: ReadHttpLikeResponseOptions): Promise<Record<string, unknown>>;
|
|
14
|
+
export type { MediaArtifact };
|
package/dist/http-actions.d.ts
CHANGED
|
@@ -7,6 +7,9 @@ export declare class HttpActionManager {
|
|
|
7
7
|
private readonly options;
|
|
8
8
|
constructor(registry: ServerRegistry, options?: {
|
|
9
9
|
authDir?: string;
|
|
10
|
+
artifactDir?: string;
|
|
11
|
+
exposeLocalArtifactPaths?: boolean;
|
|
12
|
+
maxInlineBytes?: number;
|
|
10
13
|
});
|
|
11
14
|
updateRegistry(registry: ServerRegistry): void;
|
|
12
15
|
invalidate(_serverId: string): void;
|