@finalai/agent-provider 0.9.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HOSTING.md +334 -245
- package/README.md +106 -20
- package/dist/modules/canonical-json.d.mts +4 -0
- package/dist/modules/canonical-json.mjs +33 -0
- package/dist/modules/canonical-json.mjs.map +7 -0
- package/dist/modules/channel.d.mts +51 -15
- package/dist/modules/channel.mjs +1 -0
- package/dist/modules/channel.mjs.map +2 -2
- package/dist/modules/code-host/host.d.mts +10 -0
- package/dist/modules/code-host/host.mjs +88 -0
- package/dist/modules/code-host/host.mjs.map +7 -0
- package/dist/modules/code-host/in-process.d.mts +24 -0
- package/dist/modules/code-host/in-process.mjs +89 -0
- package/dist/modules/code-host/in-process.mjs.map +7 -0
- package/dist/modules/code-host/index.d.mts +4 -0
- package/dist/modules/code-host/index.mjs +5 -0
- package/dist/modules/code-host/index.mjs.map +7 -0
- package/dist/modules/code-host/serverless.d.mts +63 -0
- package/dist/modules/code-host/serverless.mjs +27 -0
- package/dist/modules/code-host/serverless.mjs.map +7 -0
- package/dist/modules/code-host/types.d.mts +152 -0
- package/dist/modules/code-host/types.mjs +85 -0
- package/dist/modules/code-host/types.mjs.map +7 -0
- package/dist/modules/conformance/agent.mjs +72 -6
- package/dist/modules/conformance/agent.mjs.map +2 -2
- package/dist/modules/conformance/harness-kit.d.mts +9 -2
- package/dist/modules/conformance/harness-kit.mjs +224 -63
- package/dist/modules/conformance/harness-kit.mjs.map +3 -3
- package/dist/modules/conformance/local-harness.d.mts +1 -4
- package/dist/modules/conformance/local-harness.mjs +21 -22
- package/dist/modules/conformance/local-harness.mjs.map +2 -2
- package/dist/modules/conformance/protocol.d.mts +1 -0
- package/dist/modules/conformance/protocol.mjs +2 -0
- package/dist/modules/conformance/protocol.mjs.map +2 -2
- package/dist/modules/conformance/sandbox-kit.d.mts +12 -4
- package/dist/modules/conformance/sandbox-kit.mjs +189 -103
- package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/chat-completions.mjs +1 -0
- package/dist/modules/conformance/scripted-model/chat-completions.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/directives.d.mts +3 -0
- package/dist/modules/conformance/scripted-model/directives.mjs +26 -10
- package/dist/modules/conformance/scripted-model/directives.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/messages.mjs +1 -0
- package/dist/modules/conformance/scripted-model/messages.mjs.map +2 -2
- package/dist/modules/conformance/scripted-model/responses.mjs +2 -0
- package/dist/modules/conformance/scripted-model/responses.mjs.map +2 -2
- package/dist/modules/conformance/stdio.d.mts +21 -0
- package/dist/modules/conformance/stdio.mjs +158 -0
- package/dist/modules/conformance/stdio.mjs.map +7 -0
- package/dist/modules/credential-routes.d.mts +3 -3
- package/dist/modules/credential-routes.mjs +2 -2
- package/dist/modules/credential-routes.mjs.map +2 -2
- package/dist/modules/document.d.mts +358 -0
- package/dist/modules/document.mjs +193 -0
- package/dist/modules/document.mjs.map +7 -0
- package/dist/modules/harness-configuration.d.mts +16 -0
- package/dist/modules/harness-configuration.mjs +83 -0
- package/dist/modules/harness-configuration.mjs.map +7 -0
- package/dist/modules/harness-definition.d.mts +280 -0
- package/dist/modules/harness-definition.mjs +430 -0
- package/dist/modules/harness-definition.mjs.map +7 -0
- package/dist/modules/harness-provider.d.mts +197 -0
- package/dist/modules/harness-provider.mjs +108 -0
- package/dist/modules/harness-provider.mjs.map +7 -0
- package/dist/modules/harness-requirements.d.mts +19 -0
- package/dist/modules/harness-requirements.mjs +40 -0
- package/dist/modules/harness-requirements.mjs.map +7 -0
- package/dist/modules/harness-start.d.mts +33 -0
- package/dist/modules/harness-start.mjs +107 -0
- package/dist/modules/harness-start.mjs.map +7 -0
- package/dist/modules/harness.d.mts +84 -109
- package/dist/modules/harness.mjs +56 -111
- package/dist/modules/harness.mjs.map +3 -3
- package/dist/modules/identity.d.mts +1 -0
- package/dist/modules/identity.mjs +2 -0
- package/dist/modules/identity.mjs.map +7 -0
- package/dist/modules/index.d.mts +12 -7
- package/dist/modules/index.mjs +12 -7
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/inference.d.mts +35 -0
- package/dist/modules/inference.mjs +74 -0
- package/dist/modules/inference.mjs.map +7 -0
- package/dist/modules/local-channel-context.d.mts +1 -1
- package/dist/modules/local-channel-context.mjs +1 -1
- package/dist/modules/local-channel-context.mjs.map +2 -2
- package/dist/modules/requirements-check.d.mts +30 -0
- package/dist/modules/requirements-check.mjs +164 -0
- package/dist/modules/requirements-check.mjs.map +7 -0
- package/dist/modules/sandbox/client.d.mts +3 -0
- package/dist/modules/sandbox/client.mjs +101 -18
- package/dist/modules/sandbox/client.mjs.map +2 -2
- package/dist/modules/sandbox/grant.d.mts +78 -0
- package/dist/modules/sandbox/grant.mjs +134 -0
- package/dist/modules/sandbox/grant.mjs.map +7 -0
- package/dist/modules/sandbox/index.d.mts +3 -3
- package/dist/modules/sandbox/index.mjs +4 -5
- package/dist/modules/sandbox/index.mjs.map +2 -2
- package/dist/modules/sandbox/mcp-hosted.d.mts +1 -1
- package/dist/modules/sandbox/mcp-hosted.mjs +4 -7
- package/dist/modules/sandbox/mcp-hosted.mjs.map +2 -2
- package/dist/modules/sandbox/mcp.d.mts +4 -2
- package/dist/modules/sandbox/mcp.mjs +14 -7
- package/dist/modules/sandbox/mcp.mjs.map +2 -2
- package/dist/modules/sandbox/memory-sandbox.d.mts +2 -1
- package/dist/modules/sandbox/memory-sandbox.mjs +71 -41
- package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
- package/dist/modules/sandbox/networking.d.mts +7 -7
- package/dist/modules/sandbox/networking.mjs +16 -9
- package/dist/modules/sandbox/networking.mjs.map +2 -2
- package/dist/modules/sandbox/remote/adapter.d.mts +30 -0
- package/dist/modules/sandbox/remote/adapter.mjs +381 -0
- package/dist/modules/sandbox/remote/adapter.mjs.map +7 -0
- package/dist/modules/sandbox/remote/body.d.mts +1 -0
- package/dist/modules/sandbox/remote/body.mjs +27 -0
- package/dist/modules/sandbox/remote/body.mjs.map +7 -0
- package/dist/modules/sandbox/remote/errors.d.mts +10 -0
- package/dist/modules/sandbox/remote/errors.mjs +62 -0
- package/dist/modules/sandbox/remote/errors.mjs.map +7 -0
- package/dist/modules/sandbox/remote/index.d.mts +5 -0
- package/dist/modules/sandbox/remote/index.mjs +6 -0
- package/dist/modules/sandbox/remote/index.mjs.map +7 -0
- package/dist/modules/sandbox/remote/ndjson.d.mts +6 -0
- package/dist/modules/sandbox/remote/ndjson.mjs +80 -0
- package/dist/modules/sandbox/remote/ndjson.mjs.map +7 -0
- package/dist/modules/sandbox/remote/platform-api.d.mts +8 -0
- package/dist/modules/sandbox/remote/platform-api.mjs +15 -0
- package/dist/modules/sandbox/remote/platform-api.mjs.map +7 -0
- package/dist/modules/sandbox/remote/preamble.d.mts +7 -0
- package/dist/modules/sandbox/remote/preamble.mjs +51 -0
- package/dist/modules/sandbox/remote/preamble.mjs.map +7 -0
- package/dist/modules/sandbox/remote/serve.d.mts +34 -0
- package/dist/modules/sandbox/remote/serve.mjs +520 -0
- package/dist/modules/sandbox/remote/serve.mjs.map +7 -0
- package/dist/modules/sandbox/remote/testing.d.mts +34 -0
- package/dist/modules/sandbox/remote/testing.mjs +275 -0
- package/dist/modules/sandbox/remote/testing.mjs.map +7 -0
- package/dist/modules/sandbox/seeds.d.mts +2 -2
- package/dist/modules/sandbox/seeds.mjs +2 -2
- package/dist/modules/sandbox/seeds.mjs.map +2 -2
- package/dist/modules/sandbox/server.d.mts +4 -6
- package/dist/modules/sandbox/server.mjs +93 -49
- package/dist/modules/sandbox/server.mjs.map +2 -2
- package/dist/modules/sandbox/setup/apply.d.mts +40 -0
- package/dist/modules/sandbox/setup/apply.mjs +190 -0
- package/dist/modules/sandbox/setup/apply.mjs.map +7 -0
- package/dist/modules/sandbox/setup/describe.d.mts +10 -0
- package/dist/modules/sandbox/setup/describe.mjs +62 -0
- package/dist/modules/sandbox/setup/describe.mjs.map +7 -0
- package/dist/modules/sandbox/setup/index.d.mts +6 -0
- package/dist/modules/sandbox/setup/index.mjs +17 -0
- package/dist/modules/sandbox/setup/index.mjs.map +7 -0
- package/dist/modules/sandbox/setup/paths.d.mts +8 -0
- package/dist/modules/sandbox/setup/paths.mjs +18 -0
- package/dist/modules/sandbox/setup/paths.mjs.map +7 -0
- package/dist/modules/sandbox/setup/schema.d.mts +43 -0
- package/dist/modules/sandbox/setup/schema.mjs +58 -0
- package/dist/modules/sandbox/setup/schema.mjs.map +7 -0
- package/dist/modules/sandbox/tool-policy.d.mts +1 -1
- package/dist/modules/sandbox/tool-policy.mjs +1 -1
- package/dist/modules/sandbox/tool-policy.mjs.map +2 -2
- package/dist/modules/sandbox/types.d.mts +117 -142
- package/dist/modules/sandbox/types.mjs +47 -57
- package/dist/modules/sandbox/types.mjs.map +3 -3
- package/dist/modules/sandbox/wire.d.mts +93 -6
- package/dist/modules/sandbox/wire.mjs +61 -38
- package/dist/modules/sandbox/wire.mjs.map +2 -2
- package/dist/modules/schemas.d.mts +5 -76
- package/dist/modules/schemas.mjs +18 -85
- package/dist/modules/schemas.mjs.map +2 -2
- package/dist/modules/tool-annotations.d.mts +15 -6
- package/dist/modules/tool-annotations.mjs +9 -3
- package/dist/modules/tool-annotations.mjs.map +2 -2
- package/dist/modules/tool-descriptor.d.mts +16 -0
- package/dist/modules/tool-descriptor.mjs +19 -0
- package/dist/modules/tool-descriptor.mjs.map +7 -0
- package/dist/modules/tool-patterns.d.mts +7 -7
- package/dist/modules/tool-patterns.mjs +10 -9
- package/dist/modules/tool-patterns.mjs.map +2 -2
- package/package.json +86 -41
- package/dist/modules/credentials.d.mts +0 -206
- package/dist/modules/credentials.mjs +0 -207
- package/dist/modules/credentials.mjs.map +0 -7
- package/dist/modules/dynamic.d.mts +0 -40
- package/dist/modules/dynamic.mjs +0 -79
- package/dist/modules/dynamic.mjs.map +0 -7
- package/dist/modules/hosted-bindings.d.mts +0 -15
- package/dist/modules/hosted-bindings.mjs +0 -21
- package/dist/modules/hosted-bindings.mjs.map +0 -7
- package/dist/modules/manifest.d.mts +0 -791
- package/dist/modules/manifest.mjs +0 -322
- package/dist/modules/manifest.mjs.map +0 -7
- package/dist/modules/provider-ref.d.mts +0 -29
- package/dist/modules/provider-ref.mjs +0 -55
- package/dist/modules/provider-ref.mjs.map +0 -7
- package/dist/modules/room-surface.d.mts +0 -355
- package/dist/modules/room-surface.mjs +0 -156
- package/dist/modules/room-surface.mjs.map +0 -7
- package/dist/modules/sandbox/open-scope-node.d.mts +0 -4
- package/dist/modules/sandbox/open-scope-node.mjs +0 -19
- package/dist/modules/sandbox/open-scope-node.mjs.map +0 -7
- package/dist/modules/sandbox/open-scope.d.mts +0 -16
- package/dist/modules/sandbox/open-scope.mjs +0 -66
- package/dist/modules/sandbox/open-scope.mjs.map +0 -7
- package/dist/modules/sandbox/workspace-identity.d.mts +0 -5
- package/dist/modules/sandbox/workspace-identity.mjs +0 -14
- package/dist/modules/sandbox/workspace-identity.mjs.map +0 -7
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
import type { HostedBindingsIface } from "./hosted-bindings.mjs";
|
|
2
|
-
import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';
|
|
3
|
-
import type { SessionUpdateKind } from '@finalai/acp-session';
|
|
4
|
-
import * as z from 'zod';
|
|
5
|
-
import type { ChannelTurnStateIface } from "./channel.mjs";
|
|
6
|
-
import { type JsonObject, type JsonValue } from "./json.mjs";
|
|
7
|
-
import type { SemanticChannelEventKind } from "./semantic-events.mjs";
|
|
8
|
-
export declare enum RoomPrincipalType {
|
|
9
|
-
User = "user",
|
|
10
|
-
Service = "service"
|
|
11
|
-
}
|
|
12
|
-
export interface RoomAuthIface extends JsonObject {
|
|
13
|
-
principalId: string;
|
|
14
|
-
principalType: RoomPrincipalType | `${RoomPrincipalType}`;
|
|
15
|
-
authenticator: string;
|
|
16
|
-
attributes: JsonObject;
|
|
17
|
-
}
|
|
18
|
-
export declare const roomAuthSchema: z.ZodObject<{
|
|
19
|
-
principalId: z.ZodString;
|
|
20
|
-
principalType: z.ZodEnum<typeof RoomPrincipalType>;
|
|
21
|
-
authenticator: z.ZodString;
|
|
22
|
-
displayName: z.ZodOptional<z.ZodString>;
|
|
23
|
-
attributes: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
export declare const principalDisplayName: (auth: RoomAuthIface) => string;
|
|
26
|
-
export declare enum ConversationKind {
|
|
27
|
-
Direct = "direct",
|
|
28
|
-
Group = "group"
|
|
29
|
-
}
|
|
30
|
-
export declare enum ParticipantKind {
|
|
31
|
-
User = "user",
|
|
32
|
-
Agent = "agent"
|
|
33
|
-
}
|
|
34
|
-
export declare enum RoutingMode {
|
|
35
|
-
Mention = "mention",
|
|
36
|
-
All = "all",
|
|
37
|
-
Default = "default"
|
|
38
|
-
}
|
|
39
|
-
export declare enum TurnPolicy {
|
|
40
|
-
Steer = "steer",
|
|
41
|
-
Queue = "queue"
|
|
42
|
-
}
|
|
43
|
-
export declare enum Delivery {
|
|
44
|
-
Prompt = "prompt",
|
|
45
|
-
Observe = "observe"
|
|
46
|
-
}
|
|
47
|
-
export declare enum MessageKind {
|
|
48
|
-
Message = "message",
|
|
49
|
-
Card = "card"
|
|
50
|
-
}
|
|
51
|
-
export declare enum CardKind {
|
|
52
|
-
Elicitation = "elicitation",
|
|
53
|
-
Permission = "permission",
|
|
54
|
-
Notice = "notice"
|
|
55
|
-
}
|
|
56
|
-
export interface ParticipantIface {
|
|
57
|
-
id: string;
|
|
58
|
-
kind: ParticipantKind;
|
|
59
|
-
displayName: string;
|
|
60
|
-
userId: string | null;
|
|
61
|
-
definitionId: string | null;
|
|
62
|
-
routingMode: RoutingMode | null;
|
|
63
|
-
sessionId: string | null;
|
|
64
|
-
supportsObserve: boolean | null;
|
|
65
|
-
rendersAuthorMeta: boolean | null;
|
|
66
|
-
left: boolean;
|
|
67
|
-
}
|
|
68
|
-
export declare const roomReceiveResultSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
69
|
-
conversationId: z.ZodString;
|
|
70
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
71
|
-
sessionId: z.ZodString;
|
|
72
|
-
}, z.core.$strip>, z.ZodNull]>;
|
|
73
|
-
export type RoomReceiveResult = z.infer<typeof roomReceiveResultSchema>;
|
|
74
|
-
export interface ConversationRefIface {
|
|
75
|
-
conversationId: string;
|
|
76
|
-
}
|
|
77
|
-
export interface ConversationIface extends ConversationRefIface {
|
|
78
|
-
organizationId: string;
|
|
79
|
-
kind: ConversationKind;
|
|
80
|
-
title: string | null;
|
|
81
|
-
isHome: boolean;
|
|
82
|
-
turnPolicy: TurnPolicy;
|
|
83
|
-
}
|
|
84
|
-
export interface MessageRefIface {
|
|
85
|
-
messageId: string;
|
|
86
|
-
seq: number;
|
|
87
|
-
}
|
|
88
|
-
export interface ConversationMessageIface extends MessageRefIface {
|
|
89
|
-
conversationId: string;
|
|
90
|
-
authorParticipantId: string;
|
|
91
|
-
kind: MessageKind;
|
|
92
|
-
body: string;
|
|
93
|
-
content: ContentBlock[];
|
|
94
|
-
replyToMessageId: string | null;
|
|
95
|
-
threadRootId: string | null;
|
|
96
|
-
quotedMessageIds: string[];
|
|
97
|
-
mentionedParticipantIds: string[];
|
|
98
|
-
hopDepth: number;
|
|
99
|
-
agentAuthorDefinitionId?: string | null;
|
|
100
|
-
createdAt: string;
|
|
101
|
-
}
|
|
102
|
-
export interface RouteArgsIface {
|
|
103
|
-
conversation: ConversationIface;
|
|
104
|
-
message: ConversationMessageIface;
|
|
105
|
-
participants: ParticipantIface[];
|
|
106
|
-
agentParticipantId?: string;
|
|
107
|
-
}
|
|
108
|
-
export interface RouteDecisionIface {
|
|
109
|
-
participantId: string;
|
|
110
|
-
delivery: Delivery;
|
|
111
|
-
}
|
|
112
|
-
export interface PostMessageArgsIface {
|
|
113
|
-
conversationId: string;
|
|
114
|
-
authorParticipantId: string;
|
|
115
|
-
kind?: MessageKind;
|
|
116
|
-
content: ContentBlock[];
|
|
117
|
-
replyToMessageId?: string | null;
|
|
118
|
-
threadRootId?: string | null;
|
|
119
|
-
quotedMessageIds?: string[];
|
|
120
|
-
clientMessageId?: string | null;
|
|
121
|
-
mentionedParticipantIds?: string[];
|
|
122
|
-
attachmentIds?: string[];
|
|
123
|
-
hopDepth?: number;
|
|
124
|
-
originTurnId?: string | null;
|
|
125
|
-
source?: {
|
|
126
|
-
turnId: string;
|
|
127
|
-
fromSeq: number;
|
|
128
|
-
toSeq: number;
|
|
129
|
-
} | null;
|
|
130
|
-
}
|
|
131
|
-
export declare const roomMessageInputSchema: z.ZodObject<{
|
|
132
|
-
conversationId: z.ZodString;
|
|
133
|
-
authorParticipantId: z.ZodString;
|
|
134
|
-
kind: z.ZodDefault<z.ZodEnum<typeof MessageKind>>;
|
|
135
|
-
content: z.ZodArray<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
136
|
-
clientMessageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
137
|
-
replyToMessageId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
138
|
-
threadRootId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
139
|
-
quotedMessageIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
140
|
-
mentionedParticipantIds: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
141
|
-
}, z.core.$strip>;
|
|
142
|
-
export interface CardArgsIface {
|
|
143
|
-
conversationId: string;
|
|
144
|
-
authorParticipantId: string;
|
|
145
|
-
kind: CardKind;
|
|
146
|
-
decisionId: string | null;
|
|
147
|
-
state: JsonObject;
|
|
148
|
-
entityLinks: {
|
|
149
|
-
kind: string;
|
|
150
|
-
id: string;
|
|
151
|
-
title?: string;
|
|
152
|
-
url?: string;
|
|
153
|
-
description?: string;
|
|
154
|
-
imageUrl?: string;
|
|
155
|
-
}[];
|
|
156
|
-
}
|
|
157
|
-
export interface PromptArgsIface {
|
|
158
|
-
waitForAcceptance?: boolean;
|
|
159
|
-
channelBinding?: {
|
|
160
|
-
id: string;
|
|
161
|
-
revisionId: string;
|
|
162
|
-
};
|
|
163
|
-
auth?: RoomAuthIface | null;
|
|
164
|
-
title?: string;
|
|
165
|
-
participantId: string;
|
|
166
|
-
content: ContentBlock[];
|
|
167
|
-
turnPolicy: TurnPolicy;
|
|
168
|
-
replyExpected: boolean;
|
|
169
|
-
idempotencyKey: string;
|
|
170
|
-
authorParticipantId: string;
|
|
171
|
-
audienceParticipantIds: string[];
|
|
172
|
-
sourceMessageId: string;
|
|
173
|
-
}
|
|
174
|
-
export interface ObserveArgsIface {
|
|
175
|
-
participantId: string;
|
|
176
|
-
content: ContentBlock[];
|
|
177
|
-
idempotencyKey: string;
|
|
178
|
-
}
|
|
179
|
-
export interface RoomPlatformIface {
|
|
180
|
-
conversations: {
|
|
181
|
-
get(conversationId: string): Promise<ConversationIface | null>;
|
|
182
|
-
createAttachmentUpload?(args: {
|
|
183
|
-
conversationId: string;
|
|
184
|
-
name: string;
|
|
185
|
-
contentType: string;
|
|
186
|
-
sizeBytes: number;
|
|
187
|
-
}): Promise<{
|
|
188
|
-
attachmentId: string;
|
|
189
|
-
uploadUrl: string;
|
|
190
|
-
method: string;
|
|
191
|
-
headers: Record<string, string>;
|
|
192
|
-
expiresAt: string;
|
|
193
|
-
}>;
|
|
194
|
-
getAttachmentUrl?(args: {
|
|
195
|
-
conversationId: string;
|
|
196
|
-
attachmentId: string;
|
|
197
|
-
}): Promise<{
|
|
198
|
-
attachmentId: string;
|
|
199
|
-
url: string;
|
|
200
|
-
expiresAt: string;
|
|
201
|
-
}>;
|
|
202
|
-
dispatchMessage?(args: {
|
|
203
|
-
conversationId: string;
|
|
204
|
-
messageId: string;
|
|
205
|
-
participantId?: string;
|
|
206
|
-
requestedDelivery?: Delivery;
|
|
207
|
-
}): Promise<void>;
|
|
208
|
-
participants(conversationId: string): Promise<ParticipantIface[]>;
|
|
209
|
-
postMessage(args: PostMessageArgsIface): Promise<ConversationMessageIface>;
|
|
210
|
-
updateMessage(args: {
|
|
211
|
-
messageId: string;
|
|
212
|
-
content: ContentBlock[];
|
|
213
|
-
final: boolean;
|
|
214
|
-
}): Promise<void>;
|
|
215
|
-
postCard(args: CardArgsIface): Promise<ConversationMessageIface>;
|
|
216
|
-
updateCard(args: {
|
|
217
|
-
messageId: string;
|
|
218
|
-
state: JsonObject;
|
|
219
|
-
}): Promise<void>;
|
|
220
|
-
recentMessages(args: {
|
|
221
|
-
conversationId: string;
|
|
222
|
-
limit: number;
|
|
223
|
-
beforeSeq?: number;
|
|
224
|
-
afterSeq?: number;
|
|
225
|
-
}): Promise<ConversationMessageIface[]>;
|
|
226
|
-
getMessages(args: {
|
|
227
|
-
conversationId: string;
|
|
228
|
-
messageIds: string[];
|
|
229
|
-
}): Promise<ConversationMessageIface[]>;
|
|
230
|
-
};
|
|
231
|
-
sessions: {
|
|
232
|
-
prompt(args: PromptArgsIface): Promise<{
|
|
233
|
-
messageId: string;
|
|
234
|
-
sessionId?: string;
|
|
235
|
-
turnId?: string;
|
|
236
|
-
}>;
|
|
237
|
-
observe(args: ObserveArgsIface): Promise<void>;
|
|
238
|
-
cancel(args: {
|
|
239
|
-
participantId: string;
|
|
240
|
-
reason?: string;
|
|
241
|
-
throughMessageSeq?: number;
|
|
242
|
-
}): Promise<void>;
|
|
243
|
-
respond?(args: RoomInputResponseIface): Promise<{
|
|
244
|
-
resolved: boolean;
|
|
245
|
-
}>;
|
|
246
|
-
};
|
|
247
|
-
log(message: string, details?: Record<string, JsonValue>): void;
|
|
248
|
-
}
|
|
249
|
-
export interface RoomInputResponseIface {
|
|
250
|
-
channelBinding?: {
|
|
251
|
-
id: string;
|
|
252
|
-
revisionId: string;
|
|
253
|
-
};
|
|
254
|
-
auth?: RoomAuthIface | null;
|
|
255
|
-
participantId: string;
|
|
256
|
-
decisionId: string;
|
|
257
|
-
outcome: JsonValue;
|
|
258
|
-
actorParticipantId: string;
|
|
259
|
-
userId: string | null;
|
|
260
|
-
}
|
|
261
|
-
export interface RoomReceiveContextIface {
|
|
262
|
-
bindings?: HostedBindingsIface;
|
|
263
|
-
platform: RoomPlatformIface;
|
|
264
|
-
organizationId: string;
|
|
265
|
-
definitionId: string | null;
|
|
266
|
-
bindingId: string | null;
|
|
267
|
-
config: JsonObject;
|
|
268
|
-
secrets: {
|
|
269
|
-
get(name: string): Promise<string | null>;
|
|
270
|
-
};
|
|
271
|
-
agentParticipantId?: string;
|
|
272
|
-
message?: ConversationMessageIface;
|
|
273
|
-
conversation?: ConversationIface;
|
|
274
|
-
participants?: readonly ParticipantIface[];
|
|
275
|
-
response?: RoomInputResponseIface;
|
|
276
|
-
conversationId?: string;
|
|
277
|
-
cancelReason?: string;
|
|
278
|
-
cancelThroughMessageSeq?: number;
|
|
279
|
-
requestedDelivery?: Delivery;
|
|
280
|
-
}
|
|
281
|
-
export interface ProjectionContextIface<State = JsonValue> {
|
|
282
|
-
bindings?: HostedBindingsIface;
|
|
283
|
-
sessionId?: string;
|
|
284
|
-
platform: RoomPlatformIface;
|
|
285
|
-
config: JsonObject;
|
|
286
|
-
secrets: {
|
|
287
|
-
get(name: string): Promise<string | null>;
|
|
288
|
-
};
|
|
289
|
-
conversation: ConversationIface | null;
|
|
290
|
-
agentParticipant: ParticipantIface | null;
|
|
291
|
-
turn: {
|
|
292
|
-
id: string;
|
|
293
|
-
promptMessageId: string | null;
|
|
294
|
-
authorParticipantId: string | null;
|
|
295
|
-
};
|
|
296
|
-
seq: number;
|
|
297
|
-
state: ChannelTurnStateIface<State>;
|
|
298
|
-
}
|
|
299
|
-
export declare enum DecisionEventKind {
|
|
300
|
-
Created = "decision.created",
|
|
301
|
-
Resolved = "decision.resolved"
|
|
302
|
-
}
|
|
303
|
-
export type AcpUpdateKind = SessionUpdate['sessionUpdate'];
|
|
304
|
-
export type KnownAcpUpdateKind = `${SessionUpdateKind}`;
|
|
305
|
-
export type RoomEventKind = AcpUpdateKind | `${DecisionEventKind}` | `${SemanticChannelEventKind}`;
|
|
306
|
-
export interface RoomEventIface {
|
|
307
|
-
type: string;
|
|
308
|
-
data: JsonValue;
|
|
309
|
-
seq: number;
|
|
310
|
-
}
|
|
311
|
-
export type RoomEventHandler<State = JsonValue> = (event: RoomEventIface, ctx: ProjectionContextIface<State>) => Promise<void>;
|
|
312
|
-
export declare enum DecisionKind {
|
|
313
|
-
Permission = "permission",
|
|
314
|
-
Elicitation = "elicitation"
|
|
315
|
-
}
|
|
316
|
-
export declare const decisionCreatedDataSchema: z.ZodObject<{
|
|
317
|
-
decisionId: z.ZodString;
|
|
318
|
-
kind: z.ZodEnum<typeof DecisionKind>;
|
|
319
|
-
audienceParticipantIds: z.ZodArray<z.ZodString>;
|
|
320
|
-
request: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
321
|
-
}, z.core.$strip>;
|
|
322
|
-
export type DecisionCreatedDataIface = z.infer<typeof decisionCreatedDataSchema>;
|
|
323
|
-
export declare const decisionResolvedDataSchema: z.ZodObject<{
|
|
324
|
-
decisionId: z.ZodString;
|
|
325
|
-
outcome: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
|
|
326
|
-
respondedBy: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
327
|
-
principalId: z.ZodString;
|
|
328
|
-
principalType: z.ZodEnum<typeof RoomPrincipalType>;
|
|
329
|
-
authenticator: z.ZodString;
|
|
330
|
-
displayName: z.ZodOptional<z.ZodString>;
|
|
331
|
-
attributes: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
332
|
-
}, z.core.$strip>>>;
|
|
333
|
-
}, z.core.$strip>;
|
|
334
|
-
export type DecisionResolvedDataIface = z.infer<typeof decisionResolvedDataSchema>;
|
|
335
|
-
export declare const PROJECTED_UPDATE_KINDS: ReadonlySet<AcpUpdateKind>;
|
|
336
|
-
export declare const turnEndOf: (update: SessionUpdate) => {
|
|
337
|
-
stopReason: string | null;
|
|
338
|
-
} | null;
|
|
339
|
-
export declare const turnEndUpdate: (stopReason: string | null) => SessionUpdate;
|
|
340
|
-
export interface RoomSurfaceDefinitionIface<Inbound, State = undefined> {
|
|
341
|
-
config?: JsonObject;
|
|
342
|
-
configure?: (config: JsonObject) => RoomSurfaceDefinitionIface<Inbound, State>;
|
|
343
|
-
respond?(input: RoomInputResponseIface, ctx: RoomReceiveContextIface): Promise<{
|
|
344
|
-
resolved: boolean;
|
|
345
|
-
}>;
|
|
346
|
-
cancel?(ctx: RoomReceiveContextIface): Promise<{
|
|
347
|
-
accepted: boolean;
|
|
348
|
-
}>;
|
|
349
|
-
receive(input: Inbound, ctx: RoomReceiveContextIface): Promise<RoomReceiveResult>;
|
|
350
|
-
route(args: RouteArgsIface): RouteDecisionIface[] | Promise<RouteDecisionIface[]>;
|
|
351
|
-
turnPolicy: TurnPolicy;
|
|
352
|
-
project(update: SessionUpdate, ctx: ProjectionContextIface<State>): Promise<void>;
|
|
353
|
-
events?: Partial<Record<RoomEventKind, RoomEventHandler<State>>>;
|
|
354
|
-
}
|
|
355
|
-
export declare const defineRoomSurface: <Inbound, State = undefined>(definition: RoomSurfaceDefinitionIface<Inbound, State>) => RoomSurfaceDefinitionIface<Inbound, State>;
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
import { jsonObjectSchema, jsonValueSchema } from "./json.mjs";
|
|
3
|
-
var RoomPrincipalType = /* @__PURE__ */ ((RoomPrincipalType2) => {
|
|
4
|
-
RoomPrincipalType2["User"] = "user";
|
|
5
|
-
RoomPrincipalType2["Service"] = "service";
|
|
6
|
-
return RoomPrincipalType2;
|
|
7
|
-
})(RoomPrincipalType || {});
|
|
8
|
-
const roomAuthSchema = z.object({
|
|
9
|
-
principalId: z.string().min(1),
|
|
10
|
-
principalType: z.nativeEnum(RoomPrincipalType),
|
|
11
|
-
authenticator: z.string().min(1),
|
|
12
|
-
// How the agent and the people reading its reply name the principal.
|
|
13
|
-
displayName: z.string().min(1).max(200).optional(),
|
|
14
|
-
attributes: jsonObjectSchema.default({})
|
|
15
|
-
});
|
|
16
|
-
const principalDisplayName = (auth) => {
|
|
17
|
-
const name = auth["displayName"];
|
|
18
|
-
return typeof name === "string" && name.length > 0 ? name : auth.principalId;
|
|
19
|
-
};
|
|
20
|
-
var ConversationKind = /* @__PURE__ */ ((ConversationKind2) => {
|
|
21
|
-
ConversationKind2["Direct"] = "direct";
|
|
22
|
-
ConversationKind2["Group"] = "group";
|
|
23
|
-
return ConversationKind2;
|
|
24
|
-
})(ConversationKind || {});
|
|
25
|
-
var ParticipantKind = /* @__PURE__ */ ((ParticipantKind2) => {
|
|
26
|
-
ParticipantKind2["User"] = "user";
|
|
27
|
-
ParticipantKind2["Agent"] = "agent";
|
|
28
|
-
return ParticipantKind2;
|
|
29
|
-
})(ParticipantKind || {});
|
|
30
|
-
var RoutingMode = /* @__PURE__ */ ((RoutingMode2) => {
|
|
31
|
-
RoutingMode2["Mention"] = "mention";
|
|
32
|
-
RoutingMode2["All"] = "all";
|
|
33
|
-
RoutingMode2["Default"] = "default";
|
|
34
|
-
return RoutingMode2;
|
|
35
|
-
})(RoutingMode || {});
|
|
36
|
-
var TurnPolicy = /* @__PURE__ */ ((TurnPolicy2) => {
|
|
37
|
-
TurnPolicy2["Steer"] = "steer";
|
|
38
|
-
TurnPolicy2["Queue"] = "queue";
|
|
39
|
-
return TurnPolicy2;
|
|
40
|
-
})(TurnPolicy || {});
|
|
41
|
-
var Delivery = /* @__PURE__ */ ((Delivery2) => {
|
|
42
|
-
Delivery2["Prompt"] = "prompt";
|
|
43
|
-
Delivery2["Observe"] = "observe";
|
|
44
|
-
return Delivery2;
|
|
45
|
-
})(Delivery || {});
|
|
46
|
-
var MessageKind = /* @__PURE__ */ ((MessageKind2) => {
|
|
47
|
-
MessageKind2["Message"] = "message";
|
|
48
|
-
MessageKind2["Card"] = "card";
|
|
49
|
-
return MessageKind2;
|
|
50
|
-
})(MessageKind || {});
|
|
51
|
-
var CardKind = /* @__PURE__ */ ((CardKind2) => {
|
|
52
|
-
CardKind2["Elicitation"] = "elicitation";
|
|
53
|
-
CardKind2["Permission"] = "permission";
|
|
54
|
-
CardKind2["Notice"] = "notice";
|
|
55
|
-
return CardKind2;
|
|
56
|
-
})(CardKind || {});
|
|
57
|
-
const roomReceiveResultSchema = z.union([
|
|
58
|
-
z.object({ conversationId: z.string().min(1) }),
|
|
59
|
-
z.object({ sessionId: z.string().min(1) }),
|
|
60
|
-
z.null()
|
|
61
|
-
]);
|
|
62
|
-
const roomMessageInputSchema = z.object({
|
|
63
|
-
conversationId: z.string().min(1),
|
|
64
|
-
authorParticipantId: z.string().min(1),
|
|
65
|
-
kind: z.nativeEnum(MessageKind).default("message" /* Message */),
|
|
66
|
-
content: z.array(jsonObjectSchema).min(1),
|
|
67
|
-
clientMessageId: z.string().min(1).nullish(),
|
|
68
|
-
replyToMessageId: z.string().min(1).nullish(),
|
|
69
|
-
threadRootId: z.string().min(1).nullish(),
|
|
70
|
-
quotedMessageIds: z.array(z.string().min(1)).default([]),
|
|
71
|
-
mentionedParticipantIds: z.array(z.string().min(1)).default([])
|
|
72
|
-
});
|
|
73
|
-
var DecisionEventKind = /* @__PURE__ */ ((DecisionEventKind2) => {
|
|
74
|
-
DecisionEventKind2["Created"] = "decision.created";
|
|
75
|
-
DecisionEventKind2["Resolved"] = "decision.resolved";
|
|
76
|
-
return DecisionEventKind2;
|
|
77
|
-
})(DecisionEventKind || {});
|
|
78
|
-
var DecisionKind = /* @__PURE__ */ ((DecisionKind2) => {
|
|
79
|
-
DecisionKind2["Permission"] = "permission";
|
|
80
|
-
DecisionKind2["Elicitation"] = "elicitation";
|
|
81
|
-
return DecisionKind2;
|
|
82
|
-
})(DecisionKind || {});
|
|
83
|
-
const decisionCreatedDataSchema = z.object({
|
|
84
|
-
decisionId: z.string().min(1),
|
|
85
|
-
kind: z.nativeEnum(DecisionKind),
|
|
86
|
-
audienceParticipantIds: z.array(z.string()),
|
|
87
|
-
request: jsonValueSchema
|
|
88
|
-
});
|
|
89
|
-
const decisionResolvedDataSchema = z.object({
|
|
90
|
-
decisionId: z.string().min(1),
|
|
91
|
-
outcome: jsonValueSchema,
|
|
92
|
-
respondedBy: roomAuthSchema.nullable().default(null)
|
|
93
|
-
});
|
|
94
|
-
const PROJECTED_UPDATE_KINDS = /* @__PURE__ */ new Set([
|
|
95
|
-
"agent_message_chunk",
|
|
96
|
-
"agent_message"
|
|
97
|
-
]);
|
|
98
|
-
const turnEndSchema = z.looseObject({
|
|
99
|
-
sessionUpdate: z.literal("state_update"),
|
|
100
|
-
state: z.literal("idle"),
|
|
101
|
-
stopReason: z.string().nullish(),
|
|
102
|
-
_meta: z.looseObject({ "final.ai": z.looseObject({ stopReason: z.string().nullish() }).nullish() }).nullish()
|
|
103
|
-
});
|
|
104
|
-
const turnEndOf = (update) => {
|
|
105
|
-
const parsed = turnEndSchema.safeParse(update);
|
|
106
|
-
if (!parsed.success) return null;
|
|
107
|
-
return {
|
|
108
|
-
stopReason: parsed.data.stopReason ?? parsed.data._meta?.["final.ai"]?.stopReason ?? null
|
|
109
|
-
};
|
|
110
|
-
};
|
|
111
|
-
const turnEndUpdate = (stopReason) => {
|
|
112
|
-
switch (stopReason) {
|
|
113
|
-
case null:
|
|
114
|
-
return { sessionUpdate: "state_update", state: "idle" };
|
|
115
|
-
case "end_turn":
|
|
116
|
-
return { sessionUpdate: "state_update", state: "idle", stopReason: "end_turn" };
|
|
117
|
-
case "max_tokens":
|
|
118
|
-
return { sessionUpdate: "state_update", state: "idle", stopReason: "max_tokens" };
|
|
119
|
-
case "max_turn_requests":
|
|
120
|
-
return { sessionUpdate: "state_update", state: "idle", stopReason: "max_turn_requests" };
|
|
121
|
-
case "refusal":
|
|
122
|
-
return { sessionUpdate: "state_update", state: "idle", stopReason: "refusal" };
|
|
123
|
-
case "cancelled":
|
|
124
|
-
return { sessionUpdate: "state_update", state: "idle", stopReason: "cancelled" };
|
|
125
|
-
default:
|
|
126
|
-
return {
|
|
127
|
-
sessionUpdate: "state_update",
|
|
128
|
-
state: "idle",
|
|
129
|
-
_meta: { "final.ai": { stopReason } }
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const defineRoomSurface = (definition) => definition;
|
|
134
|
-
export {
|
|
135
|
-
CardKind,
|
|
136
|
-
ConversationKind,
|
|
137
|
-
DecisionEventKind,
|
|
138
|
-
DecisionKind,
|
|
139
|
-
Delivery,
|
|
140
|
-
MessageKind,
|
|
141
|
-
PROJECTED_UPDATE_KINDS,
|
|
142
|
-
ParticipantKind,
|
|
143
|
-
RoomPrincipalType,
|
|
144
|
-
RoutingMode,
|
|
145
|
-
TurnPolicy,
|
|
146
|
-
decisionCreatedDataSchema,
|
|
147
|
-
decisionResolvedDataSchema,
|
|
148
|
-
defineRoomSurface,
|
|
149
|
-
principalDisplayName,
|
|
150
|
-
roomAuthSchema,
|
|
151
|
-
roomMessageInputSchema,
|
|
152
|
-
roomReceiveResultSchema,
|
|
153
|
-
turnEndOf,
|
|
154
|
-
turnEndUpdate
|
|
155
|
-
};
|
|
156
|
-
//# sourceMappingURL=room-surface.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../src/room-surface.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport type { SessionUpdateKind } from '@finalai/acp-session';\nimport * as z from 'zod';\nimport type { ChannelTurnStateIface } from \"./channel.mjs\";\nimport { jsonObjectSchema, jsonValueSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { SemanticChannelEventKind } from \"./semantic-events.mjs\";\n\n// Contracts for customizing Final chats. Admission callbacks receive the\n// current message and members; renderers and events can post room output.\n// External transports use the separate scoped channel contract.\n\nexport enum RoomPrincipalType {\n User = 'user',\n Service = 'service',\n}\n\n// Who a room input or response came from, as vouched for by its authenticator.\nexport interface RoomAuthIface extends JsonObject {\n principalId: string;\n principalType: RoomPrincipalType | `${RoomPrincipalType}`;\n authenticator: string;\n // `displayName` (a string) when the principal is named; see principalDisplayName.\n attributes: JsonObject;\n}\n\nexport const roomAuthSchema = z.object({\n principalId: z.string().min(1),\n principalType: z.nativeEnum(RoomPrincipalType),\n authenticator: z.string().min(1),\n // How the agent and the people reading its reply name the principal.\n displayName: z.string().min(1).max(200).optional(),\n attributes: jsonObjectSchema.default({}),\n});\n\n// How a principal is named to the agent and in captions: its `displayName`, else its id.\nexport const principalDisplayName = (auth: RoomAuthIface): string => {\n const name = auth['displayName'];\n return typeof name === 'string' && name.length > 0 ? name : auth.principalId;\n};\n\nexport enum ConversationKind {\n Direct = 'direct',\n Group = 'group',\n}\n\nexport enum ParticipantKind {\n User = 'user',\n Agent = 'agent',\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 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 definitionId: string | 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 roomReceiveResultSchema = z.union([\n z.object({ conversationId: z.string().min(1) }),\n z.object({ sessionId: z.string().min(1) }),\n z.null(),\n]);\nexport type RoomReceiveResult = z.infer<typeof roomReceiveResultSchema>;\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 roomMessageInputSchema = 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 decisionId: 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?: RoomAuthIface | 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 decision 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// Operations available while customizing a Final chat.\nexport interface RoomPlatformIface {\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 participants(conversationId: string): 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: RoomInputResponseIface): Promise<{ resolved: boolean }>;\n };\n log(message: string, details?: Record<string, JsonValue>): void;\n}\n\nexport interface RoomInputResponseIface {\n channelBinding?: { id: string; revisionId: string };\n auth?: RoomAuthIface | null;\n participantId: string;\n decisionId: string;\n outcome: JsonValue;\n actorParticipantId: string;\n userId: string | null;\n}\n\nexport interface RoomReceiveContextIface {\n bindings?: HostedBindingsIface;\n platform: RoomPlatformIface;\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?: RoomInputResponseIface;\n conversationId?: string;\n cancelReason?: string;\n // Preserve this boundary when forwarding a retryable conversation Stop.\n cancelThroughMessageSeq?: number;\n requestedDelivery?: Delivery;\n}\n\nexport interface ProjectionContextIface<State = JsonValue> {\n bindings?: HostedBindingsIface;\n sessionId?: string;\n platform: RoomPlatformIface;\n // The binding's config and the agent's secrets (manifest.secrets), as receive gets them:\n // a channel posts its replies back to its own service with them.\n config: JsonObject;\n secrets: { get(name: string): Promise<string | null> };\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 DecisionEventKind {\n Created = 'decision.created',\n Resolved = 'decision.resolved',\n}\n\nexport type AcpUpdateKind = SessionUpdate['sessionUpdate'];\n// The update kinds ACP v2 names; AcpUpdateKind also admits any other string.\nexport type KnownAcpUpdateKind = `${SessionUpdateKind}`;\n\nexport type RoomEventKind = AcpUpdateKind | `${DecisionEventKind}` | `${SemanticChannelEventKind}`;\n\nexport interface RoomEventIface {\n type: string;\n data: JsonValue;\n seq: number;\n}\n\nexport type RoomEventHandler<State = JsonValue> = (\n event: RoomEventIface,\n ctx: ProjectionContextIface<State>,\n) => Promise<void>;\n\nexport enum DecisionKind {\n Permission = 'permission',\n Elicitation = 'elicitation',\n}\n\n// `data` of a decision.created event: an ACP session/request_permission or\n// elicitation/create request awaiting its audience.\nexport const decisionCreatedDataSchema = z.object({\n decisionId: z.string().min(1),\n kind: z.nativeEnum(DecisionKind),\n audienceParticipantIds: z.array(z.string()),\n request: jsonValueSchema,\n});\n\nexport type DecisionCreatedDataIface = z.infer<typeof decisionCreatedDataSchema>;\n\n// `data` of a decision.resolved event: the answer (or cancellation) as recorded,\n// and the principal a channel answered as (null for Final rooms and expiries).\nexport const decisionResolvedDataSchema = z.object({\n decisionId: z.string().min(1),\n outcome: jsonValueSchema,\n respondedBy: roomAuthSchema.nullable().default(null),\n});\n\nexport type DecisionResolvedDataIface = z.infer<typeof decisionResolvedDataSchema>;\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// The Final chat admission, routing and rendering extension.\nexport interface RoomSurfaceDefinitionIface<Inbound, State = undefined> {\n config?: JsonObject;\n configure?: (config: JsonObject) => RoomSurfaceDefinitionIface<Inbound, State>;\n respond?(\n input: RoomInputResponseIface,\n ctx: RoomReceiveContextIface,\n ): Promise<{ resolved: boolean }>;\n cancel?(ctx: RoomReceiveContextIface): Promise<{ accepted: boolean }>;\n // Inserts the input into its conversation and routes it. Returns where it went.\n receive(input: Inbound, ctx: RoomReceiveContextIface): Promise<RoomReceiveResult>;\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<RoomEventKind, RoomEventHandler<State>>>;\n}\n\nexport const defineRoomSurface = <Inbound, State = undefined>(\n definition: RoomSurfaceDefinitionIface<Inbound, State>,\n): RoomSurfaceDefinitionIface<Inbound, State> => definition;\n"],
|
|
5
|
-
"mappings": "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",
|
|
6
|
-
"names": ["RoomPrincipalType", "ConversationKind", "ParticipantKind", "RoutingMode", "TurnPolicy", "Delivery", "MessageKind", "CardKind", "DecisionEventKind", "DecisionKind"]
|
|
7
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { SandboxOpener, SandboxOpenScopeGlobalIface, SandboxOpenScopeIface } from "./open-scope.mjs";
|
|
2
|
-
export declare const sandboxOpenScope: SandboxOpenScopeIface;
|
|
3
|
-
export declare const installSandboxOpenScope: (target: SandboxOpenScopeGlobalIface) => void;
|
|
4
|
-
export declare const withSandboxOpener: <T>(opener: SandboxOpener, run: () => T) => Promise<Awaited<T>>;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
-
const openers = new AsyncLocalStorage();
|
|
3
|
-
const sandboxOpenScope = {
|
|
4
|
-
current: () => openers.getStore() ?? null
|
|
5
|
-
};
|
|
6
|
-
const installSandboxOpenScope = (target) => {
|
|
7
|
-
target.__finalSandboxOpenScope = sandboxOpenScope;
|
|
8
|
-
};
|
|
9
|
-
const withSandboxOpener = (opener, run) => {
|
|
10
|
-
if (globalThis.__finalSandboxOpenScope !== sandboxOpenScope) installSandboxOpenScope(globalThis);
|
|
11
|
-
const settle = async () => await run();
|
|
12
|
-
return openers.run(opener, settle);
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
installSandboxOpenScope,
|
|
16
|
-
sandboxOpenScope,
|
|
17
|
-
withSandboxOpener
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=open-scope-node.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../../../src/sandbox/open-scope-node.ts"],
|
|
4
|
-
"sourcesContent": ["import { AsyncLocalStorage } from 'node:async_hooks';\nimport type {\n SandboxOpener,\n SandboxOpenScopeGlobalIface,\n SandboxOpenScopeIface,\n} from \"./open-scope.mjs\";\n\n// The runtime half of open-scope.ts, for isolate runtimes with\n// AsyncLocalStorage (Node, workerd with nodejs_compat): runs a sandbox.ts\n// selector with its opener as the current one, so concurrent selectors in one\n// isolate each open their own session's target.\n\nconst openers = new AsyncLocalStorage<SandboxOpener>();\n\nexport const sandboxOpenScope: SandboxOpenScopeIface = {\n current: () => openers.getStore() ?? null,\n};\n\n// Installs the scope on a global object (the isolate's, or a local realm's).\nexport const installSandboxOpenScope = (target: SandboxOpenScopeGlobalIface): void => {\n target.__finalSandboxOpenScope = sandboxOpenScope;\n};\n\n// Settles inside the scope, so a selector that returns an open request\n// (`() => computer().open()`) is opened by its own opener too.\nexport const withSandboxOpener = <T>(opener: SandboxOpener, run: () => T): Promise<Awaited<T>> => {\n if (globalThis.__finalSandboxOpenScope !== sandboxOpenScope) installSandboxOpenScope(globalThis);\n const settle = async (): Promise<Awaited<T>> => await run();\n return openers.run(opener, settle);\n};\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,yBAAyB;AAYlC,MAAM,UAAU,IAAI,kBAAiC;AAE9C,MAAM,mBAA0C;AAAA,EACrD,SAAS,MAAM,QAAQ,SAAS,KAAK;AACvC;AAGO,MAAM,0BAA0B,CAAC,WAA8C;AACpF,SAAO,0BAA0B;AACnC;AAIO,MAAM,oBAAoB,CAAI,QAAuB,QAAsC;AAChG,MAAI,WAAW,4BAA4B,iBAAkB,yBAAwB,UAAU;AAC/F,QAAM,SAAS,YAAiC,MAAM,IAAI;AAC1D,SAAO,QAAQ,IAAI,QAAQ,MAAM;AACnC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
import type { NetworkSandboxSessionIface, SandboxOpenRequestIface } from "./types.mjs";
|
|
3
|
-
export type SandboxOpener = (request: SandboxOpenRequestIface<unknown, unknown>) => Promise<NetworkSandboxSessionIface>;
|
|
4
|
-
export interface SandboxOpenScopeIface {
|
|
5
|
-
current(): SandboxOpener | null;
|
|
6
|
-
}
|
|
7
|
-
declare global {
|
|
8
|
-
var __finalSandboxOpenScope: unknown;
|
|
9
|
-
}
|
|
10
|
-
export interface SandboxOpenScopeGlobalIface {
|
|
11
|
-
__finalSandboxOpenScope?: unknown;
|
|
12
|
-
}
|
|
13
|
-
export type AwaitableSandboxOpenRequestIface<EnvOptions, OpenOptions> = SandboxOpenRequestIface<EnvOptions, OpenOptions> & PromiseLike<NetworkSandboxSessionIface>;
|
|
14
|
-
export declare const unopenedRequestOf: (cause: unknown) => SandboxOpenRequestIface<unknown, unknown> | null;
|
|
15
|
-
export declare const awaitableOpenRequest: <T extends SandboxOpenRequestIface<unknown, unknown>>(request: T) => T & PromiseLike<NetworkSandboxSessionIface>;
|
|
16
|
-
export declare const sandboxSessionSchema: z.ZodCustom<NetworkSandboxSessionIface, NetworkSandboxSessionIface>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import * as z from "zod";
|
|
2
|
-
const openRequestFieldsSchema = z.looseObject({
|
|
3
|
-
providerName: z.string(),
|
|
4
|
-
environmentOptions: z.unknown(),
|
|
5
|
-
openOptions: z.unknown()
|
|
6
|
-
});
|
|
7
|
-
const unopenedSchema = z.object({
|
|
8
|
-
unopenedRequest: openRequestFieldsSchema
|
|
9
|
-
});
|
|
10
|
-
const unopenedRequestOf = (cause) => {
|
|
11
|
-
const parsed = unopenedSchema.safeParse(cause);
|
|
12
|
-
return parsed.success ? parsed.data.unopenedRequest : null;
|
|
13
|
-
};
|
|
14
|
-
const scopeMethodsSchema = z.looseObject({ current: z.function() });
|
|
15
|
-
const sandboxOpenScopeSchema = z.custom(
|
|
16
|
-
(value) => scopeMethodsSchema.safeParse(value).success
|
|
17
|
-
);
|
|
18
|
-
const awaitableOpenRequest = (request) => {
|
|
19
|
-
const then = (onFulfilled, onRejected) => {
|
|
20
|
-
const scope = sandboxOpenScopeSchema.safeParse(globalThis.__finalSandboxOpenScope).data;
|
|
21
|
-
const opener = scope?.current() ?? null;
|
|
22
|
-
const opened = opener == null ? Promise.reject(
|
|
23
|
-
Object.assign(
|
|
24
|
-
new Error(
|
|
25
|
-
`awaiting ${request.providerName}.open() opens a sandbox only inside a defineSandbox selector`
|
|
26
|
-
),
|
|
27
|
-
{ unopenedRequest: { ...request } }
|
|
28
|
-
)
|
|
29
|
-
) : opener(request);
|
|
30
|
-
return opened.then(onFulfilled, onRejected);
|
|
31
|
-
};
|
|
32
|
-
const awaitable = Object.assign(request, { then });
|
|
33
|
-
Object.defineProperty(awaitable, "then", { enumerable: false });
|
|
34
|
-
return awaitable;
|
|
35
|
-
};
|
|
36
|
-
const sessionMethodsSchema = z.looseObject({
|
|
37
|
-
id: z.string(),
|
|
38
|
-
description: z.string(),
|
|
39
|
-
defaultWorkingDirectory: z.string(),
|
|
40
|
-
ports: z.array(z.number()),
|
|
41
|
-
readFile: z.function(),
|
|
42
|
-
readBinaryFile: z.function(),
|
|
43
|
-
readTextFile: z.function(),
|
|
44
|
-
writeFile: z.function(),
|
|
45
|
-
writeBinaryFile: z.function(),
|
|
46
|
-
writeTextFile: z.function(),
|
|
47
|
-
spawn: z.function(),
|
|
48
|
-
run: z.function(),
|
|
49
|
-
stat: z.function(),
|
|
50
|
-
readDir: z.function(),
|
|
51
|
-
resolvePath: z.function(),
|
|
52
|
-
removePath: z.function(),
|
|
53
|
-
getPortEndpoint: z.function(),
|
|
54
|
-
getPortUrl: z.function(),
|
|
55
|
-
stop: z.function(),
|
|
56
|
-
destroy: z.function()
|
|
57
|
-
});
|
|
58
|
-
const sandboxSessionSchema = z.custom(
|
|
59
|
-
(value) => sessionMethodsSchema.safeParse(value).success
|
|
60
|
-
);
|
|
61
|
-
export {
|
|
62
|
-
awaitableOpenRequest,
|
|
63
|
-
sandboxSessionSchema,
|
|
64
|
-
unopenedRequestOf
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=open-scope.mjs.map
|