pi-freeflow 1.4.10 → 1.4.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/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.11",
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/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;