@squadbase/vite-server 0.1.8-dev.d378524 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +749 -617
- package/dist/cli/{sshcrypto-VVJOJ3LR.node → sshcrypto-P3UBA7BP.node} +0 -0
- package/dist/connectors/gmail.js +214 -348
- package/dist/connectors/google-calendar.js +477 -449
- package/dist/index.js +749 -617
- package/dist/main.js +749 -617
- package/dist/{sshcrypto-VVJOJ3LR.node → sshcrypto-P3UBA7BP.node} +0 -0
- package/dist/vite-plugin.js +749 -617
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2806,22 +2806,22 @@ var require_nacl_fast = __commonJS({
|
|
|
2806
2806
|
randombytes = fn;
|
|
2807
2807
|
};
|
|
2808
2808
|
(function() {
|
|
2809
|
-
var
|
|
2810
|
-
if (
|
|
2809
|
+
var crypto8 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
2810
|
+
if (crypto8 && crypto8.getRandomValues) {
|
|
2811
2811
|
var QUOTA = 65536;
|
|
2812
2812
|
nacl.setPRNG(function(x6, n6) {
|
|
2813
2813
|
var i6, v7 = new Uint8Array(n6);
|
|
2814
2814
|
for (i6 = 0; i6 < n6; i6 += QUOTA) {
|
|
2815
|
-
|
|
2815
|
+
crypto8.getRandomValues(v7.subarray(i6, i6 + Math.min(n6 - i6, QUOTA)));
|
|
2816
2816
|
}
|
|
2817
2817
|
for (i6 = 0; i6 < n6; i6++) x6[i6] = v7[i6];
|
|
2818
2818
|
cleanup(v7);
|
|
2819
2819
|
});
|
|
2820
2820
|
} else if (typeof __require !== "undefined") {
|
|
2821
|
-
|
|
2822
|
-
if (
|
|
2821
|
+
crypto8 = __require("crypto");
|
|
2822
|
+
if (crypto8 && crypto8.randomBytes) {
|
|
2823
2823
|
nacl.setPRNG(function(x6, n6) {
|
|
2824
|
-
var i6, v7 =
|
|
2824
|
+
var i6, v7 = crypto8.randomBytes(n6);
|
|
2825
2825
|
for (i6 = 0; i6 < n6; i6++) x6[i6] = v7[i6];
|
|
2826
2826
|
cleanup(v7);
|
|
2827
2827
|
});
|
|
@@ -4118,7 +4118,7 @@ var require_lib2 = __commonJS({
|
|
|
4118
4118
|
var require_constants = __commonJS({
|
|
4119
4119
|
"../../node_modules/ssh2/lib/protocol/constants.js"(exports2, module) {
|
|
4120
4120
|
"use strict";
|
|
4121
|
-
var
|
|
4121
|
+
var crypto8 = __require("crypto");
|
|
4122
4122
|
var cpuInfo;
|
|
4123
4123
|
try {
|
|
4124
4124
|
cpuInfo = require_lib2()();
|
|
@@ -4126,21 +4126,21 @@ var require_constants = __commonJS({
|
|
|
4126
4126
|
}
|
|
4127
4127
|
var { bindingAvailable, CIPHER_INFO, MAC_INFO } = require_crypto();
|
|
4128
4128
|
var eddsaSupported = (() => {
|
|
4129
|
-
if (typeof
|
|
4129
|
+
if (typeof crypto8.sign === "function" && typeof crypto8.verify === "function") {
|
|
4130
4130
|
const key = "-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r\n-----END PRIVATE KEY-----";
|
|
4131
4131
|
const data = Buffer.from("a");
|
|
4132
4132
|
let sig;
|
|
4133
4133
|
let verified;
|
|
4134
4134
|
try {
|
|
4135
|
-
sig =
|
|
4136
|
-
verified =
|
|
4135
|
+
sig = crypto8.sign(null, data, key);
|
|
4136
|
+
verified = crypto8.verify(null, data, key, sig);
|
|
4137
4137
|
} catch {
|
|
4138
4138
|
}
|
|
4139
4139
|
return Buffer.isBuffer(sig) && sig.length === 64 && verified === true;
|
|
4140
4140
|
}
|
|
4141
4141
|
return false;
|
|
4142
4142
|
})();
|
|
4143
|
-
var curve25519Supported = typeof
|
|
4143
|
+
var curve25519Supported = typeof crypto8.diffieHellman === "function" && typeof crypto8.generateKeyPairSync === "function" && typeof crypto8.createPublicKey === "function";
|
|
4144
4144
|
var DEFAULT_KEX = [
|
|
4145
4145
|
// https://tools.ietf.org/html/rfc5656#section-10.1
|
|
4146
4146
|
"ecdh-sha2-nistp256",
|
|
@@ -4183,7 +4183,7 @@ var require_constants = __commonJS({
|
|
|
4183
4183
|
"ssh-dss"
|
|
4184
4184
|
]);
|
|
4185
4185
|
var canUseCipher = (() => {
|
|
4186
|
-
const ciphers =
|
|
4186
|
+
const ciphers = crypto8.getCiphers();
|
|
4187
4187
|
return (name) => ciphers.includes(CIPHER_INFO[name].sslName);
|
|
4188
4188
|
})();
|
|
4189
4189
|
var DEFAULT_CIPHER = [
|
|
@@ -4221,7 +4221,7 @@ var require_constants = __commonJS({
|
|
|
4221
4221
|
"arcfour"
|
|
4222
4222
|
].filter(canUseCipher));
|
|
4223
4223
|
var canUseMAC = (() => {
|
|
4224
|
-
const hashes =
|
|
4224
|
+
const hashes = crypto8.getHashes();
|
|
4225
4225
|
return (name) => hashes.includes(MAC_INFO[name].sslName);
|
|
4226
4226
|
})();
|
|
4227
4227
|
var DEFAULT_MAC = [
|
|
@@ -4827,7 +4827,7 @@ var require_utils = __commonJS({
|
|
|
4827
4827
|
var sshcrypto_default;
|
|
4828
4828
|
var init_sshcrypto = __esm({
|
|
4829
4829
|
"../../node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node"() {
|
|
4830
|
-
sshcrypto_default = "./sshcrypto-
|
|
4830
|
+
sshcrypto_default = "./sshcrypto-P3UBA7BP.node";
|
|
4831
4831
|
}
|
|
4832
4832
|
});
|
|
4833
4833
|
|
|
@@ -6605,7 +6605,7 @@ var require_keyParser = __commonJS({
|
|
|
6605
6605
|
createECDH,
|
|
6606
6606
|
createHash: createHash4,
|
|
6607
6607
|
createHmac: createHmac2,
|
|
6608
|
-
createSign
|
|
6608
|
+
createSign,
|
|
6609
6609
|
createVerify,
|
|
6610
6610
|
getCiphers,
|
|
6611
6611
|
sign: sign_,
|
|
@@ -6906,7 +6906,7 @@ ${formatted}-----END ${type} KEY-----`;
|
|
|
6906
6906
|
return new Error("No private key available");
|
|
6907
6907
|
if (!algo || typeof algo !== "string")
|
|
6908
6908
|
algo = this[SYM_HASH_ALGO];
|
|
6909
|
-
const signature =
|
|
6909
|
+
const signature = createSign(algo);
|
|
6910
6910
|
signature.update(data);
|
|
6911
6911
|
try {
|
|
6912
6912
|
return signature.sign(pem);
|
|
@@ -20415,8 +20415,8 @@ var require_bson = __commonJS({
|
|
|
20415
20415
|
return crypto.getRandomValues(nodeJsByteUtils.allocate(byteLength));
|
|
20416
20416
|
}
|
|
20417
20417
|
var nodejsRandomBytes = (() => {
|
|
20418
|
-
const { crypto:
|
|
20419
|
-
if (
|
|
20418
|
+
const { crypto: crypto8 } = globalThis;
|
|
20419
|
+
if (crypto8 != null && typeof crypto8.getRandomValues === "function") {
|
|
20420
20420
|
return nodejsSecureRandomBytes;
|
|
20421
20421
|
} else {
|
|
20422
20422
|
return nodejsMathRandomBytes;
|
|
@@ -20521,10 +20521,10 @@ var require_bson = __commonJS({
|
|
|
20521
20521
|
return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
|
|
20522
20522
|
}
|
|
20523
20523
|
var webRandomBytes = (() => {
|
|
20524
|
-
const { crypto:
|
|
20525
|
-
if (
|
|
20524
|
+
const { crypto: crypto8 } = globalThis;
|
|
20525
|
+
if (crypto8 != null && typeof crypto8.getRandomValues === "function") {
|
|
20526
20526
|
return (byteLength) => {
|
|
20527
|
-
return
|
|
20527
|
+
return crypto8.getRandomValues(webByteUtils.allocate(byteLength));
|
|
20528
20528
|
};
|
|
20529
20529
|
} else {
|
|
20530
20530
|
if (isReactNative()) {
|
|
@@ -27026,7 +27026,7 @@ var require_utils3 = __commonJS({
|
|
|
27026
27026
|
exports2.decorateDecryptionResult = decorateDecryptionResult;
|
|
27027
27027
|
exports2.addAbortListener = addAbortListener;
|
|
27028
27028
|
exports2.abortable = abortable;
|
|
27029
|
-
var
|
|
27029
|
+
var crypto8 = __require("crypto");
|
|
27030
27030
|
var fs_1 = __require("fs");
|
|
27031
27031
|
var http2 = __require("http");
|
|
27032
27032
|
var process2 = __require("process");
|
|
@@ -27186,7 +27186,7 @@ var require_utils3 = __commonJS({
|
|
|
27186
27186
|
}
|
|
27187
27187
|
}
|
|
27188
27188
|
function uuidV4() {
|
|
27189
|
-
const result =
|
|
27189
|
+
const result = crypto8.randomBytes(16);
|
|
27190
27190
|
result[6] = result[6] & 15 | 64;
|
|
27191
27191
|
result[8] = result[8] & 63 | 128;
|
|
27192
27192
|
return result;
|
|
@@ -27738,7 +27738,7 @@ var require_utils3 = __commonJS({
|
|
|
27738
27738
|
}
|
|
27739
27739
|
var randomBytes = (size) => {
|
|
27740
27740
|
return new Promise((resolve, reject) => {
|
|
27741
|
-
|
|
27741
|
+
crypto8.randomBytes(size, (error2, buf) => {
|
|
27742
27742
|
if (error2)
|
|
27743
27743
|
return reject(error2);
|
|
27744
27744
|
resolve(buf);
|
|
@@ -39491,12 +39491,12 @@ var init_date_utils = __esm({
|
|
|
39491
39491
|
});
|
|
39492
39492
|
|
|
39493
39493
|
// ../../node_modules/@smithy/uuid/dist-es/randomUUID.js
|
|
39494
|
-
import
|
|
39494
|
+
import crypto3 from "crypto";
|
|
39495
39495
|
var randomUUID;
|
|
39496
39496
|
var init_randomUUID = __esm({
|
|
39497
39497
|
"../../node_modules/@smithy/uuid/dist-es/randomUUID.js"() {
|
|
39498
39498
|
"use strict";
|
|
39499
|
-
randomUUID =
|
|
39499
|
+
randomUUID = crypto3.randomUUID.bind(crypto3);
|
|
39500
39500
|
}
|
|
39501
39501
|
});
|
|
39502
39502
|
|
|
@@ -61430,10 +61430,10 @@ var require_retry = __commonJS({
|
|
|
61430
61430
|
});
|
|
61431
61431
|
|
|
61432
61432
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/rng.js
|
|
61433
|
-
import
|
|
61433
|
+
import crypto4 from "crypto";
|
|
61434
61434
|
function rng() {
|
|
61435
61435
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
61436
|
-
|
|
61436
|
+
crypto4.randomFillSync(rnds8Pool);
|
|
61437
61437
|
poolPtr = 0;
|
|
61438
61438
|
}
|
|
61439
61439
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
@@ -61644,14 +61644,14 @@ var init_v35 = __esm({
|
|
|
61644
61644
|
});
|
|
61645
61645
|
|
|
61646
61646
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/md5.js
|
|
61647
|
-
import
|
|
61647
|
+
import crypto5 from "crypto";
|
|
61648
61648
|
function md5(bytes) {
|
|
61649
61649
|
if (Array.isArray(bytes)) {
|
|
61650
61650
|
bytes = Buffer.from(bytes);
|
|
61651
61651
|
} else if (typeof bytes === "string") {
|
|
61652
61652
|
bytes = Buffer.from(bytes, "utf8");
|
|
61653
61653
|
}
|
|
61654
|
-
return
|
|
61654
|
+
return crypto5.createHash("md5").update(bytes).digest();
|
|
61655
61655
|
}
|
|
61656
61656
|
var md5_default;
|
|
61657
61657
|
var init_md5 = __esm({
|
|
@@ -61674,13 +61674,13 @@ var init_v3 = __esm({
|
|
|
61674
61674
|
});
|
|
61675
61675
|
|
|
61676
61676
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/native.js
|
|
61677
|
-
import
|
|
61677
|
+
import crypto6 from "crypto";
|
|
61678
61678
|
var native_default;
|
|
61679
61679
|
var init_native = __esm({
|
|
61680
61680
|
"../../node_modules/gaxios/node_modules/uuid/dist/esm-node/native.js"() {
|
|
61681
61681
|
"use strict";
|
|
61682
61682
|
native_default = {
|
|
61683
|
-
randomUUID:
|
|
61683
|
+
randomUUID: crypto6.randomUUID
|
|
61684
61684
|
};
|
|
61685
61685
|
}
|
|
61686
61686
|
});
|
|
@@ -61715,14 +61715,14 @@ var init_v42 = __esm({
|
|
|
61715
61715
|
});
|
|
61716
61716
|
|
|
61717
61717
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/sha1.js
|
|
61718
|
-
import
|
|
61718
|
+
import crypto7 from "crypto";
|
|
61719
61719
|
function sha1(bytes) {
|
|
61720
61720
|
if (Array.isArray(bytes)) {
|
|
61721
61721
|
bytes = Buffer.from(bytes);
|
|
61722
61722
|
} else if (typeof bytes === "string") {
|
|
61723
61723
|
bytes = Buffer.from(bytes, "utf8");
|
|
61724
61724
|
}
|
|
61725
|
-
return
|
|
61725
|
+
return crypto7.createHash("sha1").update(bytes).digest();
|
|
61726
61726
|
}
|
|
61727
61727
|
var sha1_default;
|
|
61728
61728
|
var init_sha1 = __esm({
|
|
@@ -82406,7 +82406,7 @@ var require_scram = __commonJS({
|
|
|
82406
82406
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
82407
82407
|
exports2.ScramSHA256 = exports2.ScramSHA1 = void 0;
|
|
82408
82408
|
var saslprep_1 = require_node2();
|
|
82409
|
-
var
|
|
82409
|
+
var crypto8 = __require("crypto");
|
|
82410
82410
|
var bson_1 = require_bson2();
|
|
82411
82411
|
var error_1 = require_error();
|
|
82412
82412
|
var utils_1 = require_utils3();
|
|
@@ -82559,9 +82559,9 @@ var require_scram = __commonJS({
|
|
|
82559
82559
|
}
|
|
82560
82560
|
let md52;
|
|
82561
82561
|
try {
|
|
82562
|
-
md52 =
|
|
82562
|
+
md52 = crypto8.createHash("md5");
|
|
82563
82563
|
} catch (err) {
|
|
82564
|
-
if (
|
|
82564
|
+
if (crypto8.getFips()) {
|
|
82565
82565
|
throw new Error("Auth mechanism SCRAM-SHA-1 is not supported in FIPS mode");
|
|
82566
82566
|
}
|
|
82567
82567
|
throw err;
|
|
@@ -82584,10 +82584,10 @@ var require_scram = __commonJS({
|
|
|
82584
82584
|
return Buffer.from(res).toString("base64");
|
|
82585
82585
|
}
|
|
82586
82586
|
function H2(method, text) {
|
|
82587
|
-
return
|
|
82587
|
+
return crypto8.createHash(method).update(text).digest();
|
|
82588
82588
|
}
|
|
82589
82589
|
function HMAC(method, key, text) {
|
|
82590
|
-
return
|
|
82590
|
+
return crypto8.createHmac(method, key).update(text).digest();
|
|
82591
82591
|
}
|
|
82592
82592
|
var _hiCache = {};
|
|
82593
82593
|
var _hiCacheCount = 0;
|
|
@@ -82604,7 +82604,7 @@ var require_scram = __commonJS({
|
|
|
82604
82604
|
if (_hiCache[key] != null) {
|
|
82605
82605
|
return _hiCache[key];
|
|
82606
82606
|
}
|
|
82607
|
-
const saltedData =
|
|
82607
|
+
const saltedData = crypto8.pbkdf2Sync(data, salt, iterations, hiLengthMap[cryptoMethod], cryptoMethod);
|
|
82608
82608
|
if (_hiCacheCount >= 200) {
|
|
82609
82609
|
_hiCachePurge();
|
|
82610
82610
|
}
|
|
@@ -82616,8 +82616,8 @@ var require_scram = __commonJS({
|
|
|
82616
82616
|
if (lhs.length !== rhs.length) {
|
|
82617
82617
|
return false;
|
|
82618
82618
|
}
|
|
82619
|
-
if (typeof
|
|
82620
|
-
return
|
|
82619
|
+
if (typeof crypto8.timingSafeEqual === "function") {
|
|
82620
|
+
return crypto8.timingSafeEqual(lhs, rhs);
|
|
82621
82621
|
}
|
|
82622
82622
|
let result = 0;
|
|
82623
82623
|
for (let i6 = 0; i6 < lhs.length; i6++) {
|
|
@@ -91332,8 +91332,7 @@ const realtime = await ga.runRealtimeReport({
|
|
|
91332
91332
|
}
|
|
91333
91333
|
});
|
|
91334
91334
|
|
|
91335
|
-
// ../connectors/src/connectors/google-calendar/tools/
|
|
91336
|
-
import * as crypto3 from "crypto";
|
|
91335
|
+
// ../connectors/src/connectors/google-calendar/tools/request.ts
|
|
91337
91336
|
import { z as z21 } from "zod";
|
|
91338
91337
|
|
|
91339
91338
|
// ../connectors/src/connectors/google-calendar/parameters.ts
|
|
@@ -91341,121 +91340,54 @@ var parameters14 = {
|
|
|
91341
91340
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
91342
91341
|
slug: "service-account-key-json-base64",
|
|
91343
91342
|
name: "Google Cloud Service Account JSON",
|
|
91344
|
-
description: "The service account JSON key
|
|
91343
|
+
description: "The service account JSON key. Used for both Domain-wide Delegation (impersonating a Workspace user) and direct service-account access (calendars explicitly shared with the SA email). The authentication path is selected per call by the tool used.",
|
|
91345
91344
|
envVarBaseKey: "GOOGLE_CALENDAR_SERVICE_ACCOUNT_JSON_BASE64",
|
|
91346
91345
|
type: "base64EncodedJson",
|
|
91347
91346
|
secret: true,
|
|
91348
91347
|
required: true
|
|
91349
91348
|
})
|
|
91350
91349
|
};
|
|
91351
|
-
|
|
91352
|
-
|
|
91353
|
-
name: "User Email Address(es)",
|
|
91354
|
-
description: "The email address(es) of the Google Workspace user(s) whose calendar is accessed via Domain-wide Delegation. Collected during the setup flow.",
|
|
91355
|
-
envVarBaseKey: "GOOGLE_CALENDAR_IMPERSONATE_EMAIL",
|
|
91356
|
-
type: "text",
|
|
91357
|
-
secret: false,
|
|
91358
|
-
required: false
|
|
91359
|
-
});
|
|
91360
|
-
var calendarIdParameter = new ParameterDefinition({
|
|
91361
|
-
slug: "calendar-id",
|
|
91362
|
-
name: "Default Calendar ID",
|
|
91363
|
-
description: "The default Google Calendar ID to use (e.g., 'primary' or an email address like 'user@example.com'). If not set, 'primary' is used.",
|
|
91364
|
-
envVarBaseKey: "GOOGLE_CALENDAR_CALENDAR_ID",
|
|
91365
|
-
type: "text",
|
|
91366
|
-
secret: false,
|
|
91367
|
-
required: false
|
|
91368
|
-
});
|
|
91369
|
-
|
|
91370
|
-
// ../connectors/src/connectors/google-calendar/tools/list-calendars.ts
|
|
91371
|
-
var TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
91350
|
+
|
|
91351
|
+
// ../connectors/src/connectors/google-calendar/tools/request.ts
|
|
91372
91352
|
var BASE_URL6 = "https://www.googleapis.com/calendar/v3";
|
|
91373
|
-
var SCOPE = "https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events.readonly";
|
|
91374
91353
|
var REQUEST_TIMEOUT_MS11 = 6e4;
|
|
91375
|
-
function
|
|
91376
|
-
const
|
|
91377
|
-
return
|
|
91378
|
-
}
|
|
91379
|
-
function buildJwt(clientEmail, privateKey, nowSec, subject) {
|
|
91380
|
-
const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
91381
|
-
const payload = base64url(
|
|
91382
|
-
JSON.stringify({
|
|
91383
|
-
iss: clientEmail,
|
|
91384
|
-
sub: subject,
|
|
91385
|
-
scope: SCOPE,
|
|
91386
|
-
aud: TOKEN_URL,
|
|
91387
|
-
iat: nowSec,
|
|
91388
|
-
exp: nowSec + 3600
|
|
91389
|
-
})
|
|
91390
|
-
);
|
|
91391
|
-
const signingInput = `${header}.${payload}`;
|
|
91392
|
-
const sign2 = crypto3.createSign("RSA-SHA256");
|
|
91393
|
-
sign2.update(signingInput);
|
|
91394
|
-
sign2.end();
|
|
91395
|
-
const signature = base64url(sign2.sign(privateKey));
|
|
91396
|
-
return `${signingInput}.${signature}`;
|
|
91397
|
-
}
|
|
91398
|
-
async function getAccessToken(serviceAccount, subject) {
|
|
91399
|
-
const nowSec = Math.floor(Date.now() / 1e3);
|
|
91400
|
-
const jwt = buildJwt(
|
|
91401
|
-
serviceAccount.client_email,
|
|
91402
|
-
serviceAccount.private_key,
|
|
91403
|
-
nowSec,
|
|
91404
|
-
subject
|
|
91405
|
-
);
|
|
91406
|
-
const response = await fetch(TOKEN_URL, {
|
|
91407
|
-
method: "POST",
|
|
91408
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
91409
|
-
body: new URLSearchParams({
|
|
91410
|
-
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
91411
|
-
assertion: jwt
|
|
91412
|
-
})
|
|
91413
|
-
});
|
|
91414
|
-
if (!response.ok) {
|
|
91415
|
-
const text = await response.text();
|
|
91416
|
-
throw new Error(
|
|
91417
|
-
`token exchange failed for ${subject} (${response.status}): ${text}`
|
|
91418
|
-
);
|
|
91419
|
-
}
|
|
91420
|
-
const data = await response.json();
|
|
91421
|
-
return data.access_token;
|
|
91354
|
+
function decodeServiceAccount(keyJsonBase64) {
|
|
91355
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
91356
|
+
return JSON.parse(decoded);
|
|
91422
91357
|
}
|
|
91423
91358
|
var inputSchema21 = z21.object({
|
|
91424
91359
|
toolUseIntent: z21.string().optional().describe(
|
|
91425
91360
|
"Brief description of what you intend to accomplish with this tool call"
|
|
91426
91361
|
),
|
|
91427
|
-
connectionId: z21.string().describe("ID of the Google Calendar connection to use")
|
|
91362
|
+
connectionId: z21.string().describe("ID of the Google Calendar connection to use"),
|
|
91363
|
+
method: z21.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
91364
|
+
path: z21.string().describe(
|
|
91365
|
+
"API path appended to https://www.googleapis.com/calendar/v3 (e.g., '/users/me/calendarList', '/calendars/team@example.com/events'). Write the calendar ID directly into the path \u2014 there is no placeholder substitution."
|
|
91366
|
+
),
|
|
91367
|
+
scopes: z21.array(z21.string()).describe(
|
|
91368
|
+
"OAuth scopes the token must include. This connector currently supports read-only operations only \u2014 pass one of ['https://www.googleapis.com/auth/calendar.readonly'] (calendars + events read), ['https://www.googleapis.com/auth/calendar.events.readonly'] (events read only), or ['https://www.googleapis.com/auth/calendar.freebusy'] (busy/free queries only). Per-endpoint scope reference: https://developers.google.com/calendar/api/auth"
|
|
91369
|
+
),
|
|
91370
|
+
queryParams: z21.record(z21.string(), z21.string()).optional().describe("Query parameters to append to the URL"),
|
|
91371
|
+
body: z21.record(z21.string(), z21.unknown()).optional().describe("JSON request body for POST/PUT/PATCH")
|
|
91428
91372
|
});
|
|
91429
91373
|
var outputSchema21 = z21.discriminatedUnion("success", [
|
|
91430
91374
|
z21.object({
|
|
91431
91375
|
success: z21.literal(true),
|
|
91432
|
-
|
|
91433
|
-
|
|
91434
|
-
impersonateEmail: z21.string(),
|
|
91435
|
-
id: z21.string(),
|
|
91436
|
-
summary: z21.string(),
|
|
91437
|
-
primary: z21.boolean().optional(),
|
|
91438
|
-
accessRole: z21.string()
|
|
91439
|
-
})
|
|
91440
|
-
),
|
|
91441
|
-
errors: z21.array(
|
|
91442
|
-
z21.object({
|
|
91443
|
-
impersonateEmail: z21.string(),
|
|
91444
|
-
error: z21.string()
|
|
91445
|
-
})
|
|
91446
|
-
)
|
|
91376
|
+
status: z21.number(),
|
|
91377
|
+
data: z21.record(z21.string(), z21.unknown())
|
|
91447
91378
|
}),
|
|
91448
91379
|
z21.object({
|
|
91449
91380
|
success: z21.literal(false),
|
|
91450
|
-
error: z21.string()
|
|
91381
|
+
error: z21.string(),
|
|
91382
|
+
serviceAccountEmail: z21.string().optional()
|
|
91451
91383
|
})
|
|
91452
91384
|
]);
|
|
91453
|
-
var
|
|
91454
|
-
name: "
|
|
91455
|
-
description: "
|
|
91385
|
+
var requestTool5 = new ConnectorTool({
|
|
91386
|
+
name: "request",
|
|
91387
|
+
description: "Call the Google Calendar API as the service account itself (no delegation). Read-only operations only. Only calendars explicitly shared with the service account email are accessible. Pass `scopes` as a read-only Calendar scope (e.g., ['https://www.googleapis.com/auth/calendar.readonly']). Use this tool when the project knowledge records the calendar with `(service-account, ...)` (no `subject`).",
|
|
91456
91388
|
inputSchema: inputSchema21,
|
|
91457
91389
|
outputSchema: outputSchema21,
|
|
91458
|
-
async execute({ connectionId }, connections) {
|
|
91390
|
+
async execute({ connectionId, method, path: path5, scopes, queryParams, body }, connections) {
|
|
91459
91391
|
const connection = connections.find((c6) => c6.id === connectionId);
|
|
91460
91392
|
if (!connection) {
|
|
91461
91393
|
return {
|
|
@@ -91463,144 +91395,89 @@ var listCalendarsTool = new ConnectorTool({
|
|
|
91463
91395
|
error: `Connection ${connectionId} not found`
|
|
91464
91396
|
};
|
|
91465
91397
|
}
|
|
91466
|
-
const
|
|
91467
|
-
const emails = impersonateEmailRaw.split(",").map((e6) => e6.trim()).filter((e6) => e6.length > 0);
|
|
91468
|
-
if (emails.length === 0) {
|
|
91469
|
-
return {
|
|
91470
|
-
success: false,
|
|
91471
|
-
error: "impersonate-email parameter is empty"
|
|
91472
|
-
};
|
|
91473
|
-
}
|
|
91474
|
-
console.log(
|
|
91475
|
-
`[connector-request] google-calendar/${connection.name}: listCalendars for ${emails.join(",")}`
|
|
91476
|
-
);
|
|
91398
|
+
const keyJsonBase64 = parameters14.serviceAccountKeyJsonBase64.getValue(connection);
|
|
91477
91399
|
let serviceAccount;
|
|
91478
91400
|
try {
|
|
91479
|
-
|
|
91480
|
-
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
91481
|
-
serviceAccount = JSON.parse(decoded);
|
|
91401
|
+
serviceAccount = decodeServiceAccount(keyJsonBase64);
|
|
91482
91402
|
} catch (err) {
|
|
91483
91403
|
const msg = err instanceof Error ? err.message : String(err);
|
|
91484
91404
|
return {
|
|
91485
91405
|
success: false,
|
|
91486
|
-
error: `
|
|
91406
|
+
error: `Failed to decode service account key: ${msg}`
|
|
91487
91407
|
};
|
|
91488
91408
|
}
|
|
91489
|
-
|
|
91490
|
-
|
|
91491
|
-
|
|
91492
|
-
|
|
91493
|
-
|
|
91494
|
-
|
|
91495
|
-
|
|
91496
|
-
|
|
91497
|
-
|
|
91409
|
+
const serviceAccountEmail = serviceAccount.client_email;
|
|
91410
|
+
console.log(
|
|
91411
|
+
`[connector-request] google-calendar/${connection.name}: ${method} ${path5} (service account)`
|
|
91412
|
+
);
|
|
91413
|
+
try {
|
|
91414
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
91415
|
+
const auth = new GoogleAuth({
|
|
91416
|
+
credentials: {
|
|
91417
|
+
client_email: serviceAccount.client_email,
|
|
91418
|
+
private_key: serviceAccount.private_key
|
|
91419
|
+
},
|
|
91420
|
+
scopes
|
|
91421
|
+
});
|
|
91422
|
+
const token = await auth.getAccessToken();
|
|
91423
|
+
if (!token) {
|
|
91424
|
+
return {
|
|
91425
|
+
success: false,
|
|
91426
|
+
error: "Failed to obtain access token",
|
|
91427
|
+
serviceAccountEmail
|
|
91428
|
+
};
|
|
91429
|
+
}
|
|
91430
|
+
let url = `${BASE_URL6}${path5.startsWith("/") ? "" : "/"}${path5}`;
|
|
91431
|
+
if (queryParams) {
|
|
91432
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
91433
|
+
url += `?${searchParams.toString()}`;
|
|
91434
|
+
}
|
|
91498
91435
|
const controller = new AbortController();
|
|
91499
91436
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS11);
|
|
91500
91437
|
try {
|
|
91501
|
-
const
|
|
91502
|
-
const response = await fetch(
|
|
91503
|
-
method
|
|
91504
|
-
headers: {
|
|
91438
|
+
const hasBody = body != null && ["POST", "PUT", "PATCH"].includes(method);
|
|
91439
|
+
const response = await fetch(url, {
|
|
91440
|
+
method,
|
|
91441
|
+
headers: {
|
|
91442
|
+
Authorization: `Bearer ${token}`,
|
|
91443
|
+
"Content-Type": "application/json"
|
|
91444
|
+
},
|
|
91445
|
+
body: hasBody ? JSON.stringify(body) : void 0,
|
|
91505
91446
|
signal: controller.signal
|
|
91506
91447
|
});
|
|
91507
|
-
const data = await response.json();
|
|
91448
|
+
const data = await response.json().catch(() => ({}));
|
|
91508
91449
|
if (!response.ok) {
|
|
91509
91450
|
const errorObj = data?.error;
|
|
91510
|
-
|
|
91511
|
-
|
|
91512
|
-
|
|
91513
|
-
|
|
91514
|
-
|
|
91515
|
-
|
|
91516
|
-
const items = data.items ?? [];
|
|
91517
|
-
for (const c6 of items) {
|
|
91518
|
-
aggregated.push({
|
|
91519
|
-
impersonateEmail: email,
|
|
91520
|
-
id: c6.id,
|
|
91521
|
-
summary: c6.summary,
|
|
91522
|
-
primary: c6.primary,
|
|
91523
|
-
accessRole: c6.accessRole
|
|
91524
|
-
});
|
|
91451
|
+
const errorMessage = errorObj?.message ?? (typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`);
|
|
91452
|
+
return {
|
|
91453
|
+
success: false,
|
|
91454
|
+
error: errorMessage,
|
|
91455
|
+
serviceAccountEmail
|
|
91456
|
+
};
|
|
91525
91457
|
}
|
|
91526
|
-
|
|
91527
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
91528
|
-
errors2.push({ impersonateEmail: email, error: msg });
|
|
91458
|
+
return { success: true, status: response.status, data };
|
|
91529
91459
|
} finally {
|
|
91530
91460
|
clearTimeout(timeout);
|
|
91531
91461
|
}
|
|
91462
|
+
} catch (err) {
|
|
91463
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
91464
|
+
return {
|
|
91465
|
+
success: false,
|
|
91466
|
+
error: msg,
|
|
91467
|
+
serviceAccountEmail
|
|
91468
|
+
};
|
|
91532
91469
|
}
|
|
91533
|
-
return {
|
|
91534
|
-
success: true,
|
|
91535
|
-
calendars: aggregated,
|
|
91536
|
-
errors: errors2
|
|
91537
|
-
};
|
|
91538
91470
|
}
|
|
91539
91471
|
});
|
|
91540
91472
|
|
|
91541
|
-
// ../connectors/src/connectors/google-calendar/
|
|
91542
|
-
var listCalendarsToolName = `google-calendar-service-account_${listCalendarsTool.name}`;
|
|
91543
|
-
var googleCalendarOnboarding = new ConnectorOnboarding({
|
|
91544
|
-
connectionSetupInstructions: {
|
|
91545
|
-
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Calendar\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\u5BFE\u8C61\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3084\u30AB\u30EC\u30F3\u30C0\u30FCID\u306F\u3053\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u4E2D\u306B\u53D6\u5F97\u3057\u307E\u3059\u3002
|
|
91546
|
-
|
|
91547
|
-
1. \`askUserQuestion\` \u3067\u30E6\u30FC\u30B6\u30FC\u306B\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:
|
|
91548
|
-
- \`type\`: \`"freeText"\`
|
|
91549
|
-
- \`question\`: \u300C\u30A2\u30AF\u30BB\u30B9\u3057\u305F\u3044\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u6301\u3064\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u3042\u308B\u5834\u5408\u306F\u30AB\u30F3\u30DE\u533A\u5207\u308A\u3067\u5165\u529B\u53EF\uFF09\u300D
|
|
91550
|
-
- \`placeholder\`: \`"user@example.com, admin@example.com"\`
|
|
91551
|
-
2. \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u53D7\u3051\u53D6\u3063\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\uFF08\u30AB\u30F3\u30DE\u533A\u5207\u308A\u5BFE\u5FDC\uFF09\u3092 \`updateConnectionParameters\` \u3067\u4FDD\u5B58\u3059\u308B:
|
|
91552
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91553
|
-
- \`options\`: \`[{ value: <\u5165\u529B\u3055\u308C\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u6587\u5B57\u5217>, label: <\u540C\u3058\u5024> }]\`\uFF081\u4EF6\u306E\u307F\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u81EA\u52D5\u9078\u629E\u3055\u308C\u308B\uFF09
|
|
91554
|
-
3. \`${listCalendarsToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3001\u4FDD\u5B58\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B\u3002
|
|
91555
|
-
- \`errors\` \u306B\u30A8\u30E9\u30FC\u304C\u3042\u308A \`calendars\` \u304C\u7A7A\u306E\u5834\u5408\uFF08\u3059\u3079\u3066\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3067\u5931\u6557\uFF09\u3001\u5165\u529B\u3055\u308C\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304C\u5B58\u5728\u3057\u306A\u3044\u53EF\u80FD\u6027\u304C\u3042\u308B\u3002\`askUserQuestion\` \u3067\u300C{\u5165\u529B\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9} \u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u30A2\u30C9\u30EC\u30B9\u306B\u8AA4\u308A\u304C\u3042\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\u3002\u4F3C\u305F\u30A2\u30C9\u30EC\u30B9\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u304B\uFF1F\u300D\u3068\u805E\u304D\u8FD4\u3057\u3001\u30B9\u30C6\u30C3\u30D72\u304B\u3089\u518D\u5EA6\u5B9F\u884C\u3059\u308B
|
|
91556
|
-
4. \u8FD4\u5374\u3055\u308C\u305F \`calendars\` \u914D\u5217\uFF08\u5404\u8981\u7D20: \`{ impersonateEmail, id, summary, primary, accessRole }\`\uFF09\u3092\u5143\u306B\u300C\u4F7F\u7528\u3059\u308B\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u77ED\u304F\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
91557
|
-
- \`parameterSlug\`: \`"calendar-id"\`
|
|
91558
|
-
- \`options\`: \u5404 option \u306E \`label\` \u306F \`\u30AB\u30EC\u30F3\u30C0\u30FC\u540D (owner: impersonateEmail)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30AB\u30EC\u30F3\u30C0\u30FCID
|
|
91559
|
-
- \`errors\` \u306B\u5931\u6557\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304C\u3042\u308B\u5834\u5408\u306F\u3001\u305D\u306E\u65E8\u3092\u77ED\u304F\u4F1D\u3048\u308B
|
|
91560
|
-
5. \u30E6\u30FC\u30B6\u30FC\u304C\u9078\u629E\u3057\u305F\u30AB\u30EC\u30F3\u30C0\u30FC\u306E \`label\` \u304B\u3089 owner \u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u62BD\u51FA\u3057\u3001\`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3057\u3066 \`impersonate-email\` \u3092\u6700\u7D42\u5024\u3067\u4E0A\u66F8\u304D\u3059\u308B:
|
|
91561
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91562
|
-
- \`options\`: \`[{ value: <ownerEmail>, label: <ownerEmail> }]\`
|
|
91563
|
-
|
|
91564
|
-
#### \u5236\u7D04
|
|
91565
|
-
- **\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u8A2D\u5B9A\u304C\u5FC5\u8981\u3067\u3059**\u3002\`${listCalendarsToolName}\` \u306E \`errors\` \u306B\u6A29\u9650\u30A8\u30E9\u30FC\u304C\u51FA\u308B\u5834\u5408\u3001Google Workspace\u7BA1\u7406\u8005\u306BDomain-wide Delegation\u306E\u8A2D\u5B9A\u78BA\u8A8D\u3092\u4FC3\u3057\u3066\u304F\u3060\u3055\u3044
|
|
91566
|
-
- \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`,
|
|
91567
|
-
en: `Follow these steps to set up the Google Calendar connection. Only the service account JSON is provided at connection creation time \u2014 the target user email and calendar ID are collected during this setup flow.
|
|
91568
|
-
|
|
91569
|
-
1. Call \`askUserQuestion\` to ask the user for the Google Workspace user email the service account will impersonate via Domain-wide Delegation:
|
|
91570
|
-
- \`type\`: \`"freeText"\`
|
|
91571
|
-
- \`question\`: "Please enter the email address of the user whose calendar you want to access (comma-separated list allowed for multiple users)"
|
|
91572
|
-
- \`placeholder\`: \`"user@example.com, admin@example.com"\`
|
|
91573
|
-
2. Save the email(s) the user provided (comma-separated supported) via \`updateConnectionParameters\`:
|
|
91574
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91575
|
-
- \`options\`: \`[{ value: <the email string entered>, label: <same value> }]\` (a single option is auto-selected)
|
|
91576
|
-
3. Call \`${listCalendarsToolName}\` to list calendars accessible via the saved email(s).
|
|
91577
|
-
- If \`errors\` is non-empty and \`calendars\` is empty (all emails failed), the entered address may not exist. Use \`askUserQuestion\` to ask: "Could not access the calendar for {entered email}. The address may be incorrect \u2014 did you mean a similar address?" Then re-run from step 2 with the new input
|
|
91578
|
-
4. Using the returned \`calendars\` array (each item: \`{ impersonateEmail, id, summary, primary, accessRole }\`), briefly say "Please select a calendar." then call \`updateConnectionParameters\`:
|
|
91579
|
-
- \`parameterSlug\`: \`"calendar-id"\`
|
|
91580
|
-
- \`options\`: Each option's \`label\` should be \`Calendar Name (owner: impersonateEmail)\`, \`value\` should be the calendar ID
|
|
91581
|
-
- If \`errors\` contains failing email addresses, briefly mention them
|
|
91582
|
-
5. Extract the owner email from the \`label\` of the user's selected calendar, then call \`updateConnectionParameters\` to overwrite \`impersonate-email\` with the final value:
|
|
91583
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91584
|
-
- \`options\`: \`[{ value: <ownerEmail>, label: <ownerEmail> }]\`
|
|
91585
|
-
|
|
91586
|
-
#### Constraints
|
|
91587
|
-
- **Domain-wide Delegation must be configured on the service account**. If \`${listCalendarsToolName}\` returns permission errors in the \`errors\` field, ask the user to verify the Domain-wide Delegation setup with their Google Workspace administrator
|
|
91588
|
-
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
91589
|
-
},
|
|
91590
|
-
dataOverviewInstructions: {
|
|
91591
|
-
en: `1. Call google-calendar-service-account_request with GET /calendars/{calendarId} to get the default calendar's metadata
|
|
91592
|
-
2. Call google-calendar-service-account_request with GET /users/me/calendarList to list all accessible calendars
|
|
91593
|
-
3. Call google-calendar-service-account_request with GET /calendars/{calendarId}/events with query params timeMin (RFC3339) and maxResults=10 to sample upcoming events`,
|
|
91594
|
-
ja: `1. google-calendar-service-account_request \u3067 GET /calendars/{calendarId} \u3092\u547C\u3073\u51FA\u3057\u3001\u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
91595
|
-
2. google-calendar-service-account_request \u3067 GET /users/me/calendarList \u3092\u547C\u3073\u51FA\u3057\u3001\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u3092\u53D6\u5F97
|
|
91596
|
-
3. google-calendar-service-account_request \u3067 GET /calendars/{calendarId}/events \u3092\u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF timeMin\uFF08RFC3339\u5F62\u5F0F\uFF09\u3068 maxResults=10 \u3067\u547C\u3073\u51FA\u3057\u3001\u76F4\u8FD1\u306E\u30A4\u30D9\u30F3\u30C8\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0`
|
|
91597
|
-
}
|
|
91598
|
-
});
|
|
91599
|
-
|
|
91600
|
-
// ../connectors/src/connectors/google-calendar/tools/request.ts
|
|
91473
|
+
// ../connectors/src/connectors/google-calendar/tools/request-with-delegation.ts
|
|
91601
91474
|
import { z as z22 } from "zod";
|
|
91602
91475
|
var BASE_URL7 = "https://www.googleapis.com/calendar/v3";
|
|
91603
91476
|
var REQUEST_TIMEOUT_MS12 = 6e4;
|
|
91477
|
+
function decodeServiceAccount2(keyJsonBase64) {
|
|
91478
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
91479
|
+
return JSON.parse(decoded);
|
|
91480
|
+
}
|
|
91604
91481
|
var inputSchema22 = z22.object({
|
|
91605
91482
|
toolUseIntent: z22.string().optional().describe(
|
|
91606
91483
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -91608,13 +91485,18 @@ var inputSchema22 = z22.object({
|
|
|
91608
91485
|
connectionId: z22.string().describe("ID of the Google Calendar connection to use"),
|
|
91609
91486
|
method: z22.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
91610
91487
|
path: z22.string().describe(
|
|
91611
|
-
"API path appended to https://www.googleapis.com/calendar/v3 (e.g., '/calendars/
|
|
91488
|
+
"API path appended to https://www.googleapis.com/calendar/v3 (e.g., '/users/me/calendarList', '/calendars/alice@example.com/events'). Write the calendar ID directly into the path \u2014 there is no placeholder substitution."
|
|
91612
91489
|
),
|
|
91613
|
-
|
|
91614
|
-
|
|
91615
|
-
|
|
91616
|
-
|
|
91617
|
-
|
|
91490
|
+
subject: z22.string().describe(
|
|
91491
|
+
"Email of the Workspace user to impersonate via Domain-wide Delegation. The token will be issued as this user."
|
|
91492
|
+
),
|
|
91493
|
+
scopes: z22.array(z22.string()).describe(
|
|
91494
|
+
"OAuth scopes the token must include. This connector currently supports read-only operations only \u2014 pass one of ['https://www.googleapis.com/auth/calendar.readonly'] (calendars + events read), ['https://www.googleapis.com/auth/calendar.events.readonly'] (events read only), or ['https://www.googleapis.com/auth/calendar.freebusy'] (busy/free queries only). Per-endpoint scope reference: https://developers.google.com/calendar/api/auth"
|
|
91495
|
+
),
|
|
91496
|
+
queryParams: z22.record(z22.string(), z22.string()).optional().describe(
|
|
91497
|
+
"Query parameters to append to the URL (e.g., { timeMin: '2025-01-01T00:00:00Z', maxResults: '10' })"
|
|
91498
|
+
),
|
|
91499
|
+
body: z22.record(z22.string(), z22.unknown()).optional().describe("JSON request body for POST/PUT/PATCH")
|
|
91618
91500
|
});
|
|
91619
91501
|
var outputSchema22 = z22.discriminatedUnion("success", [
|
|
91620
91502
|
z22.object({
|
|
@@ -91624,17 +91506,16 @@ var outputSchema22 = z22.discriminatedUnion("success", [
|
|
|
91624
91506
|
}),
|
|
91625
91507
|
z22.object({
|
|
91626
91508
|
success: z22.literal(false),
|
|
91627
|
-
error: z22.string()
|
|
91509
|
+
error: z22.string(),
|
|
91510
|
+
serviceAccountEmail: z22.string().optional()
|
|
91628
91511
|
})
|
|
91629
91512
|
]);
|
|
91630
|
-
var
|
|
91631
|
-
name: "
|
|
91632
|
-
description: `
|
|
91633
|
-
Authentication is handled automatically using a service account.
|
|
91634
|
-
{calendarId} in the path is automatically replaced with the connection's default calendar ID.`,
|
|
91513
|
+
var requestWithDelegationTool = new ConnectorTool({
|
|
91514
|
+
name: "request_with_delegation",
|
|
91515
|
+
description: "Call the Google Calendar API on behalf of the specified Workspace user via Domain-wide Delegation. Read-only operations only. Pass `subject` as the target user email and `scopes` as a read-only Calendar scope (e.g., ['https://www.googleapis.com/auth/calendar.readonly']). Use this tool when the project knowledge records the calendar with `(delegation, subject: <email>, ...)`. Requires Domain-wide Delegation to be authorized for the service account in the Workspace admin console.",
|
|
91635
91516
|
inputSchema: inputSchema22,
|
|
91636
91517
|
outputSchema: outputSchema22,
|
|
91637
|
-
async execute({ connectionId, method, path: path5, queryParams, body
|
|
91518
|
+
async execute({ connectionId, method, path: path5, subject, scopes, queryParams, body }, connections) {
|
|
91638
91519
|
const connection = connections.find((c6) => c6.id === connectionId);
|
|
91639
91520
|
if (!connection) {
|
|
91640
91521
|
return {
|
|
@@ -91642,41 +91523,40 @@ Authentication is handled automatically using a service account.
|
|
|
91642
91523
|
error: `Connection ${connectionId} not found`
|
|
91643
91524
|
};
|
|
91644
91525
|
}
|
|
91526
|
+
const keyJsonBase64 = parameters14.serviceAccountKeyJsonBase64.getValue(connection);
|
|
91527
|
+
let serviceAccount;
|
|
91528
|
+
try {
|
|
91529
|
+
serviceAccount = decodeServiceAccount2(keyJsonBase64);
|
|
91530
|
+
} catch (err) {
|
|
91531
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
91532
|
+
return {
|
|
91533
|
+
success: false,
|
|
91534
|
+
error: `Failed to decode service account key: ${msg}`
|
|
91535
|
+
};
|
|
91536
|
+
}
|
|
91537
|
+
const serviceAccountEmail = serviceAccount.client_email;
|
|
91645
91538
|
console.log(
|
|
91646
|
-
`[connector-request] google-calendar/${connection.name}: ${method} ${path5}`
|
|
91539
|
+
`[connector-request] google-calendar/${connection.name}: ${method} ${path5} subject=${subject}`
|
|
91647
91540
|
);
|
|
91648
91541
|
try {
|
|
91649
91542
|
const { GoogleAuth } = await import("google-auth-library");
|
|
91650
|
-
const keyJsonBase64 = parameters14.serviceAccountKeyJsonBase64.getValue(connection);
|
|
91651
|
-
const impersonateEmail = impersonateEmailParameter.tryGetValue(connection);
|
|
91652
|
-
const calendarId = calendarIdParameter.tryGetValue(connection) ?? "primary";
|
|
91653
|
-
const resolvedSubject = subject ?? impersonateEmail;
|
|
91654
|
-
if (!resolvedSubject) {
|
|
91655
|
-
return {
|
|
91656
|
-
success: false,
|
|
91657
|
-
error: `Missing required parameter: ${impersonateEmailParameter.slug}. Configure the user email for this connection.`
|
|
91658
|
-
};
|
|
91659
|
-
}
|
|
91660
|
-
const credentials = JSON.parse(
|
|
91661
|
-
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
91662
|
-
);
|
|
91663
91543
|
const auth = new GoogleAuth({
|
|
91664
|
-
credentials
|
|
91665
|
-
|
|
91666
|
-
|
|
91667
|
-
|
|
91668
|
-
|
|
91669
|
-
clientOptions: { subject
|
|
91544
|
+
credentials: {
|
|
91545
|
+
client_email: serviceAccount.client_email,
|
|
91546
|
+
private_key: serviceAccount.private_key
|
|
91547
|
+
},
|
|
91548
|
+
scopes,
|
|
91549
|
+
clientOptions: { subject }
|
|
91670
91550
|
});
|
|
91671
91551
|
const token = await auth.getAccessToken();
|
|
91672
91552
|
if (!token) {
|
|
91673
91553
|
return {
|
|
91674
91554
|
success: false,
|
|
91675
|
-
error: "Failed to obtain access token"
|
|
91555
|
+
error: "Failed to obtain access token",
|
|
91556
|
+
serviceAccountEmail
|
|
91676
91557
|
};
|
|
91677
91558
|
}
|
|
91678
|
-
|
|
91679
|
-
let url = `${BASE_URL7}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
|
|
91559
|
+
let url = `${BASE_URL7}${path5.startsWith("/") ? "" : "/"}${path5}`;
|
|
91680
91560
|
if (queryParams) {
|
|
91681
91561
|
const searchParams = new URLSearchParams(queryParams);
|
|
91682
91562
|
url += `?${searchParams.toString()}`;
|
|
@@ -91684,28 +91564,24 @@ Authentication is handled automatically using a service account.
|
|
|
91684
91564
|
const controller = new AbortController();
|
|
91685
91565
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS12);
|
|
91686
91566
|
try {
|
|
91567
|
+
const hasBody = body != null && ["POST", "PUT", "PATCH"].includes(method);
|
|
91687
91568
|
const response = await fetch(url, {
|
|
91688
91569
|
method,
|
|
91689
91570
|
headers: {
|
|
91690
91571
|
Authorization: `Bearer ${token}`,
|
|
91691
91572
|
"Content-Type": "application/json"
|
|
91692
91573
|
},
|
|
91693
|
-
body:
|
|
91574
|
+
body: hasBody ? JSON.stringify(body) : void 0,
|
|
91694
91575
|
signal: controller.signal
|
|
91695
91576
|
});
|
|
91696
|
-
|
|
91697
|
-
return {
|
|
91698
|
-
success: true,
|
|
91699
|
-
status: 204,
|
|
91700
|
-
data: { message: "Deleted successfully" }
|
|
91701
|
-
};
|
|
91702
|
-
}
|
|
91703
|
-
const data = await response.json();
|
|
91577
|
+
const data = await response.json().catch(() => ({}));
|
|
91704
91578
|
if (!response.ok) {
|
|
91705
91579
|
const errorObj = data?.error;
|
|
91580
|
+
const errorMessage = errorObj?.message ?? (typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`);
|
|
91706
91581
|
return {
|
|
91707
91582
|
success: false,
|
|
91708
|
-
error:
|
|
91583
|
+
error: errorMessage,
|
|
91584
|
+
serviceAccountEmail
|
|
91709
91585
|
};
|
|
91710
91586
|
}
|
|
91711
91587
|
return { success: true, status: response.status, data };
|
|
@@ -91714,13 +91590,200 @@ Authentication is handled automatically using a service account.
|
|
|
91714
91590
|
}
|
|
91715
91591
|
} catch (err) {
|
|
91716
91592
|
const msg = err instanceof Error ? err.message : String(err);
|
|
91717
|
-
return {
|
|
91593
|
+
return {
|
|
91594
|
+
success: false,
|
|
91595
|
+
error: msg,
|
|
91596
|
+
serviceAccountEmail
|
|
91597
|
+
};
|
|
91718
91598
|
}
|
|
91719
91599
|
}
|
|
91720
91600
|
});
|
|
91721
91601
|
|
|
91602
|
+
// ../connectors/src/connectors/google-calendar/setup.ts
|
|
91603
|
+
var requestToolName = `google-calendar-service-account_${requestTool5.name}`;
|
|
91604
|
+
var requestWithDelegationToolName = `google-calendar-service-account_${requestWithDelegationTool.name}`;
|
|
91605
|
+
var READONLY_SCOPES = '["https://www.googleapis.com/auth/calendar.readonly"]';
|
|
91606
|
+
var SERVICE_ACCOUNT_KEY_PARAM_SLUG = parameters14.serviceAccountKeyJsonBase64.slug;
|
|
91607
|
+
var googleCalendarOnboarding = new ConnectorOnboarding({
|
|
91608
|
+
connectionSetupInstructions: {
|
|
91609
|
+
ja: `Google Calendar \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u3092\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3057\u307E\u3059\u3002\u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u3092\u9078\u3093\u3067\u3082\u3089\u3044\u3001\u5BFE\u8C61\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u767A\u898B\u30FB\u9078\u629E\u3057\u3066 Project Knowledge \u306B\u8A18\u9332\u3057\u307E\u3059\u3002
|
|
91610
|
+
|
|
91611
|
+
## \u30B9\u30C6\u30C3\u30D7 1: \u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u3092\u9078\u629E
|
|
91612
|
+
|
|
91613
|
+
\`askUserQuestion\` \u3067\u6B21\u306E 3 \u629E\u3092\u63D0\u793A\u3059\u308B:
|
|
91614
|
+
- \`type\`: \`"select"\`
|
|
91615
|
+
- \`question\`: \u300C\u3069\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u307E\u3059\u304B\uFF1F\u300D
|
|
91616
|
+
- \`options\`:
|
|
91617
|
+
- \`{ label: "\u3053\u306E\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306B\u5171\u6709\u3055\u308C\u3066\u3044\u308B\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u4F7F\u3046", value: "service-account" }\`
|
|
91618
|
+
- \`{ label: "\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u3067\u7D44\u7E54\u306E\u30E6\u30FC\u30B6\u30FC\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u3059\u308B", value: "delegation" }\`
|
|
91619
|
+
- \`{ label: "\u4E21\u65B9\u3092\u7D44\u307F\u5408\u308F\u305B\u308B", value: "both" }\`
|
|
91620
|
+
|
|
91621
|
+
## \u30B9\u30C6\u30C3\u30D7 2: \u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u7D4C\u8DEF\u306E\u767A\u898B\u3068\u9078\u629E (\`"service-account"\` \u307E\u305F\u306F \`"both"\` \u306E\u5834\u5408)
|
|
91622
|
+
|
|
91623
|
+
1. \`${requestToolName}\` \u3092\u547C\u3093\u3067\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
|
|
91624
|
+
- \`method\`: \`"GET"\`
|
|
91625
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91626
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91627
|
+
|
|
91628
|
+
2. \u53D6\u5F97\u7D50\u679C\u306B\u5FDC\u3058\u3066\u5206\u5C90:
|
|
91629
|
+
- \u7D50\u679C\u304C\u7A7A: \u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u304C \`"service-account"\` \u3060\u3051\u306A\u3089\u30B9\u30C6\u30C3\u30D7 5 (\u30A8\u30B9\u30AB\u30EC\u30FC\u30B7\u30E7\u30F3) \u3078\u3002\`"both"\` \u306E\u5834\u5408\u306F\u305D\u306E\u307E\u307E\u30B9\u30C6\u30C3\u30D7 3 \u3078\u9032\u3080
|
|
91630
|
+
- \u7D50\u679C\u304C\u3042\u308B: \`askUserQuestion\` \u3067\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u3070\u305B\u308B
|
|
91631
|
+
- \`type\`: \`"multiSelect"\`
|
|
91632
|
+
- \`question\`: \u300C\u4F7F\u7528\u3059\u308B\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u53EF\uFF09\u300D
|
|
91633
|
+
- \`options\`: \u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u3064\u3044\u3066 \`label\`: \`"<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D>"\`\u3001\`value\`: \`"<calendarId>"\`
|
|
91634
|
+
|
|
91635
|
+
## \u30B9\u30C6\u30C3\u30D7 3: \u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u7D4C\u8DEF\u306E\u767A\u898B\u3068\u9078\u629E (\`"delegation"\` \u307E\u305F\u306F \`"both"\` \u306E\u5834\u5408)
|
|
91636
|
+
|
|
91637
|
+
1. \`askUserQuestion\` \u3067\u5BFE\u8C61\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u805E\u304F:
|
|
91638
|
+
- \`type\`: \`"freeText"\`
|
|
91639
|
+
- \`question\`: \u300C\u30A2\u30AF\u30BB\u30B9\u3057\u305F\u3044\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u6240\u6709\u3059\u308B Google Workspace \u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u53EF\u3001\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09\u3002Workspace \u7BA1\u7406\u8005\u304C\u3001\u3053\u306E\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306B\u5BFE\u3057\u3066\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u3092\u3042\u3089\u304B\u3058\u3081\u627F\u8A8D\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08[\u7BA1\u7406\u8005\u5411\u3051\u8A2D\u5B9A\u30AC\u30A4\u30C9](https://support.google.com/a/answer/162106)\uFF09\u3002\u300D
|
|
91640
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
91641
|
+
|
|
91642
|
+
2. \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u53D7\u3051\u53D6\u3063\u305F\u6587\u5B57\u5217\u304B\u3089\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u62BD\u51FA\u3057\u3001\u5404 \`<email>\` \u306B\u3064\u3044\u3066 \`${requestWithDelegationToolName}\` \u3092\u547C\u3076:
|
|
91643
|
+
- \`method\`: \`"GET"\`
|
|
91644
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91645
|
+
- \`subject\`: \`<email>\`
|
|
91646
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91647
|
+
|
|
91648
|
+
3. \u53D6\u5F97\u7D50\u679C\u306B\u5FDC\u3058\u3066\u5206\u5C90:
|
|
91649
|
+
- \u5168 email \u3067\u53D6\u5F97\u5931\u6557: \u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u304C \`"delegation"\` \u3060\u3051\u3001\u3082\u3057\u304F\u306F \`"both"\` \u3067\u30B9\u30C6\u30C3\u30D7 2 \u3067\u3082 0 \u4EF6\u306E\u5834\u5408\u306F\u30B9\u30C6\u30C3\u30D7 5 \u3078\u3002\`"both"\` \u3067\u30B9\u30C6\u30C3\u30D7 2 \u306B\u30AB\u30EC\u30F3\u30C0\u30FC\u304C\u3042\u3063\u305F\u5834\u5408\u306F\u305D\u306E\u307E\u307E\u30B9\u30C6\u30C3\u30D7 4 \u3078
|
|
91650
|
+
- \u4E00\u90E8\u307E\u305F\u306F\u5168\u4EF6\u6210\u529F: \`askUserQuestion\` \u3067\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u3070\u305B\u308B
|
|
91651
|
+
- \`type\`: \`"multiSelect"\`
|
|
91652
|
+
- \`question\`: \u300C\u4F7F\u7528\u3059\u308B\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u53EF\uFF09\u300D
|
|
91653
|
+
- \`options\`: \u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u3064\u3044\u3066 \`label\`: \`"<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D> (\u6240\u6709\u8005: <\u305D\u306E\u3068\u304D\u306E subject>)"\`\u3001\`value\`: \`"<calendarId>"\`
|
|
91654
|
+
- \u4E00\u90E8\u5931\u6557\u304C\u3042\u308C\u3070\u3001\u305D\u306E\u65E8\u3092 1 \u6587\u3067\u77ED\u304F\u4F1D\u3048\u308B
|
|
91655
|
+
|
|
91656
|
+
## \u30B9\u30C6\u30C3\u30D7 4: Project Knowledge \u306B\u8A18\u9332
|
|
91657
|
+
|
|
91658
|
+
\u30B9\u30C6\u30C3\u30D7 2 \u3068 3 \u3067\u9078\u3070\u308C\u305F calendarId \u96C6\u5408\u3092\u30C7\u30A3\u30B9\u30AB\u30D0\u30EA\u7D50\u679C\u3068\u7A81\u304D\u5408\u308F\u305B\u3066\u3001\u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u7D4C\u8DEF\u3068 subject \u3092\u7279\u5B9A\u3059\u308B\u3002\`finalizeSetup\` \u3092\u547C\u3073\u3001\`projectKnowledge\` \u306E \`#### \u30B9\u30B3\u30FC\u30D7\` \u7BC0\u306B\u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u3092 1 \u884C\u305A\u3064\u5217\u6319\u3059\u308B:
|
|
91659
|
+
- \u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u7D4C\u7531: \`- calendar: <calendarId> (delegation, subject: <subject>, name: "<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D>")\`
|
|
91660
|
+
- \u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u7D4C\u8DEF: \`- calendar: <calendarId> (service-account, name: "<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D>")\`
|
|
91661
|
+
|
|
91662
|
+
## \u30B9\u30C6\u30C3\u30D7 5: \u6700\u7D42\u7684\u306B\u30AB\u30EC\u30F3\u30C0\u30FC\u304C 0 \u4EF6\u306E\u5834\u5408\u306E\u30A8\u30B9\u30AB\u30EC\u30FC\u30B7\u30E7\u30F3
|
|
91663
|
+
|
|
91664
|
+
\u6700\u7D42\u7684\u306B\u9078\u629E\u30AB\u30EC\u30F3\u30C0\u30FC\u304C 1 \u4EF6\u3082\u7121\u3044\u5834\u5408 (\u5404\u7D4C\u8DEF\u306E\u767A\u898B\u304C\u7A7A\u3001\u307E\u305F\u306F\u9078\u629E\u3055\u308C\u306A\u304B\u3063\u305F)\u3001\u30A8\u30E9\u30FC\u30EC\u30B9\u30DD\u30F3\u30B9\u304B\u3089 \`serviceAccountEmail\` \u3092\u53D6\u308A\u51FA\u3057\u3001\`askUserQuestion\` \u3067\u6B21\u306E\u3088\u3046\u306B\u6848\u5185\u3059\u308B:
|
|
91665
|
+
|
|
91666
|
+
- \`question\`: \u300C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30AB\u30EC\u30F3\u30C0\u30FC\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093\u3067\u3057\u305F\u3002\u6B21\u306E\u3044\u305A\u308C\u304B\u3092\u884C\u3063\u3066\u304B\u3089\u7D9A\u884C\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8: \`<serviceAccountEmail>\`\u3002\u300D
|
|
91667
|
+
- \`options\`: \u3053\u3053\u307E\u3067\u306B\u8A66\u3057\u305F\u7D4C\u8DEF\u306B\u5FDC\u3058\u3066\u4EE5\u4E0B\u3092\u7D44\u307F\u5408\u308F\u305B\u308B:
|
|
91668
|
+
- \u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u7D4C\u8DEF\u3092\u8A66\u3057\u305F\u5834\u5408: \`{ label: "\u5BFE\u8C61\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306B\u5171\u6709\u3057\u305F\u306E\u3067\u30EA\u30C8\u30E9\u30A4", value: "retry" }\`
|
|
91669
|
+
- \u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u7D4C\u8DEF\u3092\u8A66\u3057\u305F\u5834\u5408: \`{ label: "\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u3092\u627F\u8A8D\u3057\u305F\u306E\u3067\u30EA\u30C8\u30E9\u30A4", value: "retry" }\`
|
|
91670
|
+
- \u5E38\u306B: \`{ label: "\u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u3092\u5909\u66F4\u3059\u308B", value: "restart" }\`
|
|
91671
|
+
- \u5E38\u306B: \`{ label: "\u5225\u306E\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u3067\u8A2D\u5B9A\u3057\u76F4\u3059", value: "change-service-account" }\`
|
|
91672
|
+
|
|
91673
|
+
\u9078\u629E\u7D50\u679C\u306B\u5FDC\u3058\u305F\u6319\u52D5:
|
|
91674
|
+
- "retry": \u76F4\u524D\u306E\u7D4C\u8DEF\u3092\u518D probe (\u5177\u4F53\u7684\u306A\u3084\u308A\u76F4\u3057\u65B9\u306F\u30A8\u30FC\u30B8\u30A7\u30F3\u30C8\u306B\u4EFB\u305B\u308B)
|
|
91675
|
+
- "restart": \u30B9\u30C6\u30C3\u30D7 1 \u304B\u3089\u518D\u5B9F\u884C
|
|
91676
|
+
- "change-service-account": \`updateConnectionParameters\` \u3092\u547C\u3093\u3067\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8 JSON \u3092\u518D\u5165\u529B\u3055\u305B\u308B:
|
|
91677
|
+
- \`parameterSlug\`: \`"${SERVICE_ACCOUNT_KEY_PARAM_SLUG}"\`
|
|
91678
|
+
- \u5B8C\u4E86\u5F8C\u3001\u30B9\u30C6\u30C3\u30D7 1 \u304B\u3089\u518D\u5B9F\u884C
|
|
91679
|
+
|
|
91680
|
+
## \u5236\u7D04
|
|
91681
|
+
|
|
91682
|
+
- \u4E0A\u8A18\u4EE5\u5916\u306E API \u547C\u3073\u51FA\u3057\u3092 setup \u4E2D\u306B\u884C\u308F\u306A\u3044
|
|
91683
|
+
- \u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u306E\u9593\u306F 1 \u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057`,
|
|
91684
|
+
en: `Set up the Google Calendar connection. Ask the user how they want to access calendars, discover and select the target calendars, and record them in Project Knowledge.
|
|
91685
|
+
|
|
91686
|
+
## Step 1: Choose the access method
|
|
91687
|
+
|
|
91688
|
+
Call \`askUserQuestion\`:
|
|
91689
|
+
- \`type\`: \`"select"\`
|
|
91690
|
+
- \`question\`: "Which calendars do you want to access?"
|
|
91691
|
+
- \`options\`:
|
|
91692
|
+
- \`{ label: "Calendars shared with this service account", value: "service-account" }\`
|
|
91693
|
+
- \`{ label: "Calendars of users in your organization (via Domain-wide Delegation)", value: "delegation" }\`
|
|
91694
|
+
- \`{ label: "Both", value: "both" }\`
|
|
91695
|
+
|
|
91696
|
+
## Step 2: Discover and select via the service-account path (when \`"service-account"\` or \`"both"\`)
|
|
91697
|
+
|
|
91698
|
+
1. Call \`${requestToolName}\`:
|
|
91699
|
+
- \`method\`: \`"GET"\`
|
|
91700
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91701
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91702
|
+
|
|
91703
|
+
2. Branch on the result:
|
|
91704
|
+
- Empty: if the access method is \`"service-account"\` only, jump to Step 5. If \`"both"\`, continue to Step 3.
|
|
91705
|
+
- Non-empty: ask the user to pick:
|
|
91706
|
+
- \`type\`: \`"multiSelect"\`
|
|
91707
|
+
- \`question\`: "Select the calendars to use (multiple allowed)"
|
|
91708
|
+
- \`options\`: For each calendar, \`label\`: \`"<calendar name>"\`, \`value\`: \`"<calendarId>"\`
|
|
91709
|
+
|
|
91710
|
+
## Step 3: Discover and select via the Domain-wide Delegation path (when \`"delegation"\` or \`"both"\`)
|
|
91711
|
+
|
|
91712
|
+
1. Ask the user for target emails:
|
|
91713
|
+
- \`type\`: \`"freeText"\`
|
|
91714
|
+
- \`question\`: "Enter the email addresses of the Google Workspace users whose calendars you want to access (comma-separated for multiple). Your Workspace admin must have authorized Domain-wide Delegation for this service account in advance ([admin setup guide](https://support.google.com/a/answer/162106))."
|
|
91715
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
91716
|
+
|
|
91717
|
+
2. Extract individual emails and, for each \`<email>\`, call \`${requestWithDelegationToolName}\`:
|
|
91718
|
+
- \`method\`: \`"GET"\`
|
|
91719
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91720
|
+
- \`subject\`: \`<email>\`
|
|
91721
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91722
|
+
|
|
91723
|
+
3. Branch on the results:
|
|
91724
|
+
- All emails failed: if the access method is \`"delegation"\` only, or it's \`"both"\` but Step 2 also produced 0 calendars, jump to Step 5. If \`"both"\` and Step 2 had calendars, proceed to Step 4.
|
|
91725
|
+
- Any success: ask the user to pick:
|
|
91726
|
+
- \`type\`: \`"multiSelect"\`
|
|
91727
|
+
- \`question\`: "Select the calendars to use (multiple allowed)"
|
|
91728
|
+
- \`options\`: For each calendar, \`label\`: \`"<calendar name> (owner: <the subject used>)"\`, \`value\`: \`"<calendarId>"\`
|
|
91729
|
+
- If some emails failed, mention that briefly in one sentence.
|
|
91730
|
+
|
|
91731
|
+
## Step 4: Record in Project Knowledge
|
|
91732
|
+
|
|
91733
|
+
Aggregate the calendarIds selected in Steps 2 and 3, cross-reference the discovery results to recover each calendar's access path and subject, and call \`finalizeSetup\`. Under \`#### \u30B9\u30B3\u30FC\u30D7\` in \`projectKnowledge\`, list each calendar on its own line:
|
|
91734
|
+
- Via Domain-wide Delegation: \`- calendar: <calendarId> (delegation, subject: <subject>, name: "<calendar name>")\`
|
|
91735
|
+
- Via service account: \`- calendar: <calendarId> (service-account, name: "<calendar name>")\`
|
|
91736
|
+
|
|
91737
|
+
## Step 5: Escalation when zero calendars are selected
|
|
91738
|
+
|
|
91739
|
+
If the final selected calendar set is empty (every attempted path returned nothing, or the user picked nothing), take \`serviceAccountEmail\` from any failed tool response and call \`askUserQuestion\`:
|
|
91740
|
+
|
|
91741
|
+
- \`question\`: "No accessible calendars found. Please do one of the following before continuing. Service account: \`<serviceAccountEmail>\`."
|
|
91742
|
+
- \`options\`: Combine these based on which paths were attempted:
|
|
91743
|
+
- Service-account path attempted: \`{ label: "Shared the calendar with the service account \u2014 retry", value: "retry" }\`
|
|
91744
|
+
- Domain-wide Delegation path attempted: \`{ label: "Authorized Domain-wide Delegation \u2014 retry", value: "retry" }\`
|
|
91745
|
+
- Always: \`{ label: "Change the access method", value: "restart" }\`
|
|
91746
|
+
- Always: \`{ label: "Use a different service account", value: "change-service-account" }\`
|
|
91747
|
+
|
|
91748
|
+
Behavior per selection:
|
|
91749
|
+
- "retry": re-probe the path that was just attempted (leave the exact retry plan to the agent)
|
|
91750
|
+
- "restart": re-run from Step 1
|
|
91751
|
+
- "change-service-account": call \`updateConnectionParameters\` to have the user re-upload the service account JSON:
|
|
91752
|
+
- \`parameterSlug\`: \`"${SERVICE_ACCOUNT_KEY_PARAM_SLUG}"\`
|
|
91753
|
+
- After it completes, re-run from Step 1
|
|
91754
|
+
|
|
91755
|
+
## Constraints
|
|
91756
|
+
|
|
91757
|
+
- Do not call any other API endpoints during setup
|
|
91758
|
+
- Write at most 1 sentence between tool calls`
|
|
91759
|
+
},
|
|
91760
|
+
dataOverviewInstructions: {
|
|
91761
|
+
en: `For each calendar recorded under \`#### \u30B9\u30B3\u30FC\u30D7\`, fetch metadata and a small sample of upcoming events. The annotation on each line tells you which tool to use:
|
|
91762
|
+
- \`(delegation, subject: <email>, ...)\` \u2192 \`${requestWithDelegationToolName}\` with \`subject: <email>\`
|
|
91763
|
+
- \`(service-account, ...)\` \u2192 \`${requestToolName}\`
|
|
91764
|
+
|
|
91765
|
+
Pass \`scopes: ${READONLY_SCOPES}\` for every call.
|
|
91766
|
+
|
|
91767
|
+
For each calendar:
|
|
91768
|
+
1. \`method=GET\`, \`path=/calendars/<id>\` to fetch metadata.
|
|
91769
|
+
2. \`method=GET\`, \`path=/calendars/<id>/events\`, \`queryParams={ timeMin: <RFC3339 now>, maxResults: "10", singleEvents: "true", orderBy: "startTime" }\`.`,
|
|
91770
|
+
ja: `\`#### \u30B9\u30B3\u30FC\u30D7\` \u306E\u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u3064\u3044\u3066\u3001\u30E1\u30BF\u30C7\u30FC\u30BF\u3068\u76F4\u8FD1\u306E\u30A4\u30D9\u30F3\u30C8\u3092\u5C11\u91CF\u53D6\u5F97\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u5404\u884C\u306E\u6CE8\u91C8\u3067\u4F7F\u7528\u3059\u308B\u30C4\u30FC\u30EB\u3092\u9078\u3073\u307E\u3059:
|
|
91771
|
+
- \`(delegation, subject: <email>, ...)\` \u2192 \`${requestWithDelegationToolName}\` \u3092 \`subject: <email>\` \u4ED8\u304D\u3067\u547C\u3076
|
|
91772
|
+
- \`(service-account, ...)\` \u2192 \`${requestToolName}\` \u3092\u547C\u3076
|
|
91773
|
+
|
|
91774
|
+
\`scopes\` \u306F\u6BCE\u56DE \`${READONLY_SCOPES}\` \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
91775
|
+
|
|
91776
|
+
\u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u3064\u3044\u3066:
|
|
91777
|
+
1. \`method=GET\`\u3001\`path=/calendars/<id>\` \u3067\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
91778
|
+
2. \`method=GET\`\u3001\`path=/calendars/<id>/events\`\u3001\`queryParams={ timeMin: <RFC3339 \u306E\u73FE\u5728\u6642\u523B>, maxResults: "10", singleEvents: "true", orderBy: "startTime" }\``
|
|
91779
|
+
}
|
|
91780
|
+
});
|
|
91781
|
+
|
|
91722
91782
|
// ../connectors/src/connectors/google-calendar/index.ts
|
|
91723
|
-
var tools14 = {
|
|
91783
|
+
var tools14 = {
|
|
91784
|
+
request: requestTool5,
|
|
91785
|
+
request_with_delegation: requestWithDelegationTool
|
|
91786
|
+
};
|
|
91724
91787
|
var googleCalendarConnector = new ConnectorPlugin({
|
|
91725
91788
|
slug: "google-calendar",
|
|
91726
91789
|
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
@@ -91733,58 +91796,45 @@ var googleCalendarConnector = new ConnectorPlugin({
|
|
|
91733
91796
|
systemPrompt: {
|
|
91734
91797
|
en: `### Tools
|
|
91735
91798
|
|
|
91736
|
-
|
|
91799
|
+
This connector exposes two request tools that correspond to the two ways a Service Account can authenticate against the Google Calendar API:
|
|
91737
91800
|
|
|
91738
|
-
|
|
91801
|
+
- \`google-calendar-service-account_request_with_delegation\`: Call the Calendar API on behalf of the specified Workspace user via Domain-wide Delegation. Pass \`subject\` as the target user email. Requires Domain-wide Delegation to be authorized for the service account in the Workspace admin console.
|
|
91802
|
+
- \`google-calendar-service-account_request\`: Call the Calendar API as the service account itself (no delegation). Only calendars explicitly shared with the service account email are accessible.
|
|
91739
91803
|
|
|
91740
|
-
|
|
91804
|
+
Both tools require a \`scopes\` argument.
|
|
91741
91805
|
|
|
91742
|
-
|
|
91743
|
-
- \`client.listCalendars()\` \u2014 list all accessible calendars
|
|
91744
|
-
- \`client.listEvents(options?, calendarId?)\` \u2014 list events with optional filters
|
|
91745
|
-
- \`client.getEvent(eventId, calendarId?)\` \u2014 get a single event by ID
|
|
91746
|
-
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
91806
|
+
### OAuth Scopes (pass as \`scopes\` argument)
|
|
91747
91807
|
|
|
91748
|
-
|
|
91808
|
+
This connector is currently read-only. Pass one of:
|
|
91749
91809
|
|
|
91750
|
-
|
|
91810
|
+
- \`https://www.googleapis.com/auth/calendar.readonly\` \u2014 read-only on calendars and events
|
|
91811
|
+
- \`https://www.googleapis.com/auth/calendar.events.readonly\` \u2014 read-only on events (no calendar metadata)
|
|
91812
|
+
- \`https://www.googleapis.com/auth/calendar.freebusy\` \u2014 busy/free time queries only
|
|
91751
91813
|
|
|
91752
|
-
|
|
91753
|
-
const calendar = connection("<connectionId>", { subject: "other-user@example.com" });
|
|
91754
|
-
\`\`\`
|
|
91814
|
+
For \`request_with_delegation\`, the Workspace admin must have authorized the requested scope for the service account in the Domain-wide Delegation settings, otherwise token issuance will fail with \`unauthorized_client\`.
|
|
91755
91815
|
|
|
91756
|
-
|
|
91757
|
-
import type { Context } from "hono";
|
|
91758
|
-
import { connection } from "@squadbase/vite-server/connectors/google-calendar";
|
|
91816
|
+
Per-endpoint scope reference: https://developers.google.com/calendar/api/auth
|
|
91759
91817
|
|
|
91760
|
-
|
|
91818
|
+
### Choosing the right tool
|
|
91761
91819
|
|
|
91762
|
-
|
|
91763
|
-
const now = new Date().toISOString();
|
|
91764
|
-
const { items } = await calendar.listEvents({
|
|
91765
|
-
timeMin: now,
|
|
91766
|
-
maxResults: 10,
|
|
91767
|
-
singleEvents: true,
|
|
91768
|
-
orderBy: "startTime",
|
|
91769
|
-
});
|
|
91820
|
+
Read \`#### \u30B9\u30B3\u30FC\u30D7\` in the project knowledge for this connection. Each calendar appears as a \`- calendar: <id> (...)\` line whose annotation tells you which tool to use:
|
|
91770
91821
|
|
|
91771
|
-
|
|
91772
|
-
|
|
91773
|
-
|
|
91774
|
-
|
|
91775
|
-
|
|
91776
|
-
|
|
91777
|
-
|
|
91778
|
-
|
|
91779
|
-
|
|
91780
|
-
|
|
91781
|
-
\`\`\`
|
|
91822
|
+
- \`(delegation, subject: <email>, name: "...")\` \u2192 use \`request_with_delegation\` and pass \`subject: <email>\`
|
|
91823
|
+
- \`(service-account, name: "...")\` \u2192 use \`request\` (no \`subject\`)
|
|
91824
|
+
|
|
91825
|
+
### Path conventions
|
|
91826
|
+
|
|
91827
|
+
Write the calendar ID directly into the path \u2014 there is no placeholder substitution. Examples:
|
|
91828
|
+
|
|
91829
|
+
- \`/users/me/calendarList\` \u2014 list calendars accessible to the authenticated identity
|
|
91830
|
+
- \`/calendars/alice@example.com/events\` \u2014 events on alice's primary calendar
|
|
91831
|
+
- \`/calendars/c_abc123@group.calendar.google.com/events\` \u2014 events on a secondary calendar
|
|
91782
91832
|
|
|
91783
91833
|
### Google Calendar API v3 Reference
|
|
91784
91834
|
|
|
91785
91835
|
#### Available Endpoints
|
|
91786
91836
|
- GET \`/calendars/{calendarId}\` \u2014 Get calendar metadata
|
|
91787
|
-
- GET \`/users/me/calendarList\` \u2014 List all calendars accessible by the authenticated
|
|
91837
|
+
- GET \`/users/me/calendarList\` \u2014 List all calendars accessible by the authenticated identity
|
|
91788
91838
|
- GET \`/calendars/{calendarId}/events\` \u2014 List events on a calendar
|
|
91789
91839
|
- GET \`/calendars/{calendarId}/events/{eventId}\` \u2014 Get a single event
|
|
91790
91840
|
|
|
@@ -91796,66 +91846,93 @@ export default async function handler(c: Context) {
|
|
|
91796
91846
|
- \`orderBy=startTime\` \u2014 Order by start time (requires singleEvents=true)
|
|
91797
91847
|
- \`q\` \u2014 Free text search terms
|
|
91798
91848
|
|
|
91799
|
-
#### Tips
|
|
91800
|
-
- Use \`{calendarId}\` placeholder in paths \u2014 it is automatically replaced with the configured default calendar ID
|
|
91801
|
-
- Set \`singleEvents=true\` to expand recurring events into individual instances
|
|
91802
|
-
- When using \`orderBy=startTime\`, you must also set \`singleEvents=true\`
|
|
91803
|
-
- Use RFC3339 format for time parameters (e.g., "2024-01-15T09:00:00Z" or "2024-01-15T09:00:00+09:00")
|
|
91804
|
-
- The default calendar ID is "primary" if not configured`,
|
|
91805
|
-
ja: `### \u30C4\u30FC\u30EB
|
|
91806
|
-
|
|
91807
|
-
- \`google-calendar-service-account_request\`: Google Calendar API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u53D6\u5F97\u3001\u30A4\u30D9\u30F3\u30C8\u306E\u53D6\u5F97\u3001\u30AB\u30EC\u30F3\u30C0\u30FC\u30C7\u30FC\u30BF\u306E\u7BA1\u7406\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\uFF0BDomain-wide Delegation\u3067\u8A8D\u8A3C\u304C\u81EA\u52D5\u7684\u306B\u51E6\u7406\u3055\u308C\u3001\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306B\u8A2D\u5B9A\u3055\u308C\u305F\u30E6\u30FC\u30B6\u30FC\uFF08\`impersonate-email\`\u30D1\u30E9\u30E1\u30FC\u30BF\uFF09\u3068\u3057\u3066\u52D5\u4F5C\u3057\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{calendarId}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u8A2D\u5B9A\u6E08\u307F\u306E\u30C7\u30D5\u30A9\u30EB\u30C8\u30AB\u30EC\u30F3\u30C0\u30FCID\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002\u7279\u5B9A\u30EA\u30AF\u30A8\u30B9\u30C8\u3067\u8A2D\u5B9A\u30E6\u30FC\u30B6\u30FC\u3092\u4E0A\u66F8\u304D\u3057\u305F\u3044\u5834\u5408\u306E\u307F\u3001\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\`subject\`\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
91808
|
-
|
|
91809
91849
|
### Business Logic
|
|
91810
91850
|
|
|
91811
|
-
|
|
91851
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
91812
91852
|
|
|
91813
|
-
SDK
|
|
91814
|
-
- \`client.listCalendars()\` \u2014 \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u53D6\u5F97
|
|
91815
|
-
- \`client.listEvents(options?, calendarId?)\` \u2014 \u30D5\u30A3\u30EB\u30BF\u30FC\u4ED8\u304D\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7\u53D6\u5F97
|
|
91816
|
-
- \`client.getEvent(eventId, calendarId?)\` \u2014 ID\u306B\u3088\u308B\u5358\u4E00\u30A4\u30D9\u30F3\u30C8\u53D6\u5F97
|
|
91817
|
-
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
91853
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
91818
91854
|
|
|
91819
|
-
|
|
91855
|
+
- \`client.requestWithDelegation(path, { subject, scopes, init? })\` \u2014 call the API as the impersonated Workspace user via Domain-wide Delegation
|
|
91856
|
+
- \`client.request(path, { scopes, init? })\` \u2014 call the API as the service account itself (only calendars shared with the SA email are accessible)
|
|
91820
91857
|
|
|
91821
|
-
|
|
91858
|
+
Both methods take \`scopes\` \u2014 pass the minimum scope(s) for the endpoint. Both return a standard \`Response\`. Read the body with \`.json()\`. Same path conventions as the tools.
|
|
91822
91859
|
|
|
91823
|
-
|
|
91824
|
-
const calendar = connection("<connectionId>", { subject: "other-user@example.com" });
|
|
91825
|
-
\`\`\`
|
|
91860
|
+
#### Example
|
|
91826
91861
|
|
|
91827
91862
|
\`\`\`ts
|
|
91828
91863
|
import type { Context } from "hono";
|
|
91829
91864
|
import { connection } from "@squadbase/vite-server/connectors/google-calendar";
|
|
91830
91865
|
|
|
91831
91866
|
const calendar = connection("<connectionId>");
|
|
91867
|
+
const READ = ["https://www.googleapis.com/auth/calendar.readonly"];
|
|
91832
91868
|
|
|
91833
91869
|
export default async function handler(c: Context) {
|
|
91834
91870
|
const now = new Date().toISOString();
|
|
91835
|
-
const
|
|
91871
|
+
const qs = new URLSearchParams({
|
|
91836
91872
|
timeMin: now,
|
|
91837
|
-
maxResults: 10,
|
|
91838
|
-
singleEvents: true,
|
|
91873
|
+
maxResults: "10",
|
|
91874
|
+
singleEvents: "true",
|
|
91839
91875
|
orderBy: "startTime",
|
|
91840
91876
|
});
|
|
91841
91877
|
|
|
91842
|
-
|
|
91843
|
-
|
|
91844
|
-
|
|
91845
|
-
|
|
91846
|
-
|
|
91847
|
-
|
|
91848
|
-
|
|
91849
|
-
|
|
91878
|
+
// Project knowledge says: alice@example.com is reachable via delegation
|
|
91879
|
+
const aliceRes = await calendar.requestWithDelegation(
|
|
91880
|
+
\`/calendars/alice@example.com/events?\${qs}\`,
|
|
91881
|
+
{ subject: "alice@example.com", scopes: READ },
|
|
91882
|
+
);
|
|
91883
|
+
const alice = await aliceRes.json();
|
|
91884
|
+
|
|
91885
|
+
// Project knowledge says: team@example.com is shared with the SA
|
|
91886
|
+
const teamRes = await calendar.request(
|
|
91887
|
+
\`/calendars/team@example.com/events?\${qs}\`,
|
|
91888
|
+
{ scopes: READ },
|
|
91850
91889
|
);
|
|
91890
|
+
const team = await teamRes.json();
|
|
91891
|
+
|
|
91892
|
+
return c.json({ alice: alice.items, team: team.items });
|
|
91851
91893
|
}
|
|
91852
|
-
|
|
91894
|
+
\`\`\``,
|
|
91895
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
91896
|
+
|
|
91897
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u30FC\u306F\u3001Service Account \u304C Google Calendar API \u306B\u8A8D\u8A3C\u3059\u308B 2 \u3064\u306E\u65B9\u6CD5\u306B\u5BFE\u5FDC\u3059\u308B 2 \u3064\u306E request \u30C4\u30FC\u30EB\u3092\u516C\u958B\u3057\u307E\u3059:
|
|
91898
|
+
|
|
91899
|
+
- \`google-calendar-service-account_request_with_delegation\`: \u6307\u5B9A\u3055\u308C\u305F Workspace \u30E6\u30FC\u30B6\u30FC\u306B\u4EE3\u308F\u3063\u3066 Domain-wide Delegation \u7D4C\u7531\u3067 Calendar API \u3092\u547C\u3073\u51FA\u3057\u307E\u3059\u3002\u4EE3\u7406\u5BFE\u8C61\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092 \`subject\` \u3068\u3057\u3066\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002Workspace \u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u3067 Service Account \u306E Domain-wide Delegation \u304C\u627F\u8A8D\u3055\u308C\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002
|
|
91900
|
+
- \`google-calendar-service-account_request\`: Service Account \u81EA\u8EAB\u3068\u3057\u3066 Calendar API \u3092\u547C\u3073\u51FA\u3057\u307E\u3059 (Domain-wide Delegation \u3092\u4F7F\u308F\u306A\u3044\u7D4C\u8DEF)\u3002Service Account \u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u306B\u660E\u793A\u7684\u306B\u5171\u6709\u3055\u308C\u3066\u3044\u308B\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u307F\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u3067\u3059\u3002
|
|
91901
|
+
|
|
91902
|
+
\u4E21\u30C4\u30FC\u30EB\u3068\u3082 \`scopes\` \u5F15\u6570\u304C\u5FC5\u9808\u3067\u3059\u3002
|
|
91903
|
+
|
|
91904
|
+
### OAuth \u30B9\u30B3\u30FC\u30D7 (\`scopes\` \u5F15\u6570\u3067\u6E21\u3059)
|
|
91905
|
+
|
|
91906
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u30FC\u306F\u73FE\u72B6\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u3067\u3059\u3002\u6B21\u306E\u3044\u305A\u308C\u304B\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044:
|
|
91907
|
+
|
|
91908
|
+
- \`https://www.googleapis.com/auth/calendar.readonly\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u3068\u30A4\u30D9\u30F3\u30C8\u306E\u8AAD\u307F\u53D6\u308A
|
|
91909
|
+
- \`https://www.googleapis.com/auth/calendar.events.readonly\` \u2014 \u30A4\u30D9\u30F3\u30C8\u306E\u307F\u8AAD\u307F\u53D6\u308A\uFF08\u30AB\u30EC\u30F3\u30C0\u30FC\u30E1\u30BF\u30C7\u30FC\u30BF\u4E0D\u53EF\uFF09
|
|
91910
|
+
- \`https://www.googleapis.com/auth/calendar.freebusy\` \u2014 \u7A7A\u304D\u72B6\u6CC1\u30AF\u30A8\u30EA\u306E\u307F
|
|
91911
|
+
|
|
91912
|
+
\`request_with_delegation\` \u306E\u5834\u5408\u3001\u8981\u6C42\u3059\u308B scope \u306F Workspace \u7BA1\u7406\u8005\u304C Domain-wide Delegation \u8A2D\u5B9A\u3067\u5F53\u8A72 Service Account \u306B\u5BFE\u3057\u3066\u627F\u8A8D\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u627F\u8A8D\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u30C8\u30FC\u30AF\u30F3\u767A\u884C\u304C \`unauthorized_client\` \u3067\u5931\u6557\u3057\u307E\u3059\u3002
|
|
91913
|
+
|
|
91914
|
+
\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u5225\u306E\u6B63\u78BA\u306A scope \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9: https://developers.google.com/calendar/api/auth
|
|
91915
|
+
|
|
91916
|
+
### \u9069\u5207\u306A\u30C4\u30FC\u30EB\u306E\u9078\u3073\u65B9
|
|
91917
|
+
|
|
91918
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E Project Knowledge \u306E \`#### \u30B9\u30B3\u30FC\u30D7\` \u3092\u8AAD\u3093\u3067\u304F\u3060\u3055\u3044\u3002\u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306F \`- calendar: <id> (...)\` \u5F62\u5F0F\u306E\u884C\u3068\u3057\u3066\u8A18\u9332\u3055\u308C\u3066\u304A\u308A\u3001\u6CE8\u91C8\u304C\u3069\u3061\u3089\u306E\u30C4\u30FC\u30EB\u3092\u4F7F\u3046\u3079\u304D\u304B\u3092\u793A\u3057\u307E\u3059:
|
|
91919
|
+
|
|
91920
|
+
- \`(delegation, subject: <email>, name: "...")\` \u2192 \`request_with_delegation\` \u3092\u4F7F\u3044\u3001\`subject: <email>\` \u3092\u6E21\u3059
|
|
91921
|
+
- \`(service-account, name: "...")\` \u2192 \`request\` \u3092\u4F7F\u3046\uFF08\`subject\` \u4E0D\u8981\uFF09
|
|
91922
|
+
|
|
91923
|
+
### \u30D1\u30B9\u306E\u66F8\u304D\u65B9
|
|
91924
|
+
|
|
91925
|
+
calendar ID \u3092\u30D1\u30B9\u306B\u76F4\u63A5\u66F8\u3044\u3066\u304F\u3060\u3055\u3044\u3002\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306E\u7F6E\u63DB\u306F\u3042\u308A\u307E\u305B\u3093\u3002\u4F8B:
|
|
91926
|
+
|
|
91927
|
+
- \`/users/me/calendarList\` \u2014 \u8A8D\u8A3C\u3055\u308C\u305F\u8B58\u5225\u5B50\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7
|
|
91928
|
+
- \`/calendars/alice@example.com/events\` \u2014 alice \u306E\u30D7\u30E9\u30A4\u30DE\u30EA\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8
|
|
91929
|
+
- \`/calendars/c_abc123@group.calendar.google.com/events\` \u2014 \u4E8C\u6B21\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8
|
|
91853
91930
|
|
|
91854
91931
|
### Google Calendar API v3 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
91855
91932
|
|
|
91856
91933
|
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
91857
91934
|
- GET \`/calendars/{calendarId}\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
91858
|
-
- GET \`/users/me/calendarList\` \u2014 \u8A8D\u8A3C\
|
|
91935
|
+
- GET \`/users/me/calendarList\` \u2014 \u8A8D\u8A3C\u3055\u308C\u305F\u8B58\u5225\u5B50\u304C\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7
|
|
91859
91936
|
- GET \`/calendars/{calendarId}/events\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u4E0A\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7
|
|
91860
91937
|
- GET \`/calendars/{calendarId}/events/{eventId}\` \u2014 \u5358\u4E00\u30A4\u30D9\u30F3\u30C8\u306E\u53D6\u5F97
|
|
91861
91938
|
|
|
@@ -91867,12 +91944,52 @@ export default async function handler(c: Context) {
|
|
|
91867
91944
|
- \`orderBy=startTime\` \u2014 \u958B\u59CB\u6642\u9593\u9806\u306B\u4E26\u3079\u66FF\u3048\uFF08singleEvents=true\u304C\u5FC5\u8981\uFF09
|
|
91868
91945
|
- \`q\` \u2014 \u30D5\u30EA\u30FC\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u8A9E
|
|
91869
91946
|
|
|
91870
|
-
|
|
91871
|
-
|
|
91872
|
-
|
|
91873
|
-
|
|
91874
|
-
|
|
91875
|
-
|
|
91947
|
+
### Business Logic
|
|
91948
|
+
|
|
91949
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306E\u30D3\u30B8\u30CD\u30B9\u30ED\u30B8\u30C3\u30AF\u30BF\u30A4\u30D7\u306F "typescript" \u3067\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u30B3\u30CD\u30AF\u30BFSDK\u3092\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u74B0\u5883\u5909\u6570\u304B\u3089\u8A8D\u8A3C\u60C5\u5831\u3092\u8AAD\u307F\u53D6\u3089\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
|
|
91950
|
+
|
|
91951
|
+
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
91952
|
+
|
|
91953
|
+
- \`client.requestWithDelegation(path, { subject, scopes, init? })\` \u2014 Domain-wide Delegation \u3067\u6307\u5B9A Workspace \u30E6\u30FC\u30B6\u30FC\u306B\u4EE3\u308F\u3063\u3066 API \u3092\u547C\u3076
|
|
91954
|
+
- \`client.request(path, { scopes, init? })\` \u2014 SA \u81EA\u8EAB\u3068\u3057\u3066 API \u3092\u547C\u3076\uFF08SA \u306B\u5171\u6709\u3055\u308C\u305F\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u307F\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\uFF09
|
|
91955
|
+
|
|
91956
|
+
\u4E21\u30E1\u30BD\u30C3\u30C9\u3068\u3082 \`scopes\` \u3092\u53D7\u3051\u53D6\u308A\u307E\u3059\u3002\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306B\u5FC5\u8981\u306A\u6700\u5C0F scope \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u6A19\u6E96\u306E \`Response\` \u3092\u8FD4\u3059\u306E\u3067 \`response.json()\` \u3067\u30DC\u30C7\u30A3\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30D1\u30B9\u306E\u66F8\u304D\u65B9\u306F\u30C4\u30FC\u30EB\u3068\u540C\u3058\u3002
|
|
91957
|
+
|
|
91958
|
+
#### Example
|
|
91959
|
+
|
|
91960
|
+
\`\`\`ts
|
|
91961
|
+
import type { Context } from "hono";
|
|
91962
|
+
import { connection } from "@squadbase/vite-server/connectors/google-calendar";
|
|
91963
|
+
|
|
91964
|
+
const calendar = connection("<connectionId>");
|
|
91965
|
+
const READ = ["https://www.googleapis.com/auth/calendar.readonly"];
|
|
91966
|
+
|
|
91967
|
+
export default async function handler(c: Context) {
|
|
91968
|
+
const now = new Date().toISOString();
|
|
91969
|
+
const qs = new URLSearchParams({
|
|
91970
|
+
timeMin: now,
|
|
91971
|
+
maxResults: "10",
|
|
91972
|
+
singleEvents: "true",
|
|
91973
|
+
orderBy: "startTime",
|
|
91974
|
+
});
|
|
91975
|
+
|
|
91976
|
+
// Project Knowledge: alice@example.com \u306F delegation \u7D4C\u8DEF\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD
|
|
91977
|
+
const aliceRes = await calendar.requestWithDelegation(
|
|
91978
|
+
\`/calendars/alice@example.com/events?\${qs}\`,
|
|
91979
|
+
{ subject: "alice@example.com", scopes: READ },
|
|
91980
|
+
);
|
|
91981
|
+
const alice = await aliceRes.json();
|
|
91982
|
+
|
|
91983
|
+
// Project Knowledge: team@example.com \u306F SA \u306B\u5171\u6709\u3055\u308C\u3066\u3044\u308B
|
|
91984
|
+
const teamRes = await calendar.request(
|
|
91985
|
+
\`/calendars/team@example.com/events?\${qs}\`,
|
|
91986
|
+
{ scopes: READ },
|
|
91987
|
+
);
|
|
91988
|
+
const team = await teamRes.json();
|
|
91989
|
+
|
|
91990
|
+
return c.json({ alice: alice.items, team: team.items });
|
|
91991
|
+
}
|
|
91992
|
+
\`\`\``
|
|
91876
91993
|
},
|
|
91877
91994
|
tools: tools14
|
|
91878
91995
|
});
|
|
@@ -91935,7 +92052,7 @@ var outputSchema23 = z23.discriminatedUnion("success", [
|
|
|
91935
92052
|
error: z23.string()
|
|
91936
92053
|
})
|
|
91937
92054
|
]);
|
|
91938
|
-
var
|
|
92055
|
+
var listCalendarsTool = new ConnectorTool({
|
|
91939
92056
|
name: "listCalendars",
|
|
91940
92057
|
description: "List all Google Calendars accessible with the OAuth credentials. Use during setup to discover available calendars.",
|
|
91941
92058
|
inputSchema: inputSchema23,
|
|
@@ -91996,12 +92113,12 @@ var listCalendarsTool2 = new ConnectorTool({
|
|
|
91996
92113
|
});
|
|
91997
92114
|
|
|
91998
92115
|
// ../connectors/src/connectors/google-calendar-oauth/setup.ts
|
|
91999
|
-
var
|
|
92116
|
+
var listCalendarsToolName = `google-calendar-oauth_${listCalendarsTool.name}`;
|
|
92000
92117
|
var googleCalendarOauthOnboarding = new ConnectorOnboarding({
|
|
92001
92118
|
connectionSetupInstructions: {
|
|
92002
92119
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Calendar (OAuth) \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
92003
92120
|
|
|
92004
|
-
1. \`${
|
|
92121
|
+
1. \`${listCalendarsToolName}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001OAuth\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B
|
|
92005
92122
|
2. \u300C\u4F7F\u7528\u3059\u308B\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u300D\u3068\u30E6\u30FC\u30B6\u30FC\u306B\u4F1D\u3048\u305F\u4E0A\u3067\u3001\`askUserQuestion\` \u3092\u547C\u3073\u51FA\u3059:
|
|
92006
92123
|
- \`options\`: \u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7\u3002\u5404 option \u306E \`label\` \u306F \`\u30AB\u30EC\u30F3\u30C0\u30FC\u540D (id: \u30AB\u30EC\u30F3\u30C0\u30FCID)\` \u306E\u5F62\u5F0F\u3001\`value\` \u306F\u30AB\u30EC\u30F3\u30C0\u30FCID
|
|
92007
92124
|
3. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
@@ -92013,7 +92130,7 @@ var googleCalendarOauthOnboarding = new ConnectorOnboarding({
|
|
|
92013
92130
|
- \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`,
|
|
92014
92131
|
en: `Follow these steps to set up the Google Calendar (OAuth) connection.
|
|
92015
92132
|
|
|
92016
|
-
1. Call \`${
|
|
92133
|
+
1. Call \`${listCalendarsToolName}\` to get the list of calendars accessible with the OAuth credentials
|
|
92017
92134
|
2. Tell the user "Please select a calendar.", then call \`askUserQuestion\`:
|
|
92018
92135
|
- \`options\`: The calendar list. Each option's \`label\` should be \`Calendar Name (id: calendarId)\`, \`value\` should be the calendar ID
|
|
92019
92136
|
3. Call \`updateConnectionParameters\`:
|
|
@@ -92169,7 +92286,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
92169
92286
|
// ../connectors/src/connectors/google-calendar-oauth/index.ts
|
|
92170
92287
|
var tools15 = {
|
|
92171
92288
|
request: requestTool6,
|
|
92172
|
-
listCalendars:
|
|
92289
|
+
listCalendars: listCalendarsTool
|
|
92173
92290
|
};
|
|
92174
92291
|
var googleCalendarOauthConnector = new ConnectorPlugin({
|
|
92175
92292
|
slug: "google-calendar",
|
|
@@ -93205,7 +93322,7 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
93205
93322
|
});
|
|
93206
93323
|
|
|
93207
93324
|
// ../connectors/src/connectors/google-sheets/setup.ts
|
|
93208
|
-
var
|
|
93325
|
+
var requestToolName2 = `google-sheets-oauth_${requestTool9.name}`;
|
|
93209
93326
|
var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
93210
93327
|
connectionSetupInstructions: {
|
|
93211
93328
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Google Sheets (OAuth) \u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u306F\u8AAD\u307F\u66F8\u304D\u53EF\u80FD\u306A\u30B9\u30B3\u30FC\u30D7 (\`spreadsheets\`) \u3067\u63A5\u7D9A\u3055\u308C\u3001OAuth\u8A8D\u8A3C\u3057\u305FGoogle\u30A2\u30AB\u30A6\u30F3\u30C8\u304C\u6A29\u9650\u3092\u6301\u3064\u4EFB\u610F\u306E\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306B\u5BFE\u3057\u3066\u8AAD\u307F\u66F8\u304D\u3067\u304D\u307E\u3059\u3002
|
|
@@ -93215,12 +93332,12 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
93215
93332
|
- \`question\`: \u300C\u64CD\u4F5C\u3057\u305F\u3044Google Sheets\u306EURL\u3092\u8CBC\u308A\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044\uFF08\u8AAD\u307F\u53D6\u308A\u30FB\u7DE8\u96C6\u3069\u3061\u3089\u3082\u53EF\u80FD\u3067\u3059\uFF09\u300D
|
|
93216
93333
|
- \`placeholder\`: \`"https://docs.google.com/spreadsheets/d/.../edit"\`
|
|
93217
93334
|
2. \u53D7\u3051\u53D6\u3063\u305FURL\u304B\u3089\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8ID\u3092\u62BD\u51FA\u3059\u308B\u3002URL\u306E \`/d/\` \u3068 \`/edit\`\uFF08\u307E\u305F\u306F\u672B\u5C3E\uFF09\u306E\u9593\u306B\u3042\u308B\u6587\u5B57\u5217\u304C\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8ID\u3067\u3059\uFF08\u4F8B: \`https://docs.google.com/spreadsheets/d/1AbCxyz.../edit\` \u2192 \`1AbCxyz...\`\uFF09\u3002URL\u3067\u306F\u306A\u304FID\u3060\u3051\u304C\u6E21\u3055\u308C\u305F\u5834\u5408\u306F\u305D\u306E\u307E\u307E\u5229\u7528\u3057\u307E\u3059\u3002
|
|
93218
|
-
3. \`${
|
|
93335
|
+
3. \`${requestToolName2}\` \u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u6027\u3092\u78BA\u8A8D\u3059\u308B:
|
|
93219
93336
|
- \`method\`: \`"GET"\`
|
|
93220
93337
|
- \`path\`: \`"/<\u62BD\u51FA\u3057\u305FspreadsheetId>"\`
|
|
93221
93338
|
4. **\u691C\u8A3C\u5931\u6557\u6642\u306E\u518D\u30D2\u30A2\u30EA\u30F3\u30B0**: \u30B9\u30C6\u30C3\u30D73\u304C \`success: false\` \u3092\u8FD4\u3057\u305F\u5834\u5408\uFF08404/403/\u898B\u3064\u304B\u3089\u306A\u3044\u7B49\uFF09\u3001\u4EE5\u4E0B\u306E\u624B\u9806\u3067\u518D\u8A66\u884C\u3059\u308B:
|
|
93222
93339
|
a. \u30E6\u30FC\u30B6\u30FC\u306B\u539F\u56E0\u306E\u53EF\u80FD\u6027\u3092\u4F1D\u3048\u308B\uFF08URL\u304C\u9593\u9055\u3063\u3066\u3044\u308B\u3001OAuth\u9023\u643A\u3057\u305FGoogle\u30A2\u30AB\u30A6\u30F3\u30C8\u306B\u30A2\u30AF\u30BB\u30B9\u6A29\u9650\u304C\u306A\u3044\u3001\u30D7\u30E9\u30A4\u30D9\u30FC\u30C8\u30B7\u30FC\u30C8\u3067\u5225\u30A2\u30AB\u30A6\u30F3\u30C8\u3068\u5171\u6709\u3055\u308C\u3066\u3044\u308B \u7B49\uFF09
|
|
93223
|
-
b. \`askUserQuestion\` \u3067\u3082\u3046\u4E00\u5EA6URL\u3092\u805E\u304D\u76F4\u3057\u3001\u518D\u5EA6 \`${
|
|
93340
|
+
b. \`askUserQuestion\` \u3067\u3082\u3046\u4E00\u5EA6URL\u3092\u805E\u304D\u76F4\u3057\u3001\u518D\u5EA6 \`${requestToolName2}\` \u3067\u691C\u8A3C
|
|
93224
93341
|
c. \u6210\u529F\u3059\u308B\u307E\u3067\uFF08\u307E\u305F\u306F\u30E6\u30FC\u30B6\u30FC\u304C\u4E2D\u65AD\u3059\u308B\u307E\u3067\uFF09\u3053\u306E\u30EB\u30FC\u30D7\u3092\u7E70\u308A\u8FD4\u3059
|
|
93225
93342
|
|
|
93226
93343
|
#### \u5236\u7D04
|
|
@@ -93234,12 +93351,12 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
93234
93351
|
- \`question\`: "Please paste the URL of the Google Sheet you want to work with (both read and edit are supported)."
|
|
93235
93352
|
- \`placeholder\`: \`"https://docs.google.com/spreadsheets/d/.../edit"\`
|
|
93236
93353
|
2. Extract the spreadsheet ID from the URL. It is the segment between \`/d/\` and \`/edit\` (or the end of the URL), e.g. \`https://docs.google.com/spreadsheets/d/1AbCxyz.../edit\` \u2192 \`1AbCxyz...\`. If the user pasted just the ID, use it as-is.
|
|
93237
|
-
3. Verify accessibility by calling \`${
|
|
93354
|
+
3. Verify accessibility by calling \`${requestToolName2}\`:
|
|
93238
93355
|
- \`method\`: \`"GET"\`
|
|
93239
93356
|
- \`path\`: \`"/<extracted spreadsheetId>"\`
|
|
93240
93357
|
4. **Retry on verification failure**: If step 3 returns \`success: false\` (404/403/not found or any other error):
|
|
93241
93358
|
a. Tell the user the likely causes (wrong URL, OAuth-connected Google account lacks access, private sheet shared with a different account, etc.)
|
|
93242
|
-
b. Call \`askUserQuestion\` again to re-ask for the URL and re-verify with \`${
|
|
93359
|
+
b. Call \`askUserQuestion\` again to re-ask for the URL and re-verify with \`${requestToolName2}\`
|
|
93243
93360
|
c. Repeat until verification succeeds (or the user aborts)
|
|
93244
93361
|
|
|
93245
93362
|
#### Constraints
|
|
@@ -93248,10 +93365,10 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
93248
93365
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently.`
|
|
93249
93366
|
},
|
|
93250
93367
|
dataOverviewInstructions: {
|
|
93251
|
-
en: `1. Call ${
|
|
93252
|
-
2. For each sheet of interest, call ${
|
|
93253
|
-
ja: `1. ${
|
|
93254
|
-
2. \u4E3B\u8981\u306A\u30B7\u30FC\u30C8\u306B\u3064\u3044\u3066 ${
|
|
93368
|
+
en: `1. Call ${requestToolName2} with GET /<spreadsheetId> to fetch spreadsheet metadata (sheet names, grid properties)
|
|
93369
|
+
2. For each sheet of interest, call ${requestToolName2} with GET /<spreadsheetId>/values/<SheetName>!A1:Z5 to sample the first rows and understand the column layout`,
|
|
93370
|
+
ja: `1. ${requestToolName2} \u3067 GET /<spreadsheetId> \u3092\u547C\u3073\u51FA\u3057\u3001\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\uFF08\u30B7\u30FC\u30C8\u540D\u3001\u30B0\u30EA\u30C3\u30C9\u30D7\u30ED\u30D1\u30C6\u30A3\uFF09\u3092\u53D6\u5F97
|
|
93371
|
+
2. \u4E3B\u8981\u306A\u30B7\u30FC\u30C8\u306B\u3064\u3044\u3066 ${requestToolName2} \u3067 GET /<spreadsheetId>/values/<\u30B7\u30FC\u30C8\u540D>!A1:Z5 \u3092\u547C\u3073\u51FA\u3057\u3001\u5148\u982D\u6570\u884C\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u3057\u3066\u30AB\u30E9\u30E0\u69CB\u9020\u3092\u628A\u63E1`
|
|
93255
93372
|
}
|
|
93256
93373
|
});
|
|
93257
93374
|
|
|
@@ -93867,12 +93984,12 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
93867
93984
|
});
|
|
93868
93985
|
|
|
93869
93986
|
// ../connectors/src/connectors/hubspot-oauth/setup.ts
|
|
93870
|
-
var
|
|
93987
|
+
var requestToolName3 = `hubspot-oauth_${requestTool11.name}`;
|
|
93871
93988
|
var hubspotOnboarding = new ConnectorOnboarding({
|
|
93872
93989
|
connectionSetupInstructions: {
|
|
93873
93990
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067HubSpot\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
93874
93991
|
|
|
93875
|
-
1. \`${
|
|
93992
|
+
1. \`${requestToolName3}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
93876
93993
|
- \`method\`: \`"GET"\`
|
|
93877
93994
|
- \`path\`: \`"/account-info/v3/details"\`
|
|
93878
93995
|
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BOAuth\u63A5\u7D9A\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
@@ -93882,7 +93999,7 @@ var hubspotOnboarding = new ConnectorOnboarding({
|
|
|
93882
93999
|
- \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`,
|
|
93883
94000
|
en: `Follow these steps to set up the HubSpot connection.
|
|
93884
94001
|
|
|
93885
|
-
1. Call \`${
|
|
94002
|
+
1. Call \`${requestToolName3}\` to fetch account info:
|
|
93886
94003
|
- \`method\`: \`"GET"\`
|
|
93887
94004
|
- \`path\`: \`"/account-info/v3/details"\`
|
|
93888
94005
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -94156,12 +94273,12 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
94156
94273
|
});
|
|
94157
94274
|
|
|
94158
94275
|
// ../connectors/src/connectors/stripe-oauth/setup.ts
|
|
94159
|
-
var
|
|
94276
|
+
var requestToolName4 = `stripe-oauth_${requestTool12.name}`;
|
|
94160
94277
|
var stripeOnboarding = new ConnectorOnboarding({
|
|
94161
94278
|
connectionSetupInstructions: {
|
|
94162
94279
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Stripe\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
94163
94280
|
|
|
94164
|
-
1. \`${
|
|
94281
|
+
1. \`${requestToolName4}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
94165
94282
|
- \`method\`: \`"GET"\`
|
|
94166
94283
|
- \`path\`: \`"/v1/accounts"\`
|
|
94167
94284
|
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BOAuth\u63A5\u7D9A\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
@@ -94171,7 +94288,7 @@ var stripeOnboarding = new ConnectorOnboarding({
|
|
|
94171
94288
|
- \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`,
|
|
94172
94289
|
en: `Follow these steps to set up the Stripe connection.
|
|
94173
94290
|
|
|
94174
|
-
1. Call \`${
|
|
94291
|
+
1. Call \`${requestToolName4}\` to fetch account info:
|
|
94175
94292
|
- \`method\`: \`"GET"\`
|
|
94176
94293
|
- \`path\`: \`"/v1/accounts"\`
|
|
94177
94294
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -94446,12 +94563,12 @@ Use this tool for all Stripe API interactions: querying charges, customers, invo
|
|
|
94446
94563
|
});
|
|
94447
94564
|
|
|
94448
94565
|
// ../connectors/src/connectors/stripe-api-key/setup.ts
|
|
94449
|
-
var
|
|
94566
|
+
var requestToolName5 = `stripe-api-key_${requestTool13.name}`;
|
|
94450
94567
|
var stripeApiKeyOnboarding = new ConnectorOnboarding({
|
|
94451
94568
|
connectionSetupInstructions: {
|
|
94452
94569
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Stripe\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
94453
94570
|
|
|
94454
|
-
1. \`${
|
|
94571
|
+
1. \`${requestToolName5}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u6B8B\u9AD8\u3092\u53D6\u5F97\u3059\u308B:
|
|
94455
94572
|
- \`method\`: \`"GET"\`
|
|
94456
94573
|
- \`path\`: \`"/v1/balance"\`
|
|
94457
94574
|
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BAPI\u30AD\u30FC\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B\uFF08Secret API Key\u307E\u305F\u306FRestricted API Key\u304C\u6B63\u3057\u304F\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u304B\uFF09
|
|
@@ -94461,7 +94578,7 @@ var stripeApiKeyOnboarding = new ConnectorOnboarding({
|
|
|
94461
94578
|
- \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`,
|
|
94462
94579
|
en: `Follow these steps to set up the Stripe connection.
|
|
94463
94580
|
|
|
94464
|
-
1. Call \`${
|
|
94581
|
+
1. Call \`${requestToolName5}\` to fetch account balance:
|
|
94465
94582
|
- \`method\`: \`"GET"\`
|
|
94466
94583
|
- \`path\`: \`"/v1/balance"\`
|
|
94467
94584
|
2. If an error is returned, ask the user to check the API key settings (verify that the Secret API Key or Restricted API Key is configured correctly)
|
|
@@ -94471,11 +94588,11 @@ var stripeApiKeyOnboarding = new ConnectorOnboarding({
|
|
|
94471
94588
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
94472
94589
|
},
|
|
94473
94590
|
dataOverviewInstructions: {
|
|
94474
|
-
en: `1. Call ${
|
|
94475
|
-
2. Call ${
|
|
94591
|
+
en: `1. Call ${requestToolName5} with GET /v1/customers?limit=5 to explore customers structure
|
|
94592
|
+
2. Call ${requestToolName5} with GET /v1/charges?limit=5 to explore charges structure
|
|
94476
94593
|
3. Explore other endpoints (invoices, subscriptions, products) as needed`,
|
|
94477
|
-
ja: `1. ${
|
|
94478
|
-
2. ${
|
|
94594
|
+
ja: `1. ${requestToolName5} \u3067 GET /v1/customers?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u9867\u5BA2\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
94595
|
+
2. ${requestToolName5} \u3067 GET /v1/charges?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u8AB2\u91D1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
94479
94596
|
3. \u5FC5\u8981\u306B\u5FDC\u3058\u3066\u4ED6\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\uFF08\u8ACB\u6C42\u66F8\u3001\u30B5\u30D6\u30B9\u30AF\u30EA\u30D7\u30B7\u30E7\u30F3\u3001\u5546\u54C1\uFF09\u3092\u63A2\u7D22`
|
|
94480
94597
|
}
|
|
94481
94598
|
});
|
|
@@ -94760,7 +94877,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
94760
94877
|
});
|
|
94761
94878
|
|
|
94762
94879
|
// ../connectors/src/connectors/airtable-oauth/setup.ts
|
|
94763
|
-
var
|
|
94880
|
+
var requestToolName6 = `airtable-oauth_${requestTool14.name}`;
|
|
94764
94881
|
var airtableOauthOnboarding = new ConnectorOnboarding({
|
|
94765
94882
|
connectionSetupInstructions: {
|
|
94766
94883
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Airtable OAuth\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
@@ -94770,7 +94887,7 @@ var airtableOauthOnboarding = new ConnectorOnboarding({
|
|
|
94770
94887
|
3. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
94771
94888
|
- \`parameterSlug\`: \`"base-id"\`
|
|
94772
94889
|
- \`value\`: \u62BD\u51FA\u3057\u305F\u30D9\u30FC\u30B9ID
|
|
94773
|
-
4. \`${
|
|
94890
|
+
4. \`${requestToolName6}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30D9\u30FC\u30B9\u306E\u30C6\u30FC\u30D6\u30EB\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
|
|
94774
94891
|
- \`method\`: \`"GET"\`
|
|
94775
94892
|
- \`path\`: \`"/meta/bases/{baseId}/tables"\`
|
|
94776
94893
|
5. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306B\u30D9\u30FC\u30B9\u306E\u5171\u6709\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
@@ -94785,7 +94902,7 @@ var airtableOauthOnboarding = new ConnectorOnboarding({
|
|
|
94785
94902
|
3. Call \`updateConnectionParameters\`:
|
|
94786
94903
|
- \`parameterSlug\`: \`"base-id"\`
|
|
94787
94904
|
- \`value\`: The extracted base ID
|
|
94788
|
-
4. Call \`${
|
|
94905
|
+
4. Call \`${requestToolName6}\` to fetch the base's table list:
|
|
94789
94906
|
- \`method\`: \`"GET"\`
|
|
94790
94907
|
- \`path\`: \`"/meta/bases/{baseId}/tables"\`
|
|
94791
94908
|
5. If an error is returned, ask the user to check the base sharing settings
|
|
@@ -97687,12 +97804,12 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
97687
97804
|
});
|
|
97688
97805
|
|
|
97689
97806
|
// ../connectors/src/connectors/shopify-oauth/setup.ts
|
|
97690
|
-
var
|
|
97807
|
+
var requestToolName7 = `shopify-oauth_${requestTool22.name}`;
|
|
97691
97808
|
var shopifyOauthOnboarding = new ConnectorOnboarding({
|
|
97692
97809
|
connectionSetupInstructions: {
|
|
97693
97810
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Shopify\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
97694
97811
|
|
|
97695
|
-
1. \`${
|
|
97812
|
+
1. \`${requestToolName7}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30B7\u30E7\u30C3\u30D7\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
97696
97813
|
- \`method\`: \`"GET"\`
|
|
97697
97814
|
- \`path\`: \`"/admin/api/2024-10/shop.json"\`
|
|
97698
97815
|
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BOAuth\u63A5\u7D9A\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
@@ -97702,7 +97819,7 @@ var shopifyOauthOnboarding = new ConnectorOnboarding({
|
|
|
97702
97819
|
- \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`,
|
|
97703
97820
|
en: `Follow these steps to set up the Shopify connection.
|
|
97704
97821
|
|
|
97705
|
-
1. Call \`${
|
|
97822
|
+
1. Call \`${requestToolName7}\` to fetch shop info:
|
|
97706
97823
|
- \`method\`: \`"GET"\`
|
|
97707
97824
|
- \`path\`: \`"/admin/api/2024-10/shop.json"\`
|
|
97708
97825
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -99959,12 +100076,12 @@ Pagination uses cursor-based start_cursor and page_size (max 100).`,
|
|
|
99959
100076
|
});
|
|
99960
100077
|
|
|
99961
100078
|
// ../connectors/src/connectors/notion-oauth/setup.ts
|
|
99962
|
-
var
|
|
100079
|
+
var requestToolName8 = `notion-oauth_${requestTool28.name}`;
|
|
99963
100080
|
var notionOauthOnboarding = new ConnectorOnboarding({
|
|
99964
100081
|
connectionSetupInstructions: {
|
|
99965
100082
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Notion\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
99966
100083
|
|
|
99967
|
-
1. \`${
|
|
100084
|
+
1. \`${requestToolName8}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30DC\u30C3\u30C8\u30E6\u30FC\u30B6\u30FC\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
99968
100085
|
- \`method\`: \`"GET"\`
|
|
99969
100086
|
- \`path\`: \`"/users/me"\`
|
|
99970
100087
|
2. \u30A8\u30E9\u30FC\u304C\u8FD4\u3055\u308C\u305F\u5834\u5408\u3001\u30E6\u30FC\u30B6\u30FC\u306BOAuth\u63A5\u7D9A\u306E\u8A2D\u5B9A\u3092\u78BA\u8A8D\u3059\u308B\u3088\u3046\u4F1D\u3048\u308B
|
|
@@ -99974,7 +100091,7 @@ var notionOauthOnboarding = new ConnectorOnboarding({
|
|
|
99974
100091
|
- \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`,
|
|
99975
100092
|
en: `Follow these steps to set up the Notion connection.
|
|
99976
100093
|
|
|
99977
|
-
1. Call \`${
|
|
100094
|
+
1. Call \`${requestToolName8}\` to fetch bot user info:
|
|
99978
100095
|
- \`method\`: \`"GET"\`
|
|
99979
100096
|
- \`path\`: \`"/users/me"\`
|
|
99980
100097
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -102417,7 +102534,7 @@ export default async function handler(c: Context) {
|
|
|
102417
102534
|
tools: tools49
|
|
102418
102535
|
});
|
|
102419
102536
|
|
|
102420
|
-
// ../connectors/src/connectors/gmail/tools/request.ts
|
|
102537
|
+
// ../connectors/src/connectors/gmail/tools/request-with-delegation.ts
|
|
102421
102538
|
import { z as z63 } from "zod";
|
|
102422
102539
|
|
|
102423
102540
|
// ../connectors/src/connectors/gmail/parameters.ts
|
|
@@ -102425,38 +102542,40 @@ var parameters50 = {
|
|
|
102425
102542
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
102426
102543
|
slug: "service-account-key-json-base64",
|
|
102427
102544
|
name: "Google Cloud Service Account JSON",
|
|
102428
|
-
description: "The service account JSON key
|
|
102545
|
+
description: "The service account JSON key. Domain-wide Delegation must be authorized in the Google Workspace admin console for the Gmail API scope. The user to impersonate is supplied per call as the `subject` argument.",
|
|
102429
102546
|
envVarBaseKey: "GMAIL_SERVICE_ACCOUNT_JSON_BASE64",
|
|
102430
102547
|
type: "base64EncodedJson",
|
|
102431
102548
|
secret: true,
|
|
102432
102549
|
required: true
|
|
102433
102550
|
})
|
|
102434
102551
|
};
|
|
102435
|
-
var delegatedUserEmailParameter = new ParameterDefinition({
|
|
102436
|
-
slug: "delegated-user-email",
|
|
102437
|
-
name: "Delegated User Email",
|
|
102438
|
-
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.",
|
|
102439
|
-
envVarBaseKey: "GMAIL_DELEGATED_USER_EMAIL",
|
|
102440
|
-
type: "text",
|
|
102441
|
-
secret: false,
|
|
102442
|
-
required: false
|
|
102443
|
-
});
|
|
102444
102552
|
|
|
102445
|
-
// ../connectors/src/connectors/gmail/tools/request.ts
|
|
102553
|
+
// ../connectors/src/connectors/gmail/tools/request-with-delegation.ts
|
|
102446
102554
|
var BASE_URL28 = "https://gmail.googleapis.com/gmail/v1/users";
|
|
102447
102555
|
var REQUEST_TIMEOUT_MS46 = 6e4;
|
|
102556
|
+
function decodeServiceAccount3(keyJsonBase64) {
|
|
102557
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
102558
|
+
return JSON.parse(decoded);
|
|
102559
|
+
}
|
|
102448
102560
|
var inputSchema61 = z63.object({
|
|
102449
102561
|
toolUseIntent: z63.string().optional().describe(
|
|
102450
102562
|
"Brief description of what you intend to accomplish with this tool call"
|
|
102451
102563
|
),
|
|
102452
102564
|
connectionId: z63.string().describe("ID of the Gmail service account connection to use"),
|
|
102453
|
-
method: z63.enum(["GET"]).describe("HTTP method
|
|
102565
|
+
method: z63.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
102454
102566
|
path: z63.string().describe(
|
|
102455
|
-
"API path appended to https://gmail.googleapis.com/gmail/v1/users (e.g., '/me/messages', '/me/messages/{id}', '/me/labels'). Use '/me' as the userId."
|
|
102567
|
+
"API path appended to https://gmail.googleapis.com/gmail/v1/users (e.g., '/me/messages', '/me/messages/{id}', '/me/labels'). Use '/me' as the userId \u2014 the impersonated user."
|
|
102568
|
+
),
|
|
102569
|
+
subject: z63.string().describe(
|
|
102570
|
+
"Email of the Workspace user to impersonate via Domain-wide Delegation. The token will be issued as this user."
|
|
102571
|
+
),
|
|
102572
|
+
scopes: z63.array(z63.string()).describe(
|
|
102573
|
+
"OAuth scopes the token must include. This connector currently supports read-only operations only \u2014 pass ['https://www.googleapis.com/auth/gmail.readonly']. Per-endpoint scope reference: https://developers.google.com/gmail/api/auth/scopes"
|
|
102456
102574
|
),
|
|
102457
102575
|
queryParams: z63.record(z63.string(), z63.string()).optional().describe(
|
|
102458
102576
|
"Query parameters to append to the URL (e.g., { q: 'from:example@gmail.com', maxResults: '10' })"
|
|
102459
|
-
)
|
|
102577
|
+
),
|
|
102578
|
+
body: z63.record(z63.string(), z63.unknown()).optional().describe("JSON request body for POST/PUT/PATCH")
|
|
102460
102579
|
});
|
|
102461
102580
|
var outputSchema61 = z63.discriminatedUnion("success", [
|
|
102462
102581
|
z63.object({
|
|
@@ -102466,17 +102585,16 @@ var outputSchema61 = z63.discriminatedUnion("success", [
|
|
|
102466
102585
|
}),
|
|
102467
102586
|
z63.object({
|
|
102468
102587
|
success: z63.literal(false),
|
|
102469
|
-
error: z63.string()
|
|
102588
|
+
error: z63.string(),
|
|
102589
|
+
serviceAccountEmail: z63.string().optional()
|
|
102470
102590
|
})
|
|
102471
102591
|
]);
|
|
102472
|
-
var
|
|
102473
|
-
name: "
|
|
102474
|
-
description: `
|
|
102475
|
-
Authentication is handled automatically using a service account with domain-wide delegation.
|
|
102476
|
-
All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me' as the userId prefix (e.g., '/me/messages').`,
|
|
102592
|
+
var requestWithDelegationTool2 = new ConnectorTool({
|
|
102593
|
+
name: "request_with_delegation",
|
|
102594
|
+
description: "Call the Gmail API on behalf of the specified Workspace user via Domain-wide Delegation. Read-only operations only. Pass `subject` as the target user email and `scopes` as ['https://www.googleapis.com/auth/gmail.readonly']. Paths are relative to https://gmail.googleapis.com/gmail/v1/users \u2014 use '/me' as the userId prefix (e.g., '/me/messages'). Requires Domain-wide Delegation to be authorized for the service account in the Workspace admin console.",
|
|
102477
102595
|
inputSchema: inputSchema61,
|
|
102478
102596
|
outputSchema: outputSchema61,
|
|
102479
|
-
async execute({ connectionId, method, path: path5, queryParams }, connections) {
|
|
102597
|
+
async execute({ connectionId, method, path: path5, subject, scopes, queryParams, body }, connections) {
|
|
102480
102598
|
const connection = connections.find((c6) => c6.id === connectionId);
|
|
102481
102599
|
if (!connection) {
|
|
102482
102600
|
return {
|
|
@@ -102484,28 +102602,37 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102484
102602
|
error: `Connection ${connectionId} not found`
|
|
102485
102603
|
};
|
|
102486
102604
|
}
|
|
102605
|
+
const keyJsonBase64 = parameters50.serviceAccountKeyJsonBase64.getValue(connection);
|
|
102606
|
+
let serviceAccount;
|
|
102607
|
+
try {
|
|
102608
|
+
serviceAccount = decodeServiceAccount3(keyJsonBase64);
|
|
102609
|
+
} catch (err) {
|
|
102610
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
102611
|
+
return {
|
|
102612
|
+
success: false,
|
|
102613
|
+
error: `Failed to decode service account key: ${msg}`
|
|
102614
|
+
};
|
|
102615
|
+
}
|
|
102616
|
+
const serviceAccountEmail = serviceAccount.client_email;
|
|
102487
102617
|
console.log(
|
|
102488
|
-
`[connector-request] gmail/${connection.name}: ${method} ${path5}`
|
|
102618
|
+
`[connector-request] gmail/${connection.name}: ${method} ${path5} subject=${subject}`
|
|
102489
102619
|
);
|
|
102490
102620
|
try {
|
|
102491
102621
|
const { GoogleAuth } = await import("google-auth-library");
|
|
102492
|
-
const keyJsonBase64 = parameters50.serviceAccountKeyJsonBase64.getValue(connection);
|
|
102493
|
-
const delegatedUserEmail = delegatedUserEmailParameter.getValue(connection);
|
|
102494
|
-
const credentials = JSON.parse(
|
|
102495
|
-
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
102496
|
-
);
|
|
102497
102622
|
const auth = new GoogleAuth({
|
|
102498
|
-
credentials
|
|
102499
|
-
|
|
102500
|
-
|
|
102501
|
-
|
|
102502
|
-
|
|
102623
|
+
credentials: {
|
|
102624
|
+
client_email: serviceAccount.client_email,
|
|
102625
|
+
private_key: serviceAccount.private_key
|
|
102626
|
+
},
|
|
102627
|
+
scopes,
|
|
102628
|
+
clientOptions: { subject }
|
|
102503
102629
|
});
|
|
102504
102630
|
const token = await auth.getAccessToken();
|
|
102505
102631
|
if (!token) {
|
|
102506
102632
|
return {
|
|
102507
102633
|
success: false,
|
|
102508
|
-
error: "Failed to obtain access token"
|
|
102634
|
+
error: "Failed to obtain access token",
|
|
102635
|
+
serviceAccountEmail
|
|
102509
102636
|
};
|
|
102510
102637
|
}
|
|
102511
102638
|
let url = `${BASE_URL28}${path5.startsWith("/") ? "" : "/"}${path5}`;
|
|
@@ -102516,18 +102643,25 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102516
102643
|
const controller = new AbortController();
|
|
102517
102644
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS46);
|
|
102518
102645
|
try {
|
|
102646
|
+
const hasBody = body != null && ["POST", "PUT", "PATCH"].includes(method);
|
|
102519
102647
|
const response = await fetch(url, {
|
|
102520
102648
|
method,
|
|
102521
102649
|
headers: {
|
|
102522
102650
|
Authorization: `Bearer ${token}`,
|
|
102523
102651
|
"Content-Type": "application/json"
|
|
102524
102652
|
},
|
|
102653
|
+
body: hasBody ? JSON.stringify(body) : void 0,
|
|
102525
102654
|
signal: controller.signal
|
|
102526
102655
|
});
|
|
102527
|
-
const data = await response.json();
|
|
102656
|
+
const data = await response.json().catch(() => ({}));
|
|
102528
102657
|
if (!response.ok) {
|
|
102529
|
-
const
|
|
102530
|
-
|
|
102658
|
+
const errorObj = data?.error;
|
|
102659
|
+
const errorMessage = errorObj?.message ?? (typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`);
|
|
102660
|
+
return {
|
|
102661
|
+
success: false,
|
|
102662
|
+
error: errorMessage,
|
|
102663
|
+
serviceAccountEmail
|
|
102664
|
+
};
|
|
102531
102665
|
}
|
|
102532
102666
|
return { success: true, status: response.status, data };
|
|
102533
102667
|
} finally {
|
|
@@ -102535,79 +102669,92 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102535
102669
|
}
|
|
102536
102670
|
} catch (err) {
|
|
102537
102671
|
const msg = err instanceof Error ? err.message : String(err);
|
|
102538
|
-
return {
|
|
102672
|
+
return {
|
|
102673
|
+
success: false,
|
|
102674
|
+
error: msg,
|
|
102675
|
+
serviceAccountEmail
|
|
102676
|
+
};
|
|
102539
102677
|
}
|
|
102540
102678
|
}
|
|
102541
102679
|
});
|
|
102542
102680
|
|
|
102543
102681
|
// ../connectors/src/connectors/gmail/setup.ts
|
|
102544
|
-
var
|
|
102682
|
+
var requestWithDelegationToolName2 = `gmail-service-account_${requestWithDelegationTool2.name}`;
|
|
102683
|
+
var READONLY_SCOPES2 = '["https://www.googleapis.com/auth/gmail.readonly"]';
|
|
102545
102684
|
var gmailOnboarding = new ConnectorOnboarding({
|
|
102546
102685
|
connectionSetupInstructions: {
|
|
102547
|
-
ja:
|
|
102686
|
+
ja: `Gmail\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\u3044\u307E\u3059\u3002\u30A2\u30AF\u30BB\u30B9\u5BFE\u8C61\u306E Workspace \u30E6\u30FC\u30B6\u30FC\u3092\u30E6\u30FC\u30B6\u30FC\u304B\u3089\u805E\u304D\u3001Project Knowledge \u306B\u8A18\u9332\u3057\u307E\u3059\u3002
|
|
102548
102687
|
|
|
102549
|
-
1. \`askUserQuestion\` \u3067\
|
|
102688
|
+
1. \`askUserQuestion\` \u3067\u5BFE\u8C61\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u805E\u304F:
|
|
102550
102689
|
- \`type\`: \`"freeText"\`
|
|
102551
|
-
- \`question\`: \u300CGmail\u3092\u53C2\u7167\u3059\
|
|
102552
|
-
- \`placeholder\`: \`"
|
|
102553
|
-
|
|
102554
|
-
|
|
102555
|
-
- \`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
|
|
102556
|
-
3. \`${requestToolName8}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\u3059\u308B:
|
|
102690
|
+
- \`question\`: \u300CGmail \u3092\u53C2\u7167\u3059\u308B Google Workspace \u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u53EF\u3001\u30AB\u30F3\u30DE\u533A\u5207\u308A\uFF09\u300D
|
|
102691
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
102692
|
+
|
|
102693
|
+
2. \u30E6\u30FC\u30B6\u30FC\u304B\u3089\u53D7\u3051\u53D6\u3063\u305F\u6587\u5B57\u5217\u304B\u3089\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u62BD\u51FA\u3059\u308B\u3002\u5404 \`<email>\` \u306B\u3064\u3044\u3066 \`${requestWithDelegationToolName2}\` \u3092\u4EE5\u4E0B\u306E\u5F15\u6570\u3067\u547C\u3073\u3001Domain-wide Delegation \u7D4C\u7531\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u304B\u3092\u78BA\u8A8D\u3059\u308B:
|
|
102557
102694
|
- \`method\`: \`"GET"\`
|
|
102558
102695
|
- \`path\`: \`"/me/profile"\`
|
|
102559
|
-
|
|
102560
|
-
-
|
|
102561
|
-
|
|
102562
|
-
|
|
102563
|
-
|
|
102564
|
-
-
|
|
102565
|
-
-
|
|
102696
|
+
- \`subject\`: \`<email>\`
|
|
102697
|
+
- \`scopes\`: \`${READONLY_SCOPES2}\`
|
|
102698
|
+
|
|
102699
|
+
3. \u5931\u6557\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304C\u3042\u308C\u3070\u3001\u30A8\u30E9\u30FC\u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`serviceAccountEmail\` \u30D5\u30A3\u30FC\u30EB\u30C9\u304B\u3089\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u53D6\u308A\u51FA\u3057\u3001\`askUserQuestion\` \u3067\u6B21\u306E\u9078\u629E\u80A2\u3092\u63D0\u793A\u3059\u308B\u3002\`question\` \u306B\u306F\u6B21\u306E\u6848\u5185\u6587\u3092\u542B\u3081\u308B: \u300C\u6B21\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u306B\u30A2\u30AF\u30BB\u30B9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F: {\u5931\u6557\u30A2\u30C9\u30EC\u30B9\u4E00\u89A7}\u3002\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8 \`<serviceAccountEmail>\` \u306E Domain-wide Delegation \u304C Workspace \u7BA1\u7406\u30B3\u30F3\u30BD\u30FC\u30EB\u3067\u627F\u8A8D\u3055\u308C\u3066\u3044\u308B\u304B\u78BA\u8A8D\u3057\u3066\u304F\u3060\u3055\u3044\uFF08[\u8A2D\u5B9A\u30AC\u30A4\u30C9](https://support.google.com/a/answer/162106)\uFF09\u300D\u3002
|
|
102700
|
+
- \`options\`: \`[{ label: "\u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u3092\u627F\u8A8D\u3057\u305F\u306E\u3067\u30EA\u30C8\u30E9\u30A4", value: "retry" }, { label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u76F4\u3059", value: "restart" }]\`
|
|
102701
|
+
- \u300C\u30EA\u30C8\u30E9\u30A4\u300D: \u76F4\u524D\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u30EA\u30B9\u30C8\u3067\u30B9\u30C6\u30C3\u30D7 2 \u3092\u518D\u5B9F\u884C
|
|
102702
|
+
- \u300C\u5165\u529B\u3057\u76F4\u3059\u300D: \u30B9\u30C6\u30C3\u30D7 1 \u304B\u3089\u518D\u5B9F\u884C
|
|
102703
|
+
|
|
102704
|
+
4. \u5168\u30A2\u30C9\u30EC\u30B9\u304C\u6210\u529F\u3057\u305F\u3089 \`finalizeSetup\` \u3092\u547C\u3076\u3002\`projectKnowledge\` \u306E \`#### \u30B9\u30B3\u30FC\u30D7\` \u7BC0\u306B\u5404\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092 1 \u884C\u305A\u3064\u5217\u6319\u3059\u308B:
|
|
102705
|
+
- \`- subject: alice@example.com\`
|
|
102706
|
+
- \`- subject: bob@example.com\`
|
|
102566
102707
|
|
|
102567
102708
|
#### \u5236\u7D04
|
|
102568
|
-
-
|
|
102569
|
-
- \u30C4\u30FC\u30EB\u9593\
|
|
102570
|
-
en: `
|
|
102709
|
+
- \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\u8A31\u53EF\u3055\u308C\u3066\u3044\u308B\u306E\u306F\u30B9\u30C6\u30C3\u30D7 2 \u306E \`/me/profile\` \u78BA\u8A8D\u306E\u307F
|
|
102710
|
+
- \u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057\u306E\u9593\u306F 1 \u6587\u3060\u3051\u66F8\u3044\u3066\u5373\u6B21\u306E\u30C4\u30FC\u30EB\u547C\u3073\u51FA\u3057`,
|
|
102711
|
+
en: `Set up the Gmail (Service Account) connection. Ask the user which Workspace users to access, verify each via Domain-wide Delegation, and record them in Project Knowledge.
|
|
102571
102712
|
|
|
102572
|
-
1. Call \`askUserQuestion\` to
|
|
102713
|
+
1. Call \`askUserQuestion\` to collect target emails:
|
|
102573
102714
|
- \`type\`: \`"freeText"\`
|
|
102574
|
-
- \`question\`: "
|
|
102575
|
-
- \`placeholder\`: \`"
|
|
102576
|
-
|
|
102577
|
-
|
|
102578
|
-
- \`options\`: \`[{ value: <entered email>, label: <same value> }]\` (a single option is auto-selected)
|
|
102579
|
-
3. Call \`${requestToolName8}\` to get the user's profile:
|
|
102715
|
+
- \`question\`: "Enter the Google Workspace user email(s) whose Gmail mailbox you want to access (comma-separated for multiple)"
|
|
102716
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
102717
|
+
|
|
102718
|
+
2. Extract individual emails from the response. For each \`<email>\`, verify Domain-wide Delegation access by calling \`${requestWithDelegationToolName2}\`:
|
|
102580
102719
|
- \`method\`: \`"GET"\`
|
|
102581
102720
|
- \`path\`: \`"/me/profile"\`
|
|
102582
|
-
|
|
102583
|
-
-
|
|
102584
|
-
|
|
102585
|
-
|
|
102586
|
-
|
|
102587
|
-
-
|
|
102588
|
-
-
|
|
102721
|
+
- \`subject\`: \`<email>\`
|
|
102722
|
+
- \`scopes\`: \`${READONLY_SCOPES2}\`
|
|
102723
|
+
|
|
102724
|
+
3. For any failed email, take \`serviceAccountEmail\` from the error response and call \`askUserQuestion\`. Include this guidance in \`question\`: "Could not access Gmail for {failed emails}. Verify Domain-wide Delegation for service account \`<serviceAccountEmail>\` in the Workspace admin console ([setup guide](https://support.google.com/a/answer/162106))".
|
|
102725
|
+
- \`options\`: \`[{ label: "Authorized Domain-wide Delegation \u2014 retry", value: "retry" }, { label: "Re-enter the email addresses", value: "restart" }]\`
|
|
102726
|
+
- On "retry" \u2192 re-run step 2 with the previously entered email list
|
|
102727
|
+
- On "Re-enter" \u2192 re-run step 1
|
|
102728
|
+
|
|
102729
|
+
4. Once every email succeeds, call \`finalizeSetup\`. Under \`#### \u30B9\u30B3\u30FC\u30D7\` in \`projectKnowledge\`, list each email on its own line:
|
|
102730
|
+
- \`- subject: alice@example.com\`
|
|
102731
|
+
- \`- subject: bob@example.com\`
|
|
102589
102732
|
|
|
102590
102733
|
#### Constraints
|
|
102591
|
-
-
|
|
102592
|
-
- Write
|
|
102734
|
+
- Do NOT read message bodies during setup. Only the \`/me/profile\` verification is permitted
|
|
102735
|
+
- Write at most 1 sentence between tool calls`
|
|
102593
102736
|
},
|
|
102594
102737
|
dataOverviewInstructions: {
|
|
102595
|
-
en: `
|
|
102596
|
-
|
|
102597
|
-
|
|
102598
|
-
|
|
102599
|
-
|
|
102600
|
-
|
|
102738
|
+
en: `Pick ONE email from \`#### \u30B9\u30B3\u30FC\u30D7\` (a \`- subject: <email>\` line) and use it as \`subject\` for every call below. Pass \`scopes: ${READONLY_SCOPES2}\` every time.
|
|
102739
|
+
|
|
102740
|
+
1. \`method=GET\`, \`path=/me/labels\` to list labels.
|
|
102741
|
+
2. \`method=GET\`, \`path=/me/messages?maxResults=5\` to fetch recent message IDs.
|
|
102742
|
+
3. For each message id, \`method=GET\`, \`path=/me/messages/{id}?format=metadata\`.`,
|
|
102743
|
+
ja: `\`#### \u30B9\u30B3\u30FC\u30D7\` \u306E \`- subject: <email>\` \u884C\u304B\u3089 1 \u3064\u9078\u3073\u3001\u4EE5\u4E0B\u306E\u30B9\u30C6\u30C3\u30D7\u3067 \`subject\` \u5F15\u6570\u3068\u3057\u3066\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002\`scopes\` \u306F\u6BCE\u56DE \`${READONLY_SCOPES2}\` \u3092\u6E21\u3057\u307E\u3059\u3002
|
|
102744
|
+
|
|
102745
|
+
1. \`method=GET\`\u3001\`path=/me/labels\` \u3067\u30E9\u30D9\u30EB\u4E00\u89A7\u3092\u53D6\u5F97
|
|
102746
|
+
2. \`method=GET\`\u3001\`path=/me/messages?maxResults=5\` \u3067\u6700\u8FD1\u306E\u30E1\u30C3\u30BB\u30FC\u30B8 ID \u3092\u53D6\u5F97
|
|
102747
|
+
3. \u5404\u30E1\u30C3\u30BB\u30FC\u30B8 ID \u306B\u3064\u3044\u3066 \`method=GET\`\u3001\`path=/me/messages/{id}?format=metadata\``
|
|
102601
102748
|
}
|
|
102602
102749
|
});
|
|
102603
102750
|
|
|
102604
102751
|
// ../connectors/src/connectors/gmail/index.ts
|
|
102605
|
-
var tools50 = {
|
|
102752
|
+
var tools50 = { request_with_delegation: requestWithDelegationTool2 };
|
|
102606
102753
|
var gmailConnector = new ConnectorPlugin({
|
|
102607
102754
|
slug: "gmail",
|
|
102608
102755
|
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
102609
102756
|
name: "Gmail",
|
|
102610
|
-
description: "Connect to Gmail for email data access using a service account with domain-wide delegation.
|
|
102757
|
+
description: "Connect to Gmail for email data access using a service account with domain-wide delegation. Currently read-only (messages, threads, labels).",
|
|
102611
102758
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4V3rfaSc1ksFIt2eHBNIwJ/7f3be41a154a6d96dcf229ed0e5858c9/Gmail_icon__2020_.svg.png",
|
|
102612
102759
|
parameters: parameters50,
|
|
102613
102760
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
@@ -102615,12 +102762,22 @@ var gmailConnector = new ConnectorPlugin({
|
|
|
102615
102762
|
systemPrompt: {
|
|
102616
102763
|
en: `### Tools
|
|
102617
102764
|
|
|
102618
|
-
- \`gmail-service-
|
|
102765
|
+
- \`gmail-service-account_request_with_delegation\`: Call the Gmail API on behalf of the specified Workspace user via Domain-wide Delegation. Pass \`subject\` as the target user email; the token will be issued as that user. The set of users this connection works with is recorded in the project knowledge under "#### \u30B9\u30B3\u30FC\u30D7" as \`- subject: <email>\` lines \u2014 read those and pick a subject before calling. Always pass \`scopes\`.
|
|
102766
|
+
|
|
102767
|
+
### OAuth Scopes (pass as \`scopes\` argument)
|
|
102768
|
+
|
|
102769
|
+
This connector is currently read-only. Pass:
|
|
102770
|
+
|
|
102771
|
+
- \`https://www.googleapis.com/auth/gmail.readonly\` \u2014 read-only access (profile, labels, messages, threads)
|
|
102772
|
+
|
|
102773
|
+
The Workspace admin must have authorized this scope for the service account in the Domain-wide Delegation settings, otherwise token issuance will fail with \`unauthorized_client\`.
|
|
102774
|
+
|
|
102775
|
+
Per-endpoint scope reference: https://developers.google.com/gmail/api/auth/scopes
|
|
102619
102776
|
|
|
102620
102777
|
### Gmail API Reference
|
|
102621
102778
|
|
|
102622
102779
|
#### Available Endpoints
|
|
102623
|
-
- GET \`/me/profile\` \u2014 Get the
|
|
102780
|
+
- GET \`/me/profile\` \u2014 Get the impersonated user's profile (email address, total messages/threads)
|
|
102624
102781
|
- GET \`/me/labels\` \u2014 List all labels in the mailbox
|
|
102625
102782
|
- GET \`/me/labels/{id}\` \u2014 Get details for a specific label
|
|
102626
102783
|
- GET \`/me/messages\` \u2014 List messages (returns IDs only; use format param on individual messages)
|
|
@@ -102645,7 +102802,7 @@ var gmailConnector = new ConnectorPlugin({
|
|
|
102645
102802
|
- \`raw\` \u2014 Full RFC 2822 formatted message in base64url
|
|
102646
102803
|
|
|
102647
102804
|
#### Tips
|
|
102648
|
-
- Always use \`/me\` as the userId \u2014 it refers to the
|
|
102805
|
+
- Always use \`/me\` as the userId in the path \u2014 it refers to the user you passed as \`subject\`
|
|
102649
102806
|
- List endpoints return only IDs; fetch individual resources for details
|
|
102650
102807
|
- Use \`format=metadata\` to efficiently get subject/sender without full body
|
|
102651
102808
|
- Message body content is base64url encoded in \`payload.body.data\` or nested \`payload.parts[].body.data\`
|
|
@@ -102656,6 +102813,12 @@ var gmailConnector = new ConnectorPlugin({
|
|
|
102656
102813
|
|
|
102657
102814
|
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.
|
|
102658
102815
|
|
|
102816
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
102817
|
+
|
|
102818
|
+
- \`client.requestWithDelegation(path, { subject, scopes, init? })\` \u2014 call the Gmail API as the impersonated Workspace user via Domain-wide Delegation. Pass the minimum scopes required by the endpoint.
|
|
102819
|
+
|
|
102820
|
+
The method returns a standard \`Response\`. Read the body with \`.json()\`. Same path conventions as the tool.
|
|
102821
|
+
|
|
102659
102822
|
#### Example
|
|
102660
102823
|
|
|
102661
102824
|
\`\`\`ts
|
|
@@ -102663,37 +102826,51 @@ import { connection } from "@squadbase/vite-server/connectors/gmail";
|
|
|
102663
102826
|
|
|
102664
102827
|
const gmail = connection("<connectionId>");
|
|
102665
102828
|
|
|
102666
|
-
//
|
|
102667
|
-
const
|
|
102829
|
+
// Pick the impersonated user from project knowledge ("#### \u30B9\u30B3\u30FC\u30D7").
|
|
102830
|
+
const subject = "alice@example.com";
|
|
102831
|
+
const READ = ["https://www.googleapis.com/auth/gmail.readonly"];
|
|
102832
|
+
|
|
102833
|
+
const profileRes = await gmail.requestWithDelegation("/me/profile", {
|
|
102834
|
+
subject,
|
|
102835
|
+
scopes: READ,
|
|
102836
|
+
});
|
|
102837
|
+
const profile = await profileRes.json();
|
|
102668
102838
|
console.log(profile.emailAddress, profile.messagesTotal);
|
|
102669
102839
|
|
|
102670
|
-
|
|
102671
|
-
|
|
102672
|
-
|
|
102673
|
-
|
|
102674
|
-
|
|
102675
|
-
|
|
102840
|
+
const messagesRes = await gmail.requestWithDelegation(
|
|
102841
|
+
"/me/messages?maxResults=10",
|
|
102842
|
+
{ subject, scopes: READ },
|
|
102843
|
+
);
|
|
102844
|
+
const messages = await messagesRes.json();
|
|
102845
|
+
|
|
102846
|
+
for (const msg of messages.messages ?? []) {
|
|
102847
|
+
const detailRes = await gmail.requestWithDelegation(
|
|
102848
|
+
\`/me/messages/\${msg.id}?format=metadata\`,
|
|
102849
|
+
{ subject, scopes: READ },
|
|
102850
|
+
);
|
|
102851
|
+
const detail = await detailRes.json();
|
|
102852
|
+
const subjectHeader = detail.payload.headers.find(h => h.name === "Subject")?.value;
|
|
102853
|
+
console.log(subjectHeader, detail.snippet);
|
|
102676
102854
|
}
|
|
102855
|
+
\`\`\``,
|
|
102856
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
102677
102857
|
|
|
102678
|
-
|
|
102679
|
-
const results = await gmail.listMessages({ q: "from:boss@company.com is:unread" });
|
|
102858
|
+
- \`gmail-service-account_request_with_delegation\`: \u6307\u5B9A\u3055\u308C\u305F Workspace \u30E6\u30FC\u30B6\u30FC\u306B\u4EE3\u308F\u3063\u3066 Domain-wide Delegation \u7D4C\u7531\u3067 Gmail API \u3092\u547C\u3073\u51FA\u3057\u307E\u3059\u3002\u4EE3\u7406\u5BFE\u8C61\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092 \`subject\` \u3068\u3057\u3066\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u30C8\u30FC\u30AF\u30F3\u306F\u305D\u306E\u30E6\u30FC\u30B6\u30FC\u3068\u3057\u3066\u767A\u884C\u3055\u308C\u307E\u3059\u3002\u3053\u306E\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u304C\u5BFE\u8C61\u3068\u3059\u308B\u30E6\u30FC\u30B6\u30FC\u306F Project Knowledge \u306E "#### \u30B9\u30B3\u30FC\u30D7" \u306B \`- subject: <email>\` \u5F62\u5F0F\u3067\u8A18\u9332\u3055\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u547C\u3073\u51FA\u3057\u524D\u306B\u305D\u3053\u3092\u8AAD\u3093\u3067 subject \u3092\u6C7A\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002\`scopes\` \u3082\u6BCE\u56DE\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
102680
102859
|
|
|
102681
|
-
|
|
102682
|
-
const labels = await gmail.listLabels();
|
|
102683
|
-
labels.labels.forEach(l => console.log(l.name, l.messagesTotal));
|
|
102860
|
+
### OAuth \u30B9\u30B3\u30FC\u30D7 (\`scopes\` \u5F15\u6570\u3067\u6E21\u3059)
|
|
102684
102861
|
|
|
102685
|
-
|
|
102686
|
-
|
|
102687
|
-
|
|
102688
|
-
|
|
102689
|
-
|
|
102862
|
+
\u3053\u306E\u30B3\u30CD\u30AF\u30BF\u30FC\u306F\u73FE\u72B6\u8AAD\u307F\u53D6\u308A\u5C02\u7528\u3067\u3059\u3002\u6B21\u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044:
|
|
102863
|
+
|
|
102864
|
+
- \`https://www.googleapis.com/auth/gmail.readonly\` \u2014 \u8AAD\u307F\u53D6\u308A\uFF08\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3001\u30E9\u30D9\u30EB\u3001\u30E1\u30C3\u30BB\u30FC\u30B8\u3001\u30B9\u30EC\u30C3\u30C9\uFF09
|
|
102865
|
+
|
|
102866
|
+
\u8981\u6C42\u3059\u308B scope \u306F Workspace \u7BA1\u7406\u8005\u304C Domain-wide Delegation \u8A2D\u5B9A\u3067\u5F53\u8A72 Service Account \u306B\u5BFE\u3057\u3066\u627F\u8A8D\u3057\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u3002\u627F\u8A8D\u3055\u308C\u3066\u3044\u306A\u3044\u5834\u5408\u30C8\u30FC\u30AF\u30F3\u767A\u884C\u304C \`unauthorized_client\` \u3067\u5931\u6557\u3057\u307E\u3059\u3002
|
|
102690
102867
|
|
|
102691
|
-
|
|
102868
|
+
\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u5225\u306E\u6B63\u78BA\u306A scope \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9: https://developers.google.com/gmail/api/auth/scopes
|
|
102692
102869
|
|
|
102693
102870
|
### Gmail API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
102694
102871
|
|
|
102695
102872
|
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
102696
|
-
- GET \`/me/profile\` \u2014 \
|
|
102873
|
+
- GET \`/me/profile\` \u2014 \u4EE3\u7406\u5BFE\u8C61\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\uFF08\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3001\u30E1\u30C3\u30BB\u30FC\u30B8/\u30B9\u30EC\u30C3\u30C9\u7DCF\u6570\uFF09
|
|
102697
102874
|
- GET \`/me/labels\` \u2014 \u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u306E\u5168\u30E9\u30D9\u30EB\u3092\u4E00\u89A7
|
|
102698
102875
|
- GET \`/me/labels/{id}\` \u2014 \u7279\u5B9A\u30E9\u30D9\u30EB\u306E\u8A73\u7D30\u3092\u53D6\u5F97
|
|
102699
102876
|
- GET \`/me/messages\` \u2014 \u30E1\u30C3\u30BB\u30FC\u30B8\u4E00\u89A7\uFF08ID\u306E\u307F\u8FD4\u5374\u3002\u500B\u5225\u30E1\u30C3\u30BB\u30FC\u30B8\u3067format\u30D1\u30E9\u30E1\u30FC\u30BF\u3092\u4F7F\u7528\uFF09
|
|
@@ -102718,7 +102895,7 @@ thread.messages.forEach(m => console.log(m.snippet));
|
|
|
102718
102895
|
- \`raw\` \u2014 base64url\u30A8\u30F3\u30B3\u30FC\u30C9\u3055\u308C\u305F\u5B8C\u5168\u306ARFC 2822\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u30E1\u30C3\u30BB\u30FC\u30B8
|
|
102719
102896
|
|
|
102720
102897
|
#### \u30D2\u30F3\u30C8
|
|
102721
|
-
- userId\u306B\u306F\u5E38\u306B \`/me\` \u3092\u4F7F\u7528 \u2014 \
|
|
102898
|
+
- \u30D1\u30B9\u306E userId \u306B\u306F\u5E38\u306B \`/me\` \u3092\u4F7F\u7528 \u2014 \`subject\` \u306B\u6E21\u3057\u305F\u30E6\u30FC\u30B6\u30FC\u3092\u6307\u3057\u307E\u3059
|
|
102722
102899
|
- \u4E00\u89A7\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306FID\u306E\u307F\u8FD4\u5374\u3057\u307E\u3059\u3002\u8A73\u7D30\u306F\u500B\u5225\u30EA\u30BD\u30FC\u30B9\u3092\u53D6\u5F97\u3057\u3066\u304F\u3060\u3055\u3044
|
|
102723
102900
|
- \u4EF6\u540D/\u9001\u4FE1\u8005\u3092\u52B9\u7387\u7684\u306B\u53D6\u5F97\u3059\u308B\u306B\u306F \`format=metadata\` \u3092\u4F7F\u7528\u3057\u307E\u3059
|
|
102724
102901
|
- \u30E1\u30C3\u30BB\u30FC\u30B8\u672C\u6587\u306F \`payload.body.data\` \u307E\u305F\u306F\u30CD\u30B9\u30C8\u3055\u308C\u305F \`payload.parts[].body.data\` \u306Bbase64url\u30A8\u30F3\u30B3\u30FC\u30C9\u3067\u683C\u7D0D\u3055\u308C\u3066\u3044\u307E\u3059
|
|
@@ -102729,6 +102906,12 @@ thread.messages.forEach(m => console.log(m.snippet));
|
|
|
102729
102906
|
|
|
102730
102907
|
\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
|
|
102731
102908
|
|
|
102909
|
+
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
102910
|
+
|
|
102911
|
+
- \`client.requestWithDelegation(path, { subject, scopes, init? })\` \u2014 Domain-wide Delegation \u3067\u6307\u5B9A Workspace \u30E6\u30FC\u30B6\u30FC\u306B\u4EE3\u308F\u3063\u3066 Gmail API \u3092\u547C\u3076\u3002\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\u306B\u5FC5\u8981\u306A\u6700\u5C0F scope \u3092\u6E21\u3059\u3002
|
|
102912
|
+
|
|
102913
|
+
\u30E1\u30BD\u30C3\u30C9\u306F\u6A19\u6E96\u306E \`Response\` \u3092\u8FD4\u3057\u307E\u3059\u3002\`response.json()\` \u3067\u30DC\u30C7\u30A3\u3092\u53D6\u5F97\u3057\u3066\u304F\u3060\u3055\u3044\u3002\u30D1\u30B9\u306E\u66F8\u304D\u65B9\u306F\u30C4\u30FC\u30EB\u3068\u540C\u3058\u3002
|
|
102914
|
+
|
|
102732
102915
|
#### Example
|
|
102733
102916
|
|
|
102734
102917
|
\`\`\`ts
|
|
@@ -102736,86 +102919,35 @@ import { connection } from "@squadbase/vite-server/connectors/gmail";
|
|
|
102736
102919
|
|
|
102737
102920
|
const gmail = connection("<connectionId>");
|
|
102738
102921
|
|
|
102739
|
-
//
|
|
102740
|
-
const
|
|
102741
|
-
|
|
102922
|
+
// \u4EE3\u7406\u5BFE\u8C61\u30E6\u30FC\u30B6\u30FC\u306F Project Knowledge ("#### \u30B9\u30B3\u30FC\u30D7") \u304B\u3089\u9078\u3076
|
|
102923
|
+
const subject = "alice@example.com";
|
|
102924
|
+
const READ = ["https://www.googleapis.com/auth/gmail.readonly"];
|
|
102742
102925
|
|
|
102743
|
-
|
|
102744
|
-
|
|
102745
|
-
|
|
102746
|
-
|
|
102747
|
-
|
|
102748
|
-
|
|
102749
|
-
}
|
|
102750
|
-
|
|
102751
|
-
// Search messages
|
|
102752
|
-
const results = await gmail.listMessages({ q: "from:boss@company.com is:unread" });
|
|
102926
|
+
const profileRes = await gmail.requestWithDelegation("/me/profile", {
|
|
102927
|
+
subject,
|
|
102928
|
+
scopes: READ,
|
|
102929
|
+
});
|
|
102930
|
+
const profile = await profileRes.json();
|
|
102931
|
+
console.log(profile.emailAddress, profile.messagesTotal);
|
|
102753
102932
|
|
|
102754
|
-
|
|
102755
|
-
|
|
102756
|
-
|
|
102933
|
+
const messagesRes = await gmail.requestWithDelegation(
|
|
102934
|
+
"/me/messages?maxResults=10",
|
|
102935
|
+
{ subject, scopes: READ },
|
|
102936
|
+
);
|
|
102937
|
+
const messages = await messagesRes.json();
|
|
102757
102938
|
|
|
102758
|
-
|
|
102759
|
-
const
|
|
102760
|
-
|
|
102939
|
+
for (const msg of messages.messages ?? []) {
|
|
102940
|
+
const detailRes = await gmail.requestWithDelegation(
|
|
102941
|
+
\`/me/messages/\${msg.id}?format=metadata\`,
|
|
102942
|
+
{ subject, scopes: READ },
|
|
102943
|
+
);
|
|
102944
|
+
const detail = await detailRes.json();
|
|
102945
|
+
const subjectHeader = detail.payload.headers.find(h => h.name === "Subject")?.value;
|
|
102946
|
+
console.log(subjectHeader, detail.snippet);
|
|
102947
|
+
}
|
|
102761
102948
|
\`\`\``
|
|
102762
102949
|
},
|
|
102763
|
-
tools: tools50
|
|
102764
|
-
async checkConnection(params, _config) {
|
|
102765
|
-
const { GoogleAuth } = await import("google-auth-library");
|
|
102766
|
-
const credentials = JSON.parse(
|
|
102767
|
-
Buffer.from(
|
|
102768
|
-
params[parameters50.serviceAccountKeyJsonBase64.slug],
|
|
102769
|
-
"base64"
|
|
102770
|
-
).toString("utf-8")
|
|
102771
|
-
);
|
|
102772
|
-
const delegatedUserEmail = params[delegatedUserEmailParameter.slug];
|
|
102773
|
-
if (!delegatedUserEmail) {
|
|
102774
|
-
if (!credentials.client_email || !credentials.private_key) {
|
|
102775
|
-
return {
|
|
102776
|
-
success: false,
|
|
102777
|
-
error: "Service account JSON must contain client_email and private_key"
|
|
102778
|
-
};
|
|
102779
|
-
}
|
|
102780
|
-
return { success: true };
|
|
102781
|
-
}
|
|
102782
|
-
const auth = new GoogleAuth({
|
|
102783
|
-
credentials,
|
|
102784
|
-
scopes: ["https://www.googleapis.com/auth/gmail.readonly"],
|
|
102785
|
-
clientOptions: {
|
|
102786
|
-
subject: delegatedUserEmail
|
|
102787
|
-
}
|
|
102788
|
-
});
|
|
102789
|
-
try {
|
|
102790
|
-
const token = await auth.getAccessToken();
|
|
102791
|
-
if (!token) {
|
|
102792
|
-
return {
|
|
102793
|
-
success: false,
|
|
102794
|
-
error: "Failed to obtain access token"
|
|
102795
|
-
};
|
|
102796
|
-
}
|
|
102797
|
-
const res = await fetch(
|
|
102798
|
-
"https://gmail.googleapis.com/gmail/v1/users/me/profile",
|
|
102799
|
-
{
|
|
102800
|
-
method: "GET",
|
|
102801
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
102802
|
-
}
|
|
102803
|
-
);
|
|
102804
|
-
if (!res.ok) {
|
|
102805
|
-
const errorText = await res.text().catch(() => res.statusText);
|
|
102806
|
-
return {
|
|
102807
|
-
success: false,
|
|
102808
|
-
error: `Gmail API failed: HTTP ${res.status} ${errorText}`
|
|
102809
|
-
};
|
|
102810
|
-
}
|
|
102811
|
-
return { success: true };
|
|
102812
|
-
} catch (error2) {
|
|
102813
|
-
return {
|
|
102814
|
-
success: false,
|
|
102815
|
-
error: error2 instanceof Error ? error2.message : String(error2)
|
|
102816
|
-
};
|
|
102817
|
-
}
|
|
102818
|
-
}
|
|
102950
|
+
tools: tools50
|
|
102819
102951
|
});
|
|
102820
102952
|
|
|
102821
102953
|
// ../connectors/src/connectors/gmail-oauth/tools/request.ts
|
|
@@ -102877,7 +103009,7 @@ var outputSchema62 = z64.discriminatedUnion("success", [
|
|
|
102877
103009
|
error: z64.string()
|
|
102878
103010
|
})
|
|
102879
103011
|
]);
|
|
102880
|
-
var
|
|
103012
|
+
var requestTool35 = new ConnectorTool({
|
|
102881
103013
|
name: "request",
|
|
102882
103014
|
description: `Send authenticated GET requests to the Gmail API v1.
|
|
102883
103015
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -102935,7 +103067,7 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102935
103067
|
});
|
|
102936
103068
|
|
|
102937
103069
|
// ../connectors/src/connectors/gmail-oauth/setup.ts
|
|
102938
|
-
var requestToolName9 = `gmail-oauth_${
|
|
103070
|
+
var requestToolName9 = `gmail-oauth_${requestTool35.name}`;
|
|
102939
103071
|
var gmailOnboarding2 = new ConnectorOnboarding({
|
|
102940
103072
|
connectionSetupInstructions: {
|
|
102941
103073
|
ja: `\u4EE5\u4E0B\u306E\u624B\u9806\u3067Gmail\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306E\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002
|
|
@@ -102979,7 +103111,7 @@ var gmailOnboarding2 = new ConnectorOnboarding({
|
|
|
102979
103111
|
var parameters51 = {};
|
|
102980
103112
|
|
|
102981
103113
|
// ../connectors/src/connectors/gmail-oauth/index.ts
|
|
102982
|
-
var tools51 = { request:
|
|
103114
|
+
var tools51 = { request: requestTool35 };
|
|
102983
103115
|
var gmailOauthConnector = new ConnectorPlugin({
|
|
102984
103116
|
slug: "gmail",
|
|
102985
103117
|
authType: AUTH_TYPES.OAUTH,
|
|
@@ -103414,7 +103546,7 @@ var outputSchema64 = z66.discriminatedUnion("success", [
|
|
|
103414
103546
|
error: z66.string()
|
|
103415
103547
|
})
|
|
103416
103548
|
]);
|
|
103417
|
-
var
|
|
103549
|
+
var requestTool36 = new ConnectorTool({
|
|
103418
103550
|
name: "request",
|
|
103419
103551
|
description: `Send authenticated requests to the LinkedIn Marketing API (REST).
|
|
103420
103552
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -103490,7 +103622,7 @@ Required headers (LinkedIn-Version, X-Restli-Protocol-Version) are set automatic
|
|
|
103490
103622
|
|
|
103491
103623
|
// ../connectors/src/connectors/linkedin-ads/index.ts
|
|
103492
103624
|
var tools52 = {
|
|
103493
|
-
request:
|
|
103625
|
+
request: requestTool36,
|
|
103494
103626
|
listAdAccounts: listAdAccountsTool3
|
|
103495
103627
|
};
|
|
103496
103628
|
var linkedinAdsConnector = new ConnectorPlugin({
|
|
@@ -103799,7 +103931,7 @@ var outputSchema65 = z67.discriminatedUnion("success", [
|
|
|
103799
103931
|
error: z67.string()
|
|
103800
103932
|
})
|
|
103801
103933
|
]);
|
|
103802
|
-
var
|
|
103934
|
+
var requestTool37 = new ConnectorTool({
|
|
103803
103935
|
name: "request",
|
|
103804
103936
|
description: `Send authenticated requests to the Zendesk Support API.
|
|
103805
103937
|
Authentication is handled automatically using email/token Basic auth.
|
|
@@ -103855,7 +103987,7 @@ Zendesk uses cursor-based pagination with page[size] and page[after] parameters.
|
|
|
103855
103987
|
});
|
|
103856
103988
|
|
|
103857
103989
|
// ../connectors/src/connectors/zendesk/index.ts
|
|
103858
|
-
var tools53 = { request:
|
|
103990
|
+
var tools53 = { request: requestTool37 };
|
|
103859
103991
|
var zendeskConnector = new ConnectorPlugin({
|
|
103860
103992
|
slug: "zendesk",
|
|
103861
103993
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -104099,7 +104231,7 @@ var outputSchema66 = z68.discriminatedUnion("success", [
|
|
|
104099
104231
|
error: z68.string()
|
|
104100
104232
|
})
|
|
104101
104233
|
]);
|
|
104102
|
-
var
|
|
104234
|
+
var requestTool38 = new ConnectorTool({
|
|
104103
104235
|
name: "request",
|
|
104104
104236
|
description: `Send authenticated requests to the Zendesk Support API.
|
|
104105
104237
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -104160,7 +104292,7 @@ Zendesk uses cursor-based pagination with page[size] and page[after] parameters.
|
|
|
104160
104292
|
});
|
|
104161
104293
|
|
|
104162
104294
|
// ../connectors/src/connectors/zendesk-oauth/setup.ts
|
|
104163
|
-
var requestToolName10 = `zendesk-oauth_${
|
|
104295
|
+
var requestToolName10 = `zendesk-oauth_${requestTool38.name}`;
|
|
104164
104296
|
var zendeskOauthOnboarding = new ConnectorOnboarding({
|
|
104165
104297
|
connectionSetupInstructions: {
|
|
104166
104298
|
en: `Follow these steps to set up the Zendesk connection.
|
|
@@ -104200,7 +104332,7 @@ var zendeskOauthOnboarding = new ConnectorOnboarding({
|
|
|
104200
104332
|
var parameters54 = {};
|
|
104201
104333
|
|
|
104202
104334
|
// ../connectors/src/connectors/zendesk-oauth/index.ts
|
|
104203
|
-
var tools54 = { request:
|
|
104335
|
+
var tools54 = { request: requestTool38 };
|
|
104204
104336
|
var zendeskOauthConnector = new ConnectorPlugin({
|
|
104205
104337
|
slug: "zendesk",
|
|
104206
104338
|
authType: AUTH_TYPES.OAUTH,
|
|
@@ -104416,7 +104548,7 @@ var outputSchema67 = z69.discriminatedUnion("success", [
|
|
|
104416
104548
|
error: z69.string()
|
|
104417
104549
|
})
|
|
104418
104550
|
]);
|
|
104419
|
-
var
|
|
104551
|
+
var requestTool39 = new ConnectorTool({
|
|
104420
104552
|
name: "request",
|
|
104421
104553
|
description: `Send authenticated requests to the Intercom API.
|
|
104422
104554
|
Authentication is handled automatically using the Access Token (Bearer token).
|
|
@@ -104472,7 +104604,7 @@ The Intercom-Version header is set to 2.11 automatically.`,
|
|
|
104472
104604
|
});
|
|
104473
104605
|
|
|
104474
104606
|
// ../connectors/src/connectors/intercom/index.ts
|
|
104475
|
-
var tools55 = { request:
|
|
104607
|
+
var tools55 = { request: requestTool39 };
|
|
104476
104608
|
var intercomConnector = new ConnectorPlugin({
|
|
104477
104609
|
slug: "intercom",
|
|
104478
104610
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -104737,7 +104869,7 @@ var outputSchema68 = z70.discriminatedUnion("success", [
|
|
|
104737
104869
|
error: z70.string()
|
|
104738
104870
|
})
|
|
104739
104871
|
]);
|
|
104740
|
-
var
|
|
104872
|
+
var requestTool40 = new ConnectorTool({
|
|
104741
104873
|
name: "request",
|
|
104742
104874
|
description: `Send authenticated requests to the Intercom API.
|
|
104743
104875
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -104800,7 +104932,7 @@ Search endpoints (contacts/search, conversations/search) use POST with a query o
|
|
|
104800
104932
|
});
|
|
104801
104933
|
|
|
104802
104934
|
// ../connectors/src/connectors/intercom-oauth/setup.ts
|
|
104803
|
-
var requestToolName11 = `intercom-oauth_${
|
|
104935
|
+
var requestToolName11 = `intercom-oauth_${requestTool40.name}`;
|
|
104804
104936
|
var intercomOauthOnboarding = new ConnectorOnboarding({
|
|
104805
104937
|
connectionSetupInstructions: {
|
|
104806
104938
|
en: `Follow these steps to set up the Intercom connection.
|
|
@@ -104840,7 +104972,7 @@ var intercomOauthOnboarding = new ConnectorOnboarding({
|
|
|
104840
104972
|
var parameters56 = {};
|
|
104841
104973
|
|
|
104842
104974
|
// ../connectors/src/connectors/intercom-oauth/index.ts
|
|
104843
|
-
var tools56 = { request:
|
|
104975
|
+
var tools56 = { request: requestTool40 };
|
|
104844
104976
|
var intercomOauthConnector = new ConnectorPlugin({
|
|
104845
104977
|
slug: "intercom",
|
|
104846
104978
|
authType: AUTH_TYPES.OAUTH,
|
|
@@ -105092,7 +105224,7 @@ var outputSchema69 = z71.discriminatedUnion("success", [
|
|
|
105092
105224
|
error: z71.string()
|
|
105093
105225
|
})
|
|
105094
105226
|
]);
|
|
105095
|
-
var
|
|
105227
|
+
var requestTool41 = new ConnectorTool({
|
|
105096
105228
|
name: "request",
|
|
105097
105229
|
description: `Send authenticated requests to the Mixpanel REST API.
|
|
105098
105230
|
Authentication is handled automatically using Basic auth (Service Account username + secret).
|
|
@@ -105186,7 +105318,7 @@ Rate limit: 60 queries/hour, 5 concurrent queries for Query API.`,
|
|
|
105186
105318
|
});
|
|
105187
105319
|
|
|
105188
105320
|
// ../connectors/src/connectors/mixpanel/index.ts
|
|
105189
|
-
var tools57 = { request:
|
|
105321
|
+
var tools57 = { request: requestTool41 };
|
|
105190
105322
|
var mixpanelConnector = new ConnectorPlugin({
|
|
105191
105323
|
slug: "mixpanel",
|
|
105192
105324
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -105380,7 +105512,7 @@ var outputSchema70 = z72.discriminatedUnion("success", [
|
|
|
105380
105512
|
error: z72.string()
|
|
105381
105513
|
})
|
|
105382
105514
|
]);
|
|
105383
|
-
var
|
|
105515
|
+
var requestTool42 = new ConnectorTool({
|
|
105384
105516
|
name: "request",
|
|
105385
105517
|
description: `Send authenticated requests to the Grafana HTTP API.
|
|
105386
105518
|
Authentication is handled automatically using the configured API Key or Service Account Token via Bearer token.
|
|
@@ -105436,7 +105568,7 @@ The path must start with '/' and is appended to the configured Grafana instance
|
|
|
105436
105568
|
});
|
|
105437
105569
|
|
|
105438
105570
|
// ../connectors/src/connectors/grafana/index.ts
|
|
105439
|
-
var tools58 = { request:
|
|
105571
|
+
var tools58 = { request: requestTool42 };
|
|
105440
105572
|
var grafanaConnector = new ConnectorPlugin({
|
|
105441
105573
|
slug: "grafana",
|
|
105442
105574
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -105624,7 +105756,7 @@ var outputSchema71 = z73.discriminatedUnion("success", [
|
|
|
105624
105756
|
error: z73.string()
|
|
105625
105757
|
})
|
|
105626
105758
|
]);
|
|
105627
|
-
var
|
|
105759
|
+
var requestTool43 = new ConnectorTool({
|
|
105628
105760
|
name: "request",
|
|
105629
105761
|
description: `Send authenticated requests to the Backlog REST API (v2).
|
|
105630
105762
|
Authentication is handled automatically by appending the apiKey query parameter to every request.
|
|
@@ -105681,7 +105813,7 @@ Do NOT include the apiKey parameter yourself; it is injected automatically.`,
|
|
|
105681
105813
|
});
|
|
105682
105814
|
|
|
105683
105815
|
// ../connectors/src/connectors/backlog/index.ts
|
|
105684
|
-
var tools59 = { request:
|
|
105816
|
+
var tools59 = { request: requestTool43 };
|
|
105685
105817
|
var backlogConnector = new ConnectorPlugin({
|
|
105686
105818
|
slug: "backlog",
|
|
105687
105819
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -105891,7 +106023,7 @@ var outputSchema72 = z74.discriminatedUnion("success", [
|
|
|
105891
106023
|
error: z74.string()
|
|
105892
106024
|
})
|
|
105893
106025
|
]);
|
|
105894
|
-
var
|
|
106026
|
+
var requestTool44 = new ConnectorTool({
|
|
105895
106027
|
name: "request",
|
|
105896
106028
|
description: `Send authenticated requests to the Gamma REST API.
|
|
105897
106029
|
Authentication is handled automatically using the API Key (X-API-KEY header).
|
|
@@ -106119,7 +106251,7 @@ Gamma does NOT support image uploads. To visualize data, embed raw numbers direc
|
|
|
106119
106251
|
});
|
|
106120
106252
|
|
|
106121
106253
|
// ../connectors/src/connectors/gamma/index.ts
|
|
106122
|
-
var tools60 = { request:
|
|
106254
|
+
var tools60 = { request: requestTool44, generate: generateTool };
|
|
106123
106255
|
var gammaConnector = new ConnectorPlugin({
|
|
106124
106256
|
slug: "gamma",
|
|
106125
106257
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -106342,7 +106474,7 @@ var outputSchema74 = z76.discriminatedUnion("success", [
|
|
|
106342
106474
|
error: z76.string()
|
|
106343
106475
|
})
|
|
106344
106476
|
]);
|
|
106345
|
-
var
|
|
106477
|
+
var requestTool45 = new ConnectorTool({
|
|
106346
106478
|
name: "request",
|
|
106347
106479
|
description: `Send authenticated requests to the Sentry API.
|
|
106348
106480
|
Supports GET, POST, PUT, and DELETE methods.
|
|
@@ -106399,7 +106531,7 @@ Authentication is handled automatically via Bearer token.
|
|
|
106399
106531
|
});
|
|
106400
106532
|
|
|
106401
106533
|
// ../connectors/src/connectors/sentry/index.ts
|
|
106402
|
-
var tools61 = { request:
|
|
106534
|
+
var tools61 = { request: requestTool45 };
|
|
106403
106535
|
var sentryConnector = new ConnectorPlugin({
|
|
106404
106536
|
slug: "sentry",
|
|
106405
106537
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -106688,7 +106820,7 @@ function normalizeInstanceUrl(raw) {
|
|
|
106688
106820
|
}
|
|
106689
106821
|
return trimmed;
|
|
106690
106822
|
}
|
|
106691
|
-
var
|
|
106823
|
+
var requestTool46 = new ConnectorTool({
|
|
106692
106824
|
name: "request",
|
|
106693
106825
|
description: `Send authenticated requests to the Salesforce REST API.
|
|
106694
106826
|
Authentication is handled automatically using the OAuth 2.0 Client Credentials Flow (External Client App or Connected App Consumer Key + Secret). An access token is obtained on each request, so the tool user only provides the API path.
|
|
@@ -106785,7 +106917,7 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
|
|
|
106785
106917
|
});
|
|
106786
106918
|
|
|
106787
106919
|
// ../connectors/src/connectors/salesforce/index.ts
|
|
106788
|
-
var tools62 = { request:
|
|
106920
|
+
var tools62 = { request: requestTool46 };
|
|
106789
106921
|
var salesforceConnector = new ConnectorPlugin({
|
|
106790
106922
|
slug: "salesforce",
|
|
106791
106923
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -107072,7 +107204,7 @@ var outputSchema76 = z78.discriminatedUnion("success", [
|
|
|
107072
107204
|
error: z78.string()
|
|
107073
107205
|
})
|
|
107074
107206
|
]);
|
|
107075
|
-
var
|
|
107207
|
+
var requestTool47 = new ConnectorTool({
|
|
107076
107208
|
name: "request",
|
|
107077
107209
|
description: `Send authenticated requests to the InfluxDB HTTP API.
|
|
107078
107210
|
Authentication is handled automatically using the API token (\`Authorization: Token {token}\`). The instance URL is resolved from the connection.
|
|
@@ -107150,7 +107282,7 @@ For read-only data exploration prefer SQL (InfluxDB 3) or InfluxQL queries \u201
|
|
|
107150
107282
|
});
|
|
107151
107283
|
|
|
107152
107284
|
// ../connectors/src/connectors/influxdb/index.ts
|
|
107153
|
-
var tools63 = { request:
|
|
107285
|
+
var tools63 = { request: requestTool47 };
|
|
107154
107286
|
var influxdbConnector = new ConnectorPlugin({
|
|
107155
107287
|
slug: "influxdb",
|
|
107156
107288
|
authType: AUTH_TYPES.API_KEY,
|