@openma/cli 0.3.0-beta.5 → 0.3.0
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/dist/index.js +59 -20
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -127,6 +127,9 @@ import { dirname as dirname2 } from "node:path";
|
|
|
127
127
|
import { spawn } from "node:child_process";
|
|
128
128
|
function buildPlist(opts) {
|
|
129
129
|
const p = paths();
|
|
130
|
+
const nodeDir = dirname2(opts.nodePath);
|
|
131
|
+
const setupPath = process.env.PATH ?? "";
|
|
132
|
+
const envPath = opts.envPath ?? dedupPath(setupPath ? `${nodeDir}:${setupPath}` : nodeDir);
|
|
130
133
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
131
134
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
132
135
|
<plist version="1.0">
|
|
@@ -135,7 +138,9 @@ function buildPlist(opts) {
|
|
|
135
138
|
<string>${p.serviceLabel}</string>
|
|
136
139
|
<key>ProgramArguments</key>
|
|
137
140
|
<array>
|
|
138
|
-
<string>${opts.
|
|
141
|
+
<string>${opts.nodePath}</string>
|
|
142
|
+
<string>${opts.cliEntry}</string>
|
|
143
|
+
<string>bridge</string>
|
|
139
144
|
<string>daemon</string>
|
|
140
145
|
</array>
|
|
141
146
|
<key>RunAtLoad</key>
|
|
@@ -151,12 +156,23 @@ function buildPlist(opts) {
|
|
|
151
156
|
<key>EnvironmentVariables</key>
|
|
152
157
|
<dict>
|
|
153
158
|
<key>PATH</key>
|
|
154
|
-
<string
|
|
159
|
+
<string>${escapeXml(envPath)}</string>
|
|
155
160
|
</dict>
|
|
156
161
|
</dict>
|
|
157
162
|
</plist>
|
|
158
163
|
`;
|
|
159
164
|
}
|
|
165
|
+
function escapeXml(s) {
|
|
166
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
167
|
+
}
|
|
168
|
+
function dedupPath(p) {
|
|
169
|
+
const seen = /* @__PURE__ */ new Set();
|
|
170
|
+
return p.split(":").filter((part) => {
|
|
171
|
+
if (!part || seen.has(part)) return false;
|
|
172
|
+
seen.add(part);
|
|
173
|
+
return true;
|
|
174
|
+
}).join(":");
|
|
175
|
+
}
|
|
160
176
|
async function install(opts) {
|
|
161
177
|
if (currentPlatform() !== "darwin") {
|
|
162
178
|
throw new Error(
|
|
@@ -230,11 +246,11 @@ var init_registry = __esm({
|
|
|
230
246
|
"use strict";
|
|
231
247
|
KNOWN_ACP_AGENTS = [
|
|
232
248
|
{
|
|
233
|
-
id: "claude-
|
|
249
|
+
id: "claude-agent-acp",
|
|
234
250
|
label: "Claude Code",
|
|
235
|
-
spec: { command: "claude-
|
|
236
|
-
installHint: "npm install -g @
|
|
237
|
-
homepage: "https://github.com/
|
|
251
|
+
spec: { command: "claude-agent-acp" },
|
|
252
|
+
installHint: "npm install -g @agentclientprotocol/claude-agent-acp",
|
|
253
|
+
homepage: "https://github.com/agentclientprotocol/claude-agent-acp"
|
|
238
254
|
},
|
|
239
255
|
{
|
|
240
256
|
id: "codex-cli",
|
|
@@ -377,6 +393,13 @@ import { createServer } from "node:http";
|
|
|
377
393
|
import { spawn as spawn3 } from "node:child_process";
|
|
378
394
|
import { hostname } from "node:os";
|
|
379
395
|
import { randomBytes } from "node:crypto";
|
|
396
|
+
import { realpathSync } from "node:fs";
|
|
397
|
+
function launchdInstallOpts() {
|
|
398
|
+
return {
|
|
399
|
+
nodePath: process.execPath,
|
|
400
|
+
cliEntry: realpathSync(process.argv[1])
|
|
401
|
+
};
|
|
402
|
+
}
|
|
380
403
|
async function runSetup(opts) {
|
|
381
404
|
printBanner(`setup \u2014 register this machine with ${opts.serverUrl}`, PKG_VERSION);
|
|
382
405
|
if (!opts.force) {
|
|
@@ -385,7 +408,7 @@ async function runSetup(opts) {
|
|
|
385
408
|
log.ok(`existing credentials found ${c.dim(paths().credsFile)}`);
|
|
386
409
|
log.hint(`runtime ${existing.runtimeId.slice(0, 8)}\u2026 (use --force to re-register)`);
|
|
387
410
|
if (!opts.noService && currentPlatform() === "darwin") {
|
|
388
|
-
await install(
|
|
411
|
+
await install(launchdInstallOpts());
|
|
389
412
|
log.ok(`launchd plist refreshed ${c.dim(paths().serviceFile ?? "")}`);
|
|
390
413
|
log.ok(`daemon restarted ${c.dim("logs: " + paths().logFile)}`);
|
|
391
414
|
} else {
|
|
@@ -422,22 +445,22 @@ ${c.bold("Up to date.")}
|
|
|
422
445
|
});
|
|
423
446
|
log.ok(`credentials written ${c.dim(paths().credsFile)}`);
|
|
424
447
|
let agents = await detectAll();
|
|
425
|
-
const hasClaudeAcp = agents.some((a) => a.id === "claude-
|
|
448
|
+
const hasClaudeAcp = agents.some((a) => a.id === "claude-agent-acp");
|
|
426
449
|
if (!hasClaudeAcp && await isOnPath2("claude")) {
|
|
427
|
-
log.step("found `claude` on PATH \u2014 installing ACP wrapper @
|
|
428
|
-
const ok = await npmInstallGlobal("@
|
|
450
|
+
log.step("found `claude` on PATH \u2014 installing ACP wrapper @agentclientprotocol/claude-agent-acp");
|
|
451
|
+
const ok = await npmInstallGlobal("@agentclientprotocol/claude-agent-acp");
|
|
429
452
|
if (ok) {
|
|
430
|
-
log.ok("claude-
|
|
453
|
+
log.ok("claude-agent-acp installed");
|
|
431
454
|
agents = await detectAll();
|
|
432
455
|
} else {
|
|
433
|
-
log.warn("auto-install failed \u2014 install manually: npm i -g @
|
|
456
|
+
log.warn("auto-install failed \u2014 install manually: npm i -g @agentclientprotocol/claude-agent-acp");
|
|
434
457
|
}
|
|
435
458
|
}
|
|
436
459
|
if (agents.length > 0) {
|
|
437
460
|
log.ok(`agents detected ${c.dim(agents.map((a) => a.id).join(", "))}`);
|
|
438
461
|
} else {
|
|
439
462
|
log.warn("no ACP agents on PATH yet");
|
|
440
|
-
log.hint("install one, e.g. `npm i -g @
|
|
463
|
+
log.hint("install one, e.g. `npm i -g @agentclientprotocol/claude-agent-acp`");
|
|
441
464
|
}
|
|
442
465
|
if (opts.noService || currentPlatform() !== "darwin") {
|
|
443
466
|
process.stderr.write("\n");
|
|
@@ -445,7 +468,7 @@ ${c.bold("Up to date.")}
|
|
|
445
468
|
log.hint("run `oma bridge daemon` to start the bridge in the foreground");
|
|
446
469
|
return;
|
|
447
470
|
}
|
|
448
|
-
await install(
|
|
471
|
+
await install(launchdInstallOpts());
|
|
449
472
|
log.ok(`launchd plist installed ${c.dim(paths().serviceFile ?? "")}`);
|
|
450
473
|
log.ok(`daemon started ${c.dim("logs: " + paths().logFile)}`);
|
|
451
474
|
process.stderr.write("\n");
|
|
@@ -14545,7 +14568,7 @@ var init_session = __esm({
|
|
|
14545
14568
|
await this.#agent.loadSession?.({
|
|
14546
14569
|
sessionId: wantsResume,
|
|
14547
14570
|
cwd: this.options.agent.cwd ?? process.cwd(),
|
|
14548
|
-
mcpServers: []
|
|
14571
|
+
mcpServers: this.options.mcpServers ?? []
|
|
14549
14572
|
});
|
|
14550
14573
|
this.#sessionId = wantsResume;
|
|
14551
14574
|
return;
|
|
@@ -14555,7 +14578,7 @@ var init_session = __esm({
|
|
|
14555
14578
|
}
|
|
14556
14579
|
const newSession = await this.#agent.newSession({
|
|
14557
14580
|
cwd: this.options.agent.cwd ?? process.cwd(),
|
|
14558
|
-
mcpServers: []
|
|
14581
|
+
mcpServers: this.options.mcpServers ?? []
|
|
14559
14582
|
});
|
|
14560
14583
|
this.#sessionId = newSession.sessionId;
|
|
14561
14584
|
}
|
|
@@ -14890,18 +14913,22 @@ var init_session_manager = __esm({
|
|
|
14890
14913
|
}
|
|
14891
14914
|
const sessionCwd = await ensureSessionCwd(p.session_id);
|
|
14892
14915
|
let blocklist = [];
|
|
14916
|
+
let bundleMcpServers = [];
|
|
14917
|
+
let bundleEnv = [];
|
|
14893
14918
|
try {
|
|
14894
14919
|
const bundle = await this.#fetchBundle(p.session_id, p.agent_id);
|
|
14895
14920
|
if (bundle) {
|
|
14896
14921
|
await writeBundle(sessionCwd, bundle.files);
|
|
14897
14922
|
blocklist = bundle.local_skill_blocklist ?? [];
|
|
14923
|
+
bundleMcpServers = bundle.mcp_servers ?? [];
|
|
14924
|
+
bundleEnv = bundle.env ?? [];
|
|
14898
14925
|
}
|
|
14899
14926
|
} catch (e) {
|
|
14900
14927
|
process.stderr.write(` ! bundle fetch failed (non-fatal): ${e.message}
|
|
14901
14928
|
`);
|
|
14902
14929
|
}
|
|
14903
14930
|
const extraEnv = {};
|
|
14904
|
-
if (p.agent_id === "claude-
|
|
14931
|
+
if (p.agent_id === "claude-agent-acp") {
|
|
14905
14932
|
try {
|
|
14906
14933
|
const cfgDir = await setupClaudeConfigDir(sessionCwd, new Set(blocklist));
|
|
14907
14934
|
extraEnv.CLAUDE_CONFIG_DIR = cfgDir;
|
|
@@ -14912,16 +14939,28 @@ var init_session_manager = __esm({
|
|
|
14912
14939
|
);
|
|
14913
14940
|
}
|
|
14914
14941
|
}
|
|
14942
|
+
const envFromBundle = {};
|
|
14943
|
+
for (const v of bundleEnv) envFromBundle[v.name] = v.value;
|
|
14944
|
+
const mcpServersForAcp = bundleMcpServers.map((s) => ({
|
|
14945
|
+
type: s.type,
|
|
14946
|
+
name: s.name,
|
|
14947
|
+
url: s.url,
|
|
14948
|
+
headers: this.#env.apiKey ? [{ name: "Authorization", value: `Bearer ${this.#env.apiKey}` }] : []
|
|
14949
|
+
}));
|
|
14915
14950
|
process.stderr.write(
|
|
14916
|
-
` \u2192 SessionManager.start ${agent.spec.command} cwd=${sessionCwd}` + (extraEnv.CLAUDE_CONFIG_DIR ? ` cfg=${extraEnv.CLAUDE_CONFIG_DIR}` : "") + (blocklist.length ? ` blocklist=${blocklist.length}` : "") + "
|
|
14951
|
+
` \u2192 SessionManager.start ${agent.spec.command} cwd=${sessionCwd}` + (extraEnv.CLAUDE_CONFIG_DIR ? ` cfg=${extraEnv.CLAUDE_CONFIG_DIR}` : "") + (blocklist.length ? ` blocklist=${blocklist.length}` : "") + (mcpServersForAcp.length ? ` mcp=${mcpServersForAcp.length}` : "") + (bundleEnv.length ? ` env=${bundleEnv.length}` : "") + // Intentionally NOT logging env names or values — these come from
|
|
14952
|
+
// user-supplied session resources and may be sensitive even if not
|
|
14953
|
+
// formally encrypted. Only the count is observable.
|
|
14954
|
+
"\n"
|
|
14917
14955
|
);
|
|
14918
14956
|
try {
|
|
14919
14957
|
const session = await this.#runtime.start({
|
|
14920
14958
|
agent: {
|
|
14921
14959
|
...agent.spec,
|
|
14922
14960
|
cwd: sessionCwd,
|
|
14923
|
-
env: scrubAcpSpawnEnv({ ...agent.spec.env ?? {}, ...extraEnv })
|
|
14961
|
+
env: scrubAcpSpawnEnv({ ...agent.spec.env ?? {}, ...envFromBundle, ...extraEnv })
|
|
14924
14962
|
},
|
|
14963
|
+
mcpServers: mcpServersForAcp,
|
|
14925
14964
|
resumeAcpSessionId: p.resume?.acp_session_id
|
|
14926
14965
|
});
|
|
14927
14966
|
this.#sessions.set(p.session_id, {
|
|
@@ -15043,7 +15082,7 @@ import { join as join4 } from "node:path";
|
|
|
15043
15082
|
import { homedir as homedir3 } from "node:os";
|
|
15044
15083
|
async function detectLocalSkills() {
|
|
15045
15084
|
return {
|
|
15046
|
-
"claude-
|
|
15085
|
+
"claude-agent-acp": await detectClaudeCodeSkills()
|
|
15047
15086
|
};
|
|
15048
15087
|
}
|
|
15049
15088
|
async function detectClaudeCodeSkills() {
|