@gakim-digital/dexter-bridge 0.5.11 → 0.5.13

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": "@gakim-digital/dexter-bridge",
3
- "version": "0.5.11",
3
+ "version": "0.5.13",
4
4
  "description": "Local Companion bridge for the Dexter Framer plugin — runs Codex or Claude Code on your machine.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -29,5 +29,8 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "license": "SEE LICENSE IN LICENSE"
32
+ "license": "SEE LICENSE IN LICENSE",
33
+ "dependencies": {
34
+ "cross-spawn": "^7.0.6"
35
+ }
33
36
  }
package/src/agent.js CHANGED
@@ -1,7 +1,8 @@
1
- import { execFileSync, spawn } from 'node:child_process';
1
+ import { execFileSync } from 'node:child_process';
2
2
  import fs from 'node:fs';
3
3
  import os from 'node:os';
4
4
  import path from 'node:path';
5
+ import crossSpawn from 'cross-spawn';
5
6
  import { postRunEvent } from './api.js';
6
7
  import { createCompanionUsageAccumulator, parseAgentOutput } from './agentOutput.js';
7
8
  import {
@@ -337,12 +338,66 @@ function argsWithoutVariadicFlag(args, flag) {
337
338
  return filtered;
338
339
  }
339
340
 
340
- function argsWithOutputSchema(args, definition, outputSchema) {
341
+ function compactClaudeOutputSchema(outputSchema) {
342
+ const toolCalls = outputSchema?.properties?.toolCalls;
343
+ const itemSchema = toolCalls?.items;
344
+ const variants = Array.isArray(itemSchema?.anyOf)
345
+ ? itemSchema.anyOf
346
+ : itemSchema
347
+ ? [itemSchema]
348
+ : [];
349
+ const toolNames = Array.from(new Set(
350
+ variants.flatMap((variant) => (
351
+ Array.isArray(variant?.properties?.name?.enum)
352
+ ? variant.properties.name.enum.filter((name) => typeof name === 'string' && name)
353
+ : []
354
+ )),
355
+ ));
356
+ return {
357
+ type: 'object',
358
+ properties: {
359
+ text: { type: 'string' },
360
+ toolCalls: {
361
+ type: 'array',
362
+ ...(Number.isFinite(Number(toolCalls?.minItems))
363
+ ? { minItems: Number(toolCalls.minItems) }
364
+ : {}),
365
+ ...(Number.isFinite(Number(toolCalls?.maxItems))
366
+ ? { maxItems: Number(toolCalls.maxItems) }
367
+ : {}),
368
+ items: {
369
+ type: 'object',
370
+ properties: {
371
+ id: { type: 'string' },
372
+ name: {
373
+ type: 'string',
374
+ ...(toolNames.length ? { enum: toolNames } : {}),
375
+ },
376
+ arguments: { type: 'object' },
377
+ },
378
+ required: ['id', 'name', 'arguments'],
379
+ additionalProperties: false,
380
+ },
381
+ },
382
+ finishReason: outputSchema?.properties?.finishReason || {
383
+ type: 'string',
384
+ enum: ['tool_calls', 'stop', 'length'],
385
+ },
386
+ },
387
+ required: ['text', 'toolCalls', 'finishReason'],
388
+ additionalProperties: false,
389
+ };
390
+ }
391
+
392
+ function argsWithOutputSchema(args, definition, outputSchema, platform = process.platform) {
341
393
  if (definition.id !== 'claude-code' || !outputSchema) return args;
394
+ const launchSchema = platform === 'win32'
395
+ ? compactClaudeOutputSchema(outputSchema)
396
+ : outputSchema;
342
397
  return [
343
398
  ...argsWithoutFlagValue(args, '--json-schema'),
344
399
  '--json-schema',
345
- JSON.stringify(outputSchema),
400
+ JSON.stringify(launchSchema),
346
401
  ];
347
402
  }
348
403
 
@@ -412,7 +467,12 @@ export function buildAgentArgs(definition, modelDefinition, env = process.env, o
412
467
  const structuredArgs = argsWithStructuredOutput(modelArgs, definition, env);
413
468
  const isolatedArgs = argsWithClaudeIsolation(structuredArgs, definition);
414
469
  const modelEngineArgs = argsWithClaudeModelEngine(isolatedArgs, definition, options, env);
415
- const schemaArgs = argsWithOutputSchema(modelEngineArgs, definition, options.outputSchema);
470
+ const schemaArgs = argsWithOutputSchema(
471
+ modelEngineArgs,
472
+ definition,
473
+ options.outputSchema,
474
+ options.platform,
475
+ );
416
476
  const resumedArgs = argsWithResumedSession(schemaArgs, definition, options.resumeSessionId);
417
477
  return argsWithPromptInput(resumedArgs, definition);
418
478
  }
@@ -643,21 +703,8 @@ export function selectAgentRuntime(inspections, definition, modelDefinition) {
643
703
  };
644
704
  }
645
705
 
646
- function quoteWindowsCommandArg(value) {
647
- return `"${String(value).replace(/%/g, '%%').replace(/(["^&|<>])/g, '^$1')}"`;
648
- }
649
-
650
706
  export function processInvocation(command, args, env = process.env, platform = process.platform) {
651
707
  const resolvedCommand = resolveExecutableCommand(command, env, platform);
652
- if (platform === 'win32' && /\.(cmd|bat)$/i.test(resolvedCommand)) {
653
- const commandLine = [resolvedCommand, ...args].map(quoteWindowsCommandArg).join(' ');
654
- return {
655
- command: env.ComSpec || env.COMSPEC || 'cmd.exe',
656
- args: ['/d', '/s', '/c', commandLine],
657
- resolvedCommand,
658
- windowsHide: true,
659
- };
660
- }
661
708
  return { command: resolvedCommand, args, resolvedCommand, windowsHide: platform === 'win32' };
662
709
  }
663
710
 
@@ -738,7 +785,7 @@ function runProcess(command, args, stdin, {
738
785
  timeoutMs,
739
786
  maxDurationMs: hardDeadlineMs,
740
787
  });
741
- const child = spawn(invocation.command, invocation.args, {
788
+ const child = crossSpawn(invocation.command, invocation.args, {
742
789
  stdio: ['pipe', 'pipe', 'pipe'],
743
790
  env: childEnv,
744
791
  cwd,
@@ -286,7 +286,7 @@ export function createClaudeAgentSdkAdapter({
286
286
  return {
287
287
  ...inherited,
288
288
  CLAUDE_CONFIG_DIR: configDir,
289
- CLAUDE_AGENT_SDK_CLIENT_APP: 'dexter-hosted-worker/0.2.0',
289
+ CLAUDE_AGENT_SDK_CLIENT_APP: 'dexter-hosted-worker/0.2.1',
290
290
  };
291
291
  }
292
292