@yeaft/webchat-agent 1.0.605 → 1.0.607

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.
@@ -7,9 +7,10 @@ const FIELDS = Object.freeze({
7
7
  status: [], open: [], snapshot: [], receipt: ['clientMessageId', 'requestHash'],
8
8
  send: ['text', 'clientMessageId', 'attachments'], think: ['text', 'clientMessageId', 'attachments'],
9
9
  dream: ['clientMessageId'], cancel: ['episodeId'],
10
+ tasks: [], task_log: ['taskId', 'offset', 'maxBytes'], task_cancel: ['taskId'], agent_close: ['agentId'],
10
11
  messages: ['cursor', 'limit'], traces: ['cursor', 'limit'],
11
12
  inspect: ['section', 'cursor', 'limit'], search: ['query', 'cursor', 'limit'],
12
- settings: ['name', 'autonomyEnabled', 'modelCandidates'],
13
+ settings: ['name', 'autonomyEnabled', 'modelCandidates', 'defaultModel'],
13
14
  });
14
15
 
15
16
  /** Request-only relay: identity is supplied by the authenticated Server, never the browser.
@@ -62,6 +63,18 @@ export function createPersonRelay({
62
63
  await reply(client, envelope, { ok: false, error: 'Invalid digital person payload' });
63
64
  return true;
64
65
  }
66
+ if (['tasks', 'task_log', 'task_cancel', 'agent_close'].includes(op)) {
67
+ const value = source ?? {};
68
+ const idKey = op === 'agent_close' ? 'agentId' : 'taskId';
69
+ const invalid = Object.keys(value).some(key => !FIELDS[op].includes(key))
70
+ || (op !== 'tasks' && (typeof value[idKey] !== 'string' || !/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/.test(value[idKey])))
71
+ || (Object.hasOwn(value, 'offset') && (!Number.isSafeInteger(value.offset) || value.offset < 0))
72
+ || (Object.hasOwn(value, 'maxBytes') && (!Number.isInteger(value.maxBytes) || value.maxBytes < 1 || value.maxBytes > 65536));
73
+ if (invalid) {
74
+ await reply(client, envelope, { ok: false, errorCode: 'invalid_request', error: 'Invalid digital person task payload' });
75
+ return true;
76
+ }
77
+ }
65
78
  const payload = Object.fromEntries(FIELDS[op].filter(key => Object.hasOwn(source || {}, key)).map(key => [key, source[key]]));
66
79
  if (JSON.stringify(payload).length > 40_000) {
67
80
  await reply(client, envelope, { ok: false, error: 'Digital person input is too large' });
@@ -127,7 +140,7 @@ export function createPersonRelay({
127
140
  await reply(row.client, row.envelope, msg.ok === true
128
141
  ? { ok: true, data: msg.data }
129
142
  : { ok: false,
130
- errorCode: ['outcome_unknown', 'invalid_request', 'busy', 'unsupported', 'not_configured', 'not_open', 'stale', 'idempotency_conflict', 'attachment_expired', 'invalid_attachment', 'unsupported_attachment', 'attachment_limit', 'image_model', 'model_selection'].includes(msg.errorCode) ? msg.errorCode : 'requestFailed',
143
+ errorCode: ['outcome_unknown', 'invalid_request', 'busy', 'unsupported', 'not_configured', 'not_open', 'stale', 'idempotency_conflict', 'attachment_expired', 'invalid_attachment', 'unsupported_attachment', 'attachment_limit', 'image_model', 'model_selection', 'not_found', 'task_scope_denied', 'task_control_unavailable'].includes(msg.errorCode) ? msg.errorCode : 'requestFailed',
131
144
  error: typeof msg.error === 'string' ? msg.error.slice(0, 500) : 'Digital person request failed' });
132
145
  return true;
133
146
  },
@@ -1 +1 @@
1
- {"version":"1.0.605"}
1
+ {"version":"1.0.607"}