@spencerboucher/switchyard 0.12.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 (178) 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 +1657 -1224
  7. package/dist/switchyard.mjs +3986 -2017
  8. package/package.json +1 -1
  9. package/web-dist/assets/AutomationView-CcxKiLxM.js +2 -0
  10. package/web-dist/assets/{AutomationView-BRVq9y-T.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-BqrWFEYY.js.map → Card-WONLvqGM.js.map} +1 -1
  15. package/web-dist/assets/Checkbox-D18Ch0n4.js +2 -0
  16. package/web-dist/assets/{Checkbox-DExv3fUO.js.map → Checkbox-D18Ch0n4.js.map} +1 -1
  17. package/web-dist/assets/Copy-D6U5ewFc.js +2 -0
  18. package/web-dist/assets/{Copy-BuBbxEQI.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-B2tdgI2D.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-DZ-qJ_AO.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-DKiwAXXz.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-DK1uv3xX.js.map → TextArea-BQPdfjO_.js.map} +1 -1
  39. package/web-dist/assets/TextLink-CCc3WEdm.js +2 -0
  40. package/web-dist/assets/{TextLink-BoFPQuaH.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-tIuyEKO0.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-BW5uUuvy.js → describe-Nw-EGTvb.js} +3 -3
  60. package/web-dist/assets/{describe-BW5uUuvy.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-CL0BGGhd.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-BKSj6mhC.js → policyLogic-4ByNprLE.js} +2 -2
  87. package/web-dist/assets/{policyLogic-BKSj6mhC.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-CSQAnBaF.js → repo-Pn-s_Ggk.js} +2 -2
  97. package/web-dist/assets/{repo-CSQAnBaF.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-M5orrPPe.js → terminal-login-BSJdzvzq.js} +2 -2
  105. package/web-dist/assets/{terminal-login-M5orrPPe.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-CA0Mbmvv.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-BTjwa4tV.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-BRVq9y-T.js +0 -2
  118. package/web-dist/assets/Card-BqrWFEYY.js +0 -2
  119. package/web-dist/assets/Checkbox-DExv3fUO.js +0 -2
  120. package/web-dist/assets/Copy-BuBbxEQI.js +0 -2
  121. package/web-dist/assets/InteractionCard-0PH6pIkH.js +0 -6
  122. package/web-dist/assets/InteractionCard-0PH6pIkH.js.map +0 -1
  123. package/web-dist/assets/Menu-BJ3Gyh5V.js +0 -2
  124. package/web-dist/assets/Menu-BJ3Gyh5V.js.map +0 -1
  125. package/web-dist/assets/Overlay-BgqVqKc6.js +0 -2
  126. package/web-dist/assets/Overlay-BgqVqKc6.js.map +0 -1
  127. package/web-dist/assets/Priority-B2tdgI2D.js +0 -2
  128. package/web-dist/assets/SegmentedControl-DzwdZG6q.js +0 -2
  129. package/web-dist/assets/SegmentedControl-DzwdZG6q.js.map +0 -1
  130. package/web-dist/assets/Select-DZ-qJ_AO.js +0 -2
  131. package/web-dist/assets/Switch-DKiwAXXz.js +0 -2
  132. package/web-dist/assets/Tabs-HOeWNnHD.js +0 -184
  133. package/web-dist/assets/Tabs-HOeWNnHD.js.map +0 -1
  134. package/web-dist/assets/TextArea-DK1uv3xX.js +0 -2
  135. package/web-dist/assets/TextLink-BoFPQuaH.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-D1G0KCOr.js +0 -2
  139. package/web-dist/assets/attention-D1G0KCOr.js.map +0 -1
  140. package/web-dist/assets/automations-DUUAfMK8.js +0 -2
  141. package/web-dist/assets/automations-DUUAfMK8.js.map +0 -1
  142. package/web-dist/assets/board-tIuyEKO0.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-O-DyPB50.js +0 -25
  146. package/web-dist/assets/code-O-DyPB50.js.map +0 -1
  147. package/web-dist/assets/enroll-CL0BGGhd.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-D-JHf__5.css +0 -2
  151. package/web-dist/assets/index-K0QOY1Li.js +0 -11
  152. package/web-dist/assets/index-K0QOY1Li.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-DNN_mtX8.js +0 -2
  158. package/web-dist/assets/more-DNN_mtX8.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-BudhqmWi.js +0 -13
  163. package/web-dist/assets/preload-helper-BudhqmWi.js.map +0 -1
  164. package/web-dist/assets/presence-05bJD5G3.js +0 -2
  165. package/web-dist/assets/queue-k4o-I9uY.js +0 -2
  166. package/web-dist/assets/queue-k4o-I9uY.js.map +0 -1
  167. package/web-dist/assets/settings-CrYZRJ7E.js +0 -7
  168. package/web-dist/assets/settings-CrYZRJ7E.js.map +0 -1
  169. package/web-dist/assets/shared-DIA598ns.js +0 -3
  170. package/web-dist/assets/shared-DIA598ns.js.map +0 -1
  171. package/web-dist/assets/states-C8oEFqek.js +0 -58
  172. package/web-dist/assets/states-C8oEFqek.js.map +0 -1
  173. package/web-dist/assets/terminal-BOV_MXPZ.js +0 -2
  174. package/web-dist/assets/timer-BCIucSXh.js +0 -2
  175. package/web-dist/assets/useBreakpoint-CA0Mbmvv.js +0 -2
  176. package/web-dist/assets/useNow-Dx0MCCez.js +0 -2
  177. package/web-dist/assets/useNow-Dx0MCCez.js.map +0 -1
  178. package/web-dist/assets/useResource-BTjwa4tV.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,448 +50,315 @@ 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);
62
+ toBody() {
63
+ return this.details === void 0 ? { code: this.code, message: this.message } : { code: this.code, message: this.message, details: this.details };
96
64
  }
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
65
  };
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);
66
+
67
+ // packages/protocol/dist/ui.js
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),
83
+ allowOther: AllowOther.optional(),
84
+ showIf: ShowIfSchema.optional()
85
+ }),
86
+ z2.object({
87
+ kind: z2.literal("multiselect"),
88
+ name: z2.string(),
89
+ label: z2.string(),
90
+ options: z2.array(OptionSchema),
91
+ allowOther: AllowOther.optional(),
92
+ min: z2.number().int().min(0).optional(),
93
+ max: z2.number().int().min(1).optional(),
94
+ showIf: ShowIfSchema.optional()
95
+ }),
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(),
103
+ showIf: ShowIfSchema.optional()
104
+ })
105
+ ]);
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() })
111
+ ]);
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()
121
+ }),
122
+ z2.object({
123
+ t: z2.literal("table"),
124
+ columns: z2.array(z2.string()),
125
+ rows: z2.array(z2.array(z2.string()))
126
+ }),
127
+ z2.object({
128
+ t: z2.literal("section"),
129
+ title: z2.string().optional(),
130
+ collapsible: z2.boolean().optional(),
131
+ children: z2.array(UINodeSchema)
132
+ }),
133
+ z2.object({
134
+ t: z2.literal("tabs"),
135
+ tabs: z2.array(z2.object({ id: z2.string(), label: z2.string(), children: z2.array(UINodeSchema) }))
136
+ }),
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()
142
+ }),
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()
150
+ }),
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()
157
+ }),
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()
164
+ }))
165
+ })
166
+ ]));
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 [];
143
179
  }
144
- return `/${parts.join("/")}`;
145
180
  }
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("/");
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;
154
197
  }
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)
198
+ var FormValueSchema = z2.union([
199
+ z2.string(),
200
+ z2.array(z2.string()),
201
+ z2.object({ other: z2.string() })
246
202
  ]);
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;
253
- }
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()
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") })
264
208
  ]);
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
209
 
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()
210
+ // packages/protocol/dist/contributions.js
211
+ var ContributionPlacement = z3.enum([
212
+ "sidebar.header",
213
+ "sidebar.footer",
214
+ "session.panel",
215
+ "composer.pill",
216
+ "palette.item",
217
+ "slash.command"
372
218
  ]);
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()
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);
222
+ var Common = {
223
+ placement: ContributionPlacement,
224
+ order: z3.number().int().min(-1e3).max(1e3).optional(),
225
+ actionId: ActionId.optional()
416
226
  };
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
- }
227
+ var ContributionDescriptor = z3.object({
228
+ id: Id,
229
+ ...Common,
230
+ name: z3.string().regex(/^[a-z][a-z0-9-]{0,39}$/).optional(),
231
+ keywords: Keywords.optional()
232
+ }).strict().superRefine((v, ctx) => {
233
+ if (v.placement === "slash.command" && (!v.name || !v.actionId)) {
234
+ ctx.addIssue({ code: "custom", message: "Slash commands need name and actionId" });
453
235
  }
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
- });
236
+ if (v.placement === "palette.item" && !v.actionId) {
237
+ ctx.addIssue({ code: "custom", message: "Palette items need actionId" });
238
+ }
239
+ if (v.placement !== "slash.command" && v.name !== void 0) {
240
+ ctx.addIssue({ code: "custom", message: "Only slash commands have names" });
241
+ }
242
+ if (v.placement !== "palette.item" && v.keywords !== void 0) {
243
+ ctx.addIssue({ code: "custom", message: "Only palette items have keywords" });
244
+ }
245
+ if (v.placement === "composer.pill" && v.actionId !== void 0) {
246
+ ctx.addIssue({ code: "custom", message: "Composer pills are not interactive" });
460
247
  }
461
248
  });
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 z10 } from "zod";
249
+ var ContributionInput = z3.object({
250
+ ...Common,
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(),
256
+ keywords: Keywords.optional()
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
+ }
481
354
 
482
355
  // packages/protocol/dist/entities.js
483
356
  import { z as z6 } from "zod";
484
357
 
485
358
  // packages/protocol/dist/github.js
486
359
  import { z as z4 } from "zod";
487
- var Id3 = z4.string().min(1).max(200);
488
- var Instant3 = z4.string().refine((s) => {
360
+ var Id2 = z4.string().min(1).max(200);
361
+ var Instant = z4.string().refine((s) => {
489
362
  try {
490
363
  return new Date(s).toISOString() === s;
491
364
  } catch {
@@ -497,7 +370,7 @@ var nonnegative = z4.number().int().safe().nonnegative();
497
370
  var reason = z4.string().min(1).max(2e3);
498
371
  var hash = z4.string().regex(/^[0-9a-f]{64}$/);
499
372
  var actionsId = z4.string().regex(/^[1-9][0-9]{0,19}$/);
500
- var bytes2 = (s) => new TextEncoder().encode(s).length;
373
+ var bytes = (s) => new TextEncoder().encode(s).length;
501
374
  var displayUrl = z4.string().max(4096).refine((s) => {
502
375
  try {
503
376
  const u = new URL(s);
@@ -581,21 +454,21 @@ var GitHubCheck = z4.object({
581
454
  link: displayUrl.nullable(),
582
455
  workflow: z4.string().max(300).nullable(),
583
456
  event: z4.string().max(100).nullable(),
584
- startedAt: Instant3.nullable(),
585
- completedAt: Instant3.nullable(),
457
+ startedAt: Instant.nullable(),
458
+ completedAt: Instant.nullable(),
586
459
  description: z4.string().max(2e3).nullable(),
587
460
  actionsJob: z4.object({ runId: actionsId, jobId: actionsId, attempt: positive }).strict().nullable()
588
461
  }).strict();
589
462
  var GitHubComment = z4.object({
590
- id: Id3,
463
+ id: Id2,
591
464
  author: z4.string().min(1).max(200).nullable(),
592
465
  body: z4.string().refine((v) => [...v].length <= 8e3),
593
466
  bodyTruncated: z4.boolean(),
594
467
  url: githubUrl,
595
- createdAt: Instant3.nullable()
468
+ createdAt: Instant.nullable()
596
469
  }).strict();
597
470
  var GitHubThread = z4.object({
598
- id: Id3,
471
+ id: Id2,
599
472
  isResolved: z4.literal(false),
600
473
  isOutdated: z4.boolean(),
601
474
  path: z4.string().max(8192).nullable(),
@@ -634,8 +507,8 @@ var WorkspaceGitHub = z4.object({
634
507
  repository: GitHubRepository.nullable(),
635
508
  headRepository: GitHubRepository.nullable(),
636
509
  branch: z4.string().min(1).max(255).nullable(),
637
- fetchedAt: Instant3.nullable(),
638
- attemptedAt: Instant3,
510
+ fetchedAt: Instant.nullable(),
511
+ attemptedAt: Instant,
639
512
  status: z4.enum(["ready", "unavailable", "error", "ambiguous"]),
640
513
  reason: reason.nullable(),
641
514
  pullRequest: GitHubPullRequest.nullable(),
@@ -645,7 +518,7 @@ var WorkspaceGitHub = z4.object({
645
518
  threadsComplete: z4.boolean(),
646
519
  truncated: z4.boolean()
647
520
  }).strict().refine((v) => {
648
- 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)
649
522
  return false;
650
523
  if (v.pullRequest && (!v.repository || !matchesPr(v.pullRequest.url, v.repository, v.pullRequest.number)))
651
524
  return false;
@@ -685,20 +558,20 @@ var GitHubJobLog = z4.object({
685
558
  lineCount: nonnegative.max(150),
686
559
  truncated: z4.boolean(),
687
560
  reason: reason.nullable()
688
- }).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);
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);
689
562
  var GitHubLogs = z4.object({
690
563
  github: HostGitHub,
691
564
  repository: GitHubRepository,
692
565
  number: positive,
693
566
  headOid: GitHubSha,
694
- fetchedAt: Instant3,
567
+ fetchedAt: Instant,
695
568
  status: z4.enum(["ready", "unavailable", "error"]),
696
569
  reason: reason.nullable(),
697
570
  jobs: z4.array(GitHubJobLog).max(10),
698
571
  complete: z4.boolean(),
699
572
  truncated: z4.boolean(),
700
573
  omittedJobs: nonnegative.nullable()
701
- }).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));
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));
702
575
  var GitHubLogsRequest = z4.object({ expectedHeadOid: GitHubSha }).strict();
703
576
  var GitHubMergeRequest = z4.object({ expectedHeadOid: GitHubSha }).strict();
704
577
  var mergeFields = {
@@ -713,13 +586,13 @@ var GitHubMergeResult = z4.discriminatedUnion("status", [
713
586
  status: z4.literal("merged"),
714
587
  ...mergeFields,
715
588
  mergeCommitOid: GitHubSha.nullable(),
716
- confirmedAt: Instant3
589
+ confirmedAt: Instant
717
590
  }).strict(),
718
591
  z4.object({
719
592
  status: z4.literal("outcome_unknown"),
720
593
  ...mergeFields,
721
594
  reason,
722
- attemptedAt: Instant3
595
+ attemptedAt: Instant
723
596
  }).strict()
724
597
  ]).refine((v) => matchesPr(v.url, v.repository, v.number));
725
598
  var path = z4.string().min(1).max(8192);
@@ -729,118 +602,306 @@ var GitHubHostMergeRequest = GitHubHostLogsRequest.extend({
729
602
  expectedPullRequestNodeId: z4.string().min(1)
730
603
  });
731
604
 
732
- // packages/protocol/dist/ui.js
605
+ // packages/protocol/dist/policies.js
733
606
  import { z as z5 } from "zod";
734
- var ToneSchema = z5.enum(["default", "muted", "success", "warning", "danger"]);
735
- var ShowIfSchema = z5.object({ field: z5.string(), values: z5.array(z5.string()) });
736
- var OptionSchema = z5.object({
737
- value: z5.string(),
738
- label: z5.string(),
739
- description: z5.string().optional(),
740
- preview: z5.string().optional()
741
- });
742
- var AllowOther = z5.object({ label: z5.string(), placeholder: z5.string().optional() });
743
- var FieldSchema = z5.discriminatedUnion("kind", [
744
- z5.object({
745
- kind: z5.literal("select"),
746
- name: z5.string(),
747
- label: z5.string(),
748
- options: z5.array(OptionSchema),
749
- allowOther: AllowOther.optional(),
750
- showIf: ShowIfSchema.optional()
751
- }),
752
- z5.object({
753
- kind: z5.literal("multiselect"),
754
- name: z5.string(),
755
- label: z5.string(),
756
- options: z5.array(OptionSchema),
757
- allowOther: AllowOther.optional(),
758
- min: z5.number().int().min(0).optional(),
759
- max: z5.number().int().min(1).optional(),
760
- showIf: ShowIfSchema.optional()
761
- }),
762
- z5.object({
763
- kind: z5.literal("text"),
764
- name: z5.string(),
765
- label: z5.string(),
766
- placeholder: z5.string().optional(),
767
- multiline: z5.boolean().optional(),
768
- prefill: z5.string().optional(),
769
- showIf: ShowIfSchema.optional()
770
- })
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"
771
666
  ]);
772
- var RefSchema = z5.discriminatedUnion("kind", [
773
- z5.object({ kind: z5.literal("file"), path: z5.string() }),
774
- z5.object({ kind: z5.literal("session"), sessionId: z5.string() }),
775
- z5.object({ kind: z5.literal("task"), taskId: z5.string() }),
776
- z5.object({ kind: z5.literal("native_session"), hostId: z5.string(), sessionFile: z5.string() })
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)
777
803
  ]);
778
- var UINodeSchema = z5.lazy(() => z5.discriminatedUnion("t", [
779
- z5.object({ t: z5.literal("text"), text: z5.string(), tone: ToneSchema.optional() }),
780
- z5.object({ t: z5.literal("markdown"), text: z5.string() }),
781
- z5.object({ t: z5.literal("code"), text: z5.string(), lang: z5.string().optional() }),
782
- z5.object({ t: z5.literal("diff"), patch: z5.string() }),
783
- z5.object({
784
- t: z5.literal("list"),
785
- items: z5.array(UINodeSchema),
786
- ordered: z5.boolean().optional()
787
- }),
788
- z5.object({
789
- t: z5.literal("table"),
790
- columns: z5.array(z5.string()),
791
- rows: z5.array(z5.array(z5.string()))
792
- }),
793
- z5.object({
794
- t: z5.literal("section"),
795
- title: z5.string().optional(),
796
- collapsible: z5.boolean().optional(),
797
- children: z5.array(UINodeSchema)
798
- }),
799
- z5.object({
800
- t: z5.literal("tabs"),
801
- tabs: z5.array(z5.object({ id: z5.string(), label: z5.string(), children: z5.array(UINodeSchema) }))
802
- }),
803
- z5.object({
804
- t: z5.literal("progress"),
805
- label: z5.string(),
806
- value: z5.number().min(0).max(1).optional(),
807
- status: z5.enum(["running", "ok", "error"]).optional()
808
- }),
809
- z5.object({ t: z5.literal("ref"), ref: RefSchema, label: z5.string() }),
810
- z5.object({
811
- t: z5.literal("form"),
812
- formId: z5.string(),
813
- fields: z5.array(FieldSchema),
814
- submitLabel: z5.string(),
815
- cancelLabel: z5.string().optional()
816
- }),
817
- z5.object({
818
- t: z5.literal("confirm"),
819
- message: z5.string(),
820
- confirmLabel: z5.string(),
821
- cancelLabel: z5.string(),
822
- destructive: z5.boolean().optional()
823
- }),
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
+ }
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(),
824
815
  z5.object({
825
- t: z5.literal("actions"),
826
- actions: z5.array(z5.object({
827
- id: z5.string(),
828
- label: z5.string(),
829
- tone: z5.enum(["default", "primary", "danger"]).optional()
830
- }))
831
- })
832
- ]));
833
- var FormValueSchema = z5.union([
834
- z5.string(),
835
- z5.array(z5.string()),
836
- z5.object({ other: z5.string() })
816
+ verdict: z5.literal("ASK"),
817
+ decisionId: Id3,
818
+ interactionId: Id3,
819
+ interactionUrl: webUrl
820
+ }).strict()
837
821
  ]);
838
- var InteractionResponseSchema = z5.discriminatedUnion("kind", [
839
- z5.object({ kind: z5.literal("form"), values: z5.record(z5.string(), FormValueSchema) }),
840
- z5.object({ kind: z5.literal("confirm"), confirmed: z5.boolean() }),
841
- z5.object({ kind: z5.literal("action"), actionId: z5.string() }),
842
- z5.object({ kind: z5.literal("cancel") })
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()
843
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);
844
905
 
845
906
  // packages/protocol/dist/entities.js
846
907
  var Iso = z6.string();
@@ -877,6 +938,8 @@ var RuntimeCapabilities = CoreCapabilities.extend({
877
938
  agentRequests: z6.boolean().optional(),
878
939
  messageDelivery: z6.boolean().optional(),
879
940
  policies: z6.boolean().optional(),
941
+ /** Session-scoped adapter inspection and safe reload. */
942
+ adapterDevelopment: z6.boolean().optional(),
880
943
  unsupported: z6.array(z6.object({ capability: z6.string(), reason: z6.string() }))
881
944
  });
882
945
  var ProjectScan = z6.object({
@@ -1089,6 +1152,8 @@ var Session = z6.object({
1089
1152
  terminal: z6.boolean().optional(),
1090
1153
  /** Set when the session finished or failed with nobody viewing it; cleared when viewed (coordinator-owned). */
1091
1154
  unreadSince: Iso.nullable().optional(),
1155
+ /** Identity of the adapter presentation currently installed on the host. */
1156
+ adapterGeneration: z6.string().uuid().optional(),
1092
1157
  /** Bumped when the transcript is rebuilt (rewind); clients drop cached copies (coordinator-owned). */
1093
1158
  transcriptEpoch: z6.number().int().min(0).optional(),
1094
1159
  bridge: z6.object({
@@ -1345,7 +1410,8 @@ var ToolItemData = z6.object({
1345
1410
  startedAt: Iso,
1346
1411
  durationMs: z6.number().nullable(),
1347
1412
  card: UINodeSchema.nullable(),
1348
- adapterId: z6.string().nullable()
1413
+ adapterId: z6.string().nullable(),
1414
+ adapterGeneration: z6.string().uuid().optional()
1349
1415
  });
1350
1416
  var TranscriptItem = z6.discriminatedUnion("kind", [
1351
1417
  z6.object({
@@ -1391,7 +1457,14 @@ var TranscriptItem = z6.discriminatedUnion("kind", [
1391
1457
  order: z6.number().int(),
1392
1458
  at: Iso,
1393
1459
  kind: z6.literal("notice"),
1394
- data: z6.object({ level: DiagnosticLevel, text: z6.string() })
1460
+ data: z6.object({
1461
+ level: DiagnosticLevel,
1462
+ text: z6.string(),
1463
+ customType: z6.string().min(1).max(200).optional(),
1464
+ card: UINodeSchema.optional(),
1465
+ adapterId: z6.string().optional(),
1466
+ adapterGeneration: z6.string().uuid().optional()
1467
+ }).refine((data) => !data.card || !!data.adapterId, "Card requires adapterId")
1395
1468
  }),
1396
1469
  z6.object({
1397
1470
  id: Id4,
@@ -1432,6 +1505,9 @@ var Panel = z6.object({
1432
1505
  node: UINodeSchema.nullable(),
1433
1506
  webRenderer: z6.boolean(),
1434
1507
  mobileFallback: z6.string().nullable(),
1508
+ contribution: ContributionDescriptor.optional(),
1509
+ state: z6.unknown().optional(),
1510
+ adapterGeneration: z6.string().uuid().optional(),
1435
1511
  updatedAt: Iso
1436
1512
  });
1437
1513
  var Diagnostic = z6.object({
@@ -1463,39 +1539,378 @@ var Passkey = z6.object({
1463
1539
  transports: z6.array(z6.string())
1464
1540
  });
1465
1541
 
1466
- // packages/protocol/dist/host-wire.js
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
1467
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
+ }
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";
1880
+
1881
+ // packages/protocol/dist/host-wire.js
1882
+ import { z as z12 } from "zod";
1468
1883
 
1469
1884
  // packages/protocol/dist/events.js
1470
- import { z as z7 } from "zod";
1885
+ import { z as z10 } from "zod";
1471
1886
  var EventDataSchemas = {
1472
1887
  "host.updated": Host,
1473
1888
  "project.updated": Project,
1474
- "project.deleted": z7.object({ id: z7.string() }),
1889
+ "project.deleted": z10.object({ id: z10.string() }),
1475
1890
  "checkout.updated": Checkout,
1476
1891
  "workspace.updated": Workspace,
1477
- "workspace.deleted": z7.object({ id: z7.string() }),
1892
+ "workspace.deleted": z10.object({ id: z10.string() }),
1478
1893
  "profile.updated": Profile,
1479
- "profile.deleted": z7.object({ id: z7.string() }),
1894
+ "profile.deleted": z10.object({ id: z10.string() }),
1480
1895
  "view.updated": View,
1481
- "view.deleted": z7.object({ id: z7.string() }),
1896
+ "view.deleted": z10.object({ id: z10.string() }),
1482
1897
  "session.updated": Session,
1483
1898
  "transcript.item": TranscriptItem,
1484
- "transcript.reset": z7.object({ sessionId: z7.string(), epoch: z7.number().int() }),
1899
+ "transcript.reset": z10.object({ sessionId: z10.string(), epoch: z10.number().int() }),
1485
1900
  "interaction.updated": Interaction,
1486
1901
  "panel.updated": Panel,
1487
- "adapters.updated": z7.object({ hostId: z7.string(), adapters: z7.array(AdapterInfo) }),
1902
+ "adapters.updated": z10.object({ hostId: z10.string(), adapters: z10.array(AdapterInfo) }),
1488
1903
  diagnostic: Diagnostic,
1489
1904
  "task.updated": Task,
1490
- "task.deleted": z7.object({ id: z7.string() }),
1905
+ "task.deleted": z10.object({ id: z10.string() }),
1491
1906
  "run.updated": Run,
1492
1907
  "automation.updated": Automation,
1493
- "automation.deleted": z7.object({ id: z7.string() }),
1908
+ "automation.deleted": z10.object({ id: z10.string() }),
1494
1909
  "occurrence.created": Occurrence,
1495
1910
  "occurrence.updated": Occurrence,
1496
1911
  "attention.updated": AttentionItem,
1497
1912
  "device.updated": Device,
1498
- "settings.updated": z7.object({ dispatchPaused: z7.boolean() })
1913
+ "settings.updated": z10.object({ dispatchPaused: z10.boolean() })
1499
1914
  };
1500
1915
  var EVENT_TYPES = Object.keys(EventDataSchemas);
1501
1916
  var LEGACY_EVENT_TYPES = {
@@ -1505,19 +1920,19 @@ function canonicalEventType(type) {
1505
1920
  return LEGACY_EVENT_TYPES[type] ?? type;
1506
1921
  }
1507
1922
  var canonical = (v) => typeof v === "string" ? canonicalEventType(v) : v;
1508
- var EventTypeSchema = z7.preprocess(canonical, z7.enum(EVENT_TYPES));
1509
- var EventScope = z7.object({
1510
- hostId: z7.string().optional(),
1511
- sessionId: z7.string().optional(),
1512
- taskId: z7.string().optional(),
1513
- projectId: z7.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()
1514
1929
  });
1515
1930
  var EventEnvelope = EventScope.extend({
1516
- seq: z7.number().int(),
1517
- id: z7.string(),
1931
+ seq: z10.number().int(),
1932
+ id: z10.string(),
1518
1933
  type: EventTypeSchema,
1519
- at: z7.string(),
1520
- data: z7.unknown()
1934
+ at: z10.string(),
1935
+ data: z10.unknown()
1521
1936
  });
1522
1937
  var HOST_EVENT_TYPES = [
1523
1938
  "session.updated",
@@ -1530,318 +1945,321 @@ var HOST_EVENT_TYPES = [
1530
1945
  "workspace.deleted"
1531
1946
  ];
1532
1947
  var HostEvent = EventScope.extend({
1533
- eventId: z7.string(),
1534
- type: z7.preprocess(canonical, z7.enum(HOST_EVENT_TYPES)),
1535
- at: z7.string(),
1536
- data: z7.unknown()
1537
- });
1538
- var StreamDelta = z7.object({
1539
- sessionId: z7.string(),
1540
- itemId: z7.string(),
1541
- kind: z7.enum(["text", "thinking", "tool_args", "tool_output"]),
1542
- delta: z7.string(),
1543
- order: z7.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()
1544
1959
  });
1545
1960
 
1546
1961
  // packages/protocol/dist/terminal-wire.js
1547
- import { z as z8 } from "zod";
1548
- var Cols = z8.number().int().min(10).max(1e3);
1549
- var Rows = z8.number().int().min(5).max(500);
1550
- var TermViewerToServer = z8.discriminatedUnion("t", [
1551
- z8.object({ t: z8.literal("in"), d: z8.string() }),
1552
- z8.object({ t: z8.literal("resize"), cols: Cols, rows: Rows }),
1553
- z8.object({ t: z8.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") })
1554
1969
  ]);
1555
- var TermServerToViewer = z8.discriminatedUnion("t", [
1556
- z8.object({ t: z8.literal("out"), d: z8.string() }),
1557
- z8.object({ t: z8.literal("closed"), reason: z8.string() }),
1558
- z8.object({ t: z8.literal("size"), cols: Cols, rows: Rows, owner: z8.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() })
1559
1974
  ]);
1560
- var TermCoordinatorMsg = z8.discriminatedUnion("t", [
1561
- z8.object({
1562
- t: z8.literal("open"),
1563
- sessionId: z8.string(),
1975
+ var TermCoordinatorMsg = z11.discriminatedUnion("t", [
1976
+ z11.object({
1977
+ t: z11.literal("open"),
1978
+ sessionId: z11.string(),
1564
1979
  cols: Cols,
1565
1980
  rows: Rows,
1566
- passive: z8.boolean().optional()
1981
+ passive: z11.boolean().optional()
1567
1982
  }),
1568
- z8.object({ t: z8.literal("claim") }),
1569
- z8.object({ t: z8.literal("in"), d: z8.string() }),
1570
- z8.object({ t: z8.literal("resize"), cols: Cols, rows: Rows }),
1571
- z8.object({ t: z8.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") })
1572
1987
  ]);
1573
1988
 
1574
1989
  // packages/protocol/dist/host-wire.js
1575
- var Origin = z9.enum(["human", "automation"]);
1576
- var HostCommand = z9.discriminatedUnion("type", [
1577
- z9.object({
1578
- type: z9.literal("session.start"),
1579
- sessionId: z9.string(),
1580
- title: z9.string(),
1581
- workspacePath: z9.string(),
1582
- projectId: z9.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(),
1583
1998
  profile: Profile,
1584
1999
  nativeHandle: NativeHandle.nullable(),
1585
- initialPrompt: z9.string().nullable(),
1586
- dispatchKey: z9.string().nullable(),
1587
- controlRevision: z9.number().int(),
2000
+ initialPrompt: z12.string().nullable(),
2001
+ dispatchKey: z12.string().nullable(),
2002
+ controlRevision: z12.number().int(),
1588
2003
  controlMode: ControlMode,
1589
2004
  origin: Origin,
1590
- readOnly: z9.boolean().default(false),
1591
- policyRequired: z9.boolean().optional()
2005
+ readOnly: z12.boolean().default(false),
2006
+ policyRequired: z12.boolean().optional()
1592
2007
  }),
1593
- z9.object({
1594
- type: z9.literal("session.deliverMessage"),
1595
- sessionId: z9.string(),
1596
- messageId: z9.string(),
1597
- payload: z9.object({
1598
- deliveryId: z9.string(),
1599
- kind: z9.enum(["message", "completion"]),
1600
- text: z9.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()
1601
2016
  }),
1602
- mode: z9.enum(["steer", "queue"]),
1603
- holdUntil: z9.string()
2017
+ mode: z12.enum(["steer", "queue"]),
2018
+ holdUntil: z12.string()
1604
2019
  }),
1605
- HostPolicySampleRequest.extend({ type: z9.literal("session.classifyPolicySample") }),
1606
- z9.object({
1607
- type: z9.literal("session.messageStatus"),
1608
- sessionId: z9.string(),
1609
- messageIds: z9.array(z9.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)
1610
2025
  }),
1611
- z9.object({
1612
- type: z9.literal("session.prompt"),
1613
- sessionId: z9.string(),
1614
- text: z9.string(),
1615
- images: z9.array(z9.object({ mimeType: z9.string(), data: z9.string() })).default([]),
1616
- mode: z9.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"]),
1617
2032
  origin: Origin,
1618
- controlRevision: z9.number().int()
2033
+ controlRevision: z12.number().int()
1619
2034
  }),
1620
- z9.object({ type: z9.literal("session.abort"), sessionId: z9.string(), clearQueue: z9.boolean() }),
1621
- z9.object({ type: z9.literal("session.stop"), sessionId: z9.string() }),
1622
- z9.object({
1623
- type: z9.literal("session.answer"),
1624
- sessionId: z9.string(),
1625
- interactionId: z9.string(),
1626
- revision: z9.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(),
1627
2042
  response: InteractionResponseSchema,
1628
- deviceId: z9.string()
2043
+ deviceId: z12.string()
1629
2044
  }),
1630
- z9.object({
1631
- type: z9.literal("session.adapterAction"),
1632
- sessionId: z9.string(),
1633
- adapterId: z9.string(),
1634
- actionId: z9.string(),
1635
- payload: z9.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()
1636
2052
  }),
1637
- z9.object({
1638
- type: z9.literal("session.setControl"),
1639
- sessionId: z9.string(),
1640
- controlRevision: z9.number().int(),
2053
+ z12.object({
2054
+ type: z12.literal("session.setControl"),
2055
+ sessionId: z12.string(),
2056
+ controlRevision: z12.number().int(),
1641
2057
  mode: ControlMode
1642
2058
  }),
1643
- z9.object({ type: z9.literal("session.rename"), sessionId: z9.string(), title: z9.string() }),
1644
- z9.object({ type: z9.literal("session.importable") }),
1645
- z9.object({ type: z9.literal("session.readNative"), sessionFile: z9.string() }),
1646
- z9.object({ type: z9.literal("session.snapshot"), sessionId: z9.string() }),
1647
- z9.object({ type: z9.literal("session.models"), sessionId: z9.string() }),
1648
- z9.object({ type: z9.literal("session.commands"), sessionId: z9.string() }),
1649
- z9.object({
1650
- type: z9.literal("session.complete"),
1651
- sessionId: z9.string(),
1652
- text: z9.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)
1653
2069
  }),
1654
- z9.object({ type: z9.literal("session.tree"), sessionId: z9.string() }),
1655
- z9.object({
1656
- type: z9.literal("session.branch"),
1657
- sessionId: z9.string(),
1658
- entryId: z9.string().nullable(),
1659
- fork: z9.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()
1660
2076
  }),
1661
- z9.object({
1662
- type: z9.literal("session.navigate"),
1663
- sessionId: z9.string(),
1664
- entryId: z9.string(),
1665
- summarize: z9.boolean(),
1666
- instructions: z9.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()
1667
2083
  }),
1668
- z9.object({ type: z9.literal("session.reload"), sessionId: z9.string() }),
1669
- z9.object({ type: z9.literal("session.export"), sessionId: z9.string() }),
1670
- z9.object({
1671
- type: z9.literal("session.setModel"),
1672
- sessionId: z9.string(),
1673
- provider: z9.string().min(1),
1674
- modelId: z9.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)
1675
2093
  }),
1676
- z9.object({ type: z9.literal("session.setThinking"), sessionId: z9.string(), level: ThinkingLevel }),
1677
- z9.object({
1678
- type: z9.literal("session.compact"),
1679
- sessionId: z9.string(),
1680
- instructions: z9.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()
1681
2099
  }),
1682
- z9.object({ type: z9.literal("checkout.inspect"), path: z9.string() }),
1683
- z9.object({ type: z9.literal("projects.scan"), folder: z9.string().min(1) }),
1684
- z9.object({
1685
- type: z9.literal("projects.suggest"),
1686
- days: z9.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)
1687
2105
  }),
1688
- z9.object({
1689
- type: z9.literal("workspace.discover"),
1690
- checkoutPath: z9.string(),
1691
- worktreeDir: z9.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)
1692
2110
  }),
1693
- z9.object({
1694
- type: z9.literal("workspace.create"),
1695
- checkoutPath: z9.string(),
1696
- branch: z9.string(),
1697
- base: z9.string(),
1698
- setupCommand: z9.string().nullable(),
1699
- worktreeDir: z9.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)
1700
2118
  }),
1701
- z9.object({ type: z9.literal("workspace.status"), path: z9.string(), base: z9.string().nullable() }),
1702
- z9.object({
1703
- type: z9.literal("workspace.remove"),
1704
- path: z9.string(),
1705
- checkoutPath: z9.string(),
1706
- base: z9.string().nullable(),
1707
- force: z9.object({ dirty: z9.boolean(), unmerged: z9.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() })
1708
2126
  }),
1709
- z9.object({
1710
- type: z9.literal("workspace.diff"),
1711
- path: z9.string(),
1712
- base: z9.string().nullable(),
1713
- file: z9.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()
1714
2132
  }),
1715
- z9.object({ type: z9.literal("workspace.files"), path: z9.string(), dir: z9.string() }),
1716
- z9.object({ type: z9.literal("workspace.readFile"), path: z9.string(), file: z9.string() }),
1717
- GitHubHostViewRequest.extend({ type: z9.literal("workspace.prView") }),
1718
- GitHubHostLogsRequest.extend({ type: z9.literal("workspace.prFailedLogs") }),
1719
- GitHubHostMergeRequest.extend({ type: z9.literal("workspace.prMerge") }),
1720
- z9.object({
1721
- type: z9.literal("dispatch.start"),
1722
- dispatchKey: z9.string(),
1723
- runId: z9.string(),
1724
- taskId: z9.string(),
1725
- sessionId: z9.string(),
1726
- projectId: z9.string(),
1727
- title: z9.string(),
1728
- workspace: z9.union([
1729
- z9.object({ path: z9.string() }),
1730
- z9.object({
1731
- createFrom: z9.object({
1732
- checkoutPath: z9.string(),
1733
- branch: z9.string(),
1734
- base: z9.string(),
1735
- setupCommand: z9.string().nullable(),
1736
- worktreeDir: z9.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)
1737
2155
  })
1738
2156
  })
1739
2157
  ]),
1740
2158
  nativeHandle: NativeHandle.nullable(),
1741
2159
  profile: Profile,
1742
- prompt: z9.string(),
2160
+ prompt: z12.string(),
1743
2161
  /** The launch's own revision; a takeover always carries a newer one. */
1744
- controlRevision: z9.number().int(),
2162
+ controlRevision: z12.number().int(),
1745
2163
  controlMode: ControlMode.default("automation"),
1746
- policyRequired: z9.boolean().optional()
2164
+ policyRequired: z12.boolean().optional()
1747
2165
  }),
1748
- z9.object({ type: z9.literal("dispatch.reconcile"), dispatchKey: z9.string() }),
1749
- z9.object({
1750
- type: z9.literal("checks.run"),
1751
- sessionId: z9.string(),
1752
- path: z9.string(),
1753
- commands: z9.array(z9.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())
1754
2172
  })
1755
2173
  ]);
1756
- var ImportableSession = z9.object({
1757
- sessionFile: z9.string(),
1758
- sessionId: z9.string(),
1759
- cwd: z9.string(),
1760
- name: z9.string().nullable(),
1761
- mtime: z9.string(),
1762
- inactive: z9.boolean()
1763
- });
1764
- var DiscoveredWorktree = z9.object({
1765
- path: z9.string(),
1766
- head: z9.string().nullable(),
1767
- branch: z9.string().nullable(),
1768
- bare: z9.boolean(),
1769
- detached: z9.boolean(),
1770
- locked: z9.boolean(),
1771
- prunable: z9.boolean(),
1772
- provenance: z9.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"]),
1773
2191
  git: GitState.nullable()
1774
2192
  });
1775
- var CheckoutInfo = z9.object({
1776
- root: z9.string(),
1777
- commonDir: z9.string(),
1778
- repoIdentity: z9.string(),
1779
- defaultBranch: z9.string()
2193
+ var CheckoutInfo = z12.object({
2194
+ root: z12.string(),
2195
+ commonDir: z12.string(),
2196
+ repoIdentity: z12.string(),
2197
+ defaultBranch: z12.string()
1780
2198
  });
1781
- var ScannedRepository = CheckoutInfo.extend({ name: z9.string() });
1782
- var ProjectFolderScan = z9.object({
2199
+ var ScannedRepository = CheckoutInfo.extend({ name: z12.string() });
2200
+ var ProjectFolderScan = z12.object({
1783
2201
  /** The folder, ~ expanded and realpath'd. */
1784
- folder: z9.string(),
1785
- repositories: z9.array(ScannedRepository)
1786
- });
1787
- var ProjectSuggestion = z9.object({
1788
- rootPath: z9.string(),
1789
- sessionCount: z9.number().int(),
1790
- lastActivityAt: z9.string()
1791
- });
1792
- var ProjectSuggestions = z9.object({ suggestions: z9.array(ProjectSuggestion) });
1793
- var DiffFile = z9.object({
1794
- path: z9.string(),
1795
- oldPath: z9.string().nullable(),
1796
- added: z9.number().int(),
1797
- deleted: z9.number().int(),
1798
- status: z9.enum(["added", "modified", "deleted", "renamed", "untracked", "binary"])
1799
- });
1800
- var DiffResult = z9.object({
1801
- base: z9.string(),
1802
- files: z9.array(DiffFile),
1803
- patch: z9.string().nullable()
1804
- });
1805
- var FileEntry = z9.object({
1806
- name: z9.string(),
1807
- path: z9.string(),
1808
- kind: z9.enum(["file", "dir", "symlink"]),
1809
- size: z9.number().int().nullable()
1810
- });
1811
- var ReconcileResult = z9.union([
1812
- z9.object({ known: z9.literal(false) }),
1813
- z9.object({
1814
- known: z9.literal(true),
1815
- sessionId: z9.string().nullable(),
1816
- state: z9.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"]),
1817
2235
  runtime: RuntimeState.nullable(),
1818
- workspacePath: z9.string().nullable(),
2236
+ workspacePath: z12.string().nullable(),
1819
2237
  nativeHandle: NativeHandle.nullable(),
1820
- error: z9.string().nullable(),
2238
+ error: z12.string().nullable(),
1821
2239
  /** `{started: "unknown"}` when the host restarted after Pi may have been spawned. */
1822
- errorDetails: z9.record(z9.string(), z9.unknown()).nullable().default(null)
2240
+ errorDetails: z12.record(z12.string(), z12.unknown()).nullable().default(null)
1823
2241
  })
1824
2242
  ]);
1825
- var DispatchStartResult = z9.object({
1826
- sessionId: z9.string(),
1827
- workspacePath: z9.string(),
2243
+ var DispatchStartResult = z12.object({
2244
+ sessionId: z12.string(),
2245
+ workspacePath: z12.string(),
1828
2246
  nativeHandle: NativeHandle.nullable(),
1829
- reused: z9.boolean(),
2247
+ reused: z12.boolean(),
1830
2248
  /** Why the launch prompt was not delivered to Pi (the session itself started), if it was not. */
1831
- promptError: z9.string().nullable().optional()
2249
+ promptError: z12.string().nullable().optional()
1832
2250
  });
1833
- var AnswerResult = z9.object({
1834
- status: z9.enum(["answered", "already_answered"]),
2251
+ var AnswerResult = z12.object({
2252
+ status: z12.enum(["answered", "already_answered"]),
1835
2253
  interaction: Interaction
1836
2254
  });
1837
- var SnapshotResult = z9.object({
1838
- partial: z9.array(TranscriptItem),
1839
- pendingInteractions: z9.array(Interaction)
2255
+ var SnapshotResult = z12.object({
2256
+ partial: z12.array(TranscriptItem),
2257
+ pendingInteractions: z12.array(Interaction)
1840
2258
  });
1841
- var ChecksResult = z9.object({ results: z9.array(CheckResult) });
1842
- var Receipt = z9.union([
1843
- z9.object({ commandId: z9.string(), ok: z9.literal(true), result: z9.unknown() }),
1844
- z9.object({ commandId: z9.string(), ok: z9.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 })
1845
2263
  ]);
1846
2264
  var HostAgentRequestFrame = AgentRequestFrame.safeExtend({
1847
2265
  policyContext: HostToolPolicyContext.optional()
@@ -1860,278 +2278,279 @@ var HostAgentRequestFrame = AgentRequestFrame.safeExtend({
1860
2278
  }
1861
2279
  ctx.addIssue({ code: "custom", message: "Host agent frame exceeds 128 KiB or is not JSON." });
1862
2280
  });
1863
- var HostToCoordinator = z9.discriminatedUnion("type", [
1864
- z9.object({
1865
- type: z9.literal("hello"),
1866
- hostId: z9.string(),
1867
- credential: z9.string(),
1868
- name: z9.string(),
1869
- agentVersion: z9.string(),
1870
- piVersion: z9.string().nullable(),
1871
- piCompatible: z9.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(),
1872
2290
  platform: Platform,
1873
2291
  capabilities: RuntimeCapabilities.nullable(),
1874
2292
  github: HostGitHub.optional(),
1875
- protocolVersion: z9.number().int(),
1876
- features: z9.array(z9.string()).optional()
2293
+ protocolVersion: z12.number().int(),
2294
+ features: z12.array(z12.string()).optional()
1877
2295
  }),
1878
2296
  HostAgentRequestFrame,
1879
- z9.object({ type: z9.literal("event"), hostSeq: z9.number().int(), event: HostEvent }),
1880
- z9.object({ type: z9.literal("stream"), delta: StreamDelta }),
1881
- z9.object({ type: z9.literal("receipt"), receipt: Receipt }),
1882
- z9.object({ type: z9.literal("pong") }),
1883
- z9.object({ type: z9.literal("usage"), usage: z9.array(ProviderUsage) }),
1884
- z9.object({ type: z9.literal("term"), streamId: z9.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 })
1885
2303
  ]);
1886
- var CoordinatorToHost = z9.discriminatedUnion("type", [
1887
- z9.object({
1888
- type: z9.literal("welcome"),
1889
- coordinatorVersion: z9.string(),
1890
- ackedHostSeq: z9.number().int(),
1891
- features: z9.array(z9.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()
1892
2310
  }),
1893
2311
  AgentResultFrame,
1894
- z9.object({ type: z9.literal("ack"), hostSeq: z9.number().int() }),
1895
- z9.object({ type: z9.literal("command"), commandId: z9.string(), command: HostCommand }),
1896
- z9.object({ type: z9.literal("ping") }),
1897
- z9.object({ type: z9.literal("reject"), error: ErrorBody }),
1898
- z9.object({ type: z9.literal("term"), streamId: z9.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 })
1899
2317
  ]);
1900
2318
 
1901
2319
  // packages/protocol/dist/api.js
1902
- var EnrollRequest = z10.object({
1903
- token: z10.string().min(1),
1904
- name: z10.string().min(1).max(80),
2320
+ var EnrollRequest = z13.object({
2321
+ token: z13.string().min(1),
2322
+ name: z13.string().min(1).max(80),
1905
2323
  kind: DeviceKind
1906
2324
  });
1907
- var EnrollResponse = z10.object({ deviceId: z10.string(), credential: z10.string() });
1908
- var CreateEnrollmentRequest = z10.object({ kind: z10.enum(["device", "host"]) });
1909
- var CreateEnrollmentResponse = z10.object({
1910
- token: z10.string(),
1911
- url: z10.string(),
1912
- expiresAt: z10.string(),
1913
- qrSvg: z10.string(),
1914
- command: z10.string().nullable()
1915
- });
1916
- var HostEnrollRequest = z10.union([
1917
- z10.object({
1918
- token: z10.string().min(1),
1919
- name: z10.string().min(1).max(80),
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()
2333
+ });
2334
+ var HostEnrollRequest = z13.union([
2335
+ z13.object({
2336
+ token: z13.string().min(1),
2337
+ name: z13.string().min(1).max(80),
1920
2338
  platform: Platform
1921
2339
  }),
1922
- z10.object({
1923
- secret: z10.string().min(1),
1924
- name: z10.string().min(1).max(80),
2340
+ z13.object({
2341
+ secret: z13.string().min(1),
2342
+ name: z13.string().min(1).max(80),
1925
2343
  platform: Platform
1926
2344
  })
1927
2345
  ]);
1928
- var HostEnrollResponse = z10.object({ hostId: z10.string(), credential: z10.string() });
1929
- var CreateProjectRequest = z10.object({
1930
- name: z10.string().min(1),
1931
- hostId: z10.string(),
1932
- path: z10.string().min(1),
1933
- defaultProfileId: z10.string().nullable().optional(),
1934
- setupCommand: z10.string().nullable().optional(),
1935
- checks: z10.array(z10.string()).optional(),
1936
- maxConcurrentRuns: z10.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(),
1937
2355
  worktreeDir: WorktreeDir.optional()
1938
2356
  });
1939
- var UpdateProjectRequest = z10.object({
1940
- name: z10.string().min(1).optional(),
1941
- defaultProfileId: z10.string().nullable().optional(),
1942
- defaultHostId: z10.string().nullable().optional(),
1943
- maxConcurrentRuns: z10.number().int().min(1).max(32).optional(),
1944
- automationEnabled: z10.boolean().optional(),
1945
- setupCommand: z10.string().nullable().optional(),
1946
- checks: z10.array(z10.string()).optional(),
1947
- workspaceSharing: z10.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(),
1948
2366
  worktreeDir: WorktreeDir.optional()
1949
2367
  });
1950
- var AddCheckoutRequest = z10.object({ hostId: z10.string(), path: z10.string().min(1) });
2368
+ var AddCheckoutRequest = z13.object({ hostId: z13.string(), path: z13.string().min(1) });
1951
2369
  function isProjectFolderPath(s) {
1952
2370
  if (s.includes("\0"))
1953
2371
  return false;
1954
2372
  return s === "~" || s.startsWith("~/") || s.startsWith("/");
1955
2373
  }
1956
- var ProjectFolder = z10.string().trim().min(1).max(1024).refine(isProjectFolderPath, "must be an absolute path or start with ~/");
1957
- var UpdateHostRequest = z10.object({
1958
- projectFolders: z10.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()
1959
2377
  });
1960
2378
  var ProjectScanResult = ProjectScan.extend({
1961
- added: z10.array(z10.object({
1962
- projectId: z10.string(),
1963
- name: z10.string(),
1964
- path: z10.string(),
1965
- newProject: z10.boolean()
2379
+ added: z13.array(z13.object({
2380
+ projectId: z13.string(),
2381
+ name: z13.string(),
2382
+ path: z13.string(),
2383
+ newProject: z13.boolean()
1966
2384
  }))
1967
2385
  });
1968
- var ProfileInput = z10.object({
1969
- name: z10.string().min(1),
1970
- provider: z10.string().nullable().default(null),
1971
- model: z10.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),
1972
2390
  thinking: ThinkingLevel.nullable().default(null),
1973
- projectTrust: z10.enum(["ask", "approve", "ignore"]).default("ask"),
1974
- extraArgs: z10.array(ExtraArg).default([]),
1975
- resources: z10.enum(["all", "vanilla"]).default("all")
1976
- });
1977
- var CreateWorkspaceRequest = z10.object({
1978
- checkoutId: z10.string(),
1979
- branch: z10.string().min(1),
1980
- base: z10.string().nullable().optional()
1981
- });
1982
- var RemoveWorkspaceRequest = z10.object({
1983
- force: z10.object({ dirty: z10.boolean(), unmerged: z10.boolean() }).default({ dirty: false, unmerged: false })
1984
- });
1985
- var CreateSessionRequest = z10.object({
1986
- projectId: z10.string(),
1987
- workspace: z10.union([
1988
- z10.object({ existingId: z10.string() }),
1989
- z10.object({
1990
- checkoutId: z10.string(),
1991
- newBranch: z10.string().min(1),
1992
- base: z10.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()
1993
2411
  })
1994
2412
  ]),
1995
- profileId: z10.string().nullable().optional(),
1996
- prompt: z10.string().default(""),
1997
- title: z10.string().optional(),
1998
- viewId: z10.string().optional()
1999
- });
2000
- var PromptRequest = z10.object({
2001
- text: z10.string().min(1),
2002
- mode: z10.enum(["prompt", "steer", "followUp"]).default("prompt"),
2003
- images: z10.array(z10.object({ mimeType: z10.string(), data: z10.string() })).default([]),
2004
- clientMessageId: z10.string().optional()
2005
- });
2006
- var CacheAlertRequest = z10.object({
2007
- enabled: z10.boolean(),
2008
- ttlSec: z10.number().int().min(60).max(86400).nullable().default(null)
2009
- });
2010
- var RenameRequest = z10.object({ title: z10.string().min(1).max(200) });
2011
- var SetModelRequest = z10.object({
2012
- provider: z10.string().min(1),
2013
- modelId: z10.string().min(1)
2014
- });
2015
- var SetThinkingRequest = z10.object({ level: ThinkingLevel });
2016
- var CompactRequest = z10.object({ instructions: z10.string().max(4e3).optional() });
2017
- var SessionModelsResult = z10.object({ models: z10.array(SessionModel) });
2018
- var SessionCommandsResult = z10.object({ commands: z10.array(SlashCommand) });
2019
- var CompleteRequest = z10.object({ text: z10.string().min(1).max(500) });
2020
- var CompletionItem = z10.object({
2021
- value: z10.string(),
2022
- label: z10.string(),
2023
- description: z10.string().nullable()
2024
- });
2025
- var SessionCompleteResult = z10.object({
2026
- items: z10.array(CompletionItem).max(50),
2027
- prefix: z10.string()
2028
- });
2029
- var TreeRow = z10.object({
2030
- entryId: z10.string(),
2031
- parentId: z10.string().nullable(),
2032
- depth: z10.number().int(),
2033
- role: z10.enum(["user", "assistant"]),
2034
- text: z10.string(),
2035
- activeBranch: z10.boolean(),
2036
- leaf: z10.boolean(),
2037
- label: z10.string().nullable(),
2038
- at: z10.string().nullable()
2039
- });
2040
- var SessionTreeResult = z10.object({ rows: z10.array(TreeRow) });
2041
- var BranchRequest = z10.object({
2042
- entryId: z10.string().nullable(),
2043
- fork: z10.boolean().default(false)
2044
- });
2045
- var HostBranchResult = z10.object({
2046
- sessionFile: z10.string().nullable(),
2047
- prefill: z10.string().nullable()
2048
- });
2049
- var TranscriptPage = z10.object({
2050
- items: z10.array(TranscriptItem),
2051
- hasMore: z10.boolean(),
2052
- epoch: z10.number().int().optional(),
2053
- rev: z10.number().int().optional(),
2054
- delta: z10.boolean().optional(),
2055
- reset: z10.boolean().optional()
2056
- });
2057
- var NavigateRequest = z10.object({
2058
- entryId: z10.string().min(1),
2059
- summarize: z10.boolean().default(false),
2060
- instructions: z10.string().max(2e3).nullable().default(null)
2061
- });
2062
- var HostNavigateResult = z10.object({
2063
- items: z10.array(TranscriptItem),
2064
- prefill: z10.string().nullable()
2065
- });
2066
- var NavigateResult = z10.object({
2067
- prefill: z10.string().nullable(),
2068
- epoch: z10.number().int()
2069
- });
2070
- var BranchResult = z10.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({
2071
2489
  session: Session.nullable(),
2072
- prefill: z10.string().nullable()
2490
+ prefill: z13.string().nullable()
2073
2491
  });
2074
- var SessionExportResult = z10.object({ fileName: z10.string(), content: z10.string() });
2075
- var CommandViewAction = z10.object({
2076
- label: z10.string().min(1).max(80),
2077
- command: z10.string().startsWith("/").max(500),
2078
- tone: z10.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()
2079
2497
  });
2080
- var CommandView = z10.object({
2081
- title: z10.string().min(1).max(200),
2498
+ var CommandView = z13.object({
2499
+ title: z13.string().min(1).max(200),
2082
2500
  body: UINodeSchema,
2083
- actions: z10.array(CommandViewAction).max(30).default([])
2501
+ actions: z13.array(CommandViewAction).max(30).default([])
2084
2502
  });
2085
- var ModelStateResult = z10.object({
2503
+ var ModelStateResult = z13.object({
2086
2504
  model: SessionModel.nullable(),
2087
2505
  thinking: ThinkingLevel.nullable()
2088
2506
  });
2089
- var ImportSessionRequest = z10.object({
2090
- hostId: z10.string(),
2091
- sessionFile: z10.string(),
2092
- projectId: z10.string().nullable().optional()
2507
+ var ImportSessionRequest = z13.object({
2508
+ hostId: z13.string(),
2509
+ sessionFile: z13.string(),
2510
+ projectId: z13.string().nullable().optional()
2093
2511
  });
2094
- var AnswerRequest = z10.object({
2095
- revision: z10.number().int(),
2512
+ var AnswerRequest = z13.object({
2513
+ revision: z13.number().int(),
2096
2514
  response: InteractionResponseSchema
2097
2515
  });
2098
- var AdapterActionRequest = z10.object({
2099
- adapterId: z10.string(),
2100
- actionId: z10.string(),
2101
- payload: z10.unknown().optional()
2102
- });
2103
- var TaskPolicyPatch = z10.object({
2104
- hostId: z10.string().nullable().optional(),
2105
- profileId: z10.string().nullable().optional(),
2106
- workspace: z10.object({
2107
- mode: z10.enum(["new_worktree", "existing"]).optional(),
2108
- branch: z10.string().nullable().optional(),
2109
- base: z10.string().nullable().optional(),
2110
- workspaceId: z10.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()
2111
2530
  }).optional(),
2112
- continuation: z10.object({
2113
- enabled: z10.boolean().optional(),
2114
- objective: z10.string().min(1).optional(),
2115
- maxContinuations: z10.number().int().min(1).max(50).optional(),
2116
- maxElapsedMinutes: z10.number().int().min(1).max(1440).optional(),
2117
- maxTokens: z10.number().int().positive().nullable().optional(),
2118
- maxCostUsd: z10.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()
2119
2538
  }).optional(),
2120
2539
  completion: CompletionPolicy.partial().optional()
2121
2540
  });
2122
- var CreateTaskRequest = z10.object({
2123
- projectId: z10.string(),
2124
- title: z10.string().max(300).optional(),
2541
+ var CreateTaskRequest = z13.object({
2542
+ projectId: z13.string(),
2543
+ title: z13.string().max(300).optional(),
2125
2544
  githubIssueUrl: GitHubIssueUrl.optional(),
2126
- githubIssue: z10.never().optional(),
2127
- launchPrompt: z10.never().optional(),
2128
- objective: z10.string().default(""),
2129
- acceptanceCriteria: z10.array(z10.string()).default([]),
2130
- dependencies: z10.array(z10.string()).default([]),
2131
- parentTaskId: z10.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(),
2132
2551
  priority: Priority.default(2),
2133
- state: z10.enum(["backlog", "ready"]).default("backlog"),
2134
- notBefore: z10.string().nullable().optional(),
2552
+ state: z13.enum(["backlog", "ready"]).default("backlog"),
2553
+ notBefore: z13.string().nullable().optional(),
2135
2554
  policy: TaskPolicyPatch.optional()
2136
2555
  }).superRefine((v, ctx) => {
2137
2556
  if (v.githubIssueUrl === void 0) {
@@ -2169,32 +2588,32 @@ var CreateTaskRequest = z10.object({
2169
2588
  const issue = githubIssueFromUrl(v.githubIssueUrl);
2170
2589
  return { ...v, title: v.title?.trim() || `${issue.repository} #${issue.number}` };
2171
2590
  });
2172
- var UpdateTaskRequest = z10.object({
2173
- githubIssueUrl: z10.never().optional(),
2174
- githubIssue: z10.never().optional(),
2175
- launchPrompt: z10.never().optional(),
2176
- title: z10.string().min(1).max(300).optional(),
2177
- objective: z10.string().optional(),
2178
- acceptanceCriteria: z10.array(z10.string()).optional(),
2179
- dependencies: z10.array(z10.string()).optional(),
2180
- parentTaskId: z10.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(),
2181
2600
  priority: Priority.optional(),
2182
- position: z10.number().optional(),
2183
- notBefore: z10.string().nullable().optional(),
2601
+ position: z13.number().optional(),
2602
+ notBefore: z13.string().nullable().optional(),
2184
2603
  policy: TaskPolicyPatch.optional()
2185
2604
  });
2186
- var MoveTaskRequest = z10.object({
2605
+ var MoveTaskRequest = z13.object({
2187
2606
  to: TaskState,
2188
- confirm: z10.boolean().optional(),
2189
- onRunning: z10.enum(["pause", "stop"]).optional(),
2190
- position: z10.number().optional()
2191
- });
2192
- var RequestChangesRequest = z10.object({ feedback: z10.array(z10.string().min(1)).min(1) });
2193
- var Eligibility = z10.union([
2194
- z10.object({ eligible: z10.literal(true), hostId: z10.string(), hostName: z10.string() }),
2195
- z10.object({
2196
- eligible: z10.literal(false),
2197
- wait: z10.enum([
2607
+ confirm: z13.boolean().optional(),
2608
+ onRunning: z13.enum(["pause", "stop"]).optional(),
2609
+ position: z13.number().optional()
2610
+ });
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([
2198
2617
  "dependency",
2199
2618
  "host_offline",
2200
2619
  "project_limit",
@@ -2207,145 +2626,145 @@ var Eligibility = z10.union([
2207
2626
  "already_dispatched",
2208
2627
  "retry_backoff"
2209
2628
  ]),
2210
- message: z10.string()
2629
+ message: z13.string()
2211
2630
  })
2212
2631
  ]);
2213
- var NowResponse = z10.object({
2214
- running: z10.array(z10.object({ taskId: z10.string(), runId: z10.string(), sessionId: z10.string().nullable() })),
2215
- queued: z10.array(z10.object({ taskId: z10.string(), eligibility: Eligibility })),
2216
- dispatchPaused: z10.boolean()
2217
- });
2218
- var AutomationInput = z10.object({
2219
- name: z10.string().min(1),
2220
- enabled: z10.boolean().default(true),
2221
- projectId: z10.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(),
2222
2641
  trigger: Trigger,
2223
- filters: z10.array(z10.object({ path: z10.string(), equals: z10.string() })).default([]),
2642
+ filters: z13.array(z13.object({ path: z13.string(), equals: z13.string() })).default([]),
2224
2643
  template: TaskTemplate,
2225
- hostId: z10.string().nullable().default(null),
2226
- profileId: z10.string().nullable().default(null),
2227
- mode: z10.enum(["fresh", "continue", "watch"]).default("fresh"),
2228
- groupingKey: z10.string().nullable().default(null),
2229
- overlap: z10.enum(["skip", "queue_one", "append"]).default("skip"),
2230
- missed: z10.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"),
2231
2650
  continuation: ContinuationPolicy.default({ enabled: false }),
2232
2651
  completion: CompletionPolicy.default({ checks: null, requireHumanReview: true })
2233
2652
  });
2234
- var AutomationView = Automation.extend({ summary: z10.string() });
2235
- var AutomationPreview = z10.object({
2236
- summary: z10.string(),
2653
+ var AutomationView = Automation.extend({ summary: z13.string() });
2654
+ var AutomationPreview = z13.object({
2655
+ summary: z13.string(),
2237
2656
  task: TaskTemplate,
2238
- next: z10.array(z10.string())
2239
- });
2240
- var WebhookTokenResponse = z10.object({ token: z10.string(), url: z10.string() });
2241
- var PushSubscriptionRequest = z10.object({
2242
- endpoint: z10.string().url(),
2243
- keys: z10.object({ p256dh: z10.string(), auth: z10.string() }),
2244
- permission: z10.enum(["granted", "denied", "default", "unknown"]).default("granted")
2245
- });
2246
- var NotificationSettings = z10.object({
2247
- quietHours: z10.object({
2248
- start: z10.string().regex(/^\d{2}:\d{2}$/),
2249
- end: z10.string().regex(/^\d{2}:\d{2}$/),
2250
- timezone: z10.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()
2251
2670
  }).nullable(),
2252
- privatePreviews: z10.boolean(),
2253
- preferredDeviceId: z10.string().nullable()
2254
- });
2255
- var PushPayload = z10.union([
2256
- z10.object({
2257
- type: z10.literal("show"),
2258
- title: z10.string(),
2259
- body: z10.string(),
2260
- tag: z10.string(),
2261
- url: z10.string(),
2262
- renotify: z10.boolean()
2671
+ privatePreviews: z13.boolean(),
2672
+ preferredDeviceId: z13.string().nullable()
2673
+ });
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()
2263
2682
  }),
2264
- z10.object({ type: z10.literal("clear"), tag: z10.string() })
2683
+ z13.object({ type: z13.literal("clear"), tag: z13.string() })
2265
2684
  ]);
2266
- var SetupState = z10.object({
2267
- passkey: z10.object({
2268
- available: z10.boolean(),
2269
- registered: z10.boolean(),
2270
- reason: z10.string().nullable()
2685
+ var SetupState = z13.object({
2686
+ passkey: z13.object({
2687
+ available: z13.boolean(),
2688
+ registered: z13.boolean(),
2689
+ reason: z13.string().nullable()
2271
2690
  }),
2272
- oidc: z10.object({ label: z10.string() }).nullable()
2691
+ oidc: z13.object({ label: z13.string() }).nullable()
2273
2692
  });
2274
- var PasskeyRegisterOptionsResponse = z10.object({
2275
- challengeId: z10.string(),
2276
- options: z10.unknown()
2693
+ var PasskeyRegisterOptionsResponse = z13.object({
2694
+ challengeId: z13.string(),
2695
+ options: z13.unknown()
2277
2696
  });
2278
- var PasskeyRegisterVerifyRequest = z10.object({
2279
- challengeId: z10.string(),
2280
- name: z10.string().min(1).max(80),
2281
- response: z10.unknown()
2697
+ var PasskeyRegisterVerifyRequest = z13.object({
2698
+ challengeId: z13.string(),
2699
+ name: z13.string().min(1).max(80),
2700
+ response: z13.unknown()
2282
2701
  });
2283
- var PasskeySignInOptionsResponse = z10.object({
2284
- challengeId: z10.string(),
2285
- options: z10.unknown()
2702
+ var PasskeySignInOptionsResponse = z13.object({
2703
+ challengeId: z13.string(),
2704
+ options: z13.unknown()
2286
2705
  });
2287
- var PasskeySignInVerifyRequest = z10.object({
2288
- challengeId: z10.string(),
2289
- response: z10.unknown(),
2290
- deviceName: z10.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),
2291
2710
  kind: DeviceKind.extract(["browser", "pwa"])
2292
2711
  });
2293
- var OidcBeginRequest = z10.object({
2294
- deviceName: z10.string().min(1).max(80),
2712
+ var OidcBeginRequest = z13.object({
2713
+ deviceName: z13.string().min(1).max(80),
2295
2714
  kind: DeviceKind.extract(["browser", "pwa"]),
2296
- next: z10.string().default("/"),
2297
- handoff: z10.boolean().default(false)
2298
- });
2299
- var OidcBeginResponse = z10.object({
2300
- authorizeUrl: z10.string(),
2301
- flowId: z10.string().nullable(),
2302
- pollToken: z10.string().nullable()
2303
- });
2304
- var OidcClaimRequest = z10.object({ flowId: z10.string(), pollToken: z10.string() });
2305
- var OidcClaimResponse = z10.union([
2306
- z10.object({ status: z10.literal("pending") }),
2307
- z10.object({ status: z10.literal("done"), deviceId: z10.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() })
2308
2727
  ]);
2309
- var TerminalLoginStartRequest = z10.object({ name: z10.string().min(1).max(80) });
2310
- var TerminalLoginStartResponse = z10.object({
2311
- userCode: z10.string(),
2312
- pollToken: z10.string(),
2313
- verifyUrl: z10.string(),
2314
- expiresAt: z10.string(),
2315
- intervalMs: z10.number().int()
2316
- });
2317
- var TerminalLoginClaimRequest = z10.object({
2318
- userCode: z10.string().min(1),
2319
- pollToken: z10.string().min(1)
2320
- });
2321
- var TerminalLoginClaimResponse = z10.union([
2322
- z10.object({ status: z10.literal("pending") }),
2323
- z10.object({ status: z10.literal("denied") }),
2324
- z10.object({ status: z10.literal("done"), deviceId: z10.string(), credential: z10.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() })
2325
2744
  ]);
2326
- var TerminalLoginRequest = z10.object({
2327
- userCode: z10.string(),
2328
- name: z10.string(),
2329
- requestedFrom: z10.string(),
2330
- createdAt: z10.string(),
2331
- expiresAt: z10.string(),
2332
- status: z10.enum(["pending", "approved", "denied"])
2333
- });
2334
- var AuthMethods = z10.object({
2335
- passkeys: z10.array(Passkey),
2336
- passkeyAvailability: z10.object({ available: z10.boolean(), reason: z10.string().nullable() }),
2337
- oidc: z10.object({
2338
- issuer: z10.string(),
2339
- label: z10.string(),
2340
- ownerMatch: z10.string(),
2341
- status: z10.enum(["ready", "error"]),
2342
- error: z10.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()
2343
2762
  }).nullable()
2344
2763
  });
2345
- var MeResponse = z10.object({
2764
+ var MeResponse = z13.object({
2346
2765
  device: Device,
2347
- admin: z10.boolean(),
2348
- publicUrl: z10.string()
2766
+ admin: z13.boolean(),
2767
+ publicUrl: z13.string()
2349
2768
  });
2350
2769
  var ViewInput = View.pick({
2351
2770
  name: true,
@@ -2359,51 +2778,65 @@ var ViewInput = View.pick({
2359
2778
  });
2360
2779
  var ViewPatch = ViewInput.partial();
2361
2780
  var ViewClientReport = ViewClient.omit({ lastSeenAt: true });
2362
- var ProjectSuggestionsResponse = z10.object({
2363
- suggestions: z10.array(ProjectSuggestion.extend({ name: z10.string(), preselected: z10.boolean() }))
2781
+ var ProjectSuggestionsResponse = z13.object({
2782
+ suggestions: z13.array(ProjectSuggestion.extend({ name: z13.string(), preselected: z13.boolean() }))
2364
2783
  });
2365
2784
 
2366
2785
  // packages/protocol/dist/client-wire.js
2367
- import { z as z11 } from "zod";
2368
- var SyncState = z11.object({
2369
- hosts: z11.array(Host),
2370
- projects: z11.array(Project),
2371
- checkouts: z11.array(Checkout),
2372
- workspaces: z11.array(Workspace),
2373
- profiles: z11.array(Profile),
2374
- views: z11.array(View),
2375
- sessions: z11.array(Session),
2376
- tasks: z11.array(Task),
2377
- runs: z11.array(Run),
2378
- automations: z11.array(Automation),
2379
- attention: z11.array(AttentionItem),
2380
- interactions: z11.array(Interaction),
2381
- panels: z11.array(Panel),
2382
- devices: z11.array(Device),
2383
- adapters: z11.record(z11.string(), z11.array(AdapterInfo)),
2384
- dispatchPaused: z11.boolean()
2385
- });
2386
- var Presence = z11.object({
2387
- foreground: z11.boolean(),
2388
- interactedAt: z11.string().nullable(),
2389
- viewing: z11.object({ sessionId: z11.string() }).nullable()
2390
- });
2391
- var ClientToServer = z11.discriminatedUnion("type", [
2392
- z11.object({ type: z11.literal("hello"), cursor: z11.number().int().nullable() }),
2393
- z11.object({ type: z11.literal("presence"), presence: Presence }),
2394
- z11.object({ type: z11.literal("ping") })
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()
2809
+ });
2810
+ var CLIENT_CAPABILITIES = ["adapter.slots.v1", "timeline.cards.v1"];
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()
2817
+ }),
2818
+ z14.object({ type: z14.literal("presence"), presence: Presence }),
2819
+ z14.object({ type: z14.literal("ping") })
2395
2820
  ]);
2396
- var ServerToClient = z11.discriminatedUnion("type", [
2397
- z11.object({
2398
- type: z11.literal("replay"),
2399
- seq: z11.number().int(),
2400
- events: z11.array(EventEnvelope)
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()
2401
2828
  }),
2402
- z11.object({ type: z11.literal("snapshot"), seq: z11.number().int(), state: SyncState }),
2403
- z11.object({ type: z11.literal("event"), event: EventEnvelope }),
2404
- z11.object({ type: z11.literal("stream"), delta: StreamDelta }),
2405
- z11.object({ type: z11.literal("pong") }),
2406
- z11.object({ type: z11.literal("force_logout"), reason: z11.string() })
2829
+ z14.object({
2830
+ type: z14.literal("snapshot"),
2831
+ seq: z14.number().int(),
2832
+ state: SyncState,
2833
+ capabilities: z14.array(z14.enum(CLIENT_CAPABILITIES)).optional(),
2834
+ projectionId: z14.string().optional()
2835
+ }),
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() })
2407
2840
  ]);
2408
2841
 
2409
2842
  // packages/protocol/dist/ids.js
@@ -2414,17 +2847,17 @@ var ulid = monotonicFactory();
2414
2847
  var CLIENT_OPEN_MS = 10 * 6e4;
2415
2848
 
2416
2849
  // packages/protocol/dist/web-bridge.js
2417
- import { z as z12 } from "zod";
2850
+ import { z as z15 } from "zod";
2418
2851
  var FRAME_MAX_HEIGHT = 4e3;
2419
- var FrameToParentMessageSchema = z12.discriminatedUnion("type", [
2420
- z12.object({
2421
- type: z12.literal("action"),
2422
- actionId: z12.string().min(1).max(200),
2423
- payload: z12.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()
2424
2857
  }),
2425
- z12.object({
2426
- type: z12.literal("resize"),
2427
- height: z12.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)
2428
2861
  })
2429
2862
  ]);
2430
2863