@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/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as loadConfigWithSources, $t as ListResourcesRequestSchema, A as codeModeRunParamsSchema, At as assertClientRequestTaskCapability, B as generateCodeModeRunToolDescription, Bt as CreateMessageResultWithToolsSchema, C as nativeCapletPromptGuidance, Ct as defaultStateBaseDir, D as nativeCodeModeToolId, Dt as resolveProjectConfigPath, Et as resolveProjectCapletsRoot, F as listCodeModeCallableCaplets, Ft as toJsonSchemaCompat, G as directResourceUriMatchesTemplate, Gt as ErrorCode, H as CapletsEngine, I as CodeModeLogStore, It as CallToolRequestSchema, J as handleServerTool, Jt as InitializedNotificationSchema, K as findProjectRoot, Kt as GetPromptRequestSchema, L as redactCodeModeLogText, Lt as CallToolResultSchema, M as QuickJsCodeModeSandbox, Mt as AjvJsonSchemaValidator, N as diagnoseCodeModeTypeScript, Nt as Protocol, Ot as ReadBuffer, P as createCodeModeCapletsApi, Pt as mergeCapabilities, Q as loadConfig, Qt as ListResourceTemplatesRequestSchema, R as codeModeDeclarationHash, Rt as CompleteRequestSchema, S as resolveCapletsServer, Sn as safeParseAsync, St as defaultConfigBaseDir, T as nativeCapletToolName, Tt as resolveConfigPath, U as resolveExposure, Ut as ElicitResultSchema, V as minifyCodeModeDeclarationText, Vt as CreateTaskResultSchema, W as decodeDirectResourceUri, Wt as EmptyResultSchema, X as capabilityDescription, Xt as LATEST_PROTOCOL_VERSION, Y as ServerRegistry, Yt as JSONRPCMessageSchema, Z as GoogleDiscoveryManager, Zt as ListPromptsRequestSchema, _ as resolveHostedCloudRemote, _n as isSchemaOptional, _t as readTokenBundle, a as projectBindingError, an as SUPPORTED_PROTOCOL_VERSIONS, at as validateCapletFile, b as parseServerBaseUrl, bn as objectFromShape, bt as DEFAULT_OBSERVED_OUTPUT_SHAPE_CACHE_DIR, c as cloudAuthPath, cn as assertCompleteRequestResourceTemplate, ct as markdownCallToolResultContent, d as CloudAuthClient, dn as isJSONRPCRequest, dt as runGenericOAuthFlow, en as ListRootsResultSchema, et as loadGlobalConfig, fn as isJSONRPCResultResponse, ft as runOAuthFlow, g as resolveCapletsRemote, gn as getSchemaDescription, gt as isTokenBundleExpired, hn as getParseErrorMessage, ht as deleteTokenBundle, i as ProjectBindingError, in as ReadResourceRequestSchema, it as discoverCapletFiles, j as runCodeMode, jt as assertToolsCallTaskCapability, k as codeModeRunInputSchema, kt as serializeMessage, l as migrateCredentials, ln as isInitializeRequest, lt as markdownStructuredContent, m as buildProjectSyncManifest, mn as getObjectShape, mt as startOAuthFlow, n as resolveRemoteSelection, nn as LoggingLevelSchema, nt as loadProjectConfig, o as projectBindingRecovery, on as SetLevelRequestSchema, ot as loadCapletFilesFromMap, p as createSdkRemoteCapletsClient, pn as getLiteralValue, pt as startGenericOAuthFlow, q as fingerprintProjectRoot, qt as InitializeRequestSchema, r as PROJECT_BINDING_ERROR_CODES, rn as McpError, rt as parseConfig, s as CloudAuthStore, sn as assertCompleteRequestPrompt, st as hasRenderableStructuredContent, t as createNativeCapletsService, tn as ListToolsRequestSchema, tt as loadLocalOverlayConfigWithSources, u as redactedCloudAuthStatus, un as isJSONRPCErrorResponse, ut as refreshOAuthTokenBundle, v as resolveRemoteMode, vn as isZ4Schema, w as nativeCapletToolDescription, wt as resolveCapletsRoot, x as resolveCapletsMode, xn as safeParse, xt as defaultCacheBaseDir, y as controlUrlForBase, yn as normalizeObjectSchema, z as generateCodeModeDeclarations, zt as CreateMessageResultSchema } from "./service-CSRCJfpA.js";
|
|
2
2
|
import { _ as record, b as unknown, d as literal, m as object, n as ZodOptional, o as array, p as number, r as _enum, s as boolean, v as string, x as url } from "./schemas-C0PNPwjS.js";
|
|
3
3
|
import { f as redactSecrets, i as SERVER_ID_PATTERN, l as CAPLETS_ERROR_CODES, p as toSafeError, u as CapletsError } from "./validation-DgxCzt-A.js";
|
|
4
4
|
import { generatedToolInputJsonSchemaForCaplet, generatedToolInputSchema, generatedToolInputSchemaForCaplet } from "./generated-tool-input-schema.js";
|
|
5
|
-
import { f as observedOutputShapeKey, g as stableJsonStringify, h as schemaHash, i as observeOutputShape, u as FileObservedOutputShapeStore } from "./observed-output-shapes-
|
|
6
|
-
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands$1, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-
|
|
5
|
+
import { f as observedOutputShapeKey, g as stableJsonStringify, h as schemaHash, i as observeOutputShape, u as FileObservedOutputShapeStore } from "./observed-output-shapes-D2k2-q8K.js";
|
|
6
|
+
import { a as formatCapletList, c as resolveCliConfigPaths, l as cliCommands$1, n as completionScript, o as formatConfigPaths, s as listCaplets, t as completeCliWords, u as completionShells } from "./completion-BC4BNWo0.js";
|
|
7
7
|
import { n as normalizeCapletSourcePath, t as FilesystemCapletSource } from "./filesystem-Kkg32TOJ.js";
|
|
8
8
|
import { parseConfig as parseConfig$1 } from "./config-runtime.js";
|
|
9
9
|
import fs, { accessSync, chmodSync, closeSync, constants, copyFileSync, cpSync, existsSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readdirSync, readlinkSync, realpathSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
@@ -1553,7 +1553,7 @@ const EMPTY_COMPLETION_RESULT = { completion: {
|
|
|
1553
1553
|
} };
|
|
1554
1554
|
//#endregion
|
|
1555
1555
|
//#region package.json
|
|
1556
|
-
var version = "0.
|
|
1556
|
+
var version = "0.23.0";
|
|
1557
1557
|
//#endregion
|
|
1558
1558
|
//#region src/serve/session.ts
|
|
1559
1559
|
var CapletsMcpSession = class {
|
|
@@ -1895,6 +1895,8 @@ function engineOptions(options) {
|
|
|
1895
1895
|
if (options.configPath !== void 0) engineOptions.configPath = options.configPath;
|
|
1896
1896
|
if (options.projectConfigPath !== void 0) engineOptions.projectConfigPath = options.projectConfigPath;
|
|
1897
1897
|
if (options.authDir !== void 0) engineOptions.authDir = options.authDir;
|
|
1898
|
+
if (options.artifactDir !== void 0) engineOptions.artifactDir = options.artifactDir;
|
|
1899
|
+
if (options.exposeLocalArtifactPaths !== void 0) engineOptions.exposeLocalArtifactPaths = options.exposeLocalArtifactPaths;
|
|
1898
1900
|
if (options.watchDebounceMs !== void 0) engineOptions.watchDebounceMs = options.watchDebounceMs;
|
|
1899
1901
|
if (options.writeErr !== void 0) engineOptions.writeErr = options.writeErr;
|
|
1900
1902
|
return engineOptions;
|
|
@@ -4994,7 +4996,7 @@ function isPackageCommand(command) {
|
|
|
4994
4996
|
function renderCaplet(input) {
|
|
4995
4997
|
const lines = [
|
|
4996
4998
|
"---",
|
|
4997
|
-
"$schema
|
|
4999
|
+
"# yaml-language-server: $schema=https://caplets.dev/caplet.schema.json",
|
|
4998
5000
|
`name: ${yamlString$1(input.name)}`,
|
|
4999
5001
|
`description: ${yamlString$1(input.description)}`,
|
|
5000
5002
|
"tags:",
|
|
@@ -5081,6 +5083,15 @@ function addOpenApiCaplet(id, options) {
|
|
|
5081
5083
|
["auth", authFromTokenEnv(options.tokenEnv) ?? { type: "none" }]
|
|
5082
5084
|
], options);
|
|
5083
5085
|
}
|
|
5086
|
+
function addGoogleDiscoveryCaplet(id, options) {
|
|
5087
|
+
const discovery = options.discovery ?? options.discoveryUrl;
|
|
5088
|
+
if (!discovery) throw new CapletsError("REQUEST_INVALID", "Google Discovery Caplet requires --discovery or --discovery-url");
|
|
5089
|
+
return writeGeneratedCaplet(id, "Google Discovery", "googleDiscoveryApi", [
|
|
5090
|
+
[options.discoveryUrl ? "discoveryUrl" : isUrlLike(discovery) ? "discoveryUrl" : "discoveryPath", discovery],
|
|
5091
|
+
["baseUrl", options.baseUrl],
|
|
5092
|
+
["auth", authFromTokenEnv(options.tokenEnv) ?? { type: "none" }]
|
|
5093
|
+
], options);
|
|
5094
|
+
}
|
|
5084
5095
|
function addGraphqlCaplet(id, options) {
|
|
5085
5096
|
if (!options.endpointUrl) throw new CapletsError("REQUEST_INVALID", "GraphQL Caplet requires --endpoint-url");
|
|
5086
5097
|
if (Boolean(options.schema) === Boolean(options.introspection)) throw new CapletsError("REQUEST_INVALID", "GraphQL Caplet requires exactly one of --schema or --introspection");
|
|
@@ -5183,7 +5194,7 @@ function resolvePrintOutputPath(id, options) {
|
|
|
5183
5194
|
}
|
|
5184
5195
|
function renderLocalPaths(fields, outputDir) {
|
|
5185
5196
|
return fields.map(([key, value]) => {
|
|
5186
|
-
if (key !== "specPath" && key !== "schemaPath" || typeof value !== "string") return [key, value];
|
|
5197
|
+
if (key !== "specPath" && key !== "schemaPath" && key !== "discoveryPath" || typeof value !== "string") return [key, value];
|
|
5187
5198
|
return [key, localPathRelativeToOutput(value, outputDir)];
|
|
5188
5199
|
});
|
|
5189
5200
|
}
|
|
@@ -5234,7 +5245,7 @@ function renderBackendCaplet(id, label, backend, fields) {
|
|
|
5234
5245
|
const description = `${label} backend Caplet generated by caplets add.`;
|
|
5235
5246
|
const lines = [
|
|
5236
5247
|
"---",
|
|
5237
|
-
"$schema: https://caplets.dev/caplet
|
|
5248
|
+
"$schema: https://caplets.dev/caplet.schema.json",
|
|
5238
5249
|
`name: ${yamlString(name)}`,
|
|
5239
5250
|
`description: ${yamlString(description)}`,
|
|
5240
5251
|
"tags:",
|
|
@@ -5343,7 +5354,7 @@ function collectFiles(root) {
|
|
|
5343
5354
|
//#endregion
|
|
5344
5355
|
//#region src/cli/auth.ts
|
|
5345
5356
|
async function loginAuth(serverId, options) {
|
|
5346
|
-
const server =
|
|
5357
|
+
const server = await resolveAuthTarget$1(serverId, options.config ?? loadConfig(options.configPath), options.authDir);
|
|
5347
5358
|
assertLoginTarget(server, serverId);
|
|
5348
5359
|
try {
|
|
5349
5360
|
const flowOptions = {
|
|
@@ -5376,7 +5387,7 @@ async function refreshAuth(serverId, options) {
|
|
|
5376
5387
|
options.writeOut(`Refreshed OAuth credentials for \`${serverId}\`.\n`);
|
|
5377
5388
|
}
|
|
5378
5389
|
async function refreshAuthResult(serverId, options) {
|
|
5379
|
-
const target =
|
|
5390
|
+
const target = await resolveAuthTarget$1(serverId, options.config ?? loadConfig(options.configPath), options.authDir);
|
|
5380
5391
|
assertLoginTarget(target, serverId);
|
|
5381
5392
|
await refreshOAuthTokenBundle(target, options.authDir);
|
|
5382
5393
|
return { server: serverId };
|
|
@@ -5450,14 +5461,35 @@ function formatAuthRows(rows, format) {
|
|
|
5450
5461
|
function findAuthTarget(serverId, config = loadConfig()) {
|
|
5451
5462
|
return authTargets(config).find((server) => server.server === serverId);
|
|
5452
5463
|
}
|
|
5464
|
+
async function resolveAuthTarget$1(serverId, config, authDir) {
|
|
5465
|
+
const target = findAuthTarget(serverId, config);
|
|
5466
|
+
if (target?.backend !== "googleDiscovery") return target;
|
|
5467
|
+
const api = config.googleDiscoveryApis[serverId];
|
|
5468
|
+
if (!api || api.auth.type !== "oauth2" && api.auth.type !== "oidc") return target;
|
|
5469
|
+
const manager = new GoogleDiscoveryManager(new ServerRegistry(config), authDir ? { authDir } : {});
|
|
5470
|
+
const baseUrl = api.baseUrl ?? await manager.resolveBaseUrl(api).catch(() => void 0) ?? api.discoveryUrl;
|
|
5471
|
+
return {
|
|
5472
|
+
...target,
|
|
5473
|
+
...baseUrl ? { baseUrl } : {},
|
|
5474
|
+
...api.auth.scopes?.length ? {} : { resolvedScopes: await manager.resolveAuthScopes(api) }
|
|
5475
|
+
};
|
|
5476
|
+
}
|
|
5453
5477
|
function authTargets(config) {
|
|
5454
5478
|
return [
|
|
5455
5479
|
...Object.values(config.mcpServers).filter((server) => server.transport !== "stdio" && (server.auth?.type === "oauth2" || server.auth?.type === "oidc")),
|
|
5456
5480
|
...Object.values(config.openapiEndpoints).filter((endpoint) => endpoint.auth?.type === "oauth2" || endpoint.auth?.type === "oidc"),
|
|
5481
|
+
...Object.values(config.googleDiscoveryApis).filter((api) => api.auth?.type === "oauth2" || api.auth?.type === "oidc").map(googleDiscoveryAuthTarget),
|
|
5457
5482
|
...Object.values(config.graphqlEndpoints).filter((endpoint) => endpoint.auth?.type === "oauth2" || endpoint.auth?.type === "oidc").map(graphQlAuthTarget),
|
|
5458
5483
|
...Object.values(config.httpApis).filter((api) => api.auth?.type === "oauth2" || api.auth?.type === "oidc").map(httpAuthTarget)
|
|
5459
5484
|
];
|
|
5460
5485
|
}
|
|
5486
|
+
function googleDiscoveryAuthTarget(api) {
|
|
5487
|
+
const baseUrl = api.baseUrl ?? api.discoveryUrl;
|
|
5488
|
+
return {
|
|
5489
|
+
...api,
|
|
5490
|
+
...baseUrl ? { baseUrl } : {}
|
|
5491
|
+
};
|
|
5492
|
+
}
|
|
5461
5493
|
function graphQlAuthTarget(endpoint) {
|
|
5462
5494
|
return {
|
|
5463
5495
|
...endpoint,
|
|
@@ -6090,6 +6122,7 @@ function allCaplets(config) {
|
|
|
6090
6122
|
return [
|
|
6091
6123
|
...Object.values(typed.mcpServers ?? {}),
|
|
6092
6124
|
...Object.values(typed.openapiEndpoints ?? {}),
|
|
6125
|
+
...Object.values(typed.googleDiscoveryApis ?? {}),
|
|
6093
6126
|
...Object.values(typed.graphqlEndpoints ?? {}),
|
|
6094
6127
|
...Object.values(typed.httpApis ?? {}),
|
|
6095
6128
|
...Object.values(typed.cliTools ?? {}),
|
|
@@ -6690,6 +6723,7 @@ async function runCapletSetupCli(capletId, options = {}) {
|
|
|
6690
6723
|
const caplet = Object.values({
|
|
6691
6724
|
...config.mcpServers,
|
|
6692
6725
|
...config.openapiEndpoints,
|
|
6726
|
+
...config.googleDiscoveryApis,
|
|
6693
6727
|
...config.graphqlEndpoints,
|
|
6694
6728
|
...config.httpApis,
|
|
6695
6729
|
...config.cliTools,
|
|
@@ -6815,6 +6849,8 @@ async function runSetup(integration, options = {}) {
|
|
|
6815
6849
|
if (!setupIntegrationIds.includes(integration)) return await runCapletSetupCli(integration, {
|
|
6816
6850
|
...options.yes === void 0 ? {} : { yes: options.yes },
|
|
6817
6851
|
target: resolveSetupTargetKind(options),
|
|
6852
|
+
...options.env?.CAPLETS_CONFIG ? { configPath: options.env.CAPLETS_CONFIG } : {},
|
|
6853
|
+
...options.env?.CAPLETS_PROJECT_CONFIG ? { projectConfigPath: options.env.CAPLETS_PROJECT_CONFIG } : {},
|
|
6818
6854
|
...options.remote === void 0 && !isRemoteSetup(options) ? {} : { remote: isRemoteSetup(options) }
|
|
6819
6855
|
});
|
|
6820
6856
|
const result = await executeSetup(integration, options);
|
|
@@ -10974,7 +11010,7 @@ async function dispatch(request, context) {
|
|
|
10974
11010
|
async function startRemoteAuthLogin(serverId, context) {
|
|
10975
11011
|
if (!context.authFlowStore || !context.controlCallbackBaseUrl) throw new CapletsError("REQUEST_INVALID", "Remote auth login is not available on this server");
|
|
10976
11012
|
const config = loadConfigWithSources(context.configPath, context.projectConfigPath).config;
|
|
10977
|
-
const target =
|
|
11013
|
+
const target = await resolveAuthTarget$1(serverId, config, context.authDir);
|
|
10978
11014
|
assertLoginTarget(target, serverId);
|
|
10979
11015
|
const flowId = randomUUID();
|
|
10980
11016
|
const baseUrl = context.controlCallbackBaseUrl.endsWith("/") ? context.controlCallbackBaseUrl : `${context.controlCallbackBaseUrl}/`;
|
|
@@ -11043,6 +11079,16 @@ function dispatchAdd(args, context) {
|
|
|
11043
11079
|
print: false
|
|
11044
11080
|
})
|
|
11045
11081
|
};
|
|
11082
|
+
case "google-discovery":
|
|
11083
|
+
case "googleDiscovery": return {
|
|
11084
|
+
remote: true,
|
|
11085
|
+
label: "Google Discovery",
|
|
11086
|
+
...addGoogleDiscoveryCaplet(id, {
|
|
11087
|
+
...options,
|
|
11088
|
+
destinationRoot: context.projectCapletsRoot,
|
|
11089
|
+
print: false
|
|
11090
|
+
})
|
|
11091
|
+
};
|
|
11046
11092
|
case "graphql": return {
|
|
11047
11093
|
remote: true,
|
|
11048
11094
|
label: "GraphQL",
|
|
@@ -11061,7 +11107,7 @@ function dispatchAdd(args, context) {
|
|
|
11061
11107
|
print: false
|
|
11062
11108
|
})
|
|
11063
11109
|
};
|
|
11064
|
-
default: throw new CapletsError("REQUEST_INVALID", "add.kind must be cli, mcp, openapi, graphql, or http");
|
|
11110
|
+
default: throw new CapletsError("REQUEST_INVALID", "add.kind must be cli, mcp, openapi, google-discovery, googleDiscovery, graphql, or http");
|
|
11065
11111
|
}
|
|
11066
11112
|
}
|
|
11067
11113
|
function optionalProp(key, value) {
|
|
@@ -11118,6 +11164,14 @@ function remoteAddOptions$1(kind, options) {
|
|
|
11118
11164
|
tokenEnv: "string",
|
|
11119
11165
|
force: "boolean"
|
|
11120
11166
|
});
|
|
11167
|
+
case "google-discovery":
|
|
11168
|
+
case "googleDiscovery": return pickOptions(options, {
|
|
11169
|
+
discovery: "string",
|
|
11170
|
+
discoveryUrl: "string",
|
|
11171
|
+
baseUrl: "string",
|
|
11172
|
+
tokenEnv: "string",
|
|
11173
|
+
force: "boolean"
|
|
11174
|
+
});
|
|
11121
11175
|
case "graphql": return pickOptions(options, {
|
|
11122
11176
|
endpointUrl: "string",
|
|
11123
11177
|
schema: "string",
|
|
@@ -11458,12 +11512,16 @@ function attachEventsResponse(engine, activeStreams) {
|
|
|
11458
11512
|
} });
|
|
11459
11513
|
}
|
|
11460
11514
|
async function serveHttp(options, engineOptions = {}, writeErr = (value) => process.stderr.write(value)) {
|
|
11461
|
-
const
|
|
11515
|
+
const resolvedEngineOptions = {
|
|
11516
|
+
exposeLocalArtifactPaths: false,
|
|
11517
|
+
...engineOptions
|
|
11518
|
+
};
|
|
11519
|
+
const engine = new CapletsEngine(resolvedEngineOptions);
|
|
11462
11520
|
const app = createHttpServeApp(options, engine, {
|
|
11463
11521
|
writeErr,
|
|
11464
11522
|
control: {
|
|
11465
|
-
...
|
|
11466
|
-
projectCapletsRoot: projectCapletsRootForEngineOptions(
|
|
11523
|
+
...resolvedEngineOptions,
|
|
11524
|
+
projectCapletsRoot: projectCapletsRootForEngineOptions(resolvedEngineOptions)
|
|
11467
11525
|
}
|
|
11468
11526
|
});
|
|
11469
11527
|
const paths = servicePaths(options.path);
|
|
@@ -11483,12 +11541,16 @@ async function serveHttp(options, engineOptions = {}, writeErr = (value) => proc
|
|
|
11483
11541
|
}), app, engine, writeErr);
|
|
11484
11542
|
}
|
|
11485
11543
|
async function serveHttpWithSessionFactory(options, createSession, writeErr = (value) => process.stderr.write(value)) {
|
|
11486
|
-
const
|
|
11544
|
+
const resolvedEngineOptions = { exposeLocalArtifactPaths: false };
|
|
11545
|
+
const engine = new CapletsEngine(resolvedEngineOptions);
|
|
11487
11546
|
const app = createHttpServeApp(options, engine, {
|
|
11488
11547
|
writeErr,
|
|
11489
11548
|
exposeAttach: false,
|
|
11490
11549
|
sessionFactory: createSession,
|
|
11491
|
-
control: {
|
|
11550
|
+
control: {
|
|
11551
|
+
...resolvedEngineOptions,
|
|
11552
|
+
projectCapletsRoot: resolveProjectCapletsRoot()
|
|
11553
|
+
}
|
|
11492
11554
|
});
|
|
11493
11555
|
const paths = servicePaths(options.path);
|
|
11494
11556
|
const origin = `http://${formatHost(options.host)}:${options.port}`;
|
|
@@ -11749,6 +11811,7 @@ function createAttachNativeService(options, io) {
|
|
|
11749
11811
|
url: options.selection.remote.attachUrl,
|
|
11750
11812
|
...options.selection.remote.fetch ? { fetch: options.selection.remote.fetch } : {}
|
|
11751
11813
|
}),
|
|
11814
|
+
exposeLocalArtifactPaths: false,
|
|
11752
11815
|
...io.writeErr ? { writeErr: io.writeErr } : {}
|
|
11753
11816
|
});
|
|
11754
11817
|
}
|
|
@@ -13314,6 +13377,22 @@ function createProgram(io = {}) {
|
|
|
13314
13377
|
});
|
|
13315
13378
|
writeAddResult(writeOut, `${localMutationTargetLabel(target, io)}OpenAPI`, result);
|
|
13316
13379
|
});
|
|
13380
|
+
add.command("google-discovery").description("Add a Google Discovery API backend Caplet.").argument("<id>", "Caplet ID/display seed").option("--discovery <path-or-url>", "Google Discovery document path or URL").option("--discovery-url <url>", "remote Google Discovery document URL").option("--base-url <url>", "request base URL override").option("--token-env <ENV>", "bearer token environment variable reference").option("--project", "write to the project Caplets root").option("-g, --global", "write to the user Caplets root").option("--remote", "add through remote control").option("--print", "print generated Caplet text without writing a file").option("--output <path>", "output path").option("--force", "overwrite an existing destination file").action(async (id, options) => {
|
|
13381
|
+
const target = parseMutationTarget(options);
|
|
13382
|
+
if (target === "remote") {
|
|
13383
|
+
writeAddResult(writeOut, "Google Discovery", await requireRemoteClientForTarget(io).request("add", {
|
|
13384
|
+
kind: "googleDiscovery",
|
|
13385
|
+
id,
|
|
13386
|
+
options: remoteAddOptions(options)
|
|
13387
|
+
}));
|
|
13388
|
+
return;
|
|
13389
|
+
}
|
|
13390
|
+
const result = addGoogleDiscoveryCaplet(id, {
|
|
13391
|
+
...options,
|
|
13392
|
+
destinationRoot: addDestinationRoot(target, currentConfigPath(), env)
|
|
13393
|
+
});
|
|
13394
|
+
writeAddResult(writeOut, `${localMutationTargetLabel(target, io)}Google Discovery`, result);
|
|
13395
|
+
});
|
|
13317
13396
|
add.command("graphql").description("Add a GraphQL backend Caplet.").argument("<id>", "Caplet ID/display seed").option("--endpoint-url <url>", "GraphQL endpoint URL").option("--schema <path-or-url>", "GraphQL schema path or URL").option("--introspection", "load schema through endpoint introspection").option("--token-env <ENV>", "bearer token environment variable reference").option("--project", "write to the project Caplets root").option("-g, --global", "write to the user Caplets root").option("--remote", "add through remote control").option("--print", "print generated Caplet text without writing a file").option("--output <path>", "output path").option("--force", "overwrite an existing destination file").action(async (id, options) => {
|
|
13318
13397
|
const target = parseMutationTarget(options);
|
|
13319
13398
|
if (target === "remote") {
|
|
@@ -13954,6 +14033,7 @@ function mergePartialLocalOverlays(globalOverlay, projectOverlay) {
|
|
|
13954
14033
|
const capletConfigKinds = [
|
|
13955
14034
|
"mcpServers",
|
|
13956
14035
|
"openapiEndpoints",
|
|
14036
|
+
"googleDiscoveryApis",
|
|
13957
14037
|
"graphqlEndpoints",
|
|
13958
14038
|
"httpApis",
|
|
13959
14039
|
"cliTools",
|
|
@@ -13996,7 +14076,7 @@ function formatOverlaySource(kind) {
|
|
|
13996
14076
|
return kind;
|
|
13997
14077
|
}
|
|
13998
14078
|
function hasEnabledCaplet(config, id) {
|
|
13999
|
-
const caplet = config.mcpServers[id] ?? config.openapiEndpoints[id] ?? config.graphqlEndpoints[id] ?? config.httpApis[id] ?? config.cliTools[id] ?? config.capletSets[id];
|
|
14079
|
+
const caplet = config.mcpServers[id] ?? config.openapiEndpoints[id] ?? config.googleDiscoveryApis[id] ?? config.graphqlEndpoints[id] ?? config.httpApis[id] ?? config.cliTools[id] ?? config.capletSets[id];
|
|
14000
14080
|
return Boolean(caplet && !caplet.disabled);
|
|
14001
14081
|
}
|
|
14002
14082
|
async function executeLocalOperation(caplet, request, io, config) {
|
|
@@ -14631,7 +14711,7 @@ function classifyCapletRuntimeRoute(caplet) {
|
|
|
14631
14711
|
if (caplet.setup) return "process";
|
|
14632
14712
|
if (caplet.backend === "cli") return "process";
|
|
14633
14713
|
if (caplet.backend === "mcp") return caplet.transport === "stdio" || Boolean(caplet.command) ? "process" : "worker_safe";
|
|
14634
|
-
if (caplet.backend === "openapi" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
|
|
14714
|
+
if (caplet.backend === "openapi" || caplet.backend === "googleDiscovery" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
|
|
14635
14715
|
if (caplet.backend === "caplets") return "worker_safe";
|
|
14636
14716
|
return "local_only";
|
|
14637
14717
|
}
|
|
@@ -14740,6 +14820,7 @@ function capletsFromConfig(config) {
|
|
|
14740
14820
|
return [
|
|
14741
14821
|
...Object.values(config.mcpServers),
|
|
14742
14822
|
...Object.values(config.openapiEndpoints),
|
|
14823
|
+
...Object.values(config.googleDiscoveryApis ?? {}),
|
|
14743
14824
|
...Object.values(config.graphqlEndpoints),
|
|
14744
14825
|
...Object.values(config.httpApis),
|
|
14745
14826
|
...Object.values(config.cliTools),
|
|
@@ -14748,6 +14829,7 @@ function capletsFromConfig(config) {
|
|
|
14748
14829
|
}
|
|
14749
14830
|
function localReferencePaths(caplet) {
|
|
14750
14831
|
if (caplet.backend === "openapi") return filterLocalReferences([caplet.specPath]);
|
|
14832
|
+
if (caplet.backend === "googleDiscovery") return filterLocalReferences([caplet.discoveryPath]);
|
|
14751
14833
|
if (caplet.backend === "graphql") return filterLocalReferences([caplet.schemaPath, ...Object.values(caplet.operations ?? {}).map((operation) => operation.documentPath)]);
|
|
14752
14834
|
if (caplet.backend === "caplets") return filterLocalReferences([caplet.configPath]);
|
|
14753
14835
|
return [];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type MediaArtifact = {
|
|
2
|
+
uri: string;
|
|
3
|
+
path?: string;
|
|
4
|
+
filename: string;
|
|
5
|
+
mimeType?: string;
|
|
6
|
+
byteLength: number;
|
|
7
|
+
sha256: string;
|
|
8
|
+
};
|
|
9
|
+
export type WriteMediaArtifactInput = {
|
|
10
|
+
rootDir?: string;
|
|
11
|
+
capletId: string;
|
|
12
|
+
callId?: string;
|
|
13
|
+
suggestedFilename?: string;
|
|
14
|
+
outputPath?: string;
|
|
15
|
+
mimeType?: string;
|
|
16
|
+
bytes: Uint8Array | Buffer;
|
|
17
|
+
exposeLocalPath?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function artifactUri(capletId: string, callId: string, filename: string): string;
|
|
20
|
+
export declare function writeMediaArtifact(input: WriteMediaArtifactInput): Promise<MediaArtifact>;
|
|
21
|
+
export declare function resolveMediaArtifact(uri: string, options?: {
|
|
22
|
+
artifactRoot?: string;
|
|
23
|
+
maxBytes?: number;
|
|
24
|
+
}): MediaArtifact;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type MediaInput = {
|
|
2
|
+
path: string;
|
|
3
|
+
artifact?: never;
|
|
4
|
+
dataUrl?: never;
|
|
5
|
+
filename?: string;
|
|
6
|
+
mimeType?: string;
|
|
7
|
+
} | {
|
|
8
|
+
artifact: string;
|
|
9
|
+
path?: never;
|
|
10
|
+
dataUrl?: never;
|
|
11
|
+
filename?: string;
|
|
12
|
+
mimeType?: string;
|
|
13
|
+
} | {
|
|
14
|
+
dataUrl: string;
|
|
15
|
+
path?: never;
|
|
16
|
+
artifact?: never;
|
|
17
|
+
filename?: string;
|
|
18
|
+
mimeType?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ResolvedMediaInput = {
|
|
21
|
+
bytes: Buffer;
|
|
22
|
+
filename: string;
|
|
23
|
+
mimeType?: string;
|
|
24
|
+
};
|
|
25
|
+
export declare function readMediaInput(input: unknown, options?: {
|
|
26
|
+
artifactRoot?: string;
|
|
27
|
+
maxBytes?: number;
|
|
28
|
+
allowLocalPaths?: boolean;
|
|
29
|
+
}): Promise<ResolvedMediaInput>;
|
package/dist/native/service.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type NativeCapletsServiceOptions = NativeCapletsServiceResolutionInput &
|
|
|
8
8
|
configPath?: string;
|
|
9
9
|
projectConfigPath?: string;
|
|
10
10
|
authDir?: string;
|
|
11
|
+
exposeLocalArtifactPaths?: boolean;
|
|
11
12
|
watchDebounceMs?: number;
|
|
12
13
|
watch?: boolean;
|
|
13
14
|
writeErr?: (value: string) => void;
|
package/dist/native.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as nativeCapletPromptGuidance, D as nativeCodeModeToolId, E as nativeCapletsSystemGuidance, O as nativeCodeModeToolName, T as nativeCapletToolName, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletToolDescription } from "./service-
|
|
1
|
+
import { C as nativeCapletPromptGuidance, D as nativeCodeModeToolId, E as nativeCapletsSystemGuidance, O as nativeCodeModeToolName, T as nativeCapletToolName, f as RemoteNativeCapletsService, h as resolveNativeCapletsServiceOptions, p as createSdkRemoteCapletsClient, t as createNativeCapletsService, w as nativeCapletToolDescription } from "./service-CSRCJfpA.js";
|
|
2
2
|
import { generatedToolInputJsonSchema, generatedToolInputSchema } from "./generated-tool-input-schema.js";
|
|
3
3
|
//#region src/native/process-cleanup.ts
|
|
4
4
|
function registerNativeCapletsProcessCleanup(service, options = {}) {
|
|
@@ -89,6 +89,15 @@ function nonSecretBackendIdentity(caplet) {
|
|
|
89
89
|
specUrl: caplet.specUrl,
|
|
90
90
|
baseUrl: caplet.baseUrl
|
|
91
91
|
};
|
|
92
|
+
case "googleDiscovery": return {
|
|
93
|
+
backend: caplet.backend,
|
|
94
|
+
server: caplet.server,
|
|
95
|
+
discoveryPath: caplet.discoveryPath,
|
|
96
|
+
discoveryUrl: caplet.discoveryUrl,
|
|
97
|
+
baseUrl: caplet.baseUrl,
|
|
98
|
+
includeOperations: caplet.includeOperations,
|
|
99
|
+
excludeOperations: caplet.excludeOperations
|
|
100
|
+
};
|
|
92
101
|
case "graphql": return {
|
|
93
102
|
backend: caplet.backend,
|
|
94
103
|
server: caplet.server,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as OBSERVED_OUTPUT_SHAPE_LIMITS, a as parseShapeableJsonText, c as shapeType, d as backendFingerprint, f as observedOutputShapeKey, i as observeOutputShape, l as mergeJsonShapes, m as stableHash, n as extractJsonShape, o as hasTruncatedShape, p as observedOutputShapeStorageKey, r as normalizedObservableValue, s as shapeToTypeScript, t as usefulOutputSchema, u as FileObservedOutputShapeStore, v as OBSERVED_OUTPUT_SHAPE_VERSION } from "./observed-output-shapes-
|
|
1
|
+
import { _ as OBSERVED_OUTPUT_SHAPE_LIMITS, a as parseShapeableJsonText, c as shapeType, d as backendFingerprint, f as observedOutputShapeKey, i as observeOutputShape, l as mergeJsonShapes, m as stableHash, n as extractJsonShape, o as hasTruncatedShape, p as observedOutputShapeStorageKey, r as normalizedObservableValue, s as shapeToTypeScript, t as usefulOutputSchema, u as FileObservedOutputShapeStore, v as OBSERVED_OUTPUT_SHAPE_VERSION } from "./observed-output-shapes-D2k2-q8K.js";
|
|
2
2
|
export { FileObservedOutputShapeStore, OBSERVED_OUTPUT_SHAPE_LIMITS, OBSERVED_OUTPUT_SHAPE_VERSION, backendFingerprint, extractJsonShape, hasTruncatedShape, mergeJsonShapes, normalizedObservableValue, observeOutputShape, observedOutputShapeKey, observedOutputShapeStorageKey, parseShapeableJsonText, shapeToTypeScript, shapeType, stableHash, usefulOutputSchema };
|
package/dist/openapi.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class OpenApiManager {
|
|
|
8
8
|
private readonly cache;
|
|
9
9
|
constructor(registry: ServerRegistry, options?: {
|
|
10
10
|
authDir?: string;
|
|
11
|
+
artifactDir?: string;
|
|
12
|
+
exposeLocalArtifactPaths?: boolean;
|
|
11
13
|
});
|
|
12
14
|
updateRegistry(registry: ServerRegistry): void;
|
|
13
15
|
invalidate(serverId: string): void;
|
package/dist/registry.d.ts
CHANGED
|
@@ -32,6 +32,12 @@ export type CapletServerDetail = {
|
|
|
32
32
|
requestTimeoutMs: number;
|
|
33
33
|
operationCacheTtlMs: number;
|
|
34
34
|
source: "specPath" | "specUrl";
|
|
35
|
+
} | {
|
|
36
|
+
type: "googleDiscovery";
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
requestTimeoutMs: number;
|
|
39
|
+
operationCacheTtlMs: number;
|
|
40
|
+
source: "discoveryPath" | "discoveryUrl";
|
|
35
41
|
} | {
|
|
36
42
|
type: "graphql";
|
|
37
43
|
disabled: boolean;
|
package/dist/runtime-plan.js
CHANGED
|
@@ -254,7 +254,7 @@ function classifyCapletRuntimeRoute(caplet) {
|
|
|
254
254
|
if (caplet.setup) return "process";
|
|
255
255
|
if (caplet.backend === "cli") return "process";
|
|
256
256
|
if (caplet.backend === "mcp") return caplet.transport === "stdio" || Boolean(caplet.command) ? "process" : "worker_safe";
|
|
257
|
-
if (caplet.backend === "openapi" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
|
|
257
|
+
if (caplet.backend === "openapi" || caplet.backend === "googleDiscovery" || caplet.backend === "graphql" || caplet.backend === "http") return "worker_safe";
|
|
258
258
|
if (caplet.backend === "caplets") return "worker_safe";
|
|
259
259
|
return "local_only";
|
|
260
260
|
}
|
package/dist/runtime.d.ts
CHANGED