@1presence/bridge 0.27.0 → 0.28.0
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/dist/claude.js +10 -1
- package/package.json +1 -1
package/dist/claude.js
CHANGED
|
@@ -147,7 +147,16 @@ function spawnClaude(params) {
|
|
|
147
147
|
throw new Error('claude stdin is null — spawn must use stdio[0]="pipe"');
|
|
148
148
|
}
|
|
149
149
|
for (const msg of history) {
|
|
150
|
-
|
|
150
|
+
// Normalise to array-of-blocks: Claude Code's stream-json input parser
|
|
151
|
+
// iterates `content` directly. A string slips into a `"tool_use_id" in
|
|
152
|
+
// <char>` check inside the CLI and aborts the process with `W is not an
|
|
153
|
+
// Object` (JSC) / exit 1 mid-turn. The gateway also normalises before
|
|
154
|
+
// sending, so a current gateway + any bridge version is safe; this guard
|
|
155
|
+
// covers older gateways and ad-hoc local replay tests.
|
|
156
|
+
const content = Array.isArray(msg.content)
|
|
157
|
+
? msg.content
|
|
158
|
+
: [{ type: 'text', text: typeof msg.content === 'string' ? msg.content : '' }];
|
|
159
|
+
const wrapped = { type: msg.role, message: { role: msg.role, content } };
|
|
151
160
|
stdin.write(JSON.stringify(wrapped) + '\n');
|
|
152
161
|
}
|
|
153
162
|
stdin.end();
|