flow-agent-bridge 0.37.5 → 0.37.7
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/dist/api.d.ts +4 -0
- package/dist/api.js +8 -0
- package/dist/api.js.map +1 -1
- package/dist/bridge.d.ts +12 -1
- package/dist/bridge.js +69 -5
- package/dist/bridge.js.map +1 -1
- package/dist/calendar-tools.d.ts +194 -0
- package/dist/calendar-tools.js +258 -0
- package/dist/calendar-tools.js.map +1 -0
- package/dist/catch-up.d.ts +5 -2
- package/dist/catch-up.js +10 -6
- package/dist/catch-up.js.map +1 -1
- package/dist/mcp-server.js +8 -1
- package/dist/mcp-server.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { CalendarInvitedEventData } from '@flow/shared';
|
|
2
|
+
import type { FlowApi } from './api.js';
|
|
3
|
+
export declare const CALENDAR_TOOLS: ({
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: string;
|
|
8
|
+
properties: {
|
|
9
|
+
from: {
|
|
10
|
+
type: string;
|
|
11
|
+
description: string;
|
|
12
|
+
};
|
|
13
|
+
to: {
|
|
14
|
+
type: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
id?: never;
|
|
18
|
+
response?: never;
|
|
19
|
+
comment?: never;
|
|
20
|
+
duration_minutes?: never;
|
|
21
|
+
timezone?: never;
|
|
22
|
+
working_hours?: never;
|
|
23
|
+
summary?: never;
|
|
24
|
+
start?: never;
|
|
25
|
+
end?: never;
|
|
26
|
+
attendees?: never;
|
|
27
|
+
location?: never;
|
|
28
|
+
description?: never;
|
|
29
|
+
};
|
|
30
|
+
required: string[];
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: string;
|
|
37
|
+
properties: {
|
|
38
|
+
id: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
response?: never;
|
|
43
|
+
comment?: never;
|
|
44
|
+
duration_minutes?: never;
|
|
45
|
+
from?: never;
|
|
46
|
+
to?: never;
|
|
47
|
+
timezone?: never;
|
|
48
|
+
working_hours?: never;
|
|
49
|
+
summary?: never;
|
|
50
|
+
start?: never;
|
|
51
|
+
end?: never;
|
|
52
|
+
attendees?: never;
|
|
53
|
+
location?: never;
|
|
54
|
+
description?: never;
|
|
55
|
+
};
|
|
56
|
+
required: string[];
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
name: string;
|
|
60
|
+
description: string;
|
|
61
|
+
inputSchema: {
|
|
62
|
+
type: string;
|
|
63
|
+
properties: {
|
|
64
|
+
id: {
|
|
65
|
+
type: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
response: {
|
|
69
|
+
type: string;
|
|
70
|
+
enum: string[];
|
|
71
|
+
};
|
|
72
|
+
comment: {
|
|
73
|
+
type: string;
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
duration_minutes?: never;
|
|
77
|
+
from?: never;
|
|
78
|
+
to?: never;
|
|
79
|
+
timezone?: never;
|
|
80
|
+
working_hours?: never;
|
|
81
|
+
summary?: never;
|
|
82
|
+
start?: never;
|
|
83
|
+
end?: never;
|
|
84
|
+
attendees?: never;
|
|
85
|
+
location?: never;
|
|
86
|
+
description?: never;
|
|
87
|
+
};
|
|
88
|
+
required: string[];
|
|
89
|
+
};
|
|
90
|
+
} | {
|
|
91
|
+
name: string;
|
|
92
|
+
description: string;
|
|
93
|
+
inputSchema: {
|
|
94
|
+
type: string;
|
|
95
|
+
properties: {
|
|
96
|
+
id?: never;
|
|
97
|
+
response?: never;
|
|
98
|
+
comment?: never;
|
|
99
|
+
duration_minutes: {
|
|
100
|
+
type: string;
|
|
101
|
+
description: string;
|
|
102
|
+
};
|
|
103
|
+
from: {
|
|
104
|
+
type: string;
|
|
105
|
+
description: string;
|
|
106
|
+
};
|
|
107
|
+
to: {
|
|
108
|
+
type: string;
|
|
109
|
+
description: string;
|
|
110
|
+
};
|
|
111
|
+
attendees: {
|
|
112
|
+
type: string;
|
|
113
|
+
items: {
|
|
114
|
+
type: string;
|
|
115
|
+
};
|
|
116
|
+
description: string;
|
|
117
|
+
};
|
|
118
|
+
timezone: {
|
|
119
|
+
type: string;
|
|
120
|
+
description: string;
|
|
121
|
+
};
|
|
122
|
+
working_hours: {
|
|
123
|
+
type: string;
|
|
124
|
+
description: string;
|
|
125
|
+
};
|
|
126
|
+
summary?: never;
|
|
127
|
+
start?: never;
|
|
128
|
+
end?: never;
|
|
129
|
+
location?: never;
|
|
130
|
+
description?: never;
|
|
131
|
+
};
|
|
132
|
+
required: string[];
|
|
133
|
+
};
|
|
134
|
+
} | {
|
|
135
|
+
name: string;
|
|
136
|
+
description: string;
|
|
137
|
+
inputSchema: {
|
|
138
|
+
type: string;
|
|
139
|
+
properties: {
|
|
140
|
+
id?: never;
|
|
141
|
+
response?: never;
|
|
142
|
+
comment?: never;
|
|
143
|
+
duration_minutes?: never;
|
|
144
|
+
from?: never;
|
|
145
|
+
to?: never;
|
|
146
|
+
timezone?: never;
|
|
147
|
+
working_hours?: never;
|
|
148
|
+
summary: {
|
|
149
|
+
type: string;
|
|
150
|
+
description: string;
|
|
151
|
+
};
|
|
152
|
+
start: {
|
|
153
|
+
type: string;
|
|
154
|
+
description: string;
|
|
155
|
+
};
|
|
156
|
+
end: {
|
|
157
|
+
type: string;
|
|
158
|
+
description: string;
|
|
159
|
+
};
|
|
160
|
+
attendees: {
|
|
161
|
+
type: string;
|
|
162
|
+
items: {
|
|
163
|
+
type: string;
|
|
164
|
+
};
|
|
165
|
+
description: string;
|
|
166
|
+
};
|
|
167
|
+
location: {
|
|
168
|
+
type: string;
|
|
169
|
+
description: string;
|
|
170
|
+
};
|
|
171
|
+
description: {
|
|
172
|
+
type: string;
|
|
173
|
+
description: string;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
required: string[];
|
|
177
|
+
};
|
|
178
|
+
})[];
|
|
179
|
+
export declare const CALENDAR_TOOL_NAMES: Set<string>;
|
|
180
|
+
/** When an event is, for a line or a prompt: "Thu, Dec 3, 2026, 15:00–16:00 UTC", or the day for an all-day one. */
|
|
181
|
+
export declare function whenOf(start: string, end: string, allDay: boolean): string;
|
|
182
|
+
/** What the agent is asked when it is invited (the turn in the DM with the organizer, or the sponsor). */
|
|
183
|
+
export declare function invitationPrompt(d: CalendarInvitedEventData): string;
|
|
184
|
+
export type CalendarApi = Pick<FlowApi, 'calendar'>;
|
|
185
|
+
/**
|
|
186
|
+
* The free stretches of at least `durationMs` in [from, to) that no busy interval covers, within `hours` (wall-clock minutes
|
|
187
|
+
* from midnight, Monday to Friday) in `zone`, or at any time when `hours` is null: longest first, then earliest.
|
|
188
|
+
*/
|
|
189
|
+
export declare function freeStretches(busy: [number, number][], from: number, to: number, durationMs: number, hours: [number, number] | null, zone: string): [number, number][];
|
|
190
|
+
/** One of CALENDAR_TOOLS, as the agent, in its organization: the text for the agent, and whether it is an error. */
|
|
191
|
+
export declare function calendarTool(api: CalendarApi, workspaceId: string, name: string, args: Record<string, unknown>): Promise<{
|
|
192
|
+
text: string;
|
|
193
|
+
isError: boolean;
|
|
194
|
+
}>;
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
export const CALENDAR_TOOLS = [
|
|
2
|
+
{
|
|
3
|
+
name: 'list_my_events',
|
|
4
|
+
description: 'List the events on your own calendars between two times (at most three months apart): id, when, title, organizer and your answer. Invitations you have not answered show "needs-action".',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
from: { type: 'string', description: 'Start of the window, an ISO time, e.g. 2026-12-01T00:00:00Z.' },
|
|
9
|
+
to: { type: 'string', description: 'End of the window, an ISO time.' },
|
|
10
|
+
},
|
|
11
|
+
required: ['from', 'to'],
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: 'get_event',
|
|
16
|
+
description: 'Read one event on your calendar by id (from list_my_events or an invitation): when, where, description, organizer, every attendee and their answer.',
|
|
17
|
+
inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'The event id.' } }, required: ['id'] },
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: 'respond_to_event',
|
|
21
|
+
description: 'Answer an invitation on your calendar: accepted, declined or tentative, with an optional comment for the organizer. The organizer sees your answer at once.',
|
|
22
|
+
inputSchema: {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
id: { type: 'string', description: 'The event id.' },
|
|
26
|
+
response: { type: 'string', enum: ['accepted', 'declined', 'tentative'] },
|
|
27
|
+
comment: { type: 'string', description: 'Optional note to the organizer.' },
|
|
28
|
+
},
|
|
29
|
+
required: ['id', 'response'],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'find_free_time',
|
|
34
|
+
description: 'Find times when you and the attendees are all free for a meeting, between two times (at most 31 days apart), within working hours (09:00-17:00 Monday to Friday in timezone, UTC unless given). Members of the organization are checked on their calendars (busy times only); anyone whose calendar cannot be seen is listed as unknown. Longest free stretches first; a meeting fits anywhere inside one. Use it before proposing a time.',
|
|
35
|
+
inputSchema: {
|
|
36
|
+
type: 'object',
|
|
37
|
+
properties: {
|
|
38
|
+
duration_minutes: { type: 'number', description: 'How long the meeting is, in minutes.' },
|
|
39
|
+
from: { type: 'string', description: 'The earliest start, an ISO time.' },
|
|
40
|
+
to: { type: 'string', description: 'The latest end, an ISO time.' },
|
|
41
|
+
attendees: { type: 'array', items: { type: 'string' }, description: 'Email addresses of the others who should be free, e.g. ann@acme.freeflow.im.' },
|
|
42
|
+
timezone: { type: 'string', description: 'The IANA time zone working hours are in, e.g. America/New_York. Defaults to UTC.' },
|
|
43
|
+
working_hours: { type: 'string', description: 'HH:MM-HH:MM (default 09:00-17:00, Monday to Friday), or "any" for any time of any day.' },
|
|
44
|
+
},
|
|
45
|
+
required: ['duration_minutes', 'from', 'to'],
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'create_event',
|
|
50
|
+
description: 'Book an event on your calendar and invite people by email address: members of the organization get it on their calendars at once and answer it there; anyone else is emailed an invitation where that is possible. Check find_free_time first, and say what you booked.',
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
properties: {
|
|
54
|
+
summary: { type: 'string', description: 'The title.' },
|
|
55
|
+
start: { type: 'string', description: 'When it starts, an ISO time with a zone, e.g. 2026-12-03T15:00:00Z.' },
|
|
56
|
+
end: { type: 'string', description: 'When it ends, an ISO time.' },
|
|
57
|
+
attendees: { type: 'array', items: { type: 'string' }, description: 'Who to invite: "name@example.com" or "Name <name@example.com>".' },
|
|
58
|
+
location: { type: 'string', description: 'Where: an address or a link.' },
|
|
59
|
+
description: { type: 'string', description: 'Notes, plain text.' },
|
|
60
|
+
},
|
|
61
|
+
required: ['summary', 'start', 'end'],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
export const CALENDAR_TOOL_NAMES = new Set(CALENDAR_TOOLS.map((t) => t.name));
|
|
66
|
+
/** When an event is, for a line or a prompt: "Thu, Dec 3, 2026, 15:00–16:00 UTC", or the day for an all-day one. */
|
|
67
|
+
export function whenOf(start, end, allDay) {
|
|
68
|
+
const day = (d) => new Intl.DateTimeFormat('en-US', { weekday: 'short', month: 'short', day: 'numeric', year: 'numeric', timeZone: 'UTC' }).format(d);
|
|
69
|
+
const s = new Date(start), e = new Date(end);
|
|
70
|
+
if (Number.isNaN(s.getTime()))
|
|
71
|
+
return start;
|
|
72
|
+
if (allDay)
|
|
73
|
+
return `${day(s)} (all day)`;
|
|
74
|
+
const time = (d) => d.toISOString().slice(11, 16);
|
|
75
|
+
return day(s) === day(e) ? `${day(s)}, ${time(s)}–${time(e)} UTC` : `${day(s)} ${time(s)} – ${day(e)} ${time(e)} UTC`;
|
|
76
|
+
}
|
|
77
|
+
const who = (p) => (p ? (p.name ? `${p.name} <${p.email}>` : p.email) : 'someone');
|
|
78
|
+
/** What the agent is asked when it is invited (the turn in the DM with the organizer, or the sponsor). */
|
|
79
|
+
export function invitationPrompt(d) {
|
|
80
|
+
const by = d.organizer ? `${d.organizer.name ? `${d.organizer.name} ` : ''}<${d.organizer.email}>` : 'someone';
|
|
81
|
+
return `You were invited to "${d.summary || 'an event'}" on ${whenOf(d.start, d.end, d.allDay)} by ${by}. ` +
|
|
82
|
+
'Decide whether to accept, decline or answer tentatively, and respond with the `respond_to_event` tool ' +
|
|
83
|
+
`(event id ${d.eventId}); you may ask a question in this DM first. get_event shows its details.`;
|
|
84
|
+
}
|
|
85
|
+
const line = (e) => `${e.id} ${whenOf(e.start, e.end, e.allDay)} ${e.summary || '(no title)'}${e.status === 'cancelled' ? ' (cancelled)' : ''}` +
|
|
86
|
+
`${e.organizer ? ` organizer ${who(e.organizer)}` : ''}${e.myResponse ? ` [your answer: ${e.myResponse}]` : ''}`;
|
|
87
|
+
const DAY = 86_400_000;
|
|
88
|
+
const EMAIL = /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/;
|
|
89
|
+
/** "Name <a@b.c>" or "a@b.c" as the API's attendee, or null for something that is not an address. */
|
|
90
|
+
function personOf(s) {
|
|
91
|
+
const m = /^\s*(?:"?([^"<]*?)"?\s*)?<([^>]+)>\s*$/.exec(s);
|
|
92
|
+
const email = (m ? m[2] : s).trim().toLowerCase();
|
|
93
|
+
const name = m?.[1]?.trim();
|
|
94
|
+
return EMAIL.test(email) ? { email, ...(name ? { name } : {}) } : null;
|
|
95
|
+
}
|
|
96
|
+
/** How far `zone`'s wall clock is ahead of UTC at instant `t`. */
|
|
97
|
+
function offsetMs(t, zone) {
|
|
98
|
+
const parts = new Intl.DateTimeFormat('en-US', { timeZone: zone, hourCycle: 'h23', year: 'numeric', month: 'numeric', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' }).formatToParts(new Date(t));
|
|
99
|
+
const n = (k) => Number(parts.find((p) => p.type === k)?.value);
|
|
100
|
+
return Date.UTC(n('year'), n('month') - 1, n('day'), n('hour'), n('minute'), n('second')) - Math.floor(t / 1000) * 1000;
|
|
101
|
+
}
|
|
102
|
+
/** The instant a wall-clock time in `zone` names. */
|
|
103
|
+
function wallToUtc(y, mo, d, h, mi, zone) {
|
|
104
|
+
const guess = Date.UTC(y, mo - 1, d, h, mi);
|
|
105
|
+
const t = guess - offsetMs(guess, zone);
|
|
106
|
+
return guess - offsetMs(t, zone);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The free stretches of at least `durationMs` in [from, to) that no busy interval covers, within `hours` (wall-clock minutes
|
|
110
|
+
* from midnight, Monday to Friday) in `zone`, or at any time when `hours` is null: longest first, then earliest.
|
|
111
|
+
*/
|
|
112
|
+
export function freeStretches(busy, from, to, durationMs, hours, zone) {
|
|
113
|
+
const merged = [];
|
|
114
|
+
for (const [a, b] of busy.filter(([a, b]) => b > a).sort((x, y) => x[0] - y[0])) {
|
|
115
|
+
const last = merged.at(-1);
|
|
116
|
+
if (last && a <= last[1])
|
|
117
|
+
last[1] = Math.max(last[1], b);
|
|
118
|
+
else
|
|
119
|
+
merged.push([a, b]);
|
|
120
|
+
}
|
|
121
|
+
const windows = [];
|
|
122
|
+
if (!hours)
|
|
123
|
+
windows.push([from, to]);
|
|
124
|
+
else {
|
|
125
|
+
const first = new Date(from + offsetMs(from, zone));
|
|
126
|
+
for (let d = Date.UTC(first.getUTCFullYear(), first.getUTCMonth(), first.getUTCDate());; d += DAY) {
|
|
127
|
+
const day = new Date(d), y = day.getUTCFullYear(), mo = day.getUTCMonth() + 1, dd = day.getUTCDate();
|
|
128
|
+
const start = wallToUtc(y, mo, dd, Math.floor(hours[0] / 60), hours[0] % 60, zone);
|
|
129
|
+
if (start >= to)
|
|
130
|
+
break;
|
|
131
|
+
if (day.getUTCDay() === 0 || day.getUTCDay() === 6)
|
|
132
|
+
continue;
|
|
133
|
+
const a = Math.max(start, from), b = Math.min(wallToUtc(y, mo, dd, Math.floor(hours[1] / 60), hours[1] % 60, zone), to);
|
|
134
|
+
if (b > a)
|
|
135
|
+
windows.push([a, b]);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const out = [];
|
|
139
|
+
for (const [ws, we] of windows) {
|
|
140
|
+
let at = ws;
|
|
141
|
+
for (const [bs, be] of merged) {
|
|
142
|
+
if (be <= at || bs >= we)
|
|
143
|
+
continue;
|
|
144
|
+
if (bs - at >= durationMs)
|
|
145
|
+
out.push([at, bs]);
|
|
146
|
+
at = Math.max(at, be);
|
|
147
|
+
}
|
|
148
|
+
if (we - at >= durationMs)
|
|
149
|
+
out.push([at, we]);
|
|
150
|
+
}
|
|
151
|
+
return out.sort((x, y) => (y[1] - y[0]) - (x[1] - x[0]) || x[0] - y[0]);
|
|
152
|
+
}
|
|
153
|
+
/** One of CALENDAR_TOOLS, as the agent, in its organization: the text for the agent, and whether it is an error. */
|
|
154
|
+
export async function calendarTool(api, workspaceId, name, args) {
|
|
155
|
+
if (!workspaceId)
|
|
156
|
+
return { text: `${name} needs a workspace (FLOW_WORKSPACE_ID is not set)`, isError: true };
|
|
157
|
+
const id = typeof args.id === 'string' ? args.id.trim() : '';
|
|
158
|
+
try {
|
|
159
|
+
switch (name) {
|
|
160
|
+
case 'list_my_events': {
|
|
161
|
+
const from = String(args.from ?? '').trim(), to = String(args.to ?? '').trim();
|
|
162
|
+
if (!from || !to)
|
|
163
|
+
return { text: 'list_my_events needs from and to (ISO times)', isError: true };
|
|
164
|
+
const r = await api.calendar('GET', `events?from=${encodeURIComponent(from)}&to=${encodeURIComponent(to)}`, workspaceId);
|
|
165
|
+
return { text: r.events.length ? r.events.map(line).join('\n') : 'no events in that window', isError: false };
|
|
166
|
+
}
|
|
167
|
+
case 'get_event': {
|
|
168
|
+
if (!id)
|
|
169
|
+
return { text: 'get_event needs an id', isError: true };
|
|
170
|
+
const { event: e } = await api.calendar('GET', `events/${encodeURIComponent(id)}`, workspaceId);
|
|
171
|
+
const rows = [
|
|
172
|
+
line(e),
|
|
173
|
+
...(e.location ? [`where: ${e.location}`] : []),
|
|
174
|
+
...(e.description ? [`description: ${e.description.slice(0, 2000)}`] : []),
|
|
175
|
+
...(e.attendees?.length ? [`attendees: ${e.attendees.map((a) => `${who(a)} (${a.response ?? 'needs-action'})`).join(', ')}`] : []),
|
|
176
|
+
];
|
|
177
|
+
return { text: rows.join('\n'), isError: false };
|
|
178
|
+
}
|
|
179
|
+
case 'respond_to_event': {
|
|
180
|
+
const response = String(args.response ?? '');
|
|
181
|
+
if (!id || !['accepted', 'declined', 'tentative'].includes(response))
|
|
182
|
+
return { text: 'respond_to_event needs an id and a response: accepted, declined or tentative', isError: true };
|
|
183
|
+
const comment = typeof args.comment === 'string' && args.comment.trim() ? args.comment.trim().slice(0, 2000) : undefined;
|
|
184
|
+
const r = await api.calendar('POST', `events/${encodeURIComponent(id)}/respond`, workspaceId, { response, ...(comment ? { comment } : {}) });
|
|
185
|
+
const told = r.replied === 'failed' ? ` — but the organizer was not told: ${r.replyError ?? 'unknown error'}` : r.replied === 'none' ? '' : ' — the organizer has your answer';
|
|
186
|
+
return { text: `answered ${response} to "${r.event.summary}"${told}`, isError: r.replied === 'failed' };
|
|
187
|
+
}
|
|
188
|
+
case 'find_free_time': {
|
|
189
|
+
const minutes = Number(args.duration_minutes), from = Date.parse(String(args.from ?? '')), to = Date.parse(String(args.to ?? ''));
|
|
190
|
+
if (!(minutes >= 5 && minutes <= 1440) || Number.isNaN(from) || Number.isNaN(to) || to <= from)
|
|
191
|
+
return { text: 'find_free_time needs duration_minutes (5 to 1440) and from before to (ISO times)', isError: true };
|
|
192
|
+
if (to - from > 31 * DAY)
|
|
193
|
+
return { text: 'find_free_time looks at most 31 days at a time; ask in parts', isError: true };
|
|
194
|
+
const zone = typeof args.timezone === 'string' && args.timezone.trim() ? args.timezone.trim() : 'UTC';
|
|
195
|
+
try {
|
|
196
|
+
new Intl.DateTimeFormat('en-US', { timeZone: zone });
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
return { text: `timezone: "${zone.slice(0, 60)}" is not an IANA time zone`, isError: true };
|
|
200
|
+
}
|
|
201
|
+
const wh = typeof args.working_hours === 'string' ? args.working_hours.trim() : '';
|
|
202
|
+
const m = /^(\d\d):(\d\d)-(\d\d):(\d\d)$/.exec(wh);
|
|
203
|
+
if (wh && wh !== 'any' && !m)
|
|
204
|
+
return { text: 'working_hours: HH:MM-HH:MM, or "any"', isError: true };
|
|
205
|
+
const hours = wh === 'any' ? null : m ? [Number(m[1]) * 60 + Number(m[2]), Number(m[3]) * 60 + Number(m[4])] : [9 * 60, 17 * 60];
|
|
206
|
+
const others = (Array.isArray(args.attendees) ? args.attendees : []).map((a) => personOf(String(a)));
|
|
207
|
+
if (others.some((p) => !p))
|
|
208
|
+
return { text: 'attendees: each one an email address', isError: true };
|
|
209
|
+
const window = { from: new Date(from).toISOString(), to: new Date(to).toISOString() };
|
|
210
|
+
// The agent's own busy time (no addresses: the server answers for the caller), and the attendees'.
|
|
211
|
+
const [mine, theirs] = await Promise.all([
|
|
212
|
+
api.calendar('POST', 'freebusy', workspaceId, { emails: [], ...window }),
|
|
213
|
+
others.length ? api.calendar('POST', 'freebusy', workspaceId, { emails: [...new Set(others.map((p) => p.email))], ...window }) : Promise.resolve({ busy: [], unknown: [] }),
|
|
214
|
+
]);
|
|
215
|
+
const busy = [...mine.busy, ...theirs.busy].flatMap((b) => b.intervals.map(([a, z]) => [Date.parse(a), Date.parse(z)]));
|
|
216
|
+
const slots = freeStretches(busy, from, to, minutes * 60_000, hours, zone).slice(0, 10);
|
|
217
|
+
const iso = (t) => new Date(t).toISOString().replace(':00.000Z', 'Z');
|
|
218
|
+
const rows = [
|
|
219
|
+
...(slots.length ? slots.map(([a, b]) => `${iso(a)} – ${iso(b)} (${Math.round((b - a) / 60_000)} min)`) : ['no free time of that length in the window']),
|
|
220
|
+
`working hours: ${hours ? `${wh && wh !== 'any' ? wh : '09:00-17:00'} Mon-Fri ${zone}` : 'any time'}`,
|
|
221
|
+
...(theirs.busy.length ? [`checked: ${theirs.busy.map((b) => b.email).join(', ')}`] : []),
|
|
222
|
+
...(theirs.unknown.length ? [`unknown (their calendars cannot be seen; say so when proposing a time): ${theirs.unknown.join(', ')}`] : []),
|
|
223
|
+
];
|
|
224
|
+
return { text: rows.join('\n'), isError: false };
|
|
225
|
+
}
|
|
226
|
+
case 'create_event': {
|
|
227
|
+
const summary = String(args.summary ?? '').trim(), start = String(args.start ?? '').trim(), end = String(args.end ?? '').trim();
|
|
228
|
+
if (!summary || !start || !end)
|
|
229
|
+
return { text: 'create_event needs summary, start and end', isError: true };
|
|
230
|
+
const attendees = (Array.isArray(args.attendees) ? args.attendees : []).map((a) => personOf(String(a)));
|
|
231
|
+
if (attendees.some((p) => !p))
|
|
232
|
+
return { text: 'attendees: each one "name@example.com" or "Name <name@example.com>"', isError: true };
|
|
233
|
+
const body = {
|
|
234
|
+
summary, start, end,
|
|
235
|
+
...(attendees.length ? { attendees } : {}),
|
|
236
|
+
...(typeof args.location === 'string' && args.location.trim() ? { location: args.location.trim().slice(0, 2000) } : {}),
|
|
237
|
+
...(typeof args.description === 'string' && args.description.trim() ? { description: args.description.slice(0, 32_000) } : {}),
|
|
238
|
+
};
|
|
239
|
+
const r = await api.calendar('POST', 'events', workspaceId, body);
|
|
240
|
+
const e = r.event;
|
|
241
|
+
const guests = (e.attendees ?? []).filter((a) => !a.self && a.email !== e.organizer?.email);
|
|
242
|
+
const members = guests.filter((a) => a.accountId).map((a) => a.email), outside = guests.filter((a) => !a.accountId).map((a) => a.email);
|
|
243
|
+
const rows = [
|
|
244
|
+
`created ${line(e)}`,
|
|
245
|
+
...(members.length ? [`on their calendars now: ${members.join(', ')}`] : []),
|
|
246
|
+
...(outside.length ? [r.invitationsSent === false ? `not emailed: ${outside.join(', ')}${r.invitationsNote ? ` (${r.invitationsNote})` : ''}` : `emailed an invitation: ${outside.join(', ')}`] : []),
|
|
247
|
+
];
|
|
248
|
+
return { text: rows.join('\n'), isError: false };
|
|
249
|
+
}
|
|
250
|
+
default:
|
|
251
|
+
return { text: `unknown tool: ${name}`, isError: true };
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
catch (err) {
|
|
255
|
+
return { text: `${name} failed: ${err.message}`, isError: true };
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=calendar-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calendar-tools.js","sourceRoot":"","sources":["../src/calendar-tools.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B;QACE,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,0LAA0L;QAC5L,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,8DAA8D,EAAE;gBACrG,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,iCAAiC,EAAE;aACvE;YACD,QAAQ,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC;SACzB;KACF;IACD;QACE,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,qJAAqJ;QAClK,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,IAAI,CAAC,EAAE;KACxH;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EACT,6JAA6J;QAC/J,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,EAAE,EAAE,EAAE,IAAI,EAAE,QA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C,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;gBACxI,MAAM,IAAI,GAAG;oBACX,WAAW,IAAI,CAAC,CAAC,CAAC,EAAE;oBACpB,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,2BAA2B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;oBAC5E,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,KAAK,KAAK,CAAC,CAAC,CAAC,gBAAgB,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,0BAA0B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBACtM,CAAC;gBACF,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YACnD,CAAC;YACD;gBACE,OAAO,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC5D,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,YAAa,GAAa,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAC9E,CAAC;AACH,CAAC"}
|
package/dist/catch-up.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { DeliveryMode, Event, EventFilter, PlatformEvent, SubscriptionDTO } from '@flow/shared';
|
|
2
2
|
import type { FlowApi } from './api.js';
|
|
3
3
|
export declare const CATCH_UP_TYPES: string[];
|
|
4
|
+
/** The events addressed to the agent's account alone that ask it for a turn: the job subscription's, and what `onAccount` gets. */
|
|
5
|
+
export declare const ACCOUNT_TYPES: string[];
|
|
4
6
|
/** How many answered message ids are remembered. */
|
|
5
7
|
export declare const HANDLED_MAX = 500;
|
|
6
8
|
export type SubscriptionApi = Pick<FlowApi, 'listSubscriptions' | 'createSubscription' | 'readSubscription' | 'ackSubscription'>;
|
|
@@ -11,7 +13,7 @@ export interface SubscriptionSpec {
|
|
|
11
13
|
filter: EventFilter;
|
|
12
14
|
delivery: DeliveryMode;
|
|
13
15
|
}
|
|
14
|
-
/** The live path for jobs: a poke on the socket when an `agent.job` for this account comes. */
|
|
16
|
+
/** The live path for jobs and invitations: a poke on the socket when an `agent.job` or `calendar.invited` for this account comes. */
|
|
15
17
|
export declare const jobsSpec: (agentId: string) => SubscriptionSpec;
|
|
16
18
|
/**
|
|
17
19
|
* The bridge's subscription in the organization: found by name, or made (starting at the log's head). `outdated` when
|
|
@@ -22,7 +24,8 @@ export declare function ensureSubscription(api: SubscriptionApi, workspaceId: st
|
|
|
22
24
|
}>;
|
|
23
25
|
/**
|
|
24
26
|
* Reads the subscription without waiting, page by page until it is empty, handing each Chat event to `feed` in order
|
|
25
|
-
* and acking each page's `next` once its events are fed. Returns the events fed
|
|
27
|
+
* (and each of ACCOUNT_TYPES to `onJob`) and acking each page's `next` once its events are fed. Returns the events fed
|
|
28
|
+
* and the cursor reached.
|
|
26
29
|
*/
|
|
27
30
|
export declare function catchUp(api: SubscriptionApi, workspaceId: string, sub: Pick<SubscriptionDTO, 'id' | 'cursor'>, feed: (event: Event) => Promise<void> | void, log: (msg: string) => void, onJob?: (event: PlatformEvent) => Promise<void> | void): Promise<{
|
|
28
31
|
events: number;
|
package/dist/catch-up.js
CHANGED
|
@@ -6,11 +6,14 @@
|
|
|
6
6
|
// kept in a state file beside the config, makes sure no message is answered twice across a restart.
|
|
7
7
|
// Wake jobs (phase 2.4) arrive as `agent.job` events on the agent's own account: the subscription catches up on them too,
|
|
8
8
|
// and a second one, `bridge-jobs:<agent id>` with `socket` delivery, pokes the socket when one comes while connected.
|
|
9
|
-
// Job ids taken are remembered in the same state file, so a job is run once.
|
|
9
|
+
// Job ids taken are remembered in the same state file, so a job is run once. Invitations (phase 4.2) come the same way:
|
|
10
|
+
// `calendar.invited` on the agent's own account, in both subscriptions, each event id answered once (state file too).
|
|
10
11
|
import fs from 'node:fs';
|
|
11
12
|
import path from 'node:path';
|
|
12
13
|
import { socketEventOf } from './gateway.js';
|
|
13
|
-
export const CATCH_UP_TYPES = ['chat.message.created', 'chat.thread.reply', 'chat.reaction.added', 'agent.job'];
|
|
14
|
+
export const CATCH_UP_TYPES = ['chat.message.created', 'chat.thread.reply', 'chat.reaction.added', 'agent.job', 'calendar.invited'];
|
|
15
|
+
/** The events addressed to the agent's account alone that ask it for a turn: the job subscription's, and what `onAccount` gets. */
|
|
16
|
+
export const ACCOUNT_TYPES = ['agent.job', 'calendar.invited'];
|
|
14
17
|
/** How many answered message ids are remembered. */
|
|
15
18
|
export const HANDLED_MAX = 500;
|
|
16
19
|
/** A bound on one catch-up's pages, so a server that never runs dry cannot hold the start-up forever. */
|
|
@@ -18,8 +21,8 @@ const MAX_PAGES = 100;
|
|
|
18
21
|
export const subscriptionName = (agentId) => `bridge:${agentId}`;
|
|
19
22
|
export const jobsSubscriptionName = (agentId) => `bridge-jobs:${agentId}`;
|
|
20
23
|
const mainSpec = (agentId) => ({ name: subscriptionName(agentId), filter: { types: CATCH_UP_TYPES }, delivery: 'pull' });
|
|
21
|
-
/** The live path for jobs: a poke on the socket when an `agent.job` for this account comes. */
|
|
22
|
-
export const jobsSpec = (agentId) => ({ name: jobsSubscriptionName(agentId), filter: { types:
|
|
24
|
+
/** The live path for jobs and invitations: a poke on the socket when an `agent.job` or `calendar.invited` for this account comes. */
|
|
25
|
+
export const jobsSpec = (agentId) => ({ name: jobsSubscriptionName(agentId), filter: { types: ACCOUNT_TYPES, self: true }, delivery: 'socket' });
|
|
23
26
|
/**
|
|
24
27
|
* The bridge's subscription in the organization: found by name, or made (starting at the log's head). `outdated` when
|
|
25
28
|
* one made by an older bridge lists types without some of today's (`agent.job`): it is caught up, then replaced.
|
|
@@ -35,7 +38,8 @@ export async function ensureSubscription(api, workspaceId, agentId, spec = mainS
|
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Reads the subscription without waiting, page by page until it is empty, handing each Chat event to `feed` in order
|
|
38
|
-
* and acking each page's `next` once its events are fed. Returns the events fed
|
|
41
|
+
* (and each of ACCOUNT_TYPES to `onJob`) and acking each page's `next` once its events are fed. Returns the events fed
|
|
42
|
+
* and the cursor reached.
|
|
39
43
|
*/
|
|
40
44
|
export async function catchUp(api, workspaceId, sub, feed, log, onJob) {
|
|
41
45
|
let cursor = sub.cursor;
|
|
@@ -46,7 +50,7 @@ export async function catchUp(api, workspaceId, sub, feed, log, onJob) {
|
|
|
46
50
|
log(`catch-up: events ${out.gap.from}–${out.gap.to} aged out of the log before they were read`);
|
|
47
51
|
for (const e of out.events) {
|
|
48
52
|
const event = socketEventOf(e);
|
|
49
|
-
if (!event && !(e.type
|
|
53
|
+
if (!event && !(ACCOUNT_TYPES.includes(e.type) && onJob))
|
|
50
54
|
continue;
|
|
51
55
|
events++;
|
|
52
56
|
try {
|
package/dist/catch-up.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catch-up.js","sourceRoot":"","sources":["../src/catch-up.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,sHAAsH;AACtH,oHAAoH;AACpH,wHAAwH;AACxH,wHAAwH;AACxH,oGAAoG;AACpG,0HAA0H;AAC1H,sHAAsH;AACtH,
|
|
1
|
+
{"version":3,"file":"catch-up.js","sourceRoot":"","sources":["../src/catch-up.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,sHAAsH;AACtH,oHAAoH;AACpH,wHAAwH;AACxH,wHAAwH;AACxH,oGAAoG;AACpG,0HAA0H;AAC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C,IAAI,MAAM,CAAC;gBAC/B,IAAI,GAAG,GAA4B,EAAE,CAAC;gBACtC,IAAI,CAAC;oBACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAA4B,CAAC;gBAClF,CAAC;gBAAC,MAAM,CAAC;oBACP,uDAAuD;gBACzD,CAAC;gBACD,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzF,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,cAAc,IAAI,CAAC,IAAI,iBAAkB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,QAAQ,CAAC,EAAU;QACzB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAClB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACjB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG;YAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAG,CAAC,CAAC;IACxE,CAAC;CACF"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// operations (list_channels, list_users, join_channel, leave_channel,
|
|
4
4
|
// create_channel, invite_to_channel, read_messages), and self-service profile
|
|
5
5
|
// bits (set_avatar) against /v1
|
|
6
|
-
// with the agent token
|
|
6
|
+
// with the agent token, and the agent's calendar (list_my_events, get_event, respond_to_event, find_free_time,
|
|
7
|
+
// create_event; calendar-tools.ts).
|
|
7
8
|
//
|
|
8
9
|
// Hand-rolled newline-delimited JSON-RPC (the MCP stdio transport) — a small
|
|
9
10
|
// fixed tool surface; no SDK dependency needed. Conversation context
|
|
@@ -16,6 +17,7 @@ import readline from 'node:readline';
|
|
|
16
17
|
import { FlowApi, FlowApiError } from './api.js';
|
|
17
18
|
import { attachmentFilename, formatAttachments } from './attachments.js';
|
|
18
19
|
import { deliverArtifact, deliveryId, inlineArtifactFile } from './artifact-delivery.js';
|
|
20
|
+
import { CALENDAR_TOOLS, CALENDAR_TOOL_NAMES, calendarTool } from './calendar-tools.js';
|
|
19
21
|
/** How a channel is named in tool output — DMs have no name, only a kind. */
|
|
20
22
|
const channelLabel = (c) => c.name ? `#${c.name}` : `(${c.kind})`;
|
|
21
23
|
/** One member as a `list_users` line. The email is member-visible data the
|
|
@@ -344,6 +346,7 @@ const TOOLS = [
|
|
|
344
346
|
required: ['fileId'],
|
|
345
347
|
},
|
|
346
348
|
},
|
|
349
|
+
...CALENDAR_TOOLS,
|
|
347
350
|
];
|
|
348
351
|
const MIME_BY_EXT = {
|
|
349
352
|
'.png': 'image/png',
|
|
@@ -508,6 +511,10 @@ export async function runMcpServer() {
|
|
|
508
511
|
return { fileId: file.id, label: label ?? filename, ownsFile: true, fingerprint: deliveryId(filename, mime, data.toString('base64')) };
|
|
509
512
|
}
|
|
510
513
|
async function callTool(name, args) {
|
|
514
|
+
if (CALENDAR_TOOL_NAMES.has(name)) {
|
|
515
|
+
const out = await calendarTool(api, workspaceId, name, args);
|
|
516
|
+
return toolText(out.text, out.isError);
|
|
517
|
+
}
|
|
511
518
|
const { channelId, threadRootId } = resolveMessageTarget(args, {
|
|
512
519
|
channelId: defaultChannelId,
|
|
513
520
|
threadRootId: defaultThreadRootId,
|