negotium 0.1.33 → 0.1.34

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 (80) hide show
  1. package/dist/agent-helpers.js +70 -14
  2. package/dist/agent-helpers.js.map +9 -9
  3. package/dist/background-bash.js.map +2 -2
  4. package/dist/{chunk-1p2n47qd.js → chunk-s56ynvmp.js} +2 -2
  5. package/dist/{chunk-1p2n47qd.js.map → chunk-s56ynvmp.js.map} +3 -3
  6. package/dist/cron.js +222 -74
  7. package/dist/cron.js.map +15 -15
  8. package/dist/hosted-agent.js +17 -4
  9. package/dist/hosted-agent.js.map +6 -6
  10. package/dist/main.js +1448 -192
  11. package/dist/main.js.map +23 -21
  12. package/dist/mcp-factories.js +1517 -626
  13. package/dist/mcp-factories.js.map +30 -18
  14. package/dist/prompts.js +56 -13
  15. package/dist/prompts.js.map +5 -5
  16. package/dist/query-runtime.js.map +2 -2
  17. package/dist/registry.js +1 -1
  18. package/dist/registry.js.map +2 -2
  19. package/dist/rollout.js +1 -1
  20. package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +447 -81
  21. package/dist/runtime/src/index.ts +7 -0
  22. package/dist/runtime/src/mcp/factories/session-comm.ts +44 -13
  23. package/dist/runtime/src/mcp/session-comm/context.ts +3 -0
  24. package/dist/runtime/src/mcp/session-comm/runtime.ts +1 -0
  25. package/dist/runtime/src/mcp/session-comm/server.ts +186 -154
  26. package/dist/runtime/src/mcp/session-comm/tell-permissions.ts +79 -0
  27. package/dist/runtime/src/platform/config.ts +1 -1
  28. package/dist/runtime/src/platform/mcp-config.ts +17 -1
  29. package/dist/runtime/src/prompts/builders.ts +86 -35
  30. package/dist/runtime/src/runtime/turn-runner.ts +21 -10
  31. package/dist/runtime/src/storage/api-topics.ts +143 -14
  32. package/dist/runtime/src/storage/storage-host.ts +4 -1
  33. package/dist/runtime/src/topics/derive.ts +11 -3
  34. package/dist/runtime/src/types/api.ts +15 -2
  35. package/dist/runtime/src/types.ts +2 -0
  36. package/dist/runtime/src/version.ts +1 -1
  37. package/dist/runtime-helpers.js.map +4 -4
  38. package/dist/storage.js +91 -13
  39. package/dist/storage.js.map +5 -5
  40. package/dist/types/packages/core/src/agents/mcp-tools/ask-user.d.ts +45 -0
  41. package/dist/types/packages/core/src/agents/mcp-tools/spawn-subagent.d.ts +47 -0
  42. package/dist/types/packages/core/src/agents/topic-cleanup.d.ts +75 -0
  43. package/dist/types/packages/core/src/mcp/peer-bridge.d.ts +87 -0
  44. package/dist/types/packages/core/src/mcp/session-comm/context.d.ts +2 -0
  45. package/dist/types/packages/core/src/mcp/session-comm/peer-forward.d.ts +59 -0
  46. package/dist/types/packages/core/src/mcp/session-comm/tell-permissions.d.ts +29 -0
  47. package/dist/types/packages/core/src/platform/config.d.ts +1 -1
  48. package/dist/types/packages/core/src/platform/mcp-config.d.ts +3 -0
  49. package/dist/types/packages/core/src/platform/playwright/browser-processes.d.ts +60 -0
  50. package/dist/types/packages/core/src/platform/playwright/headed-launch.d.ts +13 -0
  51. package/dist/types/packages/core/src/platform/playwright/manager-utils.d.ts +15 -0
  52. package/dist/types/packages/core/src/platform/playwright/manager.d.ts +80 -0
  53. package/dist/types/packages/core/src/prompts/builders.d.ts +7 -1
  54. package/dist/types/packages/core/src/query/session-inbox-cleanup.d.ts +5 -0
  55. package/dist/types/packages/core/src/query/session-inbox-path.d.ts +8 -0
  56. package/dist/types/packages/core/src/query/state.d.ts +4 -0
  57. package/dist/types/packages/core/src/runtime/ask-callbacks.d.ts +44 -0
  58. package/dist/types/packages/core/src/runtime/errors.d.ts +6 -0
  59. package/dist/types/packages/core/src/runtime/event-heartbeat.d.ts +17 -0
  60. package/dist/types/packages/core/src/runtime/tasks.d.ts +3 -0
  61. package/dist/types/packages/core/src/runtime/topic-config.d.ts +24 -0
  62. package/dist/types/packages/core/src/runtime/turn-event-stream.d.ts +26 -0
  63. package/dist/types/packages/core/src/runtime/turn-runner.d.ts +151 -0
  64. package/dist/types/packages/core/src/runtime/turn-session.d.ts +49 -0
  65. package/dist/types/packages/core/src/runtime/usage-alert.d.ts +11 -0
  66. package/dist/types/packages/core/src/runtime/visual-store.d.ts +46 -0
  67. package/dist/types/packages/core/src/runtime/visuals.d.ts +27 -0
  68. package/dist/types/packages/core/src/storage/api-topics.d.ts +8 -3
  69. package/dist/types/packages/core/src/storage/ask-user-gates.d.ts +63 -0
  70. package/dist/types/packages/core/src/storage/browser-profiles.d.ts +25 -0
  71. package/dist/types/packages/core/src/storage/runtime-process-leases.d.ts +47 -0
  72. package/dist/types/packages/core/src/storage/runtime-turn-requests.d.ts +55 -0
  73. package/dist/types/packages/core/src/storage/self-schedules.d.ts +54 -0
  74. package/dist/types/packages/core/src/topics/derive.d.ts +54 -0
  75. package/dist/types/packages/core/src/topics/lifecycle.d.ts +39 -0
  76. package/dist/types/packages/core/src/types/api.d.ts +15 -2
  77. package/dist/types/packages/core/src/types.d.ts +2 -0
  78. package/dist/types/packages/core/src/version.d.ts +1 -1
  79. package/dist/vault.js.map +2 -2
  80. package/package.json +2 -2
@@ -281,7 +281,7 @@ var AGENTS_PROMPTS_DIR = resolve(PROJECT_ROOT, "src/prompts/agents");
281
281
  var RESOURCES_DIR = resolve(PROJECT_ROOT, "src/resources");
282
282
  var FILE_TAG_REGEX = /\[FILE:(\/[^\]]+)\]/gi;
283
283
  var MODEL_SONNET = "claude-sonnet-5";
284
- var MODEL_OPUS = "claude-opus-4-8";
284
+ var MODEL_OPUS = "claude-opus-5";
285
285
  var MODEL_FABLE = "claude-fable-5";
286
286
  var FALLBACK_AGENT = resolveAgentEnv("FALLBACK_AGENT", "maestro", "DEFAULT_AGENT");
287
287
  var SESSION_AGENT = resolveAgentEnv("SESSION_AGENT", FALLBACK_AGENT);
@@ -2668,12 +2668,22 @@ var MCP_CATALOG = {
2668
2668
  },
2669
2669
  "session-comm": {
2670
2670
  ...commonRuntimeMcpPolicy("session-comm"),
2671
- build({ userId, session, topicId, agent, depth = 0, silent, peerBridge }) {
2671
+ build({
2672
+ userId,
2673
+ session,
2674
+ topicId,
2675
+ subagentParentTopicId,
2676
+ agent,
2677
+ depth = 0,
2678
+ silent,
2679
+ peerBridge
2680
+ }) {
2672
2681
  const effectiveAgent = agent ?? FALLBACK_AGENT;
2673
2682
  const args = [
2674
2683
  `--user-id=${userId}`,
2675
2684
  `--topic=${session}`,
2676
2685
  ...topicId ? [`--topic-id=${topicId}`] : [],
2686
+ ...subagentParentTopicId ? [`--subagent-parent-topic-id=${subagentParentTopicId}`] : [],
2677
2687
  `--depth=${depth}`,
2678
2688
  `--agent=${effectiveAgent}`,
2679
2689
  ...silent ? ["--reply-only=true"] : [],
@@ -2823,6 +2833,7 @@ function getForumMcpServers(opts) {
2823
2833
  userId,
2824
2834
  session,
2825
2835
  topicId,
2836
+ subagentParentTopicId,
2826
2837
  queryId,
2827
2838
  wikiTopicId,
2828
2839
  agent,
@@ -2852,6 +2863,7 @@ function getForumMcpServers(opts) {
2852
2863
  userId,
2853
2864
  session,
2854
2865
  topicId,
2866
+ subagentParentTopicId,
2855
2867
  queryId,
2856
2868
  wikiTopicId,
2857
2869
  agent,
@@ -2938,6 +2950,7 @@ function getMcpServersForQuery(opts) {
2938
2950
  userId: opts.userId || "default",
2939
2951
  session: opts.session || "default",
2940
2952
  topicId: opts.topicId,
2953
+ subagentParentTopicId: opts.subagentParentTopicId,
2941
2954
  queryId: opts.queryId,
2942
2955
  wikiTopicId: opts.wikiTopicId,
2943
2956
  agent: opts.agent,
@@ -3519,7 +3532,7 @@ import { tmpdir } from "os";
3519
3532
  import { dirname as dirname7, join as join11 } from "path";
3520
3533
 
3521
3534
  // ../../packages/core/src/version.ts
3522
- var NEGOTIUM_VERSION = "0.1.33";
3535
+ var NEGOTIUM_VERSION = "0.1.34";
3523
3536
 
3524
3537
  // ../../packages/core/src/agents/codex-native-multi-agent.ts
3525
3538
  var moduleRequire = createRequire(import.meta.url);
@@ -5437,6 +5450,7 @@ function initializeApiTopicsSchema() {
5437
5450
  created_at TEXT NOT NULL,
5438
5451
  last_message_at TEXT,
5439
5452
  parent_topic_id TEXT,
5453
+ memory_topic_id TEXT,
5440
5454
  is_fork INTEGER NOT NULL DEFAULT 0 CHECK (is_fork IN (0,1)),
5441
5455
  is_subagent INTEGER NOT NULL DEFAULT 0 CHECK (is_subagent IN (0,1)),
5442
5456
  visibility TEXT NOT NULL DEFAULT 'visible' CHECK (visibility IN ('visible','hidden')),
@@ -5486,8 +5500,8 @@ function initializeApiTopicsSchema() {
5486
5500
  const legacyBaseEffort = row.base_effort ?? row.default_effort;
5487
5501
  db.query(`INSERT INTO api_topics_next
5488
5502
  (id,title,kind,description,agent,base_model,base_effort,response_policy,
5489
- created_at,last_message_at,parent_topic_id,is_fork,is_subagent,visibility,access_mode,session_id)
5490
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`).run(String(row.id), String(row.title), normalized.kind, typeof row.description === "string" ? row.description : null, normalized.agent ?? null, typeof legacyBaseModel === "string" ? legacyBaseModel : null, typeof legacyBaseEffort === "string" ? legacyBaseEffort : null, normalized.aiMode, String(row.created_at), typeof row.last_message_at === "string" ? row.last_message_at : null, typeof row.parent_topic_id === "string" ? row.parent_topic_id : null, Number(row.is_fork ?? 0) !== 0 ? 1 : 0, Number(row.is_subagent ?? 0) !== 0 ? 1 : 0, row.visibility === "hidden" ? "hidden" : "visible", row.access_mode === "shared" ? "shared" : "private", typeof row.session_id === "string" ? row.session_id : null);
5503
+ created_at,last_message_at,parent_topic_id,memory_topic_id,is_fork,is_subagent,visibility,access_mode,session_id)
5504
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`).run(String(row.id), String(row.title), normalized.kind, typeof row.description === "string" ? row.description : null, normalized.agent ?? null, typeof legacyBaseModel === "string" ? legacyBaseModel : null, typeof legacyBaseEffort === "string" ? legacyBaseEffort : null, normalized.aiMode, String(row.created_at), typeof row.last_message_at === "string" ? row.last_message_at : null, typeof row.parent_topic_id === "string" ? row.parent_topic_id : null, typeof row.memory_topic_id === "string" ? row.memory_topic_id : null, Number(row.is_fork ?? 0) !== 0 ? 1 : 0, Number(row.is_subagent ?? 0) !== 0 ? 1 : 0, row.visibility === "hidden" ? "hidden" : "visible", row.access_mode === "shared" ? "shared" : "private", typeof row.session_id === "string" ? row.session_id : null);
5491
5505
  }
5492
5506
  db.exec("DROP TABLE IF EXISTS topic_members");
5493
5507
  db.exec("DROP TABLE api_topics");
@@ -5522,6 +5536,22 @@ function initializeApiTopicsSchema() {
5522
5536
  createCanonicalTopicsTable("api_topics");
5523
5537
  createTopicMembersTable();
5524
5538
  }
5539
+ db.exec(`
5540
+ CREATE TABLE IF NOT EXISTS subagent_tell_grants (
5541
+ subagent_topic_id TEXT NOT NULL REFERENCES api_topics(id) ON DELETE CASCADE,
5542
+ target_topic_id TEXT NOT NULL REFERENCES api_topics(id) ON DELETE CASCADE,
5543
+ granted_by_topic_id TEXT NOT NULL REFERENCES api_topics(id) ON DELETE CASCADE,
5544
+ created_at TEXT NOT NULL,
5545
+ PRIMARY KEY (subagent_topic_id, target_topic_id)
5546
+ )
5547
+ `);
5548
+ db.exec(`
5549
+ DELETE FROM subagent_tell_grants
5550
+ WHERE subagent_topic_id NOT IN (SELECT id FROM api_topics)
5551
+ OR target_topic_id NOT IN (SELECT id FROM api_topics)
5552
+ OR granted_by_topic_id NOT IN (SELECT id FROM api_topics)
5553
+ `);
5554
+ db.exec("DELETE FROM topic_members WHERE topic_id NOT IN (SELECT id FROM api_topics)");
5525
5555
  if (!tableColumns2("api_topics").has("visibility")) {
5526
5556
  db.exec("ALTER TABLE api_topics ADD COLUMN visibility TEXT NOT NULL DEFAULT 'visible'");
5527
5557
  }
@@ -5534,6 +5564,12 @@ function initializeApiTopicsSchema() {
5534
5564
  if (!tableColumns2("api_topics").has("browser_profile_owner")) {
5535
5565
  db.exec("ALTER TABLE api_topics ADD COLUMN browser_profile_owner TEXT");
5536
5566
  }
5567
+ if (!tableColumns2("api_topics").has("subagent_report_mode")) {
5568
+ db.exec("ALTER TABLE api_topics ADD COLUMN subagent_report_mode TEXT NOT NULL DEFAULT 'auto'");
5569
+ }
5570
+ if (!tableColumns2("api_topics").has("memory_topic_id")) {
5571
+ db.exec("ALTER TABLE api_topics ADD COLUMN memory_topic_id TEXT");
5572
+ }
5537
5573
  db.exec(`
5538
5574
  UPDATE api_topics
5539
5575
  SET browser_profile_owner = (
@@ -5550,7 +5586,7 @@ registerStorageSchemaInitializer(initializeApiTopicsSchema, 20);
5550
5586
  function getTopicParticipants(topicId) {
5551
5587
  return db.query("SELECT user_id, role FROM topic_members WHERE topic_id = ? ORDER BY rowid").all(topicId).map((row) => ({ userId: row.user_id, role: row.role }));
5552
5588
  }
5553
- function rowToDto(r, participants = getTopicParticipants(r.id)) {
5589
+ function rowToDto(r, participants = getTopicParticipants(r.id), tellTargets) {
5554
5590
  const normalized = normalizeTopicState({
5555
5591
  id: r.id,
5556
5592
  kind: normalizeTopicKind(r.kind),
@@ -5571,8 +5607,15 @@ function rowToDto(r, participants = getTopicParticipants(r.id)) {
5571
5607
  createdAt: r.created_at,
5572
5608
  lastMessageAt: r.last_message_at ?? new Date().toISOString(),
5573
5609
  parentTopicId: r.parent_topic_id ?? undefined,
5610
+ memoryTopicId: r.memory_topic_id ?? undefined,
5574
5611
  isFork: r.is_fork !== 0,
5575
5612
  ...r.is_subagent !== 0 ? { isSubagent: true } : {},
5613
+ ...r.is_subagent !== 0 ? {
5614
+ subagentTellTargetIds: tellTargets ? tellTargets.get(r.id) ?? [] : listSubagentTellTargetIds(r.id)
5615
+ } : {},
5616
+ ...r.is_subagent !== 0 ? {
5617
+ subagentReportMode: r.subagent_report_mode === "tell" || r.subagent_report_mode === "status-only" ? r.subagent_report_mode : "auto"
5618
+ } : {},
5576
5619
  visibility: normalizeTopicVisibility(r.visibility),
5577
5620
  accessMode: normalizeTopicAccessMode(r.access_mode)
5578
5621
  };
@@ -5627,8 +5670,9 @@ function upsertTopic(t) {
5627
5670
  db.transaction(() => {
5628
5671
  db.query(`INSERT INTO api_topics
5629
5672
  (id,title,kind,description,agent,base_model,base_effort,response_policy,
5630
- created_at,last_message_at,parent_topic_id,is_fork,is_subagent,visibility,access_mode)
5631
- VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
5673
+ created_at,last_message_at,parent_topic_id,memory_topic_id,is_fork,is_subagent,visibility,access_mode,
5674
+ subagent_report_mode)
5675
+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
5632
5676
  ON CONFLICT(id) DO UPDATE SET
5633
5677
  title = excluded.title,
5634
5678
  kind = excluded.kind,
@@ -5640,10 +5684,12 @@ function upsertTopic(t) {
5640
5684
  created_at = excluded.created_at,
5641
5685
  last_message_at = excluded.last_message_at,
5642
5686
  parent_topic_id = excluded.parent_topic_id,
5687
+ memory_topic_id = excluded.memory_topic_id,
5643
5688
  is_fork = excluded.is_fork,
5644
5689
  is_subagent = excluded.is_subagent,
5645
5690
  visibility = excluded.visibility,
5646
- access_mode = excluded.access_mode`).run(t.id, t.title, normalized.kind, t.description ?? null, normalized.agent ?? null, t.defaultModel ?? null, t.defaultEffort ?? null, normalized.aiMode, t.createdAt, t.lastMessageAt ?? null, t.parentTopicId ?? null, t.isFork ? 1 : 0, t.isSubagent ? 1 : 0, normalizeTopicVisibility(t.visibility), normalizeTopicAccessMode(t.accessMode));
5691
+ access_mode = excluded.access_mode,
5692
+ subagent_report_mode = excluded.subagent_report_mode`).run(t.id, t.title, normalized.kind, t.description ?? null, normalized.agent ?? null, t.defaultModel ?? null, t.defaultEffort ?? null, normalized.aiMode, t.createdAt, t.lastMessageAt ?? null, t.parentTopicId ?? null, t.memoryTopicId ?? null, t.isFork ? 1 : 0, t.isSubagent ? 1 : 0, normalizeTopicVisibility(t.visibility), normalizeTopicAccessMode(t.accessMode), t.subagentReportMode ?? "auto");
5647
5693
  db.query("DELETE FROM topic_members WHERE topic_id = ?").run(t.id);
5648
5694
  for (const participant of t.participants) {
5649
5695
  db.query("INSERT INTO topic_members (topic_id,user_id,role) VALUES (?,?,?)").run(t.id, participant.userId, participant.role);
@@ -5676,15 +5722,25 @@ function getTopicMemoryOrigin(id) {
5676
5722
  if (!current2)
5677
5723
  return null;
5678
5724
  const seen = new Set([current2.id]);
5679
- while (current2.parentTopicId && !seen.has(current2.parentTopicId)) {
5680
- const parent = getTopic(current2.parentTopicId);
5681
- if (!parent)
5725
+ while (true) {
5726
+ const nextId = current2.memoryTopicId ?? current2.parentTopicId;
5727
+ if (!nextId || seen.has(nextId))
5728
+ break;
5729
+ const next = getTopic(nextId);
5730
+ if (!next) {
5731
+ if (current2.memoryTopicId) {
5732
+ console.warn(`[topics] memory topic ${current2.memoryTopicId} for ${current2.id} is unresolvable; using the topic's own memory`);
5733
+ }
5682
5734
  break;
5683
- current2 = parent;
5735
+ }
5736
+ current2 = next;
5684
5737
  seen.add(current2.id);
5685
5738
  }
5686
5739
  return current2;
5687
5740
  }
5741
+ function listSubagentTellTargetIds(subagentTopicId) {
5742
+ return db.query("SELECT target_topic_id FROM subagent_tell_grants WHERE subagent_topic_id = ? ORDER BY created_at").all(subagentTopicId).map((row) => row.target_topic_id);
5743
+ }
5688
5744
 
5689
5745
  // ../../packages/core/src/topics/personal-general.ts
5690
5746
  var LEGACY_PERSONAL_GENERAL_DESCRIPTION = "\uB098\uB9CC\uC758 \uAC1C\uC778 \uACF5\uAC04\uC774\uC5D0\uC694. \uB300\uD654\uC640 AI \uC791\uC5C5\uC740 \uB2E4\uB978 \uC0AC\uC6A9\uC790\uC5D0\uAC8C \uACF5\uAC1C\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.";
@@ -6871,4 +6927,4 @@ export {
6871
6927
  MIN_MEMORY_ARCHIVE_EXCHANGES
6872
6928
  };
6873
6929
 
6874
- //# debugId=7F51ACAC3CA7F77164756E2164756E21
6930
+ //# debugId=A03A24352D1C719364756E2164756E21