@acid-cat/core-ts 0.2.0 → 0.3.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.
- package/dist/cli.js +15 -11
- package/dist/mcp.d.ts +5 -0
- package/dist/mcp.js +6 -2
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSession } from "./session.js";
|
|
2
|
-
import { CLI_EXIT_CODES, REFERENCE, bundle, cliExitCode, commandPath, isCallFailure } from "@acid-cat/spec-ts";
|
|
2
|
+
import { CLI_EXIT_CODES, REFERENCE, bundle, cliExitCode, cliFlags, cliUsage, commandPath, isCallFailure } from "@acid-cat/spec-ts";
|
|
3
3
|
//#region src/cli.ts
|
|
4
4
|
/**
|
|
5
5
|
* The CLI binding (spec/bindings/cli.md): a command line made from the catalog.
|
|
@@ -55,12 +55,15 @@ async function runCli(app, options, args, io) {
|
|
|
55
55
|
return CLI_EXIT_CODES.value;
|
|
56
56
|
}
|
|
57
57
|
if (first === "list") {
|
|
58
|
-
io.stdout(JSON.stringify([...session.handles.values()].map((handle) =>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
io.stdout(JSON.stringify([...session.handles.values()].map((handle) => {
|
|
59
|
+
const input = session.view.capabilities[handle.id].input;
|
|
60
|
+
return {
|
|
61
|
+
id: handle.id,
|
|
62
|
+
description: handle.description,
|
|
63
|
+
...handle.availability.getSnapshot(),
|
|
64
|
+
usage: cliUsage(options.name, handle.id, input === void 0 ? void 0 : bundle(input, types))
|
|
65
|
+
};
|
|
66
|
+
}), null, 2));
|
|
64
67
|
return CLI_EXIT_CODES.value;
|
|
65
68
|
}
|
|
66
69
|
if (first === "call") {
|
|
@@ -150,11 +153,12 @@ function help(name, paths) {
|
|
|
150
153
|
].join("\n");
|
|
151
154
|
}
|
|
152
155
|
function usage(name, path, description, schema) {
|
|
153
|
-
const properties = Object.keys(schema.properties ?? {});
|
|
154
|
-
const required = new Set(schema.required ?? []);
|
|
155
|
-
const flags = properties.map((property) => required.has(property) ? `--${property} <value>` : `[--${property} <value>]`);
|
|
156
156
|
return [
|
|
157
|
-
`Usage: ${
|
|
157
|
+
`Usage: ${[
|
|
158
|
+
name,
|
|
159
|
+
...path,
|
|
160
|
+
...cliFlags(schema)
|
|
161
|
+
].join(" ")}`,
|
|
158
162
|
"",
|
|
159
163
|
description
|
|
160
164
|
].join("\n");
|
package/dist/mcp.d.ts
CHANGED
|
@@ -5,6 +5,11 @@ export type McpOptions<Context> = McpSettings & ContextOption<Context>;
|
|
|
5
5
|
export interface McpSettings {
|
|
6
6
|
readonly name: string;
|
|
7
7
|
readonly version: string;
|
|
8
|
+
/**
|
|
9
|
+
* Guidance for a model about the whole server, which `server/discover` gives as `instructions`. The default is the
|
|
10
|
+
* description of the application.
|
|
11
|
+
*/
|
|
12
|
+
readonly instructions?: string | undefined;
|
|
8
13
|
/** The origins that can call the server. A request with no `Origin` header is accepted. */
|
|
9
14
|
readonly allowedOrigins: readonly string[];
|
|
10
15
|
readonly toJsonSchema: ToJsonSchema;
|
package/dist/mcp.js
CHANGED
|
@@ -43,7 +43,10 @@ function mcpHandler(app, options) {
|
|
|
43
43
|
toJsonSchema: options.toJsonSchema
|
|
44
44
|
});
|
|
45
45
|
try {
|
|
46
|
-
return await answer(session, message,
|
|
46
|
+
return await answer(session, message, {
|
|
47
|
+
...options,
|
|
48
|
+
instructions: options.instructions ?? app.description
|
|
49
|
+
}, request.signal);
|
|
47
50
|
} finally {
|
|
48
51
|
await session.dispose();
|
|
49
52
|
}
|
|
@@ -67,7 +70,8 @@ async function answer(session, message, options, signal) {
|
|
|
67
70
|
switch (message.method) {
|
|
68
71
|
case "server/discover": return complete({
|
|
69
72
|
supportedVersions: [MCP_PROTOCOL_VERSION],
|
|
70
|
-
capabilities: { tools: { listChanged: false } }
|
|
73
|
+
capabilities: { tools: { listChanged: false } },
|
|
74
|
+
...options.instructions === void 0 ? {} : { instructions: options.instructions }
|
|
71
75
|
}, true);
|
|
72
76
|
case "tools/list": return complete({ tools: listTools(session) }, true);
|
|
73
77
|
case "tools/call": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@acid-cat/core-ts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Serve AcidCat capabilities in plain TypeScript, with no Effect dependency.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acidcat",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@acid-cat/catalog": "0.
|
|
36
|
-
"@acid-cat/spec-ts": "0.
|
|
35
|
+
"@acid-cat/catalog": "0.3.1",
|
|
36
|
+
"@acid-cat/spec-ts": "0.3.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@acid-cat/cli": "0.
|
|
39
|
+
"@acid-cat/cli": "0.3.1",
|
|
40
40
|
"@types/node": "26.6.5",
|
|
41
41
|
"esbuild": "0.28.2",
|
|
42
42
|
"playwright": "1.64.0",
|