@crazx/dsh-api-session-controller 0.1.2-alpha.3.zw.1

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/README.i18n.yaml +6 -0
  3. package/README.md +74 -0
  4. package/README.zh.md +74 -0
  5. package/lib/client.js +2724 -0
  6. package/lib/index.js +2826 -0
  7. package/lib/invariant.js +13 -0
  8. package/lib/typert.host.d.ts +3 -0
  9. package/lib/typert.host.js +2574 -0
  10. package/lib/typert.remote-client.d.ts +67 -0
  11. package/lib/typert.remote-client.js +1119 -0
  12. package/lib/types/agent.d.ts +156 -0
  13. package/lib/types/agent.js +537 -0
  14. package/lib/types/catalog.d.ts +11 -0
  15. package/lib/types/catalog.js +58 -0
  16. package/lib/types/client/contract/events.d.ts +71 -0
  17. package/lib/types/client/contract/events.js +91 -0
  18. package/lib/types/client/contract/session.d.ts +150 -0
  19. package/lib/types/client/contract/session.js +2 -0
  20. package/lib/types/client/contract/sessions.d.ts +125 -0
  21. package/lib/types/client/contract/sessions.js +2 -0
  22. package/lib/types/client/contract/snapshot.d.ts +82 -0
  23. package/lib/types/client/contract/snapshot.js +2 -0
  24. package/lib/types/client/index.d.ts +30 -0
  25. package/lib/types/client/index.js +48 -0
  26. package/lib/types/client/ordered-baseline.d.ts +12 -0
  27. package/lib/types/client/ordered-baseline.js +41 -0
  28. package/lib/types/client/scope.d.ts +36 -0
  29. package/lib/types/client/scope.js +54 -0
  30. package/lib/types/client/sessions/history-records.d.ts +22 -0
  31. package/lib/types/client/sessions/history-records.js +31 -0
  32. package/lib/types/client/sessions/lineage.d.ts +38 -0
  33. package/lib/types/client/sessions/lineage.js +56 -0
  34. package/lib/types/client/sessions/manager.d.ts +280 -0
  35. package/lib/types/client/sessions/manager.js +894 -0
  36. package/lib/types/client/sessions/notifier.d.ts +39 -0
  37. package/lib/types/client/sessions/notifier.js +98 -0
  38. package/lib/types/client/sessions/projection-store.d.ts +108 -0
  39. package/lib/types/client/sessions/projection-store.js +129 -0
  40. package/lib/types/client/sessions/queue-mirror.d.ts +26 -0
  41. package/lib/types/client/sessions/queue-mirror.js +61 -0
  42. package/lib/types/client/sessions/remotes.d.ts +30 -0
  43. package/lib/types/client/sessions/remotes.js +8 -0
  44. package/lib/types/client/sessions/service.d.ts +349 -0
  45. package/lib/types/client/sessions/service.js +574 -0
  46. package/lib/types/client/sessions/session.d.ts +294 -0
  47. package/lib/types/client/sessions/session.js +711 -0
  48. package/lib/types/client/time-zone.d.ts +8 -0
  49. package/lib/types/client/time-zone.js +14 -0
  50. package/lib/types/client/transport.d.ts +73 -0
  51. package/lib/types/client/transport.js +106 -0
  52. package/lib/types/commands.d.ts +69 -0
  53. package/lib/types/commands.js +544 -0
  54. package/lib/types/control.d.ts +23 -0
  55. package/lib/types/control.js +192 -0
  56. package/lib/types/file-references.d.ts +27 -0
  57. package/lib/types/file-references.js +69 -0
  58. package/lib/types/history.d.ts +31 -0
  59. package/lib/types/history.js +376 -0
  60. package/lib/types/index.d.ts +171 -0
  61. package/lib/types/index.js +424 -0
  62. package/lib/types/invariant.d.ts +9 -0
  63. package/lib/types/invariant.js +12 -0
  64. package/lib/types/list.d.ts +53 -0
  65. package/lib/types/list.js +405 -0
  66. package/lib/types/model-selection-projection.d.ts +8 -0
  67. package/lib/types/model-selection-projection.js +66 -0
  68. package/lib/types/remote-events.d.ts +8 -0
  69. package/lib/types/remote-events.js +2 -0
  70. package/lib/types/skill-catalog.d.ts +28 -0
  71. package/lib/types/skill-catalog.js +192 -0
  72. package/lib/types/types.d.ts +505 -0
  73. package/lib/types/types.js +6 -0
  74. package/package.json +154 -0
@@ -0,0 +1,11 @@
1
+ /** Shared projection of the live LLM registry into the browser model catalog. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ import type { ModelCatalog, ModelSelection } from './types.ts';
4
+ /**
5
+ * Build the browser model catalog without requiring a Session.
6
+ * @param ctx - Host context carrying the live LLM registry.
7
+ * @param defaultSelection - deployment default used before a Session selects a model.
8
+ * @returns successful non-empty provider groups and isolated provider failures.
9
+ */
10
+ export declare function buildModelCatalog(ctx: Context, defaultSelection?: ModelSelection): Promise<ModelCatalog>;
11
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1,58 @@
1
+ /** Shared projection of the live LLM registry into the browser model catalog. */
2
+ /**
3
+ * Build the browser model catalog without requiring a Session.
4
+ * @param ctx - Host context carrying the live LLM registry.
5
+ * @param defaultSelection - deployment default used before a Session selects a model.
6
+ * @returns successful non-empty provider groups and isolated provider failures.
7
+ */
8
+ export async function buildModelCatalog(ctx, defaultSelection = ctx.agentDefaultModel.currentSelection()) {
9
+ const providers = ctx.llm.listProviders();
10
+ const catalog = await Promise.all(providers.map(async (provider) => {
11
+ try {
12
+ const models = await ctx.llm.listModels(provider.id);
13
+ const entries = await Promise.all(models.map(async (model) => {
14
+ const resolved = await ctx.llm.resolveModelInfo(provider.id, model.id);
15
+ const reasoning = resolved.reasoning === undefined
16
+ ? undefined
17
+ : {
18
+ efforts: resolved.reasoning.efforts.map(effort => ({
19
+ id: effort.id,
20
+ name: effort.name,
21
+ ...(effort.description === undefined ? {} : { description: effort.description }),
22
+ })),
23
+ ...(resolved.reasoning.defaultEffort === undefined
24
+ ? {}
25
+ : { defaultEffort: resolved.reasoning.defaultEffort }),
26
+ };
27
+ return {
28
+ id: model.id,
29
+ name: model.name,
30
+ ...(model.description === undefined ? {} : { description: model.description }),
31
+ ...(reasoning === undefined ? {} : { reasoning }),
32
+ };
33
+ }));
34
+ return {
35
+ kind: 'group',
36
+ group: { id: provider.id, name: provider.name, models: entries },
37
+ };
38
+ }
39
+ catch (error) {
40
+ return {
41
+ kind: 'failure',
42
+ failure: {
43
+ id: provider.id,
44
+ name: provider.name,
45
+ message: error instanceof Error ? error.message : String(error),
46
+ },
47
+ };
48
+ }
49
+ }));
50
+ return {
51
+ default: { ...defaultSelection },
52
+ routableProviders: providers.map(provider => provider.id),
53
+ groups: catalog.flatMap(item => item.kind === 'group' ? [item.group] : [])
54
+ .filter(group => group.models.length > 0),
55
+ failures: catalog.flatMap(item => item.kind === 'failure' ? [item.failure] : []),
56
+ };
57
+ }
58
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1,71 @@
1
+ /** Observable contiguous Session event window consumed by domain assemblers. */
2
+ import { type ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
3
+ import type { SessionEvent } from '@deepseek-ai/dsh-session/types';
4
+ import type { ChunkRowEvent } from '../../types.ts';
5
+ /** Standard Session event or compact historical Assistant run. */
6
+ export type SessionEventLike = SessionEvent | ChunkRowEvent;
7
+ /** Client history entry retaining its coarse transport discriminator. */
8
+ export type SessionEventLikeEntry = {
9
+ readonly type: 'event';
10
+ readonly event: SessionEvent;
11
+ } | {
12
+ readonly type: 'chunks';
13
+ readonly event: ChunkRowEvent;
14
+ };
15
+ /** Scalar live entry accepted by append-only Client paths. */
16
+ export type SessionLiveEventEntry = Extract<SessionEventLikeEntry, {
17
+ readonly type: 'event';
18
+ }>;
19
+ /** Exact delta that produced the latest event-window revision. */
20
+ export type SessionEventChange = {
21
+ readonly kind: 'replace';
22
+ readonly entries: readonly SessionEventLikeEntry[];
23
+ } | {
24
+ readonly kind: 'prepend';
25
+ readonly entries: readonly SessionEventLikeEntry[];
26
+ } | {
27
+ readonly kind: 'append';
28
+ readonly entries: readonly SessionLiveEventEntry[];
29
+ };
30
+ /** Current contiguous event window and its latest synchronous delta. */
31
+ export interface SessionEventWindow {
32
+ readonly entries: readonly SessionEventLikeEntry[];
33
+ readonly hasMore: boolean;
34
+ readonly revision: number;
35
+ readonly change: SessionEventChange;
36
+ }
37
+ /** Conversation-facing event source exposed by one Session binding. */
38
+ export type SessionEventSource = ObservableSnapshot<SessionEventWindow>;
39
+ /** Session-owned event feed; every accepted window mutation publishes synchronously. */
40
+ export declare class MutableSessionEventSource implements SessionEventSource {
41
+ private readonly listeners;
42
+ private window;
43
+ private snapshot;
44
+ /** @returns the cached event-window snapshot. */
45
+ getSnapshot(): SessionEventWindow;
46
+ /**
47
+ * Subscribe to synchronous window publication.
48
+ * @param listener - invalidation callback.
49
+ * @returns unsubscribe function.
50
+ */
51
+ subscribe(listener: () => void): () => void;
52
+ /**
53
+ * Replace the complete contiguous window.
54
+ * @param entries - complete window.
55
+ * @param hasMore - whether older history remains.
56
+ */
57
+ replace(entries: readonly SessionEventLikeEntry[], hasMore: boolean): void;
58
+ /**
59
+ * Prepend one older contiguous page.
60
+ * @param entries - newly loaded older entries.
61
+ * @param hasMore - whether still older history remains.
62
+ */
63
+ prepend(entries: readonly SessionEventLikeEntry[], hasMore: boolean): void;
64
+ /**
65
+ * Append one contiguous live entry.
66
+ * @param entry - live tail entry.
67
+ */
68
+ append(entry: SessionLiveEventEntry): void;
69
+ private publish;
70
+ }
71
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1,91 @@
1
+ /** Observable contiguous Session event window consumed by domain assemblers. */
2
+ import { notifySubscribers } from '@deepseek-ai/dsh-client-store';
3
+ function leaf(entries) {
4
+ return { kind: 'leaf', entries, length: entries.length };
5
+ }
6
+ function concat(left, right) {
7
+ return { kind: 'concat', left, right, length: left.length + right.length };
8
+ }
9
+ function materialize(node) {
10
+ if (node.kind === 'leaf')
11
+ return node.entries;
12
+ const entries = new Array(node.length);
13
+ const pending = [node];
14
+ let index = 0;
15
+ while (pending.length > 0) {
16
+ const current = pending.pop();
17
+ if (current.kind === 'concat') {
18
+ pending.push(current.right, current.left);
19
+ continue;
20
+ }
21
+ for (const entry of current.entries) {
22
+ entries[index] = entry;
23
+ index += 1;
24
+ }
25
+ }
26
+ return entries;
27
+ }
28
+ function windowSnapshot(node, hasMore, revision, change) {
29
+ let entries;
30
+ return {
31
+ get entries() {
32
+ entries ??= materialize(node);
33
+ return entries;
34
+ },
35
+ hasMore,
36
+ revision,
37
+ change,
38
+ };
39
+ }
40
+ /** Session-owned event feed; every accepted window mutation publishes synchronously. */
41
+ export class MutableSessionEventSource {
42
+ listeners = new Set();
43
+ window = leaf([]);
44
+ snapshot = windowSnapshot(this.window, false, 0, { kind: 'replace', entries: [] });
45
+ /** @returns the cached event-window snapshot. */
46
+ getSnapshot() { return this.snapshot; }
47
+ /**
48
+ * Subscribe to synchronous window publication.
49
+ * @param listener - invalidation callback.
50
+ * @returns unsubscribe function.
51
+ */
52
+ subscribe(listener) {
53
+ this.listeners.add(listener);
54
+ return () => { this.listeners.delete(listener); };
55
+ }
56
+ /**
57
+ * Replace the complete contiguous window.
58
+ * @param entries - complete window.
59
+ * @param hasMore - whether older history remains.
60
+ */
61
+ replace(entries, hasMore) {
62
+ this.window = leaf(entries);
63
+ this.publish(hasMore, { kind: 'replace', entries });
64
+ }
65
+ /**
66
+ * Prepend one older contiguous page.
67
+ * @param entries - newly loaded older entries.
68
+ * @param hasMore - whether still older history remains.
69
+ */
70
+ prepend(entries, hasMore) {
71
+ this.window = concat(leaf(entries), this.window);
72
+ this.publish(hasMore, { kind: 'prepend', entries });
73
+ }
74
+ /**
75
+ * Append one contiguous live entry.
76
+ * @param entry - live tail entry.
77
+ */
78
+ append(entry) {
79
+ const entries = [entry];
80
+ this.window = concat(this.window, leaf(entries));
81
+ this.publish(this.snapshot.hasMore, {
82
+ kind: 'append',
83
+ entries,
84
+ });
85
+ }
86
+ publish(hasMore, change) {
87
+ this.snapshot = windowSnapshot(this.window, hasMore, this.snapshot.revision + 1, change);
88
+ notifySubscribers(this.listeners, '[session-controller] event feed');
89
+ }
90
+ }
91
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1,150 @@
1
+ /**
2
+ * The outward session face. Feature packages never see the concrete Session
3
+ * class: components read lifecycle state through `useSession` (the
4
+ * ObservableSnapshot half), and orchestration code calls the behavior verbs
5
+ * below — nothing else. Widening this interface is the explicit act of
6
+ * widening what features may do to a session (and what every test fixture
7
+ * must stub); implementation-internal entry points (history staging, wire-frame
8
+ * dispatch) stay on the class, invisible out here.
9
+ */
10
+ import type { AttachmentIdType, ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
11
+ import type { MessageId } from '@deepseek-ai/dsh-llm/brand';
12
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
13
+ import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
14
+ import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
15
+ import type { PromptContentPart, QueueAction, SessionRequestId } from '../../types.ts';
16
+ import type { PendingSubmissionImage, SessionSnapshot } from './snapshot.ts';
17
+ /**
18
+ * Why a local submission echo left the snapshot: `observed` when its durable
19
+ * `user/message` event or host queue occurrence arrived (with the admitted
20
+ * image references in prompt order), `failed` when the prompt was rejected,
21
+ * threw, or was aborted before acceptance.
22
+ */
23
+ export type PendingSubmissionRetirement = {
24
+ readonly reason: 'observed';
25
+ readonly attachments: readonly ImageAttachmentRef[];
26
+ } | {
27
+ readonly reason: 'failed';
28
+ };
29
+ /** Input registering one local submission echo ahead of its prompt call. */
30
+ export interface BeginSubmissionInput {
31
+ /** Delivery mode used with the upcoming prompt. */
32
+ readonly mode: 'queue' | 'steer';
33
+ /** Prompt text exactly as the upcoming prompt will send it. */
34
+ readonly text: string;
35
+ /** Ordered image previews matching the upcoming prompt's image parts. */
36
+ readonly images: readonly PendingSubmissionImage[];
37
+ /** Settlement callback fired exactly once when the echo retires. */
38
+ readonly onRetire?: (retirement: PendingSubmissionRetirement) => void;
39
+ }
40
+ /** One registered submission echo: the identity its prompt must carry, and the pre-prompt escape hatch. */
41
+ export interface SubmissionHandle {
42
+ /** The prompt RPC identity; pass it to {@link ISession.prompt}. */
43
+ readonly requestId: SessionRequestId;
44
+ /** Retire the echo as failed when the caller cannot reach prompt() (serialization failure); no-op after any other settlement. */
45
+ abandon(): void;
46
+ }
47
+ /** Key-addressed projection read face (the useProjection resolution path; see ProjectionValueStore). */
48
+ export interface ProjectionsFace {
49
+ /**
50
+ * The identity-stable bare observable for one projection key (absence is
51
+ * an `undefined` snapshot, never a missing face).
52
+ * @param key - projection key.
53
+ * @returns the key's value face.
54
+ */
55
+ faceOf(key: string): ObservableSnapshot<unknown>;
56
+ }
57
+ /** Identity plus the behavior verbs features may invoke on a session. */
58
+ export interface ISession {
59
+ /** The session's host identity (agent id — same axis). */
60
+ readonly sessionId: SessionId;
61
+ /** Host-computed projection values by key (the useProjection seat). */
62
+ readonly projections: ProjectionsFace;
63
+ /**
64
+ * Register one local submission echo in `snapshot.pendingSubmissions`,
65
+ * synchronously, before the caller serializes and sends the prompt. The
66
+ * echo retires when a durable `user/message` event or queue occurrence
67
+ * carrying the returned identity arrives, or when the identified prompt
68
+ * call fails.
69
+ * @param input - echo content and the optional settlement callback.
70
+ * @returns the minted identity for {@link prompt} plus the pre-prompt abandon path.
71
+ */
72
+ beginSubmission(input: BeginSubmissionInput): SubmissionHandle;
73
+ /**
74
+ * Send a prompt into the session.
75
+ * @param content - text plus browser-owned temporary image uploads.
76
+ * @param mode - 'queue' appends a turn; 'steer' interrupts the running one.
77
+ * @param signal - optional caller cancellation for the complete admission round-trip.
78
+ * @param requestId - identity from {@link beginSubmission}; a failed identified prompt retires its echo.
79
+ * @returns acceptance, or the business error (also mirrored into snapshot.promptError).
80
+ */
81
+ prompt(content: PromptContentPart[], mode: 'queue' | 'steer', signal?: AbortSignal, requestId?: SessionRequestId): Promise<RemoteResult<{
82
+ accepted: true;
83
+ }>>;
84
+ /**
85
+ * Resolve one durable image referenced by this session.
86
+ * @param attachmentId - opaque id found in the folded session log.
87
+ * @returns the authenticated reference and decoded bytes.
88
+ */
89
+ readAttachment(attachmentId: AttachmentIdType): Promise<RemoteResult<{
90
+ attachment: ImageAttachmentRef;
91
+ data: Uint8Array;
92
+ }>>;
93
+ /**
94
+ * Apply one edit, remove, or strict steer action to a still-pending queue occurrence.
95
+ * @param itemId - agent-owned inbox occurrence identity.
96
+ * @param action - requested queue operation.
97
+ * @returns acceptance, or a business/transport error.
98
+ */
99
+ updateQueue(itemId: MessageId, action: QueueAction): Promise<RemoteResult<{
100
+ accepted: true;
101
+ }>>;
102
+ /**
103
+ * Cancel the running turn. Pending queued work remains and resumes in FIFO
104
+ * order after the Host reaches cancellation quiescence.
105
+ * @returns acceptance, or the business error.
106
+ */
107
+ cancel(): Promise<RemoteResult<{
108
+ accepted: true;
109
+ }>>;
110
+ /**
111
+ * Rename this session (explicit user title; pins it against automatic
112
+ * regeneration).
113
+ * @param title - raw title text (the host normalizes acceptance).
114
+ * @returns the normalized accepted title and its event seq, or the business error.
115
+ */
116
+ rename(title: string): Promise<RemoteResult<{
117
+ title: string;
118
+ seq: number;
119
+ }>>;
120
+ /**
121
+ * Extend the history window backwards (older messages pagination).
122
+ * @returns completion; failures land in snapshot.openState/loadingOlder.
123
+ */
124
+ loadOlder(): Promise<void>;
125
+ /**
126
+ * Page history backwards until the window covers `seq` (inclusive) — the
127
+ * turn-jump loader. Repeated calls while a jump is paging lower its shared
128
+ * target and return the in-flight completion; `snapshot.loadingOlder` is
129
+ * the busy signal for the whole jump.
130
+ * @param seq - durable event seq the window must reach (a turn's `turn/start` seq).
131
+ * @returns completion once covered, exhausted, superseded, or failed soft.
132
+ */
133
+ loadThrough(seq: number): Promise<void>;
134
+ /**
135
+ * Execute one slash-command line against this session's agent — pure
136
+ * admission semantics (the host executor durably logs the lifecycle).
137
+ * @param line - the full command line, leading slash included.
138
+ * @returns the admission result, or the Remote face's error branch.
139
+ */
140
+ command(line: string): Promise<RemoteResult<{
141
+ matched: boolean;
142
+ }>>;
143
+ }
144
+ /**
145
+ * The full outward face: behavior verbs plus the Session lifecycle read side
146
+ * (the `useSession` hook source). This is the type carried by
147
+ * `SessionBinding.session` and the provide channel.
148
+ */
149
+ export type SessionFace = ISession & ObservableSnapshot<SessionSnapshot>;
150
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1,125 @@
1
+ /**
2
+ * The outward sessions-service face — what `ctx.sessions` exposes to feature
3
+ * packages. Transport entry points and implementation internals stay on
4
+ * the concrete class. Widening this interface is the
5
+ * explicit act of widening what features may do to the sessions domain.
6
+ */
7
+ import type { Context } from '@deepseek-ai/cordis';
8
+ import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client';
9
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
10
+ import type { WorkspaceId } from '@deepseek-ai/dsh-workspace/types';
11
+ import type { RemoteResult } from '@deepseek-ai/dsh-typert-protocol';
12
+ import type { AgentContext } from '../scope.ts';
13
+ import type { SessionSearchResultItem } from '../sessions/manager.ts';
14
+ import type { SessionBinding, SessionListState } from '../sessions/service.ts';
15
+ import type { SessionFace } from './session.ts';
16
+ import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-store';
17
+ export type { AgentContext } from '../scope.ts';
18
+ /** The sessions-service face injected as `ctx.sessions`. */
19
+ export interface ISessions {
20
+ /** The useSessions standard feed (list rows + current selection; read face — writes stay inside the domain). */
21
+ readonly list: ObservableSnapshot<SessionListState>;
22
+ /**
23
+ * The `session.search` result bound the wire schema fixes, exposed to
24
+ * presentation as injected data. Not per-connection state: every transport
25
+ * (fixture included) reports the same number.
26
+ */
27
+ readonly searchResultLimit: number;
28
+ /**
29
+ * Create or adopt a Session on the Host.
30
+ * @param opts - target workspace, directory, and optional preallocated identity.
31
+ * @returns the Session identity after its local binding is addressable.
32
+ */
33
+ create(opts?: {
34
+ workspaceId?: WorkspaceId;
35
+ cwd?: string;
36
+ sessionId?: SessionId;
37
+ }): Promise<SessionId>;
38
+ /**
39
+ * Select a session as current.
40
+ * @param id - session id (must exist in the list; unknown ids fail loud).
41
+ */
42
+ open(id: SessionId): void;
43
+ /**
44
+ * Open a healthy catalog child through its exact direct-parent address.
45
+ * @param address - catalog-derived parent and child ids.
46
+ */
47
+ openSubagent(address: SubagentAddress): void;
48
+ /**
49
+ * Resolve an already discovered direct-parent address without opening it.
50
+ * @param id - possible addressed child id.
51
+ * @returns the retained address, when present.
52
+ */
53
+ subagentAddress(id: SessionId): SubagentAddress | undefined;
54
+ /**
55
+ * Mark whether a catalog menu is consuming live membership updates.
56
+ * @param parentSessionId - catalog owner.
57
+ * @param open - current menu state.
58
+ */
59
+ setSubagentCatalogOpen(parentSessionId: SessionId, open: boolean): void;
60
+ /**
61
+ * Refresh one direct-child catalog.
62
+ * @param parentSessionId - catalog owner.
63
+ * @returns completion of the current or newly started refresh.
64
+ */
65
+ refreshSubagents(parentSessionId: SessionId): Promise<void>;
66
+ /** Clear the current selection into the no-session view state. */
67
+ clear(): void;
68
+ /**
69
+ * Refresh the Host-authoritative Session list.
70
+ * @returns completion of the current or newly started Session-list refresh.
71
+ */
72
+ refresh(): Promise<void>;
73
+ /**
74
+ * Search the Host's visible message-content index. Results stay
75
+ * request-local; the list snapshot remains the metadata authority.
76
+ * @param query - non-blank literal phrase.
77
+ * @param signal - cancellation for a superseded search.
78
+ * @returns bounded results, or a business/transport error.
79
+ */
80
+ search(query: string, signal: AbortSignal): Promise<RemoteResult<{
81
+ items: SessionSearchResultItem[];
82
+ hasMore: boolean;
83
+ }>>;
84
+ /**
85
+ * Fork a session from a completed-turn prefix of the source; on resolution
86
+ * the child is in the list store and `open()` can target it.
87
+ * @param opts - source session id, the optional event seq anchoring the
88
+ * cut (the boundary is the first turn/end at or after it; an in-log
89
+ * anchor in an open turn is unavailable rather than clipped backward),
90
+ * and whether to increment an inherited durable title before resolving.
91
+ * @returns the child session id.
92
+ * @throws when the fork fails, or when a requested child-title rename fails after creation.
93
+ */
94
+ fork(opts: {
95
+ sessionId: SessionId;
96
+ atSeq?: number;
97
+ increaseTitle?: boolean;
98
+ }): Promise<SessionId>;
99
+ /**
100
+ * Resolve an Agent-scoped context view (use-and-discard).
101
+ * @param id - session id.
102
+ * @returns scoped ctx, or undefined for a session neither listed nor already scoped.
103
+ */
104
+ scope(id: SessionId): AgentContext | undefined;
105
+ /**
106
+ * Read the Agent scope tag off a context (service-method boundary: fetch
107
+ * bundles must reach scope resolution through ctx.sessions).
108
+ * @param ctx - any client context.
109
+ * @returns the session id, or undefined on root contexts.
110
+ */
111
+ scopeOf(ctx: Context): SessionId | undefined;
112
+ /**
113
+ * Resolve the session face behind an Agent-scoped context.
114
+ * @param ctx - an Agent-scoped context.
115
+ * @returns the session face, or undefined when the ctx is untagged or its scope was pruned.
116
+ */
117
+ sessionOf(ctx: Context): SessionFace | undefined;
118
+ /**
119
+ * Resolve the stable session binding (scope-addressed assembly feed).
120
+ * @param id - session id.
121
+ * @returns binding, or undefined for a session neither listed nor already scoped.
122
+ */
123
+ binding(id: SessionId): SessionBinding | undefined;
124
+ }
125
+ //# sourceMappingURL=sessions.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=sessions.js.map
@@ -0,0 +1,82 @@
1
+ /** Session-owned observable state excluding Conversation target data. */
2
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm/types';
3
+ import type { MessageId } from '@deepseek-ai/dsh-llm/brand';
4
+ import type { SessionId } from '@deepseek-ai/dsh-session/types';
5
+ import type { SubagentAddress } from '@deepseek-ai/dsh-subagent/client';
6
+ import type { RemoteFailure } from '@deepseek-ai/dsh-typert-protocol';
7
+ import type { SessionRequestId } from '../../types.ts';
8
+ /** One transient inbox occurrence from the authoritative queue snapshot. */
9
+ export interface QueuedMessage {
10
+ readonly id: MessageId;
11
+ readonly messageId: MessageId;
12
+ readonly placement: 'queued' | 'steering' | 'context';
13
+ /** Prompt-RPC identity of a browser-submitted occurrence; correlates the local submission echo. */
14
+ readonly rpcId?: SessionRequestId;
15
+ readonly content: readonly ContentBlock[];
16
+ readonly preview: string;
17
+ readonly text: string | null;
18
+ }
19
+ /** One image displayed by a local submission echo before durable admission. */
20
+ export interface PendingSubmissionImage {
21
+ /** Browser-owned preview URL; its lifecycle belongs to the submitter, never this snapshot. */
22
+ readonly previewUrl: string;
23
+ /** Browser file name, when the file had one. */
24
+ readonly name?: string;
25
+ /** Intrinsic pixel width, when the submitter has probed it. */
26
+ readonly width?: number;
27
+ /** Intrinsic pixel height, when the submitter has probed it. */
28
+ readonly height?: number;
29
+ }
30
+ /** Client surface selected when a local submission begins. */
31
+ export type PendingSubmissionPlacement = 'transcript' | 'queued' | 'steering';
32
+ /**
33
+ * One local prompt-submission echo: inserted synchronously when a submission
34
+ * begins, so the conversation can show the message before serialization,
35
+ * transport, and durable admission complete. Client-memory only — reload and
36
+ * reconnect rebuild the conversation from durable events alone.
37
+ */
38
+ export interface PendingSubmission {
39
+ /** The prompt RPC identity; the durable `user/message` source echoes it as `rpcId`. */
40
+ readonly requestId: SessionRequestId;
41
+ /** Expected surface until the Host reports the admitted queue or durable occurrence. */
42
+ readonly placement: PendingSubmissionPlacement;
43
+ /** Client wall-clock ms when the submission began. */
44
+ readonly time: number;
45
+ /** Prompt text exactly as it will be sent (one text block). */
46
+ readonly text: string;
47
+ /** Ordered image previews matching the prompt's image parts. */
48
+ readonly images: readonly PendingSubmissionImage[];
49
+ }
50
+ /** History-open lifecycle of a Session event window. */
51
+ export type OpenState = 'cold' | 'loading' | 'open' | 'error';
52
+ /** Send/stop failure surfaced by Session consumers. */
53
+ export interface PromptError {
54
+ readonly op: 'send' | 'stop';
55
+ readonly error: RemoteFailure;
56
+ }
57
+ /** Immutable Session lifecycle and control snapshot. */
58
+ export interface SessionSnapshot {
59
+ readonly sessionId: SessionId;
60
+ readonly queue: readonly QueuedMessage[];
61
+ /** Local prompt-submission echoes not yet observed as durable events or queue occurrences. */
62
+ readonly pendingSubmissions: readonly PendingSubmission[];
63
+ readonly running: boolean;
64
+ readonly subagent: {
65
+ readonly address: SubagentAddress;
66
+ /** Absent until the direct-parent catalog resolves. */
67
+ readonly parentAvailable?: boolean;
68
+ } | null;
69
+ readonly removed: boolean;
70
+ readonly openState: OpenState;
71
+ readonly openError: RemoteFailure | null;
72
+ readonly hasMore: boolean;
73
+ readonly loadingOlder: boolean;
74
+ readonly promptError: PromptError | null;
75
+ readonly blank: boolean;
76
+ readonly lastAgentError: string | null;
77
+ /** A prompt call has begun on this Client Session object. */
78
+ readonly promptAttempted: boolean;
79
+ /** The first accepted prompt has not reached a durable `turn/start` event. */
80
+ readonly awaitingFirstTurn: boolean;
81
+ }
82
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1,30 @@
1
+ /** Client Session object layer, Agent scopes, and Remote lifecycle wiring. */
2
+ import type { Context } from '@deepseek-ai/cordis';
3
+ export { createSessionControlStream, SessionEventStream, SESSION_SEARCH_RESULT_LIMIT, SESSION_SEARCH_SNIPPET_MAX_CODE_POINTS, } from './transport.ts';
4
+ export type { ClientSessionPageRequest, SessionControlStream, SessionControlStreamOptions, SessionEventStreamOptions, SessionJournalChange, SessionRemote, } from './transport.ts';
5
+ export { createScope, scopeOf } from './scope.ts';
6
+ export type { AgentContext, AgentScopeHandle } from './scope.ts';
7
+ export { SessionCreateError, SessionForkError } from './sessions/service.ts';
8
+ export type { SessionBinding, SessionListState, SessionSummary } from './sessions/service.ts';
9
+ export type { SessionListPhase, SessionListSnapshot, SessionSearchResultItem, SubagentCatalogSnapshot, } from './sessions/manager.ts';
10
+ export type { Session } from './sessions/session.ts';
11
+ export type { ProjectionsBaseline, ProjectionValueStore, SessionProjectionMap, UseProjection, } from './sessions/projection-store.ts';
12
+ export type { BeginSubmissionInput, ISession, PendingSubmissionRetirement, ProjectionsFace, SessionFace, SubmissionHandle, } from './contract/session.ts';
13
+ export type { ISessions } from './contract/sessions.ts';
14
+ export { MutableSessionEventSource } from './contract/events.ts';
15
+ export type { SessionEventChange, SessionEventLike, SessionEventLikeEntry, SessionEventSource, SessionEventWindow, SessionLiveEventEntry, } from './contract/events.ts';
16
+ export type { OpenState, PendingSubmission, PendingSubmissionImage, PendingSubmissionPlacement, PromptError, QueuedMessage, SessionSnapshot, } from './contract/snapshot.ts';
17
+ declare module '@deepseek-ai/cordis' {
18
+ interface Context {
19
+ /** Client Session object layer and Agent scope owner. */
20
+ sessions: import('./contract/sessions.ts').ISessions;
21
+ }
22
+ }
23
+ /** Required Remote and Context projection services. */
24
+ export declare const inject: string[];
25
+ /**
26
+ * Install Client Session state and its reconnecting control stream.
27
+ * @param ctx - Client Cordis context.
28
+ */
29
+ export declare function apply(ctx: Context): void;
30
+ //# sourceMappingURL=index.d.ts.map