@goodandready/dsh-image-gen 0.11.1 → 0.11.3

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 CHANGED
@@ -458,7 +458,28 @@ export async function enhancePrompt(ctx, cfg, prompt, signal, provider) {
458
458
  }
459
459
  }
460
460
 
461
- export function apply(ctx, config) {
461
+ function sanitizeRaw(raw) {
462
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {}
463
+ const cleaned = {}
464
+ for (const [k, v] of Object.entries(raw)) {
465
+ if (v && typeof v === "object" && !Array.isArray(v) && typeof v.get !== "function" && Object.keys(v).length === 0) {
466
+ continue
467
+ }
468
+ cleaned[k] = v
469
+ }
470
+ return cleaned
471
+ }
472
+
473
+ export function ensureConfig(raw) {
474
+ const cleaned = sanitizeRaw(raw)
475
+ const plain = plainConfig(cleaned)
476
+ return Config(plain)
477
+ }
478
+
479
+
480
+ export function apply(ctx, rawConfig) {
481
+ const config = ensureConfig(rawConfig)
482
+ const baseConfig = plainConfig(config)
462
483
  if (ctx.systemPrompt && typeof ctx.systemPrompt.section === 'function') {
463
484
  ctx.systemPrompt.section({
464
485
  name: 'tool:image-generation',
@@ -473,7 +494,7 @@ export function apply(ctx, config) {
473
494
  let settingsApi
474
495
  let currentLiveConfig = null
475
496
  let getConfig = () => currentLiveConfig || config
476
- const live = () => Config(structuredClone(plainConfig(getConfig() ?? {}))) ?? config
497
+ const live = () => plainConfig(getConfig() ?? {})
477
498
 
478
499
  const createSettingsAdapter = (svc) => {
479
500
  if (!svc) return undefined
@@ -690,7 +711,7 @@ export function apply(ctx, config) {
690
711
 
691
712
  // Tool registrations live in register-tools.js; each tool is a labeled ctx.effect (#216).
692
713
  registerAllTools(ctx, {
693
- config,
714
+ config: baseConfig,
694
715
  live,
695
716
  saveAndAttachResult,
696
717
  resolveSource,
@@ -70,7 +70,7 @@ export function registerGenerationTools(ctx, deps) {
70
70
  },
71
71
  image_size: {
72
72
  type: 'string',
73
- description: `One of: ${IMAGE_SIZES.join(', ')}. Default: ${config.defaultSize}.`,
73
+ description: `One of: ${IMAGE_SIZES.join(', ')}. Default: ${config?.defaultSize || 'square_hd'}.`,
74
74
  },
75
75
  aspect_ratio: {
76
76
  type: 'string',
@@ -84,7 +84,7 @@ export function registerGenerationTools(ctx, deps) {
84
84
  output_format: {
85
85
  type: 'string',
86
86
  enum: OUTPUT_FORMATS,
87
- description: `Output format. Default: ${config.defaultFormat}.`,
87
+ description: `Output format. Default: ${config?.defaultFormat || 'png'}.`,
88
88
  },
89
89
  output_name: {
90
90
  type: 'string',
@@ -219,7 +219,7 @@ export function registerGenerationTools(ctx, deps) {
219
219
  },
220
220
  },
221
221
  isConcurrencySafe: () => false,
222
- timeoutMs: config.timeoutMs + 30000,
222
+ timeoutMs: (config?.timeoutMs || 180000) + 30000,
223
223
  async execute(args, exec) {
224
224
  const cfg = live()
225
225
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-image-gen",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
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",