@finalai/final-agent-provider 0.11.0 → 0.13.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 (71) hide show
  1. package/README.md +1 -14
  2. package/dist/modules/integrations.d.mts +0 -1
  3. package/dist/modules/integrations.mjs +0 -2
  4. package/dist/modules/integrations.mjs.map +2 -2
  5. package/dist/modules/sandboxes/computer.d.mts +2 -4
  6. package/dist/modules/sandboxes/computer.mjs +110 -480
  7. package/dist/modules/sandboxes/computer.mjs.map +2 -2
  8. package/dist/modules/sandboxes/computers-api.d.mts +6 -1
  9. package/dist/modules/sandboxes/computers-api.mjs.map +2 -2
  10. package/dist/modules/sandboxes/device-api.d.mts +8 -48
  11. package/dist/modules/sandboxes/device-api.mjs +2 -92
  12. package/dist/modules/sandboxes/device-api.mjs.map +2 -2
  13. package/dist/modules/sandboxes/device.d.mts +1 -1
  14. package/dist/modules/sandboxes/device.mjs.map +2 -2
  15. package/dist/modules/sandboxes/environment.d.mts +4 -0
  16. package/dist/modules/sandboxes/environment.mjs.map +2 -2
  17. package/dist/modules/sandboxes/local.d.mts +2 -1
  18. package/dist/modules/sandboxes/local.mjs +64 -8
  19. package/dist/modules/sandboxes/local.mjs.map +2 -2
  20. package/dist/modules/sandboxes/session.mjs +0 -1
  21. package/dist/modules/sandboxes/session.mjs.map +2 -2
  22. package/package.json +5 -57
  23. package/WORKSPACE-EGRESS.md +0 -184
  24. package/dist/modules/authoring-final-channel.d.mts +0 -3
  25. package/dist/modules/authoring-final-channel.mjs +0 -10
  26. package/dist/modules/authoring-final-channel.mjs.map +0 -7
  27. package/dist/modules/channel-factories.d.mts +0 -40
  28. package/dist/modules/channel-factories.mjs +0 -212
  29. package/dist/modules/channel-factories.mjs.map +0 -7
  30. package/dist/modules/channels/content.d.mts +0 -6
  31. package/dist/modules/channels/content.mjs +0 -31
  32. package/dist/modules/channels/content.mjs.map +0 -7
  33. package/dist/modules/channels/delivery.d.mts +0 -54
  34. package/dist/modules/channels/delivery.mjs +0 -243
  35. package/dist/modules/channels/delivery.mjs.map +0 -7
  36. package/dist/modules/channels/direct-messaging.d.mts +0 -5
  37. package/dist/modules/channels/direct-messaging.mjs +0 -8
  38. package/dist/modules/channels/direct-messaging.mjs.map +0 -7
  39. package/dist/modules/channels/fake-platform.d.mts +0 -36
  40. package/dist/modules/channels/fake-platform.mjs +0 -168
  41. package/dist/modules/channels/fake-platform.mjs.map +0 -7
  42. package/dist/modules/channels/group-messaging.d.mts +0 -5
  43. package/dist/modules/channels/group-messaging.mjs +0 -8
  44. package/dist/modules/channels/group-messaging.mjs.map +0 -7
  45. package/dist/modules/channels/inbound.d.mts +0 -52
  46. package/dist/modules/channels/inbound.mjs +0 -42
  47. package/dist/modules/channels/inbound.mjs.map +0 -7
  48. package/dist/modules/channels/index.d.mts +0 -9
  49. package/dist/modules/channels/index.mjs +0 -10
  50. package/dist/modules/channels/index.mjs.map +0 -7
  51. package/dist/modules/channels/messaging-channel.d.mts +0 -7
  52. package/dist/modules/channels/messaging-channel.mjs +0 -99
  53. package/dist/modules/channels/messaging-channel.mjs.map +0 -7
  54. package/dist/modules/channels/projection.d.mts +0 -36
  55. package/dist/modules/channels/projection.mjs +0 -233
  56. package/dist/modules/channels/projection.mjs.map +0 -7
  57. package/dist/modules/channels/prompt.d.mts +0 -72
  58. package/dist/modules/channels/prompt.mjs +0 -208
  59. package/dist/modules/channels/prompt.mjs.map +0 -7
  60. package/dist/modules/channels/routing.d.mts +0 -5
  61. package/dist/modules/channels/routing.mjs +0 -53
  62. package/dist/modules/channels/routing.mjs.map +0 -7
  63. package/dist/modules/sandboxes/access.d.mts +0 -34
  64. package/dist/modules/sandboxes/access.mjs +0 -15
  65. package/dist/modules/sandboxes/access.mjs.map +0 -7
  66. package/dist/modules/sandboxes/egress-bootstrap.d.mts +0 -3
  67. package/dist/modules/sandboxes/egress-bootstrap.mjs +0 -929
  68. package/dist/modules/sandboxes/egress-bootstrap.mjs.map +0 -7
  69. package/dist/modules/sandboxes/egress.d.mts +0 -94
  70. package/dist/modules/sandboxes/egress.mjs +0 -1561
  71. package/dist/modules/sandboxes/egress.mjs.map +0 -7
@@ -1,72 +0,0 @@
1
- import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';
2
- import { type FinalAuthorIface, type FinalContextIface, type FinalMessageRefIface } from '@finalai/acp-session';
3
- import { type RoomAuthIface, type ConversationMessageIface, type ParticipantIface } from '@finalai/agent-provider/room-surface';
4
- export declare const EXCERPT_CHARS = 280;
5
- export declare const CATCH_UP_MAX_MESSAGES = 20;
6
- export declare const CATCH_UP_MAX_CHARS = 4000;
7
- export declare const textBlock: (text: string) => ContentBlock;
8
- export declare const contentText: (content: ContentBlock[]) => string;
9
- export declare const messageSummary: (content: ContentBlock[]) => string;
10
- export declare const excerpt: (text: string, maxChars?: number) => string;
11
- export declare const finalAuthorOf: (participant: ParticipantIface) => FinalAuthorIface;
12
- export declare const principalAuthorOf: (args: {
13
- auth: RoomAuthIface;
14
- agent?: boolean;
15
- }) => FinalAuthorIface;
16
- export interface AuthorPrefixedContentArgsIface {
17
- content: ContentBlock[];
18
- author: FinalAuthorIface;
19
- rendersAuthorMeta: boolean;
20
- context?: FinalContextIface;
21
- }
22
- export declare const authorPrefixedContent: (args: AuthorPrefixedContentArgsIface) => ContentBlock[];
23
- export interface ReplyContextArgsIface {
24
- replyTo?: FinalMessageRefIface | null;
25
- thread?: {
26
- rootMessageId: string;
27
- rootExcerpt: string;
28
- rootAuthor?: FinalAuthorIface | null;
29
- } | null;
30
- quotes?: FinalMessageRefIface[];
31
- }
32
- export declare const finalContextOf: (args: ReplyContextArgsIface) => FinalContextIface | undefined;
33
- export declare const renderReplyContext: (args: ReplyContextArgsIface) => ContentBlock | null;
34
- export declare const messageRefOf: (message: ConversationMessageIface, participants: ParticipantIface[]) => FinalMessageRefIface;
35
- export declare enum CatchUpSince {
36
- Start = "start",
37
- LastContact = "last-contact"
38
- }
39
- export interface CatchUpArgsIface {
40
- messages: ConversationMessageIface[];
41
- participants: ParticipantIface[];
42
- agentParticipantId: string;
43
- since: CatchUpSince;
44
- maxMessages?: number;
45
- maxChars?: number;
46
- }
47
- export declare const buildCatchUpBlock: (args: CatchUpArgsIface) => ContentBlock | null;
48
- export declare const systemNoticeBlock: (args: {
49
- text: string;
50
- }) => ContentBlock;
51
- export declare const catchUpFor: (args: {
52
- recipient: ParticipantIface;
53
- earlier: ConversationMessageIface[];
54
- participants: ParticipantIface[];
55
- }) => ContentBlock | null;
56
- export interface PromptContentArgsIface {
57
- message: ConversationMessageIface;
58
- author: ParticipantIface;
59
- recipient: ParticipantIface;
60
- replyContext: ReplyContextArgsIface;
61
- catchUp: ContentBlock | null;
62
- }
63
- export declare const buildPromptContent: (args: PromptContentArgsIface) => ContentBlock[];
64
- export interface ServiceInputPromptArgsIface {
65
- content: ContentBlock[];
66
- context?: string[];
67
- author: FinalAuthorIface;
68
- recipient: ParticipantIface;
69
- earlier: ConversationMessageIface[];
70
- participants: ParticipantIface[];
71
- }
72
- export declare const buildServiceInputPrompt: (args: ServiceInputPromptArgsIface) => ContentBlock[];
@@ -1,208 +0,0 @@
1
- import {
2
- FinalAuthorKind,
3
- FinalContentRole,
4
- promptTextWithAuthorPrefix,
5
- textOf,
6
- withFinalMeta
7
- } from "@finalai/acp-session";
8
- import {
9
- RoomPrincipalType,
10
- MessageKind,
11
- ParticipantKind,
12
- principalDisplayName,
13
- RoutingMode
14
- } from "@finalai/agent-provider/room-surface";
15
- const EXCERPT_CHARS = 280;
16
- const CATCH_UP_MAX_MESSAGES = 20;
17
- const CATCH_UP_MAX_CHARS = 4e3;
18
- const textBlock = (text) => ({ type: "text", text });
19
- const contentText = (content) => textOf(content, { separator: "\n" }).trim();
20
- const messageSummary = (content) => {
21
- const text = contentText(content);
22
- if (text.length > 0) {
23
- return text;
24
- }
25
- const attachments = content.filter((block) => block.type !== "text").length;
26
- return attachments === 0 ? "" : `[${attachments} attachment${attachments === 1 ? "" : "s"}]`;
27
- };
28
- const excerpt = (text, maxChars = EXCERPT_CHARS) => {
29
- const normalized = text.replace(/\s+/gu, " ").trim();
30
- return normalized.length <= maxChars ? normalized : `${normalized.slice(0, maxChars - 1)}\u2026`;
31
- };
32
- const finalAuthorOf = (participant) => ({
33
- participantId: participant.id,
34
- kind: participant.kind === ParticipantKind.Agent ? FinalAuthorKind.Agent : FinalAuthorKind.User,
35
- displayName: participant.displayName
36
- });
37
- const principalAuthorOf = (args) => ({
38
- kind: args.agent === true ? FinalAuthorKind.Agent : args.auth.principalType === RoomPrincipalType.User ? FinalAuthorKind.User : FinalAuthorKind.Service,
39
- displayName: principalDisplayName(args.auth),
40
- principal: {
41
- principalId: args.auth.principalId,
42
- principalType: args.auth.principalType,
43
- authenticator: args.auth.authenticator
44
- }
45
- });
46
- const withContentRole = (block, context) => withFinalMeta(block, { role: FinalContentRole.Context, context });
47
- const authorPrefixedContent = (args) => {
48
- const blocks = args.rendersAuthorMeta ? args.content : promptTextWithAuthorPrefix(args.content, args.author.displayName);
49
- return blocks.map(
50
- (block, index) => withFinalMeta(block, { author: args.author, context: index === 0 ? args.context : void 0 })
51
- );
52
- };
53
- const finalContextOf = (args) => {
54
- const context = {};
55
- if (args.replyTo != null) context.replyTo = args.replyTo;
56
- if (args.thread != null) {
57
- context.thread = {
58
- rootMessageId: args.thread.rootMessageId,
59
- rootExcerpt: args.thread.rootExcerpt
60
- };
61
- }
62
- if (args.quotes != null && args.quotes.length > 0) context.quotes = args.quotes;
63
- return Object.keys(context).length === 0 ? void 0 : context;
64
- };
65
- const renderReplyContext = (args) => {
66
- const context = finalContextOf(args);
67
- if (context == null) {
68
- return null;
69
- }
70
- const lines = [];
71
- if (args.thread != null) {
72
- const by = args.thread.rootAuthor == null ? "" : ` started by ${args.thread.rootAuthor.displayName}`;
73
- lines.push(`In a thread${by}: "${args.thread.rootExcerpt}"`);
74
- }
75
- if (args.replyTo != null) {
76
- lines.push(
77
- `Replying to ${args.replyTo.author?.displayName ?? "a message"}: "${args.replyTo.excerpt}"`
78
- );
79
- }
80
- for (const quote of args.quotes ?? []) {
81
- lines.push(`Quoting ${quote.author?.displayName ?? "a message"}: "${quote.excerpt}"`);
82
- }
83
- return withContentRole(textBlock(lines.join("\n")), context);
84
- };
85
- const messageRefOf = (message, participants) => {
86
- const author = participants.find((participant) => participant.id === message.authorParticipantId);
87
- return {
88
- messageId: message.messageId,
89
- author: author == null ? null : finalAuthorOf(author),
90
- excerpt: excerpt(messageSummary(message.content))
91
- };
92
- };
93
- const transcriptLine = (message, participants) => {
94
- const author = participants.find((participant) => participant.id === message.authorParticipantId);
95
- return `${author?.displayName ?? "Someone"}: ${messageSummary(message.content)}`;
96
- };
97
- const visibleForTranscript = (message) => message.kind !== MessageKind.Card && messageSummary(message.content).length > 0;
98
- const boundedLines = (args) => {
99
- const lines = [];
100
- let chars = 0;
101
- const ordered = [...args.messages].sort((left, right) => right.seq - left.seq);
102
- for (const message of ordered) {
103
- const line = transcriptLine(message, args.participants);
104
- if (lines.length >= args.maxMessages || chars + line.length > args.maxChars) {
105
- break;
106
- }
107
- lines.push(line);
108
- chars += line.length + 1;
109
- }
110
- return { lines: lines.reverse(), omitted: ordered.length - lines.length };
111
- };
112
- var CatchUpSince = /* @__PURE__ */ ((CatchUpSince2) => {
113
- CatchUpSince2["Start"] = "start";
114
- CatchUpSince2["LastContact"] = "last-contact";
115
- return CatchUpSince2;
116
- })(CatchUpSince || {});
117
- const buildCatchUpBlock = (args) => {
118
- let unseen = args.messages.filter(
119
- (message) => visibleForTranscript(message) && message.authorParticipantId !== args.agentParticipantId
120
- );
121
- if (args.since === "last-contact" /* LastContact */) {
122
- const lastContactSeq = args.messages.reduce(
123
- (latest, message) => message.authorParticipantId === args.agentParticipantId || message.mentionedParticipantIds.includes(args.agentParticipantId) ? Math.max(latest, message.seq) : latest,
124
- -1
125
- );
126
- unseen = unseen.filter((message) => message.seq > lastContactSeq);
127
- }
128
- if (unseen.length === 0) {
129
- return null;
130
- }
131
- const { lines, omitted } = boundedLines({
132
- messages: unseen,
133
- participants: args.participants,
134
- maxMessages: args.maxMessages ?? CATCH_UP_MAX_MESSAGES,
135
- maxChars: args.maxChars ?? CATCH_UP_MAX_CHARS
136
- });
137
- if (lines.length === 0) {
138
- return null;
139
- }
140
- const header = "Earlier in this conversation, not previously shown:";
141
- const omittedLine = omitted > 0 ? [`(${omitted} earlier message${omitted === 1 ? "" : "s"} omitted)`] : [];
142
- return withContentRole(textBlock([header, ...omittedLine, ...lines].join("\n")));
143
- };
144
- const systemNoticeBlock = (args) => withFinalMeta(textBlock(args.text), {
145
- author: { kind: FinalAuthorKind.Service, displayName: "Final" }
146
- });
147
- const catchUpFor = (args) => {
148
- const since = args.recipient.sessionId == null ? "start" /* Start */ : args.recipient.routingMode === RoutingMode.Mention ? "last-contact" /* LastContact */ : null;
149
- if (since == null) return null;
150
- return buildCatchUpBlock({
151
- messages: args.earlier,
152
- participants: args.participants,
153
- agentParticipantId: args.recipient.id,
154
- since
155
- });
156
- };
157
- const buildPromptContent = (args) => {
158
- const contextBlock = renderReplyContext(args.replyContext);
159
- const body = authorPrefixedContent({
160
- content: args.message.content.length > 0 ? args.message.content : [textBlock(args.message.body)],
161
- author: finalAuthorOf(args.author),
162
- rendersAuthorMeta: args.recipient.rendersAuthorMeta ?? false,
163
- context: finalContextOf(args.replyContext)
164
- });
165
- return [
166
- ...args.catchUp == null ? [] : [args.catchUp],
167
- ...contextBlock == null ? [] : [contextBlock],
168
- ...body
169
- ];
170
- };
171
- const buildServiceInputPrompt = (args) => {
172
- const catchUp = catchUpFor({
173
- recipient: args.recipient,
174
- earlier: args.earlier,
175
- participants: args.participants
176
- });
177
- return [
178
- ...catchUp == null ? [] : [catchUp],
179
- ...(args.context ?? []).map((text) => withContentRole(textBlock(text))),
180
- ...authorPrefixedContent({
181
- content: args.content,
182
- author: args.author,
183
- rendersAuthorMeta: args.recipient.rendersAuthorMeta ?? false
184
- })
185
- ];
186
- };
187
- export {
188
- CATCH_UP_MAX_CHARS,
189
- CATCH_UP_MAX_MESSAGES,
190
- CatchUpSince,
191
- EXCERPT_CHARS,
192
- authorPrefixedContent,
193
- buildCatchUpBlock,
194
- buildPromptContent,
195
- buildServiceInputPrompt,
196
- catchUpFor,
197
- contentText,
198
- excerpt,
199
- finalAuthorOf,
200
- finalContextOf,
201
- messageRefOf,
202
- messageSummary,
203
- principalAuthorOf,
204
- renderReplyContext,
205
- systemNoticeBlock,
206
- textBlock
207
- };
208
- //# sourceMappingURL=prompt.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/channels/prompt.ts"],
4
- "sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport {\n FinalAuthorKind,\n FinalContentRole,\n promptTextWithAuthorPrefix,\n textOf,\n withFinalMeta,\n type FinalAuthorIface,\n type FinalContextIface,\n type FinalMessageRefIface,\n} from '@finalai/acp-session';\nimport {\n RoomPrincipalType,\n MessageKind,\n ParticipantKind,\n principalDisplayName,\n RoutingMode,\n type RoomAuthIface,\n type ConversationMessageIface,\n type ParticipantIface,\n} from '@finalai/agent-provider/room-surface';\n\nexport const EXCERPT_CHARS = 280;\nexport const CATCH_UP_MAX_MESSAGES = 20;\nexport const CATCH_UP_MAX_CHARS = 4_000;\n\nexport const textBlock = (text: string): ContentBlock => ({ type: 'text', text });\n\nexport const contentText = (content: ContentBlock[]): string =>\n textOf(content, { separator: '\\n' }).trim();\n\n// A one-line description of a message for previews, excerpts and transcripts.\nexport const messageSummary = (content: ContentBlock[]): string => {\n const text = contentText(content);\n if (text.length > 0) {\n return text;\n }\n const attachments = content.filter((block) => block.type !== 'text').length;\n return attachments === 0 ? '' : `[${attachments} attachment${attachments === 1 ? '' : 's'}]`;\n};\n\nexport const excerpt = (text: string, maxChars: number = EXCERPT_CHARS): string => {\n const normalized = text.replace(/\\s+/gu, ' ').trim();\n return normalized.length <= maxChars ? normalized : `${normalized.slice(0, maxChars - 1)}\u2026`;\n};\n\nexport const finalAuthorOf = (participant: ParticipantIface): FinalAuthorIface => ({\n participantId: participant.id,\n kind: participant.kind === ParticipantKind.Agent ? FinalAuthorKind.Agent : FinalAuthorKind.User,\n displayName: participant.displayName,\n});\n\n// The author an agent sees for channel input from no member: the principal the\n// channel authenticated, named as the channel named it. `agent` marks input an\n// agent wrote elsewhere (another chat), so the recipient knows it is not a person.\nexport const principalAuthorOf = (args: {\n auth: RoomAuthIface;\n agent?: boolean;\n}): FinalAuthorIface => ({\n kind:\n args.agent === true\n ? FinalAuthorKind.Agent\n : args.auth.principalType === RoomPrincipalType.User\n ? FinalAuthorKind.User\n : FinalAuthorKind.Service,\n displayName: principalDisplayName(args.auth),\n principal: {\n principalId: args.auth.principalId,\n principalType: args.auth.principalType,\n authenticator: args.auth.authenticator,\n },\n});\n\nconst withContentRole = (block: ContentBlock, context?: FinalContextIface): ContentBlock =>\n withFinalMeta(block, { role: FinalContentRole.Context, context });\n\n// Attribution: `_meta[\"final.ai\"].author` on every block, plus a\n// `<name>: ` prefix for harnesses that do not render author meta.\nexport interface AuthorPrefixedContentArgsIface {\n content: ContentBlock[];\n author: FinalAuthorIface;\n rendersAuthorMeta: boolean;\n context?: FinalContextIface;\n}\n\nexport const authorPrefixedContent = (args: AuthorPrefixedContentArgsIface): ContentBlock[] => {\n const blocks: ContentBlock[] = args.rendersAuthorMeta\n ? args.content\n : promptTextWithAuthorPrefix(args.content, args.author.displayName);\n return blocks.map((block, index) =>\n withFinalMeta(block, { author: args.author, context: index === 0 ? args.context : undefined }),\n );\n};\n\nexport interface ReplyContextArgsIface {\n replyTo?: FinalMessageRefIface | null;\n thread?: {\n rootMessageId: string;\n rootExcerpt: string;\n rootAuthor?: FinalAuthorIface | null;\n } | null;\n quotes?: FinalMessageRefIface[];\n}\n\nexport const finalContextOf = (args: ReplyContextArgsIface): FinalContextIface | undefined => {\n const context: FinalContextIface = {};\n if (args.replyTo != null) context.replyTo = args.replyTo;\n if (args.thread != null) {\n context.thread = {\n rootMessageId: args.thread.rootMessageId,\n rootExcerpt: args.thread.rootExcerpt,\n };\n }\n if (args.quotes != null && args.quotes.length > 0) context.quotes = args.quotes;\n return Object.keys(context).length === 0 ? undefined : context;\n};\n\n// The rendered reply/thread/quote block, for harnesses that ignore\n// `_meta`. Null when the message has no context.\nexport const renderReplyContext = (args: ReplyContextArgsIface): ContentBlock | null => {\n const context = finalContextOf(args);\n if (context == null) {\n return null;\n }\n const lines: string[] = [];\n if (args.thread != null) {\n const by =\n args.thread.rootAuthor == null ? '' : ` started by ${args.thread.rootAuthor.displayName}`;\n lines.push(`In a thread${by}: \"${args.thread.rootExcerpt}\"`);\n }\n if (args.replyTo != null) {\n lines.push(\n `Replying to ${args.replyTo.author?.displayName ?? 'a message'}: \"${args.replyTo.excerpt}\"`,\n );\n }\n for (const quote of args.quotes ?? []) {\n lines.push(`Quoting ${quote.author?.displayName ?? 'a message'}: \"${quote.excerpt}\"`);\n }\n return withContentRole(textBlock(lines.join('\\n')), context);\n};\n\nexport const messageRefOf = (\n message: ConversationMessageIface,\n participants: ParticipantIface[],\n): FinalMessageRefIface => {\n const author = participants.find((participant) => participant.id === message.authorParticipantId);\n return {\n messageId: message.messageId,\n author: author == null ? null : finalAuthorOf(author),\n excerpt: excerpt(messageSummary(message.content)),\n };\n};\n\nconst transcriptLine = (\n message: ConversationMessageIface,\n participants: ParticipantIface[],\n): string => {\n const author = participants.find((participant) => participant.id === message.authorParticipantId);\n return `${author?.displayName ?? 'Someone'}: ${messageSummary(message.content)}`;\n};\n\nconst visibleForTranscript = (message: ConversationMessageIface): boolean =>\n message.kind !== MessageKind.Card && messageSummary(message.content).length > 0;\n\ninterface BoundedLinesArgsIface {\n messages: ConversationMessageIface[];\n participants: ParticipantIface[];\n maxMessages: number;\n maxChars: number;\n}\n\ninterface BoundedLinesIface {\n lines: string[];\n omitted: number;\n}\n\n// Lines from newest backwards until a bound is hit, returned oldest first.\nconst boundedLines = (args: BoundedLinesArgsIface): BoundedLinesIface => {\n const lines: string[] = [];\n let chars = 0;\n const ordered = [...args.messages].sort((left, right) => right.seq - left.seq);\n for (const message of ordered) {\n const line = transcriptLine(message, args.participants);\n if (lines.length >= args.maxMessages || chars + line.length > args.maxChars) {\n break;\n }\n lines.push(line);\n chars += line.length + 1;\n }\n return { lines: lines.reverse(), omitted: ordered.length - lines.length };\n};\n\nexport enum CatchUpSince {\n // A session that has never seen this conversation (new or reset).\n Start = 'start',\n // An agent that does not observe: since it last spoke or was mentioned.\n LastContact = 'last-contact',\n}\n\nexport interface CatchUpArgsIface {\n // Messages before the one being delivered, any order.\n messages: ConversationMessageIface[];\n participants: ParticipantIface[];\n agentParticipantId: string;\n since: CatchUpSince;\n maxMessages?: number;\n maxChars?: number;\n}\n\n// \"Earlier in this conversation, not previously shown: \u2026\", marked\n// as context. Null when there is nothing the agent has not seen.\nexport const buildCatchUpBlock = (args: CatchUpArgsIface): ContentBlock | null => {\n let unseen = args.messages.filter(\n (message) =>\n visibleForTranscript(message) && message.authorParticipantId !== args.agentParticipantId,\n );\n if (args.since === CatchUpSince.LastContact) {\n const lastContactSeq = args.messages.reduce(\n (latest, message) =>\n message.authorParticipantId === args.agentParticipantId ||\n message.mentionedParticipantIds.includes(args.agentParticipantId)\n ? Math.max(latest, message.seq)\n : latest,\n -1,\n );\n unseen = unseen.filter((message) => message.seq > lastContactSeq);\n }\n if (unseen.length === 0) {\n return null;\n }\n const { lines, omitted } = boundedLines({\n messages: unseen,\n participants: args.participants,\n maxMessages: args.maxMessages ?? CATCH_UP_MAX_MESSAGES,\n maxChars: args.maxChars ?? CATCH_UP_MAX_CHARS,\n });\n if (lines.length === 0) {\n return null;\n }\n const header = 'Earlier in this conversation, not previously shown:';\n const omittedLine =\n omitted > 0 ? [`(${omitted} earlier message${omitted === 1 ? '' : 's'} omitted)`] : [];\n return withContentRole(textBlock([header, ...omittedLine, ...lines].join('\\n')));\n};\n\n// A notice from Final itself delivered by observe: reactions, membership changes.\nexport const systemNoticeBlock = (args: { text: string }): ContentBlock =>\n withFinalMeta(textBlock(args.text), {\n author: { kind: FinalAuthorKind.Service, displayName: 'Final' },\n });\n\n// What a recipient has not seen of its conversation before a prompt: a fresh\n// session has seen nothing; a Mention agent sees only what it is prompted\n// with; everyone else has been observing.\nexport const catchUpFor = (args: {\n recipient: ParticipantIface;\n earlier: ConversationMessageIface[];\n participants: ParticipantIface[];\n}): ContentBlock | null => {\n const since =\n args.recipient.sessionId == null\n ? CatchUpSince.Start\n : args.recipient.routingMode === RoutingMode.Mention\n ? CatchUpSince.LastContact\n : null;\n if (since == null) return null;\n return buildCatchUpBlock({\n messages: args.earlier,\n participants: args.participants,\n agentParticipantId: args.recipient.id,\n since,\n });\n};\n\nexport interface PromptContentArgsIface {\n message: ConversationMessageIface;\n author: ParticipantIface;\n recipient: ParticipantIface;\n replyContext: ReplyContextArgsIface;\n catchUp: ContentBlock | null;\n}\n\n// The ACP prompt one agent receives for a conversation message.\nexport const buildPromptContent = (args: PromptContentArgsIface): ContentBlock[] => {\n const contextBlock = renderReplyContext(args.replyContext);\n const body = authorPrefixedContent({\n content:\n args.message.content.length > 0 ? args.message.content : [textBlock(args.message.body)],\n author: finalAuthorOf(args.author),\n rendersAuthorMeta: args.recipient.rendersAuthorMeta ?? false,\n context: finalContextOf(args.replyContext),\n });\n return [\n ...(args.catchUp == null ? [] : [args.catchUp]),\n ...(contextBlock == null ? [] : [contextBlock]),\n ...body,\n ];\n};\n\nexport interface ServiceInputPromptArgsIface {\n content: ContentBlock[];\n // Channel-supplied context lines, marked as context before the input.\n context?: string[];\n author: FinalAuthorIface;\n recipient: ParticipantIface;\n // The room's latest messages when the input is delivered, any order.\n earlier: ConversationMessageIface[];\n participants: ParticipantIface[];\n}\n\n// The ACP prompt a room's agent receives for channel input: what it has not seen\n// of the room up to its latest message, then the input attributed to its principal.\nexport const buildServiceInputPrompt = (args: ServiceInputPromptArgsIface): ContentBlock[] => {\n const catchUp = catchUpFor({\n recipient: args.recipient,\n earlier: args.earlier,\n participants: args.participants,\n });\n return [\n ...(catchUp == null ? [] : [catchUp]),\n ...(args.context ?? []).map((text) => withContentRole(textBlock(text))),\n ...authorPrefixedContent({\n content: args.content,\n author: args.author,\n rendersAuthorMeta: args.recipient.rendersAuthorMeta ?? false,\n }),\n ];\n};\n"],
5
- "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEA,MAAM,gBAAgB;AACtB,MAAM,wBAAwB;AAC9B,MAAM,qBAAqB;AAE3B,MAAM,YAAY,CAAC,UAAgC,EAAE,MAAM,QAAQ,KAAK;AAExE,MAAM,cAAc,CAAC,YAC1B,OAAO,SAAS,EAAE,WAAW,KAAK,CAAC,EAAE,KAAK;AAGrC,MAAM,iBAAiB,CAAC,YAAoC;AACjE,QAAM,OAAO,YAAY,OAAO;AAChC,MAAI,KAAK,SAAS,GAAG;AACnB,WAAO;AAAA,EACT;AACA,QAAM,cAAc,QAAQ,OAAO,CAAC,UAAU,MAAM,SAAS,MAAM,EAAE;AACrE,SAAO,gBAAgB,IAAI,KAAK,IAAI,WAAW,cAAc,gBAAgB,IAAI,KAAK,GAAG;AAC3F;AAEO,MAAM,UAAU,CAAC,MAAc,WAAmB,kBAA0B;AACjF,QAAM,aAAa,KAAK,QAAQ,SAAS,GAAG,EAAE,KAAK;AACnD,SAAO,WAAW,UAAU,WAAW,aAAa,GAAG,WAAW,MAAM,GAAG,WAAW,CAAC,CAAC;AAC1F;AAEO,MAAM,gBAAgB,CAAC,iBAAqD;AAAA,EACjF,eAAe,YAAY;AAAA,EAC3B,MAAM,YAAY,SAAS,gBAAgB,QAAQ,gBAAgB,QAAQ,gBAAgB;AAAA,EAC3F,aAAa,YAAY;AAC3B;AAKO,MAAM,oBAAoB,CAAC,UAGT;AAAA,EACvB,MACE,KAAK,UAAU,OACX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AAK;AAAA,MACd,QAAQ,KAAK;AAAA,MACb,mBAAmB,KAAK,UAAU,qBAAqB;AAAA,IACzD,CAAC;AAAA,EACH;AACF;",
6
- "names": ["CatchUpSince"]
7
- }
@@ -1,5 +0,0 @@
1
- import { type ParticipantIface, type RouteArgsIface, type RouteDecisionIface } from '@finalai/agent-provider/room-surface';
2
- export declare const MAX_AGENT_HOP_DEPTH = 2;
3
- export declare const effectiveDefaultAgent: (participants: ParticipantIface[]) => ParticipantIface | null;
4
- export declare const routeMessage: (args: RouteArgsIface) => RouteDecisionIface[];
5
- export declare const routeToParticipant: (participantId: string) => (args: RouteArgsIface) => RouteDecisionIface[];
@@ -1,53 +0,0 @@
1
- import {
2
- ConversationKind,
3
- Delivery,
4
- ParticipantKind,
5
- RoutingMode
6
- } from "@finalai/agent-provider/room-surface";
7
- const MAX_AGENT_HOP_DEPTH = 2;
8
- const activeAgents = (participants) => participants.filter(
9
- (participant) => participant.kind === ParticipantKind.Agent && !participant.left
10
- );
11
- const effectiveDefaultAgent = (participants) => {
12
- const agents = activeAgents(participants);
13
- return agents.find((agent) => agent.routingMode === RoutingMode.Default) ?? agents.find((agent) => agent.routingMode === RoutingMode.All) ?? null;
14
- };
15
- const routeMessage = (args) => {
16
- const { conversation, message, participants } = args;
17
- const agents = activeAgents(participants).filter(
18
- (agent) => agent.id !== message.authorParticipantId && (message.agentAuthorDefinitionId == null || agent.definitionId !== message.agentAuthorDefinitionId)
19
- );
20
- if (agents.length === 0) {
21
- return [];
22
- }
23
- const mentioned = new Set(message.mentionedParticipantIds);
24
- const mayPrompt = message.hopDepth < MAX_AGENT_HOP_DEPTH;
25
- const promptDelivery = mayPrompt ? Delivery.Prompt : Delivery.Observe;
26
- if (conversation.kind === ConversationKind.Direct) {
27
- return agents.map((agent) => ({ participantId: agent.id, delivery: promptDelivery }));
28
- }
29
- const anyAgentMentioned = agents.some((agent) => mentioned.has(agent.id));
30
- const defaultAgent = effectiveDefaultAgent(participants);
31
- return agents.flatMap((agent) => {
32
- if (mentioned.has(agent.id)) {
33
- return [{ participantId: agent.id, delivery: promptDelivery }];
34
- }
35
- if (agent.routingMode === RoutingMode.Mention || agent.routingMode == null) {
36
- return [];
37
- }
38
- if (!anyAgentMentioned && agent.id === defaultAgent?.id) {
39
- return [{ participantId: agent.id, delivery: promptDelivery }];
40
- }
41
- return [{ participantId: agent.id, delivery: Delivery.Observe }];
42
- });
43
- };
44
- const routeToParticipant = (participantId) => (args) => args.participants.some(
45
- (participant) => participant.id === participantId && participant.kind === ParticipantKind.Agent && !participant.left
46
- ) ? [{ participantId, delivery: Delivery.Prompt }] : [];
47
- export {
48
- MAX_AGENT_HOP_DEPTH,
49
- effectiveDefaultAgent,
50
- routeMessage,
51
- routeToParticipant
52
- };
53
- //# sourceMappingURL=routing.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/channels/routing.ts"],
4
- "sourcesContent": ["import {\n ConversationKind,\n Delivery,\n ParticipantKind,\n RoutingMode,\n type ParticipantIface,\n type RouteArgsIface,\n type RouteDecisionIface,\n} from '@finalai/agent-provider/room-surface';\n\n// Agent-authored messages may prompt other agents only while the chain of\n// agent hops that produced them is shorter than this: a human\n// message (0) prompts A, A's reply (1) may prompt B, B's reply (2) prompts no one.\nexport const MAX_AGENT_HOP_DEPTH = 2;\n\nconst activeAgents = (participants: ParticipantIface[]): ParticipantIface[] =>\n participants.filter(\n (participant) => participant.kind === ParticipantKind.Agent && !participant.left,\n );\n\n// The agent a no-mention message goes to: the Default agent, else (no Default)\n// the earliest-joined All agent, which then acts as the Default. Participants\n// arrive in join order.\nexport const effectiveDefaultAgent = (\n participants: ParticipantIface[],\n): ParticipantIface | null => {\n const agents = activeAgents(participants);\n return (\n agents.find((agent) => agent.routingMode === RoutingMode.Default) ??\n agents.find((agent) => agent.routingMode === RoutingMode.All) ??\n null\n );\n};\n\n// Pure: who gets a message and how. Users never receive decisions.\nexport const routeMessage = (args: RouteArgsIface): RouteDecisionIface[] => {\n const { conversation, message, participants } = args;\n const agents = activeAgents(participants).filter(\n (agent) =>\n agent.id !== message.authorParticipantId &&\n (message.agentAuthorDefinitionId == null ||\n agent.definitionId !== message.agentAuthorDefinitionId),\n );\n if (agents.length === 0) {\n return [];\n }\n const mentioned = new Set(message.mentionedParticipantIds);\n const mayPrompt = message.hopDepth < MAX_AGENT_HOP_DEPTH;\n const promptDelivery = mayPrompt ? Delivery.Prompt : Delivery.Observe;\n\n if (conversation.kind === ConversationKind.Direct) {\n return agents.map((agent) => ({ participantId: agent.id, delivery: promptDelivery }));\n }\n\n const anyAgentMentioned = agents.some((agent) => mentioned.has(agent.id));\n const defaultAgent = effectiveDefaultAgent(participants);\n return agents.flatMap((agent): RouteDecisionIface[] => {\n if (mentioned.has(agent.id)) {\n return [{ participantId: agent.id, delivery: promptDelivery }];\n }\n if (agent.routingMode === RoutingMode.Mention || agent.routingMode == null) {\n return [];\n }\n if (!anyAgentMentioned && agent.id === defaultAgent?.id) {\n return [{ participantId: agent.id, delivery: promptDelivery }];\n }\n return [{ participantId: agent.id, delivery: Delivery.Observe }];\n });\n};\n\nexport const routeToParticipant =\n (participantId: string) =>\n (args: RouteArgsIface): RouteDecisionIface[] =>\n args.participants.some(\n (participant) =>\n participant.id === participantId &&\n participant.kind === ParticipantKind.Agent &&\n !participant.left,\n )\n ? [{ participantId, delivery: Delivery.Prompt }]\n : [];\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAKA,MAAM,sBAAsB;AAEnC,MAAM,eAAe,CAAC,iBACpB,aAAa;AAAA,EACX,CAAC,gBAAgB,YAAY,SAAS,gBAAgB,SAAS,CAAC,YAAY;AAC9E;AAKK,MAAM,wBAAwB,CACnC,iBAC4B;AAC5B,QAAM,SAAS,aAAa,YAAY;AACxC,SACE,OAAO,KAAK,CAAC,UAAU,MAAM,gBAAgB,YAAY,OAAO,KAChE,OAAO,KAAK,CAAC,U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SAAS,gBAAgB,SACrC,CAAC,YAAY;AACjB,IACI,CAAC,EAAE,eAAe,UAAU,SAAS,OAAO,CAAC,IAC7C,CAAC;",
6
- "names": []
7
- }
@@ -1,34 +0,0 @@
1
- export interface FinalPlatformAccessIface {
2
- baseUrl: string;
3
- token: string;
4
- }
5
- export type ComputersAccessIface = (args: {
6
- organizationId: string;
7
- projectId: string;
8
- refresh: boolean;
9
- }) => Promise<FinalPlatformAccessIface | null>;
10
- export type DeviceAccessIface = (args: {
11
- organizationId: string;
12
- projectId: string | null;
13
- actingUserId: string | null;
14
- refresh: boolean;
15
- }) => Promise<FinalPlatformAccessIface | null>;
16
- export interface ComputersApiCredentialsIface {
17
- computersAccess(args?: {
18
- refresh?: boolean;
19
- }): Promise<FinalPlatformAccessIface | null>;
20
- }
21
- export interface DeviceApiCredentialsIface {
22
- deviceAccess(args?: {
23
- actingUserId?: string | null;
24
- refresh?: boolean;
25
- }): Promise<FinalPlatformAccessIface | null>;
26
- }
27
- export declare const computersCredentialsFor: (access: ComputersAccessIface | undefined, scope: {
28
- organizationId: string;
29
- projectId: string;
30
- }) => ComputersApiCredentialsIface;
31
- export declare const deviceCredentialsFor: (access: DeviceAccessIface | undefined, scope: {
32
- organizationId: string;
33
- projectId: string | null;
34
- }) => DeviceApiCredentialsIface;
@@ -1,15 +0,0 @@
1
- const computersCredentialsFor = (access, scope) => ({
2
- computersAccess: async (args) => access == null ? null : access({ ...scope, refresh: args?.refresh === true })
3
- });
4
- const deviceCredentialsFor = (access, scope) => ({
5
- deviceAccess: async (args) => access == null ? null : access({
6
- ...scope,
7
- actingUserId: args?.actingUserId ?? null,
8
- refresh: args?.refresh === true
9
- })
10
- });
11
- export {
12
- computersCredentialsFor,
13
- deviceCredentialsFor
14
- };
15
- //# sourceMappingURL=access.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../../src/sandboxes/access.ts"],
4
- "sourcesContent": ["// Access to Final's Computers and Device APIs. It is configuration of the\n// `computer` and `device` providers (and of workspace Device egress), supplied\n// by whoever runs them, never part of the generic provider context.\n\nexport interface FinalPlatformAccessIface {\n // The API origin; requests go to `<baseUrl>/v1/...`.\n baseUrl: string;\n token: string;\n}\n\n// Computers API access for one project's sandboxes. `refresh` asks for a new\n// token after the API rejected the last one. Null: none granted.\nexport type ComputersAccessIface = (args: {\n organizationId: string;\n projectId: string;\n refresh: boolean;\n}) => Promise<FinalPlatformAccessIface | null>;\n\n// Device API access acting for `actingUserId` (null: service access for\n// workspace networking). Null: none granted.\nexport type DeviceAccessIface = (args: {\n organizationId: string;\n projectId: string | null;\n actingUserId: string | null;\n refresh: boolean;\n}) => Promise<FinalPlatformAccessIface | null>;\n\n// The per-call form the API clients ask before each request.\nexport interface ComputersApiCredentialsIface {\n computersAccess(args?: { refresh?: boolean }): Promise<FinalPlatformAccessIface | null>;\n}\n\nexport interface DeviceApiCredentialsIface {\n deviceAccess(args?: {\n actingUserId?: string | null;\n refresh?: boolean;\n }): Promise<FinalPlatformAccessIface | null>;\n}\n\nexport const computersCredentialsFor = (\n access: ComputersAccessIface | undefined,\n scope: { organizationId: string; projectId: string },\n): ComputersApiCredentialsIface => ({\n computersAccess: async (args) =>\n access == null ? null : access({ ...scope, refresh: args?.refresh === true }),\n});\n\nexport const deviceCredentialsFor = (\n access: DeviceAccessIface | undefined,\n scope: { organizationId: string; projectId: string | null },\n): DeviceApiCredentialsIface => ({\n deviceAccess: async (args) =>\n access == null\n ? null\n : access({\n ...scope,\n actingUserId: args?.actingUserId ?? null,\n refresh: args?.refresh === true,\n }),\n});\n"],
5
- "mappings": "AAuCO,MAAM,0BAA0B,CACrC,QACA,WACkC;AAAA,EAClC,iBAAiB,OAAO,SACtB,UAAU,OAAO,OAAO,OAAO,EAAE,GAAG,OAAO,SAAS,MAAM,YAAY,KAAK,CAAC;AAChF;AAEO,MAAM,uBAAuB,CAClC,QACA,WAC+B;AAAA,EAC/B,cAAc,OAAO,SACnB,UAAU,OACN,OACA,OAAO;AAAA,IACL,GAAG;AAAA,IACH,cAAc,MAAM,gBAAgB;AAAA,IACpC,SAAS,MAAM,YAAY;AAAA,EAC7B,CAAC;AACT;",
6
- "names": []
7
- }
@@ -1,3 +0,0 @@
1
- export declare const workspaceEgressBootstrap: string;
2
- export declare const cachedWorkspaceEgressBootstrap: (sha256: string) => string;
3
- export declare const workspaceEgressLauncher: string;