@superxd-studio/adptr 0.5.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 (221) hide show
  1. package/GENERATIVE.md +101 -0
  2. package/INTERACTIONS.md +51 -0
  3. package/LICENSE +21 -0
  4. package/README.md +57 -0
  5. package/REUSE.md +170 -0
  6. package/REVIEW.md +68 -0
  7. package/THIRD-PARTY-NOTICES.md +28 -0
  8. package/ai-sdk/index.js +96 -0
  9. package/assets/ibm-plex-mono-cyrillic-400-normal.woff2 +0 -0
  10. package/assets/ibm-plex-mono-cyrillic-500-normal.woff2 +0 -0
  11. package/assets/ibm-plex-mono-cyrillic-ext-400-normal.woff2 +0 -0
  12. package/assets/ibm-plex-mono-cyrillic-ext-500-normal.woff2 +0 -0
  13. package/assets/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  14. package/assets/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  15. package/assets/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
  16. package/assets/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
  17. package/assets/ibm-plex-mono-vietnamese-400-normal.woff2 +0 -0
  18. package/assets/ibm-plex-mono-vietnamese-500-normal.woff2 +0 -0
  19. package/assets/instrument-sans-latin-ext-wght-normal.woff2 +0 -0
  20. package/assets/instrument-sans-latin-wght-normal.woff2 +0 -0
  21. package/assistant-ui/index.js +139 -0
  22. package/chunks/callout-DKMHSnjc.js +342 -0
  23. package/chunks/canvas-BJ15-XxE.js +598 -0
  24. package/chunks/controller-Cfpg0C7v.js +180 -0
  25. package/chunks/core-BCqVRLUy.js +312 -0
  26. package/chunks/text-field-BLtoaZFn.js +41 -0
  27. package/chunks/types-BGF7r1my.js +115 -0
  28. package/chunks/ui-9DyNsYXY.js +967 -0
  29. package/core/index.js +4 -0
  30. package/custom/index.js +64 -0
  31. package/examples/ai-sdk-backend/package.json +11 -0
  32. package/examples/ai-sdk-backend/server.mjs +316 -0
  33. package/examples/custom-backend/copy.mjs +7 -0
  34. package/examples/custom-backend/server.mjs +118 -0
  35. package/examples/generative/specs.json +2094 -0
  36. package/examples/review-backend/copy.mjs +27 -0
  37. package/examples/review-backend/package.json +11 -0
  38. package/examples/review-backend/server.mjs +276 -0
  39. package/examples/web-ai-sdk/index.html +12 -0
  40. package/examples/web-ai-sdk/package.json +21 -0
  41. package/examples/web-ai-sdk/src/copy.ts +1 -0
  42. package/examples/web-ai-sdk/src/main.tsx +64 -0
  43. package/examples/web-ai-sdk/tsconfig.json +13 -0
  44. package/examples/web-generative/index.html +12 -0
  45. package/examples/web-generative/package.json +23 -0
  46. package/examples/web-generative/src/copy.ts +42 -0
  47. package/examples/web-generative/src/main.tsx +74 -0
  48. package/examples/web-generative/tsconfig.json +14 -0
  49. package/examples/web-independent/index.html +12 -0
  50. package/examples/web-independent/package.json +20 -0
  51. package/examples/web-independent/src/main.tsx +32 -0
  52. package/examples/web-independent/tsconfig.json +14 -0
  53. package/examples/web-interactions/index.html +12 -0
  54. package/examples/web-interactions/package.json +21 -0
  55. package/examples/web-interactions/src/copy.ts +215 -0
  56. package/examples/web-interactions/src/examples.tsx +628 -0
  57. package/examples/web-interactions/src/main.tsx +116 -0
  58. package/examples/web-interactions/tsconfig.json +14 -0
  59. package/examples/web-review/index.html +12 -0
  60. package/examples/web-review/package.json +20 -0
  61. package/examples/web-review/src/main.tsx +59 -0
  62. package/examples/web-review/tsconfig.json +14 -0
  63. package/fonts.css +117 -0
  64. package/generative/index.js +1560 -0
  65. package/interactions/index.js +1591 -0
  66. package/langgraph-review/index.js +36 -0
  67. package/licenses/ai-sdk.txt +13 -0
  68. package/licenses/assistant-ui-generative.txt +21 -0
  69. package/licenses/assistant-ui.txt +23 -0
  70. package/licenses/ibm-plex-mono.txt +93 -0
  71. package/licenses/instrument-sans.txt +93 -0
  72. package/licenses/internationalized-date.txt +201 -0
  73. package/licenses/langgraph.txt +21 -0
  74. package/licenses/lucide.txt +43 -0
  75. package/licenses/react-markdown.txt +21 -0
  76. package/licenses/remark-gfm.txt +22 -0
  77. package/licenses/zod.txt +21 -0
  78. package/package.json +138 -0
  79. package/review/index.js +31 -0
  80. package/source/components/avatar.tsx +50 -0
  81. package/source/components/button.tsx +155 -0
  82. package/source/components/callout.tsx +65 -0
  83. package/source/components/canvas/connector.tsx +14 -0
  84. package/source/components/canvas/copy.ts +34 -0
  85. package/source/components/canvas/index.tsx +257 -0
  86. package/source/components/canvas/recorder.ts +36 -0
  87. package/source/components/date-time-field.tsx +77 -0
  88. package/source/components/flow-motion.tsx +109 -0
  89. package/source/components/icons.tsx +275 -0
  90. package/source/components/responsive-overlay.tsx +91 -0
  91. package/source/components/scenario-picker/copy.ts +5 -0
  92. package/source/components/scenario-picker/index.tsx +142 -0
  93. package/source/components/scroll-area.tsx +59 -0
  94. package/source/components/search-picker.tsx +127 -0
  95. package/source/components/segmented-control.tsx +123 -0
  96. package/source/components/skeleton.tsx +11 -0
  97. package/source/components/spinner.tsx +19 -0
  98. package/source/components/superxd-arrow.tsx +22 -0
  99. package/source/components/switch.tsx +45 -0
  100. package/source/components/text-field.tsx +81 -0
  101. package/source/components/thinking.tsx +16 -0
  102. package/source/components/ui/copy.ts +12 -0
  103. package/source/components/ui/display.tsx +276 -0
  104. package/source/components/ui/navigation.tsx +346 -0
  105. package/source/components/ui/portal-theme.tsx +28 -0
  106. package/source/components/ui/selection.tsx +336 -0
  107. package/source/lib/cn.ts +23 -0
  108. package/source/reusable/ai-sdk/index.ts +114 -0
  109. package/source/reusable/assistant-ui/index.tsx +266 -0
  110. package/source/reusable/core/attachments.ts +163 -0
  111. package/source/reusable/core/index.ts +417 -0
  112. package/source/reusable/custom/index.ts +90 -0
  113. package/source/reusable/generative/actions.ts +188 -0
  114. package/source/reusable/generative/copy.ts +47 -0
  115. package/source/reusable/generative/data.tsx +126 -0
  116. package/source/reusable/generative/index.tsx +517 -0
  117. package/source/reusable/generative/schema.ts +327 -0
  118. package/source/reusable/generative/timeline.tsx +214 -0
  119. package/source/reusable/generative/vocabulary.tsx +847 -0
  120. package/source/reusable/interactions/agent.ts +259 -0
  121. package/source/reusable/interactions/artifact.ts +236 -0
  122. package/source/reusable/interactions/context.tsx +38 -0
  123. package/source/reusable/interactions/copy.ts +117 -0
  124. package/source/reusable/interactions/feedback.ts +73 -0
  125. package/source/reusable/interactions/index.ts +11 -0
  126. package/source/reusable/interactions/presentation.tsx +483 -0
  127. package/source/reusable/interactions/store.ts +74 -0
  128. package/source/reusable/interactions/threads.ts +126 -0
  129. package/source/reusable/interactions/web.tsx +574 -0
  130. package/source/reusable/langgraph-review/index.ts +73 -0
  131. package/source/reusable/review/controller.ts +263 -0
  132. package/source/reusable/review/index.ts +47 -0
  133. package/source/reusable/review/types.ts +189 -0
  134. package/source/reusable/ui/index.ts +25 -0
  135. package/source/reusable/uploads/index.ts +48 -0
  136. package/source/reusable/web/attachments/copy.ts +23 -0
  137. package/source/reusable/web/attachments/index.tsx +233 -0
  138. package/source/reusable/web/copy.ts +22 -0
  139. package/source/reusable/web/index.tsx +470 -0
  140. package/source/reusable/web/message/copy.ts +26 -0
  141. package/source/reusable/web/message/index.tsx +388 -0
  142. package/source/reusable/web/message/streaming.ts +64 -0
  143. package/source/reusable/web/message/styles.css +21 -0
  144. package/source/reusable/web/review/copy.ts +78 -0
  145. package/source/reusable/web/review/flow.ts +24 -0
  146. package/source/reusable/web/review/index.tsx +506 -0
  147. package/source/reusable/web/styles.ts +2 -0
  148. package/source/styles/library.css +612 -0
  149. package/source/styles/theme.css +228 -0
  150. package/styles.css +3 -0
  151. package/styles.d.ts +1 -0
  152. package/types/components/avatar.d.ts +14 -0
  153. package/types/components/button.d.ts +36 -0
  154. package/types/components/callout.d.ts +19 -0
  155. package/types/components/canvas/connector.d.ts +2 -0
  156. package/types/components/canvas/copy.d.ts +34 -0
  157. package/types/components/canvas/index.d.ts +33 -0
  158. package/types/components/canvas/recorder.d.ts +10 -0
  159. package/types/components/date-time-field.d.ts +11 -0
  160. package/types/components/flow-motion.d.ts +38 -0
  161. package/types/components/icons.d.ts +138 -0
  162. package/types/components/responsive-overlay.d.ts +15 -0
  163. package/types/components/scenario-picker/copy.d.ts +5 -0
  164. package/types/components/scenario-picker/index.d.ts +14 -0
  165. package/types/components/scroll-area.d.ts +14 -0
  166. package/types/components/search-picker.d.ts +27 -0
  167. package/types/components/segmented-control.d.ts +23 -0
  168. package/types/components/skeleton.d.ts +4 -0
  169. package/types/components/spinner.d.ts +4 -0
  170. package/types/components/superxd-arrow.d.ts +5 -0
  171. package/types/components/switch.d.ts +8 -0
  172. package/types/components/text-field.d.ts +19 -0
  173. package/types/components/thinking.d.ts +8 -0
  174. package/types/components/ui/copy.d.ts +12 -0
  175. package/types/components/ui/display.d.ts +50 -0
  176. package/types/components/ui/navigation.d.ts +63 -0
  177. package/types/components/ui/portal-theme.d.ts +8 -0
  178. package/types/components/ui/selection.d.ts +37 -0
  179. package/types/lib/cn.d.ts +3 -0
  180. package/types/reusable/ai-sdk/index.d.ts +15 -0
  181. package/types/reusable/assistant-ui/index.d.ts +12 -0
  182. package/types/reusable/core/attachments.d.ts +54 -0
  183. package/types/reusable/core/index.d.ts +107 -0
  184. package/types/reusable/custom/index.d.ts +14 -0
  185. package/types/reusable/generative/actions.d.ts +45 -0
  186. package/types/reusable/generative/copy.d.ts +48 -0
  187. package/types/reusable/generative/data.d.ts +4 -0
  188. package/types/reusable/generative/index.d.ts +30 -0
  189. package/types/reusable/generative/schema.d.ts +303 -0
  190. package/types/reusable/generative/timeline.d.ts +21 -0
  191. package/types/reusable/generative/vocabulary.d.ts +34 -0
  192. package/types/reusable/interactions/agent.d.ts +98 -0
  193. package/types/reusable/interactions/artifact.d.ts +118 -0
  194. package/types/reusable/interactions/context.d.ts +130 -0
  195. package/types/reusable/interactions/copy.d.ts +115 -0
  196. package/types/reusable/interactions/feedback.d.ts +34 -0
  197. package/types/reusable/interactions/index.d.ts +10 -0
  198. package/types/reusable/interactions/presentation.d.ts +97 -0
  199. package/types/reusable/interactions/store.d.ts +29 -0
  200. package/types/reusable/interactions/threads.d.ts +38 -0
  201. package/types/reusable/interactions/web.d.ts +22 -0
  202. package/types/reusable/langgraph-review/index.d.ts +5 -0
  203. package/types/reusable/review/controller.d.ts +52 -0
  204. package/types/reusable/review/index.d.ts +12 -0
  205. package/types/reusable/review/types.d.ts +61 -0
  206. package/types/reusable/ui/index.d.ts +19 -0
  207. package/types/reusable/uploads/index.d.ts +11 -0
  208. package/types/reusable/web/attachments/copy.d.ts +25 -0
  209. package/types/reusable/web/attachments/index.d.ts +24 -0
  210. package/types/reusable/web/copy.d.ts +24 -0
  211. package/types/reusable/web/index.d.ts +41 -0
  212. package/types/reusable/web/message/copy.d.ts +27 -0
  213. package/types/reusable/web/message/index.d.ts +56 -0
  214. package/types/reusable/web/message/streaming.d.ts +27 -0
  215. package/types/reusable/web/review/copy.d.ts +72 -0
  216. package/types/reusable/web/review/flow.d.ts +3 -0
  217. package/types/reusable/web/review/index.d.ts +38 -0
  218. package/types/reusable/web/styles.d.ts +2 -0
  219. package/ui/index.js +4 -0
  220. package/uploads/index.js +34 -0
  221. package/web/index.js +931 -0
@@ -0,0 +1,1591 @@
1
+ "use client";
2
+ import { n as e, o as t, t as n } from "../chunks/callout-DKMHSnjc.js";
3
+ import { n as r, r as i, u as a } from "../chunks/canvas-BJ15-XxE.js";
4
+ import { t as o } from "../chunks/text-field-BLtoaZFn.js";
5
+ import { A as s, O as c, S as l, T as u, b as d, d as f, f as p, j as m } from "../chunks/ui-9DyNsYXY.js";
6
+ import { createContext as h, useContext as g, useLayoutEffect as _, useRef as v, useState as y, useSyncExternalStore as b } from "react";
7
+ import { Link as x } from "react-aria-components";
8
+ import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
9
+ import { z as T } from "zod";
10
+ //#region src/reusable/interactions/store.ts
11
+ function E(e, t = 0, n = { nodes: 0 }) {
12
+ return ++n.nodes > 1e4 || t > 20 ? !1 : e === null || typeof e == "string" || typeof e == "boolean" ? !0 : typeof e == "number" ? Number.isFinite(e) : Array.isArray(e) ? e.every((e) => E(e, t + 1, n)) : typeof e == "object" && Object.getPrototypeOf(e) === Object.prototype && Object.entries(e).every(([e, r]) => e.length <= 200 && E(r, t + 1, n));
13
+ }
14
+ var D = T.custom((e) => E(e) && JSON.stringify(e).length <= 1e5), O = T.string().min(1).max(200).refine((e) => e === e.trim(), "Identity must be canonical"), k = T.string().trim().min(1).max(2e3), A = T.string().max(1e5), j = () => crypto.randomUUID();
15
+ function M(e) {
16
+ return e && typeof e == "object" && !Object.isFrozen(e) && (Object.values(e).forEach(M), Object.freeze(e)), e;
17
+ }
18
+ var N = class {
19
+ state;
20
+ disposed = !1;
21
+ generation = 0;
22
+ abort;
23
+ usedIds = /* @__PURE__ */ new Set();
24
+ requestIdentity(e = j) {
25
+ let t = O.parse(e());
26
+ if (this.usedIds.has(t)) throw Error("Request identity must be unique");
27
+ return this.usedIds.add(t), t;
28
+ }
29
+ listeners = /* @__PURE__ */ new Set();
30
+ constructor(e) {
31
+ this.state = M(structuredClone(e));
32
+ }
33
+ getSnapshot = () => this.state;
34
+ subscribe = (e) => (this.listeners.add(e), () => this.listeners.delete(e));
35
+ publish(e) {
36
+ this.disposed || (this.state = M(structuredClone(e)), this.listeners.forEach((e) => e()));
37
+ }
38
+ request() {
39
+ return this.abort?.abort(), this.abort = new AbortController(), {
40
+ token: ++this.generation,
41
+ signal: this.abort.signal
42
+ };
43
+ }
44
+ current(e) {
45
+ return !this.disposed && e === this.generation;
46
+ }
47
+ dispose() {
48
+ this.disposed = !0, ++this.generation, this.abort?.abort(), this.listeners.clear();
49
+ }
50
+ }, P = T.strictObject({
51
+ id: O,
52
+ title: k,
53
+ tool: k,
54
+ input: D,
55
+ scope: k
56
+ }), F = T.discriminatedUnion("status", [
57
+ T.strictObject({
58
+ requestId: O,
59
+ status: T.literal("completed"),
60
+ output: A
61
+ }),
62
+ T.strictObject({
63
+ requestId: O,
64
+ status: T.literal("rejected"),
65
+ reason: k
66
+ }),
67
+ T.strictObject({
68
+ requestId: O,
69
+ status: T.literal("unknown")
70
+ })
71
+ ]), ee = T.union([F, T.strictObject({
72
+ requestId: O,
73
+ status: T.enum(["pending", "not-found"])
74
+ })]);
75
+ function I(e, t) {
76
+ switch (t.type) {
77
+ case "propose": return {
78
+ ...e,
79
+ phase: "approval",
80
+ request: t.request,
81
+ progress: void 0,
82
+ reason: void 0
83
+ };
84
+ case "approve": return {
85
+ ...e,
86
+ phase: "running",
87
+ progress: void 0
88
+ };
89
+ case "check": return {
90
+ ...e,
91
+ phase: "checking"
92
+ };
93
+ case "progress": return {
94
+ ...e,
95
+ progress: t.message
96
+ };
97
+ case "uncertain": return {
98
+ ...e,
99
+ phase: "uncertain",
100
+ progress: void 0
101
+ };
102
+ case "deny": return {
103
+ ...e,
104
+ phase: "denied",
105
+ progress: void 0
106
+ };
107
+ case "expire": return {
108
+ ...e,
109
+ phase: "expired"
110
+ };
111
+ case "revise": return {
112
+ ...e,
113
+ steps: t.steps
114
+ };
115
+ case "settle": {
116
+ if (t.result.status === "unknown") return {
117
+ ...e,
118
+ phase: "uncertain",
119
+ progress: void 0
120
+ };
121
+ if (t.result.status === "rejected") return {
122
+ ...e,
123
+ phase: "failed",
124
+ reason: t.result.reason,
125
+ progress: void 0
126
+ };
127
+ if (!e.request) return e;
128
+ let n = [...e.completed, {
129
+ stepId: e.request.step.id,
130
+ requestId: e.request.requestId,
131
+ output: t.result.output
132
+ }];
133
+ return {
134
+ ...e,
135
+ completed: n,
136
+ phase: n.length === e.steps.length ? "complete" : "ready",
137
+ request: void 0,
138
+ progress: void 0,
139
+ reason: void 0
140
+ };
141
+ }
142
+ }
143
+ }
144
+ var te = class extends N {
145
+ adapter;
146
+ options;
147
+ expiry;
148
+ ttl;
149
+ constructor(e, t, n = {}) {
150
+ let r = T.array(P).min(1).max(50).parse(t);
151
+ if (new Set(r.map((e) => e.id)).size !== r.length) throw Error("Duplicate plan step");
152
+ super({
153
+ steps: r,
154
+ completed: [],
155
+ phase: "ready"
156
+ }), this.adapter = e, this.options = n, this.ttl = T.number().finite().min(1e3).max(3e5).parse(n.approvalMs ?? 6e4);
157
+ }
158
+ now() {
159
+ return (this.options.now ?? Date.now)();
160
+ }
161
+ send(e) {
162
+ this.publish(I(this.state, e));
163
+ }
164
+ propose(e) {
165
+ clearTimeout(this.expiry), this.send({
166
+ type: "propose",
167
+ request: e
168
+ }), this.expiry = setTimeout(() => {
169
+ this.state.phase === "approval" && this.state.request?.requestId === e.requestId && this.send({ type: "expire" });
170
+ }, Math.max(0, e.approvedUntil - this.now()));
171
+ }
172
+ revise(e) {
173
+ if (this.disposed || this.state.phase !== "ready" || this.state.completed.length) return !1;
174
+ let t = T.array(P).min(1).max(50).safeParse(e);
175
+ return !t.success || new Set(t.data.map((e) => e.id)).size !== t.data.length ? !1 : (this.send({
176
+ type: "revise",
177
+ steps: t.data
178
+ }), !0);
179
+ }
180
+ next() {
181
+ if (this.disposed || this.state.phase !== "ready") return !1;
182
+ let e = this.state.steps.find((e) => !this.state.completed.some((t) => t.stepId === e.id));
183
+ return e ? (this.propose({
184
+ requestId: this.requestIdentity(this.options.id ?? j),
185
+ step: e,
186
+ approvedUntil: this.now() + this.ttl
187
+ }), !0) : !1;
188
+ }
189
+ approve() {
190
+ if (this.disposed || this.state.phase !== "approval" || !this.state.request) return !1;
191
+ if (this.now() >= this.state.request.approvedUntil) return this.send({ type: "expire" }), !1;
192
+ clearTimeout(this.expiry);
193
+ let e = this.state.request, { token: t, signal: n } = this.request();
194
+ return this.send({ type: "approve" }), (async () => {
195
+ try {
196
+ let r = await this.adapter.execute(e, n, (n) => {
197
+ if (this.current(t) && this.state.phase === "running" && this.state.request?.requestId === e.requestId) {
198
+ let e = k.safeParse(n);
199
+ e.success && this.send({
200
+ type: "progress",
201
+ message: e.data
202
+ });
203
+ }
204
+ }), i = F.parse(r);
205
+ if (i.requestId !== e.requestId) throw Error("Wrong receipt");
206
+ this.current(t) && this.send({
207
+ type: "settle",
208
+ result: i
209
+ });
210
+ } catch {
211
+ this.current(t) && this.send({ type: "uncertain" });
212
+ }
213
+ })(), !0;
214
+ }
215
+ deny() {
216
+ return this.disposed || this.state.phase !== "approval" ? !1 : (clearTimeout(this.expiry), this.send({ type: "deny" }), !0);
217
+ }
218
+ stop() {
219
+ return this.disposed || this.state.phase !== "running" ? !1 : (++this.generation, this.abort?.abort(), this.send({ type: "uncertain" }), !0);
220
+ }
221
+ renew() {
222
+ return this.disposed || !["failed", "expired"].includes(this.state.phase) || !this.state.request ? !1 : (this.propose({
223
+ ...this.state.request,
224
+ requestId: this.state.phase === "failed" ? this.requestIdentity(this.options.id ?? j) : this.state.request.requestId,
225
+ approvedUntil: this.now() + this.ttl
226
+ }), !0);
227
+ }
228
+ check() {
229
+ if (this.disposed || this.state.phase !== "uncertain" || !this.state.request) return !1;
230
+ let e = this.state.request, { token: t, signal: n } = this.request();
231
+ return this.send({ type: "check" }), (async () => {
232
+ try {
233
+ let r = ee.parse(await this.adapter.lookup(e.requestId, n));
234
+ if (r.requestId !== e.requestId) throw Error("Wrong receipt");
235
+ if (!this.current(t)) return;
236
+ r.status === "not-found" ? this.propose({
237
+ ...e,
238
+ approvedUntil: this.now() + this.ttl
239
+ }) : r.status === "pending" ? this.send({ type: "uncertain" }) : this.send({
240
+ type: "settle",
241
+ result: F.parse(r)
242
+ });
243
+ } catch {
244
+ this.current(t) && this.send({ type: "uncertain" });
245
+ }
246
+ })(), !0;
247
+ }
248
+ dispose() {
249
+ clearTimeout(this.expiry), super.dispose();
250
+ }
251
+ }, L = T.strictObject({
252
+ id: O,
253
+ title: k,
254
+ revision: O,
255
+ content: A,
256
+ canEdit: T.boolean(),
257
+ history: T.array(T.strictObject({
258
+ revision: O,
259
+ content: A
260
+ })).max(100)
261
+ }).refine((e) => new Set(e.history.map((e) => e.revision)).size === e.history.length, "Duplicate revision"), R = T.discriminatedUnion("status", [
262
+ T.strictObject({
263
+ requestId: O,
264
+ status: T.literal("saved"),
265
+ record: L
266
+ }),
267
+ T.strictObject({
268
+ requestId: O,
269
+ status: T.literal("conflict"),
270
+ record: L
271
+ }),
272
+ T.strictObject({
273
+ requestId: O,
274
+ status: T.literal("rejected"),
275
+ reason: k
276
+ }),
277
+ T.strictObject({
278
+ requestId: O,
279
+ status: T.literal("unknown")
280
+ })
281
+ ]), ne = T.union([R, T.strictObject({
282
+ requestId: O,
283
+ status: T.enum(["pending", "not-found"])
284
+ })]);
285
+ function z(e, t) {
286
+ switch (t.type) {
287
+ case "load": return {
288
+ ...e,
289
+ phase: "loading",
290
+ loadId: t.id,
291
+ reason: void 0
292
+ };
293
+ case "loaded": return {
294
+ phase: "viewing",
295
+ record: t.record,
296
+ draft: t.record.content
297
+ };
298
+ case "load-error": return {
299
+ ...e,
300
+ phase: "load-error"
301
+ };
302
+ case "edit": return {
303
+ ...e,
304
+ phase: "editing",
305
+ draft: t.content,
306
+ request: void 0,
307
+ reason: void 0
308
+ };
309
+ case "save": return {
310
+ ...e,
311
+ phase: "saving",
312
+ request: t.request,
313
+ reason: void 0
314
+ };
315
+ case "unknown": return {
316
+ ...e,
317
+ phase: "unknown"
318
+ };
319
+ case "check": return {
320
+ ...e,
321
+ phase: "checking"
322
+ };
323
+ case "not-found": return {
324
+ ...e,
325
+ phase: "editing"
326
+ };
327
+ case "adopt": return e.latest ? {
328
+ phase: t.keepDraft ? "editing" : "viewing",
329
+ record: e.latest,
330
+ draft: t.keepDraft ? e.draft : e.latest.content
331
+ } : e;
332
+ case "settle": return t.result.status === "saved" ? {
333
+ phase: "viewing",
334
+ record: t.result.record,
335
+ draft: t.result.record.content
336
+ } : t.result.status === "conflict" ? {
337
+ ...e,
338
+ phase: "conflict",
339
+ latest: t.result.record
340
+ } : t.result.status === "rejected" ? {
341
+ ...e,
342
+ phase: "editing",
343
+ reason: t.result.reason,
344
+ request: void 0
345
+ } : {
346
+ ...e,
347
+ phase: "unknown"
348
+ };
349
+ }
350
+ }
351
+ var B = class extends N {
352
+ adapter;
353
+ id;
354
+ constructor(e, t = j) {
355
+ super({
356
+ phase: "idle",
357
+ draft: ""
358
+ }), this.adapter = e, this.id = t;
359
+ }
360
+ send(e) {
361
+ this.publish(z(this.state, e));
362
+ }
363
+ open(e) {
364
+ if (this.disposed || [
365
+ "saving",
366
+ "unknown",
367
+ "checking",
368
+ "conflict"
369
+ ].includes(this.state.phase) || this.state.record && this.state.draft !== this.state.record.content) return !1;
370
+ let t = O.safeParse(e);
371
+ if (!t.success) return !1;
372
+ let { token: n, signal: r } = this.request();
373
+ return this.send({
374
+ type: "load",
375
+ id: t.data
376
+ }), (async () => {
377
+ try {
378
+ let e = L.parse(await this.adapter.load(t.data, r));
379
+ if (e.id !== t.data) throw Error("Wrong artifact");
380
+ this.current(n) && this.send({
381
+ type: "loaded",
382
+ record: e
383
+ });
384
+ } catch {
385
+ this.current(n) && this.send({ type: "load-error" });
386
+ }
387
+ })(), !0;
388
+ }
389
+ edit(e) {
390
+ return this.disposed || !this.state.record?.canEdit || !["viewing", "editing"].includes(this.state.phase) || !A.safeParse(e).success ? !1 : (this.send({
391
+ type: "edit",
392
+ content: e
393
+ }), !0);
394
+ }
395
+ discard() {
396
+ return this.disposed || !this.state.record || ![
397
+ "viewing",
398
+ "editing",
399
+ "load-error"
400
+ ].includes(this.state.phase) ? !1 : (this.send({
401
+ type: "loaded",
402
+ record: this.state.record
403
+ }), !0);
404
+ }
405
+ save() {
406
+ let e = this.state;
407
+ if (this.disposed || e.phase !== "editing" || !e.record?.canEdit || e.draft === e.record.content) return !1;
408
+ let t = e.request ?? Object.freeze({
409
+ requestId: this.requestIdentity(this.id),
410
+ artifactId: e.record.id,
411
+ baseRevision: e.record.revision,
412
+ content: e.draft
413
+ }), { token: n, signal: r } = this.request();
414
+ return this.send({
415
+ type: "save",
416
+ request: t
417
+ }), (async () => {
418
+ try {
419
+ let e = R.parse(await this.adapter.save(t, r));
420
+ this.validateResult(e, t), this.current(n) && this.send({
421
+ type: "settle",
422
+ result: e
423
+ });
424
+ } catch {
425
+ this.current(n) && this.send({ type: "unknown" });
426
+ }
427
+ })(), !0;
428
+ }
429
+ validateResult(e, t) {
430
+ if (e.requestId !== t.requestId || "record" in e && e.record.id !== t.artifactId || e.status === "saved" && e.record.revision === t.baseRevision) throw Error("Invalid artifact receipt");
431
+ }
432
+ adoptLatest(e) {
433
+ return this.disposed || this.state.phase !== "conflict" || !this.state.latest ? !1 : (this.send({
434
+ type: "adopt",
435
+ keepDraft: e
436
+ }), !0);
437
+ }
438
+ check() {
439
+ if (this.disposed || this.state.phase !== "unknown" || !this.state.request) return !1;
440
+ let e = this.state.request, { token: t, signal: n } = this.request();
441
+ return this.send({ type: "check" }), (async () => {
442
+ try {
443
+ let r = ne.parse(await this.adapter.lookup(e.requestId, n));
444
+ if (r.requestId !== e.requestId) throw Error("Wrong receipt");
445
+ if (!this.current(t)) return;
446
+ r.status === "not-found" ? this.send({ type: "not-found" }) : r.status === "pending" ? this.send({ type: "unknown" }) : (this.validateResult(R.parse(r), e), this.send({
447
+ type: "settle",
448
+ result: R.parse(r)
449
+ }));
450
+ } catch {
451
+ this.current(t) && this.send({ type: "unknown" });
452
+ }
453
+ })(), !0;
454
+ }
455
+ }, V = T.strictObject({
456
+ requestId: O,
457
+ responseId: O,
458
+ rating: T.enum(["helpful", "unhelpful"]),
459
+ comment: T.string().max(5e3)
460
+ }), H = class extends N {
461
+ adapter;
462
+ id;
463
+ constructor(e, t, n = j) {
464
+ super({
465
+ responseId: O.parse(t),
466
+ rating: null,
467
+ comment: "",
468
+ phase: "editing"
469
+ }), this.adapter = e, this.id = n;
470
+ }
471
+ edit(e, t = this.state.comment) {
472
+ return this.disposed || ["saving", "error"].includes(this.state.phase) || e !== null && e !== "helpful" && e !== "unhelpful" || typeof t != "string" || t.length > 5e3 ? !1 : (this.publish({
473
+ ...this.state,
474
+ rating: e,
475
+ comment: t,
476
+ phase: "editing",
477
+ request: void 0
478
+ }), !0);
479
+ }
480
+ save() {
481
+ if (this.disposed || !this.state.rating || !["editing", "error"].includes(this.state.phase)) return !1;
482
+ let e = this.state.request ?? Object.freeze(V.parse({
483
+ requestId: this.requestIdentity(this.id),
484
+ responseId: this.state.responseId,
485
+ rating: this.state.rating,
486
+ comment: this.state.comment
487
+ })), { token: t, signal: n } = this.request();
488
+ return this.publish({
489
+ ...this.state,
490
+ phase: "saving",
491
+ request: e
492
+ }), (async () => {
493
+ try {
494
+ let r = T.strictObject({
495
+ requestId: O,
496
+ responseId: O
497
+ }).parse(await this.adapter.save(e, n));
498
+ if (r.requestId !== e.requestId || r.responseId !== e.responseId) throw Error("Wrong feedback receipt");
499
+ this.current(t) && this.publish({
500
+ ...this.state,
501
+ phase: "saved"
502
+ });
503
+ } catch {
504
+ this.current(t) && this.publish({
505
+ ...this.state,
506
+ phase: "error"
507
+ });
508
+ }
509
+ })(), !0;
510
+ }
511
+ }, U = T.strictObject({
512
+ id: O,
513
+ title: k,
514
+ archived: T.boolean()
515
+ }), W = U.extend({ payload: D }), re = class extends N {
516
+ adapter;
517
+ canLeave;
518
+ constructor(e, t = () => !0) {
519
+ super({
520
+ phase: "idle",
521
+ items: []
522
+ }), this.adapter = e, this.canLeave = t;
523
+ }
524
+ refresh() {
525
+ if (this.disposed || [
526
+ "listing",
527
+ "mutating",
528
+ "opening"
529
+ ].includes(this.state.phase)) return !1;
530
+ let { token: e, signal: t } = this.request();
531
+ return this.publish({
532
+ ...this.state,
533
+ phase: "listing",
534
+ operation: "list"
535
+ }), (async () => {
536
+ try {
537
+ let n = T.array(U).max(1e3).parse(await this.adapter.list(t));
538
+ if (new Set(n.map((e) => e.id)).size !== n.length) throw Error("Duplicate thread");
539
+ this.current(e) && this.publish({
540
+ ...this.state,
541
+ items: n,
542
+ phase: "ready",
543
+ operation: void 0
544
+ });
545
+ } catch {
546
+ this.current(e) && this.publish({
547
+ ...this.state,
548
+ phase: "error"
549
+ });
550
+ }
551
+ })(), !0;
552
+ }
553
+ open(e) {
554
+ if (this.disposed || ["listing", "mutating"].includes(this.state.phase) || !this.state.items.some((t) => t.id === e) || !this.canLeave()) return !1;
555
+ let { token: t, signal: n } = this.request();
556
+ return this.publish({
557
+ ...this.state,
558
+ phase: "opening",
559
+ pendingId: e,
560
+ operation: "open"
561
+ }), (async () => {
562
+ try {
563
+ let r = W.parse(await this.adapter.load(e, n));
564
+ if (r.id !== e) throw Error("Wrong thread");
565
+ this.current(t) && this.publish({
566
+ ...this.state,
567
+ selected: r,
568
+ phase: "ready",
569
+ pendingId: void 0,
570
+ operation: void 0
571
+ });
572
+ } catch {
573
+ this.current(t) && this.publish({
574
+ ...this.state,
575
+ phase: "error",
576
+ pendingId: void 0
577
+ });
578
+ }
579
+ })(), !0;
580
+ }
581
+ rename(e, t) {
582
+ let n = k.safeParse(t);
583
+ return n.success ? this.mutate(e, "rename", (t) => this.adapter.rename(e, n.data, t)) : !1;
584
+ }
585
+ archive(e, t) {
586
+ return this.state.selected?.id === e && !this.canLeave() ? !1 : this.mutate(e, "archive", (n) => this.adapter.archive(e, t, n));
587
+ }
588
+ mutate(e, t, n) {
589
+ if (this.disposed || !["ready", "error"].includes(this.state.phase) || !this.state.items.some((t) => t.id === e)) return !1;
590
+ let { token: r, signal: i } = this.request();
591
+ return this.publish({
592
+ ...this.state,
593
+ phase: "mutating",
594
+ pendingId: e,
595
+ operation: t
596
+ }), (async () => {
597
+ try {
598
+ let t = U.parse(await n(i));
599
+ if (t.id !== e) throw Error("Wrong thread");
600
+ this.current(r) && this.publish({
601
+ ...this.state,
602
+ phase: "ready",
603
+ pendingId: void 0,
604
+ operation: void 0,
605
+ items: this.state.items.map((n) => n.id === e ? t : n),
606
+ selected: this.state.selected?.id === e ? {
607
+ ...this.state.selected,
608
+ ...t
609
+ } : this.state.selected
610
+ });
611
+ } catch {
612
+ this.current(r) && this.publish({
613
+ ...this.state,
614
+ phase: "error",
615
+ pendingId: void 0
616
+ });
617
+ }
618
+ })(), !0;
619
+ }
620
+ }, G = {
621
+ code: "Code",
622
+ files: "Files",
623
+ checks: "Checks",
624
+ passed: "Passed",
625
+ failed: "Failed",
626
+ artifactStates: {
627
+ idle: "Choose an artifact",
628
+ loading: "Loading artifact",
629
+ "load-error": "Artifact unavailable",
630
+ viewing: "Saved version",
631
+ editing: "Draft edited",
632
+ saving: "Saving revision",
633
+ conflict: "Saved version changed",
634
+ unknown: "Save result unknown",
635
+ checking: "Checking save"
636
+ },
637
+ invalid: "This content could not be displayed. Ask for an updated version.",
638
+ explanation: "Progress explanation",
639
+ supplied: "Reported by the host",
640
+ inputs: "Inputs",
641
+ output: "Result",
642
+ tool: "Tool details",
643
+ sources: "Sources",
644
+ source: (e, t) => `Source ${e}: ${t}`,
645
+ unavailable: "Source unavailable",
646
+ noSources: "No sources were supplied.",
647
+ retrieval: "Context used for this response",
648
+ included: "Included",
649
+ excluded: "Not included",
650
+ checkClaim: "Check this claim",
651
+ blocked: "This action cannot proceed",
652
+ model: "Model",
653
+ context: "Context to include",
654
+ commands: "Commands",
655
+ quote: "Quoted excerpt",
656
+ reply: "Use excerpt in reply",
657
+ connection: {
658
+ connected: "Connected",
659
+ reconnecting: "Reconnecting",
660
+ disconnected: "Disconnected"
661
+ },
662
+ disconnected: "The connection does not tell us whether remote work finished. Check the result before repeating an action.",
663
+ reconnect: "Reconnect",
664
+ trace: "Run measurements",
665
+ notReported: "Not reported",
666
+ agent: "Supervised plan",
667
+ plan: "Proposed steps",
668
+ request: "Review next step",
669
+ scope: "Approval scope",
670
+ allow: "Approve this step",
671
+ deny: "Decline",
672
+ stop: "Stop waiting",
673
+ check: "Check status",
674
+ renew: "Review again",
675
+ unknown: "The result is unknown. Check the original request before running it again.",
676
+ approvalHint: "Approval applies only to the displayed step and inputs. The host still checks your permissions.",
677
+ expires: "Approval expires if you wait too long. Review the step again to continue.",
678
+ denied: "The step was declined. Earlier completed work stays completed.",
679
+ complete: "All steps are complete.",
680
+ toolStates: {
681
+ pending: "Pending",
682
+ approval: "Awaiting approval",
683
+ running: "Running",
684
+ completed: "Complete",
685
+ rejected: "Not applied",
686
+ unknown: "Result unknown"
687
+ },
688
+ agentStates: {
689
+ ready: "Ready to review",
690
+ approval: "Awaiting approval",
691
+ running: "Working",
692
+ checking: "Checking result",
693
+ failed: "Step not applied",
694
+ uncertain: "Result unknown",
695
+ denied: "Declined",
696
+ expired: "Approval expired",
697
+ complete: "Complete"
698
+ },
699
+ artifact: "Artifact",
700
+ edit: "Edit draft",
701
+ save: "Save revision",
702
+ saving: "Saving revision",
703
+ discard: "Discard edits",
704
+ revision: "Revision",
705
+ artifactContent: "Artifact content",
706
+ latest: "Latest saved version",
707
+ localDraft: "Your draft",
708
+ conflict: "The saved version changed. Compare it with your draft before choosing what to keep.",
709
+ useLatest: "Use latest saved version",
710
+ keepDraft: "Keep my draft against the latest version",
711
+ loadError: "Couldn’t load this artifact. Try again; the current work is still here.",
712
+ retry: "Try again",
713
+ idleArtifact: "Choose an artifact to open.",
714
+ feedback: "Response feedback",
715
+ helpful: "Helpful",
716
+ unhelpful: "Needs work",
717
+ comment: "What should change?",
718
+ sendFeedback: "Save feedback",
719
+ savedFeedback: "Feedback saved for this response.",
720
+ failedFeedback: "Feedback is not confirmed. Retry with the same feedback.",
721
+ threads: "Conversation history",
722
+ refresh: "Refresh conversations",
723
+ active: "Active",
724
+ archived: "Archived",
725
+ archive: "Archive conversation",
726
+ restore: "Restore conversation",
727
+ rename: "Rename conversation",
728
+ title: "Conversation title",
729
+ saveTitle: "Save title",
730
+ chooseThread: "Choose a conversation to see its saved context.",
731
+ noThreads: "No conversations in this view.",
732
+ threadError: "Couldn’t complete that request. The current conversation is still here.",
733
+ loading: "Loading"
734
+ }, K = h(G);
735
+ function q({ copy: e = {}, children: t }) {
736
+ let n = g(K), r = {
737
+ ...n,
738
+ ...e,
739
+ toolStates: {
740
+ ...n.toolStates,
741
+ ...e.toolStates
742
+ },
743
+ agentStates: {
744
+ ...n.agentStates,
745
+ ...e.agentStates
746
+ },
747
+ artifactStates: {
748
+ ...n.artifactStates,
749
+ ...e.artifactStates
750
+ },
751
+ connection: {
752
+ ...n.connection,
753
+ ...e.connection
754
+ }
755
+ };
756
+ return /* @__PURE__ */ C(K.Provider, {
757
+ value: r,
758
+ children: t
759
+ });
760
+ }
761
+ var J = () => g(K);
762
+ //#endregion
763
+ //#region src/reusable/interactions/presentation.tsx
764
+ function Y(e) {
765
+ if (!(typeof e != "string" || e.length > 2e3)) try {
766
+ let t = new URL(e);
767
+ if (["https:", "http:"].includes(t.protocol) && !t.username && !t.password) return t.href;
768
+ } catch {}
769
+ }
770
+ var ie = T.strictObject({
771
+ id: O,
772
+ title: k,
773
+ url: T.string().max(2e3).optional(),
774
+ excerpt: A.optional(),
775
+ claim: k.optional()
776
+ });
777
+ function X({ sources: e, label: t }) {
778
+ let r = J();
779
+ t ??= r.sources;
780
+ let i = T.array(ie).max(100).safeParse(e);
781
+ return i.success ? /* @__PURE__ */ w("section", {
782
+ "aria-label": t,
783
+ className: "min-w-0",
784
+ children: [
785
+ /* @__PURE__ */ C("h3", {
786
+ className: "mb-3 type-heading text-fg-emphasis",
787
+ children: t
788
+ }),
789
+ !i.data.length && /* @__PURE__ */ C("p", {
790
+ className: "type-body text-fg-subtle",
791
+ children: r.noSources
792
+ }),
793
+ /* @__PURE__ */ C("ol", {
794
+ className: "flex flex-col gap-4",
795
+ children: i.data.map((e, t) => {
796
+ let n = Y(e.url);
797
+ return /* @__PURE__ */ w("li", {
798
+ className: "min-w-0 rounded-control border border-line-subtle bg-surface p-4",
799
+ children: [
800
+ /* @__PURE__ */ C("span", {
801
+ className: "mr-2 font-mono type-caption text-fg-subtle",
802
+ children: t + 1
803
+ }),
804
+ n ? /* @__PURE__ */ C(x, {
805
+ href: n,
806
+ target: "_blank",
807
+ rel: "noopener noreferrer",
808
+ "aria-label": r.source(t + 1, e.title),
809
+ className: "rounded-cell type-label break-words text-fg-emphasis underline outline-none data-focus-visible:focus-ring",
810
+ children: e.title
811
+ }) : /* @__PURE__ */ w("span", {
812
+ className: "type-label text-fg-emphasis",
813
+ children: [e.title, /* @__PURE__ */ C("span", {
814
+ className: "ml-2 type-caption text-fg-subtle",
815
+ children: r.unavailable
816
+ })]
817
+ }),
818
+ e.claim && /* @__PURE__ */ C("p", {
819
+ className: "mt-2 type-body text-fg",
820
+ children: e.claim
821
+ }),
822
+ e.excerpt && /* @__PURE__ */ C("blockquote", {
823
+ className: "mt-2 border-l-2 border-line-emphasis pl-3 type-body whitespace-pre-wrap text-fg-subtle",
824
+ children: e.excerpt
825
+ })
826
+ ]
827
+ }, `${e.id}-${t}`);
828
+ })
829
+ })
830
+ ]
831
+ }) : /* @__PURE__ */ C(n, {
832
+ tone: "error",
833
+ children: r.invalid
834
+ });
835
+ }
836
+ function ae({ source: e, index: t }) {
837
+ let n = J(), r = Y(e.url);
838
+ return r ? /* @__PURE__ */ w(x, {
839
+ href: r,
840
+ target: "_blank",
841
+ rel: "noopener noreferrer",
842
+ "aria-label": n.source(t, e.title),
843
+ className: "rounded-cell font-mono type-caption text-info underline outline-none data-focus-visible:focus-ring",
844
+ children: [
845
+ "[",
846
+ t,
847
+ "]"
848
+ ]
849
+ }) : /* @__PURE__ */ w("span", {
850
+ "aria-label": n.unavailable,
851
+ className: "font-mono type-caption text-fg-subtle",
852
+ children: [
853
+ "[",
854
+ t,
855
+ "]"
856
+ ]
857
+ });
858
+ }
859
+ function oe({ documents: e }) {
860
+ let t = J();
861
+ return /* @__PURE__ */ C(d, {
862
+ label: t.retrieval,
863
+ items: [{
864
+ id: "context",
865
+ title: t.retrieval,
866
+ content: /* @__PURE__ */ C("div", {
867
+ className: "flex flex-col gap-4",
868
+ children: e.map((e, n) => /* @__PURE__ */ w("div", { children: [/* @__PURE__ */ C(f, { children: e.included ? t.included : t.excluded }), /* @__PURE__ */ C(X, {
869
+ label: e.title,
870
+ sources: [{
871
+ id: e.id,
872
+ title: e.title,
873
+ url: e.url,
874
+ excerpt: e.excerpt,
875
+ claim: e.claim
876
+ }]
877
+ })] }, `${e.id}-${n}`))
878
+ })
879
+ }]
880
+ });
881
+ }
882
+ function se({ text: e, status: n = "complete", label: r }) {
883
+ let i = J();
884
+ return r ??= i.explanation, /* @__PURE__ */ w("div", {
885
+ className: "min-w-0",
886
+ children: [/* @__PURE__ */ w("div", {
887
+ className: "flex items-center gap-2 type-caption text-fg-subtle",
888
+ children: [n === "working" && /* @__PURE__ */ C(t, {}), i.supplied]
889
+ }), /* @__PURE__ */ C(d, {
890
+ label: r,
891
+ items: [{
892
+ id: "explanation",
893
+ title: r,
894
+ content: /* @__PURE__ */ C("p", {
895
+ className: "type-body break-words whitespace-pre-wrap",
896
+ children: e
897
+ })
898
+ }]
899
+ })]
900
+ });
901
+ }
902
+ function Z({ title: e, status: r, input: i, output: o }) {
903
+ let s = J(), c = D.safeParse(i);
904
+ return c.success ? /* @__PURE__ */ w(p, {
905
+ "aria-label": e,
906
+ children: [/* @__PURE__ */ w("div", {
907
+ className: "mb-3 flex flex-wrap items-center justify-between gap-3",
908
+ children: [/* @__PURE__ */ C("h3", {
909
+ className: "type-heading text-fg-emphasis",
910
+ children: e
911
+ }), /* @__PURE__ */ w(f, {
912
+ tone: r === "completed" ? "success" : r === "unknown" ? "attention" : "neutral",
913
+ children: [r === "running" && /* @__PURE__ */ C(t, {}), s.toolStates[r]]
914
+ })]
915
+ }), /* @__PURE__ */ C(d, {
916
+ label: s.tool,
917
+ items: [{
918
+ id: "input",
919
+ title: s.inputs,
920
+ content: /* @__PURE__ */ C(a, {
921
+ code: JSON.stringify(c.data, null, 2),
922
+ language: "json"
923
+ })
924
+ }, ...o === void 0 ? [] : [{
925
+ id: "output",
926
+ title: s.output,
927
+ content: /* @__PURE__ */ C("p", {
928
+ className: "type-body break-words whitespace-pre-wrap",
929
+ children: o
930
+ })
931
+ }]],
932
+ allowsMultipleExpanded: !0
933
+ })]
934
+ }) : /* @__PURE__ */ C(n, {
935
+ tone: "error",
936
+ children: s.invalid
937
+ });
938
+ }
939
+ function ce({ claim: e, explanation: t }) {
940
+ let r = J();
941
+ return /* @__PURE__ */ w(n, {
942
+ tone: "attention",
943
+ title: r.checkClaim,
944
+ children: [/* @__PURE__ */ C("p", { children: e }), /* @__PURE__ */ C("p", {
945
+ className: "mt-2",
946
+ children: t
947
+ })]
948
+ });
949
+ }
950
+ function le({ reason: t, alternatives: r, onChoose: i }) {
951
+ let a = J();
952
+ return /* @__PURE__ */ C(n, {
953
+ tone: "attention",
954
+ title: a.blocked,
955
+ actions: r.map((t) => /* @__PURE__ */ C(e, {
956
+ size: "sm",
957
+ onPress: () => i(t.id),
958
+ children: t.label
959
+ }, t.id)),
960
+ children: t
961
+ });
962
+ }
963
+ function ue({ state: t, onReconnect: r }) {
964
+ let i = J();
965
+ return /* @__PURE__ */ C(n, {
966
+ tone: t === "connected" ? "neutral" : "attention",
967
+ title: i.connection[t],
968
+ actions: t === "disconnected" && r ? /* @__PURE__ */ C(e, {
969
+ size: "sm",
970
+ onPress: r,
971
+ children: i.reconnect
972
+ }) : void 0,
973
+ children: t !== "connected" && i.disconnected
974
+ });
975
+ }
976
+ function de({ models: e, model: t, onModelChange: n, contexts: r = [], selectedContext: i = [], onContextChange: a, commands: o = [], onCommand: s }) {
977
+ let u = J();
978
+ return /* @__PURE__ */ w("div", {
979
+ className: "flex min-w-0 flex-col gap-4",
980
+ children: [
981
+ /* @__PURE__ */ C(m, {
982
+ label: u.model,
983
+ options: e,
984
+ selectedKey: t,
985
+ onSelectionChange: (e) => {
986
+ e !== null && n(String(e));
987
+ }
988
+ }),
989
+ r.length > 0 && a && /* @__PURE__ */ C(c, {
990
+ label: u.context,
991
+ options: r,
992
+ value: [...i],
993
+ onChange: a
994
+ }),
995
+ " ",
996
+ o.length > 0 && s && /* @__PURE__ */ C(l, {
997
+ label: u.commands,
998
+ items: o,
999
+ onAction: s
1000
+ })
1001
+ ]
1002
+ });
1003
+ }
1004
+ function fe({ quote: t, onReply: n }) {
1005
+ let r = J();
1006
+ return /* @__PURE__ */ w(p, {
1007
+ "aria-label": r.quote,
1008
+ children: [
1009
+ /* @__PURE__ */ C("blockquote", {
1010
+ className: "border-l-2 border-line-emphasis pl-3 type-body break-words whitespace-pre-wrap",
1011
+ children: t.text
1012
+ }),
1013
+ /* @__PURE__ */ C("p", {
1014
+ className: "mt-3 type-caption text-fg-subtle",
1015
+ children: t.sourceTitle
1016
+ }),
1017
+ n && /* @__PURE__ */ C(e, {
1018
+ size: "sm",
1019
+ className: "mt-4",
1020
+ onPress: () => n({ ...t }),
1021
+ children: r.reply
1022
+ })
1023
+ ]
1024
+ });
1025
+ }
1026
+ function pe({ code: e, files: t, output: n, tests: r }) {
1027
+ let i = J(), o = [
1028
+ ...e === void 0 ? [] : [{
1029
+ id: "code",
1030
+ label: i.code,
1031
+ content: /* @__PURE__ */ C(a, { code: e })
1032
+ }],
1033
+ ...t === void 0 ? [] : [{
1034
+ id: "files",
1035
+ label: i.files,
1036
+ content: /* @__PURE__ */ C("ul", {
1037
+ className: "flex flex-col gap-2 font-mono type-caption",
1038
+ children: t.map((e, t) => /* @__PURE__ */ C("li", {
1039
+ className: "break-words",
1040
+ children: e
1041
+ }, t))
1042
+ })
1043
+ }],
1044
+ ...n === void 0 ? [] : [{
1045
+ id: "output",
1046
+ label: i.output,
1047
+ content: /* @__PURE__ */ C("pre", {
1048
+ className: "type-caption break-words whitespace-pre-wrap",
1049
+ children: n
1050
+ })
1051
+ }],
1052
+ ...r === void 0 ? [] : [{
1053
+ id: "tests",
1054
+ label: i.checks,
1055
+ content: /* @__PURE__ */ C("ul", {
1056
+ className: "flex flex-col gap-3",
1057
+ children: r.map((e, t) => /* @__PURE__ */ w("li", {
1058
+ className: "flex flex-wrap gap-2",
1059
+ children: [/* @__PURE__ */ C(f, {
1060
+ tone: e.passed ? "success" : "error",
1061
+ children: e.passed ? i.passed : i.failed
1062
+ }), /* @__PURE__ */ C("span", {
1063
+ className: "type-body",
1064
+ children: e.name
1065
+ })]
1066
+ }, t))
1067
+ })
1068
+ }]
1069
+ ];
1070
+ return /* @__PURE__ */ C(u, {
1071
+ label: i.tool,
1072
+ items: o
1073
+ });
1074
+ }
1075
+ function me({ measurements: e }) {
1076
+ let t = J();
1077
+ return /* @__PURE__ */ w("section", {
1078
+ "aria-label": t.trace,
1079
+ children: [/* @__PURE__ */ C("h3", {
1080
+ className: "mb-3 type-heading text-fg-emphasis",
1081
+ children: t.trace
1082
+ }), /* @__PURE__ */ C("dl", {
1083
+ className: "grid grid-cols-[auto_minmax(0,1fr)] gap-x-4 gap-y-2 type-body",
1084
+ children: e.map((e, n) => /* @__PURE__ */ w("div", {
1085
+ className: "contents",
1086
+ children: [/* @__PURE__ */ C("dt", {
1087
+ className: "text-fg-subtle",
1088
+ children: e.label
1089
+ }), /* @__PURE__ */ C("dd", {
1090
+ className: "text-right break-words numeric",
1091
+ children: e.value === void 0 ? t.notReported : /* @__PURE__ */ w(S, { children: [e.value, e.unit && ` ${e.unit}`] })
1092
+ })]
1093
+ }, n))
1094
+ })]
1095
+ });
1096
+ }
1097
+ function Q({ label: e, status: t, children: n }) {
1098
+ return /* @__PURE__ */ w("div", {
1099
+ className: "flex min-w-0 flex-col gap-2",
1100
+ children: [/* @__PURE__ */ w("div", {
1101
+ className: "flex flex-wrap items-center justify-between gap-3",
1102
+ children: [/* @__PURE__ */ C("h3", {
1103
+ className: "type-heading text-fg-emphasis",
1104
+ children: e
1105
+ }), /* @__PURE__ */ C(f, { children: t })]
1106
+ }), n]
1107
+ });
1108
+ }
1109
+ //#endregion
1110
+ //#region src/reusable/interactions/web.tsx
1111
+ function $({ phase: e, label: t, children: n, terminal: r = !1 }) {
1112
+ let a = v(null), o = v(!1);
1113
+ return _(() => {
1114
+ o.current && document.activeElement === document.body && a.current?.focus({ preventScroll: !0 }), o.current = !1;
1115
+ }, [e]), /* @__PURE__ */ C(i, {
1116
+ phase: e,
1117
+ label: t,
1118
+ terminal: r,
1119
+ frameClassName: "max-w-2xl",
1120
+ children: /* @__PURE__ */ C("div", {
1121
+ ref: a,
1122
+ tabIndex: -1,
1123
+ role: "group",
1124
+ "aria-label": t,
1125
+ onPointerDownCapture: () => {
1126
+ o.current = !0;
1127
+ },
1128
+ onKeyDownCapture: () => {
1129
+ o.current = !0;
1130
+ },
1131
+ onClickCapture: () => {
1132
+ o.current = !0;
1133
+ },
1134
+ className: "mx-auto w-full max-w-2xl min-w-0 outline-none",
1135
+ children: n
1136
+ })
1137
+ });
1138
+ }
1139
+ function he({ controller: e, label: t }) {
1140
+ let n = J();
1141
+ return t ??= n.agent, /* @__PURE__ */ C(r, { children: /* @__PURE__ */ C(ge, {
1142
+ controller: e,
1143
+ label: t
1144
+ }) });
1145
+ }
1146
+ function ge({ controller: e, label: t }) {
1147
+ let n = J(), r = b(e.subscribe, e.getSnapshot, e.getSnapshot);
1148
+ return /* @__PURE__ */ C($, {
1149
+ phase: `agent-${r.completed.length}-${r.phase}`,
1150
+ label: n.agentStates[r.phase],
1151
+ terminal: r.phase === "complete" || r.phase === "denied",
1152
+ children: /* @__PURE__ */ C(_e, {
1153
+ state: r,
1154
+ label: t,
1155
+ controller: e
1156
+ })
1157
+ });
1158
+ }
1159
+ function _e({ state: r, label: i, controller: a }) {
1160
+ let o = J();
1161
+ return /* @__PURE__ */ w(p, {
1162
+ "aria-label": i,
1163
+ children: [
1164
+ /* @__PURE__ */ w("div", {
1165
+ className: "flex flex-wrap items-center justify-between gap-3",
1166
+ children: [/* @__PURE__ */ C("h2", {
1167
+ className: "type-heading text-fg-emphasis",
1168
+ children: i
1169
+ }), /* @__PURE__ */ C("span", {
1170
+ role: "status",
1171
+ className: "type-caption text-fg-subtle",
1172
+ children: o.agentStates[r.phase]
1173
+ })]
1174
+ }),
1175
+ /* @__PURE__ */ C("ol", {
1176
+ "aria-label": o.plan,
1177
+ className: "mt-4 flex flex-col gap-3",
1178
+ children: r.steps.map((e) => /* @__PURE__ */ w("li", {
1179
+ className: "flex flex-wrap items-center justify-between gap-3 type-body",
1180
+ children: [/* @__PURE__ */ C("span", { children: e.title }), /* @__PURE__ */ C(f, {
1181
+ tone: r.completed.some((t) => t.stepId === e.id) ? "success" : "neutral",
1182
+ children: r.completed.some((t) => t.stepId === e.id) ? o.toolStates.completed : o.toolStates.pending
1183
+ })]
1184
+ }, e.id))
1185
+ }),
1186
+ r.completed.map((e) => /* @__PURE__ */ C(Z, {
1187
+ title: r.steps.find((t) => t.id === e.stepId)?.title ?? o.tool,
1188
+ status: "completed",
1189
+ input: r.steps.find((t) => t.id === e.stepId)?.input ?? null,
1190
+ output: e.output
1191
+ }, e.requestId)),
1192
+ r.request && /* @__PURE__ */ w("div", {
1193
+ className: "mt-6 flex flex-col gap-4",
1194
+ children: [
1195
+ /* @__PURE__ */ C(Z, {
1196
+ title: r.request.step.title,
1197
+ status: r.phase === "approval" ? "approval" : r.phase === "running" ? "running" : r.phase === "failed" ? "rejected" : "unknown",
1198
+ input: r.request.step.input
1199
+ }),
1200
+ /* @__PURE__ */ w("p", {
1201
+ className: "type-body",
1202
+ children: [/* @__PURE__ */ w("span", {
1203
+ className: "type-label",
1204
+ children: [o.scope, ": "]
1205
+ }), r.request.step.scope]
1206
+ }),
1207
+ r.phase === "approval" && /* @__PURE__ */ C("p", {
1208
+ className: "type-caption text-fg-subtle",
1209
+ children: o.approvalHint
1210
+ })
1211
+ ]
1212
+ }),
1213
+ r.progress && /* @__PURE__ */ C("p", {
1214
+ role: "status",
1215
+ className: "mt-4 type-body",
1216
+ children: r.progress
1217
+ }),
1218
+ r.phase === "uncertain" && /* @__PURE__ */ C(n, {
1219
+ tone: "attention",
1220
+ className: "mt-4",
1221
+ children: o.unknown
1222
+ }),
1223
+ r.reason && /* @__PURE__ */ C(n, {
1224
+ tone: "error",
1225
+ className: "mt-4",
1226
+ children: r.reason
1227
+ }),
1228
+ r.phase === "expired" && /* @__PURE__ */ C(n, {
1229
+ tone: "attention",
1230
+ className: "mt-4",
1231
+ children: o.expires
1232
+ }),
1233
+ r.phase === "denied" && /* @__PURE__ */ C("p", {
1234
+ className: "mt-4 type-body",
1235
+ children: o.denied
1236
+ }),
1237
+ r.phase === "complete" && /* @__PURE__ */ C("p", {
1238
+ className: "mt-4 type-body",
1239
+ children: o.complete
1240
+ }),
1241
+ /* @__PURE__ */ w("div", {
1242
+ className: "mt-6 flex flex-wrap gap-3",
1243
+ children: [
1244
+ r.phase === "ready" && /* @__PURE__ */ C(e, {
1245
+ onPress: () => a.next(),
1246
+ children: o.request
1247
+ }),
1248
+ r.phase === "approval" && /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(e, {
1249
+ variant: "primary",
1250
+ onPress: () => a.approve(),
1251
+ children: o.allow
1252
+ }), /* @__PURE__ */ C(e, {
1253
+ onPress: () => a.deny(),
1254
+ children: o.deny
1255
+ })] }),
1256
+ r.phase === "running" && /* @__PURE__ */ C(e, {
1257
+ onPress: () => a.stop(),
1258
+ children: o.stop
1259
+ }),
1260
+ r.phase === "uncertain" && /* @__PURE__ */ C(e, {
1261
+ onPress: () => a.check(),
1262
+ children: o.check
1263
+ }),
1264
+ (r.phase === "failed" || r.phase === "expired") && /* @__PURE__ */ C(e, {
1265
+ onPress: () => a.renew(),
1266
+ children: o.renew
1267
+ }),
1268
+ r.phase === "checking" && /* @__PURE__ */ C(t, {})
1269
+ ]
1270
+ })
1271
+ ]
1272
+ });
1273
+ }
1274
+ function ve({ controller: e, label: t }) {
1275
+ let n = J();
1276
+ return t ??= n.artifact, /* @__PURE__ */ C(r, { children: /* @__PURE__ */ C(ye, {
1277
+ controller: e,
1278
+ label: t
1279
+ }) });
1280
+ }
1281
+ function ye({ controller: e, label: t }) {
1282
+ let n = J(), r = b(e.subscribe, e.getSnapshot, e.getSnapshot);
1283
+ return /* @__PURE__ */ C($, {
1284
+ phase: `artifact-${r.record?.revision ?? "idle"}-${r.phase}`,
1285
+ label: n.artifactStates[r.phase],
1286
+ children: /* @__PURE__ */ C(be, {
1287
+ state: r,
1288
+ label: t,
1289
+ controller: e
1290
+ })
1291
+ });
1292
+ }
1293
+ function be({ state: r, label: i, controller: a }) {
1294
+ let s = J(), [c, l] = y(), d = r.record, h = d?.history.find((e) => e.revision === c);
1295
+ return /* @__PURE__ */ w(p, {
1296
+ "aria-label": i,
1297
+ children: [
1298
+ /* @__PURE__ */ w("div", {
1299
+ className: "flex flex-wrap items-center justify-between gap-3",
1300
+ children: [/* @__PURE__ */ C("h2", {
1301
+ className: "type-heading text-fg-emphasis",
1302
+ children: d?.title ?? i
1303
+ }), /* @__PURE__ */ C("span", {
1304
+ role: "status",
1305
+ className: "type-caption text-fg-subtle",
1306
+ children: s.artifactStates[r.phase]
1307
+ })]
1308
+ }),
1309
+ (r.phase === "loading" || r.phase === "checking") && /* @__PURE__ */ C(t, {}),
1310
+ r.phase === "idle" && /* @__PURE__ */ C("p", {
1311
+ className: "mt-4 type-body",
1312
+ children: s.idleArtifact
1313
+ }),
1314
+ r.phase === "load-error" && /* @__PURE__ */ C(n, {
1315
+ tone: "error",
1316
+ className: "mt-4",
1317
+ actions: /* @__PURE__ */ C(e, {
1318
+ size: "sm",
1319
+ onPress: () => r.loadId && a.open(r.loadId),
1320
+ children: s.retry
1321
+ }),
1322
+ children: s.loadError
1323
+ }),
1324
+ d && /* @__PURE__ */ w("div", {
1325
+ className: "mt-4 flex flex-col gap-4",
1326
+ children: [
1327
+ /* @__PURE__ */ w(f, { children: [
1328
+ s.revision,
1329
+ ": ",
1330
+ d.revision
1331
+ ] }),
1332
+ r.phase === "viewing" && d.history.length > 0 && /* @__PURE__ */ C(m, {
1333
+ label: s.revision,
1334
+ options: [{
1335
+ id: d.revision,
1336
+ label: d.revision
1337
+ }, ...d.history.filter((e) => e.revision !== d.revision).map((e) => ({
1338
+ id: e.revision,
1339
+ label: e.revision
1340
+ }))],
1341
+ selectedKey: h?.revision ?? d.revision,
1342
+ onSelectionChange: (e) => l(e === null ? void 0 : String(e))
1343
+ }),
1344
+ r.phase === "conflict" && r.latest ? /* @__PURE__ */ w(S, { children: [
1345
+ /* @__PURE__ */ C(n, {
1346
+ tone: "attention",
1347
+ children: s.conflict
1348
+ }),
1349
+ /* @__PURE__ */ C(u, {
1350
+ label: s.revision,
1351
+ items: [{
1352
+ id: "draft",
1353
+ label: s.localDraft,
1354
+ content: /* @__PURE__ */ C("pre", {
1355
+ className: "type-body break-words whitespace-pre-wrap",
1356
+ children: r.draft
1357
+ })
1358
+ }, {
1359
+ id: "latest",
1360
+ label: s.latest,
1361
+ content: /* @__PURE__ */ C("pre", {
1362
+ className: "type-body break-words whitespace-pre-wrap",
1363
+ children: r.latest.content
1364
+ })
1365
+ }]
1366
+ }),
1367
+ /* @__PURE__ */ w("div", {
1368
+ className: "flex flex-wrap gap-3",
1369
+ children: [/* @__PURE__ */ C(e, {
1370
+ onPress: () => a.adoptLatest(!1),
1371
+ children: s.useLatest
1372
+ }), /* @__PURE__ */ C(e, {
1373
+ onPress: () => a.adoptLatest(!0),
1374
+ children: s.keepDraft
1375
+ })]
1376
+ })
1377
+ ] }) : r.phase === "viewing" ? /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C("pre", {
1378
+ className: "type-body break-words whitespace-pre-wrap",
1379
+ children: h?.content ?? d.content
1380
+ }), d.canEdit && !h && /* @__PURE__ */ C(e, {
1381
+ onPress: () => a.edit(d.content),
1382
+ children: s.edit
1383
+ })] }) : /* @__PURE__ */ C(o, {
1384
+ label: s.artifactContent,
1385
+ multiline: !0,
1386
+ value: r.draft,
1387
+ onChange: (e) => a.edit(e),
1388
+ isDisabled: r.phase !== "editing"
1389
+ }),
1390
+ r.reason && /* @__PURE__ */ C(n, {
1391
+ tone: "error",
1392
+ children: r.reason
1393
+ }),
1394
+ r.phase === "editing" && /* @__PURE__ */ w("div", {
1395
+ className: "flex flex-wrap gap-3",
1396
+ children: [/* @__PURE__ */ C(e, {
1397
+ variant: "primary",
1398
+ isDisabled: r.draft === d.content,
1399
+ onPress: () => a.save(),
1400
+ children: s.save
1401
+ }), /* @__PURE__ */ C(e, {
1402
+ onPress: () => a.discard(),
1403
+ children: s.discard
1404
+ })]
1405
+ }),
1406
+ r.phase === "unknown" && /* @__PURE__ */ C(n, {
1407
+ tone: "attention",
1408
+ actions: /* @__PURE__ */ C(e, {
1409
+ onPress: () => a.check(),
1410
+ children: s.check
1411
+ }),
1412
+ children: s.unknown
1413
+ })
1414
+ ]
1415
+ })
1416
+ ]
1417
+ });
1418
+ }
1419
+ function xe({ controller: e, label: t }) {
1420
+ let n = J();
1421
+ t ??= n.feedback;
1422
+ let r = b(e.subscribe, e.getSnapshot, e.getSnapshot);
1423
+ return /* @__PURE__ */ C(Se, {
1424
+ state: r,
1425
+ label: t,
1426
+ controller: e
1427
+ });
1428
+ }
1429
+ function Se({ state: t, label: n, controller: r }) {
1430
+ let i = J(), a = t.phase === "saving" || t.phase === "error";
1431
+ return /* @__PURE__ */ w(p, {
1432
+ "aria-label": n,
1433
+ children: [
1434
+ /* @__PURE__ */ C(s, {
1435
+ label: n,
1436
+ options: [{
1437
+ id: "helpful",
1438
+ label: i.helpful
1439
+ }, {
1440
+ id: "unhelpful",
1441
+ label: i.unhelpful
1442
+ }],
1443
+ value: t.rating ?? "",
1444
+ onChange: (e) => r.edit(e),
1445
+ isDisabled: a
1446
+ }),
1447
+ /* @__PURE__ */ C(o, {
1448
+ className: "mt-4",
1449
+ label: i.comment,
1450
+ multiline: !0,
1451
+ value: t.comment,
1452
+ onChange: (e) => r.edit(t.rating, e),
1453
+ isDisabled: a
1454
+ }),
1455
+ /* @__PURE__ */ C("div", {
1456
+ className: "mt-4",
1457
+ children: /* @__PURE__ */ C(e, {
1458
+ isDisabled: !t.rating || t.phase === "saving" || t.phase === "saved",
1459
+ onPress: () => r.save(),
1460
+ children: t.phase === "error" ? i.retry : i.sendFeedback
1461
+ })
1462
+ }),
1463
+ /* @__PURE__ */ C("p", {
1464
+ role: "status",
1465
+ className: "mt-3 type-body text-fg-subtle",
1466
+ children: t.phase === "saved" ? i.savedFeedback : t.phase === "error" ? i.failedFeedback : t.phase === "saving" ? i.saving : ""
1467
+ })
1468
+ ]
1469
+ });
1470
+ }
1471
+ function Ce({ controller: e, renderThread: t, label: n }) {
1472
+ let r = J();
1473
+ n ??= r.threads;
1474
+ let i = b(e.subscribe, e.getSnapshot, e.getSnapshot);
1475
+ return /* @__PURE__ */ C(we, {
1476
+ state: i,
1477
+ controller: e,
1478
+ renderThread: t,
1479
+ label: n
1480
+ });
1481
+ }
1482
+ function we({ state: t, controller: r, renderThread: i, label: a }) {
1483
+ let s = J(), [c, l] = y("active"), [u, d] = y(), [f, h] = y(""), g = v(null), _ = !["ready", "error"].includes(t.phase), b = t.items.filter((e) => e.archived === (c === "archived"));
1484
+ return /* @__PURE__ */ C("div", {
1485
+ ref: g,
1486
+ role: "group",
1487
+ "aria-label": a,
1488
+ tabIndex: -1,
1489
+ className: "min-w-0 outline-none",
1490
+ children: /* @__PURE__ */ w(p, {
1491
+ "aria-label": a,
1492
+ children: [
1493
+ /* @__PURE__ */ w("div", {
1494
+ className: "flex flex-wrap items-center justify-between gap-3",
1495
+ children: [/* @__PURE__ */ C("h2", {
1496
+ className: "type-heading text-fg-emphasis",
1497
+ children: a
1498
+ }), /* @__PURE__ */ C(e, {
1499
+ size: "sm",
1500
+ isDisabled: _ && t.phase !== "idle",
1501
+ onPress: () => r.refresh(),
1502
+ children: s.refresh
1503
+ })]
1504
+ }),
1505
+ /* @__PURE__ */ C(m, {
1506
+ className: "mt-4",
1507
+ label: a,
1508
+ selectedKey: c,
1509
+ onSelectionChange: (e) => l(String(e)),
1510
+ options: [{
1511
+ id: "active",
1512
+ label: s.active
1513
+ }, {
1514
+ id: "archived",
1515
+ label: s.archived
1516
+ }]
1517
+ }),
1518
+ t.phase === "error" && /* @__PURE__ */ C(n, {
1519
+ tone: "error",
1520
+ className: "mt-4",
1521
+ children: s.threadError
1522
+ }),
1523
+ /* @__PURE__ */ C("ul", {
1524
+ className: "mt-4 flex flex-col gap-4",
1525
+ children: b.map((n) => /* @__PURE__ */ w("li", {
1526
+ className: "flex flex-col gap-3 rounded-control border border-line-subtle p-3",
1527
+ children: [
1528
+ /* @__PURE__ */ C(e, {
1529
+ className: "justify-start text-left whitespace-normal",
1530
+ isDisabled: ["listing", "mutating"].includes(t.phase),
1531
+ onPress: () => {
1532
+ r.open(n.id) && d(void 0);
1533
+ },
1534
+ children: n.title
1535
+ }),
1536
+ /* @__PURE__ */ w("div", {
1537
+ className: "flex flex-wrap gap-3",
1538
+ children: [/* @__PURE__ */ C(e, {
1539
+ size: "sm",
1540
+ isDisabled: _,
1541
+ onPress: () => {
1542
+ d(n.id), h(n.title);
1543
+ },
1544
+ children: s.rename
1545
+ }), /* @__PURE__ */ C(e, {
1546
+ size: "sm",
1547
+ isDisabled: _,
1548
+ onPress: () => {
1549
+ r.archive(n.id, !n.archived) && g.current?.focus({ preventScroll: !0 });
1550
+ },
1551
+ children: n.archived ? s.restore : s.archive
1552
+ })]
1553
+ }),
1554
+ u === n.id && /* @__PURE__ */ w("div", {
1555
+ className: "flex flex-col gap-3",
1556
+ children: [/* @__PURE__ */ C(o, {
1557
+ label: s.title,
1558
+ value: f,
1559
+ onChange: h,
1560
+ isDisabled: _
1561
+ }), /* @__PURE__ */ C(e, {
1562
+ isDisabled: _ || !f.trim(),
1563
+ onPress: () => r.rename(n.id, f),
1564
+ children: s.saveTitle
1565
+ })]
1566
+ })
1567
+ ]
1568
+ }, n.id))
1569
+ }),
1570
+ !b.length && t.phase !== "idle" && /* @__PURE__ */ C("p", {
1571
+ className: "mt-4 type-body text-fg-subtle",
1572
+ children: s.noThreads
1573
+ }),
1574
+ /* @__PURE__ */ C("div", {
1575
+ role: "status",
1576
+ className: "mt-4 type-caption text-fg-subtle",
1577
+ children: _ && t.phase !== "idle" ? s.loading : ""
1578
+ }),
1579
+ /* @__PURE__ */ C("div", {
1580
+ className: "mt-6 min-w-0",
1581
+ children: t.selected ? i(t.selected) : /* @__PURE__ */ C("p", {
1582
+ className: "type-body text-fg-subtle",
1583
+ children: s.chooseThread
1584
+ })
1585
+ })
1586
+ ]
1587
+ })
1588
+ });
1589
+ }
1590
+ //#endregion
1591
+ export { te as AgentController, Q as AgentStatus, he as AgentSupervision, B as ArtifactController, ve as ArtifactWorkspace, ae as Citation, de as ComposerTools, ce as Confidence, ue as ConnectionStatus, Ce as ConversationHistory, pe as ExecutionInspector, H as FeedbackController, le as Guardrail, q as InteractionProvider, me as Observability, fe as QuotedExcerpt, se as Reasoning, xe as ResponseFeedback, oe as RetrievalInspection, X as Sources, re as ThreadController, Z as ToolCall, I as agentReducer, P as agentStepSchema, z as artifactReducer, L as artifactSchema, Y as evidenceUrl, G as interactionCopy, D as jsonSchema, W as threadDocumentSchema, U as threadSummarySchema };