@william_jin/autobrowse 0.8.25 → 0.8.27
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/assets/live-view/hub.html +68 -47
- package/assets/live-view/viewer.html +292 -21
- package/assets/overlay/bin/win32-arm64/overlay-host.exe +0 -0
- package/assets/overlay/bin/win32-x64/overlay-host.exe +0 -0
- package/dist/app/cli-record.js +17 -6
- package/dist/app/cli-record.js.map +1 -1
- package/dist/app/cli-task.d.ts +25 -0
- package/dist/app/cli-task.js +156 -0
- package/dist/app/cli-task.js.map +1 -0
- package/dist/app/config.d.ts +0 -1
- package/dist/app/config.js +1 -1
- package/dist/app/config.js.map +1 -1
- package/dist/app/help.js +1 -0
- package/dist/app/help.js.map +1 -1
- package/dist/app/task.d.ts +182 -0
- package/dist/app/task.js +382 -0
- package/dist/app/task.js.map +1 -0
- package/dist/browser/live-term.d.ts +78 -0
- package/dist/browser/live-term.js +341 -0
- package/dist/browser/live-term.js.map +1 -0
- package/dist/browser/live-view.d.ts +3 -0
- package/dist/browser/live-view.js +92 -11
- package/dist/browser/live-view.js.map +1 -1
- package/dist/explore/commands.d.ts +11 -8
- package/dist/explore/commands.js +3 -0
- package/dist/explore/commands.js.map +1 -1
- package/dist/explore/server.d.ts +8 -0
- package/dist/explore/server.js +23 -3
- package/dist/explore/server.js.map +1 -1
- package/dist/llms.txt +2 -1
- package/package.json +7 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en" data-theme="dark">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="utf-8">
|
|
5
|
-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src ws://127.0.0.1:*; frame-src about:">
|
|
5
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src ws://127.0.0.1:*; frame-src about:">
|
|
6
6
|
<title>autobrowse</title>
|
|
7
7
|
<!-- The live view's page (designs/2026-11-25-live-view.md), in the `overlay-host live` window. Talks only to its session's socket. -->
|
|
8
8
|
<script>
|
|
@@ -88,7 +88,7 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:defa
|
|
|
88
88
|
#ov{position:absolute;left:0;top:0;border:0;background:transparent;pointer-events:none;transform-origin:0 0;color-scheme:normal}
|
|
89
89
|
#ov.off{display:none}
|
|
90
90
|
#sink{position:absolute;left:0;top:0;width:1px;height:1px;opacity:0;border:0;padding:0;resize:none;pointer-events:none}
|
|
91
|
-
#app{height:100%;display:flex
|
|
91
|
+
#app{position:relative;height:100%;display:flex}
|
|
92
92
|
.cover{position:absolute;inset:0;z-index:4;display:grid;place-items:center;background:var(--bg);color:var(--mut);font-size:14px;transition:opacity .15s}
|
|
93
93
|
.cv{display:flex;flex-direction:column;align-items:center;gap:14px;text-align:center;padding:0 24px}
|
|
94
94
|
.mk{display:block;color:var(--mki)}
|
|
@@ -174,6 +174,58 @@ kbd{min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--
|
|
|
174
174
|
#acctl .u{overflow-wrap:anywhere;font-weight:500}
|
|
175
175
|
#acctl .kk{display:flex;flex-wrap:wrap;column-gap:6px;align-items:baseline;color:var(--mut);font-size:12px;overflow-wrap:anywhere}
|
|
176
176
|
#acctl .own{color:var(--ring);font-size:11px;font-weight:600}
|
|
177
|
+
/* the Claude terminal (designs/2026-12-01-agent-task.md §The terminal in the hub): dark in both looks, as Claude Code's own theme */
|
|
178
|
+
#web{flex:1;min-width:0;display:flex;flex-direction:column}
|
|
179
|
+
#term{--tbg:#121215;--tfg:#f2f2f2;--tmut:#9a9aa2;--th:rgba(255,255,255,.07);--th2:rgba(255,255,255,.12);--tring:#7f9dff;--tdot:#8aa8ff;--tshadow:rgba(0,0,0,.28);color-scheme:dark;position:relative;display:none;flex-direction:column;min-width:0;background:var(--tbg);color:var(--tfg)}
|
|
180
|
+
.term.tdock #term{display:flex;flex:none;width:var(--tw,40%);min-width:420px;max-width:calc(100% - 360px)}
|
|
181
|
+
#tdiv{display:none;flex:none;position:relative;width:1px;height:auto;margin:0;border:0;background:var(--line);cursor:col-resize;touch-action:none;outline:none}
|
|
182
|
+
#tdiv::before{content:"";position:absolute;inset:0 -4px;z-index:2}
|
|
183
|
+
#tdiv::after{content:"";position:absolute;inset:0 -1px;background:var(--ring);opacity:0;transition:opacity .12s}
|
|
184
|
+
#tdiv:hover::after,#tdiv:focus-visible::after,.tdrag #tdiv::after{opacity:1}
|
|
185
|
+
.term.tdock #tdiv{display:block}
|
|
186
|
+
#thd{flex:none;height:40px;display:flex;align-items:center;gap:8px;padding:0 6px 0 14px;font-size:13px}
|
|
187
|
+
#thd .tl{font-weight:600}
|
|
188
|
+
#tname{flex:1;min-width:0;color:var(--tmut);font:12px/1 "SF Mono",ui-monospace,Menlo,monospace;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
189
|
+
.tb{flex:none;height:28px;min-width:28px;display:flex;align-items:center;justify-content:center;gap:6px;padding:0 8px;border-radius:7px;color:var(--tmut);font-size:12px;font-weight:500;white-space:nowrap;transition:background-color .12s,color .12s}
|
|
190
|
+
.tb:hover{background:var(--th);color:var(--tfg)}
|
|
191
|
+
.tb:disabled{background:none;color:var(--tmut);cursor:default;opacity:.35;pointer-events:none}
|
|
192
|
+
.tb:focus-visible,#tstrip:focus-visible{outline:2px solid var(--tring);outline-offset:-2px}
|
|
193
|
+
.tic{width:14px;height:14px}
|
|
194
|
+
#tgho .gl{transition:opacity .12s}
|
|
195
|
+
#tbody{position:relative;flex:1;min-height:0;padding:2px 0 6px 12px}
|
|
196
|
+
#xt{position:absolute;inset:2px 4px 6px 12px}
|
|
197
|
+
#xt .xterm{height:100%}
|
|
198
|
+
/* xterm.css paints the viewport #000: the row remainder showed as a black band */
|
|
199
|
+
#xt .xterm-viewport{scrollbar-width:none;background-color:var(--tbg)}
|
|
200
|
+
#tcov{position:absolute;inset:0;z-index:2;display:grid;place-items:center;background:var(--tbg);color:var(--tmut);text-align:center;padding:0 24px;transition:opacity .15s}
|
|
201
|
+
#tcov.hide{opacity:0;pointer-events:none}
|
|
202
|
+
#tcov .cv{gap:12px}
|
|
203
|
+
#tcov.wait #tct{animation:breathe 1.6s ease-in-out infinite}
|
|
204
|
+
#tcov.ended{background:color-mix(in srgb,var(--tbg) 82%,transparent)}
|
|
205
|
+
#tcov .btn{background:var(--th);color:var(--tfg)}
|
|
206
|
+
#tcov .btn:hover{background:var(--th2)}
|
|
207
|
+
.tdrag,.tdrag *{cursor:col-resize}
|
|
208
|
+
.tdrag #stage,.tdrag #tbody{pointer-events:none}
|
|
209
|
+
/* Split, Grid, a narrow pane: the strip under the stream; the drawer over the pane */
|
|
210
|
+
#tstrip{display:none;flex:none;height:46px;align-items:center;gap:12px;padding:0 12px;background:var(--on);border-top:1px solid var(--line);text-align:left;transition:background-color .12s}
|
|
211
|
+
#tstrip:hover{background:color-mix(in srgb,var(--fg) 4%,var(--on))}
|
|
212
|
+
.term.tdrawer #tstrip{display:flex}
|
|
213
|
+
#tstrip .tl{flex:none;display:flex;align-items:center;gap:7px;font-size:12px;font-weight:600}
|
|
214
|
+
.tdot{flex:none;width:7px;height:7px;border-radius:50%;background:var(--brand)}
|
|
215
|
+
.tend .tdot{background:var(--mut)}
|
|
216
|
+
#term .tdot{background:var(--tdot)}
|
|
217
|
+
#term.tend .tdot,#term.tfail .tdot{background:var(--tmut)}
|
|
218
|
+
#tlines{flex:1;min-width:0;display:flex;flex-direction:column;font:12px/16px "SF Mono",ui-monospace,Menlo,monospace}
|
|
219
|
+
#tlines span{white-space:pre;overflow:hidden;text-overflow:ellipsis}
|
|
220
|
+
#tlines span:first-child:not(:last-child){color:var(--mut)}
|
|
221
|
+
.tkey{flex:none;min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--kbd);color:var(--mut);font:500 12px/22px -apple-system,system-ui,sans-serif;text-align:center}
|
|
222
|
+
.term.tdrawer #term{display:flex;position:absolute;z-index:10;top:0;right:0;bottom:0;width:min(560px,calc(100% - 40px));box-shadow:-12px 0 40px var(--tshadow);transform:translateX(calc(100% + 40px));visibility:hidden;transition:transform .16s cubic-bezier(.4,0,1,1),visibility 0s .16s}
|
|
223
|
+
.term.tdrawer.topen #term{transform:none;visibility:visible;transition:transform .2s cubic-bezier(.16,1,.3,1)}
|
|
224
|
+
#tscrim{display:none;position:absolute;inset:0;z-index:9;background:var(--scrim);opacity:0;pointer-events:none;transition:opacity .16s}
|
|
225
|
+
.term.tdrawer #tscrim{display:block}
|
|
226
|
+
.term.tdrawer.topen #tscrim{opacity:1;pointer-events:auto;transition-duration:.2s}
|
|
227
|
+
.nb[aria-pressed=true]{background:var(--tabh);color:var(--fg)}
|
|
228
|
+
@media (prefers-reduced-motion:reduce){.term.tdrawer #term,.term.tdrawer.topen #term{transform:none;opacity:0;transition:opacity .15s,visibility 0s .15s}.term.tdrawer.topen #term{opacity:1;transition:opacity .15s}#tcov.wait #tct{animation:none}}
|
|
177
229
|
@media (prefers-reduced-motion:reduce){#acct,#acct.on,#acctl,#acct.open #acctl{transform:none}#acctb .asp{animation:none}#sug{transform:none}#sheet .s{transform:none;transition:none}#field.loading #prog{animation:none;width:100%;transform:none;opacity:.5}.tab .sp,#agent .dot,.cover.wait .mk{animation:none}}
|
|
178
230
|
@media (max-width:520px){#field{min-width:40px}.tab{min-width:90px}#agent .lbl{display:none}#agent.on{padding:0 6px 0 8px}}
|
|
179
231
|
</style>
|
|
@@ -181,6 +233,7 @@ kbd{min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--
|
|
|
181
233
|
<body>
|
|
182
234
|
<svg width="0" height="0" style="position:absolute" aria-hidden="true"><symbol id="mark" viewBox="0 0 100 100"><g stroke-linecap="round" stroke-linejoin="round"><path d="M27.0 3.2C28.3 3.0 30.0 3.1 31.5 3.0C33.0 2.9 34.5 2.8 36.0 2.7C37.5 2.6 39.0 2.5 40.5 2.4C42.0 2.3 43.5 2.2 45.0 2.2C46.5 2.1 48.0 2.2 49.5 2.2C51.0 2.2 52.5 2.3 54.0 2.4C55.5 2.5 57.0 2.6 58.5 2.7C60.0 2.8 61.5 3.0 63.0 3.1C64.5 3.1 66.0 3.2 67.5 3.3C69.0 3.3 70.5 3.3 72.0 3.3C73.5 3.3 75.0 3.3 76.5 3.2C78.0 3.2 79.7 3.1 81.0 3.2C82.3 3.3 83.3 3.4 84.4 3.9C85.4 4.3 86.4 5.1 87.1 5.9C87.8 6.7 88.4 7.7 88.8 8.8C89.2 9.8 89.2 10.9 89.3 12.1C89.4 13.2 89.3 14.5 89.4 15.7C89.4 16.9 89.5 18.1 89.6 19.3C89.8 20.6 89.9 21.8 90.0 23.0C90.2 24.2 90.3 25.4 90.4 26.7C90.5 27.9 90.6 29.1 90.7 30.3C90.7 31.6 90.7 32.8 90.7 34.0C90.7 35.2 90.6 36.4 90.6 37.7C90.5 38.9 90.4 40.1 90.4 41.3C90.3 42.6 90.4 43.8 90.2 45.0C90.1 46.2 89.9 47.4 89.5 48.5C89.0 49.6 88.3 50.7 87.5 51.5C86.7 52.3 85.6 53.1 84.5 53.5C83.5 54.0 82.4 54.1 81.0 54.2C79.7 54.3 78.0 54.1 76.5 54.0C75.0 53.9 73.5 53.8 72.0 53.7C70.5 53.6 69.0 53.5 67.5 53.4C66.0 53.3 64.5 53.2 63.0 53.2C61.5 53.1 60.0 53.2 58.5 53.2C57.0 53.2 55.5 53.3 54.0 53.4C52.5 53.5 51.0 53.6 49.5 53.7C48.0 53.8 46.5 54.0 45.0 54.1C43.5 54.1 42.0 54.2 40.5 54.3C39.0 54.3 37.5 54.3 36.0 54.3C34.5 54.3 33.0 54.3 31.5 54.2C30.0 54.2 28.3 54.3 27.0 54.2C25.6 54.1 24.6 54.0 23.5 53.5C22.4 53.1 21.3 52.4 20.4 51.6C19.5 50.8 18.7 49.8 18.2 48.7C17.7 47.6 17.5 46.3 17.3 45.1C17.2 43.8 17.3 42.6 17.4 41.3C17.4 40.1 17.5 38.9 17.6 37.7C17.8 36.4 17.9 35.2 18.0 34.0C18.2 32.8 18.3 31.6 18.4 30.3C18.5 29.1 18.6 27.9 18.7 26.7C18.7 25.4 18.7 24.2 18.7 23.0C18.7 21.8 18.6 20.6 18.6 19.3C18.5 18.1 18.4 16.9 18.4 15.7C18.3 14.4 18.1 13.2 18.2 12.0C18.3 10.8 18.4 9.7 18.8 8.6C19.3 7.6 20.0 6.6 20.8 5.8C21.6 5.0 22.6 4.3 23.6 3.9C24.7 3.5 25.7 3.3 27.0 3.2Z" style="fill:var(--mkf)" stroke="currentColor" stroke-width="3.62"/><path d="M18.1 12.8C19.4 12.7 20.9 12.8 22.3 12.8C23.8 12.8 25.2 12.7 26.7 12.6C28.1 12.6 29.6 12.5 31.0 12.4C32.4 12.3 33.9 12.3 35.3 12.2C36.8 12.2 38.2 12.2 39.7 12.2C41.1 12.2 42.6 12.2 44.0 12.3C45.4 12.3 46.9 12.3 48.3 12.3C49.8 12.3 51.2 12.3 52.7 12.2C54.1 12.2 55.6 12.1 57.0 12.0C58.4 11.9 59.9 11.7 61.3 11.6C62.8 11.5 64.2 11.3 65.7 11.2C67.1 11.1 68.7 10.9 70.1 11.0C71.5 11.1 72.9 11.3 74.2 11.9C75.4 12.5 76.7 13.4 77.5 14.5C78.4 15.5 79.1 16.8 79.5 18.1C79.9 19.3 79.9 20.6 79.9 22.0C80.0 23.4 79.8 25.0 79.7 26.4C79.7 27.9 79.7 29.4 79.7 30.9C79.7 32.4 79.7 33.9 79.7 35.3C79.8 36.8 79.8 38.3 79.8 39.8C79.8 41.3 79.8 42.7 79.7 44.2C79.7 45.7 79.6 47.2 79.5 48.7C79.5 50.1 79.4 51.6 79.3 53.1C79.3 54.6 79.2 56.1 79.2 57.6C79.2 59.0 79.3 60.6 79.3 61.9C79.2 63.3 79.2 64.5 78.9 65.7C78.5 66.9 77.9 68.1 77.1 69.1C76.3 70.1 75.2 71.1 74.0 71.7C72.8 72.3 71.5 72.6 70.1 72.8C68.7 72.9 67.1 72.8 65.7 72.8C64.2 72.8 62.8 72.7 61.3 72.6C59.9 72.6 58.4 72.5 57.0 72.4C55.6 72.3 54.1 72.3 52.7 72.2C51.2 72.2 49.8 72.2 48.3 72.2C46.9 72.2 45.4 72.2 44.0 72.3C42.6 72.3 41.1 72.3 39.7 72.3C38.2 72.3 36.8 72.3 35.3 72.2C33.9 72.2 32.4 72.1 31.0 72.0C29.6 71.9 28.1 71.7 26.7 71.6C25.2 71.5 23.8 71.3 22.3 71.2C20.9 71.1 19.4 71.2 18.1 71.0C16.8 70.9 15.6 70.8 14.5 70.4C13.4 70.0 12.3 69.4 11.4 68.6C10.5 67.8 9.6 66.8 9.0 65.7C8.4 64.6 8.1 63.4 7.9 62.0C7.7 60.6 7.8 59.0 7.7 57.6C7.7 56.1 7.7 54.6 7.7 53.1C7.7 51.6 7.7 50.1 7.7 48.7C7.8 47.2 7.8 45.7 7.8 44.2C7.8 42.7 7.8 41.3 7.7 39.8C7.7 38.3 7.6 36.8 7.5 35.3C7.5 33.9 7.4 32.4 7.3 30.9C7.3 29.4 7.2 27.9 7.2 26.4C7.2 25.0 7.1 23.3 7.3 21.9C7.5 20.5 7.8 19.2 8.4 18.0C9.0 16.9 10.0 15.8 11.0 15.0C12.0 14.2 13.2 13.6 14.4 13.2C15.5 12.9 16.7 12.8 18.1 12.8Z" style="fill:var(--mkf)" stroke="currentColor" stroke-width="4.7"/><circle cx="18.0" cy="21" r="2.6" style="fill:none" stroke="currentColor" stroke-width="2.4"/><circle cx="25.5" cy="21" r="2.6" style="fill:none" stroke="currentColor" stroke-width="2.4"/><circle cx="33.0" cy="21" r="2.6" style="fill:none" stroke="currentColor" stroke-width="2.4"/><path d="M40.0 21.2C41.2 21.1 45.0 20.7 47.5 20.8C50.0 20.8 52.5 21.2 55.0 21.2C57.5 21.2 60.0 21.0 62.5 20.9C65.0 20.9 68.8 20.9 70.0 20.9" style="fill:none" stroke="currentColor" stroke-width="3.38"/><path d="M8.0 29.1C9.2 29.0 12.8 28.6 15.2 28.6C17.6 28.6 20.0 29.0 22.4 29.1C24.8 29.2 27.2 29.2 29.6 29.2C32.0 29.2 34.4 29.1 36.8 29.0C39.2 28.9 41.6 28.8 44.0 28.8C46.4 28.8 48.8 28.8 51.2 28.9C53.6 29.0 56.0 29.4 58.4 29.4C60.8 29.4 63.2 29.0 65.6 28.9C68.0 28.7 70.4 28.5 72.8 28.6C75.2 28.7 78.8 29.3 80.0 29.4" style="fill:none" stroke="currentColor" stroke-width="3.38"/><path d="M45 50H37M47.6 43.6L41.6 37.6M54 41V35" style="fill:none;stroke:var(--mkt)" stroke-width="4.5" /><path d="M54.0 50.0Q53.3 70.0 54.0 90.0Q58.4 85.3 63.3 81.3Q66.3 89.0 70.3 96.3Q73.9 94.4 77.7 93.1Q74.7 85.7 70.7 78.7Q76.8 78.4 83.0 79.0Q69.0 64.0 54.0 50.0Z" style="fill:var(--mkf)" stroke="currentColor" stroke-width="4.2"/></g></symbol></svg>
|
|
183
235
|
<div id="app">
|
|
236
|
+
<div id="web">
|
|
184
237
|
<div id="top">
|
|
185
238
|
<div id="strip"><div id="tabs" role="tablist"></div><button type="button" id="newtab" title="New tab (⌘T)" aria-label="New tab (⌘T)"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M8 3v10M3 8h10"/></svg></button></div>
|
|
186
239
|
<div id="nav">
|
|
@@ -190,6 +243,7 @@ kbd{min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--
|
|
|
190
243
|
<div id="field"><span id="lock" aria-hidden="true"></span><input id="url" spellcheck="false" autocomplete="off" aria-label="Address" placeholder="Search or enter an address" role="combobox" aria-autocomplete="both" aria-controls="sug" aria-expanded="false"><span id="disp" aria-hidden="true"></span><span id="prog"></span></div>
|
|
191
244
|
<span id="ro" hidden title="A run you watch: it keeps its own size and input"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/></svg>View only</span>
|
|
192
245
|
<button type="button" id="agent" aria-label="Pause the agent (⌃⌥P)" title="Pause the agent (⌃⌥P)"><span class="dot"></span><span class="lbl">Agent working</span><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M6 4v8M10 4v8"/></svg></button>
|
|
246
|
+
<button type="button" class="nb" id="tbtn" hidden aria-pressed="false" title="Claude terminal (⌘J)" aria-label="Claude terminal (⌘J)" aria-controls="term"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><rect x="1.5" y="2.5" width="13" height="11" rx="2"/><path d="M10 2.5v11"/></svg></button>
|
|
193
247
|
<button type="button" class="nb" id="win" title="Open in a window (⌘⇧O)" aria-label="Open in a window (⌘⇧O)"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M9 2.5h4.5V7M13.5 2.5 8 8M11.5 9.5v3a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3"/></svg></button>
|
|
194
248
|
<button type="button" class="nb" id="keys" title="Keyboard shortcuts (⌘/)" aria-label="Keyboard shortcuts (⌘/)"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><rect x="1.5" y="4" width="13" height="8.5" rx="1.5"/><path d="M4.5 7h.01M7 7h.01M9.5 7h.01M12 7h.01M5 10h6"/></svg></button>
|
|
195
249
|
</div>
|
|
@@ -203,6 +257,14 @@ kbd{min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--
|
|
|
203
257
|
<div id="notes"></div>
|
|
204
258
|
<div id="acct"><button type="button" id="acctb" aria-haspopup="menu" aria-expanded="false" aria-controls="acctl"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><circle cx="5.5" cy="10.5" r="3"/><path d="m7.6 8.4 5.9-5.9M11 5l1.8 1.8"/></svg><span class="asp" aria-hidden="true"></span><span id="acctt">Sign in</span></button><div id="acctl" role="menu" aria-label="Saved accounts"></div></div>
|
|
205
259
|
</div>
|
|
260
|
+
<button type="button" id="tstrip" aria-controls="term" aria-expanded="false" title="Open the Claude terminal (⌘J)"><span class="tl"><span class="tdot"></span>Claude</span><span id="tlines"></span><span class="tkey" aria-hidden="true">⌘J</span></button>
|
|
261
|
+
</div>
|
|
262
|
+
<hr id="tdiv" aria-orientation="vertical" aria-label="Terminal width" aria-controls="term" aria-valuenow="0" aria-valuemin="420" aria-valuemax="4000" tabindex="0">
|
|
263
|
+
<div id="tscrim"></div>
|
|
264
|
+
<aside id="term" aria-label="Claude terminal">
|
|
265
|
+
<div id="thd"><span class="tdot"></span><span class="tl">Claude</span><span id="tname"></span><button type="button" class="tb" id="tgho" title="Attach this session in a Ghostty window"><svg class="ic tic" aria-hidden="true" viewBox="0 0 16 16"><path d="M9 2.5h4.5V7M13.5 2.5 8 8M11.5 9.5v3a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3"/></svg><span class="gl">Open in Ghostty</span></button><button type="button" class="tb" id="thide" title="Hide (⌘J)" aria-label="Hide the terminal (⌘J)"><svg class="ic tic" aria-hidden="true" viewBox="0 0 16 16"><rect x="1.5" y="2.5" width="13" height="11" rx="2"/><path d="M10 2.5v11"/></svg></button></div>
|
|
266
|
+
<div id="tbody"><div id="xt"></div><div id="tcov" class="wait"><div class="cv"><span id="tct">Connecting</span><button type="button" class="btn" id="tretry" hidden>Retry</button></div></div></div>
|
|
267
|
+
</aside>
|
|
206
268
|
</div>
|
|
207
269
|
<div id="sug" role="listbox" aria-label="Suggestions"></div>
|
|
208
270
|
<script>
|
|
@@ -217,13 +279,14 @@ const host = (m) => { try { window.webkit.messageHandlers.ipc.postMessage(JSON.s
|
|
|
217
279
|
const hub = (m) => { if (embed) parent.postMessage({ ab: m }, '*'); };
|
|
218
280
|
let ws = null, view = { w: 0, h: 0 }, fixed = false, tabs = [], shownTab = null, canWindow = false, gone = false, readOnly = false;
|
|
219
281
|
// a pane waits for the hub's first word: tile or not, on screen or not
|
|
220
|
-
let tile = false,
|
|
282
|
+
let tile = false, floor = null, zoomed = false, onScreen = !embed, placed = !embed, inPane = false, wantUrl = false, hubKeys = [];
|
|
221
283
|
if (embed) document.documentElement.classList.add('embed');
|
|
222
284
|
// the page sits 1:1 in CSS px, top left; a fixed device viewport is centred; a hub tile scales it down to fit
|
|
223
|
-
// a run's fixed viewport scales down too: never cropped
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
285
|
+
// a run's fixed viewport scales down too: never cropped; so does a page held at the floor (`zoomed`)
|
|
286
|
+
const scaled = () => tile || zoomed;
|
|
287
|
+
const zs = () => ((scaled() || fixed) && view.w && view.h ? Math.min(1, stage.clientWidth / view.w, stage.clientHeight / view.h) : 1);
|
|
288
|
+
const ox = () => (scaled() || fixed ? Math.max(0, Math.round((stage.clientWidth - view.w * zs()) / 2)) : 0);
|
|
289
|
+
const oy = () => (scaled() ? Math.max(0, Math.round((stage.clientHeight - view.h * zs()) / 2)) : 0);
|
|
227
290
|
|
|
228
291
|
// --- socket ---------------------------------------------------------------------
|
|
229
292
|
const tx = (m) => { if (ws && ws.readyState === 1) ws.send(JSON.stringify(m)); };
|
|
@@ -232,7 +295,7 @@ function connect() {
|
|
|
232
295
|
ws.binaryType = 'arraybuffer';
|
|
233
296
|
ws.onopen = () => { if (own) tx({ t: 'own' }); if (placed) { size(true); seen(true); } };
|
|
234
297
|
ws.onmessage = (e) => (typeof e.data === 'string' ? msg(JSON.parse(e.data)) : frame(e.data));
|
|
235
|
-
ws.onclose = () => { gone = true; closeSheet(); agentState({ off: true }); $('field').classList.remove('loading'); cover('The session ended', 'ended'); ended(); };
|
|
298
|
+
ws.onclose = () => { gone = true; if (T.st) termState({ ...T.st, ended: true }); closeSheet(); agentState({ off: true }); $('field').classList.remove('loading'); cover('The session ended', 'ended'); ended(); };
|
|
236
299
|
}
|
|
237
300
|
|
|
238
301
|
// --- frames: one decode at a time, a newer frame replaces a waiting one ----------
|
|
@@ -253,13 +316,16 @@ async function frame(buf) {
|
|
|
253
316
|
}
|
|
254
317
|
function draw(bmp) {
|
|
255
318
|
g.imageSmoothingQuality = 'high';
|
|
256
|
-
// never stretch: the frame is view.w CSS px wide; a frame from a size in flight keeps its aspect
|
|
257
|
-
|
|
319
|
+
// never stretch: the frame is view.w CSS px wide; a frame from a size in flight keeps its aspect.
|
|
320
|
+
// scaled: the whole frame inside the box, by both sides (a taller frame never spills off the bottom)
|
|
321
|
+
const k = c.width / (stage.clientWidth || 1);
|
|
322
|
+
let s = ((view.w || stage.clientWidth) * zs() * k) / bmp.width;
|
|
323
|
+
if ((scaled() || fixed) && view.h) s = Math.min(s, (view.h * zs() * k) / bmp.height);
|
|
258
324
|
const dw = bmp.width * s, dh = bmp.height * s, dx = ox() * k, dy = oy() * k;
|
|
259
325
|
const gap = dx > 0 || dy > 0 || dw < c.width || dh < c.height;
|
|
260
326
|
if (gap) g.clearRect(0, 0, c.width, c.height);
|
|
261
327
|
g.drawImage(bmp, dx, dy, dw, dh);
|
|
262
|
-
if (gap && !
|
|
328
|
+
if (gap && !scaled() && !fixed) edgeFill(dw, dh);
|
|
263
329
|
}
|
|
264
330
|
|
|
265
331
|
// a sized page short of the stage = resize in flight: the gap takes the page's corner color, not the dark stage
|
|
@@ -292,7 +358,7 @@ let pageSent = '';
|
|
|
292
358
|
function pageOut() {
|
|
293
359
|
// before the hub's embed the bars are a full viewer's: the pane would size twice
|
|
294
360
|
if (!embed || !placed || !view.w || !view.h) return;
|
|
295
|
-
const chrome = Math.max(0, $('
|
|
361
|
+
const chrome = Math.max(0, $('web').clientHeight - stage.clientHeight);
|
|
296
362
|
const m = { t: 'page', w: view.w, h: view.h, fixed, chrome };
|
|
297
363
|
const j = JSON.stringify(m);
|
|
298
364
|
if (j !== pageSent) { pageSent = j; hub(m); }
|
|
@@ -301,13 +367,21 @@ function size(now) {
|
|
|
301
367
|
layout();
|
|
302
368
|
if (!placed) return;
|
|
303
369
|
clearTimeout(sizeT);
|
|
304
|
-
// a tile caps the frames at its own device px
|
|
370
|
+
// a tile caps the frames at its own device px. A pane that sizes its page, under the hub's floor
|
|
371
|
+
// on either side: the page at the floor, in the pane's shape, scaled down (a short pane never cuts a form)
|
|
305
372
|
const dpr = devicePixelRatio || 1;
|
|
306
373
|
const send = () => {
|
|
307
374
|
const w = stage.clientWidth, h = stage.clientHeight;
|
|
308
|
-
|
|
309
|
-
|
|
375
|
+
const z = floor && w > 0 && h > 0 ? Math.max(1, floor.w / w, floor.h / h) : 1, was = zoomed;
|
|
376
|
+
zoomed = !tile && z > 1;
|
|
377
|
+
if (!tile && !zoomed) {
|
|
378
|
+
// the server drops a plain size while it holds a cap
|
|
379
|
+
if (was) tx({ t: 'cap', off: true });
|
|
380
|
+
return tx({ t: 'size', w, h });
|
|
381
|
+
}
|
|
382
|
+
if (zoomed) tx({ t: 'size', zoom: true, w: Math.round(w * z), h: Math.round(h * z) });
|
|
310
383
|
tx({ t: 'cap', w: Math.round(w * dpr), h: Math.round(h * dpr) });
|
|
384
|
+
if (was !== zoomed && last) draw(last);
|
|
311
385
|
};
|
|
312
386
|
if (now) send(); else sizeT = setTimeout(send, 150);
|
|
313
387
|
}
|
|
@@ -325,18 +399,21 @@ window.addEventListener('message', (e) => {
|
|
|
325
399
|
if (!embed || e.source !== parent || !e.data || typeof e.data !== 'object' || !e.data.hub) return;
|
|
326
400
|
const m = e.data.hub;
|
|
327
401
|
if (m.t === 'embed') {
|
|
328
|
-
const wasTile = tile,
|
|
329
|
-
|
|
402
|
+
const wasTile = tile, wasFloor = JSON.stringify(floor);
|
|
403
|
+
// the floor a pane that sizes its page keeps: {w, h} CSS px
|
|
404
|
+
tile = !!m.tile; floor = !tile && m.zoom && m.zoom.w > 0 ? { w: Number(m.zoom.w), h: Number(m.zoom.h) || 0 } : null; onScreen = !!m.on; inPane = !!m.bare;
|
|
330
405
|
if (Array.isArray(m.keys)) hubKeys = m.keys;
|
|
331
406
|
document.documentElement.classList.toggle('tile', tile);
|
|
332
407
|
document.documentElement.classList.toggle('bare', inPane);
|
|
408
|
+
termLayout();
|
|
333
409
|
if (!inPane && wantUrl) { wantUrl = false; requestAnimationFrame(() => urlEl.focus()); }
|
|
334
410
|
// a tile change mid-animation: wait for the pane to settle, so the run reflows once
|
|
335
|
-
if (!placed || wasTile !== tile ||
|
|
411
|
+
if (!placed || wasTile !== tile || wasFloor !== JSON.stringify(floor)) { const first = !placed; placed = true; if (wasTile && !tile) tx({ t: 'cap', off: true }); size(first); }
|
|
336
412
|
seen();
|
|
337
413
|
} else if (m.t === 'clip') live.clip(m.text);
|
|
338
414
|
else if (m.t === 'focus') focusPage();
|
|
339
415
|
else if (m.t === 'keys') toggleSheet();
|
|
416
|
+
else if (m.t === 'term') toggleTerm();
|
|
340
417
|
});
|
|
341
418
|
// the hub marks the pane the person works in
|
|
342
419
|
addEventListener('pointerdown', () => hub({ t: 'focus' }), true);
|
|
@@ -351,7 +428,11 @@ function msg(m) {
|
|
|
351
428
|
pageOut();
|
|
352
429
|
needs(m.needs);
|
|
353
430
|
signingAs(m.signing);
|
|
431
|
+
termState(m.term, m.termLines);
|
|
354
432
|
return;
|
|
433
|
+
case 'term': return termState(m.term);
|
|
434
|
+
case 'term-line': T.lines = Array.isArray(m.lines) ? m.lines : []; return stripDraw();
|
|
435
|
+
case 'ghostty': return ghosttySaid(m);
|
|
355
436
|
case 'tabs': drawTabs(m.tabs, m.overlay); return accounts(m.accounts);
|
|
356
437
|
case 'signing': return signingAs(m.as);
|
|
357
438
|
case 'needs': return needs(m.why);
|
|
@@ -510,7 +591,7 @@ $('agent').onclick = () => { pauseAgent(); focusPage(); };
|
|
|
510
591
|
const KEYS = [
|
|
511
592
|
['Tabs', [['New tab', ['⌘', 'T']], ['Close tab', ['⌘', 'W']], ['Next tab', ['⌘', '⇧', ']'], ['⌃', 'Tab']], ['Previous tab', ['⌘', '⇧', '['], ['⌃', '⇧', 'Tab']], ['Tab 1 to 8', ['⌘', '1–8']], ['Last tab', ['⌘', '9']]]],
|
|
512
593
|
['Page', [['Address bar', ['⌘', 'L']], ['Back', ['⌘', '[']], ['Forward', ['⌘', ']']], ['Reload', ['⌘', 'R']]]],
|
|
513
|
-
['Session', [['Pause or resume the agent', ['⌃', '⌥', 'P']], ['Open in a window', ['⌘', '⇧', 'O'], 'win'], ['Hide this view', ['⌘', '⇧', 'W']], ['Shortcuts', ['⌘', '/']]]],
|
|
594
|
+
['Session', [['Pause or resume the agent', ['⌃', '⌥', 'P']], ['Open in a window', ['⌘', '⇧', 'O'], 'win'], ['Claude terminal: show or hide', ['⌘', 'J'], 'term'], ['Hide this view', ['⌘', '⇧', 'W']], ['Shortcuts', ['⌘', '/']]]],
|
|
514
595
|
];
|
|
515
596
|
let sheet = null;
|
|
516
597
|
function openSheet() {
|
|
@@ -527,6 +608,7 @@ function openSheet() {
|
|
|
527
608
|
const g = document.createElement('div'); g.className = 'g'; g.textContent = group; grp.append(g);
|
|
528
609
|
for (const [label, ...keys] of rows) {
|
|
529
610
|
if (keys.at(-1) === 'win') { if (!canWindow) continue; keys.pop(); }
|
|
611
|
+
if (keys.at(-1) === 'term') { if (!T.st) continue; keys.pop(); }
|
|
530
612
|
const r = document.createElement('div'); r.className = 'r';
|
|
531
613
|
const l = document.createElement('span'); l.textContent = label;
|
|
532
614
|
const k = document.createElement('span'); k.className = 'k';
|
|
@@ -709,6 +791,7 @@ function hotkey(e) {
|
|
|
709
791
|
if (e.ctrlKey && !e.altKey && !e.metaKey && e.code === 'Tab') { stepTab(e.shiftKey ? -1 : 1); return true; }
|
|
710
792
|
if (!cmd) return false;
|
|
711
793
|
if (e.code === 'Slash') { toggleSheet(); return true; }
|
|
794
|
+
if (e.code === 'KeyJ' && !e.shiftKey) { toggleTerm(); return !!T.st; }
|
|
712
795
|
if (e.shiftKey) {
|
|
713
796
|
if (e.code === 'BracketRight') { stepTab(1); return true; }
|
|
714
797
|
if (e.code === 'BracketLeft') { stepTab(-1); return true; }
|
|
@@ -798,11 +881,15 @@ window.addEventListener('keydown', (e) => {
|
|
|
798
881
|
return;
|
|
799
882
|
}
|
|
800
883
|
if (dlg) { if (e.key === 'Escape') { answer(false); e.preventDefault(); } return; }
|
|
884
|
+
if (termEl.contains(e.target) && termKey(e)) return;
|
|
801
885
|
if (hotkey(e)) { e.preventDefault(); e.stopPropagation(); }
|
|
802
886
|
}, true);
|
|
803
887
|
|
|
804
888
|
// --- input to the page ------------------------------------------------------------
|
|
805
|
-
const focusPage = () => {
|
|
889
|
+
const focusPage = () => {
|
|
890
|
+
if (keysTo === 'term' && termOn() && T.live) { T.x.focus(); return; }
|
|
891
|
+
if (!gone && !readOnly) sink.focus({ preventScroll: true });
|
|
892
|
+
};
|
|
806
893
|
const pos = (e) => {
|
|
807
894
|
const r = c.getBoundingClientRect(), z = zs();
|
|
808
895
|
const vw = view.w || r.width, vh = view.h || r.height;
|
|
@@ -814,6 +901,7 @@ let moveRaf = 0, moveAt = null, down = 0;
|
|
|
814
901
|
c.addEventListener('mousedown', (e) => {
|
|
815
902
|
if (readOnly) return;
|
|
816
903
|
closeMenu(-1);
|
|
904
|
+
keysTo = 'page';
|
|
817
905
|
focusPage();
|
|
818
906
|
down |= 1 << e.button;
|
|
819
907
|
tx({ t: 'mouse', type: 'down', ...pos(e), button: BTN[e.button], clickCount: e.detail || 1 });
|
|
@@ -864,7 +952,7 @@ sink.addEventListener('paste', (e) => {
|
|
|
864
952
|
e.preventDefault();
|
|
865
953
|
});
|
|
866
954
|
// a click on the stage that lands on nothing focusable gives the keys to the page
|
|
867
|
-
stage.addEventListener('mousedown', (e) => { if (e.target === stage) focusPage(); });
|
|
955
|
+
stage.addEventListener('mousedown', (e) => { if (e.target === stage) { keysTo = 'page'; focusPage(); } });
|
|
868
956
|
window.addEventListener('focus', () => { if (!dlg && !sheet && document.activeElement !== urlEl && document.activeElement !== ov) focusPage(); });
|
|
869
957
|
|
|
870
958
|
// --- <select>: headless paints no popup, so the page script sends the options --------
|
|
@@ -1021,6 +1109,189 @@ window.addEventListener('message', (e) => {
|
|
|
1021
1109
|
});
|
|
1022
1110
|
ov.addEventListener('blur', () => { ovKey = false; });
|
|
1023
1111
|
|
|
1112
|
+
// --- the Claude terminal (designs/2026-12-01-agent-task.md §The terminal in the hub) --------
|
|
1113
|
+
// Focus: a dock on the right; a bare pane or one under 900 px: the strip and a drawer. A pty only while it shows.
|
|
1114
|
+
const termEl = $('term'), xtEl = $('xt');
|
|
1115
|
+
const T = { st: null, lines: [], want: true, open: false, drawer: false, ws: null, going: false, x: null, fit: null, lib: null, sent: '', live: false, err: '', ghoT: 0 };
|
|
1116
|
+
/** where keys go: the page or the terminal; a click picks it, every focus path keeps it */
|
|
1117
|
+
let keysTo = 'page';
|
|
1118
|
+
const termOn = () => !!T.st && !readOnly && (T.drawer ? T.open : T.want);
|
|
1119
|
+
const ttx = (m) => { if (T.ws && T.ws.readyState === 1) T.ws.send(JSON.stringify(m)); };
|
|
1120
|
+
function termLib() {
|
|
1121
|
+
T.lib ??= new Promise((ok, no) => {
|
|
1122
|
+
const at = (f) => `/x/${f}?k=${encodeURIComponent(k)}`;
|
|
1123
|
+
const css = document.createElement('link'); css.rel = 'stylesheet'; css.href = at('xterm.css'); document.head.append(css);
|
|
1124
|
+
const js = (f) => new Promise((y, n) => { const el = document.createElement('script'); el.src = at(f); el.onload = y; el.onerror = () => n(new Error(f)); document.head.append(el); });
|
|
1125
|
+
js('xterm.js').then(() => js('fit.js')).then(ok, (e) => { T.lib = null; no(e); });
|
|
1126
|
+
});
|
|
1127
|
+
return T.lib;
|
|
1128
|
+
}
|
|
1129
|
+
function termState(st, lines) {
|
|
1130
|
+
T.st = st && typeof st === 'object' && !readOnly ? st : null;
|
|
1131
|
+
if (Array.isArray(lines)) T.lines = lines;
|
|
1132
|
+
if (!T.st) { T.open = false; T.err = ''; }
|
|
1133
|
+
termLayout();
|
|
1134
|
+
}
|
|
1135
|
+
function termLayout() {
|
|
1136
|
+
const has = !!T.st, root = document.documentElement;
|
|
1137
|
+
T.drawer = inPane || innerWidth < 900;
|
|
1138
|
+
if (!T.drawer) T.open = false;
|
|
1139
|
+
root.classList.toggle('term', has);
|
|
1140
|
+
root.classList.toggle('tdrawer', has && T.drawer);
|
|
1141
|
+
root.classList.toggle('tdock', has && !T.drawer && T.want);
|
|
1142
|
+
root.classList.toggle('topen', has && T.drawer && T.open);
|
|
1143
|
+
const ended = has && !!T.st.ended;
|
|
1144
|
+
termEl.classList.toggle('tend', ended); $('tstrip').classList.toggle('tend', ended);
|
|
1145
|
+
// no session to attach
|
|
1146
|
+
$('tgho').disabled = ended;
|
|
1147
|
+
$('tbtn').hidden = !has || T.drawer;
|
|
1148
|
+
$('tbtn').setAttribute('aria-pressed', String(has && !T.drawer && T.want));
|
|
1149
|
+
$('tstrip').setAttribute('aria-expanded', String(T.open));
|
|
1150
|
+
$('tname').textContent = has ? T.st.name : '';
|
|
1151
|
+
termEl.inert = !termOn();
|
|
1152
|
+
if (termOn() && !ended) termConnect();
|
|
1153
|
+
else { termDrop(); if (ended && termOn()) termCover('Claude ended', 'ended'); }
|
|
1154
|
+
if (!termOn() && keysTo === 'term') { keysTo = 'page'; if (termEl.contains(document.activeElement)) focusPage(); }
|
|
1155
|
+
stripDraw();
|
|
1156
|
+
}
|
|
1157
|
+
function stripDraw() {
|
|
1158
|
+
const box = $('tlines');
|
|
1159
|
+
const lines = T.st?.ended ? ['Claude ended'] : T.lines.length ? T.lines : ['Starting'];
|
|
1160
|
+
box.replaceChildren(...lines.map((l) => { const el = document.createElement('span'); el.textContent = l; return el; }));
|
|
1161
|
+
$('tstrip').title = `${lines.join('\n')}\n\nOpen the Claude terminal (⌘J)`;
|
|
1162
|
+
}
|
|
1163
|
+
function termCover(text, look) {
|
|
1164
|
+
const el = $('tcov');
|
|
1165
|
+
if (!text) { el.classList.add('hide'); termEl.classList.remove('tfail'); return; }
|
|
1166
|
+
$('tct').textContent = text;
|
|
1167
|
+
el.className = look || '';
|
|
1168
|
+
termEl.classList.toggle('tfail', look === 'fail' || look === 'gone');
|
|
1169
|
+
$('tretry').hidden = look !== 'fail';
|
|
1170
|
+
}
|
|
1171
|
+
function termMake() {
|
|
1172
|
+
const x = new Terminal({
|
|
1173
|
+
fontFamily: '"SF Mono", ui-monospace, Menlo, monospace', fontSize: 12, lineHeight: 1.2, cursorBlink: false,
|
|
1174
|
+
macOptionIsMeta: true, scrollback: 0, drawBoldTextInBrightColors: false,
|
|
1175
|
+
theme: { background: '#121215', foreground: '#e8e8ea', cursor: '#e8e8ea', cursorAccent: '#121215', selectionBackground: 'rgba(127,157,255,.35)' },
|
|
1176
|
+
});
|
|
1177
|
+
const fit = new FitAddon.FitAddon();
|
|
1178
|
+
x.loadAddon(fit);
|
|
1179
|
+
x.open(xtEl);
|
|
1180
|
+
x.onData((d) => ttx({ t: 'in', d }));
|
|
1181
|
+
// the wheel scrolls tmux's history (copy mode); xterm would send ↑↓ to Claude's input
|
|
1182
|
+
let acc = 0, raf = 0;
|
|
1183
|
+
x.attachCustomWheelEventHandler((e) => {
|
|
1184
|
+
acc += e.deltaMode === 1 ? e.deltaY : e.deltaY / 18;
|
|
1185
|
+
if (!raf) raf = requestAnimationFrame(() => { raf = 0; const n = Math.trunc(acc); if (n) { acc -= n; ttx({ t: 'scroll', n }); } });
|
|
1186
|
+
e.preventDefault();
|
|
1187
|
+
return false;
|
|
1188
|
+
});
|
|
1189
|
+
T.x = x; T.fit = fit;
|
|
1190
|
+
new ResizeObserver(() => termFit()).observe(xtEl);
|
|
1191
|
+
}
|
|
1192
|
+
/** only a panel on screen sizes the pty: a hidden one would shrink the window Ghostty shows too */
|
|
1193
|
+
function termFit() {
|
|
1194
|
+
if (!T.x || !termOn() || xtEl.clientWidth < 40 || xtEl.clientHeight < 20) return;
|
|
1195
|
+
const d = T.fit.proposeDimensions();
|
|
1196
|
+
if (!d || !(d.cols > 0) || !(d.rows > 0)) return;
|
|
1197
|
+
if (d.cols !== T.x.cols || d.rows !== T.x.rows) T.x.resize(d.cols, d.rows);
|
|
1198
|
+
const s = `${d.cols}x${d.rows}`;
|
|
1199
|
+
if (s !== T.sent && T.ws && T.ws.readyState === 1) { T.sent = s; ttx({ t: 'size', c: d.cols, r: d.rows }); }
|
|
1200
|
+
}
|
|
1201
|
+
async function termConnect() {
|
|
1202
|
+
if (T.ws || T.going || gone) return;
|
|
1203
|
+
T.going = true; T.err = '';
|
|
1204
|
+
termCover('Connecting', 'wait');
|
|
1205
|
+
try { await termLib(); } catch { T.going = false; termCover('The terminal could not load: its files are missing from this install. Open in Ghostty still works.', 'gone'); return; }
|
|
1206
|
+
T.going = false;
|
|
1207
|
+
if (T.ws || !termOn() || gone) return;
|
|
1208
|
+
if (!T.x) termMake(); else T.x.reset();
|
|
1209
|
+
T.sent = ''; T.live = false;
|
|
1210
|
+
const ws = new WebSocket(`ws://${location.host}/term?k=${encodeURIComponent(k)}`);
|
|
1211
|
+
T.ws = ws;
|
|
1212
|
+
ws.binaryType = 'arraybuffer';
|
|
1213
|
+
ws.onopen = () => { if (T.ws === ws) termFit(); };
|
|
1214
|
+
ws.onmessage = (e) => {
|
|
1215
|
+
if (T.ws !== ws) return;
|
|
1216
|
+
if (typeof e.data !== 'string') {
|
|
1217
|
+
T.x.write(new Uint8Array(e.data));
|
|
1218
|
+
if (!T.live) { T.live = true; termCover(null); if (keysTo === 'term') T.x.focus(); }
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
try { const m = JSON.parse(e.data); if (m.t === 'err') T.err = String(m.why || ''); } catch {}
|
|
1222
|
+
};
|
|
1223
|
+
ws.onclose = () => {
|
|
1224
|
+
if (T.ws !== ws) return;
|
|
1225
|
+
T.ws = null;
|
|
1226
|
+
if (T.err) termCover(`The terminal could not open: ${T.err}`, 'fail');
|
|
1227
|
+
else termCover('Claude ended', 'ended');
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
function termDrop() { const ws = T.ws; T.ws = null; ws?.close(); }
|
|
1231
|
+
function toggleTerm(on) {
|
|
1232
|
+
if (!T.st) return;
|
|
1233
|
+
if (T.drawer) T.open = on ?? !T.open; else T.want = on ?? !T.want;
|
|
1234
|
+
keysTo = termOn() ? 'term' : 'page';
|
|
1235
|
+
termLayout();
|
|
1236
|
+
if (termOn()) { if (T.live) T.x.focus(); } else focusPage();
|
|
1237
|
+
}
|
|
1238
|
+
// Open in Ghostty: the same session, a window behind the front app; the server opens it
|
|
1239
|
+
function ghosttySaid(m) {
|
|
1240
|
+
const el = $('tgho').querySelector('.gl');
|
|
1241
|
+
clearTimeout(T.ghoT);
|
|
1242
|
+
const say = (t) => { if (matchMedia('(prefers-reduced-motion: reduce)').matches) { el.textContent = t; return; } el.style.opacity = '0'; setTimeout(() => { el.textContent = t; el.style.opacity = ''; }, 120); };
|
|
1243
|
+
say(m.ok ? 'Opened in Ghostty' : 'Ghostty did not open');
|
|
1244
|
+
if (!m.ok && m.why) $('tgho').title = m.why;
|
|
1245
|
+
T.ghoT = setTimeout(() => { say('Open in Ghostty'); $('tgho').title = 'Attach this session in a Ghostty window'; }, 2000);
|
|
1246
|
+
}
|
|
1247
|
+
$('tgho').onclick = () => tx({ t: 'ghostty' });
|
|
1248
|
+
$('thide').onclick = () => toggleTerm(false);
|
|
1249
|
+
$('tbtn').onclick = () => toggleTerm();
|
|
1250
|
+
$('tstrip').onclick = () => toggleTerm(true);
|
|
1251
|
+
$('tscrim').addEventListener('mousedown', (e) => { e.preventDefault(); toggleTerm(false); });
|
|
1252
|
+
$('tretry').onclick = () => { T.err = ''; termDrop(); termConnect(); };
|
|
1253
|
+
termEl.addEventListener('mousedown', () => { keysTo = 'term'; });
|
|
1254
|
+
termEl.addEventListener('focusin', () => { keysTo = 'term'; });
|
|
1255
|
+
addEventListener('resize', () => termLayout());
|
|
1256
|
+
/** a key in the terminal: Claude's, but the hub's keys and ⌘J; ⌘C also sends the selection to the app's clipboard */
|
|
1257
|
+
function termKey(e) {
|
|
1258
|
+
if (hubKey(e) || (e.metaKey && !e.ctrlKey && !e.altKey && !e.shiftKey && e.code === 'KeyJ')) return false;
|
|
1259
|
+
if (e.metaKey && e.code === 'KeyC' && T.x?.hasSelection()) tx({ t: 'term-copy', text: T.x.getSelection() });
|
|
1260
|
+
return true;
|
|
1261
|
+
}
|
|
1262
|
+
// the divider: drag or ←→; the width is this viewer's own (localStorage)
|
|
1263
|
+
{
|
|
1264
|
+
const div = $('tdiv'), app = $('app');
|
|
1265
|
+
const setW = (w) => {
|
|
1266
|
+
const max = app.clientWidth - 360, px = Math.round(Math.max(420, Math.min(max, w)));
|
|
1267
|
+
termEl.style.setProperty('--tw', `${px}px`);
|
|
1268
|
+
div.setAttribute('aria-valuenow', String(px));
|
|
1269
|
+
return px;
|
|
1270
|
+
};
|
|
1271
|
+
try { const f = Number(localStorage.getItem('autobrowse.termW')); if (f > 0 && f < 1) termEl.style.setProperty('--tw', `${(f * 100).toFixed(2)}%`); } catch {}
|
|
1272
|
+
const keep = (px) => { try { localStorage.setItem('autobrowse.termW', String(px / app.clientWidth)); } catch {} };
|
|
1273
|
+
div.addEventListener('pointerdown', (e) => {
|
|
1274
|
+
if (e.button !== 0) return;
|
|
1275
|
+
div.setPointerCapture(e.pointerId);
|
|
1276
|
+
document.documentElement.classList.add('tdrag');
|
|
1277
|
+
const right = app.getBoundingClientRect().right;
|
|
1278
|
+
let px = 0;
|
|
1279
|
+
const move = (ev) => { px = setW(right - ev.clientX); };
|
|
1280
|
+
const up = () => {
|
|
1281
|
+
div.removeEventListener('pointermove', move); div.removeEventListener('pointerup', up); div.removeEventListener('pointercancel', up);
|
|
1282
|
+
document.documentElement.classList.remove('tdrag');
|
|
1283
|
+
if (px) keep(px);
|
|
1284
|
+
};
|
|
1285
|
+
div.addEventListener('pointermove', move); div.addEventListener('pointerup', up); div.addEventListener('pointercancel', up);
|
|
1286
|
+
e.preventDefault();
|
|
1287
|
+
});
|
|
1288
|
+
div.addEventListener('keydown', (e) => {
|
|
1289
|
+
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
1290
|
+
keep(setW(termEl.offsetWidth + (e.key === 'ArrowLeft' ? 24 : -24)));
|
|
1291
|
+
e.preventDefault(); e.stopPropagation();
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1024
1295
|
// --- the app's clipboard answer (live_mac: clip-read) ------------------------------------
|
|
1025
1296
|
window.live = { clip: (text) => { if (text) tx({ t: 'text', text }); } };
|
|
1026
1297
|
|
|
Binary file
|
|
Binary file
|
package/dist/app/cli-record.js
CHANGED
|
@@ -12,6 +12,7 @@ import { DEFAULT_IDLE_MINUTES, pidAlive } from "../explore/lease.js";
|
|
|
12
12
|
import { expandHome, shortHome } from "../google/auth.js";
|
|
13
13
|
import { explorerOpener } from "./backend.js";
|
|
14
14
|
import { group } from "./cli-groups.js";
|
|
15
|
+
import { registerTaskCommand } from "./cli-task.js";
|
|
15
16
|
import { displayOf, headed } from "./display.js";
|
|
16
17
|
const ENGINE_FLAG = "--engine <engine>";
|
|
17
18
|
const ENGINE_HELP = `browser build for this session: ${ENGINES.join(", ")} (default: BROWSER_ENGINE)`;
|
|
@@ -226,21 +227,31 @@ export function registerRecordCommands(program, settings, local) {
|
|
|
226
227
|
await background(back.site, port, tokenFileFor(port), false, back.argv);
|
|
227
228
|
});
|
|
228
229
|
program
|
|
229
|
-
.command("cmd <json>")
|
|
230
|
-
.description('One command to an explore session (`{"cmd":"aria"}`, click, read, save, close…); prints its JSON answer, masked')
|
|
231
|
-
.option("--port <port>", "the session's loopback port (default: this Claude session's one session)")
|
|
232
|
-
.action(async (json, o) => {
|
|
230
|
+
.command("cmd <json> [rest...]")
|
|
231
|
+
.description('One command to an explore session (`{"cmd":"aria"}`, click, read, save, close…); prints its JSON answer, masked. In a task: `cmd finish \'{"status":"done","output":…}\'` ends it, `cmd human "<reason>"` asks William')
|
|
232
|
+
.option("--port <port>", "the session's loopback port (default: the task's session, else this Claude session's one session)")
|
|
233
|
+
.action(async (json, rest, o) => {
|
|
234
|
+
if (json === "finish") {
|
|
235
|
+
const { finishTask } = await import("./task.js");
|
|
236
|
+
return console.log(finishTask(process.env, rest.join(" ")).said);
|
|
237
|
+
}
|
|
233
238
|
const { tokenFileFor } = await import("../explore/server.js");
|
|
234
239
|
const { minePort } = await import("../explore/stop.js");
|
|
235
|
-
const
|
|
240
|
+
const task = process.env.AUTOBROWSE_TASK_PORT;
|
|
241
|
+
const port = o.port !== undefined ? Number(o.port) : task ? Number(task) : minePort();
|
|
236
242
|
const tokenFile = tokenFileFor(port);
|
|
237
243
|
if (!existsSync(tokenFile))
|
|
238
244
|
throw new Error(`no explore session on ${port}: autobrowse explore <site> --background`);
|
|
239
|
-
const
|
|
245
|
+
const body = json === "human" ? { cmd: "human", why: rest.join(" ") } : JSON.parse(json);
|
|
246
|
+
const res = await postCmd(port, tokenFile, body);
|
|
240
247
|
console.log(res.body);
|
|
241
248
|
if (!res.ok)
|
|
242
249
|
process.exitCode = 1;
|
|
243
250
|
});
|
|
251
|
+
registerTaskCommand(program, settings, {
|
|
252
|
+
open: async (site, port, extra) => (await opener({ live: true }))(site, port, extra),
|
|
253
|
+
secrets: async (site, o) => withLogins(await exploreSecrets(site, o), undefined, site),
|
|
254
|
+
});
|
|
244
255
|
program
|
|
245
256
|
.command("port")
|
|
246
257
|
.description("Claim the first free session port from 9090 and print it: start.sh with no port. Passes over ports with a dead session's journal of --site")
|