@caplets/core 0.13.0 → 0.14.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/index.js +59662 -1206
- package/package.json +3 -4
- package/dist/engine-D_zyCvXx.js +0 -57997
- package/dist/generated-tool-input-schema.js +0 -64
- package/dist/native.js +0 -105
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
//#region src/generated-tool-input-schema.mjs
|
|
2
|
-
const operations = [
|
|
3
|
-
"get_caplet",
|
|
4
|
-
"check_backend",
|
|
5
|
-
"check_mcp_server",
|
|
6
|
-
"list_tools",
|
|
7
|
-
"search_tools",
|
|
8
|
-
"get_tool",
|
|
9
|
-
"call_tool"
|
|
10
|
-
];
|
|
11
|
-
const generatedToolInputDescriptions = {
|
|
12
|
-
operation: [
|
|
13
|
-
"Caplets wrapper operation to perform for this configured Caplet backend.",
|
|
14
|
-
"Use get_caplet to read the full Caplet card, check_backend to check any backend, check_mcp_server to check an MCP backend, list_tools or search_tools to discover downstream tools, get_tool to read a downstream input schema, and call_tool to run one downstream tool, operation, action, CLI command, or child Caplet.",
|
|
15
|
-
"For call_tool, pass downstream inputs only inside the top-level \"arguments\" object."
|
|
16
|
-
].join(" "),
|
|
17
|
-
query: "Required only for search_tools. Example: {\"operation\":\"search_tools\",\"query\":\"web search\",\"limit\":5}. Do not use query for call_tool; put downstream query values under arguments.query.",
|
|
18
|
-
limit: "Optional only for search_tools; defaults to the configured search limit. For downstream result limits, use call_tool.arguments with the downstream schema field name.",
|
|
19
|
-
tool: "Exact downstream tool name for get_tool or call_tool. Example: {\"operation\":\"get_tool\",\"tool\":\"web_search_exa\"} before calling it.",
|
|
20
|
-
arguments: "Required JSON object only for call_tool. Put every downstream tool input inside this object. Example: {\"operation\":\"call_tool\",\"tool\":\"web_search_exa\",\"arguments\":{\"query\":\"latest MCP docs\",\"numResults\":3}}. Do not send downstream inputs as top-level query, limit, url, path, or other fields.",
|
|
21
|
-
fields: "Optional for call_tool after get_tool shows outputSchema on a non-GraphQL tool. Example: fields: [\"path.to.field\"]."
|
|
22
|
-
};
|
|
23
|
-
function generatedToolInputJsonSchema() {
|
|
24
|
-
return {
|
|
25
|
-
type: "object",
|
|
26
|
-
properties: {
|
|
27
|
-
operation: {
|
|
28
|
-
type: "string",
|
|
29
|
-
enum: operations,
|
|
30
|
-
description: generatedToolInputDescriptions.operation
|
|
31
|
-
},
|
|
32
|
-
query: {
|
|
33
|
-
type: "string",
|
|
34
|
-
description: generatedToolInputDescriptions.query
|
|
35
|
-
},
|
|
36
|
-
limit: {
|
|
37
|
-
type: "integer",
|
|
38
|
-
minimum: 1,
|
|
39
|
-
description: generatedToolInputDescriptions.limit
|
|
40
|
-
},
|
|
41
|
-
tool: {
|
|
42
|
-
type: "string",
|
|
43
|
-
description: generatedToolInputDescriptions.tool
|
|
44
|
-
},
|
|
45
|
-
arguments: {
|
|
46
|
-
type: "object",
|
|
47
|
-
description: generatedToolInputDescriptions.arguments
|
|
48
|
-
},
|
|
49
|
-
fields: {
|
|
50
|
-
type: "array",
|
|
51
|
-
items: {
|
|
52
|
-
type: "string",
|
|
53
|
-
minLength: 1
|
|
54
|
-
},
|
|
55
|
-
minItems: 1,
|
|
56
|
-
description: generatedToolInputDescriptions.fields
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
required: ["operation"],
|
|
60
|
-
additionalProperties: false
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { generatedToolInputDescriptions, generatedToolInputJsonSchema, operations };
|
package/dist/native.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { a as capabilityDescription, n as generatedToolInputSchema, t as CapletsEngine } from "./engine-D_zyCvXx.js";
|
|
2
|
-
import { generatedToolInputJsonSchema } from "./generated-tool-input-schema.js";
|
|
3
|
-
//#region src/native/tools.ts
|
|
4
|
-
function nativeCapletToolName(capletId) {
|
|
5
|
-
return `caplets_${capletId.replace(/_/g, "__").replace(/-/g, "_")}`;
|
|
6
|
-
}
|
|
7
|
-
function nativeCapletsSystemGuidance(toolNames) {
|
|
8
|
-
return [
|
|
9
|
-
"## Caplets Native Tools",
|
|
10
|
-
"",
|
|
11
|
-
"Caplets tools are native wrappers around configured Caplet backends. Each tool is named `caplets_<id>` and represents one capability domain.",
|
|
12
|
-
"",
|
|
13
|
-
"Available Caplets native tools:",
|
|
14
|
-
toolNames.length > 0 ? toolNames.map((tool) => `- ${tool}`).join("\n") : "- none",
|
|
15
|
-
"",
|
|
16
|
-
"Recommended flow:",
|
|
17
|
-
"1. Call the relevant `caplets_<id>` tool with `operation: \"get_caplet\"` to read the full Caplet card.",
|
|
18
|
-
"2. Call `check_backend` or `check_mcp_server` only when availability is uncertain.",
|
|
19
|
-
"3. Use `search_tools` or `list_tools` to discover the selected Caplet's downstream operations.",
|
|
20
|
-
"4. Use `get_tool` before `call_tool` when argument or output schema is unclear.",
|
|
21
|
-
"5. For `call_tool`, put downstream inputs only inside the top-level `arguments` object.",
|
|
22
|
-
"6. Do not invent downstream tool names; execute only exact names returned by `list_tools`, `search_tools`, or `get_tool`."
|
|
23
|
-
].join("\n");
|
|
24
|
-
}
|
|
25
|
-
function nativeCapletPromptGuidance(toolName, caplet) {
|
|
26
|
-
const checkOperation = caplet.backend === "mcp" ? "check_mcp_server" : "check_backend";
|
|
27
|
-
return [
|
|
28
|
-
`Use ${toolName} for the ${caplet.name} Caplet capability domain.`,
|
|
29
|
-
`Call ${toolName} with operation get_caplet before using unfamiliar downstream tools.`,
|
|
30
|
-
`Call ${toolName} with operation ${checkOperation} only when backend availability is uncertain.`,
|
|
31
|
-
`Call ${toolName} with operation search_tools or list_tools to discover exact downstream tool names.`,
|
|
32
|
-
`Call ${toolName} with operation call_tool only with exact downstream tool names and put downstream inputs in arguments.`
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
function nativeCapletToolDescription(toolName, caplet) {
|
|
36
|
-
return [
|
|
37
|
-
capabilityDescription(caplet),
|
|
38
|
-
"",
|
|
39
|
-
`Native tool name: ${toolName}`,
|
|
40
|
-
`Original Caplet ID: ${caplet.server}`
|
|
41
|
-
].join("\n");
|
|
42
|
-
}
|
|
43
|
-
//#endregion
|
|
44
|
-
//#region src/native/service.ts
|
|
45
|
-
function createNativeCapletsService(options = {}) {
|
|
46
|
-
return new DefaultNativeCapletsService(options);
|
|
47
|
-
}
|
|
48
|
-
var DefaultNativeCapletsService = class {
|
|
49
|
-
engine;
|
|
50
|
-
constructor(options) {
|
|
51
|
-
this.engine = new CapletsEngine(options);
|
|
52
|
-
}
|
|
53
|
-
listTools() {
|
|
54
|
-
return this.engine.enabledServers().map((caplet) => {
|
|
55
|
-
const toolName = nativeCapletToolName(caplet.server);
|
|
56
|
-
return {
|
|
57
|
-
caplet: caplet.server,
|
|
58
|
-
toolName,
|
|
59
|
-
title: caplet.name,
|
|
60
|
-
description: nativeCapletToolDescription(toolName, caplet),
|
|
61
|
-
promptGuidance: nativeCapletPromptGuidance(toolName, caplet)
|
|
62
|
-
};
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
async execute(capletId, request) {
|
|
66
|
-
return await this.engine.execute(capletId, request);
|
|
67
|
-
}
|
|
68
|
-
async reload() {
|
|
69
|
-
return await this.engine.reload();
|
|
70
|
-
}
|
|
71
|
-
onToolsChanged(listener) {
|
|
72
|
-
return this.engine.onReload(() => listener(this.listTools()));
|
|
73
|
-
}
|
|
74
|
-
async close() {
|
|
75
|
-
await this.engine.close();
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
//#endregion
|
|
79
|
-
//#region src/native/process-cleanup.ts
|
|
80
|
-
function registerNativeCapletsProcessCleanup(service) {
|
|
81
|
-
let closed = false;
|
|
82
|
-
const close = async () => {
|
|
83
|
-
if (closed) return;
|
|
84
|
-
closed = true;
|
|
85
|
-
try {
|
|
86
|
-
await service.close();
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.error("Failed to close Caplets service:", error);
|
|
89
|
-
process.exitCode = 1;
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
const closeBeforeExit = () => {
|
|
93
|
-
close();
|
|
94
|
-
};
|
|
95
|
-
const closeAndExit = () => {
|
|
96
|
-
close().finally(() => {
|
|
97
|
-
process.exit(process.exitCode ?? 0);
|
|
98
|
-
});
|
|
99
|
-
};
|
|
100
|
-
process.once("beforeExit", closeBeforeExit);
|
|
101
|
-
process.once("SIGINT", closeAndExit);
|
|
102
|
-
process.once("SIGTERM", closeAndExit);
|
|
103
|
-
}
|
|
104
|
-
//#endregion
|
|
105
|
-
export { createNativeCapletsService, generatedToolInputJsonSchema, generatedToolInputSchema, nativeCapletPromptGuidance, nativeCapletToolDescription, nativeCapletToolName, nativeCapletsSystemGuidance, registerNativeCapletsProcessCleanup };
|