botinabox 1.8.2 → 1.8.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 (247) hide show
  1. package/dist/channels/discord/adapter.d.ts +32 -0
  2. package/dist/channels/discord/adapter.js +70 -0
  3. package/dist/channels/discord/inbound.d.ts +25 -0
  4. package/dist/channels/discord/inbound.js +24 -0
  5. package/dist/channels/discord/models.d.ts +8 -0
  6. package/dist/channels/discord/models.js +5 -0
  7. package/dist/channels/discord/outbound.d.ts +14 -0
  8. package/dist/channels/discord/outbound.js +38 -0
  9. package/dist/channels/slack/adapter.d.ts +33 -0
  10. package/dist/channels/slack/adapter.js +74 -0
  11. package/dist/channels/slack/inbound.d.ts +59 -0
  12. package/dist/channels/slack/inbound.js +96 -0
  13. package/dist/channels/slack/models.d.ts +9 -0
  14. package/dist/channels/slack/models.js +5 -0
  15. package/dist/channels/slack/outbound.d.ts +12 -0
  16. package/dist/channels/slack/outbound.js +18 -0
  17. package/dist/channels/slack/transcribe.d.ts +41 -0
  18. package/dist/channels/slack/transcribe.js +106 -0
  19. package/dist/channels/webhook/adapter.d.ts +23 -0
  20. package/dist/channels/webhook/adapter.js +86 -0
  21. package/dist/channels/webhook/hmac.d.ts +13 -0
  22. package/dist/channels/webhook/hmac.js +26 -0
  23. package/dist/channels/webhook/models.d.ts +9 -0
  24. package/dist/channels/webhook/models.js +5 -0
  25. package/dist/channels/webhook/server.d.ts +20 -0
  26. package/dist/channels/webhook/server.js +91 -0
  27. package/dist/cli/templates/config.yml.d.ts +7 -0
  28. package/dist/cli/templates/config.yml.js +61 -0
  29. package/dist/cli/templates/env.d.ts +1 -0
  30. package/dist/cli/templates/env.js +30 -0
  31. package/dist/cli/templates/index.ts.d.ts +2 -0
  32. package/dist/cli/templates/index.ts.js +30 -0
  33. package/dist/cli/templates/package.json.d.ts +5 -0
  34. package/dist/cli/templates/package.json.js +28 -0
  35. package/dist/connectors/google/calendar-connector.d.ts +40 -0
  36. package/dist/connectors/google/calendar-connector.js +243 -0
  37. package/dist/connectors/google/gmail-connector.d.ts +42 -0
  38. package/dist/connectors/google/gmail-connector.js +345 -0
  39. package/dist/connectors/google/oauth.d.ts +48 -0
  40. package/dist/connectors/google/oauth.js +112 -0
  41. package/dist/connectors/google/types.d.ts +78 -0
  42. package/dist/connectors/google/types.js +2 -0
  43. package/dist/core/chat/auto-discovery.d.ts +16 -0
  44. package/dist/core/chat/auto-discovery.js +54 -0
  45. package/dist/core/chat/channel-registry.d.ts +45 -0
  46. package/dist/core/chat/channel-registry.js +96 -0
  47. package/dist/core/chat/chat-pipeline.d.ts +104 -0
  48. package/dist/core/chat/chat-pipeline.js +282 -0
  49. package/dist/core/chat/chat-responder.d.ts +90 -0
  50. package/dist/core/chat/chat-responder.js +185 -0
  51. package/dist/core/chat/formatter.d.ts +11 -0
  52. package/dist/core/chat/formatter.js +60 -0
  53. package/dist/core/chat/index.d.ts +24 -0
  54. package/dist/core/chat/index.js +18 -0
  55. package/dist/core/chat/message-interpreter.d.ts +91 -0
  56. package/dist/core/chat/message-interpreter.js +164 -0
  57. package/dist/core/chat/message-store.d.ts +66 -0
  58. package/dist/core/chat/message-store.js +131 -0
  59. package/dist/core/chat/notification-queue.d.ts +34 -0
  60. package/dist/core/chat/notification-queue.js +111 -0
  61. package/dist/core/chat/pipeline.d.ts +38 -0
  62. package/dist/core/chat/pipeline.js +89 -0
  63. package/dist/core/chat/policies.d.ts +16 -0
  64. package/dist/core/chat/policies.js +25 -0
  65. package/dist/core/chat/routing.d.ts +17 -0
  66. package/dist/core/chat/routing.js +36 -0
  67. package/dist/core/chat/session-key.d.ts +30 -0
  68. package/dist/core/chat/session-key.js +65 -0
  69. package/dist/core/chat/session-manager.d.ts +17 -0
  70. package/dist/core/chat/session-manager.js +23 -0
  71. package/dist/core/chat/text-chunker.d.ts +9 -0
  72. package/dist/core/chat/text-chunker.js +48 -0
  73. package/dist/core/chat/triage-router.d.ts +75 -0
  74. package/dist/core/chat/triage-router.js +142 -0
  75. package/dist/core/chat/types.d.ts +5 -0
  76. package/dist/core/chat/types.js +5 -0
  77. package/dist/core/config/defaults.d.ts +2 -0
  78. package/dist/core/config/defaults.js +38 -0
  79. package/dist/core/config/index.d.ts +6 -0
  80. package/dist/core/config/index.js +4 -0
  81. package/dist/core/config/interpolate.d.ts +5 -0
  82. package/dist/core/config/interpolate.js +27 -0
  83. package/dist/core/config/loader.d.ts +24 -0
  84. package/dist/core/config/loader.js +59 -0
  85. package/dist/core/config/schema.d.ts +5 -0
  86. package/dist/core/config/schema.js +119 -0
  87. package/dist/core/data/core-entity-contexts.d.ts +14 -0
  88. package/dist/core/data/core-entity-contexts.js +197 -0
  89. package/dist/core/data/core-migrations.d.ts +5 -0
  90. package/dist/core/data/core-migrations.js +45 -0
  91. package/dist/core/data/core-schema.d.ts +6 -0
  92. package/dist/core/data/core-schema.js +454 -0
  93. package/dist/core/data/data-store.d.ts +67 -0
  94. package/dist/core/data/data-store.js +218 -0
  95. package/dist/core/data/domain-entity-contexts.d.ts +29 -0
  96. package/dist/core/data/domain-entity-contexts.js +321 -0
  97. package/dist/core/data/domain-schema.d.ts +36 -0
  98. package/dist/core/data/domain-schema.js +323 -0
  99. package/dist/core/data/index.d.ts +7 -0
  100. package/dist/core/data/index.js +7 -0
  101. package/dist/core/data/types.d.ts +111 -0
  102. package/dist/core/data/types.js +1 -0
  103. package/dist/core/hooks/hook-bus.d.ts +18 -0
  104. package/dist/core/hooks/hook-bus.js +120 -0
  105. package/dist/core/hooks/index.d.ts +2 -0
  106. package/dist/core/hooks/index.js +1 -0
  107. package/dist/core/hooks/types.d.ts +19 -0
  108. package/dist/core/hooks/types.js +1 -0
  109. package/dist/core/index.d.ts +4 -0
  110. package/dist/core/index.js +4 -0
  111. package/dist/core/llm/auto-discovery.d.ts +11 -0
  112. package/dist/core/llm/auto-discovery.js +49 -0
  113. package/dist/core/llm/cost-tracker.d.ts +6 -0
  114. package/dist/core/llm/cost-tracker.js +38 -0
  115. package/dist/core/llm/index.d.ts +4 -0
  116. package/dist/core/llm/index.js +3 -0
  117. package/dist/core/llm/model-router.d.ts +25 -0
  118. package/dist/core/llm/model-router.js +49 -0
  119. package/dist/core/llm/provider-registry.d.ts +9 -0
  120. package/dist/core/llm/provider-registry.js +25 -0
  121. package/dist/core/llm/types.d.ts +2 -0
  122. package/dist/core/llm/types.js +2 -0
  123. package/dist/core/orchestrator/adapters/api-adapter.d.ts +34 -0
  124. package/dist/core/orchestrator/adapters/api-adapter.js +88 -0
  125. package/dist/core/orchestrator/adapters/cli-adapter.d.ts +22 -0
  126. package/dist/core/orchestrator/adapters/cli-adapter.js +69 -0
  127. package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +35 -0
  128. package/dist/core/orchestrator/adapters/deterministic-adapter.js +75 -0
  129. package/dist/core/orchestrator/adapters/env-whitelist.d.ts +4 -0
  130. package/dist/core/orchestrator/adapters/env-whitelist.js +27 -0
  131. package/dist/core/orchestrator/adapters/output-extractor.d.ts +11 -0
  132. package/dist/core/orchestrator/adapters/output-extractor.js +59 -0
  133. package/dist/core/orchestrator/adapters/process-manager.d.ts +15 -0
  134. package/dist/core/orchestrator/adapters/process-manager.js +26 -0
  135. package/dist/core/orchestrator/adapters/tool-loop.d.ts +22 -0
  136. package/dist/core/orchestrator/adapters/tool-loop.js +66 -0
  137. package/dist/core/orchestrator/agent-registry.d.ts +31 -0
  138. package/dist/core/orchestrator/agent-registry.js +135 -0
  139. package/dist/core/orchestrator/budget-controller.d.ts +19 -0
  140. package/dist/core/orchestrator/budget-controller.js +73 -0
  141. package/dist/core/orchestrator/chain-guard.d.ts +14 -0
  142. package/dist/core/orchestrator/chain-guard.js +23 -0
  143. package/dist/core/orchestrator/circuit-breaker.d.ts +65 -0
  144. package/dist/core/orchestrator/circuit-breaker.js +159 -0
  145. package/dist/core/orchestrator/claude-stream-parser.d.ts +31 -0
  146. package/dist/core/orchestrator/claude-stream-parser.js +99 -0
  147. package/dist/core/orchestrator/config-revisions.d.ts +6 -0
  148. package/dist/core/orchestrator/config-revisions.js +17 -0
  149. package/dist/core/orchestrator/dependency-resolver.d.ts +20 -0
  150. package/dist/core/orchestrator/dependency-resolver.js +78 -0
  151. package/dist/core/orchestrator/governance-gate.d.ts +110 -0
  152. package/dist/core/orchestrator/governance-gate.js +170 -0
  153. package/dist/core/orchestrator/learning-pipeline.d.ts +109 -0
  154. package/dist/core/orchestrator/learning-pipeline.js +249 -0
  155. package/dist/core/orchestrator/loop-detector.d.ts +51 -0
  156. package/dist/core/orchestrator/loop-detector.js +133 -0
  157. package/dist/core/orchestrator/ndjson-logger.d.ts +6 -0
  158. package/dist/core/orchestrator/ndjson-logger.js +18 -0
  159. package/dist/core/orchestrator/permission-relay.d.ts +72 -0
  160. package/dist/core/orchestrator/permission-relay.js +164 -0
  161. package/dist/core/orchestrator/run-manager.d.ts +31 -0
  162. package/dist/core/orchestrator/run-manager.js +178 -0
  163. package/dist/core/orchestrator/scheduler.d.ts +70 -0
  164. package/dist/core/orchestrator/scheduler.js +198 -0
  165. package/dist/core/orchestrator/secret-store.d.ts +57 -0
  166. package/dist/core/orchestrator/secret-store.js +171 -0
  167. package/dist/core/orchestrator/session-manager.d.ts +13 -0
  168. package/dist/core/orchestrator/session-manager.js +66 -0
  169. package/dist/core/orchestrator/task-queue.d.ts +34 -0
  170. package/dist/core/orchestrator/task-queue.js +83 -0
  171. package/dist/core/orchestrator/template-interpolate.d.ts +5 -0
  172. package/dist/core/orchestrator/template-interpolate.js +18 -0
  173. package/dist/core/orchestrator/user-registry.d.ts +47 -0
  174. package/dist/core/orchestrator/user-registry.js +76 -0
  175. package/dist/core/orchestrator/wakeup-queue.d.ts +9 -0
  176. package/dist/core/orchestrator/wakeup-queue.js +45 -0
  177. package/dist/core/orchestrator/workflow-engine.d.ts +47 -0
  178. package/dist/core/orchestrator/workflow-engine.js +204 -0
  179. package/dist/core/security/audit.d.ts +20 -0
  180. package/dist/core/security/audit.js +33 -0
  181. package/dist/core/security/column-validator.d.ts +20 -0
  182. package/dist/core/security/column-validator.js +37 -0
  183. package/dist/core/security/index.d.ts +5 -0
  184. package/dist/core/security/index.js +5 -0
  185. package/dist/core/security/process-env.d.ts +13 -0
  186. package/dist/core/security/process-env.js +49 -0
  187. package/dist/core/security/sanitizer.d.ts +11 -0
  188. package/dist/core/security/sanitizer.js +39 -0
  189. package/dist/core/security/types.d.ts +11 -0
  190. package/dist/core/security/types.js +1 -0
  191. package/dist/core/update/auto-update.d.ts +21 -0
  192. package/dist/core/update/auto-update.js +102 -0
  193. package/dist/core/update/backup-manager.d.ts +7 -0
  194. package/dist/core/update/backup-manager.js +24 -0
  195. package/dist/core/update/index.d.ts +8 -0
  196. package/dist/core/update/index.js +6 -0
  197. package/dist/core/update/migration-hooks.d.ts +11 -0
  198. package/dist/core/update/migration-hooks.js +10 -0
  199. package/dist/core/update/types.d.ts +11 -0
  200. package/dist/core/update/types.js +1 -0
  201. package/dist/core/update/update-checker.d.ts +11 -0
  202. package/dist/core/update/update-checker.js +63 -0
  203. package/dist/core/update/update-manager.d.ts +25 -0
  204. package/dist/core/update/update-manager.js +101 -0
  205. package/dist/core/update/version-utils.d.ts +6 -0
  206. package/dist/core/update/version-utils.js +34 -0
  207. package/dist/index.d.ts +2 -0
  208. package/dist/index.js +20 -13
  209. package/dist/providers/anthropic/models.d.ts +2 -0
  210. package/dist/providers/anthropic/models.js +29 -0
  211. package/dist/providers/anthropic/provider.d.ts +13 -0
  212. package/dist/providers/anthropic/provider.js +119 -0
  213. package/dist/providers/anthropic/tool-converter.d.ts +10 -0
  214. package/dist/providers/anthropic/tool-converter.js +7 -0
  215. package/dist/providers/ollama/provider.d.ts +17 -0
  216. package/dist/providers/ollama/provider.js +185 -0
  217. package/dist/providers/openai/models.d.ts +2 -0
  218. package/dist/providers/openai/models.js +29 -0
  219. package/dist/providers/openai/provider.d.ts +13 -0
  220. package/dist/providers/openai/provider.js +163 -0
  221. package/dist/providers/openai/tool-converter.d.ts +10 -0
  222. package/dist/providers/openai/tool-converter.js +10 -0
  223. package/dist/shared/constants.d.ts +50 -0
  224. package/dist/shared/constants.js +64 -0
  225. package/dist/shared/index.d.ts +14 -0
  226. package/dist/shared/index.js +14 -0
  227. package/dist/shared/types/agent.d.ts +36 -0
  228. package/dist/shared/types/agent.js +2 -0
  229. package/dist/shared/types/channel.d.ts +70 -0
  230. package/dist/shared/types/channel.js +2 -0
  231. package/dist/shared/types/config.d.ts +111 -0
  232. package/dist/shared/types/config.js +2 -0
  233. package/dist/shared/types/connector.d.ts +77 -0
  234. package/dist/shared/types/connector.js +2 -0
  235. package/dist/shared/types/execution.d.ts +29 -0
  236. package/dist/shared/types/execution.js +2 -0
  237. package/dist/shared/types/provider.d.ts +73 -0
  238. package/dist/shared/types/provider.js +2 -0
  239. package/dist/shared/types/task.d.ts +47 -0
  240. package/dist/shared/types/task.js +2 -0
  241. package/dist/shared/types/workflow.d.ts +39 -0
  242. package/dist/shared/types/workflow.js +2 -0
  243. package/dist/shared/utils.d.ts +6 -0
  244. package/dist/shared/utils.js +13 -0
  245. package/dist/update-check.d.ts +5 -0
  246. package/dist/update-check.js +56 -0
  247. package/package.json +1 -1
@@ -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>;
@@ -0,0 +1,56 @@
1
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { homedir } from 'node:os';
4
+ const ONE_DAY_MS = 86_400_000;
5
+ function isNewer(latest, current) {
6
+ const a = latest.split('.').map(Number);
7
+ const b = current.split('.').map(Number);
8
+ for (let i = 0; i < Math.max(a.length, b.length); i++) {
9
+ const av = a[i] ?? 0;
10
+ const bv = b[i] ?? 0;
11
+ if (av > bv)
12
+ return true;
13
+ if (av < bv)
14
+ return false;
15
+ }
16
+ return false;
17
+ }
18
+ /**
19
+ * Check the npm registry for a newer version. Caches results for 24 hours.
20
+ * Returns the latest version string if an update is available, null otherwise.
21
+ */
22
+ export async function checkForUpdate(pkgName, currentVersion) {
23
+ const cacheDir = join(homedir(), `.${pkgName}`);
24
+ const cachePath = join(cacheDir, 'update-check.json');
25
+ // Check cache first
26
+ try {
27
+ if (existsSync(cachePath)) {
28
+ const cached = JSON.parse(readFileSync(cachePath, 'utf-8'));
29
+ if (Date.now() - cached.checked < ONE_DAY_MS) {
30
+ return isNewer(cached.latest, currentVersion) ? cached.latest : null;
31
+ }
32
+ }
33
+ }
34
+ catch {
35
+ // Cache corrupt or unreadable — proceed to fetch
36
+ }
37
+ // Fetch latest version from npm
38
+ const res = await fetch(`https://registry.npmjs.org/${pkgName}/latest`, {
39
+ headers: { accept: 'application/json' },
40
+ signal: AbortSignal.timeout(5000),
41
+ });
42
+ if (!res.ok)
43
+ return null;
44
+ const data = (await res.json());
45
+ const latest = data.version;
46
+ // Write cache
47
+ try {
48
+ if (!existsSync(cacheDir))
49
+ mkdirSync(cacheDir, { recursive: true });
50
+ writeFileSync(cachePath, JSON.stringify({ latest, checked: Date.now() }));
51
+ }
52
+ catch {
53
+ // Non-critical — skip caching
54
+ }
55
+ return isNewer(latest, currentVersion) ? latest : null;
56
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botinabox",
3
- "version": "1.8.2",
3
+ "version": "1.8.3",
4
4
  "description": "Bot in a Box — framework for building multi-agent bots",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",