newmark-agent 0.4.3 → 0.4.5
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/conversation-utility-host.bundle.cjs +902 -698
- package/dist/conversation-utility-host.js +3 -0
- package/dist/core/agent.d.ts +19 -0
- package/dist/core/agent.js +88 -12
- package/dist/core/agentKernelRunner.js +1 -1
- package/dist/core/conversationKernel.d.ts +8 -0
- package/dist/core/conversationKernel.js +44 -5
- package/dist/core/electronUtilityAgentClient.d.ts +1 -0
- package/dist/core/electronUtilityAgentClient.js +4 -0
- package/dist/core/electronUtilityRuntimePool.d.ts +2 -0
- package/dist/core/electronUtilityRuntimePool.js +11 -0
- package/dist/core/toolPolicy.js +28 -13
- package/dist/core/utilityAgentProtocol.d.ts +7 -0
- package/dist/core/workspace.d.ts +6 -0
- package/dist/core/workspace.js +14 -0
- package/dist/core/wslAgentClient.d.ts +1 -0
- package/dist/core/wslAgentClient.js +4 -0
- package/dist/core/wslAgentProtocol.d.ts +7 -0
- package/dist/core/wslAgentRuntimePool.d.ts +2 -0
- package/dist/core/wslAgentRuntimePool.js +12 -0
- package/dist/main.js +36 -7
- package/dist/tools/index.d.ts +14 -0
- package/dist/tools/index.js +144 -18
- package/dist/tui/src/app.js +51 -6
- package/dist/tui/src/data.js +28 -0
- package/dist/tui/src/render.js +67 -30
- package/dist/ui/index.html +11 -0
- package/dist/wsl-agent-host.bundle.cjs +902 -698
- package/dist/wsl-agent-host.js +3 -0
- package/package.json +6 -3
package/dist/tui/src/render.js
CHANGED
|
@@ -689,29 +689,34 @@ function modelView(state, width, p) {
|
|
|
689
689
|
const isCurrent = (selection) => selection.kind === current.kind
|
|
690
690
|
&& (selection.kind === "auto"
|
|
691
691
|
|| (selection.providerId === current.providerId && selection.modelId === current.modelId));
|
|
692
|
-
|
|
692
|
+
const rows = [
|
|
693
693
|
...conversationContext(state, p, "Model and reasoning effort"),
|
|
694
|
-
`${p.bold}${tr(state, "Reasoning effort")}${p.reset} ${p.muted}${tr(state, "Shared GUI/TUI request tier · ←/→ changes section")}${p.reset}
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
694
|
+
`${p.bold}${tr(state, "Reasoning effort")}${p.reset} ${p.muted}${tr(state, "Shared GUI/TUI request tier · ←/→ changes section")}${p.reset}`
|
|
695
|
+
];
|
|
696
|
+
const tierStart = rows.length;
|
|
697
|
+
INTELLIGENCE_TIERS.forEach((tier, index) => {
|
|
698
|
+
const style = state.focusRegion === "content" && state.contentColumn === 0 && index === state.selected ? `${p.selected}${p.bold}` : "";
|
|
699
|
+
if (style) state.contentFocusLine = tierStart + index;
|
|
700
|
+
rows.push(`${style} ${tier === currentTier ? `${p.cyan}●${p.reset}` : "○"} ${tier}${p.reset}`);
|
|
701
|
+
});
|
|
702
|
+
rows.push(
|
|
700
703
|
"",
|
|
701
704
|
`${p.bold}${tr(state, "Deployment")}${p.reset} ${p.muted}${tr(state, "Used by this conversation, including its Plan and Subagents")}${p.reset}`,
|
|
702
|
-
""
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
705
|
+
""
|
|
706
|
+
);
|
|
707
|
+
const deploymentStart = rows.length;
|
|
708
|
+
options.forEach((option, index) => {
|
|
709
|
+
const style = state.focusRegion === "content" && state.contentColumn === 1 && index === state.selected ? `${p.selected}${p.bold}` : "";
|
|
710
|
+
if (style) state.contentFocusLine = deploymentStart + index * 2;
|
|
711
|
+
const marker = isCurrent(option.selection) ? `${p.cyan}●${p.reset}` : "○";
|
|
712
|
+
rows.push(`${style} ${marker} ${pad(option.label, Math.max(18, Math.min(32, width - 24)))} ${p.muted}${option.provider}${p.reset}`);
|
|
713
|
+
rows.push(` ${p.muted}${truncate(option.description, Math.max(20, width - 5))}${p.reset}`);
|
|
714
|
+
});
|
|
715
|
+
rows.push(
|
|
712
716
|
"",
|
|
713
717
|
`${p.muted}${tr(state, "Enter applies the focused tier or deployment. Effort persists globally; deployments remain per conversation.")}${p.reset}`
|
|
714
|
-
|
|
718
|
+
);
|
|
719
|
+
return rows;
|
|
715
720
|
}
|
|
716
721
|
|
|
717
722
|
function flowBarView(state, width, p) {
|
|
@@ -1250,14 +1255,38 @@ function overlayLines(state, width, p) {
|
|
|
1250
1255
|
return [];
|
|
1251
1256
|
}
|
|
1252
1257
|
|
|
1253
|
-
|
|
1258
|
+
// 实时读取终端窗口尺寸:优先 getWindowSize()(每次调用都查询底层 TTY 尺寸,
|
|
1259
|
+
// 不依赖 Node 缓存的 columns/rows,避免 resize 事件丢失或延迟时按旧尺寸绘制),
|
|
1260
|
+
// 其次回退到缓存 columns/rows,再回退 COLUMNS/LINES 环境变量与默认值。
|
|
1261
|
+
function readWindowSize(fallbackColumns = 100, fallbackRows = 30) {
|
|
1262
|
+
const stdout = process.stdout;
|
|
1263
|
+
if (stdout && typeof stdout.getWindowSize === "function") {
|
|
1264
|
+
try {
|
|
1265
|
+
const [width, height] = stdout.getWindowSize();
|
|
1266
|
+
if (Number.isFinite(width) && Number.isFinite(height) && width > 0 && height > 0) {
|
|
1267
|
+
return { columns: Math.max(1, Math.floor(width)), rows: Math.max(1, Math.floor(height)) };
|
|
1268
|
+
}
|
|
1269
|
+
} catch {}
|
|
1270
|
+
}
|
|
1271
|
+
const columns = Number(stdout?.columns) || Number(process.env.COLUMNS) || fallbackColumns;
|
|
1272
|
+
const rows = Number(stdout?.rows) || Number(process.env.LINES) || fallbackRows;
|
|
1273
|
+
return { columns: Math.max(1, Math.floor(columns)), rows: Math.max(1, Math.floor(rows)) };
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
function render(state, columns, rows) {
|
|
1277
|
+
const size = (columns !== undefined && rows !== undefined)
|
|
1278
|
+
? { columns: Math.max(1, Math.floor(Number(columns) || 1)), rows: Math.max(1, Math.floor(Number(rows) || 1)) }
|
|
1279
|
+
: readWindowSize();
|
|
1254
1280
|
const p = palette(state);
|
|
1255
|
-
|
|
1256
|
-
|
|
1281
|
+
// 严格约束:直接采用终端实际尺寸,绝不通过 Math.max(52/20) 强制放大。
|
|
1282
|
+
// 终端窗口小于内部最小布局时,内容在输出阶段裁剪到窗口内,否则帧会
|
|
1283
|
+
// 画到窗口之外(用户看不到底部行/右侧列,如小窗口下的模型长菜单)。
|
|
1284
|
+
const width = size.columns;
|
|
1285
|
+
const height = size.rows;
|
|
1257
1286
|
const compact = width < 78;
|
|
1258
1287
|
const sidebarWidth = compact ? 0 : 22;
|
|
1259
1288
|
const contentWidth = width - sidebarWidth - 2;
|
|
1260
|
-
const bodyHeight = height - 3;
|
|
1289
|
+
const bodyHeight = Math.max(1, height - 3);
|
|
1261
1290
|
const sidebar = sidebarWidth ? renderSidebar(state, bodyHeight, sidebarWidth, p) : [];
|
|
1262
1291
|
const content = renderContent(state, contentWidth, bodyHeight, p);
|
|
1263
1292
|
let contentLines = content;
|
|
@@ -1266,8 +1295,11 @@ function render(state, columns = process.stdout.columns || 100, rows = process.s
|
|
|
1266
1295
|
let scroll = Math.max(0, Math.min(maximumScroll, Number(state.contentScroll) || 0));
|
|
1267
1296
|
const focusLine = Number(state.contentFocusLine) || -1;
|
|
1268
1297
|
if (focusLine >= 0) {
|
|
1269
|
-
|
|
1270
|
-
|
|
1298
|
+
// 居中跟随:焦点行尽量保持在视口中上部,上下都留出内容,避免选中行
|
|
1299
|
+
// 贴住视口边缘或被裁掉其相邻行(如两行一组的模型选项主行+描述行)。
|
|
1300
|
+
const targetLine = Math.min(Math.max(0, Math.floor(bodyHeight / 3)), Math.max(0, bodyHeight - 2));
|
|
1301
|
+
if (focusLine < scroll + targetLine) scroll = Math.max(0, focusLine - targetLine);
|
|
1302
|
+
else if (focusLine >= scroll + bodyHeight - 1 - targetLine) scroll = Math.min(maximumScroll, focusLine - (bodyHeight - 1 - targetLine));
|
|
1271
1303
|
}
|
|
1272
1304
|
scroll = Math.max(0, Math.min(maximumScroll, scroll));
|
|
1273
1305
|
state.contentScroll = scroll;
|
|
@@ -1286,20 +1318,25 @@ function render(state, columns = process.stdout.columns || 100, rows = process.s
|
|
|
1286
1318
|
: "";
|
|
1287
1319
|
if (compact) body.unshift(pad(top, width));
|
|
1288
1320
|
const focus = state.focusRegion === "menu" ? "MENU" : "CONTENT";
|
|
1289
|
-
const footer = `${p.panel} ${p.cyan}${focus}${p.reset}${p.panel}${p.muted} · ${truncate(state.notice, width - 42)}${p.reset}${p.panel}${" ".repeat(Math.max(1, width - visibleLength(state.notice) - visibleLength(focus) - 35))}Tab back ? help Q quit ${p.reset}`;
|
|
1290
|
-
const
|
|
1291
|
-
|
|
1292
|
-
|
|
1321
|
+
const footer = `${p.panel} ${p.cyan}${focus}${p.reset}${p.panel}${p.muted} · ${truncate(state.notice, Math.max(1, width - 42))}${p.reset}${p.panel}${" ".repeat(Math.max(1, width - visibleLength(state.notice) - visibleLength(focus) - 35))}Tab back ? help Q quit ${p.reset}`;
|
|
1322
|
+
const bodyLines = Math.max(1, height - 1);
|
|
1323
|
+
const renderedBody = body.slice(0, bodyLines);
|
|
1324
|
+
while (renderedBody.length < bodyLines) renderedBody.push(pad("", width));
|
|
1325
|
+
// 输出阶段严格边界:每行按可见宽度截断到窗口宽度,行数限制在窗口高度内,
|
|
1326
|
+
// 确保无论内部最小布局如何,帧绝不会画到窗口之外。
|
|
1327
|
+
const boundedBody = renderedBody.map((line) => truncate(line, width));
|
|
1328
|
+
const boundedFooter = truncate(pad(footer, width), width);
|
|
1329
|
+
let output = `${ESC}?25l${ESC}2J${ESC}H${p.paint}${boundedBody.join("\n")}\n${boundedFooter}`;
|
|
1293
1330
|
const overlay = overlayLines(state, width, p);
|
|
1294
1331
|
if (overlay.length) {
|
|
1295
1332
|
const overlayWidth = Math.max(...overlay.map(visibleLength));
|
|
1296
1333
|
const x = Math.max(1, Math.floor((width - overlayWidth) / 2) + 1);
|
|
1297
1334
|
const y = Math.max(2, Math.floor((height - overlay.length) / 2));
|
|
1298
1335
|
overlay.forEach((line, index) => {
|
|
1299
|
-
output += `${ESC}${y + index};${x}H${line}`;
|
|
1336
|
+
output += `${ESC}${y + index};${x}H${truncate(line, width)}`;
|
|
1300
1337
|
});
|
|
1301
1338
|
}
|
|
1302
1339
|
return `${output}${p.final}`;
|
|
1303
1340
|
}
|
|
1304
1341
|
|
|
1305
|
-
module.exports = { render, stripAnsi, visibleLength, wrapText };
|
|
1342
|
+
module.exports = { render, readWindowSize, stripAnsi, visibleLength, wrapText };
|
package/dist/ui/index.html
CHANGED
|
@@ -22825,6 +22825,17 @@ function schedulePostStartupUiRendering() {
|
|
|
22825
22825
|
var modelResult = await api.setModel(state.model);
|
|
22826
22826
|
if (modelResult != null) state._syncedModel = state.model;
|
|
22827
22827
|
}
|
|
22828
|
+
// The context ring/inspector must immediately reflect the newly selected
|
|
22829
|
+
// model's configured context window rather than waiting for the next send.
|
|
22830
|
+
if (api.getState) {
|
|
22831
|
+
var ctxTarget = currentConversationTarget();
|
|
22832
|
+
api.getState(ctxTarget).then(function(s) {
|
|
22833
|
+
if (s && s.contextWindow !== undefined && isActiveConversationTarget(ctxTarget) && isViewingRuntimeConversationBranch(ctxTarget)) {
|
|
22834
|
+
state.contextWindow = s.contextWindow;
|
|
22835
|
+
window.renderContextWindow();
|
|
22836
|
+
}
|
|
22837
|
+
}).catch(function(){});
|
|
22838
|
+
}
|
|
22828
22839
|
});
|
|
22829
22840
|
}
|
|
22830
22841
|
|