@finalai/final-agent-provider 0.11.0 → 0.12.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.
Files changed (44) hide show
  1. package/README.md +1 -8
  2. package/dist/modules/sandboxes/local.d.mts +2 -1
  3. package/dist/modules/sandboxes/local.mjs +64 -8
  4. package/dist/modules/sandboxes/local.mjs.map +2 -2
  5. package/package.json +5 -41
  6. package/dist/modules/authoring-final-channel.d.mts +0 -3
  7. package/dist/modules/authoring-final-channel.mjs +0 -10
  8. package/dist/modules/authoring-final-channel.mjs.map +0 -7
  9. package/dist/modules/channel-factories.d.mts +0 -40
  10. package/dist/modules/channel-factories.mjs +0 -212
  11. package/dist/modules/channel-factories.mjs.map +0 -7
  12. package/dist/modules/channels/content.d.mts +0 -6
  13. package/dist/modules/channels/content.mjs +0 -31
  14. package/dist/modules/channels/content.mjs.map +0 -7
  15. package/dist/modules/channels/delivery.d.mts +0 -54
  16. package/dist/modules/channels/delivery.mjs +0 -243
  17. package/dist/modules/channels/delivery.mjs.map +0 -7
  18. package/dist/modules/channels/direct-messaging.d.mts +0 -5
  19. package/dist/modules/channels/direct-messaging.mjs +0 -8
  20. package/dist/modules/channels/direct-messaging.mjs.map +0 -7
  21. package/dist/modules/channels/fake-platform.d.mts +0 -36
  22. package/dist/modules/channels/fake-platform.mjs +0 -168
  23. package/dist/modules/channels/fake-platform.mjs.map +0 -7
  24. package/dist/modules/channels/group-messaging.d.mts +0 -5
  25. package/dist/modules/channels/group-messaging.mjs +0 -8
  26. package/dist/modules/channels/group-messaging.mjs.map +0 -7
  27. package/dist/modules/channels/inbound.d.mts +0 -52
  28. package/dist/modules/channels/inbound.mjs +0 -42
  29. package/dist/modules/channels/inbound.mjs.map +0 -7
  30. package/dist/modules/channels/index.d.mts +0 -9
  31. package/dist/modules/channels/index.mjs +0 -10
  32. package/dist/modules/channels/index.mjs.map +0 -7
  33. package/dist/modules/channels/messaging-channel.d.mts +0 -7
  34. package/dist/modules/channels/messaging-channel.mjs +0 -99
  35. package/dist/modules/channels/messaging-channel.mjs.map +0 -7
  36. package/dist/modules/channels/projection.d.mts +0 -36
  37. package/dist/modules/channels/projection.mjs +0 -233
  38. package/dist/modules/channels/projection.mjs.map +0 -7
  39. package/dist/modules/channels/prompt.d.mts +0 -72
  40. package/dist/modules/channels/prompt.mjs +0 -208
  41. package/dist/modules/channels/prompt.mjs.map +0 -7
  42. package/dist/modules/channels/routing.d.mts +0 -5
  43. package/dist/modules/channels/routing.mjs +0 -53
  44. package/dist/modules/channels/routing.mjs.map +0 -7
@@ -1,212 +0,0 @@
1
- import {
2
- RoomPrincipalType,
3
- SemanticChannelEventKind,
4
- TurnPolicy,
5
- roomAuthSchema,
6
- channelMessageCompletedSchema,
7
- decisionCreatedDataSchema,
8
- decisionResolvedDataSchema,
9
- defineRoomSurface,
10
- jsonObjectSchema
11
- } from "@finalai/agent-provider";
12
- import * as z from "zod";
13
- import { contentBlocksOf } from "./channels/content.mjs";
14
- import { conversationEventInboundSchema, messageInboundSchema } from "./channels/inbound.mjs";
15
- import { createMessagingChannel } from "./channels/messaging-channel.mjs";
16
- import { RoomPrincipalType as RoomPrincipalType2 } from "@finalai/agent-provider";
17
- const admissionSchema = z.object({
18
- auth: roomAuthSchema.nullable(),
19
- context: z.array(z.string()).optional(),
20
- title: z.string().optional()
21
- });
22
- const optionsSchema = z.object({
23
- turnPolicy: z.nativeEnum(TurnPolicy).default(TurnPolicy.Steer),
24
- updateIntervalMs: z.number().finite().nonnegative().optional()
25
- });
26
- const defaultAuthOf = (author) => {
27
- if (author == null) return null;
28
- return {
29
- principalId: author.userId ?? author.definitionId ?? author.id,
30
- principalType: author.userId == null ? RoomPrincipalType.Service : RoomPrincipalType.User,
31
- authenticator: "final",
32
- displayName: author.displayName,
33
- attributes: { participant_id: author.id }
34
- };
35
- };
36
- const finalChannel = (inputOptions = {}) => {
37
- const options = {
38
- ...inputOptions,
39
- events: inputOptions.events == null ? void 0 : { ...inputOptions.events }
40
- };
41
- const callbacks = {
42
- onMessage: options.onMessage,
43
- onInputResponse: options.onInputResponse,
44
- renderer: options.renderer,
45
- route: options.route,
46
- ...options.events
47
- };
48
- for (const [name, callback] of Object.entries(callbacks))
49
- if (callback != null && !z.function().safeParse(callback).success)
50
- throw new Error(`Final channel ${name} must be a function`);
51
- const supportedEvents = /* @__PURE__ */ new Set([
52
- "message.delta",
53
- "message.completed",
54
- "turn.started",
55
- "turn.completed",
56
- "decision.created",
57
- "decision.resolved"
58
- ]);
59
- for (const kind of Object.keys(options.events ?? {}))
60
- if (!supportedEvents.has(kind)) throw new Error(`unsupported Final channel event: ${kind}`);
61
- const config = optionsSchema.parse(options);
62
- const base = createMessagingChannel({ ...config, route: options.route });
63
- const receive = async (input, ctx) => {
64
- if (conversationEventInboundSchema.safeParse(input).success) return base.receive(input, ctx);
65
- const parsed = messageInboundSchema.parse(input);
66
- const participants = ctx.participants ?? await ctx.platform.conversations.participants(parsed.conversationId);
67
- const author = participants.find(
68
- (participant) => participant.id === parsed.authorParticipantId
69
- );
70
- const message = ctx.message ?? await ctx.platform.conversations.postMessage({
71
- ...parsed,
72
- content: contentBlocksOf(parsed.content)
73
- });
74
- if (ctx.definitionId == null) throw new Error("Final channel has no agent definition");
75
- const messageContext = {
76
- ...ctx,
77
- defaultAuth: defaultAuthOf(author)
78
- };
79
- const accepted = options.onMessage == null ? { auth: messageContext.defaultAuth } : await options.onMessage(messageContext, message);
80
- const admission = accepted == null ? null : admissionSchema.parse(accepted);
81
- if (admission == null) return { conversationId: parsed.conversationId };
82
- const context = admission.context ?? [];
83
- const injected = context.map((text) => ({ type: "text", text }));
84
- return base.receive(
85
- {
86
- ...parsed,
87
- content: [...context.map((text) => ({ type: "text", text })), ...parsed.content]
88
- },
89
- {
90
- ...ctx,
91
- platform: {
92
- ...ctx.platform,
93
- sessions: {
94
- ...ctx.platform.sessions,
95
- prompt: (args) => ctx.platform.sessions.prompt({
96
- ...args,
97
- auth: admission.auth,
98
- title: admission.title
99
- })
100
- }
101
- },
102
- message: { ...message, content: [...injected, ...message.content] }
103
- }
104
- );
105
- };
106
- const channelContext = (ctx) => {
107
- const { conversation, agentParticipant } = ctx;
108
- if (conversation == null || agentParticipant == null || agentParticipant.definitionId == null)
109
- throw new Error("Final platform context requires a Final conversation");
110
- return {
111
- final: {
112
- post: async (message) => {
113
- if (ctx.platform.conversations.dispatchMessage == null)
114
- throw new Error("channel dispatch is unavailable");
115
- const posted = await ctx.platform.conversations.postMessage({
116
- conversationId: conversation.conversationId,
117
- authorParticipantId: agentParticipant.id,
118
- content: contentBlocksOf(message.content),
119
- clientMessageId: `channel:${ctx.turn.id}:${message.id}`,
120
- originTurnId: ctx.turn.id
121
- });
122
- await ctx.platform.conversations.dispatchMessage({
123
- conversationId: posted.conversationId,
124
- messageId: posted.messageId
125
- });
126
- return posted;
127
- }
128
- }
129
- };
130
- };
131
- const sessionContext = (ctx) => ({
132
- sessionId: ctx.sessionId ?? null,
133
- turnId: ctx.turn.id,
134
- state: ctx.state
135
- });
136
- const wrap = (schema, handler) => handler == null ? void 0 : async (event, ctx) => handler(schema.parse(event.data), channelContext(ctx), sessionContext(ctx));
137
- const authoredEvents = {
138
- [SemanticChannelEventKind.MessageCompleted]: wrap(
139
- channelMessageCompletedSchema,
140
- options.events?.["message.completed"]
141
- ),
142
- [SemanticChannelEventKind.MessageDelta]: wrap(
143
- z.object({ messageId: z.string(), delta: jsonObjectSchema }),
144
- options.events?.["message.delta"]
145
- ),
146
- [SemanticChannelEventKind.TurnStarted]: wrap(
147
- z.object({ turnId: z.string() }),
148
- options.events?.["turn.started"]
149
- ),
150
- [SemanticChannelEventKind.TurnCompleted]: wrap(
151
- z.object({ turnId: z.string(), stopReason: z.string().nullable() }),
152
- options.events?.["turn.completed"]
153
- ),
154
- "decision.created": wrap(decisionCreatedDataSchema, options.events?.["decision.created"]),
155
- "decision.resolved": wrap(decisionResolvedDataSchema, options.events?.["decision.resolved"])
156
- };
157
- const events = { ...base.events };
158
- for (const [kind, handler] of Object.entries(authoredEvents))
159
- if (handler != null) events[kind] = handler;
160
- return Object.freeze(
161
- defineRoomSurface({
162
- ...base,
163
- config: jsonObjectSchema.parse(config),
164
- configure: (next) => finalChannel({ ...options, ...optionsSchema.parse({ ...config, ...next }) }),
165
- receive,
166
- respond: async (input, ctx) => {
167
- const conversation = z.string().min(1).parse(ctx.conversationId);
168
- const participants = await ctx.platform.conversations.participants(conversation);
169
- const author = participants.find(
170
- (participant) => participant.id === input.actorParticipantId
171
- );
172
- const defaultAuth = defaultAuthOf(author);
173
- let admission = { auth: defaultAuth };
174
- if (options.onInputResponse != null) {
175
- const accepted = await options.onInputResponse({ ...ctx, defaultAuth }, input);
176
- if (accepted == null) return { resolved: false };
177
- admission = admissionSchema.parse(accepted);
178
- }
179
- if (ctx.platform.sessions.respond == null)
180
- throw new Error("response submission is unavailable");
181
- return ctx.platform.sessions.respond({ ...input, auth: admission.auth });
182
- },
183
- cancel: async (ctx) => {
184
- if (ctx.agentParticipantId == null) return { accepted: false };
185
- const conversation = z.string().min(1).parse(ctx.conversationId);
186
- const participants = await ctx.platform.conversations.participants(conversation);
187
- const agent = participants.find((participant) => participant.id === ctx.agentParticipantId);
188
- if (agent?.sessionId == null) return { accepted: false };
189
- await ctx.platform.sessions.cancel({
190
- participantId: agent.id,
191
- reason: ctx.cancelReason,
192
- throughMessageSeq: ctx.cancelThroughMessageSeq
193
- });
194
- return { accepted: true };
195
- },
196
- project: async (update, ctx) => {
197
- const next = () => options.events?.["message.completed"] == null ? base.project(update, ctx) : Promise.resolve();
198
- if (options.renderer != null) {
199
- await options.renderer(update, channelContext(ctx), sessionContext(ctx), next);
200
- return;
201
- }
202
- await next();
203
- },
204
- events: Object.freeze(events)
205
- })
206
- );
207
- };
208
- export {
209
- RoomPrincipalType2 as RoomPrincipalType,
210
- finalChannel
211
- };
212
- //# sourceMappingURL=channel-factories.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../src/channel-factories.ts"],
4
- "sourcesContent": ["import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport {\n RoomPrincipalType,\n SemanticChannelEventKind,\n TurnPolicy,\n roomAuthSchema,\n channelMessageCompletedSchema,\n decisionCreatedDataSchema,\n decisionResolvedDataSchema,\n defineRoomSurface,\n jsonObjectSchema,\n type RoomAuthIface,\n type RoomSurfaceDefinitionIface,\n type RoomEventHandler,\n type RoomInputResponseIface,\n type ChannelMessageCompletedDataIface,\n type ChannelMessageDeltaDataIface,\n type RoomReceiveContextIface,\n type ChannelTurnEventDataIface,\n type ChannelTurnStateIface,\n type ConversationMessageIface,\n type DecisionCreatedDataIface,\n type DecisionResolvedDataIface,\n type JsonValue,\n type ProjectionContextIface,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { contentBlocksOf } from \"./channels/content.mjs\";\nimport { conversationEventInboundSchema, messageInboundSchema } from \"./channels/inbound.mjs\";\nimport { createMessagingChannel } from \"./channels/messaging-channel.mjs\";\n\nexport { RoomPrincipalType, type RoomAuthIface } from '@finalai/agent-provider';\n\nexport interface ChannelAdmissionIface {\n auth: RoomAuthIface | null;\n context?: string[];\n title?: string;\n}\n\nexport interface FinalMessageContextIface extends RoomReceiveContextIface {\n defaultAuth: RoomAuthIface | null;\n}\n\nexport interface FinalChannelContextIface {\n final: {\n post(message: ChannelMessageCompletedDataIface['message']): Promise<ConversationMessageIface>;\n };\n}\nexport interface FinalSessionContextIface {\n sessionId: string | null;\n turnId: string;\n state: ChannelTurnStateIface<JsonValue>;\n}\nexport type FinalChannelEventHandler<Data> = (\n data: Data,\n channel: FinalChannelContextIface,\n ctx: FinalSessionContextIface,\n) => void | Promise<void>;\nexport interface FinalChannelEventHandlersIface {\n 'message.delta'?: FinalChannelEventHandler<ChannelMessageDeltaDataIface>;\n 'message.completed'?: FinalChannelEventHandler<ChannelMessageCompletedDataIface>;\n 'turn.started'?: FinalChannelEventHandler<ChannelTurnEventDataIface>;\n 'turn.completed'?: FinalChannelEventHandler<ChannelTurnEventDataIface>;\n 'decision.created'?: FinalChannelEventHandler<DecisionCreatedDataIface>;\n 'decision.resolved'?: FinalChannelEventHandler<DecisionResolvedDataIface>;\n}\n\nexport interface FinalChannelOptionsIface {\n turnPolicy?: TurnPolicy | `${TurnPolicy}`;\n updateIntervalMs?: number;\n route?: RoomSurfaceDefinitionIface<JsonValue, JsonValue>['route'];\n onMessage?: (\n ctx: FinalMessageContextIface,\n message: ConversationMessageIface,\n ) => ChannelAdmissionIface | null | Promise<ChannelAdmissionIface | null>;\n onInputResponse?: (\n ctx: FinalMessageContextIface,\n response: RoomInputResponseIface,\n ) => ChannelAdmissionIface | null | Promise<ChannelAdmissionIface | null>;\n events?: FinalChannelEventHandlersIface;\n renderer?: (\n update: SessionUpdate,\n channel: FinalChannelContextIface,\n ctx: FinalSessionContextIface,\n next: () => Promise<void>,\n ) => void | Promise<void>;\n}\n\nconst admissionSchema = z.object({\n auth: roomAuthSchema.nullable(),\n context: z.array(z.string()).optional(),\n title: z.string().optional(),\n});\n\nconst optionsSchema = z.object({\n turnPolicy: z.nativeEnum(TurnPolicy).default(TurnPolicy.Steer),\n updateIntervalMs: z.number().finite().nonnegative().optional(),\n});\n\n// A room member as a principal: a person by user id, an agent by definition id.\nconst defaultAuthOf = (\n author: import('@finalai/agent-provider').ParticipantIface | undefined,\n): RoomAuthIface | null => {\n if (author == null) return null;\n return {\n principalId: author.userId ?? author.definitionId ?? author.id,\n principalType: author.userId == null ? RoomPrincipalType.Service : RoomPrincipalType.User,\n authenticator: 'final',\n displayName: author.displayName,\n attributes: { participant_id: author.id },\n };\n};\n\nexport const finalChannel = (\n inputOptions: FinalChannelOptionsIface = {},\n): RoomSurfaceDefinitionIface<JsonValue, JsonValue> => {\n const options = {\n ...inputOptions,\n events: inputOptions.events == null ? undefined : { ...inputOptions.events },\n };\n const callbacks = {\n onMessage: options.onMessage,\n onInputResponse: options.onInputResponse,\n renderer: options.renderer,\n route: options.route,\n ...options.events,\n };\n for (const [name, callback] of Object.entries(callbacks))\n if (callback != null && !z.function().safeParse(callback).success)\n throw new Error(`Final channel ${name} must be a function`);\n const supportedEvents = new Set([\n 'message.delta',\n 'message.completed',\n 'turn.started',\n 'turn.completed',\n 'decision.created',\n 'decision.resolved',\n ]);\n for (const kind of Object.keys(options.events ?? {}))\n if (!supportedEvents.has(kind)) throw new Error(`unsupported Final channel event: ${kind}`);\n const config = optionsSchema.parse(options);\n const base = createMessagingChannel({ ...config, route: options.route });\n const receive: typeof base.receive = async (input, ctx) => {\n if (conversationEventInboundSchema.safeParse(input).success) return base.receive(input, ctx);\n const parsed = messageInboundSchema.parse(input);\n const participants =\n ctx.participants ?? (await ctx.platform.conversations.participants(parsed.conversationId));\n const author = participants.find(\n (participant) => participant.id === parsed.authorParticipantId,\n );\n const message =\n ctx.message ??\n (await ctx.platform.conversations.postMessage({\n ...parsed,\n content: contentBlocksOf(parsed.content),\n }));\n if (ctx.definitionId == null) throw new Error('Final channel has no agent definition');\n const messageContext: FinalMessageContextIface = {\n ...ctx,\n defaultAuth: defaultAuthOf(author),\n };\n const accepted =\n options.onMessage == null\n ? { auth: messageContext.defaultAuth }\n : await options.onMessage(messageContext, message);\n const admission = accepted == null ? null : admissionSchema.parse(accepted);\n if (admission == null) return { conversationId: parsed.conversationId };\n const context = admission.context ?? [];\n const injected: ContentBlock[] = context.map((text) => ({ type: 'text', text }));\n return base.receive(\n {\n ...parsed,\n content: [...context.map((text) => ({ type: 'text', text })), ...parsed.content],\n },\n {\n ...ctx,\n platform: {\n ...ctx.platform,\n sessions: {\n ...ctx.platform.sessions,\n prompt: (args) =>\n ctx.platform.sessions.prompt({\n ...args,\n auth: admission.auth,\n title: admission.title,\n }),\n },\n },\n message: { ...message, content: [...injected, ...message.content] },\n },\n );\n };\n const channelContext = (ctx: ProjectionContextIface): FinalChannelContextIface => {\n const { conversation, agentParticipant } = ctx;\n if (conversation == null || agentParticipant == null || agentParticipant.definitionId == null)\n throw new Error('Final platform context requires a Final conversation');\n return {\n final: {\n post: async (message) => {\n if (ctx.platform.conversations.dispatchMessage == null)\n throw new Error('channel dispatch is unavailable');\n const posted = await ctx.platform.conversations.postMessage({\n conversationId: conversation.conversationId,\n authorParticipantId: agentParticipant.id,\n content: contentBlocksOf(message.content),\n clientMessageId: `channel:${ctx.turn.id}:${message.id}`,\n originTurnId: ctx.turn.id,\n });\n await ctx.platform.conversations.dispatchMessage({\n conversationId: posted.conversationId,\n messageId: posted.messageId,\n });\n return posted;\n },\n },\n };\n };\n const sessionContext = (ctx: ProjectionContextIface): FinalSessionContextIface => ({\n sessionId: ctx.sessionId ?? null,\n turnId: ctx.turn.id,\n state: ctx.state,\n });\n const wrap = <Data>(\n schema: z.ZodType<Data>,\n handler: FinalChannelEventHandler<Data> | undefined,\n ): RoomEventHandler | undefined =>\n handler == null\n ? undefined\n : async (event, ctx) =>\n handler(schema.parse(event.data), channelContext(ctx), sessionContext(ctx));\n const authoredEvents = {\n [SemanticChannelEventKind.MessageCompleted]: wrap(\n channelMessageCompletedSchema,\n options.events?.['message.completed'],\n ),\n [SemanticChannelEventKind.MessageDelta]: wrap(\n z.object({ messageId: z.string(), delta: jsonObjectSchema }),\n options.events?.['message.delta'],\n ),\n [SemanticChannelEventKind.TurnStarted]: wrap(\n z.object({ turnId: z.string() }),\n options.events?.['turn.started'],\n ),\n [SemanticChannelEventKind.TurnCompleted]: wrap(\n z.object({ turnId: z.string(), stopReason: z.string().nullable() }),\n options.events?.['turn.completed'],\n ),\n 'decision.created': wrap(decisionCreatedDataSchema, options.events?.['decision.created']),\n 'decision.resolved': wrap(decisionResolvedDataSchema, options.events?.['decision.resolved']),\n };\n const events = { ...base.events };\n for (const [kind, handler] of Object.entries(authoredEvents))\n if (handler != null) events[kind] = handler;\n return Object.freeze(\n defineRoomSurface({\n ...base,\n config: jsonObjectSchema.parse(config),\n configure: (next) =>\n finalChannel({ ...options, ...optionsSchema.parse({ ...config, ...next }) }),\n receive,\n respond: async (input, ctx) => {\n const conversation = z.string().min(1).parse(ctx.conversationId);\n const participants = await ctx.platform.conversations.participants(conversation);\n const author = participants.find(\n (participant) => participant.id === input.actorParticipantId,\n );\n const defaultAuth = defaultAuthOf(author);\n let admission: ChannelAdmissionIface = { auth: defaultAuth };\n if (options.onInputResponse != null) {\n const accepted = await options.onInputResponse({ ...ctx, defaultAuth }, input);\n if (accepted == null) return { resolved: false };\n admission = admissionSchema.parse(accepted);\n }\n if (ctx.platform.sessions.respond == null)\n throw new Error('response submission is unavailable');\n return ctx.platform.sessions.respond({ ...input, auth: admission.auth });\n },\n cancel: async (ctx) => {\n if (ctx.agentParticipantId == null) return { accepted: false };\n const conversation = z.string().min(1).parse(ctx.conversationId);\n const participants = await ctx.platform.conversations.participants(conversation);\n const agent = participants.find((participant) => participant.id === ctx.agentParticipantId);\n if (agent?.sessionId == null) return { accepted: false };\n await ctx.platform.sessions.cancel({\n participantId: agent.id,\n reason: ctx.cancelReason,\n throughMessageSeq: ctx.cancelThroughMessageSeq,\n });\n return { accepted: true };\n },\n project: async (update, ctx) => {\n const next = () =>\n options.events?.['message.completed'] == null\n ? base.project(update, ctx)\n : Promise.resolve();\n if (options.renderer != null) {\n await options.renderer(update, channelContext(ctx), sessionContext(ctx), next);\n return;\n }\n await next();\n },\n events: Object.freeze(events),\n }),\n );\n};\n"],
5
- "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAeK;AACP,YAAY,OAAO;AACnB,SAAS,uBAAuB;AAChC,SAAS,gCAAgC,4BAA4B;AACrE,SAAS,8BAA8B;AAEvC,SAAS,qBAAAA,0BAA6C;AAyDtD,MAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,MAAM,eAAe,SAAS;AAAA,EAC9B,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACtC,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;AAC9B,cAAM,OAAO,MACX,QAAQ,SAAS,mBAAmB,KAAK,OACrC,KAAK,QAAQ,QAAQ,GAAG,IACxB,QAAQ,QAAQ;AACtB,YAAI,QAAQ,YAAY,MAAM;AAC5B,gBAAM,QAAQ,SAAS,QAAQ,eAAe,GAAG,GAAG,eAAe,GAAG,GAAG,IAAI;AAC7E;AAAA,QACF;AACA,cAAM,KAAK;AAAA,MACb;AAAA,MACA,QAAQ,OAAO,OAAO,MAAM;AAAA,IAC9B,CAAC;AAAA,EACH;AACF;",
6
- "names": ["RoomPrincipalType"]
7
- }
@@ -1,6 +0,0 @@
1
- import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';
2
- import { type JsonObject, type JsonValue } from '@finalai/agent-provider';
3
- export declare const contentBlockOf: (value: JsonValue | undefined) => ContentBlock | null;
4
- export declare const contentBlocksOf: (value: JsonValue | undefined) => ContentBlock[];
5
- export declare const jsonOfContentBlock: (block: ContentBlock) => JsonObject;
6
- export declare const jsonOfContent: (content: ContentBlock[]) => JsonObject[];
@@ -1,31 +0,0 @@
1
- import { contentBlockSchemas, ContentBlockType } from "@finalai/acp-session";
2
- import { jsonObjectSchema } from "@finalai/agent-provider";
3
- const contentBlockOf = (value) => {
4
- if (value == null) {
5
- return null;
6
- }
7
- const text = contentBlockSchemas[ContentBlockType.Text].safeParse(value);
8
- if (text.success) return text.data;
9
- const image = contentBlockSchemas[ContentBlockType.Image].safeParse(value);
10
- if (image.success) return image.data;
11
- const audio = contentBlockSchemas[ContentBlockType.Audio].safeParse(value);
12
- if (audio.success) return audio.data;
13
- const link = contentBlockSchemas[ContentBlockType.ResourceLink].safeParse(value);
14
- if (link.success) return link.data;
15
- const resource = contentBlockSchemas[ContentBlockType.Resource].safeParse(value);
16
- if (resource.success) return resource.data;
17
- return null;
18
- };
19
- const contentBlocksOf = (value) => Array.isArray(value) ? value.flatMap((item) => contentBlockOf(item) ?? []) : [];
20
- const jsonOfContentBlock = (block) => {
21
- const parsed = jsonObjectSchema.safeParse(JSON.parse(JSON.stringify(block)));
22
- return parsed.success ? parsed.data : { type: "text", text: "" };
23
- };
24
- const jsonOfContent = (content) => content.map(jsonOfContentBlock);
25
- export {
26
- contentBlockOf,
27
- contentBlocksOf,
28
- jsonOfContent,
29
- jsonOfContentBlock
30
- };
31
- //# sourceMappingURL=content.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/channels/content.ts"],
4
- "sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport { contentBlockSchemas, ContentBlockType } from '@finalai/acp-session';\nimport { jsonObjectSchema, type JsonObject, type JsonValue } from '@finalai/agent-provider';\n\n// Content blocks cross JSON boundaries (Postgres jsonb, projection state, wire\n// bodies). Only the standard ACP block types survive the trip back; custom\n// `_`-prefixed blocks are dropped rather than trusted.\nexport const contentBlockOf = (value: JsonValue | undefined): ContentBlock | null => {\n if (value == null) {\n return null;\n }\n const text = contentBlockSchemas[ContentBlockType.Text].safeParse(value);\n if (text.success) return text.data;\n const image = contentBlockSchemas[ContentBlockType.Image].safeParse(value);\n if (image.success) return image.data;\n const audio = contentBlockSchemas[ContentBlockType.Audio].safeParse(value);\n if (audio.success) return audio.data;\n const link = contentBlockSchemas[ContentBlockType.ResourceLink].safeParse(value);\n if (link.success) return link.data;\n const resource = contentBlockSchemas[ContentBlockType.Resource].safeParse(value);\n if (resource.success) return resource.data;\n return null;\n};\n\nexport const contentBlocksOf = (value: JsonValue | undefined): ContentBlock[] =>\n Array.isArray(value) ? value.flatMap((item) => contentBlockOf(item) ?? []) : [];\n\nexport const jsonOfContentBlock = (block: ContentBlock): JsonObject => {\n const parsed = jsonObjectSchema.safeParse(JSON.parse(JSON.stringify(block)));\n return parsed.success ? parsed.data : { type: 'text', text: '' };\n};\n\nexport const jsonOfContent = (content: ContentBlock[]): JsonObject[] =>\n content.map(jsonOfContentBlock);\n"],
5
- "mappings": "AACA,SAAS,qBAAqB,wBAAwB;AACtD,SAAS,wBAAyD;AAK3D,MAAM,iBAAiB,CAAC,UAAsD;AACnF,MAAI,SAAS,MAAM;AACjB,WAAO;AAAA,EACT;AACA,QAAM,OAAO,oBAAoB,iBAAiB,IAAI,EAAE,UAAU,KAAK;AACvE,MAAI,KAAK,QAAS,QAAO,KAAK;AAC9B,QAAM,QAAQ,oBAAoB,iBAAiB,KAAK,EAAE,UAAU,KAAK;AACzE,MAAI,MAAM,QAAS,QAAO,MAAM;AAChC,QAAM,QAAQ,oBAAoB,iBAAiB,KAAK,EAAE,UAAU,KAAK;AACzE,MAAI,MAAM,QAAS,QAAO,MAAM;AAChC,QAAM,OAAO,oBAAoB,iBAAiB,YAAY,EAAE,UAAU,KAAK;AAC/E,MAAI,KAAK,QAAS,QAAO,KAAK;AAC9B,QAAM,WAAW,oBAAoB,iBAAiB,QAAQ,EAAE,UAAU,KAAK;AAC/E,MAAI,SAAS,QAAS,QAAO,SAAS;AACtC,SAAO;AACT;AAEO,MAAM,kBAAkB,CAAC,UAC9B,MAAM,QAAQ,KAAK,IAAI,MAAM,QAAQ,CAAC,SAAS,eAAe,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC;AAEzE,MAAM,qBAAqB,CAAC,UAAoC;AACrE,QAAM,SAAS,iBAAiB,UAAU,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;AAC3E,SAAO,OAAO,UAAU,OAAO,OAAO,EAAE,MAAM,QAAQ,MAAM,GAAG;AACjE;AAEO,MAAM,gBAAgB,CAAC,YAC5B,QAAQ,IAAI,kBAAkB;",
6
- "names": []
7
- }
@@ -1,54 +0,0 @@
1
- import { Delivery, TurnPolicy, type RoomPlatformIface, type ConversationIface, type ConversationMessageIface, type ParticipantIface, type RouteArgsIface, type RouteDecisionIface } from '@finalai/agent-provider';
2
- export declare const CONTEXT_WINDOW_MESSAGES = 50;
3
- export interface DeliveryOutcomeIface {
4
- participantId: string;
5
- delivery: Delivery;
6
- sent: 'prompt' | 'observe' | 'silent-prompt' | 'skipped' | 'failed';
7
- messageId: string | null;
8
- error: string | null;
9
- }
10
- export interface DeliverMessageArgsIface {
11
- platform: RoomPlatformIface;
12
- route: (args: RouteArgsIface) => RouteDecisionIface[] | Promise<RouteDecisionIface[]>;
13
- conversation: ConversationIface;
14
- message: ConversationMessageIface;
15
- participants?: ParticipantIface[];
16
- turnPolicy: TurnPolicy;
17
- }
18
- export declare const effectiveTurnPolicy: (args: {
19
- channel: TurnPolicy;
20
- conversation: TurnPolicy;
21
- }) => TurnPolicy;
22
- export declare const humanAudience: (participants: ParticipantIface[]) => string[];
23
- export declare const audienceFor: (author: ParticipantIface | null, participants: ParticipantIface[]) => string[];
24
- export declare const deliveryIdempotencyKey: (messageId: string, participantId: string) => string;
25
- export declare const deliverMessage: (args: DeliverMessageArgsIface) => Promise<DeliveryOutcomeIface[]>;
26
- export interface ObserveNoticeArgsIface {
27
- platform: RoomPlatformIface;
28
- recipients: ParticipantIface[];
29
- text: string;
30
- idempotencyKey: string;
31
- }
32
- export declare const observeNotice: (args: ObserveNoticeArgsIface) => Promise<string[]>;
33
- export interface ReactionNoticeArgsIface {
34
- platform: RoomPlatformIface;
35
- participants: ParticipantIface[];
36
- message: ConversationMessageIface;
37
- isLatestOfAuthor: boolean;
38
- reactorParticipantId: string;
39
- emoji: string;
40
- eventId?: string;
41
- }
42
- export declare const reactionNotice: (args: ReactionNoticeArgsIface) => Promise<string[]>;
43
- export declare enum MembershipChange {
44
- Joined = "joined",
45
- Left = "left"
46
- }
47
- export interface MembershipNoticeArgsIface {
48
- platform: RoomPlatformIface;
49
- participants: ParticipantIface[];
50
- subject: ParticipantIface;
51
- change: MembershipChange;
52
- idempotencyKey: string;
53
- }
54
- export declare const membershipNotice: (args: MembershipNoticeArgsIface) => Promise<string[]>;
@@ -1,243 +0,0 @@
1
- import {
2
- Delivery,
3
- ParticipantKind,
4
- RoutingMode,
5
- TurnPolicy
6
- } from "@finalai/agent-provider";
7
- import * as z from "zod";
8
- import {
9
- authorPrefixedContent,
10
- buildPromptContent,
11
- catchUpFor,
12
- excerpt,
13
- finalAuthorOf,
14
- finalContextOf,
15
- messageRefOf,
16
- messageSummary,
17
- renderReplyContext,
18
- systemNoticeBlock
19
- } from "./prompt.mjs";
20
- import { MAX_AGENT_HOP_DEPTH } from "./routing.mjs";
21
- const thrownMessageSchema = z.object({ message: z.string() });
22
- const CONTEXT_WINDOW_MESSAGES = 50;
23
- const effectiveTurnPolicy = (args) => args.conversation === TurnPolicy.Queue ? TurnPolicy.Queue : args.channel;
24
- const humanAudience = (participants) => participants.filter((participant) => !participant.left && participant.kind === ParticipantKind.User).map((participant) => participant.id);
25
- const audienceFor = (author, participants) => author?.kind === ParticipantKind.User ? [author.id] : humanAudience(participants);
26
- const replyContextFor = async (args) => {
27
- const byId = new Map(args.earlier.map((message) => [message.messageId, message]));
28
- const referenced = [
29
- args.message.replyToMessageId,
30
- args.message.threadRootId,
31
- ...args.message.quotedMessageIds
32
- ].flatMap((id) => id == null || byId.has(id) ? [] : [id]);
33
- if (referenced.length > 0) {
34
- const found = await args.platform.conversations.getMessages({
35
- conversationId: args.message.conversationId,
36
- messageIds: [...new Set(referenced)]
37
- });
38
- for (const message of found) byId.set(message.messageId, message);
39
- }
40
- const replyTo = args.message.replyToMessageId == null ? null : byId.get(args.message.replyToMessageId) ?? null;
41
- const root = args.message.threadRootId == null ? null : byId.get(args.message.threadRootId) ?? null;
42
- const rootAuthor = root == null ? null : args.participants.find((participant) => participant.id === root.authorParticipantId);
43
- return {
44
- replyTo: replyTo == null || replyTo.messageId === root?.messageId ? null : messageRefOf(replyTo, args.participants),
45
- thread: args.message.threadRootId == null ? null : {
46
- rootMessageId: args.message.threadRootId,
47
- rootExcerpt: root == null ? "" : excerpt(messageSummary(root.content)),
48
- rootAuthor: rootAuthor == null ? null : finalAuthorOf(rootAuthor)
49
- },
50
- quotes: args.message.quotedMessageIds.flatMap((id) => {
51
- const quoted = byId.get(id);
52
- return quoted == null ? [] : [messageRefOf(quoted, args.participants)];
53
- })
54
- };
55
- };
56
- const deliveryIdempotencyKey = (messageId, participantId) => `${messageId}:${participantId}`;
57
- const deliverMessage = async (args) => {
58
- const { platform, conversation, message } = args;
59
- const participants = args.participants ?? await platform.conversations.participants(conversation.conversationId);
60
- const decisions = await args.route({ conversation, message, participants });
61
- const author = participants.find((participant) => participant.id === message.authorParticipantId) ?? null;
62
- for (const participant of participants) {
63
- if (participant.kind !== ParticipantKind.Agent) continue;
64
- const decision = decisions.find((candidate) => candidate.participantId === participant.id);
65
- platform.log("channel route decision", {
66
- observed_at: (/* @__PURE__ */ new Date()).toISOString(),
67
- organization_id: conversation.organizationId,
68
- conversation_id: conversation.conversationId,
69
- conversation_kind: conversation.kind,
70
- message_id: message.messageId,
71
- author_kind: author?.kind ?? "",
72
- participant_id: participant.id,
73
- routing_mode: participant.routingMode ?? "",
74
- delivery: decision?.delivery ?? "skipped",
75
- reason: participant.left ? "left conversation" : participant.id === message.authorParticipantId ? "author" : decision == null ? "not selected by route" : "selected by route",
76
- hop_depth: message.hopDepth
77
- });
78
- }
79
- if (decisions.length === 0) return [];
80
- const earlier = await platform.conversations.recentMessages({
81
- conversationId: conversation.conversationId,
82
- limit: CONTEXT_WINDOW_MESSAGES,
83
- beforeSeq: message.seq
84
- });
85
- const replyContext = await replyContextFor({ platform, message, earlier, participants });
86
- const turnPolicy = effectiveTurnPolicy({
87
- channel: args.turnPolicy,
88
- conversation: conversation.turnPolicy
89
- });
90
- const audience = audienceFor(author, participants);
91
- const authorParticipant = author ?? {
92
- id: message.authorParticipantId,
93
- kind: ParticipantKind.User,
94
- displayName: "Someone",
95
- userId: null,
96
- definitionId: null,
97
- routingMode: null,
98
- sessionId: null,
99
- supportsObserve: null,
100
- rendersAuthorMeta: null,
101
- left: true
102
- };
103
- const deliverOne = async (decision) => {
104
- const recipient = participants.find((participant) => participant.id === decision.participantId);
105
- const base = { participantId: decision.participantId, delivery: decision.delivery };
106
- if (recipient == null) {
107
- return { ...base, sent: "skipped", messageId: null, error: null };
108
- }
109
- const idempotencyKey = deliveryIdempotencyKey(message.messageId, recipient.id);
110
- const prompt = async (content, replyExpected) => {
111
- const result = await platform.sessions.prompt({
112
- participantId: recipient.id,
113
- content,
114
- turnPolicy,
115
- replyExpected,
116
- idempotencyKey,
117
- authorParticipantId: message.authorParticipantId,
118
- audienceParticipantIds: audience,
119
- sourceMessageId: message.messageId
120
- });
121
- return result.messageId;
122
- };
123
- try {
124
- if (decision.delivery === Delivery.Prompt) {
125
- const content2 = buildPromptContent({
126
- message,
127
- author: authorParticipant,
128
- recipient,
129
- replyContext,
130
- catchUp: catchUpFor({ recipient, earlier, participants })
131
- });
132
- return { ...base, sent: "prompt", messageId: await prompt(content2, true), error: null };
133
- }
134
- if (recipient.sessionId == null) {
135
- return { ...base, sent: "skipped", messageId: null, error: null };
136
- }
137
- const contextBlock = renderReplyContext(replyContext);
138
- const content = [
139
- ...contextBlock == null ? [] : [contextBlock],
140
- ...authorPrefixedContent({
141
- content: message.content,
142
- author: finalAuthorOf(authorParticipant),
143
- rendersAuthorMeta: recipient.rendersAuthorMeta ?? false,
144
- context: finalContextOf(replyContext)
145
- })
146
- ];
147
- if (recipient.supportsObserve === false) {
148
- if (message.hopDepth >= MAX_AGENT_HOP_DEPTH) {
149
- return { ...base, sent: "skipped", messageId: null, error: null };
150
- }
151
- return {
152
- ...base,
153
- sent: "silent-prompt",
154
- messageId: await prompt(content, false),
155
- error: null
156
- };
157
- }
158
- await platform.sessions.observe({ participantId: recipient.id, content, idempotencyKey });
159
- return { ...base, sent: "observe", messageId: null, error: null };
160
- } catch (error) {
161
- const reason = error instanceof Error ? error.message : thrownMessageSchema.safeParse(error).data?.message ?? String(error);
162
- platform.log("channel delivery failed", {
163
- conversationId: conversation.conversationId,
164
- messageId: message.messageId,
165
- participantId: recipient.id,
166
- delivery: decision.delivery,
167
- error: reason
168
- });
169
- return { ...base, sent: "failed", messageId: null, error: reason };
170
- }
171
- };
172
- return Promise.all(decisions.map(deliverOne));
173
- };
174
- const observeNotice = async (args) => {
175
- const delivered = [];
176
- for (const recipient of args.recipients) {
177
- if (recipient.sessionId == null || recipient.supportsObserve === false || recipient.left)
178
- continue;
179
- try {
180
- await args.platform.sessions.observe({
181
- participantId: recipient.id,
182
- content: [systemNoticeBlock({ text: args.text })],
183
- idempotencyKey: `${args.idempotencyKey}:${recipient.id}`
184
- });
185
- delivered.push(recipient.id);
186
- } catch (error) {
187
- args.platform.log("channel notice failed", {
188
- participantId: recipient.id,
189
- error: error instanceof Error ? error.message : String(error)
190
- });
191
- }
192
- }
193
- return delivered;
194
- };
195
- const reactionNotice = async (args) => {
196
- const author = args.participants.find(
197
- (participant) => participant.id === args.message.authorParticipantId
198
- );
199
- const reactor = args.participants.find(
200
- (participant) => participant.id === args.reactorParticipantId
201
- );
202
- if (author == null || author.kind !== ParticipantKind.Agent || reactor == null || reactor.id === author.id) {
203
- return [];
204
- }
205
- const target = args.isLatestOfAuthor ? "your last message" : `your message "${excerpt(messageSummary(args.message.content), 120)}"`;
206
- const reactionId = `reaction:${args.message.messageId}:${reactor.id}:${args.emoji}`;
207
- return observeNotice({
208
- platform: args.platform,
209
- recipients: [author],
210
- text: `${reactor.displayName} reacted ${args.emoji} to ${target}`,
211
- idempotencyKey: args.eventId == null ? reactionId : `${reactionId}:${args.eventId}`
212
- });
213
- };
214
- var MembershipChange = /* @__PURE__ */ ((MembershipChange2) => {
215
- MembershipChange2["Joined"] = "joined";
216
- MembershipChange2["Left"] = "left";
217
- return MembershipChange2;
218
- })(MembershipChange || {});
219
- const membershipNotice = async (args) => {
220
- const recipients = args.participants.filter(
221
- (participant) => participant.kind === ParticipantKind.Agent && participant.id !== args.subject.id && (participant.routingMode === RoutingMode.All || participant.routingMode === RoutingMode.Default)
222
- );
223
- const verb = args.change === "joined" /* Joined */ ? "joined" : "left";
224
- return observeNotice({
225
- platform: args.platform,
226
- recipients,
227
- text: `${args.subject.displayName} ${verb} the conversation`,
228
- idempotencyKey: args.idempotencyKey
229
- });
230
- };
231
- export {
232
- CONTEXT_WINDOW_MESSAGES,
233
- MembershipChange,
234
- audienceFor,
235
- deliverMessage,
236
- deliveryIdempotencyKey,
237
- effectiveTurnPolicy,
238
- humanAudience,
239
- membershipNotice,
240
- observeNotice,
241
- reactionNotice
242
- };
243
- //# sourceMappingURL=delivery.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/channels/delivery.ts"],
4
- "sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport {\n Delivery,\n ParticipantKind,\n RoutingMode,\n TurnPolicy,\n type RoomPlatformIface,\n type ConversationIface,\n type ConversationMessageIface,\n type ParticipantIface,\n type RouteArgsIface,\n type RouteDecisionIface,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport {\n authorPrefixedContent,\n buildPromptContent,\n catchUpFor,\n excerpt,\n finalAuthorOf,\n finalContextOf,\n messageRefOf,\n messageSummary,\n renderReplyContext,\n systemNoticeBlock,\n type ReplyContextArgsIface,\n} from \"./prompt.mjs\";\nimport { MAX_AGENT_HOP_DEPTH } from \"./routing.mjs\";\n\n// How a channel hands a conversation message to its agents: route, then build\n// each recipient's ACP content and call prompt or observe. Prompt construction,\n// not orchestration.\n\nconst thrownMessageSchema = z.object({ message: z.string() });\n\nexport const CONTEXT_WINDOW_MESSAGES = 50;\n\nexport interface DeliveryOutcomeIface {\n participantId: string;\n delivery: Delivery;\n // What actually happened: an observe can fall back to a silent prompt, or be\n // skipped for an agent with no session yet (its first prompt catches up).\n sent: 'prompt' | 'observe' | 'silent-prompt' | 'skipped' | 'failed';\n messageId: string | null;\n error: string | null;\n}\n\nexport interface DeliverMessageArgsIface {\n platform: RoomPlatformIface;\n // A channel's pure route(), or a bundle channel's run in its isolate.\n route: (args: RouteArgsIface) => RouteDecisionIface[] | Promise<RouteDecisionIface[]>;\n conversation: ConversationIface;\n message: ConversationMessageIface;\n participants?: ParticipantIface[];\n // The delivering channel's turnPolicy.\n turnPolicy: TurnPolicy;\n}\n\n// A channel's policy applies unless the conversation is set to\n// queue, the per-conversation override.\nexport const effectiveTurnPolicy = (args: {\n channel: TurnPolicy;\n conversation: TurnPolicy;\n}): TurnPolicy => (args.conversation === TurnPolicy.Queue ? TurnPolicy.Queue : args.channel);\n\n// Every person in the room: who may answer what a turn no person prompted asks.\nexport const humanAudience = (participants: ParticipantIface[]): string[] =>\n participants\n .filter((participant) => !participant.left && participant.kind === ParticipantKind.User)\n .map((participant) => participant.id);\n\n// A person answers their own prompt; an agent's prompt is answered by the room's people.\nexport const audienceFor = (\n author: ParticipantIface | null,\n participants: ParticipantIface[],\n): string[] => (author?.kind === ParticipantKind.User ? [author.id] : humanAudience(participants));\n\n// Reply, thread and quote context. A referenced message outside the\n// recent window is read by id, however old.\nconst replyContextFor = async (args: {\n platform: RoomPlatformIface;\n message: ConversationMessageIface;\n earlier: ConversationMessageIface[];\n participants: ParticipantIface[];\n}): Promise<ReplyContextArgsIface> => {\n const byId = new Map(args.earlier.map((message) => [message.messageId, message]));\n const referenced = [\n args.message.replyToMessageId,\n args.message.threadRootId,\n ...args.message.quotedMessageIds,\n ].flatMap((id) => (id == null || byId.has(id) ? [] : [id]));\n if (referenced.length > 0) {\n const found = await args.platform.conversations.getMessages({\n conversationId: args.message.conversationId,\n messageIds: [...new Set(referenced)],\n });\n for (const message of found) byId.set(message.messageId, message);\n }\n const replyTo =\n args.message.replyToMessageId == null\n ? null\n : (byId.get(args.message.replyToMessageId) ?? null);\n const root =\n args.message.threadRootId == null ? null : (byId.get(args.message.threadRootId) ?? null);\n const rootAuthor =\n root == null\n ? null\n : args.participants.find((participant) => participant.id === root.authorParticipantId);\n return {\n replyTo:\n replyTo == null || replyTo.messageId === root?.messageId\n ? null\n : messageRefOf(replyTo, args.participants),\n thread:\n args.message.threadRootId == null\n ? null\n : {\n rootMessageId: args.message.threadRootId,\n rootExcerpt: root == null ? '' : excerpt(messageSummary(root.content)),\n rootAuthor: rootAuthor == null ? null : finalAuthorOf(rootAuthor),\n },\n quotes: args.message.quotedMessageIds.flatMap((id) => {\n const quoted = byId.get(id);\n return quoted == null ? [] : [messageRefOf(quoted, args.participants)];\n }),\n };\n};\n\nexport const deliveryIdempotencyKey = (messageId: string, participantId: string): string =>\n `${messageId}:${participantId}`;\n\nexport const deliverMessage = async (\n args: DeliverMessageArgsIface,\n): Promise<DeliveryOutcomeIface[]> => {\n const { platform, conversation, message } = args;\n const participants =\n args.participants ?? (await platform.conversations.participants(conversation.conversationId));\n const decisions = await args.route({ conversation, message, participants });\n const author =\n participants.find((participant) => participant.id === message.authorParticipantId) ?? null;\n for (const participant of participants) {\n if (participant.kind !== ParticipantKind.Agent) continue;\n const decision = decisions.find((candidate) => candidate.participantId === participant.id);\n platform.log('channel route decision', {\n observed_at: new Date().toISOString(),\n organization_id: conversation.organizationId,\n conversation_id: conversation.conversationId,\n conversation_kind: conversation.kind,\n message_id: message.messageId,\n author_kind: author?.kind ?? '',\n participant_id: participant.id,\n routing_mode: participant.routingMode ?? '',\n delivery: decision?.delivery ?? 'skipped',\n reason: participant.left\n ? 'left conversation'\n : participant.id === message.authorParticipantId\n ? 'author'\n : decision == null\n ? 'not selected by route'\n : 'selected by route',\n hop_depth: message.hopDepth,\n });\n }\n if (decisions.length === 0) return [];\n const earlier = await platform.conversations.recentMessages({\n conversationId: conversation.conversationId,\n limit: CONTEXT_WINDOW_MESSAGES,\n beforeSeq: message.seq,\n });\n const replyContext = await replyContextFor({ platform, message, earlier, participants });\n const turnPolicy = effectiveTurnPolicy({\n channel: args.turnPolicy,\n conversation: conversation.turnPolicy,\n });\n const audience = audienceFor(author, participants);\n const authorParticipant: ParticipantIface = author ?? {\n id: message.authorParticipantId,\n kind: ParticipantKind.User,\n displayName: 'Someone',\n userId: null,\n definitionId: null,\n routingMode: null,\n sessionId: null,\n supportsObserve: null,\n rendersAuthorMeta: null,\n left: true,\n };\n\n const deliverOne = async (decision: RouteDecisionIface): Promise<DeliveryOutcomeIface> => {\n const recipient = participants.find((participant) => participant.id === decision.participantId);\n const base = { participantId: decision.participantId, delivery: decision.delivery };\n if (recipient == null) {\n return { ...base, sent: 'skipped', messageId: null, error: null };\n }\n const idempotencyKey = deliveryIdempotencyKey(message.messageId, recipient.id);\n const prompt = async (content: ContentBlock[], replyExpected: boolean): Promise<string> => {\n const result = await platform.sessions.prompt({\n participantId: recipient.id,\n content,\n turnPolicy,\n replyExpected,\n idempotencyKey,\n authorParticipantId: message.authorParticipantId,\n audienceParticipantIds: audience,\n sourceMessageId: message.messageId,\n });\n return result.messageId;\n };\n try {\n if (decision.delivery === Delivery.Prompt) {\n const content = buildPromptContent({\n message,\n author: authorParticipant,\n recipient,\n replyContext,\n catchUp: catchUpFor({ recipient, earlier, participants }),\n });\n return { ...base, sent: 'prompt', messageId: await prompt(content, true), error: null };\n }\n if (recipient.sessionId == null) {\n return { ...base, sent: 'skipped', messageId: null, error: null };\n }\n const contextBlock = renderReplyContext(replyContext);\n const content = [\n ...(contextBlock == null ? [] : [contextBlock]),\n ...authorPrefixedContent({\n content: message.content,\n author: finalAuthorOf(authorParticipant),\n rendersAuthorMeta: recipient.rendersAuthorMeta ?? false,\n context: finalContextOf(replyContext),\n }),\n ];\n if (recipient.supportsObserve === false) {\n if (message.hopDepth >= MAX_AGENT_HOP_DEPTH) {\n return { ...base, sent: 'skipped', messageId: null, error: null };\n }\n return {\n ...base,\n sent: 'silent-prompt',\n messageId: await prompt(content, false),\n error: null,\n };\n }\n await platform.sessions.observe({ participantId: recipient.id, content, idempotencyKey });\n return { ...base, sent: 'observe', messageId: null, error: null };\n } catch (error) {\n // JSON-RPC failures arrive as plain `{ code, message }` objects.\n const reason =\n error instanceof Error\n ? error.message\n : (thrownMessageSchema.safeParse(error).data?.message ?? String(error));\n platform.log('channel delivery failed', {\n conversationId: conversation.conversationId,\n messageId: message.messageId,\n participantId: recipient.id,\n delivery: decision.delivery,\n error: reason,\n });\n return { ...base, sent: 'failed', messageId: null, error: reason };\n }\n };\n\n return Promise.all(decisions.map(deliverOne));\n};\n\nexport interface ObserveNoticeArgsIface {\n platform: RoomPlatformIface;\n recipients: ParticipantIface[];\n text: string;\n idempotencyKey: string;\n}\n\n// System blocks with no model call. Agents without a session skip them (their\n// first prompt catches up); agents without observe support skip them too, since\n// a silent prompt per reaction is not worth a model call.\nexport const observeNotice = async (args: ObserveNoticeArgsIface): Promise<string[]> => {\n const delivered: string[] = [];\n for (const recipient of args.recipients) {\n if (recipient.sessionId == null || recipient.supportsObserve === false || recipient.left)\n continue;\n try {\n await args.platform.sessions.observe({\n participantId: recipient.id,\n content: [systemNoticeBlock({ text: args.text })],\n idempotencyKey: `${args.idempotencyKey}:${recipient.id}`,\n });\n delivered.push(recipient.id);\n } catch (error) {\n args.platform.log('channel notice failed', {\n participantId: recipient.id,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n return delivered;\n};\n\nexport interface ReactionNoticeArgsIface {\n platform: RoomPlatformIface;\n participants: ParticipantIface[];\n message: ConversationMessageIface;\n // Whether the reacted message is the agent's latest one.\n isLatestOfAuthor: boolean;\n reactorParticipantId: string;\n emoji: string;\n eventId?: string;\n}\n\n// Only the agent whose message was reacted to hears about it.\nexport const reactionNotice = async (args: ReactionNoticeArgsIface): Promise<string[]> => {\n const author = args.participants.find(\n (participant) => participant.id === args.message.authorParticipantId,\n );\n const reactor = args.participants.find(\n (participant) => participant.id === args.reactorParticipantId,\n );\n if (\n author == null ||\n author.kind !== ParticipantKind.Agent ||\n reactor == null ||\n reactor.id === author.id\n ) {\n return [];\n }\n const target = args.isLatestOfAuthor\n ? 'your last message'\n : `your message \"${excerpt(messageSummary(args.message.content), 120)}\"`;\n const reactionId = `reaction:${args.message.messageId}:${reactor.id}:${args.emoji}`;\n return observeNotice({\n platform: args.platform,\n recipients: [author],\n text: `${reactor.displayName} reacted ${args.emoji} to ${target}`,\n idempotencyKey: args.eventId == null ? reactionId : `${reactionId}:${args.eventId}`,\n });\n};\n\nexport enum MembershipChange {\n Joined = 'joined',\n Left = 'left',\n}\n\nexport interface MembershipNoticeArgsIface {\n platform: RoomPlatformIface;\n participants: ParticipantIface[];\n subject: ParticipantIface;\n change: MembershipChange;\n idempotencyKey: string;\n}\n\n// Membership changes reach agents that follow the whole conversation.\nexport const membershipNotice = async (args: MembershipNoticeArgsIface): Promise<string[]> => {\n const recipients = args.participants.filter(\n (participant) =>\n participant.kind === ParticipantKind.Agent &&\n participant.id !== args.subject.id &&\n (participant.routingMode === RoutingMode.All ||\n participant.routingMode === RoutingMode.Default),\n );\n const verb = args.change === MembershipChange.Joined ? 'joined' : 'left';\n return observeNotice({\n platform: args.platform,\n recipients,\n text: `${args.subject.displayName} ${verb} the conversation`,\n idempotencyKey: args.idempotencyKey,\n });\n};\n"],
5
- "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AACP,YAAY,OAAO;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,2BAA2B;AAMpC,MAAM,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAErD,MAAM,0BAA0B;AAyBhC,MAAM,sBAAsB,CAAC,SAGjB,KAAK,iBAAiB,WAAW,QAAQ,WAAW,QAAQ,KAAK;AAG7E,MAAM,gBAAgB,CAAC,iBAC5B,aACG,OAAO,CAAC,gBAAgB,CAAC,YAAY,QAAQ,YAAY,SAAS,gBAAgB,IAAI,EACtF,IAAI,CAAC,gBAAgB,YAAY,EAAE;AAGjC,MAAM,cAAc,CACzB,QACA,iBACc,QAAQ,SAAS,gBAAgB,OAAO,CAAC,OAAO,EAAE,IAAI,cAAc,YAAY;AAIhG,MAAM,kBAAkB,OAAO,SAKO;AACpC,QAAM,OAAO,IAAI,IAAI,KAAK,QAAQ,IAAI,CAAC,YA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