botinabox 2.4.3 → 2.5.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.
Files changed (276) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/bin/botinabox.mjs +1 -1
  4. package/dist/cli.js +0 -0
  5. package/dist/connectors/google/index.d.ts +67 -1
  6. package/dist/connectors/google/index.js +240 -0
  7. package/dist/index.js +19 -5
  8. package/package.json +100 -99
  9. package/dist/channels/discord/adapter.d.ts +0 -32
  10. package/dist/channels/discord/adapter.js +0 -70
  11. package/dist/channels/discord/inbound.d.ts +0 -25
  12. package/dist/channels/discord/inbound.js +0 -24
  13. package/dist/channels/discord/models.d.ts +0 -8
  14. package/dist/channels/discord/models.js +0 -5
  15. package/dist/channels/discord/outbound.d.ts +0 -14
  16. package/dist/channels/discord/outbound.js +0 -38
  17. package/dist/channels/slack/adapter.d.ts +0 -33
  18. package/dist/channels/slack/adapter.js +0 -74
  19. package/dist/channels/slack/inbound.d.ts +0 -59
  20. package/dist/channels/slack/inbound.js +0 -96
  21. package/dist/channels/slack/models.d.ts +0 -9
  22. package/dist/channels/slack/models.js +0 -5
  23. package/dist/channels/slack/outbound.d.ts +0 -12
  24. package/dist/channels/slack/outbound.js +0 -18
  25. package/dist/channels/slack/transcribe.d.ts +0 -41
  26. package/dist/channels/slack/transcribe.js +0 -106
  27. package/dist/channels/webhook/adapter.d.ts +0 -23
  28. package/dist/channels/webhook/adapter.js +0 -86
  29. package/dist/channels/webhook/hmac.d.ts +0 -13
  30. package/dist/channels/webhook/hmac.js +0 -26
  31. package/dist/channels/webhook/models.d.ts +0 -9
  32. package/dist/channels/webhook/models.js +0 -5
  33. package/dist/channels/webhook/server.d.ts +0 -20
  34. package/dist/channels/webhook/server.js +0 -91
  35. package/dist/chat-pipeline-C-XlLGNl.d.ts +0 -648
  36. package/dist/chat-pipeline-CR1KF6eX.d.ts +0 -652
  37. package/dist/chat-pipeline-DisuC8SB.d.ts +0 -643
  38. package/dist/chunk-2LGXQPEA.js +0 -41
  39. package/dist/chunk-3X3YKI4T.js +0 -357
  40. package/dist/chunk-D47AIFOD.js +0 -351
  41. package/dist/chunk-DSNJKNEW.js +0 -328
  42. package/dist/chunk-GS2JFL6I.js +0 -144
  43. package/dist/chunk-J6S6QMUY.js +0 -144
  44. package/dist/chunk-QLA6YOFN.js +0 -22
  45. package/dist/chunk-UACT2WXX.js +0 -381
  46. package/dist/cli/templates/config.yml.d.ts +0 -7
  47. package/dist/cli/templates/config.yml.js +0 -61
  48. package/dist/cli/templates/env.d.ts +0 -1
  49. package/dist/cli/templates/env.js +0 -30
  50. package/dist/cli/templates/index.ts.d.ts +0 -2
  51. package/dist/cli/templates/index.ts.js +0 -30
  52. package/dist/cli/templates/package.json.d.ts +0 -5
  53. package/dist/cli/templates/package.json.js +0 -28
  54. package/dist/connector-DDahQw-2.d.ts +0 -63
  55. package/dist/connectors/google/calendar-connector.d.ts +0 -40
  56. package/dist/connectors/google/calendar-connector.js +0 -243
  57. package/dist/connectors/google/gmail-connector.d.ts +0 -42
  58. package/dist/connectors/google/gmail-connector.js +0 -345
  59. package/dist/connectors/google/oauth.d.ts +0 -48
  60. package/dist/connectors/google/oauth.js +0 -112
  61. package/dist/connectors/google/types.d.ts +0 -78
  62. package/dist/connectors/google/types.js +0 -2
  63. package/dist/core/chat/auto-discovery.d.ts +0 -16
  64. package/dist/core/chat/auto-discovery.js +0 -54
  65. package/dist/core/chat/channel-registry.d.ts +0 -45
  66. package/dist/core/chat/channel-registry.js +0 -96
  67. package/dist/core/chat/chat-pipeline.d.ts +0 -113
  68. package/dist/core/chat/chat-pipeline.js +0 -395
  69. package/dist/core/chat/chat-responder.d.ts +0 -90
  70. package/dist/core/chat/chat-responder.js +0 -185
  71. package/dist/core/chat/formatter.d.ts +0 -11
  72. package/dist/core/chat/formatter.js +0 -60
  73. package/dist/core/chat/index.d.ts +0 -24
  74. package/dist/core/chat/index.js +0 -18
  75. package/dist/core/chat/message-interpreter.d.ts +0 -91
  76. package/dist/core/chat/message-interpreter.js +0 -166
  77. package/dist/core/chat/message-store.d.ts +0 -66
  78. package/dist/core/chat/message-store.js +0 -131
  79. package/dist/core/chat/notification-queue.d.ts +0 -34
  80. package/dist/core/chat/notification-queue.js +0 -111
  81. package/dist/core/chat/pipeline.d.ts +0 -38
  82. package/dist/core/chat/pipeline.js +0 -89
  83. package/dist/core/chat/policies.d.ts +0 -16
  84. package/dist/core/chat/policies.js +0 -25
  85. package/dist/core/chat/routing.d.ts +0 -17
  86. package/dist/core/chat/routing.js +0 -36
  87. package/dist/core/chat/session-key.d.ts +0 -30
  88. package/dist/core/chat/session-key.js +0 -65
  89. package/dist/core/chat/session-manager.d.ts +0 -17
  90. package/dist/core/chat/session-manager.js +0 -23
  91. package/dist/core/chat/text-chunker.d.ts +0 -9
  92. package/dist/core/chat/text-chunker.js +0 -48
  93. package/dist/core/chat/triage-router.d.ts +0 -75
  94. package/dist/core/chat/triage-router.js +0 -142
  95. package/dist/core/chat/types.d.ts +0 -5
  96. package/dist/core/chat/types.js +0 -5
  97. package/dist/core/config/defaults.d.ts +0 -2
  98. package/dist/core/config/defaults.js +0 -38
  99. package/dist/core/config/index.d.ts +0 -6
  100. package/dist/core/config/index.js +0 -4
  101. package/dist/core/config/interpolate.d.ts +0 -5
  102. package/dist/core/config/interpolate.js +0 -27
  103. package/dist/core/config/loader.d.ts +0 -24
  104. package/dist/core/config/loader.js +0 -59
  105. package/dist/core/config/schema.d.ts +0 -5
  106. package/dist/core/config/schema.js +0 -119
  107. package/dist/core/data/core-entity-contexts.d.ts +0 -14
  108. package/dist/core/data/core-entity-contexts.js +0 -197
  109. package/dist/core/data/core-migrations.d.ts +0 -5
  110. package/dist/core/data/core-migrations.js +0 -45
  111. package/dist/core/data/core-schema.d.ts +0 -6
  112. package/dist/core/data/core-schema.js +0 -454
  113. package/dist/core/data/data-store.d.ts +0 -67
  114. package/dist/core/data/data-store.js +0 -218
  115. package/dist/core/data/domain-entity-contexts.d.ts +0 -29
  116. package/dist/core/data/domain-entity-contexts.js +0 -321
  117. package/dist/core/data/domain-schema.d.ts +0 -36
  118. package/dist/core/data/domain-schema.js +0 -323
  119. package/dist/core/data/index.d.ts +0 -7
  120. package/dist/core/data/index.js +0 -7
  121. package/dist/core/data/types.d.ts +0 -111
  122. package/dist/core/data/types.js +0 -1
  123. package/dist/core/hooks/hook-bus.d.ts +0 -18
  124. package/dist/core/hooks/hook-bus.js +0 -120
  125. package/dist/core/hooks/index.d.ts +0 -2
  126. package/dist/core/hooks/index.js +0 -1
  127. package/dist/core/hooks/types.d.ts +0 -19
  128. package/dist/core/hooks/types.js +0 -1
  129. package/dist/core/index.d.ts +0 -4
  130. package/dist/core/index.js +0 -4
  131. package/dist/core/llm/auto-discovery.d.ts +0 -11
  132. package/dist/core/llm/auto-discovery.js +0 -49
  133. package/dist/core/llm/cost-tracker.d.ts +0 -6
  134. package/dist/core/llm/cost-tracker.js +0 -38
  135. package/dist/core/llm/index.d.ts +0 -4
  136. package/dist/core/llm/index.js +0 -3
  137. package/dist/core/llm/model-router.d.ts +0 -25
  138. package/dist/core/llm/model-router.js +0 -49
  139. package/dist/core/llm/provider-registry.d.ts +0 -9
  140. package/dist/core/llm/provider-registry.js +0 -25
  141. package/dist/core/llm/types.d.ts +0 -2
  142. package/dist/core/llm/types.js +0 -2
  143. package/dist/core/orchestrator/adapters/api-adapter.d.ts +0 -34
  144. package/dist/core/orchestrator/adapters/api-adapter.js +0 -88
  145. package/dist/core/orchestrator/adapters/cli-adapter.d.ts +0 -22
  146. package/dist/core/orchestrator/adapters/cli-adapter.js +0 -69
  147. package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +0 -35
  148. package/dist/core/orchestrator/adapters/deterministic-adapter.js +0 -75
  149. package/dist/core/orchestrator/adapters/env-whitelist.d.ts +0 -4
  150. package/dist/core/orchestrator/adapters/env-whitelist.js +0 -27
  151. package/dist/core/orchestrator/adapters/output-extractor.d.ts +0 -11
  152. package/dist/core/orchestrator/adapters/output-extractor.js +0 -59
  153. package/dist/core/orchestrator/adapters/process-manager.d.ts +0 -15
  154. package/dist/core/orchestrator/adapters/process-manager.js +0 -26
  155. package/dist/core/orchestrator/adapters/tool-loop.d.ts +0 -22
  156. package/dist/core/orchestrator/adapters/tool-loop.js +0 -66
  157. package/dist/core/orchestrator/agent-registry.d.ts +0 -31
  158. package/dist/core/orchestrator/agent-registry.js +0 -135
  159. package/dist/core/orchestrator/budget-controller.d.ts +0 -19
  160. package/dist/core/orchestrator/budget-controller.js +0 -73
  161. package/dist/core/orchestrator/chain-guard.d.ts +0 -14
  162. package/dist/core/orchestrator/chain-guard.js +0 -23
  163. package/dist/core/orchestrator/circuit-breaker.d.ts +0 -65
  164. package/dist/core/orchestrator/circuit-breaker.js +0 -159
  165. package/dist/core/orchestrator/claude-stream-parser.d.ts +0 -31
  166. package/dist/core/orchestrator/claude-stream-parser.js +0 -99
  167. package/dist/core/orchestrator/config-revisions.d.ts +0 -6
  168. package/dist/core/orchestrator/config-revisions.js +0 -17
  169. package/dist/core/orchestrator/dependency-resolver.d.ts +0 -20
  170. package/dist/core/orchestrator/dependency-resolver.js +0 -78
  171. package/dist/core/orchestrator/governance-gate.d.ts +0 -110
  172. package/dist/core/orchestrator/governance-gate.js +0 -170
  173. package/dist/core/orchestrator/learning-pipeline.d.ts +0 -109
  174. package/dist/core/orchestrator/learning-pipeline.js +0 -249
  175. package/dist/core/orchestrator/loop-detector.d.ts +0 -51
  176. package/dist/core/orchestrator/loop-detector.js +0 -133
  177. package/dist/core/orchestrator/ndjson-logger.d.ts +0 -6
  178. package/dist/core/orchestrator/ndjson-logger.js +0 -18
  179. package/dist/core/orchestrator/permission-relay.d.ts +0 -72
  180. package/dist/core/orchestrator/permission-relay.js +0 -164
  181. package/dist/core/orchestrator/run-manager.d.ts +0 -31
  182. package/dist/core/orchestrator/run-manager.js +0 -178
  183. package/dist/core/orchestrator/scheduler.d.ts +0 -70
  184. package/dist/core/orchestrator/scheduler.js +0 -198
  185. package/dist/core/orchestrator/secret-store.d.ts +0 -57
  186. package/dist/core/orchestrator/secret-store.js +0 -171
  187. package/dist/core/orchestrator/session-manager.d.ts +0 -13
  188. package/dist/core/orchestrator/session-manager.js +0 -66
  189. package/dist/core/orchestrator/task-queue.d.ts +0 -34
  190. package/dist/core/orchestrator/task-queue.js +0 -83
  191. package/dist/core/orchestrator/template-interpolate.d.ts +0 -5
  192. package/dist/core/orchestrator/template-interpolate.js +0 -18
  193. package/dist/core/orchestrator/user-registry.d.ts +0 -47
  194. package/dist/core/orchestrator/user-registry.js +0 -76
  195. package/dist/core/orchestrator/wakeup-queue.d.ts +0 -9
  196. package/dist/core/orchestrator/wakeup-queue.js +0 -45
  197. package/dist/core/orchestrator/workflow-engine.d.ts +0 -47
  198. package/dist/core/orchestrator/workflow-engine.js +0 -204
  199. package/dist/core/security/audit.d.ts +0 -20
  200. package/dist/core/security/audit.js +0 -33
  201. package/dist/core/security/column-validator.d.ts +0 -20
  202. package/dist/core/security/column-validator.js +0 -37
  203. package/dist/core/security/index.d.ts +0 -5
  204. package/dist/core/security/index.js +0 -5
  205. package/dist/core/security/process-env.d.ts +0 -13
  206. package/dist/core/security/process-env.js +0 -49
  207. package/dist/core/security/sanitizer.d.ts +0 -11
  208. package/dist/core/security/sanitizer.js +0 -39
  209. package/dist/core/security/types.d.ts +0 -11
  210. package/dist/core/security/types.js +0 -1
  211. package/dist/core/update/auto-update.d.ts +0 -21
  212. package/dist/core/update/auto-update.js +0 -102
  213. package/dist/core/update/backup-manager.d.ts +0 -7
  214. package/dist/core/update/backup-manager.js +0 -24
  215. package/dist/core/update/index.d.ts +0 -8
  216. package/dist/core/update/index.js +0 -6
  217. package/dist/core/update/migration-hooks.d.ts +0 -11
  218. package/dist/core/update/migration-hooks.js +0 -10
  219. package/dist/core/update/types.d.ts +0 -11
  220. package/dist/core/update/types.js +0 -1
  221. package/dist/core/update/update-checker.d.ts +0 -11
  222. package/dist/core/update/update-checker.js +0 -63
  223. package/dist/core/update/update-manager.d.ts +0 -25
  224. package/dist/core/update/update-manager.js +0 -101
  225. package/dist/core/update/version-utils.d.ts +0 -6
  226. package/dist/core/update/version-utils.js +0 -34
  227. package/dist/gmail-connector-2FVYTQJH.js +0 -6
  228. package/dist/gmail-connector-MNUBRNFM.js +0 -6
  229. package/dist/gmail-connector-PS2VLGNE.js +0 -6
  230. package/dist/gmail-connector-ULSMN6X2.js +0 -6
  231. package/dist/gmail-connector-URRFX6A3.js +0 -6
  232. package/dist/inbound-AFBUPSPG.js +0 -10
  233. package/dist/inbound-AFOHYNUY.js +0 -6
  234. package/dist/inbound-CGIXRXGC.js +0 -8
  235. package/dist/inbound-MCOLRH6U.js +0 -10
  236. package/dist/inbound-SNEMBLGA.js +0 -6
  237. package/dist/inbound-ZJHAYVMF.js +0 -10
  238. package/dist/provider-qqJYv9nv.d.ts +0 -75
  239. package/dist/providers/anthropic/models.d.ts +0 -2
  240. package/dist/providers/anthropic/models.js +0 -29
  241. package/dist/providers/anthropic/provider.d.ts +0 -13
  242. package/dist/providers/anthropic/provider.js +0 -119
  243. package/dist/providers/anthropic/tool-converter.d.ts +0 -10
  244. package/dist/providers/anthropic/tool-converter.js +0 -7
  245. package/dist/providers/ollama/provider.d.ts +0 -17
  246. package/dist/providers/ollama/provider.js +0 -185
  247. package/dist/providers/openai/models.d.ts +0 -2
  248. package/dist/providers/openai/models.js +0 -29
  249. package/dist/providers/openai/provider.d.ts +0 -13
  250. package/dist/providers/openai/provider.js +0 -163
  251. package/dist/providers/openai/tool-converter.d.ts +0 -10
  252. package/dist/providers/openai/tool-converter.js +0 -10
  253. package/dist/shared/constants.d.ts +0 -50
  254. package/dist/shared/constants.js +0 -64
  255. package/dist/shared/index.d.ts +0 -14
  256. package/dist/shared/index.js +0 -14
  257. package/dist/shared/types/agent.d.ts +0 -36
  258. package/dist/shared/types/agent.js +0 -2
  259. package/dist/shared/types/channel.d.ts +0 -70
  260. package/dist/shared/types/channel.js +0 -2
  261. package/dist/shared/types/config.d.ts +0 -111
  262. package/dist/shared/types/config.js +0 -2
  263. package/dist/shared/types/connector.d.ts +0 -77
  264. package/dist/shared/types/connector.js +0 -2
  265. package/dist/shared/types/execution.d.ts +0 -29
  266. package/dist/shared/types/execution.js +0 -2
  267. package/dist/shared/types/provider.d.ts +0 -73
  268. package/dist/shared/types/provider.js +0 -2
  269. package/dist/shared/types/task.d.ts +0 -47
  270. package/dist/shared/types/task.js +0 -2
  271. package/dist/shared/types/workflow.d.ts +0 -39
  272. package/dist/shared/types/workflow.js +0 -2
  273. package/dist/shared/utils.d.ts +0 -6
  274. package/dist/shared/utils.js +0 -13
  275. package/dist/update-check.d.ts +0 -5
  276. package/dist/update-check.js +0 -56
@@ -1,185 +0,0 @@
1
- export class OllamaProvider {
2
- id = 'ollama';
3
- displayName = 'Ollama';
4
- baseUrl;
5
- cachedModels = [];
6
- cacheTimestamp = 0;
7
- cacheTtlMs = 5 * 60 * 1000; // 5 minutes
8
- constructor({ baseUrl = 'http://localhost:11434' } = {}) {
9
- this.baseUrl = baseUrl.replace(/\/$/, '');
10
- }
11
- get models() {
12
- return this.cachedModels;
13
- }
14
- serializeTools(_tools) {
15
- // Ollama uses a similar format to OpenAI for tools
16
- return _tools.map((tool) => ({
17
- type: 'function',
18
- function: {
19
- name: tool.name,
20
- description: tool.description,
21
- parameters: tool.parameters,
22
- },
23
- }));
24
- }
25
- async getModels() {
26
- const now = Date.now();
27
- if (this.cachedModels.length > 0 && now - this.cacheTimestamp < this.cacheTtlMs) {
28
- return this.cachedModels;
29
- }
30
- try {
31
- const response = await fetch(`${this.baseUrl}/api/tags`);
32
- if (!response.ok) {
33
- return [];
34
- }
35
- const data = (await response.json());
36
- this.cachedModels = data.models.map((m) => ({
37
- id: m.name,
38
- displayName: m.name,
39
- contextWindow: 128000,
40
- maxOutputTokens: 4096,
41
- capabilities: ['chat', 'streaming'],
42
- }));
43
- this.cacheTimestamp = now;
44
- return this.cachedModels;
45
- }
46
- catch {
47
- return [];
48
- }
49
- }
50
- async chat(params) {
51
- const { messages, system, model, maxTokens, temperature } = params;
52
- const ollamaMessages = [];
53
- if (system) {
54
- ollamaMessages.push({ role: 'system', content: system });
55
- }
56
- for (const msg of messages) {
57
- const content = typeof msg.content === 'string'
58
- ? msg.content
59
- : msg.content
60
- .filter((b) => b.type === 'text')
61
- .map((b) => (b.type === 'text' ? b.text : ''))
62
- .join('');
63
- ollamaMessages.push({
64
- role: msg.role,
65
- content,
66
- });
67
- }
68
- const body = {
69
- model,
70
- messages: ollamaMessages,
71
- stream: false,
72
- };
73
- if (maxTokens !== undefined) {
74
- body['options'] = { ...(body['options'] ?? {}), num_predict: maxTokens };
75
- }
76
- if (temperature !== undefined) {
77
- body['options'] = { ...(body['options'] ?? {}), temperature };
78
- }
79
- const response = await fetch(`${this.baseUrl}/api/chat`, {
80
- method: 'POST',
81
- headers: { 'Content-Type': 'application/json' },
82
- body: JSON.stringify(body),
83
- signal: params.abortSignal,
84
- });
85
- if (!response.ok) {
86
- throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);
87
- }
88
- const data = (await response.json());
89
- return {
90
- content: data.message.content,
91
- usage: {
92
- inputTokens: data.prompt_eval_count ?? 0,
93
- outputTokens: data.eval_count ?? 0,
94
- },
95
- model: data.model,
96
- stopReason: 'end_turn',
97
- };
98
- }
99
- async *chatStream(params) {
100
- const { messages, system, model, maxTokens, temperature } = params;
101
- const ollamaMessages = [];
102
- if (system) {
103
- ollamaMessages.push({ role: 'system', content: system });
104
- }
105
- for (const msg of messages) {
106
- const content = typeof msg.content === 'string'
107
- ? msg.content
108
- : msg.content
109
- .filter((b) => b.type === 'text')
110
- .map((b) => (b.type === 'text' ? b.text : ''))
111
- .join('');
112
- ollamaMessages.push({
113
- role: msg.role,
114
- content,
115
- });
116
- }
117
- const body = {
118
- model,
119
- messages: ollamaMessages,
120
- stream: true,
121
- };
122
- if (maxTokens !== undefined) {
123
- body['options'] = { ...(body['options'] ?? {}), num_predict: maxTokens };
124
- }
125
- if (temperature !== undefined) {
126
- body['options'] = { ...(body['options'] ?? {}), temperature };
127
- }
128
- const response = await fetch(`${this.baseUrl}/api/chat`, {
129
- method: 'POST',
130
- headers: { 'Content-Type': 'application/json' },
131
- body: JSON.stringify(body),
132
- signal: params.abortSignal,
133
- });
134
- if (!response.ok) {
135
- throw new Error(`Ollama API error: ${response.status} ${response.statusText}`);
136
- }
137
- if (!response.body) {
138
- throw new Error('No response body for streaming');
139
- }
140
- const reader = response.body.getReader();
141
- const decoder = new TextDecoder();
142
- let buffer = '';
143
- let fullContent = '';
144
- let lastChunk;
145
- try {
146
- while (true) {
147
- const { done, value } = await reader.read();
148
- if (done)
149
- break;
150
- buffer += decoder.decode(value, { stream: true });
151
- const lines = buffer.split('\n');
152
- buffer = lines.pop() ?? '';
153
- for (const line of lines) {
154
- if (!line.trim())
155
- continue;
156
- try {
157
- const chunk = JSON.parse(line);
158
- if (chunk.message?.content) {
159
- fullContent += chunk.message.content;
160
- yield chunk.message.content;
161
- }
162
- if (chunk.done) {
163
- lastChunk = chunk;
164
- }
165
- }
166
- catch {
167
- // skip malformed lines
168
- }
169
- }
170
- }
171
- }
172
- finally {
173
- reader.releaseLock();
174
- }
175
- return {
176
- content: fullContent,
177
- usage: {
178
- inputTokens: lastChunk?.prompt_eval_count ?? 0,
179
- outputTokens: lastChunk?.eval_count ?? 0,
180
- },
181
- model,
182
- stopReason: 'end_turn',
183
- };
184
- }
185
- }
@@ -1,2 +0,0 @@
1
- import type { ModelInfo } from "../../shared/index.js";
2
- export declare const MODELS: ModelInfo[];
@@ -1,29 +0,0 @@
1
- export const MODELS = [
2
- {
3
- id: 'gpt-4o',
4
- displayName: 'GPT-4o',
5
- contextWindow: 128000,
6
- maxOutputTokens: 16384,
7
- inputCostPerMToken: 2.5,
8
- outputCostPerMToken: 10,
9
- capabilities: ['chat', 'tools', 'vision', 'streaming'],
10
- },
11
- {
12
- id: 'gpt-4o-mini',
13
- displayName: 'GPT-4o Mini',
14
- contextWindow: 128000,
15
- maxOutputTokens: 16384,
16
- inputCostPerMToken: 0.15,
17
- outputCostPerMToken: 0.6,
18
- capabilities: ['chat', 'tools', 'vision', 'streaming'],
19
- },
20
- {
21
- id: 'o3-mini',
22
- displayName: 'o3 Mini',
23
- contextWindow: 200000,
24
- maxOutputTokens: 100000,
25
- inputCostPerMToken: 1.1,
26
- outputCostPerMToken: 4.4,
27
- capabilities: ['chat', 'tools', 'streaming'],
28
- },
29
- ];
@@ -1,13 +0,0 @@
1
- import type { LLMProvider, ChatParams, ChatResult, ModelInfo, ToolDefinition } from "../../shared/index.js";
2
- export declare class OpenAIProvider implements LLMProvider {
3
- readonly id = "openai";
4
- readonly displayName = "OpenAI";
5
- readonly models: ModelInfo[];
6
- private client;
7
- constructor({ apiKey }: {
8
- apiKey: string;
9
- });
10
- serializeTools(tools: ToolDefinition[]): unknown;
11
- chat(params: ChatParams): Promise<ChatResult>;
12
- chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
13
- }
@@ -1,163 +0,0 @@
1
- import OpenAI from 'openai';
2
- import { MODELS } from './models.js';
3
- import { convertTools } from './tool-converter.js';
4
- export class OpenAIProvider {
5
- id = 'openai';
6
- displayName = 'OpenAI';
7
- models = MODELS;
8
- client;
9
- constructor({ apiKey }) {
10
- this.client = new OpenAI({ apiKey });
11
- }
12
- serializeTools(tools) {
13
- return convertTools(tools);
14
- }
15
- async chat(params) {
16
- const { messages, system, tools, maxTokens, temperature, model, abortSignal } = params;
17
- const openaiMessages = [];
18
- if (system) {
19
- openaiMessages.push({ role: 'system', content: system });
20
- }
21
- for (const msg of messages) {
22
- if (typeof msg.content === 'string') {
23
- openaiMessages.push({
24
- role: msg.role,
25
- content: msg.content,
26
- });
27
- }
28
- else {
29
- // content blocks — convert text blocks to string
30
- const textContent = msg.content
31
- .filter((b) => b.type === 'text')
32
- .map((b) => (b.type === 'text' ? b.text : ''))
33
- .join('');
34
- openaiMessages.push({
35
- role: msg.role,
36
- content: textContent,
37
- });
38
- }
39
- }
40
- const response = await this.client.chat.completions.create({
41
- model,
42
- messages: openaiMessages,
43
- ...(maxTokens !== undefined ? { max_tokens: maxTokens } : {}),
44
- ...(temperature !== undefined ? { temperature } : {}),
45
- ...(tools && tools.length > 0 ? { tools: convertTools(tools) } : {}),
46
- }, { signal: abortSignal });
47
- const choice = response.choices[0];
48
- if (!choice) {
49
- throw new Error('No choices returned from OpenAI');
50
- }
51
- const messageContent = choice.message.content ?? '';
52
- const toolUses = [];
53
- if (choice.message.tool_calls) {
54
- for (const tc of choice.message.tool_calls) {
55
- let input;
56
- try {
57
- input = JSON.parse(tc.function.arguments);
58
- }
59
- catch {
60
- input = tc.function.arguments;
61
- }
62
- toolUses.push({
63
- id: tc.id,
64
- name: tc.function.name,
65
- input,
66
- });
67
- }
68
- }
69
- const stopReason = mapFinishReason(choice.finish_reason);
70
- return {
71
- content: messageContent,
72
- toolUses: toolUses.length > 0 ? toolUses : undefined,
73
- usage: {
74
- inputTokens: response.usage?.prompt_tokens ?? 0,
75
- outputTokens: response.usage?.completion_tokens ?? 0,
76
- },
77
- model: response.model,
78
- stopReason,
79
- };
80
- }
81
- async *chatStream(params) {
82
- const { messages, system, tools, maxTokens, temperature, model, abortSignal } = params;
83
- const openaiMessages = [];
84
- if (system) {
85
- openaiMessages.push({ role: 'system', content: system });
86
- }
87
- for (const msg of messages) {
88
- if (typeof msg.content === 'string') {
89
- openaiMessages.push({
90
- role: msg.role,
91
- content: msg.content,
92
- });
93
- }
94
- else {
95
- const textContent = msg.content
96
- .filter((b) => b.type === 'text')
97
- .map((b) => (b.type === 'text' ? b.text : ''))
98
- .join('');
99
- openaiMessages.push({
100
- role: msg.role,
101
- content: textContent,
102
- });
103
- }
104
- }
105
- const stream = this.client.chat.completions.stream({
106
- model,
107
- messages: openaiMessages,
108
- ...(maxTokens !== undefined ? { max_tokens: maxTokens } : {}),
109
- ...(temperature !== undefined ? { temperature } : {}),
110
- ...(tools && tools.length > 0 ? { tools: convertTools(tools) } : {}),
111
- }, { signal: abortSignal });
112
- let accumulatedContent = '';
113
- for await (const chunk of stream) {
114
- const delta = chunk.choices[0]?.delta?.content;
115
- if (delta) {
116
- accumulatedContent += delta;
117
- yield delta;
118
- }
119
- }
120
- const finalCompletion = await stream.finalChatCompletion();
121
- const choice = finalCompletion.choices[0];
122
- if (!choice) {
123
- throw new Error('No choices in final completion');
124
- }
125
- const toolUses = [];
126
- if (choice.message.tool_calls) {
127
- for (const tc of choice.message.tool_calls) {
128
- let input;
129
- try {
130
- input = JSON.parse(tc.function.arguments);
131
- }
132
- catch {
133
- input = tc.function.arguments;
134
- }
135
- toolUses.push({ id: tc.id, name: tc.function.name, input });
136
- }
137
- }
138
- return {
139
- content: choice.message.content ?? accumulatedContent,
140
- toolUses: toolUses.length > 0 ? toolUses : undefined,
141
- usage: {
142
- inputTokens: finalCompletion.usage?.prompt_tokens ?? 0,
143
- outputTokens: finalCompletion.usage?.completion_tokens ?? 0,
144
- },
145
- model: finalCompletion.model,
146
- stopReason: mapFinishReason(choice.finish_reason),
147
- };
148
- }
149
- }
150
- function mapFinishReason(reason) {
151
- switch (reason) {
152
- case 'stop':
153
- return 'end_turn';
154
- case 'tool_calls':
155
- return 'tool_use';
156
- case 'length':
157
- return 'max_tokens';
158
- case 'content_filter':
159
- return 'stop_sequence';
160
- default:
161
- return 'end_turn';
162
- }
163
- }
@@ -1,10 +0,0 @@
1
- import type { ToolDefinition } from "../../shared/index.js";
2
- export interface OpenAITool {
3
- type: 'function';
4
- function: {
5
- name: string;
6
- description: string;
7
- parameters: Record<string, unknown>;
8
- };
9
- }
10
- export declare function convertTools(tools: ToolDefinition[]): OpenAITool[];
@@ -1,10 +0,0 @@
1
- export function convertTools(tools) {
2
- return tools.map((tool) => ({
3
- type: 'function',
4
- function: {
5
- name: tool.name,
6
- description: tool.description,
7
- parameters: tool.parameters,
8
- },
9
- }));
10
- }
@@ -1,50 +0,0 @@
1
- /** Shared constants — event names, default values, status enums */
2
- /** Hook/event name constants */
3
- export declare const EVENTS: {
4
- readonly COST_RECORDED: "cost.recorded";
5
- readonly AGENT_CREATED: "agent.created";
6
- readonly AGENT_STATUS_CHANGED: "agent.status_changed";
7
- readonly BUDGET_EXCEEDED: "budget.exceeded";
8
- readonly TASK_CREATED: "task.created";
9
- readonly TASK_COMPLETED: "task.completed";
10
- readonly TASK_FAILED: "task.failed";
11
- readonly TASK_CANCELLED: "task.cancelled";
12
- readonly RUN_STARTED: "run.started";
13
- readonly RUN_COMPLETED: "run.completed";
14
- readonly RUN_FAILED: "run.failed";
15
- readonly MESSAGE_INBOUND: "message.inbound";
16
- readonly MESSAGE_ROUTED: "message.routed";
17
- readonly MESSAGE_PROCESSED: "message.processed";
18
- readonly MESSAGE_OUTBOUND: "message.outbound";
19
- readonly MESSAGE_SENT: "message.sent";
20
- readonly UPDATE_AVAILABLE: "update.available";
21
- readonly UPDATE_STARTED: "update.started";
22
- readonly UPDATE_COMPLETED: "update.completed";
23
- readonly UPDATE_FAILED: "update.failed";
24
- readonly WORKFLOW_STARTED: "workflow.started";
25
- readonly WORKFLOW_STEP_COMPLETED: "workflow.step_completed";
26
- readonly WORKFLOW_COMPLETED: "workflow.completed";
27
- readonly WORKFLOW_FAILED: "workflow.failed";
28
- };
29
- /** Default config values */
30
- export declare const DEFAULTS: {
31
- readonly TASK_POLL_INTERVAL_MS: 30000;
32
- readonly NOTIFICATION_POLL_INTERVAL_MS: 5000;
33
- readonly ORPHAN_REAP_INTERVAL_MS: 300000;
34
- readonly STALE_RUN_THRESHOLD_MS: 1800000;
35
- readonly STALE_TASK_AGE_MS: 7200000;
36
- readonly MAX_CHAIN_DEPTH: 5;
37
- readonly MAX_NOTIFICATION_RETRIES: 3;
38
- readonly UPDATE_CHECK_INTERVAL_MS: 86400000;
39
- readonly RENDER_WATCH_INTERVAL_MS: 30000;
40
- readonly DATA_PATH: "./data/bot.db";
41
- readonly RENDER_OUTPUT_DIR: "./context";
42
- readonly LOG_PATH_TEMPLATE: "./data/runs/{runId}.ndjson";
43
- readonly BUDGET_WARN_PERCENT: 80;
44
- };
45
- /** Task status values */
46
- export declare const TASK_STATUSES: readonly ["backlog", "todo", "in_progress", "in_review", "done", "blocked", "cancelled"];
47
- /** Agent status values */
48
- export declare const AGENT_STATUSES: readonly ["idle", "running", "paused", "terminated", "error"];
49
- /** Run status values */
50
- export declare const RUN_STATUSES: readonly ["queued", "running", "succeeded", "failed", "cancelled"];
@@ -1,64 +0,0 @@
1
- /** Shared constants — event names, default values, status enums */
2
- /** Hook/event name constants */
3
- export const EVENTS = {
4
- // Cost
5
- COST_RECORDED: "cost.recorded",
6
- // Agent
7
- AGENT_CREATED: "agent.created",
8
- AGENT_STATUS_CHANGED: "agent.status_changed",
9
- BUDGET_EXCEEDED: "budget.exceeded",
10
- // Task
11
- TASK_CREATED: "task.created",
12
- TASK_COMPLETED: "task.completed",
13
- TASK_FAILED: "task.failed",
14
- TASK_CANCELLED: "task.cancelled",
15
- // Run
16
- RUN_STARTED: "run.started",
17
- RUN_COMPLETED: "run.completed",
18
- RUN_FAILED: "run.failed",
19
- // Message pipeline
20
- MESSAGE_INBOUND: "message.inbound",
21
- MESSAGE_ROUTED: "message.routed",
22
- MESSAGE_PROCESSED: "message.processed",
23
- MESSAGE_OUTBOUND: "message.outbound",
24
- MESSAGE_SENT: "message.sent",
25
- // Updates
26
- UPDATE_AVAILABLE: "update.available",
27
- UPDATE_STARTED: "update.started",
28
- UPDATE_COMPLETED: "update.completed",
29
- UPDATE_FAILED: "update.failed",
30
- // Workflow
31
- WORKFLOW_STARTED: "workflow.started",
32
- WORKFLOW_STEP_COMPLETED: "workflow.step_completed",
33
- WORKFLOW_COMPLETED: "workflow.completed",
34
- WORKFLOW_FAILED: "workflow.failed",
35
- };
36
- /** Default config values */
37
- export const DEFAULTS = {
38
- TASK_POLL_INTERVAL_MS: 30_000,
39
- NOTIFICATION_POLL_INTERVAL_MS: 5_000,
40
- ORPHAN_REAP_INTERVAL_MS: 300_000, // 5 minutes
41
- STALE_RUN_THRESHOLD_MS: 1_800_000, // 30 minutes
42
- STALE_TASK_AGE_MS: 7_200_000, // 2 hours
43
- MAX_CHAIN_DEPTH: 5,
44
- MAX_NOTIFICATION_RETRIES: 3,
45
- UPDATE_CHECK_INTERVAL_MS: 86_400_000, // 24 hours
46
- RENDER_WATCH_INTERVAL_MS: 30_000,
47
- DATA_PATH: "./data/bot.db",
48
- RENDER_OUTPUT_DIR: "./context",
49
- LOG_PATH_TEMPLATE: "./data/runs/{runId}.ndjson",
50
- BUDGET_WARN_PERCENT: 80,
51
- };
52
- /** Task status values */
53
- export const TASK_STATUSES = [
54
- "backlog", "todo", "in_progress", "in_review",
55
- "done", "blocked", "cancelled",
56
- ];
57
- /** Agent status values */
58
- export const AGENT_STATUSES = [
59
- "idle", "running", "paused", "terminated", "error",
60
- ];
61
- /** Run status values */
62
- export const RUN_STATUSES = [
63
- "queued", "running", "succeeded", "failed", "cancelled",
64
- ];
@@ -1,14 +0,0 @@
1
- /**
2
- * @botinabox/shared — Shared types and interfaces for all Bot in a Box packages.
3
- * Zero runtime dependencies.
4
- */
5
- export * from "./types/channel.js";
6
- export * from "./types/provider.js";
7
- export * from "./types/execution.js";
8
- export * from "./types/agent.js";
9
- export * from "./types/task.js";
10
- export * from "./types/config.js";
11
- export * from "./types/connector.js";
12
- export * from "./types/workflow.js";
13
- export * from "./constants.js";
14
- export * from "./utils.js";
@@ -1,14 +0,0 @@
1
- /**
2
- * @botinabox/shared — Shared types and interfaces for all Bot in a Box packages.
3
- * Zero runtime dependencies.
4
- */
5
- export * from "./types/channel.js";
6
- export * from "./types/provider.js";
7
- export * from "./types/execution.js";
8
- export * from "./types/agent.js";
9
- export * from "./types/task.js";
10
- export * from "./types/config.js";
11
- export * from "./types/connector.js";
12
- export * from "./types/workflow.js";
13
- export * from "./constants.js";
14
- export * from "./utils.js";
@@ -1,36 +0,0 @@
1
- /** Agent types — Story 1.5 / 3.1 */
2
- export type AgentStatus = "idle" | "running" | "paused" | "terminated" | "error";
3
- export interface AgentDefinition {
4
- slug: string;
5
- name: string;
6
- role?: string;
7
- adapter: string;
8
- model?: string;
9
- workdir?: string;
10
- instructionsFile?: string;
11
- maxConcurrentRuns?: number;
12
- budgetMonthlyCents?: number;
13
- canCreateAgents?: boolean;
14
- skipPermissions?: boolean;
15
- config?: Record<string, unknown>;
16
- }
17
- export interface AgentRecord extends AgentDefinition {
18
- id: string;
19
- status: AgentStatus;
20
- spentMonthlyCents: number;
21
- createdAt: string;
22
- updatedAt: string;
23
- deletedAt?: string;
24
- }
25
- export interface AgentFilter {
26
- status?: AgentStatus | AgentStatus[];
27
- role?: string;
28
- adapter?: string;
29
- }
30
- export interface BudgetCheck {
31
- allowed: boolean;
32
- status: "ok" | "warning" | "hard_stop";
33
- spentCents: number;
34
- limitCents?: number;
35
- message?: string;
36
- }
@@ -1,2 +0,0 @@
1
- /** Agent types — Story 1.5 / 3.1 */
2
- export {};
@@ -1,70 +0,0 @@
1
- /** Channel adapter types — Story 1.5 / 4.1 */
2
- export type ChatType = "direct" | "group" | "channel";
3
- export type FormattingMode = "markdown" | "mrkdwn" | "html" | "plain";
4
- export interface ChannelCapabilities {
5
- chatTypes: ChatType[];
6
- threads: boolean;
7
- reactions: boolean;
8
- editing: boolean;
9
- media: boolean;
10
- polls: boolean;
11
- maxTextLength: number;
12
- formattingMode: FormattingMode;
13
- }
14
- export interface ChannelMeta {
15
- displayName: string;
16
- icon?: string;
17
- homepage?: string;
18
- }
19
- export interface InboundMessage {
20
- id: string;
21
- channel: string;
22
- account?: string;
23
- from: string;
24
- userId?: string;
25
- body: string;
26
- threadId?: string;
27
- replyToId?: string;
28
- attachments?: Attachment[];
29
- receivedAt: string;
30
- raw?: unknown;
31
- }
32
- export interface Attachment {
33
- type: "image" | "file" | "audio" | "video";
34
- url?: string;
35
- mimeType?: string;
36
- filename?: string;
37
- size?: number;
38
- }
39
- export interface OutboundPayload {
40
- text: string;
41
- threadId?: string;
42
- replyToId?: string;
43
- attachments?: Attachment[];
44
- }
45
- export interface SendResult {
46
- success: boolean;
47
- messageId?: string;
48
- error?: string;
49
- }
50
- export interface HealthStatus {
51
- ok: boolean;
52
- latencyMs?: number;
53
- error?: string;
54
- }
55
- export type ChannelConfig = Record<string, unknown>;
56
- export interface ChannelAdapter {
57
- /** Unique identifier for this adapter instance */
58
- id: string;
59
- meta: ChannelMeta;
60
- capabilities: ChannelCapabilities;
61
- connect(config: ChannelConfig): Promise<void>;
62
- disconnect(): Promise<void>;
63
- healthCheck(): Promise<HealthStatus>;
64
- send(target: {
65
- peerId: string;
66
- threadId?: string;
67
- }, payload: OutboundPayload): Promise<SendResult>;
68
- /** Called when a message arrives — set by the framework */
69
- onMessage?: (message: InboundMessage) => Promise<void>;
70
- }
@@ -1,2 +0,0 @@
1
- /** Channel adapter types — Story 1.5 / 4.1 */
2
- export {};