dsh-openwrite 0.2.17 → 0.2.19

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.
@@ -3,7 +3,7 @@
3
3
  "dsh": "0.1.2-rc.1",
4
4
  "uv_version": "0.11.19",
5
5
  "python_version": "3.12.13",
6
- "core_version": "5.8.8",
6
+ "core_version": "5.8.9",
7
7
  "contract_version": 1,
8
8
  "platforms": {
9
9
  "darwin-arm64": {
@@ -56,8 +56,8 @@
56
56
  }
57
57
  },
58
58
  "wheel": {
59
- "file": "openwrite-5.8.8-py3-none-any.whl",
60
- "sha256": "9a3f68af9a0f41d2477d5acecb48ac0067b1e9ed7df419234ae26c0fbe1ca58e"
59
+ "file": "openwrite-5.8.9-py3-none-any.whl",
60
+ "sha256": "9526a78dde66a81a0eb7dedc1454c8dd436e42d966b5b043d13c24e263104341"
61
61
  },
62
62
  "requirements": {
63
63
  "file": "requirements.lock",
@@ -67,12 +67,15 @@
67
67
  "core": {
68
68
  "repository": "https://github.com/LiPu-jpg/Openwrite",
69
69
  "branch": "native-core",
70
- "commit": "a7f4d8769de7496cb18b9d6dc38872c60fa5517a"
70
+ "commit": "d0a75e30047c28c99af909e1b85b07190abb1fb7"
71
71
  },
72
72
  "dog": {
73
73
  "repository": "https://github.com/Fun10165/dsh-dog",
74
74
  "tag": "v1.2.0",
75
- "commit": "3a442ef4b1a82cc4258a01baf798913c94a99445"
75
+ "commit": "3a442ef4b1a82cc4258a01baf798913c94a99445",
76
+ "patches": [
77
+ "0.2.19: src/host-shims.ts 内置 dshHomePath/defineTool,移除 @deepseek-ai/dsh-home-paths 与 @deepseek-ai/dsh-tools 的运行时导入(#74)"
78
+ ]
76
79
  },
77
80
  "cryptography": {
78
81
  "package": "cryptography",
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "repository": "https://github.com/LiPu-jpg/Openwrite",
3
- "commit": "de2cacb91aa5d530db6d9f8f4dc80afa905bfeb2",
4
- "tree": "9d402deae8f9b3f9b80901c8e5c85cba2bf8f75e",
3
+ "commit": "e0c1ab7998eb3b33738827d5a8f12dd3bb2e9224",
4
+ "tree": "108c492a309f5c0b46bf59deefb8615f0c2efb66",
5
5
  "dirty": false,
6
6
  "acquisition": "git-checkout",
7
- "sourceTreeSha256": "0157201c7a889ffb27f147c8aebced7df521890714a4ea564bc4fd6e99415e35",
7
+ "sourceTreeSha256": "5d5b731c6afdf6ddae188a906382a6c2030f76561f81d3c02bb1d982cbb75a31",
8
8
  "components": [
9
9
  {
10
10
  "name": "@deepseek-ai/schemastery",
@@ -1,2 +1,2 @@
1
- import { n as resolveScriptPath, t as DogEngine } from "./core-DdfMcrB4.js";
1
+ import { n as resolveScriptPath, t as DogEngine } from "./core-BAlgZpLq.js";
2
2
  export { DogEngine, resolveScriptPath };
@@ -1,7 +1,7 @@
1
1
  import { $ as VerifierShape, A as FailurePolicy, B as GoalRuntimeTrace, C as ConstraintKind, D as DogConfig, E as DependencyEdge, F as GoalNodeInput, G as JsonPrimitive, H as GoalState, I as GoalResult, J as NotExpr, K as JsonValue, L as GoalRuntimeError, M as GoalAgentSessionRef, N as GoalId, O as DogGraphInput, P as GoalKind, Q as VerificationRecord, R as GoalRuntimeEvent, S as CompiledGraph, T as DOG_SCHEMA_VERSION, U as GraphLimits, V as GoalRuntimeVerifier, W as GraphValidationReport, X as RootTerminalState, Y as RefExpr, Z as RunInvocationContext, _ as AtLeastExpr, b as CiGoalReport, c as AgenticRunner, d as runPlan, et as isJsonValue, f as DogRepository, g as AnyExpr, h as AllExpr, j as GoalAgentRole, k as DogRun, l as ProgrammaticRunner, m as AcceptancePlan, p as loadSchemaSet, q as JudgmentIdentity, r as DogEngine, s as WorkspaceManager, u as Verdict, v as BoolExpr, w as ContainsEdge, x as CiReport, y as CapturedInput, z as GoalRuntimePhase } from "./core-BiEBMLz3.js";
2
2
  import z from "@deepseek-ai/schemastery";
3
- import { ToolDefinition } from "@deepseek-ai/dsh-tools";
4
3
  import { Agent } from "@deepseek-ai/dsh-agent";
4
+ import { ToolDefinition } from "@deepseek-ai/dsh-tools";
5
5
  import { Context } from "@deepseek-ai/cordis";
6
6
  import { ConnectionRpcHandler } from "@deepseek-ai/dsh-client-connection";
7
7
  import { SessionId } from "@deepseek-ai/dsh-session";
@@ -1,11 +1,10 @@
1
- import { a as DogRepository, c as parseGraph, d as parseBoolExpr, i as runPlan, l as isJsonValue, n as resolveScriptPath, o as loadSchemaSet, r as WorkspaceManager, s as DogValidationError, t as DogEngine, u as evaluateBoolExpr } from "./core-DdfMcrB4.js";
1
+ import { a as DogRepository, c as parseGraph, d as parseBoolExpr, i as runPlan, l as isJsonValue, n as resolveScriptPath, o as loadSchemaSet, r as WorkspaceManager, s as DogValidationError, t as DogEngine, u as evaluateBoolExpr } from "./core-BAlgZpLq.js";
2
2
  import { spawn } from "node:child_process";
3
3
  import { fileURLToPath } from "node:url";
4
- import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
4
+ import { homedir } from "node:os";
5
+ import { isAbsolute, join, resolve } from "node:path";
5
6
  import { mkdir, readFile, writeFile } from "node:fs/promises";
6
- import { isAbsolute, join } from "node:path";
7
7
  import z from "@deepseek-ai/schemastery";
8
- import { defineTool } from "@deepseek-ai/dsh-tools";
9
8
  //#region src/owned-script.ts
10
9
  /** Execute without blocking the host event loop; cancellation owns only this process tree. */
11
10
  async function runOwnedScript(script, input, signal) {
@@ -79,6 +78,205 @@ async function runOwnedScript(script, input, signal) {
79
78
  }
80
79
  }
81
80
  //#endregion
81
+ //#region src/host-shims.ts
82
+ /**
83
+ * Self-contained replacements for the two host packages this plugin used to
84
+ * import at runtime: `@deepseek-ai/dsh-home-paths` (`dshHomePath`) and
85
+ * `@deepseek-ai/dsh-tools` (`defineTool`). Both were declared as
86
+ * peerDependencies, and under the DSH profile install layout (pnpm isolated
87
+ * node_modules) peer instances are not resolvable from this vendored
88
+ * directory, so every entry import failed with ERR_MODULE_NOT_FOUND and the
89
+ * plugin never activated (GitHub issue #74). The implementations below match
90
+ * the host behavior for the schema subset this plugin declares; type-only
91
+ * imports from the host packages are still used and erased at build time.
92
+ */
93
+ /** Directory name for the default DeepSeek Harness home under the OS home. */
94
+ const DSH_HOME_DIR_NAME = ".dsh";
95
+ /** Environment variable that overrides the default DeepSeek Harness home. */
96
+ const DSH_HOME_ENV = "DSH_HOME";
97
+ /** Expand supported tilde prefixes against the operating-system home. */
98
+ function expandHomePath(path) {
99
+ if (path === "~") return homedir();
100
+ if (path.startsWith("~/") || path.startsWith("~\\")) return join(homedir(), path.slice(2));
101
+ return path;
102
+ }
103
+ /**
104
+ * Resolve the single-root DeepSeek Harness home: `$DSH_HOME` when set to a
105
+ * non-blank value, otherwise `~/.dsh`. Mirrors the host `resolveDshHome`.
106
+ */
107
+ function resolveDshHome() {
108
+ const fromEnv = process.env[DSH_HOME_ENV];
109
+ return resolve(expandHomePath(fromEnv !== void 0 && fromEnv.trim().length > 0 ? fromEnv : join(homedir(), DSH_HOME_DIR_NAME)));
110
+ }
111
+ /** Join path segments onto the resolved DeepSeek Harness home. */
112
+ function dshHomePath(...segments) {
113
+ return join(resolveDshHome(), ...segments);
114
+ }
115
+ /** Thrown when model-generated arguments violate the compiled schema. */
116
+ var ToolArgsError = class extends Error {
117
+ violations;
118
+ constructor(violations) {
119
+ super(`invalid arguments: ${violations.join("; ")}`);
120
+ this.name = "ToolArgsError";
121
+ this.violations = violations;
122
+ }
123
+ };
124
+ /** Compile one author-facing value schema node to raw JSON Schema. */
125
+ function compileValueSchema(spec, path) {
126
+ if (spec === null || typeof spec !== "object") throw new Error(`${path}: schema node must be an object`);
127
+ const node = {};
128
+ if (spec.description !== void 0) node.description = spec.description;
129
+ switch (spec.type) {
130
+ case "json": return node;
131
+ case "string":
132
+ case "number":
133
+ case "integer":
134
+ case "boolean":
135
+ case "null":
136
+ node.type = spec.type;
137
+ if ("enum" in spec && spec.enum !== void 0) node.enum = [...spec.enum];
138
+ if ("const" in spec && spec.const !== void 0) node.const = spec.const;
139
+ return node;
140
+ case "array":
141
+ node.type = "array";
142
+ if (spec.items !== void 0) node.items = compileValueSchema(spec.items, `${path}.items`);
143
+ return node;
144
+ case "object":
145
+ node.type = "object";
146
+ if (spec.additionalProperties !== void 0) node.additionalProperties = spec.additionalProperties;
147
+ if (spec.properties !== void 0) {
148
+ const { properties, required } = compilePropertyMap(spec.properties, `${path}.properties`);
149
+ node.properties = properties;
150
+ if (required.length > 0) node.required = required;
151
+ }
152
+ return node;
153
+ default: throw new Error(`${path}.type must be string/number/integer/boolean/null/array/object/json`);
154
+ }
155
+ }
156
+ /** Compile a property map, hoisting per-property `required` flags onto the parent. */
157
+ function compilePropertyMap(input, path) {
158
+ const properties = {};
159
+ const required = [];
160
+ for (const [key, property] of Object.entries(input)) {
161
+ const { required: isRequired, ...spec } = property;
162
+ properties[key] = compileValueSchema(spec, `${path}.${key}`);
163
+ if (isRequired === true) required.push(key);
164
+ }
165
+ return {
166
+ properties,
167
+ required
168
+ };
169
+ }
170
+ /** Compile the implicit open parameter object into raw JSON Schema. */
171
+ function compileParameters(spec) {
172
+ const { properties, required } = compilePropertyMap(spec, "parameters");
173
+ const schema = {
174
+ type: "object",
175
+ properties
176
+ };
177
+ if (required.length > 0) schema.required = required;
178
+ return schema;
179
+ }
180
+ /** Validate one JSON value against the compiled subset, collecting violations. */
181
+ function validateValue(schema, value, path, violations) {
182
+ const at = path === "" ? "arguments" : path;
183
+ if (schema.const !== void 0 && value !== schema.const) {
184
+ violations.push(`${at}: must equal ${JSON.stringify(schema.const)}`);
185
+ return;
186
+ }
187
+ if (Array.isArray(schema.enum) && !schema.enum.some((entry) => entry === value)) {
188
+ violations.push(`${at}: must be one of ${JSON.stringify(schema.enum)}`);
189
+ return;
190
+ }
191
+ switch (schema.type) {
192
+ case void 0: return;
193
+ case "null":
194
+ if (value !== null) violations.push(`${at}: expected null`);
195
+ return;
196
+ case "boolean":
197
+ if (typeof value !== "boolean") violations.push(`${at}: expected boolean, got ${describe(value)}`);
198
+ return;
199
+ case "string":
200
+ if (typeof value !== "string") violations.push(`${at}: expected string, got ${describe(value)}`);
201
+ return;
202
+ case "number":
203
+ if (typeof value !== "number" || !Number.isFinite(value)) violations.push(`${at}: expected number, got ${describe(value)}`);
204
+ return;
205
+ case "integer":
206
+ if (typeof value !== "number" || !Number.isInteger(value)) violations.push(`${at}: expected integer, got ${describe(value)}`);
207
+ return;
208
+ case "array": {
209
+ if (!Array.isArray(value)) {
210
+ violations.push(`${at}: expected array, got ${describe(value)}`);
211
+ return;
212
+ }
213
+ const items = schema.items;
214
+ if (items !== void 0) value.forEach((item, index) => validateValue(items, item, `${at}[${index}]`, violations));
215
+ return;
216
+ }
217
+ case "object": {
218
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
219
+ violations.push(`${at}: expected object, got ${describe(value)}`);
220
+ return;
221
+ }
222
+ const record = value;
223
+ for (const key of schema.required ?? []) if (!Object.hasOwn(record, key)) violations.push(`${at}: missing required property "${key}"`);
224
+ const properties = schema.properties;
225
+ if (properties !== void 0) {
226
+ for (const [key, propertySchema] of Object.entries(properties)) if (Object.hasOwn(record, key)) validateValue(propertySchema, record[key], `${at}.${key}`, violations);
227
+ }
228
+ return;
229
+ }
230
+ }
231
+ }
232
+ function describe(value) {
233
+ if (value === null) return "null";
234
+ if (Array.isArray(value)) return "array";
235
+ return typeof value;
236
+ }
237
+ /** Validate model-generated arguments against the compiled parameter schema. */
238
+ function validateArgs(parameters, args) {
239
+ const violations = [];
240
+ validateValue(parameters, args, "", violations);
241
+ return violations;
242
+ }
243
+ /**
244
+ * Define a first-party tool with strict execution validation, matching the
245
+ * host `defineTool` contract: arguments are validated before `execute`, and
246
+ * replay presenters validate softly and fall back to generic rendering.
247
+ */
248
+ function defineTool(options) {
249
+ const userExecute = options.execute;
250
+ const userRender = options.output.render;
251
+ const userPresentationMeta = options.output.presentationMeta;
252
+ const userIsConcurrencySafe = options.isConcurrencySafe;
253
+ if (options.timeoutMs !== void 0 && (!Number.isFinite(options.timeoutMs) || options.timeoutMs <= 0)) throw new Error(`defineTool(${options.name}): timeoutMs must be a positive finite number`);
254
+ const parameters = compileParameters(options.parameters);
255
+ const outputSchema = compileValueSchema(options.output.schema, "schema");
256
+ const validate = (args) => validateArgs(parameters, args);
257
+ const tool = {
258
+ name: options.name,
259
+ description: options.description,
260
+ parameters,
261
+ output: {
262
+ schema: outputSchema,
263
+ render: (args, value) => userRender(args, value),
264
+ ...userPresentationMeta !== void 0 ? { presentationMeta: (args, value) => userPresentationMeta(args, value) } : {}
265
+ },
266
+ ...options.timeoutMs !== void 0 ? { timeoutMs: options.timeoutMs } : {},
267
+ async execute(args, exec) {
268
+ const violations = validate(args);
269
+ if (violations.length > 0) throw new ToolArgsError(violations);
270
+ return userExecute(args, exec);
271
+ }
272
+ };
273
+ if (userIsConcurrencySafe) tool.isConcurrencySafe = (args) => {
274
+ if (validate(args).length > 0) return false;
275
+ return userIsConcurrencySafe(args);
276
+ };
277
+ return tool;
278
+ }
279
+ //#endregion
82
280
  //#region src/debug-contract.ts
83
281
  const DOG_DEBUG_RPC_CHANNEL = "/dog-rpc";
84
282
  const DOG_DEBUG_SNAPSHOT_ENDPOINT = "snapshot";
@@ -1,12 +1,12 @@
1
1
  import { fileURLToPath } from "node:url";
2
- import { appendFile, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
2
+ import { tmpdir } from "node:os";
3
3
  import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
+ import { appendFile, lstat, mkdir, mkdtemp, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
4
5
  import { createHash, randomUUID } from "node:crypto";
5
6
  import { existsSync, readFileSync, readdirSync } from "node:fs";
6
7
  import { c } from "tar";
7
8
  import Ajv2020 from "ajv/dist/2020.js";
8
9
  import addFormats from "ajv-formats";
9
- import { tmpdir } from "node:os";
10
10
  //#region src/logic.ts
11
11
  /**
12
12
  * Parse and type-check the only expression language accepted by DoG.