botinabox 0.5.6 → 0.6.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.
@@ -0,0 +1,328 @@
1
+ // src/connectors/google/oauth.ts
2
+ var _google;
3
+ async function getGoogle() {
4
+ if (!_google) {
5
+ try {
6
+ const mod = await import("googleapis");
7
+ _google = mod.google;
8
+ } catch {
9
+ throw new Error(
10
+ "googleapis is required for Google connectors. Install it: npm install googleapis"
11
+ );
12
+ }
13
+ }
14
+ return _google;
15
+ }
16
+ async function createOAuth2Client(config) {
17
+ const google = await getGoogle();
18
+ return new google.auth.OAuth2(
19
+ config.clientId,
20
+ config.clientSecret,
21
+ config.redirectUri
22
+ );
23
+ }
24
+ function getAuthUrl(client, scopes) {
25
+ return client.generateAuthUrl({
26
+ access_type: "offline",
27
+ prompt: "consent",
28
+ scope: scopes
29
+ });
30
+ }
31
+ async function exchangeCode(client, code) {
32
+ const { tokens } = await client.getToken(code);
33
+ return tokens;
34
+ }
35
+ async function loadTokens(getter, accountKey) {
36
+ const raw = await getter(`google_tokens:${accountKey}`);
37
+ if (!raw) return null;
38
+ try {
39
+ return JSON.parse(raw);
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+ async function saveTokens(setter, accountKey, tokens) {
45
+ await setter(`google_tokens:${accountKey}`, JSON.stringify(tokens));
46
+ }
47
+ async function refreshIfNeeded(client, tokens, saver) {
48
+ const buffer = 6e4;
49
+ const isExpired = tokens.expiry_date != null && Date.now() >= tokens.expiry_date - buffer;
50
+ if (!isExpired) return tokens;
51
+ client.setCredentials(tokens);
52
+ const { credentials } = await client.refreshAccessToken();
53
+ const refreshed = {
54
+ access_token: credentials.access_token,
55
+ refresh_token: credentials.refresh_token ?? tokens.refresh_token,
56
+ expiry_date: credentials.expiry_date ?? void 0,
57
+ token_type: credentials.token_type ?? "Bearer"
58
+ };
59
+ if (saver) {
60
+ await saver(refreshed);
61
+ }
62
+ return refreshed;
63
+ }
64
+
65
+ // src/connectors/google/gmail-connector.ts
66
+ var GoogleGmailConnector = class {
67
+ id = "google-gmail";
68
+ meta = {
69
+ displayName: "Google Gmail",
70
+ provider: "google",
71
+ dataType: "email"
72
+ };
73
+ tokenLoader;
74
+ tokenSaver;
75
+ client = null;
76
+ config = null;
77
+ tokens = null;
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ gmail = null;
80
+ constructor(opts) {
81
+ this.tokenLoader = opts.tokenLoader;
82
+ this.tokenSaver = opts.tokenSaver;
83
+ }
84
+ // ── Lifecycle ──────────────────────────────────────────────────
85
+ async connect(config) {
86
+ this.config = config;
87
+ this.client = await createOAuth2Client(config.oauth);
88
+ this.tokens = await loadTokens(this.tokenLoader, config.account);
89
+ if (!this.tokens) {
90
+ throw new Error(
91
+ `No stored tokens for account ${config.account}. Complete the OAuth flow first.`
92
+ );
93
+ }
94
+ this.tokens = await refreshIfNeeded(
95
+ this.client,
96
+ this.tokens,
97
+ async (t) => saveTokens(this.tokenSaver, config.account, t)
98
+ );
99
+ this.client.setCredentials(this.tokens);
100
+ const { google } = await import("googleapis");
101
+ this.gmail = google.gmail({ version: "v1", auth: this.client });
102
+ }
103
+ async disconnect() {
104
+ this.client = null;
105
+ this.gmail = null;
106
+ this.tokens = null;
107
+ this.config = null;
108
+ }
109
+ async healthCheck() {
110
+ try {
111
+ this.ensureConnected();
112
+ const res = await this.gmail.users.getProfile({ userId: "me" });
113
+ return { ok: true, account: res.data.emailAddress };
114
+ } catch (err) {
115
+ return { ok: false, error: errorMessage(err) };
116
+ }
117
+ }
118
+ // ── Auth ───────────────────────────────────────────────────────
119
+ async authenticate(codeProvider) {
120
+ if (!this.config) {
121
+ return { success: false, error: "Call connect() first to set config, or pass config and call authenticate() before connect()." };
122
+ }
123
+ try {
124
+ const client = await createOAuth2Client(this.config.oauth);
125
+ const scopes = this.config.scopes ?? [
126
+ "https://www.googleapis.com/auth/gmail.readonly",
127
+ "https://www.googleapis.com/auth/gmail.send"
128
+ ];
129
+ const authUrl = getAuthUrl(client, scopes);
130
+ const code = await codeProvider(authUrl);
131
+ const tokens = await exchangeCode(client, code);
132
+ await saveTokens(this.tokenSaver, this.config.account, tokens);
133
+ this.tokens = tokens;
134
+ this.client = client;
135
+ this.client.setCredentials(tokens);
136
+ const { google } = await import("googleapis");
137
+ this.gmail = google.gmail({ version: "v1", auth: this.client });
138
+ return { success: true, account: this.config.account };
139
+ } catch (err) {
140
+ return { success: false, error: errorMessage(err) };
141
+ }
142
+ }
143
+ // ── Sync ───────────────────────────────────────────────────────
144
+ async sync(options) {
145
+ this.ensureConnected();
146
+ if (options?.cursor) {
147
+ return this.syncIncremental(options.cursor, options.limit);
148
+ }
149
+ return this.syncFull(options);
150
+ }
151
+ /** Incremental sync using Gmail history API. */
152
+ async syncIncremental(startHistoryId, limit) {
153
+ const records = [];
154
+ const errors = [];
155
+ const seenIds = /* @__PURE__ */ new Set();
156
+ let pageToken;
157
+ let latestHistoryId = startHistoryId;
158
+ do {
159
+ const res = await this.gmail.users.history.list({
160
+ userId: "me",
161
+ startHistoryId,
162
+ historyTypes: ["messageAdded"],
163
+ ...pageToken ? { pageToken } : {}
164
+ });
165
+ latestHistoryId = res.data.historyId ?? latestHistoryId;
166
+ const histories = res.data.history ?? [];
167
+ for (const h of histories) {
168
+ for (const added of h.messagesAdded ?? []) {
169
+ const msgId = added.message?.id;
170
+ if (!msgId || seenIds.has(msgId)) continue;
171
+ seenIds.add(msgId);
172
+ try {
173
+ const record = await this.fetchMessage(msgId);
174
+ records.push(record);
175
+ } catch (err) {
176
+ errors.push({ id: msgId, error: errorMessage(err) });
177
+ }
178
+ if (limit && records.length >= limit) {
179
+ return { records, cursor: latestHistoryId, hasMore: true, errors };
180
+ }
181
+ }
182
+ }
183
+ pageToken = res.data.nextPageToken ?? void 0;
184
+ } while (pageToken);
185
+ return { records, cursor: latestHistoryId, hasMore: false, errors };
186
+ }
187
+ /** Full sync — list messages and fetch each one. */
188
+ async syncFull(options) {
189
+ const records = [];
190
+ const errors = [];
191
+ const maxResults = options?.limit ?? 100;
192
+ let query = "";
193
+ if (options?.since) {
194
+ const epoch = Math.floor(new Date(options.since).getTime() / 1e3);
195
+ query = `after:${epoch}`;
196
+ }
197
+ if (options?.filters?.q) {
198
+ query = query ? `${query} ${options.filters.q}` : String(options.filters.q);
199
+ }
200
+ let pageToken;
201
+ let collected = 0;
202
+ do {
203
+ const res = await this.gmail.users.messages.list({
204
+ userId: "me",
205
+ maxResults: Math.min(maxResults - collected, 100),
206
+ ...query ? { q: query } : {},
207
+ ...pageToken ? { pageToken } : {}
208
+ });
209
+ const messages = res.data.messages ?? [];
210
+ for (const msg of messages) {
211
+ try {
212
+ const record = await this.fetchMessage(msg.id);
213
+ records.push(record);
214
+ } catch (err) {
215
+ errors.push({ id: msg.id, error: errorMessage(err) });
216
+ }
217
+ collected++;
218
+ if (collected >= maxResults) break;
219
+ }
220
+ pageToken = res.data.nextPageToken ?? void 0;
221
+ } while (pageToken && collected < maxResults);
222
+ const profile = await this.gmail.users.getProfile({ userId: "me" });
223
+ const cursor = profile.data.historyId ?? void 0;
224
+ return {
225
+ records,
226
+ cursor,
227
+ hasMore: !!pageToken,
228
+ errors
229
+ };
230
+ }
231
+ // ── Push (send email) ─────────────────────────────────────────
232
+ async push(payload) {
233
+ this.ensureConnected();
234
+ try {
235
+ const toHeader = payload.to.map(formatAddress).join(", ");
236
+ const ccHeader = payload.cc.length ? `Cc: ${payload.cc.map(formatAddress).join(", ")}\r
237
+ ` : "";
238
+ const bccHeader = payload.bcc.length ? `Bcc: ${payload.bcc.map(formatAddress).join(", ")}\r
239
+ ` : "";
240
+ const mime = [
241
+ `To: ${toHeader}\r
242
+ `,
243
+ ccHeader,
244
+ bccHeader,
245
+ `Subject: ${payload.subject}\r
246
+ `,
247
+ `Content-Type: text/plain; charset="UTF-8"\r
248
+ `,
249
+ `\r
250
+ `,
251
+ payload.body ?? ""
252
+ ].join("");
253
+ const encoded = Buffer.from(mime).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
254
+ const res = await this.gmail.users.messages.send({
255
+ userId: "me",
256
+ requestBody: { raw: encoded }
257
+ });
258
+ return { success: true, externalId: res.data.id };
259
+ } catch (err) {
260
+ return { success: false, error: errorMessage(err) };
261
+ }
262
+ }
263
+ // ── Internals ─────────────────────────────────────────────────
264
+ ensureConnected() {
265
+ if (!this.gmail || !this.config) {
266
+ throw new Error("GoogleGmailConnector is not connected. Call connect() first.");
267
+ }
268
+ }
269
+ /** Fetch a single message by ID and parse into an EmailRecord. */
270
+ async fetchMessage(messageId) {
271
+ const res = await this.gmail.users.messages.get({
272
+ userId: "me",
273
+ id: messageId,
274
+ format: "metadata",
275
+ metadataHeaders: ["From", "To", "Cc", "Bcc", "Subject", "Date"]
276
+ });
277
+ const msg = res.data;
278
+ const headers = msg.payload?.headers ?? [];
279
+ const getHeader = (name) => headers.find((h) => h.name.toLowerCase() === name.toLowerCase())?.value ?? "";
280
+ return {
281
+ gmailId: msg.id,
282
+ threadId: msg.threadId,
283
+ account: this.config.account,
284
+ subject: getHeader("Subject"),
285
+ from: parseAddress(getHeader("From")),
286
+ to: parseAddressList(getHeader("To")),
287
+ cc: parseAddressList(getHeader("Cc")),
288
+ bcc: parseAddressList(getHeader("Bcc")),
289
+ date: new Date(getHeader("Date")).toISOString(),
290
+ snippet: msg.snippet ?? "",
291
+ labels: msg.labelIds ?? [],
292
+ isRead: !(msg.labelIds ?? []).includes("UNREAD")
293
+ };
294
+ }
295
+ };
296
+ function parseAddress(raw) {
297
+ const match = raw.match(/^(.+?)\s*<([^>]+)>$/);
298
+ if (match) {
299
+ return { name: match[1].replace(/^["']|["']$/g, "").trim(), email: match[2] };
300
+ }
301
+ return { email: raw.trim() };
302
+ }
303
+ function parseAddressList(raw) {
304
+ if (!raw.trim()) return [];
305
+ const results = [];
306
+ const parts = raw.split(/,(?=(?:[^<]*<[^>]*>)*[^>]*$)/);
307
+ for (const part of parts) {
308
+ const trimmed = part.trim();
309
+ if (trimmed) results.push(parseAddress(trimmed));
310
+ }
311
+ return results;
312
+ }
313
+ function formatAddress(addr) {
314
+ return addr.name ? `${addr.name} <${addr.email}>` : addr.email;
315
+ }
316
+ function errorMessage(err) {
317
+ return err instanceof Error ? err.message : String(err);
318
+ }
319
+
320
+ export {
321
+ createOAuth2Client,
322
+ getAuthUrl,
323
+ exchangeCode,
324
+ loadTokens,
325
+ saveTokens,
326
+ refreshIfNeeded,
327
+ GoogleGmailConnector
328
+ };
@@ -0,0 +1,63 @@
1
+ /** Connector types — generic external service integrations. */
2
+ 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
+ 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
+ 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
+ interface PushResult {
33
+ success: boolean;
34
+ externalId?: string;
35
+ error?: string;
36
+ }
37
+ type ConnectorConfig = Record<string, unknown>;
38
+ /**
39
+ * Generic connector interface for external service integrations.
40
+ *
41
+ * Connectors pull and optionally push data to/from external services
42
+ * (Gmail, Calendar, Trello, Jira, Salesforce, etc.). They produce
43
+ * typed records — the consuming application decides where to store them.
44
+ *
45
+ * @typeParam T - The record type this connector produces/consumes.
46
+ */
47
+ interface Connector<T = Record<string, unknown>> {
48
+ readonly id: string;
49
+ readonly meta: ConnectorMeta;
50
+ connect(config: ConnectorConfig): Promise<void>;
51
+ disconnect(): Promise<void>;
52
+ healthCheck(): Promise<{
53
+ ok: boolean;
54
+ account?: string;
55
+ error?: string;
56
+ }>;
57
+ /** Pull records from external source */
58
+ sync(options?: SyncOptions): Promise<SyncResult<T>>;
59
+ /** Push a record to external source (optional) */
60
+ push?(payload: T): Promise<PushResult>;
61
+ }
62
+
63
+ export type { ConnectorConfig as C, PushResult as P, SyncOptions as S, Connector as a, ConnectorMeta as b, SyncResult as c };
@@ -0,0 +1,6 @@
1
+ import {
2
+ GoogleGmailConnector
3
+ } from "./chunk-DSNJKNEW.js";
4
+ export {
5
+ GoogleGmailConnector
6
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ GoogleGmailConnector
3
+ } from "./chunk-3X3YKI4T.js";
4
+ export {
5
+ GoogleGmailConnector
6
+ };
@@ -0,0 +1,6 @@
1
+ import {
2
+ GoogleGmailConnector
3
+ } from "./chunk-D47AIFOD.js";
4
+ export {
5
+ GoogleGmailConnector
6
+ };
package/dist/index.d.ts CHANGED
@@ -305,7 +305,6 @@ declare const EVENTS: {
305
305
  declare const DEFAULTS: {
306
306
  readonly TASK_POLL_INTERVAL_MS: 30000;
307
307
  readonly NOTIFICATION_POLL_INTERVAL_MS: 5000;
308
- readonly HEARTBEAT_INTERVAL_MS: 300000;
309
308
  readonly ORPHAN_REAP_INTERVAL_MS: 300000;
310
309
  readonly STALE_RUN_THRESHOLD_MS: 1800000;
311
310
  readonly STALE_TASK_AGE_MS: 7200000;
@@ -1320,23 +1319,6 @@ declare class NdjsonLogger {
1320
1319
  close(): void;
1321
1320
  }
1322
1321
 
1323
- /**
1324
- * @deprecated Use {@link Scheduler} from `botinabox` instead.
1325
- * HeartbeatScheduler uses in-memory setInterval which loses state on restart.
1326
- * The Scheduler class uses database-backed schedules with cron expressions.
1327
- */
1328
- declare class HeartbeatScheduler {
1329
- private wakeupQueue;
1330
- private hooks;
1331
- private timers;
1332
- constructor(wakeupQueue: WakeupQueue, hooks: HookBus);
1333
- start(agents: Array<{
1334
- id: string;
1335
- heartbeat_config: string;
1336
- }>): void;
1337
- stop(): void;
1338
- }
1339
-
1340
1322
  /**
1341
1323
  * Scheduler — database-backed job scheduling with cron expressions.
1342
1324
  *
@@ -1344,7 +1326,7 @@ declare class HeartbeatScheduler {
1344
1326
  * it emits the schedule's `action` as a hook event with the
1345
1327
  * `action_config` payload. Consumers subscribe to handle the action.
1346
1328
  *
1347
- * Replaces HeartbeatScheduler for recurring use cases.
1329
+ * Supports one-time and recurring use cases.
1348
1330
  */
1349
1331
 
1350
1332
  interface ScheduleDef {
@@ -1567,4 +1549,4 @@ declare function isLoginRequired(stdout: string): boolean;
1567
1549
  /** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
1568
1550
  declare function deactivateLocalImagePaths(prompt: string): string;
1569
1551
 
1570
- export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, ChatMessage, ChatSessionManager, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, DataStoreError, type DomainEntityContextOptions, type DomainSchemaOptions, EVENTS, type EntityColumnDef, type EntityConfig, type EntityContextDef, type EntityFileSpec, type EntitySource, type ExecutionAdapter, type Filter, HealthStatus, HeartbeatScheduler, HookBus, type HookHandler, type HookOptions, type HookRegistration, InboundMessage, LLMProvider, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PkLookup, ProviderRegistry, type QueryOptions, RUN_STATUSES, type RelationDef, type RenderConfig, ResolvedModel, type RetryPolicy, type Row, type RunContext, RunManager, type RunResult, type RunStatus, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, type SeedItem, SessionKey, SessionManager, type SqliteAdapter, type StepRef, TASK_STATUSES, type TableDefinition, type TableInfoRow, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type Unsubscribe, 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, buildAgentBindings, buildChainOrigin, buildProcessEnv, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, loadConfig, parseClaudeStream, parseVersion, runPackageMigrations, sanitize, topologicalSort, validateConfig };
1552
+ export { AGENT_STATUSES, type AgentConfig, type AgentDefinition, type AgentFilter, type AgentRecord, AgentRegistry, type AgentStatus, ApiExecutionAdapter, AuditEmitter, type AuditEvent, BackupManager, type BotConfig, type BudgetCheck, type BudgetConfig, BudgetController, CORE_MIGRATIONS, ChannelAdapter, ChannelRegistry, ChannelRegistryError, ChatMessage, ChatSessionManager, CliExecutionAdapter, type ColumnValidator, ColumnValidatorImpl, type ConfigLoadError, type ConfigLoadResult, ConnectorConfig, DEFAULTS, DEFAULT_CONFIG, type DataConfig, DataStore, DataStoreError, type DomainEntityContextOptions, type DomainSchemaOptions, EVENTS, type EntityColumnDef, type EntityConfig, type EntityContextDef, type EntityFileSpec, type EntitySource, type ExecutionAdapter, type Filter, HealthStatus, HookBus, type HookHandler, type HookOptions, type HookRegistration, InboundMessage, LLMProvider, MAX_CHAIN_DEPTH, MessagePipeline, type ModelConfig, ModelInfo, ModelRouter, NdjsonLogger, NotificationQueue, type PackageMigration, type PackageUpdate, type ParsedStream, type PkLookup, ProviderRegistry, type QueryOptions, RUN_STATUSES, type RelationDef, type RenderConfig, ResolvedModel, type RetryPolicy, type Row, type RunContext, RunManager, type RunResult, type RunStatus, type SanitizerOptions, type Schedule, type ScheduleDef, Scheduler, type SchemaError, type SecretInput, type SecretMeta, SecretStore, type SecurityConfig, type SeedItem, SessionKey, SessionManager, type SqliteAdapter, type StepRef, TASK_STATUSES, type TableDefinition, type TableInfoRow, type TaskDefinition, TaskQueue, type TaskRecord, type TaskStatus, TokenUsage, type Unsubscribe, 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, buildAgentBindings, buildChainOrigin, buildProcessEnv, checkAllowlist, checkChainDepth, checkMentionGate, chunkText, classifyUpdate, compareVersions, createConfigRevision, deactivateLocalImagePaths, defineCoreEntityContexts, defineCoreTables, defineDomainEntityContexts, defineDomainTables, detectCycle, discoverChannels, discoverProviders, formatText, getConfig, initConfig, interpolate, interpolateEnv, isLoginRequired, isMaxTurns, loadConfig, parseClaudeStream, parseVersion, runPackageMigrations, sanitize, topologicalSort, validateConfig };
package/dist/index.js CHANGED
@@ -35,8 +35,6 @@ var EVENTS = {
35
35
  var DEFAULTS = {
36
36
  TASK_POLL_INTERVAL_MS: 3e4,
37
37
  NOTIFICATION_POLL_INTERVAL_MS: 5e3,
38
- HEARTBEAT_INTERVAL_MS: 3e5,
39
- // 5 minutes
40
38
  ORPHAN_REAP_INTERVAL_MS: 3e5,
41
39
  // 5 minutes
42
40
  STALE_RUN_THRESHOLD_MS: 18e5,
@@ -1155,15 +1153,17 @@ var DataStore = class {
1155
1153
  outputFile: def.indexFile,
1156
1154
  render: def.indexRender ?? ((rows) => {
1157
1155
  const active = rows.filter((r) => r.deleted_at == null);
1158
- const title = def.directory.charAt(0).toUpperCase() + def.directory.slice(1);
1156
+ const dir = def.directory;
1157
+ const title = dir.charAt(0).toUpperCase() + dir.slice(1);
1159
1158
  if (!active.length) return `# ${title}
1160
1159
 
1161
1160
  None.
1162
1161
  `;
1163
1162
  const lines = active.map((r) => {
1164
- const name2 = String(r.name ?? r[def.slugColumn] ?? r.id ?? "unknown");
1163
+ const slug = String(r[def.slugColumn] ?? r.name ?? r.id ?? "unknown");
1164
+ const name2 = String(r.name ?? slug);
1165
1165
  const status = r.status ? ` (${r.status})` : "";
1166
- return `- **${name2}**${status}`;
1166
+ return `- [${name2}](${dir}/${slug}/)${status}`;
1167
1167
  });
1168
1168
  return `# ${title}
1169
1169
 
@@ -3406,38 +3406,6 @@ var NdjsonLogger = class {
3406
3406
  }
3407
3407
  };
3408
3408
 
3409
- // src/core/orchestrator/heartbeat-scheduler.ts
3410
- var HeartbeatScheduler = class {
3411
- constructor(wakeupQueue, hooks) {
3412
- this.wakeupQueue = wakeupQueue;
3413
- this.hooks = hooks;
3414
- }
3415
- wakeupQueue;
3416
- hooks;
3417
- timers = /* @__PURE__ */ new Map();
3418
- start(agents) {
3419
- for (const agent of agents) {
3420
- let config;
3421
- try {
3422
- config = JSON.parse(agent.heartbeat_config);
3423
- } catch {
3424
- continue;
3425
- }
3426
- if (!config.enabled || !config.intervalSec) continue;
3427
- const timer = setInterval(() => {
3428
- void this.wakeupQueue.enqueue(agent.id, "heartbeat");
3429
- }, config.intervalSec * 1e3);
3430
- this.timers.set(agent.id, timer);
3431
- }
3432
- }
3433
- stop() {
3434
- for (const timer of this.timers.values()) {
3435
- clearInterval(timer);
3436
- }
3437
- this.timers.clear();
3438
- }
3439
- };
3440
-
3441
3409
  // src/core/orchestrator/scheduler.ts
3442
3410
  import cronParser from "cron-parser";
3443
3411
  import { v4 as uuid } from "uuid";
@@ -4192,7 +4160,6 @@ export {
4192
4160
  DataStore,
4193
4161
  DataStoreError,
4194
4162
  EVENTS,
4195
- HeartbeatScheduler,
4196
4163
  HookBus,
4197
4164
  MAX_CHAIN_DEPTH,
4198
4165
  MessagePipeline,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botinabox",
3
- "version": "0.5.6",
3
+ "version": "0.6.0",
4
4
  "description": "Bot in a Box — framework for building multi-agent bots",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",