@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
package/lib/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import z from "@deepseek-ai/schemastery";
2
+ //#region lib/types/submission-settings.js
3
+ /** Busy-Enter preference stored in the Host user-settings document. */
4
+ /** Settings namespace owned by the conversation plugin. */
5
+ const CONVERSATION_SETTINGS_NAMESPACE = "ui-conversation";
6
+ /** Field carrying the delivery mode for plain Enter while an agent is busy. */
7
+ const BUSY_ENTER_FIELD = "busyEnter";
8
+ /** Busy-Enter behaviors accepted at settings and input boundaries. */
9
+ const BUSY_ENTER_BEHAVIORS = ["queue", "steer"];
10
+ /** Default preserves Enter-as-Queue for running conversations. */
11
+ const DEFAULT_BUSY_ENTER_BEHAVIOR = "queue";
12
+ /** Durable conversation schema; also the wire envelope the browser scope validates against. */
13
+ const ConversationSettingsSchema = z.object({ [BUSY_ENTER_FIELD]: z.union([...BUSY_ENTER_BEHAVIORS]).default(DEFAULT_BUSY_ENTER_BEHAVIOR) });
14
+ //#endregion
15
+ //#region lib/types/index.js
16
+ /** Host registration for browser conversation preferences. */
17
+ /**
18
+ * Register the durable conversation section when a settings provider exists.
19
+ * @param ctx - Host context whose optional settings service owns the section.
20
+ */
21
+ function apply(ctx) {
22
+ ctx.inject(["settings"], (settingsCtx) => {
23
+ settingsCtx.settings.register(CONVERSATION_SETTINGS_NAMESPACE, ConversationSettingsSchema);
24
+ });
25
+ }
26
+ //#endregion
27
+ export { BUSY_ENTER_BEHAVIORS, BUSY_ENTER_FIELD, CONVERSATION_SETTINGS_NAMESPACE, DEFAULT_BUSY_ENTER_BEHAVIOR, apply };
@@ -0,0 +1,25 @@
1
+ /** Registers the target-neutral Conversation assembly, shell, input, and docks. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import z from '@deepseek-ai/schemastery';
4
+ import { type ConversationKey } from './locales.ts';
5
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
6
+ interface LocaleNamespaceMap {
7
+ /** Conversation shell, composer, queue, and dock copy. */
8
+ conversation: ConversationKey;
9
+ }
10
+ }
11
+ /** Services required by the Conversation plugin. */
12
+ export declare const inject: string[];
13
+ /** Conversation runtime configuration. */
14
+ export interface Config {
15
+ /** Maximum generic-file uploads allowed to run concurrently in browser Workers. */
16
+ maxConcurrentFileUploads?: number;
17
+ }
18
+ /** Validated Conversation runtime configuration. */
19
+ export declare const Config: z<Config>;
20
+ /**
21
+ * Mount the Conversation core and target-neutral presentation.
22
+ * @param ctx - Client root context.
23
+ */
24
+ export declare function apply(ctx: Context, config?: Config): void;
25
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { ContextPressureProjection } from '@deepseek-ai/dsh-token-meter/client';
2
+ /** Context usage rendered by conversation and Chat status surfaces. */
3
+ export interface ContextOccupancy {
4
+ percent: number;
5
+ usedTokens: number;
6
+ contextWindow: number;
7
+ }
8
+ /**
9
+ * Resolve bounded display occupancy from independently updated pressure fields.
10
+ * @param pressure - latest token-meter projection.
11
+ * @returns occupancy, or null until numerator and capacity are known.
12
+ */
13
+ export declare function contextOccupancy(pressure: ContextPressureProjection | undefined): ContextOccupancy | null;
14
+ //# sourceMappingURL=context-occupancy.d.ts.map
@@ -0,0 +1,28 @@
1
+ import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
2
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
3
+ /** Why one session's composer is inert. */
4
+ export interface ComposerBlock {
5
+ /** Localized placeholder owned by the plugin that raised the block. */
6
+ readonly reason: string;
7
+ }
8
+ /** The registry face other plugins reach through `ctx.conversation.blocks`. */
9
+ export interface ComposerBlocks {
10
+ /**
11
+ * Raise or clear this session's block.
12
+ * @param sessionId - Session whose composer is affected.
13
+ * @param block - Block to raise, or undefined to clear it.
14
+ */
15
+ set(sessionId: SessionId, block: ComposerBlock | undefined): void;
16
+ /**
17
+ * Resolve the observable block state for one Session.
18
+ * @param sessionId - Session to observe.
19
+ * @returns Identity-stable block store.
20
+ */
21
+ storeFor(sessionId: SessionId): SnapshotStore<ComposerBlock | undefined>;
22
+ /**
23
+ * Drop one Session's store.
24
+ * @param sessionId - Session being released.
25
+ */
26
+ forget(sessionId: SessionId): void;
27
+ }
28
+ //# sourceMappingURL=composer-blocks.d.ts.map
@@ -0,0 +1,8 @@
1
+ /** Composer submission vocabulary shared by the input and settings domains. */
2
+ import type { BusyEnterBehavior } from '../../submission-settings.ts';
3
+ export type { BusyEnterBehavior } from '../../submission-settings.ts';
4
+ /** Delivery mode requested for one ordinary composer message. */
5
+ export type InputSubmitMode = BusyEnterBehavior;
6
+ /** Keyboard gesture whose delivery mode the submission policy resolves. */
7
+ export type ComposerSubmitGesture = 'enter' | 'accelerated';
8
+ //# sourceMappingURL=composer-submission.d.ts.map
@@ -0,0 +1,29 @@
1
+ /** Shared types for target-owned context-source projections. */
2
+ /**
3
+ * Which model-facing role a logged non-user message plays.
4
+ *
5
+ * `recall` marks material lifted out of another session's log; `inject` marks
6
+ * every other producer-supplied context. Mid-turn steering is the third role
7
+ * the transcript distinguishes, but it has its own event and node kind
8
+ * (`steering/message` / `SteeringMessageNode`) and never reaches here.
9
+ */
10
+ export type ContextRole = 'inject' | 'recall';
11
+ /** Role and producer name presented for one logged non-user message. */
12
+ export interface ContextProvenanceView {
13
+ /** The role this context plays in the model-facing conversation. */
14
+ role: ContextRole;
15
+ /**
16
+ * Producer name for the row header, taken from the durable source: the
17
+ * instruction paths, the referenced session titles, the plugin id, or the
18
+ * bare source kind for a producer this UI version does not know. Null only
19
+ * when the source carries no readable kind at all.
20
+ */
21
+ label: string | null;
22
+ }
23
+ /**
24
+ * One durable context form this UI version knows how to present. Target
25
+ * projections map absent or unknown forms to their opaque presentation so
26
+ * logs written by older, newer, or foreign producers remain visible.
27
+ */
28
+ export type KnownContextForm = 'instructions' | 'catalog' | 'snapshot' | 'notice' | 'relay' | 'recall';
29
+ //# sourceMappingURL=context-provenance.d.ts.map
@@ -0,0 +1,256 @@
1
+ import type { SessionEventLike } from '@deepseek-ai/dsh-api-session-controller/client';
2
+ import type { SessionEvent } from '@deepseek-ai/dsh-session/types';
3
+ /** Definition-local identity and lifecycle role extracted from one event. */
4
+ export interface ConversationMatchResult {
5
+ readonly id: string;
6
+ readonly role: 'start' | 'update';
7
+ }
8
+ /** Merge-extensible business values published against one Turn. */
9
+ export interface ConversationTurnDataMap {
10
+ }
11
+ /** Merge-extensible business values published against one Step. */
12
+ export interface ConversationStepDataMap {
13
+ }
14
+ /** Observable value for one independently owned Location-data key. */
15
+ export interface ConversationLocationDataSource<Value> {
16
+ /** @returns the current value. */
17
+ readonly getSnapshot: () => Value;
18
+ /** @param listener - callback for value changes. @returns the unsubscribe function. */
19
+ readonly subscribe: (listener: () => void) => () => void;
20
+ }
21
+ /** Stable keyed reader for independently owned Location business values. */
22
+ export interface ConversationLocationDataStore<DataMap extends object> {
23
+ /**
24
+ * Read one business value without exposing another owner's mutable State.
25
+ * @param key - declaration-merged business key.
26
+ * @returns latest immutable value, when its owning Context has published one.
27
+ */
28
+ get<Key extends keyof DataMap & string>(key: Key): Readonly<DataMap[Key]> | undefined;
29
+ /**
30
+ * Observe one business value without subscribing to unrelated Location keys.
31
+ * @param key - declaration-merged business key.
32
+ * @returns identity-stable source for the current value.
33
+ */
34
+ source<Key extends keyof DataMap & string>(key: Key): ConversationLocationDataSource<Readonly<DataMap[Key]> | undefined>;
35
+ }
36
+ interface ConversationLocationDataValue {
37
+ readonly kind: 'turn' | 'step';
38
+ readonly turn: number;
39
+ readonly step?: number;
40
+ readonly key: string;
41
+ readonly value: unknown;
42
+ }
43
+ type RegisteredTurnData<DataMap extends object> = {
44
+ [Key in Extract<keyof DataMap, string>]: {
45
+ readonly kind: 'turn';
46
+ readonly turn: number;
47
+ readonly key: Key;
48
+ readonly value: DataMap[Key];
49
+ };
50
+ }[Extract<keyof DataMap, string>];
51
+ type RegisteredStepData<DataMap extends object> = {
52
+ [Key in Extract<keyof DataMap, string>]: {
53
+ readonly kind: 'step';
54
+ readonly turn: number;
55
+ readonly step: number;
56
+ readonly key: Key;
57
+ readonly value: DataMap[Key];
58
+ };
59
+ }[Extract<keyof DataMap, string>];
60
+ type ConversationLocationDataOf<TurnData extends object, StepData extends object> = [
61
+ keyof TurnData | keyof StepData
62
+ ] extends [never] ? ConversationLocationDataValue : RegisteredTurnData<TurnData> | RegisteredStepData<StepData>;
63
+ /** One Definition-owned value attached to an Engine-owned Turn or Step. */
64
+ export type ConversationLocationData = ConversationLocationDataOf<ConversationTurnDataMap, ConversationStepDataMap>;
65
+ /** Immutable resolved boundary for one Agent step. */
66
+ export interface StepLocation {
67
+ readonly turn: number;
68
+ readonly step: number;
69
+ readonly start: SessionEvent<'step/start'> | undefined;
70
+ readonly end: SessionEvent<'step/end'> | undefined;
71
+ readonly status: 'open' | 'closed' | 'unknown';
72
+ /** Stable reader for Step-scoped business values. */
73
+ readonly data: ConversationLocationDataStore<ConversationStepDataMap>;
74
+ }
75
+ /** Immutable resolved boundary for one Agent turn. */
76
+ export interface TurnLocation {
77
+ readonly turn: number;
78
+ readonly start: SessionEvent<'turn/start'> | undefined;
79
+ readonly end: SessionEvent<'turn/end'> | undefined;
80
+ readonly status: 'open' | 'closed' | 'unknown';
81
+ readonly steps: readonly StepLocation[];
82
+ /** Stable reader for Turn-scoped business values. */
83
+ readonly data: ConversationLocationDataStore<ConversationTurnDataMap>;
84
+ }
85
+ /** Engine-owned placement of one matched event in the Session hierarchy. */
86
+ export type ConversationLocation = {
87
+ readonly kind: 'session';
88
+ } | {
89
+ readonly kind: 'turn';
90
+ readonly turn: TurnLocation;
91
+ } | {
92
+ readonly kind: 'step';
93
+ readonly turn: TurnLocation;
94
+ readonly step: StepLocation;
95
+ } | {
96
+ readonly kind: 'unresolved';
97
+ };
98
+ interface ConversationMatchOf<Event extends SessionEventLike, Role extends ConversationMatchResult['role']> {
99
+ readonly event: Event;
100
+ readonly role: Role;
101
+ readonly location: ConversationLocation;
102
+ }
103
+ /** One scalar event accepted as a Context's unique start. */
104
+ export type ConversationStartMatch = ConversationMatchOf<SessionEvent, 'start'>;
105
+ /** One event accepted by a Definition, with its lifecycle role and resolved Location. */
106
+ export type ConversationMatch = ConversationStartMatch | ConversationMatchOf<SessionEventLike, 'update'>;
107
+ /** Target-neutral identity returned by a business Definition. */
108
+ export interface ConversationViewNode {
109
+ readonly key: string;
110
+ readonly kind: string;
111
+ readonly id: string;
112
+ readonly target: string;
113
+ readonly data: unknown;
114
+ }
115
+ /** Merge-extensible immutable snapshots published by registered view targets. */
116
+ export interface ConversationViewSnapshotMap {
117
+ }
118
+ /** Stable reader over the latest snapshot of every registered view target. */
119
+ export interface ConversationViewSnapshotStore {
120
+ /** @param target - registered view target. @returns its current snapshot. */
121
+ get<Target extends Extract<keyof ConversationViewSnapshotMap, string>>(target: Target): ConversationViewSnapshotMap[Target] | undefined;
122
+ }
123
+ /** Immutable public view of an assembled business Context. */
124
+ export interface ConversationNodeContext<State = unknown> {
125
+ readonly key: string;
126
+ readonly kind: string;
127
+ readonly id: string;
128
+ readonly matches: readonly ConversationMatch[];
129
+ readonly start: ConversationStartMatch | undefined;
130
+ readonly state: State | undefined;
131
+ readonly current: ReadonlyMap<string, ConversationViewNode | null>;
132
+ }
133
+ /** Read-only predecessor returned to a Definition's start function. */
134
+ export interface ConversationPreviousContext<State = unknown> {
135
+ readonly key: string;
136
+ readonly kind: string;
137
+ readonly id: string;
138
+ readonly startSeq: number;
139
+ readonly state: Readonly<State>;
140
+ readonly matches: readonly ConversationMatch[];
141
+ }
142
+ /** Strictly-backward Context lookup available while a start is evaluated. */
143
+ export interface ConversationContextReader {
144
+ /**
145
+ * Find the active Context of `kind` with the greatest start seq below the
146
+ * current start event.
147
+ * @param kind - Definition kind to query.
148
+ * @returns the nearest predecessor, or undefined when absent in the current window.
149
+ */
150
+ previous<State>(kind: string): ConversationPreviousContext<State> | undefined;
151
+ }
152
+ /** Requested cadence; `animation-frame` materializes after three browser animation frames. */
153
+ export type ConversationPublication = 'none' | 'animation-frame' | 'immediate';
154
+ /** Engine-owned Location data publication phase. */
155
+ export type ConversationLocationDataScope = 'step' | 'turn';
156
+ /** One independently registered business Event-to-Node state machine. */
157
+ export interface ConversationNodeDefinition<State = unknown> {
158
+ readonly kind: string;
159
+ /** Sole view target owned by this Definition; omitted for state-only Contexts. */
160
+ readonly target?: string;
161
+ /**
162
+ * Extract this Definition's stable business identity from one event.
163
+ * @param event - standard or compact Client history event; no Context or history access is available.
164
+ * @returns identity and lifecycle role, or null when unrelated.
165
+ */
166
+ match(event: SessionEventLike): ConversationMatchResult | null;
167
+ /**
168
+ * Create State from the unique start Match.
169
+ * @param context - complete evidence currently collected for the Context.
170
+ * @param match - the start Match.
171
+ * @param reader - strictly-backward read-only Context lookup.
172
+ * @returns the State adopted by the engine.
173
+ */
174
+ start(context: ConversationNodeContext<State>, match: ConversationStartMatch, reader: ConversationContextReader): State;
175
+ /**
176
+ * Apply one post-start update Match.
177
+ * @param context - Context with its current State.
178
+ * @param match - update Match in ascending log order.
179
+ * @returns the State adopted by the engine.
180
+ */
181
+ update(context: ConversationNodeContext<State> & {
182
+ readonly state: State;
183
+ }, match: ConversationMatch): State;
184
+ /**
185
+ * Select publication cadence for one accepted Match.
186
+ * @param match - accepted Match.
187
+ * @returns requested cadence; omission defaults to immediate.
188
+ */
189
+ publication?(match: ConversationMatch): ConversationPublication;
190
+ /**
191
+ * Publish this Definition's read-only business value for one Location phase.
192
+ * The Engine evaluates every Definition first for Step and then for Turn,
193
+ * owns replacement/removal, and rejects another Context trying to publish
194
+ * the same Location key.
195
+ * @param context - latest complete Context.
196
+ * @param scope - Location hierarchy level currently being materialized.
197
+ * @param previous - value from the preceding materialization; return it when unchanged.
198
+ * @returns current Location value, preserving value identity while unchanged,
199
+ * or null while unavailable.
200
+ */
201
+ buildLocationData?(context: ConversationNodeContext<State>, scope: ConversationLocationDataScope, previous: ConversationLocationData | null): ConversationLocationData | null;
202
+ /**
203
+ * Materialize one final Node for this Definition's declared view target.
204
+ * @param context - latest complete Context.
205
+ * @returns final Node, or null when this Context is not currently visible.
206
+ */
207
+ buildViewNode?(context: ConversationNodeContext<State>): ConversationViewNode | null;
208
+ }
209
+ /** Reference-stable Turn/Step facts published beside view Nodes. */
210
+ export interface ConversationTimelineSnapshot {
211
+ readonly turnOrder: readonly number[];
212
+ readonly turns: ReadonlyMap<number, TurnLocation>;
213
+ }
214
+ /** Per-Session incremental builder for one view target. */
215
+ export interface ConversationViewBuilder<Node extends ConversationViewNode = ConversationViewNode, Snapshot = unknown> {
216
+ readonly empty: Snapshot;
217
+ /**
218
+ * Replace the low-frequency complete materialized Node set.
219
+ * @param input - complete Nodes and current timeline.
220
+ * @returns next view snapshot.
221
+ */
222
+ replace(input: {
223
+ readonly nodes: readonly Node[];
224
+ readonly timeline: ConversationTimelineSnapshot;
225
+ }): Snapshot;
226
+ /**
227
+ * Apply only Nodes whose materialized values changed in this transaction.
228
+ * @param input - changed Nodes and current timeline.
229
+ * @returns next view snapshot.
230
+ */
231
+ apply(input: {
232
+ readonly upserts: readonly Node[];
233
+ readonly timeline: ConversationTimelineSnapshot;
234
+ }): Snapshot;
235
+ }
236
+ /** Registry contribution that creates an isolated builder when a Session first uses this target. */
237
+ export interface ConversationViewDefinition<Node extends ConversationViewNode = ConversationViewNode, Snapshot = unknown> {
238
+ readonly target: string;
239
+ /** @returns a new Session-owned incremental builder. */
240
+ create(): ConversationViewBuilder<Node, Snapshot>;
241
+ /**
242
+ * Decide whether this target contributes visible Conversation activity.
243
+ * @param snapshot - latest target-owned snapshot.
244
+ * @returns whether the shell should treat this target as active.
245
+ */
246
+ isActive?(snapshot: Snapshot): boolean;
247
+ }
248
+ /**
249
+ * Build a stable collision-free key for one Definition-local business identity.
250
+ * @param kind - Definition kind.
251
+ * @param id - Definition-local business identity.
252
+ * @returns engine-owned Context key.
253
+ */
254
+ export declare function conversationContextKey(kind: string, id: string): string;
255
+ export {};
256
+ //# sourceMappingURL=conversation.d.ts.map