@paradow/ledge-relay 0.64.0 → 0.66.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 z41 } from "zod";
5
+ import { z as z40 } from "zod";
6
6
 
7
7
  // ../../packages/protocol/src/attachments.ts
8
8
  import { z } from "zod";
@@ -1093,7 +1093,10 @@ var ACTION_IDS = [
1093
1093
  "rig.send",
1094
1094
  "brain.answer",
1095
1095
  "session.handover",
1096
- "pr.fix"
1096
+ "pr.fix",
1097
+ "session.topic",
1098
+ "session.move",
1099
+ "session.delete"
1097
1100
  ];
1098
1101
  var ActionIdSchema = z11.enum(ACTION_IDS);
1099
1102
  var def = (d) => d;
@@ -1376,8 +1379,50 @@ var ACTIONS = [
1376
1379
  summary: "demander \xE0 la session d'une pull request suivie de corriger son pipeline en \xE9chec (pr, son id de prs.md ; session, sinon la plus active de la branche)",
1377
1380
  when: "seulement quand l'utilisateur demande explicitement de faire corriger une pull request ou son pipeline, et que prs.md la montre suivie",
1378
1381
  example: { pr: "github.com/alice/api#226" }
1382
+ }),
1383
+ // The CLI's own (chat: false): what Desktop's « Gérer la session » does and the chat never proposes, so a session (the user's
1384
+ // « chef ») can tidy the others up from its shell.
1385
+ def({
1386
+ id: "session.topic",
1387
+ args: z11.object({ session: SessionRef, topic: z11.string().trim().max(500) }),
1388
+ card: "generic",
1389
+ phone: null,
1390
+ risk: "reversible",
1391
+ max: 8,
1392
+ chat: false,
1393
+ cli: 'ledge rename <session> "<sujet>"',
1394
+ summary: "changer le sujet d'une session (son nom d'agent ne change pas) ; un sujet vide rend la main au sujet automatique",
1395
+ when: "quand l'utilisateur demande de renommer une session",
1396
+ example: { session: "Nova", topic: "Pagination de /invoices" }
1397
+ }),
1398
+ def({
1399
+ id: "session.move",
1400
+ args: z11.object({ session: SessionRef, project: z11.string().trim().min(1).max(80) }),
1401
+ card: "generic",
1402
+ phone: null,
1403
+ risk: "reversible",
1404
+ max: 8,
1405
+ chat: false,
1406
+ cli: "ledge move <session> <projet>",
1407
+ summary: "ranger une session dans un projet (son id ou son nom) : son dossier y est rattach\xE9, comme \xAB Ranger dans\u2026 \xBB de Desktop",
1408
+ when: "quand l'utilisateur demande de ranger ou de d\xE9placer une session dans un projet",
1409
+ example: { session: "Nova", project: "iptv" }
1410
+ }),
1411
+ def({
1412
+ id: "session.delete",
1413
+ args: z11.object({ session: SessionRef }),
1414
+ card: "generic",
1415
+ phone: null,
1416
+ risk: "destructive",
1417
+ max: 8,
1418
+ chat: false,
1419
+ cli: "ledge delete <session> --yes",
1420
+ summary: "supprimer une session pour de bon, archiv\xE9e ou non (son agent est arr\xEAt\xE9) ; irr\xE9versible",
1421
+ when: "seulement quand l'utilisateur le lance lui-m\xEAme",
1422
+ example: { session: "Nova" }
1379
1423
  })
1380
1424
  ];
1425
+ var CHAT_ACTIONS = ACTIONS.filter((a) => a.chat !== false);
1381
1426
  var byId = new Map(ACTIONS.map((a) => [a.id, a]));
1382
1427
  var ActionBlockSchema = z11.object({ action: z11.string().trim().min(1).max(40), args: z11.record(z11.unknown()).default({}) });
1383
1428
 
@@ -1417,7 +1462,8 @@ var ChatPointSchema = z12.object({
1417
1462
  laterAt: z12.string().datetime().optional()
1418
1463
  });
1419
1464
  var OperatorNoticeSchema = z12.object({
1420
- /** `decision`: a decision a session put to the user (a task given to Ledge), said at once; its `id` is `decision:<task id>`. */
1465
+ /** `decision`: a decision a session put to the user (a task given to Ledge), said at once; its `id` is `decision:<task id>`.
1466
+ * `point`: sent only by daemons before #27 (the point left the dynamic island); kept so their notices still parse. */
1421
1467
  id: z12.string(),
1422
1468
  kind: z12.enum(["point", "rig.ask", "decision"]),
1423
1469
  qid: z12.string().optional(),
@@ -1713,22 +1759,25 @@ var IslandPrefsSchema = z19.object({
1713
1759
  * name, `#index` without one). `second`, written by older fronts, is the first monitor that is not the primary. */
1714
1760
  screen: z19.string().trim().min(1).max(200),
1715
1761
  position: z19.enum(["center", "left", "right"]),
1716
- /** A strip under a maximised window. */
1717
- discreet: z19.boolean(),
1762
+ /** Retired with the floating island (#27): it was a strip under a maximised window. Optional and never read, so a file or
1763
+ * a front that still carries it parses; still written by DEFAULT_ISLAND_PREFS because a daemon before #27 requires it in
1764
+ * `island.set`. */
1765
+ discreet: z19.boolean().optional(),
1718
1766
  islandScale: IslandScaleSchema,
1719
- panelScale: IslandScaleSchema,
1767
+ /** Retired with the floating island (#27): the island's size sizes its cards too. Optional and never read; still written by
1768
+ * DEFAULT_ISLAND_PREFS for daemons before #27, which require it. */
1769
+ panelScale: IslandScaleSchema.optional(),
1720
1770
  /** What the island shows besides asks and questions, which it always shows. */
1721
1771
  shows: z19.object({
1722
1772
  /** Allow, deny or answer in a line from the island; off, its cards only say « Open in Ledge ». */
1723
1773
  quick: z19.boolean(),
1724
- /** The 6 s bubble when an agent finishes. */
1774
+ /** The 6 s « Done » card when an agent finishes its turn. */
1725
1775
  finished: z19.boolean(),
1726
- /** An agent's sentence in a bubble. */
1727
- say: z19.boolean(),
1728
- /** The sub-agents next to their main agent. */
1729
- helpers: z19.boolean()
1776
+ /** Retired with the floating island (#27), like `helpers`: optional and never read, still written by default for older daemons. */
1777
+ say: z19.boolean().optional(),
1778
+ helpers: z19.boolean().optional()
1730
1779
  }),
1731
- /** The global shortcut that opens the island, as shown (`Ctrl Alt L`). */
1780
+ /** The global shortcut that reopens the oldest waiting request, as shown (`Ctrl Alt L`). */
1732
1781
  shortcut: z19.string().trim().min(1).max(40)
1733
1782
  });
1734
1783
 
@@ -1777,7 +1826,9 @@ ${rule.path}`;
1777
1826
  });
1778
1827
  return out;
1779
1828
  }
1780
- var ProjectsSchema = z20.object({ projects: z20.array(ProjectSchema).max(100), rules: z20.array(RuleSchema).max(1e3) }).superRefine((p, ctx) => {
1829
+ var SESSION_ORDER_MAX = 500;
1830
+ var SessionOrderSchema = z20.record(z20.string().max(64), z20.array(z20.string().min(1).max(300)).max(SESSION_ORDER_MAX));
1831
+ var ProjectsSchema = z20.object({ projects: z20.array(ProjectSchema).max(100), rules: z20.array(RuleSchema).max(1e3), order: SessionOrderSchema.optional() }).superRefine((p, ctx) => {
1781
1832
  for (const problem of projectsProblems(p)) ctx.addIssue({ code: "custom", message: problem.code, path: problem.path });
1782
1833
  });
1783
1834
 
@@ -2403,7 +2454,9 @@ var RefusalCodeSchema = z31.enum([
2403
2454
  "attachments_not_accepted",
2404
2455
  /** Issue #2: a project is saved with at least one folder (`folder_required`), and keeps its last one (`last_folder`). */
2405
2456
  "folder_required",
2406
- "last_folder"
2457
+ "last_folder",
2458
+ /** Issue #15: a name given at launch is taken (nameRefusal). */
2459
+ "name_taken"
2407
2460
  ]);
2408
2461
 
2409
2462
  // ../../packages/protocol/src/forge.ts
@@ -3005,6 +3058,8 @@ var ClientMessageSchema = z33.discriminatedUnion("type", [
3005
3058
  z33.object({ type: z33.literal("machines.set"), machines: MachinesSchema }),
3006
3059
  /** Replaces the local daemon's projects and rules as a whole; refused unless valid. */
3007
3060
  z33.object({ type: z33.literal("projects.set"), projects: ProjectsSchema }),
3061
+ /** Issue #16: one project's sessions' order (its id, or NO_PROJECT ''), as session keys (placeSessions); answered by `projects`. */
3062
+ z33.object({ type: z33.literal("sessions.order"), project: z33.string().max(64), ids: z33.array(z33.string().min(1).max(300)).max(SESSION_ORDER_MAX) }),
3008
3063
  /** Replaces the island's settings as a whole; refused unless valid. */
3009
3064
  z33.object({ type: z33.literal("island.set"), prefs: IslandPrefsSchema }),
3010
3065
  /** Mobile access (lot 3), local fronts only. A changed `relayUrl` drops the relay session. */
@@ -3289,7 +3344,7 @@ var RiskSchema = z39.enum(["low", "high"]);
3289
3344
  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
3345
  var OperationIdSchema = z39.string().uuid();
3291
3346
  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]);
3347
+ var OperationReasonSchema = z39.enum([...RefusalCodeSchema.options, "untypable", "confirm_required", "conflict", "assertion_invalid", "assertion_expired", "scheduled", "folder_taken", "not_found", "not_pending", ...ModelRefusalSchema.options]);
3293
3348
  var CapabilitiesSchema = z39.object({
3294
3349
  /** A question can be answered in free text. */
3295
3350
  freeTextAnswer: z39.boolean(),
@@ -3302,6 +3357,7 @@ var CapabilitiesByToolSchema = z39.object({ claude: CapabilitiesSchema, codex: C
3302
3357
  var PhonePendingSchema = PendingSchema.extend({ key: z39.string().max(64), risk: RiskSchema, riskReason: RiskReasonSchema, cut: z39.literal(true).optional() });
3303
3358
  var SwitchableSessionSchema = SessionSchema.extend({ canSwitch: z39.literal(true).optional() });
3304
3359
  var PhoneProjectSchema = z39.object({ id: ProjectIdSchema, name: z39.string().max(80), color: ProjectColorSchema });
3360
+ var PhoneSessionOrderSchema = z39.record(z39.string().max(64), z39.array(z39.string().max(200)).max(SESSION_ORDER_MAX));
3305
3361
  var PHONE_PROJECTS_MAX = 100;
3306
3362
  var PHONE_RIG_NAME_MAX = 100;
3307
3363
  var PhoneSessionSchema = SwitchableSessionSchema.pick({
@@ -3488,7 +3544,9 @@ var PhoneLaunchSchema = z39.object({
3488
3544
  prompt: z39.string().trim().min(1).max(MESSAGE_MAX),
3489
3545
  model: ModelIdSchema.optional(),
3490
3546
  effort: EffortSchema.optional(),
3491
- approval: OmpApprovalSchema.optional()
3547
+ approval: OmpApprovalSchema.optional(),
3548
+ /** Issue #15: the session's name (its address), cleaned as every name; taken: refused `name_taken`. Absent: the first free one. */
3549
+ name: z39.string().max(200).optional()
3492
3550
  }).strict();
3493
3551
  var PcActionSchema = z39.enum(["update", "restart"]);
3494
3552
  var PHONE_FOLDER_ENTRIES_MAX = 500;
@@ -3639,6 +3697,9 @@ var PhoneClientMessageSchema = z39.discriminatedUnion("type", [
3639
3697
  */
3640
3698
  z39.object({ type: z39.literal("project.edit"), op: OperationIdSchema, id: ProjectIdSchema, name: ProjectNameSchema.optional(), color: ProjectColorSchema.optional() }).strict(),
3641
3699
  z39.object({ type: z39.literal("project.order"), op: OperationIdSchema, ids: z39.array(ProjectIdSchema).min(1).max(PHONE_PROJECTS_MAX) }).strict(),
3700
+ /** Issue #16: some of a project's sessions (`project` null: « Sans projet ») in a new order, this PC's ids; the others keep their
3701
+ * places (placeSessions). A session not in that project, or one gone, makes it stale. */
3702
+ z39.object({ type: z39.literal("session.order"), op: OperationIdSchema, project: ProjectIdSchema.nullable(), ids: z39.array(z39.string().min(1).max(200)).min(1).max(SESSION_ORDER_MAX) }).strict(),
3642
3703
  /** Issue #2: with its first folder (`path`, of this PC) and the device's check over that name and folder (`newProjectSubject`). A
3643
3704
  * create without it, from an older phone, is refused `folder_required`. */
3644
3705
  z39.object({
@@ -3840,6 +3901,8 @@ var PhoneServerMessageSchema = z39.discriminatedUnion("type", [
3840
3901
  projectFolders: z39.literal(true).optional(),
3841
3902
  /** The daemon takes `project.edit`, `project.order`, `project.create` and `project.delete` (Réglages › Projets). */
3842
3903
  projectEdit: z39.literal(true).optional(),
3904
+ /** Issue #16: the snapshot and `projects` carry `sessionOrder`, and the daemon takes `session.order`. */
3905
+ sessionOrder: z39.literal(true).optional(),
3843
3906
  /** The daemon takes `device.prefs` and `context.set` (the phone's Réglages); the device then carries its `prefs`. */
3844
3907
  settings: z39.literal(true).optional(),
3845
3908
  /** The daemon sends `usage.state` (its harnesses' limits). */
@@ -3858,6 +3921,7 @@ var PhoneServerMessageSchema = z39.discriminatedUnion("type", [
3858
3921
  }),
3859
3922
  /** The user's projects (`daemon.atelier`), whole, in their order: absent from an older PC's snapshot. */
3860
3923
  projects: z39.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX).optional(),
3924
+ sessionOrder: PhoneSessionOrderSchema.optional(),
3861
3925
  device: z39.object({
3862
3926
  confirm: z39.boolean(),
3863
3927
  /** Its passkey can bring it back after a reinstall: without it, « Mettre à jour la passkey ». */
@@ -3892,7 +3956,7 @@ var PhoneServerMessageSchema = z39.discriminatedUnion("type", [
3892
3956
  z39.object({ type: z39.literal("session.updated"), session: PhoneSessionSchema }),
3893
3957
  /** The user's projects changed (a name, a colour, one added or removed, the order) (`daemon.atelier`): the list, whole. A session placed
3894
3958
  * elsewhere by the change follows as its own `session.updated`, after this. */
3895
- z39.object({ type: z39.literal("projects"), projects: z39.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX) }),
3959
+ z39.object({ type: z39.literal("projects"), projects: z39.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX), sessionOrder: PhoneSessionOrderSchema.optional() }),
3896
3960
  z39.object({ type: z39.literal("session.removed"), id: z39.string() }),
3897
3961
  /** A session's checklist, sent to the phone that watches it; `null`: it has none (any more). */
3898
3962
  z39.object({ type: z39.literal("session.checklist"), id: z39.string(), checklist: PhoneChecklistSchema.nullable() }),
@@ -4076,30 +4140,6 @@ var PhoneServerMessageSchema = z39.discriminatedUnion("type", [
4076
4140
  }).strict()
4077
4141
  ]);
4078
4142
 
4079
- // ../../packages/protocol/src/media.ts
4080
- import { z as z40 } from "zod";
4081
- var MediaCommandSchema = z40.enum(["previous", "play_pause", "next"]);
4082
- var ARTWORK_MAX_BYTES = 512 * 1024;
4083
- var NowPlayingSchema = z40.object({
4084
- /** The track's title; a session without one is not reported (nothing to show). */
4085
- title: z40.string().min(1),
4086
- /** '' when the player gives none (a web video often has no artist). */
4087
- artist: z40.string(),
4088
- album: z40.string().optional(),
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
4090
- * arrive in a later event than the track itself: players often publish the thumbnail a moment after the title. */
4091
- artwork: z40.string().startsWith("data:image/").optional(),
4092
- /** True while it plays; a paused session is still reported (with false), `null` means no media session at all. */
4093
- playing: z40.boolean(),
4094
- /** What the player accepts now; a control it refuses is disabled, not hidden, at the front's choice. */
4095
- can: z40.object({ previous: z40.boolean(), playPause: z40.boolean(), next: z40.boolean() }),
4096
- /** The player: SMTC's source app id (`Spotify.exe`, `MSEdge`, a packaged app's AUMID), and its display name when
4097
- * Windows knows one. Several players can hold a session: the one reported is the one playing (Windows' current one
4098
- * first), else Windows' current one. Commands go to that same player. */
4099
- player: z40.object({ id: z40.string().min(1), name: z40.string().optional() })
4100
- });
4101
- var NowPlayingStateSchema = NowPlayingSchema.nullable();
4102
-
4103
4143
  // src/config.ts
4104
4144
  var ConfigError = class extends Error {
4105
4145
  constructor(message) {
@@ -4107,8 +4147,8 @@ var ConfigError = class extends Error {
4107
4147
  this.name = "ConfigError";
4108
4148
  }
4109
4149
  };
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);
4150
+ var TokensSchema = z40.record(z40.string().min(1), z40.object({ accountId: z40.string().min(1), peer: RelayPeerSchema }));
4151
+ var PortSchema = z40.coerce.number().int().min(0).max(65535);
4112
4152
  function required(env, name) {
4113
4153
  const v = env[name];
4114
4154
  if (!v) throw new ConfigError(`${name} is not set`);
@@ -4441,10 +4481,10 @@ function countedLog(log, ms) {
4441
4481
 
4442
4482
  // src/routes.ts
4443
4483
  import { createHash as createHash3, timingSafeEqual as timingSafeEqual2 } from "crypto";
4444
- import { z as z43 } from "zod";
4484
+ import { z as z42 } from "zod";
4445
4485
 
4446
4486
  // src/github.ts
4447
- import { z as z42 } from "zod";
4487
+ import { z as z41 } from "zod";
4448
4488
  var GitHubError = class extends Error {
4449
4489
  code;
4450
4490
  constructor(code) {
@@ -4453,21 +4493,21 @@ var GitHubError = class extends Error {
4453
4493
  this.code = code;
4454
4494
  }
4455
4495
  };
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)
4496
+ var DeviceStartSchema = z41.object({
4497
+ device_code: z41.string().min(1),
4498
+ user_code: z41.string().min(1),
4499
+ verification_uri: z41.string().min(1),
4500
+ expires_in: z41.number().int().positive(),
4501
+ interval: z41.number().int().positive()
4502
+ });
4503
+ var TokenAnswerSchema = z41.object({
4504
+ access_token: z41.string().min(1).optional(),
4505
+ error: z41.string().optional(),
4506
+ interval: z41.number().int().positive().optional()
4507
+ });
4508
+ var UserSchema = z41.object({
4509
+ id: z41.number().int().nonnegative(),
4510
+ login: z41.string().min(1)
4471
4511
  });
4472
4512
  var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
4473
4513
  var USER_AGENT = "ledge-relay";
@@ -4722,10 +4762,10 @@ async function readJson(req, schema, max = MAX_BODY) {
4722
4762
  if (!r.success) throw new Answer(400, "bad_request");
4723
4763
  return r.data;
4724
4764
  }
4725
- var RevokeBodySchema = z43.object({
4765
+ var RevokeBodySchema = z42.object({
4726
4766
  peer: RelayPeerSchema.refine((p) => p !== "pc")
4727
4767
  });
4728
- var PollBodySchema = z43.object({ deviceCode: z43.string().min(1).max(1024) });
4768
+ var PollBodySchema = z42.object({ deviceCode: z42.string().min(1).max(1024) });
4729
4769
  function authRoutes(deps) {
4730
4770
  const maxCalls = deps.maxGitHubCalls ?? DEFAULT_MAX_GITHUB_CALLS;
4731
4771
  let inFlight = 0;
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  parsePublicUrl,
8
8
  startRelay,
9
9
  startupErrorLine
10
- } from "./chunk-KNMT653U.js";
10
+ } from "./chunk-OQPSXTOH.js";
11
11
 
12
12
  // src/cli.ts
13
13
  import { chmodSync as chmodSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync3, realpathSync } from "fs";
package/dist/main.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  loadConfig,
3
3
  startRelay,
4
4
  startupErrorLine
5
- } from "./chunk-KNMT653U.js";
5
+ } from "./chunk-OQPSXTOH.js";
6
6
 
7
7
  // src/main.ts
8
8
  function die(msg) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paradow/ledge-relay",
3
- "version": "0.64.0",
3
+ "version": "0.66.0",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "repository": {
6
6
  "type": "git",