@paradow/ledge 0.5.4 → 0.6.0

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.
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  QUESTION_TOOLS
3
- } from "./chunk-NKBJ3LD4.js";
3
+ } from "./chunk-VK2IBMW7.js";
4
4
  import {
5
5
  CODEX_ENV_VAR,
6
6
  CODEX_HOOK_VAR,
7
7
  codexPlan
8
- } from "./chunk-U4RU6V35.js";
8
+ } from "./chunk-HYB7ZZN4.js";
9
9
  import {
10
10
  log
11
- } from "./chunk-P2SHPHAN.js";
11
+ } from "./chunk-L6IGH4LF.js";
12
12
  import {
13
13
  connect
14
- } from "./chunk-IDGN7JGC.js";
15
- import "./chunk-E6ZQOGY4.js";
14
+ } from "./chunk-Z4YH2DLP.js";
15
+ import "./chunk-AEV7ODMZ.js";
16
16
 
17
17
  // src/cli/hook.ts
18
18
  import { readFileSync, openSync, fstatSync, readSync, closeSync } from "fs";
package/dist/cli/index.js CHANGED
@@ -16,7 +16,7 @@ async function hookMain(args) {
16
16
  try {
17
17
  const chunks = [];
18
18
  for await (const c of process.stdin) chunks.push(c);
19
- const { runHook } = await import("./hook-ARQEXMYY.js");
19
+ const { runHook } = await import("./hook-CT5OKGHQ.js");
20
20
  await runHook(event, Buffer.concat(chunks).toString("utf8"), { tool });
21
21
  } catch {
22
22
  }
@@ -26,7 +26,7 @@ async function main(argv) {
26
26
  const [cmd, ...rest] = argv;
27
27
  switch (cmd) {
28
28
  case "daemon": {
29
- const { startDaemon } = await import("./daemon-P5XWP2UC.js");
29
+ const { startDaemon } = await import("./daemon-SKI3UKOJ.js");
30
30
  await startDaemon();
31
31
  await new Promise(() => {
32
32
  });
@@ -34,39 +34,39 @@ async function main(argv) {
34
34
  }
35
35
  case "--version":
36
36
  case "version": {
37
- const { LEDGE_VERSION } = await import("./version-G5DZ7PFI.js");
37
+ const { LEDGE_VERSION } = await import("./version-3CHJ23IV.js");
38
38
  console.log(LEDGE_VERSION);
39
39
  return 0;
40
40
  }
41
41
  case "setup": {
42
- const { runSetup } = await import("./setup-EXA6OG5W.js");
42
+ const { runSetup } = await import("./setup-RMPIUCPH.js");
43
43
  for (const l of await runSetup()) console.log(l);
44
44
  return 0;
45
45
  }
46
46
  case "uninstall": {
47
- const { runUninstall } = await import("./uninstall-34TVL5BP.js");
47
+ const { runUninstall } = await import("./uninstall-GI4WT3UQ.js");
48
48
  const r = await runUninstall({ purge: rest.includes("--purge") });
49
49
  for (const l of r.lines) console.log(l);
50
50
  return r.ok ? 0 : 1;
51
51
  }
52
52
  case "status": {
53
- const { printStatus } = await import("./status-6OOVUG3V.js");
53
+ const { printStatus } = await import("./status-TACDR6DZ.js");
54
54
  console.log(await printStatus());
55
55
  return 0;
56
56
  }
57
57
  case "bridge": {
58
- const { bridge } = await import("./bridge-7RXMJSOP.js");
58
+ const { bridge } = await import("./bridge-AFAK3FU5.js");
59
59
  await bridge();
60
60
  return 0;
61
61
  }
62
62
  case "claude":
63
63
  case "codex":
64
64
  case "cursor": {
65
- const { launch } = await import("./launch-GRWEWGSC.js");
65
+ const { launch } = await import("./launch-LVMFX3KF.js");
66
66
  return launch(cmd, rest);
67
67
  }
68
68
  case "attach": {
69
- const { attach } = await import("./attach-QE22G2GY.js");
69
+ const { attach } = await import("./attach-FDMNVXYR.js");
70
70
  return attach(rest[0] ?? "");
71
71
  }
72
72
  default:
@@ -5,15 +5,15 @@ import {
5
5
  ensureDaemon,
6
6
  launch,
7
7
  parseLaunchArgs
8
- } from "./chunk-ISPFJBJM.js";
8
+ } from "./chunk-QJG7M6BJ.js";
9
9
  import {
10
10
  agentEnv,
11
11
  exitFile
12
- } from "./chunk-U4RU6V35.js";
13
- import "./chunk-XZMLFV6H.js";
14
- import "./chunk-P2SHPHAN.js";
15
- import "./chunk-IDGN7JGC.js";
16
- import "./chunk-E6ZQOGY4.js";
12
+ } from "./chunk-HYB7ZZN4.js";
13
+ import "./chunk-3TNPEAMR.js";
14
+ import "./chunk-L6IGH4LF.js";
15
+ import "./chunk-Z4YH2DLP.js";
16
+ import "./chunk-AEV7ODMZ.js";
17
17
  export {
18
18
  DaemonError,
19
19
  agentEnv,
@@ -13,9 +13,9 @@ import {
13
13
  runSetup,
14
14
  stopDetachedDaemon,
15
15
  systemdUnit
16
- } from "./chunk-HGNMPXXR.js";
17
- import "./chunk-XZMLFV6H.js";
18
- import "./chunk-P2SHPHAN.js";
16
+ } from "./chunk-Q5CLZPYJ.js";
17
+ import "./chunk-3TNPEAMR.js";
18
+ import "./chunk-L6IGH4LF.js";
19
19
  export {
20
20
  CLAUDE_EVENTS,
21
21
  CODEX_EVENTS,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  connect
3
- } from "./chunk-IDGN7JGC.js";
4
- import "./chunk-E6ZQOGY4.js";
3
+ } from "./chunk-Z4YH2DLP.js";
4
+ import "./chunk-AEV7ODMZ.js";
5
5
 
6
6
  // src/cli/status.ts
7
7
  async function printStatus(opts = {}) {
@@ -2,11 +2,11 @@ import {
2
2
  SERVICE,
3
3
  execRunner,
4
4
  stopDetachedDaemon
5
- } from "./chunk-HGNMPXXR.js";
6
- import "./chunk-XZMLFV6H.js";
5
+ } from "./chunk-Q5CLZPYJ.js";
6
+ import "./chunk-3TNPEAMR.js";
7
7
  import {
8
8
  paths
9
- } from "./chunk-P2SHPHAN.js";
9
+ } from "./chunk-L6IGH4LF.js";
10
10
 
11
11
  // src/cli/uninstall.ts
12
12
  import { readFile, writeFile, rename, rm, lstat, realpath } from "fs/promises";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  LEDGE_VERSION
3
- } from "./chunk-BRJSMZ7B.js";
3
+ } from "./chunk-FFVZIXKG.js";
4
4
  export {
5
5
  LEDGE_VERSION
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paradow/ledge",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "description": "Follow and answer your WSL agent sessions (Claude Code, Codex, Cursor Agent) from the Ledge island on Windows.",
5
5
  "type": "module",
6
6
  "bin": { "ledge": "dist/cli/index.js" },
@@ -1,6 +0,0 @@
1
- // src/version.ts
2
- var LEDGE_VERSION = true ? "0.5.4" : "0.0.0-dev";
3
-
4
- export {
5
- LEDGE_VERSION
6
- };
@@ -1,448 +0,0 @@
1
- // ../protocol/src/messages.ts
2
- import { z as z7 } from "zod";
3
-
4
- // ../protocol/src/session.ts
5
- import { z } from "zod";
6
- var ToolSchema = z.enum(["claude", "codex", "cursor"]);
7
- var SessionStateSchema = z.enum(["starting", "working", "waiting_input", "waiting_permission", "idle", "exited", "error"]);
8
- var PendingSchema = z.object({
9
- kind: z.enum(["question", "permission", "plan", "diff"]),
10
- text: z.string(),
11
- /** What to review in full before deciding, when `text` is only its summary: a plan's markdown. */
12
- body: z.string().optional(),
13
- tool: z.string().optional(),
14
- options: z.array(z.string()).optional(),
15
- /** Each option's description, by index ('' when it has none); left out when no option has one. */
16
- optionDetails: z.array(z.string()).optional(),
17
- source: z.enum(["hook", "pane"]),
18
- /** Set when the request comes from a helper (subagent): it is routed through its parent. */
19
- helperId: z.string().optional(),
20
- /** For a helper-routed request: the state the parent returns to once it is answered (main thread may stop meanwhile). */
21
- parentState: SessionStateSchema.optional()
22
- });
23
- var ReplySchema = z.object({
24
- text: z.string(),
25
- at: z.string().datetime(),
26
- /** The reply is a plan the agent proposes (Codex Plan mode): nothing in it is done yet. */
27
- plan: z.boolean().optional()
28
- });
29
- var HelperSchema = z.object({
30
- id: z.string(),
31
- kind: z.string(),
32
- task: z.string(),
33
- state: SessionStateSchema
34
- });
35
- var TopicSourceSchema = z.enum(["user", "pane", "prompt"]);
36
- var SessionSchema = z.object({
37
- /** Origin is annotated by the overlay, never used as an unqualified session id on the wire. */
38
- machineId: z.string().optional(),
39
- machineName: z.string().optional(),
40
- repoId: z.string().optional(),
41
- id: z.string().min(1),
42
- name: z.string().min(1),
43
- tool: ToolSchema,
44
- cwd: z.string(),
45
- project: z.string(),
46
- title: z.string(),
47
- /** One line saying what the session is about (spec 2026-10-11 §3). */
48
- topic: z.string().optional(),
49
- topicSource: TopicSourceSchema.optional(),
50
- /** The repository (its main worktree's folder name and absolute path), the checked-out branch, and whether `cwd` is a linked worktree (§4). */
51
- repo: z.string().optional(),
52
- repoPath: z.string().optional(),
53
- branch: z.string().optional(),
54
- worktree: z.boolean().optional(),
55
- tmuxSession: z.string().nullable(),
56
- state: SessionStateSchema,
57
- pending: PendingSchema.optional(),
58
- helpers: z.array(HelperSchema).default([]),
59
- lastReply: ReplySchema.optional(),
60
- startedAt: z.string().datetime(),
61
- lastActivityAt: z.string().datetime(),
62
- lastHookAt: z.string().datetime().optional(),
63
- /** The agent's own session id when Ledge chose it at launch (Claude Code `--session-id`). */
64
- agentSessionId: z.string().optional(),
65
- /** The agent's transcript: the latest one a hook named (it follows /clear and --resume), else the one the launch implies. */
66
- transcriptPath: z.string().optional(),
67
- exitCode: z.number().int().nullable().optional(),
68
- exitedAt: z.string().datetime().optional(),
69
- lastError: z.string().optional(),
70
- source: z.enum(["launcher", "hook_only"])
71
- });
72
-
73
- // ../protocol/src/chat.ts
74
- import { z as z2 } from "zod";
75
- var ChatStepSchema = z2.object({
76
- kind: z2.enum(["sessions", "pane", "reply", "git", "repo"]),
77
- id: z2.string().optional(),
78
- name: z2.string().optional(),
79
- path: z2.string().optional()
80
- });
81
- var ChatProposalSchema = z2.object({
82
- cwd: z2.string().min(1),
83
- project: z2.string(),
84
- prompt: z2.string().optional(),
85
- tool: ToolSchema,
86
- launchedId: z2.string().optional(),
87
- error: z2.string().optional()
88
- });
89
- var ChatRelaySchema = z2.object({
90
- id: z2.string().min(1),
91
- name: z2.string(),
92
- tool: ToolSchema,
93
- text: z2.string().min(1),
94
- status: z2.enum(["queued", "sent"]).optional(),
95
- sentAt: z2.string().datetime().optional(),
96
- error: z2.string().optional()
97
- });
98
- var ChatTurnSchema = z2.object({
99
- machineId: z2.string().optional(),
100
- machineName: z2.string().optional(),
101
- choices: z2.array(z2.object({ id: z2.string(), label: z2.string() })).optional(),
102
- qid: z2.string().min(1),
103
- question: z2.string(),
104
- askedAt: z2.string().datetime(),
105
- steps: z2.array(ChatStepSchema),
106
- answer: z2.string().optional(),
107
- answeredAt: z2.string().datetime().optional(),
108
- error: z2.string().optional(),
109
- proposal: ChatProposalSchema.optional(),
110
- relay: ChatRelaySchema.optional()
111
- });
112
-
113
- // ../protocol/src/documents.ts
114
- import { z as z3 } from "zod";
115
- var DOCUMENT_MAX_BYTES = 1048576;
116
- var path = z3.string().min(1).max(4096);
117
- var requestId = z3.string().min(1);
118
- var DocumentReadSchema = z3.object({
119
- type: z3.literal("document.read"),
120
- requestId,
121
- path,
122
- machineId: z3.string().optional(),
123
- sessionId: z3.string().min(1).optional(),
124
- basePath: path.optional()
125
- });
126
- var DocumentContentSchema = z3.object({
127
- type: z3.literal("document.content"),
128
- requestId,
129
- path,
130
- text: z3.string(),
131
- bytes: z3.number().int().nonnegative(),
132
- modifiedAt: z3.string().datetime()
133
- });
134
- var DocumentErrorCodeSchema = z3.enum([
135
- "not_found",
136
- "not_file",
137
- "unsupported_path",
138
- "unsupported_type",
139
- "permission_denied",
140
- "too_large",
141
- "invalid_utf8",
142
- "ambiguous_path",
143
- "session_missing",
144
- "read_failed"
145
- ]);
146
- var DocumentErrorSchema = z3.object({
147
- type: z3.literal("document.error"),
148
- requestId,
149
- path,
150
- code: DocumentErrorCodeSchema
151
- });
152
-
153
- // ../protocol/src/routing.ts
154
- import { z as z4 } from "zod";
155
- var MachineInventorySchema = z4.object({
156
- id: z4.string().min(1).max(80),
157
- label: z4.string().min(1).max(120),
158
- online: z4.boolean(),
159
- local: z4.boolean(),
160
- sessions: z4.array(z4.object({ id: z4.string(), name: z4.string(), project: z4.string(), cwd: z4.string(), topic: z4.string().optional(), state: z4.string(), readOnly: z4.boolean() })).max(500),
161
- folders: z4.array(z4.object({ project: z4.string(), cwd: z4.string() })).max(100)
162
- });
163
- var RoutingContextSchema = z4.object({
164
- machines: z4.array(MachineInventorySchema).min(1).max(20),
165
- history: z4.array(z4.object({ question: z4.string().max(2e4), answer: z4.string().max(2e4).optional(), machineId: z4.string().optional() })).max(50)
166
- });
167
- var RouteResultSchema = z4.object({
168
- /** Null means an answer or a clarification, never an implicit local destination. */
169
- machineId: z4.string().nullable(),
170
- text: z4.string().min(1).max(2e4),
171
- choices: z4.array(z4.string()).max(20).optional()
172
- });
173
-
174
- // ../protocol/src/ssh.ts
175
- import { z as z5 } from "zod";
176
- var SshAliasSchema = z5.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/);
177
-
178
- // ../protocol/src/thread.ts
179
- import { z as z6 } from "zod";
180
- var ToolStatusSchema = z6.enum(["running", "success", "failed", "unknown"]);
181
- var FileChangeSchema = z6.object({ path: z6.string().min(1), change: z6.enum(["add", "edit", "delete", "write"]), diff: z6.string().optional() });
182
- var base = { id: z6.string().min(1), at: z6.string().datetime(), turn: z6.number().int().nonnegative(), helperId: z6.string().optional() };
183
- var ThreadItemSchema = z6.discriminatedUnion("kind", [
184
- z6.object({ kind: z6.literal("prompt"), ...base, text: z6.string() }),
185
- z6.object({ kind: z6.literal("message"), ...base, text: z6.string() }),
186
- /** `id` is the harness's tool_use_id when it gives one, so the result updates the same row. */
187
- z6.object({ kind: z6.literal("tool"), ...base, tool: z6.string(), label: z6.string(), input: z6.string().optional(), output: z6.string().optional(), error: z6.string().optional(), status: ToolStatusSchema, durationMs: z6.number().nonnegative().optional(), files: z6.array(FileChangeSchema).default([]) }),
188
- /** `unknown`: answered in the terminal, the daemon only saw the prompt go away. */
189
- z6.object({ kind: z6.literal("permission"), ...base, tool: z6.string(), text: z6.string(), decision: z6.enum(["accept", "deny", "unknown"]).optional() }),
190
- z6.object({ kind: z6.literal("reply"), ...base, text: z6.string() }),
191
- z6.object({ kind: z6.literal("helper"), ...base, task: z6.string(), agentType: z6.string().optional(), state: z6.enum(["working", "exited"]) })
192
- ]);
193
-
194
- // ../protocol/src/messages.ts
195
- var PROTOCOL_PORT = 47831;
196
- var SessionEventSchema = z7.object({
197
- name: z7.enum(["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "Notification", "Stop", "SessionEnd", "PaneChanged", "PaneGone", "PanePrompt", "PaneIdle", "InjectFailed", "Decided", "PostToolUse", "PostToolUseFailure", "StopFailure", "SubagentStart", "SubagentStop", "PaneTitle", "Renamed"]),
198
- at: z7.string().datetime(),
199
- source: z7.enum(["hook", "pane", "daemon"]),
200
- tool: z7.string().optional(),
201
- text: z7.string().optional(),
202
- options: z7.array(z7.string()).optional(),
203
- /** Each option's description, by index ('' when it has none); left out when no option has one. */
204
- optionDetails: z7.array(z7.string()).optional(),
205
- kind: z7.enum(["question", "permission", "plan", "diff"]).optional(),
206
- /** PanePrompt: what to review in full before deciding (a plan read in the terminal), when `text` is its summary. */
207
- body: z7.string().optional(),
208
- exitCode: z7.number().int().nullable().optional(),
209
- helperId: z7.string().optional(),
210
- /** The helper's description, once known (Claude Code: its `.meta.json`, written after SubagentStart). */
211
- task: z7.string().optional(),
212
- /** PostToolUseFailure: the user interrupted the turn (Esc); Claude then waits for input with no Stop. */
213
- interrupt: z7.boolean().optional(),
214
- /** Native tracking (spec 2026-10-13 §2): the harness's id of the tool call, so its result lands on the same row. */
215
- toolUseId: z7.string().optional(),
216
- /** The tool's input as the harness gave it, every string capped by the hook. */
217
- toolInput: z7.record(z7.string(), z7.unknown()).optional(),
218
- /** PostToolUse: the result as text; SubagentStop: nothing (the report travels in `text`). */
219
- output: z7.string().optional(),
220
- durationMs: z7.number().nonnegative().optional(),
221
- /** PostToolUseFailure: the harness's error message. */
222
- error: z7.string().optional(),
223
- /** The session's transcript, or the helper's on SubagentStop; the daemon reads its tail for the agent's messages. */
224
- transcriptPath: z7.string().optional(),
225
- /** Decided: what was chosen when the daemon knows it. */
226
- decision: z7.enum(["accept", "deny"]).optional()
227
- });
228
- var RecentSchema = z7.object({ cwd: z7.string().min(1), project: z7.string().min(1), lastAt: z7.string().datetime() });
229
- var SEMVER = /^\d+\.\d+\.\d+$/;
230
- var DaemonInfoSchema = z7.object({ version: z7.string(), install: z7.enum(["npm", "git", "unknown"]), systemd: z7.boolean(), manual: z7.string().optional(), routing: z7.boolean().optional() });
231
- var UpdateFailureSchema = z7.enum(["git-install", "no-systemd", "sessions-at-risk", "npm-failed", "busy"]);
232
- var ServerMessageSchema = z7.discriminatedUnion("type", [
233
- z7.object({ type: z7.literal("chat.routed"), qid: z7.string(), result: RouteResultSchema }),
234
- DocumentContentSchema,
235
- DocumentErrorSchema,
236
- /** `recents`: the folders of past sessions, most recent first. `launcher`: the command that runs `ledge` inside WSL
237
- * (`[node, cli]`), so the overlay can attach a terminal to a session with `<launcher> attach <id>`. `daemon`: absent
238
- * from daemons older than the auto-update. */
239
- z7.object({ type: z7.literal("snapshot"), sessions: z7.array(SessionSchema), recents: z7.array(RecentSchema).optional(), launcher: z7.array(z7.string()).optional(), daemon: DaemonInfoSchema.optional(), sshAlias: SshAliasSchema.optional() }),
240
- z7.object({ type: z7.literal("session.updated"), session: SessionSchema }),
241
- z7.object({ type: z7.literal("session.removed"), id: z7.string() }),
242
- z7.object({ type: z7.literal("session.preview"), id: z7.string(), lines: z7.array(z7.string()) }),
243
- /** A session's thread, on request (spec 2026-10-13 §5); then each created or updated item, broadcast. */
244
- z7.object({ type: z7.literal("session.thread"), id: z7.string(), items: z7.array(ThreadItemSchema) }),
245
- z7.object({ type: z7.literal("session.thread.item"), id: z7.string(), item: ThreadItemSchema }),
246
- /** Answer to the requester of a `session.launch`: the session exists (its `session.updated` is broadcast as usual). */
247
- z7.object({ type: z7.literal("session.launched"), id: z7.string() }),
248
- z7.object({ type: z7.literal("recents"), recents: z7.array(RecentSchema) }),
249
- /** Answer to the requester of a `folder.list` or `folder.create`: `path` resolved (`~` expanded), `parent` null at the
250
- * root, `entries` its subfolders by name (hidden ones left out). A failure keeps the asked path and says why in `error`,
251
- * never in an `error` message, which the launch form reads as a failed launch. */
252
- z7.object({ type: z7.literal("folder.listing"), path: z7.string(), parent: z7.string().nullable(), entries: z7.array(z7.string()), error: z7.string().optional() }),
253
- /** The chat (spec 2026-10-11 §5): what Ledge reads, its words as they come, the final text, or why it stopped; the day's turns after each snapshot. */
254
- z7.object({ type: z7.literal("chat.step"), qid: z7.string(), step: ChatStepSchema }),
255
- z7.object({ type: z7.literal("chat.delta"), qid: z7.string(), text: z7.string() }),
256
- z7.object({ type: z7.literal("chat.done"), qid: z7.string(), text: z7.string(), at: z7.string().datetime(), proposal: ChatProposalSchema.optional(), relay: ChatRelaySchema.optional() }),
257
- z7.object({ type: z7.literal("chat.error"), qid: z7.string(), message: z7.string() }),
258
- z7.object({ type: z7.literal("chat.history"), turns: z7.array(ChatTurnSchema) }),
259
- /** The daemon updating itself: npm is running, then the service restarts (the socket closes right after). */
260
- z7.object({ type: z7.literal("update.progress"), version: z7.string(), step: z7.enum(["installing", "restarting"]) }),
261
- /** Nothing was changed. `detail`: the useful end of npm's output; `command`: what the person can run instead. */
262
- z7.object({ type: z7.literal("update.failed"), version: z7.string(), reason: UpdateFailureSchema, detail: z7.string().optional(), command: z7.string().optional() }),
263
- z7.object({ type: z7.literal("error"), message: z7.string(), id: z7.string().optional() })
264
- ]);
265
- var ClientMessageSchema = z7.discriminatedUnion("type", [
266
- z7.object({ type: z7.literal("chat.route"), qid: z7.string().min(1).max(100), text: z7.string().min(1).max(2e4), tool: ToolSchema.optional(), context: RoutingContextSchema }),
267
- DocumentReadSchema,
268
- /** The overlay starts a session: `cwd` is a WSL path (`~` allowed), `name` a preferred bot name (the daemon picks a
269
- * free one otherwise), `prompt` the agent's first instruction, `continue` resumes the folder's last conversation.
270
- * With `qid` it is the chat card of that turn: the daemon launches the turn's proposal and ignores the other fields. */
271
- z7.object({ type: z7.literal("session.launch"), tool: ToolSchema, cwd: z7.string().min(1), name: z7.string().optional(), prompt: z7.string().optional(), continue: z7.boolean().optional(), qid: z7.string().min(1).optional() }),
272
- /** The launch form's folder browser: list a folder's subfolders (home when no `path`), or make `name` inside `parent`
273
- * and list it. Both are answered with a `folder.listing`. */
274
- z7.object({ type: z7.literal("folder.list"), path: z7.string().optional() }),
275
- z7.object({ type: z7.literal("folder.create"), parent: z7.string().min(1), name: z7.string().min(1) }),
276
- z7.object({ type: z7.literal("session.reply"), id: z7.string(), text: z7.string().min(1) }),
277
- /** The chat card's instruction (spec 2026-10-12 relay §4): sent now if the session is free, else queued until it is. */
278
- z7.object({ type: z7.literal("session.relay"), qid: z7.string().min(1) }),
279
- /** Takes the card's queued instruction back out of the queue. */
280
- z7.object({ type: z7.literal("session.relay.cancel"), qid: z7.string().min(1) }),
281
- z7.object({ type: z7.literal("session.decide"), id: z7.string(), decision: z7.enum(["accept", "deny"]) }),
282
- z7.object({ type: z7.literal("session.focus"), id: z7.string() }),
283
- z7.object({ type: z7.literal("session.kill"), id: z7.string() }),
284
- z7.object({ type: z7.literal("session.interrupt"), id: z7.string() }),
285
- /** Removes a finished (exited) or read-only (hook_only) session from the list; refused for a live launcher session. */
286
- z7.object({ type: z7.literal("session.dismiss"), id: z7.string() }),
287
- /** The user names the session's topic from the overlay (500 characters at most, the hook's prompt cap); an empty topic hands back to the automatic sources. */
288
- z7.object({ type: z7.literal("session.rename"), id: z7.string(), topic: z7.string().max(500) }),
289
- z7.object({ type: z7.literal("session.thread"), id: z7.string() }),
290
- z7.object({ type: z7.literal("session.register"), session: SessionSchema }),
291
- /** `agent` and `cwd` describe the session when the daemon does not know it yet (a hook from an agent started without ledge). */
292
- z7.object({ type: z7.literal("session.event"), id: z7.string(), event: SessionEventSchema, agent: ToolSchema.optional(), cwd: z7.string().optional() }),
293
- z7.object({ type: z7.literal("session.unregister"), id: z7.string(), exitCode: z7.number().int().nullable() }),
294
- z7.object({ type: z7.literal("snapshot.request") }),
295
- z7.object({ type: z7.literal("chat.ask"), qid: z7.string().min(1), text: z7.string().min(1), tool: ToolSchema.optional() }),
296
- z7.object({ type: z7.literal("chat.cancel"), qid: z7.string().min(1) }),
297
- /** Starts a new conversation with Ledge: the day's turns are cleared and the next question opens a new harness session. */
298
- z7.object({ type: z7.literal("chat.reset") }),
299
- /** Installs `@paradow/ledge@version` and restarts the service (spec 2026-10-12 auto-update §6). */
300
- z7.object({ type: z7.literal("update.daemon"), version: z7.string().regex(SEMVER) })
301
- ]);
302
- function parseClientMessage(raw) {
303
- return ClientMessageSchema.parse(raw);
304
- }
305
- function parseServerMessage(raw) {
306
- return ServerMessageSchema.parse(raw);
307
- }
308
-
309
- // ../protocol/src/names.ts
310
- var NAMES = [
311
- "Otto",
312
- "Pim",
313
- "Nova",
314
- "Bix",
315
- "Lu",
316
- "Max",
317
- "Ida",
318
- "Rex",
319
- "Zoe",
320
- "Kit",
321
- "Ari",
322
- "Bo",
323
- "Cal",
324
- "Dee",
325
- "Eli",
326
- "Fay",
327
- "Gus",
328
- "Hal",
329
- "Ivy",
330
- "Jax",
331
- "Kai",
332
- "Lio",
333
- "Mo",
334
- "Nia",
335
- "Oz",
336
- "Pax",
337
- "Quin",
338
- "Rae",
339
- "Sol",
340
- "Tad",
341
- "Uma",
342
- "Vic",
343
- "Wyn",
344
- "Xen",
345
- "Yan",
346
- "Zia",
347
- "Abe",
348
- "Bea",
349
- "Cy",
350
- "Dot",
351
- "Eva",
352
- "Fin",
353
- "Gil",
354
- "Hen",
355
- "Iro",
356
- "Jo",
357
- "Kip",
358
- "Lex",
359
- "Mia",
360
- "Ned",
361
- "Ola",
362
- "Pat",
363
- "Rio",
364
- "Sam",
365
- "Tia",
366
- "Ulf",
367
- "Val",
368
- "Wes",
369
- "Yui",
370
- "Zed",
371
- "Ash",
372
- "Bry",
373
- "Cleo",
374
- "Dax"
375
- ];
376
- var cap = (s) => s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
377
- function pickName(taken, preferred) {
378
- const used = new Set(taken);
379
- const free = (n) => !used.has(n);
380
- const wanted = preferred?.trim();
381
- if (wanted) {
382
- const base2 = cap(wanted);
383
- if (free(base2)) return base2;
384
- for (let i = 2; ; i++) if (free(`${base2}-${i}`)) return `${base2}-${i}`;
385
- }
386
- const first = NAMES.find(free);
387
- if (first) return first;
388
- for (let i = 2; ; i++) if (free(`${NAMES[0]}-${i}`)) return `${NAMES[0]}-${i}`;
389
- }
390
-
391
- // ../protocol/src/proposal.ts
392
- import { z as z8 } from "zod";
393
- var ProposalBlockSchema = z8.object({ cwd: z8.string().trim().min(1), prompt: z8.string().optional() });
394
- var RelayBlockSchema = z8.object({ session: z8.string().trim().min(1), text: z8.string().trim().min(1) });
395
- var BLOCK = /```ledge-(session|relay)[ \t]*\n?([\s\S]*?)(?:```|$)/g;
396
- function extractProposal(answer) {
397
- const found = [];
398
- const text = answer.replace(BLOCK, (_m, kind, body) => {
399
- found.push({ kind, raw: body.trim() });
400
- return "";
401
- });
402
- const last = found.at(-1);
403
- return last ? { text: text.replace(/\n{3,}/g, "\n\n").trim(), kind: last.kind, raw: last.raw } : { text: answer, kind: null, raw: null };
404
- }
405
- function parseProposalBlock(raw) {
406
- try {
407
- const r = ProposalBlockSchema.safeParse(JSON.parse(raw));
408
- return r.success ? r.data : null;
409
- } catch {
410
- return null;
411
- }
412
- }
413
- function parseRelayBlock(raw) {
414
- try {
415
- const r = RelayBlockSchema.safeParse(JSON.parse(raw));
416
- return r.success ? r.data : null;
417
- } catch {
418
- return null;
419
- }
420
- }
421
-
422
- // ../protocol/src/topic.ts
423
- var TOPIC_MAX = 80;
424
- function cleanTopic(text) {
425
- const line = text.split(/\r?\n/).map((l) => l.trim()).find((l) => l.length > 0) ?? "";
426
- const flat = line.replace(/\s+/g, " ");
427
- return flat.length > TOPIC_MAX ? `${flat.slice(0, TOPIC_MAX - 1).trimEnd()}\u2026` : flat;
428
- }
429
- function sessionTitle(s) {
430
- return `${s.name} \xB7 ${s.topic || s.project}`;
431
- }
432
-
433
- export {
434
- SessionSchema,
435
- DOCUMENT_MAX_BYTES,
436
- RouteResultSchema,
437
- SshAliasSchema,
438
- PROTOCOL_PORT,
439
- RecentSchema,
440
- parseClientMessage,
441
- parseServerMessage,
442
- pickName,
443
- extractProposal,
444
- parseProposalBlock,
445
- parseRelayBlock,
446
- cleanTopic,
447
- sessionTitle
448
- };