@finalai/agent-provider 0.1.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.
Potentially problematic release.
This version of @finalai/agent-provider might be problematic. Click here for more details.
- package/README.md +12 -0
- package/dist/modules/channel-context.d.mts +102 -0
- package/dist/modules/channel-context.mjs +52 -0
- package/dist/modules/channel-context.mjs.map +7 -0
- package/dist/modules/channel-socket.d.mts +65 -0
- package/dist/modules/channel-socket.mjs +188 -0
- package/dist/modules/channel-socket.mjs.map +7 -0
- package/dist/modules/channel.d.mts +382 -0
- package/dist/modules/channel.mjs +146 -0
- package/dist/modules/channel.mjs.map +7 -0
- package/dist/modules/conformance/agent.d.mts +20 -0
- package/dist/modules/conformance/agent.mjs +623 -0
- package/dist/modules/conformance/agent.mjs.map +7 -0
- package/dist/modules/conformance/fixtures.d.mts +41 -0
- package/dist/modules/conformance/fixtures.mjs +190 -0
- package/dist/modules/conformance/fixtures.mjs.map +7 -0
- package/dist/modules/conformance/harness-kit.d.mts +82 -0
- package/dist/modules/conformance/harness-kit.mjs +1303 -0
- package/dist/modules/conformance/harness-kit.mjs.map +7 -0
- package/dist/modules/conformance/image.d.mts +2 -0
- package/dist/modules/conformance/image.mjs +79 -0
- package/dist/modules/conformance/image.mjs.map +7 -0
- package/dist/modules/conformance/index.d.mts +8 -0
- package/dist/modules/conformance/index.mjs +12 -0
- package/dist/modules/conformance/index.mjs.map +7 -0
- package/dist/modules/conformance/local-harness.d.mts +25 -0
- package/dist/modules/conformance/local-harness.mjs +108 -0
- package/dist/modules/conformance/local-harness.mjs.map +7 -0
- package/dist/modules/conformance/protocol.d.mts +30 -0
- package/dist/modules/conformance/protocol.mjs +56 -0
- package/dist/modules/conformance/protocol.mjs.map +7 -0
- package/dist/modules/conformance/sandbox-kit.d.mts +19 -0
- package/dist/modules/conformance/sandbox-kit.mjs +320 -0
- package/dist/modules/conformance/sandbox-kit.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/chat-completions.d.mts +30 -0
- package/dist/modules/conformance/scripted-model/chat-completions.mjs +125 -0
- package/dist/modules/conformance/scripted-model/chat-completions.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/directives.d.mts +84 -0
- package/dist/modules/conformance/scripted-model/directives.mjs +304 -0
- package/dist/modules/conformance/scripted-model/directives.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/handler.d.mts +14 -0
- package/dist/modules/conformance/scripted-model/handler.mjs +133 -0
- package/dist/modules/conformance/scripted-model/handler.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/index.d.mts +6 -0
- package/dist/modules/conformance/scripted-model/index.mjs +7 -0
- package/dist/modules/conformance/scripted-model/index.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/messages.d.mts +39 -0
- package/dist/modules/conformance/scripted-model/messages.mjs +139 -0
- package/dist/modules/conformance/scripted-model/messages.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/responses.d.mts +62 -0
- package/dist/modules/conformance/scripted-model/responses.mjs +273 -0
- package/dist/modules/conformance/scripted-model/responses.mjs.map +7 -0
- package/dist/modules/conformance/scripted-model/sse.d.mts +15 -0
- package/dist/modules/conformance/scripted-model/sse.mjs +75 -0
- package/dist/modules/conformance/scripted-model/sse.mjs.map +7 -0
- package/dist/modules/conformance/v1-agent.d.mts +24 -0
- package/dist/modules/conformance/v1-agent.mjs +40 -0
- package/dist/modules/conformance/v1-agent.mjs.map +7 -0
- package/dist/modules/credential-routes.d.mts +24 -0
- package/dist/modules/credential-routes.mjs +25 -0
- package/dist/modules/credential-routes.mjs.map +7 -0
- package/dist/modules/credentials.d.mts +206 -0
- package/dist/modules/credentials.mjs +207 -0
- package/dist/modules/credentials.mjs.map +7 -0
- package/dist/modules/dynamic.d.mts +32 -0
- package/dist/modules/dynamic.mjs +77 -0
- package/dist/modules/dynamic.mjs.map +7 -0
- package/dist/modules/harness.d.mts +397 -0
- package/dist/modules/harness.mjs +213 -0
- package/dist/modules/harness.mjs.map +7 -0
- package/dist/modules/index.d.mts +15 -0
- package/dist/modules/index.mjs +40 -0
- package/dist/modules/index.mjs.map +7 -0
- package/dist/modules/json.d.mts +12 -0
- package/dist/modules/json.mjs +19 -0
- package/dist/modules/json.mjs.map +7 -0
- package/dist/modules/local-channel-socket.d.mts +23 -0
- package/dist/modules/local-channel-socket.mjs +141 -0
- package/dist/modules/local-channel-socket.mjs.map +7 -0
- package/dist/modules/manifest.d.mts +558 -0
- package/dist/modules/manifest.mjs +266 -0
- package/dist/modules/manifest.mjs.map +7 -0
- package/dist/modules/mcp-content.d.mts +21 -0
- package/dist/modules/mcp-content.mjs +86 -0
- package/dist/modules/mcp-content.mjs.map +7 -0
- package/dist/modules/provider-ref.d.mts +29 -0
- package/dist/modules/provider-ref.mjs +55 -0
- package/dist/modules/provider-ref.mjs.map +7 -0
- package/dist/modules/sandbox/bytes.d.mts +9 -0
- package/dist/modules/sandbox/bytes.mjs +154 -0
- package/dist/modules/sandbox/bytes.mjs.map +7 -0
- package/dist/modules/sandbox/client.d.mts +51 -0
- package/dist/modules/sandbox/client.mjs +500 -0
- package/dist/modules/sandbox/client.mjs.map +7 -0
- package/dist/modules/sandbox/confined-files.d.mts +22 -0
- package/dist/modules/sandbox/confined-files.mjs +142 -0
- package/dist/modules/sandbox/confined-files.mjs.map +7 -0
- package/dist/modules/sandbox/convenience.d.mts +10 -0
- package/dist/modules/sandbox/convenience.mjs +116 -0
- package/dist/modules/sandbox/convenience.mjs.map +7 -0
- package/dist/modules/sandbox/editor.d.mts +49 -0
- package/dist/modules/sandbox/editor.mjs +43 -0
- package/dist/modules/sandbox/editor.mjs.map +7 -0
- package/dist/modules/sandbox/frame-channel.d.mts +47 -0
- package/dist/modules/sandbox/frame-channel.mjs +153 -0
- package/dist/modules/sandbox/frame-channel.mjs.map +7 -0
- package/dist/modules/sandbox/index.d.mts +18 -0
- package/dist/modules/sandbox/index.mjs +70 -0
- package/dist/modules/sandbox/index.mjs.map +7 -0
- package/dist/modules/sandbox/mcp-channel.d.mts +9 -0
- package/dist/modules/sandbox/mcp-channel.mjs +77 -0
- package/dist/modules/sandbox/mcp-channel.mjs.map +7 -0
- package/dist/modules/sandbox/mcp-hosted.d.mts +46 -0
- package/dist/modules/sandbox/mcp-hosted.mjs +221 -0
- package/dist/modules/sandbox/mcp-hosted.mjs.map +7 -0
- package/dist/modules/sandbox/mcp-search.d.mts +51 -0
- package/dist/modules/sandbox/mcp-search.mjs +129 -0
- package/dist/modules/sandbox/mcp-search.mjs.map +7 -0
- package/dist/modules/sandbox/mcp-shell.d.mts +21 -0
- package/dist/modules/sandbox/mcp-shell.mjs +205 -0
- package/dist/modules/sandbox/mcp-shell.mjs.map +7 -0
- package/dist/modules/sandbox/mcp-testing.d.mts +11 -0
- package/dist/modules/sandbox/mcp-testing.mjs +33 -0
- package/dist/modules/sandbox/mcp-testing.mjs.map +7 -0
- package/dist/modules/sandbox/mcp.d.mts +83 -0
- package/dist/modules/sandbox/mcp.mjs +971 -0
- package/dist/modules/sandbox/mcp.mjs.map +7 -0
- package/dist/modules/sandbox/memory-sandbox.d.mts +32 -0
- package/dist/modules/sandbox/memory-sandbox.mjs +416 -0
- package/dist/modules/sandbox/memory-sandbox.mjs.map +7 -0
- package/dist/modules/sandbox/memory-shell.d.mts +29 -0
- package/dist/modules/sandbox/memory-shell.mjs +278 -0
- package/dist/modules/sandbox/memory-shell.mjs.map +7 -0
- package/dist/modules/sandbox/open-scope-node.d.mts +4 -0
- package/dist/modules/sandbox/open-scope-node.mjs +19 -0
- package/dist/modules/sandbox/open-scope-node.mjs.map +7 -0
- package/dist/modules/sandbox/open-scope.d.mts +16 -0
- package/dist/modules/sandbox/open-scope.mjs +66 -0
- package/dist/modules/sandbox/open-scope.mjs.map +7 -0
- package/dist/modules/sandbox/paths.d.mts +7 -0
- package/dist/modules/sandbox/paths.mjs +50 -0
- package/dist/modules/sandbox/paths.mjs.map +7 -0
- package/dist/modules/sandbox/rpc-peer.d.mts +35 -0
- package/dist/modules/sandbox/rpc-peer.mjs +224 -0
- package/dist/modules/sandbox/rpc-peer.mjs.map +7 -0
- package/dist/modules/sandbox/seeds.d.mts +26 -0
- package/dist/modules/sandbox/seeds.mjs +228 -0
- package/dist/modules/sandbox/seeds.mjs.map +7 -0
- package/dist/modules/sandbox/server.d.mts +66 -0
- package/dist/modules/sandbox/server.mjs +567 -0
- package/dist/modules/sandbox/server.mjs.map +7 -0
- package/dist/modules/sandbox/snapshots.d.mts +49 -0
- package/dist/modules/sandbox/snapshots.mjs +55 -0
- package/dist/modules/sandbox/snapshots.mjs.map +7 -0
- package/dist/modules/sandbox/stream-mux.d.mts +18 -0
- package/dist/modules/sandbox/stream-mux.mjs +285 -0
- package/dist/modules/sandbox/stream-mux.mjs.map +7 -0
- package/dist/modules/sandbox/testing.d.mts +25 -0
- package/dist/modules/sandbox/testing.mjs +64 -0
- package/dist/modules/sandbox/testing.mjs.map +7 -0
- package/dist/modules/sandbox/types.d.mts +352 -0
- package/dist/modules/sandbox/types.mjs +86 -0
- package/dist/modules/sandbox/types.mjs.map +7 -0
- package/dist/modules/sandbox/wire.d.mts +671 -0
- package/dist/modules/sandbox/wire.mjs +537 -0
- package/dist/modules/sandbox/wire.mjs.map +7 -0
- package/dist/modules/sandbox/workspace-root.d.mts +8 -0
- package/dist/modules/sandbox/workspace-root.mjs +79 -0
- package/dist/modules/sandbox/workspace-root.mjs.map +7 -0
- package/dist/modules/schemas.d.mts +121 -0
- package/dist/modules/schemas.mjs +146 -0
- package/dist/modules/schemas.mjs.map +7 -0
- package/dist/modules/semantic-events.d.mts +31 -0
- package/dist/modules/semantic-events.mjs +23 -0
- package/dist/modules/semantic-events.mjs.map +7 -0
- package/package.json +199 -0
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';
|
|
2
|
+
import * as z from 'zod';
|
|
3
|
+
import type { ChannelSessionOperationsIface } from "./channel-context.mjs";
|
|
4
|
+
import { type JsonObject, type JsonValue } from "./json.mjs";
|
|
5
|
+
import type { ProviderRef } from "./provider-ref.mjs";
|
|
6
|
+
import type { SemanticChannelEventKind } from "./semantic-events.mjs";
|
|
7
|
+
export declare enum ConversationKind {
|
|
8
|
+
Direct = "direct",
|
|
9
|
+
Group = "group"
|
|
10
|
+
}
|
|
11
|
+
export declare enum ParticipantKind {
|
|
12
|
+
User = "user",
|
|
13
|
+
Agent = "agent",
|
|
14
|
+
System = "system"
|
|
15
|
+
}
|
|
16
|
+
export declare enum SystemParticipantKind {
|
|
17
|
+
Schedule = "schedule",
|
|
18
|
+
Webhook = "webhook",
|
|
19
|
+
Goal = "goal",
|
|
20
|
+
Tool = "tool",
|
|
21
|
+
ApiKey = "api-key"
|
|
22
|
+
}
|
|
23
|
+
export declare enum RoutingMode {
|
|
24
|
+
Mention = "mention",
|
|
25
|
+
All = "all",
|
|
26
|
+
Default = "default"
|
|
27
|
+
}
|
|
28
|
+
export declare enum TurnPolicy {
|
|
29
|
+
Steer = "steer",
|
|
30
|
+
Queue = "queue"
|
|
31
|
+
}
|
|
32
|
+
export declare enum Delivery {
|
|
33
|
+
Prompt = "prompt",
|
|
34
|
+
Observe = "observe"
|
|
35
|
+
}
|
|
36
|
+
export declare enum MessageKind {
|
|
37
|
+
Message = "message",
|
|
38
|
+
System = "system",
|
|
39
|
+
Card = "card"
|
|
40
|
+
}
|
|
41
|
+
export declare enum CardKind {
|
|
42
|
+
Elicitation = "elicitation",
|
|
43
|
+
Permission = "permission",
|
|
44
|
+
Notice = "notice"
|
|
45
|
+
}
|
|
46
|
+
export interface ParticipantIface {
|
|
47
|
+
id: string;
|
|
48
|
+
kind: ParticipantKind;
|
|
49
|
+
displayName: string;
|
|
50
|
+
userId: string | null;
|
|
51
|
+
servicePrincipalId?: string | null;
|
|
52
|
+
definitionId: string | null;
|
|
53
|
+
systemKind: SystemParticipantKind | null;
|
|
54
|
+
routingMode: RoutingMode | null;
|
|
55
|
+
sessionId: string | null;
|
|
56
|
+
supportsObserve: boolean | null;
|
|
57
|
+
rendersAuthorMeta: boolean | null;
|
|
58
|
+
left: boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare const channelReceiveResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
61
|
+
conversationId: z.ZodString;
|
|
62
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
63
|
+
sessionId: z.ZodString;
|
|
64
|
+
}, z.core.$strip>, z.ZodNull]>;
|
|
65
|
+
export type ChannelReceiveResult = z.infer<typeof channelReceiveResultSchema>;
|
|
66
|
+
export interface ConversationRefIface {
|
|
67
|
+
conversationId: string;
|
|
68
|
+
}
|
|
69
|
+
export interface ConversationIface extends ConversationRefIface {
|
|
70
|
+
organizationId: string;
|
|
71
|
+
kind: ConversationKind;
|
|
72
|
+
title: string | null;
|
|
73
|
+
isHome: boolean;
|
|
74
|
+
turnPolicy: TurnPolicy;
|
|
75
|
+
}
|
|
76
|
+
export interface MessageRefIface {
|
|
77
|
+
messageId: string;
|
|
78
|
+
seq: number;
|
|
79
|
+
}
|
|
80
|
+
export interface ConversationMessageIface extends MessageRefIface {
|
|
81
|
+
conversationId: string;
|
|
82
|
+
authorParticipantId: string;
|
|
83
|
+
kind: MessageKind;
|
|
84
|
+
body: string;
|
|
85
|
+
content: ContentBlock[];
|
|
86
|
+
replyToMessageId: string | null;
|
|
87
|
+
threadRootId: string | null;
|
|
88
|
+
quotedMessageIds: string[];
|
|
89
|
+
mentionedParticipantIds: string[];
|
|
90
|
+
hopDepth: number;
|
|
91
|
+
agentAuthorDefinitionId?: string | null;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
}
|
|
94
|
+
export interface RouteArgsIface {
|
|
95
|
+
conversation: ConversationIface;
|
|
96
|
+
message: ConversationMessageIface;
|
|
97
|
+
participants: ParticipantIface[];
|
|
98
|
+
agentParticipantId?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface RouteDecisionIface {
|
|
101
|
+
participantId: string;
|
|
102
|
+
delivery: Delivery;
|
|
103
|
+
}
|
|
104
|
+
export interface PostMessageArgsIface {
|
|
105
|
+
conversationId: string;
|
|
106
|
+
authorParticipantId: string;
|
|
107
|
+
kind?: MessageKind;
|
|
108
|
+
content: ContentBlock[];
|
|
109
|
+
replyToMessageId?: string | null;
|
|
110
|
+
threadRootId?: string | null;
|
|
111
|
+
quotedMessageIds?: string[];
|
|
112
|
+
clientMessageId?: string | null;
|
|
113
|
+
mentionedParticipantIds?: string[];
|
|
114
|
+
attachmentIds?: string[];
|
|
115
|
+
hopDepth?: number;
|
|
116
|
+
originTurnId?: string | null;
|
|
117
|
+
source?: {
|
|
118
|
+
turnId: string;
|
|
119
|
+
fromSeq: number;
|
|
120
|
+
toSeq: number;
|
|
121
|
+
} | null;
|
|
122
|
+
}
|
|
123
|
+
export declare const channelMessageInputSchema: z.ZodObject<{
|
|
124
|
+
conversationId: z.ZodString;
|
|
125
|
+
authorParticipantId: z.ZodString;
|
|
126
|
+
kind: z.ZodDefault<z.ZodEnum<typeof MessageKind>>;
|
|
127
|
+
content: z.ZodArray<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
128
|
+
clientMessageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
129
|
+
replyToMessageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
130
|
+
threadRootId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
131
|
+
quotedMessageIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
132
|
+
mentionedParticipantIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
export interface CardArgsIface {
|
|
135
|
+
conversationId: string;
|
|
136
|
+
authorParticipantId: string;
|
|
137
|
+
kind: CardKind;
|
|
138
|
+
pendingRequestId: string | null;
|
|
139
|
+
state: JsonObject;
|
|
140
|
+
entityLinks: {
|
|
141
|
+
kind: string;
|
|
142
|
+
id: string;
|
|
143
|
+
title?: string;
|
|
144
|
+
url?: string;
|
|
145
|
+
description?: string;
|
|
146
|
+
imageUrl?: string;
|
|
147
|
+
}[];
|
|
148
|
+
}
|
|
149
|
+
export interface PromptArgsIface {
|
|
150
|
+
waitForAcceptance?: boolean;
|
|
151
|
+
channelBinding?: {
|
|
152
|
+
id: string;
|
|
153
|
+
revisionId: string;
|
|
154
|
+
};
|
|
155
|
+
auth?: JsonObject | null;
|
|
156
|
+
title?: string;
|
|
157
|
+
participantId: string;
|
|
158
|
+
content: ContentBlock[];
|
|
159
|
+
turnPolicy: TurnPolicy;
|
|
160
|
+
replyExpected: boolean;
|
|
161
|
+
idempotencyKey: string;
|
|
162
|
+
authorParticipantId: string;
|
|
163
|
+
audienceParticipantIds: string[];
|
|
164
|
+
sourceMessageId: string;
|
|
165
|
+
}
|
|
166
|
+
export interface ObserveArgsIface {
|
|
167
|
+
participantId: string;
|
|
168
|
+
content: ContentBlock[];
|
|
169
|
+
idempotencyKey: string;
|
|
170
|
+
}
|
|
171
|
+
export interface ChannelPlatformIface {
|
|
172
|
+
channelSessions?: ChannelSessionOperationsIface;
|
|
173
|
+
conversations: {
|
|
174
|
+
get(conversationId: string): Promise<ConversationIface | null>;
|
|
175
|
+
createAttachmentUpload?(args: {
|
|
176
|
+
conversationId: string;
|
|
177
|
+
name: string;
|
|
178
|
+
contentType: string;
|
|
179
|
+
sizeBytes: number;
|
|
180
|
+
}): Promise<{
|
|
181
|
+
attachmentId: string;
|
|
182
|
+
uploadUrl: string;
|
|
183
|
+
method: string;
|
|
184
|
+
headers: Record<string, string>;
|
|
185
|
+
expiresAt: string;
|
|
186
|
+
}>;
|
|
187
|
+
getAttachmentUrl?(args: {
|
|
188
|
+
conversationId: string;
|
|
189
|
+
attachmentId: string;
|
|
190
|
+
}): Promise<{
|
|
191
|
+
attachmentId: string;
|
|
192
|
+
url: string;
|
|
193
|
+
expiresAt: string;
|
|
194
|
+
}>;
|
|
195
|
+
dispatchMessage?(args: {
|
|
196
|
+
conversationId: string;
|
|
197
|
+
messageId: string;
|
|
198
|
+
participantId?: string;
|
|
199
|
+
requestedDelivery?: Delivery;
|
|
200
|
+
}): Promise<void>;
|
|
201
|
+
findOrCreateDirect(args: {
|
|
202
|
+
organizationId: string;
|
|
203
|
+
userId: string;
|
|
204
|
+
definitionId: string;
|
|
205
|
+
}): Promise<ConversationIface>;
|
|
206
|
+
boundTo(bindingId: string): Promise<ConversationIface | null>;
|
|
207
|
+
participants(conversationId: string): Promise<ParticipantIface[]>;
|
|
208
|
+
systemParticipant(args: {
|
|
209
|
+
conversationId: string;
|
|
210
|
+
systemKind: SystemParticipantKind;
|
|
211
|
+
displayName: string;
|
|
212
|
+
sourceRef: string;
|
|
213
|
+
}): Promise<ParticipantIface>;
|
|
214
|
+
postMessage(args: PostMessageArgsIface): Promise<ConversationMessageIface>;
|
|
215
|
+
updateMessage(args: {
|
|
216
|
+
messageId: string;
|
|
217
|
+
content: ContentBlock[];
|
|
218
|
+
final: boolean;
|
|
219
|
+
}): Promise<void>;
|
|
220
|
+
postCard(args: CardArgsIface): Promise<ConversationMessageIface>;
|
|
221
|
+
updateCard(args: {
|
|
222
|
+
messageId: string;
|
|
223
|
+
state: JsonObject;
|
|
224
|
+
}): Promise<void>;
|
|
225
|
+
recentMessages(args: {
|
|
226
|
+
conversationId: string;
|
|
227
|
+
limit: number;
|
|
228
|
+
beforeSeq?: number;
|
|
229
|
+
afterSeq?: number;
|
|
230
|
+
}): Promise<ConversationMessageIface[]>;
|
|
231
|
+
getMessages(args: {
|
|
232
|
+
conversationId: string;
|
|
233
|
+
messageIds: string[];
|
|
234
|
+
}): Promise<ConversationMessageIface[]>;
|
|
235
|
+
};
|
|
236
|
+
sessions: {
|
|
237
|
+
prompt(args: PromptArgsIface): Promise<{
|
|
238
|
+
messageId: string;
|
|
239
|
+
sessionId?: string;
|
|
240
|
+
turnId?: string;
|
|
241
|
+
}>;
|
|
242
|
+
observe(args: ObserveArgsIface): Promise<void>;
|
|
243
|
+
cancel(args: {
|
|
244
|
+
participantId: string;
|
|
245
|
+
reason?: string;
|
|
246
|
+
throughMessageSeq?: number;
|
|
247
|
+
}): Promise<void>;
|
|
248
|
+
respond?(args: ChannelInputResponseIface): Promise<{
|
|
249
|
+
resolved: boolean;
|
|
250
|
+
}>;
|
|
251
|
+
};
|
|
252
|
+
log(message: string, details?: Record<string, JsonValue>): void;
|
|
253
|
+
}
|
|
254
|
+
export interface ChannelInputResponseIface {
|
|
255
|
+
channelBinding?: {
|
|
256
|
+
id: string;
|
|
257
|
+
revisionId: string;
|
|
258
|
+
};
|
|
259
|
+
auth?: JsonObject | null;
|
|
260
|
+
participantId: string;
|
|
261
|
+
pendingId: string;
|
|
262
|
+
outcome: JsonValue;
|
|
263
|
+
actorParticipantId: string;
|
|
264
|
+
userId: string | null;
|
|
265
|
+
apiKeyId: string | null;
|
|
266
|
+
}
|
|
267
|
+
export interface ChannelReceiveContextIface {
|
|
268
|
+
platform: ChannelPlatformIface;
|
|
269
|
+
organizationId: string;
|
|
270
|
+
definitionId: string | null;
|
|
271
|
+
bindingId: string | null;
|
|
272
|
+
config: JsonObject;
|
|
273
|
+
secrets: {
|
|
274
|
+
get(name: string): Promise<string | null>;
|
|
275
|
+
};
|
|
276
|
+
agentParticipantId?: string;
|
|
277
|
+
message?: ConversationMessageIface;
|
|
278
|
+
conversation?: ConversationIface;
|
|
279
|
+
participants?: readonly ParticipantIface[];
|
|
280
|
+
response?: ChannelInputResponseIface;
|
|
281
|
+
conversationId?: string;
|
|
282
|
+
cancelReason?: string;
|
|
283
|
+
cancelThroughMessageSeq?: number;
|
|
284
|
+
requestedDelivery?: Delivery;
|
|
285
|
+
}
|
|
286
|
+
export interface ChannelRouteContextIface {
|
|
287
|
+
request: Request;
|
|
288
|
+
secrets: {
|
|
289
|
+
get(name: string): Promise<string | null>;
|
|
290
|
+
};
|
|
291
|
+
receive: (input: JsonValue) => Promise<ChannelReceiveResult>;
|
|
292
|
+
}
|
|
293
|
+
export interface ChannelSocketIface {
|
|
294
|
+
readonly signal: AbortSignal;
|
|
295
|
+
readonly messages: AsyncIterable<string | Uint8Array>;
|
|
296
|
+
accept(options?: {
|
|
297
|
+
protocol?: string;
|
|
298
|
+
}): void;
|
|
299
|
+
send(data: string | Uint8Array): void;
|
|
300
|
+
close(code?: number, reason?: string): void;
|
|
301
|
+
}
|
|
302
|
+
export interface HttpChannelRouteDefinitionIface {
|
|
303
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
304
|
+
path: string;
|
|
305
|
+
handler: (args: ChannelRouteContextIface) => Promise<Response>;
|
|
306
|
+
}
|
|
307
|
+
export interface WebSocketChannelRouteDefinitionIface {
|
|
308
|
+
method: 'WS';
|
|
309
|
+
path: string;
|
|
310
|
+
handler: (args: ChannelRouteContextIface & {
|
|
311
|
+
socket: ChannelSocketIface;
|
|
312
|
+
}) => Promise<Response | void>;
|
|
313
|
+
}
|
|
314
|
+
export type RouteDefinitionIface = HttpChannelRouteDefinitionIface | WebSocketChannelRouteDefinitionIface;
|
|
315
|
+
export interface ChannelTurnStateIface<State> {
|
|
316
|
+
get(): State | null;
|
|
317
|
+
set(state: State | null): void;
|
|
318
|
+
}
|
|
319
|
+
export interface ProjectionContextIface<State = JsonValue> {
|
|
320
|
+
sessionId?: string;
|
|
321
|
+
platform: ChannelPlatformIface;
|
|
322
|
+
conversation: ConversationIface | null;
|
|
323
|
+
agentParticipant: ParticipantIface | null;
|
|
324
|
+
turn: {
|
|
325
|
+
id: string;
|
|
326
|
+
promptMessageId: string | null;
|
|
327
|
+
authorParticipantId: string | null;
|
|
328
|
+
};
|
|
329
|
+
seq: number;
|
|
330
|
+
state: ChannelTurnStateIface<State>;
|
|
331
|
+
}
|
|
332
|
+
export declare enum PendingEventKind {
|
|
333
|
+
Created = "pending.created",
|
|
334
|
+
Resolved = "pending.resolved"
|
|
335
|
+
}
|
|
336
|
+
export type AcpUpdateKind = SessionUpdate['sessionUpdate'];
|
|
337
|
+
export type ChannelEventKind = AcpUpdateKind | `${PendingEventKind}` | `${SemanticChannelEventKind}`;
|
|
338
|
+
export interface ChannelEventIface {
|
|
339
|
+
type: string;
|
|
340
|
+
data: JsonValue;
|
|
341
|
+
seq: number;
|
|
342
|
+
}
|
|
343
|
+
export type ChannelEventHandler<State = JsonValue> = (event: ChannelEventIface, ctx: ProjectionContextIface<State>) => Promise<void>;
|
|
344
|
+
export declare enum PendingKind {
|
|
345
|
+
Permission = "permission",
|
|
346
|
+
Elicitation = "elicitation"
|
|
347
|
+
}
|
|
348
|
+
export declare const pendingCreatedDataSchema: z.ZodObject<{
|
|
349
|
+
pendingRequestId: z.ZodString;
|
|
350
|
+
kind: z.ZodEnum<typeof PendingKind>;
|
|
351
|
+
audienceParticipantIds: z.ZodArray<z.ZodString>;
|
|
352
|
+
request: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
353
|
+
}, z.core.$strip>;
|
|
354
|
+
export type PendingCreatedDataIface = z.infer<typeof pendingCreatedDataSchema>;
|
|
355
|
+
export declare const pendingResolvedDataSchema: z.ZodObject<{
|
|
356
|
+
pendingRequestId: z.ZodString;
|
|
357
|
+
outcome: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
358
|
+
}, z.core.$strip>;
|
|
359
|
+
export type PendingResolvedDataIface = z.infer<typeof pendingResolvedDataSchema>;
|
|
360
|
+
export declare const PROJECTED_UPDATE_KINDS: ReadonlySet<AcpUpdateKind>;
|
|
361
|
+
export declare const turnEndOf: (update: SessionUpdate) => {
|
|
362
|
+
stopReason: string | null;
|
|
363
|
+
} | null;
|
|
364
|
+
export declare const turnEndUpdate: (stopReason: string | null) => SessionUpdate;
|
|
365
|
+
export interface ChannelDefinitionIface<Inbound, State = undefined> {
|
|
366
|
+
config?: JsonObject;
|
|
367
|
+
installed?: ProviderRef;
|
|
368
|
+
configure?: (config: JsonObject) => ChannelDefinitionIface<Inbound, State>;
|
|
369
|
+
routes?: RouteDefinitionIface[];
|
|
370
|
+
respond?(input: ChannelInputResponseIface, ctx: ChannelReceiveContextIface): Promise<{
|
|
371
|
+
resolved: boolean;
|
|
372
|
+
}>;
|
|
373
|
+
cancel?(ctx: ChannelReceiveContextIface): Promise<{
|
|
374
|
+
accepted: boolean;
|
|
375
|
+
}>;
|
|
376
|
+
receive(input: Inbound, ctx: ChannelReceiveContextIface): Promise<ChannelReceiveResult>;
|
|
377
|
+
route(args: RouteArgsIface): RouteDecisionIface[] | Promise<RouteDecisionIface[]>;
|
|
378
|
+
turnPolicy: TurnPolicy;
|
|
379
|
+
project(update: SessionUpdate, ctx: ProjectionContextIface<State>): Promise<void>;
|
|
380
|
+
events?: Partial<Record<ChannelEventKind, ChannelEventHandler<State>>>;
|
|
381
|
+
}
|
|
382
|
+
export declare const defineChannel: <Inbound, State = undefined>(definition: ChannelDefinitionIface<Inbound, State>) => ChannelDefinitionIface<Inbound, State>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { jsonObjectSchema, jsonValueSchema } from "./json.mjs";
|
|
3
|
+
var ConversationKind = /* @__PURE__ */ ((ConversationKind2) => {
|
|
4
|
+
ConversationKind2["Direct"] = "direct";
|
|
5
|
+
ConversationKind2["Group"] = "group";
|
|
6
|
+
return ConversationKind2;
|
|
7
|
+
})(ConversationKind || {});
|
|
8
|
+
var ParticipantKind = /* @__PURE__ */ ((ParticipantKind2) => {
|
|
9
|
+
ParticipantKind2["User"] = "user";
|
|
10
|
+
ParticipantKind2["Agent"] = "agent";
|
|
11
|
+
ParticipantKind2["System"] = "system";
|
|
12
|
+
return ParticipantKind2;
|
|
13
|
+
})(ParticipantKind || {});
|
|
14
|
+
var SystemParticipantKind = /* @__PURE__ */ ((SystemParticipantKind2) => {
|
|
15
|
+
SystemParticipantKind2["Schedule"] = "schedule";
|
|
16
|
+
SystemParticipantKind2["Webhook"] = "webhook";
|
|
17
|
+
SystemParticipantKind2["Goal"] = "goal";
|
|
18
|
+
SystemParticipantKind2["Tool"] = "tool";
|
|
19
|
+
SystemParticipantKind2["ApiKey"] = "api-key";
|
|
20
|
+
return SystemParticipantKind2;
|
|
21
|
+
})(SystemParticipantKind || {});
|
|
22
|
+
var RoutingMode = /* @__PURE__ */ ((RoutingMode2) => {
|
|
23
|
+
RoutingMode2["Mention"] = "mention";
|
|
24
|
+
RoutingMode2["All"] = "all";
|
|
25
|
+
RoutingMode2["Default"] = "default";
|
|
26
|
+
return RoutingMode2;
|
|
27
|
+
})(RoutingMode || {});
|
|
28
|
+
var TurnPolicy = /* @__PURE__ */ ((TurnPolicy2) => {
|
|
29
|
+
TurnPolicy2["Steer"] = "steer";
|
|
30
|
+
TurnPolicy2["Queue"] = "queue";
|
|
31
|
+
return TurnPolicy2;
|
|
32
|
+
})(TurnPolicy || {});
|
|
33
|
+
var Delivery = /* @__PURE__ */ ((Delivery2) => {
|
|
34
|
+
Delivery2["Prompt"] = "prompt";
|
|
35
|
+
Delivery2["Observe"] = "observe";
|
|
36
|
+
return Delivery2;
|
|
37
|
+
})(Delivery || {});
|
|
38
|
+
var MessageKind = /* @__PURE__ */ ((MessageKind2) => {
|
|
39
|
+
MessageKind2["Message"] = "message";
|
|
40
|
+
MessageKind2["System"] = "system";
|
|
41
|
+
MessageKind2["Card"] = "card";
|
|
42
|
+
return MessageKind2;
|
|
43
|
+
})(MessageKind || {});
|
|
44
|
+
var CardKind = /* @__PURE__ */ ((CardKind2) => {
|
|
45
|
+
CardKind2["Elicitation"] = "elicitation";
|
|
46
|
+
CardKind2["Permission"] = "permission";
|
|
47
|
+
CardKind2["Notice"] = "notice";
|
|
48
|
+
return CardKind2;
|
|
49
|
+
})(CardKind || {});
|
|
50
|
+
const channelReceiveResultSchema = z.union([
|
|
51
|
+
z.object({ conversationId: z.string().min(1) }),
|
|
52
|
+
z.object({ sessionId: z.string().min(1) }),
|
|
53
|
+
z.null()
|
|
54
|
+
]);
|
|
55
|
+
const channelMessageInputSchema = z.object({
|
|
56
|
+
conversationId: z.string().min(1),
|
|
57
|
+
authorParticipantId: z.string().min(1),
|
|
58
|
+
kind: z.nativeEnum(MessageKind).default("message" /* Message */),
|
|
59
|
+
content: z.array(jsonObjectSchema).min(1),
|
|
60
|
+
clientMessageId: z.string().min(1).nullish(),
|
|
61
|
+
replyToMessageId: z.string().min(1).nullish(),
|
|
62
|
+
threadRootId: z.string().min(1).nullish(),
|
|
63
|
+
quotedMessageIds: z.array(z.string().min(1)).default([]),
|
|
64
|
+
mentionedParticipantIds: z.array(z.string().min(1)).default([])
|
|
65
|
+
});
|
|
66
|
+
var PendingEventKind = /* @__PURE__ */ ((PendingEventKind2) => {
|
|
67
|
+
PendingEventKind2["Created"] = "pending.created";
|
|
68
|
+
PendingEventKind2["Resolved"] = "pending.resolved";
|
|
69
|
+
return PendingEventKind2;
|
|
70
|
+
})(PendingEventKind || {});
|
|
71
|
+
var PendingKind = /* @__PURE__ */ ((PendingKind2) => {
|
|
72
|
+
PendingKind2["Permission"] = "permission";
|
|
73
|
+
PendingKind2["Elicitation"] = "elicitation";
|
|
74
|
+
return PendingKind2;
|
|
75
|
+
})(PendingKind || {});
|
|
76
|
+
const pendingCreatedDataSchema = z.object({
|
|
77
|
+
pendingRequestId: z.string().min(1),
|
|
78
|
+
kind: z.nativeEnum(PendingKind),
|
|
79
|
+
audienceParticipantIds: z.array(z.string()),
|
|
80
|
+
request: jsonValueSchema
|
|
81
|
+
});
|
|
82
|
+
const pendingResolvedDataSchema = z.object({
|
|
83
|
+
pendingRequestId: z.string().min(1),
|
|
84
|
+
outcome: jsonValueSchema
|
|
85
|
+
});
|
|
86
|
+
const PROJECTED_UPDATE_KINDS = /* @__PURE__ */ new Set([
|
|
87
|
+
"agent_message_chunk",
|
|
88
|
+
"agent_message"
|
|
89
|
+
]);
|
|
90
|
+
const turnEndSchema = z.looseObject({
|
|
91
|
+
sessionUpdate: z.literal("state_update"),
|
|
92
|
+
state: z.literal("idle"),
|
|
93
|
+
stopReason: z.string().nullish(),
|
|
94
|
+
_meta: z.looseObject({ "final.ai": z.looseObject({ stopReason: z.string().nullish() }).nullish() }).nullish()
|
|
95
|
+
});
|
|
96
|
+
const turnEndOf = (update) => {
|
|
97
|
+
const parsed = turnEndSchema.safeParse(update);
|
|
98
|
+
if (!parsed.success) return null;
|
|
99
|
+
return {
|
|
100
|
+
stopReason: parsed.data.stopReason ?? parsed.data._meta?.["final.ai"]?.stopReason ?? null
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
const turnEndUpdate = (stopReason) => {
|
|
104
|
+
switch (stopReason) {
|
|
105
|
+
case null:
|
|
106
|
+
return { sessionUpdate: "state_update", state: "idle" };
|
|
107
|
+
case "end_turn":
|
|
108
|
+
return { sessionUpdate: "state_update", state: "idle", stopReason: "end_turn" };
|
|
109
|
+
case "max_tokens":
|
|
110
|
+
return { sessionUpdate: "state_update", state: "idle", stopReason: "max_tokens" };
|
|
111
|
+
case "max_turn_requests":
|
|
112
|
+
return { sessionUpdate: "state_update", state: "idle", stopReason: "max_turn_requests" };
|
|
113
|
+
case "refusal":
|
|
114
|
+
return { sessionUpdate: "state_update", state: "idle", stopReason: "refusal" };
|
|
115
|
+
case "cancelled":
|
|
116
|
+
return { sessionUpdate: "state_update", state: "idle", stopReason: "cancelled" };
|
|
117
|
+
default:
|
|
118
|
+
return {
|
|
119
|
+
sessionUpdate: "state_update",
|
|
120
|
+
state: "idle",
|
|
121
|
+
_meta: { "final.ai": { stopReason } }
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const defineChannel = (definition) => definition;
|
|
126
|
+
export {
|
|
127
|
+
CardKind,
|
|
128
|
+
ConversationKind,
|
|
129
|
+
Delivery,
|
|
130
|
+
MessageKind,
|
|
131
|
+
PROJECTED_UPDATE_KINDS,
|
|
132
|
+
ParticipantKind,
|
|
133
|
+
PendingEventKind,
|
|
134
|
+
PendingKind,
|
|
135
|
+
RoutingMode,
|
|
136
|
+
SystemParticipantKind,
|
|
137
|
+
TurnPolicy,
|
|
138
|
+
channelMessageInputSchema,
|
|
139
|
+
channelReceiveResultSchema,
|
|
140
|
+
defineChannel,
|
|
141
|
+
pendingCreatedDataSchema,
|
|
142
|
+
pendingResolvedDataSchema,
|
|
143
|
+
turnEndOf,
|
|
144
|
+
turnEndUpdate
|
|
145
|
+
};
|
|
146
|
+
//# sourceMappingURL=channel.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/channel.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport type { ChannelSessionOperationsIface } from \"./channel-context.mjs\";\nimport { jsonObjectSchema, jsonValueSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { ProviderRef } from \"./provider-ref.mjs\";\nimport type { SemanticChannelEventKind } from \"./semantic-events.mjs\";\n\n// Channels. Messaging has no orchestrator: a channel\n// receives input, inserts it into the conversation, routes it to agent\n// participants as ACP prompt or observe, and projects ACP updates back into\n// visible messages and cards. The built-in messaging channels implement this\n// contract with no private hooks into the session service; the session\n// service hands every channel the same ChannelPlatformIface.\n\nexport enum ConversationKind {\n Direct = 'direct',\n Group = 'group',\n}\n\nexport enum ParticipantKind {\n User = 'user',\n Agent = 'agent',\n System = 'system',\n}\n\nexport enum SystemParticipantKind {\n Schedule = 'schedule',\n Webhook = 'webhook',\n Goal = 'goal',\n Tool = 'tool',\n ApiKey = 'api-key',\n}\n\nexport enum RoutingMode {\n Mention = 'mention',\n All = 'all',\n Default = 'default',\n}\n\nexport enum TurnPolicy {\n Steer = 'steer',\n Queue = 'queue',\n}\n\nexport enum Delivery {\n Prompt = 'prompt',\n Observe = 'observe',\n}\n\nexport enum MessageKind {\n Message = 'message',\n System = 'system',\n Card = 'card',\n}\n\nexport enum CardKind {\n Elicitation = 'elicitation',\n Permission = 'permission',\n Notice = 'notice',\n}\n\nexport interface ParticipantIface {\n id: string;\n kind: ParticipantKind;\n displayName: string;\n userId: string | null;\n servicePrincipalId?: string | null;\n definitionId: string | null;\n systemKind: SystemParticipantKind | null;\n routingMode: RoutingMode | null;\n sessionId: string | null;\n // Whether the agent's harness supports _final/session/observe and renders\n // _meta[\"final.ai\"].author; null for non-agents.\n supportsObserve: boolean | null;\n rendersAuthorMeta: boolean | null;\n left: boolean;\n}\n\nexport const channelReceiveResultSchema = z.union([\n z.object({ conversationId: z.string().min(1) }),\n z.object({ sessionId: z.string().min(1) }),\n z.null(),\n]);\nexport type ChannelReceiveResult = z.infer<typeof channelReceiveResultSchema>;\n\nexport interface ConversationRefIface {\n conversationId: string;\n}\n\nexport interface ConversationIface extends ConversationRefIface {\n organizationId: string;\n kind: ConversationKind;\n title: string | null;\n isHome: boolean;\n turnPolicy: TurnPolicy;\n}\n\nexport interface MessageRefIface {\n messageId: string;\n seq: number;\n}\n\nexport interface ConversationMessageIface extends MessageRefIface {\n conversationId: string;\n authorParticipantId: string;\n kind: MessageKind;\n body: string;\n content: ContentBlock[];\n replyToMessageId: string | null;\n threadRootId: string | null;\n // Earlier messages of the conversation the author quoted, in order.\n quotedMessageIds: string[];\n // Agent participant ids explicitly mentioned in the message.\n mentionedParticipantIds: string[];\n // Number of agent-authored hops that led to this message (0 for humans).\n hopDepth: number;\n // The originating agent for a tool-posted message, including linked conversations.\n agentAuthorDefinitionId?: string | null;\n createdAt: string;\n}\n\nexport interface RouteArgsIface {\n conversation: ConversationIface;\n message: ConversationMessageIface;\n participants: ParticipantIface[];\n agentParticipantId?: string;\n}\n\nexport interface RouteDecisionIface {\n participantId: string;\n delivery: Delivery;\n}\n\nexport interface PostMessageArgsIface {\n conversationId: string;\n authorParticipantId: string;\n kind?: MessageKind;\n content: ContentBlock[];\n replyToMessageId?: string | null;\n threadRootId?: string | null;\n quotedMessageIds?: string[];\n clientMessageId?: string | null;\n mentionedParticipantIds?: string[];\n attachmentIds?: string[];\n hopDepth?: number;\n // A tool or linked-conversation event carries the turn that produced it.\n originTurnId?: string | null;\n // Projection provenance for agent replies.\n source?: { turnId: string; fromSeq: number; toSeq: number } | null;\n}\n\nexport const channelMessageInputSchema = z.object({\n conversationId: z.string().min(1),\n authorParticipantId: z.string().min(1),\n kind: z.nativeEnum(MessageKind).default(MessageKind.Message),\n content: z.array(jsonObjectSchema).min(1),\n clientMessageId: z.string().min(1).nullish(),\n replyToMessageId: z.string().min(1).nullish(),\n threadRootId: z.string().min(1).nullish(),\n quotedMessageIds: z.array(z.string().min(1)).default([]),\n mentionedParticipantIds: z.array(z.string().min(1)).default([]),\n});\n\nexport interface CardArgsIface {\n conversationId: string;\n authorParticipantId: string;\n kind: CardKind;\n pendingRequestId: string | null;\n // Generic cards only: a title, body, options, and entity links (a Goal is an\n // entity link, not a card kind).\n state: JsonObject;\n entityLinks: {\n kind: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n imageUrl?: string;\n }[];\n}\n\nexport interface PromptArgsIface {\n waitForAcceptance?: boolean;\n channelBinding?: { id: string; revisionId: string };\n auth?: JsonObject | null;\n title?: string;\n participantId: string;\n content: ContentBlock[];\n turnPolicy: TurnPolicy;\n replyExpected: boolean;\n idempotencyKey: string;\n // Who prompted (for payer resolution and pending-request audience).\n authorParticipantId: string;\n audienceParticipantIds: string[];\n sourceMessageId: string;\n}\n\nexport interface ObserveArgsIface {\n participantId: string;\n content: ContentBlock[];\n idempotencyKey: string;\n}\n\n// What the session service lets a channel do. Implemented once, handed to\n// built-in and custom channels alike.\nexport interface ChannelPlatformIface {\n channelSessions?: ChannelSessionOperationsIface;\n conversations: {\n get(conversationId: string): Promise<ConversationIface | null>;\n createAttachmentUpload?(args: {\n conversationId: string;\n name: string;\n contentType: string;\n sizeBytes: number;\n }): Promise<{\n attachmentId: string;\n uploadUrl: string;\n method: string;\n headers: Record<string, string>;\n expiresAt: string;\n }>;\n getAttachmentUrl?(args: {\n conversationId: string;\n attachmentId: string;\n }): Promise<{ attachmentId: string; url: string; expiresAt: string }>;\n // Dispatch a stored reply to each recipient's binding; each channel owns routing.\n dispatchMessage?(args: {\n conversationId: string;\n messageId: string;\n participantId?: string;\n requestedDelivery?: Delivery;\n }): Promise<void>;\n findOrCreateDirect(args: {\n organizationId: string;\n userId: string;\n definitionId: string;\n }): Promise<ConversationIface>;\n // The conversation a channel binding is attached to.\n boundTo(bindingId: string): Promise<ConversationIface | null>;\n participants(conversationId: string): Promise<ParticipantIface[]>;\n systemParticipant(args: {\n conversationId: string;\n systemKind: SystemParticipantKind;\n displayName: string;\n sourceRef: string;\n }): Promise<ParticipantIface>;\n postMessage(args: PostMessageArgsIface): Promise<ConversationMessageIface>;\n updateMessage(args: {\n messageId: string;\n content: ContentBlock[];\n final: boolean;\n }): Promise<void>;\n postCard(args: CardArgsIface): Promise<ConversationMessageIface>;\n updateCard(args: { messageId: string; state: JsonObject }): Promise<void>;\n recentMessages(args: {\n conversationId: string;\n limit: number;\n beforeSeq?: number;\n afterSeq?: number;\n }): Promise<ConversationMessageIface[]>;\n // Messages of the conversation by id, however old (reply, thread and quote\n // context outside the recent window); unknown and deleted ones are absent.\n getMessages(args: {\n conversationId: string;\n messageIds: string[];\n }): Promise<ConversationMessageIface[]>;\n };\n sessions: {\n prompt(\n args: PromptArgsIface,\n ): Promise<{ messageId: string; sessionId?: string; turnId?: string }>;\n observe(args: ObserveArgsIface): Promise<void>;\n cancel(args: {\n participantId: string;\n reason?: string;\n throughMessageSeq?: number;\n }): Promise<void>;\n respond?(args: ChannelInputResponseIface): Promise<{ resolved: boolean }>;\n };\n log(message: string, details?: Record<string, JsonValue>): void;\n}\n\nexport interface ChannelInputResponseIface {\n channelBinding?: { id: string; revisionId: string };\n auth?: JsonObject | null;\n participantId: string;\n pendingId: string;\n outcome: JsonValue;\n actorParticipantId: string;\n userId: string | null;\n apiKeyId: string | null;\n}\n\nexport interface ChannelReceiveContextIface {\n platform: ChannelPlatformIface;\n organizationId: string;\n definitionId: string | null;\n bindingId: string | null;\n config: JsonObject;\n secrets: { get(name: string): Promise<string | null> };\n // A stored, authenticated delivery to one agent in a shared conversation.\n agentParticipantId?: string;\n message?: ConversationMessageIface;\n conversation?: ConversationIface;\n participants?: readonly ParticipantIface[];\n response?: ChannelInputResponseIface;\n conversationId?: string;\n cancelReason?: string;\n // Preserve this boundary when forwarding a retryable conversation Stop.\n cancelThroughMessageSeq?: number;\n requestedDelivery?: Delivery;\n}\n\n// An HTTP route a channel serves (webhooks), mounted by the front door at\n// /api/events/webhooks/:bindingId<path> and the per-agent aliases.\nexport interface ChannelRouteContextIface {\n request: Request;\n secrets: { get(name: string): Promise<string | null> };\n receive: (input: JsonValue) => Promise<ChannelReceiveResult>;\n}\n\nexport interface ChannelSocketIface {\n readonly signal: AbortSignal;\n readonly messages: AsyncIterable<string | Uint8Array>;\n // Authenticate the request before accepting. The selected protocol must have been offered.\n accept(options?: { protocol?: string }): void;\n send(data: string | Uint8Array): void;\n close(code?: number, reason?: string): void;\n}\n\nexport interface HttpChannelRouteDefinitionIface {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n handler: (args: ChannelRouteContextIface) => Promise<Response>;\n}\n\nexport interface WebSocketChannelRouteDefinitionIface {\n method: 'WS';\n path: string;\n // Returning an HTTP response before accept rejects the handshake. The handler lives until close.\n handler: (\n args: ChannelRouteContextIface & { socket: ChannelSocketIface },\n ) => Promise<Response | void>;\n}\n\nexport type RouteDefinitionIface =\n | HttpChannelRouteDefinitionIface\n | WebSocketChannelRouteDefinitionIface;\n\n// The per-turn value a channel keeps between its project and event calls of\n// one turn (the definition's `State`). The platform holds it, so a channel\n// running in a Worker isolate keeps nothing in memory; it starts null each turn\n// and is discarded when the turn's projection finishes.\nexport interface ChannelTurnStateIface<State> {\n get(): State | null;\n set(state: State | null): void;\n}\n\nexport interface ProjectionContextIface<State = JsonValue> {\n sessionId?: string;\n platform: ChannelPlatformIface;\n conversation: ConversationIface | null;\n agentParticipant: ParticipantIface | null;\n turn: { id: string; promptMessageId: string | null; authorParticipantId: string | null };\n seq: number;\n state: ChannelTurnStateIface<State>;\n}\n\nexport enum PendingEventKind {\n Created = 'pending.created',\n Resolved = 'pending.resolved',\n}\n\nexport type AcpUpdateKind = SessionUpdate['sessionUpdate'];\n\nexport type ChannelEventKind =\n | AcpUpdateKind\n | `${PendingEventKind}`\n | `${SemanticChannelEventKind}`;\n\nexport interface ChannelEventIface {\n type: string;\n data: JsonValue;\n seq: number;\n}\n\nexport type ChannelEventHandler<State = JsonValue> = (\n event: ChannelEventIface,\n ctx: ProjectionContextIface<State>,\n) => Promise<void>;\n\nexport enum PendingKind {\n Permission = 'permission',\n Elicitation = 'elicitation',\n}\n\n// `data` of a pending.created event: an ACP session/request_permission or\n// elicitation/create request awaiting its audience.\nexport const pendingCreatedDataSchema = z.object({\n pendingRequestId: z.string().min(1),\n kind: z.nativeEnum(PendingKind),\n audienceParticipantIds: z.array(z.string()),\n request: jsonValueSchema,\n});\n\nexport type PendingCreatedDataIface = z.infer<typeof pendingCreatedDataSchema>;\n\n// `data` of a pending.resolved event: the answer (or cancellation) as recorded.\nexport const pendingResolvedDataSchema = z.object({\n pendingRequestId: z.string().min(1),\n outcome: jsonValueSchema,\n});\n\nexport type PendingResolvedDataIface = z.infer<typeof pendingResolvedDataSchema>;\n\n// The visible-output updates `project` receives. After them, the\n// turn's projection ends with one ACP v2 idle `state_update` (turnEndUpdate).\n// Thought, tool, plan and every other update, other state updates included,\n// reach a channel only through an `events` handler for its kind.\nexport const PROJECTED_UPDATE_KINDS: ReadonlySet<AcpUpdateKind> = new Set<AcpUpdateKind>([\n 'agent_message_chunk',\n 'agent_message',\n]);\n\nconst turnEndSchema = z.looseObject({\n sessionUpdate: z.literal('state_update'),\n state: z.literal('idle'),\n stopReason: z.string().nullish(),\n _meta: z\n .looseObject({ 'final.ai': z.looseObject({ stopReason: z.string().nullish() }).nullish() })\n .nullish(),\n});\n\n// The stop reason when the update ends the turn (an idle state_update); null otherwise.\nexport const turnEndOf = (update: SessionUpdate): { stopReason: string | null } | null => {\n const parsed = turnEndSchema.safeParse(update);\n if (!parsed.success) return null;\n return {\n stopReason: parsed.data.stopReason ?? parsed.data._meta?.['final.ai']?.stopReason ?? null,\n };\n};\n\n// The idle state_update that ends a turn, as `project` receives it. A stop\n// reason outside ACP's known set rides in `_meta[\"final.ai\"]` (the SDK types\n// only received values as unknown variants).\nexport const turnEndUpdate = (stopReason: string | null): SessionUpdate => {\n switch (stopReason) {\n case null:\n return { sessionUpdate: 'state_update', state: 'idle' };\n case 'end_turn':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'end_turn' };\n case 'max_tokens':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'max_tokens' };\n case 'max_turn_requests':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'max_turn_requests' };\n case 'refusal':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'refusal' };\n case 'cancelled':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'cancelled' };\n default:\n return {\n sessionUpdate: 'state_update',\n state: 'idle',\n _meta: { 'final.ai': { stopReason } },\n };\n }\n};\n\n// Built-in and custom (bundle) channels implement exactly this; the\n// session service calls nothing else on a channel.\nexport interface ChannelDefinitionIface<Inbound, State = undefined> {\n config?: JsonObject;\n // Installed execution is an optimization for an uncustomized definition.\n installed?: ProviderRef;\n configure?: (config: JsonObject) => ChannelDefinitionIface<Inbound, State>;\n routes?: RouteDefinitionIface[];\n respond?(\n input: ChannelInputResponseIface,\n ctx: ChannelReceiveContextIface,\n ): Promise<{ resolved: boolean }>;\n cancel?(ctx: ChannelReceiveContextIface): Promise<{ accepted: boolean }>;\n // Inserts the input into its conversation and routes it. Returns where it went.\n receive(input: Inbound, ctx: ChannelReceiveContextIface): Promise<ChannelReceiveResult>;\n // Pure: who gets this message, and how. The channel applies it\n // to what it posts, from receive and project.\n route(args: RouteArgsIface): RouteDecisionIface[] | Promise<RouteDecisionIface[]>;\n turnPolicy: TurnPolicy;\n // ACP update \u2192 visible message / card. Called with a turn's\n // PROJECTED_UPDATE_KINDS updates in seq order, then its idle state_update.\n project(update: SessionUpdate, ctx: ProjectionContextIface<State>): Promise<void>;\n events?: Partial<Record<ChannelEventKind, ChannelEventHandler<State>>>;\n}\n\nexport const defineChannel = <Inbound, State = undefined>(\n definition: ChannelDefinitionIface<Inbound, State>,\n): ChannelDefinitionIface<Inbound, State> => definition;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["ConversationKind", "ParticipantKind", "SystemParticipantKind", "RoutingMode", "TurnPolicy", "Delivery", "MessageKind", "CardKind", "PendingEventKind", "PendingKind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AgentApp, type AgentConnection, type Stream } from '@agentclientprotocol/sdk/experimental/v2';
|
|
2
|
+
import { type FrameAttachmentStoreIface } from '@finalai/acp-session';
|
|
3
|
+
import { type FetchLike } from '@modelcontextprotocol/client';
|
|
4
|
+
import { PromptWhileRunning } from "../harness.mjs";
|
|
5
|
+
export interface ConformanceAgentOptionsIface {
|
|
6
|
+
extensions?: boolean;
|
|
7
|
+
fetch?: FetchLike;
|
|
8
|
+
slowTurnMs?: number;
|
|
9
|
+
privateMethods?: string[];
|
|
10
|
+
promptWhileRunning?: PromptWhileRunning;
|
|
11
|
+
survivesDisconnect?: boolean;
|
|
12
|
+
attachments?: FrameAttachmentStoreIface;
|
|
13
|
+
}
|
|
14
|
+
export interface ConformanceAgentIface {
|
|
15
|
+
app: AgentApp;
|
|
16
|
+
connect(stream: Stream): AgentConnection;
|
|
17
|
+
sessions(): string[];
|
|
18
|
+
nativeId(sessionId: string): string | null;
|
|
19
|
+
}
|
|
20
|
+
export declare const createConformanceAgent: (options?: ConformanceAgentOptionsIface) => ConformanceAgentIface;
|