@phren/cli 0.1.17 → 0.1.20

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.
@@ -1,48 +0,0 @@
1
- import * as fs from "fs";
2
- import * as path from "path";
3
- import { execFileSync } from "child_process";
4
- import { pathToFileURL } from "url";
5
- import { ROOT } from "./package-metadata.js";
6
- async function tryImport(candidate) {
7
- try {
8
- return await import(candidate);
9
- }
10
- catch {
11
- return null;
12
- }
13
- }
14
- async function loadBundledAgentModule() {
15
- const workspaceCandidates = [
16
- path.join(ROOT, "..", "agent", "src", "index.ts"),
17
- path.join(ROOT, "..", "agent", "dist", "index.js"),
18
- ];
19
- for (const candidate of workspaceCandidates) {
20
- if (!fs.existsSync(candidate))
21
- continue;
22
- const mod = await tryImport(pathToFileURL(candidate).href);
23
- if (mod?.runAgentCli)
24
- return mod;
25
- }
26
- const packageModule = await tryImport("@phren/agent");
27
- if (packageModule?.runAgentCli)
28
- return packageModule;
29
- return null;
30
- }
31
- export async function runBundledAgentCli(args) {
32
- const mod = await loadBundledAgentModule();
33
- if (mod?.runAgentCli) {
34
- await mod.runAgentCli(args);
35
- return;
36
- }
37
- try {
38
- execFileSync("phren-agent", args, { stdio: "inherit" });
39
- return;
40
- }
41
- catch (err) {
42
- if (err && typeof err === "object" && "status" in err) {
43
- const status = err.status;
44
- process.exit(status ?? 1);
45
- }
46
- throw new Error("Integrated agent runtime is unavailable. Install or build @phren/agent, or use `phren manage ...` for memory operations.");
47
- }
48
- }