@bpmsoftwaresolutions/ai-engine-client 1.1.85 → 1.1.87
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/package.json +1 -1
- package/src/client.js +1689 -3768
- package/src/domains/collaboration.js +273 -0
- package/src/domains/message-watch.js +270 -0
- package/src/domains/ping-pong.js +358 -0
- package/src/domains/presence.js +457 -0
- package/src/domains/repo.js +124 -21
- package/src/domains/reports.js +16 -1
- package/src/domains/retrieval-management.js +19 -10
- package/src/domains/retrieval-wrapper.js +39 -3
- package/src/domains/transfer-bundles.js +372 -0
- package/src/domains/transfer-channels.js +664 -0
- package/src/domains/workflows.js +99 -0
- package/src/index.js +1 -1
- package/src/utils/communication.js +92 -0
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { cleanText, isPlainObject } from '../utils/communication.js';
|
|
2
|
+
|
|
3
|
+
export function createPresenceDomain(client) {
|
|
4
|
+
return {
|
|
5
|
+
getPresenceBoard: (request) => getPresenceBoard(client, request),
|
|
6
|
+
getChannelPresence: (request) => getChannelPresence(client, request),
|
|
7
|
+
markParticipantOnline: (request) => markParticipantOnline(client, request),
|
|
8
|
+
markParticipantOffline: (request) => markParticipantOffline(client, request),
|
|
9
|
+
whoIsOnline: (request) => whoIsOnline(client, request),
|
|
10
|
+
findOnlineParticipant: (request) => findOnlineParticipant(client, request),
|
|
11
|
+
sendToParticipant: (request) => sendToParticipant(client, request),
|
|
12
|
+
sendToRole: (request) => sendToRole(client, request),
|
|
13
|
+
postPresenceHeartbeat: (request) => postPresenceHeartbeat(client, request),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function getPresenceBoard(client, {
|
|
18
|
+
workflowRunId,
|
|
19
|
+
workflow_run_id,
|
|
20
|
+
transferChannelId,
|
|
21
|
+
transfer_channel_id,
|
|
22
|
+
participantRole,
|
|
23
|
+
participant_role,
|
|
24
|
+
role,
|
|
25
|
+
capability,
|
|
26
|
+
includeStale,
|
|
27
|
+
include_stale,
|
|
28
|
+
} = {}) {
|
|
29
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId);
|
|
30
|
+
const path = normalizedTransferChannelId
|
|
31
|
+
? `/api/operator/projections/agent-communications/presence/${encodeURIComponent(normalizedTransferChannelId)}`
|
|
32
|
+
: '/api/operator/projections/agent-communications/presence';
|
|
33
|
+
return client._requestLogaProjection(path, {
|
|
34
|
+
query: {
|
|
35
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
36
|
+
transfer_channel_id: normalizedTransferChannelId,
|
|
37
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole) || cleanText(role),
|
|
38
|
+
capability: cleanText(capability),
|
|
39
|
+
include_stale: include_stale ?? includeStale,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function getChannelPresence(client, {
|
|
45
|
+
transferChannelId,
|
|
46
|
+
transfer_channel_id,
|
|
47
|
+
channelId,
|
|
48
|
+
channel_id,
|
|
49
|
+
workflowRunId,
|
|
50
|
+
workflow_run_id,
|
|
51
|
+
participantRole,
|
|
52
|
+
participant_role,
|
|
53
|
+
role,
|
|
54
|
+
capability,
|
|
55
|
+
includeStale,
|
|
56
|
+
include_stale,
|
|
57
|
+
} = {}) {
|
|
58
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
59
|
+
if (!normalizedTransferChannelId) {
|
|
60
|
+
throw new Error('transferChannelId is required.');
|
|
61
|
+
}
|
|
62
|
+
return client._requestLogaProjection(`/api/operator/projections/agent-communications/presence/${encodeURIComponent(normalizedTransferChannelId)}`, {
|
|
63
|
+
query: {
|
|
64
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
65
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole) || cleanText(role),
|
|
66
|
+
capability: cleanText(capability),
|
|
67
|
+
include_stale: include_stale ?? includeStale,
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export async function postPresenceHeartbeat(client, {
|
|
73
|
+
transferChannelId,
|
|
74
|
+
transfer_channel_id,
|
|
75
|
+
channelId,
|
|
76
|
+
channel_id,
|
|
77
|
+
workTransferPacketId,
|
|
78
|
+
work_transfer_packet_id,
|
|
79
|
+
workflowRunId,
|
|
80
|
+
workflow_run_id,
|
|
81
|
+
participantRole,
|
|
82
|
+
participant_role,
|
|
83
|
+
activityState,
|
|
84
|
+
activity_state,
|
|
85
|
+
currentPhase,
|
|
86
|
+
current_phase,
|
|
87
|
+
currentTaskSummary,
|
|
88
|
+
current_task_summary,
|
|
89
|
+
isActive,
|
|
90
|
+
is_active,
|
|
91
|
+
agentSessionId,
|
|
92
|
+
agent_session_id,
|
|
93
|
+
actorSessionId,
|
|
94
|
+
actor_session_id,
|
|
95
|
+
observedAt,
|
|
96
|
+
observed_at,
|
|
97
|
+
metadata = {},
|
|
98
|
+
} = {}) {
|
|
99
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
100
|
+
if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
|
|
101
|
+
return client._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/heartbeats`, {
|
|
102
|
+
method: 'POST',
|
|
103
|
+
body: {
|
|
104
|
+
work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId),
|
|
105
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
106
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole),
|
|
107
|
+
activity_state: cleanText(activity_state) || cleanText(activityState) || 'active',
|
|
108
|
+
current_phase: cleanText(current_phase) || cleanText(currentPhase),
|
|
109
|
+
current_task_summary: cleanText(current_task_summary) || cleanText(currentTaskSummary),
|
|
110
|
+
is_active: Boolean(is_active ?? isActive ?? true),
|
|
111
|
+
agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId) || client.agentSessionId,
|
|
112
|
+
actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
|
|
113
|
+
observed_at: observed_at || observedAt,
|
|
114
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function resolvePresenceContext(client, request = {}) {
|
|
120
|
+
const {
|
|
121
|
+
transferChannelId,
|
|
122
|
+
transfer_channel_id,
|
|
123
|
+
channelId,
|
|
124
|
+
channel_id,
|
|
125
|
+
workTransferPacketId,
|
|
126
|
+
work_transfer_packet_id,
|
|
127
|
+
packetId,
|
|
128
|
+
packet_id,
|
|
129
|
+
workflowRunId,
|
|
130
|
+
workflow_run_id,
|
|
131
|
+
participantRole,
|
|
132
|
+
participant_role,
|
|
133
|
+
role,
|
|
134
|
+
} = request;
|
|
135
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
136
|
+
const normalizedParticipantRole = cleanText(participant_role) || cleanText(participantRole) || cleanText(role);
|
|
137
|
+
const normalizedWorkflowRunId = cleanText(workflow_run_id) || cleanText(workflowRunId);
|
|
138
|
+
if (normalizedTransferChannelId) {
|
|
139
|
+
let normalizedPacketId = cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId) || cleanText(packet_id) || cleanText(packetId);
|
|
140
|
+
if (!normalizedPacketId) {
|
|
141
|
+
try {
|
|
142
|
+
const status = await client.getCommunicationChannelStatus({ transferChannelId: normalizedTransferChannelId });
|
|
143
|
+
normalizedPacketId = cleanText(status?.packet_id || status?.packetId || status?.work_transfer_packet_id);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
void error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { channel_id: normalizedTransferChannelId, packet_id: normalizedPacketId, workflow_run_id: normalizedWorkflowRunId, stop_reason: null };
|
|
149
|
+
}
|
|
150
|
+
const presence = await client.whoIsOnline({ workflowRunId: normalizedWorkflowRunId, participantRole: normalizedParticipantRole, includeStale: true });
|
|
151
|
+
const directoryRows = Array.isArray(presence?.presence)
|
|
152
|
+
? presence.presence.filter((row) => row && typeof row === 'object')
|
|
153
|
+
: Array.isArray(presence?.online_participants)
|
|
154
|
+
? presence.online_participants.filter((row) => row && typeof row === 'object')
|
|
155
|
+
: Array.isArray(presence?.participants)
|
|
156
|
+
? presence.participants.filter((row) => row && typeof row === 'object')
|
|
157
|
+
: [];
|
|
158
|
+
const filteredRows = normalizedParticipantRole
|
|
159
|
+
? directoryRows.filter((row) => cleanText(row.participant_role) === normalizedParticipantRole)
|
|
160
|
+
: [];
|
|
161
|
+
const onlineRows = filteredRows.filter((row) => Boolean(row.is_online));
|
|
162
|
+
const chooseRows = onlineRows.length > 0 ? onlineRows : filteredRows;
|
|
163
|
+
if (chooseRows.length === 1) {
|
|
164
|
+
return {
|
|
165
|
+
channel_id: cleanText(chooseRows[0].transfer_channel_id),
|
|
166
|
+
packet_id: cleanText(chooseRows[0].work_transfer_packet_id) || cleanText(chooseRows[0].packet_id),
|
|
167
|
+
workflow_run_id: cleanText(chooseRows[0].workflow_run_id) || normalizedWorkflowRunId,
|
|
168
|
+
stop_reason: null,
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
const openChannels = await client.listOpenCommunicationChannels({ workflowRunId: normalizedWorkflowRunId });
|
|
172
|
+
const openChannelRows = Array.isArray(openChannels) ? openChannels.filter((row) => row && typeof row === 'object') : [];
|
|
173
|
+
if (openChannelRows.length === 1) {
|
|
174
|
+
return {
|
|
175
|
+
channel_id: cleanText(openChannelRows[0].channel_id || openChannelRows[0].transfer_channel_id),
|
|
176
|
+
packet_id: cleanText(openChannelRows[0].packet_id || openChannelRows[0].work_transfer_packet_id),
|
|
177
|
+
workflow_run_id: cleanText(openChannelRows[0].workflow_run_id) || normalizedWorkflowRunId,
|
|
178
|
+
stop_reason: null,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
if (openChannelRows.length > 1) {
|
|
182
|
+
return {
|
|
183
|
+
channel_id: null,
|
|
184
|
+
packet_id: null,
|
|
185
|
+
workflow_run_id: normalizedWorkflowRunId,
|
|
186
|
+
stop_reason: {
|
|
187
|
+
code: 'multiple_open_channels_need_disambiguation',
|
|
188
|
+
message: 'Multiple open channels matched the requested coordination context.',
|
|
189
|
+
details: {
|
|
190
|
+
workflow_run_id: normalizedWorkflowRunId,
|
|
191
|
+
participant_role: normalizedParticipantRole,
|
|
192
|
+
candidate_count: openChannelRows.length,
|
|
193
|
+
candidate_channel_ids: openChannelRows.map((row) => cleanText(row.channel_id || row.transfer_channel_id)).filter(Boolean),
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
channel_id: null,
|
|
200
|
+
packet_id: null,
|
|
201
|
+
workflow_run_id: normalizedWorkflowRunId,
|
|
202
|
+
stop_reason: {
|
|
203
|
+
code: 'active_channel_not_found',
|
|
204
|
+
message: 'Active transfer channel not found.',
|
|
205
|
+
details: { workflow_run_id: normalizedWorkflowRunId, participant_role: normalizedParticipantRole },
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export async function markParticipantOnline(client, request = {}) {
|
|
211
|
+
const {
|
|
212
|
+
transferChannelId,
|
|
213
|
+
transfer_channel_id,
|
|
214
|
+
channelId,
|
|
215
|
+
channel_id,
|
|
216
|
+
workTransferPacketId,
|
|
217
|
+
work_transfer_packet_id,
|
|
218
|
+
packetId,
|
|
219
|
+
packet_id,
|
|
220
|
+
workflowRunId,
|
|
221
|
+
workflow_run_id,
|
|
222
|
+
participantRole,
|
|
223
|
+
participant_role,
|
|
224
|
+
currentPhase,
|
|
225
|
+
current_phase,
|
|
226
|
+
currentTaskSummary,
|
|
227
|
+
current_task_summary,
|
|
228
|
+
agentSessionId,
|
|
229
|
+
agent_session_id,
|
|
230
|
+
actorSessionId,
|
|
231
|
+
actor_session_id,
|
|
232
|
+
observedAt,
|
|
233
|
+
observed_at,
|
|
234
|
+
metadata = {},
|
|
235
|
+
} = request;
|
|
236
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
237
|
+
if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
|
|
238
|
+
const resolved = await resolvePresenceContext(client, request);
|
|
239
|
+
return client._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/presence/online`, {
|
|
240
|
+
method: 'POST',
|
|
241
|
+
body: {
|
|
242
|
+
transfer_channel_id: normalizedTransferChannelId,
|
|
243
|
+
work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId) || cleanText(packet_id) || cleanText(packetId) || resolved.packet_id,
|
|
244
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
245
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole),
|
|
246
|
+
current_phase: cleanText(current_phase) || cleanText(currentPhase),
|
|
247
|
+
current_task_summary: cleanText(current_task_summary) || cleanText(currentTaskSummary),
|
|
248
|
+
agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId) || client.agentSessionId,
|
|
249
|
+
actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
|
|
250
|
+
observed_at: cleanText(observed_at) || cleanText(observedAt),
|
|
251
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
252
|
+
is_active: true,
|
|
253
|
+
activity_state: 'active',
|
|
254
|
+
},
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export async function markParticipantOffline(client, request = {}) {
|
|
259
|
+
const {
|
|
260
|
+
transferChannelId,
|
|
261
|
+
transfer_channel_id,
|
|
262
|
+
channelId,
|
|
263
|
+
channel_id,
|
|
264
|
+
workTransferPacketId,
|
|
265
|
+
work_transfer_packet_id,
|
|
266
|
+
packetId,
|
|
267
|
+
packet_id,
|
|
268
|
+
workflowRunId,
|
|
269
|
+
workflow_run_id,
|
|
270
|
+
participantRole,
|
|
271
|
+
participant_role,
|
|
272
|
+
currentPhase,
|
|
273
|
+
current_phase,
|
|
274
|
+
currentTaskSummary,
|
|
275
|
+
current_task_summary,
|
|
276
|
+
agentSessionId,
|
|
277
|
+
agent_session_id,
|
|
278
|
+
actorSessionId,
|
|
279
|
+
actor_session_id,
|
|
280
|
+
observedAt,
|
|
281
|
+
observed_at,
|
|
282
|
+
metadata = {},
|
|
283
|
+
} = request;
|
|
284
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
285
|
+
if (!normalizedTransferChannelId) throw new Error('transferChannelId is required.');
|
|
286
|
+
const resolved = await resolvePresenceContext(client, request);
|
|
287
|
+
return client._request(`/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/presence/offline`, {
|
|
288
|
+
method: 'POST',
|
|
289
|
+
body: {
|
|
290
|
+
transfer_channel_id: normalizedTransferChannelId,
|
|
291
|
+
work_transfer_packet_id: cleanText(work_transfer_packet_id) || cleanText(workTransferPacketId) || cleanText(packet_id) || cleanText(packetId) || resolved.packet_id,
|
|
292
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
293
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole),
|
|
294
|
+
current_phase: cleanText(current_phase) || cleanText(currentPhase),
|
|
295
|
+
current_task_summary: cleanText(current_task_summary) || cleanText(currentTaskSummary),
|
|
296
|
+
agent_session_id: cleanText(agent_session_id) || cleanText(agentSessionId) || client.agentSessionId,
|
|
297
|
+
actor_session_id: cleanText(actor_session_id) || cleanText(actorSessionId),
|
|
298
|
+
observed_at: cleanText(observed_at) || cleanText(observedAt),
|
|
299
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
300
|
+
is_active: false,
|
|
301
|
+
activity_state: 'offline',
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export async function whoIsOnline(client, {
|
|
307
|
+
workflowRunId,
|
|
308
|
+
workflow_run_id,
|
|
309
|
+
transferChannelId,
|
|
310
|
+
transfer_channel_id,
|
|
311
|
+
participantRole,
|
|
312
|
+
participant_role,
|
|
313
|
+
role,
|
|
314
|
+
capability,
|
|
315
|
+
includeStale,
|
|
316
|
+
include_stale,
|
|
317
|
+
} = {}) {
|
|
318
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId);
|
|
319
|
+
const path = normalizedTransferChannelId
|
|
320
|
+
? `/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/presence`
|
|
321
|
+
: '/api/agent-communications/presence';
|
|
322
|
+
return client._request(path, {
|
|
323
|
+
query: {
|
|
324
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
325
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole) || cleanText(role),
|
|
326
|
+
capability: cleanText(capability),
|
|
327
|
+
include_stale: include_stale ?? includeStale,
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export async function findOnlineParticipant(client, request = {}) {
|
|
333
|
+
const {
|
|
334
|
+
workflowRunId,
|
|
335
|
+
workflow_run_id,
|
|
336
|
+
transferChannelId,
|
|
337
|
+
transfer_channel_id,
|
|
338
|
+
participantRole,
|
|
339
|
+
participant_role,
|
|
340
|
+
role,
|
|
341
|
+
capability,
|
|
342
|
+
} = request;
|
|
343
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId);
|
|
344
|
+
const body = {
|
|
345
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
346
|
+
transfer_channel_id: normalizedTransferChannelId,
|
|
347
|
+
participant_role: cleanText(participant_role) || cleanText(participantRole) || cleanText(role),
|
|
348
|
+
capability: cleanText(capability),
|
|
349
|
+
};
|
|
350
|
+
const path = normalizedTransferChannelId
|
|
351
|
+
? `/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/presence/find`
|
|
352
|
+
: '/api/agent-communications/presence/find';
|
|
353
|
+
return client._request(path, {
|
|
354
|
+
method: 'POST',
|
|
355
|
+
body,
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
export async function sendToParticipant(client, {
|
|
360
|
+
transferChannelId,
|
|
361
|
+
transfer_channel_id,
|
|
362
|
+
channelId,
|
|
363
|
+
channel_id,
|
|
364
|
+
recipientParticipantId,
|
|
365
|
+
recipient_participant_id,
|
|
366
|
+
recipientAgentSessionId,
|
|
367
|
+
recipient_agent_session_id,
|
|
368
|
+
recipientActorSessionId,
|
|
369
|
+
recipient_actor_session_id,
|
|
370
|
+
senderAgentSessionId,
|
|
371
|
+
sender_agent_session_id,
|
|
372
|
+
senderRole,
|
|
373
|
+
sender_role,
|
|
374
|
+
recipientRole,
|
|
375
|
+
recipient_role,
|
|
376
|
+
role,
|
|
377
|
+
workflowRunId,
|
|
378
|
+
workflow_run_id,
|
|
379
|
+
messageKind,
|
|
380
|
+
message_kind,
|
|
381
|
+
expectedMessageKind,
|
|
382
|
+
expected_message_kind,
|
|
383
|
+
bodyMarkdown,
|
|
384
|
+
body_markdown,
|
|
385
|
+
payload = {},
|
|
386
|
+
metadata = {},
|
|
387
|
+
} = {}) {
|
|
388
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
389
|
+
const path = normalizedTransferChannelId
|
|
390
|
+
? `/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/messages/send-to-participant`
|
|
391
|
+
: '/api/agent-communications/messages/send-to-participant';
|
|
392
|
+
return client._request(path, {
|
|
393
|
+
method: 'POST',
|
|
394
|
+
body: {
|
|
395
|
+
transfer_channel_id: normalizedTransferChannelId,
|
|
396
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
397
|
+
recipient_participant_id: cleanText(recipient_participant_id) || cleanText(recipientParticipantId),
|
|
398
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
399
|
+
recipient_actor_session_id: cleanText(recipient_actor_session_id) || cleanText(recipientActorSessionId),
|
|
400
|
+
message_kind: cleanText(message_kind) || cleanText(messageKind),
|
|
401
|
+
expected_message_kind: cleanText(expected_message_kind) || cleanText(expectedMessageKind),
|
|
402
|
+
body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
|
|
403
|
+
sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId) || client.agentSessionId,
|
|
404
|
+
sender_role: cleanText(sender_role) || cleanText(senderRole),
|
|
405
|
+
recipient_role: cleanText(recipient_role) || cleanText(recipientRole) || cleanText(role),
|
|
406
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
407
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export async function sendToRole(client, {
|
|
413
|
+
transferChannelId,
|
|
414
|
+
transfer_channel_id,
|
|
415
|
+
channelId,
|
|
416
|
+
channel_id,
|
|
417
|
+
recipientRole,
|
|
418
|
+
recipient_role,
|
|
419
|
+
role,
|
|
420
|
+
senderAgentSessionId,
|
|
421
|
+
sender_agent_session_id,
|
|
422
|
+
senderRole,
|
|
423
|
+
sender_role,
|
|
424
|
+
recipientAgentSessionId,
|
|
425
|
+
recipient_agent_session_id,
|
|
426
|
+
workflowRunId,
|
|
427
|
+
workflow_run_id,
|
|
428
|
+
messageKind,
|
|
429
|
+
message_kind,
|
|
430
|
+
expectedMessageKind,
|
|
431
|
+
expected_message_kind,
|
|
432
|
+
bodyMarkdown,
|
|
433
|
+
body_markdown,
|
|
434
|
+
payload = {},
|
|
435
|
+
metadata = {},
|
|
436
|
+
} = {}) {
|
|
437
|
+
const normalizedTransferChannelId = cleanText(transfer_channel_id) || cleanText(transferChannelId) || cleanText(channel_id) || cleanText(channelId);
|
|
438
|
+
const path = normalizedTransferChannelId
|
|
439
|
+
? `/api/agent-communications/transfer-channels/${encodeURIComponent(normalizedTransferChannelId)}/messages/send-to-role`
|
|
440
|
+
: '/api/agent-communications/messages/send-to-role';
|
|
441
|
+
return client._request(path, {
|
|
442
|
+
method: 'POST',
|
|
443
|
+
body: {
|
|
444
|
+
transfer_channel_id: normalizedTransferChannelId,
|
|
445
|
+
workflow_run_id: cleanText(workflow_run_id) || cleanText(workflowRunId),
|
|
446
|
+
sender_agent_session_id: cleanText(sender_agent_session_id) || cleanText(senderAgentSessionId) || client.agentSessionId,
|
|
447
|
+
sender_role: cleanText(sender_role) || cleanText(senderRole),
|
|
448
|
+
recipient_agent_session_id: cleanText(recipient_agent_session_id) || cleanText(recipientAgentSessionId),
|
|
449
|
+
recipient_role: cleanText(recipient_role) || cleanText(recipientRole) || cleanText(role),
|
|
450
|
+
message_kind: cleanText(message_kind) || cleanText(messageKind),
|
|
451
|
+
expected_message_kind: cleanText(expected_message_kind) || cleanText(expectedMessageKind),
|
|
452
|
+
body_markdown: cleanText(body_markdown) || cleanText(bodyMarkdown),
|
|
453
|
+
payload: isPlainObject(payload) ? payload : {},
|
|
454
|
+
metadata: isPlainObject(metadata) ? metadata : {},
|
|
455
|
+
},
|
|
456
|
+
});
|
|
457
|
+
}
|
package/src/domains/repo.js
CHANGED
|
@@ -1,25 +1,128 @@
|
|
|
1
1
|
export function createRepoDomain(client) {
|
|
2
2
|
return {
|
|
3
|
-
listRepositories
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
listRepositories({ limit } = {}) {
|
|
4
|
+
return client._request('/api/repo/repositories', {
|
|
5
|
+
query: { limit },
|
|
6
|
+
});
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
getRepository(repositoryId) {
|
|
10
|
+
return client._request(`/api/repo/repositories/${repositoryId}`);
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
listProjects({ repositoryId, repoKey, limit } = {}) {
|
|
14
|
+
return client._request('/api/repo/projects', {
|
|
15
|
+
query: { repository_id: repositoryId, repo_key: repoKey, limit },
|
|
16
|
+
});
|
|
17
|
+
},
|
|
18
|
+
|
|
19
|
+
getProject(projectId) {
|
|
20
|
+
return client._request(`/api/repo/projects/${projectId}`);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
listCodeFiles({ repositoryId, projectId, language, pathPrefix, page = 1, pageSize = 50 } = {}) {
|
|
24
|
+
return client._request('/api/repo/files', {
|
|
25
|
+
query: {
|
|
26
|
+
repository_id: repositoryId,
|
|
27
|
+
project_id: projectId,
|
|
28
|
+
language,
|
|
29
|
+
path_prefix: pathPrefix,
|
|
30
|
+
page,
|
|
31
|
+
page_size: pageSize,
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
getCodeFile(fileId) {
|
|
37
|
+
return client._request(`/api/repo/files/${fileId}`);
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
getCodeFileContentWindow(fileId, { startLine = 1, endLine } = {}) {
|
|
41
|
+
return client._request(`/api/repo/files/${fileId}/content-window`, {
|
|
42
|
+
query: { start_line: startLine, end_line: endLine ?? startLine },
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
listCodeSymbolsByFile(fileId, { limit = 500 } = {}) {
|
|
47
|
+
return client._request(`/api/repo/files/${fileId}/symbols`, {
|
|
48
|
+
query: { limit },
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
getCodeSymbol(symbolId, { includeCode = false, maxLines = 120 } = {}) {
|
|
53
|
+
return client._request(`/api/repo/symbols/${symbolId}`, {
|
|
54
|
+
query: { include_code: includeCode, max_lines: maxLines },
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
searchSymbols({ query, projectScope, maxResults = 10 } = {}) {
|
|
59
|
+
return client._request('/api/repo/symbols/search', {
|
|
60
|
+
query: { query, project_scope: projectScope, max_results: maxResults },
|
|
61
|
+
});
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
getSymbolRelationships(symbolId, { relationshipType, depth = 1 } = {}) {
|
|
65
|
+
return client._request(`/api/repo/symbols/${symbolId}/relationships`, {
|
|
66
|
+
query: { relationship_type: relationshipType, depth },
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
listCodeRelationships({ repositoryId, projectId, relationshipType, limit = 100 } = {}) {
|
|
71
|
+
return client._request('/api/repo/relationships', {
|
|
72
|
+
query: { repository_id: repositoryId, project_id: projectId, relationship_type: relationshipType, limit },
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
listActionObservations({ repositoryId, projectPath, filePath, symbolId, actionKind, limit = 100 } = {}) {
|
|
77
|
+
return client._request('/api/repo/action-observations', {
|
|
78
|
+
query: { repository_id: repositoryId, project_path: projectPath, file_path: filePath, symbol_id: symbolId, action_kind: actionKind, limit },
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
listCodebaseShapeFindings({ repositoryId, projectPath, filePath, severity, status, limit = 100 } = {}) {
|
|
83
|
+
return client._request('/api/repo/shape/findings', {
|
|
84
|
+
query: { repository_id: repositoryId, project_path: projectPath, file_path: filePath, severity, status, limit },
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
listObjectFlowObservations({ repositoryId, projectPath, filePath, objectKind, boundaryKind, limit = 100 } = {}) {
|
|
89
|
+
return client._request('/api/repo/object-flow-observations', {
|
|
90
|
+
query: { repository_id: repositoryId, project_path: projectPath, file_path: filePath, object_kind: objectKind, boundary_kind: boundaryKind, limit },
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
getChangeAnalysis({ fileId, symbolId, limit = 25 } = {}) {
|
|
95
|
+
return client._request('/api/repo/change-analysis', {
|
|
96
|
+
query: { file_id: fileId, symbol_id: symbolId, limit },
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
listRefactorCandidates({ repositoryRoot, limit = 10 } = {}) {
|
|
101
|
+
return client._request('/api/repo/refactor-candidates', {
|
|
102
|
+
query: { repository_root: repositoryRoot, limit },
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
analyzeRefactorCandidate({ filePath, requestedBy, packetId, refactorIntent } = {}) {
|
|
107
|
+
return client._request('/api/repo/refactor-candidate-analysis', {
|
|
108
|
+
method: 'POST',
|
|
109
|
+
body: { file_path: filePath, requested_by: requestedBy, packet_id: packetId, refactor_intent: refactorIntent },
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
getRepoRetrievalPacket(retrievalPacketId) {
|
|
114
|
+
return client._request(`/api/repo/retrieval/packets/${retrievalPacketId}`);
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
getRepoRetrievalPacketFragments(retrievalPacketId) {
|
|
118
|
+
return client._request(`/api/repo/retrieval/packets/${retrievalPacketId}/fragments`);
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
evaluateProposalScope({ filePath, projectId, changeType = 'refactor', requestedBy, refactorIntent } = {}) {
|
|
122
|
+
return client._request('/api/repo/proposal-scope-evaluation', {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
body: { file_path: filePath, project_id: projectId, change_type: changeType, requested_by: requestedBy, refactor_intent: refactorIntent },
|
|
125
|
+
});
|
|
126
|
+
},
|
|
24
127
|
};
|
|
25
128
|
}
|
package/src/domains/reports.js
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
import { cleanText, isPlainObject } from '../utils/text.js';
|
|
2
|
+
|
|
1
3
|
export function createReportsDomain(client) {
|
|
2
4
|
return {
|
|
3
|
-
run
|
|
5
|
+
run({ reportKey, definition = {}, requestedBy } = {}) {
|
|
6
|
+
const normalizedReportKey = cleanText(reportKey);
|
|
7
|
+
if (!normalizedReportKey) {
|
|
8
|
+
throw new Error('reportKey is required.');
|
|
9
|
+
}
|
|
10
|
+
return client._request('/api/gateway/reports/run', {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
body: {
|
|
13
|
+
report_key: normalizedReportKey,
|
|
14
|
+
definition: isPlainObject(definition) ? definition : {},
|
|
15
|
+
requested_by: cleanText(requestedBy),
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
},
|
|
4
19
|
};
|
|
5
20
|
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
export function createRetrievalManagementDomain(client) {
|
|
2
2
|
return {
|
|
3
|
-
getRetrievalStatus: () => client.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
getRetrievalStatus: () => client._request('/api/operator/retrieval/status'),
|
|
4
|
+
|
|
5
|
+
getRetrievalProfileMetrics: () => client._request('/api/operator/retrieval/profiles/metrics'),
|
|
6
|
+
|
|
7
|
+
getRetrievalFeedbackMetrics: () => client._request('/api/operator/retrieval/feedback-metrics'),
|
|
8
|
+
|
|
9
|
+
getRetrievalQuery: (retrievalQueryId) => client._request(`/api/operator/retrieval/queries/${retrievalQueryId}`),
|
|
10
|
+
|
|
11
|
+
getRetrievalPacket: (retrievalPacketId) => client._request(`/api/operator/retrieval/packets/${retrievalPacketId}`),
|
|
12
|
+
|
|
13
|
+
generateRetrievalCandidates: (body) => client._request('/api/operator/retrieval/generate-candidates', { method: 'POST', body }),
|
|
14
|
+
|
|
15
|
+
selectRetrievalPacket: (body) => client._request('/api/operator/retrieval/select-packet', { method: 'POST', body }),
|
|
16
|
+
|
|
17
|
+
recordRetrievalFeedback: (body) => client._request('/api/operator/retrieval/feedback', { method: 'POST', body }),
|
|
18
|
+
|
|
19
|
+
deriveRetrievalOptimizationCandidates: (body) => client._request('/api/operator/retrieval/optimization-candidates', { method: 'POST', body }),
|
|
20
|
+
|
|
21
|
+
validatePromptAssembly: (body) => client._request('/api/operator/retrieval/validate-prompt-assembly', { method: 'POST', body }),
|
|
13
22
|
};
|
|
14
23
|
}
|