@goodandready/dsh-image-gen 0.10.5 → 0.10.6
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/lib/index.js +11 -10
- package/lib/providers.js +23 -0
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
applyStylePreset,
|
|
46
46
|
resolveStylePreset,
|
|
47
47
|
blendImagesFal,
|
|
48
|
+
toLosslessJson,
|
|
48
49
|
} from './providers.js'
|
|
49
50
|
|
|
50
51
|
import { resolveConversationImage, analyzeImageWithVision, buildDualOutputMarkdown } from './resolve-image.js'
|
|
@@ -131,7 +132,7 @@ export async function saveAndAttachResult(ctx, exec, cfg, {
|
|
|
131
132
|
attachmentId: attachment.attachmentId,
|
|
132
133
|
})
|
|
133
134
|
|
|
134
|
-
return {
|
|
135
|
+
return toLosslessJson({
|
|
135
136
|
summary,
|
|
136
137
|
path: filePath,
|
|
137
138
|
url: deliverAs === 'image' && sourceUrl ? sourceUrl : localUrl,
|
|
@@ -149,7 +150,7 @@ export async function saveAndAttachResult(ctx, exec, cfg, {
|
|
|
149
150
|
height: attachment.height,
|
|
150
151
|
name: attachment.name,
|
|
151
152
|
},
|
|
152
|
-
}
|
|
153
|
+
})
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
export const name = 'dsh-image-gen'
|
|
@@ -916,7 +917,7 @@ export function apply(ctx, config) {
|
|
|
916
917
|
height: gen.height || attachment.height,
|
|
917
918
|
seed: gen.seed,
|
|
918
919
|
prompt: promptArg,
|
|
919
|
-
|
|
920
|
+
...(enhanced.enhanced ? { originalPrompt: args.prompt } : {}),
|
|
920
921
|
cost: gen.cost,
|
|
921
922
|
format: mediaType.replace('image/', ''),
|
|
922
923
|
attachment: {
|
|
@@ -988,7 +989,7 @@ export function apply(ctx, config) {
|
|
|
988
989
|
cost: first.cost,
|
|
989
990
|
attachmentId: first.attachment?.attachmentId || 'N/A',
|
|
990
991
|
})
|
|
991
|
-
return { summary: dualOutputSummary, channel: provider, provider, model: cfg.model || cfg.customModel, ...first, images }
|
|
992
|
+
return toLosslessJson({ summary: dualOutputSummary, channel: provider, provider, model: cfg.model || cfg.customModel, ...first, images })
|
|
992
993
|
},
|
|
993
994
|
}),
|
|
994
995
|
)
|
|
@@ -1288,11 +1289,11 @@ export function apply(ctx, config) {
|
|
|
1288
1289
|
throw new Error(`All aspect ratio generations failed in pack: ${warnings.join('; ')}`)
|
|
1289
1290
|
}
|
|
1290
1291
|
|
|
1291
|
-
return {
|
|
1292
|
+
return toLosslessJson({
|
|
1292
1293
|
images: results,
|
|
1293
1294
|
count: results.length,
|
|
1294
|
-
warnings
|
|
1295
|
-
}
|
|
1295
|
+
...(warnings.length ? { warnings } : {}),
|
|
1296
|
+
})
|
|
1296
1297
|
},
|
|
1297
1298
|
}),
|
|
1298
1299
|
)
|
|
@@ -1414,7 +1415,7 @@ export function apply(ctx, config) {
|
|
|
1414
1415
|
if (vision.summary) {
|
|
1415
1416
|
result.visionAnalysis = vision.summary
|
|
1416
1417
|
}
|
|
1417
|
-
return result
|
|
1418
|
+
return toLosslessJson(result)
|
|
1418
1419
|
},
|
|
1419
1420
|
}),
|
|
1420
1421
|
)
|
|
@@ -1535,10 +1536,10 @@ export function apply(ctx, config) {
|
|
|
1535
1536
|
}
|
|
1536
1537
|
|
|
1537
1538
|
const first = results[0]
|
|
1538
|
-
return {
|
|
1539
|
+
return toLosslessJson({
|
|
1539
1540
|
...first,
|
|
1540
1541
|
variations: results.map((r) => ({ path: r.path, attachmentId: r.attachment?.attachmentId, seed: r.seed })),
|
|
1541
|
-
}
|
|
1542
|
+
})
|
|
1542
1543
|
},
|
|
1543
1544
|
}),
|
|
1544
1545
|
)
|
package/lib/providers.js
CHANGED
|
@@ -983,3 +983,26 @@ export async function varyImageDirect(deps, job) {
|
|
|
983
983
|
if (!fn) throw new Error(`Provider "${providerKey}" does not support image variations`)
|
|
984
984
|
return fn(job.seed, job.prompt)
|
|
985
985
|
}
|
|
986
|
+
|
|
987
|
+
/**
|
|
988
|
+
* Recursively removes any property with an undefined value so the result satisfies
|
|
989
|
+
* DSH lossless JSON requirements (dsh-util-values isJsonValue).
|
|
990
|
+
*
|
|
991
|
+
* @param {any} val
|
|
992
|
+
* @returns {any}
|
|
993
|
+
*/
|
|
994
|
+
export function toLosslessJson(val) {
|
|
995
|
+
if (val === null || typeof val === 'boolean' || typeof val === 'string') return val
|
|
996
|
+
if (typeof val === 'number') return Number.isFinite(val) && !Object.is(val, -0) ? val : null
|
|
997
|
+
if (Array.isArray(val)) return val.map(toLosslessJson)
|
|
998
|
+
if (typeof val === 'object' && val !== null) {
|
|
999
|
+
const res = {}
|
|
1000
|
+
for (const [k, v] of Object.entries(val)) {
|
|
1001
|
+
if (v !== undefined) {
|
|
1002
|
+
res[k] = toLosslessJson(v)
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
return res
|
|
1006
|
+
}
|
|
1007
|
+
return null
|
|
1008
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@goodandready/dsh-image-gen",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.6",
|
|
4
4
|
"description": "Image generation for DeepSeek Harness: a generate_image tool with pluggable providers — the FAL queue, any OpenAI-compatible images API, or a ChatGPT/Grok subscription with no API key at all. The picture is shown inline in the conversation; the model receives either a link (works with any chat model) or the image itself (needs dsh-vision-bridge or a vision-capable model).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek-harness",
|