@moxt-ai/mobius-protocol 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codecs/messages.d.ts +1 -0
- package/dist/codecs/messages.d.ts.map +1 -1
- package/dist/codecs/messages.js +11 -2
- package/dist/codecs/messages.js.map +1 -1
- package/dist/control-messages.d.ts +94 -0
- package/dist/control-messages.d.ts.map +1 -1
- package/dist/control-messages.js +132 -4
- package/dist/control-messages.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/messages.d.ts +2 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/messages.js.map +1 -1
- package/dist/resource-model.d.ts +18 -0
- package/dist/resource-model.d.ts.map +1 -1
- package/dist/resource-model.js +2 -1
- package/dist/resource-model.js.map +1 -1
- package/package.json +1 -1
- package/dist/bot.d.ts +0 -404
- package/dist/bot.d.ts.map +0 -1
- package/dist/bot.js +0 -954
- package/dist/bot.js.map +0 -1
package/dist/bot.js
DELETED
|
@@ -1,954 +0,0 @@
|
|
|
1
|
-
import { ProtocolMessageError } from "./codecs/messages.js";
|
|
2
|
-
import { decodePromptImagesValue, decodePromptResourcesValue, decodeSessionConfigurationSelections, } from "./control-messages.js";
|
|
3
|
-
import { SessionPromptDisposition } from "./messages.js";
|
|
4
|
-
export const BOT_BINDING_APPROVAL_REQUEST_KIND = "bot.binding.approval.request";
|
|
5
|
-
export const BOT_BINDING_APPROVED_KIND = "bot.binding.approved";
|
|
6
|
-
export const BOT_BINDING_UNAVAILABLE_KIND = "bot.binding.unavailable";
|
|
7
|
-
export const BOT_SESSION_PROMPT_KIND = "bot.session.prompt";
|
|
8
|
-
const IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
9
|
-
const DIRECTORY_IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,2047}$/;
|
|
10
|
-
const TOKEN_PATTERN = /^[a-zA-Z0-9_-]{32,256}$/;
|
|
11
|
-
const SHA256_PATTERN = /^[a-f0-9]{64}$/;
|
|
12
|
-
const MAX_INSTRUCTIONS_LENGTH = 100_000;
|
|
13
|
-
export class BotResource {
|
|
14
|
-
botId;
|
|
15
|
-
projectId;
|
|
16
|
-
currentProfileRevisionId;
|
|
17
|
-
lifecycleRevision;
|
|
18
|
-
createdAt;
|
|
19
|
-
updatedAt;
|
|
20
|
-
constructor(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt) {
|
|
21
|
-
this.botId = botId;
|
|
22
|
-
this.projectId = projectId;
|
|
23
|
-
this.currentProfileRevisionId = currentProfileRevisionId;
|
|
24
|
-
this.lifecycleRevision = lifecycleRevision;
|
|
25
|
-
this.createdAt = createdAt;
|
|
26
|
-
this.updatedAt = updatedAt;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export class DraftBot extends BotResource {
|
|
30
|
-
lifecycle = "draft";
|
|
31
|
-
constructor(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt) {
|
|
32
|
-
super(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
export class ActiveBot extends BotResource {
|
|
36
|
-
lifecycle = "active";
|
|
37
|
-
activeBehaviorRevisionId;
|
|
38
|
-
activeBindingId;
|
|
39
|
-
constructor(botId, projectId, currentProfileRevisionId, activeBehaviorRevisionId, activeBindingId, lifecycleRevision, createdAt, updatedAt) {
|
|
40
|
-
super(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt);
|
|
41
|
-
this.activeBehaviorRevisionId = activeBehaviorRevisionId;
|
|
42
|
-
this.activeBindingId = activeBindingId;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export class SuspendedBot extends BotResource {
|
|
46
|
-
lifecycle = "suspended";
|
|
47
|
-
activeBehaviorRevisionId;
|
|
48
|
-
activeBindingId;
|
|
49
|
-
suspendedAt;
|
|
50
|
-
constructor(botId, projectId, currentProfileRevisionId, activeBehaviorRevisionId, activeBindingId, lifecycleRevision, createdAt, updatedAt, suspendedAt) {
|
|
51
|
-
super(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt);
|
|
52
|
-
this.activeBehaviorRevisionId = activeBehaviorRevisionId;
|
|
53
|
-
this.activeBindingId = activeBindingId;
|
|
54
|
-
this.suspendedAt = suspendedAt;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
export class ArchivedBot extends BotResource {
|
|
58
|
-
lifecycle = "archived";
|
|
59
|
-
archivedAt;
|
|
60
|
-
constructor(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt, archivedAt) {
|
|
61
|
-
super(botId, projectId, currentProfileRevisionId, lifecycleRevision, createdAt, updatedAt);
|
|
62
|
-
this.archivedAt = archivedAt;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export class BotProfileRevision {
|
|
66
|
-
avatarRef;
|
|
67
|
-
botId;
|
|
68
|
-
createdAt;
|
|
69
|
-
description;
|
|
70
|
-
displayName;
|
|
71
|
-
profileRevisionId;
|
|
72
|
-
revisionNumber;
|
|
73
|
-
constructor(profileRevisionId, botId, revisionNumber, displayName, avatarRef, description, createdAt) {
|
|
74
|
-
this.profileRevisionId = profileRevisionId;
|
|
75
|
-
this.botId = botId;
|
|
76
|
-
this.revisionNumber = revisionNumber;
|
|
77
|
-
this.displayName = displayName;
|
|
78
|
-
this.avatarRef = avatarRef;
|
|
79
|
-
this.description = description;
|
|
80
|
-
this.createdAt = createdAt;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
export class BotBehaviorRevision {
|
|
84
|
-
agentConfiguration;
|
|
85
|
-
behaviorRevisionId;
|
|
86
|
-
botId;
|
|
87
|
-
contentDigest;
|
|
88
|
-
createdAt;
|
|
89
|
-
instructions;
|
|
90
|
-
requiredCapabilities;
|
|
91
|
-
revisionNumber;
|
|
92
|
-
constructor(behaviorRevisionId, botId, revisionNumber, instructions, requiredCapabilities, agentConfiguration, contentDigest, createdAt) {
|
|
93
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
94
|
-
this.botId = botId;
|
|
95
|
-
this.revisionNumber = revisionNumber;
|
|
96
|
-
this.instructions = instructions;
|
|
97
|
-
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
98
|
-
this.agentConfiguration = Object.freeze({ ...agentConfiguration });
|
|
99
|
-
this.contentDigest = contentDigest;
|
|
100
|
-
this.createdAt = createdAt;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export class ProposedBotBehavior extends BotBehaviorRevision {
|
|
104
|
-
lifecycle = "proposed";
|
|
105
|
-
constructor(behaviorRevisionId, botId, revisionNumber, instructions, requiredCapabilities, agentConfiguration, contentDigest, createdAt) {
|
|
106
|
-
super(behaviorRevisionId, botId, revisionNumber, instructions, requiredCapabilities, agentConfiguration, contentDigest, createdAt);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export class AwaitingLocalApprovalBotBehavior extends BotBehaviorRevision {
|
|
110
|
-
lifecycle = "awaiting_local_approval";
|
|
111
|
-
constructor(behavior) {
|
|
112
|
-
super(behavior.behaviorRevisionId, behavior.botId, behavior.revisionNumber, behavior.instructions, behavior.requiredCapabilities, behavior.agentConfiguration, behavior.contentDigest, behavior.createdAt);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
export class ApprovedBotBehavior extends BotBehaviorRevision {
|
|
116
|
-
approvedAt;
|
|
117
|
-
lifecycle = "approved";
|
|
118
|
-
constructor(behavior, approvedAt) {
|
|
119
|
-
super(behavior.behaviorRevisionId, behavior.botId, behavior.revisionNumber, behavior.instructions, behavior.requiredCapabilities, behavior.agentConfiguration, behavior.contentDigest, behavior.createdAt);
|
|
120
|
-
this.approvedAt = approvedAt;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
export class RetiredBotBehavior extends BotBehaviorRevision {
|
|
124
|
-
lifecycle = "retired";
|
|
125
|
-
retiredAt;
|
|
126
|
-
constructor(behavior, retiredAt) {
|
|
127
|
-
super(behavior.behaviorRevisionId, behavior.botId, behavior.revisionNumber, behavior.instructions, behavior.requiredCapabilities, behavior.agentConfiguration, behavior.contentDigest, behavior.createdAt);
|
|
128
|
-
this.retiredAt = retiredAt;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
export class BotExecutionBinding {
|
|
132
|
-
agentConfigRevision;
|
|
133
|
-
agentRef;
|
|
134
|
-
allowedDeliveryTargetIds;
|
|
135
|
-
behaviorRevisionId;
|
|
136
|
-
bindingId;
|
|
137
|
-
bindingRevision;
|
|
138
|
-
botId;
|
|
139
|
-
completionPolicy;
|
|
140
|
-
createdAt;
|
|
141
|
-
runtimeId;
|
|
142
|
-
workspaceRef;
|
|
143
|
-
constructor(bindingId, botId, behaviorRevisionId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, allowedDeliveryTargetIds, completionPolicy, createdAt) {
|
|
144
|
-
this.bindingId = bindingId;
|
|
145
|
-
this.botId = botId;
|
|
146
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
147
|
-
this.bindingRevision = bindingRevision;
|
|
148
|
-
this.runtimeId = runtimeId;
|
|
149
|
-
this.agentRef = agentRef;
|
|
150
|
-
this.workspaceRef = workspaceRef;
|
|
151
|
-
this.agentConfigRevision = agentConfigRevision;
|
|
152
|
-
this.allowedDeliveryTargetIds = Object.freeze([...allowedDeliveryTargetIds]);
|
|
153
|
-
this.completionPolicy = completionPolicy;
|
|
154
|
-
this.createdAt = createdAt;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
export class RequestedBotExecutionBinding extends BotExecutionBinding {
|
|
158
|
-
lifecycle = "requested";
|
|
159
|
-
constructor(bindingId, botId, behaviorRevisionId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, allowedDeliveryTargetIds, completionPolicy, createdAt) {
|
|
160
|
-
super(bindingId, botId, behaviorRevisionId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, allowedDeliveryTargetIds, completionPolicy, createdAt);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
export class ApprovedBotExecutionBinding extends BotExecutionBinding {
|
|
164
|
-
agentIdentityDigest;
|
|
165
|
-
approvedAt;
|
|
166
|
-
lifecycle = "approved";
|
|
167
|
-
localGrantId;
|
|
168
|
-
workspaceIdentityDigest;
|
|
169
|
-
constructor(binding, localGrantId, agentIdentityDigest, workspaceIdentityDigest, approvedAt) {
|
|
170
|
-
super(binding.bindingId, binding.botId, binding.behaviorRevisionId, binding.bindingRevision, binding.runtimeId, binding.agentRef, binding.workspaceRef, binding.agentConfigRevision, binding.allowedDeliveryTargetIds, binding.completionPolicy, binding.createdAt);
|
|
171
|
-
this.localGrantId = localGrantId;
|
|
172
|
-
this.agentIdentityDigest = agentIdentityDigest;
|
|
173
|
-
this.workspaceIdentityDigest = workspaceIdentityDigest;
|
|
174
|
-
this.approvedAt = approvedAt;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
export class UnavailableBotExecutionBinding extends BotExecutionBinding {
|
|
178
|
-
code;
|
|
179
|
-
lifecycle = "unavailable";
|
|
180
|
-
message;
|
|
181
|
-
unavailableAt;
|
|
182
|
-
constructor(binding, code, message, unavailableAt) {
|
|
183
|
-
super(binding.bindingId, binding.botId, binding.behaviorRevisionId, binding.bindingRevision, binding.runtimeId, binding.agentRef, binding.workspaceRef, binding.agentConfigRevision, binding.allowedDeliveryTargetIds, binding.completionPolicy, binding.createdAt);
|
|
184
|
-
this.code = code;
|
|
185
|
-
this.message = message;
|
|
186
|
-
this.unavailableAt = unavailableAt;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
export class RevokedBotExecutionBinding extends BotExecutionBinding {
|
|
190
|
-
lifecycle = "revoked";
|
|
191
|
-
revokedAt;
|
|
192
|
-
constructor(binding, revokedAt) {
|
|
193
|
-
super(binding.bindingId, binding.botId, binding.behaviorRevisionId, binding.bindingRevision, binding.runtimeId, binding.agentRef, binding.workspaceRef, binding.agentConfigRevision, binding.allowedDeliveryTargetIds, binding.completionPolicy, binding.createdAt);
|
|
194
|
-
this.revokedAt = revokedAt;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
export class BotDeliveryTargetReference {
|
|
198
|
-
alias;
|
|
199
|
-
deliveryTargetId;
|
|
200
|
-
constructor(alias, deliveryTargetId) {
|
|
201
|
-
this.alias = alias;
|
|
202
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
export class BotDeliveryTarget {
|
|
206
|
-
alias;
|
|
207
|
-
botId;
|
|
208
|
-
connectionId;
|
|
209
|
-
createdAt;
|
|
210
|
-
deliveryTargetId;
|
|
211
|
-
lifecycleRevision;
|
|
212
|
-
outboundPolicyRevision;
|
|
213
|
-
ownerApproved;
|
|
214
|
-
constructor(deliveryTargetId, botId, connectionId, alias, outboundPolicyRevision, lifecycleRevision, ownerApproved, createdAt) {
|
|
215
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
216
|
-
this.botId = botId;
|
|
217
|
-
this.connectionId = connectionId;
|
|
218
|
-
this.alias = alias;
|
|
219
|
-
this.outboundPolicyRevision = outboundPolicyRevision;
|
|
220
|
-
this.lifecycleRevision = lifecycleRevision;
|
|
221
|
-
this.ownerApproved = ownerApproved;
|
|
222
|
-
this.createdAt = createdAt;
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
export class ActiveBotDeliveryTarget extends BotDeliveryTarget {
|
|
226
|
-
lifecycle = "active";
|
|
227
|
-
constructor(deliveryTargetId, botId, connectionId, alias, outboundPolicyRevision, lifecycleRevision, ownerApproved, createdAt) {
|
|
228
|
-
super(deliveryTargetId, botId, connectionId, alias, outboundPolicyRevision, lifecycleRevision, ownerApproved, createdAt);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
export class DisabledBotDeliveryTarget extends BotDeliveryTarget {
|
|
232
|
-
disabledAt;
|
|
233
|
-
lifecycle = "disabled";
|
|
234
|
-
constructor(target, disabledAt) {
|
|
235
|
-
super(target.deliveryTargetId, target.botId, target.connectionId, target.alias, target.outboundPolicyRevision, target.lifecycleRevision + 1, false, target.createdAt);
|
|
236
|
-
this.disabledAt = disabledAt;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
export class BotCompletionDeliveryPolicy {
|
|
240
|
-
}
|
|
241
|
-
export class NoBotCompletionDeliveryPolicy extends BotCompletionDeliveryPolicy {
|
|
242
|
-
kind = "none";
|
|
243
|
-
}
|
|
244
|
-
export class RequiredBotCompletionDeliveryPolicy extends BotCompletionDeliveryPolicy {
|
|
245
|
-
deliveryTargetId;
|
|
246
|
-
kind = "required";
|
|
247
|
-
messageTemplate;
|
|
248
|
-
constructor(deliveryTargetId, messageTemplate) {
|
|
249
|
-
super();
|
|
250
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
251
|
-
this.messageTemplate = messageTemplate;
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
export class BotReplyRoute {
|
|
255
|
-
}
|
|
256
|
-
export class OwnerBotReplyRoute extends BotReplyRoute {
|
|
257
|
-
kind = "owner";
|
|
258
|
-
}
|
|
259
|
-
export class BotConnectionReplyRoute extends BotReplyRoute {
|
|
260
|
-
connectionId;
|
|
261
|
-
deliveryTargetId;
|
|
262
|
-
kind = "connection";
|
|
263
|
-
constructor(connectionId, deliveryTargetId) {
|
|
264
|
-
super();
|
|
265
|
-
this.connectionId = connectionId;
|
|
266
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
export class BotConversation {
|
|
270
|
-
behaviorRevisionId;
|
|
271
|
-
bindingId;
|
|
272
|
-
bindingRevision;
|
|
273
|
-
botId;
|
|
274
|
-
conversationId;
|
|
275
|
-
createdAt;
|
|
276
|
-
creatorPrincipalId;
|
|
277
|
-
sessionId;
|
|
278
|
-
title;
|
|
279
|
-
constructor(conversationId, botId, behaviorRevisionId, bindingId, bindingRevision, sessionId, creatorPrincipalId, title, createdAt) {
|
|
280
|
-
this.conversationId = conversationId;
|
|
281
|
-
this.botId = botId;
|
|
282
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
283
|
-
this.bindingId = bindingId;
|
|
284
|
-
this.bindingRevision = bindingRevision;
|
|
285
|
-
this.sessionId = sessionId;
|
|
286
|
-
this.creatorPrincipalId = creatorPrincipalId;
|
|
287
|
-
this.title = title;
|
|
288
|
-
this.createdAt = createdAt;
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
export class ProvisioningBotConversation extends BotConversation {
|
|
292
|
-
lifecycle = "provisioning";
|
|
293
|
-
constructor(conversationId, botId, behaviorRevisionId, bindingId, bindingRevision, sessionId, creatorPrincipalId, title, createdAt) {
|
|
294
|
-
super(conversationId, botId, behaviorRevisionId, bindingId, bindingRevision, sessionId, creatorPrincipalId, title, createdAt);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
export class ActiveBotConversation extends BotConversation {
|
|
298
|
-
activatedAt;
|
|
299
|
-
lifecycle = "active";
|
|
300
|
-
constructor(conversation, activatedAt) {
|
|
301
|
-
super(conversation.conversationId, conversation.botId, conversation.behaviorRevisionId, conversation.bindingId, conversation.bindingRevision, conversation.sessionId, conversation.creatorPrincipalId, conversation.title, conversation.createdAt);
|
|
302
|
-
this.activatedAt = activatedAt;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
export class OwnerBotConversation extends ActiveBotConversation {
|
|
306
|
-
creatorKind = "owner";
|
|
307
|
-
replyRoute = new OwnerBotReplyRoute();
|
|
308
|
-
}
|
|
309
|
-
export class ConnectedBotConversation extends ActiveBotConversation {
|
|
310
|
-
connectionId;
|
|
311
|
-
creatorKind = "connection";
|
|
312
|
-
replyRoute;
|
|
313
|
-
constructor(conversation, activatedAt, connectionId, deliveryTargetId) {
|
|
314
|
-
super(conversation, activatedAt);
|
|
315
|
-
this.connectionId = connectionId;
|
|
316
|
-
this.replyRoute = new BotConnectionReplyRoute(connectionId, deliveryTargetId);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
export class ClosedBotConversation extends BotConversation {
|
|
320
|
-
closedAt;
|
|
321
|
-
lifecycle = "closed";
|
|
322
|
-
constructor(conversation, closedAt) {
|
|
323
|
-
super(conversation.conversationId, conversation.botId, conversation.behaviorRevisionId, conversation.bindingId, conversation.bindingRevision, conversation.sessionId, conversation.creatorPrincipalId, conversation.title, conversation.createdAt);
|
|
324
|
-
this.closedAt = closedAt;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
export class BotExecution {
|
|
328
|
-
behaviorRevisionId;
|
|
329
|
-
bindingId;
|
|
330
|
-
bindingRevision;
|
|
331
|
-
botId;
|
|
332
|
-
conversationId;
|
|
333
|
-
deadlineAt;
|
|
334
|
-
executionId;
|
|
335
|
-
runtimeId;
|
|
336
|
-
turnId;
|
|
337
|
-
constructor(executionId, botId, conversationId, turnId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, deadlineAt) {
|
|
338
|
-
this.executionId = executionId;
|
|
339
|
-
this.botId = botId;
|
|
340
|
-
this.conversationId = conversationId;
|
|
341
|
-
this.turnId = turnId;
|
|
342
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
343
|
-
this.bindingId = bindingId;
|
|
344
|
-
this.bindingRevision = bindingRevision;
|
|
345
|
-
this.runtimeId = runtimeId;
|
|
346
|
-
this.deadlineAt = deadlineAt;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
export class BotExecutionCapability {
|
|
350
|
-
allowedDeliveryTargetIds;
|
|
351
|
-
behaviorRevisionId;
|
|
352
|
-
bindingId;
|
|
353
|
-
bindingRevision;
|
|
354
|
-
botId;
|
|
355
|
-
capabilityId;
|
|
356
|
-
conversationId;
|
|
357
|
-
executionId;
|
|
358
|
-
expiresAt;
|
|
359
|
-
operation;
|
|
360
|
-
turnId;
|
|
361
|
-
usageLimit;
|
|
362
|
-
constructor(capabilityId, execution, allowedDeliveryTargetIds, operation, usageLimit, expiresAt) {
|
|
363
|
-
this.capabilityId = capabilityId;
|
|
364
|
-
this.executionId = execution.executionId;
|
|
365
|
-
this.botId = execution.botId;
|
|
366
|
-
this.conversationId = execution.conversationId;
|
|
367
|
-
this.turnId = execution.turnId;
|
|
368
|
-
this.behaviorRevisionId = execution.behaviorRevisionId;
|
|
369
|
-
this.bindingId = execution.bindingId;
|
|
370
|
-
this.bindingRevision = execution.bindingRevision;
|
|
371
|
-
this.allowedDeliveryTargetIds = Object.freeze([...allowedDeliveryTargetIds]);
|
|
372
|
-
this.operation = operation;
|
|
373
|
-
this.usageLimit = usageLimit;
|
|
374
|
-
this.expiresAt = expiresAt;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
export class BotConnection {
|
|
378
|
-
audience;
|
|
379
|
-
botId;
|
|
380
|
-
connectionId;
|
|
381
|
-
connectorPrincipalId;
|
|
382
|
-
createdAt;
|
|
383
|
-
label;
|
|
384
|
-
lifecycleRevision;
|
|
385
|
-
scopes;
|
|
386
|
-
constructor(connectionId, botId, connectorPrincipalId, audience, label, scopes, lifecycleRevision, createdAt) {
|
|
387
|
-
this.connectionId = connectionId;
|
|
388
|
-
this.botId = botId;
|
|
389
|
-
this.connectorPrincipalId = connectorPrincipalId;
|
|
390
|
-
this.audience = audience;
|
|
391
|
-
this.label = label;
|
|
392
|
-
this.scopes = Object.freeze([...scopes]);
|
|
393
|
-
this.lifecycleRevision = lifecycleRevision;
|
|
394
|
-
this.createdAt = createdAt;
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
export class ActiveBotConnection extends BotConnection {
|
|
398
|
-
lastUsedAt;
|
|
399
|
-
lifecycle = "active";
|
|
400
|
-
constructor(connectionId, botId, connectorPrincipalId, audience, label, scopes, lifecycleRevision, createdAt, lastUsedAt) {
|
|
401
|
-
super(connectionId, botId, connectorPrincipalId, audience, label, scopes, lifecycleRevision, createdAt);
|
|
402
|
-
this.lastUsedAt = lastUsedAt;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
export class RevokedBotConnection extends BotConnection {
|
|
406
|
-
lifecycle = "revoked";
|
|
407
|
-
revokedAt;
|
|
408
|
-
constructor(connection, revokedAt) {
|
|
409
|
-
super(connection.connectionId, connection.botId, connection.connectorPrincipalId, connection.audience, connection.label, connection.scopes, connection.lifecycleRevision, connection.createdAt);
|
|
410
|
-
this.revokedAt = revokedAt;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
export class BotConnectionCredential {
|
|
414
|
-
connectionId;
|
|
415
|
-
credentialId;
|
|
416
|
-
expiresAt;
|
|
417
|
-
issuedAt;
|
|
418
|
-
lastUsedAt;
|
|
419
|
-
secretDigest;
|
|
420
|
-
constructor(credentialId, connectionId, secretDigest, issuedAt, expiresAt, lastUsedAt) {
|
|
421
|
-
this.credentialId = credentialId;
|
|
422
|
-
this.connectionId = connectionId;
|
|
423
|
-
this.secretDigest = secretDigest;
|
|
424
|
-
this.issuedAt = issuedAt;
|
|
425
|
-
this.expiresAt = expiresAt;
|
|
426
|
-
this.lastUsedAt = lastUsedAt;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
export class BotConnectionGrant {
|
|
430
|
-
audience;
|
|
431
|
-
botId;
|
|
432
|
-
expiresAt;
|
|
433
|
-
grantId;
|
|
434
|
-
scopes;
|
|
435
|
-
secretDigest;
|
|
436
|
-
constructor(grantId, botId, audience, scopes, secretDigest, expiresAt) {
|
|
437
|
-
this.grantId = grantId;
|
|
438
|
-
this.botId = botId;
|
|
439
|
-
this.audience = audience;
|
|
440
|
-
this.scopes = Object.freeze([...scopes]);
|
|
441
|
-
this.secretDigest = secretDigest;
|
|
442
|
-
this.expiresAt = expiresAt;
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
export class OutboundMessageDelivery {
|
|
446
|
-
acceptedAt;
|
|
447
|
-
behaviorRevisionId;
|
|
448
|
-
bindingId;
|
|
449
|
-
bindingRevision;
|
|
450
|
-
botId;
|
|
451
|
-
conversationId;
|
|
452
|
-
deliveryTargetId;
|
|
453
|
-
executionId;
|
|
454
|
-
expiresAt;
|
|
455
|
-
idempotencyKey;
|
|
456
|
-
outboundMessageId;
|
|
457
|
-
text;
|
|
458
|
-
turnId;
|
|
459
|
-
constructor(outboundMessageId, botId, conversationId, turnId, behaviorRevisionId, bindingId, bindingRevision, executionId, deliveryTargetId, idempotencyKey, text, acceptedAt, expiresAt) {
|
|
460
|
-
this.outboundMessageId = outboundMessageId;
|
|
461
|
-
this.botId = botId;
|
|
462
|
-
this.conversationId = conversationId;
|
|
463
|
-
this.turnId = turnId;
|
|
464
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
465
|
-
this.bindingId = bindingId;
|
|
466
|
-
this.bindingRevision = bindingRevision;
|
|
467
|
-
this.executionId = executionId;
|
|
468
|
-
this.deliveryTargetId = deliveryTargetId;
|
|
469
|
-
this.idempotencyKey = idempotencyKey;
|
|
470
|
-
this.text = text;
|
|
471
|
-
this.acceptedAt = acceptedAt;
|
|
472
|
-
this.expiresAt = expiresAt;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
export class AcceptedOutboundMessage extends OutboundMessageDelivery {
|
|
476
|
-
state = "accepted";
|
|
477
|
-
}
|
|
478
|
-
export class SequencedOutboundMessage extends OutboundMessageDelivery {
|
|
479
|
-
sequence;
|
|
480
|
-
constructor(message, sequence) {
|
|
481
|
-
super(message.outboundMessageId, message.botId, message.conversationId, message.turnId, message.behaviorRevisionId, message.bindingId, message.bindingRevision, message.executionId, message.deliveryTargetId, message.idempotencyKey, message.text, message.acceptedAt, message.expiresAt);
|
|
482
|
-
this.sequence = sequence;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
export class QueuedOutboundMessage extends SequencedOutboundMessage {
|
|
486
|
-
state = "queued";
|
|
487
|
-
}
|
|
488
|
-
export class ClaimedOutboundMessage extends SequencedOutboundMessage {
|
|
489
|
-
claimDeadlineAt;
|
|
490
|
-
claimId;
|
|
491
|
-
state = "claimed";
|
|
492
|
-
constructor(message, claimId, claimDeadlineAt) {
|
|
493
|
-
super(message, message.sequence);
|
|
494
|
-
this.claimId = claimId;
|
|
495
|
-
this.claimDeadlineAt = claimDeadlineAt;
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
export class DeliveredOutboundMessage extends SequencedOutboundMessage {
|
|
499
|
-
deliveredAt;
|
|
500
|
-
state = "delivered";
|
|
501
|
-
constructor(message, deliveredAt) {
|
|
502
|
-
super(message, message.sequence);
|
|
503
|
-
this.deliveredAt = deliveredAt;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
export class RetryableFailedOutboundMessage extends SequencedOutboundMessage {
|
|
507
|
-
failedAt;
|
|
508
|
-
failureCode;
|
|
509
|
-
nextAttemptAt;
|
|
510
|
-
state = "retryable_failed";
|
|
511
|
-
constructor(message, failureCode, failedAt, nextAttemptAt) {
|
|
512
|
-
super(message, message.sequence);
|
|
513
|
-
this.failureCode = failureCode;
|
|
514
|
-
this.failedAt = failedAt;
|
|
515
|
-
this.nextAttemptAt = nextAttemptAt;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
export class TerminalFailedOutboundMessage extends SequencedOutboundMessage {
|
|
519
|
-
failedAt;
|
|
520
|
-
failureCode;
|
|
521
|
-
state = "terminal_failed";
|
|
522
|
-
constructor(message, failureCode, failedAt) {
|
|
523
|
-
super(message, message.sequence);
|
|
524
|
-
this.failureCode = failureCode;
|
|
525
|
-
this.failedAt = failedAt;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
export class BotExecutionBindingApprovalRequest {
|
|
529
|
-
agentConfigRevision;
|
|
530
|
-
agentRef;
|
|
531
|
-
allowedDeliveryTargets;
|
|
532
|
-
behaviorDigest;
|
|
533
|
-
behaviorInstructions;
|
|
534
|
-
behaviorRevisionId;
|
|
535
|
-
bindingId;
|
|
536
|
-
bindingRevision;
|
|
537
|
-
botId;
|
|
538
|
-
completionPolicy;
|
|
539
|
-
kind = BOT_BINDING_APPROVAL_REQUEST_KIND;
|
|
540
|
-
requestId;
|
|
541
|
-
requiredCapabilities;
|
|
542
|
-
runtimeId;
|
|
543
|
-
sessionConfigurations;
|
|
544
|
-
workspaceRef;
|
|
545
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, runtimeId, agentRef, workspaceRef, agentConfigRevision, behaviorInstructions, behaviorDigest, requiredCapabilities, allowedDeliveryTargets, completionPolicy, sessionConfigurations = []) {
|
|
546
|
-
this.requestId = requestId;
|
|
547
|
-
this.botId = botId;
|
|
548
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
549
|
-
this.bindingId = bindingId;
|
|
550
|
-
this.bindingRevision = bindingRevision;
|
|
551
|
-
this.runtimeId = runtimeId;
|
|
552
|
-
this.agentRef = agentRef;
|
|
553
|
-
this.workspaceRef = workspaceRef;
|
|
554
|
-
this.agentConfigRevision = agentConfigRevision;
|
|
555
|
-
this.behaviorInstructions = behaviorInstructions;
|
|
556
|
-
this.behaviorDigest = behaviorDigest;
|
|
557
|
-
this.requiredCapabilities = Object.freeze([...requiredCapabilities]);
|
|
558
|
-
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
559
|
-
this.allowedDeliveryTargets = Object.freeze(allowedDeliveryTargets.map((target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)));
|
|
560
|
-
this.completionPolicy = completionPolicy;
|
|
561
|
-
}
|
|
562
|
-
toJSON() {
|
|
563
|
-
const { sessionConfigurations, ...request } = this;
|
|
564
|
-
return {
|
|
565
|
-
...request,
|
|
566
|
-
...(sessionConfigurations.length === 0 ? {} : { sessionConfigurations }),
|
|
567
|
-
};
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
export class BotExecutionBindingApprovedEvent {
|
|
571
|
-
agentIdentityDigest;
|
|
572
|
-
behaviorRevisionId;
|
|
573
|
-
bindingId;
|
|
574
|
-
bindingRevision;
|
|
575
|
-
botId;
|
|
576
|
-
kind = BOT_BINDING_APPROVED_KIND;
|
|
577
|
-
localGrantId;
|
|
578
|
-
requestId;
|
|
579
|
-
workspaceIdentityDigest;
|
|
580
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, localGrantId, agentIdentityDigest, workspaceIdentityDigest) {
|
|
581
|
-
this.requestId = requestId;
|
|
582
|
-
this.botId = botId;
|
|
583
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
584
|
-
this.bindingId = bindingId;
|
|
585
|
-
this.bindingRevision = bindingRevision;
|
|
586
|
-
this.localGrantId = localGrantId;
|
|
587
|
-
this.agentIdentityDigest = agentIdentityDigest;
|
|
588
|
-
this.workspaceIdentityDigest = workspaceIdentityDigest;
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
export class BotExecutionBindingUnavailableEvent {
|
|
592
|
-
behaviorRevisionId;
|
|
593
|
-
bindingId;
|
|
594
|
-
bindingRevision;
|
|
595
|
-
botId;
|
|
596
|
-
code;
|
|
597
|
-
kind = BOT_BINDING_UNAVAILABLE_KIND;
|
|
598
|
-
message;
|
|
599
|
-
requestId;
|
|
600
|
-
constructor(requestId, botId, behaviorRevisionId, bindingId, bindingRevision, code, message) {
|
|
601
|
-
this.requestId = requestId;
|
|
602
|
-
this.botId = botId;
|
|
603
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
604
|
-
this.bindingId = bindingId;
|
|
605
|
-
this.bindingRevision = bindingRevision;
|
|
606
|
-
this.code = code;
|
|
607
|
-
this.message = message;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
export class BotSessionPromptCommand {
|
|
611
|
-
additionalDirectoryIds;
|
|
612
|
-
agentId;
|
|
613
|
-
allowedDeliveryTargets;
|
|
614
|
-
behaviorDigest;
|
|
615
|
-
behaviorInstructions;
|
|
616
|
-
behaviorRevisionId;
|
|
617
|
-
bindingId;
|
|
618
|
-
bindingRevision;
|
|
619
|
-
botId;
|
|
620
|
-
commandId;
|
|
621
|
-
conversationId;
|
|
622
|
-
directoryId;
|
|
623
|
-
disposition;
|
|
624
|
-
executionCapabilityId;
|
|
625
|
-
executionCapabilitySecret;
|
|
626
|
-
executionDeadlineAt;
|
|
627
|
-
executionId;
|
|
628
|
-
images;
|
|
629
|
-
kind = BOT_SESSION_PROMPT_KIND;
|
|
630
|
-
localGrantId;
|
|
631
|
-
prompt;
|
|
632
|
-
replyRoute;
|
|
633
|
-
resources;
|
|
634
|
-
sessionConfigurations;
|
|
635
|
-
sessionId;
|
|
636
|
-
targetCommandId;
|
|
637
|
-
turnId;
|
|
638
|
-
constructor(sessionId, commandId, agentId, bindingId, directoryId, additionalDirectoryIds, images, resources, prompt, executionId, executionCapabilityId, executionCapabilitySecret, executionDeadlineAt, botId, conversationId, turnId, behaviorRevisionId, bindingRevision, localGrantId, behaviorInstructions, behaviorDigest, allowedDeliveryTargets, replyRoute, sessionConfigurations = [], disposition = SessionPromptDisposition.Reject, targetCommandId = "") {
|
|
639
|
-
this.sessionId = sessionId;
|
|
640
|
-
this.commandId = commandId;
|
|
641
|
-
this.agentId = agentId;
|
|
642
|
-
this.bindingId = bindingId;
|
|
643
|
-
this.directoryId = directoryId;
|
|
644
|
-
this.disposition = disposition;
|
|
645
|
-
this.additionalDirectoryIds = Object.freeze([...additionalDirectoryIds]);
|
|
646
|
-
this.images = Object.freeze([...images]);
|
|
647
|
-
this.resources = Object.freeze([...resources]);
|
|
648
|
-
this.prompt = prompt;
|
|
649
|
-
this.executionId = executionId;
|
|
650
|
-
this.executionCapabilityId = executionCapabilityId;
|
|
651
|
-
this.executionCapabilitySecret = executionCapabilitySecret;
|
|
652
|
-
this.executionDeadlineAt = executionDeadlineAt;
|
|
653
|
-
this.botId = botId;
|
|
654
|
-
this.conversationId = conversationId;
|
|
655
|
-
this.turnId = turnId;
|
|
656
|
-
this.behaviorRevisionId = behaviorRevisionId;
|
|
657
|
-
this.bindingRevision = bindingRevision;
|
|
658
|
-
this.localGrantId = localGrantId;
|
|
659
|
-
this.behaviorInstructions = behaviorInstructions;
|
|
660
|
-
this.behaviorDigest = behaviorDigest;
|
|
661
|
-
this.allowedDeliveryTargets = Object.freeze(allowedDeliveryTargets.map((target) => new BotDeliveryTargetReference(target.alias, target.deliveryTargetId)));
|
|
662
|
-
this.replyRoute = replyRoute;
|
|
663
|
-
this.sessionConfigurations = Object.freeze([...sessionConfigurations]);
|
|
664
|
-
this.targetCommandId = targetCommandId;
|
|
665
|
-
}
|
|
666
|
-
toJSON() {
|
|
667
|
-
const { disposition, sessionConfigurations, targetCommandId, ...command } = this;
|
|
668
|
-
return {
|
|
669
|
-
...command,
|
|
670
|
-
...(sessionConfigurations.length === 0 ? {} : { sessionConfigurations }),
|
|
671
|
-
...(disposition === SessionPromptDisposition.Reject ? {} : { disposition, targetCommandId }),
|
|
672
|
-
};
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
function isRecord(value) {
|
|
676
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
677
|
-
}
|
|
678
|
-
function parseJson(encoded) {
|
|
679
|
-
let value;
|
|
680
|
-
try {
|
|
681
|
-
value = JSON.parse(encoded);
|
|
682
|
-
}
|
|
683
|
-
catch (cause) {
|
|
684
|
-
throw new ProtocolMessageError("Message is not valid JSON", { cause });
|
|
685
|
-
}
|
|
686
|
-
if (!isRecord(value)) {
|
|
687
|
-
throw new ProtocolMessageError("Message must be a JSON object");
|
|
688
|
-
}
|
|
689
|
-
return value;
|
|
690
|
-
}
|
|
691
|
-
function assertExactKeys(value, expected) {
|
|
692
|
-
const keys = Object.keys(value);
|
|
693
|
-
if (keys.length !== expected.length || keys.some((key) => !expected.includes(key))) {
|
|
694
|
-
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
function assertKeysWithOptional(value, expected, optional) {
|
|
698
|
-
const keys = Object.keys(value);
|
|
699
|
-
if (keys.length < expected.length ||
|
|
700
|
-
keys.length > expected.length + optional.length ||
|
|
701
|
-
expected.some((key) => !Object.hasOwn(value, key)) ||
|
|
702
|
-
keys.some((key) => !expected.includes(key) && !optional.includes(key))) {
|
|
703
|
-
throw new ProtocolMessageError("Message fields do not match the Bot protocol");
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
function readText(value, key, maximumLength, allowEmpty) {
|
|
707
|
-
const field = value[key];
|
|
708
|
-
if (typeof field !== "string" || field.length > maximumLength || (!allowEmpty && field.length === 0)) {
|
|
709
|
-
throw new ProtocolMessageError(`Invalid Bot protocol field: ${key}`);
|
|
710
|
-
}
|
|
711
|
-
return field;
|
|
712
|
-
}
|
|
713
|
-
function readIdentifier(value, key) {
|
|
714
|
-
const field = readText(value, key, 128, false);
|
|
715
|
-
if (!IDENTIFIER_PATTERN.test(field)) {
|
|
716
|
-
throw new ProtocolMessageError(`Invalid Bot identifier field: ${key}`);
|
|
717
|
-
}
|
|
718
|
-
return field;
|
|
719
|
-
}
|
|
720
|
-
function readDirectoryIdentifier(value, key) {
|
|
721
|
-
const field = readText(value, key, 2_048, false);
|
|
722
|
-
if (!DIRECTORY_IDENTIFIER_PATTERN.test(field)) {
|
|
723
|
-
throw new ProtocolMessageError(`Invalid Bot directory field: ${key}`);
|
|
724
|
-
}
|
|
725
|
-
return field;
|
|
726
|
-
}
|
|
727
|
-
function readInteger(value, key) {
|
|
728
|
-
const field = value[key];
|
|
729
|
-
if (typeof field !== "number" || !Number.isSafeInteger(field) || field < 1) {
|
|
730
|
-
throw new ProtocolMessageError(`Invalid Bot integer field: ${key}`);
|
|
731
|
-
}
|
|
732
|
-
return field;
|
|
733
|
-
}
|
|
734
|
-
function readTimestamp(value, key) {
|
|
735
|
-
const field = readText(value, key, 64, false);
|
|
736
|
-
if (Number.isNaN(Date.parse(field))) {
|
|
737
|
-
throw new ProtocolMessageError(`Invalid Bot timestamp field: ${key}`);
|
|
738
|
-
}
|
|
739
|
-
return field;
|
|
740
|
-
}
|
|
741
|
-
function readDigest(value, key) {
|
|
742
|
-
const field = readText(value, key, 64, false);
|
|
743
|
-
if (!SHA256_PATTERN.test(field)) {
|
|
744
|
-
throw new ProtocolMessageError(`Invalid Bot digest field: ${key}`);
|
|
745
|
-
}
|
|
746
|
-
return field;
|
|
747
|
-
}
|
|
748
|
-
function readToken(value, key) {
|
|
749
|
-
const field = readText(value, key, 256, false);
|
|
750
|
-
if (!TOKEN_PATTERN.test(field)) {
|
|
751
|
-
throw new ProtocolMessageError(`Invalid Bot token field: ${key}`);
|
|
752
|
-
}
|
|
753
|
-
return field;
|
|
754
|
-
}
|
|
755
|
-
function readIdentifiers(value, key, maximumCount) {
|
|
756
|
-
const field = value[key];
|
|
757
|
-
if (!Array.isArray(field) || field.length > maximumCount) {
|
|
758
|
-
throw new ProtocolMessageError(`Invalid Bot identifier list: ${key}`);
|
|
759
|
-
}
|
|
760
|
-
const identifiers = [];
|
|
761
|
-
const unique = new Set();
|
|
762
|
-
for (const candidate of field) {
|
|
763
|
-
if (typeof candidate !== "string" || !IDENTIFIER_PATTERN.test(candidate) || unique.has(candidate)) {
|
|
764
|
-
throw new ProtocolMessageError(`Invalid Bot identifier list: ${key}`);
|
|
765
|
-
}
|
|
766
|
-
unique.add(candidate);
|
|
767
|
-
identifiers.push(candidate);
|
|
768
|
-
}
|
|
769
|
-
return Object.freeze(identifiers);
|
|
770
|
-
}
|
|
771
|
-
function readTargets(value, key) {
|
|
772
|
-
const field = value[key];
|
|
773
|
-
if (!Array.isArray(field) || field.length > 64) {
|
|
774
|
-
throw new ProtocolMessageError(`Invalid Bot delivery targets: ${key}`);
|
|
775
|
-
}
|
|
776
|
-
const targets = [];
|
|
777
|
-
const identifiers = new Set();
|
|
778
|
-
const aliases = new Set();
|
|
779
|
-
for (const candidate of field) {
|
|
780
|
-
if (!isRecord(candidate)) {
|
|
781
|
-
throw new ProtocolMessageError(`Invalid Bot delivery targets: ${key}`);
|
|
782
|
-
}
|
|
783
|
-
assertExactKeys(candidate, ["alias", "deliveryTargetId"]);
|
|
784
|
-
const alias = readIdentifier(candidate, "alias");
|
|
785
|
-
const deliveryTargetId = readIdentifier(candidate, "deliveryTargetId");
|
|
786
|
-
if (aliases.has(alias) || identifiers.has(deliveryTargetId)) {
|
|
787
|
-
throw new ProtocolMessageError(`Duplicate Bot delivery target: ${key}`);
|
|
788
|
-
}
|
|
789
|
-
aliases.add(alias);
|
|
790
|
-
identifiers.add(deliveryTargetId);
|
|
791
|
-
targets.push(new BotDeliveryTargetReference(alias, deliveryTargetId));
|
|
792
|
-
}
|
|
793
|
-
return Object.freeze(targets);
|
|
794
|
-
}
|
|
795
|
-
function readSessionConfigurations(value) {
|
|
796
|
-
if (!Object.hasOwn(value, "sessionConfigurations")) {
|
|
797
|
-
return [];
|
|
798
|
-
}
|
|
799
|
-
return decodeSessionConfigurationSelections(value["sessionConfigurations"]);
|
|
800
|
-
}
|
|
801
|
-
function readCompletionPolicy(value) {
|
|
802
|
-
if (!isRecord(value)) {
|
|
803
|
-
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
804
|
-
}
|
|
805
|
-
const kind = readText(value, "kind", 32, false);
|
|
806
|
-
if (kind === "none") {
|
|
807
|
-
assertExactKeys(value, ["kind"]);
|
|
808
|
-
return new NoBotCompletionDeliveryPolicy();
|
|
809
|
-
}
|
|
810
|
-
if (kind === "required") {
|
|
811
|
-
assertExactKeys(value, ["deliveryTargetId", "kind", "messageTemplate"]);
|
|
812
|
-
return new RequiredBotCompletionDeliveryPolicy(readIdentifier(value, "deliveryTargetId"), readText(value, "messageTemplate", 10_000, false));
|
|
813
|
-
}
|
|
814
|
-
throw new ProtocolMessageError("Invalid Bot completion policy");
|
|
815
|
-
}
|
|
816
|
-
function readReplyRoute(value) {
|
|
817
|
-
if (!isRecord(value)) {
|
|
818
|
-
throw new ProtocolMessageError("Invalid Bot reply route");
|
|
819
|
-
}
|
|
820
|
-
const kind = readText(value, "kind", 32, false);
|
|
821
|
-
if (kind === "owner") {
|
|
822
|
-
assertExactKeys(value, ["kind"]);
|
|
823
|
-
return new OwnerBotReplyRoute();
|
|
824
|
-
}
|
|
825
|
-
if (kind === "connection") {
|
|
826
|
-
assertExactKeys(value, ["connectionId", "deliveryTargetId", "kind"]);
|
|
827
|
-
return new BotConnectionReplyRoute(readIdentifier(value, "connectionId"), readIdentifier(value, "deliveryTargetId"));
|
|
828
|
-
}
|
|
829
|
-
throw new ProtocolMessageError("Invalid Bot reply route");
|
|
830
|
-
}
|
|
831
|
-
export function decodeBotExecutionBindingApprovalRequest(encoded) {
|
|
832
|
-
const value = parseJson(encoded);
|
|
833
|
-
assertKeysWithOptional(value, [
|
|
834
|
-
"agentConfigRevision",
|
|
835
|
-
"agentRef",
|
|
836
|
-
"allowedDeliveryTargets",
|
|
837
|
-
"behaviorDigest",
|
|
838
|
-
"behaviorInstructions",
|
|
839
|
-
"behaviorRevisionId",
|
|
840
|
-
"bindingId",
|
|
841
|
-
"bindingRevision",
|
|
842
|
-
"botId",
|
|
843
|
-
"completionPolicy",
|
|
844
|
-
"kind",
|
|
845
|
-
"requestId",
|
|
846
|
-
"requiredCapabilities",
|
|
847
|
-
"runtimeId",
|
|
848
|
-
"workspaceRef",
|
|
849
|
-
], ["sessionConfigurations"]);
|
|
850
|
-
if (value["kind"] !== BOT_BINDING_APPROVAL_REQUEST_KIND) {
|
|
851
|
-
throw new ProtocolMessageError("Invalid Bot binding approval request kind");
|
|
852
|
-
}
|
|
853
|
-
return new BotExecutionBindingApprovalRequest(readIdentifier(value, "requestId"), readIdentifier(value, "botId"), readIdentifier(value, "behaviorRevisionId"), readIdentifier(value, "bindingId"), readInteger(value, "bindingRevision"), readIdentifier(value, "runtimeId"), readIdentifier(value, "agentRef"), readDirectoryIdentifier(value, "workspaceRef"), readInteger(value, "agentConfigRevision"), readText(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true), readDigest(value, "behaviorDigest"), readIdentifiers(value, "requiredCapabilities", 32), readTargets(value, "allowedDeliveryTargets"), readCompletionPolicy(value["completionPolicy"]), readSessionConfigurations(value));
|
|
854
|
-
}
|
|
855
|
-
export function encodeBotExecutionBindingApprovalRequest(request) {
|
|
856
|
-
return JSON.stringify(decodeBotExecutionBindingApprovalRequest(JSON.stringify(request)));
|
|
857
|
-
}
|
|
858
|
-
export function decodeBotExecutionBindingApprovedEvent(encoded) {
|
|
859
|
-
const value = parseJson(encoded);
|
|
860
|
-
assertExactKeys(value, [
|
|
861
|
-
"agentIdentityDigest",
|
|
862
|
-
"behaviorRevisionId",
|
|
863
|
-
"bindingId",
|
|
864
|
-
"bindingRevision",
|
|
865
|
-
"botId",
|
|
866
|
-
"kind",
|
|
867
|
-
"localGrantId",
|
|
868
|
-
"requestId",
|
|
869
|
-
"workspaceIdentityDigest",
|
|
870
|
-
]);
|
|
871
|
-
if (value["kind"] !== BOT_BINDING_APPROVED_KIND) {
|
|
872
|
-
throw new ProtocolMessageError("Invalid Bot binding approval event kind");
|
|
873
|
-
}
|
|
874
|
-
return new BotExecutionBindingApprovedEvent(readIdentifier(value, "requestId"), readIdentifier(value, "botId"), readIdentifier(value, "behaviorRevisionId"), readIdentifier(value, "bindingId"), readInteger(value, "bindingRevision"), readIdentifier(value, "localGrantId"), readDigest(value, "agentIdentityDigest"), readDigest(value, "workspaceIdentityDigest"));
|
|
875
|
-
}
|
|
876
|
-
export function encodeBotExecutionBindingApprovedEvent(event) {
|
|
877
|
-
return JSON.stringify(decodeBotExecutionBindingApprovedEvent(JSON.stringify(event)));
|
|
878
|
-
}
|
|
879
|
-
export function decodeBotExecutionBindingUnavailableEvent(encoded) {
|
|
880
|
-
const value = parseJson(encoded);
|
|
881
|
-
assertExactKeys(value, [
|
|
882
|
-
"behaviorRevisionId",
|
|
883
|
-
"bindingId",
|
|
884
|
-
"bindingRevision",
|
|
885
|
-
"botId",
|
|
886
|
-
"code",
|
|
887
|
-
"kind",
|
|
888
|
-
"message",
|
|
889
|
-
"requestId",
|
|
890
|
-
]);
|
|
891
|
-
if (value["kind"] !== BOT_BINDING_UNAVAILABLE_KIND) {
|
|
892
|
-
throw new ProtocolMessageError("Invalid Bot binding unavailable event kind");
|
|
893
|
-
}
|
|
894
|
-
return new BotExecutionBindingUnavailableEvent(readIdentifier(value, "requestId"), readIdentifier(value, "botId"), readIdentifier(value, "behaviorRevisionId"), readIdentifier(value, "bindingId"), readInteger(value, "bindingRevision"), readIdentifier(value, "code"), readText(value, "message", 500, false));
|
|
895
|
-
}
|
|
896
|
-
export function encodeBotExecutionBindingUnavailableEvent(event) {
|
|
897
|
-
return JSON.stringify(decodeBotExecutionBindingUnavailableEvent(JSON.stringify(event)));
|
|
898
|
-
}
|
|
899
|
-
export function decodeBotSessionPromptCommand(encoded) {
|
|
900
|
-
const value = parseJson(encoded);
|
|
901
|
-
assertKeysWithOptional(value, [
|
|
902
|
-
"additionalDirectoryIds",
|
|
903
|
-
"agentId",
|
|
904
|
-
"allowedDeliveryTargets",
|
|
905
|
-
"behaviorDigest",
|
|
906
|
-
"behaviorInstructions",
|
|
907
|
-
"behaviorRevisionId",
|
|
908
|
-
"bindingId",
|
|
909
|
-
"bindingRevision",
|
|
910
|
-
"botId",
|
|
911
|
-
"commandId",
|
|
912
|
-
"conversationId",
|
|
913
|
-
"directoryId",
|
|
914
|
-
"executionCapabilityId",
|
|
915
|
-
"executionCapabilitySecret",
|
|
916
|
-
"executionDeadlineAt",
|
|
917
|
-
"executionId",
|
|
918
|
-
"images",
|
|
919
|
-
"kind",
|
|
920
|
-
"localGrantId",
|
|
921
|
-
"prompt",
|
|
922
|
-
"replyRoute",
|
|
923
|
-
"resources",
|
|
924
|
-
"sessionId",
|
|
925
|
-
"turnId",
|
|
926
|
-
], ["disposition", "sessionConfigurations", "targetCommandId"]);
|
|
927
|
-
if (value["kind"] !== BOT_SESSION_PROMPT_KIND) {
|
|
928
|
-
throw new ProtocolMessageError("Invalid Bot Session prompt kind");
|
|
929
|
-
}
|
|
930
|
-
const rawDisposition = value["disposition"];
|
|
931
|
-
let disposition;
|
|
932
|
-
if (rawDisposition === undefined || rawDisposition === SessionPromptDisposition.Reject) {
|
|
933
|
-
disposition = SessionPromptDisposition.Reject;
|
|
934
|
-
}
|
|
935
|
-
else if (rawDisposition === SessionPromptDisposition.Queue) {
|
|
936
|
-
disposition = SessionPromptDisposition.Queue;
|
|
937
|
-
}
|
|
938
|
-
else if (rawDisposition === SessionPromptDisposition.Steer) {
|
|
939
|
-
disposition = SessionPromptDisposition.Steer;
|
|
940
|
-
}
|
|
941
|
-
else {
|
|
942
|
-
throw new ProtocolMessageError("Invalid Bot Session prompt disposition");
|
|
943
|
-
}
|
|
944
|
-
const targetCommandId = value["targetCommandId"] === undefined ? "" : readText(value, "targetCommandId", 128, false);
|
|
945
|
-
if ((disposition === SessionPromptDisposition.Reject && targetCommandId.length > 0) ||
|
|
946
|
-
(disposition !== SessionPromptDisposition.Reject && !IDENTIFIER_PATTERN.test(targetCommandId))) {
|
|
947
|
-
throw new ProtocolMessageError("Bot Session prompt disposition has an invalid target command");
|
|
948
|
-
}
|
|
949
|
-
return new BotSessionPromptCommand(readIdentifier(value, "sessionId"), readIdentifier(value, "commandId"), readIdentifier(value, "agentId"), readIdentifier(value, "bindingId"), readDirectoryIdentifier(value, "directoryId"), readIdentifiers(value, "additionalDirectoryIds", 16), decodePromptImagesValue(value["images"]), decodePromptResourcesValue(value["resources"]), readText(value, "prompt", 10_000, false), readIdentifier(value, "executionId"), readIdentifier(value, "executionCapabilityId"), readToken(value, "executionCapabilitySecret"), readTimestamp(value, "executionDeadlineAt"), readIdentifier(value, "botId"), readIdentifier(value, "conversationId"), readIdentifier(value, "turnId"), readIdentifier(value, "behaviorRevisionId"), readInteger(value, "bindingRevision"), readIdentifier(value, "localGrantId"), readText(value, "behaviorInstructions", MAX_INSTRUCTIONS_LENGTH, true), readDigest(value, "behaviorDigest"), readTargets(value, "allowedDeliveryTargets"), readReplyRoute(value["replyRoute"]), readSessionConfigurations(value), disposition, targetCommandId);
|
|
950
|
-
}
|
|
951
|
-
export function encodeBotSessionPromptCommand(command) {
|
|
952
|
-
return JSON.stringify(decodeBotSessionPromptCommand(JSON.stringify(command)));
|
|
953
|
-
}
|
|
954
|
-
//# sourceMappingURL=bot.js.map
|