ainecto 0.16.8 → 0.16.9

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 CHANGED
@@ -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.8"]
280
+ "args": ["-y", "@ainecto/mcp@0.16.9"]
281
281
  }
282
282
  }
283
283
  }
@@ -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.8" : UNBUNDLED_VERSION;
5702
+ var CLI_VERSION = true ? "0.16.9" : UNBUNDLED_VERSION;
5703
5703
  var CLI_BUNDLED = true;
5704
- var CLI_BUILD = true ? "343be3f" : void 0;
5704
+ var CLI_BUILD = true ? "80a4221" : void 0;
5705
5705
  function cliVersionLabel(version, build, release2) {
5706
5706
  return release2 || build === void 0 ? version : `${version}-dev+${build}`;
5707
5707
  }
@@ -8091,18 +8091,27 @@ async function confirmDestructiveCommand(options) {
8091
8091
  }
8092
8092
  }
8093
8093
  async function promptLine(io, message2, signal) {
8094
- if (signal?.aborted) return "";
8094
+ return (await promptAnswer(io, message2, signal)).line;
8095
+ }
8096
+ async function promptAnswer(io, message2, signal) {
8097
+ if (signal?.aborted) return { line: "", entered: false };
8095
8098
  io.stderr.write(message2);
8096
8099
  const rl = createInterface2({ input: io.stdin, terminal: false });
8097
8100
  const close = () => rl.close();
8101
+ const ended = [];
8102
+ const mark = () => {
8103
+ ended.push(io.stdin.readableEnded);
8104
+ };
8105
+ rl.on("line", mark);
8098
8106
  signal?.addEventListener("abort", close, { once: true });
8099
8107
  try {
8100
8108
  for await (const line of rl) {
8101
- return line;
8109
+ return { line, entered: ended[0] === false };
8102
8110
  }
8103
- return "";
8111
+ return { line: "", entered: false };
8104
8112
  } finally {
8105
8113
  signal?.removeEventListener("abort", close);
8114
+ rl.off("line", mark);
8106
8115
  rl.close();
8107
8116
  }
8108
8117
  }
@@ -11251,7 +11260,7 @@ var DaemonLog = class {
11251
11260
 
11252
11261
  // src/core/term/holderImage.ts
11253
11262
  import { createHash as createHash6, randomUUID } from "crypto";
11254
- import { existsSync, realpathSync } from "fs";
11263
+ import { existsSync, readdirSync, realpathSync } from "fs";
11255
11264
  import { chmod as chmod5, copyFile, mkdir as mkdir6, readdir as readdir2, readFile as readFile8, rename as rename6, rm as rm3, stat as stat6, writeFile as writeFile5 } from "fs/promises";
11256
11265
  import { createRequire } from "module";
11257
11266
  import { basename as basename3, dirname as dirname7, join as join7, relative as relative2 } from "path";
@@ -11367,7 +11376,7 @@ async function imageFiles(bundle, nodePty, nativeDirs = nodePtyNativeDirs()) {
11367
11376
  const files = [{ to: "ainecto.js", from: bundle }, { to: "package.json", text: `${JSON.stringify({ type: "module" })}
11368
11377
  ` }];
11369
11378
  if (nodePty) {
11370
- const native = nativeDirs.find((dir) => existsSync(join7(nodePty, dir)));
11379
+ const native = nativeDirs.find((dir) => hasNativeModule(join7(nodePty, dir)));
11371
11380
  files.push({ to: "node_modules/node-pty/package.json", from: join7(nodePty, "package.json") });
11372
11381
  for (const dir of ["lib", ...native ? [native] : []]) {
11373
11382
  for (const file of await filesUnder(join7(nodePty, dir))) {
@@ -11414,6 +11423,13 @@ async function ensureImage(root, files) {
11414
11423
  }
11415
11424
  return image;
11416
11425
  }
11426
+ function hasNativeModule(dir) {
11427
+ try {
11428
+ return readdirSync(dir, { withFileTypes: true }).some((entry) => entry.isFile() && entry.name.endsWith(".node"));
11429
+ } catch {
11430
+ return false;
11431
+ }
11432
+ }
11417
11433
  async function filesUnder(dir) {
11418
11434
  const found = [];
11419
11435
  for (const entry of await readdir2(dir, { withFileTypes: true })) {
@@ -11845,7 +11861,8 @@ function readModes(data) {
11845
11861
  const appCursor = "appCursor" in modes ? modes.appCursor : void 0;
11846
11862
  const bracketedPaste = "bracketedPaste" in modes ? modes.bracketedPaste : void 0;
11847
11863
  const mouse = "mouse" in modes ? modes.mouse : void 0;
11848
- return typeof altScreen === "boolean" && typeof appCursor === "boolean" && typeof bracketedPaste === "boolean" ? { altScreen, appCursor, bracketedPaste, ...typeof mouse === "boolean" ? { mouse } : {} } : void 0;
11864
+ const click = "click" in modes ? modes.click : void 0;
11865
+ return typeof altScreen === "boolean" && typeof appCursor === "boolean" && typeof bracketedPaste === "boolean" ? { altScreen, appCursor, bracketedPaste, ...typeof mouse === "boolean" ? { mouse } : {}, ...typeof click === "boolean" ? { click } : {} } : void 0;
11849
11866
  }
11850
11867
  function readStyles(data, lineCount) {
11851
11868
  if (!data || typeof data !== "object" || !("styles" in data) || !("runs" in data)) return void 0;
@@ -11854,7 +11871,9 @@ function readStyles(data, lineCount) {
11854
11871
  if (!Array.isArray(runs) || runs.length !== lineCount || !runs.every((row) => Array.isArray(row) && row.length % 3 === 0 && row.every((value) => Number.isInteger(value) && value >= 0))) return void 0;
11855
11872
  const cursor = "cursor" in data ? data.cursor : void 0;
11856
11873
  const at = cursor && typeof cursor === "object" && "row" in cursor && "col" in cursor && Number.isInteger(cursor.row) && Number.isInteger(cursor.col) ? { row: cursor.row, col: cursor.col } : void 0;
11857
- return { styles, runs, ...at ? { cursor: at } : {} };
11874
+ const view = "view" in data && typeof data.view === "string" ? data.view : void 0;
11875
+ const top = "top" in data && Number.isInteger(data.top) ? data.top : void 0;
11876
+ return { styles, runs, ...at ? { cursor: at } : {}, ...view !== void 0 && top !== void 0 ? { view, top } : {} };
11858
11877
  }
11859
11878
  function sessionInstance(data) {
11860
11879
  return data && typeof data === "object" && "instance" in data && typeof data.instance === "string" && data.instance !== "" ? data.instance : void 0;
@@ -12329,13 +12348,22 @@ function assertSessionName(name) {
12329
12348
 
12330
12349
  // src/core/term/computeSlot.ts
12331
12350
  var import_headless = __toESM(require_xterm_headless(), 1);
12332
- import { createHash as createHash7 } from "crypto";
12351
+ import { createHash as createHash8 } from "crypto";
12333
12352
  import { readFile as readFile12, rm as rm5, writeFile as writeFile8 } from "fs/promises";
12334
12353
  import { join as join8 } from "path";
12335
12354
  import { pathToFileURL } from "url";
12336
12355
  import { isDeepStrictEqual } from "util";
12337
12356
 
12338
12357
  // src/core/term/keys.ts
12358
+ var CLICK_NAME = /^click:([an]\d+x\d+@\d+):(-?\d+):(\d+):([0-9a-f]{64})$/;
12359
+ function clickTarget(name) {
12360
+ const match = CLICK_NAME.exec(name);
12361
+ if (!match) return void 0;
12362
+ const [, view, at, offsetText, lineHash2] = match;
12363
+ const row = Number(at);
12364
+ const offset = Number(offsetText);
12365
+ return view && lineHash2 && Number.isSafeInteger(row) && Number.isSafeInteger(offset) ? { view, row, offset, lineHash: lineHash2 } : void 0;
12366
+ }
12339
12367
  var PLAIN_KEYS = {
12340
12368
  enter: "\r",
12341
12369
  tab: " ",
@@ -12409,8 +12437,21 @@ function keyBytes(raw, context) {
12409
12437
  if (name === "wheel-up" || name === "wheel-down") {
12410
12438
  return wheelBytes(name === "wheel-up", context);
12411
12439
  }
12440
+ const target = clickTarget(name);
12441
+ if (target) {
12442
+ return clickBytes(target, context);
12443
+ }
12412
12444
  return comboBytes(name);
12413
12445
  }
12446
+ function clickBytes(target, context) {
12447
+ const { wheel, click } = context;
12448
+ if (!wheel || !click) return void 0;
12449
+ if (wheel.mouseTracking === "none") return "";
12450
+ const cell = click(target);
12451
+ if (!cell) return "";
12452
+ const at = `${cell.col + 1};${cell.row + 1}`;
12453
+ return wheel.mouseTracking === "x10" ? `\x1B[<0;${at}M` : `\x1B[<0;${at}M\x1B[<0;${at}m`;
12454
+ }
12414
12455
  function comboBytes(name) {
12415
12456
  const parts = name.split("-");
12416
12457
  const last = parts.pop() ?? "";
@@ -12448,6 +12489,7 @@ function pasteBytes(text2, bracketedPasteMode) {
12448
12489
  }
12449
12490
 
12450
12491
  // src/core/term/screen.ts
12492
+ import { createHash as createHash7 } from "crypto";
12451
12493
  function screenLines(buffer, rows, range) {
12452
12494
  return styledScreen(buffer, rows, range, false).lines;
12453
12495
  }
@@ -12492,14 +12534,50 @@ function styledScreen(buffer, rows, range, cursorVisible) {
12492
12534
  let kept = lines.length;
12493
12535
  while (kept > 0 && lines[kept - 1] === "") kept -= 1;
12494
12536
  const from = range.lines === void 0 ? 0 : Math.max(0, kept - range.lines);
12495
- const cursorRow = buffer.baseY + buffer.cursorY - start - from;
12537
+ const top = buffer.baseY - start - from;
12538
+ const cursorRow = top + buffer.cursorY;
12496
12539
  return {
12497
12540
  lines: lines.slice(from, kept),
12498
12541
  styles,
12499
12542
  runs: runs.slice(from, kept),
12500
- ...cursorVisible && cursorRow >= 0 ? { cursor: { row: cursorRow, col: cursorColumn(buffer, cell) } } : {}
12543
+ ...cursorVisible && cursorRow >= 0 ? { cursor: { row: cursorRow, col: cursorColumn(buffer, cell) } } : {},
12544
+ top
12501
12545
  };
12502
12546
  }
12547
+ function lineHash(text2) {
12548
+ return createHash7("sha256").update(text2, "utf8").digest("hex");
12549
+ }
12550
+ function screenView(buffer, cols, rows) {
12551
+ return `${buffer.type === "alternate" ? "a" : "n"}${cols}x${rows}@${buffer.baseY}`;
12552
+ }
12553
+ function clickCell(buffer, cols, rows, target) {
12554
+ const { row } = target;
12555
+ if (screenView(buffer, cols, rows) !== target.view || row < 0 || row >= rows) return void 0;
12556
+ const line = buffer.getLine(buffer.baseY + row);
12557
+ const text2 = line?.translateToString(true) ?? "";
12558
+ if (lineHash(text2) !== target.lineHash) return void 0;
12559
+ const col = textColumn(line, text2, target.offset, buffer.getNullCell());
12560
+ return col < cols ? { col, row } : void 0;
12561
+ }
12562
+ function textColumn(line, text2, target, cell) {
12563
+ let offset = 0;
12564
+ let column = 0;
12565
+ for (; line && column < line.length && offset < text2.length; column += 1) {
12566
+ line.getCell(column, cell);
12567
+ if (cell.getWidth() === 0) continue;
12568
+ const length = (cell.getChars() || " ").length;
12569
+ if (target < offset + length) return column;
12570
+ offset += length;
12571
+ }
12572
+ while (line && column < line.length && (line.getCell(column, cell), cell.getWidth() === 0)) column += 1;
12573
+ return column + (target - offset);
12574
+ }
12575
+ function mouseEncoding(terminal) {
12576
+ const core = Reflect.get(terminal, "_core");
12577
+ const service = core && typeof core === "object" ? Reflect.get(core, "coreMouseService") : void 0;
12578
+ const encoding = service && typeof service === "object" ? Reflect.get(service, "activeEncoding") : void 0;
12579
+ return typeof encoding === "string" ? encoding : void 0;
12580
+ }
12503
12581
  function cursorColumn(buffer, cell) {
12504
12582
  const line = buffer.getLine(buffer.baseY + buffer.cursorY);
12505
12583
  let offset = 0;
@@ -12585,18 +12663,23 @@ var XTERM_VERSION = true ? "6.0.0" : createRequire2(import.meta.url)("@xterm/hea
12585
12663
 
12586
12664
  // src/core/term/compute.ts
12587
12665
  var alternate = (view) => view.terminal.buffer.active.type === "alternate";
12666
+ var clickable = (view) => view.terminal.modes.mouseTrackingMode !== "none" && mouseEncoding(view.terminal) === "SGR";
12588
12667
  var X10_WHEEL_UP_80x24 = `\x1B[M${String.fromCharCode(96, 72, 44)}`;
12589
12668
  var compute = {
12590
12669
  version: CLI_VERSION_LABEL,
12591
12670
  xterm: XTERM_VERSION,
12592
12671
  needs: ["terminal", "flags.cursorVisible", "flags.sgrMouse"],
12593
12672
  read: (view, range) => screenLines(view.terminal.buffer.active, view.terminal.rows, range),
12594
- readStyled: (view, range) => styledScreen(view.terminal.buffer.active, view.terminal.rows, range, view.flags.cursorVisible),
12673
+ readStyled: (view, range) => ({
12674
+ ...styledScreen(view.terminal.buffer.active, view.terminal.rows, range, view.flags.cursorVisible),
12675
+ view: screenView(view.terminal.buffer.active, view.terminal.cols, view.terminal.rows)
12676
+ }),
12595
12677
  modes: (view) => ({
12596
12678
  altScreen: alternate(view),
12597
12679
  appCursor: view.terminal.modes.applicationCursorKeysMode,
12598
12680
  bracketedPaste: view.terminal.modes.bracketedPasteMode,
12599
- mouse: view.terminal.modes.mouseTrackingMode !== "none"
12681
+ mouse: view.terminal.modes.mouseTrackingMode !== "none",
12682
+ click: clickable(view)
12600
12683
  }),
12601
12684
  key: (view, name) => keyBytes(name, {
12602
12685
  applicationCursorKeys: view.terminal.modes.applicationCursorKeysMode,
@@ -12606,7 +12689,8 @@ var compute = {
12606
12689
  altScreen: alternate(view),
12607
12690
  cols: view.terminal.cols,
12608
12691
  rows: view.terminal.rows
12609
- }
12692
+ },
12693
+ click: (target) => clickable(view) ? clickCell(view.terminal.buffer.active, view.terminal.cols, view.terminal.rows, target) : void 0
12610
12694
  }),
12611
12695
  paste: (view, text2) => pasteBytes(text2, view.terminal.modes.bracketedPasteMode),
12612
12696
  reset: (view) => terminalResetSequence(view.terminal.modes, alternate(view)),
@@ -12619,10 +12703,17 @@ var compute = {
12619
12703
  read: { range: { scrollback: false }, lines: ["hello", "red dim"] },
12620
12704
  styled: {
12621
12705
  range: { scrollback: false },
12622
- screen: { lines: ["hello", "red dim"], styles: [{ fg: 1 }, { dim: true }], runs: [[], [0, 3, 0, 4, 7, 1]], cursor: { row: 1, col: 7 } }
12706
+ screen: {
12707
+ lines: ["hello", "red dim"],
12708
+ styles: [{ fg: 1 }, { dim: true }],
12709
+ runs: [[], [0, 3, 0, 4, 7, 1]],
12710
+ cursor: { row: 1, col: 7 },
12711
+ top: 0,
12712
+ view: "n80x24@0"
12713
+ }
12623
12714
  },
12624
- modes: { altScreen: false, appCursor: false, bracketedPaste: false, mouse: false },
12625
- keys: { enter: "\r", "ctrl-c": "", up: "\x1B[A", "wheel-up": "", "no-such-key": null },
12715
+ modes: { altScreen: false, appCursor: false, bracketedPaste: false, mouse: false, click: false },
12716
+ keys: { enter: "\r", "ctrl-c": "", up: "\x1B[A", "wheel-up": "", [`click:n80x24@0:1:0:${lineHash("red dim")}`]: "", "no-such-key": null },
12626
12717
  paste: { text: "a\nb", bytes: "a\nb" },
12627
12718
  reset: "\x1B[0m\x1B[?25h"
12628
12719
  },
@@ -12631,8 +12722,8 @@ var compute = {
12631
12722
  cols: 80,
12632
12723
  rows: 24,
12633
12724
  output: "\x1B[?1049h\x1B[?1h\x1B[?2004h\x1B[?25l",
12634
- styled: { range: { scrollback: false }, screen: { lines: [], styles: [], runs: [] } },
12635
- modes: { altScreen: true, appCursor: true, bracketedPaste: true, mouse: false },
12725
+ styled: { range: { scrollback: false }, screen: { lines: [], styles: [], runs: [], top: 0, view: "a80x24@0" } },
12726
+ modes: { altScreen: true, appCursor: true, bracketedPaste: true, mouse: false, click: false },
12636
12727
  keys: { up: "\x1BOA", "wheel-down": "\x1BOB" },
12637
12728
  paste: { text: "x", bytes: "\x1B[200~x\x1B[201~" },
12638
12729
  reset: "\x1B[0m\x1B[?2004l\x1B[?1l\x1B[?1049l\x1B[?25h"
@@ -12642,15 +12733,38 @@ var compute = {
12642
12733
  cols: 80,
12643
12734
  rows: 24,
12644
12735
  output: "\x1B[?1000h\x1B[?1016h",
12645
- modes: { altScreen: false, appCursor: false, bracketedPaste: false, mouse: true },
12646
- keys: { "wheel-up": X10_WHEEL_UP_80x24 }
12736
+ modes: { altScreen: false, appCursor: false, bracketedPaste: false, mouse: true, click: false },
12737
+ keys: { "wheel-up": X10_WHEEL_UP_80x24, [`click:n80x24@0:0:0:${lineHash("")}`]: "" }
12647
12738
  },
12648
12739
  {
12649
12740
  name: "mouse 1000 \u2192 1006 \u2192 1016 (SGR cell wheel, as 0.16.3)",
12650
12741
  cols: 80,
12651
12742
  rows: 24,
12652
12743
  output: "\x1B[?1000h\x1B[?1006h\x1B[?1016h",
12653
- keys: { "wheel-up": "\x1B[<64;40;12M", "wheel-down": "\x1B[<65;40;12M" }
12744
+ modes: { altScreen: false, appCursor: false, bracketedPaste: false, mouse: true, click: false },
12745
+ keys: { "wheel-up": "\x1B[<64;40;12M", "wheel-down": "\x1B[<65;40;12M", [`click:n80x24@0:0:0:${lineHash("")}`]: "" }
12746
+ },
12747
+ {
12748
+ // 원격 웹 클릭(Ryan 11-30) — 한글 두 칸 뒤 «O» = 6번째 칸 · 본 화면(크기)이 다르거나 줄 글의 지문이 다르면(그사이 화면이 바뀜) 누르지 않는다(빈 바이트).
12749
+ name: "click (SGR \xB7 wide characters \xB7 other view \xB7 stale line)",
12750
+ cols: 20,
12751
+ rows: 5,
12752
+ output: "\x1B[?1049h\x1B[?1000h\x1B[?1006h\x1B[2;1H\uAC00\uB098 OK",
12753
+ modes: { altScreen: true, appCursor: false, bracketedPaste: false, mouse: true, click: true },
12754
+ keys: {
12755
+ [`click:a20x5@0:1:3:${lineHash("\uAC00\uB098 OK")}`]: "\x1B[<0;6;2M\x1B[<0;6;2m",
12756
+ [`click:a20x6@0:1:3:${lineHash("\uAC00\uB098 OK")}`]: "",
12757
+ [`click:a20x5@0:1:3:${lineHash("\uAC00\uB098 NO")}`]: ""
12758
+ }
12759
+ },
12760
+ {
12761
+ // 옛 X10 인코딩(1006 없음)은 클릭을 보내지 않는다 — holder 가 글로 써 96칸부터 UTF-8 로 깨진다(리뷰 r1 P0-5).
12762
+ name: "click needs SGR (1000 without 1006)",
12763
+ cols: 20,
12764
+ rows: 5,
12765
+ output: "\x1B[?1049h\x1B[?1000h\x1B[2;1HOK",
12766
+ modes: { altScreen: true, appCursor: false, bracketedPaste: false, mouse: true, click: false },
12767
+ keys: { [`click:a20x5@0:1:0:${lineHash("OK")}`]: "" }
12654
12768
  }
12655
12769
  ]
12656
12770
  };
@@ -12677,7 +12791,7 @@ var ComputeSlot = class {
12677
12791
  }
12678
12792
  async offer(file) {
12679
12793
  const bytes = await readFile12(file);
12680
- const digest = createHash7("sha256").update(bytes).digest("hex").slice(0, 16);
12794
+ const digest = createHash8("sha256").update(bytes).digest("hex").slice(0, 16);
12681
12795
  const kept = (reason2) => ({ switched: false, version: this.active.module.version, reason: reason2 });
12682
12796
  if (digest === this.active.digest) return kept("already active");
12683
12797
  const folder = join8(this.dir, digest);
@@ -17485,7 +17599,7 @@ function withoutEndpointKeys(keys, endpoint) {
17485
17599
  }
17486
17600
 
17487
17601
  // src/core/term/remoteChannel.ts
17488
- import { createHash as createHash8 } from "crypto";
17602
+ import { createHash as createHash9 } from "crypto";
17489
17603
  var HANDSHAKE_TTL_MS = 3e4;
17490
17604
  var HANDSHAKE_MAX = 4;
17491
17605
  var ACTIVE_CHANNEL_MAX = 8;
@@ -17613,7 +17727,7 @@ var ChannelBook = class {
17613
17727
  return { type: "close", reason };
17614
17728
  };
17615
17729
  if (!channel.active && this.now() >= channel.expiresAt) return close("HANDSHAKE_EXPIRED");
17616
- const digest = createHash8("sha256").update(wire.c, "utf8").digest("hex");
17730
+ const digest = createHash9("sha256").update(wire.c, "utf8").digest("hex");
17617
17731
  if (channel.last && wire.n === channel.last.n && digest === channel.last.digest) return { type: "duplicate" };
17618
17732
  if (wire.n >= MAX_MESSAGES_PER_KEY) return close("MESSAGE_LIMIT");
17619
17733
  if (wire.n >= channel.imageBelow || wire.n !== channel.receive.next) return close("CHANNEL_OUT_OF_ORDER");
@@ -17966,14 +18080,15 @@ function sessionsKey(sessions) {
17966
18080
  }
17967
18081
 
17968
18082
  // src/core/term/remoteFrame.ts
17969
- import { createHash as createHash9 } from "crypto";
18083
+ import { createHash as createHash10 } from "crypto";
17970
18084
  function screenFrame(lines, maxD, attributes) {
17971
18085
  const sizes = lines.map((line) => Buffer.byteLength(line, "utf8"));
17972
18086
  const runs = attributes?.runs.length === lines.length ? attributes.runs : void 0;
17973
18087
  const runSizes = runs ? runs.map((row) => JSON.stringify(row).length + 1) : [];
17974
18088
  let start = 0;
17975
18089
  let bytes = sizes.reduce((sum, size) => sum + size, 0) + Math.max(0, lines.length - 1) * 2;
17976
- const fixed = runs ? 10 + CURSOR_BYTES : 0;
18090
+ const viewBytes = attributes?.view !== void 0 && attributes.top !== void 0 ? Buffer.byteLength(JSON.stringify({ view: attributes.view, top: -(2 ** 32 - 1) }), "utf8") : 0;
18091
+ const fixed = runs ? 10 + CURSOR_BYTES + viewBytes : 0;
17977
18092
  let runBytes = runSizes.reduce((sum, size) => sum + size, 0);
17978
18093
  while (start < lines.length && base64Length(bytes) + fixed + runBytes > maxD) {
17979
18094
  bytes -= (sizes[start] ?? 0) + (start < lines.length - 1 ? 2 : 0);
@@ -17984,12 +18099,14 @@ function screenFrame(lines, maxD, attributes) {
17984
18099
  const kept = runs?.slice(start);
17985
18100
  const cursorRow = attributes?.cursor ? attributes.cursor.row - start : -1;
17986
18101
  const cursor = attributes?.cursor && cursorRow >= 0 ? { row: cursorRow, col: attributes.cursor.col } : void 0;
17987
- const hash = createHash9("sha256").update(text2, "utf8");
17988
- if (kept) hash.update(JSON.stringify([attributes?.styles, kept, cursor ?? null]), "utf8");
18102
+ const at = kept && attributes?.view !== void 0 && attributes.top !== void 0 ? { view: attributes.view, top: attributes.top - start } : void 0;
18103
+ const hash = createHash10("sha256").update(text2, "utf8");
18104
+ if (kept) hash.update(JSON.stringify([attributes?.styles, kept, cursor ?? null, ...at ? [at] : []]), "utf8");
17989
18105
  return {
17990
18106
  d: Buffer.from(text2, "utf8").toString("base64"),
17991
18107
  ...kept ? { runs: kept } : {},
17992
18108
  ...cursor ? { cursor } : {},
18109
+ ...at ?? {},
17993
18110
  hash: hash.digest("hex"),
17994
18111
  dropped: start
17995
18112
  };
@@ -18174,6 +18291,7 @@ var RemoteViewer = class {
18174
18291
  ...sealed,
18175
18292
  ...frame.runs ? { runs: frame.runs } : {},
18176
18293
  ...frame.cursor ? { cursor: frame.cursor } : {},
18294
+ ...frame.view !== void 0 && frame.top !== void 0 ? { view: frame.view, top: frame.top } : {},
18177
18295
  executedThrough
18178
18296
  });
18179
18297
  } catch (error) {
@@ -19988,7 +20106,7 @@ function pcResultText(result) {
19988
20106
  return `Still connecting this PC to AiNecto \u2014 run \`ainecto status\` to see when it is up. Log: ${result.log}`;
19989
20107
  }
19990
20108
  if (result.kind === "kept-old") {
19991
- return "Nothing was changed \u2014 the AiNecto terminal service on this PC keeps its old structure, and its terminal sessions and PC connection stay as they are. To switch, run `npx -y ainecto@latest` in a terminal on this PC (not inside an AiNecto terminal session) and answer y.";
20109
+ return "Nothing was changed \u2014 the AiNecto terminal service on this PC keeps its old structure, and its terminal sessions and PC connection stay as they are. To switch, run `npx -y ainecto@latest` in a terminal on this PC (not inside an AiNecto terminal session) and answer n.";
19992
20110
  }
19993
20111
  if (result.kind === "already") {
19994
20112
  return `This PC is already connected to AiNecto (folder ${result.folder}, version ${result.version}). ${STOP} Log: ${result.log}`;
@@ -20055,11 +20173,12 @@ async function executePcStart(deps) {
20055
20173
  }
20056
20174
  if (await upgradeDaemon(deps, note, key) === "kept-old") {
20057
20175
  const [pc] = runningPcs(await listed2(deps));
20058
- return withNotes(deps, later, print2(
20059
- deps,
20060
- { connected: pc !== void 0, switched: false, ...pc ? pcView(deps, pc) : {} },
20061
- pcResultText({ kind: "kept-old" })
20062
- ));
20176
+ if (pc) {
20177
+ return withNotes(deps, later, print2(deps, { connected: true, switched: false, ...pcView(deps, pc) }, pcResultText({ kind: "kept-old" })));
20178
+ }
20179
+ note("Your open terminal sessions stay open (the AiNecto terminal service keeps its old structure). The PC connection was not running \u2014 starting it\u2026");
20180
+ await prepare(deps);
20181
+ return await withRegistration(deps, key, userId, withNotes(deps, later, await launchPc(deps)));
20063
20182
  }
20064
20183
  const action = pcAction(runningPcs(await listed2(deps)), deps.cliVersion);
20065
20184
  if (action.kind === "already") {
@@ -20114,7 +20233,7 @@ async function upgradeDaemon(deps, note, destination) {
20114
20233
  let before = sessions;
20115
20234
  for (; ; ) {
20116
20235
  note(switchQuestion(shown));
20117
- if (!yes(await promptLine(deps.io, "Switch now? [y/N]: "), false)) return "kept-old";
20236
+ if (await keepAnswer(deps.io, note) === "keep") return "kept-old";
20118
20237
  const now = await listed2(deps);
20119
20238
  const late = now.filter((session) => !before.some((seen) => sameSession(seen, session)));
20120
20239
  if (late.length === 0) {
@@ -20128,12 +20247,24 @@ async function upgradeDaemon(deps, note, destination) {
20128
20247
  }
20129
20248
  }
20130
20249
  }
20250
+ async function keepAnswer(io, note) {
20251
+ const ask = async () => readKeepAnswer(await promptAnswer(io, "Keep your open terminal sessions? [Y/n]: "));
20252
+ const first = await ask();
20253
+ if (first !== void 0) return first;
20254
+ note("Please answer y (keep your sessions) or n (switch and close them).");
20255
+ return await ask() ?? "keep";
20256
+ }
20257
+ function readKeepAnswer(answer) {
20258
+ const value = answer.line.trim().toLowerCase();
20259
+ if (!answer.entered || value === "" || value === "y" || value === "yes") return "keep";
20260
+ return value === "n" || value === "no" ? "switch" : void 0;
20261
+ }
20131
20262
  function switchQuestion(sessions) {
20132
20263
  if (sessions.length === 0) {
20133
- return "The terminal structure on this PC changed. No terminal sessions are open, so none will close. From the next update on they stay open.";
20264
+ return "The terminal structure on this PC changed. No terminal sessions are open, so switching to it closes none. From then on, updates keep sessions open.";
20134
20265
  }
20135
20266
  const names = sessions.map((session) => session.kind === "pc-bridge" ? `${session.name} (PC connection)` : session.name);
20136
- return `The terminal structure on this PC changed, so this one time the ${sessions.length} open terminal session(s) will close: ${names.join(", ")}. From the next update on they stay open.`;
20267
+ return `The terminal structure on this PC changed. Switching to it (answer n) closes the ${sessions.length} open terminal session(s) this one time: ${names.join(", ")}. From then on, updates keep sessions open.`;
20137
20268
  }
20138
20269
  function sameSession(a, b) {
20139
20270
  return a.instance !== void 0 && b.instance !== void 0 ? a.instance === b.instance : a.name === b.name && a.pid === b.pid;
@@ -20927,7 +21058,7 @@ async function pcStatus(status, endpoint) {
20927
21058
  }
20928
21059
 
20929
21060
  // src/adapters/cli/agentCommand.ts
20930
- import { createHash as createHash10 } from "crypto";
21061
+ import { createHash as createHash11 } from "crypto";
20931
21062
  import { homedir as homedir6, hostname as hostname3 } from "os";
20932
21063
  import { join as join16 } from "path";
20933
21064
 
@@ -22506,7 +22637,7 @@ async function executeAgentServe(input) {
22506
22637
  // 연결 이름마다 한 폴더 — 이름 글자를 폴더 이름에 쓰지 않는다(해시).
22507
22638
  workDir: (agentName) => join16(
22508
22639
  paths.antigravity,
22509
- agentName ? `agent-${createHash10("sha256").update(agentName).digest("hex").slice(0, 16)}` : "chat"
22640
+ agentName ? `agent-${createHash11("sha256").update(agentName).digest("hex").slice(0, 16)}` : "chat"
22510
22641
  ),
22511
22642
  mcpConfig: (agentName, readOnly) => antigravityMcpConfig(bridge(agentName, readOnly)),
22512
22643
  schema: agentReplySchema