@otium-team/negotium 0.24.0 → 0.24.1

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/main.js CHANGED
@@ -3889,8 +3889,8 @@ function answerToolResult(answer) {
3889
3889
  return textResult("The user skipped this question. Continue using your best judgment and finish the current turn.");
3890
3890
  }
3891
3891
  if (answer.kind === "custom") {
3892
- return textResult(`User answered in their own words: ${answer.label}
3893
- Continue from this answer and finish the current turn.`);
3892
+ return textResult(`The user did not pick a listed option. They typed this reply in the chat instead: "${answer.label}"
3893
+ Treat it as their free-text answer to your question and read it for what it says. If it hands the decision back to you (for example "decide yourself" or "you handle it"), choose the best option yourself and go on. Continue from this answer and finish the current turn.`);
3894
3894
  }
3895
3895
  const description = answer.description ? `
3896
3896
  Description: ${answer.description}` : "";
@@ -3982,6 +3982,7 @@ function createAskUserRuntime(host) {
3982
3982
  id: createId(),
3983
3983
  topicId,
3984
3984
  authorId: userId,
3985
+ ...options.answerMessage,
3985
3986
  text: label,
3986
3987
  parentId: messageId,
3987
3988
  ...existing.threadRootId ? { threadRootId: existing.threadRootId } : {},
@@ -4000,6 +4001,20 @@ function createAskUserRuntime(host) {
4000
4001
  pending.resolve({ ...choice, userId, ...kind ? { kind } : {} });
4001
4002
  return { ok: true, queryId: pending.queryId, answerMessage };
4002
4003
  }
4004
+ function answerOpenQuestionWithText(topicId, text, userId, options = {}) {
4005
+ for (const [messageId, pending] of pendingAsks) {
4006
+ if (pending.topicId !== topicId)
4007
+ continue;
4008
+ const card = host.messaging.persistence.getMessage(topicId, messageId);
4009
+ if ((card?.threadRootId ?? undefined) !== (options.threadRootId ?? undefined))
4010
+ continue;
4011
+ return answerPendingQuestion(topicId, messageId, text, userId, {
4012
+ kind: "custom",
4013
+ ...options.answerMessage ? { answerMessage: options.answerMessage } : {}
4014
+ });
4015
+ }
4016
+ return null;
4017
+ }
4003
4018
  function cancelPendingQuestions(topicId, queryId) {
4004
4019
  for (const [messageId, pending] of pendingAsks) {
4005
4020
  if (pending.topicId === topicId && pending.queryId === queryId) {
@@ -4155,6 +4170,7 @@ function createAskUserRuntime(host) {
4155
4170
  reconcilePendingGates,
4156
4171
  hasPendingQuestion,
4157
4172
  answerPendingQuestion,
4173
+ answerOpenQuestionWithText,
4158
4174
  cancelPendingQuestions,
4159
4175
  createToolDefinition
4160
4176
  };
@@ -4171,6 +4187,9 @@ function reconcilePendingAskUserQuestionGates() {
4171
4187
  function answerPendingAskUserQuestion(topicId, messageId, label, userId, options) {
4172
4188
  return defaultAskUserRuntime.answerPendingQuestion(topicId, messageId, label, userId, options);
4173
4189
  }
4190
+ function answerOpenAskUserQuestionWithText(topicId, text, userId, options) {
4191
+ return defaultAskUserRuntime.answerOpenQuestionWithText(topicId, text, userId, options);
4192
+ }
4174
4193
  function cancelPendingAskUserQuestions(topicId, queryId) {
4175
4194
  defaultAskUserRuntime.cancelPendingQuestions(topicId, queryId);
4176
4195
  }
@@ -8899,7 +8918,7 @@ var init_codex = __esm(async () => {
8899
8918
  });
8900
8919
 
8901
8920
  // ../../packages/core/src/version.ts
8902
- var NEGOTIUM_VERSION = "0.24.0";
8921
+ var NEGOTIUM_VERSION = "0.24.1";
8903
8922
 
8904
8923
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
8905
8924
  import { spawn as spawn2 } from "child_process";
@@ -26504,6 +26523,54 @@ function gatewayPayloadHash(params, requestId, actorUserId) {
26504
26523
  params.attachments ?? []
26505
26524
  ])).digest("hex");
26506
26525
  }
26526
+ function answerOpenAskWithMessage(params) {
26527
+ const text = params.text.trim();
26528
+ if (!text || params.respond === false || params.silent === true || params.parentId || params.attachments?.length || isTopicClaimAbortFenced(params.topic.id)) {
26529
+ return null;
26530
+ }
26531
+ const requestId = params.requestId ?? params.clientMessageId;
26532
+ const actorUserId = params.actorUserId ?? params.userId;
26533
+ const sourceAdapter = params.sourceAdapter?.trim() || "runtime-gateway";
26534
+ const answered = answerOpenAskUserQuestionWithText(params.topic.id, text, params.userId, {
26535
+ ...params.threadRootId ? { threadRootId: params.threadRootId } : {},
26536
+ answerMessage: {
26537
+ authorId: actorUserId,
26538
+ ...params.actorLabel ? { authorName: params.actorLabel } : {},
26539
+ sourceAdapter,
26540
+ sourceMessageId: params.clientMessageId
26541
+ }
26542
+ });
26543
+ if (!answered?.ok)
26544
+ return null;
26545
+ const message = answered.answerMessage;
26546
+ const submission = {
26547
+ clientMessageId: params.clientMessageId,
26548
+ requestId,
26549
+ topicId: params.topic.id,
26550
+ messageId: message.id,
26551
+ userId: params.userId,
26552
+ createdAt: message.createdAt,
26553
+ ackCursor: 0,
26554
+ messageCursor: 0,
26555
+ payloadHash: gatewayPayloadHash(params, requestId, actorUserId)
26556
+ };
26557
+ db.transaction(() => {
26558
+ const acceptedEvent = appendRuntimeEvent("runtime-gateway-ingress", {
26559
+ type: "ai-status",
26560
+ topicId: params.topic.id,
26561
+ payload: {
26562
+ kind: "turn_accepted",
26563
+ requestId,
26564
+ clientMessageId: params.clientMessageId,
26565
+ messageId: message.id,
26566
+ delivery: "answered"
26567
+ }
26568
+ });
26569
+ submission.ackCursor = acceptedEvent.seq;
26570
+ recordRuntimeGatewaySubmission(submission);
26571
+ })();
26572
+ return { ...submission, message, deduplicated: false };
26573
+ }
26507
26574
  function submitRuntimeGatewayTurn(params) {
26508
26575
  const hostMcpServers = parseHostMcpServers(params.hostMcpServers);
26509
26576
  const grantRefusal = hostMcpServers === undefined ? null : hostMcpGrantRefusal(params.topic, Object.keys(hostMcpServers));
@@ -26524,6 +26591,9 @@ function submitRuntimeGatewayTurn(params) {
26524
26591
  }
26525
26592
  if (isTopicClaimAbortFenced(params.topic.id))
26526
26593
  throw new RuntimeGatewayTopicUnavailableError;
26594
+ const answeredAsk = answerOpenAskWithMessage(params);
26595
+ if (answeredAsk)
26596
+ return answeredAsk;
26527
26597
  recordTopicToolCapabilities(params.topic.id, {
26528
26598
  visualTools: params.visualTools === true,
26529
26599
  fileDeliveryTools: params.fileDeliveryTools === true
@@ -26669,6 +26739,7 @@ var init_submit_runtime_gateway_turn = __esm(async () => {
26669
26739
  init_user_turn_envelope();
26670
26740
  init_runtime_gateway();
26671
26741
  await __promiseAll([
26742
+ init_ask_user(),
26672
26743
  init_mcp_config(),
26673
26744
  init_active_rooms(),
26674
26745
  init_api_messages(),
@@ -27324,6 +27395,11 @@ function holdOrSubmitRuntimeGatewayTurn(params) {
27324
27395
  const alreadySent = findRuntimeGatewaySubmission(params.clientMessageId, requestId) !== null;
27325
27396
  const waiting = listRuntimeFollowUps(topicId).length > 0;
27326
27397
  const paused = areRuntimeFollowUpsPaused(topicId);
27398
+ if (!alreadySent) {
27399
+ const answered = answerOpenAskWithMessage(params);
27400
+ if (answered)
27401
+ return { held: false, submission: answered };
27402
+ }
27327
27403
  const holdable = !alreadySent && params.respond !== false && params.silent !== true;
27328
27404
  if (holdable && (isRoomWorking(topicId) || waiting && !paused)) {
27329
27405
  const { topic: _topic, text, ...rest } = params;
@@ -61222,4 +61298,4 @@ switch (command) {
61222
61298
  }
61223
61299
  }
61224
61300
 
61225
- //# debugId=D0AC8CE1607C019A64756E2164756E21
61301
+ //# debugId=5917D6992A07143C64756E2164756E21