@michengai/dsh-agency-agents 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.
Files changed (2) hide show
  1. package/lib/client.js +17 -9
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -6726,6 +6726,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6726
6726
  window.requestAnimationFrame(select);
6727
6727
  });
6728
6728
  }
6729
+ /** 根据当前草稿生成召唤指令。有内容时把原草稿包进 withTask 模板。 */
6730
+ function buildSummonInstruction(t, name, slug, draft) {
6731
+ return t(draft.trim().length > 0 ? "summon.instruction.withTask" : "summon.instruction", {
6732
+ name,
6733
+ slug,
6734
+ task: draft
6735
+ });
6736
+ }
6737
+ /** 将召唤指令写入输入框。有草稿时也不自动发送,留给用户确认后再提交。 */
6738
+ function applyExpertSummon(options) {
6739
+ if (options.inputActions !== void 0) options.inputActions.setDraft(options.instruction);
6740
+ }
6729
6741
  function AgentsButton(props) {
6730
6742
  const [open, setOpen] = react.default.useState(false);
6731
6743
  const [enabled, setEnabled] = react.default.useState(/* @__PURE__ */ new Set());
@@ -6755,16 +6767,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6755
6767
  const expert = EXPERTS.find((e) => e.slug === slug);
6756
6768
  const name = expert === void 0 ? slug : displayName(expert, props.getActive());
6757
6769
  const draft = props.input !== void 0 && typeof props.input.draft === "string" ? props.input.draft : "";
6758
- const hasTask = draft.trim().length > 0;
6759
- const instruction = props.t(hasTask ? "summon.instruction.withTask" : "summon.instruction", {
6760
- name,
6761
- slug,
6762
- task: draft
6770
+ applyExpertSummon({
6771
+ inputActions: props.inputActions,
6772
+ instruction: buildSummonInstruction(props.t, name, slug, draft)
6763
6773
  });
6764
- if (props.inputActions !== void 0) {
6765
- props.inputActions.setDraft(instruction);
6766
- if (hasTask) props.inputActions.submit();
6767
- }
6768
6774
  setOpen(false);
6769
6775
  };
6770
6776
  const groups = groupByDivision(EXPERTS.filter((e) => enabled.has(e.slug)));
@@ -6957,6 +6963,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
6957
6963
  }
6958
6964
  //#endregion
6959
6965
  exports.apply = apply;
6966
+ exports.applyExpertSummon = applyExpertSummon;
6967
+ exports.buildSummonInstruction = buildSummonInstruction;
6960
6968
  exports.inject = inject;
6961
6969
  exports.writeErrorKey = writeErrorKey;
6962
6970
  exports.writeErrorMessage = writeErrorMessage;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@michengai/dsh-agency-agents",
3
3
  "description": "Agency Experts — a summonable domain-expert roster for DSH (expert mode)",
4
- "version": "0.1.11",
4
+ "version": "0.1.12",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",