@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/main.js
CHANGED
|
@@ -2805,22 +2805,22 @@ var require_nacl_fast = __commonJS({
|
|
|
2805
2805
|
randombytes = fn;
|
|
2806
2806
|
};
|
|
2807
2807
|
(function() {
|
|
2808
|
-
var
|
|
2809
|
-
if (
|
|
2808
|
+
var crypto8 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
2809
|
+
if (crypto8 && crypto8.getRandomValues) {
|
|
2810
2810
|
var QUOTA = 65536;
|
|
2811
2811
|
nacl.setPRNG(function(x6, n6) {
|
|
2812
2812
|
var i6, v7 = new Uint8Array(n6);
|
|
2813
2813
|
for (i6 = 0; i6 < n6; i6 += QUOTA) {
|
|
2814
|
-
|
|
2814
|
+
crypto8.getRandomValues(v7.subarray(i6, i6 + Math.min(n6 - i6, QUOTA)));
|
|
2815
2815
|
}
|
|
2816
2816
|
for (i6 = 0; i6 < n6; i6++) x6[i6] = v7[i6];
|
|
2817
2817
|
cleanup(v7);
|
|
2818
2818
|
});
|
|
2819
2819
|
} else if (typeof __require !== "undefined") {
|
|
2820
|
-
|
|
2821
|
-
if (
|
|
2820
|
+
crypto8 = __require("crypto");
|
|
2821
|
+
if (crypto8 && crypto8.randomBytes) {
|
|
2822
2822
|
nacl.setPRNG(function(x6, n6) {
|
|
2823
|
-
var i6, v7 =
|
|
2823
|
+
var i6, v7 = crypto8.randomBytes(n6);
|
|
2824
2824
|
for (i6 = 0; i6 < n6; i6++) x6[i6] = v7[i6];
|
|
2825
2825
|
cleanup(v7);
|
|
2826
2826
|
});
|
|
@@ -4117,7 +4117,7 @@ var require_lib2 = __commonJS({
|
|
|
4117
4117
|
var require_constants = __commonJS({
|
|
4118
4118
|
"../../node_modules/ssh2/lib/protocol/constants.js"(exports2, module) {
|
|
4119
4119
|
"use strict";
|
|
4120
|
-
var
|
|
4120
|
+
var crypto8 = __require("crypto");
|
|
4121
4121
|
var cpuInfo;
|
|
4122
4122
|
try {
|
|
4123
4123
|
cpuInfo = require_lib2()();
|
|
@@ -4125,21 +4125,21 @@ var require_constants = __commonJS({
|
|
|
4125
4125
|
}
|
|
4126
4126
|
var { bindingAvailable, CIPHER_INFO, MAC_INFO } = require_crypto();
|
|
4127
4127
|
var eddsaSupported = (() => {
|
|
4128
|
-
if (typeof
|
|
4128
|
+
if (typeof crypto8.sign === "function" && typeof crypto8.verify === "function") {
|
|
4129
4129
|
const key = "-----BEGIN PRIVATE KEY-----\r\nMC4CAQAwBQYDK2VwBCIEIHKj+sVa9WcD/q2DJUJaf43Kptc8xYuUQA4bOFj9vC8T\r\n-----END PRIVATE KEY-----";
|
|
4130
4130
|
const data = Buffer.from("a");
|
|
4131
4131
|
let sig;
|
|
4132
4132
|
let verified;
|
|
4133
4133
|
try {
|
|
4134
|
-
sig =
|
|
4135
|
-
verified =
|
|
4134
|
+
sig = crypto8.sign(null, data, key);
|
|
4135
|
+
verified = crypto8.verify(null, data, key, sig);
|
|
4136
4136
|
} catch {
|
|
4137
4137
|
}
|
|
4138
4138
|
return Buffer.isBuffer(sig) && sig.length === 64 && verified === true;
|
|
4139
4139
|
}
|
|
4140
4140
|
return false;
|
|
4141
4141
|
})();
|
|
4142
|
-
var curve25519Supported = typeof
|
|
4142
|
+
var curve25519Supported = typeof crypto8.diffieHellman === "function" && typeof crypto8.generateKeyPairSync === "function" && typeof crypto8.createPublicKey === "function";
|
|
4143
4143
|
var DEFAULT_KEX = [
|
|
4144
4144
|
// https://tools.ietf.org/html/rfc5656#section-10.1
|
|
4145
4145
|
"ecdh-sha2-nistp256",
|
|
@@ -4182,7 +4182,7 @@ var require_constants = __commonJS({
|
|
|
4182
4182
|
"ssh-dss"
|
|
4183
4183
|
]);
|
|
4184
4184
|
var canUseCipher = (() => {
|
|
4185
|
-
const ciphers =
|
|
4185
|
+
const ciphers = crypto8.getCiphers();
|
|
4186
4186
|
return (name) => ciphers.includes(CIPHER_INFO[name].sslName);
|
|
4187
4187
|
})();
|
|
4188
4188
|
var DEFAULT_CIPHER = [
|
|
@@ -4220,7 +4220,7 @@ var require_constants = __commonJS({
|
|
|
4220
4220
|
"arcfour"
|
|
4221
4221
|
].filter(canUseCipher));
|
|
4222
4222
|
var canUseMAC = (() => {
|
|
4223
|
-
const hashes =
|
|
4223
|
+
const hashes = crypto8.getHashes();
|
|
4224
4224
|
return (name) => hashes.includes(MAC_INFO[name].sslName);
|
|
4225
4225
|
})();
|
|
4226
4226
|
var DEFAULT_MAC = [
|
|
@@ -4826,7 +4826,7 @@ var require_utils = __commonJS({
|
|
|
4826
4826
|
var sshcrypto_default;
|
|
4827
4827
|
var init_sshcrypto = __esm({
|
|
4828
4828
|
"../../node_modules/ssh2/lib/protocol/crypto/build/Release/sshcrypto.node"() {
|
|
4829
|
-
sshcrypto_default = "./sshcrypto-
|
|
4829
|
+
sshcrypto_default = "./sshcrypto-P3UBA7BP.node";
|
|
4830
4830
|
}
|
|
4831
4831
|
});
|
|
4832
4832
|
|
|
@@ -6604,7 +6604,7 @@ var require_keyParser = __commonJS({
|
|
|
6604
6604
|
createECDH,
|
|
6605
6605
|
createHash: createHash4,
|
|
6606
6606
|
createHmac: createHmac2,
|
|
6607
|
-
createSign
|
|
6607
|
+
createSign,
|
|
6608
6608
|
createVerify,
|
|
6609
6609
|
getCiphers,
|
|
6610
6610
|
sign: sign_,
|
|
@@ -6905,7 +6905,7 @@ ${formatted}-----END ${type} KEY-----`;
|
|
|
6905
6905
|
return new Error("No private key available");
|
|
6906
6906
|
if (!algo || typeof algo !== "string")
|
|
6907
6907
|
algo = this[SYM_HASH_ALGO];
|
|
6908
|
-
const signature =
|
|
6908
|
+
const signature = createSign(algo);
|
|
6909
6909
|
signature.update(data);
|
|
6910
6910
|
try {
|
|
6911
6911
|
return signature.sign(pem);
|
|
@@ -20414,8 +20414,8 @@ var require_bson = __commonJS({
|
|
|
20414
20414
|
return crypto.getRandomValues(nodeJsByteUtils.allocate(byteLength));
|
|
20415
20415
|
}
|
|
20416
20416
|
var nodejsRandomBytes = (() => {
|
|
20417
|
-
const { crypto:
|
|
20418
|
-
if (
|
|
20417
|
+
const { crypto: crypto8 } = globalThis;
|
|
20418
|
+
if (crypto8 != null && typeof crypto8.getRandomValues === "function") {
|
|
20419
20419
|
return nodejsSecureRandomBytes;
|
|
20420
20420
|
} else {
|
|
20421
20421
|
return nodejsMathRandomBytes;
|
|
@@ -20520,10 +20520,10 @@ var require_bson = __commonJS({
|
|
|
20520
20520
|
return webByteUtils.fromNumberArray(Array.from({ length: byteLength }, () => Math.floor(Math.random() * 256)));
|
|
20521
20521
|
}
|
|
20522
20522
|
var webRandomBytes = (() => {
|
|
20523
|
-
const { crypto:
|
|
20524
|
-
if (
|
|
20523
|
+
const { crypto: crypto8 } = globalThis;
|
|
20524
|
+
if (crypto8 != null && typeof crypto8.getRandomValues === "function") {
|
|
20525
20525
|
return (byteLength) => {
|
|
20526
|
-
return
|
|
20526
|
+
return crypto8.getRandomValues(webByteUtils.allocate(byteLength));
|
|
20527
20527
|
};
|
|
20528
20528
|
} else {
|
|
20529
20529
|
if (isReactNative()) {
|
|
@@ -27025,7 +27025,7 @@ var require_utils3 = __commonJS({
|
|
|
27025
27025
|
exports2.decorateDecryptionResult = decorateDecryptionResult;
|
|
27026
27026
|
exports2.addAbortListener = addAbortListener;
|
|
27027
27027
|
exports2.abortable = abortable;
|
|
27028
|
-
var
|
|
27028
|
+
var crypto8 = __require("crypto");
|
|
27029
27029
|
var fs_1 = __require("fs");
|
|
27030
27030
|
var http2 = __require("http");
|
|
27031
27031
|
var process2 = __require("process");
|
|
@@ -27185,7 +27185,7 @@ var require_utils3 = __commonJS({
|
|
|
27185
27185
|
}
|
|
27186
27186
|
}
|
|
27187
27187
|
function uuidV4() {
|
|
27188
|
-
const result =
|
|
27188
|
+
const result = crypto8.randomBytes(16);
|
|
27189
27189
|
result[6] = result[6] & 15 | 64;
|
|
27190
27190
|
result[8] = result[8] & 63 | 128;
|
|
27191
27191
|
return result;
|
|
@@ -27737,7 +27737,7 @@ var require_utils3 = __commonJS({
|
|
|
27737
27737
|
}
|
|
27738
27738
|
var randomBytes = (size) => {
|
|
27739
27739
|
return new Promise((resolve, reject) => {
|
|
27740
|
-
|
|
27740
|
+
crypto8.randomBytes(size, (error2, buf) => {
|
|
27741
27741
|
if (error2)
|
|
27742
27742
|
return reject(error2);
|
|
27743
27743
|
resolve(buf);
|
|
@@ -39490,12 +39490,12 @@ var init_date_utils = __esm({
|
|
|
39490
39490
|
});
|
|
39491
39491
|
|
|
39492
39492
|
// ../../node_modules/@smithy/uuid/dist-es/randomUUID.js
|
|
39493
|
-
import
|
|
39493
|
+
import crypto3 from "crypto";
|
|
39494
39494
|
var randomUUID;
|
|
39495
39495
|
var init_randomUUID = __esm({
|
|
39496
39496
|
"../../node_modules/@smithy/uuid/dist-es/randomUUID.js"() {
|
|
39497
39497
|
"use strict";
|
|
39498
|
-
randomUUID =
|
|
39498
|
+
randomUUID = crypto3.randomUUID.bind(crypto3);
|
|
39499
39499
|
}
|
|
39500
39500
|
});
|
|
39501
39501
|
|
|
@@ -61429,10 +61429,10 @@ var require_retry = __commonJS({
|
|
|
61429
61429
|
});
|
|
61430
61430
|
|
|
61431
61431
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/rng.js
|
|
61432
|
-
import
|
|
61432
|
+
import crypto4 from "crypto";
|
|
61433
61433
|
function rng() {
|
|
61434
61434
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
61435
|
-
|
|
61435
|
+
crypto4.randomFillSync(rnds8Pool);
|
|
61436
61436
|
poolPtr = 0;
|
|
61437
61437
|
}
|
|
61438
61438
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
@@ -61643,14 +61643,14 @@ var init_v35 = __esm({
|
|
|
61643
61643
|
});
|
|
61644
61644
|
|
|
61645
61645
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/md5.js
|
|
61646
|
-
import
|
|
61646
|
+
import crypto5 from "crypto";
|
|
61647
61647
|
function md5(bytes) {
|
|
61648
61648
|
if (Array.isArray(bytes)) {
|
|
61649
61649
|
bytes = Buffer.from(bytes);
|
|
61650
61650
|
} else if (typeof bytes === "string") {
|
|
61651
61651
|
bytes = Buffer.from(bytes, "utf8");
|
|
61652
61652
|
}
|
|
61653
|
-
return
|
|
61653
|
+
return crypto5.createHash("md5").update(bytes).digest();
|
|
61654
61654
|
}
|
|
61655
61655
|
var md5_default;
|
|
61656
61656
|
var init_md5 = __esm({
|
|
@@ -61673,13 +61673,13 @@ var init_v3 = __esm({
|
|
|
61673
61673
|
});
|
|
61674
61674
|
|
|
61675
61675
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/native.js
|
|
61676
|
-
import
|
|
61676
|
+
import crypto6 from "crypto";
|
|
61677
61677
|
var native_default;
|
|
61678
61678
|
var init_native = __esm({
|
|
61679
61679
|
"../../node_modules/gaxios/node_modules/uuid/dist/esm-node/native.js"() {
|
|
61680
61680
|
"use strict";
|
|
61681
61681
|
native_default = {
|
|
61682
|
-
randomUUID:
|
|
61682
|
+
randomUUID: crypto6.randomUUID
|
|
61683
61683
|
};
|
|
61684
61684
|
}
|
|
61685
61685
|
});
|
|
@@ -61714,14 +61714,14 @@ var init_v42 = __esm({
|
|
|
61714
61714
|
});
|
|
61715
61715
|
|
|
61716
61716
|
// ../../node_modules/gaxios/node_modules/uuid/dist/esm-node/sha1.js
|
|
61717
|
-
import
|
|
61717
|
+
import crypto7 from "crypto";
|
|
61718
61718
|
function sha1(bytes) {
|
|
61719
61719
|
if (Array.isArray(bytes)) {
|
|
61720
61720
|
bytes = Buffer.from(bytes);
|
|
61721
61721
|
} else if (typeof bytes === "string") {
|
|
61722
61722
|
bytes = Buffer.from(bytes, "utf8");
|
|
61723
61723
|
}
|
|
61724
|
-
return
|
|
61724
|
+
return crypto7.createHash("sha1").update(bytes).digest();
|
|
61725
61725
|
}
|
|
61726
61726
|
var sha1_default;
|
|
61727
61727
|
var init_sha1 = __esm({
|
|
@@ -82405,7 +82405,7 @@ var require_scram = __commonJS({
|
|
|
82405
82405
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
82406
82406
|
exports2.ScramSHA256 = exports2.ScramSHA1 = void 0;
|
|
82407
82407
|
var saslprep_1 = require_node2();
|
|
82408
|
-
var
|
|
82408
|
+
var crypto8 = __require("crypto");
|
|
82409
82409
|
var bson_1 = require_bson2();
|
|
82410
82410
|
var error_1 = require_error();
|
|
82411
82411
|
var utils_1 = require_utils3();
|
|
@@ -82558,9 +82558,9 @@ var require_scram = __commonJS({
|
|
|
82558
82558
|
}
|
|
82559
82559
|
let md52;
|
|
82560
82560
|
try {
|
|
82561
|
-
md52 =
|
|
82561
|
+
md52 = crypto8.createHash("md5");
|
|
82562
82562
|
} catch (err) {
|
|
82563
|
-
if (
|
|
82563
|
+
if (crypto8.getFips()) {
|
|
82564
82564
|
throw new Error("Auth mechanism SCRAM-SHA-1 is not supported in FIPS mode");
|
|
82565
82565
|
}
|
|
82566
82566
|
throw err;
|
|
@@ -82583,10 +82583,10 @@ var require_scram = __commonJS({
|
|
|
82583
82583
|
return Buffer.from(res).toString("base64");
|
|
82584
82584
|
}
|
|
82585
82585
|
function H2(method, text) {
|
|
82586
|
-
return
|
|
82586
|
+
return crypto8.createHash(method).update(text).digest();
|
|
82587
82587
|
}
|
|
82588
82588
|
function HMAC(method, key, text) {
|
|
82589
|
-
return
|
|
82589
|
+
return crypto8.createHmac(method, key).update(text).digest();
|
|
82590
82590
|
}
|
|
82591
82591
|
var _hiCache = {};
|
|
82592
82592
|
var _hiCacheCount = 0;
|
|
@@ -82603,7 +82603,7 @@ var require_scram = __commonJS({
|
|
|
82603
82603
|
if (_hiCache[key] != null) {
|
|
82604
82604
|
return _hiCache[key];
|
|
82605
82605
|
}
|
|
82606
|
-
const saltedData =
|
|
82606
|
+
const saltedData = crypto8.pbkdf2Sync(data, salt, iterations, hiLengthMap[cryptoMethod], cryptoMethod);
|
|
82607
82607
|
if (_hiCacheCount >= 200) {
|
|
82608
82608
|
_hiCachePurge();
|
|
82609
82609
|
}
|
|
@@ -82615,8 +82615,8 @@ var require_scram = __commonJS({
|
|
|
82615
82615
|
if (lhs.length !== rhs.length) {
|
|
82616
82616
|
return false;
|
|
82617
82617
|
}
|
|
82618
|
-
if (typeof
|
|
82619
|
-
return
|
|
82618
|
+
if (typeof crypto8.timingSafeEqual === "function") {
|
|
82619
|
+
return crypto8.timingSafeEqual(lhs, rhs);
|
|
82620
82620
|
}
|
|
82621
82621
|
let result = 0;
|
|
82622
82622
|
for (let i6 = 0; i6 < lhs.length; i6++) {
|
|
@@ -91267,8 +91267,7 @@ const realtime = await ga.runRealtimeReport({
|
|
|
91267
91267
|
}
|
|
91268
91268
|
});
|
|
91269
91269
|
|
|
91270
|
-
// ../connectors/src/connectors/google-calendar/tools/
|
|
91271
|
-
import * as crypto3 from "crypto";
|
|
91270
|
+
// ../connectors/src/connectors/google-calendar/tools/request.ts
|
|
91272
91271
|
import { z as z21 } from "zod";
|
|
91273
91272
|
|
|
91274
91273
|
// ../connectors/src/connectors/google-calendar/parameters.ts
|
|
@@ -91276,121 +91275,54 @@ var parameters14 = {
|
|
|
91276
91275
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
91277
91276
|
slug: "service-account-key-json-base64",
|
|
91278
91277
|
name: "Google Cloud Service Account JSON",
|
|
91279
|
-
description: "The service account JSON key
|
|
91278
|
+
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.",
|
|
91280
91279
|
envVarBaseKey: "GOOGLE_CALENDAR_SERVICE_ACCOUNT_JSON_BASE64",
|
|
91281
91280
|
type: "base64EncodedJson",
|
|
91282
91281
|
secret: true,
|
|
91283
91282
|
required: true
|
|
91284
91283
|
})
|
|
91285
91284
|
};
|
|
91286
|
-
|
|
91287
|
-
|
|
91288
|
-
name: "User Email Address(es)",
|
|
91289
|
-
description: "The email address(es) of the Google Workspace user(s) whose calendar is accessed via Domain-wide Delegation. Collected during the setup flow.",
|
|
91290
|
-
envVarBaseKey: "GOOGLE_CALENDAR_IMPERSONATE_EMAIL",
|
|
91291
|
-
type: "text",
|
|
91292
|
-
secret: false,
|
|
91293
|
-
required: false
|
|
91294
|
-
});
|
|
91295
|
-
var calendarIdParameter = new ParameterDefinition({
|
|
91296
|
-
slug: "calendar-id",
|
|
91297
|
-
name: "Default Calendar ID",
|
|
91298
|
-
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.",
|
|
91299
|
-
envVarBaseKey: "GOOGLE_CALENDAR_CALENDAR_ID",
|
|
91300
|
-
type: "text",
|
|
91301
|
-
secret: false,
|
|
91302
|
-
required: false
|
|
91303
|
-
});
|
|
91304
|
-
|
|
91305
|
-
// ../connectors/src/connectors/google-calendar/tools/list-calendars.ts
|
|
91306
|
-
var TOKEN_URL = "https://oauth2.googleapis.com/token";
|
|
91285
|
+
|
|
91286
|
+
// ../connectors/src/connectors/google-calendar/tools/request.ts
|
|
91307
91287
|
var BASE_URL6 = "https://www.googleapis.com/calendar/v3";
|
|
91308
|
-
var SCOPE = "https://www.googleapis.com/auth/calendar.readonly https://www.googleapis.com/auth/calendar.events.readonly";
|
|
91309
91288
|
var REQUEST_TIMEOUT_MS11 = 6e4;
|
|
91310
|
-
function
|
|
91311
|
-
const
|
|
91312
|
-
return
|
|
91313
|
-
}
|
|
91314
|
-
function buildJwt(clientEmail, privateKey, nowSec, subject) {
|
|
91315
|
-
const header = base64url(JSON.stringify({ alg: "RS256", typ: "JWT" }));
|
|
91316
|
-
const payload = base64url(
|
|
91317
|
-
JSON.stringify({
|
|
91318
|
-
iss: clientEmail,
|
|
91319
|
-
sub: subject,
|
|
91320
|
-
scope: SCOPE,
|
|
91321
|
-
aud: TOKEN_URL,
|
|
91322
|
-
iat: nowSec,
|
|
91323
|
-
exp: nowSec + 3600
|
|
91324
|
-
})
|
|
91325
|
-
);
|
|
91326
|
-
const signingInput = `${header}.${payload}`;
|
|
91327
|
-
const sign2 = crypto3.createSign("RSA-SHA256");
|
|
91328
|
-
sign2.update(signingInput);
|
|
91329
|
-
sign2.end();
|
|
91330
|
-
const signature = base64url(sign2.sign(privateKey));
|
|
91331
|
-
return `${signingInput}.${signature}`;
|
|
91332
|
-
}
|
|
91333
|
-
async function getAccessToken(serviceAccount, subject) {
|
|
91334
|
-
const nowSec = Math.floor(Date.now() / 1e3);
|
|
91335
|
-
const jwt = buildJwt(
|
|
91336
|
-
serviceAccount.client_email,
|
|
91337
|
-
serviceAccount.private_key,
|
|
91338
|
-
nowSec,
|
|
91339
|
-
subject
|
|
91340
|
-
);
|
|
91341
|
-
const response = await fetch(TOKEN_URL, {
|
|
91342
|
-
method: "POST",
|
|
91343
|
-
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
91344
|
-
body: new URLSearchParams({
|
|
91345
|
-
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
|
|
91346
|
-
assertion: jwt
|
|
91347
|
-
})
|
|
91348
|
-
});
|
|
91349
|
-
if (!response.ok) {
|
|
91350
|
-
const text = await response.text();
|
|
91351
|
-
throw new Error(
|
|
91352
|
-
`token exchange failed for ${subject} (${response.status}): ${text}`
|
|
91353
|
-
);
|
|
91354
|
-
}
|
|
91355
|
-
const data = await response.json();
|
|
91356
|
-
return data.access_token;
|
|
91289
|
+
function decodeServiceAccount(keyJsonBase64) {
|
|
91290
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
91291
|
+
return JSON.parse(decoded);
|
|
91357
91292
|
}
|
|
91358
91293
|
var inputSchema21 = z21.object({
|
|
91359
91294
|
toolUseIntent: z21.string().optional().describe(
|
|
91360
91295
|
"Brief description of what you intend to accomplish with this tool call"
|
|
91361
91296
|
),
|
|
91362
|
-
connectionId: z21.string().describe("ID of the Google Calendar connection to use")
|
|
91297
|
+
connectionId: z21.string().describe("ID of the Google Calendar connection to use"),
|
|
91298
|
+
method: z21.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
91299
|
+
path: z21.string().describe(
|
|
91300
|
+
"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."
|
|
91301
|
+
),
|
|
91302
|
+
scopes: z21.array(z21.string()).describe(
|
|
91303
|
+
"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"
|
|
91304
|
+
),
|
|
91305
|
+
queryParams: z21.record(z21.string(), z21.string()).optional().describe("Query parameters to append to the URL"),
|
|
91306
|
+
body: z21.record(z21.string(), z21.unknown()).optional().describe("JSON request body for POST/PUT/PATCH")
|
|
91363
91307
|
});
|
|
91364
91308
|
var outputSchema21 = z21.discriminatedUnion("success", [
|
|
91365
91309
|
z21.object({
|
|
91366
91310
|
success: z21.literal(true),
|
|
91367
|
-
|
|
91368
|
-
|
|
91369
|
-
impersonateEmail: z21.string(),
|
|
91370
|
-
id: z21.string(),
|
|
91371
|
-
summary: z21.string(),
|
|
91372
|
-
primary: z21.boolean().optional(),
|
|
91373
|
-
accessRole: z21.string()
|
|
91374
|
-
})
|
|
91375
|
-
),
|
|
91376
|
-
errors: z21.array(
|
|
91377
|
-
z21.object({
|
|
91378
|
-
impersonateEmail: z21.string(),
|
|
91379
|
-
error: z21.string()
|
|
91380
|
-
})
|
|
91381
|
-
)
|
|
91311
|
+
status: z21.number(),
|
|
91312
|
+
data: z21.record(z21.string(), z21.unknown())
|
|
91382
91313
|
}),
|
|
91383
91314
|
z21.object({
|
|
91384
91315
|
success: z21.literal(false),
|
|
91385
|
-
error: z21.string()
|
|
91316
|
+
error: z21.string(),
|
|
91317
|
+
serviceAccountEmail: z21.string().optional()
|
|
91386
91318
|
})
|
|
91387
91319
|
]);
|
|
91388
|
-
var
|
|
91389
|
-
name: "
|
|
91390
|
-
description: "
|
|
91320
|
+
var requestTool5 = new ConnectorTool({
|
|
91321
|
+
name: "request",
|
|
91322
|
+
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`).",
|
|
91391
91323
|
inputSchema: inputSchema21,
|
|
91392
91324
|
outputSchema: outputSchema21,
|
|
91393
|
-
async execute({ connectionId }, connections) {
|
|
91325
|
+
async execute({ connectionId, method, path: path6, scopes, queryParams, body }, connections) {
|
|
91394
91326
|
const connection2 = connections.find((c6) => c6.id === connectionId);
|
|
91395
91327
|
if (!connection2) {
|
|
91396
91328
|
return {
|
|
@@ -91398,144 +91330,89 @@ var listCalendarsTool = new ConnectorTool({
|
|
|
91398
91330
|
error: `Connection ${connectionId} not found`
|
|
91399
91331
|
};
|
|
91400
91332
|
}
|
|
91401
|
-
const
|
|
91402
|
-
const emails = impersonateEmailRaw.split(",").map((e6) => e6.trim()).filter((e6) => e6.length > 0);
|
|
91403
|
-
if (emails.length === 0) {
|
|
91404
|
-
return {
|
|
91405
|
-
success: false,
|
|
91406
|
-
error: "impersonate-email parameter is empty"
|
|
91407
|
-
};
|
|
91408
|
-
}
|
|
91409
|
-
console.log(
|
|
91410
|
-
`[connector-request] google-calendar/${connection2.name}: listCalendars for ${emails.join(",")}`
|
|
91411
|
-
);
|
|
91333
|
+
const keyJsonBase64 = parameters14.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
91412
91334
|
let serviceAccount;
|
|
91413
91335
|
try {
|
|
91414
|
-
|
|
91415
|
-
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
91416
|
-
serviceAccount = JSON.parse(decoded);
|
|
91336
|
+
serviceAccount = decodeServiceAccount(keyJsonBase64);
|
|
91417
91337
|
} catch (err) {
|
|
91418
91338
|
const msg = err instanceof Error ? err.message : String(err);
|
|
91419
91339
|
return {
|
|
91420
91340
|
success: false,
|
|
91421
|
-
error: `
|
|
91341
|
+
error: `Failed to decode service account key: ${msg}`
|
|
91422
91342
|
};
|
|
91423
91343
|
}
|
|
91424
|
-
|
|
91425
|
-
|
|
91426
|
-
|
|
91427
|
-
|
|
91428
|
-
|
|
91429
|
-
|
|
91430
|
-
|
|
91431
|
-
|
|
91432
|
-
|
|
91344
|
+
const serviceAccountEmail = serviceAccount.client_email;
|
|
91345
|
+
console.log(
|
|
91346
|
+
`[connector-request] google-calendar/${connection2.name}: ${method} ${path6} (service account)`
|
|
91347
|
+
);
|
|
91348
|
+
try {
|
|
91349
|
+
const { GoogleAuth } = await import("google-auth-library");
|
|
91350
|
+
const auth = new GoogleAuth({
|
|
91351
|
+
credentials: {
|
|
91352
|
+
client_email: serviceAccount.client_email,
|
|
91353
|
+
private_key: serviceAccount.private_key
|
|
91354
|
+
},
|
|
91355
|
+
scopes
|
|
91356
|
+
});
|
|
91357
|
+
const token = await auth.getAccessToken();
|
|
91358
|
+
if (!token) {
|
|
91359
|
+
return {
|
|
91360
|
+
success: false,
|
|
91361
|
+
error: "Failed to obtain access token",
|
|
91362
|
+
serviceAccountEmail
|
|
91363
|
+
};
|
|
91364
|
+
}
|
|
91365
|
+
let url = `${BASE_URL6}${path6.startsWith("/") ? "" : "/"}${path6}`;
|
|
91366
|
+
if (queryParams) {
|
|
91367
|
+
const searchParams = new URLSearchParams(queryParams);
|
|
91368
|
+
url += `?${searchParams.toString()}`;
|
|
91369
|
+
}
|
|
91433
91370
|
const controller = new AbortController();
|
|
91434
91371
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS11);
|
|
91435
91372
|
try {
|
|
91436
|
-
const
|
|
91437
|
-
const response = await fetch(
|
|
91438
|
-
method
|
|
91439
|
-
headers: {
|
|
91373
|
+
const hasBody = body != null && ["POST", "PUT", "PATCH"].includes(method);
|
|
91374
|
+
const response = await fetch(url, {
|
|
91375
|
+
method,
|
|
91376
|
+
headers: {
|
|
91377
|
+
Authorization: `Bearer ${token}`,
|
|
91378
|
+
"Content-Type": "application/json"
|
|
91379
|
+
},
|
|
91380
|
+
body: hasBody ? JSON.stringify(body) : void 0,
|
|
91440
91381
|
signal: controller.signal
|
|
91441
91382
|
});
|
|
91442
|
-
const data = await response.json();
|
|
91383
|
+
const data = await response.json().catch(() => ({}));
|
|
91443
91384
|
if (!response.ok) {
|
|
91444
91385
|
const errorObj = data?.error;
|
|
91445
|
-
|
|
91446
|
-
|
|
91447
|
-
|
|
91448
|
-
|
|
91449
|
-
|
|
91450
|
-
|
|
91451
|
-
const items = data.items ?? [];
|
|
91452
|
-
for (const c6 of items) {
|
|
91453
|
-
aggregated.push({
|
|
91454
|
-
impersonateEmail: email,
|
|
91455
|
-
id: c6.id,
|
|
91456
|
-
summary: c6.summary,
|
|
91457
|
-
primary: c6.primary,
|
|
91458
|
-
accessRole: c6.accessRole
|
|
91459
|
-
});
|
|
91386
|
+
const errorMessage = errorObj?.message ?? (typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`);
|
|
91387
|
+
return {
|
|
91388
|
+
success: false,
|
|
91389
|
+
error: errorMessage,
|
|
91390
|
+
serviceAccountEmail
|
|
91391
|
+
};
|
|
91460
91392
|
}
|
|
91461
|
-
|
|
91462
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
91463
|
-
errors2.push({ impersonateEmail: email, error: msg });
|
|
91393
|
+
return { success: true, status: response.status, data };
|
|
91464
91394
|
} finally {
|
|
91465
91395
|
clearTimeout(timeout);
|
|
91466
91396
|
}
|
|
91397
|
+
} catch (err) {
|
|
91398
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
91399
|
+
return {
|
|
91400
|
+
success: false,
|
|
91401
|
+
error: msg,
|
|
91402
|
+
serviceAccountEmail
|
|
91403
|
+
};
|
|
91467
91404
|
}
|
|
91468
|
-
return {
|
|
91469
|
-
success: true,
|
|
91470
|
-
calendars: aggregated,
|
|
91471
|
-
errors: errors2
|
|
91472
|
-
};
|
|
91473
91405
|
}
|
|
91474
91406
|
});
|
|
91475
91407
|
|
|
91476
|
-
// ../connectors/src/connectors/google-calendar/
|
|
91477
|
-
var listCalendarsToolName = `google-calendar-service-account_${listCalendarsTool.name}`;
|
|
91478
|
-
var googleCalendarOnboarding = new ConnectorOnboarding({
|
|
91479
|
-
connectionSetupInstructions: {
|
|
91480
|
-
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
|
|
91481
|
-
|
|
91482
|
-
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:
|
|
91483
|
-
- \`type\`: \`"freeText"\`
|
|
91484
|
-
- \`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
|
|
91485
|
-
- \`placeholder\`: \`"user@example.com, admin@example.com"\`
|
|
91486
|
-
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:
|
|
91487
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91488
|
-
- \`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
|
|
91489
|
-
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
|
|
91490
|
-
- \`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
|
|
91491
|
-
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:
|
|
91492
|
-
- \`parameterSlug\`: \`"calendar-id"\`
|
|
91493
|
-
- \`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
|
|
91494
|
-
- \`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
|
|
91495
|
-
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:
|
|
91496
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91497
|
-
- \`options\`: \`[{ value: <ownerEmail>, label: <ownerEmail> }]\`
|
|
91498
|
-
|
|
91499
|
-
#### \u5236\u7D04
|
|
91500
|
-
- **\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
|
|
91501
|
-
- \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`,
|
|
91502
|
-
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.
|
|
91503
|
-
|
|
91504
|
-
1. Call \`askUserQuestion\` to ask the user for the Google Workspace user email the service account will impersonate via Domain-wide Delegation:
|
|
91505
|
-
- \`type\`: \`"freeText"\`
|
|
91506
|
-
- \`question\`: "Please enter the email address of the user whose calendar you want to access (comma-separated list allowed for multiple users)"
|
|
91507
|
-
- \`placeholder\`: \`"user@example.com, admin@example.com"\`
|
|
91508
|
-
2. Save the email(s) the user provided (comma-separated supported) via \`updateConnectionParameters\`:
|
|
91509
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91510
|
-
- \`options\`: \`[{ value: <the email string entered>, label: <same value> }]\` (a single option is auto-selected)
|
|
91511
|
-
3. Call \`${listCalendarsToolName}\` to list calendars accessible via the saved email(s).
|
|
91512
|
-
- 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
|
|
91513
|
-
4. Using the returned \`calendars\` array (each item: \`{ impersonateEmail, id, summary, primary, accessRole }\`), briefly say "Please select a calendar." then call \`updateConnectionParameters\`:
|
|
91514
|
-
- \`parameterSlug\`: \`"calendar-id"\`
|
|
91515
|
-
- \`options\`: Each option's \`label\` should be \`Calendar Name (owner: impersonateEmail)\`, \`value\` should be the calendar ID
|
|
91516
|
-
- If \`errors\` contains failing email addresses, briefly mention them
|
|
91517
|
-
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:
|
|
91518
|
-
- \`parameterSlug\`: \`"impersonate-email"\`
|
|
91519
|
-
- \`options\`: \`[{ value: <ownerEmail>, label: <ownerEmail> }]\`
|
|
91520
|
-
|
|
91521
|
-
#### Constraints
|
|
91522
|
-
- **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
|
|
91523
|
-
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
91524
|
-
},
|
|
91525
|
-
dataOverviewInstructions: {
|
|
91526
|
-
en: `1. Call google-calendar-service-account_request with GET /calendars/{calendarId} to get the default calendar's metadata
|
|
91527
|
-
2. Call google-calendar-service-account_request with GET /users/me/calendarList to list all accessible calendars
|
|
91528
|
-
3. Call google-calendar-service-account_request with GET /calendars/{calendarId}/events with query params timeMin (RFC3339) and maxResults=10 to sample upcoming events`,
|
|
91529
|
-
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
|
|
91530
|
-
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
|
|
91531
|
-
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`
|
|
91532
|
-
}
|
|
91533
|
-
});
|
|
91534
|
-
|
|
91535
|
-
// ../connectors/src/connectors/google-calendar/tools/request.ts
|
|
91408
|
+
// ../connectors/src/connectors/google-calendar/tools/request-with-delegation.ts
|
|
91536
91409
|
import { z as z22 } from "zod";
|
|
91537
91410
|
var BASE_URL7 = "https://www.googleapis.com/calendar/v3";
|
|
91538
91411
|
var REQUEST_TIMEOUT_MS12 = 6e4;
|
|
91412
|
+
function decodeServiceAccount2(keyJsonBase64) {
|
|
91413
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
91414
|
+
return JSON.parse(decoded);
|
|
91415
|
+
}
|
|
91539
91416
|
var inputSchema22 = z22.object({
|
|
91540
91417
|
toolUseIntent: z22.string().optional().describe(
|
|
91541
91418
|
"Brief description of what you intend to accomplish with this tool call"
|
|
@@ -91543,13 +91420,18 @@ var inputSchema22 = z22.object({
|
|
|
91543
91420
|
connectionId: z22.string().describe("ID of the Google Calendar connection to use"),
|
|
91544
91421
|
method: z22.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
91545
91422
|
path: z22.string().describe(
|
|
91546
|
-
"API path appended to https://www.googleapis.com/calendar/v3 (e.g., '/calendars/
|
|
91423
|
+
"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."
|
|
91547
91424
|
),
|
|
91548
|
-
|
|
91549
|
-
|
|
91550
|
-
|
|
91551
|
-
|
|
91552
|
-
|
|
91425
|
+
subject: z22.string().describe(
|
|
91426
|
+
"Email of the Workspace user to impersonate via Domain-wide Delegation. The token will be issued as this user."
|
|
91427
|
+
),
|
|
91428
|
+
scopes: z22.array(z22.string()).describe(
|
|
91429
|
+
"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"
|
|
91430
|
+
),
|
|
91431
|
+
queryParams: z22.record(z22.string(), z22.string()).optional().describe(
|
|
91432
|
+
"Query parameters to append to the URL (e.g., { timeMin: '2025-01-01T00:00:00Z', maxResults: '10' })"
|
|
91433
|
+
),
|
|
91434
|
+
body: z22.record(z22.string(), z22.unknown()).optional().describe("JSON request body for POST/PUT/PATCH")
|
|
91553
91435
|
});
|
|
91554
91436
|
var outputSchema22 = z22.discriminatedUnion("success", [
|
|
91555
91437
|
z22.object({
|
|
@@ -91559,17 +91441,16 @@ var outputSchema22 = z22.discriminatedUnion("success", [
|
|
|
91559
91441
|
}),
|
|
91560
91442
|
z22.object({
|
|
91561
91443
|
success: z22.literal(false),
|
|
91562
|
-
error: z22.string()
|
|
91444
|
+
error: z22.string(),
|
|
91445
|
+
serviceAccountEmail: z22.string().optional()
|
|
91563
91446
|
})
|
|
91564
91447
|
]);
|
|
91565
|
-
var
|
|
91566
|
-
name: "
|
|
91567
|
-
description: `
|
|
91568
|
-
Authentication is handled automatically using a service account.
|
|
91569
|
-
{calendarId} in the path is automatically replaced with the connection's default calendar ID.`,
|
|
91448
|
+
var requestWithDelegationTool = new ConnectorTool({
|
|
91449
|
+
name: "request_with_delegation",
|
|
91450
|
+
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.",
|
|
91570
91451
|
inputSchema: inputSchema22,
|
|
91571
91452
|
outputSchema: outputSchema22,
|
|
91572
|
-
async execute({ connectionId, method, path: path6, queryParams, body
|
|
91453
|
+
async execute({ connectionId, method, path: path6, subject, scopes, queryParams, body }, connections) {
|
|
91573
91454
|
const connection2 = connections.find((c6) => c6.id === connectionId);
|
|
91574
91455
|
if (!connection2) {
|
|
91575
91456
|
return {
|
|
@@ -91577,41 +91458,40 @@ Authentication is handled automatically using a service account.
|
|
|
91577
91458
|
error: `Connection ${connectionId} not found`
|
|
91578
91459
|
};
|
|
91579
91460
|
}
|
|
91461
|
+
const keyJsonBase64 = parameters14.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
91462
|
+
let serviceAccount;
|
|
91463
|
+
try {
|
|
91464
|
+
serviceAccount = decodeServiceAccount2(keyJsonBase64);
|
|
91465
|
+
} catch (err) {
|
|
91466
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
91467
|
+
return {
|
|
91468
|
+
success: false,
|
|
91469
|
+
error: `Failed to decode service account key: ${msg}`
|
|
91470
|
+
};
|
|
91471
|
+
}
|
|
91472
|
+
const serviceAccountEmail = serviceAccount.client_email;
|
|
91580
91473
|
console.log(
|
|
91581
|
-
`[connector-request] google-calendar/${connection2.name}: ${method} ${path6}`
|
|
91474
|
+
`[connector-request] google-calendar/${connection2.name}: ${method} ${path6} subject=${subject}`
|
|
91582
91475
|
);
|
|
91583
91476
|
try {
|
|
91584
91477
|
const { GoogleAuth } = await import("google-auth-library");
|
|
91585
|
-
const keyJsonBase64 = parameters14.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
91586
|
-
const impersonateEmail = impersonateEmailParameter.tryGetValue(connection2);
|
|
91587
|
-
const calendarId = calendarIdParameter.tryGetValue(connection2) ?? "primary";
|
|
91588
|
-
const resolvedSubject = subject ?? impersonateEmail;
|
|
91589
|
-
if (!resolvedSubject) {
|
|
91590
|
-
return {
|
|
91591
|
-
success: false,
|
|
91592
|
-
error: `Missing required parameter: ${impersonateEmailParameter.slug}. Configure the user email for this connection.`
|
|
91593
|
-
};
|
|
91594
|
-
}
|
|
91595
|
-
const credentials = JSON.parse(
|
|
91596
|
-
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
91597
|
-
);
|
|
91598
91478
|
const auth = new GoogleAuth({
|
|
91599
|
-
credentials
|
|
91600
|
-
|
|
91601
|
-
|
|
91602
|
-
|
|
91603
|
-
|
|
91604
|
-
clientOptions: { subject
|
|
91479
|
+
credentials: {
|
|
91480
|
+
client_email: serviceAccount.client_email,
|
|
91481
|
+
private_key: serviceAccount.private_key
|
|
91482
|
+
},
|
|
91483
|
+
scopes,
|
|
91484
|
+
clientOptions: { subject }
|
|
91605
91485
|
});
|
|
91606
91486
|
const token = await auth.getAccessToken();
|
|
91607
91487
|
if (!token) {
|
|
91608
91488
|
return {
|
|
91609
91489
|
success: false,
|
|
91610
|
-
error: "Failed to obtain access token"
|
|
91490
|
+
error: "Failed to obtain access token",
|
|
91491
|
+
serviceAccountEmail
|
|
91611
91492
|
};
|
|
91612
91493
|
}
|
|
91613
|
-
|
|
91614
|
-
let url = `${BASE_URL7}${resolvedPath.startsWith("/") ? "" : "/"}${resolvedPath}`;
|
|
91494
|
+
let url = `${BASE_URL7}${path6.startsWith("/") ? "" : "/"}${path6}`;
|
|
91615
91495
|
if (queryParams) {
|
|
91616
91496
|
const searchParams = new URLSearchParams(queryParams);
|
|
91617
91497
|
url += `?${searchParams.toString()}`;
|
|
@@ -91619,28 +91499,24 @@ Authentication is handled automatically using a service account.
|
|
|
91619
91499
|
const controller = new AbortController();
|
|
91620
91500
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS12);
|
|
91621
91501
|
try {
|
|
91502
|
+
const hasBody = body != null && ["POST", "PUT", "PATCH"].includes(method);
|
|
91622
91503
|
const response = await fetch(url, {
|
|
91623
91504
|
method,
|
|
91624
91505
|
headers: {
|
|
91625
91506
|
Authorization: `Bearer ${token}`,
|
|
91626
91507
|
"Content-Type": "application/json"
|
|
91627
91508
|
},
|
|
91628
|
-
body:
|
|
91509
|
+
body: hasBody ? JSON.stringify(body) : void 0,
|
|
91629
91510
|
signal: controller.signal
|
|
91630
91511
|
});
|
|
91631
|
-
|
|
91632
|
-
return {
|
|
91633
|
-
success: true,
|
|
91634
|
-
status: 204,
|
|
91635
|
-
data: { message: "Deleted successfully" }
|
|
91636
|
-
};
|
|
91637
|
-
}
|
|
91638
|
-
const data = await response.json();
|
|
91512
|
+
const data = await response.json().catch(() => ({}));
|
|
91639
91513
|
if (!response.ok) {
|
|
91640
91514
|
const errorObj = data?.error;
|
|
91515
|
+
const errorMessage = errorObj?.message ?? (typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`);
|
|
91641
91516
|
return {
|
|
91642
91517
|
success: false,
|
|
91643
|
-
error:
|
|
91518
|
+
error: errorMessage,
|
|
91519
|
+
serviceAccountEmail
|
|
91644
91520
|
};
|
|
91645
91521
|
}
|
|
91646
91522
|
return { success: true, status: response.status, data };
|
|
@@ -91649,13 +91525,200 @@ Authentication is handled automatically using a service account.
|
|
|
91649
91525
|
}
|
|
91650
91526
|
} catch (err) {
|
|
91651
91527
|
const msg = err instanceof Error ? err.message : String(err);
|
|
91652
|
-
return {
|
|
91528
|
+
return {
|
|
91529
|
+
success: false,
|
|
91530
|
+
error: msg,
|
|
91531
|
+
serviceAccountEmail
|
|
91532
|
+
};
|
|
91653
91533
|
}
|
|
91654
91534
|
}
|
|
91655
91535
|
});
|
|
91656
91536
|
|
|
91537
|
+
// ../connectors/src/connectors/google-calendar/setup.ts
|
|
91538
|
+
var requestToolName = `google-calendar-service-account_${requestTool5.name}`;
|
|
91539
|
+
var requestWithDelegationToolName = `google-calendar-service-account_${requestWithDelegationTool.name}`;
|
|
91540
|
+
var READONLY_SCOPES = '["https://www.googleapis.com/auth/calendar.readonly"]';
|
|
91541
|
+
var SERVICE_ACCOUNT_KEY_PARAM_SLUG = parameters14.serviceAccountKeyJsonBase64.slug;
|
|
91542
|
+
var googleCalendarOnboarding = new ConnectorOnboarding({
|
|
91543
|
+
connectionSetupInstructions: {
|
|
91544
|
+
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
|
|
91545
|
+
|
|
91546
|
+
## \u30B9\u30C6\u30C3\u30D7 1: \u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u3092\u9078\u629E
|
|
91547
|
+
|
|
91548
|
+
\`askUserQuestion\` \u3067\u6B21\u306E 3 \u629E\u3092\u63D0\u793A\u3059\u308B:
|
|
91549
|
+
- \`type\`: \`"select"\`
|
|
91550
|
+
- \`question\`: \u300C\u3069\u306E\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u30A2\u30AF\u30BB\u30B9\u3057\u307E\u3059\u304B\uFF1F\u300D
|
|
91551
|
+
- \`options\`:
|
|
91552
|
+
- \`{ 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" }\`
|
|
91553
|
+
- \`{ 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" }\`
|
|
91554
|
+
- \`{ label: "\u4E21\u65B9\u3092\u7D44\u307F\u5408\u308F\u305B\u308B", value: "both" }\`
|
|
91555
|
+
|
|
91556
|
+
## \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)
|
|
91557
|
+
|
|
91558
|
+
1. \`${requestToolName}\` \u3092\u547C\u3093\u3067\u30AB\u30EC\u30F3\u30C0\u30FC\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
|
|
91559
|
+
- \`method\`: \`"GET"\`
|
|
91560
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91561
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91562
|
+
|
|
91563
|
+
2. \u53D6\u5F97\u7D50\u679C\u306B\u5FDC\u3058\u3066\u5206\u5C90:
|
|
91564
|
+
- \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
|
|
91565
|
+
- \u7D50\u679C\u304C\u3042\u308B: \`askUserQuestion\` \u3067\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u3070\u305B\u308B
|
|
91566
|
+
- \`type\`: \`"multiSelect"\`
|
|
91567
|
+
- \`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
|
|
91568
|
+
- \`options\`: \u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u3064\u3044\u3066 \`label\`: \`"<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D>"\`\u3001\`value\`: \`"<calendarId>"\`
|
|
91569
|
+
|
|
91570
|
+
## \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)
|
|
91571
|
+
|
|
91572
|
+
1. \`askUserQuestion\` \u3067\u5BFE\u8C61\u30E6\u30FC\u30B6\u30FC\u306E\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u805E\u304F:
|
|
91573
|
+
- \`type\`: \`"freeText"\`
|
|
91574
|
+
- \`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
|
|
91575
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
91576
|
+
|
|
91577
|
+
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:
|
|
91578
|
+
- \`method\`: \`"GET"\`
|
|
91579
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91580
|
+
- \`subject\`: \`<email>\`
|
|
91581
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91582
|
+
|
|
91583
|
+
3. \u53D6\u5F97\u7D50\u679C\u306B\u5FDC\u3058\u3066\u5206\u5C90:
|
|
91584
|
+
- \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
|
|
91585
|
+
- \u4E00\u90E8\u307E\u305F\u306F\u5168\u4EF6\u6210\u529F: \`askUserQuestion\` \u3067\u30AB\u30EC\u30F3\u30C0\u30FC\u3092\u9078\u3070\u305B\u308B
|
|
91586
|
+
- \`type\`: \`"multiSelect"\`
|
|
91587
|
+
- \`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
|
|
91588
|
+
- \`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>"\`
|
|
91589
|
+
- \u4E00\u90E8\u5931\u6557\u304C\u3042\u308C\u3070\u3001\u305D\u306E\u65E8\u3092 1 \u6587\u3067\u77ED\u304F\u4F1D\u3048\u308B
|
|
91590
|
+
|
|
91591
|
+
## \u30B9\u30C6\u30C3\u30D7 4: Project Knowledge \u306B\u8A18\u9332
|
|
91592
|
+
|
|
91593
|
+
\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:
|
|
91594
|
+
- \u30C9\u30E1\u30A4\u30F3\u5168\u4F53\u306E\u59D4\u4EFB\u7D4C\u7531: \`- calendar: <calendarId> (delegation, subject: <subject>, name: "<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D>")\`
|
|
91595
|
+
- \u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u7D4C\u8DEF: \`- calendar: <calendarId> (service-account, name: "<\u30AB\u30EC\u30F3\u30C0\u30FC\u540D>")\`
|
|
91596
|
+
|
|
91597
|
+
## \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
|
|
91598
|
+
|
|
91599
|
+
\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:
|
|
91600
|
+
|
|
91601
|
+
- \`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
|
|
91602
|
+
- \`options\`: \u3053\u3053\u307E\u3067\u306B\u8A66\u3057\u305F\u7D4C\u8DEF\u306B\u5FDC\u3058\u3066\u4EE5\u4E0B\u3092\u7D44\u307F\u5408\u308F\u305B\u308B:
|
|
91603
|
+
- \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" }\`
|
|
91604
|
+
- \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" }\`
|
|
91605
|
+
- \u5E38\u306B: \`{ label: "\u30A2\u30AF\u30BB\u30B9\u65B9\u6CD5\u3092\u5909\u66F4\u3059\u308B", value: "restart" }\`
|
|
91606
|
+
- \u5E38\u306B: \`{ label: "\u5225\u306E\u30B5\u30FC\u30D3\u30B9\u30A2\u30AB\u30A6\u30F3\u30C8\u3067\u8A2D\u5B9A\u3057\u76F4\u3059", value: "change-service-account" }\`
|
|
91607
|
+
|
|
91608
|
+
\u9078\u629E\u7D50\u679C\u306B\u5FDC\u3058\u305F\u6319\u52D5:
|
|
91609
|
+
- "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)
|
|
91610
|
+
- "restart": \u30B9\u30C6\u30C3\u30D7 1 \u304B\u3089\u518D\u5B9F\u884C
|
|
91611
|
+
- "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:
|
|
91612
|
+
- \`parameterSlug\`: \`"${SERVICE_ACCOUNT_KEY_PARAM_SLUG}"\`
|
|
91613
|
+
- \u5B8C\u4E86\u5F8C\u3001\u30B9\u30C6\u30C3\u30D7 1 \u304B\u3089\u518D\u5B9F\u884C
|
|
91614
|
+
|
|
91615
|
+
## \u5236\u7D04
|
|
91616
|
+
|
|
91617
|
+
- \u4E0A\u8A18\u4EE5\u5916\u306E API \u547C\u3073\u51FA\u3057\u3092 setup \u4E2D\u306B\u884C\u308F\u306A\u3044
|
|
91618
|
+
- \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`,
|
|
91619
|
+
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.
|
|
91620
|
+
|
|
91621
|
+
## Step 1: Choose the access method
|
|
91622
|
+
|
|
91623
|
+
Call \`askUserQuestion\`:
|
|
91624
|
+
- \`type\`: \`"select"\`
|
|
91625
|
+
- \`question\`: "Which calendars do you want to access?"
|
|
91626
|
+
- \`options\`:
|
|
91627
|
+
- \`{ label: "Calendars shared with this service account", value: "service-account" }\`
|
|
91628
|
+
- \`{ label: "Calendars of users in your organization (via Domain-wide Delegation)", value: "delegation" }\`
|
|
91629
|
+
- \`{ label: "Both", value: "both" }\`
|
|
91630
|
+
|
|
91631
|
+
## Step 2: Discover and select via the service-account path (when \`"service-account"\` or \`"both"\`)
|
|
91632
|
+
|
|
91633
|
+
1. Call \`${requestToolName}\`:
|
|
91634
|
+
- \`method\`: \`"GET"\`
|
|
91635
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91636
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91637
|
+
|
|
91638
|
+
2. Branch on the result:
|
|
91639
|
+
- Empty: if the access method is \`"service-account"\` only, jump to Step 5. If \`"both"\`, continue to Step 3.
|
|
91640
|
+
- Non-empty: ask the user to pick:
|
|
91641
|
+
- \`type\`: \`"multiSelect"\`
|
|
91642
|
+
- \`question\`: "Select the calendars to use (multiple allowed)"
|
|
91643
|
+
- \`options\`: For each calendar, \`label\`: \`"<calendar name>"\`, \`value\`: \`"<calendarId>"\`
|
|
91644
|
+
|
|
91645
|
+
## Step 3: Discover and select via the Domain-wide Delegation path (when \`"delegation"\` or \`"both"\`)
|
|
91646
|
+
|
|
91647
|
+
1. Ask the user for target emails:
|
|
91648
|
+
- \`type\`: \`"freeText"\`
|
|
91649
|
+
- \`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))."
|
|
91650
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
91651
|
+
|
|
91652
|
+
2. Extract individual emails and, for each \`<email>\`, call \`${requestWithDelegationToolName}\`:
|
|
91653
|
+
- \`method\`: \`"GET"\`
|
|
91654
|
+
- \`path\`: \`"/users/me/calendarList"\`
|
|
91655
|
+
- \`subject\`: \`<email>\`
|
|
91656
|
+
- \`scopes\`: \`${READONLY_SCOPES}\`
|
|
91657
|
+
|
|
91658
|
+
3. Branch on the results:
|
|
91659
|
+
- 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.
|
|
91660
|
+
- Any success: ask the user to pick:
|
|
91661
|
+
- \`type\`: \`"multiSelect"\`
|
|
91662
|
+
- \`question\`: "Select the calendars to use (multiple allowed)"
|
|
91663
|
+
- \`options\`: For each calendar, \`label\`: \`"<calendar name> (owner: <the subject used>)"\`, \`value\`: \`"<calendarId>"\`
|
|
91664
|
+
- If some emails failed, mention that briefly in one sentence.
|
|
91665
|
+
|
|
91666
|
+
## Step 4: Record in Project Knowledge
|
|
91667
|
+
|
|
91668
|
+
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:
|
|
91669
|
+
- Via Domain-wide Delegation: \`- calendar: <calendarId> (delegation, subject: <subject>, name: "<calendar name>")\`
|
|
91670
|
+
- Via service account: \`- calendar: <calendarId> (service-account, name: "<calendar name>")\`
|
|
91671
|
+
|
|
91672
|
+
## Step 5: Escalation when zero calendars are selected
|
|
91673
|
+
|
|
91674
|
+
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\`:
|
|
91675
|
+
|
|
91676
|
+
- \`question\`: "No accessible calendars found. Please do one of the following before continuing. Service account: \`<serviceAccountEmail>\`."
|
|
91677
|
+
- \`options\`: Combine these based on which paths were attempted:
|
|
91678
|
+
- Service-account path attempted: \`{ label: "Shared the calendar with the service account \u2014 retry", value: "retry" }\`
|
|
91679
|
+
- Domain-wide Delegation path attempted: \`{ label: "Authorized Domain-wide Delegation \u2014 retry", value: "retry" }\`
|
|
91680
|
+
- Always: \`{ label: "Change the access method", value: "restart" }\`
|
|
91681
|
+
- Always: \`{ label: "Use a different service account", value: "change-service-account" }\`
|
|
91682
|
+
|
|
91683
|
+
Behavior per selection:
|
|
91684
|
+
- "retry": re-probe the path that was just attempted (leave the exact retry plan to the agent)
|
|
91685
|
+
- "restart": re-run from Step 1
|
|
91686
|
+
- "change-service-account": call \`updateConnectionParameters\` to have the user re-upload the service account JSON:
|
|
91687
|
+
- \`parameterSlug\`: \`"${SERVICE_ACCOUNT_KEY_PARAM_SLUG}"\`
|
|
91688
|
+
- After it completes, re-run from Step 1
|
|
91689
|
+
|
|
91690
|
+
## Constraints
|
|
91691
|
+
|
|
91692
|
+
- Do not call any other API endpoints during setup
|
|
91693
|
+
- Write at most 1 sentence between tool calls`
|
|
91694
|
+
},
|
|
91695
|
+
dataOverviewInstructions: {
|
|
91696
|
+
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:
|
|
91697
|
+
- \`(delegation, subject: <email>, ...)\` \u2192 \`${requestWithDelegationToolName}\` with \`subject: <email>\`
|
|
91698
|
+
- \`(service-account, ...)\` \u2192 \`${requestToolName}\`
|
|
91699
|
+
|
|
91700
|
+
Pass \`scopes: ${READONLY_SCOPES}\` for every call.
|
|
91701
|
+
|
|
91702
|
+
For each calendar:
|
|
91703
|
+
1. \`method=GET\`, \`path=/calendars/<id>\` to fetch metadata.
|
|
91704
|
+
2. \`method=GET\`, \`path=/calendars/<id>/events\`, \`queryParams={ timeMin: <RFC3339 now>, maxResults: "10", singleEvents: "true", orderBy: "startTime" }\`.`,
|
|
91705
|
+
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:
|
|
91706
|
+
- \`(delegation, subject: <email>, ...)\` \u2192 \`${requestWithDelegationToolName}\` \u3092 \`subject: <email>\` \u4ED8\u304D\u3067\u547C\u3076
|
|
91707
|
+
- \`(service-account, ...)\` \u2192 \`${requestToolName}\` \u3092\u547C\u3076
|
|
91708
|
+
|
|
91709
|
+
\`scopes\` \u306F\u6BCE\u56DE \`${READONLY_SCOPES}\` \u3092\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
91710
|
+
|
|
91711
|
+
\u5404\u30AB\u30EC\u30F3\u30C0\u30FC\u306B\u3064\u3044\u3066:
|
|
91712
|
+
1. \`method=GET\`\u3001\`path=/calendars/<id>\` \u3067\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
91713
|
+
2. \`method=GET\`\u3001\`path=/calendars/<id>/events\`\u3001\`queryParams={ timeMin: <RFC3339 \u306E\u73FE\u5728\u6642\u523B>, maxResults: "10", singleEvents: "true", orderBy: "startTime" }\``
|
|
91714
|
+
}
|
|
91715
|
+
});
|
|
91716
|
+
|
|
91657
91717
|
// ../connectors/src/connectors/google-calendar/index.ts
|
|
91658
|
-
var tools14 = {
|
|
91718
|
+
var tools14 = {
|
|
91719
|
+
request: requestTool5,
|
|
91720
|
+
request_with_delegation: requestWithDelegationTool
|
|
91721
|
+
};
|
|
91659
91722
|
var googleCalendarConnector = new ConnectorPlugin({
|
|
91660
91723
|
slug: "google-calendar",
|
|
91661
91724
|
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
@@ -91668,58 +91731,45 @@ var googleCalendarConnector = new ConnectorPlugin({
|
|
|
91668
91731
|
systemPrompt: {
|
|
91669
91732
|
en: `### Tools
|
|
91670
91733
|
|
|
91671
|
-
|
|
91734
|
+
This connector exposes two request tools that correspond to the two ways a Service Account can authenticate against the Google Calendar API:
|
|
91672
91735
|
|
|
91673
|
-
|
|
91736
|
+
- \`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.
|
|
91737
|
+
- \`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.
|
|
91674
91738
|
|
|
91675
|
-
|
|
91739
|
+
Both tools require a \`scopes\` argument.
|
|
91676
91740
|
|
|
91677
|
-
|
|
91678
|
-
- \`client.listCalendars()\` \u2014 list all accessible calendars
|
|
91679
|
-
- \`client.listEvents(options?, calendarId?)\` \u2014 list events with optional filters
|
|
91680
|
-
- \`client.getEvent(eventId, calendarId?)\` \u2014 get a single event by ID
|
|
91681
|
-
- \`client.request(path, init?)\` \u2014 low-level authenticated fetch
|
|
91741
|
+
### OAuth Scopes (pass as \`scopes\` argument)
|
|
91682
91742
|
|
|
91683
|
-
|
|
91743
|
+
This connector is currently read-only. Pass one of:
|
|
91684
91744
|
|
|
91685
|
-
|
|
91745
|
+
- \`https://www.googleapis.com/auth/calendar.readonly\` \u2014 read-only on calendars and events
|
|
91746
|
+
- \`https://www.googleapis.com/auth/calendar.events.readonly\` \u2014 read-only on events (no calendar metadata)
|
|
91747
|
+
- \`https://www.googleapis.com/auth/calendar.freebusy\` \u2014 busy/free time queries only
|
|
91686
91748
|
|
|
91687
|
-
|
|
91688
|
-
const calendar = connection("<connectionId>", { subject: "other-user@example.com" });
|
|
91689
|
-
\`\`\`
|
|
91749
|
+
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\`.
|
|
91690
91750
|
|
|
91691
|
-
|
|
91692
|
-
import type { Context } from "hono";
|
|
91693
|
-
import { connection } from "@squadbase/vite-server/connectors/google-calendar";
|
|
91751
|
+
Per-endpoint scope reference: https://developers.google.com/calendar/api/auth
|
|
91694
91752
|
|
|
91695
|
-
|
|
91753
|
+
### Choosing the right tool
|
|
91696
91754
|
|
|
91697
|
-
|
|
91698
|
-
const now = new Date().toISOString();
|
|
91699
|
-
const { items } = await calendar.listEvents({
|
|
91700
|
-
timeMin: now,
|
|
91701
|
-
maxResults: 10,
|
|
91702
|
-
singleEvents: true,
|
|
91703
|
-
orderBy: "startTime",
|
|
91704
|
-
});
|
|
91755
|
+
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:
|
|
91705
91756
|
|
|
91706
|
-
|
|
91707
|
-
|
|
91708
|
-
|
|
91709
|
-
|
|
91710
|
-
|
|
91711
|
-
|
|
91712
|
-
|
|
91713
|
-
|
|
91714
|
-
|
|
91715
|
-
|
|
91716
|
-
\`\`\`
|
|
91757
|
+
- \`(delegation, subject: <email>, name: "...")\` \u2192 use \`request_with_delegation\` and pass \`subject: <email>\`
|
|
91758
|
+
- \`(service-account, name: "...")\` \u2192 use \`request\` (no \`subject\`)
|
|
91759
|
+
|
|
91760
|
+
### Path conventions
|
|
91761
|
+
|
|
91762
|
+
Write the calendar ID directly into the path \u2014 there is no placeholder substitution. Examples:
|
|
91763
|
+
|
|
91764
|
+
- \`/users/me/calendarList\` \u2014 list calendars accessible to the authenticated identity
|
|
91765
|
+
- \`/calendars/alice@example.com/events\` \u2014 events on alice's primary calendar
|
|
91766
|
+
- \`/calendars/c_abc123@group.calendar.google.com/events\` \u2014 events on a secondary calendar
|
|
91717
91767
|
|
|
91718
91768
|
### Google Calendar API v3 Reference
|
|
91719
91769
|
|
|
91720
91770
|
#### Available Endpoints
|
|
91721
91771
|
- GET \`/calendars/{calendarId}\` \u2014 Get calendar metadata
|
|
91722
|
-
- GET \`/users/me/calendarList\` \u2014 List all calendars accessible by the authenticated
|
|
91772
|
+
- GET \`/users/me/calendarList\` \u2014 List all calendars accessible by the authenticated identity
|
|
91723
91773
|
- GET \`/calendars/{calendarId}/events\` \u2014 List events on a calendar
|
|
91724
91774
|
- GET \`/calendars/{calendarId}/events/{eventId}\` \u2014 Get a single event
|
|
91725
91775
|
|
|
@@ -91731,66 +91781,93 @@ export default async function handler(c: Context) {
|
|
|
91731
91781
|
- \`orderBy=startTime\` \u2014 Order by start time (requires singleEvents=true)
|
|
91732
91782
|
- \`q\` \u2014 Free text search terms
|
|
91733
91783
|
|
|
91734
|
-
#### Tips
|
|
91735
|
-
- Use \`{calendarId}\` placeholder in paths \u2014 it is automatically replaced with the configured default calendar ID
|
|
91736
|
-
- Set \`singleEvents=true\` to expand recurring events into individual instances
|
|
91737
|
-
- When using \`orderBy=startTime\`, you must also set \`singleEvents=true\`
|
|
91738
|
-
- Use RFC3339 format for time parameters (e.g., "2024-01-15T09:00:00Z" or "2024-01-15T09:00:00+09:00")
|
|
91739
|
-
- The default calendar ID is "primary" if not configured`,
|
|
91740
|
-
ja: `### \u30C4\u30FC\u30EB
|
|
91741
|
-
|
|
91742
|
-
- \`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
|
|
91743
|
-
|
|
91744
91784
|
### Business Logic
|
|
91745
91785
|
|
|
91746
|
-
|
|
91786
|
+
The business logic type for this connector is "typescript". Use the connector SDK in your handler. Do NOT read credentials from environment variables.
|
|
91747
91787
|
|
|
91748
|
-
SDK
|
|
91749
|
-
- \`client.listCalendars()\` \u2014 \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306A\u5168\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u4E00\u89A7\u53D6\u5F97
|
|
91750
|
-
- \`client.listEvents(options?, calendarId?)\` \u2014 \u30D5\u30A3\u30EB\u30BF\u30FC\u4ED8\u304D\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7\u53D6\u5F97
|
|
91751
|
-
- \`client.getEvent(eventId, calendarId?)\` \u2014 ID\u306B\u3088\u308B\u5358\u4E00\u30A4\u30D9\u30F3\u30C8\u53D6\u5F97
|
|
91752
|
-
- \`client.request(path, init?)\` \u2014 \u4F4E\u30EC\u30D9\u30EB\u306E\u8A8D\u8A3C\u4ED8\u304Dfetch
|
|
91788
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
91753
91789
|
|
|
91754
|
-
|
|
91790
|
+
- \`client.requestWithDelegation(path, { subject, scopes, init? })\` \u2014 call the API as the impersonated Workspace user via Domain-wide Delegation
|
|
91791
|
+
- \`client.request(path, { scopes, init? })\` \u2014 call the API as the service account itself (only calendars shared with the SA email are accessible)
|
|
91755
91792
|
|
|
91756
|
-
|
|
91793
|
+
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.
|
|
91757
91794
|
|
|
91758
|
-
|
|
91759
|
-
const calendar = connection("<connectionId>", { subject: "other-user@example.com" });
|
|
91760
|
-
\`\`\`
|
|
91795
|
+
#### Example
|
|
91761
91796
|
|
|
91762
91797
|
\`\`\`ts
|
|
91763
91798
|
import type { Context } from "hono";
|
|
91764
91799
|
import { connection } from "@squadbase/vite-server/connectors/google-calendar";
|
|
91765
91800
|
|
|
91766
91801
|
const calendar = connection("<connectionId>");
|
|
91802
|
+
const READ = ["https://www.googleapis.com/auth/calendar.readonly"];
|
|
91767
91803
|
|
|
91768
91804
|
export default async function handler(c: Context) {
|
|
91769
91805
|
const now = new Date().toISOString();
|
|
91770
|
-
const
|
|
91806
|
+
const qs = new URLSearchParams({
|
|
91771
91807
|
timeMin: now,
|
|
91772
|
-
maxResults: 10,
|
|
91773
|
-
singleEvents: true,
|
|
91808
|
+
maxResults: "10",
|
|
91809
|
+
singleEvents: "true",
|
|
91774
91810
|
orderBy: "startTime",
|
|
91775
91811
|
});
|
|
91776
91812
|
|
|
91777
|
-
|
|
91778
|
-
|
|
91779
|
-
|
|
91780
|
-
|
|
91781
|
-
|
|
91782
|
-
|
|
91783
|
-
|
|
91784
|
-
|
|
91813
|
+
// Project knowledge says: alice@example.com is reachable via delegation
|
|
91814
|
+
const aliceRes = await calendar.requestWithDelegation(
|
|
91815
|
+
\`/calendars/alice@example.com/events?\${qs}\`,
|
|
91816
|
+
{ subject: "alice@example.com", scopes: READ },
|
|
91817
|
+
);
|
|
91818
|
+
const alice = await aliceRes.json();
|
|
91819
|
+
|
|
91820
|
+
// Project knowledge says: team@example.com is shared with the SA
|
|
91821
|
+
const teamRes = await calendar.request(
|
|
91822
|
+
\`/calendars/team@example.com/events?\${qs}\`,
|
|
91823
|
+
{ scopes: READ },
|
|
91785
91824
|
);
|
|
91825
|
+
const team = await teamRes.json();
|
|
91826
|
+
|
|
91827
|
+
return c.json({ alice: alice.items, team: team.items });
|
|
91786
91828
|
}
|
|
91787
|
-
|
|
91829
|
+
\`\`\``,
|
|
91830
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
91831
|
+
|
|
91832
|
+
\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:
|
|
91833
|
+
|
|
91834
|
+
- \`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
|
|
91835
|
+
- \`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
|
|
91836
|
+
|
|
91837
|
+
\u4E21\u30C4\u30FC\u30EB\u3068\u3082 \`scopes\` \u5F15\u6570\u304C\u5FC5\u9808\u3067\u3059\u3002
|
|
91838
|
+
|
|
91839
|
+
### OAuth \u30B9\u30B3\u30FC\u30D7 (\`scopes\` \u5F15\u6570\u3067\u6E21\u3059)
|
|
91840
|
+
|
|
91841
|
+
\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:
|
|
91842
|
+
|
|
91843
|
+
- \`https://www.googleapis.com/auth/calendar.readonly\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u3068\u30A4\u30D9\u30F3\u30C8\u306E\u8AAD\u307F\u53D6\u308A
|
|
91844
|
+
- \`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
|
|
91845
|
+
- \`https://www.googleapis.com/auth/calendar.freebusy\` \u2014 \u7A7A\u304D\u72B6\u6CC1\u30AF\u30A8\u30EA\u306E\u307F
|
|
91846
|
+
|
|
91847
|
+
\`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
|
|
91848
|
+
|
|
91849
|
+
\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
|
|
91850
|
+
|
|
91851
|
+
### \u9069\u5207\u306A\u30C4\u30FC\u30EB\u306E\u9078\u3073\u65B9
|
|
91852
|
+
|
|
91853
|
+
\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:
|
|
91854
|
+
|
|
91855
|
+
- \`(delegation, subject: <email>, name: "...")\` \u2192 \`request_with_delegation\` \u3092\u4F7F\u3044\u3001\`subject: <email>\` \u3092\u6E21\u3059
|
|
91856
|
+
- \`(service-account, name: "...")\` \u2192 \`request\` \u3092\u4F7F\u3046\uFF08\`subject\` \u4E0D\u8981\uFF09
|
|
91857
|
+
|
|
91858
|
+
### \u30D1\u30B9\u306E\u66F8\u304D\u65B9
|
|
91859
|
+
|
|
91860
|
+
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:
|
|
91861
|
+
|
|
91862
|
+
- \`/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
|
|
91863
|
+
- \`/calendars/alice@example.com/events\` \u2014 alice \u306E\u30D7\u30E9\u30A4\u30DE\u30EA\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8
|
|
91864
|
+
- \`/calendars/c_abc123@group.calendar.google.com/events\` \u2014 \u4E8C\u6B21\u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30A4\u30D9\u30F3\u30C8
|
|
91788
91865
|
|
|
91789
91866
|
### Google Calendar API v3 \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
91790
91867
|
|
|
91791
91868
|
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
91792
91869
|
- GET \`/calendars/{calendarId}\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
|
|
91793
|
-
- GET \`/users/me/calendarList\` \u2014 \u8A8D\u8A3C\
|
|
91870
|
+
- 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
|
|
91794
91871
|
- GET \`/calendars/{calendarId}/events\` \u2014 \u30AB\u30EC\u30F3\u30C0\u30FC\u4E0A\u306E\u30A4\u30D9\u30F3\u30C8\u4E00\u89A7
|
|
91795
91872
|
- GET \`/calendars/{calendarId}/events/{eventId}\` \u2014 \u5358\u4E00\u30A4\u30D9\u30F3\u30C8\u306E\u53D6\u5F97
|
|
91796
91873
|
|
|
@@ -91802,12 +91879,52 @@ export default async function handler(c: Context) {
|
|
|
91802
91879
|
- \`orderBy=startTime\` \u2014 \u958B\u59CB\u6642\u9593\u9806\u306B\u4E26\u3079\u66FF\u3048\uFF08singleEvents=true\u304C\u5FC5\u8981\uFF09
|
|
91803
91880
|
- \`q\` \u2014 \u30D5\u30EA\u30FC\u30C6\u30AD\u30B9\u30C8\u691C\u7D22\u8A9E
|
|
91804
91881
|
|
|
91805
|
-
|
|
91806
|
-
|
|
91807
|
-
|
|
91808
|
-
|
|
91809
|
-
|
|
91810
|
-
|
|
91882
|
+
### Business Logic
|
|
91883
|
+
|
|
91884
|
+
\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
|
|
91885
|
+
|
|
91886
|
+
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
91887
|
+
|
|
91888
|
+
- \`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
|
|
91889
|
+
- \`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
|
|
91890
|
+
|
|
91891
|
+
\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
|
|
91892
|
+
|
|
91893
|
+
#### Example
|
|
91894
|
+
|
|
91895
|
+
\`\`\`ts
|
|
91896
|
+
import type { Context } from "hono";
|
|
91897
|
+
import { connection } from "@squadbase/vite-server/connectors/google-calendar";
|
|
91898
|
+
|
|
91899
|
+
const calendar = connection("<connectionId>");
|
|
91900
|
+
const READ = ["https://www.googleapis.com/auth/calendar.readonly"];
|
|
91901
|
+
|
|
91902
|
+
export default async function handler(c: Context) {
|
|
91903
|
+
const now = new Date().toISOString();
|
|
91904
|
+
const qs = new URLSearchParams({
|
|
91905
|
+
timeMin: now,
|
|
91906
|
+
maxResults: "10",
|
|
91907
|
+
singleEvents: "true",
|
|
91908
|
+
orderBy: "startTime",
|
|
91909
|
+
});
|
|
91910
|
+
|
|
91911
|
+
// Project Knowledge: alice@example.com \u306F delegation \u7D4C\u8DEF\u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD
|
|
91912
|
+
const aliceRes = await calendar.requestWithDelegation(
|
|
91913
|
+
\`/calendars/alice@example.com/events?\${qs}\`,
|
|
91914
|
+
{ subject: "alice@example.com", scopes: READ },
|
|
91915
|
+
);
|
|
91916
|
+
const alice = await aliceRes.json();
|
|
91917
|
+
|
|
91918
|
+
// Project Knowledge: team@example.com \u306F SA \u306B\u5171\u6709\u3055\u308C\u3066\u3044\u308B
|
|
91919
|
+
const teamRes = await calendar.request(
|
|
91920
|
+
\`/calendars/team@example.com/events?\${qs}\`,
|
|
91921
|
+
{ scopes: READ },
|
|
91922
|
+
);
|
|
91923
|
+
const team = await teamRes.json();
|
|
91924
|
+
|
|
91925
|
+
return c.json({ alice: alice.items, team: team.items });
|
|
91926
|
+
}
|
|
91927
|
+
\`\`\``
|
|
91811
91928
|
},
|
|
91812
91929
|
tools: tools14
|
|
91813
91930
|
});
|
|
@@ -91870,7 +91987,7 @@ var outputSchema23 = z23.discriminatedUnion("success", [
|
|
|
91870
91987
|
error: z23.string()
|
|
91871
91988
|
})
|
|
91872
91989
|
]);
|
|
91873
|
-
var
|
|
91990
|
+
var listCalendarsTool = new ConnectorTool({
|
|
91874
91991
|
name: "listCalendars",
|
|
91875
91992
|
description: "List all Google Calendars accessible with the OAuth credentials. Use during setup to discover available calendars.",
|
|
91876
91993
|
inputSchema: inputSchema23,
|
|
@@ -91931,12 +92048,12 @@ var listCalendarsTool2 = new ConnectorTool({
|
|
|
91931
92048
|
});
|
|
91932
92049
|
|
|
91933
92050
|
// ../connectors/src/connectors/google-calendar-oauth/setup.ts
|
|
91934
|
-
var
|
|
92051
|
+
var listCalendarsToolName = `google-calendar-oauth_${listCalendarsTool.name}`;
|
|
91935
92052
|
var googleCalendarOauthOnboarding = new ConnectorOnboarding({
|
|
91936
92053
|
connectionSetupInstructions: {
|
|
91937
92054
|
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
|
|
91938
92055
|
|
|
91939
|
-
1. \`${
|
|
92056
|
+
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
|
|
91940
92057
|
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:
|
|
91941
92058
|
- \`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
|
|
91942
92059
|
3. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
@@ -91948,7 +92065,7 @@ var googleCalendarOauthOnboarding = new ConnectorOnboarding({
|
|
|
91948
92065
|
- \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`,
|
|
91949
92066
|
en: `Follow these steps to set up the Google Calendar (OAuth) connection.
|
|
91950
92067
|
|
|
91951
|
-
1. Call \`${
|
|
92068
|
+
1. Call \`${listCalendarsToolName}\` to get the list of calendars accessible with the OAuth credentials
|
|
91952
92069
|
2. Tell the user "Please select a calendar.", then call \`askUserQuestion\`:
|
|
91953
92070
|
- \`options\`: The calendar list. Each option's \`label\` should be \`Calendar Name (id: calendarId)\`, \`value\` should be the calendar ID
|
|
91954
92071
|
3. Call \`updateConnectionParameters\`:
|
|
@@ -92104,7 +92221,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
92104
92221
|
// ../connectors/src/connectors/google-calendar-oauth/index.ts
|
|
92105
92222
|
var tools15 = {
|
|
92106
92223
|
request: requestTool6,
|
|
92107
|
-
listCalendars:
|
|
92224
|
+
listCalendars: listCalendarsTool
|
|
92108
92225
|
};
|
|
92109
92226
|
var googleCalendarOauthConnector = new ConnectorPlugin({
|
|
92110
92227
|
slug: "google-calendar",
|
|
@@ -93140,7 +93257,7 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
93140
93257
|
});
|
|
93141
93258
|
|
|
93142
93259
|
// ../connectors/src/connectors/google-sheets/setup.ts
|
|
93143
|
-
var
|
|
93260
|
+
var requestToolName2 = `google-sheets-oauth_${requestTool9.name}`;
|
|
93144
93261
|
var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
93145
93262
|
connectionSetupInstructions: {
|
|
93146
93263
|
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
|
|
@@ -93150,12 +93267,12 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
93150
93267
|
- \`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
|
|
93151
93268
|
- \`placeholder\`: \`"https://docs.google.com/spreadsheets/d/.../edit"\`
|
|
93152
93269
|
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
|
|
93153
|
-
3. \`${
|
|
93270
|
+
3. \`${requestToolName2}\` \u3067\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u6027\u3092\u78BA\u8A8D\u3059\u308B:
|
|
93154
93271
|
- \`method\`: \`"GET"\`
|
|
93155
93272
|
- \`path\`: \`"/<\u62BD\u51FA\u3057\u305FspreadsheetId>"\`
|
|
93156
93273
|
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:
|
|
93157
93274
|
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
|
|
93158
|
-
b. \`askUserQuestion\` \u3067\u3082\u3046\u4E00\u5EA6URL\u3092\u805E\u304D\u76F4\u3057\u3001\u518D\u5EA6 \`${
|
|
93275
|
+
b. \`askUserQuestion\` \u3067\u3082\u3046\u4E00\u5EA6URL\u3092\u805E\u304D\u76F4\u3057\u3001\u518D\u5EA6 \`${requestToolName2}\` \u3067\u691C\u8A3C
|
|
93159
93276
|
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
|
|
93160
93277
|
|
|
93161
93278
|
#### \u5236\u7D04
|
|
@@ -93169,12 +93286,12 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
93169
93286
|
- \`question\`: "Please paste the URL of the Google Sheet you want to work with (both read and edit are supported)."
|
|
93170
93287
|
- \`placeholder\`: \`"https://docs.google.com/spreadsheets/d/.../edit"\`
|
|
93171
93288
|
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.
|
|
93172
|
-
3. Verify accessibility by calling \`${
|
|
93289
|
+
3. Verify accessibility by calling \`${requestToolName2}\`:
|
|
93173
93290
|
- \`method\`: \`"GET"\`
|
|
93174
93291
|
- \`path\`: \`"/<extracted spreadsheetId>"\`
|
|
93175
93292
|
4. **Retry on verification failure**: If step 3 returns \`success: false\` (404/403/not found or any other error):
|
|
93176
93293
|
a. Tell the user the likely causes (wrong URL, OAuth-connected Google account lacks access, private sheet shared with a different account, etc.)
|
|
93177
|
-
b. Call \`askUserQuestion\` again to re-ask for the URL and re-verify with \`${
|
|
93294
|
+
b. Call \`askUserQuestion\` again to re-ask for the URL and re-verify with \`${requestToolName2}\`
|
|
93178
93295
|
c. Repeat until verification succeeds (or the user aborts)
|
|
93179
93296
|
|
|
93180
93297
|
#### Constraints
|
|
@@ -93183,10 +93300,10 @@ var googleSheetsOnboarding = new ConnectorOnboarding({
|
|
|
93183
93300
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently.`
|
|
93184
93301
|
},
|
|
93185
93302
|
dataOverviewInstructions: {
|
|
93186
|
-
en: `1. Call ${
|
|
93187
|
-
2. For each sheet of interest, call ${
|
|
93188
|
-
ja: `1. ${
|
|
93189
|
-
2. \u4E3B\u8981\u306A\u30B7\u30FC\u30C8\u306B\u3064\u3044\u3066 ${
|
|
93303
|
+
en: `1. Call ${requestToolName2} with GET /<spreadsheetId> to fetch spreadsheet metadata (sheet names, grid properties)
|
|
93304
|
+
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`,
|
|
93305
|
+
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
|
|
93306
|
+
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`
|
|
93190
93307
|
}
|
|
93191
93308
|
});
|
|
93192
93309
|
|
|
@@ -93802,12 +93919,12 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
93802
93919
|
});
|
|
93803
93920
|
|
|
93804
93921
|
// ../connectors/src/connectors/hubspot-oauth/setup.ts
|
|
93805
|
-
var
|
|
93922
|
+
var requestToolName3 = `hubspot-oauth_${requestTool11.name}`;
|
|
93806
93923
|
var hubspotOnboarding = new ConnectorOnboarding({
|
|
93807
93924
|
connectionSetupInstructions: {
|
|
93808
93925
|
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
|
|
93809
93926
|
|
|
93810
|
-
1. \`${
|
|
93927
|
+
1. \`${requestToolName3}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
93811
93928
|
- \`method\`: \`"GET"\`
|
|
93812
93929
|
- \`path\`: \`"/account-info/v3/details"\`
|
|
93813
93930
|
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
|
|
@@ -93817,7 +93934,7 @@ var hubspotOnboarding = new ConnectorOnboarding({
|
|
|
93817
93934
|
- \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`,
|
|
93818
93935
|
en: `Follow these steps to set up the HubSpot connection.
|
|
93819
93936
|
|
|
93820
|
-
1. Call \`${
|
|
93937
|
+
1. Call \`${requestToolName3}\` to fetch account info:
|
|
93821
93938
|
- \`method\`: \`"GET"\`
|
|
93822
93939
|
- \`path\`: \`"/account-info/v3/details"\`
|
|
93823
93940
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -94091,12 +94208,12 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
94091
94208
|
});
|
|
94092
94209
|
|
|
94093
94210
|
// ../connectors/src/connectors/stripe-oauth/setup.ts
|
|
94094
|
-
var
|
|
94211
|
+
var requestToolName4 = `stripe-oauth_${requestTool12.name}`;
|
|
94095
94212
|
var stripeOnboarding = new ConnectorOnboarding({
|
|
94096
94213
|
connectionSetupInstructions: {
|
|
94097
94214
|
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
|
|
94098
94215
|
|
|
94099
|
-
1. \`${
|
|
94216
|
+
1. \`${requestToolName4}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
94100
94217
|
- \`method\`: \`"GET"\`
|
|
94101
94218
|
- \`path\`: \`"/v1/accounts"\`
|
|
94102
94219
|
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
|
|
@@ -94106,7 +94223,7 @@ var stripeOnboarding = new ConnectorOnboarding({
|
|
|
94106
94223
|
- \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`,
|
|
94107
94224
|
en: `Follow these steps to set up the Stripe connection.
|
|
94108
94225
|
|
|
94109
|
-
1. Call \`${
|
|
94226
|
+
1. Call \`${requestToolName4}\` to fetch account info:
|
|
94110
94227
|
- \`method\`: \`"GET"\`
|
|
94111
94228
|
- \`path\`: \`"/v1/accounts"\`
|
|
94112
94229
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -94381,12 +94498,12 @@ Use this tool for all Stripe API interactions: querying charges, customers, invo
|
|
|
94381
94498
|
});
|
|
94382
94499
|
|
|
94383
94500
|
// ../connectors/src/connectors/stripe-api-key/setup.ts
|
|
94384
|
-
var
|
|
94501
|
+
var requestToolName5 = `stripe-api-key_${requestTool13.name}`;
|
|
94385
94502
|
var stripeApiKeyOnboarding = new ConnectorOnboarding({
|
|
94386
94503
|
connectionSetupInstructions: {
|
|
94387
94504
|
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
|
|
94388
94505
|
|
|
94389
|
-
1. \`${
|
|
94506
|
+
1. \`${requestToolName5}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u6B8B\u9AD8\u3092\u53D6\u5F97\u3059\u308B:
|
|
94390
94507
|
- \`method\`: \`"GET"\`
|
|
94391
94508
|
- \`path\`: \`"/v1/balance"\`
|
|
94392
94509
|
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
|
|
@@ -94396,7 +94513,7 @@ var stripeApiKeyOnboarding = new ConnectorOnboarding({
|
|
|
94396
94513
|
- \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`,
|
|
94397
94514
|
en: `Follow these steps to set up the Stripe connection.
|
|
94398
94515
|
|
|
94399
|
-
1. Call \`${
|
|
94516
|
+
1. Call \`${requestToolName5}\` to fetch account balance:
|
|
94400
94517
|
- \`method\`: \`"GET"\`
|
|
94401
94518
|
- \`path\`: \`"/v1/balance"\`
|
|
94402
94519
|
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)
|
|
@@ -94406,11 +94523,11 @@ var stripeApiKeyOnboarding = new ConnectorOnboarding({
|
|
|
94406
94523
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
94407
94524
|
},
|
|
94408
94525
|
dataOverviewInstructions: {
|
|
94409
|
-
en: `1. Call ${
|
|
94410
|
-
2. Call ${
|
|
94526
|
+
en: `1. Call ${requestToolName5} with GET /v1/customers?limit=5 to explore customers structure
|
|
94527
|
+
2. Call ${requestToolName5} with GET /v1/charges?limit=5 to explore charges structure
|
|
94411
94528
|
3. Explore other endpoints (invoices, subscriptions, products) as needed`,
|
|
94412
|
-
ja: `1. ${
|
|
94413
|
-
2. ${
|
|
94529
|
+
ja: `1. ${requestToolName5} \u3067 GET /v1/customers?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u9867\u5BA2\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
94530
|
+
2. ${requestToolName5} \u3067 GET /v1/charges?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u8AB2\u91D1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
|
|
94414
94531
|
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`
|
|
94415
94532
|
}
|
|
94416
94533
|
});
|
|
@@ -94695,7 +94812,7 @@ Authentication is handled automatically via OAuth proxy.
|
|
|
94695
94812
|
});
|
|
94696
94813
|
|
|
94697
94814
|
// ../connectors/src/connectors/airtable-oauth/setup.ts
|
|
94698
|
-
var
|
|
94815
|
+
var requestToolName6 = `airtable-oauth_${requestTool14.name}`;
|
|
94699
94816
|
var airtableOauthOnboarding = new ConnectorOnboarding({
|
|
94700
94817
|
connectionSetupInstructions: {
|
|
94701
94818
|
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
|
|
@@ -94705,7 +94822,7 @@ var airtableOauthOnboarding = new ConnectorOnboarding({
|
|
|
94705
94822
|
3. \`updateConnectionParameters\` \u3092\u547C\u3073\u51FA\u3059:
|
|
94706
94823
|
- \`parameterSlug\`: \`"base-id"\`
|
|
94707
94824
|
- \`value\`: \u62BD\u51FA\u3057\u305F\u30D9\u30FC\u30B9ID
|
|
94708
|
-
4. \`${
|
|
94825
|
+
4. \`${requestToolName6}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30D9\u30FC\u30B9\u306E\u30C6\u30FC\u30D6\u30EB\u4E00\u89A7\u3092\u53D6\u5F97\u3059\u308B:
|
|
94709
94826
|
- \`method\`: \`"GET"\`
|
|
94710
94827
|
- \`path\`: \`"/meta/bases/{baseId}/tables"\`
|
|
94711
94828
|
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
|
|
@@ -94720,7 +94837,7 @@ var airtableOauthOnboarding = new ConnectorOnboarding({
|
|
|
94720
94837
|
3. Call \`updateConnectionParameters\`:
|
|
94721
94838
|
- \`parameterSlug\`: \`"base-id"\`
|
|
94722
94839
|
- \`value\`: The extracted base ID
|
|
94723
|
-
4. Call \`${
|
|
94840
|
+
4. Call \`${requestToolName6}\` to fetch the base's table list:
|
|
94724
94841
|
- \`method\`: \`"GET"\`
|
|
94725
94842
|
- \`path\`: \`"/meta/bases/{baseId}/tables"\`
|
|
94726
94843
|
5. If an error is returned, ask the user to check the base sharing settings
|
|
@@ -97622,12 +97739,12 @@ Authentication is handled automatically via OAuth proxy.`,
|
|
|
97622
97739
|
});
|
|
97623
97740
|
|
|
97624
97741
|
// ../connectors/src/connectors/shopify-oauth/setup.ts
|
|
97625
|
-
var
|
|
97742
|
+
var requestToolName7 = `shopify-oauth_${requestTool22.name}`;
|
|
97626
97743
|
var shopifyOauthOnboarding = new ConnectorOnboarding({
|
|
97627
97744
|
connectionSetupInstructions: {
|
|
97628
97745
|
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
|
|
97629
97746
|
|
|
97630
|
-
1. \`${
|
|
97747
|
+
1. \`${requestToolName7}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30B7\u30E7\u30C3\u30D7\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
97631
97748
|
- \`method\`: \`"GET"\`
|
|
97632
97749
|
- \`path\`: \`"/admin/api/2024-10/shop.json"\`
|
|
97633
97750
|
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
|
|
@@ -97637,7 +97754,7 @@ var shopifyOauthOnboarding = new ConnectorOnboarding({
|
|
|
97637
97754
|
- \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`,
|
|
97638
97755
|
en: `Follow these steps to set up the Shopify connection.
|
|
97639
97756
|
|
|
97640
|
-
1. Call \`${
|
|
97757
|
+
1. Call \`${requestToolName7}\` to fetch shop info:
|
|
97641
97758
|
- \`method\`: \`"GET"\`
|
|
97642
97759
|
- \`path\`: \`"/admin/api/2024-10/shop.json"\`
|
|
97643
97760
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -99894,12 +100011,12 @@ Pagination uses cursor-based start_cursor and page_size (max 100).`,
|
|
|
99894
100011
|
});
|
|
99895
100012
|
|
|
99896
100013
|
// ../connectors/src/connectors/notion-oauth/setup.ts
|
|
99897
|
-
var
|
|
100014
|
+
var requestToolName8 = `notion-oauth_${requestTool28.name}`;
|
|
99898
100015
|
var notionOauthOnboarding = new ConnectorOnboarding({
|
|
99899
100016
|
connectionSetupInstructions: {
|
|
99900
100017
|
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
|
|
99901
100018
|
|
|
99902
|
-
1. \`${
|
|
100019
|
+
1. \`${requestToolName8}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u3001\u30DC\u30C3\u30C8\u30E6\u30FC\u30B6\u30FC\u60C5\u5831\u3092\u53D6\u5F97\u3059\u308B:
|
|
99903
100020
|
- \`method\`: \`"GET"\`
|
|
99904
100021
|
- \`path\`: \`"/users/me"\`
|
|
99905
100022
|
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
|
|
@@ -99909,7 +100026,7 @@ var notionOauthOnboarding = new ConnectorOnboarding({
|
|
|
99909
100026
|
- \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`,
|
|
99910
100027
|
en: `Follow these steps to set up the Notion connection.
|
|
99911
100028
|
|
|
99912
|
-
1. Call \`${
|
|
100029
|
+
1. Call \`${requestToolName8}\` to fetch bot user info:
|
|
99913
100030
|
- \`method\`: \`"GET"\`
|
|
99914
100031
|
- \`path\`: \`"/users/me"\`
|
|
99915
100032
|
2. If an error is returned, ask the user to check the OAuth connection settings
|
|
@@ -102352,7 +102469,7 @@ export default async function handler(c: Context) {
|
|
|
102352
102469
|
tools: tools49
|
|
102353
102470
|
});
|
|
102354
102471
|
|
|
102355
|
-
// ../connectors/src/connectors/gmail/tools/request.ts
|
|
102472
|
+
// ../connectors/src/connectors/gmail/tools/request-with-delegation.ts
|
|
102356
102473
|
import { z as z63 } from "zod";
|
|
102357
102474
|
|
|
102358
102475
|
// ../connectors/src/connectors/gmail/parameters.ts
|
|
@@ -102360,38 +102477,40 @@ var parameters50 = {
|
|
|
102360
102477
|
serviceAccountKeyJsonBase64: new ParameterDefinition({
|
|
102361
102478
|
slug: "service-account-key-json-base64",
|
|
102362
102479
|
name: "Google Cloud Service Account JSON",
|
|
102363
|
-
description: "The service account JSON key
|
|
102480
|
+
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.",
|
|
102364
102481
|
envVarBaseKey: "GMAIL_SERVICE_ACCOUNT_JSON_BASE64",
|
|
102365
102482
|
type: "base64EncodedJson",
|
|
102366
102483
|
secret: true,
|
|
102367
102484
|
required: true
|
|
102368
102485
|
})
|
|
102369
102486
|
};
|
|
102370
|
-
var delegatedUserEmailParameter = new ParameterDefinition({
|
|
102371
|
-
slug: "delegated-user-email",
|
|
102372
|
-
name: "Delegated User Email",
|
|
102373
|
-
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.",
|
|
102374
|
-
envVarBaseKey: "GMAIL_DELEGATED_USER_EMAIL",
|
|
102375
|
-
type: "text",
|
|
102376
|
-
secret: false,
|
|
102377
|
-
required: false
|
|
102378
|
-
});
|
|
102379
102487
|
|
|
102380
|
-
// ../connectors/src/connectors/gmail/tools/request.ts
|
|
102488
|
+
// ../connectors/src/connectors/gmail/tools/request-with-delegation.ts
|
|
102381
102489
|
var BASE_URL28 = "https://gmail.googleapis.com/gmail/v1/users";
|
|
102382
102490
|
var REQUEST_TIMEOUT_MS46 = 6e4;
|
|
102491
|
+
function decodeServiceAccount3(keyJsonBase64) {
|
|
102492
|
+
const decoded = Buffer.from(keyJsonBase64, "base64").toString("utf-8");
|
|
102493
|
+
return JSON.parse(decoded);
|
|
102494
|
+
}
|
|
102383
102495
|
var inputSchema61 = z63.object({
|
|
102384
102496
|
toolUseIntent: z63.string().optional().describe(
|
|
102385
102497
|
"Brief description of what you intend to accomplish with this tool call"
|
|
102386
102498
|
),
|
|
102387
102499
|
connectionId: z63.string().describe("ID of the Gmail service account connection to use"),
|
|
102388
|
-
method: z63.enum(["GET"]).describe("HTTP method
|
|
102500
|
+
method: z63.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).describe("HTTP method"),
|
|
102389
102501
|
path: z63.string().describe(
|
|
102390
|
-
"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."
|
|
102502
|
+
"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."
|
|
102503
|
+
),
|
|
102504
|
+
subject: z63.string().describe(
|
|
102505
|
+
"Email of the Workspace user to impersonate via Domain-wide Delegation. The token will be issued as this user."
|
|
102506
|
+
),
|
|
102507
|
+
scopes: z63.array(z63.string()).describe(
|
|
102508
|
+
"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"
|
|
102391
102509
|
),
|
|
102392
102510
|
queryParams: z63.record(z63.string(), z63.string()).optional().describe(
|
|
102393
102511
|
"Query parameters to append to the URL (e.g., { q: 'from:example@gmail.com', maxResults: '10' })"
|
|
102394
|
-
)
|
|
102512
|
+
),
|
|
102513
|
+
body: z63.record(z63.string(), z63.unknown()).optional().describe("JSON request body for POST/PUT/PATCH")
|
|
102395
102514
|
});
|
|
102396
102515
|
var outputSchema61 = z63.discriminatedUnion("success", [
|
|
102397
102516
|
z63.object({
|
|
@@ -102401,17 +102520,16 @@ var outputSchema61 = z63.discriminatedUnion("success", [
|
|
|
102401
102520
|
}),
|
|
102402
102521
|
z63.object({
|
|
102403
102522
|
success: z63.literal(false),
|
|
102404
|
-
error: z63.string()
|
|
102523
|
+
error: z63.string(),
|
|
102524
|
+
serviceAccountEmail: z63.string().optional()
|
|
102405
102525
|
})
|
|
102406
102526
|
]);
|
|
102407
|
-
var
|
|
102408
|
-
name: "
|
|
102409
|
-
description: `
|
|
102410
|
-
Authentication is handled automatically using a service account with domain-wide delegation.
|
|
102411
|
-
All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me' as the userId prefix (e.g., '/me/messages').`,
|
|
102527
|
+
var requestWithDelegationTool2 = new ConnectorTool({
|
|
102528
|
+
name: "request_with_delegation",
|
|
102529
|
+
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.",
|
|
102412
102530
|
inputSchema: inputSchema61,
|
|
102413
102531
|
outputSchema: outputSchema61,
|
|
102414
|
-
async execute({ connectionId, method, path: path6, queryParams }, connections) {
|
|
102532
|
+
async execute({ connectionId, method, path: path6, subject, scopes, queryParams, body }, connections) {
|
|
102415
102533
|
const connection2 = connections.find((c6) => c6.id === connectionId);
|
|
102416
102534
|
if (!connection2) {
|
|
102417
102535
|
return {
|
|
@@ -102419,28 +102537,37 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102419
102537
|
error: `Connection ${connectionId} not found`
|
|
102420
102538
|
};
|
|
102421
102539
|
}
|
|
102540
|
+
const keyJsonBase64 = parameters50.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
102541
|
+
let serviceAccount;
|
|
102542
|
+
try {
|
|
102543
|
+
serviceAccount = decodeServiceAccount3(keyJsonBase64);
|
|
102544
|
+
} catch (err) {
|
|
102545
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
102546
|
+
return {
|
|
102547
|
+
success: false,
|
|
102548
|
+
error: `Failed to decode service account key: ${msg}`
|
|
102549
|
+
};
|
|
102550
|
+
}
|
|
102551
|
+
const serviceAccountEmail = serviceAccount.client_email;
|
|
102422
102552
|
console.log(
|
|
102423
|
-
`[connector-request] gmail/${connection2.name}: ${method} ${path6}`
|
|
102553
|
+
`[connector-request] gmail/${connection2.name}: ${method} ${path6} subject=${subject}`
|
|
102424
102554
|
);
|
|
102425
102555
|
try {
|
|
102426
102556
|
const { GoogleAuth } = await import("google-auth-library");
|
|
102427
|
-
const keyJsonBase64 = parameters50.serviceAccountKeyJsonBase64.getValue(connection2);
|
|
102428
|
-
const delegatedUserEmail = delegatedUserEmailParameter.getValue(connection2);
|
|
102429
|
-
const credentials = JSON.parse(
|
|
102430
|
-
Buffer.from(keyJsonBase64, "base64").toString("utf-8")
|
|
102431
|
-
);
|
|
102432
102557
|
const auth = new GoogleAuth({
|
|
102433
|
-
credentials
|
|
102434
|
-
|
|
102435
|
-
|
|
102436
|
-
|
|
102437
|
-
|
|
102558
|
+
credentials: {
|
|
102559
|
+
client_email: serviceAccount.client_email,
|
|
102560
|
+
private_key: serviceAccount.private_key
|
|
102561
|
+
},
|
|
102562
|
+
scopes,
|
|
102563
|
+
clientOptions: { subject }
|
|
102438
102564
|
});
|
|
102439
102565
|
const token = await auth.getAccessToken();
|
|
102440
102566
|
if (!token) {
|
|
102441
102567
|
return {
|
|
102442
102568
|
success: false,
|
|
102443
|
-
error: "Failed to obtain access token"
|
|
102569
|
+
error: "Failed to obtain access token",
|
|
102570
|
+
serviceAccountEmail
|
|
102444
102571
|
};
|
|
102445
102572
|
}
|
|
102446
102573
|
let url = `${BASE_URL28}${path6.startsWith("/") ? "" : "/"}${path6}`;
|
|
@@ -102451,18 +102578,25 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102451
102578
|
const controller = new AbortController();
|
|
102452
102579
|
const timeout = setTimeout(() => controller.abort(), REQUEST_TIMEOUT_MS46);
|
|
102453
102580
|
try {
|
|
102581
|
+
const hasBody = body != null && ["POST", "PUT", "PATCH"].includes(method);
|
|
102454
102582
|
const response = await fetch(url, {
|
|
102455
102583
|
method,
|
|
102456
102584
|
headers: {
|
|
102457
102585
|
Authorization: `Bearer ${token}`,
|
|
102458
102586
|
"Content-Type": "application/json"
|
|
102459
102587
|
},
|
|
102588
|
+
body: hasBody ? JSON.stringify(body) : void 0,
|
|
102460
102589
|
signal: controller.signal
|
|
102461
102590
|
});
|
|
102462
|
-
const data = await response.json();
|
|
102591
|
+
const data = await response.json().catch(() => ({}));
|
|
102463
102592
|
if (!response.ok) {
|
|
102464
|
-
const
|
|
102465
|
-
|
|
102593
|
+
const errorObj = data?.error;
|
|
102594
|
+
const errorMessage = errorObj?.message ?? (typeof data?.message === "string" ? data.message : `HTTP ${response.status} ${response.statusText}`);
|
|
102595
|
+
return {
|
|
102596
|
+
success: false,
|
|
102597
|
+
error: errorMessage,
|
|
102598
|
+
serviceAccountEmail
|
|
102599
|
+
};
|
|
102466
102600
|
}
|
|
102467
102601
|
return { success: true, status: response.status, data };
|
|
102468
102602
|
} finally {
|
|
@@ -102470,79 +102604,92 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102470
102604
|
}
|
|
102471
102605
|
} catch (err) {
|
|
102472
102606
|
const msg = err instanceof Error ? err.message : String(err);
|
|
102473
|
-
return {
|
|
102607
|
+
return {
|
|
102608
|
+
success: false,
|
|
102609
|
+
error: msg,
|
|
102610
|
+
serviceAccountEmail
|
|
102611
|
+
};
|
|
102474
102612
|
}
|
|
102475
102613
|
}
|
|
102476
102614
|
});
|
|
102477
102615
|
|
|
102478
102616
|
// ../connectors/src/connectors/gmail/setup.ts
|
|
102479
|
-
var
|
|
102617
|
+
var requestWithDelegationToolName2 = `gmail-service-account_${requestWithDelegationTool2.name}`;
|
|
102618
|
+
var READONLY_SCOPES2 = '["https://www.googleapis.com/auth/gmail.readonly"]';
|
|
102480
102619
|
var gmailOnboarding = new ConnectorOnboarding({
|
|
102481
102620
|
connectionSetupInstructions: {
|
|
102482
|
-
ja:
|
|
102621
|
+
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
|
|
102483
102622
|
|
|
102484
|
-
1. \`askUserQuestion\` \u3067\
|
|
102623
|
+
1. \`askUserQuestion\` \u3067\u5BFE\u8C61\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u805E\u304F:
|
|
102485
102624
|
- \`type\`: \`"freeText"\`
|
|
102486
|
-
- \`question\`: \u300CGmail\u3092\u53C2\u7167\u3059\
|
|
102487
|
-
- \`placeholder\`: \`"
|
|
102488
|
-
|
|
102489
|
-
|
|
102490
|
-
- \`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
|
|
102491
|
-
3. \`${requestToolName8}\` \u3092\u547C\u3073\u51FA\u3057\u3066\u30E6\u30FC\u30B6\u30FC\u306E\u30D7\u30ED\u30D5\u30A3\u30FC\u30EB\u3092\u53D6\u5F97\u3059\u308B:
|
|
102625
|
+
- \`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
|
|
102626
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
102627
|
+
|
|
102628
|
+
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:
|
|
102492
102629
|
- \`method\`: \`"GET"\`
|
|
102493
102630
|
- \`path\`: \`"/me/profile"\`
|
|
102494
|
-
|
|
102495
|
-
-
|
|
102496
|
-
|
|
102497
|
-
|
|
102498
|
-
|
|
102499
|
-
-
|
|
102500
|
-
-
|
|
102631
|
+
- \`subject\`: \`<email>\`
|
|
102632
|
+
- \`scopes\`: \`${READONLY_SCOPES2}\`
|
|
102633
|
+
|
|
102634
|
+
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
|
|
102635
|
+
- \`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" }]\`
|
|
102636
|
+
- \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
|
|
102637
|
+
- \u300C\u5165\u529B\u3057\u76F4\u3059\u300D: \u30B9\u30C6\u30C3\u30D7 1 \u304B\u3089\u518D\u5B9F\u884C
|
|
102638
|
+
|
|
102639
|
+
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:
|
|
102640
|
+
- \`- subject: alice@example.com\`
|
|
102641
|
+
- \`- subject: bob@example.com\`
|
|
102501
102642
|
|
|
102502
102643
|
#### \u5236\u7D04
|
|
102503
|
-
-
|
|
102504
|
-
- \u30C4\u30FC\u30EB\u9593\
|
|
102505
|
-
en: `
|
|
102644
|
+
- \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
|
|
102645
|
+
- \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`,
|
|
102646
|
+
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.
|
|
102506
102647
|
|
|
102507
|
-
1. Call \`askUserQuestion\` to
|
|
102648
|
+
1. Call \`askUserQuestion\` to collect target emails:
|
|
102508
102649
|
- \`type\`: \`"freeText"\`
|
|
102509
|
-
- \`question\`: "
|
|
102510
|
-
- \`placeholder\`: \`"
|
|
102511
|
-
|
|
102512
|
-
|
|
102513
|
-
- \`options\`: \`[{ value: <entered email>, label: <same value> }]\` (a single option is auto-selected)
|
|
102514
|
-
3. Call \`${requestToolName8}\` to get the user's profile:
|
|
102650
|
+
- \`question\`: "Enter the Google Workspace user email(s) whose Gmail mailbox you want to access (comma-separated for multiple)"
|
|
102651
|
+
- \`placeholder\`: \`"alice@example.com, bob@example.com"\`
|
|
102652
|
+
|
|
102653
|
+
2. Extract individual emails from the response. For each \`<email>\`, verify Domain-wide Delegation access by calling \`${requestWithDelegationToolName2}\`:
|
|
102515
102654
|
- \`method\`: \`"GET"\`
|
|
102516
102655
|
- \`path\`: \`"/me/profile"\`
|
|
102517
|
-
|
|
102518
|
-
-
|
|
102519
|
-
|
|
102520
|
-
|
|
102521
|
-
|
|
102522
|
-
-
|
|
102523
|
-
-
|
|
102656
|
+
- \`subject\`: \`<email>\`
|
|
102657
|
+
- \`scopes\`: \`${READONLY_SCOPES2}\`
|
|
102658
|
+
|
|
102659
|
+
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))".
|
|
102660
|
+
- \`options\`: \`[{ label: "Authorized Domain-wide Delegation \u2014 retry", value: "retry" }, { label: "Re-enter the email addresses", value: "restart" }]\`
|
|
102661
|
+
- On "retry" \u2192 re-run step 2 with the previously entered email list
|
|
102662
|
+
- On "Re-enter" \u2192 re-run step 1
|
|
102663
|
+
|
|
102664
|
+
4. Once every email succeeds, call \`finalizeSetup\`. Under \`#### \u30B9\u30B3\u30FC\u30D7\` in \`projectKnowledge\`, list each email on its own line:
|
|
102665
|
+
- \`- subject: alice@example.com\`
|
|
102666
|
+
- \`- subject: bob@example.com\`
|
|
102524
102667
|
|
|
102525
102668
|
#### Constraints
|
|
102526
|
-
-
|
|
102527
|
-
- Write
|
|
102669
|
+
- Do NOT read message bodies during setup. Only the \`/me/profile\` verification is permitted
|
|
102670
|
+
- Write at most 1 sentence between tool calls`
|
|
102528
102671
|
},
|
|
102529
102672
|
dataOverviewInstructions: {
|
|
102530
|
-
en: `
|
|
102531
|
-
|
|
102532
|
-
|
|
102533
|
-
|
|
102534
|
-
|
|
102535
|
-
|
|
102673
|
+
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.
|
|
102674
|
+
|
|
102675
|
+
1. \`method=GET\`, \`path=/me/labels\` to list labels.
|
|
102676
|
+
2. \`method=GET\`, \`path=/me/messages?maxResults=5\` to fetch recent message IDs.
|
|
102677
|
+
3. For each message id, \`method=GET\`, \`path=/me/messages/{id}?format=metadata\`.`,
|
|
102678
|
+
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
|
|
102679
|
+
|
|
102680
|
+
1. \`method=GET\`\u3001\`path=/me/labels\` \u3067\u30E9\u30D9\u30EB\u4E00\u89A7\u3092\u53D6\u5F97
|
|
102681
|
+
2. \`method=GET\`\u3001\`path=/me/messages?maxResults=5\` \u3067\u6700\u8FD1\u306E\u30E1\u30C3\u30BB\u30FC\u30B8 ID \u3092\u53D6\u5F97
|
|
102682
|
+
3. \u5404\u30E1\u30C3\u30BB\u30FC\u30B8 ID \u306B\u3064\u3044\u3066 \`method=GET\`\u3001\`path=/me/messages/{id}?format=metadata\``
|
|
102536
102683
|
}
|
|
102537
102684
|
});
|
|
102538
102685
|
|
|
102539
102686
|
// ../connectors/src/connectors/gmail/index.ts
|
|
102540
|
-
var tools50 = {
|
|
102687
|
+
var tools50 = { request_with_delegation: requestWithDelegationTool2 };
|
|
102541
102688
|
var gmailConnector = new ConnectorPlugin({
|
|
102542
102689
|
slug: "gmail",
|
|
102543
102690
|
authType: AUTH_TYPES.SERVICE_ACCOUNT,
|
|
102544
102691
|
name: "Gmail",
|
|
102545
|
-
description: "Connect to Gmail for email data access using a service account with domain-wide delegation.
|
|
102692
|
+
description: "Connect to Gmail for email data access using a service account with domain-wide delegation. Currently read-only (messages, threads, labels).",
|
|
102546
102693
|
iconUrl: "https://images.ctfassets.net/9ncizv60xc5y/4V3rfaSc1ksFIt2eHBNIwJ/7f3be41a154a6d96dcf229ed0e5858c9/Gmail_icon__2020_.svg.png",
|
|
102547
102694
|
parameters: parameters50,
|
|
102548
102695
|
releaseFlag: { dev1: true, dev2: true, prod: true },
|
|
@@ -102550,12 +102697,22 @@ var gmailConnector = new ConnectorPlugin({
|
|
|
102550
102697
|
systemPrompt: {
|
|
102551
102698
|
en: `### Tools
|
|
102552
102699
|
|
|
102553
|
-
- \`gmail-service-
|
|
102700
|
+
- \`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\`.
|
|
102701
|
+
|
|
102702
|
+
### OAuth Scopes (pass as \`scopes\` argument)
|
|
102703
|
+
|
|
102704
|
+
This connector is currently read-only. Pass:
|
|
102705
|
+
|
|
102706
|
+
- \`https://www.googleapis.com/auth/gmail.readonly\` \u2014 read-only access (profile, labels, messages, threads)
|
|
102707
|
+
|
|
102708
|
+
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\`.
|
|
102709
|
+
|
|
102710
|
+
Per-endpoint scope reference: https://developers.google.com/gmail/api/auth/scopes
|
|
102554
102711
|
|
|
102555
102712
|
### Gmail API Reference
|
|
102556
102713
|
|
|
102557
102714
|
#### Available Endpoints
|
|
102558
|
-
- GET \`/me/profile\` \u2014 Get the
|
|
102715
|
+
- GET \`/me/profile\` \u2014 Get the impersonated user's profile (email address, total messages/threads)
|
|
102559
102716
|
- GET \`/me/labels\` \u2014 List all labels in the mailbox
|
|
102560
102717
|
- GET \`/me/labels/{id}\` \u2014 Get details for a specific label
|
|
102561
102718
|
- GET \`/me/messages\` \u2014 List messages (returns IDs only; use format param on individual messages)
|
|
@@ -102580,7 +102737,7 @@ var gmailConnector = new ConnectorPlugin({
|
|
|
102580
102737
|
- \`raw\` \u2014 Full RFC 2822 formatted message in base64url
|
|
102581
102738
|
|
|
102582
102739
|
#### Tips
|
|
102583
|
-
- Always use \`/me\` as the userId \u2014 it refers to the
|
|
102740
|
+
- Always use \`/me\` as the userId in the path \u2014 it refers to the user you passed as \`subject\`
|
|
102584
102741
|
- List endpoints return only IDs; fetch individual resources for details
|
|
102585
102742
|
- Use \`format=metadata\` to efficiently get subject/sender without full body
|
|
102586
102743
|
- Message body content is base64url encoded in \`payload.body.data\` or nested \`payload.parts[].body.data\`
|
|
@@ -102591,6 +102748,12 @@ var gmailConnector = new ConnectorPlugin({
|
|
|
102591
102748
|
|
|
102592
102749
|
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.
|
|
102593
102750
|
|
|
102751
|
+
SDK methods (client created via \`connection(connectionId)\`):
|
|
102752
|
+
|
|
102753
|
+
- \`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.
|
|
102754
|
+
|
|
102755
|
+
The method returns a standard \`Response\`. Read the body with \`.json()\`. Same path conventions as the tool.
|
|
102756
|
+
|
|
102594
102757
|
#### Example
|
|
102595
102758
|
|
|
102596
102759
|
\`\`\`ts
|
|
@@ -102598,37 +102761,51 @@ import { connection } from "@squadbase/vite-server/connectors/gmail";
|
|
|
102598
102761
|
|
|
102599
102762
|
const gmail = connection("<connectionId>");
|
|
102600
102763
|
|
|
102601
|
-
//
|
|
102602
|
-
const
|
|
102764
|
+
// Pick the impersonated user from project knowledge ("#### \u30B9\u30B3\u30FC\u30D7").
|
|
102765
|
+
const subject = "alice@example.com";
|
|
102766
|
+
const READ = ["https://www.googleapis.com/auth/gmail.readonly"];
|
|
102767
|
+
|
|
102768
|
+
const profileRes = await gmail.requestWithDelegation("/me/profile", {
|
|
102769
|
+
subject,
|
|
102770
|
+
scopes: READ,
|
|
102771
|
+
});
|
|
102772
|
+
const profile = await profileRes.json();
|
|
102603
102773
|
console.log(profile.emailAddress, profile.messagesTotal);
|
|
102604
102774
|
|
|
102605
|
-
|
|
102606
|
-
|
|
102607
|
-
|
|
102608
|
-
|
|
102609
|
-
|
|
102610
|
-
|
|
102775
|
+
const messagesRes = await gmail.requestWithDelegation(
|
|
102776
|
+
"/me/messages?maxResults=10",
|
|
102777
|
+
{ subject, scopes: READ },
|
|
102778
|
+
);
|
|
102779
|
+
const messages = await messagesRes.json();
|
|
102780
|
+
|
|
102781
|
+
for (const msg of messages.messages ?? []) {
|
|
102782
|
+
const detailRes = await gmail.requestWithDelegation(
|
|
102783
|
+
\`/me/messages/\${msg.id}?format=metadata\`,
|
|
102784
|
+
{ subject, scopes: READ },
|
|
102785
|
+
);
|
|
102786
|
+
const detail = await detailRes.json();
|
|
102787
|
+
const subjectHeader = detail.payload.headers.find(h => h.name === "Subject")?.value;
|
|
102788
|
+
console.log(subjectHeader, detail.snippet);
|
|
102611
102789
|
}
|
|
102790
|
+
\`\`\``,
|
|
102791
|
+
ja: `### \u30C4\u30FC\u30EB
|
|
102612
102792
|
|
|
102613
|
-
|
|
102614
|
-
const results = await gmail.listMessages({ q: "from:boss@company.com is:unread" });
|
|
102793
|
+
- \`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
|
|
102615
102794
|
|
|
102616
|
-
|
|
102617
|
-
const labels = await gmail.listLabels();
|
|
102618
|
-
labels.labels.forEach(l => console.log(l.name, l.messagesTotal));
|
|
102795
|
+
### OAuth \u30B9\u30B3\u30FC\u30D7 (\`scopes\` \u5F15\u6570\u3067\u6E21\u3059)
|
|
102619
102796
|
|
|
102620
|
-
|
|
102621
|
-
|
|
102622
|
-
|
|
102623
|
-
|
|
102624
|
-
|
|
102797
|
+
\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:
|
|
102798
|
+
|
|
102799
|
+
- \`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
|
|
102800
|
+
|
|
102801
|
+
\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
|
|
102625
102802
|
|
|
102626
|
-
|
|
102803
|
+
\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
|
|
102627
102804
|
|
|
102628
102805
|
### Gmail API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
102629
102806
|
|
|
102630
102807
|
#### \u5229\u7528\u53EF\u80FD\u306A\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8
|
|
102631
|
-
- GET \`/me/profile\` \u2014 \
|
|
102808
|
+
- 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
|
|
102632
102809
|
- GET \`/me/labels\` \u2014 \u30E1\u30FC\u30EB\u30DC\u30C3\u30AF\u30B9\u306E\u5168\u30E9\u30D9\u30EB\u3092\u4E00\u89A7
|
|
102633
102810
|
- GET \`/me/labels/{id}\` \u2014 \u7279\u5B9A\u30E9\u30D9\u30EB\u306E\u8A73\u7D30\u3092\u53D6\u5F97
|
|
102634
102811
|
- 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
|
|
@@ -102653,7 +102830,7 @@ thread.messages.forEach(m => console.log(m.snippet));
|
|
|
102653
102830
|
- \`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
|
|
102654
102831
|
|
|
102655
102832
|
#### \u30D2\u30F3\u30C8
|
|
102656
|
-
- userId\u306B\u306F\u5E38\u306B \`/me\` \u3092\u4F7F\u7528 \u2014 \
|
|
102833
|
+
- \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
|
|
102657
102834
|
- \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
|
|
102658
102835
|
- \u4EF6\u540D/\u9001\u4FE1\u8005\u3092\u52B9\u7387\u7684\u306B\u53D6\u5F97\u3059\u308B\u306B\u306F \`format=metadata\` \u3092\u4F7F\u7528\u3057\u307E\u3059
|
|
102659
102836
|
- \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
|
|
@@ -102664,6 +102841,12 @@ thread.messages.forEach(m => console.log(m.snippet));
|
|
|
102664
102841
|
|
|
102665
102842
|
\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
|
|
102666
102843
|
|
|
102844
|
+
SDK\u30E1\u30BD\u30C3\u30C9 (\`connection(connectionId)\` \u3067\u4F5C\u6210\u3057\u305F\u30AF\u30E9\u30A4\u30A2\u30F3\u30C8):
|
|
102845
|
+
|
|
102846
|
+
- \`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
|
|
102847
|
+
|
|
102848
|
+
\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
|
|
102849
|
+
|
|
102667
102850
|
#### Example
|
|
102668
102851
|
|
|
102669
102852
|
\`\`\`ts
|
|
@@ -102671,86 +102854,35 @@ import { connection } from "@squadbase/vite-server/connectors/gmail";
|
|
|
102671
102854
|
|
|
102672
102855
|
const gmail = connection("<connectionId>");
|
|
102673
102856
|
|
|
102674
|
-
//
|
|
102675
|
-
const
|
|
102676
|
-
|
|
102857
|
+
// \u4EE3\u7406\u5BFE\u8C61\u30E6\u30FC\u30B6\u30FC\u306F Project Knowledge ("#### \u30B9\u30B3\u30FC\u30D7") \u304B\u3089\u9078\u3076
|
|
102858
|
+
const subject = "alice@example.com";
|
|
102859
|
+
const READ = ["https://www.googleapis.com/auth/gmail.readonly"];
|
|
102677
102860
|
|
|
102678
|
-
|
|
102679
|
-
|
|
102680
|
-
|
|
102681
|
-
|
|
102682
|
-
|
|
102683
|
-
|
|
102684
|
-
}
|
|
102685
|
-
|
|
102686
|
-
// Search messages
|
|
102687
|
-
const results = await gmail.listMessages({ q: "from:boss@company.com is:unread" });
|
|
102861
|
+
const profileRes = await gmail.requestWithDelegation("/me/profile", {
|
|
102862
|
+
subject,
|
|
102863
|
+
scopes: READ,
|
|
102864
|
+
});
|
|
102865
|
+
const profile = await profileRes.json();
|
|
102866
|
+
console.log(profile.emailAddress, profile.messagesTotal);
|
|
102688
102867
|
|
|
102689
|
-
|
|
102690
|
-
|
|
102691
|
-
|
|
102868
|
+
const messagesRes = await gmail.requestWithDelegation(
|
|
102869
|
+
"/me/messages?maxResults=10",
|
|
102870
|
+
{ subject, scopes: READ },
|
|
102871
|
+
);
|
|
102872
|
+
const messages = await messagesRes.json();
|
|
102692
102873
|
|
|
102693
|
-
|
|
102694
|
-
const
|
|
102695
|
-
|
|
102874
|
+
for (const msg of messages.messages ?? []) {
|
|
102875
|
+
const detailRes = await gmail.requestWithDelegation(
|
|
102876
|
+
\`/me/messages/\${msg.id}?format=metadata\`,
|
|
102877
|
+
{ subject, scopes: READ },
|
|
102878
|
+
);
|
|
102879
|
+
const detail = await detailRes.json();
|
|
102880
|
+
const subjectHeader = detail.payload.headers.find(h => h.name === "Subject")?.value;
|
|
102881
|
+
console.log(subjectHeader, detail.snippet);
|
|
102882
|
+
}
|
|
102696
102883
|
\`\`\``
|
|
102697
102884
|
},
|
|
102698
|
-
tools: tools50
|
|
102699
|
-
async checkConnection(params, _config) {
|
|
102700
|
-
const { GoogleAuth } = await import("google-auth-library");
|
|
102701
|
-
const credentials = JSON.parse(
|
|
102702
|
-
Buffer.from(
|
|
102703
|
-
params[parameters50.serviceAccountKeyJsonBase64.slug],
|
|
102704
|
-
"base64"
|
|
102705
|
-
).toString("utf-8")
|
|
102706
|
-
);
|
|
102707
|
-
const delegatedUserEmail = params[delegatedUserEmailParameter.slug];
|
|
102708
|
-
if (!delegatedUserEmail) {
|
|
102709
|
-
if (!credentials.client_email || !credentials.private_key) {
|
|
102710
|
-
return {
|
|
102711
|
-
success: false,
|
|
102712
|
-
error: "Service account JSON must contain client_email and private_key"
|
|
102713
|
-
};
|
|
102714
|
-
}
|
|
102715
|
-
return { success: true };
|
|
102716
|
-
}
|
|
102717
|
-
const auth = new GoogleAuth({
|
|
102718
|
-
credentials,
|
|
102719
|
-
scopes: ["https://www.googleapis.com/auth/gmail.readonly"],
|
|
102720
|
-
clientOptions: {
|
|
102721
|
-
subject: delegatedUserEmail
|
|
102722
|
-
}
|
|
102723
|
-
});
|
|
102724
|
-
try {
|
|
102725
|
-
const token = await auth.getAccessToken();
|
|
102726
|
-
if (!token) {
|
|
102727
|
-
return {
|
|
102728
|
-
success: false,
|
|
102729
|
-
error: "Failed to obtain access token"
|
|
102730
|
-
};
|
|
102731
|
-
}
|
|
102732
|
-
const res = await fetch(
|
|
102733
|
-
"https://gmail.googleapis.com/gmail/v1/users/me/profile",
|
|
102734
|
-
{
|
|
102735
|
-
method: "GET",
|
|
102736
|
-
headers: { Authorization: `Bearer ${token}` }
|
|
102737
|
-
}
|
|
102738
|
-
);
|
|
102739
|
-
if (!res.ok) {
|
|
102740
|
-
const errorText = await res.text().catch(() => res.statusText);
|
|
102741
|
-
return {
|
|
102742
|
-
success: false,
|
|
102743
|
-
error: `Gmail API failed: HTTP ${res.status} ${errorText}`
|
|
102744
|
-
};
|
|
102745
|
-
}
|
|
102746
|
-
return { success: true };
|
|
102747
|
-
} catch (error2) {
|
|
102748
|
-
return {
|
|
102749
|
-
success: false,
|
|
102750
|
-
error: error2 instanceof Error ? error2.message : String(error2)
|
|
102751
|
-
};
|
|
102752
|
-
}
|
|
102753
|
-
}
|
|
102885
|
+
tools: tools50
|
|
102754
102886
|
});
|
|
102755
102887
|
|
|
102756
102888
|
// ../connectors/src/connectors/gmail-oauth/tools/request.ts
|
|
@@ -102812,7 +102944,7 @@ var outputSchema62 = z64.discriminatedUnion("success", [
|
|
|
102812
102944
|
error: z64.string()
|
|
102813
102945
|
})
|
|
102814
102946
|
]);
|
|
102815
|
-
var
|
|
102947
|
+
var requestTool35 = new ConnectorTool({
|
|
102816
102948
|
name: "request",
|
|
102817
102949
|
description: `Send authenticated GET requests to the Gmail API v1.
|
|
102818
102950
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -102870,7 +103002,7 @@ All paths are relative to https://gmail.googleapis.com/gmail/v1/users. Use '/me'
|
|
|
102870
103002
|
});
|
|
102871
103003
|
|
|
102872
103004
|
// ../connectors/src/connectors/gmail-oauth/setup.ts
|
|
102873
|
-
var requestToolName9 = `gmail-oauth_${
|
|
103005
|
+
var requestToolName9 = `gmail-oauth_${requestTool35.name}`;
|
|
102874
103006
|
var gmailOnboarding2 = new ConnectorOnboarding({
|
|
102875
103007
|
connectionSetupInstructions: {
|
|
102876
103008
|
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
|
|
@@ -102914,7 +103046,7 @@ var gmailOnboarding2 = new ConnectorOnboarding({
|
|
|
102914
103046
|
var parameters51 = {};
|
|
102915
103047
|
|
|
102916
103048
|
// ../connectors/src/connectors/gmail-oauth/index.ts
|
|
102917
|
-
var tools51 = { request:
|
|
103049
|
+
var tools51 = { request: requestTool35 };
|
|
102918
103050
|
var gmailOauthConnector = new ConnectorPlugin({
|
|
102919
103051
|
slug: "gmail",
|
|
102920
103052
|
authType: AUTH_TYPES.OAUTH,
|
|
@@ -103349,7 +103481,7 @@ var outputSchema64 = z66.discriminatedUnion("success", [
|
|
|
103349
103481
|
error: z66.string()
|
|
103350
103482
|
})
|
|
103351
103483
|
]);
|
|
103352
|
-
var
|
|
103484
|
+
var requestTool36 = new ConnectorTool({
|
|
103353
103485
|
name: "request",
|
|
103354
103486
|
description: `Send authenticated requests to the LinkedIn Marketing API (REST).
|
|
103355
103487
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -103425,7 +103557,7 @@ Required headers (LinkedIn-Version, X-Restli-Protocol-Version) are set automatic
|
|
|
103425
103557
|
|
|
103426
103558
|
// ../connectors/src/connectors/linkedin-ads/index.ts
|
|
103427
103559
|
var tools52 = {
|
|
103428
|
-
request:
|
|
103560
|
+
request: requestTool36,
|
|
103429
103561
|
listAdAccounts: listAdAccountsTool3
|
|
103430
103562
|
};
|
|
103431
103563
|
var linkedinAdsConnector = new ConnectorPlugin({
|
|
@@ -103734,7 +103866,7 @@ var outputSchema65 = z67.discriminatedUnion("success", [
|
|
|
103734
103866
|
error: z67.string()
|
|
103735
103867
|
})
|
|
103736
103868
|
]);
|
|
103737
|
-
var
|
|
103869
|
+
var requestTool37 = new ConnectorTool({
|
|
103738
103870
|
name: "request",
|
|
103739
103871
|
description: `Send authenticated requests to the Zendesk Support API.
|
|
103740
103872
|
Authentication is handled automatically using email/token Basic auth.
|
|
@@ -103790,7 +103922,7 @@ Zendesk uses cursor-based pagination with page[size] and page[after] parameters.
|
|
|
103790
103922
|
});
|
|
103791
103923
|
|
|
103792
103924
|
// ../connectors/src/connectors/zendesk/index.ts
|
|
103793
|
-
var tools53 = { request:
|
|
103925
|
+
var tools53 = { request: requestTool37 };
|
|
103794
103926
|
var zendeskConnector = new ConnectorPlugin({
|
|
103795
103927
|
slug: "zendesk",
|
|
103796
103928
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -104034,7 +104166,7 @@ var outputSchema66 = z68.discriminatedUnion("success", [
|
|
|
104034
104166
|
error: z68.string()
|
|
104035
104167
|
})
|
|
104036
104168
|
]);
|
|
104037
|
-
var
|
|
104169
|
+
var requestTool38 = new ConnectorTool({
|
|
104038
104170
|
name: "request",
|
|
104039
104171
|
description: `Send authenticated requests to the Zendesk Support API.
|
|
104040
104172
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -104095,7 +104227,7 @@ Zendesk uses cursor-based pagination with page[size] and page[after] parameters.
|
|
|
104095
104227
|
});
|
|
104096
104228
|
|
|
104097
104229
|
// ../connectors/src/connectors/zendesk-oauth/setup.ts
|
|
104098
|
-
var requestToolName10 = `zendesk-oauth_${
|
|
104230
|
+
var requestToolName10 = `zendesk-oauth_${requestTool38.name}`;
|
|
104099
104231
|
var zendeskOauthOnboarding = new ConnectorOnboarding({
|
|
104100
104232
|
connectionSetupInstructions: {
|
|
104101
104233
|
en: `Follow these steps to set up the Zendesk connection.
|
|
@@ -104135,7 +104267,7 @@ var zendeskOauthOnboarding = new ConnectorOnboarding({
|
|
|
104135
104267
|
var parameters54 = {};
|
|
104136
104268
|
|
|
104137
104269
|
// ../connectors/src/connectors/zendesk-oauth/index.ts
|
|
104138
|
-
var tools54 = { request:
|
|
104270
|
+
var tools54 = { request: requestTool38 };
|
|
104139
104271
|
var zendeskOauthConnector = new ConnectorPlugin({
|
|
104140
104272
|
slug: "zendesk",
|
|
104141
104273
|
authType: AUTH_TYPES.OAUTH,
|
|
@@ -104351,7 +104483,7 @@ var outputSchema67 = z69.discriminatedUnion("success", [
|
|
|
104351
104483
|
error: z69.string()
|
|
104352
104484
|
})
|
|
104353
104485
|
]);
|
|
104354
|
-
var
|
|
104486
|
+
var requestTool39 = new ConnectorTool({
|
|
104355
104487
|
name: "request",
|
|
104356
104488
|
description: `Send authenticated requests to the Intercom API.
|
|
104357
104489
|
Authentication is handled automatically using the Access Token (Bearer token).
|
|
@@ -104407,7 +104539,7 @@ The Intercom-Version header is set to 2.11 automatically.`,
|
|
|
104407
104539
|
});
|
|
104408
104540
|
|
|
104409
104541
|
// ../connectors/src/connectors/intercom/index.ts
|
|
104410
|
-
var tools55 = { request:
|
|
104542
|
+
var tools55 = { request: requestTool39 };
|
|
104411
104543
|
var intercomConnector = new ConnectorPlugin({
|
|
104412
104544
|
slug: "intercom",
|
|
104413
104545
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -104672,7 +104804,7 @@ var outputSchema68 = z70.discriminatedUnion("success", [
|
|
|
104672
104804
|
error: z70.string()
|
|
104673
104805
|
})
|
|
104674
104806
|
]);
|
|
104675
|
-
var
|
|
104807
|
+
var requestTool40 = new ConnectorTool({
|
|
104676
104808
|
name: "request",
|
|
104677
104809
|
description: `Send authenticated requests to the Intercom API.
|
|
104678
104810
|
Authentication is handled automatically via OAuth proxy.
|
|
@@ -104735,7 +104867,7 @@ Search endpoints (contacts/search, conversations/search) use POST with a query o
|
|
|
104735
104867
|
});
|
|
104736
104868
|
|
|
104737
104869
|
// ../connectors/src/connectors/intercom-oauth/setup.ts
|
|
104738
|
-
var requestToolName11 = `intercom-oauth_${
|
|
104870
|
+
var requestToolName11 = `intercom-oauth_${requestTool40.name}`;
|
|
104739
104871
|
var intercomOauthOnboarding = new ConnectorOnboarding({
|
|
104740
104872
|
connectionSetupInstructions: {
|
|
104741
104873
|
en: `Follow these steps to set up the Intercom connection.
|
|
@@ -104775,7 +104907,7 @@ var intercomOauthOnboarding = new ConnectorOnboarding({
|
|
|
104775
104907
|
var parameters56 = {};
|
|
104776
104908
|
|
|
104777
104909
|
// ../connectors/src/connectors/intercom-oauth/index.ts
|
|
104778
|
-
var tools56 = { request:
|
|
104910
|
+
var tools56 = { request: requestTool40 };
|
|
104779
104911
|
var intercomOauthConnector = new ConnectorPlugin({
|
|
104780
104912
|
slug: "intercom",
|
|
104781
104913
|
authType: AUTH_TYPES.OAUTH,
|
|
@@ -105027,7 +105159,7 @@ var outputSchema69 = z71.discriminatedUnion("success", [
|
|
|
105027
105159
|
error: z71.string()
|
|
105028
105160
|
})
|
|
105029
105161
|
]);
|
|
105030
|
-
var
|
|
105162
|
+
var requestTool41 = new ConnectorTool({
|
|
105031
105163
|
name: "request",
|
|
105032
105164
|
description: `Send authenticated requests to the Mixpanel REST API.
|
|
105033
105165
|
Authentication is handled automatically using Basic auth (Service Account username + secret).
|
|
@@ -105121,7 +105253,7 @@ Rate limit: 60 queries/hour, 5 concurrent queries for Query API.`,
|
|
|
105121
105253
|
});
|
|
105122
105254
|
|
|
105123
105255
|
// ../connectors/src/connectors/mixpanel/index.ts
|
|
105124
|
-
var tools57 = { request:
|
|
105256
|
+
var tools57 = { request: requestTool41 };
|
|
105125
105257
|
var mixpanelConnector = new ConnectorPlugin({
|
|
105126
105258
|
slug: "mixpanel",
|
|
105127
105259
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -105315,7 +105447,7 @@ var outputSchema70 = z72.discriminatedUnion("success", [
|
|
|
105315
105447
|
error: z72.string()
|
|
105316
105448
|
})
|
|
105317
105449
|
]);
|
|
105318
|
-
var
|
|
105450
|
+
var requestTool42 = new ConnectorTool({
|
|
105319
105451
|
name: "request",
|
|
105320
105452
|
description: `Send authenticated requests to the Grafana HTTP API.
|
|
105321
105453
|
Authentication is handled automatically using the configured API Key or Service Account Token via Bearer token.
|
|
@@ -105371,7 +105503,7 @@ The path must start with '/' and is appended to the configured Grafana instance
|
|
|
105371
105503
|
});
|
|
105372
105504
|
|
|
105373
105505
|
// ../connectors/src/connectors/grafana/index.ts
|
|
105374
|
-
var tools58 = { request:
|
|
105506
|
+
var tools58 = { request: requestTool42 };
|
|
105375
105507
|
var grafanaConnector = new ConnectorPlugin({
|
|
105376
105508
|
slug: "grafana",
|
|
105377
105509
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -105559,7 +105691,7 @@ var outputSchema71 = z73.discriminatedUnion("success", [
|
|
|
105559
105691
|
error: z73.string()
|
|
105560
105692
|
})
|
|
105561
105693
|
]);
|
|
105562
|
-
var
|
|
105694
|
+
var requestTool43 = new ConnectorTool({
|
|
105563
105695
|
name: "request",
|
|
105564
105696
|
description: `Send authenticated requests to the Backlog REST API (v2).
|
|
105565
105697
|
Authentication is handled automatically by appending the apiKey query parameter to every request.
|
|
@@ -105616,7 +105748,7 @@ Do NOT include the apiKey parameter yourself; it is injected automatically.`,
|
|
|
105616
105748
|
});
|
|
105617
105749
|
|
|
105618
105750
|
// ../connectors/src/connectors/backlog/index.ts
|
|
105619
|
-
var tools59 = { request:
|
|
105751
|
+
var tools59 = { request: requestTool43 };
|
|
105620
105752
|
var backlogConnector = new ConnectorPlugin({
|
|
105621
105753
|
slug: "backlog",
|
|
105622
105754
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -105826,7 +105958,7 @@ var outputSchema72 = z74.discriminatedUnion("success", [
|
|
|
105826
105958
|
error: z74.string()
|
|
105827
105959
|
})
|
|
105828
105960
|
]);
|
|
105829
|
-
var
|
|
105961
|
+
var requestTool44 = new ConnectorTool({
|
|
105830
105962
|
name: "request",
|
|
105831
105963
|
description: `Send authenticated requests to the Gamma REST API.
|
|
105832
105964
|
Authentication is handled automatically using the API Key (X-API-KEY header).
|
|
@@ -106054,7 +106186,7 @@ Gamma does NOT support image uploads. To visualize data, embed raw numbers direc
|
|
|
106054
106186
|
});
|
|
106055
106187
|
|
|
106056
106188
|
// ../connectors/src/connectors/gamma/index.ts
|
|
106057
|
-
var tools60 = { request:
|
|
106189
|
+
var tools60 = { request: requestTool44, generate: generateTool };
|
|
106058
106190
|
var gammaConnector = new ConnectorPlugin({
|
|
106059
106191
|
slug: "gamma",
|
|
106060
106192
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -106277,7 +106409,7 @@ var outputSchema74 = z76.discriminatedUnion("success", [
|
|
|
106277
106409
|
error: z76.string()
|
|
106278
106410
|
})
|
|
106279
106411
|
]);
|
|
106280
|
-
var
|
|
106412
|
+
var requestTool45 = new ConnectorTool({
|
|
106281
106413
|
name: "request",
|
|
106282
106414
|
description: `Send authenticated requests to the Sentry API.
|
|
106283
106415
|
Supports GET, POST, PUT, and DELETE methods.
|
|
@@ -106334,7 +106466,7 @@ Authentication is handled automatically via Bearer token.
|
|
|
106334
106466
|
});
|
|
106335
106467
|
|
|
106336
106468
|
// ../connectors/src/connectors/sentry/index.ts
|
|
106337
|
-
var tools61 = { request:
|
|
106469
|
+
var tools61 = { request: requestTool45 };
|
|
106338
106470
|
var sentryConnector = new ConnectorPlugin({
|
|
106339
106471
|
slug: "sentry",
|
|
106340
106472
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -106623,7 +106755,7 @@ function normalizeInstanceUrl(raw) {
|
|
|
106623
106755
|
}
|
|
106624
106756
|
return trimmed;
|
|
106625
106757
|
}
|
|
106626
|
-
var
|
|
106758
|
+
var requestTool46 = new ConnectorTool({
|
|
106627
106759
|
name: "request",
|
|
106628
106760
|
description: `Send authenticated requests to the Salesforce REST API.
|
|
106629
106761
|
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.
|
|
@@ -106720,7 +106852,7 @@ Prefer SOQL via the /query endpoint for filtered, joined, or aggregated reads ra
|
|
|
106720
106852
|
});
|
|
106721
106853
|
|
|
106722
106854
|
// ../connectors/src/connectors/salesforce/index.ts
|
|
106723
|
-
var tools62 = { request:
|
|
106855
|
+
var tools62 = { request: requestTool46 };
|
|
106724
106856
|
var salesforceConnector = new ConnectorPlugin({
|
|
106725
106857
|
slug: "salesforce",
|
|
106726
106858
|
authType: AUTH_TYPES.API_KEY,
|
|
@@ -107007,7 +107139,7 @@ var outputSchema76 = z78.discriminatedUnion("success", [
|
|
|
107007
107139
|
error: z78.string()
|
|
107008
107140
|
})
|
|
107009
107141
|
]);
|
|
107010
|
-
var
|
|
107142
|
+
var requestTool47 = new ConnectorTool({
|
|
107011
107143
|
name: "request",
|
|
107012
107144
|
description: `Send authenticated requests to the InfluxDB HTTP API.
|
|
107013
107145
|
Authentication is handled automatically using the API token (\`Authorization: Token {token}\`). The instance URL is resolved from the connection.
|
|
@@ -107085,7 +107217,7 @@ For read-only data exploration prefer SQL (InfluxDB 3) or InfluxQL queries \u201
|
|
|
107085
107217
|
});
|
|
107086
107218
|
|
|
107087
107219
|
// ../connectors/src/connectors/influxdb/index.ts
|
|
107088
|
-
var tools63 = { request:
|
|
107220
|
+
var tools63 = { request: requestTool47 };
|
|
107089
107221
|
var influxdbConnector = new ConnectorPlugin({
|
|
107090
107222
|
slug: "influxdb",
|
|
107091
107223
|
authType: AUTH_TYPES.API_KEY,
|