@volter/supercode-teams 0.2.70 → 0.2.72
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 +1 -0
- package/bin/teams.mjs +18 -2
- package/package.json +1 -1
- package/terminal-look.mjs +17 -4
package/README.md
CHANGED
|
@@ -82,6 +82,7 @@ supercode teams machine start # local door only
|
|
|
82
82
|
supercode open --new bash --detach # a pane; prints its contextKey
|
|
83
83
|
supercode open <ctx> # attach; ctrl-] detaches
|
|
84
84
|
supercode teams input <ctx> "make test"
|
|
85
|
+
supercode teams input <ctx> --key Escape # keys by tmux name: C-c, "Down Enter", …
|
|
85
86
|
supercode teams title set <ctx> "rate-limit rescue" # also names the owned tmux window
|
|
86
87
|
supercode teams suspend <ctx> # remote input refused; observe keeps streaming
|
|
87
88
|
supercode teams resume <ctx> --input "carry on" # the input that hands the pane back
|
package/bin/teams.mjs
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// machine status the running daemon, if any
|
|
11
11
|
// describe the host-key-signed statement
|
|
12
12
|
// panes ls | capture <pane> | close <pane>
|
|
13
|
-
// input <pane> <text> [--no-enter]
|
|
13
|
+
// input <pane> <text> [--no-enter] | input <pane> --key NAMES text, or keys by tmux name (Escape, C-c, Down …)
|
|
14
14
|
// suspend <pane> [--interrupt] | resume <pane> [--input text] refuse/allow remote input on a pane
|
|
15
15
|
// files ls|get|put|stat|search <path> [--out f] [--in f] [--query q]
|
|
16
16
|
// ports ls | resolve <pane> port <pane>/<n> [--listen host:port]
|
|
@@ -45,7 +45,7 @@ import { NODE_PROTOCOL } from '@volter/teams/channel';
|
|
|
45
45
|
|
|
46
46
|
const MACHINE_VERBS = new Set(['machine', 'describe', 'panes', 'input', 'suspend', 'resume', 'files', 'ports', 'port', 'browser', 'stream', 'jobs', 'workspace', 'title', 'attention', 'watch', 'rpc', 'log', 'mail']);
|
|
47
47
|
// Every flag a machine verb reads; any other is refused rather than silently ignored.
|
|
48
|
-
const KNOWN_FLAGS = new Set(['home', 'machine', 'context', 'floor', 'supercode', 'tmux-socket', 'verbose', 'lines', 'input', 'name', 'for', 'urgency', 'reason', 'interrupt', 'query', 'out', 'in', 'interval', 'no-enter', 'when-composer-empty', 'listen', 'list', 'from', 'to', 'path', 'to-path']);
|
|
48
|
+
const KNOWN_FLAGS = new Set(['home', 'machine', 'context', 'floor', 'supercode', 'tmux-socket', 'verbose', 'lines', 'input', 'name', 'for', 'urgency', 'reason', 'interrupt', 'query', 'out', 'in', 'interval', 'no-enter', 'when-composer-empty', 'key', 'listen', 'list', 'from', 'to', 'path', 'to-path']);
|
|
49
49
|
|
|
50
50
|
const argv = process.argv.slice(2);
|
|
51
51
|
const flags = {};
|
|
@@ -90,6 +90,18 @@ const out = (value) => process.stdout.write((typeof value === 'string' ? value :
|
|
|
90
90
|
const die = (message, code = 2) => { process.stderr.write(`supercode teams: ${message}\n`); process.exit(code); };
|
|
91
91
|
if (!workspaceVerb) for (const flag of Object.keys(flags)) if (!KNOWN_FLAGS.has(flag)) die(`unknown flag: --${flag}`);
|
|
92
92
|
|
|
93
|
+
/** Named keys (tmux's names) as the bytes a terminal sends for them: `panes.input` delivers
|
|
94
|
+
* text without a trailing newline as a keystream, which every terminal host turns back into keys. */
|
|
95
|
+
const KEY_BYTES = { Escape: '\u001b', Enter: '\r', Tab: '\t', BTab: '\u001b[Z', BSpace: '\u007f', Space: ' ', Up: '\u001b[A', Down: '\u001b[B', Right: '\u001b[C', Left: '\u001b[D', Home: '\u001b[H', End: '\u001b[F', PPage: '\u001b[5~', NPage: '\u001b[6~', DC: '\u001b[3~' };
|
|
96
|
+
function keyBytes(names) {
|
|
97
|
+
return names.split(/[\s,]+/u).filter(Boolean).map((name) => {
|
|
98
|
+
const control = /^C-([a-z])$/iu.exec(name);
|
|
99
|
+
if (control) return String.fromCharCode(control[1].toLowerCase().charCodeAt(0) - 96);
|
|
100
|
+
if (!Object.hasOwn(KEY_BYTES, name)) die(`unknown key ${name}: one of ${Object.keys(KEY_BYTES).join(', ')}, C-a … C-z`);
|
|
101
|
+
return KEY_BYTES[name];
|
|
102
|
+
}).join('');
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
async function machineChannel() {
|
|
94
106
|
return openMachine({ machine: flags.machine ? String(flags.machine) : null, context: flags.context ? String(flags.context) : null, home });
|
|
95
107
|
}
|
|
@@ -198,6 +210,10 @@ async function main() {
|
|
|
198
210
|
// `input <pane> <text>`: one delivery through the host's own sendInput; gated like control.
|
|
199
211
|
// `--when-composer-empty`: a user's own turn, typed only into an empty composer
|
|
200
212
|
// (answers `delivered: false` with the reason when it holds a draft).
|
|
213
|
+
if (flags.key !== undefined) {
|
|
214
|
+
if (flags.key === true || rest.length) die('input <pane> --key NAMES: keys by tmux name, space- or comma-separated (Escape, Enter, Tab, BTab, BSpace, Space, Up, Down, Left, Right, Home, End, PPage, NPage, DC, C-a … C-z)');
|
|
215
|
+
return withNode(async (rpc) => out(await rpc.call('panes.input', { pane: sub, text: keyBytes(String(flags.key)), submit: false })));
|
|
216
|
+
}
|
|
201
217
|
if (flags['when-composer-empty']) return withNode(async (rpc) => out(await rpc.call('panes.turn', { pane: sub, text: rest.join(' ') })));
|
|
202
218
|
return withNode(async (rpc) => out(await rpc.call('panes.input', { pane: sub, text: rest.join(' '), submit: !flags['no-enter'] })));
|
|
203
219
|
case 'port': {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/supercode-teams",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
|
|
6
6
|
"license": "MIT",
|
package/terminal-look.mjs
CHANGED
|
@@ -11,6 +11,11 @@ import { join } from 'node:path';
|
|
|
11
11
|
import { TERMINAL_BASIC } from './terminal-basic.mjs';
|
|
12
12
|
|
|
13
13
|
const TERMINAL_FONTS = '/System/Applications/Utilities/Terminal.app/Contents/Resources/Fonts';
|
|
14
|
+
// Where CoreText finds a glyph Terminal.app's face lacks, in its order (CTFontCopyDefaultCascadeListForLanguages for
|
|
15
|
+
// SFMonoTerminal-Regular, then the faces it picked for ⎿ and ⏺ on macOS 26): WezTerm's own fallbacks come after.
|
|
16
|
+
// CoreText's cascade holds a subset of Apple Symbols (.AppleSymbolsFB) that lacks ⎿, which it draws from Hiragino
|
|
17
|
+
// Sans; WezTerm reads the whole face, so Apple Symbols comes after the faces CoreText reached first.
|
|
18
|
+
const MAC_CASCADE = ['Menlo', 'Monaco', 'Courier New', 'Helvetica', 'Lucida Grande', 'PingFang SC', 'Hiragino Sans', 'STIX Two Math', 'Apple Symbols', 'Apple Color Emoji'];
|
|
14
19
|
const ANSI = ['Black', 'Red', 'Green', 'Yellow', 'Blue', 'Magenta', 'Cyan', 'White'];
|
|
15
20
|
|
|
16
21
|
// Runs in osascript's JavaScript for Automation with the Objective-C bridge: no Apple Event is sent, so no automation
|
|
@@ -40,7 +45,7 @@ function run() {
|
|
|
40
45
|
const font = archived('Font');
|
|
41
46
|
return JSON.stringify({
|
|
42
47
|
name, colors,
|
|
43
|
-
font: font && !font.isNil() ? { family: ObjC.unwrap(font.familyName), size: font.pointSize } : null,
|
|
48
|
+
font: font && !font.isNil() ? { family: ObjC.unwrap(font.familyName), size: font.pointSize, lineHeight: $.NSLayoutManager.alloc.init.defaultLineHeightForFont(font), ascender: font.ascender, descender: font.descender } : null,
|
|
44
49
|
widthSpacing: value('FontWidthSpacing'), heightSpacing: value('FontHeightSpacing'),
|
|
45
50
|
cursorType: value('CursorType'), cursorBlink: value('CursorBlink'), optionIsMeta: value('useOptionAsMetaKey'),
|
|
46
51
|
bell: value('Bell'), visualBell: value('VisualBell'), brightBold: value('UseBrightBold'),
|
|
@@ -63,6 +68,7 @@ const lua = (value) => (typeof value === 'string' ? JSON.stringify(value) : Stri
|
|
|
63
68
|
|
|
64
69
|
/** WezTerm's config (Lua) for a window that looks like Terminal.app with `profile` (from terminalAppProfile, or null). */
|
|
65
70
|
export function weztermConfig(profile, { fontDirs = existsSync(TERMINAL_FONTS) ? [TERMINAL_FONTS] : [] } = {}) {
|
|
71
|
+
const mac = fontDirs.length > 0;
|
|
66
72
|
const stored = profile?.colors ?? {};
|
|
67
73
|
// One colour table per appearance: the profile's colour where it stores one, else Basic's for that appearance.
|
|
68
74
|
const scheme = (basic) => {
|
|
@@ -79,7 +85,10 @@ export function weztermConfig(profile, { fontDirs = existsSync(TERMINAL_FONTS) ?
|
|
|
79
85
|
};
|
|
80
86
|
};
|
|
81
87
|
const table = (colors) => `{\n${Object.entries(colors).map(([key, value]) => ` ${key} = ${Array.isArray(value) ? `{ ${value.map(lua).join(', ')} }` : lua(value)},`).join('\n')}\n }`;
|
|
82
|
-
const families = [...new Set([profile?.font?.family
|
|
88
|
+
const families = mac ? [...new Set([profile?.font?.family ?? 'SF Mono Terminal', ...MAC_CASCADE])] : [];
|
|
89
|
+
// A row is AppKit's line height for the face (Terminal.app's), where WezTerm's is the face's ascent plus descent.
|
|
90
|
+
const font = profile?.font;
|
|
91
|
+
const rowScale = font?.lineHeight && font.ascender - font.descender > 0 ? font.lineHeight / (font.ascender - font.descender) : 1;
|
|
83
92
|
const opacity = stored.BackgroundColor?.[3] ?? 1;
|
|
84
93
|
const cursorShape = ['Block', 'Underline', 'Bar'][profile?.cursorType ?? 0] ?? 'Block';
|
|
85
94
|
const composed = !profile?.optionIsMeta;
|
|
@@ -91,10 +100,14 @@ export function weztermConfig(profile, { fontDirs = existsSync(TERMINAL_FONTS) ?
|
|
|
91
100
|
"local appearance = wezterm.gui and wezterm.gui.get_appearance() or 'Dark'",
|
|
92
101
|
"config.colors = appearance:find('Dark') and schemes.dark or schemes.light",
|
|
93
102
|
`config.font_dirs = { ${fontDirs.map(lua).join(', ')} }`,
|
|
94
|
-
`config.font = wezterm.font_with_fallback({ ${families.map(lua).join(', ')} })
|
|
103
|
+
...(families.length ? [`config.font = wezterm.font_with_fallback({ ${families.map(lua).join(', ')} })`] : []),
|
|
104
|
+
// CoreText draws glyphs unhinted; FreeType's default hinting snaps their outlines to the pixel grid.
|
|
105
|
+
"config.freetype_load_flags = 'NO_HINTING'",
|
|
106
|
+
// Box and block characters are the face's own glyphs, as CoreText draws them, not WezTerm's drawn lines.
|
|
107
|
+
'config.custom_block_glyphs = false',
|
|
95
108
|
`config.font_size = ${profile?.font?.size ?? TERMINAL_BASIC.fontSize}`,
|
|
96
109
|
`config.cell_width = ${profile?.widthSpacing ?? 1}`,
|
|
97
|
-
`config.line_height = ${profile?.heightSpacing ?? 1}`,
|
|
110
|
+
`config.line_height = ${Number(((profile?.heightSpacing ?? 1) * rowScale).toFixed(4))}`,
|
|
98
111
|
`config.default_cursor_style = ${lua(`${profile?.cursorBlink ? 'Blinking' : 'Steady'}${cursorShape}`)}`,
|
|
99
112
|
`config.send_composed_key_when_left_alt_is_pressed = ${composed}`,
|
|
100
113
|
`config.send_composed_key_when_right_alt_is_pressed = ${composed}`,
|