@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,192 @@
1
+ /** Session-addressed, cold-readable skill catalog Remote. */
2
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
3
+ var useValue = arguments.length > 2;
4
+ for (var i = 0; i < initializers.length; i++) {
5
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
6
+ }
7
+ return useValue ? value : void 0;
8
+ };
9
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
10
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
11
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
12
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
13
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
14
+ var _, done = false;
15
+ for (var i = decorators.length - 1; i >= 0; i--) {
16
+ var context = {};
17
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
18
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
19
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
20
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21
+ if (kind === "accessor") {
22
+ if (result === void 0) continue;
23
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24
+ if (_ = accept(result.get)) descriptor.get = _;
25
+ if (_ = accept(result.set)) descriptor.set = _;
26
+ if (_ = accept(result.init)) initializers.unshift(_);
27
+ }
28
+ else if (_ = accept(result)) {
29
+ if (kind === "field") initializers.unshift(_);
30
+ else descriptor[key] = _;
31
+ }
32
+ }
33
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
34
+ done = true;
35
+ };
36
+ var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) {
37
+ if (value !== null && value !== void 0) {
38
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
39
+ var dispose, inner;
40
+ if (async) {
41
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
42
+ dispose = value[Symbol.asyncDispose];
43
+ }
44
+ if (dispose === void 0) {
45
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
46
+ dispose = value[Symbol.dispose];
47
+ if (async) inner = dispose;
48
+ }
49
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
50
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
51
+ env.stack.push({ value: value, dispose: dispose, async: async });
52
+ }
53
+ else if (async) {
54
+ env.stack.push({ async: true });
55
+ }
56
+ return value;
57
+ };
58
+ var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) {
59
+ return function (env) {
60
+ function fail(e) {
61
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
62
+ env.hasError = true;
63
+ }
64
+ var r, s = 0;
65
+ function next() {
66
+ while (r = env.stack.pop()) {
67
+ try {
68
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
69
+ if (r.dispose) {
70
+ var result = r.dispose.call(r.value);
71
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
72
+ }
73
+ else s |= 1;
74
+ }
75
+ catch (e) {
76
+ fail(e);
77
+ }
78
+ }
79
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
80
+ if (env.hasError) throw env.error;
81
+ }
82
+ return next();
83
+ };
84
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
85
+ var e = new Error(message);
86
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
87
+ });
88
+ import { SessionQueryError } from '@deepseek-ai/dsh-session-query';
89
+ import { isUserInvocable } from '@deepseek-ai/dsh-skill';
90
+ import { Remote, RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
91
+ /** Host service backing `ctx.remote.skills` without activating a cold Agent. */
92
+ let SessionSkillCatalog = (() => {
93
+ let _classSuper = TypertRemoteService;
94
+ let _instanceExtraInitializers = [];
95
+ let _list_decorators;
96
+ return class SessionSkillCatalog extends _classSuper {
97
+ static {
98
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
99
+ _list_decorators = [Remote];
100
+ __esDecorate(this, null, _list_decorators, { kind: "method", name: "list", static: false, private: false, access: { has: obj => "list" in obj, get: obj => obj.list }, metadata: _metadata }, null, _instanceExtraInitializers);
101
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
102
+ }
103
+ static inject = ['agents', 'sessionQuery', 'typert'];
104
+ /** @param ctx - Host context carrying Session reads and optional skill/preset services. */
105
+ constructor(ctx) {
106
+ super(ctx, 'sessionSkillCatalog', { namespace: 'skills' });
107
+ __runInitializers(this, _instanceExtraInitializers);
108
+ }
109
+ /**
110
+ * List the user-invocable skills visible to one Session composition.
111
+ * @param request - Session identity whose cwd and preset select the catalog view.
112
+ * @param signal - caller lifetime carried by the Remote transport; admitted catalog reads retain their existing completion semantics.
113
+ * @returns user-invocable skill metadata without loading skill bodies.
114
+ * @throws RemoteError when the Session cannot be inspected or no registry can serve it.
115
+ */
116
+ async list(request, signal) {
117
+ void signal;
118
+ const { sessionId } = request;
119
+ let cwd;
120
+ let agentPreset;
121
+ try {
122
+ const env_1 = { stack: [], error: void 0, hasError: false };
123
+ try {
124
+ const observation = __addDisposableResource(env_1, await this.ctx.sessionQuery.observeSession(sessionId), false);
125
+ if (observation.projections === undefined) {
126
+ throw new Error('skill catalog requires a projected Session observation');
127
+ }
128
+ cwd = observation.header.cwd;
129
+ agentPreset = observation.projections.values.agentPreset ?? undefined;
130
+ }
131
+ catch (e_1) {
132
+ env_1.error = e_1;
133
+ env_1.hasError = true;
134
+ }
135
+ finally {
136
+ __disposeResources(env_1);
137
+ }
138
+ }
139
+ catch (error) {
140
+ if (error instanceof SessionQueryError
141
+ && error.code === 'SESSION_QUERY_SESSION_NOT_FOUND') {
142
+ throw new RemoteError('session/not-found', `session "${sessionId}" not found`, { sessionId });
143
+ }
144
+ throw new RemoteError('gateway/internal', `session "${sessionId}" could not be inspected: ${String(error)}`, {});
145
+ }
146
+ if (cwd === undefined) {
147
+ throw new RemoteError('gateway/internal', `session "${sessionId}" has no project cwd`, {});
148
+ }
149
+ const live = this.ctx.agents.get(sessionId);
150
+ const presets = this.ctx.get('agentPresets');
151
+ const scoped = live === undefined ? undefined : presets?.serviceFor(live, 'skills');
152
+ const skillRegistry = scoped ?? this.ctx.get('skills');
153
+ if (skillRegistry === undefined) {
154
+ throw new RemoteError('gateway/internal', 'skill registry is absent: neither this session\'s agent preset nor the host composition mounts @deepseek-ai/dsh-skill', {});
155
+ }
156
+ const scope = await this.scopeFor(sessionId, agentPreset);
157
+ try {
158
+ const skills = (await skillRegistry.list({ cwd, scope })).filter(isUserInvocable);
159
+ return {
160
+ skills: skills.map(skill => ({
161
+ name: skill.name,
162
+ description: skill.description,
163
+ ...skill.whenToUse === undefined ? {} : { whenToUse: skill.whenToUse },
164
+ modelInvocable: skill.invocation.modelInvocable,
165
+ })),
166
+ };
167
+ }
168
+ catch (error) {
169
+ throw new RemoteError('gateway/internal', `skill listing failed: ${String(error)}`, {});
170
+ }
171
+ }
172
+ /** Resolve a live or standing preset scope without creating an Agent. */
173
+ async scopeFor(sessionId, agentPreset) {
174
+ const live = this.ctx.agents.get(sessionId);
175
+ if (live !== undefined)
176
+ return live;
177
+ const presets = this.ctx.get('agentPresets');
178
+ if (presets === undefined)
179
+ return undefined;
180
+ try {
181
+ return await presets.standingKeyFor(agentPreset);
182
+ }
183
+ catch {
184
+ // An unknown or unusable recorded preset falls back to the global registry.
185
+ return undefined;
186
+ }
187
+ }
188
+ };
189
+ })();
190
+ export { SessionSkillCatalog };
191
+ export default SessionSkillCatalog;
192
+ //# sourceMappingURL=skill-catalog.js.map
@@ -0,0 +1,505 @@
1
+ /** Browser-safe request, result, and lifecycle vocabulary for the Session Remote service. */
2
+ import type { AttachmentIdType, ImageAttachmentLimits, ImageAttachmentRef, ImageMediaType } from '@deepseek-ai/dsh-attachment';
3
+ import type { Branded } from '@deepseek-ai/dsh-brand';
4
+ import type { MessageId } from '@deepseek-ai/dsh-llm/brand';
5
+ import type { ContentBlock } from '@deepseek-ai/dsh-llm/types';
6
+ import type { ChunkRow } from '@deepseek-ai/dsh-session/chunk-rows';
7
+ import type { SessionHeader, SessionId, SurfaceOp } from '@deepseek-ai/dsh-session/types';
8
+ import type { SessionProjectionMap } from '@deepseek-ai/dsh-session-projection/types';
9
+ import type { JobId } from '@deepseek-ai/dsh-jobs/brand';
10
+ import type { JsonValue } from '@deepseek-ai/dsh-util-values';
11
+ import type { WorkspaceId } from '@deepseek-ai/dsh-workspace/types';
12
+ declare module '@deepseek-ai/dsh-session-projection/types' {
13
+ interface SessionProjectionStateMap {
14
+ /** Host state persisted for cold Session list summaries. */
15
+ sessionListMetadata: SessionListMetadata;
16
+ /** Host state for the boot-constant image-limit view. */
17
+ imageLimits: null;
18
+ /** Durable model selection already used by a request and still pending for a later request. */
19
+ modelSelection: ModelSelectionProjectionState;
20
+ }
21
+ interface SessionProjectionMap {
22
+ /** Persisted facts used to summarize a Session without activating it. */
23
+ sessionListMetadata: SessionListMetadata;
24
+ /** Image-intake limits enforced by the Session prompt endpoint. */
25
+ imageLimits: ImageAttachmentLimits;
26
+ /** Durable model selection already used and selected for the next request. */
27
+ modelSelection: ModelSelectionProjection;
28
+ }
29
+ }
30
+ declare module '@deepseek-ai/dsh-session/types' {
31
+ interface SessionEventMap {
32
+ /**
33
+ * Complete validated model selection requested for subsequent prompt
34
+ * assembly. Log-only: it never enters derived model history.
35
+ */
36
+ 'model/selection': ModelSelection;
37
+ }
38
+ }
39
+ /** Persisted hints used to summarize a cold Session. */
40
+ export interface SessionListMetadata {
41
+ /** Whether the folded prefix contains no turn. */
42
+ readonly blank: boolean;
43
+ /** Latest human-authored prompt time in the folded prefix. */
44
+ readonly lastPromptAt: number | null;
45
+ }
46
+ /** Every available cached wire value used as partial, possibly stale Session-list hints. */
47
+ export interface SessionProjectionHints {
48
+ readonly asOfSeq: number;
49
+ /** Provider-validated values present in the cache; omitted keys remain unknown. */
50
+ readonly values: SessionProjectionValues;
51
+ }
52
+ /** Complete projection values at an exact Session event cursor. */
53
+ export interface SessionProjectionBaseline {
54
+ readonly asOfSeq: number;
55
+ /** Provider-validated values; omitted keys are absent capabilities at this cut. */
56
+ readonly values: SessionProjectionValues;
57
+ }
58
+ /** Typed known projections plus JSON-safe values contributed outside this compilation face. */
59
+ export type SessionProjectionValues = Partial<SessionProjectionMap> & Readonly<Record<string, SessionProjectionValue>>;
60
+ /** Browser-submitted prompt content; the Host promotes image bytes to durable references. */
61
+ export type PromptContentPart = {
62
+ readonly type: 'text';
63
+ readonly text: string;
64
+ } | {
65
+ readonly type: 'image';
66
+ readonly mediaType: ImageMediaType;
67
+ readonly data: string;
68
+ readonly name?: string;
69
+ };
70
+ /** Complete model selection for one Session. */
71
+ export interface ModelSelection {
72
+ readonly provider: string;
73
+ readonly model: string;
74
+ readonly reasoningEffort?: string;
75
+ }
76
+ /** Host fold state for durable model selection. */
77
+ export interface ModelSelectionProjectionState {
78
+ /** Selection consumed by the latest recorded model request. */
79
+ readonly lastUsed: ModelSelection | null;
80
+ /** Later user selection not yet consumed by a matching model request. */
81
+ readonly pending: ModelSelection | null;
82
+ }
83
+ /** Client view of the durable model-selection fold. */
84
+ export interface ModelSelectionProjection {
85
+ /** Selection consumed by the latest recorded model request. */
86
+ readonly lastUsed: ModelSelection | null;
87
+ /** Selection the next request should use, falling back to {@link lastUsed}. */
88
+ readonly next: ModelSelection | null;
89
+ }
90
+ /** One adapter-owned reasoning effort for an exact model route. */
91
+ export interface ModelReasoningEffort {
92
+ readonly id: string;
93
+ readonly name: string;
94
+ readonly description?: string;
95
+ }
96
+ /** Selectable reasoning metadata for one exact model route. */
97
+ export interface ModelReasoning {
98
+ readonly efforts: readonly ModelReasoningEffort[];
99
+ readonly defaultEffort?: string;
100
+ }
101
+ /** One model displayed inside its provider group. */
102
+ export interface ModelCatalogModel {
103
+ readonly id: string;
104
+ readonly name: string;
105
+ readonly description?: string;
106
+ readonly reasoning?: ModelReasoning;
107
+ }
108
+ /** One provider and its successfully loaded model catalog. */
109
+ export interface ModelProviderGroup {
110
+ readonly id: string;
111
+ readonly name: string;
112
+ readonly models: readonly ModelCatalogModel[];
113
+ }
114
+ /** One provider whose model catalog lookup failed. */
115
+ export interface ModelCatalogFailure {
116
+ readonly id: string;
117
+ readonly name: string;
118
+ readonly message: string;
119
+ }
120
+ /** Host-generation model catalog and the default used by unconfigured Sessions. */
121
+ export interface ModelCatalog {
122
+ readonly default: ModelSelection;
123
+ /** Provider routes currently able to serve a request, including empty catalogs. */
124
+ readonly routableProviders: readonly string[];
125
+ readonly groups: readonly ModelProviderGroup[];
126
+ readonly failures: readonly ModelCatalogFailure[];
127
+ }
128
+ /** One client-requested mutation of a still-pending queue item. */
129
+ export type QueueAction = {
130
+ readonly kind: 'edit';
131
+ readonly content: readonly ContentBlock[];
132
+ } | {
133
+ readonly kind: 'remove';
134
+ } | {
135
+ readonly kind: 'steer';
136
+ };
137
+ /** One Session list entry. */
138
+ export interface SessionSummary {
139
+ readonly sessionId: SessionId;
140
+ readonly updatedAt: number;
141
+ readonly running: boolean;
142
+ readonly blank: boolean;
143
+ readonly parentSessionId?: SessionId;
144
+ readonly origin?: 'subagent';
145
+ readonly cwd?: string;
146
+ readonly projections?: SessionProjectionHints;
147
+ }
148
+ /** One session-content search result. */
149
+ export interface SessionSearchItem {
150
+ readonly sessionId: SessionId;
151
+ readonly snippet: string;
152
+ }
153
+ /** Maximum number of Sessions returned by one search. */
154
+ export declare const SESSION_SEARCH_RESULT_LIMIT = 20;
155
+ /** Maximum search snippet length in Unicode code points. */
156
+ export declare const SESSION_SEARCH_SNIPPET_MAX_CODE_POINTS = 240;
157
+ declare module '@deepseek-ai/dsh-typert-protocol' {
158
+ interface RemoteErrorDetailsMap {
159
+ 'session/model-unavailable': {
160
+ readonly provider: string;
161
+ readonly model: string;
162
+ };
163
+ 'session/conflict': {
164
+ readonly sessionId: SessionId;
165
+ readonly requestedCwd: string;
166
+ readonly existingCwd?: string;
167
+ };
168
+ 'session/agent-busy': {
169
+ readonly reason: string;
170
+ };
171
+ 'session/invalid-time-zone': {
172
+ readonly value: string;
173
+ };
174
+ 'session/workspace-attach-failed': {
175
+ readonly sessionId: SessionId;
176
+ readonly workspaceId: string;
177
+ };
178
+ 'agent-preset/conflict': {
179
+ readonly sessionId: SessionId;
180
+ readonly requestedPreset: string;
181
+ readonly existingPreset?: string;
182
+ };
183
+ 'session/attachment-invalid': {
184
+ readonly reason: string;
185
+ };
186
+ 'session/queue-item-not-found': {
187
+ readonly itemId: MessageId;
188
+ };
189
+ 'session/steer-unavailable': {
190
+ readonly itemId: MessageId;
191
+ };
192
+ 'session/title-invalid': {
193
+ readonly sessionId: SessionId;
194
+ };
195
+ 'session/fork-unavailable': {
196
+ readonly sessionId: SessionId;
197
+ };
198
+ 'subagent/not-found': {
199
+ readonly parentSessionId: SessionId;
200
+ readonly childSessionId: SessionId;
201
+ };
202
+ 'subagent/catalog-diagnostic': {
203
+ readonly parentSessionId: SessionId;
204
+ readonly childSessionId: SessionId;
205
+ readonly reason: 'corrupt' | 'unsupported' | 'unavailable';
206
+ };
207
+ }
208
+ }
209
+ /** Session-addressed request for the human-invocable skill catalog. */
210
+ export interface SkillListRequest {
211
+ readonly sessionId: SessionId;
212
+ }
213
+ /** One skill available to the Session's human-facing composer. */
214
+ export interface SkillEntry {
215
+ /** Kebab-case identifier referenced as `/name`. */
216
+ readonly name: string;
217
+ /** Short routing description. */
218
+ readonly description: string;
219
+ /** Optional extra routing guidance. */
220
+ readonly whenToUse?: string;
221
+ /** Whether the same skill is also advertised to the model. */
222
+ readonly modelInvocable: boolean;
223
+ }
224
+ /** Human-invocable skills visible through one Session's composition. */
225
+ export interface SkillListValue {
226
+ readonly skills: readonly SkillEntry[];
227
+ }
228
+ /** Session list request. */
229
+ export interface SessionListRequest {
230
+ readonly cursor?: string;
231
+ }
232
+ /** Session list response value. */
233
+ export interface SessionListValue {
234
+ readonly items: readonly SessionSummary[];
235
+ }
236
+ /** Session search request. */
237
+ export interface SessionSearchRequest {
238
+ readonly query: string;
239
+ }
240
+ /** Session search response value. */
241
+ export interface SessionSearchValue {
242
+ readonly items: readonly SessionSearchItem[];
243
+ readonly hasMore: boolean;
244
+ }
245
+ /** Session creation or explicit-id adoption request. */
246
+ export interface SessionCreateRequest {
247
+ readonly workspaceId?: WorkspaceId;
248
+ readonly cwd?: string;
249
+ readonly sessionId?: SessionId;
250
+ readonly agentPreset?: string;
251
+ }
252
+ /** Session creation response value. */
253
+ export interface SessionCreateValue {
254
+ readonly sessionId: SessionId;
255
+ readonly agentPreset?: string;
256
+ }
257
+ /** Session model-selection request. */
258
+ export interface SessionSelectModelRequest extends ModelSelection {
259
+ readonly sessionId: SessionId;
260
+ }
261
+ /** Accepted model selection after Host resolution. */
262
+ export interface SessionSelectModelValue {
263
+ readonly selected: ModelSelection;
264
+ }
265
+ /** Session rename request. */
266
+ export interface SessionRenameRequest {
267
+ readonly sessionId: SessionId;
268
+ readonly title: string;
269
+ }
270
+ /** Normalized title and the durable event position that committed it. */
271
+ export interface SessionRenameValue {
272
+ readonly title: string;
273
+ readonly seq: number;
274
+ }
275
+ /** Session fork request. */
276
+ export interface SessionForkRequest {
277
+ readonly sessionId: SessionId;
278
+ readonly atSeq?: number;
279
+ }
280
+ /** Identity of a newly forked Session. */
281
+ export interface SessionForkValue {
282
+ readonly sessionId: SessionId;
283
+ }
284
+ /** Session prompt request. */
285
+ export interface SessionPromptRequest {
286
+ /** Client-minted identity persisted on the exact accepted user message. */
287
+ readonly requestId: SessionRequestId;
288
+ readonly sessionId: SessionId;
289
+ readonly mode: 'queue' | 'steer';
290
+ readonly content: readonly PromptContentPart[];
291
+ readonly clientTimeZone?: string;
292
+ }
293
+ /** Receipt after one prompt enters the target Agent inbox. */
294
+ export interface SessionPromptValue {
295
+ readonly accepted: true;
296
+ }
297
+ /** Durable image read request. */
298
+ export interface SessionAttachmentRequest {
299
+ readonly sessionId: SessionId;
300
+ readonly attachmentId: AttachmentIdType;
301
+ }
302
+ /** Durable image read response value. */
303
+ export interface SessionAttachmentValue {
304
+ readonly attachment: ImageAttachmentRef;
305
+ readonly data: string;
306
+ }
307
+ /** Pending queue mutation request. */
308
+ export interface SessionUpdateQueueRequest {
309
+ readonly sessionId: SessionId;
310
+ readonly itemId: MessageId;
311
+ readonly action: QueueAction;
312
+ }
313
+ /** Receipt after one pending queue mutation commits. */
314
+ export interface SessionUpdateQueueValue {
315
+ readonly accepted: true;
316
+ }
317
+ /** Active-turn cancellation request. */
318
+ export interface SessionCancelRequest {
319
+ readonly sessionId: SessionId;
320
+ }
321
+ /** Receipt after cancellation is admitted to the live Agent. */
322
+ export interface SessionCancelValue {
323
+ readonly accepted: true;
324
+ }
325
+ /** Request to open one path prepared by a Session-aware caller on the Host desktop. */
326
+ export interface SessionOpenWorkspacePathRequest {
327
+ /** Path after best-effort Session workspace resolution, in Host filesystem syntax. */
328
+ readonly path: string;
329
+ }
330
+ /** Confirmation that the Host handed a workspace path to its native opener. */
331
+ export interface SessionOpenWorkspacePathValue {
332
+ readonly opened: true;
333
+ }
334
+ /** Client-minted prompt identity used to reconcile optimistic and durable messages. */
335
+ export type SessionRequestId = Branded<'session-request-id'>;
336
+ declare module '@deepseek-ai/dsh-llm' {
337
+ interface MessageSourceMap {
338
+ /** Browser prompt correlation and optional Host-validated time zone. */
339
+ 'user-rpc': {
340
+ kind: 'user';
341
+ rpcId: SessionRequestId;
342
+ clientTimeZone?: string;
343
+ };
344
+ }
345
+ }
346
+ /** Durable identity selecting an ordinary Session or one direct subagent child. */
347
+ export type SessionAddress = {
348
+ readonly kind: 'session';
349
+ readonly sessionId: SessionId;
350
+ } | {
351
+ readonly kind: 'subagent';
352
+ readonly parentSessionId: SessionId;
353
+ readonly childSessionId: SessionId;
354
+ readonly mode: 'one-shot' | 'continuable';
355
+ };
356
+ /** One raw Session event in the Remote journal. */
357
+ export interface SessionEventEntry {
358
+ readonly type: 'event';
359
+ readonly event: SessionWireEvent;
360
+ }
361
+ /** Event-shaped wire representation of one packed chunk row. */
362
+ export type ChunkRowEvent = {
363
+ [Kind in ChunkRow['type']]: {
364
+ readonly type: `chunkrow/${Kind}`;
365
+ readonly seq: number;
366
+ readonly time: number;
367
+ readonly data: Extract<ChunkRow, {
368
+ readonly type: Kind;
369
+ }>['data'];
370
+ };
371
+ }[ChunkRow['type']];
372
+ /** One lossless run of consecutive Assistant delta events in a history page. */
373
+ export interface SessionChunkRun {
374
+ readonly type: 'chunks';
375
+ readonly event: ChunkRowEvent;
376
+ }
377
+ /** One history-page record: a raw event or a packed Assistant delta run. */
378
+ export type SessionHistoryRecord = SessionEventEntry | SessionChunkRun;
379
+ /** Session event wire form; durable readers own recognition of merge-extensible event names. */
380
+ export interface SessionWireEvent {
381
+ readonly type: string;
382
+ readonly seq: number;
383
+ readonly time: number;
384
+ readonly data: JsonValue;
385
+ readonly ignorable?: true;
386
+ readonly sourceEventSeqs?: number[];
387
+ readonly surfaceOp?: SurfaceOp;
388
+ }
389
+ /** One message-aligned backwards-history request. */
390
+ export interface SessionPageRequest {
391
+ readonly address: SessionAddress;
392
+ /** Inclusive log cut obtained from the corresponding follow opening frame. */
393
+ readonly throughSeq: number;
394
+ readonly beforeSeq?: number;
395
+ readonly maxMessages?: number;
396
+ }
397
+ /** One live event request for a durable Session address. */
398
+ export interface SessionFollowRequest {
399
+ readonly address: SessionAddress;
400
+ readonly maxMessages?: number;
401
+ }
402
+ /** One contiguous backwards page of a Session log. */
403
+ export interface SessionPage {
404
+ readonly records: readonly SessionHistoryRecord[];
405
+ readonly hasMore: boolean;
406
+ }
407
+ /** Complete opening window followed by ordered events appended after its cursor. */
408
+ export type SessionFollowFrame = {
409
+ readonly type: 'snapshot';
410
+ readonly header: SessionHeader;
411
+ readonly cursor: number;
412
+ readonly records: readonly SessionHistoryRecord[];
413
+ readonly hasMore: boolean;
414
+ readonly projections: SessionProjectionBaseline;
415
+ } | SessionEventEntry;
416
+ /** One pending inbox occurrence in the authoritative queue snapshot. */
417
+ export interface SessionQueuedItem {
418
+ readonly id: MessageId;
419
+ readonly placement: 'queued' | 'steering' | 'context';
420
+ /** Prompt-RPC identity from the queued message's user source; clients retire the matching local submission echo on it. */
421
+ readonly rpcId?: SessionRequestId;
422
+ /** JSON-safe message fields consumed by pending-queue presentation. */
423
+ readonly message: {
424
+ readonly id: MessageId;
425
+ readonly content: readonly JsonValue[];
426
+ };
427
+ }
428
+ /** Browser-safe background-job row. */
429
+ export interface SessionJob {
430
+ readonly id: JobId;
431
+ readonly kind: string;
432
+ readonly label: string;
433
+ readonly status: 'running' | 'stopping' | 'completed' | 'killed' | 'failed';
434
+ readonly detail?: string;
435
+ readonly startedAt: number;
436
+ readonly finishedAt?: number;
437
+ }
438
+ /** Complete live control baseline emitted once per control stream generation. */
439
+ export interface SessionControlBaseline {
440
+ readonly queues: Readonly<Record<SessionId, readonly SessionQueuedItem[]>>;
441
+ readonly jobs: Readonly<Record<SessionId, readonly SessionJob[]>>;
442
+ readonly projections: Readonly<Record<SessionId, SessionProjectionBaseline>>;
443
+ }
444
+ /** One finished projection value and its durable watermark. */
445
+ export interface SessionProjectionUpdate {
446
+ readonly sessionId: SessionId;
447
+ readonly key: string;
448
+ readonly value: JsonValue;
449
+ readonly seq: number;
450
+ }
451
+ /** Host-wide live state stream. Each generation starts with exactly one baseline. */
452
+ export type SessionControlFrame = {
453
+ readonly type: 'baseline';
454
+ readonly value: SessionControlBaseline;
455
+ } | {
456
+ readonly type: 'queue';
457
+ readonly sessionId: SessionId;
458
+ readonly items: readonly SessionQueuedItem[];
459
+ } | {
460
+ readonly type: 'jobs';
461
+ readonly sessionId: SessionId;
462
+ readonly jobs: readonly SessionJob[];
463
+ } | ({
464
+ readonly type: 'projection';
465
+ } & SessionProjectionUpdate);
466
+ declare module '@deepseek-ai/cordis' {
467
+ interface Events {
468
+ /**
469
+ * A Session became visible to Session list consumers.
470
+ * @mode emit
471
+ * @param summary - initial list row for the Session.
472
+ */
473
+ 'api-session/added'(summary: SessionSummary): void;
474
+ /**
475
+ * A Session left the live Host registry.
476
+ * @mode emit
477
+ * @param sessionId - removed Session identity.
478
+ */
479
+ 'api-session/removed'(sessionId: SessionId): void;
480
+ /**
481
+ * One Agent changed running state.
482
+ * @mode emit
483
+ * @param sessionId - Agent and Session identity.
484
+ * @param running - whether the Agent is running.
485
+ */
486
+ 'api-session/status'(sessionId: SessionId, running: boolean): void;
487
+ /**
488
+ * One user-authored durable message advanced Session list activity.
489
+ * @mode emit
490
+ * @param sessionId - addressed Session identity.
491
+ * @param updatedAt - durable message time used for list ordering.
492
+ */
493
+ 'api-session/activity'(sessionId: SessionId, updatedAt: number): void;
494
+ /**
495
+ * One Agent failed outside a durable turn position.
496
+ * @mode emit
497
+ * @param sessionId - Agent and Session identity.
498
+ * @param message - user-safe failure chain.
499
+ */
500
+ 'api-session/error'(sessionId: SessionId, message: string): void;
501
+ }
502
+ }
503
+ /** JSON-compatible projection value accepted by list consumers. */
504
+ export type SessionProjectionValue = JsonValue;
505
+ //# sourceMappingURL=types.d.ts.map