@opengeni/react 0.20.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-6BXBGJ3B.js → chunk-6XUS5VFM.js} +2 -2
- package/dist/{chunk-LAZ2A743.js → chunk-CATATY77.js} +3 -3
- package/dist/{chunk-HHFA4AFX.js → chunk-I3BJZIG5.js} +15 -1
- package/dist/chunk-I3BJZIG5.js.map +1 -0
- package/dist/{chunk-6UT5OC3P.js → chunk-UAHPKLB6.js} +113 -9
- package/dist/chunk-UAHPKLB6.js.map +1 -0
- package/dist/{chunk-MRSECXRP.js → chunk-UQS7OQDE.js} +82 -54
- package/dist/chunk-UQS7OQDE.js.map +1 -0
- package/dist/{chunk-EBTT3MYN.js → chunk-YDNWMKXO.js} +11 -1
- package/dist/chunk-YDNWMKXO.js.map +1 -0
- package/dist/{composer-DvUaa5ki.d.ts → composer-CVm5uoUI.d.ts} +2 -2
- package/dist/composer.d.ts +3 -3
- package/dist/composer.js +3 -3
- package/dist/index.d.ts +8 -8
- package/dist/index.js +140 -26
- package/dist/index.js.map +1 -1
- package/dist/machines.d.ts +1 -1
- package/dist/machines.js +2 -2
- package/dist/{queue-surface-implementation-NQMV2ML3.js → queue-surface-implementation-3UW3MIIR.js} +9 -9
- package/dist/queue-surface-implementation-3UW3MIIR.js.map +1 -0
- package/dist/{session-Gd4iVPYw.d.ts → session-Db00TRwl.d.ts} +32 -11
- package/dist/{session-context-DIFFlXKc.d.ts → session-context-rgrfElMl.d.ts} +7 -1
- package/dist/session.d.ts +3 -3
- package/dist/session.js +7 -3
- package/dist/{use-composer-BCfm4mzX.d.ts → use-composer-By1wn3MM.d.ts} +5 -18
- package/package.json +2 -2
- package/src/client.ts +4 -0
- package/src/components/message-timeline.tsx +195 -23
- package/src/components/queue-draft-policy.ts +18 -0
- package/src/components/queue-surface-implementation.tsx +6 -10
- package/src/components/queue-surface.tsx +1 -0
- package/src/hooks/use-composer.ts +128 -78
- package/src/hooks/use-session-mcp-approval-policy.ts +161 -0
- package/src/index.ts +9 -0
- package/src/session-context.ts +25 -0
- package/src/session.ts +10 -0
- package/src/timeline/types.ts +8 -15
- package/dist/chunk-6UT5OC3P.js.map +0 -1
- package/dist/chunk-EBTT3MYN.js.map +0 -1
- package/dist/chunk-HHFA4AFX.js.map +0 -1
- package/dist/chunk-MRSECXRP.js.map +0 -1
- package/dist/queue-surface-implementation-NQMV2ML3.js.map +0 -1
- /package/dist/{chunk-6BXBGJ3B.js.map → chunk-6XUS5VFM.js.map} +0 -0
- /package/dist/{chunk-LAZ2A743.js.map → chunk-CATATY77.js.map} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useEmbeddedSession,
|
|
3
3
|
useSessionEventTrigger
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-I3BJZIG5.js";
|
|
5
5
|
|
|
6
6
|
// src/hooks/use-composer.ts
|
|
7
7
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -21,31 +21,30 @@ function useComposer(sessionId, options = {}) {
|
|
|
21
21
|
const [draftConflict, setDraftConflict] = useState(null);
|
|
22
22
|
const [restoredResources, setRestoredResources] = useState([]);
|
|
23
23
|
const pendingClientEventId = useRef(null);
|
|
24
|
+
const valueRef = useRef("");
|
|
24
25
|
const draftRef = useRef(null);
|
|
25
|
-
const
|
|
26
|
-
const draftReadGeneration = useRef(0);
|
|
26
|
+
const restoredResourcesRef = useRef([]);
|
|
27
27
|
const localEditRevision = useRef(0);
|
|
28
28
|
const targetGeneration = useRef(0);
|
|
29
|
+
const draftReadGeneration = useRef(0);
|
|
29
30
|
const lastSavedSignature = useRef(null);
|
|
30
31
|
const saveChain = useRef(Promise.resolve());
|
|
31
32
|
const onSent = options.onSent;
|
|
32
33
|
const onDraftApplied = options.onDraftApplied;
|
|
33
34
|
const sendExtrasRef = useRef(options.sendExtras);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}, [options.sendExtras]);
|
|
37
|
-
const liveExtras = resolveSendExtras(options.sendExtras);
|
|
38
|
-
const liveExtrasVersion = JSON.stringify(liveExtras);
|
|
35
|
+
sendExtrasRef.current = options.sendExtras;
|
|
36
|
+
const liveExtrasVersion = JSON.stringify(resolveSendExtras(options.sendExtras));
|
|
39
37
|
const targetKeyRef = useRef(targetKey);
|
|
40
38
|
useLayoutEffect(() => {
|
|
41
39
|
if (targetKeyRef.current === targetKey) return;
|
|
42
40
|
targetKeyRef.current = targetKey;
|
|
43
41
|
targetGeneration.current += 1;
|
|
42
|
+
draftReadGeneration.current += 1;
|
|
44
43
|
pendingClientEventId.current = null;
|
|
45
44
|
localEditRevision.current = 0;
|
|
46
|
-
|
|
45
|
+
valueRef.current = "";
|
|
47
46
|
draftRef.current = null;
|
|
48
|
-
|
|
47
|
+
restoredResourcesRef.current = [];
|
|
49
48
|
lastSavedSignature.current = null;
|
|
50
49
|
saveChain.current = Promise.resolve();
|
|
51
50
|
setStateTargetKey(targetKey);
|
|
@@ -66,6 +65,8 @@ function useComposer(sessionId, options = {}) {
|
|
|
66
65
|
if (!durableDrafts) {
|
|
67
66
|
pendingClientEventId.current = null;
|
|
68
67
|
localEditRevision.current += 1;
|
|
68
|
+
valueRef.current = next.text;
|
|
69
|
+
restoredResourcesRef.current = next.resources;
|
|
69
70
|
draftRef.current = null;
|
|
70
71
|
lastSavedSignature.current = null;
|
|
71
72
|
setDraft(null);
|
|
@@ -74,7 +75,9 @@ function useComposer(sessionId, options = {}) {
|
|
|
74
75
|
setDraftConflict(null);
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
78
|
+
valueRef.current = next.text;
|
|
77
79
|
draftRef.current = next;
|
|
80
|
+
restoredResourcesRef.current = next.resources;
|
|
78
81
|
lastSavedSignature.current = draftSignature(draftPayload(next));
|
|
79
82
|
localEditRevision.current += 1;
|
|
80
83
|
pendingClientEventId.current = null;
|
|
@@ -87,7 +90,7 @@ function useComposer(sessionId, options = {}) {
|
|
|
87
90
|
[durableDrafts, onDraftApplied, targetKey]
|
|
88
91
|
);
|
|
89
92
|
const loadDraft = useCallback(
|
|
90
|
-
async (replaceLocal
|
|
93
|
+
async (replaceLocal) => {
|
|
91
94
|
if (targetKeyRef.current !== targetKey) return;
|
|
92
95
|
if (!sessionId || !durableDrafts) {
|
|
93
96
|
setDraftLoading(false);
|
|
@@ -96,43 +99,41 @@ function useComposer(sessionId, options = {}) {
|
|
|
96
99
|
const generation = targetGeneration.current;
|
|
97
100
|
const readTicket = ++draftReadGeneration.current;
|
|
98
101
|
const localAtStart = localEditRevision.current;
|
|
102
|
+
const baseAtStart = draftRef.current;
|
|
103
|
+
const extrasAtStart = resolveSendExtras(sendExtrasRef.current);
|
|
104
|
+
const localSignatureAtStart = baseAtStart ? draftSignature(
|
|
105
|
+
composerDraftPayload(
|
|
106
|
+
baseAtStart,
|
|
107
|
+
valueRef.current,
|
|
108
|
+
restoredResourcesRef.current,
|
|
109
|
+
extrasAtStart
|
|
110
|
+
)
|
|
111
|
+
) : null;
|
|
112
|
+
const localWasDirtyAtStart = localSignatureAtStart === null ? localAtStart !== 0 : localSignatureAtStart !== lastSavedSignature.current;
|
|
99
113
|
setDraftLoading(true);
|
|
100
114
|
try {
|
|
101
115
|
const fetched = await client.getComposerDraft(workspaceId, sessionId);
|
|
102
|
-
if (generation !== targetGeneration.current || targetKeyRef.current !== targetKey) {
|
|
116
|
+
if (generation !== targetGeneration.current || targetKeyRef.current !== targetKey || readTicket !== draftReadGeneration.current) {
|
|
103
117
|
return;
|
|
104
118
|
}
|
|
105
|
-
const ownsLatestRead = readTicket === draftReadGeneration.current;
|
|
106
119
|
const currentRevision = draftRef.current?.revision ?? -1;
|
|
107
|
-
if (
|
|
120
|
+
if (fetched.revision >= currentRevision) {
|
|
108
121
|
draftRef.current = fetched;
|
|
109
122
|
setDraft(fetched);
|
|
110
123
|
setDraftConflict(null);
|
|
111
|
-
if (replaceLocal || localAtStart === localEditRevision.current) {
|
|
124
|
+
if (replaceLocal || !localWasDirtyAtStart && localAtStart === localEditRevision.current) {
|
|
125
|
+
valueRef.current = fetched.text;
|
|
126
|
+
restoredResourcesRef.current = fetched.resources;
|
|
112
127
|
lastSavedSignature.current = draftSignature(draftPayload(fetched));
|
|
113
128
|
setValue(fetched.text);
|
|
114
129
|
setRestoredResources(fetched.resources);
|
|
115
130
|
onDraftApplied?.(fetched);
|
|
116
131
|
}
|
|
117
132
|
}
|
|
118
|
-
const authoritativeRevision = draftRef.current?.revision ?? -1;
|
|
119
|
-
if (rejectOnFailure && authoritativeRevision < fetched.revision) {
|
|
120
|
-
throw new TypeError("Composer draft reconciliation did not commit authoritative state");
|
|
121
|
-
}
|
|
122
|
-
if (ownsLatestRead || rejectOnFailure) {
|
|
123
|
-
const recoveredError = draftLoadErrorRef.current;
|
|
124
|
-
draftLoadErrorRef.current = null;
|
|
125
|
-
if (recoveredError) {
|
|
126
|
-
setError((current) => current === recoveredError ? null : current);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
133
|
} catch (cause) {
|
|
130
|
-
if (generation === targetGeneration.current && targetKeyRef.current === targetKey &&
|
|
131
|
-
|
|
132
|
-
draftLoadErrorRef.current = failure;
|
|
133
|
-
setError(failure);
|
|
134
|
+
if (generation === targetGeneration.current && targetKeyRef.current === targetKey && readTicket === draftReadGeneration.current) {
|
|
135
|
+
setError(asError(cause));
|
|
134
136
|
}
|
|
135
|
-
if (rejectOnFailure) throw cause;
|
|
136
137
|
} finally {
|
|
137
138
|
if (generation === targetGeneration.current && targetKeyRef.current === targetKey && readTicket === draftReadGeneration.current) {
|
|
138
139
|
setDraftLoading(false);
|
|
@@ -161,28 +162,22 @@ function useComposer(sessionId, options = {}) {
|
|
|
161
162
|
{
|
|
162
163
|
enabled: Boolean(sessionId) && durableDrafts,
|
|
163
164
|
...options.events !== void 0 ? { events: options.events } : {}
|
|
164
|
-
}
|
|
165
|
-
async () => await loadDraft(false, true)
|
|
165
|
+
}
|
|
166
166
|
);
|
|
167
167
|
const currentDraftPayload = useCallback(() => {
|
|
168
|
-
if (targetKeyRef.current !== targetKey) return null;
|
|
168
|
+
if (!durableDrafts || targetKeyRef.current !== targetKey) return null;
|
|
169
169
|
const base = draftRef.current;
|
|
170
170
|
if (!base) return null;
|
|
171
171
|
const extras = resolveSendExtras(sendExtrasRef.current);
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
text: value,
|
|
175
|
-
resources: mergeResources(restoredResources, extras.resources ?? []),
|
|
176
|
-
tools: extras.tools ?? base.tools,
|
|
177
|
-
model: extras.model ?? base.model,
|
|
178
|
-
reasoningEffort: extras.reasoningEffort ?? base.reasoningEffort
|
|
179
|
-
};
|
|
180
|
-
}, [restoredResources, targetKey, value]);
|
|
172
|
+
return composerDraftPayload(base, value, restoredResources, extras);
|
|
173
|
+
}, [durableDrafts, restoredResources, targetKey, value]);
|
|
181
174
|
const persistPayload = useCallback(
|
|
182
175
|
async (payload) => {
|
|
183
176
|
const ownedTargetKey = targetKey;
|
|
184
177
|
const ownedGeneration = targetGeneration.current;
|
|
185
|
-
if (!sessionId || targetKeyRef.current !== ownedTargetKey)
|
|
178
|
+
if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) {
|
|
179
|
+
return false;
|
|
180
|
+
}
|
|
186
181
|
let success = false;
|
|
187
182
|
const run = async () => {
|
|
188
183
|
if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
|
|
@@ -223,7 +218,7 @@ function useComposer(sessionId, options = {}) {
|
|
|
223
218
|
await saveChain.current;
|
|
224
219
|
return success;
|
|
225
220
|
},
|
|
226
|
-
[client, sessionId, targetKey, workspaceId]
|
|
221
|
+
[client, durableDrafts, sessionId, targetKey, workspaceId]
|
|
227
222
|
);
|
|
228
223
|
useEffect(() => {
|
|
229
224
|
if (!durableDrafts || !sessionId || draftLoading || sending || !draftRef.current || draftConflict)
|
|
@@ -265,9 +260,11 @@ function useComposer(sessionId, options = {}) {
|
|
|
265
260
|
if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {
|
|
266
261
|
return false;
|
|
267
262
|
}
|
|
268
|
-
const
|
|
263
|
+
const acknowledgedDraft = draftRef.current;
|
|
264
|
+
const sendExtras = acknowledgedDraft?.toolsProvided === true && !Object.prototype.hasOwnProperty.call(extras, "tools") ? { ...extras, tools: acknowledgedDraft.tools } : extras;
|
|
265
|
+
const input = composeSendInput(sendText, pendingClientEventId.current, sendExtras, {
|
|
269
266
|
...options.effectiveControl?.controlEtag ? { controlEtag: options.effectiveControl.controlEtag } : {},
|
|
270
|
-
...draftRef.current ? { expectedDraftRevision: draftRef.current.revision } : {},
|
|
267
|
+
...durableDrafts && draftRef.current ? { expectedDraftRevision: draftRef.current.revision } : {},
|
|
271
268
|
resources: mergeResources(restoredResources, extras.resources ?? [])
|
|
272
269
|
});
|
|
273
270
|
if (delivery === "steer") {
|
|
@@ -291,12 +288,16 @@ function useComposer(sessionId, options = {}) {
|
|
|
291
288
|
updatedAt: null
|
|
292
289
|
};
|
|
293
290
|
draftRef.current = cleared;
|
|
291
|
+
restoredResourcesRef.current = [];
|
|
294
292
|
setDraft(cleared);
|
|
295
293
|
setRestoredResources([]);
|
|
296
294
|
lastSavedSignature.current = draftSignature(draftPayload(cleared));
|
|
297
295
|
}
|
|
298
296
|
if (explicit === void 0) {
|
|
299
|
-
|
|
297
|
+
if (valueRef.current === draftAtSend) {
|
|
298
|
+
valueRef.current = "";
|
|
299
|
+
setValue("");
|
|
300
|
+
}
|
|
300
301
|
}
|
|
301
302
|
onSent?.(sendText);
|
|
302
303
|
return true;
|
|
@@ -314,6 +315,7 @@ function useComposer(sessionId, options = {}) {
|
|
|
314
315
|
[
|
|
315
316
|
client,
|
|
316
317
|
currentDraftPayload,
|
|
318
|
+
durableDrafts,
|
|
317
319
|
onSent,
|
|
318
320
|
options.effectiveControl?.controlEtag,
|
|
319
321
|
persistPayload,
|
|
@@ -327,7 +329,7 @@ function useComposer(sessionId, options = {}) {
|
|
|
327
329
|
);
|
|
328
330
|
const send = useCallback(async (text) => await dispatch("send", text), [dispatch]);
|
|
329
331
|
const steer = useCallback(async (text) => await dispatch("steer", text), [dispatch]);
|
|
330
|
-
const hasReadyResources = restoredResources.length > 0 || (
|
|
332
|
+
const hasReadyResources = restoredResources.length > 0 || (resolveSendExtras(sendExtrasRef.current).resources?.length ?? 0) > 0;
|
|
331
333
|
const pause = useCallback(
|
|
332
334
|
async (reason) => {
|
|
333
335
|
const ownedTargetKey = targetKey;
|
|
@@ -387,12 +389,14 @@ function useComposer(sessionId, options = {}) {
|
|
|
387
389
|
setError(null);
|
|
388
390
|
try {
|
|
389
391
|
if (option.scope === "workspace") {
|
|
390
|
-
if (!client.setWorkspaceInferenceState) {
|
|
391
|
-
throw new Error("Workspace-level resume is not available through this client");
|
|
392
|
-
}
|
|
393
392
|
const workspaceBlocker = options.effectiveControl?.blockers.find(
|
|
394
393
|
(blocker) => blocker.kind === "workspace"
|
|
395
394
|
);
|
|
395
|
+
if (!client.setWorkspaceInferenceState) {
|
|
396
|
+
throw new Error(
|
|
397
|
+
"@opengeni/react: workspace-scoped resume requires setWorkspaceInferenceState."
|
|
398
|
+
);
|
|
399
|
+
}
|
|
396
400
|
await client.setWorkspaceInferenceState(workspaceId, {
|
|
397
401
|
action: "resume",
|
|
398
402
|
clientEventId: generateClientEventId(),
|
|
@@ -428,6 +432,7 @@ function useComposer(sessionId, options = {}) {
|
|
|
428
432
|
if (targetKeyRef.current !== targetKey) return;
|
|
429
433
|
pendingClientEventId.current = null;
|
|
430
434
|
localEditRevision.current += 1;
|
|
435
|
+
valueRef.current = next;
|
|
431
436
|
setValue(next);
|
|
432
437
|
},
|
|
433
438
|
[targetKey]
|
|
@@ -436,10 +441,19 @@ function useComposer(sessionId, options = {}) {
|
|
|
436
441
|
(index) => {
|
|
437
442
|
if (targetKeyRef.current !== targetKey) return;
|
|
438
443
|
localEditRevision.current += 1;
|
|
439
|
-
|
|
444
|
+
const next = restoredResourcesRef.current.filter((_, candidate) => candidate !== index);
|
|
445
|
+
restoredResourcesRef.current = next;
|
|
446
|
+
setRestoredResources(next);
|
|
440
447
|
},
|
|
441
448
|
[targetKey]
|
|
442
449
|
);
|
|
450
|
+
const hasDraftContent = useCallback(() => {
|
|
451
|
+
const current = draftRef.current;
|
|
452
|
+
const extras = resolveSendExtras(sendExtrasRef.current);
|
|
453
|
+
const toolsProvidedByHost = Object.prototype.hasOwnProperty.call(extras, "tools");
|
|
454
|
+
const tools = toolsProvidedByHost ? extras.tools ?? [] : current?.tools ?? [];
|
|
455
|
+
return valueRef.current.length > 0 || restoredResourcesRef.current.length > 0 || (extras.resources?.length ?? 0) > 0 || tools.length > 0 || current?.sourceTurnId !== null && current?.sourceTurnId !== void 0;
|
|
456
|
+
}, []);
|
|
443
457
|
const resolveDraftConflict = useCallback(
|
|
444
458
|
async (choice) => {
|
|
445
459
|
const ownedTargetKey = targetKey;
|
|
@@ -480,6 +494,7 @@ function useComposer(sessionId, options = {}) {
|
|
|
480
494
|
return {
|
|
481
495
|
value: identityMatches ? value : "",
|
|
482
496
|
setValue: updateValue,
|
|
497
|
+
hasDraftContent,
|
|
483
498
|
send,
|
|
484
499
|
steer,
|
|
485
500
|
sending: identityMatches ? sending : false,
|
|
@@ -535,10 +550,23 @@ function draftPayload(draft) {
|
|
|
535
550
|
text: draft.text,
|
|
536
551
|
resources: draft.resources,
|
|
537
552
|
tools: draft.tools,
|
|
553
|
+
toolsProvided: draft.toolsProvided,
|
|
538
554
|
model: draft.model,
|
|
539
555
|
reasoningEffort: draft.reasoningEffort
|
|
540
556
|
};
|
|
541
557
|
}
|
|
558
|
+
function composerDraftPayload(base, text, restoredResources, extras) {
|
|
559
|
+
const toolsProvidedByHost = Object.prototype.hasOwnProperty.call(extras, "tools");
|
|
560
|
+
return {
|
|
561
|
+
expectedRevision: base.revision,
|
|
562
|
+
text,
|
|
563
|
+
resources: mergeResources(restoredResources, extras.resources ?? []),
|
|
564
|
+
tools: toolsProvidedByHost ? extras.tools ?? [] : base.tools,
|
|
565
|
+
toolsProvided: toolsProvidedByHost ? true : base.toolsProvided,
|
|
566
|
+
model: extras.model ?? base.model,
|
|
567
|
+
reasoningEffort: extras.reasoningEffort ?? base.reasoningEffort
|
|
568
|
+
};
|
|
569
|
+
}
|
|
542
570
|
function draftSignature(payload) {
|
|
543
571
|
const { expectedRevision: _revision, ...content } = payload;
|
|
544
572
|
return JSON.stringify(content);
|
|
@@ -560,4 +588,4 @@ export {
|
|
|
560
588
|
shouldSubmitOnKey,
|
|
561
589
|
shouldSteerOnKey
|
|
562
590
|
};
|
|
563
|
-
//# sourceMappingURL=chunk-
|
|
591
|
+
//# sourceMappingURL=chunk-UQS7OQDE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-composer.ts"],"sourcesContent":["import type {\n ComposerDraft,\n EffectiveControlResumeOption,\n EffectiveSessionControl,\n ResourceRef,\n SaveComposerDraftRequest,\n SendMessageInput,\n SessionEvent,\n} from \"@opengeni/sdk\";\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from \"react\";\nimport { useEmbeddedSession, type EmbeddedSessionClientOverride } from \"../session-context\";\nimport { useSessionEventTrigger, type SessionEventFeedOptions } from \"./internal\";\n\nexport type ComposerSendExtras = Omit<SendMessageInput, \"text\" | \"clientEventId\">;\n\nexport type UseComposerOptions = EmbeddedSessionClientOverride &\n SessionEventFeedOptions & {\n /** Called with the accepted text after a successful send. */\n onSent?: ((text: string) => void) | undefined;\n /**\n * Extra message fields (resources, tools, model, reasoningEffort) merged\n * into every send. A function is evaluated at send time so it can read the\n * surrounding UI state (attachment pickers, model selectors, ...).\n */\n sendExtras?: ComposerSendExtras | (() => ComposerSendExtras) | undefined;\n /** Latest server-derived workstream control; bound into Send/Steer OCC. */\n effectiveControl?: EffectiveSessionControl | null | undefined;\n /** Apply durable model/tool/reasoning settings in the host's controlled UI. */\n onDraftApplied?: ((draft: ComposerDraft) => void) | undefined;\n /** Disable remote composer-draft reads and writes for embedded hosts. */\n draftPersistence?: \"durable\" | \"disabled\" | undefined;\n };\n\nexport type ComposerState = {\n value: string;\n setValue: (value: string) => void;\n /** Read the current draft synchronously before a destructive replacement. */\n hasDraftContent: () => boolean;\n /** Append the draft behind prompts already visible in the queue. */\n send: (text?: string) => Promise<boolean>;\n /** Supersede current direction with the draft. */\n steer: (text?: string) => Promise<boolean>;\n sending: boolean;\n canSend: boolean;\n /** Pause the session without deleting its prompt queue. */\n pause: (reason?: string) => Promise<void>;\n pausing: boolean;\n resume: (reason?: string) => Promise<void>;\n resumeScope: (option: EffectiveControlResumeOption) => Promise<void>;\n resuming: boolean;\n draft: ComposerDraft | null;\n draftRevision: number;\n draftLoading: boolean;\n draftSaving: boolean;\n draftConflict: Error | null;\n /** Whether this controller owns a durable server-side draft. */\n draftPersistence?: \"durable\" | \"disabled\" | undefined;\n /** Apply an atomic queue Edit checkout without a second read. */\n applyDraft: (draft: ComposerDraft) => void;\n reloadDraft: () => Promise<void>;\n resolveDraftConflict: (choice: \"keep_mine\" | \"use_remote\") => Promise<void>;\n restoredResources: ResourceRef[];\n removeRestoredResource: (index: number) => void;\n error: Error | null;\n clearError: () => void;\n};\n\n/**\n * Draft + send + Pause/Resume state for the chat composer — the only\n * human-to-agent input surface. The draft survives a failed send (nothing is\n * more hostile than losing a typed message); each send carries a generated\n * `clientEventId` so retries stay idempotent server-side.\n */\nexport function useComposer(\n sessionId: string | null | undefined,\n options: UseComposerOptions = {},\n): ComposerState {\n const { client, workspaceId, registerSessionReconciler } = useEmbeddedSession(options);\n const durableDrafts = options.draftPersistence !== \"disabled\";\n const targetKey = `${workspaceId}\\u0000${sessionId ?? \"\"}\\u0000${durableDrafts ? \"durable\" : \"disabled\"}`;\n const [value, setValue] = useState(\"\");\n // Keep rendered state behind the committed target identity for one frame:\n // a parent may switch sessionId without remounting this public hook.\n const [stateTargetKey, setStateTargetKey] = useState(targetKey);\n const [sending, setSending] = useState(false);\n const [pausing, setPausing] = useState(false);\n const [resuming, setResuming] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [draft, setDraft] = useState<ComposerDraft | null>(null);\n const [draftLoading, setDraftLoading] = useState(Boolean(sessionId) && durableDrafts);\n const [draftSaving, setDraftSaving] = useState(false);\n const [draftConflict, setDraftConflict] = useState<Error | null>(null);\n const [restoredResources, setRestoredResources] = useState<ResourceRef[]>([]);\n const pendingClientEventId = useRef<string | null>(null);\n const valueRef = useRef(\"\");\n const draftRef = useRef<ComposerDraft | null>(null);\n const restoredResourcesRef = useRef<ResourceRef[]>([]);\n const localEditRevision = useRef(0);\n const targetGeneration = useRef(0);\n const draftReadGeneration = useRef(0);\n const lastSavedSignature = useRef<string | null>(null);\n const saveChain = useRef<Promise<void>>(Promise.resolve());\n const onSent = options.onSent;\n const onDraftApplied = options.onDraftApplied;\n // Read through a ref so a new extras closure (created every render by\n // callers passing inline functions) does not invalidate `send`.\n const sendExtrasRef = useRef(options.sendExtras);\n sendExtrasRef.current = options.sendExtras;\n const liveExtrasVersion = JSON.stringify(resolveSendExtras(options.sendExtras));\n\n // A composer is bound to one session: switching targets must not leak the\n // previous session's draft, error, or retry idempotency key.\n const targetKeyRef = useRef(targetKey);\n useLayoutEffect(() => {\n if (targetKeyRef.current === targetKey) return;\n targetKeyRef.current = targetKey;\n targetGeneration.current += 1;\n draftReadGeneration.current += 1;\n pendingClientEventId.current = null;\n localEditRevision.current = 0;\n valueRef.current = \"\";\n draftRef.current = null;\n restoredResourcesRef.current = [];\n lastSavedSignature.current = null;\n // Old saves may still be awaiting the network. Their generation fence\n // prevents settlement, and a fresh chain avoids blocking this target.\n saveChain.current = Promise.resolve();\n setStateTargetKey(targetKey);\n setValue(\"\");\n setSending(false);\n setPausing(false);\n setResuming(false);\n setError(null);\n setDraft(null);\n setDraftLoading(Boolean(sessionId) && durableDrafts);\n setDraftSaving(false);\n setDraftConflict(null);\n setRestoredResources([]);\n }, [durableDrafts, sessionId, targetKey]);\n\n const applyDraft = useCallback(\n (next: ComposerDraft): void => {\n if (targetKeyRef.current !== targetKey) return;\n if (!durableDrafts) {\n pendingClientEventId.current = null;\n localEditRevision.current += 1;\n valueRef.current = next.text;\n restoredResourcesRef.current = next.resources;\n draftRef.current = null;\n lastSavedSignature.current = null;\n setDraft(null);\n setValue(next.text);\n setRestoredResources(next.resources);\n setDraftConflict(null);\n return;\n }\n valueRef.current = next.text;\n draftRef.current = next;\n restoredResourcesRef.current = next.resources;\n lastSavedSignature.current = draftSignature(draftPayload(next));\n localEditRevision.current += 1;\n pendingClientEventId.current = null;\n setDraft(next);\n setValue(next.text);\n setRestoredResources(next.resources);\n setDraftConflict(null);\n onDraftApplied?.(next);\n },\n [durableDrafts, onDraftApplied, targetKey],\n );\n\n const loadDraft = useCallback(\n async (replaceLocal: boolean): Promise<void> => {\n if (targetKeyRef.current !== targetKey) return;\n if (!sessionId || !durableDrafts) {\n setDraftLoading(false);\n return;\n }\n const generation = targetGeneration.current;\n const readTicket = ++draftReadGeneration.current;\n const localAtStart = localEditRevision.current;\n const baseAtStart = draftRef.current;\n const extrasAtStart = resolveSendExtras(sendExtrasRef.current);\n const localSignatureAtStart = baseAtStart\n ? draftSignature(\n composerDraftPayload(\n baseAtStart,\n valueRef.current,\n restoredResourcesRef.current,\n extrasAtStart,\n ),\n )\n : null;\n const localWasDirtyAtStart =\n localSignatureAtStart === null\n ? localAtStart !== 0\n : localSignatureAtStart !== lastSavedSignature.current;\n setDraftLoading(true);\n try {\n const fetched = await client.getComposerDraft(workspaceId, sessionId);\n if (\n generation !== targetGeneration.current ||\n targetKeyRef.current !== targetKey ||\n readTicket !== draftReadGeneration.current\n ) {\n return;\n }\n const currentRevision = draftRef.current?.revision ?? -1;\n if (fetched.revision >= currentRevision) {\n draftRef.current = fetched;\n setDraft(fetched);\n setDraftConflict(null);\n if (\n replaceLocal ||\n (!localWasDirtyAtStart && localAtStart === localEditRevision.current)\n ) {\n valueRef.current = fetched.text;\n restoredResourcesRef.current = fetched.resources;\n lastSavedSignature.current = draftSignature(draftPayload(fetched));\n setValue(fetched.text);\n setRestoredResources(fetched.resources);\n onDraftApplied?.(fetched);\n }\n }\n } catch (cause) {\n if (\n generation === targetGeneration.current &&\n targetKeyRef.current === targetKey &&\n readTicket === draftReadGeneration.current\n ) {\n setError(asError(cause));\n }\n } finally {\n if (\n generation === targetGeneration.current &&\n targetKeyRef.current === targetKey &&\n readTicket === draftReadGeneration.current\n ) {\n setDraftLoading(false);\n }\n }\n },\n [client, durableDrafts, onDraftApplied, sessionId, targetKey, workspaceId],\n );\n\n useEffect(() => {\n if (!sessionId || !durableDrafts) {\n setDraftLoading(false);\n return;\n }\n void loadDraft(false);\n }, [durableDrafts, loadDraft, sessionId]);\n useEffect(() => {\n if (!sessionId || !durableDrafts) return;\n return registerSessionReconciler(sessionId, \"composer\", async () => await loadDraft(false));\n }, [durableDrafts, loadDraft, registerSessionReconciler, sessionId]);\n useSessionEventTrigger(\n client,\n workspaceId,\n sessionId,\n isComposerDraftEvent,\n () => void loadDraft(false),\n {\n enabled: Boolean(sessionId) && durableDrafts,\n ...(options.events !== undefined ? { events: options.events } : {}),\n },\n );\n\n const currentDraftPayload = useCallback((): SaveComposerDraftRequest | null => {\n if (!durableDrafts || targetKeyRef.current !== targetKey) return null;\n const base = draftRef.current;\n if (!base) return null;\n const extras = resolveSendExtras(sendExtrasRef.current);\n return composerDraftPayload(base, value, restoredResources, extras);\n }, [durableDrafts, restoredResources, targetKey, value]);\n\n const persistPayload = useCallback(\n async (payload: SaveComposerDraftRequest): Promise<boolean> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) {\n return false;\n }\n let success = false;\n const run = async () => {\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n const current = draftRef.current;\n if (!current) return;\n const request = { ...payload, expectedRevision: current.revision };\n const signature = draftSignature(request);\n if (signature === lastSavedSignature.current) {\n success = true;\n return;\n }\n setDraftSaving(true);\n try {\n const saved = await client.saveComposerDraft(workspaceId, sessionId, request);\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n draftRef.current = saved;\n setDraft(saved);\n lastSavedSignature.current = signature;\n setDraftConflict(null);\n success = true;\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n const problem = asError(cause);\n setDraftConflict(problem);\n setError(problem);\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setDraftSaving(false);\n }\n }\n };\n saveChain.current = saveChain.current.then(run, run);\n await saveChain.current;\n return success;\n },\n [client, durableDrafts, sessionId, targetKey, workspaceId],\n );\n\n // Private durable autosave. A newer local edit is never replaced by an older\n // response; saves serialize and each reads the latest acknowledged revision.\n useEffect(() => {\n if (\n !durableDrafts ||\n !sessionId ||\n draftLoading ||\n sending ||\n !draftRef.current ||\n draftConflict\n )\n return;\n const payload = currentDraftPayload();\n if (!payload || draftSignature(payload) === lastSavedSignature.current) return;\n const timer = window.setTimeout(() => void persistPayload(payload), 500);\n return () => window.clearTimeout(timer);\n }, [\n currentDraftPayload,\n durableDrafts,\n draftConflict,\n draftLoading,\n liveExtrasVersion,\n persistPayload,\n sending,\n sessionId,\n ]);\n\n const dispatch = useCallback(\n async (delivery: \"send\" | \"steer\", explicit?: string): Promise<boolean> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n const draftAtSend = value;\n const rawText = explicit ?? draftAtSend;\n const hasText = rawText.trim().length > 0;\n // Resolve the extras once: a file-only message (empty text + ≥1 ready\n // resource) is legitimate, so we must not bail on empty text alone.\n const extras = resolveSendExtras(sendExtrasRef.current);\n const hasResources = restoredResources.length > 0 || (extras.resources?.length ?? 0) > 0;\n if (\n (!hasText && !hasResources) ||\n !sessionId ||\n sending ||\n targetKeyRef.current !== ownedTargetKey\n ) {\n return false;\n }\n // Reuse the clientEventId across retries of the same draft so a\n // timeout + resend cannot double-deliver the message.\n pendingClientEventId.current ??= generateClientEventId();\n setSending(true);\n setError(null);\n try {\n // Trimming is only an emptiness check. A non-blank prompt is persisted\n // and submitted byte-for-byte, while file-only sends use the same\n // placeholder for both operations so the server content fence cannot\n // reject its own client.\n const sendText = hasText ? rawText : FILE_ONLY_MESSAGE_TEXT;\n const currentPayload = currentDraftPayload();\n const payload = currentPayload ? { ...currentPayload, text: sendText } : null;\n if (payload && !(await persistPayload(payload))) return false;\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return false;\n }\n // The wire contract requires non-empty text (z.string().min(1)) and the\n // worker rejects whitespace-only text; a file-only message therefore\n // carries a minimal default so the attachments still get delivered.\n const acknowledgedDraft = draftRef.current;\n const sendExtras =\n acknowledgedDraft?.toolsProvided === true &&\n !Object.prototype.hasOwnProperty.call(extras, \"tools\")\n ? { ...extras, tools: acknowledgedDraft.tools }\n : extras;\n const input = composeSendInput(sendText, pendingClientEventId.current, sendExtras, {\n ...(options.effectiveControl?.controlEtag\n ? { controlEtag: options.effectiveControl.controlEtag }\n : {}),\n ...(durableDrafts && draftRef.current\n ? { expectedDraftRevision: draftRef.current.revision }\n : {}),\n resources: mergeResources(restoredResources, extras.resources ?? []),\n });\n if (delivery === \"steer\") {\n await client.steerMessage(workspaceId, sessionId, input);\n } else {\n await client.sendMessage(workspaceId, sessionId, input);\n }\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return false;\n }\n pendingClientEventId.current = null;\n const previousDraft = draftRef.current;\n if (previousDraft) {\n const cleared = {\n ...previousDraft,\n revision: 0,\n text: \"\",\n resources: [],\n sourceTurnId: null,\n sourceTurnVersion: null,\n updatedAt: null,\n };\n draftRef.current = cleared;\n restoredResourcesRef.current = [];\n setDraft(cleared);\n setRestoredResources([]);\n lastSavedSignature.current = draftSignature(draftPayload(cleared));\n }\n if (explicit === undefined) {\n // Clear only the draft that was sent: edits made while the request\n // was in flight were never delivered and must survive.\n if (valueRef.current === draftAtSend) {\n valueRef.current = \"\";\n setValue(\"\");\n }\n }\n onSent?.(sendText);\n return true;\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n return false;\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setSending(false);\n }\n }\n },\n [\n client,\n currentDraftPayload,\n durableDrafts,\n onSent,\n options.effectiveControl?.controlEtag,\n persistPayload,\n restoredResources,\n sending,\n sessionId,\n targetKey,\n value,\n workspaceId,\n ],\n );\n\n const send = useCallback(async (text?: string) => await dispatch(\"send\", text), [dispatch]);\n const steer = useCallback(async (text?: string) => await dispatch(\"steer\", text), [dispatch]);\n\n // A send is possible with non-empty text OR with ≥1 attached resource (a\n // file-only message). Resources ride in `sendExtras`, so we resolve them here\n // — keeping useComposer attachment-agnostic while still lighting up the send\n // affordance the moment a file is ready. ChatComposer additionally gates this\n // on its `attachments.uploading` flag so a message never departs mid-upload.\n const hasReadyResources =\n restoredResources.length > 0 ||\n (resolveSendExtras(sendExtrasRef.current).resources?.length ?? 0) > 0;\n\n const pause = useCallback(\n async (reason?: string): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || pausing || targetKeyRef.current !== ownedTargetKey) {\n return;\n }\n setPausing(true);\n setError(null);\n try {\n await client.pauseSession(workspaceId, sessionId, {\n ...(reason !== undefined ? { reason } : {}),\n ...(options.effectiveControl?.controlEtag\n ? { expectedControlEtag: options.effectiveControl.controlEtag }\n : {}),\n });\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setPausing(false);\n }\n }\n },\n [client, workspaceId, sessionId, pausing, options.effectiveControl?.controlEtag, targetKey],\n );\n\n const resume = useCallback(\n async (reason?: string): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;\n setResuming(true);\n setError(null);\n try {\n await client.resumeSession(workspaceId, sessionId, {\n ...(reason !== undefined ? { reason } : {}),\n ...(options.effectiveControl?.controlEtag\n ? { expectedControlEtag: options.effectiveControl.controlEtag }\n : {}),\n });\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(cause instanceof Error ? cause : new Error(String(cause)));\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setResuming(false);\n }\n }\n },\n [client, workspaceId, sessionId, resuming, options.effectiveControl?.controlEtag, targetKey],\n );\n\n const resumeScope = useCallback(\n async (option: EffectiveControlResumeOption): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || resuming || targetKeyRef.current !== ownedTargetKey) return;\n setResuming(true);\n setError(null);\n try {\n if (option.scope === \"workspace\") {\n const workspaceBlocker = options.effectiveControl?.blockers.find(\n (blocker) => blocker.kind === \"workspace\",\n );\n if (!client.setWorkspaceInferenceState) {\n throw new Error(\n \"@opengeni/react: workspace-scoped resume requires setWorkspaceInferenceState.\",\n );\n }\n await client.setWorkspaceInferenceState(workspaceId, {\n action: \"resume\",\n clientEventId: generateClientEventId(),\n ...(workspaceBlocker ? { expectedRevision: workspaceBlocker.revision } : {}),\n });\n } else if (option.scope === \"session\" && option.targetId) {\n const target = await client.getQueue(workspaceId, option.targetId);\n if (\n targetKeyRef.current !== ownedTargetKey ||\n targetGeneration.current !== ownedGeneration\n ) {\n return;\n }\n await client.resumeSession(workspaceId, option.targetId, {\n expectedControlEtag: target.effectiveControl.controlEtag,\n });\n } else {\n await client.resumeSession(workspaceId, sessionId, {\n ...(options.effectiveControl?.controlEtag\n ? { expectedControlEtag: options.effectiveControl.controlEtag }\n : {}),\n });\n }\n } catch (cause) {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setError(asError(cause));\n }\n } finally {\n if (\n targetKeyRef.current === ownedTargetKey &&\n targetGeneration.current === ownedGeneration\n ) {\n setResuming(false);\n }\n }\n },\n [client, options.effectiveControl, resuming, sessionId, targetKey, workspaceId],\n );\n\n const updateValue = useCallback(\n (next: string) => {\n if (targetKeyRef.current !== targetKey) return;\n pendingClientEventId.current = null;\n localEditRevision.current += 1;\n valueRef.current = next;\n setValue(next);\n },\n [targetKey],\n );\n\n const removeRestoredResource = useCallback(\n (index: number) => {\n if (targetKeyRef.current !== targetKey) return;\n localEditRevision.current += 1;\n const next = restoredResourcesRef.current.filter((_, candidate) => candidate !== index);\n restoredResourcesRef.current = next;\n setRestoredResources(next);\n },\n [targetKey],\n );\n\n const hasDraftContent = useCallback((): boolean => {\n const current = draftRef.current;\n const extras = resolveSendExtras(sendExtrasRef.current);\n const toolsProvidedByHost = Object.prototype.hasOwnProperty.call(extras, \"tools\");\n const tools = toolsProvidedByHost ? (extras.tools ?? []) : (current?.tools ?? []);\n return (\n valueRef.current.length > 0 ||\n restoredResourcesRef.current.length > 0 ||\n (extras.resources?.length ?? 0) > 0 ||\n tools.length > 0 ||\n (current?.sourceTurnId !== null && current?.sourceTurnId !== undefined)\n );\n }, []);\n\n const resolveDraftConflict = useCallback(\n async (choice: \"keep_mine\" | \"use_remote\"): Promise<void> => {\n const ownedTargetKey = targetKey;\n const ownedGeneration = targetGeneration.current;\n if (!sessionId || !durableDrafts || targetKeyRef.current !== ownedTargetKey) return;\n const remote = await client.getComposerDraft(workspaceId, sessionId);\n if (targetKeyRef.current !== ownedTargetKey || targetGeneration.current !== ownedGeneration) {\n return;\n }\n if (choice === \"use_remote\") {\n applyDraft(remote);\n return;\n }\n draftRef.current = remote;\n setDraft(remote);\n setDraftConflict(null);\n const payload = currentDraftPayload();\n if (payload) await persistPayload({ ...payload, expectedRevision: remote.revision });\n },\n [\n applyDraft,\n client,\n currentDraftPayload,\n durableDrafts,\n persistPayload,\n sessionId,\n targetKey,\n workspaceId,\n ],\n );\n\n const identityMatches = stateTargetKey === targetKey;\n const reloadDraft = useCallback(async () => await loadDraft(true), [loadDraft]);\n const clearError = useCallback(() => {\n if (targetKeyRef.current !== targetKey) return;\n setError(null);\n setDraftConflict(null);\n }, [targetKey]);\n\n return {\n value: identityMatches ? value : \"\",\n setValue: updateValue,\n hasDraftContent,\n send,\n steer,\n sending: identityMatches ? sending : false,\n canSend:\n identityMatches &&\n Boolean(sessionId) &&\n !sending &&\n (value.trim().length > 0 || hasReadyResources),\n pause,\n pausing: identityMatches ? pausing : false,\n resume,\n resumeScope,\n resuming: identityMatches ? resuming : false,\n draft: identityMatches ? draft : null,\n draftRevision: identityMatches ? (draft?.revision ?? 0) : 0,\n draftLoading: identityMatches ? draftLoading : Boolean(sessionId) && durableDrafts,\n draftSaving: identityMatches ? draftSaving : false,\n draftConflict: identityMatches ? draftConflict : null,\n draftPersistence: durableDrafts ? \"durable\" : \"disabled\",\n applyDraft,\n reloadDraft,\n resolveDraftConflict,\n restoredResources: identityMatches ? restoredResources : [],\n removeRestoredResource,\n error: identityMatches ? error : null,\n clearError,\n };\n}\n\n/** Events that can atomically replace or clear this subject's durable draft. */\nexport function isComposerDraftEvent(event: Pick<SessionEvent, \"type\">): boolean {\n return event.type === \"user.message\" || event.type === \"session.queue.changed\";\n}\n\n/**\n * Default text for a file-only message (attachment(s) present, no typed draft).\n * Kept non-empty so the wire contract (`text: z.string().min(1)`) and the\n * worker's non-whitespace guard accept it; the attached files still ride in\n * `resources`. Exported for tests.\n */\nexport const FILE_ONLY_MESSAGE_TEXT = \"(see attached files)\";\n\n/** Resolve possibly-deferred extras to a concrete bag (function evaluated now). */\nexport function resolveSendExtras(\n extras: ComposerSendExtras | (() => ComposerSendExtras) | undefined,\n): ComposerSendExtras {\n return (typeof extras === \"function\" ? extras() : extras) ?? {};\n}\n\n/**\n * Merge the draft text + idempotency key with caller-provided extras. The\n * text and clientEventId always win over extras. Exported for tests.\n */\nexport function composeSendInput(\n text: string,\n clientEventId: string,\n extras: ComposerSendExtras | (() => ComposerSendExtras) | undefined,\n bound: Partial<SendMessageInput> = {},\n): SendMessageInput {\n return { ...resolveSendExtras(extras), ...bound, text, clientEventId };\n}\n\n/** Submit on plain Enter; Shift+Enter inserts a newline. Exported for tests. */\nexport function shouldSubmitOnKey(event: {\n key: string;\n shiftKey: boolean;\n metaKey?: boolean;\n ctrlKey?: boolean;\n nativeEvent?: { isComposing?: boolean };\n}): boolean {\n if (event.key !== \"Enter\" || event.shiftKey) {\n return false;\n }\n return event.nativeEvent?.isComposing !== true;\n}\n\n/** Cmd/Ctrl+Enter steers; ordinary Enter appends to the queue. */\nexport function shouldSteerOnKey(event: { metaKey?: boolean; ctrlKey?: boolean }): boolean {\n return event.metaKey === true || event.ctrlKey === true;\n}\n\nfunction generateClientEventId(): string {\n return globalThis.crypto.randomUUID();\n}\n\nfunction asError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause));\n}\n\nfunction draftPayload(draft: ComposerDraft): SaveComposerDraftRequest {\n return {\n expectedRevision: draft.revision,\n text: draft.text,\n resources: draft.resources,\n tools: draft.tools,\n toolsProvided: draft.toolsProvided,\n model: draft.model,\n reasoningEffort: draft.reasoningEffort,\n };\n}\n\nfunction composerDraftPayload(\n base: ComposerDraft,\n text: string,\n restoredResources: ResourceRef[],\n extras: ComposerSendExtras,\n): SaveComposerDraftRequest {\n const toolsProvidedByHost = Object.prototype.hasOwnProperty.call(extras, \"tools\");\n return {\n expectedRevision: base.revision,\n text,\n resources: mergeResources(restoredResources, extras.resources ?? []),\n tools: toolsProvidedByHost ? (extras.tools ?? []) : base.tools,\n toolsProvided: toolsProvidedByHost ? true : base.toolsProvided,\n model: extras.model ?? base.model,\n reasoningEffort: extras.reasoningEffort ?? base.reasoningEffort,\n };\n}\n\nfunction draftSignature(payload: SaveComposerDraftRequest): string {\n const { expectedRevision: _revision, ...content } = payload;\n return JSON.stringify(content);\n}\n\nfunction mergeResources(base: ResourceRef[], additions: ResourceRef[]): ResourceRef[] {\n const seen = new Set<string>();\n return [...base, ...additions].filter((resource) => {\n const key = JSON.stringify(resource);\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n"],"mappings":";;;;;;AASA,SAAS,aAAa,WAAW,iBAAiB,QAAQ,gBAAgB;AAgEnE,SAAS,YACd,WACA,UAA8B,CAAC,GAChB;AACf,QAAM,EAAE,QAAQ,aAAa,0BAA0B,IAAI,mBAAmB,OAAO;AACrF,QAAM,gBAAgB,QAAQ,qBAAqB;AACnD,QAAM,YAAY,GAAG,WAAW,KAAS,aAAa,EAAE,KAAS,gBAAgB,YAAY,UAAU;AACvG,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AAGrC,QAAM,CAAC,gBAAgB,iBAAiB,IAAI,SAAS,SAAS;AAC9D,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,CAAC,UAAU,WAAW,IAAI,SAAS,KAAK;AAC9C,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA+B,IAAI;AAC7D,QAAM,CAAC,cAAc,eAAe,IAAI,SAAS,QAAQ,SAAS,KAAK,aAAa;AACpF,QAAM,CAAC,aAAa,cAAc,IAAI,SAAS,KAAK;AACpD,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAuB,IAAI;AACrE,QAAM,CAAC,mBAAmB,oBAAoB,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,WAAW,GAAG,QAAQ,IAAI;AACpD,SAAO,KAAK,UAAU,OAAO;AAC/B;AAEA,SAAS,eAAe,MAAqB,WAAyC;AACpF,QAAM,OAAO,oBAAI,IAAY;AAC7B,SAAO,CAAC,GAAG,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,aAAa;AAClD,UAAM,MAAM,KAAK,UAAU,QAAQ;AACnC,QAAI,KAAK,IAAI,GAAG,EAAG,QAAO;AAC1B,SAAK,IAAI,GAAG;AACZ,WAAO;AAAA,EACT,CAAC;AACH;","names":[]}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
// src/components/queue-draft-policy.ts
|
|
2
|
+
function requestQueueDraftEdit(composer, confirmReplacement, editImmediately) {
|
|
3
|
+
if (composer.hasDraftContent()) {
|
|
4
|
+
confirmReplacement();
|
|
5
|
+
} else {
|
|
6
|
+
editImmediately();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
// src/components/queue-surface-state.tsx
|
|
2
11
|
import { Loader2Icon, RotateCwIcon } from "lucide-react";
|
|
3
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -85,8 +94,9 @@ function QueueErrorAlert({
|
|
|
85
94
|
}
|
|
86
95
|
|
|
87
96
|
export {
|
|
97
|
+
requestQueueDraftEdit,
|
|
88
98
|
EmptyQueueStateSurface,
|
|
89
99
|
QueueStoppingStatus,
|
|
90
100
|
QueueErrorAlert
|
|
91
101
|
};
|
|
92
|
-
//# sourceMappingURL=chunk-
|
|
102
|
+
//# sourceMappingURL=chunk-YDNWMKXO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/queue-draft-policy.ts","../src/components/queue-surface-state.tsx"],"sourcesContent":["import type { ComposerState } from \"../hooks/use-composer\";\n\n/**\n * Decide whether checking out a queued prompt would replace current composer\n * content. `hasDraftContent` reads the synchronous draft refs, so this stays\n * correct even when a controlled input update has not rendered yet.\n */\nexport function requestQueueDraftEdit(\n composer: Pick<ComposerState, \"hasDraftContent\">,\n confirmReplacement: () => void,\n editImmediately: () => void,\n): void {\n if (composer.hasDraftContent()) {\n confirmReplacement();\n } else {\n editImmediately();\n }\n}\n","import { Loader2Icon, RotateCwIcon } from \"lucide-react\";\n\nimport type { UseTurnQueueResult } from \"../hooks/use-turn-queue\";\n\ntype QueueStateProps = {\n queue: UseTurnQueueResult;\n};\n\nexport function EmptyQueueStateSurface({ queue }: QueueStateProps) {\n const hasError = Boolean(queue.error || queue.mutationError);\n return (\n <div\n className=\"mx-auto mb-2 w-full max-w-3xl shrink-0 px-4 sm:px-6\"\n data-testid=\"queue-surface\"\n >\n <div className=\"overflow-hidden rounded-lg border border-border bg-surface/80 shadow-sm\">\n {queue.stoppingPreviousAttempt ? (\n <QueueStoppingStatus queue={queue} dividerAfter={hasError} />\n ) : null}\n {hasError ? <QueueErrorAlert queue={queue} /> : null}\n </div>\n </div>\n );\n}\n\nexport function QueueStoppingStatus({\n queue,\n dividerAfter = false,\n}: QueueStateProps & { dividerAfter?: boolean }) {\n return (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className={`flex min-h-11 items-center gap-2.5 bg-status-waiting/[0.07] px-3 py-2 text-xs text-fg ${\n dividerAfter ? \"border-b border-status-waiting/20\" : \"\"\n }`}\n data-testid=\"stopping-previous-attempt\"\n >\n <Loader2Icon\n aria-hidden=\"true\"\n className=\"size-3.5 shrink-0 animate-spin text-status-waiting motion-reduce:animate-none\"\n />\n <span className=\"min-w-0\">\n <span className=\"font-medium\">\n {queue.effectiveControl?.state === \"paused\"\n ? \"Stopping current attempt…\"\n : \"Stopping previous attempt…\"}\n </span>{\" \"}\n <span className=\"text-fg-muted\">\n {queue.effectiveControl?.state === \"paused\"\n ? \"Queued work stays saved until you resume.\"\n : \"Queued work is saved and starts automatically.\"}\n </span>\n </span>\n </div>\n );\n}\n\nexport function QueueErrorAlert({\n queue,\n dividerBefore = false,\n}: QueueStateProps & { dividerBefore?: boolean }) {\n return (\n <div className={`${dividerBefore ? \"border-t border-border\" : \"\"} p-2`}>\n <div\n role=\"alert\"\n className=\"flex min-w-0 max-w-full flex-wrap items-start gap-2 rounded-md bg-status-failed/10 px-2 py-1.5 text-xs text-status-failed\"\n >\n <span\n role=\"region\"\n aria-label=\"Queue error details\"\n tabIndex={0}\n className=\"max-h-[min(5rem,20dvh)] min-w-0 max-w-full flex-[1_1_5rem] overflow-auto overscroll-contain whitespace-pre-wrap rounded-sm outline-none [overflow-wrap:anywhere] [unicode-bidi:plaintext] focus-visible:ring-2 focus-visible:ring-ring/40\"\n data-testid=\"queue-error-message\"\n dir=\"auto\"\n >\n {(queue.mutationError ?? queue.error)?.message}\n </span>\n <button\n type=\"button\"\n onClick={() => {\n queue.clearMutationError();\n void queue.refresh();\n }}\n aria-label=\"Dismiss queue error and retry\"\n title=\"Retry loading the queue\"\n className=\"ms-auto inline-flex size-7 shrink-0 items-center justify-center self-start rounded-md outline-none transition-colors hover:bg-surface-3 focus-visible:ring-2 focus-visible:ring-ring/40 motion-reduce:transition-none pointer-coarse:size-[44px]\"\n >\n <RotateCwIcon className=\"size-3.5\" />\n </button>\n </div>\n </div>\n );\n}\n"],"mappings":";AAOO,SAAS,sBACd,UACA,oBACA,iBACM;AACN,MAAI,SAAS,gBAAgB,GAAG;AAC9B,uBAAmB;AAAA,EACrB,OAAO;AACL,oBAAgB;AAAA,EAClB;AACF;;;ACjBA,SAAS,aAAa,oBAAoB;AAepC,SAEI,KAFJ;AAPC,SAAS,uBAAuB,EAAE,MAAM,GAAoB;AACjE,QAAM,WAAW,QAAQ,MAAM,SAAS,MAAM,aAAa;AAC3D,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,eAAY;AAAA,MAEZ,+BAAC,SAAI,WAAU,2EACZ;AAAA,cAAM,0BACL,oBAAC,uBAAoB,OAAc,cAAc,UAAU,IACzD;AAAA,QACH,WAAW,oBAAC,mBAAgB,OAAc,IAAK;AAAA,SAClD;AAAA;AAA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
3
|
import { KeyboardEvent, ButtonHTMLAttributes, ClipboardEvent, RefObject, DragEvent, ChangeEvent, ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
4
4
|
import * as _opengeni_sdk from '@opengeni/sdk';
|
|
5
5
|
import { Permission, SessionStatus, FileAsset, FileResourceRef, EffectiveSessionControl, ClientModel, TranscriptionLifecycleStatus, TranscriptionErrorCode, TranscriptionEvent, TranscriptionAdapter, WorkspaceTranscriptionPolicy, TranscriptionTargetSelection, TranscriptionDiagnostic, TranscriptionPolicyBlockReason } from '@opengeni/sdk';
|
|
6
|
-
import { S as SessionClientLike, C as ClientOverride } from './session-context-
|
|
7
|
-
import { C as ComposerState } from './use-composer-
|
|
6
|
+
import { S as SessionClientLike, C as ClientOverride } from './session-context-rgrfElMl.js';
|
|
7
|
+
import { C as ComposerState } from './use-composer-By1wn3MM.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The slash-command registry. A command is a SESSION / OPERATOR control — an
|
package/dist/composer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { A as Actions, x as AttachButton, y as Attachments, z as ChatComposerContextValue, B as ChatComposerController, c as ChatComposerMessages, D as CommandPalette, E as ComposerActionsProps, G as ComposerAttachButtonProps, H as ComposerCommandPaletteProps, C as ComposerControlLinks, J as ComposerControlState, K as ComposerControlsProps, L as ComposerDelivery, M as ComposerDraftState, P as ComposerFooterProps, Q as ComposerFrameProps, R as ComposerHintProps, V as ComposerInputProps, W as ComposerModelPickerProps, X as ComposerPauseButtonProps, Y as ComposerRootProps, Z as ComposerSendButtonProps, _ as ComposerSubmitBlocker, $ as ComposerSubmitMode, a0 as ComposerSurfaceProps, g as ComposerTranscriptionControl, a as ComposerTranscriptionControlProps, h as ComposerTranscriptionMessages, a1 as Confirmation, a2 as Controls, a3 as Footer, a4 as Frame, a5 as Help, a6 as Hint, a7 as Input, a8 as ModelPicker, O as OPEN_WORKSTREAM_CONTROL_EVENT, a9 as PauseButton, aa as PausedState, ab as RestoredResources, ac as Root, ad as SendButton, ae as Status, af as Surface, ag as UseChatComposerControllerOptions, s as defaultChatComposerMessages, ah as useChatComposer, ai as useChatComposerController } from './composer-
|
|
1
|
+
export { A as Actions, x as AttachButton, y as Attachments, z as ChatComposerContextValue, B as ChatComposerController, c as ChatComposerMessages, D as CommandPalette, E as ComposerActionsProps, G as ComposerAttachButtonProps, H as ComposerCommandPaletteProps, C as ComposerControlLinks, J as ComposerControlState, K as ComposerControlsProps, L as ComposerDelivery, M as ComposerDraftState, P as ComposerFooterProps, Q as ComposerFrameProps, R as ComposerHintProps, V as ComposerInputProps, W as ComposerModelPickerProps, X as ComposerPauseButtonProps, Y as ComposerRootProps, Z as ComposerSendButtonProps, _ as ComposerSubmitBlocker, $ as ComposerSubmitMode, a0 as ComposerSurfaceProps, g as ComposerTranscriptionControl, a as ComposerTranscriptionControlProps, h as ComposerTranscriptionMessages, a1 as Confirmation, a2 as Controls, a3 as Footer, a4 as Frame, a5 as Help, a6 as Hint, a7 as Input, a8 as ModelPicker, O as OPEN_WORKSTREAM_CONTROL_EVENT, a9 as PauseButton, aa as PausedState, ab as RestoredResources, ac as Root, ad as SendButton, ae as Status, af as Surface, ag as UseChatComposerControllerOptions, s as defaultChatComposerMessages, ah as useChatComposer, ai as useChatComposerController } from './composer-CVm5uoUI.js';
|
|
2
2
|
import 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
4
|
import '@opengeni/sdk';
|
|
5
|
-
import './session-context-
|
|
6
|
-
import './use-composer-
|
|
5
|
+
import './session-context-rgrfElMl.js';
|
|
6
|
+
import './use-composer-By1wn3MM.js';
|
package/dist/composer.js
CHANGED
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
defaultChatComposerMessages,
|
|
24
24
|
useChatComposer,
|
|
25
25
|
useChatComposerController
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-CATATY77.js";
|
|
27
27
|
import "./chunk-TK7G6XLT.js";
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-UQS7OQDE.js";
|
|
29
|
+
import "./chunk-I3BJZIG5.js";
|
|
30
30
|
export {
|
|
31
31
|
Actions,
|
|
32
32
|
AttachButton,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { S as SessionClientLike, C as ClientOverride } from './session-context-
|
|
2
|
-
export { a as EmbeddedHumanInputSessionClientLike, b as EmbeddedSessionClientLike, O as OpenGeniContextValue, u as useOpenGeni,
|
|
1
|
+
import { S as SessionClientLike, C as ClientOverride } from './session-context-rgrfElMl.js';
|
|
2
|
+
export { a as EmbeddedHumanInputSessionClientLike, b as EmbeddedSessionClientLike, c as EmbeddedSessionMcpApprovalPolicyClientLike, O as OpenGeniContextValue, u as useOpenGeni, d as useOpenGeniClient } from './session-context-rgrfElMl.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import { WorkspaceControlEvent, Session, SessionEvent, EffectiveSessionControl, ClientModel, SessionGoal, ScheduledTask, SessionLineageResponse, VariableSet, CreateVariableSetRequest, UpdateVariableSetRequest, VariableSetVariableMetadata, RigChange, Rig, UpdateRigRequest, RigVersion, ProposeRigChangeRequest, CreateRigRequest, CapabilityPack, PackInstallation, RegisterCapabilityPackRequest, WorkspaceRegisteredPack, EnablePackRequest, Workspace, CreateWorkspaceRequest, UpdateWorkspaceRequest, BillingBalance, UsageEvent, SessionCapabilities, DesktopStreamCapability, DesktopConnectionState, DesktopRfbFactory, TerminalCapability, OpenGeniRequestOptions, FsReadResponse, FsWriteResponse, WorkspaceCaptureManifest, GitFileDiff, WorkspaceCaptureDegradedReason, MachineState, SessionHumanInputRequest, SubmitHumanInputResponseRequest, HumanInputQuestion, HumanInputAnswer, Permission, SessionStatus as SessionStatus$1, CapabilityUnavailableReason, MachineView, CodexAccountsResponse, CodexAccount, CodexRotationSettings } from '@opengeni/sdk';
|
|
5
5
|
export { MachineKind, MachineMetricsSeriesResponse, MachineState, MachineView, MachinesResponse, MetricSample } from '@opengeni/sdk';
|
|
6
6
|
import * as react from 'react';
|
|
7
7
|
import { ReactNode, ClipboardEvent, RefObject, ComponentType } from 'react';
|
|
8
|
-
import { S as SessionEventFeedOptions, C as ComposerState } from './use-composer-
|
|
9
|
-
export { a as ComposerSendExtras, F as FILE_ONLY_MESSAGE_TEXT, U as UseComposerOptions, c as composeSendInput, s as shouldSteerOnKey, b as shouldSubmitOnKey, u as useComposer } from './use-composer-
|
|
10
|
-
import { U as UseTurnQueueResult, P as PendingApproval, T as ToolCallItem, A as ActivityItem, a as TurnOutcome, b as TimelineItem, c as AgentMessageItem, d as UserMessageItem, e as AuthNeededItem } from './session-
|
|
11
|
-
export { B as BrowserSessionEventWindow, G as GoalItem, N as NoticeItem, f as PendingHumanInputRequest, Q as QueueMutationKind, R as ReasoningItem, S as SESSION_EVENT_BROWSER_MAX_BYTES, g as SESSION_EVENT_BROWSER_MAX_COUNT, h as SESSION_EVENT_BROWSER_PENDING_MAX_BYTES, i as SESSION_EVENT_BROWSER_PENDING_MAX_COUNT, j as SESSION_EVENT_BROWSER_SINGLE_EVENT_MAX_BYTES, k as SandboxItem, l as SessionEventsConnectionState, m as SessionStatusItem, n as TimelineGroup, o as TurnEndItem, p as UseHumanInputRequestsOptions, q as UseHumanInputRequestsResult, r as UseSessionControlOptions, s as UseSessionControlResult, t as UseSessionEventsOptions, u as UseSessionEventsResult, v as UseTurnQueueOptions, W as WorkerItem,
|
|
12
|
-
import { C as ComposerControlLinks, a as ComposerTranscriptionControlProps, U as UseFileAttachmentsResult, S as SlashCommand, b as SlashCommandContext, c as ChatComposerMessages, d as SlashArg, e as CommandContext } from './composer-
|
|
13
|
-
export { f as CommandResult, g as ComposerTranscriptionControl, h as ComposerTranscriptionMessages, i as ConfirmState, F as FileAttachment, I as INITIAL_TRANSCRIPTION_CONTROL_STATE, N as Notice, O as OPEN_WORKSTREAM_CONTROL_EVENT, j as SlashCommandHandlers, T as TranscriptionControlAction, k as TranscriptionControlState, l as TranscriptionControlTransition, m as UseFileAttachmentsOptions, n as UseSlashCommandsOptions, o as UseSlashCommandsResult, p as UseTranscriptionOptions, q as UseTranscriptionResult, r as appendFinalTranscript, s as defaultChatComposerMessages, t as transitionTranscriptionControl, u as useFileAttachments, v as useSlashCommands, w as useTranscription } from './composer-
|
|
8
|
+
import { S as SessionEventFeedOptions, C as ComposerState } from './use-composer-By1wn3MM.js';
|
|
9
|
+
export { a as ComposerSendExtras, F as FILE_ONLY_MESSAGE_TEXT, U as UseComposerOptions, c as composeSendInput, s as shouldSteerOnKey, b as shouldSubmitOnKey, u as useComposer } from './use-composer-By1wn3MM.js';
|
|
10
|
+
import { U as UseTurnQueueResult, P as PendingApproval, T as ToolCallItem, A as ActivityItem, a as TurnOutcome, b as TimelineItem, c as AgentMessageItem, d as UserMessageItem, e as AuthNeededItem } from './session-Db00TRwl.js';
|
|
11
|
+
export { B as BrowserSessionEventWindow, G as GoalItem, N as NoticeItem, f as PendingHumanInputRequest, Q as QueueMutationKind, R as ReasoningItem, S as SESSION_EVENT_BROWSER_MAX_BYTES, g as SESSION_EVENT_BROWSER_MAX_COUNT, h as SESSION_EVENT_BROWSER_PENDING_MAX_BYTES, i as SESSION_EVENT_BROWSER_PENDING_MAX_COUNT, j as SESSION_EVENT_BROWSER_SINGLE_EVENT_MAX_BYTES, k as SandboxItem, l as SessionEventsConnectionState, m as SessionStatusItem, n as TimelineGroup, o as TurnEndItem, p as UseHumanInputRequestsOptions, q as UseHumanInputRequestsResult, r as UseSessionControlOptions, s as UseSessionControlResult, t as UseSessionEventsOptions, u as UseSessionEventsResult, v as UseSessionMcpApprovalPolicyOptions, w as UseSessionMcpApprovalPolicyResult, x as UseTurnQueueOptions, W as WorkerItem, y as approvalsFromRequiresAction, z as boundBrowserSessionEventWindow, C as buildTimeline, D as creditExhaustedFromEvents, E as extractSessionRef, F as groupTimeline, H as humanInputRequestFromEvent, I as isHumanInputEvent, J as isSessionMcpApprovalPolicyEvent, K as isTurnQueueEvent, L as projectPendingApprovals, M as projectPendingHumanInputRequests, O as sessionStatusFromEvents, V as toolDisplayName, X as useHumanInputRequests, Y as useSessionControl, Z as useSessionEvents, _ as useSessionMcpApprovalPolicy, $ as useTurnQueue } from './session-Db00TRwl.js';
|
|
12
|
+
import { C as ComposerControlLinks, a as ComposerTranscriptionControlProps, U as UseFileAttachmentsResult, S as SlashCommand, b as SlashCommandContext, c as ChatComposerMessages, d as SlashArg, e as CommandContext } from './composer-CVm5uoUI.js';
|
|
13
|
+
export { f as CommandResult, g as ComposerTranscriptionControl, h as ComposerTranscriptionMessages, i as ConfirmState, F as FileAttachment, I as INITIAL_TRANSCRIPTION_CONTROL_STATE, N as Notice, O as OPEN_WORKSTREAM_CONTROL_EVENT, j as SlashCommandHandlers, T as TranscriptionControlAction, k as TranscriptionControlState, l as TranscriptionControlTransition, m as UseFileAttachmentsOptions, n as UseSlashCommandsOptions, o as UseSlashCommandsResult, p as UseTranscriptionOptions, q as UseTranscriptionResult, r as appendFinalTranscript, s as defaultChatComposerMessages, t as transitionTranscriptionControl, u as useFileAttachments, v as useSlashCommands, w as useTranscription } from './composer-CVm5uoUI.js';
|
|
14
14
|
export { CONNECTION_STATUS_META, ConnectionDot, ConnectionDotProps, ConnectionStatus, ConnectionStatusMeta, ConnectionStatusPill, ConnectionStatusPillProps, DeviceFlowPhase, EnrollmentConsent, EnrollmentConsentMachine, EnrollmentConsentPhase, EnrollmentConsentProps, EnrollmentDeviceFlow, EnrollmentDeviceFlowProps, HEALTH_TOKEN, HealthLevel, HealthVerdict, MACHINE_STATE_BADGE_META, METRICS, METRIC_WINDOWS, MachineCard, MachineCardProps, MachineDetail, MachineDetailProps, MachineDockBar, MachineDockBarProps, MachineHealthPill, MachineHealthPillProps, MachineMetrics, MachineMetricsProps, MachineStateBadgeMeta, MachineStatusPill, MachineStatusPillProps, MachinesClientLike, MachinesDashboard, MachinesDashboardProps, MetricDef, MetricHistoryChart, MetricHistoryChartProps, MetricKey, MetricSparkline, MetricSparklineProps, MetricWindow, SeriesPoint, SharedMachineDisclosure, SharedMachineDisclosureProps, UseMachinesOptions, UseMachinesResult, WINDOW_LABEL, connectionStatusForState, deriveHealth, healthPulses, pointsFor, useMachines } from './machines.js';
|
|
15
15
|
import { ClassValue } from 'clsx';
|
|
16
16
|
|