@yeaft/webchat-agent 1.0.249 → 1.0.251

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.
@@ -12,6 +12,11 @@ import {
12
12
 
13
13
  const REQUEST_TIMEOUT_MS = 60_000;
14
14
  const pendingRequests = new Map();
15
+ const WORK_ITEM_ATTACHMENT_OPS = new Set(['create', 'work_item_message', 'action_input', 'guide']);
16
+
17
+ export function workCenterOpAcceptsAttachments(op) {
18
+ return WORK_ITEM_ATTACHMENT_OPS.has(op);
19
+ }
15
20
 
16
21
  function decodePreviewBase64(value) {
17
22
  const data = typeof value === 'string' ? value : '';
@@ -140,7 +145,7 @@ export async function handleClientWorkCenter(client, msg, checkAgentAccess) {
140
145
 
141
146
  const op = typeof msg.op === 'string' ? msg.op : '';
142
147
  const sourcePayload = msg.payload && typeof msg.payload === 'object' ? msg.payload : {};
143
- if (['create', 'action_input', 'guide'].includes(op) && Object.hasOwn(sourcePayload, 'files')) {
148
+ if (workCenterOpAcceptsAttachments(op) && Object.hasOwn(sourcePayload, 'files')) {
144
149
  await sendToWebClient(client, {
145
150
  type: 'work_center_response',
146
151
  requestId: typeof msg.requestId === 'string' ? msg.requestId : null,
@@ -170,13 +175,15 @@ export async function handleClientWorkCenter(client, msg, checkAgentAccess) {
170
175
  let resolved = { payload: sourcePayload, consumedIds: [] };
171
176
  try {
172
177
  const attachments = Array.isArray(sourcePayload.attachments) ? sourcePayload.attachments : [];
173
- if (['create', 'action_input', 'guide'].includes(op) && attachments.length > 0) {
178
+ if (workCenterOpAcceptsAttachments(op) && attachments.length > 0) {
174
179
  const capabilities = agents.get(agentId)?.capabilities;
175
180
  if (!Array.isArray(capabilities) || !capabilities.includes('work_item_attachments')) {
176
181
  throw new Error('The selected Agent does not support WorkItem attachments');
177
182
  }
178
183
  }
179
- if (['create', 'action_input', 'guide'].includes(op)) resolved = resolveWorkItemAttachments(client, sourcePayload);
184
+ if (workCenterOpAcceptsAttachments(op)) {
185
+ resolved = resolveWorkItemAttachments(client, sourcePayload);
186
+ }
180
187
  } catch (error) {
181
188
  await sendToWebClient(client, {
182
189
  type: 'work_center_response',
@@ -1 +1 @@
1
- {"version":"1.0.249"}
1
+ {"version":"1.0.251"}