@squadbase/vite-server 0.1.3-dev.9 → 0.1.3

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.
Files changed (63) hide show
  1. package/dist/cli/index.js +14229 -29321
  2. package/dist/connectors/airtable-oauth.js +43 -6
  3. package/dist/connectors/airtable.js +43 -6
  4. package/dist/connectors/amplitude.js +43 -6
  5. package/dist/connectors/anthropic.js +43 -6
  6. package/dist/connectors/asana.js +43 -6
  7. package/dist/connectors/attio.js +43 -6
  8. package/dist/connectors/{google-ads-oauth.d.ts → backlog-api-key.d.ts} +1 -1
  9. package/dist/connectors/backlog-api-key.js +629 -0
  10. package/dist/connectors/customerio.js +43 -6
  11. package/dist/connectors/dbt.js +43 -6
  12. package/dist/connectors/{google-sheets-oauth.d.ts → gamma.d.ts} +1 -1
  13. package/dist/connectors/gamma.js +866 -0
  14. package/dist/connectors/gemini.js +43 -6
  15. package/dist/connectors/gmail-oauth.js +65 -8
  16. package/dist/connectors/gmail.js +104 -44
  17. package/dist/connectors/google-ads.d.ts +1 -1
  18. package/dist/connectors/google-ads.js +410 -332
  19. package/dist/connectors/google-analytics-oauth.js +61 -8
  20. package/dist/connectors/google-analytics.js +107 -292
  21. package/dist/connectors/google-calendar-oauth.js +61 -8
  22. package/dist/connectors/google-calendar.js +111 -58
  23. package/dist/connectors/{linkedin-ads-oauth.d.ts → google-docs.d.ts} +1 -1
  24. package/dist/connectors/google-docs.js +631 -0
  25. package/dist/connectors/google-drive.d.ts +5 -0
  26. package/dist/connectors/google-drive.js +875 -0
  27. package/dist/connectors/google-sheets.d.ts +1 -1
  28. package/dist/connectors/google-sheets.js +267 -285
  29. package/dist/connectors/google-slides.d.ts +5 -0
  30. package/dist/connectors/google-slides.js +663 -0
  31. package/dist/connectors/grafana.js +43 -6
  32. package/dist/connectors/hubspot-oauth.js +43 -6
  33. package/dist/connectors/hubspot.js +43 -6
  34. package/dist/connectors/intercom-oauth.js +43 -6
  35. package/dist/connectors/intercom.js +43 -6
  36. package/dist/connectors/jira-api-key.js +43 -6
  37. package/dist/connectors/kintone-api-token.js +256 -82
  38. package/dist/connectors/kintone.js +43 -6
  39. package/dist/connectors/linkedin-ads.js +188 -168
  40. package/dist/connectors/mailchimp-oauth.js +43 -6
  41. package/dist/connectors/mailchimp.js +43 -6
  42. package/dist/connectors/mixpanel.d.ts +5 -0
  43. package/dist/connectors/mixpanel.js +779 -0
  44. package/dist/connectors/notion-oauth.js +43 -6
  45. package/dist/connectors/notion.js +43 -6
  46. package/dist/connectors/openai.js +43 -6
  47. package/dist/connectors/sentry.d.ts +5 -0
  48. package/dist/connectors/sentry.js +761 -0
  49. package/dist/connectors/shopify-oauth.js +43 -6
  50. package/dist/connectors/shopify.js +43 -6
  51. package/dist/connectors/stripe-api-key.js +46 -7
  52. package/dist/connectors/stripe-oauth.js +43 -6
  53. package/dist/connectors/wix-store.js +43 -6
  54. package/dist/connectors/zendesk-oauth.js +43 -6
  55. package/dist/connectors/zendesk.js +43 -6
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +4476 -3949
  58. package/dist/main.js +4474 -3948
  59. package/dist/vite-plugin.js +4474 -3948
  60. package/package.json +30 -12
  61. package/dist/connectors/google-ads-oauth.js +0 -890
  62. package/dist/connectors/google-sheets-oauth.js +0 -718
  63. package/dist/connectors/linkedin-ads-oauth.js +0 -848
@@ -106,21 +106,58 @@ var ConnectorPlugin = class _ConnectorPlugin {
106
106
  * Filters connections by connectorKey internally.
107
107
  * Returns tools keyed as `${connectorKey}_${toolName}`.
108
108
  */
109
- createTools(connections, config) {
109
+ createTools(connections, config, opts) {
110
110
  const myConnections = connections.filter(
111
111
  (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
112
112
  );
113
113
  const result = {};
114
114
  for (const t of Object.values(this.tools)) {
115
- result[`${this.connectorKey}_${t.name}`] = t.createTool(
116
- myConnections,
117
- config
118
- );
115
+ const tool = t.createTool(myConnections, config);
116
+ const originalToModelOutput = tool.toModelOutput;
117
+ result[`${this.connectorKey}_${t.name}`] = {
118
+ ...tool,
119
+ toModelOutput: async (options) => {
120
+ if (!originalToModelOutput) {
121
+ return opts.truncateOutput(options.output);
122
+ }
123
+ const modelOutput = await originalToModelOutput(options);
124
+ if (modelOutput.type === "text" || modelOutput.type === "json") {
125
+ return opts.truncateOutput(modelOutput.value);
126
+ }
127
+ return modelOutput;
128
+ }
129
+ };
119
130
  }
120
131
  return result;
121
132
  }
122
133
  static deriveKey(slug, authType) {
123
- return authType ? `${slug}-${authType}` : slug;
134
+ if (authType) return `${slug}-${authType}`;
135
+ const LEGACY_NULL_AUTH_TYPE_MAP = {
136
+ // user-password
137
+ "postgresql": "user-password",
138
+ "mysql": "user-password",
139
+ "clickhouse": "user-password",
140
+ "kintone": "user-password",
141
+ "squadbase-db": "user-password",
142
+ // service-account
143
+ "snowflake": "service-account",
144
+ "bigquery": "service-account",
145
+ "google-analytics": "service-account",
146
+ "google-calendar": "service-account",
147
+ "aws-athena": "service-account",
148
+ "redshift": "service-account",
149
+ // api-key
150
+ "databricks": "api-key",
151
+ "dbt": "api-key",
152
+ "airtable": "api-key",
153
+ "openai": "api-key",
154
+ "gemini": "api-key",
155
+ "anthropic": "api-key",
156
+ "wix-store": "api-key"
157
+ };
158
+ const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
159
+ if (fallbackAuthType) return `${slug}-${fallbackAuthType}`;
160
+ return slug;
124
161
  }
125
162
  };
126
163
 
@@ -188,21 +188,58 @@ var ConnectorPlugin = class _ConnectorPlugin {
188
188
  * Filters connections by connectorKey internally.
189
189
  * Returns tools keyed as `${connectorKey}_${toolName}`.
190
190
  */
191
- createTools(connections, config) {
191
+ createTools(connections, config, opts) {
192
192
  const myConnections = connections.filter(
193
193
  (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
194
194
  );
195
195
  const result = {};
196
196
  for (const t of Object.values(this.tools)) {
197
- result[`${this.connectorKey}_${t.name}`] = t.createTool(
198
- myConnections,
199
- config
200
- );
197
+ const tool = t.createTool(myConnections, config);
198
+ const originalToModelOutput = tool.toModelOutput;
199
+ result[`${this.connectorKey}_${t.name}`] = {
200
+ ...tool,
201
+ toModelOutput: async (options) => {
202
+ if (!originalToModelOutput) {
203
+ return opts.truncateOutput(options.output);
204
+ }
205
+ const modelOutput = await originalToModelOutput(options);
206
+ if (modelOutput.type === "text" || modelOutput.type === "json") {
207
+ return opts.truncateOutput(modelOutput.value);
208
+ }
209
+ return modelOutput;
210
+ }
211
+ };
201
212
  }
202
213
  return result;
203
214
  }
204
215
  static deriveKey(slug, authType) {
205
- return authType ? `${slug}-${authType}` : slug;
216
+ if (authType) return `${slug}-${authType}`;
217
+ const LEGACY_NULL_AUTH_TYPE_MAP = {
218
+ // user-password
219
+ "postgresql": "user-password",
220
+ "mysql": "user-password",
221
+ "clickhouse": "user-password",
222
+ "kintone": "user-password",
223
+ "squadbase-db": "user-password",
224
+ // service-account
225
+ "snowflake": "service-account",
226
+ "bigquery": "service-account",
227
+ "google-analytics": "service-account",
228
+ "google-calendar": "service-account",
229
+ "aws-athena": "service-account",
230
+ "redshift": "service-account",
231
+ // api-key
232
+ "databricks": "api-key",
233
+ "dbt": "api-key",
234
+ "airtable": "api-key",
235
+ "openai": "api-key",
236
+ "gemini": "api-key",
237
+ "anthropic": "api-key",
238
+ "wix-store": "api-key"
239
+ };
240
+ const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
241
+ if (fallbackAuthType) return `${slug}-${fallbackAuthType}`;
242
+ return slug;
206
243
  }
207
244
  };
208
245
 
@@ -445,7 +482,17 @@ var gmailOauthConnector = new ConnectorPlugin({
445
482
 
446
483
  ### Business Logic
447
484
 
448
- The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables.
485
+ The business logic type for this connector is "typescript". Write handler code using the connector SDK shown below. Do NOT access credentials directly from environment variables and do NOT read \`INTERNAL_SQUADBASE_*\` env vars \u2014 the SDK takes care of OAuth.
486
+
487
+ SDK surface (client created via \`connection(connectionId)\`):
488
+ - \`client.request(path, init?)\` \u2014 low-level authenticated fetch (\`path\` is appended to \`https://gmail.googleapis.com/gmail/v1/users\`).
489
+ - \`client.getProfile()\` \u2014 fetch the authenticated user's profile.
490
+ - \`client.listLabels()\` \u2014 list all labels.
491
+ - \`client.listMessages(options?)\` \u2014 list messages with optional \`q\`, \`maxResults\`, \`labelIds\`, \`pageToken\`.
492
+ - \`client.getMessage(id, format?)\` \u2014 fetch a specific message (format: \`full\` / \`metadata\` / \`minimal\` / \`raw\`).
493
+ - \`client.listThreads(options?)\` / \`client.getThread(id)\` \u2014 thread operations.
494
+
495
+ If a handler test fails with \`Connection proxy is not configured\`, retry \u2014 the sandbox is still initializing. Do NOT abandon the SDK and construct OAuth proxy URLs manually.
449
496
 
450
497
  #### Example
451
498
 
@@ -518,7 +565,17 @@ thread.messages.forEach(m => console.log(m.snippet));
518
565
 
519
566
  ### Business Logic
520
567
 
521
- \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
568
+ \u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u4EE5\u4E0B\u306B\u793A\u3059\u30B3\u30CD\u30AF\u30BF SDK \u3092\u4F7F\u7528\u3057\u3066\u30CF\u30F3\u30C9\u30E9\u30B3\u30FC\u30C9\u3092\u8A18\u8FF0\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u76F4\u63A5\u8A8D\u8A3C\u60C5\u5831\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002\`INTERNAL_SQUADBASE_*\` \u306E\u74B0\u5883\u5909\u6570\u3092\u4F7F\u3063\u3066\u624B\u52D5\u3067 OAuth \u30D7\u30ED\u30AD\u30B7\u3092\u53E9\u304F\u3053\u3068\u3082\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044 \u2014 SDK \u304C OAuth \u3092\u51E6\u7406\u3057\u307E\u3059\u3002
569
+
570
+ SDK\uFF08\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8\uFF09:
571
+ - \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304D fetch\uFF08\`path\` \u306F \`https://gmail.googleapis.com/gmail/v1/users\` \u306B\u8FFD\u52A0\u3055\u308C\u307E\u3059\uFF09\u3002
572
+ - \`client.getProfile()\` \u2014 \u8A8D\u8A3C\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\u3002
573
+ - \`client.listLabels()\` \u2014 \u5168\u30E9\u30D9\u30EB\u3092\u4E00\u89A7\u3002
574
+ - \`client.listMessages(options?)\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7\uFF08\`q\`, \`maxResults\`, \`labelIds\`, \`pageToken\` \u30AA\u30D7\u30B7\u30E7\u30F3\u5BFE\u5FDC\uFF09\u3002
575
+ - \`client.getMessage(id, format?)\` \u2014 \u7279\u5B9A\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D6\u5F97\uFF08format: \`full\` / \`metadata\` / \`minimal\` / \`raw\`\uFF09\u3002
576
+ - \`client.listThreads(options?)\` / \`client.getThread(id)\` \u2014 \u30B9\u30EC\u30C3\u30C9\u64CD\u4F5C\u3002
577
+
578
+ \u30CF\u30F3\u30C9\u30E9\u306E\u30C6\u30B9\u30C8\u304C \`Connection proxy is not configured\` \u3067\u5931\u6557\u3059\u308B\u5834\u5408\u306F\u518D\u8A66\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u901A\u5E38\u306F\u30B5\u30F3\u30C9\u30DC\u30C3\u30AF\u30B9\u306E\u521D\u671F\u5316\u4E2D\u306B\u8D77\u304D\u307E\u3059\u3002SDK \u3092\u8AE6\u3081\u3066 OAuth \u30D7\u30ED\u30AD\u30B7\u306E URL \u3092\u81EA\u5206\u3067\u7D44\u307F\u7ACB\u3066\u308B\u3053\u3068\u306F **\u3057\u306A\u3044\u3067\u304F\u3060\u3055\u3044**\u3002
522
579
 
523
580
  #### Example
524
581
 
@@ -55,17 +55,17 @@ var parameters = {
55
55
  type: "base64EncodedJson",
56
56
  secret: true,
57
57
  required: true
58
- }),
59
- delegatedUserEmail: new ParameterDefinition({
60
- slug: "delegated-user-email",
61
- name: "Delegated User Email",
62
- description: "The email address of the Google Workspace user whose Gmail mailbox the service account will access via domain-wide delegation.",
63
- envVarBaseKey: "GMAIL_DELEGATED_USER_EMAIL",
64
- type: "text",
65
- secret: false,
66
- required: true
67
58
  })
68
59
  };
60
+ var delegatedUserEmailParameter = new ParameterDefinition({
61
+ slug: "delegated-user-email",
62
+ name: "Delegated User Email",
63
+ description: "The email address of the Google Workspace user whose Gmail mailbox the service account will access via domain-wide delegation. Collected during the setup flow.",
64
+ envVarBaseKey: "GMAIL_DELEGATED_USER_EMAIL",
65
+ type: "text",
66
+ secret: false,
67
+ required: false
68
+ });
69
69
 
70
70
  // ../connectors/src/connectors/gmail/sdk/index.ts
71
71
  var TOKEN_URL = "https://oauth2.googleapis.com/token";
@@ -96,7 +96,7 @@ function buildJwt(clientEmail, privateKey, subject, nowSec) {
96
96
  }
97
97
  function createClient(params) {
98
98
  const serviceAccountKeyJsonBase64 = params[parameters.serviceAccountKeyJsonBase64.slug];
99
- const delegatedUserEmail = params[parameters.delegatedUserEmail.slug];
99
+ const delegatedUserEmail = params[delegatedUserEmailParameter.slug];
100
100
  if (!serviceAccountKeyJsonBase64) {
101
101
  throw new Error(
102
102
  `gmail: missing required parameter: ${parameters.serviceAccountKeyJsonBase64.slug}`
@@ -104,7 +104,7 @@ function createClient(params) {
104
104
  }
105
105
  if (!delegatedUserEmail) {
106
106
  throw new Error(
107
- `gmail: missing required parameter: ${parameters.delegatedUserEmail.slug}`
107
+ `gmail: missing required parameter: ${delegatedUserEmailParameter.slug}`
108
108
  );
109
109
  }
110
110
  let serviceAccountKey;
@@ -346,21 +346,58 @@ var ConnectorPlugin = class _ConnectorPlugin {
346
346
  * Filters connections by connectorKey internally.
347
347
  * Returns tools keyed as `${connectorKey}_${toolName}`.
348
348
  */
349
- createTools(connections, config) {
349
+ createTools(connections, config, opts) {
350
350
  const myConnections = connections.filter(
351
351
  (c) => _ConnectorPlugin.deriveKey(c.connector.slug, c.connector.authType) === this.connectorKey
352
352
  );
353
353
  const result = {};
354
354
  for (const t of Object.values(this.tools)) {
355
- result[`${this.connectorKey}_${t.name}`] = t.createTool(
356
- myConnections,
357
- config
358
- );
355
+ const tool = t.createTool(myConnections, config);
356
+ const originalToModelOutput = tool.toModelOutput;
357
+ result[`${this.connectorKey}_${t.name}`] = {
358
+ ...tool,
359
+ toModelOutput: async (options) => {
360
+ if (!originalToModelOutput) {
361
+ return opts.truncateOutput(options.output);
362
+ }
363
+ const modelOutput = await originalToModelOutput(options);
364
+ if (modelOutput.type === "text" || modelOutput.type === "json") {
365
+ return opts.truncateOutput(modelOutput.value);
366
+ }
367
+ return modelOutput;
368
+ }
369
+ };
359
370
  }
360
371
  return result;
361
372
  }
362
373
  static deriveKey(slug, authType) {
363
- return authType ? `${slug}-${authType}` : slug;
374
+ if (authType) return `${slug}-${authType}`;
375
+ const LEGACY_NULL_AUTH_TYPE_MAP = {
376
+ // user-password
377
+ "postgresql": "user-password",
378
+ "mysql": "user-password",
379
+ "clickhouse": "user-password",
380
+ "kintone": "user-password",
381
+ "squadbase-db": "user-password",
382
+ // service-account
383
+ "snowflake": "service-account",
384
+ "bigquery": "service-account",
385
+ "google-analytics": "service-account",
386
+ "google-calendar": "service-account",
387
+ "aws-athena": "service-account",
388
+ "redshift": "service-account",
389
+ // api-key
390
+ "databricks": "api-key",
391
+ "dbt": "api-key",
392
+ "airtable": "api-key",
393
+ "openai": "api-key",
394
+ "gemini": "api-key",
395
+ "anthropic": "api-key",
396
+ "wix-store": "api-key"
397
+ };
398
+ const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
399
+ if (fallbackAuthType) return `${slug}-${fallbackAuthType}`;
400
+ return slug;
364
401
  }
365
402
  };
366
403
 
@@ -423,7 +460,7 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
423
460
  try {
424
461
  const { GoogleAuth } = await import("google-auth-library");
425
462
  const keyJsonBase64 = parameters.serviceAccountKeyJsonBase64.getValue(connection2);
426
- const delegatedUserEmail = parameters.delegatedUserEmail.getValue(connection2);
463
+ const delegatedUserEmail = delegatedUserEmailParameter.getValue(connection2);
427
464
  const credentials = JSON.parse(
428
465
  Buffer.from(keyJsonBase64, "base64").toString("utf-8")
429
466
  );
@@ -474,43 +511,57 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
474
511
  });
475
512
 
476
513
  // ../connectors/src/connectors/gmail/setup.ts
477
- var requestToolName = `gmail_${requestTool.name}`;
514
+ var requestToolName = `gmail-service-account_${requestTool.name}`;
478
515
  var gmailOnboarding = new ConnectorOnboarding({
479
516
  connectionSetupInstructions: {
480
- ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Gmail\uFF08\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\uFF09\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
481
-
482
- 1. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\u3059\u308B:
517
+ ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Gmail\uFF08\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\uFF09\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002\u63A5\u7D9A\u4F5C\u6210\u6642\u306B\u306F\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8JSON\u306E\u307F\u304C\u8A2D\u5B9A\u6E08\u307F\u3067\u3001\u59D4\u4EFB\u5BFE\u8C61\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u306F\u3053\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u53D6\u5F97\u3057\u307E\u3059\u3002
518
+
519
+ 1. \`askUserQuestion\` \u3067\u3001\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u304CDomain-wide Delegation\u3067\u4EE3\u7406\u30A2\u30AF\u30BB\u30B9\u3059\u308BGoogle Workspace\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u30D2\u30A2\u30EA\u30F3\u30B0\u3059\u308B:
520
+ - \`question\`: \u300CGmail\u3092\u53C2\u7167\u3059\u308BGoogle Workspace\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u300D
521
+ - \`header\`: \u300C\u30E1\u30FC\u30EB\u5165\u529B\u300D
522
+ - \`options\`: \`[{ label: "\u4F8B: user@example.com", description: "\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u4EE3\u7406\u30A2\u30AF\u30BB\u30B9\u3059\u308B\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B" }, { label: "\u5225\u306E\u4F8B: admin@example.com", description: "\u7BA1\u7406\u8005\u30E6\u30FC\u30B6\u30FC\u3084\u5171\u6709\u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u306E\u30A2\u30C9\u30EC\u30B9\u3067\u3082\u53EF" }]\` \uFF08\`allowFreeText: true\` \u306E\u305F\u3081\u81EA\u7531\u5165\u529B\u53EF\uFF09
523
+ 2. \u53D7\u3051\u53D6\u3063\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092 \`updateConnectionParameters\` \u3067\u4FDD\u5B58\u3059\u308B:
524
+ - \`parameterSlug\`: \`"delegated-user-email"\`
525
+ - \`options\`: \`[{ value: <\u5165\u529B\u3055\u308C\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9>, label: <\u540C\u3058\u5024> }]\`\uFF081\u4EF6\u306E\u307F\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u81EA\u52D5\u9078\u629E\u3055\u308C\u308B\uFF09
526
+ 3. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\u3059\u308B:
483
527
  - \`method\`: \`"GET"\`
484
528
  - \`path\`: \`"/me/profile"\`
485
- 2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u4EE5\u4E0B\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u308B:
529
+ 4. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u4EE5\u4E0B\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u308B:
486
530
  - \u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u304C\u6709\u52B9\u304B
487
531
  - Google Workspace\u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u3067Gmail API\u30B9\u30B3\u30FC\u30D7\u304C\u8A31\u53EF\u3055\u308C\u3066\u3044\u308B\u304B
488
- - \u59D4\u4EFB\u5BFE\u8C61\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304C\u6B63\u3057\u3044\u304B
489
- 3. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E9\u30D9\u30EB\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
532
+ - \u5165\u529B\u3055\u308C\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304C\u6B63\u3057\u3044\u304B
533
+ 5. \`${requestToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E9\u30D9\u30EB\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
490
534
  - \`method\`: \`"GET"\`
491
535
  - \`path\`: \`"/me/labels"\`
492
- 4. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
493
- - \`email\`: \u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9
536
+ 6. \`updateConnectionContext\` \u3092\u547C\u3073\u51FA\u3059:
537
+ - \`email\`: \u8A2D\u5B9A\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9
494
538
  - \`labels\`: \u4E3B\u8981\u306A\u30E9\u30D9\u30EB\u540D\u4E00\u89A7\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3001INBOX, SENT, DRAFT, SPAM, TRASH\u7B49\u306E\u30B7\u30B9\u30C6\u30E0\u30E9\u30D9\u30EB\u3092\u542B\u3080\uFF09
495
539
  - \`note\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u5185\u5BB9\u306E\u7C21\u5358\u306A\u8AAC\u660E
496
540
 
497
541
  #### \u5236\u7D04
498
542
  - **\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u30E1\u30C3\u30BB\u30FC\u30B8\u672C\u6587\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3053\u3068**\u3002\u5B9F\u884C\u3057\u3066\u3088\u3044\u306E\u306F\u4E0A\u8A18\u624B\u9806\u3067\u6307\u5B9A\u3055\u308C\u305F\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u53D6\u5F97\u3068\u30E9\u30D9\u30EB\u4E00\u89A7\u53D6\u5F97\u306E\u307F
499
543
  - \u30C4\u30FC\u30EB\u9593\u306F1\u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u3002\u4E0D\u8981\u306A\u8AAC\u660E\u306F\u7701\u7565\u3057\u3001\u52B9\u7387\u7684\u306B\u9032\u3081\u308B`,
500
- en: `Follow these steps to set up the Gmail (Service Account) connection.
501
-
502
- 1. Call \`${requestToolName}\` to get the user's profile:
544
+ en: `Follow these steps to set up the Gmail (Service Account) connection. Only the service account JSON is provided at connection creation time \u2014 the delegated user email is collected during this setup flow.
545
+
546
+ 1. Call \`askUserQuestion\` to ask the user for the Google Workspace user email the service account will impersonate via Domain-wide Delegation:
547
+ - \`question\`: "Please enter the email address of the Google Workspace user whose Gmail mailbox you want to access"
548
+ - \`header\`: "Email input"
549
+ - \`options\`: \`[{ label: "e.g., user@example.com", description: "The user whose mailbox the service account will impersonate" }, { label: "e.g., admin@example.com", description: "An admin user or shared mailbox is also fine" }]\` (free text entry is allowed because \`allowFreeText: true\`)
550
+ 2. Save the email via \`updateConnectionParameters\`:
551
+ - \`parameterSlug\`: \`"delegated-user-email"\`
552
+ - \`options\`: \`[{ value: <entered email>, label: <same value> }]\` (a single option is auto-selected)
553
+ 3. Call \`${requestToolName}\` to get the user's profile:
503
554
  - \`method\`: \`"GET"\`
504
555
  - \`path\`: \`"/me/profile"\`
505
- 2. If an error is returned, ask the user to verify:
556
+ 4. If an error is returned, ask the user to verify:
506
557
  - Domain-wide delegation is enabled for the service account
507
558
  - Gmail API scope is authorized in Google Workspace admin console
508
- - The delegated user email address is correct
509
- 3. Call \`${requestToolName}\` to get the label list:
559
+ - The entered email address is correct
560
+ 5. Call \`${requestToolName}\` to get the label list:
510
561
  - \`method\`: \`"GET"\`
511
562
  - \`path\`: \`"/me/labels"\`
512
- 4. Call \`updateConnectionContext\`:
513
- - \`email\`: The user's email address
563
+ 6. Call \`updateConnectionContext\`:
564
+ - \`email\`: The configured email address
514
565
  - \`labels\`: Key label names (comma-separated, including system labels like INBOX, SENT, DRAFT, SPAM, TRASH)
515
566
  - \`note\`: Brief description of the setup
516
567
 
@@ -519,12 +570,12 @@ var gmailOnboarding = new ConnectorOnboarding({
519
570
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
520
571
  },
521
572
  dataOverviewInstructions: {
522
- en: `1. Call gmail_request with GET /me/labels to list all labels
523
- 2. Call gmail_request with GET /me/messages?maxResults=5 to get recent message IDs
524
- 3. Call gmail_request with GET /me/messages/{id}?format=metadata for each message to see subjects and senders`,
525
- ja: `1. gmail_request \u3067 GET /me/labels \u3092\u547C\u3073\u51FA\u3057\u3001\u5168\u30E9\u30D9\u30EB\u4E00\u89A7\u3092\u53D6\u5F97
526
- 2. gmail_request \u3067 GET /me/messages?maxResults=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u65B0\u30E1\u30C3\u30BB\u30FC\u30B8ID\u3092\u53D6\u5F97
527
- 3. \u5404\u30E1\u30C3\u30BB\u30FC\u30B8\u306B\u3064\u3044\u3066 gmail_request \u3067 GET /me/messages/{id}?format=metadata \u3092\u547C\u3073\u51FA\u3057\u3001\u4EF6\u540D\u3068\u9001\u4FE1\u8005\u3092\u78BA\u8A8D`
573
+ en: `1. Call gmail-service-account_request with GET /me/labels to list all labels
574
+ 2. Call gmail-service-account_request with GET /me/messages?maxResults=5 to get recent message IDs
575
+ 3. Call gmail-service-account_request with GET /me/messages/{id}?format=metadata for each message to see subjects and senders`,
576
+ ja: `1. gmail-service-account_request \u3067 GET /me/labels \u3092\u547C\u3073\u51FA\u3057\u3001\u5168\u30E9\u30D9\u30EB\u4E00\u89A7\u3092\u53D6\u5F97
577
+ 2. gmail-service-account_request \u3067 GET /me/messages?maxResults=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u65B0\u30E1\u30C3\u30BB\u30FC\u30B8ID\u3092\u53D6\u5F97
578
+ 3. \u5404\u30E1\u30C3\u30BB\u30FC\u30B8\u306B\u3064\u3044\u3066 gmail-service-account_request \u3067 GET /me/messages/{id}?format=metadata \u3092\u547C\u3073\u51FA\u3057\u3001\u4EF6\u540D\u3068\u9001\u4FE1\u8005\u3092\u78BA\u8A8D`
528
579
  }
529
580
  });
530
581
 
@@ -542,7 +593,7 @@ var gmailConnector = new ConnectorPlugin({
542
593
  systemPrompt: {
543
594
  en: `### Tools
544
595
 
545
- - \`gmail_request\`: The only way to call the Gmail API (read-only). Use it to list messages, get message details, list labels, list threads, and get user profile. Authentication is handled automatically using a service account with domain-wide delegation.
596
+ - \`gmail-service-account_request\`: The only way to call the Gmail API (read-only). Use it to list messages, get message details, list labels, list threads, and get user profile. Authentication is handled automatically using a service account with domain-wide delegation.
546
597
 
547
598
  ### Gmail API Reference
548
599
 
@@ -615,7 +666,7 @@ thread.messages.forEach(m => console.log(m.snippet));
615
666
  \`\`\``,
616
667
  ja: `### \u30C4\u30FC\u30EB
617
668
 
618
- - \`gmail_request\`: Gmail API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\uFF08\u8AAD\u307F\u53D6\u308A\u5C02\u7528\uFF09\u3002\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7\u306E\u53D6\u5F97\u3001\u30E1\u30C3\u30BB\u30FC\u30B8\u8A73\u7D30\u306E\u53D6\u5F97\u3001\u30E9\u30D9\u30EB\u4E00\u89A7\u3001\u30B9\u30EC\u30C3\u30C9\u4E00\u89A7\u3001\u30E6\u30FC\u30B6\u30FC\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u306E\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u3092\u4F7F\u7528\u3057\u3066\u8A8D\u8A3C\u306F\u81EA\u52D5\u7684\u306B\u51E6\u7406\u3055\u308C\u307E\u3059\u3002
669
+ - \`gmail-service-account_request\`: Gmail API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\uFF08\u8AAD\u307F\u53D6\u308A\u5C02\u7528\uFF09\u3002\u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7\u306E\u53D6\u5F97\u3001\u30E1\u30C3\u30BB\u30FC\u30B8\u8A73\u7D30\u306E\u53D6\u5F97\u3001\u30E9\u30D9\u30EB\u4E00\u89A7\u3001\u30B9\u30EC\u30C3\u30C9\u4E00\u89A7\u3001\u30E6\u30FC\u30B6\u30FC\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u306E\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u3092\u4F7F\u7528\u3057\u3066\u8A8D\u8A3C\u306F\u81EA\u52D5\u7684\u306B\u51E6\u7406\u3055\u308C\u307E\u3059\u3002
619
670
 
620
671
  ### Gmail API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
621
672
 
@@ -696,7 +747,16 @@ thread.messages.forEach(m => console.log(m.snippet));
696
747
  "base64"
697
748
  ).toString("utf-8")
698
749
  );
699
- const delegatedUserEmail = params[parameters.delegatedUserEmail.slug];
750
+ const delegatedUserEmail = params[delegatedUserEmailParameter.slug];
751
+ if (!delegatedUserEmail) {
752
+ if (!credentials.client_email || !credentials.private_key) {
753
+ return {
754
+ success: false,
755
+ error: "Service account JSON must contain client_email and private_key"
756
+ };
757
+ }
758
+ return { success: true };
759
+ }
700
760
  const auth = new GoogleAuth({
701
761
  credentials,
702
762
  scopes: ["https://www.googleapis.com/auth/gmail.readonly"],
@@ -1,5 +1,5 @@
1
1
  import * as _squadbase_connectors_sdk from '@squadbase/connectors/sdk';
2
2
 
3
- declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleAdsServiceAccountConnectorSdk;
3
+ declare const connection: (connectionId: string) => _squadbase_connectors_sdk.GoogleAdsConnectorSdk;
4
4
 
5
5
  export { connection };