@paigy/mcp 0.31.0 → 0.32.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/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  > QR scan; no pairing codes. Everything below is the manual per-client reference for
5
5
  > machines that can't run the harness.
6
6
 
7
- A voice inbox for your AI agents. This MCP server lets an agent **notify a user** and **await their reply** — so a long-running agent can ask a question, hand off, and resume on the answer. It's a thin MCP-tool wrapper over `@paigy/sdk` (`packages/sdk`) — use the SDK directly from any Node process that isn't an MCP client.
7
+ The AI agent harness that calls you. This MCP server lets an agent **notify a user** and **await their reply** — so a long-running agent can ask a question, hand off, and resume on the answer. It's a thin MCP-tool wrapper over `@paigy/sdk` (`packages/sdk`) — use the SDK directly from any Node process that isn't an MCP client.
8
8
 
9
9
  ## Install
10
10
 
@@ -118,7 +118,7 @@ Then pair: `PAIGY_AGENT=gemini npx -p @paigy/mcp@latest paigy-mcp-onboard`.
118
118
 
119
119
  - **`pair`** — pair this agent with the user's Paigy account (one-time). No args to start: returns the code to show the user **and begins polling for approval in the background**; pass the returned `device_code` to collect the result (it returns the moment the user approves). On success it prompts you to allowlist Paigy's notify/await tools so they run without an approval prompt each time.
120
120
  - **`unpair`** — log this agent out of the user's Paigy account; revokes the token server-side and deletes the local one.
121
- - **`enable_tools`** — after pairing (and only with the user's consent), allowlist Paigy's notify/await tools so they run without an approval prompt each time. Writes Claude Code's `permissions.allow` — `scope:'user'` (default, every project) or `scope:'project'` (this repo). Merges, never clobbers; leaves `pair`/`unpair` human-approved.
121
+ - **`paigy-enable-tools`** (a CLI, *not* a tool) — allowlist Paigy's notify/await tools so they run without an approval prompt each time. `npx -y -p @paigy/mcp@latest paigy-enable-tools` (or `paigy-harness enable-tools`); `--scope project` limits it to the current repo instead of `~/.claude/settings.json`. Merges, never clobbers; leaves `pair`/`unpair` human-approved. **This is deliberately not an MCP tool.** It writes the calling agent's own permission allowlist, which every host worth trusting treats as privilege escalation — Claude Code's auto mode denies it outright, and the user's consent inside Paigy is invisible to the classifier making that call. `pair` returns the command for the agent to print; a human runs it.
122
122
  - **`contact`** — THE way to reach the user: tell them something, or ask and get their answer. Core form is two fields — `ask` (plain prose: what you need to tell them or find out) and `waiting` (what happens to your work meanwhile: `none` = just informing, `soft` = want an answer but can keep working, `hard` = stopped until answered — reaches them urgently and escalates to a real phone call). Paigy's broker picks the channel, phrasing, and answer format. When the choices themselves must be *seen*, attach `options` (each may carry a sandboxed `html` or `image` preview); attach `visuals` for context screenshots. Returns `{ notificationId, threadId }`; a threaded follow-up supersedes that thread's pending items, and an identical threaded re-send escalates in place. If a reply comes back as `{kind:'clarify', chunks:[...]}`, contact again on the SAME threadId with an expanded ask. (The former `notify_user`/`notify` names remain accepted as hidden aliases for older setups, and the fully-shaped wire form — context/select/urgency — is still accepted from code; neither is part of the model surface anymore.)
123
123
  - **`await_reply`** — wait for the user's reply to a specific notification (pass its notificationId). Scoped: will not return replies meant for other notifications. Returns `reply` / `remind` / `idle`.
124
124
  - **`check_replies`** — catch-up sweep: returns replies you haven't consumed yet (now marked seen) plus still-pending notifications, new user-initiated requests, and owed callbacks.
@@ -2531,7 +2531,7 @@ var NotifyRequestSchema = z.object({
2531
2531
  if (r.ask !== void 0) {
2532
2532
  for (const f of ["context", "select", "points"]) {
2533
2533
  if (r[f] !== void 0)
2534
- ctx.addIssue({ code: z.ZodIssueCode.custom, path: [f], message: `the simplified \`ask\` form takes no ${f} \u2014 the broker derives it (use \`needs\` for multi-part asks)` });
2534
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: [f], message: `the simplified \`ask\` form takes no ${f} \u2014 the broker derives the answer shape from your prose. Drop ${f} and say it in \`ask\` instead ("should I\u2026" for approve/deny, "which of these\u2026" for a pick), passing \`options\` when you're offering concrete alternatives.` });
2535
2535
  }
2536
2536
  return;
2537
2537
  }
@@ -2795,7 +2795,22 @@ var NotifyPlanUnitSchema = z.object({
2795
2795
  settled: z.literal(true).optional(),
2796
2796
  /** What this unit would need to be answerable and does not carry (#894). A PROPOSAL to the
2797
2797
  * agent — nothing here changed the ask, and ignoring it costs nothing. */
2798
- needs: z.array(z.enum(["options", "visuals"])).optional()
2798
+ needs: z.array(z.enum(["options", "visuals"])).optional(),
2799
+ /** The SHAPE the broker would give this unit, for the agent to ratify (#886/#894). The
2800
+ * split layer reads prose and can see that a paragraph is a yes/no or a pick-one — but a
2801
+ * broker that DECIDES that destroys the only fact separating a statement from a real ask
2802
+ * (#731), so it is offered, never applied: the unit is stored `text` until the agent
2803
+ * confirms the shape (POST /notify/:id/confirm). Ignoring it costs nothing. */
2804
+ proposal: z.object({
2805
+ select: SelectShapeSchema,
2806
+ options: z.array(z.object({ label: z.string().min(1) })).optional()
2807
+ }).optional(),
2808
+ /** What the broker READ this unit as wanting from the human (#952 layer 2): a `decision`
2809
+ * between alternatives, an `approval` the agent is blocked on, or `knowledge` it just
2810
+ * needs to know. Reported so the agent can correct a misread the same way it ratifies a
2811
+ * shape — the read RAISES (a decision always asks) and never silences a question the
2812
+ * agent declared (#731, #923). */
2813
+ wants: z.enum(["decision", "approval", "knowledge"]).optional()
2799
2814
  });
2800
2815
  var NotifyPlanSchema = z.object({
2801
2816
  units: z.array(NotifyPlanUnitSchema),
@@ -2886,6 +2901,11 @@ var InboxItemSchema = z.object({
2886
2901
  * its acknowledge affordance: without it a status update offers a text box and a dismiss,
2887
2902
  * and neither of those is "got it" (owner, 2026-08-10). */
2888
2903
  asks: z.boolean().optional(),
2904
+ /** When a live process last pulsed for this row's agent — the liveness input for
2905
+ * "working requires a pulse" (#928): the list said "Working…" from agent_state alone
2906
+ * while the party called the same dead claim stalled. Absent = no token/no data,
2907
+ * which must never CLAIM stalled. */
2908
+ lastSeenAt: z.string().optional(),
2889
2909
  agenda: z.array(AgendaTurnSchema).optional(),
2890
2910
  /** On a replied detail (#397): the next steps the user attached to the answer
2891
2911
  * ("call back after lunch") — shown so they can see the commitment was captured. */
@@ -2924,7 +2944,7 @@ var InboxItemSchema = z.object({
2924
2944
  why: z.object({
2925
2945
  asked: NotifyLevelSchema,
2926
2946
  got: NotifyLevelSchema,
2927
- because: z.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned"]).optional(),
2947
+ because: z.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned", "learned_raise"]).optional(),
2928
2948
  line: z.string()
2929
2949
  }).optional(),
2930
2950
  select: z.enum(["one", "many", "rank", "confirm", "text"]).default("one"),
@@ -3037,6 +3057,15 @@ var HistoryItemSchema = z.object({
3037
3057
  /** When you answered the agent's notification (agent→user only). */
3038
3058
  humanAckedAt: z.string().nullable()
3039
3059
  });
3060
+ var ACTIVITY_LINES = 2;
3061
+ var ACTIVITY_LINE_MAX = 80;
3062
+ var AgentActivitySchema = z.object({
3063
+ /** Oldest first, so the newest line is last — the one that replaces in place. */
3064
+ lines: z.array(z.string().max(ACTIVITY_LINE_MAX)).max(ACTIVITY_LINES),
3065
+ /** When the harness observed this tail. Its own timestamp, not the heartbeat's: a beat
3066
+ * that carries an UNCHANGED tail must not make a stalled agent look like it just moved. */
3067
+ at: z.string().datetime()
3068
+ });
3040
3069
  var ConnectionSummarySchema = z.object({
3041
3070
  /** The connection = the agent's token id (used to address a request). */
3042
3071
  id: z.string(),
@@ -3070,6 +3099,11 @@ var ConnectionSummarySchema = z.object({
3070
3099
  harnesses: z.array(z.object({ name: z.string(), label: z.string(), status: z.string() })).optional(),
3071
3100
  workspaces: z.array(z.string()).optional()
3072
3101
  }).optional(),
3102
+ /** The tail of this agent's working log, when a harness is driving it — the agent page's
3103
+ * live strip. Absent for anything the desktop harness isn't running (a hatched identity
3104
+ * used straight from a terminal emits no work events; the page says so rather than
3105
+ * drawing an empty box). */
3106
+ activity: AgentActivitySchema.optional(),
3073
3107
  /** True = a provider-managed agent running in the provider's cloud (e.g. Anthropic CMA);
3074
3108
  * false = a local MCP connection running on the user's computer (Claude Code/Codex/…). */
3075
3109
  managed: z.boolean()
@@ -4114,10 +4148,14 @@ async function setIdentity(patch, opts = {}) {
4114
4148
  return await res.json();
4115
4149
  }
4116
4150
  async function heartbeat(runtime, opts = {}) {
4151
+ const body = {
4152
+ ...runtime !== void 0 ? { runtime } : {},
4153
+ ...opts.activity !== void 0 ? { activity: opts.activity } : {}
4154
+ };
4117
4155
  const res = ensureAuthed(await reach(`${BACKEND_URL}/api/presence`, {
4118
4156
  method: "POST",
4119
4157
  headers: { "content-type": "application/json", authorization: `Bearer ${authToken(opts.token)}` },
4120
- ...runtime !== void 0 ? { body: JSON.stringify({ runtime }) } : {}
4158
+ ...Object.keys(body).length > 0 ? { body: JSON.stringify(body) } : {}
4121
4159
  }));
4122
4160
  if (!res.ok) throw new Error(`heartbeat failed: ${res.status}`);
4123
4161
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  AGENT_NAME
3
- } from "./chunk-2WPQJYJH.js";
3
+ } from "./chunk-7SFOTYXZ.js";
4
4
 
5
5
  // src/clients.ts
6
6
  import { execFile } from "child_process";
@@ -87,6 +87,7 @@ function claudeInstallHint(skip = AGENT_NAME) {
87
87
  }
88
88
  return "Claude Code detected \u2014 to add Paigy there, run /plugin marketplace add paigy-ai/mcp then /plugin install paigy (pairing carries over; no need to pair again). Note: If you run this inside a live session, type /reload-plugins afterward so the agent connects to the new tools.";
89
89
  }
90
+ var ENABLE_COMMAND = "npx -y -p @paigy/mcp@latest paigy-enable-tools";
90
91
  var PAIGY_TOOL_IDS = [
91
92
  "mcp__paigy__contact",
92
93
  "mcp__paigy__notify_user",
@@ -169,6 +170,7 @@ export {
169
170
  openBrowser,
170
171
  autoConfigureClients,
171
172
  claudeInstallHint,
173
+ ENABLE_COMMAND,
172
174
  PAIGY_TOOL_IDS,
173
175
  paigyToolsAllowlisted,
174
176
  enablePaigyTools
@@ -192,7 +192,7 @@ var NotifyRequestSchema = z.object({
192
192
  if (r.ask !== void 0) {
193
193
  for (const f of ["context", "select", "points"]) {
194
194
  if (r[f] !== void 0)
195
- ctx.addIssue({ code: z.ZodIssueCode.custom, path: [f], message: `the simplified \`ask\` form takes no ${f} \u2014 the broker derives it (use \`needs\` for multi-part asks)` });
195
+ ctx.addIssue({ code: z.ZodIssueCode.custom, path: [f], message: `the simplified \`ask\` form takes no ${f} \u2014 the broker derives the answer shape from your prose. Drop ${f} and say it in \`ask\` instead ("should I\u2026" for approve/deny, "which of these\u2026" for a pick), passing \`options\` when you're offering concrete alternatives.` });
196
196
  }
197
197
  return;
198
198
  }
@@ -401,7 +401,22 @@ var NotifyPlanUnitSchema = z.object({
401
401
  settled: z.literal(true).optional(),
402
402
  /** What this unit would need to be answerable and does not carry (#894). A PROPOSAL to the
403
403
  * agent — nothing here changed the ask, and ignoring it costs nothing. */
404
- needs: z.array(z.enum(["options", "visuals"])).optional()
404
+ needs: z.array(z.enum(["options", "visuals"])).optional(),
405
+ /** The SHAPE the broker would give this unit, for the agent to ratify (#886/#894). The
406
+ * split layer reads prose and can see that a paragraph is a yes/no or a pick-one — but a
407
+ * broker that DECIDES that destroys the only fact separating a statement from a real ask
408
+ * (#731), so it is offered, never applied: the unit is stored `text` until the agent
409
+ * confirms the shape (POST /notify/:id/confirm). Ignoring it costs nothing. */
410
+ proposal: z.object({
411
+ select: SelectShapeSchema,
412
+ options: z.array(z.object({ label: z.string().min(1) })).optional()
413
+ }).optional(),
414
+ /** What the broker READ this unit as wanting from the human (#952 layer 2): a `decision`
415
+ * between alternatives, an `approval` the agent is blocked on, or `knowledge` it just
416
+ * needs to know. Reported so the agent can correct a misread the same way it ratifies a
417
+ * shape — the read RAISES (a decision always asks) and never silences a question the
418
+ * agent declared (#731, #923). */
419
+ wants: z.enum(["decision", "approval", "knowledge"]).optional()
405
420
  });
406
421
  var NotifyPlanSchema = z.object({
407
422
  units: z.array(NotifyPlanUnitSchema),
@@ -492,6 +507,11 @@ var InboxItemSchema = z.object({
492
507
  * its acknowledge affordance: without it a status update offers a text box and a dismiss,
493
508
  * and neither of those is "got it" (owner, 2026-08-10). */
494
509
  asks: z.boolean().optional(),
510
+ /** When a live process last pulsed for this row's agent — the liveness input for
511
+ * "working requires a pulse" (#928): the list said "Working…" from agent_state alone
512
+ * while the party called the same dead claim stalled. Absent = no token/no data,
513
+ * which must never CLAIM stalled. */
514
+ lastSeenAt: z.string().optional(),
495
515
  agenda: z.array(AgendaTurnSchema).optional(),
496
516
  /** On a replied detail (#397): the next steps the user attached to the answer
497
517
  * ("call back after lunch") — shown so they can see the commitment was captured. */
@@ -530,7 +550,7 @@ var InboxItemSchema = z.object({
530
550
  why: z.object({
531
551
  asked: NotifyLevelSchema,
532
552
  got: NotifyLevelSchema,
533
- because: z.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned"]).optional(),
553
+ because: z.enum(["unresponsive", "dismissed", "not_permitted", "silent", "coalesced", "agent_capped", "unplanned", "learned_raise"]).optional(),
534
554
  line: z.string()
535
555
  }).optional(),
536
556
  select: z.enum(["one", "many", "rank", "confirm", "text"]).default("one"),
@@ -579,6 +599,16 @@ var MissedCallSchema = z.enum([
579
599
  "inbox",
580
600
  "dismiss"
581
601
  ]);
602
+ var MISSED_CALL_PLAN = {
603
+ retry_10m: { kind: "every", minutes: 10 },
604
+ retry_30m: { kind: "every", minutes: 30 },
605
+ retry_60m: { kind: "every", minutes: 60 },
606
+ backoff_gentle: { kind: "at", minutes: [30, 120, 360] },
607
+ backoff_standard: { kind: "at", minutes: [10, 30, 120] },
608
+ backoff_aggressive: { kind: "at", minutes: [5, 15, 45] },
609
+ inbox: { kind: "once" },
610
+ dismiss: { kind: "grace", minutes: 2 }
611
+ };
582
612
  var BrokerTuningSchema = z.object({
583
613
  /** 'none' = skip the spoken ack after a mapped answer (power users find it slow). */
584
614
  ackVerbosity: z.enum(["normal", "none"]).optional(),
@@ -643,6 +673,15 @@ var HistoryItemSchema = z.object({
643
673
  /** When you answered the agent's notification (agent→user only). */
644
674
  humanAckedAt: z.string().nullable()
645
675
  });
676
+ var ACTIVITY_LINES = 2;
677
+ var ACTIVITY_LINE_MAX = 80;
678
+ var AgentActivitySchema = z.object({
679
+ /** Oldest first, so the newest line is last — the one that replaces in place. */
680
+ lines: z.array(z.string().max(ACTIVITY_LINE_MAX)).max(ACTIVITY_LINES),
681
+ /** When the harness observed this tail. Its own timestamp, not the heartbeat's: a beat
682
+ * that carries an UNCHANGED tail must not make a stalled agent look like it just moved. */
683
+ at: z.string().datetime()
684
+ });
646
685
  var ConnectionSummarySchema = z.object({
647
686
  /** The connection = the agent's token id (used to address a request). */
648
687
  id: z.string(),
@@ -676,6 +715,11 @@ var ConnectionSummarySchema = z.object({
676
715
  harnesses: z.array(z.object({ name: z.string(), label: z.string(), status: z.string() })).optional(),
677
716
  workspaces: z.array(z.string()).optional()
678
717
  }).optional(),
718
+ /** The tail of this agent's working log, when a harness is driving it — the agent page's
719
+ * live strip. Absent for anything the desktop harness isn't running (a hatched identity
720
+ * used straight from a terminal emits no work events; the page says so rather than
721
+ * drawing an empty box). */
722
+ activity: AgentActivitySchema.optional(),
679
723
  /** True = a provider-managed agent running in the provider's cloud (e.g. Anthropic CMA);
680
724
  * false = a local MCP connection running on the user's computer (Claude Code/Codex/…). */
681
725
  managed: z.boolean()
@@ -982,6 +1026,7 @@ var FeedbackOutcomeSchema = z.object({
982
1026
  });
983
1027
 
984
1028
  export {
1029
+ MISSED_CALL_PLAN,
985
1030
  HandoffSchema,
986
1031
  WAKE_EVENT,
987
1032
  wakeChannel
package/dist/enable.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ PAIGY_TOOL_IDS,
4
+ enablePaigyTools
5
+ } from "./chunk-LKA7UMRZ.js";
6
+ import "./chunk-7SFOTYXZ.js";
7
+
8
+ // src/enable.ts
9
+ function main() {
10
+ const argv = process.argv.slice(2);
11
+ let scope = "user";
12
+ for (let i = 0; i < argv.length; i++) {
13
+ const arg = argv[i];
14
+ if (arg === "-h" || arg === "--help") {
15
+ console.log("usage: paigy-enable-tools [--scope user|project]");
16
+ console.log("");
17
+ console.log("Allowlist Paigy's notify/await tools in Claude Code so they run without an");
18
+ console.log("approval prompt each time \u2014 an unattended session can't stall on a dialog.");
19
+ console.log("");
20
+ console.log(" --scope user ~/.claude/settings.json (default) \u2014 every project");
21
+ console.log(" --scope project ./.claude/settings.json \u2014 just this repo");
22
+ console.log("");
23
+ console.log(`Adds: ${PAIGY_TOOL_IDS.join(", ")}`);
24
+ console.log("Leaves pair/unpair out, so they stay human-approved. Safe to re-run.");
25
+ return;
26
+ }
27
+ if (arg === "--scope") {
28
+ const v = argv[++i];
29
+ if (v !== "user" && v !== "project") {
30
+ console.error(`paigy-enable-tools: --scope must be user or project, got ${v ?? "nothing"}`);
31
+ process.exit(2);
32
+ }
33
+ scope = v;
34
+ } else {
35
+ console.error(`paigy-enable-tools: unknown argument ${arg}`);
36
+ console.error("usage: paigy-enable-tools [--scope user|project]");
37
+ process.exit(2);
38
+ }
39
+ }
40
+ const result = enablePaigyTools(scope);
41
+ if (!result.ok) {
42
+ console.error(`\u2717 ${result.reason}`);
43
+ process.exit(1);
44
+ }
45
+ if (result.added.length) {
46
+ console.log(`\u2713 allowlisted ${result.added.length} Paigy tool${result.added.length === 1 ? "" : "s"} in ${result.path}`);
47
+ for (const id of result.added) console.log(` ${id}`);
48
+ } else {
49
+ console.log(`\u2713 already allowlisted in ${result.path} \u2014 nothing to do`);
50
+ }
51
+ if (result.already.length && result.added.length) {
52
+ console.log(` (${result.already.length} already present)`);
53
+ }
54
+ }
55
+ main();
package/dist/index.js CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- HandoffSchema
4
- } from "./chunk-Z5FEQ4GK.js";
3
+ HandoffSchema,
4
+ MISSED_CALL_PLAN
5
+ } from "./chunk-XSHUDPJ3.js";
5
6
  import {
7
+ ENABLE_COMMAND,
6
8
  PAIGY_TOOL_IDS,
7
9
  autoConfigureClients,
8
10
  claudeInstallHint,
9
- enablePaigyTools,
10
11
  paigyToolsAllowlisted
11
- } from "./chunk-ENE65M5Y.js";
12
+ } from "./chunk-LKA7UMRZ.js";
12
13
  import {
13
14
  clearSurface,
14
15
  writeSurface
@@ -50,7 +51,7 @@ import {
50
51
  startE2ee,
51
52
  submitNotification,
52
53
  whoAmI
53
- } from "./chunk-2WPQJYJH.js";
54
+ } from "./chunk-7SFOTYXZ.js";
54
55
 
55
56
  // src/index.ts
56
57
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
@@ -89,12 +90,20 @@ function json(s) {
89
90
  }
90
91
 
91
92
  // src/toolset.ts
93
+ var fmtMin = (m) => m >= 60 ? `${m / 60} hr` : `${m} min`;
94
+ var STANDARD_MEANS = (() => {
95
+ const plan = MISSED_CALL_PLAN.backoff_standard;
96
+ const mins = plan.kind === "at" ? plan.minutes : [];
97
+ const parts = mins.map(fmtMin);
98
+ const list = parts.length > 1 ? `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}` : parts[0] ?? "";
99
+ return `Rings again ${list} after the missed call, then leaves it in your inbox`;
100
+ })();
92
101
  var CONTACT_SCHEMA = {
93
102
  type: "object",
94
103
  properties: {
95
104
  ask: {
96
105
  type: "string",
97
- description: "What to tell the user, or what you need to find out from them. Plain prose \u2014 as long as it needs to be (up to 10k characters); Paigy splits it into topics and reads back a few sentences at a time, so do NOT compress a briefing into one line. May be spoken aloud on a call, so write natural speech and name things (not IDs). Contact at exactly two moments: BLOCKED on a decision only they can make, or DONE (one short report \u2014 what shipped, how you verified it, what you flagged). Progress is never a contact: set_task_state carries it, and working narration stays in your own terminal \u2014 the user sees you're working without being interrupted by it."
106
+ description: `What to tell the user, or what you need to find out from them. Plain prose \u2014 as long as it needs to be (up to 10k characters); Paigy splits it into topics and reads back a few sentences at a time, so do NOT compress a briefing into one line. May be spoken aloud on a call, so write natural speech and name things (not IDs). Contact at exactly two moments: BLOCKED on a decision only they can make, or DONE (one short report \u2014 what shipped, how you verified it, what you flagged). DONE IS SAID ONCE: "all set", "nothing open on my end", "that thread is complete" are the same report in new words, and each one reaches them separately (live 2026-08-12: three of them in three minutes). After the first, you are finished speaking; if they acknowledge it, stop rather than confirming the acknowledgement. Progress is never a contact: set_task_state carries it, and working narration stays in your own terminal \u2014 the user sees you're working without being interrupted by it.`
98
107
  },
99
108
  waiting: {
100
109
  type: "string",
@@ -129,8 +138,9 @@ var CONTACT_SCHEMA = {
129
138
  },
130
139
  required: ["ask"]
131
140
  };
132
- var CONTACT_DESCRIPTION = "Reach the user through Paigy \u2014 tell them something, or ask and get their answer. State what you need in `ask`, say what happens to your work while you wait in `waiting`, and Paigy handles the rest (channel, phrasing, answer format). If the user explicitly asks you to CALL them, send waiting:'hard' and say so in the ask. Returns { notificationId, parentId } \u2014 pass notificationId to await_reply for the answer, parentId to a later contact to continue the conversation. THREADING REPLACES: a threaded follow-up SUPERSEDES your earlier pending items on that thread \u2014 right for updates to one ask, WRONG for a checklist (send independent to-dos un-threaded). A threaded re-send with IDENTICAL content escalates the pending ask in place. If a reply comes back as {kind:'clarify', chunks:[...]}, the user wants more detail \u2014 contact again on the SAME parentId with an expanded ask. ONE ASK, ONE ROW: never restate a still-pending ask's question inside a NEW contact (e.g. weaving it into a briefing) \u2014 the whole answer settles on the new row and the original can never receive it. Keep waiting on the original (a live call reads every pending ask out separately, each answer routes to its own row), and use `needs` for a genuinely multi-part NEW ask.";
133
- var ONBOARD_DESCRIPTION = "Get this agent talking to Paigy \u2014 call it FIRST, before contact/await_reply, and any time you're unsure who you are. One call, and it does whatever the situation needs: NOT SET UP \u2192 hatches an identity instantly if this machine holds a device credential (the user ran the Paigy desktop app or harness), otherwise starts the code ceremony; ALREADY SET UP \u2192 returns your current identity and offers the two things left to decide, renaming it or unpairing; TOKEN NO LONGER VALID \u2192 says so, then re-pairs. Pass { name, voice } to choose who you are when hatching, or to RENAME yourself when already set up (voices: rachel, george, jessica, brian, lily). Safe to call any time: idempotent, and it never writes settings \u2014 the tool-allowlist state it reports is read-only. If it returns a `user_code`, print it to the user immediately and call onboard again with the `device_code`. If it returns `enable_prompt`, ask the user that question and call `enable_tools` on yes.";
141
+ var CONTACT_DESCRIPTION = `Reach the user through Paigy \u2014 tell them something, or ask and get their answer. State what you need in \`ask\`, say what happens to your work while you wait in \`waiting\`, and Paigy handles the rest (channel, phrasing, answer format). If the user explicitly asks you to CALL them, send waiting:'hard' and say so in the ask. Returns { notificationId, parentId } \u2014 pass notificationId to await_reply for the answer, parentId to a later contact to continue the conversation. When it rang, the reply also carries { ifMissed: { mode, means } }: what the user's own policy does with a call they don't take ("${STANDARD_MEANS}"), so a no-answer tells you how long to wait before coming back. THREADING REPLACES: a threaded follow-up SUPERSEDES your earlier pending items on that thread \u2014 right for updates to one ask, WRONG for a checklist (send independent to-dos un-threaded). A threaded re-send with IDENTICAL content escalates the pending ask in place. If a reply comes back as {kind:'clarify', chunks:[...]}, the user wants more detail \u2014 contact again on the SAME parentId with an expanded ask. ONE ASK, ONE ROW: never restate a still-pending ask's question inside a NEW contact (e.g. weaving it into a briefing) \u2014 the whole answer settles on the new row and the original can never receive it. Keep waiting on the original (a live call reads every pending ask out separately, each answer routes to its own row), and use \`needs\` for a genuinely multi-part NEW ask. ANSWERABLE, NOT JUST ASKED: when the reply comes back carrying \`plan.units[].needs\`, that unit asked for something it gave the user no way to answer \u2014 'options' means it posed a choice with nothing to choose from, 'visuals' means it asked about something to look at with nothing to look at. Send it again on the SAME parentId with 2-4 options (or the image), drawn from your own sentence. Paigy will not add them for you: a shape it guessed wrong cannot be undone, and you are the one who knows what the real alternatives are. \`units\` reports WHAT BECAME OF YOUR PROSE \u2014 { kept, raw, why }: how many topics Paigy compressed for delivery, how many kept your exact words, and the reason when it kept them (e.g. 'no_output' = compression produced nothing usable, so the user got your raw sentence). It needs no action and is not an error \u2014 read it only when the delivered wording matters to you; a high \`raw\` count means the user is hearing you verbatim.`;
142
+ var ONBOARD_DESCRIPTION = "Get this agent talking to Paigy \u2014 call it FIRST, before contact/await_reply, and any time you're unsure who you are. One call, and it does whatever the situation needs: NOT SET UP \u2192 hatches an identity instantly if this machine holds a device credential (the user ran the Paigy desktop app or harness), otherwise starts the code ceremony; ALREADY SET UP \u2192 returns your current identity and offers the two things left to decide, renaming it or unpairing; TOKEN NO LONGER VALID \u2192 says so, then re-pairs. Pass { name, voice } to choose who you are when hatching, or to RENAME yourself when already set up (voices: rachel, george, jessica, brian, lily). Safe to call any time: idempotent, and it never writes settings \u2014 the tool-allowlist state it reports is read-only. If it returns a `user_code`, print it to the user immediately and call onboard again with the `device_code`. If it returns `enable_command`, PRINT that command for the user to run \u2014 you cannot apply it yourself (it writes your own permission allowlist, which hosts block as privilege escalation), so print it, don't wait for it, and carry on.";
143
+ var SERVER_INSTRUCTIONS = "On startup, call check_replies once to pick up any replies or pending work you missed while away. A check_replies request whose parentId you don't recognize, or one carrying a contextParentId, means the user is resuming or seeding a past conversation \u2014 call get_thread on it FIRST and treat the transcript as prior conversation, not new input. To wait for the answer to something you just asked, call await_reply with that notificationId \u2014 it's scoped to that one notification, so it never returns replies meant for other notifications. Use check_replies again only when re-booting or after waiting a long time on something else. Never end a turn that still needs the user without contact + await_reply. When you need a decision or input, WRITE THE QUESTION and Paigy derives the answer shape from it \u2014 there is no shape parameter to set, and passing one is an error. Ask a yes/no question and they get yes/no; ask them to approve an action and they get approve/deny; ask them to pick, and to pick several, and to rank, and each gets the control it needs. So phrase the ask precisely: 'which of these should I do first' and 'should I do this' are different questions and become different answers. The one thing the prose can't supply is the CHOICES themselves \u2014 when you're asking them to pick between concrete alternatives, pass `options` (2-4 of them, drawn from your own sentence), because Paigy will not invent alternatives it can't know. On a { kind: 'clarify' } reply, see contact's own description for how to respond. When you send waiting:'hard' (or the user asked you to call), remember the ask may be spoken aloud \u2014 write it short and conversational, and name things instead of using IDs (e.g. 'the pull request about the agents page', not 'PR #235'). When the user asks you to follow up later \u2014 when you're done, if you're blocked, or at a set time \u2014 record it with schedule_callback so you don't drop it if you go idle. If you're about to start a genuinely long-running or blocking piece of work \u2014 one where the user would otherwise sit and wait \u2014 mention ONCE, in passing, that you can reach them when it's done or if you hit a blocker, instead of them needing to babysit the terminal. Don't offer this for quick tasks, and don't repeat the offer if they've already said yes or no earlier in the conversation. NEVER go quietly idle while something might still be pending for you: whenever you end a turn with any Paigy notification unanswered (or any chance the user replied through the app while you worked), schedule your own ~2-minute wake-up (harness ScheduleWakeup or equivalent) and call check_replies when it fires; if still nothing, re-schedule and keep looping until resolved or the user says stop. For legibility, always use this exact wording \u2014 reason: 'Paigy idle check \u2014 waiting on <thing>', wake-up prompt: 'Paigy idle check: call check_replies and engage with anything unacknowledged; if idle, re-schedule (~2min).' \u2014 so the user can recognize every idle check at a glance. This self-polling in your own live session (full context intact) is the PRIMARY mechanism; the plugin's Stop hooks are only the dead-session safety net.";
134
144
 
135
145
  // src/pairing.ts
136
146
  async function resolvePairing(deviceCode, capMs, pollMs = 2e3) {
@@ -257,9 +267,6 @@ var GetThreadSchema = z.object({
257
267
  var SearchThreadsSchema = z.object({
258
268
  q: z.string().describe("What to look for \u2014 plain words or a phrase (e.g. 'the livekit timeout', 'deploy to prod').")
259
269
  });
260
- var EnableToolsSchema = z.object({
261
- scope: z.enum(["user", "project"]).optional().describe("'user' (default) allowlists Paigy's tools for every project (~/.claude/settings.json); 'project' scopes them to this repo (.claude/settings.json).")
262
- });
263
270
  var SetTaskStateToolSchema = z.object({
264
271
  notificationId: z.string(),
265
272
  state: SetTaskStateSchema.shape.state
@@ -308,8 +315,9 @@ function pairedResult(token, sas, note, e2ee) {
308
315
  } catch {
309
316
  }
310
317
  base.enable_tool_ids = PAIGY_TOOL_IDS;
311
- base.enable_prompt = `REQUIRED \u2014 before you do anything else, ask the user now: "Want me to let Paigy's tools run without an approval prompt each time? I'll only allowlist the notify/await tools \u2014 pair and unpair still ask." Prompt every time you pair; don't skip it.`;
312
- base.enable_apply = "On yes: call the `enable_tools` tool \u2014 it writes the allowlist for you (scope:'user' = every project, the default; scope:'project' = just this repo). No hand-editing. If it returns ok:false (the host isn't Claude Code), fall back to adding `enable_tool_ids` to that tool's own allowlist by hand, merging \u2014 never clobbering. pair/unpair stay out, so they remain human-approved. On no: drop it, don't ask again this session.";
318
+ base.enable_command = ENABLE_COMMAND;
319
+ base.enable_prompt = "REQUIRED \u2014 before you do anything else, print `enable_command` to the user and say: \"Run this to let Paigy's tools work without an approval prompt each time \u2014 it only allowlists the notify/await tools; pair and unpair still ask.\" Print it every time you pair; don't skip it.";
320
+ base.enable_apply = "You cannot apply this yourself, and must not try: it writes YOUR OWN permission allowlist, which hosts block as privilege escalation no matter what the user said here. PRINT the command and move on \u2014 don't wait for them to run it, and don't re-ask. Paigy's tools still work meanwhile; they just prompt for approval each time until the user runs it. If the host isn't Claude Code, tell them to add `enable_tool_ids` to that tool's own allowlist instead, merging \u2014 never clobbering.";
313
321
  return { content: [{ type: "text", text: JSON.stringify(base) }] };
314
322
  }
315
323
  function awaitingConfirmResult(sas, device_code) {
@@ -359,7 +367,7 @@ function unidentifiedResult() {
359
367
  return { isError: true, content: [{ type: "text", text: JSON.stringify({
360
368
  error: "no_identity",
361
369
  slot: AGENT_NAME,
362
- message: `This session has no Paigy identity yet, so nothing was sent \u2014 it will not speak as another session. This machine is already paired, so call \`pair\` (no arguments) to hatch this session its own identity instantly, then retry. To reuse an existing one instead, start the session with PAIGY_AGENT set to its slot (${listSlots().filter((s) => s !== "Desktop").join(", ") || "none yet"}).`
370
+ message: `This session has no Paigy identity yet, so nothing was sent \u2014 it will not speak as another session. This machine holds a device credential but hatching under it just failed (it may have been revoked), so call \`pair\` (no arguments) to set this session up, then retry \u2014 it re-hatches if the credential recovered and runs the code ceremony if it didn't. To reuse an existing identity instead, start the session with PAIGY_AGENT set to its slot (${listSlots().filter((s) => s !== "Desktop").join(", ") || "none yet"}).`
363
371
  }) }] };
364
372
  }
365
373
  function pairStartResult(start) {
@@ -388,29 +396,34 @@ var server = new Server(
388
396
  { name: "paigy", version: "0.0.0" },
389
397
  {
390
398
  capabilities: { tools: {} },
391
- instructions: "On startup, call check_replies once to pick up any replies or pending work you missed while away. A check_replies request whose parentId you don't recognize, or one carrying a contextParentId, means the user is resuming or seeding a past conversation \u2014 call get_thread on it FIRST and treat the transcript as prior conversation, not new input. To wait for the answer to something you just asked, call await_reply with that notificationId \u2014 it's scoped to that one notification, so it never returns replies meant for other notifications. Use check_replies again only when re-booting or after waiting a long time on something else. Never end a turn that still needs the user without contact + await_reply. When you need a decision or input, MATCH the answer shape to the question \u2014 don't default everything to free text, and don't reflexively make everything yes/no. Pick the best tool for the job: yes/no \u2192 select:'confirm'; approve/deny an action \u2192 select:'confirm' + confirmStyle:'approve'; pick one of several \u2192 options + select:'one'; pick several / a subset \u2192 options + select:'many'; rank or prioritize \u2192 options + select:'rank'. Reserve select:'text' (free-form reply only) for plain updates and answers that genuinely can't be structured (the user can always add free text on top of any shape). On a { kind: 'clarify' } reply, see contact's own description for how to respond. When you send waiting:'hard' (or the user asked you to call), remember the ask may be spoken aloud \u2014 write it short and conversational, and name things instead of using IDs (e.g. 'the pull request about the agents page', not 'PR #235'). When the user asks you to follow up later \u2014 when you're done, if you're blocked, or at a set time \u2014 record it with schedule_callback so you don't drop it if you go idle. If you're about to start a genuinely long-running or blocking piece of work \u2014 one where the user would otherwise sit and wait \u2014 mention ONCE, in passing, that you can reach them when it's done or if you hit a blocker, instead of them needing to babysit the terminal. Don't offer this for quick tasks, and don't repeat the offer if they've already said yes or no earlier in the conversation. NEVER go quietly idle while something might still be pending for you: whenever you end a turn with any Paigy notification unanswered (or any chance the user replied through the app while you worked), schedule your own ~2-minute wake-up (harness ScheduleWakeup or equivalent) and call check_replies when it fires; if still nothing, re-schedule and keep looping until resolved or the user says stop. For legibility, always use this exact wording \u2014 reason: 'Paigy idle check \u2014 waiting on <thing>', wake-up prompt: 'Paigy idle check: call check_replies and engage with anything unacknowledged; if idle, re-schedule (~2min).' \u2014 so the user can recognize every idle check at a glance. This self-polling in your own live session (full context intact) is the PRIMARY mechanism; the plugin's Stop hooks are only the dead-session safety net."
399
+ instructions: SERVER_INSTRUCTIONS
392
400
  }
393
401
  );
394
402
  function prependNote(result, note) {
395
403
  return { content: [{ type: "text", text: note }, ...result.content] };
396
404
  }
405
+ async function hatchUnderDevice(name, voice) {
406
+ if (!listSlots().includes("Desktop")) return null;
407
+ overrideToken(readToken("Desktop"));
408
+ try {
409
+ const minted = await hatch(name ?? suggestedAgentName() ?? "Agent", voice ?? null);
410
+ const dt = { ok: true, access_token: minted.token, name: minted.name, device: null };
411
+ saveToken(dt);
412
+ return dt;
413
+ } catch {
414
+ return null;
415
+ } finally {
416
+ overrideToken(null);
417
+ }
418
+ }
397
419
  async function runPair(device_code, name, voice, note) {
398
- if (!device_code && listSlots().includes("Desktop")) {
399
- const device = readToken("Desktop");
400
- overrideToken(device);
401
- try {
402
- const minted = await hatch(name ?? suggestedAgentName() ?? "Agent", voice ?? null);
403
- const dt = { ok: true, access_token: minted.token, name: minted.name, device: null };
404
- saveToken(dt);
405
- return pairedResult(
406
- dt,
407
- void 0,
408
- "Hatched instantly under this device's credential \u2014 no code needed. " + (name ? "" : "You were given a default name \u2014 choose your own name and voice and update them via the identity tools or by re-calling pair with { name, voice }.")
409
- );
410
- } catch {
411
- } finally {
412
- overrideToken(null);
413
- }
420
+ if (!device_code) {
421
+ const dt = await hatchUnderDevice(name, voice);
422
+ if (dt) return pairedResult(
423
+ dt,
424
+ void 0,
425
+ "Hatched instantly under this device's credential \u2014 no code needed. " + (name ? "" : `You were given a default name ("${dt.name}") \u2014 the user never chose it, so don't announce it as their agent's identity. They can rename it in the app, or you can re-call pair with { name, voice }.`)
426
+ );
414
427
  }
415
428
  if (!device_code) {
416
429
  const started2 = pairStartResult(await startPairing(suggestedAgentName()));
@@ -440,7 +453,7 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
440
453
  },
441
454
  {
442
455
  name: "pair",
443
- description: "Pair this agent with the user's Paigy account (one-time) \u2014 required before contact/await_reply work. FAST PATH: if this machine already holds a device credential (the user ran the Paigy desktop harness or app), calling pair hatches a fresh identity INSTANTLY \u2014 no code, no approval. Pass { name, voice } to choose who you are (pick your own; voices: rachel, george, jessica, brian, lily). Only when no device credential exists does the code ceremony below run. It does NOT open a browser; the user enters the code in the Paigy app (or scans `qr`). Step 1: call with NO args \u2014 returns { user_code, device_code, qr, user_message } AND starts polling for approval in the background. REQUIRED: You MUST immediately print the `user_message` (the bare code) as a text message to the user, AND in that same turn call step 2 (pair with the device_code). This ensures the user sees the code in chat while the tool blocks/polls in the background for approval. Step 2: call with that device_code to collect the result. Because approval is already being polled in the background, this returns the moment the user approves; on { status:'pending' } just call again to keep waiting; on { status:'awaiting_confirmation' } (E2EE) show the bare `user_message` verify code and call again to finish. The leading text block of every result states the code plainly, so it shows even if you emit no prose. On { status:'paired' } ALWAYS follow the `enable_prompt` \u2014 ask the user to allowlist Paigy's tools so notify/await don't prompt each time.",
456
+ description: "Pair this agent with the user's Paigy account (one-time) \u2014 required before contact/await_reply work. FAST PATH: if this machine already holds a device credential (the user ran the Paigy desktop harness or app), calling pair hatches a fresh identity INSTANTLY \u2014 no code, no approval. Pass { name, voice } to choose who you are (pick your own; voices: rachel, george, jessica, brian, lily). Only when no device credential exists does the code ceremony below run. It does NOT open a browser; the user enters the code in the Paigy app (or scans `qr`). Step 1: call with NO args \u2014 returns { user_code, device_code, qr, user_message } AND starts polling for approval in the background. REQUIRED: You MUST immediately print the `user_message` (the bare code) as a text message to the user, AND in that same turn call step 2 (pair with the device_code). This ensures the user sees the code in chat while the tool blocks/polls in the background for approval. Step 2: call with that device_code to collect the result. Because approval is already being polled in the background, this returns the moment the user approves; on { status:'pending' } just call again to keep waiting; on { status:'awaiting_confirmation' } (E2EE) show the bare `user_message` verify code and call again to finish. The leading text block of every result states the code plainly, so it shows even if you emit no prose. On { status:'paired' } ALWAYS follow the `enable_prompt` \u2014 PRINT the returned `enable_command` so the user can allowlist Paigy's tools and notify/await stop prompting each time. Printing is the whole job: that command writes your own permission allowlist, so you must not run it and a host will block you if you try.",
444
457
  inputSchema: json(PairSchema)
445
458
  },
446
459
  {
@@ -448,11 +461,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
448
461
  description: "Log out / unpair this agent from the user's Paigy account: revokes the token server-side (it stops working everywhere) and deletes the local ~/.paigy/token.json. Takes no arguments. After this, contact/await_reply won't work until the user pairs again with the pair tool.",
449
462
  inputSchema: json(z.object({}))
450
463
  },
451
- {
452
- name: "enable_tools",
453
- description: "Allowlist Paigy's notify/await tools so they run WITHOUT an approval prompt each time \u2014 call this AFTER pairing, once the user has said yes to the `enable_prompt` (never without their consent). It writes the hosting tool's permission allowlist for you: `scope:'user'` (default) covers every project (~/.claude/settings.json), `scope:'project'` scopes it to this repo (.claude/settings.json). Merges into the existing file (never clobbers) and leaves pair/unpair OUT so they stay human-approved. Returns { ok, path, added, already } on success, or { ok:false, reason } when the host isn't Claude Code (add the ids to that tool's own allowlist by hand). Idempotent \u2014 re-running just reports everything already present.",
454
- inputSchema: json(EnableToolsSchema)
455
- },
456
464
  {
457
465
  name: "await_reply",
458
466
  description: "Wait for the user's reply to a specific notification you sent (pass the notificationId from contact). This is how you wait for your answer in-context. Polls ~45s per call \u2014 deliberately under the 60s cap most hosts put on a single tool call, so it ALWAYS returns you something (raise it with maxWaitSeconds only if you know your host allows longer). Returns { type:'reply', answer } when they respond, { type:'remind', remindInSeconds } on snooze (ScheduleWakeup then await_reply again), or { type:'idle' } (this window ended, no answer yet). While your contact is being handled on a LIVE call, you may receive { type:'partial', inFlight:true, turn } results: what the user said to each turn, as they say it. Use partials to PREPARE \u2014 fetch the data, draft the thing, warm the build \u2014 never to act irreversibly: the user can still revise any of them until the final reply arrives. Partial = intelligence, settled = authorization. If a partial's acts carry a question aimed at you and you know the answer, call contact on the SAME parentId right away \u2014 the caller hears your answer on the same call instead of waiting for a callback. Keep calling await_reply until you get the final reply \u2014 THAT one is the decision. On idle, if this is genuinely still blocking you and you have nothing else useful to do meanwhile, just call await_reply again immediately \u2014 keep looping. This is how you actually deliver on the point of calling: the user steps away for a while and comes back to find you'd already continued the moment they answered, not idle waiting to be checked on. Don't give up after one window. Only stop looping to do other work (and check back later), or after an unreasonably long stretch (tens of minutes to hours) worth telling the user about instead. Scoped to that one notification \u2014 it NEVER returns replies meant for other notifications, so concurrent contact calls don't cross. A CALL answer can come back as {kind:'turns', turns:[{prompt,reply}]} \u2014 the ordered log of that call. Read turns[0].reply as the user's main instruction. Usually that's the only turn; if there are more (e.g. an end-of-call 'call me back when it's done / I have a blocking question'), read each one in order as a further follow-up instruction, not a single combined one. If they asked for a callback, re-engage in the SAME thread (contact with the reply's parentId) when the task is done or you hit a blocker \u2014 waiting:'hard' for a blocker, waiting:'none' for done. Paigy has no scheduler; the callback is yours to send (use ScheduleWakeup/cron for timing). A call-mapped answer may carry `intents` \u2014 next steps the user attached, each { kind, detail } with detail quoting their words. ACT on them, don't just read them: 'defer' (\"call me after lunch\") \u2192 register it NOW with schedule_callback \u2014 when the intent carries `dueInSeconds` (Paigy pre-parsed the spoken time against the user's clock) pass it straight through; otherwise derive it from the detail yourself \u2014 then follow up on the same thread; 'delegate' (\"you pick\") \u2192 make the call yourself and tell them what you chose; 'channel' (\"text me next time\") \u2192 honor it on your next contact (channel:'message'); 'question' (an open question aimed back at you that the call couldn't answer) \u2192 you OWE them the answer \u2014 work it out and follow up on the same thread without being asked, the call deliberately skipped \"should I call you back?\" because the follow-up is implied. `transcript` is the user's raw words behind a shaped answer \u2014 read it for hedges and conditions (\"yes, IF tests pass\") before acting. If your ask declared `points`, the reply carries `covered` \u2014 the points actually addressed. Compare against what you declared: a missing point is STILL unanswered \u2014 re-ask it (contact on the same parentId) or proceed knowingly partial; never treat a partial answer as complete.",
@@ -501,6 +509,9 @@ server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
501
509
  return await handleTool(request, extra?.signal);
502
510
  } catch (e) {
503
511
  if (e instanceof UnpairedError) {
512
+ const IDENTITY_TOOLS = /* @__PURE__ */ new Set(["pair", "onboard", "unpair"]);
513
+ const hatched = IDENTITY_TOOLS.has(request.params.name) ? null : await hatchUnderDevice();
514
+ if (hatched) return await handleTool(request, extra?.signal);
504
515
  if (listSlots().includes("Desktop")) return unidentifiedResult();
505
516
  return pairStartResult(await startPairing(suggestedAgentName()));
506
517
  }
@@ -571,7 +582,8 @@ async function handleTool(request, signal) {
571
582
  tools_allowlisted: allowlisted,
572
583
  ...allowlisted ? {} : {
573
584
  enable_tool_ids: PAIGY_TOOL_IDS,
574
- enable_prompt: "Ask the user: \"Want me to let Paigy's tools run without an approval prompt each time? I'll only allowlist the notify/await tools \u2014 pair and unpair still ask.\" On yes, call `enable_tools`."
585
+ enable_command: ENABLE_COMMAND,
586
+ enable_prompt: "Print `enable_command` to the user: \"Run this to let Paigy's tools work without an approval prompt each time \u2014 it only allowlists the notify/await tools; pair and unpair still ask.\" You cannot run it yourself (it writes your own permission allowlist, which hosts block as privilege escalation) \u2014 print it, don't wait for it, and carry on."
575
587
  },
576
588
  // Setup is done, so the only things left are the user's to decide. Named here
577
589
  // rather than left implicit: an agent that reports "ready" and stops gives the
@@ -613,12 +625,6 @@ async function handleTool(request, signal) {
613
625
  }]
614
626
  };
615
627
  }
616
- case "enable_tools": {
617
- const { scope } = EnableToolsSchema.parse(request.params.arguments ?? {});
618
- const result = enablePaigyTools(scope ?? "user");
619
- const message = result.ok ? `Allowlisted ${result.added.length} Paigy tool(s) in ${result.path}` + (result.already.length ? ` (${result.already.length} already present).` : ".") + " They now run without an approval prompt; restart/reload the tool if it caches settings. pair/unpair stay human-approved." : result.reason;
620
- return { content: [{ type: "text", text: JSON.stringify({ ...result, message }) }] };
621
- }
622
628
  // `contact` (#575) is the one LISTED name; `notify` (#496) and `notify_user`
623
629
  // (the original) are HIDDEN aliases — unlisted but accepted, so stale prompts,
624
630
  // hooks, and cached 0.24 servers' habits keep working. Same handler, same wire.
@@ -691,11 +697,17 @@ async function handleTool(request, signal) {
691
697
  var beatDown = false;
692
698
  async function beat() {
693
699
  try {
694
- await heartbeat();
700
+ const token = readToken();
701
+ if (!token) return;
702
+ await heartbeat(void 0, { token });
695
703
  if (beatDown) console.error("paigy: presence restored \u2014 the live dot is honest again");
696
704
  beatDown = false;
697
705
  } catch (err) {
698
- if (err instanceof UnpairedError) return;
706
+ if (err instanceof UnpairedError) {
707
+ if (!beatDown) console.error("paigy: identity unpaired/revoked \u2014 the live dot goes dark on purpose");
708
+ beatDown = true;
709
+ return;
710
+ }
699
711
  if (!beatDown) console.error(`paigy: presence beat failed \u2014 the phone may show this agent offline (${String(err)})`);
700
712
  beatDown = true;
701
713
  }
package/dist/listen.js CHANGED
@@ -2,11 +2,11 @@
2
2
  import {
3
3
  WAKE_EVENT,
4
4
  wakeChannel
5
- } from "./chunk-Z5FEQ4GK.js";
5
+ } from "./chunk-XSHUDPJ3.js";
6
6
  import {
7
7
  checkReplies,
8
8
  registerDelivery
9
- } from "./chunk-2WPQJYJH.js";
9
+ } from "./chunk-7SFOTYXZ.js";
10
10
 
11
11
  // src/listen.ts
12
12
  import { createClient } from "@supabase/supabase-js";
package/dist/onboard.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  autoConfigureClients,
4
4
  claudeInstallHint,
5
5
  openBrowser
6
- } from "./chunk-ENE65M5Y.js";
6
+ } from "./chunk-LKA7UMRZ.js";
7
7
  import {
8
8
  AGENT_NAME,
9
9
  TOKEN_PATH,
@@ -17,7 +17,7 @@ import {
17
17
  setIdentity,
18
18
  sleep,
19
19
  whoAmI
20
- } from "./chunk-2WPQJYJH.js";
20
+ } from "./chunk-7SFOTYXZ.js";
21
21
 
22
22
  // src/onboard.ts
23
23
  async function main() {
@@ -6,7 +6,7 @@ import {
6
6
  BACKEND_URL,
7
7
  reach,
8
8
  readToken
9
- } from "./chunk-2WPQJYJH.js";
9
+ } from "./chunk-7SFOTYXZ.js";
10
10
 
11
11
  // src/statusline.ts
12
12
  import { mkdirSync, readFileSync, realpathSync, writeFileSync } from "fs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@paigy/mcp",
3
- "version": "0.31.0",
4
- "description": "Paigy MCP server — a voice inbox for your AI agents. Lets an agent notify a user and await their reply.",
3
+ "version": "0.32.0",
4
+ "description": "Paigy MCP server — the AI agent harness that calls you. Lets an agent notify a user and await their reply.",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "bin": {
@@ -9,7 +9,8 @@
9
9
  "paigy-mcp": "./dist/index.js",
10
10
  "paigy-mcp-onboard": "./dist/onboard.js",
11
11
  "paigy-listen": "./dist/listen.js",
12
- "paigy-statusline": "./dist/statusline.js"
12
+ "paigy-statusline": "./dist/statusline.js",
13
+ "paigy-enable-tools": "./dist/enable.js"
13
14
  },
14
15
  "files": [
15
16
  "dist"
@@ -22,6 +23,13 @@
22
23
  "url": "git+https://github.com/mauurda/paigy.git",
23
24
  "directory": "apps/mcp"
24
25
  },
26
+ "scripts": {
27
+ "build": "tsup",
28
+ "dev": "tsup --watch",
29
+ "typecheck": "tsc --noEmit",
30
+ "test": "vitest run",
31
+ "prepublishOnly": "pnpm --filter @paigy/schema build && pnpm --filter @paigy/crypto build && pnpm --filter @paigy/sdk build && pnpm build"
32
+ },
25
33
  "dependencies": {
26
34
  "@modelcontextprotocol/sdk": "^1.0.4",
27
35
  "@supabase/supabase-js": "^2.47.10",
@@ -31,19 +39,13 @@
31
39
  "zod-to-json-schema": "^3.24.1"
32
40
  },
33
41
  "devDependencies": {
42
+ "@paigy/crypto": "workspace:*",
43
+ "@paigy/schema": "workspace:*",
44
+ "@paigy/sdk": "workspace:*",
34
45
  "@types/node": "^22.0.0",
35
46
  "@types/qrcode-generator": "^1.0.6",
36
47
  "tsup": "^8.3.5",
37
48
  "typescript": "^5.7.2",
38
- "vitest": "^2.1.8",
39
- "@paigy/schema": "0.0.0",
40
- "@paigy/sdk": "0.2.0",
41
- "@paigy/crypto": "0.0.0"
42
- },
43
- "scripts": {
44
- "build": "tsup",
45
- "dev": "tsup --watch",
46
- "typecheck": "tsc --noEmit",
47
- "test": "vitest run"
49
+ "vitest": "^2.1.8"
48
50
  }
49
- }
51
+ }