@a1hvdy/cc-openclaw 0.4.7 → 0.4.8

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": "@a1hvdy/cc-openclaw",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "A1xAI's Anthropic CLI bridge plugin for OpenClaw",
5
5
  "author": "@a1cy",
6
6
  "license": "MIT",
@@ -222,12 +222,32 @@ export function extractUserMessage(messages, headers) {
222
222
  const userMessage = lastUserText ? `${toolResultBlock}\n\n${lastUserText}` : toolResultBlock;
223
223
  return { systemPrompt, userMessage, isNewConversation: false };
224
224
  }
225
- // Find last user message
225
+ // Find user messages — concatenate all of them in order.
226
+ //
227
+ // 2026-05-07 fix for OpenClaw 2026.5.6 multi-user-message format:
228
+ // 5.6 sends TWO user messages — [0]=actual user input as content blocks,
229
+ // [1]=large system context + sender metadata as a string. The previous
230
+ // `userMessages[length-1]` extraction picked up the metadata blob and
231
+ // silently dropped the actual user input, causing bare prompts to appear
232
+ // as empty questions to Claude (Claude responds with stale/recycled
233
+ // context like "Good. What's up?" because no real question reached it).
234
+ //
235
+ // Fix: concatenate all user messages with double-newline separator. This
236
+ // ensures the actual user input AND the conversation/runtime context
237
+ // both reach Claude. The first message (typed text) leads, followed by
238
+ // the metadata block as additional context.
239
+ //
240
+ // Backwards compat: when only one user message exists (older OpenClaw
241
+ // versions or non-OpenClaw callers), this is identical to the old
242
+ // single-message extraction.
226
243
  const userMessages = messages.filter((m) => m.role === 'user');
227
244
  if (userMessages.length === 0) {
228
245
  throw new Error('No user message found in messages array');
229
246
  }
230
- const rawUserMessage = textOf(userMessages[userMessages.length - 1]);
247
+ const userTexts = userMessages.map(textOf).filter((t) => t && t.length > 0);
248
+ const rawUserMessage = userTexts.length > 1
249
+ ? userTexts.join('\n\n')
250
+ : (userTexts[0] || textOf(userMessages[userMessages.length - 1]));
231
251
  // Workspace skill auto-inline: if the user typed /<skillname> [args] and
232
252
  // ~/.openclaw/workspace/skills/*/SKILL.md has a matching `name:` frontmatter,
233
253
  // inline the SKILL.md body so the model has full skill context without
@@ -446,23 +446,8 @@ export class PersistentClaudeSession extends EventEmitter {
446
446
  content: typeof finalMessage === 'string' ? [{ type: 'text', text: finalMessage }] : finalMessage,
447
447
  },
448
448
  };
449
- // 2026-05-07 instrumentation — diagnose silent /cc subprocess hang
450
- process.stderr.write(JSON.stringify({
451
- ts: new Date().toISOString(),
452
- type: 'cc-openclaw.stdin-write',
453
- sessionName: this.options?.name || 'unknown',
454
- payloadSize: JSON.stringify(payload).length + 1,
455
- stdinWritable: !!(this.proc?.stdin?.writable),
456
- stdinDestroyed: !!(this.proc?.stdin?.destroyed),
457
- procPid: this.proc?.pid,
458
- procKilled: !!(this.proc?.killed),
459
- }) + '\n');
460
- const _writeOk = this.proc.stdin.write(JSON.stringify(payload) + '\n');
461
- process.stderr.write(JSON.stringify({
462
- ts: new Date().toISOString(),
463
- type: 'cc-openclaw.stdin-write.result',
464
- writeReturn: _writeOk,
465
- }) + '\n');
449
+ this.proc.stdin.write(JSON.stringify(payload) + '
450
+ ');
466
451
  if (options.callbacks)
467
452
  this._streamCallbacks = options.callbacks;
468
453
  if (options.waitForComplete) {