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
@@ -1,369 +1,10 @@
1
- import { C as ConnectorConfig, a as Connector, b as ConnectorMeta, A as AuthResult, S as SyncOptions, c as SyncResult, P as PushResult } from '../../connector-B4Mj0P1b.js';
2
-
3
- /** Google connector types. */
4
-
5
- interface GoogleOAuthConfig {
6
- clientId: string;
7
- clientSecret: string;
8
- redirectUri: string;
9
- }
10
- interface GoogleTokens {
11
- access_token: string;
12
- refresh_token?: string;
13
- expiry_date?: number;
14
- token_type: string;
15
- }
16
- interface GoogleServiceAccountConfig {
17
- /** Path to service account key JSON file */
18
- keyFile?: string;
19
- /** Inline service account credentials (alternative to keyFile) */
20
- credentials?: {
21
- client_email: string;
22
- private_key: string;
23
- project_id?: string;
24
- };
25
- /** Email of the user to impersonate via domain-wide delegation */
26
- subject: string;
27
- }
28
- interface GoogleConnectorConfig extends ConnectorConfig {
29
- /** Google account email */
30
- account: string;
31
- /** OAuth2 user auth (requires browser flow) */
32
- oauth?: GoogleOAuthConfig;
33
- /** Service account auth (headless, for cloud deployments) */
34
- serviceAccount?: GoogleServiceAccountConfig;
35
- scopes?: string[];
36
- }
37
- interface EmailAddress {
38
- name?: string;
39
- email: string;
40
- }
41
- interface EmailAttachment {
42
- /** The Gmail attachment ID — can be used with users.messages.attachments.get */
43
- attachmentId: string;
44
- filename: string;
45
- mimeType: string;
46
- /** Size in bytes as reported by Gmail */
47
- size: number;
48
- }
49
- interface EmailRecord {
50
- gmailId: string;
51
- threadId: string;
52
- account: string;
53
- subject: string;
54
- from: EmailAddress;
55
- to: EmailAddress[];
56
- cc: EmailAddress[];
57
- bcc: EmailAddress[];
58
- /** ISO 8601 timestamp */
59
- date: string;
60
- snippet: string;
61
- body?: string;
62
- labels: string[];
63
- isRead: boolean;
64
- attachments: EmailAttachment[];
65
- }
66
- interface DriveOwner {
67
- displayName: string;
68
- emailAddress: string;
69
- }
70
- interface DriveFileRecord {
71
- driveFileId: string;
72
- account: string;
73
- name: string;
74
- mimeType: string;
75
- webViewLink: string;
76
- webContentLink?: string;
77
- /** ISO 8601 */
78
- modifiedTime: string;
79
- /** ISO 8601 */
80
- createdTime: string;
81
- size?: number;
82
- parents?: string[];
83
- description?: string;
84
- owners: DriveOwner[];
85
- lastModifyingUser?: DriveOwner;
86
- starred: boolean;
87
- trashed: boolean;
88
- }
89
- interface CalendarAttendee {
90
- email: string;
91
- displayName?: string;
92
- responseStatus?: string;
93
- }
94
- interface CalendarEventRecord {
95
- googleEventId: string;
96
- calendarId: string;
97
- account: string;
98
- title: string;
99
- description?: string;
100
- location?: string;
101
- /** ISO 8601 timestamp */
102
- startAt: string;
103
- /** ISO 8601 timestamp */
104
- endAt: string;
105
- allDay: boolean;
106
- timezone?: string;
107
- status: string;
108
- organizerEmail: string;
109
- attendees: CalendarAttendee[];
110
- recurrence?: string[];
111
- htmlLink?: string;
112
- }
113
-
114
- /**
115
- * Google OAuth2 helpers.
116
- *
117
- * Uses dynamic `import('googleapis')` so the package is only required
118
- * at runtime by consumers who actually use the Google connectors.
119
- */
120
-
121
- type OAuth2Client = any;
122
- /**
123
- * Create a Google OAuth2 client from app credentials.
124
- */
125
- declare function createOAuth2Client(config: GoogleOAuthConfig): Promise<OAuth2Client>;
126
- /**
127
- * Generate the consent screen URL for the given scopes.
128
- */
129
- declare function getAuthUrl(client: OAuth2Client, scopes: string[]): string;
130
- /**
131
- * Exchange an authorization code for tokens.
132
- */
133
- declare function exchangeCode(client: OAuth2Client, code: string): Promise<GoogleTokens>;
134
- /**
135
- * Create an authenticated client using a service account with
136
- * domain-wide delegation (impersonation). No browser flow needed.
137
- */
138
- declare function createServiceAccountClient(config: GoogleServiceAccountConfig, scopes: string[]): Promise<OAuth2Client>;
139
- /**
140
- * Load persisted tokens via a generic getter callback.
141
- *
142
- * @param getter Reads a string value by key (e.g. SecretStore.get)
143
- * @param accountKey Unique key prefix for this account
144
- */
145
- declare function loadTokens(getter: (key: string) => Promise<string | null>, accountKey: string): Promise<GoogleTokens | null>;
146
- /**
147
- * Persist tokens via a generic setter callback.
148
- *
149
- * @param setter Writes a string value by key (e.g. SecretStore.set)
150
- * @param accountKey Unique key prefix for this account
151
- * @param tokens Tokens to persist
152
- */
153
- declare function saveTokens(setter: (key: string, value: string) => Promise<void>, accountKey: string, tokens: GoogleTokens): Promise<void>;
154
- /**
155
- * Refresh the access token if it has expired (or is about to within 60 s).
156
- *
157
- * If the token was refreshed and a `saver` callback is provided, the new
158
- * tokens are persisted automatically.
159
- */
160
- declare function refreshIfNeeded(client: OAuth2Client, tokens: GoogleTokens, saver?: (tokens: GoogleTokens) => Promise<void>): Promise<GoogleTokens>;
161
-
162
- /**
163
- * Gmail connector — pulls email metadata and optionally sends mail.
164
- *
165
- * Produces `EmailRecord` objects. Does NOT write to any database table;
166
- * the consuming application decides how to store records.
167
- */
168
-
169
- interface GmailConnectorOpts {
170
- /** Load persisted tokens for a given account key (OAuth2 flow only). */
171
- tokenLoader?: (key: string) => Promise<string | null>;
172
- /** Persist tokens for a given account key (OAuth2 flow only). */
173
- tokenSaver?: (key: string, value: string) => Promise<void>;
174
- }
175
- declare class GoogleGmailConnector implements Connector<EmailRecord> {
176
- readonly id = "google-gmail";
177
- readonly meta: ConnectorMeta;
178
- private tokenLoader?;
179
- private tokenSaver?;
180
- private client;
181
- private config;
182
- private tokens;
183
- private gmail;
184
- constructor(opts?: GmailConnectorOpts);
185
- connect(config: GoogleConnectorConfig): Promise<void>;
186
- disconnect(): Promise<void>;
187
- healthCheck(): Promise<{
188
- ok: boolean;
189
- account?: string;
190
- error?: string;
191
- }>;
192
- authenticate(codeProvider: (authUrl: string) => Promise<string>): Promise<AuthResult>;
193
- sync(options?: SyncOptions): Promise<SyncResult<EmailRecord>>;
194
- /** Incremental sync using Gmail history API. */
195
- private syncIncremental;
196
- /** Full sync — list messages and fetch each one. */
197
- private syncFull;
198
- push(payload: EmailRecord): Promise<PushResult>;
199
- private ensureConnected;
200
- /** Fetch a single message by ID and parse into an EmailRecord. */
201
- private fetchMessage;
202
- }
203
-
204
- /**
205
- * Google Calendar connector — pulls calendar events.
206
- *
207
- * Produces `CalendarEventRecord` objects. Does NOT write to any database
208
- * table; the consuming application decides how to store records.
209
- */
210
-
211
- interface CalendarConnectorOpts {
212
- /** Load persisted tokens for a given account key (OAuth2 flow only). */
213
- tokenLoader?: (key: string) => Promise<string | null>;
214
- /** Persist tokens for a given account key (OAuth2 flow only). */
215
- tokenSaver?: (key: string, value: string) => Promise<void>;
216
- }
217
- declare class GoogleCalendarConnector implements Connector<CalendarEventRecord> {
218
- readonly id = "google-calendar";
219
- readonly meta: ConnectorMeta;
220
- private tokenLoader?;
221
- private tokenSaver?;
222
- private client;
223
- private config;
224
- private tokens;
225
- private calendar;
226
- constructor(opts?: CalendarConnectorOpts);
227
- connect(config: GoogleConnectorConfig): Promise<void>;
228
- disconnect(): Promise<void>;
229
- healthCheck(): Promise<{
230
- ok: boolean;
231
- account?: string;
232
- error?: string;
233
- }>;
234
- authenticate(codeProvider: (authUrl: string) => Promise<string>): Promise<AuthResult>;
235
- sync(options?: SyncOptions): Promise<SyncResult<CalendarEventRecord>>;
236
- /** Incremental sync using Calendar syncToken. */
237
- private syncIncremental;
238
- /** Full sync using timeMin. */
239
- private syncFull;
240
- private ensureConnected;
241
- private mapEvent;
242
- }
243
-
244
- /**
245
- * Google Drive connector — pulls file metadata from Drive.
246
- *
247
- * Produces `DriveFileRecord` objects. Does NOT write to any database
248
- * table; the consuming application decides how to store records.
249
- *
250
- * Supports incremental sync via Drive Changes API (startPageToken)
251
- * and full sync via files.list with optional folder/MIME filters.
252
- */
253
-
254
- interface DriveConnectorOpts {
255
- /** Load persisted tokens for a given account key (OAuth2 flow only). */
256
- tokenLoader?: (key: string) => Promise<string | null>;
257
- /** Persist tokens for a given account key (OAuth2 flow only). */
258
- tokenSaver?: (key: string, value: string) => Promise<void>;
259
- }
260
- declare class GoogleDriveConnector implements Connector<DriveFileRecord> {
261
- readonly id = "google-drive";
262
- readonly meta: ConnectorMeta;
263
- private tokenLoader?;
264
- private tokenSaver?;
265
- private client;
266
- private config;
267
- private tokens;
268
- private drive;
269
- constructor(opts?: DriveConnectorOpts);
270
- connect(config: GoogleConnectorConfig): Promise<void>;
271
- disconnect(): Promise<void>;
272
- healthCheck(): Promise<{
273
- ok: boolean;
274
- account?: string;
275
- error?: string;
276
- }>;
277
- authenticate(codeProvider: (authUrl: string) => Promise<string>): Promise<AuthResult>;
278
- sync(options?: SyncOptions): Promise<SyncResult<DriveFileRecord>>;
279
- /** Incremental sync using Drive Changes API. */
280
- private syncIncremental;
281
- /** Full sync using files.list. */
282
- private syncFull;
283
- private ensureConnected;
284
- private mapFile;
285
- }
286
-
287
- /**
288
- * Google Drive file read primitives — download or export files to raw bytes.
289
- *
290
- * Signature-agnostic primitives that produce `{ buffer, mimeType, filename }`
291
- * tuples for use in attachment enrichment pipelines and other file consumers.
292
- */
293
- /**
294
- * Raw file bytes fetched from Google Drive, plus the metadata needed to
295
- * decide what to do with them (MIME type → extractor, filename → display).
296
- */
297
- interface DriveFileBytes {
298
- buffer: Buffer;
299
- mimeType: string;
300
- filename: string;
301
- /** Size in bytes as reported by the download response. */
302
- size: number;
303
- }
304
- /**
305
- * Supported export target formats for Google-native file types
306
- * (Docs, Sheets, Slides, Drawings).
307
- */
308
- type GoogleDocExportAs = 'docx' | 'xlsx' | 'pptx' | 'png' | 'pdf' | 'txt' | 'csv' | 'html';
309
- /**
310
- * Download a binary Drive file as raw bytes.
311
- *
312
- * Use this for files uploaded to Drive in their native format (pdf, docx,
313
- * xlsx, pptx, jpg, png, mp4, etc.) — anything where the Drive `mimeType`
314
- * is NOT `application/vnd.google-apps.*`.
315
- *
316
- * For Google-native formats (Docs, Sheets, Slides, Drawings) use
317
- * `exportGoogleDoc` instead — `files.get` with `alt: 'media'` fails on
318
- * those with `fileNotDownloadable`.
319
- *
320
- * @param drive - googleapis `drive_v3.Drive` instance (kept as `any` to avoid hard type import)
321
- * @param fileId - Drive file ID
322
- * @returns Promise resolving to `DriveFileBytes` with buffer, mimeType, filename, and size
323
- */
324
- declare function downloadDriveFile(drive: any, fileId: string): Promise<DriveFileBytes>;
325
- /**
326
- * Export a Google-native document to a downloadable format.
327
- *
328
- * The `exportAs` argument picks the target MIME type:
329
- * - docx → application/vnd.openxmlformats-officedocument.wordprocessingml.document
330
- * - xlsx → application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
331
- * - pptx → application/vnd.openxmlformats-officedocument.presentationml.presentation
332
- * - png → image/png
333
- * - pdf → application/pdf
334
- * - txt → text/plain
335
- * - csv → text/csv (only valid for spreadsheets)
336
- * - html → text/html
337
- *
338
- * Throws if the source file is not a Google-native type, or if the
339
- * requested export is not supported for that type (e.g., csv on a Doc).
340
- *
341
- * @param drive - googleapis `drive_v3.Drive` instance
342
- * @param fileId - Drive file ID
343
- * @param exportAs - Target export format
344
- * @returns Promise resolving to `DriveFileBytes` with exported content
345
- */
346
- declare function exportGoogleDoc(drive: any, fileId: string, exportAs: GoogleDocExportAs): Promise<DriveFileBytes>;
347
- /**
348
- * High-level dispatcher. Fetches file metadata, inspects the mimeType,
349
- * and picks `downloadDriveFile` (binary) or `exportGoogleDoc` (native)
350
- * automatically.
351
- *
352
- * Google-native → exported format mapping:
353
- * - Docs → docx
354
- * - Sheets → xlsx
355
- * - Slides → pptx
356
- * - Drawings → png
357
- * - Scripts → throws (not supported)
358
- * - Forms/Site → throws (not supported)
359
- *
360
- * Consumers that want a different export target (e.g., gdoc → pdf for
361
- * Claude's native PDF reading) should call `exportGoogleDoc` directly.
362
- *
363
- * @param drive - googleapis `drive_v3.Drive` instance
364
- * @param fileId - Drive file ID
365
- * @returns Promise resolving to `DriveFileBytes` with automatically chosen format
366
- */
367
- declare function readDriveFile(drive: any, fileId: string): Promise<DriveFileBytes>;
368
-
369
- export { type CalendarAttendee, type CalendarConnectorOpts, type CalendarEventRecord, type DriveConnectorOpts, type DriveFileBytes, type DriveFileRecord, type DriveOwner, type EmailAddress, type EmailAttachment, type EmailRecord, type GmailConnectorOpts, GoogleCalendarConnector, type GoogleConnectorConfig, type GoogleDocExportAs, GoogleDriveConnector, GoogleGmailConnector, type GoogleOAuthConfig, type GoogleServiceAccountConfig, type GoogleTokens, createOAuth2Client, createServiceAccountClient, downloadDriveFile, exchangeCode, exportGoogleDoc, getAuthUrl, loadTokens, readDriveFile, refreshIfNeeded, saveTokens };
1
+ /** Google connectors Gmail, Calendar, and Drive. */
2
+ export * from './types.js';
3
+ export * from './oauth.js';
4
+ export { GoogleGmailConnector } from './gmail-connector.js';
5
+ export type { GmailConnectorOpts } from './gmail-connector.js';
6
+ export { GoogleCalendarConnector } from './calendar-connector.js';
7
+ export type { CalendarConnectorOpts } from './calendar-connector.js';
8
+ export { GoogleDriveConnector } from './drive-connector.js';
9
+ export type { DriveConnectorOpts } from './drive-connector.js';
10
+ export { downloadDriveFile, exportGoogleDoc, readDriveFile, type DriveFileBytes, type GoogleDocExportAs, } from './drive-read.js';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Google OAuth2 helpers.
3
+ *
4
+ * Uses dynamic `import('googleapis')` so the package is only required
5
+ * at runtime by consumers who actually use the Google connectors.
6
+ */
7
+ import type { GoogleOAuthConfig, GoogleServiceAccountConfig, GoogleTokens } from './types.js';
8
+ type OAuth2Client = any;
9
+ /**
10
+ * Create a Google OAuth2 client from app credentials.
11
+ */
12
+ export declare function createOAuth2Client(config: GoogleOAuthConfig): Promise<OAuth2Client>;
13
+ /**
14
+ * Generate the consent screen URL for the given scopes.
15
+ */
16
+ export declare function getAuthUrl(client: OAuth2Client, scopes: string[]): string;
17
+ /**
18
+ * Exchange an authorization code for tokens.
19
+ */
20
+ export declare function exchangeCode(client: OAuth2Client, code: string): Promise<GoogleTokens>;
21
+ /**
22
+ * Create an authenticated client using a service account with
23
+ * domain-wide delegation (impersonation). No browser flow needed.
24
+ */
25
+ export declare function createServiceAccountClient(config: GoogleServiceAccountConfig, scopes: string[]): Promise<OAuth2Client>;
26
+ /**
27
+ * Load persisted tokens via a generic getter callback.
28
+ *
29
+ * @param getter Reads a string value by key (e.g. SecretStore.get)
30
+ * @param accountKey Unique key prefix for this account
31
+ */
32
+ export declare function loadTokens(getter: (key: string) => Promise<string | null>, accountKey: string): Promise<GoogleTokens | null>;
33
+ /**
34
+ * Persist tokens via a generic setter callback.
35
+ *
36
+ * @param setter Writes a string value by key (e.g. SecretStore.set)
37
+ * @param accountKey Unique key prefix for this account
38
+ * @param tokens Tokens to persist
39
+ */
40
+ export declare function saveTokens(setter: (key: string, value: string) => Promise<void>, accountKey: string, tokens: GoogleTokens): Promise<void>;
41
+ /**
42
+ * Refresh the access token if it has expired (or is about to within 60 s).
43
+ *
44
+ * If the token was refreshed and a `saver` callback is provided, the new
45
+ * tokens are persisted automatically.
46
+ */
47
+ export declare function refreshIfNeeded(client: OAuth2Client, tokens: GoogleTokens, saver?: (tokens: GoogleTokens) => Promise<void>): Promise<GoogleTokens>;
48
+ export {};
@@ -0,0 +1,110 @@
1
+ /** Google connector types. */
2
+ import type { ConnectorConfig } from '../../shared/types/connector.js';
3
+ export interface GoogleOAuthConfig {
4
+ clientId: string;
5
+ clientSecret: string;
6
+ redirectUri: string;
7
+ }
8
+ export interface GoogleTokens {
9
+ access_token: string;
10
+ refresh_token?: string;
11
+ expiry_date?: number;
12
+ token_type: string;
13
+ }
14
+ export interface GoogleServiceAccountConfig {
15
+ /** Path to service account key JSON file */
16
+ keyFile?: string;
17
+ /** Inline service account credentials (alternative to keyFile) */
18
+ credentials?: {
19
+ client_email: string;
20
+ private_key: string;
21
+ project_id?: string;
22
+ };
23
+ /** Email of the user to impersonate via domain-wide delegation */
24
+ subject: string;
25
+ }
26
+ export interface GoogleConnectorConfig extends ConnectorConfig {
27
+ /** Google account email */
28
+ account: string;
29
+ /** OAuth2 user auth (requires browser flow) */
30
+ oauth?: GoogleOAuthConfig;
31
+ /** Service account auth (headless, for cloud deployments) */
32
+ serviceAccount?: GoogleServiceAccountConfig;
33
+ scopes?: string[];
34
+ }
35
+ export interface EmailAddress {
36
+ name?: string;
37
+ email: string;
38
+ }
39
+ export interface EmailAttachment {
40
+ /** The Gmail attachment ID — can be used with users.messages.attachments.get */
41
+ attachmentId: string;
42
+ filename: string;
43
+ mimeType: string;
44
+ /** Size in bytes as reported by Gmail */
45
+ size: number;
46
+ }
47
+ export interface EmailRecord {
48
+ gmailId: string;
49
+ threadId: string;
50
+ account: string;
51
+ subject: string;
52
+ from: EmailAddress;
53
+ to: EmailAddress[];
54
+ cc: EmailAddress[];
55
+ bcc: EmailAddress[];
56
+ /** ISO 8601 timestamp */
57
+ date: string;
58
+ snippet: string;
59
+ body?: string;
60
+ labels: string[];
61
+ isRead: boolean;
62
+ attachments: EmailAttachment[];
63
+ }
64
+ export interface DriveOwner {
65
+ displayName: string;
66
+ emailAddress: string;
67
+ }
68
+ export interface DriveFileRecord {
69
+ driveFileId: string;
70
+ account: string;
71
+ name: string;
72
+ mimeType: string;
73
+ webViewLink: string;
74
+ webContentLink?: string;
75
+ /** ISO 8601 */
76
+ modifiedTime: string;
77
+ /** ISO 8601 */
78
+ createdTime: string;
79
+ size?: number;
80
+ parents?: string[];
81
+ description?: string;
82
+ owners: DriveOwner[];
83
+ lastModifyingUser?: DriveOwner;
84
+ starred: boolean;
85
+ trashed: boolean;
86
+ }
87
+ export interface CalendarAttendee {
88
+ email: string;
89
+ displayName?: string;
90
+ responseStatus?: string;
91
+ }
92
+ export interface CalendarEventRecord {
93
+ googleEventId: string;
94
+ calendarId: string;
95
+ account: string;
96
+ title: string;
97
+ description?: string;
98
+ location?: string;
99
+ /** ISO 8601 timestamp */
100
+ startAt: string;
101
+ /** ISO 8601 timestamp */
102
+ endAt: string;
103
+ allDay: boolean;
104
+ timezone?: string;
105
+ status: string;
106
+ organizerEmail: string;
107
+ attendees: CalendarAttendee[];
108
+ recurrence?: string[];
109
+ htmlLink?: string;
110
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Auto-discovery for channel adapters.
3
+ * Scans @botinabox/* packages for botinabox.type === 'channel'.
4
+ * Story 4.1
5
+ */
6
+ import type { ChannelAdapter } from "./types.js";
7
+ type Importer = (packageName: string) => Promise<unknown>;
8
+ /**
9
+ * Scans nodeModulesPath/@botinabox/{pkg}/package.json for each package in the scope.
10
+ * If pkg.botinabox?.type === 'channel', dynamically imports the package
11
+ * and returns the discovered ChannelAdapter instances.
12
+ *
13
+ * The optional importer parameter allows injection for testing.
14
+ */
15
+ export declare function discoverChannels(nodeModulesPath: string, importer?: Importer): Promise<ChannelAdapter[]>;
16
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * ChannelRegistry — manages channel adapter lifecycle.
3
+ * Story 4.1
4
+ */
5
+ import type { ChannelAdapter, HealthStatus } from "./types.js";
6
+ export declare class ChannelRegistryError extends Error {
7
+ constructor(message: string);
8
+ }
9
+ export declare class ChannelRegistry {
10
+ private readonly adapters;
11
+ private started;
12
+ /**
13
+ * Register a channel adapter.
14
+ * Throws if an adapter with the same id is already registered.
15
+ * If registry is already started, immediately connects the adapter.
16
+ */
17
+ register(adapter: ChannelAdapter, config?: unknown): void;
18
+ /**
19
+ * Unregister a channel adapter.
20
+ * Disconnects the adapter if it exists.
21
+ */
22
+ unregister(id: string): Promise<void>;
23
+ /**
24
+ * Reconfigure an adapter: disconnect, update config, reconnect.
25
+ */
26
+ reconfigure(id: string, config: unknown): Promise<void>;
27
+ /**
28
+ * Run health checks on all registered adapters.
29
+ */
30
+ healthCheck(): Promise<Record<string, HealthStatus>>;
31
+ /** Check if an adapter is registered. */
32
+ has(id: string): boolean;
33
+ /** Get an adapter by ID. */
34
+ get(id: string): ChannelAdapter | undefined;
35
+ /** List all registered adapters. */
36
+ list(): ChannelAdapter[];
37
+ /**
38
+ * Start: connect all registered adapters and mark registry as started.
39
+ */
40
+ start(): Promise<void>;
41
+ /**
42
+ * Stop: disconnect all registered adapters.
43
+ */
44
+ stop(): Promise<void>;
45
+ }