@crazx/dsh-client-ui-conversation 0.1.5-alpha.1.zw.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +127 -0
  4. package/README.zh.md +127 -0
  5. package/lib/client.js +16935 -0
  6. package/lib/index.js +27 -0
  7. package/lib/types/client/apply.d.ts +25 -0
  8. package/lib/types/client/context-occupancy.d.ts +14 -0
  9. package/lib/types/client/contract/composer-blocks.d.ts +28 -0
  10. package/lib/types/client/contract/composer-submission.d.ts +8 -0
  11. package/lib/types/client/contract/context-provenance.d.ts +29 -0
  12. package/lib/types/client/contract/conversation.d.ts +256 -0
  13. package/lib/types/client/contract/input.d.ts +427 -0
  14. package/lib/types/client/contract/queue.d.ts +9 -0
  15. package/lib/types/client/contract/records.d.ts +272 -0
  16. package/lib/types/client/contract/request-inspection.d.ts +131 -0
  17. package/lib/types/client/contract/slots.d.ts +409 -0
  18. package/lib/types/client/contract/snapshot.d.ts +20 -0
  19. package/lib/types/client/contract/system-prompt.d.ts +35 -0
  20. package/lib/types/client/contract/views.d.ts +26 -0
  21. package/lib/types/client/conversation/assembler.d.ts +128 -0
  22. package/lib/types/client/conversation/assembly.d.ts +97 -0
  23. package/lib/types/client/conversation/definition-registry.d.ts +33 -0
  24. package/lib/types/client/conversation/event-registry.d.ts +24 -0
  25. package/lib/types/client/conversation/historical-images.d.ts +51 -0
  26. package/lib/types/client/conversation/location-index.d.ts +85 -0
  27. package/lib/types/client/conversation/view-registry.d.ts +12 -0
  28. package/lib/types/client/image-labels.d.ts +23 -0
  29. package/lib/types/client/index.d.ts +36 -0
  30. package/lib/types/client/input/blocks.d.ts +27 -0
  31. package/lib/types/client/input/decorations.d.ts +32 -0
  32. package/lib/types/client/input/editor/ComposerContentEditable.d.ts +16 -0
  33. package/lib/types/client/input/editor/DecoratorPortals.d.ts +14 -0
  34. package/lib/types/client/input/editor/ReferenceChip.d.ts +17 -0
  35. package/lib/types/client/input/editor/chip-node.d.ts +110 -0
  36. package/lib/types/client/input/editor/claim-decor.d.ts +23 -0
  37. package/lib/types/client/input/editor/keymap.d.ts +41 -0
  38. package/lib/types/client/input/editor/projection.d.ts +93 -0
  39. package/lib/types/client/input/editor/span-map.d.ts +38 -0
  40. package/lib/types/client/input/editor/text-ref.d.ts +60 -0
  41. package/lib/types/client/input/facade.d.ts +298 -0
  42. package/lib/types/client/input/hub.d.ts +88 -0
  43. package/lib/types/client/input/machine.d.ts +46 -0
  44. package/lib/types/client/input/queue-store.d.ts +20 -0
  45. package/lib/types/client/input/submission-policy.d.ts +52 -0
  46. package/lib/types/client/locales.d.ts +330 -0
  47. package/lib/types/client/queue/QueueDock.d.ts +26 -0
  48. package/lib/types/client/service.d.ts +185 -0
  49. package/lib/types/client/settings/EnterBehaviorRow.d.ts +21 -0
  50. package/lib/types/client/skeleton/ContextMeter.d.ts +14 -0
  51. package/lib/types/client/skeleton/ConversationRoot.d.ts +5 -0
  52. package/lib/types/client/skeleton/ConversationSession.d.ts +26 -0
  53. package/lib/types/client/skeleton/EmptyHero.d.ts +46 -0
  54. package/lib/types/client/skeleton/InputBar.d.ts +18 -0
  55. package/lib/types/client/skeleton/PermissionSelect.d.ts +11 -0
  56. package/lib/types/client/skeleton/TodoPanel.d.ts +21 -0
  57. package/lib/types/client/skeleton/safari.d.ts +18 -0
  58. package/lib/types/client/skeleton/toolbar-hosts.d.ts +17 -0
  59. package/lib/types/client/stores.d.ts +24 -0
  60. package/lib/types/client/view-selection.d.ts +9 -0
  61. package/lib/types/index.d.ts +9 -0
  62. package/lib/types/submission-settings.d.ts +20 -0
  63. package/package.json +103 -0
@@ -0,0 +1,272 @@
1
+ import type { CommandId } from '@deepseek-ai/dsh-commands/brand';
2
+ import type { MessageId } from '@deepseek-ai/dsh-llm/brand';
3
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm/types';
4
+ import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
5
+ import type { LlmRetryEventData } from '@deepseek-ai/dsh-llm-retry/types';
6
+ import type { TodoItem } from '@deepseek-ai/dsh-tool-todo/client';
7
+ import type { ContextProvenanceView, KnownContextForm } from './context-provenance.ts';
8
+ export type { TodoItem };
9
+ /** Request configuration recorded for one provider call. */
10
+ export interface AssistantRequestConfig {
11
+ provider: string;
12
+ model: string;
13
+ purpose?: string;
14
+ thinking?: string;
15
+ reasoningEffort?: string;
16
+ temperature?: number;
17
+ maxTokens?: number;
18
+ stop?: readonly string[];
19
+ }
20
+ /** Stable provider/model identity reported for one completed request. */
21
+ export interface AssistantProvenanceView {
22
+ provider: string;
23
+ model: string;
24
+ }
25
+ /** Assistant content blocks sorted by what a UI target presents. */
26
+ export type AssistantBlock = {
27
+ kind: 'text';
28
+ text: string;
29
+ } | {
30
+ kind: 'reasoning';
31
+ text: string;
32
+ } | {
33
+ kind: 'image';
34
+ attachment: ImageAttachmentRef;
35
+ } | {
36
+ kind: 'tool-call';
37
+ callId: string;
38
+ name: string;
39
+ argsRaw: string;
40
+ } | {
41
+ kind: 'other';
42
+ block: unknown;
43
+ };
44
+ /** A finalized user message. */
45
+ export interface UserMessageNode {
46
+ kind: 'user';
47
+ seq: number;
48
+ /** Unix epoch ms from the source session event. */
49
+ time: number;
50
+ content: readonly ContentBlock[];
51
+ source: unknown;
52
+ }
53
+ /** Recorded boundaries used to derive assistant latency and throughput. */
54
+ export interface AssistantTiming {
55
+ /** Matching step/start timestamp, or null when it is outside the current event window. */
56
+ stepStartTime: number | null;
57
+ /** First non-empty text/reasoning/tool delta timestamp, or null when no token delta was recorded. */
58
+ firstTokenTime: number | null;
59
+ /** Final assistant/message timestamp. */
60
+ completedTime: number;
61
+ }
62
+ /** A finalized assistant message or an interruption-frozen streaming prefix. */
63
+ export interface AssistantMessageNode {
64
+ kind: 'assistant';
65
+ seq: number;
66
+ /**
67
+ * Stable identity carried from the `assistant/message` event. Absent only on
68
+ * synthetic interruption fallbacks assembled from chunks without a durable
69
+ * assistant message.
70
+ */
71
+ messageId?: MessageId;
72
+ /** Unix epoch ms from the source session event (or turn/end when frozen from a partial). */
73
+ time: number;
74
+ turn: number;
75
+ step: number;
76
+ blocks: readonly AssistantBlock[];
77
+ usage?: unknown;
78
+ provenance?: AssistantProvenanceView;
79
+ requestConfig?: AssistantRequestConfig;
80
+ /** Timing derived from the recorded step/chunk/message event sequence. */
81
+ timing?: AssistantTiming;
82
+ /** Prefix of an aborted turn, rendered with a 已停止 marker. A durable
83
+ * finalized prefix uses its event seq; a chunk-only fallback uses a fractional
84
+ * seq derived from the closing boundary to keep it ordered inside the flow. */
85
+ interrupted?: true;
86
+ }
87
+ /** A human message admitted from the next-step inbox while a turn was running. */
88
+ export interface SteeringMessageNode {
89
+ kind: 'steering';
90
+ /** Stable message identity shared with its pre-admission inbox occurrence. */
91
+ messageId: MessageId;
92
+ seq: number;
93
+ /** Unix epoch ms from the source session event. */
94
+ time: number;
95
+ content: readonly ContentBlock[];
96
+ source: unknown;
97
+ }
98
+ /** A context/system injection surfaced in the flow. */
99
+ export interface ContextMessageNode {
100
+ kind: 'context';
101
+ seq: number;
102
+ /** Unix epoch ms from the source session event. */
103
+ time: number;
104
+ content: readonly ContentBlock[];
105
+ source: unknown;
106
+ /** Role and producer name projected from `source` by the target. */
107
+ provenance: ContextProvenanceView;
108
+ /** Producer-declared information form supported by the target; null presents as opaque. */
109
+ form: KnownContextForm | null;
110
+ }
111
+ /** Durable notice that a closed failed step is waiting for a model-request retry. */
112
+ export type ModelRetryNode = LlmRetryEventData & {
113
+ kind: 'model-retry';
114
+ seq: number;
115
+ /** Unix epoch ms from the llm/retry session event. */
116
+ time: number;
117
+ /**
118
+ * Client-derived lifecycle: scheduled until a retry turn starts, started
119
+ * once it does, or cancelled when the failed turn aborts first.
120
+ */
121
+ retryState: 'scheduled' | 'started' | 'cancelled';
122
+ };
123
+ /**
124
+ * Durable terminal failure for a turn that ended with an error reason; the
125
+ * turn's settled retry chain renders separately and never replaces this node.
126
+ */
127
+ export interface TurnErrorNode {
128
+ kind: 'turn-error';
129
+ /** Seq of the owning turn/end event. */
130
+ seq: number;
131
+ /** Unix epoch ms from the turn/end event. */
132
+ time: number;
133
+ turn: number;
134
+ step: number;
135
+ /** Sanitized provider message; empty when a known code owns localized copy. */
136
+ message: string;
137
+ /** Stable provider failure code, when recorded. */
138
+ code?: string;
139
+ }
140
+ /** Durable notice for a turn ended by the per-request output-token cap. */
141
+ export interface TurnMaxTokensNode {
142
+ kind: 'turn-max-tokens';
143
+ /** Seq of the owning turn/end event. */
144
+ seq: number;
145
+ /** Unix epoch ms from the turn/end event. */
146
+ time: number;
147
+ turn: number;
148
+ step: number;
149
+ }
150
+ /** A tool result paired (when in-window) with its call head. */
151
+ export interface ToolResultNode {
152
+ kind: 'tool-result';
153
+ seq: number;
154
+ /** Unix epoch ms from the tool/result session event. */
155
+ time: number;
156
+ callId: string;
157
+ /** Parent Tool call for a Code Dispatch result; absent on a root Session result. */
158
+ parentCallId?: string;
159
+ /** Call head backfilled from the in-window tool/call; null when window truncation left the call outside (card head shows callId). */
160
+ call: {
161
+ name: string;
162
+ argsRaw: string;
163
+ } | null;
164
+ /** Unix epoch ms of the paired tool/call when the call is still in-window; used for call-row duration. */
165
+ callTime: number | null;
166
+ content: readonly ContentBlock[];
167
+ isError: boolean;
168
+ error?: {
169
+ name: string;
170
+ code: string;
171
+ };
172
+ meta?: unknown;
173
+ /** Child calls owned by this call, in dispatch order. */
174
+ subCalls: readonly ToolCallBlock[];
175
+ }
176
+ /**
177
+ * One landed compaction, marked at the checkpoint's own log position. The
178
+ * conversation it shadowed on the model surface stays in the transcript above
179
+ * it: the marker reports where the model stopped seeing that history, it does
180
+ * not replace it. The framed checkpoint payload is an instruction envelope
181
+ * written for the model and never renders.
182
+ */
183
+ export interface CompactionSummaryNode {
184
+ kind: 'compaction';
185
+ /** Seq of the replacement `user/message` that landed the checkpoint. */
186
+ seq: number;
187
+ /** Unix epoch ms of the checkpoint event. */
188
+ time: number;
189
+ /** Summary text from the checkpoint's cited `compaction/summary` event; null when
190
+ * the window cut left that event outside (the marker is then not expandable). */
191
+ summary: string | null;
192
+ /** Seq of the loaded `compaction/summary` event, or null when that event is outside the window. */
193
+ summaryEventSeq: number | null;
194
+ /** Number of surface items replaced, or null when the summary event is unavailable or malformed. */
195
+ shadowedItemCount: number | null;
196
+ /** Estimated token price of the replaced items, or null when the summary event is unavailable or malformed. */
197
+ shadowedTokenCount: number | null;
198
+ }
199
+ /**
200
+ * Fallback for surface events this UI version does not know: the documented
201
+ * default arm of `SessionEventMap`, which is merge-extensible, so the
202
+ * projection's switch cannot end in `assertNever`. No event produces this node
203
+ * because `isAppendSurfaceEvent` admits only the four types in core's
204
+ * `SurfaceEventType`, and each has its own arm (`system/message` is claimed by
205
+ * a Chat Definition that renders no transcript row) — and it exists so widening
206
+ * that set core-side degrades to a raw row instead of dropping the event silently.
207
+ */
208
+ export interface UnknownSurfaceNode {
209
+ kind: 'unknown';
210
+ seq: number;
211
+ /** Unix epoch ms from the source session event when known. */
212
+ time: number;
213
+ type: string;
214
+ data: unknown;
215
+ }
216
+ /**
217
+ * One slash-command lifecycle folded from the log-only `command/run` /
218
+ * `command/done` pair (paired by commandId, mirroring tool call↔result).
219
+ * Log-only events are not surface events, so the command Definition indexes
220
+ * them separately and the Chat builder orders the resulting node by seq. A window cut
221
+ * between the pair soft-falls like tool pairs: a done with no in-window run
222
+ * still builds a node (name/args null), and a run with no done renders as
223
+ * still executing.
224
+ */
225
+ export interface CommandNode {
226
+ kind: 'command';
227
+ /** Seq of the command/run event; the done event's seq when only the done is in-window. */
228
+ seq: number;
229
+ /** Unix epoch ms of the anchoring event. */
230
+ time: number;
231
+ /** Pairing id minted by the host executor. */
232
+ commandId: CommandId;
233
+ /** Command name (run payload's structured field); null when the run fell outside the window. */
234
+ name: string | null;
235
+ /**
236
+ * Verbatim rawInput after the name, including separator whitespace; null
237
+ * when omitted by the command or when the run fell outside the window.
238
+ */
239
+ args: string | null;
240
+ /** Settlement outcome (done payload); null while the command is still executing. */
241
+ outcome: {
242
+ kind: 'success' | 'error';
243
+ text?: string;
244
+ /** Earlier authoritative domain event for a richer client-computed presentation. */
245
+ sourceEventSeq?: number;
246
+ } | null;
247
+ }
248
+ /** Finalized conversation node union (kind discriminates; seq is the React key). */
249
+ export type ConversationNode = UserMessageNode | AssistantMessageNode | SteeringMessageNode | ContextMessageNode | ModelRetryNode | TurnErrorNode | TurnMaxTokensNode | ToolResultNode | CommandNode | CompactionSummaryNode | UnknownSurfaceNode;
250
+ /** In-flight tool card material: tool/call seen, tool/result not yet. */
251
+ export interface RunningToolCall {
252
+ callId: string;
253
+ /** Parent Tool call for a Code Dispatch start; absent on a root Session call. */
254
+ parentCallId?: string;
255
+ name: string;
256
+ argsRaw: string;
257
+ turn: number;
258
+ step: number;
259
+ /** Unix epoch ms when the tool/call event was logged. */
260
+ time: number;
261
+ /** Child calls owned by this call, in dispatch order. */
262
+ subCalls: readonly ToolCallBlock[];
263
+ }
264
+ /** One running or settled call, recursively owning its child calls. */
265
+ export type ToolCallBlock = RunningToolCall | ToolResultNode;
266
+ /** In-progress assistant output (chunk accumulator product). */
267
+ export interface PartialAssistant {
268
+ turn: number;
269
+ step: number;
270
+ blocks: readonly AssistantBlock[];
271
+ }
272
+ //# sourceMappingURL=records.d.ts.map
@@ -0,0 +1,131 @@
1
+ import type { ContentBlock, ToolSchema } from '@deepseek-ai/dsh-llm/types';
2
+ import type { SessionEvent } from '@deepseek-ai/dsh-session/types';
3
+ import type { AssistantProvenanceView, AssistantRequestConfig } from './records.ts';
4
+ export type { AssistantProvenanceView, AssistantRequestConfig, } from './records.ts';
5
+ /**
6
+ * Complete model-visible request state in force for an ordinary generation:
7
+ * the `request/header` config and tools plus the system prompt held by the
8
+ * current `system/message` surface node.
9
+ */
10
+ export interface ConversationPromptSnapshot {
11
+ /** Provider/model and sampling configuration from the effective request header. */
12
+ config: AssistantRequestConfig;
13
+ /**
14
+ * Rendered text of the `system/message` surface node in force for the
15
+ * request; empty when the surface has no system prompt or the node lies
16
+ * outside the loaded history window.
17
+ */
18
+ system: string;
19
+ /** Complete tool catalog sent with the request, including tools that were never called. */
20
+ tools: readonly ToolSchema[];
21
+ }
22
+ /** Effective prompt or introduced system node, anchored at the event that establishes it. */
23
+ export interface SystemPromptNode {
24
+ /** Sequence of the system event or replacement that establishes this prompt. */
25
+ seq: number;
26
+ /** Unix epoch ms of that event. */
27
+ time: number;
28
+ /** Turn the loop committed the node in. */
29
+ turn: number;
30
+ /** Step the loop committed the node in. */
31
+ step: number;
32
+ /** Rendered system prompt text; empty records "no system prompt". */
33
+ text: string;
34
+ /**
35
+ * True for a prompt appended after an earlier loaded system node: an
36
+ * in-history update the model reads at this position, presented where it
37
+ * was committed rather than by the next request header.
38
+ */
39
+ update: boolean;
40
+ }
41
+ /** System/tool change introduced while preparing one ordinary request, or by an in-history prompt update. */
42
+ export interface RequestPromptChange {
43
+ /**
44
+ * Sequence of the event that introduced this state: the `system/message`
45
+ * node when it introduced, replaced, or updated the system prompt, otherwise the
46
+ * `request/header` event.
47
+ */
48
+ seq: number;
49
+ /** Unix epoch ms of that event. */
50
+ time: number;
51
+ /** How the model-visible prompt differs from the previous recorded state. */
52
+ kind: 'initial' | 'system' | 'tools' | 'system-and-tools';
53
+ /** State immediately before this change; absent for the initial header. */
54
+ previous?: ConversationPromptSnapshot;
55
+ }
56
+ /** Canonical prompt snapshot and any model-visible change introduced by one request header. */
57
+ export interface RequestPromptInspection {
58
+ /** Complete prompt state in force for the header's request. */
59
+ prompt: ConversationPromptSnapshot;
60
+ /** System/tool change relative to the preceding loaded header. */
61
+ change?: RequestPromptChange;
62
+ }
63
+ /**
64
+ * The {@link inspectRequestPrompt} signature as a value seam: Chat and
65
+ * Trajectory Definitions receive it from the uiConversation service because a
66
+ * client bundle cannot value-import another plugin's module.
67
+ */
68
+ export type RequestPromptInspector = (previous: ConversationPromptSnapshot | undefined, event: SessionEvent<'request/header'>, system: SystemPromptNode | undefined) => RequestPromptInspection;
69
+ /**
70
+ * Canonicalize one request header against the system node in force and
71
+ * classify the model-visible prompt change.
72
+ * @param previous - Prompt from the preceding loaded request header, when available.
73
+ * @param event - Durable full request header to inspect.
74
+ * @param system - Effective nonempty system prompt after loaded surface replacements; empty when removed.
75
+ * An in-history update already presented its text at its own position, so the header reports no system change for it.
76
+ * @returns The canonical prompt and an initial/system/tool change when it can be established.
77
+ */
78
+ export declare function inspectRequestPrompt(previous: ConversationPromptSnapshot | undefined, event: SessionEvent<'request/header'>, system: SystemPromptNode | undefined): RequestPromptInspection;
79
+ /** Lifecycle fields shared by ordinary generation and compaction requests. */
80
+ interface RequestViewBase {
81
+ /** Sequence that opened the operation represented by this request. */
82
+ startSeq: number;
83
+ startedAt: number;
84
+ completedAt: number | null;
85
+ status: 'running' | 'complete' | 'error';
86
+ error?: string;
87
+ /** Stable provider code for localized presentation of known failures. */
88
+ errorCode?: string;
89
+ provenance?: AssistantProvenanceView;
90
+ requestConfig?: AssistantRequestConfig;
91
+ usage?: unknown;
92
+ /** Assistant message or compaction summary sequence produced by this request. */
93
+ resultSeq?: number;
94
+ }
95
+ /** One ordinary assistant generation assembled from durable request events. */
96
+ interface AssistantRequestView extends RequestViewBase {
97
+ purpose: 'assistant';
98
+ turn: number;
99
+ /** Agent-loop step that issued this request. */
100
+ step: number;
101
+ /** Effective ordinary request input, inherited until a later header changes it. */
102
+ prompt?: ConversationPromptSnapshot;
103
+ /** Prompt change logged while preparing this request. */
104
+ promptChange?: RequestPromptChange;
105
+ /** Retry ordinal scheduled after a failed ordinary request. */
106
+ retry?: number;
107
+ maxRetries?: number;
108
+ retryDelayMs?: number;
109
+ }
110
+ /** One compaction provider request, either turn-owned or standalone between turns. */
111
+ interface CompactionRequestView extends RequestViewBase {
112
+ purpose: 'compaction';
113
+ /** Owning turn, or `null` when manual compaction ran between turns. */
114
+ turn: number | null;
115
+ /** Direct compaction requests do not consume an agent-loop step. */
116
+ step: 0;
117
+ /** Compaction replacement message sequence, when one was committed. */
118
+ replacementSeq?: number;
119
+ /** Safe compaction summary projection. */
120
+ summary?: readonly ContentBlock[];
121
+ /** Complete compaction provider output before the safe projection. */
122
+ rawOutput?: readonly ContentBlock[];
123
+ }
124
+ /** One provider request assembled from durable request lifecycle events. */
125
+ export type RequestView = AssistantRequestView | CompactionRequestView;
126
+ /** Request data consumed by the stage-oriented Trajectory layout. */
127
+ export interface RequestInspectionSnapshot {
128
+ requests: readonly RequestView[];
129
+ callSchemas: ReadonlyMap<string, ToolSchema>;
130
+ }
131
+ //# sourceMappingURL=request-inspection.d.ts.map