ptywright 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/agent.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { a as formatAgentLaunchPlan, i as runAgentSpecPath, n as replayAgentRecordPath, r as runAgentSpec, t as defaultSpecNameForPath } from "./runner-GIEf0C6d.mjs";
1
+ import { a as formatAgentLaunchPlan, i as runAgentSpecPath, n as replayAgentRecordPath, r as runAgentSpec, t as defaultSpecNameForPath } from "./runner-XEimk7TO.mjs";
2
2
  export { defaultSpecNameForPath, formatAgentLaunchPlan, replayAgentRecordPath, runAgentSpec, runAgentSpecPath };
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env bun
2
- import { t as main } from "../cli-IXmvK56U.mjs";
2
+ import { t as main } from "../cli-XLR4BPhA.mjs";
3
3
  //#region src/bin/ptywright.ts
4
4
  await main();
5
5
  //#endregion
@@ -1,9 +1,9 @@
1
1
  import { n as loadPtywrightConfig } from "./config-bGg636EW.mjs";
2
- import { C as writeAgentManifestPath, D as escapeHtml, E as escapeAttribute, O as normalizeAgentFlowSpec, S as validateAgentManifestFiles, T as readAgentCassettePath, _ as formatArgv, b as isAgentManifestLike, c as launchAgentBrowser, d as AGENT_RUN_RECORD_SCHEMA_URL, f as agentRunModeSchema, g as writeAgentRunRecordPath, h as readAgentRunRecordPath, i as runAgentSpecPath, k as sanitizeArtifactName, l as createAgentTemplateSpec, m as isAgentRunRecordLike, n as replayAgentRecordPath, o as resolveAgentLaunchTarget, p as formatAgentArgv, s as normalizeAgentFlowSpecWithConfig, u as loadAgentSpec, v as AGENT_MANIFEST_FILE_NAME, w as isAgentCassetteLike, x as readAgentManifestPath, y as agentManifestPath } from "./runner-GIEf0C6d.mjs";
2
+ import { C as writeAgentManifestPath, D as escapeHtml, E as escapeAttribute, O as normalizeAgentFlowSpec, S as validateAgentManifestFiles, T as readAgentCassettePath, _ as formatArgv, b as isAgentManifestLike, c as launchAgentBrowser, d as AGENT_RUN_RECORD_SCHEMA_URL, f as agentRunModeSchema, g as writeAgentRunRecordPath, h as readAgentRunRecordPath, i as runAgentSpecPath, k as sanitizeArtifactName, l as createAgentTemplateSpec, m as isAgentRunRecordLike, n as replayAgentRecordPath, o as resolveAgentLaunchTarget, p as formatAgentArgv, s as normalizeAgentFlowSpecWithConfig, u as loadAgentSpec, v as AGENT_MANIFEST_FILE_NAME, w as isAgentCassetteLike, x as readAgentManifestPath, y as agentManifestPath } from "./runner-XEimk7TO.mjs";
3
3
  import { a as sameArgv, i as diffCommandMaps, r as formatZodIssues } from "./manifest_files-DW80c1H7.mjs";
4
4
  import { i as portableCliPath, n as mergeProcessEnv, o as relativeHref, s as samePath } from "./env-DPYHo-zH.mjs";
5
5
  import { d as resolvePtyBackend, u as createDefaultPtyAdapter } from "./runner-BHXXwxYp.mjs";
6
- import { a as resolveScriptManifestPath, c as relocateScriptManifestCommands, d as resolveScriptRunSummaryPath, f as runScriptPath, i as readScriptManifestPath, l as resolveManifestPrimaryPath$1, n as runAllScripts, o as validateScriptManifest, r as findScriptSummaryManifest, t as createPtywrightServer, u as readScriptRunSummaryPath } from "./server-ceZ1-s_J.mjs";
6
+ import { a as resolveScriptManifestPath, c as relocateScriptManifestCommands, d as resolveScriptRunSummaryPath, f as runScriptPath, i as readScriptManifestPath, l as resolveManifestPrimaryPath$1, n as runAllScripts, o as validateScriptManifest, r as findScriptSummaryManifest, t as createPtywrightServer, u as readScriptRunSummaryPath } from "./server-COuf3mW7.mjs";
7
7
  import { c as createPtyCassetteReplay, i as formatPtyCassetteInspectLines, l as readPtyCassettePath, o as inspectPtyCassettePath, r as createPtyCassetteRecorder, t as wrapPtyLike, v as validatePtyCassette } from "./pty_like-DWIlWGgA.mjs";
8
8
  import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
9
9
  import { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
package/dist/cli.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as main } from "./cli-IXmvK56U.mjs";
1
+ import { t as main } from "./cli-XLR4BPhA.mjs";
2
2
  export { main };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createPtywrightServer } from "./server-ceZ1-s_J.mjs";
1
+ import { t as createPtywrightServer } from "./server-COuf3mW7.mjs";
2
2
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
3
  //#region src/index.ts
4
4
  const { server, sessions } = createPtywrightServer();
package/dist/mcp.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { t as createPtywrightServer } from "./server-ceZ1-s_J.mjs";
1
+ import { t as createPtywrightServer } from "./server-COuf3mW7.mjs";
2
2
  export { createPtywrightServer };
@@ -1866,17 +1866,63 @@ function renderStableFrameDom(frame, targetCols) {
1866
1866
  let totalRows = 0;
1867
1867
  let wideBlockId = 0;
1868
1868
  for (const line of frame.lines) {
1869
- const lineCols = Math.max(targetCols, cellsDisplayWidth(line.cells));
1870
- if (lineCols > targetCols || line.physicalRows > 1) {
1869
+ const lineCols = cellsDisplayWidth(line.cells);
1870
+ if (shouldRenderViewportPan(line, lineCols, targetCols)) {
1871
1871
  wideBlockId += 1;
1872
- html += `<div class="term-wide-row-block" data-aitty-wide-block="true" data-aitty-wide-block-id="${wideBlockId}" data-aitty-wide-block-kind="viewport-pan" style="--aitty-wide-block-cols: ${lineCols}">`;
1873
- html += renderStableFrameRow(line, lineCols, totalRows);
1872
+ const blockCols = Math.max(targetCols, lineCols);
1873
+ html += `<div class="term-wide-row-block" data-aitty-wide-block="true" data-aitty-wide-block-id="${wideBlockId}" data-aitty-wide-block-kind="viewport-pan" style="--aitty-wide-block-cols: ${blockCols}">`;
1874
+ html += renderStableFrameRow(line, blockCols, totalRows);
1874
1875
  html += "</div>";
1875
- } else html += renderStableFrameRow(line, targetCols, totalRows);
1876
- totalRows += 1;
1876
+ totalRows += 1;
1877
+ } else for (const row of wrapStableLogicalLine(line, targetCols)) {
1878
+ html += renderStableFrameRow(row, targetCols, totalRows);
1879
+ totalRows += 1;
1880
+ }
1877
1881
  }
1878
1882
  return `<div class="term-grid" data-cols="${targetCols}" data-rows="${totalRows}" style="--term-cols: ${targetCols}; --term-rows: ${totalRows};">${html}</div>`;
1879
1883
  }
1884
+ function shouldRenderViewportPan(line, lineCols, targetCols) {
1885
+ if (lineCols <= targetCols) return false;
1886
+ return isDiffLikeLine(stableLineText(line));
1887
+ }
1888
+ function stableLineText(line) {
1889
+ return line.cells.map((cell) => cell.text).join("").trimEnd();
1890
+ }
1891
+ function isDiffLikeLine(text) {
1892
+ const normalized = text.replace(/[│┃┆┊▏▕]/g, " ").trimStart();
1893
+ if (normalized === "") return false;
1894
+ if (/^(?:diff --git|index [0-9a-f]{6,}\.\.|@@\s|[-+]{3}\s)/.test(normalized)) return true;
1895
+ if (/^\d+\s+[+-]/.test(normalized)) return true;
1896
+ const signed = normalized.match(/^[+-]\s*(.*)$/);
1897
+ if (!signed) return false;
1898
+ return isCodeLikeText(signed[1] ?? "");
1899
+ }
1900
+ function isCodeLikeText(text) {
1901
+ return /[{}()[\];=<>]/.test(text) || /\b(?:async|await|class|const|def|export|from|function|if|import|interface|let|return|type|var)\b/.test(text) || /(?:^|\s)(?:--?[a-z][\w-]*|#[\w-]+|\/[A-Za-z0-9._/-]+)(?:\s|$)/.test(text);
1902
+ }
1903
+ function wrapStableLogicalLine(line, targetCols) {
1904
+ if (cellsDisplayWidth(line.cells) <= targetCols) return [line];
1905
+ const rows = [];
1906
+ let cells = [];
1907
+ let cols = 0;
1908
+ const flush = () => {
1909
+ rows.push({
1910
+ cells,
1911
+ live: line.live,
1912
+ physicalRows: 1
1913
+ });
1914
+ cells = [];
1915
+ cols = 0;
1916
+ };
1917
+ for (const cell of line.cells) {
1918
+ if (cols > 0 && cols + cell.width > targetCols) flush();
1919
+ cells.push(cell);
1920
+ cols += cell.width;
1921
+ if (cols >= targetCols) flush();
1922
+ }
1923
+ if (cells.length > 0 || rows.length === 0) flush();
1924
+ return rows;
1925
+ }
1880
1926
  function renderStableFrameRow(line, lineCols, lineIndex) {
1881
1927
  return `<div class="${line.live ? "term-row" : "term-row term-scrollback-row"}"${line.live ? ` data-aitty-live-grid-row="${lineIndex + 1}"` : ""} data-aitty-line-cols="${lineCols}">${renderStableFrameCells(line.cells, lineCols)}</div>`;
1882
1928
  }
@@ -1944,10 +1990,30 @@ function styleDeclarations(style) {
1944
1990
  }
1945
1991
  function colorToCss(color) {
1946
1992
  if (color.mode === "default") return null;
1947
- if (color.mode === "palette") return `var(--term-color-${color.value})`;
1993
+ if (color.mode === "palette") return paletteColorToCss(color.value);
1948
1994
  const value = color.value;
1949
1995
  return `rgb(${value >> 16 & 255},${value >> 8 & 255},${value & 255})`;
1950
1996
  }
1997
+ function paletteColorToCss(value) {
1998
+ if (value >= 0 && value <= 15) return `var(--term-color-${value})`;
1999
+ if (value >= 16 && value <= 231) {
2000
+ const index = value - 16;
2001
+ const steps = [
2002
+ 0,
2003
+ 95,
2004
+ 135,
2005
+ 175,
2006
+ 215,
2007
+ 255
2008
+ ];
2009
+ return `rgb(${steps[Math.floor(index / 36)] ?? 0},${steps[Math.floor(index % 36 / 6)] ?? 0},${steps[index % 6] ?? 0})`;
2010
+ }
2011
+ if (value >= 232 && value <= 255) {
2012
+ const channel = 8 + (value - 232) * 10;
2013
+ return `rgb(${channel},${channel},${channel})`;
2014
+ }
2015
+ return `var(--term-color-${value})`;
2016
+ }
1951
2017
  function widthDeclaration(width) {
1952
2018
  if (width <= 1) return "width: var(--term-cell-width, 1ch)";
1953
2019
  return `width: calc(var(--term-cell-width, 1ch) * ${width})`;
@@ -144,7 +144,7 @@ var ScriptRecordingManager = class {
144
144
  };
145
145
  //#endregion
146
146
  //#region package.json
147
- var version = "0.6.0";
147
+ var version = "0.6.1";
148
148
  //#endregion
149
149
  //#region src/mcp/tool_result.ts
150
150
  function toolError(message, extra = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ptywright",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Terminal/TUI automation driver over PTY + xterm, exposed as MCP tools",
5
5
  "keywords": [
6
6
  "agent",