@michengai/dsh-automation 0.1.11 → 0.1.12

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.
@@ -13,7 +13,7 @@
13
13
  - 每次到期都创建全新 root Agent 和 Session,不继承来源对话。
14
14
  - 规则、修订号和运行历史持久化。
15
15
  - 同一条规则同时最多一个 active run;超时、重叠和 Host 中断都有明确终态。
16
- - 默认只读;可显式选择 `workspace-write`。禁止无人值守 `danger-full-access`。
16
+ - 权限预设与 Chat 保持一致,完整使用 Host 提供的列表与默认值;切换到 `danger-full-access` 时显示同款风险确认。
17
17
 
18
18
  ## 稳定边界
19
19
 
package/lib/client.js CHANGED
@@ -405,6 +405,11 @@ function permissionLabel(option, t) {
405
405
  return option.name || option.value;
406
406
  }
407
407
 
408
+ // src/client/create-modal-logic.ts
409
+ function shouldConfirmFullAccess(current, next) {
410
+ return current !== next && next === "danger-full-access";
411
+ }
412
+
408
413
  // src/client/menu.tsx
409
414
  var import_react = require("react");
410
415
  var import_react_dom = require("react-dom");
@@ -635,13 +640,29 @@ function CreateModal({
635
640
  }) {
636
641
  const [form, setForm] = (0, import_react2.useState)(() => ({ ...defaultFormState(/* @__PURE__ */ new Date(), workspaces, defaultModel, defaultPermission), ...draft }));
637
642
  const [validationError, setValidationError] = (0, import_react2.useState)();
643
+ const [confirmingPermission, setConfirmingPermission] = (0, import_react2.useState)();
644
+ const [fullAccessAcknowledged, setFullAccessAcknowledged] = (0, import_react2.useState)(false);
638
645
  const update = (patch) => {
639
646
  setForm((current) => ({ ...current, ...patch }));
640
647
  setValidationError(void 0);
641
648
  };
642
649
  const choosePermission = (permission) => {
650
+ if (shouldConfirmFullAccess(form.permission, permission)) {
651
+ setFullAccessAcknowledged(false);
652
+ setConfirmingPermission(permission);
653
+ return;
654
+ }
643
655
  update({ permission });
644
656
  };
657
+ const cancelFullAccessConfirmation = () => {
658
+ setFullAccessAcknowledged(false);
659
+ setConfirmingPermission(void 0);
660
+ };
661
+ const confirmFullAccess = () => {
662
+ if (!fullAccessAcknowledged || confirmingPermission === void 0) return;
663
+ update({ permission: confirmingPermission });
664
+ cancelFullAccessConfirmation();
665
+ };
645
666
  (0, import_react2.useEffect)(() => {
646
667
  const onKey = (event) => {
647
668
  if (event.key !== "Escape") return;
@@ -837,7 +858,22 @@ function CreateModal({
837
858
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "submit", className: "dsh-st-btn dsh-st-btn--primary", disabled: busy, children: t("modal.save") })
838
859
  ] })
839
860
  ] }),
840
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-st-flyout-root", ref: setMenuHost })
861
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "dsh-st-flyout-root", ref: setMenuHost }),
862
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
863
+ import_dsh_client_ui_primitives.RiskConfirmation,
864
+ {
865
+ open: confirmingPermission !== void 0,
866
+ title: permissionT("confirm.title"),
867
+ description: permissionT("confirm.description"),
868
+ acknowledgeLabel: permissionT("confirm.acknowledge"),
869
+ cancelLabel: permissionT("confirm.cancel"),
870
+ confirmLabel: permissionT("confirm.enable"),
871
+ acknowledged: fullAccessAcknowledged,
872
+ onAcknowledgedChange: setFullAccessAcknowledged,
873
+ onCancel: cancelFullAccessConfirmation,
874
+ onConfirm: confirmFullAccess
875
+ }
876
+ )
841
877
  ] }) });
842
878
  }
843
879
  function ModelPicker({