@assemblyline-agents/gmail 1.0.0 → 3.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 OpenEve contributors
3
+ Copyright (c) 2026 Assembly Line contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Official Assembly Line Gmail connection plugin.
4
4
 
5
- It exposes Gmail threads, messages, attachments, drafts, and sends through a dedicated MCP connection. Gmail authorization stays independent from Google Calendar and Google Drive. The package exports `defineGmailConnection(options)` and bundles focused Gmail guidance under `skills/`.
5
+ It exposes Gmail threads, messages, attachments, drafts, and sends through a reviewed direct Gmail REST API connection. Gmail authorization is stored independently from Google Calendar and Google Drive. The package exports `defineGmailConnection(options)`.
6
6
 
7
7
  ## Install
8
8
 
@@ -10,7 +10,26 @@ It exposes Gmail threads, messages, attachments, drafts, and sends through a ded
10
10
  npm install @assemblyline-agents/gmail
11
11
  ```
12
12
 
13
- Configure `GMAIL_MCP_URL` and `GMAIL_MCP_TOKEN`, or pass the connection URL and authentication resolver directly. New connections scaffold read-only; drafts and sends require explicit write access and the configured approval policy.
13
+ Create a Google OAuth web client, enable the Gmail API, and set `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`. Optionally set `GOOGLE_REDIRECT_URI` or `GMAIL_API_BASE_URL`. Assembly Line runs Authorization Code + PKCE, requests offline access, and stores the refreshable grant host-side. New connections enable reviewed Gmail tools without requiring an approval surface. Set `access: "approval-required"` if drafts and sends should pause for approval, or `access: "read-only"` to request only `gmail.readonly`.
14
+
15
+ Gmail connections also expose the reviewed `email.received` event. Enable the
16
+ Gmail API and Pub/Sub API, then set `GOOGLE_CLOUD_PROJECT`,
17
+ `GMAIL_PUBSUB_TOPIC`, and a stable random
18
+ `GMAIL_PUBSUB_VERIFICATION_TOKEN`. The operator owns the Pub/Sub resources:
19
+
20
+ 1. Create the topic in `GOOGLE_CLOUD_PROJECT`.
21
+ 2. Grant `serviceAccount:gmail-api-push@system.gserviceaccount.com` the
22
+ `roles/pubsub.publisher` role on that topic.
23
+ 3. Run `assembly-line connections wire` after deployment and create a Pub/Sub
24
+ push subscription for the reported callback URL. Append
25
+ `?token=<GMAIL_PUBSUB_VERIFICATION_TOKEN>` using the actual secret value.
26
+
27
+ Assembly Line uses the user's existing Gmail OAuth grant only to create and
28
+ renew `users.watch`; it never needs a Google Cloud service-account key and does
29
+ not create or delete operator-owned Pub/Sub resources. Notifications are
30
+ expanded through Gmail History into one stable event per newly received
31
+ message; sent mail, drafts, spam, and trash are excluded. Add an explicit
32
+ `automations/*.ts` event automation to start agent work.
14
33
 
15
34
  ## Part of Assembly Line
16
35
 
package/dist/auth.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { type ConnectionAuthDefinition, type ConnectionPluginAccessSelection } from "@assemblyline-agents/core";
2
+ export declare function gmailOAuth(access: ConnectionPluginAccessSelection | undefined): ConnectionAuthDefinition;
3
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,+BAA+B,EACrC,MAAM,2BAA2B,CAAC;AAQnC,wBAAgB,UAAU,CAAC,MAAM,EAAE,+BAA+B,GAAG,SAAS,GAAG,wBAAwB,CAoBxG"}
package/dist/auth.js ADDED
@@ -0,0 +1,33 @@
1
+ import { defineOAuthAuthorization } from "@assemblyline-agents/core";
2
+ const READ_SCOPES = ["https://www.googleapis.com/auth/gmail.readonly"];
3
+ const WRITE_SCOPES = [
4
+ "https://www.googleapis.com/auth/gmail.compose",
5
+ "https://www.googleapis.com/auth/gmail.send"
6
+ ];
7
+ export function gmailOAuth(access) {
8
+ return ({ env }) => {
9
+ const clientId = env.GOOGLE_CLIENT_ID?.trim();
10
+ const clientSecret = env.GOOGLE_CLIENT_SECRET?.trim();
11
+ const redirectUri = env.GOOGLE_REDIRECT_URI?.trim();
12
+ if (!clientId || !clientSecret) {
13
+ throw new Error("Gmail OAuth requires GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET.");
14
+ }
15
+ return defineOAuthAuthorization({
16
+ displayName: "Gmail",
17
+ authorizeUrl: "https://accounts.google.com/o/oauth2/v2/auth",
18
+ tokenUrl: "https://oauth2.googleapis.com/token",
19
+ clientId,
20
+ clientSecret,
21
+ scopes: writesEnabled(access) ? [...READ_SCOPES, ...WRITE_SCOPES] : [...READ_SCOPES],
22
+ ...(redirectUri ? { redirectUri } : {}),
23
+ authorizationParams: { access_type: "offline", prompt: "consent" },
24
+ pkce: true
25
+ });
26
+ };
27
+ }
28
+ function writesEnabled(access) {
29
+ if (access === "read-only")
30
+ return false;
31
+ return typeof access !== "object" || access.write !== false;
32
+ }
33
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAGzB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,GAAG,CAAC,gDAAgD,CAAU,CAAC;AAChF,MAAM,YAAY,GAAG;IACnB,+CAA+C;IAC/C,4CAA4C;CACpC,CAAC;AAEX,MAAM,UAAU,UAAU,CAAC,MAAmD;IAC5E,OAAO,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;QACjB,MAAM,QAAQ,GAAG,GAAG,CAAC,gBAAgB,EAAE,IAAI,EAAE,CAAC;QAC9C,MAAM,YAAY,GAAG,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAC;QACtD,MAAM,WAAW,GAAG,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC;QACpD,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAC;QACrF,CAAC;QACD,OAAO,wBAAwB,CAAC;YAC9B,WAAW,EAAE,OAAO;YACpB,YAAY,EAAE,8CAA8C;YAC5D,QAAQ,EAAE,qCAAqC;YAC/C,QAAQ;YACR,YAAY;YACZ,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;YACpF,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACvC,mBAAmB,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE;YAClE,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CAAC,MAAmD;IACxE,IAAI,MAAM,KAAK,WAAW;QAAE,OAAO,KAAK,CAAC;IACzC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ConnectionPluginEventAdapter } from "@assemblyline-agents/core";
2
+ export declare const gmailEvents: ConnectionPluginEventAdapter;
3
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,4BAA4B,EAElC,MAAM,2BAA2B,CAAC;AAInC,eAAO,MAAM,WAAW,EAAE,4BAoFzB,CAAC"}
package/dist/events.js ADDED
@@ -0,0 +1,149 @@
1
+ import { ConnectionEventError, parseConnectionEventJson, providerJson, recordField, requireEnvironmentValue, stringField } from "@assemblyline-agents/core";
2
+ const GMAIL = "https://gmail.googleapis.com/gmail/v1/users/me";
3
+ export const gmailEvents = {
4
+ async reconcile(context) {
5
+ const gmailToken = (await context.getToken()).token;
6
+ const project = requireEnvironmentValue(context.env, "GOOGLE_CLOUD_PROJECT");
7
+ const configuredTopic = requireEnvironmentValue(context.env, "GMAIL_PUBSUB_TOPIC");
8
+ const topic = configuredTopic.startsWith("projects/") ? configuredTopic : `projects/${project}/topics/${configuredTopic}`;
9
+ requireEnvironmentValue(context.env, "GMAIL_PUBSUB_VERIFICATION_TOKEN");
10
+ const labels = selectedLabels(context.resources);
11
+ const watched = await providerJson(context.fetch, `${GMAIL}/watch`, {
12
+ method: "POST",
13
+ headers: auth(gmailToken),
14
+ body: JSON.stringify({ topicName: topic, ...(labels.length ? { labelIds: labels, labelFilterBehavior: "include" } : {}) })
15
+ });
16
+ const expirationMs = Number(watched.expiration);
17
+ const expiresAt = Number.isFinite(expirationMs) ? new Date(expirationMs).toISOString() : undefined;
18
+ const historyId = stringField(context.state ?? {}, "historyId") ?? stringField(watched, "historyId");
19
+ return {
20
+ status: "active",
21
+ externalId: topic,
22
+ state: { topic, ...(historyId ? { historyId } : {}) },
23
+ ...(expiresAt ? { expiresAt } : {}),
24
+ instructions: `Create an externally managed Pub/Sub push subscription for ${topic}. Its endpoint must be ${context.callbackUrl}?token=<GMAIL_PUBSUB_VERIFICATION_TOKEN>, and serviceAccount:gmail-api-push@system.gserviceaccount.com must have roles/pubsub.publisher on the topic.`,
25
+ detail: "The Gmail watch is active and uses the externally managed Pub/Sub topic."
26
+ };
27
+ },
28
+ async remove(context) {
29
+ const gmailToken = (await context.getToken()).token;
30
+ await providerJson(context.fetch, `${GMAIL}/stop`, { method: "POST", headers: auth(gmailToken), body: "{}" }, [200, 204, 404]);
31
+ },
32
+ check(context) {
33
+ const topic = stringField(context.state ?? {}, "topic");
34
+ return topic
35
+ ? { status: "active", detail: "The Gmail watch is active and uses the externally managed Pub/Sub topic." }
36
+ : { status: "needs_setup", detail: "The Gmail watch has not been configured." };
37
+ },
38
+ async ingress(request, context) {
39
+ if (request.query.token !== requireEnvironmentValue(context.env, "GMAIL_PUBSUB_VERIFICATION_TOKEN")) {
40
+ throw new ConnectionEventError("Gmail Pub/Sub verification token is invalid.", 401);
41
+ }
42
+ const envelope = parseConnectionEventJson(request.body);
43
+ const message = recordField(envelope, "message");
44
+ const data = message && stringField(message, "data");
45
+ const messageId = message && stringField(message, "messageId", "message_id");
46
+ if (!data || !messageId)
47
+ throw new ConnectionEventError("Gmail Pub/Sub message is incomplete.");
48
+ let payload;
49
+ try {
50
+ payload = JSON.parse(Buffer.from(data, "base64").toString("utf8"));
51
+ }
52
+ catch {
53
+ throw new ConnectionEventError("Gmail Pub/Sub data is invalid.");
54
+ }
55
+ const currentHistoryId = stringField(payload, "historyId");
56
+ if (!currentHistoryId)
57
+ throw new ConnectionEventError("Gmail Pub/Sub data omitted historyId.");
58
+ const previousHistoryId = stringField(context.state ?? {}, "historyId");
59
+ const state = { ...(context.state ?? {}), historyId: currentHistoryId };
60
+ if (!previousHistoryId) {
61
+ return { events: [], state, response: { status: 200, body: { ok: true } }, audit: { event: "email.received", received: 0 } };
62
+ }
63
+ if (historyIdAtOrBefore(currentHistoryId, previousHistoryId)) {
64
+ return { events: [], state: { ...(context.state ?? {}), historyId: previousHistoryId }, response: { status: 200, body: { ok: true } }, audit: { event: "email.received", received: 0, stale: true } };
65
+ }
66
+ const token = (await context.getToken()).token;
67
+ let received;
68
+ try {
69
+ received = await receivedMessagesSince(context.fetch, token, previousHistoryId);
70
+ }
71
+ catch (error) {
72
+ if (!isExpiredHistoryId(error))
73
+ throw error;
74
+ return { events: [], state, response: { status: 200, body: { ok: true } }, audit: { event: "email.received", received: 0, watermarkReset: true } };
75
+ }
76
+ const occurredAt = message && stringField(message, "publishTime", "publish_time");
77
+ return {
78
+ events: received.map((item) => ({
79
+ event: "email.received",
80
+ eventId: item.id,
81
+ payload: {
82
+ emailAddress: stringField(payload, "emailAddress") ?? "",
83
+ historyId: currentHistoryId,
84
+ messageId: item.id,
85
+ ...(item.threadId ? { threadId: item.threadId } : {}),
86
+ labelIds: item.labelIds
87
+ },
88
+ ...(occurredAt ? { occurredAt } : {})
89
+ })),
90
+ state,
91
+ response: { status: 200, body: { ok: true } },
92
+ audit: { event: "email.received", received: received.length }
93
+ };
94
+ }
95
+ };
96
+ async function receivedMessagesSince(fetchImpl, token, startHistoryId) {
97
+ const messages = new Map();
98
+ let pageToken;
99
+ do {
100
+ const url = new URL(`${GMAIL}/history`);
101
+ url.searchParams.set("startHistoryId", startHistoryId);
102
+ url.searchParams.set("historyTypes", "messageAdded");
103
+ url.searchParams.set("maxResults", "500");
104
+ if (pageToken)
105
+ url.searchParams.set("pageToken", pageToken);
106
+ const value = await providerJson(fetchImpl, url.toString(), { method: "GET", headers: auth(token) });
107
+ for (const history of records(value.history)) {
108
+ for (const addition of records(history.messagesAdded)) {
109
+ const message = recordField(addition, "message");
110
+ const id = message && stringField(message, "id");
111
+ if (!id)
112
+ continue;
113
+ const labelIds = stringArray(message.labelIds);
114
+ if (labelIds.some((label) => IGNORED_MESSAGE_LABELS.has(label)))
115
+ continue;
116
+ messages.set(id, {
117
+ id,
118
+ ...(stringField(message, "threadId") ? { threadId: stringField(message, "threadId") } : {}),
119
+ labelIds
120
+ });
121
+ }
122
+ }
123
+ pageToken = stringField(value, "nextPageToken");
124
+ } while (pageToken);
125
+ return [...messages.values()];
126
+ }
127
+ const IGNORED_MESSAGE_LABELS = new Set(["SENT", "DRAFT", "SPAM", "TRASH"]);
128
+ function records(value) {
129
+ return Array.isArray(value)
130
+ ? value.filter((item) => Boolean(item) && typeof item === "object" && !Array.isArray(item))
131
+ : [];
132
+ }
133
+ function stringArray(value) {
134
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
135
+ }
136
+ function historyIdAtOrBefore(candidate, watermark) {
137
+ try {
138
+ return BigInt(candidate) <= BigInt(watermark);
139
+ }
140
+ catch {
141
+ throw new ConnectionEventError("Gmail Pub/Sub data contains an invalid historyId.");
142
+ }
143
+ }
144
+ function isExpiredHistoryId(error) {
145
+ return error instanceof Error && /Provider event API returned HTTP 404(?:\D|$)/u.test(error.message);
146
+ }
147
+ function auth(token) { return { authorization: `Bearer ${token}`, "content-type": "application/json" }; }
148
+ function selectedLabels(resources) { return resources.flatMap((resource) => Array.isArray(resource.labelIds) ? resource.labelIds.filter((value) => typeof value === "string") : []); }
149
+ //# sourceMappingURL=events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,uBAAuB,EACvB,WAAW,EAGZ,MAAM,2BAA2B,CAAC;AAEnC,MAAM,KAAK,GAAG,gDAAgD,CAAC;AAE/D,MAAM,CAAC,MAAM,WAAW,GAAiC;IACvD,KAAK,CAAC,SAAS,CAAC,OAAO;QACrB,MAAM,UAAU,GAAG,CAAC,MAAM,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC;QACpD,MAAM,OAAO,GAAG,uBAAuB,CAAC,OAAO,CAAC,GAAG,EAAE,sBAAsB,CAAC,CAAC;QAC7E,MAAM,eAAe,GAAG,uBAAuB,CAAC,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;QACnF,MAAM,KAAK,GAAG,eAAe,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,YAAY,OAAO,WAAW,eAAe,EAAE,CAAC;QAC1H,uBAAuB,CAAC,OAAO,CAAC,GAAG,EAAE,iCAAiC,CAAC,CAAC;QACxE,MAAM,MAAM,GAAG,cAAc,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjD,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,KAAK,QAAQ,EAAE;YAClE,MAAM,EAA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AC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAkB,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACtG,CAAC;AAED,SAAS,mBAAmB,CAAC,SAAiB,EAAE,SAAiB;IAC/D,IAAI,CAAC;QAAC,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,MAAM,CAAC,SAAS,CAAC,CAAC;IAAC,CAAC;IACtD,MAAM,CAAC;QAAC,MAAM,IAAI,oBAAoB,CAAC,mDAAmD,CAAC,CAAC;IAAC,CAAC;AAChG,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,KAAK,YAAY,KAAK,IAAI,+CAA+C,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACvG,CAAC;AAED,SAAS,IAAI,CAAC,KAAa,IAA4B,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC,CAAC,CAAC;AACzI,SAAS,cAAc,CAAC,SAAuB,IAAc,OAAO,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { type McpPluginConnectionOptions } from "@assemblyline-agents/core";
2
- export type GmailConnectionOptions = McpPluginConnectionOptions;
3
- export declare function defineGmailConnection(options: GmailConnectionOptions): import("@assemblyline-agents/core").McpHttpClientConnectionDefinition;
1
+ import { type ConnectionAuthDefinition, type HttpApiPluginConnectionOptions } from "@assemblyline-agents/core";
2
+ export interface GmailConnectionOptions extends Omit<HttpApiPluginConnectionOptions, "auth" | "operations"> {
3
+ auth?: ConnectionAuthDefinition | false;
4
+ }
5
+ export declare function defineGmailConnection(options?: GmailConnectionOptions): import("@assemblyline-agents/core").HttpApiConnectionDefinition;
4
6
  export declare const assemblyLinePlugin: import("@assemblyline-agents/core").PluginModule;
5
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AAInC,MAAM,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAEhE,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,yEAEpE;AAED,eAAO,MAAM,kBAAkB,kDAA0C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EACpC,MAAM,2BAA2B,CAAC;AAOnC,MAAM,WAAW,sBAAuB,SAAQ,IAAI,CAAC,8BAA8B,EAAE,MAAM,GAAG,YAAY,CAAC;IACzG,IAAI,CAAC,EAAE,wBAAwB,GAAG,KAAK,CAAC;CACzC;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,sBAA2B,mEAUzE;AAED,eAAO,MAAM,kBAAkB,kDAA0C,CAAC"}
package/dist/index.js CHANGED
@@ -1,7 +1,19 @@
1
- import { connectionPluginMetadata, defineMcpPluginConnection, definePlugin } from "@assemblyline-agents/core";
1
+ import { connectionPluginMetadata, defineConnectionPluginEvents, defineHttpApiPluginConnection, definePlugin } from "@assemblyline-agents/core";
2
+ import { gmailOAuth } from "./auth.js";
3
+ import { gmailEvents } from "./events.js";
4
+ import { GMAIL_OPERATIONS } from "./operations.js";
2
5
  const PLUGIN = connectionPluginMetadata("gmail");
3
- export function defineGmailConnection(options) {
4
- return defineMcpPluginConnection(PLUGIN, options);
6
+ export function defineGmailConnection(options = {}) {
7
+ const { auth, ...connection } = options;
8
+ const definition = defineHttpApiPluginConnection(PLUGIN, {
9
+ ...connection,
10
+ operations: GMAIL_OPERATIONS,
11
+ auth: auth === false ? false : auth ?? gmailOAuth(options.access)
12
+ });
13
+ const events = defineConnectionPluginEvents(PLUGIN, options.events, gmailEvents);
14
+ if (events)
15
+ definition.events = events;
16
+ return definition;
5
17
  }
6
18
  export const assemblyLinePlugin = definePlugin({ connections: [PLUGIN] });
7
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EAEb,MAAM,2BAA2B,CAAC;AAEnC,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAE,CAAC;AAIlD,MAAM,UAAU,qBAAqB,CAAC,OAA+B;IACnE,OAAO,yBAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,4BAA4B,EAC5B,6BAA6B,EAC7B,YAAY,EAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,MAAM,GAAG,wBAAwB,CAAC,OAAO,CAAE,CAAC;AAMlD,MAAM,UAAU,qBAAqB,CAAC,UAAkC,EAAE;IACxE,MAAM,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,GAAG,OAAO,CAAC;IACxC,MAAM,UAAU,GAAG,6BAA6B,CAAC,MAAM,EAAE;QACvD,GAAG,UAAU;QACb,UAAU,EAAE,gBAAgB;QAC5B,IAAI,EAAE,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC;KAClE,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,4BAA4B,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACjF,IAAI,MAAM;QAAE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC;IACvC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,YAAY,CAAC,EAAE,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { HttpApiOperationDefinition } from "@assemblyline-agents/core";
2
+ export declare const GMAIL_OPERATIONS: HttpApiOperationDefinition[];
3
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,0BAA0B,EAAc,MAAM,2BAA2B,CAAC;AAYxF,eAAO,MAAM,gBAAgB,EAAE,0BAA0B,EAsCxD,CAAC"}
@@ -0,0 +1,58 @@
1
+ const id = (description) => ({ type: "string", minLength: 1, description });
2
+ const query = (name, schema, required = false) => ({ name, in: "query", schema, required });
3
+ const path = (name, description) => ({ name, in: "path", schema: id(description), required: true });
4
+ const pageSize = { type: "integer", minimum: 1, maximum: 500 };
5
+ const pageToken = id("Opaque next-page token returned by Gmail.");
6
+ const rawMessage = objectSchema({
7
+ raw: id("RFC 2822 message bytes encoded as base64url."),
8
+ threadId: id("Existing Gmail thread id when sending a reply in that thread.")
9
+ }, ["raw"]);
10
+ export const GMAIL_OPERATIONS = [
11
+ read("gmail_get_profile", "Get the connected Gmail account profile and mailbox history id.", "/users/me/profile"),
12
+ read("gmail_list_messages", "Search or list Gmail messages. Continue with pageToken when nextPageToken is returned.", "/users/me/messages", [
13
+ query("q", id("Gmail search query, such as from:alice@example.com newer_than:7d.")),
14
+ query("labelIds", { type: "array", items: id("Gmail label id.") }),
15
+ query("includeSpamTrash", { type: "boolean" }), query("maxResults", pageSize), query("pageToken", pageToken)
16
+ ]),
17
+ read("gmail_get_message", "Get one Gmail message by id, including headers and MIME parts according to format.", "/users/me/messages/{id}", [
18
+ path("id", "Gmail message id."),
19
+ query("format", { type: "string", enum: ["minimal", "full", "raw", "metadata"] }),
20
+ query("metadataHeaders", { type: "array", items: { type: "string" } })
21
+ ]),
22
+ read("gmail_get_attachment", "Get one Gmail attachment as base64url data.", "/users/me/messages/{messageId}/attachments/{id}", [
23
+ path("messageId", "Gmail message id."), path("id", "Attachment body id from the message MIME part.")
24
+ ]),
25
+ read("gmail_list_threads", "Search or list Gmail threads. Continue with pageToken when nextPageToken is returned.", "/users/me/threads", [
26
+ query("q", id("Gmail search query.")), query("labelIds", { type: "array", items: id("Gmail label id.") }),
27
+ query("includeSpamTrash", { type: "boolean" }), query("maxResults", pageSize), query("pageToken", pageToken)
28
+ ]),
29
+ read("gmail_get_thread", "Get a Gmail thread and its messages by thread id.", "/users/me/threads/{id}", [
30
+ path("id", "Gmail thread id."),
31
+ query("format", { type: "string", enum: ["minimal", "full", "metadata"] }),
32
+ query("metadataHeaders", { type: "array", items: { type: "string" } })
33
+ ]),
34
+ read("gmail_list_labels", "List labels in the connected Gmail mailbox.", "/users/me/labels"),
35
+ read("gmail_get_label", "Get one Gmail label and its message and thread counts.", "/users/me/labels/{id}", [path("id", "Gmail label id.")]),
36
+ read("gmail_list_drafts", "List Gmail drafts. Continue with pageToken when nextPageToken is returned.", "/users/me/drafts", [
37
+ query("q", id("Gmail search query used to filter drafts.")), query("includeSpamTrash", { type: "boolean" }),
38
+ query("maxResults", pageSize), query("pageToken", pageToken)
39
+ ]),
40
+ read("gmail_get_draft", "Get one Gmail draft and its message.", "/users/me/drafts/{id}", [
41
+ path("id", "Gmail draft id."), query("format", { type: "string", enum: ["minimal", "full", "raw", "metadata"] })
42
+ ]),
43
+ write("gmail_create_draft", "Create a Gmail draft from a base64url RFC 2822 message.", "POST", "/users/me/drafts", objectSchema({ message: rawMessage }, ["message"])),
44
+ write("gmail_update_draft", "Replace an existing Gmail draft with a base64url RFC 2822 message.", "PUT", "/users/me/drafts/{id}", objectSchema({ message: rawMessage }, ["message"]), [path("id", "Gmail draft id.")]),
45
+ { name: "gmail_delete_draft", description: "Permanently delete one Gmail draft.", method: "DELETE", path: "/users/me/drafts/{id}", parameters: [path("id", "Gmail draft id.")] },
46
+ write("gmail_send_draft", "Send an existing Gmail draft to the recipients in its message headers.", "POST", "/users/me/drafts/send", objectSchema({ id: id("Gmail draft id.") }, ["id"])),
47
+ write("gmail_send_message", "Send a base64url RFC 2822 message through Gmail.", "POST", "/users/me/messages/send", rawMessage)
48
+ ];
49
+ function read(name, description, operationPath, parameters) {
50
+ return { name, description, method: "GET", path: operationPath, ...(parameters ? { parameters } : {}) };
51
+ }
52
+ function write(name, description, method, operationPath, schema, parameters) {
53
+ return { name, description, method, path: operationPath, ...(parameters ? { parameters } : {}), body: { contentType: "application/json", field: "body", schema, required: true } };
54
+ }
55
+ function objectSchema(properties, required = []) {
56
+ return { type: "object", properties, ...(required.length ? { required } : {}), additionalProperties: false };
57
+ }
58
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAEA,MAAM,EAAE,GAAG,CAAC,WAAmB,EAAc,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;AAChG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CAAC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AAC/G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assemblyline-agents/gmail",
3
- "version": "1.0.0",
3
+ "version": "3.0.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -9,12 +9,11 @@
9
9
  }
10
10
  },
11
11
  "dependencies": {
12
- "@assemblyline-agents/core": "1.0.0"
12
+ "@assemblyline-agents/core": "3.0.0"
13
13
  },
14
- "description": "Official Assembly Line Gmail connection plugin.",
14
+ "description": "Official Assembly Line direct Gmail API connection plugin.",
15
15
  "files": [
16
- "dist",
17
- "skills"
16
+ "dist"
18
17
  ],
19
18
  "engines": {
20
19
  "node": ">=22.19.0"
@@ -1,13 +0,0 @@
1
- ---
2
- name: gmail
3
- description: Use a configured, independently authorized Gmail connection for mail search, threads, messages, attachments, drafts, and sends.
4
- ---
5
- # Gmail
6
-
7
- Use the `gmail` connection only for Gmail work. Its authorization is independent from Google Calendar and Google Drive; never assume either service is connected because Gmail is connected.
8
-
9
- Read narrowly before requesting broader data. Prefer a targeted Gmail query, then inspect the exact thread or message needed. The deployment owner configures the Gmail OAuth grant or MCP bridge. Never request, print, or store access tokens, refresh tokens, client secrets, API keys, or cookies.
10
-
11
- The scaffold is read-only. Draft creation or changes, sends, label changes, and other mailbox mutations require explicit write access and the configured approval gate. Approval for a send must cover the exact recipients, subject, body, thread, and attachments; request new approval if any of them changes.
12
-
13
- Read `references/gmail.md` when the task needs Gmail query syntax, thread behavior, attachments, drafts, or send safety.
@@ -1,41 +0,0 @@
1
- # Gmail
2
-
3
- Use the configured `gmail` connection for Gmail search, threads, messages, attachments, drafts, and sends.
4
-
5
- Official documentation:
6
-
7
- - https://developers.google.com/workspace/gmail/api/reference/rest
8
- - https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.messages/send
9
- - https://developers.google.com/workspace/gmail/api/reference/rest/v1/users.history/list
10
-
11
- ## Source Selection
12
-
13
- Use a bounded search for normal recall, then fetch the exact thread or message when freshness or complete context matters. Useful Gmail searches include:
14
-
15
- ```text
16
- in:inbox category:primary from:person@example.com
17
- in:inbox category:primary subject:(invoice)
18
- in:inbox category:primary newer_than:7d
19
- in:inbox category:primary has:attachment
20
- ```
21
-
22
- Gmail's Primary tab is the system label `CATEGORY_PERSONAL`; there is no `CATEGORY_PRIMARY`. Do not describe a Primary Inbox mirror or query as all Gmail. Keep pagination bounded rather than traversing a large mailbox in a foreground turn.
23
-
24
- ## Drafts And Sends
25
-
26
- Draft creation is a write. Sending mail is a high-impact write. Both require the configured write approval path.
27
-
28
- Common Gmail REST endpoints are:
29
-
30
- - `POST /gmail/v1/users/me/drafts`
31
- - `PUT /gmail/v1/users/me/drafts/{id}`
32
- - `POST /gmail/v1/users/me/drafts/send`
33
- - `POST /gmail/v1/users/me/messages/send`
34
-
35
- Resolve the exact MIME/RFC 2822 body before requesting approval. Approval must cover recipients, subject, body, thread id, attachments, method, path, and raw message hash where applicable. If the message changes, request approval again.
36
-
37
- Never claim mail was sent until the provider confirms the approved send.
38
-
39
- ## Attachments
40
-
41
- When answering from an attachment, identify the supporting filename. Keep binary handling bounded and avoid dumping private attachment content when a concise answer will do.