@paradow/ledge-relay 0.66.0 → 0.68.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.
- package/dist/{chunk-OQPSXTOH.js → chunk-XNZAVWQ2.js} +1305 -1271
- package/dist/cli.js +1 -1
- package/dist/main.js +1 -1
- package/package.json +1 -1
- package/web/assets/{App-BSiUwkYQ.js → App-_yi572PP.js} +22 -22
- package/web/assets/{boot-D2V-wju8.js → boot-BbpqdzkM.js} +1 -1
- package/web/assets/index-CzqtV0OH.js +52 -0
- package/web/assets/{label-C-VicMT7.js → label-QUEtuA8i.js} +1 -1
- package/web/assets/{xterm-DmfYKkwX.js → xterm-BhZrDqc2.js} +1 -1
- package/web/build.json +1 -1
- package/web/index.html +1 -1
- package/web/sw.js +2 -2
- package/web/assets/index-C5B85TXh.js +0 -52
|
@@ -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
|
|
5
|
+
import { z as z41 } from "zod";
|
|
6
6
|
|
|
7
7
|
// ../../packages/protocol/src/attachments.ts
|
|
8
8
|
import { z } from "zod";
|
|
@@ -149,6 +149,7 @@ var BackgroundCommandSchema = z4.object({
|
|
|
149
149
|
taskId: z4.string().optional()
|
|
150
150
|
});
|
|
151
151
|
var TopicSourceSchema = z4.enum(["user", "pane", "prompt"]);
|
|
152
|
+
var SESSION_LABEL_MAX = 40;
|
|
152
153
|
var SessionSchema = z4.object({
|
|
153
154
|
/** Origin is annotated by the overlay, never used as an unqualified session id on the wire. */
|
|
154
155
|
machineId: z4.string().optional(),
|
|
@@ -158,6 +159,9 @@ var SessionSchema = z4.object({
|
|
|
158
159
|
offline: z4.boolean().optional(),
|
|
159
160
|
id: z4.string().min(1),
|
|
160
161
|
name: z4.string().min(1),
|
|
162
|
+
/** A nickname the person gave it (docs/mockups/ledge-sidebar-names.html, card 2): shown before its name, « KB Projet 1 (Otto) ».
|
|
163
|
+
* Only a label: the name stays its address for the other sessions, the tasks and the routines. */
|
|
164
|
+
label: z4.string().min(1).max(SESSION_LABEL_MAX).optional(),
|
|
161
165
|
tool: ToolSchema,
|
|
162
166
|
cwd: z4.string(),
|
|
163
167
|
project: z4.string(),
|
|
@@ -1718,23 +1722,43 @@ var TermOutputSchema = z16.object({ type: z16.literal("term.output"), id, shell:
|
|
|
1718
1722
|
var TermSizeSchema = z16.object({ type: z16.literal("term.size"), id, shell: shell.optional(), cols, rows });
|
|
1719
1723
|
var TermExitSchema = z16.object({ type: z16.literal("term.exit"), id, shell: shell.optional(), why: PaneExitWhySchema });
|
|
1720
1724
|
|
|
1725
|
+
// ../../packages/protocol/src/aside.ts
|
|
1726
|
+
import { z as z17 } from "zod";
|
|
1727
|
+
var ASIDE_QUESTION_MAX = 4e3;
|
|
1728
|
+
var ASIDE_ANSWER_MAX = 5e4;
|
|
1729
|
+
var AsideStateSchema = z17.enum(["asking", "answered", "failed"]);
|
|
1730
|
+
var AsideCauseSchema = z17.enum(["unsupported", "read_only", "busy", "not_empty", "no_panel", "timeout", "unreadable", "interrupted", "invalid"]).catch("invalid");
|
|
1731
|
+
var AsideSchema = z17.object({
|
|
1732
|
+
rid: z17.string().min(1).max(100),
|
|
1733
|
+
question: z17.string().max(ASIDE_QUESTION_MAX),
|
|
1734
|
+
askedAt: z17.string().datetime(),
|
|
1735
|
+
state: AsideStateSchema,
|
|
1736
|
+
/** The answer as Claude Code copies it: Markdown. */
|
|
1737
|
+
answer: z17.string().max(ASIDE_ANSWER_MAX).optional(),
|
|
1738
|
+
truncated: z17.literal(true).optional(),
|
|
1739
|
+
answeredAt: z17.string().datetime().optional(),
|
|
1740
|
+
cause: AsideCauseSchema.optional()
|
|
1741
|
+
});
|
|
1742
|
+
var SessionAsideAskSchema = z17.object({ type: z17.literal("session.aside"), id: z17.string().min(1), rid: z17.string().min(1).max(100), question: z17.string().trim().min(1).max(ASIDE_QUESTION_MAX) });
|
|
1743
|
+
var SessionAsideSchema = z17.object({ type: z17.literal("session.aside"), id: z17.string().min(1), aside: AsideSchema });
|
|
1744
|
+
|
|
1721
1745
|
// ../../packages/protocol/src/machines.ts
|
|
1722
|
-
import { z as
|
|
1746
|
+
import { z as z19 } from "zod";
|
|
1723
1747
|
|
|
1724
1748
|
// ../../packages/protocol/src/ssh.ts
|
|
1725
|
-
import { z as
|
|
1726
|
-
var SshAliasSchema =
|
|
1749
|
+
import { z as z18 } from "zod";
|
|
1750
|
+
var SshAliasSchema = z18.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,127}$/);
|
|
1727
1751
|
|
|
1728
1752
|
// ../../packages/protocol/src/machines.ts
|
|
1729
|
-
var MachineIdSchema =
|
|
1730
|
-
var MachineSchema =
|
|
1753
|
+
var MachineIdSchema = z19.string().regex(/^[a-zA-Z0-9_-]{1,64}$/);
|
|
1754
|
+
var MachineSchema = z19.object({
|
|
1731
1755
|
id: MachineIdSchema,
|
|
1732
|
-
label:
|
|
1756
|
+
label: z19.string().trim().min(1).max(80),
|
|
1733
1757
|
ssh: SshAliasSchema.optional(),
|
|
1734
1758
|
/** Kept in the list but never connected to: no peer, no retry, no session shown until it is enabled again. */
|
|
1735
|
-
disabled:
|
|
1759
|
+
disabled: z19.boolean().optional()
|
|
1736
1760
|
});
|
|
1737
|
-
var MachinesSchema =
|
|
1761
|
+
var MachinesSchema = z19.array(MachineSchema).min(1).max(20).superRefine((list, ctx) => {
|
|
1738
1762
|
if (list[0]?.id !== "local" || list[0].ssh !== void 0) ctx.addIssue({ code: "custom", message: "the first machine is local, without ssh", path: [0] });
|
|
1739
1763
|
const ids = /* @__PURE__ */ new Set(), aliases = /* @__PURE__ */ new Set();
|
|
1740
1764
|
list.forEach((m, i) => {
|
|
@@ -1750,57 +1774,57 @@ var MachinesSchema = z18.array(MachineSchema).min(1).max(20).superRefine((list,
|
|
|
1750
1774
|
});
|
|
1751
1775
|
|
|
1752
1776
|
// ../../packages/protocol/src/island.ts
|
|
1753
|
-
import { z as
|
|
1754
|
-
var IslandScaleSchema =
|
|
1755
|
-
var IslandPrefsSchema =
|
|
1777
|
+
import { z as z20 } from "zod";
|
|
1778
|
+
var IslandScaleSchema = z20.union([z20.literal("auto"), z20.literal(1), z20.literal(1.25), z20.literal(1.5), z20.literal(2)]);
|
|
1779
|
+
var IslandPrefsSchema = z20.object({
|
|
1756
1780
|
/** Shown at the top of the screen; hidden, Desktop still notifies. */
|
|
1757
|
-
visible:
|
|
1781
|
+
visible: z20.boolean(),
|
|
1758
1782
|
/** `primary` (whichever it is after a reconfiguration), or a monitor's id as the shell lists it (`list_monitors`: the OS
|
|
1759
1783
|
* name, `#index` without one). `second`, written by older fronts, is the first monitor that is not the primary. */
|
|
1760
|
-
screen:
|
|
1761
|
-
position:
|
|
1784
|
+
screen: z20.string().trim().min(1).max(200),
|
|
1785
|
+
position: z20.enum(["center", "left", "right"]),
|
|
1762
1786
|
/** Retired with the floating island (#27): it was a strip under a maximised window. Optional and never read, so a file or
|
|
1763
1787
|
* a front that still carries it parses; still written by DEFAULT_ISLAND_PREFS because a daemon before #27 requires it in
|
|
1764
1788
|
* `island.set`. */
|
|
1765
|
-
discreet:
|
|
1789
|
+
discreet: z20.boolean().optional(),
|
|
1766
1790
|
islandScale: IslandScaleSchema,
|
|
1767
1791
|
/** Retired with the floating island (#27): the island's size sizes its cards too. Optional and never read; still written by
|
|
1768
1792
|
* DEFAULT_ISLAND_PREFS for daemons before #27, which require it. */
|
|
1769
1793
|
panelScale: IslandScaleSchema.optional(),
|
|
1770
1794
|
/** What the island shows besides asks and questions, which it always shows. */
|
|
1771
|
-
shows:
|
|
1795
|
+
shows: z20.object({
|
|
1772
1796
|
/** Allow, deny or answer in a line from the island; off, its cards only say « Open in Ledge ». */
|
|
1773
|
-
quick:
|
|
1797
|
+
quick: z20.boolean(),
|
|
1774
1798
|
/** The 6 s « Done » card when an agent finishes its turn. */
|
|
1775
|
-
finished:
|
|
1799
|
+
finished: z20.boolean(),
|
|
1776
1800
|
/** Retired with the floating island (#27), like `helpers`: optional and never read, still written by default for older daemons. */
|
|
1777
|
-
say:
|
|
1778
|
-
helpers:
|
|
1801
|
+
say: z20.boolean().optional(),
|
|
1802
|
+
helpers: z20.boolean().optional()
|
|
1779
1803
|
}),
|
|
1780
1804
|
/** The global shortcut that reopens the oldest waiting request, as shown (`Ctrl Alt L`). */
|
|
1781
|
-
shortcut:
|
|
1805
|
+
shortcut: z20.string().trim().min(1).max(40)
|
|
1782
1806
|
});
|
|
1783
1807
|
|
|
1784
1808
|
// ../../packages/protocol/src/projects.ts
|
|
1785
|
-
import { z as
|
|
1786
|
-
var ProjectColorSchema =
|
|
1787
|
-
var ProjectIdSchema =
|
|
1809
|
+
import { z as z21 } from "zod";
|
|
1810
|
+
var ProjectColorSchema = z21.enum(["blue", "green", "amber", "violet", "teal", "pink", "red", "slate"]);
|
|
1811
|
+
var ProjectIdSchema = z21.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/);
|
|
1788
1812
|
function normalizePath(raw) {
|
|
1789
1813
|
const p = raw.trim().replace(/\/+/g, "/");
|
|
1790
1814
|
return p.length > 1 && p.endsWith("/") ? p.slice(0, -1) : p;
|
|
1791
1815
|
}
|
|
1792
|
-
var PathSchema =
|
|
1816
|
+
var PathSchema = z21.string().max(4096).refine((p) => p.startsWith("/") && p === normalizePath(p), "an absolute, normalized path");
|
|
1793
1817
|
var FolderPathSchema = PathSchema;
|
|
1794
|
-
var RepoSchema =
|
|
1795
|
-
var ProjectNameSchema =
|
|
1796
|
-
var ProjectSchema =
|
|
1818
|
+
var RepoSchema = z21.object({ machine: MachineIdSchema, path: PathSchema });
|
|
1819
|
+
var ProjectNameSchema = z21.string().trim().min(1).max(80);
|
|
1820
|
+
var ProjectSchema = z21.object({
|
|
1797
1821
|
id: ProjectIdSchema,
|
|
1798
1822
|
name: ProjectNameSchema,
|
|
1799
1823
|
color: ProjectColorSchema,
|
|
1800
|
-
description:
|
|
1801
|
-
repos:
|
|
1824
|
+
description: z21.string().max(500).default(""),
|
|
1825
|
+
repos: z21.array(RepoSchema).max(50)
|
|
1802
1826
|
});
|
|
1803
|
-
var RuleSchema =
|
|
1827
|
+
var RuleSchema = z21.object({ machine: MachineIdSchema, path: PathSchema, project: ProjectIdSchema });
|
|
1804
1828
|
function projectsProblems(p) {
|
|
1805
1829
|
const out = [];
|
|
1806
1830
|
const ids = /* @__PURE__ */ new Set(), names = /* @__PURE__ */ new Set(), repos = /* @__PURE__ */ new Set(), rules = /* @__PURE__ */ new Set();
|
|
@@ -1827,8 +1851,8 @@ ${rule.path}`;
|
|
|
1827
1851
|
return out;
|
|
1828
1852
|
}
|
|
1829
1853
|
var SESSION_ORDER_MAX = 500;
|
|
1830
|
-
var SessionOrderSchema =
|
|
1831
|
-
var ProjectsSchema =
|
|
1854
|
+
var SessionOrderSchema = z21.record(z21.string().max(64), z21.array(z21.string().min(1).max(300)).max(SESSION_ORDER_MAX));
|
|
1855
|
+
var ProjectsSchema = z21.object({ projects: z21.array(ProjectSchema).max(100), rules: z21.array(RuleSchema).max(1e3), order: SessionOrderSchema.optional() }).superRefine((p, ctx) => {
|
|
1832
1856
|
for (const problem of projectsProblems(p)) ctx.addIssue({ code: "custom", message: problem.code, path: problem.path });
|
|
1833
1857
|
});
|
|
1834
1858
|
|
|
@@ -1837,421 +1861,421 @@ var BROADCAST_SESSIONS_MAX = 32;
|
|
|
1837
1861
|
var BROADCAST_LABEL_MAX = 120;
|
|
1838
1862
|
|
|
1839
1863
|
// ../../packages/protocol/src/messages.ts
|
|
1840
|
-
import { z as
|
|
1864
|
+
import { z as z34 } from "zod";
|
|
1841
1865
|
|
|
1842
1866
|
// ../../packages/protocol/src/repos.ts
|
|
1843
|
-
import { z as
|
|
1844
|
-
var ReposInspectSchema =
|
|
1845
|
-
type:
|
|
1846
|
-
requestId:
|
|
1847
|
-
paths:
|
|
1848
|
-
machineId:
|
|
1849
|
-
});
|
|
1850
|
-
var RepoInfoSchema =
|
|
1851
|
-
var ReposInfoSchema =
|
|
1867
|
+
import { z as z22 } from "zod";
|
|
1868
|
+
var ReposInspectSchema = z22.object({
|
|
1869
|
+
type: z22.literal("repos.inspect"),
|
|
1870
|
+
requestId: z22.string().min(1).max(100),
|
|
1871
|
+
paths: z22.array(z22.string().min(1)).min(1).max(50),
|
|
1872
|
+
machineId: z22.string().optional()
|
|
1873
|
+
});
|
|
1874
|
+
var RepoInfoSchema = z22.object({ path: z22.string(), exists: z22.boolean(), branch: z22.string().nullable() });
|
|
1875
|
+
var ReposInfoSchema = z22.object({ type: z22.literal("repos.info"), requestId: z22.string(), repos: z22.array(RepoInfoSchema) });
|
|
1852
1876
|
|
|
1853
1877
|
// ../../packages/protocol/src/commands.ts
|
|
1854
|
-
import { z as
|
|
1855
|
-
var SlashSourceSchema =
|
|
1878
|
+
import { z as z23 } from "zod";
|
|
1879
|
+
var SlashSourceSchema = z23.enum(["builtin", "project", "user", "plugin", "extension"]);
|
|
1856
1880
|
var SLASH_COMMANDS_MAX = 400;
|
|
1857
1881
|
var SLASH_DESCRIPTION_MAX = 300;
|
|
1858
|
-
var SlashCommandSchema =
|
|
1859
|
-
name:
|
|
1860
|
-
description:
|
|
1861
|
-
argumentHint:
|
|
1862
|
-
aliases:
|
|
1882
|
+
var SlashCommandSchema = z23.object({
|
|
1883
|
+
name: z23.string().min(1).max(200),
|
|
1884
|
+
description: z23.string().max(SLASH_DESCRIPTION_MAX).optional(),
|
|
1885
|
+
argumentHint: z23.string().max(200).optional(),
|
|
1886
|
+
aliases: z23.array(z23.string().min(1).max(200)).max(10).optional(),
|
|
1863
1887
|
source: SlashSourceSchema,
|
|
1864
|
-
blocked:
|
|
1865
|
-
bare:
|
|
1866
|
-
});
|
|
1867
|
-
var SessionCommandsSchema =
|
|
1868
|
-
var SessionCommandsListingSchema =
|
|
1869
|
-
type:
|
|
1870
|
-
requestId:
|
|
1871
|
-
id:
|
|
1888
|
+
blocked: z23.enum(["panel", "close"]).optional(),
|
|
1889
|
+
bare: z23.literal("panel").optional()
|
|
1890
|
+
});
|
|
1891
|
+
var SessionCommandsSchema = z23.object({ type: z23.literal("session.commands"), requestId: z23.string().min(1).max(100), id: z23.string() });
|
|
1892
|
+
var SessionCommandsListingSchema = z23.object({
|
|
1893
|
+
type: z23.literal("session.commands.listing"),
|
|
1894
|
+
requestId: z23.string(),
|
|
1895
|
+
id: z23.string(),
|
|
1872
1896
|
tool: ToolSchema.optional(),
|
|
1873
|
-
commands:
|
|
1874
|
-
error:
|
|
1897
|
+
commands: z23.array(SlashCommandSchema).max(SLASH_COMMANDS_MAX),
|
|
1898
|
+
error: z23.string().max(200).optional()
|
|
1875
1899
|
});
|
|
1876
1900
|
|
|
1877
1901
|
// ../../packages/protocol/src/scan.ts
|
|
1878
|
-
import { z as
|
|
1879
|
-
var ReposScanSchema =
|
|
1880
|
-
var FoundRepoSchema =
|
|
1881
|
-
var ReposFoundSchema =
|
|
1902
|
+
import { z as z24 } from "zod";
|
|
1903
|
+
var ReposScanSchema = z24.object({ type: z24.literal("repos.scan"), requestId: z24.string().min(1).max(100), machineId: z24.string().optional() });
|
|
1904
|
+
var FoundRepoSchema = z24.object({ path: z24.string(), branch: z24.string().nullable(), remote: z24.string().optional(), manifest: z24.string().max(200).optional() });
|
|
1905
|
+
var ReposFoundSchema = z24.object({ type: z24.literal("repos.found"), requestId: z24.string(), repos: z24.array(FoundRepoSchema).max(500), truncated: z24.boolean(), error: z24.string().optional() });
|
|
1882
1906
|
|
|
1883
1907
|
// ../../packages/protocol/src/rigMessages.ts
|
|
1884
|
-
import { z as
|
|
1885
|
-
var QitemIdSchema =
|
|
1908
|
+
import { z as z25 } from "zod";
|
|
1909
|
+
var QitemIdSchema = z25.string().regex(/^qitem-[A-Za-z0-9-]{1,120}$/, "not a qitem");
|
|
1886
1910
|
var QITEM = "qitem-[A-Za-z0-9-]+";
|
|
1887
|
-
var RigKindSchema =
|
|
1888
|
-
var RigInfoSchema =
|
|
1911
|
+
var RigKindSchema = z25.enum(["message", "handoff", "unblocked", "openrig", "unreadable"]);
|
|
1912
|
+
var RigInfoSchema = z25.object({
|
|
1889
1913
|
kind: RigKindSchema,
|
|
1890
1914
|
/** The envelope's From, as written (`pilot-lead@ledge-dev-2`, `daemon@kernel`, `ledge@external`, `<unknown sender>`).
|
|
1891
1915
|
* On the seat's own `sent`: absent (it is the seat). The item's `peer` is the Ledge session of that seat, when known. */
|
|
1892
|
-
from:
|
|
1916
|
+
from: z25.string().optional(),
|
|
1893
1917
|
/** The envelope's To, as written (a seat, a list `a, b`, or `broadcast to <rig> (n seats)`); on an outgoing item, the
|
|
1894
1918
|
* destination the command named. */
|
|
1895
|
-
to:
|
|
1919
|
+
to: z25.string().optional(),
|
|
1896
1920
|
/** The envelope's `Sent:` stamp as an ISO time (OpenRig gives no year: the year of receipt, or the year before when
|
|
1897
1921
|
* that would put it in the future). Absent when the envelope has no `Sent:` line. */
|
|
1898
|
-
sentAt:
|
|
1922
|
+
sentAt: z25.string().datetime().optional(),
|
|
1899
1923
|
/** The sender's generation (8 hex), when the stamp carries one. */
|
|
1900
|
-
gen:
|
|
1924
|
+
gen: z25.string().optional(),
|
|
1901
1925
|
/** The row the item is about. `handoff`: the row handed (outgoing: the new row, when the command's output names it);
|
|
1902
1926
|
* `unblocked`: the parked row now pending; `openrig`: the row it names (a stuck sweep: the stalled row). */
|
|
1903
1927
|
qitem: QitemIdSchema.optional(),
|
|
1904
1928
|
/** `handoff`: the row's summary as OpenRig carried it (one line, at most 120 characters, `…` when cut). */
|
|
1905
|
-
summary:
|
|
1929
|
+
summary: z25.string().optional(),
|
|
1906
1930
|
/** `unblocked`: the row whose closing unblocked it. */
|
|
1907
1931
|
blocker: QitemIdSchema.optional(),
|
|
1908
1932
|
/** `openrig`: the recovery row OpenRig opened for it (a stuck sweep comes as a handoff of a `qitem-recovery-…` row). */
|
|
1909
1933
|
recovery: QitemIdSchema.optional(),
|
|
1910
1934
|
/** `openrig`: `stalled` a stuck sweep (a seat that does not move: amber), `custody` a custody check; else absent. */
|
|
1911
|
-
alert:
|
|
1935
|
+
alert: z25.enum(["stalled", "custody"]).optional(),
|
|
1912
1936
|
/** `openrig` with an alert: how long, in minutes, as OpenRig said. */
|
|
1913
|
-
minutes:
|
|
1937
|
+
minutes: z25.number().int().nonnegative().optional(),
|
|
1914
1938
|
/** The seat's own command (an outgoing `sent` or `handoff`): the Bash command, as run. */
|
|
1915
|
-
command:
|
|
1939
|
+
command: z25.string().optional(),
|
|
1916
1940
|
/** OpenRig said the delivery may repeat (`Recovered queue notification`). */
|
|
1917
|
-
recovered:
|
|
1941
|
+
recovered: z25.literal(true).optional(),
|
|
1918
1942
|
/** Received that many times (2 or more): the same block came again, and this item stands for all of them. */
|
|
1919
|
-
count:
|
|
1943
|
+
count: z25.number().int().min(2).optional(),
|
|
1920
1944
|
/** Blocks pasted together in one prompt: the prompt's id, this block's place and how many there were. The front shows
|
|
1921
1945
|
* one raw for the packet, the raws of its items joined. */
|
|
1922
|
-
packet:
|
|
1946
|
+
packet: z25.object({ id: z25.string().min(1), index: z25.number().int().nonnegative(), count: z25.number().int().min(2) }).optional(),
|
|
1923
1947
|
/** The block exactly as received (every delivery, separated by a blank line, when `count` is set); outgoing: the command
|
|
1924
1948
|
* and what it printed. Always there. */
|
|
1925
|
-
raw:
|
|
1949
|
+
raw: z25.string()
|
|
1926
1950
|
});
|
|
1927
1951
|
var HANDOFF = new RegExp(`^Queue handoff: (${QITEM}) - check your queue\\.(?: Summary: (.*))?$`);
|
|
1928
1952
|
var BLOCKER = new RegExp(`^Blocker (${QITEM}) resolved; parked qitem (${QITEM}) is pending\\.`);
|
|
1929
1953
|
var STALLED = new RegExp(`^Stuck sweep: \\S+ on (${QITEM}) \\((\\d+) min\\)`);
|
|
1930
1954
|
var CUSTODY = new RegExp(`^Custody not checked\\b.*?(?:for |of )(${QITEM}).*?\\((\\d+) min\\)`);
|
|
1931
|
-
var RigRowSchema =
|
|
1955
|
+
var RigRowSchema = z25.object({
|
|
1932
1956
|
id: QitemIdSchema,
|
|
1933
|
-
state:
|
|
1934
|
-
summary:
|
|
1957
|
+
state: z25.string().min(1),
|
|
1958
|
+
summary: z25.string().optional(),
|
|
1935
1959
|
/** Who made it and who holds it (seats). */
|
|
1936
|
-
from:
|
|
1937
|
-
to:
|
|
1960
|
+
from: z25.string(),
|
|
1961
|
+
to: z25.string(),
|
|
1938
1962
|
/** `handed-off`: the seat it went to. */
|
|
1939
|
-
handedOffTo:
|
|
1963
|
+
handedOffTo: z25.string().optional(),
|
|
1940
1964
|
/** `blocked`: the row it waits on. */
|
|
1941
|
-
blockedOn:
|
|
1942
|
-
createdAt:
|
|
1943
|
-
claimedAt:
|
|
1944
|
-
updatedAt:
|
|
1965
|
+
blockedOn: z25.string().optional(),
|
|
1966
|
+
createdAt: z25.string(),
|
|
1967
|
+
claimedAt: z25.string().optional(),
|
|
1968
|
+
updatedAt: z25.string(),
|
|
1945
1969
|
/** When Ledge read it. */
|
|
1946
|
-
at:
|
|
1970
|
+
at: z25.string(),
|
|
1947
1971
|
/** The request waits on a prompt (`waiting.liveness.needsInput`): how many, and why (`permission_prompt`…). Only set when `count` > 0. */
|
|
1948
|
-
needsInput:
|
|
1949
|
-
});
|
|
1950
|
-
var OpenRigRowSchema =
|
|
1951
|
-
var OpenRigRowStateSchema =
|
|
1952
|
-
type:
|
|
1953
|
-
requestId:
|
|
1954
|
-
machineId:
|
|
1955
|
-
qitem:
|
|
1972
|
+
needsInput: z25.object({ count: z25.number().int().min(1), reason: z25.string().nullable() }).optional()
|
|
1973
|
+
});
|
|
1974
|
+
var OpenRigRowSchema = z25.object({ type: z25.literal("openrig.row"), requestId: z25.string().min(1).max(100), qitem: QitemIdSchema, machineId: z25.string().optional() });
|
|
1975
|
+
var OpenRigRowStateSchema = z25.object({
|
|
1976
|
+
type: z25.literal("openrig.rowState"),
|
|
1977
|
+
requestId: z25.string(),
|
|
1978
|
+
machineId: z25.string().optional(),
|
|
1979
|
+
qitem: z25.string(),
|
|
1956
1980
|
row: RigRowSchema.optional(),
|
|
1957
|
-
error:
|
|
1958
|
-
});
|
|
1959
|
-
var OpenRigQueueSchema =
|
|
1960
|
-
var OpenRigQueueStateSchema =
|
|
1961
|
-
type:
|
|
1962
|
-
requestId:
|
|
1963
|
-
machineId:
|
|
1964
|
-
rig:
|
|
1965
|
-
rows:
|
|
1966
|
-
truncated:
|
|
1967
|
-
error:
|
|
1981
|
+
error: z25.string().optional()
|
|
1982
|
+
});
|
|
1983
|
+
var OpenRigQueueSchema = z25.object({ type: z25.literal("openrig.queue"), requestId: z25.string().min(1).max(100), machineId: z25.string().optional(), rig: RigNameSchema });
|
|
1984
|
+
var OpenRigQueueStateSchema = z25.object({
|
|
1985
|
+
type: z25.literal("openrig.queueState"),
|
|
1986
|
+
requestId: z25.string(),
|
|
1987
|
+
machineId: z25.string().optional(),
|
|
1988
|
+
rig: z25.string(),
|
|
1989
|
+
rows: z25.array(RigRowSchema),
|
|
1990
|
+
truncated: z25.boolean(),
|
|
1991
|
+
error: z25.string().optional()
|
|
1968
1992
|
});
|
|
1969
1993
|
|
|
1970
1994
|
// ../../packages/protocol/src/openrigRoles.ts
|
|
1971
|
-
import { z as
|
|
1972
|
-
var RoleUnknownWhySchema =
|
|
1973
|
-
var RoleFromSchema =
|
|
1974
|
-
var OriginSchema =
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1995
|
+
import { z as z26 } from "zod";
|
|
1996
|
+
var RoleUnknownWhySchema = z26.enum(["resolved_at_launch", "not_exposed", "unreadable", "ambiguous", "not_found", "missing_from_guidance"]);
|
|
1997
|
+
var RoleFromSchema = z26.enum(["import", "defaults", "profile", "rig", "pod", "member", "launch", "openrig", "plugin", "seat"]);
|
|
1998
|
+
var OriginSchema = z26.discriminatedUnion("kind", [
|
|
1999
|
+
z26.object({ kind: z26.literal("here"), key: z26.string().optional() }),
|
|
2000
|
+
z26.object({ kind: z26.literal("inherited"), from: RoleFromSchema, ref: z26.string().optional(), key: z26.string().optional(), path: z26.string().optional() }),
|
|
2001
|
+
z26.object({ kind: z26.literal("absent") }),
|
|
2002
|
+
z26.object({ kind: z26.literal("unknown"), why: RoleUnknownWhySchema, detail: z26.string().optional() })
|
|
1979
2003
|
]);
|
|
1980
|
-
var SourcedStringSchema =
|
|
1981
|
-
var RoleResourceCategorySchema =
|
|
1982
|
-
var RoleResourceSchema =
|
|
2004
|
+
var SourcedStringSchema = z26.object({ value: z26.string().nullable(), origin: OriginSchema });
|
|
2005
|
+
var RoleResourceCategorySchema = z26.enum(["skill", "guidance", "plugin", "subagent", "runtime_resource"]);
|
|
2006
|
+
var RoleResourceSchema = z26.object({
|
|
1983
2007
|
category: RoleResourceCategorySchema,
|
|
1984
|
-
id:
|
|
1985
|
-
path:
|
|
1986
|
-
absolutePath:
|
|
1987
|
-
runtime:
|
|
1988
|
-
type:
|
|
1989
|
-
target:
|
|
1990
|
-
plugin:
|
|
2008
|
+
id: z26.string(),
|
|
2009
|
+
path: z26.string().optional(),
|
|
2010
|
+
absolutePath: z26.string().optional(),
|
|
2011
|
+
runtime: z26.string().optional(),
|
|
2012
|
+
type: z26.string().optional(),
|
|
2013
|
+
target: z26.string().optional(),
|
|
2014
|
+
plugin: z26.object({ version: z26.string().optional(), skills: z26.array(z26.string()), hooks: z26.number().int().min(0) }).optional(),
|
|
1991
2015
|
origin: OriginSchema
|
|
1992
2016
|
});
|
|
1993
|
-
var RoleUsesListSchema =
|
|
1994
|
-
var StartupLayerSchema =
|
|
1995
|
-
var StartupEntrySchema =
|
|
1996
|
-
kind:
|
|
1997
|
-
path:
|
|
1998
|
-
absolutePath:
|
|
1999
|
-
size:
|
|
2000
|
-
value:
|
|
2001
|
-
builtin:
|
|
2017
|
+
var RoleUsesListSchema = z26.object({ declared: z26.boolean(), key: z26.string(), items: z26.array(RoleResourceSchema) });
|
|
2018
|
+
var StartupLayerSchema = z26.enum(["agent", "profile", "culture", "rig", "pod", "member", "openrig", "seat", "unknown"]);
|
|
2019
|
+
var StartupEntrySchema = z26.object({
|
|
2020
|
+
kind: z26.enum(["file", "action"]),
|
|
2021
|
+
path: z26.string().optional(),
|
|
2022
|
+
absolutePath: z26.string().optional(),
|
|
2023
|
+
size: z26.number().int().min(0).optional(),
|
|
2024
|
+
value: z26.string().optional(),
|
|
2025
|
+
builtin: z26.string().optional(),
|
|
2002
2026
|
layer: StartupLayerSchema,
|
|
2003
|
-
layerInferred:
|
|
2004
|
-
delivery:
|
|
2005
|
-
into:
|
|
2006
|
-
delivered:
|
|
2007
|
-
required:
|
|
2008
|
-
orientation:
|
|
2009
|
-
appliesOn:
|
|
2027
|
+
layerInferred: z26.boolean(),
|
|
2028
|
+
delivery: z26.string(),
|
|
2029
|
+
into: z26.string().optional(),
|
|
2030
|
+
delivered: z26.boolean().optional(),
|
|
2031
|
+
required: z26.boolean().optional(),
|
|
2032
|
+
orientation: z26.string().optional(),
|
|
2033
|
+
appliesOn: z26.array(z26.string()),
|
|
2010
2034
|
origin: OriginSchema
|
|
2011
2035
|
});
|
|
2012
|
-
var RoleFileErrorSchema =
|
|
2013
|
-
var RoleSummarySchema =
|
|
2014
|
-
id:
|
|
2015
|
-
name:
|
|
2016
|
-
version:
|
|
2017
|
-
description:
|
|
2018
|
-
source:
|
|
2019
|
-
path:
|
|
2020
|
-
runtime:
|
|
2021
|
-
importOnly:
|
|
2022
|
-
seats:
|
|
2023
|
-
running:
|
|
2024
|
-
skills:
|
|
2025
|
-
startupFiles:
|
|
2036
|
+
var RoleFileErrorSchema = z26.object({ kind: z26.enum(["missing", "invalid"]), message: z26.string(), line: z26.number().int().optional(), col: z26.number().int().optional() });
|
|
2037
|
+
var RoleSummarySchema = z26.object({
|
|
2038
|
+
id: z26.string(),
|
|
2039
|
+
name: z26.string(),
|
|
2040
|
+
version: z26.string().optional(),
|
|
2041
|
+
description: z26.string().optional(),
|
|
2042
|
+
source: z26.enum(["builtin", "user"]),
|
|
2043
|
+
path: z26.string(),
|
|
2044
|
+
runtime: z26.string().optional(),
|
|
2045
|
+
importOnly: z26.boolean(),
|
|
2046
|
+
seats: z26.number().int().min(0),
|
|
2047
|
+
running: z26.number().int().min(0),
|
|
2048
|
+
skills: z26.array(z26.string()),
|
|
2049
|
+
startupFiles: z26.array(z26.string()),
|
|
2026
2050
|
/** 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`). */
|
|
2027
|
-
seatRefs:
|
|
2028
|
-
error:
|
|
2029
|
-
});
|
|
2030
|
-
var RoleImportSchema =
|
|
2031
|
-
ref:
|
|
2032
|
-
key:
|
|
2033
|
-
name:
|
|
2034
|
-
path:
|
|
2035
|
-
version:
|
|
2036
|
-
resolved:
|
|
2037
|
-
error:
|
|
2038
|
-
});
|
|
2039
|
-
var RoleProfileSchema =
|
|
2040
|
-
name:
|
|
2041
|
-
description:
|
|
2051
|
+
seatRefs: z26.array(z26.object({ rig: z26.string(), logicalId: z26.string(), session: z26.string().optional() })),
|
|
2052
|
+
error: z26.enum(["missing", "invalid"]).optional()
|
|
2053
|
+
});
|
|
2054
|
+
var RoleImportSchema = z26.object({
|
|
2055
|
+
ref: z26.string(),
|
|
2056
|
+
key: z26.string(),
|
|
2057
|
+
name: z26.string().optional(),
|
|
2058
|
+
path: z26.string().optional(),
|
|
2059
|
+
version: z26.string().optional(),
|
|
2060
|
+
resolved: z26.boolean(),
|
|
2061
|
+
error: z26.string().optional()
|
|
2062
|
+
});
|
|
2063
|
+
var RoleProfileSchema = z26.object({
|
|
2064
|
+
name: z26.string(),
|
|
2065
|
+
description: z26.string().optional(),
|
|
2042
2066
|
runtime: SourcedStringSchema,
|
|
2043
2067
|
model: SourcedStringSchema,
|
|
2044
2068
|
effort: SourcedStringSchema,
|
|
2045
|
-
uses:
|
|
2069
|
+
uses: z26.object({ skills: RoleUsesListSchema, guidance: RoleUsesListSchema, subagents: RoleUsesListSchema, plugins: RoleUsesListSchema, runtimeResources: RoleUsesListSchema }),
|
|
2046
2070
|
/** The role's share of the startup: agent then profile files and actions, in that order. */
|
|
2047
|
-
startup:
|
|
2048
|
-
});
|
|
2049
|
-
var RoleSeatSchema =
|
|
2050
|
-
rig:
|
|
2051
|
-
rigId:
|
|
2052
|
-
rigSpecPath:
|
|
2053
|
-
composed:
|
|
2054
|
-
logicalId:
|
|
2055
|
-
session:
|
|
2056
|
-
label:
|
|
2057
|
-
profile:
|
|
2058
|
-
running:
|
|
2059
|
-
activity:
|
|
2071
|
+
startup: z26.array(StartupEntrySchema)
|
|
2072
|
+
});
|
|
2073
|
+
var RoleSeatSchema = z26.object({
|
|
2074
|
+
rig: z26.string(),
|
|
2075
|
+
rigId: z26.string(),
|
|
2076
|
+
rigSpecPath: z26.string().optional(),
|
|
2077
|
+
composed: z26.boolean(),
|
|
2078
|
+
logicalId: z26.string(),
|
|
2079
|
+
session: z26.string().optional(),
|
|
2080
|
+
label: z26.string().optional(),
|
|
2081
|
+
profile: z26.string(),
|
|
2082
|
+
running: z26.boolean(),
|
|
2083
|
+
activity: z26.string(),
|
|
2060
2084
|
runtime: SourcedStringSchema,
|
|
2061
2085
|
model: SourcedStringSchema,
|
|
2062
2086
|
effort: SourcedStringSchema,
|
|
2063
2087
|
cwd: SourcedStringSchema,
|
|
2064
2088
|
cultureFile: SourcedStringSchema,
|
|
2065
|
-
member:
|
|
2066
|
-
memberStartup:
|
|
2089
|
+
member: z26.string().optional(),
|
|
2090
|
+
memberStartup: z26.array(StartupEntrySchema),
|
|
2067
2091
|
/** The Role tab of this seat: its role guidance (`role.md`), then the startup files of its own (member layer), in delivery
|
|
2068
2092
|
* order — OpenRig's when the seat was launched, else the spec's. */
|
|
2069
|
-
roleDocs:
|
|
2070
|
-
live:
|
|
2071
|
-
resolvedSpec:
|
|
2072
|
-
resources:
|
|
2093
|
+
roleDocs: z26.array(StartupEntrySchema),
|
|
2094
|
+
live: z26.object({
|
|
2095
|
+
resolvedSpec: z26.object({ name: z26.string().optional(), version: z26.string().optional(), hash: z26.string().optional() }),
|
|
2096
|
+
resources: z26.array(RoleResourceSchema),
|
|
2073
2097
|
/** In the order OpenRig returns them. */
|
|
2074
|
-
startup:
|
|
2098
|
+
startup: z26.array(StartupEntrySchema),
|
|
2075
2099
|
/** `rig skill loadout --seat`: the skills projected for this seat; absent when it could not be read. */
|
|
2076
|
-
skills:
|
|
2100
|
+
skills: z26.array(z26.object({ id: z26.string(), trigger: z26.string().optional() })).optional()
|
|
2077
2101
|
}).optional()
|
|
2078
2102
|
});
|
|
2079
|
-
var RoleUnavailableSchema =
|
|
2080
|
-
var RoleDetailSchema =
|
|
2103
|
+
var RoleUnavailableSchema = z26.enum(["harness_prompt", "effective_settings", "delivered_content", "harness_own_files"]);
|
|
2104
|
+
var RoleDetailSchema = z26.object({
|
|
2081
2105
|
summary: RoleSummarySchema,
|
|
2082
|
-
file:
|
|
2083
|
-
path:
|
|
2084
|
-
relativePath:
|
|
2085
|
-
modifiedAt:
|
|
2086
|
-
copies:
|
|
2106
|
+
file: z26.object({
|
|
2107
|
+
path: z26.string(),
|
|
2108
|
+
relativePath: z26.string().optional(),
|
|
2109
|
+
modifiedAt: z26.string().optional(),
|
|
2110
|
+
copies: z26.array(z26.object({ kind: z26.literal("repo"), path: z26.string(), identical: z26.boolean(), modifiedAt: z26.string().optional() }))
|
|
2087
2111
|
}),
|
|
2088
2112
|
error: RoleFileErrorSchema.optional(),
|
|
2089
|
-
role:
|
|
2090
|
-
defaults:
|
|
2091
|
-
imports:
|
|
2092
|
-
importedBy:
|
|
2093
|
-
profiles:
|
|
2113
|
+
role: z26.object({ path: z26.string(), absolutePath: z26.string(), origin: OriginSchema }).nullable(),
|
|
2114
|
+
defaults: z26.object({ runtime: SourcedStringSchema, model: SourcedStringSchema, effort: SourcedStringSchema }),
|
|
2115
|
+
imports: z26.array(RoleImportSchema),
|
|
2116
|
+
importedBy: z26.array(z26.string()),
|
|
2117
|
+
profiles: z26.array(RoleProfileSchema),
|
|
2094
2118
|
/** What the file declares in `resources`. */
|
|
2095
|
-
resources:
|
|
2096
|
-
seats:
|
|
2097
|
-
unavailable:
|
|
2098
|
-
warnings:
|
|
2099
|
-
openrigVersion:
|
|
2100
|
-
});
|
|
2101
|
-
var RoleErrorSchema =
|
|
2102
|
-
var LibraryIdSchema =
|
|
2103
|
-
var OpenRigRolesSchema =
|
|
2104
|
-
var OpenRigRoleListSchema =
|
|
2105
|
-
type:
|
|
2106
|
-
requestId:
|
|
2107
|
-
machineId:
|
|
2108
|
-
roles:
|
|
2109
|
-
openrigVersion:
|
|
2119
|
+
resources: z26.array(RoleResourceSchema),
|
|
2120
|
+
seats: z26.array(RoleSeatSchema),
|
|
2121
|
+
unavailable: z26.array(RoleUnavailableSchema),
|
|
2122
|
+
warnings: z26.array(z26.string()),
|
|
2123
|
+
openrigVersion: z26.string().optional()
|
|
2124
|
+
});
|
|
2125
|
+
var RoleErrorSchema = z26.string();
|
|
2126
|
+
var LibraryIdSchema = z26.string().min(1).max(200).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, "not a library id");
|
|
2127
|
+
var OpenRigRolesSchema = z26.object({ type: z26.literal("openrig.roles"), requestId: z26.string().min(1).max(100), machineId: z26.string().optional() });
|
|
2128
|
+
var OpenRigRoleListSchema = z26.object({
|
|
2129
|
+
type: z26.literal("openrig.roleList"),
|
|
2130
|
+
requestId: z26.string(),
|
|
2131
|
+
machineId: z26.string().optional(),
|
|
2132
|
+
roles: z26.array(RoleSummarySchema),
|
|
2133
|
+
openrigVersion: z26.string().optional(),
|
|
2110
2134
|
error: RoleErrorSchema.optional()
|
|
2111
2135
|
});
|
|
2112
|
-
var OpenRigRoleSchema =
|
|
2113
|
-
var OpenRigRoleDetailSchema =
|
|
2114
|
-
type:
|
|
2115
|
-
requestId:
|
|
2116
|
-
machineId:
|
|
2117
|
-
roleId:
|
|
2136
|
+
var OpenRigRoleSchema = z26.object({ type: z26.literal("openrig.role"), requestId: z26.string().min(1).max(100), machineId: z26.string().optional(), roleId: LibraryIdSchema });
|
|
2137
|
+
var OpenRigRoleDetailSchema = z26.object({
|
|
2138
|
+
type: z26.literal("openrig.roleDetail"),
|
|
2139
|
+
requestId: z26.string(),
|
|
2140
|
+
machineId: z26.string().optional(),
|
|
2141
|
+
roleId: z26.string(),
|
|
2118
2142
|
role: RoleDetailSchema.optional(),
|
|
2119
2143
|
error: RoleErrorSchema.optional()
|
|
2120
2144
|
});
|
|
2121
|
-
var OpenRigRoleFileSchema =
|
|
2122
|
-
type:
|
|
2123
|
-
requestId:
|
|
2124
|
-
machineId:
|
|
2145
|
+
var OpenRigRoleFileSchema = z26.object({
|
|
2146
|
+
type: z26.literal("openrig.roleFile"),
|
|
2147
|
+
requestId: z26.string().min(1).max(100),
|
|
2148
|
+
machineId: z26.string().optional(),
|
|
2125
2149
|
roleId: LibraryIdSchema,
|
|
2126
|
-
path:
|
|
2127
|
-
});
|
|
2128
|
-
var OpenRigRoleFileContentSchema =
|
|
2129
|
-
type:
|
|
2130
|
-
requestId:
|
|
2131
|
-
machineId:
|
|
2132
|
-
roleId:
|
|
2133
|
-
path:
|
|
2134
|
-
content:
|
|
2135
|
-
size:
|
|
2136
|
-
truncated:
|
|
2150
|
+
path: z26.string().min(1).max(4096)
|
|
2151
|
+
});
|
|
2152
|
+
var OpenRigRoleFileContentSchema = z26.object({
|
|
2153
|
+
type: z26.literal("openrig.roleFileContent"),
|
|
2154
|
+
requestId: z26.string(),
|
|
2155
|
+
machineId: z26.string().optional(),
|
|
2156
|
+
roleId: z26.string(),
|
|
2157
|
+
path: z26.string(),
|
|
2158
|
+
content: z26.string().optional(),
|
|
2159
|
+
size: z26.number().int().min(0).optional(),
|
|
2160
|
+
truncated: z26.boolean().optional(),
|
|
2137
2161
|
error: RoleErrorSchema.optional()
|
|
2138
2162
|
});
|
|
2139
|
-
var OpenRigRoleDuplicateSchema =
|
|
2140
|
-
type:
|
|
2141
|
-
requestId:
|
|
2142
|
-
machineId:
|
|
2163
|
+
var OpenRigRoleDuplicateSchema = z26.object({
|
|
2164
|
+
type: z26.literal("openrig.role.duplicate"),
|
|
2165
|
+
requestId: z26.string().min(1).max(100),
|
|
2166
|
+
machineId: z26.string().optional(),
|
|
2143
2167
|
roleId: LibraryIdSchema,
|
|
2144
2168
|
name: RigNameSchema
|
|
2145
2169
|
});
|
|
2146
|
-
var OpenRigRoleDuplicatedSchema =
|
|
2147
|
-
type:
|
|
2148
|
-
requestId:
|
|
2149
|
-
machineId:
|
|
2150
|
-
ok:
|
|
2151
|
-
roleId:
|
|
2152
|
-
path:
|
|
2170
|
+
var OpenRigRoleDuplicatedSchema = z26.object({
|
|
2171
|
+
type: z26.literal("openrig.roleDuplicated"),
|
|
2172
|
+
requestId: z26.string(),
|
|
2173
|
+
machineId: z26.string().optional(),
|
|
2174
|
+
ok: z26.boolean(),
|
|
2175
|
+
roleId: z26.string().optional(),
|
|
2176
|
+
path: z26.string().optional(),
|
|
2153
2177
|
error: RoleErrorSchema.optional()
|
|
2154
2178
|
});
|
|
2155
2179
|
var ROLE_FILE_MAX = 512 * 1024;
|
|
2156
2180
|
|
|
2157
2181
|
// ../../packages/protocol/src/routing.ts
|
|
2158
|
-
import { z as
|
|
2159
|
-
var MachineInventorySchema =
|
|
2160
|
-
id:
|
|
2161
|
-
label:
|
|
2162
|
-
online:
|
|
2163
|
-
local:
|
|
2164
|
-
sessions:
|
|
2165
|
-
folders:
|
|
2166
|
-
});
|
|
2167
|
-
var RoutingContextSchema =
|
|
2168
|
-
machines:
|
|
2169
|
-
history:
|
|
2170
|
-
});
|
|
2171
|
-
var RouteResultSchema =
|
|
2182
|
+
import { z as z27 } from "zod";
|
|
2183
|
+
var MachineInventorySchema = z27.object({
|
|
2184
|
+
id: z27.string().min(1).max(80),
|
|
2185
|
+
label: z27.string().min(1).max(120),
|
|
2186
|
+
online: z27.boolean(),
|
|
2187
|
+
local: z27.boolean(),
|
|
2188
|
+
sessions: z27.array(z27.object({ id: z27.string(), name: z27.string(), project: z27.string(), cwd: z27.string(), topic: z27.string().optional(), state: z27.string(), readOnly: z27.boolean() })).max(500),
|
|
2189
|
+
folders: z27.array(z27.object({ project: z27.string(), cwd: z27.string() })).max(100)
|
|
2190
|
+
});
|
|
2191
|
+
var RoutingContextSchema = z27.object({
|
|
2192
|
+
machines: z27.array(MachineInventorySchema).min(1).max(20),
|
|
2193
|
+
history: z27.array(z27.object({ question: z27.string().max(2e4), answer: z27.string().max(2e4).optional(), machineId: z27.string().optional() })).max(50)
|
|
2194
|
+
});
|
|
2195
|
+
var RouteResultSchema = z27.object({
|
|
2172
2196
|
/** Null means an answer or a clarification, never an implicit local destination. */
|
|
2173
|
-
machineId:
|
|
2174
|
-
text:
|
|
2175
|
-
choices:
|
|
2197
|
+
machineId: z27.string().nullable(),
|
|
2198
|
+
text: z27.string().min(1).max(2e4),
|
|
2199
|
+
choices: z27.array(z27.string()).max(20).optional()
|
|
2176
2200
|
});
|
|
2177
2201
|
|
|
2178
2202
|
// ../../packages/protocol/src/thread.ts
|
|
2179
|
-
import { z as
|
|
2180
|
-
var ToolStatusSchema =
|
|
2181
|
-
var FileChangeSchema =
|
|
2182
|
-
var base = { id:
|
|
2183
|
-
var ThreadItemSchema =
|
|
2184
|
-
|
|
2185
|
-
|
|
2203
|
+
import { z as z28 } from "zod";
|
|
2204
|
+
var ToolStatusSchema = z28.enum(["running", "success", "failed", "unknown"]);
|
|
2205
|
+
var FileChangeSchema = z28.object({ path: z28.string().min(1), from: z28.string().min(1).optional(), change: z28.enum(["add", "edit", "delete", "write"]), diff: z28.string().optional() });
|
|
2206
|
+
var base = { id: z28.string().min(1), at: z28.string().datetime(), turn: z28.number().int().nonnegative(), helperId: z28.string().optional() };
|
|
2207
|
+
var ThreadItemSchema = z28.discriminatedUnion("kind", [
|
|
2208
|
+
z28.object({ kind: z28.literal("prompt"), ...base, text: z28.string(), images: z28.array(AttachmentRefSchema).optional() }),
|
|
2209
|
+
z28.object({ kind: z28.literal("message"), ...base, text: z28.string() }),
|
|
2186
2210
|
/** `id` is the harness's tool_use_id when it gives one, so the result updates the same row; `byClose`: a question
|
|
2187
2211
|
* dismissed by Ledge closing the session. */
|
|
2188
|
-
|
|
2189
|
-
kind:
|
|
2212
|
+
z28.object({
|
|
2213
|
+
kind: z28.literal("tool"),
|
|
2190
2214
|
...base,
|
|
2191
|
-
tool:
|
|
2192
|
-
label:
|
|
2193
|
-
input:
|
|
2194
|
-
output:
|
|
2195
|
-
error:
|
|
2215
|
+
tool: z28.string(),
|
|
2216
|
+
label: z28.string(),
|
|
2217
|
+
input: z28.string().optional(),
|
|
2218
|
+
output: z28.string().optional(),
|
|
2219
|
+
error: z28.string().optional(),
|
|
2196
2220
|
status: ToolStatusSchema,
|
|
2197
|
-
durationMs:
|
|
2198
|
-
files:
|
|
2199
|
-
byClose:
|
|
2221
|
+
durationMs: z28.number().nonnegative().optional(),
|
|
2222
|
+
files: z28.array(FileChangeSchema).default([]),
|
|
2223
|
+
byClose: z28.literal(true).optional(),
|
|
2200
2224
|
/** Images the tool returned (a browser screenshot), in order; `imagesDropped`: some were not kept. */
|
|
2201
|
-
images:
|
|
2202
|
-
imagesDropped:
|
|
2225
|
+
images: z28.array(AttachmentRefSchema).max(ATTACHMENTS_MAX).optional(),
|
|
2226
|
+
imagesDropped: z28.literal(true).optional()
|
|
2203
2227
|
}),
|
|
2204
2228
|
/** `unknown`: answered in the terminal, the daemon only saw the prompt go away; `always`: allowed and not asked again;
|
|
2205
2229
|
* `byClose`: denied by Ledge closing the session; `by`: who answered it from Ledge (the PC or a device, its name then). */
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2230
|
+
z28.object({ kind: z28.literal("permission"), ...base, tool: z28.string(), text: z28.string(), decision: z28.enum(["accept", "deny", "always", "unknown"]).optional(), byClose: z28.literal(true).optional(), by: DecidedBySchema.optional() }),
|
|
2231
|
+
z28.object({ kind: z28.literal("reply"), ...base, text: z28.string() }),
|
|
2232
|
+
z28.object({ kind: z28.literal("helper"), ...base, task: z28.string(), agentType: z28.string().optional(), state: z28.enum(["working", "exited"]) }),
|
|
2209
2233
|
/** 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. */
|
|
2210
|
-
|
|
2211
|
-
kind:
|
|
2234
|
+
z28.object({
|
|
2235
|
+
kind: z28.literal("sent"),
|
|
2212
2236
|
...base,
|
|
2213
|
-
to:
|
|
2214
|
-
peer:
|
|
2215
|
-
summary:
|
|
2216
|
-
text:
|
|
2217
|
-
status:
|
|
2218
|
-
received:
|
|
2219
|
-
via:
|
|
2237
|
+
to: z28.string(),
|
|
2238
|
+
peer: z28.string().optional(),
|
|
2239
|
+
summary: z28.string().optional(),
|
|
2240
|
+
text: z28.string(),
|
|
2241
|
+
status: z28.enum(["sending", "delivered", "read", "failed"]),
|
|
2242
|
+
received: z28.string().optional(),
|
|
2243
|
+
via: z28.literal("ledge").optional(),
|
|
2220
2244
|
/** The seat's own `rig send` (its Bash call), docs/mockups/ledge-openrig-messages.html: `rig.command` is what it ran. */
|
|
2221
2245
|
rig: RigInfoSchema.optional()
|
|
2222
2246
|
}),
|
|
2223
2247
|
/** 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. */
|
|
2224
|
-
|
|
2225
|
-
kind:
|
|
2248
|
+
z28.object({
|
|
2249
|
+
kind: z28.literal("received"),
|
|
2226
2250
|
...base,
|
|
2227
|
-
from:
|
|
2228
|
-
peer:
|
|
2229
|
-
text:
|
|
2230
|
-
sent:
|
|
2251
|
+
from: z28.string(),
|
|
2252
|
+
peer: z28.string().optional(),
|
|
2253
|
+
text: z28.string(),
|
|
2254
|
+
sent: z28.string().optional(),
|
|
2231
2255
|
/** An OpenRig `rig send` typed into this seat (`rig.kind` `message`): `from` is the envelope's sender, `text` its body. */
|
|
2232
2256
|
rig: RigInfoSchema.optional()
|
|
2233
2257
|
}),
|
|
2234
2258
|
/** An automated notice of the agent's harness about messages between sessions (Claude Code's `[Cross-session idle
|
|
2235
2259
|
* notice]` / `[Cross-session delivery notice]`): a system event, never the user's words. `name` is the session it is
|
|
2236
2260
|
* about as quoted, `peer` its Ledge session id; a delivery notice says the outcome of `count` messages to `recipients`. */
|
|
2237
|
-
|
|
2238
|
-
kind:
|
|
2261
|
+
z28.object({
|
|
2262
|
+
kind: z28.literal("notice"),
|
|
2239
2263
|
...base,
|
|
2240
|
-
notice:
|
|
2264
|
+
notice: z28.enum(["idle", "exited", "unavailable", "expired", "delivery", "other"]),
|
|
2241
2265
|
/** 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. */
|
|
2242
|
-
task:
|
|
2266
|
+
task: z28.string().optional(),
|
|
2243
2267
|
/** A task this session handed over (`outgoing`), and how (issue #92). */
|
|
2244
|
-
taskOp:
|
|
2245
|
-
outgoing:
|
|
2246
|
-
name:
|
|
2247
|
-
peer:
|
|
2248
|
-
time:
|
|
2249
|
-
summary:
|
|
2250
|
-
status:
|
|
2251
|
-
count:
|
|
2252
|
-
recipients:
|
|
2253
|
-
reason:
|
|
2254
|
-
text:
|
|
2268
|
+
taskOp: z28.enum(TRANSMISSION_OPS).optional(),
|
|
2269
|
+
outgoing: z28.literal(true).optional(),
|
|
2270
|
+
name: z28.string().optional(),
|
|
2271
|
+
peer: z28.string().optional(),
|
|
2272
|
+
time: z28.string().optional(),
|
|
2273
|
+
summary: z28.string().optional(),
|
|
2274
|
+
status: z28.enum(["held", "denied", "expired", "delivered", "refused", "dropped", "unknown"]).optional(),
|
|
2275
|
+
count: z28.number().int().positive().optional(),
|
|
2276
|
+
recipients: z28.array(z28.string()).optional(),
|
|
2277
|
+
reason: z28.string().optional(),
|
|
2278
|
+
text: z28.string(),
|
|
2255
2279
|
/** An OpenRig block that is not a message: a row handed to this seat or passed by it (`handoff`, `outgoing` for its own),
|
|
2256
2280
|
* a row unblocked, OpenRig's own notice, or an unreadable block; `text` is the body (unreadable: the block as is). */
|
|
2257
2281
|
rig: RigInfoSchema.optional()
|
|
@@ -2259,11 +2283,11 @@ var ThreadItemSchema = z27.discriminatedUnion("kind", [
|
|
|
2259
2283
|
]);
|
|
2260
2284
|
|
|
2261
2285
|
// ../../packages/protocol/src/mobile.ts
|
|
2262
|
-
import { z as
|
|
2263
|
-
var RelayUrlSchema =
|
|
2286
|
+
import { z as z29 } from "zod";
|
|
2287
|
+
var RelayUrlSchema = z29.string().transform((v, ctx) => {
|
|
2264
2288
|
const bad = () => {
|
|
2265
|
-
ctx.addIssue({ code:
|
|
2266
|
-
return
|
|
2289
|
+
ctx.addIssue({ code: z29.ZodIssueCode.custom, message: "invalid relay URL" });
|
|
2290
|
+
return z29.NEVER;
|
|
2267
2291
|
};
|
|
2268
2292
|
let u;
|
|
2269
2293
|
try {
|
|
@@ -2276,168 +2300,168 @@ var RelayUrlSchema = z28.string().transform((v, ctx) => {
|
|
|
2276
2300
|
if (u.username || u.password || u.pathname !== "/" || u.search || u.hash) return bad();
|
|
2277
2301
|
return u.origin;
|
|
2278
2302
|
});
|
|
2279
|
-
var MobileConfigSchema =
|
|
2280
|
-
var MobileLinkStateSchema =
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2303
|
+
var MobileConfigSchema = z29.object({ enabled: z29.boolean(), relayUrl: RelayUrlSchema, terminalInput: z29.boolean().optional() });
|
|
2304
|
+
var MobileLinkStateSchema = z29.discriminatedUnion("state", [
|
|
2305
|
+
z29.object({ state: z29.literal("off") }),
|
|
2306
|
+
z29.object({ state: z29.literal("connecting") }),
|
|
2307
|
+
z29.object({ state: z29.literal("online") }),
|
|
2308
|
+
z29.object({ state: z29.literal("offline"), retryAt: z29.string().datetime(), error: z29.string() }),
|
|
2309
|
+
z29.object({ state: z29.literal("signed_out"), reason: z29.enum(["other_pc", "session_invalid"]) }),
|
|
2286
2310
|
/** The mobile service did not start (a broken mobile.json, a missing key store): nothing is linked until the daemon restarts. */
|
|
2287
|
-
|
|
2311
|
+
z29.object({ state: z29.literal("unavailable"), error: z29.string().max(200) })
|
|
2288
2312
|
]);
|
|
2289
|
-
var DeviceKindSchema =
|
|
2313
|
+
var DeviceKindSchema = z29.enum(["phone", "tablet"]);
|
|
2290
2314
|
var DEVICE_NAME_MAX = 40;
|
|
2291
|
-
var DeviceNameSchema =
|
|
2292
|
-
var MobilePairingSchema =
|
|
2293
|
-
id:
|
|
2294
|
-
label:
|
|
2295
|
-
code:
|
|
2296
|
-
expiresAt:
|
|
2297
|
-
state:
|
|
2298
|
-
});
|
|
2299
|
-
var RecoveredSchema =
|
|
2300
|
-
var MobileStateSchema =
|
|
2301
|
-
enabled:
|
|
2302
|
-
relayUrl:
|
|
2303
|
-
account:
|
|
2304
|
-
signin:
|
|
2315
|
+
var DeviceNameSchema = z29.string().trim().min(1).max(DEVICE_NAME_MAX).regex(/^[^\u0000-\u001f\u007f]+$/);
|
|
2316
|
+
var MobilePairingSchema = z29.object({
|
|
2317
|
+
id: z29.string(),
|
|
2318
|
+
label: z29.string(),
|
|
2319
|
+
code: z29.string().nullable(),
|
|
2320
|
+
expiresAt: z29.string().datetime(),
|
|
2321
|
+
state: z29.enum(["waiting", "confirm", "approved", "linked", "expired", "refused"])
|
|
2322
|
+
});
|
|
2323
|
+
var RecoveredSchema = z29.object({ at: z29.string().datetime(), model: z29.string().max(40).optional(), pending: z29.literal(true).optional() });
|
|
2324
|
+
var MobileStateSchema = z29.object({
|
|
2325
|
+
enabled: z29.boolean(),
|
|
2326
|
+
relayUrl: z29.string(),
|
|
2327
|
+
account: z29.object({ login: z29.string(), accountId: z29.string() }).nullable(),
|
|
2328
|
+
signin: z29.object({ userCode: z29.string(), verificationUri: z29.string(), expiresAt: z29.string().datetime() }).nullable(),
|
|
2305
2329
|
/** The last sign-in that did not end with a session; cleared by the next one. */
|
|
2306
|
-
signinError:
|
|
2330
|
+
signinError: z29.enum(["expired", "denied", "not_allowed", "failed"]).nullable(),
|
|
2307
2331
|
link: MobileLinkStateSchema,
|
|
2308
|
-
devices:
|
|
2309
|
-
id:
|
|
2310
|
-
label:
|
|
2311
|
-
approvedAt:
|
|
2312
|
-
online:
|
|
2313
|
-
lastSeenAt:
|
|
2332
|
+
devices: z29.array(z29.object({
|
|
2333
|
+
id: z29.string(),
|
|
2334
|
+
label: z29.string(),
|
|
2335
|
+
approvedAt: z29.string(),
|
|
2336
|
+
online: z29.boolean(),
|
|
2337
|
+
lastSeenAt: z29.string().optional(),
|
|
2314
2338
|
/** Absent from an older daemon; `name` absent: the user gave none, the front derives one from the label. */
|
|
2315
2339
|
kind: DeviceKindSchema.optional(),
|
|
2316
|
-
name:
|
|
2340
|
+
name: z29.string().optional(),
|
|
2317
2341
|
/** Its passkey can bring it back after a reinstall (registered with the PC key's digest, docs/mobile-passkey-recover-contract.md). */
|
|
2318
|
-
recover:
|
|
2342
|
+
recover: z29.literal(true).optional(),
|
|
2319
2343
|
/** It came back with its passkey: when, on what it says it runs (`iPhone`, `iPad`), and `pending` until « C'était bien moi »
|
|
2320
2344
|
* (`mobile.device.ack` `recovered`). Kept after that, for the « reconnecté avec sa passkey le … » line. */
|
|
2321
2345
|
recovered: RecoveredSchema.optional(),
|
|
2322
2346
|
/** Another device tried to take its place with its passkey while it was connected; until « Compris » (`mobile.device.ack` `refused`). */
|
|
2323
|
-
refused:
|
|
2347
|
+
refused: z29.object({ at: z29.string().datetime(), model: z29.string().optional() }).optional()
|
|
2324
2348
|
})),
|
|
2325
|
-
pairings:
|
|
2349
|
+
pairings: z29.array(MobilePairingSchema),
|
|
2326
2350
|
/** « Taper dans les terminaux depuis le téléphone »: absent from an older daemon, which has no phone terminal. */
|
|
2327
|
-
terminalInput:
|
|
2351
|
+
terminalInput: z29.boolean().optional(),
|
|
2328
2352
|
/** Passkey recovery on the account: `blocked` after 3 failed verifications, until « Débloquer » (`mobile.recovery.unblock`). */
|
|
2329
|
-
recovery:
|
|
2353
|
+
recovery: z29.object({ blocked: z29.object({ since: z29.string().datetime(), failures: z29.number().int().min(0) }).optional() }).optional()
|
|
2330
2354
|
});
|
|
2331
|
-
var MobileRecoveryEventSchema =
|
|
2332
|
-
event:
|
|
2333
|
-
id:
|
|
2334
|
-
at:
|
|
2355
|
+
var MobileRecoveryEventSchema = z29.object({
|
|
2356
|
+
event: z29.enum(["recovered", "refused", "blocked"]),
|
|
2357
|
+
id: z29.string().optional(),
|
|
2358
|
+
at: z29.string().datetime()
|
|
2335
2359
|
});
|
|
2336
2360
|
|
|
2337
2361
|
// ../../packages/protocol/src/brain.ts
|
|
2338
|
-
import { z as
|
|
2339
|
-
var NoteInfoSchema =
|
|
2340
|
-
name:
|
|
2341
|
-
file:
|
|
2342
|
-
title:
|
|
2343
|
-
when:
|
|
2344
|
-
firstLine:
|
|
2345
|
-
scope:
|
|
2346
|
-
projects:
|
|
2347
|
-
modifiedAt:
|
|
2348
|
-
checkedAt:
|
|
2362
|
+
import { z as z30 } from "zod";
|
|
2363
|
+
var NoteInfoSchema = z30.object({
|
|
2364
|
+
name: z30.string(),
|
|
2365
|
+
file: z30.string(),
|
|
2366
|
+
title: z30.string(),
|
|
2367
|
+
when: z30.string().optional(),
|
|
2368
|
+
firstLine: z30.string(),
|
|
2369
|
+
scope: z30.enum(["all", "chat", "sessions"]),
|
|
2370
|
+
projects: z30.array(z30.string()),
|
|
2371
|
+
modifiedAt: z30.string(),
|
|
2372
|
+
checkedAt: z30.string().optional(),
|
|
2349
2373
|
/** Days since it was last checked or changed, past the threshold (spec §3.7). */
|
|
2350
|
-
oldDays:
|
|
2351
|
-
flag:
|
|
2374
|
+
oldDays: z30.number().int().optional(),
|
|
2375
|
+
flag: z30.object({ what: z30.string(), by: z30.string(), at: z30.string() }).optional(),
|
|
2352
2376
|
/** Lines under « ## Ajouts ». */
|
|
2353
|
-
additions:
|
|
2354
|
-
truncated:
|
|
2355
|
-
});
|
|
2356
|
-
var BrainAnswerSchema =
|
|
2357
|
-
var BrainListSchema =
|
|
2358
|
-
var BrainNoteSchema =
|
|
2359
|
-
var BrainAddSchema =
|
|
2360
|
-
type:
|
|
2361
|
-
rid:
|
|
2377
|
+
additions: z30.number().int(),
|
|
2378
|
+
truncated: z30.boolean()
|
|
2379
|
+
});
|
|
2380
|
+
var BrainAnswerSchema = z30.object({ type: z30.literal("brain.answer"), rid: z30.string().min(1).max(100), task: z30.string().min(1).max(40), choice: BrainChoiceSchema });
|
|
2381
|
+
var BrainListSchema = z30.object({ type: z30.literal("brain.list"), rid: z30.string().min(1).max(100) });
|
|
2382
|
+
var BrainNoteSchema = z30.object({ type: z30.literal("brain.note"), rid: z30.string().min(1).max(100), note: NoteNameSchema, op: z30.enum(["checked", "unflag"]) });
|
|
2383
|
+
var BrainAddSchema = z30.object({
|
|
2384
|
+
type: z30.literal("brain.add"),
|
|
2385
|
+
rid: z30.string().min(1).max(100),
|
|
2362
2386
|
note: NoteNameSchema,
|
|
2363
|
-
fact:
|
|
2364
|
-
source:
|
|
2387
|
+
fact: z30.string().trim().min(1).max(BRAIN_FACT_MAX),
|
|
2388
|
+
source: z30.string().trim().min(1).max(BRAIN_SOURCE_MAX).optional()
|
|
2365
2389
|
});
|
|
2366
|
-
var BrainResultSchema =
|
|
2367
|
-
type:
|
|
2368
|
-
rid:
|
|
2369
|
-
reason:
|
|
2390
|
+
var BrainResultSchema = z30.object({
|
|
2391
|
+
type: z30.literal("brain.result"),
|
|
2392
|
+
rid: z30.string(),
|
|
2393
|
+
reason: z30.string().optional(),
|
|
2370
2394
|
/** What came of an answer (the text its proposer is told). */
|
|
2371
|
-
result:
|
|
2372
|
-
dir:
|
|
2373
|
-
notes:
|
|
2395
|
+
result: z30.string().optional(),
|
|
2396
|
+
dir: z30.string().optional(),
|
|
2397
|
+
notes: z30.array(NoteInfoSchema).optional()
|
|
2374
2398
|
});
|
|
2375
2399
|
|
|
2376
2400
|
// ../../packages/protocol/src/usage.ts
|
|
2377
|
-
import { z as
|
|
2378
|
-
var UsageHarnessSchema =
|
|
2401
|
+
import { z as z31 } from "zod";
|
|
2402
|
+
var UsageHarnessSchema = z31.enum(["claude", "codex", "cursor"]);
|
|
2379
2403
|
var USAGE_WINDOW_KINDS = ["five_hour", "seven_day", "model", "month", "pool"];
|
|
2380
2404
|
var POOLS = ["cursor", "other"];
|
|
2381
2405
|
var poolMatchesKind = (w) => w.kind === "pool" === (w.pool !== void 0) && (w.pool === void 0 || POOLS.includes(w.pool));
|
|
2382
|
-
var UsageWindowSchema =
|
|
2383
|
-
kind:
|
|
2384
|
-
model:
|
|
2406
|
+
var UsageWindowSchema = z31.object({
|
|
2407
|
+
kind: z31.enum(USAGE_WINDOW_KINDS),
|
|
2408
|
+
model: z31.string().min(1).max(80).optional(),
|
|
2385
2409
|
/** A pool of the included usage (`kind: 'pool'`): Cursor's own models (`cursor`) or the others at API prices (`other`). */
|
|
2386
|
-
pool:
|
|
2410
|
+
pool: z31.enum(POOLS).optional(),
|
|
2387
2411
|
/** How much of it is used, in percent (rounded); 100 or more: reached. */
|
|
2388
|
-
pct:
|
|
2412
|
+
pct: z31.number().int().min(0).max(1e3),
|
|
2389
2413
|
/** When it starts again from zero; null when the harness does not say. */
|
|
2390
|
-
resetsAt:
|
|
2414
|
+
resetsAt: z31.string().datetime().nullable()
|
|
2391
2415
|
}).refine(poolMatchesKind, { message: "a pool window names its pool, and only a pool window does", path: ["pool"] });
|
|
2392
|
-
var UsageStatusSchema =
|
|
2416
|
+
var UsageStatusSchema = z31.enum(["ok", "loading", "stale", "unreachable", "expired"]);
|
|
2393
2417
|
var USAGE_ALERT_MIN = 0.5;
|
|
2394
2418
|
var USAGE_ALERT_MAX = 0.95;
|
|
2395
|
-
var UsagePrefsSchema =
|
|
2396
|
-
var HarnessUsageSchema =
|
|
2419
|
+
var UsagePrefsSchema = z31.object({ alert: z31.number().min(USAGE_ALERT_MIN).max(USAGE_ALERT_MAX) });
|
|
2420
|
+
var HarnessUsageSchema = z31.object({
|
|
2397
2421
|
harness: UsageHarnessSchema,
|
|
2398
|
-
account:
|
|
2422
|
+
account: z31.string().regex(/^[0-9a-f]{12}$/).nullable(),
|
|
2399
2423
|
status: UsageStatusSchema,
|
|
2400
2424
|
/** The last read that succeeded; null when none did. */
|
|
2401
|
-
readAt:
|
|
2425
|
+
readAt: z31.string().datetime().nullable(),
|
|
2402
2426
|
/** The 5 hours and the week first, then one window per model. Empty while loading, expired, or read more than an hour ago. */
|
|
2403
|
-
windows:
|
|
2427
|
+
windows: z31.array(UsageWindowSchema).max(20),
|
|
2404
2428
|
/**
|
|
2405
2429
|
* Why the account cannot be read now (#301), absent when it can. `local_expired`: the token on this machine is past its time, which
|
|
2406
2430
|
* the harness renews itself at its next use (Claude Code's access token is short): still signed in, so the last values are kept
|
|
2407
2431
|
* as `stale` while under an hour old, then the harness is no longer listed. `refused`: the provider refused the token (401):
|
|
2408
2432
|
* status `expired`, no window. A refusal wins over a local expiry.
|
|
2409
2433
|
*/
|
|
2410
|
-
cause:
|
|
2434
|
+
cause: z31.enum(["local_expired", "refused"]).optional()
|
|
2411
2435
|
});
|
|
2412
|
-
var UsageAlertSchema =
|
|
2413
|
-
id:
|
|
2436
|
+
var UsageAlertSchema = z31.object({
|
|
2437
|
+
id: z31.string().min(1).max(200),
|
|
2414
2438
|
harness: UsageHarnessSchema,
|
|
2415
|
-
account:
|
|
2439
|
+
account: z31.string().regex(/^[0-9a-f]{12}$/).nullable(),
|
|
2416
2440
|
window: UsageWindowSchema,
|
|
2417
|
-
level:
|
|
2418
|
-
at:
|
|
2441
|
+
level: z31.enum(["threshold", "full"]),
|
|
2442
|
+
at: z31.string().datetime()
|
|
2419
2443
|
});
|
|
2420
2444
|
var isRecord = (v) => typeof v === "object" && v !== null;
|
|
2421
2445
|
var knownHarness = (h) => UsageHarnessSchema.safeParse(h).success;
|
|
2422
2446
|
var knownKind = (k) => USAGE_WINDOW_KINDS.includes(k);
|
|
2423
2447
|
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;
|
|
2424
2448
|
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;
|
|
2425
|
-
var UsageStateMessageSchema =
|
|
2426
|
-
type:
|
|
2427
|
-
machineId:
|
|
2428
|
-
harnesses:
|
|
2429
|
-
alerts:
|
|
2449
|
+
var UsageStateMessageSchema = z31.object({
|
|
2450
|
+
type: z31.literal("usage.state"),
|
|
2451
|
+
machineId: z31.string().optional(),
|
|
2452
|
+
harnesses: z31.preprocess(dropUnknownHarnesses, z31.array(HarnessUsageSchema).max(4)),
|
|
2453
|
+
alerts: z31.preprocess(dropUnknownAlerts, z31.array(UsageAlertSchema).max(40)),
|
|
2430
2454
|
prefs: UsagePrefsSchema
|
|
2431
2455
|
});
|
|
2432
|
-
var UsageSetSchema =
|
|
2433
|
-
var UsageAckSchema =
|
|
2456
|
+
var UsageSetSchema = z31.object({ type: z31.literal("usage.set"), prefs: UsagePrefsSchema, machineId: z31.string().optional() });
|
|
2457
|
+
var UsageAckSchema = z31.object({ type: z31.literal("usage.ack"), id: z31.string().min(1).max(200), machineId: z31.string().optional() });
|
|
2434
2458
|
|
|
2435
2459
|
// ../../packages/protocol/src/forge.ts
|
|
2436
|
-
import { z as
|
|
2460
|
+
import { z as z33 } from "zod";
|
|
2437
2461
|
|
|
2438
2462
|
// ../../packages/protocol/src/refusal.ts
|
|
2439
|
-
import { z as
|
|
2440
|
-
var RefusalCodeSchema =
|
|
2463
|
+
import { z as z32 } from "zod";
|
|
2464
|
+
var RefusalCodeSchema = z32.enum([
|
|
2441
2465
|
"stale",
|
|
2442
2466
|
"read_only",
|
|
2443
2467
|
"no_prompt",
|
|
@@ -2461,261 +2485,265 @@ var RefusalCodeSchema = z31.enum([
|
|
|
2461
2485
|
|
|
2462
2486
|
// ../../packages/protocol/src/forge.ts
|
|
2463
2487
|
var FORGE_KINDS = ["github", "gitlab"];
|
|
2464
|
-
var ForgeKindSchema =
|
|
2488
|
+
var ForgeKindSchema = z33.enum(FORGE_KINDS);
|
|
2465
2489
|
var PIPE_STATUSES = ["ok", "run", "fail", "wait", "skip", "none"];
|
|
2466
|
-
var PipeStatusSchema =
|
|
2490
|
+
var PipeStatusSchema = z33.enum(PIPE_STATUSES);
|
|
2467
2491
|
var PR_STATES = ["draft", "open", "review", "merged", "closed"];
|
|
2468
|
-
var PrStateSchema =
|
|
2492
|
+
var PrStateSchema = z33.enum(PR_STATES);
|
|
2469
2493
|
var PR_ROLES = ["author", "assignee", "reviewer"];
|
|
2470
|
-
var PrRoleSchema =
|
|
2494
|
+
var PrRoleSchema = z33.enum(PR_ROLES);
|
|
2471
2495
|
var dropUnknownRoles = (raw) => Array.isArray(raw) ? raw.filter((r) => known(PR_ROLES, r)) : raw;
|
|
2472
2496
|
var FORGE_BODY_MAX = 65536;
|
|
2473
|
-
var PullRequestSchema =
|
|
2497
|
+
var PullRequestSchema = z33.object({
|
|
2474
2498
|
/** `${host}/${repo}#${number}`, stable. */
|
|
2475
|
-
id:
|
|
2499
|
+
id: z33.string().min(1),
|
|
2476
2500
|
forge: ForgeKindSchema,
|
|
2477
|
-
host:
|
|
2501
|
+
host: z33.string().min(1),
|
|
2478
2502
|
/** The repository's path: `owner/name`, or `group/sub/project`. */
|
|
2479
|
-
repo:
|
|
2480
|
-
number:
|
|
2503
|
+
repo: z33.string().min(1),
|
|
2504
|
+
number: z33.number().int().positive(),
|
|
2481
2505
|
/** As the forge shows it: `#226` (GitHub) or `!41` (GitLab). */
|
|
2482
|
-
ref:
|
|
2506
|
+
ref: z33.string(),
|
|
2483
2507
|
/** « Ouvrir sur GitHub / GitLab »: the front opens it itself (R11). */
|
|
2484
|
-
url:
|
|
2485
|
-
title:
|
|
2508
|
+
url: z33.string().url(),
|
|
2509
|
+
title: z33.string(),
|
|
2486
2510
|
state: PrStateSchema,
|
|
2487
2511
|
/** The source branch, and the branch it goes into. */
|
|
2488
|
-
branch:
|
|
2489
|
-
target:
|
|
2490
|
-
headSha:
|
|
2512
|
+
branch: z33.string(),
|
|
2513
|
+
target: z33.string(),
|
|
2514
|
+
headSha: z33.string(),
|
|
2491
2515
|
pipeline: PipeStatusSchema,
|
|
2492
2516
|
/** `required` when the forge gives it (GitLab); GitHub leaves it out. */
|
|
2493
|
-
approvals:
|
|
2517
|
+
approvals: z33.object({ given: z33.number().int().min(0), required: z33.number().int().min(0).optional() }),
|
|
2494
2518
|
/** The mockup's `ok`: all that a merge needs (R5), the pipeline set apart. */
|
|
2495
|
-
mergeable:
|
|
2519
|
+
mergeable: z33.boolean(),
|
|
2496
2520
|
/** Threads that can be resolved and are not. */
|
|
2497
|
-
openThreads:
|
|
2498
|
-
updatedAt:
|
|
2521
|
+
openThreads: z33.number().int().min(0),
|
|
2522
|
+
updatedAt: z33.string().datetime(),
|
|
2499
2523
|
/** The daemon's sessions on that branch, most recently active first (R12); the fleet qualifies them `machine:id`. */
|
|
2500
|
-
sessions:
|
|
2524
|
+
sessions: z33.array(z33.string()),
|
|
2501
2525
|
/**
|
|
2502
2526
|
* The account's roles on the request (issue #3), in the order author, assignee, reviewer; absent when it has none, and from a daemon
|
|
2503
2527
|
* older than this field.
|
|
2504
2528
|
*/
|
|
2505
|
-
roles:
|
|
2529
|
+
roles: z33.preprocess(dropUnknownRoles, z33.array(PrRoleSchema)).optional()
|
|
2506
2530
|
});
|
|
2507
|
-
var FollowedSessionSchema =
|
|
2508
|
-
var ForgeStatusSchema =
|
|
2531
|
+
var FollowedSessionSchema = z33.object({ session: z33.string(), forge: ForgeKindSchema, host: z33.string(), repo: z33.string() });
|
|
2532
|
+
var ForgeStatusSchema = z33.object({
|
|
2509
2533
|
forge: ForgeKindSchema,
|
|
2510
|
-
host:
|
|
2511
|
-
status:
|
|
2512
|
-
message:
|
|
2513
|
-
at:
|
|
2534
|
+
host: z33.string(),
|
|
2535
|
+
status: z33.enum(["ok", "missing", "unauthenticated", "error"]),
|
|
2536
|
+
message: z33.string().optional(),
|
|
2537
|
+
at: z33.string().datetime(),
|
|
2514
2538
|
/** Not `ok`: since when the forge cannot be read, whatever its messages since (« le relevé échoue depuis 10:42 »). */
|
|
2515
|
-
since:
|
|
2539
|
+
since: z33.string().datetime().optional(),
|
|
2516
2540
|
/** After a failed read (`error` mostly): when the daemon reads it again, its backoff of 2 to 10 minutes (« Nouvel essai à 10:50 »). */
|
|
2517
|
-
retryAt:
|
|
2541
|
+
retryAt: z33.string().datetime().optional(),
|
|
2518
2542
|
/** Not `ok`: when its requests, still shown, were last read; absent when they never were. */
|
|
2519
|
-
readAt:
|
|
2543
|
+
readAt: z33.string().datetime().optional()
|
|
2520
2544
|
});
|
|
2521
2545
|
var isRecord2 = (v) => typeof v === "object" && v !== null;
|
|
2522
2546
|
var known = (list, v) => typeof v === "string" && list.includes(v);
|
|
2523
2547
|
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;
|
|
2524
2548
|
var dropUnknownForges = (raw) => Array.isArray(raw) ? raw.filter((f) => isRecord2(f) && known(FORGE_KINDS, f.forge)) : raw;
|
|
2525
|
-
var ForgeStateMessageSchema =
|
|
2526
|
-
type:
|
|
2527
|
-
prs:
|
|
2528
|
-
forges:
|
|
2549
|
+
var ForgeStateMessageSchema = z33.object({
|
|
2550
|
+
type: z33.literal("forge.state"),
|
|
2551
|
+
prs: z33.preprocess(dropUnknownPrs, z33.array(PullRequestSchema)),
|
|
2552
|
+
forges: z33.preprocess(dropUnknownForges, z33.array(ForgeStatusSchema)),
|
|
2529
2553
|
/** Absent from a daemon older than this field. */
|
|
2530
|
-
followed:
|
|
2554
|
+
followed: z33.preprocess(dropUnknownForges, z33.array(FollowedSessionSchema)).optional(),
|
|
2531
2555
|
/**
|
|
2532
2556
|
* The account's own requests no session follows (issue #3): `sessions` empty, `roles` set. A request is in `prs` or here, never in
|
|
2533
2557
|
* both; a followed one carries its `roles` in `prs`. Absent from a daemon older than this field.
|
|
2534
2558
|
*/
|
|
2535
|
-
mine:
|
|
2536
|
-
machineId:
|
|
2537
|
-
});
|
|
2538
|
-
var PrJobSchema =
|
|
2539
|
-
id:
|
|
2540
|
-
name:
|
|
2541
|
-
column:
|
|
2542
|
-
columnName:
|
|
2543
|
-
status:
|
|
2544
|
-
durationS:
|
|
2545
|
-
});
|
|
2546
|
-
var PrCommentSchema =
|
|
2547
|
-
var PrThreadSchema =
|
|
2548
|
-
id:
|
|
2549
|
-
resolvable:
|
|
2550
|
-
resolved:
|
|
2551
|
-
file:
|
|
2552
|
-
line:
|
|
2553
|
-
code:
|
|
2554
|
-
comments:
|
|
2555
|
-
});
|
|
2556
|
-
var PrFileSchema =
|
|
2557
|
-
var PrReviewerSchema =
|
|
2558
|
-
var PrCommitSchema =
|
|
2559
|
-
var PrDetailSchema =
|
|
2559
|
+
mine: z33.preprocess(dropUnknownPrs, z33.array(PullRequestSchema)).optional(),
|
|
2560
|
+
machineId: z33.string().optional()
|
|
2561
|
+
});
|
|
2562
|
+
var PrJobSchema = z33.object({
|
|
2563
|
+
id: z33.string(),
|
|
2564
|
+
name: z33.string(),
|
|
2565
|
+
column: z33.number().int().min(0),
|
|
2566
|
+
columnName: z33.string(),
|
|
2567
|
+
status: z33.preprocess((s) => known(PIPE_STATUSES, s) ? s : "none", PipeStatusSchema),
|
|
2568
|
+
durationS: z33.number().min(0).optional()
|
|
2569
|
+
});
|
|
2570
|
+
var PrCommentSchema = z33.object({ id: z33.string(), author: z33.string(), at: z33.string().datetime(), body: z33.string() });
|
|
2571
|
+
var PrThreadSchema = z33.object({
|
|
2572
|
+
id: z33.string(),
|
|
2573
|
+
resolvable: z33.boolean(),
|
|
2574
|
+
resolved: z33.boolean(),
|
|
2575
|
+
file: z33.string().optional(),
|
|
2576
|
+
line: z33.number().int().optional(),
|
|
2577
|
+
code: z33.string().optional(),
|
|
2578
|
+
comments: z33.array(PrCommentSchema).min(1)
|
|
2579
|
+
});
|
|
2580
|
+
var PrFileSchema = z33.object({ path: z33.string(), added: z33.number().int().min(0), removed: z33.number().int().min(0), patch: z33.string().optional() });
|
|
2581
|
+
var PrReviewerSchema = z33.object({ name: z33.string(), state: z33.enum(["approved", "changes", "pending"]) });
|
|
2582
|
+
var PrCommitSchema = z33.object({ sha: z33.string(), title: z33.string(), author: z33.string(), at: z33.string().datetime() });
|
|
2583
|
+
var PrDetailSchema = z33.object({
|
|
2560
2584
|
pr: PullRequestSchema,
|
|
2561
|
-
description:
|
|
2562
|
-
author:
|
|
2563
|
-
reviewers:
|
|
2564
|
-
labels:
|
|
2585
|
+
description: z33.string(),
|
|
2586
|
+
author: z33.string(),
|
|
2587
|
+
reviewers: z33.array(PrReviewerSchema),
|
|
2588
|
+
labels: z33.array(z33.string()),
|
|
2565
2589
|
/** The tickets it closes, as the forge shows them (`#38`). */
|
|
2566
|
-
issues:
|
|
2567
|
-
jobs:
|
|
2590
|
+
issues: z33.array(z33.string()),
|
|
2591
|
+
jobs: z33.array(PrJobSchema),
|
|
2568
2592
|
/** A job's log when asked (`forge.detail` with `log`): its last 60 lines, no ANSI, redacted. */
|
|
2569
|
-
log:
|
|
2570
|
-
threads:
|
|
2571
|
-
files:
|
|
2572
|
-
commits:
|
|
2593
|
+
log: z33.object({ jobId: z33.string(), text: z33.string() }).optional(),
|
|
2594
|
+
threads: z33.array(PrThreadSchema),
|
|
2595
|
+
files: z33.array(PrFileSchema),
|
|
2596
|
+
commits: z33.array(PrCommitSchema),
|
|
2573
2597
|
/** The exact command a merge runs, for the front's confirmation (R5). */
|
|
2574
|
-
mergeCommand:
|
|
2598
|
+
mergeCommand: z33.string(),
|
|
2575
2599
|
/**
|
|
2576
2600
|
* Why a merge is refused now, as codes; empty: it can be merged (R5). `not_open`, `draft`, `approvals`, `changes_requested`;
|
|
2577
2601
|
* `pipeline`: the pipeline is not green (`pr.pipeline` says how); `pipeline_not_started`: no pipeline yet on the head, in a
|
|
2578
2602
|
* repository with CI or whose CI is unknown (`pr.pipeline` reads `wait`). A repository without any CI gives `none` and no code.
|
|
2579
2603
|
* A front shows a code it does not know as is.
|
|
2580
2604
|
*/
|
|
2581
|
-
mergeBlockers:
|
|
2605
|
+
mergeBlockers: z33.array(z33.string())
|
|
2582
2606
|
});
|
|
2583
|
-
var ForgeActionSchema =
|
|
2584
|
-
|
|
2607
|
+
var ForgeActionSchema = z33.discriminatedUnion("kind", [
|
|
2608
|
+
z33.object({ kind: z33.literal("rerun") }),
|
|
2585
2609
|
/** `headSha`: the head the person saw; `stale` when it has moved. */
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2610
|
+
z33.object({ kind: z33.literal("merge"), headSha: z33.string().min(1).max(64) }),
|
|
2611
|
+
z33.object({ kind: z33.literal("comment"), body: z33.string().min(1).max(FORGE_BODY_MAX) }),
|
|
2612
|
+
z33.object({ kind: z33.literal("reply"), threadId: z33.string().min(1).max(200), body: z33.string().min(1).max(FORGE_BODY_MAX) }),
|
|
2613
|
+
z33.object({ kind: z33.literal("resolve"), threadId: z33.string().min(1).max(200) })
|
|
2590
2614
|
]);
|
|
2591
|
-
var ForgeDetailSchema =
|
|
2592
|
-
var ForgeActSchema =
|
|
2593
|
-
var ForgeDetailReplySchema =
|
|
2594
|
-
var ForgeActReplySchema =
|
|
2615
|
+
var ForgeDetailSchema = z33.object({ type: z33.literal("forge.detail"), requestId: z33.string().min(1).max(100), prId: z33.string().min(1).max(500), log: z33.string().min(1).max(40).optional(), machineId: z33.string().optional() });
|
|
2616
|
+
var ForgeActSchema = z33.object({ type: z33.literal("forge.act"), requestId: z33.string().min(1).max(100), prId: z33.string().min(1).max(500), machineId: z33.string().optional(), action: ForgeActionSchema });
|
|
2617
|
+
var ForgeDetailReplySchema = z33.object({ type: z33.literal("forge.detail.reply"), requestId: z33.string(), ok: z33.boolean(), detail: PrDetailSchema.optional(), message: z33.string().optional(), code: RefusalCodeSchema.optional() });
|
|
2618
|
+
var ForgeActReplySchema = z33.object({ type: z33.literal("forge.act.reply"), requestId: z33.string(), ok: z33.boolean(), command: z33.string().optional(), message: z33.string().optional(), code: RefusalCodeSchema.optional() });
|
|
2595
2619
|
var CLOSED_KEEP_DAYS = 7;
|
|
2596
2620
|
var CLOSED_KEEP_MS = CLOSED_KEEP_DAYS * 24 * 60 * 6e4;
|
|
2597
2621
|
var PR_ROLE_FILTERS = ["all", ...PR_ROLES];
|
|
2598
2622
|
|
|
2599
2623
|
// ../../packages/protocol/src/messages.ts
|
|
2600
|
-
var SessionEventSchema =
|
|
2601
|
-
name:
|
|
2602
|
-
at:
|
|
2603
|
-
source:
|
|
2604
|
-
tool:
|
|
2605
|
-
text:
|
|
2606
|
-
options:
|
|
2624
|
+
var SessionEventSchema = z34.object({
|
|
2625
|
+
name: z34.enum(["SessionStart", "UserPromptSubmit", "PreToolUse", "PermissionRequest", "Notification", "Stop", "SessionEnd", "PaneChanged", "PaneGone", "PanePrompt", "PaneIdle", "InjectFailed", "Decided", "PostToolUse", "PostToolUseFailure", "StopFailure", "SubagentStart", "SubagentStop", "PaneTitle", "Renamed", "NativeRequest", "AgentMessage", "QueueUpdate", "PaneUnreadable", "PaneReadable"]),
|
|
2626
|
+
at: z34.string().datetime(),
|
|
2627
|
+
source: z34.enum(["hook", "pane", "daemon"]),
|
|
2628
|
+
tool: z34.string().optional(),
|
|
2629
|
+
text: z34.string().optional(),
|
|
2630
|
+
options: z34.array(z34.string()).optional(),
|
|
2607
2631
|
/** Each option's description, by index ('' when it has none); left out when no option has one. */
|
|
2608
|
-
optionDetails:
|
|
2609
|
-
kind:
|
|
2632
|
+
optionDetails: z34.array(z34.string()).optional(),
|
|
2633
|
+
kind: z34.enum(["question", "permission", "plan", "diff"]).optional(),
|
|
2610
2634
|
/** PanePrompt: what to review in full before deciding (a plan read in the terminal), when `text` is its summary. */
|
|
2611
|
-
body:
|
|
2612
|
-
exitCode:
|
|
2613
|
-
helperId:
|
|
2635
|
+
body: z34.string().optional(),
|
|
2636
|
+
exitCode: z34.number().int().nullable().optional(),
|
|
2637
|
+
helperId: z34.string().optional(),
|
|
2614
2638
|
/** The helper's description, once known (Claude Code: its `.meta.json`, written after SubagentStart). */
|
|
2615
|
-
task:
|
|
2639
|
+
task: z34.string().optional(),
|
|
2616
2640
|
/** PostToolUseFailure: the user interrupted the turn (Esc); Claude then waits for input with no Stop. */
|
|
2617
|
-
interrupt:
|
|
2641
|
+
interrupt: z34.boolean().optional(),
|
|
2618
2642
|
/** UserPromptSubmit, PostToolUse: the images the prompt or the tool result carried, by attachment id. */
|
|
2619
|
-
attachments:
|
|
2643
|
+
attachments: z34.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(),
|
|
2620
2644
|
/** PostToolUse: some of the result's images were not kept. */
|
|
2621
|
-
imagesDropped:
|
|
2645
|
+
imagesDropped: z34.boolean().optional(),
|
|
2622
2646
|
/** QueueUpdate: OMP's queue as it stands. */
|
|
2623
|
-
queue:
|
|
2647
|
+
queue: z34.array(z34.object({ text: z34.string(), mode: z34.enum(["steer", "follow_up"]) })).optional(),
|
|
2624
2648
|
/** AgentMessage: the harness's own message, its text so far (`streaming`) or whole. `messageId` is unique for the session's life. */
|
|
2625
|
-
messageId:
|
|
2626
|
-
streaming:
|
|
2649
|
+
messageId: z34.string().optional(),
|
|
2650
|
+
streaming: z34.boolean().optional(),
|
|
2627
2651
|
/** NativeRequest: the dialog's id, and OMP's `ask` questions when it is one. */
|
|
2628
|
-
requestId:
|
|
2629
|
-
questions:
|
|
2652
|
+
requestId: z34.string().optional(),
|
|
2653
|
+
questions: z34.array(AskQuestionSchema).optional(),
|
|
2630
2654
|
/** Stop: its text is already in the thread as AgentMessage cards, which the reply card must not repeat. */
|
|
2631
|
-
streamed:
|
|
2655
|
+
streamed: z34.boolean().optional(),
|
|
2632
2656
|
/** Native tracking (spec 2026-10-13 §2): the harness's id of the tool call, so its result lands on the same row. */
|
|
2633
|
-
toolUseId:
|
|
2657
|
+
toolUseId: z34.string().optional(),
|
|
2634
2658
|
/** The tool's input as the harness gave it, every string capped by the hook. */
|
|
2635
|
-
toolInput:
|
|
2659
|
+
toolInput: z34.record(z34.string(), z34.unknown()).optional(),
|
|
2636
2660
|
/** PostToolUse: the id the harness gave a call it left running in the background (Claude Code's `backgroundTaskId`, issue #1). */
|
|
2637
|
-
backgroundTaskId:
|
|
2661
|
+
backgroundTaskId: z34.string().optional(),
|
|
2638
2662
|
/** PostToolUse: the result as text; SubagentStop: nothing (the report travels in `text`). */
|
|
2639
|
-
output:
|
|
2640
|
-
durationMs:
|
|
2663
|
+
output: z34.string().optional(),
|
|
2664
|
+
durationMs: z34.number().nonnegative().optional(),
|
|
2641
2665
|
/** PostToolUseFailure: the harness's error message. */
|
|
2642
|
-
error:
|
|
2666
|
+
error: z34.string().optional(),
|
|
2643
2667
|
/** The session's transcript, or the helper's on SubagentStop; the daemon reads its tail for the agent's messages. */
|
|
2644
|
-
transcriptPath:
|
|
2668
|
+
transcriptPath: z34.string().optional(),
|
|
2645
2669
|
/** Decided: what was chosen when the daemon knows it. */
|
|
2646
2670
|
decision: DecisionSchema.optional(),
|
|
2647
2671
|
/** Decided: the request was refused by Ledge closing the session (its interrupt keys), not by the user's answer. */
|
|
2648
|
-
byClose:
|
|
2672
|
+
byClose: z34.literal(true).optional(),
|
|
2649
2673
|
/** Decided: who answered, when the daemon typed it (absent: answered in the terminal, or an older daemon). */
|
|
2650
2674
|
by: DecidedBySchema.optional(),
|
|
2651
2675
|
/** The agent's own session id when the hook names it, so the daemon can resume that conversation. */
|
|
2652
|
-
agentSessionId:
|
|
2676
|
+
agentSessionId: z34.string().optional()
|
|
2653
2677
|
});
|
|
2654
|
-
var RecentSchema =
|
|
2678
|
+
var RecentSchema = z34.object({ cwd: z34.string().min(1), project: z34.string().min(1), lastAt: z34.string().datetime() });
|
|
2655
2679
|
var SEMVER = /^\d+\.\d+\.\d+$/;
|
|
2656
|
-
var PingSchema =
|
|
2657
|
-
var PongSchema =
|
|
2658
|
-
var DaemonInfoSchema =
|
|
2659
|
-
version:
|
|
2660
|
-
install:
|
|
2661
|
-
systemd:
|
|
2662
|
-
manual:
|
|
2663
|
-
routing:
|
|
2664
|
-
archive:
|
|
2680
|
+
var PingSchema = z34.object({ type: z34.literal("ping"), requestId: z34.string().min(1).max(100), machineId: z34.string().optional() });
|
|
2681
|
+
var PongSchema = z34.object({ type: z34.literal("pong"), requestId: z34.string(), machineId: z34.string().optional(), error: z34.enum(["offline", "outdated"]).optional() });
|
|
2682
|
+
var DaemonInfoSchema = z34.object({
|
|
2683
|
+
version: z34.string(),
|
|
2684
|
+
install: z34.enum(["npm", "git", "unknown"]),
|
|
2685
|
+
systemd: z34.boolean(),
|
|
2686
|
+
manual: z34.string().optional(),
|
|
2687
|
+
routing: z34.boolean().optional(),
|
|
2688
|
+
archive: z34.boolean().optional(),
|
|
2665
2689
|
/** Takes `model` and `effort` on `session.launch` and answers `models.list` (#58). */
|
|
2666
|
-
models:
|
|
2690
|
+
models: z34.boolean().optional(),
|
|
2667
2691
|
/** Drives OMP over its RPC: launching `omp` sessions is possible when the binary is there (`models.list` says so). */
|
|
2668
|
-
omp:
|
|
2692
|
+
omp: z34.boolean().optional(),
|
|
2669
2693
|
/** Takes `session.model`: a live session's model and effort changed (#58, lot 2). */
|
|
2670
|
-
modelSwitch:
|
|
2694
|
+
modelSwitch: z34.boolean().optional(),
|
|
2671
2695
|
/** Answers `session.commands`: the slash commands a session's agent offers. */
|
|
2672
|
-
commands:
|
|
2696
|
+
commands: z34.boolean().optional(),
|
|
2673
2697
|
/** Takes `approval` on an OMP `session.launch` (auto mode). */
|
|
2674
|
-
ompApproval:
|
|
2698
|
+
ompApproval: z34.boolean().optional(),
|
|
2675
2699
|
/** Its home folder, so a client shows the folders under it as `~` (absent from older daemons). */
|
|
2676
|
-
home:
|
|
2677
|
-
mobile:
|
|
2700
|
+
home: z34.string().optional(),
|
|
2701
|
+
mobile: z34.boolean().optional(),
|
|
2678
2702
|
/** Answers `openrig.status` and `openrig.act`: drives OpenRig on its machine. */
|
|
2679
|
-
openrig:
|
|
2703
|
+
openrig: z34.boolean().optional(),
|
|
2680
2704
|
/** Answers `openrig.roles`, `openrig.role` and `openrig.roleFile`: reads OpenRig's roles (agent specs). */
|
|
2681
|
-
openrigRoles:
|
|
2705
|
+
openrigRoles: z34.boolean().optional(),
|
|
2682
2706
|
/** 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):
|
|
2683
2707
|
* a client (the fleet) sends none of them to a daemon without it. */
|
|
2684
|
-
openrigRig:
|
|
2708
|
+
openrigRig: z34.boolean().optional(),
|
|
2685
2709
|
/** Takes the action `rig.policy` (lot 7c): a client (the fleet) sends it only when this is set. */
|
|
2686
|
-
openrigPolicy:
|
|
2710
|
+
openrigPolicy: z34.boolean().optional(),
|
|
2687
2711
|
/** Takes `rig.start` with `fresh` (lot 7d): a client (the fleet) sends it only when this is set. */
|
|
2688
|
-
openrigFresh:
|
|
2712
|
+
openrigFresh: z34.boolean().optional(),
|
|
2689
2713
|
/** Answers `ping` with `pong`: a client measures the round trip to this machine (lot 7d). */
|
|
2690
|
-
ping:
|
|
2714
|
+
ping: z34.boolean().optional(),
|
|
2691
2715
|
/** Answers `openrig.row`: a queue row's state, for the OpenRig task cards of a thread. */
|
|
2692
|
-
openrigRows:
|
|
2716
|
+
openrigRows: z34.boolean().optional(),
|
|
2693
2717
|
/** Answers `openrig.asks` and `openrig.answer`: what OpenRig asks the person, and their answers (« À toi »). */
|
|
2694
|
-
openrigAsks:
|
|
2718
|
+
openrigAsks: z34.boolean().optional(),
|
|
2695
2719
|
/** Answers `openrig.goal.send`, `openrig.goals` and `openrig.goal.reply`: goals given to Max (lot 2). */
|
|
2696
|
-
openrigGoals:
|
|
2720
|
+
openrigGoals: z34.boolean().optional(),
|
|
2697
2721
|
/** Takes `session.broadcast` (its `ledge bridge` too, on this machine): a client sends it only when this is set. */
|
|
2698
|
-
broadcast:
|
|
2722
|
+
broadcast: z34.boolean().optional(),
|
|
2699
2723
|
/** Sends `browser.live` and answers `browser.watch`, `browser.unwatch` and `browser.enable`: the agent's browser, live. */
|
|
2700
|
-
browserLive:
|
|
2724
|
+
browserLive: z34.boolean().optional(),
|
|
2701
2725
|
/** Answers `term.watch` and `term.shell`: the pane and the shells as a tmux control stream, xterm.js the only emulator. */
|
|
2702
|
-
terminalStream:
|
|
2726
|
+
terminalStream: z34.boolean().optional(),
|
|
2703
2727
|
/** Sends `usage.state` (each harness's account limits, the alerts, the threshold) and takes `usage.set` and `usage.ack`. */
|
|
2704
|
-
usage:
|
|
2728
|
+
usage: z34.boolean().optional(),
|
|
2705
2729
|
/** `term.watch` also streams an OpenRig seat (`@` in its tmux name), through a control client on the seat's own tmux server.
|
|
2706
2730
|
* Without it, a front keeps a seat on the pseudo-terminal: an older daemon answers its watch `failed`. */
|
|
2707
|
-
terminalStreamSeats:
|
|
2731
|
+
terminalStreamSeats: z34.boolean().optional(),
|
|
2708
2732
|
/** Sends `forge.state` and answers `forge.detail` and `forge.act`: the pull and merge requests of its sessions' branches (lot 8a). */
|
|
2709
|
-
forge:
|
|
2733
|
+
forge: z34.boolean().optional(),
|
|
2710
2734
|
/** Answers `routine.list`, `routine.cmd` and `routine.preview`, and sends `routine.changed` (spec 2026-11-23 routines). */
|
|
2711
|
-
routines:
|
|
2735
|
+
routines: z34.boolean().optional(),
|
|
2712
2736
|
/** Answers a grouped `routine.cmd` (`others`) all or nothing: a client sends one only to a daemon that says it. */
|
|
2713
|
-
routineGroups:
|
|
2737
|
+
routineGroups: z34.boolean().optional(),
|
|
2738
|
+
/** Takes `session.aside` (#41): a Claude Code session's `/btw`, answered as an aside, not a thread item. */
|
|
2739
|
+
aside: z34.boolean().optional(),
|
|
2740
|
+
/** Takes `session.label`: a session's nickname, kept with it. A client sends one only to a daemon that says it. */
|
|
2741
|
+
sessionLabel: z34.boolean().optional(),
|
|
2714
2742
|
/** Its launcher answers `shell --nonce <N> <dir>` (#299): a free shell started through it gets the shell integration (OSC 633). */
|
|
2715
|
-
freeShell:
|
|
2743
|
+
freeShell: z34.boolean().optional()
|
|
2716
2744
|
});
|
|
2717
|
-
var UpdateFailureSchema =
|
|
2718
|
-
var ServerMessageSchema =
|
|
2745
|
+
var UpdateFailureSchema = z34.enum(["git-install", "no-systemd", "sessions-at-risk", "npm-failed", "busy"]);
|
|
2746
|
+
var ServerMessageSchema = z34.discriminatedUnion("type", [
|
|
2719
2747
|
BrowserLiveSchema,
|
|
2720
2748
|
BrowserFrameSchema,
|
|
2721
2749
|
BrowserEnabledSchema,
|
|
@@ -2724,7 +2752,7 @@ var ServerMessageSchema = z33.discriminatedUnion("type", [
|
|
|
2724
2752
|
TermSizeSchema,
|
|
2725
2753
|
TermExitSchema,
|
|
2726
2754
|
SessionModelAcceptedSchema,
|
|
2727
|
-
|
|
2755
|
+
z34.object({ type: z34.literal("chat.routed"), qid: z34.string(), result: RouteResultSchema }),
|
|
2728
2756
|
DocumentContentSchema,
|
|
2729
2757
|
DocumentErrorSchema,
|
|
2730
2758
|
AttachmentStoredSchema,
|
|
@@ -2757,87 +2785,88 @@ var ServerMessageSchema = z33.discriminatedUnion("type", [
|
|
|
2757
2785
|
/** `recents`: the folders of past sessions, most recent first. `launcher`: the command that runs `ledge` inside WSL
|
|
2758
2786
|
* (`[node, cli]`), so the overlay can attach a terminal to a session with `<launcher> attach <id>`. `daemon`: absent
|
|
2759
2787
|
* from daemons older than the auto-update. */
|
|
2760
|
-
|
|
2761
|
-
|
|
2788
|
+
z34.object({ type: z34.literal("snapshot"), sessions: z34.array(SessionSchema), recents: z34.array(RecentSchema).optional(), launcher: z34.array(z34.string()).optional(), daemon: DaemonInfoSchema.optional(), sshAlias: SshAliasSchema.optional() }),
|
|
2789
|
+
z34.object({ type: z34.literal("session.updated"), session: SessionSchema }),
|
|
2762
2790
|
/** OMP: the instructions taken back from its queue by an interrupt that restores it; the asker puts them back in its draft. */
|
|
2763
|
-
|
|
2764
|
-
type:
|
|
2765
|
-
id:
|
|
2766
|
-
texts:
|
|
2791
|
+
z34.object({
|
|
2792
|
+
type: z34.literal("session.queue.restored"),
|
|
2793
|
+
id: z34.string(),
|
|
2794
|
+
texts: z34.array(z34.string()),
|
|
2767
2795
|
/** The same instructions with the images they carried; `imagesDropped`: some images could not be put back. */
|
|
2768
|
-
entries:
|
|
2769
|
-
imagesDropped:
|
|
2796
|
+
entries: z34.array(z34.object({ text: z34.string(), attachments: z34.array(AttachmentIdSchema).optional() })).optional(),
|
|
2797
|
+
imagesDropped: z34.boolean().optional()
|
|
2770
2798
|
}),
|
|
2771
|
-
|
|
2772
|
-
|
|
2799
|
+
z34.object({ type: z34.literal("session.removed"), id: z34.string() }),
|
|
2800
|
+
z34.object({ type: z34.literal("session.preview"), id: z34.string(), lines: z34.array(z34.string()) }),
|
|
2773
2801
|
/** A session's thread, on request (spec 2026-10-13 §5); then each created or updated item, broadcast. */
|
|
2774
|
-
|
|
2775
|
-
|
|
2802
|
+
z34.object({ type: z34.literal("session.thread"), id: z34.string(), items: z34.array(ThreadItemSchema) }),
|
|
2803
|
+
z34.object({ type: z34.literal("session.thread.item"), id: z34.string(), item: ThreadItemSchema }),
|
|
2804
|
+
SessionAsideSchema,
|
|
2776
2805
|
/** Answer to the requester of a `session.launch`: the session exists (its `session.updated` is broadcast as usual). */
|
|
2777
|
-
|
|
2806
|
+
z34.object({ type: z34.literal("session.launched"), id: z34.string() }),
|
|
2778
2807
|
/** Answer to the requester of a `session.close`, once per row closed: the session `id` and how it ended. */
|
|
2779
|
-
|
|
2780
|
-
|
|
2808
|
+
z34.object({ type: z34.literal("session.closed"), qid: z34.string(), row: z34.number().int().min(0), id: z34.string(), how: z34.enum(["exit", "killed"]) }),
|
|
2809
|
+
z34.object({ type: z34.literal("recents"), recents: z34.array(RecentSchema) }),
|
|
2781
2810
|
/** Answer to the requester of a `folder.list` or `folder.create`: `path` resolved (`~` expanded), `parent` null at the
|
|
2782
2811
|
* root, `entries` its subfolders by name (hidden ones left out). A failure keeps the asked path and says why in `error`,
|
|
2783
2812
|
* never in an `error` message, which the launch form reads as a failed launch. */
|
|
2784
|
-
|
|
2785
|
-
type:
|
|
2786
|
-
path:
|
|
2787
|
-
parent:
|
|
2788
|
-
entries:
|
|
2789
|
-
error:
|
|
2813
|
+
z34.object({
|
|
2814
|
+
type: z34.literal("folder.listing"),
|
|
2815
|
+
path: z34.string(),
|
|
2816
|
+
parent: z34.string().nullable(),
|
|
2817
|
+
entries: z34.array(z34.string()),
|
|
2818
|
+
error: z34.string().optional(),
|
|
2790
2819
|
/** The request this answers, when it carried one. */
|
|
2791
|
-
requestId:
|
|
2820
|
+
requestId: z34.string().optional(),
|
|
2792
2821
|
/** Those `entries` that are Git repositories, with their branch (the short commit when HEAD is detached). */
|
|
2793
|
-
repos:
|
|
2822
|
+
repos: z34.array(z34.object({ name: z34.string(), branch: z34.string() })).optional()
|
|
2794
2823
|
}),
|
|
2795
2824
|
/** 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. */
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2825
|
+
z34.object({ type: z34.literal("chat.step"), qid: z34.string(), step: ChatStepSchema }),
|
|
2826
|
+
z34.object({ type: z34.literal("chat.delta"), qid: z34.string(), text: z34.string() }),
|
|
2827
|
+
z34.object({ type: z34.literal("chat.done"), qid: z34.string(), text: z34.string(), at: z34.string().datetime(), proposal: ChatProposalSchema.optional(), proposals: ChatProposalsSchema.optional(), relay: ChatRelaySchema.optional(), closes: ChatClosesSchema.optional(), projectProposal: ChatProjectProposalSchema.optional(), tasks: ChatTasksSchema.optional(), actions: ChatActionsSchema.optional() }),
|
|
2799
2828
|
/** What a `chat.act` applied: the rows done, and the one that failed with why (the rows after it stay proposed). */
|
|
2800
|
-
|
|
2801
|
-
row:
|
|
2802
|
-
message:
|
|
2829
|
+
z34.object({ type: z34.literal("chat.acted"), rid: z34.string(), qid: z34.string(), done: z34.array(z34.number().int().min(0)), failed: z34.array(z34.object({
|
|
2830
|
+
row: z34.number().int().min(0),
|
|
2831
|
+
message: z34.string(),
|
|
2803
2832
|
/** nothing was sent */
|
|
2804
|
-
refused:
|
|
2833
|
+
refused: z34.literal(true).optional()
|
|
2805
2834
|
})) }),
|
|
2806
2835
|
/** What an `action.run` came to: `row` the action as the daemon resolved it (its summary, its risk); `reason` why it was not
|
|
2807
2836
|
* done, with `code` (`refused`: not possible now; `agent`: a session may not run it; `confirm_required`: destructive, ask
|
|
2808
2837
|
* again; `failed`: the handler turned it down; a free string, as an `error`'s). */
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2838
|
+
z34.object({ type: z34.literal("action.result"), rid: z34.string(), action: z34.string().min(1).max(40), row: ChatActionSchema.optional(), reason: z34.string().optional(), code: z34.string().optional() }),
|
|
2839
|
+
z34.object({ type: z34.literal("chat.error"), qid: z34.string(), message: z34.string() }),
|
|
2840
|
+
z34.object({ type: z34.literal("chat.history"), turns: z34.array(ChatTurnSchema) }),
|
|
2812
2841
|
/** The daemon updating itself: npm is running, then the service restarts (the socket closes right after). */
|
|
2813
|
-
|
|
2842
|
+
z34.object({ type: z34.literal("update.progress"), version: z34.string(), step: z34.enum(["installing", "restarting"]) }),
|
|
2814
2843
|
/** Nothing was changed. `detail`: the useful end of npm's output; `command`: what the person can run instead. */
|
|
2815
|
-
|
|
2844
|
+
z34.object({ type: z34.literal("update.failed"), version: z34.string(), reason: UpdateFailureSchema, detail: z34.string().optional(), command: z34.string().optional() }),
|
|
2816
2845
|
/** The shared machines list (spec 2026-10-14 §5), sent to local clients only. */
|
|
2817
|
-
|
|
2846
|
+
z34.object({ type: z34.literal("machines"), machines: MachinesSchema }),
|
|
2818
2847
|
/** The local daemon's projects and folder rules (spec 2026-10-16 build §5), sent to local clients only. */
|
|
2819
|
-
|
|
2848
|
+
z34.object({ type: z34.literal("projects"), projects: ProjectsSchema }),
|
|
2820
2849
|
/** The island's settings shared by the local fronts; null until a front sets them (the island then sends its own). Local clients only. */
|
|
2821
|
-
|
|
2850
|
+
z34.object({ type: z34.literal("island"), prefs: IslandPrefsSchema.nullable() }),
|
|
2822
2851
|
/** Mobile access (lot 3), after the island in each snapshot and on every change. Local clients only. */
|
|
2823
|
-
|
|
2852
|
+
z34.object({ type: z34.literal("mobile"), state: MobileStateSchema }),
|
|
2824
2853
|
/** A passkey recovery as it happens (docs/mobile-passkey-recover-contract.md), for the local fronts' toast; the lasting trace is in `mobile`. */
|
|
2825
|
-
|
|
2854
|
+
z34.object({ type: z34.literal("mobile.recovery") }).merge(MobileRecoveryEventSchema),
|
|
2826
2855
|
/** The sessions a phone types into (« Téléphone au clavier »), after each snapshot and each change; `device` is its label. */
|
|
2827
|
-
|
|
2856
|
+
z34.object({ type: z34.literal("terminal.holders"), holds: z34.array(z34.object({ id: z34.string(), device: z34.string() })) }),
|
|
2828
2857
|
/** 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`. */
|
|
2829
|
-
|
|
2830
|
-
type:
|
|
2831
|
-
rid:
|
|
2832
|
-
outcome:
|
|
2833
|
-
reason:
|
|
2858
|
+
z34.object({
|
|
2859
|
+
type: z34.literal("message.ack"),
|
|
2860
|
+
rid: z34.string(),
|
|
2861
|
+
outcome: z34.enum(["accepted", "queued", "native", "refused"]),
|
|
2862
|
+
reason: z34.string().optional(),
|
|
2834
2863
|
/** A broadcast's per-recipient outcome, by name. */
|
|
2835
|
-
recipients:
|
|
2864
|
+
recipients: z34.object({ sent: z34.array(z34.string()), refused: z34.array(z34.object({ name: z34.string(), reason: z34.string() })) }).optional()
|
|
2836
2865
|
}),
|
|
2837
2866
|
/** The answer to a `session.broadcast`: who got it (`sent`) and who did not; `reason`: the whole broadcast was refused. */
|
|
2838
|
-
|
|
2867
|
+
z34.object({ type: z34.literal("session.broadcast.result"), rid: z34.string(), sent: z34.array(z34.object({ id: z34.string(), name: z34.string() })), refused: z34.array(z34.object({ name: z34.string(), reason: z34.string() })), reason: z34.string().optional() }),
|
|
2839
2868
|
/** The answer to a `message.read`: the body with its sender, target and time, or the refusal's `reason`. */
|
|
2840
|
-
|
|
2869
|
+
z34.object({ type: z34.literal("message.body"), id: z34.string(), from: z34.string().optional(), to: z34.string().optional(), at: z34.string().optional(), text: z34.string().optional(), reason: z34.string().optional() }),
|
|
2841
2870
|
TaskResultSchema,
|
|
2842
2871
|
ReportPreviewReplySchema,
|
|
2843
2872
|
ReportCreatedSchema,
|
|
@@ -2858,21 +2887,21 @@ var ServerMessageSchema = z33.discriminatedUnion("type", [
|
|
|
2858
2887
|
RoutineChangedSchema,
|
|
2859
2888
|
RoutinePreviewedSchema,
|
|
2860
2889
|
/** The operator's notices, broadcast on change and in the snapshot. */
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
type:
|
|
2864
|
-
message:
|
|
2865
|
-
id:
|
|
2890
|
+
z34.object({ type: z34.literal("operator.state"), notices: z34.array(OperatorNoticeSchema).max(50) }),
|
|
2891
|
+
z34.object({
|
|
2892
|
+
type: z34.literal("error"),
|
|
2893
|
+
message: z34.string(),
|
|
2894
|
+
id: z34.string().optional(),
|
|
2866
2895
|
/** Le type du message client refusé. */
|
|
2867
|
-
request:
|
|
2896
|
+
request: z34.string().optional(),
|
|
2868
2897
|
/** Ce que le front doit reconnaître au-delà du texte (NOTE_NOT_TYPED) ; une chaîne libre, qu'un front plus ancien ignore. */
|
|
2869
|
-
code:
|
|
2898
|
+
code: z34.string().optional()
|
|
2870
2899
|
})
|
|
2871
2900
|
]);
|
|
2872
2901
|
var MESSAGE_MAX = 2e4;
|
|
2873
2902
|
var SUMMARY_MAX = 500;
|
|
2874
|
-
var launchRows =
|
|
2875
|
-
var ClientMessageSchema =
|
|
2903
|
+
var launchRows = z34.array(z34.number().int().min(0).max(MAX_PROPOSALS - 1)).min(1).max(MAX_PROPOSALS).refine((r) => new Set(r).size === r.length, "a row twice");
|
|
2904
|
+
var ClientMessageSchema = z34.discriminatedUnion("type", [
|
|
2876
2905
|
BrowserWatchSchema,
|
|
2877
2906
|
BrowserUnwatchSchema,
|
|
2878
2907
|
BrowserEnableSchema,
|
|
@@ -2881,7 +2910,7 @@ var ClientMessageSchema = z33.discriminatedUnion("type", [
|
|
|
2881
2910
|
TermUnwatchSchema,
|
|
2882
2911
|
TermInputSchema,
|
|
2883
2912
|
TermResizeSchema,
|
|
2884
|
-
|
|
2913
|
+
z34.object({ type: z34.literal("chat.route"), qid: z34.string().min(1).max(100), text: z34.string().min(1).max(2e4), tool: ToolSchema.optional(), context: RoutingContextSchema }),
|
|
2885
2914
|
DocumentReadSchema,
|
|
2886
2915
|
AttachmentPutSchema,
|
|
2887
2916
|
AttachmentCaptureSchema,
|
|
@@ -2914,190 +2943,194 @@ var ClientMessageSchema = z33.discriminatedUnion("type", [
|
|
|
2914
2943
|
* free one otherwise), `prompt` the agent's first instruction, `continue` resumes the folder's last conversation.
|
|
2915
2944
|
* With `qid` it is the chat card of that turn: the daemon launches the turn's proposal and ignores the other fields
|
|
2916
2945
|
* but `rows`, `model` and `effort`. */
|
|
2917
|
-
|
|
2918
|
-
type:
|
|
2946
|
+
z34.object({
|
|
2947
|
+
type: z34.literal("session.launch"),
|
|
2919
2948
|
tool: ToolSchema,
|
|
2920
|
-
cwd:
|
|
2921
|
-
name:
|
|
2922
|
-
prompt:
|
|
2923
|
-
continue:
|
|
2924
|
-
qid:
|
|
2949
|
+
cwd: z34.string().min(1),
|
|
2950
|
+
name: z34.string().optional(),
|
|
2951
|
+
prompt: z34.string().optional(),
|
|
2952
|
+
continue: z34.boolean().optional(),
|
|
2953
|
+
qid: z34.string().min(1).optional(),
|
|
2925
2954
|
/** With `qid`: the card's rows to launch (#24), indexes into the turn's `proposals`, each once; the first row without it. */
|
|
2926
2955
|
rows: launchRows.optional(),
|
|
2927
2956
|
/** Folders in addition to `cwd` (Claude: `--add-dir`); resolved like `cwd`. */
|
|
2928
|
-
dirs:
|
|
2957
|
+
dirs: z34.array(z34.string().min(1)).max(20).optional(),
|
|
2929
2958
|
/** The agent's model and effort (#58), the agent's own default when left out; with `qid`, for every row launched. */
|
|
2930
2959
|
model: ModelIdSchema.optional(),
|
|
2931
2960
|
effort: EffortSchema.optional(),
|
|
2932
2961
|
/** OMP only: its approval mode, `always-ask` when left out. */
|
|
2933
2962
|
approval: OmpApprovalSchema.optional(),
|
|
2934
2963
|
/** Routing by the fleet, removed before the message reaches the daemon. */
|
|
2935
|
-
machineId:
|
|
2964
|
+
machineId: z34.string().optional()
|
|
2936
2965
|
}),
|
|
2937
2966
|
/** The launch form's folder browser: list a folder's subfolders (home when no `path`), or make `name` inside `parent`
|
|
2938
2967
|
* and list it. Both are answered with a `folder.listing`. */
|
|
2939
|
-
|
|
2940
|
-
type:
|
|
2941
|
-
path:
|
|
2968
|
+
z34.object({
|
|
2969
|
+
type: z34.literal("folder.list"),
|
|
2970
|
+
path: z34.string().optional(),
|
|
2942
2971
|
/** Routing by the fleet, removed before the message reaches the daemon. */
|
|
2943
|
-
machineId:
|
|
2972
|
+
machineId: z34.string().optional(),
|
|
2944
2973
|
/** Copied into the `folder.listing` that answers; the fleet relays only that listing, from the machine asked. */
|
|
2945
|
-
requestId:
|
|
2974
|
+
requestId: z34.string().min(1).max(100).optional()
|
|
2946
2975
|
}),
|
|
2947
|
-
|
|
2948
|
-
type:
|
|
2949
|
-
parent:
|
|
2950
|
-
name:
|
|
2976
|
+
z34.object({
|
|
2977
|
+
type: z34.literal("folder.create"),
|
|
2978
|
+
parent: z34.string().min(1),
|
|
2979
|
+
name: z34.string().min(1),
|
|
2951
2980
|
/** As for `folder.list`: routing by the fleet, and the request its `folder.listing` answers. */
|
|
2952
|
-
machineId:
|
|
2953
|
-
requestId:
|
|
2981
|
+
machineId: z34.string().optional(),
|
|
2982
|
+
requestId: z34.string().min(1).max(100).optional()
|
|
2954
2983
|
}),
|
|
2955
2984
|
/** `steer`: OMP only, redirect the turn running now instead of queueing the text after it. */
|
|
2956
2985
|
/** OMP's `ask`: the answers to every question of the dialog `requestId`, in order (`selected` labels, and/or free `text`); `cancel` declines it. */
|
|
2957
|
-
|
|
2986
|
+
z34.object({ type: z34.literal("session.answer"), id: z34.string(), requestId: z34.string().min(1).max(200), answers: z34.array(z34.object({ id: z34.string(), selected: z34.array(z34.string().max(2e3)).max(100), text: z34.string().max(2e4).optional() })).max(50), cancel: z34.boolean().optional() }),
|
|
2958
2987
|
/** `by`: as session.decide's, who answers when the reply answers a request (set by the phone gateway for a device; absent, the PC). */
|
|
2959
|
-
|
|
2988
|
+
z34.object({ type: z34.literal("session.reply"), id: z34.string(), text: z34.string(), attachments: z34.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(), steer: z34.boolean().optional(), by: DecidedBySchema.optional() }),
|
|
2960
2989
|
/** The chat card's instruction (spec 2026-10-12 relay §4): sent now if the session is free, else queued until it is. */
|
|
2961
|
-
|
|
2990
|
+
z34.object({ type: z34.literal("session.relay"), qid: z34.string().min(1) }),
|
|
2962
2991
|
/** Takes the card's queued instruction back out of the queue. */
|
|
2963
|
-
|
|
2992
|
+
z34.object({ type: z34.literal("session.relay.cancel"), qid: z34.string().min(1) }),
|
|
2964
2993
|
/** The chat's generic card (action registry spec §5.1): applies its rows in order (all of them without `rows`), stopping at
|
|
2965
2994
|
* the first failure. `confirmed` says the front asked again; refused without it when a row is destructive. */
|
|
2966
|
-
|
|
2967
|
-
type:
|
|
2968
|
-
rid:
|
|
2969
|
-
qid:
|
|
2995
|
+
z34.object({
|
|
2996
|
+
type: z34.literal("chat.act"),
|
|
2997
|
+
rid: z34.string().min(1).max(100),
|
|
2998
|
+
qid: z34.string().min(1),
|
|
2970
2999
|
rows: launchRows.optional(),
|
|
2971
|
-
confirmed:
|
|
3000
|
+
confirmed: z34.literal(true).optional(),
|
|
2972
3001
|
/** « Refuser »: each row (session.decide only) answers its session's request with deny, whatever its own decision; never
|
|
2973
3002
|
* confirmed, and allowed on a request shown cut. The rows become `denied`. */
|
|
2974
|
-
deny:
|
|
3003
|
+
deny: z34.literal(true).optional()
|
|
2975
3004
|
}),
|
|
2976
3005
|
/** « Ignorer » the turn's cards, for every device and for Ledge (who is told at the next question); `undo` opens them
|
|
2977
3006
|
* again (« Revoir »). Refused while one of them is under way. Every client gets the turn's `ignoredAt` through chat.history. */
|
|
2978
|
-
|
|
3007
|
+
z34.object({ type: z34.literal("chat.ignore"), qid: z34.string().min(1), undo: z34.literal(true).optional() }),
|
|
2979
3008
|
/** 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. */
|
|
2980
|
-
|
|
2981
|
-
type:
|
|
2982
|
-
qid:
|
|
2983
|
-
item:
|
|
3009
|
+
z34.object({
|
|
3010
|
+
type: z34.literal("point.act"),
|
|
3011
|
+
qid: z34.string().min(1),
|
|
3012
|
+
item: z34.string().min(1).max(200),
|
|
2984
3013
|
answer: PointAnswerSchema.optional(),
|
|
2985
3014
|
/** Applies the row's suggestion instead of answering it (exactly one of `answer` and `suggest`). */
|
|
2986
|
-
suggest:
|
|
3015
|
+
suggest: z34.literal(true).optional(),
|
|
2987
3016
|
/** The front's confirmation of a destructive answer (an accepted request, a decision), as `chat.act` takes it. */
|
|
2988
|
-
confirmed:
|
|
3017
|
+
confirmed: z34.literal(true).optional()
|
|
2989
3018
|
}),
|
|
2990
|
-
|
|
2991
|
-
|
|
3019
|
+
z34.object({ type: z34.literal("point.later"), qid: z34.string().min(1) }),
|
|
3020
|
+
z34.object({ type: z34.literal("operator.read"), eventId: z34.number().int().min(0) }),
|
|
2992
3021
|
/** A registry action run outside the chat (#93, the CLI): the daemon resolves `args` as it does a generic card's row, then
|
|
2993
3022
|
* applies it through its own handler. `by` the session that asks, left out for the user; `confirmed` for a destructive one. */
|
|
2994
|
-
|
|
2995
|
-
type:
|
|
2996
|
-
rid:
|
|
2997
|
-
by:
|
|
3023
|
+
z34.object({
|
|
3024
|
+
type: z34.literal("action.run"),
|
|
3025
|
+
rid: z34.string().min(1).max(100),
|
|
3026
|
+
by: z34.string().min(1).optional(),
|
|
2998
3027
|
/** `by`'s key (LEDGE_SESSION_KEY) */
|
|
2999
|
-
key:
|
|
3028
|
+
key: z34.string().max(128).optional(),
|
|
3000
3029
|
action: ActionIdSchema,
|
|
3001
|
-
args:
|
|
3002
|
-
confirmed:
|
|
3030
|
+
args: z34.record(z34.unknown()),
|
|
3031
|
+
confirmed: z34.literal(true).optional()
|
|
3003
3032
|
}),
|
|
3004
3033
|
/** The chat's close card: closes the turn's sessions, `rows` (indexes into its `closes`) or all of them. */
|
|
3005
|
-
|
|
3034
|
+
z34.object({ type: z34.literal("session.close"), qid: z34.string().min(1), rows: launchRows.optional() }),
|
|
3006
3035
|
/** `always` and `note` only where the harness offers them (`offers`); a note goes with `deny`, for the agent to read. */
|
|
3007
|
-
|
|
3008
|
-
type:
|
|
3009
|
-
id:
|
|
3036
|
+
z34.object({
|
|
3037
|
+
type: z34.literal("session.decide"),
|
|
3038
|
+
id: z34.string(),
|
|
3010
3039
|
decision: DecisionSchema,
|
|
3011
|
-
note:
|
|
3040
|
+
note: z34.string().trim().min(1).max(NOTE_MAX).optional(),
|
|
3012
3041
|
/** 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.
|
|
3013
3042
|
* `key` (pendingKey) covers its whole content; older fronts send kind and text only. */
|
|
3014
|
-
expect: PendingSchema.pick({ kind: true, text: true }).extend({ key:
|
|
3043
|
+
expect: PendingSchema.pick({ kind: true, text: true }).extend({ key: z34.string().max(64).optional() }).optional(),
|
|
3015
3044
|
/** 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. */
|
|
3016
3045
|
by: DecidedBySchema.optional()
|
|
3017
3046
|
}),
|
|
3018
|
-
|
|
3019
|
-
|
|
3047
|
+
z34.object({ type: z34.literal("session.focus"), id: z34.string() }),
|
|
3048
|
+
z34.object({ type: z34.literal("session.kill"), id: z34.string() }),
|
|
3020
3049
|
/** `restoreQueue` (OMP): also take back what waits in its queue, returned as `session.queue.restored` to put in the draft. */
|
|
3021
|
-
|
|
3050
|
+
z34.object({ type: z34.literal("session.interrupt"), id: z34.string(), restoreQueue: z34.boolean().optional() }),
|
|
3051
|
+
SessionAsideAskSchema,
|
|
3022
3052
|
/** Removes a finished (exited) or read-only (hook_only) session from the list; refused for a live launcher session. */
|
|
3023
|
-
|
|
3053
|
+
z34.object({ type: z34.literal("session.dismiss"), id: z34.string() }),
|
|
3024
3054
|
/** Puts a session in the archive: it leaves the live list but is kept. */
|
|
3025
|
-
|
|
3055
|
+
z34.object({ type: z34.literal("session.archive"), id: z34.string() }),
|
|
3026
3056
|
/** Takes an archived session back out of the archive, as it was. */
|
|
3027
|
-
|
|
3057
|
+
z34.object({ type: z34.literal("session.restore"), id: z34.string() }),
|
|
3028
3058
|
/** Starts the agent again on an archived session's conversation. */
|
|
3029
|
-
|
|
3059
|
+
z34.object({ type: z34.literal("session.resume"), id: z34.string() }),
|
|
3030
3060
|
/** Changes a live session's model and effort (#58, lot 2), `null` for the agent's own default: the daemon restarts the
|
|
3031
3061
|
* agent on the same conversation with them, at once when the session is free, else at its next free moment. */
|
|
3032
|
-
|
|
3062
|
+
z34.object({ type: z34.literal("session.model"), id: z34.string(), model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
|
|
3033
3063
|
/** Deletes a session for good, archived or not. */
|
|
3034
|
-
|
|
3064
|
+
z34.object({ type: z34.literal("session.delete"), id: z34.string() }),
|
|
3035
3065
|
/** 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. */
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3066
|
+
z34.object({ type: z34.literal("session.rename"), id: z34.string(), topic: z34.string().max(500) }),
|
|
3067
|
+
/** A session's nickname set from the sidebar (`sessionLabel` in the daemon's info), trimmed; empty removes it. Its name, its
|
|
3068
|
+
* address, does not change. */
|
|
3069
|
+
z34.object({ type: z34.literal("session.label"), id: z34.string(), label: z34.string().max(200) }),
|
|
3070
|
+
z34.object({ type: z34.literal("session.thread"), id: z34.string() }),
|
|
3071
|
+
z34.object({ type: z34.literal("session.register"), session: SessionSchema }),
|
|
3039
3072
|
/** `agent` and `cwd` describe the session when the daemon does not know it yet (a hook from an agent started without ledge). */
|
|
3040
|
-
|
|
3041
|
-
type:
|
|
3042
|
-
id:
|
|
3073
|
+
z34.object({
|
|
3074
|
+
type: z34.literal("session.event"),
|
|
3075
|
+
id: z34.string(),
|
|
3043
3076
|
event: SessionEventSchema,
|
|
3044
3077
|
agent: ToolSchema.optional(),
|
|
3045
|
-
cwd:
|
|
3078
|
+
cwd: z34.string().optional(),
|
|
3046
3079
|
/** The OpenRig seat the agent runs in (`OPENRIG_SESSION_NAME`, `pod-member@rig`), when OpenRig launched it. */
|
|
3047
3080
|
rigSeat: RigSeatNameSchema.optional()
|
|
3048
3081
|
}),
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3082
|
+
z34.object({ type: z34.literal("session.unregister"), id: z34.string(), exitCode: z34.number().int().nullable() }),
|
|
3083
|
+
z34.object({ type: z34.literal("snapshot.request") }),
|
|
3084
|
+
z34.object({ type: z34.literal("chat.ask"), qid: z34.string().min(1), text: z34.string(), images: z34.array(ImageUploadSchema).max(ATTACHMENTS_MAX).optional(), tool: ToolSchema.optional() }),
|
|
3085
|
+
z34.object({ type: z34.literal("chat.cancel"), qid: z34.string().min(1) }),
|
|
3053
3086
|
/** Starts a new conversation with Ledge: the day's turns are cleared and the next question opens a new harness session. */
|
|
3054
|
-
|
|
3087
|
+
z34.object({ type: z34.literal("chat.reset") }),
|
|
3055
3088
|
/** Installs `@paradow/ledge@version` and restarts the service (spec 2026-10-12 auto-update §6). */
|
|
3056
|
-
|
|
3089
|
+
z34.object({ type: z34.literal("update.daemon"), version: z34.string().regex(SEMVER) }),
|
|
3057
3090
|
/** Replaces the daemon's machines list (first connected front wins); refused unless valid. */
|
|
3058
|
-
|
|
3091
|
+
z34.object({ type: z34.literal("machines.set"), machines: MachinesSchema }),
|
|
3059
3092
|
/** Replaces the local daemon's projects and rules as a whole; refused unless valid. */
|
|
3060
|
-
|
|
3093
|
+
z34.object({ type: z34.literal("projects.set"), projects: ProjectsSchema }),
|
|
3061
3094
|
/** Issue #16: one project's sessions' order (its id, or NO_PROJECT ''), as session keys (placeSessions); answered by `projects`. */
|
|
3062
|
-
|
|
3095
|
+
z34.object({ type: z34.literal("sessions.order"), project: z34.string().max(64), ids: z34.array(z34.string().min(1).max(300)).max(SESSION_ORDER_MAX) }),
|
|
3063
3096
|
/** Replaces the island's settings as a whole; refused unless valid. */
|
|
3064
|
-
|
|
3097
|
+
z34.object({ type: z34.literal("island.set"), prefs: IslandPrefsSchema }),
|
|
3065
3098
|
/** Mobile access (lot 3), local fronts only. A changed `relayUrl` drops the relay session. */
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3099
|
+
z34.object({ type: z34.literal("mobile.set"), enabled: z34.boolean(), relayUrl: RelayUrlSchema }),
|
|
3100
|
+
z34.object({ type: z34.literal("mobile.signin") }),
|
|
3101
|
+
z34.object({ type: z34.literal("mobile.signin.cancel") }),
|
|
3102
|
+
z34.object({ type: z34.literal("mobile.signout") }),
|
|
3070
3103
|
/** While the link is offline: try again now. */
|
|
3071
|
-
|
|
3104
|
+
z34.object({ type: z34.literal("mobile.retry") }),
|
|
3072
3105
|
/** `replaces`: an approved device this one takes the place of (the same app reinstalled), revoked once this one is stored. */
|
|
3073
|
-
|
|
3074
|
-
|
|
3106
|
+
z34.object({ type: z34.literal("mobile.pairing.approve"), id: z34.string().min(1).max(100), replaces: z34.string().min(1).max(100).optional() }),
|
|
3107
|
+
z34.object({ type: z34.literal("mobile.pairing.deny"), id: z34.string().min(1).max(100) }),
|
|
3075
3108
|
/** `id`: the device's fingerprint. */
|
|
3076
|
-
|
|
3109
|
+
z34.object({ type: z34.literal("mobile.device.revoke"), id: z34.string().min(1).max(100) }),
|
|
3077
3110
|
/** Names a device (`id`: its fingerprint); the device sees its new name in its next snapshot. */
|
|
3078
|
-
|
|
3111
|
+
z34.object({ type: z34.literal("mobile.device.rename"), id: z34.string().min(1).max(100), name: DeviceNameSchema }),
|
|
3079
3112
|
/** « Taper dans les terminaux depuis le téléphone »; turned off, every phone loses the hand. */
|
|
3080
|
-
|
|
3113
|
+
z34.object({ type: z34.literal("mobile.terminal"), input: z34.boolean() }),
|
|
3081
3114
|
/** « C'était bien moi » (`recovered`: its notice goes, the trace stays) or « Compris » (`refused`) on a device's row. */
|
|
3082
|
-
|
|
3115
|
+
z34.object({ type: z34.literal("mobile.device.ack"), id: z34.string().min(1).max(100), what: z34.enum(["recovered", "refused"]) }),
|
|
3083
3116
|
/** « Débloquer »: passkey recovery is taken again after 3 failed verifications. */
|
|
3084
|
-
|
|
3117
|
+
z34.object({ type: z34.literal("mobile.recovery.unblock") }),
|
|
3085
3118
|
/** « Reprendre la main »: the phone typing into the session's terminal goes back to reading it. */
|
|
3086
|
-
|
|
3119
|
+
z34.object({ type: z34.literal("terminal.release"), id: z34.string().min(1) }),
|
|
3087
3120
|
/** 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. */
|
|
3088
|
-
|
|
3121
|
+
z34.object({ type: z34.literal("session.message"), rid: z34.string().min(1), from: z34.string().min(1), to: z34.string().min(1), text: z34.string().min(1).max(MESSAGE_MAX), summary: z34.string().max(SUMMARY_MAX).optional(), intercept: z34.boolean().optional() }),
|
|
3089
3122
|
/** The user writing to every session of a project, or to several sessions (ids or names). */
|
|
3090
|
-
|
|
3091
|
-
type:
|
|
3092
|
-
rid:
|
|
3093
|
-
to:
|
|
3094
|
-
text:
|
|
3095
|
-
summary:
|
|
3123
|
+
z34.object({
|
|
3124
|
+
type: z34.literal("session.broadcast"),
|
|
3125
|
+
rid: z34.string().min(1).max(100),
|
|
3126
|
+
to: z34.union([z34.object({ project: z34.string().min(1).max(80) }), z34.object({ sessions: z34.array(z34.string().min(1)).min(1).max(BROADCAST_SESSIONS_MAX) })]),
|
|
3127
|
+
text: z34.string().trim().min(1).max(MESSAGE_MAX),
|
|
3128
|
+
summary: z34.string().max(SUMMARY_MAX).optional(),
|
|
3096
3129
|
/** How the recipients are told who it went to (« (à <label>) »), instead of the names: a project the fleet turned into sessions. */
|
|
3097
|
-
label:
|
|
3130
|
+
label: z34.string().min(1).max(BROADCAST_LABEL_MAX).optional()
|
|
3098
3131
|
}),
|
|
3099
3132
|
/** `ledge read <id>`: a message's whole body, for its receiver or its sender (`by`, a session id). */
|
|
3100
|
-
|
|
3133
|
+
z34.object({ type: z34.literal("message.read"), id: z34.string().min(1).max(40), by: z34.string().min(1) }),
|
|
3101
3134
|
TaskCmdSchema,
|
|
3102
3135
|
/** Reports (issue #9): the « Signaler » form's preview, creation and an agent's report ignored; `ledge report`. */
|
|
3103
3136
|
ReportPreviewSchema,
|
|
@@ -3123,111 +3156,111 @@ var ClientMessageSchema = z33.discriminatedUnion("type", [
|
|
|
3123
3156
|
]);
|
|
3124
3157
|
|
|
3125
3158
|
// ../../packages/protocol/src/relay.ts
|
|
3126
|
-
import { z as
|
|
3159
|
+
import { z as z35 } from "zod";
|
|
3127
3160
|
var SEALED_MAX = 1048576;
|
|
3128
|
-
var RelayPeerSchema =
|
|
3129
|
-
var RelayClientMessageSchema =
|
|
3130
|
-
type:
|
|
3161
|
+
var RelayPeerSchema = z35.union([z35.literal("pc"), z35.string().regex(/^d_[A-Za-z0-9_-]{16,40}$/)]);
|
|
3162
|
+
var RelayClientMessageSchema = z35.object({
|
|
3163
|
+
type: z35.literal("send"),
|
|
3131
3164
|
to: RelayPeerSchema,
|
|
3132
|
-
body:
|
|
3165
|
+
body: z35.string().max(SEALED_MAX)
|
|
3133
3166
|
});
|
|
3134
|
-
var RelayServerMessageSchema =
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3167
|
+
var RelayServerMessageSchema = z35.discriminatedUnion("type", [
|
|
3168
|
+
z35.object({ type: z35.literal("welcome"), accountId: z35.string(), self: RelayPeerSchema, online: z35.array(RelayPeerSchema) }),
|
|
3169
|
+
z35.object({ type: z35.literal("deliver"), from: RelayPeerSchema, body: z35.string() }),
|
|
3170
|
+
z35.object({ type: z35.literal("presence"), peer: RelayPeerSchema, online: z35.boolean() }),
|
|
3138
3171
|
/**
|
|
3139
3172
|
* A frame was refused; `to` names the target when it is known.
|
|
3140
3173
|
* Contract: an error concerning a sealed body (`offline`, `too_large`, or a socket closed with 4008
|
|
3141
3174
|
* `rate_limited`) means that body was not delivered, so the sequence on that channel is lost: the
|
|
3142
3175
|
* sender must re-handshake with that peer before sending to it again.
|
|
3143
3176
|
*/
|
|
3144
|
-
|
|
3145
|
-
type:
|
|
3146
|
-
code:
|
|
3177
|
+
z35.object({
|
|
3178
|
+
type: z35.literal("error"),
|
|
3179
|
+
code: z35.enum(["bad_frame", "too_large", "bad_target", "offline", "rate_limited"]),
|
|
3147
3180
|
to: RelayPeerSchema.optional()
|
|
3148
3181
|
})
|
|
3149
3182
|
]);
|
|
3150
3183
|
var PAIR_LABEL_MAX = 40;
|
|
3151
|
-
var KeyB64 =
|
|
3152
|
-
var Nonce =
|
|
3153
|
-
var Fingerprint =
|
|
3154
|
-
var B64U =
|
|
3155
|
-
var RecoverWhySchema =
|
|
3184
|
+
var KeyB64 = z35.string().regex(/^[A-Za-z0-9_-]{87}$/);
|
|
3185
|
+
var Nonce = z35.string().regex(/^[A-Za-z0-9_-]{43}$/);
|
|
3186
|
+
var Fingerprint = z35.string().regex(/^[A-Za-z0-9_-]{22}$/);
|
|
3187
|
+
var B64U = z35.string().regex(/^[A-Za-z0-9_-]*$/);
|
|
3188
|
+
var RecoverWhySchema = z35.enum(["none", "old", "offline", "otherPc", "timeout", "revoked", "connected", "rate", "blocked", "failed"]);
|
|
3156
3189
|
var RecoverRefusalSchema = RecoverWhySchema.extract(["revoked", "connected", "rate", "blocked", "failed"]);
|
|
3157
|
-
var ModelLabel =
|
|
3158
|
-
var RecoverAssertion =
|
|
3190
|
+
var ModelLabel = z35.string().trim().min(1).max(PAIR_LABEL_MAX);
|
|
3191
|
+
var RecoverAssertion = z35.object({
|
|
3159
3192
|
id: B64U.max(1366),
|
|
3160
3193
|
clientDataJSON: B64U.max(4096),
|
|
3161
3194
|
authenticatorData: B64U.max(4096),
|
|
3162
3195
|
signature: B64U.max(1024)
|
|
3163
3196
|
}).strict();
|
|
3164
|
-
var SealedFrameSchema =
|
|
3197
|
+
var SealedFrameSchema = z35.discriminatedUnion("k", [
|
|
3165
3198
|
/** `e` is the ephemeral key, `f` the fingerprint of the sender's static key. */
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3199
|
+
z35.object({ k: z35.literal("hello"), e: KeyB64, f: Fingerprint }),
|
|
3200
|
+
z35.object({ k: z35.literal("msg"), s: z35.string() }),
|
|
3201
|
+
z35.object({ k: z35.literal("pair_commit"), c: Nonce, label: z35.string().trim().min(1).max(PAIR_LABEL_MAX) }),
|
|
3202
|
+
z35.object({ k: z35.literal("pair_offer"), pc: KeyB64, n: Nonce }),
|
|
3203
|
+
z35.object({ k: z35.literal("pair_reveal"), d: KeyB64, n: Nonce }),
|
|
3204
|
+
z35.object({ k: z35.literal("pair_ok") }),
|
|
3205
|
+
z35.object({ k: z35.literal("pair_no") }),
|
|
3206
|
+
z35.object({ k: z35.literal("denied") }),
|
|
3207
|
+
z35.object({ k: z35.literal("rekey") }),
|
|
3175
3208
|
// ── Passkey recovery after a reinstall (unsealed, like pairing: nothing in them lets the relay act) ──
|
|
3176
3209
|
/** 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. */
|
|
3177
|
-
|
|
3210
|
+
z35.object({ k: z35.literal("recover_start"), d: KeyB64, n: Nonce, model: ModelLabel.optional() }),
|
|
3178
3211
|
/** PC → phone: its key `pc`, a one-use nonce `n` (60 s), and its name (`WSL`), for the phone's screens. */
|
|
3179
|
-
|
|
3212
|
+
z35.object({ k: z35.literal("recover_offer"), pc: KeyB64, n: Nonce, name: z35.string().max(PAIR_LABEL_MAX).optional() }),
|
|
3180
3213
|
/** Phone → PC: the discoverable assertion over `recoverChallenge(pc, d, pcNonce, n)`, and its `userHandle` (« L1 » ‖ digest ‖ random). */
|
|
3181
|
-
|
|
3214
|
+
z35.object({ k: z35.literal("recover_proof"), assertion: RecoverAssertion, userHandle: B64U.max(128) }),
|
|
3182
3215
|
/** PC → phone: the device is back under its new key; `name` the one it keeps. The phone pins the PC key, then says `hello`. */
|
|
3183
|
-
|
|
3216
|
+
z35.object({ k: z35.literal("recover_ok"), name: z35.string().max(PAIR_LABEL_MAX).optional() }),
|
|
3184
3217
|
/** PC → phone: refused. `device` the device the passkey names (`revoked`, `connected`); `revokedAt` when it was revoked (ISO,
|
|
3185
3218
|
* `revoked` within 90 days); `retryInMs` until a recovery is taken again (`rate`). */
|
|
3186
|
-
|
|
3187
|
-
k:
|
|
3219
|
+
z35.object({
|
|
3220
|
+
k: z35.literal("recover_no"),
|
|
3188
3221
|
why: RecoverRefusalSchema,
|
|
3189
|
-
device:
|
|
3190
|
-
revokedAt:
|
|
3191
|
-
retryInMs:
|
|
3222
|
+
device: z35.string().max(PAIR_LABEL_MAX).optional(),
|
|
3223
|
+
revokedAt: z35.string().datetime().optional(),
|
|
3224
|
+
retryInMs: z35.number().int().min(0).optional()
|
|
3192
3225
|
})
|
|
3193
3226
|
]);
|
|
3194
3227
|
|
|
3195
3228
|
// ../../packages/protocol/src/relayAuth.ts
|
|
3196
|
-
import { z as
|
|
3229
|
+
import { z as z36 } from "zod";
|
|
3197
3230
|
var RELAY_SESSION_COOKIE = "ledge_session";
|
|
3198
3231
|
var RELAY_CLOSE_SIGNED_OUT = 4001;
|
|
3199
3232
|
var RELAY_CLOSE_REPLACED = 4e3;
|
|
3200
3233
|
var RELAY_CLOSE_RATE_LIMITED = 4008;
|
|
3201
|
-
var DeviceStartResponseSchema =
|
|
3202
|
-
deviceCode:
|
|
3203
|
-
userCode:
|
|
3204
|
-
verificationUri:
|
|
3205
|
-
expiresIn:
|
|
3206
|
-
interval:
|
|
3207
|
-
});
|
|
3208
|
-
var DevicePollResponseSchema =
|
|
3209
|
-
|
|
3210
|
-
|
|
3234
|
+
var DeviceStartResponseSchema = z36.object({
|
|
3235
|
+
deviceCode: z36.string().min(1),
|
|
3236
|
+
userCode: z36.string().min(1),
|
|
3237
|
+
verificationUri: z36.string().min(1),
|
|
3238
|
+
expiresIn: z36.number().int().positive(),
|
|
3239
|
+
interval: z36.number().int().positive()
|
|
3240
|
+
});
|
|
3241
|
+
var DevicePollResponseSchema = z36.discriminatedUnion("status", [
|
|
3242
|
+
z36.object({ status: z36.literal("pending") }),
|
|
3243
|
+
z36.object({ status: z36.literal("slow_down"), interval: z36.number().int().positive() }),
|
|
3211
3244
|
/** `token` is the relay session token, shown this once only. */
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3245
|
+
z36.object({ status: z36.literal("ok"), token: z36.string().min(1), accountId: z36.string().min(1), login: z36.string().min(1) }),
|
|
3246
|
+
z36.object({ status: z36.literal("expired") }),
|
|
3247
|
+
z36.object({ status: z36.literal("denied") }),
|
|
3248
|
+
z36.object({ status: z36.literal("not_allowed") })
|
|
3216
3249
|
]);
|
|
3217
|
-
var DeviceRevokeResponseSchema =
|
|
3218
|
-
var MeResponseSchema =
|
|
3219
|
-
accountId:
|
|
3220
|
-
login:
|
|
3250
|
+
var DeviceRevokeResponseSchema = z36.object({ revoked: z36.number().int().min(0) });
|
|
3251
|
+
var MeResponseSchema = z36.object({
|
|
3252
|
+
accountId: z36.string().min(1),
|
|
3253
|
+
login: z36.string().min(1),
|
|
3221
3254
|
peer: RelayPeerSchema,
|
|
3222
|
-
kind:
|
|
3255
|
+
kind: z36.enum(["pc", "device"])
|
|
3223
3256
|
});
|
|
3224
3257
|
|
|
3225
3258
|
// ../../packages/protocol/src/phone.ts
|
|
3226
|
-
import { z as
|
|
3259
|
+
import { z as z40 } from "zod";
|
|
3227
3260
|
|
|
3228
3261
|
// ../../packages/protocol/src/push.ts
|
|
3229
|
-
import { z as
|
|
3230
|
-
var B64U2 =
|
|
3262
|
+
import { z as z37 } from "zod";
|
|
3263
|
+
var B64U2 = z37.string().regex(/^[A-Za-z0-9_-]*$/);
|
|
3231
3264
|
var PUSH_HOSTS = ["*.push.apple.com", "fcm.googleapis.com", "updates.push.services.mozilla.com", "*.notify.windows.com"];
|
|
3232
3265
|
function pushEndpointAllowed(url2) {
|
|
3233
3266
|
let u;
|
|
@@ -3244,43 +3277,43 @@ function pushEndpointAllowed(url2) {
|
|
|
3244
3277
|
return host.length > suffix.length && host.endsWith(suffix);
|
|
3245
3278
|
});
|
|
3246
3279
|
}
|
|
3247
|
-
var PushSendSchema =
|
|
3248
|
-
endpoint:
|
|
3280
|
+
var PushSendSchema = z37.object({
|
|
3281
|
+
endpoint: z37.string().url().max(1024),
|
|
3249
3282
|
body: B64U2.max(5462),
|
|
3250
|
-
ttl:
|
|
3251
|
-
urgency:
|
|
3252
|
-
topic:
|
|
3283
|
+
ttl: z37.number().int().min(0).max(86400),
|
|
3284
|
+
urgency: z37.enum(["normal", "high"]),
|
|
3285
|
+
topic: z37.string().regex(/^[A-Za-z0-9_-]{1,32}$/)
|
|
3253
3286
|
});
|
|
3254
|
-
var PushSendResultSchema =
|
|
3255
|
-
result:
|
|
3256
|
-
status:
|
|
3287
|
+
var PushSendResultSchema = z37.object({
|
|
3288
|
+
result: z37.enum(["sent", "gone", "failed"]),
|
|
3289
|
+
status: z37.number().int().optional()
|
|
3257
3290
|
});
|
|
3258
|
-
var PushSubscriptionSchema =
|
|
3259
|
-
endpoint:
|
|
3260
|
-
keys:
|
|
3291
|
+
var PushSubscriptionSchema = z37.object({
|
|
3292
|
+
endpoint: z37.string().url().max(1024).refine(pushEndpointAllowed),
|
|
3293
|
+
keys: z37.object({ p256dh: B64U2.length(87), auth: B64U2.length(22) })
|
|
3261
3294
|
});
|
|
3262
|
-
var PushPayloadSchema =
|
|
3263
|
-
v:
|
|
3295
|
+
var PushPayloadSchema = z37.object({
|
|
3296
|
+
v: z37.literal(1),
|
|
3264
3297
|
/** `resolved`: a request or question answered (anywhere), replacing its notification under the same tag; only sent to a
|
|
3265
3298
|
* device whose subscription says its service worker knows it (`push.subscribe` `resolved`). `point`: the operator's point, one per
|
|
3266
3299
|
* paired device (the body is its lead); it replaces `finished`, which stays in the schema for older daemons but is no longer sent. */
|
|
3267
|
-
kind:
|
|
3268
|
-
title:
|
|
3300
|
+
kind: z37.enum(["request", "question", "finished", "chat", "decision", "resolved", "point"]),
|
|
3301
|
+
title: z37.string().max(80),
|
|
3269
3302
|
/**
|
|
3270
3303
|
* Who the notification is about, so the phone writes its own title in its language (Q29): the session's name for `request`,
|
|
3271
3304
|
* `question` and `resolved`, the giver's for `decision`; none for `chat`. Optional: an older daemon sends none, and an
|
|
3272
3305
|
* older phone ignores it and shows `title`.
|
|
3273
3306
|
*/
|
|
3274
|
-
name:
|
|
3275
|
-
body:
|
|
3276
|
-
url:
|
|
3277
|
-
badge:
|
|
3278
|
-
tag:
|
|
3307
|
+
name: z37.string().max(100).optional(),
|
|
3308
|
+
body: z37.string().max(120),
|
|
3309
|
+
url: z37.string().regex(/^\/#\/[A-Za-z0-9/%._~-]*$/).max(300),
|
|
3310
|
+
badge: z37.number().int().min(0).max(999),
|
|
3311
|
+
tag: z37.string().regex(/^[A-Za-z0-9_-]{1,32}$/)
|
|
3279
3312
|
});
|
|
3280
3313
|
|
|
3281
3314
|
// ../../packages/protocol/src/phoneRigs.ts
|
|
3282
|
-
import { z as
|
|
3283
|
-
var PhoneRigErrorSchema =
|
|
3315
|
+
import { z as z38 } from "zod";
|
|
3316
|
+
var PhoneRigErrorSchema = z38.enum(["unknown_rig", "not_installed", "daemon_stopped", "unavailable"]);
|
|
3284
3317
|
var PHONE_RIG_TEXT_MAX = 500;
|
|
3285
3318
|
var PHONE_RIGS_MAX = 50;
|
|
3286
3319
|
var PHONE_RIG_SEATS_MAX = 200;
|
|
@@ -3290,79 +3323,80 @@ var PHONE_GOALS_MAX = 50;
|
|
|
3290
3323
|
var PhoneRigSchema = RigSchema.omit({ specPath: true }).extend({ nodes: RigSchema.shape.nodes.max(PHONE_RIG_SEATS_MAX) });
|
|
3291
3324
|
var PhoneOpenRigStateSchema = OpenRigStateSchema.extend({
|
|
3292
3325
|
daemon: OpenRigStateSchema.shape.daemon.omit({ message: true, pid: true }),
|
|
3293
|
-
rigs:
|
|
3326
|
+
rigs: z38.array(PhoneRigSchema).max(PHONE_RIGS_MAX)
|
|
3294
3327
|
});
|
|
3295
|
-
var PhoneRigQueueRowSchema = RigRowSchema.extend({ summary:
|
|
3296
|
-
var PhoneRigRoutingSchema = RigRoutingEntrySchema.extend({ summary:
|
|
3297
|
-
var PhoneRigPermissionSchema = RigSeatPermissionSchema.extend({ summary:
|
|
3328
|
+
var PhoneRigQueueRowSchema = RigRowSchema.extend({ summary: z38.string().max(PHONE_RIG_SUMMARY_MAX).optional() });
|
|
3329
|
+
var PhoneRigRoutingSchema = RigRoutingEntrySchema.extend({ summary: z38.string().max(PHONE_RIG_SUMMARY_MAX).optional() });
|
|
3330
|
+
var PhoneRigPermissionSchema = RigSeatPermissionSchema.extend({ summary: z38.string().max(PHONE_RIG_TEXT_MAX).optional(), error: z38.string().max(PHONE_RIG_TEXT_MAX).optional() });
|
|
3298
3331
|
var PhoneGoalSchema = GoalSchema;
|
|
3299
|
-
var RigSeatCountsSchema =
|
|
3300
|
-
var PhoneRigRejectedSchema =
|
|
3332
|
+
var RigSeatCountsSchema = z38.record(RigRoleSchema, z38.number().int().min(0).max(9));
|
|
3333
|
+
var PhoneRigRejectedSchema = z38.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]);
|
|
3301
3334
|
|
|
3302
3335
|
// ../../packages/protocol/src/phoneForge.ts
|
|
3303
|
-
import { z as
|
|
3336
|
+
import { z as z39 } from "zod";
|
|
3304
3337
|
var PHONE_FORGE_PRS_MAX = 100;
|
|
3305
3338
|
var PHONE_FORGE_FOLLOWED_MAX = 200;
|
|
3306
3339
|
var PHONE_FORGE_MESSAGE_MAX = 500;
|
|
3307
3340
|
var PhoneForgeStatusSchema = ForgeStatusSchema.omit({ message: true });
|
|
3308
|
-
var PhoneForgeErrorSchema =
|
|
3309
|
-
var PhoneForgeActErrorSchema =
|
|
3310
|
-
var PhoneForgeRejectedSchema =
|
|
3311
|
-
var PhoneForgeStateSchema =
|
|
3341
|
+
var PhoneForgeErrorSchema = z39.enum(["unavailable", "failed", "too_large"]);
|
|
3342
|
+
var PhoneForgeActErrorSchema = z39.enum(["stale", "busy", "not_offered", "unavailable", "failed"]);
|
|
3343
|
+
var PhoneForgeRejectedSchema = z39.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]);
|
|
3344
|
+
var PhoneForgeStateSchema = z39.object({
|
|
3312
3345
|
/** Newest change first. A request whose forge, state or pipeline an older phone does not know is dropped, not the message. */
|
|
3313
|
-
prs:
|
|
3314
|
-
forges:
|
|
3315
|
-
followed:
|
|
3346
|
+
prs: z39.preprocess(dropUnknownPrs, z39.array(PullRequestSchema).max(PHONE_FORGE_PRS_MAX)),
|
|
3347
|
+
forges: z39.preprocess(dropUnknownForges, z39.array(PhoneForgeStatusSchema).max(20)),
|
|
3348
|
+
followed: z39.preprocess(dropUnknownForges, z39.array(FollowedSessionSchema).max(PHONE_FORGE_FOLLOWED_MAX)),
|
|
3316
3349
|
/** The account's own requests no session follows (issue #3), newest change first; absent from an older daemon. */
|
|
3317
|
-
mine:
|
|
3350
|
+
mine: z39.preprocess(dropUnknownPrs, z39.array(PullRequestSchema).max(PHONE_FORGE_PRS_MAX)).optional()
|
|
3318
3351
|
});
|
|
3319
3352
|
|
|
3320
3353
|
// ../../packages/protocol/src/phone.ts
|
|
3321
3354
|
var PHONE_ROW_SUMMARY_MAX = 200;
|
|
3322
|
-
var PhoneRigRowSchema = RigRowSchema.extend({ summary:
|
|
3323
|
-
var PhoneRowErrorSchema =
|
|
3355
|
+
var PhoneRigRowSchema = RigRowSchema.extend({ summary: z40.string().max(PHONE_ROW_SUMMARY_MAX).optional() });
|
|
3356
|
+
var PhoneRowErrorSchema = z40.enum(["not_found", "unavailable"]);
|
|
3324
3357
|
var PHONE_PROTOCOL = 1;
|
|
3325
3358
|
var utf8 = new TextEncoder();
|
|
3326
3359
|
var THREAD_TEXT_MAX = 8192;
|
|
3327
3360
|
var TOOL_TEXT_MAX = 2048;
|
|
3328
3361
|
var CHECKLIST_TASKS_MAX = 50;
|
|
3329
3362
|
var CHECKLIST_TEXT_MAX = 200;
|
|
3330
|
-
var ChecklistStatusSchema =
|
|
3331
|
-
var PhoneChecklistSchema =
|
|
3332
|
-
tasks:
|
|
3333
|
-
done:
|
|
3334
|
-
total:
|
|
3335
|
-
cut:
|
|
3336
|
-
});
|
|
3337
|
-
var PhoneChecklistSummarySchema =
|
|
3338
|
-
done:
|
|
3339
|
-
total:
|
|
3340
|
-
current:
|
|
3341
|
-
cut:
|
|
3342
|
-
});
|
|
3343
|
-
var RiskSchema =
|
|
3344
|
-
var RiskReasonSchema =
|
|
3345
|
-
var OperationIdSchema =
|
|
3346
|
-
var OperationStatusSchema =
|
|
3347
|
-
var OperationReasonSchema =
|
|
3348
|
-
var CapabilitiesSchema =
|
|
3363
|
+
var ChecklistStatusSchema = z40.enum(["pending", "in_progress", "completed"]);
|
|
3364
|
+
var PhoneChecklistSchema = z40.object({
|
|
3365
|
+
tasks: z40.array(z40.object({ text: z40.string().max(CHECKLIST_TEXT_MAX), status: ChecklistStatusSchema })).max(CHECKLIST_TASKS_MAX),
|
|
3366
|
+
done: z40.number().int().nonnegative(),
|
|
3367
|
+
total: z40.number().int().nonnegative(),
|
|
3368
|
+
cut: z40.literal(true).optional()
|
|
3369
|
+
});
|
|
3370
|
+
var PhoneChecklistSummarySchema = z40.object({
|
|
3371
|
+
done: z40.number().int().nonnegative(),
|
|
3372
|
+
total: z40.number().int().nonnegative(),
|
|
3373
|
+
current: z40.string().max(CHECKLIST_TEXT_MAX).optional(),
|
|
3374
|
+
cut: z40.literal(true).optional()
|
|
3375
|
+
});
|
|
3376
|
+
var RiskSchema = z40.enum(["low", "high"]);
|
|
3377
|
+
var RiskReasonSchema = z40.enum(["question", "read_only_command", "edit_inside_folder", "pushes", "destroys", "deploys", "publishes", "pipes_to_shell", "network", "writes_outside_folder", "sensitive_path", "unsafe_flag", "shell_syntax", "script", "plan", "unknown"]);
|
|
3378
|
+
var OperationIdSchema = z40.string().uuid();
|
|
3379
|
+
var OperationStatusSchema = z40.enum(["received", "applied", "rejected", "failed"]);
|
|
3380
|
+
var OperationReasonSchema = z40.enum([...RefusalCodeSchema.options, "untypable", "confirm_required", "conflict", "assertion_invalid", "assertion_expired", "scheduled", "folder_taken", "not_found", "not_pending", ...ModelRefusalSchema.options]);
|
|
3381
|
+
var CapabilitiesSchema = z40.object({
|
|
3349
3382
|
/** A question can be answered in free text. */
|
|
3350
|
-
freeTextAnswer:
|
|
3383
|
+
freeTextAnswer: z40.boolean(),
|
|
3351
3384
|
/** The session's accept/deny can be typed; absent = true. */
|
|
3352
|
-
decide:
|
|
3385
|
+
decide: z40.boolean().optional(),
|
|
3353
3386
|
/** OMP's dialog questions can be answered from the phone; absent = false. */
|
|
3354
|
-
questions:
|
|
3387
|
+
questions: z40.boolean().optional()
|
|
3355
3388
|
});
|
|
3356
|
-
var CapabilitiesByToolSchema =
|
|
3357
|
-
var PhonePendingSchema = PendingSchema.extend({ key:
|
|
3358
|
-
var SwitchableSessionSchema = SessionSchema.extend({ canSwitch:
|
|
3359
|
-
var PhoneProjectSchema =
|
|
3360
|
-
var PhoneSessionOrderSchema =
|
|
3389
|
+
var CapabilitiesByToolSchema = z40.object({ claude: CapabilitiesSchema, codex: CapabilitiesSchema, cursor: CapabilitiesSchema, omp: CapabilitiesSchema });
|
|
3390
|
+
var PhonePendingSchema = PendingSchema.extend({ key: z40.string().max(64), risk: RiskSchema, riskReason: RiskReasonSchema, cut: z40.literal(true).optional() });
|
|
3391
|
+
var SwitchableSessionSchema = SessionSchema.extend({ canSwitch: z40.literal(true).optional() });
|
|
3392
|
+
var PhoneProjectSchema = z40.object({ id: ProjectIdSchema, name: z40.string().max(80), color: ProjectColorSchema });
|
|
3393
|
+
var PhoneSessionOrderSchema = z40.record(z40.string().max(64), z40.array(z40.string().max(200)).max(SESSION_ORDER_MAX));
|
|
3361
3394
|
var PHONE_PROJECTS_MAX = 100;
|
|
3362
3395
|
var PHONE_RIG_NAME_MAX = 100;
|
|
3363
3396
|
var PhoneSessionSchema = SwitchableSessionSchema.pick({
|
|
3364
3397
|
id: true,
|
|
3365
3398
|
name: true,
|
|
3399
|
+
label: true,
|
|
3366
3400
|
tool: true,
|
|
3367
3401
|
project: true,
|
|
3368
3402
|
title: true,
|
|
@@ -3392,110 +3426,110 @@ var PhoneSessionSchema = SwitchableSessionSchema.pick({
|
|
|
3392
3426
|
closedHow: true
|
|
3393
3427
|
}).extend({
|
|
3394
3428
|
/** What it is running now (« pnpm --filter desktop test »), `doingOf` on the PC: the list row and « En cours ». Older phones drop the field. */
|
|
3395
|
-
doing:
|
|
3429
|
+
doing: z40.object({ tool: z40.string().max(DOING_TOOL_MAX), label: z40.string().max(DOING_LABEL_MAX), since: z40.string().datetime() }).optional(),
|
|
3396
3430
|
pending: PhonePendingSchema.optional(),
|
|
3397
|
-
unread:
|
|
3398
|
-
handover:
|
|
3431
|
+
unread: z40.boolean(),
|
|
3432
|
+
handover: z40.object({ state: HandoverStateSchema, toName: z40.string().max(80).optional() }).strict().optional(),
|
|
3399
3433
|
/** Absent: the agent has no checklist. */
|
|
3400
3434
|
checklist: PhoneChecklistSummarySchema.optional(),
|
|
3401
3435
|
/** Started without Ledge (`hook_only`): the phone can neither close nor resume it. */
|
|
3402
|
-
readOnly:
|
|
3436
|
+
readOnly: z40.literal(true).optional(),
|
|
3403
3437
|
/** 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 »). */
|
|
3404
3438
|
projectId: ProjectIdSchema.optional(),
|
|
3405
3439
|
/** The OpenRig seat it is (`daemon.atelier`): its rig and its role once OpenRig named it. Never the seat's folder. */
|
|
3406
|
-
rig:
|
|
3440
|
+
rig: z40.object({ name: z40.string().max(PHONE_RIG_NAME_MAX), role: z40.string().max(PHONE_RIG_NAME_MAX).optional() }).optional()
|
|
3407
3441
|
});
|
|
3408
|
-
var B64U3 =
|
|
3409
|
-
var CredentialSchema =
|
|
3442
|
+
var B64U3 = z40.string().regex(/^[A-Za-z0-9_-]*$/);
|
|
3443
|
+
var CredentialSchema = z40.object({
|
|
3410
3444
|
id: B64U3.max(1366),
|
|
3411
3445
|
publicKey: B64U3.max(2048),
|
|
3412
|
-
alg:
|
|
3446
|
+
alg: z40.union([z40.literal(-7), z40.literal(-257)]),
|
|
3413
3447
|
clientDataJSON: B64U3.max(4096),
|
|
3414
3448
|
authenticatorData: B64U3.max(4096),
|
|
3415
|
-
transports:
|
|
3449
|
+
transports: z40.array(z40.string().max(20)).max(8).optional()
|
|
3416
3450
|
});
|
|
3417
|
-
var AssertionSchema =
|
|
3451
|
+
var AssertionSchema = z40.object({
|
|
3418
3452
|
id: B64U3.max(1366),
|
|
3419
3453
|
clientDataJSON: B64U3.max(4096),
|
|
3420
3454
|
authenticatorData: B64U3.max(4096),
|
|
3421
3455
|
signature: B64U3.max(1024)
|
|
3422
3456
|
});
|
|
3423
|
-
var ConfirmPurposeSchema =
|
|
3457
|
+
var ConfirmPurposeSchema = z40.enum(["register", "decide", "launch", "close", "act", "pc", "terminal", "rig", "note", "project", "folder", "rigs", "forge", "routine"]);
|
|
3424
3458
|
var PhoneChatStepSchema = ChatStepSchema.pick({ kind: true, id: true, name: true }).strict();
|
|
3425
|
-
var PhoneChatProposalSchema =
|
|
3426
|
-
project:
|
|
3459
|
+
var PhoneChatProposalSchema = z40.object({
|
|
3460
|
+
project: z40.string().max(80),
|
|
3427
3461
|
tool: ToolSchema,
|
|
3428
|
-
prompt:
|
|
3429
|
-
launchedId:
|
|
3430
|
-
failed:
|
|
3462
|
+
prompt: z40.string().max(TOOL_TEXT_MAX).optional(),
|
|
3463
|
+
launchedId: z40.string().optional(),
|
|
3464
|
+
failed: z40.literal(true).optional()
|
|
3431
3465
|
}).strict();
|
|
3432
|
-
var PhoneChatRelaySchema =
|
|
3433
|
-
id:
|
|
3434
|
-
name:
|
|
3466
|
+
var PhoneChatRelaySchema = z40.object({
|
|
3467
|
+
id: z40.string().min(1),
|
|
3468
|
+
name: z40.string(),
|
|
3435
3469
|
tool: ToolSchema,
|
|
3436
|
-
text:
|
|
3437
|
-
status:
|
|
3438
|
-
sentAt:
|
|
3439
|
-
failed:
|
|
3470
|
+
text: z40.string().max(TOOL_TEXT_MAX),
|
|
3471
|
+
status: z40.enum(["queued", "sent"]).optional(),
|
|
3472
|
+
sentAt: z40.string().datetime().optional(),
|
|
3473
|
+
failed: z40.literal(true).optional(),
|
|
3440
3474
|
/** With `failed`: why, as the PC's code (never its text). */
|
|
3441
|
-
code:
|
|
3475
|
+
code: z40.string().max(40).optional()
|
|
3442
3476
|
}).strict();
|
|
3443
|
-
var CloseHowSchema =
|
|
3444
|
-
var PhoneChatCloseSchema =
|
|
3445
|
-
id:
|
|
3446
|
-
name:
|
|
3477
|
+
var CloseHowSchema = z40.enum(["exit", "killed"]);
|
|
3478
|
+
var PhoneChatCloseSchema = z40.object({
|
|
3479
|
+
id: z40.string().min(1),
|
|
3480
|
+
name: z40.string(),
|
|
3447
3481
|
tool: ToolSchema,
|
|
3448
3482
|
how: CloseHowSchema.optional(),
|
|
3449
|
-
closedAt:
|
|
3450
|
-
failed:
|
|
3483
|
+
closedAt: z40.string().datetime().optional(),
|
|
3484
|
+
failed: z40.literal(true).optional()
|
|
3451
3485
|
}).strict();
|
|
3452
|
-
var PhoneChatTaskSchema =
|
|
3453
|
-
to:
|
|
3454
|
-
toName:
|
|
3455
|
-
title:
|
|
3456
|
-
text:
|
|
3457
|
-
taskId:
|
|
3458
|
-
ownerName:
|
|
3459
|
-
state:
|
|
3460
|
-
failed:
|
|
3486
|
+
var PhoneChatTaskSchema = z40.object({
|
|
3487
|
+
to: z40.string().max(80),
|
|
3488
|
+
toName: z40.string().max(80).optional(),
|
|
3489
|
+
title: z40.string().max(200),
|
|
3490
|
+
text: z40.string().max(TOOL_TEXT_MAX).optional(),
|
|
3491
|
+
taskId: z40.string().max(40).optional(),
|
|
3492
|
+
ownerName: z40.string().max(80).optional(),
|
|
3493
|
+
state: z40.enum(["open", "taken", "done", "refused", "dropped"]).optional(),
|
|
3494
|
+
failed: z40.literal(true).optional()
|
|
3461
3495
|
}).strict();
|
|
3462
|
-
var PhoneChatActionSchema =
|
|
3463
|
-
action:
|
|
3464
|
-
summary:
|
|
3496
|
+
var PhoneChatActionSchema = z40.object({
|
|
3497
|
+
action: z40.string().min(1).max(40),
|
|
3498
|
+
summary: z40.string().max(300),
|
|
3465
3499
|
vars: ActionVarsSchema.optional(),
|
|
3466
|
-
detail:
|
|
3467
|
-
detailCut:
|
|
3500
|
+
detail: z40.string().max(TOOL_TEXT_MAX).optional(),
|
|
3501
|
+
detailCut: z40.literal(true).optional(),
|
|
3468
3502
|
risk: ActionRiskSchema,
|
|
3469
|
-
session:
|
|
3503
|
+
session: z40.string().max(100).optional(),
|
|
3470
3504
|
state: ChatActionStateSchema.optional(),
|
|
3471
|
-
doneAt:
|
|
3472
|
-
code:
|
|
3505
|
+
doneAt: z40.string().datetime().optional(),
|
|
3506
|
+
code: z40.string().max(40).optional()
|
|
3473
3507
|
}).strict();
|
|
3474
|
-
var PhoneTaskSchema =
|
|
3475
|
-
id:
|
|
3476
|
-
title:
|
|
3477
|
-
owner:
|
|
3478
|
-
ownerName:
|
|
3508
|
+
var PhoneTaskSchema = z40.object({
|
|
3509
|
+
id: z40.string().max(40),
|
|
3510
|
+
title: z40.string().max(200),
|
|
3511
|
+
owner: z40.string().max(100),
|
|
3512
|
+
ownerName: z40.string().max(80),
|
|
3479
3513
|
/** 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). */
|
|
3480
|
-
giver:
|
|
3481
|
-
giverName:
|
|
3482
|
-
text:
|
|
3483
|
-
state:
|
|
3484
|
-
result:
|
|
3485
|
-
cut:
|
|
3486
|
-
at:
|
|
3487
|
-
updatedAt:
|
|
3488
|
-
seen:
|
|
3514
|
+
giver: z40.string().max(100).optional(),
|
|
3515
|
+
giverName: z40.string().max(80).optional(),
|
|
3516
|
+
text: z40.string().max(TOOL_TEXT_MAX).optional(),
|
|
3517
|
+
state: z40.enum(["open", "taken", "done", "refused", "dropped"]),
|
|
3518
|
+
result: z40.string().max(TOOL_TEXT_MAX).optional(),
|
|
3519
|
+
cut: z40.literal(true).optional(),
|
|
3520
|
+
at: z40.string(),
|
|
3521
|
+
updatedAt: z40.string(),
|
|
3522
|
+
seen: z40.literal(true).optional(),
|
|
3489
3523
|
/** A proposal about the user's notes (brain spec §3.6): the phone answers it with its buttons (`brain.answer`). */
|
|
3490
3524
|
brain: BrainProposalSchema.optional(),
|
|
3491
3525
|
/** A routine's item (routines spec): an activation request the phone answers with `routine.cmd` (`approve` / `refuse`), or a failure (`run`). */
|
|
3492
3526
|
routine: TaskRoutineSchema.optional()
|
|
3493
3527
|
}).strict();
|
|
3494
|
-
var PhoneRoutineRefSchema =
|
|
3528
|
+
var PhoneRoutineRefSchema = z40.object({ routine: RoutineIdSchema, routineKey: RoutineKeySchema }).strict();
|
|
3495
3529
|
var PhoneRoutineSchema = RoutineSchema.omit({ prompt: true, target: true, runs: true, proposal: true }).extend({
|
|
3496
|
-
target: RoutineTargetSchema.extend({ cwd:
|
|
3497
|
-
cut:
|
|
3498
|
-
proposed:
|
|
3530
|
+
target: RoutineTargetSchema.extend({ cwd: z40.string().min(1).max(PHONE_ROUTINE_CWD_MAX) }),
|
|
3531
|
+
cut: z40.literal(true).optional(),
|
|
3532
|
+
proposed: z40.literal(true).optional(),
|
|
3499
3533
|
key: RoutineKeySchema
|
|
3500
3534
|
});
|
|
3501
3535
|
var PhoneRoutineDetailSchema = PhoneRoutineSchema.omit({ cut: true, proposed: true }).extend({
|
|
@@ -3504,108 +3538,108 @@ var PhoneRoutineDetailSchema = PhoneRoutineSchema.omit({ cut: true, proposed: tr
|
|
|
3504
3538
|
proposal: RoutineSchema.shape.proposal,
|
|
3505
3539
|
runs: RoutineSchema.shape.runs
|
|
3506
3540
|
});
|
|
3507
|
-
var ChatErrorCodeSchema =
|
|
3508
|
-
var ChatLimitsReadSchema =
|
|
3509
|
-
var ChatConversationSummarySchema =
|
|
3510
|
-
id:
|
|
3511
|
-
startedAt:
|
|
3512
|
-
lastAt:
|
|
3513
|
-
first:
|
|
3514
|
-
count:
|
|
3541
|
+
var ChatErrorCodeSchema = z40.enum(["busy", "timeout", "cancelled", "failed"]);
|
|
3542
|
+
var ChatLimitsReadSchema = z40.object({ qid: OperationIdSchema, at: z40.string().datetime() }).strict();
|
|
3543
|
+
var ChatConversationSummarySchema = z40.object({
|
|
3544
|
+
id: z40.string().uuid(),
|
|
3545
|
+
startedAt: z40.string().datetime(),
|
|
3546
|
+
lastAt: z40.string().datetime(),
|
|
3547
|
+
first: z40.string().max(200),
|
|
3548
|
+
count: z40.number().int().min(1)
|
|
3515
3549
|
}).strict();
|
|
3516
|
-
var PhoneChatTurnSchema =
|
|
3550
|
+
var PhoneChatTurnSchema = z40.object({
|
|
3517
3551
|
qid: OperationIdSchema,
|
|
3518
|
-
question:
|
|
3519
|
-
askedAt:
|
|
3520
|
-
steps:
|
|
3521
|
-
answer:
|
|
3522
|
-
answeredAt:
|
|
3552
|
+
question: z40.string().max(MESSAGE_MAX),
|
|
3553
|
+
askedAt: z40.string().datetime(),
|
|
3554
|
+
steps: z40.array(PhoneChatStepSchema).max(50),
|
|
3555
|
+
answer: z40.string().max(THREAD_TEXT_MAX).optional(),
|
|
3556
|
+
answeredAt: z40.string().datetime().optional(),
|
|
3523
3557
|
error: ChatErrorCodeSchema.optional(),
|
|
3524
|
-
proposals:
|
|
3558
|
+
proposals: z40.array(PhoneChatProposalSchema).max(MAX_PROPOSALS).optional(),
|
|
3525
3559
|
relay: PhoneChatRelaySchema.optional(),
|
|
3526
|
-
closes:
|
|
3527
|
-
cut:
|
|
3528
|
-
tasks:
|
|
3529
|
-
actions:
|
|
3530
|
-
ignoredAt:
|
|
3531
|
-
attachments:
|
|
3532
|
-
by:
|
|
3560
|
+
closes: z40.array(PhoneChatCloseSchema).min(1).max(MAX_PROPOSALS).optional(),
|
|
3561
|
+
cut: z40.literal(true).optional(),
|
|
3562
|
+
tasks: z40.array(PhoneChatTaskSchema).min(1).max(MAX_PROPOSALS).optional(),
|
|
3563
|
+
actions: z40.array(PhoneChatActionSchema).min(1).max(MAX_PROPOSALS).optional(),
|
|
3564
|
+
ignoredAt: z40.string().datetime().optional(),
|
|
3565
|
+
attachments: z40.array(AttachmentRefSchema).max(ATTACHMENTS_MAX).optional(),
|
|
3566
|
+
by: z40.literal("ledge").optional(),
|
|
3533
3567
|
point: ChatPointSchema.optional()
|
|
3534
3568
|
}).strict();
|
|
3535
|
-
var sessionId =
|
|
3536
|
-
var PhoneExpectSchema = PendingSchema.pick({ kind: true, text: true }).extend({ key:
|
|
3537
|
-
var CardRowsSchema =
|
|
3569
|
+
var sessionId = z40.string().min(1).max(100);
|
|
3570
|
+
var PhoneExpectSchema = PendingSchema.pick({ kind: true, text: true }).extend({ key: z40.string().min(1).max(64) });
|
|
3571
|
+
var CardRowsSchema = z40.array(z40.number().int().min(0).max(MAX_PROPOSALS - 1)).min(1).max(MAX_PROPOSALS).refine((r) => new Set(r).size === r.length, "a row twice");
|
|
3538
3572
|
var pcOp = { op: OperationIdSchema, assertion: AssertionSchema.optional() };
|
|
3539
3573
|
var PHONE_LAUNCH_FOLDERS_MAX = 20;
|
|
3540
|
-
var PhoneLaunchSchema =
|
|
3574
|
+
var PhoneLaunchSchema = z40.object({
|
|
3541
3575
|
project: ProjectIdSchema,
|
|
3542
3576
|
tool: ToolSchema,
|
|
3543
|
-
folders:
|
|
3544
|
-
prompt:
|
|
3577
|
+
folders: z40.array(FolderPathSchema).min(1).max(PHONE_LAUNCH_FOLDERS_MAX),
|
|
3578
|
+
prompt: z40.string().trim().min(1).max(MESSAGE_MAX),
|
|
3545
3579
|
model: ModelIdSchema.optional(),
|
|
3546
3580
|
effort: EffortSchema.optional(),
|
|
3547
3581
|
approval: OmpApprovalSchema.optional(),
|
|
3548
3582
|
/** Issue #15: the session's name (its address), cleaned as every name; taken: refused `name_taken`. Absent: the first free one. */
|
|
3549
|
-
name:
|
|
3583
|
+
name: z40.string().max(200).optional()
|
|
3550
3584
|
}).strict();
|
|
3551
|
-
var PcActionSchema =
|
|
3585
|
+
var PcActionSchema = z40.enum(["update", "restart"]);
|
|
3552
3586
|
var PHONE_FOLDER_ENTRIES_MAX = 500;
|
|
3553
|
-
var PhoneFolderErrorSchema =
|
|
3554
|
-
var PhoneFolderSchema =
|
|
3587
|
+
var PhoneFolderErrorSchema = z40.enum(["not_found", "not_folder", "unreadable"]);
|
|
3588
|
+
var PhoneFolderSchema = z40.object({
|
|
3555
3589
|
machine: MachineIdSchema,
|
|
3556
|
-
label:
|
|
3590
|
+
label: z40.string().max(80).optional(),
|
|
3557
3591
|
path: FolderPathSchema,
|
|
3558
|
-
exists:
|
|
3559
|
-
branch:
|
|
3592
|
+
exists: z40.boolean().optional(),
|
|
3593
|
+
branch: z40.string().max(200).nullable().optional()
|
|
3560
3594
|
});
|
|
3561
3595
|
var PHONE_RECENT_FOLDERS_MAX = 20;
|
|
3562
|
-
var TerminalIdSchema =
|
|
3596
|
+
var TerminalIdSchema = z40.string().regex(/^t_[A-Za-z0-9_-]{8,40}$/);
|
|
3563
3597
|
var TERM_INPUT_MAX = 4096;
|
|
3564
3598
|
var TERM_SCREEN_MAX = 65536;
|
|
3565
3599
|
var TERM_OUTPUT_MAX = 32768;
|
|
3566
|
-
var TermDimSchema =
|
|
3567
|
-
var TermReleaseWhySchema =
|
|
3568
|
-
var TermExitWhySchema =
|
|
3569
|
-
var DevicePrefsSchema =
|
|
3570
|
-
notify:
|
|
3600
|
+
var TermDimSchema = z40.number().int().min(1).max(1e4);
|
|
3601
|
+
var TermReleaseWhySchema = z40.enum(["asked", "pc", "idle", "expired", "background", "link"]);
|
|
3602
|
+
var TermExitWhySchema = z40.enum(["ended", "gone", "closed", "superseded", "failed"]);
|
|
3603
|
+
var DevicePrefsSchema = z40.object({
|
|
3604
|
+
notify: z40.object({
|
|
3571
3605
|
/** « Le point de Ledge » (the key keeps its first name, « Agent terminé »): the operator's point. */
|
|
3572
|
-
finished:
|
|
3606
|
+
finished: z40.boolean(),
|
|
3573
3607
|
/** « Réponse de Ledge »: the end of a question asked from this device. */
|
|
3574
|
-
chat:
|
|
3608
|
+
chat: z40.boolean(),
|
|
3575
3609
|
/** « Décision à prendre »: a session puts a decision to the user. */
|
|
3576
|
-
decision:
|
|
3610
|
+
decision: z40.boolean()
|
|
3577
3611
|
}),
|
|
3578
3612
|
/** No notification before this moment (a `resolved` still replaces one already shown); null: no pause. */
|
|
3579
|
-
quietUntil:
|
|
3613
|
+
quietUntil: z40.string().datetime().nullable(),
|
|
3580
3614
|
/** The agent of this device's chat with Ledge; null: the PC's (the one its own chat last used). */
|
|
3581
3615
|
chatTool: ToolSchema.nullable()
|
|
3582
3616
|
});
|
|
3583
|
-
var PhoneClientMessageSchema =
|
|
3584
|
-
|
|
3585
|
-
|
|
3617
|
+
var PhoneClientMessageSchema = z40.discriminatedUnion("type", [
|
|
3618
|
+
z40.object({ type: z40.literal("snapshot.request") }),
|
|
3619
|
+
z40.object({ type: z40.literal("session.thread"), id: sessionId }),
|
|
3586
3620
|
/** The session's request with its whole body (up to `PENDING_BODY_MAX`). */
|
|
3587
|
-
|
|
3621
|
+
z40.object({ type: z40.literal("session.pending"), id: sessionId }),
|
|
3588
3622
|
/** The session whose terminal the phone shows; null when it shows none. */
|
|
3589
|
-
|
|
3590
|
-
|
|
3623
|
+
z40.object({ type: z40.literal("session.watch"), id: sessionId.nullable() }),
|
|
3624
|
+
z40.object({ type: z40.literal("session.read"), id: sessionId, at: z40.string().datetime() }),
|
|
3591
3625
|
/**
|
|
3592
3626
|
* Asks for a challenge. One object for every purpose: the gateway refuses a `decide` without `id` and `expect`. A `close`
|
|
3593
3627
|
* or `act` names a turn of the chat (`qid`) or a session (`id`, for `session.close` and `session.resume`).
|
|
3594
3628
|
*/
|
|
3595
|
-
|
|
3596
|
-
type:
|
|
3629
|
+
z40.object({
|
|
3630
|
+
type: z40.literal("confirm.prepare"),
|
|
3597
3631
|
purpose: ConfirmPurposeSchema,
|
|
3598
3632
|
id: sessionId.optional(),
|
|
3599
3633
|
expect: PhoneExpectSchema.optional(),
|
|
3600
3634
|
qid: OperationIdSchema.optional(),
|
|
3601
3635
|
/** A `pc` challenge: what it is for, and for an update the version it covers. */
|
|
3602
3636
|
action: PcActionSchema.optional(),
|
|
3603
|
-
version:
|
|
3637
|
+
version: z40.string().regex(SEMVER).optional(),
|
|
3604
3638
|
/** A `rig` challenge: the OpenRig row and the exact answer it covers. */
|
|
3605
|
-
qitem:
|
|
3639
|
+
qitem: z40.string().min(1).max(200).optional(),
|
|
3606
3640
|
answer: HumanAnswerSchema.optional(),
|
|
3607
3641
|
/** A `note` challenge: the proposal (a task) and the exact choice it covers. */
|
|
3608
|
-
task:
|
|
3642
|
+
task: z40.string().min(1).max(40).optional(),
|
|
3609
3643
|
choice: BrainChoiceSchema.optional(),
|
|
3610
3644
|
/** A `project` challenge: the project deleted and where its agents go (null: no project). */
|
|
3611
3645
|
project: ProjectIdSchema.optional(),
|
|
@@ -3616,76 +3650,76 @@ var PhoneClientMessageSchema = z39.discriminatedUnion("type", [
|
|
|
3616
3650
|
newProject: ProjectNameSchema.optional(),
|
|
3617
3651
|
/** A `rigs` challenge: the action (`rigAct`) or the change of seats (`rigSeats`) it covers, exactly as it will be sent. */
|
|
3618
3652
|
rigAct: OpenRigActionSchema.optional(),
|
|
3619
|
-
rigSeats:
|
|
3653
|
+
rigSeats: z40.object({ rig: RigNameSchema, seats: RigSeatCountsSchema }).strict().optional(),
|
|
3620
3654
|
/** An `act` challenge for a point row (`qid` and `item`): bound to that row and to its `pointAnswer`, or to its suggestion when `suggest`. */
|
|
3621
|
-
item:
|
|
3655
|
+
item: z40.string().min(1).max(200).optional(),
|
|
3622
3656
|
pointAnswer: PointAnswerSchema.optional(),
|
|
3623
|
-
suggest:
|
|
3657
|
+
suggest: z40.literal(true).optional(),
|
|
3624
3658
|
/** A `launch` challenge without `qid`: the « Nouvelle session » it covers, exactly as it will be sent. */
|
|
3625
3659
|
launch: PhoneLaunchSchema.optional(),
|
|
3626
3660
|
/** A `forge` challenge: the request and the action it covers, exactly as they will be sent. */
|
|
3627
|
-
forge:
|
|
3661
|
+
forge: z40.object({ prId: z40.string().min(1).max(500), action: ForgeActionSchema }).strict().optional(),
|
|
3628
3662
|
/** A `routine` challenge: the pending routine its « Activer » covers, and its key as the phone showed it; `routineOthers`, the
|
|
3629
3663
|
* other routines of a grouped request « Activer les N » covers with the same check. */
|
|
3630
3664
|
routine: RoutineIdSchema.optional(),
|
|
3631
3665
|
routineKey: RoutineKeySchema.optional(),
|
|
3632
|
-
routineOthers:
|
|
3666
|
+
routineOthers: z40.array(PhoneRoutineRefSchema).max(ROUTINES_ACTIVE_MAX - 1).optional()
|
|
3633
3667
|
}),
|
|
3634
3668
|
/** `userId`: the passkey's `user.id` as the phone made it (« L1 » ‖ the PC key's digest ‖ random, docs/mobile-passkey-recover-contract.md);
|
|
3635
3669
|
* given and made for this PC, the passkey can bring the device back after a reinstall (the snapshot's `device.recover`). */
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
type:
|
|
3670
|
+
z40.object({ type: z40.literal("credential.register"), op: OperationIdSchema, credential: CredentialSchema, userId: B64U3.max(128).optional() }),
|
|
3671
|
+
z40.object({
|
|
3672
|
+
type: z40.literal("session.decide"),
|
|
3639
3673
|
op: OperationIdSchema,
|
|
3640
3674
|
id: sessionId,
|
|
3641
3675
|
decision: DecisionSchema,
|
|
3642
|
-
note:
|
|
3676
|
+
note: z40.string().trim().min(1).max(NOTE_MAX).optional(),
|
|
3643
3677
|
/** The request the phone showed: refused unless it is still the pending one. */
|
|
3644
3678
|
expect: PhoneExpectSchema,
|
|
3645
3679
|
/** The device check over the challenge of `confirm.prepare`; required by the daemon for a high-risk accept. */
|
|
3646
3680
|
assertion: AssertionSchema.optional()
|
|
3647
3681
|
}),
|
|
3648
|
-
|
|
3649
|
-
type:
|
|
3682
|
+
z40.object({
|
|
3683
|
+
type: z40.literal("session.reply"),
|
|
3650
3684
|
op: OperationIdSchema,
|
|
3651
3685
|
id: sessionId,
|
|
3652
|
-
text:
|
|
3653
|
-
attachments:
|
|
3686
|
+
text: z40.string().max(MESSAGE_MAX),
|
|
3687
|
+
attachments: z40.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional(),
|
|
3654
3688
|
/** The request the reply answers, or null when the phone showed none: refused if the session's request is no longer that one. */
|
|
3655
3689
|
expect: PhoneExpectSchema.nullable(),
|
|
3656
3690
|
assertion: AssertionSchema.optional()
|
|
3657
3691
|
}),
|
|
3658
3692
|
/** OMP's `ask`: the answers to every question of the dialog `requestId`, in order; `cancel` declines it. Bounds as the local `session.answer`. */
|
|
3659
|
-
|
|
3660
|
-
type:
|
|
3693
|
+
z40.object({
|
|
3694
|
+
type: z40.literal("session.answer"),
|
|
3661
3695
|
op: OperationIdSchema,
|
|
3662
3696
|
id: sessionId,
|
|
3663
|
-
requestId:
|
|
3664
|
-
answers:
|
|
3665
|
-
cancel:
|
|
3697
|
+
requestId: z40.string().min(1).max(200),
|
|
3698
|
+
answers: z40.array(z40.object({ id: z40.string().max(200), selected: z40.array(z40.string().max(2e3)).max(100), text: z40.string().max(2e4).optional() })).max(50),
|
|
3699
|
+
cancel: z40.literal(true).optional(),
|
|
3666
3700
|
expect: PhoneExpectSchema
|
|
3667
3701
|
}),
|
|
3668
|
-
|
|
3702
|
+
z40.object({ type: z40.literal("session.interrupt"), op: OperationIdSchema, id: sessionId }),
|
|
3669
3703
|
/** Ends a live session as `/exit` would, killed as a last resort; answered with its `how`. Passkey, purpose `close`, over the session. */
|
|
3670
|
-
|
|
3704
|
+
z40.object({ type: z40.literal("session.close"), op: OperationIdSchema, id: sessionId, assertion: AssertionSchema.optional() }),
|
|
3671
3705
|
/** Starts an ended session again on its conversation. Passkey, purpose `act`, over the session. */
|
|
3672
|
-
|
|
3706
|
+
z40.object({ type: z40.literal("session.resume"), op: OperationIdSchema, id: sessionId, assertion: AssertionSchema.optional() }),
|
|
3673
3707
|
/** 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`. */
|
|
3674
|
-
|
|
3708
|
+
z40.object({ type: z40.literal("session.model"), op: OperationIdSchema, id: sessionId, model: ModelIdSchema.nullable(), effort: EffortSchema.nullable() }),
|
|
3675
3709
|
/** One message to several sessions (ids); answered by `operation.result` with `sent` and `refused`. */
|
|
3676
|
-
|
|
3710
|
+
z40.object({ type: z40.literal("session.broadcast"), op: OperationIdSchema, sessions: z40.array(sessionId).min(1).max(BROADCAST_SESSIONS_MAX), text: z40.string().trim().min(1).max(MESSAGE_MAX) }).strict(),
|
|
3677
3711
|
/** The models an agent offers on the PC. */
|
|
3678
|
-
|
|
3712
|
+
z40.object({ type: z40.literal("models.list"), tool: ToolSchema }),
|
|
3679
3713
|
/** The slash commands of a session's agent, for the « / » list of its field. */
|
|
3680
|
-
|
|
3714
|
+
z40.object({ type: z40.literal("session.commands"), id: sessionId }),
|
|
3681
3715
|
/** A queue row's state, for an OpenRig task card: asked while the card shows and every `RIG_ROW_REFRESH_MS` (`daemon.rigRows`). */
|
|
3682
|
-
|
|
3716
|
+
z40.object({ type: z40.literal("openrig.row"), qitem: QitemIdSchema }),
|
|
3683
3717
|
/** The phone drops its passkey from the daemon. */
|
|
3684
|
-
|
|
3718
|
+
z40.object({ type: z40.literal("device.forget"), op: OperationIdSchema }),
|
|
3685
3719
|
/** The device names itself (on the PC and in its next snapshot); applied to the sender only. */
|
|
3686
|
-
|
|
3720
|
+
z40.object({ type: z40.literal("device.rename"), op: OperationIdSchema, name: DeviceNameSchema }),
|
|
3687
3721
|
/** The device's own settings, whole (`daemon.settings`): applied to the sender only, told back in its next snapshot. */
|
|
3688
|
-
|
|
3722
|
+
z40.object({ type: z40.literal("device.prefs"), op: OperationIdSchema, prefs: z40.object({
|
|
3689
3723
|
notify: DevicePrefsSchema.shape.notify.strict(),
|
|
3690
3724
|
quietUntil: DevicePrefsSchema.shape.quietUntil,
|
|
3691
3725
|
chatTool: DevicePrefsSchema.shape.chatTool
|
|
@@ -3695,447 +3729,447 @@ var PhoneClientMessageSchema = z39.discriminatedUnion("type", [
|
|
|
3695
3729
|
* 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
|
|
3696
3730
|
* new project. A deletion carries the device's check over the project and `moveTo` (purpose `project`).
|
|
3697
3731
|
*/
|
|
3698
|
-
|
|
3699
|
-
|
|
3732
|
+
z40.object({ type: z40.literal("project.edit"), op: OperationIdSchema, id: ProjectIdSchema, name: ProjectNameSchema.optional(), color: ProjectColorSchema.optional() }).strict(),
|
|
3733
|
+
z40.object({ type: z40.literal("project.order"), op: OperationIdSchema, ids: z40.array(ProjectIdSchema).min(1).max(PHONE_PROJECTS_MAX) }).strict(),
|
|
3700
3734
|
/** 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
3735
|
* places (placeSessions). A session not in that project, or one gone, makes it stale. */
|
|
3702
|
-
|
|
3736
|
+
z40.object({ type: z40.literal("session.order"), op: OperationIdSchema, project: ProjectIdSchema.nullable(), ids: z40.array(z40.string().min(1).max(200)).min(1).max(SESSION_ORDER_MAX) }).strict(),
|
|
3703
3737
|
/** Issue #2: with its first folder (`path`, of this PC) and the device's check over that name and folder (`newProjectSubject`). A
|
|
3704
3738
|
* create without it, from an older phone, is refused `folder_required`. */
|
|
3705
|
-
|
|
3706
|
-
type:
|
|
3739
|
+
z40.object({
|
|
3740
|
+
type: z40.literal("project.create"),
|
|
3707
3741
|
op: OperationIdSchema,
|
|
3708
3742
|
name: ProjectNameSchema,
|
|
3709
3743
|
color: ProjectColorSchema,
|
|
3710
3744
|
path: FolderPathSchema.optional(),
|
|
3711
3745
|
assertion: AssertionSchema.optional()
|
|
3712
3746
|
}).strict(),
|
|
3713
|
-
|
|
3747
|
+
z40.object({ type: z40.literal("project.delete"), op: OperationIdSchema, id: ProjectIdSchema, moveTo: ProjectIdSchema.nullable(), assertion: AssertionSchema.optional() }).strict(),
|
|
3714
3748
|
/**
|
|
3715
3749
|
* A project's folders (`daemon.projectFolders`): browsing this PC's folders, its recent ones, a project's folders, then adding one
|
|
3716
3750
|
* of this PC (with the device's check, purpose `folder`) or removing one. Reads are answered to the asker alone.
|
|
3717
3751
|
*/
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3752
|
+
z40.object({ type: z40.literal("folder.list"), path: FolderPathSchema.optional() }).strict(),
|
|
3753
|
+
z40.object({ type: z40.literal("folder.recents") }).strict(),
|
|
3754
|
+
z40.object({ type: z40.literal("project.folders"), id: ProjectIdSchema }).strict(),
|
|
3755
|
+
z40.object({ type: z40.literal("project.folder.add"), op: OperationIdSchema, id: ProjectIdSchema, path: FolderPathSchema, assertion: AssertionSchema.optional() }).strict(),
|
|
3756
|
+
z40.object({ type: z40.literal("project.folder.remove"), op: OperationIdSchema, id: ProjectIdSchema, machine: MachineIdSchema, path: FolderPathSchema }).strict(),
|
|
3723
3757
|
/** « Contexte max », the PC's threshold shared by every front (`daemon.settings`): as the desktop's `context.set`. */
|
|
3724
|
-
|
|
3758
|
+
z40.object({ type: z40.literal("context.set"), op: OperationIdSchema, near: ContextPrefsSchema.shape.near }).strict(),
|
|
3725
3759
|
/** The phone's push subscription, with the VAPID key it was made with (so a key change is seen). `resolved`: its service
|
|
3726
3760
|
* worker shows a `resolved` push, which replaces a request's notification once it is answered elsewhere. */
|
|
3727
|
-
|
|
3728
|
-
|
|
3761
|
+
z40.object({ type: z40.literal("push.subscribe"), op: OperationIdSchema, subscription: PushSubscriptionSchema, key: B64U3.length(87), resolved: z40.literal(true).optional() }),
|
|
3762
|
+
z40.object({ type: z40.literal("push.unsubscribe"), op: OperationIdSchema }),
|
|
3729
3763
|
/** The phone's own chat with Ledge. */
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3764
|
+
z40.object({ type: z40.literal("chat.ask"), qid: OperationIdSchema, text: z40.string().trim().max(MESSAGE_MAX), attachments: z40.array(AttachmentIdSchema).max(ATTACHMENTS_MAX).optional() }),
|
|
3765
|
+
z40.object({ type: z40.literal("chat.cancel"), qid: OperationIdSchema }),
|
|
3766
|
+
z40.object({ type: z40.literal("chat.reset") }),
|
|
3767
|
+
z40.object({ type: z40.literal("chat.history") }),
|
|
3734
3768
|
/** The device's conversations, and one of them (`daemon.conversations`): answered to the asker alone. */
|
|
3735
|
-
|
|
3736
|
-
|
|
3769
|
+
z40.object({ type: z40.literal("chat.conversations") }).strict(),
|
|
3770
|
+
z40.object({ type: z40.literal("chat.conversation"), id: z40.string().uuid() }).strict(),
|
|
3737
3771
|
/** An image to store, sent alone before the message that names it; no `id`, and at most `ATTACHMENT_MAX` bytes. */
|
|
3738
|
-
AttachmentPutSchema.pick({ type: true, requestId: true }).extend({ image: ImageUploadSchema.extend({ data:
|
|
3772
|
+
AttachmentPutSchema.pick({ type: true, requestId: true }).extend({ image: ImageUploadSchema.extend({ data: z40.string().min(1).max(b64Max(ATTACHMENT_MAX)) }) }),
|
|
3739
3773
|
AttachmentGetSchema.pick({ type: true, requestId: true, attachment: true, preview: true }),
|
|
3740
|
-
|
|
3774
|
+
z40.object({ type: z40.literal("chat.relay"), op: OperationIdSchema, qid: OperationIdSchema }),
|
|
3741
3775
|
/** Takes the card's queued instruction back out of the queue, as the local `session.relay.cancel`. */
|
|
3742
|
-
|
|
3743
|
-
|
|
3776
|
+
z40.object({ type: z40.literal("chat.relay.cancel"), op: OperationIdSchema, qid: OperationIdSchema }),
|
|
3777
|
+
z40.object({ type: z40.literal("chat.launch"), op: OperationIdSchema, qid: OperationIdSchema, rows: CardRowsSchema.optional(), assertion: AssertionSchema.optional() }),
|
|
3744
3778
|
/** « Nouvelle session » (M2 §9): passkey, purpose `launch`, over this very launch. Applied, its result names the new session (`id`). */
|
|
3745
|
-
|
|
3746
|
-
|
|
3779
|
+
z40.object({ type: z40.literal("session.launch"), op: OperationIdSchema, launch: PhoneLaunchSchema, assertion: AssertionSchema.optional() }).strict(),
|
|
3780
|
+
z40.object({ type: z40.literal("chat.close"), op: OperationIdSchema, qid: OperationIdSchema, rows: CardRowsSchema.optional(), assertion: AssertionSchema.optional() }),
|
|
3747
3781
|
/** A row of the turn's task card: given by Ledge. */
|
|
3748
|
-
|
|
3782
|
+
z40.object({ type: z40.literal("chat.task"), op: OperationIdSchema, qid: OperationIdSchema, row: z40.number().int().min(0).max(MAX_PROPOSALS - 1) }),
|
|
3749
3783
|
/** Rows of the turn's generic card (action registry spec §5): `confirmed` as the local `chat.act`; a row whose action asks
|
|
3750
3784
|
* for a device check (`phone`) needs one assertion, purpose `act`, over the turn. */
|
|
3751
|
-
|
|
3752
|
-
type:
|
|
3785
|
+
z40.object({
|
|
3786
|
+
type: z40.literal("chat.act"),
|
|
3753
3787
|
op: OperationIdSchema,
|
|
3754
3788
|
qid: OperationIdSchema,
|
|
3755
3789
|
rows: CardRowsSchema.optional(),
|
|
3756
|
-
confirmed:
|
|
3790
|
+
confirmed: z40.literal(true).optional(),
|
|
3757
3791
|
assertion: AssertionSchema.optional(),
|
|
3758
3792
|
/** « Refuser », as the local `chat.act`: no passkey, no confirmation. */
|
|
3759
|
-
deny:
|
|
3793
|
+
deny: z40.literal(true).optional()
|
|
3760
3794
|
}),
|
|
3761
3795
|
/** « Ignorer » the turn's cards, or `undo` (« Revoir »), as the local `chat.ignore`. */
|
|
3762
|
-
|
|
3796
|
+
z40.object({ type: z40.literal("chat.ignore"), op: OperationIdSchema, qid: OperationIdSchema, undo: z40.literal(true).optional() }),
|
|
3763
3797
|
/** The operator's point: `point.act` answers a row, `point.later` sets the point aside, `operator.read` marks events read for this device. */
|
|
3764
|
-
|
|
3765
|
-
type:
|
|
3798
|
+
z40.object({
|
|
3799
|
+
type: z40.literal("point.act"),
|
|
3766
3800
|
op: OperationIdSchema,
|
|
3767
3801
|
qid: OperationIdSchema,
|
|
3768
|
-
item:
|
|
3802
|
+
item: z40.string().min(1).max(200),
|
|
3769
3803
|
answer: PointAnswerSchema.optional(),
|
|
3770
3804
|
/** Applies the row's suggestion instead of answering it (exactly one of `answer` and `suggest`). */
|
|
3771
|
-
suggest:
|
|
3805
|
+
suggest: z40.literal(true).optional(),
|
|
3772
3806
|
/** A destructive answer says it was confirmed on the phone; the device check (`assertion`) is bound to this item and this answer. */
|
|
3773
|
-
confirmed:
|
|
3807
|
+
confirmed: z40.literal(true).optional(),
|
|
3774
3808
|
assertion: AssertionSchema.optional()
|
|
3775
3809
|
}),
|
|
3776
|
-
|
|
3777
|
-
|
|
3810
|
+
z40.object({ type: z40.literal("point.later"), op: OperationIdSchema, qid: OperationIdSchema }),
|
|
3811
|
+
z40.object({ type: z40.literal("operator.read"), op: OperationIdSchema, eventId: z40.number().int().min(0) }),
|
|
3778
3812
|
/** 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
|
|
3779
3813
|
* task and that exact choice; a `no` needs none. */
|
|
3780
|
-
|
|
3814
|
+
z40.object({ type: z40.literal("brain.answer"), op: OperationIdSchema, task: z40.string().min(1).max(40), choice: BrainChoiceSchema, assertion: AssertionSchema.optional() }),
|
|
3781
3815
|
/** Puts a closed task Ledge gave away from « À traiter ». */
|
|
3782
|
-
|
|
3816
|
+
z40.object({ type: z40.literal("task.seen"), op: OperationIdSchema, task: z40.string().min(1).max(40) }),
|
|
3783
3817
|
/** The routines (routines spec §3.7): answered by `routines`, then each change comes as `routine.changed`. */
|
|
3784
|
-
|
|
3818
|
+
z40.object({ type: z40.literal("routine.list") }).strict(),
|
|
3785
3819
|
/** One routine whole, its prompt included: answered by `routine.detail`. The phone shows it before « Activer ». */
|
|
3786
|
-
|
|
3820
|
+
z40.object({ type: z40.literal("routine.show"), routine: RoutineIdSchema }).strict(),
|
|
3787
3821
|
/** « Lancer maintenant », « Pause » / « Reprendre », and « Activer » / « Refuser » from « À toi »; answered by `operation.result`.
|
|
3788
3822
|
* An `approve` names the key of the routine the phone showed (`routineKey`, refused as `stale` once it changed) and carries an
|
|
3789
3823
|
* assertion of purpose `routine` bound to that routine and that key. */
|
|
3790
|
-
|
|
3791
|
-
type:
|
|
3824
|
+
z40.object({
|
|
3825
|
+
type: z40.literal("routine.cmd"),
|
|
3792
3826
|
op: OperationIdSchema,
|
|
3793
3827
|
action: PhoneRoutineActionSchema,
|
|
3794
3828
|
routine: RoutineIdSchema,
|
|
3795
3829
|
routineKey: RoutineKeySchema.optional(),
|
|
3796
3830
|
/** « Activer les N » / « Refuser les N » of a grouped request: the other routines, each with the key the phone showed; an approve's
|
|
3797
3831
|
* one assertion covers them all. */
|
|
3798
|
-
others:
|
|
3832
|
+
others: z40.array(PhoneRoutineRefSchema).max(ROUTINES_ACTIVE_MAX - 1).optional(),
|
|
3799
3833
|
assertion: AssertionSchema.optional()
|
|
3800
3834
|
}).strict(),
|
|
3801
3835
|
/** Streams a session's pane, read-only; answered by `term.opened` or `operation.result` (rejected). `helper`: one of the
|
|
3802
3836
|
* session's subagents (`helpers[].id`), whose terminal is its parent's, read-only for good (`term.opened.readOnly`). */
|
|
3803
|
-
|
|
3837
|
+
z40.object({ type: z40.literal("term.open"), op: OperationIdSchema, id: sessionId, helper: z40.string().min(1).max(200).optional() }),
|
|
3804
3838
|
/** « Prendre la main »: passkey, purpose `terminal`, over the session; answered by `term.held` or `operation.result` (rejected). */
|
|
3805
|
-
|
|
3839
|
+
z40.object({ type: z40.literal("term.hold"), op: OperationIdSchema, tid: TerminalIdSchema, assertion: AssertionSchema.optional() }),
|
|
3806
3840
|
/** 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. */
|
|
3807
|
-
|
|
3841
|
+
z40.object({ type: z40.literal("term.input"), tid: TerminalIdSchema, n: z40.number().int().nonnegative(), data: z40.string().min(1).max(TERM_INPUT_MAX) }),
|
|
3808
3842
|
/** « Rendre la main »: back to read-only. */
|
|
3809
|
-
|
|
3843
|
+
z40.object({ type: z40.literal("term.release"), tid: TerminalIdSchema }),
|
|
3810
3844
|
/** The phone saw a gap in `seq`: a fresh `term.opened`, please. */
|
|
3811
|
-
|
|
3812
|
-
|
|
3845
|
+
z40.object({ type: z40.literal("term.resync"), tid: TerminalIdSchema }),
|
|
3846
|
+
z40.object({ type: z40.literal("term.close"), tid: TerminalIdSchema }),
|
|
3813
3847
|
/** Whether the phone's app is in front: a device that is visible gets no push. */
|
|
3814
|
-
|
|
3848
|
+
z40.object({ type: z40.literal("presence"), visible: z40.boolean() }),
|
|
3815
3849
|
/** « À toi » (lot 3): what OpenRig on this PC asks the person, then pushed whole when it changes (`openrig.asks`). */
|
|
3816
|
-
|
|
3850
|
+
z40.object({ type: z40.literal("openrig.asks") }),
|
|
3817
3851
|
/** 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
|
|
3818
3852
|
* answer; « Vu » (`seen`) needs none. */
|
|
3819
|
-
|
|
3853
|
+
z40.object({ type: z40.literal("openrig.answer"), op: OperationIdSchema, qitemId: z40.string().min(1).max(200), answer: HumanAnswerSchema, assertion: AssertionSchema.optional() }),
|
|
3820
3854
|
/** Installs `version` on the PC, then restarts its daemon; the phone asks for its own build's version. Passkey, purpose `pc`. */
|
|
3821
|
-
|
|
3855
|
+
z40.object({ type: z40.literal("daemon.update"), ...pcOp, version: z40.string().regex(SEMVER) }).strict(),
|
|
3822
3856
|
/** Restarts the PC's daemon without installing anything. Passkey, purpose `pc`. */
|
|
3823
|
-
|
|
3857
|
+
z40.object({ type: z40.literal("daemon.restart"), ...pcOp }).strict(),
|
|
3824
3858
|
// ── Rigs and the kernel (`daemon.rigs`, docs/mobile-openrig-contract.md) ──
|
|
3825
3859
|
/** OpenRig on this PC, answered by `rigs.state`, then each change, whole, while the phone follows. */
|
|
3826
|
-
|
|
3827
|
-
|
|
3860
|
+
z40.object({ type: z40.literal("rigs.state") }).strict(),
|
|
3861
|
+
z40.object({ type: z40.literal("rigs.graph"), rig: RigNameSchema }).strict(),
|
|
3828
3862
|
/** A rig's open rows and its recently closed ones. */
|
|
3829
|
-
|
|
3863
|
+
z40.object({ type: z40.literal("rigs.queue"), rig: RigNameSchema }).strict(),
|
|
3830
3864
|
/** The queue's routing on this PC: the latest claims, handoffs, blocks and closes, every rig. */
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3865
|
+
z40.object({ type: z40.literal("rigs.routing") }).strict(),
|
|
3866
|
+
z40.object({ type: z40.literal("rigs.permissions"), rig: RigNameSchema }).strict(),
|
|
3867
|
+
z40.object({ type: z40.literal("rigs.snapshots"), rig: RigNameSchema }).strict(),
|
|
3834
3868
|
/** The goals given to the operator, answered by `rigs.goals`, then each change, whole, while the phone follows. */
|
|
3835
|
-
|
|
3869
|
+
z40.object({ type: z40.literal("rigs.goals") }).strict(),
|
|
3836
3870
|
/** An action on OpenRig, every kind the Desktop's `openrig.act` takes. One that `rigActNeedsCheck` names carries a passkey, purpose `rigs`. */
|
|
3837
|
-
|
|
3871
|
+
z40.object({ type: z40.literal("rigs.act"), op: OperationIdSchema, action: OpenRigActionSchema, assertion: AssertionSchema.optional() }).strict(),
|
|
3838
3872
|
// ── Pull and merge requests (`daemon.forge`, docs/mobile-forge-contract.md) ──
|
|
3839
3873
|
/** The requests of this PC's sessions and seats; subscribes the device to each change. */
|
|
3840
|
-
|
|
3874
|
+
z40.object({ type: z40.literal("forge.state") }).strict(),
|
|
3841
3875
|
/** A request's detail; `log`: also that job's last lines. */
|
|
3842
|
-
|
|
3876
|
+
z40.object({ type: z40.literal("forge.detail"), prId: z40.string().min(1).max(500), log: z40.string().min(1).max(40).optional() }).strict(),
|
|
3843
3877
|
/** 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`). */
|
|
3844
|
-
|
|
3878
|
+
z40.object({ type: z40.literal("forge.act"), op: OperationIdSchema, prId: z40.string().min(1).max(500), action: ForgeActionSchema, assertion: AssertionSchema.optional() }).strict(),
|
|
3845
3879
|
/** A running rig's seats per role (the Desktop's `openrig.seats`). One that removes a seat carries a passkey, purpose `rigs`. */
|
|
3846
|
-
|
|
3880
|
+
z40.object({ type: z40.literal("rigs.seats"), op: OperationIdSchema, rig: RigNameSchema, seats: RigSeatCountsSchema, delegation: z40.enum(["pairs", "all"]).optional(), assertion: AssertionSchema.optional() }).strict(),
|
|
3847
3881
|
/** A goal to the operator (the Desktop's `openrig.goal.send`); `goalId` is the phone's, the same for a retry. */
|
|
3848
|
-
|
|
3882
|
+
z40.object({ type: z40.literal("rigs.goal.send"), op: OperationIdSchema, goalId: z40.string().regex(/^[A-Za-z0-9-]{8,64}$/), text: z40.string().trim().min(1).max(8e3), folder: z40.string().min(1).max(4096).optional() }).strict(),
|
|
3849
3883
|
/** 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. */
|
|
3850
|
-
|
|
3884
|
+
z40.object({ type: z40.literal("rigs.goal.reply"), op: OperationIdSchema, goalId: z40.string().regex(/^[A-Za-z0-9-]{8,64}$/), replyId: z40.string().regex(/^[A-Za-z0-9-]{8,64}$/), text: z40.string().trim().min(1).max(8e3) }).strict()
|
|
3851
3885
|
]);
|
|
3852
|
-
var PhoneModelChoiceSchema =
|
|
3886
|
+
var PhoneModelChoiceSchema = z40.object({
|
|
3853
3887
|
id: ModelChoiceSchema.shape.id.max(120),
|
|
3854
|
-
label:
|
|
3855
|
-
description:
|
|
3856
|
-
efforts:
|
|
3888
|
+
label: z40.string().max(80),
|
|
3889
|
+
description: z40.string().max(200).optional(),
|
|
3890
|
+
efforts: z40.array(EffortSchema).max(8).optional(),
|
|
3857
3891
|
defaultEffort: EffortSchema.optional(),
|
|
3858
|
-
isDefault:
|
|
3892
|
+
isDefault: z40.boolean().optional()
|
|
3859
3893
|
}).strict();
|
|
3860
3894
|
var PHONE_COMMANDS_MAX = 300;
|
|
3861
|
-
var PhoneSlashCommandSchema = SlashCommandSchema.extend({ description:
|
|
3895
|
+
var PhoneSlashCommandSchema = SlashCommandSchema.extend({ description: z40.string().max(200).optional() }).strict();
|
|
3862
3896
|
var PhoneHarnessUsageSchema = HarnessUsageSchema.omit({ account: true }).strict();
|
|
3863
|
-
var PhoneServerMessageSchema =
|
|
3897
|
+
var PhoneServerMessageSchema = z40.discriminatedUnion("type", [
|
|
3864
3898
|
/** This PC's harness limits (`daemon.usage`): after `snapshot.request`, then on each change, whole. `prefs.alert`: the PC's
|
|
3865
3899
|
* threshold, so the phone marks a window past it (amber, a line in « À toi ») and one reached (red). */
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
type:
|
|
3869
|
-
protocol:
|
|
3870
|
-
sessions:
|
|
3900
|
+
z40.object({ type: z40.literal("usage.state"), harnesses: z40.preprocess(dropUnknownHarnesses, z40.array(PhoneHarnessUsageSchema).max(4)), prefs: UsagePrefsSchema }),
|
|
3901
|
+
z40.object({
|
|
3902
|
+
type: z40.literal("snapshot"),
|
|
3903
|
+
protocol: z40.literal(PHONE_PROTOCOL),
|
|
3904
|
+
sessions: z40.array(PhoneSessionSchema),
|
|
3871
3905
|
capabilities: CapabilitiesByToolSchema,
|
|
3872
|
-
daemon:
|
|
3873
|
-
version:
|
|
3874
|
-
name:
|
|
3875
|
-
boot:
|
|
3906
|
+
daemon: z40.object({
|
|
3907
|
+
version: z40.string(),
|
|
3908
|
+
name: z40.string().max(40),
|
|
3909
|
+
boot: z40.string().uuid().optional(),
|
|
3876
3910
|
/** The daemon takes `session.model`. */
|
|
3877
|
-
models:
|
|
3911
|
+
models: z40.literal(true).optional(),
|
|
3878
3912
|
/** The daemon sends `session.checklist` and a session's `checklist` summary. */
|
|
3879
|
-
checklist:
|
|
3913
|
+
checklist: z40.literal(true).optional(),
|
|
3880
3914
|
/** `update`: the daemon can install a version and restart (npm, systemd); `restart`: it can restart (systemd). */
|
|
3881
|
-
update:
|
|
3882
|
-
restart:
|
|
3915
|
+
update: z40.literal(true).optional(),
|
|
3916
|
+
restart: z40.literal(true).optional(),
|
|
3883
3917
|
/** The daemon takes `session.close` and `session.resume`. */
|
|
3884
|
-
sessionClose:
|
|
3918
|
+
sessionClose: z40.literal(true).optional(),
|
|
3885
3919
|
/** The daemon streams a session's terminal (`term.open`). */
|
|
3886
|
-
terminal:
|
|
3920
|
+
terminal: z40.literal(true).optional(),
|
|
3887
3921
|
/** The PC lets a phone type into a terminal (`term.hold`): its setting is on. */
|
|
3888
|
-
terminalInput:
|
|
3922
|
+
terminalInput: z40.literal(true).optional(),
|
|
3889
3923
|
/** `term.open` takes `helper`: a subagent's terminal is its parent's, read-only for good. Absent (an older PC, which would drop
|
|
3890
3924
|
* `helper` and open the parent's pane as its own): the phone opens no subagent's terminal. */
|
|
3891
|
-
helperTerminal:
|
|
3925
|
+
helperTerminal: z40.literal(true).optional(),
|
|
3892
3926
|
/** The daemon answers `session.commands`. */
|
|
3893
|
-
commands:
|
|
3927
|
+
commands: z40.literal(true).optional(),
|
|
3894
3928
|
/** The daemon answers `openrig.row`. */
|
|
3895
|
-
rigRows:
|
|
3929
|
+
rigRows: z40.literal(true).optional(),
|
|
3896
3930
|
/** The daemon answers `openrig.asks` and `openrig.answer` (« À toi »). */
|
|
3897
|
-
openrig:
|
|
3931
|
+
openrig: z40.literal(true).optional(),
|
|
3898
3932
|
/** The daemon takes `session.broadcast` (« Écrire au groupe »). */
|
|
3899
|
-
broadcast:
|
|
3933
|
+
broadcast: z40.literal(true).optional(),
|
|
3900
3934
|
/** The daemon answers `folder.list`, `folder.recents` and `project.folders`, and takes `project.folder.add` and `.remove`. */
|
|
3901
|
-
projectFolders:
|
|
3935
|
+
projectFolders: z40.literal(true).optional(),
|
|
3902
3936
|
/** The daemon takes `project.edit`, `project.order`, `project.create` and `project.delete` (Réglages › Projets). */
|
|
3903
|
-
projectEdit:
|
|
3937
|
+
projectEdit: z40.literal(true).optional(),
|
|
3904
3938
|
/** Issue #16: the snapshot and `projects` carry `sessionOrder`, and the daemon takes `session.order`. */
|
|
3905
|
-
sessionOrder:
|
|
3939
|
+
sessionOrder: z40.literal(true).optional(),
|
|
3906
3940
|
/** The daemon takes `device.prefs` and `context.set` (the phone's Réglages); the device then carries its `prefs`. */
|
|
3907
|
-
settings:
|
|
3941
|
+
settings: z40.literal(true).optional(),
|
|
3908
3942
|
/** The daemon sends `usage.state` (its harnesses' limits). */
|
|
3909
|
-
usage:
|
|
3943
|
+
usage: z40.literal(true).optional(),
|
|
3910
3944
|
/** The Atelier: the snapshot carries `projects`, each session its `projectId` and `rig`, and `projects` follows each change. Absent (an older PC): no Atelier. */
|
|
3911
|
-
atelier:
|
|
3945
|
+
atelier: z40.literal(true).optional(),
|
|
3912
3946
|
/** 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 ». */
|
|
3913
|
-
rigs:
|
|
3947
|
+
rigs: z40.literal(true).optional(),
|
|
3914
3948
|
/** « Nouvelle session »: the daemon takes `session.launch` and `project.folders` carries this PC's folders' branch. Absent (an older PC): « Nouvelle » cannot start. */
|
|
3915
|
-
launch:
|
|
3949
|
+
launch: z40.literal(true).optional(),
|
|
3916
3950
|
/** 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 ». */
|
|
3917
|
-
forge:
|
|
3951
|
+
forge: z40.literal(true).optional(),
|
|
3918
3952
|
/** The device's conversations are kept 7 days (M3 Q33): the daemon answers `chat.conversations` and `chat.conversation`, and
|
|
3919
3953
|
* `chat.reset` puts the conversation away. Absent (an older PC): « Nouvelle conversation » forgets it. */
|
|
3920
|
-
conversations:
|
|
3954
|
+
conversations: z40.literal(true).optional()
|
|
3921
3955
|
}),
|
|
3922
3956
|
/** The user's projects (`daemon.atelier`), whole, in their order: absent from an older PC's snapshot. */
|
|
3923
|
-
projects:
|
|
3957
|
+
projects: z40.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX).optional(),
|
|
3924
3958
|
sessionOrder: PhoneSessionOrderSchema.optional(),
|
|
3925
|
-
device:
|
|
3926
|
-
confirm:
|
|
3959
|
+
device: z40.object({
|
|
3960
|
+
confirm: z40.boolean(),
|
|
3927
3961
|
/** Its passkey can bring it back after a reinstall: without it, « Mettre à jour la passkey ». */
|
|
3928
|
-
recover:
|
|
3929
|
-
push:
|
|
3930
|
-
chat:
|
|
3962
|
+
recover: z40.literal(true).optional(),
|
|
3963
|
+
push: z40.enum(["on", "off", "stale", "unavailable"]).optional(),
|
|
3964
|
+
chat: z40.literal(true).optional(),
|
|
3931
3965
|
contextNear: ContextPrefsSchema.shape.near.optional(),
|
|
3932
3966
|
/** This device's id (its fingerprint, as decisions name it in `by`), its kind, and the name the user gave it (absent: none given). */
|
|
3933
|
-
id:
|
|
3967
|
+
id: z40.string().optional(),
|
|
3934
3968
|
kind: DeviceKindSchema.optional(),
|
|
3935
|
-
name:
|
|
3969
|
+
name: z40.string().optional(),
|
|
3936
3970
|
/** This device's own settings (`daemon.settings`). */
|
|
3937
3971
|
prefs: DevicePrefsSchema.optional()
|
|
3938
3972
|
}).optional()
|
|
3939
3973
|
}),
|
|
3940
3974
|
/** « À toi » on this PC: the answer to `openrig.asks`, then each change, whole. */
|
|
3941
|
-
|
|
3975
|
+
z40.object({ type: z40.literal("openrig.asks"), channel: HumanChannelSchema, asks: z40.array(HumanAskSchema), partial: z40.literal(true).optional(), truncated: z40.literal(true).optional() }),
|
|
3942
3976
|
/** An answer's end, as on the desktop (`openrig.answered`), under the phone's `op`. `rejected`: the device check refused it (`reason`). */
|
|
3943
|
-
|
|
3944
|
-
type:
|
|
3977
|
+
z40.object({
|
|
3978
|
+
type: z40.literal("openrig.answered"),
|
|
3945
3979
|
op: OperationIdSchema,
|
|
3946
|
-
qitemId:
|
|
3947
|
-
ok:
|
|
3948
|
-
outcome:
|
|
3949
|
-
remaining:
|
|
3950
|
-
replyId:
|
|
3980
|
+
qitemId: z40.string(),
|
|
3981
|
+
ok: z40.boolean(),
|
|
3982
|
+
outcome: z40.enum(["recorded", "answered", "already"]).optional(),
|
|
3983
|
+
remaining: z40.array(z40.string()).optional(),
|
|
3984
|
+
replyId: z40.string().optional(),
|
|
3951
3985
|
error: HumanAnswerErrorSchema.optional(),
|
|
3952
|
-
message:
|
|
3953
|
-
rejected:
|
|
3986
|
+
message: z40.string().max(500).optional(),
|
|
3987
|
+
rejected: z40.enum(["confirm_required", "assertion_invalid", "assertion_expired", "unavailable"]).optional()
|
|
3954
3988
|
}),
|
|
3955
|
-
|
|
3956
|
-
|
|
3989
|
+
z40.object({ type: z40.literal("confirm.challenge"), purpose: ConfirmPurposeSchema, challenge: B64U3.max(64), rpId: z40.string().max(253), credentialId: B64U3.max(1366).optional(), expiresInMs: z40.number().int().positive() }),
|
|
3990
|
+
z40.object({ type: z40.literal("session.updated"), session: PhoneSessionSchema }),
|
|
3957
3991
|
/** The user's projects changed (a name, a colour, one added or removed, the order) (`daemon.atelier`): the list, whole. A session placed
|
|
3958
3992
|
* elsewhere by the change follows as its own `session.updated`, after this. */
|
|
3959
|
-
|
|
3960
|
-
|
|
3993
|
+
z40.object({ type: z40.literal("projects"), projects: z40.array(PhoneProjectSchema).max(PHONE_PROJECTS_MAX), sessionOrder: PhoneSessionOrderSchema.optional() }),
|
|
3994
|
+
z40.object({ type: z40.literal("session.removed"), id: z40.string() }),
|
|
3961
3995
|
/** A session's checklist, sent to the phone that watches it; `null`: it has none (any more). */
|
|
3962
|
-
|
|
3996
|
+
z40.object({ type: z40.literal("session.checklist"), id: z40.string(), checklist: PhoneChecklistSchema.nullable() }),
|
|
3963
3997
|
/** `pending.cut` is set when even this body was shortened. */
|
|
3964
|
-
|
|
3965
|
-
|
|
3998
|
+
z40.object({ type: z40.literal("session.pending"), id: z40.string(), pending: PhonePendingSchema }),
|
|
3999
|
+
z40.object({ type: z40.literal("session.preview"), id: z40.string(), lines: z40.array(z40.string()) }),
|
|
3966
4000
|
/** `cut`: the ids of the items shortened; `more`: older items were left out. */
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
type:
|
|
4001
|
+
z40.object({ type: z40.literal("session.thread"), id: z40.string(), items: z40.array(ThreadItemSchema), cut: z40.array(z40.string()), more: z40.boolean() }),
|
|
4002
|
+
z40.object({ type: z40.literal("session.thread.item"), id: z40.string(), item: ThreadItemSchema, cut: z40.literal(true).optional() }),
|
|
4003
|
+
z40.object({
|
|
4004
|
+
type: z40.literal("operation.result"),
|
|
3971
4005
|
op: OperationIdSchema,
|
|
3972
4006
|
status: OperationStatusSchema,
|
|
3973
4007
|
reason: OperationReasonSchema.optional(),
|
|
3974
4008
|
/** How an applied `session.close` ended the agent: `killed` when it had to be forced. */
|
|
3975
4009
|
how: CloseHowSchema.optional(),
|
|
3976
4010
|
/** An applied `session.launch`: the new session, whose thread the phone opens. */
|
|
3977
|
-
id:
|
|
4011
|
+
id: z40.string().max(200).optional(),
|
|
3978
4012
|
/** An applied `session.broadcast`: the names that got it and those that did not. */
|
|
3979
|
-
sent:
|
|
3980
|
-
refused:
|
|
4013
|
+
sent: z40.array(z40.string().max(100)).max(BROADCAST_SESSIONS_MAX).optional(),
|
|
4014
|
+
refused: z40.array(z40.object({ name: z40.string().max(100), reason: z40.string().max(200) })).max(BROADCAST_SESSIONS_MAX).optional()
|
|
3981
4015
|
}),
|
|
3982
4016
|
/** The models an agent offers; `error`: it could not be asked, `models` is then what Ledge knows without it. */
|
|
3983
|
-
|
|
4017
|
+
z40.object({ type: z40.literal("models.listing"), tool: ToolSchema, models: z40.array(PhoneModelChoiceSchema).max(40), error: z40.literal(true).optional() }),
|
|
3984
4018
|
/** A model change that was accepted and then failed (the agent could not restart). */
|
|
3985
|
-
|
|
4019
|
+
z40.object({ type: z40.literal("session.model.failed"), id: z40.string(), reason: ModelRefusalSchema }),
|
|
3986
4020
|
/** 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. */
|
|
3987
|
-
|
|
4021
|
+
z40.object({ type: z40.literal("session.commands.listing"), id: z40.string(), commands: z40.array(PhoneSlashCommandSchema).max(PHONE_COMMANDS_MAX), error: z40.literal(true).optional() }),
|
|
3988
4022
|
/** A queue row's state, answering `openrig.row`: `row`, or `error`. */
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
4023
|
+
z40.object({ type: z40.literal("openrig.rowState"), qitem: z40.string(), row: PhoneRigRowSchema.optional(), error: PhoneRowErrorSchema.optional() }),
|
|
4024
|
+
z40.object({ type: z40.literal("chat.history"), turns: z40.array(PhoneChatTurnSchema).max(50) }),
|
|
4025
|
+
z40.object({ type: z40.literal("chat.step"), qid: OperationIdSchema, step: PhoneChatStepSchema }),
|
|
3992
4026
|
/** The whole text so far, not an increment. */
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
4027
|
+
z40.object({ type: z40.literal("chat.delta"), qid: OperationIdSchema, text: z40.string().max(THREAD_TEXT_MAX) }),
|
|
4028
|
+
z40.object({ type: z40.literal("chat.done"), qid: OperationIdSchema, turn: PhoneChatTurnSchema }),
|
|
4029
|
+
z40.object({ type: z40.literal("chat.error"), qid: OperationIdSchema, code: ChatErrorCodeSchema }),
|
|
3996
4030
|
/** The current conversation's answers that read the account limits, and when (M3 Q31): a phone shows the limits under each. Sent after a
|
|
3997
4031
|
* `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. */
|
|
3998
|
-
|
|
4032
|
+
z40.object({ type: z40.literal("chat.limits"), reads: z40.array(ChatLimitsReadSchema).max(50) }),
|
|
3999
4033
|
/** The device's conversations (M3 Q33): the current one once it has a question, and the ones put away, the most recent first. */
|
|
4000
|
-
|
|
4034
|
+
z40.object({ type: z40.literal("chat.conversations"), current: ChatConversationSummarySchema.optional(), past: z40.array(ChatConversationSummarySchema).max(200) }),
|
|
4001
4035
|
/** One conversation, read-only, as `chat.history` gives its turns (`limits` as `chat.limits`); `error`: it is no longer kept. */
|
|
4002
|
-
|
|
4003
|
-
type:
|
|
4004
|
-
id:
|
|
4005
|
-
turns:
|
|
4006
|
-
limits:
|
|
4007
|
-
error:
|
|
4036
|
+
z40.object({
|
|
4037
|
+
type: z40.literal("chat.conversation"),
|
|
4038
|
+
id: z40.string().uuid(),
|
|
4039
|
+
turns: z40.array(PhoneChatTurnSchema).max(50).optional(),
|
|
4040
|
+
limits: z40.array(ChatLimitsReadSchema).max(50).optional(),
|
|
4041
|
+
error: z40.literal("unknown").optional()
|
|
4008
4042
|
}),
|
|
4009
4043
|
/** The daemon updating or restarting itself, whoever asked: npm runs, then the service restarts (the link drops right after). */
|
|
4010
|
-
|
|
4044
|
+
z40.object({ type: z40.literal("daemon.progress"), version: z40.string().max(40), step: z40.enum(["installing", "restarting"]) }),
|
|
4011
4045
|
/** Nothing was changed. Never npm's output nor a command: both hold the PC's paths. */
|
|
4012
|
-
|
|
4046
|
+
z40.object({ type: z40.literal("daemon.failed"), version: z40.string().max(40), reason: UpdateFailureSchema }),
|
|
4013
4047
|
/** The tasks Ledge gave, open or closed lately, after each snapshot; then each change. */
|
|
4014
|
-
|
|
4015
|
-
|
|
4048
|
+
z40.object({ type: z40.literal("tasks"), tasks: z40.array(PhoneTaskSchema).max(200) }),
|
|
4049
|
+
z40.object({ type: z40.literal("task.updated"), task: PhoneTaskSchema }),
|
|
4016
4050
|
/** The routines, newest first, without their prompt (the phone's list is read-only); then each change, or `removed` (its id). */
|
|
4017
4051
|
// Not strict, as every routine schema: a newer PC's field never makes the list unreadable to an older phone.
|
|
4018
|
-
|
|
4019
|
-
|
|
4052
|
+
z40.object({ type: z40.literal("routines"), routines: z40.array(PhoneRoutineSchema).max(ROUTINES_MAX) }),
|
|
4053
|
+
z40.object({ type: z40.literal("routine.changed"), routine: PhoneRoutineSchema.optional(), removed: RoutineIdSchema.optional() }),
|
|
4020
4054
|
/** The answer to `routine.show`: the routine whole, or `gone` when there is no such routine now. */
|
|
4021
|
-
|
|
4055
|
+
z40.object({ type: z40.literal("routine.detail"), id: RoutineIdSchema, routine: PhoneRoutineDetailSchema.optional(), gone: z40.literal(true).optional() }),
|
|
4022
4056
|
AttachmentStoredSchema,
|
|
4023
4057
|
AttachmentDataSchema,
|
|
4024
4058
|
AttachmentErrorSchema,
|
|
4025
4059
|
/** 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. */
|
|
4026
|
-
|
|
4027
|
-
type:
|
|
4060
|
+
z40.object({
|
|
4061
|
+
type: z40.literal("term.opened"),
|
|
4028
4062
|
op: OperationIdSchema.optional(),
|
|
4029
4063
|
tid: TerminalIdSchema,
|
|
4030
|
-
id:
|
|
4064
|
+
id: z40.string(),
|
|
4031
4065
|
cols: TermDimSchema,
|
|
4032
4066
|
rows: TermDimSchema,
|
|
4033
|
-
screen:
|
|
4034
|
-
cursor:
|
|
4035
|
-
seq:
|
|
4067
|
+
screen: z40.string().max(TERM_SCREEN_MAX),
|
|
4068
|
+
cursor: z40.object({ x: z40.number().int().nonnegative(), y: z40.number().int().nonnegative() }),
|
|
4069
|
+
seq: z40.number().int().nonnegative(),
|
|
4036
4070
|
/** Read-only for good: a subagent's page shows its parent's pane. */
|
|
4037
|
-
readOnly:
|
|
4071
|
+
readOnly: z40.literal(true).optional()
|
|
4038
4072
|
}),
|
|
4039
4073
|
/** What the pane printed since the last one; `seq` + 1 each time. */
|
|
4040
|
-
|
|
4041
|
-
|
|
4074
|
+
z40.object({ type: z40.literal("term.output"), tid: TerminalIdSchema, seq: z40.number().int().nonnegative(), data: z40.string().min(1).max(TERM_OUTPUT_MAX) }),
|
|
4075
|
+
z40.object({ type: z40.literal("term.size"), tid: TerminalIdSchema, cols: TermDimSchema, rows: TermDimSchema }),
|
|
4042
4076
|
/** The phone holds the hand until `until`, pushed back by each key (5 min), never past 30 min from the hold. */
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
|
|
4077
|
+
z40.object({ type: z40.literal("term.held"), tid: TerminalIdSchema, until: z40.string().datetime() }),
|
|
4078
|
+
z40.object({ type: z40.literal("term.released"), tid: TerminalIdSchema, why: TermReleaseWhySchema }),
|
|
4079
|
+
z40.object({ type: z40.literal("term.exit"), tid: TerminalIdSchema, why: TermExitWhySchema }),
|
|
4046
4080
|
/** Never carries free text. */
|
|
4047
4081
|
/** The subfolders of `path` on this PC (home when asked without one); `parent` null at the root. */
|
|
4048
|
-
|
|
4049
|
-
type:
|
|
4082
|
+
z40.object({
|
|
4083
|
+
type: z40.literal("folder.listing"),
|
|
4050
4084
|
path: FolderPathSchema,
|
|
4051
4085
|
parent: FolderPathSchema.nullable(),
|
|
4052
|
-
entries:
|
|
4053
|
-
repos:
|
|
4054
|
-
cut:
|
|
4086
|
+
entries: z40.array(z40.string().min(1).max(255)).max(PHONE_FOLDER_ENTRIES_MAX),
|
|
4087
|
+
repos: z40.array(z40.object({ name: z40.string().min(1).max(255), branch: z40.string().max(200) })).max(PHONE_FOLDER_ENTRIES_MAX),
|
|
4088
|
+
cut: z40.literal(true).optional(),
|
|
4055
4089
|
error: PhoneFolderErrorSchema.optional()
|
|
4056
4090
|
}),
|
|
4057
|
-
|
|
4091
|
+
z40.object({ type: z40.literal("folder.recents"), paths: z40.array(FolderPathSchema).max(PHONE_RECENT_FOLDERS_MAX) }),
|
|
4058
4092
|
/** A project's folders, in its order; `gone`: no such project now. */
|
|
4059
|
-
|
|
4060
|
-
|
|
4093
|
+
z40.object({ type: z40.literal("project.folders"), id: z40.string(), folders: z40.array(PhoneFolderSchema).max(50), gone: z40.literal(true).optional() }),
|
|
4094
|
+
z40.object({ type: z40.literal("error"), code: z40.enum(["invalid", "unknown_session", "too_large"]), request: z40.string().max(40).optional() }),
|
|
4061
4095
|
// ── Rigs and the kernel (`daemon.rigs`) ──
|
|
4062
4096
|
/** `error`: OpenRig could not be read (`state` absent). */
|
|
4063
|
-
|
|
4097
|
+
z40.object({ type: z40.literal("rigs.state"), state: PhoneOpenRigStateSchema.optional(), error: PhoneRigErrorSchema.optional() }).strict(),
|
|
4064
4098
|
// ── Pull and merge requests (`daemon.forge`) ──
|
|
4065
4099
|
/** After `forge.state`, then on each change, whole. */
|
|
4066
|
-
|
|
4100
|
+
z40.object({ type: z40.literal("forge.state"), ...PhoneForgeStateSchema.shape }).strict(),
|
|
4067
4101
|
/** `cut`: the gateway left out patches, discussions or commits, or shortened texts, to fit the frame. */
|
|
4068
|
-
|
|
4102
|
+
z40.object({ type: z40.literal("forge.detail"), prId: z40.string(), detail: PrDetailSchema.optional(), cut: z40.literal(true).optional(), error: PhoneForgeErrorSchema.optional() }).strict(),
|
|
4069
4103
|
/** 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`. */
|
|
4070
|
-
|
|
4071
|
-
type:
|
|
4104
|
+
z40.object({
|
|
4105
|
+
type: z40.literal("forge.done"),
|
|
4072
4106
|
op: OperationIdSchema,
|
|
4073
|
-
ok:
|
|
4074
|
-
command:
|
|
4107
|
+
ok: z40.boolean(),
|
|
4108
|
+
command: z40.string().max(PHONE_FORGE_MESSAGE_MAX).optional(),
|
|
4075
4109
|
error: PhoneForgeActErrorSchema.optional(),
|
|
4076
|
-
message:
|
|
4110
|
+
message: z40.string().max(PHONE_FORGE_MESSAGE_MAX).optional(),
|
|
4077
4111
|
rejected: PhoneForgeRejectedSchema.optional()
|
|
4078
4112
|
}).strict(),
|
|
4079
|
-
|
|
4113
|
+
z40.object({ type: z40.literal("rigs.graph"), rig: z40.string(), graph: RigGraphSchema.optional(), error: PhoneRigErrorSchema.optional() }).strict(),
|
|
4080
4114
|
/** `rows`: open (pending, in-progress, blocked), newest first; `closed`: closed lately, newest first; `truncated`: older open rows may be missing. */
|
|
4081
|
-
|
|
4082
|
-
type:
|
|
4083
|
-
rig:
|
|
4084
|
-
rows:
|
|
4085
|
-
closed:
|
|
4086
|
-
truncated:
|
|
4115
|
+
z40.object({
|
|
4116
|
+
type: z40.literal("rigs.queue"),
|
|
4117
|
+
rig: z40.string(),
|
|
4118
|
+
rows: z40.array(PhoneRigQueueRowSchema).max(PHONE_RIG_ROWS_MAX),
|
|
4119
|
+
closed: z40.array(PhoneRigQueueRowSchema).max(PHONE_RIG_ROWS_MAX),
|
|
4120
|
+
truncated: z40.boolean(),
|
|
4087
4121
|
error: PhoneRigErrorSchema.optional()
|
|
4088
4122
|
}).strict(),
|
|
4089
4123
|
/** Oldest first, at most 20. */
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4124
|
+
z40.object({ type: z40.literal("rigs.routing"), entries: z40.array(PhoneRigRoutingSchema).max(20), error: PhoneRigErrorSchema.optional() }).strict(),
|
|
4125
|
+
z40.object({ type: z40.literal("rigs.permissions"), rig: z40.string(), policy: z40.string().max(PHONE_RIG_TEXT_MAX).optional(), seats: z40.array(PhoneRigPermissionSchema).max(PHONE_RIG_SEATS_MAX), error: PhoneRigErrorSchema.optional() }).strict(),
|
|
4126
|
+
z40.object({ type: z40.literal("rigs.snapshots"), rig: z40.string(), snapshots: z40.array(RigSnapshotSchema).max(20), error: PhoneRigErrorSchema.optional() }).strict(),
|
|
4127
|
+
z40.object({ type: z40.literal("rigs.goals"), goals: z40.array(PhoneGoalSchema).max(PHONE_GOALS_MAX), partial: z40.literal(true).optional(), error: PhoneRigErrorSchema.optional() }).strict(),
|
|
4094
4128
|
/** An action's end, under its `op` (`operation.result` says whether it ran). `commands`: the `rig` commands as shown; `error`: `busy`, `not_installed`,
|
|
4095
4129
|
* `spec_unknown`, `spec_no_policy`, `spec_policy_unsupported`, or `failed` with `message`, OpenRig's last line; `completed` as the Desktop's. */
|
|
4096
|
-
|
|
4097
|
-
type:
|
|
4130
|
+
z40.object({
|
|
4131
|
+
type: z40.literal("rigs.done"),
|
|
4098
4132
|
op: OperationIdSchema,
|
|
4099
|
-
ok:
|
|
4100
|
-
commands:
|
|
4101
|
-
error:
|
|
4102
|
-
message:
|
|
4103
|
-
completed:
|
|
4133
|
+
ok: z40.boolean(),
|
|
4134
|
+
commands: z40.array(z40.string().max(PHONE_RIG_TEXT_MAX)).max(400),
|
|
4135
|
+
error: z40.string().max(40).optional(),
|
|
4136
|
+
message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
|
|
4137
|
+
completed: z40.number().int().min(0).optional(),
|
|
4104
4138
|
rejected: PhoneRigRejectedSchema.optional()
|
|
4105
4139
|
}).strict(),
|
|
4106
4140
|
/** A change of seats ended: `added` / `removed` as `pod.member`; `error`: `rig_not_running`, `rig_root_unknown`, `busy`, or `failed` with `message`. */
|
|
4107
|
-
|
|
4108
|
-
type:
|
|
4141
|
+
z40.object({
|
|
4142
|
+
type: z40.literal("rigs.reseated"),
|
|
4109
4143
|
op: OperationIdSchema,
|
|
4110
|
-
ok:
|
|
4111
|
-
commands:
|
|
4112
|
-
added:
|
|
4113
|
-
removed:
|
|
4114
|
-
error:
|
|
4115
|
-
message:
|
|
4116
|
-
links:
|
|
4117
|
-
linksUnsupported:
|
|
4144
|
+
ok: z40.boolean(),
|
|
4145
|
+
commands: z40.array(z40.string().max(PHONE_RIG_TEXT_MAX)).max(400),
|
|
4146
|
+
added: z40.array(z40.string()).max(PHONE_RIG_SEATS_MAX),
|
|
4147
|
+
removed: z40.array(z40.string()).max(PHONE_RIG_SEATS_MAX),
|
|
4148
|
+
error: z40.string().max(40).optional(),
|
|
4149
|
+
message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
|
|
4150
|
+
links: z40.number().int().optional(),
|
|
4151
|
+
linksUnsupported: z40.boolean().optional(),
|
|
4118
4152
|
rejected: PhoneRigRejectedSchema.optional()
|
|
4119
4153
|
}).strict(),
|
|
4120
|
-
|
|
4121
|
-
type:
|
|
4154
|
+
z40.object({
|
|
4155
|
+
type: z40.literal("rigs.goal.sent"),
|
|
4122
4156
|
op: OperationIdSchema,
|
|
4123
|
-
goalId:
|
|
4124
|
-
ok:
|
|
4125
|
-
qitemId:
|
|
4157
|
+
goalId: z40.string(),
|
|
4158
|
+
ok: z40.boolean(),
|
|
4159
|
+
qitemId: z40.string().optional(),
|
|
4126
4160
|
error: GoalErrorSchema.optional(),
|
|
4127
|
-
message:
|
|
4161
|
+
message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
|
|
4128
4162
|
rejected: PhoneRigRejectedSchema.optional()
|
|
4129
4163
|
}).strict(),
|
|
4130
|
-
|
|
4131
|
-
type:
|
|
4164
|
+
z40.object({
|
|
4165
|
+
type: z40.literal("rigs.goal.replied"),
|
|
4132
4166
|
op: OperationIdSchema,
|
|
4133
|
-
goalId:
|
|
4134
|
-
replyId:
|
|
4135
|
-
ok:
|
|
4136
|
-
qitemId:
|
|
4167
|
+
goalId: z40.string(),
|
|
4168
|
+
replyId: z40.string(),
|
|
4169
|
+
ok: z40.boolean(),
|
|
4170
|
+
qitemId: z40.string().optional(),
|
|
4137
4171
|
error: GoalErrorSchema.optional(),
|
|
4138
|
-
message:
|
|
4172
|
+
message: z40.string().max(PHONE_RIG_TEXT_MAX).optional(),
|
|
4139
4173
|
rejected: PhoneRigRejectedSchema.optional()
|
|
4140
4174
|
}).strict()
|
|
4141
4175
|
]);
|
|
@@ -4147,8 +4181,8 @@ var ConfigError = class extends Error {
|
|
|
4147
4181
|
this.name = "ConfigError";
|
|
4148
4182
|
}
|
|
4149
4183
|
};
|
|
4150
|
-
var TokensSchema =
|
|
4151
|
-
var PortSchema =
|
|
4184
|
+
var TokensSchema = z41.record(z41.string().min(1), z41.object({ accountId: z41.string().min(1), peer: RelayPeerSchema }));
|
|
4185
|
+
var PortSchema = z41.coerce.number().int().min(0).max(65535);
|
|
4152
4186
|
function required(env, name) {
|
|
4153
4187
|
const v = env[name];
|
|
4154
4188
|
if (!v) throw new ConfigError(`${name} is not set`);
|
|
@@ -4481,10 +4515,10 @@ function countedLog(log, ms) {
|
|
|
4481
4515
|
|
|
4482
4516
|
// src/routes.ts
|
|
4483
4517
|
import { createHash as createHash3, timingSafeEqual as timingSafeEqual2 } from "crypto";
|
|
4484
|
-
import { z as
|
|
4518
|
+
import { z as z43 } from "zod";
|
|
4485
4519
|
|
|
4486
4520
|
// src/github.ts
|
|
4487
|
-
import { z as
|
|
4521
|
+
import { z as z42 } from "zod";
|
|
4488
4522
|
var GitHubError = class extends Error {
|
|
4489
4523
|
code;
|
|
4490
4524
|
constructor(code) {
|
|
@@ -4493,21 +4527,21 @@ var GitHubError = class extends Error {
|
|
|
4493
4527
|
this.code = code;
|
|
4494
4528
|
}
|
|
4495
4529
|
};
|
|
4496
|
-
var DeviceStartSchema =
|
|
4497
|
-
device_code:
|
|
4498
|
-
user_code:
|
|
4499
|
-
verification_uri:
|
|
4500
|
-
expires_in:
|
|
4501
|
-
interval:
|
|
4502
|
-
});
|
|
4503
|
-
var TokenAnswerSchema =
|
|
4504
|
-
access_token:
|
|
4505
|
-
error:
|
|
4506
|
-
interval:
|
|
4507
|
-
});
|
|
4508
|
-
var UserSchema =
|
|
4509
|
-
id:
|
|
4510
|
-
login:
|
|
4530
|
+
var DeviceStartSchema = z42.object({
|
|
4531
|
+
device_code: z42.string().min(1),
|
|
4532
|
+
user_code: z42.string().min(1),
|
|
4533
|
+
verification_uri: z42.string().min(1),
|
|
4534
|
+
expires_in: z42.number().int().positive(),
|
|
4535
|
+
interval: z42.number().int().positive()
|
|
4536
|
+
});
|
|
4537
|
+
var TokenAnswerSchema = z42.object({
|
|
4538
|
+
access_token: z42.string().min(1).optional(),
|
|
4539
|
+
error: z42.string().optional(),
|
|
4540
|
+
interval: z42.number().int().positive().optional()
|
|
4541
|
+
});
|
|
4542
|
+
var UserSchema = z42.object({
|
|
4543
|
+
id: z42.number().int().nonnegative(),
|
|
4544
|
+
login: z42.string().min(1)
|
|
4511
4545
|
});
|
|
4512
4546
|
var DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
4513
4547
|
var USER_AGENT = "ledge-relay";
|
|
@@ -4762,10 +4796,10 @@ async function readJson(req, schema, max = MAX_BODY) {
|
|
|
4762
4796
|
if (!r.success) throw new Answer(400, "bad_request");
|
|
4763
4797
|
return r.data;
|
|
4764
4798
|
}
|
|
4765
|
-
var RevokeBodySchema =
|
|
4799
|
+
var RevokeBodySchema = z43.object({
|
|
4766
4800
|
peer: RelayPeerSchema.refine((p) => p !== "pc")
|
|
4767
4801
|
});
|
|
4768
|
-
var PollBodySchema =
|
|
4802
|
+
var PollBodySchema = z43.object({ deviceCode: z43.string().min(1).max(1024) });
|
|
4769
4803
|
function authRoutes(deps) {
|
|
4770
4804
|
const maxCalls = deps.maxGitHubCalls ?? DEFAULT_MAX_GITHUB_CALLS;
|
|
4771
4805
|
let inFlight = 0;
|