@agent-native/scheduling 0.3.2 → 0.4.0-nightly-20261118182504
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/server/providers/google-calendar.d.ts +12 -0
- package/dist/server/providers/google-calendar.d.ts.map +1 -1
- package/dist/server/providers/google-calendar.js +22 -3
- package/dist/server/providers/google-calendar.js.map +1 -1
- package/docs/llms-full.txt +14 -0
- package/docs/llms.txt +1 -0
- package/docs/providers.md +13 -0
- package/package.json +4 -4
- package/src/server/providers/google-calendar-gates.test.ts +252 -0
- package/src/server/providers/google-calendar.ts +47 -3
|
@@ -3,12 +3,24 @@ export interface GoogleCalendarProviderConfig {
|
|
|
3
3
|
clientId: string;
|
|
4
4
|
clientSecret: string;
|
|
5
5
|
getAccessToken: (credentialId: string) => Promise<string>;
|
|
6
|
+
/**
|
|
7
|
+
* The Google account a credential belongs to, such as its connect-time
|
|
8
|
+
* email. Provider call gates registered for "google_calendar" receive it as
|
|
9
|
+
* the request's `accountId`; return null or undefined when the credential
|
|
10
|
+
* records none, and throw when it cannot be read.
|
|
11
|
+
*/
|
|
12
|
+
getAccountIdentity?: (credentialId: string) => Promise<string | null | undefined>;
|
|
6
13
|
updateTokens?: (credentialId: string, tokens: {
|
|
7
14
|
accessToken: string;
|
|
8
15
|
refreshToken?: string;
|
|
9
16
|
expiresAt?: Date;
|
|
10
17
|
}) => Promise<void>;
|
|
11
18
|
markInvalid?: (credentialId: string) => Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* The consuming app's id, which provider call gates receive as the
|
|
21
|
+
* request's `appId`. Defaults to "scheduling".
|
|
22
|
+
*/
|
|
23
|
+
appId?: string;
|
|
12
24
|
}
|
|
13
25
|
export declare function createGoogleCalendarProvider(config: GoogleCalendarProviderConfig): CalendarProvider;
|
|
14
26
|
//# sourceMappingURL=google-calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-calendar.d.ts","sourceRoot":"","sources":["../../../src/server/providers/google-calendar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"google-calendar.d.ts","sourceRoot":"","sources":["../../../src/server/providers/google-calendar.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA+BnD,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1D;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,CACnB,YAAY,EAAE,MAAM,KACjB,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,CACb,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,IAAI,CAAA;KAAE,KACrE,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAOD,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,4BAA4B,GACnC,gBAAgB,CA8PlB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fetchWithProviderCallGate, isProviderCallGateRefusal, markProviderCallGateRefusal, precheckGatedProviderCall, } from "@agent-native/core/provider-api/call-gates";
|
|
1
2
|
/**
|
|
2
3
|
* Google Calendar provider.
|
|
3
4
|
*
|
|
@@ -43,14 +44,32 @@ const SCOPES = [
|
|
|
43
44
|
];
|
|
44
45
|
export function createGoogleCalendarProvider(config) {
|
|
45
46
|
async function apiCall(credentialId, url, init) {
|
|
47
|
+
// A paused provider must refuse before the token lookup can refresh it.
|
|
48
|
+
const prechecked = await precheckGatedProviderCall("google_calendar", url);
|
|
46
49
|
const token = await config.getAccessToken(credentialId);
|
|
47
50
|
const headers = new Headers(init?.headers);
|
|
48
51
|
headers.set("authorization", `Bearer ${token}`);
|
|
49
52
|
headers.set("content-type", "application/json");
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
const getAccountIdentity = config.getAccountIdentity;
|
|
54
|
+
const res = await fetchWithProviderCallGate({
|
|
55
|
+
providerId: "google_calendar",
|
|
56
|
+
appId: config.appId ?? "scheduling",
|
|
57
|
+
url,
|
|
58
|
+
init: { ...init, headers },
|
|
59
|
+
connectionId: credentialId,
|
|
60
|
+
prechecked,
|
|
61
|
+
...(getAccountIdentity
|
|
62
|
+
? { resolveAccountId: () => getAccountIdentity(credentialId) }
|
|
63
|
+
: {}),
|
|
53
64
|
});
|
|
65
|
+
if (isProviderCallGateRefusal(res)) {
|
|
66
|
+
if (res.status === 429) {
|
|
67
|
+
throw new CalendarLookupRateLimitedError(`Google Calendar: held by a provider call gate (${res.status} ${res.statusText})`, parseRetryAfterSeconds(res.headers.get("retry-after")));
|
|
68
|
+
}
|
|
69
|
+
const refusal = new Error(`Google Calendar: refused by a provider call gate (${res.status} ${res.statusText})`);
|
|
70
|
+
markProviderCallGateRefusal(refusal);
|
|
71
|
+
throw refusal;
|
|
72
|
+
}
|
|
54
73
|
if (res.status === 401 || res.status === 403 || res.status === 429) {
|
|
55
74
|
const body = await res.text();
|
|
56
75
|
// Google sends rate and quota limits as 403 (or 429); those are
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-calendar.js","sourceRoot":"","sources":["../../../src/server/providers/google-calendar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"google-calendar.js","sourceRoot":"","sources":["../../../src/server/providers/google-calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,yBAAyB,EAC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CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/docs/llms-full.txt
CHANGED
|
@@ -246,6 +246,7 @@ registerCalendarProvider(createGoogleCalendarProvider({
|
|
|
246
246
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
247
247
|
getAccessToken: async (credentialId) =>
|
|
248
248
|
(await readCalendarCredential(credentialId)).accessToken,
|
|
249
|
+
// Optional: the account provider call gates see for this credential.
|
|
249
250
|
getAccountIdentity: async (credentialId) =>
|
|
250
251
|
(await readCalendarCredential(credentialId))?.externalEmail,
|
|
251
252
|
}));
|
|
@@ -355,6 +356,19 @@ your token store. The package's `setSchedulingContext()` doesn't touch
|
|
|
355
356
|
tokens; consumers typically use core's `oauth_tokens` and pass a
|
|
356
357
|
`getAccessToken(credentialId)` callback.
|
|
357
358
|
|
|
359
|
+
### Provider call gates
|
|
360
|
+
|
|
361
|
+
The built-in Google Calendar provider sends every Calendar API request
|
|
362
|
+
through core's provider call gates (`fetchWithProviderCallGate` from
|
|
363
|
+
`@agent-native/core/provider-api/call-gates`) with provider id
|
|
364
|
+
`google_calendar` and app id `scheduling`. A gate a deployment registers with
|
|
365
|
+
`registerProviderCallGate()` can pause, budget, or rate-limit free/busy and
|
|
366
|
+
event requests the same way it governs provider-api requests; with no gate
|
|
367
|
+
registered the request is sent unchanged. Pass `getAccountIdentity` to tell
|
|
368
|
+
the gate which Google account a credential belongs to: return `null` when the
|
|
369
|
+
credential records none, and throw when it can't be read, so the gate sees
|
|
370
|
+
`accountIdError` instead of a missing account.
|
|
371
|
+
|
|
358
372
|
## VideoProvider
|
|
359
373
|
|
|
360
374
|
```ts
|
package/docs/llms.txt
CHANGED
|
@@ -62,6 +62,7 @@ registerCalendarProvider(createGoogleCalendarProvider({
|
|
|
62
62
|
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
|
|
63
63
|
getAccessToken: async (credentialId) =>
|
|
64
64
|
(await readCalendarCredential(credentialId)).accessToken,
|
|
65
|
+
// Optional: the account provider call gates see for this credential.
|
|
65
66
|
getAccountIdentity: async (credentialId) =>
|
|
66
67
|
(await readCalendarCredential(credentialId))?.externalEmail,
|
|
67
68
|
}));
|
package/docs/providers.md
CHANGED
|
@@ -60,6 +60,19 @@ your token store. The package's `setSchedulingContext()` doesn't touch
|
|
|
60
60
|
tokens; consumers typically use core's `oauth_tokens` and pass a
|
|
61
61
|
`getAccessToken(credentialId)` callback.
|
|
62
62
|
|
|
63
|
+
### Provider call gates
|
|
64
|
+
|
|
65
|
+
The built-in Google Calendar provider sends every Calendar API request
|
|
66
|
+
through core's provider call gates (`fetchWithProviderCallGate` from
|
|
67
|
+
`@agent-native/core/provider-api/call-gates`) with provider id
|
|
68
|
+
`google_calendar` and app id `scheduling`. A gate a deployment registers with
|
|
69
|
+
`registerProviderCallGate()` can pause, budget, or rate-limit free/busy and
|
|
70
|
+
event requests the same way it governs provider-api requests; with no gate
|
|
71
|
+
registered the request is sent unchanged. Pass `getAccountIdentity` to tell
|
|
72
|
+
the gate which Google account a credential belongs to: return `null` when the
|
|
73
|
+
credential records none, and throw when it can't be read, so the gate sees
|
|
74
|
+
`accountIdError` instead of a missing account.
|
|
75
|
+
|
|
63
76
|
## VideoProvider
|
|
64
77
|
|
|
65
78
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/scheduling",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-nightly-20261118182504",
|
|
4
4
|
"description": "Scheduling primitives for agent-native apps — event types, availability, bookings, team scheduling, workflows, and routing forms.",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"nanoid": "^5.1.9",
|
|
57
57
|
"rrule": "^2.8.1",
|
|
58
58
|
"zod": "^4.3.6",
|
|
59
|
-
"@agent-native/toolkit": "^0.
|
|
59
|
+
"@agent-native/toolkit": "^0.232.0-nightly-20261118182504"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@tabler/icons-react": "3.44.0",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"react": "^19.2.5",
|
|
67
67
|
"typescript-7": "npm:typescript@^7.0.2",
|
|
68
68
|
"vitest": "^4.1.5",
|
|
69
|
-
"@agent-native/core": "0.
|
|
69
|
+
"@agent-native/core": "0.232.0-nightly-20261118182504"
|
|
70
70
|
},
|
|
71
71
|
"peerDependencies": {
|
|
72
|
-
"@agent-native/core": "
|
|
72
|
+
"@agent-native/core": "0.232.0-nightly-20261118182504",
|
|
73
73
|
"@tabler/icons-react": "^3.41.1",
|
|
74
74
|
"drizzle-orm": ">=0.45",
|
|
75
75
|
"react": ">=18",
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isProviderCallGateRefusal,
|
|
3
|
+
ProviderCallGateAdmissionTimeoutError,
|
|
4
|
+
registerProviderCallGate,
|
|
5
|
+
type ProviderCallGate,
|
|
6
|
+
type ProviderCallGateRequest,
|
|
7
|
+
} from "@agent-native/core/provider-api/call-gates";
|
|
8
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
9
|
+
|
|
10
|
+
import { CalendarLookupRateLimitedError } from "./errors.js";
|
|
11
|
+
import {
|
|
12
|
+
createGoogleCalendarProvider,
|
|
13
|
+
type GoogleCalendarProviderConfig,
|
|
14
|
+
} from "./google-calendar.js";
|
|
15
|
+
|
|
16
|
+
const START = new Date("2030-01-07T00:00:00.000Z");
|
|
17
|
+
const END = new Date("2030-01-08T00:00:00.000Z");
|
|
18
|
+
|
|
19
|
+
const removers: (() => void)[] = [];
|
|
20
|
+
|
|
21
|
+
function registerGate(overrides: Partial<ProviderCallGate> = {}) {
|
|
22
|
+
const prepared: ProviderCallGateRequest[] = [];
|
|
23
|
+
removers.push(
|
|
24
|
+
registerProviderCallGate({
|
|
25
|
+
id: "example-calendar-gate",
|
|
26
|
+
matches: ({ providerId }) => providerId === "google_calendar",
|
|
27
|
+
prepare: (request) => {
|
|
28
|
+
prepared.push(request);
|
|
29
|
+
return async () => undefined;
|
|
30
|
+
},
|
|
31
|
+
...overrides,
|
|
32
|
+
}),
|
|
33
|
+
);
|
|
34
|
+
return prepared;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function stubFetch() {
|
|
38
|
+
const fetchMock = vi.fn(
|
|
39
|
+
async () =>
|
|
40
|
+
new Response(
|
|
41
|
+
JSON.stringify({ calendars: { "host@example.com": { busy: [] } } }),
|
|
42
|
+
{ status: 200 },
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
vi.stubGlobal("fetch", fetchMock);
|
|
46
|
+
return fetchMock;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function busy(extra: Partial<GoogleCalendarProviderConfig> = {}) {
|
|
50
|
+
return createGoogleCalendarProvider({
|
|
51
|
+
clientId: "client-example",
|
|
52
|
+
clientSecret: "secret-example",
|
|
53
|
+
getAccessToken: async () => "token-example",
|
|
54
|
+
...extra,
|
|
55
|
+
}).getBusy({
|
|
56
|
+
credentialId: "credential-example",
|
|
57
|
+
calendarExternalIds: ["host@example.com"],
|
|
58
|
+
start: START,
|
|
59
|
+
end: END,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
afterEach(() => {
|
|
64
|
+
for (const remove of removers.splice(0)) remove();
|
|
65
|
+
vi.unstubAllGlobals();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe("Google Calendar provider call gates", () => {
|
|
69
|
+
it("sends the request unchanged when no gate is registered", async () => {
|
|
70
|
+
const fetchMock = stubFetch();
|
|
71
|
+
|
|
72
|
+
await expect(busy()).resolves.toEqual([]);
|
|
73
|
+
|
|
74
|
+
expect(fetchMock).toHaveBeenCalledOnce();
|
|
75
|
+
const [url, init] = fetchMock.mock.calls[0] as unknown as [
|
|
76
|
+
string,
|
|
77
|
+
RequestInit,
|
|
78
|
+
];
|
|
79
|
+
expect(url).toBe("https://www.googleapis.com/calendar/v3/freeBusy");
|
|
80
|
+
expect(init.method).toBe("POST");
|
|
81
|
+
expect(new Headers(init.headers).get("authorization")).toBe(
|
|
82
|
+
"Bearer token-example",
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it("hands the gate the credential and its account identity", async () => {
|
|
87
|
+
stubFetch();
|
|
88
|
+
const prepared = registerGate();
|
|
89
|
+
|
|
90
|
+
await busy({ getAccountIdentity: async () => "host@example.com" });
|
|
91
|
+
|
|
92
|
+
expect(prepared).toHaveLength(1);
|
|
93
|
+
expect(prepared[0]).toMatchObject({
|
|
94
|
+
providerId: "google_calendar",
|
|
95
|
+
appId: "scheduling",
|
|
96
|
+
method: "POST",
|
|
97
|
+
accountId: "host@example.com",
|
|
98
|
+
connectionId: "credential-example",
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("runs the gate precheck once per request", async () => {
|
|
103
|
+
stubFetch();
|
|
104
|
+
const precheck = vi.fn(async () => undefined);
|
|
105
|
+
registerGate({ precheck });
|
|
106
|
+
|
|
107
|
+
await busy();
|
|
108
|
+
|
|
109
|
+
expect(precheck).toHaveBeenCalledOnce();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("prechecks a gate that claims Calendar requests by URL before the token lookup", async () => {
|
|
113
|
+
stubFetch();
|
|
114
|
+
const order: string[] = [];
|
|
115
|
+
removers.push(
|
|
116
|
+
registerProviderCallGate({
|
|
117
|
+
id: "url-calendar-gate",
|
|
118
|
+
matches: ({ url }) =>
|
|
119
|
+
url?.startsWith("https://www.googleapis.com/calendar/") === true,
|
|
120
|
+
precheck: async () => {
|
|
121
|
+
order.push("precheck");
|
|
122
|
+
},
|
|
123
|
+
prepare: () => async () => undefined,
|
|
124
|
+
}),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
await busy({
|
|
128
|
+
getAccessToken: async () => {
|
|
129
|
+
order.push("token");
|
|
130
|
+
return "token-example";
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
expect(order).toEqual(["precheck", "token"]);
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("names the consuming app to the gate when the consumer sets one", async () => {
|
|
138
|
+
stubFetch();
|
|
139
|
+
const prepared = registerGate();
|
|
140
|
+
|
|
141
|
+
await busy({ appId: "calendar" });
|
|
142
|
+
|
|
143
|
+
expect(prepared[0]).toMatchObject({
|
|
144
|
+
providerId: "google_calendar",
|
|
145
|
+
appId: "calendar",
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
it("tells the gate when the account identity could not be read", async () => {
|
|
150
|
+
stubFetch();
|
|
151
|
+
const prepared = registerGate();
|
|
152
|
+
const failure = new Error("identity unreadable");
|
|
153
|
+
|
|
154
|
+
await busy({
|
|
155
|
+
getAccountIdentity: async () => {
|
|
156
|
+
throw failure;
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
expect(prepared[0]?.accountId).toBeUndefined();
|
|
161
|
+
expect(prepared[0]?.accountIdError).toBe(failure);
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
it("does not send a request the gate refuses", async () => {
|
|
165
|
+
const fetchMock = stubFetch();
|
|
166
|
+
registerGate({
|
|
167
|
+
precheck: async () => {
|
|
168
|
+
throw new Error("Google Calendar is paused");
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await expect(busy()).rejects.toThrow("Google Calendar is paused");
|
|
173
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("reports a budget refusal response as a retryable throttle", async () => {
|
|
177
|
+
const fetchMock = stubFetch();
|
|
178
|
+
registerGate({
|
|
179
|
+
prepare: () => async () => {
|
|
180
|
+
throw new Error("budget exhausted");
|
|
181
|
+
},
|
|
182
|
+
refusalResponse: () => ({
|
|
183
|
+
status: 429,
|
|
184
|
+
statusText: "Budget exhausted",
|
|
185
|
+
headers: { "retry-after": "12" },
|
|
186
|
+
}),
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const error = await busy().catch((caught: unknown) => caught);
|
|
190
|
+
|
|
191
|
+
expect(error).toBeInstanceOf(CalendarLookupRateLimitedError);
|
|
192
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it("refuses a paused provider before resolving the access token", async () => {
|
|
196
|
+
const fetchMock = stubFetch();
|
|
197
|
+
const getAccessToken = vi.fn(async () => "token-example");
|
|
198
|
+
registerGate({
|
|
199
|
+
precheck: async () => {
|
|
200
|
+
throw new Error("Google Calendar is paused");
|
|
201
|
+
},
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
await expect(busy({ getAccessToken })).rejects.toThrow(
|
|
205
|
+
"Google Calendar is paused",
|
|
206
|
+
);
|
|
207
|
+
expect(getAccessToken).not.toHaveBeenCalled();
|
|
208
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("refuses a precheck that never settles before resolving the access token", async () => {
|
|
212
|
+
vi.useFakeTimers();
|
|
213
|
+
try {
|
|
214
|
+
const fetchMock = stubFetch();
|
|
215
|
+
const getAccessToken = vi.fn(async () => "token-example");
|
|
216
|
+
registerGate({ precheck: () => new Promise<void>(() => {}) });
|
|
217
|
+
|
|
218
|
+
const pending = busy({ getAccessToken }).catch(
|
|
219
|
+
(caught: unknown) => caught,
|
|
220
|
+
);
|
|
221
|
+
await vi.advanceTimersByTimeAsync(2_000);
|
|
222
|
+
const error = await pending;
|
|
223
|
+
|
|
224
|
+
expect(error).toBeInstanceOf(ProviderCallGateAdmissionTimeoutError);
|
|
225
|
+
expect(isProviderCallGateRefusal(error)).toBe(true);
|
|
226
|
+
expect(getAccessToken).not.toHaveBeenCalled();
|
|
227
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
228
|
+
} finally {
|
|
229
|
+
vi.useRealTimers();
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
it("keeps the credential valid when a gate answers with a 403 refusal", async () => {
|
|
234
|
+
const fetchMock = stubFetch();
|
|
235
|
+
const markInvalid = vi.fn(async () => undefined);
|
|
236
|
+
registerGate({
|
|
237
|
+
prepare: () => async () => {
|
|
238
|
+
throw new Error("not allowed");
|
|
239
|
+
},
|
|
240
|
+
refusalResponse: () => ({ status: 403, statusText: "Forbidden" }),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const error = await busy({ markInvalid }).catch(
|
|
244
|
+
(caught: unknown) => caught,
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
expect(error).toBeInstanceOf(Error);
|
|
248
|
+
expect(isProviderCallGateRefusal(error)).toBe(true);
|
|
249
|
+
expect(markInvalid).not.toHaveBeenCalled();
|
|
250
|
+
expect(fetchMock).not.toHaveBeenCalled();
|
|
251
|
+
});
|
|
252
|
+
});
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fetchWithProviderCallGate,
|
|
3
|
+
isProviderCallGateRefusal,
|
|
4
|
+
markProviderCallGateRefusal,
|
|
5
|
+
precheckGatedProviderCall,
|
|
6
|
+
} from "@agent-native/core/provider-api/call-gates";
|
|
7
|
+
|
|
1
8
|
import type { BusyInterval } from "../../shared/index.js";
|
|
2
9
|
/**
|
|
3
10
|
* Google Calendar provider.
|
|
@@ -50,11 +57,25 @@ export interface GoogleCalendarProviderConfig {
|
|
|
50
57
|
clientId: string;
|
|
51
58
|
clientSecret: string;
|
|
52
59
|
getAccessToken: (credentialId: string) => Promise<string>;
|
|
60
|
+
/**
|
|
61
|
+
* The Google account a credential belongs to, such as its connect-time
|
|
62
|
+
* email. Provider call gates registered for "google_calendar" receive it as
|
|
63
|
+
* the request's `accountId`; return null or undefined when the credential
|
|
64
|
+
* records none, and throw when it cannot be read.
|
|
65
|
+
*/
|
|
66
|
+
getAccountIdentity?: (
|
|
67
|
+
credentialId: string,
|
|
68
|
+
) => Promise<string | null | undefined>;
|
|
53
69
|
updateTokens?: (
|
|
54
70
|
credentialId: string,
|
|
55
71
|
tokens: { accessToken: string; refreshToken?: string; expiresAt?: Date },
|
|
56
72
|
) => Promise<void>;
|
|
57
73
|
markInvalid?: (credentialId: string) => Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* The consuming app's id, which provider call gates receive as the
|
|
76
|
+
* request's `appId`. Defaults to "scheduling".
|
|
77
|
+
*/
|
|
78
|
+
appId?: string;
|
|
58
79
|
}
|
|
59
80
|
|
|
60
81
|
const SCOPES = [
|
|
@@ -70,14 +91,37 @@ export function createGoogleCalendarProvider(
|
|
|
70
91
|
url: string,
|
|
71
92
|
init?: RequestInit,
|
|
72
93
|
): Promise<T> {
|
|
94
|
+
// A paused provider must refuse before the token lookup can refresh it.
|
|
95
|
+
const prechecked = await precheckGatedProviderCall("google_calendar", url);
|
|
73
96
|
const token = await config.getAccessToken(credentialId);
|
|
74
97
|
const headers = new Headers(init?.headers);
|
|
75
98
|
headers.set("authorization", `Bearer ${token}`);
|
|
76
99
|
headers.set("content-type", "application/json");
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
100
|
+
const getAccountIdentity = config.getAccountIdentity;
|
|
101
|
+
const res = await fetchWithProviderCallGate({
|
|
102
|
+
providerId: "google_calendar",
|
|
103
|
+
appId: config.appId ?? "scheduling",
|
|
104
|
+
url,
|
|
105
|
+
init: { ...init, headers },
|
|
106
|
+
connectionId: credentialId,
|
|
107
|
+
prechecked,
|
|
108
|
+
...(getAccountIdentity
|
|
109
|
+
? { resolveAccountId: () => getAccountIdentity(credentialId) }
|
|
110
|
+
: {}),
|
|
80
111
|
});
|
|
112
|
+
if (isProviderCallGateRefusal(res)) {
|
|
113
|
+
if (res.status === 429) {
|
|
114
|
+
throw new CalendarLookupRateLimitedError(
|
|
115
|
+
`Google Calendar: held by a provider call gate (${res.status} ${res.statusText})`,
|
|
116
|
+
parseRetryAfterSeconds(res.headers.get("retry-after")),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
const refusal = new Error(
|
|
120
|
+
`Google Calendar: refused by a provider call gate (${res.status} ${res.statusText})`,
|
|
121
|
+
);
|
|
122
|
+
markProviderCallGateRefusal(refusal);
|
|
123
|
+
throw refusal;
|
|
124
|
+
}
|
|
81
125
|
if (res.status === 401 || res.status === 403 || res.status === 429) {
|
|
82
126
|
const body = await res.text();
|
|
83
127
|
// Google sends rate and quota limits as 403 (or 429); those are
|