@kolbo/mcp 1.76.0 → 1.76.1
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/tools/_shared.js +7 -0
- package/src/tools/generate.js +32 -2
package/package.json
CHANGED
package/src/tools/_shared.js
CHANGED
|
@@ -655,6 +655,13 @@ async function uiCompleted(p, textPayload, extraContent) {
|
|
|
655
655
|
// above which assume everything finished together. Only set when the
|
|
656
656
|
// caller actually has this shape; every existing caller is unaffected.
|
|
657
657
|
...(Array.isArray(p.items) ? { items: p.items } : {}),
|
|
658
|
+
// The RAW generation state, when the caller has one. `phase` above is
|
|
659
|
+
// hardcoded 'completed' — it means "this tool call finished", not "the
|
|
660
|
+
// generation finished" — so a status check on a still-running job looked
|
|
661
|
+
// done to every reader. A live generation card polls get_generation_status
|
|
662
|
+
// from its own iframe and reads `state` FIRST; without it, a processing job
|
|
663
|
+
// resolved as completed-with-no-media and painted a red failure card.
|
|
664
|
+
...(p.state ? { state: p.state } : {}),
|
|
658
665
|
credits_used: p.credits_used,
|
|
659
666
|
open_url: buildOpenUrl(p.tool, p.gen),
|
|
660
667
|
};
|
package/src/tools/generate.js
CHANGED
|
@@ -108,6 +108,17 @@ async function pollBatch(client, batch, { interval, timeout }, toolName) {
|
|
|
108
108
|
}, text);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
+
// Same extension sniff the generation widget already does (kindFromTool in
|
|
112
|
+
// apps/widgets/generation.js) — a status check knows a url came back, not what
|
|
113
|
+
// kind of media it is, and the card needs the media kind to pick a renderer.
|
|
114
|
+
function mediaKind(url) {
|
|
115
|
+
const u = String(url || '').split('?')[0].toLowerCase();
|
|
116
|
+
if (/\.(mp4|mov|webm|mkv)$/.test(u)) return 'video';
|
|
117
|
+
if (/\.(mp3|wav|m4a|aac|ogg|flac)$/.test(u)) return 'audio';
|
|
118
|
+
if (/\.(glb|gltf|fbx|obj|usdz)$/.test(u)) return '3d';
|
|
119
|
+
return 'image';
|
|
120
|
+
}
|
|
121
|
+
|
|
111
122
|
// ─── Widget settings block ──────────────────────────────────────────────────
|
|
112
123
|
// What the CALLER actually asked for, for the generation card AND for the model
|
|
113
124
|
// reading the tool result. Undefined/false keys are dropped by JSON.stringify, so
|
|
@@ -1016,10 +1027,29 @@ function registerGenerateTools(server, client, options = {}) {
|
|
|
1016
1027
|
: pendingHint;
|
|
1017
1028
|
const singleText = JSON.stringify(single, null, 2);
|
|
1018
1029
|
const res = single.result || {};
|
|
1030
|
+
// A live generation card polls THIS branch from inside its own iframe,
|
|
1031
|
+
// and it reads structuredContent — never the text (apps/html.js
|
|
1032
|
+
// structured() returns structuredContent first and only falls back to
|
|
1033
|
+
// parsing content[].text). So preserving the flat TEXT shape, as the
|
|
1034
|
+
// comment above intended, protected nothing: the card does
|
|
1035
|
+
// `r = st.result || st` then `r.urls`, found only `items`, and painted
|
|
1036
|
+
// "No output received / Failed" over a generation that had completed
|
|
1037
|
+
// and billed. Every card rendered before v1.74 keeps that old iframe JS
|
|
1038
|
+
// forever, so the flat fields have to live in structuredContent too.
|
|
1039
|
+
const urls = Array.isArray(res.urls) ? res.urls : [];
|
|
1040
|
+
const done = single.state === 'completed' && urls.length > 0;
|
|
1019
1041
|
return uiCompleted({
|
|
1020
|
-
tool: 'get_generation_status', kind: 'status', client,
|
|
1021
|
-
model
|
|
1042
|
+
tool: 'get_generation_status', kind: done ? mediaKind(urls[0]) : 'status', client,
|
|
1043
|
+
// The model that ACTUALLY ran. A single-id check resolves one
|
|
1044
|
+
// generation, so 'Generations' here overwrote the real model name on
|
|
1045
|
+
// the finished card the moment the live widget merged this payload in.
|
|
1046
|
+
model: res.model || 'Generations', gen: { generation_id: single.generation_id },
|
|
1022
1047
|
settings: {},
|
|
1048
|
+
state: single.state,
|
|
1049
|
+
urls: done ? urls : undefined,
|
|
1050
|
+
thumbnail_url: res.thumbnail_url,
|
|
1051
|
+
prompt: res.prompt_used || res.prompt || undefined,
|
|
1052
|
+
credits_used: creditFields(single).credits_used,
|
|
1023
1053
|
items: [{
|
|
1024
1054
|
id: single.generation_id,
|
|
1025
1055
|
state: single.state,
|