@gilbertgt/dsh-plan-orchestrator 1.0.2 → 1.0.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.
Files changed (2) hide show
  1. package/lib/index.js +29 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -2598,6 +2598,34 @@ const OWNERSHIP_SAFE_MUTATION_TOOLS = [
2598
2598
  "apply_patch",
2599
2599
  "patch"
2600
2600
  ];
2601
+ function errorMessage(error) {
2602
+ return error instanceof Error ? error.message : String(error);
2603
+ }
2604
+ /**
2605
+ * Resolve the conservative ownership-safe policy against the host's actual
2606
+ * global tool catalog. DSH rejects unknown names in tools.restrict(), so aliases
2607
+ * that are not registered in the active profile must never reach toolFilter.
2608
+ */
2609
+ function resolveOwnershipSafeToolAllow(ctx) {
2610
+ const schemas = ctx?.tools?.schemas;
2611
+ if (typeof schemas !== "function") throw new Error("tools.schemas unavailable for ownership-safe tool filtering");
2612
+ let catalog;
2613
+ try {
2614
+ catalog = schemas.call(ctx.tools);
2615
+ } catch (error) {
2616
+ throw new Error(`tools.schemas failed for ownership-safe tool filtering: ${errorMessage(error)}`);
2617
+ }
2618
+ if (!Array.isArray(catalog)) throw new Error("tools.schemas returned an invalid catalog for ownership-safe tool filtering");
2619
+ const registered = /* @__PURE__ */ new Set();
2620
+ for (const schema of catalog) {
2621
+ if (!schema || typeof schema !== "object" || Array.isArray(schema)) continue;
2622
+ const name = schema.name;
2623
+ if (typeof name === "string" && name.length > 0) registered.add(name);
2624
+ }
2625
+ const allow = OWNERSHIP_SAFE_MUTATION_TOOLS.filter((name) => registered.has(name));
2626
+ if (allow.length === 0) throw new Error("no ownership-safe global tools are registered in the active DSH profile");
2627
+ return [...allow];
2628
+ }
2601
2629
  var NativeSpawnBackend = class {
2602
2630
  ctx;
2603
2631
  constructor(ctx) {
@@ -2610,7 +2638,7 @@ var NativeSpawnBackend = class {
2610
2638
  try {
2611
2639
  const cwd = req.parent?.session?.header?.cwd;
2612
2640
  const signal = req.ownership ? withRoleTimeout(cwd, req.signal) : req.signal;
2613
- const toolFilter = req.ownership ? { allow: OWNERSHIP_SAFE_MUTATION_TOOLS } : req.toolFilter;
2641
+ const toolFilter = req.ownership ? { allow: resolveOwnershipSafeToolAllow(this.ctx) } : req.toolFilter;
2614
2642
  run = await this.ctx.subagents.start("spawn", {
2615
2643
  label: `${req.role}:${req.taskId}`,
2616
2644
  prompt: [{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gilbertgt/dsh-plan-orchestrator",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Product-grade orchestration layer for DeepSeek Harness native Plan Mode",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",