@paradow/ledge-relay 0.70.1 → 0.72.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.
@@ -2,7 +2,7 @@
2
2
  import { existsSync } from "fs";
3
3
  import { join } from "path";
4
4
  import { createPrivateKey, createPublicKey, sign, verify } from "crypto";
5
- import { z as z40 } from "zod";
5
+ import { z as z41 } from "zod";
6
6
 
7
7
  // ../../packages/protocol/src/attachments.ts
8
8
  import { z } from "zod";
@@ -39,7 +39,7 @@ var AttachmentDataSchema = z.object({ type: z.literal("attachment.data"), reques
39
39
  var AttachmentErrorSchema = z.object({ type: z.literal("attachment.error"), requestId, reason: AttachmentErrorReasonSchema });
40
40
 
41
41
  // ../../packages/protocol/src/chat.ts
42
- import { z as z13 } from "zod";
42
+ import { z as z14 } from "zod";
43
43
 
44
44
  // ../../packages/protocol/src/session.ts
45
45
  import { z as z4 } from "zod";
@@ -295,7 +295,7 @@ var ModelRefusalSchema = z5.enum(["not_launched", "ended", "no_conversation", "n
295
295
  var SessionModelAcceptedSchema = z5.object({ type: z5.literal("session.model.accepted"), id: z5.string(), when: z5.enum(["now", "turn", "none"]) });
296
296
 
297
297
  // ../../packages/protocol/src/actions.ts
298
- import { z as z11 } from "zod";
298
+ import { z as z12 } from "zod";
299
299
 
300
300
  // ../../packages/protocol/src/proposal.ts
301
301
  import { z as z6 } from "zod";
@@ -315,7 +315,7 @@ var TaskBlockSchema = z6.object({
315
315
  });
316
316
 
317
317
  // ../../packages/protocol/src/tasks.ts
318
- import { z as z10 } from "zod";
318
+ import { z as z11 } from "zod";
319
319
 
320
320
  // ../../packages/protocol/src/report.ts
321
321
  import { z as z8 } from "zod";
@@ -1067,59 +1067,65 @@ var TaskRoutineSchema = z9.object({
1067
1067
  var PHONE_ROUTINE_ACTIONS = ["run", "pause", "resume", "approve", "refuse"];
1068
1068
  var PhoneRoutineActionSchema = z9.enum(PHONE_ROUTINE_ACTIONS);
1069
1069
 
1070
+ // ../../packages/protocol/src/external.ts
1071
+ import { z as z10 } from "zod";
1072
+ var ExternalNameSchema = z10.string().regex(/^[a-z0-9][a-z0-9-]{0,31}$/);
1073
+
1070
1074
  // ../../packages/protocol/src/tasks.ts
1071
1075
  var TASK_TITLE_MAX = 200;
1072
1076
  var TASK_TEXT_MAX = 2e4;
1073
1077
  var TASK_OPS = ["give", "take", "pass", "done", "refuse", "cancel", "drop"];
1074
1078
  var TRANSMISSION_OPS = ["give", "pass", "done", "refuse", "cancel"];
1075
- var TaskLogEntrySchema = z10.object({
1076
- at: z10.string(),
1077
- by: z10.string(),
1078
- what: z10.string(),
1079
- op: z10.enum(TASK_OPS).optional(),
1080
- from: z10.string().optional(),
1081
- to: z10.string().optional(),
1082
- fromName: z10.string().optional(),
1083
- toName: z10.string().optional(),
1084
- note: z10.string().optional()
1079
+ var TaskLogEntrySchema = z11.object({
1080
+ at: z11.string(),
1081
+ by: z11.string(),
1082
+ what: z11.string(),
1083
+ op: z11.enum(TASK_OPS).optional(),
1084
+ from: z11.string().optional(),
1085
+ to: z11.string().optional(),
1086
+ fromName: z11.string().optional(),
1087
+ toName: z11.string().optional(),
1088
+ note: z11.string().optional()
1085
1089
  });
1086
1090
  var BRAIN_FACT_MAX = 500;
1087
1091
  var BRAIN_SOURCE_MAX = 300;
1088
- var NoteNameSchema = z10.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,59}$/);
1089
- var BrainProposalSchema = z10.object({
1090
- kind: z10.enum(["add", "flag"]),
1092
+ var NoteNameSchema = z11.string().regex(/^[A-Za-z0-9][A-Za-z0-9._-]{0,59}$/);
1093
+ var BrainProposalSchema = z11.object({
1094
+ kind: z11.enum(["add", "flag"]),
1091
1095
  note: NoteNameSchema,
1092
- create: z10.boolean().optional(),
1093
- fact: z10.string().trim().min(1).max(BRAIN_FACT_MAX),
1094
- source: z10.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional(),
1096
+ create: z11.boolean().optional(),
1097
+ fact: z11.string().trim().min(1).max(BRAIN_FACT_MAX),
1098
+ source: z11.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional(),
1095
1099
  /** A new note's title and « quand la lire », as the session proposes them (the user may correct them). */
1096
- title: z10.string().trim().min(1).max(200).optional(),
1097
- when: z10.string().trim().min(1).max(300).optional()
1100
+ title: z11.string().trim().min(1).max(200).optional(),
1101
+ when: z11.string().trim().min(1).max(300).optional()
1098
1102
  });
1099
1103
  var NOTE_TITLE_MAX = 200;
1100
1104
  var NOTE_WHEN_MAX = 300;
1101
- var oneLineOf = (max) => z10.string().trim().min(1).max(max).refine((s) => !/[\r\n]/.test(s), "one line");
1102
- var BrainChoiceSchema = z10.object({
1103
- yes: z10.boolean(),
1105
+ var oneLineOf = (max) => z11.string().trim().min(1).max(max).refine((s) => !/[\r\n]/.test(s), "one line");
1106
+ var BrainChoiceSchema = z11.object({
1107
+ yes: z11.boolean(),
1104
1108
  text: oneLineOf(BRAIN_FACT_MAX).optional(),
1105
1109
  title: oneLineOf(NOTE_TITLE_MAX).optional(),
1106
1110
  when: oneLineOf(NOTE_WHEN_MAX).optional()
1107
1111
  }).strict();
1108
- var TaskSchema = z10.object({
1109
- id: z10.string(),
1110
- title: z10.string(),
1111
- text: z10.string().optional(),
1112
- giver: z10.string(),
1113
- giverName: z10.string(),
1114
- owner: z10.string(),
1115
- ownerName: z10.string(),
1116
- state: z10.enum(["open", "taken", "done", "refused", "dropped"]),
1117
- result: z10.string().optional(),
1112
+ var TaskSchema = z11.object({
1113
+ id: z11.string(),
1114
+ title: z11.string(),
1115
+ text: z11.string().optional(),
1116
+ giver: z11.string(),
1117
+ giverName: z11.string(),
1118
+ owner: z11.string(),
1119
+ ownerName: z11.string(),
1120
+ state: z11.enum(["open", "taken", "done", "refused", "dropped"]),
1121
+ result: z11.string().optional(),
1118
1122
  /** A task Ledge gave and the user put away from « À toi » once closed. */
1119
- seen: z10.boolean().optional(),
1120
- at: z10.string(),
1121
- updatedAt: z10.string(),
1122
- log: z10.array(TaskLogEntrySchema),
1123
+ seen: z11.boolean().optional(),
1124
+ /** The retry key of a program's give (`--from <name> --id <clé>`, its rid): the same key given again answers this task. */
1125
+ key: z11.string().optional(),
1126
+ at: z11.string(),
1127
+ updatedAt: z11.string(),
1128
+ log: z11.array(TaskLogEntrySchema),
1123
1129
  /** A decision about the user's notes: its answer writes them (brain spec §3.6). */
1124
1130
  brain: BrainProposalSchema.optional(),
1125
1131
  /** An agent's report (issue #9): « Créer l'issue » (report.create with this task), « Modifier avant », « Ignorer » (report.ignore). */
@@ -1127,20 +1133,25 @@ var TaskSchema = z10.object({
1127
1133
  /** A routine's « À toi » item (routines spec §3.2, §3.4): its buttons send `routine.cmd`, never `task.cmd`. */
1128
1134
  routine: TaskRoutineSchema.optional()
1129
1135
  });
1130
- var TaskCmdSchema = z10.object({
1131
- type: z10.literal("task.cmd"),
1132
- rid: z10.string().min(1),
1133
- by: z10.string().min(1),
1134
- op: z10.enum(["give", "take", "done", "refuse", "pass", "show", "list", "seen", "cancel"]),
1135
- task: z10.string().min(1).max(40).optional(),
1136
- to: z10.string().min(1).optional(),
1137
- title: z10.string().min(1).max(TASK_TITLE_MAX).optional(),
1138
- text: z10.string().max(TASK_TEXT_MAX).optional(),
1139
- all: z10.boolean().optional(),
1140
- qid: z10.string().min(1).optional(),
1141
- row: z10.number().int().min(0).max(7).optional(),
1136
+ var TaskCmdSchema = z11.object({
1137
+ type: z11.literal("task.cmd"),
1138
+ rid: z11.string().min(1),
1139
+ by: z11.string().min(1),
1140
+ op: z11.enum(["give", "take", "done", "refuse", "pass", "show", "list", "seen", "cancel"]),
1141
+ task: z11.string().min(1).max(40).optional(),
1142
+ to: z11.string().min(1).optional(),
1143
+ title: z11.string().min(1).max(TASK_TITLE_MAX).optional(),
1144
+ text: z11.string().max(TASK_TEXT_MAX).optional(),
1145
+ all: z11.boolean().optional(),
1146
+ qid: z11.string().min(1).optional(),
1147
+ row: z11.number().int().min(0).max(7).optional(),
1148
+ /** The client reads a give's `qitem` and `forwarded` (task.result): only then is a give to an OpenRig seat made a queue row,
1149
+ * so an older CLI, which reads `task` only, is refused instead of failing after the row exists. */
1150
+ seatRows: z11.literal(true).optional(),
1151
+ /** A program outside Ledge giving, following or withdrawing a task (`--from <name>`), `by` then being `externalId(name)`: no key. */
1152
+ external: ExternalNameSchema.optional(),
1142
1153
  /** Session `by`'s key (#93, #152): without it, a session only reads (`list`, `show`, `seen`). */
1143
- key: z10.string().min(1).max(128).optional(),
1154
+ key: z11.string().min(1).max(128).optional(),
1144
1155
  /** A `give` to `ledge` only: a proposal about the user's notes, whose title and detail the daemon writes. */
1145
1156
  brain: BrainProposalSchema.optional(),
1146
1157
  /** An agent's report (issue #9): the daemon's own give, from `report.agent`; a client's `task.cmd` carrying it is refused. */
@@ -1148,17 +1159,23 @@ var TaskCmdSchema = z10.object({
1148
1159
  /** A `done` by Ledge of such a proposal, from its buttons: what to write, instead of reading `text`. */
1149
1160
  choice: BrainChoiceSchema.optional()
1150
1161
  });
1151
- var TaskUpdatedSchema = z10.object({ type: z10.literal("task.updated"), task: TaskSchema });
1152
- var TaskResultSchema = z10.object({
1153
- type: z10.literal("task.result"),
1154
- rid: z10.string(),
1162
+ var TaskUpdatedSchema = z11.object({ type: z11.literal("task.updated"), task: TaskSchema });
1163
+ var TaskResultSchema = z11.object({
1164
+ type: z11.literal("task.result"),
1165
+ rid: z11.string(),
1155
1166
  task: TaskSchema.optional(),
1156
- tasks: z10.array(TaskSchema).optional(),
1157
- reason: z10.string().optional()
1167
+ tasks: z11.array(TaskSchema).optional(),
1168
+ reason: z11.string().optional(),
1169
+ /** Why, for a refusal a sender reads in its own language (`key_reused`); a free string, so an older front ignores a new one. */
1170
+ code: z11.string().optional(),
1171
+ /** A give to an OpenRig seat: the queue row it became (`rig queue show <qitem>`), not a Ledge task. */
1172
+ qitem: z11.string().optional(),
1173
+ /** A give to a seat whose row OpenRig had not made within the wait: handed on, its id unknown; only a failure is typed back later. */
1174
+ forwarded: z11.literal(true).optional()
1158
1175
  });
1159
1176
 
1160
1177
  // ../../packages/protocol/src/actions.ts
1161
- var ActionRiskSchema = z11.enum(["read", "reversible", "destructive"]);
1178
+ var ActionRiskSchema = z12.enum(["read", "reversible", "destructive"]);
1162
1179
  var ACTION_IDS = [
1163
1180
  "session.launch",
1164
1181
  "session.relay",
@@ -1188,18 +1205,18 @@ var ACTION_IDS = [
1188
1205
  "session.move",
1189
1206
  "session.delete"
1190
1207
  ];
1191
- var ActionIdSchema = z11.enum(ACTION_IDS);
1208
+ var ActionIdSchema = z12.enum(ACTION_IDS);
1192
1209
  var def = (d) => d;
1193
- var SessionRef = z11.string().trim().min(1).max(80);
1194
- var TaskRef = z11.string().trim().min(1).max(40);
1210
+ var SessionRef = z12.string().trim().min(1).max(80);
1211
+ var TaskRef = z12.string().trim().min(1).max(40);
1195
1212
  var LAUNCH_OPTIONS = ["confirm", "launch-rig"];
1196
- var RigAnswer = z11.union([
1197
- z11.object({ option: z11.string().trim().min(1).max(200) }).strict(),
1198
- z11.object({ text: z11.string().trim().min(1).max(8e3) }).strict(),
1199
- z11.object({ seen: z11.literal(true) }).strict()
1213
+ var RigAnswer = z12.union([
1214
+ z12.object({ option: z12.string().trim().min(1).max(200) }).strict(),
1215
+ z12.object({ text: z12.string().trim().min(1).max(8e3) }).strict(),
1216
+ z12.object({ seen: z12.literal(true) }).strict()
1200
1217
  ]);
1201
1218
  var RIG_CHAT_KINDS = ["rig.start", "rig.stop", "rig.restart", "rig.snapshot", "kernel.start", "kernel.stop", "kernel.restart"];
1202
- var RigActArgs = z11.object({ kind: z11.enum(RIG_CHAT_KINDS), rig: RigNameSchema.optional() }).refine((a) => a.kind.startsWith("rig.") ? a.rig !== void 0 : a.rig === void 0, "rig names the rig of a rig.* kind, and only of one");
1219
+ var RigActArgs = z12.object({ kind: z12.enum(RIG_CHAT_KINDS), rig: RigNameSchema.optional() }).refine((a) => a.kind.startsWith("rig.") ? a.rig !== void 0 : a.rig === void 0, "rig names the rig of a rig.* kind, and only of one");
1203
1220
  var LaunchArgs = ProposalBlockSchema.extend({ model: ModelIdSchema.optional(), effort: EffortSchema.optional() });
1204
1221
  var ACTIONS = [
1205
1222
  def({
@@ -1265,14 +1282,14 @@ var ACTIONS = [
1265
1282
  phone: null,
1266
1283
  risk: "reversible",
1267
1284
  max: 8,
1268
- args: z11.object({ session: SessionRef, model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
1285
+ args: z12.object({ session: SessionRef, model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
1269
1286
  summary: "changer le mod\xE8le et l'effort d'une session en cours (null : le d\xE9faut de l'agent) ; elle red\xE9marre sur la m\xEAme conversation, \xE0 son prochain moment libre",
1270
1287
  when: "quand l'utilisateur demande de passer une session sur un autre mod\xE8le ou un autre effort",
1271
1288
  example: { session: "Nova", model: "claude-opus-5-5", effort: "high" }
1272
1289
  }),
1273
1290
  def({
1274
1291
  id: "session.interrupt",
1275
- args: z11.object({ session: SessionRef }),
1292
+ args: z12.object({ session: SessionRef }),
1276
1293
  card: "generic",
1277
1294
  phone: null,
1278
1295
  risk: "reversible",
@@ -1283,7 +1300,7 @@ var ACTIONS = [
1283
1300
  }),
1284
1301
  def({
1285
1302
  id: "session.archive",
1286
- args: z11.object({ session: SessionRef }),
1303
+ args: z12.object({ session: SessionRef }),
1287
1304
  card: "generic",
1288
1305
  phone: null,
1289
1306
  risk: "reversible",
@@ -1294,7 +1311,7 @@ var ACTIONS = [
1294
1311
  }),
1295
1312
  def({
1296
1313
  id: "session.restore",
1297
- args: z11.object({ session: SessionRef }),
1314
+ args: z12.object({ session: SessionRef }),
1298
1315
  card: "generic",
1299
1316
  phone: null,
1300
1317
  risk: "reversible",
@@ -1305,7 +1322,7 @@ var ACTIONS = [
1305
1322
  }),
1306
1323
  def({
1307
1324
  id: "session.resume",
1308
- args: z11.object({ session: SessionRef }),
1325
+ args: z12.object({ session: SessionRef }),
1309
1326
  card: "generic",
1310
1327
  phone: "act",
1311
1328
  risk: "reversible",
@@ -1319,7 +1336,7 @@ var ACTIONS = [
1319
1336
  card: "generic",
1320
1337
  phone: "act",
1321
1338
  max: 1,
1322
- args: z11.object({ session: SessionRef, decision: z11.enum(["accept", "deny"]), note: z11.string().trim().min(1).max(NOTE_MAX).optional() }),
1339
+ args: z12.object({ session: SessionRef, decision: z12.enum(["accept", "deny"]), note: z12.string().trim().min(1).max(NOTE_MAX).optional() }),
1323
1340
  risk: (a) => a.decision === "accept" ? "destructive" : "reversible",
1324
1341
  summary: "accepter ou refuser la demande en attente d'une session (permission, diff ou plan), note possible avec un refus ; jamais \xAB toujours \xBB",
1325
1342
  when: "seulement quand l'utilisateur demande explicitement d'accepter ou de refuser la demande d'une session pr\xE9cise, et que sessions.md montre une demande en attente pour elle ; cite la demande telle quelle dans ta r\xE9ponse",
@@ -1327,7 +1344,7 @@ var ACTIONS = [
1327
1344
  }),
1328
1345
  def({
1329
1346
  id: "task.cancel",
1330
- args: z11.object({ task: TaskRef, reason: z11.string().trim().min(1).max(500).optional() }),
1347
+ args: z12.object({ task: TaskRef, reason: z12.string().trim().min(1).max(500).optional() }),
1331
1348
  card: "generic",
1332
1349
  phone: "act",
1333
1350
  risk: "destructive",
@@ -1338,7 +1355,7 @@ var ACTIONS = [
1338
1355
  }),
1339
1356
  def({
1340
1357
  id: "task.pass",
1341
- args: z11.object({ task: TaskRef, to: SessionRef, note: z11.string().trim().min(1).max(TASK_TEXT_MAX).optional() }),
1358
+ args: z12.object({ task: TaskRef, to: SessionRef, note: z12.string().trim().min(1).max(TASK_TEXT_MAX).optional() }),
1342
1359
  card: "generic",
1343
1360
  phone: null,
1344
1361
  risk: "reversible",
@@ -1349,7 +1366,7 @@ var ACTIONS = [
1349
1366
  }),
1350
1367
  def({
1351
1368
  id: "task.answer",
1352
- args: z11.object({ task: TaskRef, answer: z11.string().trim().min(1).max(TASK_TEXT_MAX) }),
1369
+ args: z12.object({ task: TaskRef, answer: z12.string().trim().min(1).max(TASK_TEXT_MAX) }),
1353
1370
  card: "generic",
1354
1371
  phone: "act",
1355
1372
  risk: "destructive",
@@ -1364,7 +1381,7 @@ var ACTIONS = [
1364
1381
  phone: null,
1365
1382
  risk: "reversible",
1366
1383
  max: 1,
1367
- args: z11.object({ note: NoteNameSchema, fact: z11.string().trim().min(1).max(BRAIN_FACT_MAX).refine((t) => !/[\r\n]/.test(t), "one line"), source: z11.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional() }),
1384
+ args: z12.object({ note: NoteNameSchema, fact: z12.string().trim().min(1).max(BRAIN_FACT_MAX).refine((t) => !/[\r\n]/.test(t), "one line"), source: z12.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional() }),
1368
1385
  summary: "ajouter un fait durable \xE0 une note de l'utilisateur (context-index.md), dat\xE9 et sign\xE9 \xAB dit par l'utilisateur \xBB, sous \xAB Ajouts \xBB",
1369
1386
  when: "seulement quand l'utilisateur dit un fait sur son environnement et demande de le retenir (\xAB retiens que\u2026 \xBB) : note est le nom d'une note de context-index.md (son fichier sans context- ni .md) qui en parle ; aucune ne convient, ou plusieurs : cite-les et demande laquelle ; jamais la valeur d'un secret",
1370
1387
  example: { note: "machines", fact: "Legion a 64 Go de RAM" }
@@ -1382,7 +1399,7 @@ var ACTIONS = [
1382
1399
  }),
1383
1400
  def({
1384
1401
  id: "rig.seats",
1385
- args: z11.object({ rig: RigNameSchema, role: RigRoleSchema, count: z11.number().int().min(0).max(9) }),
1402
+ args: z12.object({ rig: RigNameSchema, role: RigRoleSchema, count: z12.number().int().min(0).max(9) }),
1386
1403
  card: "generic",
1387
1404
  phone: "act",
1388
1405
  max: 4,
@@ -1397,7 +1414,7 @@ var ACTIONS = [
1397
1414
  card: "generic",
1398
1415
  phone: "act",
1399
1416
  max: 4,
1400
- args: z11.object({ qitem: z11.string().trim().min(1).max(200), answer: RigAnswer }),
1417
+ args: z12.object({ qitem: z12.string().trim().min(1).max(200), answer: RigAnswer }),
1401
1418
  // The daemon knows whether the ask proposes a team; here an option that confirms or launches is taken as the destructive one.
1402
1419
  risk: (a) => "option" in a.answer && LAUNCH_OPTIONS.includes(a.answer.option) ? "destructive" : "reversible",
1403
1420
  summary: "r\xE9pondre, au nom de l'utilisateur, \xE0 une demande de \xAB \xC0 toi \xBB (attentes.md) : une option (option, son id), ses propres mots (text) ou \xAB Vu \xBB sur une nouvelle (seen) ; confirmer un lancement de rig ne se d\xE9fait pas",
@@ -1410,7 +1427,7 @@ var ACTIONS = [
1410
1427
  phone: null,
1411
1428
  risk: "reversible",
1412
1429
  max: 1,
1413
- args: z11.object({ text: z11.string().trim().min(1).max(2e3), folder: z11.string().trim().min(1).max(4096).refine((f) => f.startsWith("/"), "an absolute path").optional() }),
1430
+ args: z12.object({ text: z12.string().trim().min(1).max(2e3), folder: z12.string().trim().min(1).max(4096).refine((f) => f.startsWith("/"), "an absolute path").optional() }),
1414
1431
  summary: "donner un objectif \xE0 Max, l'orchestrateur d'OpenRig, qui propose l'\xE9quipe ; folder (chemin absolu) seulement s'il est connu",
1415
1432
  when: "seulement quand l'utilisateur demande explicitement de donner un objectif aux rigs ; text reprend ses mots, folder un chemin absolu lu dans sessions.md ou folders.md ou donn\xE9 tel quel",
1416
1433
  example: { text: "Ajouter la pagination \xE0 /invoices", folder: "/home/alice/projets/api" }
@@ -1420,7 +1437,7 @@ var ACTIONS = [
1420
1437
  card: "generic",
1421
1438
  phone: "act",
1422
1439
  max: 1,
1423
- args: z11.object({ goal: z11.string().trim().min(1).max(100), answer: z11.union([z11.literal("confirm"), z11.object({ text: z11.string().trim().min(1).max(8e3) }).strict()]) }),
1440
+ args: z12.object({ goal: z12.string().trim().min(1).max(100), answer: z12.union([z12.literal("confirm"), z12.object({ text: z12.string().trim().min(1).max(8e3) }).strict()]) }),
1424
1441
  risk: (a) => a.answer === "confirm" ? "destructive" : "reversible",
1425
1442
  summary: "r\xE9pondre \xE0 Max au sujet d'un objectif (goal, son id de rigs.md) : confirmer l'\xE9quipe qu'il propose (confirm), ou lui \xE9crire (text) ; confirmer un lancement de rig ne se d\xE9fait pas",
1426
1443
  when: "seulement quand l'utilisateur demande explicitement de confirmer l'\xE9quipe propos\xE9e pour un objectif ou d'\xE9crire \xE0 Max \xE0 son sujet, et que rigs.md ou attentes.md montre cet objectif ; confirm seulement s'il a dit oui \xE0 cette \xE9quipe",
@@ -1432,7 +1449,7 @@ var ACTIONS = [
1432
1449
  phone: null,
1433
1450
  risk: "reversible",
1434
1451
  max: 4,
1435
- args: z11.object({ rig: RigNameSchema, seat: z11.string().trim().min(1).max(200), text: z11.string().trim().min(1).max(4e3) }),
1452
+ args: z12.object({ rig: RigNameSchema, seat: z12.string().trim().min(1).max(200), text: z12.string().trim().min(1).max(4e3) }),
1436
1453
  summary: "\xE9crire \xE0 un si\xE8ge d'un rig qui tourne (rig send) : le texte lui est envoy\xE9 tel quel",
1437
1454
  when: "seulement quand l'utilisateur demande explicitement d'\xE9crire \xE0 un si\xE8ge d'un rig ; seat tel que rigs.md le donne (son identifiant ou sa session) ; le texte est formul\xE9 pour l'agent",
1438
1455
  example: { rig: "ledge-dev", seat: "dev.back", text: "Peux-tu relire la PR 226 ?" }
@@ -1443,14 +1460,14 @@ var ACTIONS = [
1443
1460
  phone: "act",
1444
1461
  risk: "reversible",
1445
1462
  max: 4,
1446
- args: z11.object({ task: TaskRef, choice: z11.union([z11.enum(["add", "refuse"]), z11.object({ edit: z11.string().trim().min(1).max(BRAIN_FACT_MAX) }).strict()]) }),
1463
+ args: z12.object({ task: TaskRef, choice: z12.union([z12.enum(["add", "refuse"]), z12.object({ edit: z12.string().trim().min(1).max(BRAIN_FACT_MAX) }).strict()]) }),
1447
1464
  summary: "r\xE9pondre \xE0 une proposition de note de \xAB \xC0 toi \xBB (tasks.md) : l'ajouter telle quelle (add), la refuser (refuse), ou l'ajouter corrig\xE9e (edit, le fait corrig\xE9)",
1448
1465
  when: "seulement quand l'utilisateur dit s'il veut ajouter, refuser ou corriger une proposition de note de tasks.md",
1449
1466
  example: { task: "t91b0d4", choice: "add" }
1450
1467
  }),
1451
1468
  def({
1452
1469
  id: "session.handover",
1453
- args: z11.object({ session: SessionRef }),
1470
+ args: z12.object({ session: SessionRef }),
1454
1471
  card: "generic",
1455
1472
  phone: null,
1456
1473
  risk: "reversible",
@@ -1461,7 +1478,7 @@ var ACTIONS = [
1461
1478
  }),
1462
1479
  def({
1463
1480
  id: "pr.fix",
1464
- args: z11.object({ pr: z11.string().trim().min(1).max(500), session: SessionRef.optional() }),
1481
+ args: z12.object({ pr: z12.string().trim().min(1).max(500), session: SessionRef.optional() }),
1465
1482
  card: "generic",
1466
1483
  phone: "act",
1467
1484
  risk: "reversible",
@@ -1474,7 +1491,7 @@ var ACTIONS = [
1474
1491
  // « chef ») can tidy the others up from its shell.
1475
1492
  def({
1476
1493
  id: "session.topic",
1477
- args: z11.object({ session: SessionRef, topic: z11.string().trim().max(500) }),
1494
+ args: z12.object({ session: SessionRef, topic: z12.string().trim().max(500) }),
1478
1495
  card: "generic",
1479
1496
  phone: null,
1480
1497
  risk: "reversible",
@@ -1487,7 +1504,7 @@ var ACTIONS = [
1487
1504
  }),
1488
1505
  def({
1489
1506
  id: "session.move",
1490
- args: z11.object({ session: SessionRef, project: z11.string().trim().min(1).max(80) }),
1507
+ args: z12.object({ session: SessionRef, project: z12.string().trim().min(1).max(80) }),
1491
1508
  card: "generic",
1492
1509
  phone: null,
1493
1510
  risk: "reversible",
@@ -1500,7 +1517,7 @@ var ACTIONS = [
1500
1517
  }),
1501
1518
  def({
1502
1519
  id: "session.delete",
1503
- args: z11.object({ session: SessionRef }),
1520
+ args: z12.object({ session: SessionRef }),
1504
1521
  card: "generic",
1505
1522
  phone: null,
1506
1523
  risk: "destructive",
@@ -1514,152 +1531,152 @@ var ACTIONS = [
1514
1531
  ];
1515
1532
  var CHAT_ACTIONS = ACTIONS.filter((a) => a.chat !== false);
1516
1533
  var byId = new Map(ACTIONS.map((a) => [a.id, a]));
1517
- var ActionBlockSchema = z11.object({ action: z11.string().trim().min(1).max(40), args: z11.record(z11.unknown()).default({}) });
1534
+ var ActionBlockSchema = z12.object({ action: z12.string().trim().min(1).max(40), args: z12.record(z12.unknown()).default({}) });
1518
1535
 
1519
1536
  // ../../packages/protocol/src/operator.ts
1520
- import { z as z12 } from "zod";
1521
- var PointGroupSchema = z12.enum(["atoi", "done", "ongoing", "rigs"]);
1522
- var PointRefSchema = z12.discriminatedUnion("kind", [
1523
- z12.object({ kind: z12.literal("session.request"), session: z12.string(), key: z12.string() }),
1524
- z12.object({ kind: z12.literal("rig.ask"), qitem: z12.string() }),
1525
- z12.object({ kind: z12.literal("task"), task: z12.string() })
1537
+ import { z as z13 } from "zod";
1538
+ var PointGroupSchema = z13.enum(["atoi", "done", "ongoing", "rigs"]);
1539
+ var PointRefSchema = z13.discriminatedUnion("kind", [
1540
+ z13.object({ kind: z13.literal("session.request"), session: z13.string(), key: z13.string() }),
1541
+ z13.object({ kind: z13.literal("rig.ask"), qitem: z13.string() }),
1542
+ z13.object({ kind: z13.literal("task"), task: z13.string() })
1526
1543
  ]);
1527
- var PointItemSchema = z12.object({
1528
- id: z12.string(),
1529
- event: z12.number().int(),
1544
+ var PointItemSchema = z13.object({
1545
+ id: z13.string(),
1546
+ event: z13.number().int(),
1530
1547
  group: PointGroupSchema,
1531
- tone: z12.enum(["perm", "ask", "work", "idle", "off"]),
1532
- who: z12.string().max(100),
1533
- rig: z12.string().max(100).optional(),
1534
- text: z12.string().max(400),
1535
- sub: z12.string().max(200).optional(),
1536
- at: z12.string().datetime(),
1548
+ tone: z13.enum(["perm", "ask", "work", "idle", "off"]),
1549
+ who: z13.string().max(100),
1550
+ rig: z13.string().max(100).optional(),
1551
+ text: z13.string().max(400),
1552
+ sub: z13.string().max(200).optional(),
1553
+ at: z13.string().datetime(),
1537
1554
  ref: PointRefSchema.optional(),
1538
- answers: z12.array(z12.object({ id: z12.string(), label: z12.string().max(60), style: z12.enum(["primary", "danger", "plain"]) })).max(4).optional(),
1539
- freeText: z12.boolean().optional(),
1555
+ answers: z13.array(z13.object({ id: z13.string(), label: z13.string().max(60), style: z13.enum(["primary", "danger", "plain"]) })).max(4).optional(),
1556
+ freeText: z13.boolean().optional(),
1540
1557
  /** `routine`: a routine's page (its id), which a routine's « À toi » row opens (« Voir »). */
1541
- nav: z12.array(z12.object({ kind: z12.enum(["session", "pr", "rig", "task", "routine"]), id: z12.string() })).max(2).optional(),
1542
- suggestion: z12.lazy(() => ChatActionSchema).optional(),
1543
- settled: z12.object({ at: z12.string().datetime(), where: z12.enum(["terminal", "phone", "desktop", "chat", "elsewhere"]), answer: z12.string().max(60).optional() }).optional(),
1544
- error: z12.string().max(200).optional()
1545
- });
1546
- var ChatPointSchema = z12.object({
1547
- since: z12.string().datetime(),
1548
- lead: z12.string().max(300),
1549
- leadBy: z12.enum(["agent", "daemon"]),
1550
- items: z12.array(PointItemSchema).max(40),
1551
- foldedAt: z12.string().datetime().optional(),
1552
- laterAt: z12.string().datetime().optional()
1553
- });
1554
- var OperatorNoticeSchema = z12.object({
1558
+ nav: z13.array(z13.object({ kind: z13.enum(["session", "pr", "rig", "task", "routine"]), id: z13.string() })).max(2).optional(),
1559
+ suggestion: z13.lazy(() => ChatActionSchema).optional(),
1560
+ settled: z13.object({ at: z13.string().datetime(), where: z13.enum(["terminal", "phone", "desktop", "chat", "elsewhere"]), answer: z13.string().max(60).optional() }).optional(),
1561
+ error: z13.string().max(200).optional()
1562
+ });
1563
+ var ChatPointSchema = z13.object({
1564
+ since: z13.string().datetime(),
1565
+ lead: z13.string().max(300),
1566
+ leadBy: z13.enum(["agent", "daemon"]),
1567
+ items: z13.array(PointItemSchema).max(40),
1568
+ foldedAt: z13.string().datetime().optional(),
1569
+ laterAt: z13.string().datetime().optional()
1570
+ });
1571
+ var OperatorNoticeSchema = z13.object({
1555
1572
  /** `decision`: a decision a session put to the user (a task given to Ledge), said at once; its `id` is `decision:<task id>`.
1556
1573
  * `point`: sent only by daemons before #27 (the point left the dynamic island); kept so their notices still parse. */
1557
- id: z12.string(),
1558
- kind: z12.enum(["point", "rig.ask", "decision"]),
1559
- qid: z12.string().optional(),
1560
- text: z12.string().max(300),
1561
- who: z12.string().max(100).optional(),
1562
- rig: z12.string().optional(),
1563
- qitem: z12.string().optional(),
1564
- options: z12.array(z12.object({ id: z12.string(), label: z12.string().max(60) })).max(3).optional(),
1574
+ id: z13.string(),
1575
+ kind: z13.enum(["point", "rig.ask", "decision"]),
1576
+ qid: z13.string().optional(),
1577
+ text: z13.string().max(300),
1578
+ who: z13.string().max(100).optional(),
1579
+ rig: z13.string().optional(),
1580
+ qitem: z13.string().optional(),
1581
+ options: z13.array(z13.object({ id: z13.string(), label: z13.string().max(60) })).max(3).optional(),
1565
1582
  /** The question `options` belong to (#40): an option picked is `openrig.answer`'s `choice` with this `questionId`. Absent from daemons
1566
1583
  * before #40, and when there are no options. */
1567
- questionId: z12.string().optional(),
1568
- priority: z12.enum(["routine", "urgent", "critical"]),
1569
- at: z12.string().datetime()
1584
+ questionId: z13.string().optional(),
1585
+ priority: z13.enum(["routine", "urgent", "critical"]),
1586
+ at: z13.string().datetime()
1570
1587
  });
1571
- var PointAnswerSchema = z12.union([z12.object({ id: z12.string().min(1) }).strict(), z12.object({ text: z12.string().min(1).max(4e3) }).strict()]);
1588
+ var PointAnswerSchema = z13.union([z13.object({ id: z13.string().min(1) }).strict(), z13.object({ text: z13.string().min(1).max(4e3) }).strict()]);
1572
1589
 
1573
1590
  // ../../packages/protocol/src/chat.ts
1574
- var ChatStepSchema = z13.object({
1575
- kind: z13.enum(["sessions", "pane", "reply", "git", "repo"]),
1576
- id: z13.string().optional(),
1577
- name: z13.string().optional(),
1578
- path: z13.string().optional()
1579
- });
1580
- var ChatProposalSchema = z13.object({
1581
- cwd: z13.string().min(1),
1582
- project: z13.string(),
1583
- prompt: z13.string().optional(),
1591
+ var ChatStepSchema = z14.object({
1592
+ kind: z14.enum(["sessions", "pane", "reply", "git", "repo"]),
1593
+ id: z14.string().optional(),
1594
+ name: z14.string().optional(),
1595
+ path: z14.string().optional()
1596
+ });
1597
+ var ChatProposalSchema = z14.object({
1598
+ cwd: z14.string().min(1),
1599
+ project: z14.string(),
1600
+ prompt: z14.string().optional(),
1584
1601
  tool: ToolSchema,
1585
1602
  /** What Ledge proposed on the card's picker (spec 2026-10-26 action registry §4), the agent's own default when left out. */
1586
1603
  model: ModelIdSchema.optional(),
1587
1604
  effort: EffortSchema.optional(),
1588
- launchedId: z13.string().optional(),
1589
- error: z13.string().optional()
1605
+ launchedId: z14.string().optional(),
1606
+ error: z14.string().optional()
1590
1607
  });
1591
1608
  var MAX_PROPOSALS = 8;
1592
- var ChatProposalsSchema = z13.array(ChatProposalSchema).min(1).max(MAX_PROPOSALS);
1593
- var ChatRelaySchema = z13.object({
1594
- id: z13.string().min(1),
1595
- name: z13.string(),
1609
+ var ChatProposalsSchema = z14.array(ChatProposalSchema).min(1).max(MAX_PROPOSALS);
1610
+ var ChatRelaySchema = z14.object({
1611
+ id: z14.string().min(1),
1612
+ name: z14.string(),
1596
1613
  tool: ToolSchema,
1597
- text: z13.string().min(1),
1598
- status: z13.enum(["queued", "sent"]).optional(),
1599
- sentAt: z13.string().datetime().optional(),
1600
- error: z13.string().optional(),
1614
+ text: z14.string().min(1),
1615
+ status: z14.enum(["queued", "sent"]).optional(),
1616
+ sentAt: z14.string().datetime().optional(),
1617
+ error: z14.string().optional(),
1601
1618
  /** Why it failed, as a code a front words itself (a RefusalCode, `ended`, or `failed` for the machinery); goes with `error`. */
1602
- code: z13.string().max(40).optional()
1619
+ code: z14.string().max(40).optional()
1603
1620
  });
1604
- var ChatCloseSchema = z13.object({
1605
- id: z13.string().min(1),
1606
- name: z13.string(),
1621
+ var ChatCloseSchema = z14.object({
1622
+ id: z14.string().min(1),
1623
+ name: z14.string(),
1607
1624
  tool: ToolSchema,
1608
- closedAt: z13.string().datetime().optional(),
1609
- how: z13.enum(["exit", "killed"]).optional(),
1610
- error: z13.string().optional()
1611
- });
1612
- var ChatClosesSchema = z13.array(ChatCloseSchema).min(1).max(MAX_PROPOSALS);
1613
- var ChatProjectProposalSchema = z13.object({
1614
- name: z13.string().min(1).max(80),
1615
- description: z13.string().max(500).optional(),
1616
- repos: z13.array(z13.object({ path: z13.string().min(1).max(4096), why: z13.string().min(1).max(200) })).min(1).max(50),
1617
- addTo: z13.string().min(1).max(80).optional()
1618
- });
1619
- var ChatTaskProposalSchema = z13.object({
1620
- to: z13.string().min(1),
1621
- toName: z13.string().optional(),
1622
- title: z13.string().min(1).max(200),
1623
- text: z13.string().max(2e4).optional(),
1624
- taskId: z13.string().optional(),
1625
- ownerName: z13.string().optional(),
1626
- state: z13.enum(["open", "taken", "done", "refused", "dropped"]).optional(),
1627
- givenAt: z13.string().datetime().optional(),
1628
- error: z13.string().optional()
1629
- });
1630
- var ChatTasksSchema = z13.array(ChatTaskProposalSchema).min(1).max(MAX_PROPOSALS);
1631
- var ActionVarsSchema = z13.record(z13.string().max(40), z13.string().max(300));
1625
+ closedAt: z14.string().datetime().optional(),
1626
+ how: z14.enum(["exit", "killed"]).optional(),
1627
+ error: z14.string().optional()
1628
+ });
1629
+ var ChatClosesSchema = z14.array(ChatCloseSchema).min(1).max(MAX_PROPOSALS);
1630
+ var ChatProjectProposalSchema = z14.object({
1631
+ name: z14.string().min(1).max(80),
1632
+ description: z14.string().max(500).optional(),
1633
+ repos: z14.array(z14.object({ path: z14.string().min(1).max(4096), why: z14.string().min(1).max(200) })).min(1).max(50),
1634
+ addTo: z14.string().min(1).max(80).optional()
1635
+ });
1636
+ var ChatTaskProposalSchema = z14.object({
1637
+ to: z14.string().min(1),
1638
+ toName: z14.string().optional(),
1639
+ title: z14.string().min(1).max(200),
1640
+ text: z14.string().max(2e4).optional(),
1641
+ taskId: z14.string().optional(),
1642
+ ownerName: z14.string().optional(),
1643
+ state: z14.enum(["open", "taken", "done", "refused", "dropped"]).optional(),
1644
+ givenAt: z14.string().datetime().optional(),
1645
+ error: z14.string().optional()
1646
+ });
1647
+ var ChatTasksSchema = z14.array(ChatTaskProposalSchema).min(1).max(MAX_PROPOSALS);
1648
+ var ActionVarsSchema = z14.record(z14.string().max(40), z14.string().max(300));
1632
1649
  var DETAIL_MAX = 4e3;
1633
- var ChatActionStateSchema = z13.enum(["running", "done", "denied", "failed", "refused"]);
1634
- var ChatActionSchema = z13.object({
1635
- action: z13.string().min(1).max(40),
1636
- args: z13.record(z13.unknown()),
1637
- summary: z13.string().min(1).max(300),
1650
+ var ChatActionStateSchema = z14.enum(["running", "done", "denied", "failed", "refused"]);
1651
+ var ChatActionSchema = z14.object({
1652
+ action: z14.string().min(1).max(40),
1653
+ args: z14.record(z14.unknown()),
1654
+ summary: z14.string().min(1).max(300),
1638
1655
  vars: ActionVarsSchema.optional(),
1639
- detail: z13.string().max(DETAIL_MAX).optional(),
1640
- detailCut: z13.literal(true).optional(),
1656
+ detail: z14.string().max(DETAIL_MAX).optional(),
1657
+ detailCut: z14.literal(true).optional(),
1641
1658
  risk: ActionRiskSchema,
1642
- session: z13.string().optional(),
1659
+ session: z14.string().optional(),
1643
1660
  /** The sessions an OpenRig step stops, whole (`vars.seats` is cut for the screen): the step is refused if they changed before it applies. */
1644
- cuts: z13.array(z13.string().max(200)).max(500).optional(),
1661
+ cuts: z14.array(z14.string().max(200)).max(500).optional(),
1645
1662
  state: ChatActionStateSchema.optional(),
1646
- doneAt: z13.string().datetime().optional(),
1647
- error: z13.string().optional(),
1648
- code: z13.string().max(40).optional()
1649
- });
1650
- var ChatActionsSchema = z13.array(ChatActionSchema).min(1).max(MAX_PROPOSALS);
1651
- var ChatTurnSchema = z13.object({
1652
- machineId: z13.string().optional(),
1653
- machineName: z13.string().optional(),
1654
- choices: z13.array(z13.object({ id: z13.string(), label: z13.string() })).optional(),
1655
- qid: z13.string().min(1),
1656
- question: z13.string(),
1657
- askedAt: z13.string().datetime(),
1658
- steps: z13.array(ChatStepSchema),
1659
- answer: z13.string().optional(),
1660
- answeredAt: z13.string().datetime().optional(),
1661
- error: z13.string().optional(),
1662
- errorCause: z13.string().max(40).optional(),
1663
+ doneAt: z14.string().datetime().optional(),
1664
+ error: z14.string().optional(),
1665
+ code: z14.string().max(40).optional()
1666
+ });
1667
+ var ChatActionsSchema = z14.array(ChatActionSchema).min(1).max(MAX_PROPOSALS);
1668
+ var ChatTurnSchema = z14.object({
1669
+ machineId: z14.string().optional(),
1670
+ machineName: z14.string().optional(),
1671
+ choices: z14.array(z14.object({ id: z14.string(), label: z14.string() })).optional(),
1672
+ qid: z14.string().min(1),
1673
+ question: z14.string(),
1674
+ askedAt: z14.string().datetime(),
1675
+ steps: z14.array(ChatStepSchema),
1676
+ answer: z14.string().optional(),
1677
+ answeredAt: z14.string().datetime().optional(),
1678
+ error: z14.string().optional(),
1679
+ errorCause: z14.string().max(40).optional(),
1663
1680
  proposal: ChatProposalSchema.optional(),
1664
1681
  proposals: ChatProposalsSchema.optional(),
1665
1682
  relay: ChatRelaySchema.optional(),
@@ -1667,36 +1684,36 @@ var ChatTurnSchema = z13.object({
1667
1684
  projectProposal: ChatProjectProposalSchema.optional(),
1668
1685
  tasks: ChatTasksSchema.optional(),
1669
1686
  actions: ChatActionsSchema.optional(),
1670
- ignoredAt: z13.string().datetime().optional(),
1671
- attachments: z13.array(AttachmentRefSchema).optional(),
1687
+ ignoredAt: z14.string().datetime().optional(),
1688
+ attachments: z14.array(AttachmentRefSchema).optional(),
1672
1689
  /** When Ledge read the account limits for this answer (`limits.md`): a phone shows the limits under it (M3 Q31). */
1673
- limitsAt: z13.string().datetime().optional(),
1690
+ limitsAt: z14.string().datetime().optional(),
1674
1691
  /** `ledge`: a turn Ledge wrote on its own (a point), with an empty `question`; lazy because `operator.ts` imports this file. */
1675
- by: z13.literal("ledge").optional(),
1676
- point: z13.lazy(() => ChatPointSchema).optional()
1692
+ by: z14.literal("ledge").optional(),
1693
+ point: z14.lazy(() => ChatPointSchema).optional()
1677
1694
  });
1678
1695
 
1679
1696
  // ../../packages/protocol/src/documents.ts
1680
- import { z as z14 } from "zod";
1681
- var path = z14.string().min(1).max(4096);
1682
- var requestId2 = z14.string().min(1);
1683
- var DocumentReadSchema = z14.object({
1684
- type: z14.literal("document.read"),
1697
+ import { z as z15 } from "zod";
1698
+ var path = z15.string().min(1).max(4096);
1699
+ var requestId2 = z15.string().min(1);
1700
+ var DocumentReadSchema = z15.object({
1701
+ type: z15.literal("document.read"),
1685
1702
  requestId: requestId2,
1686
1703
  path,
1687
- machineId: z14.string().optional(),
1688
- sessionId: z14.string().min(1).optional(),
1704
+ machineId: z15.string().optional(),
1705
+ sessionId: z15.string().min(1).optional(),
1689
1706
  basePath: path.optional()
1690
1707
  });
1691
- var DocumentContentSchema = z14.object({
1692
- type: z14.literal("document.content"),
1708
+ var DocumentContentSchema = z15.object({
1709
+ type: z15.literal("document.content"),
1693
1710
  requestId: requestId2,
1694
1711
  path,
1695
- text: z14.string(),
1696
- bytes: z14.number().int().nonnegative(),
1697
- modifiedAt: z14.string().datetime()
1712
+ text: z15.string(),
1713
+ bytes: z15.number().int().nonnegative(),
1714
+ modifiedAt: z15.string().datetime()
1698
1715
  });
1699
- var DocumentErrorCodeSchema = z14.enum([
1716
+ var DocumentErrorCodeSchema = z15.enum([
1700
1717
  "not_found",
1701
1718
  "not_file",
1702
1719
  "unsupported_path",
@@ -1708,146 +1725,146 @@ var DocumentErrorCodeSchema = z14.enum([
1708
1725
  "session_missing",
1709
1726
  "read_failed"
1710
1727
  ]);
1711
- var DocumentErrorSchema = z14.object({
1712
- type: z14.literal("document.error"),
1728
+ var DocumentErrorSchema = z15.object({
1729
+ type: z15.literal("document.error"),
1713
1730
  requestId: requestId2,
1714
1731
  path,
1715
1732
  code: DocumentErrorCodeSchema
1716
1733
  });
1717
1734
 
1718
1735
  // ../../packages/protocol/src/browser.ts
1719
- import { z as z15 } from "zod";
1720
- var BrowserStateSchema = z15.enum(["none", "off", "live", "closed"]);
1721
- var BrowserClosedHowSchema = z15.enum(["browser", "tabs", "stopped"]);
1736
+ import { z as z16 } from "zod";
1737
+ var BrowserStateSchema = z16.enum(["none", "off", "live", "closed"]);
1738
+ var BrowserClosedHowSchema = z16.enum(["browser", "tabs", "stopped"]);
1722
1739
  var BROWSER_URL_MAX = 2048;
1723
1740
  var BROWSER_TITLE_MAX = 300;
1724
1741
  var BROWSER_FRAME_MAX = 2e6;
1725
- var url = z15.string().max(BROWSER_URL_MAX);
1726
- var page = z15.string().min(1).max(64);
1727
- var title = z15.string().max(BROWSER_TITLE_MAX);
1728
- var BrowserLiveSchema = z15.object({
1729
- type: z15.literal("browser.live"),
1730
- id: z15.string(),
1742
+ var url = z16.string().max(BROWSER_URL_MAX);
1743
+ var page = z16.string().min(1).max(64);
1744
+ var title = z16.string().max(BROWSER_TITLE_MAX);
1745
+ var BrowserLiveSchema = z16.object({
1746
+ type: z16.literal("browser.live"),
1747
+ id: z16.string(),
1731
1748
  state: BrowserStateSchema,
1732
1749
  url: url.optional(),
1733
1750
  title: title.optional(),
1734
1751
  /** The page the film shows now (live), or showed last (closed). A front shows a frame only when its `page` is this one. */
1735
1752
  page: page.optional(),
1736
- tabs: z15.number().int().nonnegative(),
1737
- since: z15.string().datetime().optional(),
1738
- closedAt: z15.string().datetime().optional(),
1753
+ tabs: z16.number().int().nonnegative(),
1754
+ since: z16.string().datetime().optional(),
1755
+ closedAt: z16.string().datetime().optional(),
1739
1756
  closed: BrowserClosedHowSchema.optional(),
1740
- image: z15.object({ at: z15.string().datetime(), url: url.optional(), title: title.optional(), page: page.optional() }).optional()
1741
- });
1742
- var BrowserFrameSchema = z15.object({
1743
- type: z15.literal("browser.frame"),
1744
- id: z15.string(),
1745
- data: z15.string().min(1).max(BROWSER_FRAME_MAX),
1746
- at: z15.string().datetime(),
1747
- width: z15.number().int().positive().optional(),
1748
- height: z15.number().int().positive().optional(),
1757
+ image: z16.object({ at: z16.string().datetime(), url: url.optional(), title: title.optional(), page: page.optional() }).optional()
1758
+ });
1759
+ var BrowserFrameSchema = z16.object({
1760
+ type: z16.literal("browser.frame"),
1761
+ id: z16.string(),
1762
+ data: z16.string().min(1).max(BROWSER_FRAME_MAX),
1763
+ at: z16.string().datetime(),
1764
+ width: z16.number().int().positive().optional(),
1765
+ height: z16.number().int().positive().optional(),
1749
1766
  /** The page this image is of (film or kept image): a late frame of another page is told apart by it. */
1750
1767
  page: page.optional(),
1751
- live: z15.boolean()
1752
- });
1753
- var BrowserWatchSchema = z15.object({ type: z15.literal("browser.watch"), id: z15.string().min(1) });
1754
- var BrowserUnwatchSchema = z15.object({ type: z15.literal("browser.unwatch"), id: z15.string().min(1) });
1755
- var BrowserEnableSchema = z15.object({ type: z15.literal("browser.enable"), rid: z15.string().min(1).max(100), confirmed: z15.literal(true) });
1756
- var BrowserEnabledSchema = z15.object({
1757
- type: z15.literal("browser.enabled"),
1758
- rid: z15.string(),
1759
- outcome: z15.enum(["enabled", "already", "refused"]),
1760
- reason: z15.enum(["not_configured", "invalid_config", "write_failed"]).optional(),
1761
- path: z15.string().optional()
1768
+ live: z16.boolean()
1769
+ });
1770
+ var BrowserWatchSchema = z16.object({ type: z16.literal("browser.watch"), id: z16.string().min(1) });
1771
+ var BrowserUnwatchSchema = z16.object({ type: z16.literal("browser.unwatch"), id: z16.string().min(1) });
1772
+ var BrowserEnableSchema = z16.object({ type: z16.literal("browser.enable"), rid: z16.string().min(1).max(100), confirmed: z16.literal(true) });
1773
+ var BrowserEnabledSchema = z16.object({
1774
+ type: z16.literal("browser.enabled"),
1775
+ rid: z16.string(),
1776
+ outcome: z16.enum(["enabled", "already", "refused"]),
1777
+ reason: z16.enum(["not_configured", "invalid_config", "write_failed"]).optional(),
1778
+ path: z16.string().optional()
1762
1779
  });
1763
1780
 
1764
1781
  // ../../packages/protocol/src/term.ts
1765
- import { z as z16 } from "zod";
1782
+ import { z as z17 } from "zod";
1766
1783
  var TERM_CHUNK_B64 = 22e3;
1767
1784
  var TERM_PANE_SCREEN_MAX = 65536;
1768
1785
  var PANE_INPUT_MAX = 4096;
1769
- var id = z16.string().min(1).max(200);
1770
- var cols = z16.number().int().min(2).max(500);
1771
- var rows = z16.number().int().min(2).max(200);
1772
- var shell = z16.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
1773
- var TermWatchSchema = z16.object({
1774
- type: z16.literal("term.watch"),
1786
+ var id = z17.string().min(1).max(200);
1787
+ var cols = z17.number().int().min(2).max(500);
1788
+ var rows = z17.number().int().min(2).max(200);
1789
+ var shell = z17.string().regex(/^[A-Za-z0-9_-]{1,40}$/);
1790
+ var TermWatchSchema = z17.object({
1791
+ type: z17.literal("term.watch"),
1775
1792
  id,
1776
1793
  cols,
1777
1794
  rows,
1778
- readOnly: z16.literal(true).optional()
1779
- });
1780
- var TermShellSchema = z16.object({ type: z16.literal("term.shell"), id, shell, cols, rows });
1781
- var TermUnwatchSchema = z16.object({ type: z16.literal("term.unwatch"), id, shell: shell.optional() });
1782
- var TermInputSchema = z16.object({ type: z16.literal("term.input"), id, shell: shell.optional(), data: z16.string().min(1).max(PANE_INPUT_MAX) });
1783
- var TermResizeSchema = z16.object({ type: z16.literal("term.resize"), id, shell: shell.optional(), cols, rows });
1784
- var PaneExitWhySchema = z16.enum(["ended", "gone", "failed"]);
1785
- var TermModesSchema = z16.object({
1786
- alt: z16.boolean(),
1787
- cursor: z16.boolean(),
1788
- appCursor: z16.boolean(),
1789
- appKeypad: z16.boolean(),
1790
- mouse: z16.enum(["none", "standard", "button", "any"]),
1791
- sgr: z16.boolean(),
1792
- wrap: z16.boolean(),
1793
- insert: z16.boolean(),
1794
- paste: z16.boolean().optional()
1795
- });
1796
- var TermOpenedSchema = z16.object({
1797
- type: z16.literal("term.opened"),
1795
+ readOnly: z17.literal(true).optional()
1796
+ });
1797
+ var TermShellSchema = z17.object({ type: z17.literal("term.shell"), id, shell, cols, rows });
1798
+ var TermUnwatchSchema = z17.object({ type: z17.literal("term.unwatch"), id, shell: shell.optional() });
1799
+ var TermInputSchema = z17.object({ type: z17.literal("term.input"), id, shell: shell.optional(), data: z17.string().min(1).max(PANE_INPUT_MAX) });
1800
+ var TermResizeSchema = z17.object({ type: z17.literal("term.resize"), id, shell: shell.optional(), cols, rows });
1801
+ var PaneExitWhySchema = z17.enum(["ended", "gone", "failed"]);
1802
+ var TermModesSchema = z17.object({
1803
+ alt: z17.boolean(),
1804
+ cursor: z17.boolean(),
1805
+ appCursor: z17.boolean(),
1806
+ appKeypad: z17.boolean(),
1807
+ mouse: z17.enum(["none", "standard", "button", "any"]),
1808
+ sgr: z17.boolean(),
1809
+ wrap: z17.boolean(),
1810
+ insert: z17.boolean(),
1811
+ paste: z17.boolean().optional()
1812
+ });
1813
+ var TermOpenedSchema = z17.object({
1814
+ type: z17.literal("term.opened"),
1798
1815
  id,
1799
1816
  shell: shell.optional(),
1800
1817
  cols,
1801
1818
  rows,
1802
- screen: z16.string().max(TERM_PANE_SCREEN_MAX),
1803
- cursor: z16.object({ x: z16.number().int().nonnegative().max(1e3), y: z16.number().int().nonnegative().max(1e3) }),
1819
+ screen: z17.string().max(TERM_PANE_SCREEN_MAX),
1820
+ cursor: z17.object({ x: z17.number().int().nonnegative().max(1e3), y: z17.number().int().nonnegative().max(1e3) }),
1804
1821
  /** Absent from an older daemon: the screen is painted with xterm's own modes, as before. */
1805
1822
  modes: TermModesSchema.optional(),
1806
1823
  /** #299: a free shell with Ledge's integration signs its command lines (OSC 633;E;<line>;<nonce>) with this: an E without it, or
1807
1824
  * with another, comes from what a program wrote, not from the shell, and is never run again. Absent: no integration. */
1808
- nonce: z16.string().regex(/^[0-9a-f]{32}$/).optional()
1825
+ nonce: z17.string().regex(/^[0-9a-f]{32}$/).optional()
1809
1826
  });
1810
- var TermOutputSchema = z16.object({ type: z16.literal("term.output"), id, shell: shell.optional(), data: z16.string().min(1).max(TERM_CHUNK_B64) });
1811
- var TermSizeSchema = z16.object({ type: z16.literal("term.size"), id, shell: shell.optional(), cols, rows });
1812
- var TermExitSchema = z16.object({ type: z16.literal("term.exit"), id, shell: shell.optional(), why: PaneExitWhySchema });
1827
+ var TermOutputSchema = z17.object({ type: z17.literal("term.output"), id, shell: shell.optional(), data: z17.string().min(1).max(TERM_CHUNK_B64) });
1828
+ var TermSizeSchema = z17.object({ type: z17.literal("term.size"), id, shell: shell.optional(), cols, rows });
1829
+ var TermExitSchema = z17.object({ type: z17.literal("term.exit"), id, shell: shell.optional(), why: PaneExitWhySchema });
1813
1830
 
1814
1831
  // ../../packages/protocol/src/aside.ts
1815
- import { z as z17 } from "zod";
1832
+ import { z as z18 } from "zod";
1816
1833
  var ASIDE_QUESTION_MAX = 4e3;
1817
1834
  var ASIDE_ANSWER_MAX = 5e4;
1818
- var AsideStateSchema = z17.enum(["asking", "answered", "failed"]);
1819
- var AsideCauseSchema = z17.enum(["unsupported", "read_only", "busy", "not_empty", "no_panel", "timeout", "unreadable", "interrupted", "invalid"]).catch("invalid");
1820
- var AsideSchema = z17.object({
1821
- rid: z17.string().min(1).max(100),
1822
- question: z17.string().max(ASIDE_QUESTION_MAX),
1823
- askedAt: z17.string().datetime(),
1835
+ var AsideStateSchema = z18.enum(["asking", "answered", "failed"]);
1836
+ var AsideCauseSchema = z18.enum(["unsupported", "read_only", "busy", "not_empty", "no_panel", "timeout", "unreadable", "interrupted", "invalid"]).catch("invalid");
1837
+ var AsideSchema = z18.object({
1838
+ rid: z18.string().min(1).max(100),
1839
+ question: z18.string().max(ASIDE_QUESTION_MAX),
1840
+ askedAt: z18.string().datetime(),
1824
1841
  state: AsideStateSchema,
1825
1842
  /** The answer as Claude Code copies it: Markdown. */
1826
- answer: z17.string().max(ASIDE_ANSWER_MAX).optional(),
1827
- truncated: z17.literal(true).optional(),
1828
- answeredAt: z17.string().datetime().optional(),
1843
+ answer: z18.string().max(ASIDE_ANSWER_MAX).optional(),
1844
+ truncated: z18.literal(true).optional(),
1845
+ answeredAt: z18.string().datetime().optional(),
1829
1846
  cause: AsideCauseSchema.optional()
1830
1847
  });
1831
- var SessionAsideAskSchema = z17.object({ type: z17.literal("session.aside"), id: z17.string().min(1), rid: z17.string().min(1).max(100), question: z17.string().trim().min(1).max(ASIDE_QUESTION_MAX) });
1832
- var SessionAsideSchema = z17.object({ type: z17.literal("session.aside"), id: z17.string().min(1), aside: AsideSchema });
1848
+ var SessionAsideAskSchema = z18.object({ type: z18.literal("session.aside"), id: z18.string().min(1), rid: z18.string().min(1).max(100), question: z18.string().trim().min(1).max(ASIDE_QUESTION_MAX) });
1849
+ var SessionAsideSchema = z18.object({ type: z18.literal("session.aside"), id: z18.string().min(1), aside: AsideSchema });
1833
1850
 
1834
1851
  // ../../packages/protocol/src/machines.ts
1835
- import { z as z19 } from "zod";
1852
+ import { z as z20 } from "zod";
1836
1853
 
1837
1854
  // ../../packages/protocol/src/ssh.ts
1838
- import { z as z18 } from "zod";
1839
- var SshAliasSchema = z18.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/);
1855
+ import { z as z19 } from "zod";
1856
+ var SshAliasSchema = z19.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/);
1840
1857
 
1841
1858
  // ../../packages/protocol/src/machines.ts
1842
- var MachineIdSchema = z19.string().regex(/^[a-zA-Z0-9_-]{1,64}$/);
1843
- var MachineSchema = z19.object({
1859
+ var MachineIdSchema = z20.string().regex(/^[a-zA-Z0-9_-]{1,64}$/);
1860
+ var MachineSchema = z20.object({
1844
1861
  id: MachineIdSchema,
1845
- label: z19.string().trim().min(1).max(80),
1862
+ label: z20.string().trim().min(1).max(80),
1846
1863
  ssh: SshAliasSchema.optional(),
1847
1864
  /** Kept in the list but never connected to: no peer, no retry, no session shown until it is enabled again. */
1848
- disabled: z19.boolean().optional()
1865
+ disabled: z20.boolean().optional()
1849
1866
  });
1850
- var MachinesSchema = z19.array(MachineSchema).min(1).max(20).superRefine((list, ctx) => {
1867
+ var MachinesSchema = z20.array(MachineSchema).min(1).max(20).superRefine((list, ctx) => {
1851
1868
  if (list[0]?.id !== "local" || list[0].ssh !== void 0) ctx.addIssue({ code: "custom", message: "the first machine is local, without ssh", path: [0] });
1852
1869
  const ids = /* @__PURE__ */ new Set(), aliases = /* @__PURE__ */ new Set();
1853
1870
  list.forEach((m, i) => {
@@ -1863,57 +1880,57 @@ var MachinesSchema = z19.array(MachineSchema).min(1).max(20).superRefine((list,
1863
1880
  });
1864
1881
 
1865
1882
  // ../../packages/protocol/src/island.ts
1866
- import { z as z20 } from "zod";
1867
- var IslandScaleSchema = z20.union([z20.literal("auto"), z20.literal(1), z20.literal(1.25), z20.literal(1.5), z20.literal(2)]);
1868
- var IslandPrefsSchema = z20.object({
1883
+ import { z as z21 } from "zod";
1884
+ var IslandScaleSchema = z21.union([z21.literal("auto"), z21.literal(1), z21.literal(1.25), z21.literal(1.5), z21.literal(2)]);
1885
+ var IslandPrefsSchema = z21.object({
1869
1886
  /** Shown at the top of the screen; hidden, Desktop still notifies. */
1870
- visible: z20.boolean(),
1887
+ visible: z21.boolean(),
1871
1888
  /** `primary` (whichever it is after a reconfiguration), or a monitor's id as the shell lists it (`list_monitors`: the OS
1872
1889
  * name, `#index` without one). `second`, written by older fronts, is the first monitor that is not the primary. */
1873
- screen: z20.string().trim().min(1).max(200),
1874
- position: z20.enum(["center", "left", "right"]),
1890
+ screen: z21.string().trim().min(1).max(200),
1891
+ position: z21.enum(["center", "left", "right"]),
1875
1892
  /** Retired with the floating island (#27): it was a strip under a maximised window. Optional and never read, so a file or
1876
1893
  * a front that still carries it parses; still written by DEFAULT_ISLAND_PREFS because a daemon before #27 requires it in
1877
1894
  * `island.set`. */
1878
- discreet: z20.boolean().optional(),
1895
+ discreet: z21.boolean().optional(),
1879
1896
  islandScale: IslandScaleSchema,
1880
1897
  /** Retired with the floating island (#27): the island's size sizes its cards too. Optional and never read; still written by
1881
1898
  * DEFAULT_ISLAND_PREFS for daemons before #27, which require it. */
1882
1899
  panelScale: IslandScaleSchema.optional(),
1883
1900
  /** What the island shows besides asks and questions, which it always shows. */
1884
- shows: z20.object({
1901
+ shows: z21.object({
1885
1902
  /** Allow, deny or answer in a line from the island; off, its cards only say « Open in Ledge ». */
1886
- quick: z20.boolean(),
1903
+ quick: z21.boolean(),
1887
1904
  /** The 6 s « Done » card when an agent finishes its turn. */
1888
- finished: z20.boolean(),
1905
+ finished: z21.boolean(),
1889
1906
  /** Retired with the floating island (#27), like `helpers`: optional and never read, still written by default for older daemons. */
1890
- say: z20.boolean().optional(),
1891
- helpers: z20.boolean().optional()
1907
+ say: z21.boolean().optional(),
1908
+ helpers: z21.boolean().optional()
1892
1909
  }),
1893
1910
  /** The global shortcut that reopens the oldest waiting request, as shown (`Ctrl Alt L`). */
1894
- shortcut: z20.string().trim().min(1).max(40)
1911
+ shortcut: z21.string().trim().min(1).max(40)
1895
1912
  });
1896
1913
 
1897
1914
  // ../../packages/protocol/src/projects.ts
1898
- import { z as z21 } from "zod";
1899
- var ProjectColorSchema = z21.enum(["blue", "green", "amber", "violet", "teal", "pink", "red", "slate"]);
1900
- var ProjectIdSchema = z21.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/);
1915
+ import { z as z22 } from "zod";
1916
+ var ProjectColorSchema = z22.enum(["blue", "green", "amber", "violet", "teal", "pink", "red", "slate"]);
1917
+ var ProjectIdSchema = z22.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/);
1901
1918
  function normalizePath(raw) {
1902
1919
  const p = raw.trim().replace(/\/+/g, "/");
1903
1920
  return p.length > 1 && p.endsWith("/") ? p.slice(0, -1) : p;
1904
1921
  }
1905
- var PathSchema = z21.string().max(4096).refine((p) => p.startsWith("/") && p === normalizePath(p), "an absolute, normalized path");
1922
+ var PathSchema = z22.string().max(4096).refine((p) => p.startsWith("/") && p === normalizePath(p), "an absolute, normalized path");
1906
1923
  var FolderPathSchema = PathSchema;
1907
- var RepoSchema = z21.object({ machine: MachineIdSchema, path: PathSchema });
1908
- var ProjectNameSchema = z21.string().trim().min(1).max(80);
1909
- var ProjectSchema = z21.object({
1924
+ var RepoSchema = z22.object({ machine: MachineIdSchema, path: PathSchema });
1925
+ var ProjectNameSchema = z22.string().trim().min(1).max(80);
1926
+ var ProjectSchema = z22.object({
1910
1927
  id: ProjectIdSchema,
1911
1928
  name: ProjectNameSchema,
1912
1929
  color: ProjectColorSchema,
1913
- description: z21.string().max(500).default(""),
1914
- repos: z21.array(RepoSchema).max(50)
1930
+ description: z22.string().max(500).default(""),
1931
+ repos: z22.array(RepoSchema).max(50)
1915
1932
  });
1916
- var RuleSchema = z21.object({ machine: MachineIdSchema, path: PathSchema, project: ProjectIdSchema });
1933
+ var RuleSchema = z22.object({ machine: MachineIdSchema, path: PathSchema, project: ProjectIdSchema });
1917
1934
  function projectsProblems(p) {
1918
1935
  const out = [];
1919
1936
  const ids = /* @__PURE__ */ new Set(), names = /* @__PURE__ */ new Set(), repos = /* @__PURE__ */ new Set(), rules = /* @__PURE__ */ new Set();
@@ -1940,8 +1957,8 @@ ${rule.path}`;
1940
1957
  return out;
1941
1958
  }
1942
1959
  var SESSION_ORDER_MAX = 500;
1943
- var SessionOrderSchema = z21.record(z21.string().max(64), z21.array(z21.string().min(1).max(300)).max(SESSION_ORDER_MAX));
1944
- var ProjectsSchema = z21.object({ projects: z21.array(ProjectSchema).max(100), rules: z21.array(RuleSchema).max(1e3), order: SessionOrderSchema.optional() }).superRefine((p, ctx) => {
1960
+ var SessionOrderSchema = z22.record(z22.string().max(64), z22.array(z22.string().min(1).max(300)).max(SESSION_ORDER_MAX));
1961
+ var ProjectsSchema = z22.object({ projects: z22.array(ProjectSchema).max(100), rules: z22.array(RuleSchema).max(1e3), order: SessionOrderSchema.optional() }).superRefine((p, ctx) => {
1945
1962
  for (const problem of projectsProblems(p)) ctx.addIssue({ code: "custom", message: problem.code, path: problem.path });
1946
1963
  });
1947
1964
 
@@ -1950,415 +1967,415 @@ var BROADCAST_SESSIONS_MAX = 32;
1950
1967
  var BROADCAST_LABEL_MAX = 120;
1951
1968
 
1952
1969
  // ../../packages/protocol/src/messages.ts
1953
- import { z as z33 } from "zod";
1970
+ import { z as z34 } from "zod";
1954
1971
 
1955
1972
  // ../../packages/protocol/src/repos.ts
1956
- import { z as z22 } from "zod";
1957
- var ReposInspectSchema = z22.object({
1958
- type: z22.literal("repos.inspect"),
1959
- requestId: z22.string().min(1).max(100),
1960
- paths: z22.array(z22.string().min(1)).min(1).max(50),
1961
- machineId: z22.string().optional()
1962
- });
1963
- var RepoInfoSchema = z22.object({ path: z22.string(), exists: z22.boolean(), branch: z22.string().nullable() });
1964
- var ReposInfoSchema = z22.object({ type: z22.literal("repos.info"), requestId: z22.string(), repos: z22.array(RepoInfoSchema) });
1973
+ import { z as z23 } from "zod";
1974
+ var ReposInspectSchema = z23.object({
1975
+ type: z23.literal("repos.inspect"),
1976
+ requestId: z23.string().min(1).max(100),
1977
+ paths: z23.array(z23.string().min(1)).min(1).max(50),
1978
+ machineId: z23.string().optional()
1979
+ });
1980
+ var RepoInfoSchema = z23.object({ path: z23.string(), exists: z23.boolean(), branch: z23.string().nullable() });
1981
+ var ReposInfoSchema = z23.object({ type: z23.literal("repos.info"), requestId: z23.string(), repos: z23.array(RepoInfoSchema) });
1965
1982
 
1966
1983
  // ../../packages/protocol/src/commands.ts
1967
- import { z as z23 } from "zod";
1968
- var SlashSourceSchema = z23.enum(["builtin", "project", "user", "plugin", "extension"]);
1984
+ import { z as z24 } from "zod";
1985
+ var SlashSourceSchema = z24.enum(["builtin", "project", "user", "plugin", "extension"]);
1969
1986
  var SLASH_COMMANDS_MAX = 400;
1970
1987
  var SLASH_DESCRIPTION_MAX = 300;
1971
- var SlashCommandSchema = z23.object({
1972
- name: z23.string().min(1).max(200),
1973
- description: z23.string().max(SLASH_DESCRIPTION_MAX).optional(),
1974
- argumentHint: z23.string().max(200).optional(),
1975
- aliases: z23.array(z23.string().min(1).max(200)).max(10).optional(),
1988
+ var SlashCommandSchema = z24.object({
1989
+ name: z24.string().min(1).max(200),
1990
+ description: z24.string().max(SLASH_DESCRIPTION_MAX).optional(),
1991
+ argumentHint: z24.string().max(200).optional(),
1992
+ aliases: z24.array(z24.string().min(1).max(200)).max(10).optional(),
1976
1993
  source: SlashSourceSchema,
1977
- blocked: z23.enum(["panel", "close"]).optional(),
1978
- bare: z23.literal("panel").optional()
1979
- });
1980
- var SessionCommandsSchema = z23.object({ type: z23.literal("session.commands"), requestId: z23.string().min(1).max(100), id: z23.string() });
1981
- var SessionCommandsListingSchema = z23.object({
1982
- type: z23.literal("session.commands.listing"),
1983
- requestId: z23.string(),
1984
- id: z23.string(),
1994
+ blocked: z24.enum(["panel", "close"]).optional(),
1995
+ bare: z24.literal("panel").optional()
1996
+ });
1997
+ var SessionCommandsSchema = z24.object({ type: z24.literal("session.commands"), requestId: z24.string().min(1).max(100), id: z24.string() });
1998
+ var SessionCommandsListingSchema = z24.object({
1999
+ type: z24.literal("session.commands.listing"),
2000
+ requestId: z24.string(),
2001
+ id: z24.string(),
1985
2002
  tool: ToolSchema.optional(),
1986
- commands: z23.array(SlashCommandSchema).max(SLASH_COMMANDS_MAX),
1987
- error: z23.string().max(200).optional()
2003
+ commands: z24.array(SlashCommandSchema).max(SLASH_COMMANDS_MAX),
2004
+ error: z24.string().max(200).optional()
1988
2005
  });
1989
2006
 
1990
2007
  // ../../packages/protocol/src/scan.ts
1991
- import { z as z24 } from "zod";
1992
- var ReposScanSchema = z24.object({ type: z24.literal("repos.scan"), requestId: z24.string().min(1).max(100), machineId: z24.string().optional() });
1993
- var FoundRepoSchema = z24.object({ path: z24.string(), branch: z24.string().nullable(), remote: z24.string().optional(), manifest: z24.string().max(200).optional() });
1994
- var ReposFoundSchema = z24.object({ type: z24.literal("repos.found"), requestId: z24.string(), repos: z24.array(FoundRepoSchema).max(500), truncated: z24.boolean(), error: z24.string().optional() });
2008
+ import { z as z25 } from "zod";
2009
+ var ReposScanSchema = z25.object({ type: z25.literal("repos.scan"), requestId: z25.string().min(1).max(100), machineId: z25.string().optional() });
2010
+ var FoundRepoSchema = z25.object({ path: z25.string(), branch: z25.string().nullable(), remote: z25.string().optional(), manifest: z25.string().max(200).optional() });
2011
+ var ReposFoundSchema = z25.object({ type: z25.literal("repos.found"), requestId: z25.string(), repos: z25.array(FoundRepoSchema).max(500), truncated: z25.boolean(), error: z25.string().optional() });
1995
2012
 
1996
2013
  // ../../packages/protocol/src/rigMessages.ts
1997
- import { z as z25 } from "zod";
1998
- var QitemIdSchema = z25.string().regex(/^qitem-[A-Za-z0-9-]{1,120}$/, "not a qitem");
2014
+ import { z as z26 } from "zod";
2015
+ var QitemIdSchema = z26.string().regex(/^qitem-[A-Za-z0-9-]{1,120}$/, "not a qitem");
1999
2016
  var QITEM = "qitem-[A-Za-z0-9-]+";
2000
- var RigKindSchema = z25.enum(["message", "handoff", "unblocked", "openrig", "unreadable"]);
2001
- var RigInfoSchema = z25.object({
2017
+ var RigKindSchema = z26.enum(["message", "handoff", "unblocked", "openrig", "unreadable"]);
2018
+ var RigInfoSchema = z26.object({
2002
2019
  kind: RigKindSchema,
2003
2020
  /** The envelope's From, as written (`pilot-lead@ledge-dev-2`, `daemon@kernel`, `ledge@external`, `<unknown sender>`).
2004
2021
  * On the seat's own `sent`: absent (it is the seat). The item's `peer` is the Ledge session of that seat, when known. */
2005
- from: z25.string().optional(),
2022
+ from: z26.string().optional(),
2006
2023
  /** The envelope's To, as written (a seat, a list `a, b`, or `broadcast to <rig> (n seats)`); on an outgoing item, the
2007
2024
  * destination the command named. */
2008
- to: z25.string().optional(),
2025
+ to: z26.string().optional(),
2009
2026
  /** The envelope's `Sent:` stamp as an ISO time (OpenRig gives no year: the year of receipt, or the year before when
2010
2027
  * that would put it in the future). Absent when the envelope has no `Sent:` line. */
2011
- sentAt: z25.string().datetime().optional(),
2028
+ sentAt: z26.string().datetime().optional(),
2012
2029
  /** The sender's generation (8 hex), when the stamp carries one. */
2013
- gen: z25.string().optional(),
2030
+ gen: z26.string().optional(),
2014
2031
  /** The row the item is about. `handoff`: the row handed (outgoing: the new row, when the command's output names it);
2015
2032
  * `unblocked`: the parked row now pending; `openrig`: the row it names (a stuck sweep: the stalled row). */
2016
2033
  qitem: QitemIdSchema.optional(),
2017
2034
  /** `handoff`: the row's summary as OpenRig carried it (one line, at most 120 characters, `…` when cut). */
2018
- summary: z25.string().optional(),
2035
+ summary: z26.string().optional(),
2019
2036
  /** `unblocked`: the row whose closing unblocked it. */
2020
2037
  blocker: QitemIdSchema.optional(),
2021
2038
  /** `openrig`: the recovery row OpenRig opened for it (a stuck sweep comes as a handoff of a `qitem-recovery-…` row). */
2022
2039
  recovery: QitemIdSchema.optional(),
2023
2040
  /** `openrig`: `stalled` a stuck sweep (a seat that does not move: amber), `custody` a custody check; else absent. */
2024
- alert: z25.enum(["stalled", "custody"]).optional(),
2041
+ alert: z26.enum(["stalled", "custody"]).optional(),
2025
2042
  /** `openrig` with an alert: how long, in minutes, as OpenRig said. */
2026
- minutes: z25.number().int().nonnegative().optional(),
2043
+ minutes: z26.number().int().nonnegative().optional(),
2027
2044
  /** The seat's own command (an outgoing `sent` or `handoff`): the Bash command, as run. */
2028
- command: z25.string().optional(),
2045
+ command: z26.string().optional(),
2029
2046
  /** OpenRig said the delivery may repeat (`Recovered queue notification`). */
2030
- recovered: z25.literal(true).optional(),
2047
+ recovered: z26.literal(true).optional(),
2031
2048
  /** Received that many times (2 or more): the same block came again, and this item stands for all of them. */
2032
- count: z25.number().int().min(2).optional(),
2049
+ count: z26.number().int().min(2).optional(),
2033
2050
  /** Blocks pasted together in one prompt: the prompt's id, this block's place and how many there were. The front shows
2034
2051
  * one raw for the packet, the raws of its items joined. */
2035
- packet: z25.object({ id: z25.string().min(1), index: z25.number().int().nonnegative(), count: z25.number().int().min(2) }).optional(),
2052
+ packet: z26.object({ id: z26.string().min(1), index: z26.number().int().nonnegative(), count: z26.number().int().min(2) }).optional(),
2036
2053
  /** The block exactly as received (every delivery, separated by a blank line, when `count` is set); outgoing: the command
2037
2054
  * and what it printed. Always there. */
2038
- raw: z25.string()
2055
+ raw: z26.string()
2039
2056
  });
2040
2057
  var HANDOFF = new RegExp(`^Queue handoff: (${QITEM}) - check your queue\\.(?: Summary: (.*))?$`);
2041
2058
  var BLOCKER = new RegExp(`^Blocker (${QITEM}) resolved; parked qitem (${QITEM}) is pending\\.`);
2042
2059
  var STALLED = new RegExp(`^Stuck sweep: \\S+ on (${QITEM}) \\((\\d+) min\\)`);
2043
2060
  var CUSTODY = new RegExp(`^Custody not checked\\b.*?(?:for |of )(${QITEM}).*?\\((\\d+) min\\)`);
2044
- var RigRowSchema = z25.object({
2061
+ var RigRowSchema = z26.object({
2045
2062
  id: QitemIdSchema,
2046
- state: z25.string().min(1),
2047
- summary: z25.string().optional(),
2063
+ state: z26.string().min(1),
2064
+ summary: z26.string().optional(),
2048
2065
  /** Who made it and who holds it (seats). */
2049
- from: z25.string(),
2050
- to: z25.string(),
2066
+ from: z26.string(),
2067
+ to: z26.string(),
2051
2068
  /** `handed-off`: the seat it went to. */
2052
- handedOffTo: z25.string().optional(),
2069
+ handedOffTo: z26.string().optional(),
2053
2070
  /** `blocked`: the row it waits on. */
2054
- blockedOn: z25.string().optional(),
2055
- createdAt: z25.string(),
2056
- claimedAt: z25.string().optional(),
2057
- updatedAt: z25.string(),
2071
+ blockedOn: z26.string().optional(),
2072
+ createdAt: z26.string(),
2073
+ claimedAt: z26.string().optional(),
2074
+ updatedAt: z26.string(),
2058
2075
  /** When Ledge read it. */
2059
- at: z25.string(),
2076
+ at: z26.string(),
2060
2077
  /** The request waits on a prompt (`waiting.liveness.needsInput`): how many, and why (`permission_prompt`…). Only set when `count` > 0. */
2061
- needsInput: z25.object({ count: z25.number().int().min(1), reason: z25.string().nullable() }).optional()
2062
- });
2063
- var OpenRigRowSchema = z25.object({ type: z25.literal("openrig.row"), requestId: z25.string().min(1).max(100), qitem: QitemIdSchema, machineId: z25.string().optional() });
2064
- var OpenRigRowStateSchema = z25.object({
2065
- type: z25.literal("openrig.rowState"),
2066
- requestId: z25.string(),
2067
- machineId: z25.string().optional(),
2068
- qitem: z25.string(),
2078
+ needsInput: z26.object({ count: z26.number().int().min(1), reason: z26.string().nullable() }).optional()
2079
+ });
2080
+ var OpenRigRowSchema = z26.object({ type: z26.literal("openrig.row"), requestId: z26.string().min(1).max(100), qitem: QitemIdSchema, machineId: z26.string().optional() });
2081
+ var OpenRigRowStateSchema = z26.object({
2082
+ type: z26.literal("openrig.rowState"),
2083
+ requestId: z26.string(),
2084
+ machineId: z26.string().optional(),
2085
+ qitem: z26.string(),
2069
2086
  row: RigRowSchema.optional(),
2070
- error: z25.string().optional()
2071
- });
2072
- var OpenRigQueueSchema = z25.object({ type: z25.literal("openrig.queue"), requestId: z25.string().min(1).max(100), machineId: z25.string().optional(), rig: RigNameSchema });
2073
- var OpenRigQueueStateSchema = z25.object({
2074
- type: z25.literal("openrig.queueState"),
2075
- requestId: z25.string(),
2076
- machineId: z25.string().optional(),
2077
- rig: z25.string(),
2078
- rows: z25.array(RigRowSchema),
2079
- truncated: z25.boolean(),
2080
- error: z25.string().optional()
2087
+ error: z26.string().optional()
2088
+ });
2089
+ var OpenRigQueueSchema = z26.object({ type: z26.literal("openrig.queue"), requestId: z26.string().min(1).max(100), machineId: z26.string().optional(), rig: RigNameSchema });
2090
+ var OpenRigQueueStateSchema = z26.object({
2091
+ type: z26.literal("openrig.queueState"),
2092
+ requestId: z26.string(),
2093
+ machineId: z26.string().optional(),
2094
+ rig: z26.string(),
2095
+ rows: z26.array(RigRowSchema),
2096
+ truncated: z26.boolean(),
2097
+ error: z26.string().optional()
2081
2098
  });
2082
2099
 
2083
2100
  // ../../packages/protocol/src/openrigRoles.ts
2084
- import { z as z26 } from "zod";
2085
- var RoleUnknownWhySchema = z26.enum(["resolved_at_launch", "not_exposed", "unreadable", "ambiguous", "not_found", "missing_from_guidance"]);
2086
- var RoleFromSchema = z26.enum(["import", "defaults", "profile", "rig", "pod", "member", "launch", "openrig", "plugin", "seat"]);
2087
- var OriginSchema = z26.discriminatedUnion("kind", [
2088
- z26.object({ kind: z26.literal("here"), key: z26.string().optional() }),
2089
- z26.object({ kind: z26.literal("inherited"), from: RoleFromSchema, ref: z26.string().optional(), key: z26.string().optional(), path: z26.string().optional() }),
2090
- z26.object({ kind: z26.literal("absent") }),
2091
- z26.object({ kind: z26.literal("unknown"), why: RoleUnknownWhySchema, detail: z26.string().optional() })
2101
+ import { z as z27 } from "zod";
2102
+ var RoleUnknownWhySchema = z27.enum(["resolved_at_launch", "not_exposed", "unreadable", "ambiguous", "not_found", "missing_from_guidance"]);
2103
+ var RoleFromSchema = z27.enum(["import", "defaults", "profile", "rig", "pod", "member", "launch", "openrig", "plugin", "seat"]);
2104
+ var OriginSchema = z27.discriminatedUnion("kind", [
2105
+ z27.object({ kind: z27.literal("here"), key: z27.string().optional() }),
2106
+ z27.object({ kind: z27.literal("inherited"), from: RoleFromSchema, ref: z27.string().optional(), key: z27.string().optional(), path: z27.string().optional() }),
2107
+ z27.object({ kind: z27.literal("absent") }),
2108
+ z27.object({ kind: z27.literal("unknown"), why: RoleUnknownWhySchema, detail: z27.string().optional() })
2092
2109
  ]);
2093
- var SourcedStringSchema = z26.object({ value: z26.string().nullable(), origin: OriginSchema });
2094
- var RoleResourceCategorySchema = z26.enum(["skill", "guidance", "plugin", "subagent", "runtime_resource"]);
2095
- var RoleResourceSchema = z26.object({
2110
+ var SourcedStringSchema = z27.object({ value: z27.string().nullable(), origin: OriginSchema });
2111
+ var RoleResourceCategorySchema = z27.enum(["skill", "guidance", "plugin", "subagent", "runtime_resource"]);
2112
+ var RoleResourceSchema = z27.object({
2096
2113
  category: RoleResourceCategorySchema,
2097
- id: z26.string(),
2098
- path: z26.string().optional(),
2099
- absolutePath: z26.string().optional(),
2100
- runtime: z26.string().optional(),
2101
- type: z26.string().optional(),
2102
- target: z26.string().optional(),
2103
- plugin: z26.object({ version: z26.string().optional(), skills: z26.array(z26.string()), hooks: z26.number().int().min(0) }).optional(),
2114
+ id: z27.string(),
2115
+ path: z27.string().optional(),
2116
+ absolutePath: z27.string().optional(),
2117
+ runtime: z27.string().optional(),
2118
+ type: z27.string().optional(),
2119
+ target: z27.string().optional(),
2120
+ plugin: z27.object({ version: z27.string().optional(), skills: z27.array(z27.string()), hooks: z27.number().int().min(0) }).optional(),
2104
2121
  origin: OriginSchema
2105
2122
  });
2106
- var RoleUsesListSchema = z26.object({ declared: z26.boolean(), key: z26.string(), items: z26.array(RoleResourceSchema) });
2107
- var StartupLayerSchema = z26.enum(["agent", "profile", "culture", "rig", "pod", "member", "openrig", "seat", "unknown"]);
2108
- var StartupEntrySchema = z26.object({
2109
- kind: z26.enum(["file", "action"]),
2110
- path: z26.string().optional(),
2111
- absolutePath: z26.string().optional(),
2112
- size: z26.number().int().min(0).optional(),
2113
- value: z26.string().optional(),
2114
- builtin: z26.string().optional(),
2123
+ var RoleUsesListSchema = z27.object({ declared: z27.boolean(), key: z27.string(), items: z27.array(RoleResourceSchema) });
2124
+ var StartupLayerSchema = z27.enum(["agent", "profile", "culture", "rig", "pod", "member", "openrig", "seat", "unknown"]);
2125
+ var StartupEntrySchema = z27.object({
2126
+ kind: z27.enum(["file", "action"]),
2127
+ path: z27.string().optional(),
2128
+ absolutePath: z27.string().optional(),
2129
+ size: z27.number().int().min(0).optional(),
2130
+ value: z27.string().optional(),
2131
+ builtin: z27.string().optional(),
2115
2132
  layer: StartupLayerSchema,
2116
- layerInferred: z26.boolean(),
2117
- delivery: z26.string(),
2118
- into: z26.string().optional(),
2119
- delivered: z26.boolean().optional(),
2120
- required: z26.boolean().optional(),
2121
- orientation: z26.string().optional(),
2122
- appliesOn: z26.array(z26.string()),
2133
+ layerInferred: z27.boolean(),
2134
+ delivery: z27.string(),
2135
+ into: z27.string().optional(),
2136
+ delivered: z27.boolean().optional(),
2137
+ required: z27.boolean().optional(),
2138
+ orientation: z27.string().optional(),
2139
+ appliesOn: z27.array(z27.string()),
2123
2140
  origin: OriginSchema
2124
2141
  });
2125
- var RoleFileErrorSchema = z26.object({ kind: z26.enum(["missing", "invalid"]), message: z26.string(), line: z26.number().int().optional(), col: z26.number().int().optional() });
2126
- var RoleSummarySchema = z26.object({
2127
- id: z26.string(),
2128
- name: z26.string(),
2129
- version: z26.string().optional(),
2130
- description: z26.string().optional(),
2131
- source: z26.enum(["builtin", "user"]),
2132
- path: z26.string(),
2133
- runtime: z26.string().optional(),
2134
- importOnly: z26.boolean(),
2135
- seats: z26.number().int().min(0),
2136
- running: z26.number().int().min(0),
2137
- skills: z26.array(z26.string()),
2138
- startupFiles: z26.array(z26.string()),
2142
+ var RoleFileErrorSchema = z27.object({ kind: z27.enum(["missing", "invalid"]), message: z27.string(), line: z27.number().int().optional(), col: z27.number().int().optional() });
2143
+ var RoleSummarySchema = z27.object({
2144
+ id: z27.string(),
2145
+ name: z27.string(),
2146
+ version: z27.string().optional(),
2147
+ description: z27.string().optional(),
2148
+ source: z27.enum(["builtin", "user"]),
2149
+ path: z27.string(),
2150
+ runtime: z27.string().optional(),
2151
+ importOnly: z27.boolean(),
2152
+ seats: z27.number().int().min(0),
2153
+ running: z27.number().int().min(0),
2154
+ skills: z27.array(z27.string()),
2155
+ startupFiles: z27.array(z27.string()),
2139
2156
  /** The seats that run it, so a seat of the Rigs page opens its role « seen from » it (`openrig.role` with `id`, then the seat by `rig` + `logicalId`). */
2140
- seatRefs: z26.array(z26.object({ rig: z26.string(), logicalId: z26.string(), session: z26.string().optional() })),
2141
- error: z26.enum(["missing", "invalid"]).optional()
2142
- });
2143
- var RoleImportSchema = z26.object({
2144
- ref: z26.string(),
2145
- key: z26.string(),
2146
- name: z26.string().optional(),
2147
- path: z26.string().optional(),
2148
- version: z26.string().optional(),
2149
- resolved: z26.boolean(),
2150
- error: z26.string().optional()
2151
- });
2152
- var RoleProfileSchema = z26.object({
2153
- name: z26.string(),
2154
- description: z26.string().optional(),
2157
+ seatRefs: z27.array(z27.object({ rig: z27.string(), logicalId: z27.string(), session: z27.string().optional() })),
2158
+ error: z27.enum(["missing", "invalid"]).optional()
2159
+ });
2160
+ var RoleImportSchema = z27.object({
2161
+ ref: z27.string(),
2162
+ key: z27.string(),
2163
+ name: z27.string().optional(),
2164
+ path: z27.string().optional(),
2165
+ version: z27.string().optional(),
2166
+ resolved: z27.boolean(),
2167
+ error: z27.string().optional()
2168
+ });
2169
+ var RoleProfileSchema = z27.object({
2170
+ name: z27.string(),
2171
+ description: z27.string().optional(),
2155
2172
  runtime: SourcedStringSchema,
2156
2173
  model: SourcedStringSchema,
2157
2174
  effort: SourcedStringSchema,
2158
- uses: z26.object({ skills: RoleUsesListSchema, guidance: RoleUsesListSchema, subagents: RoleUsesListSchema, plugins: RoleUsesListSchema, runtimeResources: RoleUsesListSchema }),
2175
+ uses: z27.object({ skills: RoleUsesListSchema, guidance: RoleUsesListSchema, subagents: RoleUsesListSchema, plugins: RoleUsesListSchema, runtimeResources: RoleUsesListSchema }),
2159
2176
  /** The role's share of the startup: agent then profile files and actions, in that order. */
2160
- startup: z26.array(StartupEntrySchema)
2161
- });
2162
- var RoleSeatSchema = z26.object({
2163
- rig: z26.string(),
2164
- rigId: z26.string(),
2165
- rigSpecPath: z26.string().optional(),
2166
- composed: z26.boolean(),
2167
- logicalId: z26.string(),
2168
- session: z26.string().optional(),
2169
- label: z26.string().optional(),
2170
- profile: z26.string(),
2171
- running: z26.boolean(),
2172
- activity: z26.string(),
2177
+ startup: z27.array(StartupEntrySchema)
2178
+ });
2179
+ var RoleSeatSchema = z27.object({
2180
+ rig: z27.string(),
2181
+ rigId: z27.string(),
2182
+ rigSpecPath: z27.string().optional(),
2183
+ composed: z27.boolean(),
2184
+ logicalId: z27.string(),
2185
+ session: z27.string().optional(),
2186
+ label: z27.string().optional(),
2187
+ profile: z27.string(),
2188
+ running: z27.boolean(),
2189
+ activity: z27.string(),
2173
2190
  runtime: SourcedStringSchema,
2174
2191
  model: SourcedStringSchema,
2175
2192
  effort: SourcedStringSchema,
2176
2193
  cwd: SourcedStringSchema,
2177
2194
  cultureFile: SourcedStringSchema,
2178
- member: z26.string().optional(),
2179
- memberStartup: z26.array(StartupEntrySchema),
2195
+ member: z27.string().optional(),
2196
+ memberStartup: z27.array(StartupEntrySchema),
2180
2197
  /** The Role tab of this seat: its role guidance (`role.md`), then the startup files of its own (member layer), in delivery
2181
2198
  * order — OpenRig's when the seat was launched, else the spec's. */
2182
- roleDocs: z26.array(StartupEntrySchema),
2183
- live: z26.object({
2184
- resolvedSpec: z26.object({ name: z26.string().optional(), version: z26.string().optional(), hash: z26.string().optional() }),
2185
- resources: z26.array(RoleResourceSchema),
2199
+ roleDocs: z27.array(StartupEntrySchema),
2200
+ live: z27.object({
2201
+ resolvedSpec: z27.object({ name: z27.string().optional(), version: z27.string().optional(), hash: z27.string().optional() }),
2202
+ resources: z27.array(RoleResourceSchema),
2186
2203
  /** In the order OpenRig returns them. */
2187
- startup: z26.array(StartupEntrySchema),
2204
+ startup: z27.array(StartupEntrySchema),
2188
2205
  /** `rig skill loadout --seat`: the skills projected for this seat; absent when it could not be read. */
2189
- skills: z26.array(z26.object({ id: z26.string(), trigger: z26.string().optional() })).optional()
2206
+ skills: z27.array(z27.object({ id: z27.string(), trigger: z27.string().optional() })).optional()
2190
2207
  }).optional()
2191
2208
  });
2192
- var RoleUnavailableSchema = z26.enum(["harness_prompt", "effective_settings", "delivered_content", "harness_own_files"]);
2193
- var RoleDetailSchema = z26.object({
2209
+ var RoleUnavailableSchema = z27.enum(["harness_prompt", "effective_settings", "delivered_content", "harness_own_files"]);
2210
+ var RoleDetailSchema = z27.object({
2194
2211
  summary: RoleSummarySchema,
2195
- file: z26.object({
2196
- path: z26.string(),
2197
- relativePath: z26.string().optional(),
2198
- modifiedAt: z26.string().optional(),
2199
- copies: z26.array(z26.object({ kind: z26.literal("repo"), path: z26.string(), identical: z26.boolean(), modifiedAt: z26.string().optional() }))
2212
+ file: z27.object({
2213
+ path: z27.string(),
2214
+ relativePath: z27.string().optional(),
2215
+ modifiedAt: z27.string().optional(),
2216
+ copies: z27.array(z27.object({ kind: z27.literal("repo"), path: z27.string(), identical: z27.boolean(), modifiedAt: z27.string().optional() }))
2200
2217
  }),
2201
2218
  error: RoleFileErrorSchema.optional(),
2202
- role: z26.object({ path: z26.string(), absolutePath: z26.string(), origin: OriginSchema }).nullable(),
2203
- defaults: z26.object({ runtime: SourcedStringSchema, model: SourcedStringSchema, effort: SourcedStringSchema }),
2204
- imports: z26.array(RoleImportSchema),
2205
- importedBy: z26.array(z26.string()),
2206
- profiles: z26.array(RoleProfileSchema),
2219
+ role: z27.object({ path: z27.string(), absolutePath: z27.string(), origin: OriginSchema }).nullable(),
2220
+ defaults: z27.object({ runtime: SourcedStringSchema, model: SourcedStringSchema, effort: SourcedStringSchema }),
2221
+ imports: z27.array(RoleImportSchema),
2222
+ importedBy: z27.array(z27.string()),
2223
+ profiles: z27.array(RoleProfileSchema),
2207
2224
  /** What the file declares in `resources`. */
2208
- resources: z26.array(RoleResourceSchema),
2209
- seats: z26.array(RoleSeatSchema),
2210
- unavailable: z26.array(RoleUnavailableSchema),
2211
- warnings: z26.array(z26.string()),
2212
- openrigVersion: z26.string().optional()
2213
- });
2214
- var RoleErrorSchema = z26.string();
2215
- var LibraryIdSchema = z26.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, "not a library id");
2216
- var OpenRigRolesSchema = z26.object({ type: z26.literal("openrig.roles"), requestId: z26.string().min(1).max(100), machineId: z26.string().optional() });
2217
- var OpenRigRoleListSchema = z26.object({
2218
- type: z26.literal("openrig.roleList"),
2219
- requestId: z26.string(),
2220
- machineId: z26.string().optional(),
2221
- roles: z26.array(RoleSummarySchema),
2222
- openrigVersion: z26.string().optional(),
2225
+ resources: z27.array(RoleResourceSchema),
2226
+ seats: z27.array(RoleSeatSchema),
2227
+ unavailable: z27.array(RoleUnavailableSchema),
2228
+ warnings: z27.array(z27.string()),
2229
+ openrigVersion: z27.string().optional()
2230
+ });
2231
+ var RoleErrorSchema = z27.string();
2232
+ var LibraryIdSchema = z27.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, "not a library id");
2233
+ var OpenRigRolesSchema = z27.object({ type: z27.literal("openrig.roles"), requestId: z27.string().min(1).max(100), machineId: z27.string().optional() });
2234
+ var OpenRigRoleListSchema = z27.object({
2235
+ type: z27.literal("openrig.roleList"),
2236
+ requestId: z27.string(),
2237
+ machineId: z27.string().optional(),
2238
+ roles: z27.array(RoleSummarySchema),
2239
+ openrigVersion: z27.string().optional(),
2223
2240
  error: RoleErrorSchema.optional()
2224
2241
  });
2225
- var OpenRigRoleSchema = z26.object({ type: z26.literal("openrig.role"), requestId: z26.string().min(1).max(100), machineId: z26.string().optional(), roleId: LibraryIdSchema });
2226
- var OpenRigRoleDetailSchema = z26.object({
2227
- type: z26.literal("openrig.roleDetail"),
2228
- requestId: z26.string(),
2229
- machineId: z26.string().optional(),
2230
- roleId: z26.string(),
2242
+ var OpenRigRoleSchema = z27.object({ type: z27.literal("openrig.role"), requestId: z27.string().min(1).max(100), machineId: z27.string().optional(), roleId: LibraryIdSchema });
2243
+ var OpenRigRoleDetailSchema = z27.object({
2244
+ type: z27.literal("openrig.roleDetail"),
2245
+ requestId: z27.string(),
2246
+ machineId: z27.string().optional(),
2247
+ roleId: z27.string(),
2231
2248
  role: RoleDetailSchema.optional(),
2232
2249
  error: RoleErrorSchema.optional()
2233
2250
  });
2234
- var OpenRigRoleFileSchema = z26.object({
2235
- type: z26.literal("openrig.roleFile"),
2236
- requestId: z26.string().min(1).max(100),
2237
- machineId: z26.string().optional(),
2251
+ var OpenRigRoleFileSchema = z27.object({
2252
+ type: z27.literal("openrig.roleFile"),
2253
+ requestId: z27.string().min(1).max(100),
2254
+ machineId: z27.string().optional(),
2238
2255
  roleId: LibraryIdSchema,
2239
- path: z26.string().min(1).max(4096)
2240
- });
2241
- var OpenRigRoleFileContentSchema = z26.object({
2242
- type: z26.literal("openrig.roleFileContent"),
2243
- requestId: z26.string(),
2244
- machineId: z26.string().optional(),
2245
- roleId: z26.string(),
2246
- path: z26.string(),
2247
- content: z26.string().optional(),
2248
- size: z26.number().int().min(0).optional(),
2249
- truncated: z26.boolean().optional(),
2256
+ path: z27.string().min(1).max(4096)
2257
+ });
2258
+ var OpenRigRoleFileContentSchema = z27.object({
2259
+ type: z27.literal("openrig.roleFileContent"),
2260
+ requestId: z27.string(),
2261
+ machineId: z27.string().optional(),
2262
+ roleId: z27.string(),
2263
+ path: z27.string(),
2264
+ content: z27.string().optional(),
2265
+ size: z27.number().int().min(0).optional(),
2266
+ truncated: z27.boolean().optional(),
2250
2267
  error: RoleErrorSchema.optional()
2251
2268
  });
2252
- var OpenRigRoleDuplicateSchema = z26.object({
2253
- type: z26.literal("openrig.role.duplicate"),
2254
- requestId: z26.string().min(1).max(100),
2255
- machineId: z26.string().optional(),
2269
+ var OpenRigRoleDuplicateSchema = z27.object({
2270
+ type: z27.literal("openrig.role.duplicate"),
2271
+ requestId: z27.string().min(1).max(100),
2272
+ machineId: z27.string().optional(),
2256
2273
  roleId: LibraryIdSchema,
2257
2274
  name: RigNameSchema
2258
2275
  });
2259
- var OpenRigRoleDuplicatedSchema = z26.object({
2260
- type: z26.literal("openrig.roleDuplicated"),
2261
- requestId: z26.string(),
2262
- machineId: z26.string().optional(),
2263
- ok: z26.boolean(),
2264
- roleId: z26.string().optional(),
2265
- path: z26.string().optional(),
2276
+ var OpenRigRoleDuplicatedSchema = z27.object({
2277
+ type: z27.literal("openrig.roleDuplicated"),
2278
+ requestId: z27.string(),
2279
+ machineId: z27.string().optional(),
2280
+ ok: z27.boolean(),
2281
+ roleId: z27.string().optional(),
2282
+ path: z27.string().optional(),
2266
2283
  error: RoleErrorSchema.optional()
2267
2284
  });
2268
2285
  var ROLE_FILE_MAX = 512 * 1024;
2269
2286
 
2270
2287
  // ../../packages/protocol/src/thread.ts
2271
- import { z as z27 } from "zod";
2272
- var ToolStatusSchema = z27.enum(["running", "success", "failed", "unknown"]);
2273
- var FileChangeSchema = z27.object({ path: z27.string().min(1), from: z27.string().min(1).optional(), change: z27.enum(["add", "edit", "delete", "write"]), diff: z27.string().optional() });
2274
- var base = { id: z27.string().min(1), at: z27.string().datetime(), turn: z27.number().int().nonnegative(), helperId: z27.string().optional() };
2275
- var ThreadItemSchema = z27.discriminatedUnion("kind", [
2276
- z27.object({ kind: z27.literal("prompt"), ...base, text: z27.string(), images: z27.array(AttachmentRefSchema).optional() }),
2277
- z27.object({ kind: z27.literal("message"), ...base, text: z27.string() }),
2288
+ import { z as z28 } from "zod";
2289
+ var ToolStatusSchema = z28.enum(["running", "success", "failed", "unknown"]);
2290
+ var FileChangeSchema = z28.object({ path: z28.string().min(1), from: z28.string().min(1).optional(), change: z28.enum(["add", "edit", "delete", "write"]), diff: z28.string().optional() });
2291
+ var base = { id: z28.string().min(1), at: z28.string().datetime(), turn: z28.number().int().nonnegative(), helperId: z28.string().optional() };
2292
+ var ThreadItemSchema = z28.discriminatedUnion("kind", [
2293
+ z28.object({ kind: z28.literal("prompt"), ...base, text: z28.string(), images: z28.array(AttachmentRefSchema).optional() }),
2294
+ z28.object({ kind: z28.literal("message"), ...base, text: z28.string() }),
2278
2295
  /** `id` is the harness's tool_use_id when it gives one, so the result updates the same row; `byClose`: a question
2279
2296
  * dismissed by Ledge closing the session. */
2280
- z27.object({
2281
- kind: z27.literal("tool"),
2297
+ z28.object({
2298
+ kind: z28.literal("tool"),
2282
2299
  ...base,
2283
- tool: z27.string(),
2284
- label: z27.string(),
2285
- input: z27.string().optional(),
2286
- output: z27.string().optional(),
2287
- error: z27.string().optional(),
2300
+ tool: z28.string(),
2301
+ label: z28.string(),
2302
+ input: z28.string().optional(),
2303
+ output: z28.string().optional(),
2304
+ error: z28.string().optional(),
2288
2305
  status: ToolStatusSchema,
2289
- durationMs: z27.number().nonnegative().optional(),
2290
- files: z27.array(FileChangeSchema).default([]),
2291
- byClose: z27.literal(true).optional(),
2306
+ durationMs: z28.number().nonnegative().optional(),
2307
+ files: z28.array(FileChangeSchema).default([]),
2308
+ byClose: z28.literal(true).optional(),
2292
2309
  /** Images the tool returned (a browser screenshot), in order; `imagesDropped`: some were not kept. */
2293
- images: z27.array(AttachmentRefSchema).max(ATTACHMENTS_MAX).optional(),
2294
- imagesDropped: z27.literal(true).optional()
2310
+ images: z28.array(AttachmentRefSchema).max(ATTACHMENTS_MAX).optional(),
2311
+ imagesDropped: z28.literal(true).optional()
2295
2312
  }),
2296
2313
  /** `unknown`: answered in the terminal, the daemon only saw the prompt go away; `always`: allowed and not asked again;
2297
2314
  * `byClose`: denied by Ledge closing the session; `by`: who answered it from Ledge (the PC or a device, its name then). */
2298
- z27.object({ kind: z27.literal("permission"), ...base, tool: z27.string(), text: z27.string(), decision: z27.enum(["accept", "deny", "always", "unknown"]).optional(), byClose: z27.literal(true).optional(), by: DecidedBySchema.optional() }),
2299
- z27.object({ kind: z27.literal("reply"), ...base, text: z27.string() }),
2300
- z27.object({ kind: z27.literal("helper"), ...base, task: z27.string(), agentType: z27.string().optional(), state: z27.enum(["working", "exited"]) }),
2315
+ z28.object({ kind: z28.literal("permission"), ...base, tool: z28.string(), text: z28.string(), decision: z28.enum(["accept", "deny", "always", "unknown"]).optional(), byClose: z28.literal(true).optional(), by: DecidedBySchema.optional() }),
2316
+ z28.object({ kind: z28.literal("reply"), ...base, text: z28.string() }),
2317
+ z28.object({ kind: z28.literal("helper"), ...base, task: z28.string(), agentType: z28.string().optional(), state: z28.enum(["working", "exited"]) }),
2301
2318
  /** A message this session sent to another agent; `id` is the tool_use_id, `to` the address it used, `peer` the Ledge session id, `received` the paired item's id in the peer's thread, `via` set when Ledge's mailbox carries it. */
2302
- z27.object({
2303
- kind: z27.literal("sent"),
2319
+ z28.object({
2320
+ kind: z28.literal("sent"),
2304
2321
  ...base,
2305
- to: z27.string(),
2306
- peer: z27.string().optional(),
2307
- summary: z27.string().optional(),
2308
- text: z27.string(),
2309
- status: z27.enum(["sending", "delivered", "read", "failed"]),
2310
- received: z27.string().optional(),
2311
- via: z27.literal("ledge").optional(),
2322
+ to: z28.string(),
2323
+ peer: z28.string().optional(),
2324
+ summary: z28.string().optional(),
2325
+ text: z28.string(),
2326
+ status: z28.enum(["sending", "delivered", "read", "failed"]),
2327
+ received: z28.string().optional(),
2328
+ via: z28.literal("ledge").optional(),
2312
2329
  /** The seat's own `rig send` (its Bash call), docs/mockups/ledge-openrig-messages.html: `rig.command` is what it ran. */
2313
2330
  rig: RigInfoSchema.optional()
2314
2331
  }),
2315
2332
  /** A message another agent sent to this session; `from` is its from-name (else its address), `sent` the paired item's id in the peer's thread. */
2316
- z27.object({
2317
- kind: z27.literal("received"),
2333
+ z28.object({
2334
+ kind: z28.literal("received"),
2318
2335
  ...base,
2319
- from: z27.string(),
2320
- peer: z27.string().optional(),
2321
- text: z27.string(),
2322
- sent: z27.string().optional(),
2336
+ from: z28.string(),
2337
+ peer: z28.string().optional(),
2338
+ text: z28.string(),
2339
+ sent: z28.string().optional(),
2323
2340
  /** An OpenRig `rig send` typed into this seat (`rig.kind` `message`): `from` is the envelope's sender, `text` its body. */
2324
2341
  rig: RigInfoSchema.optional()
2325
2342
  }),
2326
2343
  /** An automated notice of the agent's harness about messages between sessions (Claude Code's `[Cross-session idle
2327
2344
  * notice]` / `[Cross-session delivery notice]`): a system event, never the user's words. `name` is the session it is
2328
2345
  * about as quoted, `peer` its Ledge session id; a delivery notice says the outcome of `count` messages to `recipients`. */
2329
- z27.object({
2330
- kind: z27.literal("notice"),
2346
+ z28.object({
2347
+ kind: z28.literal("notice"),
2331
2348
  ...base,
2332
- notice: z27.enum(["idle", "exited", "unavailable", "expired", "delivery", "other"]),
2349
+ notice: z28.enum(["idle", "exited", "unavailable", "expired", "delivery", "other"]),
2333
2350
  /** An `other` notice from Ledge: `task`, the task a `<ledge-task>` is about. An older front, which does not know it, shows it as any other notice. */
2334
- task: z27.string().optional(),
2351
+ task: z28.string().optional(),
2335
2352
  /** A task this session handed over (`outgoing`), and how (issue #92). */
2336
- taskOp: z27.enum(TRANSMISSION_OPS).optional(),
2337
- outgoing: z27.literal(true).optional(),
2338
- name: z27.string().optional(),
2339
- peer: z27.string().optional(),
2340
- time: z27.string().optional(),
2341
- summary: z27.string().optional(),
2342
- status: z27.enum(["held", "denied", "expired", "delivered", "refused", "dropped", "unknown"]).optional(),
2343
- count: z27.number().int().positive().optional(),
2344
- recipients: z27.array(z27.string()).optional(),
2345
- reason: z27.string().optional(),
2346
- text: z27.string(),
2353
+ taskOp: z28.enum(TRANSMISSION_OPS).optional(),
2354
+ outgoing: z28.literal(true).optional(),
2355
+ name: z28.string().optional(),
2356
+ peer: z28.string().optional(),
2357
+ time: z28.string().optional(),
2358
+ summary: z28.string().optional(),
2359
+ status: z28.enum(["held", "denied", "expired", "delivered", "refused", "dropped", "unknown"]).optional(),
2360
+ count: z28.number().int().positive().optional(),
2361
+ recipients: z28.array(z28.string()).optional(),
2362
+ reason: z28.string().optional(),
2363
+ text: z28.string(),
2347
2364
  /** An OpenRig block that is not a message: a row handed to this seat or passed by it (`handoff`, `outgoing` for its own),
2348
2365
  * a row unblocked, OpenRig's own notice, or an unreadable block; `text` is the body (unreadable: the block as is). */
2349
2366
  rig: RigInfoSchema.optional(),
2350
2367
  /** The moment the session was brought into Ledge (« Rattacher à Ledge », spec 2026-12-01 rattacher): driven in its tmux pane, or
2351
2368
  * resumed on the same conversation. A front that knows it says it in its own words; an older one shows `text`. */
2352
- adopted: z27.enum(["pane", "resume"]).optional()
2369
+ adopted: z28.enum(["pane", "resume"]).optional()
2353
2370
  })
2354
2371
  ]);
2355
2372
 
2356
2373
  // ../../packages/protocol/src/mobile.ts
2357
- import { z as z28 } from "zod";
2358
- var RelayUrlSchema = z28.string().transform((v, ctx) => {
2374
+ import { z as z29 } from "zod";
2375
+ var RelayUrlSchema = z29.string().transform((v, ctx) => {
2359
2376
  const bad = () => {
2360
- ctx.addIssue({ code: z28.ZodIssueCode.custom, message: "invalid relay URL" });
2361
- return z28.NEVER;
2377
+ ctx.addIssue({ code: z29.ZodIssueCode.custom, message: "invalid relay URL" });
2378
+ return z29.NEVER;
2362
2379
  };
2363
2380
  let u;
2364
2381
  try {
@@ -2371,168 +2388,168 @@ var RelayUrlSchema = z28.string().transform((v, ctx) => {
2371
2388
  if (u.username || u.password || u.pathname !== "/" || u.search || u.hash) return bad();
2372
2389
  return u.origin;
2373
2390
  });
2374
- var MobileConfigSchema = z28.object({ enabled: z28.boolean(), relayUrl: RelayUrlSchema, terminalInput: z28.boolean().optional() });
2375
- var MobileLinkStateSchema = z28.discriminatedUnion("state", [
2376
- z28.object({ state: z28.literal("off") }),
2377
- z28.object({ state: z28.literal("connecting") }),
2378
- z28.object({ state: z28.literal("online") }),
2379
- z28.object({ state: z28.literal("offline"), retryAt: z28.string().datetime(), error: z28.string() }),
2380
- z28.object({ state: z28.literal("signed_out"), reason: z28.enum(["other_pc", "session_invalid"]) }),
2391
+ var MobileConfigSchema = z29.object({ enabled: z29.boolean(), relayUrl: RelayUrlSchema, terminalInput: z29.boolean().optional() });
2392
+ var MobileLinkStateSchema = z29.discriminatedUnion("state", [
2393
+ z29.object({ state: z29.literal("off") }),
2394
+ z29.object({ state: z29.literal("connecting") }),
2395
+ z29.object({ state: z29.literal("online") }),
2396
+ z29.object({ state: z29.literal("offline"), retryAt: z29.string().datetime(), error: z29.string() }),
2397
+ z29.object({ state: z29.literal("signed_out"), reason: z29.enum(["other_pc", "session_invalid"]) }),
2381
2398
  /** The mobile service did not start (a broken mobile.json, a missing key store): nothing is linked until the daemon restarts. */
2382
- z28.object({ state: z28.literal("unavailable"), error: z28.string().max(200) })
2399
+ z29.object({ state: z29.literal("unavailable"), error: z29.string().max(200) })
2383
2400
  ]);
2384
- var DeviceKindSchema = z28.enum(["phone", "tablet"]);
2401
+ var DeviceKindSchema = z29.enum(["phone", "tablet"]);
2385
2402
  var DEVICE_NAME_MAX = 40;
2386
- var DeviceNameSchema = z28.string().trim().min(1).max(DEVICE_NAME_MAX).regex(/^[^\u0000-\u001f\u007f]+$/);
2387
- var MobilePairingSchema = z28.object({
2388
- id: z28.string(),
2389
- label: z28.string(),
2390
- code: z28.string().nullable(),
2391
- expiresAt: z28.string().datetime(),
2392
- state: z28.enum(["waiting", "confirm", "approved", "linked", "expired", "refused"])
2393
- });
2394
- var RecoveredSchema = z28.object({ at: z28.string().datetime(), model: z28.string().max(40).optional(), pending: z28.literal(true).optional() });
2395
- var MobileStateSchema = z28.object({
2396
- enabled: z28.boolean(),
2397
- relayUrl: z28.string(),
2398
- account: z28.object({ login: z28.string(), accountId: z28.string() }).nullable(),
2399
- signin: z28.object({ userCode: z28.string(), verificationUri: z28.string(), expiresAt: z28.string().datetime() }).nullable(),
2403
+ var DeviceNameSchema = z29.string().trim().min(1).max(DEVICE_NAME_MAX).regex(/^[^\u0000-\u001f\u007f]+$/);
2404
+ var MobilePairingSchema = z29.object({
2405
+ id: z29.string(),
2406
+ label: z29.string(),
2407
+ code: z29.string().nullable(),
2408
+ expiresAt: z29.string().datetime(),
2409
+ state: z29.enum(["waiting", "confirm", "approved", "linked", "expired", "refused"])
2410
+ });
2411
+ var RecoveredSchema = z29.object({ at: z29.string().datetime(), model: z29.string().max(40).optional(), pending: z29.literal(true).optional() });
2412
+ var MobileStateSchema = z29.object({
2413
+ enabled: z29.boolean(),
2414
+ relayUrl: z29.string(),
2415
+ account: z29.object({ login: z29.string(), accountId: z29.string() }).nullable(),
2416
+ signin: z29.object({ userCode: z29.string(), verificationUri: z29.string(), expiresAt: z29.string().datetime() }).nullable(),
2400
2417
  /** The last sign-in that did not end with a session; cleared by the next one. */
2401
- signinError: z28.enum(["expired", "denied", "not_allowed", "failed"]).nullable(),
2418
+ signinError: z29.enum(["expired", "denied", "not_allowed", "failed"]).nullable(),
2402
2419
  link: MobileLinkStateSchema,
2403
- devices: z28.array(z28.object({
2404
- id: z28.string(),
2405
- label: z28.string(),
2406
- approvedAt: z28.string(),
2407
- online: z28.boolean(),
2408
- lastSeenAt: z28.string().optional(),
2420
+ devices: z29.array(z29.object({
2421
+ id: z29.string(),
2422
+ label: z29.string(),
2423
+ approvedAt: z29.string(),
2424
+ online: z29.boolean(),
2425
+ lastSeenAt: z29.string().optional(),
2409
2426
  /** Absent from an older daemon; `name` absent: the user gave none, the front derives one from the label. */
2410
2427
  kind: DeviceKindSchema.optional(),
2411
- name: z28.string().optional(),
2428
+ name: z29.string().optional(),
2412
2429
  /** Its passkey can bring it back after a reinstall (registered with the PC key's digest, docs/mobile-passkey-recover-contract.md). */
2413
- recover: z28.literal(true).optional(),
2430
+ recover: z29.literal(true).optional(),
2414
2431
  /** It came back with its passkey: when, on what it says it runs (`iPhone`, `iPad`), and `pending` until « C'était bien moi »
2415
2432
  * (`mobile.device.ack` `recovered`). Kept after that, for the « reconnecté avec sa passkey le … » line. */
2416
2433
  recovered: RecoveredSchema.optional(),
2417
2434
  /** Another device tried to take its place with its passkey while it was connected; until « Compris » (`mobile.device.ack` `refused`). */
2418
- refused: z28.object({ at: z28.string().datetime(), model: z28.string().optional() }).optional()
2435
+ refused: z29.object({ at: z29.string().datetime(), model: z29.string().optional() }).optional()
2419
2436
  })),
2420
- pairings: z28.array(MobilePairingSchema),
2437
+ pairings: z29.array(MobilePairingSchema),
2421
2438
  /** « Taper dans les terminaux depuis le téléphone »: absent from an older daemon, which has no phone terminal. */
2422
- terminalInput: z28.boolean().optional(),
2439
+ terminalInput: z29.boolean().optional(),
2423
2440
  /** Passkey recovery on the account: `blocked` after 3 failed verifications, until « Débloquer » (`mobile.recovery.unblock`). */
2424
- recovery: z28.object({ blocked: z28.object({ since: z28.string().datetime(), failures: z28.number().int().min(0) }).optional() }).optional()
2441
+ recovery: z29.object({ blocked: z29.object({ since: z29.string().datetime(), failures: z29.number().int().min(0) }).optional() }).optional()
2425
2442
  });
2426
- var MobileRecoveryEventSchema = z28.object({
2427
- event: z28.enum(["recovered", "refused", "blocked"]),
2428
- id: z28.string().optional(),
2429
- at: z28.string().datetime()
2443
+ var MobileRecoveryEventSchema = z29.object({
2444
+ event: z29.enum(["recovered", "refused", "blocked"]),
2445
+ id: z29.string().optional(),
2446
+ at: z29.string().datetime()
2430
2447
  });
2431
2448
 
2432
2449
  // ../../packages/protocol/src/brain.ts
2433
- import { z as z29 } from "zod";
2434
- var NoteInfoSchema = z29.object({
2435
- name: z29.string(),
2436
- file: z29.string(),
2437
- title: z29.string(),
2438
- when: z29.string().optional(),
2439
- firstLine: z29.string(),
2440
- scope: z29.enum(["all", "chat", "sessions"]),
2441
- projects: z29.array(z29.string()),
2442
- modifiedAt: z29.string(),
2443
- checkedAt: z29.string().optional(),
2450
+ import { z as z30 } from "zod";
2451
+ var NoteInfoSchema = z30.object({
2452
+ name: z30.string(),
2453
+ file: z30.string(),
2454
+ title: z30.string(),
2455
+ when: z30.string().optional(),
2456
+ firstLine: z30.string(),
2457
+ scope: z30.enum(["all", "chat", "sessions"]),
2458
+ projects: z30.array(z30.string()),
2459
+ modifiedAt: z30.string(),
2460
+ checkedAt: z30.string().optional(),
2444
2461
  /** Days since it was last checked or changed, past the threshold (spec §3.7). */
2445
- oldDays: z29.number().int().optional(),
2446
- flag: z29.object({ what: z29.string(), by: z29.string(), at: z29.string() }).optional(),
2462
+ oldDays: z30.number().int().optional(),
2463
+ flag: z30.object({ what: z30.string(), by: z30.string(), at: z30.string() }).optional(),
2447
2464
  /** Lines under « ## Ajouts ». */
2448
- additions: z29.number().int(),
2449
- truncated: z29.boolean()
2450
- });
2451
- var BrainAnswerSchema = z29.object({ type: z29.literal("brain.answer"), rid: z29.string().min(1).max(100), task: z29.string().min(1).max(40), choice: BrainChoiceSchema });
2452
- var BrainListSchema = z29.object({ type: z29.literal("brain.list"), rid: z29.string().min(1).max(100) });
2453
- var BrainNoteSchema = z29.object({ type: z29.literal("brain.note"), rid: z29.string().min(1).max(100), note: NoteNameSchema, op: z29.enum(["checked", "unflag"]) });
2454
- var BrainAddSchema = z29.object({
2455
- type: z29.literal("brain.add"),
2456
- rid: z29.string().min(1).max(100),
2465
+ additions: z30.number().int(),
2466
+ truncated: z30.boolean()
2467
+ });
2468
+ var BrainAnswerSchema = z30.object({ type: z30.literal("brain.answer"), rid: z30.string().min(1).max(100), task: z30.string().min(1).max(40), choice: BrainChoiceSchema });
2469
+ var BrainListSchema = z30.object({ type: z30.literal("brain.list"), rid: z30.string().min(1).max(100) });
2470
+ var BrainNoteSchema = z30.object({ type: z30.literal("brain.note"), rid: z30.string().min(1).max(100), note: NoteNameSchema, op: z30.enum(["checked", "unflag"]) });
2471
+ var BrainAddSchema = z30.object({
2472
+ type: z30.literal("brain.add"),
2473
+ rid: z30.string().min(1).max(100),
2457
2474
  note: NoteNameSchema,
2458
- fact: z29.string().trim().min(1).max(BRAIN_FACT_MAX),
2459
- source: z29.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional()
2475
+ fact: z30.string().trim().min(1).max(BRAIN_FACT_MAX),
2476
+ source: z30.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional()
2460
2477
  });
2461
- var BrainResultSchema = z29.object({
2462
- type: z29.literal("brain.result"),
2463
- rid: z29.string(),
2464
- reason: z29.string().optional(),
2478
+ var BrainResultSchema = z30.object({
2479
+ type: z30.literal("brain.result"),
2480
+ rid: z30.string(),
2481
+ reason: z30.string().optional(),
2465
2482
  /** What came of an answer (the text its proposer is told). */
2466
- result: z29.string().optional(),
2467
- dir: z29.string().optional(),
2468
- notes: z29.array(NoteInfoSchema).optional()
2483
+ result: z30.string().optional(),
2484
+ dir: z30.string().optional(),
2485
+ notes: z30.array(NoteInfoSchema).optional()
2469
2486
  });
2470
2487
 
2471
2488
  // ../../packages/protocol/src/usage.ts
2472
- import { z as z30 } from "zod";
2473
- var UsageHarnessSchema = z30.enum(["claude", "codex", "cursor"]);
2489
+ import { z as z31 } from "zod";
2490
+ var UsageHarnessSchema = z31.enum(["claude", "codex", "cursor"]);
2474
2491
  var USAGE_WINDOW_KINDS = ["five_hour", "seven_day", "model", "month", "pool"];
2475
2492
  var POOLS = ["cursor", "other"];
2476
2493
  var poolMatchesKind = (w) => w.kind === "pool" === (w.pool !== void 0) && (w.pool === void 0 || POOLS.includes(w.pool));
2477
- var UsageWindowSchema = z30.object({
2478
- kind: z30.enum(USAGE_WINDOW_KINDS),
2479
- model: z30.string().min(1).max(80).optional(),
2494
+ var UsageWindowSchema = z31.object({
2495
+ kind: z31.enum(USAGE_WINDOW_KINDS),
2496
+ model: z31.string().min(1).max(80).optional(),
2480
2497
  /** A pool of the included usage (`kind: 'pool'`): Cursor's own models (`cursor`) or the others at API prices (`other`). */
2481
- pool: z30.enum(POOLS).optional(),
2498
+ pool: z31.enum(POOLS).optional(),
2482
2499
  /** How much of it is used, in percent (rounded); 100 or more: reached. */
2483
- pct: z30.number().int().min(0).max(1e3),
2500
+ pct: z31.number().int().min(0).max(1e3),
2484
2501
  /** When it starts again from zero; null when the harness does not say. */
2485
- resetsAt: z30.string().datetime().nullable()
2502
+ resetsAt: z31.string().datetime().nullable()
2486
2503
  }).refine(poolMatchesKind, { message: "a pool window names its pool, and only a pool window does", path: ["pool"] });
2487
- var UsageStatusSchema = z30.enum(["ok", "loading", "stale", "unreachable", "expired"]);
2504
+ var UsageStatusSchema = z31.enum(["ok", "loading", "stale", "unreachable", "expired"]);
2488
2505
  var USAGE_ALERT_MIN = 0.5;
2489
2506
  var USAGE_ALERT_MAX = 0.95;
2490
- var UsagePrefsSchema = z30.object({ alert: z30.number().min(USAGE_ALERT_MIN).max(USAGE_ALERT_MAX) });
2491
- var HarnessUsageSchema = z30.object({
2507
+ var UsagePrefsSchema = z31.object({ alert: z31.number().min(USAGE_ALERT_MIN).max(USAGE_ALERT_MAX) });
2508
+ var HarnessUsageSchema = z31.object({
2492
2509
  harness: UsageHarnessSchema,
2493
- account: z30.string().regex(/^[0-9a-f]{12}$/).nullable(),
2510
+ account: z31.string().regex(/^[0-9a-f]{12}$/).nullable(),
2494
2511
  status: UsageStatusSchema,
2495
2512
  /** The last read that succeeded; null when none did. */
2496
- readAt: z30.string().datetime().nullable(),
2513
+ readAt: z31.string().datetime().nullable(),
2497
2514
  /** The 5 hours and the week first, then one window per model. Empty while loading, expired, or read more than an hour ago. */
2498
- windows: z30.array(UsageWindowSchema).max(20),
2515
+ windows: z31.array(UsageWindowSchema).max(20),
2499
2516
  /**
2500
2517
  * Why the account cannot be read now (#301), absent when it can. `local_expired`: the token on this machine is past its time, which
2501
2518
  * the harness renews itself at its next use (Claude Code's access token is short): still signed in, so the last values are kept
2502
2519
  * as `stale` while under an hour old, then the harness is no longer listed. `refused`: the provider refused the token (401):
2503
2520
  * status `expired`, no window. A refusal wins over a local expiry.
2504
2521
  */
2505
- cause: z30.enum(["local_expired", "refused"]).optional()
2522
+ cause: z31.enum(["local_expired", "refused"]).optional()
2506
2523
  });
2507
- var UsageAlertSchema = z30.object({
2508
- id: z30.string().min(1).max(200),
2524
+ var UsageAlertSchema = z31.object({
2525
+ id: z31.string().min(1).max(200),
2509
2526
  harness: UsageHarnessSchema,
2510
- account: z30.string().regex(/^[0-9a-f]{12}$/).nullable(),
2527
+ account: z31.string().regex(/^[0-9a-f]{12}$/).nullable(),
2511
2528
  window: UsageWindowSchema,
2512
- level: z30.enum(["threshold", "full"]),
2513
- at: z30.string().datetime()
2529
+ level: z31.enum(["threshold", "full"]),
2530
+ at: z31.string().datetime()
2514
2531
  });
2515
2532
  var isRecord = (v) => typeof v === "object" && v !== null;
2516
2533
  var knownHarness = (h) => UsageHarnessSchema.safeParse(h).success;
2517
2534
  var knownKind = (k) => USAGE_WINDOW_KINDS.includes(k);
2518
2535
  var dropUnknownHarnesses = (raw) => Array.isArray(raw) ? raw.filter((h) => isRecord(h) && knownHarness(h.harness)).map((h) => Array.isArray(h.windows) ? { ...h, windows: h.windows.filter((w) => !isRecord(w) || knownKind(w.kind) && poolMatchesKind(w)) } : h) : raw;
2519
2536
  var dropUnknownAlerts = (raw) => Array.isArray(raw) ? raw.filter((a) => isRecord(a) && knownHarness(a.harness) && (!isRecord(a.window) || knownKind(a.window.kind) && poolMatchesKind(a.window))) : raw;
2520
- var UsageStateMessageSchema = z30.object({
2521
- type: z30.literal("usage.state"),
2522
- machineId: z30.string().optional(),
2523
- harnesses: z30.preprocess(dropUnknownHarnesses, z30.array(HarnessUsageSchema).max(4)),
2524
- alerts: z30.preprocess(dropUnknownAlerts, z30.array(UsageAlertSchema).max(40)),
2537
+ var UsageStateMessageSchema = z31.object({
2538
+ type: z31.literal("usage.state"),
2539
+ machineId: z31.string().optional(),
2540
+ harnesses: z31.preprocess(dropUnknownHarnesses, z31.array(HarnessUsageSchema).max(4)),
2541
+ alerts: z31.preprocess(dropUnknownAlerts, z31.array(UsageAlertSchema).max(40)),
2525
2542
  prefs: UsagePrefsSchema
2526
2543
  });
2527
- var UsageSetSchema = z30.object({ type: z30.literal("usage.set"), prefs: UsagePrefsSchema, machineId: z30.string().optional() });
2528
- var UsageAckSchema = z30.object({ type: z30.literal("usage.ack"), id: z30.string().min(1).max(200), machineId: z30.string().optional() });
2544
+ var UsageSetSchema = z31.object({ type: z31.literal("usage.set"), prefs: UsagePrefsSchema, machineId: z31.string().optional() });
2545
+ var UsageAckSchema = z31.object({ type: z31.literal("usage.ack"), id: z31.string().min(1).max(200), machineId: z31.string().optional() });
2529
2546
 
2530
2547
  // ../../packages/protocol/src/forge.ts
2531
- import { z as z32 } from "zod";
2548
+ import { z as z33 } from "zod";
2532
2549
 
2533
2550
  // ../../packages/protocol/src/refusal.ts
2534
- import { z as z31 } from "zod";
2535
- var RefusalCodeSchema = z31.enum([
2551
+ import { z as z32 } from "zod";
2552
+ var RefusalCodeSchema = z32.enum([
2536
2553
  "stale",
2537
2554
  "read_only",
2538
2555
  "no_prompt",
@@ -2556,268 +2573,269 @@ var RefusalCodeSchema = z31.enum([
2556
2573
 
2557
2574
  // ../../packages/protocol/src/forge.ts
2558
2575
  var FORGE_KINDS = ["github", "gitlab"];
2559
- var ForgeKindSchema = z32.enum(FORGE_KINDS);
2576
+ var ForgeKindSchema = z33.enum(FORGE_KINDS);
2560
2577
  var PIPE_STATUSES = ["ok", "run", "fail", "wait", "skip", "none"];
2561
- var PipeStatusSchema = z32.enum(PIPE_STATUSES);
2578
+ var PipeStatusSchema = z33.enum(PIPE_STATUSES);
2562
2579
  var PR_STATES = ["draft", "open", "review", "merged", "closed"];
2563
- var PrStateSchema = z32.enum(PR_STATES);
2580
+ var PrStateSchema = z33.enum(PR_STATES);
2564
2581
  var PR_ROLES = ["author", "assignee", "reviewer"];
2565
- var PrRoleSchema = z32.enum(PR_ROLES);
2582
+ var PrRoleSchema = z33.enum(PR_ROLES);
2566
2583
  var dropUnknownRoles = (raw) => Array.isArray(raw) ? raw.filter((r) => known(PR_ROLES, r)) : raw;
2567
2584
  var FORGE_BODY_MAX = 65536;
2568
- var PullRequestSchema = z32.object({
2585
+ var PullRequestSchema = z33.object({
2569
2586
  /** `${host}/${repo}#${number}`, stable. */
2570
- id: z32.string().min(1),
2587
+ id: z33.string().min(1),
2571
2588
  forge: ForgeKindSchema,
2572
- host: z32.string().min(1),
2589
+ host: z33.string().min(1),
2573
2590
  /** The repository's path: `owner/name`, or `group/sub/project`. */
2574
- repo: z32.string().min(1),
2575
- number: z32.number().int().positive(),
2591
+ repo: z33.string().min(1),
2592
+ number: z33.number().int().positive(),
2576
2593
  /** As the forge shows it: `#226` (GitHub) or `!41` (GitLab). */
2577
- ref: z32.string(),
2594
+ ref: z33.string(),
2578
2595
  /** « Ouvrir sur GitHub / GitLab »: the front opens it itself (R11). */
2579
- url: z32.string().url(),
2580
- title: z32.string(),
2596
+ url: z33.string().url(),
2597
+ title: z33.string(),
2581
2598
  state: PrStateSchema,
2582
2599
  /** The source branch, and the branch it goes into. */
2583
- branch: z32.string(),
2584
- target: z32.string(),
2585
- headSha: z32.string(),
2600
+ branch: z33.string(),
2601
+ target: z33.string(),
2602
+ headSha: z33.string(),
2586
2603
  pipeline: PipeStatusSchema,
2587
2604
  /** `required` when the forge gives it (GitLab); GitHub leaves it out. */
2588
- approvals: z32.object({ given: z32.number().int().min(0), required: z32.number().int().min(0).optional() }),
2605
+ approvals: z33.object({ given: z33.number().int().min(0), required: z33.number().int().min(0).optional() }),
2589
2606
  /** The mockup's `ok`: all that a merge needs (R5), the pipeline set apart. */
2590
- mergeable: z32.boolean(),
2607
+ mergeable: z33.boolean(),
2591
2608
  /** Threads that can be resolved and are not. */
2592
- openThreads: z32.number().int().min(0),
2593
- updatedAt: z32.string().datetime(),
2609
+ openThreads: z33.number().int().min(0),
2610
+ updatedAt: z33.string().datetime(),
2594
2611
  /** The daemon's sessions on that branch, most recently active first (R12); the fleet qualifies them `machine:id`. */
2595
- sessions: z32.array(z32.string()),
2612
+ sessions: z33.array(z33.string()),
2596
2613
  /**
2597
2614
  * The account's roles on the request (issue #3), in the order author, assignee, reviewer; absent when it has none, and from a daemon
2598
2615
  * older than this field.
2599
2616
  */
2600
- roles: z32.preprocess(dropUnknownRoles, z32.array(PrRoleSchema)).optional()
2617
+ roles: z33.preprocess(dropUnknownRoles, z33.array(PrRoleSchema)).optional()
2601
2618
  });
2602
- var FollowedSessionSchema = z32.object({ session: z32.string(), forge: ForgeKindSchema, host: z32.string(), repo: z32.string() });
2603
- var ForgeStatusSchema = z32.object({
2619
+ var FollowedSessionSchema = z33.object({ session: z33.string(), forge: ForgeKindSchema, host: z33.string(), repo: z33.string() });
2620
+ var ForgeStatusSchema = z33.object({
2604
2621
  forge: ForgeKindSchema,
2605
- host: z32.string(),
2606
- status: z32.enum(["ok", "missing", "unauthenticated", "error"]),
2607
- message: z32.string().optional(),
2608
- at: z32.string().datetime(),
2622
+ host: z33.string(),
2623
+ status: z33.enum(["ok", "missing", "unauthenticated", "error"]),
2624
+ message: z33.string().optional(),
2625
+ at: z33.string().datetime(),
2609
2626
  /** Not `ok`: since when the forge cannot be read, whatever its messages since (« le relevé échoue depuis 10:42 »). */
2610
- since: z32.string().datetime().optional(),
2627
+ since: z33.string().datetime().optional(),
2611
2628
  /** After a failed read (`error` mostly): when the daemon reads it again, its backoff of 2 to 10 minutes (« Nouvel essai à 10:50 »). */
2612
- retryAt: z32.string().datetime().optional(),
2629
+ retryAt: z33.string().datetime().optional(),
2613
2630
  /** Not `ok`: when its requests, still shown, were last read; absent when they never were. */
2614
- readAt: z32.string().datetime().optional()
2631
+ readAt: z33.string().datetime().optional()
2615
2632
  });
2616
2633
  var isRecord2 = (v) => typeof v === "object" && v !== null;
2617
2634
  var known = (list, v) => typeof v === "string" && list.includes(v);
2618
2635
  var dropUnknownPrs = (raw) => Array.isArray(raw) ? raw.filter((p) => isRecord2(p) && known(FORGE_KINDS, p.forge) && known(PR_STATES, p.state) && known(PIPE_STATUSES, p.pipeline)) : raw;
2619
2636
  var dropUnknownForges = (raw) => Array.isArray(raw) ? raw.filter((f) => isRecord2(f) && known(FORGE_KINDS, f.forge)) : raw;
2620
- var ForgeStateMessageSchema = z32.object({
2621
- type: z32.literal("forge.state"),
2622
- prs: z32.preprocess(dropUnknownPrs, z32.array(PullRequestSchema)),
2623
- forges: z32.preprocess(dropUnknownForges, z32.array(ForgeStatusSchema)),
2637
+ var ForgeStateMessageSchema = z33.object({
2638
+ type: z33.literal("forge.state"),
2639
+ prs: z33.preprocess(dropUnknownPrs, z33.array(PullRequestSchema)),
2640
+ forges: z33.preprocess(dropUnknownForges, z33.array(ForgeStatusSchema)),
2624
2641
  /** Absent from a daemon older than this field. */
2625
- followed: z32.preprocess(dropUnknownForges, z32.array(FollowedSessionSchema)).optional(),
2642
+ followed: z33.preprocess(dropUnknownForges, z33.array(FollowedSessionSchema)).optional(),
2626
2643
  /**
2627
2644
  * The account's own requests no session follows (issue #3): `sessions` empty, `roles` set. A request is in `prs` or here, never in
2628
2645
  * both; a followed one carries its `roles` in `prs`. Absent from a daemon older than this field.
2629
2646
  */
2630
- mine: z32.preprocess(dropUnknownPrs, z32.array(PullRequestSchema)).optional(),
2631
- machineId: z32.string().optional()
2632
- });
2633
- var PrJobSchema = z32.object({
2634
- id: z32.string(),
2635
- name: z32.string(),
2636
- column: z32.number().int().min(0),
2637
- columnName: z32.string(),
2638
- status: z32.preprocess((s) => known(PIPE_STATUSES, s) ? s : "none", PipeStatusSchema),
2639
- durationS: z32.number().min(0).optional()
2640
- });
2641
- var PrCommentSchema = z32.object({ id: z32.string(), author: z32.string(), at: z32.string().datetime(), body: z32.string() });
2642
- var PrThreadSchema = z32.object({
2643
- id: z32.string(),
2644
- resolvable: z32.boolean(),
2645
- resolved: z32.boolean(),
2646
- file: z32.string().optional(),
2647
- line: z32.number().int().optional(),
2648
- code: z32.string().optional(),
2649
- comments: z32.array(PrCommentSchema).min(1)
2650
- });
2651
- var PrFileSchema = z32.object({ path: z32.string(), added: z32.number().int().min(0), removed: z32.number().int().min(0), patch: z32.string().optional() });
2652
- var PrReviewerSchema = z32.object({ name: z32.string(), state: z32.enum(["approved", "changes", "pending"]) });
2653
- var PrCommitSchema = z32.object({ sha: z32.string(), title: z32.string(), author: z32.string(), at: z32.string().datetime() });
2654
- var PrDetailSchema = z32.object({
2647
+ mine: z33.preprocess(dropUnknownPrs, z33.array(PullRequestSchema)).optional(),
2648
+ machineId: z33.string().optional()
2649
+ });
2650
+ var PrJobSchema = z33.object({
2651
+ id: z33.string(),
2652
+ name: z33.string(),
2653
+ column: z33.number().int().min(0),
2654
+ columnName: z33.string(),
2655
+ status: z33.preprocess((s) => known(PIPE_STATUSES, s) ? s : "none", PipeStatusSchema),
2656
+ durationS: z33.number().min(0).optional()
2657
+ });
2658
+ var PrCommentSchema = z33.object({ id: z33.string(), author: z33.string(), at: z33.string().datetime(), body: z33.string() });
2659
+ var PrThreadSchema = z33.object({
2660
+ id: z33.string(),
2661
+ resolvable: z33.boolean(),
2662
+ resolved: z33.boolean(),
2663
+ file: z33.string().optional(),
2664
+ line: z33.number().int().optional(),
2665
+ code: z33.string().optional(),
2666
+ comments: z33.array(PrCommentSchema).min(1)
2667
+ });
2668
+ var PrFileSchema = z33.object({ path: z33.string(), added: z33.number().int().min(0), removed: z33.number().int().min(0), patch: z33.string().optional() });
2669
+ var PrReviewerSchema = z33.object({ name: z33.string(), state: z33.enum(["approved", "changes", "pending"]) });
2670
+ var PrCommitSchema = z33.object({ sha: z33.string(), title: z33.string(), author: z33.string(), at: z33.string().datetime() });
2671
+ var PrDetailSchema = z33.object({
2655
2672
  pr: PullRequestSchema,
2656
- description: z32.string(),
2657
- author: z32.string(),
2658
- reviewers: z32.array(PrReviewerSchema),
2659
- labels: z32.array(z32.string()),
2673
+ description: z33.string(),
2674
+ author: z33.string(),
2675
+ reviewers: z33.array(PrReviewerSchema),
2676
+ labels: z33.array(z33.string()),
2660
2677
  /** The tickets it closes, as the forge shows them (`#38`). */
2661
- issues: z32.array(z32.string()),
2662
- jobs: z32.array(PrJobSchema),
2678
+ issues: z33.array(z33.string()),
2679
+ jobs: z33.array(PrJobSchema),
2663
2680
  /** A job's log when asked (`forge.detail` with `log`): its last 60 lines, no ANSI, redacted. */
2664
- log: z32.object({ jobId: z32.string(), text: z32.string() }).optional(),
2665
- threads: z32.array(PrThreadSchema),
2666
- files: z32.array(PrFileSchema),
2667
- commits: z32.array(PrCommitSchema),
2681
+ log: z33.object({ jobId: z33.string(), text: z33.string() }).optional(),
2682
+ threads: z33.array(PrThreadSchema),
2683
+ files: z33.array(PrFileSchema),
2684
+ commits: z33.array(PrCommitSchema),
2668
2685
  /** The exact command a merge runs, for the front's confirmation (R5). */
2669
- mergeCommand: z32.string(),
2686
+ mergeCommand: z33.string(),
2670
2687
  /**
2671
2688
  * Why a merge is refused now, as codes; empty: it can be merged (R5). `not_open`, `draft`, `approvals`, `changes_requested`;
2672
2689
  * `pipeline`: the pipeline is not green (`pr.pipeline` says how); `pipeline_not_started`: no pipeline yet on the head, in a
2673
2690
  * repository with CI or whose CI is unknown (`pr.pipeline` reads `wait`). A repository without any CI gives `none` and no code.
2674
2691
  * A front shows a code it does not know as is.
2675
2692
  */
2676
- mergeBlockers: z32.array(z32.string())
2693
+ mergeBlockers: z33.array(z33.string())
2677
2694
  });
2678
- var ForgeActionSchema = z32.discriminatedUnion("kind", [
2679
- z32.object({ kind: z32.literal("rerun") }),
2695
+ var ForgeActionSchema = z33.discriminatedUnion("kind", [
2696
+ z33.object({ kind: z33.literal("rerun") }),
2680
2697
  /** `headSha`: the head the person saw; `stale` when it has moved. */
2681
- z32.object({ kind: z32.literal("merge"), headSha: z32.string().min(1).max(64) }),
2682
- z32.object({ kind: z32.literal("comment"), body: z32.string().min(1).max(FORGE_BODY_MAX) }),
2683
- z32.object({ kind: z32.literal("reply"), threadId: z32.string().min(1).max(200), body: z32.string().min(1).max(FORGE_BODY_MAX) }),
2684
- z32.object({ kind: z32.literal("resolve"), threadId: z32.string().min(1).max(200) })
2698
+ z33.object({ kind: z33.literal("merge"), headSha: z33.string().min(1).max(64) }),
2699
+ z33.object({ kind: z33.literal("comment"), body: z33.string().min(1).max(FORGE_BODY_MAX) }),
2700
+ z33.object({ kind: z33.literal("reply"), threadId: z33.string().min(1).max(200), body: z33.string().min(1).max(FORGE_BODY_MAX) }),
2701
+ z33.object({ kind: z33.literal("resolve"), threadId: z33.string().min(1).max(200) })
2685
2702
  ]);
2686
- var ForgeDetailSchema = z32.object({ type: z32.literal("forge.detail"), requestId: z32.string().min(1).max(100), prId: z32.string().min(1).max(500), log: z32.string().min(1).max(40).optional(), machineId: z32.string().optional() });
2687
- var ForgeActSchema = z32.object({ type: z32.literal("forge.act"), requestId: z32.string().min(1).max(100), prId: z32.string().min(1).max(500), machineId: z32.string().optional(), action: ForgeActionSchema });
2688
- var ForgeDetailReplySchema = z32.object({ type: z32.literal("forge.detail.reply"), requestId: z32.string(), ok: z32.boolean(), detail: PrDetailSchema.optional(), message: z32.string().optional(), code: RefusalCodeSchema.optional() });
2689
- var ForgeActReplySchema = z32.object({ type: z32.literal("forge.act.reply"), requestId: z32.string(), ok: z32.boolean(), command: z32.string().optional(), message: z32.string().optional(), code: RefusalCodeSchema.optional() });
2703
+ var ForgeDetailSchema = z33.object({ type: z33.literal("forge.detail"), requestId: z33.string().min(1).max(100), prId: z33.string().min(1).max(500), log: z33.string().min(1).max(40).optional(), machineId: z33.string().optional() });
2704
+ var ForgeActSchema = z33.object({ type: z33.literal("forge.act"), requestId: z33.string().min(1).max(100), prId: z33.string().min(1).max(500), machineId: z33.string().optional(), action: ForgeActionSchema });
2705
+ var ForgeDetailReplySchema = z33.object({ type: z33.literal("forge.detail.reply"), requestId: z33.string(), ok: z33.boolean(), detail: PrDetailSchema.optional(), message: z33.string().optional(), code: RefusalCodeSchema.optional() });
2706
+ var ForgeActReplySchema = z33.object({ type: z33.literal("forge.act.reply"), requestId: z33.string(), ok: z33.boolean(), command: z33.string().optional(), message: z33.string().optional(), code: RefusalCodeSchema.optional() });
2690
2707
  var CLOSED_KEEP_DAYS = 7;
2691
2708
  var CLOSED_KEEP_MS = CLOSED_KEEP_DAYS * 24 * 60 * 6e4;
2692
2709
  var PR_ROLE_FILTERS = ["all", ...PR_ROLES];
2693
2710
 
2694
2711
  // ../../packages/protocol/src/messages.ts
2695
- var SessionEventSchema = z33.object({
2696
- name: z33.enum(["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "Notification", "Stop", "SessionEnd", "PaneChanged", "PaneGone", "PanePrompt", "PaneIdle", "InjectFailed", "Decided", "PostToolUse", "PostToolUseFailure", "StopFailure", "SubagentStart", "SubagentStop", "PaneTitle", "Renamed", "NativeRequest", "AgentMessage", "QueueUpdate", "PaneUnreadable", "PaneReadable"]),
2697
- at: z33.string().datetime(),
2698
- source: z33.enum(["hook", "pane", "daemon"]),
2699
- tool: z33.string().optional(),
2700
- text: z33.string().optional(),
2701
- options: z33.array(z33.string()).optional(),
2712
+ var SessionEventSchema = z34.object({
2713
+ name: z34.enum(["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "Notification", "Stop", "SessionEnd", "PaneChanged", "PaneGone", "PanePrompt", "PaneIdle", "InjectFailed", "Decided", "PostToolUse", "PostToolUseFailure", "StopFailure", "SubagentStart", "SubagentStop", "PaneTitle", "Renamed", "NativeRequest", "AgentMessage", "QueueUpdate", "PaneUnreadable", "PaneReadable"]),
2714
+ at: z34.string().datetime(),
2715
+ source: z34.enum(["hook", "pane", "daemon"]),
2716
+ tool: z34.string().optional(),
2717
+ text: z34.string().optional(),
2718
+ options: z34.array(z34.string()).optional(),
2702
2719
  /** Each option's description, by index ('' when it has none); left out when no option has one. */
2703
- optionDetails: z33.array(z33.string()).optional(),
2704
- kind: z33.enum(["question", "permission", "plan", "diff"]).optional(),
2720
+ optionDetails: z34.array(z34.string()).optional(),
2721
+ kind: z34.enum(["question", "permission", "plan", "diff"]).optional(),
2705
2722
  /** PanePrompt: what to review in full before deciding (a plan read in the terminal), when `text` is its summary. */
2706
- body: z33.string().optional(),
2707
- exitCode: z33.number().int().nullable().optional(),
2708
- helperId: z33.string().optional(),
2723
+ body: z34.string().optional(),
2724
+ exitCode: z34.number().int().nullable().optional(),
2725
+ helperId: z34.string().optional(),
2709
2726
  /** The helper's description, once known (Claude Code: its `.meta.json`, written after SubagentStart). */
2710
- task: z33.string().optional(),
2727
+ task: z34.string().optional(),
2711
2728
  /** PostToolUseFailure: the user interrupted the turn (Esc); Claude then waits for input with no Stop. */
2712
- interrupt: z33.boolean().optional(),
2729
+ interrupt: z34.boolean().optional(),
2713
2730
  /** UserPromptSubmit, PostToolUse: the images the prompt or the tool result carried, by attachment id. */
2714
- attachments: z33.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(),
2731
+ attachments: z34.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(),
2715
2732
  /** PostToolUse: some of the result's images were not kept. */
2716
- imagesDropped: z33.boolean().optional(),
2733
+ imagesDropped: z34.boolean().optional(),
2717
2734
  /** QueueUpdate: OMP's queue as it stands. */
2718
- queue: z33.array(z33.object({ text: z33.string(), mode: z33.enum(["steer", "follow_up"]) })).optional(),
2735
+ queue: z34.array(z34.object({ text: z34.string(), mode: z34.enum(["steer", "follow_up"]) })).optional(),
2719
2736
  /** AgentMessage: the harness's own message, its text so far (`streaming`) or whole. `messageId` is unique for the session's life. */
2720
- messageId: z33.string().optional(),
2721
- streaming: z33.boolean().optional(),
2737
+ messageId: z34.string().optional(),
2738
+ streaming: z34.boolean().optional(),
2722
2739
  /** NativeRequest: the dialog's id, and OMP's `ask` questions when it is one. */
2723
- requestId: z33.string().optional(),
2724
- questions: z33.array(AskQuestionSchema).optional(),
2740
+ requestId: z34.string().optional(),
2741
+ questions: z34.array(AskQuestionSchema).optional(),
2725
2742
  /** Stop: its text is already in the thread as AgentMessage cards, which the reply card must not repeat. */
2726
- streamed: z33.boolean().optional(),
2743
+ streamed: z34.boolean().optional(),
2727
2744
  /** Native tracking (spec 2026-10-13 §2): the harness's id of the tool call, so its result lands on the same row. */
2728
- toolUseId: z33.string().optional(),
2745
+ toolUseId: z34.string().optional(),
2729
2746
  /** The tool's input as the harness gave it, every string capped by the hook. */
2730
- toolInput: z33.record(z33.string(), z33.unknown()).optional(),
2747
+ toolInput: z34.record(z34.string(), z34.unknown()).optional(),
2731
2748
  /** PostToolUse: the id the harness gave a call it left running in the background (Claude Code's `backgroundTaskId`, issue #1). */
2732
- backgroundTaskId: z33.string().optional(),
2749
+ backgroundTaskId: z34.string().optional(),
2733
2750
  /** PostToolUse: the result as text; SubagentStop: nothing (the report travels in `text`). */
2734
- output: z33.string().optional(),
2735
- durationMs: z33.number().nonnegative().optional(),
2751
+ output: z34.string().optional(),
2752
+ durationMs: z34.number().nonnegative().optional(),
2736
2753
  /** PostToolUseFailure: the harness's error message. */
2737
- error: z33.string().optional(),
2754
+ error: z34.string().optional(),
2738
2755
  /** The session's transcript, or the helper's on SubagentStop; the daemon reads its tail for the agent's messages. */
2739
- transcriptPath: z33.string().optional(),
2756
+ transcriptPath: z34.string().optional(),
2740
2757
  /** Decided: what was chosen when the daemon knows it. */
2741
2758
  decision: DecisionSchema.optional(),
2742
2759
  /** Decided: the request was refused by Ledge closing the session (its interrupt keys), not by the user's answer. */
2743
- byClose: z33.literal(true).optional(),
2760
+ byClose: z34.literal(true).optional(),
2744
2761
  /** Decided: who answered, when the daemon typed it (absent: answered in the terminal, or an older daemon). */
2745
2762
  by: DecidedBySchema.optional(),
2746
2763
  /** The agent's own session id when the hook names it, so the daemon can resume that conversation. */
2747
- agentSessionId: z33.string().optional()
2764
+ agentSessionId: z34.string().optional()
2748
2765
  });
2749
- var RecentSchema = z33.object({ cwd: z33.string().min(1), project: z33.string().min(1), lastAt: z33.string().datetime() });
2766
+ var RecentSchema = z34.object({ cwd: z34.string().min(1), project: z34.string().min(1), lastAt: z34.string().datetime() });
2750
2767
  var SEMVER = /^\d+\.\d+\.\d+$/;
2751
- var PingSchema = z33.object({ type: z33.literal("ping"), requestId: z33.string().min(1).max(100), machineId: z33.string().optional() });
2752
- var PongSchema = z33.object({ type: z33.literal("pong"), requestId: z33.string(), machineId: z33.string().optional(), error: z33.enum(["offline", "outdated"]).optional() });
2753
- var DaemonInfoSchema = z33.object({
2754
- version: z33.string(),
2755
- install: z33.enum(["npm", "git", "unknown"]),
2756
- systemd: z33.boolean(),
2757
- manual: z33.string().optional(),
2758
- archive: z33.boolean().optional(),
2768
+ var PingSchema = z34.object({ type: z34.literal("ping"), requestId: z34.string().min(1).max(100), machineId: z34.string().optional() });
2769
+ var PongSchema = z34.object({ type: z34.literal("pong"), requestId: z34.string(), machineId: z34.string().optional(), error: z34.enum(["offline", "outdated"]).optional() });
2770
+ var DaemonInfoSchema = z34.object({
2771
+ version: z34.string(),
2772
+ install: z34.enum(["npm", "git", "unknown"]),
2773
+ systemd: z34.boolean(),
2774
+ manual: z34.string().optional(),
2775
+ archive: z34.boolean().optional(),
2759
2776
  /** Takes `model` and `effort` on `session.launch` and answers `models.list` (#58). */
2760
- models: z33.boolean().optional(),
2777
+ models: z34.boolean().optional(),
2761
2778
  /** Drives OMP over its RPC: launching `omp` sessions is possible when the binary is there (`models.list` says so). */
2762
- omp: z33.boolean().optional(),
2779
+ omp: z34.boolean().optional(),
2763
2780
  /** Takes `session.model`: a live session's model and effort changed (#58, lot 2). */
2764
- modelSwitch: z33.boolean().optional(),
2781
+ modelSwitch: z34.boolean().optional(),
2765
2782
  /** Takes `session.adopt`: « Rattacher à Ledge » (spec 2026-12-01 rattacher). */
2766
- adopt: z33.boolean().optional(),
2783
+ adopt: z34.boolean().optional(),
2767
2784
  /** Answers `session.commands`: the slash commands a session's agent offers. */
2768
- commands: z33.boolean().optional(),
2785
+ commands: z34.boolean().optional(),
2769
2786
  /** Takes `approval` on an OMP `session.launch` (auto mode). */
2770
- ompApproval: z33.boolean().optional(),
2787
+ ompApproval: z34.boolean().optional(),
2771
2788
  /** Its home folder, so a client shows the folders under it as `~` (absent from older daemons). */
2772
- home: z33.string().optional(),
2773
- mobile: z33.boolean().optional(),
2789
+ home: z34.string().optional(),
2790
+ mobile: z34.boolean().optional(),
2774
2791
  /** Answers `openrig.status` and `openrig.act`: drives OpenRig on its machine. */
2775
- openrig: z33.boolean().optional(),
2792
+ openrig: z34.boolean().optional(),
2776
2793
  /** Answers `openrig.roles`, `openrig.role` and `openrig.roleFile`: reads OpenRig's roles (agent specs). */
2777
- openrigRoles: z33.boolean().optional(),
2794
+ openrigRoles: z34.boolean().optional(),
2778
2795
  /** Answers `openrig.graph`, `openrig.snapshots`, `openrig.permissions`, `openrig.queue` and `openrig.role.duplicate`, and takes the actions `rig.snapshot`, `rig.permissions` and `rig.start` with a `snapshot` (lot 7a):
2779
2796
  * a client (the fleet) sends none of them to a daemon without it. */
2780
- openrigRig: z33.boolean().optional(),
2797
+ openrigRig: z34.boolean().optional(),
2781
2798
  /** Takes the action `rig.policy` (lot 7c): a client (the fleet) sends it only when this is set. */
2782
- openrigPolicy: z33.boolean().optional(),
2799
+ openrigPolicy: z34.boolean().optional(),
2783
2800
  /** Takes `rig.start` with `fresh` (lot 7d): a client (the fleet) sends it only when this is set. */
2784
- openrigFresh: z33.boolean().optional(),
2801
+ openrigFresh: z34.boolean().optional(),
2785
2802
  /** Answers `ping` with `pong`: a client measures the round trip to this machine (lot 7d). */
2786
- ping: z33.boolean().optional(),
2803
+ ping: z34.boolean().optional(),
2787
2804
  /** Answers `openrig.row`: a queue row's state, for the OpenRig task cards of a thread. */
2788
- openrigRows: z33.boolean().optional(),
2805
+ openrigRows: z34.boolean().optional(),
2789
2806
  /** Answers `openrig.asks` and `openrig.answer`: what OpenRig asks the person, and their answers (« À toi »). */
2790
- openrigAsks: z33.boolean().optional(),
2807
+ openrigAsks: z34.boolean().optional(),
2791
2808
  /** Answers `openrig.goal.send`, `openrig.goals` and `openrig.goal.reply`: goals given to Max (lot 2). */
2792
- openrigGoals: z33.boolean().optional(),
2809
+ openrigGoals: z34.boolean().optional(),
2793
2810
  /** Answers `openrig.missions`: the operator's thread's « Missions » and « Échanges » cards (#54). */
2794
- openrigMissions: z33.boolean().optional(),
2811
+ openrigMissions: z34.boolean().optional(),
2795
2812
  /** Takes `session.broadcast` (its `ledge bridge` too, on this machine): a client sends it only when this is set. */
2796
- broadcast: z33.boolean().optional(),
2813
+ broadcast: z34.boolean().optional(),
2797
2814
  /** Sends `browser.live` and answers `browser.watch`, `browser.unwatch` and `browser.enable`: the agent's browser, live. */
2798
- browserLive: z33.boolean().optional(),
2815
+ browserLive: z34.boolean().optional(),
2799
2816
  /** Answers `term.watch` and `term.shell`: the pane and the shells as a tmux control stream, xterm.js the only emulator. */
2800
- terminalStream: z33.boolean().optional(),
2817
+ terminalStream: z34.boolean().optional(),
2801
2818
  /** Sends `usage.state` (each harness's account limits, the alerts, the threshold) and takes `usage.set` and `usage.ack`. */
2802
- usage: z33.boolean().optional(),
2819
+ usage: z34.boolean().optional(),
2803
2820
  /** `term.watch` also streams an OpenRig seat (`@` in its tmux name), through a control client on the seat's own tmux server.
2804
2821
  * Without it, a front keeps a seat on the pseudo-terminal: an older daemon answers its watch `failed`. */
2805
- terminalStreamSeats: z33.boolean().optional(),
2822
+ terminalStreamSeats: z34.boolean().optional(),
2806
2823
  /** Sends `forge.state` and answers `forge.detail` and `forge.act`: the pull and merge requests of its sessions' branches (lot 8a). */
2807
- forge: z33.boolean().optional(),
2824
+ forge: z34.boolean().optional(),
2808
2825
  /** Answers `routine.list`, `routine.cmd` and `routine.preview`, and sends `routine.changed` (spec 2026-11-23 routines). */
2809
- routines: z33.boolean().optional(),
2826
+ routines: z34.boolean().optional(),
2810
2827
  /** Answers a grouped `routine.cmd` (`others`) all or nothing: a client sends one only to a daemon that says it. */
2811
- routineGroups: z33.boolean().optional(),
2828
+ routineGroups: z34.boolean().optional(),
2812
2829
  /** Takes `session.aside` (#41): a Claude Code session's `/btw`, answered as an aside, not a thread item. */
2813
- aside: z33.boolean().optional(),
2830
+ aside: z34.boolean().optional(),
2814
2831
  /** Takes `session.label`: a session's nickname, kept with it. A client sends one only to a daemon that says it. */
2815
- sessionLabel: z33.boolean().optional(),
2832
+ sessionLabel: z34.boolean().optional(),
2816
2833
  /** Its launcher answers `shell --nonce <N> <dir>` (#299): a free shell started through it gets the shell integration (OSC 633). */
2817
- freeShell: z33.boolean().optional()
2834
+ freeShell: z34.boolean().optional()
2818
2835
  });
2819
- var UpdateFailureSchema = z33.enum(["git-install", "no-systemd", "sessions-at-risk", "npm-failed", "busy"]);
2820
- var ServerMessageSchema = z33.discriminatedUnion("type", [
2836
+ var UpdateFailureSchema = z34.enum(["git-install", "no-systemd", "sessions-at-risk", "npm-failed", "busy"]);
2837
+ var SetupFailedSchema = z34.literal(true).optional();
2838
+ var ServerMessageSchema = z34.discriminatedUnion("type", [
2821
2839
  BrowserLiveSchema,
2822
2840
  BrowserFrameSchema,
2823
2841
  BrowserEnabledSchema,
@@ -2859,77 +2877,79 @@ var ServerMessageSchema = z33.discriminatedUnion("type", [
2859
2877
  /** `recents`: the folders of past sessions, most recent first. `launcher`: the command that runs `ledge` inside WSL
2860
2878
  * (`[node, cli]`), so the overlay can attach a terminal to a session with `<launcher> attach <id>`. `daemon`: absent
2861
2879
  * from daemons older than the auto-update. */
2862
- z33.object({ type: z33.literal("snapshot"), sessions: z33.array(SessionSchema), recents: z33.array(RecentSchema).optional(), launcher: z33.array(z33.string()).optional(), daemon: DaemonInfoSchema.optional(), sshAlias: SshAliasSchema.optional() }),
2863
- z33.object({ type: z33.literal("session.updated"), session: SessionSchema }),
2880
+ z34.object({ type: z34.literal("snapshot"), sessions: z34.array(SessionSchema), recents: z34.array(RecentSchema).optional(), launcher: z34.array(z34.string()).optional(), daemon: DaemonInfoSchema.optional(), sshAlias: SshAliasSchema.optional() }),
2881
+ z34.object({ type: z34.literal("session.updated"), session: SessionSchema }),
2864
2882
  /** OMP: the instructions taken back from its queue by an interrupt that restores it; the asker puts them back in its draft. */
2865
- z33.object({
2866
- type: z33.literal("session.queue.restored"),
2867
- id: z33.string(),
2868
- texts: z33.array(z33.string()),
2883
+ z34.object({
2884
+ type: z34.literal("session.queue.restored"),
2885
+ id: z34.string(),
2886
+ texts: z34.array(z34.string()),
2869
2887
  /** The same instructions with the images they carried; `imagesDropped`: some images could not be put back. */
2870
- entries: z33.array(z33.object({ text: z33.string(), attachments: z33.array(AttachmentIdSchema).optional() })).optional(),
2871
- imagesDropped: z33.boolean().optional()
2888
+ entries: z34.array(z34.object({ text: z34.string(), attachments: z34.array(AttachmentIdSchema).optional() })).optional(),
2889
+ imagesDropped: z34.boolean().optional()
2872
2890
  }),
2873
- z33.object({ type: z33.literal("session.removed"), id: z33.string() }),
2874
- z33.object({ type: z33.literal("session.preview"), id: z33.string(), lines: z33.array(z33.string()) }),
2891
+ z34.object({ type: z34.literal("session.removed"), id: z34.string() }),
2892
+ z34.object({ type: z34.literal("session.preview"), id: z34.string(), lines: z34.array(z34.string()) }),
2875
2893
  /** A session's thread, on request (spec 2026-10-13 §5); then each created or updated item, broadcast. */
2876
- z33.object({ type: z33.literal("session.thread"), id: z33.string(), items: z33.array(ThreadItemSchema) }),
2877
- z33.object({ type: z33.literal("session.thread.item"), id: z33.string(), item: ThreadItemSchema }),
2894
+ z34.object({ type: z34.literal("session.thread"), id: z34.string(), items: z34.array(ThreadItemSchema) }),
2895
+ z34.object({ type: z34.literal("session.thread.item"), id: z34.string(), item: ThreadItemSchema }),
2878
2896
  SessionAsideSchema,
2879
2897
  /** Answer to the requester of a `session.launch`: the session exists (its `session.updated` is broadcast as usual). */
2880
- z33.object({ type: z33.literal("session.launched"), id: z33.string() }),
2898
+ z34.object({ type: z34.literal("session.launched"), id: z34.string() }),
2881
2899
  /** Answer to the requester of a `session.adopt`: the session is Ledge's now; on `resume` the requester opens its terminal. */
2882
- z33.object({ type: z33.literal("session.adopted"), id: z33.string(), path: AdoptPathSchema }),
2883
- z33.object({ type: z33.literal("recents"), recents: z33.array(RecentSchema) }),
2900
+ z34.object({ type: z34.literal("session.adopted"), id: z34.string(), path: AdoptPathSchema }),
2901
+ z34.object({ type: z34.literal("recents"), recents: z34.array(RecentSchema) }),
2884
2902
  /** Answer to the requester of a `folder.list` or `folder.create`: `path` resolved (`~` expanded), `parent` null at the
2885
2903
  * root, `entries` its subfolders by name (hidden ones left out). A failure keeps the asked path and says why in `error`,
2886
2904
  * never in an `error` message, which the launch form reads as a failed launch. */
2887
- z33.object({
2888
- type: z33.literal("folder.listing"),
2889
- path: z33.string(),
2890
- parent: z33.string().nullable(),
2891
- entries: z33.array(z33.string()),
2892
- error: z33.string().optional(),
2905
+ z34.object({
2906
+ type: z34.literal("folder.listing"),
2907
+ path: z34.string(),
2908
+ parent: z34.string().nullable(),
2909
+ entries: z34.array(z34.string()),
2910
+ error: z34.string().optional(),
2893
2911
  /** The request this answers, when it carried one. */
2894
- requestId: z33.string().optional(),
2912
+ requestId: z34.string().optional(),
2895
2913
  /** Those `entries` that are Git repositories, with their branch (the short commit when HEAD is detached). */
2896
- repos: z33.array(z33.object({ name: z33.string(), branch: z33.string() })).optional()
2914
+ repos: z34.array(z34.object({ name: z34.string(), branch: z34.string() })).optional()
2897
2915
  }),
2898
2916
  /** What an `action.run` came to: `row` the action as the daemon resolved it (its summary, its risk); `reason` why it was not
2899
2917
  * done, with `code` (`refused`: not possible now; `agent`: a session may not run it; `confirm_required`: destructive, ask
2900
2918
  * again; `failed`: the handler turned it down; a free string, as an `error`'s). */
2901
- z33.object({ type: z33.literal("action.result"), rid: z33.string(), action: z33.string().min(1).max(40), row: ChatActionSchema.optional(), reason: z33.string().optional(), code: z33.string().optional() }),
2919
+ z34.object({ type: z34.literal("action.result"), rid: z34.string(), action: z34.string().min(1).max(40), row: ChatActionSchema.optional(), reason: z34.string().optional(), code: z34.string().optional() }),
2902
2920
  /** #40: the chat left Ledge. An older front's `chat.ask` or `chat.route` is answered with this, so it stops waiting (D12). */
2903
- z33.object({ type: z33.literal("chat.error"), qid: z33.string(), message: z33.string() }),
2921
+ z34.object({ type: z34.literal("chat.error"), qid: z34.string(), message: z34.string() }),
2904
2922
  /** The daemon updating itself: npm is running, then the service restarts (the socket closes right after). */
2905
- z33.object({ type: z33.literal("update.progress"), version: z33.string(), step: z33.enum(["installing", "restarting"]) }),
2906
- /** Nothing was changed. `detail`: the useful end of npm's output; `command`: what the person can run instead. */
2907
- z33.object({ type: z33.literal("update.failed"), version: z33.string(), reason: UpdateFailureSchema, detail: z33.string().optional(), command: z33.string().optional() }),
2923
+ z34.object({ type: z34.literal("update.progress"), version: z34.string(), step: z34.enum(["installing", "restarting"]) }),
2924
+ /** Nothing was changed, unless `setup` (the version is installed, its setup failed). `detail`: the useful end of npm's or setup's output; `command`: what the person can run instead. */
2925
+ z34.object({ type: z34.literal("update.failed"), version: z34.string(), reason: UpdateFailureSchema, detail: z34.string().optional(), command: z34.string().optional(), setup: SetupFailedSchema }),
2908
2926
  /** The shared machines list (spec 2026-10-14 §5), sent to local clients only. */
2909
- z33.object({ type: z33.literal("machines"), machines: MachinesSchema }),
2927
+ z34.object({ type: z34.literal("machines"), machines: MachinesSchema }),
2910
2928
  /** The local daemon's projects and folder rules (spec 2026-10-16 build §5), sent to local clients only. */
2911
- z33.object({ type: z33.literal("projects"), projects: ProjectsSchema }),
2929
+ z34.object({ type: z34.literal("projects"), projects: ProjectsSchema }),
2912
2930
  /** The island's settings shared by the local fronts; null until a front sets them (the island then sends its own). Local clients only. */
2913
- z33.object({ type: z33.literal("island"), prefs: IslandPrefsSchema.nullable() }),
2931
+ z34.object({ type: z34.literal("island"), prefs: IslandPrefsSchema.nullable() }),
2914
2932
  /** Mobile access (lot 3), after the island in each snapshot and on every change. Local clients only. */
2915
- z33.object({ type: z33.literal("mobile"), state: MobileStateSchema }),
2933
+ z34.object({ type: z34.literal("mobile"), state: MobileStateSchema }),
2916
2934
  /** A passkey recovery as it happens (docs/mobile-passkey-recover-contract.md), for the local fronts' toast; the lasting trace is in `mobile`. */
2917
- z33.object({ type: z33.literal("mobile.recovery") }).merge(MobileRecoveryEventSchema),
2935
+ z34.object({ type: z34.literal("mobile.recovery") }).merge(MobileRecoveryEventSchema),
2918
2936
  /** The sessions a phone types into (« Téléphone au clavier »), after each snapshot and each change; `device` is its label. */
2919
- z33.object({ type: z33.literal("terminal.holders"), holds: z33.array(z33.object({ id: z33.string(), device: z33.string() })) }),
2937
+ z34.object({ type: z34.literal("terminal.holders"), holds: z34.array(z34.object({ id: z34.string(), device: z34.string() })) }),
2920
2938
  /** The daemon's immediate answer to a `session.message`: delivered (`accepted`), held for later (`queued`), left to Claude's own SendMessage (`native`), or refused with a `reason`. */
2921
- z33.object({
2922
- type: z33.literal("message.ack"),
2923
- rid: z33.string(),
2924
- outcome: z33.enum(["accepted", "queued", "native", "refused"]),
2925
- reason: z33.string().optional(),
2939
+ z34.object({
2940
+ type: z34.literal("message.ack"),
2941
+ rid: z34.string(),
2942
+ outcome: z34.enum(["accepted", "queued", "native", "refused"]),
2943
+ reason: z34.string().optional(),
2944
+ /** Why, for a refusal a sender reads in its own language (`key_reused`); a free string, so an older front ignores a new one. */
2945
+ code: z34.string().optional(),
2926
2946
  /** A broadcast's per-recipient outcome, by name. */
2927
- recipients: z33.object({ sent: z33.array(z33.string()), refused: z33.array(z33.object({ name: z33.string(), reason: z33.string() })) }).optional()
2947
+ recipients: z34.object({ sent: z34.array(z34.string()), refused: z34.array(z34.object({ name: z34.string(), reason: z34.string() })) }).optional()
2928
2948
  }),
2929
2949
  /** The answer to a `session.broadcast`: who got it (`sent`) and who did not; `reason`: the whole broadcast was refused. */
2930
- z33.object({ type: z33.literal("session.broadcast.result"), rid: z33.string(), sent: z33.array(z33.object({ id: z33.string(), name: z33.string() })), refused: z33.array(z33.object({ name: z33.string(), reason: z33.string() })), reason: z33.string().optional() }),
2950
+ z34.object({ type: z34.literal("session.broadcast.result"), rid: z34.string(), sent: z34.array(z34.object({ id: z34.string(), name: z34.string() })), refused: z34.array(z34.object({ name: z34.string(), reason: z34.string() })), reason: z34.string().optional() }),
2931
2951
  /** The answer to a `message.read`: the body with its sender, target and time, or the refusal's `reason`. */
2932
- z33.object({ type: z33.literal("message.body"), id: z33.string(), from: z33.string().optional(), to: z33.string().optional(), at: z33.string().optional(), text: z33.string().optional(), reason: z33.string().optional() }),
2952
+ z34.object({ type: z34.literal("message.body"), id: z34.string(), from: z34.string().optional(), to: z34.string().optional(), at: z34.string().optional(), text: z34.string().optional(), reason: z34.string().optional() }),
2933
2953
  TaskResultSchema,
2934
2954
  ReportPreviewReplySchema,
2935
2955
  ReportCreatedSchema,
@@ -2950,20 +2970,20 @@ var ServerMessageSchema = z33.discriminatedUnion("type", [
2950
2970
  RoutineChangedSchema,
2951
2971
  RoutinePreviewedSchema,
2952
2972
  /** The operator's notices, broadcast on change and in the snapshot. */
2953
- z33.object({ type: z33.literal("operator.state"), notices: z33.array(OperatorNoticeSchema).max(50) }),
2954
- z33.object({
2955
- type: z33.literal("error"),
2956
- message: z33.string(),
2957
- id: z33.string().optional(),
2973
+ z34.object({ type: z34.literal("operator.state"), notices: z34.array(OperatorNoticeSchema).max(50) }),
2974
+ z34.object({
2975
+ type: z34.literal("error"),
2976
+ message: z34.string(),
2977
+ id: z34.string().optional(),
2958
2978
  /** Le type du message client refusé. */
2959
- request: z33.string().optional(),
2979
+ request: z34.string().optional(),
2960
2980
  /** Ce que le front doit reconnaître au-delà du texte (NOTE_NOT_TYPED) ; une chaîne libre, qu'un front plus ancien ignore. */
2961
- code: z33.string().optional()
2981
+ code: z34.string().optional()
2962
2982
  })
2963
2983
  ]);
2964
2984
  var MESSAGE_MAX = 2e4;
2965
2985
  var SUMMARY_MAX = 500;
2966
- var ClientMessageSchema = z33.discriminatedUnion("type", [
2986
+ var ClientMessageSchema = z34.discriminatedUnion("type", [
2967
2987
  BrowserWatchSchema,
2968
2988
  BrowserUnwatchSchema,
2969
2989
  BrowserEnableSchema,
@@ -3004,163 +3024,179 @@ var ClientMessageSchema = z33.discriminatedUnion("type", [
3004
3024
  /** The overlay starts a session: `cwd` is a WSL path (`~` allowed), `name` a preferred bot name (the daemon picks a
3005
3025
  * free one otherwise), `prompt` the agent's first instruction, `continue` resumes the folder's last conversation.
3006
3026
  * `qid` named a chat card's turn: the chat left Ledge (#40), so the daemon refuses it (an older front, D12). */
3007
- z33.object({
3008
- type: z33.literal("session.launch"),
3027
+ z34.object({
3028
+ type: z34.literal("session.launch"),
3009
3029
  tool: ToolSchema,
3010
- cwd: z33.string().min(1),
3011
- name: z33.string().optional(),
3012
- prompt: z33.string().optional(),
3013
- continue: z33.boolean().optional(),
3014
- qid: z33.string().min(1).optional(),
3030
+ cwd: z34.string().min(1),
3031
+ name: z34.string().optional(),
3032
+ prompt: z34.string().optional(),
3033
+ continue: z34.boolean().optional(),
3034
+ qid: z34.string().min(1).optional(),
3015
3035
  /** Folders in addition to `cwd` (Claude: `--add-dir`); resolved like `cwd`. */
3016
- dirs: z33.array(z33.string().min(1)).max(20).optional(),
3036
+ dirs: z34.array(z34.string().min(1)).max(20).optional(),
3017
3037
  /** The agent's model and effort (#58), the agent's own default when left out. */
3018
3038
  model: ModelIdSchema.optional(),
3019
3039
  effort: EffortSchema.optional(),
3020
3040
  /** OMP only: its approval mode, `always-ask` when left out. */
3021
3041
  approval: OmpApprovalSchema.optional(),
3022
3042
  /** Routing by the fleet, removed before the message reaches the daemon. */
3023
- machineId: z33.string().optional()
3043
+ machineId: z34.string().optional()
3024
3044
  }),
3025
3045
  /** The launch form's folder browser: list a folder's subfolders (home when no `path`), or make `name` inside `parent`
3026
3046
  * and list it. Both are answered with a `folder.listing`. */
3027
- z33.object({
3028
- type: z33.literal("folder.list"),
3029
- path: z33.string().optional(),
3047
+ z34.object({
3048
+ type: z34.literal("folder.list"),
3049
+ path: z34.string().optional(),
3030
3050
  /** Routing by the fleet, removed before the message reaches the daemon. */
3031
- machineId: z33.string().optional(),
3051
+ machineId: z34.string().optional(),
3032
3052
  /** Copied into the `folder.listing` that answers; the fleet relays only that listing, from the machine asked. */
3033
- requestId: z33.string().min(1).max(100).optional()
3053
+ requestId: z34.string().min(1).max(100).optional()
3034
3054
  }),
3035
- z33.object({
3036
- type: z33.literal("folder.create"),
3037
- parent: z33.string().min(1),
3038
- name: z33.string().min(1),
3055
+ z34.object({
3056
+ type: z34.literal("folder.create"),
3057
+ parent: z34.string().min(1),
3058
+ name: z34.string().min(1),
3039
3059
  /** As for `folder.list`: routing by the fleet, and the request its `folder.listing` answers. */
3040
- machineId: z33.string().optional(),
3041
- requestId: z33.string().min(1).max(100).optional()
3060
+ machineId: z34.string().optional(),
3061
+ requestId: z34.string().min(1).max(100).optional()
3042
3062
  }),
3043
3063
  /** `steer`: OMP only, redirect the turn running now instead of queueing the text after it. */
3044
3064
  /** OMP's `ask`: the answers to every question of the dialog `requestId`, in order (`selected` labels, and/or free `text`); `cancel` declines it. */
3045
- z33.object({ type: z33.literal("session.answer"), id: z33.string(), requestId: z33.string().min(1).max(200), answers: z33.array(z33.object({ id: z33.string(), selected: z33.array(z33.string().max(2e3)).max(100), text: z33.string().max(2e4).optional() })).max(50), cancel: z33.boolean().optional() }),
3065
+ z34.object({ type: z34.literal("session.answer"), id: z34.string(), requestId: z34.string().min(1).max(200), answers: z34.array(z34.object({ id: z34.string(), selected: z34.array(z34.string().max(2e3)).max(100), text: z34.string().max(2e4).optional() })).max(50), cancel: z34.boolean().optional() }),
3046
3066
  /** `by`: as session.decide's, who answers when the reply answers a request (set by the phone gateway for a device; absent, the PC). */
3047
- z33.object({ type: z33.literal("session.reply"), id: z33.string(), text: z33.string(), attachments: z33.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(), steer: z33.boolean().optional(), by: DecidedBySchema.optional() }),
3067
+ z34.object({ type: z34.literal("session.reply"), id: z34.string(), text: z34.string(), attachments: z34.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(), steer: z34.boolean().optional(), by: DecidedBySchema.optional() }),
3048
3068
  /** A registry action run outside the chat (#93, the CLI): the daemon resolves `args` as it does a generic card's row, then
3049
3069
  * applies it through its own handler. `by` the session that asks, left out for the user; `confirmed` for a destructive one. */
3050
- z33.object({
3051
- type: z33.literal("action.run"),
3052
- rid: z33.string().min(1).max(100),
3053
- by: z33.string().min(1).optional(),
3070
+ z34.object({
3071
+ type: z34.literal("action.run"),
3072
+ rid: z34.string().min(1).max(100),
3073
+ by: z34.string().min(1).optional(),
3054
3074
  /** `by`'s key (LEDGE_SESSION_KEY) */
3055
- key: z33.string().max(128).optional(),
3075
+ key: z34.string().max(128).optional(),
3056
3076
  action: ActionIdSchema,
3057
- args: z33.record(z33.unknown()),
3058
- confirmed: z33.literal(true).optional()
3077
+ args: z34.record(z34.unknown()),
3078
+ confirmed: z34.literal(true).optional()
3059
3079
  }),
3060
3080
  /** `always` and `note` only where the harness offers them (`offers`); a note goes with `deny`, for the agent to read. */
3061
- z33.object({
3062
- type: z33.literal("session.decide"),
3063
- id: z33.string(),
3081
+ z34.object({
3082
+ type: z34.literal("session.decide"),
3083
+ id: z34.string(),
3064
3084
  decision: DecisionSchema,
3065
- note: z33.string().trim().min(1).max(NOTE_MAX).optional(),
3085
+ note: z34.string().trim().min(1).max(NOTE_MAX).optional(),
3066
3086
  /** The request the user saw when deciding: refused (the request changed) unless it is still the pending one. Left out by older fronts and the island.
3067
3087
  * `key` (pendingKey) covers its whole content; older fronts send kind and text only. */
3068
- expect: PendingSchema.pick({ kind: true, text: true }).extend({ key: z33.string().max(64).optional() }).optional(),
3088
+ expect: PendingSchema.pick({ kind: true, text: true }).extend({ key: z34.string().max(64).optional() }).optional(),
3069
3089
  /** Who decides: set by the phone gateway for a device (over anything the device sent); left out by a local front, which means the PC. */
3070
3090
  by: DecidedBySchema.optional()
3071
3091
  }),
3072
- z33.object({ type: z33.literal("session.focus"), id: z33.string() }),
3073
- z33.object({ type: z33.literal("session.kill"), id: z33.string() }),
3092
+ z34.object({ type: z34.literal("session.focus"), id: z34.string() }),
3093
+ z34.object({ type: z34.literal("session.kill"), id: z34.string() }),
3074
3094
  /** `restoreQueue` (OMP): also take back what waits in its queue, returned as `session.queue.restored` to put in the draft. */
3075
- z33.object({ type: z33.literal("session.interrupt"), id: z33.string(), restoreQueue: z33.boolean().optional() }),
3095
+ z34.object({ type: z34.literal("session.interrupt"), id: z34.string(), restoreQueue: z34.boolean().optional() }),
3076
3096
  SessionAsideAskSchema,
3077
3097
  /** Removes a finished (exited) or read-only (hook_only) session from the list; refused for a live launcher session. */
3078
- z33.object({ type: z33.literal("session.dismiss"), id: z33.string() }),
3098
+ z34.object({ type: z34.literal("session.dismiss"), id: z34.string() }),
3079
3099
  /** Puts a session in the archive: it leaves the live list but is kept. */
3080
- z33.object({ type: z33.literal("session.archive"), id: z33.string() }),
3100
+ z34.object({ type: z34.literal("session.archive"), id: z34.string() }),
3081
3101
  /** Takes an archived session back out of the archive, as it was. */
3082
- z33.object({ type: z33.literal("session.restore"), id: z33.string() }),
3102
+ z34.object({ type: z34.literal("session.restore"), id: z34.string() }),
3083
3103
  /** Starts the agent again on an archived session's conversation. */
3084
- z33.object({ type: z33.literal("session.resume"), id: z33.string() }),
3104
+ z34.object({ type: z34.literal("session.resume"), id: z34.string() }),
3085
3105
  /** Changes a live session's model and effort (#58, lot 2), `null` for the agent's own default: the daemon restarts the
3086
3106
  * agent on the same conversation with them, at once when the session is free, else at its next free moment. */
3087
- z33.object({ type: z33.literal("session.model"), id: z33.string(), model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
3107
+ z34.object({ type: z34.literal("session.model"), id: z34.string(), model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
3088
3108
  /** Deletes a session for good, archived or not. */
3089
- z33.object({ type: z33.literal("session.delete"), id: z33.string() }),
3109
+ z34.object({ type: z34.literal("session.delete"), id: z34.string() }),
3090
3110
  /** 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. */
3091
- z33.object({ type: z33.literal("session.rename"), id: z33.string(), topic: z33.string().max(500) }),
3111
+ z34.object({ type: z34.literal("session.rename"), id: z34.string(), topic: z34.string().max(500) }),
3092
3112
  /** A session's nickname set from the sidebar (`sessionLabel` in the daemon's info), trimmed; empty removes it. Its name, its
3093
3113
  * address, does not change. */
3094
- z33.object({ type: z33.literal("session.label"), id: z33.string(), label: z33.string().max(200) }),
3095
- z33.object({ type: z33.literal("session.thread"), id: z33.string() }),
3096
- z33.object({ type: z33.literal("session.register"), session: SessionSchema }),
3114
+ z34.object({ type: z34.literal("session.label"), id: z34.string(), label: z34.string().max(200) }),
3115
+ z34.object({ type: z34.literal("session.thread"), id: z34.string() }),
3116
+ z34.object({ type: z34.literal("session.register"), session: SessionSchema }),
3097
3117
  /** `agent` and `cwd` describe the session when the daemon does not know it yet (a hook from an agent started without ledge). */
3098
- z33.object({
3099
- type: z33.literal("session.event"),
3100
- id: z33.string(),
3118
+ z34.object({
3119
+ type: z34.literal("session.event"),
3120
+ id: z34.string(),
3101
3121
  event: SessionEventSchema,
3102
3122
  agent: ToolSchema.optional(),
3103
- cwd: z33.string().optional(),
3123
+ cwd: z34.string().optional(),
3104
3124
  /** The OpenRig seat the agent runs in (`OPENRIG_SESSION_NAME`, `pod-member@rig`), when OpenRig launched it. */
3105
3125
  rigSeat: RigSeatNameSchema.optional(),
3106
3126
  /** Where the agent runs, from an agent Ledge did not launch (spec 2026-12-01 rattacher §2). */
3107
3127
  where: AgentWhereSchema.optional()
3108
3128
  }),
3109
3129
  /** « Rattacher à Ledge » on a read-only session (spec 2026-12-01 rattacher §3); `cancel` withdraws one still `waiting`. */
3110
- z33.object({ type: z33.literal("session.adopt"), id: z33.string(), cancel: z33.literal(true).optional() }),
3111
- z33.object({ type: z33.literal("session.unregister"), id: z33.string(), exitCode: z33.number().int().nullable() }),
3112
- z33.object({ type: z33.literal("snapshot.request") }),
3130
+ z34.object({ type: z34.literal("session.adopt"), id: z34.string(), cancel: z34.literal(true).optional() }),
3131
+ z34.object({ type: z34.literal("session.unregister"), id: z34.string(), exitCode: z34.number().int().nullable() }),
3132
+ z34.object({ type: z34.literal("snapshot.request") }),
3113
3133
  /** #40: the chat, its cards and the operator's point left Ledge. An older front's message still parses, by its name only, so
3114
3134
  * the daemon refuses it by name (D12); `chat.ask` and `chat.route` keep their `qid`, answered with a `chat.error`. */
3115
- z33.object({ type: z33.literal("chat.ask"), qid: z33.string().min(1).max(100) }),
3116
- z33.object({ type: z33.literal("chat.route"), qid: z33.string().min(1).max(100) }),
3117
- ...["chat.cancel", "chat.reset", "chat.act", "chat.ignore", "point.act", "point.later", "operator.read", "session.relay", "session.relay.cancel", "session.close"].map((type) => z33.object({ type: z33.literal(type) })),
3135
+ z34.object({ type: z34.literal("chat.ask"), qid: z34.string().min(1).max(100) }),
3136
+ z34.object({ type: z34.literal("chat.route"), qid: z34.string().min(1).max(100) }),
3137
+ ...["chat.cancel", "chat.reset", "chat.act", "chat.ignore", "point.act", "point.later", "operator.read", "session.relay", "session.relay.cancel", "session.close"].map((type) => z34.object({ type: z34.literal(type) })),
3118
3138
  /** Installs `@paradow/ledge@version` and restarts the service (spec 2026-10-12 auto-update §6). */
3119
- z33.object({ type: z33.literal("update.daemon"), version: z33.string().regex(SEMVER) }),
3139
+ z34.object({ type: z34.literal("update.daemon"), version: z34.string().regex(SEMVER) }),
3120
3140
  /** Replaces the daemon's machines list (first connected front wins); refused unless valid. */
3121
- z33.object({ type: z33.literal("machines.set"), machines: MachinesSchema }),
3141
+ z34.object({ type: z34.literal("machines.set"), machines: MachinesSchema }),
3122
3142
  /** Replaces the local daemon's projects and rules as a whole; refused unless valid. */
3123
- z33.object({ type: z33.literal("projects.set"), projects: ProjectsSchema }),
3143
+ z34.object({ type: z34.literal("projects.set"), projects: ProjectsSchema }),
3124
3144
  /** Issue #16: one project's sessions' order (its id, or NO_PROJECT ''), as session keys (placeSessions); answered by `projects`. */
3125
- z33.object({ type: z33.literal("sessions.order"), project: z33.string().max(64), ids: z33.array(z33.string().min(1).max(300)).max(SESSION_ORDER_MAX) }),
3145
+ z34.object({ type: z34.literal("sessions.order"), project: z34.string().max(64), ids: z34.array(z34.string().min(1).max(300)).max(SESSION_ORDER_MAX) }),
3126
3146
  /** Replaces the island's settings as a whole; refused unless valid. */
3127
- z33.object({ type: z33.literal("island.set"), prefs: IslandPrefsSchema }),
3147
+ z34.object({ type: z34.literal("island.set"), prefs: IslandPrefsSchema }),
3128
3148
  /** Mobile access (lot 3), local fronts only. A changed `relayUrl` drops the relay session. */
3129
- z33.object({ type: z33.literal("mobile.set"), enabled: z33.boolean(), relayUrl: RelayUrlSchema }),
3130
- z33.object({ type: z33.literal("mobile.signin") }),
3131
- z33.object({ type: z33.literal("mobile.signin.cancel") }),
3132
- z33.object({ type: z33.literal("mobile.signout") }),
3149
+ z34.object({ type: z34.literal("mobile.set"), enabled: z34.boolean(), relayUrl: RelayUrlSchema }),
3150
+ z34.object({ type: z34.literal("mobile.signin") }),
3151
+ z34.object({ type: z34.literal("mobile.signin.cancel") }),
3152
+ z34.object({ type: z34.literal("mobile.signout") }),
3133
3153
  /** While the link is offline: try again now. */
3134
- z33.object({ type: z33.literal("mobile.retry") }),
3154
+ z34.object({ type: z34.literal("mobile.retry") }),
3135
3155
  /** `replaces`: an approved device this one takes the place of (the same app reinstalled), revoked once this one is stored. */
3136
- z33.object({ type: z33.literal("mobile.pairing.approve"), id: z33.string().min(1).max(100), replaces: z33.string().min(1).max(100).optional() }),
3137
- z33.object({ type: z33.literal("mobile.pairing.deny"), id: z33.string().min(1).max(100) }),
3156
+ z34.object({ type: z34.literal("mobile.pairing.approve"), id: z34.string().min(1).max(100), replaces: z34.string().min(1).max(100).optional() }),
3157
+ z34.object({ type: z34.literal("mobile.pairing.deny"), id: z34.string().min(1).max(100) }),
3138
3158
  /** `id`: the device's fingerprint. */
3139
- z33.object({ type: z33.literal("mobile.device.revoke"), id: z33.string().min(1).max(100) }),
3159
+ z34.object({ type: z34.literal("mobile.device.revoke"), id: z34.string().min(1).max(100) }),
3140
3160
  /** Names a device (`id`: its fingerprint); the device sees its new name in its next snapshot. */
3141
- z33.object({ type: z33.literal("mobile.device.rename"), id: z33.string().min(1).max(100), name: DeviceNameSchema }),
3161
+ z34.object({ type: z34.literal("mobile.device.rename"), id: z34.string().min(1).max(100), name: DeviceNameSchema }),
3142
3162
  /** « Taper dans les terminaux depuis le téléphone »; turned off, every phone loses the hand. */
3143
- z33.object({ type: z33.literal("mobile.terminal"), input: z33.boolean() }),
3163
+ z34.object({ type: z34.literal("mobile.terminal"), input: z34.boolean() }),
3144
3164
  /** « C'était bien moi » (`recovered`: its notice goes, the trace stays) or « Compris » (`refused`) on a device's row. */
3145
- z33.object({ type: z33.literal("mobile.device.ack"), id: z33.string().min(1).max(100), what: z33.enum(["recovered", "refused"]) }),
3165
+ z34.object({ type: z34.literal("mobile.device.ack"), id: z34.string().min(1).max(100), what: z34.enum(["recovered", "refused"]) }),
3146
3166
  /** « Débloquer »: passkey recovery is taken again after 3 failed verifications. */
3147
- z33.object({ type: z33.literal("mobile.recovery.unblock") }),
3167
+ z34.object({ type: z34.literal("mobile.recovery.unblock") }),
3148
3168
  /** « Reprendre la main »: the phone typing into the session's terminal goes back to reading it. */
3149
- z33.object({ type: z33.literal("terminal.release"), id: z33.string().min(1) }),
3169
+ z34.object({ type: z34.literal("terminal.release"), id: z34.string().min(1) }),
3150
3170
  /** One session writing to another by Ledge name (`to` may end in ` [ref]`); `intercept` (the Claude hook): answer `native` unless `to` is a live non-Claude session. */
3151
- z33.object({ type: z33.literal("session.message"), rid: z33.string().min(1), from: z33.string().min(1), to: z33.string().min(1), text: z33.string().min(1).max(MESSAGE_MAX), summary: z33.string().max(SUMMARY_MAX).optional(), intercept: z33.boolean().optional() }),
3171
+ z34.object({
3172
+ type: z34.literal("session.message"),
3173
+ rid: z34.string().min(1),
3174
+ from: z34.string().min(1),
3175
+ to: z34.string().min(1),
3176
+ text: z34.string().min(1).max(MESSAGE_MAX),
3177
+ summary: z34.string().max(SUMMARY_MAX).optional(),
3178
+ intercept: z34.boolean().optional(),
3179
+ /** A program outside Ledge writing (`ledge send --from <name>`): its name, `from` then being `externalId(name)`. */
3180
+ external: ExternalNameSchema.optional()
3181
+ }),
3152
3182
  /** The user writing to every session of a project, or to several sessions (ids or names). */
3153
- z33.object({
3154
- type: z33.literal("session.broadcast"),
3155
- rid: z33.string().min(1).max(100),
3156
- to: z33.union([z33.object({ project: z33.string().min(1).max(80) }), z33.object({ sessions: z33.array(z33.string().min(1)).min(1).max(BROADCAST_SESSIONS_MAX) })]),
3157
- text: z33.string().trim().min(1).max(MESSAGE_MAX),
3158
- summary: z33.string().max(SUMMARY_MAX).optional(),
3183
+ z34.object({
3184
+ type: z34.literal("session.broadcast"),
3185
+ rid: z34.string().min(1).max(100),
3186
+ to: z34.union([z34.object({ project: z34.string().min(1).max(80) }), z34.object({ sessions: z34.array(z34.string().min(1)).min(1).max(BROADCAST_SESSIONS_MAX) })]),
3187
+ text: z34.string().trim().min(1).max(MESSAGE_MAX),
3188
+ summary: z34.string().max(SUMMARY_MAX).optional(),
3159
3189
  /** How the recipients are told who it went to (« (à <label>) »), instead of the names: a project the fleet turned into sessions. */
3160
- label: z33.string().min(1).max(BROADCAST_LABEL_MAX).optional()
3190
+ label: z34.string().min(1).max(BROADCAST_LABEL_MAX).optional()
3191
+ }),
3192
+ /** `ledge read <id>`: a message's whole body, for its receiver or its sender (`by`, a session id or an external sender's id). */
3193
+ z34.object({
3194
+ type: z34.literal("message.read"),
3195
+ id: z34.string().min(1).max(40),
3196
+ by: z34.string().min(1),
3197
+ /** A program outside Ledge reading back what it sent (`ledge read <id> --from <name>`), `by` then being `externalId(name)`. */
3198
+ external: ExternalNameSchema.optional()
3161
3199
  }),
3162
- /** `ledge read <id>`: a message's whole body, for its receiver or its sender (`by`, a session id). */
3163
- z33.object({ type: z33.literal("message.read"), id: z33.string().min(1).max(40), by: z33.string().min(1) }),
3164
3200
  TaskCmdSchema,
3165
3201
  /** Reports (issue #9): the « Signaler » form's preview, creation and an agent's report ignored; `ledge report`. */
3166
3202
  ReportPreviewSchema,
@@ -3186,111 +3222,111 @@ var ClientMessageSchema = z33.discriminatedUnion("type", [
3186
3222
  ]);
3187
3223
 
3188
3224
  // ../../packages/protocol/src/relay.ts
3189
- import { z as z34 } from "zod";
3225
+ import { z as z35 } from "zod";
3190
3226
  var SEALED_MAX = 1048576;
3191
- var RelayPeerSchema = z34.union([z34.literal("pc"), z34.string().regex(/^d_[A-Za-z0-9_-]{16,40}$/)]);
3192
- var RelayClientMessageSchema = z34.object({
3193
- type: z34.literal("send"),
3227
+ var RelayPeerSchema = z35.union([z35.literal("pc"), z35.string().regex(/^d_[A-Za-z0-9_-]{16,40}$/)]);
3228
+ var RelayClientMessageSchema = z35.object({
3229
+ type: z35.literal("send"),
3194
3230
  to: RelayPeerSchema,
3195
- body: z34.string().max(SEALED_MAX)
3231
+ body: z35.string().max(SEALED_MAX)
3196
3232
  });
3197
- var RelayServerMessageSchema = z34.discriminatedUnion("type", [
3198
- z34.object({ type: z34.literal("welcome"), accountId: z34.string(), self: RelayPeerSchema, online: z34.array(RelayPeerSchema) }),
3199
- z34.object({ type: z34.literal("deliver"), from: RelayPeerSchema, body: z34.string() }),
3200
- z34.object({ type: z34.literal("presence"), peer: RelayPeerSchema, online: z34.boolean() }),
3233
+ var RelayServerMessageSchema = z35.discriminatedUnion("type", [
3234
+ z35.object({ type: z35.literal("welcome"), accountId: z35.string(), self: RelayPeerSchema, online: z35.array(RelayPeerSchema) }),
3235
+ z35.object({ type: z35.literal("deliver"), from: RelayPeerSchema, body: z35.string() }),
3236
+ z35.object({ type: z35.literal("presence"), peer: RelayPeerSchema, online: z35.boolean() }),
3201
3237
  /**
3202
3238
  * A frame was refused; `to` names the target when it is known.
3203
3239
  * Contract: an error concerning a sealed body (`offline`, `too_large`, or a socket closed with 4008
3204
3240
  * `rate_limited`) means that body was not delivered, so the sequence on that channel is lost: the
3205
3241
  * sender must re-handshake with that peer before sending to it again.
3206
3242
  */
3207
- z34.object({
3208
- type: z34.literal("error"),
3209
- code: z34.enum(["bad_frame", "too_large", "bad_target", "offline", "rate_limited"]),
3243
+ z35.object({
3244
+ type: z35.literal("error"),
3245
+ code: z35.enum(["bad_frame", "too_large", "bad_target", "offline", "rate_limited"]),
3210
3246
  to: RelayPeerSchema.optional()
3211
3247
  })
3212
3248
  ]);
3213
3249
  var PAIR_LABEL_MAX = 40;
3214
- var KeyB64 = z34.string().regex(/^[A-Za-z0-9_-]{87}$/);
3215
- var Nonce = z34.string().regex(/^[A-Za-z0-9_-]{43}$/);
3216
- var Fingerprint = z34.string().regex(/^[A-Za-z0-9_-]{22}$/);
3217
- var B64U = z34.string().regex(/^[A-Za-z0-9_-]*$/);
3218
- var RecoverWhySchema = z34.enum(["none", "old", "offline", "otherPc", "timeout", "revoked", "connected", "rate", "blocked", "failed"]);
3250
+ var KeyB64 = z35.string().regex(/^[A-Za-z0-9_-]{87}$/);
3251
+ var Nonce = z35.string().regex(/^[A-Za-z0-9_-]{43}$/);
3252
+ var Fingerprint = z35.string().regex(/^[A-Za-z0-9_-]{22}$/);
3253
+ var B64U = z35.string().regex(/^[A-Za-z0-9_-]*$/);
3254
+ var RecoverWhySchema = z35.enum(["none", "old", "offline", "otherPc", "timeout", "revoked", "connected", "rate", "blocked", "failed"]);
3219
3255
  var RecoverRefusalSchema = RecoverWhySchema.extract(["revoked", "connected", "rate", "blocked", "failed"]);
3220
- var ModelLabel = z34.string().trim().min(1).max(PAIR_LABEL_MAX);
3221
- var RecoverAssertion = z34.object({
3256
+ var ModelLabel = z35.string().trim().min(1).max(PAIR_LABEL_MAX);
3257
+ var RecoverAssertion = z35.object({
3222
3258
  id: B64U.max(1366),
3223
3259
  clientDataJSON: B64U.max(4096),
3224
3260
  authenticatorData: B64U.max(4096),
3225
3261
  signature: B64U.max(1024)
3226
3262
  }).strict();
3227
- var SealedFrameSchema = z34.discriminatedUnion("k", [
3263
+ var SealedFrameSchema = z35.discriminatedUnion("k", [
3228
3264
  /** `e` is the ephemeral key, `f` the fingerprint of the sender's static key. */
3229
- z34.object({ k: z34.literal("hello"), e: KeyB64, f: Fingerprint }),
3230
- z34.object({ k: z34.literal("msg"), s: z34.string() }),
3231
- z34.object({ k: z34.literal("pair_commit"), c: Nonce, label: z34.string().trim().min(1).max(PAIR_LABEL_MAX) }),
3232
- z34.object({ k: z34.literal("pair_offer"), pc: KeyB64, n: Nonce }),
3233
- z34.object({ k: z34.literal("pair_reveal"), d: KeyB64, n: Nonce }),
3234
- z34.object({ k: z34.literal("pair_ok") }),
3235
- z34.object({ k: z34.literal("pair_no") }),
3236
- z34.object({ k: z34.literal("denied") }),
3237
- z34.object({ k: z34.literal("rekey") }),
3265
+ z35.object({ k: z35.literal("hello"), e: KeyB64, f: Fingerprint }),
3266
+ z35.object({ k: z35.literal("msg"), s: z35.string() }),
3267
+ z35.object({ k: z35.literal("pair_commit"), c: Nonce, label: z35.string().trim().min(1).max(PAIR_LABEL_MAX) }),
3268
+ z35.object({ k: z35.literal("pair_offer"), pc: KeyB64, n: Nonce }),
3269
+ z35.object({ k: z35.literal("pair_reveal"), d: KeyB64, n: Nonce }),
3270
+ z35.object({ k: z35.literal("pair_ok") }),
3271
+ z35.object({ k: z35.literal("pair_no") }),
3272
+ z35.object({ k: z35.literal("denied") }),
3273
+ z35.object({ k: z35.literal("rekey") }),
3238
3274
  // ── Passkey recovery after a reinstall (unsealed, like pairing: nothing in them lets the relay act) ──
3239
3275
  /** Phone → PC: the app's new device key `d`, its nonce `n`, and what it runs on (`iPhone`, `iPad`), told to the PC as it is. */
3240
- z34.object({ k: z34.literal("recover_start"), d: KeyB64, n: Nonce, model: ModelLabel.optional() }),
3276
+ z35.object({ k: z35.literal("recover_start"), d: KeyB64, n: Nonce, model: ModelLabel.optional() }),
3241
3277
  /** PC → phone: its key `pc`, a one-use nonce `n` (60 s), and its name (`WSL`), for the phone's screens. */
3242
- z34.object({ k: z34.literal("recover_offer"), pc: KeyB64, n: Nonce, name: z34.string().max(PAIR_LABEL_MAX).optional() }),
3278
+ z35.object({ k: z35.literal("recover_offer"), pc: KeyB64, n: Nonce, name: z35.string().max(PAIR_LABEL_MAX).optional() }),
3243
3279
  /** Phone → PC: the discoverable assertion over `recoverChallenge(pc, d, pcNonce, n)`, and its `userHandle` (« L1 » ‖ digest ‖ random). */
3244
- z34.object({ k: z34.literal("recover_proof"), assertion: RecoverAssertion, userHandle: B64U.max(128) }),
3280
+ z35.object({ k: z35.literal("recover_proof"), assertion: RecoverAssertion, userHandle: B64U.max(128) }),
3245
3281
  /** PC → phone: the device is back under its new key; `name` the one it keeps. The phone pins the PC key, then says `hello`. */
3246
- z34.object({ k: z34.literal("recover_ok"), name: z34.string().max(PAIR_LABEL_MAX).optional() }),
3282
+ z35.object({ k: z35.literal("recover_ok"), name: z35.string().max(PAIR_LABEL_MAX).optional() }),
3247
3283
  /** PC → phone: refused. `device` the device the passkey names (`revoked`, `connected`); `revokedAt` when it was revoked (ISO,
3248
3284
  * `revoked` within 90 days); `retryInMs` until a recovery is taken again (`rate`). */
3249
- z34.object({
3250
- k: z34.literal("recover_no"),
3285
+ z35.object({
3286
+ k: z35.literal("recover_no"),
3251
3287
  why: RecoverRefusalSchema,
3252
- device: z34.string().max(PAIR_LABEL_MAX).optional(),
3253
- revokedAt: z34.string().datetime().optional(),
3254
- retryInMs: z34.number().int().min(0).optional()
3288
+ device: z35.string().max(PAIR_LABEL_MAX).optional(),
3289
+ revokedAt: z35.string().datetime().optional(),
3290
+ retryInMs: z35.number().int().min(0).optional()
3255
3291
  })
3256
3292
  ]);
3257
3293
 
3258
3294
  // ../../packages/protocol/src/relayAuth.ts
3259
- import { z as z35 } from "zod";
3295
+ import { z as z36 } from "zod";
3260
3296
  var RELAY_SESSION_COOKIE = "ledge_session";
3261
3297
  var RELAY_CLOSE_SIGNED_OUT = 4001;
3262
3298
  var RELAY_CLOSE_REPLACED = 4e3;
3263
3299
  var RELAY_CLOSE_RATE_LIMITED = 4008;
3264
- var DeviceStartResponseSchema = z35.object({
3265
- deviceCode: z35.string().min(1),
3266
- userCode: z35.string().min(1),
3267
- verificationUri: z35.string().min(1),
3268
- expiresIn: z35.number().int().positive(),
3269
- interval: z35.number().int().positive()
3270
- });
3271
- var DevicePollResponseSchema = z35.discriminatedUnion("status", [
3272
- z35.object({ status: z35.literal("pending") }),
3273
- z35.object({ status: z35.literal("slow_down"), interval: z35.number().int().positive() }),
3300
+ var DeviceStartResponseSchema = z36.object({
3301
+ deviceCode: z36.string().min(1),
3302
+ userCode: z36.string().min(1),
3303
+ verificationUri: z36.string().min(1),
3304
+ expiresIn: z36.number().int().positive(),
3305
+ interval: z36.number().int().positive()
3306
+ });
3307
+ var DevicePollResponseSchema = z36.discriminatedUnion("status", [
3308
+ z36.object({ status: z36.literal("pending") }),
3309
+ z36.object({ status: z36.literal("slow_down"), interval: z36.number().int().positive() }),
3274
3310
  /** `token` is the relay session token, shown this once only. */
3275
- z35.object({ status: z35.literal("ok"), token: z35.string().min(1), accountId: z35.string().min(1), login: z35.string().min(1) }),
3276
- z35.object({ status: z35.literal("expired") }),
3277
- z35.object({ status: z35.literal("denied") }),
3278
- z35.object({ status: z35.literal("not_allowed") })
3311
+ z36.object({ status: z36.literal("ok"), token: z36.string().min(1), accountId: z36.string().min(1), login: z36.string().min(1) }),
3312
+ z36.object({ status: z36.literal("expired") }),
3313
+ z36.object({ status: z36.literal("denied") }),
3314
+ z36.object({ status: z36.literal("not_allowed") })
3279
3315
  ]);
3280
- var DeviceRevokeResponseSchema = z35.object({ revoked: z35.number().int().min(0) });
3281
- var MeResponseSchema = z35.object({
3282
- accountId: z35.string().min(1),
3283
- login: z35.string().min(1),
3316
+ var DeviceRevokeResponseSchema = z36.object({ revoked: z36.number().int().min(0) });
3317
+ var MeResponseSchema = z36.object({
3318
+ accountId: z36.string().min(1),
3319
+ login: z36.string().min(1),
3284
3320
  peer: RelayPeerSchema,
3285
- kind: z35.enum(["pc", "device"])
3321
+ kind: z36.enum(["pc", "device"])
3286
3322
  });
3287
3323
 
3288
3324
  // ../../packages/protocol/src/phone.ts
3289
- import { z as z39 } from "zod";
3325
+ import { z as z40 } from "zod";
3290
3326
 
3291
3327
  // ../../packages/protocol/src/push.ts
3292
- import { z as z36 } from "zod";
3293
- var B64U2 = z36.string().regex(/^[A-Za-z0-9_-]*$/);
3328
+ import { z as z37 } from "zod";
3329
+ var B64U2 = z37.string().regex(/^[A-Za-z0-9_-]*$/);
3294
3330
  var PUSH_HOSTS = ["*.push.apple.com", "fcm.googleapis.com", "updates.push.services.mozilla.com", "*.notify.windows.com"];
3295
3331
  function pushEndpointAllowed(url2) {
3296
3332
  let u;
@@ -3307,43 +3343,43 @@ function pushEndpointAllowed(url2) {
3307
3343
  return host.length > suffix.length && host.endsWith(suffix);
3308
3344
  });
3309
3345
  }
3310
- var PushSendSchema = z36.object({
3311
- endpoint: z36.string().url().max(1024),
3346
+ var PushSendSchema = z37.object({
3347
+ endpoint: z37.string().url().max(1024),
3312
3348
  body: B64U2.max(5462),
3313
- ttl: z36.number().int().min(0).max(86400),
3314
- urgency: z36.enum(["normal", "high"]),
3315
- topic: z36.string().regex(/^[A-Za-z0-9_-]{1,32}$/)
3349
+ ttl: z37.number().int().min(0).max(86400),
3350
+ urgency: z37.enum(["normal", "high"]),
3351
+ topic: z37.string().regex(/^[A-Za-z0-9_-]{1,32}$/)
3316
3352
  });
3317
- var PushSendResultSchema = z36.object({
3318
- result: z36.enum(["sent", "gone", "failed"]),
3319
- status: z36.number().int().optional()
3353
+ var PushSendResultSchema = z37.object({
3354
+ result: z37.enum(["sent", "gone", "failed"]),
3355
+ status: z37.number().int().optional()
3320
3356
  });
3321
- var PushSubscriptionSchema = z36.object({
3322
- endpoint: z36.string().url().max(1024).refine(pushEndpointAllowed),
3323
- keys: z36.object({ p256dh: B64U2.length(87), auth: B64U2.length(22) })
3357
+ var PushSubscriptionSchema = z37.object({
3358
+ endpoint: z37.string().url().max(1024).refine(pushEndpointAllowed),
3359
+ keys: z37.object({ p256dh: B64U2.length(87), auth: B64U2.length(22) })
3324
3360
  });
3325
- var PushPayloadSchema = z36.object({
3326
- v: z36.literal(1),
3361
+ var PushPayloadSchema = z37.object({
3362
+ v: z37.literal(1),
3327
3363
  /** `resolved`: a request or question answered (anywhere), replacing its notification under the same tag; only sent to a
3328
3364
  * device whose subscription says its service worker knows it (`push.subscribe` `resolved`). `point`: the operator's point, one per
3329
3365
  * paired device (the body is its lead); it replaces `finished`, which stays in the schema for older daemons but is no longer sent. */
3330
- kind: z36.enum(["request", "question", "finished", "chat", "decision", "resolved", "point"]),
3331
- title: z36.string().max(80),
3366
+ kind: z37.enum(["request", "question", "finished", "chat", "decision", "resolved", "point"]),
3367
+ title: z37.string().max(80),
3332
3368
  /**
3333
3369
  * Who the notification is about, so the phone writes its own title in its language (Q29): the session's name for `request`,
3334
3370
  * `question` and `resolved`, the giver's for `decision`; none for `chat`. Optional: an older daemon sends none, and an
3335
3371
  * older phone ignores it and shows `title`.
3336
3372
  */
3337
- name: z36.string().max(100).optional(),
3338
- body: z36.string().max(120),
3339
- url: z36.string().regex(/^\/#\/[A-Za-z0-9/%._~-]*$/).max(300),
3340
- badge: z36.number().int().min(0).max(999),
3341
- tag: z36.string().regex(/^[A-Za-z0-9_-]{1,32}$/)
3373
+ name: z37.string().max(100).optional(),
3374
+ body: z37.string().max(120),
3375
+ url: z37.string().regex(/^\/#\/[A-Za-z0-9/%._~-]*$/).max(300),
3376
+ badge: z37.number().int().min(0).max(999),
3377
+ tag: z37.string().regex(/^[A-Za-z0-9_-]{1,32}$/)
3342
3378
  });
3343
3379
 
3344
3380
  // ../../packages/protocol/src/phoneRigs.ts
3345
- import { z as z37 } from "zod";
3346
- var PhoneRigErrorSchema = z37.enum(["unknown_rig", "not_installed", "daemon_stopped", "unavailable"]);
3381
+ import { z as z38 } from "zod";
3382
+ var PhoneRigErrorSchema = z38.enum(["unknown_rig", "not_installed", "daemon_stopped", "unavailable"]);
3347
3383
  var PHONE_RIG_TEXT_MAX = 500;
3348
3384
  var PHONE_RIGS_MAX = 50;
3349
3385
  var PHONE_RIG_SEATS_MAX = 200;
@@ -3353,61 +3389,61 @@ var PHONE_GOALS_MAX = 50;
3353
3389
  var PhoneRigSchema = RigSchema.omit({ specPath: true }).extend({ nodes: RigSchema.shape.nodes.max(PHONE_RIG_SEATS_MAX) });
3354
3390
  var PhoneOpenRigStateSchema = OpenRigStateSchema.extend({
3355
3391
  daemon: OpenRigStateSchema.shape.daemon.omit({ message: true, pid: true }),
3356
- rigs: z37.array(PhoneRigSchema).max(PHONE_RIGS_MAX)
3392
+ rigs: z38.array(PhoneRigSchema).max(PHONE_RIGS_MAX)
3357
3393
  });
3358
- var PhoneRigQueueRowSchema = RigRowSchema.extend({ summary: z37.string().max(PHONE_RIG_SUMMARY_MAX).optional() });
3359
- var PhoneRigRoutingSchema = RigRoutingEntrySchema.extend({ summary: z37.string().max(PHONE_RIG_SUMMARY_MAX).optional() });
3360
- var PhoneRigPermissionSchema = RigSeatPermissionSchema.extend({ summary: z37.string().max(PHONE_RIG_TEXT_MAX).optional(), error: z37.string().max(PHONE_RIG_TEXT_MAX).optional() });
3394
+ var PhoneRigQueueRowSchema = RigRowSchema.extend({ summary: z38.string().max(PHONE_RIG_SUMMARY_MAX).optional() });
3395
+ var PhoneRigRoutingSchema = RigRoutingEntrySchema.extend({ summary: z38.string().max(PHONE_RIG_SUMMARY_MAX).optional() });
3396
+ var PhoneRigPermissionSchema = RigSeatPermissionSchema.extend({ summary: z38.string().max(PHONE_RIG_TEXT_MAX).optional(), error: z38.string().max(PHONE_RIG_TEXT_MAX).optional() });
3361
3397
  var PhoneGoalSchema = GoalSchema;
3362
- var RigSeatCountsSchema = z37.record(RigRoleSchema, z37.number().int().min(0).max(9));
3363
- var PhoneRigRejectedSchema = z37.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]);
3398
+ var RigSeatCountsSchema = z38.record(RigRoleSchema, z38.number().int().min(0).max(9));
3399
+ var PhoneRigRejectedSchema = z38.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]);
3364
3400
 
3365
3401
  // ../../packages/protocol/src/phoneForge.ts
3366
- import { z as z38 } from "zod";
3402
+ import { z as z39 } from "zod";
3367
3403
  var PHONE_FORGE_PRS_MAX = 100;
3368
3404
  var PHONE_FORGE_FOLLOWED_MAX = 200;
3369
3405
  var PHONE_FORGE_MESSAGE_MAX = 500;
3370
3406
  var PhoneForgeStatusSchema = ForgeStatusSchema.omit({ message: true });
3371
- var PhoneForgeErrorSchema = z38.enum(["unavailable", "failed", "too_large"]);
3372
- var PhoneForgeActErrorSchema = z38.enum(["stale", "busy", "not_offered", "unavailable", "failed"]);
3373
- var PhoneForgeRejectedSchema = z38.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]);
3374
- var PhoneForgeStateSchema = z38.object({
3407
+ var PhoneForgeErrorSchema = z39.enum(["unavailable", "failed", "too_large"]);
3408
+ var PhoneForgeActErrorSchema = z39.enum(["stale", "busy", "not_offered", "unavailable", "failed"]);
3409
+ var PhoneForgeRejectedSchema = z39.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]);
3410
+ var PhoneForgeStateSchema = z39.object({
3375
3411
  /** Newest change first. A request whose forge, state or pipeline an older phone does not know is dropped, not the message. */
3376
- prs: z38.preprocess(dropUnknownPrs, z38.array(PullRequestSchema).max(PHONE_FORGE_PRS_MAX)),
3377
- forges: z38.preprocess(dropUnknownForges, z38.array(PhoneForgeStatusSchema).max(20)),
3378
- followed: z38.preprocess(dropUnknownForges, z38.array(FollowedSessionSchema).max(PHONE_FORGE_FOLLOWED_MAX)),
3412
+ prs: z39.preprocess(dropUnknownPrs, z39.array(PullRequestSchema).max(PHONE_FORGE_PRS_MAX)),
3413
+ forges: z39.preprocess(dropUnknownForges, z39.array(PhoneForgeStatusSchema).max(20)),
3414
+ followed: z39.preprocess(dropUnknownForges, z39.array(FollowedSessionSchema).max(PHONE_FORGE_FOLLOWED_MAX)),
3379
3415
  /** The account's own requests no session follows (issue #3), newest change first; absent from an older daemon. */
3380
- mine: z38.preprocess(dropUnknownPrs, z38.array(PullRequestSchema).max(PHONE_FORGE_PRS_MAX)).optional()
3416
+ mine: z39.preprocess(dropUnknownPrs, z39.array(PullRequestSchema).max(PHONE_FORGE_PRS_MAX)).optional()
3381
3417
  });
3382
3418
 
3383
3419
  // ../../packages/protocol/src/phone.ts
3384
3420
  var PHONE_ROW_SUMMARY_MAX = 200;
3385
- var PhoneRigRowSchema = RigRowSchema.extend({ summary: z39.string().max(PHONE_ROW_SUMMARY_MAX).optional() });
3386
- var PhoneRowErrorSchema = z39.enum(["not_found", "unavailable"]);
3421
+ var PhoneRigRowSchema = RigRowSchema.extend({ summary: z40.string().max(PHONE_ROW_SUMMARY_MAX).optional() });
3422
+ var PhoneRowErrorSchema = z40.enum(["not_found", "unavailable"]);
3387
3423
  var PHONE_PROTOCOL = 1;
3388
3424
  var utf8 = new TextEncoder();
3389
3425
  var THREAD_TEXT_MAX = 8192;
3390
3426
  var TOOL_TEXT_MAX = 2048;
3391
3427
  var CHECKLIST_TASKS_MAX = 50;
3392
3428
  var CHECKLIST_TEXT_MAX = 200;
3393
- var ChecklistStatusSchema = z39.enum(["pending", "in_progress", "completed"]);
3394
- var PhoneChecklistSchema = z39.object({
3395
- tasks: z39.array(z39.object({ text: z39.string().max(CHECKLIST_TEXT_MAX), status: ChecklistStatusSchema })).max(CHECKLIST_TASKS_MAX),
3396
- done: z39.number().int().nonnegative(),
3397
- total: z39.number().int().nonnegative(),
3398
- cut: z39.literal(true).optional()
3399
- });
3400
- var PhoneChecklistSummarySchema = z39.object({
3401
- done: z39.number().int().nonnegative(),
3402
- total: z39.number().int().nonnegative(),
3403
- current: z39.string().max(CHECKLIST_TEXT_MAX).optional(),
3404
- cut: z39.literal(true).optional()
3405
- });
3406
- var RiskSchema = z39.enum(["low", "high"]);
3407
- var RiskReasonSchema = z39.enum(["question", "read_only_command", "edit_inside_folder", "pushes", "destroys", "deploys", "publishes", "pipes_to_shell", "network", "writes_outside_folder", "sensitive_path", "unsafe_flag", "shell_syntax", "script", "plan", "unknown"]);
3408
- var OperationIdSchema = z39.string().uuid();
3409
- var OperationStatusSchema = z39.enum(["received", "applied", "rejected", "failed"]);
3410
- var OperationReasonSchema = z39.enum([
3429
+ var ChecklistStatusSchema = z40.enum(["pending", "in_progress", "completed"]);
3430
+ var PhoneChecklistSchema = z40.object({
3431
+ tasks: z40.array(z40.object({ text: z40.string().max(CHECKLIST_TEXT_MAX), status: ChecklistStatusSchema })).max(CHECKLIST_TASKS_MAX),
3432
+ done: z40.number().int().nonnegative(),
3433
+ total: z40.number().int().nonnegative(),
3434
+ cut: z40.literal(true).optional()
3435
+ });
3436
+ var PhoneChecklistSummarySchema = z40.object({
3437
+ done: z40.number().int().nonnegative(),
3438
+ total: z40.number().int().nonnegative(),
3439
+ current: z40.string().max(CHECKLIST_TEXT_MAX).optional(),
3440
+ cut: z40.literal(true).optional()
3441
+ });
3442
+ var RiskSchema = z40.enum(["low", "high"]);
3443
+ var RiskReasonSchema = z40.enum(["question", "read_only_command", "edit_inside_folder", "pushes", "destroys", "deploys", "publishes", "pipes_to_shell", "network", "writes_outside_folder", "sensitive_path", "unsafe_flag", "shell_syntax", "script", "plan", "unknown"]);
3444
+ var OperationIdSchema = z40.string().uuid();
3445
+ var OperationStatusSchema = z40.enum(["received", "applied", "rejected", "failed"]);
3446
+ var OperationReasonSchema = z40.enum([
3411
3447
  ...RefusalCodeSchema.options,
3412
3448
  "untypable",
3413
3449
  "confirm_required",
@@ -3428,19 +3464,19 @@ var OperationReasonSchema = z39.enum([
3428
3464
  "resume_failed",
3429
3465
  "cancelled"
3430
3466
  ]);
3431
- var CapabilitiesSchema = z39.object({
3467
+ var CapabilitiesSchema = z40.object({
3432
3468
  /** A question can be answered in free text. */
3433
- freeTextAnswer: z39.boolean(),
3469
+ freeTextAnswer: z40.boolean(),
3434
3470
  /** The session's accept/deny can be typed; absent = true. */
3435
- decide: z39.boolean().optional(),
3471
+ decide: z40.boolean().optional(),
3436
3472
  /** OMP's dialog questions can be answered from the phone; absent = false. */
3437
- questions: z39.boolean().optional()
3473
+ questions: z40.boolean().optional()
3438
3474
  });
3439
- var CapabilitiesByToolSchema = z39.object({ claude: CapabilitiesSchema, codex: CapabilitiesSchema, cursor: CapabilitiesSchema, omp: CapabilitiesSchema });
3440
- var PhonePendingSchema = PendingSchema.extend({ key: z39.string().max(64), risk: RiskSchema, riskReason: RiskReasonSchema, cut: z39.literal(true).optional() });
3441
- var SwitchableSessionSchema = SessionSchema.extend({ canSwitch: z39.literal(true).optional() });
3442
- var PhoneProjectSchema = z39.object({ id: ProjectIdSchema, name: z39.string().max(80), color: ProjectColorSchema });
3443
- var PhoneSessionOrderSchema = z39.record(z39.string().max(64), z39.array(z39.string().max(200)).max(SESSION_ORDER_MAX));
3475
+ var CapabilitiesByToolSchema = z40.object({ claude: CapabilitiesSchema, codex: CapabilitiesSchema, cursor: CapabilitiesSchema, omp: CapabilitiesSchema });
3476
+ var PhonePendingSchema = PendingSchema.extend({ key: z40.string().max(64), risk: RiskSchema, riskReason: RiskReasonSchema, cut: z40.literal(true).optional() });
3477
+ var SwitchableSessionSchema = SessionSchema.extend({ canSwitch: z40.literal(true).optional() });
3478
+ var PhoneProjectSchema = z40.object({ id: ProjectIdSchema, name: z40.string().max(80), color: ProjectColorSchema });
3479
+ var PhoneSessionOrderSchema = z40.record(z40.string().max(64), z40.array(z40.string().max(200)).max(SESSION_ORDER_MAX));
3444
3480
  var PHONE_PROJECTS_MAX = 100;
3445
3481
  var PHONE_RIG_NAME_MAX = 100;
3446
3482
  var PhoneSessionSchema = SwitchableSessionSchema.pick({
@@ -3476,114 +3512,114 @@ var PhoneSessionSchema = SwitchableSessionSchema.pick({
3476
3512
  closedHow: true
3477
3513
  }).extend({
3478
3514
  /** What it is running now (« pnpm --filter desktop test »), `doingOf` on the PC: the list row and « En cours ». Older phones drop the field. */
3479
- doing: z39.object({ tool: z39.string().max(DOING_TOOL_MAX), label: z39.string().max(DOING_LABEL_MAX), since: z39.string().datetime() }).optional(),
3515
+ doing: z40.object({ tool: z40.string().max(DOING_TOOL_MAX), label: z40.string().max(DOING_LABEL_MAX), since: z40.string().datetime() }).optional(),
3480
3516
  pending: PhonePendingSchema.optional(),
3481
- unread: z39.boolean(),
3482
- handover: z39.object({ state: HandoverStateSchema, toName: z39.string().max(80).optional() }).strict().optional(),
3517
+ unread: z40.boolean(),
3518
+ handover: z40.object({ state: HandoverStateSchema, toName: z40.string().max(80).optional() }).strict().optional(),
3483
3519
  /** Absent: the agent has no checklist. */
3484
3520
  checklist: PhoneChecklistSummarySchema.optional(),
3485
3521
  /** Started without Ledge (`hook_only`): the phone can neither close nor resume it. */
3486
- readOnly: z39.literal(true).optional(),
3522
+ readOnly: z40.literal(true).optional(),
3487
3523
  /** « Rattacher à Ledge » on a read-only session: what it would do (`adoptPlan`, spec 2026-12-01 rattacher §3.3); absent, not offered. */
3488
- adopt: z39.enum(["pane", "resume", "not_located"]).optional(),
3524
+ adopt: z40.enum(["pane", "resume", "not_located"]).optional(),
3489
3525
  /** A « Rattacher à Ledge » under way: its step. */
3490
- adopting: z39.object({ step: AdoptStepSchema }).strict().optional(),
3526
+ adopting: z40.object({ step: AdoptStepSchema }).strict().optional(),
3491
3527
  /** Its room in the Atelier (`daemon.atelier`): the user's project it belongs to, placed by the PC as the desktop places it; absent: none (« Sans projet »). */
3492
3528
  projectId: ProjectIdSchema.optional(),
3493
3529
  /** The OpenRig seat it is (`daemon.atelier`): its rig and its role once OpenRig named it. Never the seat's folder. */
3494
- rig: z39.object({ name: z39.string().max(PHONE_RIG_NAME_MAX), role: z39.string().max(PHONE_RIG_NAME_MAX).optional() }).optional()
3530
+ rig: z40.object({ name: z40.string().max(PHONE_RIG_NAME_MAX), role: z40.string().max(PHONE_RIG_NAME_MAX).optional() }).optional()
3495
3531
  });
3496
- var B64U3 = z39.string().regex(/^[A-Za-z0-9_-]*$/);
3497
- var CredentialSchema = z39.object({
3532
+ var B64U3 = z40.string().regex(/^[A-Za-z0-9_-]*$/);
3533
+ var CredentialSchema = z40.object({
3498
3534
  id: B64U3.max(1366),
3499
3535
  publicKey: B64U3.max(2048),
3500
- alg: z39.union([z39.literal(-7), z39.literal(-257)]),
3536
+ alg: z40.union([z40.literal(-7), z40.literal(-257)]),
3501
3537
  clientDataJSON: B64U3.max(4096),
3502
3538
  authenticatorData: B64U3.max(4096),
3503
- transports: z39.array(z39.string().max(20)).max(8).optional()
3539
+ transports: z40.array(z40.string().max(20)).max(8).optional()
3504
3540
  });
3505
- var AssertionSchema = z39.object({
3541
+ var AssertionSchema = z40.object({
3506
3542
  id: B64U3.max(1366),
3507
3543
  clientDataJSON: B64U3.max(4096),
3508
3544
  authenticatorData: B64U3.max(4096),
3509
3545
  signature: B64U3.max(1024)
3510
3546
  });
3511
- var ConfirmPurposeSchema = z39.enum(["register", "decide", "launch", "close", "act", "pc", "terminal", "rig", "note", "project", "folder", "rigs", "forge", "routine", "decision"]);
3547
+ var ConfirmPurposeSchema = z40.enum(["register", "decide", "launch", "close", "act", "pc", "terminal", "rig", "note", "project", "folder", "rigs", "forge", "routine", "decision"]);
3512
3548
  var PhoneChatStepSchema = ChatStepSchema.pick({ kind: true, id: true, name: true }).strict();
3513
- var PhoneChatProposalSchema = z39.object({
3514
- project: z39.string().max(80),
3549
+ var PhoneChatProposalSchema = z40.object({
3550
+ project: z40.string().max(80),
3515
3551
  tool: ToolSchema,
3516
- prompt: z39.string().max(TOOL_TEXT_MAX).optional(),
3517
- launchedId: z39.string().optional(),
3518
- failed: z39.literal(true).optional()
3552
+ prompt: z40.string().max(TOOL_TEXT_MAX).optional(),
3553
+ launchedId: z40.string().optional(),
3554
+ failed: z40.literal(true).optional()
3519
3555
  }).strict();
3520
- var PhoneChatRelaySchema = z39.object({
3521
- id: z39.string().min(1),
3522
- name: z39.string(),
3556
+ var PhoneChatRelaySchema = z40.object({
3557
+ id: z40.string().min(1),
3558
+ name: z40.string(),
3523
3559
  tool: ToolSchema,
3524
- text: z39.string().max(TOOL_TEXT_MAX),
3525
- status: z39.enum(["queued", "sent"]).optional(),
3526
- sentAt: z39.string().datetime().optional(),
3527
- failed: z39.literal(true).optional(),
3560
+ text: z40.string().max(TOOL_TEXT_MAX),
3561
+ status: z40.enum(["queued", "sent"]).optional(),
3562
+ sentAt: z40.string().datetime().optional(),
3563
+ failed: z40.literal(true).optional(),
3528
3564
  /** With `failed`: why, as the PC's code (never its text). */
3529
- code: z39.string().max(40).optional()
3565
+ code: z40.string().max(40).optional()
3530
3566
  }).strict();
3531
- var CloseHowSchema = z39.enum(["exit", "killed"]);
3532
- var PhoneChatCloseSchema = z39.object({
3533
- id: z39.string().min(1),
3534
- name: z39.string(),
3567
+ var CloseHowSchema = z40.enum(["exit", "killed"]);
3568
+ var PhoneChatCloseSchema = z40.object({
3569
+ id: z40.string().min(1),
3570
+ name: z40.string(),
3535
3571
  tool: ToolSchema,
3536
3572
  how: CloseHowSchema.optional(),
3537
- closedAt: z39.string().datetime().optional(),
3538
- failed: z39.literal(true).optional()
3573
+ closedAt: z40.string().datetime().optional(),
3574
+ failed: z40.literal(true).optional()
3539
3575
  }).strict();
3540
- var PhoneChatTaskSchema = z39.object({
3541
- to: z39.string().max(80),
3542
- toName: z39.string().max(80).optional(),
3543
- title: z39.string().max(200),
3544
- text: z39.string().max(TOOL_TEXT_MAX).optional(),
3545
- taskId: z39.string().max(40).optional(),
3546
- ownerName: z39.string().max(80).optional(),
3547
- state: z39.enum(["open", "taken", "done", "refused", "dropped"]).optional(),
3548
- failed: z39.literal(true).optional()
3576
+ var PhoneChatTaskSchema = z40.object({
3577
+ to: z40.string().max(80),
3578
+ toName: z40.string().max(80).optional(),
3579
+ title: z40.string().max(200),
3580
+ text: z40.string().max(TOOL_TEXT_MAX).optional(),
3581
+ taskId: z40.string().max(40).optional(),
3582
+ ownerName: z40.string().max(80).optional(),
3583
+ state: z40.enum(["open", "taken", "done", "refused", "dropped"]).optional(),
3584
+ failed: z40.literal(true).optional()
3549
3585
  }).strict();
3550
- var PhoneChatActionSchema = z39.object({
3551
- action: z39.string().min(1).max(40),
3552
- summary: z39.string().max(300),
3586
+ var PhoneChatActionSchema = z40.object({
3587
+ action: z40.string().min(1).max(40),
3588
+ summary: z40.string().max(300),
3553
3589
  vars: ActionVarsSchema.optional(),
3554
- detail: z39.string().max(TOOL_TEXT_MAX).optional(),
3555
- detailCut: z39.literal(true).optional(),
3590
+ detail: z40.string().max(TOOL_TEXT_MAX).optional(),
3591
+ detailCut: z40.literal(true).optional(),
3556
3592
  risk: ActionRiskSchema,
3557
- session: z39.string().max(100).optional(),
3593
+ session: z40.string().max(100).optional(),
3558
3594
  state: ChatActionStateSchema.optional(),
3559
- doneAt: z39.string().datetime().optional(),
3560
- code: z39.string().max(40).optional()
3595
+ doneAt: z40.string().datetime().optional(),
3596
+ code: z40.string().max(40).optional()
3561
3597
  }).strict();
3562
- var PhoneTaskSchema = z39.object({
3563
- id: z39.string().max(40),
3564
- title: z39.string().max(200),
3565
- owner: z39.string().max(100),
3566
- ownerName: z39.string().max(80),
3598
+ var PhoneTaskSchema = z40.object({
3599
+ id: z40.string().max(40),
3600
+ title: z40.string().max(200),
3601
+ owner: z40.string().max(100),
3602
+ ownerName: z40.string().max(80),
3567
3603
  /** Who gave it: `ledge` for Ledge's own; a session for a decision it put to the user (owner `ledge`), with its detail (the options). */
3568
- giver: z39.string().max(100).optional(),
3569
- giverName: z39.string().max(80).optional(),
3570
- text: z39.string().max(TOOL_TEXT_MAX).optional(),
3571
- state: z39.enum(["open", "taken", "done", "refused", "dropped"]),
3572
- result: z39.string().max(TOOL_TEXT_MAX).optional(),
3573
- cut: z39.literal(true).optional(),
3574
- at: z39.string(),
3575
- updatedAt: z39.string(),
3576
- seen: z39.literal(true).optional(),
3604
+ giver: z40.string().max(100).optional(),
3605
+ giverName: z40.string().max(80).optional(),
3606
+ text: z40.string().max(TOOL_TEXT_MAX).optional(),
3607
+ state: z40.enum(["open", "taken", "done", "refused", "dropped"]),
3608
+ result: z40.string().max(TOOL_TEXT_MAX).optional(),
3609
+ cut: z40.literal(true).optional(),
3610
+ at: z40.string(),
3611
+ updatedAt: z40.string(),
3612
+ seen: z40.literal(true).optional(),
3577
3613
  /** A proposal about the user's notes (brain spec §3.6): the phone answers it with its buttons (`brain.answer`). */
3578
3614
  brain: BrainProposalSchema.optional(),
3579
3615
  /** A routine's item (routines spec): an activation request the phone answers with `routine.cmd` (`approve` / `refuse`), or a failure (`run`). */
3580
3616
  routine: TaskRoutineSchema.optional()
3581
3617
  }).strict();
3582
- var PhoneRoutineRefSchema = z39.object({ routine: RoutineIdSchema, routineKey: RoutineKeySchema }).strict();
3618
+ var PhoneRoutineRefSchema = z40.object({ routine: RoutineIdSchema, routineKey: RoutineKeySchema }).strict();
3583
3619
  var PhoneRoutineSchema = RoutineSchema.omit({ prompt: true, target: true, runs: true, proposal: true }).extend({
3584
- target: RoutineTargetSchema.extend({ cwd: z39.string().min(1).max(PHONE_ROUTINE_CWD_MAX) }),
3585
- cut: z39.literal(true).optional(),
3586
- proposed: z39.literal(true).optional(),
3620
+ target: RoutineTargetSchema.extend({ cwd: z40.string().min(1).max(PHONE_ROUTINE_CWD_MAX) }),
3621
+ cut: z40.literal(true).optional(),
3622
+ proposed: z40.literal(true).optional(),
3587
3623
  key: RoutineKeySchema
3588
3624
  });
3589
3625
  var PhoneRoutineDetailSchema = PhoneRoutineSchema.omit({ cut: true, proposed: true }).extend({
@@ -3592,111 +3628,111 @@ var PhoneRoutineDetailSchema = PhoneRoutineSchema.omit({ cut: true, proposed: tr
3592
3628
  proposal: RoutineSchema.shape.proposal,
3593
3629
  runs: RoutineSchema.shape.runs
3594
3630
  });
3595
- var ChatErrorCodeSchema = z39.enum(["busy", "timeout", "cancelled", "failed"]);
3596
- var ChatLimitsReadSchema = z39.object({ qid: OperationIdSchema, at: z39.string().datetime() }).strict();
3597
- var ChatConversationSummarySchema = z39.object({
3598
- id: z39.string().uuid(),
3599
- startedAt: z39.string().datetime(),
3600
- lastAt: z39.string().datetime(),
3601
- first: z39.string().max(200),
3602
- count: z39.number().int().min(1)
3631
+ var ChatErrorCodeSchema = z40.enum(["busy", "timeout", "cancelled", "failed"]);
3632
+ var ChatLimitsReadSchema = z40.object({ qid: OperationIdSchema, at: z40.string().datetime() }).strict();
3633
+ var ChatConversationSummarySchema = z40.object({
3634
+ id: z40.string().uuid(),
3635
+ startedAt: z40.string().datetime(),
3636
+ lastAt: z40.string().datetime(),
3637
+ first: z40.string().max(200),
3638
+ count: z40.number().int().min(1)
3603
3639
  }).strict();
3604
- var PhoneChatTurnSchema = z39.object({
3640
+ var PhoneChatTurnSchema = z40.object({
3605
3641
  qid: OperationIdSchema,
3606
- question: z39.string().max(MESSAGE_MAX),
3607
- askedAt: z39.string().datetime(),
3608
- steps: z39.array(PhoneChatStepSchema).max(50),
3609
- answer: z39.string().max(THREAD_TEXT_MAX).optional(),
3610
- answeredAt: z39.string().datetime().optional(),
3642
+ question: z40.string().max(MESSAGE_MAX),
3643
+ askedAt: z40.string().datetime(),
3644
+ steps: z40.array(PhoneChatStepSchema).max(50),
3645
+ answer: z40.string().max(THREAD_TEXT_MAX).optional(),
3646
+ answeredAt: z40.string().datetime().optional(),
3611
3647
  error: ChatErrorCodeSchema.optional(),
3612
- proposals: z39.array(PhoneChatProposalSchema).max(MAX_PROPOSALS).optional(),
3648
+ proposals: z40.array(PhoneChatProposalSchema).max(MAX_PROPOSALS).optional(),
3613
3649
  relay: PhoneChatRelaySchema.optional(),
3614
- closes: z39.array(PhoneChatCloseSchema).min(1).max(MAX_PROPOSALS).optional(),
3615
- cut: z39.literal(true).optional(),
3616
- tasks: z39.array(PhoneChatTaskSchema).min(1).max(MAX_PROPOSALS).optional(),
3617
- actions: z39.array(PhoneChatActionSchema).min(1).max(MAX_PROPOSALS).optional(),
3618
- ignoredAt: z39.string().datetime().optional(),
3619
- attachments: z39.array(AttachmentRefSchema).max(ATTACHMENTS_MAX).optional(),
3620
- by: z39.literal("ledge").optional(),
3650
+ closes: z40.array(PhoneChatCloseSchema).min(1).max(MAX_PROPOSALS).optional(),
3651
+ cut: z40.literal(true).optional(),
3652
+ tasks: z40.array(PhoneChatTaskSchema).min(1).max(MAX_PROPOSALS).optional(),
3653
+ actions: z40.array(PhoneChatActionSchema).min(1).max(MAX_PROPOSALS).optional(),
3654
+ ignoredAt: z40.string().datetime().optional(),
3655
+ attachments: z40.array(AttachmentRefSchema).max(ATTACHMENTS_MAX).optional(),
3656
+ by: z40.literal("ledge").optional(),
3621
3657
  point: ChatPointSchema.optional()
3622
3658
  }).strict();
3623
- var sessionId = z39.string().min(1).max(100);
3624
- var PhoneExpectSchema = PendingSchema.pick({ kind: true, text: true }).extend({ key: z39.string().min(1).max(64) });
3625
- var CardRowsSchema = z39.array(z39.number().int().min(0).max(MAX_PROPOSALS - 1)).min(1).max(MAX_PROPOSALS).refine((r) => new Set(r).size === r.length, "a row twice");
3659
+ var sessionId = z40.string().min(1).max(100);
3660
+ var PhoneExpectSchema = PendingSchema.pick({ kind: true, text: true }).extend({ key: z40.string().min(1).max(64) });
3661
+ var CardRowsSchema = z40.array(z40.number().int().min(0).max(MAX_PROPOSALS - 1)).min(1).max(MAX_PROPOSALS).refine((r) => new Set(r).size === r.length, "a row twice");
3626
3662
  var pcOp = { op: OperationIdSchema, assertion: AssertionSchema.optional() };
3627
3663
  var PHONE_LAUNCH_FOLDERS_MAX = 20;
3628
- var PhoneLaunchSchema = z39.object({
3664
+ var PhoneLaunchSchema = z40.object({
3629
3665
  project: ProjectIdSchema,
3630
3666
  tool: ToolSchema,
3631
- folders: z39.array(FolderPathSchema).min(1).max(PHONE_LAUNCH_FOLDERS_MAX),
3632
- prompt: z39.string().trim().min(1).max(MESSAGE_MAX),
3667
+ folders: z40.array(FolderPathSchema).min(1).max(PHONE_LAUNCH_FOLDERS_MAX),
3668
+ prompt: z40.string().trim().min(1).max(MESSAGE_MAX),
3633
3669
  model: ModelIdSchema.optional(),
3634
3670
  effort: EffortSchema.optional(),
3635
3671
  approval: OmpApprovalSchema.optional(),
3636
3672
  /** Issue #15: the session's name (its address), cleaned as every name; taken: refused `name_taken`. Absent: the first free one. */
3637
- name: z39.string().max(200).optional()
3673
+ name: z40.string().max(200).optional()
3638
3674
  }).strict();
3639
- var PcActionSchema = z39.enum(["update", "restart"]);
3675
+ var PcActionSchema = z40.enum(["update", "restart"]);
3640
3676
  var PHONE_FOLDER_ENTRIES_MAX = 500;
3641
- var PhoneFolderErrorSchema = z39.enum(["not_found", "not_folder", "unreadable"]);
3642
- var PhoneFolderSchema = z39.object({
3677
+ var PhoneFolderErrorSchema = z40.enum(["not_found", "not_folder", "unreadable"]);
3678
+ var PhoneFolderSchema = z40.object({
3643
3679
  machine: MachineIdSchema,
3644
- label: z39.string().max(80).optional(),
3680
+ label: z40.string().max(80).optional(),
3645
3681
  path: FolderPathSchema,
3646
- exists: z39.boolean().optional(),
3647
- branch: z39.string().max(200).nullable().optional()
3682
+ exists: z40.boolean().optional(),
3683
+ branch: z40.string().max(200).nullable().optional()
3648
3684
  });
3649
3685
  var PHONE_RECENT_FOLDERS_MAX = 20;
3650
- var TerminalIdSchema = z39.string().regex(/^t_[A-Za-z0-9_-]{8,40}$/);
3686
+ var TerminalIdSchema = z40.string().regex(/^t_[A-Za-z0-9_-]{8,40}$/);
3651
3687
  var TERM_INPUT_MAX = 4096;
3652
3688
  var TERM_SCREEN_MAX = 65536;
3653
3689
  var TERM_OUTPUT_MAX = 32768;
3654
- var TermDimSchema = z39.number().int().min(1).max(1e4);
3655
- var TermReleaseWhySchema = z39.enum(["asked", "pc", "idle", "expired", "background", "link"]);
3656
- var TermExitWhySchema = z39.enum(["ended", "gone", "closed", "superseded", "failed"]);
3657
- var DevicePrefsSchema = z39.object({
3658
- notify: z39.object({
3690
+ var TermDimSchema = z40.number().int().min(1).max(1e4);
3691
+ var TermReleaseWhySchema = z40.enum(["asked", "pc", "idle", "expired", "background", "link"]);
3692
+ var TermExitWhySchema = z40.enum(["ended", "gone", "closed", "superseded", "failed"]);
3693
+ var DevicePrefsSchema = z40.object({
3694
+ notify: z40.object({
3659
3695
  /** « Le point de Ledge » (the key keeps its first name, « Agent terminé »): the operator's point. */
3660
- finished: z39.boolean(),
3696
+ finished: z40.boolean(),
3661
3697
  /** « Réponse de Ledge »: the end of a question asked from this device. */
3662
- chat: z39.boolean(),
3698
+ chat: z40.boolean(),
3663
3699
  /** « Décision à prendre »: a session puts a decision to the user. */
3664
- decision: z39.boolean()
3700
+ decision: z40.boolean()
3665
3701
  }),
3666
3702
  /** No notification before this moment (a `resolved` still replaces one already shown); null: no pause. */
3667
- quietUntil: z39.string().datetime().nullable(),
3703
+ quietUntil: z40.string().datetime().nullable(),
3668
3704
  /** The agent of this device's chat with Ledge; null: the PC's (the one its own chat last used). */
3669
3705
  chatTool: ToolSchema.nullable()
3670
3706
  });
3671
- var PhoneClientMessageSchema = z39.discriminatedUnion("type", [
3672
- z39.object({ type: z39.literal("snapshot.request") }),
3673
- z39.object({ type: z39.literal("session.thread"), id: sessionId }),
3707
+ var PhoneClientMessageSchema = z40.discriminatedUnion("type", [
3708
+ z40.object({ type: z40.literal("snapshot.request") }),
3709
+ z40.object({ type: z40.literal("session.thread"), id: sessionId }),
3674
3710
  /** The session's request with its whole body (up to `PENDING_BODY_MAX`). */
3675
- z39.object({ type: z39.literal("session.pending"), id: sessionId }),
3711
+ z40.object({ type: z40.literal("session.pending"), id: sessionId }),
3676
3712
  /** The session whose terminal the phone shows; null when it shows none. */
3677
- z39.object({ type: z39.literal("session.watch"), id: sessionId.nullable() }),
3678
- z39.object({ type: z39.literal("session.read"), id: sessionId, at: z39.string().datetime() }),
3713
+ z40.object({ type: z40.literal("session.watch"), id: sessionId.nullable() }),
3714
+ z40.object({ type: z40.literal("session.read"), id: sessionId, at: z40.string().datetime() }),
3679
3715
  /**
3680
3716
  * Asks for a challenge. One object for every purpose: the gateway refuses a `decide` without `id` and `expect`. A `close`
3681
3717
  * or `act` names a turn of the chat (`qid`) or a session (`id`, for `session.close` and `session.resume`).
3682
3718
  */
3683
- z39.object({
3684
- type: z39.literal("confirm.prepare"),
3719
+ z40.object({
3720
+ type: z40.literal("confirm.prepare"),
3685
3721
  purpose: ConfirmPurposeSchema,
3686
3722
  id: sessionId.optional(),
3687
3723
  expect: PhoneExpectSchema.optional(),
3688
3724
  qid: OperationIdSchema.optional(),
3689
3725
  /** A `pc` challenge: what it is for, and for an update the version it covers. */
3690
3726
  action: PcActionSchema.optional(),
3691
- version: z39.string().regex(SEMVER).optional(),
3727
+ version: z40.string().regex(SEMVER).optional(),
3692
3728
  /** A `rig` challenge: the OpenRig row and the exact answer it covers. */
3693
- qitem: z39.string().min(1).max(200).optional(),
3729
+ qitem: z40.string().min(1).max(200).optional(),
3694
3730
  answer: HumanAnswerSchema.optional(),
3695
3731
  /** A `note` challenge: the proposal (a task) and the exact choice it covers. */
3696
- task: z39.string().min(1).max(40).optional(),
3732
+ task: z40.string().min(1).max(40).optional(),
3697
3733
  choice: BrainChoiceSchema.optional(),
3698
3734
  /** A `decision` challenge (#40): the decision (`task`) and the exact answer it covers, as `task.answer` will send it. */
3699
- taskAnswer: z39.string().trim().min(1).max(TASK_TEXT_MAX).optional(),
3735
+ taskAnswer: z40.string().trim().min(1).max(TASK_TEXT_MAX).optional(),
3700
3736
  /** A `project` challenge: the project deleted and where its agents go (null: no project). */
3701
3737
  project: ProjectIdSchema.optional(),
3702
3738
  moveTo: ProjectIdSchema.nullable().optional(),
@@ -3706,79 +3742,79 @@ var PhoneClientMessageSchema = z39.discriminatedUnion("type", [
3706
3742
  newProject: ProjectNameSchema.optional(),
3707
3743
  /** A `rigs` challenge: the action (`rigAct`) or the change of seats (`rigSeats`) it covers, exactly as it will be sent. */
3708
3744
  rigAct: OpenRigActionSchema.optional(),
3709
- rigSeats: z39.object({ rig: RigNameSchema, seats: RigSeatCountsSchema }).strict().optional(),
3745
+ rigSeats: z40.object({ rig: RigNameSchema, seats: RigSeatCountsSchema }).strict().optional(),
3710
3746
  /** An `act` challenge for a point row (`qid` and `item`): bound to that row and to its `pointAnswer`, or to its suggestion when `suggest`. */
3711
- item: z39.string().min(1).max(200).optional(),
3747
+ item: z40.string().min(1).max(200).optional(),
3712
3748
  pointAnswer: PointAnswerSchema.optional(),
3713
- suggest: z39.literal(true).optional(),
3749
+ suggest: z40.literal(true).optional(),
3714
3750
  /** A `launch` challenge without `qid`: the « Nouvelle session » it covers, exactly as it will be sent. */
3715
3751
  launch: PhoneLaunchSchema.optional(),
3716
3752
  /** A `forge` challenge: the request and the action it covers, exactly as they will be sent. */
3717
- forge: z39.object({ prId: z39.string().min(1).max(500), action: ForgeActionSchema }).strict().optional(),
3753
+ forge: z40.object({ prId: z40.string().min(1).max(500), action: ForgeActionSchema }).strict().optional(),
3718
3754
  /** A `routine` challenge: the pending routine its « Activer » covers, and its key as the phone showed it; `routineOthers`, the
3719
3755
  * other routines of a grouped request « Activer les N » covers with the same check. */
3720
3756
  routine: RoutineIdSchema.optional(),
3721
3757
  routineKey: RoutineKeySchema.optional(),
3722
- routineOthers: z39.array(PhoneRoutineRefSchema).max(ROUTINES_ACTIVE_MAX - 1).optional()
3758
+ routineOthers: z40.array(PhoneRoutineRefSchema).max(ROUTINES_ACTIVE_MAX - 1).optional()
3723
3759
  }),
3724
3760
  /** `userId`: the passkey's `user.id` as the phone made it (« L1 » ‖ the PC key's digest ‖ random, docs/mobile-passkey-recover-contract.md);
3725
3761
  * given and made for this PC, the passkey can bring the device back after a reinstall (the snapshot's `device.recover`). */
3726
- z39.object({ type: z39.literal("credential.register"), op: OperationIdSchema, credential: CredentialSchema, userId: B64U3.max(128).optional() }),
3727
- z39.object({
3728
- type: z39.literal("session.decide"),
3762
+ z40.object({ type: z40.literal("credential.register"), op: OperationIdSchema, credential: CredentialSchema, userId: B64U3.max(128).optional() }),
3763
+ z40.object({
3764
+ type: z40.literal("session.decide"),
3729
3765
  op: OperationIdSchema,
3730
3766
  id: sessionId,
3731
3767
  decision: DecisionSchema,
3732
- note: z39.string().trim().min(1).max(NOTE_MAX).optional(),
3768
+ note: z40.string().trim().min(1).max(NOTE_MAX).optional(),
3733
3769
  /** The request the phone showed: refused unless it is still the pending one. */
3734
3770
  expect: PhoneExpectSchema,
3735
3771
  /** The device check over the challenge of `confirm.prepare`; required by the daemon for a high-risk accept. */
3736
3772
  assertion: AssertionSchema.optional()
3737
3773
  }),
3738
- z39.object({
3739
- type: z39.literal("session.reply"),
3774
+ z40.object({
3775
+ type: z40.literal("session.reply"),
3740
3776
  op: OperationIdSchema,
3741
3777
  id: sessionId,
3742
- text: z39.string().max(MESSAGE_MAX),
3743
- attachments: z39.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(),
3778
+ text: z40.string().max(MESSAGE_MAX),
3779
+ attachments: z40.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(),
3744
3780
  /** The request the reply answers, or null when the phone showed none: refused if the session's request is no longer that one. */
3745
3781
  expect: PhoneExpectSchema.nullable(),
3746
3782
  assertion: AssertionSchema.optional()
3747
3783
  }),
3748
3784
  /** OMP's `ask`: the answers to every question of the dialog `requestId`, in order; `cancel` declines it. Bounds as the local `session.answer`. */
3749
- z39.object({
3750
- type: z39.literal("session.answer"),
3785
+ z40.object({
3786
+ type: z40.literal("session.answer"),
3751
3787
  op: OperationIdSchema,
3752
3788
  id: sessionId,
3753
- requestId: z39.string().min(1).max(200),
3754
- answers: z39.array(z39.object({ id: z39.string().max(200), selected: z39.array(z39.string().max(2e3)).max(100), text: z39.string().max(2e4).optional() })).max(50),
3755
- cancel: z39.literal(true).optional(),
3789
+ requestId: z40.string().min(1).max(200),
3790
+ answers: z40.array(z40.object({ id: z40.string().max(200), selected: z40.array(z40.string().max(2e3)).max(100), text: z40.string().max(2e4).optional() })).max(50),
3791
+ cancel: z40.literal(true).optional(),
3756
3792
  expect: PhoneExpectSchema
3757
3793
  }),
3758
- z39.object({ type: z39.literal("session.interrupt"), op: OperationIdSchema, id: sessionId }),
3794
+ z40.object({ type: z40.literal("session.interrupt"), op: OperationIdSchema, id: sessionId }),
3759
3795
  /** Ends a live session as `/exit` would, killed as a last resort; answered with its `how`. Passkey, purpose `close`, over the session. */
3760
- z39.object({ type: z39.literal("session.close"), op: OperationIdSchema, id: sessionId, assertion: AssertionSchema.optional() }),
3796
+ z40.object({ type: z40.literal("session.close"), op: OperationIdSchema, id: sessionId, assertion: AssertionSchema.optional() }),
3761
3797
  /** Starts an ended session again on its conversation. Passkey, purpose `act`, over the session. */
3762
- z39.object({ type: z39.literal("session.resume"), op: OperationIdSchema, id: sessionId, assertion: AssertionSchema.optional() }),
3798
+ z40.object({ type: z40.literal("session.resume"), op: OperationIdSchema, id: sessionId, assertion: AssertionSchema.optional() }),
3763
3799
  /** Changes a live session's model and effort, `null` for the agent's own default; answered by `operation.result` and, when refused, `session.model.failed`. */
3764
- z39.object({ type: z39.literal("session.model"), op: OperationIdSchema, id: sessionId, model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
3800
+ z40.object({ type: z40.literal("session.model"), op: OperationIdSchema, id: sessionId, model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
3765
3801
  /** « Rattacher à Ledge » on a read-only session (`cancel`: withdraws one still waiting); answered by `operation.result`, then
3766
3802
  * `session.adopted` or `session.adopt.failed`. */
3767
- z39.object({ type: z39.literal("session.adopt"), op: OperationIdSchema, id: sessionId, cancel: z39.literal(true).optional() }),
3803
+ z40.object({ type: z40.literal("session.adopt"), op: OperationIdSchema, id: sessionId, cancel: z40.literal(true).optional() }),
3768
3804
  /** One message to several sessions (ids); answered by `operation.result` with `sent` and `refused`. */
3769
- z39.object({ type: z39.literal("session.broadcast"), op: OperationIdSchema, sessions: z39.array(sessionId).min(1).max(BROADCAST_SESSIONS_MAX), text: z39.string().trim().min(1).max(MESSAGE_MAX) }).strict(),
3805
+ z40.object({ type: z40.literal("session.broadcast"), op: OperationIdSchema, sessions: z40.array(sessionId).min(1).max(BROADCAST_SESSIONS_MAX), text: z40.string().trim().min(1).max(MESSAGE_MAX) }).strict(),
3770
3806
  /** The models an agent offers on the PC. */
3771
- z39.object({ type: z39.literal("models.list"), tool: ToolSchema }),
3807
+ z40.object({ type: z40.literal("models.list"), tool: ToolSchema }),
3772
3808
  /** The slash commands of a session's agent, for the « / » list of its field. */
3773
- z39.object({ type: z39.literal("session.commands"), id: sessionId }),
3809
+ z40.object({ type: z40.literal("session.commands"), id: sessionId }),
3774
3810
  /** A queue row's state, for an OpenRig task card: asked while the card shows and every `RIG_ROW_REFRESH_MS` (`daemon.rigRows`). */
3775
- z39.object({ type: z39.literal("openrig.row"), qitem: QitemIdSchema }),
3811
+ z40.object({ type: z40.literal("openrig.row"), qitem: QitemIdSchema }),
3776
3812
  /** The phone drops its passkey from the daemon. */
3777
- z39.object({ type: z39.literal("device.forget"), op: OperationIdSchema }),
3813
+ z40.object({ type: z40.literal("device.forget"), op: OperationIdSchema }),
3778
3814
  /** The device names itself (on the PC and in its next snapshot); applied to the sender only. */
3779
- z39.object({ type: z39.literal("device.rename"), op: OperationIdSchema, name: DeviceNameSchema }),
3815
+ z40.object({ type: z40.literal("device.rename"), op: OperationIdSchema, name: DeviceNameSchema }),
3780
3816
  /** The device's own settings, whole (`daemon.settings`): applied to the sender only, told back in its next snapshot. */
3781
- z39.object({ type: z39.literal("device.prefs"), op: OperationIdSchema, prefs: z39.object({
3817
+ z40.object({ type: z40.literal("device.prefs"), op: OperationIdSchema, prefs: z40.object({
3782
3818
  notify: DevicePrefsSchema.shape.notify.strict(),
3783
3819
  quietUntil: DevicePrefsSchema.shape.quietUntil,
3784
3820
  chatTool: DevicePrefsSchema.shape.chatTool
@@ -3788,465 +3824,465 @@ var PhoneClientMessageSchema = z39.discriminatedUnion("type", [
3788
3824
  * Never a folder or a rule: the daemon keeps them as they are (a deletion moves them as the desktop's does). The PC names a
3789
3825
  * new project. A deletion carries the device's check over the project and `moveTo` (purpose `project`).
3790
3826
  */
3791
- z39.object({ type: z39.literal("project.edit"), op: OperationIdSchema, id: ProjectIdSchema, name: ProjectNameSchema.optional(), color: ProjectColorSchema.optional() }).strict(),
3792
- z39.object({ type: z39.literal("project.order"), op: OperationIdSchema, ids: z39.array(ProjectIdSchema).min(1).max(PHONE_PROJECTS_MAX) }).strict(),
3827
+ z40.object({ type: z40.literal("project.edit"), op: OperationIdSchema, id: ProjectIdSchema, name: ProjectNameSchema.optional(), color: ProjectColorSchema.optional() }).strict(),
3828
+ z40.object({ type: z40.literal("project.order"), op: OperationIdSchema, ids: z40.array(ProjectIdSchema).min(1).max(PHONE_PROJECTS_MAX) }).strict(),
3793
3829
  /** Issue #16: some of a project's sessions (`project` null: « Sans projet ») in a new order, this PC's ids; the others keep their
3794
3830
  * places (placeSessions). A session not in that project, or one gone, makes it stale. */
3795
- z39.object({ type: z39.literal("session.order"), op: OperationIdSchema, project: ProjectIdSchema.nullable(), ids: z39.array(z39.string().min(1).max(200)).min(1).max(SESSION_ORDER_MAX) }).strict(),
3831
+ z40.object({ type: z40.literal("session.order"), op: OperationIdSchema, project: ProjectIdSchema.nullable(), ids: z40.array(z40.string().min(1).max(200)).min(1).max(SESSION_ORDER_MAX) }).strict(),
3796
3832
  /** Issue #2: with its first folder (`path`, of this PC) and the device's check over that name and folder (`newProjectSubject`). A
3797
3833
  * create without it, from an older phone, is refused `folder_required`. */
3798
- z39.object({
3799
- type: z39.literal("project.create"),
3834
+ z40.object({
3835
+ type: z40.literal("project.create"),
3800
3836
  op: OperationIdSchema,
3801
3837
  name: ProjectNameSchema,
3802
3838
  color: ProjectColorSchema,
3803
3839
  path: FolderPathSchema.optional(),
3804
3840
  assertion: AssertionSchema.optional()
3805
3841
  }).strict(),
3806
- z39.object({ type: z39.literal("project.delete"), op: OperationIdSchema, id: ProjectIdSchema, moveTo: ProjectIdSchema.nullable(), assertion: AssertionSchema.optional() }).strict(),
3842
+ z40.object({ type: z40.literal("project.delete"), op: OperationIdSchema, id: ProjectIdSchema, moveTo: ProjectIdSchema.nullable(), assertion: AssertionSchema.optional() }).strict(),
3807
3843
  /**
3808
3844
  * A project's folders (`daemon.projectFolders`): browsing this PC's folders, its recent ones, a project's folders, then adding one
3809
3845
  * of this PC (with the device's check, purpose `folder`) or removing one. Reads are answered to the asker alone.
3810
3846
  */
3811
- z39.object({ type: z39.literal("folder.list"), path: FolderPathSchema.optional() }).strict(),
3812
- z39.object({ type: z39.literal("folder.recents") }).strict(),
3813
- z39.object({ type: z39.literal("project.folders"), id: ProjectIdSchema }).strict(),
3814
- z39.object({ type: z39.literal("project.folder.add"), op: OperationIdSchema, id: ProjectIdSchema, path: FolderPathSchema, assertion: AssertionSchema.optional() }).strict(),
3815
- z39.object({ type: z39.literal("project.folder.remove"), op: OperationIdSchema, id: ProjectIdSchema, machine: MachineIdSchema, path: FolderPathSchema }).strict(),
3847
+ z40.object({ type: z40.literal("folder.list"), path: FolderPathSchema.optional() }).strict(),
3848
+ z40.object({ type: z40.literal("folder.recents") }).strict(),
3849
+ z40.object({ type: z40.literal("project.folders"), id: ProjectIdSchema }).strict(),
3850
+ z40.object({ type: z40.literal("project.folder.add"), op: OperationIdSchema, id: ProjectIdSchema, path: FolderPathSchema, assertion: AssertionSchema.optional() }).strict(),
3851
+ z40.object({ type: z40.literal("project.folder.remove"), op: OperationIdSchema, id: ProjectIdSchema, machine: MachineIdSchema, path: FolderPathSchema }).strict(),
3816
3852
  /** « Contexte max », the PC's threshold shared by every front (`daemon.settings`): as the desktop's `context.set`. */
3817
- z39.object({ type: z39.literal("context.set"), op: OperationIdSchema, near: ContextPrefsSchema.shape.near }).strict(),
3853
+ z40.object({ type: z40.literal("context.set"), op: OperationIdSchema, near: ContextPrefsSchema.shape.near }).strict(),
3818
3854
  /** The phone's push subscription, with the VAPID key it was made with (so a key change is seen). `resolved`: its service
3819
3855
  * worker shows a `resolved` push, which replaces a request's notification once it is answered elsewhere. */
3820
- z39.object({ type: z39.literal("push.subscribe"), op: OperationIdSchema, subscription: PushSubscriptionSchema, key: B64U3.length(87), resolved: z39.literal(true).optional() }),
3821
- z39.object({ type: z39.literal("push.unsubscribe"), op: OperationIdSchema }),
3856
+ z40.object({ type: z40.literal("push.subscribe"), op: OperationIdSchema, subscription: PushSubscriptionSchema, key: B64U3.length(87), resolved: z40.literal(true).optional() }),
3857
+ z40.object({ type: z40.literal("push.unsubscribe"), op: OperationIdSchema }),
3822
3858
  /** The phone's own chat with Ledge. */
3823
- z39.object({ type: z39.literal("chat.ask"), qid: OperationIdSchema, text: z39.string().trim().max(MESSAGE_MAX), attachments: z39.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional() }),
3824
- z39.object({ type: z39.literal("chat.cancel"), qid: OperationIdSchema }),
3825
- z39.object({ type: z39.literal("chat.reset") }),
3826
- z39.object({ type: z39.literal("chat.history") }),
3859
+ z40.object({ type: z40.literal("chat.ask"), qid: OperationIdSchema, text: z40.string().trim().max(MESSAGE_MAX), attachments: z40.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional() }),
3860
+ z40.object({ type: z40.literal("chat.cancel"), qid: OperationIdSchema }),
3861
+ z40.object({ type: z40.literal("chat.reset") }),
3862
+ z40.object({ type: z40.literal("chat.history") }),
3827
3863
  /** The device's conversations, and one of them (`daemon.conversations`): answered to the asker alone. */
3828
- z39.object({ type: z39.literal("chat.conversations") }).strict(),
3829
- z39.object({ type: z39.literal("chat.conversation"), id: z39.string().uuid() }).strict(),
3864
+ z40.object({ type: z40.literal("chat.conversations") }).strict(),
3865
+ z40.object({ type: z40.literal("chat.conversation"), id: z40.string().uuid() }).strict(),
3830
3866
  /** An image to store, sent alone before the message that names it; no `id`, and at most `ATTACHMENT_MAX` bytes. */
3831
- AttachmentPutSchema.pick({ type: true, requestId: true }).extend({ image: ImageUploadSchema.extend({ data: z39.string().min(1).max(b64Max(ATTACHMENT_MAX)) }) }),
3867
+ AttachmentPutSchema.pick({ type: true, requestId: true }).extend({ image: ImageUploadSchema.extend({ data: z40.string().min(1).max(b64Max(ATTACHMENT_MAX)) }) }),
3832
3868
  AttachmentGetSchema.pick({ type: true, requestId: true, attachment: true, preview: true }),
3833
- z39.object({ type: z39.literal("chat.relay"), op: OperationIdSchema, qid: OperationIdSchema }),
3869
+ z40.object({ type: z40.literal("chat.relay"), op: OperationIdSchema, qid: OperationIdSchema }),
3834
3870
  /** Takes the card's queued instruction back out of the queue, as the local `session.relay.cancel`. */
3835
- z39.object({ type: z39.literal("chat.relay.cancel"), op: OperationIdSchema, qid: OperationIdSchema }),
3836
- z39.object({ type: z39.literal("chat.launch"), op: OperationIdSchema, qid: OperationIdSchema, rows: CardRowsSchema.optional(), assertion: AssertionSchema.optional() }),
3871
+ z40.object({ type: z40.literal("chat.relay.cancel"), op: OperationIdSchema, qid: OperationIdSchema }),
3872
+ z40.object({ type: z40.literal("chat.launch"), op: OperationIdSchema, qid: OperationIdSchema, rows: CardRowsSchema.optional(), assertion: AssertionSchema.optional() }),
3837
3873
  /** « Nouvelle session » (M2 §9): passkey, purpose `launch`, over this very launch. Applied, its result names the new session (`id`). */
3838
- z39.object({ type: z39.literal("session.launch"), op: OperationIdSchema, launch: PhoneLaunchSchema, assertion: AssertionSchema.optional() }).strict(),
3839
- z39.object({ type: z39.literal("chat.close"), op: OperationIdSchema, qid: OperationIdSchema, rows: CardRowsSchema.optional(), assertion: AssertionSchema.optional() }),
3874
+ z40.object({ type: z40.literal("session.launch"), op: OperationIdSchema, launch: PhoneLaunchSchema, assertion: AssertionSchema.optional() }).strict(),
3875
+ z40.object({ type: z40.literal("chat.close"), op: OperationIdSchema, qid: OperationIdSchema, rows: CardRowsSchema.optional(), assertion: AssertionSchema.optional() }),
3840
3876
  /** A row of the turn's task card: given by Ledge. */
3841
- z39.object({ type: z39.literal("chat.task"), op: OperationIdSchema, qid: OperationIdSchema, row: z39.number().int().min(0).max(MAX_PROPOSALS - 1) }),
3877
+ z40.object({ type: z40.literal("chat.task"), op: OperationIdSchema, qid: OperationIdSchema, row: z40.number().int().min(0).max(MAX_PROPOSALS - 1) }),
3842
3878
  /** Rows of the turn's generic card (action registry spec §5): `confirmed` as the local `chat.act`; a row whose action asks
3843
3879
  * for a device check (`phone`) needs one assertion, purpose `act`, over the turn. */
3844
- z39.object({
3845
- type: z39.literal("chat.act"),
3880
+ z40.object({
3881
+ type: z40.literal("chat.act"),
3846
3882
  op: OperationIdSchema,
3847
3883
  qid: OperationIdSchema,
3848
3884
  rows: CardRowsSchema.optional(),
3849
- confirmed: z39.literal(true).optional(),
3885
+ confirmed: z40.literal(true).optional(),
3850
3886
  assertion: AssertionSchema.optional(),
3851
3887
  /** « Refuser », as the local `chat.act`: no passkey, no confirmation. */
3852
- deny: z39.literal(true).optional()
3888
+ deny: z40.literal(true).optional()
3853
3889
  }),
3854
3890
  /** « Ignorer » the turn's cards, or `undo` (« Revoir »), as the local `chat.ignore`. */
3855
- z39.object({ type: z39.literal("chat.ignore"), op: OperationIdSchema, qid: OperationIdSchema, undo: z39.literal(true).optional() }),
3891
+ z40.object({ type: z40.literal("chat.ignore"), op: OperationIdSchema, qid: OperationIdSchema, undo: z40.literal(true).optional() }),
3856
3892
  /** The operator's point: `point.act` answers a row, `point.later` sets the point aside, `operator.read` marks events read for this device. */
3857
- z39.object({
3858
- type: z39.literal("point.act"),
3893
+ z40.object({
3894
+ type: z40.literal("point.act"),
3859
3895
  op: OperationIdSchema,
3860
3896
  qid: OperationIdSchema,
3861
- item: z39.string().min(1).max(200),
3897
+ item: z40.string().min(1).max(200),
3862
3898
  answer: PointAnswerSchema.optional(),
3863
3899
  /** Applies the row's suggestion instead of answering it (exactly one of `answer` and `suggest`). */
3864
- suggest: z39.literal(true).optional(),
3900
+ suggest: z40.literal(true).optional(),
3865
3901
  /** A destructive answer says it was confirmed on the phone; the device check (`assertion`) is bound to this item and this answer. */
3866
- confirmed: z39.literal(true).optional(),
3902
+ confirmed: z40.literal(true).optional(),
3867
3903
  assertion: AssertionSchema.optional()
3868
3904
  }),
3869
- z39.object({ type: z39.literal("point.later"), op: OperationIdSchema, qid: OperationIdSchema }),
3870
- z39.object({ type: z39.literal("operator.read"), op: OperationIdSchema, eventId: z39.number().int().min(0) }),
3905
+ z40.object({ type: z40.literal("point.later"), op: OperationIdSchema, qid: OperationIdSchema }),
3906
+ z40.object({ type: z40.literal("operator.read"), op: OperationIdSchema, eventId: z40.number().int().min(0) }),
3871
3907
  /** The user's answer to a proposal about the notes (brain spec, lot 4): a `yes` carries an assertion of purpose `note` bound to the
3872
3908
  * task and that exact choice; a `no` needs none. */
3873
- z39.object({ type: z39.literal("brain.answer"), op: OperationIdSchema, task: z39.string().min(1).max(40), choice: BrainChoiceSchema, assertion: AssertionSchema.optional() }),
3909
+ z40.object({ type: z40.literal("brain.answer"), op: OperationIdSchema, task: z40.string().min(1).max(40), choice: BrainChoiceSchema, assertion: AssertionSchema.optional() }),
3874
3910
  /** The user's answer to a decision a session put to them (`ledge task give ledge`, #40): destructive, so always `confirmed`, and backed
3875
3911
  * by an assertion of purpose `decision` bound to that decision and that exact answer. Sent only to a daemon with `daemon.taskAnswer`. */
3876
- z39.object({ type: z39.literal("task.answer"), op: OperationIdSchema, task: z39.string().min(1).max(40), answer: z39.string().trim().min(1).max(TASK_TEXT_MAX), confirmed: z39.literal(true), assertion: AssertionSchema.optional() }).strict(),
3912
+ z40.object({ type: z40.literal("task.answer"), op: OperationIdSchema, task: z40.string().min(1).max(40), answer: z40.string().trim().min(1).max(TASK_TEXT_MAX), confirmed: z40.literal(true), assertion: AssertionSchema.optional() }).strict(),
3877
3913
  /** Puts a closed task Ledge gave away from « À traiter ». */
3878
- z39.object({ type: z39.literal("task.seen"), op: OperationIdSchema, task: z39.string().min(1).max(40) }),
3914
+ z40.object({ type: z40.literal("task.seen"), op: OperationIdSchema, task: z40.string().min(1).max(40) }),
3879
3915
  /** The routines (routines spec §3.7): answered by `routines`, then each change comes as `routine.changed`. */
3880
- z39.object({ type: z39.literal("routine.list") }).strict(),
3916
+ z40.object({ type: z40.literal("routine.list") }).strict(),
3881
3917
  /** One routine whole, its prompt included: answered by `routine.detail`. The phone shows it before « Activer ». */
3882
- z39.object({ type: z39.literal("routine.show"), routine: RoutineIdSchema }).strict(),
3918
+ z40.object({ type: z40.literal("routine.show"), routine: RoutineIdSchema }).strict(),
3883
3919
  /** « Lancer maintenant », « Pause » / « Reprendre », and « Activer » / « Refuser » from « À toi »; answered by `operation.result`.
3884
3920
  * An `approve` names the key of the routine the phone showed (`routineKey`, refused as `stale` once it changed) and carries an
3885
3921
  * assertion of purpose `routine` bound to that routine and that key. */
3886
- z39.object({
3887
- type: z39.literal("routine.cmd"),
3922
+ z40.object({
3923
+ type: z40.literal("routine.cmd"),
3888
3924
  op: OperationIdSchema,
3889
3925
  action: PhoneRoutineActionSchema,
3890
3926
  routine: RoutineIdSchema,
3891
3927
  routineKey: RoutineKeySchema.optional(),
3892
3928
  /** « Activer les N » / « Refuser les N » of a grouped request: the other routines, each with the key the phone showed; an approve's
3893
3929
  * one assertion covers them all. */
3894
- others: z39.array(PhoneRoutineRefSchema).max(ROUTINES_ACTIVE_MAX - 1).optional(),
3930
+ others: z40.array(PhoneRoutineRefSchema).max(ROUTINES_ACTIVE_MAX - 1).optional(),
3895
3931
  assertion: AssertionSchema.optional()
3896
3932
  }).strict(),
3897
3933
  /** Streams a session's pane, read-only; answered by `term.opened` or `operation.result` (rejected). `helper`: one of the
3898
3934
  * session's subagents (`helpers[].id`), whose terminal is its parent's, read-only for good (`term.opened.readOnly`). */
3899
- z39.object({ type: z39.literal("term.open"), op: OperationIdSchema, id: sessionId, helper: z39.string().min(1).max(200).optional() }),
3935
+ z40.object({ type: z40.literal("term.open"), op: OperationIdSchema, id: sessionId, helper: z40.string().min(1).max(200).optional() }),
3900
3936
  /** « Prendre la main »: passkey, purpose `terminal`, over the session; answered by `term.held` or `operation.result` (rejected). */
3901
- z39.object({ type: z39.literal("term.hold"), op: OperationIdSchema, tid: TerminalIdSchema, assertion: AssertionSchema.optional() }),
3937
+ z40.object({ type: z40.literal("term.hold"), op: OperationIdSchema, tid: TerminalIdSchema, assertion: AssertionSchema.optional() }),
3902
3938
  /** Keys to type, as xterm produced them; `n` counts from 0 for the terminal, so a duplicate is dropped and a gap seen. Refused unless held. */
3903
- z39.object({ type: z39.literal("term.input"), tid: TerminalIdSchema, n: z39.number().int().nonnegative(), data: z39.string().min(1).max(TERM_INPUT_MAX) }),
3939
+ z40.object({ type: z40.literal("term.input"), tid: TerminalIdSchema, n: z40.number().int().nonnegative(), data: z40.string().min(1).max(TERM_INPUT_MAX) }),
3904
3940
  /** « Rendre la main »: back to read-only. */
3905
- z39.object({ type: z39.literal("term.release"), tid: TerminalIdSchema }),
3941
+ z40.object({ type: z40.literal("term.release"), tid: TerminalIdSchema }),
3906
3942
  /** The phone saw a gap in `seq`: a fresh `term.opened`, please. */
3907
- z39.object({ type: z39.literal("term.resync"), tid: TerminalIdSchema }),
3908
- z39.object({ type: z39.literal("term.close"), tid: TerminalIdSchema }),
3943
+ z40.object({ type: z40.literal("term.resync"), tid: TerminalIdSchema }),
3944
+ z40.object({ type: z40.literal("term.close"), tid: TerminalIdSchema }),
3909
3945
  /** Whether the phone's app is in front: a device that is visible gets no push. */
3910
- z39.object({ type: z39.literal("presence"), visible: z39.boolean() }),
3946
+ z40.object({ type: z40.literal("presence"), visible: z40.boolean() }),
3911
3947
  /** « À toi » (lot 3): what OpenRig on this PC asks the person, then pushed whole when it changes (`openrig.asks`). */
3912
- z39.object({ type: z39.literal("openrig.asks") }),
3948
+ z40.object({ type: z40.literal("openrig.asks") }),
3913
3949
  /** The person's answer to an OpenRig row. A choice, words or a resolve carries an assertion of purpose `rig` bound to that row and that
3914
3950
  * answer; « Vu » (`seen`) needs none. */
3915
- z39.object({ type: z39.literal("openrig.answer"), op: OperationIdSchema, qitemId: z39.string().min(1).max(200), answer: HumanAnswerSchema, assertion: AssertionSchema.optional() }),
3951
+ z40.object({ type: z40.literal("openrig.answer"), op: OperationIdSchema, qitemId: z40.string().min(1).max(200), answer: HumanAnswerSchema, assertion: AssertionSchema.optional() }),
3916
3952
  /** Installs `version` on the PC, then restarts its daemon; the phone asks for its own build's version. Passkey, purpose `pc`. */
3917
- z39.object({ type: z39.literal("daemon.update"), ...pcOp, version: z39.string().regex(SEMVER) }).strict(),
3953
+ z40.object({ type: z40.literal("daemon.update"), ...pcOp, version: z40.string().regex(SEMVER) }).strict(),
3918
3954
  /** Restarts the PC's daemon without installing anything. Passkey, purpose `pc`. */
3919
- z39.object({ type: z39.literal("daemon.restart"), ...pcOp }).strict(),
3955
+ z40.object({ type: z40.literal("daemon.restart"), ...pcOp }).strict(),
3920
3956
  // ── Rigs and the kernel (`daemon.rigs`, docs/mobile-openrig-contract.md) ──
3921
3957
  /** OpenRig on this PC, answered by `rigs.state`, then each change, whole, while the phone follows. */
3922
- z39.object({ type: z39.literal("rigs.state") }).strict(),
3923
- z39.object({ type: z39.literal("rigs.graph"), rig: RigNameSchema }).strict(),
3958
+ z40.object({ type: z40.literal("rigs.state") }).strict(),
3959
+ z40.object({ type: z40.literal("rigs.graph"), rig: RigNameSchema }).strict(),
3924
3960
  /** A rig's open rows and its recently closed ones. */
3925
- z39.object({ type: z39.literal("rigs.queue"), rig: RigNameSchema }).strict(),
3961
+ z40.object({ type: z40.literal("rigs.queue"), rig: RigNameSchema }).strict(),
3926
3962
  /** The queue's routing on this PC: the latest claims, handoffs, blocks and closes, every rig. */
3927
- z39.object({ type: z39.literal("rigs.routing") }).strict(),
3928
- z39.object({ type: z39.literal("rigs.permissions"), rig: RigNameSchema }).strict(),
3929
- z39.object({ type: z39.literal("rigs.snapshots"), rig: RigNameSchema }).strict(),
3963
+ z40.object({ type: z40.literal("rigs.routing") }).strict(),
3964
+ z40.object({ type: z40.literal("rigs.permissions"), rig: RigNameSchema }).strict(),
3965
+ z40.object({ type: z40.literal("rigs.snapshots"), rig: RigNameSchema }).strict(),
3930
3966
  /** The goals given to the operator, answered by `rigs.goals`, then each change, whole, while the phone follows. */
3931
- z39.object({ type: z39.literal("rigs.goals") }).strict(),
3967
+ z40.object({ type: z40.literal("rigs.goals") }).strict(),
3932
3968
  /** An action on OpenRig, every kind the Desktop's `openrig.act` takes. One that `rigActNeedsCheck` names carries a passkey, purpose `rigs`. */
3933
- z39.object({ type: z39.literal("rigs.act"), op: OperationIdSchema, action: OpenRigActionSchema, assertion: AssertionSchema.optional() }).strict(),
3969
+ z40.object({ type: z40.literal("rigs.act"), op: OperationIdSchema, action: OpenRigActionSchema, assertion: AssertionSchema.optional() }).strict(),
3934
3970
  // ── Pull and merge requests (`daemon.forge`, docs/mobile-forge-contract.md) ──
3935
3971
  /** The requests of this PC's sessions and seats; subscribes the device to each change. */
3936
- z39.object({ type: z39.literal("forge.state") }).strict(),
3972
+ z40.object({ type: z40.literal("forge.state") }).strict(),
3937
3973
  /** A request's detail; `log`: also that job's last lines. */
3938
- z39.object({ type: z39.literal("forge.detail"), prId: z39.string().min(1).max(500), log: z39.string().min(1).max(40).optional() }).strict(),
3974
+ z40.object({ type: z40.literal("forge.detail"), prId: z40.string().min(1).max(500), log: z40.string().min(1).max(40).optional() }).strict(),
3939
3975
  /** Rerun, merge, comment, reply or resolve: every one writes on the forge, so each needs the device's check over that very action (purpose `forge`). */
3940
- z39.object({ type: z39.literal("forge.act"), op: OperationIdSchema, prId: z39.string().min(1).max(500), action: ForgeActionSchema, assertion: AssertionSchema.optional() }).strict(),
3976
+ z40.object({ type: z40.literal("forge.act"), op: OperationIdSchema, prId: z40.string().min(1).max(500), action: ForgeActionSchema, assertion: AssertionSchema.optional() }).strict(),
3941
3977
  /** A running rig's seats per role (the Desktop's `openrig.seats`). One that removes a seat carries a passkey, purpose `rigs`. */
3942
- z39.object({ type: z39.literal("rigs.seats"), op: OperationIdSchema, rig: RigNameSchema, seats: RigSeatCountsSchema, delegation: z39.enum(["pairs", "all"]).optional(), assertion: AssertionSchema.optional() }).strict(),
3978
+ z40.object({ type: z40.literal("rigs.seats"), op: OperationIdSchema, rig: RigNameSchema, seats: RigSeatCountsSchema, delegation: z40.enum(["pairs", "all"]).optional(), assertion: AssertionSchema.optional() }).strict(),
3943
3979
  /** A goal to the operator (the Desktop's `openrig.goal.send`); `goalId` is the phone's, the same for a retry. */
3944
- z39.object({ type: z39.literal("rigs.goal.send"), op: OperationIdSchema, goalId: z39.string().regex(/^[A-Za-z0-9-]{8,64}$/), text: z39.string().trim().min(1).max(8e3), folder: z39.string().min(1).max(4096).optional() }).strict(),
3980
+ z40.object({ type: z40.literal("rigs.goal.send"), op: OperationIdSchema, goalId: z40.string().regex(/^[A-Za-z0-9-]{8,64}$/), text: z40.string().trim().min(1).max(8e3), folder: z40.string().min(1).max(4096).optional() }).strict(),
3945
3981
  /** The person's words to the operator about a goal (the Desktop's `openrig.goal.reply`); `replyId` the phone's, the same for a retry. */
3946
- z39.object({ type: z39.literal("rigs.goal.reply"), op: OperationIdSchema, goalId: z39.string().regex(/^[A-Za-z0-9-]{8,64}$/), replyId: z39.string().regex(/^[A-Za-z0-9-]{8,64}$/), text: z39.string().trim().min(1).max(8e3) }).strict()
3982
+ z40.object({ type: z40.literal("rigs.goal.reply"), op: OperationIdSchema, goalId: z40.string().regex(/^[A-Za-z0-9-]{8,64}$/), replyId: z40.string().regex(/^[A-Za-z0-9-]{8,64}$/), text: z40.string().trim().min(1).max(8e3) }).strict()
3947
3983
  ]);
3948
- var PhoneModelChoiceSchema = z39.object({
3984
+ var PhoneModelChoiceSchema = z40.object({
3949
3985
  id: ModelChoiceSchema.shape.id.max(120),
3950
- label: z39.string().max(80),
3951
- description: z39.string().max(200).optional(),
3952
- efforts: z39.array(EffortSchema).max(8).optional(),
3986
+ label: z40.string().max(80),
3987
+ description: z40.string().max(200).optional(),
3988
+ efforts: z40.array(EffortSchema).max(8).optional(),
3953
3989
  defaultEffort: EffortSchema.optional(),
3954
- isDefault: z39.boolean().optional()
3990
+ isDefault: z40.boolean().optional()
3955
3991
  }).strict();
3956
3992
  var PHONE_COMMANDS_MAX = 300;
3957
- var PhoneSlashCommandSchema = SlashCommandSchema.extend({ description: z39.string().max(200).optional() }).strict();
3993
+ var PhoneSlashCommandSchema = SlashCommandSchema.extend({ description: z40.string().max(200).optional() }).strict();
3958
3994
  var PhoneHarnessUsageSchema = HarnessUsageSchema.omit({ account: true }).strict();
3959
- var PhoneServerMessageSchema = z39.discriminatedUnion("type", [
3995
+ var PhoneServerMessageSchema = z40.discriminatedUnion("type", [
3960
3996
  /** This PC's harness limits (`daemon.usage`): after `snapshot.request`, then on each change, whole. `prefs.alert`: the PC's
3961
3997
  * threshold, so the phone marks a window past it (amber, a line in « À toi ») and one reached (red). */
3962
- z39.object({ type: z39.literal("usage.state"), harnesses: z39.preprocess(dropUnknownHarnesses, z39.array(PhoneHarnessUsageSchema).max(4)), prefs: UsagePrefsSchema }),
3963
- z39.object({
3964
- type: z39.literal("snapshot"),
3965
- protocol: z39.literal(PHONE_PROTOCOL),
3966
- sessions: z39.array(PhoneSessionSchema),
3998
+ z40.object({ type: z40.literal("usage.state"), harnesses: z40.preprocess(dropUnknownHarnesses, z40.array(PhoneHarnessUsageSchema).max(4)), prefs: UsagePrefsSchema }),
3999
+ z40.object({
4000
+ type: z40.literal("snapshot"),
4001
+ protocol: z40.literal(PHONE_PROTOCOL),
4002
+ sessions: z40.array(PhoneSessionSchema),
3967
4003
  capabilities: CapabilitiesByToolSchema,
3968
- daemon: z39.object({
3969
- version: z39.string(),
3970
- name: z39.string().max(40),
3971
- boot: z39.string().uuid().optional(),
4004
+ daemon: z40.object({
4005
+ version: z40.string(),
4006
+ name: z40.string().max(40),
4007
+ boot: z40.string().uuid().optional(),
3972
4008
  /** The daemon takes `session.model`. */
3973
- models: z39.literal(true).optional(),
4009
+ models: z40.literal(true).optional(),
3974
4010
  /** The daemon sends `session.checklist` and a session's `checklist` summary. */
3975
- checklist: z39.literal(true).optional(),
4011
+ checklist: z40.literal(true).optional(),
3976
4012
  /** `update`: the daemon can install a version and restart (npm, systemd); `restart`: it can restart (systemd). */
3977
- update: z39.literal(true).optional(),
3978
- restart: z39.literal(true).optional(),
4013
+ update: z40.literal(true).optional(),
4014
+ restart: z40.literal(true).optional(),
3979
4015
  /** The daemon takes `session.close` and `session.resume`. */
3980
- sessionClose: z39.literal(true).optional(),
4016
+ sessionClose: z40.literal(true).optional(),
3981
4017
  /** The daemon takes `session.adopt` (« Rattacher à Ledge »). */
3982
- adopt: z39.literal(true).optional(),
4018
+ adopt: z40.literal(true).optional(),
3983
4019
  /** The daemon streams a session's terminal (`term.open`). */
3984
- terminal: z39.literal(true).optional(),
4020
+ terminal: z40.literal(true).optional(),
3985
4021
  /** The PC lets a phone type into a terminal (`term.hold`): its setting is on. */
3986
- terminalInput: z39.literal(true).optional(),
4022
+ terminalInput: z40.literal(true).optional(),
3987
4023
  /** `term.open` takes `helper`: a subagent's terminal is its parent's, read-only for good. Absent (an older PC, which would drop
3988
4024
  * `helper` and open the parent's pane as its own): the phone opens no subagent's terminal. */
3989
- helperTerminal: z39.literal(true).optional(),
4025
+ helperTerminal: z40.literal(true).optional(),
3990
4026
  /** The daemon answers `session.commands`. */
3991
- commands: z39.literal(true).optional(),
4027
+ commands: z40.literal(true).optional(),
3992
4028
  /** The daemon answers `openrig.row`. */
3993
- rigRows: z39.literal(true).optional(),
4029
+ rigRows: z40.literal(true).optional(),
3994
4030
  /** The daemon answers `openrig.asks` and `openrig.answer` (« À toi »). */
3995
- openrig: z39.literal(true).optional(),
4031
+ openrig: z40.literal(true).optional(),
3996
4032
  /** The daemon takes `session.broadcast` (« Écrire au groupe »). */
3997
- broadcast: z39.literal(true).optional(),
4033
+ broadcast: z40.literal(true).optional(),
3998
4034
  /** The daemon answers `folder.list`, `folder.recents` and `project.folders`, and takes `project.folder.add` and `.remove`. */
3999
- projectFolders: z39.literal(true).optional(),
4035
+ projectFolders: z40.literal(true).optional(),
4000
4036
  /** The daemon takes `project.edit`, `project.order`, `project.create` and `project.delete` (Réglages › Projets). */
4001
- projectEdit: z39.literal(true).optional(),
4037
+ projectEdit: z40.literal(true).optional(),
4002
4038
  /** Issue #16: the snapshot and `projects` carry `sessionOrder`, and the daemon takes `session.order`. */
4003
- sessionOrder: z39.literal(true).optional(),
4039
+ sessionOrder: z40.literal(true).optional(),
4004
4040
  /** The daemon takes `task.answer` (#40): a decision answered from the phone, outside the chat. */
4005
- taskAnswer: z39.literal(true).optional(),
4041
+ taskAnswer: z40.literal(true).optional(),
4006
4042
  /** The daemon takes `device.prefs` and `context.set` (the phone's Réglages); the device then carries its `prefs`. */
4007
- settings: z39.literal(true).optional(),
4043
+ settings: z40.literal(true).optional(),
4008
4044
  /** The daemon sends `usage.state` (its harnesses' limits). */
4009
- usage: z39.literal(true).optional(),
4045
+ usage: z40.literal(true).optional(),
4010
4046
  /** The Atelier: the snapshot carries `projects`, each session its `projectId` and `rig`, and `projects` follows each change. Absent (an older PC): no Atelier. */
4011
- atelier: z39.literal(true).optional(),
4047
+ atelier: z40.literal(true).optional(),
4012
4048
  /** Rigs and the kernel: the daemon answers the `rigs.*` reads and takes `rigs.act`, `rigs.seats`, `rigs.goal.send` and `.reply`. Absent (an older PC): the Rigs tab says « rien à afficher ». */
4013
- rigs: z39.literal(true).optional(),
4049
+ rigs: z40.literal(true).optional(),
4014
4050
  /** « Nouvelle session »: the daemon takes `session.launch` and `project.folders` carries this PC's folders' branch. Absent (an older PC): « Nouvelle » cannot start. */
4015
- launch: z39.literal(true).optional(),
4051
+ launch: z40.literal(true).optional(),
4016
4052
  /** Pull and merge requests: the daemon answers `forge.state` and `forge.detail`, and takes `forge.act`. Absent (an older PC): the MR/PR tab says « rien à afficher ». */
4017
- forge: z39.literal(true).optional(),
4053
+ forge: z40.literal(true).optional(),
4018
4054
  /** The device's conversations are kept 7 days (M3 Q33): the daemon answers `chat.conversations` and `chat.conversation`, and
4019
4055
  * `chat.reset` puts the conversation away. Absent (an older PC): « Nouvelle conversation » forgets it. */
4020
- conversations: z39.literal(true).optional()
4056
+ conversations: z40.literal(true).optional()
4021
4057
  }),
4022
4058
  /** The user's projects (`daemon.atelier`), whole, in their order: absent from an older PC's snapshot. */
4023
- projects: z39.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX).optional(),
4059
+ projects: z40.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX).optional(),
4024
4060
  sessionOrder: PhoneSessionOrderSchema.optional(),
4025
- device: z39.object({
4026
- confirm: z39.boolean(),
4061
+ device: z40.object({
4062
+ confirm: z40.boolean(),
4027
4063
  /** Its passkey can bring it back after a reinstall: without it, « Mettre à jour la passkey ». */
4028
- recover: z39.literal(true).optional(),
4029
- push: z39.enum(["on", "off", "stale", "unavailable"]).optional(),
4030
- chat: z39.literal(true).optional(),
4064
+ recover: z40.literal(true).optional(),
4065
+ push: z40.enum(["on", "off", "stale", "unavailable"]).optional(),
4066
+ chat: z40.literal(true).optional(),
4031
4067
  contextNear: ContextPrefsSchema.shape.near.optional(),
4032
4068
  /** This device's id (its fingerprint, as decisions name it in `by`), its kind, and the name the user gave it (absent: none given). */
4033
- id: z39.string().optional(),
4069
+ id: z40.string().optional(),
4034
4070
  kind: DeviceKindSchema.optional(),
4035
- name: z39.string().optional(),
4071
+ name: z40.string().optional(),
4036
4072
  /** This device's own settings (`daemon.settings`). */
4037
4073
  prefs: DevicePrefsSchema.optional()
4038
4074
  }).optional()
4039
4075
  }),
4040
4076
  /** « À toi » on this PC: the answer to `openrig.asks`, then each change, whole. */
4041
- z39.object({ type: z39.literal("openrig.asks"), channel: HumanChannelSchema, asks: z39.array(HumanAskSchema), partial: z39.literal(true).optional(), truncated: z39.literal(true).optional() }),
4077
+ z40.object({ type: z40.literal("openrig.asks"), channel: HumanChannelSchema, asks: z40.array(HumanAskSchema), partial: z40.literal(true).optional(), truncated: z40.literal(true).optional() }),
4042
4078
  /** An answer's end, as on the desktop (`openrig.answered`), under the phone's `op`. `rejected`: the device check refused it (`reason`). */
4043
- z39.object({
4044
- type: z39.literal("openrig.answered"),
4079
+ z40.object({
4080
+ type: z40.literal("openrig.answered"),
4045
4081
  op: OperationIdSchema,
4046
- qitemId: z39.string(),
4047
- ok: z39.boolean(),
4048
- outcome: z39.enum(["recorded", "answered", "already"]).optional(),
4049
- remaining: z39.array(z39.string()).optional(),
4050
- replyId: z39.string().optional(),
4082
+ qitemId: z40.string(),
4083
+ ok: z40.boolean(),
4084
+ outcome: z40.enum(["recorded", "answered", "already"]).optional(),
4085
+ remaining: z40.array(z40.string()).optional(),
4086
+ replyId: z40.string().optional(),
4051
4087
  error: HumanAnswerErrorSchema.optional(),
4052
- message: z39.string().max(500).optional(),
4053
- rejected: z39.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]).optional()
4088
+ message: z40.string().max(500).optional(),
4089
+ rejected: z40.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]).optional()
4054
4090
  }),
4055
- z39.object({ type: z39.literal("confirm.challenge"), purpose: ConfirmPurposeSchema, challenge: B64U3.max(64), rpId: z39.string().max(253), credentialId: B64U3.max(1366).optional(), expiresInMs: z39.number().int().positive() }),
4056
- z39.object({ type: z39.literal("session.updated"), session: PhoneSessionSchema }),
4091
+ z40.object({ type: z40.literal("confirm.challenge"), purpose: ConfirmPurposeSchema, challenge: B64U3.max(64), rpId: z40.string().max(253), credentialId: B64U3.max(1366).optional(), expiresInMs: z40.number().int().positive() }),
4092
+ z40.object({ type: z40.literal("session.updated"), session: PhoneSessionSchema }),
4057
4093
  /** The user's projects changed (a name, a colour, one added or removed, the order) (`daemon.atelier`): the list, whole. A session placed
4058
4094
  * elsewhere by the change follows as its own `session.updated`, after this. */
4059
- z39.object({ type: z39.literal("projects"), projects: z39.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX), sessionOrder: PhoneSessionOrderSchema.optional() }),
4060
- z39.object({ type: z39.literal("session.removed"), id: z39.string() }),
4095
+ z40.object({ type: z40.literal("projects"), projects: z40.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX), sessionOrder: PhoneSessionOrderSchema.optional() }),
4096
+ z40.object({ type: z40.literal("session.removed"), id: z40.string() }),
4061
4097
  /** A session's checklist, sent to the phone that watches it; `null`: it has none (any more). */
4062
- z39.object({ type: z39.literal("session.checklist"), id: z39.string(), checklist: PhoneChecklistSchema.nullable() }),
4098
+ z40.object({ type: z40.literal("session.checklist"), id: z40.string(), checklist: PhoneChecklistSchema.nullable() }),
4063
4099
  /** `pending.cut` is set when even this body was shortened. */
4064
- z39.object({ type: z39.literal("session.pending"), id: z39.string(), pending: PhonePendingSchema }),
4065
- z39.object({ type: z39.literal("session.preview"), id: z39.string(), lines: z39.array(z39.string()) }),
4100
+ z40.object({ type: z40.literal("session.pending"), id: z40.string(), pending: PhonePendingSchema }),
4101
+ z40.object({ type: z40.literal("session.preview"), id: z40.string(), lines: z40.array(z40.string()) }),
4066
4102
  /** `cut`: the ids of the items shortened; `more`: older items were left out. */
4067
- z39.object({ type: z39.literal("session.thread"), id: z39.string(), items: z39.array(ThreadItemSchema), cut: z39.array(z39.string()), more: z39.boolean() }),
4068
- z39.object({ type: z39.literal("session.thread.item"), id: z39.string(), item: ThreadItemSchema, cut: z39.literal(true).optional() }),
4069
- z39.object({
4070
- type: z39.literal("operation.result"),
4103
+ z40.object({ type: z40.literal("session.thread"), id: z40.string(), items: z40.array(ThreadItemSchema), cut: z40.array(z40.string()), more: z40.boolean() }),
4104
+ z40.object({ type: z40.literal("session.thread.item"), id: z40.string(), item: ThreadItemSchema, cut: z40.literal(true).optional() }),
4105
+ z40.object({
4106
+ type: z40.literal("operation.result"),
4071
4107
  op: OperationIdSchema,
4072
4108
  status: OperationStatusSchema,
4073
4109
  reason: OperationReasonSchema.optional(),
4074
4110
  /** How an applied `session.close` ended the agent: `killed` when it had to be forced. */
4075
4111
  how: CloseHowSchema.optional(),
4076
4112
  /** An applied `session.launch`: the new session, whose thread the phone opens. */
4077
- id: z39.string().max(200).optional(),
4113
+ id: z40.string().max(200).optional(),
4078
4114
  /** An applied `session.broadcast`: the names that got it and those that did not. */
4079
- sent: z39.array(z39.string().max(100)).max(BROADCAST_SESSIONS_MAX).optional(),
4080
- refused: z39.array(z39.object({ name: z39.string().max(100), reason: z39.string().max(200) })).max(BROADCAST_SESSIONS_MAX).optional()
4115
+ sent: z40.array(z40.string().max(100)).max(BROADCAST_SESSIONS_MAX).optional(),
4116
+ refused: z40.array(z40.object({ name: z40.string().max(100), reason: z40.string().max(200) })).max(BROADCAST_SESSIONS_MAX).optional()
4081
4117
  }),
4082
4118
  /** The models an agent offers; `error`: it could not be asked, `models` is then what Ledge knows without it. */
4083
- z39.object({ type: z39.literal("models.listing"), tool: ToolSchema, models: z39.array(PhoneModelChoiceSchema).max(40), error: z39.literal(true).optional() }),
4119
+ z40.object({ type: z40.literal("models.listing"), tool: ToolSchema, models: z40.array(PhoneModelChoiceSchema).max(40), error: z40.literal(true).optional() }),
4084
4120
  /** A model change that was accepted and then failed (the agent could not restart). */
4085
- z39.object({ type: z39.literal("session.model.failed"), id: z39.string(), reason: ModelRefusalSchema }),
4121
+ z40.object({ type: z40.literal("session.model.failed"), id: z40.string(), reason: ModelRefusalSchema }),
4086
4122
  /** A « Rattacher à Ledge » done: the session is Ledge's now (`resume`: it was restarted on its conversation in Ledge's tmux). */
4087
- z39.object({ type: z39.literal("session.adopted"), id: z39.string(), path: AdoptPathSchema }),
4123
+ z40.object({ type: z40.literal("session.adopted"), id: z40.string(), path: AdoptPathSchema }),
4088
4124
  /** A « Rattacher à Ledge » that was accepted and then did not happen. */
4089
- z39.object({
4090
- type: z39.literal("session.adopt.failed"),
4091
- id: z39.string(),
4125
+ z40.object({
4126
+ type: z40.literal("session.adopt.failed"),
4127
+ id: z40.string(),
4092
4128
  reason: AdoptFailureSchema,
4093
4129
  /** `resume_failed`: the exit code of the resumed agent that quit at once (« claude a quitté au démarrage (code 1) »), when
4094
4130
  * known. Never the daemon's own words, which may hold a path. */
4095
- exitCode: z39.number().int().optional()
4131
+ exitCode: z40.number().int().optional()
4096
4132
  }),
4097
4133
  /** A session's slash commands; `error`: they could not be read (the agent is not listed, or did not answer in time): a command typed by hand still goes. */
4098
- z39.object({ type: z39.literal("session.commands.listing"), id: z39.string(), commands: z39.array(PhoneSlashCommandSchema).max(PHONE_COMMANDS_MAX), error: z39.literal(true).optional() }),
4134
+ z40.object({ type: z40.literal("session.commands.listing"), id: z40.string(), commands: z40.array(PhoneSlashCommandSchema).max(PHONE_COMMANDS_MAX), error: z40.literal(true).optional() }),
4099
4135
  /** A queue row's state, answering `openrig.row`: `row`, or `error`. */
4100
- z39.object({ type: z39.literal("openrig.rowState"), qitem: z39.string(), row: PhoneRigRowSchema.optional(), error: PhoneRowErrorSchema.optional() }),
4101
- z39.object({ type: z39.literal("chat.history"), turns: z39.array(PhoneChatTurnSchema).max(50) }),
4102
- z39.object({ type: z39.literal("chat.step"), qid: OperationIdSchema, step: PhoneChatStepSchema }),
4136
+ z40.object({ type: z40.literal("openrig.rowState"), qitem: z40.string(), row: PhoneRigRowSchema.optional(), error: PhoneRowErrorSchema.optional() }),
4137
+ z40.object({ type: z40.literal("chat.history"), turns: z40.array(PhoneChatTurnSchema).max(50) }),
4138
+ z40.object({ type: z40.literal("chat.step"), qid: OperationIdSchema, step: PhoneChatStepSchema }),
4103
4139
  /** The whole text so far, not an increment. */
4104
- z39.object({ type: z39.literal("chat.delta"), qid: OperationIdSchema, text: z39.string().max(THREAD_TEXT_MAX) }),
4105
- z39.object({ type: z39.literal("chat.done"), qid: OperationIdSchema, turn: PhoneChatTurnSchema }),
4106
- z39.object({ type: z39.literal("chat.error"), qid: OperationIdSchema, code: ChatErrorCodeSchema }),
4140
+ z40.object({ type: z40.literal("chat.delta"), qid: OperationIdSchema, text: z40.string().max(THREAD_TEXT_MAX) }),
4141
+ z40.object({ type: z40.literal("chat.done"), qid: OperationIdSchema, turn: PhoneChatTurnSchema }),
4142
+ z40.object({ type: z40.literal("chat.error"), qid: OperationIdSchema, code: ChatErrorCodeSchema }),
4107
4143
  /** The current conversation's answers that read the account limits, and when (M3 Q31): a phone shows the limits under each. Sent after a
4108
4144
  * `chat.history` or a `chat.done` that touches one, apart from the turn so that an older phone, whose turn schema is strict, loses nothing. */
4109
- z39.object({ type: z39.literal("chat.limits"), reads: z39.array(ChatLimitsReadSchema).max(50) }),
4145
+ z40.object({ type: z40.literal("chat.limits"), reads: z40.array(ChatLimitsReadSchema).max(50) }),
4110
4146
  /** The device's conversations (M3 Q33): the current one once it has a question, and the ones put away, the most recent first. */
4111
- z39.object({ type: z39.literal("chat.conversations"), current: ChatConversationSummarySchema.optional(), past: z39.array(ChatConversationSummarySchema).max(200) }),
4147
+ z40.object({ type: z40.literal("chat.conversations"), current: ChatConversationSummarySchema.optional(), past: z40.array(ChatConversationSummarySchema).max(200) }),
4112
4148
  /** One conversation, read-only, as `chat.history` gives its turns (`limits` as `chat.limits`); `error`: it is no longer kept. */
4113
- z39.object({
4114
- type: z39.literal("chat.conversation"),
4115
- id: z39.string().uuid(),
4116
- turns: z39.array(PhoneChatTurnSchema).max(50).optional(),
4117
- limits: z39.array(ChatLimitsReadSchema).max(50).optional(),
4118
- error: z39.literal("unknown").optional()
4149
+ z40.object({
4150
+ type: z40.literal("chat.conversation"),
4151
+ id: z40.string().uuid(),
4152
+ turns: z40.array(PhoneChatTurnSchema).max(50).optional(),
4153
+ limits: z40.array(ChatLimitsReadSchema).max(50).optional(),
4154
+ error: z40.literal("unknown").optional()
4119
4155
  }),
4120
4156
  /** The daemon updating or restarting itself, whoever asked: npm runs, then the service restarts (the link drops right after). */
4121
- z39.object({ type: z39.literal("daemon.progress"), version: z39.string().max(40), step: z39.enum(["installing", "restarting"]) }),
4122
- /** Nothing was changed. Never npm's output nor a command: both hold the PC's paths. */
4123
- z39.object({ type: z39.literal("daemon.failed"), version: z39.string().max(40), reason: UpdateFailureSchema }),
4157
+ z40.object({ type: z40.literal("daemon.progress"), version: z40.string().max(40), step: z40.enum(["installing", "restarting"]) }),
4158
+ /** Nothing was changed, unless `setup` (the version is installed, its setup failed). Never npm's output nor a command: both hold the PC's paths. */
4159
+ z40.object({ type: z40.literal("daemon.failed"), version: z40.string().max(40), reason: UpdateFailureSchema, setup: SetupFailedSchema }),
4124
4160
  /** The tasks Ledge gave, open or closed lately, after each snapshot; then each change. */
4125
- z39.object({ type: z39.literal("tasks"), tasks: z39.array(PhoneTaskSchema).max(200) }),
4126
- z39.object({ type: z39.literal("task.updated"), task: PhoneTaskSchema }),
4161
+ z40.object({ type: z40.literal("tasks"), tasks: z40.array(PhoneTaskSchema).max(200) }),
4162
+ z40.object({ type: z40.literal("task.updated"), task: PhoneTaskSchema }),
4127
4163
  /** The routines, newest first, without their prompt (the phone's list is read-only); then each change, or `removed` (its id). */
4128
4164
  // Not strict, as every routine schema: a newer PC's field never makes the list unreadable to an older phone.
4129
- z39.object({ type: z39.literal("routines"), routines: z39.array(PhoneRoutineSchema).max(ROUTINES_MAX) }),
4130
- z39.object({ type: z39.literal("routine.changed"), routine: PhoneRoutineSchema.optional(), removed: RoutineIdSchema.optional() }),
4165
+ z40.object({ type: z40.literal("routines"), routines: z40.array(PhoneRoutineSchema).max(ROUTINES_MAX) }),
4166
+ z40.object({ type: z40.literal("routine.changed"), routine: PhoneRoutineSchema.optional(), removed: RoutineIdSchema.optional() }),
4131
4167
  /** The answer to `routine.show`: the routine whole, or `gone` when there is no such routine now. */
4132
- z39.object({ type: z39.literal("routine.detail"), id: RoutineIdSchema, routine: PhoneRoutineDetailSchema.optional(), gone: z39.literal(true).optional() }),
4168
+ z40.object({ type: z40.literal("routine.detail"), id: RoutineIdSchema, routine: PhoneRoutineDetailSchema.optional(), gone: z40.literal(true).optional() }),
4133
4169
  AttachmentStoredSchema,
4134
4170
  AttachmentDataSchema,
4135
4171
  AttachmentErrorSchema,
4136
4172
  /** A terminal's first screen (also the answer to `term.resync`, then without `op`): the pane's size, the cursor, and the `seq` the next output takes. */
4137
- z39.object({
4138
- type: z39.literal("term.opened"),
4173
+ z40.object({
4174
+ type: z40.literal("term.opened"),
4139
4175
  op: OperationIdSchema.optional(),
4140
4176
  tid: TerminalIdSchema,
4141
- id: z39.string(),
4177
+ id: z40.string(),
4142
4178
  cols: TermDimSchema,
4143
4179
  rows: TermDimSchema,
4144
- screen: z39.string().max(TERM_SCREEN_MAX),
4145
- cursor: z39.object({ x: z39.number().int().nonnegative(), y: z39.number().int().nonnegative() }),
4146
- seq: z39.number().int().nonnegative(),
4180
+ screen: z40.string().max(TERM_SCREEN_MAX),
4181
+ cursor: z40.object({ x: z40.number().int().nonnegative(), y: z40.number().int().nonnegative() }),
4182
+ seq: z40.number().int().nonnegative(),
4147
4183
  /** Read-only for good: a subagent's page shows its parent's pane. */
4148
- readOnly: z39.literal(true).optional()
4184
+ readOnly: z40.literal(true).optional()
4149
4185
  }),
4150
4186
  /** What the pane printed since the last one; `seq` + 1 each time. */
4151
- z39.object({ type: z39.literal("term.output"), tid: TerminalIdSchema, seq: z39.number().int().nonnegative(), data: z39.string().min(1).max(TERM_OUTPUT_MAX) }),
4152
- z39.object({ type: z39.literal("term.size"), tid: TerminalIdSchema, cols: TermDimSchema, rows: TermDimSchema }),
4187
+ z40.object({ type: z40.literal("term.output"), tid: TerminalIdSchema, seq: z40.number().int().nonnegative(), data: z40.string().min(1).max(TERM_OUTPUT_MAX) }),
4188
+ z40.object({ type: z40.literal("term.size"), tid: TerminalIdSchema, cols: TermDimSchema, rows: TermDimSchema }),
4153
4189
  /** The phone holds the hand until `until`, pushed back by each key (5 min), never past 30 min from the hold. */
4154
- z39.object({ type: z39.literal("term.held"), tid: TerminalIdSchema, until: z39.string().datetime() }),
4155
- z39.object({ type: z39.literal("term.released"), tid: TerminalIdSchema, why: TermReleaseWhySchema }),
4156
- z39.object({ type: z39.literal("term.exit"), tid: TerminalIdSchema, why: TermExitWhySchema }),
4190
+ z40.object({ type: z40.literal("term.held"), tid: TerminalIdSchema, until: z40.string().datetime() }),
4191
+ z40.object({ type: z40.literal("term.released"), tid: TerminalIdSchema, why: TermReleaseWhySchema }),
4192
+ z40.object({ type: z40.literal("term.exit"), tid: TerminalIdSchema, why: TermExitWhySchema }),
4157
4193
  /** Never carries free text. */
4158
4194
  /** The subfolders of `path` on this PC (home when asked without one); `parent` null at the root. */
4159
- z39.object({
4160
- type: z39.literal("folder.listing"),
4195
+ z40.object({
4196
+ type: z40.literal("folder.listing"),
4161
4197
  path: FolderPathSchema,
4162
4198
  parent: FolderPathSchema.nullable(),
4163
- entries: z39.array(z39.string().min(1).max(255)).max(PHONE_FOLDER_ENTRIES_MAX),
4164
- repos: z39.array(z39.object({ name: z39.string().min(1).max(255), branch: z39.string().max(200) })).max(PHONE_FOLDER_ENTRIES_MAX),
4165
- cut: z39.literal(true).optional(),
4199
+ entries: z40.array(z40.string().min(1).max(255)).max(PHONE_FOLDER_ENTRIES_MAX),
4200
+ repos: z40.array(z40.object({ name: z40.string().min(1).max(255), branch: z40.string().max(200) })).max(PHONE_FOLDER_ENTRIES_MAX),
4201
+ cut: z40.literal(true).optional(),
4166
4202
  error: PhoneFolderErrorSchema.optional()
4167
4203
  }),
4168
- z39.object({ type: z39.literal("folder.recents"), paths: z39.array(FolderPathSchema).max(PHONE_RECENT_FOLDERS_MAX) }),
4204
+ z40.object({ type: z40.literal("folder.recents"), paths: z40.array(FolderPathSchema).max(PHONE_RECENT_FOLDERS_MAX) }),
4169
4205
  /** A project's folders, in its order; `gone`: no such project now. */
4170
- z39.object({ type: z39.literal("project.folders"), id: z39.string(), folders: z39.array(PhoneFolderSchema).max(50), gone: z39.literal(true).optional() }),
4171
- z39.object({ type: z39.literal("error"), code: z39.enum(["invalid", "unknown_session", "too_large"]), request: z39.string().max(40).optional() }),
4206
+ z40.object({ type: z40.literal("project.folders"), id: z40.string(), folders: z40.array(PhoneFolderSchema).max(50), gone: z40.literal(true).optional() }),
4207
+ z40.object({ type: z40.literal("error"), code: z40.enum(["invalid", "unknown_session", "too_large"]), request: z40.string().max(40).optional() }),
4172
4208
  // ── Rigs and the kernel (`daemon.rigs`) ──
4173
4209
  /** `error`: OpenRig could not be read (`state` absent). */
4174
- z39.object({ type: z39.literal("rigs.state"), state: PhoneOpenRigStateSchema.optional(), error: PhoneRigErrorSchema.optional() }).strict(),
4210
+ z40.object({ type: z40.literal("rigs.state"), state: PhoneOpenRigStateSchema.optional(), error: PhoneRigErrorSchema.optional() }).strict(),
4175
4211
  // ── Pull and merge requests (`daemon.forge`) ──
4176
4212
  /** After `forge.state`, then on each change, whole. */
4177
- z39.object({ type: z39.literal("forge.state"), ...PhoneForgeStateSchema.shape }).strict(),
4213
+ z40.object({ type: z40.literal("forge.state"), ...PhoneForgeStateSchema.shape }).strict(),
4178
4214
  /** `cut`: the gateway left out patches, discussions or commits, or shortened texts, to fit the frame. */
4179
- z39.object({ type: z39.literal("forge.detail"), prId: z39.string(), detail: PrDetailSchema.optional(), cut: z39.literal(true).optional(), error: PhoneForgeErrorSchema.optional() }).strict(),
4215
+ z40.object({ type: z40.literal("forge.detail"), prId: z40.string(), detail: PrDetailSchema.optional(), cut: z40.literal(true).optional(), error: PhoneForgeErrorSchema.optional() }).strict(),
4180
4216
  /** An action's end, under its `op` (`operation.result` says whether it ran). `command`: what ran; `message`: gh's or glab's line when `failed`. */
4181
- z39.object({
4182
- type: z39.literal("forge.done"),
4217
+ z40.object({
4218
+ type: z40.literal("forge.done"),
4183
4219
  op: OperationIdSchema,
4184
- ok: z39.boolean(),
4185
- command: z39.string().max(PHONE_FORGE_MESSAGE_MAX).optional(),
4220
+ ok: z40.boolean(),
4221
+ command: z40.string().max(PHONE_FORGE_MESSAGE_MAX).optional(),
4186
4222
  error: PhoneForgeActErrorSchema.optional(),
4187
- message: z39.string().max(PHONE_FORGE_MESSAGE_MAX).optional(),
4223
+ message: z40.string().max(PHONE_FORGE_MESSAGE_MAX).optional(),
4188
4224
  rejected: PhoneForgeRejectedSchema.optional()
4189
4225
  }).strict(),
4190
- z39.object({ type: z39.literal("rigs.graph"), rig: z39.string(), graph: RigGraphSchema.optional(), error: PhoneRigErrorSchema.optional() }).strict(),
4226
+ z40.object({ type: z40.literal("rigs.graph"), rig: z40.string(), graph: RigGraphSchema.optional(), error: PhoneRigErrorSchema.optional() }).strict(),
4191
4227
  /** `rows`: open (pending, in-progress, blocked), newest first; `closed`: closed lately, newest first; `truncated`: older open rows may be missing. */
4192
- z39.object({
4193
- type: z39.literal("rigs.queue"),
4194
- rig: z39.string(),
4195
- rows: z39.array(PhoneRigQueueRowSchema).max(PHONE_RIG_ROWS_MAX),
4196
- closed: z39.array(PhoneRigQueueRowSchema).max(PHONE_RIG_ROWS_MAX),
4197
- truncated: z39.boolean(),
4228
+ z40.object({
4229
+ type: z40.literal("rigs.queue"),
4230
+ rig: z40.string(),
4231
+ rows: z40.array(PhoneRigQueueRowSchema).max(PHONE_RIG_ROWS_MAX),
4232
+ closed: z40.array(PhoneRigQueueRowSchema).max(PHONE_RIG_ROWS_MAX),
4233
+ truncated: z40.boolean(),
4198
4234
  error: PhoneRigErrorSchema.optional()
4199
4235
  }).strict(),
4200
4236
  /** Oldest first, at most 20. */
4201
- z39.object({ type: z39.literal("rigs.routing"), entries: z39.array(PhoneRigRoutingSchema).max(20), error: PhoneRigErrorSchema.optional() }).strict(),
4202
- z39.object({ type: z39.literal("rigs.permissions"), rig: z39.string(), policy: z39.string().max(PHONE_RIG_TEXT_MAX).optional(), seats: z39.array(PhoneRigPermissionSchema).max(PHONE_RIG_SEATS_MAX), error: PhoneRigErrorSchema.optional() }).strict(),
4203
- z39.object({ type: z39.literal("rigs.snapshots"), rig: z39.string(), snapshots: z39.array(RigSnapshotSchema).max(20), error: PhoneRigErrorSchema.optional() }).strict(),
4204
- z39.object({ type: z39.literal("rigs.goals"), goals: z39.array(PhoneGoalSchema).max(PHONE_GOALS_MAX), partial: z39.literal(true).optional(), error: PhoneRigErrorSchema.optional() }).strict(),
4237
+ z40.object({ type: z40.literal("rigs.routing"), entries: z40.array(PhoneRigRoutingSchema).max(20), error: PhoneRigErrorSchema.optional() }).strict(),
4238
+ z40.object({ type: z40.literal("rigs.permissions"), rig: z40.string(), policy: z40.string().max(PHONE_RIG_TEXT_MAX).optional(), seats: z40.array(PhoneRigPermissionSchema).max(PHONE_RIG_SEATS_MAX), error: PhoneRigErrorSchema.optional() }).strict(),
4239
+ z40.object({ type: z40.literal("rigs.snapshots"), rig: z40.string(), snapshots: z40.array(RigSnapshotSchema).max(20), error: PhoneRigErrorSchema.optional() }).strict(),
4240
+ z40.object({ type: z40.literal("rigs.goals"), goals: z40.array(PhoneGoalSchema).max(PHONE_GOALS_MAX), partial: z40.literal(true).optional(), error: PhoneRigErrorSchema.optional() }).strict(),
4205
4241
  /** An action's end, under its `op` (`operation.result` says whether it ran). `commands`: the `rig` commands as shown; `error`: `busy`, `not_installed`,
4206
4242
  * `spec_unknown`, `spec_no_policy`, `spec_policy_unsupported`, or `failed` with `message`, OpenRig's last line; `completed` as the Desktop's. */
4207
- z39.object({
4208
- type: z39.literal("rigs.done"),
4243
+ z40.object({
4244
+ type: z40.literal("rigs.done"),
4209
4245
  op: OperationIdSchema,
4210
- ok: z39.boolean(),
4211
- commands: z39.array(z39.string().max(PHONE_RIG_TEXT_MAX)).max(400),
4212
- error: z39.string().max(40).optional(),
4213
- message: z39.string().max(PHONE_RIG_TEXT_MAX).optional(),
4214
- completed: z39.number().int().min(0).optional(),
4246
+ ok: z40.boolean(),
4247
+ commands: z40.array(z40.string().max(PHONE_RIG_TEXT_MAX)).max(400),
4248
+ error: z40.string().max(40).optional(),
4249
+ message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
4250
+ completed: z40.number().int().min(0).optional(),
4215
4251
  rejected: PhoneRigRejectedSchema.optional()
4216
4252
  }).strict(),
4217
4253
  /** A change of seats ended: `added` / `removed` as `pod.member`; `error`: `rig_not_running`, `rig_root_unknown`, `busy`, or `failed` with `message`. */
4218
- z39.object({
4219
- type: z39.literal("rigs.reseated"),
4254
+ z40.object({
4255
+ type: z40.literal("rigs.reseated"),
4220
4256
  op: OperationIdSchema,
4221
- ok: z39.boolean(),
4222
- commands: z39.array(z39.string().max(PHONE_RIG_TEXT_MAX)).max(400),
4223
- added: z39.array(z39.string()).max(PHONE_RIG_SEATS_MAX),
4224
- removed: z39.array(z39.string()).max(PHONE_RIG_SEATS_MAX),
4225
- error: z39.string().max(40).optional(),
4226
- message: z39.string().max(PHONE_RIG_TEXT_MAX).optional(),
4227
- links: z39.number().int().optional(),
4228
- linksUnsupported: z39.boolean().optional(),
4257
+ ok: z40.boolean(),
4258
+ commands: z40.array(z40.string().max(PHONE_RIG_TEXT_MAX)).max(400),
4259
+ added: z40.array(z40.string()).max(PHONE_RIG_SEATS_MAX),
4260
+ removed: z40.array(z40.string()).max(PHONE_RIG_SEATS_MAX),
4261
+ error: z40.string().max(40).optional(),
4262
+ message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
4263
+ links: z40.number().int().optional(),
4264
+ linksUnsupported: z40.boolean().optional(),
4229
4265
  rejected: PhoneRigRejectedSchema.optional()
4230
4266
  }).strict(),
4231
- z39.object({
4232
- type: z39.literal("rigs.goal.sent"),
4267
+ z40.object({
4268
+ type: z40.literal("rigs.goal.sent"),
4233
4269
  op: OperationIdSchema,
4234
- goalId: z39.string(),
4235
- ok: z39.boolean(),
4236
- qitemId: z39.string().optional(),
4270
+ goalId: z40.string(),
4271
+ ok: z40.boolean(),
4272
+ qitemId: z40.string().optional(),
4237
4273
  error: GoalErrorSchema.optional(),
4238
- message: z39.string().max(PHONE_RIG_TEXT_MAX).optional(),
4274
+ message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
4239
4275
  rejected: PhoneRigRejectedSchema.optional()
4240
4276
  }).strict(),
4241
- z39.object({
4242
- type: z39.literal("rigs.goal.replied"),
4277
+ z40.object({
4278
+ type: z40.literal("rigs.goal.replied"),
4243
4279
  op: OperationIdSchema,
4244
- goalId: z39.string(),
4245
- replyId: z39.string(),
4246
- ok: z39.boolean(),
4247
- qitemId: z39.string().optional(),
4280
+ goalId: z40.string(),
4281
+ replyId: z40.string(),
4282
+ ok: z40.boolean(),
4283
+ qitemId: z40.string().optional(),
4248
4284
  error: GoalErrorSchema.optional(),
4249
- message: z39.string().max(PHONE_RIG_TEXT_MAX).optional(),
4285
+ message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
4250
4286
  rejected: PhoneRigRejectedSchema.optional()
4251
4287
  }).strict()
4252
4288
  ]);
@@ -4258,8 +4294,8 @@ var ConfigError = class extends Error {
4258
4294
  this.name = "ConfigError";
4259
4295
  }
4260
4296
  };
4261
- var TokensSchema = z40.record(z40.string().min(1), z40.object({ accountId: z40.string().min(1), peer: RelayPeerSchema }));
4262
- var PortSchema = z40.coerce.number().int().min(0).max(65535);
4297
+ var TokensSchema = z41.record(z41.string().min(1), z41.object({ accountId: z41.string().min(1), peer: RelayPeerSchema }));
4298
+ var PortSchema = z41.coerce.number().int().min(0).max(65535);
4263
4299
  function required(env, name) {
4264
4300
  const v = env[name];
4265
4301
  if (!v) throw new ConfigError(`${name} is not set`);
@@ -4592,10 +4628,10 @@ function countedLog(log, ms) {
4592
4628
 
4593
4629
  // src/routes.ts
4594
4630
  import { createHash as createHash3, timingSafeEqual as timingSafeEqual2 } from "crypto";
4595
- import { z as z42 } from "zod";
4631
+ import { z as z43 } from "zod";
4596
4632
 
4597
4633
  // src/github.ts
4598
- import { z as z41 } from "zod";
4634
+ import { z as z42 } from "zod";
4599
4635
  var GitHubError = class extends Error {
4600
4636
  code;
4601
4637
  constructor(code) {
@@ -4604,21 +4640,21 @@ var GitHubError = class extends Error {
4604
4640
  this.code = code;
4605
4641
  }
4606
4642
  };
4607
- var DeviceStartSchema = z41.object({
4608
- device_code: z41.string().min(1),
4609
- user_code: z41.string().min(1),
4610
- verification_uri: z41.string().min(1),
4611
- expires_in: z41.number().int().positive(),
4612
- interval: z41.number().int().positive()
4613
- });
4614
- var TokenAnswerSchema = z41.object({
4615
- access_token: z41.string().min(1).optional(),
4616
- error: z41.string().optional(),
4617
- interval: z41.number().int().positive().optional()
4618
- });
4619
- var UserSchema = z41.object({
4620
- id: z41.number().int().nonnegative(),
4621
- login: z41.string().min(1)
4643
+ var DeviceStartSchema = z42.object({
4644
+ device_code: z42.string().min(1),
4645
+ user_code: z42.string().min(1),
4646
+ verification_uri: z42.string().min(1),
4647
+ expires_in: z42.number().int().positive(),
4648
+ interval: z42.number().int().positive()
4649
+ });
4650
+ var TokenAnswerSchema = z42.object({
4651
+ access_token: z42.string().min(1).optional(),
4652
+ error: z42.string().optional(),
4653
+ interval: z42.number().int().positive().optional()
4654
+ });
4655
+ var UserSchema = z42.object({
4656
+ id: z42.number().int().nonnegative(),
4657
+ login: z42.string().min(1)
4622
4658
  });
4623
4659
  var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
4624
4660
  var USER_AGENT = "ledge-relay";
@@ -4873,10 +4909,10 @@ async function readJson(req, schema, max = MAX_BODY) {
4873
4909
  if (!r.success) throw new Answer(400, "bad_request");
4874
4910
  return r.data;
4875
4911
  }
4876
- var RevokeBodySchema = z42.object({
4912
+ var RevokeBodySchema = z43.object({
4877
4913
  peer: RelayPeerSchema.refine((p) => p !== "pc")
4878
4914
  });
4879
- var PollBodySchema = z42.object({ deviceCode: z42.string().min(1).max(1024) });
4915
+ var PollBodySchema = z43.object({ deviceCode: z43.string().min(1).max(1024) });
4880
4916
  function authRoutes(deps) {
4881
4917
  const maxCalls = deps.maxGitHubCalls ?? DEFAULT_MAX_GITHUB_CALLS;
4882
4918
  let inFlight = 0;