botinabox 2.9.0 → 2.9.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 (158) hide show
  1. package/README.md +2 -1
  2. package/dist/channels/discord/adapter.d.ts +32 -0
  3. package/dist/channels/discord/inbound.d.ts +25 -0
  4. package/dist/channels/discord/index.d.ts +8 -84
  5. package/dist/channels/discord/models.d.ts +8 -0
  6. package/dist/channels/discord/outbound.d.ts +14 -0
  7. package/dist/channels/slack/adapter.d.ts +33 -0
  8. package/dist/channels/slack/bolt-adapter.d.ts +31 -0
  9. package/dist/channels/slack/enrichers/enrich.d.ts +12 -0
  10. package/dist/channels/slack/enrichers/image-enricher.d.ts +10 -0
  11. package/dist/channels/slack/enrichers/index.d.ts +4 -0
  12. package/dist/channels/slack/enrichers/pdf-enricher.d.ts +8 -0
  13. package/dist/channels/slack/enrichers/types.d.ts +33 -0
  14. package/dist/channels/slack/inbound.d.ts +59 -0
  15. package/dist/channels/slack/index.d.ts +13 -252
  16. package/dist/channels/slack/index.js +6 -2
  17. package/dist/channels/slack/media-type.d.ts +14 -0
  18. package/dist/channels/slack/models.d.ts +9 -0
  19. package/dist/channels/slack/outbound.d.ts +12 -0
  20. package/dist/channels/slack/transcribe.d.ts +41 -0
  21. package/dist/channels/webhook/adapter.d.ts +23 -0
  22. package/dist/channels/webhook/hmac.d.ts +13 -0
  23. package/dist/channels/webhook/index.d.ts +7 -70
  24. package/dist/channels/webhook/models.d.ts +9 -0
  25. package/dist/channels/webhook/server.d.ts +20 -0
  26. package/dist/cli/templates/config.yml.d.ts +7 -0
  27. package/dist/cli/templates/env.d.ts +1 -0
  28. package/dist/cli/templates/index.ts.d.ts +2 -0
  29. package/dist/cli/templates/package.json.d.ts +5 -0
  30. package/dist/cli.d.ts +1 -3
  31. package/dist/connectors/google/calendar-connector.d.ts +40 -0
  32. package/dist/connectors/google/drive-connector.d.ts +43 -0
  33. package/dist/connectors/google/drive-read.d.ts +81 -0
  34. package/dist/connectors/google/gmail-connector.d.ts +42 -0
  35. package/dist/connectors/google/index.d.ts +10 -369
  36. package/dist/connectors/google/oauth.d.ts +48 -0
  37. package/dist/connectors/google/types.d.ts +110 -0
  38. package/dist/core/chat/auto-discovery.d.ts +16 -0
  39. package/dist/core/chat/channel-registry.d.ts +45 -0
  40. package/dist/core/chat/chat-pipeline-v2.d.ts +138 -0
  41. package/dist/core/chat/chat-pipeline.d.ts +116 -0
  42. package/dist/core/chat/chat-responder.d.ts +94 -0
  43. package/dist/core/chat/formatter.d.ts +11 -0
  44. package/dist/core/chat/index.d.ts +26 -0
  45. package/dist/core/chat/message-interpreter.d.ts +91 -0
  46. package/dist/core/chat/message-store.d.ts +71 -0
  47. package/dist/core/chat/notification-queue.d.ts +34 -0
  48. package/dist/core/chat/pipeline.d.ts +38 -0
  49. package/dist/core/chat/policies.d.ts +16 -0
  50. package/dist/core/chat/routing.d.ts +17 -0
  51. package/dist/core/chat/session-key.d.ts +30 -0
  52. package/dist/core/chat/session-manager.d.ts +17 -0
  53. package/dist/core/chat/text-chunker.d.ts +9 -0
  54. package/dist/core/chat/triage-router.d.ts +75 -0
  55. package/dist/core/chat/types.d.ts +5 -0
  56. package/dist/core/config/defaults.d.ts +2 -0
  57. package/dist/core/config/index.d.ts +6 -0
  58. package/dist/core/config/interpolate.d.ts +5 -0
  59. package/dist/core/config/loader.d.ts +24 -0
  60. package/dist/core/config/schema.d.ts +5 -0
  61. package/dist/core/data/context-builder.d.ts +27 -0
  62. package/dist/core/data/core-entity-contexts.d.ts +14 -0
  63. package/dist/core/data/core-migrations.d.ts +5 -0
  64. package/dist/core/data/core-schema.d.ts +6 -0
  65. package/dist/core/data/data-store.d.ts +67 -0
  66. package/dist/core/data/domain-entity-contexts.d.ts +35 -0
  67. package/dist/core/data/domain-schema.d.ts +36 -0
  68. package/dist/core/data/index.d.ts +8 -0
  69. package/dist/core/data/types.d.ts +111 -0
  70. package/dist/core/hooks/hook-bus.d.ts +24 -0
  71. package/dist/core/hooks/index.d.ts +2 -0
  72. package/dist/core/hooks/types.d.ts +19 -0
  73. package/dist/core/index.d.ts +4 -0
  74. package/dist/core/llm/auto-discovery.d.ts +11 -0
  75. package/dist/core/llm/cost-tracker.d.ts +6 -0
  76. package/dist/core/llm/default-llm-call.d.ts +35 -0
  77. package/dist/core/llm/index.d.ts +6 -0
  78. package/dist/core/llm/model-router.d.ts +25 -0
  79. package/dist/core/llm/provider-registry.d.ts +9 -0
  80. package/dist/core/llm/types.d.ts +2 -0
  81. package/dist/core/orchestrator/adapters/api-adapter.d.ts +34 -0
  82. package/dist/core/orchestrator/adapters/cli-adapter.d.ts +62 -0
  83. package/dist/core/orchestrator/adapters/deterministic-adapter.d.ts +35 -0
  84. package/dist/core/orchestrator/adapters/env-whitelist.d.ts +4 -0
  85. package/dist/core/orchestrator/adapters/output-extractor.d.ts +11 -0
  86. package/dist/core/orchestrator/adapters/process-manager.d.ts +15 -0
  87. package/dist/core/orchestrator/adapters/tool-loop.d.ts +22 -0
  88. package/dist/core/orchestrator/agent-registry.d.ts +31 -0
  89. package/dist/core/orchestrator/budget-controller.d.ts +19 -0
  90. package/dist/core/orchestrator/chain-guard.d.ts +14 -0
  91. package/dist/core/orchestrator/circuit-breaker.d.ts +65 -0
  92. package/dist/core/orchestrator/claude-stream-parser.d.ts +31 -0
  93. package/dist/core/orchestrator/config-revisions.d.ts +6 -0
  94. package/dist/core/orchestrator/dependency-resolver.d.ts +20 -0
  95. package/dist/core/orchestrator/execution-engine.d.ts +99 -0
  96. package/dist/core/orchestrator/governance-gate.d.ts +110 -0
  97. package/dist/core/orchestrator/learning-pipeline.d.ts +112 -0
  98. package/dist/core/orchestrator/loop-detector.d.ts +51 -0
  99. package/dist/core/orchestrator/ndjson-logger.d.ts +6 -0
  100. package/dist/core/orchestrator/permission-relay.d.ts +72 -0
  101. package/dist/core/orchestrator/run-manager.d.ts +31 -0
  102. package/dist/core/orchestrator/scheduler.d.ts +74 -0
  103. package/dist/core/orchestrator/secret-store.d.ts +57 -0
  104. package/dist/core/orchestrator/session-manager.d.ts +13 -0
  105. package/dist/core/orchestrator/task-queue.d.ts +34 -0
  106. package/dist/core/orchestrator/template-interpolate.d.ts +5 -0
  107. package/dist/core/orchestrator/tools/file-ops.d.ts +12 -0
  108. package/dist/core/orchestrator/tools/index.d.ts +47 -0
  109. package/dist/core/orchestrator/tools/management.d.ts +12 -0
  110. package/dist/core/orchestrator/tools/messaging.d.ts +21 -0
  111. package/dist/core/orchestrator/tools/read-file.d.ts +5 -0
  112. package/dist/core/orchestrator/tools/resolve-agent.d.ts +9 -0
  113. package/dist/core/orchestrator/tools/roster.d.ts +16 -0
  114. package/dist/core/orchestrator/tools/send-file.d.ts +5 -0
  115. package/dist/core/orchestrator/tools/status.d.ts +20 -0
  116. package/dist/core/orchestrator/tools/task-ops.d.ts +13 -0
  117. package/dist/core/orchestrator/user-registry.d.ts +47 -0
  118. package/dist/core/orchestrator/wakeup-queue.d.ts +9 -0
  119. package/dist/core/orchestrator/workflow-engine.d.ts +47 -0
  120. package/dist/core/security/audit.d.ts +20 -0
  121. package/dist/core/security/column-validator.d.ts +20 -0
  122. package/dist/core/security/index.d.ts +5 -0
  123. package/dist/core/security/process-env.d.ts +13 -0
  124. package/dist/core/security/sanitizer.d.ts +11 -0
  125. package/dist/core/security/types.d.ts +11 -0
  126. package/dist/core/update/auto-update.d.ts +21 -0
  127. package/dist/core/update/backup-manager.d.ts +7 -0
  128. package/dist/core/update/index.d.ts +8 -0
  129. package/dist/core/update/migration-hooks.d.ts +11 -0
  130. package/dist/core/update/types.d.ts +11 -0
  131. package/dist/core/update/update-checker.d.ts +11 -0
  132. package/dist/core/update/update-manager.d.ts +25 -0
  133. package/dist/core/update/version-utils.d.ts +6 -0
  134. package/dist/index.d.ts +38 -2366
  135. package/dist/index.js +112 -5
  136. package/dist/providers/anthropic/index.d.ts +5 -20
  137. package/dist/providers/anthropic/models.d.ts +2 -0
  138. package/dist/providers/anthropic/provider.d.ts +13 -0
  139. package/dist/providers/anthropic/tool-converter.d.ts +10 -0
  140. package/dist/providers/ollama/index.d.ts +4 -22
  141. package/dist/providers/ollama/provider.d.ts +17 -0
  142. package/dist/providers/openai/index.d.ts +5 -20
  143. package/dist/providers/openai/models.d.ts +2 -0
  144. package/dist/providers/openai/provider.d.ts +13 -0
  145. package/dist/providers/openai/tool-converter.d.ts +10 -0
  146. package/dist/shared/constants.d.ts +50 -0
  147. package/dist/shared/index.d.ts +14 -0
  148. package/dist/shared/types/agent.d.ts +36 -0
  149. package/dist/shared/types/channel.d.ts +78 -0
  150. package/dist/shared/types/config.d.ts +160 -0
  151. package/dist/shared/types/connector.d.ts +77 -0
  152. package/dist/shared/types/execution.d.ts +29 -0
  153. package/dist/shared/types/provider.d.ts +87 -0
  154. package/dist/shared/types/task.d.ts +47 -0
  155. package/dist/shared/types/workflow.d.ts +39 -0
  156. package/dist/shared/utils.d.ts +6 -0
  157. package/dist/update-check.d.ts +5 -0
  158. package/package.json +2 -2
@@ -0,0 +1,47 @@
1
+ import type { DataStore } from "../data/data-store.js";
2
+ import type { HookBus } from "../hooks/hook-bus.js";
3
+ export interface UserInput {
4
+ id?: string;
5
+ org_id?: string;
6
+ name: string;
7
+ email?: string;
8
+ role?: string;
9
+ title?: string;
10
+ external_id?: string;
11
+ channel?: string;
12
+ timezone?: string;
13
+ preferences?: string;
14
+ notes?: string;
15
+ }
16
+ export interface User {
17
+ id: string;
18
+ org_id: string | null;
19
+ name: string;
20
+ email: string | null;
21
+ role: string | null;
22
+ title: string | null;
23
+ external_id: string | null;
24
+ channel: string | null;
25
+ timezone: string | null;
26
+ preferences: string;
27
+ notes: string | null;
28
+ created_at: string;
29
+ updated_at: string;
30
+ deleted_at: string | null;
31
+ }
32
+ export declare class UserRegistry {
33
+ private readonly db;
34
+ private readonly hooks;
35
+ constructor(db: DataStore, hooks: HookBus);
36
+ register(input: UserInput): Promise<User>;
37
+ getById(id: string): Promise<User | null>;
38
+ getByEmail(email: string): Promise<User | null>;
39
+ resolveByIdentity(channel: string, externalId: string): Promise<User | null>;
40
+ resolveOrCreate(externalId: string, channel: string, defaults?: Partial<UserInput>): Promise<User>;
41
+ list(filter?: {
42
+ role?: string;
43
+ org_id?: string;
44
+ }): Promise<User[]>;
45
+ update(id: string, changes: Partial<UserInput>): Promise<void>;
46
+ addIdentity(userId: string, channel: string, externalId: string, displayName?: string): Promise<void>;
47
+ }
@@ -0,0 +1,9 @@
1
+ import type { DataStore } from '../data/data-store.js';
2
+ export declare class WakeupQueue {
3
+ private db;
4
+ constructor(db: DataStore);
5
+ enqueue(agentId: string, source: string, context?: Record<string, unknown>): Promise<string>;
6
+ coalesce(agentId: string, context?: Record<string, unknown>): Promise<void>;
7
+ getNext(agentId: string): Promise<Record<string, unknown> | undefined>;
8
+ markFired(wakeupId: string, runId: string): Promise<void>;
9
+ }
@@ -0,0 +1,47 @@
1
+ import type { DataStore } from '../data/data-store.js';
2
+ import type { HookBus } from '../hooks/hook-bus.js';
3
+ import type { TaskQueue } from './task-queue.js';
4
+ export interface WorkflowStep {
5
+ id: string;
6
+ name: string;
7
+ agentSlug?: string;
8
+ taskTemplate: {
9
+ title: string;
10
+ description: string;
11
+ };
12
+ dependsOn?: string[];
13
+ onComplete?: 'next' | 'parallel' | 'end';
14
+ onFail?: 'abort' | 'skip' | 'retry';
15
+ }
16
+ export interface WorkflowDefinition {
17
+ name: string;
18
+ description?: string;
19
+ steps: WorkflowStep[];
20
+ trigger?: {
21
+ type: 'task_completed' | 'event' | 'schedule' | 'manual';
22
+ filter?: Record<string, unknown>;
23
+ };
24
+ }
25
+ export declare class WorkflowEngine {
26
+ private db;
27
+ private hooks;
28
+ private taskQueue;
29
+ constructor(db: DataStore, hooks: HookBus, taskQueue: TaskQueue);
30
+ /**
31
+ * Define/register a workflow.
32
+ */
33
+ define(slug: string, def: WorkflowDefinition): Promise<void>;
34
+ /**
35
+ * Start a workflow run.
36
+ */
37
+ start(workflowSlug: string, context: Record<string, unknown>): Promise<string>;
38
+ /**
39
+ * Called when a task with workflow_run_id completes.
40
+ */
41
+ onStepCompleted(taskId: string, output: string): Promise<void>;
42
+ /**
43
+ * Mark a workflow run as failed.
44
+ */
45
+ onStepFailed(taskId: string, error: string): Promise<void>;
46
+ private _createStepTask;
47
+ }
@@ -0,0 +1,20 @@
1
+ import type { HookBus } from '../hooks/hook-bus.js';
2
+ import type { AuditEvent } from './types.js';
3
+ interface AuditEmitterOptions {
4
+ auditTables?: string[];
5
+ }
6
+ /**
7
+ * Emits audit events via the HookBus for tracked tables.
8
+ *
9
+ * - auditTables defaults to [] (nothing audited)
10
+ * - '*' wildcard audits all tables
11
+ * - emit is fire-and-forget — errors are swallowed, no awaiting
12
+ */
13
+ export declare class AuditEmitter {
14
+ private readonly hooks;
15
+ private readonly auditTables;
16
+ constructor(hooks: HookBus, opts?: AuditEmitterOptions);
17
+ shouldAudit(table: string): boolean;
18
+ emit(event: AuditEvent): void;
19
+ }
20
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { DataStore } from '../data/data-store.js';
2
+ export interface ColumnValidator {
3
+ validateWrite(table: string, row: Record<string, unknown>): Record<string, unknown>;
4
+ validateRead(table: string, columns: string[]): void;
5
+ invalidateCache(table: string): void;
6
+ }
7
+ /**
8
+ * Validates column names against the live SQLite schema.
9
+ *
10
+ * - validateWrite: strips unknown columns silently
11
+ * - validateRead: throws on unknown columns
12
+ */
13
+ export declare class ColumnValidatorImpl implements ColumnValidator {
14
+ private readonly db;
15
+ constructor(db: DataStore);
16
+ private getValidColumns;
17
+ validateWrite(table: string, row: Record<string, unknown>): Record<string, unknown>;
18
+ validateRead(table: string, columns: string[]): void;
19
+ invalidateCache(_table: string): void;
20
+ }
@@ -0,0 +1,5 @@
1
+ export * from './types.js';
2
+ export * from './sanitizer.js';
3
+ export * from './column-validator.js';
4
+ export * from './audit.js';
5
+ export * from './process-env.js';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Build a clean environment for spawned subprocesses.
3
+ * Strips secrets and passes only safe system variables.
4
+ * Used by the CLI execution adapter when spawning agent processes.
5
+ */
6
+ /**
7
+ * Build a filtered environment for subprocess execution.
8
+ * Only passes explicitly allowed variables — all secrets are stripped.
9
+ *
10
+ * @param allowedKeys - Additional keys to allow beyond the defaults
11
+ * @param inject - Extra key-value pairs to inject into the env
12
+ */
13
+ export declare function buildProcessEnv(allowedKeys?: string[], inject?: Record<string, string>): Record<string, string>;
@@ -0,0 +1,11 @@
1
+ import type { SanitizerOptions } from './types.js';
2
+ /**
3
+ * Sanitizes a row object by:
4
+ * 1. Stripping null bytes from string values
5
+ * 2. Stripping control characters (preserving \n, \r, \t)
6
+ * 3. Truncating fields that exceed their byte length limit
7
+ *
8
+ * Non-string values pass through unchanged.
9
+ * Returns a new object — input is never mutated.
10
+ */
11
+ export declare function sanitize(row: Record<string, unknown>, opts?: SanitizerOptions): Record<string, unknown>;
@@ -0,0 +1,11 @@
1
+ export interface SanitizerOptions {
2
+ fieldLengthLimits?: Record<string, number>;
3
+ truncateSuffix?: string;
4
+ }
5
+ export interface AuditEvent {
6
+ table: string;
7
+ operation: 'insert' | 'update' | 'delete';
8
+ pk: unknown;
9
+ timestamp: number;
10
+ changedColumns?: string[];
11
+ }
@@ -0,0 +1,21 @@
1
+ interface UpdateResult {
2
+ updated: boolean;
3
+ packages: Array<{
4
+ name: string;
5
+ from: string;
6
+ to: string;
7
+ }>;
8
+ restartRequired: boolean;
9
+ }
10
+ /**
11
+ * Check npm for newer versions of framework packages and install them.
12
+ * Returns what was updated. Safe to call on every startup — skips if
13
+ * already on latest.
14
+ *
15
+ * @param packages - Package names to check (default: botinabox + latticesql)
16
+ * @param opts.quiet - Suppress console output (default: false)
17
+ */
18
+ export declare function autoUpdate(packages?: string[], opts?: {
19
+ quiet?: boolean;
20
+ }): Promise<UpdateResult>;
21
+ export {};
@@ -0,0 +1,7 @@
1
+ export declare class BackupManager {
2
+ private projectRoot;
3
+ constructor(projectRoot: string);
4
+ backup(): Promise<string>;
5
+ restore(backupPath: string): Promise<void>;
6
+ cleanup(backupPath: string): Promise<void>;
7
+ }
@@ -0,0 +1,8 @@
1
+ export type { PackageUpdate, UpdateManifest } from './types.js';
2
+ export { parseVersion, compareVersions, classifyUpdate } from './version-utils.js';
3
+ export { UpdateChecker } from './update-checker.js';
4
+ export { BackupManager } from './backup-manager.js';
5
+ export { UpdateManager } from './update-manager.js';
6
+ export { runPackageMigrations } from './migration-hooks.js';
7
+ export type { PackageMigration } from './migration-hooks.js';
8
+ export { autoUpdate } from './auto-update.js';
@@ -0,0 +1,11 @@
1
+ import type { DataStore } from '../data/data-store.js';
2
+ export interface PackageMigration {
3
+ version: string;
4
+ package: string;
5
+ sql: string;
6
+ }
7
+ /**
8
+ * Runs package migrations using the __lattice_migrations table for tracking.
9
+ * Each migration is keyed by "{package}:{version}" to ensure idempotency.
10
+ */
11
+ export declare function runPackageMigrations(db: DataStore, migrations: PackageMigration[]): Promise<void>;
@@ -0,0 +1,11 @@
1
+ export interface PackageUpdate {
2
+ name: string;
3
+ installedVersion: string;
4
+ latestVersion: string;
5
+ updateType: 'patch' | 'minor' | 'major';
6
+ }
7
+ export interface UpdateManifest {
8
+ checkedAt: string;
9
+ packages: PackageUpdate[];
10
+ hasUpdates: boolean;
11
+ }
@@ -0,0 +1,11 @@
1
+ import type { UpdateManifest } from './types.js';
2
+ export declare class UpdateChecker {
3
+ private nodeModulesPath;
4
+ private opts?;
5
+ private readonly fetchFn;
6
+ constructor(nodeModulesPath: string, opts?: {
7
+ fetch?: typeof globalThis.fetch;
8
+ } | undefined);
9
+ getInstalledPackages(): string[];
10
+ check(packageNames?: string[]): Promise<UpdateManifest>;
11
+ }
@@ -0,0 +1,25 @@
1
+ import type { DataStore } from '../data/data-store.js';
2
+ import type { HookBus } from '../hooks/hook-bus.js';
3
+ import type { PackageUpdate, UpdateManifest } from './types.js';
4
+ import { UpdateChecker } from './update-checker.js';
5
+ type UpdatePolicy = 'auto-all' | 'auto-compatible' | 'auto-patch' | 'notify' | 'manual';
6
+ export declare class UpdateManager {
7
+ private checker;
8
+ private db;
9
+ private hooks;
10
+ private opts?;
11
+ private backupManager;
12
+ constructor(checker: UpdateChecker, db: DataStore, hooks: HookBus, opts?: {
13
+ projectRoot?: string;
14
+ policy?: UpdatePolicy;
15
+ maintenanceWindow?: {
16
+ utcHourStart: number;
17
+ utcHourEnd: number;
18
+ };
19
+ } | undefined);
20
+ checkAndNotify(): Promise<UpdateManifest>;
21
+ applyUpdates(updates: PackageUpdate[]): Promise<void>;
22
+ isInMaintenanceWindow(): boolean;
23
+ filterByPolicy(updates: PackageUpdate[]): PackageUpdate[];
24
+ }
25
+ export {};
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Simple semver utilities — no external deps.
3
+ */
4
+ export declare function parseVersion(v: string): [number, number, number];
5
+ export declare function compareVersions(a: string, b: string): -1 | 0 | 1;
6
+ export declare function classifyUpdate(from: string, to: string): 'patch' | 'minor' | 'major' | 'none';