botinabox 2.9.1 → 2.9.3

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 (162) hide show
  1. package/README.md +2 -1
  2. package/bin/botinabox.mjs +1 -1
  3. package/dist/channels/discord/adapter.d.ts +32 -0
  4. package/dist/channels/discord/inbound.d.ts +25 -0
  5. package/dist/channels/discord/index.d.ts +8 -84
  6. package/dist/channels/discord/models.d.ts +8 -0
  7. package/dist/channels/discord/outbound.d.ts +14 -0
  8. package/dist/channels/slack/adapter.d.ts +33 -0
  9. package/dist/channels/slack/bolt-adapter.d.ts +31 -0
  10. package/dist/channels/slack/enrichers/enrich.d.ts +12 -0
  11. package/dist/channels/slack/enrichers/image-enricher.d.ts +10 -0
  12. package/dist/channels/slack/enrichers/index.d.ts +4 -0
  13. package/dist/channels/slack/enrichers/pdf-enricher.d.ts +8 -0
  14. package/dist/channels/slack/enrichers/types.d.ts +33 -0
  15. package/dist/channels/slack/inbound.d.ts +59 -0
  16. package/dist/channels/slack/index.d.ts +13 -252
  17. package/dist/channels/slack/media-type.d.ts +14 -0
  18. package/dist/channels/slack/models.d.ts +9 -0
  19. package/dist/channels/slack/outbound.d.ts +12 -0
  20. package/dist/channels/slack/transcribe.d.ts +41 -0
  21. package/dist/channels/webhook/adapter.d.ts +23 -0
  22. package/dist/channels/webhook/hmac.d.ts +13 -0
  23. package/dist/channels/webhook/index.d.ts +7 -70
  24. package/dist/channels/webhook/models.d.ts +9 -0
  25. package/dist/channels/webhook/server.d.ts +20 -0
  26. package/dist/cli/templates/config.yml.d.ts +7 -0
  27. package/dist/cli/templates/env.d.ts +1 -0
  28. package/dist/cli/templates/index.ts.d.ts +2 -0
  29. package/dist/cli/templates/package.json.d.ts +5 -0
  30. package/dist/cli.d.ts +1 -3
  31. package/dist/connectors/google/calendar-connector.d.ts +40 -0
  32. package/dist/connectors/google/drive-connector.d.ts +43 -0
  33. package/dist/connectors/google/drive-read.d.ts +81 -0
  34. package/dist/connectors/google/gmail-connector.d.ts +42 -0
  35. package/dist/connectors/google/index.d.ts +10 -369
  36. package/dist/connectors/google/oauth.d.ts +48 -0
  37. package/dist/connectors/google/types.d.ts +110 -0
  38. package/dist/core/chat/auto-discovery.d.ts +16 -0
  39. package/dist/core/chat/channel-registry.d.ts +45 -0
  40. package/dist/core/chat/chat-pipeline-v2.d.ts +138 -0
  41. package/dist/core/chat/chat-pipeline.d.ts +116 -0
  42. package/dist/core/chat/chat-responder.d.ts +94 -0
  43. package/dist/core/chat/formatter.d.ts +11 -0
  44. package/dist/core/chat/index.d.ts +26 -0
  45. package/dist/core/chat/message-interpreter.d.ts +91 -0
  46. package/dist/core/chat/message-store.d.ts +71 -0
  47. package/dist/core/chat/notification-queue.d.ts +34 -0
  48. package/dist/core/chat/pipeline.d.ts +38 -0
  49. package/dist/core/chat/policies.d.ts +16 -0
  50. package/dist/core/chat/routing.d.ts +17 -0
  51. package/dist/core/chat/session-key.d.ts +30 -0
  52. package/dist/core/chat/session-manager.d.ts +17 -0
  53. package/dist/core/chat/text-chunker.d.ts +9 -0
  54. package/dist/core/chat/triage-router.d.ts +75 -0
  55. package/dist/core/chat/types.d.ts +5 -0
  56. package/dist/core/config/defaults.d.ts +2 -0
  57. package/dist/core/config/index.d.ts +6 -0
  58. package/dist/core/config/interpolate.d.ts +5 -0
  59. package/dist/core/config/loader.d.ts +24 -0
  60. package/dist/core/config/schema.d.ts +5 -0
  61. package/dist/core/data/context-builder.d.ts +27 -0
  62. package/dist/core/data/core-entity-contexts.d.ts +14 -0
  63. package/dist/core/data/core-migrations.d.ts +5 -0
  64. package/dist/core/data/core-schema.d.ts +6 -0
  65. package/dist/core/data/data-store.d.ts +67 -0
  66. package/dist/core/data/domain-entity-contexts.d.ts +35 -0
  67. package/dist/core/data/domain-schema.d.ts +36 -0
  68. package/dist/core/data/index.d.ts +8 -0
  69. package/dist/core/data/types.d.ts +111 -0
  70. package/dist/core/hooks/hook-bus.d.ts +24 -0
  71. package/dist/core/hooks/index.d.ts +2 -0
  72. package/dist/core/hooks/types.d.ts +19 -0
  73. package/dist/core/index.d.ts +4 -0
  74. package/dist/core/llm/auto-discovery.d.ts +11 -0
  75. package/dist/core/llm/cost-tracker.d.ts +6 -0
  76. package/dist/core/llm/default-llm-call.d.ts +35 -0
  77. package/dist/core/llm/index.d.ts +6 -0
  78. package/dist/core/llm/model-router.d.ts +25 -0
  79. package/dist/core/llm/provider-registry.d.ts +9 -0
  80. package/dist/core/llm/types.d.ts +2 -0
  81. package/dist/core/orchestrator/adapters/api-adapter.d.ts +34 -0
  82. package/dist/core/orchestrator/adapters/cli-adapter.d.ts +62 -0
  83. package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +35 -0
  84. package/dist/core/orchestrator/adapters/env-whitelist.d.ts +4 -0
  85. package/dist/core/orchestrator/adapters/output-extractor.d.ts +11 -0
  86. package/dist/core/orchestrator/adapters/process-manager.d.ts +15 -0
  87. package/dist/core/orchestrator/adapters/tool-loop.d.ts +22 -0
  88. package/dist/core/orchestrator/agent-registry.d.ts +31 -0
  89. package/dist/core/orchestrator/budget-controller.d.ts +19 -0
  90. package/dist/core/orchestrator/chain-guard.d.ts +14 -0
  91. package/dist/core/orchestrator/circuit-breaker.d.ts +65 -0
  92. package/dist/core/orchestrator/claude-stream-parser.d.ts +31 -0
  93. package/dist/core/orchestrator/config-revisions.d.ts +6 -0
  94. package/dist/core/orchestrator/dependency-resolver.d.ts +20 -0
  95. package/dist/core/orchestrator/execution-engine.d.ts +99 -0
  96. package/dist/core/orchestrator/governance-gate.d.ts +110 -0
  97. package/dist/core/orchestrator/learning-pipeline.d.ts +112 -0
  98. package/dist/core/orchestrator/loop-detector.d.ts +51 -0
  99. package/dist/core/orchestrator/ndjson-logger.d.ts +6 -0
  100. package/dist/core/orchestrator/permission-relay.d.ts +72 -0
  101. package/dist/core/orchestrator/run-manager.d.ts +31 -0
  102. package/dist/core/orchestrator/scheduler.d.ts +74 -0
  103. package/dist/core/orchestrator/secret-store.d.ts +57 -0
  104. package/dist/core/orchestrator/session-manager.d.ts +13 -0
  105. package/dist/core/orchestrator/task-queue.d.ts +34 -0
  106. package/dist/core/orchestrator/template-interpolate.d.ts +5 -0
  107. package/dist/core/orchestrator/tools/file-ops.d.ts +12 -0
  108. package/dist/core/orchestrator/tools/index.d.ts +47 -0
  109. package/dist/core/orchestrator/tools/management.d.ts +12 -0
  110. package/dist/core/orchestrator/tools/messaging.d.ts +21 -0
  111. package/dist/core/orchestrator/tools/read-file.d.ts +5 -0
  112. package/dist/core/orchestrator/tools/resolve-agent.d.ts +9 -0
  113. package/dist/core/orchestrator/tools/roster.d.ts +16 -0
  114. package/dist/core/orchestrator/tools/send-file.d.ts +5 -0
  115. package/dist/core/orchestrator/tools/status.d.ts +20 -0
  116. package/dist/core/orchestrator/tools/task-ops.d.ts +13 -0
  117. package/dist/core/orchestrator/user-registry.d.ts +47 -0
  118. package/dist/core/orchestrator/wakeup-queue.d.ts +9 -0
  119. package/dist/core/orchestrator/workflow-engine.d.ts +47 -0
  120. package/dist/core/security/audit.d.ts +20 -0
  121. package/dist/core/security/column-validator.d.ts +20 -0
  122. package/dist/core/security/index.d.ts +5 -0
  123. package/dist/core/security/process-env.d.ts +13 -0
  124. package/dist/core/security/sanitizer.d.ts +11 -0
  125. package/dist/core/security/types.d.ts +11 -0
  126. package/dist/core/update/auto-update.d.ts +21 -0
  127. package/dist/core/update/backup-manager.d.ts +7 -0
  128. package/dist/core/update/index.d.ts +8 -0
  129. package/dist/core/update/migration-hooks.d.ts +11 -0
  130. package/dist/core/update/types.d.ts +11 -0
  131. package/dist/core/update/update-checker.d.ts +11 -0
  132. package/dist/core/update/update-manager.d.ts +25 -0
  133. package/dist/core/update/version-utils.d.ts +6 -0
  134. package/dist/index.d.ts +38 -2366
  135. package/dist/index.js +117 -10
  136. package/dist/providers/anthropic/index.d.ts +5 -20
  137. package/dist/providers/anthropic/models.d.ts +2 -0
  138. package/dist/providers/anthropic/provider.d.ts +13 -0
  139. package/dist/providers/anthropic/tool-converter.d.ts +10 -0
  140. package/dist/providers/ollama/index.d.ts +4 -22
  141. package/dist/providers/ollama/provider.d.ts +17 -0
  142. package/dist/providers/openai/index.d.ts +5 -20
  143. package/dist/providers/openai/models.d.ts +2 -0
  144. package/dist/providers/openai/provider.d.ts +13 -0
  145. package/dist/providers/openai/tool-converter.d.ts +10 -0
  146. package/dist/shared/constants.d.ts +50 -0
  147. package/dist/shared/index.d.ts +14 -0
  148. package/dist/shared/types/agent.d.ts +36 -0
  149. package/dist/{channel-CVm1AWUF.d.ts → shared/types/channel.d.ts} +13 -17
  150. package/dist/shared/types/config.d.ts +160 -0
  151. package/dist/shared/types/connector.d.ts +77 -0
  152. package/dist/shared/types/execution.d.ts +29 -0
  153. package/dist/{provider-BHkqkSdq.d.ts → shared/types/provider.d.ts} +10 -12
  154. package/dist/shared/types/task.d.ts +47 -0
  155. package/dist/shared/types/workflow.d.ts +39 -0
  156. package/dist/shared/utils.d.ts +6 -0
  157. package/dist/update-check.d.ts +5 -0
  158. package/package.json +3 -3
  159. package/dist/channel-DziSPayj.d.ts +0 -73
  160. package/dist/chat-pipeline-BGgmH_ap.d.ts +0 -655
  161. package/dist/chat-pipeline-BWrtVqEP.d.ts +0 -652
  162. package/dist/chat-pipeline-aBSj7a4E.d.ts +0 -655
package/dist/index.js CHANGED
@@ -139,6 +139,44 @@ var HookBus = class {
139
139
  if (idx !== -1) arr.splice(idx, 1);
140
140
  }
141
141
  }
142
+ /**
143
+ * Emit an event and collect handler errors instead of swallowing them.
144
+ * Handlers still run in priority order and one handler's error does not
145
+ * block subsequent handlers. Returns the array of errors (empty = success).
146
+ */
147
+ async emitCollectingErrors(event, context) {
148
+ const list = this.registrations.get(event);
149
+ if (!list || list.length === 0) return [];
150
+ const snapshot = [...list];
151
+ const toRemove = [];
152
+ const errors = [];
153
+ for (const reg of snapshot) {
154
+ if (reg.filter) {
155
+ const matches = Object.entries(reg.filter).every(
156
+ ([k, v]) => context[k] === v
157
+ );
158
+ if (!matches) continue;
159
+ }
160
+ try {
161
+ await reg.handler(context);
162
+ } catch (err) {
163
+ const wrapped = err instanceof Error ? err : new Error(String(err));
164
+ errors.push(wrapped);
165
+ console.error(
166
+ `[HookBus] Handler error on event "${event}":`,
167
+ err
168
+ );
169
+ }
170
+ if (reg.once) toRemove.push(reg);
171
+ }
172
+ for (const r of toRemove) {
173
+ const arr = this.registrations.get(event);
174
+ if (!arr) continue;
175
+ const idx = arr.indexOf(r);
176
+ if (idx !== -1) arr.splice(idx, 1);
177
+ }
178
+ return errors;
179
+ }
142
180
  /** Emit synchronously (use only when async is not needed) */
143
181
  emitSync(event, context) {
144
182
  const list = this.registrations.get(event);
@@ -2140,7 +2178,7 @@ var ChatPipelineV2 = class {
2140
2178
  if (this.messageFilter && !this.messageFilter(msg)) return;
2141
2179
  if (await this.isDuplicate(msg)) return;
2142
2180
  const channelId = msg.account ?? "";
2143
- const threadTs = channelId || msg.threadId || msg.id;
2181
+ const threadTs = msg.threadId || channelId || msg.id;
2144
2182
  if (threadTs && channelId) {
2145
2183
  this.threadChannelMap.set(threadTs, channelId);
2146
2184
  }
@@ -2148,7 +2186,7 @@ var ChatPipelineV2 = class {
2148
2186
  const { messageId } = await this.messageStore.storeInbound(msgWithThread);
2149
2187
  await this.hooks.emit("typing.start", { channel: this.channel, threadId: threadTs });
2150
2188
  try {
2151
- const history = await this.buildHistory(channelId);
2189
+ const history = await this.buildHistory(threadTs);
2152
2190
  let systemPrompt = this.config.systemPrompt;
2153
2191
  if (this.config.includeSystemContext !== false) {
2154
2192
  const ctx2 = await buildSystemContext(this.db, this.config.systemContextOptions);
@@ -2295,10 +2333,10 @@ ${ctx2}`;
2295
2333
  return { text: finalText, tasksDispatched };
2296
2334
  }
2297
2335
  /**
2298
- * Build conversation history from channel messages.
2336
+ * Build conversation history from thread messages.
2299
2337
  * Includes BOTH user and assistant messages (unlike v1 which excluded bot messages).
2300
2338
  */
2301
- async buildHistory(channelId) {
2339
+ async buildHistory(threadTs) {
2302
2340
  const maxMessages = this.config.history?.maxMessages ?? DEFAULT_MAX_MESSAGES;
2303
2341
  const maxAgeDays = this.config.history?.maxAgeDays ?? DEFAULT_MAX_AGE_DAYS;
2304
2342
  const includeAssistant = this.config.history?.includeAssistant !== false;
@@ -2306,7 +2344,7 @@ ${ctx2}`;
2306
2344
  let rows;
2307
2345
  try {
2308
2346
  rows = await this.db.query("messages", {
2309
- where: { channel: this.channel },
2347
+ where: { thread_id: threadTs },
2310
2348
  orderBy: "created_at",
2311
2349
  orderDir: "desc",
2312
2350
  limit: maxMessages
@@ -5146,6 +5184,11 @@ var Scheduler = class {
5146
5184
  db;
5147
5185
  hooks;
5148
5186
  timer = null;
5187
+ breaker;
5188
+ /** Wire a CircuitBreaker for connector.sync actions. */
5189
+ setCircuitBreaker(cb) {
5190
+ this.breaker = cb;
5191
+ }
5149
5192
  /**
5150
5193
  * Start the scheduler. Computes initial next_fire_at for schedules
5151
5194
  * that don't have one, then polls for due schedules.
@@ -5178,11 +5221,54 @@ var Scheduler = class {
5178
5221
  for (const [k, v] of Object.entries(config)) {
5179
5222
  if (!k.startsWith("__")) safeConfig[k] = v;
5180
5223
  }
5181
- await this.hooks.emit(schedule.action, {
5182
- schedule_id: schedule.id,
5183
- schedule_name: schedule.name,
5184
- ...safeConfig
5185
- });
5224
+ const breakerKey = schedule.action === "connector.sync" && this.breaker ? `${safeConfig["connector"]}:${safeConfig["account"]}` : null;
5225
+ if (breakerKey && !this.breaker.canExecute(breakerKey)) {
5226
+ console.warn(
5227
+ `[Scheduler] circuit open for ${breakerKey}, skipping sync`
5228
+ );
5229
+ continue;
5230
+ }
5231
+ const handlerErrors = await this.hooks.emitCollectingErrors(
5232
+ schedule.action,
5233
+ {
5234
+ schedule_id: schedule.id,
5235
+ schedule_name: schedule.name,
5236
+ ...safeConfig
5237
+ }
5238
+ );
5239
+ if (handlerErrors.length > 0) {
5240
+ if (breakerKey) {
5241
+ await this.breaker.recordFailure(
5242
+ breakerKey,
5243
+ handlerErrors[0].message
5244
+ );
5245
+ }
5246
+ await this.hooks.emit("schedule.error", {
5247
+ schedule_id: schedule.id,
5248
+ schedule_name: schedule.name,
5249
+ error: handlerErrors[0].message
5250
+ });
5251
+ console.error(
5252
+ `[Scheduler] Handler error firing "${schedule.name}":`,
5253
+ handlerErrors[0]
5254
+ );
5255
+ if (schedule.type === "recurring" && schedule.cron) {
5256
+ const nextFire = computeNextFire(
5257
+ schedule.cron,
5258
+ schedule.timezone,
5259
+ /* @__PURE__ */ new Date()
5260
+ );
5261
+ await this.db.update(
5262
+ "schedules",
5263
+ { id: schedule.id },
5264
+ { next_fire_at: nextFire, updated_at: now }
5265
+ );
5266
+ }
5267
+ continue;
5268
+ }
5269
+ if (breakerKey) {
5270
+ await this.breaker.recordSuccess(breakerKey);
5271
+ }
5186
5272
  await this.hooks.emit("schedule.fired", {
5187
5273
  schedule_id: schedule.id,
5188
5274
  schedule_name: schedule.name,
@@ -7190,6 +7276,26 @@ var coordinatorTools = [
7190
7276
  listProjectsTool,
7191
7277
  sendFileTool
7192
7278
  ];
7279
+ function mergeTools(...toolSets) {
7280
+ const seen = /* @__PURE__ */ new Map();
7281
+ const result = [];
7282
+ for (const set of toolSets) {
7283
+ for (const tool of set) {
7284
+ const name = tool.definition.name;
7285
+ const existing = seen.get(name);
7286
+ if (existing !== void 0) {
7287
+ result[existing] = tool;
7288
+ console.warn(
7289
+ `[mergeTools] tool '${name}' overridden by a later tool set -- the earlier definition will not be used`
7290
+ );
7291
+ } else {
7292
+ seen.set(name, result.length);
7293
+ result.push(tool);
7294
+ }
7295
+ }
7296
+ }
7297
+ return result;
7298
+ }
7193
7299
 
7194
7300
  // src/core/orchestrator/user-registry.ts
7195
7301
  import { v4 as uuidv4 } from "uuid";
@@ -7618,6 +7724,7 @@ export {
7618
7724
  listFilesTool,
7619
7725
  listProjectsTool,
7620
7726
  loadConfig,
7727
+ mergeTools,
7621
7728
  nativeTools,
7622
7729
  parseClaudeStream,
7623
7730
  parseVersion,
@@ -1,22 +1,7 @@
1
- import { L as LLMProvider, M as ModelInfo, e as ToolDefinition, a as ChatParams, b as ChatResult } from '../../provider-BHkqkSdq.js';
2
-
3
- declare class AnthropicProvider implements LLMProvider {
4
- readonly id = "anthropic";
5
- readonly displayName = "Anthropic";
6
- readonly models: ModelInfo[];
7
- private client;
8
- constructor({ apiKey }: {
9
- apiKey: string;
10
- });
11
- serializeTools(tools: ToolDefinition[]): unknown;
12
- chat(params: ChatParams): Promise<ChatResult>;
13
- chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
14
- }
15
-
16
- declare const MODELS: ModelInfo[];
17
-
18
- declare function createAnthropicProvider(config: {
1
+ import type { LLMProvider } from "../../shared/index.js";
2
+ import { AnthropicProvider } from './provider.js';
3
+ import { MODELS } from './models.js';
4
+ export { AnthropicProvider, MODELS };
5
+ export default function createAnthropicProvider(config: {
19
6
  apiKey: string;
20
7
  }): LLMProvider;
21
-
22
- export { AnthropicProvider, MODELS, createAnthropicProvider as default };
@@ -0,0 +1,2 @@
1
+ import type { ModelInfo } from "../../shared/index.js";
2
+ export declare const MODELS: ModelInfo[];
@@ -0,0 +1,13 @@
1
+ import type { LLMProvider, ChatParams, ChatResult, ModelInfo, ToolDefinition } from "../../shared/index.js";
2
+ export declare class AnthropicProvider implements LLMProvider {
3
+ readonly id = "anthropic";
4
+ readonly displayName = "Anthropic";
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
+ }
@@ -0,0 +1,10 @@
1
+ import type { ToolDefinition } from "../../shared/index.js";
2
+ export interface AnthropicTool {
3
+ name: string;
4
+ description: string;
5
+ input_schema: {
6
+ type: 'object';
7
+ [key: string]: unknown;
8
+ };
9
+ }
10
+ export declare function convertTools(tools: ToolDefinition[]): AnthropicTool[];
@@ -1,24 +1,6 @@
1
- import { L as LLMProvider, M as ModelInfo, e as ToolDefinition, a as ChatParams, b as ChatResult } from '../../provider-BHkqkSdq.js';
2
-
3
- declare class OllamaProvider implements LLMProvider {
4
- readonly id = "ollama";
5
- readonly displayName = "Ollama";
6
- private baseUrl;
7
- private cachedModels;
8
- private cacheTimestamp;
9
- private readonly cacheTtlMs;
10
- constructor({ baseUrl }?: {
11
- baseUrl?: string;
12
- });
13
- get models(): ModelInfo[];
14
- serializeTools(_tools: ToolDefinition[]): unknown;
15
- getModels(): Promise<ModelInfo[]>;
16
- chat(params: ChatParams): Promise<ChatResult>;
17
- chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
18
- }
19
-
20
- declare function createOllamaProvider(config?: {
1
+ import type { LLMProvider } from "../../shared/index.js";
2
+ import { OllamaProvider } from './provider.js';
3
+ export { OllamaProvider };
4
+ export default function createOllamaProvider(config?: {
21
5
  baseUrl?: string;
22
6
  }): LLMProvider;
23
-
24
- export { OllamaProvider, createOllamaProvider as default };
@@ -0,0 +1,17 @@
1
+ import type { LLMProvider, ChatParams, ChatResult, ModelInfo, ToolDefinition } from "../../shared/index.js";
2
+ export declare class OllamaProvider implements LLMProvider {
3
+ readonly id = "ollama";
4
+ readonly displayName = "Ollama";
5
+ private baseUrl;
6
+ private cachedModels;
7
+ private cacheTimestamp;
8
+ private readonly cacheTtlMs;
9
+ constructor({ baseUrl }?: {
10
+ baseUrl?: string;
11
+ });
12
+ get models(): ModelInfo[];
13
+ serializeTools(_tools: ToolDefinition[]): unknown;
14
+ getModels(): Promise<ModelInfo[]>;
15
+ chat(params: ChatParams): Promise<ChatResult>;
16
+ chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
17
+ }
@@ -1,22 +1,7 @@
1
- import { L as LLMProvider, M as ModelInfo, e as ToolDefinition, a as ChatParams, b as ChatResult } from '../../provider-BHkqkSdq.js';
2
-
3
- declare class OpenAIProvider implements LLMProvider {
4
- readonly id = "openai";
5
- readonly displayName = "OpenAI";
6
- readonly models: ModelInfo[];
7
- private client;
8
- constructor({ apiKey }: {
9
- apiKey: string;
10
- });
11
- serializeTools(tools: ToolDefinition[]): unknown;
12
- chat(params: ChatParams): Promise<ChatResult>;
13
- chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
14
- }
15
-
16
- declare const MODELS: ModelInfo[];
17
-
18
- declare function createOpenAIProvider(config: {
1
+ import type { LLMProvider } from "../../shared/index.js";
2
+ import { OpenAIProvider } from './provider.js';
3
+ import { MODELS } from './models.js';
4
+ export { OpenAIProvider, MODELS };
5
+ export default function createOpenAIProvider(config: {
19
6
  apiKey: string;
20
7
  }): LLMProvider;
21
-
22
- export { MODELS, OpenAIProvider, createOpenAIProvider as default };
@@ -0,0 +1,2 @@
1
+ import type { ModelInfo } from "../../shared/index.js";
2
+ export declare const MODELS: ModelInfo[];
@@ -0,0 +1,13 @@
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
+ }
@@ -0,0 +1,10 @@
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[];
@@ -0,0 +1,50 @@
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"];
@@ -0,0 +1,14 @@
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";
@@ -0,0 +1,36 @@
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,10 +1,8 @@
1
- import { c as ContentBlock } from './provider-BHkqkSdq.js';
2
-
3
1
  /** Channel adapter types — Story 1.5 / 4.1 */
4
-
5
- type ChatType = "direct" | "group" | "channel";
6
- type FormattingMode = "markdown" | "mrkdwn" | "html" | "plain";
7
- interface ChannelCapabilities {
2
+ import type { ContentBlock } from "./provider.js";
3
+ export type ChatType = "direct" | "group" | "channel";
4
+ export type FormattingMode = "markdown" | "mrkdwn" | "html" | "plain";
5
+ export interface ChannelCapabilities {
8
6
  chatTypes: ChatType[];
9
7
  threads: boolean;
10
8
  reactions: boolean;
@@ -14,12 +12,12 @@ interface ChannelCapabilities {
14
12
  maxTextLength: number;
15
13
  formattingMode: FormattingMode;
16
14
  }
17
- interface ChannelMeta {
15
+ export interface ChannelMeta {
18
16
  displayName: string;
19
17
  icon?: string;
20
18
  homepage?: string;
21
19
  }
22
- interface InboundMessage {
20
+ export interface InboundMessage {
23
21
  id: string;
24
22
  channel: string;
25
23
  account?: string;
@@ -38,32 +36,32 @@ interface InboundMessage {
38
36
  receivedAt: string;
39
37
  raw?: unknown;
40
38
  }
41
- type AttachmentMediaType = "image" | "video" | "audio" | "pdf" | "doc" | "excel" | "presentation" | "html" | "link" | "misc";
42
- interface Attachment {
39
+ export type AttachmentMediaType = "image" | "video" | "audio" | "pdf" | "doc" | "excel" | "presentation" | "html" | "link" | "misc";
40
+ export interface Attachment {
43
41
  type: AttachmentMediaType;
44
42
  url?: string;
45
43
  mimeType?: string;
46
44
  filename?: string;
47
45
  size?: number;
48
46
  }
49
- interface OutboundPayload {
47
+ export interface OutboundPayload {
50
48
  text: string;
51
49
  threadId?: string;
52
50
  replyToId?: string;
53
51
  attachments?: Attachment[];
54
52
  }
55
- interface SendResult {
53
+ export interface SendResult {
56
54
  success: boolean;
57
55
  messageId?: string;
58
56
  error?: string;
59
57
  }
60
- interface HealthStatus {
58
+ export interface HealthStatus {
61
59
  ok: boolean;
62
60
  latencyMs?: number;
63
61
  error?: string;
64
62
  }
65
- type ChannelConfig = Record<string, unknown>;
66
- interface ChannelAdapter {
63
+ export type ChannelConfig = Record<string, unknown>;
64
+ export interface ChannelAdapter {
67
65
  /** Unique identifier for this adapter instance */
68
66
  id: string;
69
67
  meta: ChannelMeta;
@@ -78,5 +76,3 @@ interface ChannelAdapter {
78
76
  /** Called when a message arrives — set by the framework */
79
77
  onMessage?: (message: InboundMessage) => Promise<void>;
80
78
  }
81
-
82
- export type { Attachment as A, ChannelAdapter as C, FormattingMode as F, HealthStatus as H, InboundMessage as I, OutboundPayload as O, SendResult as S, AttachmentMediaType as a, ChannelCapabilities as b, ChannelConfig as c, ChannelMeta as d, ChatType as e };