@caplets/core 0.22.0 → 0.23.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/commands.d.ts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/code-mode/diagnostics-builtins.generated.d.ts +1 -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.js +18 -13
- package/dist/{completion-DnQujlrc.js → completion-BC4BNWo0.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 +100 -18
- 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/service.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/runtime-plan.js +1 -1
- package/dist/runtime.d.ts +2 -0
- package/dist/{service-4_chB2wu.js → service-CSRCJfpA.js} +1711 -187
- package/dist/tools.d.ts +2 -1
- package/package.json +9 -2
package/dist/code-mode.js
CHANGED
|
@@ -41,7 +41,7 @@ function capletHintText(caplet) {
|
|
|
41
41
|
].filter((value) => Boolean(value)).join(" ");
|
|
42
42
|
}
|
|
43
43
|
function minifyCodeModeDeclarationText(value) {
|
|
44
|
-
return value.replace(/^\s*export\s*\{\s*\}\s*;?\s*/u, "").replace(/\r\n?/gu, "\n").split("\n").map((line) => line.trim()).filter(Boolean).join(" ").replace(/\s+/gu, " ").replace(/\s*([{}()[\]:;,|&=])\s*/gu, "$1").replace(/\s*<\s*/gu, "<").replace(/\s*>\s*/gu, ">").replace(/\?\s*:/gu, "?:").trim();
|
|
44
|
+
return value.replace(/^\s*export\s*\{\s*\}\s*;?\s*/u, "").replace(/\s*export\s*\{\s*\}\s*;?\s*$/u, "").replace(/\r\n?/gu, "\n").split("\n").map((line) => line.trim()).filter(Boolean).join(" ").replace(/\s+/gu, " ").replace(/\s*([{}()[\]:;,|&=])\s*/gu, "$1").replace(/\s*<\s*/gu, "<").replace(/\s*>\s*/gu, ">").replace(/\?\s*:/gu, "?:").trim();
|
|
45
45
|
}
|
|
46
46
|
function codeModeDeclarationHash(declaration) {
|
|
47
47
|
return [
|
|
@@ -12678,7 +12678,7 @@ const PARSER_OPTIONS = {
|
|
|
12678
12678
|
]
|
|
12679
12679
|
};
|
|
12680
12680
|
function hasDirectFetchCall(code) {
|
|
12681
|
-
return hasMatchingAstNode(code,
|
|
12681
|
+
return hasMatchingAstNode(code, isDirectFetchCallNode);
|
|
12682
12682
|
}
|
|
12683
12683
|
function hasExecutableImport(code) {
|
|
12684
12684
|
return hasMatchingAstNode(code, isExecutableImportNode);
|
|
@@ -12687,9 +12687,9 @@ function hasMatchingAstNode(code, predicate) {
|
|
|
12687
12687
|
const ast = parseCode(code);
|
|
12688
12688
|
if (!ast) return false;
|
|
12689
12689
|
let found = false;
|
|
12690
|
-
visitAst(ast, (node) => {
|
|
12690
|
+
visitAst(ast, (node, parent) => {
|
|
12691
12691
|
if (found) return;
|
|
12692
|
-
found = predicate(node);
|
|
12692
|
+
found = predicate(node, parent);
|
|
12693
12693
|
});
|
|
12694
12694
|
return found;
|
|
12695
12695
|
}
|
|
@@ -12707,11 +12707,10 @@ function isExecutableImportNode(node) {
|
|
|
12707
12707
|
function isCallExpression(node) {
|
|
12708
12708
|
return (node.type === "CallExpression" || node.type === "OptionalCallExpression") && "callee" in node;
|
|
12709
12709
|
}
|
|
12710
|
-
function
|
|
12711
|
-
if (!isNode(
|
|
12712
|
-
if (
|
|
12713
|
-
|
|
12714
|
-
return false;
|
|
12710
|
+
function isDirectFetchCallNode(node) {
|
|
12711
|
+
if (!isCallExpression(node) || !isNode(node.callee)) return false;
|
|
12712
|
+
if (isIdentifierNamed(node.callee, "fetch")) return true;
|
|
12713
|
+
return (node.callee.type === "MemberExpression" || node.callee.type === "OptionalMemberExpression") && isGlobalFetchMember(node.callee);
|
|
12715
12714
|
}
|
|
12716
12715
|
function isGlobalFetchMember(node) {
|
|
12717
12716
|
if (!isIdentifierNamed(node.object, "globalThis", "window", "self")) return false;
|
|
@@ -12721,16 +12720,22 @@ function isGlobalFetchMember(node) {
|
|
|
12721
12720
|
function isExportDeclaration(node) {
|
|
12722
12721
|
return node.type === "ExportAllDeclaration" || node.type === "ExportDefaultDeclaration" || node.type === "ExportNamedDeclaration";
|
|
12723
12722
|
}
|
|
12724
|
-
function visitAst(value, visit) {
|
|
12723
|
+
function visitAst(value, visit, parent) {
|
|
12725
12724
|
if (!isNode(value)) return;
|
|
12726
|
-
visit(value);
|
|
12725
|
+
visit(value, parent);
|
|
12727
12726
|
for (const [key, child] of Object.entries(value)) {
|
|
12728
12727
|
if (key === "loc" || key === "start" || key === "end" || key === "extra") continue;
|
|
12729
12728
|
if (Array.isArray(child)) {
|
|
12730
|
-
for (const item of child) visitAst(item, visit
|
|
12729
|
+
for (const item of child) visitAst(item, visit, {
|
|
12730
|
+
node: value,
|
|
12731
|
+
key
|
|
12732
|
+
});
|
|
12731
12733
|
continue;
|
|
12732
12734
|
}
|
|
12733
|
-
visitAst(child, visit
|
|
12735
|
+
visitAst(child, visit, {
|
|
12736
|
+
node: value,
|
|
12737
|
+
key
|
|
12738
|
+
});
|
|
12734
12739
|
}
|
|
12735
12740
|
}
|
|
12736
12741
|
function isNode(value) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as loadConfigWithSources, Cn as __exportAll, Dt as resolveProjectConfigPath, Tt as resolveConfigPath, vt as DEFAULT_AUTH_DIR, wt as resolveCapletsRoot, yt as DEFAULT_COMPLETION_CACHE_DIR } from "./service-CSRCJfpA.js";
|
|
2
2
|
import { u as CapletsError } from "./validation-DgxCzt-A.js";
|
|
3
3
|
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
@@ -75,6 +75,7 @@ const cliSubcommands = {
|
|
|
75
75
|
"cli",
|
|
76
76
|
"mcp",
|
|
77
77
|
"openapi",
|
|
78
|
+
"google-discovery",
|
|
78
79
|
"graphql",
|
|
79
80
|
"http"
|
|
80
81
|
],
|
|
@@ -142,6 +143,7 @@ function allCaplets(config) {
|
|
|
142
143
|
return [
|
|
143
144
|
...Object.values(config.mcpServers),
|
|
144
145
|
...Object.values(config.openapiEndpoints),
|
|
146
|
+
...Object.values(config.googleDiscoveryApis ?? {}),
|
|
145
147
|
...Object.values(config.graphqlEndpoints),
|
|
146
148
|
...Object.values(config.httpApis),
|
|
147
149
|
...Object.values(config.cliTools),
|
|
@@ -383,6 +385,16 @@ function secretFreeServerShape(server) {
|
|
|
383
385
|
authType: server.auth.type,
|
|
384
386
|
requestTimeoutMs: server.requestTimeoutMs
|
|
385
387
|
};
|
|
388
|
+
case "googleDiscovery": return {
|
|
389
|
+
...base,
|
|
390
|
+
discoveryPath: server.discoveryPath,
|
|
391
|
+
discoveryUrl: server.discoveryUrl,
|
|
392
|
+
baseUrl: server.baseUrl,
|
|
393
|
+
includeOperations: server.includeOperations,
|
|
394
|
+
excludeOperations: server.excludeOperations,
|
|
395
|
+
authType: server.auth.type,
|
|
396
|
+
requestTimeoutMs: server.requestTimeoutMs
|
|
397
|
+
};
|
|
386
398
|
case "graphql": return {
|
|
387
399
|
...base,
|
|
388
400
|
endpointUrl: server.endpointUrl,
|
|
@@ -441,7 +453,7 @@ async function withTimeout(promise, timeoutMs) {
|
|
|
441
453
|
}
|
|
442
454
|
}
|
|
443
455
|
function enabledServer(serverId, config) {
|
|
444
|
-
const server = config.mcpServers[serverId] ?? config.openapiEndpoints[serverId] ?? config.graphqlEndpoints[serverId] ?? config.httpApis[serverId] ?? config.cliTools[serverId] ?? config.capletSets[serverId];
|
|
456
|
+
const server = config.mcpServers[serverId] ?? config.openapiEndpoints[serverId] ?? config.googleDiscoveryApis[serverId] ?? config.graphqlEndpoints[serverId] ?? config.httpApis[serverId] ?? config.cliTools[serverId] ?? config.capletSets[serverId];
|
|
445
457
|
return server && !server.disabled ? server : void 0;
|
|
446
458
|
}
|
|
447
459
|
function dedupeCandidates(candidates) {
|
package/dist/config/paths.d.ts
CHANGED
|
@@ -5,10 +5,12 @@ export declare function defaultStateBaseDir(env?: PathEnv, home?: string, platfo
|
|
|
5
5
|
export declare function defaultCacheBaseDir(env?: PathEnv, home?: string, platform?: Platform): string;
|
|
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
|
+
export declare function defaultArtifactDir(env?: PathEnv, home?: string, platform?: Platform): string;
|
|
8
9
|
export declare function defaultCompletionCacheDir(env?: PathEnv, home?: string, platform?: Platform): string;
|
|
9
10
|
export declare function defaultObservedOutputShapeCacheDir(env?: PathEnv, home?: string, platform?: Platform): string;
|
|
10
11
|
export declare const DEFAULT_CONFIG_PATH: string;
|
|
11
12
|
export declare const DEFAULT_AUTH_DIR: string;
|
|
13
|
+
export declare const DEFAULT_ARTIFACT_DIR: string;
|
|
12
14
|
export declare const DEFAULT_COMPLETION_CACHE_DIR: string;
|
|
13
15
|
export declare const DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR: string;
|
|
14
16
|
export declare const PROJECT_CONFIG_FILE: string;
|
package/dist/config-runtime.d.ts
CHANGED
|
@@ -73,6 +73,17 @@ export type OpenApiEndpointConfig = CommonCapletConfig & {
|
|
|
73
73
|
requestTimeoutMs: number;
|
|
74
74
|
operationCacheTtlMs: number;
|
|
75
75
|
};
|
|
76
|
+
export type GoogleDiscoveryApiConfig = CommonCapletConfig & {
|
|
77
|
+
backend: "googleDiscovery";
|
|
78
|
+
discoveryPath?: string | undefined;
|
|
79
|
+
discoveryUrl?: string | undefined;
|
|
80
|
+
baseUrl?: string | undefined;
|
|
81
|
+
includeOperations?: string[] | undefined;
|
|
82
|
+
excludeOperations?: string[] | undefined;
|
|
83
|
+
auth: OpenApiAuthConfig;
|
|
84
|
+
requestTimeoutMs: number;
|
|
85
|
+
operationCacheTtlMs: number;
|
|
86
|
+
};
|
|
76
87
|
export type GraphQlOperationConfig = AgentSelectionHintsConfig & {
|
|
77
88
|
document?: string | undefined;
|
|
78
89
|
documentPath?: string | undefined;
|
|
@@ -145,7 +156,7 @@ export type CapletSetConfig = CommonCapletConfig & {
|
|
|
145
156
|
maxSearchLimit: number;
|
|
146
157
|
toolCacheTtlMs: number;
|
|
147
158
|
};
|
|
148
|
-
export type CapletConfig = CapletServerConfig | OpenApiEndpointConfig | GraphQlEndpointConfig | HttpApiConfig | CliToolsConfig | CapletSetConfig;
|
|
159
|
+
export type CapletConfig = CapletServerConfig | OpenApiEndpointConfig | GoogleDiscoveryApiConfig | GraphQlEndpointConfig | HttpApiConfig | CliToolsConfig | CapletSetConfig;
|
|
149
160
|
export type CapletsConfig = {
|
|
150
161
|
version: 1;
|
|
151
162
|
options: {
|
|
@@ -163,6 +174,7 @@ export type CapletsConfig = {
|
|
|
163
174
|
};
|
|
164
175
|
mcpServers: Record<string, CapletServerConfig>;
|
|
165
176
|
openapiEndpoints: Record<string, OpenApiEndpointConfig>;
|
|
177
|
+
googleDiscoveryApis: Record<string, GoogleDiscoveryApiConfig>;
|
|
166
178
|
graphqlEndpoints: Record<string, GraphQlEndpointConfig>;
|
|
167
179
|
httpApis: Record<string, HttpApiConfig>;
|
|
168
180
|
cliTools: Record<string, CliToolsConfig>;
|
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;
|