pi-open-agents 0.1.19 → 0.1.21

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,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-open-agents",
3
- "version": "0.1.19",
3
+ "version": "0.1.21",
4
4
  "description": "Unified agent and subagent management for pi coding agent, with OpenCode-compatible agent definitions.",
5
5
  "keywords": [
6
6
  "pi-package",
@@ -63,6 +63,9 @@
63
63
  }
64
64
  },
65
65
  "devDependencies": {
66
+ "@earendil-works/pi-ai": "0.84.4",
67
+ "@earendil-works/pi-coding-agent": "0.84.4",
68
+ "@earendil-works/pi-tui": "0.84.4",
66
69
  "@types/node": "^24.0.0",
67
70
  "tsx": "^4.19.0",
68
71
  "typebox": "^1.3.10",
@@ -9,12 +9,13 @@
9
9
  */
10
10
 
11
11
  import {
12
- AuthStorage,
13
12
  ModelRegistry,
14
13
  SessionManager,
15
14
  withFileMutationQueue,
16
15
  } from "@earendil-works/pi-coding-agent";
16
+ import * as piCodingAgent from "@earendil-works/pi-coding-agent";
17
17
  import { spawn } from "node:child_process";
18
+ import { realpathSync } from "node:fs";
18
19
  import * as fs from "node:fs/promises";
19
20
  import * as os from "node:os";
20
21
  import * as path from "node:path";
@@ -195,10 +196,23 @@ export function subagentSessionDir(
195
196
  return path.join(agentDir, "sessions", safeProject, "subagents");
196
197
  }
197
198
 
198
- export function resolvePiEntryPoint(): PiResolution {
199
- const packageEntryPoint = fileURLToPath(
200
- import.meta.resolve("@earendil-works/pi-coding-agent"),
201
- );
199
+ export function resolvePiEntryPoint(
200
+ resolveSelf: (specifier: string) => string = (specifier) => import.meta.resolve(specifier),
201
+ ): PiResolution {
202
+ let packageEntryPoint: string;
203
+ try {
204
+ packageEntryPoint = fileURLToPath(resolveSelf("@earendil-works/pi-coding-agent"));
205
+ } catch {
206
+ // npm-distributed plugin + bundled pi: the loader resolves host imports
207
+ // through virtualModules, but import.meta.resolve falls back to native
208
+ // resolution which cannot see the host package from the plugin's install
209
+ // tree (peer dependencies are never installed next to it). Fall back to
210
+ // the running pi entry itself — the child must run the same pi anyway.
211
+ return {
212
+ command: process.execPath,
213
+ entryPoint: realpathSync(process.argv[1]),
214
+ };
215
+ }
202
216
  const packageRoot = path.dirname(path.dirname(packageEntryPoint));
203
217
  return {
204
218
  command: process.execPath,
@@ -402,7 +416,11 @@ export function buildModelRegistry(
402
416
  agentDir: string | undefined,
403
417
  factories: { auth?: AuthFactory; model?: RegistryFactory } = {},
404
418
  ): ContextWindowLookup | undefined {
405
- const auth = ("auth" in factories ? factories.auth : AuthStorage) as AuthFactory | undefined;
419
+ // AuthStorage was removed from newer pi-coding-agent hosts. A static named
420
+ // import of it would fail module linking on hosts that no longer export it,
421
+ // so look it up on the namespace object instead (absent → undefined).
422
+ const hostAuth = (piCodingAgent as Record<string, unknown>).AuthStorage;
423
+ const auth = ("auth" in factories ? factories.auth : hostAuth) as AuthFactory | undefined;
406
424
  const model = ("model" in factories ? factories.model : ModelRegistry) as RegistryFactory | undefined;
407
425
  try {
408
426
  if (!auth || typeof auth.create !== "function") return undefined;