@grknbyk/agent-wire 0.13.1 → 0.13.2
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/package.json +1 -1
- package/src/inbox.mjs +7 -3
- package/src/mcp.mjs +5 -5
- package/src/protocol.mjs +5 -1
package/package.json
CHANGED
package/src/inbox.mjs
CHANGED
|
@@ -160,9 +160,13 @@ export const findByTs = (ts) => readInbox().find((item) => item.ts === ts) ?? nu
|
|
|
160
160
|
|
|
161
161
|
// Newest first: a ref is short enough to collide eventually, and the one a person
|
|
162
162
|
// just read off the channel is the recent one.
|
|
163
|
-
export
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
export function findByRef(handle) {
|
|
164
|
+
const [channel, ref] = String(handle).toLowerCase().split('@');
|
|
165
|
+
const wanted = ref ?? channel;
|
|
166
|
+
return readInbox()
|
|
167
|
+
.filter((item) => item.ref === wanted && (!ref || !channel || item.channel === channel))
|
|
168
|
+
.at(-1) ?? null;
|
|
169
|
+
}
|
|
166
170
|
|
|
167
171
|
export const readCursor = (channelId) => readJsonCached(paths.cursors, {})[channelId] ?? null;
|
|
168
172
|
|
package/src/mcp.mjs
CHANGED
|
@@ -262,7 +262,7 @@ async function sendText(config, { to, text, channel, replyTo }) {
|
|
|
262
262
|
|
|
263
263
|
const client = slackClient(config.bot_token);
|
|
264
264
|
const ref = mintRef();
|
|
265
|
-
const rendered = formatMessage({ mark: config.mark, from: config.nickname, to, text, ref });
|
|
265
|
+
const rendered = formatMessage({ mark: config.mark, from: config.nickname, to, text, ref, channel: target.name });
|
|
266
266
|
const signature = signMessage(config.private_key, {
|
|
267
267
|
channel: target.id, from: config.nickname, to, conv: chain.conv, hop: chain.hop, text,
|
|
268
268
|
});
|
|
@@ -279,7 +279,7 @@ async function sendText(config, { to, text, channel, replyTo }) {
|
|
|
279
279
|
if (!posted.ok) return `Slack rejected it (${posted.reason})`;
|
|
280
280
|
|
|
281
281
|
recordOwnMessage(config, { ts: posted.ts, target, to, text, chain, ref });
|
|
282
|
-
return `delivered to ${to} in #${target.name} as @${ref}`;
|
|
282
|
+
return `delivered to ${to} in #${target.name} as ${target.name}@${ref}`;
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
// Our own sent messages go into the local log too, so the log is a complete
|
|
@@ -319,7 +319,7 @@ async function postFile(config, { to, path, note, target, chain, logText }) {
|
|
|
319
319
|
});
|
|
320
320
|
const posted = await postMessage(client, {
|
|
321
321
|
channel: target.id,
|
|
322
|
-
rendered: formatMessage({ mark: config.mark, from: config.nickname, to, text, ref }),
|
|
322
|
+
rendered: formatMessage({ mark: config.mark, from: config.nickname, to, text, ref, channel: target.name }),
|
|
323
323
|
signature,
|
|
324
324
|
publicKey: config.public_key,
|
|
325
325
|
from: config.nickname,
|
|
@@ -351,7 +351,7 @@ async function sendLongText(config, { to, text, target, chain }) {
|
|
|
351
351
|
unlinkSync(path);
|
|
352
352
|
if (!result.ok) return result.message;
|
|
353
353
|
|
|
354
|
-
return `delivered to ${to} in #${result.channelName} as @${result.ref} — ${text.length} characters, sent as a file`;
|
|
354
|
+
return `delivered to ${to} in #${result.channelName} as ${result.channelName}@${result.ref} — ${text.length} characters, sent as a file`;
|
|
355
355
|
}
|
|
356
356
|
|
|
357
357
|
async function call(name, args, session) {
|
|
@@ -454,7 +454,7 @@ async function call(name, args, session) {
|
|
|
454
454
|
});
|
|
455
455
|
if (!result.ok) return result.message;
|
|
456
456
|
|
|
457
|
-
return `sent ${result.name} to ${args.to} in #${result.channelName} as @${result.ref}`;
|
|
457
|
+
return `sent ${result.name} to ${args.to} in #${result.channelName} as ${result.channelName}@${result.ref}`;
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
if (name === 'archive') return `archived ${archive(args.ts)} message(s)`;
|
package/src/protocol.mjs
CHANGED
|
@@ -72,7 +72,11 @@ export function formatMessage({ mark, from, to, text, ref, channel }) {
|
|
|
72
72
|
const left = `${mark ? `${mark} ` : ''}${from} => ${to}`;
|
|
73
73
|
if (!ref) return `${left}\n${toSlackText(text)}\n`;
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
// Shipped once without this: a call site forgot the channel, the handle went out
|
|
76
|
+
// bare, and every test still passed because they all called this directly.
|
|
77
|
+
if (!channel) throw new TypeError(`formatMessage: ref ${ref} with no channel to put in front of it`);
|
|
78
|
+
|
|
79
|
+
const handle = `${channel}@${ref}`;
|
|
76
80
|
const gap = Math.max(1, HEADER_WIDTH - displayWidth(left) - handle.length);
|
|
77
81
|
return `${left}${' '.repeat(gap)}${handle}\n${toSlackText(text)}\n`;
|
|
78
82
|
}
|