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.
@@ -2223,7 +2223,7 @@ var init_claude_registry = __esm(() => {
2223
2223
  });
2224
2224
 
2225
2225
  // ../../packages/core/src/version.ts
2226
- var NEGOTIUM_VERSION = "0.2.16";
2226
+ var NEGOTIUM_VERSION = "0.2.17";
2227
2227
 
2228
2228
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
2229
2229
  import { spawn as spawn2 } from "child_process";
@@ -5834,6 +5834,7 @@ function maestroProvider(opts) {
5834
5834
  ...opts,
5835
5835
  enableToolSearch: !opts.toolPolicy && opts.enableToolSearch !== false,
5836
5836
  toolResultTruncation: buildMaestroToolResultTruncation(opts),
5837
+ ephemeralSystemPrompt: opts.ephemeralSystemPrompt,
5837
5838
  apiKeyOverrides: resolveMaestroApiKeyOverrides(userId),
5838
5839
  agent: "maestro",
5839
5840
  disallowedTools: buildMaestroDisallowedTools(callerDisallowedTools, opts.toolPolicy),
@@ -14856,6 +14857,9 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14856
14857
  let pendingSawDelta = false;
14857
14858
  let accumulatedText = "";
14858
14859
  let pendingText = "";
14860
+ let assistantContextTokens = 0;
14861
+ let toolContextTokens = 0;
14862
+ let lastContextProgressAt = 0;
14859
14863
  let lastVisibleMessageId = null;
14860
14864
  const visibleMessageIds = [];
14861
14865
  let lastTaskPanelText = null;
@@ -14874,6 +14878,20 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14874
14878
  model
14875
14879
  });
14876
14880
  };
14881
+ const broadcastContextProgress = (force = false) => {
14882
+ if (silent)
14883
+ return;
14884
+ const now = Date.now();
14885
+ if (!force && lastContextProgressAt > 0 && now - lastContextProgressAt < 250)
14886
+ return;
14887
+ lastContextProgressAt = now;
14888
+ hub.broadcastAiStatus(topicId, {
14889
+ kind: "context_progress",
14890
+ queryId,
14891
+ assistantTokens: assistantContextTokens,
14892
+ toolTokens: toolContextTokens
14893
+ });
14894
+ };
14877
14895
  const nextSyntheticToolUseId = () => `tool-${queryId}-${++syntheticToolCounter}`;
14878
14896
  const bindToolUseId = (providerToolUseId, fallback) => {
14879
14897
  const providerId = normalizeToolUseId(providerToolUseId);
@@ -14983,6 +15001,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14983
15001
  const incoming = event.content;
14984
15002
  accumulatedText += incoming;
14985
15003
  pendingText += incoming;
15004
+ assistantContextTokens = estimateTextTokens(accumulatedText);
15005
+ broadcastContextProgress();
14986
15006
  break;
14987
15007
  }
14988
15008
  case "text":
@@ -14990,10 +15010,15 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
14990
15010
  const incoming = event.content;
14991
15011
  accumulatedText += incoming;
14992
15012
  pendingText += incoming;
15013
+ assistantContextTokens = estimateTextTokens(accumulatedText);
15014
+ broadcastContextProgress();
14993
15015
  }
14994
15016
  break;
14995
15017
  case "tool_use":
14996
15018
  emitPendingAssistantMessage();
15019
+ toolContextTokens += estimateTextTokens(`${event.name}
15020
+ ${JSON.stringify(event.input ?? {})}`);
15021
+ broadcastContextProgress(true);
14997
15022
  if (isVisualsShowHtmlTool(event.name)) {
14998
15023
  const input = event.input;
14999
15024
  if (typeof input.html !== "string" || input.html.trim().length === 0) {
@@ -15147,6 +15172,8 @@ async function runTurnEventStream(topicId, topicTitle, queryId, events, control,
15147
15172
  }
15148
15173
  break;
15149
15174
  case "tool_result":
15175
+ toolContextTokens += estimateTextTokens(event.content);
15176
+ broadcastContextProgress(true);
15150
15177
  if (isVisualToolResultHandled(event.toolUseId))
15151
15178
  break;
15152
15179
  if (!silent) {
@@ -15532,6 +15559,7 @@ __export(exports_turn_runner, {
15532
15559
  channelTranscriptSpeaker: () => channelTranscriptSpeaker,
15533
15560
  canonicalModelId: () => canonicalModelId,
15534
15561
  buildVideoHtml: () => buildVideoHtml,
15562
+ buildTurnReminderQuery: () => buildTurnReminderQuery,
15535
15563
  buildMermaidHtml: () => buildMermaidHtml,
15536
15564
  buildMentionOnlyChannelPrompt: () => buildMentionOnlyChannelPrompt,
15537
15565
  buildImageHtml: () => buildImageHtml,
@@ -15557,6 +15585,18 @@ function withDefaultPlaywright(configuredMcp, isManager) {
15557
15585
  enabled.add("background-bash");
15558
15586
  return [...enabled];
15559
15587
  }
15588
+ function buildTurnReminderQuery(agent, prompt, reminders) {
15589
+ const reminderPrompt = reminders.join(`
15590
+
15591
+ `);
15592
+ if (!reminderPrompt)
15593
+ return { prompt };
15594
+ if (agent === "maestro")
15595
+ return { prompt, ephemeralSystemPrompt: reminderPrompt };
15596
+ return { prompt: `${prompt}
15597
+
15598
+ ${reminderPrompt}` };
15599
+ }
15560
15600
  function appendSystemMessage(topicId, text2) {
15561
15601
  const message = {
15562
15602
  id: randomUUID16(),
@@ -16504,15 +16544,11 @@ function startAiTurn(params) {
16504
16544
  if (consumePlaywrightUnavailable(userId, topic.title)) {
16505
16545
  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>");
16506
16546
  }
16507
- const effectivePrompt = turnReminders.length > 0 ? `${agentPrompt}
16508
-
16509
- ${turnReminders.join(`
16510
-
16511
- `)}` : agentPrompt;
16547
+ const reminderQuery = buildTurnReminderQuery(agentKind, agentPrompt, turnReminders);
16512
16548
  try {
16513
16549
  yield* runAgent({
16514
16550
  agent: agentKind,
16515
- prompt: effectivePrompt,
16551
+ ...reminderQuery,
16516
16552
  attachments: promptAttachments,
16517
16553
  cwd: workspaceCwd,
16518
16554
  systemPrompt,
@@ -18731,4 +18767,4 @@ export {
18731
18767
  DEFAULT_SELF_CONFIG_PRODUCT
18732
18768
  };
18733
18769
 
18734
- //# debugId=969112A1E458C75264756E2164756E21
18770
+ //# debugId=814F0B0C425F56EA64756E2164756E21