@grknbyk/agent-wire 0.13.6 → 0.13.7
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/slack.mjs +9 -1
package/package.json
CHANGED
package/src/slack.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
6
6
|
import { paths, readJsonCached, writeJson } from './config.mjs';
|
|
7
7
|
import { checkAuthorship } from './identity.mjs';
|
|
8
8
|
import { HUMAN_TEXT_CAP, METADATA_EVENT, fromSlackText, parseMessage } from './protocol.mjs';
|
|
9
|
+
import { installedVersion } from './version.mjs';
|
|
9
10
|
|
|
10
11
|
const API = 'https://slack.com/api/';
|
|
11
12
|
const RATE_LIMITED = 429;
|
|
@@ -136,13 +137,19 @@ export async function listMembers(client, channelId) {
|
|
|
136
137
|
// `rendered` is the whole visible message — header line plus body — because that
|
|
137
138
|
// is what a human scrolling the channel reads. The signature and routing fields
|
|
138
139
|
// travel in metadata, which Slack never renders.
|
|
140
|
+
// "which of us is on an old build" was a question nobody could answer without
|
|
141
|
+
// asking each person, so every message carries the version that sent it. Not
|
|
142
|
+
// signed, like the rest of the envelope around the signature: it answers a
|
|
143
|
+
// housekeeping question, and a sender who lies about it is lying to no effect.
|
|
139
144
|
export async function postMessage(client, { channel, rendered, signature, publicKey, from, to, conv, hop, file }) {
|
|
140
145
|
const result = await client.json('chat.postMessage', {
|
|
141
146
|
channel,
|
|
142
147
|
text: rendered,
|
|
143
148
|
metadata: {
|
|
144
149
|
event_type: METADATA_EVENT,
|
|
145
|
-
event_payload: {
|
|
150
|
+
event_payload: {
|
|
151
|
+
v: 2, av: installedVersion(), from, to, conv, hop, file: file ?? '', sig: signature, key: publicKey,
|
|
152
|
+
},
|
|
146
153
|
},
|
|
147
154
|
});
|
|
148
155
|
if (result.ok) return { ok: true, ts: result.ts };
|
|
@@ -299,6 +306,7 @@ async function agentItem(client, message, channel, payload) {
|
|
|
299
306
|
authorship: authorship.verdict,
|
|
300
307
|
conv: payload.conv,
|
|
301
308
|
hop: Number(payload.hop) || 1,
|
|
309
|
+
wireVersion: payload.av ?? '',
|
|
302
310
|
ref: parsed?.ref ?? '',
|
|
303
311
|
text,
|
|
304
312
|
files,
|