@deepseek-ai/dsh-tool-fs 0.1.5-rc.2 → 0.1.6-alpha.2
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/lib/index.js +18 -20
- package/lib/types/diff.d.ts +4 -1
- package/lib/types/sandbox.d.ts +2 -1
- package/lib/types/session-cwd.d.ts +2 -5
- package/package.json +28 -28
package/lib/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
3
3
|
import { FsError } from "@deepseek-ai/dsh-fs";
|
|
4
|
-
import { ESCALATION_TARGETS, approveEscalation, canonicalPath, escalationHintMarker, sandboxDenialMarker, validateEscalationArgs } from "@deepseek-ai/dsh-sandbox";
|
|
5
4
|
import { structuredPatch } from "diff";
|
|
6
5
|
import { basename, extname } from "node:path";
|
|
7
6
|
import { AttachmentError, AttachmentId } from "@deepseek-ai/dsh-attachment";
|
|
7
|
+
import { ESCALATION_TARGETS, approveEscalation, escalationHintMarker, sandboxDenialMarker, validateEscalationArgs } from "@deepseek-ai/dsh-sandbox";
|
|
8
8
|
//#region lib/types/read-render.js
|
|
9
9
|
/**
|
|
10
10
|
* Pure read presentation: turn provider-decoded text into a bounded, line-numbered window and
|
|
@@ -229,28 +229,22 @@ function readMetaFromMeta(meta) {
|
|
|
229
229
|
* `process.cwd()` at the tool boundary.
|
|
230
230
|
* @module @deepseek-ai/dsh-tool-fs/session-cwd
|
|
231
231
|
*/
|
|
232
|
-
const PARENT_PATH_SEGMENT = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
|
|
233
232
|
/**
|
|
234
233
|
* The session workspace cwd for this call, or `undefined` when none applies.
|
|
235
234
|
* @param exec - the tool-execution context; only its optional `agent` is read.
|
|
236
|
-
* @param requestedPath - the path the provider will resolve; parent traversal
|
|
237
|
-
* makes a symlinked cwd's filesystem identity observable.
|
|
238
235
|
* @returns the calling agent's session cwd, or undefined for a non-agent caller (the backend then applies its own default).
|
|
239
236
|
*/
|
|
240
|
-
function sessionCwd(exec
|
|
241
|
-
|
|
242
|
-
if (cwd === void 0 || !PARENT_PATH_SEGMENT.test(cwd) && !PARENT_PATH_SEGMENT.test(requestedPath)) return cwd;
|
|
243
|
-
return canonicalPath(cwd);
|
|
237
|
+
function sessionCwd(exec) {
|
|
238
|
+
return exec.agent?.session.header.cwd;
|
|
244
239
|
}
|
|
245
240
|
/**
|
|
246
241
|
* Resolution options shared by all model-facing filesystem tools.
|
|
247
242
|
* @param exec - the tool-execution context supplying session cwd and cancellation.
|
|
248
|
-
* @param requestedPath - the path the provider will resolve.
|
|
249
243
|
* @param policyWorkspaceRoot - resolved per-call root, when a mutation carries sandbox policy.
|
|
250
244
|
* @returns provider resolution options for the current tool call.
|
|
251
245
|
*/
|
|
252
|
-
function sessionResolveOptions(exec,
|
|
253
|
-
const cwd = policyWorkspaceRoot ?? sessionCwd(exec
|
|
246
|
+
function sessionResolveOptions(exec, policyWorkspaceRoot) {
|
|
247
|
+
const cwd = policyWorkspaceRoot ?? sessionCwd(exec);
|
|
254
248
|
return {
|
|
255
249
|
...cwd !== void 0 ? { cwd } : {},
|
|
256
250
|
signal: exec.signal
|
|
@@ -270,7 +264,7 @@ function sessionResolveOptions(exec, requestedPath, policyWorkspaceRoot) {
|
|
|
270
264
|
* @returns the resolved target and its single stat result.
|
|
271
265
|
*/
|
|
272
266
|
async function resolveRegularReadTarget(ctx, exec, requestedPath) {
|
|
273
|
-
const target = await ctx.fs.resolve(requestedPath, sessionResolveOptions(exec
|
|
267
|
+
const target = await ctx.fs.resolve(requestedPath, sessionResolveOptions(exec));
|
|
274
268
|
const info = await ctx.fs.stat(target, exec.signal);
|
|
275
269
|
if (info === void 0) {
|
|
276
270
|
ctx.emit("fs/observed", target, { kind: "absent" }, exec);
|
|
@@ -637,16 +631,19 @@ function applyWriteTool(ctx, sandbox) {
|
|
|
637
631
|
type: "text",
|
|
638
632
|
text: formatWriteOutput(value.path, value)
|
|
639
633
|
}],
|
|
640
|
-
presentationMeta: (args, value) => ({
|
|
641
|
-
|
|
642
|
-
oldText,
|
|
643
|
-
|
|
644
|
-
|
|
634
|
+
presentationMeta: (args, value) => ({
|
|
635
|
+
operation: value.operation,
|
|
636
|
+
diffs: value.before === null ? [] : computeHunkDiffs(args.file_path, value.before, value.after).map(({ path, oldText, newText }) => ({
|
|
637
|
+
path,
|
|
638
|
+
oldText,
|
|
639
|
+
newText
|
|
640
|
+
}))
|
|
641
|
+
})
|
|
645
642
|
},
|
|
646
643
|
async execute(args, exec) {
|
|
647
644
|
const input = parseWriteArgs(args);
|
|
648
645
|
const sandboxPolicy = await sandbox.resolvePolicy("write", args, exec);
|
|
649
|
-
const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec,
|
|
646
|
+
const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec, sandboxPolicy?.workspaceRoot));
|
|
650
647
|
const intent = await ctx.waterfall("fs/write-intent", target, exec, () => void 0);
|
|
651
648
|
let outcome;
|
|
652
649
|
try {
|
|
@@ -795,7 +792,7 @@ function applyEditTool(ctx, sandbox) {
|
|
|
795
792
|
async execute(args, exec) {
|
|
796
793
|
const input = parseEditArgs(args);
|
|
797
794
|
const sandboxPolicy = await sandbox.resolvePolicy("edit", args, exec);
|
|
798
|
-
const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec,
|
|
795
|
+
const target = await ctx.fs.resolve(input.filePath, sessionResolveOptions(exec, sandboxPolicy?.workspaceRoot));
|
|
799
796
|
let outcome;
|
|
800
797
|
try {
|
|
801
798
|
const intent = await ctx.waterfall("fs/edit-intent", target, exec, () => void 0);
|
|
@@ -1176,7 +1173,8 @@ var FsSandboxController = class {
|
|
|
1176
1173
|
/**
|
|
1177
1174
|
* The policy to stamp onto this mutation: an approved escalation grant (a
|
|
1178
1175
|
* strictly wider retry resolved through `ctx.approval` before anything
|
|
1179
|
-
* executes), else the session's standing mode.
|
|
1176
|
+
* executes), else the session's standing mode. Repeating the standing mode
|
|
1177
|
+
* requires no approval. The calling session's cwd is
|
|
1180
1178
|
* always carried as the workspace root. Validates the escalation argument
|
|
1181
1179
|
* pairing first.
|
|
1182
1180
|
* @param toolName - the mutating tool's name, for the approval audit trail.
|
package/lib/types/diff.d.ts
CHANGED
|
@@ -8,13 +8,16 @@ import type { FileDiff } from '@deepseek-ai/dsh-tools';
|
|
|
8
8
|
export declare const DIFF_CONTEXT = 3;
|
|
9
9
|
/**
|
|
10
10
|
* The `write`/`edit` tools' private `tool/result` `meta` payload: the applied
|
|
11
|
-
* contextual-diff hunks
|
|
11
|
+
* contextual-diff hunks, and for `write` whether the call created or updated
|
|
12
|
+
* the file, which tells an empty hunk list of a create from one of an
|
|
13
|
+
* unchanged overwrite. Attached opaquely (as `unknown`) on the tool result and
|
|
12
14
|
* persisted with the session log — it must be JSON-serializable (the session
|
|
13
15
|
* validates this at `append`), so `presentResult` reproduces the diff card on
|
|
14
16
|
* replay. The producing tool owns and narrows this opaque shape.
|
|
15
17
|
*/
|
|
16
18
|
export type FsDiffMeta = {
|
|
17
19
|
diffs: FileDiff[];
|
|
20
|
+
operation?: 'create' | 'update';
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
20
23
|
* Compute one {@link FileDiff} per hunk between `before` and `after`, each carrying the
|
package/lib/types/sandbox.d.ts
CHANGED
|
@@ -52,7 +52,8 @@ export declare class FsSandboxController {
|
|
|
52
52
|
/**
|
|
53
53
|
* The policy to stamp onto this mutation: an approved escalation grant (a
|
|
54
54
|
* strictly wider retry resolved through `ctx.approval` before anything
|
|
55
|
-
* executes), else the session's standing mode.
|
|
55
|
+
* executes), else the session's standing mode. Repeating the standing mode
|
|
56
|
+
* requires no approval. The calling session's cwd is
|
|
56
57
|
* always carried as the workspace root. Validates the escalation argument
|
|
57
58
|
* pairing first.
|
|
58
59
|
* @param toolName - the mutating tool's name, for the approval audit trail.
|
|
@@ -10,19 +10,16 @@ import type { ToolExecution } from '@deepseek-ai/dsh-tools';
|
|
|
10
10
|
/**
|
|
11
11
|
* The session workspace cwd for this call, or `undefined` when none applies.
|
|
12
12
|
* @param exec - the tool-execution context; only its optional `agent` is read.
|
|
13
|
-
* @param requestedPath - the path the provider will resolve; parent traversal
|
|
14
|
-
* makes a symlinked cwd's filesystem identity observable.
|
|
15
13
|
* @returns the calling agent's session cwd, or undefined for a non-agent caller (the backend then applies its own default).
|
|
16
14
|
*/
|
|
17
|
-
export declare function sessionCwd(exec: ToolExecution
|
|
15
|
+
export declare function sessionCwd(exec: ToolExecution): string | undefined;
|
|
18
16
|
/**
|
|
19
17
|
* Resolution options shared by all model-facing filesystem tools.
|
|
20
18
|
* @param exec - the tool-execution context supplying session cwd and cancellation.
|
|
21
|
-
* @param requestedPath - the path the provider will resolve.
|
|
22
19
|
* @param policyWorkspaceRoot - resolved per-call root, when a mutation carries sandbox policy.
|
|
23
20
|
* @returns provider resolution options for the current tool call.
|
|
24
21
|
*/
|
|
25
|
-
export declare function sessionResolveOptions(exec: ToolExecution,
|
|
22
|
+
export declare function sessionResolveOptions(exec: ToolExecution, policyWorkspaceRoot?: string): {
|
|
26
23
|
cwd?: string;
|
|
27
24
|
signal?: AbortSignal;
|
|
28
25
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepseek-ai/dsh-tool-fs",
|
|
3
3
|
"description": "Model-facing filesystem tools (read, write, edit) over the DeepSeek Harness filesystem seam (ctx.fs)",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.6-alpha.2",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -31,36 +31,36 @@
|
|
|
31
31
|
"@deepseek-ai/schemastery": "^3.18.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@deepseek-ai/dsh-
|
|
35
|
-
"@deepseek-ai/dsh-
|
|
36
|
-
"@deepseek-ai/dsh-sandbox": "^0.1.
|
|
37
|
-
"@deepseek-ai/dsh-sandbox-policy": "^0.1.
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/dsh-
|
|
40
|
-
"@deepseek-ai/dsh-tools": "^0.1.
|
|
41
|
-
"@deepseek-ai/dsh-
|
|
42
|
-
"@deepseek-ai/dsh-
|
|
34
|
+
"@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
|
|
35
|
+
"@deepseek-ai/dsh-fs": "^0.1.6-alpha.2",
|
|
36
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.6-alpha.2",
|
|
37
|
+
"@deepseek-ai/dsh-sandbox-policy": "^0.1.6-alpha.2",
|
|
38
|
+
"@deepseek-ai/dsh-attachment": "^0.1.6-alpha.2",
|
|
39
|
+
"@deepseek-ai/dsh-session": "^0.1.6-alpha.2",
|
|
40
|
+
"@deepseek-ai/dsh-tools": "^0.1.6-alpha.2",
|
|
41
|
+
"@deepseek-ai/dsh-user-approval": "^0.1.6-alpha.2",
|
|
42
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.6-alpha.2",
|
|
43
43
|
"@deepseek-ai/cordis": "^4.0.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@deepseek-ai/dsh-agent": "^0.1.
|
|
47
|
-
"@deepseek-ai/dsh-agent-loop": "^0.1.
|
|
48
|
-
"@deepseek-ai/dsh-agent-loop-testkit": "^0.1.
|
|
49
|
-
"@deepseek-ai/dsh-attachment": "^0.1.
|
|
50
|
-
"@deepseek-ai/dsh-fs
|
|
51
|
-
"@deepseek-ai/dsh-
|
|
52
|
-
"@deepseek-ai/dsh-fs-
|
|
53
|
-
"@deepseek-ai/dsh-
|
|
54
|
-
"@deepseek-ai/dsh-sandbox
|
|
55
|
-
"@deepseek-ai/dsh-
|
|
56
|
-
"@deepseek-ai/dsh-
|
|
57
|
-
"@deepseek-ai/dsh-
|
|
58
|
-
"@deepseek-ai/dsh-tools": "^0.1.
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
46
|
+
"@deepseek-ai/dsh-agent": "^0.1.6-alpha.2",
|
|
47
|
+
"@deepseek-ai/dsh-agent-loop": "^0.1.6-alpha.2",
|
|
48
|
+
"@deepseek-ai/dsh-agent-loop-testkit": "^0.1.6-alpha.2",
|
|
49
|
+
"@deepseek-ai/dsh-attachment": "^0.1.6-alpha.2",
|
|
50
|
+
"@deepseek-ai/dsh-fs": "^0.1.6-alpha.2",
|
|
51
|
+
"@deepseek-ai/dsh-fs-observation-policy": "^0.1.6-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-fs-local": "^0.1.6-alpha.2",
|
|
53
|
+
"@deepseek-ai/dsh-llm-deepseek": "^0.1.6-alpha.2",
|
|
54
|
+
"@deepseek-ai/dsh-sandbox": "^0.1.6-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-sandbox-policy": "^0.1.6-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-session": "^0.1.6-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-system-prompt": "^0.1.6-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-tools": "^0.1.6-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-session-projection": "^0.1.6-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-scope": "^0.1.6-alpha.2",
|
|
61
|
+
"@deepseek-ai/dsh-ptc-runtime": "^0.1.6-alpha.2",
|
|
60
62
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/dsh-code-runtime": "^0.1.5-rc.2",
|
|
64
|
-
"@deepseek-ai/dsh-llm-deepseek": "^0.1.5-rc.2"
|
|
63
|
+
"@deepseek-ai/dsh-llm": "^0.1.6-alpha.2",
|
|
64
|
+
"@deepseek-ai/dsh-user-approval": "^0.1.6-alpha.2"
|
|
65
65
|
}
|
|
66
66
|
}
|