botinabox 2.5.2 → 2.6.0

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 (277) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/bin/botinabox.mjs +1 -1
  4. package/dist/{chunk-UACT2WXX.js → chunk-7AGWGYZC.js} +43 -5
  5. package/dist/cli.js +1 -1
  6. package/dist/connectors/google/index.d.ts +10 -1
  7. package/dist/connectors/google/index.js +1 -1
  8. package/dist/{gmail-connector-2FVYTQJH.js → gmail-connector-VP5FF56J.js} +2 -1
  9. package/dist/index.d.ts +64 -1
  10. package/dist/index.js +44 -10
  11. package/package.json +100 -100
  12. package/dist/channels/discord/adapter.d.ts +0 -32
  13. package/dist/channels/discord/adapter.js +0 -70
  14. package/dist/channels/discord/inbound.d.ts +0 -25
  15. package/dist/channels/discord/inbound.js +0 -24
  16. package/dist/channels/discord/models.d.ts +0 -8
  17. package/dist/channels/discord/models.js +0 -5
  18. package/dist/channels/discord/outbound.d.ts +0 -14
  19. package/dist/channels/discord/outbound.js +0 -38
  20. package/dist/channels/slack/adapter.d.ts +0 -33
  21. package/dist/channels/slack/adapter.js +0 -74
  22. package/dist/channels/slack/inbound.d.ts +0 -59
  23. package/dist/channels/slack/inbound.js +0 -96
  24. package/dist/channels/slack/models.d.ts +0 -9
  25. package/dist/channels/slack/models.js +0 -5
  26. package/dist/channels/slack/outbound.d.ts +0 -12
  27. package/dist/channels/slack/outbound.js +0 -18
  28. package/dist/channels/slack/transcribe.d.ts +0 -41
  29. package/dist/channels/slack/transcribe.js +0 -106
  30. package/dist/channels/webhook/adapter.d.ts +0 -23
  31. package/dist/channels/webhook/adapter.js +0 -86
  32. package/dist/channels/webhook/hmac.d.ts +0 -13
  33. package/dist/channels/webhook/hmac.js +0 -26
  34. package/dist/channels/webhook/models.d.ts +0 -9
  35. package/dist/channels/webhook/models.js +0 -5
  36. package/dist/channels/webhook/server.d.ts +0 -20
  37. package/dist/channels/webhook/server.js +0 -91
  38. package/dist/chat-pipeline-C-XlLGNl.d.ts +0 -648
  39. package/dist/chat-pipeline-CR1KF6eX.d.ts +0 -652
  40. package/dist/chat-pipeline-DisuC8SB.d.ts +0 -643
  41. package/dist/chunk-2LGXQPEA.js +0 -41
  42. package/dist/chunk-3X3YKI4T.js +0 -357
  43. package/dist/chunk-D47AIFOD.js +0 -351
  44. package/dist/chunk-DSNJKNEW.js +0 -328
  45. package/dist/chunk-GS2JFL6I.js +0 -144
  46. package/dist/chunk-J6S6QMUY.js +0 -144
  47. package/dist/chunk-QLA6YOFN.js +0 -22
  48. package/dist/cli/templates/config.yml.d.ts +0 -7
  49. package/dist/cli/templates/config.yml.js +0 -61
  50. package/dist/cli/templates/env.d.ts +0 -1
  51. package/dist/cli/templates/env.js +0 -30
  52. package/dist/cli/templates/index.ts.d.ts +0 -2
  53. package/dist/cli/templates/index.ts.js +0 -30
  54. package/dist/cli/templates/package.json.d.ts +0 -5
  55. package/dist/cli/templates/package.json.js +0 -28
  56. package/dist/connector-DDahQw-2.d.ts +0 -63
  57. package/dist/connectors/google/calendar-connector.d.ts +0 -40
  58. package/dist/connectors/google/calendar-connector.js +0 -243
  59. package/dist/connectors/google/gmail-connector.d.ts +0 -42
  60. package/dist/connectors/google/gmail-connector.js +0 -345
  61. package/dist/connectors/google/oauth.d.ts +0 -48
  62. package/dist/connectors/google/oauth.js +0 -112
  63. package/dist/connectors/google/types.d.ts +0 -78
  64. package/dist/connectors/google/types.js +0 -2
  65. package/dist/core/chat/auto-discovery.d.ts +0 -16
  66. package/dist/core/chat/auto-discovery.js +0 -54
  67. package/dist/core/chat/channel-registry.d.ts +0 -45
  68. package/dist/core/chat/channel-registry.js +0 -96
  69. package/dist/core/chat/chat-pipeline.d.ts +0 -113
  70. package/dist/core/chat/chat-pipeline.js +0 -395
  71. package/dist/core/chat/chat-responder.d.ts +0 -90
  72. package/dist/core/chat/chat-responder.js +0 -185
  73. package/dist/core/chat/formatter.d.ts +0 -11
  74. package/dist/core/chat/formatter.js +0 -60
  75. package/dist/core/chat/index.d.ts +0 -24
  76. package/dist/core/chat/index.js +0 -18
  77. package/dist/core/chat/message-interpreter.d.ts +0 -91
  78. package/dist/core/chat/message-interpreter.js +0 -166
  79. package/dist/core/chat/message-store.d.ts +0 -66
  80. package/dist/core/chat/message-store.js +0 -131
  81. package/dist/core/chat/notification-queue.d.ts +0 -34
  82. package/dist/core/chat/notification-queue.js +0 -111
  83. package/dist/core/chat/pipeline.d.ts +0 -38
  84. package/dist/core/chat/pipeline.js +0 -89
  85. package/dist/core/chat/policies.d.ts +0 -16
  86. package/dist/core/chat/policies.js +0 -25
  87. package/dist/core/chat/routing.d.ts +0 -17
  88. package/dist/core/chat/routing.js +0 -36
  89. package/dist/core/chat/session-key.d.ts +0 -30
  90. package/dist/core/chat/session-key.js +0 -65
  91. package/dist/core/chat/session-manager.d.ts +0 -17
  92. package/dist/core/chat/session-manager.js +0 -23
  93. package/dist/core/chat/text-chunker.d.ts +0 -9
  94. package/dist/core/chat/text-chunker.js +0 -48
  95. package/dist/core/chat/triage-router.d.ts +0 -75
  96. package/dist/core/chat/triage-router.js +0 -142
  97. package/dist/core/chat/types.d.ts +0 -5
  98. package/dist/core/chat/types.js +0 -5
  99. package/dist/core/config/defaults.d.ts +0 -2
  100. package/dist/core/config/defaults.js +0 -38
  101. package/dist/core/config/index.d.ts +0 -6
  102. package/dist/core/config/index.js +0 -4
  103. package/dist/core/config/interpolate.d.ts +0 -5
  104. package/dist/core/config/interpolate.js +0 -27
  105. package/dist/core/config/loader.d.ts +0 -24
  106. package/dist/core/config/loader.js +0 -59
  107. package/dist/core/config/schema.d.ts +0 -5
  108. package/dist/core/config/schema.js +0 -119
  109. package/dist/core/data/core-entity-contexts.d.ts +0 -14
  110. package/dist/core/data/core-entity-contexts.js +0 -197
  111. package/dist/core/data/core-migrations.d.ts +0 -5
  112. package/dist/core/data/core-migrations.js +0 -45
  113. package/dist/core/data/core-schema.d.ts +0 -6
  114. package/dist/core/data/core-schema.js +0 -454
  115. package/dist/core/data/data-store.d.ts +0 -67
  116. package/dist/core/data/data-store.js +0 -218
  117. package/dist/core/data/domain-entity-contexts.d.ts +0 -29
  118. package/dist/core/data/domain-entity-contexts.js +0 -321
  119. package/dist/core/data/domain-schema.d.ts +0 -36
  120. package/dist/core/data/domain-schema.js +0 -323
  121. package/dist/core/data/index.d.ts +0 -7
  122. package/dist/core/data/index.js +0 -7
  123. package/dist/core/data/types.d.ts +0 -111
  124. package/dist/core/data/types.js +0 -1
  125. package/dist/core/hooks/hook-bus.d.ts +0 -18
  126. package/dist/core/hooks/hook-bus.js +0 -120
  127. package/dist/core/hooks/index.d.ts +0 -2
  128. package/dist/core/hooks/index.js +0 -1
  129. package/dist/core/hooks/types.d.ts +0 -19
  130. package/dist/core/hooks/types.js +0 -1
  131. package/dist/core/index.d.ts +0 -4
  132. package/dist/core/index.js +0 -4
  133. package/dist/core/llm/auto-discovery.d.ts +0 -11
  134. package/dist/core/llm/auto-discovery.js +0 -49
  135. package/dist/core/llm/cost-tracker.d.ts +0 -6
  136. package/dist/core/llm/cost-tracker.js +0 -38
  137. package/dist/core/llm/index.d.ts +0 -4
  138. package/dist/core/llm/index.js +0 -3
  139. package/dist/core/llm/model-router.d.ts +0 -25
  140. package/dist/core/llm/model-router.js +0 -49
  141. package/dist/core/llm/provider-registry.d.ts +0 -9
  142. package/dist/core/llm/provider-registry.js +0 -25
  143. package/dist/core/llm/types.d.ts +0 -2
  144. package/dist/core/llm/types.js +0 -2
  145. package/dist/core/orchestrator/adapters/api-adapter.d.ts +0 -34
  146. package/dist/core/orchestrator/adapters/api-adapter.js +0 -88
  147. package/dist/core/orchestrator/adapters/cli-adapter.d.ts +0 -22
  148. package/dist/core/orchestrator/adapters/cli-adapter.js +0 -69
  149. package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +0 -35
  150. package/dist/core/orchestrator/adapters/deterministic-adapter.js +0 -75
  151. package/dist/core/orchestrator/adapters/env-whitelist.d.ts +0 -4
  152. package/dist/core/orchestrator/adapters/env-whitelist.js +0 -27
  153. package/dist/core/orchestrator/adapters/output-extractor.d.ts +0 -11
  154. package/dist/core/orchestrator/adapters/output-extractor.js +0 -59
  155. package/dist/core/orchestrator/adapters/process-manager.d.ts +0 -15
  156. package/dist/core/orchestrator/adapters/process-manager.js +0 -26
  157. package/dist/core/orchestrator/adapters/tool-loop.d.ts +0 -22
  158. package/dist/core/orchestrator/adapters/tool-loop.js +0 -66
  159. package/dist/core/orchestrator/agent-registry.d.ts +0 -31
  160. package/dist/core/orchestrator/agent-registry.js +0 -135
  161. package/dist/core/orchestrator/budget-controller.d.ts +0 -19
  162. package/dist/core/orchestrator/budget-controller.js +0 -73
  163. package/dist/core/orchestrator/chain-guard.d.ts +0 -14
  164. package/dist/core/orchestrator/chain-guard.js +0 -23
  165. package/dist/core/orchestrator/circuit-breaker.d.ts +0 -65
  166. package/dist/core/orchestrator/circuit-breaker.js +0 -159
  167. package/dist/core/orchestrator/claude-stream-parser.d.ts +0 -31
  168. package/dist/core/orchestrator/claude-stream-parser.js +0 -99
  169. package/dist/core/orchestrator/config-revisions.d.ts +0 -6
  170. package/dist/core/orchestrator/config-revisions.js +0 -17
  171. package/dist/core/orchestrator/dependency-resolver.d.ts +0 -20
  172. package/dist/core/orchestrator/dependency-resolver.js +0 -78
  173. package/dist/core/orchestrator/governance-gate.d.ts +0 -110
  174. package/dist/core/orchestrator/governance-gate.js +0 -170
  175. package/dist/core/orchestrator/learning-pipeline.d.ts +0 -109
  176. package/dist/core/orchestrator/learning-pipeline.js +0 -249
  177. package/dist/core/orchestrator/loop-detector.d.ts +0 -51
  178. package/dist/core/orchestrator/loop-detector.js +0 -133
  179. package/dist/core/orchestrator/ndjson-logger.d.ts +0 -6
  180. package/dist/core/orchestrator/ndjson-logger.js +0 -18
  181. package/dist/core/orchestrator/permission-relay.d.ts +0 -72
  182. package/dist/core/orchestrator/permission-relay.js +0 -164
  183. package/dist/core/orchestrator/run-manager.d.ts +0 -31
  184. package/dist/core/orchestrator/run-manager.js +0 -178
  185. package/dist/core/orchestrator/scheduler.d.ts +0 -70
  186. package/dist/core/orchestrator/scheduler.js +0 -198
  187. package/dist/core/orchestrator/secret-store.d.ts +0 -57
  188. package/dist/core/orchestrator/secret-store.js +0 -171
  189. package/dist/core/orchestrator/session-manager.d.ts +0 -13
  190. package/dist/core/orchestrator/session-manager.js +0 -66
  191. package/dist/core/orchestrator/task-queue.d.ts +0 -34
  192. package/dist/core/orchestrator/task-queue.js +0 -83
  193. package/dist/core/orchestrator/template-interpolate.d.ts +0 -5
  194. package/dist/core/orchestrator/template-interpolate.js +0 -18
  195. package/dist/core/orchestrator/user-registry.d.ts +0 -47
  196. package/dist/core/orchestrator/user-registry.js +0 -76
  197. package/dist/core/orchestrator/wakeup-queue.d.ts +0 -9
  198. package/dist/core/orchestrator/wakeup-queue.js +0 -45
  199. package/dist/core/orchestrator/workflow-engine.d.ts +0 -47
  200. package/dist/core/orchestrator/workflow-engine.js +0 -204
  201. package/dist/core/security/audit.d.ts +0 -20
  202. package/dist/core/security/audit.js +0 -33
  203. package/dist/core/security/column-validator.d.ts +0 -20
  204. package/dist/core/security/column-validator.js +0 -37
  205. package/dist/core/security/index.d.ts +0 -5
  206. package/dist/core/security/index.js +0 -5
  207. package/dist/core/security/process-env.d.ts +0 -13
  208. package/dist/core/security/process-env.js +0 -49
  209. package/dist/core/security/sanitizer.d.ts +0 -11
  210. package/dist/core/security/sanitizer.js +0 -39
  211. package/dist/core/security/types.d.ts +0 -11
  212. package/dist/core/security/types.js +0 -1
  213. package/dist/core/update/auto-update.d.ts +0 -21
  214. package/dist/core/update/auto-update.js +0 -102
  215. package/dist/core/update/backup-manager.d.ts +0 -7
  216. package/dist/core/update/backup-manager.js +0 -24
  217. package/dist/core/update/index.d.ts +0 -8
  218. package/dist/core/update/index.js +0 -6
  219. package/dist/core/update/migration-hooks.d.ts +0 -11
  220. package/dist/core/update/migration-hooks.js +0 -10
  221. package/dist/core/update/types.d.ts +0 -11
  222. package/dist/core/update/types.js +0 -1
  223. package/dist/core/update/update-checker.d.ts +0 -11
  224. package/dist/core/update/update-checker.js +0 -63
  225. package/dist/core/update/update-manager.d.ts +0 -25
  226. package/dist/core/update/update-manager.js +0 -101
  227. package/dist/core/update/version-utils.d.ts +0 -6
  228. package/dist/core/update/version-utils.js +0 -34
  229. package/dist/gmail-connector-MNUBRNFM.js +0 -6
  230. package/dist/gmail-connector-PS2VLGNE.js +0 -6
  231. package/dist/gmail-connector-ULSMN6X2.js +0 -6
  232. package/dist/gmail-connector-URRFX6A3.js +0 -6
  233. package/dist/inbound-AFBUPSPG.js +0 -10
  234. package/dist/inbound-AFOHYNUY.js +0 -6
  235. package/dist/inbound-CGIXRXGC.js +0 -8
  236. package/dist/inbound-MCOLRH6U.js +0 -10
  237. package/dist/inbound-SNEMBLGA.js +0 -6
  238. package/dist/inbound-ZJHAYVMF.js +0 -10
  239. package/dist/provider-qqJYv9nv.d.ts +0 -75
  240. package/dist/providers/anthropic/models.d.ts +0 -2
  241. package/dist/providers/anthropic/models.js +0 -29
  242. package/dist/providers/anthropic/provider.d.ts +0 -13
  243. package/dist/providers/anthropic/provider.js +0 -119
  244. package/dist/providers/anthropic/tool-converter.d.ts +0 -10
  245. package/dist/providers/anthropic/tool-converter.js +0 -7
  246. package/dist/providers/ollama/provider.d.ts +0 -17
  247. package/dist/providers/ollama/provider.js +0 -185
  248. package/dist/providers/openai/models.d.ts +0 -2
  249. package/dist/providers/openai/models.js +0 -29
  250. package/dist/providers/openai/provider.d.ts +0 -13
  251. package/dist/providers/openai/provider.js +0 -163
  252. package/dist/providers/openai/tool-converter.d.ts +0 -10
  253. package/dist/providers/openai/tool-converter.js +0 -10
  254. package/dist/shared/constants.d.ts +0 -50
  255. package/dist/shared/constants.js +0 -64
  256. package/dist/shared/index.d.ts +0 -14
  257. package/dist/shared/index.js +0 -14
  258. package/dist/shared/types/agent.d.ts +0 -36
  259. package/dist/shared/types/agent.js +0 -2
  260. package/dist/shared/types/channel.d.ts +0 -70
  261. package/dist/shared/types/channel.js +0 -2
  262. package/dist/shared/types/config.d.ts +0 -111
  263. package/dist/shared/types/config.js +0 -2
  264. package/dist/shared/types/connector.d.ts +0 -77
  265. package/dist/shared/types/connector.js +0 -2
  266. package/dist/shared/types/execution.d.ts +0 -29
  267. package/dist/shared/types/execution.js +0 -2
  268. package/dist/shared/types/provider.d.ts +0 -73
  269. package/dist/shared/types/provider.js +0 -2
  270. package/dist/shared/types/task.d.ts +0 -47
  271. package/dist/shared/types/task.js +0 -2
  272. package/dist/shared/types/workflow.d.ts +0 -39
  273. package/dist/shared/types/workflow.js +0 -2
  274. package/dist/shared/utils.d.ts +0 -6
  275. package/dist/shared/utils.js +0 -13
  276. package/dist/update-check.d.ts +0 -5
  277. package/dist/update-check.js +0 -56
package/dist/index.d.ts CHANGED
@@ -950,6 +950,12 @@ interface ToolContext {
950
950
  /** Resolve a relative file path to an absolute path (environment-aware). */
951
951
  resolveFilePath?: (path: string) => string;
952
952
  }
953
+ interface ContextFile {
954
+ /** Absolute path, used as the `path` attribute in the wrapped XML tag. */
955
+ path: string;
956
+ /** Raw file contents (UTF-8). The engine does not read the filesystem itself. */
957
+ content: string;
958
+ }
953
959
  interface ExecutionEngineConfig {
954
960
  /** Anthropic client instance */
955
961
  client: {
@@ -985,6 +991,23 @@ interface ExecutionEngineConfig {
985
991
  includeSystemContext?: boolean;
986
992
  /** Resolve file paths from DB-relative to absolute (for cross-environment support). */
987
993
  resolveFilePath?: (path: string) => string;
994
+ /**
995
+ * Optional per-dispatch context resolver. Called once per task pickup with
996
+ * the resolved agent and task rows. Returned files are wrapped in
997
+ * `<file path="...">...</file>` XML tags and inserted into the system
998
+ * prompt between the static `buildSystemContext` block and the tool
999
+ * listing. Intended for apps that want to inject per-agent or per-project
1000
+ * rendered context (rules, playbooks, agent definitions) that is not
1001
+ * already covered by `buildSystemContext`.
1002
+ *
1003
+ * The resolver owns all filesystem / database lookups — the engine does
1004
+ * not touch the disk. If the resolver throws, the task fails loudly per
1005
+ * Rule-16-style fail-loud semantics; there is no silent fallback.
1006
+ */
1007
+ resolveContextFiles?: (ctx: {
1008
+ agent: Record<string, unknown>;
1009
+ task: Record<string, unknown>;
1010
+ }) => Promise<ContextFile[]> | ContextFile[];
988
1011
  }
989
1012
  declare function registerExecutionEngine(opts: {
990
1013
  db: DataStore;
@@ -1663,6 +1686,27 @@ declare class ApiExecutionAdapter {
1663
1686
  }>;
1664
1687
  }
1665
1688
 
1689
+ /**
1690
+ * Inputs to the CLI argument builder. Kept as a separate type so the
1691
+ * pure arg-construction function is unit-testable without spawning a process.
1692
+ */
1693
+ interface CliArgBuildInput {
1694
+ prompt: string;
1695
+ skipPermissions?: boolean;
1696
+ sessionId?: string;
1697
+ settings?: string;
1698
+ appendSystemPrompt?: string;
1699
+ addDirs?: string[];
1700
+ extraArgs?: string[];
1701
+ }
1702
+ /**
1703
+ * Build the argv array passed to the `claude` binary.
1704
+ *
1705
+ * Order matters for the `claude` CLI: flags come first, then `--print` with
1706
+ * the prompt as the final positional argument. This function exists so the
1707
+ * argv shape can be asserted in tests without a real subprocess.
1708
+ */
1709
+ declare function buildCliArgs(input: CliArgBuildInput): string[];
1666
1710
  declare class CliExecutionAdapter {
1667
1711
  readonly type = "cli";
1668
1712
  execute(ctx: {
@@ -1677,6 +1721,25 @@ declare class CliExecutionAdapter {
1677
1721
  description?: string;
1678
1722
  context?: string;
1679
1723
  };
1724
+ /**
1725
+ * Optional Claude Code session UUID. When provided, passed as `--session-id`
1726
+ * so the same UUID on subsequent calls resumes the same conversation.
1727
+ * Callers typically derive this deterministically from a stable conversation
1728
+ * key (e.g. thread identifier) so multi-turn exchanges maintain history.
1729
+ */
1730
+ sessionId?: string;
1731
+ /**
1732
+ * Value for `--settings`. Accepts a JSON string or a path to a settings
1733
+ * file. Use this to override settings like `autoMemoryDirectory` without
1734
+ * mutating the caller's global config.
1735
+ */
1736
+ settings?: string;
1737
+ /** Value for `--append-system-prompt`. */
1738
+ appendSystemPrompt?: string;
1739
+ /** Additional directories passed via `--add-dir`. */
1740
+ addDirs?: string[];
1741
+ /** Extra CLI flags appended before the positional prompt. */
1742
+ extraArgs?: string[];
1680
1743
  logPath?: string;
1681
1744
  onLog?: (stream: string, chunk: string) => void;
1682
1745
  abortSignal?: AbortSignal;
@@ -2300,4 +2363,4 @@ declare function isLoginRequired(stdout: string): boolean;
2300
2363
  /** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
2301
2364
  declare function deactivateLocalImagePaths(prompt: string): string;
2302
2365
 
2303
- export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, type ApprovalResponse, type ApprovalStatus, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, BreakerState, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, type ChatConfig, ChatMessage, ChatPipelineV2, type ChatPipelineV2Config, ChatResponder, ChatResponderConfig, ChatSessionManager, CircuitBreaker, type CircuitBreakerConfig, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, type DefaultLLMCallConfig, DeterministicAdapter, type DeterministicConfig, type DomainEntityContextOptions, type DomainSchemaOptions, DriftGate, EVENTS, type EntityColumnDef, type EntityConfig, type ExecutionAdapter, type ExecutionConfig, type ExecutionEngineConfig, Extractor, type FeedbackEntry, type GateFinding, type GateInput, type GateResult, GateRunner, type GateVerdict, GovernanceGate, HealthStatus, HookBus, InboundMessage, LLMProvider, LearningPipeline, type LearningPipelineConfig, type LoopDetection, LoopDetector, type LoopDetectorConfig, LoopType, MAX_CHAIN_DEPTH, MessageInterpreter, MessagePipeline, MessageStore, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PermissionPrompt, type PermissionProvider, PermissionRelay, type PermissionRelayConfig, type PlaybookEntry, ProviderRegistry, QAGate, QualityGate, RUN_STATUSES, type RenderConfig, ResolvedModel, type RetryPolicy, type RoutingConfig, type RunContext, RunManager, type RunResult, type RunStatus, type SafetyConfig, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, SessionKey, SessionManager, type SkillEntry, type StepRef, type SystemContextOptions, TASK_STATUSES, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, addTaskCommentTool, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, cancelTaskTool, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, coordinatorTools, createAgentTool, createConfigRevision, createDefaultLLMCall, createProjectTool, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, dispatchTaskTool, formatText, getActiveTasksTool, getAgentDetailTool, getAgentStatusTool, getConfig, getSystemStatusTool, getTaskStatusTool, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, listAgentsTool, listFilesTool, listProjectsTool, loadConfig, nativeTools, parseClaudeStream, parseVersion, readConversationTool, readFileTool, reassignTaskTool, registerExecutionEngine, registerFileTool, resolveAgent, runPackageMigrations, sanitize, searchConversationTool, sendFileTool, sendMessageTool, topologicalSort, truncateAtWord, validateConfig };
2366
+ export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, type ApprovalResponse, type ApprovalStatus, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, BreakerState, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, type ChatConfig, ChatMessage, ChatPipelineV2, type ChatPipelineV2Config, ChatResponder, ChatResponderConfig, ChatSessionManager, CircuitBreaker, type CircuitBreakerConfig, type CliArgBuildInput, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, type DefaultLLMCallConfig, DeterministicAdapter, type DeterministicConfig, type DomainEntityContextOptions, type DomainSchemaOptions, DriftGate, EVENTS, type EntityColumnDef, type EntityConfig, type ExecutionAdapter, type ExecutionConfig, type ExecutionEngineConfig, Extractor, type FeedbackEntry, type GateFinding, type GateInput, type GateResult, GateRunner, type GateVerdict, GovernanceGate, HealthStatus, HookBus, InboundMessage, LLMProvider, LearningPipeline, type LearningPipelineConfig, type LoopDetection, LoopDetector, type LoopDetectorConfig, LoopType, MAX_CHAIN_DEPTH, MessageInterpreter, MessagePipeline, MessageStore, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PermissionPrompt, type PermissionProvider, PermissionRelay, type PermissionRelayConfig, type PlaybookEntry, ProviderRegistry, QAGate, QualityGate, RUN_STATUSES, type RenderConfig, ResolvedModel, type RetryPolicy, type RoutingConfig, type RunContext, RunManager, type RunResult, type RunStatus, type SafetyConfig, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, SessionKey, SessionManager, type SkillEntry, type StepRef, type SystemContextOptions, TASK_STATUSES, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type ToolContext, type ToolDefinition, type ToolHandler, UpdateChecker, type UpdateConfig, UpdateManager, type UpdateManifest, type UsageSummary, type User, type UserInput, UserRegistry, WakeupQueue, type WorkflowConfigEntry, type WorkflowDefinition$1 as WorkflowDefinition, WorkflowEngine, type WorkflowRunRecord, type WorkflowRunStatus, type WorkflowStep$1 as WorkflowStep, type WorkflowStepConfig, type WorkflowTrigger, _resetConfig, addTaskCommentTool, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildCliArgs, buildProcessEnv, buildSystemContext, cancelTaskTool, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, coordinatorTools, createAgentTool, createConfigRevision, createDefaultLLMCall, createProjectTool, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, dispatchTaskTool, formatText, getActiveTasksTool, getAgentDetailTool, getAgentStatusTool, getConfig, getSystemStatusTool, getTaskStatusTool, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, listAgentsTool, listFilesTool, listProjectsTool, loadConfig, nativeTools, parseClaudeStream, parseVersion, readConversationTool, readFileTool, reassignTaskTool, registerExecutionEngine, registerFileTool, resolveAgent, runPackageMigrations, sanitize, searchConversationTool, sendFileTool, sendMessageTool, topologicalSort, truncateAtWord, validateConfig };
package/dist/index.js CHANGED
@@ -5555,6 +5555,29 @@ function extractOutput(ndjsonContent) {
5555
5555
  }
5556
5556
 
5557
5557
  // src/core/orchestrator/adapters/cli-adapter.ts
5558
+ function buildCliArgs(input) {
5559
+ const args = [];
5560
+ if (input.skipPermissions) {
5561
+ args.push("--dangerously-skip-permissions");
5562
+ }
5563
+ if (input.sessionId) {
5564
+ args.push("--session-id", input.sessionId);
5565
+ }
5566
+ if (input.settings) {
5567
+ args.push("--settings", input.settings);
5568
+ }
5569
+ if (input.appendSystemPrompt) {
5570
+ args.push("--append-system-prompt", input.appendSystemPrompt);
5571
+ }
5572
+ if (input.addDirs && input.addDirs.length > 0) {
5573
+ args.push("--add-dir", ...input.addDirs);
5574
+ }
5575
+ if (input.extraArgs && input.extraArgs.length > 0) {
5576
+ args.push(...input.extraArgs);
5577
+ }
5578
+ args.push("--print", input.prompt);
5579
+ return args;
5580
+ }
5558
5581
  var CliExecutionAdapter = class {
5559
5582
  type = "cli";
5560
5583
  async execute(ctx) {
@@ -5567,16 +5590,16 @@ var CliExecutionAdapter = class {
5567
5590
  }
5568
5591
  }
5569
5592
  const skipPermissions = ctx.agent.skip_permissions ?? config["skip_permissions"] ?? false;
5570
- const args = [];
5571
- if (skipPermissions) {
5572
- args.push("--dangerously-skip-permissions");
5573
- }
5574
- const prompt = [
5575
- ctx.task.title,
5576
- ctx.task.description,
5577
- ctx.task.context
5578
- ].filter(Boolean).join("\n\n");
5579
- args.push("--print", prompt);
5593
+ const prompt = [ctx.task.title, ctx.task.description, ctx.task.context].filter(Boolean).join("\n\n");
5594
+ const args = buildCliArgs({
5595
+ prompt,
5596
+ skipPermissions,
5597
+ sessionId: ctx.sessionId,
5598
+ settings: ctx.settings,
5599
+ appendSystemPrompt: ctx.appendSystemPrompt,
5600
+ addDirs: ctx.addDirs,
5601
+ extraArgs: ctx.extraArgs
5602
+ });
5580
5603
  const child = spawnProcess("claude", args, { cwd });
5581
5604
  const stdoutChunks = [];
5582
5605
  let logStream = null;
@@ -6417,6 +6440,12 @@ var GateRunner = class {
6417
6440
  };
6418
6441
 
6419
6442
  // src/core/orchestrator/execution-engine.ts
6443
+ function formatContextFilesBlock(files) {
6444
+ if (!files || files.length === 0) return "";
6445
+ return files.map((f) => `<file path="${f.path}">
6446
+ ${f.content}
6447
+ </file>`).join("\n\n");
6448
+ }
6420
6449
  async function registerExecutionEngine(opts) {
6421
6450
  const { db, hooks, runs, config } = opts;
6422
6451
  const model = config.model ?? "claude-sonnet-4-20250514";
@@ -6445,6 +6474,8 @@ async function registerExecutionEngine(opts) {
6445
6474
  }
6446
6475
  const prompt = task.description ?? task.title ?? "";
6447
6476
  try {
6477
+ const contextFiles = config.resolveContextFiles ? await config.resolveContextFiles({ agent, task }) : [];
6478
+ const contextFilesBlock = formatContextFilesBlock(contextFiles);
6448
6479
  const toolListing = toolDefs.length > 0 ? `
6449
6480
  ## Available Tools
6450
6481
  ${toolDefs.map((t) => `- **${t.name}**: ${t.description}`).join("\n")}
@@ -6454,6 +6485,8 @@ Use your tools to take action. Do NOT describe what you would do \u2014 call the
6454
6485
  `You are ${agent.name}, an AI agent with role: ${agent.role}.`,
6455
6486
  systemContext ? `
6456
6487
  ${systemContext}` : "",
6488
+ contextFilesBlock ? `
6489
+ ${contextFilesBlock}` : "",
6457
6490
  toolListing,
6458
6491
  config.systemPromptSuffix ?? ""
6459
6492
  ].filter(Boolean).join("\n");
@@ -7535,6 +7568,7 @@ export {
7535
7568
  autoUpdate,
7536
7569
  buildAgentBindings,
7537
7570
  buildChainOrigin,
7571
+ buildCliArgs,
7538
7572
  buildProcessEnv,
7539
7573
  buildSystemContext,
7540
7574
  cancelTaskTool,
package/package.json CHANGED
@@ -1,100 +1,100 @@
1
- {
2
- "name": "botinabox",
3
- "version": "2.5.2",
4
- "description": "Bot in a Box — framework for building multi-agent bots",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/index.js",
11
- "types": "./dist/index.d.ts"
12
- },
13
- "./anthropic": {
14
- "import": "./dist/providers/anthropic/index.js",
15
- "types": "./dist/providers/anthropic/index.d.ts"
16
- },
17
- "./openai": {
18
- "import": "./dist/providers/openai/index.js",
19
- "types": "./dist/providers/openai/index.d.ts"
20
- },
21
- "./ollama": {
22
- "import": "./dist/providers/ollama/index.js",
23
- "types": "./dist/providers/ollama/index.d.ts"
24
- },
25
- "./slack": {
26
- "import": "./dist/channels/slack/index.js",
27
- "types": "./dist/channels/slack/index.d.ts"
28
- },
29
- "./discord": {
30
- "import": "./dist/channels/discord/index.js",
31
- "types": "./dist/channels/discord/index.d.ts"
32
- },
33
- "./webhook": {
34
- "import": "./dist/channels/webhook/index.js",
35
- "types": "./dist/channels/webhook/index.d.ts"
36
- },
37
- "./google": {
38
- "import": "./dist/connectors/google/index.js",
39
- "types": "./dist/connectors/google/index.d.ts"
40
- }
41
- },
42
- "bin": {
43
- "botinabox": "./bin/botinabox.mjs"
44
- },
45
- "files": [
46
- "dist",
47
- "bin"
48
- ],
49
- "engines": {
50
- "node": ">=18"
51
- },
52
- "scripts": {
53
- "build": "tsup",
54
- "test": "vitest run",
55
- "typecheck": "tsc --noEmit",
56
- "check-docs": "echo 'Documentation check passed'",
57
- "prepublishOnly": "npm run build && npm run typecheck && npm test"
58
- },
59
- "dependencies": {
60
- "@types/uuid": "^10.0.0",
61
- "ajv": "^8.17.1",
62
- "cron-parser": "^4.9.0",
63
- "latticesql": "^1.4.0",
64
- "uuid": "^13.0.0",
65
- "yaml": "^2.7.0"
66
- },
67
- "optionalDependencies": {
68
- "whisper-node": "^1.1.1"
69
- },
70
- "peerDependencies": {
71
- "@anthropic-ai/sdk": "^0.52.0",
72
- "googleapis": ">=140.0.0 <200.0.0",
73
- "openai": "^4.104.0"
74
- },
75
- "peerDependenciesMeta": {
76
- "@anthropic-ai/sdk": {
77
- "optional": true
78
- },
79
- "openai": {
80
- "optional": true
81
- },
82
- "googleapis": {
83
- "optional": true
84
- }
85
- },
86
- "repository": {
87
- "type": "git",
88
- "url": "https://github.com/automated-industries/botinabox.git"
89
- },
90
- "devDependencies": {
91
- "@anthropic-ai/sdk": "^0.52.0",
92
- "@types/better-sqlite3": "^7.6.12",
93
- "@types/node": "^22.10.0",
94
- "googleapis": "^171.4.0",
95
- "openai": "^4.104.0",
96
- "tsup": "^8.3.5",
97
- "typescript": "^5.7.2",
98
- "vitest": "^3.0.0"
99
- }
100
- }
1
+ {
2
+ "name": "botinabox",
3
+ "version": "2.6.0",
4
+ "description": "Bot in a Box — framework for building multi-agent bots",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./anthropic": {
14
+ "import": "./dist/providers/anthropic/index.js",
15
+ "types": "./dist/providers/anthropic/index.d.ts"
16
+ },
17
+ "./openai": {
18
+ "import": "./dist/providers/openai/index.js",
19
+ "types": "./dist/providers/openai/index.d.ts"
20
+ },
21
+ "./ollama": {
22
+ "import": "./dist/providers/ollama/index.js",
23
+ "types": "./dist/providers/ollama/index.d.ts"
24
+ },
25
+ "./slack": {
26
+ "import": "./dist/channels/slack/index.js",
27
+ "types": "./dist/channels/slack/index.d.ts"
28
+ },
29
+ "./discord": {
30
+ "import": "./dist/channels/discord/index.js",
31
+ "types": "./dist/channels/discord/index.d.ts"
32
+ },
33
+ "./webhook": {
34
+ "import": "./dist/channels/webhook/index.js",
35
+ "types": "./dist/channels/webhook/index.d.ts"
36
+ },
37
+ "./google": {
38
+ "import": "./dist/connectors/google/index.js",
39
+ "types": "./dist/connectors/google/index.d.ts"
40
+ }
41
+ },
42
+ "bin": {
43
+ "botinabox": "./bin/botinabox.mjs"
44
+ },
45
+ "files": [
46
+ "dist",
47
+ "bin"
48
+ ],
49
+ "engines": {
50
+ "node": ">=18"
51
+ },
52
+ "scripts": {
53
+ "build": "tsup",
54
+ "test": "vitest run",
55
+ "typecheck": "tsc --noEmit",
56
+ "check-docs": "echo 'Documentation check passed'",
57
+ "prepublishOnly": "npm run build && npm run typecheck && npm test"
58
+ },
59
+ "dependencies": {
60
+ "@types/uuid": "^10.0.0",
61
+ "ajv": "^8.17.1",
62
+ "cron-parser": "^4.9.0",
63
+ "latticesql": "^1.4.0",
64
+ "uuid": "^13.0.0",
65
+ "yaml": "^2.7.0"
66
+ },
67
+ "optionalDependencies": {
68
+ "whisper-node": "^1.1.1"
69
+ },
70
+ "peerDependencies": {
71
+ "@anthropic-ai/sdk": "^0.52.0",
72
+ "googleapis": ">=140.0.0 <200.0.0",
73
+ "openai": "^4.104.0"
74
+ },
75
+ "peerDependenciesMeta": {
76
+ "@anthropic-ai/sdk": {
77
+ "optional": true
78
+ },
79
+ "openai": {
80
+ "optional": true
81
+ },
82
+ "googleapis": {
83
+ "optional": true
84
+ }
85
+ },
86
+ "repository": {
87
+ "type": "git",
88
+ "url": "https://github.com/automated-industries/botinabox.git"
89
+ },
90
+ "devDependencies": {
91
+ "@anthropic-ai/sdk": "^0.52.0",
92
+ "@types/better-sqlite3": "^7.6.12",
93
+ "@types/node": "^22.10.0",
94
+ "googleapis": "^171.4.0",
95
+ "openai": "^4.104.0",
96
+ "tsup": "^8.3.5",
97
+ "typescript": "^5.7.2",
98
+ "vitest": "^3.0.0"
99
+ }
100
+ }
@@ -1,32 +0,0 @@
1
- /**
2
- * DiscordAdapter — ChannelAdapter implementation for Discord.
3
- * Story 4.6
4
- */
5
- import type { ChannelAdapter, ChannelCapabilities, ChannelMeta, ChannelConfig, InboundMessage, OutboundPayload, SendResult, HealthStatus } from "../../shared/index.js";
6
- /** Minimal Discord client interface for mockability. */
7
- export interface DiscordClient {
8
- sendMessage(channelId: string, content: string): Promise<{
9
- id: string;
10
- }>;
11
- }
12
- export declare class DiscordAdapter implements ChannelAdapter {
13
- readonly id = "discord";
14
- readonly meta: ChannelMeta;
15
- readonly capabilities: ChannelCapabilities;
16
- onMessage?: (message: InboundMessage) => Promise<void>;
17
- private connected;
18
- private config;
19
- private client;
20
- constructor(client?: DiscordClient);
21
- connect(config: ChannelConfig): Promise<void>;
22
- disconnect(): Promise<void>;
23
- healthCheck(): Promise<HealthStatus>;
24
- send(target: {
25
- peerId: string;
26
- threadId?: string;
27
- }, payload: OutboundPayload): Promise<SendResult>;
28
- /** Simulate receiving an inbound message (for testing/webhooks). */
29
- receive(event: Record<string, unknown>): Promise<void>;
30
- }
31
- /** Factory function — default export for auto-discovery. */
32
- export default function createDiscordAdapter(client?: DiscordClient): DiscordAdapter;
@@ -1,70 +0,0 @@
1
- /**
2
- * DiscordAdapter — ChannelAdapter implementation for Discord.
3
- * Story 4.6
4
- */
5
- import { formatForDiscord } from "./outbound.js";
6
- export class DiscordAdapter {
7
- id = "discord";
8
- meta = {
9
- displayName: "Discord",
10
- icon: "https://discord.com/favicon.ico",
11
- homepage: "https://discord.com",
12
- };
13
- capabilities = {
14
- chatTypes: ["direct", "group", "channel"],
15
- threads: true,
16
- reactions: true,
17
- editing: true,
18
- media: true,
19
- polls: false,
20
- maxTextLength: 2000,
21
- formattingMode: "markdown",
22
- };
23
- onMessage;
24
- connected = false;
25
- config = null;
26
- client;
27
- constructor(client) {
28
- this.client = client ?? null;
29
- }
30
- async connect(config) {
31
- this.config = config;
32
- this.connected = true;
33
- }
34
- async disconnect() {
35
- this.connected = false;
36
- this.config = null;
37
- }
38
- async healthCheck() {
39
- return { ok: this.connected };
40
- }
41
- async send(target, payload) {
42
- if (!this.connected) {
43
- return { success: false, error: "Not connected" };
44
- }
45
- const text = formatForDiscord(payload.text);
46
- if (this.client) {
47
- try {
48
- const result = await this.client.sendMessage(target.peerId, text);
49
- return { success: true, messageId: result.id };
50
- }
51
- catch (err) {
52
- return { success: false, error: String(err) };
53
- }
54
- }
55
- // No-op when no client provided
56
- return { success: true };
57
- }
58
- /** Simulate receiving an inbound message (for testing/webhooks). */
59
- async receive(event) {
60
- if (this.onMessage) {
61
- const { parseDiscordEvent } = await import("./inbound.js");
62
- const msg = parseDiscordEvent(event);
63
- await this.onMessage(msg);
64
- }
65
- }
66
- }
67
- /** Factory function — default export for auto-discovery. */
68
- export default function createDiscordAdapter(client) {
69
- return new DiscordAdapter(client);
70
- }
@@ -1,25 +0,0 @@
1
- /**
2
- * Discord inbound message parsing.
3
- * Story 4.6
4
- */
5
- import type { InboundMessage } from "../../shared/index.js";
6
- export interface DiscordEvent {
7
- id?: string;
8
- channel_id?: string;
9
- guild_id?: string;
10
- author?: {
11
- id?: string;
12
- username?: string;
13
- };
14
- content?: string;
15
- message_reference?: {
16
- message_id?: string;
17
- channel_id?: string;
18
- };
19
- timestamp?: string;
20
- [key: string]: unknown;
21
- }
22
- /**
23
- * Parse a Discord message event into an InboundMessage.
24
- */
25
- export declare function parseDiscordEvent(event: DiscordEvent): InboundMessage;
@@ -1,24 +0,0 @@
1
- /**
2
- * Discord inbound message parsing.
3
- * Story 4.6
4
- */
5
- /**
6
- * Parse a Discord message event into an InboundMessage.
7
- */
8
- export function parseDiscordEvent(event) {
9
- const id = event.id ?? `discord-${Date.now()}`;
10
- const channel = event.channel_id ?? "unknown";
11
- const from = event.author?.id ?? "unknown";
12
- const body = event.content ?? "";
13
- const replyToId = event.message_reference?.message_id;
14
- const receivedAt = event.timestamp ?? new Date().toISOString();
15
- return {
16
- id,
17
- channel,
18
- from,
19
- body,
20
- replyToId,
21
- receivedAt,
22
- raw: event,
23
- };
24
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * Discord channel configuration types.
3
- * Story 4.6
4
- */
5
- export interface DiscordConfig {
6
- token: string;
7
- guildId?: string;
8
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Discord channel configuration types.
3
- * Story 4.6
4
- */
5
- export {};
@@ -1,14 +0,0 @@
1
- /**
2
- * Discord outbound formatting.
3
- * Discord uses native markdown — just enforce the 2000-char limit.
4
- * Story 4.6
5
- */
6
- /**
7
- * Split text into Discord-compatible chunks (2000 char max each).
8
- */
9
- export declare function chunkForDiscord(text: string): string[];
10
- /**
11
- * Discord uses native markdown — no conversion needed.
12
- * Returns the text unchanged (Discord renders it natively).
13
- */
14
- export declare function formatForDiscord(text: string): string;
@@ -1,38 +0,0 @@
1
- /**
2
- * Discord outbound formatting.
3
- * Discord uses native markdown — just enforce the 2000-char limit.
4
- * Story 4.6
5
- */
6
- const DISCORD_MAX_LENGTH = 2000;
7
- /**
8
- * Split text into Discord-compatible chunks (2000 char max each).
9
- */
10
- export function chunkForDiscord(text) {
11
- if (text.length <= DISCORD_MAX_LENGTH)
12
- return [text];
13
- const chunks = [];
14
- let remaining = text;
15
- while (remaining.length > DISCORD_MAX_LENGTH) {
16
- // Try to split at a word boundary
17
- const slice = remaining.slice(0, DISCORD_MAX_LENGTH);
18
- const lastSpace = slice.lastIndexOf(" ");
19
- if (lastSpace > 0) {
20
- chunks.push(remaining.slice(0, lastSpace));
21
- remaining = remaining.slice(lastSpace + 1);
22
- }
23
- else {
24
- chunks.push(remaining.slice(0, DISCORD_MAX_LENGTH));
25
- remaining = remaining.slice(DISCORD_MAX_LENGTH);
26
- }
27
- }
28
- if (remaining.length > 0)
29
- chunks.push(remaining);
30
- return chunks;
31
- }
32
- /**
33
- * Discord uses native markdown — no conversion needed.
34
- * Returns the text unchanged (Discord renders it natively).
35
- */
36
- export function formatForDiscord(text) {
37
- return text;
38
- }
@@ -1,33 +0,0 @@
1
- /**
2
- * SlackAdapter — ChannelAdapter implementation for Slack.
3
- * Story 4.5
4
- */
5
- import type { ChannelAdapter, ChannelCapabilities, ChannelMeta, ChannelConfig, InboundMessage, OutboundPayload, SendResult, HealthStatus } from "../../shared/index.js";
6
- /** Minimal Bolt-compatible client interface for mockability. */
7
- export interface BoltClient {
8
- postMessage(channel: string, text: string, threadTs?: string): Promise<{
9
- ok: boolean;
10
- ts?: string;
11
- }>;
12
- }
13
- export declare class SlackAdapter implements ChannelAdapter {
14
- readonly id = "slack";
15
- readonly meta: ChannelMeta;
16
- readonly capabilities: ChannelCapabilities;
17
- onMessage?: (message: InboundMessage) => Promise<void>;
18
- private connected;
19
- private config;
20
- private client;
21
- constructor(client?: BoltClient);
22
- connect(config: ChannelConfig): Promise<void>;
23
- disconnect(): Promise<void>;
24
- healthCheck(): Promise<HealthStatus>;
25
- send(target: {
26
- peerId: string;
27
- threadId?: string;
28
- }, payload: OutboundPayload): Promise<SendResult>;
29
- /** Simulate receiving an inbound message (for testing/webhooks). */
30
- receive(event: Record<string, unknown>): Promise<void>;
31
- }
32
- /** Factory function — default export for auto-discovery. */
33
- export default function createSlackAdapter(client?: BoltClient): SlackAdapter;