botinabox 1.0.0 → 1.2.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.
- package/README.md +130 -205
- package/dist/channels/slack/index.d.ts +27 -1
- package/dist/channels/slack/index.js +4 -2
- package/dist/chunk-2LGXQPEA.js +41 -0
- package/dist/chunk-3X3YKI4T.js +357 -0
- package/dist/chunk-D47AIFOD.js +351 -0
- package/dist/chunk-DSNJKNEW.js +328 -0
- package/dist/connector-DDahQw-2.d.ts +63 -0
- package/dist/gmail-connector-2FVYTQJH.js +6 -0
- package/dist/gmail-connector-MNUBRNFM.js +6 -0
- package/dist/gmail-connector-URRFX6A3.js +6 -0
- package/dist/inbound-CGIXRXGC.js +8 -0
- package/dist/index.d.ts +41 -20
- package/dist/index.js +211 -43
- package/package.json +1 -1
|
@@ -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 };
|
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;
|
|
@@ -325,6 +324,13 @@ declare const AGENT_STATUSES: readonly ["idle", "running", "paused", "terminated
|
|
|
325
324
|
/** Run status values */
|
|
326
325
|
declare const RUN_STATUSES: readonly ["queued", "running", "succeeded", "failed", "cancelled"];
|
|
327
326
|
|
|
327
|
+
/** Shared utility functions. */
|
|
328
|
+
/**
|
|
329
|
+
* Truncate text at a word boundary, appending "..." if truncated.
|
|
330
|
+
* Returns the original text if it's shorter than maxLen.
|
|
331
|
+
*/
|
|
332
|
+
declare function truncateAtWord(text: string, maxLen: number): string;
|
|
333
|
+
|
|
328
334
|
type HookHandler = (context: Record<string, unknown>) => Promise<void> | void;
|
|
329
335
|
type Unsubscribe = () => void;
|
|
330
336
|
interface HookOptions {
|
|
@@ -1013,6 +1019,8 @@ interface DomainSchemaOptions {
|
|
|
1013
1019
|
rules?: boolean;
|
|
1014
1020
|
/** Include event audit log (default: true) */
|
|
1015
1021
|
events?: boolean;
|
|
1022
|
+
/** Include cross-domain junction tables (default: true) */
|
|
1023
|
+
junctions?: boolean;
|
|
1016
1024
|
}
|
|
1017
1025
|
/**
|
|
1018
1026
|
* Define standard domain tables that most multi-agent apps need.
|
|
@@ -1204,6 +1212,27 @@ interface PackageMigration {
|
|
|
1204
1212
|
*/
|
|
1205
1213
|
declare function runPackageMigrations(db: DataStore, migrations: PackageMigration[]): Promise<void>;
|
|
1206
1214
|
|
|
1215
|
+
interface UpdateResult {
|
|
1216
|
+
updated: boolean;
|
|
1217
|
+
packages: Array<{
|
|
1218
|
+
name: string;
|
|
1219
|
+
from: string;
|
|
1220
|
+
to: string;
|
|
1221
|
+
}>;
|
|
1222
|
+
restartRequired: boolean;
|
|
1223
|
+
}
|
|
1224
|
+
/**
|
|
1225
|
+
* Check npm for newer versions of framework packages and install them.
|
|
1226
|
+
* Returns what was updated. Safe to call on every startup — skips if
|
|
1227
|
+
* already on latest.
|
|
1228
|
+
*
|
|
1229
|
+
* @param packages - Package names to check (default: botinabox + latticesql)
|
|
1230
|
+
* @param opts.quiet - Suppress console output (default: false)
|
|
1231
|
+
*/
|
|
1232
|
+
declare function autoUpdate(packages?: string[], opts?: {
|
|
1233
|
+
quiet?: boolean;
|
|
1234
|
+
}): Promise<UpdateResult>;
|
|
1235
|
+
|
|
1207
1236
|
declare class RunManager {
|
|
1208
1237
|
private db;
|
|
1209
1238
|
private hooks;
|
|
@@ -1320,23 +1349,6 @@ declare class NdjsonLogger {
|
|
|
1320
1349
|
close(): void;
|
|
1321
1350
|
}
|
|
1322
1351
|
|
|
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
1352
|
/**
|
|
1341
1353
|
* Scheduler — database-backed job scheduling with cron expressions.
|
|
1342
1354
|
*
|
|
@@ -1344,7 +1356,7 @@ declare class HeartbeatScheduler {
|
|
|
1344
1356
|
* it emits the schedule's `action` as a hook event with the
|
|
1345
1357
|
* `action_config` payload. Consumers subscribe to handle the action.
|
|
1346
1358
|
*
|
|
1347
|
-
*
|
|
1359
|
+
* Supports one-time and recurring use cases.
|
|
1348
1360
|
*/
|
|
1349
1361
|
|
|
1350
1362
|
interface ScheduleDef {
|
|
@@ -1532,6 +1544,15 @@ declare class SecretStore {
|
|
|
1532
1544
|
list(): Promise<SecretMeta[]>;
|
|
1533
1545
|
rotate(name: string, newValue: string, environment?: string): Promise<void>;
|
|
1534
1546
|
delete(name: string, environment?: string): Promise<void>;
|
|
1547
|
+
/**
|
|
1548
|
+
* Load a sync cursor by key. Returns undefined if not found.
|
|
1549
|
+
* Cursors are stored as secrets with type='sync_cursor'.
|
|
1550
|
+
*/
|
|
1551
|
+
loadCursor(key: string): Promise<string | undefined>;
|
|
1552
|
+
/**
|
|
1553
|
+
* Persist a sync cursor by key. Creates or updates the secret.
|
|
1554
|
+
*/
|
|
1555
|
+
saveCursor(key: string, value: string): Promise<void>;
|
|
1535
1556
|
private _toMeta;
|
|
1536
1557
|
}
|
|
1537
1558
|
|
|
@@ -1567,4 +1588,4 @@ declare function isLoginRequired(stdout: string): boolean;
|
|
|
1567
1588
|
/** Rewrite local image paths to prevent CLI auto-embedding as vision content. */
|
|
1568
1589
|
declare function deactivateLocalImagePaths(prompt: string): string;
|
|
1569
1590
|
|
|
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,
|
|
1591
|
+
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, autoUpdate, 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, truncateAtWord, validateConfig };
|