dsh-office-tools 0.1.0
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 +21 -0
- package/README.md +59 -0
- package/README.zh.md +59 -0
- package/cordis.patch.yml +6 -0
- package/dsh.plugin.json +21 -0
- package/lib/index.js +88724 -0
- package/lib/index.js.map +7 -0
- package/lib/types/index.d.ts +19 -0
- package/lib/types/paths.d.ts +56 -0
- package/lib/types/tools/excel.d.ts +8 -0
- package/lib/types/tools/ppt.d.ts +8 -0
- package/lib/types/tools/shared.d.ts +48 -0
- package/lib/types/tools/word.d.ts +6 -0
- package/package.json +106 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dsh-office-tools host plugin.
|
|
3
|
+
*
|
|
4
|
+
* Registers seven model-facing tools on `ctx.tools`:
|
|
5
|
+
*
|
|
6
|
+
* word_create / word_read
|
|
7
|
+
* excel_create / excel_read / excel_update
|
|
8
|
+
* ppt_create / ppt_read
|
|
9
|
+
*
|
|
10
|
+
* All file access is confined to the calling agent's session workspace and
|
|
11
|
+
* every registration is wrapped in `ctx.effect` so Cordis disposes the tools
|
|
12
|
+
* with the plugin fiber.
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
/** Plugin identity for cordis.yml rows. */
|
|
16
|
+
export declare const name = "dsh-office-tools";
|
|
17
|
+
/** The tool registry is the only runtime service this plugin requires. */
|
|
18
|
+
export declare const inject: string[];
|
|
19
|
+
export declare function apply(ctx: Context): void;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace-confined path resolution and durable-write helpers shared by all
|
|
3
|
+
* seven Office tools.
|
|
4
|
+
*
|
|
5
|
+
* Every tool binds to the CALLING agent's session cwd (the authoritative
|
|
6
|
+
* `session.header.cwd`) — the model never gets to pick a root. Relative paths
|
|
7
|
+
* resolve against that cwd, absolute paths are accepted only when they stay
|
|
8
|
+
* inside it, and a realpath check on the nearest existing ancestor closes the
|
|
9
|
+
* symlink escape hatch.
|
|
10
|
+
*/
|
|
11
|
+
import type { ToolRunContext } from '@deepseek-ai/dsh-tools';
|
|
12
|
+
/** Hard cap for reading an existing Office file into memory. */
|
|
13
|
+
export declare const MAX_OFFICE_FILE_BYTES: number;
|
|
14
|
+
/** Cap for text materialized into a single tool result. */
|
|
15
|
+
export declare const MAX_TEXT_CHARS = 200000;
|
|
16
|
+
/** Cap for worksheet cells materialized into a single tool result. */
|
|
17
|
+
export declare const MAX_READ_CELLS = 200000;
|
|
18
|
+
/** Cap for worksheet cells accepted by one create/update call. */
|
|
19
|
+
export declare const MAX_WRITE_CELLS = 200000;
|
|
20
|
+
export interface ResolvedOfficePath {
|
|
21
|
+
/** The path exactly as the model passed it. */
|
|
22
|
+
input: string;
|
|
23
|
+
/** Absolute path used for every fs operation. */
|
|
24
|
+
absolute: string;
|
|
25
|
+
/** Path rendered back to the model (workspace-relative when possible). */
|
|
26
|
+
display: string;
|
|
27
|
+
/** Lowercased extension including the leading dot. */
|
|
28
|
+
ext: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Resolve one model-supplied path to a workspace-confined absolute file path.
|
|
32
|
+
*
|
|
33
|
+
* @param exec - the running tool call (carries the session cwd + abort signal).
|
|
34
|
+
* @param rawPath - the model-supplied path string.
|
|
35
|
+
* @param allowedExts - acceptable lowercased extensions WITH dots (e.g. `.docx`).
|
|
36
|
+
* @param mustExist - when true, stat the file and reject directories.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveOfficePath(exec: ToolRunContext, rawPath: string, allowedExts: readonly string[], mustExist: boolean): Promise<ResolvedOfficePath>;
|
|
39
|
+
/**
|
|
40
|
+
* Read a bounded Office file into memory, observing tool-call cancellation.
|
|
41
|
+
*/
|
|
42
|
+
export declare function readOfficeBuffer(path: string, signal: AbortSignal): Promise<{
|
|
43
|
+
buffer: Buffer;
|
|
44
|
+
sizeBytes: number;
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* Write a buffer through a same-directory temp file + rename so a failed
|
|
48
|
+
* generation never leaves a half-written Office document behind.
|
|
49
|
+
*/
|
|
50
|
+
export declare function atomicWriteFile(path: string, buffer: Buffer): Promise<number>;
|
|
51
|
+
/**
|
|
52
|
+
* Reject an overwrite when `overwrite` is false and the target already exists.
|
|
53
|
+
* Callers use this BEFORE doing expensive generation so the model gets a fast
|
|
54
|
+
* refusal instead of wasted work.
|
|
55
|
+
*/
|
|
56
|
+
export declare function assertMayCreate(path: string, overwrite: boolean): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Excel (.xlsx) tools over SheetJS: `excel_create` writes a new workbook,
|
|
3
|
+
* `excel_read` materializes sheets as rows of scalar cells, and
|
|
4
|
+
* `excel_update` replaces/creates whole sheets and/or writes individual cell
|
|
5
|
+
* values into an existing workbook.
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
export declare function registerExcelTools(ctx: Context): () => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PowerPoint (.pptx) tools: `ppt_create` builds slide decks with pptxgenjs
|
|
3
|
+
* (text, bullets, speaker notes, and PNG/JPG/GIF images); `ppt_read` unzips a
|
|
4
|
+
* deck with JSZip and extracts paragraph text, speaker notes, and per-slide
|
|
5
|
+
* image counts without any native dependency.
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
8
|
+
export declare function registerPptTools(ctx: Context): () => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared schema fragments and cell types for the Office tool suite. Keeping
|
|
3
|
+
* the schemas in one place keeps the seven tool contracts consistent.
|
|
4
|
+
*/
|
|
5
|
+
/** One cell value accepted by the Excel tools. */
|
|
6
|
+
export declare const CELL_VALUE_SCHEMA: {
|
|
7
|
+
readonly oneOf: readonly [{
|
|
8
|
+
readonly type: "string";
|
|
9
|
+
}, {
|
|
10
|
+
readonly type: "number";
|
|
11
|
+
}, {
|
|
12
|
+
readonly type: "boolean";
|
|
13
|
+
}, {
|
|
14
|
+
readonly type: "null";
|
|
15
|
+
}];
|
|
16
|
+
};
|
|
17
|
+
/** One spreadsheet row. */
|
|
18
|
+
export declare const ROW_SCHEMA: {
|
|
19
|
+
readonly type: "array";
|
|
20
|
+
readonly items: {
|
|
21
|
+
readonly oneOf: readonly [{
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
}, {
|
|
24
|
+
readonly type: "number";
|
|
25
|
+
}, {
|
|
26
|
+
readonly type: "boolean";
|
|
27
|
+
}, {
|
|
28
|
+
readonly type: "null";
|
|
29
|
+
}];
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
/** Common success echo for a created/replaced file. */
|
|
33
|
+
export declare const FILE_RESULT_SCHEMA: {
|
|
34
|
+
readonly type: "object";
|
|
35
|
+
readonly additionalProperties: false;
|
|
36
|
+
readonly properties: {
|
|
37
|
+
readonly path: {
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly required: true;
|
|
40
|
+
};
|
|
41
|
+
readonly sizeBytes: {
|
|
42
|
+
readonly type: "integer";
|
|
43
|
+
readonly required: true;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type CellValue = string | number | boolean | null;
|
|
48
|
+
export type CellRow = CellValue[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Word (.docx) tools: `word_create` builds a styled document with the `docx`
|
|
3
|
+
* package; `word_read` extracts plain text with `mammoth`.
|
|
4
|
+
*/
|
|
5
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
6
|
+
export declare function registerWordTools(ctx: Context): () => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-office-tools",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "DSH model-facing Office tools: create, read, and update Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) files inside the session workspace.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "lib/index.js",
|
|
8
|
+
"types": "lib/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/types/index.d.ts",
|
|
12
|
+
"default": "./lib/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"dsh": {
|
|
17
|
+
"bundle": {
|
|
18
|
+
"patch": "./cordis.patch.yml"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"lib",
|
|
23
|
+
"cordis.patch.yml",
|
|
24
|
+
"dsh.plugin.json",
|
|
25
|
+
"README.md",
|
|
26
|
+
"README.zh.md",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "node build.mjs",
|
|
31
|
+
"typecheck": "tsc --noEmit",
|
|
32
|
+
"test": "vitest run",
|
|
33
|
+
"check": "pnpm run typecheck && pnpm run test && pnpm run build"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"docx": "^9.5.1",
|
|
37
|
+
"jszip": "^3.10.1",
|
|
38
|
+
"mammoth": "^1.11.0",
|
|
39
|
+
"pptxgenjs": "^4.0.1",
|
|
40
|
+
"xlsx": "^0.18.5"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
44
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
|
|
45
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
|
|
46
|
+
"@deepseek-ai/dsh-session": "^0.1.0-rc.6",
|
|
47
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6"
|
|
48
|
+
},
|
|
49
|
+
"peerDependenciesMeta": {
|
|
50
|
+
"@deepseek-ai/cordis": {
|
|
51
|
+
"optional": true
|
|
52
|
+
},
|
|
53
|
+
"@deepseek-ai/dsh-agent": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@deepseek-ai/dsh-llm": {
|
|
57
|
+
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"@deepseek-ai/dsh-session": {
|
|
60
|
+
"optional": true
|
|
61
|
+
},
|
|
62
|
+
"@deepseek-ai/dsh-tools": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
68
|
+
"@deepseek-ai/dsh-agent": "^0.1.0-rc.6",
|
|
69
|
+
"@deepseek-ai/dsh-llm": "^0.1.0-rc.6",
|
|
70
|
+
"@deepseek-ai/dsh-session": "^0.1.0-rc.6",
|
|
71
|
+
"@deepseek-ai/dsh-tools": "^0.1.0-rc.6",
|
|
72
|
+
"@types/node": "^24.0.0",
|
|
73
|
+
"esbuild": "^0.25.0",
|
|
74
|
+
"typescript": "^5.6.0",
|
|
75
|
+
"vitest": "^4.1.8"
|
|
76
|
+
},
|
|
77
|
+
"author": "kw78",
|
|
78
|
+
"homepage": "https://github.com/kw78/dsh-office-tools#readme",
|
|
79
|
+
"repository": {
|
|
80
|
+
"type": "git",
|
|
81
|
+
"url": "git+https://github.com/kw78/dsh-office-tools.git"
|
|
82
|
+
},
|
|
83
|
+
"bugs": {
|
|
84
|
+
"url": "https://github.com/kw78/dsh-office-tools/issues"
|
|
85
|
+
},
|
|
86
|
+
"keywords": [
|
|
87
|
+
"dsh",
|
|
88
|
+
"dsh-plugin",
|
|
89
|
+
"deepseek-harness",
|
|
90
|
+
"office",
|
|
91
|
+
"word",
|
|
92
|
+
"excel",
|
|
93
|
+
"powerpoint",
|
|
94
|
+
"docx",
|
|
95
|
+
"xlsx",
|
|
96
|
+
"pptx",
|
|
97
|
+
"tools"
|
|
98
|
+
],
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": ">=20"
|
|
101
|
+
},
|
|
102
|
+
"publishConfig": {
|
|
103
|
+
"access": "public"
|
|
104
|
+
},
|
|
105
|
+
"packageManager": "pnpm@11.7.0"
|
|
106
|
+
}
|