@memberjunction/messaging-adapters 0.0.1 → 5.17.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/README.md +231 -43
- package/dist/base/BaseMessagingAdapter.d.ts +428 -0
- package/dist/base/BaseMessagingAdapter.d.ts.map +1 -0
- package/dist/base/BaseMessagingAdapter.js +934 -0
- package/dist/base/BaseMessagingAdapter.js.map +1 -0
- package/dist/base/message-formatter.d.ts +70 -0
- package/dist/base/message-formatter.d.ts.map +1 -0
- package/dist/base/message-formatter.js +201 -0
- package/dist/base/message-formatter.js.map +1 -0
- package/dist/base/types.d.ts +211 -0
- package/dist/base/types.d.ts.map +1 -0
- package/dist/base/types.js +6 -0
- package/dist/base/types.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +76 -0
- package/dist/index.js.map +1 -0
- package/dist/slack/SlackAdapter.d.ts +141 -0
- package/dist/slack/SlackAdapter.d.ts.map +1 -0
- package/dist/slack/SlackAdapter.js +291 -0
- package/dist/slack/SlackAdapter.js.map +1 -0
- package/dist/slack/SlackMessagingExtension.d.ts +148 -0
- package/dist/slack/SlackMessagingExtension.d.ts.map +1 -0
- package/dist/slack/SlackMessagingExtension.js +433 -0
- package/dist/slack/SlackMessagingExtension.js.map +1 -0
- package/dist/slack/slack-block-builder.d.ts +133 -0
- package/dist/slack/slack-block-builder.d.ts.map +1 -0
- package/dist/slack/slack-block-builder.js +748 -0
- package/dist/slack/slack-block-builder.js.map +1 -0
- package/dist/slack/slack-formatter.d.ts +37 -0
- package/dist/slack/slack-formatter.d.ts.map +1 -0
- package/dist/slack/slack-formatter.js +116 -0
- package/dist/slack/slack-formatter.js.map +1 -0
- package/dist/slack/slack-interactivity.d.ts +38 -0
- package/dist/slack/slack-interactivity.d.ts.map +1 -0
- package/dist/slack/slack-interactivity.js +414 -0
- package/dist/slack/slack-interactivity.js.map +1 -0
- package/dist/slack/slack-routes.d.ts +35 -0
- package/dist/slack/slack-routes.d.ts.map +1 -0
- package/dist/slack/slack-routes.js +98 -0
- package/dist/slack/slack-routes.js.map +1 -0
- package/dist/teams/TeamsAdapter.d.ts +155 -0
- package/dist/teams/TeamsAdapter.d.ts.map +1 -0
- package/dist/teams/TeamsAdapter.js +383 -0
- package/dist/teams/TeamsAdapter.js.map +1 -0
- package/dist/teams/TeamsMessagingExtension.d.ts +75 -0
- package/dist/teams/TeamsMessagingExtension.d.ts.map +1 -0
- package/dist/teams/TeamsMessagingExtension.js +176 -0
- package/dist/teams/TeamsMessagingExtension.js.map +1 -0
- package/dist/teams/teams-card-builder.d.ts +94 -0
- package/dist/teams/teams-card-builder.d.ts.map +1 -0
- package/dist/teams/teams-card-builder.js +648 -0
- package/dist/teams/teams-card-builder.js.map +1 -0
- package/dist/teams/teams-formatter.d.ts +39 -0
- package/dist/teams/teams-formatter.d.ts.map +1 -0
- package/dist/teams/teams-formatter.js +107 -0
- package/dist/teams/teams-formatter.js.map +1 -0
- package/package.json +40 -7
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @memberjunction/messaging-adapters
|
|
3
|
+
* @description Rich Slack Block Kit builder functions for agent responses.
|
|
4
|
+
*
|
|
5
|
+
* Composes structured Block Kit layouts from agent execution results,
|
|
6
|
+
* including agent identity headers, artifact cards, action buttons,
|
|
7
|
+
* media blocks, and metadata footers.
|
|
8
|
+
*
|
|
9
|
+
* @see https://api.slack.com/reference/block-kit
|
|
10
|
+
*/
|
|
11
|
+
import { ExecuteAgentResult, MJAIAgentEntityExtended, ActionableCommand, AutomaticCommand, AgentResponseForm } from '@memberjunction/ai-core-plus';
|
|
12
|
+
/**
|
|
13
|
+
* Retrieve full response text by store key.
|
|
14
|
+
* Returns null if expired or not found.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getFullResponseText(key: string): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Structured payload detected in an agent result.
|
|
19
|
+
* Used for rendering rich artifact cards.
|
|
20
|
+
*/
|
|
21
|
+
export interface ArtifactPayload {
|
|
22
|
+
Title?: string;
|
|
23
|
+
Summary?: string;
|
|
24
|
+
Sections?: ArtifactSection[];
|
|
25
|
+
Sources?: ArtifactSource[];
|
|
26
|
+
URL?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ArtifactSection {
|
|
29
|
+
Heading: string;
|
|
30
|
+
Content: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ArtifactSource {
|
|
33
|
+
Title: string;
|
|
34
|
+
URL: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Options for building a rich response layout.
|
|
38
|
+
*/
|
|
39
|
+
export interface BuildRichResponseOptions {
|
|
40
|
+
/** Base URL of MJ Explorer for deep-linking `open:resource` commands. */
|
|
41
|
+
explorerBaseURL?: string;
|
|
42
|
+
/** MJ Conversation Artifact ID — when provided, the Explorer link points to the artifact viewer. */
|
|
43
|
+
artifactId?: string;
|
|
44
|
+
/** MJ Conversation ID — when no artifact exists, links to the conversation in MJ Explorer. */
|
|
45
|
+
conversationId?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Build the complete Block Kit layout for an agent response.
|
|
49
|
+
*
|
|
50
|
+
* Layout:
|
|
51
|
+
* ```
|
|
52
|
+
* [Agent Context Header] — agent avatar + name
|
|
53
|
+
* [Divider]
|
|
54
|
+
* [Text Content Blocks] — markdown → mrkdwn sections
|
|
55
|
+
* [Artifact Card] — if structured payload detected
|
|
56
|
+
* [Media Blocks] — if mediaOutputs present
|
|
57
|
+
* [Notification Blocks] — if automatic notification commands present
|
|
58
|
+
* [Divider]
|
|
59
|
+
* [Action Buttons] — if actionableCommands present
|
|
60
|
+
* [Metadata Footer] — timing and token info
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Enforces Slack's 50-block limit. If exceeded, truncates text blocks
|
|
64
|
+
* and adds a truncation notice.
|
|
65
|
+
*/
|
|
66
|
+
export declare function buildRichResponse(result: ExecuteAgentResult | null, agent: MJAIAgentEntityExtended, responseText: string, options?: BuildRichResponseOptions): Record<string, unknown>[];
|
|
67
|
+
/**
|
|
68
|
+
* Build a context block showing the agent's avatar and name.
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildAgentContextBlock(agent: MJAIAgentEntityExtended): Record<string, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Convert markdown response text to Block Kit text sections.
|
|
73
|
+
* Reuses the existing `markdownToBlocks` logic from `slack-formatter.ts`.
|
|
74
|
+
*/
|
|
75
|
+
export declare function buildTextBlocks(markdown: string): Record<string, unknown>[];
|
|
76
|
+
/**
|
|
77
|
+
* Build a rich artifact card from a structured payload.
|
|
78
|
+
* Renders title, summary, source links, and an optional "View Full" button.
|
|
79
|
+
*/
|
|
80
|
+
export declare function buildArtifactCard(artifact: ArtifactPayload): Record<string, unknown>[];
|
|
81
|
+
/**
|
|
82
|
+
* Build action buttons from agent actionable commands.
|
|
83
|
+
*
|
|
84
|
+
* Handles both command types:
|
|
85
|
+
* - `open:url` → Slack URL button (opens external link)
|
|
86
|
+
* - `open:resource` → Deep-link button to MJ Explorer if `explorerBaseURL` is configured,
|
|
87
|
+
* otherwise rendered as an informational context block showing entity/resource info
|
|
88
|
+
*
|
|
89
|
+
* Returns an array of blocks (may include both action and context blocks).
|
|
90
|
+
*/
|
|
91
|
+
export declare function buildActionButtons(commands: ActionableCommand[], explorerBaseURL?: string): Record<string, unknown>[];
|
|
92
|
+
/**
|
|
93
|
+
* Build notification blocks from automatic commands.
|
|
94
|
+
*
|
|
95
|
+
* Only handles `notification` type automatic commands — other types
|
|
96
|
+
* (like `refresh:data`) have no meaningful Slack representation.
|
|
97
|
+
*
|
|
98
|
+
* Renders notifications as styled context blocks with severity icons.
|
|
99
|
+
*/
|
|
100
|
+
export declare function buildNotificationBlocks(commands: AutomaticCommand[] | undefined): Record<string, unknown>[];
|
|
101
|
+
/**
|
|
102
|
+
* Build image blocks from media outputs.
|
|
103
|
+
*/
|
|
104
|
+
export declare function buildMediaBlocks(mediaOutputs: Record<string, unknown>[]): Record<string, unknown>[];
|
|
105
|
+
/**
|
|
106
|
+
* Build a warning-styled error display block.
|
|
107
|
+
*/
|
|
108
|
+
export declare function buildErrorBlocks(errorMessage: string): Record<string, unknown>[];
|
|
109
|
+
/**
|
|
110
|
+
* Build a metadata footer with timing and token information.
|
|
111
|
+
*/
|
|
112
|
+
export declare function buildMetadataFooter(result: ExecuteAgentResult): Record<string, unknown>;
|
|
113
|
+
/**
|
|
114
|
+
* Build a divider block.
|
|
115
|
+
*/
|
|
116
|
+
export declare function buildDivider(): Record<string, unknown>;
|
|
117
|
+
/**
|
|
118
|
+
* Build response form blocks from an AgentResponseForm.
|
|
119
|
+
*
|
|
120
|
+
* All forms render as a summary + a single green button that opens a Slack modal.
|
|
121
|
+
* This is agent-agnostic and avoids partial submissions — the user fills out
|
|
122
|
+
* everything in the modal and submits once.
|
|
123
|
+
*/
|
|
124
|
+
export declare function buildResponseForm(form: AgentResponseForm): Record<string, unknown>[];
|
|
125
|
+
/**
|
|
126
|
+
* Build a Slack modal view definition from an AgentResponseForm.
|
|
127
|
+
* Used when the form contains non-choice questions that need input fields.
|
|
128
|
+
*
|
|
129
|
+
* Slack modals support: plain_text_input, number_input, datepicker, checkboxes,
|
|
130
|
+
* radio_buttons, static_select, and multi_static_select.
|
|
131
|
+
*/
|
|
132
|
+
export declare function buildFormModal(form: AgentResponseForm): Record<string, unknown>;
|
|
133
|
+
//# sourceMappingURL=slack-block-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slack-block-builder.d.ts","sourceRoot":"","sources":["../../src/slack/slack-block-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,iBAAiB,EAAuB,gBAAgB,EAAE,iBAAiB,EAA6B,MAAM,8BAA8B,CAAC;AAqCnM;;;GAGG;AACH,wBAAgB,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