blits-bridge 0.1.10 → 0.1.11

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/bridge.d.ts CHANGED
@@ -13,7 +13,6 @@ export declare class BlitsBridge {
13
13
  private send;
14
14
  private handleRequest;
15
15
  private streamClaudeCLI;
16
- private processStreamEvent;
17
16
  private scheduleReconnect;
18
17
  private startHeartbeat;
19
18
  private stopHeartbeat;
package/dist/bridge.js CHANGED
@@ -108,9 +108,7 @@ class BlitsBridge {
108
108
  : JSON.stringify(lastUserMsg?.content ?? '');
109
109
  const args = [
110
110
  '-p',
111
- '--output-format', 'stream-json',
112
- '--verbose',
113
- '--include-partial-messages',
111
+ '--output-format', 'text',
114
112
  '--model', payload.model,
115
113
  '--no-session-persistence',
116
114
  '--effort', payload.effort || 'low',
@@ -126,62 +124,22 @@ class BlitsBridge {
126
124
  cwd: process.env.TMPDIR || process.env.TEMP || '/tmp',
127
125
  });
128
126
  let fullText = '';
129
- let buffer = '';
130
- let usageData = { input_tokens: 0, output_tokens: 0 };
127
+ const usageData = { input_tokens: 0, output_tokens: 0 };
131
128
  proc.stdout.on('data', (chunk) => {
132
- buffer += chunk.toString();
133
- // Process complete JSON lines
134
- const lines = buffer.split('\n');
135
- buffer = lines.pop() || ''; // keep incomplete line in buffer
136
- for (const line of lines) {
137
- if (!line.trim())
138
- continue;
139
- try {
140
- const event = JSON.parse(line);
141
- console.log(` [CLI] type=${event.type} ${event.type === 'assistant' ? `content_len=${JSON.stringify(event.message?.content || []).length} stop=${event.message?.stop_reason}` : ''}`);
142
- this.processStreamEvent(requestId, event, fullText);
143
- // Accumulate text from assistant messages
144
- if (event.type === 'assistant') {
145
- const text = event.message?.content
146
- ?.filter((c) => c.type === 'text')
147
- .map((c) => c.text)
148
- .join('') || '';
149
- if (text)
150
- fullText = text;
151
- }
152
- // Final result
153
- if (event.type === 'result') {
154
- fullText = event.result || fullText;
155
- if (event.usage) {
156
- usageData = {
157
- input_tokens: event.usage.input_tokens || 0,
158
- output_tokens: event.usage.output_tokens || 0,
159
- };
160
- }
161
- }
162
- }
163
- catch {
164
- // Not JSON, ignore
165
- }
166
- }
129
+ const text = chunk.toString();
130
+ fullText += text;
131
+ // Send each stdout chunk as a stream event
132
+ this.send({
133
+ id: requestId,
134
+ type: 'claude_api_stream',
135
+ text: fullText,
136
+ done: false,
137
+ });
167
138
  });
168
139
  proc.stderr.on('data', () => { }); // ignore stderr
169
140
  proc.stdin.write(prompt);
170
141
  proc.stdin.end();
171
142
  proc.on('close', (code) => {
172
- // Process remaining buffer
173
- if (buffer.trim()) {
174
- try {
175
- const event = JSON.parse(buffer);
176
- if (event.type === 'result') {
177
- fullText = event.result || fullText;
178
- if (event.usage) {
179
- usageData = { input_tokens: event.usage.input_tokens || 0, output_tokens: event.usage.output_tokens || 0 };
180
- }
181
- }
182
- }
183
- catch { }
184
- }
185
143
  // Send final result
186
144
  this.send({
187
145
  id: requestId,
@@ -208,23 +166,6 @@ class BlitsBridge {
208
166
  });
209
167
  });
210
168
  }
211
- processStreamEvent(requestId, event, _currentText) {
212
- // Send stream chunks to server for both full and partial assistant messages
213
- if (event.type === 'assistant') {
214
- const text = event.message?.content
215
- ?.filter((c) => c.type === 'text')
216
- .map((c) => c.text)
217
- .join('') || '';
218
- if (text) {
219
- this.send({
220
- id: requestId,
221
- type: 'claude_api_stream',
222
- text,
223
- done: event.message?.stop_reason === 'end_turn',
224
- });
225
- }
226
- }
227
- }
228
169
  scheduleReconnect() {
229
170
  if (this.reconnecting)
230
171
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blits-bridge",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "Bridge between Blits platform and local Claude CLI. Runs Claude API calls through your subscription.",
5
5
  "bin": {
6
6
  "blits-bridge": "./dist/cli.js"