@aaronsb/google-workspace-mcp 4.6.0 → 4.7.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/build/accounts/oauth.js +6 -1
- package/build/accounts/oauth.js.map +1 -1
- package/build/factory/manifest/gmail.yaml +211 -6
- package/build/factory/safety.js +35 -11
- package/build/factory/safety.js.map +1 -1
- package/build/server/call-context.d.ts +12 -0
- package/build/server/call-context.js +20 -0
- package/build/server/call-context.js.map +1 -0
- package/build/server/handler.d.ts +4 -0
- package/build/server/handler.js +9 -1
- package/build/server/handler.js.map +1 -1
- package/build/server/preview-gate.d.ts +36 -0
- package/build/server/preview-gate.js +105 -0
- package/build/server/preview-gate.js.map +1 -0
- package/build/server/scratchpad/adapters/import-drive.js +12 -31
- package/build/server/scratchpad/adapters/import-drive.js.map +1 -1
- package/build/server/scratchpad/adapters/send-workspace.js +23 -20
- package/build/server/scratchpad/adapters/send-workspace.js.map +1 -1
- package/build/server/scratchpad/handler.js +28 -30
- package/build/server/scratchpad/handler.js.map +1 -1
- package/build/server/scratchpad/manager.d.ts +1 -0
- package/build/server/scratchpad/manager.js.map +1 -1
- package/build/server/tools.js +2 -1
- package/build/server/tools.js.map +1 -1
- package/build/services/drive/patch.js +4 -23
- package/build/services/drive/patch.js.map +1 -1
- package/build/services/drive/workspace-download.d.ts +24 -0
- package/build/services/drive/workspace-download.js +50 -0
- package/build/services/drive/workspace-download.js.map +1 -0
- package/build/services/gmail/filters.d.ts +88 -0
- package/build/services/gmail/filters.js +504 -0
- package/build/services/gmail/filters.js.map +1 -0
- package/build/services/gmail/hydrate.d.ts +29 -0
- package/build/services/gmail/hydrate.js +116 -0
- package/build/services/gmail/hydrate.js.map +1 -0
- package/build/services/gmail/patch.js +72 -116
- package/build/services/gmail/patch.js.map +1 -1
- package/build/version.d.ts +1 -1
- package/build/version.js +1 -1
- package/package.json +1 -1
package/build/accounts/oauth.js
CHANGED
|
@@ -8,7 +8,12 @@ const GOOGLE_USERINFO_URL = 'https://www.googleapis.com/oauth2/v3/userinfo';
|
|
|
8
8
|
const CALLBACK_TIMEOUT = 5 * 60_000; // 5 minutes
|
|
9
9
|
/** Service name → OAuth scope URL(s). */
|
|
10
10
|
export const SERVICE_SCOPE_MAP = {
|
|
11
|
-
|
|
11
|
+
// settings.basic is the only scope Google accepts for creating or deleting a filter
|
|
12
|
+
// (ADR-309). Reading filters needs only gmail.modify or gmail.readonly.
|
|
13
|
+
gmail: [
|
|
14
|
+
'https://www.googleapis.com/auth/gmail.modify',
|
|
15
|
+
'https://www.googleapis.com/auth/gmail.settings.basic',
|
|
16
|
+
],
|
|
12
17
|
drive: ['https://www.googleapis.com/auth/drive'],
|
|
13
18
|
calendar: ['https://www.googleapis.com/auth/calendar'],
|
|
14
19
|
sheets: ['https://www.googleapis.com/auth/spreadsheets'],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/accounts/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,MAAM,eAAe,GAAG,2CAA2C,CAAC;AACpE,MAAM,gBAAgB,GAAG,qCAAqC,CAAC;AAC/D,MAAM,mBAAmB,GAAG,+CAA+C,CAAC;AAE5E,MAAM,gBAAgB,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,YAAY;AAEjD,yCAAyC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAA6B;IACzD,KAAK,
|
|
1
|
+
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../src/accounts/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAA6C,MAAM,WAAW,CAAC;A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@@ -8,7 +8,7 @@ operations:
|
|
|
8
8
|
|
|
9
9
|
search:
|
|
10
10
|
type: list
|
|
11
|
-
description: "find emails by query"
|
|
11
|
+
description: "find emails by query. Says when more results exist than the page shows; continue with pageToken, or pass idsOnly to collect up to 500 ids per page for bulk_operations."
|
|
12
12
|
resource: users.messages.list
|
|
13
13
|
params:
|
|
14
14
|
query:
|
|
@@ -17,9 +17,16 @@ operations:
|
|
|
17
17
|
maps_to: q
|
|
18
18
|
maxResults:
|
|
19
19
|
type: number
|
|
20
|
-
description: "Max results (default
|
|
20
|
+
description: "Max results per page (default 10, max 50). On `search` with idsOnly, default and max 500."
|
|
21
21
|
default: 10
|
|
22
22
|
max: 50
|
|
23
|
+
pageToken:
|
|
24
|
+
type: string
|
|
25
|
+
description: "Continue a list from where the previous page stopped: pass the pageToken its response gave. Absent from a response means that response was the last page."
|
|
26
|
+
idsOnly:
|
|
27
|
+
type: boolean
|
|
28
|
+
description: "On `search`: return only message ids, up to 500 per page, without fetching each message's headers. For counting a large result or collecting ids to pass to bulk_operations batch mode (e.g. modify)."
|
|
29
|
+
client_only: true
|
|
23
30
|
defaults:
|
|
24
31
|
userId: me
|
|
25
32
|
hydration:
|
|
@@ -169,6 +176,10 @@ operations:
|
|
|
169
176
|
type: list
|
|
170
177
|
description: "unread inbox summary (sender, subject, date)"
|
|
171
178
|
resource: users.messages.list
|
|
179
|
+
params:
|
|
180
|
+
pageToken:
|
|
181
|
+
type: string
|
|
182
|
+
description: "Continue a list from where the previous page stopped: pass the pageToken its response gave. Absent from a response means that response was the last page."
|
|
172
183
|
defaults:
|
|
173
184
|
userId: me
|
|
174
185
|
q: "is:unread in:inbox"
|
|
@@ -230,9 +241,12 @@ operations:
|
|
|
230
241
|
maps_to: q
|
|
231
242
|
maxResults:
|
|
232
243
|
type: number
|
|
233
|
-
description: "Max results (default
|
|
244
|
+
description: "Max results per page (default 10, max 50). On `search` with idsOnly, default and max 500."
|
|
234
245
|
default: 10
|
|
235
246
|
max: 50
|
|
247
|
+
pageToken:
|
|
248
|
+
type: string
|
|
249
|
+
description: "Continue a list from where the previous page stopped: pass the pageToken its response gave. Absent from a response means that response was the last page."
|
|
236
250
|
defaults:
|
|
237
251
|
userId: me
|
|
238
252
|
|
|
@@ -297,10 +311,10 @@ operations:
|
|
|
297
311
|
maps_to: id
|
|
298
312
|
addLabelIds:
|
|
299
313
|
type: string
|
|
300
|
-
description: "Comma-separated label IDs to add (e.g. STARRED, IMPORTANT, Label_123)"
|
|
314
|
+
description: "Comma-separated label IDs to add (e.g. STARRED, IMPORTANT, Label_123). On modify, to this message; on the filter operations, to each matching message as it arrives."
|
|
301
315
|
removeLabelIds:
|
|
302
316
|
type: string
|
|
303
|
-
description: "Comma-separated label IDs to remove (e.g. UNREAD, INBOX to archive)"
|
|
317
|
+
description: "Comma-separated label IDs to remove (e.g. UNREAD to mark read, INBOX to archive). On modify, from this message; on the filter operations, from each matching message as it arrives."
|
|
304
318
|
defaults:
|
|
305
319
|
userId: me
|
|
306
320
|
|
|
@@ -333,6 +347,194 @@ operations:
|
|
|
333
347
|
defaults:
|
|
334
348
|
userId: me
|
|
335
349
|
|
|
350
|
+
# --- Filters (ADR-309) ---
|
|
351
|
+
|
|
352
|
+
# A filter acts on mail that has not arrived yet, so a create or a replace is gated: it
|
|
353
|
+
# runs only with the token previewFilter mints over that exact change. The handlers are
|
|
354
|
+
# in gmail/filters.ts. `resource` names the Google method whose scopes the access policy
|
|
355
|
+
# checks (ADR-202); previewFilter is all reads, and updateFilter's create and delete need
|
|
356
|
+
# the same scope.
|
|
357
|
+
|
|
358
|
+
filters:
|
|
359
|
+
type: list
|
|
360
|
+
description: "list the account's filters: id, criteria and what each does. Gmail allows 1,000."
|
|
361
|
+
resource: users.settings.filters.list
|
|
362
|
+
defaults:
|
|
363
|
+
userId: me
|
|
364
|
+
|
|
365
|
+
getFilter:
|
|
366
|
+
type: detail
|
|
367
|
+
description: "one filter's criteria and actions in words, plus the parameters that recreate or edit it"
|
|
368
|
+
resource: users.settings.filters.get
|
|
369
|
+
params:
|
|
370
|
+
filterId:
|
|
371
|
+
type: string
|
|
372
|
+
description: "Filter id, as listed by `filters`. On previewFilter, the filter a change would replace; leave it out to preview a new filter."
|
|
373
|
+
maps_to: id
|
|
374
|
+
defaults:
|
|
375
|
+
userId: me
|
|
376
|
+
|
|
377
|
+
previewFilter:
|
|
378
|
+
type: list
|
|
379
|
+
description: "evaluate a filter without creating it: how many messages it matches today and a sample, what each action does, and any duplicate or overlapping filter. Returns the previewToken createFilter needs; with filterId, previews replacing that filter and returns the token updateFilter needs. Criteria are the match* params; actions are addLabelIds, removeLabelIds and forwardTo. A good criterion is the query of a search that already found the mail."
|
|
380
|
+
resource: users.settings.filters.list
|
|
381
|
+
params:
|
|
382
|
+
filterId:
|
|
383
|
+
type: string
|
|
384
|
+
description: "Filter id, as listed by `filters`. On previewFilter, the filter a change would replace; leave it out to preview a new filter."
|
|
385
|
+
maps_to: id
|
|
386
|
+
matchFrom:
|
|
387
|
+
type: string
|
|
388
|
+
description: "Filter criterion: sender, e.g. billing@vendor.com or @vendor.com"
|
|
389
|
+
matchTo:
|
|
390
|
+
type: string
|
|
391
|
+
description: "Filter criterion: recipient, e.g. a list or alias address"
|
|
392
|
+
matchSubject:
|
|
393
|
+
type: string
|
|
394
|
+
description: "Filter criterion: words in the subject"
|
|
395
|
+
matchQuery:
|
|
396
|
+
type: string
|
|
397
|
+
description: "Filter criterion: any Gmail search query the message must match, same syntax as search"
|
|
398
|
+
matchNegatedQuery:
|
|
399
|
+
type: string
|
|
400
|
+
description: "Filter criterion: a Gmail search query the message must NOT match"
|
|
401
|
+
matchHasAttachment:
|
|
402
|
+
type: boolean
|
|
403
|
+
description: "Filter criterion: only messages with an attachment"
|
|
404
|
+
matchExcludeChats:
|
|
405
|
+
type: boolean
|
|
406
|
+
description: "Filter criterion: leave chat messages out"
|
|
407
|
+
matchSize:
|
|
408
|
+
type: number
|
|
409
|
+
description: "Filter criterion: size in bytes; requires matchSizeComparison"
|
|
410
|
+
matchSizeComparison:
|
|
411
|
+
type: string
|
|
412
|
+
description: "Filter criterion: whether matches are larger or smaller than matchSize"
|
|
413
|
+
enum: [larger, smaller]
|
|
414
|
+
addLabelIds:
|
|
415
|
+
type: string
|
|
416
|
+
description: "Comma-separated label IDs to add (e.g. STARRED, IMPORTANT, Label_123). On modify, to this message; on the filter operations, to each matching message as it arrives."
|
|
417
|
+
removeLabelIds:
|
|
418
|
+
type: string
|
|
419
|
+
description: "Comma-separated label IDs to remove (e.g. UNREAD to mark read, INBOX to archive). On modify, from this message; on the filter operations, from each matching message as it arrives."
|
|
420
|
+
forwardTo:
|
|
421
|
+
type: string
|
|
422
|
+
description: "Filter action: forward each match to this address. It must already be a verified forwarding address in Gmail settings."
|
|
423
|
+
defaults:
|
|
424
|
+
userId: me
|
|
425
|
+
|
|
426
|
+
createFilter:
|
|
427
|
+
type: action
|
|
428
|
+
description: "create a filter. Requires the previewToken from previewFilter called with the same parameters, in an earlier call, within 30 minutes. Acts on mail arriving from then on."
|
|
429
|
+
resource: users.settings.filters.create
|
|
430
|
+
params:
|
|
431
|
+
matchFrom:
|
|
432
|
+
type: string
|
|
433
|
+
description: "Filter criterion: sender, e.g. billing@vendor.com or @vendor.com"
|
|
434
|
+
matchTo:
|
|
435
|
+
type: string
|
|
436
|
+
description: "Filter criterion: recipient, e.g. a list or alias address"
|
|
437
|
+
matchSubject:
|
|
438
|
+
type: string
|
|
439
|
+
description: "Filter criterion: words in the subject"
|
|
440
|
+
matchQuery:
|
|
441
|
+
type: string
|
|
442
|
+
description: "Filter criterion: any Gmail search query the message must match, same syntax as search"
|
|
443
|
+
matchNegatedQuery:
|
|
444
|
+
type: string
|
|
445
|
+
description: "Filter criterion: a Gmail search query the message must NOT match"
|
|
446
|
+
matchHasAttachment:
|
|
447
|
+
type: boolean
|
|
448
|
+
description: "Filter criterion: only messages with an attachment"
|
|
449
|
+
matchExcludeChats:
|
|
450
|
+
type: boolean
|
|
451
|
+
description: "Filter criterion: leave chat messages out"
|
|
452
|
+
matchSize:
|
|
453
|
+
type: number
|
|
454
|
+
description: "Filter criterion: size in bytes; requires matchSizeComparison"
|
|
455
|
+
matchSizeComparison:
|
|
456
|
+
type: string
|
|
457
|
+
description: "Filter criterion: whether matches are larger or smaller than matchSize"
|
|
458
|
+
enum: [larger, smaller]
|
|
459
|
+
addLabelIds:
|
|
460
|
+
type: string
|
|
461
|
+
description: "Comma-separated label IDs to add (e.g. STARRED, IMPORTANT, Label_123). On modify, to this message; on the filter operations, to each matching message as it arrives."
|
|
462
|
+
removeLabelIds:
|
|
463
|
+
type: string
|
|
464
|
+
description: "Comma-separated label IDs to remove (e.g. UNREAD to mark read, INBOX to archive). On modify, from this message; on the filter operations, from each matching message as it arrives."
|
|
465
|
+
forwardTo:
|
|
466
|
+
type: string
|
|
467
|
+
description: "Filter action: forward each match to this address. It must already be a verified forwarding address in Gmail settings."
|
|
468
|
+
previewToken:
|
|
469
|
+
type: string
|
|
470
|
+
description: "The token previewFilter returned for this exact change. Required: the write runs only after its preview has been seen."
|
|
471
|
+
defaults:
|
|
472
|
+
userId: me
|
|
473
|
+
|
|
474
|
+
updateFilter:
|
|
475
|
+
type: action
|
|
476
|
+
description: "change a filter's criteria or actions. Gmail has no in-place update, so this creates the replacement and then deletes the original; the filter gets a new id. Requires the previewToken from previewFilter called with filterId and the same parameters."
|
|
477
|
+
resource: users.settings.filters.create
|
|
478
|
+
params:
|
|
479
|
+
filterId:
|
|
480
|
+
type: string
|
|
481
|
+
description: "Filter id, as listed by `filters`. On previewFilter, the filter a change would replace; leave it out to preview a new filter."
|
|
482
|
+
maps_to: id
|
|
483
|
+
matchFrom:
|
|
484
|
+
type: string
|
|
485
|
+
description: "Filter criterion: sender, e.g. billing@vendor.com or @vendor.com"
|
|
486
|
+
matchTo:
|
|
487
|
+
type: string
|
|
488
|
+
description: "Filter criterion: recipient, e.g. a list or alias address"
|
|
489
|
+
matchSubject:
|
|
490
|
+
type: string
|
|
491
|
+
description: "Filter criterion: words in the subject"
|
|
492
|
+
matchQuery:
|
|
493
|
+
type: string
|
|
494
|
+
description: "Filter criterion: any Gmail search query the message must match, same syntax as search"
|
|
495
|
+
matchNegatedQuery:
|
|
496
|
+
type: string
|
|
497
|
+
description: "Filter criterion: a Gmail search query the message must NOT match"
|
|
498
|
+
matchHasAttachment:
|
|
499
|
+
type: boolean
|
|
500
|
+
description: "Filter criterion: only messages with an attachment"
|
|
501
|
+
matchExcludeChats:
|
|
502
|
+
type: boolean
|
|
503
|
+
description: "Filter criterion: leave chat messages out"
|
|
504
|
+
matchSize:
|
|
505
|
+
type: number
|
|
506
|
+
description: "Filter criterion: size in bytes; requires matchSizeComparison"
|
|
507
|
+
matchSizeComparison:
|
|
508
|
+
type: string
|
|
509
|
+
description: "Filter criterion: whether matches are larger or smaller than matchSize"
|
|
510
|
+
enum: [larger, smaller]
|
|
511
|
+
addLabelIds:
|
|
512
|
+
type: string
|
|
513
|
+
description: "Comma-separated label IDs to add (e.g. STARRED, IMPORTANT, Label_123). On modify, to this message; on the filter operations, to each matching message as it arrives."
|
|
514
|
+
removeLabelIds:
|
|
515
|
+
type: string
|
|
516
|
+
description: "Comma-separated label IDs to remove (e.g. UNREAD to mark read, INBOX to archive). On modify, from this message; on the filter operations, from each matching message as it arrives."
|
|
517
|
+
forwardTo:
|
|
518
|
+
type: string
|
|
519
|
+
description: "Filter action: forward each match to this address. It must already be a verified forwarding address in Gmail settings."
|
|
520
|
+
previewToken:
|
|
521
|
+
type: string
|
|
522
|
+
description: "The token previewFilter returned for this exact change. Required: the write runs only after its preview has been seen."
|
|
523
|
+
defaults:
|
|
524
|
+
userId: me
|
|
525
|
+
|
|
526
|
+
deleteFilter:
|
|
527
|
+
type: action
|
|
528
|
+
description: "delete a filter. Returns what it was and the parameters to recreate it."
|
|
529
|
+
resource: users.settings.filters.delete
|
|
530
|
+
params:
|
|
531
|
+
filterId:
|
|
532
|
+
type: string
|
|
533
|
+
description: "Filter id, as listed by `filters`. On previewFilter, the filter a change would replace; leave it out to preview a new filter."
|
|
534
|
+
maps_to: id
|
|
535
|
+
defaults:
|
|
536
|
+
userId: me
|
|
537
|
+
|
|
336
538
|
# --- Threads ---
|
|
337
539
|
|
|
338
540
|
threads:
|
|
@@ -346,9 +548,12 @@ operations:
|
|
|
346
548
|
maps_to: q
|
|
347
549
|
maxResults:
|
|
348
550
|
type: number
|
|
349
|
-
description: "Max results (default
|
|
551
|
+
description: "Max results per page (default 10, max 50). On `search` with idsOnly, default and max 500."
|
|
350
552
|
default: 10
|
|
351
553
|
max: 50
|
|
554
|
+
pageToken:
|
|
555
|
+
type: string
|
|
556
|
+
description: "Continue a list from where the previous page stopped: pass the pageToken its response gave. Absent from a response means that response was the last page."
|
|
352
557
|
defaults:
|
|
353
558
|
userId: me
|
|
354
559
|
|
package/build/factory/safety.js
CHANGED
|
@@ -51,6 +51,16 @@ export const draftOnlyEmail = {
|
|
|
51
51
|
`The agent can read, search, and triage emails but cannot send on behalf of the user.`,
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
// A filter that forwards sends every future match, with nobody in the loop for any of
|
|
55
|
+
// them. That is outbound mail, however it is set up.
|
|
56
|
+
const filterWrites = ['createFilter', 'updateFilter'];
|
|
57
|
+
if (filterWrites.includes(ctx.operation) && String(ctx.params.forwardTo ?? '').trim()) {
|
|
58
|
+
return {
|
|
59
|
+
action: 'block',
|
|
60
|
+
reason: `A filter that forwards mail is blocked by draft-only email policy: it would send every ` +
|
|
61
|
+
`future match to ${String(ctx.params.forwardTo)}. Filters that label, archive or mark mail are allowed.`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
54
64
|
return { action: 'allow' };
|
|
55
65
|
},
|
|
56
66
|
};
|
|
@@ -101,7 +111,7 @@ function isReadOperation(operation) {
|
|
|
101
111
|
if (op.startsWith('get') || op.startsWith('list') || op.startsWith('search'))
|
|
102
112
|
return true;
|
|
103
113
|
// Exact read-only names
|
|
104
|
-
const readOps = ['read', 'triage', 'labels', 'threads', 'agenda', 'calendars', 'freebusy', 'tree'];
|
|
114
|
+
const readOps = ['read', 'triage', 'labels', 'threads', 'agenda', 'calendars', 'freebusy', 'tree', 'filters', 'previewfilter'];
|
|
105
115
|
return readOps.includes(op);
|
|
106
116
|
}
|
|
107
117
|
/**
|
|
@@ -173,21 +183,35 @@ export const accountAccess = {
|
|
|
173
183
|
return { action: 'allow' };
|
|
174
184
|
if (required.some((scope) => granted.has(scope)))
|
|
175
185
|
return { action: 'allow' };
|
|
176
|
-
// Nothing the operation accepts was granted.
|
|
186
|
+
// Nothing the operation accepts was granted. Three different causes: the account
|
|
187
|
+
// never authorized the service, authorized it read-only, or authorized it read/write
|
|
188
|
+
// before the service's scope set grew to include what this operation needs.
|
|
177
189
|
const holdsSomething = anyScopesFor(op.service).some((scope) => granted.has(scope));
|
|
190
|
+
const holdsWrite = writeScopesFor(op.service).some((scope) => granted.has(scope));
|
|
178
191
|
const reconsent = `manage_accounts {operation:'scopes', email:'${ctx.account}', ` +
|
|
179
192
|
`services:'${op.service}', access:'readwrite'}`;
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
reason
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
let reason;
|
|
194
|
+
if (holdsWrite) {
|
|
195
|
+
reason = `'${ctx.operation}' needs ${required.map(scopeName).join(' or ')}, which account ${ctx.account} ` +
|
|
196
|
+
`has not granted: either the account authorized ${op.service} before this server asked for it, or it was ` +
|
|
197
|
+
`declined on the consent screen. Re-authorize with ${reconsent} and allow it.`;
|
|
198
|
+
}
|
|
199
|
+
else if (holdsSomething) {
|
|
200
|
+
reason = `'${ctx.operation}' needs write access to ${op.service}. ` +
|
|
201
|
+
`Account ${ctx.account} was authorized read-only for ${op.service}. ` +
|
|
202
|
+
`Re-authorize with ${reconsent}, or use an account that already has it.`;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
reason = `'${ctx.operation}' needs access to ${op.service}, which account ${ctx.account} ` +
|
|
206
|
+
`has never authorized. Grant it with ${reconsent}, or use an account that already has it.`;
|
|
207
|
+
}
|
|
208
|
+
return { action: 'block', reason };
|
|
189
209
|
},
|
|
190
210
|
};
|
|
211
|
+
/** `https://www.googleapis.com/auth/gmail.settings.basic` -> `gmail.settings.basic`. */
|
|
212
|
+
function scopeName(scope) {
|
|
213
|
+
return scope.replace('https://www.googleapis.com/auth/', '');
|
|
214
|
+
}
|
|
191
215
|
/**
|
|
192
216
|
* The scopes Google will accept for this operation.
|
|
193
217
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safety.js","sourceRoot":"","sources":["../../src/factory/safety.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAsDzD,wEAAwE;AAExE;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAiB;IAC1C,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,qDAAqD;IAClE,OAAO,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,OAAO;IACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACvB,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;QACzD,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACpC,OAAO;gBACL,MAAM,EAAE,OAAO;gBACf,MAAM,EAAE,cAAc,GAAG,CAAC,SAAS,2CAA2C;oBAC5E,sFAAsF;aACzF,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,MAAM,E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AAC;YACF,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which top-level tool call the current code is running inside.
|
|
3
|
+
*
|
|
4
|
+
* A `bulk_operations` queue runs its operations by calling their handlers directly, inside
|
|
5
|
+
* the one tool call that carried the queue, so everything a queue does shares that call's
|
|
6
|
+
* id. The preview gate (ADR-309) reads it to refuse a token minted earlier in the same
|
|
7
|
+
* call: a preview chained straight into a write returns nothing to the caller between them.
|
|
8
|
+
*/
|
|
9
|
+
/** Run `fn` as a new top-level tool call. */
|
|
10
|
+
export declare function runAsToolCall<T>(fn: () => Promise<T>): Promise<T>;
|
|
11
|
+
/** The id of the tool call in progress; 0 outside one (tests, startup). */
|
|
12
|
+
export declare function currentCallId(): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which top-level tool call the current code is running inside.
|
|
3
|
+
*
|
|
4
|
+
* A `bulk_operations` queue runs its operations by calling their handlers directly, inside
|
|
5
|
+
* the one tool call that carried the queue, so everything a queue does shares that call's
|
|
6
|
+
* id. The preview gate (ADR-309) reads it to refuse a token minted earlier in the same
|
|
7
|
+
* call: a preview chained straight into a write returns nothing to the caller between them.
|
|
8
|
+
*/
|
|
9
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
10
|
+
const storage = new AsyncLocalStorage();
|
|
11
|
+
let lastCallId = 0;
|
|
12
|
+
/** Run `fn` as a new top-level tool call. */
|
|
13
|
+
export function runAsToolCall(fn) {
|
|
14
|
+
return storage.run({ callId: ++lastCallId }, fn);
|
|
15
|
+
}
|
|
16
|
+
/** The id of the tool call in progress; 0 outside one (tests, startup). */
|
|
17
|
+
export function currentCallId() {
|
|
18
|
+
return storage.getStore()?.callId ?? 0;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=call-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"call-context.js","sourceRoot":"","sources":["../../src/server/call-context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,MAAM,OAAO,GAAG,IAAI,iBAAiB,EAAsB,CAAC;AAC5D,IAAI,UAAU,GAAG,CAAC,CAAC;AAEnB,6CAA6C;AAC7C,MAAM,UAAU,aAAa,CAAI,EAAoB;IACnD,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC,QAAQ,EAAE,EAAE,MAAM,IAAI,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -9,4 +9,8 @@ export declare function advanceEpoch(): number;
|
|
|
9
9
|
* working for one minor release — ADR-308. Both are advertised and both dispatch here.
|
|
10
10
|
*/
|
|
11
11
|
export declare const BULK_TOOL_NAMES: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Dispatch one tool call from the client. Everything it runs, a queue's operations
|
|
14
|
+
* included, shares one call id (see call-context.ts).
|
|
15
|
+
*/
|
|
12
16
|
export declare function handleToolCall(toolName: string, params: Record<string, unknown>): Promise<HandlerResponse>;
|
package/build/server/handler.js
CHANGED
|
@@ -5,6 +5,7 @@ import { handleQueue } from './queue.js';
|
|
|
5
5
|
import { handleBatch } from './batch.js';
|
|
6
6
|
import { generatedTools } from '../factory/registry.js';
|
|
7
7
|
import { getSessionTracker, sessionContext } from './session/index.js';
|
|
8
|
+
import { runAsToolCall } from './call-context.js';
|
|
8
9
|
// ── Epoch counter ─────────────────────────────────────────
|
|
9
10
|
// Server-wide monotonic counter incremented on every tool call.
|
|
10
11
|
// Used by ScratchpadManager for activity-based garbage collection.
|
|
@@ -51,7 +52,14 @@ function queueableHandlers(depth) {
|
|
|
51
52
|
...Object.fromEntries(BULK_TOOL_NAMES.map((name) => [name, nested])),
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
|
-
|
|
55
|
+
/**
|
|
56
|
+
* Dispatch one tool call from the client. Everything it runs, a queue's operations
|
|
57
|
+
* included, shares one call id (see call-context.ts).
|
|
58
|
+
*/
|
|
59
|
+
export function handleToolCall(toolName, params) {
|
|
60
|
+
return runAsToolCall(() => dispatchToolCall(toolName, params));
|
|
61
|
+
}
|
|
62
|
+
async function dispatchToolCall(toolName, params) {
|
|
55
63
|
const currentEpoch = advanceEpoch();
|
|
56
64
|
const tracker = getSessionTracker();
|
|
57
65
|
// Bulk wraps the domain handlers (each queued op also advances the epoch)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/server/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/server/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAA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,CAAC,SAAS,CAAC;IAE1E,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC;IAErC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,MAAM,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;QAC3D,IAAI,GAAG;YAAE,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iEAAiE;AACjE,SAAS,qBAAqB,CAAC,MAA+B;IAC5D,MAAM,UAAU,GAAG,MAAM,CAAC,UAAmE,CAAC;IAC9F,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAAE,OAAO,SAAS,CAAC;IACjD,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;IAC/D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The preview gate for standing-effect writes (ADR-309).
|
|
3
|
+
*
|
|
4
|
+
* A preview mints a token over the exact payload it evaluated; the write refuses without
|
|
5
|
+
* one. The token is an HMAC under a key made at process start, so nothing is stored and
|
|
6
|
+
* nothing needs cleaning up. A restart invalidates every outstanding token, and the remedy
|
|
7
|
+
* is to preview again.
|
|
8
|
+
*
|
|
9
|
+
* A token proves the evaluation was returned to the caller. It does not prove a person
|
|
10
|
+
* read it; that is the MCP client's per-call permission prompt.
|
|
11
|
+
*/
|
|
12
|
+
/** How long a preview stays good. Match counts and conflicts drift as mail arrives. */
|
|
13
|
+
export declare const PREVIEW_TTL_MS: number;
|
|
14
|
+
export type TokenFailure = 'missing' | 'malformed' | 'wrong-kind' | 'mismatch' | 'expired' | 'same-call';
|
|
15
|
+
export type TokenCheck = {
|
|
16
|
+
ok: true;
|
|
17
|
+
} | {
|
|
18
|
+
ok: false;
|
|
19
|
+
failure: TokenFailure;
|
|
20
|
+
issuedFor?: string;
|
|
21
|
+
};
|
|
22
|
+
/** JSON with object keys sorted at every depth, so equal payloads serialize equally. */
|
|
23
|
+
export declare function canonicalJson(value: unknown): string;
|
|
24
|
+
/** Mint a token for `kind`, bound to this account, this payload, now, and this call. */
|
|
25
|
+
export declare function mintPreviewToken(kind: string, account: string, payload: unknown, now?: number): string;
|
|
26
|
+
/** Check a token against the write about to happen. */
|
|
27
|
+
export declare function checkPreviewToken(token: unknown, kind: string, account: string, payload: unknown, now?: number): TokenCheck;
|
|
28
|
+
/**
|
|
29
|
+
* The sentence a refused write returns.
|
|
30
|
+
*
|
|
31
|
+
* @param write The operation refused, e.g. `createFilter`.
|
|
32
|
+
* @param preview The operation that mints its token, e.g. `previewFilter`.
|
|
33
|
+
*/
|
|
34
|
+
export declare function describeTokenFailure(check: Extract<TokenCheck, {
|
|
35
|
+
ok: false;
|
|
36
|
+
}>, write: string, preview: string): string;
|