negotium 0.1.7 → 0.1.8

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 (256) hide show
  1. package/README.md +2 -2
  2. package/dist/chunk-0ay6cjdy.js +1331 -0
  3. package/dist/chunk-0ay6cjdy.js.map +16 -0
  4. package/dist/chunk-1k7t7bnx.js +97 -0
  5. package/dist/chunk-1k7t7bnx.js.map +10 -0
  6. package/dist/chunk-5ahkew9c.js +806 -0
  7. package/dist/chunk-5ahkew9c.js.map +17 -0
  8. package/dist/chunk-6cpn7ht2.js +287 -0
  9. package/dist/chunk-6cpn7ht2.js.map +13 -0
  10. package/dist/chunk-6kctn20e.js +3529 -0
  11. package/dist/chunk-6kctn20e.js.map +20 -0
  12. package/dist/chunk-7xqj7aex.js +77 -0
  13. package/dist/chunk-7xqj7aex.js.map +11 -0
  14. package/dist/chunk-9p0ww3tk.js +41 -0
  15. package/dist/chunk-9p0ww3tk.js.map +10 -0
  16. package/dist/chunk-a92a7nrk.js +252 -0
  17. package/dist/chunk-a92a7nrk.js.map +10 -0
  18. package/dist/chunk-c500xe9z.js +33 -0
  19. package/dist/chunk-c500xe9z.js.map +10 -0
  20. package/dist/chunk-cds1qxsf.js +1644 -0
  21. package/dist/chunk-cds1qxsf.js.map +17 -0
  22. package/dist/chunk-e4407g8x.js +274 -0
  23. package/dist/chunk-e4407g8x.js.map +10 -0
  24. package/dist/chunk-e5pbggsh.js +363 -0
  25. package/dist/chunk-e5pbggsh.js.map +11 -0
  26. package/dist/chunk-edb07sjp.js +567 -0
  27. package/dist/chunk-edb07sjp.js.map +14 -0
  28. package/dist/chunk-exd0v74a.js +3012 -0
  29. package/dist/chunk-exd0v74a.js.map +32 -0
  30. package/dist/chunk-fgrme9tr.js +4398 -0
  31. package/dist/chunk-fgrme9tr.js.map +47 -0
  32. package/dist/chunk-fka9eqe1.js +581 -0
  33. package/dist/chunk-fka9eqe1.js.map +11 -0
  34. package/dist/chunk-g82jygez.js +108 -0
  35. package/dist/chunk-g82jygez.js.map +10 -0
  36. package/dist/chunk-ghs2j1fr.js +312 -0
  37. package/dist/chunk-ghs2j1fr.js.map +10 -0
  38. package/dist/chunk-gmy11efb.js +125 -0
  39. package/dist/chunk-gmy11efb.js.map +10 -0
  40. package/dist/chunk-gxma4c70.js +110 -0
  41. package/dist/chunk-gxma4c70.js.map +10 -0
  42. package/dist/chunk-hkdqhm34.js +61 -0
  43. package/dist/chunk-hkdqhm34.js.map +10 -0
  44. package/dist/chunk-hpa0cpzh.js +134 -0
  45. package/dist/chunk-hpa0cpzh.js.map +10 -0
  46. package/dist/chunk-hwy3n31w.js +21 -0
  47. package/dist/chunk-hwy3n31w.js.map +9 -0
  48. package/dist/chunk-j2behpy7.js +214 -0
  49. package/dist/chunk-j2behpy7.js.map +10 -0
  50. package/dist/chunk-jc0at0tc.js +102 -0
  51. package/dist/chunk-jc0at0tc.js.map +10 -0
  52. package/dist/chunk-jkqq5ef6.js +243 -0
  53. package/dist/chunk-jkqq5ef6.js.map +11 -0
  54. package/dist/chunk-jzkw2f01.js +51 -0
  55. package/dist/chunk-jzkw2f01.js.map +10 -0
  56. package/dist/chunk-jzz91jwh.js +70 -0
  57. package/dist/chunk-jzz91jwh.js.map +10 -0
  58. package/dist/chunk-k9z47mab.js +247 -0
  59. package/dist/chunk-k9z47mab.js.map +12 -0
  60. package/dist/chunk-n17yxpa8.js +23 -0
  61. package/dist/chunk-n17yxpa8.js.map +10 -0
  62. package/dist/chunk-naa09ags.js +2143 -0
  63. package/dist/chunk-naa09ags.js.map +15 -0
  64. package/dist/chunk-ns3ke88n.js +142 -0
  65. package/dist/chunk-ns3ke88n.js.map +10 -0
  66. package/dist/chunk-p3cr2ejg.js +1626 -0
  67. package/dist/chunk-p3cr2ejg.js.map +15 -0
  68. package/dist/chunk-q5bcpf23.js +2925 -0
  69. package/dist/chunk-q5bcpf23.js.map +20 -0
  70. package/dist/chunk-rafc55bs.js +424 -0
  71. package/dist/chunk-rafc55bs.js.map +11 -0
  72. package/dist/chunk-rbrxjvbj.js +2830 -0
  73. package/dist/chunk-rbrxjvbj.js.map +23 -0
  74. package/dist/chunk-sa874j5c.js +9 -0
  75. package/dist/chunk-sa874j5c.js.map +10 -0
  76. package/dist/chunk-sgsz2fpq.js +289 -0
  77. package/dist/chunk-sgsz2fpq.js.map +10 -0
  78. package/dist/chunk-sm6fh5c5.js +569 -0
  79. package/dist/chunk-sm6fh5c5.js.map +14 -0
  80. package/dist/chunk-t9zcg8f1.js +499 -0
  81. package/dist/chunk-t9zcg8f1.js.map +13 -0
  82. package/dist/chunk-vp2db42d.js +121 -0
  83. package/dist/chunk-vp2db42d.js.map +10 -0
  84. package/dist/chunk-w13jjf4a.js +46 -0
  85. package/dist/chunk-w13jjf4a.js.map +10 -0
  86. package/dist/chunk-x1arr7ze.js +63 -0
  87. package/dist/chunk-x1arr7ze.js.map +10 -0
  88. package/dist/chunk-xfq68rch.js +583 -0
  89. package/dist/chunk-xfq68rch.js.map +11 -0
  90. package/dist/main.js +132 -20
  91. package/dist/main.js.map +4 -4
  92. package/dist/runtime/scripts/faster-whisper-wrapper.py +87 -0
  93. package/dist/runtime/scripts/mcp-patchright-http.mjs +349 -0
  94. package/dist/runtime/src/agents/api-topic-agent-switch.ts +178 -0
  95. package/dist/runtime/src/agents/archiver.ts +396 -0
  96. package/dist/runtime/src/agents/auth-check.ts +64 -0
  97. package/dist/runtime/src/agents/claude-provider.ts +737 -0
  98. package/dist/runtime/src/agents/claude-registry.ts +115 -0
  99. package/dist/runtime/src/agents/codex-native-multi-agent.ts +177 -0
  100. package/dist/runtime/src/agents/codex-provider.ts +785 -0
  101. package/dist/runtime/src/agents/codex-registry.ts +115 -0
  102. package/dist/runtime/src/agents/codex-tree-kill.ts +365 -0
  103. package/dist/runtime/src/agents/contracts.ts +69 -0
  104. package/dist/runtime/src/agents/deep-map.ts +13 -0
  105. package/dist/runtime/src/agents/execution-host.ts +91 -0
  106. package/dist/runtime/src/agents/fixtures/claude-attachments.jsonl +2 -0
  107. package/dist/runtime/src/agents/fixtures/codex-shell.jsonl +5 -0
  108. package/dist/runtime/src/agents/fork.ts +65 -0
  109. package/dist/runtime/src/agents/hosted-agent.ts +48 -0
  110. package/dist/runtime/src/agents/idle-archiver.ts +128 -0
  111. package/dist/runtime/src/agents/index.ts +205 -0
  112. package/dist/runtime/src/agents/maestro-provider.ts +206 -0
  113. package/dist/runtime/src/agents/maestro-registry.ts +31 -0
  114. package/dist/runtime/src/agents/mcp-tools/ask-user.ts +280 -0
  115. package/dist/runtime/src/agents/mcp-tools/common.ts +21 -0
  116. package/dist/runtime/src/agents/mcp-tools/self-config.ts +220 -0
  117. package/dist/runtime/src/agents/mcp-tools/spawn-subagent.ts +525 -0
  118. package/dist/runtime/src/agents/mcp-tools/visuals.ts +88 -0
  119. package/dist/runtime/src/agents/model-catalog.ts +151 -0
  120. package/dist/runtime/src/agents/registry.ts +24 -0
  121. package/dist/runtime/src/agents/rollout/claude.ts +331 -0
  122. package/dist/runtime/src/agents/rollout/codex.ts +569 -0
  123. package/dist/runtime/src/agents/rollout/shared.ts +205 -0
  124. package/dist/runtime/src/agents/self-config-core.ts +415 -0
  125. package/dist/runtime/src/agents/task-events.ts +44 -0
  126. package/dist/runtime/src/agents/tool-format.ts +352 -0
  127. package/dist/runtime/src/agents/topic-agent-switch.ts +193 -0
  128. package/dist/runtime/src/agents/topic-cleanup.ts +231 -0
  129. package/dist/runtime/src/agents/vault-tool-policy.ts +33 -0
  130. package/dist/runtime/src/application/execute-external-user-turn.ts +23 -0
  131. package/dist/runtime/src/application/submit-user-message.ts +47 -0
  132. package/dist/runtime/src/application/switch-topic-effort.ts +48 -0
  133. package/dist/runtime/src/application/switch-topic-model.ts +79 -0
  134. package/dist/runtime/src/application/topic-service.ts +139 -0
  135. package/dist/runtime/src/application/vault-command.ts +170 -0
  136. package/dist/runtime/src/bus.ts +319 -0
  137. package/dist/runtime/src/index.ts +333 -0
  138. package/dist/runtime/src/mcp/agent-health-server.ts +309 -0
  139. package/dist/runtime/src/mcp/background-bash-server.ts +346 -0
  140. package/dist/runtime/src/mcp/canonical-bridge-config.ts +84 -0
  141. package/dist/runtime/src/mcp/canonical-proxy-server.ts +171 -0
  142. package/dist/runtime/src/mcp/dm-ipc.ts +60 -0
  143. package/dist/runtime/src/mcp/mcp-helpers.ts +40 -0
  144. package/dist/runtime/src/mcp/paddleocr-server.ts +105 -0
  145. package/dist/runtime/src/mcp/peer-bridge.ts +114 -0
  146. package/dist/runtime/src/mcp/runtime-spec.ts +134 -0
  147. package/dist/runtime/src/mcp/session-comm/bridge-ipc-config.ts +27 -0
  148. package/dist/runtime/src/mcp/session-comm/peer-forward.ts +165 -0
  149. package/dist/runtime/src/mcp/session-comm/runtime.ts +115 -0
  150. package/dist/runtime/src/mcp/session-comm/server.ts +649 -0
  151. package/dist/runtime/src/mcp/session-comm/topic-config.ts +131 -0
  152. package/dist/runtime/src/mcp/session-comm/topics.ts +229 -0
  153. package/dist/runtime/src/mcp/stdio-protect.ts +84 -0
  154. package/dist/runtime/src/mcp/system-health-server.ts +130 -0
  155. package/dist/runtime/src/mcp/task-server.ts +173 -0
  156. package/dist/runtime/src/mcp/token-stats-server.ts +98 -0
  157. package/dist/runtime/src/mcp/vault-http.ts +219 -0
  158. package/dist/runtime/src/mcp/vault-run.ts +153 -0
  159. package/dist/runtime/src/mcp/vault-server.ts +104 -0
  160. package/dist/runtime/src/mcp/wiki-server.ts +755 -0
  161. package/dist/runtime/src/media/file-events.ts +33 -0
  162. package/dist/runtime/src/media/text-extractor.ts +312 -0
  163. package/dist/runtime/src/media/video.ts +92 -0
  164. package/dist/runtime/src/outbox/file-ops.ts +210 -0
  165. package/dist/runtime/src/outbox/index.ts +8 -0
  166. package/dist/runtime/src/outbox/utils.ts +51 -0
  167. package/dist/runtime/src/platform/background-bash/manager.ts +279 -0
  168. package/dist/runtime/src/platform/config.ts +371 -0
  169. package/dist/runtime/src/platform/constants.ts +18 -0
  170. package/dist/runtime/src/platform/debug-users.ts +14 -0
  171. package/dist/runtime/src/platform/delay.ts +1 -0
  172. package/dist/runtime/src/platform/error.ts +9 -0
  173. package/dist/runtime/src/platform/file-utils.ts +16 -0
  174. package/dist/runtime/src/platform/jsonl.ts +202 -0
  175. package/dist/runtime/src/platform/lifecycle.ts +174 -0
  176. package/dist/runtime/src/platform/logger.ts +31 -0
  177. package/dist/runtime/src/platform/maestro-bootstrap-env.ts +3 -0
  178. package/dist/runtime/src/platform/mcp-config.ts +865 -0
  179. package/dist/runtime/src/platform/modules.ts +145 -0
  180. package/dist/runtime/src/platform/node-plugins.ts +46 -0
  181. package/dist/runtime/src/platform/playwright/manager.ts +1233 -0
  182. package/dist/runtime/src/prompts/agents/wiki-archiver.md +261 -0
  183. package/dist/runtime/src/prompts/builders.ts +357 -0
  184. package/dist/runtime/src/prompts/sessions/channel-system.md +48 -0
  185. package/dist/runtime/src/prompts/sessions/manager-system.md +37 -0
  186. package/dist/runtime/src/prompts/sessions/topic-system.md +47 -0
  187. package/dist/runtime/src/prompts/sessions/visual-design.md +86 -0
  188. package/dist/runtime/src/query/active-rooms.ts +532 -0
  189. package/dist/runtime/src/query/control.ts +313 -0
  190. package/dist/runtime/src/query/index.ts +24 -0
  191. package/dist/runtime/src/query/session-inbox-cleanup.ts +44 -0
  192. package/dist/runtime/src/query/session-inbox-path.ts +42 -0
  193. package/dist/runtime/src/query/state.ts +94 -0
  194. package/dist/runtime/src/query/types.ts +83 -0
  195. package/dist/runtime/src/runtime/ask-callbacks.ts +153 -0
  196. package/dist/runtime/src/runtime/attachments.ts +151 -0
  197. package/dist/runtime/src/runtime/background-sessions.ts +83 -0
  198. package/dist/runtime/src/runtime/channel-context.ts +107 -0
  199. package/dist/runtime/src/runtime/errors.ts +69 -0
  200. package/dist/runtime/src/runtime/event-heartbeat.ts +77 -0
  201. package/dist/runtime/src/runtime/file-hooks.ts +81 -0
  202. package/dist/runtime/src/runtime/footer.ts +23 -0
  203. package/dist/runtime/src/runtime/inbox.ts +946 -0
  204. package/dist/runtime/src/runtime/tasks.ts +56 -0
  205. package/dist/runtime/src/runtime/topic-config.ts +29 -0
  206. package/dist/runtime/src/runtime/turn-runner.ts +2286 -0
  207. package/dist/runtime/src/runtime/usage-alert.ts +84 -0
  208. package/dist/runtime/src/runtime/visual-html.ts +109 -0
  209. package/dist/runtime/src/runtime/visual-store.ts +430 -0
  210. package/dist/runtime/src/runtime/visuals.ts +171 -0
  211. package/dist/runtime/src/security/sanitize.ts +27 -0
  212. package/dist/runtime/src/security/sensitive-path.ts +34 -0
  213. package/dist/runtime/src/storage/activity-log.ts +152 -0
  214. package/dist/runtime/src/storage/api-messages.ts +617 -0
  215. package/dist/runtime/src/storage/api-topic-brief.ts +127 -0
  216. package/dist/runtime/src/storage/api-topic-config.ts +192 -0
  217. package/dist/runtime/src/storage/api-topics.ts +844 -0
  218. package/dist/runtime/src/storage/app-settings.ts +44 -0
  219. package/dist/runtime/src/storage/browser-profiles.ts +133 -0
  220. package/dist/runtime/src/storage/conversations.ts +268 -0
  221. package/dist/runtime/src/storage/forum/agent-settings.ts +20 -0
  222. package/dist/runtime/src/storage/forum/index.ts +4 -0
  223. package/dist/runtime/src/storage/forum/repository.ts +283 -0
  224. package/dist/runtime/src/storage/forum/schema.ts +300 -0
  225. package/dist/runtime/src/storage/forum-db.ts +23 -0
  226. package/dist/runtime/src/storage/runtime-events.ts +130 -0
  227. package/dist/runtime/src/storage/runtime-leases.ts +189 -0
  228. package/dist/runtime/src/storage/runtime-process-leases.ts +216 -0
  229. package/dist/runtime/src/storage/runtime-topic-state.ts +148 -0
  230. package/dist/runtime/src/storage/runtime-turn-requests.ts +300 -0
  231. package/dist/runtime/src/storage/self-schedules.ts +298 -0
  232. package/dist/runtime/src/storage/session-asks.ts +347 -0
  233. package/dist/runtime/src/storage/sqlite.ts +129 -0
  234. package/dist/runtime/src/storage/tasks.ts +179 -0
  235. package/dist/runtime/src/storage/token-stats.ts +144 -0
  236. package/dist/runtime/src/storage/topic-archive-state.ts +59 -0
  237. package/dist/runtime/src/storage/topic-archive.ts +74 -0
  238. package/dist/runtime/src/storage/topic-settings.ts +67 -0
  239. package/dist/runtime/src/storage/topic-transcript.ts +98 -0
  240. package/dist/runtime/src/storage/vault-crypto.ts +65 -0
  241. package/dist/runtime/src/storage/vault.ts +225 -0
  242. package/dist/runtime/src/storage/wiki-summary-names.ts +33 -0
  243. package/dist/runtime/src/storage/wiki.ts +85 -0
  244. package/dist/runtime/src/topics/create.ts +123 -0
  245. package/dist/runtime/src/topics/derive.ts +398 -0
  246. package/dist/runtime/src/topics/lifecycle.ts +311 -0
  247. package/dist/runtime/src/topics/links.ts +7 -0
  248. package/dist/runtime/src/topics/personal-general.ts +65 -0
  249. package/dist/runtime/src/topics/session.ts +381 -0
  250. package/dist/runtime/src/types/api.ts +497 -0
  251. package/dist/runtime/src/types.ts +255 -0
  252. package/dist/runtime/src/version.ts +1 -0
  253. package/dist/runtime/tsconfig.json +13 -0
  254. package/package.json +16 -3
  255. package/dist/main.d.ts +0 -3
  256. package/dist/main.d.ts.map +0 -1
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Common context carried through the attachment/prompt-build pipeline.
3
+ * Used by buildPromptFromMessage and related helpers.
4
+ */
5
+ export interface SessionContext {
6
+ userId: number;
7
+ topicName?: string;
8
+ userDir?: string;
9
+ sessionType?: "dm" | "forum" | "ephemeral" | "manager" | "cron";
10
+ }
11
+
12
+ export interface TokenUsage {
13
+ /** Aggregate billable input across every model call made during this turn. */
14
+ inputTokens: number;
15
+ outputTokens: number;
16
+ cacheCreationInputTokens?: number;
17
+ cacheReadInputTokens?: number;
18
+ /** Provider-reported query cost when available. */
19
+ costUsd?: number;
20
+ /** Tokens occupied by the latest model call, not aggregate turn spend. */
21
+ contextTokens?: number;
22
+ /** Provider-reported context window for the latest model call. */
23
+ contextWindow?: number;
24
+ }
25
+
26
+ /** Agent identifier — one of the supported AI provider backends. */
27
+ export type AgentKind = "maestro" | "claude" | "codex";
28
+
29
+ export const SUPPORTED_AGENTS: readonly AgentKind[] = ["maestro", "claude", "codex"] as const;
30
+
31
+ export function isAgentKind(value: unknown): value is AgentKind {
32
+ return typeof value === "string" && (SUPPORTED_AGENTS as readonly string[]).includes(value);
33
+ }
34
+
35
+ /**
36
+ * Per-agent supported reasoning efforts. Single source of truth for both the
37
+ * `EffortLevel` type and each registry's `validEfforts` runtime list — the
38
+ * registries import these directly so adding a value in one place
39
+ * propagates to validation, footer rendering, and zod enums.
40
+ *
41
+ * Claude SDK rejects 'minimal'; Codex SDK rejects 'max'. The two sets
42
+ * intersect on low/medium/high/xhigh. Maestro (TS port) currently piggybacks
43
+ * on the Anthropic provider, so its efforts mirror the Claude set; this can
44
+ * narrow per-provider once Phase 5 lands.
45
+ *
46
+ * 'minimal' removed from codex: Codex API rejects it when default tools
47
+ * (image_gen, web_search) are active, making agent sessions unusable.
48
+ */
49
+ export const CLAUDE_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"] as const;
50
+ export const CODEX_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"] as const;
51
+ export const MAESTRO_EFFORT_VALUES = ["low", "medium", "high", "xhigh", "max"] as const;
52
+
53
+ export type EffortLevel =
54
+ | (typeof CLAUDE_EFFORT_VALUES)[number]
55
+ | (typeof CODEX_EFFORT_VALUES)[number]
56
+ | (typeof MAESTRO_EFFORT_VALUES)[number];
57
+
58
+ /**
59
+ * Runtime iteration list (used by zod enums and any callers that need to
60
+ * loop over every accepted value). Manually ordered for readability; the
61
+ * `satisfies` check fails the build if an entry here isn't covered by the
62
+ * per-agent unions above.
63
+ */
64
+ export const EFFORT_VALUES = [
65
+ "low",
66
+ "medium",
67
+ "high",
68
+ "xhigh",
69
+ "max",
70
+ ] as const satisfies readonly EffortLevel[];
71
+
72
+ /**
73
+ * Normalized events yielded by any agent provider (claudeProvider, codexProvider).
74
+ * The handler/event-processor consumes these without caring which backend produced them.
75
+ *
76
+ * `user_message` is the lone "into-the-log" variant — no provider yields it.
77
+ * The query handler writes it directly to the conversation log right before
78
+ * `runAgent()` starts, so cross-agent rollout reconstruction can pair every
79
+ * assistant turn with the user prompt that triggered it. Consumers that only
80
+ * react to provider output (e.g. processAgentEvent) can safely ignore it.
81
+ */
82
+ /**
83
+ * Wire-safe projection of one task, carried by the `tasks` UnifiedEvent.
84
+ *
85
+ * This is also the on-disk shape of Otium's shared task store, so claude,
86
+ * codex, and maestro render the same live panel from the same source of truth.
87
+ */
88
+ export interface TaskSnapshot {
89
+ id: string;
90
+ subject: string;
91
+ status: "pending" | "in_progress" | "completed";
92
+ /** Task ids this one is blocked by; omitted when empty. */
93
+ blockedBy?: string[];
94
+ /** Present-continuous label for spinners, when set. */
95
+ activeForm?: string;
96
+ /** Owner / agent name for multi-agent runs, when set. */
97
+ owner?: string;
98
+ }
99
+
100
+ export type UnifiedEvent =
101
+ | { type: "user_message"; content: string }
102
+ | { type: "session"; sessionId: string }
103
+ | {
104
+ type: "tool_use";
105
+ name: string;
106
+ input: Record<string, unknown>;
107
+ /** Provider-assigned id so the client can match tool_use→tool_result pairs. */
108
+ toolUseId?: string;
109
+ }
110
+ | { type: "tool_progress"; toolName: string; elapsed: number }
111
+ | { type: "tool_use_summary"; summary: string }
112
+ // Provider reasoning/thinking summary text (Codex `reasoning` items; Claude
113
+ // extended-thinking). Surfaced so background runs (cron/archiver) show the
114
+ // agent's thought process, not just tool calls.
115
+ | { type: "reasoning"; content: string }
116
+ // Full task-list snapshot (replace, not delta) from Otium's shared task
117
+ // store. Provider-native task/todo stores are not authoritative.
118
+ | { type: "tasks"; tasks: TaskSnapshot[] }
119
+ | {
120
+ type: "tool_result";
121
+ toolUseId: string;
122
+ content: string;
123
+ metadata?: {
124
+ truncatedForModel: boolean;
125
+ originalBytes: number;
126
+ returnedBytes: number;
127
+ omittedBytes?: number;
128
+ outputPath?: string;
129
+ };
130
+ }
131
+ | { type: "text_delta"; content: string }
132
+ | { type: "text"; content: string }
133
+ | { type: "result"; content: string; stopReason: string; usage?: TokenUsage }
134
+ | { type: "file"; path: string; source: string; origin: "tag" | "extension" }
135
+ | {
136
+ type: "error";
137
+ content: string;
138
+ usage?: TokenUsage;
139
+ code?: "budget_exceeded";
140
+ }
141
+ | { type: "status"; content: string };
142
+
143
+ export interface AgentInputAttachment {
144
+ id: string;
145
+ type: "image" | "file" | "audio";
146
+ filename: string;
147
+ mimeType: string;
148
+ sizeBytes: number;
149
+ path: string;
150
+ }
151
+
152
+ /** Worker-side runtime tools proxy user-facing state back to the canonical
153
+ * hub topic identified here. */
154
+ export interface PeerRuntimeBridgeContext {
155
+ hubCellId: string;
156
+ hostTopicId: string;
157
+ hostQueryId: string;
158
+ canSpawnSubagents: boolean;
159
+ }
160
+
161
+ export interface AgentQueryOptions {
162
+ agent: AgentKind;
163
+ prompt: string;
164
+ attachments?: AgentInputAttachment[];
165
+ sessionId?: string | null;
166
+ cwd: string;
167
+ systemPrompt: string;
168
+ userId?: string;
169
+ session?: string;
170
+ playwrightPort?: number;
171
+ playwrightCapability?: string;
172
+ bgBashPort?: number;
173
+ sessionType?: "dm" | "forum" | "ephemeral" | "manager" | "cron";
174
+ /** API topic id (REST/WS world). Carries per-query topic context for MCP servers. */
175
+ topicId?: string;
176
+ /** API query id for the currently running turn. Used by runtime MCP tools. */
177
+ queryId?: string;
178
+ /** Optional wiki-memory topic id. Derived topics use their root origin here
179
+ * while other per-topic MCP servers keep `topicId` bound to the live room. */
180
+ wikiTopicId?: string;
181
+ /** Whether self-config MCP may enqueue an automatic continue turn after set_* changes. */
182
+ autoContinue?: boolean;
183
+ abortController?: AbortController;
184
+ model?: string;
185
+ /** Provider-side hard budget when the selected SDK supports one. */
186
+ maxBudgetUsd?: number;
187
+ depth?: number;
188
+ agents?: Record<
189
+ string,
190
+ {
191
+ description: string;
192
+ prompt: string;
193
+ model?: string;
194
+ tools?: string[];
195
+ maxTurns?: number;
196
+ effort?: EffortLevel | number;
197
+ }
198
+ >;
199
+ effort?: EffortLevel;
200
+ /**
201
+ * Per-API-call `max_tokens` ceiling on the assistant's output. Wired
202
+ * through to the underlying provider request body for every agent
203
+ * (claude/codex/maestro). Omit to inherit each provider SDK's per-model
204
+ * default — for maestro that's the v0.1.21+ `getNativeMaxOutputTokens`
205
+ * catalog (deepseek-pro=64K, deepseek-flash=32K).
206
+ *
207
+ * Pass an explicit number when a specific topic / surface needs a tighter
208
+ * latency cap or a higher ceiling for long-form generation (legal
209
+ * report writing, multi-K Write/Edit file bodies). Pre-0.1.21 maestro
210
+ * builds silently clamped at 4096 and truncated outputs mid-string;
211
+ * setting this field is now the supported way to lift that ceiling.
212
+ */
213
+ maxTokens?: number;
214
+ /**
215
+ * v0.1.22+: Claude-Code-style deferred tool catalog + `ToolSearch` built-in.
216
+ *
217
+ * Wired straight through to `maestro-agent-sdk`'s
218
+ * `AgentQueryOptions.enableToolSearch`. When `true`, the maestro provider
219
+ * registers every MCP tool as deferred — schemas stay off the wire until
220
+ * the model promotes them via `ToolSearch("select:Name1,Name2")` or
221
+ * `ToolSearch("keyword")`. Active set persists across resume.
222
+ *
223
+ * Otium's maestro provider supplies `true` when the caller leaves this
224
+ * option unset, because most forum turns carry enough MCP surface for the
225
+ * reminder-token savings to outweigh the first-use `ToolSearch` round-trip.
226
+ * Callers can still pass `false` per call when a narrow surface or
227
+ * latency-sensitive workflow is better served by eager MCP schemas.
228
+ *
229
+ * No-op for claude / codex agents — they have their own deferred-tool
230
+ * machinery owned by their respective SDKs.
231
+ */
232
+ enableToolSearch?: boolean;
233
+ /**
234
+ * Claude-Code-compatible exact tool denylist. Maestro v0.1.42+ hides these
235
+ * tools from provider schemas / ToolSearch and blocks dispatch if a stale
236
+ * call still arrives. Claude maps this to its SDK option. Codex does not
237
+ * support this name-based list; its provider-native multi-agent tool family
238
+ * is disabled separately through the Codex feature config.
239
+ */
240
+ disallowedTools?: readonly string[];
241
+ mcpEnabled?: string[] | null;
242
+ peerBridge?: PeerRuntimeBridgeContext;
243
+ mcpExtra?: Record<string, unknown>;
244
+ /**
245
+ * true for silent fork runs generating ask_session replies — restricts session-comm
246
+ * outbound tools (ask/tell/abort) so the forked session can only produce text
247
+ */
248
+ silent?: boolean;
249
+ }
250
+
251
+ /** State file written to data/users/{userId}/active-queries/{topic}.json while a query is running. */
252
+ export interface QueryState {
253
+ task?: string; // first 100 chars of prompt, newlines normalized
254
+ since: string; // ISO timestamp
255
+ }
@@ -0,0 +1 @@
1
+ export const NEGOTIUM_VERSION = "0.1.8";
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "baseUrl": ".",
7
+ "paths": {
8
+ "#*": [
9
+ "src/*.ts"
10
+ ]
11
+ }
12
+ }
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "negotium",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "Install the Negotium multi-agent runtime and CLI with one package",
6
6
  "license": "Apache-2.0",
@@ -28,17 +28,30 @@
28
28
  "access": "public"
29
29
  },
30
30
  "scripts": {
31
- "build": "bun ../../scripts/build-package.ts src/main.ts",
31
+ "build": "bun ../../scripts/build-negotium-package.ts",
32
32
  "check": "bunx tsc --noEmit",
33
33
  "lint": "biome check",
34
34
  "prepack": "bun run build"
35
35
  },
36
36
  "dependencies": {
37
- "@negotium/cli": "0.1.7"
37
+ "@anthropic-ai/claude-agent-sdk": "^0.3.210",
38
+ "@anthropic-ai/sdk": "^0.111.0",
39
+ "@modelcontextprotocol/sdk": "^1.29.0",
40
+ "@openai/codex-sdk": "0.144.4",
41
+ "maestro-agent-sdk": "0.1.45",
42
+ "mcp-patchright": "0.1.10",
43
+ "node-telegram-bot-api": "^1.1.2",
44
+ "pino": "^10.3.1",
45
+ "pino-pretty": "^13.1.3",
46
+ "tsx": "^4.22.4",
47
+ "zod": "^4.3.6"
38
48
  },
39
49
  "devDependencies": {
40
50
  "@types/node": "^20",
41
51
  "bun-types": "^1.3.11",
42
52
  "typescript": "^5"
53
+ },
54
+ "imports": {
55
+ "#*": "./dist/runtime/src/*.ts"
43
56
  }
44
57
  }
package/dist/main.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bun
2
- export {};
3
- //# sourceMappingURL=main.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,CAAC"}