@lelouchhe/webagent 0.1.2 → 0.1.4

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 CHANGED
@@ -45,7 +45,24 @@ Tech stack: Node.js + TypeScript (`--experimental-strip-types`), real-time WebSo
45
45
  ## Prerequisites
46
46
 
47
47
  - Node.js 22.6+ (requires `--experimental-strip-types`)
48
- - An ACP-compatible agent (e.g. [Copilot CLI](https://github.com/github/copilot-cli)) installed and authenticated
48
+ - An ACP-compatible agent installed and authenticated
49
+
50
+ ### ACP-Compatible Agents
51
+
52
+ WebAgent works with any agent that implements the [Agent Client Protocol](https://agentclientprotocol.com/). Some options:
53
+
54
+ | Agent | Command | Notes |
55
+ |---|---|---|
56
+ | [Copilot CLI](https://github.com/github/copilot-cli) | `copilot --acp` | Default. GitHub's AI pair programmer |
57
+ | [Claude Code](https://docs.anthropic.com/en/docs/agents/claude-code) | `claude --acp` | Anthropic's coding agent |
58
+ | [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `gemini --acp` | Google's Gemini models |
59
+ | [OpenCode](https://opencode.ai/) | `opencode --acp` | Open-source, extensible |
60
+
61
+ See the [ACP Registry](https://agentclientprotocol.com/get-started/agents) for the full list. To use a different agent, set `agent_cmd` in your config:
62
+
63
+ ```toml
64
+ agent_cmd = "claude --acp"
65
+ ```
49
66
 
50
67
  ## Install
51
68
 
package/bin/webagent.mjs CHANGED
@@ -13,7 +13,10 @@ const child = spawn(
13
13
  { stdio: "inherit" },
14
14
  );
15
15
 
16
- for (const sig of ["SIGINT", "SIGTERM", "SIGHUP"]) {
16
+ const signals = process.platform === "win32"
17
+ ? ["SIGINT", "SIGTERM"]
18
+ : ["SIGINT", "SIGTERM", "SIGHUP"];
19
+ for (const sig of signals) {
17
20
  process.on(sig, () => child.kill(sig));
18
21
  }
19
22
 
package/dist/index.html CHANGED
@@ -13,7 +13,7 @@
13
13
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
14
14
  <script src="https://cdn.jsdelivr.net/npm/dompurify@3.3.2/dist/purify.min.js"></script>
15
15
  <script>document.documentElement.setAttribute('data-theme', localStorage.getItem('theme') || 'auto');</script>
16
- <link rel="stylesheet" href="/styles.mmjrsqet.css">
16
+ <link rel="stylesheet" href="/styles.mmk25uhc.css">
17
17
  </head>
18
18
  <body>
19
19
 
@@ -41,6 +41,6 @@
41
41
  <input type="file" id="file-input" accept="image/*" multiple hidden>
42
42
  </div>
43
43
 
44
- <script type="module" src="/js/app.mmjrsqet.js"></script>
44
+ <script type="module" src="/js/app.mmk25uhc.js"></script>
45
45
  </body>
46
46
  </html>
@@ -0,0 +1,10 @@
1
+ // Boot entry point — imports all modules and starts the app
2
+
3
+ import './render.mmk25uhc.js'; // theme, click-to-collapse listeners
4
+ import './commands.mmk25uhc.js'; // slash menu listeners
5
+ import './images.mmk25uhc.js'; // attach/paste listeners
6
+ import './input.mmk25uhc.js'; // keyboard/send listeners
7
+ import { connect } from './connection.mmk25uhc.js';
8
+
9
+ connect();
10
+ if ('serviceWorker' in navigator) navigator.serviceWorker.register('/sw.js');
@@ -4,9 +4,9 @@ import {
4
4
  state, dom, setBusy, resetSessionUI, requestNewSession, sendCancel,
5
5
  getConfigOption, getConfigValue, setHashSessionId, updateSessionInfo,
6
6
  updateNewBtnVisibility,
7
- } from './state.mmjrsqet.js';
8
- import { addSystem, addMessage, scrollToBottom, escHtml, formatLocalTime } from './render.mmjrsqet.js';
9
- import { loadHistory } from './events.mmjrsqet.js';
7
+ } from './state.mmk25uhc.js';
8
+ import { addSystem, addMessage, scrollToBottom, escHtml, formatLocalTime } from './render.mmk25uhc.js';
9
+ import { loadHistory } from './events.mmk25uhc.js';
10
10
 
11
11
  // --- Slash command execution ---
12
12
 
@@ -1,8 +1,8 @@
1
1
  // WebSocket connection lifecycle
2
2
 
3
- import { state, setBusy, getHashSessionId, requestNewSession, resetSessionUI, setConnectionStatus, clearCancelTimer } from './state.mmjrsqet.js';
4
- import { addSystem, finishThinking, finishAssistant, finishBash, scrollToBottom } from './render.mmjrsqet.js';
5
- import { handleEvent, loadHistory, loadNewEvents } from './events.mmjrsqet.js';
3
+ import { state, setBusy, getHashSessionId, requestNewSession, resetSessionUI, setConnectionStatus, clearCancelTimer } from './state.mmk25uhc.js';
4
+ import { addSystem, finishThinking, finishAssistant, finishBash, scrollToBottom } from './render.mmk25uhc.js';
5
+ import { handleEvent, loadHistory, loadNewEvents } from './events.mmk25uhc.js';
6
6
 
7
7
  export function connect() {
8
8
  const proto = location.protocol === 'https:' ? 'wss:' : 'ws:';
@@ -15,7 +15,7 @@ export function connect() {
15
15
  const existingId = getHashSessionId();
16
16
 
17
17
  // Incremental reconnect: same session still in memory — skip DOM wipe
18
- if (existingId && existingId === state.sessionId) {
18
+ if (existingId && existingId === state.sessionId && state.lastEventSeq > 0) {
19
19
  await loadNewEvents(existingId);
20
20
  scrollToBottom(false);
21
21
  state.ws.send(JSON.stringify({ type: 'resume_session', sessionId: existingId }));
@@ -4,12 +4,12 @@ import {
4
4
  state, dom, setBusy, setConfigValue, getConfigOption, updateConfigOptions,
5
5
  updateModeUI, resetSessionUI, requestNewSession, setHashSessionId, updateSessionInfo,
6
6
  setConnectionStatus, clearCancelTimer,
7
- } from './state.mmjrsqet.js';
7
+ } from './state.mmk25uhc.js';
8
8
  import {
9
9
  addMessage, addSystem, finishAssistant, finishThinking, hideWaiting,
10
10
  scrollToBottom, renderMd, escHtml, renderPatchDiff, addBashBlock, finishBash, appendMessageElement,
11
11
  formatLocalTime,
12
- } from './render.mmjrsqet.js';
12
+ } from './render.mmk25uhc.js';
13
13
 
14
14
  function finishPromptIfIdle() {
15
15
  if (!state.pendingPromptDone) return;
@@ -32,7 +32,7 @@ function cancelPendingTurnUI() {
32
32
  }
33
33
  for (const requestId of state.pendingPermissionRequestIds) {
34
34
  const permEl = document.querySelector(`.permission[data-request-id="${requestId}"]`);
35
- if (!permEl) continue;
35
+ if (!permEl || !permEl.querySelector('button')) continue;
36
36
  const titleEl = permEl.querySelector('.title');
37
37
  const title = titleEl?.textContent || '⚿';
38
38
  permEl.innerHTML = `<span style="opacity:0.5">${escHtml(title)} — cancelled</span>`;
@@ -236,7 +236,7 @@ export function replayEvent(type, data, events, idx) {
236
236
  const el = document.querySelector(`.permission[data-request-id="${data.requestId}"]`);
237
237
  if (el) {
238
238
  const title = el.dataset.title ? `⚿ ${el.dataset.title}` : '⚿';
239
- const action = data.denied ? 'denied' : data.optionName || 'allowed';
239
+ const action = data.optionName || (data.denied ? 'denied' : 'allowed');
240
240
  el.innerHTML = `<span style="opacity:0.5">${escHtml(title)} — ${escHtml(action)}</span>`;
241
241
  }
242
242
  break;
@@ -508,7 +508,7 @@ export function handleEvent(msg) {
508
508
  const permTarget = document.querySelector(`.permission[data-request-id="${msg.requestId}"]`);
509
509
  if (msg.sessionId === state.sessionId && permTarget) {
510
510
  const title = permTarget.dataset.title ? `⚿ ${permTarget.dataset.title}` : '⚿';
511
- const action = msg.denied ? 'denied' : msg.optionName || 'allowed';
511
+ const action = msg.optionName || (msg.denied ? 'denied' : 'allowed');
512
512
  permTarget.innerHTML = `<span style="opacity:0.5">${escHtml(title)} — ${escHtml(action)}</span>`;
513
513
  }
514
514
  finishPromptIfIdle();
@@ -1,6 +1,6 @@
1
1
  // Image attach, preview, and paste handling
2
2
 
3
- import { state, dom } from './state.mmjrsqet.js';
3
+ import { state, dom } from './state.mmk25uhc.js';
4
4
 
5
5
  function readFileAsBase64(file) {
6
6
  return new Promise((resolve) => {
@@ -3,10 +3,10 @@
3
3
  import {
4
4
  state, dom, setBusy, sendCancel,
5
5
  getConfigOption, getConfigValue, updateNewBtnVisibility,
6
- } from './state.mmjrsqet.js';
7
- import { addMessage, addSystem, addBashBlock, showWaiting } from './render.mmjrsqet.js';
8
- import { handleSlashCommand, hideSlashMenu, handleSlashMenuKey, updateSlashMenu } from './commands.mmjrsqet.js';
9
- import { renderAttachPreview } from './images.mmjrsqet.js';
6
+ } from './state.mmk25uhc.js';
7
+ import { addMessage, addSystem, addBashBlock, showWaiting } from './render.mmk25uhc.js';
8
+ import { handleSlashCommand, hideSlashMenu, handleSlashMenuKey, updateSlashMenu } from './commands.mmk25uhc.js';
9
+ import { renderAttachPreview } from './images.mmk25uhc.js';
10
10
 
11
11
  // Wire up cancel-timeout feedback (state.js cannot import render.js directly)
12
12
  state._onCancelTimeout = () => addSystem('warn: Agent not responding to cancel');
@@ -1,6 +1,6 @@
1
1
  // Rendering functions, theme, markdown, bash UI
2
2
 
3
- import { dom, state } from './state.mmjrsqet.js';
3
+ import { dom, state } from './state.mmk25uhc.js';
4
4
 
5
5
  // --- Markdown ---
6
6
  marked.setOptions({ breaks: true, gfm: true });
package/lib/bridge.js CHANGED
@@ -172,7 +172,7 @@ export class AgentBridge extends EventEmitter {
172
172
  this.proc.kill();
173
173
  await new Promise((resolve) => {
174
174
  const timer = setTimeout(() => {
175
- this.proc?.kill("SIGKILL");
175
+ this.proc?.kill(process.platform === "win32" ? undefined : "SIGKILL");
176
176
  resolve();
177
177
  }, 5000);
178
178
  this.proc?.on("exit", () => {
@@ -191,8 +191,9 @@ export class SessionManager {
191
191
  }
192
192
  /** Kill all running bash processes (for shutdown). */
193
193
  killAllBashProcs() {
194
+ const forceSignal = process.platform === "win32" ? undefined : "SIGKILL";
194
195
  for (const [, proc] of this.runningBashProcs)
195
- proc.kill("SIGKILL");
196
+ proc.kill(forceSignal);
196
197
  this.runningBashProcs.clear();
197
198
  }
198
199
  }
package/lib/ws-handler.js CHANGED
@@ -1,9 +1,15 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { WebSocket, WebSocketServer } from "ws";
3
3
  import { WsMessageSchema, errorMessage } from "./types.js";
4
+ const IS_WIN = process.platform === "win32";
4
5
  function interruptBashProc(proc) {
5
6
  if (!proc)
6
7
  return;
8
+ if (IS_WIN && typeof proc.pid === "number") {
9
+ // Windows: kill entire process tree since there are no process groups
10
+ spawn("taskkill", ["/T", "/F", "/PID", String(proc.pid)]).unref();
11
+ return;
12
+ }
7
13
  if (typeof proc.pid === "number") {
8
14
  try {
9
15
  process.kill(-proc.pid, "SIGINT");
@@ -196,9 +202,11 @@ export function setupWsHandler(deps) {
196
202
  client.send(bashEvent);
197
203
  }
198
204
  }
199
- const child = spawn("bash", ["-c", msg.command], {
205
+ const shell = IS_WIN ? (process.env.COMSPEC || "cmd.exe") : (process.env.SHELL || "bash");
206
+ const shellArgs = IS_WIN ? ["/s", "/c", msg.command] : ["-c", msg.command];
207
+ const child = spawn(shell, shellArgs, {
200
208
  cwd,
201
- detached: true,
209
+ detached: !IS_WIN,
202
210
  env: { ...process.env, TERM: "dumb" },
203
211
  stdio: ["ignore", "pipe", "pipe"],
204
212
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lelouchhe/webagent",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A terminal-style web UI for ACP-compatible agents",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1,10 +0,0 @@
1
- // Boot entry point — imports all modules and starts the app
2
-
3
- import './render.mmjrsqet.js'; // theme, click-to-collapse listeners
4
- import './commands.mmjrsqet.js'; // slash menu listeners
5
- import './images.mmjrsqet.js'; // attach/paste listeners
6
- import './input.mmjrsqet.js'; // keyboard/send listeners
7
- import { connect } from './connection.mmjrsqet.js';
8
-
9
- connect();
10
- if ('serviceWorker' in navigator) navigator.serviceWorker.register('/sw.js');