botinabox 2.5.0 → 2.5.2

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 (278) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/bin/botinabox.mjs +2 -2
  4. package/dist/channels/discord/adapter.d.ts +32 -0
  5. package/dist/channels/discord/adapter.js +70 -0
  6. package/dist/channels/discord/inbound.d.ts +25 -0
  7. package/dist/channels/discord/inbound.js +24 -0
  8. package/dist/channels/discord/models.d.ts +8 -0
  9. package/dist/channels/discord/models.js +5 -0
  10. package/dist/channels/discord/outbound.d.ts +14 -0
  11. package/dist/channels/discord/outbound.js +38 -0
  12. package/dist/channels/slack/adapter.d.ts +33 -0
  13. package/dist/channels/slack/adapter.js +74 -0
  14. package/dist/channels/slack/inbound.d.ts +59 -0
  15. package/dist/channels/slack/inbound.js +96 -0
  16. package/dist/channels/slack/models.d.ts +9 -0
  17. package/dist/channels/slack/models.js +5 -0
  18. package/dist/channels/slack/outbound.d.ts +12 -0
  19. package/dist/channels/slack/outbound.js +18 -0
  20. package/dist/channels/slack/transcribe.d.ts +41 -0
  21. package/dist/channels/slack/transcribe.js +106 -0
  22. package/dist/channels/webhook/adapter.d.ts +23 -0
  23. package/dist/channels/webhook/adapter.js +86 -0
  24. package/dist/channels/webhook/hmac.d.ts +13 -0
  25. package/dist/channels/webhook/hmac.js +26 -0
  26. package/dist/channels/webhook/models.d.ts +9 -0
  27. package/dist/channels/webhook/models.js +5 -0
  28. package/dist/channels/webhook/server.d.ts +20 -0
  29. package/dist/channels/webhook/server.js +91 -0
  30. package/dist/chat-pipeline-BWrtVqEP.d.ts +652 -0
  31. package/dist/chat-pipeline-C-XlLGNl.d.ts +648 -0
  32. package/dist/chat-pipeline-CR1KF6eX.d.ts +652 -0
  33. package/dist/chat-pipeline-DisuC8SB.d.ts +643 -0
  34. package/dist/chunk-2LGXQPEA.js +41 -0
  35. package/dist/chunk-3X3YKI4T.js +357 -0
  36. package/dist/chunk-D47AIFOD.js +351 -0
  37. package/dist/chunk-DSNJKNEW.js +328 -0
  38. package/dist/chunk-GS2JFL6I.js +144 -0
  39. package/dist/chunk-J6S6QMUY.js +144 -0
  40. package/dist/chunk-QLA6YOFN.js +22 -0
  41. package/dist/chunk-UACT2WXX.js +381 -0
  42. package/dist/cli/templates/config.yml.d.ts +7 -0
  43. package/dist/cli/templates/config.yml.js +61 -0
  44. package/dist/cli/templates/env.d.ts +1 -0
  45. package/dist/cli/templates/env.js +30 -0
  46. package/dist/cli/templates/index.ts.d.ts +2 -0
  47. package/dist/cli/templates/index.ts.js +30 -0
  48. package/dist/cli/templates/package.json.d.ts +5 -0
  49. package/dist/cli/templates/package.json.js +28 -0
  50. package/dist/cli.js +0 -0
  51. package/dist/connector-DDahQw-2.d.ts +63 -0
  52. package/dist/connectors/google/calendar-connector.d.ts +40 -0
  53. package/dist/connectors/google/calendar-connector.js +243 -0
  54. package/dist/connectors/google/gmail-connector.d.ts +42 -0
  55. package/dist/connectors/google/gmail-connector.js +345 -0
  56. package/dist/connectors/google/index.d.ts +67 -1
  57. package/dist/connectors/google/index.js +240 -0
  58. package/dist/connectors/google/oauth.d.ts +48 -0
  59. package/dist/connectors/google/oauth.js +112 -0
  60. package/dist/connectors/google/types.d.ts +78 -0
  61. package/dist/connectors/google/types.js +2 -0
  62. package/dist/core/chat/auto-discovery.d.ts +16 -0
  63. package/dist/core/chat/auto-discovery.js +54 -0
  64. package/dist/core/chat/channel-registry.d.ts +45 -0
  65. package/dist/core/chat/channel-registry.js +96 -0
  66. package/dist/core/chat/chat-pipeline.d.ts +113 -0
  67. package/dist/core/chat/chat-pipeline.js +395 -0
  68. package/dist/core/chat/chat-responder.d.ts +90 -0
  69. package/dist/core/chat/chat-responder.js +185 -0
  70. package/dist/core/chat/formatter.d.ts +11 -0
  71. package/dist/core/chat/formatter.js +60 -0
  72. package/dist/core/chat/index.d.ts +24 -0
  73. package/dist/core/chat/index.js +18 -0
  74. package/dist/core/chat/message-interpreter.d.ts +91 -0
  75. package/dist/core/chat/message-interpreter.js +166 -0
  76. package/dist/core/chat/message-store.d.ts +66 -0
  77. package/dist/core/chat/message-store.js +131 -0
  78. package/dist/core/chat/notification-queue.d.ts +34 -0
  79. package/dist/core/chat/notification-queue.js +111 -0
  80. package/dist/core/chat/pipeline.d.ts +38 -0
  81. package/dist/core/chat/pipeline.js +89 -0
  82. package/dist/core/chat/policies.d.ts +16 -0
  83. package/dist/core/chat/policies.js +25 -0
  84. package/dist/core/chat/routing.d.ts +17 -0
  85. package/dist/core/chat/routing.js +36 -0
  86. package/dist/core/chat/session-key.d.ts +30 -0
  87. package/dist/core/chat/session-key.js +65 -0
  88. package/dist/core/chat/session-manager.d.ts +17 -0
  89. package/dist/core/chat/session-manager.js +23 -0
  90. package/dist/core/chat/text-chunker.d.ts +9 -0
  91. package/dist/core/chat/text-chunker.js +48 -0
  92. package/dist/core/chat/triage-router.d.ts +75 -0
  93. package/dist/core/chat/triage-router.js +142 -0
  94. package/dist/core/chat/types.d.ts +5 -0
  95. package/dist/core/chat/types.js +5 -0
  96. package/dist/core/config/defaults.d.ts +2 -0
  97. package/dist/core/config/defaults.js +38 -0
  98. package/dist/core/config/index.d.ts +6 -0
  99. package/dist/core/config/index.js +4 -0
  100. package/dist/core/config/interpolate.d.ts +5 -0
  101. package/dist/core/config/interpolate.js +27 -0
  102. package/dist/core/config/loader.d.ts +24 -0
  103. package/dist/core/config/loader.js +59 -0
  104. package/dist/core/config/schema.d.ts +5 -0
  105. package/dist/core/config/schema.js +119 -0
  106. package/dist/core/data/core-entity-contexts.d.ts +14 -0
  107. package/dist/core/data/core-entity-contexts.js +197 -0
  108. package/dist/core/data/core-migrations.d.ts +5 -0
  109. package/dist/core/data/core-migrations.js +45 -0
  110. package/dist/core/data/core-schema.d.ts +6 -0
  111. package/dist/core/data/core-schema.js +454 -0
  112. package/dist/core/data/data-store.d.ts +67 -0
  113. package/dist/core/data/data-store.js +218 -0
  114. package/dist/core/data/domain-entity-contexts.d.ts +29 -0
  115. package/dist/core/data/domain-entity-contexts.js +321 -0
  116. package/dist/core/data/domain-schema.d.ts +36 -0
  117. package/dist/core/data/domain-schema.js +323 -0
  118. package/dist/core/data/index.d.ts +7 -0
  119. package/dist/core/data/index.js +7 -0
  120. package/dist/core/data/types.d.ts +111 -0
  121. package/dist/core/data/types.js +1 -0
  122. package/dist/core/hooks/hook-bus.d.ts +18 -0
  123. package/dist/core/hooks/hook-bus.js +120 -0
  124. package/dist/core/hooks/index.d.ts +2 -0
  125. package/dist/core/hooks/index.js +1 -0
  126. package/dist/core/hooks/types.d.ts +19 -0
  127. package/dist/core/hooks/types.js +1 -0
  128. package/dist/core/index.d.ts +4 -0
  129. package/dist/core/index.js +4 -0
  130. package/dist/core/llm/auto-discovery.d.ts +11 -0
  131. package/dist/core/llm/auto-discovery.js +49 -0
  132. package/dist/core/llm/cost-tracker.d.ts +6 -0
  133. package/dist/core/llm/cost-tracker.js +38 -0
  134. package/dist/core/llm/index.d.ts +4 -0
  135. package/dist/core/llm/index.js +3 -0
  136. package/dist/core/llm/model-router.d.ts +25 -0
  137. package/dist/core/llm/model-router.js +49 -0
  138. package/dist/core/llm/provider-registry.d.ts +9 -0
  139. package/dist/core/llm/provider-registry.js +25 -0
  140. package/dist/core/llm/types.d.ts +2 -0
  141. package/dist/core/llm/types.js +2 -0
  142. package/dist/core/orchestrator/adapters/api-adapter.d.ts +34 -0
  143. package/dist/core/orchestrator/adapters/api-adapter.js +88 -0
  144. package/dist/core/orchestrator/adapters/cli-adapter.d.ts +22 -0
  145. package/dist/core/orchestrator/adapters/cli-adapter.js +69 -0
  146. package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +35 -0
  147. package/dist/core/orchestrator/adapters/deterministic-adapter.js +75 -0
  148. package/dist/core/orchestrator/adapters/env-whitelist.d.ts +4 -0
  149. package/dist/core/orchestrator/adapters/env-whitelist.js +27 -0
  150. package/dist/core/orchestrator/adapters/output-extractor.d.ts +11 -0
  151. package/dist/core/orchestrator/adapters/output-extractor.js +59 -0
  152. package/dist/core/orchestrator/adapters/process-manager.d.ts +15 -0
  153. package/dist/core/orchestrator/adapters/process-manager.js +26 -0
  154. package/dist/core/orchestrator/adapters/tool-loop.d.ts +22 -0
  155. package/dist/core/orchestrator/adapters/tool-loop.js +66 -0
  156. package/dist/core/orchestrator/agent-registry.d.ts +31 -0
  157. package/dist/core/orchestrator/agent-registry.js +135 -0
  158. package/dist/core/orchestrator/budget-controller.d.ts +19 -0
  159. package/dist/core/orchestrator/budget-controller.js +73 -0
  160. package/dist/core/orchestrator/chain-guard.d.ts +14 -0
  161. package/dist/core/orchestrator/chain-guard.js +23 -0
  162. package/dist/core/orchestrator/circuit-breaker.d.ts +65 -0
  163. package/dist/core/orchestrator/circuit-breaker.js +159 -0
  164. package/dist/core/orchestrator/claude-stream-parser.d.ts +31 -0
  165. package/dist/core/orchestrator/claude-stream-parser.js +99 -0
  166. package/dist/core/orchestrator/config-revisions.d.ts +6 -0
  167. package/dist/core/orchestrator/config-revisions.js +17 -0
  168. package/dist/core/orchestrator/dependency-resolver.d.ts +20 -0
  169. package/dist/core/orchestrator/dependency-resolver.js +78 -0
  170. package/dist/core/orchestrator/governance-gate.d.ts +110 -0
  171. package/dist/core/orchestrator/governance-gate.js +170 -0
  172. package/dist/core/orchestrator/learning-pipeline.d.ts +109 -0
  173. package/dist/core/orchestrator/learning-pipeline.js +249 -0
  174. package/dist/core/orchestrator/loop-detector.d.ts +51 -0
  175. package/dist/core/orchestrator/loop-detector.js +133 -0
  176. package/dist/core/orchestrator/ndjson-logger.d.ts +6 -0
  177. package/dist/core/orchestrator/ndjson-logger.js +18 -0
  178. package/dist/core/orchestrator/permission-relay.d.ts +72 -0
  179. package/dist/core/orchestrator/permission-relay.js +164 -0
  180. package/dist/core/orchestrator/run-manager.d.ts +31 -0
  181. package/dist/core/orchestrator/run-manager.js +178 -0
  182. package/dist/core/orchestrator/scheduler.d.ts +70 -0
  183. package/dist/core/orchestrator/scheduler.js +198 -0
  184. package/dist/core/orchestrator/secret-store.d.ts +57 -0
  185. package/dist/core/orchestrator/secret-store.js +171 -0
  186. package/dist/core/orchestrator/session-manager.d.ts +13 -0
  187. package/dist/core/orchestrator/session-manager.js +66 -0
  188. package/dist/core/orchestrator/task-queue.d.ts +34 -0
  189. package/dist/core/orchestrator/task-queue.js +83 -0
  190. package/dist/core/orchestrator/template-interpolate.d.ts +5 -0
  191. package/dist/core/orchestrator/template-interpolate.js +18 -0
  192. package/dist/core/orchestrator/user-registry.d.ts +47 -0
  193. package/dist/core/orchestrator/user-registry.js +76 -0
  194. package/dist/core/orchestrator/wakeup-queue.d.ts +9 -0
  195. package/dist/core/orchestrator/wakeup-queue.js +45 -0
  196. package/dist/core/orchestrator/workflow-engine.d.ts +47 -0
  197. package/dist/core/orchestrator/workflow-engine.js +204 -0
  198. package/dist/core/security/audit.d.ts +20 -0
  199. package/dist/core/security/audit.js +33 -0
  200. package/dist/core/security/column-validator.d.ts +20 -0
  201. package/dist/core/security/column-validator.js +37 -0
  202. package/dist/core/security/index.d.ts +5 -0
  203. package/dist/core/security/index.js +5 -0
  204. package/dist/core/security/process-env.d.ts +13 -0
  205. package/dist/core/security/process-env.js +49 -0
  206. package/dist/core/security/sanitizer.d.ts +11 -0
  207. package/dist/core/security/sanitizer.js +39 -0
  208. package/dist/core/security/types.d.ts +11 -0
  209. package/dist/core/security/types.js +1 -0
  210. package/dist/core/update/auto-update.d.ts +21 -0
  211. package/dist/core/update/auto-update.js +102 -0
  212. package/dist/core/update/backup-manager.d.ts +7 -0
  213. package/dist/core/update/backup-manager.js +24 -0
  214. package/dist/core/update/index.d.ts +8 -0
  215. package/dist/core/update/index.js +6 -0
  216. package/dist/core/update/migration-hooks.d.ts +11 -0
  217. package/dist/core/update/migration-hooks.js +10 -0
  218. package/dist/core/update/types.d.ts +11 -0
  219. package/dist/core/update/types.js +1 -0
  220. package/dist/core/update/update-checker.d.ts +11 -0
  221. package/dist/core/update/update-checker.js +63 -0
  222. package/dist/core/update/update-manager.d.ts +25 -0
  223. package/dist/core/update/update-manager.js +101 -0
  224. package/dist/core/update/version-utils.d.ts +6 -0
  225. package/dist/core/update/version-utils.js +34 -0
  226. package/dist/gmail-connector-2FVYTQJH.js +6 -0
  227. package/dist/gmail-connector-MNUBRNFM.js +6 -0
  228. package/dist/gmail-connector-PS2VLGNE.js +6 -0
  229. package/dist/gmail-connector-ULSMN6X2.js +6 -0
  230. package/dist/gmail-connector-URRFX6A3.js +6 -0
  231. package/dist/inbound-AFBUPSPG.js +10 -0
  232. package/dist/inbound-AFOHYNUY.js +6 -0
  233. package/dist/inbound-CGIXRXGC.js +8 -0
  234. package/dist/inbound-MCOLRH6U.js +10 -0
  235. package/dist/inbound-SNEMBLGA.js +6 -0
  236. package/dist/inbound-ZJHAYVMF.js +10 -0
  237. package/dist/index.d.ts +11 -1
  238. package/dist/index.js +27 -11
  239. package/dist/provider-qqJYv9nv.d.ts +75 -0
  240. package/dist/providers/anthropic/models.d.ts +2 -0
  241. package/dist/providers/anthropic/models.js +29 -0
  242. package/dist/providers/anthropic/provider.d.ts +13 -0
  243. package/dist/providers/anthropic/provider.js +119 -0
  244. package/dist/providers/anthropic/tool-converter.d.ts +10 -0
  245. package/dist/providers/anthropic/tool-converter.js +7 -0
  246. package/dist/providers/ollama/provider.d.ts +17 -0
  247. package/dist/providers/ollama/provider.js +185 -0
  248. package/dist/providers/openai/models.d.ts +2 -0
  249. package/dist/providers/openai/models.js +29 -0
  250. package/dist/providers/openai/provider.d.ts +13 -0
  251. package/dist/providers/openai/provider.js +163 -0
  252. package/dist/providers/openai/tool-converter.d.ts +10 -0
  253. package/dist/providers/openai/tool-converter.js +10 -0
  254. package/dist/shared/constants.d.ts +50 -0
  255. package/dist/shared/constants.js +64 -0
  256. package/dist/shared/index.d.ts +14 -0
  257. package/dist/shared/index.js +14 -0
  258. package/dist/shared/types/agent.d.ts +36 -0
  259. package/dist/shared/types/agent.js +2 -0
  260. package/dist/shared/types/channel.d.ts +70 -0
  261. package/dist/shared/types/channel.js +2 -0
  262. package/dist/shared/types/config.d.ts +111 -0
  263. package/dist/shared/types/config.js +2 -0
  264. package/dist/shared/types/connector.d.ts +77 -0
  265. package/dist/shared/types/connector.js +2 -0
  266. package/dist/shared/types/execution.d.ts +29 -0
  267. package/dist/shared/types/execution.js +2 -0
  268. package/dist/shared/types/provider.d.ts +73 -0
  269. package/dist/shared/types/provider.js +2 -0
  270. package/dist/shared/types/task.d.ts +47 -0
  271. package/dist/shared/types/task.js +2 -0
  272. package/dist/shared/types/workflow.d.ts +39 -0
  273. package/dist/shared/types/workflow.js +2 -0
  274. package/dist/shared/utils.d.ts +6 -0
  275. package/dist/shared/utils.js +13 -0
  276. package/dist/update-check.d.ts +5 -0
  277. package/dist/update-check.js +56 -0
  278. package/package.json +100 -100
@@ -0,0 +1,64 @@
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
+ ];
@@ -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,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
+ }
@@ -0,0 +1,2 @@
1
+ /** Agent types — Story 1.5 / 3.1 */
2
+ export {};
@@ -0,0 +1,70 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ /** Channel adapter types — Story 1.5 / 4.1 */
2
+ export {};
@@ -0,0 +1,111 @@
1
+ /** Bot configuration types — Story 1.2 / 1.5 */
2
+ export interface DataConfig {
3
+ path: string;
4
+ walMode: boolean;
5
+ backupDir?: string;
6
+ }
7
+ export interface ModelConfig {
8
+ aliases: Record<string, string>;
9
+ default: string;
10
+ routing: Record<string, string>;
11
+ fallbackChain: string[];
12
+ costLimit?: {
13
+ perRunCents?: number;
14
+ };
15
+ }
16
+ export interface SecurityConfig {
17
+ fieldLengthLimits?: Record<string, number>;
18
+ allowedFilePrefixes?: string[];
19
+ }
20
+ export interface RenderConfig {
21
+ outputDir: string;
22
+ watchIntervalMs: number;
23
+ }
24
+ export interface UpdateConfig {
25
+ policy: "auto-all" | "auto-compatible" | "auto-patch" | "notify" | "manual";
26
+ checkIntervalMs: number;
27
+ maintenanceWindow?: {
28
+ utcHourStart: number;
29
+ utcHourEnd: number;
30
+ days?: Array<"mon" | "tue" | "wed" | "thu" | "fri" | "sat" | "sun">;
31
+ };
32
+ }
33
+ export interface BudgetConfig {
34
+ globalMonthlyCents?: number;
35
+ warnPercent: number;
36
+ }
37
+ export interface EntityColumnDef {
38
+ type: "uuid" | "text" | "integer" | "boolean" | "datetime" | "real";
39
+ required?: boolean;
40
+ default?: string | number | boolean;
41
+ references?: string;
42
+ }
43
+ export interface EntityConfig {
44
+ columns: Record<string, EntityColumnDef>;
45
+ relations?: Array<{
46
+ type: "hasMany" | "manyToMany" | "belongsTo";
47
+ table: string;
48
+ through?: string;
49
+ localKey?: string;
50
+ remoteKey?: string;
51
+ }>;
52
+ }
53
+ export interface AgentConfig {
54
+ slug: string;
55
+ name: string;
56
+ role?: string;
57
+ adapter: string;
58
+ model?: string;
59
+ workdir?: string;
60
+ instructionsFile?: string;
61
+ maxConcurrentRuns?: number;
62
+ budgetMonthlyCents?: number;
63
+ canCreateAgents?: boolean;
64
+ skipPermissions?: boolean;
65
+ config?: Record<string, unknown>;
66
+ }
67
+ export interface BotConfig {
68
+ data: DataConfig;
69
+ channels: Record<string, {
70
+ enabled: boolean;
71
+ accounts?: Record<string, unknown>;
72
+ } & Record<string, unknown>>;
73
+ connectors?: Record<string, {
74
+ enabled: boolean;
75
+ provider: string;
76
+ accounts?: Record<string, import("./connector.js").ConnectorConfig>;
77
+ } & Record<string, unknown>>;
78
+ agents: AgentConfig[];
79
+ providers: Record<string, {
80
+ enabled: boolean;
81
+ } & Record<string, unknown>>;
82
+ models: ModelConfig;
83
+ entities: Record<string, EntityConfig>;
84
+ security: SecurityConfig;
85
+ render: RenderConfig;
86
+ updates: UpdateConfig;
87
+ budget: BudgetConfig;
88
+ workflows?: Record<string, WorkflowConfigEntry>;
89
+ }
90
+ export interface WorkflowConfigEntry {
91
+ name: string;
92
+ description?: string;
93
+ steps: WorkflowStepConfig[];
94
+ trigger?: {
95
+ type: "task_completed" | "event" | "schedule" | "manual";
96
+ filter?: Record<string, unknown>;
97
+ };
98
+ }
99
+ export interface WorkflowStepConfig {
100
+ id: string;
101
+ name: string;
102
+ agentSlug?: string;
103
+ taskTemplate: {
104
+ title: string;
105
+ description: string;
106
+ };
107
+ dependsOn?: string[];
108
+ onComplete?: "next" | "parallel" | "end";
109
+ onFail?: "abort" | "skip" | "retry";
110
+ retryPolicy?: import("./task.js").RetryPolicy;
111
+ }
@@ -0,0 +1,2 @@
1
+ /** Bot configuration types — Story 1.2 / 1.5 */
2
+ export {};
@@ -0,0 +1,77 @@
1
+ /** Connector types — generic external service integrations. */
2
+ export interface ConnectorMeta {
3
+ displayName: string;
4
+ /** Provider identifier, e.g. "google", "trello", "jira", "salesforce" */
5
+ provider: string;
6
+ /** Data type this connector handles, e.g. "email", "calendar", "board", "crm" */
7
+ dataType: string;
8
+ }
9
+ export interface SyncOptions {
10
+ /** Only sync records after this ISO 8601 timestamp */
11
+ since?: string;
12
+ /** Provider-specific incremental sync token */
13
+ cursor?: string;
14
+ /** Maximum number of records to fetch */
15
+ limit?: number;
16
+ /** Provider-specific query filters */
17
+ filters?: Record<string, unknown>;
18
+ }
19
+ export interface SyncResult<T = Record<string, unknown>> {
20
+ /** Typed records produced by the connector — consumer decides where to store */
21
+ records: T[];
22
+ /** Next incremental sync token (persist for future calls) */
23
+ cursor?: string;
24
+ /** Whether more records are available (pagination) */
25
+ hasMore: boolean;
26
+ /** Errors encountered during sync (non-fatal per-record failures) */
27
+ errors: Array<{
28
+ id?: string;
29
+ error: string;
30
+ }>;
31
+ }
32
+ export interface PushResult {
33
+ success: boolean;
34
+ externalId?: string;
35
+ error?: string;
36
+ }
37
+ export interface AuthResult {
38
+ success: boolean;
39
+ account?: string;
40
+ /** URL the user must visit to authorize (for OAuth flows) */
41
+ authUrl?: string;
42
+ error?: string;
43
+ }
44
+ export type ConnectorConfig = Record<string, unknown>;
45
+ /**
46
+ * Generic connector interface for external service integrations.
47
+ *
48
+ * Connectors pull and optionally push data to/from external services
49
+ * (Gmail, Calendar, Trello, Jira, Salesforce, etc.). They produce
50
+ * typed records — the consuming application decides where to store them.
51
+ *
52
+ * @typeParam T - The record type this connector produces/consumes.
53
+ */
54
+ export interface Connector<T = Record<string, unknown>> {
55
+ readonly id: string;
56
+ readonly meta: ConnectorMeta;
57
+ connect(config: ConnectorConfig): Promise<void>;
58
+ disconnect(): Promise<void>;
59
+ healthCheck(): Promise<{
60
+ ok: boolean;
61
+ account?: string;
62
+ error?: string;
63
+ }>;
64
+ /** Pull records from external source */
65
+ sync(options?: SyncOptions): Promise<SyncResult<T>>;
66
+ /** Push a record to external source (optional) */
67
+ push?(payload: T): Promise<PushResult>;
68
+ /**
69
+ * Run the authentication/authorization flow for this connector.
70
+ * For OAuth connectors, this generates the auth URL and exchanges the code for tokens.
71
+ *
72
+ * @param codeProvider - called with the auth URL; must return the authorization code.
73
+ * For CLI flows, this prints the URL and reads from stdin.
74
+ * For programmatic flows, the caller handles the redirect.
75
+ */
76
+ authenticate?(codeProvider: (authUrl: string) => Promise<string>): Promise<AuthResult>;
77
+ }
@@ -0,0 +1,2 @@
1
+ /** Connector types — generic external service integrations. */
2
+ export {};
@@ -0,0 +1,29 @@
1
+ /** Execution adapter types — Story 1.5 / 3.4 / 3.5 */
2
+ export type RunStatus = "queued" | "running" | "succeeded" | "failed" | "cancelled";
3
+ export interface RunContext {
4
+ runId: string;
5
+ agentId: string;
6
+ agentSlug: string;
7
+ taskId?: string;
8
+ taskTitle?: string;
9
+ taskDescription?: string;
10
+ model: string;
11
+ workdir: string;
12
+ sessionParams?: unknown;
13
+ abortSignal?: AbortSignal;
14
+ onLog?: (line: string) => void;
15
+ }
16
+ export interface RunResult {
17
+ status: "succeeded" | "failed";
18
+ output?: string;
19
+ error?: string;
20
+ usage?: import("./provider.js").TokenUsage;
21
+ costCents?: number;
22
+ sessionParams?: unknown;
23
+ clearSession?: boolean;
24
+ durationMs: number;
25
+ }
26
+ export interface ExecutionAdapter {
27
+ id: string;
28
+ execute(ctx: RunContext): Promise<RunResult>;
29
+ }
@@ -0,0 +1,2 @@
1
+ /** Execution adapter types — Story 1.5 / 3.4 / 3.5 */
2
+ export {};
@@ -0,0 +1,73 @@
1
+ /** LLM provider types — Story 1.5 / 2.1 */
2
+ export interface ToolDefinition {
3
+ name: string;
4
+ description: string;
5
+ parameters: Record<string, unknown>;
6
+ }
7
+ export interface ChatMessage {
8
+ role: "user" | "assistant" | "system";
9
+ content: string | ContentBlock[];
10
+ }
11
+ export type ContentBlock = {
12
+ type: "text";
13
+ text: string;
14
+ } | {
15
+ type: "tool_use";
16
+ id: string;
17
+ name: string;
18
+ input: unknown;
19
+ } | {
20
+ type: "tool_result";
21
+ tool_use_id: string;
22
+ content: string;
23
+ };
24
+ export interface ChatParams {
25
+ messages: ChatMessage[];
26
+ system?: string;
27
+ tools?: ToolDefinition[];
28
+ maxTokens?: number;
29
+ temperature?: number;
30
+ model: string;
31
+ abortSignal?: AbortSignal;
32
+ }
33
+ export interface TokenUsage {
34
+ inputTokens: number;
35
+ outputTokens: number;
36
+ cacheReadTokens?: number;
37
+ cacheWriteTokens?: number;
38
+ }
39
+ export interface ChatResult {
40
+ content: string;
41
+ toolUses?: ToolUse[];
42
+ usage: TokenUsage;
43
+ model: string;
44
+ stopReason: "end_turn" | "tool_use" | "max_tokens" | "stop_sequence";
45
+ }
46
+ export interface ToolUse {
47
+ id: string;
48
+ name: string;
49
+ input: unknown;
50
+ }
51
+ export interface ModelInfo {
52
+ id: string;
53
+ displayName: string;
54
+ contextWindow: number;
55
+ maxOutputTokens: number;
56
+ capabilities: Array<"chat" | "tools" | "vision" | "streaming">;
57
+ /** Cost in micro-cents per 1M tokens */
58
+ inputCostPerMToken?: number;
59
+ outputCostPerMToken?: number;
60
+ }
61
+ export interface ResolvedModel {
62
+ provider: string;
63
+ model: string;
64
+ }
65
+ export interface LLMProvider {
66
+ id: string;
67
+ displayName: string;
68
+ models: ModelInfo[];
69
+ chat(params: ChatParams): Promise<ChatResult>;
70
+ chatStream(params: ChatParams): AsyncGenerator<string, ChatResult, unknown>;
71
+ /** Convert ToolDefinition[] to provider-native format */
72
+ serializeTools(tools: ToolDefinition[]): unknown;
73
+ }
@@ -0,0 +1,2 @@
1
+ /** LLM provider types — Story 1.5 / 2.1 */
2
+ export {};
@@ -0,0 +1,47 @@
1
+ /** Task types — Story 1.5 / 3.2 */
2
+ export type TaskStatus = "backlog" | "todo" | "in_progress" | "in_review" | "done" | "blocked" | "cancelled";
3
+ export interface RetryPolicy {
4
+ maxRetries: number;
5
+ backoffMs: number;
6
+ backoffMultiplier: number;
7
+ maxBackoffMs: number;
8
+ }
9
+ export interface TaskDefinition {
10
+ title: string;
11
+ description?: string;
12
+ assigneeId?: string;
13
+ priority?: number;
14
+ parentId?: string;
15
+ dependsOn?: string[];
16
+ followupAgentId?: string;
17
+ followupTemplate?: string;
18
+ chainOriginId?: string;
19
+ chainDepth?: number;
20
+ retryPolicy?: RetryPolicy;
21
+ metadata?: Record<string, unknown>;
22
+ }
23
+ export interface TaskRecord extends Required<Pick<TaskDefinition, "title" | "priority">> {
24
+ id: string;
25
+ description: string;
26
+ assigneeId?: string;
27
+ status: TaskStatus;
28
+ priority: number;
29
+ parentId?: string;
30
+ dependsOn: string[];
31
+ followupAgentId?: string;
32
+ followupTemplate?: string;
33
+ chainOriginId?: string;
34
+ chainDepth: number;
35
+ retryPolicy?: RetryPolicy;
36
+ retryCount: number;
37
+ maxRetries: number;
38
+ nextRetryAt?: string;
39
+ executionRunId?: string;
40
+ result?: string;
41
+ completedOutput?: string;
42
+ metadata?: Record<string, unknown>;
43
+ createdAt: string;
44
+ updatedAt: string;
45
+ completedAt?: string;
46
+ deletedAt?: string;
47
+ }
@@ -0,0 +1,2 @@
1
+ /** Task types — Story 1.5 / 3.2 */
2
+ export {};
@@ -0,0 +1,39 @@
1
+ /** Workflow types — Story 1.5 / 5.1 */
2
+ export type WorkflowRunStatus = "running" | "completed" | "failed" | "cancelled";
3
+ export interface WorkflowStep {
4
+ id: string;
5
+ name: string;
6
+ agentSlug?: string;
7
+ agentResolver?: string;
8
+ taskTemplate: {
9
+ title: string;
10
+ description: string;
11
+ };
12
+ dependsOn?: string[];
13
+ onComplete?: "next" | "parallel" | "end";
14
+ onFail?: "abort" | "skip" | "retry";
15
+ retryPolicy?: import("./task.js").RetryPolicy;
16
+ condition?: string;
17
+ }
18
+ export interface WorkflowDefinition {
19
+ slug: string;
20
+ name: string;
21
+ description?: string;
22
+ steps: WorkflowStep[];
23
+ trigger?: WorkflowTrigger;
24
+ }
25
+ export interface WorkflowTrigger {
26
+ type: "task_completed" | "event" | "schedule" | "manual";
27
+ filter?: Record<string, unknown>;
28
+ }
29
+ export interface WorkflowRunRecord {
30
+ id: string;
31
+ workflowId: string;
32
+ status: WorkflowRunStatus;
33
+ currentStep: number;
34
+ context: Record<string, unknown>;
35
+ originTaskId?: string;
36
+ startedAt: string;
37
+ finishedAt?: string;
38
+ error?: string;
39
+ }
@@ -0,0 +1,2 @@
1
+ /** Workflow types — Story 1.5 / 5.1 */
2
+ export {};
@@ -0,0 +1,6 @@
1
+ /** Shared utility functions. */
2
+ /**
3
+ * Truncate text at a word boundary, appending "..." if truncated.
4
+ * Returns the original text if it's shorter than maxLen.
5
+ */
6
+ export declare function truncateAtWord(text: string, maxLen: number): string;
@@ -0,0 +1,13 @@
1
+ /** Shared utility functions. */
2
+ /**
3
+ * Truncate text at a word boundary, appending "..." if truncated.
4
+ * Returns the original text if it's shorter than maxLen.
5
+ */
6
+ export function truncateAtWord(text, maxLen) {
7
+ if (text.length <= maxLen)
8
+ return text;
9
+ const truncated = text.slice(0, maxLen);
10
+ const lastSpace = truncated.lastIndexOf(" ");
11
+ const cutPoint = lastSpace > maxLen * 0.5 ? lastSpace : maxLen;
12
+ return truncated.slice(0, cutPoint) + "...";
13
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Check the npm registry for a newer version. Caches results for 24 hours.
3
+ * Returns the latest version string if an update is available, null otherwise.
4
+ */
5
+ export declare function checkForUpdate(pkgName: string, currentVersion: string): Promise<string | null>;