@1presence/bridge 0.29.0 → 0.31.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.
Files changed (2) hide show
  1. package/dist/claude.js +50 -3
  2. package/package.json +1 -1
package/dist/claude.js CHANGED
@@ -76,6 +76,33 @@ function debugBlock(label, colorCode, body) {
76
76
  const rule = `── ${label} `.padEnd(64, '─');
77
77
  process.stderr.write(`\n${paint(colorCode, rule)}\n${body.trimEnd()}\n`);
78
78
  }
79
+ // Render one replayed-history content block as a single readable line for the
80
+ // debug transcript. Tool calls and results are inlined so a history turn shows
81
+ // exactly what the model received — text, the tools it ran, and what they
82
+ // returned (including error flags) — not just an opaque "(replaying N turns)".
83
+ function summariseHistoryBlock(block) {
84
+ if (block.type === 'text')
85
+ return block.text.trimEnd();
86
+ if (block.type === 'tool_use') {
87
+ return `→ ${block.name} ${formatPayload(block.input)}`;
88
+ }
89
+ // tool_result
90
+ const body = typeof block.content === 'string'
91
+ ? block.content
92
+ : block.content.map((c) => c.text).join('');
93
+ const errFlag = block.is_error ? ' [error]' : '';
94
+ return `← ${block.tool_use_id}${errFlag} ${body}`;
95
+ }
96
+ // Render a full replayed-history message with its role colour so the operator
97
+ // can tell user turns from assistant turns at a glance — the missing
98
+ // distinction that made replayed context unreadable in --debug.
99
+ function renderHistoryMessage(msg) {
100
+ const color = msg.role === 'user' ? DEBUG_COLORS.user : DEBUG_COLORS.assistant;
101
+ const body = typeof msg.content === 'string'
102
+ ? msg.content
103
+ : msg.content.map(summariseHistoryBlock).join('\n');
104
+ debugBlock(`${msg.role} · history`, color, body);
105
+ }
79
106
  // ─── Active processes ─────────────────────────────────────────────────────────
80
107
  const active = new Map();
81
108
  // ─── Spawn ────────────────────────────────────────────────────────────────────
@@ -88,14 +115,34 @@ function spawnClaude(params) {
88
115
  process.stderr.write(`[bridge:verbose] override md: ${(0, path_1.join)(BRIDGE_CWD, 'CLAUDE.md')}\n`);
89
116
  process.stderr.write(`[bridge:verbose] system prompt: ${systemPromptPath}\n`);
90
117
  process.stderr.write(`[bridge:verbose] mcp config: ${mcpConfigPath}\n`);
118
+ process.stderr.write(`[bridge:verbose] session id: ${presenceSessionId}\n`);
119
+ process.stderr.write(`[bridge:verbose] conversation: ${conversationId}\n`);
91
120
  process.stderr.write(`[bridge:verbose] history turns: ${history.length}\n`);
92
121
  }
93
122
  // Debug transcript: lead with the user prompt for this turn (the clean
94
- // message, before the gateway's ephemeral-context prefix), plus a hint at
123
+ // message, before the gateway's ephemeral-context prefix), plus the session
124
+ // id (correlates with the chat URL / Firestore session doc) and a hint at
95
125
  // how much prior context is being replayed.
96
126
  if (debug) {
97
- const histNote = history.length ? ` (replaying ${history.length} prior turn${history.length === 1 ? '' : 's'})` : '';
98
- debugBlock(`user${histNote}`, DEBUG_COLORS.user, text);
127
+ process.stderr.write(`\n${paint('1', `══ session ${presenceSessionId} ══`)}\n`);
128
+ // `history` already ends with the new user prompt (gateway-appended). Render
129
+ // every PRIOR message with its role colour so what the model saw as context
130
+ // is auditable — then the live turn is shown via the clean `text` below and
131
+ // streams in beneath it. Defensive: if the tail isn't the current user turn
132
+ // (unexpected), render the whole history rather than dropping a message.
133
+ const tail = history[history.length - 1];
134
+ const prior = tail?.role === 'user' ? history.slice(0, -1) : history;
135
+ if (prior.length > 0) {
136
+ process.stderr.write(paint('90', ` replaying ${prior.length} prior message${prior.length === 1 ? '' : 's'}:\n`));
137
+ for (const msg of prior)
138
+ renderHistoryMessage(msg);
139
+ }
140
+ debugBlock('user · this turn', DEBUG_COLORS.user, text);
141
+ }
142
+ else if (!verbose) {
143
+ // Default mode is quiet, but always surface the session id once per turn so
144
+ // it can be matched to the chat URL / Firestore session doc when debugging.
145
+ process.stderr.write(`[bridge] session ${presenceSessionId}\n`);
99
146
  }
100
147
  // tool_use_id → tool name, so a tool_result block (which only carries the id)
101
148
  // can be labelled with the tool it answers in the debug transcript.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1presence/bridge",
3
- "version": "0.29.0",
3
+ "version": "0.31.0",
4
4
  "description": "Run 1Presence on your Mac and use your Claude.ai Pro subscription from any device",
5
5
  "bin": {
6
6
  "1presence-bridge": "dist/index.js"