flow-agent-bridge 0.37.5 → 0.37.8

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 CHANGED
@@ -143,6 +143,7 @@ onboarding.
143
143
  | `agentMentionChainLimit` | 4× `agentChainLimit` | the breaker's limit for agent messages that explicitly `<@mention>` this agent — deliberate hand-offs keep landing past `agentChainLimit` until this higher count, so a pipeline flows while a real mention ping-pong still gets cut. 0 = same as `agentChainLimit`; never lower than it |
144
144
  | `progress` | `thinking` | `thinking` \| `typing` \| `silent` |
145
145
  | `relayText` | true | relay the agent's interim text into the conversation as it works (`thinking` mode only); it grows one message by editing rather than posting per chunk |
146
+ | `mail.fromOutside` | `ignore` | mail to the agent's mailbox from a member of the organization starts a turn in the DM with them (with the sponsor, for an agent's mail); mail from anyone else is logged and ignored, or with `wake` starts a turn in the sponsor's DM |
146
147
  | `logFile` | `<config>.log` next to the config | daemon log file (rotates once at 5 MB); JSON `null` disables |
147
148
  | `voice.enabled` | true | answer DM Huddle rings as the agent; set false to decline with an explanation |
148
149
  | `voice.sttModel` | `deepgram/flux-general-en` | LiveKit Inference speech-to-text model; `FLOW_VOICE_STT_MODEL` overrides it |
package/dist/api.d.ts CHANGED
@@ -57,6 +57,12 @@ export declare class FlowApi {
57
57
  myWorkspaces(): Promise<WorkspaceDTO[]>;
58
58
  listChannels(workspaceId: string): Promise<ChannelDTO[]>;
59
59
  listMembers(workspaceId: string): Promise<WorkspaceMemberDTO[]>;
60
+ /** The DM with these members (the server's upsert: the existing one for this member set, else a new one). */
61
+ createDm(workspaceId: string, userIds: string[]): Promise<ChannelDTO>;
62
+ /** Calendar (`/v1/calendar/<path>`), as the agent's account in one organization (`?workspace=`). */
63
+ calendar<T>(method: 'GET' | 'POST', path: string, workspaceId: string, body?: unknown): Promise<T>;
64
+ /** Mail (`/v1/mail/<path>`), as the agent's account in one organization (`?workspace=`): its own mailbox (phase 5.4). */
65
+ mail<T>(method: 'GET' | 'POST' | 'PATCH', path: string, workspaceId: string, body?: unknown): Promise<T>;
60
66
  /** Post a message; mentions are parsed out of the body (server fans out notifications). */
61
67
  sendMessage(channelId: string, body: string, threadRootId?: string, fileIds?: string[], clientMsgId?: string): Promise<MessageDTO>;
62
68
  getArtifact(artifactId: string): Promise<ArtifactDTO>;
package/dist/api.js CHANGED
@@ -141,6 +141,18 @@ export class FlowApi {
141
141
  const r = await this.req('GET', `/v1/workspaces/${workspaceId}/members`);
142
142
  return r.members;
143
143
  }
144
+ /** The DM with these members (the server's upsert: the existing one for this member set, else a new one). */
145
+ createDm(workspaceId, userIds) {
146
+ return this.req('POST', `/v1/workspaces/${encodeURIComponent(workspaceId)}/dms`, { userIds });
147
+ }
148
+ /** Calendar (`/v1/calendar/<path>`), as the agent's account in one organization (`?workspace=`). */
149
+ calendar(method, path, workspaceId, body) {
150
+ return this.req(method, `/v1/calendar/${path}${path.includes('?') ? '&' : '?'}workspace=${encodeURIComponent(workspaceId)}`, body);
151
+ }
152
+ /** Mail (`/v1/mail/<path>`), as the agent's account in one organization (`?workspace=`): its own mailbox (phase 5.4). */
153
+ mail(method, path, workspaceId, body) {
154
+ return this.req(method, `/v1/mail/${path}${path.includes('?') ? '&' : '?'}workspace=${encodeURIComponent(workspaceId)}`, body);
155
+ }
144
156
  /** Post a message; mentions are parsed out of the body (server fans out notifications). */
145
157
  sendMessage(channelId, body, threadRootId, fileIds, clientMsgId = randomUUID()) {
146
158
  const mentions = [...new Set([...body.matchAll(USER_MENTION_RE)].map((m) => m[1]))];
package/dist/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2BtD,sHAAsH;AACtH,MAAM,UAAU,YAAY,CAAC,EAAS,EAAE,UAA+C;IACrF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC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,CAAC,EAAE;QAAE,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAwB,CAAC;AACnD,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE,GAAW;IAC/E,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,kBAAkB,EAAE;QAC1E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;KACxC,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IACnC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAuB,CAAC;AAClD,CAAC"}
package/dist/bridge.d.ts CHANGED
@@ -85,6 +85,13 @@ export declare class AgentBridge {
85
85
  private cursorTimer;
86
86
  /** Wake jobs taken (platform.md §5.2, phase 2.4), across restarts, so a job delivered again or replayed runs once. */
87
87
  private handledJobs;
88
+ /** Invitations answered (phase 4.2), by event id, across restarts: each `calendar.invited` starts one turn. */
89
+ private handledInvitations;
90
+ private readonly takingInvitations;
91
+ /** Mail taken (phase 5.4), by message id, across restarts: each `mail.received` starts at most one turn. */
92
+ private handledMail;
93
+ private readonly takingMail;
94
+ private mailTimer;
88
95
  /** Jobs whose ack is in flight, so two copies of one `agent.job` arriving together are taken once. */
89
96
  private readonly takingJobs;
90
97
  /** The `bridge-jobs:` socket subscription, whose poke means an `agent.job` came; one read at a time. */
@@ -104,12 +111,29 @@ export declare class AgentBridge {
104
111
  * no subscriptions (an older server), which leaves the bridge on live events alone.
105
112
  */
106
113
  catchUp(): Promise<number | null>;
107
- /** An older bridge's subscription, caught up: replaced by one with today's types (`agent.job`), starting at the head. */
114
+ /** An older bridge's subscription, caught up: replaced by one with today's types (`agent.job`, `calendar.invited`), starting at the head. */
108
115
  private replaceSubscription;
109
116
  /** The socket subscription that pokes when a wake job comes (catch-up.ts `jobsSpec`). Without it jobs still come, late. */
110
117
  private ensureJobsSubscription;
111
118
  /** A poke for the job subscription: read it until empty, taking each job, acking as it goes. */
112
119
  readJobs(id: string): Promise<void>;
120
+ /** An event on the agent's own account (catch-up.ts ACCOUNT_TYPES): a wake job, an invitation, or mail. */
121
+ handleAccountEvent(e: PlatformEvent): Promise<void>;
122
+ /**
123
+ * A `calendar.invited` event (platform.md §7, phase 4.2): a turn in the DM with the organizer when they are a member of
124
+ * the organization, else with the agent's sponsor, asking the agent to answer with `respond_to_event` (or ask first).
125
+ * One turn per event id, across restarts (state.json); an invitation from another organization is a sibling process's.
126
+ */
127
+ handleInvitation(e: PlatformEvent): Promise<void>;
128
+ /** The mailbox's accounts, asked for so the Mail object keeps syncing (MAIL_TOUCH_MS); at start, its address logged. */
129
+ private touchMailbox;
130
+ /**
131
+ * A `mail.received` event (phase 5.4): new mail in the agent's mailbox. From a member of the organization (by address),
132
+ * a turn in the DM with them, or with the agent's sponsor when the sender is an agent, asking it to read the message
133
+ * (`read_mail`) and act on it. From anyone else, logged and left, unless `mail.fromOutside` is `wake` (then the sponsor's
134
+ * DM). Each message id once, across restarts (state.json); mail it sent itself, and another organization's, are passed over.
135
+ */
136
+ handleMail(e: PlatformEvent): Promise<void>;
113
137
  /**
114
138
  * An `agent.job` event (live or from a catch-up): acked as this agent, then run as a turn the way `start_task` runs
115
139
  * one. Taken once: a job id already taken (state.json) or being taken is passed over. A job the server no longer
package/dist/bridge.js CHANGED
@@ -24,8 +24,15 @@ import { EXIT_RESTART, EXIT_UPDATE } from './supervisor.js';
24
24
  import { currentVersion, isOutdated, latestPublishedVersion } from './version.js';
25
25
  import { HuddleVoiceManager } from './huddle-voice.js';
26
26
  import { CATCH_UP_TYPES, catchUp, ensureSubscription, HandledMessages, jobsSpec, subscriptionName } from './catch-up.js';
27
+ import { invitationPrompt } from './calendar-tools.js';
28
+ import { mailPrompt } from './mail-tools.js';
27
29
  /** How often the socket's latest cursor is acked to the bridge's subscription. */
28
30
  const CURSOR_ACK_MS = 30_000;
31
+ /**
32
+ * How often the bridge looks at its mailbox's accounts (phase 5.4). Any request keeps the Mail object syncing (every 5
33
+ * minutes within an hour of one, none after a day without), and only a sync publishes `mail.received`.
34
+ */
35
+ const MAIL_TOUCH_MS = 30 * 60_000;
29
36
  /** A wake job's lease is renewed this often while its turn runs (the server's lease is 10 minutes). */
30
37
  export const JOB_EXTEND_MS = 5 * 60_000;
31
38
  /** A job whose turn never got to run (a `/reset` dropped it, say) is reported failed after this long. */
@@ -159,6 +166,13 @@ export class AgentBridge {
159
166
  cursorTimer = null;
160
167
  /** Wake jobs taken (platform.md §5.2, phase 2.4), across restarts, so a job delivered again or replayed runs once. */
161
168
  handledJobs;
169
+ /** Invitations answered (phase 4.2), by event id, across restarts: each `calendar.invited` starts one turn. */
170
+ handledInvitations;
171
+ takingInvitations = new Set();
172
+ /** Mail taken (phase 5.4), by message id, across restarts: each `mail.received` starts at most one turn. */
173
+ handledMail;
174
+ takingMail = new Set();
175
+ mailTimer = null;
162
176
  /** Jobs whose ack is in flight, so two copies of one `agent.job` arriving together are taken once. */
163
177
  takingJobs = new Set();
164
178
  /** The `bridge-jobs:` socket subscription, whose poke means an `agent.job` came; one read at a time. */
@@ -175,6 +189,8 @@ export class AgentBridge {
175
189
  this.sem = new Semaphore(cfg.concurrency);
176
190
  this.handled = new HandledMessages(cfg.stateFile ?? null, (m) => this.log(m));
177
191
  this.handledJobs = new HandledMessages(cfg.stateFile ?? null, (m) => this.log(m), undefined, 'handledJobIds');
192
+ this.handledInvitations = new HandledMessages(cfg.stateFile ?? null, (m) => this.log(m), undefined, 'handledInvitationIds');
193
+ this.handledMail = new HandledMessages(cfg.stateFile ?? null, (m) => this.log(m), undefined, 'handledMailIds');
178
194
  this.sessions = new SessionManager({
179
195
  cfg: cfg.runtime,
180
196
  idleMs: cfg.runtime.sessionIdleSec * 1000,
@@ -272,6 +288,9 @@ export class AgentBridge {
272
288
  this.cursorTimer.unref();
273
289
  }
274
290
  this.startTaskIpc();
291
+ void this.touchMailbox(true);
292
+ this.mailTimer = setInterval(() => void this.touchMailbox(false), MAIL_TOUCH_MS);
293
+ this.mailTimer.unref();
275
294
  // Best-effort staleness check — never blocks startup or crashes on failure.
276
295
  void this.checkVersion();
277
296
  void this.reportRelaunch();
@@ -294,7 +313,7 @@ export class AgentBridge {
294
313
  this.latestCursor = sub.cursor;
295
314
  const before = this.answered;
296
315
  try {
297
- const out = await catchUp(this.api, this.workspace.id, sub, (ev) => this.handleEvent(ev), (m) => this.log(m), (e) => this.handleJob(e));
316
+ const out = await catchUp(this.api, this.workspace.id, sub, (ev) => this.handleEvent(ev), (m) => this.log(m), (e) => this.handleAccountEvent(e));
298
317
  this.subscription.acked = out.next;
299
318
  this.latestCursor = Math.max(this.latestCursor, out.next);
300
319
  this.log(`caught up: ${out.events} events, answered ${this.answered - before}`);
@@ -307,14 +326,14 @@ export class AgentBridge {
307
326
  return this.subscription.acked;
308
327
  }
309
328
  }
310
- /** An older bridge's subscription, caught up: replaced by one with today's types (`agent.job`), starting at the head. */
329
+ /** An older bridge's subscription, caught up: replaced by one with today's types (`agent.job`, `calendar.invited`), starting at the head. */
311
330
  async replaceSubscription(oldId) {
312
331
  try {
313
332
  const fresh = await this.api.createSubscription(this.workspace.id, { name: subscriptionName(this.me.id), filter: { types: CATCH_UP_TYPES }, delivery: 'pull' });
314
333
  await this.api.deleteSubscription(this.workspace.id, oldId).catch((err) => this.log(`old subscription not deleted: ${err.message}`));
315
334
  this.subscription = { id: fresh.id, acked: fresh.cursor };
316
335
  this.latestCursor = Math.max(this.latestCursor, fresh.cursor);
317
- this.log('event subscription renewed with agent.job');
336
+ this.log('event subscription renewed with today\'s types');
318
337
  }
319
338
  catch (err) {
320
339
  this.log(`event subscription not renewed: ${err.message}`);
@@ -323,7 +342,17 @@ export class AgentBridge {
323
342
  /** The socket subscription that pokes when a wake job comes (catch-up.ts `jobsSpec`). Without it jobs still come, late. */
324
343
  async ensureJobsSubscription() {
325
344
  try {
326
- this.jobsSub = { id: (await ensureSubscription(this.api, this.workspace.id, this.me.id, jobsSpec(this.me.id))).id };
345
+ const spec = jobsSpec(this.me.id);
346
+ const sub = await ensureSubscription(this.api, this.workspace.id, this.me.id, spec);
347
+ this.jobsSub = { id: sub.id };
348
+ if (sub.outdated) {
349
+ // An older bridge's (agent.job alone): what it holds is read now, then it is replaced by one with today's types.
350
+ await this.readJobs(sub.id);
351
+ const fresh = await this.api.createSubscription(this.workspace.id, spec);
352
+ await this.api.deleteSubscription(this.workspace.id, sub.id).catch((err) => this.log(`old job subscription not deleted: ${err.message}`));
353
+ this.jobsSub = { id: fresh.id };
354
+ this.log('job subscription renewed with today\'s types');
355
+ }
327
356
  }
328
357
  catch (err) {
329
358
  this.log(`no job subscription (${err.message}) — wake jobs arrive with the next catch-up or delivery`);
@@ -341,7 +370,7 @@ export class AgentBridge {
341
370
  try {
342
371
  do {
343
372
  this.jobsAgain = false;
344
- await catchUp(this.api, this.workspace.id, { id, cursor: 0 }, () => { }, (m) => this.log(m), (e) => this.handleJob(e));
373
+ await catchUp(this.api, this.workspace.id, { id, cursor: 0 }, () => { }, (m) => this.log(m), (e) => this.handleAccountEvent(e));
345
374
  } while (this.jobsAgain);
346
375
  }
347
376
  catch (err) {
@@ -351,6 +380,128 @@ export class AgentBridge {
351
380
  this.jobsReading = false;
352
381
  }
353
382
  }
383
+ /** An event on the agent's own account (catch-up.ts ACCOUNT_TYPES): a wake job, an invitation, or mail. */
384
+ async handleAccountEvent(e) {
385
+ if (e.type === 'calendar.invited')
386
+ return this.handleInvitation(e);
387
+ if (e.type === 'mail.received')
388
+ return this.handleMail(e);
389
+ if (e.type === 'agent.job')
390
+ return this.handleJob(e);
391
+ }
392
+ /**
393
+ * A `calendar.invited` event (platform.md §7, phase 4.2): a turn in the DM with the organizer when they are a member of
394
+ * the organization, else with the agent's sponsor, asking the agent to answer with `respond_to_event` (or ask first).
395
+ * One turn per event id, across restarts (state.json); an invitation from another organization is a sibling process's.
396
+ */
397
+ async handleInvitation(e) {
398
+ const d = e.data;
399
+ const eventId = d?.eventId;
400
+ if (!eventId || (e.organizationId && e.organizationId !== this.workspace.id))
401
+ return;
402
+ if (this.handledInvitations.has(eventId) || this.takingInvitations.has(eventId)) {
403
+ this.log('invitation already answered — skipping the copy');
404
+ return;
405
+ }
406
+ this.takingInvitations.add(eventId);
407
+ try {
408
+ const find = () => [...this.members.values()].find((m) => m.userId !== this.me.id && !!d.organizer &&
409
+ ((!!d.organizer.accountId && m.accountId === d.organizer.accountId) || (!!d.organizer.email && [m.address, m.email].some((a) => a?.toLowerCase() === d.organizer.email.toLowerCase()))));
410
+ let organizer = find();
411
+ if (!organizer) {
412
+ await this.refreshDirectory().catch((err) => this.log(`directory refresh failed: ${err.message}`));
413
+ organizer = find();
414
+ }
415
+ const who = organizer?.userId ?? this.members.get(this.me.id)?.sponsorId ?? null;
416
+ if (!who) {
417
+ this.log('invitation: neither the organizer nor a sponsor to ask in a DM — not answered');
418
+ this.handledInvitations.add(eventId);
419
+ return;
420
+ }
421
+ const dm = await this.api.createDm(this.workspace.id, [who]);
422
+ this.channels.set(dm.id, { ...dm, isMember: true });
423
+ this.handledInvitations.add(eventId);
424
+ this.log(`invitation: a turn in the DM with the ${organizer ? 'organizer' : 'sponsor'}`);
425
+ this.enqueue(this.taskMessage(`invite-${createHash('sha256').update(eventId).digest('hex').slice(0, 16)}`, dm.id, who, invitationPrompt(d)));
426
+ }
427
+ catch (err) {
428
+ this.log(`invitation: not started (${err.message}) — not answered`);
429
+ }
430
+ finally {
431
+ this.takingInvitations.delete(eventId);
432
+ }
433
+ }
434
+ /** The mailbox's accounts, asked for so the Mail object keeps syncing (MAIL_TOUCH_MS); at start, its address logged. */
435
+ async touchMailbox(first) {
436
+ if (this.departed)
437
+ return;
438
+ try {
439
+ const { accounts } = await this.api.mail('GET', 'accounts', this.workspace.id);
440
+ const box = accounts.find((a) => a.kind === 'hosted');
441
+ if (first)
442
+ this.log(box ? `mailbox ${box.email}` : 'no mailbox in this organization (the mail tools say so)');
443
+ }
444
+ catch (err) {
445
+ if (first)
446
+ this.log(`mailbox not checked: ${err.message}`);
447
+ }
448
+ }
449
+ /**
450
+ * A `mail.received` event (phase 5.4): new mail in the agent's mailbox. From a member of the organization (by address),
451
+ * a turn in the DM with them, or with the agent's sponsor when the sender is an agent, asking it to read the message
452
+ * (`read_mail`) and act on it. From anyone else, logged and left, unless `mail.fromOutside` is `wake` (then the sponsor's
453
+ * DM). Each message id once, across restarts (state.json); mail it sent itself, and another organization's, are passed over.
454
+ */
455
+ async handleMail(e) {
456
+ const d = e.data;
457
+ if (!d || !d.accountId || !d.uid || (e.organizationId && e.organizationId !== this.workspace.id))
458
+ return;
459
+ const id = e.ref?.id ?? `${d.accountId}:${d.folder}:${d.uid}`;
460
+ if (this.handledMail.has(id) || this.takingMail.has(id)) {
461
+ this.log('mail already taken — skipping the copy');
462
+ return;
463
+ }
464
+ this.takingMail.add(id);
465
+ try {
466
+ const from = d.from?.address?.toLowerCase() ?? '';
467
+ const mine = [addressIn(this.me, this.workspace.id), this.members.get(this.me.id)?.address].filter(Boolean).map((a) => a.toLowerCase());
468
+ if (!from || mine.includes(from)) {
469
+ this.log(`mail ${id}: ${from ? 'from this agent itself' : 'with no sender'} — not answered`);
470
+ this.handledMail.add(id);
471
+ return;
472
+ }
473
+ const find = () => [...this.members.values()].find((m) => m.userId !== this.me.id && [m.address, m.email].some((a) => !!a && a.toLowerCase() === from));
474
+ let sender = find();
475
+ if (!sender) {
476
+ await this.refreshDirectory().catch((err) => this.log(`directory refresh failed: ${err.message}`));
477
+ sender = find();
478
+ }
479
+ const sponsor = this.members.get(this.me.id)?.sponsorId ?? null;
480
+ if (!sender && this.cfg.mail?.fromOutside !== 'wake') {
481
+ this.log(`mail ${id} from ${from}, not a member — ignored (mail.fromOutside: "wake" in agent.json answers it)`);
482
+ this.handledMail.add(id);
483
+ return;
484
+ }
485
+ const who = sender && !sender.isAgent ? sender.userId : sponsor;
486
+ if (!who) {
487
+ this.log(`mail ${id}: no sponsor to ask in a DM — not answered`);
488
+ this.handledMail.add(id);
489
+ return;
490
+ }
491
+ const dm = await this.api.createDm(this.workspace.id, [who]);
492
+ this.channels.set(dm.id, { ...dm, isMember: true });
493
+ this.handledMail.add(id);
494
+ this.log(`mail ${id}: a turn in the DM with the ${who === sender?.userId ? 'sender' : 'sponsor'}`);
495
+ const name = sender?.displayName ?? (d.from?.name || null);
496
+ this.enqueue(this.taskMessage(`mail-${createHash('sha256').update(id).digest('hex').slice(0, 16)}`, dm.id, who, mailPrompt(d, id, name)));
497
+ }
498
+ catch (err) {
499
+ this.log(`mail ${id}: not started (${err.message}) — not answered`);
500
+ }
501
+ finally {
502
+ this.takingMail.delete(id);
503
+ }
504
+ }
354
505
  /**
355
506
  * An `agent.job` event (live or from a catch-up): acked as this agent, then run as a turn the way `start_task` runs
356
507
  * one. Taken once: a job id already taken (state.json) or being taken is passed over. A job the server no longer
@@ -651,6 +802,9 @@ export class AgentBridge {
651
802
  if (this.cursorTimer)
652
803
  clearInterval(this.cursorTimer);
653
804
  this.cursorTimer = null;
805
+ if (this.mailTimer)
806
+ clearInterval(this.mailTimer);
807
+ this.mailTimer = null;
654
808
  const acked = this.ackCursor();
655
809
  this.ipcServer?.close();
656
810
  this.ipcServer = null;