@tangle-network/agent-app 0.45.23 → 0.45.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DesignCanvas-ZG7DJS7C.js → DesignCanvas-3RRPVPCP.js} +2 -2
- package/dist/{DesignCanvasEditor-SLFMHOII.js → DesignCanvasEditor-KAMMEX7E.js} +4 -4
- package/dist/{TimelineEditor-6PV42FLG.js → TimelineEditor-IIBVCAZV.js} +2 -2
- package/dist/VaultPane-MUWGYVJ7.js +7 -0
- package/dist/assistant/index.d.ts +11 -0
- package/dist/assistant/index.js +89 -56
- package/dist/assistant/index.js.map +1 -1
- package/dist/chat-react/index.js +4 -1
- package/dist/chat-react/index.js.map +1 -1
- package/dist/{chunk-MLACJ6DB.js → chunk-7O4FZAFP.js} +10 -10
- package/dist/chunk-7O4FZAFP.js.map +1 -0
- package/dist/{chunk-OASVAPRL.js → chunk-AWPK7ZDS.js} +3 -3
- package/dist/{chunk-YTMKRL3L.js → chunk-HZ4WCA37.js} +3 -2
- package/dist/chunk-HZ4WCA37.js.map +1 -0
- package/dist/{chunk-FVJP2RTC.js → chunk-JJJEO4ND.js} +91 -36
- package/dist/chunk-JJJEO4ND.js.map +1 -0
- package/dist/{chunk-7PFFFRVU.js → chunk-KOMP6NDW.js} +172 -43
- package/dist/chunk-KOMP6NDW.js.map +1 -0
- package/dist/{chunk-TZO3SOUL.js → chunk-LSQR6HM6.js} +49 -33
- package/dist/chunk-LSQR6HM6.js.map +1 -0
- package/dist/{chunk-3IHYJIDJ.js → chunk-NC2V63EL.js} +15 -15
- package/dist/chunk-NC2V63EL.js.map +1 -0
- package/dist/{chunk-73CQJOIU.js → chunk-OYGM5WLD.js} +5 -5
- package/dist/chunk-OYGM5WLD.js.map +1 -0
- package/dist/chunk-YIQHOAHN.js +340 -0
- package/dist/chunk-YIQHOAHN.js.map +1 -0
- package/dist/design-canvas-react/index.d.ts +2 -2
- package/dist/design-canvas-react/index.js +9 -9
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/sequences-react/index.js +2 -2
- package/dist/theme/index.d.ts +27 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/tailwind-preset.d.ts +25 -0
- package/dist/theme/tailwind-preset.js +55 -1
- package/dist/theme/tailwind-preset.js.map +1 -1
- package/dist/theme/tokens.css +298 -40
- package/dist/vault/index.js +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/web-react/async/index.js +19 -307
- package/dist/web-react/async/index.js.map +1 -1
- package/dist/web-react/index.d.ts +73 -6
- package/dist/web-react/index.js +2 -2
- package/dist/work-product-react/index.js +1 -1
- package/package.json +1 -1
- package/dist/VaultPane-HFH734K6.js +0 -7
- package/dist/chunk-3IHYJIDJ.js.map +0 -1
- package/dist/chunk-73CQJOIU.js.map +0 -1
- package/dist/chunk-7PFFFRVU.js.map +0 -1
- package/dist/chunk-FVJP2RTC.js.map +0 -1
- package/dist/chunk-MLACJ6DB.js.map +0 -1
- package/dist/chunk-TZO3SOUL.js.map +0 -1
- package/dist/chunk-YTMKRL3L.js.map +0 -1
- /package/dist/{DesignCanvas-ZG7DJS7C.js.map → DesignCanvas-3RRPVPCP.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-SLFMHOII.js.map → DesignCanvasEditor-KAMMEX7E.js.map} +0 -0
- /package/dist/{TimelineEditor-6PV42FLG.js.map → TimelineEditor-IIBVCAZV.js.map} +0 -0
- /package/dist/{VaultPane-HFH734K6.js.map → VaultPane-MUWGYVJ7.js.map} +0 -0
- /package/dist/{chunk-OASVAPRL.js.map → chunk-AWPK7ZDS.js.map} +0 -0
|
@@ -1,310 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
function resolveAsyncValue(value, isEmpty = defaultIsEmpty) {
|
|
21
|
-
return isEmpty(value) ? { status: "empty", value } : { status: "ready", value };
|
|
22
|
-
}
|
|
23
|
-
var AsyncRequestError = class extends Error {
|
|
24
|
-
status;
|
|
25
|
-
statusText;
|
|
26
|
-
url;
|
|
27
|
-
/** First 200 characters of the response body when it could be read, else `''`.
|
|
28
|
-
* Kept off `message` so a server's HTML error page never becomes UI copy. */
|
|
29
|
-
body;
|
|
30
|
-
constructor(response, body = "") {
|
|
31
|
-
const statusText = response.statusText ?? "";
|
|
32
|
-
super(`Request failed (${response.status}${statusText ? ` ${statusText}` : ""})`);
|
|
33
|
-
this.name = "AsyncRequestError";
|
|
34
|
-
this.status = response.status;
|
|
35
|
-
this.statusText = statusText;
|
|
36
|
-
this.url = response.url ?? "";
|
|
37
|
-
this.body = body;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
async function readBodySnippet(response) {
|
|
41
|
-
try {
|
|
42
|
-
return (await response.text()).slice(0, 200);
|
|
43
|
-
} catch {
|
|
44
|
-
return "";
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function requireOk(response) {
|
|
48
|
-
if (response.ok) return response;
|
|
49
|
-
throw new AsyncRequestError(response, await readBodySnippet(response));
|
|
50
|
-
}
|
|
51
|
-
async function readOkJson(response, parse) {
|
|
52
|
-
await requireOk(response);
|
|
53
|
-
let data;
|
|
54
|
-
try {
|
|
55
|
-
data = await response.json();
|
|
56
|
-
} catch (error) {
|
|
57
|
-
throw new Error("The response was not valid JSON.", { cause: error });
|
|
58
|
-
}
|
|
59
|
-
return parse ? parse(data) : data;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// src/web-react/async/use-async-resource.ts
|
|
63
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
64
|
-
function useChangeToken(deps) {
|
|
65
|
-
const ref = useRef({ deps, token: 0 });
|
|
66
|
-
const changed = ref.current.deps.length !== deps.length || deps.some((dep, index) => !Object.is(dep, ref.current.deps[index]));
|
|
67
|
-
if (changed) ref.current = { deps, token: ref.current.token + 1 };
|
|
68
|
-
return ref.current.token;
|
|
69
|
-
}
|
|
70
|
-
var NO_DEPS = [];
|
|
71
|
-
function useAsyncResource({
|
|
72
|
-
load,
|
|
73
|
-
deps = NO_DEPS,
|
|
74
|
-
enabled = true,
|
|
75
|
-
initialValue,
|
|
76
|
-
isEmpty,
|
|
77
|
-
errorMessage
|
|
78
|
-
}) {
|
|
79
|
-
const loadRef = useRef(load);
|
|
80
|
-
loadRef.current = load;
|
|
81
|
-
const isEmptyRef = useRef(isEmpty ?? defaultIsEmpty);
|
|
82
|
-
isEmptyRef.current = isEmpty ?? defaultIsEmpty;
|
|
83
|
-
const errorMessageRef = useRef(errorMessage);
|
|
84
|
-
errorMessageRef.current = errorMessage;
|
|
85
|
-
const [resolution, setResolution] = useState(() => {
|
|
86
|
-
if (initialValue !== void 0) return resolveAsyncValue(initialValue, isEmpty ?? defaultIsEmpty);
|
|
87
|
-
return enabled ? { status: "loading" } : { status: "idle" };
|
|
88
|
-
});
|
|
89
|
-
const [reloadKey, setReloadKey] = useState(0);
|
|
90
|
-
const seqRef = useRef(0);
|
|
91
|
-
const seededRef = useRef(initialValue !== void 0);
|
|
92
|
-
const token = useChangeToken(deps);
|
|
93
|
-
useEffect(() => {
|
|
94
|
-
if (!enabled) return;
|
|
95
|
-
if (seededRef.current) {
|
|
96
|
-
seededRef.current = false;
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
const seq = ++seqRef.current;
|
|
100
|
-
const controller = new AbortController();
|
|
101
|
-
setResolution({ status: "loading" });
|
|
102
|
-
void (async () => {
|
|
103
|
-
try {
|
|
104
|
-
const value = await loadRef.current({ signal: controller.signal });
|
|
105
|
-
if (seq !== seqRef.current || controller.signal.aborted) return;
|
|
106
|
-
setResolution(resolveAsyncValue(value, isEmptyRef.current));
|
|
107
|
-
} catch (error) {
|
|
108
|
-
if (seq !== seqRef.current || controller.signal.aborted) return;
|
|
109
|
-
setResolution({
|
|
110
|
-
status: "error",
|
|
111
|
-
message: errorMessageRef.current ? errorMessageRef.current(error) : asyncErrorMessage(error),
|
|
112
|
-
error
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
})();
|
|
116
|
-
return () => controller.abort();
|
|
117
|
-
}, [token, enabled, reloadKey]);
|
|
118
|
-
const retry = useCallback(() => {
|
|
119
|
-
setReloadKey((key) => key + 1);
|
|
120
|
-
}, []);
|
|
121
|
-
return useMemo(() => {
|
|
122
|
-
switch (resolution.status) {
|
|
123
|
-
case "ready":
|
|
124
|
-
return { status: "ready", value: resolution.value, retry };
|
|
125
|
-
case "empty":
|
|
126
|
-
return { status: "empty", value: resolution.value, retry };
|
|
127
|
-
case "error":
|
|
128
|
-
return { status: "error", message: resolution.message, error: resolution.error, retry };
|
|
129
|
-
case "loading":
|
|
130
|
-
return { status: "loading", retry };
|
|
131
|
-
case "idle":
|
|
132
|
-
return { status: "idle", retry };
|
|
133
|
-
}
|
|
134
|
-
}, [resolution, retry]);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/web-react/async/use-confirmed-mutation.ts
|
|
138
|
-
import { useCallback as useCallback2, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
139
|
-
var CONFIRMED_WRITE = /* @__PURE__ */ Symbol("agent-app.confirmed-write");
|
|
140
|
-
function confirmWrite(value) {
|
|
141
|
-
return { succeeded: true, value, [CONFIRMED_WRITE]: true };
|
|
142
|
-
}
|
|
143
|
-
function rejectWrite(message, error) {
|
|
144
|
-
return error === void 0 ? { succeeded: false, message } : { succeeded: false, message, error };
|
|
145
|
-
}
|
|
146
|
-
async function confirmResponse(response) {
|
|
147
|
-
try {
|
|
148
|
-
return confirmWrite(await requireOk(response));
|
|
149
|
-
} catch (error) {
|
|
150
|
-
return rejectWrite(asyncErrorMessage(error), error);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
async function confirmJson(response, parse) {
|
|
154
|
-
try {
|
|
155
|
-
return confirmWrite(await readOkJson(response, parse));
|
|
156
|
-
} catch (error) {
|
|
157
|
-
return rejectWrite(asyncErrorMessage(error), error);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function isConfirmedWrite(outcome) {
|
|
161
|
-
if (typeof outcome !== "object" || outcome === null) return false;
|
|
162
|
-
return outcome[CONFIRMED_WRITE] === true;
|
|
163
|
-
}
|
|
164
|
-
function asRejection(outcome) {
|
|
165
|
-
if (typeof outcome !== "object" || outcome === null) return null;
|
|
166
|
-
const candidate = outcome;
|
|
167
|
-
if (candidate.succeeded !== false) return null;
|
|
168
|
-
const message = typeof candidate.message === "string" && candidate.message.trim() !== "" ? candidate.message : UNCONFIRMED_MESSAGE;
|
|
169
|
-
return rejectWrite(message, candidate.error);
|
|
170
|
-
}
|
|
171
|
-
var UNCONFIRMED_MESSAGE = "The write could not be confirmed.";
|
|
172
|
-
var UNCONFIRMED_CONTRACT = "mutate() resolved without a confirmation. Return confirmWrite(value), confirmResponse(response) or confirmJson(response, parse) so the success state proves the write landed.";
|
|
173
|
-
function useConfirmedMutation({
|
|
174
|
-
mutate,
|
|
175
|
-
onSucceeded,
|
|
176
|
-
onFailed,
|
|
177
|
-
errorMessage
|
|
178
|
-
}) {
|
|
179
|
-
const mutateRef = useRef2(mutate);
|
|
180
|
-
mutateRef.current = mutate;
|
|
181
|
-
const onSucceededRef = useRef2(onSucceeded);
|
|
182
|
-
onSucceededRef.current = onSucceeded;
|
|
183
|
-
const onFailedRef = useRef2(onFailed);
|
|
184
|
-
onFailedRef.current = onFailed;
|
|
185
|
-
const errorMessageRef = useRef2(errorMessage);
|
|
186
|
-
errorMessageRef.current = errorMessage;
|
|
187
|
-
const [state, setState] = useState2({ status: "idle" });
|
|
188
|
-
const seqRef = useRef2(0);
|
|
189
|
-
const inFlightRef = useRef2(null);
|
|
190
|
-
const run = useCallback2(async (input) => {
|
|
191
|
-
inFlightRef.current?.abort();
|
|
192
|
-
const controller = new AbortController();
|
|
193
|
-
inFlightRef.current = controller;
|
|
194
|
-
const seq = ++seqRef.current;
|
|
195
|
-
setState({ status: "pending" });
|
|
196
|
-
let outcome;
|
|
197
|
-
try {
|
|
198
|
-
const returned = await mutateRef.current(input, { signal: controller.signal });
|
|
199
|
-
outcome = isConfirmedWrite(returned) ? returned : asRejection(returned) ?? rejectWrite(UNCONFIRMED_MESSAGE, new Error(UNCONFIRMED_CONTRACT));
|
|
200
|
-
} catch (error) {
|
|
201
|
-
outcome = rejectWrite(errorMessageRef.current ? errorMessageRef.current(error) : asyncErrorMessage(error), error);
|
|
202
|
-
}
|
|
203
|
-
if (seq !== seqRef.current) return outcome;
|
|
204
|
-
if (outcome.succeeded) {
|
|
205
|
-
setState({ status: "succeeded", value: outcome.value });
|
|
206
|
-
onSucceededRef.current?.(outcome.value);
|
|
207
|
-
} else {
|
|
208
|
-
setState({ status: "failed", message: outcome.message, error: outcome.error });
|
|
209
|
-
onFailedRef.current?.(outcome.message, outcome.error);
|
|
210
|
-
}
|
|
211
|
-
return outcome;
|
|
212
|
-
}, []);
|
|
213
|
-
const reset = useCallback2(() => {
|
|
214
|
-
seqRef.current += 1;
|
|
215
|
-
inFlightRef.current?.abort();
|
|
216
|
-
inFlightRef.current = null;
|
|
217
|
-
setState({ status: "idle" });
|
|
218
|
-
}, []);
|
|
219
|
-
return useMemo2(() => ({ state, run, reset }), [state, run, reset]);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// src/web-react/async/async-view.tsx
|
|
223
|
-
import { isValidElement } from "react";
|
|
224
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
225
|
-
var BLOCK_CLASS = "flex flex-col items-center justify-center gap-2 px-4 py-10 text-center";
|
|
226
|
-
function AsyncView({
|
|
227
|
-
state,
|
|
228
|
-
children,
|
|
229
|
-
empty,
|
|
230
|
-
renderLoading,
|
|
231
|
-
renderError,
|
|
232
|
-
renderIdle,
|
|
233
|
-
loadingLabel = "Loading\u2026",
|
|
234
|
-
retryLabel = "Retry",
|
|
235
|
-
className
|
|
236
|
-
}) {
|
|
237
|
-
if (state.status === "ready") return /* @__PURE__ */ jsx(Fragment, { children: children(state.value) });
|
|
238
|
-
const branch = () => {
|
|
239
|
-
switch (state.status) {
|
|
240
|
-
case "idle":
|
|
241
|
-
return renderIdle?.() ?? /* @__PURE__ */ jsx(LoadingBlock, { label: loadingLabel });
|
|
242
|
-
case "loading":
|
|
243
|
-
return renderLoading?.() ?? /* @__PURE__ */ jsx(LoadingBlock, { label: loadingLabel });
|
|
244
|
-
case "error":
|
|
245
|
-
return renderError?.({ message: state.message, retry: state.retry }) ?? /* @__PURE__ */ jsx(ErrorBlock, { message: state.message, retry: state.retry, retryLabel });
|
|
246
|
-
case "empty":
|
|
247
|
-
if (isValidElement(empty)) return empty;
|
|
248
|
-
return typeof empty === "object" && empty !== null && typeof empty.title === "string" ? /* @__PURE__ */ jsx(EmptyBlock, { spec: empty }) : /* @__PURE__ */ jsx(EmptyBlock, { spec: { title: "Nothing here yet." } });
|
|
249
|
-
}
|
|
250
|
-
};
|
|
251
|
-
return /* @__PURE__ */ jsx("div", { "data-async-state": state.status, className, children: branch() });
|
|
252
|
-
}
|
|
253
|
-
function LoadingBlock({ label }) {
|
|
254
|
-
return /* @__PURE__ */ jsxs("div", { role: "status", "aria-live": "polite", "aria-busy": "true", className: BLOCK_CLASS, children: [
|
|
255
|
-
/* @__PURE__ */ jsx(
|
|
256
|
-
"span",
|
|
257
|
-
{
|
|
258
|
-
className: "h-4 w-4 animate-spin rounded-full border-2 border-border border-t-transparent",
|
|
259
|
-
"aria-hidden": "true"
|
|
260
|
-
}
|
|
261
|
-
),
|
|
262
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: label })
|
|
263
|
-
] });
|
|
264
|
-
}
|
|
265
|
-
function ErrorBlock({
|
|
266
|
-
message,
|
|
267
|
-
retry,
|
|
268
|
-
retryLabel
|
|
269
|
-
}) {
|
|
270
|
-
return /* @__PURE__ */ jsxs("div", { role: "alert", className: BLOCK_CLASS, children: [
|
|
271
|
-
/* @__PURE__ */ jsx("p", { className: "max-w-md text-sm text-muted-foreground", children: message }),
|
|
272
|
-
/* @__PURE__ */ jsx(
|
|
273
|
-
"button",
|
|
274
|
-
{
|
|
275
|
-
type: "button",
|
|
276
|
-
onClick: retry,
|
|
277
|
-
className: "h-8 rounded-md border border-border px-3 text-xs font-medium text-foreground transition hover:bg-accent/30",
|
|
278
|
-
children: retryLabel
|
|
279
|
-
}
|
|
280
|
-
)
|
|
281
|
-
] });
|
|
282
|
-
}
|
|
283
|
-
function EmptyBlock({ spec }) {
|
|
284
|
-
return /* @__PURE__ */ jsxs("div", { className: BLOCK_CLASS, children: [
|
|
285
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-foreground", children: spec.title }),
|
|
286
|
-
spec.description ? /* @__PURE__ */ jsx("p", { className: "max-w-md text-sm text-muted-foreground", children: spec.description }) : null,
|
|
287
|
-
spec.action ? isValidElement(spec.action) ? spec.action : /* @__PURE__ */ jsx(
|
|
288
|
-
"button",
|
|
289
|
-
{
|
|
290
|
-
type: "button",
|
|
291
|
-
onClick: spec.action.onClick,
|
|
292
|
-
className: "h-8 rounded-md border border-border px-3 text-xs font-medium text-foreground transition hover:bg-accent/30",
|
|
293
|
-
children: spec.action.label
|
|
294
|
-
}
|
|
295
|
-
) : null
|
|
296
|
-
] });
|
|
297
|
-
}
|
|
298
|
-
function MutationStatus({ state, labels, className }) {
|
|
299
|
-
if (state.status === "idle") return null;
|
|
300
|
-
if (state.status === "pending") {
|
|
301
|
-
return /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: className ?? "text-xs text-muted-foreground", children: labels?.pending ?? "Saving\u2026" });
|
|
302
|
-
}
|
|
303
|
-
if (state.status === "succeeded") {
|
|
304
|
-
return /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: className ?? "text-xs text-muted-foreground", children: labels?.succeeded ?? "Saved" });
|
|
305
|
-
}
|
|
306
|
-
return /* @__PURE__ */ jsx("span", { role: "alert", className: className ?? "text-xs text-destructive", children: state.message });
|
|
307
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
AsyncRequestError,
|
|
3
|
+
AsyncView,
|
|
4
|
+
CONFIRMED_WRITE,
|
|
5
|
+
DEFAULT_ASYNC_ERROR_MESSAGE,
|
|
6
|
+
MutationStatus,
|
|
7
|
+
asyncErrorMessage,
|
|
8
|
+
confirmJson,
|
|
9
|
+
confirmResponse,
|
|
10
|
+
confirmWrite,
|
|
11
|
+
defaultIsEmpty,
|
|
12
|
+
isConfirmedWrite,
|
|
13
|
+
readOkJson,
|
|
14
|
+
rejectWrite,
|
|
15
|
+
requireOk,
|
|
16
|
+
resolveAsyncValue,
|
|
17
|
+
useAsyncResource,
|
|
18
|
+
useConfirmedMutation
|
|
19
|
+
} from "../../chunk-YIQHOAHN.js";
|
|
308
20
|
export {
|
|
309
21
|
AsyncRequestError,
|
|
310
22
|
AsyncView,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/web-react/async/state.ts","../../../src/web-react/async/use-async-resource.ts","../../../src/web-react/async/use-confirmed-mutation.ts","../../../src/web-react/async/async-view.tsx"],"sourcesContent":["/**\n * The fetch-state contract: a failed load cannot render as empty data.\n *\n * Three shapes produce that defect, and two audited verticals shipped dozens of\n * each: a `catch` handler that only clears a loading flag, an early return on a\n * non-ok response, and a bare `null` returned while loading. All three end with\n * the same pixels a successful-but-empty load produces — \"No templates\n * available\", an empty member list, a blank conversation — so the reader cannot\n * tell \"we asked and there is nothing\" from \"we could not ask\", and the retry\n * that would fix it is never offered.\n *\n * `AsyncResourceState` makes the two outcomes separate variants: `error` is the\n * only one carrying a message and it is never reachable with a value, `empty` is\n * the only one carrying a resolved-but-empty value and it never carries a\n * message. A component rendering one is structurally not rendering the other.\n *\n * This file is React-free so the state model, the emptiness rule and the\n * Response readers can be unit-tested and reused outside a component.\n */\n\n/**\n * - `idle` — no load has been attempted (the hook is disabled, or its inputs\n * are not resolved yet). Distinct from `loading`: nothing is in flight.\n * - `loading` — a load is in flight and no value is held.\n * - `error` — the load failed. Carries the message and never a value.\n * - `empty` — the load succeeded and the value is empty. Never carries a message.\n * - `ready` — the load succeeded and the value is non-empty.\n */\nexport type AsyncResourceStatus = 'idle' | 'loading' | 'error' | 'empty' | 'ready'\n\n/** Re-runs the load. Present on every variant so the error branch can never be\n * rendered without the action that recovers from it. */\nexport interface AsyncRetryable {\n readonly retry: () => void\n}\n\nexport type AsyncResourceState<T> =\n | ({ readonly status: 'idle' } & AsyncRetryable)\n | ({ readonly status: 'loading' } & AsyncRetryable)\n | ({ readonly status: 'error'; readonly message: string; readonly error: unknown } & AsyncRetryable)\n | ({ readonly status: 'empty'; readonly value: T } & AsyncRetryable)\n | ({ readonly status: 'ready'; readonly value: T } & AsyncRetryable)\n\n/** The state model without the retry action — what a reducer produces. */\nexport type AsyncResolution<T> =\n | { readonly status: 'idle' }\n | { readonly status: 'loading' }\n | { readonly status: 'error'; readonly message: string; readonly error: unknown }\n | { readonly status: 'empty'; readonly value: T }\n | { readonly status: 'ready'; readonly value: T }\n\nexport const DEFAULT_ASYNC_ERROR_MESSAGE = 'Something went wrong. Please try again.'\n\n/**\n * Default emptiness rule: `null`/`undefined`, an empty array, an empty `Map` or\n * `Set`. A string, a number and a plain object are `ready` — `''` and `{}` are\n * legitimate values for the resources that produce them, and guessing otherwise\n * would route a real answer into the empty branch. Pass `isEmpty` for a shape\n * this cannot see into (`{ items: [] }`, a paged envelope, a count).\n */\nexport function defaultIsEmpty(value: unknown): boolean {\n if (value === null || value === undefined) return true\n if (Array.isArray(value)) return value.length === 0\n if (value instanceof Map || value instanceof Set) return value.size === 0\n return false\n}\n\nfunction hasMessage(value: object): value is { message: unknown } {\n return 'message' in value\n}\n\n/** Best available human-readable message for a thrown value. Never returns an\n * empty string — a blank error block reads as a rendering bug. */\nexport function asyncErrorMessage(error: unknown, fallback: string = DEFAULT_ASYNC_ERROR_MESSAGE): string {\n if (typeof error === 'string' && error.trim() !== '') return error\n if (typeof error === 'object' && error !== null && hasMessage(error)) {\n const message = error.message\n if (typeof message === 'string' && message.trim() !== '') return message\n }\n return fallback\n}\n\n/** Classifies a successfully loaded value into `ready` or `empty`. */\nexport function resolveAsyncValue<T>(value: T, isEmpty: (value: T) => boolean = defaultIsEmpty): AsyncResolution<T> {\n return isEmpty(value) ? { status: 'empty', value } : { status: 'ready', value }\n}\n\n/**\n * A non-ok HTTP response, as a throwable. `requireOk`/`readOkJson` raise this so\n * a non-ok response reaches the `error` branch instead of an early `return` that\n * leaves the caller rendering the empty branch.\n */\nexport class AsyncRequestError extends Error {\n readonly status: number\n readonly statusText: string\n readonly url: string\n /** First 200 characters of the response body when it could be read, else `''`.\n * Kept off `message` so a server's HTML error page never becomes UI copy. */\n readonly body: string\n\n constructor(response: { status: number; statusText?: string; url?: string }, body = '') {\n const statusText = response.statusText ?? ''\n super(`Request failed (${response.status}${statusText ? ` ${statusText}` : ''})`)\n this.name = 'AsyncRequestError'\n this.status = response.status\n this.statusText = statusText\n this.url = response.url ?? ''\n this.body = body\n }\n}\n\nasync function readBodySnippet(response: Response): Promise<string> {\n try {\n return (await response.text()).slice(0, 200)\n } catch {\n // An already-consumed or unreadable body is a missing diagnostic, not a\n // second failure — the status is what the error reports.\n return ''\n }\n}\n\n/** Returns the response when ok; throws `AsyncRequestError` otherwise. Reads the\n * body only on the failure path, so the caller keeps an unconsumed stream. */\nexport async function requireOk(response: Response): Promise<Response> {\n if (response.ok) return response\n throw new AsyncRequestError(response, await readBodySnippet(response))\n}\n\n/**\n * `requireOk` + `response.json()`. Without `parse` the result is `unknown`, so a\n * caller narrows at the JSON boundary rather than inheriting an unchecked shape;\n * with `parse` the validator runs inside the load and a rejection lands in the\n * `error` branch.\n */\nexport async function readOkJson(response: Response): Promise<unknown>\nexport async function readOkJson<T>(response: Response, parse: (data: unknown) => T): Promise<T>\nexport async function readOkJson<T>(response: Response, parse?: (data: unknown) => T): Promise<T | unknown> {\n await requireOk(response)\n let data: unknown\n try {\n data = await response.json()\n } catch (error) {\n throw new Error('The response was not valid JSON.', { cause: error })\n }\n return parse ? parse(data) : data\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport {\n asyncErrorMessage,\n defaultIsEmpty,\n resolveAsyncValue,\n type AsyncResolution,\n type AsyncResourceState,\n} from './state'\n\nexport interface AsyncLoadContext {\n /** Aborted when the inputs change, a retry supersedes this load, or the\n * component unmounts. Forward it to `fetch` so a superseded request stops. */\n readonly signal: AbortSignal\n}\n\nexport interface UseAsyncResourceOptions<T> {\n /**\n * The one load. Reject (or throw) to reach the `error` branch — a non-ok\n * response must reject too, which is what `requireOk`/`readOkJson` are for.\n * Read from a ref internally, so an inline arrow does not re-trigger; `deps`\n * is what declares when the load must run again.\n */\n load: (context: AsyncLoadContext) => Promise<T>\n /** Re-runs the load when any entry changes by `Object.is`, like `useEffect`. */\n deps?: readonly unknown[]\n /** `false` holds the resource at `idle` and runs nothing — for inputs that are\n * not resolved yet. Flipping it to `true` starts the load. */\n enabled?: boolean\n /** First-render seed (an SSR/loader page). The hook starts resolved and skips\n * the first load. Read once — later identity changes are ignored, so a\n * revalidating loader belongs in `deps`, not here. */\n initialValue?: T\n /** Splits a successful load into `empty` vs `ready`. Default: `defaultIsEmpty`. */\n isEmpty?: (value: T) => boolean\n /** Maps a thrown value to the message the `error` branch renders. */\n errorMessage?: (error: unknown) => string\n}\n\n/** Bumps a token when any dependency changes identity, so the effect's own\n * dependency list stays a fixed length whatever the caller passes. */\nfunction useChangeToken(deps: readonly unknown[]): number {\n const ref = useRef<{ deps: readonly unknown[]; token: number }>({ deps, token: 0 })\n const changed =\n ref.current.deps.length !== deps.length || deps.some((dep, index) => !Object.is(dep, ref.current.deps[index]))\n if (changed) ref.current = { deps, token: ref.current.token + 1 }\n return ref.current.token\n}\n\nconst NO_DEPS: readonly unknown[] = []\n\n/**\n * The five-state fetch machine: `idle | loading | error | empty | ready`.\n *\n * What it guarantees, and what the hand-rolled versions it replaces did not:\n *\n * - a rejected load lands on `error` with a message and a `retry`, never on an\n * empty list;\n * - `empty` is only reachable from a load that actually succeeded;\n * - a superseded load (inputs changed, retry pressed, component unmounted) is\n * aborted and its late result is dropped by a monotonic sequence guard, so it\n * cannot repaint a newer view.\n */\nexport function useAsyncResource<T>({\n load,\n deps = NO_DEPS,\n enabled = true,\n initialValue,\n isEmpty,\n errorMessage,\n}: UseAsyncResourceOptions<T>): AsyncResourceState<T> {\n const loadRef = useRef(load)\n loadRef.current = load\n const isEmptyRef = useRef(isEmpty ?? defaultIsEmpty)\n isEmptyRef.current = isEmpty ?? defaultIsEmpty\n const errorMessageRef = useRef(errorMessage)\n errorMessageRef.current = errorMessage\n\n const [resolution, setResolution] = useState<AsyncResolution<T>>(() => {\n if (initialValue !== undefined) return resolveAsyncValue(initialValue, isEmpty ?? defaultIsEmpty)\n return enabled ? { status: 'loading' } : { status: 'idle' }\n })\n const [reloadKey, setReloadKey] = useState(0)\n\n const seqRef = useRef(0)\n // Consumed by the first load attempt: a seeded resource must not throw its\n // seed away to re-fetch what the server already sent.\n const seededRef = useRef(initialValue !== undefined)\n const token = useChangeToken(deps)\n\n useEffect(() => {\n if (!enabled) return\n if (seededRef.current) {\n seededRef.current = false\n return\n }\n\n const seq = ++seqRef.current\n const controller = new AbortController()\n setResolution({ status: 'loading' })\n\n void (async () => {\n try {\n const value = await loadRef.current({ signal: controller.signal })\n if (seq !== seqRef.current || controller.signal.aborted) return\n setResolution(resolveAsyncValue(value, isEmptyRef.current))\n } catch (error) {\n if (seq !== seqRef.current || controller.signal.aborted) return\n setResolution({\n status: 'error',\n message: errorMessageRef.current ? errorMessageRef.current(error) : asyncErrorMessage(error),\n error,\n })\n }\n })()\n\n return () => controller.abort()\n }, [token, enabled, reloadKey])\n\n const retry = useCallback(() => {\n setReloadKey((key) => key + 1)\n }, [])\n\n return useMemo<AsyncResourceState<T>>(() => {\n switch (resolution.status) {\n case 'ready':\n return { status: 'ready', value: resolution.value, retry }\n case 'empty':\n return { status: 'empty', value: resolution.value, retry }\n case 'error':\n return { status: 'error', message: resolution.message, error: resolution.error, retry }\n case 'loading':\n return { status: 'loading', retry }\n case 'idle':\n return { status: 'idle', retry }\n }\n }, [resolution, retry])\n}\n","import { useCallback, useMemo, useRef, useState } from 'react'\n\nimport { asyncErrorMessage, readOkJson, requireOk } from './state'\nimport type { AsyncLoadContext } from './use-async-resource'\n\n/**\n * The brand that makes \"Saved\" unreachable without a confirmed write.\n *\n * A resolved promise is not a success: `fetch` resolves on a 404, and the\n * shipped defect this closes is a save button that rendered \"Saved\" because the\n * only thing awaited was that the request came back at all. The success variant\n * therefore carries a symbol no object literal can spell, so the only way into\n * `succeeded` is `confirmWrite` / `confirmResponse` / `confirmJson` — each of\n * which has already checked that the write landed.\n */\nexport const CONFIRMED_WRITE: unique symbol = Symbol('agent-app.confirmed-write')\n\nexport interface MutationConfirmed<T> {\n readonly succeeded: true\n readonly value: T\n readonly [CONFIRMED_WRITE]: true\n}\n\nexport interface MutationRejected {\n readonly succeeded: false\n /** Safe to render: what the user is told the write did not do. */\n readonly message: string\n readonly error?: unknown\n}\n\nexport type MutationOutcome<T> = MutationConfirmed<T> | MutationRejected\n\n/** Confirms a write whose success is already established (an SDK call that\n * throws on failure, a store returning its own typed outcome). The deliberate\n * act is the point — this call is what an audit greps for. */\nexport function confirmWrite<T>(value: T): MutationConfirmed<T> {\n return { succeeded: true, value, [CONFIRMED_WRITE]: true }\n}\n\n/** A write that did not land. Constructible by hand: failing loud is never the\n * direction that needs guarding. */\nexport function rejectWrite(message: string, error?: unknown): MutationRejected {\n return error === undefined ? { succeeded: false, message } : { succeeded: false, message, error }\n}\n\n/** Confirms only a 2xx response. A 404/500 becomes a rejection carrying the\n * status — never a success, whatever the promise did. */\nexport async function confirmResponse(response: Response): Promise<MutationOutcome<Response>> {\n try {\n return confirmWrite(await requireOk(response))\n } catch (error) {\n return rejectWrite(asyncErrorMessage(error), error)\n }\n}\n\n/** `confirmResponse` + a JSON body. A non-ok status, an unreadable body and a\n * throwing `parse` are all rejections. */\nexport async function confirmJson<T>(response: Response, parse: (data: unknown) => T): Promise<MutationOutcome<T>> {\n try {\n return confirmWrite(await readOkJson(response, parse))\n } catch (error) {\n return rejectWrite(asyncErrorMessage(error), error)\n }\n}\n\n/** True only for a value built by one of the confirm helpers. Takes `unknown`\n * because an untyped consumer can return anything from `mutate`. */\nexport function isConfirmedWrite<T>(outcome: unknown): outcome is MutationConfirmed<T> {\n if (typeof outcome !== 'object' || outcome === null) return false\n return (outcome as { readonly [CONFIRMED_WRITE]?: unknown })[CONFIRMED_WRITE] === true\n}\n\nfunction asRejection(outcome: unknown): MutationRejected | null {\n if (typeof outcome !== 'object' || outcome === null) return null\n const candidate = outcome as { succeeded?: unknown; message?: unknown; error?: unknown }\n if (candidate.succeeded !== false) return null\n const message = typeof candidate.message === 'string' && candidate.message.trim() !== ''\n ? candidate.message\n : UNCONFIRMED_MESSAGE\n return rejectWrite(message, candidate.error)\n}\n\nexport type MutationState<T> =\n | { readonly status: 'idle' }\n | { readonly status: 'pending' }\n | { readonly status: 'succeeded'; readonly value: T }\n | { readonly status: 'failed'; readonly message: string; readonly error: unknown }\n\nexport interface UseConfirmedMutationOptions<TInput, TValue> {\n /**\n * Performs the write and returns a confirmation. Anything else — including a\n * hand-written `{ succeeded: true }` — is treated as a failed write, because\n * an unbranded object is exactly the shape produced by code that never\n * checked the response.\n *\n * The context signal aborts only when a later `run` supersedes this one. It is\n * NOT aborted on unmount: a write the user asked for must not be cancelled by\n * navigating away.\n */\n mutate: (input: TInput, context: AsyncLoadContext) => Promise<MutationOutcome<TValue>>\n /** Fires after the state reaches `succeeded` (latest run only). */\n onSucceeded?: (value: TValue) => void\n /** Fires after the state reaches `failed` (latest run only). */\n onFailed?: (message: string, error: unknown) => void\n /** Maps a thrown value to the message the `failed` state renders. */\n errorMessage?: (error: unknown) => string\n}\n\nexport interface ConfirmedMutation<TInput, TValue> {\n readonly state: MutationState<TValue>\n /** Runs the write. Never rejects — the outcome is returned and mirrored into\n * `state`. Concurrent runs are last-write-wins; disable the control while\n * `state.status === 'pending'`. */\n readonly run: (input: TInput) => Promise<MutationOutcome<TValue>>\n /** Back to `idle` (dismisses a \"Saved\" or error affordance). */\n readonly reset: () => void\n}\n\nconst UNCONFIRMED_MESSAGE = 'The write could not be confirmed.'\n\nconst UNCONFIRMED_CONTRACT =\n 'mutate() resolved without a confirmation. Return confirmWrite(value), confirmResponse(response) or confirmJson(response, parse) so the success state proves the write landed.'\n\n/**\n * `idle | pending | succeeded | failed` over a write that must confirm itself.\n *\n * `succeeded` is reachable only through a branded confirmation, so the audited\n * \"Saved on a 404\" bug cannot be written with this hook: the 404 path produces\n * `failed` carrying the status, and a `mutate` that forgot to check produces\n * `failed` carrying the contract violation rather than a success it never\n * earned.\n */\nexport function useConfirmedMutation<TInput, TValue>({\n mutate,\n onSucceeded,\n onFailed,\n errorMessage,\n}: UseConfirmedMutationOptions<TInput, TValue>): ConfirmedMutation<TInput, TValue> {\n const mutateRef = useRef(mutate)\n mutateRef.current = mutate\n const onSucceededRef = useRef(onSucceeded)\n onSucceededRef.current = onSucceeded\n const onFailedRef = useRef(onFailed)\n onFailedRef.current = onFailed\n const errorMessageRef = useRef(errorMessage)\n errorMessageRef.current = errorMessage\n\n const [state, setState] = useState<MutationState<TValue>>({ status: 'idle' })\n const seqRef = useRef(0)\n const inFlightRef = useRef<AbortController | null>(null)\n\n const run = useCallback(async (input: TInput): Promise<MutationOutcome<TValue>> => {\n inFlightRef.current?.abort()\n const controller = new AbortController()\n inFlightRef.current = controller\n const seq = ++seqRef.current\n\n setState({ status: 'pending' })\n\n let outcome: MutationOutcome<TValue>\n try {\n const returned: unknown = await mutateRef.current(input, { signal: controller.signal })\n outcome = isConfirmedWrite<TValue>(returned)\n ? returned\n : asRejection(returned) ?? rejectWrite(UNCONFIRMED_MESSAGE, new Error(UNCONFIRMED_CONTRACT))\n } catch (error) {\n outcome = rejectWrite(errorMessageRef.current ? errorMessageRef.current(error) : asyncErrorMessage(error), error)\n }\n\n // A superseded run reports its own outcome to its own caller and never\n // repaints the state a newer run owns.\n if (seq !== seqRef.current) return outcome\n\n if (outcome.succeeded) {\n setState({ status: 'succeeded', value: outcome.value })\n onSucceededRef.current?.(outcome.value)\n } else {\n setState({ status: 'failed', message: outcome.message, error: outcome.error })\n onFailedRef.current?.(outcome.message, outcome.error)\n }\n return outcome\n }, [])\n\n const reset = useCallback(() => {\n seqRef.current += 1\n inFlightRef.current?.abort()\n inFlightRef.current = null\n setState({ status: 'idle' })\n }, [])\n\n return useMemo(() => ({ state, run, reset }), [state, run, reset])\n}\n","import { isValidElement, type ReactElement, type ReactNode } from 'react'\n\nimport type { AsyncResourceState } from './state'\nimport type { MutationState } from './use-confirmed-mutation'\n\nexport interface AsyncEmptyAction {\n label: string\n onClick: () => void\n}\n\nexport interface AsyncEmptySpec {\n /** What is not there, in the reader's words (\"No templates yet\"). Required:\n * an empty state with nothing to say is the state this module exists to\n * stop being mistaken for a failure. */\n title: string\n description?: string\n /** The next action. An element is rendered as supplied (a link, a dialog\n * trigger); the object form renders the standard button. */\n action?: AsyncEmptyAction | ReactElement\n}\n\nexport interface AsyncErrorRenderProps {\n message: string\n retry: () => void\n}\n\nexport interface AsyncViewProps<T> {\n state: AsyncResourceState<T>\n /** Rendered only for `ready`, with the loaded value — the branch cannot be\n * entered without one. */\n children: (value: T) => ReactNode\n /** Required: `empty` must name what is missing and what to do about it. */\n empty: AsyncEmptySpec | ReactElement\n /** Must return an element. Returning nothing is what produced the blank\n * screens this component replaces, so a nullish return falls back to the\n * built-in block rather than rendering nothing. */\n renderLoading?: () => ReactElement\n renderError?: (props: AsyncErrorRenderProps) => ReactElement\n /** `idle` renders the loading block by default — from the reader's side,\n * \"not started\" and \"in flight\" are the same wait. */\n renderIdle?: () => ReactElement\n loadingLabel?: string\n retryLabel?: string\n /** Applied to the wrapper around the non-`ready` branches. `ready` renders the\n * children with no wrapper element, so grids and lists keep their layout. */\n className?: string\n}\n\nconst BLOCK_CLASS = 'flex flex-col items-center justify-center gap-2 px-4 py-10 text-center'\n\n/**\n * Renders the branch the state is actually in.\n *\n * The three anti-patterns this replaces (`catch` that only clears a loading\n * flag, early return on a non-ok response, bare `null` while loading) all end at\n * the same rendered output as a successful-but-empty load. Here every branch is\n * reached from a different variant and each renders visibly: `loading` and\n * `idle` render a labelled busy block, `error` renders the message plus the\n * retry, `empty` renders the caller's copy and next action, and `ready` is the\n * only branch with a value to hand to `children`.\n */\nexport function AsyncView<T>({\n state,\n children,\n empty,\n renderLoading,\n renderError,\n renderIdle,\n loadingLabel = 'Loading…',\n retryLabel = 'Retry',\n className,\n}: AsyncViewProps<T>): ReactElement {\n if (state.status === 'ready') return <>{children(state.value)}</>\n\n // Every `??` here is the guarantee: a custom renderer that returns nothing\n // leaves the reader with the built-in block, never a blank region.\n const branch = (): ReactNode => {\n switch (state.status) {\n case 'idle':\n return renderIdle?.() ?? <LoadingBlock label={loadingLabel} />\n case 'loading':\n return renderLoading?.() ?? <LoadingBlock label={loadingLabel} />\n case 'error':\n return (\n renderError?.({ message: state.message, retry: state.retry }) ?? (\n <ErrorBlock message={state.message} retry={state.retry} retryLabel={retryLabel} />\n )\n )\n case 'empty':\n if (isValidElement(empty)) return empty\n return typeof empty === 'object' && empty !== null && typeof empty.title === 'string' ? (\n <EmptyBlock spec={empty} />\n ) : (\n <EmptyBlock spec={{ title: 'Nothing here yet.' }} />\n )\n }\n }\n\n return (\n <div data-async-state={state.status} className={className}>\n {branch()}\n </div>\n )\n}\n\nfunction LoadingBlock({ label }: { label: string }): ReactElement {\n return (\n <div role=\"status\" aria-live=\"polite\" aria-busy=\"true\" className={BLOCK_CLASS}>\n <span\n className=\"h-4 w-4 animate-spin rounded-full border-2 border-border border-t-transparent\"\n aria-hidden=\"true\"\n />\n <span className=\"text-sm text-muted-foreground\">{label}</span>\n </div>\n )\n}\n\nfunction ErrorBlock({\n message,\n retry,\n retryLabel,\n}: {\n message: string\n retry: () => void\n retryLabel: string\n}): ReactElement {\n return (\n <div role=\"alert\" className={BLOCK_CLASS}>\n <p className=\"max-w-md text-sm text-muted-foreground\">{message}</p>\n <button\n type=\"button\"\n onClick={retry}\n className=\"h-8 rounded-md border border-border px-3 text-xs font-medium text-foreground transition hover:bg-accent/30\"\n >\n {retryLabel}\n </button>\n </div>\n )\n}\n\nfunction EmptyBlock({ spec }: { spec: AsyncEmptySpec }): ReactElement {\n return (\n <div className={BLOCK_CLASS}>\n <p className=\"text-sm font-medium text-foreground\">{spec.title}</p>\n {spec.description ? <p className=\"max-w-md text-sm text-muted-foreground\">{spec.description}</p> : null}\n {spec.action ? (\n isValidElement(spec.action) ? (\n spec.action\n ) : (\n <button\n type=\"button\"\n onClick={(spec.action as AsyncEmptyAction).onClick}\n className=\"h-8 rounded-md border border-border px-3 text-xs font-medium text-foreground transition hover:bg-accent/30\"\n >\n {(spec.action as AsyncEmptyAction).label}\n </button>\n )\n ) : null}\n </div>\n )\n}\n\nexport interface MutationStatusLabels {\n pending?: string\n succeeded?: string\n}\n\nexport interface MutationStatusProps<T> {\n state: MutationState<T>\n labels?: MutationStatusLabels\n className?: string\n}\n\n/**\n * The write's own status line. \"Saved\" renders only from `succeeded`, which\n * `useConfirmedMutation` can only reach through a confirmed write, so the label\n * cannot appear over a failed request.\n */\nexport function MutationStatus<T>({ state, labels, className }: MutationStatusProps<T>): ReactElement | null {\n if (state.status === 'idle') return null\n if (state.status === 'pending') {\n return (\n <span role=\"status\" aria-live=\"polite\" className={className ?? 'text-xs text-muted-foreground'}>\n {labels?.pending ?? 'Saving…'}\n </span>\n )\n }\n if (state.status === 'succeeded') {\n return (\n <span role=\"status\" aria-live=\"polite\" className={className ?? 'text-xs text-muted-foreground'}>\n {labels?.succeeded ?? 'Saved'}\n </span>\n )\n }\n return (\n <span role=\"alert\" className={className ?? 'text-xs text-destructive'}>\n {state.message}\n </span>\n )\n}\n"],"mappings":";AAmDO,IAAM,8BAA8B;AASpC,SAAS,eAAe,OAAyB;AACtD,MAAI,UAAU,QAAQ,UAAU,OAAW,QAAO;AAClD,MAAI,MAAM,QAAQ,KAAK,EAAG,QAAO,MAAM,WAAW;AAClD,MAAI,iBAAiB,OAAO,iBAAiB,IAAK,QAAO,MAAM,SAAS;AACxE,SAAO;AACT;AAEA,SAAS,WAAW,OAA8C;AAChE,SAAO,aAAa;AACtB;AAIO,SAAS,kBAAkB,OAAgB,WAAmB,6BAAqC;AACxG,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,MAAM,GAAI,QAAO;AAC7D,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,WAAW,KAAK,GAAG;AACpE,UAAM,UAAU,MAAM;AACtB,QAAI,OAAO,YAAY,YAAY,QAAQ,KAAK,MAAM,GAAI,QAAO;AAAA,EACnE;AACA,SAAO;AACT;AAGO,SAAS,kBAAqB,OAAU,UAAiC,gBAAoC;AAClH,SAAO,QAAQ,KAAK,IAAI,EAAE,QAAQ,SAAS,MAAM,IAAI,EAAE,QAAQ,SAAS,MAAM;AAChF;AAOO,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA,EAGA;AAAA,EAET,YAAY,UAAiE,OAAO,IAAI;AACtF,UAAM,aAAa,SAAS,cAAc;AAC1C,UAAM,mBAAmB,SAAS,MAAM,GAAG,aAAa,IAAI,UAAU,KAAK,EAAE,GAAG;AAChF,SAAK,OAAO;AACZ,SAAK,SAAS,SAAS;AACvB,SAAK,aAAa;AAClB,SAAK,MAAM,SAAS,OAAO;AAC3B,SAAK,OAAO;AAAA,EACd;AACF;AAEA,eAAe,gBAAgB,UAAqC;AAClE,MAAI;AACF,YAAQ,MAAM,SAAS,KAAK,GAAG,MAAM,GAAG,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AAQ,WAAW,gBACtB;AAAA,EAEJ;AACA,MAAI,MAAM,WAAW,aAAa;AAChC,WACE,oBAAC,UAAK,MAAK,UAAS,aAAU,UAAS,WAAW,aAAa,iCAC5D,kBAAQ,aAAa,SACxB;AAAA,EAEJ;AACA,SACE,oBAAC,UAAK,MAAK,SAAQ,WAAW,aAAa,4BACxC,gBAAM,SACT;AAEJ;","names":["useCallback","useMemo","useRef","useState","useRef","useState","useCallback","useMemo"]}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -372,15 +372,82 @@ interface ComposerFile {
|
|
|
372
372
|
* `status: 'ready'` files with a part travel on a parts-aware send. */
|
|
373
373
|
part?: ComposerFilePart;
|
|
374
374
|
}
|
|
375
|
+
/** A send the host refused. `error` is shown verbatim in the composer's notice;
|
|
376
|
+
* omit it for the generic copy. */
|
|
377
|
+
interface ComposerSendRejected {
|
|
378
|
+
ok: false;
|
|
379
|
+
error?: string;
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* What a send handler reports back. `void` — what every handler returned before
|
|
383
|
+
* this existed — reads as accepted, so wiring stays unchanged; a thrown error, a
|
|
384
|
+
* rejected promise, or `{ ok: false }` is the rejection that restores the draft.
|
|
385
|
+
* A handler that resolves only when the whole turn finishes still reports
|
|
386
|
+
* correctly: the input already cleared on dispatch, so the answer only decides
|
|
387
|
+
* whether the draft comes back.
|
|
388
|
+
*/
|
|
389
|
+
type ComposerSendOutcome = void | {
|
|
390
|
+
ok: true;
|
|
391
|
+
} | ComposerSendRejected;
|
|
392
|
+
type ComposerSendResult = ComposerSendOutcome | Promise<ComposerSendOutcome>;
|
|
393
|
+
/**
|
|
394
|
+
* A send handler, typed as a UNION with the legacy `=> void` signature rather
|
|
395
|
+
* than as `(…) => ComposerSendResult` alone.
|
|
396
|
+
*
|
|
397
|
+
* TypeScript's return-type-`void` rule accepts a function returning ANYTHING
|
|
398
|
+
* where a `=> void` is expected, and that rule fires only when the target's
|
|
399
|
+
* return type is exactly `void` — not when it is a union that contains `void`.
|
|
400
|
+
* So narrowing this prop to `ComposerSendResult` would reject handler shapes
|
|
401
|
+
* that compiled against the shipped `onSend?: (message: string) => void`:
|
|
402
|
+
* `onSend={(m) => rows.push(m)}` (returns `number`) and
|
|
403
|
+
* `onSend={(m) => append({ role: 'user', content: m })}` (an ai-sdk append
|
|
404
|
+
* returns `Promise<string | null | undefined>`) both stop compiling, on a
|
|
405
|
+
* package whose pinned consumers must never need a source edit to take a minor.
|
|
406
|
+
*
|
|
407
|
+
* The union keeps both: a legacy handler lands on the first member, and a
|
|
408
|
+
* handler that reports an outcome lands on the second. A call through it
|
|
409
|
+
* resolves to `void | ComposerSendResult`, which IS `ComposerSendResult`, so
|
|
410
|
+
* the composer reads the outcome exactly as before.
|
|
411
|
+
*/
|
|
412
|
+
type ComposerSendHandler = ((message: string) => void) | ((message: string) => ComposerSendResult);
|
|
413
|
+
/** @see ComposerSendHandler — the parts-aware arity, same union for the same reason. */
|
|
414
|
+
type ComposerSendPartsHandler = ((message: string, parts: ComposerFilePart[]) => void) | ((message: string, parts: ComposerFilePart[]) => ComposerSendResult);
|
|
415
|
+
/** The rejected send, handed to `onSendFailed` so the host can undo whatever it
|
|
416
|
+
* cleared optimistically — most importantly the staged attachments, which the
|
|
417
|
+
* composer does not own (`pendingFiles` is a prop). */
|
|
418
|
+
interface ComposerSendFailure {
|
|
419
|
+
/** The reason as the composer renders it. */
|
|
420
|
+
message: string;
|
|
421
|
+
/** The user's exact draft, untrimmed. */
|
|
422
|
+
text: string;
|
|
423
|
+
/** The parts the rejected send carried. */
|
|
424
|
+
parts: ComposerFilePart[];
|
|
425
|
+
/** Whatever the handler threw / rejected with, or the `{ ok: false }` value. */
|
|
426
|
+
error: unknown;
|
|
427
|
+
/** True when the draft was put back in the textarea (the box was empty).
|
|
428
|
+
* False means the user had typed a replacement, so the unsent text is held in
|
|
429
|
+
* the notice instead. */
|
|
430
|
+
restored: boolean;
|
|
431
|
+
}
|
|
375
432
|
interface ChatComposerProps {
|
|
376
433
|
/** Send the trimmed, non-empty message. Attached files travel separately via
|
|
377
434
|
* `onAttach` + `pendingFiles` (the host consumes and clears them on send).
|
|
378
|
-
* Optional when `onSendParts` is wired.
|
|
379
|
-
|
|
435
|
+
* Optional when `onSendParts` is wired.
|
|
436
|
+
*
|
|
437
|
+
* Report a refused send by throwing, rejecting, or returning `{ ok: false }`
|
|
438
|
+
* — the composer restores the draft rather than losing it. */
|
|
439
|
+
onSend?: ComposerSendHandler;
|
|
380
440
|
/** Parts-aware send: receives the trimmed message plus the `part`
|
|
381
441
|
* descriptors of every `ready` pending file. Takes precedence over
|
|
382
|
-
* `onSend`; enables file-only sends (empty text, ≥1 ready part).
|
|
383
|
-
|
|
442
|
+
* `onSend`; enables file-only sends (empty text, ≥1 ready part).
|
|
443
|
+
*
|
|
444
|
+
* Same rejection contract as `onSend`. */
|
|
445
|
+
onSendParts?: ComposerSendPartsHandler;
|
|
446
|
+
/** Notified when a send is rejected, after the composer has restored what it
|
|
447
|
+
* owns. The host uses it to put back the `pendingFiles` it consumed. */
|
|
448
|
+
onSendFailed?: (failure: ComposerSendFailure) => void;
|
|
449
|
+
/** Notice copy when the handler names no reason of its own. */
|
|
450
|
+
sendFailureMessage?: string;
|
|
384
451
|
/** Stop the in-flight turn; shown in place of Send while `isStreaming`. */
|
|
385
452
|
onCancel?: () => void;
|
|
386
453
|
isStreaming?: boolean;
|
|
@@ -425,7 +492,7 @@ interface ChatComposerProps {
|
|
|
425
492
|
sendLabel?: string;
|
|
426
493
|
className?: string;
|
|
427
494
|
}
|
|
428
|
-
declare function ChatComposer({ onSend, onSendParts, onCancel, isStreaming, disabled, placeholder, value, onValueChange, initialValue, seed, onSeedApplied, controls, controlsPlacement, onAttach, onAttachFolder, pendingFiles, onRemoveFile, accept, dropTitle, dropDescription, focusShortcut, sendLabel, className, }: ChatComposerProps): react.JSX.Element;
|
|
495
|
+
declare function ChatComposer({ onSend, onSendParts, onSendFailed, sendFailureMessage, onCancel, isStreaming, disabled, placeholder, value, onValueChange, initialValue, seed, onSeedApplied, controls, controlsPlacement, onAttach, onAttachFolder, pendingFiles, onRemoveFile, accept, dropTitle, dropDescription, focusShortcut, sendLabel, className, }: ChatComposerProps): react.JSX.Element;
|
|
429
496
|
|
|
430
497
|
type InteractionBadgeVariant = 'outline' | 'default' | 'destructive';
|
|
431
498
|
declare function InteractionBadge({ variant, children }: {
|
|
@@ -2156,4 +2223,4 @@ declare function useThinkingSeconds(active: boolean): number;
|
|
|
2156
2223
|
*/
|
|
2157
2224
|
declare function ChatMessages({ messages, messageSize, models, renderMarkdown, renderExtras, durableCards, userLabel, agentLabel, loading, approval, onToolCallClick, toolRenderers, error, onRetry, renderEmpty, emptyState, header, resolveAttachmentUrl, workProductCards, }: ChatMessagesProps): react.JSX.Element;
|
|
2158
2225
|
|
|
2159
|
-
export { type ActivityTone, type AgentActivityPage, AgentActivityPanel, type AgentActivityPanelProps, type AgentActivityRecord, AgentSessionControls, type AgentSessionControlsProps, type AttachmentFileResult, CatalogModel, ChatAttachmentInput, ChatAttachmentKind, ChatAttachmentPart, ChatComposer, type ChatComposerProps, type ChatEmptyDoor, ChatEmptyState, type ChatEmptyStateProps, ChatInteraction, ChatInteractionField, type ChatInteractionRestoreMode, ChatInteractionStatus, ChatMentionPart, type ChatMessageMetrics, type ChatMessageSegment, ChatMessages, type ChatMessagesProps, ChatSelectField, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ComposerFile, type ComposerFilePart, type ConsumeChatStreamResult, DEFAULT_EFFORT_LEVELS, DEFAULT_PROVENANCE_CONFIDENCE_POLICY, type DurableChatCard, DurableChatCards, type DurableChatCardsProps, type DurableInteractionAnswerSubmitterOptions, DurablePlanCard, type DurablePlanCardProps, DurablePlanClientError, type DurablePlanCurrentInput, type DurablePlanDecision, type DurablePlanDecisionClient, type DurablePlanDecisionClientOptions, type DurablePlanDecisionInput, type DurablePlanDecisionResult, type DurablePlanFollowUpReceipt, EMPTY_RECORD_GRID_OVERLAY, type EffortLevel, EffortPicker, type EffortPickerProps, EvidenceLineageTable, type EvidenceLineageTableProps, ExceptionList, type ExceptionListProps, type FetchSessionPage, type FieldValues, FlowWaterfall, type FlowWaterfallProps, INTERACTION_SUBMIT_TIMEOUT_MESSAGE, INTERACTION_SUBMIT_TIMEOUT_MS, InteractionActionButton, type InteractionAnswerSubmission, type InteractionAnswerSubmitterOptions, InteractionAnswers, type InteractionAttemptStore, InteractionBadge, type InteractionBadgeVariant, InteractionCancelData, InteractionPlanCard, type InteractionPlanCardProps, InteractionQuestionCard, type InteractionQuestionCardProps, InteractionRequestWire, type InteractionSubmitResult, type LinkLikeComponent, type LinkLikeProps, type MentionTextSegment, MessageAttachments, type MessageAttachmentsProps, MissionActivityLane, type MissionActivityLaneProps, ModelPicker, type ModelPickerProps, PROVENANCE_BASES, type ProposalApprovalHandlers, type ProvenanceBasis, type ProvenanceBasisMeta, type ProvenanceConfidencePolicy, type ProvenanceGap, type ProvenanceGapKind, ProvenanceLegend, type ProvenanceLegendProps, type ProvenanceRecord, type ProvenanceSource, type ProvenanceSourceStatus, ProvenanceStamp, type ProvenanceStampProps, type ProvenanceStanding, type ProvenanceStandingMeta, ProvenanceValue, type ProvenanceValueProps, ProviderLogo, type ProviderLogoProps, QualityCheckList, type QualityCheckListProps, QuestionOptionList, type QuestionOptionListProps, RecordGrid, type RecordGridBooleanColumn, type RecordGridCellChange, type RecordGridCellOutcome, type RecordGridCellSource, type RecordGridColumn, type RecordGridColumnBase, type RecordGridCreateOutcome, type RecordGridCurrencyColumn, type RecordGridDateColumn, type RecordGridDependency, type RecordGridEmptyState, type RecordGridNumberColumn, type RecordGridOverlay, type RecordGridProps, type RecordGridRow, type RecordGridRowOutcome, type RecordGridSelectColumn, type RecordGridSelectOption, type RecordGridSourceBasis, type RecordGridState, type RecordGridTextColumn, type RecordGridValue, type RecordGridWriteOutcome, type RestoreChatInteractionsOptions, ReviewQueueItem, type ReviewQueuePage, ReviewQueuePanel, type ReviewQueuePanelProps, ReviewQueueState, RunDrillIn, type RunDrillInProps, SeatPaywall, type SeatPaywallProps, type SessionActionLabels, type SessionActions, type SessionActionsOptions, type SessionBulkAction, SessionHistoryPanel, type SessionHistoryPanelProps, type SessionHistoryState, type SessionPageQuery, type SmoothRevealOptions, type StreamChatOptions, type SubmitInteractionAnswer, type ToolDetailRenderers, type ToolRunRecord, type ToolRunStep, type UseChatInteractionsOptions, type UseChatInteractionsResult, type UseComposerAttachmentsOptions, type UseComposerAttachmentsResult, type UseDurablePlanFlowOptions, type UseDurablePlanFlowResult, type UseInfiniteScrollOptions, type UseSessionHistoryOptions, type WaterfallRow, WorkProductCard, type WorkProductCardProps, __resetAttachmentFileCacheForTests, activityTone, buildAnswerData, cancelChatInteraction, consumeChatStream, createDurableInteractionAnswerSubmitter, createDurablePlanDecisionClient, createInteractionAnswerSubmitter, createMemoryInteractionAttemptStore, createSessionInteractionAttemptStore, describeProvenance, describeProvenanceSourceStatus, dispatchChatStreamLine, durableChatCardsFromParts, fieldAnswer, fieldValuesFromAnswers, formatActivityCost, formatActivityDuration, formatModelCost, formatRecordGridValue, formatSessionTimestamp, formatTokensPerSecond, hasSecretField, hydrateChatInteractions, interactionStatusLabels, interactionSubmissionSignature, interactionTerminalNotes, isLateAnswerableStatus, isRecordGridCellApplicable, lateAnswerMessage, loadAttachmentFile, loadingProvenanceSources, mergeActivityPages, mergeReviewQueuePages, nextRevealCount, parseRecordGridInput, pendingApprovalOf, projectRecordGridRows, provenanceBasisMeta, provenanceGaps, provenanceNextMove, provenanceStandingMeta, provenanceTriggerLabel, pruneRecordGridOverlay, readRecordGridCell, recordGridEditorText, recordGridFail, recordGridOk, recordGridRowLabel, resolveChatInteraction, resolveProvenanceStanding, responseErrorMessage, restoreChatInteractions, reviewQueueStateLabel, rollUpProvenanceStanding, sameRecordGridValue, segmentMentionContent, settleInteractionSubmit, standingFromConfidence, streamChatTurn, sumRecordGridColumn, terminalizePendingChatInteractions, triggerAttachmentDownload, upsertChatInteraction, useChatInteractions, useComposerAttachments, useDurablePlanFlow, useInfiniteScroll, usePending, usePopover, useSessionActions, useSessionHistory, useSmoothText, useThinkingSeconds, validateRecordGridCell, validateRecordGridRow, waterfallLayout, weakerProvenanceStanding, withRecordGridCreated, withRecordGridRemoved, withRecordGridServerRow, withRecordGridUpdate, withoutRecordGridCreated, withoutRecordGridRemoved, withoutRecordGridUpdate, workProductPartsFromMessageParts, workProductStatusLabel };
|
|
2226
|
+
export { type ActivityTone, type AgentActivityPage, AgentActivityPanel, type AgentActivityPanelProps, type AgentActivityRecord, AgentSessionControls, type AgentSessionControlsProps, type AttachmentFileResult, CatalogModel, ChatAttachmentInput, ChatAttachmentKind, ChatAttachmentPart, ChatComposer, type ChatComposerProps, type ChatEmptyDoor, ChatEmptyState, type ChatEmptyStateProps, ChatInteraction, ChatInteractionField, type ChatInteractionRestoreMode, ChatInteractionStatus, ChatMentionPart, type ChatMessageMetrics, type ChatMessageSegment, ChatMessages, type ChatMessagesProps, ChatSelectField, type ChatStreamCallbacks, type ChatStreamToolCall, type ChatStreamToolResult, type ChatToolCallInfo, type ChatUiMessage, type ComposerFile, type ComposerFilePart, type ComposerSendFailure, type ComposerSendHandler, type ComposerSendOutcome, type ComposerSendPartsHandler, type ComposerSendRejected, type ComposerSendResult, type ConsumeChatStreamResult, DEFAULT_EFFORT_LEVELS, DEFAULT_PROVENANCE_CONFIDENCE_POLICY, type DurableChatCard, DurableChatCards, type DurableChatCardsProps, type DurableInteractionAnswerSubmitterOptions, DurablePlanCard, type DurablePlanCardProps, DurablePlanClientError, type DurablePlanCurrentInput, type DurablePlanDecision, type DurablePlanDecisionClient, type DurablePlanDecisionClientOptions, type DurablePlanDecisionInput, type DurablePlanDecisionResult, type DurablePlanFollowUpReceipt, EMPTY_RECORD_GRID_OVERLAY, type EffortLevel, EffortPicker, type EffortPickerProps, EvidenceLineageTable, type EvidenceLineageTableProps, ExceptionList, type ExceptionListProps, type FetchSessionPage, type FieldValues, FlowWaterfall, type FlowWaterfallProps, INTERACTION_SUBMIT_TIMEOUT_MESSAGE, INTERACTION_SUBMIT_TIMEOUT_MS, InteractionActionButton, type InteractionAnswerSubmission, type InteractionAnswerSubmitterOptions, InteractionAnswers, type InteractionAttemptStore, InteractionBadge, type InteractionBadgeVariant, InteractionCancelData, InteractionPlanCard, type InteractionPlanCardProps, InteractionQuestionCard, type InteractionQuestionCardProps, InteractionRequestWire, type InteractionSubmitResult, type LinkLikeComponent, type LinkLikeProps, type MentionTextSegment, MessageAttachments, type MessageAttachmentsProps, MissionActivityLane, type MissionActivityLaneProps, ModelPicker, type ModelPickerProps, PROVENANCE_BASES, type ProposalApprovalHandlers, type ProvenanceBasis, type ProvenanceBasisMeta, type ProvenanceConfidencePolicy, type ProvenanceGap, type ProvenanceGapKind, ProvenanceLegend, type ProvenanceLegendProps, type ProvenanceRecord, type ProvenanceSource, type ProvenanceSourceStatus, ProvenanceStamp, type ProvenanceStampProps, type ProvenanceStanding, type ProvenanceStandingMeta, ProvenanceValue, type ProvenanceValueProps, ProviderLogo, type ProviderLogoProps, QualityCheckList, type QualityCheckListProps, QuestionOptionList, type QuestionOptionListProps, RecordGrid, type RecordGridBooleanColumn, type RecordGridCellChange, type RecordGridCellOutcome, type RecordGridCellSource, type RecordGridColumn, type RecordGridColumnBase, type RecordGridCreateOutcome, type RecordGridCurrencyColumn, type RecordGridDateColumn, type RecordGridDependency, type RecordGridEmptyState, type RecordGridNumberColumn, type RecordGridOverlay, type RecordGridProps, type RecordGridRow, type RecordGridRowOutcome, type RecordGridSelectColumn, type RecordGridSelectOption, type RecordGridSourceBasis, type RecordGridState, type RecordGridTextColumn, type RecordGridValue, type RecordGridWriteOutcome, type RestoreChatInteractionsOptions, ReviewQueueItem, type ReviewQueuePage, ReviewQueuePanel, type ReviewQueuePanelProps, ReviewQueueState, RunDrillIn, type RunDrillInProps, SeatPaywall, type SeatPaywallProps, type SessionActionLabels, type SessionActions, type SessionActionsOptions, type SessionBulkAction, SessionHistoryPanel, type SessionHistoryPanelProps, type SessionHistoryState, type SessionPageQuery, type SmoothRevealOptions, type StreamChatOptions, type SubmitInteractionAnswer, type ToolDetailRenderers, type ToolRunRecord, type ToolRunStep, type UseChatInteractionsOptions, type UseChatInteractionsResult, type UseComposerAttachmentsOptions, type UseComposerAttachmentsResult, type UseDurablePlanFlowOptions, type UseDurablePlanFlowResult, type UseInfiniteScrollOptions, type UseSessionHistoryOptions, type WaterfallRow, WorkProductCard, type WorkProductCardProps, __resetAttachmentFileCacheForTests, activityTone, buildAnswerData, cancelChatInteraction, consumeChatStream, createDurableInteractionAnswerSubmitter, createDurablePlanDecisionClient, createInteractionAnswerSubmitter, createMemoryInteractionAttemptStore, createSessionInteractionAttemptStore, describeProvenance, describeProvenanceSourceStatus, dispatchChatStreamLine, durableChatCardsFromParts, fieldAnswer, fieldValuesFromAnswers, formatActivityCost, formatActivityDuration, formatModelCost, formatRecordGridValue, formatSessionTimestamp, formatTokensPerSecond, hasSecretField, hydrateChatInteractions, interactionStatusLabels, interactionSubmissionSignature, interactionTerminalNotes, isLateAnswerableStatus, isRecordGridCellApplicable, lateAnswerMessage, loadAttachmentFile, loadingProvenanceSources, mergeActivityPages, mergeReviewQueuePages, nextRevealCount, parseRecordGridInput, pendingApprovalOf, projectRecordGridRows, provenanceBasisMeta, provenanceGaps, provenanceNextMove, provenanceStandingMeta, provenanceTriggerLabel, pruneRecordGridOverlay, readRecordGridCell, recordGridEditorText, recordGridFail, recordGridOk, recordGridRowLabel, resolveChatInteraction, resolveProvenanceStanding, responseErrorMessage, restoreChatInteractions, reviewQueueStateLabel, rollUpProvenanceStanding, sameRecordGridValue, segmentMentionContent, settleInteractionSubmit, standingFromConfidence, streamChatTurn, sumRecordGridColumn, terminalizePendingChatInteractions, triggerAttachmentDownload, upsertChatInteraction, useChatInteractions, useComposerAttachments, useDurablePlanFlow, useInfiniteScroll, usePending, usePopover, useSessionActions, useSessionHistory, useSmoothText, useThinkingSeconds, validateRecordGridCell, validateRecordGridRow, waterfallLayout, weakerProvenanceStanding, withRecordGridCreated, withRecordGridRemoved, withRecordGridServerRow, withRecordGridUpdate, withoutRecordGridCreated, withoutRecordGridRemoved, withoutRecordGridUpdate, workProductPartsFromMessageParts, workProductStatusLabel };
|
package/dist/web-react/index.js
CHANGED
|
@@ -117,7 +117,7 @@ import {
|
|
|
117
117
|
withoutRecordGridCreated,
|
|
118
118
|
withoutRecordGridRemoved,
|
|
119
119
|
withoutRecordGridUpdate
|
|
120
|
-
} from "../chunk-
|
|
120
|
+
} from "../chunk-KOMP6NDW.js";
|
|
121
121
|
import "../chunk-FBVLEGEG.js";
|
|
122
122
|
import {
|
|
123
123
|
useComposerAttachments
|
|
@@ -138,7 +138,7 @@ import {
|
|
|
138
138
|
reviewQueueStateLabel,
|
|
139
139
|
workProductPartsFromMessageParts,
|
|
140
140
|
workProductStatusLabel
|
|
141
|
-
} from "../chunk-
|
|
141
|
+
} from "../chunk-HZ4WCA37.js";
|
|
142
142
|
import {
|
|
143
143
|
parseReviewQueueItem
|
|
144
144
|
} from "../chunk-GEYACSFW.js";
|
package/package.json
CHANGED