polydev-ai 1.10.5 → 1.10.7
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 +15 -5
- 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
|
});
|
|
@@ -213,6 +215,7 @@ class TunnelClient {
|
|
|
213
215
|
},
|
|
214
216
|
body: JSON.stringify({
|
|
215
217
|
instance_id: this.instanceId,
|
|
218
|
+
client_version: this._cachedVersion,
|
|
216
219
|
limit: 5,
|
|
217
220
|
}),
|
|
218
221
|
});
|
|
@@ -251,7 +254,7 @@ class TunnelClient {
|
|
|
251
254
|
// Use streaming path ONLY for gemini_cli.
|
|
252
255
|
// claude_code streaming (--output-format stream-json) produces no NDJSON output
|
|
253
256
|
// in headless/tunnel mode — the non-streaming sendCliPrompt() path works reliably.
|
|
254
|
-
if (request.provider !== 'claude_code' && this.cliManager.supportsStreaming(request.provider)) {
|
|
257
|
+
if (!request._forceNonStreaming && request.provider !== 'claude_code' && this.cliManager.supportsStreaming(request.provider)) {
|
|
255
258
|
return this.handleStreamingRequest(request);
|
|
256
259
|
}
|
|
257
260
|
|
|
@@ -300,12 +303,19 @@ class TunnelClient {
|
|
|
300
303
|
}
|
|
301
304
|
|
|
302
305
|
/**
|
|
303
|
-
* Handle a streaming-capable tunnel request (
|
|
306
|
+
* Handle a streaming-capable tunnel request (Gemini CLI only).
|
|
304
307
|
* Spawns CLI with stream-json flags, reads NDJSON stdout line-by-line,
|
|
305
308
|
* extracts text deltas, batches them, and POSTs chunks to /api/tunnel/stream-chunk.
|
|
306
309
|
* On completion, POSTs final response to /api/tunnel/respond for backward compat.
|
|
307
310
|
*/
|
|
308
311
|
async handleStreamingRequest(request) {
|
|
312
|
+
// Safety guard: claude_code should NEVER enter this path.
|
|
313
|
+
// Redirect to non-streaming sendCliPrompt() which works reliably.
|
|
314
|
+
if (request.provider === 'claude_code') {
|
|
315
|
+
console.error(`[Tunnel] WARNING: claude_code routed to streaming path — redirecting to non-streaming`);
|
|
316
|
+
return this.handleRequest({ ...request, _forceNonStreaming: true });
|
|
317
|
+
}
|
|
318
|
+
|
|
309
319
|
const startTime = Date.now();
|
|
310
320
|
const requestId = request.id;
|
|
311
321
|
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.7",
|
|
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",
|