@caplets/core 0.17.0 → 0.18.1

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.
@@ -4,6 +4,7 @@ export type RemoteCapletsTool = {
4
4
  name: string;
5
5
  title?: string | undefined;
6
6
  description?: string | undefined;
7
+ inputSchema?: unknown;
7
8
  };
8
9
  export type RemoteCapletsClient = {
9
10
  listTools(): Promise<RemoteCapletsTool[]>;
@@ -1,6 +1,7 @@
1
1
  import type { NativeCapletsServiceResolutionInput } from "./options";
2
2
  import { resolveNativeCapletsServiceOptions } from "./options";
3
3
  import { type RemoteCapletsClient } from "./remote";
4
+ import { generatedToolInputJsonSchemaForCaplet } from "../generated-tool-input-schema";
4
5
  export type NativeCapletsServiceOptions = NativeCapletsServiceResolutionInput & {
5
6
  configPath?: string;
6
7
  projectConfigPath?: string;
@@ -18,6 +19,8 @@ export type NativeCapletTool = {
18
19
  title: string;
19
20
  description: string;
20
21
  promptGuidance: string[];
22
+ inputSchema?: ReturnType<typeof generatedToolInputJsonSchemaForCaplet> | Record<string, unknown>;
23
+ operationNames?: string[];
21
24
  };
22
25
  export type NativeCapletsToolsChangedListener = (tools: NativeCapletTool[]) => void;
23
26
  export type NativeCapletsService = {
package/dist/native.js CHANGED
@@ -1,5 +1,5 @@
1
- import { $ as ToolListChangedNotificationSchema, Nt as CapletsError, a as resolveCapletsServer, i as resolveCapletsMode, n as mcpUrlForBase, o as CapletsEngine, s as generatedToolInputSchema, u as capabilityDescription, v as StreamableHTTPClientTransport, x as Client } from "./options-CJEOqS87.js";
2
- import { generatedToolInputJsonSchema } from "./generated-tool-input-schema.js";
1
+ import { Ot as CapletsError, Q as ToolListChangedNotificationSchema, _ as StreamableHTTPClientTransport, a as resolveCapletsServer, b as Client, i as resolveCapletsMode, l as capabilityDescription, n as mcpUrlForBase, o as CapletsEngine } from "./options-BqibJVxq.js";
2
+ import { a as generatedToolInputJsonSchemaForCaplet, i as generatedToolInputJsonSchema, l as operations, o as generatedToolInputSchema } from "./generated-tool-input-schema-BYoyY-l-.js";
3
3
  //#region src/native/options.ts
4
4
  const DEFAULT_POLL_INTERVAL_MS = 3e4;
5
5
  function resolveNativeCapletsServiceOptions(input = {}, env = process.env) {
@@ -42,12 +42,12 @@ function nativeCapletsSystemGuidance(toolNames) {
42
42
  "Available Caplets native tools:",
43
43
  toolNames.length > 0 ? toolNames.map((tool) => `- ${tool}`).join("\n") : "- none",
44
44
  "",
45
- "Flow: get_caplet when the domain is unfamiliar; search_tools or list_tools to find exact downstream names; get_tool only when schemas are unclear; call_tool with downstream inputs inside arguments.",
45
+ "Flow: get_caplet when the domain is unfamiliar; use search_tools/list_tools for actions; MCP-backed Caplets may also expose resources, prompts, and completions in their tool schema.",
46
46
  "Use fields on call_tool when a non-GraphQL downstream outputSchema allows selecting only needed structured paths."
47
47
  ].join("\n");
48
48
  }
49
49
  function nativeCapletPromptGuidance(toolName, caplet) {
50
- return [`Use ${toolName} for the ${caplet.name} Caplet capability domain.`];
50
+ return caplet.backend === "mcp" ? [`Use ${toolName} for the ${caplet.name} Caplet capability domain.`, "Prefer resources for readable context, prompts for reusable workflows, and tools for actions."] : [`Use ${toolName} for the ${caplet.name} Caplet capability domain.`];
51
51
  }
52
52
  function nativeCapletToolDescription(toolName, caplet) {
53
53
  return [
@@ -80,7 +80,8 @@ function createSdkRemoteCapletsClient(options) {
80
80
  return ((await client.listTools()).tools ?? []).map((tool) => ({
81
81
  name: tool.name,
82
82
  ...tool.title ? { title: tool.title } : {},
83
- ...tool.description ? { description: tool.description } : {}
83
+ ...tool.description ? { description: tool.description } : {},
84
+ ...tool.inputSchema ? { inputSchema: tool.inputSchema } : {}
84
85
  }));
85
86
  },
86
87
  async callTool(name, args) {
@@ -221,6 +222,7 @@ var RemoteNativeCapletsService = class {
221
222
  };
222
223
  function remoteToolToNativeTool(tool) {
223
224
  const toolName = nativeCapletToolName(tool.name);
225
+ const inputSchema = isPlainObject(tool.inputSchema) ? tool.inputSchema : generatedToolInputJsonSchemaForCaplet({ backend: "tool" });
224
226
  return {
225
227
  caplet: tool.name,
226
228
  toolName,
@@ -231,9 +233,21 @@ function remoteToolToNativeTool(tool) {
231
233
  `Native tool name: ${toolName}`,
232
234
  `Remote Caplet ID: ${tool.name}`
233
235
  ].join("\n"),
234
- promptGuidance: [`Use ${toolName} through the remote Caplets service.`]
236
+ promptGuidance: [`Use ${toolName} through the remote Caplets service.`],
237
+ inputSchema,
238
+ operationNames: operationNamesFromSchema(inputSchema)
235
239
  };
236
240
  }
241
+ function operationNamesFromSchema(schema) {
242
+ const properties = schema.properties;
243
+ if (!isPlainObject(properties)) return [...operations];
244
+ const operation = properties.operation;
245
+ if (!isPlainObject(operation) || !Array.isArray(operation.enum)) return [...operations];
246
+ return operation.enum.filter((value) => typeof value === "string");
247
+ }
248
+ function isPlainObject(value) {
249
+ return value !== null && typeof value === "object" && !Array.isArray(value);
250
+ }
237
251
  function errorMessage(error) {
238
252
  return error instanceof Error ? error.message : String(error);
239
253
  }
@@ -272,12 +286,15 @@ var DefaultNativeCapletsService = class {
272
286
  listTools() {
273
287
  return this.engine.enabledServers().map((caplet) => {
274
288
  const toolName = nativeCapletToolName(caplet.server);
289
+ const inputSchema = generatedToolInputJsonSchemaForCaplet(caplet);
275
290
  return {
276
291
  caplet: caplet.server,
277
292
  toolName,
278
293
  title: caplet.name,
279
294
  description: nativeCapletToolDescription(toolName, caplet),
280
- promptGuidance: nativeCapletPromptGuidance(toolName, caplet)
295
+ promptGuidance: nativeCapletPromptGuidance(toolName, caplet),
296
+ inputSchema,
297
+ operationNames: [...inputSchema.properties.operation.enum]
281
298
  };
282
299
  });
283
300
  }