@cognipeer/agent-sdk 0.8.3 → 0.8.4

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/dist/index.cjs CHANGED
@@ -4573,6 +4573,7 @@ function resolveUserQuestionState(state, resolution) {
4573
4573
  ctx
4574
4574
  };
4575
4575
  }
4576
+ var ASK_USER_TOOL_NAME = "ask_user_question";
4576
4577
  var DEFAULT_DESCRIPTION_WITH_FREETEXT = "Pause the agent and surface a structured prompt to the human user when you genuinely cannot proceed without their input. Group up to 4 closely related questions into a single call. Prefer concrete options the user can pick over open-ended free-text \u2014 list `options` whenever you can anticipate the choices. The user may type a custom answer for any question. Do not use this tool for things you can deduce from the conversation, the system prompt, or another tool. After the user answers, their selections come back as the tool result.";
4577
4578
  var DEFAULT_DESCRIPTION_NO_FREETEXT = "Pause the agent and surface a structured multi-choice prompt to the human user when you genuinely cannot proceed without their input. Group up to 4 closely related questions into a single call. Every question MUST include at least two `options` \u2014 free-text answers are disabled for this agent. Do not use this tool for things you can deduce from the conversation, the system prompt, or another tool. After the user picks, their selections come back as the tool result.";
4578
4579
  function buildOptionSchema() {
@@ -4608,7 +4609,7 @@ function createAskUserQuestionTool(stateRef, config) {
4608
4609
  const description = config.promptOverride ?? (allowFreeText ? DEFAULT_DESCRIPTION_WITH_FREETEXT : DEFAULT_DESCRIPTION_NO_FREETEXT);
4609
4610
  const questionSchema = buildQuestionSchema(allowFreeText);
4610
4611
  const askUser = createTool({
4611
- name: "ask_user_question",
4612
+ name: ASK_USER_TOOL_NAME,
4612
4613
  description,
4613
4614
  schema: zod.z.object({
4614
4615
  questions: zod.z.array(questionSchema).min(1).max(4).describe("1-4 related questions to ask in a single pause.")
@@ -4624,7 +4625,7 @@ function createAskUserQuestionTool(stateRef, config) {
4624
4625
  const entry = {
4625
4626
  id: nanoid.nanoid(),
4626
4627
  toolCallId,
4627
- toolName: "ask_user_question",
4628
+ toolName: ASK_USER_TOOL_NAME,
4628
4629
  questions,
4629
4630
  status: "pending",
4630
4631
  requestedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -4980,14 +4981,15 @@ function createAgent(opts) {
4980
4981
  })();
4981
4982
  const askUserOnQuestion = typeof opts.humanInTheLoop?.askUser === "object" ? opts.humanInTheLoop?.askUser?.onQuestion : void 0;
4982
4983
  const askUserStateRef = askUserConfig ? { pendingUserQuestions: void 0, ctx: void 0, __onEvent: void 0, __currentToolCallId: void 0 } : void 0;
4983
- if (askUserConfig && askUserStateRef) {
4984
+ const hasTool = (name) => toolsBase.some((tool) => tool?.name === name);
4985
+ if (askUserConfig && askUserStateRef && !hasTool(ASK_USER_TOOL_NAME)) {
4984
4986
  toolsBase.push(createAskUserQuestionTool(askUserStateRef, askUserConfig));
4985
4987
  }
4986
4988
  const soManager = opts.outputSchema ? new StructuredOutputManager(opts.outputSchema, resolveStrategy(opts.model)) : void 0;
4987
4989
  if (soManager) {
4988
4990
  const modelCapabilities = getModelCapabilities(opts.model);
4989
4991
  const responseTool = soManager.getResponseTool();
4990
- if (responseTool && modelCapabilities.structuredOutput !== "native") {
4992
+ if (responseTool && modelCapabilities.structuredOutput !== "native" && !hasTool(responseTool.name)) {
4991
4993
  toolsBase.push(responseTool);
4992
4994
  }
4993
4995
  }
@@ -10947,6 +10949,7 @@ function createProvider(config) {
10947
10949
  }
10948
10950
  }
10949
10951
 
10952
+ exports.ASK_USER_TOOL_NAME = ASK_USER_TOOL_NAME;
10950
10953
  exports.AnthropicProvider = AnthropicProvider;
10951
10954
  exports.AzureProvider = AzureProvider;
10952
10955
  exports.BaseProvider = BaseProvider;