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