@open-everywhere/provider-slack 0.6.0 → 0.8.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/agent/access/slack-attachment-fetch.ts +2 -1
- package/agent/app-manifest.ts +15 -1
- package/agent/channels/slack-agent-session.ts +249 -0
- package/agent/channels/slack-attachments.ts +20 -11
- package/agent/channels/slack-bot-ask.ts +101 -0
- package/agent/channels/slack-commands.ts +178 -17
- package/agent/channels/slack-context.ts +0 -5
- package/agent/channels/slack-events.ts +110 -33
- package/agent/channels/slack-follow-ups.ts +148 -0
- package/agent/channels/slack-friendly-names.ts +55 -0
- package/agent/channels/slack-front.ts +262 -27
- package/agent/channels/slack-home.ts +9 -3
- package/agent/channels/slack-identity.ts +9 -1
- package/agent/channels/slack-memory-canvas.ts +197 -54
- package/agent/channels/slack-origin-codec.ts +9 -0
- package/agent/channels/slack-post-arm.ts +68 -11
- package/agent/channels/slack-read.ts +27 -2
- package/agent/channels/slack-reply-blocks.ts +180 -0
- package/agent/channels/slack-reply-feedback.ts +75 -0
- package/agent/channels/slack-shortcut.ts +1 -1
- package/agent/channels/slack-voice-clips.ts +82 -0
- package/agent/channels/slack-wake-backscroll.ts +0 -5
- package/agent/channels/slack-web-api.ts +4 -2
- package/agent/channels/slack.ts +81 -19
- package/agent/docs-generated.ts +1282 -2
- package/agent/ops.ts +14 -21
- package/agent/register.ts +25 -0
- package/agent/setup/credentials.ts +17 -0
- package/agent/setup/page.ts +6 -3
- package/agent/surface-parity.ts +2 -0
- package/dist/agent/access/slack-attachment-fetch.d.ts.map +1 -1
- package/dist/agent/access/slack-attachment-fetch.js.map +1 -1
- package/dist/agent/app-manifest.d.ts.map +1 -1
- package/dist/agent/app-manifest.js +15 -1
- package/dist/agent/app-manifest.js.map +1 -1
- package/dist/agent/channels/slack-agent-session.d.ts +81 -0
- package/dist/agent/channels/slack-agent-session.d.ts.map +1 -0
- package/dist/agent/channels/slack-agent-session.js +198 -0
- package/dist/agent/channels/slack-agent-session.js.map +1 -0
- package/dist/agent/channels/slack-attachments.d.ts +11 -0
- package/dist/agent/channels/slack-attachments.d.ts.map +1 -1
- package/dist/agent/channels/slack-attachments.js +21 -14
- package/dist/agent/channels/slack-attachments.js.map +1 -1
- package/dist/agent/channels/slack-bot-ask.d.ts +30 -0
- package/dist/agent/channels/slack-bot-ask.d.ts.map +1 -0
- package/dist/agent/channels/slack-bot-ask.js +91 -0
- package/dist/agent/channels/slack-bot-ask.js.map +1 -0
- package/dist/agent/channels/slack-commands.d.ts +113 -10
- package/dist/agent/channels/slack-commands.d.ts.map +1 -1
- package/dist/agent/channels/slack-commands.js +151 -18
- package/dist/agent/channels/slack-commands.js.map +1 -1
- package/dist/agent/channels/slack-context.d.ts +1 -2
- package/dist/agent/channels/slack-context.d.ts.map +1 -1
- package/dist/agent/channels/slack-context.js +0 -4
- package/dist/agent/channels/slack-context.js.map +1 -1
- package/dist/agent/channels/slack-events.d.ts +47 -97
- package/dist/agent/channels/slack-events.d.ts.map +1 -1
- package/dist/agent/channels/slack-events.js +90 -22
- package/dist/agent/channels/slack-events.js.map +1 -1
- package/dist/agent/channels/slack-follow-ups.d.ts +44 -0
- package/dist/agent/channels/slack-follow-ups.d.ts.map +1 -0
- package/dist/agent/channels/slack-follow-ups.js +129 -0
- package/dist/agent/channels/slack-follow-ups.js.map +1 -0
- package/dist/agent/channels/slack-friendly-names.d.ts +10 -0
- package/dist/agent/channels/slack-friendly-names.d.ts.map +1 -0
- package/dist/agent/channels/slack-friendly-names.js +45 -0
- package/dist/agent/channels/slack-friendly-names.js.map +1 -0
- package/dist/agent/channels/slack-front.d.ts +38 -46
- package/dist/agent/channels/slack-front.d.ts.map +1 -1
- package/dist/agent/channels/slack-front.js +230 -23
- package/dist/agent/channels/slack-front.js.map +1 -1
- package/dist/agent/channels/slack-home.d.ts.map +1 -1
- package/dist/agent/channels/slack-home.js +10 -3
- package/dist/agent/channels/slack-home.js.map +1 -1
- package/dist/agent/channels/slack-identity.d.ts +7 -21
- package/dist/agent/channels/slack-identity.d.ts.map +1 -1
- package/dist/agent/channels/slack-identity.js +3 -1
- package/dist/agent/channels/slack-identity.js.map +1 -1
- package/dist/agent/channels/slack-memory-canvas.d.ts +21 -5
- package/dist/agent/channels/slack-memory-canvas.d.ts.map +1 -1
- package/dist/agent/channels/slack-memory-canvas.js +166 -55
- package/dist/agent/channels/slack-memory-canvas.js.map +1 -1
- package/dist/agent/channels/slack-origin-codec.d.ts.map +1 -1
- package/dist/agent/channels/slack-origin-codec.js +10 -0
- package/dist/agent/channels/slack-origin-codec.js.map +1 -1
- package/dist/agent/channels/slack-post-arm.d.ts +21 -1
- package/dist/agent/channels/slack-post-arm.d.ts.map +1 -1
- package/dist/agent/channels/slack-post-arm.js +57 -10
- package/dist/agent/channels/slack-post-arm.js.map +1 -1
- package/dist/agent/channels/slack-read.d.ts +11 -1
- package/dist/agent/channels/slack-read.d.ts.map +1 -1
- package/dist/agent/channels/slack-read.js +27 -3
- package/dist/agent/channels/slack-read.js.map +1 -1
- package/dist/agent/channels/slack-reply-blocks.d.ts +29 -0
- package/dist/agent/channels/slack-reply-blocks.d.ts.map +1 -0
- package/dist/agent/channels/slack-reply-blocks.js +172 -0
- package/dist/agent/channels/slack-reply-blocks.js.map +1 -0
- package/dist/agent/channels/slack-reply-feedback.d.ts +23 -0
- package/dist/agent/channels/slack-reply-feedback.d.ts.map +1 -0
- package/dist/agent/channels/slack-reply-feedback.js +63 -0
- package/dist/agent/channels/slack-reply-feedback.js.map +1 -0
- package/dist/agent/channels/slack-shortcut.d.ts +10 -0
- package/dist/agent/channels/slack-shortcut.d.ts.map +1 -1
- package/dist/agent/channels/slack-shortcut.js +1 -1
- package/dist/agent/channels/slack-shortcut.js.map +1 -1
- package/dist/agent/channels/slack-voice-clips.d.ts +16 -0
- package/dist/agent/channels/slack-voice-clips.d.ts.map +1 -0
- package/dist/agent/channels/slack-voice-clips.js +80 -0
- package/dist/agent/channels/slack-voice-clips.js.map +1 -0
- package/dist/agent/channels/slack-wake-backscroll.d.ts +0 -2
- package/dist/agent/channels/slack-wake-backscroll.d.ts.map +1 -1
- package/dist/agent/channels/slack-wake-backscroll.js +0 -4
- package/dist/agent/channels/slack-wake-backscroll.js.map +1 -1
- package/dist/agent/channels/slack-web-api.d.ts.map +1 -1
- package/dist/agent/channels/slack-web-api.js +4 -2
- package/dist/agent/channels/slack-web-api.js.map +1 -1
- package/dist/agent/channels/slack.d.ts +22 -1
- package/dist/agent/channels/slack.d.ts.map +1 -1
- package/dist/agent/channels/slack.js +70 -16
- package/dist/agent/channels/slack.js.map +1 -1
- package/dist/agent/docs-generated.d.ts.map +1 -1
- package/dist/agent/docs-generated.js +1282 -2
- package/dist/agent/docs-generated.js.map +1 -1
- package/dist/agent/ops.d.ts +1 -1
- package/dist/agent/ops.d.ts.map +1 -1
- package/dist/agent/ops.js +15 -21
- package/dist/agent/ops.js.map +1 -1
- package/dist/agent/register.d.ts.map +1 -1
- package/dist/agent/register.js +22 -1
- package/dist/agent/register.js.map +1 -1
- package/dist/agent/setup/credentials.d.ts +12 -0
- package/dist/agent/setup/credentials.d.ts.map +1 -1
- package/dist/agent/setup/credentials.js +17 -0
- package/dist/agent/setup/credentials.js.map +1 -1
- package/dist/agent/setup/page.d.ts.map +1 -1
- package/dist/agent/setup/page.js +6 -3
- package/dist/agent/setup/page.js.map +1 -1
- package/dist/agent/surface-parity.d.ts.map +1 -1
- package/dist/agent/surface-parity.js +2 -0
- package/dist/agent/surface-parity.js.map +1 -1
- package/package.json +40 -3
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type BindableContext } from "@open-everywhere/core/agent/adapter-api.js";
|
|
1
2
|
/** A resolved attachment record — its `urlPrivate` came from a Slack event's `files[].url_private`
|
|
2
3
|
* (trusted provenance), never a model-supplied string. */
|
|
3
4
|
export interface SlackAttachmentRecord {
|
|
@@ -48,6 +49,16 @@ export declare function persistSlackAttachment(fileId: string | undefined, rec:
|
|
|
48
49
|
* defaults to the deployment org (single-tenant) when omitted.
|
|
49
50
|
*/
|
|
50
51
|
export declare function resolveSlackAttachmentDurable(fileId: string, org?: string): Promise<SlackAttachmentRecord | undefined>;
|
|
52
|
+
/**
|
|
53
|
+
* The size-guarded byte pull over a TRUSTED `url_private`: the bot-token, host-pinned fetch, then the Content-Length
|
|
54
|
+
* pre-check (rejects with {@link AttachmentOversizeError} phase "declared" BEFORE the body is read), then the post-read
|
|
55
|
+
* cap (phase "actual"). Two callers: the guarded resolver below, and the voice-clip loader (slack-voice-clips.ts),
|
|
56
|
+
* which reads a clip off the event that woke the agent. Both pass an event-supplied URL, never a model string.
|
|
57
|
+
*/
|
|
58
|
+
export declare function pullSlackAttachmentBytes(ctx: BindableContext, ref: {
|
|
59
|
+
readonly urlPrivate: string;
|
|
60
|
+
readonly id?: string;
|
|
61
|
+
}, maxBytes: number): Promise<Uint8Array>;
|
|
51
62
|
/**
|
|
52
63
|
* Register Slack as an attachment-plane resolver (channels/attachments.ts) — the neutral seam
|
|
53
64
|
* describe_image consults so its contract carries no per-platform union arm. The resolver wraps the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack-attachments.d.ts","sourceRoot":"","sources":["../../../agent/channels/slack-attachments.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"slack-attachments.d.ts","sourceRoot":"","sources":["../../../agent/channels/slack-attachments.ts"],"names":[],"mappings":"AA4BA,OAAO,EAOL,KAAK,eAAe,EACrB,MAAM,4CAA4C,CAAC;AAGpD;2DAC2D;AAC3D,MAAM,WAAW,qBAAqB;IACpC,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;gFAC4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;wEACoE;IACpE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,oFAAoF;IACpF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;2GACuG;IACvG,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAUD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,qBAAqB,GAAG,IAAI,CASpG;AAED;;oFAEoF;AACpF,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS,CAExF;AAED;;;;;;GAMG;AACH,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAahI;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAY5H;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE;IAAE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAUtK;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,IAAI,IAAI,CA0BtD;AAMD,2EAA2E;AAC3E,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
|
|
@@ -109,6 +109,26 @@ export async function resolveSlackAttachmentDurable(fileId, org) {
|
|
|
109
109
|
return undefined;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* The size-guarded byte pull over a TRUSTED `url_private`: the bot-token, host-pinned fetch, then the Content-Length
|
|
114
|
+
* pre-check (rejects with {@link AttachmentOversizeError} phase "declared" BEFORE the body is read), then the post-read
|
|
115
|
+
* cap (phase "actual"). Two callers: the guarded resolver below, and the voice-clip loader (slack-voice-clips.ts),
|
|
116
|
+
* which reads a clip off the event that woke the agent. Both pass an event-supplied URL, never a model string.
|
|
117
|
+
*/
|
|
118
|
+
export async function pullSlackAttachmentBytes(ctx, ref, maxBytes) {
|
|
119
|
+
const res = await fetchSlackAttachment(ctx, ref);
|
|
120
|
+
if (!res.ok)
|
|
121
|
+
throw new Error(`fetching the upload failed (HTTP ${res.status})`);
|
|
122
|
+
// Content-Length pre-check off the declared length — reject before reading the body.
|
|
123
|
+
const declared = Number.parseInt(res.headers.get("content-length") ?? "", 10);
|
|
124
|
+
if (Number.isFinite(declared) && declared > maxBytes)
|
|
125
|
+
throw new AttachmentOversizeError(declared, "declared", maxBytes);
|
|
126
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
127
|
+
// Post-read cap — a chunked response can exceed the (possibly-absent) Content-Length.
|
|
128
|
+
if (bytes.byteLength > maxBytes)
|
|
129
|
+
throw new AttachmentOversizeError(bytes.byteLength, "actual", maxBytes);
|
|
130
|
+
return bytes;
|
|
131
|
+
}
|
|
112
132
|
/**
|
|
113
133
|
* Register Slack as an attachment-plane resolver (channels/attachments.ts) — the neutral seam
|
|
114
134
|
* describe_image consults so its contract carries no per-platform union arm. The resolver wraps the
|
|
@@ -146,20 +166,7 @@ export function registerSlackAttachmentResolver() {
|
|
|
146
166
|
ref: `slack-file:${attachmentId}`,
|
|
147
167
|
mimeType: rec.mimeType,
|
|
148
168
|
name: rec.name,
|
|
149
|
-
|
|
150
|
-
const res = await fetchSlackAttachment(ctx, { urlPrivate: rec.urlPrivate, id: attachmentId });
|
|
151
|
-
if (!res.ok)
|
|
152
|
-
throw new Error(`fetching the upload failed (HTTP ${res.status})`);
|
|
153
|
-
// Content-Length pre-check off the declared length — reject before reading the body.
|
|
154
|
-
const declared = Number.parseInt(res.headers.get("content-length") ?? "", 10);
|
|
155
|
-
if (Number.isFinite(declared) && declared > maxBytes)
|
|
156
|
-
throw new AttachmentOversizeError(declared, "declared", maxBytes);
|
|
157
|
-
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
158
|
-
// Post-read cap — a chunked response can exceed the (possibly-absent) Content-Length.
|
|
159
|
-
if (bytes.byteLength > maxBytes)
|
|
160
|
-
throw new AttachmentOversizeError(bytes.byteLength, "actual", maxBytes);
|
|
161
|
-
return bytes;
|
|
162
|
-
},
|
|
169
|
+
pull: ({ maxBytes }) => pullSlackAttachmentBytes(ctx, { urlPrivate: rec.urlPrivate, id: attachmentId }, maxBytes),
|
|
163
170
|
};
|
|
164
171
|
},
|
|
165
172
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack-attachments.js","sourceRoot":"","sources":["../../../agent/channels/slack-attachments.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,uDAAuD;AACvD,EAAE;AACF,+FAA+F;AAC/F,gGAAgG;AAChG,iGAAiG;AACjG,iGAAiG;AACjG,gGAAgG;AAChG,iGAAiG;AACjG,kGAAkG;AAClG,mGAAmG;AACnG,gGAAgG;AAChG,EAAE;AACF,kGAAkG;AAClG,gGAAgG;AAChG,+FAA+F;AAC/F,sFAAsF;AACtF,EAAE;AACF,gGAAgG;AAChG,qGAAqG;AACrG,iGAAiG;AACjG,iGAAiG;AACjG,kGAAkG;AAClG,qGAAqG;AACrG,gGAAgG;AAChG,mGAAmG;AACnG,4FAA4F;AAE5F,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,0BAA0B,EAC1B,uBAAuB,
|
|
1
|
+
{"version":3,"file":"slack-attachments.js","sourceRoot":"","sources":["../../../agent/channels/slack-attachments.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,uDAAuD;AACvD,EAAE;AACF,+FAA+F;AAC/F,gGAAgG;AAChG,iGAAiG;AACjG,iGAAiG;AACjG,gGAAgG;AAChG,iGAAiG;AACjG,kGAAkG;AAClG,mGAAmG;AACnG,gGAAgG;AAChG,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C,IAAI;gBACd,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,wBAAwB,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,CAAC,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,QAAQ,CAAC;aAClH,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,mGAAmG;AACnG,mGAAmG;AACnG,iGAAiG;AAEjG,2EAA2E;AAC3E,MAAM,UAAU,6BAA6B;IAC3C,QAAQ,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { BotAskProbe, BotReplyFacts } from "@open-everywhere/core/agent/adapter-api.js";
|
|
2
|
+
import type { ParsedMessageEvent } from "./slack-events.js";
|
|
3
|
+
/** The Slack calls the probe makes (injectable for the unit test). */
|
|
4
|
+
export interface SlackBotAskDeps {
|
|
5
|
+
/** One Web API call with the bot token; resolves the parsed body, or undefined on a transport failure. */
|
|
6
|
+
readonly call: (method: string, body: Record<string, string>) => Promise<Record<string, unknown> | undefined>;
|
|
7
|
+
/** This app's own bot user id and bot id (`auth.test`), best-effort. */
|
|
8
|
+
readonly self: () => Promise<{
|
|
9
|
+
readonly userId?: string;
|
|
10
|
+
readonly botId?: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/** Does the text @mention this user id (`<@U123>` or `<@U123|name>`)? PURE. */
|
|
14
|
+
export declare function mentionsUser(text: string, userId: string): boolean;
|
|
15
|
+
/** Build Slack's probe. */
|
|
16
|
+
export declare function slackBotAskProbe(deps: SlackBotAskDeps): BotAskProbe;
|
|
17
|
+
/** The live deps: `slackForm` with the bot token, and the front route's cached `auth.test`. */
|
|
18
|
+
export declare function liveSlackBotAskDeps(form: (method: string, body: string) => Promise<Record<string, unknown> | undefined>, self: () => Promise<{
|
|
19
|
+
readonly userId?: string;
|
|
20
|
+
readonly botId?: string;
|
|
21
|
+
}>): SlackBotAskDeps;
|
|
22
|
+
/** Is this parsed message a candidate for the asked-thread exception at all? A cheap, pure pre-filter, so a
|
|
23
|
+
* human message never pays a store read. PURE. */
|
|
24
|
+
export declare function botReplyCandidate(ev: ParsedMessageEvent): boolean;
|
|
25
|
+
/** Core's facts for one parsed Slack message. PURE. */
|
|
26
|
+
export declare function slackBotReplyFacts(ev: ParsedMessageEvent, org: string, self: {
|
|
27
|
+
readonly userId?: string;
|
|
28
|
+
readonly botId?: string;
|
|
29
|
+
}): BotReplyFacts;
|
|
30
|
+
//# sourceMappingURL=slack-bot-ask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-bot-ask.d.ts","sourceRoot":"","sources":["../../../agent/channels/slack-bot-ask.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAqB,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B,0GAA0G;IAC1G,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC;IAC9G,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC;QAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACrF;AAID,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAElE;AAED,2BAA2B;AAC3B,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,WAAW,CAoCnE;AAED,+FAA+F;AAC/F,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EACpF,IAAI,EAAE,MAAM,OAAO,CAAC;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACzE,eAAe,CAEjB;AAED;mDACmD;AACnD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAEjE;AAED,uDAAuD;AACvD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,kBAAkB,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAclJ"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// SLACK'S ARM OF CHIEF-OF-STAFF DELEGATION (OPE-2426) — the probe that proves an ask to another bot, and
|
|
2
|
+
// the facts the front route hands core for an inbound bot message. Core holds the policy
|
|
3
|
+
// (core/agent/channels/bot-ask.ts); this file only reads Slack.
|
|
4
|
+
//
|
|
5
|
+
// THE PROBE reads three facts with the BOT token, never a model string:
|
|
6
|
+
// 1. the ask message itself (`conversations.replies` on its ts). The bot token reads it only when this
|
|
7
|
+
// app is in the channel, and the app must be in the channel to receive the other bot's reply at all.
|
|
8
|
+
// So an unreadable message is a refusal that says "invite the agent";
|
|
9
|
+
// 2. its author is the person who asks, and its own text @mentions the named bot;
|
|
10
|
+
// 3. the named account is a bot (`users.info` `is_bot`), and not this app itself (`auth.test`). An
|
|
11
|
+
// unknown own identity refuses: it cannot prove "not this app".
|
|
12
|
+
// Any failed call refuses (`unreadable`). The probe never throws.
|
|
13
|
+
import { encodeSlackForm } from "./slack-web-api.js";
|
|
14
|
+
/** Does the text @mention this user id (`<@U123>` or `<@U123|name>`)? PURE. */
|
|
15
|
+
export function mentionsUser(text, userId) {
|
|
16
|
+
return text.includes(`<@${userId}>`) || text.includes(`<@${userId}|`);
|
|
17
|
+
}
|
|
18
|
+
/** Build Slack's probe. */
|
|
19
|
+
export function slackBotAskProbe(deps) {
|
|
20
|
+
return async (q) => {
|
|
21
|
+
try {
|
|
22
|
+
const [platform, teamId] = q.workspaceKey.split("/");
|
|
23
|
+
if (platform !== "slack" || !teamId)
|
|
24
|
+
return { ok: false, reason: "unreadable" };
|
|
25
|
+
const replies = await deps.call("conversations.replies", { channel: q.channel, ts: q.messageTs, limit: "1", inclusive: "true" });
|
|
26
|
+
const messages = replies?.ok === true && Array.isArray(replies.messages) ? replies.messages : [];
|
|
27
|
+
const msg = messages.find((m) => m.ts === q.messageTs);
|
|
28
|
+
if (!msg)
|
|
29
|
+
return { ok: false, reason: "unreadable" };
|
|
30
|
+
if (msg.user !== q.personId)
|
|
31
|
+
return { ok: false, reason: "not-yours" };
|
|
32
|
+
const text = typeof msg.text === "string" ? msg.text : "";
|
|
33
|
+
if (!mentionsUser(text, q.bot))
|
|
34
|
+
return { ok: false, reason: "bot-not-named" };
|
|
35
|
+
const self = await deps.self().catch(() => ({}));
|
|
36
|
+
// FAIL-CLOSED: without this app's own user id, a mention of this app cannot be told from another bot's.
|
|
37
|
+
if (self.userId === undefined)
|
|
38
|
+
return { ok: false, reason: "unreadable" };
|
|
39
|
+
if (self.userId === q.bot)
|
|
40
|
+
return { ok: false, reason: "self" };
|
|
41
|
+
const info = await deps.call("users.info", { user: q.bot });
|
|
42
|
+
const user = info?.ok === true && info.user && typeof info.user === "object" ? info.user : undefined;
|
|
43
|
+
if (!user)
|
|
44
|
+
return { ok: false, reason: "unreadable" };
|
|
45
|
+
if (user.is_bot !== true)
|
|
46
|
+
return { ok: false, reason: "not-a-bot" };
|
|
47
|
+
const profile = user.profile && typeof user.profile === "object" ? user.profile : {};
|
|
48
|
+
const botId = typeof profile.bot_id === "string" && profile.bot_id.length > 0 ? profile.bot_id : undefined;
|
|
49
|
+
if (botId !== undefined && self.botId !== undefined && botId === self.botId)
|
|
50
|
+
return { ok: false, reason: "self" };
|
|
51
|
+
const label = [user.real_name, profile.display_name, user.name].find((v) => typeof v === "string" && v.trim().length > 0);
|
|
52
|
+
return {
|
|
53
|
+
ok: true,
|
|
54
|
+
threadTs: typeof msg.thread_ts === "string" && msg.thread_ts.length > 0 ? msg.thread_ts : q.messageTs,
|
|
55
|
+
botUserId: q.bot,
|
|
56
|
+
...(botId === undefined ? {} : { botId }),
|
|
57
|
+
...(label === undefined ? {} : { botLabel: label }),
|
|
58
|
+
askText: text,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return { ok: false, reason: "unreadable" };
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** The live deps: `slackForm` with the bot token, and the front route's cached `auth.test`. */
|
|
67
|
+
export function liveSlackBotAskDeps(form, self) {
|
|
68
|
+
return { call: (method, body) => form(method, encodeSlackForm(body)), self };
|
|
69
|
+
}
|
|
70
|
+
/** Is this parsed message a candidate for the asked-thread exception at all? A cheap, pure pre-filter, so a
|
|
71
|
+
* human message never pays a store read. PURE. */
|
|
72
|
+
export function botReplyCandidate(ev) {
|
|
73
|
+
return (Boolean(ev.botId) || ev.subtype === "bot_message") && ev.threadTs !== undefined && ev.threadTs !== ev.ts;
|
|
74
|
+
}
|
|
75
|
+
/** Core's facts for one parsed Slack message. PURE. */
|
|
76
|
+
export function slackBotReplyFacts(ev, org, self) {
|
|
77
|
+
return {
|
|
78
|
+
org,
|
|
79
|
+
platform: "slack",
|
|
80
|
+
workspace: ev.teamId,
|
|
81
|
+
channel: ev.channelId,
|
|
82
|
+
threadTs: ev.threadTs,
|
|
83
|
+
messageTs: ev.ts,
|
|
84
|
+
authorUserId: ev.userId,
|
|
85
|
+
authorBotId: ev.botId,
|
|
86
|
+
subtype: ev.subtype,
|
|
87
|
+
...(self.userId === undefined ? {} : { selfUserId: self.userId }),
|
|
88
|
+
...(self.botId === undefined ? {} : { selfBotId: self.botId }),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=slack-bot-ask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-bot-ask.js","sourceRoot":"","sources":["../../../agent/channels/slack-bot-ask.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,yFAAyF;AACzF,gEAAgE;AAChE,EAAE;AACF,wEAAwE;AACxE,yGAAyG;AACzG,0GAA0G;AAC1G,2EAA2E;AAC3E,oFAAoF;AACpF,qGAAqG;AACrG,qEAAqE;AACrE,kEAAkE;AAGlE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAarD,+EAA+E;AAC/E,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,MAAc;IACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,MAAM,GAAG,CAAC,CAAC;AACxE,CAAC;AAED,2BAA2B;AAC3B,MAAM,UAAU,gBAAgB,CAAC,IAAqB;IACpD,OAAO,KAAK,EAAE,CAAC,EAA8B,EAAE;QAC7C,IAAI,CAAC;YACH,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACrD,IAAI,QAAQ,KAAK,OAAO,IAAI,CAAC,MAAM;gBAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;YAChF,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,EAA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AuD;AACvD,MAAM,UAAU,kBAAkB,CAAC,EAAsB,EAAE,GAAW,EAAE,IAA2D;IACjI,OAAO;QACL,GAAG;QACH,QAAQ,EAAE,OAAO;QACjB,SAAS,EAAE,EAAE,CAAC,MAAM;QACpB,OAAO,EAAE,EAAE,CAAC,SAAS;QACrB,QAAQ,EAAE,EAAE,CAAC,QAAQ;QACrB,SAAS,EAAE,EAAE,CAAC,EAAE;QAChB,YAAY,EAAE,EAAE,CAAC,MAAM;QACvB,WAAW,EAAE,EAAE,CAAC,KAAK;QACrB,OAAO,EAAE,EAAE,CAAC,OAAO;QACnB,GAAG,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;QACjE,GAAG,CAAC,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;KAC/D,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,21 @@
|
|
|
1
|
-
import { type BindableContext } from "@open-everywhere/core/agent/adapter-api.js";
|
|
1
|
+
import { type BindableContext, type SurfaceBinding } from "@open-everywhere/core/agent/adapter-api.js";
|
|
2
2
|
/** The public URL Slack POSTs the "/oe" slash command to (the app's Slash Command Request URL). */
|
|
3
3
|
export declare const SLACK_COMMANDS_ROUTE = "/eve/v1/slack/commands";
|
|
4
|
+
/** What the route learned about a command's trust before it binds. `dmPartnerTrust` is the invoker's own
|
|
5
|
+
* verdict in a 1:1 DM. `room` is a channel's `conversations.info` verdict, present whenever Slack answered
|
|
6
|
+
* it, whoever typed the command. `invokerMember` is present only when `users.info` CONFIRMED the invoker a
|
|
7
|
+
* member (see {@link slashRoomVerdict}). The person's binding stamps `room` only beside `invokerMember`;
|
|
8
|
+
* the room's binding stamps it alone (OPE-2588). */
|
|
9
|
+
export interface SlashTrustFacts {
|
|
10
|
+
readonly dmPartnerTrust?: "internal" | "external";
|
|
11
|
+
readonly room?: {
|
|
12
|
+
readonly extShared: boolean;
|
|
13
|
+
};
|
|
14
|
+
readonly invokerMember?: true;
|
|
15
|
+
}
|
|
16
|
+
/** Which verdict a slash binding resolves: the PERSON's (the room's verdict folded with the invoker
|
|
17
|
+
* check, which every member gate reads) or the ROOM's alone (which the room's budget reads). */
|
|
18
|
+
export type SlashTrustLeg = "person" | "room";
|
|
4
19
|
/** Build the BindableContext the identity seam (bindFrom/bindSlack) expects from Slack's
|
|
5
20
|
* slash-command form fields. Slack's slash-command payload carries no `channel_type` /
|
|
6
21
|
* `is_private` bit (unlike an app_mention/message event) — `bindSlack`'s existing fallbacks
|
|
@@ -13,15 +28,103 @@ export declare const SLACK_COMMANDS_ROUTE = "/eve/v1/slack/commands";
|
|
|
13
28
|
* reads — so a Grid declared once now answers here the same way it answers at every other door,
|
|
14
29
|
* instead of resolving as though the line were absent.
|
|
15
30
|
*
|
|
16
|
-
* 🔴 STATE ITS REACH EXACTLY
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
|
|
31
|
+
* 🔴 STATE ITS REACH EXACTLY. For a CHANNEL command the rung does NOT change `binding.trust`: the
|
|
32
|
+
* room's own verdict answers there (see below), and `bindFrom` takes that raw verdict ahead of any
|
|
33
|
+
* vouch. The rung reaches `binding.trust` only on a DM-shaped `/oe` (a `D…` channel id), and only
|
|
34
|
+
* when the invoker probe gave no verdict: the mapper then leaves trust undefined and the vouch
|
|
35
|
+
* answers (see below). Spread conditionally, like every other door: a single-workspace install
|
|
36
|
+
* stamps nothing.
|
|
37
|
+
*
|
|
38
|
+
* 🔴 A CHANNEL COMMAND CARRIES THE ROOM'S OWN VERDICT (OPE-2579). Slack's slash payload carries no
|
|
39
|
+
* sharing bit, so before this every channel `/oe` bound `slackTrust(undefined, undefined,
|
|
40
|
+
* "channel")`, which fails closed to `external`. A member in an internal channel was then refused
|
|
41
|
+
* `/oe suggest on` as an outsider. The route now passes {@link slashRoomVerdict}'s answer as
|
|
42
|
+
* `is_ext_shared` + `trust_checked`, the two attributes a channel message stamps from the same
|
|
43
|
+
* TTL-cached `conversations.info`. So a channel command reads the room's `internal` or `external` as a
|
|
44
|
+
* message in that room does. On the `person` leg (the default) the verdict is stamped only for an
|
|
45
|
+
* invoker `users.info` confirms a member. On the `room` leg it is stamped for anybody, because that
|
|
46
|
+
* leg answers the room's budget, not a member gate (OPE-2588, {@link bindSlashCommand}). No verdict
|
|
47
|
+
* stamps nothing, and the command stays fail-closed `external`.
|
|
48
|
+
*
|
|
49
|
+
* 🔴 A DM COMMAND CARRIES THE INVOKER'S OWN VERDICT (OPE-2579). In a 1:1 DM the invoker IS the
|
|
50
|
+
* partner, and the route passes {@link slashInvokerDmTrust}'s answer as `dm_partner_trust`, the
|
|
51
|
+
* attribute the chat DM leg stamps from the same `users.info` probe. Before this, a workspace vouch
|
|
52
|
+
* alone answered a DM command, so a guest or a Connect stranger in their DM with the app read
|
|
53
|
+
* `internal` here while the same person read `external` in a DM turn. A verdict outranks the vouch
|
|
54
|
+
* in both directions, exactly as in a DM turn: a guest reads `external` under a workspace vouch, and
|
|
55
|
+
* a confirmed member reads `internal` with no declaration at all. No verdict leaves the attribute
|
|
56
|
+
* unset and the binding resolves as before. This reaches every `/oe` command typed in a DM, not
|
|
57
|
+
* only `watch`. */
|
|
58
|
+
export declare function bindableForSlashCommand(params: URLSearchParams, invoker?: SlashTrustFacts, leg?: SlashTrustLeg): BindableContext;
|
|
59
|
+
/**
|
|
60
|
+
* The invoker's own membership verdict for a 1:1 DM command, in `dm_partner_trust`'s vocabulary, or
|
|
61
|
+
* `{}` when there is none to give (OPE-2579). It is the chat DM leg's reading of the same probe
|
|
62
|
+
* (slack-front.ts `liveDmPartnerTrust`): `slackAuthorIsMember` decides, so the two doors cannot
|
|
63
|
+
* drift on what a guest is. A channel or group DM asks nothing here: there the ROOM's verdict is the
|
|
64
|
+
* binding's trust, and {@link slashRoomVerdict} reads it.
|
|
65
|
+
*
|
|
66
|
+
* 🔴 NO VERDICT IS NOT A VERDICT. No user id, no bot token, a refused `users.info`, a transport
|
|
67
|
+
* failure or a probe slower than {@link INVOKER_PROBE_MS} all answer `{}`, which leaves the binding
|
|
68
|
+
* exactly as it resolved before this probe existed. An unanswered probe never invents a guest, and
|
|
69
|
+
* never invents a member.
|
|
70
|
+
*/
|
|
71
|
+
export declare function slashInvokerDmTrust(params: URLSearchParams, probe?: (userId: string, teamId: string | undefined) => Promise<boolean | undefined>): Promise<{
|
|
72
|
+
readonly dmPartnerTrust?: "internal" | "external";
|
|
73
|
+
}>;
|
|
74
|
+
/** The room facts {@link slashRoomVerdict} reads: `slackChannelFactsFor`'s shape, which every channel wake reads. */
|
|
75
|
+
export type SlashRoomFacts = (channelId: string) => Promise<{
|
|
76
|
+
readonly channelType?: string;
|
|
77
|
+
readonly extShared?: boolean;
|
|
78
|
+
readonly trustChecked?: boolean;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* A CHANNEL command's room verdict and invoker check, or `{}` when there is no room verdict to give
|
|
82
|
+
* (OPE-2579). The room read is `slackChannelFactsFor`, the TTL-cached `conversations.info` every
|
|
83
|
+
* channel wake reads, so the command door and the message door cannot disagree about one room.
|
|
84
|
+
*
|
|
85
|
+
* 🔴 THE INVOKER LEG, AND IT FAILS CLOSED. A channel message keeps the room's verdict on the auth and marks
|
|
86
|
+
* a guest author on the side (slack-events.ts `slackWakeAuthorFacts`), because one guest's message must not
|
|
87
|
+
* demote the channel's memory for everybody. A command has no session to protect: its binding exists for
|
|
88
|
+
* one answer, and `/oe suggest on` and `/oe watch more|less` read `binding.trust` as "is this person a
|
|
89
|
+
* member". So the route folds the author leg into the binding's `trust`, the composition Discord and
|
|
90
|
+
* Teams make: `invokerMember` is set only when `users.info` CONFIRMS the invoker a member, and the
|
|
91
|
+
* person's binding stamps the room's verdict only beside it. A guest, a Slack Connect stranger, and a
|
|
92
|
+
* person the probe could not check (no `users:read`, a refusal, a timeout) all leave `trust` fail-closed
|
|
93
|
+
* `external`. The message door fails OPEN on an unanswered probe because it marks a turn. Here `trust`
|
|
94
|
+
* IS the member gate, and a channel has no declaration to fall back to the way a DM command does.
|
|
95
|
+
*
|
|
96
|
+
* 🔴 THE ROOM'S VERDICT IS RETURNED FOR EVERY INVOKER (OPE-2588). `/oe budget` names the room's budget,
|
|
97
|
+
* and a channel's turns are charged under the room's domain, whoever typed them. So {@link bindSlashCommand}
|
|
98
|
+
* binds the room's verdict alone into `roomTrust`, and the budget reads that. A guest's `trust` is
|
|
99
|
+
* unchanged, and `/oe budget` reads both to refuse a guest in an internal channel (commands/core.ts
|
|
100
|
+
* `budgetWithheldFrom`). `/oe cover on` refuses outside a DM before it reads trust.
|
|
101
|
+
*
|
|
102
|
+
* 🔴 ONLY A ROOM IN THE CHANNEL MODE IS STAMPED. A 1:1 DM has its own leg ({@link slashInvokerDmTrust}).
|
|
103
|
+
* A group DM, or a room whose type Slack did not report, stamps nothing, so its binding is unchanged.
|
|
104
|
+
* Stamping a sharing verdict on a group DM the binding still calls a channel would mix two modes' rules.
|
|
105
|
+
*
|
|
106
|
+
* 🔴 NO VERDICT IS NOT A VERDICT. A failed or refused `conversations.info`, a response without the check,
|
|
107
|
+
* or a read slower than {@link INVOKER_PROBE_MS} answers `{}`. The command then binds `external`, as
|
|
108
|
+
* before this read existed. The room read and the invoker probe run in parallel inside one ack budget.
|
|
109
|
+
*/
|
|
110
|
+
export declare function slashRoomVerdict(params: URLSearchParams, roomFacts?: SlashRoomFacts, probe?: (userId: string, teamId: string | undefined) => Promise<boolean | undefined>): Promise<SlashTrustFacts>;
|
|
111
|
+
/** Both legs, for whichever kind of room the command came from. Never throws. */
|
|
112
|
+
export declare function slashTrustFacts(params: URLSearchParams): Promise<SlashTrustFacts>;
|
|
113
|
+
/**
|
|
114
|
+
* The slash command's binding, with the room's trust and the person's trust kept apart (OPE-2588).
|
|
115
|
+
*
|
|
116
|
+
* `trust` is the PERSON leg: the member gate `/oe suggest on`, `/oe watch more|less` and `/oe cover on`
|
|
117
|
+
* read. `roomTrust` is the ROOM leg: the same `bindFrom` walk over the room's verdict alone, so the
|
|
118
|
+
* declarations and the fail-closed default apply to it unchanged. `/oe budget` and the caps behind
|
|
119
|
+
* `raise` and `clear` read it through `roomTrustOf`. Before this the binding carried one value, so a
|
|
120
|
+
* guest in an internal channel read the external domain's budget while that channel's turns were
|
|
121
|
+
* charged under the internal domain. Now `/oe budget` refuses that guest, because a guest must not read
|
|
122
|
+
* an internal room's caps and spend (Tommy's ruling on #1431).
|
|
123
|
+
*
|
|
124
|
+
* In a DM both legs bind the same context, so the two values are equal. Every other field comes from
|
|
125
|
+
* the person's binding. The two bindings differ only in the two trust attributes, which move no key.
|
|
126
|
+
*/
|
|
127
|
+
export declare function bindSlashCommand(params: URLSearchParams, facts: SlashTrustFacts): SurfaceBinding;
|
|
25
128
|
declare const _default: import("eve/channels").Channel<undefined, Record<string, unknown>, Record<string, unknown>>;
|
|
26
129
|
export default _default;
|
|
27
130
|
//# sourceMappingURL=slack-commands.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack-commands.d.ts","sourceRoot":"","sources":["../../../agent/channels/slack-commands.ts"],"names":[],"mappings":"AAqCA,OAAO,
|
|
1
|
+
{"version":3,"file":"slack-commands.d.ts","sourceRoot":"","sources":["../../../agent/channels/slack-commands.ts"],"names":[],"mappings":"AAqCA,OAAO,EAYL,KAAK,eAAe,EACpB,KAAK,cAAc,EACpB,MAAM,4CAA4C,CAAC;AASpD,mGAAmG;AACnG,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAS7D;;;;qDAIqD;AACrD,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,cAAc,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC;IAClD,QAAQ,CA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