ainecto 0.16.9 → 0.16.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/README.md +2 -2
- package/dist/bin/ainecto.js +87 -24
- package/dist/bin/ainecto.js.map +1 -1
- package/dist/bin/mcp.js +12 -4
- package/dist/bin/mcp.js.map +1 -1
- package/dist/term/compute.js +2 -2
- package/dist/term/compute.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -253,7 +253,7 @@ ainecto term restore # after a reboot: start again
|
|
|
253
253
|
command stops with an error and removes nothing.
|
|
254
254
|
- Starting the background process waits up to 10 seconds per try for it to report ready, at most 3 tries.
|
|
255
255
|
- `wait` itself waits until `--timeout` (without it, until the pattern appears or the session ends).
|
|
256
|
-
- Platforms: macOS; Linux with glibc on Node.js 20.8.0 or newer; Windows
|
|
256
|
+
- Platforms: macOS; Linux with glibc on Node.js 20.8.0 or newer; Windows 11 on x64
|
|
257
257
|
and arm64 (the rest of the CLI runs on Node 18). It uses the optional dependency `node-pty`, which ships
|
|
258
258
|
prebuilt binaries — no compiler needed. If it could not be installed, `ainecto term` says so and the other
|
|
259
259
|
commands keep working.
|
|
@@ -277,7 +277,7 @@ This is the entry `setup --local` and `init --mcp --local` write — you normall
|
|
|
277
277
|
"mcpServers": {
|
|
278
278
|
"ainecto": {
|
|
279
279
|
"command": "npx",
|
|
280
|
-
"args": ["-y", "@ainecto/mcp@0.16.
|
|
280
|
+
"args": ["-y", "@ainecto/mcp@0.16.11"]
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
package/dist/bin/ainecto.js
CHANGED
|
@@ -5699,9 +5699,9 @@ function legacyRoleInput(flag, envVars = process.env) {
|
|
|
5699
5699
|
|
|
5700
5700
|
// src/core/version.ts
|
|
5701
5701
|
var UNBUNDLED_VERSION = "dev";
|
|
5702
|
-
var CLI_VERSION = true ? "0.16.
|
|
5702
|
+
var CLI_VERSION = true ? "0.16.11" : UNBUNDLED_VERSION;
|
|
5703
5703
|
var CLI_BUNDLED = true;
|
|
5704
|
-
var CLI_BUILD = true ? "
|
|
5704
|
+
var CLI_BUILD = true ? "7d9df43" : void 0;
|
|
5705
5705
|
function cliVersionLabel(version, build, release2) {
|
|
5706
5706
|
return release2 || build === void 0 ? version : `${version}-dev+${build}`;
|
|
5707
5707
|
}
|
|
@@ -6007,6 +6007,7 @@ function isRecord5(value) {
|
|
|
6007
6007
|
var CHANNEL_HEADER = "X-AiNecto-Channel";
|
|
6008
6008
|
var AGENT_HEADER = "X-AiNecto-Agent";
|
|
6009
6009
|
var AGENT_NAME_HEADER = "X-AiNecto-Agent-Name";
|
|
6010
|
+
var CONNECT_TURN_HEADER = "X-Ainecto-Connect-Turn";
|
|
6010
6011
|
var MAX_AGENT_NAME_LENGTH = 100;
|
|
6011
6012
|
var McpRpcError = class extends Error {
|
|
6012
6013
|
constructor(message2, code, details) {
|
|
@@ -6166,6 +6167,9 @@ var McpRpcClient = class {
|
|
|
6166
6167
|
if (this.options.agentName) {
|
|
6167
6168
|
headers[AGENT_NAME_HEADER.toLowerCase()] = this.options.agentName;
|
|
6168
6169
|
}
|
|
6170
|
+
if (this.options.connectTurn) {
|
|
6171
|
+
headers[CONNECT_TURN_HEADER.toLowerCase()] = "1";
|
|
6172
|
+
}
|
|
6169
6173
|
return this.fetchImpl(this.options.endpoint, {
|
|
6170
6174
|
method: "POST",
|
|
6171
6175
|
headers,
|
|
@@ -7713,7 +7717,8 @@ async function runConnector(options) {
|
|
|
7713
7717
|
legacyRole,
|
|
7714
7718
|
agentName: options.agentFlag ?? await readAgentName(options.cwd ?? process.cwd()),
|
|
7715
7719
|
// 에이전트의 MCP 연결 — 에이전트 «종류»는 브리지가 호스트의 initialize 에서 읽어 싣는다(«이름»은 위 agentName).
|
|
7716
|
-
channel: "mcp"
|
|
7720
|
+
channel: "mcp",
|
|
7721
|
+
...options.connectTurn ? { connectTurn: true } : {}
|
|
7717
7722
|
});
|
|
7718
7723
|
await runStdioBridge({
|
|
7719
7724
|
input: options.input,
|
|
@@ -7726,7 +7731,7 @@ async function runConnector(options) {
|
|
|
7726
7731
|
|
|
7727
7732
|
// src/adapters/mcp/args.ts
|
|
7728
7733
|
function parseMcpArgs(argv) {
|
|
7729
|
-
const result = { readOnly: false, help: false };
|
|
7734
|
+
const result = { readOnly: false, connectTurn: false, help: false };
|
|
7730
7735
|
for (let index = 0; index < argv.length; index += 1) {
|
|
7731
7736
|
const arg = argv[index];
|
|
7732
7737
|
if (!arg) {
|
|
@@ -7744,6 +7749,8 @@ function parseMcpArgs(argv) {
|
|
|
7744
7749
|
result.agent = name;
|
|
7745
7750
|
} else if (arg === "--read-only") {
|
|
7746
7751
|
result.readOnly = true;
|
|
7752
|
+
} else if (arg === "--connect-turn") {
|
|
7753
|
+
result.connectTurn = true;
|
|
7747
7754
|
} else if (arg === "--role") {
|
|
7748
7755
|
const value = argv[index + 1];
|
|
7749
7756
|
if (value !== void 0 && !value.startsWith("--")) {
|
|
@@ -10087,6 +10094,9 @@ function findExecutable(command, env, isFile) {
|
|
|
10087
10094
|
}
|
|
10088
10095
|
return void 0;
|
|
10089
10096
|
}
|
|
10097
|
+
function envNameKey(name, platform = process.platform) {
|
|
10098
|
+
return platform === "win32" ? name.toUpperCase() : name;
|
|
10099
|
+
}
|
|
10090
10100
|
function envValue(env, name) {
|
|
10091
10101
|
const key = Object.keys(env).find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
10092
10102
|
return key === void 0 ? void 0 : env[key];
|
|
@@ -14716,7 +14726,8 @@ var DetachKeyScanner = class {
|
|
|
14716
14726
|
function pickTarget(sessions, ref) {
|
|
14717
14727
|
const byInstance = sessions.find((session) => session.instance === ref);
|
|
14718
14728
|
if (byInstance) return toTarget(byInstance);
|
|
14719
|
-
const
|
|
14729
|
+
const byLabel = !isUuid(ref);
|
|
14730
|
+
const byName = sessions.filter((session) => session.name === ref || byLabel && session.label === ref);
|
|
14720
14731
|
if (byName.length === 1) return toTarget(byName[0]);
|
|
14721
14732
|
if (byName.length > 1) {
|
|
14722
14733
|
throw new TermError("TERM_AMBIGUOUS_NAME", `There are ${byName.length} sessions named "${ref}" \u2014 name one by its uuid (see term ls).`);
|
|
@@ -15108,10 +15119,28 @@ function print(input, data, human) {
|
|
|
15108
15119
|
function usage(text2) {
|
|
15109
15120
|
return new TermError("TERM_USAGE", `Usage: ainecto ${text2}`);
|
|
15110
15121
|
}
|
|
15111
|
-
|
|
15122
|
+
var PARENT_AGENT_ENV = /* @__PURE__ */ new Set([
|
|
15123
|
+
"CLAUDECODE",
|
|
15124
|
+
"CLAUDE_CODE_SESSION_ID",
|
|
15125
|
+
"CLAUDE_CODE_ENTRYPOINT",
|
|
15126
|
+
"CLAUDE_CODE_CHILD_SESSION",
|
|
15127
|
+
"CLAUDE_CODE_CHILD_NOTES_DIR",
|
|
15128
|
+
"CLAUDE_CODE_MESSAGING_SOCKET",
|
|
15129
|
+
"CLAUDE_CODE_MESSAGING_TOKEN",
|
|
15130
|
+
"CLAUDE_CODE_SESSION_ATTENDED",
|
|
15131
|
+
"CLAUDE_CODE_EXECPATH",
|
|
15132
|
+
"CLAUDE_PID",
|
|
15133
|
+
"CLAUDE_EFFORT",
|
|
15134
|
+
"CODEX_CI",
|
|
15135
|
+
"CODEX_SESSION_ID",
|
|
15136
|
+
"CODEX_THREAD_ID",
|
|
15137
|
+
"CODEX_TOOL_CALL_ID",
|
|
15138
|
+
"CODEX_VERSION"
|
|
15139
|
+
]);
|
|
15140
|
+
function stringEnv(source = process.env, platform) {
|
|
15112
15141
|
const env = {};
|
|
15113
|
-
for (const [key, value] of Object.entries(
|
|
15114
|
-
if (typeof value === "string") {
|
|
15142
|
+
for (const [key, value] of Object.entries(source)) {
|
|
15143
|
+
if (typeof value === "string" && !PARENT_AGENT_ENV.has(envNameKey(key, platform))) {
|
|
15115
15144
|
env[key] = value;
|
|
15116
15145
|
}
|
|
15117
15146
|
}
|
|
@@ -15307,7 +15336,8 @@ function ainectoBridge(nodePath, cliScript, endpoint, agentName, readOnly = fals
|
|
|
15307
15336
|
endpoint,
|
|
15308
15337
|
"mcp",
|
|
15309
15338
|
...agentName ? ["--agent", agentName] : [],
|
|
15310
|
-
...readOnly ? ["--read-only"] : []
|
|
15339
|
+
...readOnly ? ["--read-only"] : [],
|
|
15340
|
+
"--connect-turn"
|
|
15311
15341
|
] };
|
|
15312
15342
|
}
|
|
15313
15343
|
function agentEnv(env) {
|
|
@@ -18254,7 +18284,14 @@ var RemoteViewer = class {
|
|
|
18254
18284
|
let data;
|
|
18255
18285
|
try {
|
|
18256
18286
|
if (!this.client) throw new TermError("TERM_DAEMON_GONE", "The term daemon connection is being opened again.");
|
|
18257
|
-
data = await this.client.request({
|
|
18287
|
+
data = await this.client.request({
|
|
18288
|
+
op: "read",
|
|
18289
|
+
name,
|
|
18290
|
+
...this.instance ? { instance: this.instance } : {},
|
|
18291
|
+
scrollback: true,
|
|
18292
|
+
lines: FRAME_SCROLLBACK_LINES + rows,
|
|
18293
|
+
styles: true
|
|
18294
|
+
});
|
|
18258
18295
|
} catch (error) {
|
|
18259
18296
|
if (error instanceof TermError && error.code === "TERM_DAEMON_GONE" && !this.stopped) {
|
|
18260
18297
|
if (await this.reconnect()) continue;
|
|
@@ -19439,6 +19476,20 @@ var DaemonControl = class {
|
|
|
19439
19476
|
paths;
|
|
19440
19477
|
client;
|
|
19441
19478
|
async request(body) {
|
|
19479
|
+
for (let retries = 0; ; ) {
|
|
19480
|
+
const client = await this.connected();
|
|
19481
|
+
try {
|
|
19482
|
+
return await client.request(body);
|
|
19483
|
+
} catch (error) {
|
|
19484
|
+
if (!(error instanceof TermError && error.code === RETRY_CODE)) throw error;
|
|
19485
|
+
if (this.client === client) this.client = void 0;
|
|
19486
|
+
client.close();
|
|
19487
|
+
retries += 1;
|
|
19488
|
+
if (retries >= DAEMON_START_ATTEMPTS) throw error;
|
|
19489
|
+
}
|
|
19490
|
+
}
|
|
19491
|
+
}
|
|
19492
|
+
async connected() {
|
|
19442
19493
|
if (!this.client) {
|
|
19443
19494
|
const client = await openTermClient(this.paths, { start: false });
|
|
19444
19495
|
if (!client) throw new TermError("TERM_DAEMON_GONE", "No term daemon is running.");
|
|
@@ -19447,7 +19498,7 @@ var DaemonControl = class {
|
|
|
19447
19498
|
});
|
|
19448
19499
|
this.client = client;
|
|
19449
19500
|
}
|
|
19450
|
-
return
|
|
19501
|
+
return this.client;
|
|
19451
19502
|
}
|
|
19452
19503
|
close() {
|
|
19453
19504
|
this.client?.close();
|
|
@@ -20012,6 +20063,7 @@ async function executePair(deps, argv) {
|
|
|
20012
20063
|
}
|
|
20013
20064
|
async function pinBrowser(input) {
|
|
20014
20065
|
const { key, pcKey, browser } = input;
|
|
20066
|
+
let replaced;
|
|
20015
20067
|
await updatePcKeys(input.keysPath, (latest) => {
|
|
20016
20068
|
const stored = latest.accounts[key]?.pcKey;
|
|
20017
20069
|
if (stored && stored.d !== pcKey.d) {
|
|
@@ -20020,8 +20072,10 @@ async function pinBrowser(input) {
|
|
|
20020
20072
|
if (latest.accounts[key]?.pendingTurnOff?.removals.some((item) => item.keyId === browser.keyId)) {
|
|
20021
20073
|
throw new CliCommandError("PAIR_REMOVE_PENDING", `This browser's earlier removal has not finished. Nothing was saved \u2014 run \`ainecto pair --remove ${browser.keyId}\` first, then \`npx -y ainecto@latest\` again.`);
|
|
20022
20074
|
}
|
|
20075
|
+
replaced = latest.accounts[key]?.browsers.find((item) => item.keyId === browser.keyId);
|
|
20023
20076
|
return withBrowser(latest, key, pcKey, { ...browser, pairedAt: input.now.toISOString() });
|
|
20024
20077
|
});
|
|
20078
|
+
return replaced;
|
|
20025
20079
|
}
|
|
20026
20080
|
async function listBrowsers(deps) {
|
|
20027
20081
|
const browsers = (await loadPcKeys(deps.keysPath)).accounts[(await account(deps)).key]?.browsers ?? [];
|
|
@@ -20305,18 +20359,13 @@ async function registerBrowserOnStart(deps, account2) {
|
|
|
20305
20359
|
const settings = await loadPcSettings(deps.settingsPath, deps.hostName);
|
|
20306
20360
|
if (settings.accounts[account2.key]?.remoteTerminal !== true) return;
|
|
20307
20361
|
const stored = (await loadPcKeys(deps.keysPath)).accounts[account2.key];
|
|
20308
|
-
const registered = stored?.browsers.length ?? 0;
|
|
20309
20362
|
const note = (line) => {
|
|
20310
20363
|
deps.io.stderr.write(`${line}
|
|
20311
20364
|
`);
|
|
20312
20365
|
};
|
|
20313
20366
|
const noBrowser = "This PC can't open a browser here (for example over ssh). Run `npx -y ainecto@latest` in a terminal on this PC's own screen to register your browser.";
|
|
20314
20367
|
if (register.overSsh) {
|
|
20315
|
-
|
|
20316
|
-
return;
|
|
20317
|
-
}
|
|
20318
|
-
if (registered > 0) {
|
|
20319
|
-
note(`This PC trusts ${registered} browser${registered === 1 ? "" : "s"}. To use another browser, allow it from a registered browser.`);
|
|
20368
|
+
note(noBrowser);
|
|
20320
20369
|
return;
|
|
20321
20370
|
}
|
|
20322
20371
|
const userId = transcriptUserId(account2.userId);
|
|
@@ -20324,6 +20373,7 @@ async function registerBrowserOnStart(deps, account2) {
|
|
|
20324
20373
|
const interrupt = register.interrupt();
|
|
20325
20374
|
let outcome;
|
|
20326
20375
|
let writtenAt = "";
|
|
20376
|
+
let replaced;
|
|
20327
20377
|
try {
|
|
20328
20378
|
const tag = await registerTag((await registerKeys(secret)).account, userId);
|
|
20329
20379
|
const url = `${new URL(deps.endpoint).origin}${REGISTER_PATH}#${registerFragment({ pcId: settings.pcId, tag, secret })}`;
|
|
@@ -20344,7 +20394,9 @@ async function registerBrowserOnStart(deps, account2) {
|
|
|
20344
20394
|
pcKey,
|
|
20345
20395
|
transport: await register.transport(settings.pcId),
|
|
20346
20396
|
confirm: { kind: "secret", secret },
|
|
20347
|
-
pin: (browser2) =>
|
|
20397
|
+
pin: async (browser2) => {
|
|
20398
|
+
replaced = await pinBrowser({ keysPath: deps.keysPath, key: account2.key, pcKey, browser: browser2, now: pinnedAt });
|
|
20399
|
+
},
|
|
20348
20400
|
waitMs: register.waitMs,
|
|
20349
20401
|
cancel: interrupt.signal
|
|
20350
20402
|
});
|
|
@@ -20365,10 +20417,8 @@ async function registerBrowserOnStart(deps, account2) {
|
|
|
20365
20417
|
await updatePcKeys(deps.keysPath, (keys) => {
|
|
20366
20418
|
const current = keys.accounts[account2.key];
|
|
20367
20419
|
if (!current?.browsers.some((item) => item.keyId === browser.keyId && item.pairedAt === writtenAt)) return void 0;
|
|
20368
|
-
|
|
20369
|
-
|
|
20370
|
-
browsers: current.browsers.filter((item) => !(item.keyId === browser.keyId && item.pairedAt === writtenAt))
|
|
20371
|
-
} } };
|
|
20420
|
+
const kept = current.browsers.filter((item) => !(item.keyId === browser.keyId && item.pairedAt === writtenAt));
|
|
20421
|
+
return { accounts: { ...keys.accounts, [account2.key]: { ...current, browsers: replaced ? [...kept, replaced] : kept } } };
|
|
20372
20422
|
});
|
|
20373
20423
|
note(`The browser "${browser.name}" did not get the confirmation (${doneError}), so nothing was kept. ${REGISTER_AGAIN}`);
|
|
20374
20424
|
return;
|
|
@@ -20609,7 +20659,7 @@ async function stopPc(deps, pc) {
|
|
|
20609
20659
|
resolve4("ended");
|
|
20610
20660
|
}
|
|
20611
20661
|
});
|
|
20612
|
-
client.onClose(() => resolve4("
|
|
20662
|
+
client.onClose(() => resolve4("closed"));
|
|
20613
20663
|
});
|
|
20614
20664
|
try {
|
|
20615
20665
|
await client.request({ op: "watch", ...target });
|
|
@@ -20620,9 +20670,11 @@ async function stopPc(deps, pc) {
|
|
|
20620
20670
|
}
|
|
20621
20671
|
throw error;
|
|
20622
20672
|
}
|
|
20623
|
-
const
|
|
20673
|
+
const deadline = Date.now() + deps.stopDeadlineMs;
|
|
20674
|
+
const raced = await Promise.race([ended, new Promise((resolve4) => {
|
|
20624
20675
|
timer = setTimeout(() => resolve4("late"), deps.stopDeadlineMs);
|
|
20625
20676
|
})]);
|
|
20677
|
+
const outcome = raced === "closed" ? await goneBy(deps, target, deadline) : raced;
|
|
20626
20678
|
if (outcome === "ended") {
|
|
20627
20679
|
return `Disconnected this PC (session ${pc.session}).`;
|
|
20628
20680
|
}
|
|
@@ -20650,6 +20702,15 @@ async function listed2(deps, connect2 = { start: false }) {
|
|
|
20650
20702
|
const result = await termRequest(deps.paths, { op: "ls" }, connect2);
|
|
20651
20703
|
return listedSessions(result.daemon ? result.data : void 0);
|
|
20652
20704
|
}
|
|
20705
|
+
async function goneBy(deps, target, deadline) {
|
|
20706
|
+
for (; ; ) {
|
|
20707
|
+
const listedNow = await listedToTurnOff(deps);
|
|
20708
|
+
const still = listedNow.some((session) => session.name === target.name && (target.instance === void 0 || sessionInstance(session) === target.instance));
|
|
20709
|
+
if (!still) return "ended";
|
|
20710
|
+
if (Date.now() >= deadline) return "late";
|
|
20711
|
+
await new Promise((resolve4) => setTimeout(resolve4, STOP_CONFIRM_POLL_MS));
|
|
20712
|
+
}
|
|
20713
|
+
}
|
|
20653
20714
|
async function listedToTurnOff(deps) {
|
|
20654
20715
|
return await listed2(deps, { start: false, resetFails: true });
|
|
20655
20716
|
}
|
|
@@ -22245,6 +22306,7 @@ var CodexSession = class {
|
|
|
22245
22306
|
await this.rpc.request("initialize", codexInitializeParams(this.deps.clientVersion));
|
|
22246
22307
|
this.rpc.notify("initialized");
|
|
22247
22308
|
const read = await this.rpc.request("config/read", { cwd: this.deps.cwd }).catch((error) => {
|
|
22309
|
+
if (this.child.exit) throw toError(error);
|
|
22248
22310
|
throw new CodexConfigError(toError(error).message);
|
|
22249
22311
|
});
|
|
22250
22312
|
const off = codexOtherMcpServersOff(read.config);
|
|
@@ -22759,6 +22821,7 @@ async function runAinectoCli(argv, io) {
|
|
|
22759
22821
|
legacyRoleFlag: parsed.legacyRole,
|
|
22760
22822
|
agentFlag: bridgeArgs.agent,
|
|
22761
22823
|
readOnly: bridgeArgs.readOnly,
|
|
22824
|
+
connectTurn: bridgeArgs.connectTurn,
|
|
22762
22825
|
input: io.stdin,
|
|
22763
22826
|
output: io.stdout,
|
|
22764
22827
|
errorOutput: io.stderr
|