@novu/framework 2.13.0 → 2.13.1-rc.72c80d5b17
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/cjs/{agent.types-Dqm2VBTO.d.cts → agent.types-B5VnP69G.d.cts} +48 -2
- package/dist/cjs/ai-sdk/index.d.cts +1 -1
- package/dist/cjs/cards.cjs +1 -1
- package/dist/cjs/{health-check.types-B9FbzRbm.d.cts → health-check.types-CtWQ_YSy.d.cts} +4 -3
- package/dist/cjs/{index-CLZZRnNV.d.cts → index-vgb88C84.d.cts} +3 -3
- package/dist/cjs/index.cjs +88 -88
- package/dist/cjs/index.d.cts +5 -5
- package/dist/cjs/internal/index.cjs +43 -43
- package/dist/cjs/internal/index.d.cts +19 -15
- package/dist/cjs/langchain/index.cjs +1 -1
- package/dist/cjs/langchain/index.d.cts +15 -1
- package/dist/cjs/servers/express.cjs +88 -88
- package/dist/cjs/servers/express.d.cts +6 -6
- package/dist/cjs/servers/h3.cjs +86 -86
- package/dist/cjs/servers/h3.d.cts +6 -6
- package/dist/cjs/servers/hono.cjs +86 -86
- package/dist/cjs/servers/hono.d.cts +6 -6
- package/dist/cjs/servers/lambda.cjs +88 -88
- package/dist/cjs/servers/lambda.d.cts +6 -6
- package/dist/cjs/servers/nest.cjs +96 -96
- package/dist/cjs/servers/nest.d.cts +8 -8
- package/dist/cjs/servers/next.cjs +90 -90
- package/dist/cjs/servers/next.d.cts +6 -6
- package/dist/cjs/servers/nuxt.cjs +86 -86
- package/dist/cjs/servers/nuxt.d.cts +6 -6
- package/dist/cjs/servers/remix.cjs +86 -86
- package/dist/cjs/servers/remix.d.cts +6 -6
- package/dist/cjs/servers/sveltekit.cjs +74 -74
- package/dist/cjs/servers/sveltekit.d.cts +6 -6
- package/dist/cjs/step-resolver.cjs +4 -4
- package/dist/cjs/step-resolver.d.cts +17 -4
- package/dist/cjs/{subscriber.types-DubxcL8q.d.cts → subscriber.types-CyNKT0nZ.d.cts} +67 -2
- package/dist/cjs/validators.cjs +1 -1
- package/dist/esm/{agent.types-E3sxq6xr.d.ts → agent.types-HUDhyXrV.d.ts} +48 -2
- package/dist/esm/ai-sdk/index.d.ts +1 -1
- package/dist/esm/cards.js +1 -1
- package/dist/esm/{chunk-WDBIT4NK.js → chunk-CGZ5P44A.js} +66 -66
- package/dist/esm/chunk-FMKD6TON.js +1 -0
- package/dist/esm/{chunk-CANJPWLT.js → chunk-SPS3KBKF.js} +4 -4
- package/dist/esm/{chunk-FRWG7YTE.js → chunk-VY27ZAO7.js} +1 -1
- package/dist/esm/{chunk-46AHJTS7.js → chunk-X5AZIKIR.js} +8 -8
- package/dist/esm/{chunk-22DBAEUX.js → chunk-XIVU4VDS.js} +1 -1
- package/dist/esm/{chunk-2M25EATE.js → chunk-YLCLZVYS.js} +1 -1
- package/dist/esm/{health-check.types-BNocZ4Wk.d.ts → health-check.types-0Rv-l8yD.d.ts} +4 -3
- package/dist/esm/{index-CWldA6G5.d.ts → index-C0oUWDlb.d.ts} +3 -3
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/index.d.ts +10 -6
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/jsx-dev-runtime.js +1 -1
- package/dist/esm/{jsx-runtime-P2HN3TPO.js → jsx-runtime-5ZWEWA4A.js} +1 -1
- package/dist/esm/jsx-runtime.js +1 -1
- package/dist/esm/langchain/index.d.ts +15 -1
- package/dist/esm/langchain/index.js +1 -1
- package/dist/esm/servers/express.d.ts +6 -6
- package/dist/esm/servers/express.js +1 -1
- package/dist/esm/servers/h3.d.ts +6 -6
- package/dist/esm/servers/h3.js +1 -1
- package/dist/esm/servers/hono.d.ts +6 -6
- package/dist/esm/servers/hono.js +1 -1
- package/dist/esm/servers/lambda.d.ts +6 -6
- package/dist/esm/servers/lambda.js +1 -1
- package/dist/esm/servers/nest.d.ts +8 -8
- package/dist/esm/servers/nest.js +1 -1
- package/dist/esm/servers/next.d.ts +6 -6
- package/dist/esm/servers/next.js +1 -1
- package/dist/esm/servers/nuxt.d.ts +6 -6
- package/dist/esm/servers/nuxt.js +1 -1
- package/dist/esm/servers/remix.d.ts +6 -6
- package/dist/esm/servers/remix.js +1 -1
- package/dist/esm/servers/sveltekit.d.ts +6 -6
- package/dist/esm/servers/sveltekit.js +1 -1
- package/dist/esm/step-resolver.d.ts +17 -4
- package/dist/esm/step-resolver.js +1 -1
- package/dist/esm/{subscriber.types-CmybpXhA.d.ts → subscriber.types-g7VnI_ZQ.d.ts} +67 -2
- package/dist/esm/validators.js +1 -1
- package/langchain/package.json +4 -0
- package/nest/package.json +2 -1
- package/package.json +2 -2
- package/dist/esm/chunk-LHU5A7DI.js +0 -1
- /package/dist/esm/{chunk-3ZWME5KT.js → chunk-7C3QBYLB.js} +0 -0
- /package/dist/esm/{chunk-XEHQJMMQ.js → chunk-RBTQQ5IZ.js} +0 -0
|
@@ -47,7 +47,8 @@ declare enum ChannelTypeEnum {
|
|
|
47
47
|
EMAIL = "email",
|
|
48
48
|
SMS = "sms",
|
|
49
49
|
CHAT = "chat",
|
|
50
|
-
PUSH = "push"
|
|
50
|
+
PUSH = "push",
|
|
51
|
+
TOOL = "tool"
|
|
51
52
|
}
|
|
52
53
|
interface IAttachmentOptions {
|
|
53
54
|
mime: string;
|
|
@@ -241,6 +242,24 @@ interface AgentConversation {
|
|
|
241
242
|
createdAt: string;
|
|
242
243
|
lastActivityAt: string;
|
|
243
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* A single connect-time context value: either a bare string id, or a rich object with an `id`
|
|
247
|
+
* and arbitrary `data`. Mirrors Novu's `ContextValue`.
|
|
248
|
+
*/
|
|
249
|
+
type AgentContextValue = string | {
|
|
250
|
+
id: string;
|
|
251
|
+
data?: Record<string, unknown>;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Connect-time context bound to the channel connection and resolved server-side for the current
|
|
255
|
+
* turn.
|
|
256
|
+
*
|
|
257
|
+
* Populated by Novu from the context an integrator passes to the Connect button (e.g. the Slack
|
|
258
|
+
* connect flow persists it on the `ChannelConnection`). It lets a single hosted agent serve many
|
|
259
|
+
* tenants: the agent reads its own tenant/org out of the context to scope writes. Keys are
|
|
260
|
+
* integrator-defined context types (e.g. `tenant`), mirroring Novu's `ContextPayload`.
|
|
261
|
+
*/
|
|
262
|
+
type AgentContextPayload = Record<string, AgentContextValue>;
|
|
244
263
|
/** The Novu subscriber who initiated or is participating in the conversation. */
|
|
245
264
|
interface AgentSubscriber {
|
|
246
265
|
/** Stable Novu subscriber ID. */
|
|
@@ -441,6 +460,14 @@ interface ToolApprovalConfig {
|
|
|
441
460
|
approvalCard: (overrides?: Omit<ToolApprovalCard, 'type'>) => ToolApprovalCard;
|
|
442
461
|
}) => MessageContent | ToolApprovalCard;
|
|
443
462
|
}
|
|
463
|
+
/**
|
|
464
|
+
* How Novu treats unknown/unlinked senders of a distributed agent, mirrored onto
|
|
465
|
+
* the bridge wire so the framework can gate before running a handler:
|
|
466
|
+
* - `open`: anyone may talk to the agent (unknown senders are auto-provisioned).
|
|
467
|
+
* - `restricted`: only authenticated, linked subscribers proceed; unlinked authors
|
|
468
|
+
* are shown an auth CTA and short-circuited.
|
|
469
|
+
*/
|
|
470
|
+
type AgentSubscriberAccess = 'open' | 'restricted';
|
|
444
471
|
/** Passed to `onToolApproval` when the user clicks Approve or Deny. */
|
|
445
472
|
interface ToolApprovalDecision {
|
|
446
473
|
/** The tool that was awaiting approval. */
|
|
@@ -500,6 +527,12 @@ interface AgentHandlerContext {
|
|
|
500
527
|
* resolve a subscriber for this conversation.
|
|
501
528
|
*/
|
|
502
529
|
readonly subscriber: AgentSubscriber | null;
|
|
530
|
+
/**
|
|
531
|
+
* Connect-time context resolved for this turn from the channel connection, or `null` when none
|
|
532
|
+
* was bound. Populated server-side (trusted) — safe to use for authorizing and scoping writes
|
|
533
|
+
* (e.g. reading the customer's tenant/organization out of it).
|
|
534
|
+
*/
|
|
535
|
+
readonly context: AgentContextPayload | null;
|
|
503
536
|
/**
|
|
504
537
|
* Full conversation history as an ordered array of entries.
|
|
505
538
|
* Map to your LLM's message format before making a model call:
|
|
@@ -728,6 +761,19 @@ interface AgentBridgeRequest {
|
|
|
728
761
|
reaction: AgentReaction | null;
|
|
729
762
|
conversation: AgentConversation;
|
|
730
763
|
subscriber: AgentSubscriber | null;
|
|
764
|
+
/**
|
|
765
|
+
* Effective subscriber-access policy for this agent (`open` | `restricted`),
|
|
766
|
+
* resolved server-side. Drives the framework's built-in auth gate: on a
|
|
767
|
+
* `restricted` agent an unlinked author is short-circuited with an auth CTA
|
|
768
|
+
* before any handler runs. Optional on the wire for backward compatibility;
|
|
769
|
+
* absent is treated as `open` (no gating).
|
|
770
|
+
*/
|
|
771
|
+
subscriberAccess?: AgentSubscriberAccess;
|
|
772
|
+
/**
|
|
773
|
+
* Connect-time context resolved server-side for this turn (trusted). Optional on the wire so
|
|
774
|
+
* older API versions that don't send it remain compatible; absent → `ctx.context` is `null`.
|
|
775
|
+
*/
|
|
776
|
+
context?: AgentContextPayload | null;
|
|
731
777
|
history: AgentHistoryEntry[];
|
|
732
778
|
platform: string;
|
|
733
779
|
platformContext: AgentPlatformContext;
|
|
@@ -823,4 +869,4 @@ interface SentMessageInfo {
|
|
|
823
869
|
platformThreadId: string;
|
|
824
870
|
}
|
|
825
871
|
|
|
826
|
-
export { type Agent as A, type
|
|
872
|
+
export { type Agent as A, type ISubscriberPayload as B, TriggerEventStatusEnum as C, type ToolResult as D, type ToolApprovalRequestPayload as E, type FileRef as F, AgentEventEnum as G, type TypingControl as H, type ITriggerPayload as I, type ToolApprovalControl as J, type AgentBridgeRequest as K, type AgentReplyPayload as L, type MessageContent as M, type DeleteMessagePayload as N, type EditPayload as O, type MetadataSignal as P, type ParsedApprovalAction as Q, type ReplyHandle as R, type SentMessageInfo as S, type ToolApprovalCard as T, type ReplyContent as U, type Signal as V, type WorkflowPreferencesPartial as W, type TriggerSignal as X, buildApprovalActionId as Y, parseApprovalActionId as Z, type AgentAction as a, type AgentActionContext as b, type AgentAttachment as c, type AgentContext as d, type AgentContextPayload as e, type AgentContextValue as f, type AgentConversation as g, AgentDeliveryError as h, AgentError as i, type AgentHandlerContext as j, type AgentHandlers as k, type AgentHistoryEntry as l, type AgentMessage as m, type AgentMessageAuthor as n, type AgentMessageContext as o, type AgentPlatformContext as p, type AgentReaction as q, type AgentReactionContext as r, type AgentResolveContext as s, type AgentSubscriber as t, type AgentSubscriberAccess as u, type AgentToolCall as v, type ToolApprovalConfig as w, type ToolApprovalDecision as x, toAgentError as y, type TriggerRecipientsPayload as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { k as AgentHandlers, m as AgentMessage, o as AgentMessageContext, M as MessageContent, x as ToolApprovalDecision, b as AgentActionContext, R as ReplyHandle, A as Agent, l as AgentHistoryEntry } from '../agent.types-B5VnP69G.cjs';
|
|
2
2
|
import { streamText, generateText, ModelMessage } from 'ai';
|
|
3
3
|
import { A as Awaitable } from '../util.types-DaFfsxgy.cjs';
|
|
4
4
|
import 'chat';
|
package/dist/cjs/cards.cjs
CHANGED
|
@@ -54,4 +54,4 @@ $$`:`${t}$$`},Fc=t=>Ac(t)%2===0?t:Lc(t),Dc=t=>Mc(t)%2===1?`${t}$`:t,vc=(t,r,e)=>
|
|
|
54
54
|
`),n=t.split(`
|
|
55
55
|
`);e&&n.length>0&&n.at(-1)===""&&n.pop();let i=[],o=!1,a=!1;for(let l=0;l<n.length;l++){let u=n[l].trim();if(!o&&(u.startsWith("```")||u.startsWith("~~~"))){a=!a,i.push(n[l]);continue}if(a){i.push(n[l]);continue}let c=u!==""&&(Rn.test(u)||On.test(u));if(c&&!o){let h=!1;for(let d=l;d<n.length;d++){let f=n[d].trim();if(On.test(f)){h=!0;break}if(f===""||!Rn.test(f))break}h&&(i.push("```"),o=!0)}else!c&&o&&(i.push("```"),o=!1);i.push(n[l])}o&&r&&i.push("```");let s=i.join(`
|
|
56
56
|
`);return e&&(s+=`
|
|
57
|
-
`),s}function fh(t){return"adapterName"in t&&!("adapter"in t)}var Ua="thread-state:";function dh(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var qy=class Nn{constructor(r){L(this,"id");L(this,"channelId");L(this,"isDM");L(this,"channelVisibility");L(this,"_adapter");L(this,"_adapterName");L(this,"_stateAdapterInstance");L(this,"_recentMessages",[]);L(this,"_isSubscribedContext");L(this,"_currentMessage");L(this,"_streamingUpdateIntervalMs");L(this,"_fallbackStreamingPlaceholderText");L(this,"_channel");L(this,"_threadHistory");L(this,"_logger");var e,n,i,o;this.id=r.id,this.channelId=r.channelId,this.isDM=(e=r.isDM)!=null?e:!1,this.channelVisibility=(n=r.channelVisibility)!=null?n:"unknown",this._isSubscribedContext=(i=r.isSubscribedContext)!=null?i:!1,this._currentMessage=r.currentMessage,this._logger=r.logger,this._streamingUpdateIntervalMs=(o=r.streamingUpdateIntervalMs)!=null?o:500,this._fallbackStreamingPlaceholderText=r.fallbackStreamingPlaceholderText!==void 0?r.fallbackStreamingPlaceholderText:"...",fh(r)?this._adapterName=r.adapterName:(this._adapter=r.adapter,this._stateAdapterInstance=r.stateAdapter,this._threadHistory=r.threadHistory),r.initialMessage&&(this._recentMessages=[r.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let e=Je().getAdapter(this._adapterName);if(!e)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=e,e}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let r=Je();return this._stateAdapterInstance=r.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(r){this._recentMessages=r}get state(){return this._stateAdapter.get(`${Ua}${this.id}`)}async setState(r,e){let n=`${Ua}${this.id}`;if(e!=null&&e.replace)await this._stateAdapter.set(n,r,Qe);else{let o={...await this._stateAdapter.get(n),...r};await this._stateAdapter.set(n,o,Qe)}}get channel(){if(!this._channel){let r=oh(this.adapter,this.id);this._channel=new ah({id:r,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,threadHistory:this._threadHistory})}return this._channel}get messages(){let r=this.adapter,e=this.id,n=this._threadHistory;return{async*[Symbol.asyncIterator](){let i,o=!1;for(;;){let a=await r.fetchMessages(e,{cursor:i,direction:"backward"}),s=[...a.messages].reverse();for(let l of s)o=!0,yield l;if(!a.nextCursor||a.messages.length===0)break;i=a.nextCursor}if(!o&&n){let a=await n.getMessages(e);for(let s=a.length-1;s>=0;s--)yield a[s]}}}}get allMessages(){let r=this.adapter,e=this.id,n=this._threadHistory;return{async*[Symbol.asyncIterator](){let i,o=!1;for(;;){let a=await r.fetchMessages(e,{limit:100,cursor:i,direction:"forward"});for(let s of a.messages)o=!0,yield s;if(!a.nextCursor||a.messages.length===0)break;i=a.nextCursor}if(!o&&n){let a=await n.getMessages(e);for(let s of a)yield s}}}}async getParticipants(){let r=new Map;this._currentMessage&&!this._currentMessage.author.isMe&&!this._currentMessage.author.isBot&&r.set(this._currentMessage.author.userId,this._currentMessage.author);for await(let e of this.allMessages)e.author.isMe||e.author.isBot||r.has(e.author.userId)||r.set(e.author.userId,e.author);return[...r.values()]}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(r){if(Wa(r)){if(r.kind==="stream"){let o=r.getPostData(),a={...o.options.updateIntervalMs?{updateIntervalMs:o.options.updateIntervalMs}:{},...o.options.groupTasks?{taskDisplayMode:o.options.groupTasks}:{},...o.options.endWith?{stopBlocks:o.options.endWith}:{}};return await this.handleStream(o.stream,a),r}return await this.handlePostableObject(r),r}if(dh(r))return this.handleStream(r);let e=r;if(dt(r)){let o=ft(r);if(!o)throw new Error("Invalid JSX element: must be a Card element");e=o}e=await this.processCallbackUrls(e);let n=await this.adapter.postMessage(this.id,e),i=this.createSentMessage(n.id,e,n.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new Ut(i)),i}async handlePostableObject(r){await Ga(r,this.adapter,this.id,(e,n)=>this.adapter.postMessage(e,n),this._logger)}async postEphemeral(r,e,n){let{fallbackToDM:i}=n,o=typeof r=="string"?r:r.userId,a;if(dt(e)){let s=ft(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");a=s}else a=e;if(a=await this.processCallbackUrls(a),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,o,a);if(!i)return null;if(this.adapter.openDM){let s=await this.adapter.openDM(o),l=await this.adapter.postMessage(s,a);return{id:l.id,threadId:s,usedFallback:!0,raw:l.raw}}return null}async processCallbackUrls(r){var e;if(typeof r=="string")return r;if("type"in r&&r.type==="card")return Ge(r,this._stateAdapter);if("card"in r&&((e=r.card)==null?void 0:e.type)==="card"){let n=await Ge(r.card,this._stateAdapter);if(n!==r.card)return{...r,card:n}}return r}async schedule(r,e){let n;if(dt(r)){let i=ft(r);if(!i)throw new Error("Invalid JSX element: must be a Card element");n=i}else n=r;if(n=await this.processCallbackUrls(n),!this.adapter.scheduleMessage)throw new Ja("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,n,e)}async handleStream(r,e){let n=Va(r),i={updateIntervalMs:this._streamingUpdateIntervalMs,...e};if(this._currentMessage&&(i.recipientUserId=this._currentMessage.author.userId,i.recipientTeamId=this.extractSlackRecipientTeamId(this._currentMessage.raw)),this.adapter.stream){let a="",s={[Symbol.asyncIterator]:()=>{let u=n[Symbol.asyncIterator]();return{async next(){let c=await u.next();if(!c.done){let h=c.value;typeof h=="string"?a+=h:h.type==="markdown_text"&&(a+=h.text)}return c}}}},l=await this.adapter.stream(this.id,s,i);if(l){let u=this.createSentMessage(l.id,{markdown:a},l.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new Ut(u)),u}}let o={[Symbol.asyncIterator]:()=>{let a=n[Symbol.asyncIterator]();return{async next(){for(;;){let s=await a.next();if(s.done)return{value:void 0,done:!0};let l=s.value;if(typeof l=="string")return{value:l,done:!1};if(l.type==="markdown_text")return{value:l.text,done:!1}}}}}};return this.fallbackStream(o,i)}extractSlackRecipientTeamId(r){var n;if(!r||typeof r!="object")return;let e=r;if(typeof e.team_id=="string"&&e.team_id)return e.team_id;if(typeof e.team=="string"&&e.team)return e.team;if(e.team&&typeof e.team=="object"&&typeof e.team.id=="string"&&e.team.id)return e.team.id;if(typeof((n=e.user)==null?void 0:n.team_id)=="string"&&e.user.team_id)return e.user.team_id}async startTyping(r){await this.adapter.startTyping(this.id,r)}async fallbackStream(r,e){var y;let n=(y=e==null?void 0:e.updateIntervalMs)!=null?y:this._streamingUpdateIntervalMs,i=this._fallbackStreamingPlaceholderText,o=i===null?null:await this.adapter.postMessage(this.id,i),a=this.id,s=new lh,l="",u=!1,c=null,h=null;o&&(a=o.threadId||this.id,l=i!=null?i:"");let d=()=>{h=setTimeout(()=>{c=f()},n)},f=async()=>{var w;if(u||!o)return;let _=s.render();if(_.trim()&&_!==l)try{await this.adapter.editMessage(a,o.id,{markdown:_}),l=_}catch(D){(w=this._logger)==null||w.warn("fallbackStream edit failed",D)}u||d()};o&&d();try{for await(let _ of r)if(s.push(_),!o){let w=s.render();w.trim()&&(o=await this.adapter.postMessage(this.id,{markdown:w}),a=o.threadId||this.id,l=w,d())}}finally{u=!0,h&&(clearTimeout(h),h=null)}c&&await c;let g=s.getText(),S=s.finish();o||(o=await this.adapter.postMessage(this.id,{markdown:g.trim()?g:" "}),a=o.threadId||this.id,l=g),S.trim()&&S!==l&&await this.adapter.editMessage(a,o.id,{markdown:g});let E=this.createSentMessage(o.id,{markdown:g},a);return this._threadHistory&&await this._threadHistory.append(this.id,new Ut(E)),E}async refresh(){let r=await this.adapter.fetchMessages(this.id,{limit:50});r.messages.length>0?this._recentMessages=r.messages:this._threadHistory?this._recentMessages=await this._threadHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(r){return`<@${r}>`}toJSON(){var r,e;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(r=this._currentMessage)==null?void 0:r.toJSON(),isDM:this.isDM,adapterName:(e=this._adapterName)!=null?e:this.adapter.name}}static fromJSON(r,e){let n=new Nn({id:r.id,adapterName:r.adapterName,channelId:r.channelId,channelVisibility:r.channelVisibility,currentMessage:r.currentMessage?Ut.fromJSON(r.currentMessage):void 0,isDM:r.isDM});return e&&(n._adapter=e),n}static[Qt](r){return r.toJSON()}static[Kt](r){return Nn.fromJSON(r)}createSentMessage(r,e,n){let i=this.adapter,o=n||this.id,a=this,{plainText:s,formatted:l,attachments:u}=ph(e);return{id:r,threadId:o,text:s,formatted:l,raw:null,links:[],author:{userId:"self",userName:i.userName,fullName:i.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:u,toJSON(){return new Ut(this).toJSON()},async edit(h){let d=h;if(dt(h)){let f=ft(h);if(!f)throw new Error("Invalid JSX element: must be a Card element");d=f}return d=await a.processCallbackUrls(d),await i.editMessage(o,r,d),a.createSentMessage(r,d)},async delete(){await i.deleteMessage(o,r)},async addReaction(h){await i.addReaction(o,r,h)},async removeReaction(h){await i.removeReaction(o,r,h)}}}createSentMessageFromMessage(r){let e=this.adapter,n=this.id,i=r.id,o=this;return{id:r.id,threadId:r.threadId,text:r.text,formatted:r.formatted,raw:r.raw,author:r.author,metadata:r.metadata,attachments:r.attachments,links:r.links,isMention:r.isMention,toJSON(){return r.toJSON()},async edit(a){let s=a;if(dt(a)){let l=ft(a);if(!l)throw new Error("Invalid JSX element: must be a Card element");s=l}return s=await o.processCallbackUrls(s),await e.editMessage(n,i,s),o.createSentMessage(i,s,n)},async delete(){await e.deleteMessage(n,i)},async addReaction(a){await e.addReaction(n,i,a)},async removeReaction(a){await e.removeReaction(n,i,a)}}}};function ph(t){if(typeof t=="string")return{plainText:t,formatted:St([wt([xt(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:St([wt([xt(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let r=In(t.markdown);return{plainText:he(r),formatted:r,attachments:t.attachments||[]}}if("ast"in t)return{plainText:he(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let r=t.fallbackText||fe(t.card);return{plainText:r,formatted:St([wt([xt(r)])]),attachments:[]}}if("type"in t&&t.type==="card"){let r=fe(t);return{plainText:r,formatted:St([wt([xt(r)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var By=10080*60*1e3;var Uy=300*1e3,Hy=1440*60*1e3;var Ha=new Map;function Xt(t){let r=Ha.get(t);return r||(r=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),Ha.set(t,r)),r}var mh={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},gh=class{constructor(t){L(this,"emojiMap");L(this,"slackToNormalized");L(this,"gchatToNormalized");this.emojiMap={...mh,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,r]of Object.entries(this.emojiMap)){let e=Array.isArray(r.slack)?r.slack:[r.slack];for(let i of e)this.slackToNormalized.set(i.toLowerCase(),t);let n=Array.isArray(r.gchat)?r.gchat:[r.gchat];for(let i of n)this.gchatToNormalized.set(i,t)}}fromSlack(t){var n;let r=t.replace(/^:|:$/g,"").toLowerCase(),e=(n=this.slackToNormalized.get(r))!=null?n:t;return Xt(e)}fromGChat(t){var e;let r=(e=this.gchatToNormalized.get(t))!=null?e:t;return Xt(r)}fromTeams(t){var n;let e=(n={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?n:t;return Xt(e)}toSlack(t){let r=typeof t=="string"?t:t.name,e=this.emojiMap[r];return e?Array.isArray(e.slack)?e.slack[0]:e.slack:r}toGChat(t){let r=typeof t=="string"?t:t.name,e=this.emojiMap[r];return e?Array.isArray(e.gchat)?e.gchat[0]:e.gchat:r}toDiscord(t){return this.toGChat(t)}matches(t,r){let e=typeof r=="string"?r:r.name,n=this.emojiMap[e];if(!n)return t===e;let i=Array.isArray(n.slack)?n.slack:[n.slack],o=Array.isArray(n.gchat)?n.gchat:[n.gchat],a=t.replace(/^:|:$/g,"").toLowerCase();return i.some(s=>s.toLowerCase()===a)||o.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},bh=new gh;function kh(t){let r=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],e={custom:n=>Xt(n)};for(let n of r)e[n]=Xt(n);if(t){for(let n of Object.keys(t))e[n]=Xt(n);bh.extend(t)}return e}var $y=kh(),Qa=Be,Ka=Ue,Xa=Tn;var Ya=He,Za=xa,to=qe;var eo=je,ro=Ve,no=$e;0&&(module.exports={Actions,Button,Card,CardLink,CardText,Divider,Select,SelectOption,TextInput});
|
|
57
|
+
`),s}function fh(t){return"adapterName"in t&&!("adapter"in t)}var Ua="thread-state:";function dh(t){return t!==null&&typeof t=="object"&&Symbol.asyncIterator in t}var qy=class Nn{constructor(r){L(this,"id");L(this,"channelId");L(this,"isDM");L(this,"channelVisibility");L(this,"_adapter");L(this,"_adapterName");L(this,"_stateAdapterInstance");L(this,"_recentMessages",[]);L(this,"_isSubscribedContext");L(this,"_currentMessage");L(this,"_streamingUpdateIntervalMs");L(this,"_fallbackStreamingPlaceholderText");L(this,"_channel");L(this,"_threadHistory");L(this,"_logger");var e,n,i,o;this.id=r.id,this.channelId=r.channelId,this.isDM=(e=r.isDM)!=null?e:!1,this.channelVisibility=(n=r.channelVisibility)!=null?n:"unknown",this._isSubscribedContext=(i=r.isSubscribedContext)!=null?i:!1,this._currentMessage=r.currentMessage,this._logger=r.logger,this._streamingUpdateIntervalMs=(o=r.streamingUpdateIntervalMs)!=null?o:500,this._fallbackStreamingPlaceholderText=r.fallbackStreamingPlaceholderText!==void 0?r.fallbackStreamingPlaceholderText:"...",fh(r)?this._adapterName=r.adapterName:(this._adapter=r.adapter,this._stateAdapterInstance=r.stateAdapter,this._threadHistory=r.threadHistory),r.initialMessage&&(this._recentMessages=[r.initialMessage])}get adapter(){if(this._adapter)return this._adapter;if(!this._adapterName)throw new Error("Thread has no adapter configured");let e=Je().getAdapter(this._adapterName);if(!e)throw new Error(`Adapter "${this._adapterName}" not found in Chat singleton`);return this._adapter=e,e}get _stateAdapter(){if(this._stateAdapterInstance)return this._stateAdapterInstance;let r=Je();return this._stateAdapterInstance=r.getState(),this._stateAdapterInstance}get recentMessages(){return this._recentMessages}set recentMessages(r){this._recentMessages=r}get state(){return this._stateAdapter.get(`${Ua}${this.id}`)}async setState(r,e){let n=`${Ua}${this.id}`;if(e!=null&&e.replace)await this._stateAdapter.set(n,r,Qe);else{let o={...await this._stateAdapter.get(n),...r};await this._stateAdapter.set(n,o,Qe)}}get channel(){if(!this._channel){let r=oh(this.adapter,this.id);this._channel=new ah({id:r,adapter:this.adapter,stateAdapter:this._stateAdapter,isDM:this.isDM,channelVisibility:this.channelVisibility,threadHistory:this._threadHistory})}return this._channel}get messages(){let r=this.adapter,e=this.id,n=this._threadHistory;return{async*[Symbol.asyncIterator](){let i,o=!1;for(;;){let a=await r.fetchMessages(e,{cursor:i,direction:"backward"}),s=[...a.messages].reverse();for(let l of s)o=!0,yield l;if(!a.nextCursor||a.messages.length===0)break;i=a.nextCursor}if(!o&&n){let a=await n.getMessages(e);for(let s=a.length-1;s>=0;s--)yield a[s]}}}}get allMessages(){let r=this.adapter,e=this.id,n=this._threadHistory;return{async*[Symbol.asyncIterator](){let i,o=!1;for(;;){let a=await r.fetchMessages(e,{limit:100,cursor:i,direction:"forward"});for(let s of a.messages)o=!0,yield s;if(!a.nextCursor||a.messages.length===0)break;i=a.nextCursor}if(!o&&n){let a=await n.getMessages(e);for(let s of a)yield s}}}}async getParticipants(){let r=new Map;this._currentMessage&&!this._currentMessage.author.isMe&&!this._currentMessage.author.isBot&&r.set(this._currentMessage.author.userId,this._currentMessage.author);for await(let e of this.allMessages)e.author.isMe||e.author.isBot||r.has(e.author.userId)||r.set(e.author.userId,e.author);return[...r.values()]}async isSubscribed(){return this._isSubscribedContext?!0:this._stateAdapter.isSubscribed(this.id)}async subscribe(){await this._stateAdapter.subscribe(this.id),this.adapter.onThreadSubscribe&&await this.adapter.onThreadSubscribe(this.id)}async unsubscribe(){await this._stateAdapter.unsubscribe(this.id)}async post(r){if(Wa(r)){if(r.kind==="stream"){let o=r.getPostData(),a={...o.options.updateIntervalMs?{updateIntervalMs:o.options.updateIntervalMs}:{},...o.options.groupTasks?{taskDisplayMode:o.options.groupTasks}:{},...o.options.endWith?{stopBlocks:o.options.endWith}:{}};return await this.handleStream(o.stream,a),r}return await this.handlePostableObject(r),r}if(dh(r))return this.handleStream(r);let e=r;if(dt(r)){let o=ft(r);if(!o)throw new Error("Invalid JSX element: must be a Card element");e=o}e=await this.processCallbackUrls(e);let n=await this.adapter.postMessage(this.id,e),i=this.createSentMessage(n.id,e,n.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new Ut(i)),i}async handlePostableObject(r){await Ga(r,this.adapter,this.id,(e,n)=>this.adapter.postMessage(e,n),this._logger)}async postEphemeral(r,e,n){let{fallbackToDM:i}=n,o=typeof r=="string"?r:r.userId,a;if(dt(e)){let s=ft(e);if(!s)throw new Error("Invalid JSX element: must be a Card element");a=s}else a=e;if(a=await this.processCallbackUrls(a),this.adapter.postEphemeral)return this.adapter.postEphemeral(this.id,o,a);if(!i)return null;if(this.adapter.openDM){let s=await this.adapter.openDM(o),l=await this.adapter.postMessage(s,a);return{id:l.id,threadId:s,usedFallback:!0,raw:l.raw}}return null}async processCallbackUrls(r){var e;if(typeof r=="string")return r;if("type"in r&&r.type==="card")return Ge(r,this._stateAdapter);if("card"in r&&((e=r.card)==null?void 0:e.type)==="card"){let n=await Ge(r.card,this._stateAdapter);if(n!==r.card)return{...r,card:n}}return r}async schedule(r,e){let n;if(dt(r)){let i=ft(r);if(!i)throw new Error("Invalid JSX element: must be a Card element");n=i}else n=r;if(n=await this.processCallbackUrls(n),!this.adapter.scheduleMessage)throw new Ja("Scheduled messages are not supported by this adapter","scheduling");return this.adapter.scheduleMessage(this.id,n,e)}async handleStream(r,e){let n=Va(r),i={updateIntervalMs:this._streamingUpdateIntervalMs,...e};if(this._currentMessage&&(i.recipientUserId=this._currentMessage.author.userId,i.recipientTeamId=this.extractSlackRecipientTeamId(this._currentMessage.raw)),this.adapter.stream){let a="",s={[Symbol.asyncIterator]:()=>{let u=n[Symbol.asyncIterator]();return{async next(){let c=await u.next();if(!c.done){let h=c.value;typeof h=="string"?a+=h:h.type==="markdown_text"&&(a+=h.text)}return c}}}},l=await this.adapter.stream(this.id,s,i);if(l){let u=this.createSentMessage(l.id,{markdown:a},l.threadId);return this._threadHistory&&await this._threadHistory.append(this.id,new Ut(u)),u}}let o={[Symbol.asyncIterator]:()=>{let a=n[Symbol.asyncIterator]();return{async next(){for(;;){let s=await a.next();if(s.done)return{value:void 0,done:!0};let l=s.value;if(typeof l=="string")return{value:l,done:!1};if(l.type==="markdown_text")return{value:l.text,done:!1}}}}}};return this.fallbackStream(o,i)}extractSlackRecipientTeamId(r){var n;if(!r||typeof r!="object")return;let e=r;if(typeof e.team_id=="string"&&e.team_id)return e.team_id;if(typeof e.team=="string"&&e.team)return e.team;if(e.team&&typeof e.team=="object"&&typeof e.team.id=="string"&&e.team.id)return e.team.id;if(typeof((n=e.user)==null?void 0:n.team_id)=="string"&&e.user.team_id)return e.user.team_id}async startTyping(r){await this.adapter.startTyping(this.id,r)}async fallbackStream(r,e){var y;let n=(y=e==null?void 0:e.updateIntervalMs)!=null?y:this._streamingUpdateIntervalMs,i=this._fallbackStreamingPlaceholderText,o=i===null?null:await this.adapter.postMessage(this.id,i),a=this.id,s=new lh,l="",u=!1,c=null,h=null;o&&(a=o.threadId||this.id,l=i!=null?i:"");let d=()=>{h=setTimeout(()=>{c=f()},n)},f=async()=>{var w;if(u||!o)return;let _=s.render();if(_.trim()&&_!==l)try{await this.adapter.editMessage(a,o.id,{markdown:_}),l=_}catch(D){(w=this._logger)==null||w.warn("fallbackStream edit failed",D)}u||d()};o&&d();try{for await(let _ of r)if(s.push(_),!o){let w=s.render();w.trim()&&(o=await this.adapter.postMessage(this.id,{markdown:w}),a=o.threadId||this.id,l=w,d())}}finally{u=!0,h&&(clearTimeout(h),h=null)}c&&await c;let g=s.getText(),S=s.finish();o||(o=await this.adapter.postMessage(this.id,{markdown:g.trim()?g:" "}),a=o.threadId||this.id,l=g),S.trim()&&S!==l&&await this.adapter.editMessage(a,o.id,{markdown:g});let E=this.createSentMessage(o.id,{markdown:g},a);return this._threadHistory&&await this._threadHistory.append(this.id,new Ut(E)),E}async refresh(){let r=await this.adapter.fetchMessages(this.id,{limit:50});r.messages.length>0?this._recentMessages=r.messages:this._threadHistory?this._recentMessages=await this._threadHistory.getMessages(this.id,50):this._recentMessages=[]}mentionUser(r){return`<@${r}>`}toJSON(){var r,e;return{_type:"chat:Thread",id:this.id,channelId:this.channelId,channelVisibility:this.channelVisibility,currentMessage:(r=this._currentMessage)==null?void 0:r.toJSON(),isDM:this.isDM,adapterName:(e=this._adapterName)!=null?e:this.adapter.name}}static fromJSON(r,e){let n=new Nn({id:r.id,adapterName:r.adapterName,channelId:r.channelId,channelVisibility:r.channelVisibility,currentMessage:r.currentMessage?Ut.fromJSON(r.currentMessage):void 0,isDM:r.isDM});return e&&(n._adapter=e),n}static[Qt](r){return r.toJSON()}static[Kt](r){return Nn.fromJSON(r)}createSentMessage(r,e,n){let i=this.adapter,o=n||this.id,a=this,{plainText:s,formatted:l,attachments:u}=ph(e);return{id:r,threadId:o,text:s,formatted:l,raw:null,links:[],author:{userId:"self",userName:i.userName,fullName:i.userName,isBot:!0,isMe:!0},metadata:{dateSent:new Date,edited:!1},attachments:u,toJSON(){return new Ut(this).toJSON()},async edit(h){let d=h;if(dt(h)){let f=ft(h);if(!f)throw new Error("Invalid JSX element: must be a Card element");d=f}return d=await a.processCallbackUrls(d),await i.editMessage(o,r,d),a.createSentMessage(r,d)},async delete(){await i.deleteMessage(o,r)},async addReaction(h){await i.addReaction(o,r,h)},async removeReaction(h){await i.removeReaction(o,r,h)}}}createSentMessageFromMessage(r){let e=this.adapter,n=this.id,i=r.id,o=this;return{id:r.id,threadId:r.threadId,text:r.text,formatted:r.formatted,raw:r.raw,author:r.author,metadata:r.metadata,attachments:r.attachments,links:r.links,isMention:r.isMention,toJSON(){return r.toJSON()},async edit(a){let s=a;if(dt(a)){let l=ft(a);if(!l)throw new Error("Invalid JSX element: must be a Card element");s=l}return s=await o.processCallbackUrls(s),await e.editMessage(n,i,s),o.createSentMessage(i,s,n)},async delete(){await e.deleteMessage(n,i)},async addReaction(a){await e.addReaction(n,i,a)},async removeReaction(a){await e.removeReaction(n,i,a)}}}};function ph(t){if(typeof t=="string")return{plainText:t,formatted:St([wt([xt(t)])]),attachments:[]};if("raw"in t)return{plainText:t.raw,formatted:St([wt([xt(t.raw)])]),attachments:t.attachments||[]};if("markdown"in t){let r=In(t.markdown);return{plainText:he(r),formatted:r,attachments:t.attachments||[]}}if("ast"in t)return{plainText:he(t.ast),formatted:t.ast,attachments:t.attachments||[]};if("card"in t){let r=t.fallbackText||fe(t.card);return{plainText:r,formatted:St([wt([xt(r)])]),attachments:[]}}if("type"in t&&t.type==="card"){let r=fe(t);return{plainText:r,formatted:St([wt([xt(r)])]),attachments:[]}}throw new Error("Invalid PostableMessage format")}var By=10080*60*1e3;var Uy=600*1e3,Hy=1440*60*1e3;var Ha=new Map;function Xt(t){let r=Ha.get(t);return r||(r=Object.freeze({name:t,toString:()=>`{{emoji:${t}}}`,toJSON:()=>`{{emoji:${t}}}`}),Ha.set(t,r)),r}var mh={thumbs_up:{slack:["+1","thumbsup"],gchat:"\u{1F44D}"},thumbs_down:{slack:["-1","thumbsdown"],gchat:"\u{1F44E}"},clap:{slack:"clap",gchat:"\u{1F44F}"},wave:{slack:"wave",gchat:"\u{1F44B}"},pray:{slack:"pray",gchat:"\u{1F64F}"},muscle:{slack:"muscle",gchat:"\u{1F4AA}"},ok_hand:{slack:"ok_hand",gchat:"\u{1F44C}"},point_up:{slack:"point_up",gchat:"\u{1F446}"},point_down:{slack:"point_down",gchat:"\u{1F447}"},point_left:{slack:"point_left",gchat:"\u{1F448}"},point_right:{slack:"point_right",gchat:"\u{1F449}"},raised_hands:{slack:"raised_hands",gchat:"\u{1F64C}"},shrug:{slack:"shrug",gchat:"\u{1F937}"},facepalm:{slack:"facepalm",gchat:"\u{1F926}"},heart:{slack:"heart",gchat:["\u2764\uFE0F","\u2764"]},smile:{slack:["smile","slightly_smiling_face"],gchat:"\u{1F60A}"},laugh:{slack:["laughing","satisfied","joy"],gchat:["\u{1F602}","\u{1F606}"]},thinking:{slack:"thinking_face",gchat:"\u{1F914}"},sad:{slack:["cry","sad","white_frowning_face"],gchat:"\u{1F622}"},cry:{slack:"sob",gchat:"\u{1F62D}"},angry:{slack:"angry",gchat:"\u{1F620}"},love_eyes:{slack:"heart_eyes",gchat:"\u{1F60D}"},cool:{slack:"sunglasses",gchat:"\u{1F60E}"},wink:{slack:"wink",gchat:"\u{1F609}"},surprised:{slack:"open_mouth",gchat:"\u{1F62E}"},worried:{slack:"worried",gchat:"\u{1F61F}"},confused:{slack:"confused",gchat:"\u{1F615}"},neutral:{slack:"neutral_face",gchat:"\u{1F610}"},sleeping:{slack:"sleeping",gchat:"\u{1F634}"},sick:{slack:"nauseated_face",gchat:"\u{1F922}"},mind_blown:{slack:"exploding_head",gchat:"\u{1F92F}"},relieved:{slack:"relieved",gchat:"\u{1F60C}"},grimace:{slack:"grimacing",gchat:"\u{1F62C}"},rolling_eyes:{slack:"rolling_eyes",gchat:"\u{1F644}"},hug:{slack:"hugging_face",gchat:"\u{1F917}"},zany:{slack:"zany_face",gchat:"\u{1F92A}"},check:{slack:["white_check_mark","heavy_check_mark"],gchat:["\u2705","\u2714\uFE0F"]},x:{slack:["x","heavy_multiplication_x"],gchat:["\u274C","\u2716\uFE0F"]},question:{slack:"question",gchat:["\u2753","?"]},exclamation:{slack:"exclamation",gchat:"\u2757"},warning:{slack:"warning",gchat:"\u26A0\uFE0F"},stop:{slack:"octagonal_sign",gchat:"\u{1F6D1}"},info:{slack:"information_source",gchat:"\u2139\uFE0F"},100:{slack:"100",gchat:"\u{1F4AF}"},fire:{slack:"fire",gchat:"\u{1F525}"},star:{slack:"star",gchat:"\u2B50"},sparkles:{slack:"sparkles",gchat:"\u2728"},lightning:{slack:"zap",gchat:"\u26A1"},boom:{slack:"boom",gchat:"\u{1F4A5}"},eyes:{slack:"eyes",gchat:"\u{1F440}"},green_circle:{slack:"large_green_circle",gchat:"\u{1F7E2}"},yellow_circle:{slack:"large_yellow_circle",gchat:"\u{1F7E1}"},red_circle:{slack:"red_circle",gchat:"\u{1F534}"},blue_circle:{slack:"large_blue_circle",gchat:"\u{1F535}"},white_circle:{slack:"white_circle",gchat:"\u26AA"},black_circle:{slack:"black_circle",gchat:"\u26AB"},rocket:{slack:"rocket",gchat:"\u{1F680}"},party:{slack:["tada","partying_face"],gchat:["\u{1F389}","\u{1F973}"]},confetti:{slack:"confetti_ball",gchat:"\u{1F38A}"},balloon:{slack:"balloon",gchat:"\u{1F388}"},gift:{slack:"gift",gchat:"\u{1F381}"},trophy:{slack:"trophy",gchat:"\u{1F3C6}"},medal:{slack:"first_place_medal",gchat:"\u{1F947}"},lightbulb:{slack:"bulb",gchat:"\u{1F4A1}"},gear:{slack:"gear",gchat:"\u2699\uFE0F"},wrench:{slack:"wrench",gchat:"\u{1F527}"},hammer:{slack:"hammer",gchat:"\u{1F528}"},bug:{slack:"bug",gchat:"\u{1F41B}"},link:{slack:"link",gchat:"\u{1F517}"},lock:{slack:"lock",gchat:"\u{1F512}"},unlock:{slack:"unlock",gchat:"\u{1F513}"},key:{slack:"key",gchat:"\u{1F511}"},pin:{slack:"pushpin",gchat:"\u{1F4CC}"},memo:{slack:"memo",gchat:"\u{1F4DD}"},clipboard:{slack:"clipboard",gchat:"\u{1F4CB}"},calendar:{slack:"calendar",gchat:"\u{1F4C5}"},clock:{slack:"clock1",gchat:"\u{1F550}"},hourglass:{slack:"hourglass",gchat:"\u23F3"},bell:{slack:"bell",gchat:"\u{1F514}"},megaphone:{slack:"mega",gchat:"\u{1F4E2}"},speech_bubble:{slack:"speech_balloon",gchat:"\u{1F4AC}"},email:{slack:"email",gchat:"\u{1F4E7}"},inbox:{slack:"inbox_tray",gchat:"\u{1F4E5}"},outbox:{slack:"outbox_tray",gchat:"\u{1F4E4}"},package:{slack:"package",gchat:"\u{1F4E6}"},folder:{slack:"file_folder",gchat:"\u{1F4C1}"},file:{slack:"page_facing_up",gchat:"\u{1F4C4}"},chart_up:{slack:"chart_with_upwards_trend",gchat:"\u{1F4C8}"},chart_down:{slack:"chart_with_downwards_trend",gchat:"\u{1F4C9}"},coffee:{slack:"coffee",gchat:"\u2615"},pizza:{slack:"pizza",gchat:"\u{1F355}"},beer:{slack:"beer",gchat:"\u{1F37A}"},arrow_up:{slack:"arrow_up",gchat:"\u2B06\uFE0F"},arrow_down:{slack:"arrow_down",gchat:"\u2B07\uFE0F"},arrow_left:{slack:"arrow_left",gchat:"\u2B05\uFE0F"},arrow_right:{slack:"arrow_right",gchat:"\u27A1\uFE0F"},refresh:{slack:"arrows_counterclockwise",gchat:"\u{1F504}"},sun:{slack:"sunny",gchat:"\u2600\uFE0F"},cloud:{slack:"cloud",gchat:"\u2601\uFE0F"},rain:{slack:"rain_cloud",gchat:"\u{1F327}\uFE0F"},snow:{slack:"snowflake",gchat:"\u2744\uFE0F"},rainbow:{slack:"rainbow",gchat:"\u{1F308}"}},gh=class{constructor(t){L(this,"emojiMap");L(this,"slackToNormalized");L(this,"gchatToNormalized");this.emojiMap={...mh,...t},this.slackToNormalized=new Map,this.gchatToNormalized=new Map,this.buildReverseMaps()}buildReverseMaps(){for(let[t,r]of Object.entries(this.emojiMap)){let e=Array.isArray(r.slack)?r.slack:[r.slack];for(let i of e)this.slackToNormalized.set(i.toLowerCase(),t);let n=Array.isArray(r.gchat)?r.gchat:[r.gchat];for(let i of n)this.gchatToNormalized.set(i,t)}}fromSlack(t){var n;let r=t.replace(/^:|:$/g,"").toLowerCase(),e=(n=this.slackToNormalized.get(r))!=null?n:t;return Xt(e)}fromGChat(t){var e;let r=(e=this.gchatToNormalized.get(t))!=null?e:t;return Xt(r)}fromTeams(t){var n;let e=(n={like:"thumbs_up",heart:"heart",laugh:"laugh",surprised:"surprised",sad:"sad",angry:"angry"}[t])!=null?n:t;return Xt(e)}toSlack(t){let r=typeof t=="string"?t:t.name,e=this.emojiMap[r];return e?Array.isArray(e.slack)?e.slack[0]:e.slack:r}toGChat(t){let r=typeof t=="string"?t:t.name,e=this.emojiMap[r];return e?Array.isArray(e.gchat)?e.gchat[0]:e.gchat:r}toDiscord(t){return this.toGChat(t)}matches(t,r){let e=typeof r=="string"?r:r.name,n=this.emojiMap[e];if(!n)return t===e;let i=Array.isArray(n.slack)?n.slack:[n.slack],o=Array.isArray(n.gchat)?n.gchat:[n.gchat],a=t.replace(/^:|:$/g,"").toLowerCase();return i.some(s=>s.toLowerCase()===a)||o.includes(t)}extend(t){Object.assign(this.emojiMap,t),this.buildReverseMaps()}},bh=new gh;function kh(t){let r=["thumbs_up","thumbs_down","clap","wave","pray","muscle","ok_hand","point_up","point_down","point_left","point_right","raised_hands","shrug","facepalm","heart","smile","laugh","thinking","sad","cry","angry","love_eyes","cool","wink","surprised","worried","confused","neutral","sleeping","sick","mind_blown","relieved","grimace","rolling_eyes","hug","zany","check","x","question","exclamation","warning","stop","info","100","fire","star","sparkles","lightning","boom","eyes","green_circle","yellow_circle","red_circle","blue_circle","white_circle","black_circle","rocket","party","confetti","balloon","gift","trophy","medal","lightbulb","gear","wrench","hammer","bug","link","lock","unlock","key","pin","memo","clipboard","calendar","clock","hourglass","bell","megaphone","speech_bubble","email","inbox","outbox","package","folder","file","chart_up","chart_down","coffee","pizza","beer","arrow_up","arrow_down","arrow_left","arrow_right","refresh","sun","cloud","rain","snow","rainbow"],e={custom:n=>Xt(n)};for(let n of r)e[n]=Xt(n);if(t){for(let n of Object.keys(t))e[n]=Xt(n);bh.extend(t)}return e}var $y=kh(),Qa=Be,Ka=Ue,Xa=Tn;var Ya=He,Za=xa,to=qe;var eo=je,ro=Ve,no=$e;0&&(module.exports={Actions,Button,Card,CardLink,CardText,Divider,Select,SelectOption,TextInput});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-
|
|
2
|
-
import { I as ITriggerPayload,
|
|
1
|
+
import { a as ContextPayload, b as Step, S as Subscriber, E as EnvironmentSystemVariables, C as ContextResolved, c as ChannelStepEnum, A as ActionStepEnum, W as WithPassthrough, d as StepOptions } from './subscriber.types-CyNKT0nZ.cjs';
|
|
2
|
+
import { I as ITriggerPayload, z as TriggerRecipientsPayload, B as ISubscriberPayload, C as TriggerEventStatusEnum, W as WorkflowPreferencesPartial } from './agent.types-B5VnP69G.cjs';
|
|
3
3
|
import { C as ConditionalPartial, P as PickRequiredKeys, a as Prettify, D as DeepPartial, A as Awaitable } from './util.types-DaFfsxgy.cjs';
|
|
4
4
|
import { S as Schema, J as JsonSchema } from './base.schema.types-BApIn9jr.cjs';
|
|
5
5
|
|
|
@@ -178,7 +178,8 @@ declare enum WorkflowChannelEnum {
|
|
|
178
178
|
PUSH = "push",
|
|
179
179
|
CHAT = "chat",
|
|
180
180
|
/** Differs from ChannelTypeEnum in capitalization / snake_case */
|
|
181
|
-
IN_APP = "inApp"
|
|
181
|
+
IN_APP = "inApp",
|
|
182
|
+
TOOL = "tool"
|
|
182
183
|
}
|
|
183
184
|
|
|
184
185
|
type EventPayload = ITriggerPayload;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-
|
|
1
|
+
import { k as AgentHandlers, A as Agent } from './agent.types-B5VnP69G.cjs';
|
|
2
|
+
import { L as Logger, C as ClientOptions, W as Workflow, H as HealthCheck, e as DiscoverOutput, i as Event, n as ExecuteOutput, d as CodeResult, j as EventTriggerParams, m as Execute, t as WorkflowOptions } from './health-check.types-CtWQ_YSy.cjs';
|
|
3
3
|
import { A as Awaitable } from './util.types-DaFfsxgy.cjs';
|
|
4
4
|
import 'chat';
|
|
5
5
|
import { S as Schema, a as FromSchema, F as FromSchemaUnvalidated } from './base.schema.types-BApIn9jr.cjs';
|
|
6
6
|
import './step-resolver.cjs';
|
|
7
|
-
import './subscriber.types-
|
|
7
|
+
import './subscriber.types-CyNKT0nZ.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Define a new conversational agent.
|