@yeaft/webchat-agent 0.1.728 → 0.1.731

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.728",
3
+ "version": "0.1.731",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,9 +27,13 @@
27
27
  * stay small).
28
28
  * - `promptSuffix`: text to append to the user's prompt so the model
29
29
  * sees the file list in the same form Chat mode uses.
30
- * - `promptParts`: an array of `{ type:'image', source:{ data, mediaType } }`
30
+ * - `promptParts`: an array of `{ type:'image', source:{ data, media_type } }`
31
31
  * blocks for images, ready to be combined with a text block for
32
32
  * `engine.query({ promptParts })`. Empty when no images are present.
33
+ * Field name is `media_type` (snake_case) to match the Anthropic
34
+ * Messages API spec — Anthropic adapter forwards user-content blocks
35
+ * verbatim, so the on-the-wire form must already be correct here.
36
+ * `crew/routing.js` / `workbench/transfer.js` emit the same shape.
33
37
  * - `failed`: list of `{ name, error }` for entries that could not
34
38
  * be persisted (disk full, bad base64, ...). The caller surfaces
35
39
  * this so the UI can tell the user *which* file blew up rather
@@ -92,7 +96,7 @@ function sanitizeBaseName(base) {
92
96
  * @returns {{
93
97
  * promptAttachments: Array<{name:string, path:string, mimeType:string, isImage:boolean}>,
94
98
  * promptSuffix: string,
95
- * promptParts: Array<{type:'image', source:{type:'base64', mediaType:string, data:string}}>,
99
+ * promptParts: Array<{type:'image', source:{type:'base64', media_type:string, data:string}}>,
96
100
  * failed: Array<{name:string, error:string}>
97
101
  * }}
98
102
  */
@@ -176,11 +180,13 @@ export function persistUnifyAttachments(files, opts = {}) {
176
180
  type: 'image',
177
181
  source: {
178
182
  type: 'base64',
179
- // Both adapters accept either `mediaType` or `media_type`
180
- // (see openai-responses.js:#translateUserContent and the
181
- // Anthropic upstream contract). Use the camelCase form to
182
- // match `openai-responses.js` exactly.
183
- mediaType: file.mimeType || 'image/png',
183
+ // Field name MUST be `media_type` (snake_case) — the Anthropic
184
+ // Messages API rejects camelCase here with `400 Failed to
185
+ // read request body`, and the Anthropic adapter forwards
186
+ // user-content blocks verbatim (no field rename). The OpenAI
187
+ // Responses adapter accepts both forms (see
188
+ // `openai-responses.js#translateUserContent`).
189
+ media_type: file.mimeType || 'image/png',
184
190
  data: file.data,
185
191
  },
186
192
  });
package/unify/engine.js CHANGED
@@ -1042,7 +1042,7 @@ export class Engine {
1042
1042
  * @param {Array<{type:string, source?:object, text?:string}>} [params.promptParts] -
1043
1043
  * PR #721: optional content-array form of the user message used
1044
1044
  * when attachments are present. Each entry is either an
1045
- * `{type:'image', source:{type:'base64', mediaType, data}}` block
1045
+ * `{type:'image', source:{type:'base64', media_type, data}}` block
1046
1046
  * (one per uploaded image) or a `{type:'text', text}` block (the
1047
1047
  * text prompt body, including any [Uploaded files] suffix). When
1048
1048
  * supplied and non-empty, the LLM call uses this array as the
@@ -112,13 +112,16 @@ export class OpenAIResponsesAdapter extends LLMAdapter {
112
112
  return { type: 'input_text', text: part.text || '' };
113
113
  }
114
114
  if (part.type === 'image') {
115
- // part.source may be { url } or { data, mediaType } (base64)
115
+ // part.source may be { url } or { data, media_type } (base64).
116
+ // We accept the legacy `mediaType` (camelCase) for backward
117
+ // compatibility with any caller still on the pre-fix shape;
118
+ // the canonical wire form is now `media_type` per Anthropic.
116
119
  const src = part.source || {};
117
120
  let imageUrl;
118
121
  if (src.url) {
119
122
  imageUrl = src.url;
120
123
  } else if (src.data) {
121
- const mt = src.mediaType || 'image/png';
124
+ const mt = src.media_type || src.mediaType || 'image/png';
122
125
  imageUrl = `data:${mt};base64,${src.data}`;
123
126
  } else {
124
127
  imageUrl = '';