polydev-ai 1.10.4 → 1.10.6
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/lib/tunnelClient.js +17 -6
- package/package.json +2 -1
package/lib/tunnelClient.js
CHANGED
|
@@ -27,6 +27,10 @@ class TunnelClient {
|
|
|
27
27
|
this._started = false;
|
|
28
28
|
this._consecutive401s = 0; // track auth failures for token reload
|
|
29
29
|
|
|
30
|
+
// Cache version at startup — prevents stale processes from misreporting
|
|
31
|
+
// after npm cache is updated by another `npx polydev-ai@latest` invocation
|
|
32
|
+
this._cachedVersion = this._getPackageVersion();
|
|
33
|
+
|
|
30
34
|
// Configurable intervals
|
|
31
35
|
this.HEARTBEAT_INTERVAL_MS = 30_000; // 30s
|
|
32
36
|
this.POLL_INTERVAL_MS = 3_000; // 3s
|
|
@@ -171,8 +175,6 @@ class TunnelClient {
|
|
|
171
175
|
.filter(([_, s]) => s.available && s.authenticated)
|
|
172
176
|
.map(([id]) => id);
|
|
173
177
|
|
|
174
|
-
const packageVersion = this._getPackageVersion();
|
|
175
|
-
|
|
176
178
|
const url = `${this.serverBaseUrl}/api/tunnel/heartbeat`;
|
|
177
179
|
const res = await fetch(url, {
|
|
178
180
|
method: 'POST',
|
|
@@ -182,7 +184,7 @@ class TunnelClient {
|
|
|
182
184
|
},
|
|
183
185
|
body: JSON.stringify({
|
|
184
186
|
available_providers: providers,
|
|
185
|
-
client_version:
|
|
187
|
+
client_version: this._cachedVersion,
|
|
186
188
|
instance_id: this.instanceId,
|
|
187
189
|
}),
|
|
188
190
|
});
|
|
@@ -248,8 +250,10 @@ class TunnelClient {
|
|
|
248
250
|
* Handle a single tunnel request by routing to CLI
|
|
249
251
|
*/
|
|
250
252
|
async handleRequest(request) {
|
|
251
|
-
// Use streaming path for
|
|
252
|
-
|
|
253
|
+
// Use streaming path ONLY for gemini_cli.
|
|
254
|
+
// claude_code streaming (--output-format stream-json) produces no NDJSON output
|
|
255
|
+
// in headless/tunnel mode — the non-streaming sendCliPrompt() path works reliably.
|
|
256
|
+
if (!request._forceNonStreaming && request.provider !== 'claude_code' && this.cliManager.supportsStreaming(request.provider)) {
|
|
253
257
|
return this.handleStreamingRequest(request);
|
|
254
258
|
}
|
|
255
259
|
|
|
@@ -298,12 +302,19 @@ class TunnelClient {
|
|
|
298
302
|
}
|
|
299
303
|
|
|
300
304
|
/**
|
|
301
|
-
* Handle a streaming-capable tunnel request (
|
|
305
|
+
* Handle a streaming-capable tunnel request (Gemini CLI only).
|
|
302
306
|
* Spawns CLI with stream-json flags, reads NDJSON stdout line-by-line,
|
|
303
307
|
* extracts text deltas, batches them, and POSTs chunks to /api/tunnel/stream-chunk.
|
|
304
308
|
* On completion, POSTs final response to /api/tunnel/respond for backward compat.
|
|
305
309
|
*/
|
|
306
310
|
async handleStreamingRequest(request) {
|
|
311
|
+
// Safety guard: claude_code should NEVER enter this path.
|
|
312
|
+
// Redirect to non-streaming sendCliPrompt() which works reliably.
|
|
313
|
+
if (request.provider === 'claude_code') {
|
|
314
|
+
console.error(`[Tunnel] WARNING: claude_code routed to streaming path — redirecting to non-streaming`);
|
|
315
|
+
return this.handleRequest({ ...request, _forceNonStreaming: true });
|
|
316
|
+
}
|
|
317
|
+
|
|
307
318
|
const startTime = Date.now();
|
|
308
319
|
const requestId = request.id;
|
|
309
320
|
const provider = request.provider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polydev-ai",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.6",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=20.x <=22.x"
|
|
6
6
|
},
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"marked": "^16.2.1",
|
|
83
83
|
"next": "^15.5.7",
|
|
84
84
|
"open": "^11.0.0",
|
|
85
|
+
"polydev-ai": "^1.10.5",
|
|
85
86
|
"posthog-js": "^1.157.2",
|
|
86
87
|
"prismjs": "^1.30.0",
|
|
87
88
|
"react": "^18.3.1",
|