@deepseek-ai/dsh-api-workspace-files 0.1.6-alpha.2 → 0.1.7-alpha.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.
@@ -3,6 +3,8 @@ import { z } from 'zod'
3
3
 
4
4
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema$value
5
5
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
6
+ let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema$value
7
+ const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema$value ??= z.string())
6
8
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema$value
7
9
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema$value ??= z.union([z.object({
8
10
  'kind': z.literal("ready").readonly(),
@@ -49,47 +51,22 @@ const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_read_result$schema = (
49
51
  'version': z.string().readonly(),
50
52
  'bytes': z.number().readonly().optional(),
51
53
  }))
52
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema$value
53
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
54
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema$value
55
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema$value ??= z.string())
56
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema$value
57
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema$value ??= z.object({
58
- 'offset': z.number().readonly(),
59
- 'data': z.string().readonly(),
60
- 'eof': z.boolean().readonly(),
61
- 'absolutePath': z.string().readonly(),
62
- 'version': z.string().readonly(),
63
- 'bytes': z.number().readonly().optional(),
64
- }))
65
54
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_0$schema$value
66
55
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
67
56
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_1$schema$value
68
57
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_1$schema$value ??= z.string())
69
58
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema$value
70
59
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema$value ??= z.object({
60
+ 'range': z.object({
71
61
  'offset': z.number().readonly().optional(),
72
62
  'length': z.number().readonly().optional(),
63
+ }).readonly().optional(),
64
+ 'baseFile': z.string().readonly().optional(),
73
65
  }))
74
66
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema$value
75
67
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema$value ??= z.object({
76
68
  'offset': z.number().readonly(),
77
- 'data': z.string().readonly(),
78
- 'eof': z.boolean().readonly(),
79
- 'absolutePath': z.string().readonly(),
80
- 'version': z.string().readonly(),
81
- 'bytes': z.number().readonly().optional(),
82
- }))
83
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema$value
84
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
85
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema$value
86
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema$value ??= z.string())
87
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema$value
88
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema$value ??= z.string())
89
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema$value
90
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema$value ??= z.object({
91
- 'offset': z.number().readonly(),
92
- 'data': z.string().readonly(),
69
+ 'data': z.instanceof(Uint8Array),
93
70
  'eof': z.boolean().readonly(),
94
71
  'absolutePath': z.string().readonly(),
95
72
  'version': z.string().readonly(),
@@ -105,6 +82,42 @@ const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_stat_result$schema = (
105
82
  'version': z.string().readonly(),
106
83
  'bytes': z.number().readonly().optional(),
107
84
  }))
85
+ const $resultSnapshot = (input, path) => {
86
+ if (input === null || typeof input !== 'object' || input instanceof Uint8Array) return input
87
+ const toJSON = input.toJSON
88
+ const value = typeof toJSON === 'function' ? toJSON.call(input, path.at(-1)?.toString() ?? 'value') : input
89
+ if (value === null || typeof value !== 'object' || value instanceof Uint8Array) return value
90
+ if (Array.isArray(value)) {
91
+ const items = []
92
+ for (let index = 0, length = value.length; index < length; index++) items.push(value[index])
93
+ return items
94
+ }
95
+ const fields = {}
96
+ for (const key of Object.keys(value)) {
97
+ const item = key === 'toJSON' && value === input ? toJSON : value[key]
98
+ if (key === 'toJSON' && typeof item === 'function') continue
99
+ Object.defineProperty(fields, key, { value: item, enumerable: true, writable: true, configurable: true })
100
+ }
101
+ return fields
102
+ }
103
+ const $resultContainer = (input, path, ancestors, project, snapshot) => {
104
+ if (input === null || typeof input !== 'object') return project(input)
105
+ const owner = !ancestors.has(input)
106
+ if (!owner && ancestors.get(input) !== path.length) throw new TypeError('Remote result contains a circular object')
107
+ if (owner) ancestors.set(input, path.length)
108
+ try { return project(snapshot ? $resultSnapshot(input, path) : input) }
109
+ finally { if (owner) ancestors.delete(input) }
110
+ }
111
+ const $encode1 = (value, writeBytes, path, ancestors) => {
112
+ return value instanceof Uint8Array ? writeBytes(value, path) : value
113
+ }
114
+ const $encode0 = (value, writeBytes, path, ancestors) => {
115
+ return $resultContainer(value, path, ancestors, value => {
116
+ if (value === null || typeof value !== 'object' || Array.isArray(value) || value instanceof Uint8Array) return value
117
+ if (Object.hasOwn(value, 'data')) value['data'] = $encode1(value['data'], writeBytes, [...path, 'data'], ancestors)
118
+ return value
119
+ }, true)
120
+ }
108
121
 
109
122
  export const TYPERT = {
110
123
  package: '@deepseek-ai/dsh-api-workspace-files',
@@ -131,6 +144,16 @@ export const TYPERT = {
131
144
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema,
132
145
  },
133
146
  },
147
+ {
148
+ name: 'path',
149
+ wire: 'path',
150
+ source: 'json',
151
+ codec: {
152
+ mode: 'strict',
153
+ typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/changes:path',
154
+ create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema,
155
+ },
156
+ },
134
157
  ],
135
158
  cancellation: { parameter: 'signal' },
136
159
  result: {
@@ -138,7 +161,7 @@ export const TYPERT = {
138
161
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileWatchFrame',
139
162
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema,
140
163
  },
141
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":364,"column":3},
164
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":331,"column":3},
142
165
  },
143
166
  {
144
167
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/list',
@@ -175,7 +198,7 @@ export const TYPERT = {
175
198
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceDirectoryListing',
176
199
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_list_result$schema,
177
200
  },
178
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":336,"column":9},
201
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":303,"column":9},
179
202
  },
180
203
  {
181
204
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/read',
@@ -222,44 +245,7 @@ export const TYPERT = {
222
245
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileText',
223
246
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_read_result$schema,
224
247
  },
225
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":232,"column":9},
226
- },
227
- {
228
- id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readAll',
229
- service: 'workspaceFiles',
230
- namespace: 'workspaceFiles',
231
- method: 'readAll',
232
- invocation: { kind: 'direct' },
233
- parameters: [
234
- {
235
- name: 'workspaceFileScope',
236
- wire: 'workspaceFileScopeId',
237
- source: 'lookup',
238
- lookup: 'workspaceFileScope',
239
- codec: {
240
- mode: 'strict',
241
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
242
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema,
243
- },
244
- },
245
- {
246
- name: 'path',
247
- wire: 'path',
248
- source: 'json',
249
- codec: {
250
- mode: 'strict',
251
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readAll:path',
252
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema,
253
- },
254
- },
255
- ],
256
- cancellation: { parameter: 'signal' },
257
- result: {
258
- mode: 'strict',
259
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileBytes',
260
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema,
261
- },
262
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":278,"column":9},
248
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":233,"column":9},
263
249
  },
264
250
  {
265
251
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readBytes',
@@ -290,12 +276,12 @@ export const TYPERT = {
290
276
  },
291
277
  },
292
278
  {
293
- name: 'range',
294
- wire: 'range',
279
+ name: 'options',
280
+ wire: 'options',
295
281
  source: 'json',
296
282
  codec: {
297
283
  mode: 'strict',
298
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceByteRange',
284
+ typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceByteReadOptions',
299
285
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema,
300
286
  },
301
287
  },
@@ -305,56 +291,11 @@ export const TYPERT = {
305
291
  mode: 'strict',
306
292
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileBytes',
307
293
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema,
294
+ decode: value => _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema().parse(value),
295
+ encode: (value, writeBytes) => $encode0(value, writeBytes, [], new Map()),
308
296
  },
309
297
  sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":257,"column":9},
310
298
  },
311
- {
312
- id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readRelated',
313
- service: 'workspaceFiles',
314
- namespace: 'workspaceFiles',
315
- method: 'readRelated',
316
- invocation: { kind: 'direct' },
317
- parameters: [
318
- {
319
- name: 'workspaceFileScope',
320
- wire: 'workspaceFileScopeId',
321
- source: 'lookup',
322
- lookup: 'workspaceFileScope',
323
- codec: {
324
- mode: 'strict',
325
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
326
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema,
327
- },
328
- },
329
- {
330
- name: 'path',
331
- wire: 'path',
332
- source: 'json',
333
- codec: {
334
- mode: 'strict',
335
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readRelated:path',
336
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema,
337
- },
338
- },
339
- {
340
- name: 'relativePath',
341
- wire: 'relativePath',
342
- source: 'json',
343
- codec: {
344
- mode: 'strict',
345
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readRelated:relativePath',
346
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema,
347
- },
348
- },
349
- ],
350
- cancellation: { parameter: 'signal' },
351
- result: {
352
- mode: 'strict',
353
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileBytes',
354
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema,
355
- },
356
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":299,"column":9},
357
- },
358
299
  {
359
300
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/stat',
360
301
  service: 'workspaceFiles',
@@ -390,7 +331,7 @@ export const TYPERT = {
390
331
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileStat',
391
332
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_stat_result$schema,
392
333
  },
393
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":323,"column":9},
334
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":290,"column":9},
394
335
  },
395
336
  ],
396
337
  model: {
@@ -413,23 +354,9 @@ export const TYPERT = {
413
354
  {
414
355
  "kind": "method",
415
356
  "name": "readBytes",
416
- "signature": "@Remote async readBytes( workspaceFileScope: WorkspaceFileScope, path: string, range: WorkspaceByteRange, signal: AbortSignal, ): Promise<WorkspaceFileBytes>",
417
- "summary": "Read one byte window of a regular file readable by the filesystem backend: raw bytes, no text decoding and no binary rejection.",
418
- "jsDoc": "/**\n * Read one byte window of a regular file readable by the filesystem backend: raw\n * bytes, no text decoding and no binary rejection.\n * @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.\n * @param path - absolute path or path relative to the workspace root; files outside it are allowed.\n * @param range - the byte window; omitted fields take the window defaults.\n * @param signal - caller cancellation.\n * @returns the window in base64, the file's version and size at the stat before it, and whether it reaches the last byte.\n */"
419
- },
420
- {
421
- "kind": "method",
422
- "name": "readAll",
423
- "signature": "@Remote async readAll(workspaceFileScope: WorkspaceFileScope, path: string, signal: AbortSignal): Promise<WorkspaceFileBytes>",
424
- "summary": "Read a complete regular file as bytes, subject to the configured full-file cap.",
425
- "jsDoc": "/**\n * Read a complete regular file as bytes, subject to the configured full-file cap.\n * @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.\n * @param path - absolute or workspace-relative file path.\n * @param signal - caller cancellation.\n * @returns one complete base64 window with offset zero and eof true; oversized files fail with too-large.\n */"
426
- },
427
- {
428
- "kind": "method",
429
- "name": "readRelated",
430
- "signature": "@Remote async readRelated( workspaceFileScope: WorkspaceFileScope, path: string, relativePath: string, signal: AbortSignal, ): Promise<WorkspaceFileBytes>",
431
- "summary": "Read a complete file relative to another file's directory, including outside the workspace.",
432
- "jsDoc": "/**\n * Read a complete file relative to another file's directory, including outside the workspace.\n * @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.\n * @param path - base file, absolute or workspace-relative.\n * @param relativePath - relative filesystem path, not a URL or absolute path.\n * @param signal - caller cancellation.\n * @returns the complete related file using the ordinary file-size and access checks.\n */"
357
+ "signature": "@Remote async readBytes( workspaceFileScope: WorkspaceFileScope, path: string, options: WorkspaceByteReadOptions, signal: AbortSignal, ): Promise<WorkspaceFileBytes>",
358
+ "summary": "Read a complete regular file or one byte range without text decoding.",
359
+ "jsDoc": "/**\n * Read a complete regular file or one byte range without text decoding.\n * @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.\n * @param path - target path, absolute or workspace-relative; relative to the base file's directory when provided.\n * @param options - optional base file and range; without a range the complete-file cap applies.\n * @param signal - caller cancellation.\n * @returns native bytes with the file's version and size at the preceding stat, byte offset, and EOF marker.\n */"
433
360
  },
434
361
  {
435
362
  "kind": "method",
@@ -448,9 +375,9 @@ export const TYPERT = {
448
375
  {
449
376
  "kind": "method",
450
377
  "name": "changes",
451
- "signature": "@Remote({ mode: 'stream' }) changes(workspaceFileScope: WorkspaceFileScope, signal: AbortSignal): AsyncIterable<WorkspaceFileWatchFrame>",
452
- "summary": "Stream every `fs/observed` observation of a file inside the Session's workspace.",
453
- "jsDoc": "/**\n * Stream every `fs/observed` observation of a file inside the Session's\n * workspace. Only instrumented filesystem operations report here; the OS is\n * not watched.\n * @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.\n * @param signal - generation cancellation.\n * @returns `ready` once the Host observation queue is active and the workspace\n * root is resolved, then queued and live observations in emission order.\n */"
378
+ "signature": "@Remote({ mode: 'stream' }) changes(workspaceFileScope: WorkspaceFileScope, path: string, signal: AbortSignal): AsyncIterable<WorkspaceFileWatchFrame>",
379
+ "summary": "Watch one file or a directory's direct entries in the Session's filesystem.",
380
+ "jsDoc": "/**\n * Watch one file or a directory's direct entries in the Session's filesystem.\n * Files use the backend's read authority; directories remain workspace-scoped.\n * @param workspaceFileScope - header-derived workspace root for the Session identity on the wire.\n * @param path - target path; the Host determines its type and confines directories to the workspace.\n * @param signal - generation cancellation.\n * @returns `ready` once the target watch is active, then current metadata for queued and live invalidations.\n * @throws RemoteError when watching is unavailable or a directory is outside the workspace.\n */"
454
381
  }
455
382
  ],
456
383
  "types": [
@@ -466,6 +393,10 @@ export const TYPERT = {
466
393
  "name": "WorkspaceByteRange",
467
394
  "declaration": "export interface WorkspaceByteRange {\n readonly offset?: number;\n readonly length?: number;\n}"
468
395
  },
396
+ {
397
+ "name": "WorkspaceByteReadOptions",
398
+ "declaration": "export interface WorkspaceByteReadOptions {\n readonly range?: WorkspaceByteRange;\n readonly baseFile?: string;\n}"
399
+ },
469
400
  {
470
401
  "name": "WorkspaceDirectoryEntry",
471
402
  "declaration": "export interface WorkspaceDirectoryEntry {\n readonly name: string;\n readonly type: 'file' | 'directory' | 'other';\n readonly size?: number;\n}"
@@ -476,7 +407,7 @@ export const TYPERT = {
476
407
  },
477
408
  {
478
409
  "name": "WorkspaceFileBytes",
479
- "declaration": "export interface WorkspaceFileBytes extends WorkspaceFileStat {\n readonly offset: number;\n readonly data: string;\n readonly eof: boolean;\n}"
410
+ "declaration": "export interface WorkspaceFileBytes<Data extends Uint8Array = Uint8Array> extends WorkspaceFileStat {\n readonly offset: number;\n readonly data: Data;\n readonly eof: boolean;\n}"
480
411
  },
481
412
  {
482
413
  "name": "WorkspaceFileChange",
@@ -1,28 +1,29 @@
1
1
  /* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
2
2
  import type {
3
3
  RemoteResult,
4
+ RemoteStreamHandle,
4
5
  TypertRemoteContribution,
5
6
  } from '@deepseek-ai/dsh-typert-protocol'
6
- import type { WorkspaceByteRange, WorkspaceDirectoryListing, WorkspaceFileBytes, WorkspaceFileRange, WorkspaceFileStat, WorkspaceFileText, WorkspaceFileWatchFrame } from '@deepseek-ai/dsh-api-workspace-files/types'
7
+ import type { WorkspaceByteReadOptions, WorkspaceDirectoryListing, WorkspaceFileBytes, WorkspaceFileRange, WorkspaceFileStat, WorkspaceFileText, WorkspaceFileWatchFrame } from '@deepseek-ai/dsh-api-workspace-files/types'
7
8
  import type { SessionId } from '@deepseek-ai/dsh-session/types'
8
9
 
10
+ type RemoteDecoded<Value> = Value extends Uint8Array ? Uint8Array<ArrayBuffer>
11
+ : Value extends string | number | boolean | null | undefined ? Value
12
+ : { [Key in keyof Value]: RemoteDecoded<Value[Key]> }
13
+
9
14
  declare module '@deepseek-ai/dsh-typert-protocol' {
10
15
  interface TypertRemoteNamespace$776f726b737061636546696c6573 {
11
- changes: (workspaceFileScopeId: SessionId, signal?: AbortSignal) => AsyncIterable<WorkspaceFileWatchFrame>
16
+ changes: (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => RemoteStreamHandle<WorkspaceFileWatchFrame, never>
12
17
  list: (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceDirectoryListing>>
13
18
  read: (workspaceFileScopeId: SessionId, path: string, range: WorkspaceFileRange, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileText>>
14
- readAll: (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>
15
- readBytes: (workspaceFileScopeId: SessionId, path: string, range: WorkspaceByteRange, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>
16
- readRelated: (workspaceFileScopeId: SessionId, path: string, relativePath: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>
19
+ readBytes: (workspaceFileScopeId: SessionId, path: string, options: WorkspaceByteReadOptions, signal?: AbortSignal) => Promise<RemoteResult<RemoteDecoded<WorkspaceFileBytes>>>
17
20
  stat: (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileStat>>
18
21
  }
19
22
  interface TypertRemoteMap {
20
- 'workspaceFiles/changes': (workspaceFileScopeId: SessionId, signal?: AbortSignal) => AsyncIterable<WorkspaceFileWatchFrame>
23
+ 'workspaceFiles/changes': (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => RemoteStreamHandle<WorkspaceFileWatchFrame, never>
21
24
  'workspaceFiles/list': (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceDirectoryListing>>
22
25
  'workspaceFiles/read': (workspaceFileScopeId: SessionId, path: string, range: WorkspaceFileRange, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileText>>
23
- 'workspaceFiles/readAll': (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>
24
- 'workspaceFiles/readBytes': (workspaceFileScopeId: SessionId, path: string, range: WorkspaceByteRange, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>
25
- 'workspaceFiles/readRelated': (workspaceFileScopeId: SessionId, path: string, relativePath: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileBytes>>
26
+ 'workspaceFiles/readBytes': (workspaceFileScopeId: SessionId, path: string, options: WorkspaceByteReadOptions, signal?: AbortSignal) => Promise<RemoteResult<RemoteDecoded<WorkspaceFileBytes>>>
26
27
  'workspaceFiles/stat': (workspaceFileScopeId: SessionId, path: string, signal?: AbortSignal) => Promise<RemoteResult<WorkspaceFileStat>>
27
28
  }
28
29
  interface TypertRemoteNamespaceMap {
@@ -3,6 +3,8 @@ import { z } from 'zod'
3
3
 
4
4
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema$value
5
5
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
6
+ let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema$value
7
+ const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema$value ??= z.string())
6
8
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema$value
7
9
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema$value ??= z.union([z.object({
8
10
  'kind': z.literal("ready").readonly(),
@@ -49,47 +51,22 @@ const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_read_result$schema = (
49
51
  'version': z.string().readonly(),
50
52
  'bytes': z.number().readonly().optional(),
51
53
  }))
52
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema$value
53
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
54
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema$value
55
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema$value ??= z.string())
56
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema$value
57
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema$value ??= z.object({
58
- 'offset': z.number().readonly(),
59
- 'data': z.string().readonly(),
60
- 'eof': z.boolean().readonly(),
61
- 'absolutePath': z.string().readonly(),
62
- 'version': z.string().readonly(),
63
- 'bytes': z.number().readonly().optional(),
64
- }))
65
54
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_0$schema$value
66
55
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
67
56
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_1$schema$value
68
57
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_1$schema$value ??= z.string())
69
58
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema$value
70
59
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema$value ??= z.object({
60
+ 'range': z.object({
71
61
  'offset': z.number().readonly().optional(),
72
62
  'length': z.number().readonly().optional(),
63
+ }).readonly().optional(),
64
+ 'baseFile': z.string().readonly().optional(),
73
65
  }))
74
66
  let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema$value
75
67
  const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema$value ??= z.object({
76
68
  'offset': z.number().readonly(),
77
- 'data': z.string().readonly(),
78
- 'eof': z.boolean().readonly(),
79
- 'absolutePath': z.string().readonly(),
80
- 'version': z.string().readonly(),
81
- 'bytes': z.number().readonly().optional(),
82
- }))
83
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema$value
84
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema$value ??= z.intersection(z.string(), z.unknown()))
85
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema$value
86
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema$value ??= z.string())
87
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema$value
88
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema$value ??= z.string())
89
- let _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema$value
90
- const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema = () => (_deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema$value ??= z.object({
91
- 'offset': z.number().readonly(),
92
- 'data': z.string().readonly(),
69
+ 'data': z.instanceof(Uint8Array),
93
70
  'eof': z.boolean().readonly(),
94
71
  'absolutePath': z.string().readonly(),
95
72
  'version': z.string().readonly(),
@@ -105,6 +82,42 @@ const _deepseek_ai_dsh_api_workspace_files_workspaceFiles_stat_result$schema = (
105
82
  'version': z.string().readonly(),
106
83
  'bytes': z.number().readonly().optional(),
107
84
  }))
85
+ const $resultSnapshot = (input, path) => {
86
+ if (input === null || typeof input !== 'object' || input instanceof Uint8Array) return input
87
+ const toJSON = input.toJSON
88
+ const value = typeof toJSON === 'function' ? toJSON.call(input, path.at(-1)?.toString() ?? 'value') : input
89
+ if (value === null || typeof value !== 'object' || value instanceof Uint8Array) return value
90
+ if (Array.isArray(value)) {
91
+ const items = []
92
+ for (let index = 0, length = value.length; index < length; index++) items.push(value[index])
93
+ return items
94
+ }
95
+ const fields = {}
96
+ for (const key of Object.keys(value)) {
97
+ const item = key === 'toJSON' && value === input ? toJSON : value[key]
98
+ if (key === 'toJSON' && typeof item === 'function') continue
99
+ Object.defineProperty(fields, key, { value: item, enumerable: true, writable: true, configurable: true })
100
+ }
101
+ return fields
102
+ }
103
+ const $resultContainer = (input, path, ancestors, project, snapshot) => {
104
+ if (input === null || typeof input !== 'object') return project(input)
105
+ const owner = !ancestors.has(input)
106
+ if (!owner && ancestors.get(input) !== path.length) throw new TypeError('Remote result contains a circular object')
107
+ if (owner) ancestors.set(input, path.length)
108
+ try { return project(snapshot ? $resultSnapshot(input, path) : input) }
109
+ finally { if (owner) ancestors.delete(input) }
110
+ }
111
+ const $encode1 = (value, writeBytes, path, ancestors) => {
112
+ return value instanceof Uint8Array ? writeBytes(value, path) : value
113
+ }
114
+ const $encode0 = (value, writeBytes, path, ancestors) => {
115
+ return $resultContainer(value, path, ancestors, value => {
116
+ if (value === null || typeof value !== 'object' || Array.isArray(value) || value instanceof Uint8Array) return value
117
+ if (Object.hasOwn(value, 'data')) value['data'] = $encode1(value['data'], writeBytes, [...path, 'data'], ancestors)
118
+ return value
119
+ }, true)
120
+ }
108
121
 
109
122
  export const TYPERT_REMOTE = {
110
123
  package: '@deepseek-ai/dsh-api-workspace-files',
@@ -128,6 +141,16 @@ export const TYPERT_REMOTE = {
128
141
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_0$schema,
129
142
  },
130
143
  },
144
+ {
145
+ name: 'path',
146
+ wire: 'path',
147
+ source: 'json',
148
+ codec: {
149
+ mode: 'strict',
150
+ typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/changes:path',
151
+ create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_parameter_1$schema,
152
+ },
153
+ },
131
154
  ],
132
155
  cancellation: { parameter: 'signal' },
133
156
  result: {
@@ -135,7 +158,7 @@ export const TYPERT_REMOTE = {
135
158
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileWatchFrame',
136
159
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_changes_result$schema,
137
160
  },
138
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":364,"column":3},
161
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":331,"column":3},
139
162
  },
140
163
  {
141
164
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/list',
@@ -172,7 +195,7 @@ export const TYPERT_REMOTE = {
172
195
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceDirectoryListing',
173
196
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_list_result$schema,
174
197
  },
175
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":336,"column":9},
198
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":303,"column":9},
176
199
  },
177
200
  {
178
201
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/read',
@@ -219,44 +242,7 @@ export const TYPERT_REMOTE = {
219
242
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileText',
220
243
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_read_result$schema,
221
244
  },
222
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":232,"column":9},
223
- },
224
- {
225
- id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readAll',
226
- service: 'workspaceFiles',
227
- namespace: 'workspaceFiles',
228
- method: 'readAll',
229
- invocation: { kind: 'direct' },
230
- parameters: [
231
- {
232
- name: 'workspaceFileScope',
233
- wire: 'workspaceFileScopeId',
234
- source: 'lookup',
235
- lookup: 'workspaceFileScope',
236
- codec: {
237
- mode: 'strict',
238
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
239
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_0$schema,
240
- },
241
- },
242
- {
243
- name: 'path',
244
- wire: 'path',
245
- source: 'json',
246
- codec: {
247
- mode: 'strict',
248
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readAll:path',
249
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_parameter_1$schema,
250
- },
251
- },
252
- ],
253
- cancellation: { parameter: 'signal' },
254
- result: {
255
- mode: 'strict',
256
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileBytes',
257
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readAll_result$schema,
258
- },
259
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":278,"column":9},
245
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":233,"column":9},
260
246
  },
261
247
  {
262
248
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readBytes',
@@ -287,12 +273,12 @@ export const TYPERT_REMOTE = {
287
273
  },
288
274
  },
289
275
  {
290
- name: 'range',
291
- wire: 'range',
276
+ name: 'options',
277
+ wire: 'options',
292
278
  source: 'json',
293
279
  codec: {
294
280
  mode: 'strict',
295
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceByteRange',
281
+ typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceByteReadOptions',
296
282
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_parameter_2$schema,
297
283
  },
298
284
  },
@@ -302,56 +288,11 @@ export const TYPERT_REMOTE = {
302
288
  mode: 'strict',
303
289
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileBytes',
304
290
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema,
291
+ decode: value => _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readBytes_result$schema().parse(value),
292
+ encode: (value, writeBytes) => $encode0(value, writeBytes, [], new Map()),
305
293
  },
306
294
  sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":257,"column":9},
307
295
  },
308
- {
309
- id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readRelated',
310
- service: 'workspaceFiles',
311
- namespace: 'workspaceFiles',
312
- method: 'readRelated',
313
- invocation: { kind: 'direct' },
314
- parameters: [
315
- {
316
- name: 'workspaceFileScope',
317
- wire: 'workspaceFileScopeId',
318
- source: 'lookup',
319
- lookup: 'workspaceFileScope',
320
- codec: {
321
- mode: 'strict',
322
- typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
323
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_0$schema,
324
- },
325
- },
326
- {
327
- name: 'path',
328
- wire: 'path',
329
- source: 'json',
330
- codec: {
331
- mode: 'strict',
332
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readRelated:path',
333
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_1$schema,
334
- },
335
- },
336
- {
337
- name: 'relativePath',
338
- wire: 'relativePath',
339
- source: 'json',
340
- codec: {
341
- mode: 'strict',
342
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/readRelated:relativePath',
343
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_parameter_2$schema,
344
- },
345
- },
346
- ],
347
- cancellation: { parameter: 'signal' },
348
- result: {
349
- mode: 'strict',
350
- typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileBytes',
351
- create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_readRelated_result$schema,
352
- },
353
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":299,"column":9},
354
- },
355
296
  {
356
297
  id: '@deepseek-ai/dsh-api-workspace-files#workspaceFiles/stat',
357
298
  service: 'workspaceFiles',
@@ -387,7 +328,7 @@ export const TYPERT_REMOTE = {
387
328
  typeSymbol: '@deepseek-ai/dsh-api-workspace-files/types#WorkspaceFileStat',
388
329
  create: _deepseek_ai_dsh_api_workspace_files_workspaceFiles_stat_result$schema,
389
330
  },
390
- sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":323,"column":9},
331
+ sourceLocation: {"file":"packages/api/workspace-files/src/index.ts","line":290,"column":9},
391
332
  },
392
333
  ],
393
334
  }