pi-freeflow 1.4.10 → 1.4.12

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-freeflow",
3
3
  "type": "module",
4
- "version": "1.4.10",
4
+ "version": "1.4.12",
5
5
  "description": "Thin provider for OMP/Pi — model list + dumb relay proxy + log; host pi-ai owns thinking/normalization",
6
6
  "main": "extensions/index.ts",
7
7
  "types": "src/index.ts",
package/src/catalog.ts CHANGED
@@ -34,8 +34,7 @@ import type {
34
34
  /**
35
35
  * Pruned model IDs that must never re-enter the catalog via disk cache or upstream merge.
36
36
  */
37
- const DEAD_MODEL_IDS = new Set<string>(["deepseek-v4-flash-free", "x-preview-f-free"]);
38
-
37
+ export const DEAD_MODEL_IDS = new Set<string>(["deepseek-v4-flash-free", "x-preview-f-free"]);
39
38
  /**
40
39
  * In-memory cache of currently active/available free models.
41
40
  * Initialized with all 21 verified models for 0ms instant availability.
package/src/config.ts CHANGED
@@ -15,6 +15,7 @@ export const OPENCODE_API_URL = `${UPSTREAM_OPENCODE}/v1`;
15
15
 
16
16
  // ── Network & Server defaults ───────────────────────────────────────
17
17
  export const DEFAULT_PORT = 28180;
18
+ export const LEGACY_PORT = 18080;
18
19
  export const HOST = "127.0.0.1";
19
20
  export const DEFAULT_HOST = "127.0.0.1";
20
21
 
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  setAliveCatalog,
18
18
  } from "./catalog.ts";
19
19
  import { createCommandSpec, updateStatusBar } from "./commands.ts";
20
- import { DEFAULT_HOST, HOST, PORT } from "./config.ts";
20
+ import { DEFAULT_HOST, HOST, LEGACY_PORT, PORT } from "./config.ts";
21
21
  import { log, logInfo, logWarn } from "./logger.ts";
22
22
  import { ALL_MODELS, KILO_MODEL_IDS, MODEL_MAP, getAllRegisteredModels, resolveCanonicalModelId } from "./models.ts";
23
23
  import { isProxyAlive, startProxy } from "./proxy.ts";
@@ -117,12 +117,20 @@ export default async function (pi: ExtensionAPI): Promise<void> {
117
117
  let actualPort = PORT;
118
118
 
119
119
  // 2. Single-Port Shared Pattern: Check if daemon is already running (e.g. parent session)
120
- const alreadyRunning = await isProxyAlive(PORT);
120
+ // Dual-probe: probe current PORT first; if missing, check LEGACY_PORT so existing v1.4.9
121
+ // sessions on 18080 are seamlessly reused without split-brain or duplicate daemons.
122
+ let alreadyRunning = await isProxyAlive(PORT);
121
123
  if (alreadyRunning) {
122
124
  logInfo(
123
125
  `Reusing existing pi-freeflow proxy daemon on http://${HOST}:${PORT}`,
124
126
  );
125
127
  actualPort = PORT;
128
+ } else if (PORT !== LEGACY_PORT && (await isProxyAlive(LEGACY_PORT))) {
129
+ logInfo(
130
+ `Reusing existing legacy pi-freeflow proxy daemon on http://${HOST}:${LEGACY_PORT}`,
131
+ );
132
+ alreadyRunning = true;
133
+ actualPort = LEGACY_PORT;
126
134
  } else {
127
135
  try {
128
136
  const r = await startProxy();
@@ -161,6 +169,19 @@ export default async function (pi: ExtensionAPI): Promise<void> {
161
169
  ensuringDaemon = true;
162
170
  try {
163
171
  if (await isProxyAlive(actualPort)) return;
172
+ // If actualPort died, check if another daemon is alive on PORT or LEGACY_PORT before binding
173
+ if (await isProxyAlive(PORT)) {
174
+ actualPort = PORT;
175
+ registerCatalog(getAliveCatalog());
176
+ logInfo(`Re-attached to proxy daemon on http://${HOST}:${PORT}`);
177
+ return;
178
+ }
179
+ if (PORT !== LEGACY_PORT && (await isProxyAlive(LEGACY_PORT))) {
180
+ actualPort = LEGACY_PORT;
181
+ registerCatalog(getAliveCatalog());
182
+ logInfo(`Re-attached to legacy proxy daemon on http://${HOST}:${LEGACY_PORT}`);
183
+ return;
184
+ }
164
185
  const r = await startProxy();
165
186
  if (r.server) server = r.server;
166
187
  if (r.port) actualPort = r.port;
package/src/proxy.ts CHANGED
@@ -475,10 +475,12 @@ export function startProxy(
475
475
  log("error", "server error", { code: err.code, message: err.message });
476
476
  reject(err);
477
477
  });
478
-
479
478
  server.listen(port, HOST, () => {
480
479
  if (settled) return;
481
480
  settled = true;
481
+ try {
482
+ server.unref();
483
+ } catch {}
482
484
  const addr = server.address();
483
485
  const realPort = addr && typeof addr === "object" ? addr.port : port;
484
486
  log("info", `proxy listening on http://${HOST}:${realPort}`);