@qilin-agent/client-ui-conversation 0.0.0-stage → 3.1.4
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/LICENSE +21 -0
- package/README.i18n.yaml +37 -0
- package/README.md +149 -2
- package/README.zh.md +150 -0
- package/lib/client.js +19208 -0
- package/lib/index.js +46 -0
- package/lib/types/client/apply.d.ts +25 -0
- package/lib/types/client/context-occupancy.d.ts +14 -0
- package/lib/types/client/contract/composer-blocks.d.ts +28 -0
- package/lib/types/client/contract/composer-submission.d.ts +8 -0
- package/lib/types/client/contract/context-producer.d.ts +29 -0
- package/lib/types/client/contract/conversation.d.ts +279 -0
- package/lib/types/client/contract/draft-editor.d.ts +102 -0
- package/lib/types/client/contract/groups.d.ts +116 -0
- package/lib/types/client/contract/input.d.ts +361 -0
- package/lib/types/client/contract/records.d.ts +301 -0
- package/lib/types/client/contract/request-inspection.d.ts +132 -0
- package/lib/types/client/contract/slots.d.ts +541 -0
- package/lib/types/client/contract/snapshot.d.ts +20 -0
- package/lib/types/client/contract/system-prompt.d.ts +35 -0
- package/lib/types/client/contract/views.d.ts +36 -0
- package/lib/types/client/conversation/assembler.d.ts +151 -0
- package/lib/types/client/conversation/assembly.d.ts +128 -0
- package/lib/types/client/conversation/definition-registry.d.ts +33 -0
- package/lib/types/client/conversation/event-registry.d.ts +40 -0
- package/lib/types/client/conversation/group-registry.d.ts +30 -0
- package/lib/types/client/conversation/group-store.d.ts +29 -0
- package/lib/types/client/conversation/historical-images.d.ts +49 -0
- package/lib/types/client/conversation/location-index.d.ts +91 -0
- package/lib/types/client/conversation/view-registry.d.ts +12 -0
- package/lib/types/client/image-labels.d.ts +23 -0
- package/lib/types/client/index.d.ts +39 -0
- package/lib/types/client/input/blocks.d.ts +27 -0
- package/lib/types/client/input/decorations.d.ts +32 -0
- package/lib/types/client/input/editor/ComposerContentEditable.d.ts +16 -0
- package/lib/types/client/input/editor/DecoratorPortals.d.ts +14 -0
- package/lib/types/client/input/editor/DraftEditor.d.ts +27 -0
- package/lib/types/client/input/editor/ReferenceChip.d.ts +17 -0
- package/lib/types/client/input/editor/chip-node.d.ts +110 -0
- package/lib/types/client/input/editor/claim-decor.d.ts +23 -0
- package/lib/types/client/input/editor/keymap.d.ts +43 -0
- package/lib/types/client/input/editor/projection.d.ts +93 -0
- package/lib/types/client/input/editor/reference-activation.d.ts +10 -0
- package/lib/types/client/input/editor/runtime.d.ts +123 -0
- package/lib/types/client/input/editor/span-map.d.ts +38 -0
- package/lib/types/client/input/editor/text-ref.d.ts +49 -0
- package/lib/types/client/input/editor/view-binding.d.ts +60 -0
- package/lib/types/client/input/facade.d.ts +303 -0
- package/lib/types/client/input/hub.d.ts +100 -0
- package/lib/types/client/input/machine.d.ts +46 -0
- package/lib/types/client/input/submission-policy.d.ts +52 -0
- package/lib/types/client/layout-policy.d.ts +42 -0
- package/lib/types/client/locales.d.ts +772 -0
- package/lib/types/client/queue/QueueDock.d.ts +27 -0
- package/lib/types/client/service.d.ts +192 -0
- package/lib/types/client/settings/ContentWidthRow.d.ts +26 -0
- package/lib/types/client/settings/EnterBehaviorRow.d.ts +21 -0
- package/lib/types/client/skeleton/ContextMeter.d.ts +14 -0
- package/lib/types/client/skeleton/ConversationContent.d.ts +8 -0
- package/lib/types/client/skeleton/ConversationHeader.d.ts +8 -0
- package/lib/types/client/skeleton/ConversationMainPanel.d.ts +3 -0
- package/lib/types/client/skeleton/ConversationPanel.d.ts +9 -0
- package/lib/types/client/skeleton/ConversationRoot.d.ts +5 -0
- package/lib/types/client/skeleton/ConversationSession.d.ts +21 -0
- package/lib/types/client/skeleton/ConversationWidthControls.d.ts +14 -0
- package/lib/types/client/skeleton/DefaultConversationViews.d.ts +9 -0
- package/lib/types/client/skeleton/EmptyHero.d.ts +49 -0
- package/lib/types/client/skeleton/InputBar.d.ts +18 -0
- package/lib/types/client/skeleton/TodoPanel.d.ts +21 -0
- package/lib/types/client/skeleton/control-row-layout.d.ts +10 -0
- package/lib/types/client/skeleton/safari.d.ts +18 -0
- package/lib/types/client/stop-sequence.d.ts +32 -0
- package/lib/types/client/stop-shortcut.d.ts +17 -0
- package/lib/types/client/stores.d.ts +24 -0
- package/lib/types/client/view-selection.d.ts +11 -0
- package/lib/types/conversation-settings.d.ts +38 -0
- package/lib/types/index.d.ts +9 -0
- package/package.json +106 -3
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frozen input-machine contract. Types
|
|
3
|
+
* only. Three-tier visibility: business packages see InputState via the
|
|
4
|
+
* InputZone currency; the scoped input events carry the mutation verbs; the
|
|
5
|
+
* conversation wiring layer alone sees the full SessionInput. The draft text
|
|
6
|
+
* and its reference chips live in the shell's Lexical editor; the machine
|
|
7
|
+
* here is the submit plane (phase, claim, attempt) alone.
|
|
8
|
+
*/
|
|
9
|
+
import type { Context } from '@qilin-agent/kylin';
|
|
10
|
+
import type { InboxState } from '@qilin-agent/agent/types';
|
|
11
|
+
import type { ObservableSnapshot, SnapshotStore } from '@qilin-agent/client-store';
|
|
12
|
+
import type { Branded } from '@qilin-agent/brand';
|
|
13
|
+
import type { ArbitrateKey, ArbitrateOutcome, Occurrence, ReferenceInsert, TokenSpan } from './draft-editor.ts';
|
|
14
|
+
import type { InputSubmitMode } from './composer-submission.ts';
|
|
15
|
+
/** Attachment payload passed to a claimed command submission. */
|
|
16
|
+
export type SubmitAttachment = {
|
|
17
|
+
readonly type: 'image';
|
|
18
|
+
readonly mediaType: 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';
|
|
19
|
+
readonly data: string;
|
|
20
|
+
readonly name?: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: 'file';
|
|
23
|
+
readonly receiptId: string;
|
|
24
|
+
};
|
|
25
|
+
/** Command serialization result for one ordered attachment draft. */
|
|
26
|
+
export interface DraftAttachmentSerializationResult {
|
|
27
|
+
readonly attachments: readonly SubmitAttachment[];
|
|
28
|
+
}
|
|
29
|
+
/** Settled result of a command or default composer submission. */
|
|
30
|
+
export interface SubmitOutcome {
|
|
31
|
+
readonly kind: 'success' | 'error';
|
|
32
|
+
readonly text?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Command-mode credential supplied by one input-trigger source. */
|
|
35
|
+
export interface CommandClaim {
|
|
36
|
+
/** Catalog command name without the leading slash (the key of per-command composer copy such as `hint.*`). */
|
|
37
|
+
readonly name: string;
|
|
38
|
+
/** Inserted command text with its argument separator; the bare complete name also retains the claim. */
|
|
39
|
+
readonly token: string;
|
|
40
|
+
readonly hint?: string;
|
|
41
|
+
readonly attachments?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Submit the claimed command.
|
|
44
|
+
* @param args - command text after the claimed token.
|
|
45
|
+
* @param actx - current Session scope.
|
|
46
|
+
* @param attachments - serialized draft attachments accepted by the claim.
|
|
47
|
+
* @returns command settlement.
|
|
48
|
+
*/
|
|
49
|
+
submit(args: string, actx: Context, attachments: readonly SubmitAttachment[]): Promise<SubmitOutcome>;
|
|
50
|
+
}
|
|
51
|
+
/** Result of trigger-source adjudication. */
|
|
52
|
+
export type PickOutcome = {
|
|
53
|
+
readonly claim: CommandClaim;
|
|
54
|
+
} | {
|
|
55
|
+
readonly insert: ReferenceInsert;
|
|
56
|
+
} | {
|
|
57
|
+
readonly text: string;
|
|
58
|
+
readonly continue?: boolean;
|
|
59
|
+
} | 'handled' | undefined;
|
|
60
|
+
/** Scoped request to enter command mode. */
|
|
61
|
+
export interface BeginCommandRequest {
|
|
62
|
+
readonly claim: CommandClaim;
|
|
63
|
+
readonly span: TokenSpan;
|
|
64
|
+
}
|
|
65
|
+
/** Scoped request to insert a structured reference. */
|
|
66
|
+
export interface InsertReferenceRequest {
|
|
67
|
+
readonly reference: ReferenceInsert;
|
|
68
|
+
readonly span: TokenSpan;
|
|
69
|
+
}
|
|
70
|
+
/** Scoped request to consume a command token after business settlement. */
|
|
71
|
+
export interface ConsumeTokenRequest {
|
|
72
|
+
readonly guard: {
|
|
73
|
+
readonly kind: 'span';
|
|
74
|
+
readonly span: TokenSpan;
|
|
75
|
+
} | {
|
|
76
|
+
readonly kind: 'bare-token';
|
|
77
|
+
readonly token: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Scoped request to insert ordinary completion text. */
|
|
81
|
+
export interface InsertTextRequest {
|
|
82
|
+
readonly text: string;
|
|
83
|
+
readonly span: TokenSpan;
|
|
84
|
+
readonly continue?: boolean;
|
|
85
|
+
}
|
|
86
|
+
/** Trigger hit used to open one source programmatically. */
|
|
87
|
+
export interface InputTriggerHit {
|
|
88
|
+
readonly trigger: '/' | '@';
|
|
89
|
+
readonly query: string;
|
|
90
|
+
readonly quoted: boolean;
|
|
91
|
+
readonly position: 'leading' | 'inline';
|
|
92
|
+
readonly span: TokenSpan;
|
|
93
|
+
}
|
|
94
|
+
/** Structural per-Session trigger provider consumed by the input shell. */
|
|
95
|
+
export interface InputTriggerController {
|
|
96
|
+
readonly launcher: ObservableSnapshot<string | null>;
|
|
97
|
+
readonly lexicon: ObservableSnapshot<ReadonlyMap<'/' | '@', readonly string[]>>;
|
|
98
|
+
/** @param draft - current draft. @param caret - caret offset. @param guard - availability tier. @param draftRev - input revision. */
|
|
99
|
+
track(draft: string, caret: number, guard: {
|
|
100
|
+
readonly tier: 'plain' | 'claimed' | 'frozen';
|
|
101
|
+
}, draftRev: number): void;
|
|
102
|
+
/** @param key - intercepted key. @param composing - whether IME composition is active. @returns routing result. */
|
|
103
|
+
arbitrate(key: ArbitrateKey, composing: boolean): ArbitrateOutcome;
|
|
104
|
+
/** @returns whether Space applied a trigger result. */
|
|
105
|
+
onSpace(): boolean;
|
|
106
|
+
/** @param source - reference source. @param ref - source-local id. @param signal - submit cancellation. @returns model text. */
|
|
107
|
+
serializeReference(source: string, ref: string, signal: AbortSignal): Promise<string>;
|
|
108
|
+
/** @param line - trimmed draft. @param signal - submit cancellation. @param envelope - attachment count. @returns winning result. */
|
|
109
|
+
adjudicate(line: string, signal: AbortSignal, envelope: {
|
|
110
|
+
readonly attachments: number;
|
|
111
|
+
}): Promise<PickOutcome>;
|
|
112
|
+
/**
|
|
113
|
+
* @param source - chip owner, or undefined for a text reference.
|
|
114
|
+
* @param reference - source id and glyph.
|
|
115
|
+
* @returns whether a preview opened.
|
|
116
|
+
*/
|
|
117
|
+
openReference(source: string | undefined, reference: Pick<ReferenceInsert, 'ref' | 'appearance'>): boolean;
|
|
118
|
+
/** @param source - source name. @param hit - synthetic trigger hit. */
|
|
119
|
+
toggleSource(source: string, hit: InputTriggerHit): void;
|
|
120
|
+
}
|
|
121
|
+
declare module '@qilin-agent/kylin' {
|
|
122
|
+
interface Events {
|
|
123
|
+
/**
|
|
124
|
+
* Claim a command token for the scoped input machine.
|
|
125
|
+
* @param request - command claim and span.
|
|
126
|
+
* @mode bail
|
|
127
|
+
*/
|
|
128
|
+
'slash/input-begin-command'(request: BeginCommandRequest): true | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Insert a structured reference into the scoped input machine.
|
|
131
|
+
* @param request - reference and span.
|
|
132
|
+
* @mode bail
|
|
133
|
+
*/
|
|
134
|
+
'slash/input-insert-reference'(request: InsertReferenceRequest): true | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Consume a trigger token without inserting replacement content.
|
|
137
|
+
* @param request - token guard.
|
|
138
|
+
* @mode bail
|
|
139
|
+
*/
|
|
140
|
+
'slash/input-consume-token'(request: ConsumeTokenRequest): true | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Insert plain text into the scoped input machine.
|
|
143
|
+
* @param request - plain text and span.
|
|
144
|
+
* @mode bail
|
|
145
|
+
*/
|
|
146
|
+
'slash/input-insert-text'(request: InsertTextRequest): true | undefined;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/** Browser-runtime identity of one unsent attachment draft. */
|
|
150
|
+
export type DraftAttachmentId = Branded<'DraftAttachmentId'>;
|
|
151
|
+
/**
|
|
152
|
+
* The scoped-event application verbs: the hub's bail listeners call these,
|
|
153
|
+
* and the boolean answer IS the event's bail value (true ⟺ the editor
|
|
154
|
+
* applied the edit after phase and span guards).
|
|
155
|
+
*/
|
|
156
|
+
export interface InputTarget {
|
|
157
|
+
/** Replace the trigger span with claim.token and enter claimed (span-CAS'd). */
|
|
158
|
+
beginCommand(claim: CommandClaim, span: TokenSpan): boolean;
|
|
159
|
+
/** Replace the trigger span with one reference chip (span-CAS'd). */
|
|
160
|
+
insertReference(ref: ReferenceInsert, span: TokenSpan): boolean;
|
|
161
|
+
}
|
|
162
|
+
/** Per-session input facade owned by the conversation wiring layer. */
|
|
163
|
+
export interface SessionInput extends InputTarget {
|
|
164
|
+
/** Replace the whole draft (persisted-draft seed and programmatic writes). */
|
|
165
|
+
setDraft(text: string): void;
|
|
166
|
+
/** Append ordered browser-owned attachment ids; busy admission phases refuse. */
|
|
167
|
+
addAttachments(ids: readonly DraftAttachmentId[]): boolean;
|
|
168
|
+
/** Remove one browser-owned attachment id; busy admission phases refuse. @returns whether the id was removed. */
|
|
169
|
+
removeAttachment(id: DraftAttachmentId): boolean;
|
|
170
|
+
/** Drop ids whose browser-owned objects no longer exist. */
|
|
171
|
+
pruneAttachments(ids: readonly DraftAttachmentId[]): void;
|
|
172
|
+
/**
|
|
173
|
+
* THE complexity sink: enter adjudication, submit transaction, and the default sink live inside.
|
|
174
|
+
* @param mode - delivery intent retained through asynchronous adjudication and serialization.
|
|
175
|
+
*/
|
|
176
|
+
submit(mode?: InputSubmitMode): void;
|
|
177
|
+
/**
|
|
178
|
+
* Surface a notice outside the machine's own effect stream: detached
|
|
179
|
+
* command results and business notifications render through here.
|
|
180
|
+
* Session-routed — resolving the facade via SessionInputResolver.for(actx) lands
|
|
181
|
+
* the notice on that session's composer, so a result arriving after a
|
|
182
|
+
* session switch still reaches its own session.
|
|
183
|
+
* @param level - severity tier.
|
|
184
|
+
* @param text - notice body.
|
|
185
|
+
*/
|
|
186
|
+
notify(level: 'info' | 'error', text: string): void;
|
|
187
|
+
/**
|
|
188
|
+
* Return the keyboard to the composer with the caret it last held, for
|
|
189
|
+
* callers that took focus away from it (an overlay that held its own).
|
|
190
|
+
*/
|
|
191
|
+
focus(): void;
|
|
192
|
+
/** Input state store (InputZone currency + decorations read here). */
|
|
193
|
+
readonly state: SnapshotStore<InputState>;
|
|
194
|
+
}
|
|
195
|
+
/** Session-addressed access to the per-session input facade. */
|
|
196
|
+
export interface SessionInputResolver {
|
|
197
|
+
/** Resolve the facade for one session-scope ctx. */
|
|
198
|
+
for(actx: Context): SessionInput;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The public input action face provided to every session-scope slot
|
|
202
|
+
* component: stable-identity void callbacks, mirroring the
|
|
203
|
+
* useStore+actions convention. Command-style handles (arbitrate/space/
|
|
204
|
+
* paste/…) stay InputBar-private and never ride this face.
|
|
205
|
+
*/
|
|
206
|
+
export interface InputActions {
|
|
207
|
+
/** @returns a revision-guarded copy of the current editor selection. */
|
|
208
|
+
captureInsertion(): TokenSpan;
|
|
209
|
+
/**
|
|
210
|
+
* Insert asynchronous text without replacing subsequent edits or reference chips.
|
|
211
|
+
* @param text - plain text to insert in one undo step.
|
|
212
|
+
* @param span - captured selection and draft revision.
|
|
213
|
+
* @returns false when the draft changed or submission locked the editor.
|
|
214
|
+
*/
|
|
215
|
+
insertText(text: string, span: TokenSpan): boolean;
|
|
216
|
+
/** Replace the whole draft (persisted-draft seed and programmatic writes). */
|
|
217
|
+
setDraft(text: string): void;
|
|
218
|
+
/** Append ordered browser-owned attachment ids; busy admission phases refuse. */
|
|
219
|
+
addAttachments(ids: readonly DraftAttachmentId[]): boolean;
|
|
220
|
+
/** Remove one browser-owned attachment id; busy admission phases refuse. */
|
|
221
|
+
removeAttachment(id: DraftAttachmentId): void;
|
|
222
|
+
/** Drop ids whose browser-owned objects no longer exist. */
|
|
223
|
+
pruneAttachments(ids: readonly DraftAttachmentId[]): void;
|
|
224
|
+
/** Enter submission (adjudication / claim transaction / default sink inside). */
|
|
225
|
+
submit(): void;
|
|
226
|
+
}
|
|
227
|
+
/** One surfaced notice (command results, adjudication failures). seq keys re-render of repeats. */
|
|
228
|
+
export interface InputNotice {
|
|
229
|
+
readonly level: 'info' | 'error';
|
|
230
|
+
readonly text: string;
|
|
231
|
+
readonly seq: number;
|
|
232
|
+
}
|
|
233
|
+
/** Guard union of the scoped consume-token event, checked by the shell. */
|
|
234
|
+
export type ConsumeTokenGuard = ConsumeTokenRequest['guard'];
|
|
235
|
+
/** Published input state (the currency; per-session). */
|
|
236
|
+
export interface InputState {
|
|
237
|
+
/** Clipboard-text projection of the editor document (chips expanded to their clipboard form). */
|
|
238
|
+
readonly draft: string;
|
|
239
|
+
/** Ordered runtime-only attachment ids; browser objects stay in ConversationController. */
|
|
240
|
+
readonly attachmentIds: readonly DraftAttachmentId[];
|
|
241
|
+
/** Monotonic editor revision (span CAS compares against this). */
|
|
242
|
+
readonly draftRev: number;
|
|
243
|
+
readonly phase: 'plain' | 'adjudicating' | 'claimed' | 'submitting';
|
|
244
|
+
/** Present exactly while claimed/submitting (claim snapshot during flight; submit closure withheld). */
|
|
245
|
+
readonly claim?: {
|
|
246
|
+
readonly name: string;
|
|
247
|
+
readonly token: string;
|
|
248
|
+
readonly hint?: string;
|
|
249
|
+
readonly attachments?: boolean;
|
|
250
|
+
};
|
|
251
|
+
/** Reference occurrence view of the editor's chips, sorted by offset. */
|
|
252
|
+
readonly occurrences: readonly Occurrence[];
|
|
253
|
+
/** Messages still waiting for their own turn. */
|
|
254
|
+
readonly queue: InboxState['next-turn'];
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* One in-flight submission attempt: the ONLY id concept in the submit plane.
|
|
258
|
+
* Created on enter; carried by adjudicated/submit-settled/sink-settled
|
|
259
|
+
* events; stale attempts are dropped (anti-backwash). Command attempts hold
|
|
260
|
+
* the single frozen in-flight slot; default-sink attempts run detached and
|
|
261
|
+
* concurrently. release/session teardown aborts them all, keeping every
|
|
262
|
+
* promise bounded.
|
|
263
|
+
*/
|
|
264
|
+
export interface SubmitAttempt {
|
|
265
|
+
readonly seq: number;
|
|
266
|
+
readonly signal: AbortSignal;
|
|
267
|
+
/** Clipboard-projection draft captured before an optimistic default-send commit. */
|
|
268
|
+
readonly draftSnapshot: string;
|
|
269
|
+
/** Default-message delivery intent retained while slash adjudication is pending. */
|
|
270
|
+
readonly mode: InputSubmitMode;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Submit-machine input events (the machine's single write path). Text
|
|
274
|
+
* mutation lives in the editor; the machine only observes the draft through
|
|
275
|
+
* event payloads (claim integrity, enter snapshots, settlement decisions).
|
|
276
|
+
*/
|
|
277
|
+
export type InputEvent =
|
|
278
|
+
/** Clipboard projection changed: the claimed integrity watch runs (zero effects). */
|
|
279
|
+
{
|
|
280
|
+
readonly type: 'draft-changed';
|
|
281
|
+
readonly draft: string;
|
|
282
|
+
}
|
|
283
|
+
/** The editor applied a claim-token replacement: enter claimed. */
|
|
284
|
+
| {
|
|
285
|
+
readonly type: 'claim';
|
|
286
|
+
readonly claim: CommandClaim;
|
|
287
|
+
}
|
|
288
|
+
/** Enter submission with the current clipboard projection. */
|
|
289
|
+
| {
|
|
290
|
+
readonly type: 'enter';
|
|
291
|
+
readonly mode: InputSubmitMode;
|
|
292
|
+
readonly draft: string;
|
|
293
|
+
} | {
|
|
294
|
+
readonly type: 'adjudicated';
|
|
295
|
+
readonly attempt: SubmitAttempt;
|
|
296
|
+
readonly outcome: PickOutcome;
|
|
297
|
+
} | {
|
|
298
|
+
readonly type: 'adjudication-failed';
|
|
299
|
+
readonly attempt: SubmitAttempt;
|
|
300
|
+
readonly message: string;
|
|
301
|
+
}
|
|
302
|
+
/** Settlement carries the live clipboard projection for suffix-retention and claim re-entry decisions. */
|
|
303
|
+
| {
|
|
304
|
+
readonly type: 'submit-settled';
|
|
305
|
+
readonly attempt: SubmitAttempt;
|
|
306
|
+
readonly ok: boolean;
|
|
307
|
+
readonly draft: string;
|
|
308
|
+
readonly outcome?: SubmitOutcome;
|
|
309
|
+
readonly message?: string;
|
|
310
|
+
}
|
|
311
|
+
/** Settlement of one optimistic default send, independent of the frozen command slot. */
|
|
312
|
+
| {
|
|
313
|
+
readonly type: 'sink-settled';
|
|
314
|
+
readonly attempt: SubmitAttempt;
|
|
315
|
+
readonly ok: boolean;
|
|
316
|
+
readonly outcome?: SubmitOutcome;
|
|
317
|
+
readonly message?: string;
|
|
318
|
+
}
|
|
319
|
+
/** Commit an attachment-only send whose empty draft did not need an attempt. */
|
|
320
|
+
| {
|
|
321
|
+
readonly type: 'send-committed';
|
|
322
|
+
} | {
|
|
323
|
+
readonly type: 'release';
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Submit-machine output effects (executed by the SessionInput shell; the
|
|
327
|
+
* machine stays pure).
|
|
328
|
+
*/
|
|
329
|
+
export type InputEffect = {
|
|
330
|
+
readonly type: 'adjudicate';
|
|
331
|
+
readonly attempt: SubmitAttempt;
|
|
332
|
+
readonly draft: string;
|
|
333
|
+
} | {
|
|
334
|
+
readonly type: 'begin-submit';
|
|
335
|
+
readonly attempt: SubmitAttempt;
|
|
336
|
+
readonly claim: CommandClaim;
|
|
337
|
+
readonly args: string;
|
|
338
|
+
}
|
|
339
|
+
/** Detached default send; the shell captures its editor projection before the following commit effect. */
|
|
340
|
+
| {
|
|
341
|
+
readonly type: 'default-sink';
|
|
342
|
+
readonly attempt: SubmitAttempt;
|
|
343
|
+
readonly draft: string;
|
|
344
|
+
readonly mode: InputSubmitMode;
|
|
345
|
+
} | {
|
|
346
|
+
readonly type: 'notice';
|
|
347
|
+
readonly level: 'info' | 'error';
|
|
348
|
+
readonly text: string;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Clear the committed draft in the editor and cut undo history. A string
|
|
352
|
+
* snapshot keeps a pure suffix typed during the Host round-trip (content
|
|
353
|
+
* appended after the sent snapshot survives; interleaved edits cannot be
|
|
354
|
+
* separated and clear whole); null clears unconditionally (attachment-only
|
|
355
|
+
* sends have no draft to retain).
|
|
356
|
+
*/
|
|
357
|
+
| {
|
|
358
|
+
readonly type: 'commit-draft';
|
|
359
|
+
readonly retainSuffixOf: string | null;
|
|
360
|
+
};
|
|
361
|
+
//# sourceMappingURL=input.d.ts.map
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import type { CommandId } from '@qilin-agent/commands/brand';
|
|
2
|
+
import type { MessageId } from '@qilin-agent/llm/brand';
|
|
3
|
+
import type { ContentBlock } from '@qilin-agent/llm/types';
|
|
4
|
+
import type { ImageAttachmentRef } from '@qilin-agent/attachment';
|
|
5
|
+
import type { LlmRetryEventData } from '@qilin-agent/llm-retry/types';
|
|
6
|
+
import type { TodoItem } from '@qilin-agent/tool-todo/client';
|
|
7
|
+
import type { ContextProducerView, KnownContextForm } from './context-producer.ts';
|
|
8
|
+
import type { PartialArguments } from '@qilin-agent/util-values';
|
|
9
|
+
export type { TodoItem };
|
|
10
|
+
/** Request configuration recorded for one provider call. */
|
|
11
|
+
export interface AssistantRequestConfig {
|
|
12
|
+
provider: string;
|
|
13
|
+
model: string;
|
|
14
|
+
purpose?: string;
|
|
15
|
+
thinking?: string;
|
|
16
|
+
reasoningEffort?: string;
|
|
17
|
+
temperature?: number;
|
|
18
|
+
maxTokens?: number;
|
|
19
|
+
stop?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/** Stable provider/model identity reported for one completed request. */
|
|
22
|
+
export interface AssistantProviderMetadataView {
|
|
23
|
+
provider: string;
|
|
24
|
+
model: string;
|
|
25
|
+
}
|
|
26
|
+
/** Assistant content blocks sorted by what a UI target presents. */
|
|
27
|
+
export type AssistantBlock = {
|
|
28
|
+
kind: 'text';
|
|
29
|
+
text: string;
|
|
30
|
+
} | {
|
|
31
|
+
kind: 'reasoning';
|
|
32
|
+
text: string;
|
|
33
|
+
} | {
|
|
34
|
+
kind: 'image';
|
|
35
|
+
attachment: ImageAttachmentRef;
|
|
36
|
+
} | {
|
|
37
|
+
kind: 'tool-call';
|
|
38
|
+
callId: string;
|
|
39
|
+
name: string;
|
|
40
|
+
argsRaw: string;
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'other';
|
|
43
|
+
block: unknown;
|
|
44
|
+
};
|
|
45
|
+
/** A finalized user message. */
|
|
46
|
+
export interface UserMessageNode {
|
|
47
|
+
kind: 'user';
|
|
48
|
+
seq: number;
|
|
49
|
+
/** Unix epoch ms from the source session event. */
|
|
50
|
+
time: number;
|
|
51
|
+
content: readonly ContentBlock[];
|
|
52
|
+
source: unknown;
|
|
53
|
+
}
|
|
54
|
+
/** Recorded boundaries used to derive assistant latency and throughput. */
|
|
55
|
+
export interface AssistantTiming {
|
|
56
|
+
/** Matching step/start timestamp, or null when it is outside the current event window. */
|
|
57
|
+
stepStartTime: number | null;
|
|
58
|
+
/** First non-empty text/reasoning/tool delta timestamp, or null when no token delta was recorded. */
|
|
59
|
+
firstTokenTime: number | null;
|
|
60
|
+
/** Final assistant/message timestamp. */
|
|
61
|
+
completedTime: number;
|
|
62
|
+
}
|
|
63
|
+
/** A finalized assistant message or an interruption-frozen streaming prefix. */
|
|
64
|
+
export interface AssistantMessageNode {
|
|
65
|
+
kind: 'assistant';
|
|
66
|
+
seq: number;
|
|
67
|
+
/**
|
|
68
|
+
* Stable identity carried from the `assistant/message` event. Absent only on
|
|
69
|
+
* synthetic interruption fallbacks assembled from chunks without a durable
|
|
70
|
+
* assistant message.
|
|
71
|
+
*/
|
|
72
|
+
messageId?: MessageId;
|
|
73
|
+
/** Unix epoch ms from the source session event (or turn/end when frozen from a partial). */
|
|
74
|
+
time: number;
|
|
75
|
+
turn: number;
|
|
76
|
+
step: number;
|
|
77
|
+
blocks: readonly AssistantBlock[];
|
|
78
|
+
usage?: unknown;
|
|
79
|
+
providerMetadata?: AssistantProviderMetadataView;
|
|
80
|
+
requestConfig?: AssistantRequestConfig;
|
|
81
|
+
/** Timing derived from the recorded step/chunk/message event sequence. */
|
|
82
|
+
timing?: AssistantTiming;
|
|
83
|
+
/** Prefix of an aborted turn, rendered with a 已停止 marker. A durable
|
|
84
|
+
* finalized prefix uses its event seq; a chunk-only fallback uses a fractional
|
|
85
|
+
* seq derived from the closing boundary to keep it ordered inside the flow. */
|
|
86
|
+
interrupted?: true;
|
|
87
|
+
}
|
|
88
|
+
/** A human message admitted from the next-step inbox while a turn was running. */
|
|
89
|
+
export interface SteeringMessageNode {
|
|
90
|
+
kind: 'steering';
|
|
91
|
+
/** Stable message identity shared with its pre-admission inbox occurrence. */
|
|
92
|
+
messageId: MessageId;
|
|
93
|
+
seq: number;
|
|
94
|
+
/** Unix epoch ms from the source session event. */
|
|
95
|
+
time: number;
|
|
96
|
+
content: readonly ContentBlock[];
|
|
97
|
+
source: unknown;
|
|
98
|
+
}
|
|
99
|
+
/** A context/system injection surfaced in the flow. */
|
|
100
|
+
export interface ContextMessageNode {
|
|
101
|
+
kind: 'context';
|
|
102
|
+
seq: number;
|
|
103
|
+
/** Unix epoch ms from the source session event. */
|
|
104
|
+
time: number;
|
|
105
|
+
content: readonly ContentBlock[];
|
|
106
|
+
source: unknown;
|
|
107
|
+
/** Role and producer name projected from `source` by the target. */
|
|
108
|
+
producer: ContextProducerView;
|
|
109
|
+
/** Producer-declared information form supported by the target; null presents as opaque. */
|
|
110
|
+
form: KnownContextForm | null;
|
|
111
|
+
}
|
|
112
|
+
/** Durable notice that a closed failed step is waiting for a model-request retry. */
|
|
113
|
+
export type ModelRetryNode = LlmRetryEventData & {
|
|
114
|
+
kind: 'model-retry';
|
|
115
|
+
seq: number;
|
|
116
|
+
/** Unix epoch ms from the llm/retry session event. */
|
|
117
|
+
time: number;
|
|
118
|
+
/**
|
|
119
|
+
* Client-derived lifecycle: scheduled until a retry turn starts, started
|
|
120
|
+
* once it does, or cancelled when the failed turn aborts first.
|
|
121
|
+
*/
|
|
122
|
+
retryState: 'scheduled' | 'started' | 'cancelled';
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Durable terminal failure for a turn that ended with an error reason; the
|
|
126
|
+
* turn's settled retry chain renders separately and never replaces this node.
|
|
127
|
+
*/
|
|
128
|
+
export interface TurnErrorNode {
|
|
129
|
+
kind: 'turn-error';
|
|
130
|
+
/** Seq of the owning turn/end event. */
|
|
131
|
+
seq: number;
|
|
132
|
+
/** Unix epoch ms from the turn/end event. */
|
|
133
|
+
time: number;
|
|
134
|
+
turn: number;
|
|
135
|
+
step: number;
|
|
136
|
+
/** Sanitized provider message; empty when a known code owns localized copy. */
|
|
137
|
+
message: string;
|
|
138
|
+
/** Stable provider failure code, when recorded. */
|
|
139
|
+
code?: string;
|
|
140
|
+
}
|
|
141
|
+
/** Durable notice for a turn ended by the per-request output-token cap. */
|
|
142
|
+
export interface TurnMaxTokensNode {
|
|
143
|
+
kind: 'turn-max-tokens';
|
|
144
|
+
/** Seq of the owning turn/end event. */
|
|
145
|
+
seq: number;
|
|
146
|
+
/** Unix epoch ms from the turn/end event. */
|
|
147
|
+
time: number;
|
|
148
|
+
turn: number;
|
|
149
|
+
step: number;
|
|
150
|
+
}
|
|
151
|
+
/** A tool result paired (when in-window) with its call head. */
|
|
152
|
+
export interface ToolResultNode {
|
|
153
|
+
kind: 'tool-result';
|
|
154
|
+
seq: number;
|
|
155
|
+
/** Unix epoch ms from the tool/result session event. */
|
|
156
|
+
time: number;
|
|
157
|
+
callId: string;
|
|
158
|
+
/** Parent Tool call for a PTC dispatch result; absent on a root Session result. */
|
|
159
|
+
parentCallId?: string;
|
|
160
|
+
/** Wire tool name from the paired tool/call; empty when that call left the loaded window. */
|
|
161
|
+
name: string;
|
|
162
|
+
/** The argument view of the paired call; see {@link ToolArgs}. */
|
|
163
|
+
args: ToolArgs;
|
|
164
|
+
/** Call head backfilled from the in-window tool/call; null when window truncation left the call outside (card head shows callId). */
|
|
165
|
+
call: {
|
|
166
|
+
name: string;
|
|
167
|
+
argsRaw: string;
|
|
168
|
+
} | null;
|
|
169
|
+
/** Unix epoch ms of the paired tool/call when the call is still in-window; used for call-row duration. */
|
|
170
|
+
callTime: number | null;
|
|
171
|
+
content: readonly ContentBlock[];
|
|
172
|
+
isError: boolean;
|
|
173
|
+
error?: {
|
|
174
|
+
name: string;
|
|
175
|
+
code: string;
|
|
176
|
+
reason?: string;
|
|
177
|
+
};
|
|
178
|
+
meta?: unknown;
|
|
179
|
+
/** Child calls owned by this call, in dispatch order. */
|
|
180
|
+
subCalls: readonly ToolCallBlock[];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* One landed compaction, marked at the checkpoint's own log position. The
|
|
184
|
+
* conversation it shadowed on the model surface stays in the transcript above
|
|
185
|
+
* it: the marker reports where the model stopped seeing that history, it does
|
|
186
|
+
* not replace it. The framed checkpoint payload is an instruction envelope
|
|
187
|
+
* written for the model and never renders.
|
|
188
|
+
*/
|
|
189
|
+
export interface CompactionSummaryNode {
|
|
190
|
+
kind: 'compaction';
|
|
191
|
+
/** Seq of the replacement `user/message` that landed the checkpoint. */
|
|
192
|
+
seq: number;
|
|
193
|
+
/** Unix epoch ms of the checkpoint event. */
|
|
194
|
+
time: number;
|
|
195
|
+
/** Summary text from the checkpoint's cited `compaction/summary` event; null when
|
|
196
|
+
* the window cut left that event outside (the marker is then not expandable). */
|
|
197
|
+
summary: string | null;
|
|
198
|
+
/** Seq of the loaded `compaction/summary` event, or null when that event is outside the window. */
|
|
199
|
+
summaryEventSeq: number | null;
|
|
200
|
+
/** Number of surface items replaced, or null when the summary event is unavailable or malformed. */
|
|
201
|
+
shadowedItemCount: number | null;
|
|
202
|
+
/** Estimated token price of the replaced items, or null when the summary event is unavailable or malformed. */
|
|
203
|
+
shadowedTokenCount: number | null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Fallback for surface events this UI version does not know: the documented
|
|
207
|
+
* default arm of `SessionEventMap`, which is merge-extensible, so the
|
|
208
|
+
* projection's switch cannot end in `assertNever`. No event produces this node
|
|
209
|
+
* because `isAppendSurfaceEvent` admits only the four types in core's
|
|
210
|
+
* `SurfaceEventType`, and each has its own arm (`system/message` is claimed by
|
|
211
|
+
* a Chat Definition that renders no transcript row) — and it exists so widening
|
|
212
|
+
* that set core-side degrades to a raw row instead of dropping the event silently.
|
|
213
|
+
*/
|
|
214
|
+
export interface UnknownSurfaceNode {
|
|
215
|
+
kind: 'unknown';
|
|
216
|
+
seq: number;
|
|
217
|
+
/** Unix epoch ms from the source session event when known. */
|
|
218
|
+
time: number;
|
|
219
|
+
type: string;
|
|
220
|
+
data: unknown;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* One slash-command lifecycle folded from the log-only `command/run` /
|
|
224
|
+
* `command/done` pair (paired by commandId, mirroring tool call↔result).
|
|
225
|
+
* Log-only events are not surface events, so the command Definition indexes
|
|
226
|
+
* them separately and the Chat builder orders the resulting node by seq. A window cut
|
|
227
|
+
* between the pair soft-falls like tool pairs: a done with no in-window run
|
|
228
|
+
* still builds a node (name/args null), and a run with no done renders as
|
|
229
|
+
* still executing.
|
|
230
|
+
*/
|
|
231
|
+
export interface CommandNode {
|
|
232
|
+
kind: 'command';
|
|
233
|
+
/** Seq of the command/run event; the done event's seq when only the done is in-window. */
|
|
234
|
+
seq: number;
|
|
235
|
+
/** Unix epoch ms of the anchoring event. */
|
|
236
|
+
time: number;
|
|
237
|
+
/** Pairing id minted by the host executor. */
|
|
238
|
+
commandId: CommandId;
|
|
239
|
+
/** Command name (run payload's structured field); null when the run fell outside the window. */
|
|
240
|
+
name: string | null;
|
|
241
|
+
/**
|
|
242
|
+
* Verbatim rawInput after the name, including separator whitespace; null
|
|
243
|
+
* when omitted by the command or when the run fell outside the window.
|
|
244
|
+
*/
|
|
245
|
+
args: string | null;
|
|
246
|
+
/** Settlement outcome (done payload); null while the command is still executing. */
|
|
247
|
+
outcome: {
|
|
248
|
+
kind: 'success' | 'error';
|
|
249
|
+
text?: string;
|
|
250
|
+
/** Earlier authoritative domain event for a richer client-computed presentation. */
|
|
251
|
+
sourceEventSeq?: number;
|
|
252
|
+
} | null;
|
|
253
|
+
}
|
|
254
|
+
/** Finalized conversation node union (kind discriminates; seq is the React key). */
|
|
255
|
+
export type ConversationNode = UserMessageNode | AssistantMessageNode | SteeringMessageNode | ContextMessageNode | ModelRetryNode | TurnErrorNode | TurnMaxTokensNode | ToolResultNode | CommandNode | CompactionSummaryNode | UnknownSurfaceNode;
|
|
256
|
+
/** Identity and placement shared by tool preparation and dispatch. */
|
|
257
|
+
interface ToolCallHead {
|
|
258
|
+
callId: string;
|
|
259
|
+
/** Parent Tool call for a PTC dispatch start; absent on a root Session call. */
|
|
260
|
+
parentCallId?: string;
|
|
261
|
+
name: string;
|
|
262
|
+
turn: number;
|
|
263
|
+
step: number;
|
|
264
|
+
/** Unix epoch ms when this stage began. */
|
|
265
|
+
time: number;
|
|
266
|
+
/** Child calls owned by this call, in dispatch order. */
|
|
267
|
+
subCalls: readonly ToolCallBlock[];
|
|
268
|
+
/** The argument view; see {@link ToolArgs}. */
|
|
269
|
+
args: ToolArgs;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Lazy top-level argument readers shared by preparing, start, and result;
|
|
273
|
+
* {@link PartialArguments} defines field, prefix, length, and completion reads.
|
|
274
|
+
* A preparing view grows in place. Read it during render or view construction,
|
|
275
|
+
* not into independent state keyed only by the args or block object identity.
|
|
276
|
+
* The Definition publishes the initial named block, then republishes when an
|
|
277
|
+
* observed answer changes. Unread fields alone do not request republication.
|
|
278
|
+
* Dispatched views are sealed over finished text or parsed values. The view is
|
|
279
|
+
* empty for a result whose `tool/call` left the loaded window.
|
|
280
|
+
*/
|
|
281
|
+
export type ToolArgs = PartialArguments;
|
|
282
|
+
/** A named model call whose complete arguments are not yet available to tool views. */
|
|
283
|
+
export interface PreparingToolCall extends ToolCallHead {
|
|
284
|
+
readonly phase: 'preparing';
|
|
285
|
+
}
|
|
286
|
+
/** A dispatched tool call with complete arguments and no result yet. */
|
|
287
|
+
export interface StartedToolCall extends ToolCallHead {
|
|
288
|
+
readonly phase: 'start';
|
|
289
|
+
readonly argsRaw: string;
|
|
290
|
+
}
|
|
291
|
+
/** A tool still preparing or awaiting its result. */
|
|
292
|
+
export type RunningToolCall = PreparingToolCall | StartedToolCall;
|
|
293
|
+
/** One preparing, dispatched, or settled call, recursively owning its child calls. */
|
|
294
|
+
export type ToolCallBlock = RunningToolCall | ToolResultNode;
|
|
295
|
+
/** In-progress assistant output (chunk accumulator product). */
|
|
296
|
+
export interface PartialAssistant {
|
|
297
|
+
turn: number;
|
|
298
|
+
step: number;
|
|
299
|
+
blocks: readonly AssistantBlock[];
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=records.d.ts.map
|