botinabox 1.9.3 → 1.10.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.
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  parseDiscordEvent
3
3
  } from "../../chunk-DLJKZD3Q.js";
4
+ import "../../chunk-3RG5ZIWI.js";
4
5
 
5
6
  // src/channels/discord/outbound.ts
6
7
  var DISCORD_MAX_LENGTH = 2e3;
@@ -80,7 +81,7 @@ var DiscordAdapter = class {
80
81
  /** Simulate receiving an inbound message (for testing/webhooks). */
81
82
  async receive(event) {
82
83
  if (this.onMessage) {
83
- const { parseDiscordEvent: parseDiscordEvent2 } = await import("../../inbound-SNEMBLGA.js");
84
+ const { parseDiscordEvent: parseDiscordEvent2 } = await import("../../inbound-WU7X2HGA.js");
84
85
  const msg = parseDiscordEvent2(event);
85
86
  await this.onMessage(msg);
86
87
  }
@@ -8,6 +8,7 @@ import {
8
8
  import {
9
9
  chunkText
10
10
  } from "../../chunk-ZTZFPTOQ.js";
11
+ import "../../chunk-3RG5ZIWI.js";
11
12
 
12
13
  // src/channels/slack/outbound.ts
13
14
  function formatForSlack(text) {
@@ -70,8 +71,8 @@ var SlackAdapter = class {
70
71
  /** Simulate receiving an inbound message (for testing/webhooks). */
71
72
  async receive(event) {
72
73
  if (this.onMessage) {
73
- const { parseSlackEvent: parseSlackEvent2 } = await import("../../inbound-ZJHAYVMF.js");
74
- const { enrichVoiceMessage: enrichVoiceMessage2 } = await import("../../inbound-ZJHAYVMF.js");
74
+ const { parseSlackEvent: parseSlackEvent2 } = await import("../../inbound-IBKXBFZF.js");
75
+ const { enrichVoiceMessage: enrichVoiceMessage2 } = await import("../../inbound-IBKXBFZF.js");
75
76
  let msg = parseSlackEvent2(event);
76
77
  if (msg.body.includes("[Voice message") && this.config?.botToken) {
77
78
  msg = await enrichVoiceMessage2(msg, this.config.botToken);
@@ -94,7 +95,7 @@ var SlackBoltAdapter = class {
94
95
  async start() {
95
96
  const boltModule = "@slack/bolt";
96
97
  const bolt = await import(boltModule);
97
- const { enrichVoiceMessage: enrichVoiceMessage2 } = await import("../../inbound-ZJHAYVMF.js");
98
+ const { enrichVoiceMessage: enrichVoiceMessage2 } = await import("../../inbound-IBKXBFZF.js");
98
99
  const boltApp = new bolt.App({
99
100
  token: this.config.botToken,
100
101
  appToken: this.config.appToken,
@@ -1,3 +1,5 @@
1
+ import "../../chunk-3RG5ZIWI.js";
2
+
1
3
  // src/channels/webhook/server.ts
2
4
  import { createServer } from "http";
3
5
 
@@ -0,0 +1,10 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
package/dist/cli.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import "./chunk-3RG5ZIWI.js";
2
3
 
3
4
  // src/cli.ts
4
5
  import * as readline from "readline";
@@ -178,7 +179,7 @@ async function authGoogle(args) {
178
179
  });
179
180
  }
180
181
  };
181
- const { GoogleGmailConnector } = await import("./gmail-connector-ULSMN6X2.js");
182
+ const { GoogleGmailConnector } = await import("./gmail-connector-Z7SO6VOS.js");
182
183
  const connector = new GoogleGmailConnector({ tokenLoader, tokenSaver });
183
184
  connector.config = {
184
185
  account,
@@ -8,6 +8,7 @@ import {
8
8
  refreshIfNeeded,
9
9
  saveTokens
10
10
  } from "../../chunk-XYF5PSB2.js";
11
+ import "../../chunk-3RG5ZIWI.js";
11
12
 
12
13
  // src/connectors/google/calendar-connector.ts
13
14
  var GoogleCalendarConnector = class {
@@ -0,0 +1,7 @@
1
+ import {
2
+ GoogleGmailConnector
3
+ } from "./chunk-XYF5PSB2.js";
4
+ import "./chunk-3RG5ZIWI.js";
5
+ export {
6
+ GoogleGmailConnector
7
+ };
@@ -0,0 +1,11 @@
1
+ import {
2
+ enrichVoiceMessage,
3
+ extractVoiceTranscript,
4
+ parseSlackEvent
5
+ } from "./chunk-NNPCKR6G.js";
6
+ import "./chunk-3RG5ZIWI.js";
7
+ export {
8
+ enrichVoiceMessage,
9
+ extractVoiceTranscript,
10
+ parseSlackEvent
11
+ };
@@ -0,0 +1,7 @@
1
+ import {
2
+ parseDiscordEvent
3
+ } from "./chunk-DLJKZD3Q.js";
4
+ import "./chunk-3RG5ZIWI.js";
5
+ export {
6
+ parseDiscordEvent
7
+ };
package/dist/index.d.ts CHANGED
@@ -1835,6 +1835,8 @@ type ToolHandler = (input: Record<string, unknown>, context: {
1835
1835
  taskId: string;
1836
1836
  agentId: string;
1837
1837
  hooks: HookBus;
1838
+ /** Resolve a relative file path to an absolute path (environment-aware). */
1839
+ resolveFilePath?: (path: string) => string;
1838
1840
  }) => Promise<string>;
1839
1841
  interface ExecutionEngineConfig {
1840
1842
  /** Anthropic client instance */
@@ -1869,6 +1871,8 @@ interface ExecutionEngineConfig {
1869
1871
  systemPromptSuffix?: string;
1870
1872
  /** Include system context (users, files, etc). Default: true */
1871
1873
  includeSystemContext?: boolean;
1874
+ /** Resolve file paths from DB-relative to absolute (for cross-environment support). */
1875
+ resolveFilePath?: (path: string) => string;
1872
1876
  }
1873
1877
  declare function registerExecutionEngine(opts: {
1874
1878
  db: DataStore;
@@ -1877,6 +1881,16 @@ declare function registerExecutionEngine(opts: {
1877
1881
  config: ExecutionEngineConfig;
1878
1882
  }): Promise<void>;
1879
1883
 
1884
+ declare const sendFileTool: {
1885
+ definition: ToolDefinition;
1886
+ handler: ToolHandler;
1887
+ };
1888
+
1889
+ declare const readFileTool: {
1890
+ definition: ToolDefinition;
1891
+ handler: ToolHandler;
1892
+ };
1893
+
1880
1894
  interface SecretInput {
1881
1895
  name: string;
1882
1896
  type?: string;
@@ -1965,4 +1979,4 @@ declare function isLoginRequired(stdout: string): boolean;
1965
1979
  /** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
1966
1980
  declare function deactivateLocalImagePaths(prompt: string): string;
1967
1981
 
1968
- 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, ChatMessage, 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 ExecutionEngineConfig, 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, MessagePipeline, 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 RunContext, RunManager, type RunResult, type RunStatus, 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 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, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, createDefaultLLMCall, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, loadConfig, parseClaudeStream, parseVersion, registerExecutionEngine, runPackageMigrations, sanitize, topologicalSort, truncateAtWord, validateConfig };
1982
+ 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, ChatMessage, 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 ExecutionEngineConfig, 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, MessagePipeline, 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 RunContext, RunManager, type RunResult, type RunStatus, 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 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, areDependenciesMet, autoUpdate, buildAgentBindings, buildChainOrigin, buildProcessEnv, buildSystemContext, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, createDefaultLLMCall, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, loadConfig, parseClaudeStream, parseVersion, readFileTool, registerExecutionEngine, runPackageMigrations, sanitize, sendFileTool, topologicalSort, truncateAtWord, validateConfig };
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import {
2
2
  chunkText
3
3
  } from "./chunk-ZTZFPTOQ.js";
4
+ import {
5
+ __require
6
+ } from "./chunk-3RG5ZIWI.js";
4
7
 
5
8
  // src/shared/constants.ts
6
9
  var EVENTS = {
@@ -6123,7 +6126,7 @@ ${systemContext}` : "",
6123
6126
  try {
6124
6127
  const result = await handler(
6125
6128
  toolUse.input,
6126
- { taskId, agentId: assigneeId, hooks }
6129
+ { taskId, agentId: assigneeId, hooks, resolveFilePath: config.resolveFilePath }
6127
6130
  );
6128
6131
  toolResults.push({ type: "tool_result", tool_use_id: toolUse.id, content: result });
6129
6132
  } catch (err) {
@@ -6152,6 +6155,102 @@ ${systemContext}` : "",
6152
6155
  });
6153
6156
  }
6154
6157
 
6158
+ // src/core/orchestrator/tools/send-file.ts
6159
+ import { existsSync as existsSync3 } from "fs";
6160
+ import { basename } from "path";
6161
+ var sendFileTool = {
6162
+ definition: {
6163
+ name: "send_file",
6164
+ description: "Send/deliver/attach a file to the user on Slack. Use this when the user asks for a document, contract, report, or any file. The file_path is in the Files section of your system context.",
6165
+ input_schema: {
6166
+ type: "object",
6167
+ properties: {
6168
+ file_path: { type: "string", description: "Path to the file (from system context)" }
6169
+ },
6170
+ required: ["file_path"]
6171
+ }
6172
+ },
6173
+ handler: async (input, context) => {
6174
+ const rawPath = input.file_path;
6175
+ const filePath = context.resolveFilePath?.(rawPath) ?? rawPath;
6176
+ if (!existsSync3(filePath)) return `Error: file not found at ${filePath}`;
6177
+ await context.hooks.emit("file.deliver", {
6178
+ filePath,
6179
+ fileName: basename(filePath),
6180
+ taskId: context.taskId
6181
+ });
6182
+ return `File "${basename(filePath)}" sent to user.`;
6183
+ }
6184
+ };
6185
+
6186
+ // src/core/orchestrator/tools/read-file.ts
6187
+ import { existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
6188
+ var readFileTool = {
6189
+ definition: {
6190
+ name: "read_file",
6191
+ description: "Read/review the contents of a file. Use this when the user asks about what a document contains, wants you to review a contract, check terms, summarize a report, etc. Supports .docx (Word), .txt, .md, .json, .csv. The file_path is in the Files section of your system context.",
6192
+ input_schema: {
6193
+ type: "object",
6194
+ properties: {
6195
+ file_path: { type: "string", description: "Path to the file (from system context)" }
6196
+ },
6197
+ required: ["file_path"]
6198
+ }
6199
+ },
6200
+ handler: async (input, context) => {
6201
+ const rawPath = input.file_path;
6202
+ const filePath = context.resolveFilePath?.(rawPath) ?? rawPath;
6203
+ if (!existsSync4(filePath)) return `Error: file not found at ${filePath}`;
6204
+ try {
6205
+ if (filePath.endsWith(".docx")) {
6206
+ return extractDocxText(filePath);
6207
+ }
6208
+ return readFileSync6(filePath, "utf8").slice(0, 8e3);
6209
+ } catch (err) {
6210
+ return `Error reading file: ${err instanceof Error ? err.message : String(err)}`;
6211
+ }
6212
+ }
6213
+ };
6214
+ function extractDocxText(filePath) {
6215
+ const data = readFileSync6(filePath);
6216
+ try {
6217
+ const zip = parseZipEntries(data);
6218
+ const docEntry = zip.find((e) => e.name === "word/document.xml");
6219
+ if (!docEntry) return "Error: could not find document.xml in docx";
6220
+ const xml = docEntry.data.toString("utf8");
6221
+ return xml.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim().slice(0, 8e3);
6222
+ } catch {
6223
+ return "Error: could not parse docx file";
6224
+ }
6225
+ }
6226
+ function parseZipEntries(buf) {
6227
+ const entries = [];
6228
+ let offset = 0;
6229
+ while (offset < buf.length - 4) {
6230
+ if (buf[offset] !== 80 || buf[offset + 1] !== 75 || buf[offset + 2] !== 3 || buf[offset + 3] !== 4) {
6231
+ break;
6232
+ }
6233
+ const compressionMethod = buf.readUInt16LE(offset + 8);
6234
+ const compressedSize = buf.readUInt32LE(offset + 18);
6235
+ const nameLen = buf.readUInt16LE(offset + 26);
6236
+ const extraLen = buf.readUInt16LE(offset + 28);
6237
+ const name = buf.slice(offset + 30, offset + 30 + nameLen).toString("utf8");
6238
+ const dataStart = offset + 30 + nameLen + extraLen;
6239
+ if (compressionMethod === 0) {
6240
+ entries.push({ name, data: buf.slice(dataStart, dataStart + compressedSize) });
6241
+ } else if (compressionMethod === 8) {
6242
+ try {
6243
+ const { inflateRawSync } = __require("zlib");
6244
+ const inflated = inflateRawSync(buf.slice(dataStart, dataStart + compressedSize));
6245
+ entries.push({ name, data: inflated });
6246
+ } catch {
6247
+ }
6248
+ }
6249
+ offset = dataStart + compressedSize;
6250
+ }
6251
+ return entries;
6252
+ }
6253
+
6155
6254
  // src/core/orchestrator/user-registry.ts
6156
6255
  import { v4 as uuidv4 } from "uuid";
6157
6256
  var UserRegistry = class {
@@ -6565,9 +6664,11 @@ export {
6565
6664
  loadConfig,
6566
6665
  parseClaudeStream,
6567
6666
  parseVersion,
6667
+ readFileTool,
6568
6668
  registerExecutionEngine,
6569
6669
  runPackageMigrations,
6570
6670
  sanitize,
6671
+ sendFileTool,
6571
6672
  topologicalSort,
6572
6673
  truncateAtWord,
6573
6674
  validateConfig
@@ -1,3 +1,5 @@
1
+ import "../../chunk-3RG5ZIWI.js";
2
+
1
3
  // src/providers/anthropic/provider.ts
2
4
  import Anthropic from "@anthropic-ai/sdk";
3
5
 
@@ -1,3 +1,5 @@
1
+ import "../../chunk-3RG5ZIWI.js";
2
+
1
3
  // src/providers/ollama/provider.ts
2
4
  var OllamaProvider = class {
3
5
  id = "ollama";
@@ -1,3 +1,5 @@
1
+ import "../../chunk-3RG5ZIWI.js";
2
+
1
3
  // src/providers/openai/provider.ts
2
4
  import OpenAI from "openai";
3
5
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botinabox",
3
- "version": "1.9.3",
3
+ "version": "1.10.0",
4
4
  "description": "Bot in a Box — framework for building multi-agent bots",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",