@theronap/agnoclast-mcp 0.9.331 → 0.9.332

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.
@@ -19,9 +19,21 @@
19
19
  //
20
20
  // ⚠ THE POST IS NOT IDEMPOTENT. Never retried: a 5xx may mean the request was created.
21
21
 
22
- /** PURE. The draft preview — unchanged in spirit from the old tool. */
23
- export function draftText({ recipient, message }) {
24
- return `📝 DRAFT (not sent) — to ${recipient}:\n${message}\n\n(Call send_imessage again with send:true to ask the user to approve it.)`
22
+ /** PURE. The draft preview. A reply names the conversation; the server finds the number when it is sent. */
23
+ export function draftText({ recipient, replyTo, message }) {
24
+ const to = replyTo ? `the conversation with ${replyTo} (Agnoclast finds the number when you send)` : recipient
25
+ const again = replyTo ? 'with the same reply_to and send:true' : 'with send:true'
26
+ return `📝 DRAFT (not sent) — to ${to}:\n${message}\n\n(Call send_imessage again ${again} to ask the user to approve it.)`
27
+ }
28
+
29
+ /**
30
+ * PURE. Does `recipient` look like something a text can be addressed to? The server decides for real; this only
31
+ * stops a DRAFT from looking fine for a recipient the send will refuse (2026-11-07: a draft "to Andres" previewed,
32
+ * and the send then said "Andres" is not a phone number). A name belongs in reply_to.
33
+ */
34
+ export function looksAddressable(recipient) {
35
+ const s = String(recipient ?? '').trim()
36
+ return s.includes('@') || /^\+?[0-9 ().\-]{7,}$/.test(s)
25
37
  }
26
38
 
27
39
  /**
@@ -32,6 +44,8 @@ export function draftText({ recipient, message }) {
32
44
  * Returns { text, isError }.
33
45
  */
34
46
  export function textRequestReply(status, body, recipient) {
47
+ // A reply's recipient is the person's name from the server (`recipientName`), never the number.
48
+ if (typeof body?.recipientName === 'string' && body.recipientName) recipient = body.recipientName
35
49
  const msg = typeof body?.error === 'string' ? body.error : null
36
50
  if (status === 201 || (status >= 200 && status < 300)) {
37
51
  const reviewUrl = body?.reviewUrl
@@ -61,18 +75,24 @@ export function textRequestReply(status, body, recipient) {
61
75
  * Tool entry. `request` is the injected POST (fetchCortex with retries off, in server.mjs), so this
62
76
  * stays testable without a network.
63
77
  */
64
- export async function runSendImessage({ recipient, message, send }, request) {
65
- if (!recipient || !String(recipient).trim()) return { isError: true, text: 'Name who to text: a phone number or an iMessage email address.' }
78
+ export async function runSendImessage({ recipient, replyTo, message, send }, request) {
79
+ const hasTo = !!recipient && !!String(recipient).trim()
80
+ const hasReply = !!replyTo && !!String(replyTo).trim()
81
+ if (hasTo && hasReply) return { isError: true, text: 'Give recipient OR reply_to, not both.' }
82
+ if (!hasTo && !hasReply) return { isError: true, text: 'Name who to text: a phone number or iMessage email in recipient, or — to answer a text — the person\'s name or their text\'s id in reply_to.' }
83
+ if (hasTo && !looksAddressable(recipient)) {
84
+ return { isError: true, text: `"${String(recipient).trim().slice(0, 80)}" is not a phone number or iMessage email. To answer someone who texted the user, pass their name as reply_to instead; otherwise ask the user for the number.` }
85
+ }
66
86
  if (!message || !String(message).trim()) return { isError: true, text: 'The text is empty.' }
67
- if (send !== true) return { isError: false, text: draftText({ recipient, message }) }
87
+ if (send !== true) return { isError: false, text: draftText({ recipient, replyTo: hasReply ? String(replyTo).trim() : undefined, message }) }
68
88
  let res
69
89
  try {
70
- res = await request({ to: String(recipient).trim(), text: String(message) })
90
+ res = await request(hasReply ? { replyTo: String(replyTo).trim(), text: String(message) } : { to: String(recipient).trim(), text: String(message) })
71
91
  } catch (e) {
72
92
  return { isError: true, text:
73
93
  `Could not confirm the text request: ${e?.message ?? e} ⚠ It may have been created anyway. ` +
74
94
  `Do NOT call send_imessage again — ask the user to check Email in Agnoclast.` }
75
95
  }
76
96
  const body = await res.json().catch(() => null)
77
- return textRequestReply(res.status, body, recipient)
97
+ return textRequestReply(res.status, body, hasReply ? String(replyTo).trim() : recipient)
78
98
  }
package/lib/server.mjs CHANGED
@@ -8410,16 +8410,17 @@ function renderNudge(payload) {
8410
8410
  'send_imessage',
8411
8411
  {
8412
8412
  title: 'Ask to send a text (iMessage) from the user\'s Mac',
8413
- description: 'Text someone from the USER\'S OWN Mac, through Messages. Without send:true this only returns a draft preview. With send:true it creates a request that WAITS for the user to approve it in Agnoclast (Email → Waiting), unless their own send rule allows it; once approved, their Mac sends it within about a minute. The text is frozen when the request is made, so write the final wording, and show the user what you are about to send first. Returns an approval link to relay, or confirmation that their rule approved it. ⚠ NEVER call it twice with send:true for the same text — it is not idempotent.',
8413
+ description: 'Text someone from the USER\'S OWN Mac, through Messages. To answer a text they got, pass reply_to (the person\'s name, or the id of their text) instead of recipient: Agnoclast finds the number, which you never need. Without send:true this only returns a draft preview. With send:true it creates a request that WAITS for the user to approve it (their phone is notified), unless their own send rule allows it; once approved, their Mac sends it within about a minute. The text is frozen when the request is made, so write the final wording, and show the user what you are about to send first. ⚠ NEVER call it twice with send:true for the same text — it is not idempotent.',
8414
8414
  inputSchema: {
8415
- recipient: z.string().describe('one phone number (e.g. +18015551234, or (801) 555-1234 for a US number) or iMessage email address'),
8415
+ recipient: z.string().optional().describe('one phone number (e.g. +18015551234, or (801) 555-1234 for a US number) or iMessage email address. Omit when using reply_to'),
8416
+ reply_to: z.string().optional().describe('instead of recipient: the conversation to answer — the person\'s name as their texts show it (e.g. "Zach Nielsen"), or the id of a captured text from them'),
8416
8417
  message: z.string().describe('the text to send'),
8417
8418
  send: z.boolean().optional().describe('true to ask the user to approve sending it; omit or false for a draft preview only'),
8418
8419
  confirm: z.string().optional().describe('NO LONGER USED — approval happens in Agnoclast now. Ignored.'),
8419
8420
  },
8420
8421
  },
8421
- async ({ recipient, message, send }) => {
8422
- const r = await runSendImessage({ recipient, message, send }, (body) => fetchCortex(`${BASE}/api/texts/send-requests`, {
8422
+ async ({ recipient, reply_to, message, send }) => {
8423
+ const r = await runSendImessage({ recipient, replyTo: reply_to, message, send }, (body) => fetchCortex(`${BASE}/api/texts/send-requests`, {
8423
8424
  method: 'POST',
8424
8425
  headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
8425
8426
  body: JSON.stringify(body),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theronap/agnoclast-mcp",
3
- "version": "0.9.331",
3
+ "version": "0.9.332",
4
4
  "description": "Connect your AI assistant to Cortex — your org's projects, activity, gaps, and directives, scoped to you.",
5
5
  "type": "module",
6
6
  "bin": {