ping-a-human 0.1.2 → 0.1.4
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.d.ts +0 -8
- package/dist/index.js +17 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { type CreateChannelOptions } from "./channel-factory.js";
|
|
4
|
-
/**
|
|
5
|
-
* Build the MCP server with notify_human and ask_human registered.
|
|
6
|
-
*
|
|
7
|
-
* The Channel is resolved lazily (per tool call) via {@link createChannel} so
|
|
8
|
-
* the server still boots without configuration; a missing/invalid config
|
|
9
|
-
* surfaces as a tool error result instead of crashing at startup. Tests inject
|
|
10
|
-
* a stub Channel through `channelOptions.channel`.
|
|
11
|
-
*/
|
|
12
4
|
export declare function createServer(channelOptions?: CreateChannelOptions): McpServer;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { realpathSync } from "node:fs";
|
|
4
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { z } from "zod";
|
|
7
8
|
import { createChannel } from "./channel-factory.js";
|
|
@@ -15,18 +16,30 @@ import { runSetup } from "./setup.js";
|
|
|
15
16
|
* surfaces as a tool error result instead of crashing at startup. Tests inject
|
|
16
17
|
* a stub Channel through `channelOptions.channel`.
|
|
17
18
|
*/
|
|
19
|
+
/** Read this package's version from package.json so MCP serverInfo never drifts. */
|
|
20
|
+
function packageVersion() {
|
|
21
|
+
try {
|
|
22
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
23
|
+
// dist/index.js -> ../package.json
|
|
24
|
+
const pkg = JSON.parse(readFileSync(join(here, "..", "package.json"), "utf8"));
|
|
25
|
+
return pkg.version ?? "0.0.0";
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return "0.0.0";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
18
31
|
export function createServer(channelOptions = {}) {
|
|
19
|
-
const server = new McpServer({ name: "ping-a-human", version:
|
|
32
|
+
const server = new McpServer({ name: "ping-a-human", version: packageVersion() });
|
|
20
33
|
const resolveChannel = () => createChannel(channelOptions);
|
|
21
34
|
// 1.x registerTool: inputSchema is a ZodRawShape (plain object), NOT z.object(...).
|
|
22
35
|
server.registerTool("notify_human", {
|
|
23
36
|
title: "Notify human",
|
|
24
|
-
description: "Send a fire-and-forget message to the configured human (via Telegram) and return
|
|
37
|
+
description: "Send a one-way, fire-and-forget message to the configured human (via Telegram) and return IMMEDIATELY. Use this ONLY to inform the human (status updates, 'task finished', 'deploy succeeded', FYIs) when you do NOT need anything back. The human's reply, if any, is NOT captured or returned. If you need a decision, approval, or any answer before continuing, DO NOT use this — use ask_human instead.",
|
|
25
38
|
inputSchema: { message: z.string() },
|
|
26
39
|
}, async ({ message }) => notifyHuman(resolveChannel(), { message }));
|
|
27
40
|
server.registerTool("ask_human", {
|
|
28
41
|
title: "Ask human",
|
|
29
|
-
description: "
|
|
42
|
+
description: "Ask the configured human a question and BLOCK until they reply on their messaging app (Telegram) or a timeout elapses. Use this whenever you need a human decision, approval, confirmation, clarification, or any answer before you can continue — the human's reply is captured and returned to you. Optionally provide `choices` to render tappable buttons (the tapped value is returned). Returns the human's answer, or a clear timed-out result if they don't respond in time. If you only need to inform the human and do NOT need a response, use notify_human instead.",
|
|
30
43
|
inputSchema: {
|
|
31
44
|
question: z.string(),
|
|
32
45
|
choices: z.array(z.string()).optional(),
|
package/package.json
CHANGED