cli-jaw 2.17.75 → 2.17.76
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/src/code-mode/manager.js +51 -7
- package/dist/src/code-mode/manager.js.map +1 -1
- package/dist/src/code-mode/normalize.js +3 -2
- package/dist/src/code-mode/normalize.js.map +1 -1
- package/dist/src/code-mode/session.js +10 -2
- package/dist/src/code-mode/session.js.map +1 -1
- package/dist/src/code-mode/store.js +265 -27
- package/dist/src/code-mode/store.js.map +1 -1
- package/dist/src/code-mode/wire.js +4 -1
- package/dist/src/code-mode/wire.js.map +1 -1
- package/dist/src/routes/code-native.js +56 -5
- package/dist/src/routes/code-native.js.map +1 -1
- package/dist/src/slack/blocks.js +22 -3
- package/dist/src/slack/blocks.js.map +1 -1
- package/dist/src/slack/bot.js +239 -26
- package/dist/src/slack/bot.js.map +1 -1
- package/dist/src/slack/events.js +99 -2
- package/dist/src/slack/events.js.map +1 -1
- package/dist/src/slack/identity.js +30 -0
- package/dist/src/slack/identity.js.map +1 -1
- package/dist/src/slack/ingress.js +5 -4
- package/dist/src/slack/ingress.js.map +1 -1
- package/package.json +1 -1
- package/public/dist/.vite/manifest.json +3 -3
- package/public/dist/assets/CodeCanvas-DLXPccm9.js +3 -0
- package/public/dist/assets/manager-CZcR8tfs.css +1 -0
- package/public/dist/assets/{manager-DIaOU2Vf.js → manager-HCkO4cai.js} +1 -1
- package/public/dist/manager/index.html +2 -2
- package/public/manager/src/code/CodeWorkbench.tsx +48 -4
- package/public/manager/src/code/ComposerFooter.tsx +21 -7
- package/public/manager/src/code/code-composer.css +1 -0
- package/public/manager/src/code/code-controller-draft-storage.ts +45 -6
- package/public/manager/src/code/code-controller-drafts.ts +14 -2
- package/public/manager/src/code/code-controller-runtime.ts +312 -17
- package/public/manager/src/code/code-controller-types.ts +43 -0
- package/public/manager/src/code/code-session-client.ts +22 -3
- package/public/manager/src/code/code-session-state.ts +1 -0
- package/public/manager/src/code/code-ulid.ts +19 -0
- package/public/manager/src/code/code-workbench.css +3 -0
- package/public/dist/assets/CodeCanvas-Ba7ROkA8.js +0 -3
- package/public/dist/assets/manager-DQjyj2aO.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../../src/slack/blocks.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAMrD,SAAS,OAAO,CAAC,OAAe;IAC5B,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACnG,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAC/C,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,SAAS,CAAC;IACpC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE;WAC7D,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;eAC3D,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,OAAO,OAAO,CAAC,+DAA+D,CAAC,CAAC;IACpF,CAAC;IACD,OAAO,KAAqB,CAAC;AACjC,CAA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,GAAG,OAAO,CAAC,MAAM,CAAC;IACjD,CAAC;IACD,KAAK,EAAE,CAAC;IACR,OAAO,QAAQ,CAAC;AACpB,CAAC"}
|
package/dist/src/slack/bot.js
CHANGED
|
@@ -44,7 +44,7 @@ import { getQueueNoticeStore } from '../messaging/queue-notice-store.js';
|
|
|
44
44
|
import { createSlackNoticeTransport } from './notice-transport.js';
|
|
45
45
|
import { currentGenerationForEnvelope } from '../messaging/ingress-generation.js';
|
|
46
46
|
import { slackInboundEnvelope } from '../messaging/inbound-envelope.js';
|
|
47
|
-
import { readSlackAllowlist, resolveEventText, shouldAttachSlack, shouldProcessSlackEvent } from './events.js';
|
|
47
|
+
import { readSlackAllowlist, resolveEventText, shouldAttachSlack, shouldProcessSlackEvent, slackBlockActionEvent, SLACK_AGENT_ACTION_PREFIX } from './events.js';
|
|
48
48
|
import { captureMentionWatchInbox } from './mention-watch-inbox.js';
|
|
49
49
|
import { markThreadParticipated, threadParticipationKind, claimThreadPrefetch, commitThreadPrefetch, releaseThreadPrefetch, resetThreadPrefetchClaims, } from './thread-tracker.js';
|
|
50
50
|
import { sendSlackText, getSlackSendClient } from './send-only-client.js';
|
|
@@ -54,14 +54,14 @@ import { createSlackForwarder, relaySlackImages } from './forwarder.js';
|
|
|
54
54
|
import { nextDeliverySeq, wasSelfDelivered } from '../messaging/turn-delivery.js';
|
|
55
55
|
import { shouldSkipForwarding } from '../messaging/forwarder-origin.js';
|
|
56
56
|
import { requiresNativeBodyDelivery } from '../messaging/native-body.js';
|
|
57
|
-
import { visibleReplyText } from '../messaging/silent-reply.js';
|
|
57
|
+
import { hasSilentLine, visibleReplyText, withoutSilentLines } from '../messaging/silent-reply.js';
|
|
58
58
|
import { createQueueNoticeRecorder } from '../messaging/queue-notice-record.js';
|
|
59
59
|
import { admitTargetReply } from '../messaging/target-reply-guard.js';
|
|
60
60
|
import { handleSlackSlashCommand } from './commands.js';
|
|
61
61
|
import { logErrorText, redactOutboundText } from '../messaging/redact.js';
|
|
62
62
|
import { downloadAndSaveSlackFiles } from './inbound-file.js';
|
|
63
63
|
import { admitSlackRun, claimSlackEvent, commitSlackEvent, currentIngressGeneration, enqueueSlackIngress, isIngressGenerationCurrent, resetSlackIngress, resolveSlackScopeForTarget, slackEventKey, slackIngressLaneKey } from './ingress.js';
|
|
64
|
-
import { buildSenderDisplay, buildSenderPrompt, resolveSenderIdentity } from './identity.js';
|
|
64
|
+
import { buildSenderDisplay, buildSenderPrompt, resolveSenderIdentity, lookupSlackBotApp, lookupSlackClicker } from './identity.js';
|
|
65
65
|
import { admitHistoryStart, cachedNameMap, resolveConversationInfo, resolveThreadInfo, THREAD_FETCH_LIMIT, } from './conversation.js';
|
|
66
66
|
import { fetchSlackHistory, fetchSlackReplies, formatHistoryForAgent } from './history.js';
|
|
67
67
|
import { buildSlackContextBlock, applySlackContext, buildThreadPreamble, ROSTER_PREVIEW } from './context.js';
|
|
@@ -80,6 +80,12 @@ let selfUserId = null;
|
|
|
80
80
|
// bot id matters because this app's own answers post AS the bot (bot_id), not
|
|
81
81
|
// as the user behind the token.
|
|
82
82
|
let selfBotId = null;
|
|
83
|
+
let selfAppId = null;
|
|
84
|
+
export function setSlackSelfIdentityForTest(identity) {
|
|
85
|
+
selfUserId = identity.userId;
|
|
86
|
+
selfBotId = identity.botId;
|
|
87
|
+
selfAppId = identity.appId ?? null;
|
|
88
|
+
}
|
|
83
89
|
let slackInitLock = false;
|
|
84
90
|
let activeClaimArbiter = null;
|
|
85
91
|
let claimRecheckTimer = null;
|
|
@@ -336,6 +342,13 @@ function isPreSendBaseContext(value) {
|
|
|
336
342
|
&& typeof value['requester'] === 'string'
|
|
337
343
|
&& typeof value['jobKind'] === 'string');
|
|
338
344
|
}
|
|
345
|
+
const SLACK_BLOCK_ACTION_JOB = 'slack_block_action';
|
|
346
|
+
function isSlackBlockActionContext(context) {
|
|
347
|
+
return isPreSendBaseContext(context) && context.jobKind === SLACK_BLOCK_ACTION_JOB;
|
|
348
|
+
}
|
|
349
|
+
function isSilentBlockActionReply(text, context) {
|
|
350
|
+
return isSlackBlockActionContext(context) && hasSilentLine(text) && !withoutSilentLines(text);
|
|
351
|
+
}
|
|
339
352
|
function buildSlackPreSendContext(target, base, requestId, data) {
|
|
340
353
|
const dataBase = isPreSendBaseContext(data['preSendContext']) ? data['preSendContext'] : undefined;
|
|
341
354
|
const finalRequestId = typeof data['requestId'] === 'string' && data['requestId'].trim()
|
|
@@ -683,6 +696,12 @@ function trackSlackReply(options) {
|
|
|
683
696
|
const unconfirmed = data['workflowUnconfirmed'] === true || Boolean(options.workflow && isWorkflowReplyUnconfirmed(rawText, data));
|
|
684
697
|
if (unconfirmed)
|
|
685
698
|
outcomeData = { ...data, workflowUnconfirmed: true };
|
|
699
|
+
if (!unconfirmed && data['error'] !== true
|
|
700
|
+
&& isSilentBlockActionReply(rawText, data['preSendContext'] ?? options.preSendContext)) {
|
|
701
|
+
log.info(`[slack:out:silent] ${target.targetId}: block action ended silently`);
|
|
702
|
+
await Promise.allSettled([settleAck('success'), display.finish('complete')]);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
686
705
|
const text = unconfirmed ? workflowDiagnosticText(rawText, t('slack.workflow.unconfirmed', {}, locale))
|
|
687
706
|
: data['error'] === true && !requireBodyDelivery ? t('slack.progress.failure', {}, locale)
|
|
688
707
|
: requireBodyDelivery && !rawText.trim() ? '' : visibleReplyText(rawText, t('tg.noResponse', {}, locale));
|
|
@@ -718,7 +737,9 @@ function trackSlackReply(options) {
|
|
|
718
737
|
});
|
|
719
738
|
}, true);
|
|
720
739
|
}
|
|
721
|
-
|
|
740
|
+
const showProgress = !isSlackBlockActionContext(options.preSendContext);
|
|
741
|
+
if (showProgress)
|
|
742
|
+
slackNoticeRecord.reserve(requestId, target);
|
|
722
743
|
display = createSlackProgressLifecycle({
|
|
723
744
|
token, target, requestId, scope: session.scope, sessionId: session.chatSessionId, locale,
|
|
724
745
|
workflowResponse: Boolean(options.workflow),
|
|
@@ -747,7 +768,8 @@ function trackSlackReply(options) {
|
|
|
747
768
|
pendingQueueRequestIds.add(requestId);
|
|
748
769
|
signal.addEventListener('abort', abortInput, { once: true });
|
|
749
770
|
resetTimer();
|
|
750
|
-
|
|
771
|
+
if (showProgress)
|
|
772
|
+
display.start({ initialPhase });
|
|
751
773
|
void ack?.to('running', { wasQueued: initialPhase === 'queued' });
|
|
752
774
|
}
|
|
753
775
|
function installSlackTargetReplyForwarder() {
|
|
@@ -788,7 +810,8 @@ function installSlackTargetReplyForwarder() {
|
|
|
788
810
|
? workflowDiagnosticText(String(data['text'] ?? ''), t('slack.workflow.unconfirmed', {}, currentLocale()))
|
|
789
811
|
: data['error'] === true && !requireBodyDelivery
|
|
790
812
|
? t('slack.progress.failure', {}, currentLocale())
|
|
791
|
-
:
|
|
813
|
+
: isSilentBlockActionReply(String(data['text'] ?? ''), data['preSendContext']) ? ''
|
|
814
|
+
: visibleReplyText(String(data['text'] ?? ''), t('tg.noResponse', {}, currentLocale()));
|
|
792
815
|
const requestId = admitted.requestId;
|
|
793
816
|
const scope = slackReplyDelivery.scope(requestId, target)
|
|
794
817
|
?? (typeof data['scope'] === 'string' ? data['scope'] : 'default');
|
|
@@ -891,11 +914,13 @@ async function slackOrchestrate(target, prompt, displayMsg, signal, dedupe = {})
|
|
|
891
914
|
let bodyAttempted = false;
|
|
892
915
|
let bodySucceeded = false;
|
|
893
916
|
let bodyConfirmed = false;
|
|
917
|
+
let silent = false;
|
|
894
918
|
let resultData = {};
|
|
895
919
|
const current = () => !shutdownSealed && !slackStopping && !signal.aborted && generation === lifecycleGeneration;
|
|
896
920
|
if (!current())
|
|
897
921
|
return;
|
|
898
|
-
|
|
922
|
+
const showProgress = !isSlackBlockActionContext(dedupe.preSendContext);
|
|
923
|
+
if (ctx.requestId && showProgress)
|
|
899
924
|
slackNoticeRecord.reserve(ctx.requestId, target);
|
|
900
925
|
const display = createSlackProgressLifecycle({
|
|
901
926
|
token, target, requestId: ctx.requestId, scope: ctx.scope, sessionId: ctx.chatSessionId, locale,
|
|
@@ -913,7 +938,8 @@ async function slackOrchestrate(target, prompt, displayMsg, signal, dedupe = {})
|
|
|
913
938
|
void display.finish(executionOutcome ?? 'expired');
|
|
914
939
|
};
|
|
915
940
|
signal.addEventListener('abort', abortInput, { once: true });
|
|
916
|
-
|
|
941
|
+
if (showProgress)
|
|
942
|
+
display.start({ initialPhase: 'running' });
|
|
917
943
|
void ack?.to('running');
|
|
918
944
|
const turnStartedAt = nextDeliverySeq();
|
|
919
945
|
try {
|
|
@@ -944,6 +970,12 @@ async function slackOrchestrate(target, prompt, displayMsg, signal, dedupe = {})
|
|
|
944
970
|
const unconfirmed = resultData['workflowUnconfirmed'] === true || Boolean(dedupe.workflow && isWorkflowReplyUnconfirmed(collected.text, resultData));
|
|
945
971
|
if (unconfirmed)
|
|
946
972
|
resultData = { ...resultData, workflowUnconfirmed: true };
|
|
973
|
+
silent = !unconfirmed && !collected.data.collectionFailure && isSilentBlockActionReply(collected.text, dedupe.preSendContext);
|
|
974
|
+
if (silent) {
|
|
975
|
+
log.info(`[slack:out:silent] ${target.targetId}: block action ended silently`);
|
|
976
|
+
await settleAck('success');
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
947
979
|
const text = unconfirmed ? workflowDiagnosticText(collected.text, t('slack.workflow.unconfirmed', {}, locale))
|
|
948
980
|
: collected.data.collectionFailure === 'error' ? t('slack.progress.failure', {}, locale)
|
|
949
981
|
: collected.data.collectionFailure === 'timeout' ? t('tg.timeout', {}, locale)
|
|
@@ -989,7 +1021,7 @@ async function slackOrchestrate(target, prompt, displayMsg, signal, dedupe = {})
|
|
|
989
1021
|
finally {
|
|
990
1022
|
signal.removeEventListener('abort', abortInput);
|
|
991
1023
|
await settleAck('failure');
|
|
992
|
-
await display.finish(bodyProgressOutcome(resultData, bodySucceeded, executionOutcome, !current()), bodyAttempted ? { bodyDelivered: bodyConfirmed } : {});
|
|
1024
|
+
await display.finish(bodyProgressOutcome(resultData, bodySucceeded || silent, executionOutcome, !current()), bodyAttempted ? { bodyDelivered: bodyConfirmed } : {});
|
|
993
1025
|
}
|
|
994
1026
|
},
|
|
995
1027
|
});
|
|
@@ -1260,6 +1292,15 @@ async function runSlackMessageEvent(event, target, text, signal, opts, commitPre
|
|
|
1260
1292
|
const toolSource = workspace && workspace.teamId === opts.socketTeamId && event.user && sourceToken
|
|
1261
1293
|
? { teamId: workspace.teamId, actorId: event.user, destination: target, credentialKey: slackCredentialKey(sourceToken),
|
|
1262
1294
|
...(typeof event.action_token === 'string' ? { actionToken: event.action_token } : {}) } : undefined;
|
|
1295
|
+
const binding = opts.clickBinding;
|
|
1296
|
+
if (event.type === 'block_actions' && (!toolSource || !binding || sourceToken !== binding.token
|
|
1297
|
+
|| sourceToken !== getSlackSendClient().token || workspace?.userId !== binding.selfUserId
|
|
1298
|
+
|| selfUserId !== binding.selfUserId || selfBotId !== binding.selfBotId || selfAppId !== binding.selfAppId
|
|
1299
|
+
|| lifecycleGeneration !== binding.generation || toolSource.teamId !== binding.teamId
|
|
1300
|
+
|| binding.teamId !== String(settings['slack']?.teamId || ''))) {
|
|
1301
|
+
log.info('[slack:click] refused (grant_unavailable)');
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1263
1304
|
await slackOrchestrate(target, prompt, displayText, signal, {
|
|
1264
1305
|
...(workflow.kind === 'ready' ? { workflow: workflow.metadata } : {}),
|
|
1265
1306
|
...(toolSource ? { toolSource } : {}),
|
|
@@ -1270,9 +1311,9 @@ async function runSlackMessageEvent(event, target, text, signal, opts, commitPre
|
|
|
1270
1311
|
: opts.preResolvedScope !== undefined ? { preResolvedScope: opts.preResolvedScope } : {}),
|
|
1271
1312
|
// The ACK anchor is the user's own message. Only this caller has the raw
|
|
1272
1313
|
// event, so the scope inputs are resolved here rather than re-derived.
|
|
1273
|
-
...(event.ts ? { ackTs: event.ts } : {}),
|
|
1314
|
+
...(event.ts && event.type !== 'block_actions' ? { ackTs: event.ts } : {}),
|
|
1274
1315
|
...(event.user ? { recipientUserId: event.user } : {}),
|
|
1275
|
-
preSendContext: { requester: event.user || 'unknown', jobKind: 'slack_turn' },
|
|
1316
|
+
preSendContext: { requester: event.user || 'unknown', jobKind: event.type === 'block_actions' ? SLACK_BLOCK_ACTION_JOB : 'slack_turn' },
|
|
1276
1317
|
isDirect: event.channel_type === 'im',
|
|
1277
1318
|
// A trusted bot trigger is addressed to this instance as surely as a
|
|
1278
1319
|
// human mention, and `isSlackMention` deliberately stays narrow.
|
|
@@ -1394,12 +1435,30 @@ function raceContextDeadline(work, ms) {
|
|
|
1394
1435
|
* never recorded as delivered.
|
|
1395
1436
|
*/
|
|
1396
1437
|
export async function preflightSlackEnvelope(envelope) {
|
|
1397
|
-
if (envelope.type !== 'events_api')
|
|
1438
|
+
if (envelope.type !== 'events_api' && envelope.type !== 'interactive')
|
|
1398
1439
|
return 'committed';
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1440
|
+
if (envelope.type === 'interactive') {
|
|
1441
|
+
const key = slackClickKey(envelope);
|
|
1442
|
+
const prior = slackClickDecisions.get(key);
|
|
1443
|
+
const mine = (async () => {
|
|
1444
|
+
if (prior)
|
|
1445
|
+
await prior.catch(() => undefined);
|
|
1446
|
+
return decideSlackClick(envelope);
|
|
1447
|
+
})();
|
|
1448
|
+
slackClickDecisions.set(key, mine);
|
|
1449
|
+
try {
|
|
1450
|
+
return await mine;
|
|
1451
|
+
}
|
|
1452
|
+
finally {
|
|
1453
|
+
if (slackClickDecisions.get(key) === mine)
|
|
1454
|
+
slackClickDecisions.delete(key);
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
const event = slackEnvelopeEvent(envelope);
|
|
1458
|
+
if (envelope.type === 'events_api') {
|
|
1459
|
+
// Before the channel/ts check: reaction events carry them under `item`.
|
|
1460
|
+
tapSlackEvent(event);
|
|
1461
|
+
}
|
|
1403
1462
|
if (!event?.channel || !event?.ts)
|
|
1404
1463
|
return 'committed';
|
|
1405
1464
|
// BEFORE the gate, and before the journal short-circuit, because this is the
|
|
@@ -1407,7 +1466,92 @@ export async function preflightSlackEnvelope(envelope) {
|
|
|
1407
1466
|
// — correctly, since the bot was not addressed — and conversations.history
|
|
1408
1467
|
// will never show it again if it lives inside a thread. Capturing here is
|
|
1409
1468
|
// what makes a thread reply answerable at all.
|
|
1410
|
-
|
|
1469
|
+
if (envelope.type === 'events_api')
|
|
1470
|
+
captureMentionWatchInbox(event);
|
|
1471
|
+
return admitSlackEnvelope(envelope, event);
|
|
1472
|
+
}
|
|
1473
|
+
async function decideSlackClick(envelope) {
|
|
1474
|
+
const generation = lifecycleGeneration;
|
|
1475
|
+
const token = getSlackSendClient().token;
|
|
1476
|
+
const self = { userId: selfUserId, botId: selfBotId, appId: selfAppId };
|
|
1477
|
+
const teamId = String(settings['slack']?.teamId || '');
|
|
1478
|
+
let event = slackBlockActionEvent(envelope.payload, teamId, self);
|
|
1479
|
+
if (!event?.channel || !event.ts) {
|
|
1480
|
+
const actions = envelope.payload?.['actions'];
|
|
1481
|
+
const action = Array.isArray(actions) && actions.length === 1 ? actions[0] : null;
|
|
1482
|
+
if (action && typeof action === 'object' && typeof action['action_id'] === 'string'
|
|
1483
|
+
&& action['action_id'].startsWith(SLACK_AGENT_ACTION_PREFIX))
|
|
1484
|
+
log.info('[slack:click] refused (not_admissible)');
|
|
1485
|
+
return 'committed';
|
|
1486
|
+
}
|
|
1487
|
+
const gate = shouldProcessSlackEvent(event, gateConfig(), 'interactive');
|
|
1488
|
+
if (!gate.process)
|
|
1489
|
+
return refuseSlackClick(gate.reason);
|
|
1490
|
+
if (!token || !event.user)
|
|
1491
|
+
return refuseSlackClick('clicker_unverified');
|
|
1492
|
+
const binding = { generation, token, selfUserId: self.userId, selfBotId: self.botId, selfAppId: self.appId, teamId };
|
|
1493
|
+
const key = slackClickKey(envelope);
|
|
1494
|
+
const cached = slackClickLookups.get(key);
|
|
1495
|
+
let clicker;
|
|
1496
|
+
let workspace;
|
|
1497
|
+
const reuse = cached && cached.expiresAt > Date.now() && cached.userId === event.user
|
|
1498
|
+
&& cached.binding.generation === generation && cached.binding.token === token
|
|
1499
|
+
&& cached.binding.selfUserId === self.userId && cached.binding.selfBotId === self.botId
|
|
1500
|
+
&& cached.binding.selfAppId === self.appId && cached.binding.teamId === teamId;
|
|
1501
|
+
if (reuse) {
|
|
1502
|
+
({ clicker, workspace } = cached);
|
|
1503
|
+
}
|
|
1504
|
+
else {
|
|
1505
|
+
const signal = AbortSignal.timeout(2000);
|
|
1506
|
+
[clicker, workspace] = await Promise.all([
|
|
1507
|
+
lookupSlackClicker(token, event.user, { signal }),
|
|
1508
|
+
verifiedSlackWorkspace(token, { signal }).catch(() => null),
|
|
1509
|
+
]);
|
|
1510
|
+
}
|
|
1511
|
+
if (generation !== lifecycleGeneration || token !== getSlackSendClient().token || self.userId !== selfUserId
|
|
1512
|
+
|| self.botId !== selfBotId || self.appId !== selfAppId)
|
|
1513
|
+
return refuseSlackClick('identity_changed');
|
|
1514
|
+
if (String(settings['slack']?.teamId || '') !== teamId)
|
|
1515
|
+
return refuseSlackClick('workspace_changed');
|
|
1516
|
+
const now = Date.now();
|
|
1517
|
+
for (const [held, row] of slackClickLookups)
|
|
1518
|
+
if (row.expiresAt <= now)
|
|
1519
|
+
slackClickLookups.delete(held);
|
|
1520
|
+
if (!slackClickLookups.has(key) && slackClickLookups.size >= 256) {
|
|
1521
|
+
const first = slackClickLookups.keys().next().value;
|
|
1522
|
+
if (first)
|
|
1523
|
+
slackClickLookups.delete(first);
|
|
1524
|
+
}
|
|
1525
|
+
slackClickLookups.set(key, { binding, userId: event.user, clicker, workspace,
|
|
1526
|
+
expiresAt: reuse ? cached.expiresAt : now + 10_000 });
|
|
1527
|
+
if (!workspace || workspace.teamId !== teamId || workspace.userId !== self.userId)
|
|
1528
|
+
return refuseSlackClick('workspace_unverified');
|
|
1529
|
+
if (!clicker.ok)
|
|
1530
|
+
return refuseSlackClick('clicker_unverified');
|
|
1531
|
+
if (clicker.isBot || event.bot_id || event.bot_profile) {
|
|
1532
|
+
const botId = event.bot_id || clicker.botId;
|
|
1533
|
+
event = { ...event, ...(botId ? { bot_id: botId } : {}),
|
|
1534
|
+
bot_profile: { user_id: event.user, ...(botId ? { id: botId } : {}) } };
|
|
1535
|
+
}
|
|
1536
|
+
const final = shouldProcessSlackEvent(event, gateConfig(), 'interactive');
|
|
1537
|
+
if (!final.process)
|
|
1538
|
+
return refuseSlackClick(final.reason);
|
|
1539
|
+
const result = admitSlackEnvelope(envelope, event);
|
|
1540
|
+
if (result === 'committed')
|
|
1541
|
+
stashVerifiedSlackClick(envelope, event, binding);
|
|
1542
|
+
return result;
|
|
1543
|
+
}
|
|
1544
|
+
/**
|
|
1545
|
+
* A refused click is ACKed and dropped with no journal row, so this line is the
|
|
1546
|
+
* only trace an operator gets of why a button did nothing.
|
|
1547
|
+
*/
|
|
1548
|
+
function refuseSlackClick(reason) {
|
|
1549
|
+
log.info(`[slack:click] refused (${reason})`);
|
|
1550
|
+
return 'ignored';
|
|
1551
|
+
}
|
|
1552
|
+
function admitSlackEnvelope(envelope, event) {
|
|
1553
|
+
if (!event.channel || !event.ts)
|
|
1554
|
+
return 'committed';
|
|
1411
1555
|
const journal = getIngressJournal();
|
|
1412
1556
|
if (!journal)
|
|
1413
1557
|
return 'committed';
|
|
@@ -1447,10 +1591,52 @@ export async function preflightSlackEnvelope(envelope) {
|
|
|
1447
1591
|
}
|
|
1448
1592
|
const SLACK_ADMISSION_TTL_MS = 10 * 60 * 1000;
|
|
1449
1593
|
const slackAdmissions = new Map();
|
|
1594
|
+
const slackClickDecisions = new Map();
|
|
1595
|
+
const slackClickLookups = new Map();
|
|
1596
|
+
const verifiedSlackClicks = new Map();
|
|
1597
|
+
function slackClickKey(envelope) {
|
|
1598
|
+
const payload = envelope.payload;
|
|
1599
|
+
const team = payload?.['team']?.id;
|
|
1600
|
+
const container = payload?.['container'];
|
|
1601
|
+
const actions = payload?.['actions'];
|
|
1602
|
+
const action = Array.isArray(actions) ? actions[0] : undefined;
|
|
1603
|
+
return JSON.stringify([team, container?.channel_id, action?.action_ts]);
|
|
1604
|
+
}
|
|
1605
|
+
function stashVerifiedSlackClick(envelope, event, binding) {
|
|
1606
|
+
const key = slackAdmissionKey(envelope);
|
|
1607
|
+
if (!key)
|
|
1608
|
+
return;
|
|
1609
|
+
const now = Date.now();
|
|
1610
|
+
for (const [held, row] of verifiedSlackClicks)
|
|
1611
|
+
if (row.expiresAt <= now)
|
|
1612
|
+
verifiedSlackClicks.delete(held);
|
|
1613
|
+
if (verifiedSlackClicks.size >= 256) {
|
|
1614
|
+
const first = verifiedSlackClicks.keys().next().value;
|
|
1615
|
+
if (first)
|
|
1616
|
+
verifiedSlackClicks.delete(first);
|
|
1617
|
+
}
|
|
1618
|
+
verifiedSlackClicks.set(key, { event, binding, expiresAt: now + SLACK_ADMISSION_TTL_MS });
|
|
1619
|
+
}
|
|
1620
|
+
function takeVerifiedSlackClick(envelope) {
|
|
1621
|
+
const key = slackAdmissionKey(envelope);
|
|
1622
|
+
const row = verifiedSlackClicks.get(key);
|
|
1623
|
+
verifiedSlackClicks.delete(key);
|
|
1624
|
+
return row && row.expiresAt > Date.now() && row.binding.generation === lifecycleGeneration ? row : undefined;
|
|
1625
|
+
}
|
|
1626
|
+
function slackEnvelopeEvent(envelope) {
|
|
1627
|
+
return envelope.payload?.event;
|
|
1628
|
+
}
|
|
1629
|
+
function slackEnvelopeTeamId(envelope) {
|
|
1630
|
+
const payload = envelope.payload;
|
|
1631
|
+
const team = envelope.type === 'interactive' ? payload?.['team']?.id : payload?.['team_id'];
|
|
1632
|
+
return typeof team === 'string' && team ? team : undefined;
|
|
1633
|
+
}
|
|
1450
1634
|
function slackAdmissionKey(envelope) {
|
|
1451
1635
|
if (envelope.envelope_id)
|
|
1452
1636
|
return `eid:${envelope.envelope_id}`;
|
|
1453
|
-
|
|
1637
|
+
if (envelope.type === 'interactive')
|
|
1638
|
+
return `click:${slackClickKey(envelope)}`;
|
|
1639
|
+
const event = slackEnvelopeEvent(envelope);
|
|
1454
1640
|
const team = String(settings['slack']?.teamId || '');
|
|
1455
1641
|
if (event?.channel && event?.ts && team)
|
|
1456
1642
|
return `ev:${team}:${event.channel}:${event.ts}`;
|
|
@@ -1480,7 +1666,16 @@ function takeSlackAdmission(envelope) {
|
|
|
1480
1666
|
slackAdmissions.delete(key);
|
|
1481
1667
|
if (row && row.expiresAt > Date.now())
|
|
1482
1668
|
return row.admission;
|
|
1483
|
-
|
|
1669
|
+
if (envelope.type === 'interactive' && !verifiedSlackClicks.has(key))
|
|
1670
|
+
return undefined;
|
|
1671
|
+
const payload = envelope.payload;
|
|
1672
|
+
const container = payload?.['container'];
|
|
1673
|
+
const actions = payload?.['actions'];
|
|
1674
|
+
const action = Array.isArray(actions) ? actions[0] : undefined;
|
|
1675
|
+
const event = envelope.type === 'interactive'
|
|
1676
|
+
? { channel: typeof container?.channel_id === 'string' ? container.channel_id : undefined,
|
|
1677
|
+
ts: typeof action?.action_ts === 'string' ? action.action_ts : undefined }
|
|
1678
|
+
: slackEnvelopeEvent(envelope);
|
|
1484
1679
|
const team = String(settings['slack']?.teamId || '');
|
|
1485
1680
|
if (!event?.channel || !event.ts || !team)
|
|
1486
1681
|
return undefined;
|
|
@@ -1538,7 +1733,10 @@ export async function handleSlackEnvelope(envelope, approvalTransport = slackApp
|
|
|
1538
1733
|
await handleSlackSlashCommand(envelope.payload || {});
|
|
1539
1734
|
return;
|
|
1540
1735
|
}
|
|
1541
|
-
|
|
1736
|
+
const verifiedClick = envelope.type === 'interactive' ? takeVerifiedSlackClick(envelope) : undefined;
|
|
1737
|
+
const event = envelope.type === 'interactive' ? verifiedClick?.event : slackEnvelopeEvent(envelope);
|
|
1738
|
+
const socketTeamId = slackEnvelopeTeamId(envelope);
|
|
1739
|
+
if (envelope.type === 'interactive' && !event) {
|
|
1542
1740
|
const payload = envelope.payload || {};
|
|
1543
1741
|
const actions = payload['actions'];
|
|
1544
1742
|
const actionId = Array.isArray(actions) && actions[0] && typeof actions[0] === 'object'
|
|
@@ -1552,6 +1750,7 @@ export async function handleSlackEnvelope(envelope, approvalTransport = slackApp
|
|
|
1552
1750
|
await consumeSlackInteractionCallback(payload, token);
|
|
1553
1751
|
}
|
|
1554
1752
|
log.info('[slack:interactive] received (not an approval action)');
|
|
1753
|
+
settleOk();
|
|
1555
1754
|
return;
|
|
1556
1755
|
}
|
|
1557
1756
|
const result = handleApprovalCallback(approvalTransport, payload, parsed.opaqueId, parsed.action, {
|
|
@@ -1566,17 +1765,16 @@ export async function handleSlackEnvelope(envelope, approvalTransport = slackApp
|
|
|
1566
1765
|
if (token && channel) {
|
|
1567
1766
|
await sendSlackText(token, slackTargetFromId(channel), redactOutboundText(reply)).catch(() => undefined);
|
|
1568
1767
|
}
|
|
1768
|
+
settleOk();
|
|
1569
1769
|
return;
|
|
1570
1770
|
}
|
|
1571
|
-
const payload = envelope.payload;
|
|
1572
|
-
const event = payload?.event;
|
|
1573
1771
|
if (!event) {
|
|
1574
1772
|
settleOk();
|
|
1575
1773
|
return;
|
|
1576
1774
|
}
|
|
1577
1775
|
const receiveGate = gateConfig();
|
|
1578
1776
|
const workflowSelection = captureSlackWorkflow(event, receiveGate);
|
|
1579
|
-
const approval = workflowSelection.kind === 'none' ? handleApprovalCommand(approvalTransport, {
|
|
1777
|
+
const approval = event.type !== 'block_actions' && workflowSelection.kind === 'none' ? handleApprovalCommand(approvalTransport, {
|
|
1580
1778
|
...event,
|
|
1581
1779
|
__jawSelf: Boolean(event.user && event.user === getSlackSelfUserId()),
|
|
1582
1780
|
}, String(event.text || '')) : { handled: false };
|
|
@@ -1687,7 +1885,8 @@ export async function handleSlackEnvelope(envelope, approvalTransport = slackApp
|
|
|
1687
1885
|
try {
|
|
1688
1886
|
await processSlackMessageEvent(event, target, text, signal, {
|
|
1689
1887
|
workflowSelection,
|
|
1690
|
-
...(
|
|
1888
|
+
...(verifiedClick ? { clickBinding: verifiedClick.binding } : {}),
|
|
1889
|
+
...(socketTeamId ? { socketTeamId } : {}),
|
|
1691
1890
|
prefetchToken,
|
|
1692
1891
|
...(prefetchOwner ? { prefetchOwner } : {}),
|
|
1693
1892
|
preResolvedScope,
|
|
@@ -1805,8 +2004,18 @@ async function runSlackInit(ctx) {
|
|
|
1805
2004
|
log.error('[slack] auth.test failed:', auth.error);
|
|
1806
2005
|
return transportNotStarted('failed', 'auth_test_failed');
|
|
1807
2006
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
2007
|
+
const userId = auth.data?.user_id || null;
|
|
2008
|
+
const botId = auth.data?.bot_id || null;
|
|
2009
|
+
const appId = botId && userId ? await lookupSlackBotApp(sc.botToken, botId, userId) : null;
|
|
2010
|
+
if (generation !== lifecycleGeneration) {
|
|
2011
|
+
log.info('[slack] init superseded during bot lookup — aborting');
|
|
2012
|
+
return transportNotStarted('superseded');
|
|
2013
|
+
}
|
|
2014
|
+
selfUserId = userId;
|
|
2015
|
+
selfBotId = botId;
|
|
2016
|
+
selfAppId = appId;
|
|
2017
|
+
if (!appId)
|
|
2018
|
+
log.warn('[slack] bot app id unverified (bots.info) — app-stamped block actions are refused until transport restart');
|
|
1810
2019
|
// The grant is whatever the app was installed with, not whatever the
|
|
1811
2020
|
// current manifest asks for. Record it here — auth.test already ran, so
|
|
1812
2021
|
// this costs nothing — and say the whole gap once instead of leaking one
|
|
@@ -2125,5 +2334,9 @@ async function disposeSlackRuntime() {
|
|
|
2125
2334
|
clearSlackClaimRecheck();
|
|
2126
2335
|
selfUserId = null;
|
|
2127
2336
|
selfBotId = null;
|
|
2337
|
+
selfAppId = null;
|
|
2338
|
+
verifiedSlackClicks.clear();
|
|
2339
|
+
slackClickDecisions.clear();
|
|
2340
|
+
slackClickLookups.clear();
|
|
2128
2341
|
}
|
|
2129
2342
|
//# sourceMappingURL=bot.js.map
|