@ainecto/cli 0.16.0 → 0.16.2
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 +6 -3
- package/dist/bin/ainecto.js +672 -100
- package/dist/bin/ainecto.js.map +1 -1
- package/dist/bin/mcp.js +2 -2
- package/package.json +2 -2
package/dist/bin/ainecto.js
CHANGED
|
@@ -5699,8 +5699,8 @@ 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.
|
|
5703
|
-
var CLI_BUILD = true ? "
|
|
5702
|
+
var CLI_VERSION = true ? "0.16.2" : UNBUNDLED_VERSION;
|
|
5703
|
+
var CLI_BUILD = true ? "3033982" : void 0;
|
|
5704
5704
|
function cliVersionLabel(version, build, release2) {
|
|
5705
5705
|
return release2 || build === void 0 ? version : `${version}-dev+${build}`;
|
|
5706
5706
|
}
|
|
@@ -11072,6 +11072,18 @@ async function acquirePcBridgeLock(paths) {
|
|
|
11072
11072
|
abstractLockName: paths.abstractLockName.replace(/\.lock$/, "-pc-bridge.lock")
|
|
11073
11073
|
});
|
|
11074
11074
|
}
|
|
11075
|
+
async function waitForDaemonLockFree(paths, ms) {
|
|
11076
|
+
const until = Date.now() + ms;
|
|
11077
|
+
for (; ; ) {
|
|
11078
|
+
const lock = await acquireProcessLock(paths);
|
|
11079
|
+
if (lock) {
|
|
11080
|
+
lock.release();
|
|
11081
|
+
return true;
|
|
11082
|
+
}
|
|
11083
|
+
if (Date.now() >= until) return false;
|
|
11084
|
+
await new Promise((resolve4) => setTimeout(resolve4, 100));
|
|
11085
|
+
}
|
|
11086
|
+
}
|
|
11075
11087
|
async function acquireProcessLock(paths) {
|
|
11076
11088
|
assertTermRuntime();
|
|
11077
11089
|
const fileLock = FILE_LOCK[process.platform];
|
|
@@ -11734,14 +11746,6 @@ function readDaemonInfo(paths) {
|
|
|
11734
11746
|
function daemonPid(paths) {
|
|
11735
11747
|
return readDaemonInfo(paths)?.pid;
|
|
11736
11748
|
}
|
|
11737
|
-
async function waitForPidGone(pid, ms) {
|
|
11738
|
-
const until = Date.now() + ms;
|
|
11739
|
-
while (isAlive(pid)) {
|
|
11740
|
-
if (Date.now() >= until) return false;
|
|
11741
|
-
await new Promise((resolve4) => setTimeout(resolve4, 100));
|
|
11742
|
-
}
|
|
11743
|
-
return true;
|
|
11744
|
-
}
|
|
11745
11749
|
function notListening(paths) {
|
|
11746
11750
|
const pid = daemonPid(paths);
|
|
11747
11751
|
const holder = pid !== void 0 && isAlive(pid) ? `Daemon pid ${pid} holds the lock but is not listening on ${paths.socket} \u2014 it may be stopped or hung. ${stuckProcessHint(pid)}` : "No running daemon answered.";
|
|
@@ -13518,8 +13522,12 @@ function sleep(ms, signal) {
|
|
|
13518
13522
|
}
|
|
13519
13523
|
|
|
13520
13524
|
// src/core/agent/agents.ts
|
|
13521
|
-
var AGENT_IDS = ["claude-code", "codex"];
|
|
13522
|
-
var AGENT_MCP_CLIENT_NAMES = {
|
|
13525
|
+
var AGENT_IDS = ["claude-code", "codex", "antigravity"];
|
|
13526
|
+
var AGENT_MCP_CLIENT_NAMES = {
|
|
13527
|
+
"claude-code": "claude-code",
|
|
13528
|
+
codex: "codex-mcp-client",
|
|
13529
|
+
antigravity: "antigravity-client"
|
|
13530
|
+
};
|
|
13523
13531
|
var DEFAULT_AGENT = "claude-code";
|
|
13524
13532
|
function isAgentId(value) {
|
|
13525
13533
|
return typeof value === "string" && AGENT_IDS.includes(value);
|
|
@@ -13711,6 +13719,8 @@ function replyForOutcome(outcome, limits, agentName) {
|
|
|
13711
13719
|
case "exited":
|
|
13712
13720
|
return failed("AGENT_EXITED", `${agentName} \uAC00 \uB05D\uB0AC\uC5B4\uC694(code ${outcome.code ?? "-"}${outcome.signal ? `, ${outcome.signal}` : ""}).` + (outcome.stderrTail ? `
|
|
13713
13721
|
${outcome.stderrTail}` : ""));
|
|
13722
|
+
case "refused":
|
|
13723
|
+
return failed(outcome.errorCode, outcome.errorCode === "AGENT_PREVIOUS_RUNNING" ? `${agentName} \uC758 \uC55E \uC694\uCCAD \uD504\uB85C\uC138\uC2A4\uAC00 \uC544\uC9C1 \uB05D\uB098\uC9C0 \uC54A\uC544 \uC774\uBC88 \uC694\uCCAD\uC740 \uC2E4\uD589\uD558\uC9C0 \uC54A\uC558\uC5B4\uC694. \uC7A0\uC2DC \uB4A4 \uB2E4\uC2DC \uBCF4\uB0B4 \uC8FC\uC138\uC694(${outcome.reason}).` : `${agentName} \uC124\uC815\uC744 \uB2E4 \uD655\uC778\uD558\uC9C0 \uBABB\uD574 \uC774 PC \uC5D0\uC11C \uC2E4\uD589\uD558\uC9C0 \uC54A\uC558\uC5B4\uC694(${outcome.reason}).`);
|
|
13714
13724
|
case "result": {
|
|
13715
13725
|
const { result } = outcome;
|
|
13716
13726
|
if (result.isError) {
|
|
@@ -14212,7 +14222,7 @@ var TODO_NOTES = {
|
|
|
14212
14222
|
stopped: "Stopped."
|
|
14213
14223
|
};
|
|
14214
14224
|
var SERVE_CONNECTED_PREFIX = "Connected to AiNecto as ";
|
|
14215
|
-
var AGENT_MISSING_LINE = "Agent: no
|
|
14225
|
+
var AGENT_MISSING_LINE = "Agent: no supported agent CLI on this PC \u2014 install one, then `ainecto` again.";
|
|
14216
14226
|
var SERVE_RECONNECTED_LINE = "AiNecto lost this connection (it may have restarted); connected again.";
|
|
14217
14227
|
async function runAgentServe(deps) {
|
|
14218
14228
|
const folderName = deps.todos?.agentName;
|
|
@@ -14415,10 +14425,10 @@ async function runAgentServe(deps) {
|
|
|
14415
14425
|
await session.interrupt();
|
|
14416
14426
|
await session.close();
|
|
14417
14427
|
}
|
|
14418
|
-
if (outcome.kind
|
|
14428
|
+
if (outcome.kind === "timeout" || outcome.kind === "exited") {
|
|
14419
14429
|
if (live.get(adapter.id) === session) live.delete(adapter.id);
|
|
14420
14430
|
if (session.resumed) await deps.sessions.forget(offer.conversationUuid, adapter.id);
|
|
14421
|
-
} else if (session.sessionRef) {
|
|
14431
|
+
} else if (outcome.kind === "result" && session.sessionRef) {
|
|
14422
14432
|
await deps.sessions.set(offer.conversationUuid, adapter.id, session.sessionRef);
|
|
14423
14433
|
}
|
|
14424
14434
|
reply = stopping.has(offer.key) ? stoppedReply(outcome, limits) : replyForOutcome(outcome, limits, adapter.displayName);
|
|
@@ -14615,15 +14625,19 @@ function serverLimits(value) {
|
|
|
14615
14625
|
};
|
|
14616
14626
|
return { pollHoldSeconds: num("pollHoldSeconds"), textMaxCharacters: num("textMaxCharacters"), documentsMax: num("documentsMax") };
|
|
14617
14627
|
}
|
|
14618
|
-
async function openLink(deps,
|
|
14628
|
+
async function openLink(deps, allAgents) {
|
|
14619
14629
|
const base = { hostName: deps.hostName, cliVersion: deps.cliVersion };
|
|
14630
|
+
const agents = allAgents.filter((a) => !NEWER_AGENT_IDS.includes(a.id));
|
|
14631
|
+
const newer = agents.length < allAgents.length;
|
|
14620
14632
|
const named = agents.some((a) => a.name !== void 0);
|
|
14621
14633
|
const unnamed = agents.map(({ name: _name, ...rest }) => rest);
|
|
14622
14634
|
const features = pcFeatures(deps.todos !== void 0);
|
|
14623
14635
|
const older = features.filter((f) => f !== "todos");
|
|
14636
|
+
const build = deps.cliBuild ? { cliBuild: deps.cliBuild } : {};
|
|
14624
14637
|
const attempts = [
|
|
14625
|
-
...
|
|
14626
|
-
{ body: { ...base, agents, features }, ...
|
|
14638
|
+
...newer ? [{ body: { ...base, ...build, agents: allAgents, features } }] : [],
|
|
14639
|
+
...deps.cliBuild ? [{ body: { ...base, cliBuild: deps.cliBuild, agents, features }, ...newer ? { dropped: "agents.newer" } : {} }] : [],
|
|
14640
|
+
{ body: { ...base, agents, features }, ...deps.cliBuild ? { dropped: "cliBuild" } : newer ? { dropped: "agents.newer" } : {} },
|
|
14627
14641
|
...older.length < features.length ? [{ body: { ...base, agents, features: older }, dropped: "features.todos" }] : [],
|
|
14628
14642
|
...named ? [{ body: { ...base, agents: unnamed, features: older }, dropped: "agents.name" }] : [],
|
|
14629
14643
|
{ body: { ...base, agents: unnamed }, dropped: "features" }
|
|
@@ -14639,6 +14653,7 @@ async function openLink(deps, agents) {
|
|
|
14639
14653
|
}
|
|
14640
14654
|
}
|
|
14641
14655
|
}
|
|
14656
|
+
var NEWER_AGENT_IDS = ["antigravity"];
|
|
14642
14657
|
function folderKind(agents) {
|
|
14643
14658
|
return agents.find((a) => a.ready && a.id === DEFAULT_AGENT)?.id ?? agents.find((a) => a.ready)?.id;
|
|
14644
14659
|
}
|
|
@@ -16232,23 +16247,39 @@ var DeviceManager = class {
|
|
|
16232
16247
|
deps;
|
|
16233
16248
|
slot = new ApprovalSlot();
|
|
16234
16249
|
running;
|
|
16250
|
+
/** 진행 중에 온 새 요청 — 앞 작업이 끝나면 이어서 받는다(마지막 것 하나). */
|
|
16251
|
+
next;
|
|
16235
16252
|
quietUntil = 0;
|
|
16236
16253
|
/** keyId → 지운 시각(ms). 그보다 먼저 시작한 등록은 그 키를 쓰지 못한다(다시 요청하면 새 등록이라 쓸 수 있다). */
|
|
16237
16254
|
removedAt = /* @__PURE__ */ new Map();
|
|
16238
16255
|
now;
|
|
16239
16256
|
/** poll 의 pair-request — 받을 수 있으면 등록 작업을 백그라운드로 시작한다(기다리지 않는다). */
|
|
16240
16257
|
async onPairRequest(requestId) {
|
|
16241
|
-
const refuse = (reason) =>
|
|
16242
|
-
|
|
16243
|
-
|
|
16244
|
-
|
|
16258
|
+
const refuse = async (reason) => {
|
|
16259
|
+
this.deps.log({ event: "pc_device", step: "request", requestId, result: "refused", reason });
|
|
16260
|
+
await this.deps.relay(requestId).refuse(reason);
|
|
16261
|
+
};
|
|
16262
|
+
if (!this.deps.remoteOn()) return await refuse("remote-off");
|
|
16263
|
+
if (this.running) {
|
|
16264
|
+
this.deps.log({ event: "pc_device", step: "request", requestId, result: "replacing", reason: this.running.requestId });
|
|
16265
|
+
this.next = requestId;
|
|
16266
|
+
this.running.replaced = true;
|
|
16267
|
+
this.running.stop.abort();
|
|
16268
|
+
return;
|
|
16269
|
+
}
|
|
16270
|
+
if (this.now().getTime() < this.quietUntil) return await refuse("quiet");
|
|
16245
16271
|
const account2 = await this.account();
|
|
16246
|
-
if (!account2 || account2.browsers.length === 0) return refuse("no-trusted-browser");
|
|
16247
|
-
const
|
|
16248
|
-
this.running =
|
|
16272
|
+
if (!account2 || account2.browsers.length === 0) return await refuse("no-trusted-browser");
|
|
16273
|
+
const running = { requestId, stop: new AbortController(), replaced: false };
|
|
16274
|
+
this.running = running;
|
|
16249
16275
|
this.deps.log({ event: "pc_device", step: "request", requestId, result: "started" });
|
|
16250
|
-
void this.pair(requestId, account2.pcKey,
|
|
16251
|
-
if (this.running
|
|
16276
|
+
void this.pair(requestId, account2.pcKey, running).finally(() => {
|
|
16277
|
+
if (this.running === running) this.running = void 0;
|
|
16278
|
+
const next = this.next;
|
|
16279
|
+
if (next !== void 0 && this.running === void 0) {
|
|
16280
|
+
this.next = void 0;
|
|
16281
|
+
void this.onPairRequest(next);
|
|
16282
|
+
}
|
|
16252
16283
|
});
|
|
16253
16284
|
}
|
|
16254
16285
|
/** 다리 끝·원격 꺼짐·링크 다시 열기 — 진행 중 등록을 끝낸다(abort 를 보낸다). */
|
|
@@ -16299,7 +16330,8 @@ var DeviceManager = class {
|
|
|
16299
16330
|
}
|
|
16300
16331
|
}
|
|
16301
16332
|
}
|
|
16302
|
-
async pair(requestId, pcKey,
|
|
16333
|
+
async pair(requestId, pcKey, running) {
|
|
16334
|
+
const stop = running.stop;
|
|
16303
16335
|
let outcome;
|
|
16304
16336
|
let reason;
|
|
16305
16337
|
const startedAt = this.now().getTime();
|
|
@@ -16326,7 +16358,7 @@ var DeviceManager = class {
|
|
|
16326
16358
|
}
|
|
16327
16359
|
if (outcome?.kind === "paired" && outcome.doneError !== void 0) reason = outcome.doneError;
|
|
16328
16360
|
const result = outcome === void 0 ? "error" : outcome.kind === "paired" && outcome.doneError !== void 0 ? "done-failed" : outcome.kind;
|
|
16329
|
-
if (result !== "paired" && result !== "timeout") this.quietUntil = this.now().getTime() + NOTIFY_BATCH_MS;
|
|
16361
|
+
if (result !== "paired" && result !== "timeout" && !running.replaced) this.quietUntil = this.now().getTime() + NOTIFY_BATCH_MS;
|
|
16330
16362
|
this.deps.log({
|
|
16331
16363
|
event: "pc_device",
|
|
16332
16364
|
step: "finished",
|
|
@@ -17443,7 +17475,7 @@ function pcResultText(result) {
|
|
|
17443
17475
|
if (result.kind === "already") {
|
|
17444
17476
|
return `This PC is already connected to AiNecto (folder ${result.folder}, version ${result.version}). ${STOP} Log: ${result.log}`;
|
|
17445
17477
|
}
|
|
17446
|
-
const use = result.agentMissing ? "From AiNecto on the web you can open a terminal on this PC and run commands. No Claude Code or
|
|
17478
|
+
const use = result.agentMissing ? "From AiNecto on the web you can open a terminal on this PC and run commands. No Claude Code, Codex or Antigravity was found, so AiNecto agent work cannot run here yet \u2014 install one, then run `ainecto` again." : "From AiNecto on the web you can open a terminal on this PC and run commands, and your AiNecto agent can run work here (Claude Code, Codex or Antigravity).";
|
|
17447
17479
|
return `This PC is now connected to AiNecto. ${use} It keeps running after you close this window. ${STOP} Log: ${result.log}`;
|
|
17448
17480
|
}
|
|
17449
17481
|
function pcNotApprovedText(hostName, then) {
|
|
@@ -17492,7 +17524,7 @@ async function executePcStart(deps) {
|
|
|
17492
17524
|
}
|
|
17493
17525
|
note("");
|
|
17494
17526
|
note(`This connects this PC to AiNecto as ${status.account?.displayName ?? "your account"} (${deps.endpoint}).`);
|
|
17495
|
-
note(" \xB7 Your AiNecto agent will run work on this PC (Claude Code / Codex).");
|
|
17527
|
+
note(" \xB7 Your AiNecto agent will run work on this PC (Claude Code / Codex / Antigravity).");
|
|
17496
17528
|
note(" \xB7 From AiNecto on the web, you can open terminals on this PC and run commands in them.");
|
|
17497
17529
|
note(" \xB7 It keeps itself up to date \u2014 new AiNecto releases built and signed on AiNecto's GitHub are installed when this PC is idle.");
|
|
17498
17530
|
if (!yes(await promptLine(deps.io, "Connect this PC? [y/N]: "), false)) {
|
|
@@ -17538,8 +17570,8 @@ async function upgradeDaemon(deps, note) {
|
|
|
17538
17570
|
}
|
|
17539
17571
|
note("Updating the AiNecto terminal service on this PC\u2026");
|
|
17540
17572
|
await termRequest(deps.paths, { op: "kill-server" }, { start: false });
|
|
17541
|
-
if (!await
|
|
17542
|
-
throw new CliCommandError("PC_START_FAILED", `The old terminal service (pid ${info.pid}) did not stop.
|
|
17573
|
+
if (!await waitForDaemonLockFree(deps.paths, deps.stopDeadlineMs)) {
|
|
17574
|
+
throw new CliCommandError("PC_START_FAILED", `The old AiNecto terminal service (${info.version}, started as pid ${info.pid}) is still running and did not stop within ${Math.round(deps.stopDeadlineMs / 1e3)} s. End it \u2014 on Windows: Task Manager \u203A Details \u203A the node.exe whose command line has "term daemon"; on macOS/Linux: \`kill ${info.pid}\` if that pid is still the daemon \u2014 or restart this PC, then run \`npx -y ainecto@latest\` again.`);
|
|
17543
17575
|
}
|
|
17544
17576
|
}
|
|
17545
17577
|
async function withRegistration(deps, key, userId, code) {
|
|
@@ -17974,6 +18006,16 @@ function createPairRelay(input) {
|
|
|
17974
18006
|
await send({ type: "done", signature: b64u3(signature) }, signal);
|
|
17975
18007
|
finished = true;
|
|
17976
18008
|
},
|
|
18009
|
+
async refuse(reason) {
|
|
18010
|
+
try {
|
|
18011
|
+
const opened = await http.call("pair/open", { pcId: input.pcId, ...input.requestId ? { requestId: input.requestId } : {} });
|
|
18012
|
+
if (typeof opened.attemptId !== "string" || opened.attemptId === "") return;
|
|
18013
|
+
attemptId = opened.attemptId;
|
|
18014
|
+
finished = true;
|
|
18015
|
+
await http.call("pair/send", { attemptId, msg: { type: "abort", reason } });
|
|
18016
|
+
} catch {
|
|
18017
|
+
}
|
|
18018
|
+
},
|
|
17977
18019
|
async abort(reason) {
|
|
17978
18020
|
if (!attemptId || finished) return;
|
|
17979
18021
|
finished = true;
|
|
@@ -18219,7 +18261,7 @@ function swapArgsOf(argv) {
|
|
|
18219
18261
|
|
|
18220
18262
|
// src/adapters/cli/ainectoCli.ts
|
|
18221
18263
|
import { mkdtemp, rm as rm3 } from "fs/promises";
|
|
18222
|
-
import { join as
|
|
18264
|
+
import { join as join14 } from "path";
|
|
18223
18265
|
|
|
18224
18266
|
// src/adapters/cli/pcStatus.ts
|
|
18225
18267
|
import { readFile as readFile14 } from "fs/promises";
|
|
@@ -18233,6 +18275,7 @@ function agentPaths(home = homedir5()) {
|
|
|
18233
18275
|
return {
|
|
18234
18276
|
dir,
|
|
18235
18277
|
work: join10(dir, "work"),
|
|
18278
|
+
antigravity: join10(dir, "antigravity"),
|
|
18236
18279
|
sessions: join10(dir, "sessions.json"),
|
|
18237
18280
|
runs: join10(dir, "runs.json"),
|
|
18238
18281
|
log: join10(dir, "agent.log"),
|
|
@@ -18265,7 +18308,176 @@ async function pcStatus(status, endpoint) {
|
|
|
18265
18308
|
}
|
|
18266
18309
|
|
|
18267
18310
|
// src/adapters/cli/agentCommand.ts
|
|
18268
|
-
import {
|
|
18311
|
+
import { createHash as createHash8 } from "crypto";
|
|
18312
|
+
import { homedir as homedir6, hostname as hostname3 } from "os";
|
|
18313
|
+
import { join as join13 } from "path";
|
|
18314
|
+
|
|
18315
|
+
// src/core/agent/antigravity.ts
|
|
18316
|
+
import { mkdir as mkdir7, readFile as readFile16 } from "fs/promises";
|
|
18317
|
+
import { join as join12 } from "path";
|
|
18318
|
+
|
|
18319
|
+
// src/core/agent/antigravityArgs.ts
|
|
18320
|
+
var AGY = "agy";
|
|
18321
|
+
var VERIFIED_AGY_VERSION = "1.5.15";
|
|
18322
|
+
var ANTIGRAVITY_MCP_SERVER = "ainecto-pc";
|
|
18323
|
+
var AGY_CUSTOMIZATION_DIRS = [".agents", ".agent", "_agents", "_agent"];
|
|
18324
|
+
var BUILTIN_DENY = ["command(*)", "write_file(*)", "read_file(*)", "read_url(*)", "execute_url(*)"];
|
|
18325
|
+
function antigravityToolPreamble(tools) {
|
|
18326
|
+
const definitions = tools.map(({ name, description, inputSchema }) => ({ name, description, inputSchema }));
|
|
18327
|
+
return `[AiNecto tool definitions \u2014 MCP server "${ANTIGRAVITY_MCP_SERVER}" (call these with call_mcp_tool; the definitions are complete, do not look for definition files)]
|
|
18328
|
+
${JSON.stringify(definitions)}
|
|
18329
|
+
|
|
18330
|
+
`;
|
|
18331
|
+
}
|
|
18332
|
+
function antigravityMcpConfig(bridge) {
|
|
18333
|
+
return { mcpServers: { [ANTIGRAVITY_MCP_SERVER]: { command: bridge.command, args: bridge.args } } };
|
|
18334
|
+
}
|
|
18335
|
+
function antigravitySettings(denyServers) {
|
|
18336
|
+
return {
|
|
18337
|
+
toolPermission: "request-review",
|
|
18338
|
+
permissions: {
|
|
18339
|
+
allow: [`mcp(${ANTIGRAVITY_MCP_SERVER}/*)`],
|
|
18340
|
+
deny: [...BUILTIN_DENY, ...denyServers.map((name) => `mcp(${name}/*)`)]
|
|
18341
|
+
}
|
|
18342
|
+
};
|
|
18343
|
+
}
|
|
18344
|
+
function antigravityAgentArgs(input) {
|
|
18345
|
+
const args = [
|
|
18346
|
+
// ★`-p` 는 값을 받는다 — 비우지 않으면 다음 인자를 프롬프트로 먹는다(실측 1.5.14 끝 코드 2). 프롬프트는 stdin(stream-json) 한 줄이라 빈 글.
|
|
18347
|
+
"-p",
|
|
18348
|
+
"",
|
|
18349
|
+
"--input-format",
|
|
18350
|
+
"stream-json",
|
|
18351
|
+
"--output-format",
|
|
18352
|
+
"stream-json",
|
|
18353
|
+
"--json-schema",
|
|
18354
|
+
JSON.stringify(input.schema),
|
|
18355
|
+
"--settings",
|
|
18356
|
+
JSON.stringify(input.settings)
|
|
18357
|
+
];
|
|
18358
|
+
if (input.conversationId) {
|
|
18359
|
+
args.push("--conversation", input.conversationId);
|
|
18360
|
+
}
|
|
18361
|
+
return args;
|
|
18362
|
+
}
|
|
18363
|
+
|
|
18364
|
+
// src/core/agent/antigravityPolicy.ts
|
|
18365
|
+
import { existsSync as existsSync2 } from "fs";
|
|
18366
|
+
import { mkdir as mkdir6, readdir as readdir2, readFile as readFile15, rename as rename7, writeFile as writeFile8 } from "fs/promises";
|
|
18367
|
+
import { dirname as dirname8, join as join11, parse as parsePath } from "path";
|
|
18368
|
+
var SAFE_SERVER_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
18369
|
+
var Refuse = class extends Error {
|
|
18370
|
+
constructor(reason, path) {
|
|
18371
|
+
super(reason);
|
|
18372
|
+
this.reason = reason;
|
|
18373
|
+
this.path = path;
|
|
18374
|
+
}
|
|
18375
|
+
reason;
|
|
18376
|
+
path;
|
|
18377
|
+
};
|
|
18378
|
+
async function antigravityMcpPolicy(input) {
|
|
18379
|
+
try {
|
|
18380
|
+
const names = /* @__PURE__ */ new Set();
|
|
18381
|
+
const add = (found, path) => {
|
|
18382
|
+
for (const name of found) {
|
|
18383
|
+
if (!SAFE_SERVER_NAME.test(name)) throw new Refuse("server name the deny rule cannot carry", path);
|
|
18384
|
+
if (name === ANTIGRAVITY_MCP_SERVER) throw new Refuse(`another config also names ${ANTIGRAVITY_MCP_SERVER}`, path);
|
|
18385
|
+
names.add(name);
|
|
18386
|
+
}
|
|
18387
|
+
};
|
|
18388
|
+
for (const dir of selfAndAncestors(input.cwd)) {
|
|
18389
|
+
if (existsSync2(join11(dir, ".git"))) throw new Refuse("work folder is inside a git repository", join11(dir, ".git"));
|
|
18390
|
+
}
|
|
18391
|
+
await onlyEntry(input.cwd, ".agents");
|
|
18392
|
+
const ours = join11(input.cwd, ".agents");
|
|
18393
|
+
await onlyEntry(ours, "mcp_config.json");
|
|
18394
|
+
const ourNames = await serverNames(join11(ours, "mcp_config.json"));
|
|
18395
|
+
if (ourNames.length !== 1 || ourNames[0] !== ANTIGRAVITY_MCP_SERVER) {
|
|
18396
|
+
throw new Refuse("work folder config is not ours", join11(ours, "mcp_config.json"));
|
|
18397
|
+
}
|
|
18398
|
+
for (const dir of selfAndAncestors(dirname8(input.cwd))) {
|
|
18399
|
+
for (const folder of AGY_CUSTOMIZATION_DIRS) {
|
|
18400
|
+
const file = join11(dir, folder, "mcp_config.json");
|
|
18401
|
+
if (existsSync2(file)) add(await serverNames(file), file);
|
|
18402
|
+
}
|
|
18403
|
+
}
|
|
18404
|
+
const globalRoot = join11(input.home, ".gemini", "config");
|
|
18405
|
+
const globalPlugins = join11(globalRoot, "plugins.json");
|
|
18406
|
+
if (existsSync2(globalPlugins)) throw new Refuse("global plugins.json adds plugins that agy plugin list does not show", globalPlugins);
|
|
18407
|
+
const globalFile = join11(globalRoot, "mcp_config.json");
|
|
18408
|
+
if (existsSync2(globalFile)) add(await serverNames(globalFile), globalFile);
|
|
18409
|
+
const listed3 = await input.pluginList();
|
|
18410
|
+
if (!listed3.ok) throw new Refuse(`agy plugin list failed: ${listed3.detail}`);
|
|
18411
|
+
for (const plugin of pluginEntries(listed3.stdout)) {
|
|
18412
|
+
add(plugin.mcpServers, plugin.path);
|
|
18413
|
+
const file = join11(plugin.path, "mcp_config.json");
|
|
18414
|
+
if (existsSync2(file)) add(await serverNames(file), file);
|
|
18415
|
+
}
|
|
18416
|
+
return { ok: true, deny: [...names].sort() };
|
|
18417
|
+
} catch (error) {
|
|
18418
|
+
if (error instanceof Refuse) return { ok: false, reason: error.reason, ...error.path ? { path: error.path } : {} };
|
|
18419
|
+
return { ok: false, reason: `could not read the Antigravity settings: ${error instanceof Error ? error.message : String(error)}` };
|
|
18420
|
+
}
|
|
18421
|
+
}
|
|
18422
|
+
async function writeWorkspaceMcpConfig(cwd, config) {
|
|
18423
|
+
const target = join11(cwd, ".agents", "mcp_config.json");
|
|
18424
|
+
await mkdir6(dirname8(target), { recursive: true, mode: 448 });
|
|
18425
|
+
const temp = join11(dirname8(cwd), `.${parsePath(cwd).base}.mcp_config.${process.pid}.tmp`);
|
|
18426
|
+
await writeFile8(temp, `${JSON.stringify(config)}
|
|
18427
|
+
`, { mode: 384 });
|
|
18428
|
+
await rename7(temp, target);
|
|
18429
|
+
}
|
|
18430
|
+
function selfAndAncestors(start) {
|
|
18431
|
+
const out = [];
|
|
18432
|
+
let dir = start;
|
|
18433
|
+
for (; ; ) {
|
|
18434
|
+
out.push(dir);
|
|
18435
|
+
const parent = dirname8(dir);
|
|
18436
|
+
if (parent === dir) return out;
|
|
18437
|
+
dir = parent;
|
|
18438
|
+
}
|
|
18439
|
+
}
|
|
18440
|
+
async function onlyEntry(dir, expected) {
|
|
18441
|
+
const entries2 = await readdir2(dir);
|
|
18442
|
+
const others = entries2.filter((name) => name !== expected);
|
|
18443
|
+
if (others.length > 0 || !entries2.includes(expected)) {
|
|
18444
|
+
throw new Refuse("work folder holds something other than our config", join11(dir, others[0] ?? expected));
|
|
18445
|
+
}
|
|
18446
|
+
}
|
|
18447
|
+
async function serverNames(file) {
|
|
18448
|
+
const text2 = await readFile15(file, "utf8");
|
|
18449
|
+
if (text2.trim() === "") return [];
|
|
18450
|
+
let value;
|
|
18451
|
+
try {
|
|
18452
|
+
value = JSON.parse(text2);
|
|
18453
|
+
} catch {
|
|
18454
|
+
throw new Refuse("unreadable mcp_config.json", file);
|
|
18455
|
+
}
|
|
18456
|
+
if (!isObject2(value)) throw new Refuse("unknown mcp_config.json shape", file);
|
|
18457
|
+
if (value.mcpServers === void 0) return [];
|
|
18458
|
+
if (!isObject2(value.mcpServers)) throw new Refuse("unknown mcp_config.json shape", file);
|
|
18459
|
+
return Object.keys(value.mcpServers);
|
|
18460
|
+
}
|
|
18461
|
+
function pluginEntries(stdout) {
|
|
18462
|
+
let value;
|
|
18463
|
+
try {
|
|
18464
|
+
value = JSON.parse(stdout);
|
|
18465
|
+
} catch {
|
|
18466
|
+
throw new Refuse("unreadable agy plugin list");
|
|
18467
|
+
}
|
|
18468
|
+
if (!Array.isArray(value)) throw new Refuse("unknown agy plugin list shape");
|
|
18469
|
+
return value.map((item) => {
|
|
18470
|
+
if (!isObject2(item) || typeof item.path !== "string") throw new Refuse("unknown agy plugin list shape");
|
|
18471
|
+
const servers = item.mcpServers ?? [];
|
|
18472
|
+
if (!Array.isArray(servers) || !servers.every((name) => typeof name === "string")) {
|
|
18473
|
+
throw new Refuse("unknown agy plugin list shape", item.path);
|
|
18474
|
+
}
|
|
18475
|
+
return { path: item.path, mcpServers: servers };
|
|
18476
|
+
});
|
|
18477
|
+
}
|
|
18478
|
+
function isObject2(value) {
|
|
18479
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18480
|
+
}
|
|
18269
18481
|
|
|
18270
18482
|
// src/core/agent/child.ts
|
|
18271
18483
|
import { createInterface as createInterface3 } from "readline";
|
|
@@ -18277,6 +18489,7 @@ var AgentChild = class {
|
|
|
18277
18489
|
stderr = "";
|
|
18278
18490
|
exitInfo;
|
|
18279
18491
|
exited;
|
|
18492
|
+
outputDone;
|
|
18280
18493
|
onKilled;
|
|
18281
18494
|
constructor(spawnImpl, command, args, options, hooks) {
|
|
18282
18495
|
this.onKilled = hooks.killed;
|
|
@@ -18294,14 +18507,16 @@ var AgentChild = class {
|
|
|
18294
18507
|
};
|
|
18295
18508
|
this.child.on("exit", done);
|
|
18296
18509
|
this.child.on("error", (error) => {
|
|
18297
|
-
this.stderr
|
|
18298
|
-
${error.message}
|
|
18299
|
-
done(null, null);
|
|
18510
|
+
this.stderr = `${this.stderr}
|
|
18511
|
+
${error.message}`.slice(-STDERR_KEEP);
|
|
18512
|
+
if (this.child.pid === void 0) done(null, null);
|
|
18300
18513
|
});
|
|
18301
18514
|
});
|
|
18302
18515
|
this.child.stdin.on("error", () => {
|
|
18303
18516
|
});
|
|
18304
|
-
createInterface3({ input: this.child.stdout })
|
|
18517
|
+
const lines = createInterface3({ input: this.child.stdout });
|
|
18518
|
+
lines.on("line", hooks.line);
|
|
18519
|
+
this.outputDone = new Promise((resolve4) => lines.once("close", () => resolve4()));
|
|
18305
18520
|
}
|
|
18306
18521
|
get pid() {
|
|
18307
18522
|
return this.child.pid ?? -1;
|
|
@@ -18323,19 +18538,33 @@ ${error.message}`;
|
|
|
18323
18538
|
`);
|
|
18324
18539
|
return true;
|
|
18325
18540
|
}
|
|
18326
|
-
/** stdin
|
|
18327
|
-
|
|
18541
|
+
/** stdin 만 닫는다(입력 끝 알림) — 프로세스는 그대로 돈다. 한 차례에 프로세스 하나인 Agent(agy -p)가 쓴다. */
|
|
18542
|
+
endInput() {
|
|
18543
|
+
if (this.alive) this.child.stdin.end();
|
|
18544
|
+
}
|
|
18545
|
+
/** 기다리지 않고 바로 끈다(SIGTERM → B6 → SIGKILL · Windows 는 taskkill /T /F). 결과는 hooks.killed 에도. */
|
|
18546
|
+
async forceStop() {
|
|
18328
18547
|
if (!this.alive) return void 0;
|
|
18329
|
-
this.child.stdin.end();
|
|
18330
|
-
if (await this.waitExit(AGENT_STOP_WAIT_MS)) return void 0;
|
|
18331
18548
|
const first = await killTree(this.child, AGENT_STOP_WAIT_MS, "SIGTERM");
|
|
18332
18549
|
const result = first.directExited ? first : await killTree(this.child, AGENT_STOP_WAIT_MS, "SIGKILL");
|
|
18333
18550
|
this.onKilled?.(result);
|
|
18334
18551
|
return result;
|
|
18335
18552
|
}
|
|
18336
|
-
|
|
18553
|
+
/** stdin 을 닫아 스스로 끝나게 하고, 안 끝나면 강제로. 강제로 껐으면 그 결과(직계·트리)를 돌려주고 hooks.killed 에도 알린다. */
|
|
18554
|
+
async stop() {
|
|
18555
|
+
if (!this.alive) return void 0;
|
|
18556
|
+
this.child.stdin.end();
|
|
18557
|
+
if (await this.waitForExit(AGENT_STOP_WAIT_MS)) return void 0;
|
|
18558
|
+
return await this.forceStop();
|
|
18559
|
+
}
|
|
18560
|
+
/** {@code ms} 안에 프로세스가 끝나면 true. */
|
|
18561
|
+
async waitForExit(ms) {
|
|
18337
18562
|
return await withDeadline(this.exited.then(() => true), ms, false);
|
|
18338
18563
|
}
|
|
18564
|
+
/** stdout 이 다 읽혔으면(마지막 줄까지 hooks.line 으로 나갔으면) true — exit 이 마지막 줄보다 먼저 올 수 있다. */
|
|
18565
|
+
async waitForOutput(ms) {
|
|
18566
|
+
return await withDeadline(this.outputDone.then(() => true), ms, false);
|
|
18567
|
+
}
|
|
18339
18568
|
};
|
|
18340
18569
|
async function withDeadline(work, ms, fallback) {
|
|
18341
18570
|
let timer;
|
|
@@ -18413,42 +18642,6 @@ async function detectByVersion(spawnImpl, command, options) {
|
|
|
18413
18642
|
return { installed: true, version: run.stdout.trim().split("\n")[0]?.trim() };
|
|
18414
18643
|
}
|
|
18415
18644
|
|
|
18416
|
-
// src/core/agent/claudeArgs.ts
|
|
18417
|
-
function claudeMcpConfig(bridge) {
|
|
18418
|
-
return { mcpServers: { [AINECTO_MCP_SERVER]: { command: bridge.command, args: bridge.args } } };
|
|
18419
|
-
}
|
|
18420
|
-
function claudeAgentArgs(input) {
|
|
18421
|
-
const args = [
|
|
18422
|
-
"-p",
|
|
18423
|
-
"--input-format",
|
|
18424
|
-
"stream-json",
|
|
18425
|
-
"--output-format",
|
|
18426
|
-
"stream-json",
|
|
18427
|
-
"--verbose",
|
|
18428
|
-
"--json-schema",
|
|
18429
|
-
JSON.stringify(input.schema),
|
|
18430
|
-
"--tools",
|
|
18431
|
-
"",
|
|
18432
|
-
// 내장 도구(Bash·Read·Write·Edit·Agent·Skill·WebFetch…) 전부 끔
|
|
18433
|
-
"--strict-mcp-config",
|
|
18434
|
-
"--mcp-config",
|
|
18435
|
-
JSON.stringify(input.mcpConfig),
|
|
18436
|
-
"--allowedTools",
|
|
18437
|
-
`mcp__${AINECTO_MCP_SERVER}`,
|
|
18438
|
-
"--permission-mode",
|
|
18439
|
-
"dontAsk",
|
|
18440
|
-
// 허용 밖은 묻지 않고 바로 거절(헤드리스에서 묻기 = 2분 대기)
|
|
18441
|
-
"--setting-sources",
|
|
18442
|
-
""
|
|
18443
|
-
// 사용자·프로젝트 설정(플러그인·스킬·훅·권한) 끔
|
|
18444
|
-
];
|
|
18445
|
-
if (input.resumeSessionId) {
|
|
18446
|
-
args.push("--resume", input.resumeSessionId);
|
|
18447
|
-
}
|
|
18448
|
-
return args;
|
|
18449
|
-
}
|
|
18450
|
-
var AINECTO_TOOL_PREFIX = `mcp__${AINECTO_MCP_SERVER}__`;
|
|
18451
|
-
|
|
18452
18645
|
// src/core/agent/documents.ts
|
|
18453
18646
|
var DOCUMENT_LINE = /📄[^\n]*?\/app\/docs\/([0-9a-f]{32})(?![0-9a-f])/gu;
|
|
18454
18647
|
var HEX32 = /^[0-9a-f]{32}$/;
|
|
@@ -18550,6 +18743,369 @@ function appendUnique(target, items) {
|
|
|
18550
18743
|
}
|
|
18551
18744
|
}
|
|
18552
18745
|
|
|
18746
|
+
// src/core/agent/antigravity.ts
|
|
18747
|
+
function antigravityAdapter(deps) {
|
|
18748
|
+
const processes = new AgyProcesses();
|
|
18749
|
+
const tools = { names: new Set(deps.tools.map((tool) => tool.name)), preamble: antigravityToolPreamble(deps.tools) };
|
|
18750
|
+
return {
|
|
18751
|
+
id: "antigravity",
|
|
18752
|
+
displayName: "Antigravity",
|
|
18753
|
+
async detect() {
|
|
18754
|
+
const detected = await detectByVersion(deps.spawnImpl, AGY, { cwd: deps.home, env: deps.env, timeoutMs: AGENT_CALL_TIMEOUT_MS });
|
|
18755
|
+
if (detected.installed && detected.version !== VERIFIED_AGY_VERSION) {
|
|
18756
|
+
deps.log.write({ event: "agent_version_unverified", agent: "antigravity", version: detected.version ?? "-", verified: VERIFIED_AGY_VERSION });
|
|
18757
|
+
}
|
|
18758
|
+
return detected;
|
|
18759
|
+
},
|
|
18760
|
+
async authStatus() {
|
|
18761
|
+
const run = await runToEnd(deps.spawnImpl, AGY, ["models"], { cwd: deps.home, env: deps.env, timeoutMs: AGENT_CALL_TIMEOUT_MS });
|
|
18762
|
+
if (run.spawnError || run.timedOut) return { ready: false, detail: run.spawnError ?? "timed out" };
|
|
18763
|
+
return antigravityAuth(run.code, deps.env, await modelProvider(deps.home));
|
|
18764
|
+
},
|
|
18765
|
+
open: ({ conversationUuid, resumeRef, textMaxCharacters, documentsMax, agentName }) => new AntigravitySession(conversationUuid, resumeRef, agentName, deps.schema(textMaxCharacters, documentsMax), deps, processes, tools)
|
|
18766
|
+
};
|
|
18767
|
+
}
|
|
18768
|
+
function antigravityAuth(code, env, provider) {
|
|
18769
|
+
if (code !== 0) return { ready: false, detail: "sign in \u2014 run `agy` once" };
|
|
18770
|
+
if ((env.GEMINI_API_KEY ?? "") !== "" && provider === "gemini") return { ready: true, mode: "apiKey", method: "gemini-api-key" };
|
|
18771
|
+
if (env.AGY_ADC_AUTH === "true") return { ready: true, mode: "apiKey", method: "google-cloud-adc" };
|
|
18772
|
+
return { ready: true, mode: "subscription", method: "google-account" };
|
|
18773
|
+
}
|
|
18774
|
+
async function modelProvider(home) {
|
|
18775
|
+
try {
|
|
18776
|
+
const value = JSON.parse(await readFile16(join12(home, ".gemini", "antigravity-cli", "settings.json"), "utf8"));
|
|
18777
|
+
const provider = value?.modelProvider;
|
|
18778
|
+
return typeof provider === "string" ? provider : void 0;
|
|
18779
|
+
} catch {
|
|
18780
|
+
return void 0;
|
|
18781
|
+
}
|
|
18782
|
+
}
|
|
18783
|
+
var AgyProcesses = class {
|
|
18784
|
+
children = /* @__PURE__ */ new Set();
|
|
18785
|
+
stuck = /* @__PURE__ */ new Set();
|
|
18786
|
+
add(child) {
|
|
18787
|
+
this.children.add(child);
|
|
18788
|
+
}
|
|
18789
|
+
exited(child) {
|
|
18790
|
+
this.children.delete(child);
|
|
18791
|
+
this.stuck.delete(child);
|
|
18792
|
+
}
|
|
18793
|
+
/** 모두 끝났나 — 안 끝난 것은 B6 기다리고 강제로 끈다(이미 못 끈 것은 기다리지 않는다). 하나라도 살아 있으면 그 pid 들. */
|
|
18794
|
+
async settle() {
|
|
18795
|
+
for (const child of [...this.children]) {
|
|
18796
|
+
if (!child.alive || this.stuck.has(child)) continue;
|
|
18797
|
+
if (await child.waitForExit(AGENT_STOP_WAIT_MS)) continue;
|
|
18798
|
+
await child.forceStop();
|
|
18799
|
+
if (child.alive) this.stuck.add(child);
|
|
18800
|
+
}
|
|
18801
|
+
return [...this.children].filter((child) => child.alive).map((child) => child.pid);
|
|
18802
|
+
}
|
|
18803
|
+
/** close — 아직 못 끈 것으로 표시되지 않은 것만 끈다(못 끈 것은 settle 이 계속 막는다). */
|
|
18804
|
+
async stopAll() {
|
|
18805
|
+
await Promise.all([...this.children].filter((child) => !this.stuck.has(child)).map(async (child) => {
|
|
18806
|
+
await child.forceStop();
|
|
18807
|
+
if (child.alive) this.stuck.add(child);
|
|
18808
|
+
}));
|
|
18809
|
+
}
|
|
18810
|
+
};
|
|
18811
|
+
var AntigravitySession = class {
|
|
18812
|
+
constructor(conversationUuid, resumeRef, agentName, schema, deps, processes, tools) {
|
|
18813
|
+
this.conversationUuid = conversationUuid;
|
|
18814
|
+
this.agentName = agentName;
|
|
18815
|
+
this.schema = schema;
|
|
18816
|
+
this.deps = deps;
|
|
18817
|
+
this.processes = processes;
|
|
18818
|
+
this.tools = tools;
|
|
18819
|
+
this.resumed = resumeRef !== void 0;
|
|
18820
|
+
this.sessionRef = resumeRef;
|
|
18821
|
+
this.cwd = deps.workDir(agentName);
|
|
18822
|
+
}
|
|
18823
|
+
conversationUuid;
|
|
18824
|
+
agentName;
|
|
18825
|
+
schema;
|
|
18826
|
+
deps;
|
|
18827
|
+
processes;
|
|
18828
|
+
tools;
|
|
18829
|
+
agent = "antigravity";
|
|
18830
|
+
resumed;
|
|
18831
|
+
sessionRef;
|
|
18832
|
+
closed = false;
|
|
18833
|
+
generation = 0;
|
|
18834
|
+
lastPid = -1;
|
|
18835
|
+
turn;
|
|
18836
|
+
cwd;
|
|
18837
|
+
get pid() {
|
|
18838
|
+
return this.lastPid;
|
|
18839
|
+
}
|
|
18840
|
+
get alive() {
|
|
18841
|
+
return !this.closed;
|
|
18842
|
+
}
|
|
18843
|
+
async send(text2, timeoutMs) {
|
|
18844
|
+
if (this.closed) return { kind: "exited", code: null, signal: null, stderrTail: "session closed" };
|
|
18845
|
+
let resolve4;
|
|
18846
|
+
const outcome = new Promise((r) => {
|
|
18847
|
+
resolve4 = r;
|
|
18848
|
+
});
|
|
18849
|
+
const turn = {
|
|
18850
|
+
generation: ++this.generation,
|
|
18851
|
+
resolve: resolve4,
|
|
18852
|
+
facts: new TurnFactsCollector(),
|
|
18853
|
+
counted: /* @__PURE__ */ new Set(),
|
|
18854
|
+
foreign: [],
|
|
18855
|
+
interrupted: false,
|
|
18856
|
+
done: false
|
|
18857
|
+
};
|
|
18858
|
+
this.turn = turn;
|
|
18859
|
+
void this.run(turn, text2).catch((error) => this.finish(turn, {
|
|
18860
|
+
kind: "exited",
|
|
18861
|
+
code: null,
|
|
18862
|
+
signal: null,
|
|
18863
|
+
stderrTail: error instanceof Error ? error.message : String(error)
|
|
18864
|
+
}));
|
|
18865
|
+
try {
|
|
18866
|
+
return await withDeadline(outcome, timeoutMs, { kind: "timeout" });
|
|
18867
|
+
} finally {
|
|
18868
|
+
if (!turn.done) {
|
|
18869
|
+
turn.interrupted = true;
|
|
18870
|
+
turn.done = true;
|
|
18871
|
+
}
|
|
18872
|
+
if (this.turn === turn) this.turn = void 0;
|
|
18873
|
+
}
|
|
18874
|
+
}
|
|
18875
|
+
async interrupt() {
|
|
18876
|
+
const turn = this.turn;
|
|
18877
|
+
if (!turn || turn.done) return;
|
|
18878
|
+
turn.interrupted = true;
|
|
18879
|
+
if (turn.child?.alive) {
|
|
18880
|
+
await turn.child.forceStop();
|
|
18881
|
+
} else {
|
|
18882
|
+
this.finishInterrupted(turn);
|
|
18883
|
+
}
|
|
18884
|
+
}
|
|
18885
|
+
async close() {
|
|
18886
|
+
this.closed = true;
|
|
18887
|
+
const turn = this.turn;
|
|
18888
|
+
if (turn) turn.interrupted = true;
|
|
18889
|
+
await this.processes.stopAll();
|
|
18890
|
+
if (turn) this.finishInterrupted(turn);
|
|
18891
|
+
}
|
|
18892
|
+
/** 한 차례 — 앞 프로세스 정리 → 사전 점검 → 띄우기. await 마다 멈춤을 다시 본다. */
|
|
18893
|
+
async run(turn, text2) {
|
|
18894
|
+
const running = await this.processes.settle();
|
|
18895
|
+
if (running.length > 0) {
|
|
18896
|
+
this.deps.log.write({ event: "agent_previous_running", agent: this.agent, conversationUuid: this.conversationUuid, pids: running });
|
|
18897
|
+
this.finish(turn, { kind: "refused", errorCode: "AGENT_PREVIOUS_RUNNING", reason: `the previous Antigravity process did not stop (pid ${running.join(", ")})` });
|
|
18898
|
+
return;
|
|
18899
|
+
}
|
|
18900
|
+
if (this.stopped(turn)) return this.finishInterrupted(turn);
|
|
18901
|
+
let policy;
|
|
18902
|
+
try {
|
|
18903
|
+
await mkdir7(this.cwd, { recursive: true, mode: 448 });
|
|
18904
|
+
await writeWorkspaceMcpConfig(this.cwd, this.deps.mcpConfig(this.agentName));
|
|
18905
|
+
policy = await antigravityMcpPolicy({ cwd: this.cwd, home: this.deps.home, pluginList: () => this.pluginList() });
|
|
18906
|
+
} catch (error) {
|
|
18907
|
+
policy = { ok: false, reason: `could not prepare the work folder: ${error instanceof Error ? error.message : String(error)}` };
|
|
18908
|
+
}
|
|
18909
|
+
if (this.stopped(turn)) return this.finishInterrupted(turn);
|
|
18910
|
+
if (!policy.ok) {
|
|
18911
|
+
this.deps.log.write({
|
|
18912
|
+
event: "agent_policy_unverified",
|
|
18913
|
+
agent: this.agent,
|
|
18914
|
+
conversationUuid: this.conversationUuid,
|
|
18915
|
+
reason: policy.reason,
|
|
18916
|
+
...policy.path ? { path: policy.path } : {}
|
|
18917
|
+
});
|
|
18918
|
+
this.finish(turn, { kind: "refused", errorCode: "AGENT_POLICY_UNVERIFIED", reason: policy.reason });
|
|
18919
|
+
return;
|
|
18920
|
+
}
|
|
18921
|
+
const args = antigravityAgentArgs({ schema: this.schema, settings: antigravitySettings(policy.deny), conversationId: this.sessionRef });
|
|
18922
|
+
const child = new AgentChild(this.deps.spawnImpl, AGY, args, { cwd: this.cwd, env: this.deps.env }, {
|
|
18923
|
+
line: (line) => this.onLine(turn, child, line),
|
|
18924
|
+
exit: (exit) => this.onExit(turn, child, exit),
|
|
18925
|
+
killed: (result) => this.deps.log.write({ event: "process_kill", pid: child.pid, agent: this.agent, ...result })
|
|
18926
|
+
});
|
|
18927
|
+
this.processes.add(child);
|
|
18928
|
+
turn.child = child;
|
|
18929
|
+
this.lastPid = child.pid;
|
|
18930
|
+
this.deps.log.write({
|
|
18931
|
+
event: "process_start",
|
|
18932
|
+
pid: child.pid,
|
|
18933
|
+
agent: this.agent,
|
|
18934
|
+
conversationUuid: this.conversationUuid,
|
|
18935
|
+
resume: this.sessionRef !== void 0
|
|
18936
|
+
});
|
|
18937
|
+
child.writeLine({ event: "user", message: { content: this.tools.preamble + text2 } });
|
|
18938
|
+
child.endInput();
|
|
18939
|
+
}
|
|
18940
|
+
stopped(turn) {
|
|
18941
|
+
return turn.interrupted || turn.done || this.closed;
|
|
18942
|
+
}
|
|
18943
|
+
async pluginList() {
|
|
18944
|
+
const run = await runToEnd(
|
|
18945
|
+
this.deps.spawnImpl,
|
|
18946
|
+
AGY,
|
|
18947
|
+
["plugin", "list", "--json"],
|
|
18948
|
+
{ cwd: this.cwd, env: this.deps.env, timeoutMs: AGENT_CALL_TIMEOUT_MS }
|
|
18949
|
+
);
|
|
18950
|
+
if (run.spawnError || run.timedOut || run.code !== 0) {
|
|
18951
|
+
return { ok: false, detail: run.spawnError ?? (run.timedOut ? "timed out" : `exit ${run.code}`) };
|
|
18952
|
+
}
|
|
18953
|
+
return { ok: true, stdout: run.stdout };
|
|
18954
|
+
}
|
|
18955
|
+
/** 결과는 한 번만 — 그 뒤 줄·exit·멈춤은 이 차례를 바꾸지 않는다. */
|
|
18956
|
+
finish(turn, outcome) {
|
|
18957
|
+
if (turn.done) return;
|
|
18958
|
+
turn.done = true;
|
|
18959
|
+
if (this.turn === turn) this.turn = void 0;
|
|
18960
|
+
turn.resolve(outcome);
|
|
18961
|
+
}
|
|
18962
|
+
finishInterrupted(turn) {
|
|
18963
|
+
this.finish(turn, { kind: "result", facts: turn.facts.snapshot(), result: { isError: true, subtype: "interrupted" } });
|
|
18964
|
+
}
|
|
18965
|
+
/** 프로세스 종료 — 소유를 놓고(로그는 그 세대 pid), 결과가 아직이면 마지막 줄까지 읽힌 뒤에 정한다(exit 이 result 줄보다 먼저 올 수 있다). */
|
|
18966
|
+
onExit(turn, child, exit) {
|
|
18967
|
+
this.processes.exited(child);
|
|
18968
|
+
this.deps.log.write({
|
|
18969
|
+
event: "process_exit",
|
|
18970
|
+
pid: child.pid,
|
|
18971
|
+
agent: this.agent,
|
|
18972
|
+
conversationUuid: this.conversationUuid,
|
|
18973
|
+
code: exit.code,
|
|
18974
|
+
signal: exit.signal
|
|
18975
|
+
});
|
|
18976
|
+
void child.waitForOutput(AGENT_STOP_WAIT_MS).then(() => {
|
|
18977
|
+
if (turn.interrupted) this.finishInterrupted(turn);
|
|
18978
|
+
else this.finish(turn, { kind: "exited", ...exit });
|
|
18979
|
+
});
|
|
18980
|
+
}
|
|
18981
|
+
onLine(turn, child, line) {
|
|
18982
|
+
if (turn.done) return;
|
|
18983
|
+
let event;
|
|
18984
|
+
try {
|
|
18985
|
+
const value = JSON.parse(line);
|
|
18986
|
+
if (!isObject3(value)) throw new Error("not an object");
|
|
18987
|
+
event = value;
|
|
18988
|
+
} catch {
|
|
18989
|
+
this.deps.log.write({ event: "bad_line", pid: child.pid, agent: this.agent, length: line.length });
|
|
18990
|
+
return;
|
|
18991
|
+
}
|
|
18992
|
+
if (event.event === "init") {
|
|
18993
|
+
if (typeof event.conversation_id === "string") this.sessionRef = event.conversation_id;
|
|
18994
|
+
return;
|
|
18995
|
+
}
|
|
18996
|
+
if (event.event === "step_update" && isObject3(event.step_update)) {
|
|
18997
|
+
this.onStep(turn, event.step_update);
|
|
18998
|
+
return;
|
|
18999
|
+
}
|
|
19000
|
+
if (event.event === "result" && isObject3(event.result)) {
|
|
19001
|
+
this.onResult(turn, child, event.result);
|
|
19002
|
+
}
|
|
19003
|
+
}
|
|
19004
|
+
/** TurnFacts(r2 좁힘): tool · DONE · call_mcp_tool · 브리지 · 공개 도구 이름 · 오류 없는 글 결과 · 같은 단계 한 번. */
|
|
19005
|
+
onStep(turn, step) {
|
|
19006
|
+
if (step.step_type !== "tool" || step.state !== "DONE" || !isObject3(step.tool_info)) return;
|
|
19007
|
+
const tool = step.tool_info;
|
|
19008
|
+
if (tool.name !== "call_mcp_tool" || !isObject3(tool.parameters)) return;
|
|
19009
|
+
const server = typeof tool.parameters.ServerName === "string" ? tool.parameters.ServerName : "";
|
|
19010
|
+
const name = typeof tool.parameters.ToolName === "string" ? tool.parameters.ToolName : "";
|
|
19011
|
+
if (server !== ANTIGRAVITY_MCP_SERVER) {
|
|
19012
|
+
turn.foreign.push({ server, tool: name });
|
|
19013
|
+
return;
|
|
19014
|
+
}
|
|
19015
|
+
if (typeof step.step_index !== "number" || turn.counted.has(step.step_index)) return;
|
|
19016
|
+
if (tool.error !== void 0 || typeof tool.output !== "string" || !this.tools.names.has(name)) return;
|
|
19017
|
+
turn.counted.add(step.step_index);
|
|
19018
|
+
turn.facts.add(agyContentParts(tool.output), this.deps.writeTools.has(name));
|
|
19019
|
+
}
|
|
19020
|
+
onResult(turn, child, result) {
|
|
19021
|
+
if (typeof result.conversation_id === "string") this.sessionRef = result.conversation_id;
|
|
19022
|
+
const usage2 = isObject3(result.usage) ? result.usage : void 0;
|
|
19023
|
+
this.deps.log.write({
|
|
19024
|
+
event: "agent_usage",
|
|
19025
|
+
pid: child.pid,
|
|
19026
|
+
agent: this.agent,
|
|
19027
|
+
conversationUuid: this.conversationUuid,
|
|
19028
|
+
...typeof usage2?.input_tokens === "number" ? { inputTokens: usage2.input_tokens } : {},
|
|
19029
|
+
...typeof usage2?.output_tokens === "number" ? { outputTokens: usage2.output_tokens } : {}
|
|
19030
|
+
});
|
|
19031
|
+
if (turn.interrupted) return this.finishInterrupted(turn);
|
|
19032
|
+
const facts = turn.facts.snapshot();
|
|
19033
|
+
if (turn.foreign.length > 0) {
|
|
19034
|
+
for (const { server, tool } of turn.foreign) {
|
|
19035
|
+
this.deps.log.write({
|
|
19036
|
+
event: "agent_policy_violation",
|
|
19037
|
+
pid: child.pid,
|
|
19038
|
+
agent: this.agent,
|
|
19039
|
+
conversationUuid: this.conversationUuid,
|
|
19040
|
+
server,
|
|
19041
|
+
tool
|
|
19042
|
+
});
|
|
19043
|
+
}
|
|
19044
|
+
this.finish(turn, { kind: "result", facts, result: { isError: true, subtype: "policy_violation" } });
|
|
19045
|
+
return;
|
|
19046
|
+
}
|
|
19047
|
+
const status = typeof result.status === "string" ? result.status : void 0;
|
|
19048
|
+
this.finish(turn, {
|
|
19049
|
+
kind: "result",
|
|
19050
|
+
facts,
|
|
19051
|
+
result: {
|
|
19052
|
+
subtype: status,
|
|
19053
|
+
isError: status !== "SUCCESS",
|
|
19054
|
+
structuredOutput: result.structured_output,
|
|
19055
|
+
resultText: typeof result.response === "string" ? result.response : void 0,
|
|
19056
|
+
numTurns: typeof result.num_turns === "number" ? result.num_turns : void 0
|
|
19057
|
+
}
|
|
19058
|
+
});
|
|
19059
|
+
}
|
|
19060
|
+
};
|
|
19061
|
+
function agyContentParts(output) {
|
|
19062
|
+
try {
|
|
19063
|
+
JSON.parse(output);
|
|
19064
|
+
return [{ type: "text", text: output }];
|
|
19065
|
+
} catch {
|
|
19066
|
+
return output.split("\n").map((text2) => ({ type: "text", text: text2 }));
|
|
19067
|
+
}
|
|
19068
|
+
}
|
|
19069
|
+
function isObject3(value) {
|
|
19070
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
19071
|
+
}
|
|
19072
|
+
|
|
19073
|
+
// src/core/agent/claudeArgs.ts
|
|
19074
|
+
function claudeMcpConfig(bridge) {
|
|
19075
|
+
return { mcpServers: { [AINECTO_MCP_SERVER]: { command: bridge.command, args: bridge.args } } };
|
|
19076
|
+
}
|
|
19077
|
+
function claudeAgentArgs(input) {
|
|
19078
|
+
const args = [
|
|
19079
|
+
"-p",
|
|
19080
|
+
"--input-format",
|
|
19081
|
+
"stream-json",
|
|
19082
|
+
"--output-format",
|
|
19083
|
+
"stream-json",
|
|
19084
|
+
"--verbose",
|
|
19085
|
+
"--json-schema",
|
|
19086
|
+
JSON.stringify(input.schema),
|
|
19087
|
+
"--tools",
|
|
19088
|
+
"",
|
|
19089
|
+
// 내장 도구(Bash·Read·Write·Edit·Agent·Skill·WebFetch…) 전부 끔
|
|
19090
|
+
"--strict-mcp-config",
|
|
19091
|
+
"--mcp-config",
|
|
19092
|
+
JSON.stringify(input.mcpConfig),
|
|
19093
|
+
"--allowedTools",
|
|
19094
|
+
`mcp__${AINECTO_MCP_SERVER}`,
|
|
19095
|
+
"--permission-mode",
|
|
19096
|
+
"dontAsk",
|
|
19097
|
+
// 허용 밖은 묻지 않고 바로 거절(헤드리스에서 묻기 = 2분 대기)
|
|
19098
|
+
"--setting-sources",
|
|
19099
|
+
""
|
|
19100
|
+
// 사용자·프로젝트 설정(플러그인·스킬·훅·권한) 끔
|
|
19101
|
+
];
|
|
19102
|
+
if (input.resumeSessionId) {
|
|
19103
|
+
args.push("--resume", input.resumeSessionId);
|
|
19104
|
+
}
|
|
19105
|
+
return args;
|
|
19106
|
+
}
|
|
19107
|
+
var AINECTO_TOOL_PREFIX = `mcp__${AINECTO_MCP_SERVER}__`;
|
|
19108
|
+
|
|
18553
19109
|
// src/core/agent/claudeCode.ts
|
|
18554
19110
|
var CLAUDE = "claude";
|
|
18555
19111
|
function claudeCodeAdapter(deps) {
|
|
@@ -19095,7 +19651,7 @@ function toError(error) {
|
|
|
19095
19651
|
}
|
|
19096
19652
|
|
|
19097
19653
|
// src/core/agent/runs.ts
|
|
19098
|
-
import { readFile as
|
|
19654
|
+
import { readFile as readFile17, rename as rename8, writeFile as writeFile9 } from "fs/promises";
|
|
19099
19655
|
var AgentRunLog = class {
|
|
19100
19656
|
constructor(path, log) {
|
|
19101
19657
|
this.path = path;
|
|
@@ -19109,7 +19665,7 @@ var AgentRunLog = class {
|
|
|
19109
19665
|
let reason;
|
|
19110
19666
|
const runs = /* @__PURE__ */ new Map();
|
|
19111
19667
|
try {
|
|
19112
|
-
const parsed = JSON.parse(await
|
|
19668
|
+
const parsed = JSON.parse(await readFile17(this.path, "utf8"));
|
|
19113
19669
|
for (const value of Array.isArray(parsed.runs) ? parsed.runs : []) {
|
|
19114
19670
|
const e = value ?? {};
|
|
19115
19671
|
if (typeof e.cardUuid === "string" && typeof e.startedAt === "string") {
|
|
@@ -19147,9 +19703,9 @@ var AgentRunLog = class {
|
|
|
19147
19703
|
}
|
|
19148
19704
|
async save() {
|
|
19149
19705
|
const tmp = `${this.path}.tmp`;
|
|
19150
|
-
await
|
|
19706
|
+
await writeFile9(tmp, `${JSON.stringify({ version: 1, runs: [...this.runs.values()] }, null, 2)}
|
|
19151
19707
|
`, { mode: PRIVATE_FILE_MODE });
|
|
19152
|
-
await
|
|
19708
|
+
await rename8(tmp, this.path);
|
|
19153
19709
|
}
|
|
19154
19710
|
};
|
|
19155
19711
|
|
|
@@ -19210,7 +19766,7 @@ async function probe(log, agent, kind, work, summary2) {
|
|
|
19210
19766
|
}
|
|
19211
19767
|
|
|
19212
19768
|
// src/core/agent/sessions.ts
|
|
19213
|
-
import { readFile as
|
|
19769
|
+
import { readFile as readFile18, rename as rename9, writeFile as writeFile10 } from "fs/promises";
|
|
19214
19770
|
var AgentSessionMap = class {
|
|
19215
19771
|
constructor(path) {
|
|
19216
19772
|
this.path = path;
|
|
@@ -19219,7 +19775,7 @@ var AgentSessionMap = class {
|
|
|
19219
19775
|
map = emptyMap();
|
|
19220
19776
|
async load() {
|
|
19221
19777
|
try {
|
|
19222
|
-
const parsed = JSON.parse(await
|
|
19778
|
+
const parsed = JSON.parse(await readFile18(this.path, "utf8"));
|
|
19223
19779
|
const map = emptyMap();
|
|
19224
19780
|
map[DEFAULT_AGENT] = entries(parsed.conversations);
|
|
19225
19781
|
const byAgent = parsed.byAgent && typeof parsed.byAgent === "object" ? parsed.byAgent : {};
|
|
@@ -19246,13 +19802,13 @@ var AgentSessionMap = class {
|
|
|
19246
19802
|
async save() {
|
|
19247
19803
|
const byAgent = Object.fromEntries(AGENT_IDS.filter((id) => id !== DEFAULT_AGENT).map((id) => [id, this.map[id]]));
|
|
19248
19804
|
const tmp = `${this.path}.tmp`;
|
|
19249
|
-
await
|
|
19805
|
+
await writeFile10(
|
|
19250
19806
|
tmp,
|
|
19251
19807
|
`${JSON.stringify({ version: 2, conversations: this.map[DEFAULT_AGENT], byAgent }, null, 2)}
|
|
19252
19808
|
`,
|
|
19253
19809
|
{ mode: PRIVATE_FILE_MODE }
|
|
19254
19810
|
);
|
|
19255
|
-
await
|
|
19811
|
+
await rename9(tmp, this.path);
|
|
19256
19812
|
}
|
|
19257
19813
|
};
|
|
19258
19814
|
function emptyMap() {
|
|
@@ -19397,7 +19953,7 @@ var AGENT_HELP_LINES = [
|
|
|
19397
19953
|
function isPcRunCommand(domain, action) {
|
|
19398
19954
|
return domain === "pc" && action === "run";
|
|
19399
19955
|
}
|
|
19400
|
-
var BILLED_TO = { "claude-code": "Anthropic", codex: "OpenAI" };
|
|
19956
|
+
var BILLED_TO = { "claude-code": "Anthropic", codex: "OpenAI", antigravity: "Google" };
|
|
19401
19957
|
async function executeAgentServe(input) {
|
|
19402
19958
|
const paths = agentPaths();
|
|
19403
19959
|
await ensurePrivateDir(paths.dir);
|
|
@@ -19414,14 +19970,30 @@ async function executeAgentServe(input) {
|
|
|
19414
19970
|
},
|
|
19415
19971
|
log
|
|
19416
19972
|
});
|
|
19417
|
-
const
|
|
19973
|
+
const serverTools = await tools.list();
|
|
19974
|
+
const writeTools = writeToolNames(serverTools);
|
|
19418
19975
|
const cliScript = process.argv[1];
|
|
19419
19976
|
if (!cliScript) throw new Error("Cannot find the path of this CLI to start the AiNecto bridge for the agents.");
|
|
19420
19977
|
const bridge = (agentName) => ainectoBridge(process.execPath, cliScript, input.endpoint, agentName);
|
|
19421
19978
|
const shared = { spawnImpl: spawnAgent, cwd: paths.work, env: agentEnv(process.env), log, writeTools };
|
|
19422
19979
|
const all = [
|
|
19423
19980
|
claudeCodeAdapter({ ...shared, args: ({ textMaxCharacters, documentsMax, resumeSessionId, agentName }) => claudeAgentArgs({ schema: agentReplySchema(textMaxCharacters, documentsMax), mcpConfig: claudeMcpConfig(bridge(agentName)), resumeSessionId }) }),
|
|
19424
|
-
codexAdapter({ ...shared, appServerArgs: (agentName) => codexAppServerArgs(bridge(agentName), writeTools), clientVersion: CLI_VERSION })
|
|
19981
|
+
codexAdapter({ ...shared, appServerArgs: (agentName) => codexAppServerArgs(bridge(agentName), writeTools), clientVersion: CLI_VERSION }),
|
|
19982
|
+
antigravityAdapter({
|
|
19983
|
+
spawnImpl: spawnAgent,
|
|
19984
|
+
env: shared.env,
|
|
19985
|
+
home: homedir6(),
|
|
19986
|
+
log,
|
|
19987
|
+
writeTools,
|
|
19988
|
+
tools: serverTools,
|
|
19989
|
+
// 연결 이름마다 한 폴더 — 이름 글자를 폴더 이름에 쓰지 않는다(해시).
|
|
19990
|
+
workDir: (agentName) => join13(
|
|
19991
|
+
paths.antigravity,
|
|
19992
|
+
agentName ? `agent-${createHash8("sha256").update(agentName).digest("hex").slice(0, 16)}` : "chat"
|
|
19993
|
+
),
|
|
19994
|
+
mcpConfig: (agentName) => antigravityMcpConfig(bridge(agentName)),
|
|
19995
|
+
schema: agentReplySchema
|
|
19996
|
+
})
|
|
19425
19997
|
];
|
|
19426
19998
|
const checks = await checkAgents(all, log);
|
|
19427
19999
|
log.write({
|
|
@@ -19436,7 +20008,7 @@ async function executeAgentServe(input) {
|
|
|
19436
20008
|
const remote = await pcRemoteSetup({ endpoint: input.endpoint, auth: input.auth, account: () => readAccount(client()), io: input.io });
|
|
19437
20009
|
const plan = pcPlan({ agents: agents.length, remoteEnabled: remote.remoteEnabled });
|
|
19438
20010
|
if (plan === "nothing") {
|
|
19439
|
-
throw new Error("
|
|
20011
|
+
throw new Error("None of Claude Code (`claude`), Codex (`codex`) or Antigravity (`agy`) is on PATH, and terminals from the web are off on this PC. Install one and sign in, or allow terminals from the web with `ainecto remote on`, then run `ainecto` again.");
|
|
19440
20012
|
}
|
|
19441
20013
|
let agentBusy = () => false;
|
|
19442
20014
|
const upgrades = upgradeWatch({
|
|
@@ -19501,7 +20073,7 @@ async function executeAgentServe(input) {
|
|
|
19501
20073
|
}
|
|
19502
20074
|
|
|
19503
20075
|
// src/adapters/cli/ainectoCli.ts
|
|
19504
|
-
import { homedir as
|
|
20076
|
+
import { homedir as homedir7, hostname as hostname4, tmpdir } from "os";
|
|
19505
20077
|
async function runAinectoCli(argv, io) {
|
|
19506
20078
|
let parsed = { json: argv.includes("--json"), help: false, version: false, positionals: [] };
|
|
19507
20079
|
try {
|
|
@@ -19590,8 +20162,8 @@ async function runAinectoCli(argv, io) {
|
|
|
19590
20162
|
auth,
|
|
19591
20163
|
client: client2,
|
|
19592
20164
|
// ★외부 CLI 는 홈 폴더에서 돈다 — 지금 저장소의 local·project 범위 항목이 사용자 범위 판정에 끼지 않게.
|
|
19593
|
-
runner: systemCommandRunner({ cwd:
|
|
19594
|
-
home:
|
|
20165
|
+
runner: systemCommandRunner({ cwd: homedir7() }),
|
|
20166
|
+
home: homedir7(),
|
|
19595
20167
|
json: parsed.json,
|
|
19596
20168
|
io
|
|
19597
20169
|
});
|
|
@@ -19605,9 +20177,9 @@ async function runAinectoCli(argv, io) {
|
|
|
19605
20177
|
tokenStore,
|
|
19606
20178
|
auth,
|
|
19607
20179
|
client: client2,
|
|
19608
|
-
runner: systemCommandRunner({ cwd:
|
|
20180
|
+
runner: systemCommandRunner({ cwd: homedir7() }),
|
|
19609
20181
|
hereRunner: systemCommandRunner({ cwd: process.cwd() }),
|
|
19610
|
-
home:
|
|
20182
|
+
home: homedir7(),
|
|
19611
20183
|
cwd: process.cwd(),
|
|
19612
20184
|
envVars: process.env
|
|
19613
20185
|
};
|
|
@@ -19735,9 +20307,9 @@ async function runAinectoCli(argv, io) {
|
|
|
19735
20307
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
19736
20308
|
return await response.json();
|
|
19737
20309
|
},
|
|
19738
|
-
makeTempDir: () => mkdtemp(
|
|
20310
|
+
makeTempDir: () => mkdtemp(join14(tmpdir(), "ainecto-upgrade-")),
|
|
19739
20311
|
removeDir: (path) => rm3(path, { recursive: true, force: true }),
|
|
19740
|
-
home:
|
|
20312
|
+
home: homedir7(),
|
|
19741
20313
|
log: openAgentLog(swapPaths)
|
|
19742
20314
|
});
|
|
19743
20315
|
}
|
|
@@ -19961,7 +20533,7 @@ function helpText() {
|
|
|
19961
20533
|
" ainecto init --agent NAME name the agent working in this folder: writes .ainecto/agent.local (do not commit it) and puts the name in .mcp.json, .cursor/mcp.json, .agents/mcp_config.json and .codex/config.toml",
|
|
19962
20534
|
" ainecto init --undo",
|
|
19963
20535
|
"",
|
|
19964
|
-
"This PC (requests from AiNecto Chat and auto-run cards, answered by Claude Code or
|
|
20536
|
+
"This PC (requests from AiNecto Chat and auto-run cards, answered by Claude Code, Codex or Antigravity on this machine):",
|
|
19965
20537
|
...AGENT_HELP_LINES,
|
|
19966
20538
|
"",
|
|
19967
20539
|
"Terminal sessions on this machine (no tmux or cmux needed; macOS, Linux and Windows):",
|