negotium 0.2.16 → 0.2.17

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.
@@ -952,7 +952,7 @@ var init_claude_registry = __esm(() => {
952
952
  });
953
953
 
954
954
  // ../../packages/core/src/version.ts
955
- var NEGOTIUM_VERSION = "0.2.16";
955
+ var NEGOTIUM_VERSION = "0.2.17";
956
956
 
957
957
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
958
958
  import { spawn as spawn2 } from "child_process";
@@ -9787,6 +9787,7 @@ function maestroProvider(opts) {
9787
9787
  ...opts,
9788
9788
  enableToolSearch: !opts.toolPolicy && opts.enableToolSearch !== false,
9789
9789
  toolResultTruncation: buildMaestroToolResultTruncation(opts),
9790
+ ephemeralSystemPrompt: opts.ephemeralSystemPrompt,
9790
9791
  apiKeyOverrides: resolveMaestroApiKeyOverrides(userId),
9791
9792
  agent: "maestro",
9792
9793
  disallowedTools: buildMaestroDisallowedTools(callerDisallowedTools, opts.toolPolicy),
@@ -14883,6 +14884,9 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14883
14884
  let pendingSawDelta = false;
14884
14885
  let accumulatedText = "";
14885
14886
  let pendingText = "";
14887
+ let assistantContextTokens = 0;
14888
+ let toolContextTokens = 0;
14889
+ let lastContextProgressAt = 0;
14886
14890
  let lastVisibleMessageId = null;
14887
14891
  const visibleMessageIds = [];
14888
14892
  let lastTaskPanelText = null;
@@ -14901,6 +14905,20 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14901
14905
  model
14902
14906
  });
14903
14907
  };
14908
+ const broadcastContextProgress = (force = false) => {
14909
+ if (silent)
14910
+ return;
14911
+ const now = Date.now();
14912
+ if (!force && lastContextProgressAt > 0 && now - lastContextProgressAt < 250)
14913
+ return;
14914
+ lastContextProgressAt = now;
14915
+ hub.broadcastAiStatus(topicId, {
14916
+ kind: "context_progress",
14917
+ queryId,
14918
+ assistantTokens: assistantContextTokens,
14919
+ toolTokens: toolContextTokens
14920
+ });
14921
+ };
14904
14922
  const nextSyntheticToolUseId = () => `tool-${queryId}-${++syntheticToolCounter}`;
14905
14923
  const bindToolUseId = (providerToolUseId, fallback) => {
14906
14924
  const providerId = normalizeToolUseId(providerToolUseId);
@@ -15010,6 +15028,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
15010
15028
  const incoming = event.content;
15011
15029
  accumulatedText += incoming;
15012
15030
  pendingText += incoming;
15031
+ assistantContextTokens = estimateTextTokens(accumulatedText);
15032
+ broadcastContextProgress();
15013
15033
  break;
15014
15034
  }
15015
15035
  case "text":
@@ -15017,10 +15037,15 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
15017
15037
  const incoming = event.content;
15018
15038
  accumulatedText += incoming;
15019
15039
  pendingText += incoming;
15040
+ assistantContextTokens = estimateTextTokens(accumulatedText);
15041
+ broadcastContextProgress();
15020
15042
  }
15021
15043
  break;
15022
15044
  case "tool_use":
15023
15045
  emitPendingAssistantMessage();
15046
+ toolContextTokens += estimateTextTokens(`${event.name}
15047
+ ${JSON.stringify(event.input ?? {})}`);
15048
+ broadcastContextProgress(true);
15024
15049
  if (isVisualsShowHtmlTool(event.name)) {
15025
15050
  const input = event.input;
15026
15051
  if (typeof input.html !== "string" || input.html.trim().length === 0) {
@@ -15174,6 +15199,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
15174
15199
  }
15175
15200
  break;
15176
15201
  case "tool_result":
15202
+ toolContextTokens += estimateTextTokens(event.content);
15203
+ broadcastContextProgress(true);
15177
15204
  if (isVisualToolResultHandled(event.toolUseId))
15178
15205
  break;
15179
15206
  if (!silent) {
@@ -15559,6 +15586,7 @@ __export(exports_turn_runner, {
15559
15586
  channelTranscriptSpeaker: () => channelTranscriptSpeaker,
15560
15587
  canonicalModelId: () => canonicalModelId,
15561
15588
  buildVideoHtml: () => buildVideoHtml,
15589
+ buildTurnReminderQuery: () => buildTurnReminderQuery,
15562
15590
  buildMermaidHtml: () => buildMermaidHtml,
15563
15591
  buildMentionOnlyChannelPrompt: () => buildMentionOnlyChannelPrompt,
15564
15592
  buildImageHtml: () => buildImageHtml,
@@ -15584,6 +15612,18 @@ function withDefaultPlaywright(configuredMcp, isManager) {
15584
15612
  enabled.add("background-bash");
15585
15613
  return [...enabled];
15586
15614
  }
15615
+ function buildTurnReminderQuery(agent, prompt, reminders) {
15616
+ const reminderPrompt = reminders.join(`
15617
+
15618
+ `);
15619
+ if (!reminderPrompt)
15620
+ return { prompt };
15621
+ if (agent === "maestro")
15622
+ return { prompt, ephemeralSystemPrompt: reminderPrompt };
15623
+ return { prompt: `${prompt}
15624
+
15625
+ ${reminderPrompt}` };
15626
+ }
15587
15627
  function appendSystemMessage(topicId, text2) {
15588
15628
  const message = {
15589
15629
  id: randomUUID16(),
@@ -16531,15 +16571,11 @@ function startAiTurn(params) {
16531
16571
  if (consumePlaywrightUnavailable(userId, topic.title)) {
16532
16572
  turnReminders.push("<system-reminder>Playwright browser tools are UNAVAILABLE this turn. The `mcp__playwright__*` tools have been removed from this turn's catalog because the long-lived browser MCP could not be prepared. Do not attempt to call browser tools. If browser interaction is required, ask the user to retry shortly or use a non-browser alternative.</system-reminder>");
16533
16573
  }
16534
- const effectivePrompt = turnReminders.length > 0 ? `${agentPrompt}
16535
-
16536
- ${turnReminders.join(`
16537
-
16538
- `)}` : agentPrompt;
16574
+ const reminderQuery = buildTurnReminderQuery(agentKind, agentPrompt, turnReminders);
16539
16575
  try {
16540
16576
  yield* runAgent({
16541
16577
  agent: agentKind,
16542
- prompt: effectivePrompt,
16578
+ ...reminderQuery,
16543
16579
  attachments: promptAttachments,
16544
16580
  cwd: workspaceCwd,
16545
16581
  systemPrompt,
@@ -19907,4 +19943,4 @@ export {
19907
19943
  createAgentHealthMcpServer
19908
19944
  };
19909
19945
 
19910
- //# debugId=AD21E471FB1B87CE64756E2164756E21
19946
+ //# debugId=AD1DC675E382EEA164756E2164756E21