@deepseek-ai/dsh-tool-present 0.2.2-rc.1 → 0.2.2-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +1 -1
- package/lib/index.js +7 -7
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +7 -7
- package/lib/types/index.js.map +1 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/types.js.map +1 -0
- package/package.json +24 -21
- package/src/index.ts +110 -0
- package/src/types.ts +17 -0
package/README.i18n.yaml
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
en: d152484eb41ac6b4
|
|
16
16
|
zh: 09388d293f9be9cb
|
|
17
17
|
/deepseek-ai-dsh-tool-present/use-this-package:
|
|
18
|
-
en:
|
|
19
|
-
zh:
|
|
18
|
+
en: aecb160dd6ee85ba
|
|
19
|
+
zh: 148288a2e92236fa
|
|
20
20
|
/deepseek-ai-dsh-tool-present/understand-the-implementation:
|
|
21
21
|
en: 6e73ca41dddc096e
|
|
22
22
|
zh: b59fdfa3f3cc47e1
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ Shared output and file-link guidance comes from [`dsh-deliverable-file-reference
|
|
|
29
29
|
|
|
30
30
|
`present` validates paths against the Session's current working directory and records absolute paths, so later directory changes do not redirect delivered files.
|
|
31
31
|
|
|
32
|
-
The `standard`, `ptc`, and `cordis` agent presets mount this plugin. Call `present` with `files: [{ path, description? }]` after creating the files. Files must be regular files accessible through the Session filesystem. Relative paths resolve against the Session working directory; absolute paths may name files outside it, including `/tmp` or Downloads. Missing files, directories, final symbolic links, and provider-denied paths fail the call. Files in a shell sandbox’s private `/tmp` must first be written somewhere the Session filesystem can access.
|
|
32
|
+
The `standard`, `ptc`, and `cordis` agent presets mount this plugin. Call `present` with `files: [{ path, description? }]` after creating the files. Files must be regular files accessible through the Session filesystem. Relative paths resolve against the Session working directory; absolute paths may name files outside it, including `/tmp` or Downloads. Missing files, directories, final symbolic links, and provider-denied paths fail the call with `FsError` codes such as `FS_NOT_FOUND`, `FS_NOT_REGULAR_FILE`, and `FS_PERMISSION_DENIED`; an empty path or a file count outside 1 to `maxFiles` reports `ToolArgsError` (`INVALID_ARGS`), and a call without an agent Session or open turn reports `ToolContextUnavailableError` (`TOOL_CONTEXT_UNAVAILABLE`). Files in a shell sandbox’s private `/tmp` must first be written somewhere the Session filesystem can access.
|
|
33
33
|
|
|
34
34
|
Mount it in an agent's Cordis composition with `tools`, `fs`, and the `turnBoundary` Session projection available:
|
|
35
35
|
|
package/README.zh.md
CHANGED
|
@@ -29,7 +29,7 @@ kind: "package-reference"
|
|
|
29
29
|
|
|
30
30
|
`present` 按 Session 的当前工作目录校验路径并记录绝对路径,因此后续目录切换不会让已交付文件指向其他位置。
|
|
31
31
|
|
|
32
|
-
`standard`、`ptc` 与 `cordis` Agent preset 挂载本插件。创建文件后,以 `files: [{ path, description? }]` 调用 `present`。文件必须是 Session 文件系统可访问的普通文件。相对路径按 Session 工作目录解析;绝对路径可以指向工作区外的文件,包括 `/tmp` 或 Downloads
|
|
32
|
+
`standard`、`ptc` 与 `cordis` Agent preset 挂载本插件。创建文件后,以 `files: [{ path, description? }]` 调用 `present`。文件必须是 Session 文件系统可访问的普通文件。相对路径按 Session 工作目录解析;绝对路径可以指向工作区外的文件,包括 `/tmp` 或 Downloads。文件缺失、为目录、最终路径为符号链接或提供方拒绝访问时,调用以 `FsError` 失败,错误码如 `FS_NOT_FOUND`、`FS_NOT_REGULAR_FILE` 与 `FS_PERMISSION_DENIED`;路径为空或文件数量不在 1 到 `maxFiles` 之间时报告 `ToolArgsError`(`INVALID_ARGS`),缺少 agent Session 或打开的 turn 时报告 `ToolContextUnavailableError`(`TOOL_CONTEXT_UNAVAILABLE`)。Shell 沙箱私有 `/tmp` 中的文件需要先写入 Session 文件系统可访问的位置。
|
|
33
33
|
|
|
34
34
|
在 Agent 的 Cordis 组合中挂载,并提供 `tools`、`fs` 和 `turnBoundary` Session 投影:
|
|
35
35
|
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { FsError } from "@deepseek-ai/dsh-fs";
|
|
3
|
-
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
|
+
import { ToolArgsError, ToolContextUnavailableError, defineTool } from "@deepseek-ai/dsh-tools";
|
|
4
4
|
//#region lib/types/index.js
|
|
5
5
|
/** Stable Loader identity. */
|
|
6
6
|
const name = "tool-present";
|
|
@@ -76,10 +76,10 @@ function apply(ctx, config) {
|
|
|
76
76
|
}]
|
|
77
77
|
},
|
|
78
78
|
async execute(args, exec) {
|
|
79
|
-
if (exec.agent === void 0) throw new
|
|
79
|
+
if (exec.agent === void 0) throw new ToolContextUnavailableError("present requires an agent Session");
|
|
80
80
|
const boundary = ctx.agents.turnBoundaryOf(exec.agent.session);
|
|
81
|
-
if (boundary.openTurnStartSeq === null) throw new
|
|
82
|
-
if (args.files.length === 0 || args.files.length > config.maxFiles) throw new
|
|
81
|
+
if (boundary.openTurnStartSeq === null) throw new ToolContextUnavailableError("present requires an open turn");
|
|
82
|
+
if (args.files.length === 0 || args.files.length > config.maxFiles) throw new ToolArgsError([`present accepts 1 to ${config.maxFiles} files`]);
|
|
83
83
|
const cwd = await ctx.workingDirectory.ensure(exec.agent, exec.signal);
|
|
84
84
|
const options = {
|
|
85
85
|
cwd,
|
|
@@ -87,13 +87,13 @@ function apply(ctx, config) {
|
|
|
87
87
|
};
|
|
88
88
|
const files = [];
|
|
89
89
|
for (const file of args.files) {
|
|
90
|
-
if (file.path.trim().length === 0) throw new
|
|
90
|
+
if (file.path.trim().length === 0) throw new ToolArgsError(["present requires a non-empty file path"]);
|
|
91
91
|
const entry = await ctx.fs.lstat(file.path, { cwd }, exec.signal);
|
|
92
|
-
if (entry !== void 0 && entry.type !== "file") throw new
|
|
92
|
+
if (entry !== void 0 && entry.type !== "file") throw new FsError(`Cannot present ${file.path}: not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
93
93
|
const target = await ctx.fs.resolve(file.path, options);
|
|
94
94
|
const info = await ctx.fs.stat(target, exec.signal);
|
|
95
95
|
if (info === void 0) throw new FsError(`Cannot present ${file.path}: file not found. Check the path, create the file if needed, and retry.`, "FS_NOT_FOUND");
|
|
96
|
-
if (info.type !== "file") throw new
|
|
96
|
+
if (info.type !== "file") throw new FsError(`Cannot present ${file.path}: not a regular file`, "FS_NOT_REGULAR_FILE");
|
|
97
97
|
files.push({
|
|
98
98
|
...file,
|
|
99
99
|
path: ctx.fs.processPath(target)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAOxC,8BAA8B;AAC9B,eAAO,MAAM,IAAI,iBAAiB,CAAA;AAElC,+BAA+B;AAC/B,MAAM,WAAW,MAAM;IACrB,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,gCAAgC;AAChC,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAE3B,CAAA;AAEF,iDAAiD;AACjD,eAAO,MAAM,MAAM,UAAgD,CAAA;AAEnE;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CA6ExD"}
|
package/lib/types/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from '@deepseek-ai/schemastery';
|
|
2
2
|
import { FsError } from '@deepseek-ai/dsh-fs';
|
|
3
|
-
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
3
|
+
import { ToolArgsError, ToolContextUnavailableError, defineTool } from '@deepseek-ai/dsh-tools';
|
|
4
4
|
/** Stable Loader identity. */
|
|
5
5
|
export const name = 'tool-present';
|
|
6
6
|
/** Validated delivery limit. */
|
|
@@ -61,27 +61,27 @@ export function apply(ctx, config) {
|
|
|
61
61
|
},
|
|
62
62
|
async execute(args, exec) {
|
|
63
63
|
if (exec.agent === undefined)
|
|
64
|
-
throw new
|
|
64
|
+
throw new ToolContextUnavailableError('present requires an agent Session');
|
|
65
65
|
const boundary = ctx.agents.turnBoundaryOf(exec.agent.session);
|
|
66
66
|
if (boundary.openTurnStartSeq === null)
|
|
67
|
-
throw new
|
|
67
|
+
throw new ToolContextUnavailableError('present requires an open turn');
|
|
68
68
|
if (args.files.length === 0 || args.files.length > config.maxFiles)
|
|
69
|
-
throw new
|
|
69
|
+
throw new ToolArgsError([`present accepts 1 to ${config.maxFiles} files`]);
|
|
70
70
|
const cwd = await ctx.workingDirectory.ensure(exec.agent, exec.signal);
|
|
71
71
|
const options = { cwd, signal: exec.signal };
|
|
72
72
|
const files = [];
|
|
73
73
|
for (const file of args.files) {
|
|
74
74
|
if (file.path.trim().length === 0)
|
|
75
|
-
throw new
|
|
75
|
+
throw new ToolArgsError(['present requires a non-empty file path']);
|
|
76
76
|
const entry = await ctx.fs.lstat(file.path, { cwd }, exec.signal);
|
|
77
77
|
if (entry !== undefined && entry.type !== 'file')
|
|
78
|
-
throw new
|
|
78
|
+
throw new FsError(`Cannot present ${file.path}: not a regular file`, 'FS_NOT_REGULAR_FILE');
|
|
79
79
|
const target = await ctx.fs.resolve(file.path, options);
|
|
80
80
|
const info = await ctx.fs.stat(target, exec.signal);
|
|
81
81
|
if (info === undefined)
|
|
82
82
|
throw new FsError(`Cannot present ${file.path}: file not found. Check the path, create the file if needed, and retry.`, 'FS_NOT_FOUND');
|
|
83
83
|
if (info.type !== 'file')
|
|
84
|
-
throw new
|
|
84
|
+
throw new FsError(`Cannot present ${file.path}: not a regular file`, 'FS_NOT_REGULAR_FILE');
|
|
85
85
|
files.push({ ...file, path: ctx.fs.processPath(target) });
|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,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK;SACjC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AAE5D,mFAAmF;AACnF,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAA;IACZ,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,OAAO,QAAQ,gCAAgC,CAAC;IAC9C,UAAU,eAAe;QACvB,gGAAgG;QAChG,wBAAwB,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,UAAU,CAAC;YAAC,KAAK,EAAE,aAAa,EAAE,CAAA;SAAE,CAAA;KACvF;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-tool-present",
|
|
3
3
|
"description": "Explicit workspace file delivery declarations for the DeepSeek Harness",
|
|
4
|
-
"version": "0.2.2-rc.
|
|
4
|
+
"version": "0.2.2-rc.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,34 +31,37 @@
|
|
|
31
31
|
"locale/*.json",
|
|
32
32
|
"lib/index.js",
|
|
33
33
|
"lib/types/**/*.js",
|
|
34
|
-
"lib/types/**/*.d.ts"
|
|
34
|
+
"lib/types/**/*.d.ts",
|
|
35
|
+
"lib/types/**/*.d.ts.map",
|
|
36
|
+
"lib/**/*.js.map",
|
|
37
|
+
"src"
|
|
35
38
|
],
|
|
36
39
|
"dependencies": {
|
|
37
40
|
"@deepseek-ai/schemastery": "~3.19.0"
|
|
38
41
|
},
|
|
39
42
|
"peerDependencies": {
|
|
40
43
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
41
|
-
"@deepseek-ai/dsh-agent": "0.2.2-rc.
|
|
42
|
-
"@deepseek-ai/dsh-fs": "0.2.2-rc.
|
|
43
|
-
"@deepseek-ai/dsh-llm": "0.2.2-rc.
|
|
44
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.
|
|
45
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.
|
|
46
|
-
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.
|
|
44
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.3",
|
|
45
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.3",
|
|
46
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.3",
|
|
47
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.3",
|
|
48
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.3",
|
|
49
|
+
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.3"
|
|
47
50
|
},
|
|
48
51
|
"devDependencies": {
|
|
49
52
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
50
|
-
"@deepseek-ai/dsh-agent": "0.2.2-rc.
|
|
51
|
-
"@deepseek-ai/dsh-fs": "0.2.2-rc.
|
|
52
|
-
"@deepseek-ai/dsh-llm": "0.2.2-rc.
|
|
53
|
-
"@deepseek-ai/dsh-session": "0.2.2-rc.
|
|
54
|
-
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.
|
|
55
|
-
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.
|
|
56
|
-
"@deepseek-ai/dsh-tool-testkit": "0.2.2-rc.
|
|
57
|
-
"@deepseek-ai/dsh-tools": "0.2.2-rc.
|
|
58
|
-
"@deepseek-ai/dsh-agent-loop": "0.2.2-rc.
|
|
59
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.
|
|
60
|
-
"@deepseek-ai/dsh-fs-local": "0.2.2-rc.
|
|
61
|
-
"@deepseek-ai/dsh-scope": "0.2.2-rc.
|
|
62
|
-
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.
|
|
53
|
+
"@deepseek-ai/dsh-agent": "0.2.2-rc.3",
|
|
54
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.3",
|
|
55
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.3",
|
|
56
|
+
"@deepseek-ai/dsh-session": "0.2.2-rc.3",
|
|
57
|
+
"@deepseek-ai/dsh-session-projection": "0.2.2-rc.3",
|
|
58
|
+
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.3",
|
|
59
|
+
"@deepseek-ai/dsh-tool-testkit": "0.2.2-rc.3",
|
|
60
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.3",
|
|
61
|
+
"@deepseek-ai/dsh-agent-loop": "0.2.2-rc.3",
|
|
62
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.3",
|
|
63
|
+
"@deepseek-ai/dsh-fs-local": "0.2.2-rc.3",
|
|
64
|
+
"@deepseek-ai/dsh-scope": "0.2.2-rc.3",
|
|
65
|
+
"@deepseek-ai/dsh-working-directory": "0.2.2-rc.3"
|
|
63
66
|
}
|
|
64
67
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Scoped tool that declares filesystem deliveries in their owning Session. */
|
|
2
|
+
import type {} from '@deepseek-ai/dsh-working-directory'
|
|
3
|
+
import type { Context } from '@deepseek-ai/cordis'
|
|
4
|
+
import z from '@deepseek-ai/schemastery'
|
|
5
|
+
import { FsError } from '@deepseek-ai/dsh-fs'
|
|
6
|
+
import { ToolArgsError, ToolContextUnavailableError, defineTool, type ToolExecution } from '@deepseek-ai/dsh-tools'
|
|
7
|
+
import type {} from '@deepseek-ai/dsh-agent'
|
|
8
|
+
import type { Session } from '@deepseek-ai/dsh-session'
|
|
9
|
+
import type { PresentedFile } from './types.ts'
|
|
10
|
+
|
|
11
|
+
/** Stable Loader identity. */
|
|
12
|
+
export const name = 'tool-present'
|
|
13
|
+
|
|
14
|
+
/** Per-call delivery limit. */
|
|
15
|
+
export interface Config {
|
|
16
|
+
/** Maximum number of files in one call. */
|
|
17
|
+
maxFiles: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Validated delivery limit. */
|
|
21
|
+
export const Config: z<Config> = z.object({
|
|
22
|
+
maxFiles: z.number().default(8),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
/** Services used by the scoped delivery tool. */
|
|
26
|
+
export const inject = ['tools', 'fs', 'agents', 'workingDirectory']
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Register present with durable file references in its tool result.
|
|
30
|
+
* @param ctx - agent-scoped services.
|
|
31
|
+
* @param config - maximum files per call.
|
|
32
|
+
*/
|
|
33
|
+
export function apply(ctx: Context, config: Config): void {
|
|
34
|
+
if (!Number.isSafeInteger(config.maxFiles) || config.maxFiles < 1) {
|
|
35
|
+
throw new Error('present requires a positive integer maxFiles')
|
|
36
|
+
}
|
|
37
|
+
const pending = new WeakMap<ToolExecution, { session: Session; turn: number; files: PresentedFile[] }>()
|
|
38
|
+
ctx.tools.register(defineTool({
|
|
39
|
+
name: 'present',
|
|
40
|
+
description: 'Declare existing files as final deliverables for the user. '
|
|
41
|
+
+ 'Hosts may show presented files only after your turn ends, so call it once the files are final. '
|
|
42
|
+
+ 'If the user needs to review files earlier, such as before a tool call that waits for their answer, link them in your message instead. '
|
|
43
|
+
+ 'Use it when the user needs a separate file, especially Office documents, spreadsheets, and slide decks; '
|
|
44
|
+
+ 'prefer your final response when that suffices. The user opens the current files; their contents are not copied.',
|
|
45
|
+
parameters: {
|
|
46
|
+
files: {
|
|
47
|
+
type: 'array', required: true,
|
|
48
|
+
// 4 is the recommended per-call count; `maxFiles` is the enforced ceiling above it.
|
|
49
|
+
description: 'Usually the 1-2 most important deliverables; at most 4 per call.',
|
|
50
|
+
items: {
|
|
51
|
+
type: 'object', additionalProperties: false,
|
|
52
|
+
properties: {
|
|
53
|
+
path: { type: 'string', required: true, description: 'Path of an existing regular file. Relative paths use the Session working directory.' },
|
|
54
|
+
description: { type: 'string', description: 'Brief description for the user.' },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
output: {
|
|
60
|
+
schema: {
|
|
61
|
+
type: 'object', additionalProperties: false,
|
|
62
|
+
properties: {
|
|
63
|
+
turn: { type: 'integer', required: true },
|
|
64
|
+
files: {
|
|
65
|
+
type: 'array', required: true,
|
|
66
|
+
items: {
|
|
67
|
+
type: 'object', additionalProperties: false,
|
|
68
|
+
properties: {
|
|
69
|
+
path: { type: 'string', required: true },
|
|
70
|
+
description: { type: 'string' },
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
render: (_args, value) => [{ type: 'text', text: value.files.map(file => `Presented ${file.path}`).join('\n') }],
|
|
77
|
+
},
|
|
78
|
+
async execute(args, exec) {
|
|
79
|
+
if (exec.agent === undefined) throw new ToolContextUnavailableError('present requires an agent Session')
|
|
80
|
+
const boundary = ctx.agents.turnBoundaryOf(exec.agent.session)
|
|
81
|
+
if (boundary.openTurnStartSeq === null) throw new ToolContextUnavailableError('present requires an open turn')
|
|
82
|
+
if (args.files.length === 0 || args.files.length > config.maxFiles) throw new ToolArgsError([`present accepts 1 to ${config.maxFiles} files`])
|
|
83
|
+
const cwd = await ctx.workingDirectory.ensure(exec.agent, exec.signal)
|
|
84
|
+
const options = { cwd, signal: exec.signal }
|
|
85
|
+
const files: PresentedFile[] = []
|
|
86
|
+
for (const file of args.files) {
|
|
87
|
+
if (file.path.trim().length === 0) throw new ToolArgsError(['present requires a non-empty file path'])
|
|
88
|
+
const entry = await ctx.fs.lstat(file.path, { cwd }, exec.signal)
|
|
89
|
+
if (entry !== undefined && entry.type !== 'file') throw new FsError(`Cannot present ${file.path}: not a regular file`, 'FS_NOT_REGULAR_FILE')
|
|
90
|
+
const target = await ctx.fs.resolve(file.path, options)
|
|
91
|
+
const info = await ctx.fs.stat(target, exec.signal)
|
|
92
|
+
if (info === undefined) throw new FsError(`Cannot present ${file.path}: file not found. Check the path, create the file if needed, and retry.`, 'FS_NOT_FOUND')
|
|
93
|
+
if (info.type !== 'file') throw new FsError(`Cannot present ${file.path}: not a regular file`, 'FS_NOT_REGULAR_FILE')
|
|
94
|
+
files.push({ ...file, path: ctx.fs.processPath(target) })
|
|
95
|
+
}
|
|
96
|
+
exec.signal.throwIfAborted()
|
|
97
|
+
pending.set(exec, { session: exec.agent.session, turn: boundary.lastTurn, files })
|
|
98
|
+
return { turn: boundary.lastTurn, files }
|
|
99
|
+
},
|
|
100
|
+
}))
|
|
101
|
+
ctx.on('tools/result', (exec, result) => {
|
|
102
|
+
const delivery = pending.get(exec)
|
|
103
|
+
pending.delete(exec)
|
|
104
|
+
if (delivery === undefined || result.isError) return
|
|
105
|
+
const { session, turn, files } = delivery
|
|
106
|
+
session.append('deliverables/presented', {
|
|
107
|
+
turn, callId: exec.callId, files,
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Durable file deliveries produced by the present tool. */
|
|
2
|
+
import type { ToolCallId } from '@deepseek-ai/dsh-llm/brand'
|
|
3
|
+
|
|
4
|
+
/** A declared filesystem file whose current contents remain at its source path. */
|
|
5
|
+
export interface PresentedFile {
|
|
6
|
+
/** Original absolute path or path relative to the Session working directory. */
|
|
7
|
+
path: string
|
|
8
|
+
/** Optional description supplied by the model. */
|
|
9
|
+
description?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare module '@deepseek-ai/dsh-session/types' {
|
|
13
|
+
interface SessionEventMap {
|
|
14
|
+
/** Declared filesystem files from a successful final present result, including nested calls. */
|
|
15
|
+
'deliverables/presented': { turn: number; callId: ToolCallId; files: PresentedFile[] }
|
|
16
|
+
}
|
|
17
|
+
}
|