@sqdr2/dsh-fusion 0.3.0 → 0.3.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/dsh-fusion.js CHANGED
@@ -95,7 +95,7 @@ function recordedProcessId(value) {
95
95
  return typeof pid === "number" && Number.isSafeInteger(pid) && pid > 0 ? pid : void 0;
96
96
  }
97
97
  /** Durable state names that mean the row was still open when its process stopped. */
98
- const OPEN_EFFECT = new Set(["dispatch-started", "outcome-unknown"]);
98
+ const OPEN_EFFECT = /* @__PURE__ */ new Set(["dispatch-started", "outcome-unknown"]);
99
99
  /**
100
100
  * A row is unfinished when its own state says so. The families disagree on
101
101
  * where they record that, so each one is read through its own field and an
@@ -228,7 +228,7 @@ function addWrites(first, second) {
228
228
  };
229
229
  }
230
230
  requireThat$3(first.kind === "details" && second.kind === "details", "CACHE_LAYOUT_CONFLICT");
231
- const keys = [...new Set([...Object.keys(first.buckets), ...Object.keys(second.buckets)])].sort();
231
+ const keys = [.../* @__PURE__ */ new Set([...Object.keys(first.buckets), ...Object.keys(second.buckets)])].sort();
232
232
  return {
233
233
  kind: "details",
234
234
  buckets: Object.fromEntries(keys.map((key) => {
@@ -570,7 +570,7 @@ var FusionCatalogAdapter = class extends LlmAdapter {
570
570
  id: FUSION_MODEL,
571
571
  name: "Fusion · 自动",
572
572
  description: "Lead 与 Worker 协作。在设置 → Fusion 中配置模型。",
573
- inputModalities: [...new Set(["text", ...lead])]
573
+ inputModalities: [.../* @__PURE__ */ new Set(["text", ...lead])]
574
574
  }];
575
575
  }
576
576
  async resolveModel(provider, model) {
@@ -1036,7 +1036,8 @@ function cacheDefaults(provider, model) {
1036
1036
  source: "generic"
1037
1037
  };
1038
1038
  }
1039
- const MIN_INTERVAL = 60, MAX_INTERVAL = 3540;
1039
+ const MIN_INTERVAL = 60;
1040
+ const MAX_INTERVAL = 3540;
1040
1041
  /** A request reused its prefix when most of its input came from the cache. */
1041
1042
  const cacheHit = (cacheRead, input) => cacheRead > 0 && cacheRead / (cacheRead + input) >= .5;
1042
1043
  const key = (provider, model) => `${provider}\u0001${model}`;
@@ -1214,7 +1215,7 @@ function cacheView(policy, pair, pairChoice) {
1214
1215
  }
1215
1216
  //#endregion
1216
1217
  //#region src/profile/resolve.ts
1217
- const PLACEHOLDERS = new Set([
1218
+ const PLACEHOLDERS = /* @__PURE__ */ new Set([
1218
1219
  "__AUTHORIZED_PROVIDER__",
1219
1220
  "__EXACT_MODEL_ID__",
1220
1221
  "__EXACT_WORKER_ID__",
@@ -1634,20 +1635,20 @@ const ArtifactId = (raw) => asBrand(raw);
1634
1635
  const SnapshotId = (raw) => asBrand(raw);
1635
1636
  const EpochId = (raw) => asBrand(raw);
1636
1637
  const UsdDecimal = (raw) => raw;
1637
- const TERMINAL_PHASES = new Set([
1638
+ const TERMINAL_PHASES = /* @__PURE__ */ new Set([
1638
1639
  "COMPLETED",
1639
1640
  "CANCELLED",
1640
1641
  "FAILED"
1641
1642
  ]);
1642
1643
  //#endregion
1643
1644
  //#region src/review/protocol.ts
1644
- const VALID_DECISIONS = new Set([
1645
+ const VALID_DECISIONS = /* @__PURE__ */ new Set([
1645
1646
  "approve",
1646
1647
  "accept",
1647
1648
  "rework",
1648
1649
  "needs-decision"
1649
1650
  ]);
1650
- const SUCCESS_REASONS = new Set([
1651
+ const SUCCESS_REASONS = /* @__PURE__ */ new Set([
1651
1652
  "stop",
1652
1653
  "end_turn",
1653
1654
  "end-turn",
@@ -1656,24 +1657,24 @@ const SUCCESS_REASONS = new Set([
1656
1657
  "completed",
1657
1658
  "success"
1658
1659
  ]);
1659
- const TRUNCATED_REASONS = new Set([
1660
+ const TRUNCATED_REASONS = /* @__PURE__ */ new Set([
1660
1661
  "length",
1661
1662
  "max_tokens",
1662
1663
  "max_token"
1663
1664
  ]);
1664
- const ABORTED_REASONS = new Set([
1665
+ const ABORTED_REASONS = /* @__PURE__ */ new Set([
1665
1666
  "aborted",
1666
1667
  "abort",
1667
1668
  "cancelled",
1668
1669
  "canceled",
1669
1670
  "cancel"
1670
1671
  ]);
1671
- const ERROR_REASONS = new Set([
1672
+ const ERROR_REASONS = /* @__PURE__ */ new Set([
1672
1673
  "error",
1673
1674
  "internal_error",
1674
1675
  "server_error"
1675
1676
  ]);
1676
- const FILTERED_REASONS = new Set([
1677
+ const FILTERED_REASONS = /* @__PURE__ */ new Set([
1677
1678
  "content_filter",
1678
1679
  "content-filter",
1679
1680
  "filtered",
@@ -1928,7 +1929,7 @@ function assertCurrentSubject(state, ticket, actualSnapshot) {
1928
1929
  }
1929
1930
  //#endregion
1930
1931
  //#region src/task/reducer.ts
1931
- const WAITING = new Set([
1932
+ const WAITING = /* @__PURE__ */ new Set([
1932
1933
  "WAITING_APPROVAL",
1933
1934
  "WAITING_USER",
1934
1935
  "WAITING_BUDGET",
@@ -2398,7 +2399,7 @@ function applyBoundReviewResult(state, result, event) {
2398
2399
  function applyApprovalPending(state, event) {
2399
2400
  const next = need(state, event);
2400
2401
  const approval = event.payload.approval;
2401
- const pendingApprovalIds = [...new Set([...next.pendingApprovalIds, approval.id])];
2402
+ const pendingApprovalIds = [.../* @__PURE__ */ new Set([...next.pendingApprovalIds, approval.id])];
2402
2403
  return {
2403
2404
  ...waiting(next, "WAITING_APPROVAL"),
2404
2405
  pendingApprovalIds,
@@ -3477,7 +3478,7 @@ var WorkspaceWriteLease = class {
3477
3478
  const prior = this.#record(row, workspaceId);
3478
3479
  if (prior) throw new FusionError(LEASE_BUSY, `workspace is held by ${prior.holder}; reconcile before handoff`);
3479
3480
  if (row.generation === Number.MAX_SAFE_INTEGER) throw new FusionError(LEASE_GENERATION, "lease generation exhausted");
3480
- const refs = [...new Set([process.pid, ...input.liveProcessRefs ?? []])];
3481
+ const refs = [.../* @__PURE__ */ new Set([process.pid, ...input.liveProcessRefs ?? []])];
3481
3482
  if (refs.some((pid) => !Number.isSafeInteger(pid) || pid <= 0)) throw new FusionError(LEASE_BUSY, "invalid process reference");
3482
3483
  const record = {
3483
3484
  workspaceId,
@@ -3538,7 +3539,7 @@ var WorkspaceWriteLease = class {
3538
3539
  });
3539
3540
  const oldTemporary = leasePath(workspaceId, path.join(fs.existsSync("/tmp") ? "/tmp" : os.tmpdir(), "dsh-model-fusion-leases"));
3540
3541
  const oldDurable = leasePath(workspaceId, LEGACY_LEASE_ROOT);
3541
- for (const lock of new Set([
3542
+ for (const lock of /* @__PURE__ */ new Set([
3542
3543
  legacy,
3543
3544
  oldDurable,
3544
3545
  oldTemporary
@@ -4036,7 +4037,7 @@ function changedPaths(before, after) {
4036
4037
  if (before.root !== after.root) throw new Error("Workspace root changed");
4037
4038
  const old = new Map(before.entries.map((entry) => [entry.path, digestOf(entry)]));
4038
4039
  const now = new Map(after.entries.map((entry) => [entry.path, digestOf(entry)]));
4039
- return [...new Set([...old.keys(), ...now.keys()])].filter((path) => old.get(path) !== now.get(path)).sort();
4040
+ return [.../* @__PURE__ */ new Set([...old.keys(), ...now.keys()])].filter((path) => old.get(path) !== now.get(path)).sort();
4040
4041
  }
4041
4042
  /**
4042
4043
  * Workspace-relative allowlist check. `/` always separates segments; `\` is a
@@ -4340,7 +4341,7 @@ function record(value) {
4340
4341
  return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
4341
4342
  }
4342
4343
  const execFileAsync = promisify(execFile);
4343
- const WRAPPERS = new Set([
4344
+ const WRAPPERS = /* @__PURE__ */ new Set([
4344
4345
  "env",
4345
4346
  "exec",
4346
4347
  "time",
@@ -4365,7 +4366,7 @@ const WRAPPER_VALUE_OPTIONS = {
4365
4366
  "--output"
4366
4367
  ]
4367
4368
  };
4368
- const PWSH_KEYWORDS = new Set([
4369
+ const PWSH_KEYWORDS = /* @__PURE__ */ new Set([
4369
4370
  "exit",
4370
4371
  "return",
4371
4372
  "throw",
@@ -7717,7 +7718,7 @@ var NativeWorkerTransport = class {
7717
7718
  //#endregion
7718
7719
  //#region src/host/native-activity.ts
7719
7720
  const prefix = "activity-link:";
7720
- const visibleTools = new Set([
7721
+ const visibleTools = /* @__PURE__ */ new Set([
7721
7722
  "bash",
7722
7723
  "pwsh",
7723
7724
  "read",
@@ -8326,7 +8327,7 @@ const optionalStringList = {
8326
8327
  type: "array",
8327
8328
  items: { type: "string" }
8328
8329
  };
8329
- const READ_TOOLS = new Set([
8330
+ const READ_TOOLS = /* @__PURE__ */ new Set([
8330
8331
  "fusion_read_state",
8331
8332
  "glob",
8332
8333
  "grep",
@@ -8335,7 +8336,7 @@ const READ_TOOLS = new Set([
8335
8336
  "job_output"
8336
8337
  ]);
8337
8338
  const isRead = (exec) => READ_TOOLS.has(exec.name) || exec.name === "str_replace_editor" && exec.arguments.command === "view";
8338
- const FUSION_TOOLS = new Set([
8339
+ const FUSION_TOOLS = /* @__PURE__ */ new Set([
8339
8340
  "fusion_read_state",
8340
8341
  "fusion_delegate_text",
8341
8342
  "fusion_explore",
@@ -8348,7 +8349,7 @@ const FUSION_TOOLS = new Set([
8348
8349
  "fusion_finish_direct",
8349
8350
  "fusion_read_evidence"
8350
8351
  ]);
8351
- const WORKER_FUSION_TOOLS = new Set([
8352
+ const WORKER_FUSION_TOOLS = /* @__PURE__ */ new Set([
8352
8353
  "fusion_submit_result",
8353
8354
  "fusion_read_state",
8354
8355
  "fusion_read_evidence"
@@ -8410,7 +8411,7 @@ const normalizeQuote = (text) => text.replace(/\s+/g, " ").trim();
8410
8411
  /** Literal code spans (`like this`) a requirement asks for; a candidate that omits them gets flagged. */
8411
8412
  const literalSpans = (text) => [...new Set([...text.matchAll(/`([^`\n]{2,120})`/g)].map((match) => match[1]))];
8412
8413
  /** The enforced-v3 Lead's fixed catalog (order is part of the cached prompt prefix). */
8413
- const SEPARATED_LEAD_TOOLS = [...new Set([
8414
+ const SEPARATED_LEAD_TOOLS = [.../* @__PURE__ */ new Set([
8414
8415
  ...READ_TOOLS,
8415
8416
  nativeShellTool,
8416
8417
  ...[...FUSION_TOOLS].filter((name) => ![
@@ -9858,7 +9859,7 @@ var FusionCoordinator = class {
9858
9859
  ...known,
9859
9860
  ...extra.contents
9860
9861
  },
9861
- unavailable: [...new Set([...changeBase.unavailable ?? [], ...extra.unavailable ?? []])]
9862
+ unavailable: [.../* @__PURE__ */ new Set([...changeBase.unavailable ?? [], ...extra.unavailable ?? []])]
9862
9863
  };
9863
9864
  }
9864
9865
  this.store.writeDocument(`scope-expansion:${binding.taskId}:${randomUUID()}`, 0, {
@@ -10965,7 +10966,7 @@ var FusionCoordinator = class {
10965
10966
  //#endregion
10966
10967
  //#region src/host/native-budget.ts
10967
10968
  function nativeAuthorization(raw) {
10968
- const keys = new Set([
10969
+ const keys = /* @__PURE__ */ new Set([
10969
10970
  "schemaVersion",
10970
10971
  "kind",
10971
10972
  "approved",
@@ -12286,8 +12287,9 @@ async function apply(ctx, config = {}) {
12286
12287
  if (runtime) return Promise.resolve(runtime);
12287
12288
  if (creating) return creating;
12288
12289
  creating = (async () => {
12290
+ const profile = frozen ?? await configuredProfile();
12289
12291
  runtime = new FusionCoordinator(ctx, store, {
12290
- profile: frozen ?? await configuredProfile(),
12292
+ profile,
12291
12293
  workerTools: config.workerTools ?? defaultWorkerTools,
12292
12294
  resumeAuthorization: (binding) => needsBudget(binding.profile) ? budget.check(effectiveRoutes(binding)).authorizationId : "native-account",
12293
12295
  authorizeRequest: (_agent, binding) => {
@@ -12533,7 +12535,8 @@ async function apply(ctx, config = {}) {
12533
12535
  if (!Number.isSafeInteger(body.revision) || Number(body.revision) < 0) throw new Error(bi("配置版本无效,请刷新后重试", "Invalid settings revision; refresh and retry"));
12534
12536
  const pair = validatePairChoice(body.pair, await physicalCatalog());
12535
12537
  const revision = store.writeDocument("settings:profile", Number(body.revision), modelProfileFromChoice(pair));
12536
- await getRuntime(await configuredProfile());
12538
+ const profile = await configuredProfile();
12539
+ await getRuntime(profile);
12537
12540
  return json(res, 200, {
12538
12541
  ok: true,
12539
12542
  revision
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sqdr2/dsh-fusion",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -30,6 +30,8 @@
30
30
  "README.en.md",
31
31
  "INSTALL.md",
32
32
  "INSTALL.zh.md",
33
+ "RELEASING.md",
34
+ "RELEASING.zh.md",
33
35
  "LICENSE",
34
36
  "docs/COMPATIBILITY.md",
35
37
  "docs/EVIDENCE.md"