ainecto 0.14.0-next.7 → 0.14.0-next.8
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 -1
- package/dist/bin/ainecto.js +97 -22
- package/dist/bin/ainecto.js.map +1 -1
- package/dist/bin/mcp.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -226,7 +226,8 @@ ainecto term remote api # show it in AiNecto on the we
|
|
|
226
226
|
own after a reboot. A session that exits by itself is forgotten; `kill` and `kill-server` forget theirs.
|
|
227
227
|
- `remote` uses your AiNecto sign-in: open Terminal in AiNecto on the web to see the session as plain text
|
|
228
228
|
(no colors yet) and type into it. It runs until you press Ctrl+C, close it on the web, or the session
|
|
229
|
-
ends.
|
|
229
|
+
ends. If AiNecto restarts, it opens the remote terminal again on its own. One remote terminal per
|
|
230
|
+
account; its log is `~/.ainecto/term/remote.log`.
|
|
230
231
|
- Files are in `~/.ainecto/term/` (folder only you can read): the control socket, `sessions.json` (what
|
|
231
232
|
`restore` starts) and `daemon.log` (one line per request and one per answer; kept to 10 MB plus one older
|
|
232
233
|
file, `daemon.log.1`). Typed text, screens and environment values are not logged.
|
package/dist/bin/ainecto.js
CHANGED
|
@@ -5678,8 +5678,8 @@ function legacyRoleInput(flag, envVars = process.env) {
|
|
|
5678
5678
|
|
|
5679
5679
|
// src/core/version.ts
|
|
5680
5680
|
var UNBUNDLED_VERSION = "dev";
|
|
5681
|
-
var CLI_VERSION = true ? "0.14.0-next.
|
|
5682
|
-
var CLI_BUILD = true ? "
|
|
5681
|
+
var CLI_VERSION = true ? "0.14.0-next.8" : UNBUNDLED_VERSION;
|
|
5682
|
+
var CLI_BUILD = true ? "b8df977" : void 0;
|
|
5683
5683
|
function cliVersionLabel(version, build, release) {
|
|
5684
5684
|
return release || build === void 0 ? version : `${version}-dev+${build}`;
|
|
5685
5685
|
}
|
|
@@ -12342,7 +12342,7 @@ function createPcHttp(input) {
|
|
|
12342
12342
|
if (!response.ok) {
|
|
12343
12343
|
const code = typeof parsed?.code === "string" ? parsed.code : void 0;
|
|
12344
12344
|
outcome = { ok: false, status: response.status, code };
|
|
12345
|
-
throw fail(typeof parsed?.
|
|
12345
|
+
throw fail(typeof parsed?.message === "string" ? parsed.message : `HTTP ${response.status}`, op, response.status, code);
|
|
12346
12346
|
}
|
|
12347
12347
|
outcome = { ok: true, status: response.status, body: parsed ?? {} };
|
|
12348
12348
|
return parsed ?? {};
|
|
@@ -12403,6 +12403,7 @@ function retryWait(attempt, random) {
|
|
|
12403
12403
|
}
|
|
12404
12404
|
|
|
12405
12405
|
// src/core/term/remote.ts
|
|
12406
|
+
var REMOTE_NOT_FOUND = "REMOTE_NOT_FOUND";
|
|
12406
12407
|
function openRemoteLog(paths) {
|
|
12407
12408
|
const log = new DaemonLog(paths.remoteLog, paths.previousRemoteLog);
|
|
12408
12409
|
log.enableRotation();
|
|
@@ -12468,7 +12469,7 @@ async function runRemote(deps) {
|
|
|
12468
12469
|
}
|
|
12469
12470
|
});
|
|
12470
12471
|
client.onClose(() => end({ exitCode: 1, reason: "Lost the connection to the term daemon.", close: true }));
|
|
12471
|
-
let
|
|
12472
|
+
let opened = false;
|
|
12472
12473
|
try {
|
|
12473
12474
|
await client.request({ op: "watch", name });
|
|
12474
12475
|
const listed = listedSessions(await client.request({ op: "ls" })).find((session) => session.name === name);
|
|
@@ -12479,15 +12480,29 @@ async function runRemote(deps) {
|
|
|
12479
12480
|
if (ending) {
|
|
12480
12481
|
return { exitCode: ending.exitCode, reason: ending.reason };
|
|
12481
12482
|
}
|
|
12482
|
-
const
|
|
12483
|
-
|
|
12484
|
-
|
|
12485
|
-
|
|
12486
|
-
|
|
12487
|
-
|
|
12488
|
-
|
|
12489
|
-
|
|
12490
|
-
|
|
12483
|
+
const openLink2 = async (generation, signal) => {
|
|
12484
|
+
const opened2 = await deps.http.call(
|
|
12485
|
+
"open",
|
|
12486
|
+
{ session: name, hostName: deps.hostName, cliVersion: deps.cliVersion, cols, rows },
|
|
12487
|
+
signal ? { signal } : void 0
|
|
12488
|
+
);
|
|
12489
|
+
const limits = serverLimits(opened2.limits);
|
|
12490
|
+
if (typeof opened2.remoteId !== "string" || typeof opened2.remoteToken !== "string" || !limits) {
|
|
12491
|
+
throw new TermError("TERM_REMOTE_BAD_RESPONSE", "AiNecto answered open without remoteId, remoteToken or limits.");
|
|
12492
|
+
}
|
|
12493
|
+
deps.http.useSessionToken(opened2.remoteToken);
|
|
12494
|
+
return { remoteId: opened2.remoteId, generation, ...limits };
|
|
12495
|
+
};
|
|
12496
|
+
let current = await openLink2(1);
|
|
12497
|
+
opened = true;
|
|
12498
|
+
deps.log.write({
|
|
12499
|
+
event: "remote_opened",
|
|
12500
|
+
remoteId: current.remoteId,
|
|
12501
|
+
cols,
|
|
12502
|
+
rows,
|
|
12503
|
+
pollHoldSeconds: current.pollHoldSeconds,
|
|
12504
|
+
frameMaxBytes: current.frameMaxBytes
|
|
12505
|
+
});
|
|
12491
12506
|
deps.print(`Sharing ${name} (${cols}x${rows}) on AiNecto from ${deps.hostName}. Open the remote terminal in AiNecto to watch and type. Press Ctrl+C to stop.`);
|
|
12492
12507
|
const refused = (error) => {
|
|
12493
12508
|
if (error instanceof PcCallError && error.status === 404) {
|
|
@@ -12496,15 +12511,52 @@ async function runRemote(deps) {
|
|
|
12496
12511
|
const what = error instanceof PcCallError ? `${error.op}: ${error.status ?? "-"} ${error.code ?? ""} ${error.message}`.replace(/\s+/g, " ") : error instanceof Error ? error.message : String(error);
|
|
12497
12512
|
return { exitCode: 1, reason: `AiNecto refused the remote terminal (${what}).`, close: true };
|
|
12498
12513
|
};
|
|
12514
|
+
const forgotten = (error) => error instanceof PcCallError && error.status === 404 && error.code === REMOTE_NOT_FOUND;
|
|
12515
|
+
let gone = false;
|
|
12516
|
+
let reopens = 0;
|
|
12517
|
+
const reopen = async () => {
|
|
12518
|
+
const previous = current;
|
|
12519
|
+
while (!ending) {
|
|
12520
|
+
if (reopens > 0) {
|
|
12521
|
+
await sleep(retryWait(reopens - 1, Math.random()), stopper.signal);
|
|
12522
|
+
if (ending) return;
|
|
12523
|
+
}
|
|
12524
|
+
reopens += 1;
|
|
12525
|
+
try {
|
|
12526
|
+
current = await openLink2(previous.generation + 1, stopper.signal);
|
|
12527
|
+
} catch (error) {
|
|
12528
|
+
if (ending) return;
|
|
12529
|
+
if (error instanceof PcCallError && error.retryable) continue;
|
|
12530
|
+
end(refused(error));
|
|
12531
|
+
return;
|
|
12532
|
+
}
|
|
12533
|
+
gone = false;
|
|
12534
|
+
deps.log.write({ event: "remote_reopened", reason: REMOTE_NOT_FOUND, previousRemoteId: previous.remoteId, remoteId: current.remoteId });
|
|
12535
|
+
deps.print("AiNecto lost this remote terminal (it may have restarted); opened it again.");
|
|
12536
|
+
dirty = true;
|
|
12537
|
+
nudge();
|
|
12538
|
+
return;
|
|
12539
|
+
}
|
|
12540
|
+
};
|
|
12499
12541
|
const decoder = new StringDecoder("utf8");
|
|
12500
12542
|
const pollLoop = async () => {
|
|
12501
12543
|
let attempt = 0;
|
|
12502
12544
|
while (!ending) {
|
|
12503
12545
|
let answer;
|
|
12504
12546
|
try {
|
|
12505
|
-
answer = await deps.http.call(
|
|
12547
|
+
answer = await deps.http.call(
|
|
12548
|
+
"poll",
|
|
12549
|
+
{ remoteId: current.remoteId },
|
|
12550
|
+
{ holdMs: current.pollHoldSeconds * 1e3, signal: stopper.signal }
|
|
12551
|
+
);
|
|
12506
12552
|
} catch (error) {
|
|
12507
12553
|
if (ending) return;
|
|
12554
|
+
if (forgotten(error)) {
|
|
12555
|
+
gone = true;
|
|
12556
|
+
attempt = 0;
|
|
12557
|
+
await reopen();
|
|
12558
|
+
continue;
|
|
12559
|
+
}
|
|
12508
12560
|
if (!(error instanceof PcCallError) || !error.retryable) {
|
|
12509
12561
|
end(refused(error));
|
|
12510
12562
|
return;
|
|
@@ -12514,6 +12566,7 @@ async function runRemote(deps) {
|
|
|
12514
12566
|
continue;
|
|
12515
12567
|
}
|
|
12516
12568
|
attempt = 0;
|
|
12569
|
+
reopens = 0;
|
|
12517
12570
|
if (answer.state === "CLOSED") {
|
|
12518
12571
|
end({ exitCode: 0, reason: `AiNecto closed this remote terminal (${typeof answer.reason === "string" ? answer.reason : "CLOSED"}).`, close: false });
|
|
12519
12572
|
return;
|
|
@@ -12531,18 +12584,24 @@ async function runRemote(deps) {
|
|
|
12531
12584
|
}
|
|
12532
12585
|
};
|
|
12533
12586
|
const frameLoop = async () => {
|
|
12534
|
-
const budget = frameBudget(limits.frameMaxBytes, { remoteId: id, cols, rows });
|
|
12535
12587
|
let sentHash;
|
|
12588
|
+
let sentGeneration = 0;
|
|
12589
|
+
let parkedGeneration = 0;
|
|
12536
12590
|
let lastRead = 0;
|
|
12537
12591
|
let dropped = 0;
|
|
12538
12592
|
let attempt = 0;
|
|
12539
12593
|
while (!ending) {
|
|
12540
|
-
|
|
12594
|
+
const target = current;
|
|
12595
|
+
if (!dirty || parkedGeneration === target.generation) {
|
|
12541
12596
|
await new Promise((resolve4) => {
|
|
12542
12597
|
wakeFrame = resolve4;
|
|
12543
12598
|
});
|
|
12544
12599
|
continue;
|
|
12545
12600
|
}
|
|
12601
|
+
if (sentGeneration !== target.generation) {
|
|
12602
|
+
sentGeneration = target.generation;
|
|
12603
|
+
sentHash = void 0;
|
|
12604
|
+
}
|
|
12546
12605
|
const gap = lastRead + FRAME_MIN_INTERVAL_MS - Date.now();
|
|
12547
12606
|
if (gap > 0) {
|
|
12548
12607
|
await sleep(gap, stopper.signal);
|
|
@@ -12557,18 +12616,23 @@ async function runRemote(deps) {
|
|
|
12557
12616
|
daemonFailed("read", error);
|
|
12558
12617
|
return;
|
|
12559
12618
|
}
|
|
12560
|
-
const frame = screenFrame(lines,
|
|
12619
|
+
const frame = screenFrame(lines, frameBudget(target.frameMaxBytes, { remoteId: target.remoteId, cols, rows }));
|
|
12561
12620
|
if (frame.dropped !== dropped) {
|
|
12562
12621
|
dropped = frame.dropped;
|
|
12563
12622
|
deps.log.write({ event: "remote_frame_trimmed", dropped });
|
|
12564
12623
|
}
|
|
12565
12624
|
if (frame.hash === sentHash) continue;
|
|
12566
12625
|
try {
|
|
12567
|
-
await deps.http.call("frame", { remoteId:
|
|
12626
|
+
await deps.http.call("frame", { remoteId: target.remoteId, cols, rows, d: frame.d }, { signal: stopper.signal });
|
|
12568
12627
|
sentHash = frame.hash;
|
|
12569
12628
|
attempt = 0;
|
|
12570
12629
|
} catch (error) {
|
|
12571
12630
|
if (ending) return;
|
|
12631
|
+
if (forgotten(error)) {
|
|
12632
|
+
parkedGeneration = target.generation;
|
|
12633
|
+
dirty = true;
|
|
12634
|
+
continue;
|
|
12635
|
+
}
|
|
12572
12636
|
if (!(error instanceof PcCallError) || !error.retryable) {
|
|
12573
12637
|
end(refused(error));
|
|
12574
12638
|
return;
|
|
@@ -12581,16 +12645,16 @@ async function runRemote(deps) {
|
|
|
12581
12645
|
};
|
|
12582
12646
|
await Promise.all([pollLoop(), frameLoop()]);
|
|
12583
12647
|
const outcome = ending ?? { exitCode: 1, reason: "The remote terminal stopped.", close: true };
|
|
12584
|
-
if (outcome.close) {
|
|
12648
|
+
if (outcome.close && !gone) {
|
|
12585
12649
|
try {
|
|
12586
|
-
await deps.http.call("close", { remoteId:
|
|
12650
|
+
await deps.http.call("close", { remoteId: current.remoteId });
|
|
12587
12651
|
} catch (error) {
|
|
12588
12652
|
deps.print(`Could not tell AiNecto that sharing stopped: ${error instanceof Error ? error.message : String(error)}`);
|
|
12589
12653
|
}
|
|
12590
12654
|
}
|
|
12591
12655
|
return { exitCode: outcome.exitCode, reason: outcome.reason };
|
|
12592
12656
|
} finally {
|
|
12593
|
-
if (!
|
|
12657
|
+
if (!opened) stopper.abort();
|
|
12594
12658
|
deps.signal.removeEventListener("abort", onUserStop);
|
|
12595
12659
|
client.close();
|
|
12596
12660
|
}
|
|
@@ -14181,6 +14245,7 @@ function cardFactsOf(detail) {
|
|
|
14181
14245
|
status: card.status,
|
|
14182
14246
|
...typeof card.assignmentState === "string" ? { assignmentState: card.assignmentState } : {},
|
|
14183
14247
|
blocked: card.blocked === true,
|
|
14248
|
+
archived: card.archived === true,
|
|
14184
14249
|
...typeof d.description === "string" && d.description.trim() ? { description: d.description } : {},
|
|
14185
14250
|
criteria: (Array.isArray(d.criteria) ? d.criteria : []).flatMap((c) => {
|
|
14186
14251
|
const v = record(c);
|
|
@@ -14255,6 +14320,7 @@ async function runTodo(deps, todo) {
|
|
|
14255
14320
|
let conversationUuid;
|
|
14256
14321
|
let failure2;
|
|
14257
14322
|
let warning;
|
|
14323
|
+
let runDropped = false;
|
|
14258
14324
|
try {
|
|
14259
14325
|
const ends = async (value) => {
|
|
14260
14326
|
outcome = value;
|
|
@@ -14295,6 +14361,14 @@ async function runTodo(deps, todo) {
|
|
|
14295
14361
|
return await ends("review_requested");
|
|
14296
14362
|
} catch (error) {
|
|
14297
14363
|
failure2 = error instanceof Error ? error : new Error(String(error));
|
|
14364
|
+
if (todo.kind !== "DECISION_ANSWERED" && error instanceof AgentToolError && !error.retryable) {
|
|
14365
|
+
try {
|
|
14366
|
+
await deps.runs?.finished(todo.cardUuid);
|
|
14367
|
+
runDropped = true;
|
|
14368
|
+
} catch (saveError) {
|
|
14369
|
+
warning = `runs.json not updated: ${saveError instanceof Error ? saveError.message : String(saveError)}`;
|
|
14370
|
+
}
|
|
14371
|
+
}
|
|
14298
14372
|
throw error;
|
|
14299
14373
|
} finally {
|
|
14300
14374
|
deps.log.write({
|
|
@@ -14304,6 +14378,7 @@ async function runTodo(deps, todo) {
|
|
|
14304
14378
|
cardUuid: todo.cardUuid,
|
|
14305
14379
|
outcome: outcome ?? `error: ${failure2?.message ?? "unknown"}`,
|
|
14306
14380
|
...warning ? { warning } : {},
|
|
14381
|
+
...runDropped ? { runDropped } : {},
|
|
14307
14382
|
...failure2 instanceof AgentToolError ? { tool: failure2.tool, ...failure2.code ? { code: failure2.code } : {} } : {},
|
|
14308
14383
|
...workId ? { workId } : {},
|
|
14309
14384
|
...conversationUuid ? { conversationUuid } : {},
|
|
@@ -14317,7 +14392,7 @@ var OPENINGS = {
|
|
|
14317
14392
|
RESUME: (title) => `\uC774 PC \uAC00 \uB2E4\uC2DC \uCF1C\uC838 \xAB${title}\xBB \uC791\uC5C5\uC744 \uC774\uC5B4 \uAC00\uC694.`
|
|
14318
14393
|
};
|
|
14319
14394
|
function resumable(card, workId) {
|
|
14320
|
-
if (card.assignmentState !== "ACCEPTED" || card.blocked) return false;
|
|
14395
|
+
if (card.archived || card.assignmentState !== "ACCEPTED" || card.blocked) return false;
|
|
14321
14396
|
if (card.status !== "TODO" && card.status !== "IN_PROGRESS") return false;
|
|
14322
14397
|
return !workId || !card.workId || card.workId === workId;
|
|
14323
14398
|
}
|