@baryonlabs/cli 0.3.0 → 0.3.1
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 +1 -1
- package/src/commands.js +20 -2
- package/src/config.js +41 -0
- package/src/constants.js +23 -4
package/package.json
CHANGED
package/src/commands.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
hasConfig,
|
|
6
6
|
loadConfig,
|
|
7
7
|
piProviderConfigured,
|
|
8
|
+
prunePiPackages,
|
|
8
9
|
saveConfig,
|
|
9
10
|
syncPiModels,
|
|
10
11
|
BARYON_CONFIG,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
DEFAULT_BASE_URL,
|
|
16
17
|
DEFAULT_EXTENSIONS,
|
|
17
18
|
DEFAULT_MODELS,
|
|
19
|
+
DEPRECATED_EXTENSIONS,
|
|
18
20
|
HOMEPAGE,
|
|
19
21
|
KEYS_URL,
|
|
20
22
|
KEY_PREFIX,
|
|
@@ -233,13 +235,29 @@ export function installDefaults() {
|
|
|
233
235
|
return 0;
|
|
234
236
|
}
|
|
235
237
|
|
|
238
|
+
// Self-heal machines broken by a previously-shipped conflicting extension
|
|
239
|
+
// (e.g. pi-search ↔ pi-web-fetch both registering `web_fetch`, which hard-fails
|
|
240
|
+
// every run). Remove them from pi's registry + disk before (re)installing.
|
|
241
|
+
const pruned = prunePiPackages(DEPRECATED_EXTENSIONS);
|
|
242
|
+
if (pruned.length) warn(`충돌 확장 제거: ${pruned.join(", ")} (자가 치유)`);
|
|
243
|
+
|
|
236
244
|
log(` ${sym.info} 기본 확장 설치 중 (${DEFAULT_EXTENSIONS.length}종 · git clone, 잠시 걸립니다)…`);
|
|
237
245
|
let okc = 0;
|
|
238
246
|
|
|
239
247
|
for (const e of DEFAULT_EXTENSIONS) {
|
|
240
|
-
|
|
248
|
+
// git clone is flaky under GitHub rate-limiting / transient network — retry
|
|
249
|
+
// a few times so a single class doesn't end up with "0/N" extensions.
|
|
250
|
+
let status = 1;
|
|
251
|
+
|
|
252
|
+
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
253
|
+
const r = spawnSync(process.execPath, [entry, "install", e.src], { encoding: "utf8" });
|
|
254
|
+
status = r.status;
|
|
255
|
+
if (status === 0) break;
|
|
256
|
+
// Cross-platform synchronous backoff (no `sleep` binary — Windows lacks it).
|
|
257
|
+
if (attempt < 3) Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, 2000);
|
|
258
|
+
}
|
|
241
259
|
|
|
242
|
-
if (
|
|
260
|
+
if (status === 0) {
|
|
243
261
|
ok(`${e.name} — ${e.note}`);
|
|
244
262
|
okc++;
|
|
245
263
|
} else {
|
package/src/config.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
DEFAULT_MODELS,
|
|
11
11
|
PI_AGENT_DIR,
|
|
12
12
|
PI_MODELS_JSON,
|
|
13
|
+
PI_SETTINGS_JSON,
|
|
13
14
|
PROVIDER,
|
|
14
15
|
SESSION_HEADER,
|
|
15
16
|
SESSION_ID_ENV,
|
|
@@ -115,4 +116,44 @@ export function ensurePiSessionHeader() {
|
|
|
115
116
|
return true;
|
|
116
117
|
}
|
|
117
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Self-heal installs broken by a deprecated extension: drop its URL from pi's
|
|
121
|
+
* settings.json `packages` list and remove the cloned dir so pi stops loading
|
|
122
|
+
* it. Pure fs/JSON → works identically on macOS/Linux/Windows. Returns the list
|
|
123
|
+
* of names actually removed.
|
|
124
|
+
*/
|
|
125
|
+
export function prunePiPackages(deprecated) {
|
|
126
|
+
const removed = [];
|
|
127
|
+
const srcs = new Set(deprecated.map((d) => d.src));
|
|
128
|
+
|
|
129
|
+
// 1) drop from settings.json packages[]
|
|
130
|
+
try {
|
|
131
|
+
const s = readJson(PI_SETTINGS_JSON, null);
|
|
132
|
+
if (s && Array.isArray(s.packages)) {
|
|
133
|
+
const kept = s.packages.filter((u) => !srcs.has(u));
|
|
134
|
+
if (kept.length !== s.packages.length) {
|
|
135
|
+
s.packages = kept;
|
|
136
|
+
writeJson(PI_SETTINGS_JSON, s);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
} catch {
|
|
140
|
+
/* settings missing/unreadable — nothing to prune */
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 2) remove the cloned extension directory (git/github.com/<owner>/<name>)
|
|
144
|
+
for (const d of deprecated) {
|
|
145
|
+
const dir = path.join(PI_AGENT_DIR, "git", "github.com", d.owner, d.name);
|
|
146
|
+
try {
|
|
147
|
+
if (fs.existsSync(dir)) {
|
|
148
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
149
|
+
removed.push(d.name);
|
|
150
|
+
}
|
|
151
|
+
} catch {
|
|
152
|
+
/* best-effort */
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return removed;
|
|
157
|
+
}
|
|
158
|
+
|
|
118
159
|
export { PI_MODELS_JSON, BARYON_CONFIG };
|
package/src/constants.js
CHANGED
|
@@ -49,6 +49,8 @@ export const BARYON_CONFIG = path.join(BARYON_DIR, "config.json");
|
|
|
49
49
|
/** pi's custom-provider/model registry. */
|
|
50
50
|
export const PI_AGENT_DIR = path.join(os.homedir(), ".pi", "agent");
|
|
51
51
|
export const PI_MODELS_JSON = path.join(PI_AGENT_DIR, "models.json");
|
|
52
|
+
/** pi's extension registry — a `{ packages: [<git url>, …] }` list loaded on startup. */
|
|
53
|
+
export const PI_SETTINGS_JSON = path.join(PI_AGENT_DIR, "settings.json");
|
|
52
54
|
|
|
53
55
|
/**
|
|
54
56
|
* Fallback model catalog used when /models discovery is unavailable
|
|
@@ -76,19 +78,36 @@ export const DEFAULT_MODELS = [
|
|
|
76
78
|
|
|
77
79
|
/**
|
|
78
80
|
* Extensions installed by default so `baryon` ships with sub-agents, a canvas,
|
|
79
|
-
* an interactive shell, and web access/
|
|
81
|
+
* an interactive shell, and web access/search out of the box. Installed via
|
|
80
82
|
* `pi install <src>` into ~/.pi/agent/settings.json (loaded on startup).
|
|
83
|
+
*
|
|
84
|
+
* Curated for conflict-free startup (verified in a clean container):
|
|
85
|
+
* - pi-search removed — it registers a `web_fetch` tool that collides with
|
|
86
|
+
* pi-web-fetch, hard-failing extension load on every run.
|
|
87
|
+
* - pi-web-fetch removed — requires `puppeteer` (chromium download), which is
|
|
88
|
+
* absent in fresh/CI environments, so the extension fails to load. pi-web-access
|
|
89
|
+
* already provides browsing + fetch_content + web_search without that dependency.
|
|
81
90
|
*/
|
|
82
91
|
export const DEFAULT_EXTENSIONS = [
|
|
83
92
|
{ name: "pi-subagents", src: "https://github.com/nicobailon/pi-subagents", note: "서브에이전트(작업 분해·위임·통합)" },
|
|
84
93
|
{ name: "pi-canvas", src: "https://github.com/jyaunches/pi-canvas", note: "캔버스" },
|
|
85
94
|
{ name: "pi-interactive-shell", src: "https://github.com/nicobailon/pi-interactive-shell", note: "인터랙티브 셸" },
|
|
86
|
-
{ name: "pi-web-access", src: "https://github.com/nicobailon/pi-web-access", note: "웹 액세스(
|
|
87
|
-
{ name: "pi-web-fetch", src: "https://github.com/georgebashi/pi-web-fetch", note: "웹 페치" },
|
|
88
|
-
{ name: "pi-search", src: "https://github.com/buddingnewinsights/pi-search", note: "웹 검색" },
|
|
95
|
+
{ name: "pi-web-access", src: "https://github.com/nicobailon/pi-web-access", note: "웹 액세스(브라우징·검색·페치)" },
|
|
89
96
|
{ name: "pi-parallel-web-search", src: "https://github.com/philipp-spiess/pi-parallel-web-search", note: "병렬 웹 검색" }
|
|
90
97
|
];
|
|
91
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Extensions previously shipped as defaults that BREAK startup and must be
|
|
101
|
+
* actively removed from existing installs (settings.json + cloned dir):
|
|
102
|
+
* - pi-web-fetch: `web_fetch` collides with pi-search; also needs puppeteer.
|
|
103
|
+
* - pi-search: `web_fetch` collision; superseded by pi-web-access.
|
|
104
|
+
* `baryon setup` self-heals an already-broken machine by pruning these.
|
|
105
|
+
*/
|
|
106
|
+
export const DEPRECATED_EXTENSIONS = [
|
|
107
|
+
{ name: "pi-web-fetch", src: "https://github.com/georgebashi/pi-web-fetch", owner: "georgebashi" },
|
|
108
|
+
{ name: "pi-search", src: "https://github.com/buddingnewinsights/pi-search", owner: "buddingnewinsights" }
|
|
109
|
+
];
|
|
110
|
+
|
|
92
111
|
export const HOMEPAGE = "https://cli.baryon.ai";
|
|
93
112
|
export const SUPPORT_EMAIL = "support@baryon.ai";
|
|
94
113
|
|