@a-t-h-i/bot-lobby 0.7.2 → 0.7.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.
Files changed (37) hide show
  1. package/THIRD_PARTY_NOTICES.md +17 -0
  2. package/package.json +1 -1
  3. package/prompts/lobby-chat.md +2 -2
  4. package/prompts/master.md +20 -0
  5. package/src/classifier/lobby.ts +4 -3
  6. package/src/index.ts +3 -0
  7. package/src/lobby/host.ts +5 -0
  8. package/src/lobby/keys.ts +1 -0
  9. package/src/lobby/runtime.ts +12 -0
  10. package/src/lobby/service.ts +36 -0
  11. package/src/pi/commands.ts +23 -2
  12. package/src/pi/events.ts +3 -1
  13. package/src/pi/start-task-tool.ts +94 -0
  14. package/src/text.ts +22 -0
  15. package/src/webui/api/index.ts +2 -1
  16. package/src/webui/api/sessions.ts +6 -0
  17. package/src/webui/dev/fake-service.ts +1 -0
  18. package/src/webui/protocol.ts +1 -0
  19. package/webui/dist/apple-touch-icon.png +0 -0
  20. package/webui/dist/assets/{CodeSurface-12WUcZSS.js → CodeSurface-B9IpRRpY.js} +1 -1
  21. package/webui/dist/assets/{TerminalView-C1ez7iqT.js → TerminalView-CHnFTGrB.js} +1 -1
  22. package/webui/dist/assets/index-BcsQfVsV.js +117 -0
  23. package/webui/dist/assets/index-Dfi2IVPS.css +2 -0
  24. package/webui/dist/build.json +32 -28
  25. package/webui/dist/icon-192.png +0 -0
  26. package/webui/dist/icon-512.png +0 -0
  27. package/webui/dist/icon-maskable-192.png +0 -0
  28. package/webui/dist/icon-maskable-512.png +0 -0
  29. package/webui/dist/index.html +2 -2
  30. package/webui/dist/licenses/sounds.txt +33 -0
  31. package/webui/dist/sounds/attention.mp3 +0 -0
  32. package/webui/dist/sounds/done.mp3 +0 -0
  33. package/webui/dist/sounds/error.mp3 +0 -0
  34. package/webui/dist/sounds/question.mp3 +0 -0
  35. package/webui/dist/sounds/sent.mp3 +0 -0
  36. package/webui/dist/assets/index-BUrfox9b.js +0 -117
  37. package/webui/dist/assets/index-CoVxsMKn.css +0 -2
@@ -98,3 +98,20 @@ License 2.0, https://www.apache.org/licenses/LICENSE-2.0), Shiki and its
98
98
  grammars (`shiki`, `@shikijs/*`, Pine Wu and Anthony Fu, MIT; each grammar
99
99
  keeps its own licence, listed in `@shikijs/langs`) and `diff` (Kevin Decker,
100
100
  BSD 3-Clause).
101
+
102
+ ## Sounds
103
+
104
+ The five sounds in `webui/public/sounds` (shipped in `webui/dist/sounds`) were
105
+ converted to MP3 and levelled in loudness; nothing else was changed. Full
106
+ details are in `webui/public/licenses/sounds.txt`.
107
+
108
+ - `question.mp3` and `attention.mp3`: "dialog-question" and
109
+ "message-new-email" from the Ocean Sound Theme for KDE Plasma by Guilherme
110
+ Marçal Silva (https://invent.kde.org/plasma/ocean-sound-theme), CC BY-SA 4.0
111
+ (https://creativecommons.org/licenses/by-sa/4.0/). The changed files are
112
+ shared under the same license.
113
+ - `done.mp3` and `error.mp3`: "NFCSuccess" and "NFCFailure" from the Android
114
+ Open Source Project (`frameworks/base/data/sounds`), Apache License 2.0.
115
+ - `sent.mp3`: "audio-volume-change" from the elementary OS sound theme
116
+ (https://github.com/elementary/sound-theme), from Freesound user
117
+ ianslattery, CC0 1.0.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a-t-h-i/bot-lobby",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "Structured multi-agent software engineering orchestrator for Pi",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -26,8 +26,8 @@ and read your reply.
26
26
  one you chose; do not stop to ask.
27
27
  - If the work turns out large (many areas, a new dependency, an architecture
28
28
  change, a decision only the user can make), do not start it: say what it
29
- would take, and suggest `/plan` to plan it with the panel or `/task` to hand
30
- it to the team.
29
+ would take and say the Master can start it as a task for the team (or the
30
+ user can type `/plan` to plan it with the panel).
31
31
  - A bot-lobby task may be running in this working tree at the same time:
32
32
  touch only the files the message needs, re-read a file right before you
33
33
  edit it, and never revert changes you did not make.
package/prompts/master.md CHANGED
@@ -97,6 +97,26 @@ reassess what it affects, then call `action=plan` with the full revised plan
97
97
  delegating more. Before a plan exists, `propose` again. Never silently
98
98
  reinterpret an amendment. If a comment needs no change, say why in one line.
99
99
 
100
+ ## User messages during a task
101
+
102
+ The user can message you while the task runs. Judge each message before you
103
+ act on it, and say in one line which you chose:
104
+
105
+ - **A step of this task**: it changes, extends or corrects this task's work.
106
+ Before a plan exists, fold it into the proposal (`propose` again); after,
107
+ call `action=plan` with the full plan and the new or changed step, then
108
+ delegate it like any other step.
109
+ - **A separate task**: sizeable work that does not belong to this task (a
110
+ different feature or area, or something the user wants tracked on its own).
111
+ Call `start_task` with the request written in full: it runs in its own
112
+ session and this task carries on. Do not fold it into this task.
113
+ - **Yours to handle**: a question, a status check, or a tiny change unrelated
114
+ to the task's files. Answer or do it yourself in a reply, without touching
115
+ the task's state, then carry on with the task.
116
+
117
+ When unsure between a step and a separate task, pick a step if it touches
118
+ the same files or goal, a separate task otherwise.
119
+
100
120
  ## Delegation
101
121
 
102
122
  Assign by where the code runs: everything in the browser (pages, components,
@@ -3,8 +3,9 @@
3
3
  * the last few lines of the conversation) and picks the agent whose area it
4
4
  * is, so a frontend question goes to DESIGN, a library question to RESEARCH,
5
5
  * "how does this work" to a scout and a question about the project's saved
6
- * knowledge to the oracle's knowledge lookup. Anything it is unsure of, and
7
- * every message while it is off, goes to the Master.
6
+ * knowledge to the oracle's knowledge lookup. Work too big for one quick
7
+ * change goes to the Master, who starts a task for it (start_task). Anything
8
+ * it is unsure of, and every message while it is off, goes to the Master.
8
9
  */
9
10
  import type { ChatAgent } from "../lobby/prompts.ts";
10
11
  import type { Classifier } from "./classifier.ts";
@@ -15,7 +16,7 @@ import { clip } from "./limits.ts";
15
16
  export type ChatRoute = ChatAgent | "knowledge";
16
17
 
17
18
  const ROUTES: Record<ChatRoute, string> = {
18
- master: "The Master (the orchestrator): general conversation, the team's tasks and plans, anything across several areas of the project, or anything no single agent below clearly owns",
19
+ master: "The Master (the orchestrator): general conversation, the team's tasks and plans, anything across several areas of the project, a request for work too big for one quick change (a new feature, an architecture change, work that needs tests and review), which the Master hands to the team as a task, or anything no single agent below clearly owns",
19
20
  designer: "DESIGN: the frontend, meaning pages, components, styling, layout, UX, on-screen copy and browser code, whether a question about it or a change to it",
20
21
  backend: "DEV: backend code, meaning APIs, data and databases, server logic, integrations, scripts, build and tooling, whether a question about it or a change to it",
21
22
  qa: "QA: tests, meaning writing, running or fixing them, test strategy, how to verify a change, or checking work for bugs",
package/src/index.ts CHANGED
@@ -4,6 +4,7 @@ import { CONFIG_DIR_NAME, type ExtensionAPI } from "@earendil-works/pi-coding-ag
4
4
  import { registerCommands } from "./pi/commands.ts";
5
5
  import { registerLifecycle } from "./pi/events.ts";
6
6
  import { registerOrchestrateTool } from "./pi/tools.ts";
7
+ import { registerStartTaskTool } from "./pi/start-task-tool.ts";
7
8
  import { onTransition } from "./state/task-state.ts";
8
9
  import { releaseAttachments } from "./state/attachments.ts";
9
10
  import { detectProjectRoot } from "./state/project.ts";
@@ -47,6 +48,8 @@ export default function (pi: ExtensionAPI): void {
47
48
  });
48
49
  registerCommands(pi, CONFIG_DIR_NAME);
49
50
  registerOrchestrateTool(pi, CONFIG_DIR_NAME);
51
+ // The Master starts a task itself from the lobby chat when a request is too big to do in one reply.
52
+ registerStartTaskTool(pi, CONFIG_DIR_NAME);
50
53
  // The questionnaire the oracle (and pi without a task) asks the user with; no other extension is needed for it.
51
54
  registerAskTool(pi, undefined, CONFIG_DIR_NAME);
52
55
  // The web tools, for the researcher and for pi without a task (the oracle leaves them to the researcher).
package/src/lobby/host.ts CHANGED
@@ -195,6 +195,11 @@ export interface LobbyService {
195
195
  liveSessions(): readonly LiveSession[];
196
196
  /** Run another session in this window (stopping its background process first); resolves to a notice. */
197
197
  switchTo(target: SwitchTarget): Promise<string>;
198
+ /**
199
+ * Open a fresh, empty session in this window (this one carries on in the background if it is at work). Whether
200
+ * it opens one, and a notice only when there is something to say (why not, or what carries on in the background).
201
+ */
202
+ newSession?(): { opened: boolean; notice?: string };
198
203
  /** Archived tasks, most recently archived first. */
199
204
  archivedTasks(): Task[];
200
205
  /** Archive, restore or delete a task; each returns a notice. */
package/src/lobby/keys.ts CHANGED
@@ -9,6 +9,7 @@ export const LOBBY_ACTIONS = {
9
9
  help: { key: "alt+h", help: "show or hide this list" },
10
10
  settings: { key: "alt+s", help: "settings: each agent's model and effort" },
11
11
  savePlan: { key: "ctrl+s", help: "save the plan from the Plan tab" },
12
+ newSession: { key: "alt+n", help: "open a new session in this window" },
12
13
  sidebar: { key: "alt+b", help: "fold or open the sidebar (on a phone, open it)" },
13
14
  activity: { key: "alt+a", help: "open or fold every step in the Lobby conversation" },
14
15
  thinking: { key: "alt+t", help: "show or hide Thinking on the Lobby" },
@@ -24,6 +24,7 @@ import { KnowledgeBook } from "./knowledge.ts";
24
24
  import type { LobbyService } from "./host.ts";
25
25
  import { backgroundSessions, carryHandOff, chatProfile, chatReplied, chatHistoryLines, createLobbyService, lobbyNotify, lobbyProfile, plannerDeps, resumeSession, seatProfile, setServiceState, savePlan as serviceSavePlan, answerPanel as serviceAnswerPanel } from "./service.ts";
26
26
  import { lobbyTopics } from "./topics.ts";
27
+ import { sessionTitle } from "../text.ts";
27
28
  export { backgroundSessions, setSessionLauncher } from "./service.ts";
28
29
  import { deliverComments, onOwnerEvent } from "../pi/owner.ts";
29
30
  import { pushNotice } from "../webui/notices.ts";
@@ -280,6 +281,17 @@ export function registerLobbyEvents(pi: ExtensionAPI, configDir: string): void {
280
281
  pi.on("ui_prompt_end", () => {
281
282
  lobbyTopics.bump("status");
282
283
  });
284
+ // A session starts unnamed (New session asks nothing): the first prompt names it, as a chat app titles a chat.
285
+ pi.on("before_agent_start", (event) => {
286
+ if (isMinimized() || event.messageType !== "user" || pi.getSessionName()) return;
287
+ const prompt = event.prompt.trim();
288
+ if (!prompt || prompt.startsWith("/") || prompt.startsWith("bot-lobby:")) return;
289
+ const name = sessionTitle(prompt);
290
+ if (!name) return;
291
+ pi.setSessionName(name);
292
+ lobbyTopics.bump("status");
293
+ lobbyTopics.bump("sessions");
294
+ });
283
295
  pi.on("agent_start", (_event, ctx) => {
284
296
  track(ctx);
285
297
  runtime?.keeper?.window.schedule();
@@ -504,6 +504,19 @@ function startSession(state: Runtime, start: { request?: string; plan?: PlannedT
504
504
  }
505
505
  }
506
506
 
507
+ /**
508
+ * The Master's start_task while it drives a task here: the new task runs in a
509
+ * session of its own, so this one carries on. Its name, or why not.
510
+ */
511
+ export function startTaskInNewSession(request: string, options: { track?: "fast" | "full"; auto?: boolean } = {}): { name: string } | string {
512
+ const state = serviceState;
513
+ if (!state) return "the lobby is not open in this window, so a second task cannot start alongside this one";
514
+ const made = startSession(state, { request: `${options.track ? `--${options.track} ` : ""}${request}`, ...(options.auto ? { auto: true } : {}) });
515
+ if (typeof made === "string") return made;
516
+ lobbyTopics.bump("sessions");
517
+ return { name: made.name };
518
+ }
519
+
507
520
  /** Start again, in the background, a session a stopped window drove; the session, or why not. */
508
521
  export function resumeSession(state: Runtime, start: Relaunch): BackgroundSession | string {
509
522
  try {
@@ -822,6 +835,28 @@ async function switchTo(state: Runtime, target: SwitchTarget): Promise<string> {
822
835
  return leaving ? `${leaving.name} carries on in the background; switching this window to ${target.name}…` : `switching this window to ${target.name}…`;
823
836
  }
824
837
 
838
+ /**
839
+ * Open a fresh, empty session in this window through `/bot-lobby new` (only a
840
+ * command context may replace the session). New session asks nothing: the
841
+ * first prompt names the session (see registerLobbyEvents). As with a switch,
842
+ * a turn at work or a task this session drives carries on in the background.
843
+ */
844
+ function newSession(state: Runtime): { opened: boolean; notice?: string } {
845
+ if (switching) return { opened: false, notice: "a switch is already under way — wait a moment" };
846
+ // An empty session is already new: nothing to open, and nothing worth a notice.
847
+ if (!state.ctx.sessionManager.getBranch().some((entry) => entry.type === "message")) return { opened: false };
848
+ const leaving = handOffFor(state);
849
+ if (typeof leaving === "string") return { opened: false, notice: leaving };
850
+ const resumeOwner = pauseOwner();
851
+ if (!state.ctx.isIdle()) state.ctx.abort();
852
+ switchPending(() => {
853
+ handOff = undefined;
854
+ resumeOwner();
855
+ });
856
+ state.pi.sendUserMessage("/bot-lobby new", { expandPromptTemplates: true });
857
+ return leaving ? { opened: true, notice: `${leaving.name} carries on in the background` } : { opened: true };
858
+ }
859
+
825
860
  /** A switch is under way (between the reply and pi opening the next session). */
826
861
  let switching = false;
827
862
 
@@ -1267,6 +1302,7 @@ export function createLobbyService(state: Runtime): LobbyService {
1267
1302
  sendToSession: (sessionId, text) => sendToSession(state, sessionId, text),
1268
1303
  liveSessions: () => liveSessions(state),
1269
1304
  switchTo: (target) => switchTo(state, target),
1305
+ newSession: () => newSession(state),
1270
1306
  archivedTasks: () => listArchivedTasks(state.root, state.configDir),
1271
1307
  archiveTask: (taskId) => archiveTask(state, taskId),
1272
1308
  restoreTask: (taskId) => restoreTask(state, taskId),
@@ -57,16 +57,17 @@ const HELP = [
57
57
  "/bot-lobby carry-on <taskId> Take over a task no running session drives, unpause it and have the orchestrator carry it on (the Tasks screen's Resume)",
58
58
  "/bot-lobby auto [on|off] Auto mode: the orchestrator drives this session's task without asking (alt+g)",
59
59
  "/bot-lobby start-plan PLAN-… [auto] Start a planned task here; its agreed plan needs no approval",
60
+ "/bot-lobby new Open a fresh session in this window (named after its first prompt)",
60
61
  "/bot-lobby switch <session.jsonl> Run a saved session in this window (the web lobby's session browser uses it)",
61
62
  "/bot-lobby web [stop|link|reset] Open the browser UI (it starts with pi, on this machine only), or stop it, print its link, reset its link",
62
63
  "/bot-lobby help This help",
63
64
  ].join("\n");
64
65
 
65
66
  /** Subcommands only win when no free-form text follows (so tasks still start). */
66
- const SUBCOMMANDS = new Set(["lobby", "help", "status", "runs", "tasks", "pause", "resume", "cancel", "approve", "amend", "decline", "accept", "knowledge", "config", "settings", "on", "off", "minimize", "restore", "claim", "carry-on", "auto", "start-plan", "switch", "web"]);
67
+ const SUBCOMMANDS = new Set(["lobby", "help", "status", "runs", "tasks", "pause", "resume", "cancel", "approve", "amend", "decline", "accept", "knowledge", "config", "settings", "on", "off", "minimize", "restore", "claim", "carry-on", "auto", "start-plan", "switch", "new", "web"]);
67
68
 
68
69
  /** Subcommands that act on a task or open the lobby turn bot-lobby on first; the rest work while it is off. */
69
- const TURNS_ON = new Set(["lobby", "settings", "resume", "approve", "amend", "decline", "accept", "claim", "carry-on", "auto", "start-plan", "switch", "web"]);
70
+ const TURNS_ON = new Set(["lobby", "settings", "resume", "approve", "amend", "decline", "accept", "claim", "carry-on", "auto", "start-plan", "switch", "new", "web"]);
70
71
 
71
72
  /** `Task-Change-Table-Font-27-09-2026`, or an older `TASK-add-login` id. */
72
73
  function isTaskId(value: string | undefined): boolean {
@@ -330,6 +331,24 @@ async function switchCommand(ctx: ExtensionCommandContext, path: string): Promis
330
331
  }
331
332
  }
332
333
 
334
+ /**
335
+ * `/bot-lobby new`: open a fresh session in this window, as the lobby's New
336
+ * session asks. Like a switch, the context is stale once it lands.
337
+ */
338
+ async function newCommand(ctx: ExtensionCommandContext): Promise<void> {
339
+ let result: { cancelled: boolean };
340
+ try {
341
+ result = await ctx.newSession();
342
+ } catch (error) {
343
+ switchFailed();
344
+ throw error;
345
+ }
346
+ if (result.cancelled) {
347
+ switchFailed();
348
+ ctx.ui.notify("bot-lobby: the new session was cancelled", "warning");
349
+ }
350
+ }
351
+
333
352
  /** `/bot-lobby auto [on|off]`: switch (or set) auto mode for this session's task. */
334
353
  function autoCommand(ctx: ExtensionCommandContext, configDir: string, value: string | undefined): void {
335
354
  if (!value) return ctx.ui.notify(`bot-lobby: ${toggleOwnAuto()}`, "info");
@@ -407,6 +426,8 @@ export function registerCommands(pi: ExtensionAPI, configDir: string): void {
407
426
  return autoCommand(ctx, configDir, rest[0]);
408
427
  case "switch":
409
428
  return switchCommand(ctx, restText);
429
+ case "new":
430
+ return newCommand(ctx);
410
431
  case "web":
411
432
  return webCommand(ctx, rest[0]);
412
433
  case "start-plan": {
package/src/pi/events.ts CHANGED
@@ -64,7 +64,9 @@ export const LOBBY_CHAT_NOTE = [
64
64
  "## Bot Lobby chat",
65
65
  "You are the Master in Bot Lobby's chat: the user talks to the team here, and everyday work (questions, code changes, updates, minor fixes) happens in the chat itself, so do it directly.",
66
66
  "DESIGN, DEV, QA, RESEARCH and the scout answer in this chat too when the user names one with @ or the classifier gives a message to one; those lines reach you as \"The user asked …\" and \"… answered\" messages, for context: you need not answer them.",
67
- "Bot Lobby's workflow (scouts, a plan, the QA gate) runs only when the user types /plan (plan it with the panel) or /task (start it as a task). When a request is large, risky or spans several areas, suggest one of them in a line; never start one yourself.",
67
+ "You are the orchestrator, so judge each request before you act. Questions, explanations and small, clear changes (a few files in one area) you do yourself, right here.",
68
+ "Work that is large, risky or spans several areas (a new feature, frontend and backend together, an architecture change, anything that needs tests and review) goes to the team: call start_task with the request written in full, say in one line that you started a task, and end your turn. Effort decides its track, and the task's kickoff follows. Do not ask first.",
69
+ "If the request is unclear, ask one short question before starting a task. The user can also type /plan (plan it with the panel) or /task (start a task) themselves.",
68
70
  ].join("\n");
69
71
 
70
72
  /**
@@ -0,0 +1,94 @@
1
+ /**
2
+ * `start_task`: the Master's own way to turn a lobby request into a task.
3
+ * In the lobby chat it judges each message: a question or a small change it
4
+ * does itself; work that is large, risky or spans several areas it hands to
5
+ * the team by starting a task here, the same as the user typing `/task`.
6
+ * The task's track (fast or full) still comes from the effort and triage
7
+ * reads, and the kickoff follows the current turn, in a fresh context.
8
+ * While it drives a task, a message that is separate work starts its task in
9
+ * a new background session instead, and the current task carries on.
10
+ */
11
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
12
+ import { Container, Text } from "@earendil-works/pi-tui";
13
+ import { Type } from "typebox";
14
+ import { isSubagentProcess } from "./quiet.ts";
15
+ import { isMinimized } from "./ui.ts";
16
+ import { startTask } from "./start-task.ts";
17
+ import { activeTask } from "../state/persistence.ts";
18
+ import { detectProjectRoot } from "../state/project.ts";
19
+ import { lobbyFeed } from "../lobby/feed.ts";
20
+ import { lobbyTopics } from "../lobby/topics.ts";
21
+ import { startTaskInNewSession } from "../lobby/service.ts";
22
+ import type { TrackPath } from "../schemas/task.ts";
23
+
24
+ export const START_TASK_TOOL = "start_task";
25
+
26
+ const Params = Type.Object({
27
+ request: Type.String({ minLength: 1, maxLength: 8000, description: "The work, written in full for the team: what the user wants, the files or areas you already know it touches, and any constraint they gave. The task starts in a fresh context, so this must stand on its own." }),
28
+ title: Type.Optional(Type.String({ maxLength: 80, description: "A short title (3-8 words); derived from the request when absent." })),
29
+ track: Type.Optional(Type.Union([Type.Literal("fast"), Type.Literal("full")], { description: "Only when you are sure: fast (small and clear, straight to the agents) or full (scouts, proposal, QA). Left out, the effort read picks." })),
30
+ auto: Type.Optional(Type.Boolean({ description: "true only when the user asked for it to run without them (no proposal approval or questions)." })),
31
+ });
32
+
33
+ type StartTaskParams = { request: string; title?: string; track?: TrackPath; auto?: boolean };
34
+
35
+ const DESCRIPTION = [
36
+ "Start a bot-lobby task from the lobby chat and hand the work to the team (scouts, DESIGN/DEV workers, QA), the same as the user typing /task.",
37
+ "Use it when the request is too big to do well yourself in one reply: several files or areas, a new feature, a risky or architectural change, or work that needs tests and review.",
38
+ "Do questions, explanations and small, clear edits yourself instead.",
39
+ "While you drive a task, use it only for separate work that does not belong to that task: it starts in its own session and your task carries on. Work that changes or extends your task is a step of it (amend the plan), not a new task.",
40
+ "After calling it, tell the user in one short line that you started a task and why. With no task running, end your turn: the task's kickoff follows.",
41
+ ].join(" ");
42
+
43
+ export function registerStartTaskTool(pi: ExtensionAPI, configDir: string): void {
44
+ if (isSubagentProcess()) return;
45
+ pi.registerTool({
46
+ name: START_TASK_TOOL,
47
+ label: "Start task",
48
+ description: DESCRIPTION,
49
+ promptSnippet: "Turn a large lobby request into a bot-lobby task the team works on",
50
+ promptGuidelines: [
51
+ "In the lobby chat, judge each request: do small things yourself; call start_task for work that spans several areas, needs a plan, or needs tests and review.",
52
+ "While driving a task, judge each user message: a change to this task becomes a step (amend the plan); separate, sizeable work goes to start_task; a question or tiny unrelated fix you handle yourself.",
53
+ ],
54
+ parameters: Params,
55
+ async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
56
+ const call = params as StartTaskParams;
57
+ if (isMinimized()) throw new Error("bot-lobby is off in this session; do the work yourself or ask the user to turn it on.");
58
+ const root = detectProjectRoot(ctx.cwd, configDir);
59
+ const current = activeTask(root, configDir, ctx.sessionManager.getSessionId());
60
+ if (current) {
61
+ const started = startTaskInNewSession(call.request.trim(), { ...(call.track ? { track: call.track } : {}), ...(call.auto ? { auto: true } : {}) });
62
+ if (typeof started === "string") throw new Error(`${started}. Add it to ${current.id} as a step, or tell the user to start it with /task from another session.`);
63
+ lobbyFeed.log("LOBBY", `the orchestrator started separate work in a new session: ${started.name}`, "info");
64
+ return {
65
+ content: [{ type: "text", text: `Started "${started.name}" in its own session; ${current.id} carries on here. Tell the user in one line and continue your task.` }],
66
+ details: { session: started.name },
67
+ };
68
+ }
69
+ lobbyFeed.log("LOBBY", "the orchestrator is starting a task for this request", "info");
70
+ const task = await startTask(pi, ctx, configDir, call.request.trim(), {
71
+ ...(call.title?.trim() ? { title: call.title.trim() } : {}),
72
+ ...(call.track ? { track: call.track } : {}),
73
+ ...(call.auto ? { auto: true } : {}),
74
+ });
75
+ if (!task) throw new Error("the task did not start: this session already drives one.");
76
+ lobbyTopics.bump("tasks");
77
+ const path = task.track?.path === "fast" ? "fast track: straight to the agents" : "full track: scouts, then a proposal for the user";
78
+ return {
79
+ content: [{ type: "text", text: `Started ${task.id} (${task.title}), ${path}. Tell the user in one line and end your turn; the kickoff follows.` }],
80
+ details: { taskId: task.id, title: task.title, track: task.track?.path },
81
+ };
82
+ },
83
+ renderCall(args, theme) {
84
+ const call = args as Partial<StartTaskParams>;
85
+ return new Text(`${theme.fg("toolTitle", theme.bold("start task"))}${call.title ? ` ${theme.fg("accent", call.title)}` : ""}`, 0, 0);
86
+ },
87
+ renderResult(result, _options, theme) {
88
+ const details = result.details as { taskId?: string; track?: string; session?: string } | undefined;
89
+ if (details?.session) return new Text(`${theme.fg("success", "✓")} ${theme.fg("accent", details.session)} ${theme.fg("muted", "new session")}`, 0, 0);
90
+ if (!details?.taskId) return new Container();
91
+ return new Text(`${theme.fg("success", "✓")} ${theme.fg("accent", details.taskId)}${details.track ? ` ${theme.fg("muted", details.track)}` : ""}`, 0, 0);
92
+ },
93
+ });
94
+ }
package/src/text.ts CHANGED
@@ -57,6 +57,28 @@ export function shortTitle(request: string, maxWords = 3): string {
57
57
  return (content.length > 0 ? content : words).slice(0, maxWords).join(" ").replace(/[:;,]+$/, "");
58
58
  }
59
59
 
60
+ /**
61
+ * A session's name from its first prompt, read like a chat title: the prompt's
62
+ * opening words with polite lead-ins (`can you`, `please`) dropped, at most
63
+ * `maxWords` words and `maxChars` characters, cut between words, first letter
64
+ * capitalised (`Fix the flaky login test`). Empty when the prompt has no words.
65
+ */
66
+ export function sessionTitle(prompt: string, maxWords = 7, maxChars = 48): string {
67
+ const words = titleText(prompt).split(/\s+/).filter((word) => /[\p{L}\p{N}]/u.test(word));
68
+ let start = 0;
69
+ // Polite lead-ins and leading @mentions (`@Design does…`) are not what the session is about.
70
+ while (start < words.length - 1 && (FILLER_WORDS.has(fillerKey(words[start]!)) || words[start]!.startsWith("@"))) start += 1;
71
+ const kept: string[] = [];
72
+ for (const word of words.slice(start, start + maxWords)) {
73
+ if ([...kept, word].join(" ").length > maxChars && kept.length > 0) break;
74
+ kept.push(word);
75
+ }
76
+ // A title ends on a word that matters, not on `and`, `the` or a comma.
77
+ while (kept.length > 1 && (NAME_CONNECTORS.has(fillerKey(kept.at(-1)!)) || FILLER_WORDS.has(fillerKey(kept.at(-1)!)))) kept.pop();
78
+ const title = kept.join(" ").replace(/[\s:;,.!?…-]+$/u, "").replace(/^[^\p{L}\p{N}]+/u, "");
79
+ return title.charAt(0).toLocaleUpperCase() + title.slice(1);
80
+ }
81
+
60
82
  /** Words a task's name leaves out: they join the words that matter without being any of them. */
61
83
  const NAME_CONNECTORS = new Set(["and", "or", "but", "with", "without", "on", "in", "at", "of", "by", "from", "into", "so", "as", "is", "are", "be", "it", "its", "that", "this", "then", "also", "just", "some"]);
62
84
 
@@ -17,7 +17,7 @@ import { plannerAnswer, plannerCommentLine, plannerGet, plannerNew, plannerRetry
17
17
  import { tasksArchive, tasksArchived, tasksAuto, tasksComment, tasksComments, tasksDelete, tasksEditComment, tasksGet, tasksList, tasksMessage, tasksRestore, tasksOpen, tasksResume, tasksDeliveryReview, tasksDeliveryDefer, tasksDeliver, tasksAccept, tasksSkipStep, tasksForceClose, tasksResolveApproval } from "./tasks.ts";
18
18
  import { knowledgeAccept, knowledgeAdd, knowledgeAsk, knowledgeComment, knowledgeDismiss, knowledgeEdit, knowledgeFiles, knowledgeLedger, knowledgeMove, knowledgeOpen, knowledgePin, knowledgeRemove, knowledgeReplaceFile, knowledgeRestore, knowledgeUnnote } from "./knowledge.ts";
19
19
  import { plansDiscard, plansGet, plansStart } from "./plans.ts";
20
- import { sessionsAnswer, sessionsArchive, sessionsChat, sessionsDelete, sessionsList, sessionsMessage, sessionsRename, sessionsStart, sessionsStop, sessionsSwitch } from "./sessions.ts";
20
+ import { sessionsAnswer, sessionsArchive, sessionsChat, sessionsDelete, sessionsList, sessionsMessage, sessionsNew, sessionsRename, sessionsStart, sessionsStop, sessionsSwitch } from "./sessions.ts";
21
21
  import { settingsGet, settingsGrants, settingsHarnesses, settingsLintCreate, settingsLinters, settingsLintRule, settingsLintSetup, settingsSet } from "./settings.ts";
22
22
  import { lobbyRetention, lobbySetRetention } from "./retention.ts";
23
23
  import { terminalClose, terminalInput, terminalList, terminalOpen, terminalResize } from "./terminal.ts";
@@ -224,6 +224,7 @@ function buildRoutes(): Record<string, Route> {
224
224
  schema: Type.Object({ key: Type.Optional(TaskId), sessionId: Type.Optional(TaskId), text: NoticeText, attachments: Attachments }, { additionalProperties: false }),
225
225
  run: (body, ctx) => sessionsMessage(body as { key?: string; sessionId?: string; text: string; attachments?: string[] }, ctx),
226
226
  };
227
+ routes["sessions.new"] = { schema: Empty, run: (_body, ctx) => sessionsNew(ctx) };
227
228
  routes["sessions.switch"] = {
228
229
  schema: Type.Object({ key: Type.Optional(TaskId), sessionId: Type.Optional(TaskId), claimTaskId: Type.Optional(TaskId) }, { additionalProperties: false }),
229
230
  run: (body, ctx) => sessionsSwitch(body as { key?: string; sessionId?: string; claimTaskId?: string }, ctx),
@@ -89,6 +89,12 @@ export function sessionsMessage(body: { key?: string; sessionId?: string; text:
89
89
  return { notice: ctx.service.sendToSession(body.sessionId!, text) };
90
90
  }
91
91
 
92
+ /** Open a fresh, empty session in this window; it is named after its first prompt. */
93
+ export function sessionsNew(ctx: ApiContext): { opened: boolean; notice?: string } {
94
+ if (!ctx.service.newSession) fail(501, "unsupported", "this lobby cannot open a new session");
95
+ return ctx.service.newSession!();
96
+ }
97
+
92
98
  /** Run a session in this window (stopping its background process first); a window at work carries its own session on in the background. */
93
99
  export async function sessionsSwitch(body: { key?: string; sessionId?: string; claimTaskId?: string }, ctx: ApiContext): Promise<{ notice: string }> {
94
100
  if (!body.key && !body.sessionId && !body.claimTaskId) fail(400, "bad_request", "a session key, id or task is required");
@@ -486,6 +486,7 @@ export function createFixtureService(name: string, feed = new LobbyFeed()): Lobb
486
486
  planningRounds: () => 5,
487
487
  sessionChat: () => [],
488
488
  hasOlderChat: () => false,
489
+ newSession: () => (fixture.status.busy ? { opened: true, notice: `${sessionName ?? "this window's session"} carries on in the background` } : { opened: true }),
489
490
  switchTo: async (target: { name: string }) => (fixture.status.busy ? `${sessionName ?? "this window's session"} carries on in the background; switching this window to ${target.name}…` : `switching this window to ${target.name}…`),
490
491
  } as unknown as LobbyService;
491
492
  seedPrompts(service, fixture);
@@ -513,6 +513,7 @@ export interface Api {
513
513
  "sessions.start": { request: { request?: string; planId?: string; auto?: boolean; attachments?: string[] }; result: { notice: string; key?: string } };
514
514
  "sessions.stop": { request: { key: string }; result: { notice: string } };
515
515
  "sessions.message": { request: { key?: string; sessionId?: string; text: string; attachments?: string[] }; result: { notice?: string } };
516
+ "sessions.new": { request: Record<string, never>; result: { opened: boolean; notice?: string } };
516
517
  "sessions.switch": { request: { key?: string; sessionId?: string; claimTaskId?: string }; result: { notice: string } };
517
518
  "sessions.answer": { request: { key: string; dialogId: string; answer: DialogAnswer }; result: { notice: string } };
518
519
  "sessions.rename": { request: { key?: string; name: string }; result: { notice: string } };
Binary file
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/astro-p42oEArs.js","assets/json-qhed-kSA.js","assets/javascript-BgS3c2Ky.js","assets/typescript-BydbNFcO.js","assets/rolldown-runtime-hePW80VL.js","assets/css-C8fQr_0Q.js","assets/postcss-D_Wz94rJ.js","assets/tsx-CUOciP0b.js","assets/graphql-AVu4aKQX.js","assets/jsx-gTgmArGx.js","assets/html-wSbaAAK3.js","assets/java-DdHNQ9hk.js","assets/kts-DFAlwc6n.js","assets/kotlin-DhhofPvG.js","assets/lua-xZcbXUE9.js","assets/c-DaO8xguW.js","assets/php-C6PDnbTe.js","assets/xml-CeXJrFlG.js","assets/sql-CEbI0hMM.js","assets/properties-CxAuzHS9.js","assets/ini-B5eOa1yu.js","assets/ruby-CPL7DL0w.js","assets/shellscript-CLZ0U2zV.js","assets/yaml-rwi0_p6S.js","assets/scss-CHVQqdPx.js","assets/svelte-DKhxH1PN.js","assets/vue-kBwcnTZb.js","assets/yml-s9iVJXCw.js","assets/zsh-B7CDPTg5.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./ccount-DQxSH8e6.js";import{t as d}from"./index-BUrfox9b.js";var f={}.hasOwnProperty;function p(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&f.call(t,e)){let n=String(t[e]);i=f.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var m=10,h=13,g=4,_=40;function v(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
2
+ import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{a as n,c as r,i,l as a,n as o,o as s,r as c,s as l,t as u}from"./ccount-DQxSH8e6.js";import{t as d}from"./index-BcsQfVsV.js";var f={}.hasOwnProperty;function p(e,t){let n=t||{};function r(t,...n){let i=r.invalid,a=r.handlers;if(t&&f.call(t,e)){let n=String(t[e]);i=f.call(a,n)?a[n]:r.unknown}if(i)return i.call(this,t,...n)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}var m=10,h=13,g=4,_=40;function v(e){let t=[0],n=e.indexOf(`\r`),r=e.indexOf(`
3
3
  `),i=0,a=0;for(;n!==-1||r!==-1;){let o;if(n!==-1&&(r===-1||n<r)?r===n+1?(o=r+1,n=e.indexOf(`\r`,o),r=e.indexOf(`
4
4
  `,o)):(o=n+1,n=e.indexOf(`\r`,o)):(o=r+1,r=e.indexOf(`
5
5
  `,o)),t.push(o),++a===g){if(o-i<=_){for(let n=o;n<e.length;n++){let r=e.charCodeAt(n);(r===m||r===h)&&(r===h&&n+1<e.length&&e.charCodeAt(n+1)===m&&n++,t.push(n+1))}return t}i=o,a=0}}return t}function y(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);(r===m||r===h)&&(r===h&&n+1<e.length&&e.charCodeAt(n+1)===m&&n++,t++)}return t}function b(e){let t=v(e);return Array.from({length:t.length},(n,r)=>{let i=t[r],a=t[r+1]??e.length;return e.slice(i,a)})}var x=100,S=`insert`,C=`backspace`,w=`delete`,T=class e{#e=[];#t=[];#n;#r=!1;constructor(e){this.#n=Math.max(1,e?.maxEntries??x)}get canUndo(){return this.#e.length>0}get canRedo(){return this.#t.length>0}getState(){return{undoStack:this.#e.map(ee),redoStack:this.#t.map(ee),maxEntries:this.#n,canCoalesce:this.#r}}getLiveState(){return Object.defineProperties({},{undoStack:{enumerable:!0,get:()=>this.#e},redoStack:{enumerable:!0,get:()=>this.#t},maxEntries:{enumerable:!0,get:()=>this.#n},canCoalesce:{enumerable:!0,get:()=>this.#r}})}static fromState(t){let n=new e({maxEntries:t.maxEntries});return n.#e=t.undoStack,n.#t=t.redoStack,n.#r=t.canCoalesce,n}clear(){this.#e.length=0,this.#t.length=0,this.#r=!1}clearRedo(){this.#t.length=0}push(e){this.#e.push(e),this.clearRedo(),this.#r=!0,this.#e.length>this.#n&&this.#e.shift()}setLastUndoSelectionsAfter(e){let t=this.#e[this.#e.length-1];t!==void 0&&(t.selectionsAfter=e.map(e=>({...e})))}setLastUndoLineAnnotations(e,t){let n=this.#e[this.#e.length-1];n!==void 0&&(n.lineAnnotationsBefore=e.slice(),n.lineAnnotationsAfter=t.slice())}peekUndo(){return this.#e[this.#e.length-1]}peekUndoForCoalescing(){return this.#r?this.peekUndo():void 0}replaceLastUndo(e){if(this.#e.length===0){this.push(e);return}this.#e[this.#e.length-1]=e,this.clearRedo(),this.#r=!0}popUndoToRedo(){let e=this.#e.pop();if(e!==void 0)return this.#t.push(e),this.#r=!1,e}popRedoToUndo(){let e=this.#t.pop();if(e!==void 0)return this.#e.push(e),this.#r=!1,e}};function E(e){return{...e,forwardEdits:e.forwardEdits.map(e=>({...e})),inverseEdits:e.inverseEdits.map(e=>({...e})),selectionsBefore:e.selectionsBefore?.map(D),selectionsAfter:e.selectionsAfter?.map(D),lineAnnotationsBefore:e.lineAnnotationsBefore?.slice(),lineAnnotationsAfter:e.lineAnnotationsAfter?.slice()}}function ee(e){return{...E(e),lineAnnotationsBefore:e.lineAnnotationsBefore?.map(e=>({...e})),lineAnnotationsAfter:e.lineAnnotationsAfter?.map(e=>({...e}))}}function D(e){return{...e,start:{...e.start},end:{...e.end}}}function O(e,t,n,r,i,a,o,s){let c=[...t].sort((e,t)=>e.start-t.start),l=[],u;if(i?.length===c.length){let t=[];for(let n of i){if(n.start.line!==n.end.line||n.start.character!==n.end.character)break;t.push(e.offsetAt(n.start))}if(t.length===c.length){t.sort((e,t)=>e-t);let e=!0,n=!0;for(let r=0;r<c.length;r++){let i=c[r];if(i.text.length>0||i.start===i.end){e=!1,n=!1;break}e&&=t[r]===i.end,n&&=t[r]===i.start}u=e?C:n?w:void 0}}for(let t=0,n=0;t<c.length;t++){let r=c[t],i=e.getTextSlice(r.start,r.end),a=r.start+n;l.push({start:a,end:a+r.text.length,text:i}),n+=r.text.length-(r.end-r.start)}return{forwardEdits:c.map(e=>({...e})),inverseEdits:l,versionBefore:n,versionAfter:r,selectionsBefore:i?.map(e=>({...e})),selectionsAfter:a?.map(e=>({...e})),lineAnnotationsBefore:o?.slice(),lineAnnotationsAfter:s?.slice(),coalescingMode:u}}function k(e,t){if(e===void 0||e.undoBoundary===!0||t.undoBoundary===!0||e.forwardEdits.length===0||e.forwardEdits.length!==e.inverseEdits.length||e.forwardEdits.length!==t.forwardEdits.length||t.forwardEdits.length!==t.inverseEdits.length)return!1;let n;for(let r=0;r<e.forwardEdits.length;r++){let i=e.forwardEdits[r],a=e.inverseEdits[r],o=t.forwardEdits[r],s=t.inverseEdits[r],c=ne(o.start,e.forwardEdits),l=i.start<=i.end&&i.text.length>0&&!i.text.includes(`
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./ccount-DQxSH8e6.js";import{i as r,n as i,r as a}from"./index-BUrfox9b.js";var o=e(n(),1),s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{for(var i=r>1?void 0:r?c(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&s(t,n,i),i},d=(e,t)=>(n,r)=>t(n,r,e),f=`Terminal input`,p={get:()=>f,set:e=>f=e},m=`Too much output to announce, navigate to rows manually to read`,h={get:()=>m,set:e=>m=e};function g(e){return e.replace(/\r?\n/g,`\r`)}function _(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ee(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function te(e,t,n,r){e.stopPropagation(),e.clipboardData&&ne(e.clipboardData.getData(`text/plain`),t,n,r)}function ne(e,t,n,r){e=g(e),e=_(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function re(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ie(e,t,n,r,i){re(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ae(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ce=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},v=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new de}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},de=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},y=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new de,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ae(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fe=`di$target`,pe=`di$dependencies`,me=new Map;function b(e){return e[pe]||[]}function x(e){if(me.has(e))return me.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);he(t,e,r)};return t._id=e,me.set(e,t),t}function he(e,t,n){t[fe]===t?t[pe].push({id:e,index:n}):(t[pe]=[{id:e,index:n}],t[fe]=t)}var S=x(`BufferService`),ge=x(`CoreMouseService`),_e=x(`CoreService`),C=x(`CharsetService`),ve=x(`InstantiationService`),w=x(`LogService`),T=x(`OptionsService`),ye=x(`OscLinkService`),be=x(`UnicodeService`),xe=x(`DecorationService`),Se=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new y,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ce(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Se=u([d(0,S),d(1,T),d(2,ye)],Se);function Ce(e,t){if(confirm(`Do you want to navigate to ${t}?
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,l as n}from"./ccount-DQxSH8e6.js";import{i as r,n as i,r as a}from"./index-BcsQfVsV.js";var o=e(n(),1),s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=(e,t)=>{for(var n in t)s(e,n,{get:t[n],enumerable:!0})},u=(e,t,n,r)=>{for(var i=r>1?void 0:r?c(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&s(t,n,i),i},d=(e,t)=>(n,r)=>t(n,r,e),f=`Terminal input`,p={get:()=>f,set:e=>f=e},m=`Too much output to announce, navigate to rows manually to read`,h={get:()=>m,set:e=>m=e};function g(e){return e.replace(/\r?\n/g,`\r`)}function _(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function ee(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function te(e,t,n,r){e.stopPropagation(),e.clipboardData&&ne(e.clipboardData.getData(`text/plain`),t,n,r)}function ne(e,t,n,r){e=g(e),e=_(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function re(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ie(e,t,n,r,i){re(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function ae(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function oe(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var se=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},ce=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},v=``,le=` `,ue=class e{constructor(){this.fg=0,this.bg=0,this.extended=new de}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},de=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},y=class e extends ue{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new de,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?ae(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},fe=`di$target`,pe=`di$dependencies`,me=new Map;function b(e){return e[pe]||[]}function x(e){if(me.has(e))return me.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);he(t,e,r)};return t._id=e,me.set(e,t),t}function he(e,t,n){t[fe]===t?t[pe].push({id:e,index:n}):(t[pe]=[{id:e,index:n}],t[fe]=t)}var S=x(`BufferService`),ge=x(`CoreMouseService`),_e=x(`CoreService`),C=x(`CharsetService`),ve=x(`InstantiationService`),w=x(`LogService`),T=x(`OptionsService`),ye=x(`OscLinkService`),be=x(`UnicodeService`),xe=x(`DecorationService`),Se=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new y,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(c!==-1||n.hasContent(t)){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId){if(c===-1){c=t,s=a.extended.urlId;continue}l=a.extended.urlId!==s}else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):Ce(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Se=u([d(0,S),d(1,T),d(2,ye)],Se);function Ce(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var we=x(`CharSizeService`),Te=x(`CoreBrowserService`),Ee=x(`MouseService`),De=x(`RenderService`),Oe=x(`SelectionService`),ke=x(`CharacterJoinerService`),Ae=x(`ThemeService`),je=x(`LinkProviderService`),Me=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Re.isErrorNoTelemetry(e)?new Re(e.message+`
4
4