@paigy/mcp 0.15.0 → 0.16.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 CHANGED
@@ -1,23 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
3
2
  import {
4
- awaitReply,
5
- checkReplies,
6
- scheduleCallback,
7
- setTaskState,
8
- submitNotification
9
- } from "./chunk-7S6W7NEZ.js";
3
+ autoConfigureClients,
4
+ claudeInstallHint
5
+ } from "./chunk-U3WODCOE.js";
6
+ import {
7
+ clearSurface,
8
+ writeSurface
9
+ } from "./chunk-3SVNPJPN.js";
10
10
  import {
11
11
  NotifyRequestSchema,
12
12
  ScheduleCallbackSchema,
13
13
  SetTaskStateSchema,
14
- autoConfigureClients,
15
- claudeInstallHint,
16
- clearSurface,
14
+ UnpairedError,
15
+ awaitReply,
16
+ checkReplies,
17
17
  deleteKeyFile,
18
18
  deleteToken,
19
19
  fetchCredential,
20
20
  finalizeE2ee,
21
+ lintNotify,
21
22
  pairStep,
22
23
  readKeyFile,
23
24
  readToken,
@@ -25,10 +26,12 @@ import {
25
26
  revokeToken,
26
27
  saveKeyFile,
27
28
  saveToken,
29
+ scheduleCallback,
30
+ setTaskState,
28
31
  sleep,
29
32
  startE2ee,
30
- writeSurface
31
- } from "./chunk-W2ZS7IBA.js";
33
+ submitNotification
34
+ } from "./chunk-R3YGSGPX.js";
32
35
 
33
36
  // src/index.ts
34
37
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -38,52 +41,6 @@ import {
38
41
  ListToolsRequestSchema
39
42
  } from "@modelcontextprotocol/sdk/types.js";
40
43
  import { execSync } from "child_process";
41
-
42
- // src/lint.ts
43
- var TITLE_MAX = 90;
44
- var CHUNKS_MAX = 8;
45
- var CHUNK_MAX = 300;
46
- var ASK_MAX = 600;
47
- var OPTION_MAX = 80;
48
- var NEEDS_MAX = 6;
49
- var UNSPEAKABLE = /```|\n/;
50
- function lintNotify(req) {
51
- const problems = [];
52
- if (req.ask !== void 0) {
53
- if (req.ask.length > ASK_MAX)
54
- problems.push(`ask is ${req.ask.length} chars \u2014 state the need and why it matters now in \u2264${ASK_MAX}; move detail into a smaller follow-up`);
55
- if (UNSPEAKABLE.test(req.ask))
56
- problems.push("ask contains code fences or newlines \u2014 write it as plain prose (it may be read aloud on a call)");
57
- for (const n of req.needs ?? []) {
58
- if (n.length > OPTION_MAX) problems.push(`need "${n.slice(0, 40)}\u2026" is too long \u2014 each need is a short phrase (\u2264${OPTION_MAX} chars)`);
59
- }
60
- if ((req.needs?.length ?? 0) > NEEDS_MAX)
61
- problems.push(`${req.needs?.length} needs \u2014 cap at ${NEEDS_MAX}; a call can't cover more in one conversation, split the rest into a second ask`);
62
- return problems;
63
- }
64
- const spoken = req.urgency === "call" || req.urgency === "banner";
65
- if (req.context) {
66
- if (req.context.title.length > TITLE_MAX)
67
- problems.push(`title is ${req.context.title.length} chars \u2014 shorten to \u2264${TITLE_MAX} (it's what shows on the banner / gets spoken on a ring)`);
68
- if (UNSPEAKABLE.test(req.context.title))
69
- problems.push("title contains code fences or newlines \u2014 one plain-prose line");
70
- if (req.context.description.length > CHUNKS_MAX)
71
- problems.push(`${req.context.description.length} description chunks \u2014 cap at ${CHUNKS_MAX}; merge or drop the rest`);
72
- for (const [i, chunk] of req.context.description.entries()) {
73
- if (chunk.length > CHUNK_MAX)
74
- problems.push(`description[${i}] is ${chunk.length} chars \u2014 split it into standalone points of \u2264${CHUNK_MAX}`);
75
- }
76
- if (spoken && UNSPEAKABLE.test(req.context.description.join(" ")))
77
- problems.push("urgency is 'call'/'banner' but the description has code fences/newlines-in-chunk \u2014 rewrite in spoken register (it will be read aloud)");
78
- }
79
- for (const o of req.options ?? []) {
80
- if (o.label.length > OPTION_MAX)
81
- problems.push(`option label "${o.label.slice(0, 40)}\u2026" is ${o.label.length} chars \u2014 labels must read at a glance (\u2264${OPTION_MAX}); move detail into the description`);
82
- }
83
- return problems;
84
- }
85
-
86
- // src/index.ts
87
44
  import { z } from "zod";
88
45
  import qrcode from "qrcode-generator";
89
46
 
@@ -113,6 +70,7 @@ function json(s) {
113
70
  }
114
71
 
115
72
  // src/index.ts
73
+ var ONBOARD_MSG = "Not paired with Paigy yet \u2014 call the `pair` tool to connect this agent (it returns an approval link to show the user), then retry. Manual fallback: `npx -y @paigy/mcp paigy-mcp-onboard`.";
116
74
  var AwaitReplySchema = z.object({
117
75
  notificationId: z.string().describe("The notificationId returned by notify_user \u2014 waits for the user's reply to THIS notification only.")
118
76
  });
@@ -233,6 +191,14 @@ server.setRequestHandler(ListToolsRequestSchema, async () => ({
233
191
  ]
234
192
  }));
235
193
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
194
+ try {
195
+ return await handleTool(request);
196
+ } catch (e) {
197
+ if (e instanceof UnpairedError) throw new Error(ONBOARD_MSG);
198
+ throw e;
199
+ }
200
+ });
201
+ async function handleTool(request) {
236
202
  switch (request.params.name) {
237
203
  case "pair": {
238
204
  const { device_code } = PairSchema.parse(request.params.arguments ?? {});
@@ -381,6 +347,6 @@ Enter it in the Paigy app (Inbox \u2192 Add a new agent).`,
381
347
  default:
382
348
  throw new Error(`Unknown tool: ${request.params.name}`);
383
349
  }
384
- });
350
+ }
385
351
  var transport = new StdioServerTransport();
386
352
  await server.connect(transport);