wherdr 1.2.0 → 1.3.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/.output/nitro.json +1 -1
- package/.output/public/_nuxt/{AgentView.DE2GDt4O.css → AgentView.C4YOwvZG.css} +1 -1
- package/.output/public/_nuxt/{BIA9pZvC.js → B6qBWHWB.js} +1 -1
- package/.output/public/_nuxt/BMIe8p_3.js +2 -0
- package/.output/public/_nuxt/BrAeJIZR.js +30 -0
- package/.output/public/_nuxt/C12eXl5z.js +1 -0
- package/.output/public/_nuxt/{DxO1TBoK.js → C2T9fQ4f.js} +1 -1
- package/.output/public/_nuxt/CYxHnMNH.js +83 -0
- package/.output/public/_nuxt/{D903WmCE.js → CctS2Xn6.js} +1 -1
- package/.output/public/_nuxt/{Bta8at9w.js → CiYar6hg.js} +1 -1
- package/.output/public/_nuxt/{CjKICX3g.js → Dwh-l2rQ.js} +11 -11
- package/.output/public/_nuxt/{e5N4AqCN.js → WLQjK8uJ.js} +41 -41
- package/.output/public/_nuxt/builds/latest.json +1 -1
- package/.output/public/_nuxt/builds/meta/6466b0ab-7935-460c-abdf-2ea632dae6d0.json +1 -0
- package/.output/public/_nuxt/{entry.SHBiCXBL.css → entry.cKR16VqG.css} +1 -1
- package/.output/public/_nuxt/whFLy_Ne.js +23 -0
- package/.output/public/sw.js +1 -1
- package/.output/server/chunks/_/branding.mjs +1 -1
- package/.output/server/chunks/_/plugins.mjs +10 -2
- package/.output/server/chunks/_/worktrees.mjs +1 -1
- package/.output/server/chunks/_/ws.mjs +1 -1
- package/.output/server/chunks/nitro/nitro.mjs +626 -436
- package/.output/server/chunks/raw/bump-homebrew.mjs +7 -0
- package/.output/server/chunks/raw/herdr-plugin.mjs +1 -1
- package/.output/server/chunks/routes/api/_..._.mjs +1 -0
- package/.output/server/chunks/routes/api/agents.post.mjs +1 -0
- package/.output/server/chunks/routes/api/ask-tab.post.mjs +1 -0
- package/.output/server/chunks/routes/api/attach.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/disable.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/lock-all.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/lock.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/login/options.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/login/verify.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/max-session.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/register/options.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/register/verify.post.mjs +1 -0
- package/.output/server/chunks/routes/api/auth/status.get.mjs +1 -0
- package/.output/server/chunks/routes/api/changes.get.mjs +1 -0
- package/.output/server/chunks/routes/api/chat/image.get.mjs +1 -0
- package/.output/server/chunks/routes/api/chat.get.mjs +1 -0
- package/.output/server/chunks/routes/api/choose.post.mjs +1 -0
- package/.output/server/chunks/routes/api/claude-statusline.post.mjs +1 -0
- package/.output/server/chunks/routes/api/close/status.get.mjs +1 -0
- package/.output/server/chunks/routes/api/close.post.mjs +1 -0
- package/.output/server/chunks/routes/api/codex-update.post.mjs +1 -0
- package/.output/server/chunks/routes/api/commands.get.mjs +1 -0
- package/.output/server/chunks/routes/api/config.get.mjs +1 -0
- package/.output/server/chunks/routes/api/dirs.get.mjs +1 -0
- package/.output/server/chunks/routes/api/dismiss.post.mjs +1 -0
- package/.output/server/chunks/routes/api/effort.post.mjs +1 -0
- package/.output/server/chunks/routes/api/efforts.get.mjs +1 -0
- package/.output/server/chunks/routes/api/file.post.mjs +1 -0
- package/.output/server/chunks/routes/api/gitroot.get.mjs +1 -0
- package/.output/server/chunks/routes/api/index.get.mjs +1 -0
- package/.output/server/chunks/routes/api/input.post.mjs +1 -0
- package/.output/server/chunks/routes/api/interrupt.post.mjs +1 -0
- package/.output/server/chunks/routes/api/isgit.get.mjs +1 -0
- package/.output/server/chunks/routes/api/machine/awake.get.mjs +1 -0
- package/.output/server/chunks/routes/api/machine/awake.post.mjs +1 -0
- package/.output/server/chunks/routes/api/machine/order.get.mjs +1 -0
- package/.output/server/chunks/routes/api/machine/order.post.mjs +1 -0
- package/.output/server/chunks/routes/api/machine/rename.post.mjs +1 -0
- package/.output/server/chunks/routes/api/menu.post.mjs +1 -0
- package/.output/server/chunks/routes/api/model.post.mjs +1 -0
- package/.output/server/chunks/routes/api/models.get.mjs +1 -0
- package/.output/server/chunks/routes/api/nav.post.mjs +1 -0
- package/.output/server/chunks/routes/api/onboarding.get.mjs +1 -0
- package/.output/server/chunks/routes/api/onboarding.post.mjs +1 -0
- package/.output/server/chunks/routes/api/phone.get.mjs +1 -0
- package/.output/server/chunks/routes/api/phone.post.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/actions.get.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/invoke.post.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/profiles.get.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/projects.get.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/projects.post.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/thread-limits.get.mjs +1 -0
- package/.output/server/chunks/routes/api/plugins/thread-limits.post.mjs +1 -0
- package/.output/server/chunks/routes/api/project/report.get.mjs +1 -0
- package/.output/server/chunks/routes/api/prompt.post.mjs +1 -0
- package/.output/server/chunks/routes/api/push/quiet.post.mjs +1 -0
- package/.output/server/chunks/routes/api/push/subscribe.post.mjs +1 -0
- package/.output/server/chunks/routes/api/push/test.post.mjs +1 -0
- package/.output/server/chunks/routes/api/push/unsubscribe.post.mjs +1 -0
- package/.output/server/chunks/routes/api/quotas.get.mjs +1 -0
- package/.output/server/chunks/routes/api/rename.post.mjs +1 -0
- package/.output/server/chunks/routes/api/requeue.post.mjs +1 -0
- package/.output/server/chunks/routes/api/restart.get.mjs +1 -0
- package/.output/server/chunks/routes/api/restart.post.mjs +1 -0
- package/.output/server/chunks/routes/api/reveal.post.mjs +1 -0
- package/.output/server/chunks/routes/api/screen-key.post.mjs +1 -0
- package/.output/server/chunks/routes/api/screen.get.mjs +8 -5
- package/.output/server/chunks/routes/api/search.get.mjs +2 -1
- package/.output/server/chunks/routes/api/seen.post.mjs +2 -1
- package/.output/server/chunks/routes/api/sessions.get.mjs +2 -1
- package/.output/server/chunks/routes/api/sessions.post.mjs +2 -1
- package/.output/server/chunks/routes/api/space.post.mjs +2 -1
- package/.output/server/chunks/routes/api/state.get.mjs +1 -0
- package/.output/server/chunks/routes/api/unqueue.post.mjs +2 -1
- package/.output/server/chunks/routes/api/update.get.mjs +3 -2
- package/.output/server/chunks/routes/api/upload.post.mjs +1 -0
- package/.output/server/chunks/routes/api/worktrees/remove.post.mjs +1 -0
- package/.output/server/chunks/routes/api/worktrees.get.mjs +1 -0
- package/.output/server/chunks/routes/favicon.ico.get.mjs +1 -0
- package/.output/server/chunks/routes/icons/_name_.get.mjs +2 -1
- package/.output/server/chunks/routes/renderer.mjs +3 -2
- package/.output/server/chunks/routes/uploads/_...name_.get.mjs +2 -1
- package/.output/server/chunks/routes/ws/_..._.mjs +2 -1
- package/.output/server/chunks/routes/ws/events.mjs +2 -1
- package/.output/server/chunks/routes/ws/mirror.mjs +1 -1
- package/.output/server/chunks/routes/ws/term.mjs +2 -96
- package/.output/server/chunks/virtual/precomputed.mjs +1 -1
- package/.output/server/index.mjs +2 -1
- package/.output/server/package.json +1 -1
- package/README.md +107 -23
- package/bin/lib/brew.mjs +86 -0
- package/bin/lib/commands.mjs +32 -8
- package/bin/lib/core.mjs +7 -2
- package/package.json +1 -1
- package/.output/public/_nuxt/BDI8xNSb.js +0 -2
- package/.output/public/_nuxt/BevNMnQ2.js +0 -83
- package/.output/public/_nuxt/CA9mI3eg.js +0 -23
- package/.output/public/_nuxt/DBu2-cEy.js +0 -30
- package/.output/public/_nuxt/DJE_XMLO.js +0 -1
- package/.output/public/_nuxt/builds/meta/211609c0-be04-46c5-a6b0-566bc0c4a3dd.json +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineApi, i as getQuery, P as PANE_RE, H as HerdrError, h as herdr } from '../../nitro/nitro.mjs';
|
|
1
|
+
import { a as defineApi, i as getQuery, P as PANE_RE, H as HerdrError, h as herdr, b7 as settingsTabs, b8 as tabsOfRow } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -63,13 +64,15 @@ const screen_get = defineApi(async (event) => {
|
|
|
63
64
|
if (!PANE_RE.test(pane)) throw new HerdrError("bad_pane", "Invalid pane");
|
|
64
65
|
const r = await herdr("pane.read", { pane_id: pane, source: "visible" }, 4e3);
|
|
65
66
|
const text = r.read && r.read.text || "";
|
|
67
|
+
const tabs = settingsTabs(text);
|
|
66
68
|
let tab = null;
|
|
67
|
-
if (
|
|
69
|
+
if (tabs) {
|
|
68
70
|
const a = await herdr("pane.read", { pane_id: pane, source: "visible", format: "ansi" }, 4e3).catch(() => null);
|
|
69
|
-
const line = String(a && a.read && a.read.text || "").split("\n").find((l) => l.
|
|
70
|
-
|
|
71
|
+
const line = String(a && a.read && a.read.text || "").split("\n").find((l) => tabsOfRow(l.replace(/\x1b\[[\d;]*m|\r/g, "")));
|
|
72
|
+
const hit = line ? activeTab(line) : null;
|
|
73
|
+
tab = hit && tabs.includes(hit) ? hit : null;
|
|
71
74
|
}
|
|
72
|
-
return { text, tab };
|
|
75
|
+
return { text, tabs, tab };
|
|
73
76
|
});
|
|
74
77
|
|
|
75
78
|
export { screen_get as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineApi, i as getQuery, aC as getState,
|
|
1
|
+
import { a as defineApi, i as getQuery, aC as getState, b9 as hasTranscript, n as machineOfPane, ba as SEARCH_DEADLINE_MS, bb as SEARCH_MAX_RESULTS, bc as spaceTitle } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineApi, P as PANE_RE, H as HerdrError,
|
|
1
|
+
import { a as defineApi, P as PANE_RE, H as HerdrError, bd as markSeen } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineApi, i as getQuery,
|
|
1
|
+
import { a as defineApi, i as getQuery, be as listSessions } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineApi, H as HerdrError,
|
|
1
|
+
import { a as defineApi, H as HerdrError, bf as openSession } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bg as PANE_DIRECTIONS, a5 as splitId, a4 as PANE_RE, a as defineApi, H as HerdrError, Q as log, p as poll, aB as herdrOn } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as defineApi, P as PANE_RE, H as HerdrError,
|
|
1
|
+
import { a as defineApi, P as PANE_RE, H as HerdrError, bh as cancelQueued } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bi as installMode, bj as updateCommand, bk as compareVersions, a as defineApi } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,11 +20,12 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
26
27
|
|
|
27
|
-
var version = "1.
|
|
28
|
+
var version = "1.3.1";
|
|
28
29
|
const pkg = {
|
|
29
30
|
version: version};
|
|
30
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defineEventHandler,
|
|
1
|
+
import { d as defineEventHandler, bq as getRouterParam } from '../../nitro/nitro.mjs';
|
|
2
2
|
import { s as serveBranding } from '../../_/branding.mjs';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
import 'node:https';
|
|
@@ -21,6 +21,7 @@ import 'web-push';
|
|
|
21
21
|
import 'node:os';
|
|
22
22
|
import 'node:child_process';
|
|
23
23
|
import 'node:net';
|
|
24
|
+
import 'node:readline';
|
|
24
25
|
import 'node:fs/promises';
|
|
25
26
|
import 'node:url';
|
|
26
27
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bz as useRuntimeConfig, bA as encodePath, bB as joinRelativeURL, bC as defineRenderHandler, i as getQuery, bD as createError, bE as destr, bF as getRouteRules, bG as relative, bH as joinURL, bI as getResponseStatusText, bJ as getResponseStatus, bK as useNitroApp } from '../nitro/nitro.mjs';
|
|
2
2
|
import { createHead as createHead$1, propsToString, renderSSRHead } from 'unhead/server';
|
|
3
3
|
import { isRef, toValue } from 'vue';
|
|
4
4
|
import { DeprecationsPlugin } from 'unhead/legacy';
|
|
@@ -26,6 +26,7 @@ import 'web-push';
|
|
|
26
26
|
import 'node:os';
|
|
27
27
|
import 'node:child_process';
|
|
28
28
|
import 'node:net';
|
|
29
|
+
import 'node:readline';
|
|
29
30
|
import 'node:fs/promises';
|
|
30
31
|
import 'node:url';
|
|
31
32
|
import '@simplewebauthn/server';
|
|
@@ -201,7 +202,7 @@ function encodeForwardSlashes(str) {
|
|
|
201
202
|
|
|
202
203
|
const renderSSRHeadOptions = {"omitLineBreaks":true};
|
|
203
204
|
|
|
204
|
-
const entryFileName = "
|
|
205
|
+
const entryFileName = "BrAeJIZR.js";
|
|
205
206
|
|
|
206
207
|
//#region src/runtime/handlers/renderer.ts
|
|
207
208
|
globalThis.__buildAssetsURL = buildAssetsURL;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as defineEventHandler,
|
|
1
|
+
import { d as defineEventHandler, bq as getRouterParam, br as readUpload, s as sendError, z as sendImage } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bs as defineWebSocketHandler } from '../../nitro/nitro.mjs';
|
|
2
2
|
import 'node:http';
|
|
3
3
|
import 'node:https';
|
|
4
4
|
import 'node:crypto';
|
|
@@ -20,6 +20,7 @@ import 'web-push';
|
|
|
20
20
|
import 'node:os';
|
|
21
21
|
import 'node:child_process';
|
|
22
22
|
import 'node:net';
|
|
23
|
+
import 'node:readline';
|
|
23
24
|
import 'node:fs/promises';
|
|
24
25
|
import 'node:url';
|
|
25
26
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bs as defineWebSocketHandler, bt as eventClients, P as PANE_RE, bu as getStateJson } from '../../nitro/nitro.mjs';
|
|
2
2
|
import { u as unwatchPeer, m as messageText, w as watchPeer, i as isOpen, c as checkUpgrade } from '../../_/ws.mjs';
|
|
3
3
|
import 'node:http';
|
|
4
4
|
import 'node:https';
|
|
@@ -21,6 +21,7 @@ import 'web-push';
|
|
|
21
21
|
import 'node:os';
|
|
22
22
|
import 'node:child_process';
|
|
23
23
|
import 'node:net';
|
|
24
|
+
import 'node:readline';
|
|
24
25
|
import 'node:fs/promises';
|
|
25
26
|
import 'node:url';
|
|
26
27
|
import '@simplewebauthn/server';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as PANE_RE, n as machineOfPane, o as fmt, h as herdr, aC as getState,
|
|
1
|
+
import { P as PANE_RE, n as machineOfPane, o as fmt, h as herdr, aC as getState, bx as mirrorSize, a5 as splitId, Q as log, bs as defineWebSocketHandler } from '../../nitro/nitro.mjs';
|
|
2
2
|
import { u as unwatchPeer, m as messageText, w as watchPeer, c as checkUpgrade, i as isOpen } from '../../_/ws.mjs';
|
|
3
3
|
import readline from 'node:readline';
|
|
4
4
|
import 'node:http';
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { bs as defineWebSocketHandler, by as openTerm } from '../../nitro/nitro.mjs';
|
|
2
2
|
import { u as unwatchPeer, m as messageText, w as watchPeer, c as checkUpgrade, i as isOpen } from '../../_/ws.mjs';
|
|
3
|
-
import readline from 'node:readline';
|
|
4
3
|
import 'node:http';
|
|
5
4
|
import 'node:https';
|
|
6
5
|
import 'node:crypto';
|
|
@@ -22,104 +21,11 @@ import 'web-push';
|
|
|
22
21
|
import 'node:os';
|
|
23
22
|
import 'node:child_process';
|
|
24
23
|
import 'node:net';
|
|
24
|
+
import 'node:readline';
|
|
25
25
|
import 'node:fs/promises';
|
|
26
26
|
import 'node:url';
|
|
27
27
|
import '@simplewebauthn/server';
|
|
28
28
|
|
|
29
|
-
const clampInt = (v, lo, hi, dflt) => {
|
|
30
|
-
const n = parseInt(String(v), 10);
|
|
31
|
-
return Number.isFinite(n) ? Math.min(hi, Math.max(lo, n)) : dflt;
|
|
32
|
-
};
|
|
33
|
-
function openTerm(ws, url) {
|
|
34
|
-
const pane = url.searchParams.get("pane") || "";
|
|
35
|
-
if (!PANE_RE.test(pane)) {
|
|
36
|
-
ws.close(4400, "Invalid pane");
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
const machine = machineOfPane(pane);
|
|
40
|
-
if (!machine || !machine.sock()) {
|
|
41
|
-
ws.send(JSON.stringify({ type: "terminal.closed", reason: machine ? fmt("{machine} is unreachable", { machine: machine.label }) : "unknown machine", code: machine ? "unreachable" : "unknown_machine", machine: machine == null ? void 0 : machine.label }));
|
|
42
|
-
ws.close(4503, "machine unreachable");
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const cols = clampInt(url.searchParams.get("cols"), 10, 400, 80);
|
|
46
|
-
const rows = clampInt(url.searchParams.get("rows"), 5, 200, 24);
|
|
47
|
-
const args = ["terminal", "session", "control", splitId(pane).local, "--cols", String(cols), "--rows", String(rows)];
|
|
48
|
-
if (url.searchParams.get("takeover") === "1") args.push("--takeover");
|
|
49
|
-
const child = machine.spawnHerdr(args);
|
|
50
|
-
const sess = { pane, visible: true };
|
|
51
|
-
termSessions.add(sess);
|
|
52
|
-
log(`term ${pane} opened ${cols}x${rows}${args.includes("--takeover") ? " (takeover)" : ""}${machine.local ? "" : ` on ${machine.label}`}`);
|
|
53
|
-
readline.createInterface({ input: child.stdout }).on("line", (line) => {
|
|
54
|
-
if (ws.isOpen()) ws.send(line);
|
|
55
|
-
});
|
|
56
|
-
readline.createInterface({ input: child.stderr }).on("line", (line) => {
|
|
57
|
-
log(`term ${pane} stderr: ${line}`);
|
|
58
|
-
if (ws.isOpen()) ws.send(JSON.stringify({ type: "herdr.stderr", message: line }));
|
|
59
|
-
});
|
|
60
|
-
child.on("error", (e) => {
|
|
61
|
-
if (ws.isOpen()) ws.send(JSON.stringify({ type: "terminal.closed", reason: `herdr: ${e.message}` }));
|
|
62
|
-
ws.close(4500, "herdr error");
|
|
63
|
-
});
|
|
64
|
-
child.on("exit", (code) => {
|
|
65
|
-
termSessions.delete(sess);
|
|
66
|
-
if (ws.isOpen()) ws.close(4e3, `herdr exit ${code}`);
|
|
67
|
-
});
|
|
68
|
-
child.stdin.on("error", () => {
|
|
69
|
-
});
|
|
70
|
-
const toChild = (obj) => {
|
|
71
|
-
if (child.stdin.writable) child.stdin.write(JSON.stringify(obj) + "\n");
|
|
72
|
-
};
|
|
73
|
-
return {
|
|
74
|
-
onMessage(raw) {
|
|
75
|
-
let m;
|
|
76
|
-
try {
|
|
77
|
-
m = JSON.parse(raw);
|
|
78
|
-
} catch {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
switch (m && m.type) {
|
|
82
|
-
case "terminal.input":
|
|
83
|
-
if (typeof m.text === "string" && m.text.length <= 65536) toChild({ type: "terminal.input", text: m.text });
|
|
84
|
-
else if (typeof m.bytes === "string" && m.bytes.length <= 9e4) toChild({ type: "terminal.input", bytes: m.bytes });
|
|
85
|
-
break;
|
|
86
|
-
case "terminal.resize":
|
|
87
|
-
toChild({ type: "terminal.resize", cols: clampInt(m.cols, 10, 400, cols), rows: clampInt(m.rows, 5, 200, rows) });
|
|
88
|
-
break;
|
|
89
|
-
case "terminal.scroll":
|
|
90
|
-
if (m.direction === "up" || m.direction === "down") {
|
|
91
|
-
toChild({ type: "terminal.scroll", direction: m.direction, lines: clampInt(m.lines, 1, 500, 3) });
|
|
92
|
-
}
|
|
93
|
-
break;
|
|
94
|
-
case "keys":
|
|
95
|
-
if (Array.isArray(m.keys) && m.keys.length <= 32 && m.keys.every((k) => typeof k === "string" && k.length <= 24)) {
|
|
96
|
-
herdr("pane.send_input", { pane_id: pane, keys: m.keys }).catch((e) => ws.isOpen() && ws.send(JSON.stringify({ type: "web.error", code: e.code, message: e.message })));
|
|
97
|
-
}
|
|
98
|
-
break;
|
|
99
|
-
// Pasted text, as Herdr's pane input: omp receives it as a paste and
|
|
100
|
-
// turns an image path into an image (typed through wherdr's xterm, which
|
|
101
|
-
// never learns the program's bracketed paste mode, it stays text).
|
|
102
|
-
case "paste":
|
|
103
|
-
if (typeof m.text === "string" && m.text && m.text.length <= 65536) {
|
|
104
|
-
herdr("pane.send_input", { pane_id: pane, text: m.text }).catch((e) => ws.isOpen() && ws.send(JSON.stringify({ type: "web.error", code: e.code, message: e.message })));
|
|
105
|
-
}
|
|
106
|
-
break;
|
|
107
|
-
case "visibility":
|
|
108
|
-
sess.visible = Boolean(m.visible);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
onClose() {
|
|
113
|
-
termSessions.delete(sess);
|
|
114
|
-
toChild({ type: "terminal.release" });
|
|
115
|
-
child.stdin.end();
|
|
116
|
-
setTimeout(() => {
|
|
117
|
-
if (child.exitCode === null) child.kill("SIGTERM");
|
|
118
|
-
}, 1500);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
29
|
const sessions = /* @__PURE__ */ new Map();
|
|
124
30
|
const term = defineWebSocketHandler({
|
|
125
31
|
upgrade: (request) => checkUpgrade(request),
|