@civilization/dsh-drawio 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +10 -6
- package/src/index.js +21 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@civilization/dsh-drawio",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Local draw.io canvas and model tools for DeepSeek Harness",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -55,11 +55,15 @@
|
|
|
55
55
|
"pako": "2.1.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@deepseek-ai/cordis": "
|
|
59
|
-
"@deepseek-ai/dsh-fs": "
|
|
60
|
-
"@deepseek-ai/dsh-host-webserver": "
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
|
|
58
|
+
"@deepseek-ai/cordis": ">=4.0.0 <5.0.0-0",
|
|
59
|
+
"@deepseek-ai/dsh-fs": ">=0.1.2-rc.1 <0.2.0-0",
|
|
60
|
+
"@deepseek-ai/dsh-host-webserver": ">=0.1.2-rc.1 <0.2.0-0",
|
|
61
|
+
"@deepseek-ai/dsh-tools": ">=0.1.2-rc.1 <0.2.0-0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependenciesMeta": {
|
|
64
|
+
"@deepseek-ai/dsh-sandbox": {
|
|
65
|
+
"optional": true
|
|
66
|
+
}
|
|
63
67
|
},
|
|
64
68
|
"devDependencies": {
|
|
65
69
|
"@deepseek-ai/cordis": "4.0.2",
|
package/src/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
|
6
6
|
import { editDrawio, inspectDrawio, normalizeDrawio } from './xml.js'
|
|
7
7
|
|
|
8
8
|
export const name = 'dsh-drawio'
|
|
9
|
-
export const inject = ['tools', 'fs', '
|
|
9
|
+
export const inject = ['tools', 'fs', 'webServer']
|
|
10
10
|
|
|
11
11
|
const runtimeRoot = fileURLToPath(new URL('../vendor/drawio/', import.meta.url))
|
|
12
12
|
const MAX_DIAGRAM_BYTES = 10 * 1024 * 1024
|
|
@@ -54,7 +54,8 @@ export function apply(ctx) {
|
|
|
54
54
|
async execute(args, exec) {
|
|
55
55
|
const { text, target } = await readDiagram(ctx, args.path, exec)
|
|
56
56
|
const xml = editDrawio(text, args.operations, args.page)
|
|
57
|
-
const
|
|
57
|
+
const policy = await resolvePolicy(ctx, 'drawio_edit', args, exec)
|
|
58
|
+
const outcome = await writeDiagram(ctx, target, xml, args, exec, policy)
|
|
58
59
|
return { path: target.displayPath, operation: outcome.operation, operationsApplied: args.operations.length, ...inspectDrawio(xml, false) }
|
|
59
60
|
},
|
|
60
61
|
}))
|
|
@@ -65,7 +66,7 @@ export function apply(ctx) {
|
|
|
65
66
|
output,
|
|
66
67
|
async execute(args, exec) {
|
|
67
68
|
assertDrawioPath(args.path)
|
|
68
|
-
const policy = await
|
|
69
|
+
const policy = await resolvePolicy(ctx, 'drawio_write', args, exec)
|
|
69
70
|
const target = await ctx.fs.resolve(args.path, resolveOptions(exec, args.path, policy?.workspaceRoot))
|
|
70
71
|
const xml = normalizeDrawio(args.xml)
|
|
71
72
|
const outcome = await writeDiagram(ctx, target, xml, args, exec, policy)
|
|
@@ -150,8 +151,24 @@ async function readDiagram(ctx, requestedPath, exec) {
|
|
|
150
151
|
return { target, text }
|
|
151
152
|
}
|
|
152
153
|
|
|
154
|
+
async function resolvePolicy(ctx, toolName, args, exec) {
|
|
155
|
+
const sandbox = ctx.get?.('sandbox')
|
|
156
|
+
if (sandbox?.resolvePolicy) {
|
|
157
|
+
try {
|
|
158
|
+
return await sandbox.resolvePolicy(toolName, args, exec)
|
|
159
|
+
} catch {}
|
|
160
|
+
}
|
|
161
|
+
const policyService = ctx.get?.('sandboxPolicy')
|
|
162
|
+
if (policyService?.resolve) {
|
|
163
|
+
try {
|
|
164
|
+
return policyService.resolve({ ...(exec?.agent ? { session: exec.agent.session } : {}) })
|
|
165
|
+
} catch {}
|
|
166
|
+
}
|
|
167
|
+
return undefined
|
|
168
|
+
}
|
|
169
|
+
|
|
153
170
|
async function writeDiagram(ctx, target, xml, args, exec, resolvedPolicy) {
|
|
154
|
-
const policy = resolvedPolicy ?? await
|
|
171
|
+
const policy = resolvedPolicy ?? await resolvePolicy(ctx, 'write', args, exec)
|
|
155
172
|
const intent = await ctx.waterfall('fs/write-intent', target, exec, () => undefined)
|
|
156
173
|
const outcome = await ctx.fs.writeText(target, xml, intent, exec.signal, policy)
|
|
157
174
|
ctx.emit('fs/observed', target, { kind: 'present', version: outcome.version }, exec)
|