@spencerboucher/switchyard 0.13.0 → 0.14.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.
Files changed (179) hide show
  1. package/README.md +4 -3
  2. package/dist/bridge/agent-channel.js +26 -0
  3. package/dist/bridge/resource-snapshot.js +47 -0
  4. package/dist/bridge/switchyard-bridge.js +11 -0
  5. package/dist/bridge/switchyard-terminal.js +39 -5
  6. package/dist/policies/worker.js +2084 -1725
  7. package/dist/switchyard.mjs +3670 -2388
  8. package/package.json +1 -1
  9. package/web-dist/assets/AutomationView-CcxKiLxM.js +2 -0
  10. package/web-dist/assets/{AutomationView-Cg7yk8nb.js.map → AutomationView-CcxKiLxM.js.map} +1 -1
  11. package/web-dist/assets/{jsx-runtime-D13aM9HY.js → Button-BKQW9doW.js} +2 -2
  12. package/web-dist/assets/Button-BKQW9doW.js.map +1 -0
  13. package/web-dist/assets/Card-WONLvqGM.js +2 -0
  14. package/web-dist/assets/{Card-sHm0eI2Q.js.map → Card-WONLvqGM.js.map} +1 -1
  15. package/web-dist/assets/Checkbox-D18Ch0n4.js +2 -0
  16. package/web-dist/assets/{Checkbox-CEvKyfJz.js.map → Checkbox-D18Ch0n4.js.map} +1 -1
  17. package/web-dist/assets/Copy-D6U5ewFc.js +2 -0
  18. package/web-dist/assets/{Copy-BHOLVthK.js.map → Copy-D6U5ewFc.js.map} +1 -1
  19. package/web-dist/assets/{DangerZone-og55TRug.js → DangerZone-Ch2KNmob.js} +2 -2
  20. package/web-dist/assets/{DangerZone-og55TRug.js.map → DangerZone-Ch2KNmob.js.map} +1 -1
  21. package/web-dist/assets/InteractionCard-Bd4Cr_Zi.js +4 -0
  22. package/web-dist/assets/InteractionCard-Bd4Cr_Zi.js.map +1 -0
  23. package/web-dist/assets/Menu-CDIEOsaM.js +2 -0
  24. package/web-dist/assets/Menu-CDIEOsaM.js.map +1 -0
  25. package/web-dist/assets/Overlay-QSBH5woa.js +2 -0
  26. package/web-dist/assets/Overlay-QSBH5woa.js.map +1 -0
  27. package/web-dist/assets/Priority-PUuNGK2s.js +2 -0
  28. package/web-dist/assets/{Priority-xSUsxoXm.js.map → Priority-PUuNGK2s.js.map} +1 -1
  29. package/web-dist/assets/SegmentedControl-D2kj3j7u.js +2 -0
  30. package/web-dist/assets/SegmentedControl-D2kj3j7u.js.map +1 -0
  31. package/web-dist/assets/Select-CpWLZnId.js +2 -0
  32. package/web-dist/assets/{Select-C5xlhWYb.js.map → Select-CpWLZnId.js.map} +1 -1
  33. package/web-dist/assets/Switch-DHX-YYPr.js +2 -0
  34. package/web-dist/assets/{Switch-dVcf-7Je.js.map → Switch-DHX-YYPr.js.map} +1 -1
  35. package/web-dist/assets/Tabs-BplxI0Eb.js +184 -0
  36. package/web-dist/assets/Tabs-BplxI0Eb.js.map +1 -0
  37. package/web-dist/assets/TextArea-BQPdfjO_.js +2 -0
  38. package/web-dist/assets/{TextArea-D8WB5GD8.js.map → TextArea-BQPdfjO_.js.map} +1 -1
  39. package/web-dist/assets/TextLink-CCc3WEdm.js +2 -0
  40. package/web-dist/assets/{TextLink-CrfA8AeH.js.map → TextLink-CCc3WEdm.js.map} +1 -1
  41. package/web-dist/assets/UINodeRenderer-Bxq4kPwg.js +4 -0
  42. package/web-dist/assets/UINodeRenderer-Bxq4kPwg.js.map +1 -0
  43. package/web-dist/assets/arrow-down-YwTzxo-r.js +2 -0
  44. package/web-dist/assets/{arrow-down-C-iLrN8I.js.map → arrow-down-YwTzxo-r.js.map} +1 -1
  45. package/web-dist/assets/arrow-up-Bzh112dp.js +2 -0
  46. package/web-dist/assets/{arrow-up-Dj-VTKx4.js.map → arrow-up-Bzh112dp.js.map} +1 -1
  47. package/web-dist/assets/attention-BwQ0PjVB.js +2 -0
  48. package/web-dist/assets/attention-BwQ0PjVB.js.map +1 -0
  49. package/web-dist/assets/automations-BSV9KuSH.js +2 -0
  50. package/web-dist/assets/automations-BSV9KuSH.js.map +1 -0
  51. package/web-dist/assets/board-C8N8_GS0.js +10 -0
  52. package/web-dist/assets/{board-aS6ooJpx.js.map → board-C8N8_GS0.js.map} +1 -1
  53. package/web-dist/assets/calendar-clock-CwOgyN2z.js +2 -0
  54. package/web-dist/assets/{calendar-clock-B8zE4JsX.js.map → calendar-clock-CwOgyN2z.js.map} +1 -1
  55. package/web-dist/assets/chevron-right-aaHL5Igi.js +2 -0
  56. package/web-dist/assets/{chevron-right-evVLS6hq.js.map → chevron-right-aaHL5Igi.js.map} +1 -1
  57. package/web-dist/assets/code-BmxcCLin.js +25 -0
  58. package/web-dist/assets/code-BmxcCLin.js.map +1 -0
  59. package/web-dist/assets/{describe-w4KmQFfU.js → describe-Nw-EGTvb.js} +3 -3
  60. package/web-dist/assets/{describe-w4KmQFfU.js.map → describe-Nw-EGTvb.js.map} +1 -1
  61. package/web-dist/assets/drafts-CbBiiFKw.js +13 -0
  62. package/web-dist/assets/drafts-CbBiiFKw.js.map +1 -0
  63. package/web-dist/assets/enroll-2bd2qhh1.js +2 -0
  64. package/web-dist/assets/{enroll-DPKdD0en.js.map → enroll-2bd2qhh1.js.map} +1 -1
  65. package/web-dist/assets/external-link-CI-Uzhfh.js +2 -0
  66. package/web-dist/assets/{external-link-3jjTxo92.js.map → external-link-CI-Uzhfh.js.map} +1 -1
  67. package/web-dist/assets/hand-HCdmhGph.js +2 -0
  68. package/web-dist/assets/{hand-UPoHamrn.js.map → hand-HCdmhGph.js.map} +1 -1
  69. package/web-dist/assets/index-5cSRL594.js +11 -0
  70. package/web-dist/assets/index-5cSRL594.js.map +1 -0
  71. package/web-dist/assets/index-f4tQ91xN.css +2 -0
  72. package/web-dist/assets/key-round-DIA3lje5.js +2 -0
  73. package/web-dist/assets/{key-round-VDbE9E4X.js.map → key-round-DIA3lje5.js.map} +1 -1
  74. package/web-dist/assets/link-2-D6l0YZ-8.js +2 -0
  75. package/web-dist/assets/{link-2-CaMlUDRG.js.map → link-2-D6l0YZ-8.js.map} +1 -1
  76. package/web-dist/assets/logic-CzU-NdeO.js +2 -0
  77. package/web-dist/assets/{logic-B46fwD-8.js.map → logic-CzU-NdeO.js.map} +1 -1
  78. package/web-dist/assets/more-tcGYFcpM.js +2 -0
  79. package/web-dist/assets/more-tcGYFcpM.js.map +1 -0
  80. package/web-dist/assets/pencil-BtK08_f_.js +2 -0
  81. package/web-dist/assets/{pencil-DI8QbCN8.js.map → pencil-BtK08_f_.js.map} +1 -1
  82. package/web-dist/assets/play-j138GLHB.js +2 -0
  83. package/web-dist/assets/{play-CjoDg3ws.js.map → play-j138GLHB.js.map} +1 -1
  84. package/web-dist/assets/plus-D935l0Os.js +2 -0
  85. package/web-dist/assets/{plus-BLP-wIYD.js.map → plus-D935l0Os.js.map} +1 -1
  86. package/web-dist/assets/{policyLogic-7OOzM_xa.js → policyLogic-4ByNprLE.js} +2 -2
  87. package/web-dist/assets/{policyLogic-7OOzM_xa.js.map → policyLogic-4ByNprLE.js.map} +1 -1
  88. package/web-dist/assets/preload-helper-dybNq0aL.js +3 -0
  89. package/web-dist/assets/preload-helper-dybNq0aL.js.map +1 -0
  90. package/web-dist/assets/presence-BnGwJNSq.js +2 -0
  91. package/web-dist/assets/{presence-05bJD5G3.js.map → presence-BnGwJNSq.js.map} +1 -1
  92. package/web-dist/assets/queue-BH_AgQ1C.js +2 -0
  93. package/web-dist/assets/queue-BH_AgQ1C.js.map +1 -0
  94. package/web-dist/assets/registry-D8Ph1G2W.js +2 -0
  95. package/web-dist/assets/registry-D8Ph1G2W.js.map +1 -0
  96. package/web-dist/assets/{repo-BA_bnCvu.js → repo-Pn-s_Ggk.js} +2 -2
  97. package/web-dist/assets/{repo-BA_bnCvu.js.map → repo-Pn-s_Ggk.js.map} +1 -1
  98. package/web-dist/assets/settings-DjBmhTW8.js +9 -0
  99. package/web-dist/assets/settings-DjBmhTW8.js.map +1 -0
  100. package/web-dist/assets/states-f12WE0Zx.js +58 -0
  101. package/web-dist/assets/states-f12WE0Zx.js.map +1 -0
  102. package/web-dist/assets/terminal-DKqo1lis.js +2 -0
  103. package/web-dist/assets/{terminal-BOV_MXPZ.js.map → terminal-DKqo1lis.js.map} +1 -1
  104. package/web-dist/assets/terminal-login-BSJdzvzq.js +2 -0
  105. package/web-dist/assets/{terminal-login-C0n8cXqn.js.map → terminal-login-BSJdzvzq.js.map} +1 -1
  106. package/web-dist/assets/timer-CyFp7DQs.js +2 -0
  107. package/web-dist/assets/{timer-BCIucSXh.js.map → timer-CyFp7DQs.js.map} +1 -1
  108. package/web-dist/assets/useBreakpoint-kT0J1Dnk.js +2 -0
  109. package/web-dist/assets/{useBreakpoint-CYDIV-KM.js.map → useBreakpoint-kT0J1Dnk.js.map} +1 -1
  110. package/web-dist/assets/useNow-Cul-GfCg.js +2 -0
  111. package/web-dist/assets/useNow-Cul-GfCg.js.map +1 -0
  112. package/web-dist/assets/useResource-Bzqxz-K_.js +2 -0
  113. package/web-dist/assets/{useResource-DHtFcID5.js.map → useResource-Bzqxz-K_.js.map} +1 -1
  114. package/web-dist/index.html +13 -12
  115. package/web-dist/sw.js +1 -1
  116. package/web-dist/sw.js.map +1 -1
  117. package/web-dist/assets/AutomationView-Cg7yk8nb.js +0 -2
  118. package/web-dist/assets/Card-sHm0eI2Q.js +0 -2
  119. package/web-dist/assets/Checkbox-CEvKyfJz.js +0 -2
  120. package/web-dist/assets/Copy-BHOLVthK.js +0 -2
  121. package/web-dist/assets/InteractionCard-B-yhxwKs.js +0 -6
  122. package/web-dist/assets/InteractionCard-B-yhxwKs.js.map +0 -1
  123. package/web-dist/assets/Menu-Cyt18mF2.js +0 -2
  124. package/web-dist/assets/Menu-Cyt18mF2.js.map +0 -1
  125. package/web-dist/assets/Overlay-BPNYBq3V.js +0 -2
  126. package/web-dist/assets/Overlay-BPNYBq3V.js.map +0 -1
  127. package/web-dist/assets/Priority-xSUsxoXm.js +0 -2
  128. package/web-dist/assets/SegmentedControl-DaBwumC0.js +0 -2
  129. package/web-dist/assets/SegmentedControl-DaBwumC0.js.map +0 -1
  130. package/web-dist/assets/Select-C5xlhWYb.js +0 -2
  131. package/web-dist/assets/Switch-dVcf-7Je.js +0 -2
  132. package/web-dist/assets/Tabs-93APobOB.js +0 -184
  133. package/web-dist/assets/Tabs-93APobOB.js.map +0 -1
  134. package/web-dist/assets/TextArea-D8WB5GD8.js +0 -2
  135. package/web-dist/assets/TextLink-CrfA8AeH.js +0 -2
  136. package/web-dist/assets/arrow-down-C-iLrN8I.js +0 -2
  137. package/web-dist/assets/arrow-up-Dj-VTKx4.js +0 -2
  138. package/web-dist/assets/attention-C8rfu6Uw.js +0 -2
  139. package/web-dist/assets/attention-C8rfu6Uw.js.map +0 -1
  140. package/web-dist/assets/automations-DQxUzi5Q.js +0 -2
  141. package/web-dist/assets/automations-DQxUzi5Q.js.map +0 -1
  142. package/web-dist/assets/board-aS6ooJpx.js +0 -10
  143. package/web-dist/assets/calendar-clock-B8zE4JsX.js +0 -2
  144. package/web-dist/assets/chevron-right-evVLS6hq.js +0 -2
  145. package/web-dist/assets/code-Zr5DqwWI.js +0 -25
  146. package/web-dist/assets/code-Zr5DqwWI.js.map +0 -1
  147. package/web-dist/assets/enroll-DPKdD0en.js +0 -2
  148. package/web-dist/assets/external-link-3jjTxo92.js +0 -2
  149. package/web-dist/assets/hand-UPoHamrn.js +0 -2
  150. package/web-dist/assets/index-DFNY2EUd.css +0 -2
  151. package/web-dist/assets/index-DPScWz2I.js +0 -11
  152. package/web-dist/assets/index-DPScWz2I.js.map +0 -1
  153. package/web-dist/assets/jsx-runtime-D13aM9HY.js.map +0 -1
  154. package/web-dist/assets/key-round-VDbE9E4X.js +0 -2
  155. package/web-dist/assets/link-2-CaMlUDRG.js +0 -2
  156. package/web-dist/assets/logic-B46fwD-8.js +0 -2
  157. package/web-dist/assets/more-CiyGP5GD.js +0 -2
  158. package/web-dist/assets/more-CiyGP5GD.js.map +0 -1
  159. package/web-dist/assets/pencil-DI8QbCN8.js +0 -2
  160. package/web-dist/assets/play-CjoDg3ws.js +0 -2
  161. package/web-dist/assets/plus-BLP-wIYD.js +0 -2
  162. package/web-dist/assets/preload-helper-B2m1UyXR.js +0 -13
  163. package/web-dist/assets/preload-helper-B2m1UyXR.js.map +0 -1
  164. package/web-dist/assets/presence-05bJD5G3.js +0 -2
  165. package/web-dist/assets/queue-BcbJqzTY.js +0 -2
  166. package/web-dist/assets/queue-BcbJqzTY.js.map +0 -1
  167. package/web-dist/assets/settings-D03MF_Kx.js +0 -7
  168. package/web-dist/assets/settings-D03MF_Kx.js.map +0 -1
  169. package/web-dist/assets/shared-Bxc2JM1K.js +0 -3
  170. package/web-dist/assets/shared-Bxc2JM1K.js.map +0 -1
  171. package/web-dist/assets/states-DynH8-o6.js +0 -58
  172. package/web-dist/assets/states-DynH8-o6.js.map +0 -1
  173. package/web-dist/assets/terminal-BOV_MXPZ.js +0 -2
  174. package/web-dist/assets/terminal-login-C0n8cXqn.js +0 -2
  175. package/web-dist/assets/timer-BCIucSXh.js +0 -2
  176. package/web-dist/assets/useBreakpoint-CYDIV-KM.js +0 -2
  177. package/web-dist/assets/useNow-0tMsLHnB.js +0 -2
  178. package/web-dist/assets/useNow-0tMsLHnB.js.map +0 -1
  179. package/web-dist/assets/useResource-DHtFcID5.js +0 -2
@@ -2,9 +2,15 @@
2
2
  import { parentPort } from "node:worker_threads";
3
3
  import { Environment } from "@marcbachmann/cel-js";
4
4
 
5
- // packages/protocol/dist/agent-wire.js
5
+ // packages/protocol/dist/adapter-preview.js
6
+ import { z as z7 } from "zod";
7
+
8
+ // packages/protocol/dist/contributions.js
6
9
  import { z as z3 } from "zod";
7
10
 
11
+ // packages/protocol/dist/ui.js
12
+ import { z as z2 } from "zod";
13
+
8
14
  // packages/protocol/dist/errors.js
9
15
  import { z } from "zod";
10
16
  var ERROR_CODES = [
@@ -44,562 +50,165 @@ var ErrorBody = z.object({
44
50
  details: z.unknown().optional()
45
51
  });
46
52
  var ApiError = z.object({ error: ErrorBody });
47
-
48
- // packages/protocol/dist/policies.js
49
- import { z as z2 } from "zod";
50
- var Id = z2.string().min(1).max(200);
51
- var Revision = z2.number().int().safe().min(1);
52
- var Instant = z2.string().refine((s) => {
53
- try {
54
- return new Date(s).toISOString() === s;
55
- } catch {
56
- return false;
53
+ var SwitchyardError = class extends Error {
54
+ code;
55
+ details;
56
+ constructor(code, message, details) {
57
+ super(message);
58
+ this.name = "SwitchyardError";
59
+ this.code = code;
60
+ this.details = details;
57
61
  }
58
- });
59
- var Text = z2.string().max(4e3);
60
- var Reason = Text.min(1);
61
- var Fingerprint = z2.string().regex(/^[0-9a-f]{64}$/);
62
- var forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
63
- var bytes = (s) => new TextEncoder().encode(s).length;
64
- function validJson(value, depth = 0, seen = /* @__PURE__ */ new Set()) {
65
- if (depth > 20)
66
- return false;
67
- if (value === null || typeof value === "string" || typeof value === "boolean")
68
- return true;
69
- if (typeof value === "number")
70
- return Number.isFinite(value) && (!Number.isInteger(value) || Number.isSafeInteger(value));
71
- if (typeof value !== "object" || seen.has(value))
72
- return false;
73
- const prototype = Object.getPrototypeOf(value);
74
- if (Array.isArray(value) ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null)
75
- return false;
76
- seen.add(value);
77
- try {
78
- const descriptors = Object.getOwnPropertyDescriptors(value);
79
- const keys = Reflect.ownKeys(descriptors);
80
- if (Array.isArray(value) && keys.length !== value.length + 1)
81
- return false;
82
- return keys.every((key) => {
83
- if (typeof key !== "string" || forbidden.has(key))
84
- return false;
85
- if (Array.isArray(value)) {
86
- if (key === "length")
87
- return true;
88
- if (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= value.length)
89
- return false;
90
- }
91
- const descriptor = descriptors[key];
92
- return descriptor.enumerable === true && "value" in descriptor && validJson(descriptor.value, depth + 1, seen);
93
- });
94
- } finally {
95
- seen.delete(value);
96
- }
97
- }
98
- var JsonObject = z2.custom((v) => !!v && typeof v === "object" && !Array.isArray(v) && validJson(v));
99
- var CompletedUsageWatermark = z2.object({ runtimeId: Id, settleSeq: Revision }).strict();
100
- var scopeShape = { scope: z2.enum(["session", "profile", "server"]), scopeId: Id.nullable() };
101
- var scopeValid = (v) => v.scope === "server" === (v.scopeId === null);
102
- var PolicyPhase = z2.enum(["tool_call", "request"]);
103
- var PolicyVerdict = z2.enum(["ALLOW", "ASK", "DENY"]);
104
- var PolicyRequestAction = z2.enum([
105
- "task.create",
106
- "message.send",
107
- "inbox.read",
108
- "run.continue"
109
- ]);
110
- var PolicyScope = scopeShape.scope;
111
- var PolicyCounterMap = z2.record(z2.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/).refine((k) => !forbidden.has(k)), z2.number().int().safe()).refine((v) => Object.keys(v).length <= 64);
112
- var phases = z2.array(PolicyPhase).min(1).max(2).refine((v) => new Set(v).size === v.length);
113
- var ruleFields = {
114
- priority: z2.number().int().safe().min(-1e6).max(1e6),
115
- enabled: z2.boolean(),
116
- phases,
117
- name: z2.string().min(1).max(120),
118
- expression: z2.string().min(1).max(8192)
119
- };
120
- var PolicyRule = z2.object({
121
- id: Id,
122
- ...scopeShape,
123
- ...ruleFields,
124
- revision: Revision,
125
- builtIn: z2.boolean(),
126
- createdAt: Instant,
127
- updatedAt: Instant
128
- }).strict().refine(scopeValid);
129
- var PolicyToolSafety = z2.object({
130
- destructiveDelete: z2.boolean(),
131
- forcePush: z2.boolean(),
132
- defaultBranchPush: z2.boolean(),
133
- uncertain: z2.boolean(),
134
- reasons: z2.array(z2.string().min(1).max(1e3)).max(16)
135
- }).strict();
136
- function normalizePosixPath(value) {
137
- const parts = [];
138
- for (const part of value.split("/")) {
139
- if (part === "..")
140
- parts.pop();
141
- else if (part && part !== ".")
142
- parts.push(part);
143
- }
144
- return `/${parts.join("/")}`;
145
- }
146
- var hostPath = z2.string().min(1).max(8192).refine((value) => value.startsWith("/") && !value.includes("\0"), "Expected absolute POSIX path").transform(normalizePosixPath);
147
- function relativePosixPath(from, to) {
148
- const fromParts = from.split("/").filter(Boolean);
149
- const toParts = to.split("/").filter(Boolean);
150
- let shared = 0;
151
- while (shared < fromParts.length && fromParts[shared] === toParts[shared])
152
- shared++;
153
- return [...fromParts.slice(shared).map(() => ".."), ...toParts.slice(shared)].join("/");
154
- }
155
- var HostPolicyBoundary = z2.object({
156
- cwd: hostPath,
157
- workspaceRoot: hostPath,
158
- cwdReal: hostPath,
159
- workspaceRootReal: hostPath
160
- }).strict().refine((boundary) => {
161
- const relative = relativePosixPath(boundary.workspaceRootReal, boundary.cwdReal);
162
- return relative !== ".." && !relative.startsWith("../");
163
- }, "Real cwd must be within the real workspace boundary.");
164
- var HostToolPolicyContext = z2.object({
165
- version: z2.literal(1),
166
- toolCallId: Id,
167
- toolHash: Fingerprint,
168
- boundary: HostPolicyBoundary,
169
- defaultBranch: z2.string().min(1).max(255).nullable(),
170
- safety: PolicyToolSafety
171
- }).strict();
172
- var PolicyToolContext = z2.object({ name: Id, args: JsonObject, safety: PolicyToolSafety }).strict();
173
- var PolicyRequestContext = z2.object({ method: PolicyRequestAction, args: JsonObject }).strict();
174
- var absolutePath = z2.string().min(1).max(8192).refine((v) => v.startsWith("/") || /^[A-Za-z]:[\\/]/.test(v));
175
- var controlMode = z2.enum(["human", "automation"]);
176
- var PolicySessionContext = z2.object({
177
- id: Id,
178
- hostId: Id,
179
- nativeSessionId: Id.nullable(),
180
- runtimeId: Id.nullable(),
181
- profileId: Id,
182
- projectId: Id.nullable(),
183
- taskId: Id.nullable(),
184
- runId: Id.nullable(),
185
- controlMode,
186
- controlRevision: Revision,
187
- cwd: absolutePath,
188
- workspaceRoot: absolutePath,
189
- repository: z2.string().min(1).max(2048).nullable(),
190
- defaultBranch: z2.string().min(1).max(255).nullable(),
191
- readOnly: z2.boolean()
192
- }).strict();
193
- var PolicyTaskContext = z2.object({
194
- id: Id,
195
- projectId: Id,
196
- rootTaskId: Id,
197
- parentTaskId: Id.nullable(),
198
- title: z2.string().min(1).max(300),
199
- state: z2.enum(["backlog", "ready", "in_progress", "review", "done", "canceled"])
200
- }).strict();
201
- var PolicyTargetContext = z2.object({
202
- id: Id,
203
- hostId: Id,
204
- projectId: Id.nullable(),
205
- taskId: Id.nullable(),
206
- controlMode,
207
- controlRevision: Revision,
208
- runtime: z2.enum([
209
- "starting",
210
- "idle",
211
- "running",
212
- "waiting_input",
213
- "interrupted",
214
- "failed",
215
- "stopped"
216
- ]),
217
- readOnly: z2.boolean()
218
- }).strict();
219
- var PolicyCostContext = z2.object({
220
- tokens: z2.number().int().safe().nonnegative().nullable(),
221
- costUsd: z2.number().finite().nonnegative().nullable(),
222
- maxTokens: z2.number().int().safe().positive().nullable(),
223
- maxCostUsd: z2.number().finite().positive().nullable(),
224
- accounting: z2.enum(["available", "unavailable"]),
225
- fresh: z2.boolean(),
226
- watermark: CompletedUsageWatermark.nullable(),
227
- provider: Id.nullable(),
228
- modelId: z2.string().min(1).max(512).nullable(),
229
- classification: z2.enum(["cheap", "expensive", "unclassified"]),
230
- expensive: z2.boolean()
231
- }).strict().refine((v) => v.expensive === (v.classification !== "cheap") && (v.provider !== null && v.modelId !== null || v.classification === "unclassified") && v.accounting === "available" === (v.tokens !== null || v.costUsd !== null));
232
- var PolicyContext = z2.object({
233
- phase: PolicyPhase,
234
- action: z2.union([z2.literal("tool.call"), PolicyRequestAction]),
235
- tool: PolicyToolContext.nullable(),
236
- request: PolicyRequestContext.nullable(),
237
- session: PolicySessionContext,
238
- task: PolicyTaskContext.nullable(),
239
- target: PolicyTargetContext.nullable(),
240
- cost: PolicyCostContext,
241
- counters: PolicyCounterMap
242
- }).strict().refine((v) => (v.phase === "tool_call" ? v.action === "tool.call" && v.tool !== null && v.request === null : v.tool === null && v.request !== null && v.action === v.request.method) && (v.action === "message.send" ? v.target !== null : v.target === null)).refine((v) => bytes(JSON.stringify(v)) <= 65536, "Policy input is too large to evaluate.");
243
- var PolicyRuleResult = z2.union([
244
- z2.null(),
245
- z2.object({ verdict: PolicyVerdict, reason: Text, state_updates: PolicyCounterMap.optional() }).strict().refine((v) => v.verdict === "ALLOW" || v.reason.length > 0)
246
- ]);
247
- var webUrl = z2.string().max(4096).refine((s) => {
248
- try {
249
- const u = new URL(s);
250
- return ["http:", "https:"].includes(u.protocol) && !u.username && !u.password;
251
- } catch {
252
- return false;
62
+ toBody() {
63
+ return this.details === void 0 ? { code: this.code, message: this.message } : { code: this.code, message: this.message, details: this.details };
253
64
  }
254
- });
255
- var PolicyEvaluation = z2.discriminatedUnion("verdict", [
256
- z2.object({ verdict: z2.literal("ALLOW") }).strict(),
257
- z2.object({ verdict: z2.literal("DENY"), reason: Reason }).strict(),
258
- z2.object({
259
- verdict: z2.literal("ASK"),
260
- decisionId: Id,
261
- interactionId: Id,
262
- interactionUrl: webUrl
263
- }).strict()
264
- ]);
265
- var PolicyPermission = z2.object({
266
- kind: z2.literal("policy"),
267
- decisionId: Id,
268
- rootTaskId: Id.nullable(),
269
- ruleId: Id,
270
- ruleRevision: Revision,
271
- fingerprint: Fingerprint
272
- }).strict();
273
- var PolicyGrant = z2.object({
274
- id: Id,
275
- scope: z2.object({ kind: z2.enum(["task", "session"]), id: Id }).strict(),
276
- ruleId: Id,
277
- ruleRevision: Revision,
278
- fingerprint: Fingerprint,
279
- approvedByDeviceId: Id,
280
- approvedAt: Instant
281
- }).strict();
282
- var trimmed = (max) => z2.string().min(1).max(max).refine((s) => s.trim() === s);
283
- var PolicyModelClassification = z2.object({
284
- provider: trimmed(200),
285
- modelId: trimmed(512),
286
- classification: z2.enum(["cheap", "expensive"])
287
- }).strict();
288
- var classifications = z2.array(PolicyModelClassification).max(1e3).refine((v) => new Set(v.map((x) => JSON.stringify([x.provider, x.modelId]))).size === v.length);
289
- var PolicySettings = z2.object({ revision: Revision, modelClassifications: classifications, updatedAt: Instant }).strict();
290
- var toolInput = z2.object({ name: Id, args: JsonObject }).strict();
291
- var sampleIdentity = { sessionId: Id, nativeSessionId: Id, runtimeId: Id, sampleId: Id };
292
- var HostPolicySampleRequest = z2.object({ ...sampleIdentity, tool: toolInput }).strict();
293
- var HostPolicySampleResult = z2.object({
294
- ...sampleIdentity,
295
- toolHash: Fingerprint,
296
- boundary: HostPolicyBoundary,
297
- defaultBranch: z2.string().min(1).max(255).nullable(),
298
- safety: PolicyToolSafety
299
- }).strict();
300
- var PolicyEvaluateRequest = z2.object({ evaluationId: Id, toolCallId: Id, tool: toolInput }).strict();
301
- var PolicyStatusRequest = z2.object({ decisionId: Id, waitMs: z2.literal(25e3) }).strict();
302
- var PolicyStatusResult = z2.discriminatedUnion("state", [
303
- z2.object({ state: z2.literal("pending") }).strict(),
304
- z2.object({ state: z2.literal("allowed") }).strict(),
305
- z2.object({ state: z2.literal("denied"), reason: Reason }).strict(),
306
- z2.object({ state: z2.literal("canceled"), reason: Reason }).strict()
307
- ]);
308
- var PolicyCancelRequest = z2.object({ decisionId: Id }).strict();
309
- var PolicyCancelResult = z2.object({ state: z2.enum(["canceled", "already_resolved"]) }).strict();
310
- var PolicyTrace = z2.object({
311
- ruleId: Id,
312
- ruleRevision: Revision,
313
- ...scopeShape,
314
- verdict: PolicyVerdict.nullable(),
315
- reason: Text.nullable(),
316
- granted: z2.boolean(),
317
- overridden: z2.boolean(),
318
- proposedStateUpdates: PolicyCounterMap
319
- }).strict().refine(scopeValid);
320
- var PolicyTestResult = z2.object({
321
- verdict: PolicyVerdict,
322
- reason: Text.nullable(),
323
- trace: z2.array(PolicyTrace).max(128),
324
- proposedStateUpdates: z2.record(Id, PolicyCounterMap),
325
- enforcement: z2.object({
326
- phases: z2.array(PolicyPhase),
327
- modelRequest: z2.literal(false),
328
- explanation: z2.string()
329
- }).strict()
330
- }).strict();
331
- var CreatePolicyRuleRequest = z2.object({ ...scopeShape, ...ruleFields }).strict().refine(scopeValid);
332
- var UpdatePolicyRuleRequest = z2.object({
333
- expectedRevision: Revision,
334
- name: ruleFields.name.optional(),
335
- priority: ruleFields.priority.optional(),
336
- enabled: z2.boolean().optional(),
337
- phases: phases.optional(),
338
- expression: ruleFields.expression.optional()
339
- }).strict().refine((v) => Object.keys(v).length > 1);
340
- var DeletePolicyRuleQuery = z2.object({ expectedRevision: Revision }).strict();
341
- var UpdatePolicySettingsRequest = z2.object({ expectedRevision: Revision, modelClassifications: classifications }).strict();
342
- var PolicyTestRequest = z2.object({
343
- sessionId: Id,
344
- phase: PolicyPhase,
345
- tool: toolInput.nullable(),
346
- request: PolicyRequestContext.nullable()
347
- }).strict().refine((v) => v.phase === "tool_call" ? v.tool !== null && v.request === null : v.tool === null && v.request !== null);
348
-
349
- // packages/protocol/dist/agent-wire.js
350
- var Id2 = z3.string().min(1).max(200);
351
- var Instant2 = z3.string().refine((value) => {
352
- const date = new Date(value);
353
- return Number.isFinite(date.getTime()) && date.toISOString() === value;
354
- }, "Expected canonical UTC timestamp");
355
- var AGENT_FRAME_MAX_BYTES = 128 * 1024;
356
- var AgentMethod = z3.enum([
357
- "session.bind",
358
- "task.create",
359
- "message.send",
360
- "inbox.read",
361
- "receipt.peek",
362
- "policy.evaluate",
363
- "policy.status",
364
- "policy.cancel"
365
- ]);
366
- var AgentToolMethod = z3.enum(["task.create", "message.send", "inbox.read"]);
367
- var RequestHash = z3.string().regex(/^[a-f0-9]{64}$/);
368
- var AgentReceiptPeekRequest = z3.object({ method: AgentToolMethod, args: z3.record(z3.string(), z3.json()) }).strict();
369
- var AgentReceiptPeekResult = z3.discriminatedUnion("found", [
370
- z3.object({ found: z3.literal(false) }).strict(),
371
- z3.object({ found: z3.literal(true), requestHash: RequestHash }).strict()
372
- ]);
373
- var AgentReceiptReplay = z3.object({ requestHash: RequestHash }).strict();
374
- var CreateAgentTask = z3.object({
375
- objective: z3.string().min(1).max(16e3),
376
- acceptance: z3.array(z3.string().min(1).max(2e3)).max(100).default([]),
377
- dependencies: z3.array(Id2).max(100).default([]),
378
- parentTaskId: Id2.nullable().optional(),
379
- hostId: Id2.optional(),
380
- profileId: Id2.optional(),
381
- notifyOnFinish: z3.boolean().default(true)
382
- });
383
- var SendAgentMessage = z3.object({
384
- sessionId: Id2,
385
- body: z3.string().min(1).max(16e3),
386
- mode: z3.enum(["steer", "queue"]),
387
- replyTo: Id2.optional()
388
- });
389
- var ReadAgentInbox = z3.object({
390
- after: z3.number().int().nonnegative().default(0),
391
- limit: z3.number().int().min(1).max(100).default(20)
392
- });
393
- var DeliveryState = z3.enum([
394
- "pending",
395
- "held",
396
- "deferred",
397
- "accepted",
398
- "queued",
399
- "appended",
400
- "uncertain",
401
- "failed"
402
- ]);
403
- var AgentMessageFields = {
404
- seq: z3.number().int().positive(),
405
- id: Id2,
406
- recipientSessionId: Id2,
407
- replyTo: Id2.nullable(),
408
- chainId: Id2,
409
- depth: z3.number().int().min(0).max(4),
410
- body: z3.unknown(),
411
- requestedMode: z3.enum(["steer", "queue"]),
412
- deliveryState: DeliveryState,
413
- holdUntil: z3.string(),
414
- readAt: z3.string().nullable(),
415
- createdAt: z3.string()
416
65
  };
417
- var AgentMessage = z3.discriminatedUnion("kind", [
418
- z3.object({ ...AgentMessageFields, kind: z3.literal("message"), senderSessionId: Id2 }),
419
- z3.object({
420
- ...AgentMessageFields,
421
- kind: z3.literal("completion"),
422
- senderSessionId: Id2.nullable()
423
- })
424
- ]);
425
- var AgentInbox = z3.object({
426
- messages: z3.array(AgentMessage),
427
- nextAfter: z3.number().int().nonnegative(),
428
- hasMore: z3.boolean()
429
- });
430
- var AgentToolPolicyWait = PolicyEvaluation.options[2].omit({ verdict: true }).extend({ type: z3.literal("policy.required") }).strict();
431
- var AgentRequestFrame = z3.object({
432
- type: z3.literal("agent.request"),
433
- requestId: Id2,
434
- sessionId: Id2,
435
- nativeSessionId: Id2,
436
- runtimeId: Id2,
437
- context: z3.object({ humanInputId: Id2.nullable(), causalMessageId: Id2.nullable() }).strict(),
438
- toolCallId: Id2.optional(),
439
- receiptReplay: AgentReceiptReplay.optional(),
440
- // Tool-method ingress requires this separately; legacy/non-tool frames remain compatible.
441
- deadlineAt: Instant2.optional(),
442
- method: AgentMethod,
443
- args: z3.unknown()
444
- }).strict().superRefine((frame, ctx) => {
445
- if (frame.method === "receipt.peek") {
446
- if (!frame.toolCallId) {
447
- ctx.addIssue({
448
- code: "custom",
449
- path: ["toolCallId"],
450
- message: "Receipt lookup requires a tool call ID."
451
- });
452
- }
453
- }
454
- if (Object.hasOwn(frame, "receiptReplay") && !AgentToolMethod.safeParse(frame.method).success) {
455
- ctx.addIssue({
456
- code: "custom",
457
- path: ["receiptReplay"],
458
- message: "Receipt replay is only valid for tool methods."
459
- });
460
- }
461
- });
462
- var AgentResultFrame = z3.discriminatedUnion("ok", [
463
- z3.object({
464
- type: z3.literal("agent.result"),
465
- requestId: Id2,
466
- runtimeId: Id2,
467
- ok: z3.literal(true),
468
- result: z3.unknown()
469
- }),
470
- z3.object({
471
- type: z3.literal("agent.result"),
472
- requestId: Id2,
473
- runtimeId: Id2,
474
- ok: z3.literal(false),
475
- error: ErrorBody
476
- })
477
- ]);
478
-
479
- // packages/protocol/dist/api.js
480
- import { z as z11 } from "zod";
481
-
482
- // packages/protocol/dist/entities.js
483
- import { z as z7 } from "zod";
484
-
485
- // packages/protocol/dist/contributions.js
486
- import { z as z5 } from "zod";
487
66
 
488
67
  // packages/protocol/dist/ui.js
489
- import { z as z4 } from "zod";
490
- var ToneSchema = z4.enum(["default", "muted", "success", "warning", "danger"]);
491
- var ShowIfSchema = z4.object({ field: z4.string(), values: z4.array(z4.string()) });
492
- var OptionSchema = z4.object({
493
- value: z4.string(),
494
- label: z4.string(),
495
- description: z4.string().optional(),
496
- preview: z4.string().optional()
497
- });
498
- var AllowOther = z4.object({ label: z4.string(), placeholder: z4.string().optional() });
499
- var FieldSchema = z4.discriminatedUnion("kind", [
500
- z4.object({
501
- kind: z4.literal("select"),
502
- name: z4.string(),
503
- label: z4.string(),
504
- options: z4.array(OptionSchema),
68
+ var ToneSchema = z2.enum(["default", "muted", "success", "warning", "danger"]);
69
+ var ShowIfSchema = z2.object({ field: z2.string(), values: z2.array(z2.string()) });
70
+ var OptionSchema = z2.object({
71
+ value: z2.string(),
72
+ label: z2.string(),
73
+ description: z2.string().optional(),
74
+ preview: z2.string().optional()
75
+ });
76
+ var AllowOther = z2.object({ label: z2.string(), placeholder: z2.string().optional() });
77
+ var FieldSchema = z2.discriminatedUnion("kind", [
78
+ z2.object({
79
+ kind: z2.literal("select"),
80
+ name: z2.string(),
81
+ label: z2.string(),
82
+ options: z2.array(OptionSchema),
505
83
  allowOther: AllowOther.optional(),
506
84
  showIf: ShowIfSchema.optional()
507
85
  }),
508
- z4.object({
509
- kind: z4.literal("multiselect"),
510
- name: z4.string(),
511
- label: z4.string(),
512
- options: z4.array(OptionSchema),
86
+ z2.object({
87
+ kind: z2.literal("multiselect"),
88
+ name: z2.string(),
89
+ label: z2.string(),
90
+ options: z2.array(OptionSchema),
513
91
  allowOther: AllowOther.optional(),
514
- min: z4.number().int().min(0).optional(),
515
- max: z4.number().int().min(1).optional(),
92
+ min: z2.number().int().min(0).optional(),
93
+ max: z2.number().int().min(1).optional(),
516
94
  showIf: ShowIfSchema.optional()
517
95
  }),
518
- z4.object({
519
- kind: z4.literal("text"),
520
- name: z4.string(),
521
- label: z4.string(),
522
- placeholder: z4.string().optional(),
523
- multiline: z4.boolean().optional(),
524
- prefill: z4.string().optional(),
96
+ z2.object({
97
+ kind: z2.literal("text"),
98
+ name: z2.string(),
99
+ label: z2.string(),
100
+ placeholder: z2.string().optional(),
101
+ multiline: z2.boolean().optional(),
102
+ prefill: z2.string().optional(),
525
103
  showIf: ShowIfSchema.optional()
526
104
  })
527
105
  ]);
528
- var RefSchema = z4.discriminatedUnion("kind", [
529
- z4.object({ kind: z4.literal("file"), path: z4.string() }),
530
- z4.object({ kind: z4.literal("session"), sessionId: z4.string() }),
531
- z4.object({ kind: z4.literal("task"), taskId: z4.string() }),
532
- z4.object({ kind: z4.literal("native_session"), hostId: z4.string(), sessionFile: z4.string() })
106
+ var RefSchema = z2.discriminatedUnion("kind", [
107
+ z2.object({ kind: z2.literal("file"), path: z2.string() }),
108
+ z2.object({ kind: z2.literal("session"), sessionId: z2.string() }),
109
+ z2.object({ kind: z2.literal("task"), taskId: z2.string() }),
110
+ z2.object({ kind: z2.literal("native_session"), hostId: z2.string(), sessionFile: z2.string() })
533
111
  ]);
534
- var UINodeSchema = z4.lazy(() => z4.discriminatedUnion("t", [
535
- z4.object({ t: z4.literal("text"), text: z4.string(), tone: ToneSchema.optional() }),
536
- z4.object({ t: z4.literal("markdown"), text: z4.string() }),
537
- z4.object({ t: z4.literal("code"), text: z4.string(), lang: z4.string().optional() }),
538
- z4.object({ t: z4.literal("diff"), patch: z4.string() }),
539
- z4.object({
540
- t: z4.literal("list"),
541
- items: z4.array(UINodeSchema),
542
- ordered: z4.boolean().optional()
112
+ var UINodeSchema = z2.lazy(() => z2.discriminatedUnion("t", [
113
+ z2.object({ t: z2.literal("text"), text: z2.string(), tone: ToneSchema.optional() }),
114
+ z2.object({ t: z2.literal("markdown"), text: z2.string() }),
115
+ z2.object({ t: z2.literal("code"), text: z2.string(), lang: z2.string().optional() }),
116
+ z2.object({ t: z2.literal("diff"), patch: z2.string() }),
117
+ z2.object({
118
+ t: z2.literal("list"),
119
+ items: z2.array(UINodeSchema),
120
+ ordered: z2.boolean().optional()
543
121
  }),
544
- z4.object({
545
- t: z4.literal("table"),
546
- columns: z4.array(z4.string()),
547
- rows: z4.array(z4.array(z4.string()))
122
+ z2.object({
123
+ t: z2.literal("table"),
124
+ columns: z2.array(z2.string()),
125
+ rows: z2.array(z2.array(z2.string()))
548
126
  }),
549
- z4.object({
550
- t: z4.literal("section"),
551
- title: z4.string().optional(),
552
- collapsible: z4.boolean().optional(),
553
- children: z4.array(UINodeSchema)
127
+ z2.object({
128
+ t: z2.literal("section"),
129
+ title: z2.string().optional(),
130
+ collapsible: z2.boolean().optional(),
131
+ children: z2.array(UINodeSchema)
554
132
  }),
555
- z4.object({
556
- t: z4.literal("tabs"),
557
- tabs: z4.array(z4.object({ id: z4.string(), label: z4.string(), children: z4.array(UINodeSchema) }))
133
+ z2.object({
134
+ t: z2.literal("tabs"),
135
+ tabs: z2.array(z2.object({ id: z2.string(), label: z2.string(), children: z2.array(UINodeSchema) }))
558
136
  }),
559
- z4.object({
560
- t: z4.literal("progress"),
561
- label: z4.string(),
562
- value: z4.number().min(0).max(1).optional(),
563
- status: z4.enum(["running", "ok", "error"]).optional()
137
+ z2.object({
138
+ t: z2.literal("progress"),
139
+ label: z2.string(),
140
+ value: z2.number().min(0).max(1).optional(),
141
+ status: z2.enum(["running", "ok", "error"]).optional()
564
142
  }),
565
- z4.object({ t: z4.literal("ref"), ref: RefSchema, label: z4.string() }),
566
- z4.object({
567
- t: z4.literal("form"),
568
- formId: z4.string(),
569
- fields: z4.array(FieldSchema),
570
- submitLabel: z4.string(),
571
- cancelLabel: z4.string().optional()
143
+ z2.object({ t: z2.literal("ref"), ref: RefSchema, label: z2.string() }),
144
+ z2.object({
145
+ t: z2.literal("form"),
146
+ formId: z2.string(),
147
+ fields: z2.array(FieldSchema),
148
+ submitLabel: z2.string(),
149
+ cancelLabel: z2.string().optional()
572
150
  }),
573
- z4.object({
574
- t: z4.literal("confirm"),
575
- message: z4.string(),
576
- confirmLabel: z4.string(),
577
- cancelLabel: z4.string(),
578
- destructive: z4.boolean().optional()
151
+ z2.object({
152
+ t: z2.literal("confirm"),
153
+ message: z2.string(),
154
+ confirmLabel: z2.string(),
155
+ cancelLabel: z2.string(),
156
+ destructive: z2.boolean().optional()
579
157
  }),
580
- z4.object({
581
- t: z4.literal("actions"),
582
- actions: z4.array(z4.object({
583
- id: z4.string(),
584
- label: z4.string(),
585
- tone: z4.enum(["default", "primary", "danger"]).optional()
158
+ z2.object({
159
+ t: z2.literal("actions"),
160
+ actions: z2.array(z2.object({
161
+ id: z2.string(),
162
+ label: z2.string(),
163
+ tone: z2.enum(["default", "primary", "danger"]).optional()
586
164
  }))
587
165
  })
588
166
  ]));
589
- var FormValueSchema = z4.union([
590
- z4.string(),
591
- z4.array(z4.string()),
592
- z4.object({ other: z4.string() })
167
+ var UI_MAX_DEPTH = 12;
168
+ var UI_MAX_NODES = 2e3;
169
+ function children(node) {
170
+ switch (node.t) {
171
+ case "list":
172
+ return node.items;
173
+ case "section":
174
+ return node.children;
175
+ case "tabs":
176
+ return node.tabs.flatMap((tab) => tab.children);
177
+ default:
178
+ return [];
179
+ }
180
+ }
181
+ function validateUINode(input) {
182
+ const node = UINodeSchema.parse(input);
183
+ let count = 0;
184
+ const walk = (n, depth) => {
185
+ count++;
186
+ if (depth > UI_MAX_DEPTH) {
187
+ throw new SwitchyardError("ui_tree_too_large", `UI tree deeper than ${UI_MAX_DEPTH}`);
188
+ }
189
+ if (count > UI_MAX_NODES) {
190
+ throw new SwitchyardError("ui_tree_too_large", `UI tree has more than ${UI_MAX_NODES} nodes`);
191
+ }
192
+ for (const c of children(n))
193
+ walk(c, depth + 1);
194
+ };
195
+ walk(node, 1);
196
+ return node;
197
+ }
198
+ var FormValueSchema = z2.union([
199
+ z2.string(),
200
+ z2.array(z2.string()),
201
+ z2.object({ other: z2.string() })
593
202
  ]);
594
- var InteractionResponseSchema = z4.discriminatedUnion("kind", [
595
- z4.object({ kind: z4.literal("form"), values: z4.record(z4.string(), FormValueSchema) }),
596
- z4.object({ kind: z4.literal("confirm"), confirmed: z4.boolean() }),
597
- z4.object({ kind: z4.literal("action"), actionId: z4.string() }),
598
- z4.object({ kind: z4.literal("cancel") })
203
+ var InteractionResponseSchema = z2.discriminatedUnion("kind", [
204
+ z2.object({ kind: z2.literal("form"), values: z2.record(z2.string(), FormValueSchema) }),
205
+ z2.object({ kind: z2.literal("confirm"), confirmed: z2.boolean() }),
206
+ z2.object({ kind: z2.literal("action"), actionId: z2.string() }),
207
+ z2.object({ kind: z2.literal("cancel") })
599
208
  ]);
600
209
 
601
210
  // packages/protocol/dist/contributions.js
602
- var ContributionPlacement = z5.enum([
211
+ var ContributionPlacement = z3.enum([
603
212
  "sidebar.header",
604
213
  "sidebar.footer",
605
214
  "session.panel",
@@ -607,18 +216,18 @@ var ContributionPlacement = z5.enum([
607
216
  "palette.item",
608
217
  "slash.command"
609
218
  ]);
610
- var Id3 = z5.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
611
- var ActionId = z5.string().min(1).max(200);
612
- var Keywords = z5.array(z5.string().min(1).max(80)).max(20);
219
+ var Id = z3.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}$/);
220
+ var ActionId = z3.string().min(1).max(200);
221
+ var Keywords = z3.array(z3.string().min(1).max(80)).max(20);
613
222
  var Common = {
614
223
  placement: ContributionPlacement,
615
- order: z5.number().int().min(-1e3).max(1e3).optional(),
224
+ order: z3.number().int().min(-1e3).max(1e3).optional(),
616
225
  actionId: ActionId.optional()
617
226
  };
618
- var ContributionDescriptor = z5.object({
619
- id: Id3,
227
+ var ContributionDescriptor = z3.object({
228
+ id: Id,
620
229
  ...Common,
621
- name: z5.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),
230
+ name: z3.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),
622
231
  keywords: Keywords.optional()
623
232
  }).strict().superRefine((v, ctx) => {
624
233
  if (v.placement === "slash.command" && (!v.name || !v.actionId)) {
@@ -637,33 +246,132 @@ var ContributionDescriptor = z5.object({
637
246
  ctx.addIssue({ code: "custom", message: "Composer pills are not interactive" });
638
247
  }
639
248
  });
640
- var ContributionInput = z5.object({
249
+ var ContributionInput = z3.object({
641
250
  ...Common,
642
- title: z5.string().min(1).max(100),
643
- node: z5.unknown(),
644
- mobileFallback: z5.string().min(1).max(2e3),
645
- state: z5.unknown().optional(),
646
- name: z5.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),
251
+ title: z3.string().min(1).max(100),
252
+ node: z3.unknown(),
253
+ mobileFallback: z3.string().min(1).max(2e3),
254
+ state: z3.unknown().optional(),
255
+ name: z3.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),
647
256
  keywords: Keywords.optional()
648
257
  }).strict();
258
+ function boundContributionJson(value, maxBytes = 256 * 1024) {
259
+ const stack = [{ value, depth: 0 }];
260
+ const ancestors = /* @__PURE__ */ new Set();
261
+ let count = 0;
262
+ let characterCount = 0;
263
+ while (stack.length) {
264
+ const { value: v, depth, leave } = stack.pop();
265
+ if (leave) {
266
+ ancestors.delete(v);
267
+ continue;
268
+ }
269
+ if (++count > 2e4 || depth > 32)
270
+ throw new Error("Contribution exceeds complexity limit");
271
+ if (typeof v === "string") {
272
+ characterCount += v.length;
273
+ if (characterCount > maxBytes)
274
+ throw new Error("Contribution exceeds size limit");
275
+ }
276
+ if (v === null || typeof v === "string" || typeof v === "boolean")
277
+ continue;
278
+ if (typeof v === "number" && Number.isFinite(v))
279
+ continue;
280
+ if (!v || typeof v !== "object")
281
+ throw new Error("Contribution contains a non-JSON value");
282
+ if (ancestors.has(v))
283
+ throw new Error("Contribution contains a cycle");
284
+ ancestors.add(v);
285
+ stack.push({ value: v, depth, leave: true });
286
+ if (Array.isArray(v)) {
287
+ for (const child of v)
288
+ stack.push({ value: child, depth: depth + 1 });
289
+ } else {
290
+ if (Object.getPrototypeOf(v) !== Object.prototype && Object.getPrototypeOf(v) !== null) {
291
+ throw new Error("Contribution contains a non-plain object");
292
+ }
293
+ for (const [key, child] of Object.entries(v)) {
294
+ characterCount += key.length;
295
+ if (characterCount > maxBytes)
296
+ throw new Error("Contribution exceeds size limit");
297
+ stack.push({ value: child, depth: depth + 1 });
298
+ }
299
+ }
300
+ }
301
+ const json = JSON.stringify(value);
302
+ let bytes3 = 0;
303
+ for (const char of json) {
304
+ const code = char.codePointAt(0);
305
+ bytes3 += code < 128 ? 1 : code < 2048 ? 2 : code < 65536 ? 3 : 4;
306
+ if (bytes3 > maxBytes)
307
+ throw new Error("Contribution exceeds size limit");
308
+ }
309
+ }
310
+ function hasInteractive(node) {
311
+ if (node.t === "form" || node.t === "confirm")
312
+ return true;
313
+ if (node.t === "section")
314
+ return node.children.some(hasInteractive);
315
+ if (node.t === "list")
316
+ return node.items.some(hasInteractive);
317
+ if (node.t === "tabs")
318
+ return node.tabs.some((t) => t.children.some(hasInteractive));
319
+ return false;
320
+ }
321
+ function validateContribution(id, input) {
322
+ Id.parse(id);
323
+ boundContributionJson(input);
324
+ const parsed = ContributionInput.parse(input);
325
+ const node = validateUINode(parsed.node);
326
+ const { title, mobileFallback, state, node: _node, ...meta } = parsed;
327
+ const descriptor = ContributionDescriptor.parse({ ...meta, id });
328
+ if (descriptor.placement === "slash.command" && node.t !== "form") {
329
+ throw new Error("Slash command content must be a form");
330
+ }
331
+ if (descriptor.placement === "composer.pill" && node.t !== "text" && node.t !== "progress") {
332
+ throw new Error("Composer pill content must be text or progress");
333
+ }
334
+ if (descriptor.placement !== "session.panel" && state !== void 0) {
335
+ throw new Error("Only session panels accept renderer state");
336
+ }
337
+ if (state !== void 0)
338
+ boundContributionJson(state, 64 * 1024);
339
+ if (hasInteractive(node) && !descriptor.actionId) {
340
+ throw new Error("Interactive content requires actionId");
341
+ }
342
+ return { descriptor, title, node, mobileFallback, ...state === void 0 ? {} : { state } };
343
+ }
344
+ function validateContributionCard(node) {
345
+ boundContributionJson(node);
346
+ const checked = validateUINode(node);
347
+ if (hasInteractive(checked))
348
+ throw new Error("Timeline cards cannot contain forms or confirms");
349
+ return checked;
350
+ }
351
+ function contributionSlot(id) {
352
+ return `@slot/${Id.parse(id)}`;
353
+ }
649
354
 
650
- // packages/protocol/dist/github.js
355
+ // packages/protocol/dist/entities.js
651
356
  import { z as z6 } from "zod";
652
- var Id4 = z6.string().min(1).max(200);
653
- var Instant3 = z6.string().refine((s) => {
357
+
358
+ // packages/protocol/dist/github.js
359
+ import { z as z4 } from "zod";
360
+ var Id2 = z4.string().min(1).max(200);
361
+ var Instant = z4.string().refine((s) => {
654
362
  try {
655
363
  return new Date(s).toISOString() === s;
656
364
  } catch {
657
365
  return false;
658
366
  }
659
367
  });
660
- var positive = z6.number().int().safe().positive();
661
- var nonnegative = z6.number().int().safe().nonnegative();
662
- var reason = z6.string().min(1).max(2e3);
663
- var hash = z6.string().regex(/^[0-9a-f]{64}$/);
664
- var actionsId = z6.string().regex(/^[1-9][0-9]{0,19}$/);
665
- var bytes2 = (s) => new TextEncoder().encode(s).length;
666
- var displayUrl = z6.string().max(4096).refine((s) => {
368
+ var positive = z4.number().int().safe().positive();
369
+ var nonnegative = z4.number().int().safe().nonnegative();
370
+ var reason = z4.string().min(1).max(2e3);
371
+ var hash = z4.string().regex(/^[0-9a-f]{64}$/);
372
+ var actionsId = z4.string().regex(/^[1-9][0-9]{0,19}$/);
373
+ var bytes = (s) => new TextEncoder().encode(s).length;
374
+ var displayUrl = z4.string().max(4096).refine((s) => {
667
375
  try {
668
376
  const u = new URL(s);
669
377
  return ["http:", "https:"].includes(u.protocol) && !u.username && !u.password;
@@ -679,14 +387,14 @@ var githubUrl = displayUrl.refine((s) => {
679
387
  return false;
680
388
  }
681
389
  });
682
- var GitHubRepository = z6.string().regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?\/(?!\.{1,2}$)[A-Za-z0-9_.-]{1,100}$/);
390
+ var GitHubRepository = z4.string().regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?\/(?!\.{1,2}$)[A-Za-z0-9_.-]{1,100}$/);
683
391
  var issuePath = /^[hH][tT][tT][pP][sS]:\/\/[gG][iI][tT][hH][uU][bB]\.[cC][oO][mM]\/([^/]+)\/([^/]+)\/issues\/([1-9][0-9]*)$/;
684
- var GitHubIssueUrl = z6.string().trim().transform((raw, ctx) => {
392
+ var GitHubIssueUrl = z4.string().trim().transform((raw, ctx) => {
685
393
  const match = issuePath.exec(raw);
686
394
  const number = match ? Number(match[3]) : NaN;
687
395
  if (!match || !GitHubRepository.safeParse(`${match[1]}/${match[2]}`).success || !Number.isSafeInteger(number)) {
688
396
  ctx.addIssue({ code: "custom", message: "Invalid GitHub issue URL" });
689
- return z6.NEVER;
397
+ return z4.NEVER;
690
398
  }
691
399
  return `https://github.com/${match[1]}/${match[2]}/issues/${number}`;
692
400
  });
@@ -699,7 +407,7 @@ function issuePrompt(url) {
699
407
 
700
408
  Read it with \`gh issue view ${url}\`.`;
701
409
  }
702
- var GitHubIssueIdentity = z6.object({
410
+ var GitHubIssueIdentity = z4.object({
703
411
  repository: GitHubRepository,
704
412
  number: positive,
705
413
  url: GitHubIssueUrl
@@ -707,11 +415,11 @@ var GitHubIssueIdentity = z6.object({
707
415
  const parts = issueParts(v.url);
708
416
  return v.repository === parts.repository && v.number === parts.number;
709
417
  });
710
- var GitHubIssue = z6.object({
418
+ var GitHubIssue = z4.object({
711
419
  repository: GitHubRepository,
712
420
  number: positive,
713
421
  url: GitHubIssueUrl,
714
- launchPrompt: z6.string()
422
+ launchPrompt: z4.string()
715
423
  }).strict().refine((v) => {
716
424
  const parts = issueParts(v.url);
717
425
  return v.repository === parts.repository && v.number === parts.number && v.launchPrompt === issuePrompt(v.url);
@@ -720,7 +428,7 @@ function githubIssueFromUrl(raw) {
720
428
  const url = GitHubIssueUrl.parse(raw);
721
429
  return { ...issueParts(url), url, launchPrompt: issuePrompt(url) };
722
430
  }
723
- var GitHubSha = z6.string().regex(/^[0-9a-f]{40}$/);
431
+ var GitHubSha = z4.string().regex(/^[0-9a-f]{40}$/);
724
432
  var prUrl = githubUrl.refine((s) => {
725
433
  try {
726
434
  const u = new URL(s);
@@ -737,57 +445,57 @@ function matchesPr(url, repository, number) {
737
445
  return false;
738
446
  }
739
447
  }
740
- var HostGitHub = z6.object({ available: z6.boolean(), reason: reason.nullable() }).strict().refine((v) => v.available === (v.reason === null));
741
- var GitHubCheck = z6.object({
448
+ var HostGitHub = z4.object({ available: z4.boolean(), reason: reason.nullable() }).strict().refine((v) => v.available === (v.reason === null));
449
+ var GitHubCheck = z4.object({
742
450
  id: hash,
743
- name: z6.string().min(1).max(300),
744
- state: z6.string().min(1).max(100),
745
- bucket: z6.enum(["pass", "fail", "pending", "skipping", "cancel", "unknown"]),
451
+ name: z4.string().min(1).max(300),
452
+ state: z4.string().min(1).max(100),
453
+ bucket: z4.enum(["pass", "fail", "pending", "skipping", "cancel", "unknown"]),
746
454
  link: displayUrl.nullable(),
747
- workflow: z6.string().max(300).nullable(),
748
- event: z6.string().max(100).nullable(),
749
- startedAt: Instant3.nullable(),
750
- completedAt: Instant3.nullable(),
751
- description: z6.string().max(2e3).nullable(),
752
- actionsJob: z6.object({ runId: actionsId, jobId: actionsId, attempt: positive }).strict().nullable()
455
+ workflow: z4.string().max(300).nullable(),
456
+ event: z4.string().max(100).nullable(),
457
+ startedAt: Instant.nullable(),
458
+ completedAt: Instant.nullable(),
459
+ description: z4.string().max(2e3).nullable(),
460
+ actionsJob: z4.object({ runId: actionsId, jobId: actionsId, attempt: positive }).strict().nullable()
753
461
  }).strict();
754
- var GitHubComment = z6.object({
755
- id: Id4,
756
- author: z6.string().min(1).max(200).nullable(),
757
- body: z6.string().refine((v) => [...v].length <= 8e3),
758
- bodyTruncated: z6.boolean(),
462
+ var GitHubComment = z4.object({
463
+ id: Id2,
464
+ author: z4.string().min(1).max(200).nullable(),
465
+ body: z4.string().refine((v) => [...v].length <= 8e3),
466
+ bodyTruncated: z4.boolean(),
759
467
  url: githubUrl,
760
- createdAt: Instant3.nullable()
468
+ createdAt: Instant.nullable()
761
469
  }).strict();
762
- var GitHubThread = z6.object({
763
- id: Id4,
764
- isResolved: z6.literal(false),
765
- isOutdated: z6.boolean(),
766
- path: z6.string().max(8192).nullable(),
470
+ var GitHubThread = z4.object({
471
+ id: Id2,
472
+ isResolved: z4.literal(false),
473
+ isOutdated: z4.boolean(),
474
+ path: z4.string().max(8192).nullable(),
767
475
  line: positive.nullable(),
768
476
  startLine: positive.nullable(),
769
- side: z6.enum(["LEFT", "RIGHT"]).nullable(),
770
- comments: z6.array(GitHubComment).max(10),
771
- commentsComplete: z6.boolean()
477
+ side: z4.enum(["LEFT", "RIGHT"]).nullable(),
478
+ comments: z4.array(GitHubComment).max(10),
479
+ commentsComplete: z4.boolean()
772
480
  }).strict();
773
- var GitHubPullRequest = z6.object({
774
- nodeId: z6.string().min(1).optional(),
481
+ var GitHubPullRequest = z4.object({
482
+ nodeId: z4.string().min(1).optional(),
775
483
  number: positive,
776
484
  url: prUrl,
777
- title: z6.string().min(1).max(1e3),
778
- state: z6.enum(["OPEN", "CLOSED", "MERGED"]),
779
- isDraft: z6.boolean(),
780
- headRefName: z6.string().min(1).max(255),
485
+ title: z4.string().min(1).max(1e3),
486
+ state: z4.enum(["OPEN", "CLOSED", "MERGED"]),
487
+ isDraft: z4.boolean(),
488
+ headRefName: z4.string().min(1).max(255),
781
489
  headRefOid: GitHubSha,
782
490
  headRepository: GitHubRepository.nullable(),
783
- baseRefName: z6.string().min(1).max(255),
784
- mergeable: z6.string().min(1).max(100),
785
- mergeStateStatus: z6.string().min(1).max(100),
786
- reviewDecision: z6.enum(["APPROVED", "REVIEW_REQUIRED", "CHANGES_REQUESTED"]).nullable(),
787
- mergeQueueEnabled: z6.boolean(),
788
- inMergeQueue: z6.boolean(),
789
- autoMergeEnabled: z6.boolean(),
790
- squashMergeAllowed: z6.boolean()
491
+ baseRefName: z4.string().min(1).max(255),
492
+ mergeable: z4.string().min(1).max(100),
493
+ mergeStateStatus: z4.string().min(1).max(100),
494
+ reviewDecision: z4.enum(["APPROVED", "REVIEW_REQUIRED", "CHANGES_REQUESTED"]).nullable(),
495
+ mergeQueueEnabled: z4.boolean(),
496
+ inMergeQueue: z4.boolean(),
497
+ autoMergeEnabled: z4.boolean(),
498
+ squashMergeAllowed: z4.boolean()
791
499
  }).strict().refine((v) => {
792
500
  try {
793
501
  return new URL(v.url).pathname.endsWith(`/pull/${v.number}`);
@@ -795,22 +503,22 @@ var GitHubPullRequest = z6.object({
795
503
  return false;
796
504
  }
797
505
  });
798
- var WorkspaceGitHub = z6.object({
506
+ var WorkspaceGitHub = z4.object({
799
507
  repository: GitHubRepository.nullable(),
800
508
  headRepository: GitHubRepository.nullable(),
801
- branch: z6.string().min(1).max(255).nullable(),
802
- fetchedAt: Instant3.nullable(),
803
- attemptedAt: Instant3,
804
- status: z6.enum(["ready", "unavailable", "error", "ambiguous"]),
509
+ branch: z4.string().min(1).max(255).nullable(),
510
+ fetchedAt: Instant.nullable(),
511
+ attemptedAt: Instant,
512
+ status: z4.enum(["ready", "unavailable", "error", "ambiguous"]),
805
513
  reason: reason.nullable(),
806
514
  pullRequest: GitHubPullRequest.nullable(),
807
- checks: z6.array(GitHubCheck).max(500),
808
- checksComplete: z6.boolean(),
809
- threads: z6.array(GitHubThread).max(500),
810
- threadsComplete: z6.boolean(),
811
- truncated: z6.boolean()
515
+ checks: z4.array(GitHubCheck).max(500),
516
+ checksComplete: z4.boolean(),
517
+ threads: z4.array(GitHubThread).max(500),
518
+ threadsComplete: z4.boolean(),
519
+ truncated: z4.boolean()
812
520
  }).strict().refine((v) => {
813
- if (bytes2(JSON.stringify(v)) > 512 * 1024 || new Set(v.checks.map((c) => c.id)).size !== v.checks.length)
521
+ if (bytes(JSON.stringify(v)) > 512 * 1024 || new Set(v.checks.map((c) => c.id)).size !== v.checks.length)
814
522
  return false;
815
523
  if (v.pullRequest && (!v.repository || !matchesPr(v.pullRequest.url, v.repository, v.pullRequest.number)))
816
524
  return false;
@@ -820,8 +528,8 @@ var WorkspaceGitHub = z6.object({
820
528
  return v.reason !== null && !v.checksComplete && !v.threadsComplete;
821
529
  return v.reason === null && v.fetchedAt !== null && v.repository !== null && v.headRepository !== null && v.branch !== null && (v.pullRequest !== null || v.checks.length === 0 && v.threads.length === 0 && v.checksComplete && v.threadsComplete);
822
530
  });
823
- var GitHubViewResult = z6.object({ github: HostGitHub, snapshot: WorkspaceGitHub }).strict();
824
- var GitHubViewResponse = z6.object({ github: HostGitHub.nullable(), snapshot: WorkspaceGitHub.nullable() }).strict();
531
+ var GitHubViewResult = z4.object({ github: HostGitHub, snapshot: WorkspaceGitHub }).strict();
532
+ var GitHubViewResponse = z4.object({ github: HostGitHub.nullable(), snapshot: WorkspaceGitHub.nullable() }).strict();
825
533
  function lineCount(s) {
826
534
  if (!s)
827
535
  return 0;
@@ -830,14 +538,14 @@ function lineCount(s) {
830
538
  lines.pop();
831
539
  return lines.length;
832
540
  }
833
- var GitHubJobLog = z6.object({
541
+ var GitHubJobLog = z4.object({
834
542
  checkId: hash,
835
- name: z6.string().min(1).max(300),
543
+ name: z4.string().min(1).max(300),
836
544
  url: displayUrl.nullable(),
837
545
  runId: actionsId.nullable(),
838
546
  jobId: actionsId.nullable(),
839
547
  attempt: positive.nullable(),
840
- status: z6.enum([
548
+ status: z4.enum([
841
549
  "available",
842
550
  "unmapped",
843
551
  "incomplete",
@@ -846,26 +554,26 @@ var GitHubJobLog = z6.object({
846
554
  "timeout",
847
555
  "error"
848
556
  ]),
849
- outputTail: z6.string().nullable(),
557
+ outputTail: z4.string().nullable(),
850
558
  lineCount: nonnegative.max(150),
851
- truncated: z6.boolean(),
559
+ truncated: z4.boolean(),
852
560
  reason: reason.nullable()
853
- }).strict().refine((v) => v.status === "available" ? v.runId !== null && v.jobId !== null && v.attempt !== null && v.outputTail !== null && bytes2(v.outputTail) <= 65536 && lineCount(v.outputTail) === v.lineCount && v.reason === null : v.outputTail === null && v.lineCount === 0 && v.reason !== null);
854
- var GitHubLogs = z6.object({
561
+ }).strict().refine((v) => v.status === "available" ? v.runId !== null && v.jobId !== null && v.attempt !== null && v.outputTail !== null && bytes(v.outputTail) <= 65536 && lineCount(v.outputTail) === v.lineCount && v.reason === null : v.outputTail === null && v.lineCount === 0 && v.reason !== null);
562
+ var GitHubLogs = z4.object({
855
563
  github: HostGitHub,
856
564
  repository: GitHubRepository,
857
565
  number: positive,
858
566
  headOid: GitHubSha,
859
- fetchedAt: Instant3,
860
- status: z6.enum(["ready", "unavailable", "error"]),
567
+ fetchedAt: Instant,
568
+ status: z4.enum(["ready", "unavailable", "error"]),
861
569
  reason: reason.nullable(),
862
- jobs: z6.array(GitHubJobLog).max(10),
863
- complete: z6.boolean(),
864
- truncated: z6.boolean(),
570
+ jobs: z4.array(GitHubJobLog).max(10),
571
+ complete: z4.boolean(),
572
+ truncated: z4.boolean(),
865
573
  omittedJobs: nonnegative.nullable()
866
- }).strict().refine((v) => bytes2(JSON.stringify(v)) <= 1024 * 1024 && (v.status === "ready" ? v.github.available && v.reason === null && (!v.complete || v.omittedJobs === 0 && v.jobs.every((j) => j.status === "available")) : v.reason !== null && v.jobs.length === 0 && !v.complete));
867
- var GitHubLogsRequest = z6.object({ expectedHeadOid: GitHubSha }).strict();
868
- var GitHubMergeRequest = z6.object({ expectedHeadOid: GitHubSha }).strict();
574
+ }).strict().refine((v) => bytes(JSON.stringify(v)) <= 1024 * 1024 && (v.status === "ready" ? v.github.available && v.reason === null && (!v.complete || v.omittedJobs === 0 && v.jobs.every((j) => j.status === "available")) : v.reason !== null && v.jobs.length === 0 && !v.complete));
575
+ var GitHubLogsRequest = z4.object({ expectedHeadOid: GitHubSha }).strict();
576
+ var GitHubMergeRequest = z4.object({ expectedHeadOid: GitHubSha }).strict();
869
577
  var mergeFields = {
870
578
  github: HostGitHub,
871
579
  repository: GitHubRepository,
@@ -873,217 +581,520 @@ var mergeFields = {
873
581
  url: prUrl,
874
582
  expectedHeadOid: GitHubSha
875
583
  };
876
- var GitHubMergeResult = z6.discriminatedUnion("status", [
877
- z6.object({
878
- status: z6.literal("merged"),
584
+ var GitHubMergeResult = z4.discriminatedUnion("status", [
585
+ z4.object({
586
+ status: z4.literal("merged"),
879
587
  ...mergeFields,
880
588
  mergeCommitOid: GitHubSha.nullable(),
881
- confirmedAt: Instant3
589
+ confirmedAt: Instant
882
590
  }).strict(),
883
- z6.object({
884
- status: z6.literal("outcome_unknown"),
591
+ z4.object({
592
+ status: z4.literal("outcome_unknown"),
885
593
  ...mergeFields,
886
594
  reason,
887
- attemptedAt: Instant3
595
+ attemptedAt: Instant
888
596
  }).strict()
889
597
  ]).refine((v) => matchesPr(v.url, v.repository, v.number));
890
- var path = z6.string().min(1).max(8192);
891
- var GitHubHostViewRequest = z6.object({ path }).strict();
892
- var GitHubHostLogsRequest = z6.object({ path, repository: GitHubRepository, number: positive, expectedHeadOid: GitHubSha }).strict();
598
+ var path = z4.string().min(1).max(8192);
599
+ var GitHubHostViewRequest = z4.object({ path }).strict();
600
+ var GitHubHostLogsRequest = z4.object({ path, repository: GitHubRepository, number: positive, expectedHeadOid: GitHubSha }).strict();
893
601
  var GitHubHostMergeRequest = GitHubHostLogsRequest.extend({
894
- expectedPullRequestNodeId: z6.string().min(1)
602
+ expectedPullRequestNodeId: z4.string().min(1)
603
+ });
604
+
605
+ // packages/protocol/dist/policies.js
606
+ import { z as z5 } from "zod";
607
+ var Id3 = z5.string().min(1).max(200);
608
+ var Revision = z5.number().int().safe().min(1);
609
+ var Instant2 = z5.string().refine((s) => {
610
+ try {
611
+ return new Date(s).toISOString() === s;
612
+ } catch {
613
+ return false;
614
+ }
615
+ });
616
+ var Text = z5.string().max(4e3);
617
+ var Reason = Text.min(1);
618
+ var Fingerprint = z5.string().regex(/^[0-9a-f]{64}$/);
619
+ var forbidden = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
620
+ var bytes2 = (s) => new TextEncoder().encode(s).length;
621
+ function validJson(value, depth = 0, seen = /* @__PURE__ */ new Set()) {
622
+ if (depth > 20)
623
+ return false;
624
+ if (value === null || typeof value === "string" || typeof value === "boolean")
625
+ return true;
626
+ if (typeof value === "number")
627
+ return Number.isFinite(value) && (!Number.isInteger(value) || Number.isSafeInteger(value));
628
+ if (typeof value !== "object" || seen.has(value))
629
+ return false;
630
+ const prototype = Object.getPrototypeOf(value);
631
+ if (Array.isArray(value) ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null)
632
+ return false;
633
+ seen.add(value);
634
+ try {
635
+ const descriptors = Object.getOwnPropertyDescriptors(value);
636
+ const keys = Reflect.ownKeys(descriptors);
637
+ if (Array.isArray(value) && keys.length !== value.length + 1)
638
+ return false;
639
+ return keys.every((key) => {
640
+ if (typeof key !== "string" || forbidden.has(key))
641
+ return false;
642
+ if (Array.isArray(value)) {
643
+ if (key === "length")
644
+ return true;
645
+ if (!/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= value.length)
646
+ return false;
647
+ }
648
+ const descriptor = descriptors[key];
649
+ return descriptor.enumerable === true && "value" in descriptor && validJson(descriptor.value, depth + 1, seen);
650
+ });
651
+ } finally {
652
+ seen.delete(value);
653
+ }
654
+ }
655
+ var JsonObject = z5.custom((v) => !!v && typeof v === "object" && !Array.isArray(v) && validJson(v));
656
+ var CompletedUsageWatermark = z5.object({ runtimeId: Id3, settleSeq: Revision }).strict();
657
+ var scopeShape = { scope: z5.enum(["session", "profile", "server"]), scopeId: Id3.nullable() };
658
+ var scopeValid = (v) => v.scope === "server" === (v.scopeId === null);
659
+ var PolicyPhase = z5.enum(["tool_call", "request"]);
660
+ var PolicyVerdict = z5.enum(["ALLOW", "ASK", "DENY"]);
661
+ var PolicyRequestAction = z5.enum([
662
+ "task.create",
663
+ "message.send",
664
+ "inbox.read",
665
+ "run.continue"
666
+ ]);
667
+ var PolicyScope = scopeShape.scope;
668
+ var PolicyCounterMap = z5.record(z5.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,63}$/).refine((k) => !forbidden.has(k)), z5.number().int().safe()).refine((v) => Object.keys(v).length <= 64);
669
+ var phases = z5.array(PolicyPhase).min(1).max(2).refine((v) => new Set(v).size === v.length);
670
+ var ruleFields = {
671
+ priority: z5.number().int().safe().min(-1e6).max(1e6),
672
+ enabled: z5.boolean(),
673
+ phases,
674
+ name: z5.string().min(1).max(120),
675
+ expression: z5.string().min(1).max(8192)
676
+ };
677
+ var PolicyRule = z5.object({
678
+ id: Id3,
679
+ ...scopeShape,
680
+ ...ruleFields,
681
+ revision: Revision,
682
+ builtIn: z5.boolean(),
683
+ createdAt: Instant2,
684
+ updatedAt: Instant2
685
+ }).strict().refine(scopeValid);
686
+ var PolicyToolSafety = z5.object({
687
+ destructiveDelete: z5.boolean(),
688
+ forcePush: z5.boolean(),
689
+ defaultBranchPush: z5.boolean(),
690
+ uncertain: z5.boolean(),
691
+ reasons: z5.array(z5.string().min(1).max(1e3)).max(16)
692
+ }).strict();
693
+ function normalizePosixPath(value) {
694
+ const parts = [];
695
+ for (const part of value.split("/")) {
696
+ if (part === "..")
697
+ parts.pop();
698
+ else if (part && part !== ".")
699
+ parts.push(part);
700
+ }
701
+ return `/${parts.join("/")}`;
702
+ }
703
+ var hostPath = z5.string().min(1).max(8192).refine((value) => value.startsWith("/") && !value.includes("\0"), "Expected absolute POSIX path").transform(normalizePosixPath);
704
+ function relativePosixPath(from, to) {
705
+ const fromParts = from.split("/").filter(Boolean);
706
+ const toParts = to.split("/").filter(Boolean);
707
+ let shared = 0;
708
+ while (shared < fromParts.length && fromParts[shared] === toParts[shared])
709
+ shared++;
710
+ return [...fromParts.slice(shared).map(() => ".."), ...toParts.slice(shared)].join("/");
711
+ }
712
+ var HostPolicyBoundary = z5.object({
713
+ cwd: hostPath,
714
+ workspaceRoot: hostPath,
715
+ cwdReal: hostPath,
716
+ workspaceRootReal: hostPath
717
+ }).strict().refine((boundary) => {
718
+ const relative = relativePosixPath(boundary.workspaceRootReal, boundary.cwdReal);
719
+ return relative !== ".." && !relative.startsWith("../");
720
+ }, "Real cwd must be within the real workspace boundary.");
721
+ var HostToolPolicyContext = z5.object({
722
+ version: z5.literal(1),
723
+ toolCallId: Id3,
724
+ toolHash: Fingerprint,
725
+ boundary: HostPolicyBoundary,
726
+ defaultBranch: z5.string().min(1).max(255).nullable(),
727
+ safety: PolicyToolSafety
728
+ }).strict();
729
+ var PolicyToolContext = z5.object({ name: Id3, args: JsonObject, safety: PolicyToolSafety }).strict();
730
+ var PolicyRequestContext = z5.object({ method: PolicyRequestAction, args: JsonObject }).strict();
731
+ var absolutePath = z5.string().min(1).max(8192).refine((v) => v.startsWith("/") || /^[A-Za-z]:[\\/]/.test(v));
732
+ var controlMode = z5.enum(["human", "automation"]);
733
+ var PolicySessionContext = z5.object({
734
+ id: Id3,
735
+ hostId: Id3,
736
+ nativeSessionId: Id3.nullable(),
737
+ runtimeId: Id3.nullable(),
738
+ profileId: Id3,
739
+ projectId: Id3.nullable(),
740
+ taskId: Id3.nullable(),
741
+ runId: Id3.nullable(),
742
+ controlMode,
743
+ controlRevision: Revision,
744
+ cwd: absolutePath,
745
+ workspaceRoot: absolutePath,
746
+ repository: z5.string().min(1).max(2048).nullable(),
747
+ defaultBranch: z5.string().min(1).max(255).nullable(),
748
+ readOnly: z5.boolean()
749
+ }).strict();
750
+ var PolicyTaskContext = z5.object({
751
+ id: Id3,
752
+ projectId: Id3,
753
+ rootTaskId: Id3,
754
+ parentTaskId: Id3.nullable(),
755
+ title: z5.string().min(1).max(300),
756
+ state: z5.enum(["backlog", "ready", "in_progress", "review", "done", "canceled"])
757
+ }).strict();
758
+ var PolicyTargetContext = z5.object({
759
+ id: Id3,
760
+ hostId: Id3,
761
+ projectId: Id3.nullable(),
762
+ taskId: Id3.nullable(),
763
+ controlMode,
764
+ controlRevision: Revision,
765
+ runtime: z5.enum([
766
+ "starting",
767
+ "idle",
768
+ "running",
769
+ "waiting_input",
770
+ "interrupted",
771
+ "failed",
772
+ "stopped"
773
+ ]),
774
+ readOnly: z5.boolean()
775
+ }).strict();
776
+ var PolicyCostContext = z5.object({
777
+ tokens: z5.number().int().safe().nonnegative().nullable(),
778
+ costUsd: z5.number().finite().nonnegative().nullable(),
779
+ maxTokens: z5.number().int().safe().positive().nullable(),
780
+ maxCostUsd: z5.number().finite().positive().nullable(),
781
+ accounting: z5.enum(["available", "unavailable"]),
782
+ fresh: z5.boolean(),
783
+ watermark: CompletedUsageWatermark.nullable(),
784
+ provider: Id3.nullable(),
785
+ modelId: z5.string().min(1).max(512).nullable(),
786
+ classification: z5.enum(["cheap", "expensive", "unclassified"]),
787
+ expensive: z5.boolean()
788
+ }).strict().refine((v) => v.expensive === (v.classification !== "cheap") && (v.provider !== null && v.modelId !== null || v.classification === "unclassified") && v.accounting === "available" === (v.tokens !== null || v.costUsd !== null));
789
+ var PolicyContext = z5.object({
790
+ phase: PolicyPhase,
791
+ action: z5.union([z5.literal("tool.call"), PolicyRequestAction]),
792
+ tool: PolicyToolContext.nullable(),
793
+ request: PolicyRequestContext.nullable(),
794
+ session: PolicySessionContext,
795
+ task: PolicyTaskContext.nullable(),
796
+ target: PolicyTargetContext.nullable(),
797
+ cost: PolicyCostContext,
798
+ counters: PolicyCounterMap
799
+ }).strict().refine((v) => (v.phase === "tool_call" ? v.action === "tool.call" && v.tool !== null && v.request === null : v.tool === null && v.request !== null && v.action === v.request.method) && (v.action === "message.send" ? v.target !== null : v.target === null)).refine((v) => bytes2(JSON.stringify(v)) <= 65536, "Policy input is too large to evaluate.");
800
+ var PolicyRuleResult = z5.union([
801
+ z5.null(),
802
+ z5.object({ verdict: PolicyVerdict, reason: Text, state_updates: PolicyCounterMap.optional() }).strict().refine((v) => v.verdict === "ALLOW" || v.reason.length > 0)
803
+ ]);
804
+ var webUrl = z5.string().max(4096).refine((s) => {
805
+ try {
806
+ const u = new URL(s);
807
+ return ["http:", "https:"].includes(u.protocol) && !u.username && !u.password;
808
+ } catch {
809
+ return false;
810
+ }
895
811
  });
812
+ var PolicyEvaluation = z5.discriminatedUnion("verdict", [
813
+ z5.object({ verdict: z5.literal("ALLOW") }).strict(),
814
+ z5.object({ verdict: z5.literal("DENY"), reason: Reason }).strict(),
815
+ z5.object({
816
+ verdict: z5.literal("ASK"),
817
+ decisionId: Id3,
818
+ interactionId: Id3,
819
+ interactionUrl: webUrl
820
+ }).strict()
821
+ ]);
822
+ var PolicyPermission = z5.object({
823
+ kind: z5.literal("policy"),
824
+ decisionId: Id3,
825
+ rootTaskId: Id3.nullable(),
826
+ ruleId: Id3,
827
+ ruleRevision: Revision,
828
+ fingerprint: Fingerprint
829
+ }).strict();
830
+ var PolicyGrant = z5.object({
831
+ id: Id3,
832
+ scope: z5.object({ kind: z5.enum(["task", "session"]), id: Id3 }).strict(),
833
+ ruleId: Id3,
834
+ ruleRevision: Revision,
835
+ fingerprint: Fingerprint,
836
+ approvedByDeviceId: Id3,
837
+ approvedAt: Instant2
838
+ }).strict();
839
+ var trimmed = (max) => z5.string().min(1).max(max).refine((s) => s.trim() === s);
840
+ var PolicyModelClassification = z5.object({
841
+ provider: trimmed(200),
842
+ modelId: trimmed(512),
843
+ classification: z5.enum(["cheap", "expensive"])
844
+ }).strict();
845
+ var classifications = z5.array(PolicyModelClassification).max(1e3).refine((v) => new Set(v.map((x) => JSON.stringify([x.provider, x.modelId]))).size === v.length);
846
+ var PolicySettings = z5.object({ revision: Revision, modelClassifications: classifications, updatedAt: Instant2 }).strict();
847
+ var toolInput = z5.object({ name: Id3, args: JsonObject }).strict();
848
+ var sampleIdentity = { sessionId: Id3, nativeSessionId: Id3, runtimeId: Id3, sampleId: Id3 };
849
+ var HostPolicySampleRequest = z5.object({ ...sampleIdentity, tool: toolInput }).strict();
850
+ var HostPolicySampleResult = z5.object({
851
+ ...sampleIdentity,
852
+ toolHash: Fingerprint,
853
+ boundary: HostPolicyBoundary,
854
+ defaultBranch: z5.string().min(1).max(255).nullable(),
855
+ safety: PolicyToolSafety
856
+ }).strict();
857
+ var PolicyEvaluateRequest = z5.object({ evaluationId: Id3, toolCallId: Id3, tool: toolInput }).strict();
858
+ var PolicyStatusRequest = z5.object({ decisionId: Id3, waitMs: z5.literal(25e3) }).strict();
859
+ var PolicyStatusResult = z5.discriminatedUnion("state", [
860
+ z5.object({ state: z5.literal("pending") }).strict(),
861
+ z5.object({ state: z5.literal("allowed") }).strict(),
862
+ z5.object({ state: z5.literal("denied"), reason: Reason }).strict(),
863
+ z5.object({ state: z5.literal("canceled"), reason: Reason }).strict()
864
+ ]);
865
+ var PolicyCancelRequest = z5.object({ decisionId: Id3 }).strict();
866
+ var PolicyCancelResult = z5.object({ state: z5.enum(["canceled", "already_resolved"]) }).strict();
867
+ var PolicyTrace = z5.object({
868
+ ruleId: Id3,
869
+ ruleRevision: Revision,
870
+ ...scopeShape,
871
+ verdict: PolicyVerdict.nullable(),
872
+ reason: Text.nullable(),
873
+ granted: z5.boolean(),
874
+ overridden: z5.boolean(),
875
+ proposedStateUpdates: PolicyCounterMap
876
+ }).strict().refine(scopeValid);
877
+ var PolicyTestResult = z5.object({
878
+ verdict: PolicyVerdict,
879
+ reason: Text.nullable(),
880
+ trace: z5.array(PolicyTrace).max(128),
881
+ proposedStateUpdates: z5.record(Id3, PolicyCounterMap),
882
+ enforcement: z5.object({
883
+ phases: z5.array(PolicyPhase),
884
+ modelRequest: z5.literal(false),
885
+ explanation: z5.string()
886
+ }).strict()
887
+ }).strict();
888
+ var CreatePolicyRuleRequest = z5.object({ ...scopeShape, ...ruleFields }).strict().refine(scopeValid);
889
+ var UpdatePolicyRuleRequest = z5.object({
890
+ expectedRevision: Revision,
891
+ name: ruleFields.name.optional(),
892
+ priority: ruleFields.priority.optional(),
893
+ enabled: z5.boolean().optional(),
894
+ phases: phases.optional(),
895
+ expression: ruleFields.expression.optional()
896
+ }).strict().refine((v) => Object.keys(v).length > 1);
897
+ var DeletePolicyRuleQuery = z5.object({ expectedRevision: Revision }).strict();
898
+ var UpdatePolicySettingsRequest = z5.object({ expectedRevision: Revision, modelClassifications: classifications }).strict();
899
+ var PolicyTestRequest = z5.object({
900
+ sessionId: Id3,
901
+ phase: PolicyPhase,
902
+ tool: toolInput.nullable(),
903
+ request: PolicyRequestContext.nullable()
904
+ }).strict().refine((v) => v.phase === "tool_call" ? v.tool !== null && v.request === null : v.tool === null && v.request !== null);
896
905
 
897
906
  // packages/protocol/dist/entities.js
898
- var Iso = z7.string();
899
- var Id5 = z7.string();
900
- var Connectivity = z7.enum(["connected", "reconnecting", "unreachable"]);
901
- var ControlMode = z7.enum(["automation", "human"]);
902
- var Platform = z7.enum(["darwin", "linux"]);
903
- var DeviceKind = z7.enum(["browser", "pwa", "terminal", "cli"]);
904
- var DiagnosticLevel = z7.enum(["info", "warning", "error"]);
907
+ var Iso = z6.string();
908
+ var Id4 = z6.string();
909
+ var Connectivity = z6.enum(["connected", "reconnecting", "unreachable"]);
910
+ var ControlMode = z6.enum(["automation", "human"]);
911
+ var Platform = z6.enum(["darwin", "linux"]);
912
+ var DeviceKind = z6.enum(["browser", "pwa", "terminal", "cli"]);
913
+ var DiagnosticLevel = z6.enum(["info", "warning", "error"]);
905
914
  var DEFAULT_WORKTREE_DIR = ".worktrees";
906
- var CoreCapabilities = z7.object({
907
- prompt: z7.boolean(),
908
- steer: z7.boolean(),
909
- followUp: z7.boolean(),
910
- abort: z7.boolean(),
911
- resume: z7.boolean(),
912
- rename: z7.boolean(),
913
- importInactive: z7.boolean(),
914
- extensionDialogs: z7.boolean(),
915
- customUi: z7.boolean(),
916
- widgetsText: z7.boolean(),
917
- widgetsComponent: z7.boolean(),
918
- tokenAccounting: z7.boolean(),
919
- costAccounting: z7.boolean()
915
+ var CoreCapabilities = z6.object({
916
+ prompt: z6.boolean(),
917
+ steer: z6.boolean(),
918
+ followUp: z6.boolean(),
919
+ abort: z6.boolean(),
920
+ resume: z6.boolean(),
921
+ rename: z6.boolean(),
922
+ importInactive: z6.boolean(),
923
+ extensionDialogs: z6.boolean(),
924
+ customUi: z6.boolean(),
925
+ widgetsText: z6.boolean(),
926
+ widgetsComponent: z6.boolean(),
927
+ tokenAccounting: z6.boolean(),
928
+ costAccounting: z6.boolean()
920
929
  });
921
930
  var CAPABILITY_KEYS = CoreCapabilities.keyof().options;
922
931
  var RuntimeCapabilities = CoreCapabilities.extend({
923
932
  /** The host runs sessions as interactive Pi in a terminal that clients can attach to. */
924
- terminal: z7.boolean().optional(),
933
+ terminal: z6.boolean().optional(),
925
934
  /** The host answers session.models, session.commands, session.setModel, session.setThinking and session.compact. */
926
- sessionControls: z7.boolean().optional(),
935
+ sessionControls: z6.boolean().optional(),
927
936
  /** The host answers session.navigate for terminal sessions. */
928
- treeNavigation: z7.boolean().optional(),
929
- agentRequests: z7.boolean().optional(),
930
- messageDelivery: z7.boolean().optional(),
931
- policies: z7.boolean().optional(),
932
- unsupported: z7.array(z7.object({ capability: z7.string(), reason: z7.string() }))
933
- });
934
- var ProjectScan = z7.object({
935
- state: z7.enum(["running", "done", "failed"]),
937
+ treeNavigation: z6.boolean().optional(),
938
+ agentRequests: z6.boolean().optional(),
939
+ messageDelivery: z6.boolean().optional(),
940
+ policies: z6.boolean().optional(),
941
+ /** Session-scoped adapter inspection and safe reload. */
942
+ adapterDevelopment: z6.boolean().optional(),
943
+ unsupported: z6.array(z6.object({ capability: z6.string(), reason: z6.string() }))
944
+ });
945
+ var ProjectScan = z6.object({
946
+ state: z6.enum(["running", "done", "failed"]),
936
947
  startedAt: Iso,
937
948
  finishedAt: Iso.nullable(),
938
949
  /** Repositories found across all folders. */
939
- repositories: z7.number().int(),
950
+ repositories: z6.number().int(),
940
951
  /** New projects created by this scan. */
941
- projectsCreated: z7.number().int(),
952
+ projectsCreated: z6.number().int(),
942
953
  /** New checkouts (including the ones of new projects). */
943
- checkoutsAdded: z7.number().int(),
954
+ checkoutsAdded: z6.number().int(),
944
955
  /** "<folder>: <message>" per folder that failed; for state "failed", the reason last. */
945
- errors: z7.array(z7.string())
956
+ errors: z6.array(z6.string())
946
957
  });
947
- var UsageWindow = z7.object({
948
- id: z7.enum(["five_hour", "weekly"]),
949
- usedPct: z7.number(),
958
+ var UsageWindow = z6.object({
959
+ id: z6.enum(["five_hour", "weekly"]),
960
+ usedPct: z6.number(),
950
961
  resetsAt: Iso.nullable()
951
962
  });
952
- var ProviderUsage = z7.object({
953
- provider: z7.enum(["anthropic", "openai-codex"]),
954
- status: z7.enum(["available", "expired", "rejected", "error"]),
955
- message: z7.string().nullable(),
956
- windows: z7.array(UsageWindow),
963
+ var ProviderUsage = z6.object({
964
+ provider: z6.enum(["anthropic", "openai-codex"]),
965
+ status: z6.enum(["available", "expired", "rejected", "error"]),
966
+ message: z6.string().nullable(),
967
+ windows: z6.array(UsageWindow),
957
968
  fetchedAt: Iso
958
969
  });
959
- var Host = z7.object({
960
- id: Id5,
961
- name: z7.string(),
970
+ var Host = z6.object({
971
+ id: Id4,
972
+ name: z6.string(),
962
973
  platform: Platform,
963
- agentVersion: z7.string(),
964
- piVersion: z7.string().nullable(),
965
- piCompatible: z7.boolean(),
974
+ agentVersion: z6.string(),
975
+ piVersion: z6.string().nullable(),
976
+ piCompatible: z6.boolean(),
966
977
  capabilities: RuntimeCapabilities.nullable(),
967
978
  connectivity: Connectivity,
968
979
  lastSeenAt: Iso.nullable(),
969
980
  revokedAt: Iso.nullable(),
970
981
  createdAt: Iso,
971
982
  /** Folders on the host whose git repositories become projects (absolute or ~/...). */
972
- projectFolders: z7.array(z7.string()).optional(),
983
+ projectFolders: z6.array(z6.string()).optional(),
973
984
  projectScan: ProjectScan.nullable().optional(),
974
985
  /** Subscription limits (host-reported, refreshed every few minutes). */
975
- usage: z7.array(ProviderUsage).optional(),
986
+ usage: z6.array(ProviderUsage).optional(),
976
987
  github: HostGitHub.optional()
977
988
  });
978
- var WorktreeDir = z7.string().min(1).refine((d) => !d.startsWith("/") && !d.includes("\\"), "must be a relative path").refine((d) => !d.split("/").includes(".."), "must stay inside the repository").refine((d) => d.split("/").every((s) => s.length > 0 && s !== "."), "must be a plain relative path");
979
- var Project = z7.object({
980
- id: Id5,
981
- name: z7.string().min(1),
982
- repoIdentity: z7.string(),
983
- defaultProfileId: Id5.nullable(),
984
- defaultHostId: Id5.nullable(),
985
- maxConcurrentRuns: z7.number().int().min(1).max(32),
986
- automationEnabled: z7.boolean(),
987
- setupCommand: z7.string().nullable(),
988
- checks: z7.array(z7.string()),
989
- workspaceSharing: z7.enum(["single_writer", "shared"]),
989
+ var WorktreeDir = z6.string().min(1).refine((d) => !d.startsWith("/") && !d.includes("\\"), "must be a relative path").refine((d) => !d.split("/").includes(".."), "must stay inside the repository").refine((d) => d.split("/").every((s) => s.length > 0 && s !== "."), "must be a plain relative path");
990
+ var Project = z6.object({
991
+ id: Id4,
992
+ name: z6.string().min(1),
993
+ repoIdentity: z6.string(),
994
+ defaultProfileId: Id4.nullable(),
995
+ defaultHostId: Id4.nullable(),
996
+ maxConcurrentRuns: z6.number().int().min(1).max(32),
997
+ automationEnabled: z6.boolean(),
998
+ setupCommand: z6.string().nullable(),
999
+ checks: z6.array(z6.string()),
1000
+ workspaceSharing: z6.enum(["single_writer", "shared"]),
990
1001
  worktreeDir: WorktreeDir.default(DEFAULT_WORKTREE_DIR),
991
1002
  createdAt: Iso,
992
1003
  updatedAt: Iso
993
1004
  });
994
- var Checkout = z7.object({
995
- id: Id5,
996
- projectId: Id5,
997
- hostId: Id5,
998
- path: z7.string(),
999
- commonDir: z7.string(),
1000
- defaultBranch: z7.string(),
1005
+ var Checkout = z6.object({
1006
+ id: Id4,
1007
+ projectId: Id4,
1008
+ hostId: Id4,
1009
+ path: z6.string(),
1010
+ commonDir: z6.string(),
1011
+ defaultBranch: z6.string(),
1001
1012
  createdAt: Iso
1002
1013
  });
1003
- var GitState = z7.object({
1004
- dirty: z7.boolean(),
1005
- changedFiles: z7.number().int(),
1006
- ahead: z7.number().int(),
1007
- behind: z7.number().int(),
1008
- unmerged: z7.boolean()
1009
- });
1010
- var Workspace = z7.object({
1011
- id: Id5,
1012
- checkoutId: Id5,
1013
- projectId: Id5,
1014
- hostId: Id5,
1015
- path: z7.string(),
1016
- branch: z7.string().nullable(),
1017
- baseBranch: z7.string().nullable(),
1018
- provenance: z7.enum(["managed", "discovered", "main"]),
1014
+ var GitState = z6.object({
1015
+ dirty: z6.boolean(),
1016
+ changedFiles: z6.number().int(),
1017
+ ahead: z6.number().int(),
1018
+ behind: z6.number().int(),
1019
+ unmerged: z6.boolean()
1020
+ });
1021
+ var Workspace = z6.object({
1022
+ id: Id4,
1023
+ checkoutId: Id4,
1024
+ projectId: Id4,
1025
+ hostId: Id4,
1026
+ path: z6.string(),
1027
+ branch: z6.string().nullable(),
1028
+ baseBranch: z6.string().nullable(),
1029
+ provenance: z6.enum(["managed", "discovered", "main"]),
1019
1030
  git: GitState,
1020
- setup: z7.object({
1021
- state: z7.enum(["none", "running", "succeeded", "failed"]),
1022
- log: z7.string()
1031
+ setup: z6.object({
1032
+ state: z6.enum(["none", "running", "succeeded", "failed"]),
1033
+ log: z6.string()
1023
1034
  }),
1024
1035
  archivedAt: Iso.nullable(),
1025
1036
  updatedAt: Iso,
1026
1037
  github: WorkspaceGitHub.optional()
1027
1038
  });
1028
- var ThinkingLevel = z7.enum(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
1029
- var SessionModel = z7.object({
1030
- provider: z7.string(),
1031
- id: z7.string(),
1032
- name: z7.string().nullable(),
1033
- contextWindow: z7.number().nullable(),
1034
- reasoning: z7.boolean(),
1039
+ var ThinkingLevel = z6.enum(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
1040
+ var SessionModel = z6.object({
1041
+ provider: z6.string(),
1042
+ id: z6.string(),
1043
+ name: z6.string().nullable(),
1044
+ contextWindow: z6.number().nullable(),
1045
+ reasoning: z6.boolean(),
1035
1046
  /** In Pi's scoped (favorite) model list; set only when Pi has one. */
1036
- scoped: z7.boolean().optional(),
1047
+ scoped: z6.boolean().optional(),
1037
1048
  /** Effort levels this model accepts, in Pi's order; ["off"] without reasoning. */
1038
- thinkingLevels: z7.array(ThinkingLevel),
1049
+ thinkingLevels: z6.array(ThinkingLevel),
1039
1050
  /** Prompt-cache lifetimes in seconds from Pi's model metadata. */
1040
- promptCache: z7.object({ short: z7.number().optional(), long: z7.number().optional() }).nullable().optional()
1051
+ promptCache: z6.object({ short: z6.number().optional(), long: z6.number().optional() }).nullable().optional()
1041
1052
  });
1042
- var SlashCommand = z7.object({
1043
- name: z7.string().min(1),
1044
- description: z7.string().nullable(),
1045
- source: z7.enum(["extension", "prompt", "skill"]),
1046
- argumentHint: z7.string().nullable().optional()
1053
+ var SlashCommand = z6.object({
1054
+ name: z6.string().min(1),
1055
+ description: z6.string().nullable(),
1056
+ source: z6.enum(["extension", "prompt", "skill"]),
1057
+ argumentHint: z6.string().nullable().optional()
1047
1058
  });
1048
- var ContextUsage = z7.object({
1059
+ var ContextUsage = z6.object({
1049
1060
  /** Estimated tokens in context; null right after compaction until the next reply. */
1050
- tokens: z7.number().nullable(),
1051
- window: z7.number(),
1052
- percent: z7.number().nullable()
1061
+ tokens: z6.number().nullable(),
1062
+ window: z6.number(),
1063
+ percent: z6.number().nullable()
1053
1064
  });
1054
1065
  var FORBIDDEN_EXTRA_ARGS = ["--mode", "--fork", "--no-session", "-e", "--extension"];
1055
- var ExtraArg = z7.string().refine((a) => a.startsWith("--") || !a.startsWith("-"), "extra args must be long flags").refine((a) => !FORBIDDEN_EXTRA_ARGS.includes(a.split("=")[0]) && !a.startsWith("--session"), "this flag is managed by Switchyard");
1056
- var Profile = z7.object({
1057
- id: Id5,
1058
- name: z7.string().min(1),
1059
- provider: z7.string().nullable(),
1060
- model: z7.string().nullable(),
1066
+ var ExtraArg = z6.string().refine((a) => a.startsWith("--") || !a.startsWith("-"), "extra args must be long flags").refine((a) => !FORBIDDEN_EXTRA_ARGS.includes(a.split("=")[0]) && !a.startsWith("--session"), "this flag is managed by Switchyard");
1067
+ var Profile = z6.object({
1068
+ id: Id4,
1069
+ name: z6.string().min(1),
1070
+ provider: z6.string().nullable(),
1071
+ model: z6.string().nullable(),
1061
1072
  thinking: ThinkingLevel.nullable(),
1062
- projectTrust: z7.enum(["ask", "approve", "ignore"]),
1063
- extraArgs: z7.array(ExtraArg),
1073
+ projectTrust: z6.enum(["ask", "approve", "ignore"]),
1074
+ extraArgs: z6.array(ExtraArg),
1064
1075
  /** "vanilla": --no-extensions --no-skills --no-prompt-templates. Undefined means "all". */
1065
- resources: z7.enum(["all", "vanilla"]).optional()
1076
+ resources: z6.enum(["all", "vanilla"]).optional()
1066
1077
  });
1067
- var ViewClient = z7.object({
1078
+ var ViewClient = z6.object({
1068
1079
  /** `${kind}:${name}@${machine}` */
1069
- id: z7.string().min(1),
1070
- kind: z7.enum(["herdr", "tmux"]),
1071
- name: z7.string().min(1),
1072
- machine: z7.string().min(1),
1080
+ id: z6.string().min(1),
1081
+ kind: z6.enum(["herdr", "tmux"]),
1082
+ name: z6.string().min(1),
1083
+ machine: z6.string().min(1),
1073
1084
  lastSeenAt: Iso
1074
1085
  });
1075
- var View = z7.object({
1076
- id: Id5,
1077
- name: z7.string().min(1).max(60),
1078
- mode: z7.enum(["all", "pinned"]),
1079
- projectIds: z7.array(z7.string()).nullable(),
1080
- hostIds: z7.array(z7.string()).nullable(),
1081
- sessionIds: z7.array(z7.string()),
1082
- clients: z7.array(ViewClient),
1086
+ var View = z6.object({
1087
+ id: Id4,
1088
+ name: z6.string().min(1).max(60),
1089
+ mode: z6.enum(["all", "pinned"]),
1090
+ projectIds: z6.array(z6.string()).nullable(),
1091
+ hostIds: z6.array(z6.string()).nullable(),
1092
+ sessionIds: z6.array(z6.string()),
1093
+ clients: z6.array(ViewClient),
1083
1094
  createdAt: Iso,
1084
1095
  updatedAt: Iso
1085
1096
  });
1086
- var RuntimeState = z7.enum([
1097
+ var RuntimeState = z6.enum([
1087
1098
  "starting",
1088
1099
  "idle",
1089
1100
  "running",
@@ -1092,141 +1103,143 @@ var RuntimeState = z7.enum([
1092
1103
  "failed",
1093
1104
  "stopped"
1094
1105
  ]);
1095
- var NativeHandle = z7.object({ sessionId: z7.string(), sessionFile: z7.string() });
1096
- var SessionStats = z7.object({
1097
- tokens: z7.number().nullable(),
1098
- costUsd: z7.number().nullable(),
1106
+ var NativeHandle = z6.object({ sessionId: z6.string(), sessionFile: z6.string() });
1107
+ var SessionStats = z6.object({
1108
+ tokens: z6.number().nullable(),
1109
+ costUsd: z6.number().nullable(),
1099
1110
  /** Completed usage, refreshed for this exact settlement; absent on older hosts or failure. */
1100
1111
  watermark: CompletedUsageWatermark.optional(),
1101
1112
  context: ContextUsage.nullable().optional()
1102
1113
  });
1103
- var PromptCacheInfo = z7.object({
1114
+ var PromptCacheInfo = z6.object({
1104
1115
  at: Iso,
1105
- provider: z7.string(),
1106
- model: z7.string(),
1107
- cacheRead: z7.number(),
1108
- cacheWrite: z7.number(),
1109
- cacheWrite1h: z7.number()
1110
- });
1111
- var Session = z7.object({
1112
- id: Id5,
1113
- title: z7.string(),
1114
- subtitle: z7.string().nullable(),
1115
- hostId: Id5,
1116
- workspaceId: Id5.nullable(),
1117
- projectId: Id5.nullable(),
1118
- cwd: z7.string(),
1116
+ provider: z6.string(),
1117
+ model: z6.string(),
1118
+ cacheRead: z6.number(),
1119
+ cacheWrite: z6.number(),
1120
+ cacheWrite1h: z6.number()
1121
+ });
1122
+ var Session = z6.object({
1123
+ id: Id4,
1124
+ title: z6.string(),
1125
+ subtitle: z6.string().nullable(),
1126
+ hostId: Id4,
1127
+ workspaceId: Id4.nullable(),
1128
+ projectId: Id4.nullable(),
1129
+ cwd: z6.string(),
1119
1130
  nativeHandle: NativeHandle.nullable(),
1120
1131
  profileSnapshot: Profile,
1121
1132
  runtime: RuntimeState,
1122
- runtimeDetail: z7.string().nullable(),
1133
+ runtimeDetail: z6.string().nullable(),
1123
1134
  connectivity: Connectivity,
1124
- runId: Id5.nullable(),
1125
- taskId: Id5.nullable(),
1126
- provenance: z7.enum(["created", "imported", "subagent"]),
1127
- readOnly: z7.boolean(),
1135
+ runId: Id4.nullable(),
1136
+ taskId: Id4.nullable(),
1137
+ provenance: z6.enum(["created", "imported", "subagent"]),
1138
+ readOnly: z6.boolean(),
1128
1139
  lastActivityAt: Iso,
1129
1140
  archivedAt: Iso.nullable(),
1130
- queue: z7.object({ steering: z7.array(z7.string()), followUp: z7.array(z7.string()) }),
1141
+ queue: z6.object({ steering: z6.array(z6.string()), followUp: z6.array(z6.string()) }),
1131
1142
  stats: SessionStats.nullable(),
1132
1143
  /** The live model (host-owned; last known when stopped). */
1133
1144
  model: SessionModel.nullable().optional(),
1134
1145
  /** The live effort (Pi's thinking level). */
1135
1146
  thinking: ThinkingLevel.nullable().optional(),
1136
1147
  /** Pi is compacting the context. */
1137
- compacting: z7.boolean().optional(),
1138
- lastAssistantText: z7.string().nullable(),
1148
+ compacting: z6.boolean().optional(),
1149
+ lastAssistantText: z6.string().nullable(),
1139
1150
  createdAt: Iso,
1140
1151
  /** A live terminal session: `switchyard tui` can attach to its Pi terminal. */
1141
- terminal: z7.boolean().optional(),
1152
+ terminal: z6.boolean().optional(),
1142
1153
  /** Set when the session finished or failed with nobody viewing it; cleared when viewed (coordinator-owned). */
1143
1154
  unreadSince: Iso.nullable().optional(),
1155
+ /** Identity of the adapter presentation currently installed on the host. */
1156
+ adapterGeneration: z6.string().uuid().optional(),
1144
1157
  /** Bumped when the transcript is rebuilt (rewind); clients drop cached copies (coordinator-owned). */
1145
- transcriptEpoch: z7.number().int().min(0).optional(),
1146
- bridge: z7.object({
1147
- version: z7.literal(1),
1148
- runtimeId: Id5,
1149
- nativeSessionId: Id5,
1158
+ transcriptEpoch: z6.number().int().min(0).optional(),
1159
+ bridge: z6.object({
1160
+ version: z6.literal(1),
1161
+ runtimeId: Id4,
1162
+ nativeSessionId: Id4,
1150
1163
  /** Host-generated local-controller identity, not Pi's private binding credential. */
1151
- controllerEpoch: Id5.optional(),
1152
- agentTools: z7.boolean(),
1153
- messageDelivery: z7.boolean(),
1154
- policyState: z7.enum(["initializing", "active", "unsupported", "lost"]),
1155
- policyPhases: z7.array(PolicyPhase)
1164
+ controllerEpoch: Id4.optional(),
1165
+ agentTools: z6.boolean(),
1166
+ messageDelivery: z6.boolean(),
1167
+ policyState: z6.enum(["initializing", "active", "unsupported", "lost"]),
1168
+ policyPhases: z6.array(PolicyPhase)
1156
1169
  }).optional(),
1157
1170
  /** Last assistant message's cache usage (host-owned). */
1158
1171
  promptCache: PromptCacheInfo.nullable().optional(),
1159
1172
  /** Warn before the prompt cache expires; non-null means on (coordinator-owned). */
1160
- cacheAlert: z7.object({ ttlSec: z7.number().int().min(60).max(86400).nullable(), warnedFor: Iso.nullable() }).nullable().optional()
1173
+ cacheAlert: z6.object({ ttlSec: z6.number().int().min(60).max(86400).nullable(), warnedFor: Iso.nullable() }).nullable().optional()
1161
1174
  });
1162
- var ContinuationPolicy = z7.discriminatedUnion("enabled", [
1163
- z7.object({ enabled: z7.literal(false) }),
1164
- z7.object({
1165
- enabled: z7.literal(true),
1166
- objective: z7.string().min(1),
1167
- maxContinuations: z7.number().int().min(1).max(50),
1168
- maxElapsedMinutes: z7.number().int().min(1).max(1440),
1169
- maxTokens: z7.number().int().positive().nullable(),
1170
- maxCostUsd: z7.number().positive().nullable()
1175
+ var ContinuationPolicy = z6.discriminatedUnion("enabled", [
1176
+ z6.object({ enabled: z6.literal(false) }),
1177
+ z6.object({
1178
+ enabled: z6.literal(true),
1179
+ objective: z6.string().min(1),
1180
+ maxContinuations: z6.number().int().min(1).max(50),
1181
+ maxElapsedMinutes: z6.number().int().min(1).max(1440),
1182
+ maxTokens: z6.number().int().positive().nullable(),
1183
+ maxCostUsd: z6.number().positive().nullable()
1171
1184
  })
1172
1185
  ]);
1173
- var CompletionPolicy = z7.object({
1174
- checks: z7.array(z7.string()).nullable(),
1175
- requireHumanReview: z7.boolean()
1186
+ var CompletionPolicy = z6.object({
1187
+ checks: z6.array(z6.string()).nullable(),
1188
+ requireHumanReview: z6.boolean()
1176
1189
  });
1177
- var WorkspacePolicy = z7.discriminatedUnion("mode", [
1178
- z7.object({
1179
- mode: z7.literal("new_worktree"),
1180
- branch: z7.string().nullable(),
1181
- base: z7.string().nullable()
1190
+ var WorkspacePolicy = z6.discriminatedUnion("mode", [
1191
+ z6.object({
1192
+ mode: z6.literal("new_worktree"),
1193
+ branch: z6.string().nullable(),
1194
+ base: z6.string().nullable()
1182
1195
  }),
1183
- z7.object({ mode: z7.literal("existing"), workspaceId: Id5 })
1196
+ z6.object({ mode: z6.literal("existing"), workspaceId: Id4 })
1184
1197
  ]);
1185
- var TaskPolicy = z7.object({
1186
- hostId: Id5.nullable(),
1187
- profileId: Id5.nullable(),
1198
+ var TaskPolicy = z6.object({
1199
+ hostId: Id4.nullable(),
1200
+ profileId: Id4.nullable(),
1188
1201
  workspace: WorkspacePolicy,
1189
1202
  continuation: ContinuationPolicy,
1190
1203
  completion: CompletionPolicy
1191
1204
  });
1192
- var TaskState = z7.enum(["backlog", "ready", "in_progress", "review", "done", "canceled"]);
1193
- var Priority = z7.union([z7.literal(0), z7.literal(1), z7.literal(2), z7.literal(3)]);
1194
- var TaskOrigin = z7.discriminatedUnion("kind", [
1195
- z7.object({ kind: z7.literal("manual") }),
1196
- z7.object({
1197
- kind: z7.literal("automation"),
1198
- automationId: Id5,
1199
- occurrenceId: Id5,
1200
- routine: z7.boolean()
1205
+ var TaskState = z6.enum(["backlog", "ready", "in_progress", "review", "done", "canceled"]);
1206
+ var Priority = z6.union([z6.literal(0), z6.literal(1), z6.literal(2), z6.literal(3)]);
1207
+ var TaskOrigin = z6.discriminatedUnion("kind", [
1208
+ z6.object({ kind: z6.literal("manual") }),
1209
+ z6.object({
1210
+ kind: z6.literal("automation"),
1211
+ automationId: Id4,
1212
+ occurrenceId: Id4,
1213
+ routine: z6.boolean()
1201
1214
  })
1202
1215
  ]);
1203
- var Task = z7.object({
1204
- id: Id5,
1205
- projectId: Id5,
1206
- title: z7.string().min(1),
1207
- objective: z7.string(),
1208
- acceptanceCriteria: z7.array(z7.string()),
1209
- dependencies: z7.array(Id5),
1216
+ var Task = z6.object({
1217
+ id: Id4,
1218
+ projectId: Id4,
1219
+ title: z6.string().min(1),
1220
+ objective: z6.string(),
1221
+ acceptanceCriteria: z6.array(z6.string()),
1222
+ dependencies: z6.array(Id4),
1210
1223
  priority: Priority,
1211
- position: z7.number(),
1224
+ position: z6.number(),
1212
1225
  state: TaskState,
1213
- blocked: z7.object({ reason: z7.string() }).nullable(),
1226
+ blocked: z6.object({ reason: z6.string() }).nullable(),
1214
1227
  notBefore: Iso.nullable(),
1215
1228
  policy: TaskPolicy,
1216
1229
  origin: TaskOrigin,
1217
- groupingKey: z7.string().nullable(),
1218
- parentTaskId: Id5.nullable().optional(),
1219
- agentOrigin: z7.object({ sessionId: Id5, toolCallId: Id5 }).optional(),
1230
+ groupingKey: z6.string().nullable(),
1231
+ parentTaskId: Id4.nullable().optional(),
1232
+ agentOrigin: z6.object({ sessionId: Id4, toolCallId: Id4 }).optional(),
1220
1233
  githubIssue: GitHubIssue.optional(),
1221
- currentRunId: Id5.nullable(),
1222
- sessionId: Id5.nullable(),
1223
- review: z7.object({ feedback: z7.array(z7.string()), changesRequested: z7.boolean() }),
1224
- hiddenFromBoard: z7.boolean(),
1234
+ currentRunId: Id4.nullable(),
1235
+ sessionId: Id4.nullable(),
1236
+ review: z6.object({ feedback: z6.array(z6.string()), changesRequested: z6.boolean() }),
1237
+ hiddenFromBoard: z6.boolean(),
1225
1238
  lastActivityAt: Iso,
1226
1239
  createdAt: Iso,
1227
1240
  updatedAt: Iso
1228
1241
  });
1229
- var RunState = z7.enum([
1242
+ var RunState = z6.enum([
1230
1243
  "queued",
1231
1244
  "dispatching",
1232
1245
  "uncertain",
@@ -1238,79 +1251,79 @@ var RunState = z7.enum([
1238
1251
  "interrupted",
1239
1252
  "canceled"
1240
1253
  ]);
1241
- var CheckResult = z7.object({
1242
- command: z7.string(),
1243
- exitCode: z7.number().int().nullable(),
1244
- outputTail: z7.string()
1245
- });
1246
- var Run = z7.object({
1247
- id: Id5,
1248
- taskId: Id5,
1249
- sessionId: Id5.nullable(),
1250
- hostId: Id5.nullable(),
1251
- dispatchKey: z7.string(),
1252
- attempt: z7.number().int().min(1),
1254
+ var CheckResult = z6.object({
1255
+ command: z6.string(),
1256
+ exitCode: z6.number().int().nullable(),
1257
+ outputTail: z6.string()
1258
+ });
1259
+ var Run = z6.object({
1260
+ id: Id4,
1261
+ taskId: Id4,
1262
+ sessionId: Id4.nullable(),
1263
+ hostId: Id4.nullable(),
1264
+ dispatchKey: z6.string(),
1265
+ attempt: z6.number().int().min(1),
1253
1266
  state: RunState,
1254
1267
  controlMode: ControlMode,
1255
- controlRevision: z7.number().int().min(1),
1256
- continuationsUsed: z7.number().int().min(0),
1257
- infraRetries: z7.number().int().min(0),
1268
+ controlRevision: z6.number().int().min(1),
1269
+ continuationsUsed: z6.number().int().min(0),
1270
+ infraRetries: z6.number().int().min(0),
1258
1271
  nextAttemptAt: Iso.nullable(),
1259
1272
  startedAt: Iso.nullable(),
1260
1273
  endedAt: Iso.nullable(),
1261
- outcome: z7.object({
1262
- kind: z7.enum(["review", "failed", "blocked", "no_change", "canceled"]),
1263
- summary: z7.string()
1274
+ outcome: z6.object({
1275
+ kind: z6.enum(["review", "failed", "blocked", "no_change", "canceled"]),
1276
+ summary: z6.string()
1264
1277
  }).nullable(),
1265
1278
  limits: ContinuationPolicy,
1266
- usage: z7.object({
1267
- tokens: z7.number().nullable(),
1268
- costUsd: z7.number().nullable(),
1269
- accounting: z7.enum(["available", "unavailable"]),
1270
- note: z7.string().nullable()
1279
+ usage: z6.object({
1280
+ tokens: z6.number().nullable(),
1281
+ costUsd: z6.number().nullable(),
1282
+ accounting: z6.enum(["available", "unavailable"]),
1283
+ note: z6.string().nullable()
1271
1284
  }),
1272
- checks: z7.array(CheckResult),
1285
+ checks: z6.array(CheckResult),
1273
1286
  createdAt: Iso,
1274
1287
  updatedAt: Iso
1275
1288
  });
1276
- var Trigger = z7.discriminatedUnion("kind", [
1277
- z7.object({ kind: z7.literal("manual") }),
1278
- z7.object({ kind: z7.literal("once"), at: Iso }),
1279
- z7.object({ kind: z7.literal("cron"), expr: z7.string().min(1), timezone: z7.string().min(1) }),
1280
- z7.object({ kind: z7.literal("webhook") }),
1281
- z7.object({ kind: z7.literal("dependency"), taskId: Id5 })
1289
+ var Trigger = z6.discriminatedUnion("kind", [
1290
+ z6.object({ kind: z6.literal("manual") }),
1291
+ z6.object({ kind: z6.literal("once"), at: Iso }),
1292
+ z6.object({ kind: z6.literal("cron"), expr: z6.string().min(1), timezone: z6.string().min(1) }),
1293
+ z6.object({ kind: z6.literal("webhook") }),
1294
+ z6.object({ kind: z6.literal("dependency"), taskId: Id4 })
1282
1295
  ]);
1283
- var TaskTemplate = z7.object({
1284
- title: z7.string().min(1),
1285
- objective: z7.string(),
1286
- acceptanceCriteria: z7.array(z7.string()),
1296
+ var TaskTemplate = z6.object({
1297
+ title: z6.string().min(1),
1298
+ objective: z6.string(),
1299
+ acceptanceCriteria: z6.array(z6.string()),
1287
1300
  priority: Priority
1288
1301
  });
1289
- var Automation = z7.object({
1290
- id: Id5,
1291
- name: z7.string().min(1),
1292
- enabled: z7.boolean(),
1293
- projectId: Id5,
1302
+ var Automation = z6.object({
1303
+ id: Id4,
1304
+ name: z6.string().min(1),
1305
+ enabled: z6.boolean(),
1306
+ projectId: Id4,
1294
1307
  trigger: Trigger,
1295
- filters: z7.array(z7.object({ path: z7.string(), equals: z7.string() })),
1308
+ filters: z6.array(z6.object({ path: z6.string(), equals: z6.string() })),
1296
1309
  template: TaskTemplate,
1297
- hostId: Id5.nullable(),
1298
- profileId: Id5.nullable(),
1299
- mode: z7.enum(["fresh", "continue", "watch"]),
1300
- groupingKey: z7.string().nullable(),
1301
- overlap: z7.enum(["skip", "queue_one", "append"]),
1302
- missed: z7.enum(["skip", "run_once"]),
1310
+ hostId: Id4.nullable(),
1311
+ profileId: Id4.nullable(),
1312
+ mode: z6.enum(["fresh", "continue", "watch"]),
1313
+ groupingKey: z6.string().nullable(),
1314
+ overlap: z6.enum(["skip", "queue_one", "append"]),
1315
+ missed: z6.enum(["skip", "run_once"]),
1303
1316
  continuation: ContinuationPolicy,
1304
1317
  completion: CompletionPolicy,
1305
1318
  nextAt: Iso.nullable(),
1306
1319
  lastEvaluatedAt: Iso.nullable(),
1307
- lastOutcome: z7.string().nullable(),
1308
- failureCount: z7.number().int().min(0),
1309
- webhookTokenSet: z7.boolean(),
1320
+ lastOutcome: z6.string().nullable(),
1321
+ failureCount: z6.number().int().min(0),
1322
+ webhookTokenSet: z6.boolean(),
1310
1323
  createdAt: Iso,
1311
1324
  updatedAt: Iso
1312
1325
  });
1313
- var OccurrenceState = z7.enum([
1326
+ var OccurrenceState = z6.enum([
1314
1327
  "fired",
1315
1328
  "skipped_overlap",
1316
1329
  "skipped_missed",
@@ -1319,39 +1332,39 @@ var OccurrenceState = z7.enum([
1319
1332
  "failed",
1320
1333
  "filtered"
1321
1334
  ]);
1322
- var Occurrence = z7.object({
1323
- id: Id5,
1324
- automationId: Id5,
1325
- key: z7.string(),
1335
+ var Occurrence = z6.object({
1336
+ id: Id4,
1337
+ automationId: Id4,
1338
+ key: z6.string(),
1326
1339
  scheduledFor: Iso.nullable(),
1327
1340
  state: OccurrenceState,
1328
- taskId: Id5.nullable(),
1329
- reason: z7.string().nullable(),
1330
- outcome: z7.string().nullable(),
1341
+ taskId: Id4.nullable(),
1342
+ reason: z6.string().nullable(),
1343
+ outcome: z6.string().nullable(),
1331
1344
  createdAt: Iso
1332
1345
  });
1333
- var InteractionState = z7.preprocess((v) => v === "cancelled" ? "canceled" : v, z7.enum(["pending", "resolved", "expired", "canceled", "unsupported"]));
1334
- var Interaction = z7.object({
1335
- id: Id5,
1336
- sessionId: Id5,
1337
- revision: z7.number().int().min(1),
1338
- source: z7.discriminatedUnion("kind", [
1339
- z7.object({
1340
- kind: z7.literal("extension_ui"),
1341
- method: z7.enum(["select", "confirm", "input", "editor"]),
1342
- piRequestIds: z7.array(z7.string())
1346
+ var InteractionState = z6.preprocess((v) => v === "cancelled" ? "canceled" : v, z6.enum(["pending", "resolved", "expired", "canceled", "unsupported"]));
1347
+ var Interaction = z6.object({
1348
+ id: Id4,
1349
+ sessionId: Id4,
1350
+ revision: z6.number().int().min(1),
1351
+ source: z6.discriminatedUnion("kind", [
1352
+ z6.object({
1353
+ kind: z6.literal("extension_ui"),
1354
+ method: z6.enum(["select", "confirm", "input", "editor"]),
1355
+ piRequestIds: z6.array(z6.string())
1343
1356
  }),
1344
- z7.object({ kind: z7.literal("unsupported_custom"), title: z7.string().nullable() })
1357
+ z6.object({ kind: z6.literal("unsupported_custom"), title: z6.string().nullable() })
1345
1358
  ]),
1346
- adapterId: z7.string().nullable(),
1359
+ adapterId: z6.string().nullable(),
1347
1360
  permission: PolicyPermission.optional(),
1348
- title: z7.string(),
1361
+ title: z6.string(),
1349
1362
  presentation: UINodeSchema,
1350
1363
  state: InteractionState,
1351
- resolution: z7.object({ by: z7.string(), summary: z7.string(), at: Iso }).nullable(),
1364
+ resolution: z6.object({ by: z6.string(), summary: z6.string(), at: Iso }).nullable(),
1352
1365
  createdAt: Iso
1353
1366
  });
1354
- var AttentionReason = z7.enum([
1367
+ var AttentionReason = z6.enum([
1355
1368
  "needs_input",
1356
1369
  "failed",
1357
1370
  "ready_for_review",
@@ -1359,203 +1372,545 @@ var AttentionReason = z7.enum([
1359
1372
  "host_unreachable",
1360
1373
  "cache_expiring"
1361
1374
  ]);
1362
- var AttentionItem = z7.object({
1363
- id: Id5,
1364
- sessionId: Id5.nullable(),
1365
- taskId: Id5.nullable(),
1366
- projectId: Id5.nullable(),
1375
+ var AttentionItem = z6.object({
1376
+ id: Id4,
1377
+ sessionId: Id4.nullable(),
1378
+ taskId: Id4.nullable(),
1379
+ projectId: Id4.nullable(),
1367
1380
  reason: AttentionReason,
1368
- severity: z7.enum(["info", "warning", "critical"]),
1369
- summary: z7.string(),
1370
- interactionId: Id5.nullable(),
1371
- deepLink: z7.string(),
1381
+ severity: z6.enum(["info", "warning", "critical"]),
1382
+ summary: z6.string(),
1383
+ interactionId: Id4.nullable(),
1384
+ deepLink: z6.string(),
1372
1385
  acknowledgedAt: Iso.nullable(),
1373
1386
  resolvedAt: Iso.nullable(),
1374
1387
  createdAt: Iso
1375
1388
  });
1376
- var Device = z7.object({
1377
- id: Id5,
1378
- name: z7.string(),
1389
+ var Device = z6.object({
1390
+ id: Id4,
1391
+ name: z6.string(),
1379
1392
  kind: DeviceKind,
1380
1393
  createdAt: Iso,
1381
1394
  lastSeenAt: Iso.nullable(),
1382
1395
  revokedAt: Iso.nullable(),
1383
- push: z7.object({
1384
- subscribed: z7.boolean(),
1385
- permission: z7.enum(["granted", "denied", "default", "unknown"])
1396
+ push: z6.object({
1397
+ subscribed: z6.boolean(),
1398
+ permission: z6.enum(["granted", "denied", "default", "unknown"])
1386
1399
  }),
1387
- preferredMobile: z7.boolean(),
1388
- enrolledVia: z7.enum(["enrollment", "passkey", "oidc", "admin", "approval"]).default("enrollment")
1389
- });
1390
- var ToolItemData = z7.object({
1391
- toolCallId: z7.string(),
1392
- name: z7.string(),
1393
- status: z7.enum(["running", "ok", "error"]),
1394
- args: z7.unknown(),
1395
- summary: z7.string(),
1396
- output: z7.string(),
1400
+ preferredMobile: z6.boolean(),
1401
+ enrolledVia: z6.enum(["enrollment", "passkey", "oidc", "admin", "approval"]).default("enrollment")
1402
+ });
1403
+ var ToolItemData = z6.object({
1404
+ toolCallId: z6.string(),
1405
+ name: z6.string(),
1406
+ status: z6.enum(["running", "ok", "error"]),
1407
+ args: z6.unknown(),
1408
+ summary: z6.string(),
1409
+ output: z6.string(),
1397
1410
  startedAt: Iso,
1398
- durationMs: z7.number().nullable(),
1411
+ durationMs: z6.number().nullable(),
1399
1412
  card: UINodeSchema.nullable(),
1400
- adapterId: z7.string().nullable()
1413
+ adapterId: z6.string().nullable(),
1414
+ adapterGeneration: z6.string().uuid().optional()
1401
1415
  });
1402
- var TranscriptItem = z7.discriminatedUnion("kind", [
1403
- z7.object({
1404
- id: Id5,
1405
- sessionId: Id5,
1406
- order: z7.number().int(),
1416
+ var TranscriptItem = z6.discriminatedUnion("kind", [
1417
+ z6.object({
1418
+ id: Id4,
1419
+ sessionId: Id4,
1420
+ order: z6.number().int(),
1407
1421
  at: Iso,
1408
- kind: z7.literal("user"),
1409
- data: z7.object({
1410
- text: z7.string(),
1411
- images: z7.number().int().optional(),
1422
+ kind: z6.literal("user"),
1423
+ data: z6.object({
1424
+ text: z6.string(),
1425
+ images: z6.number().int().optional(),
1412
1426
  /** Pi session entry id, for rewind and fork from this message. */
1413
- entryId: z7.string().optional()
1427
+ entryId: z6.string().optional()
1414
1428
  })
1415
1429
  }),
1416
- z7.object({
1417
- id: Id5,
1418
- sessionId: Id5,
1419
- order: z7.number().int(),
1430
+ z6.object({
1431
+ id: Id4,
1432
+ sessionId: Id4,
1433
+ order: z6.number().int(),
1420
1434
  at: Iso,
1421
- kind: z7.literal("assistant"),
1422
- data: z7.object({ text: z7.string(), streaming: z7.boolean().optional() })
1435
+ kind: z6.literal("assistant"),
1436
+ data: z6.object({ text: z6.string(), streaming: z6.boolean().optional() })
1423
1437
  }),
1424
- z7.object({
1425
- id: Id5,
1426
- sessionId: Id5,
1427
- order: z7.number().int(),
1438
+ z6.object({
1439
+ id: Id4,
1440
+ sessionId: Id4,
1441
+ order: z6.number().int(),
1428
1442
  at: Iso,
1429
- kind: z7.literal("thinking"),
1430
- data: z7.object({ text: z7.string() })
1443
+ kind: z6.literal("thinking"),
1444
+ data: z6.object({ text: z6.string() })
1431
1445
  }),
1432
- z7.object({
1433
- id: Id5,
1434
- sessionId: Id5,
1435
- order: z7.number().int(),
1446
+ z6.object({
1447
+ id: Id4,
1448
+ sessionId: Id4,
1449
+ order: z6.number().int(),
1436
1450
  at: Iso,
1437
- kind: z7.literal("tool"),
1451
+ kind: z6.literal("tool"),
1438
1452
  data: ToolItemData
1439
1453
  }),
1440
- z7.object({
1441
- id: Id5,
1442
- sessionId: Id5,
1443
- order: z7.number().int(),
1454
+ z6.object({
1455
+ id: Id4,
1456
+ sessionId: Id4,
1457
+ order: z6.number().int(),
1444
1458
  at: Iso,
1445
- kind: z7.literal("notice"),
1446
- data: z7.object({
1459
+ kind: z6.literal("notice"),
1460
+ data: z6.object({
1447
1461
  level: DiagnosticLevel,
1448
- text: z7.string(),
1449
- customType: z7.string().min(1).max(200).optional(),
1462
+ text: z6.string(),
1463
+ customType: z6.string().min(1).max(200).optional(),
1450
1464
  card: UINodeSchema.optional(),
1451
- adapterId: z7.string().optional()
1465
+ adapterId: z6.string().optional(),
1466
+ adapterGeneration: z6.string().uuid().optional()
1452
1467
  }).refine((data) => !data.card || !!data.adapterId, "Card requires adapterId")
1453
1468
  }),
1454
- z7.object({
1455
- id: Id5,
1456
- sessionId: Id5,
1457
- order: z7.number().int(),
1469
+ z6.object({
1470
+ id: Id4,
1471
+ sessionId: Id4,
1472
+ order: z6.number().int(),
1458
1473
  at: Iso,
1459
- kind: z7.literal("interaction"),
1460
- data: z7.object({ interactionId: Id5 })
1474
+ kind: z6.literal("interaction"),
1475
+ data: z6.object({ interactionId: Id4 })
1461
1476
  }),
1462
- z7.object({
1463
- id: Id5,
1464
- sessionId: Id5,
1465
- order: z7.number().int(),
1477
+ z6.object({
1478
+ id: Id4,
1479
+ sessionId: Id4,
1480
+ order: z6.number().int(),
1466
1481
  at: Iso,
1467
- kind: z7.literal("subagent"),
1468
- data: z7.object({
1469
- runId: z7.string(),
1470
- label: z7.string(),
1471
- status: z7.string(),
1472
- sessionFile: z7.string().nullable(),
1473
- linkedSessionId: Id5.nullable()
1482
+ kind: z6.literal("subagent"),
1483
+ data: z6.object({
1484
+ runId: z6.string(),
1485
+ label: z6.string(),
1486
+ status: z6.string(),
1487
+ sessionFile: z6.string().nullable(),
1488
+ linkedSessionId: Id4.nullable()
1474
1489
  })
1475
1490
  }),
1476
- z7.object({
1477
- id: Id5,
1478
- sessionId: Id5,
1479
- order: z7.number().int(),
1491
+ z6.object({
1492
+ id: Id4,
1493
+ sessionId: Id4,
1494
+ order: z6.number().int(),
1480
1495
  at: Iso,
1481
- kind: z7.literal("system"),
1482
- data: z7.object({ text: z7.string(), suggestion: z7.boolean().optional() })
1496
+ kind: z6.literal("system"),
1497
+ data: z6.object({ text: z6.string(), suggestion: z6.boolean().optional() })
1483
1498
  })
1484
1499
  ]);
1485
- var Panel = z7.object({
1486
- sessionId: Id5,
1487
- adapterId: z7.string(),
1488
- slot: z7.string(),
1489
- title: z7.string(),
1500
+ var Panel = z6.object({
1501
+ sessionId: Id4,
1502
+ adapterId: z6.string(),
1503
+ slot: z6.string(),
1504
+ title: z6.string(),
1490
1505
  node: UINodeSchema.nullable(),
1491
- webRenderer: z7.boolean(),
1492
- mobileFallback: z7.string().nullable(),
1506
+ webRenderer: z6.boolean(),
1507
+ mobileFallback: z6.string().nullable(),
1493
1508
  contribution: ContributionDescriptor.optional(),
1494
- state: z7.unknown().optional(),
1509
+ state: z6.unknown().optional(),
1510
+ adapterGeneration: z6.string().uuid().optional(),
1495
1511
  updatedAt: Iso
1496
1512
  });
1497
- var Diagnostic = z7.object({
1498
- sessionId: Id5.nullable(),
1499
- adapterId: z7.string().nullable(),
1513
+ var Diagnostic = z6.object({
1514
+ sessionId: Id4.nullable(),
1515
+ adapterId: z6.string().nullable(),
1500
1516
  level: DiagnosticLevel,
1501
- message: z7.string(),
1517
+ message: z6.string(),
1502
1518
  at: Iso
1503
1519
  });
1504
- var AdapterInfo = z7.object({
1505
- id: z7.string(),
1506
- version: z7.string(),
1507
- tier: z7.enum(["project", "owner", "plugin", "bundled"]),
1508
- target: z7.object({
1509
- extension: z7.string(),
1510
- versionRange: z7.string(),
1511
- testedVersions: z7.array(z7.string())
1520
+ var AdapterInfo = z6.object({
1521
+ id: z6.string(),
1522
+ version: z6.string(),
1523
+ tier: z6.enum(["project", "owner", "plugin", "bundled"]),
1524
+ target: z6.object({
1525
+ extension: z6.string(),
1526
+ versionRange: z6.string(),
1527
+ testedVersions: z6.array(z6.string())
1512
1528
  }),
1513
- capabilities: z7.array(z7.string()),
1514
- webRenderer: z7.boolean(),
1515
- status: z7.enum(["active", "disabled", "error"]),
1516
- detail: z7.string().nullable()
1517
- });
1518
- var Passkey = z7.object({
1519
- id: z7.string(),
1520
- name: z7.string(),
1529
+ capabilities: z6.array(z6.string()),
1530
+ webRenderer: z6.boolean(),
1531
+ status: z6.enum(["active", "disabled", "error"]),
1532
+ detail: z6.string().nullable()
1533
+ });
1534
+ var Passkey = z6.object({
1535
+ id: z6.string(),
1536
+ name: z6.string(),
1521
1537
  createdAt: Iso,
1522
1538
  lastUsedAt: Iso.nullable(),
1523
- transports: z7.array(z7.string())
1539
+ transports: z6.array(z6.string())
1540
+ });
1541
+
1542
+ // packages/protocol/dist/adapter-preview.js
1543
+ var ADAPTER_PREVIEW_MAX_BYTES = 1024 * 1024;
1544
+ var ADAPTER_PREVIEW_MAX_STEPS = 200;
1545
+ var ADAPTER_PREVIEW_SESSION_ID = "ses_adapter_preview";
1546
+ function bounded(input, ctx) {
1547
+ try {
1548
+ boundContributionJson(input, ADAPTER_PREVIEW_MAX_BYTES);
1549
+ return input;
1550
+ } catch (error) {
1551
+ ctx.addIssue({ code: "custom", message: error.message });
1552
+ return z7.NEVER;
1553
+ }
1554
+ }
1555
+ var Id5 = z7.string().min(1).max(200);
1556
+ var Text2 = z7.string().max(64 * 1024);
1557
+ var Tool = { toolCallId: Id5, name: Id5, args: z7.unknown() };
1558
+ var DialogCommon = { id: Id5, title: Text2 };
1559
+ var AdapterPreviewPiUiRequestSchema = z7.discriminatedUnion("method", [
1560
+ z7.object({
1561
+ ...DialogCommon,
1562
+ method: z7.literal("select"),
1563
+ options: z7.array(Text2).max(200),
1564
+ timeout: z7.number().nonnegative().optional()
1565
+ }).strict(),
1566
+ z7.object({
1567
+ ...DialogCommon,
1568
+ method: z7.literal("confirm"),
1569
+ message: Text2,
1570
+ timeout: z7.number().nonnegative().optional()
1571
+ }).strict(),
1572
+ z7.object({
1573
+ ...DialogCommon,
1574
+ method: z7.literal("input"),
1575
+ placeholder: Text2.optional(),
1576
+ timeout: z7.number().nonnegative().optional()
1577
+ }).strict(),
1578
+ z7.object({ ...DialogCommon, method: z7.literal("editor"), prefill: Text2.optional() }).strict()
1579
+ ]);
1580
+ var AdapterPreviewStepSchema = z7.discriminatedUnion("kind", [
1581
+ z7.object({ kind: z7.literal("restore") }).strict(),
1582
+ z7.object({ kind: z7.literal("toolStart"), data: z7.object(Tool).strict() }).strict(),
1583
+ z7.object({
1584
+ kind: z7.literal("toolUpdate"),
1585
+ data: z7.object({ ...Tool, partialResult: z7.unknown(), details: z7.unknown().optional() }).strict()
1586
+ }).strict(),
1587
+ z7.object({
1588
+ kind: z7.literal("toolEnd"),
1589
+ data: z7.object({
1590
+ ...Tool,
1591
+ result: z7.unknown(),
1592
+ isError: z7.boolean(),
1593
+ details: z7.unknown().optional()
1594
+ }).strict()
1595
+ }).strict(),
1596
+ z7.object({
1597
+ kind: z7.literal("status"),
1598
+ data: z7.object({ key: Id5, text: Text2.optional() }).strict()
1599
+ }).strict(),
1600
+ z7.object({
1601
+ kind: z7.literal("widget"),
1602
+ data: z7.object({ key: Id5, lines: z7.array(Text2).max(200).optional() }).strict()
1603
+ }).strict(),
1604
+ z7.object({ kind: z7.literal("dialog"), data: AdapterPreviewPiUiRequestSchema }).strict(),
1605
+ z7.object({
1606
+ kind: z7.literal("answer"),
1607
+ data: z7.object({ requestId: Id5, response: InteractionResponseSchema }).strict()
1608
+ }).strict(),
1609
+ z7.object({
1610
+ kind: z7.literal("customMessage"),
1611
+ data: z7.object({
1612
+ customType: Id5,
1613
+ content: z7.unknown(),
1614
+ display: z7.boolean().optional(),
1615
+ details: z7.unknown().optional()
1616
+ }).strict()
1617
+ }).strict(),
1618
+ z7.object({
1619
+ kind: z7.literal("action"),
1620
+ data: z7.object({ actionId: Id5, payload: z7.unknown() }).strict()
1621
+ }).strict()
1622
+ ]);
1623
+ var AdapterPreviewFixtureSchema = z7.unknown().transform(bounded).pipe(z7.object({
1624
+ version: z7.literal(1),
1625
+ name: z7.string().min(1).max(200),
1626
+ initialState: z7.record(z7.string(), z7.record(z7.string(), z7.unknown())).optional(),
1627
+ steps: z7.array(AdapterPreviewStepSchema).max(ADAPTER_PREVIEW_MAX_STEPS)
1628
+ }).strict());
1629
+ var PortableNode = z7.unknown().transform((input, ctx) => {
1630
+ try {
1631
+ return validateUINode(input);
1632
+ } catch (error) {
1633
+ ctx.addIssue({ code: "custom", message: error.message });
1634
+ return z7.NEVER;
1635
+ }
1636
+ });
1637
+ var PreviewPanel = Panel.extend({ webRenderer: z7.literal(false) }).superRefine((panel, ctx) => {
1638
+ try {
1639
+ if (panel.sessionId !== ADAPTER_PREVIEW_SESSION_ID)
1640
+ throw new Error("Preview panels must use the fake preview session");
1641
+ if (panel.node !== null)
1642
+ validateUINode(panel.node);
1643
+ if (panel.contribution) {
1644
+ const { id, ...descriptor } = panel.contribution;
1645
+ if (panel.slot !== contributionSlot(id))
1646
+ throw new Error("Contribution slot does not match its id");
1647
+ validateContribution(id, {
1648
+ ...descriptor,
1649
+ title: panel.title,
1650
+ node: panel.node,
1651
+ mobileFallback: panel.mobileFallback,
1652
+ ...panel.state === void 0 ? {} : { state: panel.state }
1653
+ });
1654
+ }
1655
+ } catch (error) {
1656
+ ctx.addIssue({ code: "custom", message: error.message });
1657
+ }
1658
+ });
1659
+ var AdapterPreviewSchema = z7.unknown().transform(bounded).pipe(z7.object({
1660
+ version: z7.literal(1),
1661
+ name: z7.string().min(1).max(200),
1662
+ adapter: z7.object({ id: Id5, version: Id5 }).strict(),
1663
+ steps: z7.array(z7.object({
1664
+ index: z7.number().int().min(0).max(ADAPTER_PREVIEW_MAX_STEPS - 1),
1665
+ kind: z7.enum([
1666
+ "restore",
1667
+ "toolStart",
1668
+ "toolUpdate",
1669
+ "toolEnd",
1670
+ "status",
1671
+ "widget",
1672
+ "dialog",
1673
+ "answer",
1674
+ "customMessage",
1675
+ "action"
1676
+ ]),
1677
+ ok: z7.boolean(),
1678
+ error: z7.string().max(4e3).nullable()
1679
+ }).strict()).max(ADAPTER_PREVIEW_MAX_STEPS),
1680
+ panels: z7.array(PreviewPanel).max(256),
1681
+ interactions: z7.array(z7.object({
1682
+ request: AdapterPreviewPiUiRequestSchema,
1683
+ presentation: PortableNode,
1684
+ state: z7.enum(["pending", "resolved"])
1685
+ }).strict()).max(ADAPTER_PREVIEW_MAX_STEPS),
1686
+ cards: z7.array(z7.unknown().transform((input, ctx) => {
1687
+ try {
1688
+ return validateContributionCard(input);
1689
+ } catch (error) {
1690
+ ctx.addIssue({ code: "custom", message: error.message });
1691
+ return z7.NEVER;
1692
+ }
1693
+ })).max(ADAPTER_PREVIEW_MAX_STEPS * 3),
1694
+ diagnostics: z7.array(Diagnostic.extend({ message: z7.string().max(4e3) }).refine((d) => d.sessionId === null || d.sessionId === ADAPTER_PREVIEW_SESSION_ID, "Preview diagnostics must use the fake preview session")).max(200)
1695
+ }).strict().superRefine((preview, ctx) => {
1696
+ const slots = /* @__PURE__ */ new Set();
1697
+ let contributions = 0;
1698
+ for (const panel of preview.panels) {
1699
+ if (panel.adapterId !== preview.adapter.id)
1700
+ ctx.addIssue({
1701
+ code: "custom",
1702
+ message: "Preview panel belongs to a different adapter"
1703
+ });
1704
+ const key = JSON.stringify([panel.adapterId, panel.slot]);
1705
+ if (slots.has(key))
1706
+ ctx.addIssue({ code: "custom", message: "Duplicate preview panel slot" });
1707
+ slots.add(key);
1708
+ if (panel.contribution && ++contributions > 64)
1709
+ ctx.addIssue({
1710
+ code: "custom",
1711
+ message: "At most 64 contributions per adapter/session"
1712
+ });
1713
+ }
1714
+ const requests = /* @__PURE__ */ new Set();
1715
+ for (const interaction of preview.interactions) {
1716
+ if (requests.has(interaction.request.id))
1717
+ ctx.addIssue({ code: "custom", message: "Duplicate preview dialog" });
1718
+ requests.add(interaction.request.id);
1719
+ }
1720
+ }));
1721
+
1722
+ // packages/protocol/dist/adapters.js
1723
+ import { z as z8 } from "zod";
1724
+ var Path = z8.string().max(4096);
1725
+ var SessionAdapterInfo = AdapterInfo.extend({
1726
+ runtimeStatus: z8.enum(["active", "disabled", "unavailable"]),
1727
+ runtimeDetail: z8.string().max(4e3).nullable(),
1728
+ provenance: z8.object({
1729
+ scope: z8.enum(["user", "project", "explicit"]),
1730
+ source: Path.nullable(),
1731
+ packageDir: Path.nullable(),
1732
+ manifestPath: Path.nullable(),
1733
+ targetVersion: z8.string().nullable(),
1734
+ entrypoints: z8.array(Path).max(128),
1735
+ evidence: z8.enum(["runtime-reported", "package-level", "explicit"])
1736
+ })
1737
+ });
1738
+ var SessionAdaptersResult = z8.object({
1739
+ generation: z8.string().uuid().nullable(),
1740
+ runtimeId: z8.string().nullable(),
1741
+ reloadable: z8.boolean(),
1742
+ blockedReason: z8.string().nullable(),
1743
+ adapters: z8.array(SessionAdapterInfo).max(256),
1744
+ diagnostics: z8.array(Diagnostic).max(100)
1745
+ });
1746
+
1747
+ // packages/protocol/dist/agent-wire.js
1748
+ import { z as z9 } from "zod";
1749
+ var Id6 = z9.string().min(1).max(200);
1750
+ var Instant3 = z9.string().refine((value) => {
1751
+ const date = new Date(value);
1752
+ return Number.isFinite(date.getTime()) && date.toISOString() === value;
1753
+ }, "Expected canonical UTC timestamp");
1754
+ var AGENT_FRAME_MAX_BYTES = 128 * 1024;
1755
+ var AgentMethod = z9.enum([
1756
+ "session.bind",
1757
+ "task.create",
1758
+ "message.send",
1759
+ "inbox.read",
1760
+ "receipt.peek",
1761
+ "policy.evaluate",
1762
+ "policy.status",
1763
+ "policy.cancel"
1764
+ ]);
1765
+ var AgentToolMethod = z9.enum(["task.create", "message.send", "inbox.read"]);
1766
+ var RequestHash = z9.string().regex(/^[a-f0-9]{64}$/);
1767
+ var AgentReceiptPeekRequest = z9.object({ method: AgentToolMethod, args: z9.record(z9.string(), z9.json()) }).strict();
1768
+ var AgentReceiptPeekResult = z9.discriminatedUnion("found", [
1769
+ z9.object({ found: z9.literal(false) }).strict(),
1770
+ z9.object({ found: z9.literal(true), requestHash: RequestHash }).strict()
1771
+ ]);
1772
+ var AgentReceiptReplay = z9.object({ requestHash: RequestHash }).strict();
1773
+ var CreateAgentTask = z9.object({
1774
+ objective: z9.string().min(1).max(16e3),
1775
+ acceptance: z9.array(z9.string().min(1).max(2e3)).max(100).default([]),
1776
+ dependencies: z9.array(Id6).max(100).default([]),
1777
+ parentTaskId: Id6.nullable().optional(),
1778
+ hostId: Id6.optional(),
1779
+ profileId: Id6.optional(),
1780
+ notifyOnFinish: z9.boolean().default(true)
1781
+ });
1782
+ var SendAgentMessage = z9.object({
1783
+ sessionId: Id6,
1784
+ body: z9.string().min(1).max(16e3),
1785
+ mode: z9.enum(["steer", "queue"]),
1786
+ replyTo: Id6.optional()
1787
+ });
1788
+ var ReadAgentInbox = z9.object({
1789
+ after: z9.number().int().nonnegative().default(0),
1790
+ limit: z9.number().int().min(1).max(100).default(20)
1791
+ });
1792
+ var DeliveryState = z9.enum([
1793
+ "pending",
1794
+ "held",
1795
+ "deferred",
1796
+ "accepted",
1797
+ "queued",
1798
+ "appended",
1799
+ "uncertain",
1800
+ "failed"
1801
+ ]);
1802
+ var AgentMessageFields = {
1803
+ seq: z9.number().int().positive(),
1804
+ id: Id6,
1805
+ recipientSessionId: Id6,
1806
+ replyTo: Id6.nullable(),
1807
+ chainId: Id6,
1808
+ depth: z9.number().int().min(0).max(4),
1809
+ body: z9.unknown(),
1810
+ requestedMode: z9.enum(["steer", "queue"]),
1811
+ deliveryState: DeliveryState,
1812
+ holdUntil: z9.string(),
1813
+ readAt: z9.string().nullable(),
1814
+ createdAt: z9.string()
1815
+ };
1816
+ var AgentMessage = z9.discriminatedUnion("kind", [
1817
+ z9.object({ ...AgentMessageFields, kind: z9.literal("message"), senderSessionId: Id6 }),
1818
+ z9.object({
1819
+ ...AgentMessageFields,
1820
+ kind: z9.literal("completion"),
1821
+ senderSessionId: Id6.nullable()
1822
+ })
1823
+ ]);
1824
+ var AgentInbox = z9.object({
1825
+ messages: z9.array(AgentMessage),
1826
+ nextAfter: z9.number().int().nonnegative(),
1827
+ hasMore: z9.boolean()
1828
+ });
1829
+ var AgentToolPolicyWait = PolicyEvaluation.options[2].omit({ verdict: true }).extend({ type: z9.literal("policy.required") }).strict();
1830
+ var AgentRequestFrame = z9.object({
1831
+ type: z9.literal("agent.request"),
1832
+ requestId: Id6,
1833
+ sessionId: Id6,
1834
+ nativeSessionId: Id6,
1835
+ runtimeId: Id6,
1836
+ context: z9.object({ humanInputId: Id6.nullable(), causalMessageId: Id6.nullable() }).strict(),
1837
+ toolCallId: Id6.optional(),
1838
+ receiptReplay: AgentReceiptReplay.optional(),
1839
+ // Tool-method ingress requires this separately; legacy/non-tool frames remain compatible.
1840
+ deadlineAt: Instant3.optional(),
1841
+ method: AgentMethod,
1842
+ args: z9.unknown()
1843
+ }).strict().superRefine((frame, ctx) => {
1844
+ if (frame.method === "receipt.peek") {
1845
+ if (!frame.toolCallId) {
1846
+ ctx.addIssue({
1847
+ code: "custom",
1848
+ path: ["toolCallId"],
1849
+ message: "Receipt lookup requires a tool call ID."
1850
+ });
1851
+ }
1852
+ }
1853
+ if (Object.hasOwn(frame, "receiptReplay") && !AgentToolMethod.safeParse(frame.method).success) {
1854
+ ctx.addIssue({
1855
+ code: "custom",
1856
+ path: ["receiptReplay"],
1857
+ message: "Receipt replay is only valid for tool methods."
1858
+ });
1859
+ }
1524
1860
  });
1861
+ var AgentResultFrame = z9.discriminatedUnion("ok", [
1862
+ z9.object({
1863
+ type: z9.literal("agent.result"),
1864
+ requestId: Id6,
1865
+ runtimeId: Id6,
1866
+ ok: z9.literal(true),
1867
+ result: z9.unknown()
1868
+ }),
1869
+ z9.object({
1870
+ type: z9.literal("agent.result"),
1871
+ requestId: Id6,
1872
+ runtimeId: Id6,
1873
+ ok: z9.literal(false),
1874
+ error: ErrorBody
1875
+ })
1876
+ ]);
1877
+
1878
+ // packages/protocol/dist/api.js
1879
+ import { z as z13 } from "zod";
1525
1880
 
1526
1881
  // packages/protocol/dist/host-wire.js
1527
- import { z as z10 } from "zod";
1882
+ import { z as z12 } from "zod";
1528
1883
 
1529
1884
  // packages/protocol/dist/events.js
1530
- import { z as z8 } from "zod";
1885
+ import { z as z10 } from "zod";
1531
1886
  var EventDataSchemas = {
1532
1887
  "host.updated": Host,
1533
1888
  "project.updated": Project,
1534
- "project.deleted": z8.object({ id: z8.string() }),
1889
+ "project.deleted": z10.object({ id: z10.string() }),
1535
1890
  "checkout.updated": Checkout,
1536
1891
  "workspace.updated": Workspace,
1537
- "workspace.deleted": z8.object({ id: z8.string() }),
1892
+ "workspace.deleted": z10.object({ id: z10.string() }),
1538
1893
  "profile.updated": Profile,
1539
- "profile.deleted": z8.object({ id: z8.string() }),
1894
+ "profile.deleted": z10.object({ id: z10.string() }),
1540
1895
  "view.updated": View,
1541
- "view.deleted": z8.object({ id: z8.string() }),
1896
+ "view.deleted": z10.object({ id: z10.string() }),
1542
1897
  "session.updated": Session,
1543
1898
  "transcript.item": TranscriptItem,
1544
- "transcript.reset": z8.object({ sessionId: z8.string(), epoch: z8.number().int() }),
1899
+ "transcript.reset": z10.object({ sessionId: z10.string(), epoch: z10.number().int() }),
1545
1900
  "interaction.updated": Interaction,
1546
1901
  "panel.updated": Panel,
1547
- "adapters.updated": z8.object({ hostId: z8.string(), adapters: z8.array(AdapterInfo) }),
1902
+ "adapters.updated": z10.object({ hostId: z10.string(), adapters: z10.array(AdapterInfo) }),
1548
1903
  diagnostic: Diagnostic,
1549
1904
  "task.updated": Task,
1550
- "task.deleted": z8.object({ id: z8.string() }),
1905
+ "task.deleted": z10.object({ id: z10.string() }),
1551
1906
  "run.updated": Run,
1552
1907
  "automation.updated": Automation,
1553
- "automation.deleted": z8.object({ id: z8.string() }),
1908
+ "automation.deleted": z10.object({ id: z10.string() }),
1554
1909
  "occurrence.created": Occurrence,
1555
1910
  "occurrence.updated": Occurrence,
1556
1911
  "attention.updated": AttentionItem,
1557
1912
  "device.updated": Device,
1558
- "settings.updated": z8.object({ dispatchPaused: z8.boolean() })
1913
+ "settings.updated": z10.object({ dispatchPaused: z10.boolean() })
1559
1914
  };
1560
1915
  var EVENT_TYPES = Object.keys(EventDataSchemas);
1561
1916
  var LEGACY_EVENT_TYPES = {
@@ -1565,19 +1920,19 @@ function canonicalEventType(type) {
1565
1920
  return LEGACY_EVENT_TYPES[type] ?? type;
1566
1921
  }
1567
1922
  var canonical = (v) => typeof v === "string" ? canonicalEventType(v) : v;
1568
- var EventTypeSchema = z8.preprocess(canonical, z8.enum(EVENT_TYPES));
1569
- var EventScope = z8.object({
1570
- hostId: z8.string().optional(),
1571
- sessionId: z8.string().optional(),
1572
- taskId: z8.string().optional(),
1573
- projectId: z8.string().optional()
1923
+ var EventTypeSchema = z10.preprocess(canonical, z10.enum(EVENT_TYPES));
1924
+ var EventScope = z10.object({
1925
+ hostId: z10.string().optional(),
1926
+ sessionId: z10.string().optional(),
1927
+ taskId: z10.string().optional(),
1928
+ projectId: z10.string().optional()
1574
1929
  });
1575
1930
  var EventEnvelope = EventScope.extend({
1576
- seq: z8.number().int(),
1577
- id: z8.string(),
1931
+ seq: z10.number().int(),
1932
+ id: z10.string(),
1578
1933
  type: EventTypeSchema,
1579
- at: z8.string(),
1580
- data: z8.unknown()
1934
+ at: z10.string(),
1935
+ data: z10.unknown()
1581
1936
  });
1582
1937
  var HOST_EVENT_TYPES = [
1583
1938
  "session.updated",
@@ -1590,318 +1945,321 @@ var HOST_EVENT_TYPES = [
1590
1945
  "workspace.deleted"
1591
1946
  ];
1592
1947
  var HostEvent = EventScope.extend({
1593
- eventId: z8.string(),
1594
- type: z8.preprocess(canonical, z8.enum(HOST_EVENT_TYPES)),
1595
- at: z8.string(),
1596
- data: z8.unknown()
1597
- });
1598
- var StreamDelta = z8.object({
1599
- sessionId: z8.string(),
1600
- itemId: z8.string(),
1601
- kind: z8.enum(["text", "thinking", "tool_args", "tool_output"]),
1602
- delta: z8.string(),
1603
- order: z8.number().int().optional()
1948
+ eventId: z10.string(),
1949
+ type: z10.preprocess(canonical, z10.enum(HOST_EVENT_TYPES)),
1950
+ at: z10.string(),
1951
+ data: z10.unknown()
1952
+ });
1953
+ var StreamDelta = z10.object({
1954
+ sessionId: z10.string(),
1955
+ itemId: z10.string(),
1956
+ kind: z10.enum(["text", "thinking", "tool_args", "tool_output"]),
1957
+ delta: z10.string(),
1958
+ order: z10.number().int().optional()
1604
1959
  });
1605
1960
 
1606
1961
  // packages/protocol/dist/terminal-wire.js
1607
- import { z as z9 } from "zod";
1608
- var Cols = z9.number().int().min(10).max(1e3);
1609
- var Rows = z9.number().int().min(5).max(500);
1610
- var TermViewerToServer = z9.discriminatedUnion("t", [
1611
- z9.object({ t: z9.literal("in"), d: z9.string() }),
1612
- z9.object({ t: z9.literal("resize"), cols: Cols, rows: Rows }),
1613
- z9.object({ t: z9.literal("claim") })
1962
+ import { z as z11 } from "zod";
1963
+ var Cols = z11.number().int().min(10).max(1e3);
1964
+ var Rows = z11.number().int().min(5).max(500);
1965
+ var TermViewerToServer = z11.discriminatedUnion("t", [
1966
+ z11.object({ t: z11.literal("in"), d: z11.string() }),
1967
+ z11.object({ t: z11.literal("resize"), cols: Cols, rows: Rows }),
1968
+ z11.object({ t: z11.literal("claim") })
1614
1969
  ]);
1615
- var TermServerToViewer = z9.discriminatedUnion("t", [
1616
- z9.object({ t: z9.literal("out"), d: z9.string() }),
1617
- z9.object({ t: z9.literal("closed"), reason: z9.string() }),
1618
- z9.object({ t: z9.literal("size"), cols: Cols, rows: Rows, owner: z9.boolean() })
1970
+ var TermServerToViewer = z11.discriminatedUnion("t", [
1971
+ z11.object({ t: z11.literal("out"), d: z11.string() }),
1972
+ z11.object({ t: z11.literal("closed"), reason: z11.string() }),
1973
+ z11.object({ t: z11.literal("size"), cols: Cols, rows: Rows, owner: z11.boolean() })
1619
1974
  ]);
1620
- var TermCoordinatorMsg = z9.discriminatedUnion("t", [
1621
- z9.object({
1622
- t: z9.literal("open"),
1623
- sessionId: z9.string(),
1975
+ var TermCoordinatorMsg = z11.discriminatedUnion("t", [
1976
+ z11.object({
1977
+ t: z11.literal("open"),
1978
+ sessionId: z11.string(),
1624
1979
  cols: Cols,
1625
1980
  rows: Rows,
1626
- passive: z9.boolean().optional()
1981
+ passive: z11.boolean().optional()
1627
1982
  }),
1628
- z9.object({ t: z9.literal("claim") }),
1629
- z9.object({ t: z9.literal("in"), d: z9.string() }),
1630
- z9.object({ t: z9.literal("resize"), cols: Cols, rows: Rows }),
1631
- z9.object({ t: z9.literal("close") })
1983
+ z11.object({ t: z11.literal("claim") }),
1984
+ z11.object({ t: z11.literal("in"), d: z11.string() }),
1985
+ z11.object({ t: z11.literal("resize"), cols: Cols, rows: Rows }),
1986
+ z11.object({ t: z11.literal("close") })
1632
1987
  ]);
1633
1988
 
1634
1989
  // packages/protocol/dist/host-wire.js
1635
- var Origin = z10.enum(["human", "automation"]);
1636
- var HostCommand = z10.discriminatedUnion("type", [
1637
- z10.object({
1638
- type: z10.literal("session.start"),
1639
- sessionId: z10.string(),
1640
- title: z10.string(),
1641
- workspacePath: z10.string(),
1642
- projectId: z10.string().nullable(),
1990
+ var Origin = z12.enum(["human", "automation"]);
1991
+ var HostCommand = z12.discriminatedUnion("type", [
1992
+ z12.object({
1993
+ type: z12.literal("session.start"),
1994
+ sessionId: z12.string(),
1995
+ title: z12.string(),
1996
+ workspacePath: z12.string(),
1997
+ projectId: z12.string().nullable(),
1643
1998
  profile: Profile,
1644
1999
  nativeHandle: NativeHandle.nullable(),
1645
- initialPrompt: z10.string().nullable(),
1646
- dispatchKey: z10.string().nullable(),
1647
- controlRevision: z10.number().int(),
2000
+ initialPrompt: z12.string().nullable(),
2001
+ dispatchKey: z12.string().nullable(),
2002
+ controlRevision: z12.number().int(),
1648
2003
  controlMode: ControlMode,
1649
2004
  origin: Origin,
1650
- readOnly: z10.boolean().default(false),
1651
- policyRequired: z10.boolean().optional()
2005
+ readOnly: z12.boolean().default(false),
2006
+ policyRequired: z12.boolean().optional()
1652
2007
  }),
1653
- z10.object({
1654
- type: z10.literal("session.deliverMessage"),
1655
- sessionId: z10.string(),
1656
- messageId: z10.string(),
1657
- payload: z10.object({
1658
- deliveryId: z10.string(),
1659
- kind: z10.enum(["message", "completion"]),
1660
- text: z10.string()
2008
+ z12.object({
2009
+ type: z12.literal("session.deliverMessage"),
2010
+ sessionId: z12.string(),
2011
+ messageId: z12.string(),
2012
+ payload: z12.object({
2013
+ deliveryId: z12.string(),
2014
+ kind: z12.enum(["message", "completion"]),
2015
+ text: z12.string()
1661
2016
  }),
1662
- mode: z10.enum(["steer", "queue"]),
1663
- holdUntil: z10.string()
2017
+ mode: z12.enum(["steer", "queue"]),
2018
+ holdUntil: z12.string()
1664
2019
  }),
1665
- HostPolicySampleRequest.extend({ type: z10.literal("session.classifyPolicySample") }),
1666
- z10.object({
1667
- type: z10.literal("session.messageStatus"),
1668
- sessionId: z10.string(),
1669
- messageIds: z10.array(z10.string().min(1)).min(1).max(100)
2020
+ HostPolicySampleRequest.extend({ type: z12.literal("session.classifyPolicySample") }),
2021
+ z12.object({
2022
+ type: z12.literal("session.messageStatus"),
2023
+ sessionId: z12.string(),
2024
+ messageIds: z12.array(z12.string().min(1)).min(1).max(100)
1670
2025
  }),
1671
- z10.object({
1672
- type: z10.literal("session.prompt"),
1673
- sessionId: z10.string(),
1674
- text: z10.string(),
1675
- images: z10.array(z10.object({ mimeType: z10.string(), data: z10.string() })).default([]),
1676
- mode: z10.enum(["prompt", "steer", "followUp"]),
2026
+ z12.object({
2027
+ type: z12.literal("session.prompt"),
2028
+ sessionId: z12.string(),
2029
+ text: z12.string(),
2030
+ images: z12.array(z12.object({ mimeType: z12.string(), data: z12.string() })).default([]),
2031
+ mode: z12.enum(["prompt", "steer", "followUp"]),
1677
2032
  origin: Origin,
1678
- controlRevision: z10.number().int()
2033
+ controlRevision: z12.number().int()
1679
2034
  }),
1680
- z10.object({ type: z10.literal("session.abort"), sessionId: z10.string(), clearQueue: z10.boolean() }),
1681
- z10.object({ type: z10.literal("session.stop"), sessionId: z10.string() }),
1682
- z10.object({
1683
- type: z10.literal("session.answer"),
1684
- sessionId: z10.string(),
1685
- interactionId: z10.string(),
1686
- revision: z10.number().int(),
2035
+ z12.object({ type: z12.literal("session.abort"), sessionId: z12.string(), clearQueue: z12.boolean() }),
2036
+ z12.object({ type: z12.literal("session.stop"), sessionId: z12.string() }),
2037
+ z12.object({
2038
+ type: z12.literal("session.answer"),
2039
+ sessionId: z12.string(),
2040
+ interactionId: z12.string(),
2041
+ revision: z12.number().int(),
1687
2042
  response: InteractionResponseSchema,
1688
- deviceId: z10.string()
2043
+ deviceId: z12.string()
1689
2044
  }),
1690
- z10.object({
1691
- type: z10.literal("session.adapterAction"),
1692
- sessionId: z10.string(),
1693
- adapterId: z10.string(),
1694
- actionId: z10.string(),
1695
- payload: z10.unknown()
2045
+ z12.object({
2046
+ type: z12.literal("session.adapterAction"),
2047
+ sessionId: z12.string(),
2048
+ generation: z12.string().uuid().optional(),
2049
+ adapterId: z12.string(),
2050
+ actionId: z12.string(),
2051
+ payload: z12.unknown()
1696
2052
  }),
1697
- z10.object({
1698
- type: z10.literal("session.setControl"),
1699
- sessionId: z10.string(),
1700
- controlRevision: z10.number().int(),
2053
+ z12.object({
2054
+ type: z12.literal("session.setControl"),
2055
+ sessionId: z12.string(),
2056
+ controlRevision: z12.number().int(),
1701
2057
  mode: ControlMode
1702
2058
  }),
1703
- z10.object({ type: z10.literal("session.rename"), sessionId: z10.string(), title: z10.string() }),
1704
- z10.object({ type: z10.literal("session.importable") }),
1705
- z10.object({ type: z10.literal("session.readNative"), sessionFile: z10.string() }),
1706
- z10.object({ type: z10.literal("session.snapshot"), sessionId: z10.string() }),
1707
- z10.object({ type: z10.literal("session.models"), sessionId: z10.string() }),
1708
- z10.object({ type: z10.literal("session.commands"), sessionId: z10.string() }),
1709
- z10.object({
1710
- type: z10.literal("session.complete"),
1711
- sessionId: z10.string(),
1712
- text: z10.string().max(500)
2059
+ z12.object({ type: z12.literal("session.rename"), sessionId: z12.string(), title: z12.string() }),
2060
+ z12.object({ type: z12.literal("session.importable") }),
2061
+ z12.object({ type: z12.literal("session.readNative"), sessionFile: z12.string() }),
2062
+ z12.object({ type: z12.literal("session.snapshot"), sessionId: z12.string() }),
2063
+ z12.object({ type: z12.literal("session.models"), sessionId: z12.string() }),
2064
+ z12.object({ type: z12.literal("session.commands"), sessionId: z12.string() }),
2065
+ z12.object({
2066
+ type: z12.literal("session.complete"),
2067
+ sessionId: z12.string(),
2068
+ text: z12.string().max(500)
1713
2069
  }),
1714
- z10.object({ type: z10.literal("session.tree"), sessionId: z10.string() }),
1715
- z10.object({
1716
- type: z10.literal("session.branch"),
1717
- sessionId: z10.string(),
1718
- entryId: z10.string().nullable(),
1719
- fork: z10.boolean()
2070
+ z12.object({ type: z12.literal("session.tree"), sessionId: z12.string() }),
2071
+ z12.object({
2072
+ type: z12.literal("session.branch"),
2073
+ sessionId: z12.string(),
2074
+ entryId: z12.string().nullable(),
2075
+ fork: z12.boolean()
1720
2076
  }),
1721
- z10.object({
1722
- type: z10.literal("session.navigate"),
1723
- sessionId: z10.string(),
1724
- entryId: z10.string(),
1725
- summarize: z10.boolean(),
1726
- instructions: z10.string().max(2e3).nullable()
2077
+ z12.object({
2078
+ type: z12.literal("session.navigate"),
2079
+ sessionId: z12.string(),
2080
+ entryId: z12.string(),
2081
+ summarize: z12.boolean(),
2082
+ instructions: z12.string().max(2e3).nullable()
1727
2083
  }),
1728
- z10.object({ type: z10.literal("session.reload"), sessionId: z10.string() }),
1729
- z10.object({ type: z10.literal("session.export"), sessionId: z10.string() }),
1730
- z10.object({
1731
- type: z10.literal("session.setModel"),
1732
- sessionId: z10.string(),
1733
- provider: z10.string().min(1),
1734
- modelId: z10.string().min(1)
2084
+ z12.object({ type: z12.literal("session.reload"), sessionId: z12.string() }),
2085
+ z12.object({ type: z12.literal("session.adapters"), sessionId: z12.string() }),
2086
+ z12.object({ type: z12.literal("session.reloadAdapters"), sessionId: z12.string() }),
2087
+ z12.object({ type: z12.literal("session.export"), sessionId: z12.string() }),
2088
+ z12.object({
2089
+ type: z12.literal("session.setModel"),
2090
+ sessionId: z12.string(),
2091
+ provider: z12.string().min(1),
2092
+ modelId: z12.string().min(1)
1735
2093
  }),
1736
- z10.object({ type: z10.literal("session.setThinking"), sessionId: z10.string(), level: ThinkingLevel }),
1737
- z10.object({
1738
- type: z10.literal("session.compact"),
1739
- sessionId: z10.string(),
1740
- instructions: z10.string().nullable()
2094
+ z12.object({ type: z12.literal("session.setThinking"), sessionId: z12.string(), level: ThinkingLevel }),
2095
+ z12.object({
2096
+ type: z12.literal("session.compact"),
2097
+ sessionId: z12.string(),
2098
+ instructions: z12.string().nullable()
1741
2099
  }),
1742
- z10.object({ type: z10.literal("checkout.inspect"), path: z10.string() }),
1743
- z10.object({ type: z10.literal("projects.scan"), folder: z10.string().min(1) }),
1744
- z10.object({
1745
- type: z10.literal("projects.suggest"),
1746
- days: z10.number().int().min(1).max(365).default(30)
2100
+ z12.object({ type: z12.literal("checkout.inspect"), path: z12.string() }),
2101
+ z12.object({ type: z12.literal("projects.scan"), folder: z12.string().min(1) }),
2102
+ z12.object({
2103
+ type: z12.literal("projects.suggest"),
2104
+ days: z12.number().int().min(1).max(365).default(30)
1747
2105
  }),
1748
- z10.object({
1749
- type: z10.literal("workspace.discover"),
1750
- checkoutPath: z10.string(),
1751
- worktreeDir: z10.string().default(DEFAULT_WORKTREE_DIR)
2106
+ z12.object({
2107
+ type: z12.literal("workspace.discover"),
2108
+ checkoutPath: z12.string(),
2109
+ worktreeDir: z12.string().default(DEFAULT_WORKTREE_DIR)
1752
2110
  }),
1753
- z10.object({
1754
- type: z10.literal("workspace.create"),
1755
- checkoutPath: z10.string(),
1756
- branch: z10.string(),
1757
- base: z10.string(),
1758
- setupCommand: z10.string().nullable(),
1759
- worktreeDir: z10.string().default(DEFAULT_WORKTREE_DIR)
2111
+ z12.object({
2112
+ type: z12.literal("workspace.create"),
2113
+ checkoutPath: z12.string(),
2114
+ branch: z12.string(),
2115
+ base: z12.string(),
2116
+ setupCommand: z12.string().nullable(),
2117
+ worktreeDir: z12.string().default(DEFAULT_WORKTREE_DIR)
1760
2118
  }),
1761
- z10.object({ type: z10.literal("workspace.status"), path: z10.string(), base: z10.string().nullable() }),
1762
- z10.object({
1763
- type: z10.literal("workspace.remove"),
1764
- path: z10.string(),
1765
- checkoutPath: z10.string(),
1766
- base: z10.string().nullable(),
1767
- force: z10.object({ dirty: z10.boolean(), unmerged: z10.boolean() })
2119
+ z12.object({ type: z12.literal("workspace.status"), path: z12.string(), base: z12.string().nullable() }),
2120
+ z12.object({
2121
+ type: z12.literal("workspace.remove"),
2122
+ path: z12.string(),
2123
+ checkoutPath: z12.string(),
2124
+ base: z12.string().nullable(),
2125
+ force: z12.object({ dirty: z12.boolean(), unmerged: z12.boolean() })
1768
2126
  }),
1769
- z10.object({
1770
- type: z10.literal("workspace.diff"),
1771
- path: z10.string(),
1772
- base: z10.string().nullable(),
1773
- file: z10.string().nullable()
2127
+ z12.object({
2128
+ type: z12.literal("workspace.diff"),
2129
+ path: z12.string(),
2130
+ base: z12.string().nullable(),
2131
+ file: z12.string().nullable()
1774
2132
  }),
1775
- z10.object({ type: z10.literal("workspace.files"), path: z10.string(), dir: z10.string() }),
1776
- z10.object({ type: z10.literal("workspace.readFile"), path: z10.string(), file: z10.string() }),
1777
- GitHubHostViewRequest.extend({ type: z10.literal("workspace.prView") }),
1778
- GitHubHostLogsRequest.extend({ type: z10.literal("workspace.prFailedLogs") }),
1779
- GitHubHostMergeRequest.extend({ type: z10.literal("workspace.prMerge") }),
1780
- z10.object({
1781
- type: z10.literal("dispatch.start"),
1782
- dispatchKey: z10.string(),
1783
- runId: z10.string(),
1784
- taskId: z10.string(),
1785
- sessionId: z10.string(),
1786
- projectId: z10.string(),
1787
- title: z10.string(),
1788
- workspace: z10.union([
1789
- z10.object({ path: z10.string() }),
1790
- z10.object({
1791
- createFrom: z10.object({
1792
- checkoutPath: z10.string(),
1793
- branch: z10.string(),
1794
- base: z10.string(),
1795
- setupCommand: z10.string().nullable(),
1796
- worktreeDir: z10.string().default(DEFAULT_WORKTREE_DIR)
2133
+ z12.object({ type: z12.literal("workspace.files"), path: z12.string(), dir: z12.string() }),
2134
+ z12.object({ type: z12.literal("workspace.readFile"), path: z12.string(), file: z12.string() }),
2135
+ GitHubHostViewRequest.extend({ type: z12.literal("workspace.prView") }),
2136
+ GitHubHostLogsRequest.extend({ type: z12.literal("workspace.prFailedLogs") }),
2137
+ GitHubHostMergeRequest.extend({ type: z12.literal("workspace.prMerge") }),
2138
+ z12.object({
2139
+ type: z12.literal("dispatch.start"),
2140
+ dispatchKey: z12.string(),
2141
+ runId: z12.string(),
2142
+ taskId: z12.string(),
2143
+ sessionId: z12.string(),
2144
+ projectId: z12.string(),
2145
+ title: z12.string(),
2146
+ workspace: z12.union([
2147
+ z12.object({ path: z12.string() }),
2148
+ z12.object({
2149
+ createFrom: z12.object({
2150
+ checkoutPath: z12.string(),
2151
+ branch: z12.string(),
2152
+ base: z12.string(),
2153
+ setupCommand: z12.string().nullable(),
2154
+ worktreeDir: z12.string().default(DEFAULT_WORKTREE_DIR)
1797
2155
  })
1798
2156
  })
1799
2157
  ]),
1800
2158
  nativeHandle: NativeHandle.nullable(),
1801
2159
  profile: Profile,
1802
- prompt: z10.string(),
2160
+ prompt: z12.string(),
1803
2161
  /** The launch's own revision; a takeover always carries a newer one. */
1804
- controlRevision: z10.number().int(),
2162
+ controlRevision: z12.number().int(),
1805
2163
  controlMode: ControlMode.default("automation"),
1806
- policyRequired: z10.boolean().optional()
2164
+ policyRequired: z12.boolean().optional()
1807
2165
  }),
1808
- z10.object({ type: z10.literal("dispatch.reconcile"), dispatchKey: z10.string() }),
1809
- z10.object({
1810
- type: z10.literal("checks.run"),
1811
- sessionId: z10.string(),
1812
- path: z10.string(),
1813
- commands: z10.array(z10.string())
2166
+ z12.object({ type: z12.literal("dispatch.reconcile"), dispatchKey: z12.string() }),
2167
+ z12.object({
2168
+ type: z12.literal("checks.run"),
2169
+ sessionId: z12.string(),
2170
+ path: z12.string(),
2171
+ commands: z12.array(z12.string())
1814
2172
  })
1815
2173
  ]);
1816
- var ImportableSession = z10.object({
1817
- sessionFile: z10.string(),
1818
- sessionId: z10.string(),
1819
- cwd: z10.string(),
1820
- name: z10.string().nullable(),
1821
- mtime: z10.string(),
1822
- inactive: z10.boolean()
1823
- });
1824
- var DiscoveredWorktree = z10.object({
1825
- path: z10.string(),
1826
- head: z10.string().nullable(),
1827
- branch: z10.string().nullable(),
1828
- bare: z10.boolean(),
1829
- detached: z10.boolean(),
1830
- locked: z10.boolean(),
1831
- prunable: z10.boolean(),
1832
- provenance: z10.enum(["managed", "discovered", "main"]),
2174
+ var ImportableSession = z12.object({
2175
+ sessionFile: z12.string(),
2176
+ sessionId: z12.string(),
2177
+ cwd: z12.string(),
2178
+ name: z12.string().nullable(),
2179
+ mtime: z12.string(),
2180
+ inactive: z12.boolean()
2181
+ });
2182
+ var DiscoveredWorktree = z12.object({
2183
+ path: z12.string(),
2184
+ head: z12.string().nullable(),
2185
+ branch: z12.string().nullable(),
2186
+ bare: z12.boolean(),
2187
+ detached: z12.boolean(),
2188
+ locked: z12.boolean(),
2189
+ prunable: z12.boolean(),
2190
+ provenance: z12.enum(["managed", "discovered", "main"]),
1833
2191
  git: GitState.nullable()
1834
2192
  });
1835
- var CheckoutInfo = z10.object({
1836
- root: z10.string(),
1837
- commonDir: z10.string(),
1838
- repoIdentity: z10.string(),
1839
- defaultBranch: z10.string()
2193
+ var CheckoutInfo = z12.object({
2194
+ root: z12.string(),
2195
+ commonDir: z12.string(),
2196
+ repoIdentity: z12.string(),
2197
+ defaultBranch: z12.string()
1840
2198
  });
1841
- var ScannedRepository = CheckoutInfo.extend({ name: z10.string() });
1842
- var ProjectFolderScan = z10.object({
2199
+ var ScannedRepository = CheckoutInfo.extend({ name: z12.string() });
2200
+ var ProjectFolderScan = z12.object({
1843
2201
  /** The folder, ~ expanded and realpath'd. */
1844
- folder: z10.string(),
1845
- repositories: z10.array(ScannedRepository)
1846
- });
1847
- var ProjectSuggestion = z10.object({
1848
- rootPath: z10.string(),
1849
- sessionCount: z10.number().int(),
1850
- lastActivityAt: z10.string()
1851
- });
1852
- var ProjectSuggestions = z10.object({ suggestions: z10.array(ProjectSuggestion) });
1853
- var DiffFile = z10.object({
1854
- path: z10.string(),
1855
- oldPath: z10.string().nullable(),
1856
- added: z10.number().int(),
1857
- deleted: z10.number().int(),
1858
- status: z10.enum(["added", "modified", "deleted", "renamed", "untracked", "binary"])
1859
- });
1860
- var DiffResult = z10.object({
1861
- base: z10.string(),
1862
- files: z10.array(DiffFile),
1863
- patch: z10.string().nullable()
1864
- });
1865
- var FileEntry = z10.object({
1866
- name: z10.string(),
1867
- path: z10.string(),
1868
- kind: z10.enum(["file", "dir", "symlink"]),
1869
- size: z10.number().int().nullable()
1870
- });
1871
- var ReconcileResult = z10.union([
1872
- z10.object({ known: z10.literal(false) }),
1873
- z10.object({
1874
- known: z10.literal(true),
1875
- sessionId: z10.string().nullable(),
1876
- state: z10.enum(["accepted", "workspace_ready", "started", "failed"]),
2202
+ folder: z12.string(),
2203
+ repositories: z12.array(ScannedRepository)
2204
+ });
2205
+ var ProjectSuggestion = z12.object({
2206
+ rootPath: z12.string(),
2207
+ sessionCount: z12.number().int(),
2208
+ lastActivityAt: z12.string()
2209
+ });
2210
+ var ProjectSuggestions = z12.object({ suggestions: z12.array(ProjectSuggestion) });
2211
+ var DiffFile = z12.object({
2212
+ path: z12.string(),
2213
+ oldPath: z12.string().nullable(),
2214
+ added: z12.number().int(),
2215
+ deleted: z12.number().int(),
2216
+ status: z12.enum(["added", "modified", "deleted", "renamed", "untracked", "binary"])
2217
+ });
2218
+ var DiffResult = z12.object({
2219
+ base: z12.string(),
2220
+ files: z12.array(DiffFile),
2221
+ patch: z12.string().nullable()
2222
+ });
2223
+ var FileEntry = z12.object({
2224
+ name: z12.string(),
2225
+ path: z12.string(),
2226
+ kind: z12.enum(["file", "dir", "symlink"]),
2227
+ size: z12.number().int().nullable()
2228
+ });
2229
+ var ReconcileResult = z12.union([
2230
+ z12.object({ known: z12.literal(false) }),
2231
+ z12.object({
2232
+ known: z12.literal(true),
2233
+ sessionId: z12.string().nullable(),
2234
+ state: z12.enum(["accepted", "workspace_ready", "started", "failed"]),
1877
2235
  runtime: RuntimeState.nullable(),
1878
- workspacePath: z10.string().nullable(),
2236
+ workspacePath: z12.string().nullable(),
1879
2237
  nativeHandle: NativeHandle.nullable(),
1880
- error: z10.string().nullable(),
2238
+ error: z12.string().nullable(),
1881
2239
  /** `{started: "unknown"}` when the host restarted after Pi may have been spawned. */
1882
- errorDetails: z10.record(z10.string(), z10.unknown()).nullable().default(null)
2240
+ errorDetails: z12.record(z12.string(), z12.unknown()).nullable().default(null)
1883
2241
  })
1884
2242
  ]);
1885
- var DispatchStartResult = z10.object({
1886
- sessionId: z10.string(),
1887
- workspacePath: z10.string(),
2243
+ var DispatchStartResult = z12.object({
2244
+ sessionId: z12.string(),
2245
+ workspacePath: z12.string(),
1888
2246
  nativeHandle: NativeHandle.nullable(),
1889
- reused: z10.boolean(),
2247
+ reused: z12.boolean(),
1890
2248
  /** Why the launch prompt was not delivered to Pi (the session itself started), if it was not. */
1891
- promptError: z10.string().nullable().optional()
2249
+ promptError: z12.string().nullable().optional()
1892
2250
  });
1893
- var AnswerResult = z10.object({
1894
- status: z10.enum(["answered", "already_answered"]),
2251
+ var AnswerResult = z12.object({
2252
+ status: z12.enum(["answered", "already_answered"]),
1895
2253
  interaction: Interaction
1896
2254
  });
1897
- var SnapshotResult = z10.object({
1898
- partial: z10.array(TranscriptItem),
1899
- pendingInteractions: z10.array(Interaction)
2255
+ var SnapshotResult = z12.object({
2256
+ partial: z12.array(TranscriptItem),
2257
+ pendingInteractions: z12.array(Interaction)
1900
2258
  });
1901
- var ChecksResult = z10.object({ results: z10.array(CheckResult) });
1902
- var Receipt = z10.union([
1903
- z10.object({ commandId: z10.string(), ok: z10.literal(true), result: z10.unknown() }),
1904
- z10.object({ commandId: z10.string(), ok: z10.literal(false), error: ErrorBody })
2259
+ var ChecksResult = z12.object({ results: z12.array(CheckResult) });
2260
+ var Receipt = z12.union([
2261
+ z12.object({ commandId: z12.string(), ok: z12.literal(true), result: z12.unknown() }),
2262
+ z12.object({ commandId: z12.string(), ok: z12.literal(false), error: ErrorBody })
1905
2263
  ]);
1906
2264
  var HostAgentRequestFrame = AgentRequestFrame.safeExtend({
1907
2265
  policyContext: HostToolPolicyContext.optional()
@@ -1920,278 +2278,279 @@ var HostAgentRequestFrame = AgentRequestFrame.safeExtend({
1920
2278
  }
1921
2279
  ctx.addIssue({ code: "custom", message: "Host agent frame exceeds 128 KiB or is not JSON." });
1922
2280
  });
1923
- var HostToCoordinator = z10.discriminatedUnion("type", [
1924
- z10.object({
1925
- type: z10.literal("hello"),
1926
- hostId: z10.string(),
1927
- credential: z10.string(),
1928
- name: z10.string(),
1929
- agentVersion: z10.string(),
1930
- piVersion: z10.string().nullable(),
1931
- piCompatible: z10.boolean(),
2281
+ var HostToCoordinator = z12.discriminatedUnion("type", [
2282
+ z12.object({
2283
+ type: z12.literal("hello"),
2284
+ hostId: z12.string(),
2285
+ credential: z12.string(),
2286
+ name: z12.string(),
2287
+ agentVersion: z12.string(),
2288
+ piVersion: z12.string().nullable(),
2289
+ piCompatible: z12.boolean(),
1932
2290
  platform: Platform,
1933
2291
  capabilities: RuntimeCapabilities.nullable(),
1934
2292
  github: HostGitHub.optional(),
1935
- protocolVersion: z10.number().int(),
1936
- features: z10.array(z10.string()).optional()
2293
+ protocolVersion: z12.number().int(),
2294
+ features: z12.array(z12.string()).optional()
1937
2295
  }),
1938
2296
  HostAgentRequestFrame,
1939
- z10.object({ type: z10.literal("event"), hostSeq: z10.number().int(), event: HostEvent }),
1940
- z10.object({ type: z10.literal("stream"), delta: StreamDelta }),
1941
- z10.object({ type: z10.literal("receipt"), receipt: Receipt }),
1942
- z10.object({ type: z10.literal("pong") }),
1943
- z10.object({ type: z10.literal("usage"), usage: z10.array(ProviderUsage) }),
1944
- z10.object({ type: z10.literal("term"), streamId: z10.string(), msg: TermServerToViewer })
2297
+ z12.object({ type: z12.literal("event"), hostSeq: z12.number().int(), event: HostEvent }),
2298
+ z12.object({ type: z12.literal("stream"), delta: StreamDelta }),
2299
+ z12.object({ type: z12.literal("receipt"), receipt: Receipt }),
2300
+ z12.object({ type: z12.literal("pong") }),
2301
+ z12.object({ type: z12.literal("usage"), usage: z12.array(ProviderUsage) }),
2302
+ z12.object({ type: z12.literal("term"), streamId: z12.string(), msg: TermServerToViewer })
1945
2303
  ]);
1946
- var CoordinatorToHost = z10.discriminatedUnion("type", [
1947
- z10.object({
1948
- type: z10.literal("welcome"),
1949
- coordinatorVersion: z10.string(),
1950
- ackedHostSeq: z10.number().int(),
1951
- features: z10.array(z10.string()).optional()
2304
+ var CoordinatorToHost = z12.discriminatedUnion("type", [
2305
+ z12.object({
2306
+ type: z12.literal("welcome"),
2307
+ coordinatorVersion: z12.string(),
2308
+ ackedHostSeq: z12.number().int(),
2309
+ features: z12.array(z12.string()).optional()
1952
2310
  }),
1953
2311
  AgentResultFrame,
1954
- z10.object({ type: z10.literal("ack"), hostSeq: z10.number().int() }),
1955
- z10.object({ type: z10.literal("command"), commandId: z10.string(), command: HostCommand }),
1956
- z10.object({ type: z10.literal("ping") }),
1957
- z10.object({ type: z10.literal("reject"), error: ErrorBody }),
1958
- z10.object({ type: z10.literal("term"), streamId: z10.string(), msg: TermCoordinatorMsg })
2312
+ z12.object({ type: z12.literal("ack"), hostSeq: z12.number().int() }),
2313
+ z12.object({ type: z12.literal("command"), commandId: z12.string(), command: HostCommand }),
2314
+ z12.object({ type: z12.literal("ping") }),
2315
+ z12.object({ type: z12.literal("reject"), error: ErrorBody }),
2316
+ z12.object({ type: z12.literal("term"), streamId: z12.string(), msg: TermCoordinatorMsg })
1959
2317
  ]);
1960
2318
 
1961
2319
  // packages/protocol/dist/api.js
1962
- var EnrollRequest = z11.object({
1963
- token: z11.string().min(1),
1964
- name: z11.string().min(1).max(80),
2320
+ var EnrollRequest = z13.object({
2321
+ token: z13.string().min(1),
2322
+ name: z13.string().min(1).max(80),
1965
2323
  kind: DeviceKind
1966
2324
  });
1967
- var EnrollResponse = z11.object({ deviceId: z11.string(), credential: z11.string() });
1968
- var CreateEnrollmentRequest = z11.object({ kind: z11.enum(["device", "host"]) });
1969
- var CreateEnrollmentResponse = z11.object({
1970
- token: z11.string(),
1971
- url: z11.string(),
1972
- expiresAt: z11.string(),
1973
- qrSvg: z11.string(),
1974
- command: z11.string().nullable()
2325
+ var EnrollResponse = z13.object({ deviceId: z13.string(), credential: z13.string() });
2326
+ var CreateEnrollmentRequest = z13.object({ kind: z13.enum(["device", "host"]) });
2327
+ var CreateEnrollmentResponse = z13.object({
2328
+ token: z13.string(),
2329
+ url: z13.string(),
2330
+ expiresAt: z13.string(),
2331
+ qrSvg: z13.string(),
2332
+ command: z13.string().nullable()
1975
2333
  });
1976
- var HostEnrollRequest = z11.union([
1977
- z11.object({
1978
- token: z11.string().min(1),
1979
- name: z11.string().min(1).max(80),
2334
+ var HostEnrollRequest = z13.union([
2335
+ z13.object({
2336
+ token: z13.string().min(1),
2337
+ name: z13.string().min(1).max(80),
1980
2338
  platform: Platform
1981
2339
  }),
1982
- z11.object({
1983
- secret: z11.string().min(1),
1984
- name: z11.string().min(1).max(80),
2340
+ z13.object({
2341
+ secret: z13.string().min(1),
2342
+ name: z13.string().min(1).max(80),
1985
2343
  platform: Platform
1986
2344
  })
1987
2345
  ]);
1988
- var HostEnrollResponse = z11.object({ hostId: z11.string(), credential: z11.string() });
1989
- var CreateProjectRequest = z11.object({
1990
- name: z11.string().min(1),
1991
- hostId: z11.string(),
1992
- path: z11.string().min(1),
1993
- defaultProfileId: z11.string().nullable().optional(),
1994
- setupCommand: z11.string().nullable().optional(),
1995
- checks: z11.array(z11.string()).optional(),
1996
- maxConcurrentRuns: z11.number().int().min(1).max(32).optional(),
2346
+ var HostEnrollResponse = z13.object({ hostId: z13.string(), credential: z13.string() });
2347
+ var CreateProjectRequest = z13.object({
2348
+ name: z13.string().min(1),
2349
+ hostId: z13.string(),
2350
+ path: z13.string().min(1),
2351
+ defaultProfileId: z13.string().nullable().optional(),
2352
+ setupCommand: z13.string().nullable().optional(),
2353
+ checks: z13.array(z13.string()).optional(),
2354
+ maxConcurrentRuns: z13.number().int().min(1).max(32).optional(),
1997
2355
  worktreeDir: WorktreeDir.optional()
1998
2356
  });
1999
- var UpdateProjectRequest = z11.object({
2000
- name: z11.string().min(1).optional(),
2001
- defaultProfileId: z11.string().nullable().optional(),
2002
- defaultHostId: z11.string().nullable().optional(),
2003
- maxConcurrentRuns: z11.number().int().min(1).max(32).optional(),
2004
- automationEnabled: z11.boolean().optional(),
2005
- setupCommand: z11.string().nullable().optional(),
2006
- checks: z11.array(z11.string()).optional(),
2007
- workspaceSharing: z11.enum(["single_writer", "shared"]).optional(),
2357
+ var UpdateProjectRequest = z13.object({
2358
+ name: z13.string().min(1).optional(),
2359
+ defaultProfileId: z13.string().nullable().optional(),
2360
+ defaultHostId: z13.string().nullable().optional(),
2361
+ maxConcurrentRuns: z13.number().int().min(1).max(32).optional(),
2362
+ automationEnabled: z13.boolean().optional(),
2363
+ setupCommand: z13.string().nullable().optional(),
2364
+ checks: z13.array(z13.string()).optional(),
2365
+ workspaceSharing: z13.enum(["single_writer", "shared"]).optional(),
2008
2366
  worktreeDir: WorktreeDir.optional()
2009
2367
  });
2010
- var AddCheckoutRequest = z11.object({ hostId: z11.string(), path: z11.string().min(1) });
2368
+ var AddCheckoutRequest = z13.object({ hostId: z13.string(), path: z13.string().min(1) });
2011
2369
  function isProjectFolderPath(s) {
2012
2370
  if (s.includes("\0"))
2013
2371
  return false;
2014
2372
  return s === "~" || s.startsWith("~/") || s.startsWith("/");
2015
2373
  }
2016
- var ProjectFolder = z11.string().trim().min(1).max(1024).refine(isProjectFolderPath, "must be an absolute path or start with ~/");
2017
- var UpdateHostRequest = z11.object({
2018
- projectFolders: z11.array(ProjectFolder).max(20).optional()
2374
+ var ProjectFolder = z13.string().trim().min(1).max(1024).refine(isProjectFolderPath, "must be an absolute path or start with ~/");
2375
+ var UpdateHostRequest = z13.object({
2376
+ projectFolders: z13.array(ProjectFolder).max(20).optional()
2019
2377
  });
2020
2378
  var ProjectScanResult = ProjectScan.extend({
2021
- added: z11.array(z11.object({
2022
- projectId: z11.string(),
2023
- name: z11.string(),
2024
- path: z11.string(),
2025
- newProject: z11.boolean()
2379
+ added: z13.array(z13.object({
2380
+ projectId: z13.string(),
2381
+ name: z13.string(),
2382
+ path: z13.string(),
2383
+ newProject: z13.boolean()
2026
2384
  }))
2027
2385
  });
2028
- var ProfileInput = z11.object({
2029
- name: z11.string().min(1),
2030
- provider: z11.string().nullable().default(null),
2031
- model: z11.string().nullable().default(null),
2386
+ var ProfileInput = z13.object({
2387
+ name: z13.string().min(1),
2388
+ provider: z13.string().nullable().default(null),
2389
+ model: z13.string().nullable().default(null),
2032
2390
  thinking: ThinkingLevel.nullable().default(null),
2033
- projectTrust: z11.enum(["ask", "approve", "ignore"]).default("ask"),
2034
- extraArgs: z11.array(ExtraArg).default([]),
2035
- resources: z11.enum(["all", "vanilla"]).default("all")
2036
- });
2037
- var CreateWorkspaceRequest = z11.object({
2038
- checkoutId: z11.string(),
2039
- branch: z11.string().min(1),
2040
- base: z11.string().nullable().optional()
2041
- });
2042
- var RemoveWorkspaceRequest = z11.object({
2043
- force: z11.object({ dirty: z11.boolean(), unmerged: z11.boolean() }).default({ dirty: false, unmerged: false })
2044
- });
2045
- var CreateSessionRequest = z11.object({
2046
- projectId: z11.string(),
2047
- workspace: z11.union([
2048
- z11.object({ existingId: z11.string() }),
2049
- z11.object({
2050
- checkoutId: z11.string(),
2051
- newBranch: z11.string().min(1),
2052
- base: z11.string().nullable().optional()
2391
+ projectTrust: z13.enum(["ask", "approve", "ignore"]).default("ask"),
2392
+ extraArgs: z13.array(ExtraArg).default([]),
2393
+ resources: z13.enum(["all", "vanilla"]).default("all")
2394
+ });
2395
+ var CreateWorkspaceRequest = z13.object({
2396
+ checkoutId: z13.string(),
2397
+ branch: z13.string().min(1),
2398
+ base: z13.string().nullable().optional()
2399
+ });
2400
+ var RemoveWorkspaceRequest = z13.object({
2401
+ force: z13.object({ dirty: z13.boolean(), unmerged: z13.boolean() }).default({ dirty: false, unmerged: false })
2402
+ });
2403
+ var CreateSessionRequest = z13.object({
2404
+ projectId: z13.string(),
2405
+ workspace: z13.union([
2406
+ z13.object({ existingId: z13.string() }),
2407
+ z13.object({
2408
+ checkoutId: z13.string(),
2409
+ newBranch: z13.string().min(1),
2410
+ base: z13.string().nullable().optional()
2053
2411
  })
2054
2412
  ]),
2055
- profileId: z11.string().nullable().optional(),
2056
- prompt: z11.string().default(""),
2057
- title: z11.string().optional(),
2058
- viewId: z11.string().optional()
2059
- });
2060
- var PromptRequest = z11.object({
2061
- text: z11.string().min(1),
2062
- mode: z11.enum(["prompt", "steer", "followUp"]).default("prompt"),
2063
- images: z11.array(z11.object({ mimeType: z11.string(), data: z11.string() })).default([]),
2064
- clientMessageId: z11.string().optional()
2065
- });
2066
- var CacheAlertRequest = z11.object({
2067
- enabled: z11.boolean(),
2068
- ttlSec: z11.number().int().min(60).max(86400).nullable().default(null)
2069
- });
2070
- var RenameRequest = z11.object({ title: z11.string().min(1).max(200) });
2071
- var SetModelRequest = z11.object({
2072
- provider: z11.string().min(1),
2073
- modelId: z11.string().min(1)
2074
- });
2075
- var SetThinkingRequest = z11.object({ level: ThinkingLevel });
2076
- var CompactRequest = z11.object({ instructions: z11.string().max(4e3).optional() });
2077
- var SessionModelsResult = z11.object({ models: z11.array(SessionModel) });
2078
- var SessionCommandsResult = z11.object({ commands: z11.array(SlashCommand) });
2079
- var CompleteRequest = z11.object({ text: z11.string().min(1).max(500) });
2080
- var CompletionItem = z11.object({
2081
- value: z11.string(),
2082
- label: z11.string(),
2083
- description: z11.string().nullable()
2084
- });
2085
- var SessionCompleteResult = z11.object({
2086
- items: z11.array(CompletionItem).max(50),
2087
- prefix: z11.string()
2088
- });
2089
- var TreeRow = z11.object({
2090
- entryId: z11.string(),
2091
- parentId: z11.string().nullable(),
2092
- depth: z11.number().int(),
2093
- role: z11.enum(["user", "assistant"]),
2094
- text: z11.string(),
2095
- activeBranch: z11.boolean(),
2096
- leaf: z11.boolean(),
2097
- label: z11.string().nullable(),
2098
- at: z11.string().nullable()
2099
- });
2100
- var SessionTreeResult = z11.object({ rows: z11.array(TreeRow) });
2101
- var BranchRequest = z11.object({
2102
- entryId: z11.string().nullable(),
2103
- fork: z11.boolean().default(false)
2104
- });
2105
- var HostBranchResult = z11.object({
2106
- sessionFile: z11.string().nullable(),
2107
- prefill: z11.string().nullable()
2108
- });
2109
- var TranscriptPage = z11.object({
2110
- items: z11.array(TranscriptItem),
2111
- hasMore: z11.boolean(),
2112
- epoch: z11.number().int().optional(),
2113
- rev: z11.number().int().optional(),
2114
- delta: z11.boolean().optional(),
2115
- reset: z11.boolean().optional()
2116
- });
2117
- var NavigateRequest = z11.object({
2118
- entryId: z11.string().min(1),
2119
- summarize: z11.boolean().default(false),
2120
- instructions: z11.string().max(2e3).nullable().default(null)
2121
- });
2122
- var HostNavigateResult = z11.object({
2123
- items: z11.array(TranscriptItem),
2124
- prefill: z11.string().nullable()
2125
- });
2126
- var NavigateResult = z11.object({
2127
- prefill: z11.string().nullable(),
2128
- epoch: z11.number().int()
2129
- });
2130
- var BranchResult = z11.object({
2413
+ profileId: z13.string().nullable().optional(),
2414
+ prompt: z13.string().default(""),
2415
+ title: z13.string().optional(),
2416
+ viewId: z13.string().optional()
2417
+ });
2418
+ var PromptRequest = z13.object({
2419
+ text: z13.string().min(1),
2420
+ mode: z13.enum(["prompt", "steer", "followUp"]).default("prompt"),
2421
+ images: z13.array(z13.object({ mimeType: z13.string(), data: z13.string() })).default([]),
2422
+ clientMessageId: z13.string().optional()
2423
+ });
2424
+ var CacheAlertRequest = z13.object({
2425
+ enabled: z13.boolean(),
2426
+ ttlSec: z13.number().int().min(60).max(86400).nullable().default(null)
2427
+ });
2428
+ var RenameRequest = z13.object({ title: z13.string().min(1).max(200) });
2429
+ var SetModelRequest = z13.object({
2430
+ provider: z13.string().min(1),
2431
+ modelId: z13.string().min(1)
2432
+ });
2433
+ var SetThinkingRequest = z13.object({ level: ThinkingLevel });
2434
+ var CompactRequest = z13.object({ instructions: z13.string().max(4e3).optional() });
2435
+ var SessionModelsResult = z13.object({ models: z13.array(SessionModel) });
2436
+ var SessionCommandsResult = z13.object({ commands: z13.array(SlashCommand) });
2437
+ var CompleteRequest = z13.object({ text: z13.string().min(1).max(500) });
2438
+ var CompletionItem = z13.object({
2439
+ value: z13.string(),
2440
+ label: z13.string(),
2441
+ description: z13.string().nullable()
2442
+ });
2443
+ var SessionCompleteResult = z13.object({
2444
+ items: z13.array(CompletionItem).max(50),
2445
+ prefix: z13.string()
2446
+ });
2447
+ var TreeRow = z13.object({
2448
+ entryId: z13.string(),
2449
+ parentId: z13.string().nullable(),
2450
+ depth: z13.number().int(),
2451
+ role: z13.enum(["user", "assistant"]),
2452
+ text: z13.string(),
2453
+ activeBranch: z13.boolean(),
2454
+ leaf: z13.boolean(),
2455
+ label: z13.string().nullable(),
2456
+ at: z13.string().nullable()
2457
+ });
2458
+ var SessionTreeResult = z13.object({ rows: z13.array(TreeRow) });
2459
+ var BranchRequest = z13.object({
2460
+ entryId: z13.string().nullable(),
2461
+ fork: z13.boolean().default(false)
2462
+ });
2463
+ var HostBranchResult = z13.object({
2464
+ sessionFile: z13.string().nullable(),
2465
+ prefill: z13.string().nullable()
2466
+ });
2467
+ var TranscriptPage = z13.object({
2468
+ items: z13.array(TranscriptItem),
2469
+ hasMore: z13.boolean(),
2470
+ epoch: z13.number().int().optional(),
2471
+ rev: z13.number().int().optional(),
2472
+ delta: z13.boolean().optional(),
2473
+ reset: z13.boolean().optional()
2474
+ });
2475
+ var NavigateRequest = z13.object({
2476
+ entryId: z13.string().min(1),
2477
+ summarize: z13.boolean().default(false),
2478
+ instructions: z13.string().max(2e3).nullable().default(null)
2479
+ });
2480
+ var HostNavigateResult = z13.object({
2481
+ items: z13.array(TranscriptItem),
2482
+ prefill: z13.string().nullable()
2483
+ });
2484
+ var NavigateResult = z13.object({
2485
+ prefill: z13.string().nullable(),
2486
+ epoch: z13.number().int()
2487
+ });
2488
+ var BranchResult = z13.object({
2131
2489
  session: Session.nullable(),
2132
- prefill: z11.string().nullable()
2490
+ prefill: z13.string().nullable()
2133
2491
  });
2134
- var SessionExportResult = z11.object({ fileName: z11.string(), content: z11.string() });
2135
- var CommandViewAction = z11.object({
2136
- label: z11.string().min(1).max(80),
2137
- command: z11.string().startsWith("/").max(500),
2138
- tone: z11.enum(["default", "primary", "danger"]).optional()
2492
+ var SessionExportResult = z13.object({ fileName: z13.string(), content: z13.string() });
2493
+ var CommandViewAction = z13.object({
2494
+ label: z13.string().min(1).max(80),
2495
+ command: z13.string().startsWith("/").max(500),
2496
+ tone: z13.enum(["default", "primary", "danger"]).optional()
2139
2497
  });
2140
- var CommandView = z11.object({
2141
- title: z11.string().min(1).max(200),
2498
+ var CommandView = z13.object({
2499
+ title: z13.string().min(1).max(200),
2142
2500
  body: UINodeSchema,
2143
- actions: z11.array(CommandViewAction).max(30).default([])
2501
+ actions: z13.array(CommandViewAction).max(30).default([])
2144
2502
  });
2145
- var ModelStateResult = z11.object({
2503
+ var ModelStateResult = z13.object({
2146
2504
  model: SessionModel.nullable(),
2147
2505
  thinking: ThinkingLevel.nullable()
2148
2506
  });
2149
- var ImportSessionRequest = z11.object({
2150
- hostId: z11.string(),
2151
- sessionFile: z11.string(),
2152
- projectId: z11.string().nullable().optional()
2507
+ var ImportSessionRequest = z13.object({
2508
+ hostId: z13.string(),
2509
+ sessionFile: z13.string(),
2510
+ projectId: z13.string().nullable().optional()
2153
2511
  });
2154
- var AnswerRequest = z11.object({
2155
- revision: z11.number().int(),
2512
+ var AnswerRequest = z13.object({
2513
+ revision: z13.number().int(),
2156
2514
  response: InteractionResponseSchema
2157
2515
  });
2158
- var AdapterActionRequest = z11.object({
2159
- adapterId: z11.string(),
2160
- actionId: z11.string(),
2161
- payload: z11.unknown().optional()
2162
- });
2163
- var TaskPolicyPatch = z11.object({
2164
- hostId: z11.string().nullable().optional(),
2165
- profileId: z11.string().nullable().optional(),
2166
- workspace: z11.object({
2167
- mode: z11.enum(["new_worktree", "existing"]).optional(),
2168
- branch: z11.string().nullable().optional(),
2169
- base: z11.string().nullable().optional(),
2170
- workspaceId: z11.string().optional()
2516
+ var AdapterActionRequest = z13.object({
2517
+ generation: z13.string().uuid().optional(),
2518
+ adapterId: z13.string(),
2519
+ actionId: z13.string(),
2520
+ payload: z13.unknown().optional()
2521
+ });
2522
+ var TaskPolicyPatch = z13.object({
2523
+ hostId: z13.string().nullable().optional(),
2524
+ profileId: z13.string().nullable().optional(),
2525
+ workspace: z13.object({
2526
+ mode: z13.enum(["new_worktree", "existing"]).optional(),
2527
+ branch: z13.string().nullable().optional(),
2528
+ base: z13.string().nullable().optional(),
2529
+ workspaceId: z13.string().optional()
2171
2530
  }).optional(),
2172
- continuation: z11.object({
2173
- enabled: z11.boolean().optional(),
2174
- objective: z11.string().min(1).optional(),
2175
- maxContinuations: z11.number().int().min(1).max(50).optional(),
2176
- maxElapsedMinutes: z11.number().int().min(1).max(1440).optional(),
2177
- maxTokens: z11.number().int().positive().nullable().optional(),
2178
- maxCostUsd: z11.number().positive().nullable().optional()
2531
+ continuation: z13.object({
2532
+ enabled: z13.boolean().optional(),
2533
+ objective: z13.string().min(1).optional(),
2534
+ maxContinuations: z13.number().int().min(1).max(50).optional(),
2535
+ maxElapsedMinutes: z13.number().int().min(1).max(1440).optional(),
2536
+ maxTokens: z13.number().int().positive().nullable().optional(),
2537
+ maxCostUsd: z13.number().positive().nullable().optional()
2179
2538
  }).optional(),
2180
2539
  completion: CompletionPolicy.partial().optional()
2181
2540
  });
2182
- var CreateTaskRequest = z11.object({
2183
- projectId: z11.string(),
2184
- title: z11.string().max(300).optional(),
2541
+ var CreateTaskRequest = z13.object({
2542
+ projectId: z13.string(),
2543
+ title: z13.string().max(300).optional(),
2185
2544
  githubIssueUrl: GitHubIssueUrl.optional(),
2186
- githubIssue: z11.never().optional(),
2187
- launchPrompt: z11.never().optional(),
2188
- objective: z11.string().default(""),
2189
- acceptanceCriteria: z11.array(z11.string()).default([]),
2190
- dependencies: z11.array(z11.string()).default([]),
2191
- parentTaskId: z11.string().nullable().optional(),
2545
+ githubIssue: z13.never().optional(),
2546
+ launchPrompt: z13.never().optional(),
2547
+ objective: z13.string().default(""),
2548
+ acceptanceCriteria: z13.array(z13.string()).default([]),
2549
+ dependencies: z13.array(z13.string()).default([]),
2550
+ parentTaskId: z13.string().nullable().optional(),
2192
2551
  priority: Priority.default(2),
2193
- state: z11.enum(["backlog", "ready"]).default("backlog"),
2194
- notBefore: z11.string().nullable().optional(),
2552
+ state: z13.enum(["backlog", "ready"]).default("backlog"),
2553
+ notBefore: z13.string().nullable().optional(),
2195
2554
  policy: TaskPolicyPatch.optional()
2196
2555
  }).superRefine((v, ctx) => {
2197
2556
  if (v.githubIssueUrl === void 0) {
@@ -2229,32 +2588,32 @@ var CreateTaskRequest = z11.object({
2229
2588
  const issue = githubIssueFromUrl(v.githubIssueUrl);
2230
2589
  return { ...v, title: v.title?.trim() || `${issue.repository} #${issue.number}` };
2231
2590
  });
2232
- var UpdateTaskRequest = z11.object({
2233
- githubIssueUrl: z11.never().optional(),
2234
- githubIssue: z11.never().optional(),
2235
- launchPrompt: z11.never().optional(),
2236
- title: z11.string().min(1).max(300).optional(),
2237
- objective: z11.string().optional(),
2238
- acceptanceCriteria: z11.array(z11.string()).optional(),
2239
- dependencies: z11.array(z11.string()).optional(),
2240
- parentTaskId: z11.string().nullable().optional(),
2591
+ var UpdateTaskRequest = z13.object({
2592
+ githubIssueUrl: z13.never().optional(),
2593
+ githubIssue: z13.never().optional(),
2594
+ launchPrompt: z13.never().optional(),
2595
+ title: z13.string().min(1).max(300).optional(),
2596
+ objective: z13.string().optional(),
2597
+ acceptanceCriteria: z13.array(z13.string()).optional(),
2598
+ dependencies: z13.array(z13.string()).optional(),
2599
+ parentTaskId: z13.string().nullable().optional(),
2241
2600
  priority: Priority.optional(),
2242
- position: z11.number().optional(),
2243
- notBefore: z11.string().nullable().optional(),
2601
+ position: z13.number().optional(),
2602
+ notBefore: z13.string().nullable().optional(),
2244
2603
  policy: TaskPolicyPatch.optional()
2245
2604
  });
2246
- var MoveTaskRequest = z11.object({
2605
+ var MoveTaskRequest = z13.object({
2247
2606
  to: TaskState,
2248
- confirm: z11.boolean().optional(),
2249
- onRunning: z11.enum(["pause", "stop"]).optional(),
2250
- position: z11.number().optional()
2607
+ confirm: z13.boolean().optional(),
2608
+ onRunning: z13.enum(["pause", "stop"]).optional(),
2609
+ position: z13.number().optional()
2251
2610
  });
2252
- var RequestChangesRequest = z11.object({ feedback: z11.array(z11.string().min(1)).min(1) });
2253
- var Eligibility = z11.union([
2254
- z11.object({ eligible: z11.literal(true), hostId: z11.string(), hostName: z11.string() }),
2255
- z11.object({
2256
- eligible: z11.literal(false),
2257
- wait: z11.enum([
2611
+ var RequestChangesRequest = z13.object({ feedback: z13.array(z13.string().min(1)).min(1) });
2612
+ var Eligibility = z13.union([
2613
+ z13.object({ eligible: z13.literal(true), hostId: z13.string(), hostName: z13.string() }),
2614
+ z13.object({
2615
+ eligible: z13.literal(false),
2616
+ wait: z13.enum([
2258
2617
  "dependency",
2259
2618
  "host_offline",
2260
2619
  "project_limit",
@@ -2267,145 +2626,145 @@ var Eligibility = z11.union([
2267
2626
  "already_dispatched",
2268
2627
  "retry_backoff"
2269
2628
  ]),
2270
- message: z11.string()
2629
+ message: z13.string()
2271
2630
  })
2272
2631
  ]);
2273
- var NowResponse = z11.object({
2274
- running: z11.array(z11.object({ taskId: z11.string(), runId: z11.string(), sessionId: z11.string().nullable() })),
2275
- queued: z11.array(z11.object({ taskId: z11.string(), eligibility: Eligibility })),
2276
- dispatchPaused: z11.boolean()
2277
- });
2278
- var AutomationInput = z11.object({
2279
- name: z11.string().min(1),
2280
- enabled: z11.boolean().default(true),
2281
- projectId: z11.string(),
2632
+ var NowResponse = z13.object({
2633
+ running: z13.array(z13.object({ taskId: z13.string(), runId: z13.string(), sessionId: z13.string().nullable() })),
2634
+ queued: z13.array(z13.object({ taskId: z13.string(), eligibility: Eligibility })),
2635
+ dispatchPaused: z13.boolean()
2636
+ });
2637
+ var AutomationInput = z13.object({
2638
+ name: z13.string().min(1),
2639
+ enabled: z13.boolean().default(true),
2640
+ projectId: z13.string(),
2282
2641
  trigger: Trigger,
2283
- filters: z11.array(z11.object({ path: z11.string(), equals: z11.string() })).default([]),
2642
+ filters: z13.array(z13.object({ path: z13.string(), equals: z13.string() })).default([]),
2284
2643
  template: TaskTemplate,
2285
- hostId: z11.string().nullable().default(null),
2286
- profileId: z11.string().nullable().default(null),
2287
- mode: z11.enum(["fresh", "continue", "watch"]).default("fresh"),
2288
- groupingKey: z11.string().nullable().default(null),
2289
- overlap: z11.enum(["skip", "queue_one", "append"]).default("skip"),
2290
- missed: z11.enum(["skip", "run_once"]).default("skip"),
2644
+ hostId: z13.string().nullable().default(null),
2645
+ profileId: z13.string().nullable().default(null),
2646
+ mode: z13.enum(["fresh", "continue", "watch"]).default("fresh"),
2647
+ groupingKey: z13.string().nullable().default(null),
2648
+ overlap: z13.enum(["skip", "queue_one", "append"]).default("skip"),
2649
+ missed: z13.enum(["skip", "run_once"]).default("skip"),
2291
2650
  continuation: ContinuationPolicy.default({ enabled: false }),
2292
2651
  completion: CompletionPolicy.default({ checks: null, requireHumanReview: true })
2293
2652
  });
2294
- var AutomationView = Automation.extend({ summary: z11.string() });
2295
- var AutomationPreview = z11.object({
2296
- summary: z11.string(),
2653
+ var AutomationView = Automation.extend({ summary: z13.string() });
2654
+ var AutomationPreview = z13.object({
2655
+ summary: z13.string(),
2297
2656
  task: TaskTemplate,
2298
- next: z11.array(z11.string())
2299
- });
2300
- var WebhookTokenResponse = z11.object({ token: z11.string(), url: z11.string() });
2301
- var PushSubscriptionRequest = z11.object({
2302
- endpoint: z11.string().url(),
2303
- keys: z11.object({ p256dh: z11.string(), auth: z11.string() }),
2304
- permission: z11.enum(["granted", "denied", "default", "unknown"]).default("granted")
2305
- });
2306
- var NotificationSettings = z11.object({
2307
- quietHours: z11.object({
2308
- start: z11.string().regex(/^\d{2}:\d{2}$/),
2309
- end: z11.string().regex(/^\d{2}:\d{2}$/),
2310
- timezone: z11.string()
2657
+ next: z13.array(z13.string())
2658
+ });
2659
+ var WebhookTokenResponse = z13.object({ token: z13.string(), url: z13.string() });
2660
+ var PushSubscriptionRequest = z13.object({
2661
+ endpoint: z13.string().url(),
2662
+ keys: z13.object({ p256dh: z13.string(), auth: z13.string() }),
2663
+ permission: z13.enum(["granted", "denied", "default", "unknown"]).default("granted")
2664
+ });
2665
+ var NotificationSettings = z13.object({
2666
+ quietHours: z13.object({
2667
+ start: z13.string().regex(/^\d{2}:\d{2}$/),
2668
+ end: z13.string().regex(/^\d{2}:\d{2}$/),
2669
+ timezone: z13.string()
2311
2670
  }).nullable(),
2312
- privatePreviews: z11.boolean(),
2313
- preferredDeviceId: z11.string().nullable()
2671
+ privatePreviews: z13.boolean(),
2672
+ preferredDeviceId: z13.string().nullable()
2314
2673
  });
2315
- var PushPayload = z11.union([
2316
- z11.object({
2317
- type: z11.literal("show"),
2318
- title: z11.string(),
2319
- body: z11.string(),
2320
- tag: z11.string(),
2321
- url: z11.string(),
2322
- renotify: z11.boolean()
2674
+ var PushPayload = z13.union([
2675
+ z13.object({
2676
+ type: z13.literal("show"),
2677
+ title: z13.string(),
2678
+ body: z13.string(),
2679
+ tag: z13.string(),
2680
+ url: z13.string(),
2681
+ renotify: z13.boolean()
2323
2682
  }),
2324
- z11.object({ type: z11.literal("clear"), tag: z11.string() })
2683
+ z13.object({ type: z13.literal("clear"), tag: z13.string() })
2325
2684
  ]);
2326
- var SetupState = z11.object({
2327
- passkey: z11.object({
2328
- available: z11.boolean(),
2329
- registered: z11.boolean(),
2330
- reason: z11.string().nullable()
2685
+ var SetupState = z13.object({
2686
+ passkey: z13.object({
2687
+ available: z13.boolean(),
2688
+ registered: z13.boolean(),
2689
+ reason: z13.string().nullable()
2331
2690
  }),
2332
- oidc: z11.object({ label: z11.string() }).nullable()
2691
+ oidc: z13.object({ label: z13.string() }).nullable()
2333
2692
  });
2334
- var PasskeyRegisterOptionsResponse = z11.object({
2335
- challengeId: z11.string(),
2336
- options: z11.unknown()
2693
+ var PasskeyRegisterOptionsResponse = z13.object({
2694
+ challengeId: z13.string(),
2695
+ options: z13.unknown()
2337
2696
  });
2338
- var PasskeyRegisterVerifyRequest = z11.object({
2339
- challengeId: z11.string(),
2340
- name: z11.string().min(1).max(80),
2341
- response: z11.unknown()
2697
+ var PasskeyRegisterVerifyRequest = z13.object({
2698
+ challengeId: z13.string(),
2699
+ name: z13.string().min(1).max(80),
2700
+ response: z13.unknown()
2342
2701
  });
2343
- var PasskeySignInOptionsResponse = z11.object({
2344
- challengeId: z11.string(),
2345
- options: z11.unknown()
2702
+ var PasskeySignInOptionsResponse = z13.object({
2703
+ challengeId: z13.string(),
2704
+ options: z13.unknown()
2346
2705
  });
2347
- var PasskeySignInVerifyRequest = z11.object({
2348
- challengeId: z11.string(),
2349
- response: z11.unknown(),
2350
- deviceName: z11.string().min(1).max(80),
2706
+ var PasskeySignInVerifyRequest = z13.object({
2707
+ challengeId: z13.string(),
2708
+ response: z13.unknown(),
2709
+ deviceName: z13.string().min(1).max(80),
2351
2710
  kind: DeviceKind.extract(["browser", "pwa"])
2352
2711
  });
2353
- var OidcBeginRequest = z11.object({
2354
- deviceName: z11.string().min(1).max(80),
2712
+ var OidcBeginRequest = z13.object({
2713
+ deviceName: z13.string().min(1).max(80),
2355
2714
  kind: DeviceKind.extract(["browser", "pwa"]),
2356
- next: z11.string().default("/"),
2357
- handoff: z11.boolean().default(false)
2358
- });
2359
- var OidcBeginResponse = z11.object({
2360
- authorizeUrl: z11.string(),
2361
- flowId: z11.string().nullable(),
2362
- pollToken: z11.string().nullable()
2363
- });
2364
- var OidcClaimRequest = z11.object({ flowId: z11.string(), pollToken: z11.string() });
2365
- var OidcClaimResponse = z11.union([
2366
- z11.object({ status: z11.literal("pending") }),
2367
- z11.object({ status: z11.literal("done"), deviceId: z11.string() })
2715
+ next: z13.string().default("/"),
2716
+ handoff: z13.boolean().default(false)
2717
+ });
2718
+ var OidcBeginResponse = z13.object({
2719
+ authorizeUrl: z13.string(),
2720
+ flowId: z13.string().nullable(),
2721
+ pollToken: z13.string().nullable()
2722
+ });
2723
+ var OidcClaimRequest = z13.object({ flowId: z13.string(), pollToken: z13.string() });
2724
+ var OidcClaimResponse = z13.union([
2725
+ z13.object({ status: z13.literal("pending") }),
2726
+ z13.object({ status: z13.literal("done"), deviceId: z13.string() })
2368
2727
  ]);
2369
- var TerminalLoginStartRequest = z11.object({ name: z11.string().min(1).max(80) });
2370
- var TerminalLoginStartResponse = z11.object({
2371
- userCode: z11.string(),
2372
- pollToken: z11.string(),
2373
- verifyUrl: z11.string(),
2374
- expiresAt: z11.string(),
2375
- intervalMs: z11.number().int()
2376
- });
2377
- var TerminalLoginClaimRequest = z11.object({
2378
- userCode: z11.string().min(1),
2379
- pollToken: z11.string().min(1)
2380
- });
2381
- var TerminalLoginClaimResponse = z11.union([
2382
- z11.object({ status: z11.literal("pending") }),
2383
- z11.object({ status: z11.literal("denied") }),
2384
- z11.object({ status: z11.literal("done"), deviceId: z11.string(), credential: z11.string() })
2728
+ var TerminalLoginStartRequest = z13.object({ name: z13.string().min(1).max(80) });
2729
+ var TerminalLoginStartResponse = z13.object({
2730
+ userCode: z13.string(),
2731
+ pollToken: z13.string(),
2732
+ verifyUrl: z13.string(),
2733
+ expiresAt: z13.string(),
2734
+ intervalMs: z13.number().int()
2735
+ });
2736
+ var TerminalLoginClaimRequest = z13.object({
2737
+ userCode: z13.string().min(1),
2738
+ pollToken: z13.string().min(1)
2739
+ });
2740
+ var TerminalLoginClaimResponse = z13.union([
2741
+ z13.object({ status: z13.literal("pending") }),
2742
+ z13.object({ status: z13.literal("denied") }),
2743
+ z13.object({ status: z13.literal("done"), deviceId: z13.string(), credential: z13.string() })
2385
2744
  ]);
2386
- var TerminalLoginRequest = z11.object({
2387
- userCode: z11.string(),
2388
- name: z11.string(),
2389
- requestedFrom: z11.string(),
2390
- createdAt: z11.string(),
2391
- expiresAt: z11.string(),
2392
- status: z11.enum(["pending", "approved", "denied"])
2393
- });
2394
- var AuthMethods = z11.object({
2395
- passkeys: z11.array(Passkey),
2396
- passkeyAvailability: z11.object({ available: z11.boolean(), reason: z11.string().nullable() }),
2397
- oidc: z11.object({
2398
- issuer: z11.string(),
2399
- label: z11.string(),
2400
- ownerMatch: z11.string(),
2401
- status: z11.enum(["ready", "error"]),
2402
- error: z11.string().nullable()
2745
+ var TerminalLoginRequest = z13.object({
2746
+ userCode: z13.string(),
2747
+ name: z13.string(),
2748
+ requestedFrom: z13.string(),
2749
+ createdAt: z13.string(),
2750
+ expiresAt: z13.string(),
2751
+ status: z13.enum(["pending", "approved", "denied"])
2752
+ });
2753
+ var AuthMethods = z13.object({
2754
+ passkeys: z13.array(Passkey),
2755
+ passkeyAvailability: z13.object({ available: z13.boolean(), reason: z13.string().nullable() }),
2756
+ oidc: z13.object({
2757
+ issuer: z13.string(),
2758
+ label: z13.string(),
2759
+ ownerMatch: z13.string(),
2760
+ status: z13.enum(["ready", "error"]),
2761
+ error: z13.string().nullable()
2403
2762
  }).nullable()
2404
2763
  });
2405
- var MeResponse = z11.object({
2764
+ var MeResponse = z13.object({
2406
2765
  device: Device,
2407
- admin: z11.boolean(),
2408
- publicUrl: z11.string()
2766
+ admin: z13.boolean(),
2767
+ publicUrl: z13.string()
2409
2768
  });
2410
2769
  var ViewInput = View.pick({
2411
2770
  name: true,
@@ -2419,65 +2778,65 @@ var ViewInput = View.pick({
2419
2778
  });
2420
2779
  var ViewPatch = ViewInput.partial();
2421
2780
  var ViewClientReport = ViewClient.omit({ lastSeenAt: true });
2422
- var ProjectSuggestionsResponse = z11.object({
2423
- suggestions: z11.array(ProjectSuggestion.extend({ name: z11.string(), preselected: z11.boolean() }))
2781
+ var ProjectSuggestionsResponse = z13.object({
2782
+ suggestions: z13.array(ProjectSuggestion.extend({ name: z13.string(), preselected: z13.boolean() }))
2424
2783
  });
2425
2784
 
2426
2785
  // packages/protocol/dist/client-wire.js
2427
- import { z as z12 } from "zod";
2428
- var SyncState = z12.object({
2429
- hosts: z12.array(Host),
2430
- projects: z12.array(Project),
2431
- checkouts: z12.array(Checkout),
2432
- workspaces: z12.array(Workspace),
2433
- profiles: z12.array(Profile),
2434
- views: z12.array(View),
2435
- sessions: z12.array(Session),
2436
- tasks: z12.array(Task),
2437
- runs: z12.array(Run),
2438
- automations: z12.array(Automation),
2439
- attention: z12.array(AttentionItem),
2440
- interactions: z12.array(Interaction),
2441
- panels: z12.array(Panel),
2442
- devices: z12.array(Device),
2443
- adapters: z12.record(z12.string(), z12.array(AdapterInfo)),
2444
- dispatchPaused: z12.boolean()
2445
- });
2446
- var Presence = z12.object({
2447
- foreground: z12.boolean(),
2448
- interactedAt: z12.string().nullable(),
2449
- viewing: z12.object({ sessionId: z12.string() }).nullable()
2786
+ import { z as z14 } from "zod";
2787
+ var SyncState = z14.object({
2788
+ hosts: z14.array(Host),
2789
+ projects: z14.array(Project),
2790
+ checkouts: z14.array(Checkout),
2791
+ workspaces: z14.array(Workspace),
2792
+ profiles: z14.array(Profile),
2793
+ views: z14.array(View),
2794
+ sessions: z14.array(Session),
2795
+ tasks: z14.array(Task),
2796
+ runs: z14.array(Run),
2797
+ automations: z14.array(Automation),
2798
+ attention: z14.array(AttentionItem),
2799
+ interactions: z14.array(Interaction),
2800
+ panels: z14.array(Panel),
2801
+ devices: z14.array(Device),
2802
+ adapters: z14.record(z14.string(), z14.array(AdapterInfo)),
2803
+ dispatchPaused: z14.boolean()
2804
+ });
2805
+ var Presence = z14.object({
2806
+ foreground: z14.boolean(),
2807
+ interactedAt: z14.string().nullable(),
2808
+ viewing: z14.object({ sessionId: z14.string() }).nullable()
2450
2809
  });
2451
2810
  var CLIENT_CAPABILITIES = ["adapter.slots.v1", "timeline.cards.v1"];
2452
- var ClientToServer = z12.discriminatedUnion("type", [
2453
- z12.object({
2454
- type: z12.literal("hello"),
2455
- cursor: z12.number().int().nullable(),
2456
- capabilities: z12.array(z12.string().min(1).max(80)).max(32).optional(),
2457
- projectionId: z12.string().max(256).nullable().optional()
2811
+ var ClientToServer = z14.discriminatedUnion("type", [
2812
+ z14.object({
2813
+ type: z14.literal("hello"),
2814
+ cursor: z14.number().int().nullable(),
2815
+ capabilities: z14.array(z14.string().min(1).max(80)).max(32).optional(),
2816
+ projectionId: z14.string().max(256).nullable().optional()
2458
2817
  }),
2459
- z12.object({ type: z12.literal("presence"), presence: Presence }),
2460
- z12.object({ type: z12.literal("ping") })
2818
+ z14.object({ type: z14.literal("presence"), presence: Presence }),
2819
+ z14.object({ type: z14.literal("ping") })
2461
2820
  ]);
2462
- var ServerToClient = z12.discriminatedUnion("type", [
2463
- z12.object({
2464
- type: z12.literal("replay"),
2465
- seq: z12.number().int(),
2466
- events: z12.array(EventEnvelope),
2467
- capabilities: z12.array(z12.enum(CLIENT_CAPABILITIES)).optional(),
2468
- projectionId: z12.string().optional()
2821
+ var ServerToClient = z14.discriminatedUnion("type", [
2822
+ z14.object({
2823
+ type: z14.literal("replay"),
2824
+ seq: z14.number().int(),
2825
+ events: z14.array(EventEnvelope),
2826
+ capabilities: z14.array(z14.enum(CLIENT_CAPABILITIES)).optional(),
2827
+ projectionId: z14.string().optional()
2469
2828
  }),
2470
- z12.object({
2471
- type: z12.literal("snapshot"),
2472
- seq: z12.number().int(),
2829
+ z14.object({
2830
+ type: z14.literal("snapshot"),
2831
+ seq: z14.number().int(),
2473
2832
  state: SyncState,
2474
- capabilities: z12.array(z12.enum(CLIENT_CAPABILITIES)).optional(),
2475
- projectionId: z12.string().optional()
2833
+ capabilities: z14.array(z14.enum(CLIENT_CAPABILITIES)).optional(),
2834
+ projectionId: z14.string().optional()
2476
2835
  }),
2477
- z12.object({ type: z12.literal("event"), event: EventEnvelope }),
2478
- z12.object({ type: z12.literal("stream"), delta: StreamDelta }),
2479
- z12.object({ type: z12.literal("pong") }),
2480
- z12.object({ type: z12.literal("force_logout"), reason: z12.string() })
2836
+ z14.object({ type: z14.literal("event"), event: EventEnvelope }),
2837
+ z14.object({ type: z14.literal("stream"), delta: StreamDelta }),
2838
+ z14.object({ type: z14.literal("pong") }),
2839
+ z14.object({ type: z14.literal("force_logout"), reason: z14.string() })
2481
2840
  ]);
2482
2841
 
2483
2842
  // packages/protocol/dist/ids.js
@@ -2488,17 +2847,17 @@ var ulid = monotonicFactory();
2488
2847
  var CLIENT_OPEN_MS = 10 * 6e4;
2489
2848
 
2490
2849
  // packages/protocol/dist/web-bridge.js
2491
- import { z as z13 } from "zod";
2850
+ import { z as z15 } from "zod";
2492
2851
  var FRAME_MAX_HEIGHT = 4e3;
2493
- var FrameToParentMessageSchema = z13.discriminatedUnion("type", [
2494
- z13.object({
2495
- type: z13.literal("action"),
2496
- actionId: z13.string().min(1).max(200),
2497
- payload: z13.unknown().optional()
2852
+ var FrameToParentMessageSchema = z15.discriminatedUnion("type", [
2853
+ z15.object({
2854
+ type: z15.literal("action"),
2855
+ actionId: z15.string().min(1).max(200),
2856
+ payload: z15.unknown().optional()
2498
2857
  }),
2499
- z13.object({
2500
- type: z13.literal("resize"),
2501
- height: z13.number().finite().min(0).max(FRAME_MAX_HEIGHT)
2858
+ z15.object({
2859
+ type: z15.literal("resize"),
2860
+ height: z15.number().finite().min(0).max(FRAME_MAX_HEIGHT)
2502
2861
  })
2503
2862
  ]);
2504
2863