@raquezha/noheadroom 0.2.3 → 0.2.4

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/client.d.ts CHANGED
@@ -8,6 +8,7 @@ export declare class HeadroomHttpClient {
8
8
  private readonly timeoutMs;
9
9
  constructor(options: HeadroomClientOptions);
10
10
  health(signal?: AbortSignal): Promise<boolean>;
11
+ probe(signal?: AbortSignal): Promise<boolean>;
11
12
  stats(signal?: AbortSignal): Promise<unknown>;
12
13
  compress(messages: OpenAIMessage[], model: string | undefined, signal?: AbortSignal): Promise<CompressResult>;
13
14
  }
package/dist/client.js CHANGED
@@ -21,6 +21,20 @@ export class HeadroomHttpClient {
21
21
  return false;
22
22
  }
23
23
  }
24
+ async probe(signal) {
25
+ try {
26
+ const response = await fetch(`${this.baseUrl}/v1/compress`, {
27
+ method: "POST",
28
+ headers: { "Content-Type": "application/json" },
29
+ body: JSON.stringify({ messages: [{ role: "user", content: "ping" }], model: "gpt-4o" }),
30
+ signal: buildSignal(5_000, signal),
31
+ });
32
+ return response.ok;
33
+ }
34
+ catch {
35
+ return false;
36
+ }
37
+ }
24
38
  async stats(signal) {
25
39
  const response = await fetch(`${this.baseUrl}/stats`, {
26
40
  signal: buildSignal(this.timeoutMs, signal),
package/dist/index.js CHANGED
@@ -82,7 +82,12 @@ function createRuntime(pi) {
82
82
  async function updateHealthState(runtime, signal) {
83
83
  if (isRemoteBlocked(runtime.config))
84
84
  return false;
85
- runtime.state.proxyOnline = await runtime.client.health(signal);
85
+ if (await runtime.client.health(signal)) {
86
+ runtime.state.proxyOnline = true;
87
+ }
88
+ else {
89
+ runtime.state.proxyOnline = await runtime.client.probe(signal);
90
+ }
86
91
  return runtime.state.proxyOnline;
87
92
  }
88
93
  async function ensureProxy(runtime, ctx) {
@@ -38,6 +38,20 @@ export class HeadroomHttpClient {
38
38
  }
39
39
  }
40
40
 
41
+ async probe(signal?: AbortSignal): Promise<boolean> {
42
+ try {
43
+ const response = await fetch(`${this.baseUrl}/v1/compress`, {
44
+ method: "POST",
45
+ headers: { "Content-Type": "application/json" },
46
+ body: JSON.stringify({ messages: [{ role: "user", content: "ping" }], model: "gpt-4o" }),
47
+ signal: buildSignal(5_000, signal),
48
+ });
49
+ return response.ok;
50
+ } catch {
51
+ return false;
52
+ }
53
+ }
54
+
41
55
  async stats(signal?: AbortSignal): Promise<unknown> {
42
56
  const response = await fetch(`${this.baseUrl}/stats`, {
43
57
  signal: buildSignal(this.timeoutMs, signal),
@@ -137,7 +137,11 @@ function createRuntime(pi: ExtensionAPI): HeadroomRuntime {
137
137
 
138
138
  async function updateHealthState(runtime: HeadroomRuntime, signal?: AbortSignal): Promise<boolean> {
139
139
  if (isRemoteBlocked(runtime.config)) return false;
140
- runtime.state.proxyOnline = await runtime.client.health(signal);
140
+ if (await runtime.client.health(signal)) {
141
+ runtime.state.proxyOnline = true;
142
+ } else {
143
+ runtime.state.proxyOnline = await runtime.client.probe(signal);
144
+ }
141
145
  return runtime.state.proxyOnline;
142
146
  }
143
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raquezha/noheadroom",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Personal Headroom compression bridge for Pi with Docker-first defaults and Pi tool-name adaptation",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",