@deepseek-ai/dsh-file-reference 0.1.0-rc.8

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DeepSeek
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,6 @@
1
+ # Bilingual-pair consistency record (docs/i18n/README.md): the git blob hash of each
2
+ # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
+ # after editing either side, bring the other along and re-record with:
4
+ # pnpm run verify-translation-pairing --write packages/context/file-reference/README.md
5
+ README.md: ae0e1ef68f927890af78767660cac094d831380c
6
+ README.zh.md: 1645dd345cd52cf5d3e02270c1fbd4c4344ada37
package/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # `@deepseek-ai/dsh-file-reference`
2
+
3
+ English | [中文](README.zh.md)
4
+
5
+ File-reference discovery seam and browser-safe `@file` grammar shared by host-backed user interfaces. `ctx.fileReferences.list(agent, query, signal)` returns path-only file or directory candidates for the addressed agent; concrete providers own namespace access, ranking, caching, and invalidation. The same contract is remotely callable as the unary `fileReferences/list` Remote method (`@Remote` on the Service Definition, cancelled through the reserved trailing signal), so browser consumers call `ctx.remote.fileReferences.list` without an API Proxy route.
6
+
7
+ `activeAtToken()` recognizes an `@path` or open `@"path with spaces` token only at the start of input or after whitespace, so email-like text does not open completion. `formatFileMention()` emits the matching prompt spelling, appends `/` to directory candidates, preserves an explicitly opened quote, and rejects control characters or embedded quotes that the editor grammar cannot represent safely.
8
+
9
+ Selecting a candidate does not read or attach file contents. The exported `FILE_REFERENCE_PROMPT` is stable guidance that a provider may install when the addressed agent can call `read`.
10
+
11
+ ## Model Experience
12
+
13
+ Indirectly, through `@deepseek-ai/dsh-file-reference-local`, which conditionally contributes this package's stable file-reference guidance.
14
+
15
+ #### KV Cache effect
16
+
17
+ The interface and grammar add no request tokens themselves; a provider-owned prompt section determines cache behavior.
18
+
19
+ ## Known Limitations and Deferred Work
20
+
21
+ - **Path candidates are advisory** — the seam does not prove that a later model-facing filesystem tool can access the same namespace; deployments must align the provider with the effective `read` implementation.
22
+ - **No file-content reference object** — selected files remain ordinary prompt text and require an explicit model tool call before their contents become model-visible.
package/README.zh.md ADDED
@@ -0,0 +1,22 @@
1
+ # `@deepseek-ai/dsh-file-reference`
2
+
3
+ [English](README.md) | 中文
4
+
5
+ 文件引用发现 seam,以及供宿主驱动的用户界面共享、可在浏览器中安全使用的 `@file` 语法。`ctx.fileReferences.list(agent, query, signal)` 为指定 agent(智能体)返回仅含路径的文件或目录候选;具体提供方负责命名空间访问、排序、缓存和失效处理。同一契约以一元 `fileReferences/list` Remote 方法对外可调(`@Remote` 标注在 Service Definition 上,经保留的末位 signal 参数取消),浏览器消费方直接调用 `ctx.remote.fileReferences.list`,无需 API Proxy 路由。
6
+
7
+ `activeAtToken()` 只在输入开头或空白后识别 `@path` 或尚未闭合的 `@"path with spaces` token,因此类似电子邮件的文本不会打开补全。`formatFileMention()` 会生成与提示词匹配的写法,为目录候选追加 `/`,保留显式打开的引号,并拒绝编辑器语法无法安全表示的控制字符或内嵌引号。
8
+
9
+ 选择候选项不会读取或附加文件内容。导出的 `FILE_REFERENCE_PROMPT` 是稳定指引;当指定 agent 可以调用 `read` 时,提供方可以安装该指引。
10
+
11
+ ## 模型体验
12
+
13
+ 间接影响模型体验:`@deepseek-ai/dsh-file-reference-local` 会按条件贡献本包的稳定文件引用指引。
14
+
15
+ #### KV 缓存影响
16
+
17
+ 接口和语法本身不会增加请求 token;缓存行为取决于提供方拥有的提示词段。
18
+
19
+ ## 已知限制与暂缓事项
20
+
21
+ - **路径候选仅供参考**:该 seam 不保证后续面向模型的文件系统工具能够访问同一命名空间;部署时必须让提供方与实际生效的 `read` 实现对齐。
22
+ - **没有文件内容引用对象**:所选文件仍是普通提示词文本,其内容必须经过模型显式调用工具后才对模型可见。
package/lib/index.js ADDED
@@ -0,0 +1,138 @@
1
+ import { Remote, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
2
+ //#region lib/types/grammar.js
3
+ /**
4
+ * Browser-safe `@file` token grammar shared by terminal and web clients.
5
+ *
6
+ * @module @deepseek-ai/dsh-file-reference/grammar
7
+ */
8
+ /**
9
+ * Extract an `@path` or `@"path with spaces` token at the cursor. An `@`
10
+ * inside another token, such as an email address, is not a completion trigger.
11
+ * @param line - current editor line.
12
+ * @param cursorCol - cursor column within that line.
13
+ * @returns the active token, or `undefined` outside an `@` token.
14
+ */
15
+ function activeAtToken(line, cursorCol) {
16
+ const beforeCursor = line.slice(0, cursorCol);
17
+ const quoted = /(?:^|\s)(@"([^"]*))$/u.exec(beforeCursor);
18
+ if (quoted?.[1] !== void 0 && quoted[2] !== void 0) return {
19
+ prefix: quoted[1],
20
+ query: quoted[2],
21
+ quoted: true
22
+ };
23
+ const plain = /(?:^|\s)(@([^\s]*))$/u.exec(beforeCursor);
24
+ if (plain?.[1] === void 0 || plain[2] === void 0) return void 0;
25
+ return {
26
+ prefix: plain[1],
27
+ query: plain[2],
28
+ quoted: false
29
+ };
30
+ }
31
+ /**
32
+ * Format a selected path as prompt text. Whitespace uses the quoted
33
+ * `@"path"` grammar; a quoted directory keeps that quote open after its
34
+ * trailing slash so completion can descend another level.
35
+ * @param candidate - selected file or directory.
36
+ * @param preserveQuote - retain an explicitly opened quote even when unnecessary.
37
+ * @returns the insertion value, or `undefined` for a path the editor grammar cannot represent safely.
38
+ */
39
+ function formatFileMention(candidate, preserveQuote) {
40
+ const path = candidate.kind === "directory" ? `${candidate.path}/` : candidate.path;
41
+ if (/[\u0000-\u001f\u007f-\u009f"]/u.test(path)) return void 0;
42
+ if (!(preserveQuote || /\s/u.test(path))) return `@${path}`;
43
+ if (candidate.kind === "directory") return `@"${path}`;
44
+ return `@"${path}"`;
45
+ }
46
+ //#endregion
47
+ //#region lib/types/index.js
48
+ /**
49
+ * File-reference discovery seam shared by host-backed user interfaces.
50
+ *
51
+ * @module @deepseek-ai/dsh-file-reference
52
+ */
53
+ var __runInitializers = function(thisArg, initializers, value) {
54
+ var useValue = arguments.length > 2;
55
+ for (var i = 0; i < initializers.length; i++) value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
56
+ return useValue ? value : void 0;
57
+ };
58
+ var __esDecorate = function(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
59
+ function accept(f) {
60
+ if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected");
61
+ return f;
62
+ }
63
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
64
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
65
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
66
+ var _, done = false;
67
+ for (var i = decorators.length - 1; i >= 0; i--) {
68
+ var context = {};
69
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
70
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
71
+ context.addInitializer = function(f) {
72
+ if (done) throw new TypeError("Cannot add initializers after decoration has completed");
73
+ extraInitializers.push(accept(f || null));
74
+ };
75
+ var result = (0, decorators[i])(kind === "accessor" ? {
76
+ get: descriptor.get,
77
+ set: descriptor.set
78
+ } : descriptor[key], context);
79
+ if (kind === "accessor") {
80
+ if (result === void 0) continue;
81
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
82
+ if (_ = accept(result.get)) descriptor.get = _;
83
+ if (_ = accept(result.set)) descriptor.set = _;
84
+ if (_ = accept(result.init)) initializers.unshift(_);
85
+ } else if (_ = accept(result)) if (kind === "field") initializers.unshift(_);
86
+ else descriptor[key] = _;
87
+ }
88
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
89
+ done = true;
90
+ };
91
+ /** Model guidance for path-only references selected by a user interface. */
92
+ const FILE_REFERENCE_PROMPT = "Paths prefixed with @ are files explicitly referenced by the user. Use the read tool when their contents are needed; do not claim to have inspected a file before reading it.";
93
+ /** Host capability for cancellable file-reference discovery. */
94
+ let FileReferenceService = (() => {
95
+ let _classSuper = TypertRemoteService;
96
+ let _instanceExtraInitializers = [];
97
+ let _remoteExportList_decorators;
98
+ return class FileReferenceService extends _classSuper {
99
+ static {
100
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
101
+ _remoteExportList_decorators = [Remote("list")];
102
+ __esDecorate(this, null, _remoteExportList_decorators, {
103
+ kind: "method",
104
+ name: "remoteExportList",
105
+ static: false,
106
+ private: false,
107
+ access: {
108
+ has: (obj) => "remoteExportList" in obj,
109
+ get: (obj) => obj.remoteExportList
110
+ },
111
+ metadata: _metadata
112
+ }, null, _instanceExtraInitializers);
113
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, {
114
+ enumerable: true,
115
+ configurable: true,
116
+ writable: true,
117
+ value: _metadata
118
+ });
119
+ }
120
+ constructor(ctx) {
121
+ super(ctx, "fileReferences");
122
+ __runInitializers(this, _instanceExtraInitializers);
123
+ }
124
+ /**
125
+ * Remote face of {@link list}; the decorator cannot mark the abstract
126
+ * member, so this concrete adapter carries the identical contract.
127
+ * @param agent - target agent whose session cwd bounds discovery.
128
+ * @param query - path text following `@` or `@"`.
129
+ * @param signal - caller cancellation.
130
+ * @returns deterministic path-only candidates.
131
+ */
132
+ remoteExportList(agent, query, signal) {
133
+ return this.list(agent, query, signal);
134
+ }
135
+ };
136
+ })();
137
+ //#endregion
138
+ export { FILE_REFERENCE_PROMPT, FileReferenceService, FileReferenceService as default, activeAtToken, formatFileMention };
@@ -0,0 +1,23 @@
1
+ //#region lib/types/invariant.js
2
+ /**
3
+ * Package-owned invariant companion for `@deepseek-ai/dsh-file-reference`.
4
+ * @module @deepseek-ai/dsh-file-reference/invariant
5
+ */
6
+ const PACKAGE_NAME = "@deepseek-ai/dsh-file-reference";
7
+ /** Cordis companion plugin name. */
8
+ const name = "file-reference-invariant";
9
+ /** Service required before the companion can reserve package ownership. */
10
+ const inject = ["invariants"];
11
+ /**
12
+ * No runtime invariant: the interface retains no candidate or lifecycle
13
+ * state; concrete providers own their cache and invalidation relationships.
14
+ */
15
+ const install = () => {};
16
+ /**
17
+ * Register this package's invariant companion.
18
+ * @param ctx - Cordis context carrying the invariant service.
19
+ * @returns the installed registration's disposer after setup succeeds.
20
+ */
21
+ const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
22
+ //#endregion
23
+ export { apply, inject, name };
@@ -0,0 +1,3 @@
1
+ /* Generated by @deepseek-ai/dsh-typert-generator from FaceModel — do not edit. */
2
+
3
+ export declare const TYPERT: unknown
@@ -0,0 +1,436 @@
1
+ /* Generated by @deepseek-ai/dsh-typert-generator from FaceModel — do not edit. */
2
+ import { z } from 'zod'
3
+
4
+ const _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_0$schema = z.intersection(z.string(), z.unknown())
5
+ const _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_1$schema = z.string()
6
+ const _deepseek_ai_dsh_file_reference_fileReferences_list_result$schema = z.array(z.object({
7
+ 'path': z.string(),
8
+ 'kind': z.union([z.literal("file"), z.literal("directory")]),
9
+ }))
10
+
11
+ export const TYPERT = {
12
+ package: '@deepseek-ai/dsh-file-reference',
13
+ face: 'host',
14
+ schemas: [
15
+ ],
16
+ invocations: [
17
+ {
18
+ id: '@deepseek-ai/dsh-file-reference#fileReferences/list',
19
+ service: 'fileReferences',
20
+ namespace: 'fileReferences',
21
+ method: 'list',
22
+ implementation: 'remoteExportList',
23
+ invocation: { kind: 'direct' },
24
+ scope: {
25
+ context: 'agent',
26
+ wire: 'agentId',
27
+ },
28
+ parameters: [
29
+ {
30
+ name: 'agent',
31
+ wire: 'agentId',
32
+ source: 'lookup',
33
+ lookup: 'agent',
34
+ codec: {
35
+ mode: 'strict',
36
+ typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
37
+ schema: _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_0$schema,
38
+ },
39
+ },
40
+ {
41
+ name: 'query',
42
+ wire: 'query',
43
+ source: 'json',
44
+ codec: {
45
+ mode: 'strict',
46
+ typeSymbol: '@deepseek-ai/dsh-file-reference#fileReferences/list:query',
47
+ schema: _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_1$schema,
48
+ },
49
+ },
50
+ ],
51
+ cancellation: { parameter: 'signal' },
52
+ result: {
53
+ mode: 'strict',
54
+ typeSymbol: '@deepseek-ai/dsh-file-reference#fileReferences/list:result',
55
+ schema: _deepseek_ai_dsh_file_reference_fileReferences_list_result$schema,
56
+ },
57
+ sourceLocation: {"file":"packages/context/file-reference/src/index.ts","line":54,"column":3},
58
+ },
59
+ ],
60
+ model: {
61
+ "services": [
62
+ {
63
+ "description": "Host capability for cancellable file-reference discovery.",
64
+ "summary": "Host capability for cancellable file-reference discovery.",
65
+ "tags": [],
66
+ "jsDoc": "/** Host capability for cancellable file-reference discovery. */",
67
+ "key": "fileReferences",
68
+ "exportName": "FileReferenceService",
69
+ "members": [
70
+ {
71
+ "kind": "method",
72
+ "name": "list",
73
+ "signature": "abstract list( agent: Agent, query: string, signal: AbortSignal, ): Promise<FileReferenceCandidate[]>",
74
+ "summary": "List file and directory candidates for one agent's working directory.",
75
+ "jsDoc": "/**\n * List file and directory candidates for one agent's working directory.\n * @param agent - target agent whose session cwd bounds discovery.\n * @param query - path text following `@` or `@\"`.\n * @param signal - caller cancellation.\n * @returns deterministic path-only candidates.\n */"
76
+ },
77
+ {
78
+ "kind": "method",
79
+ "name": "remoteExportList",
80
+ "signature": "@Remote('list') remoteExportList( agent: Agent, query: string, signal: AbortSignal, ): Promise<FileReferenceCandidate[]>",
81
+ "summary": "Remote face of {@link list}; the decorator cannot mark the abstract member, so this concrete adapter carries the identical contract.",
82
+ "jsDoc": "/**\n * Remote face of {@link list}; the decorator cannot mark the abstract\n * member, so this concrete adapter carries the identical contract.\n * @param agent - target agent whose session cwd bounds discovery.\n * @param query - path text following `@` or `@\"`.\n * @param signal - caller cancellation.\n * @returns deterministic path-only candidates.\n */"
83
+ }
84
+ ],
85
+ "types": [
86
+ {
87
+ "name": "Agent",
88
+ "declaration": "export interface Agent {\n readonly id: SessionId;\n readonly options: AgentOptions;\n readonly session: Session;\n readonly inbox: Inbox;\n readonly status: AgentStatus;\n readonly ctx: Context;\n cancel(cause: AgentCancelCause, options?: CancelOptions): void;\n whenIdle(): Promise<void>;\n runMaintenance<T>(task: (signal: AbortSignal) => Promise<T>): Promise<T>;\n send(message: UserMessage, target: InboxTarget, wakeup: boolean): void;\n followup(message: UserMessage): void;\n steer(message: UserMessage): void;\n inject(message: UserMessage): void;\n}"
89
+ },
90
+ {
91
+ "name": "AgentCancelCause",
92
+ "declaration": "export type AgentCancelCause = { readonly kind: 'user'; } | { readonly kind: 'parent'; } | { readonly kind: 'hook'; readonly reason: string; } | { readonly kind: 'disposed'; };"
93
+ },
94
+ {
95
+ "name": "AgentOptions",
96
+ "declaration": "export interface AgentOptions {\n provider?: string;\n model?: string;\n maxTokens?: number;\n}"
97
+ },
98
+ {
99
+ "name": "AgentStatus",
100
+ "declaration": "export type AgentStatus = 'idle' | 'running';"
101
+ },
102
+ {
103
+ "name": "ApprovalOutcome",
104
+ "declaration": "export type ApprovalOutcome = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable';"
105
+ },
106
+ {
107
+ "name": "ApprovalPolicy",
108
+ "declaration": "export type ApprovalPolicy = 'ask' | 'never';"
109
+ },
110
+ {
111
+ "name": "ApprovalRequestId",
112
+ "declaration": "export type ApprovalRequestId = Branded<'ApprovalRequestId'>;"
113
+ },
114
+ {
115
+ "name": "AssistantMessage",
116
+ "declaration": "export interface AssistantMessage extends Message {\n readonly role: 'assistant';\n readonly source: ModelMessageSource;\n}"
117
+ },
118
+ {
119
+ "name": "AssistantProvenance",
120
+ "declaration": "export interface AssistantProvenance {\n provider: string;\n model: string;\n replayState?: unknown;\n}"
121
+ },
122
+ {
123
+ "name": "AttachmentId",
124
+ "declaration": "export type AttachmentId = Branded<'AttachmentId'>;"
125
+ },
126
+ {
127
+ "name": "Branded",
128
+ "declaration": "export type Branded<B extends string> = string & { readonly [BRAND]: B; };"
129
+ },
130
+ {
131
+ "name": "CallId",
132
+ "declaration": "export type CallId = Branded<'CallId'>;"
133
+ },
134
+ {
135
+ "name": "CancelOptions",
136
+ "declaration": "export interface CancelOptions {\n keepInbox?: boolean | undefined;\n}"
137
+ },
138
+ {
139
+ "name": "CodeDispatchEventData",
140
+ "declaration": "export interface CodeDispatchEventData extends CodeDispatchStartEventData {\n isError: boolean;\n content: ContentBlock[];\n}"
141
+ },
142
+ {
143
+ "name": "CodeDispatchStartEventData",
144
+ "declaration": "export interface CodeDispatchStartEventData {\n rootCallId: CallId;\n parentCallId: CallId;\n subCallId: CallId;\n name: string;\n arguments: unknown;\n}"
145
+ },
146
+ {
147
+ "name": "CommandId",
148
+ "declaration": "export type CommandId = Branded<'CommandId'>;"
149
+ },
150
+ {
151
+ "name": "CommandSource",
152
+ "declaration": "export type CommandSource = CommandSourceMap[keyof CommandSourceMap];"
153
+ },
154
+ {
155
+ "name": "CommandSourceMap",
156
+ "declaration": "export interface CommandSourceMap {\n user: { kind: 'user'; };\n}"
157
+ },
158
+ {
159
+ "name": "CompactionId",
160
+ "declaration": "export type CompactionId = Branded<'CompactionId'>;"
161
+ },
162
+ {
163
+ "name": "ContentBlock",
164
+ "declaration": "export type ContentBlock = ContentBlockMap[ContentBlockType];"
165
+ },
166
+ {
167
+ "name": "ContentBlockMap",
168
+ "declaration": "export interface ContentBlockMap {\n text: TextBlock;\n reasoning: ReasoningBlock;\n image: ImageBlock;\n 'tool-call': ToolCallBlock;\n 'tool-result': ToolResultBlock;\n}"
169
+ },
170
+ {
171
+ "name": "ContentBlockType",
172
+ "declaration": "export type ContentBlockType = keyof ContentBlockMap;"
173
+ },
174
+ {
175
+ "name": "ContextFormed",
176
+ "declaration": "export type ContextFormed = { readonly form?: never; } | { readonly form: 'instructions'; } | { readonly form: 'catalog'; } | { readonly form: 'snapshot'; readonly sections: readonly ContextSnapshotSection[]; } | { readonly form: 'notice'; readonly summary: string; } | { readonly form: 'relay'; } | { readonly form: 'recall'; };"
177
+ },
178
+ {
179
+ "name": "ContextSnapshotSection",
180
+ "declaration": "export interface ContextSnapshotSection {\n readonly name: string;\n readonly text: string;\n}"
181
+ },
182
+ {
183
+ "name": "EpochHeader",
184
+ "declaration": "export interface EpochHeader {\n config: LlmCallConfig;\n adapterDefaults?: LlmCallConfigAdapterDefaults;\n system?: string;\n tools?: ToolSchema[];\n}"
185
+ },
186
+ {
187
+ "name": "FileReferenceCandidate",
188
+ "declaration": "export interface FileReferenceCandidate {\n path: string;\n kind: 'file' | 'directory';\n}"
189
+ },
190
+ {
191
+ "name": "FinishReason",
192
+ "declaration": "export type FinishReason = FinishReasonMap[keyof FinishReasonMap];"
193
+ },
194
+ {
195
+ "name": "FinishReasonMap",
196
+ "declaration": "export interface FinishReasonMap {\n stop: { kind: 'stop'; };\n 'tool-calls': { kind: 'tool-calls'; };\n 'max-tokens': { kind: 'max-tokens'; };\n aborted: { kind: 'aborted'; failure: LlmFailure; };\n error: { kind: 'error'; failure: LlmFailure; };\n}"
197
+ },
198
+ {
199
+ "name": "GoalBlockReason",
200
+ "declaration": "export interface GoalBlockReason {\n readonly code: string;\n readonly message: string;\n}"
201
+ },
202
+ {
203
+ "name": "GoalChangeMeta",
204
+ "declaration": "export type GoalChangeMeta = GoalSnapshotChangeMeta | GoalClearChangeMeta;"
205
+ },
206
+ {
207
+ "name": "GoalClearChangeMeta",
208
+ "declaration": "export interface GoalClearChangeMeta {\n readonly kind: 'goal/change';\n readonly version: 1;\n readonly operation: 'clear';\n readonly cleared: GoalRef;\n readonly clearedAt: number;\n}"
209
+ },
210
+ {
211
+ "name": "GoalId",
212
+ "declaration": "export type GoalId = Branded<'GoalId'>;"
213
+ },
214
+ {
215
+ "name": "GoalMessageSource",
216
+ "declaration": "export interface GoalMessageSource {\n readonly kind: 'goal';\n readonly goalId: GoalId;\n readonly revision: number;\n readonly round: number;\n}"
217
+ },
218
+ {
219
+ "name": "GoalOperation",
220
+ "declaration": "export type GoalOperation = 'create' | 'edit' | 'pause' | 'resume' | 'complete' | 'block' | 'clear';"
221
+ },
222
+ {
223
+ "name": "GoalPhase",
224
+ "declaration": "export type GoalPhase = 'active' | 'paused' | 'blocked' | 'complete';"
225
+ },
226
+ {
227
+ "name": "GoalRef",
228
+ "declaration": "export interface GoalRef {\n readonly id: GoalId;\n readonly revision: number;\n}"
229
+ },
230
+ {
231
+ "name": "GoalSnapshot",
232
+ "declaration": "export interface GoalSnapshot extends GoalRef {\n readonly objective: string;\n readonly phase: GoalPhase;\n readonly blockedReason?: GoalBlockReason;\n readonly maxGoalRounds: number;\n}"
233
+ },
234
+ {
235
+ "name": "GoalSnapshotChangeMeta",
236
+ "declaration": "export interface GoalSnapshotChangeMeta {\n readonly kind: 'goal/change';\n readonly version: 1;\n readonly operation: Exclude<GoalOperation, 'clear'>;\n readonly goal: GoalSnapshot;\n readonly roundsStarted: number;\n readonly createdAt: number;\n readonly updatedAt: number;\n}"
237
+ },
238
+ {
239
+ "name": "ImageAttachmentRef",
240
+ "declaration": "export interface ImageAttachmentRef {\n attachmentId: AttachmentId;\n mediaType: ImageMediaType;\n bytes: number;\n width: number;\n height: number;\n name?: string;\n}"
241
+ },
242
+ {
243
+ "name": "ImageBlock",
244
+ "declaration": "export interface ImageBlock {\n type: 'image';\n attachment: ImageAttachmentRef;\n}"
245
+ },
246
+ {
247
+ "name": "ImageMediaType",
248
+ "declaration": "export type ImageMediaType = 'image/png' | 'image/jpeg' | 'image/webp' | 'image/gif';"
249
+ },
250
+ {
251
+ "name": "Inbox",
252
+ "declaration": "export class Inbox {\n get nextTurn(): readonly UserMessage[];\n get nextStep(): readonly UserMessage[];\n get hasPending(): boolean;\n clear(): void;\n claim(target: InboxTarget, turn: number): UserMessage[];\n append(target: InboxTarget, message: UserMessage): void;\n prepend(target: InboxTarget, message: UserMessage): void;\n replace(messageId: MessageId, newMessage: UserMessage): boolean;\n remove(messageId: MessageId): boolean;\n splice(target: InboxTarget, start: number, deleteCount: number, inserted: UserMessage[]): UserMessage[];\n}"
253
+ },
254
+ {
255
+ "name": "InboxTarget",
256
+ "declaration": "export type InboxTarget = 'next-turn' | 'next-step';"
257
+ },
258
+ {
259
+ "name": "JsonValue",
260
+ "declaration": "export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue; };"
261
+ },
262
+ {
263
+ "name": "LlmCallConfig",
264
+ "declaration": "export interface LlmCallConfig {\n provider: string;\n model: string;\n reasoningEffort?: ReasoningEffortId;\n temperature?: number;\n maxTokens?: number;\n stop?: string[];\n}"
265
+ },
266
+ {
267
+ "name": "LlmCallConfigAdapterDefaults",
268
+ "declaration": "export interface LlmCallConfigAdapterDefaults {\n reasoningEffort?: true;\n maxTokens?: true;\n}"
269
+ },
270
+ {
271
+ "name": "LlmFailure",
272
+ "declaration": "export interface LlmFailure {\n readonly message: string;\n readonly code: string;\n readonly status?: number;\n readonly providerRetryAfterMs?: number;\n readonly requestId?: ProviderRequestId;\n}"
273
+ },
274
+ {
275
+ "name": "Message",
276
+ "declaration": "export interface Message {\n readonly id: MessageId;\n readonly role: 'system' | 'user' | 'assistant';\n readonly content: ContentBlock[];\n readonly source: MessageSource;\n}"
277
+ },
278
+ {
279
+ "name": "MessageId",
280
+ "declaration": "export type MessageId = Branded<'MessageId'>;"
281
+ },
282
+ {
283
+ "name": "MessageSource",
284
+ "declaration": "export type MessageSource = MessageSourceMap[keyof MessageSourceMap];"
285
+ },
286
+ {
287
+ "name": "MessageSourceMap",
288
+ "declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n plugin: { kind: 'plugin'; plugin: string; } & ContextFormed;\n model: ModelMessageSource;\n tool: ToolMessageSource;\n goal: GoalMessageSource;\n 'session-reference': SessionReferenceSource;\n}"
289
+ },
290
+ {
291
+ "name": "ModelMessageSource",
292
+ "declaration": "export interface ModelMessageSource extends AssistantProvenance {\n kind: 'model';\n}"
293
+ },
294
+ {
295
+ "name": "ProviderRequestId",
296
+ "declaration": "export type ProviderRequestId = Branded<'ProviderRequestId'>;"
297
+ },
298
+ {
299
+ "name": "ReasoningBlock",
300
+ "declaration": "export interface ReasoningBlock {\n type: 'reasoning';\n text: string;\n}"
301
+ },
302
+ {
303
+ "name": "ReasoningEffortId",
304
+ "declaration": "export type ReasoningEffortId = Branded<'ReasoningEffortId'>;"
305
+ },
306
+ {
307
+ "name": "ReplayEnvelope",
308
+ "declaration": "export interface ReplayEnvelope {\n response: unknown;\n blocks?: readonly unknown[];\n}"
309
+ },
310
+ {
311
+ "name": "RequestContext",
312
+ "declaration": "export interface RequestContext {\n provider: string;\n model: string;\n contextWindow?: number;\n}"
313
+ },
314
+ {
315
+ "name": "RequestHeaderReason",
316
+ "declaration": "export type RequestHeaderReason = 'initial' | 'resume' | 'change';"
317
+ },
318
+ {
319
+ "name": "Session",
320
+ "declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n get id(): SessionId;\n readonly firstLiveSeq: number;\n get events(): readonly SessionEvent[];\n get seq(): number;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
321
+ },
322
+ {
323
+ "name": "SessionEvent",
324
+ "declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: number; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? { sourceEventSeqs?: number[]; surfaceOp?: SurfaceOp; } : object) }[T];"
325
+ },
326
+ {
327
+ "name": "SessionEventMap",
328
+ "declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'assistant/chunk': { turn: number; step: number; chunk: StreamChunk; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; usage?: TokenUsage; interrupted?: true; };\n 'tool/call': { turn: number; step: number; callId: CallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; }; meta?: JsonValue; };\n 'todo/write': { todos: TodoItem[]; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; };\n 'request/context': RequestContext;\n 'session/end-seed': Record<string, never>;\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: number; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: CallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'tool/code-dispatch-start': CodeDispatchStartEventData;\n 'tool/code-dispatch': CodeDispatchEventData;\n 'goal/change': GoalChangeMeta;\n 'session/title': SessionTitleEventData;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: number; end: number; }; shadowedSeqs: number[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: number; end: number; }; shadowedSeqs: number[]; shadowedTokenCount: number; };\n}"
329
+ },
330
+ {
331
+ "name": "SessionEventType",
332
+ "declaration": "export type SessionEventType = keyof SessionEventMap;"
333
+ },
334
+ {
335
+ "name": "SessionHeader",
336
+ "declaration": "export interface SessionHeader {\n readonly version: number;\n readonly id: SessionId;\n readonly createdAt: number;\n readonly cwd?: string;\n readonly parentSession?: SessionId;\n readonly seedLength?: number;\n readonly origin?: 'subagent';\n readonly delegationDepth?: number;\n readonly agentPreset?: string;\n}"
337
+ },
338
+ {
339
+ "name": "SessionId",
340
+ "declaration": "export type SessionId = Branded<'SessionId'>;"
341
+ },
342
+ {
343
+ "name": "SessionReferenceSource",
344
+ "declaration": "export interface SessionReferenceSource {\n kind: 'session-reference';\n form: 'recall';\n version: 1;\n references: { sessionId: string; label: string; capturedThroughSeq: number | null; compacted: boolean; originalMessages: number; retainedMessages: number; omittedMessages: number; omittedBytes: number; truncated: boolean; inputIndex: number; }[];\n}"
345
+ },
346
+ {
347
+ "name": "SessionSurface",
348
+ "declaration": "export interface SessionSurface {\n readonly nodes: readonly number[];\n readonly replaceGeneration: number;\n}"
349
+ },
350
+ {
351
+ "name": "SessionTitleEventData",
352
+ "declaration": "export interface SessionTitleEventData {\n readonly title: string;\n readonly messageSeqs: number[];\n readonly source: SessionTitleSource;\n}"
353
+ },
354
+ {
355
+ "name": "SessionTitleModelProvenance",
356
+ "declaration": "export interface SessionTitleModelProvenance {\n readonly provider: string;\n readonly model: string;\n}"
357
+ },
358
+ {
359
+ "name": "SessionTitleProviderId",
360
+ "declaration": "export type SessionTitleProviderId = Branded<'SessionTitleProviderId'>;"
361
+ },
362
+ {
363
+ "name": "SessionTitleSource",
364
+ "declaration": "export type SessionTitleSource = { readonly kind: 'fallback'; } | { readonly kind: 'provider'; readonly provider: SessionTitleProviderId; readonly model?: SessionTitleModelProvenance; } | { readonly kind: 'user'; };"
365
+ },
366
+ {
367
+ "name": "StreamChunk",
368
+ "declaration": "export type StreamChunk = { type: 'block-start'; index: number; blockType: ContentBlockType; } | { type: 'text-delta'; index: number; text: string; } | { type: 'reasoning-delta'; index: number; text: string; } | { type: 'tool-call-delta'; index: number; id: CallId; name?: string; argumentsDelta: string; } | { type: 'block-end'; index: number; block: ContentBlock; } | { type: 'usage'; usage: TokenUsage; } | { type: 'finish'; reason: FinishReason; replayState?: ReplayEnvelope; };"
369
+ },
370
+ {
371
+ "name": "SurfaceEventType",
372
+ "declaration": "export type SurfaceEventType = 'user/message' | 'assistant/message' | 'tool/result';"
373
+ },
374
+ {
375
+ "name": "SurfaceIntent",
376
+ "declaration": "export interface SurfaceIntent {\n surfaceOp: SurfaceOp;\n sourceEventSeqs?: number[];\n}"
377
+ },
378
+ {
379
+ "name": "SurfaceOp",
380
+ "declaration": "export type SurfaceOp = 'append' | { op: 'replace'; start: number; end: number; };"
381
+ },
382
+ {
383
+ "name": "TextBlock",
384
+ "declaration": "export interface TextBlock {\n type: 'text';\n text: string;\n}"
385
+ },
386
+ {
387
+ "name": "TodoItem",
388
+ "declaration": "export interface TodoItem {\n content: string;\n status: 'pending' | 'in_progress' | 'completed';\n}"
389
+ },
390
+ {
391
+ "name": "TokenUsage",
392
+ "declaration": "export interface TokenUsage {\n inputTokens: number;\n outputTokens: number;\n cacheReadTokens?: number;\n cacheWriteTokens?: number;\n reasoningTokens?: number;\n}"
393
+ },
394
+ {
395
+ "name": "ToolCallBlock",
396
+ "declaration": "export interface ToolCallBlock {\n type: 'tool-call';\n id: CallId;\n name: string;\n arguments: string;\n}"
397
+ },
398
+ {
399
+ "name": "ToolMessageSource",
400
+ "declaration": "export interface ToolMessageSource {\n kind: 'tool';\n callId: CallId;\n}"
401
+ },
402
+ {
403
+ "name": "ToolResultBlock",
404
+ "declaration": "export interface ToolResultBlock {\n type: 'tool-result';\n toolCallId: CallId;\n content: ContentBlock[];\n isError?: boolean;\n}"
405
+ },
406
+ {
407
+ "name": "ToolResultMessage",
408
+ "declaration": "export interface ToolResultMessage extends Message {\n readonly role: 'user';\n readonly content: [ToolResultBlock];\n readonly source: ToolMessageSource;\n}"
409
+ },
410
+ {
411
+ "name": "ToolSchema",
412
+ "declaration": "export interface ToolSchema {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n}"
413
+ },
414
+ {
415
+ "name": "TurnEndCancelCause",
416
+ "declaration": "export type TurnEndCancelCause = AgentCancelCause | { readonly kind: 'legacy'; };"
417
+ },
418
+ {
419
+ "name": "TurnEndReason",
420
+ "declaration": "export type TurnEndReason = TurnEndReasonMap[keyof TurnEndReasonMap];"
421
+ },
422
+ {
423
+ "name": "TurnEndReasonMap",
424
+ "declaration": "export interface TurnEndReasonMap {\n completed: { kind: 'completed'; };\n aborted: { kind: 'aborted'; reason: TurnEndCancelCause; };\n blocked: { kind: 'blocked'; };\n error: { kind: 'error'; error: LlmFailure; };\n 'max-tokens': { kind: 'max-tokens'; };\n interrupted: { kind: 'interrupted'; };\n}"
425
+ },
426
+ {
427
+ "name": "UserMessage",
428
+ "declaration": "export interface UserMessage extends Message {\n readonly role: 'user';\n}"
429
+ }
430
+ ]
431
+ }
432
+ ],
433
+ "events": [],
434
+ "objects": []
435
+ },
436
+ }
@@ -0,0 +1,26 @@
1
+ /* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
2
+ import type {
3
+ RemoteResult,
4
+ TypertRemoteContribution,
5
+ } from '@deepseek-ai/dsh-typert-protocol'
6
+ import type { FileReferenceCandidate } from '@deepseek-ai/dsh-file-reference/types'
7
+ import type { SessionId } from '@deepseek-ai/dsh-session/types'
8
+
9
+ declare module '@deepseek-ai/dsh-typert-protocol' {
10
+ interface TypertRemoteNamespace$66696c655265666572656e636573 {
11
+ list: (agentId: SessionId, query: string, signal?: AbortSignal) => Promise<RemoteResult<FileReferenceCandidate[]>>
12
+ }
13
+ interface TypertRemoteMap {
14
+ 'fileReferences/list': (agentId: SessionId, query: string, signal?: AbortSignal) => Promise<RemoteResult<FileReferenceCandidate[]>>
15
+ }
16
+ interface TypertRemoteNamespaceMap {
17
+ 'fileReferences': TypertRemoteNamespace$66696c655265666572656e636573
18
+ }
19
+ interface TypertRemoteScopeMap {
20
+ 'agent:fileReferences/list': (query: string, signal?: AbortSignal) => Promise<RemoteResult<FileReferenceCandidate[]>>
21
+ }
22
+ }
23
+
24
+ export declare const TYPERT_REMOTE: TypertRemoteContribution
25
+ export default TYPERT_REMOTE
26
+ //# sourceMappingURL=typert.remote-client.d.ts.map
@@ -0,0 +1,59 @@
1
+ /* Generated by @deepseek-ai/dsh-typert-generator from the Host FaceModel — do not edit. */
2
+ import { z } from 'zod'
3
+
4
+ const _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_0$schema = z.intersection(z.string(), z.unknown())
5
+ const _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_1$schema = z.string()
6
+ const _deepseek_ai_dsh_file_reference_fileReferences_list_result$schema = z.array(z.object({
7
+ 'path': z.string(),
8
+ 'kind': z.union([z.literal("file"), z.literal("directory")]),
9
+ }))
10
+
11
+ export const TYPERT_REMOTE = {
12
+ package: '@deepseek-ai/dsh-file-reference',
13
+ descriptors: [
14
+ {
15
+ id: '@deepseek-ai/dsh-file-reference#fileReferences/list',
16
+ service: 'fileReferences',
17
+ namespace: 'fileReferences',
18
+ method: 'list',
19
+ implementation: 'remoteExportList',
20
+ invocation: { kind: 'direct' },
21
+ scope: {
22
+ context: 'agent',
23
+ wire: 'agentId',
24
+ },
25
+ parameters: [
26
+ {
27
+ name: 'agent',
28
+ wire: 'agentId',
29
+ source: 'lookup',
30
+ lookup: 'agent',
31
+ codec: {
32
+ mode: 'strict',
33
+ typeSymbol: '@deepseek-ai/dsh-session/types#SessionId',
34
+ schema: _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_0$schema,
35
+ },
36
+ },
37
+ {
38
+ name: 'query',
39
+ wire: 'query',
40
+ source: 'json',
41
+ codec: {
42
+ mode: 'strict',
43
+ typeSymbol: '@deepseek-ai/dsh-file-reference#fileReferences/list:query',
44
+ schema: _deepseek_ai_dsh_file_reference_fileReferences_list_parameter_1$schema,
45
+ },
46
+ },
47
+ ],
48
+ cancellation: { parameter: 'signal' },
49
+ result: {
50
+ mode: 'strict',
51
+ typeSymbol: '@deepseek-ai/dsh-file-reference#fileReferences/list:result',
52
+ schema: _deepseek_ai_dsh_file_reference_fileReferences_list_result$schema,
53
+ },
54
+ sourceLocation: {"file":"packages/context/file-reference/src/index.ts","line":54,"column":3},
55
+ },
56
+ ],
57
+ }
58
+
59
+ export default TYPERT_REMOTE
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Browser-safe `@file` token grammar shared by terminal and web clients.
3
+ *
4
+ * @module @deepseek-ai/dsh-file-reference/grammar
5
+ */
6
+ import type { FileReferenceCandidate } from './types.ts';
7
+ /** Active `@` token ending at the editor cursor. */
8
+ export interface ActiveAtToken {
9
+ /** Complete token replaced when the user accepts a completion. */
10
+ prefix: string;
11
+ /** Path query after `@` or `@"`. */
12
+ query: string;
13
+ /** Whether the user opened a quoted path. */
14
+ quoted: boolean;
15
+ }
16
+ /**
17
+ * Extract an `@path` or `@"path with spaces` token at the cursor. An `@`
18
+ * inside another token, such as an email address, is not a completion trigger.
19
+ * @param line - current editor line.
20
+ * @param cursorCol - cursor column within that line.
21
+ * @returns the active token, or `undefined` outside an `@` token.
22
+ */
23
+ export declare function activeAtToken(line: string, cursorCol: number): ActiveAtToken | undefined;
24
+ /**
25
+ * Format a selected path as prompt text. Whitespace uses the quoted
26
+ * `@"path"` grammar; a quoted directory keeps that quote open after its
27
+ * trailing slash so completion can descend another level.
28
+ * @param candidate - selected file or directory.
29
+ * @param preserveQuote - retain an explicitly opened quote even when unnecessary.
30
+ * @returns the insertion value, or `undefined` for a path the editor grammar cannot represent safely.
31
+ */
32
+ export declare function formatFileMention(candidate: FileReferenceCandidate, preserveQuote: boolean): string | undefined;
33
+ //# sourceMappingURL=grammar.d.ts.map
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Browser-safe `@file` token grammar shared by terminal and web clients.
3
+ *
4
+ * @module @deepseek-ai/dsh-file-reference/grammar
5
+ */
6
+ /**
7
+ * Extract an `@path` or `@"path with spaces` token at the cursor. An `@`
8
+ * inside another token, such as an email address, is not a completion trigger.
9
+ * @param line - current editor line.
10
+ * @param cursorCol - cursor column within that line.
11
+ * @returns the active token, or `undefined` outside an `@` token.
12
+ */
13
+ export function activeAtToken(line, cursorCol) {
14
+ const beforeCursor = line.slice(0, cursorCol);
15
+ const quoted = /(?:^|\s)(@"([^"]*))$/u.exec(beforeCursor);
16
+ if (quoted?.[1] !== undefined && quoted[2] !== undefined) {
17
+ return { prefix: quoted[1], query: quoted[2], quoted: true };
18
+ }
19
+ const plain = /(?:^|\s)(@([^\s]*))$/u.exec(beforeCursor);
20
+ if (plain?.[1] === undefined || plain[2] === undefined)
21
+ return undefined;
22
+ return { prefix: plain[1], query: plain[2], quoted: false };
23
+ }
24
+ /**
25
+ * Format a selected path as prompt text. Whitespace uses the quoted
26
+ * `@"path"` grammar; a quoted directory keeps that quote open after its
27
+ * trailing slash so completion can descend another level.
28
+ * @param candidate - selected file or directory.
29
+ * @param preserveQuote - retain an explicitly opened quote even when unnecessary.
30
+ * @returns the insertion value, or `undefined` for a path the editor grammar cannot represent safely.
31
+ */
32
+ export function formatFileMention(candidate, preserveQuote) {
33
+ const path = candidate.kind === 'directory' ? `${candidate.path}/` : candidate.path;
34
+ if (/[\u0000-\u001f\u007f-\u009f"]/u.test(path))
35
+ return undefined;
36
+ const quoted = preserveQuote || /\s/u.test(path);
37
+ if (!quoted)
38
+ return `@${path}`;
39
+ if (candidate.kind === 'directory')
40
+ return `@"${path}`;
41
+ return `@"${path}"`;
42
+ }
43
+ //# sourceMappingURL=grammar.js.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * File-reference discovery seam shared by host-backed user interfaces.
3
+ *
4
+ * @module @deepseek-ai/dsh-file-reference
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { Agent } from '@deepseek-ai/dsh-agent';
8
+ import { TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
9
+ import type { FileReferenceCandidate } from './types.ts';
10
+ export { activeAtToken, formatFileMention } from './grammar.ts';
11
+ export type { ActiveAtToken } from './grammar.ts';
12
+ export type { FileReferenceCandidate } from './types.ts';
13
+ /** Model guidance for path-only references selected by a user interface. */
14
+ export declare const FILE_REFERENCE_PROMPT = "Paths prefixed with @ are files explicitly referenced by the user. Use the read tool when their contents are needed; do not claim to have inspected a file before reading it.";
15
+ declare module '@deepseek-ai/cordis' {
16
+ interface Context {
17
+ fileReferences: FileReferenceService;
18
+ }
19
+ }
20
+ /** Host capability for cancellable file-reference discovery. */
21
+ export declare abstract class FileReferenceService extends TypertRemoteService {
22
+ constructor(ctx: Context);
23
+ /**
24
+ * List file and directory candidates for one agent's working directory.
25
+ * @param agent - target agent whose session cwd bounds discovery.
26
+ * @param query - path text following `@` or `@"`.
27
+ * @param signal - caller cancellation.
28
+ * @returns deterministic path-only candidates.
29
+ */
30
+ abstract list(agent: Agent, query: string, signal: AbortSignal): Promise<FileReferenceCandidate[]>;
31
+ /**
32
+ * Remote face of {@link list}; the decorator cannot mark the abstract
33
+ * member, so this concrete adapter carries the identical contract.
34
+ * @param agent - target agent whose session cwd bounds discovery.
35
+ * @param query - path text following `@` or `@"`.
36
+ * @param signal - caller cancellation.
37
+ * @returns deterministic path-only candidates.
38
+ */
39
+ remoteExportList(agent: Agent, query: string, signal: AbortSignal): Promise<FileReferenceCandidate[]>;
40
+ }
41
+ export default FileReferenceService;
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,75 @@
1
+ /**
2
+ * File-reference discovery seam shared by host-backed user interfaces.
3
+ *
4
+ * @module @deepseek-ai/dsh-file-reference
5
+ */
6
+ var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
7
+ var useValue = arguments.length > 2;
8
+ for (var i = 0; i < initializers.length; i++) {
9
+ value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
10
+ }
11
+ return useValue ? value : void 0;
12
+ };
13
+ var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
14
+ function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
15
+ var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
16
+ var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
17
+ var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
18
+ var _, done = false;
19
+ for (var i = decorators.length - 1; i >= 0; i--) {
20
+ var context = {};
21
+ for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
22
+ for (var p in contextIn.access) context.access[p] = contextIn.access[p];
23
+ context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
24
+ var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
25
+ if (kind === "accessor") {
26
+ if (result === void 0) continue;
27
+ if (result === null || typeof result !== "object") throw new TypeError("Object expected");
28
+ if (_ = accept(result.get)) descriptor.get = _;
29
+ if (_ = accept(result.set)) descriptor.set = _;
30
+ if (_ = accept(result.init)) initializers.unshift(_);
31
+ }
32
+ else if (_ = accept(result)) {
33
+ if (kind === "field") initializers.unshift(_);
34
+ else descriptor[key] = _;
35
+ }
36
+ }
37
+ if (target) Object.defineProperty(target, contextIn.name, descriptor);
38
+ done = true;
39
+ };
40
+ import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';
41
+ export { activeAtToken, formatFileMention } from "./grammar.js";
42
+ /** Model guidance for path-only references selected by a user interface. */
43
+ export const FILE_REFERENCE_PROMPT = 'Paths prefixed with @ are files explicitly referenced by the user. Use the read tool when their contents are needed; do not claim to have inspected a file before reading it.';
44
+ /** Host capability for cancellable file-reference discovery. */
45
+ let FileReferenceService = (() => {
46
+ let _classSuper = TypertRemoteService;
47
+ let _instanceExtraInitializers = [];
48
+ let _remoteExportList_decorators;
49
+ return class FileReferenceService extends _classSuper {
50
+ static {
51
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
52
+ _remoteExportList_decorators = [Remote('list')];
53
+ __esDecorate(this, null, _remoteExportList_decorators, { kind: "method", name: "remoteExportList", static: false, private: false, access: { has: obj => "remoteExportList" in obj, get: obj => obj.remoteExportList }, metadata: _metadata }, null, _instanceExtraInitializers);
54
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
55
+ }
56
+ constructor(ctx) {
57
+ super(ctx, 'fileReferences');
58
+ __runInitializers(this, _instanceExtraInitializers);
59
+ }
60
+ /**
61
+ * Remote face of {@link list}; the decorator cannot mark the abstract
62
+ * member, so this concrete adapter carries the identical contract.
63
+ * @param agent - target agent whose session cwd bounds discovery.
64
+ * @param query - path text following `@` or `@"`.
65
+ * @param signal - caller cancellation.
66
+ * @returns deterministic path-only candidates.
67
+ */
68
+ remoteExportList(agent, query, signal) {
69
+ return this.list(agent, query, signal);
70
+ }
71
+ };
72
+ })();
73
+ export { FileReferenceService };
74
+ export default FileReferenceService;
75
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-file-reference`.
3
+ * @module @deepseek-ai/dsh-file-reference/invariant
4
+ */
5
+ import type { Context } from '@deepseek-ai/cordis';
6
+ /** Cordis companion plugin name. */
7
+ export declare const name = "file-reference-invariant";
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export declare const inject: string[];
10
+ /**
11
+ * Register this package's invariant companion.
12
+ * @param ctx - Cordis context carrying the invariant service.
13
+ * @returns the installed registration's disposer after setup succeeds.
14
+ */
15
+ export declare const apply: (ctx: Context) => Promise<() => void>;
16
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Package-owned invariant companion for `@deepseek-ai/dsh-file-reference`.
3
+ * @module @deepseek-ai/dsh-file-reference/invariant
4
+ */
5
+ const PACKAGE_NAME = '@deepseek-ai/dsh-file-reference';
6
+ /** Cordis companion plugin name. */
7
+ export const name = 'file-reference-invariant';
8
+ /** Service required before the companion can reserve package ownership. */
9
+ export const inject = ['invariants'];
10
+ /**
11
+ * No runtime invariant: the interface retains no candidate or lifecycle
12
+ * state; concrete providers own their cache and invalidation relationships.
13
+ */
14
+ const install = () => { };
15
+ /**
16
+ * Register this package's invariant companion.
17
+ * @param ctx - Cordis context carrying the invariant service.
18
+ * @returns the installed registration's disposer after setup succeeds.
19
+ */
20
+ export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
21
+ /* jscpd:ignore-end */
22
+ //# sourceMappingURL=invariant.js.map
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Public file-reference discovery records. This module contains types only so
3
+ * generated Remote clients can consume it without Host runtime code.
4
+ * @module @deepseek-ai/dsh-file-reference/types
5
+ */
6
+ /** One path-only completion candidate inside the target session cwd. */
7
+ export interface FileReferenceCandidate {
8
+ /** User-facing path accepted by normal prompts and filesystem tools. */
9
+ path: string;
10
+ /** Directories keep completion open; files finish the mention. */
11
+ kind: 'file' | 'directory';
12
+ }
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Public file-reference discovery records. This module contains types only so
3
+ * generated Remote clients can consume it without Host runtime code.
4
+ * @module @deepseek-ai/dsh-file-reference/types
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=types.js.map
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@deepseek-ai/dsh-file-reference",
3
+ "description": "File-reference discovery contract and shared @file grammar",
4
+ "version": "0.1.0-rc.8",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/deepseek-ai/deepseek-harness.git",
11
+ "directory": "packages/context/file-reference"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./grammar": {
22
+ "types": "./lib/types/grammar.d.ts",
23
+ "default": "./lib/types/grammar.js"
24
+ },
25
+ "./invariant": {
26
+ "types": "./lib/types/invariant.d.ts",
27
+ "default": "./lib/invariant.js"
28
+ },
29
+ "./types": {
30
+ "types": "./lib/types/types.d.ts",
31
+ "default": "./lib/types/types.js"
32
+ },
33
+ "./typert": {
34
+ "types": "./lib/typert.host.d.ts",
35
+ "default": "./lib/typert.host.js"
36
+ },
37
+ "./remote": {
38
+ "types": "./lib/typert.remote-client.d.ts",
39
+ "default": "./lib/typert.remote-client.js"
40
+ },
41
+ "./src/*": "./src/*",
42
+ "./package.json": "./package.json"
43
+ },
44
+ "files": [
45
+ "lib/index.js",
46
+ "lib/invariant.js",
47
+ "lib/types/**/*.js",
48
+ "lib/types/**/*.d.ts",
49
+ "lib/typert.host.js",
50
+ "lib/typert.host.d.ts",
51
+ "lib/typert.remote-client.js",
52
+ "lib/typert.remote-client.d.ts"
53
+ ],
54
+ "license": "MIT",
55
+ "peerDependencies": {
56
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.8",
57
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
58
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.8",
59
+ "@deepseek-ai/cordis": "^4.0.1"
60
+ },
61
+ "devDependencies": {
62
+ "@deepseek-ai/dsh-invariants": "^0.1.0-rc.8",
63
+ "@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.8",
64
+ "@deepseek-ai/cordis": "^4.0.1",
65
+ "@deepseek-ai/dsh-agent": "^0.1.0-rc.8"
66
+ },
67
+ "dependencies": {
68
+ "zod": "^4.4.3"
69
+ }
70
+ }