@squadbase/vite-server 0.1.17-dev.a9ddcfa → 0.1.17-dev.e4768d1
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 +8941 -3700
- package/dist/connectors/airtable-oauth.js +87 -23
- package/dist/connectors/airtable.js +130 -23
- package/dist/connectors/amplitude.js +47 -23
- package/dist/connectors/anthropic.js +41 -17
- package/dist/connectors/asana.js +76 -25
- package/dist/connectors/attio.js +69 -28
- package/dist/connectors/aws-billing.js +47 -23
- package/dist/connectors/azure-sql.js +322 -25
- package/dist/connectors/backlog-api-key.js +79 -30
- package/dist/connectors/clickup.js +89 -25
- package/dist/connectors/cosmosdb.js +51 -27
- package/dist/connectors/customerio.js +47 -23
- package/dist/connectors/dbt.js +725 -40
- package/dist/connectors/freshdesk.js +121 -23
- package/dist/connectors/freshsales.js +47 -23
- package/dist/connectors/freshservice.js +47 -23
- package/dist/connectors/gamma.js +54 -30
- package/dist/connectors/gemini.js +41 -17
- package/dist/connectors/github.js +51 -27
- package/dist/connectors/gmail-oauth.js +42 -23
- package/dist/connectors/gmail.js +43 -19
- package/dist/connectors/google-ads.js +47 -23
- package/dist/connectors/google-analytics-oauth.js +191 -40
- package/dist/connectors/google-analytics.js +529 -111
- package/dist/connectors/google-audit-log.js +43 -19
- package/dist/connectors/google-calendar-oauth.js +100 -30
- package/dist/connectors/google-calendar.js +100 -26
- package/dist/connectors/google-docs.js +42 -23
- package/dist/connectors/google-drive.js +64 -23
- package/dist/connectors/google-search-console-oauth.js +165 -32
- package/dist/connectors/google-sheets.js +142 -199
- package/dist/connectors/google-slides.js +42 -23
- package/dist/connectors/grafana.js +84 -25
- package/dist/connectors/hackernews.d.ts +5 -0
- package/dist/connectors/hackernews.js +909 -0
- package/dist/connectors/hubspot-oauth.js +73 -22
- package/dist/connectors/hubspot.js +64 -24
- package/dist/connectors/influxdb.js +47 -23
- package/dist/connectors/intercom-oauth.js +104 -25
- package/dist/connectors/intercom.js +51 -27
- package/dist/connectors/jdbc.js +76 -25
- package/dist/connectors/jira-api-key.js +107 -26
- package/dist/connectors/kintone-api-token.js +105 -33
- package/dist/connectors/kintone.js +182 -26
- package/dist/connectors/linear.js +93 -27
- package/dist/connectors/linkedin-ads.js +80 -29
- package/dist/connectors/mailchimp-oauth.js +45 -21
- package/dist/connectors/mailchimp.js +45 -21
- package/dist/connectors/meta-ads-oauth.js +72 -29
- package/dist/connectors/meta-ads.js +74 -29
- package/dist/connectors/mixpanel.js +47 -23
- package/dist/connectors/monday.js +48 -24
- package/dist/connectors/mongodb.js +47 -23
- package/dist/connectors/notion-oauth.js +92 -24
- package/dist/connectors/notion.js +144 -26
- package/dist/connectors/openai.js +41 -17
- package/dist/connectors/oracle.js +316 -26
- package/dist/connectors/outlook-oauth.js +53 -34
- package/dist/connectors/powerbi-oauth.js +45 -26
- package/dist/connectors/salesforce.js +150 -24
- package/dist/connectors/semrush.js +45 -21
- package/dist/connectors/sentry.js +75 -25
- package/dist/connectors/shopify-oauth.js +75 -23
- package/dist/connectors/shopify.js +47 -23
- package/dist/connectors/sqlserver.js +322 -25
- package/dist/connectors/stripe-api-key.js +105 -30
- package/dist/connectors/stripe-oauth.js +102 -32
- package/dist/connectors/supabase.js +315 -21
- package/dist/connectors/tableau.js +54 -30
- package/dist/connectors/tiktok-ads.js +76 -31
- package/dist/connectors/wix-store.js +47 -23
- package/dist/connectors/x.d.ts +5 -0
- package/dist/connectors/x.js +951 -0
- package/dist/connectors/zendesk-oauth.js +87 -25
- package/dist/connectors/zendesk.js +51 -27
- package/dist/index.js +9005 -3709
- package/dist/main.js +9005 -3709
- package/dist/vite-plugin.js +8939 -3698
- package/package.json +12 -4
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __esm = (fn, res) => function __init() {
|
|
3
|
-
|
|
2
|
+
var __esm = (fn, res, err) => function __init() {
|
|
3
|
+
if (err) throw err[0];
|
|
4
|
+
try {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
} catch (e) {
|
|
7
|
+
throw err = [e], e;
|
|
8
|
+
}
|
|
4
9
|
};
|
|
5
10
|
|
|
6
11
|
// ../connectors/src/parameter-definition.ts
|
|
@@ -325,6 +330,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
325
330
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
326
331
|
*/
|
|
327
332
|
setup;
|
|
333
|
+
/**
|
|
334
|
+
* 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
|
|
335
|
+
* メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
|
|
336
|
+
* {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
|
|
337
|
+
* 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
|
|
338
|
+
* `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
|
|
339
|
+
* coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
|
|
340
|
+
*/
|
|
341
|
+
introspect;
|
|
328
342
|
/**
|
|
329
343
|
* Opt-out of the default "verify before save" behavior on connection
|
|
330
344
|
* creation. The backend invokes `checkConnection` synchronously while
|
|
@@ -339,6 +353,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
339
353
|
* the default verify-on-create behavior without opt-in.
|
|
340
354
|
*/
|
|
341
355
|
skipConnectionCheckOnCreate;
|
|
356
|
+
/**
|
|
357
|
+
* 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
|
|
358
|
+
* read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
|
|
359
|
+
* recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
|
|
360
|
+
* driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
|
|
361
|
+
* 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
|
|
362
|
+
*/
|
|
363
|
+
surveyProbes;
|
|
342
364
|
constructor(config) {
|
|
343
365
|
this.slug = config.slug;
|
|
344
366
|
this.authType = config.authType;
|
|
@@ -356,7 +378,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
356
378
|
this.query = config.query;
|
|
357
379
|
this.checkConnection = config.checkConnection;
|
|
358
380
|
this.setup = config.setup;
|
|
381
|
+
this.introspect = config.introspect;
|
|
359
382
|
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
383
|
+
this.surveyProbes = config.surveyProbes;
|
|
360
384
|
}
|
|
361
385
|
get connectorKey() {
|
|
362
386
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -364,7 +388,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
364
388
|
/**
|
|
365
389
|
* Create tools for connections that belong to this connector.
|
|
366
390
|
* Filters connections by connectorKey internally.
|
|
367
|
-
* Returns tools keyed as
|
|
391
|
+
* Returns tools keyed as `connector_${connectorKey}_${toolName}`.
|
|
368
392
|
*/
|
|
369
393
|
createTools(connections, config, opts) {
|
|
370
394
|
const myConnections = connections.filter(
|
|
@@ -374,7 +398,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
374
398
|
for (const t of Object.values(this.tools)) {
|
|
375
399
|
const tool = t.createTool(myConnections, config);
|
|
376
400
|
const originalToModelOutput = tool.toModelOutput;
|
|
377
|
-
result[
|
|
401
|
+
result[`connector_${this.connectorKey}_${t.name}`] = {
|
|
378
402
|
...tool,
|
|
379
403
|
toModelOutput: async (options) => {
|
|
380
404
|
if (!originalToModelOutput) {
|
|
@@ -394,25 +418,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
394
418
|
if (authType) return `${slug}-${authType}`;
|
|
395
419
|
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
396
420
|
// user-password
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
421
|
+
postgresql: "user-password",
|
|
422
|
+
mysql: "user-password",
|
|
423
|
+
clickhouse: "user-password",
|
|
424
|
+
kintone: "user-password",
|
|
401
425
|
"squadbase-db": "user-password",
|
|
402
426
|
// service-account
|
|
403
|
-
|
|
404
|
-
|
|
427
|
+
snowflake: "service-account",
|
|
428
|
+
bigquery: "service-account",
|
|
405
429
|
"google-analytics": "service-account",
|
|
406
430
|
"google-calendar": "service-account",
|
|
407
431
|
"aws-athena": "service-account",
|
|
408
|
-
|
|
432
|
+
redshift: "service-account",
|
|
409
433
|
// api-key
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
434
|
+
databricks: "api-key",
|
|
435
|
+
dbt: "api-key",
|
|
436
|
+
airtable: "api-key",
|
|
437
|
+
openai: "api-key",
|
|
438
|
+
gemini: "api-key",
|
|
439
|
+
anthropic: "api-key",
|
|
416
440
|
"wix-store": "api-key"
|
|
417
441
|
};
|
|
418
442
|
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
@@ -504,13 +528,13 @@ var AUTH_TYPES = {
|
|
|
504
528
|
// ../connectors/src/connectors/monday/setup.ts
|
|
505
529
|
var mondayOnboarding = new ConnectorOnboarding({
|
|
506
530
|
dataOverviewInstructions: {
|
|
507
|
-
en: `1. Call
|
|
508
|
-
2. Call
|
|
509
|
-
3. For a target board, call
|
|
531
|
+
en: `1. Call connector_monday_request with query \`{ me { id name email account { id name } } }\` to verify the token and identify the account
|
|
532
|
+
2. Call connector_monday_request with query \`{ boards(limit: 10) { id name state board_kind workspace { id name } } }\` to list boards
|
|
533
|
+
3. For a target board, call connector_monday_request with query \`{ boards(ids: [BOARD_ID]) { id name columns { id title type settings_str } } }\` to inspect column definitions
|
|
510
534
|
4. Sample items with \`{ boards(ids: [BOARD_ID]) { items_page(limit: 5) { cursor items { id name created_at updated_at column_values { id text value } } } } }\`
|
|
511
535
|
5. Explore other resources (workspaces, users, tags) as needed`,
|
|
512
|
-
ja: `1.
|
|
513
|
-
2.
|
|
536
|
+
ja: `1. connector_monday_request \u3067\u30AF\u30A8\u30EA \`{ me { id name email account { id name } } }\` \u3092\u547C\u3073\u51FA\u3057\u3001\u30C8\u30FC\u30AF\u30F3\u306E\u691C\u8A3C\u3068\u30A2\u30AB\u30A6\u30F3\u30C8\u306E\u78BA\u8A8D
|
|
537
|
+
2. connector_monday_request \u3067\u30AF\u30A8\u30EA \`{ boards(limit: 10) { id name state board_kind workspace { id name } } }\` \u3092\u547C\u3073\u51FA\u3057\u3001\u30DC\u30FC\u30C9\u4E00\u89A7\u3092\u53D6\u5F97
|
|
514
538
|
3. \u5BFE\u8C61\u30DC\u30FC\u30C9\u306B\u5BFE\u3057\u3066 \`{ boards(ids: [BOARD_ID]) { id name columns { id title type settings_str } } }\` \u3092\u547C\u3073\u51FA\u3057\u3001\u30AB\u30E9\u30E0\u5B9A\u7FA9\u3092\u78BA\u8A8D
|
|
515
539
|
4. \`{ boards(ids: [BOARD_ID]) { items_page(limit: 5) { cursor items { id name created_at updated_at column_values { id text value } } } } }\` \u3067\u30A2\u30A4\u30C6\u30E0\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
|
|
516
540
|
5. \u5FC5\u8981\u306B\u5FDC\u3058\u3066\u4ED6\u306E\u30EA\u30BD\u30FC\u30B9\uFF08workspaces\u3001users\u3001tags\uFF09\u3092\u63A2\u7D22`
|
|
@@ -773,7 +797,7 @@ var mondayConnector = new ConnectorPlugin({
|
|
|
773
797
|
systemPrompt: {
|
|
774
798
|
en: `### Tools
|
|
775
799
|
|
|
776
|
-
- \`
|
|
800
|
+
- \`connector_monday_request\`: The only way to call the monday.com GraphQL API. Use it to query and mutate all monday.com resources: boards, items, groups, columns, column values, users, workspaces, tags, teams, and updates. Authentication is configured automatically. monday.com's API is GraphQL-only \u2014 send a query string and optional variables. Items on a board are paginated with cursor-based \`items_page(limit, cursor)\`; boards/users/workspaces use page-based \`limit\`/\`page\`. IDs are passed as the GraphQL \`ID\` scalar (string).
|
|
777
801
|
|
|
778
802
|
### Business Logic
|
|
779
803
|
|
|
@@ -863,7 +887,7 @@ const items = res.data?.boards?.[0]?.items_page?.items; // always undefined!
|
|
|
863
887
|
- Some fields (e.g. \`board.tags\`) are only populated for boards that explicitly use them.`,
|
|
864
888
|
ja: `### \u30C4\u30FC\u30EB
|
|
865
889
|
|
|
866
|
-
- \`
|
|
890
|
+
- \`connector_monday_request\`: monday.com GraphQL API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30DC\u30FC\u30C9\u3001\u30A2\u30A4\u30C6\u30E0\u3001\u30B0\u30EB\u30FC\u30D7\u3001\u30AB\u30E9\u30E0\u3001\u30AB\u30E9\u30E0\u5024\u3001\u30E6\u30FC\u30B6\u30FC\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u3001\u30BF\u30B0\u3001\u30C1\u30FC\u30E0\u3001\u30A2\u30C3\u30D7\u30C7\u30FC\u30C8\u306A\u3069\u3059\u3079\u3066\u306E\u30EA\u30BD\u30FC\u30B9\u306E\u30AF\u30A8\u30EA\u3068\u30DF\u30E5\u30FC\u30C6\u30FC\u30B7\u30E7\u30F3\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002monday.com \u306E API \u306F GraphQL \u306E\u307F\u3067\u3001\u30AF\u30A8\u30EA\u6587\u5B57\u5217\u3068\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u5909\u6570\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002\u30DC\u30FC\u30C9\u4E0A\u306E\u30A2\u30A4\u30C6\u30E0\u306F\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E \`items_page(limit, cursor)\` \u3067\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3055\u308C\u3001\u30DC\u30FC\u30C9\uFF0F\u30E6\u30FC\u30B6\u30FC\uFF0F\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u306F\u30DA\u30FC\u30B8\u30D9\u30FC\u30B9\u306E \`limit\`/\`page\` \u3092\u4F7F\u7528\u3057\u307E\u3059\u3002ID \u306F GraphQL \u306E \`ID\` \u30B9\u30AB\u30E9\u30FC\uFF08\u6587\u5B57\u5217\uFF09\u3068\u3057\u3066\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
867
891
|
|
|
868
892
|
### Business Logic
|
|
869
893
|
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __esm = (fn, res) => function __init() {
|
|
3
|
-
|
|
2
|
+
var __esm = (fn, res, err) => function __init() {
|
|
3
|
+
if (err) throw err[0];
|
|
4
|
+
try {
|
|
5
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
+
} catch (e) {
|
|
7
|
+
throw err = [e], e;
|
|
8
|
+
}
|
|
4
9
|
};
|
|
5
10
|
|
|
6
11
|
// ../connectors/src/parameter-definition.ts
|
|
@@ -230,6 +235,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
230
235
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
231
236
|
*/
|
|
232
237
|
setup;
|
|
238
|
+
/**
|
|
239
|
+
* 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
|
|
240
|
+
* メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
|
|
241
|
+
* {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
|
|
242
|
+
* 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
|
|
243
|
+
* `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
|
|
244
|
+
* coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
|
|
245
|
+
*/
|
|
246
|
+
introspect;
|
|
233
247
|
/**
|
|
234
248
|
* Opt-out of the default "verify before save" behavior on connection
|
|
235
249
|
* creation. The backend invokes `checkConnection` synchronously while
|
|
@@ -244,6 +258,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
244
258
|
* the default verify-on-create behavior without opt-in.
|
|
245
259
|
*/
|
|
246
260
|
skipConnectionCheckOnCreate;
|
|
261
|
+
/**
|
|
262
|
+
* 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
|
|
263
|
+
* read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
|
|
264
|
+
* recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
|
|
265
|
+
* driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
|
|
266
|
+
* 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
|
|
267
|
+
*/
|
|
268
|
+
surveyProbes;
|
|
247
269
|
constructor(config) {
|
|
248
270
|
this.slug = config.slug;
|
|
249
271
|
this.authType = config.authType;
|
|
@@ -261,7 +283,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
261
283
|
this.query = config.query;
|
|
262
284
|
this.checkConnection = config.checkConnection;
|
|
263
285
|
this.setup = config.setup;
|
|
286
|
+
this.introspect = config.introspect;
|
|
264
287
|
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
288
|
+
this.surveyProbes = config.surveyProbes;
|
|
265
289
|
}
|
|
266
290
|
get connectorKey() {
|
|
267
291
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -269,7 +293,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
269
293
|
/**
|
|
270
294
|
* Create tools for connections that belong to this connector.
|
|
271
295
|
* Filters connections by connectorKey internally.
|
|
272
|
-
* Returns tools keyed as
|
|
296
|
+
* Returns tools keyed as `connector_${connectorKey}_${toolName}`.
|
|
273
297
|
*/
|
|
274
298
|
createTools(connections, config, opts) {
|
|
275
299
|
const myConnections = connections.filter(
|
|
@@ -279,7 +303,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
279
303
|
for (const t of Object.values(this.tools)) {
|
|
280
304
|
const tool = t.createTool(myConnections, config);
|
|
281
305
|
const originalToModelOutput = tool.toModelOutput;
|
|
282
|
-
result[
|
|
306
|
+
result[`connector_${this.connectorKey}_${t.name}`] = {
|
|
283
307
|
...tool,
|
|
284
308
|
toModelOutput: async (options) => {
|
|
285
309
|
if (!originalToModelOutput) {
|
|
@@ -299,25 +323,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
299
323
|
if (authType) return `${slug}-${authType}`;
|
|
300
324
|
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
301
325
|
// user-password
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
326
|
+
postgresql: "user-password",
|
|
327
|
+
mysql: "user-password",
|
|
328
|
+
clickhouse: "user-password",
|
|
329
|
+
kintone: "user-password",
|
|
306
330
|
"squadbase-db": "user-password",
|
|
307
331
|
// service-account
|
|
308
|
-
|
|
309
|
-
|
|
332
|
+
snowflake: "service-account",
|
|
333
|
+
bigquery: "service-account",
|
|
310
334
|
"google-analytics": "service-account",
|
|
311
335
|
"google-calendar": "service-account",
|
|
312
336
|
"aws-athena": "service-account",
|
|
313
|
-
|
|
337
|
+
redshift: "service-account",
|
|
314
338
|
// api-key
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
339
|
+
databricks: "api-key",
|
|
340
|
+
dbt: "api-key",
|
|
341
|
+
airtable: "api-key",
|
|
342
|
+
openai: "api-key",
|
|
343
|
+
gemini: "api-key",
|
|
344
|
+
anthropic: "api-key",
|
|
321
345
|
"wix-store": "api-key"
|
|
322
346
|
};
|
|
323
347
|
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
@@ -842,9 +866,9 @@ var mongodbConnector = new ConnectorPlugin({
|
|
|
842
866
|
systemPrompt: {
|
|
843
867
|
en: `### Tools
|
|
844
868
|
|
|
845
|
-
- \`
|
|
846
|
-
- \`
|
|
847
|
-
- \`
|
|
869
|
+
- \`connector_mongodb_listCollections\`: Lists all collections in the database. Use this first to explore available data.
|
|
870
|
+
- \`connector_mongodb_find\`: Finds documents in a collection with optional filter, projection, sort, and limit. Use for data sampling and querying specific documents. Pass filter, projection, and sort as JSON strings.
|
|
871
|
+
- \`connector_mongodb_aggregate\`: Runs a MongoDB aggregation pipeline on a collection. Use for complex data analysis, grouping, joining, and transformations. Pass pipeline as a JSON string.
|
|
848
872
|
|
|
849
873
|
### Business Logic
|
|
850
874
|
|
|
@@ -897,9 +921,9 @@ export default async function handler(_c: Context) {
|
|
|
897
921
|
- Always include limit in find queries and $limit in aggregation pipelines`,
|
|
898
922
|
ja: `### \u30C4\u30FC\u30EB
|
|
899
923
|
|
|
900
|
-
- \`
|
|
901
|
-
- \`
|
|
902
|
-
- \`
|
|
924
|
+
- \`connector_mongodb_listCollections\`: \u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u5185\u306E\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30C7\u30FC\u30BF\u63A2\u7D22\u306E\u6700\u521D\u306E\u30B9\u30C6\u30C3\u30D7\u3068\u3057\u3066\u4F7F\u7528\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
925
|
+
- \`connector_mongodb_find\`: \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u5185\u306E\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u691C\u7D22\u3057\u307E\u3059\u3002\u30D5\u30A3\u30EB\u30BF\u30FC\u3001\u30D7\u30ED\u30B8\u30A7\u30AF\u30B7\u30E7\u30F3\u3001\u30BD\u30FC\u30C8\u3001\u5236\u9650\u3092\u30AA\u30D7\u30B7\u30E7\u30F3\u3067\u6307\u5B9A\u53EF\u80FD\u3002\u30C7\u30FC\u30BF\u306E\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u3084\u7279\u5B9A\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002filter\u3001projection\u3001sort\u306FJSON\u6587\u5B57\u5217\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
926
|
+
- \`connector_mongodb_aggregate\`: \u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u4E0A\u3067MongoDB\u96C6\u7D04\u30D1\u30A4\u30D7\u30E9\u30A4\u30F3\u3092\u5B9F\u884C\u3057\u307E\u3059\u3002\u8907\u96D1\u306A\u30C7\u30FC\u30BF\u5206\u6790\u3001\u30B0\u30EB\u30FC\u30D7\u5316\u3001\u7D50\u5408\u3001\u5909\u63DB\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002pipeline\u306FJSON\u6587\u5B57\u5217\u3067\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
|
|
903
927
|
|
|
904
928
|
### Business Logic
|
|
905
929
|
|
|
@@ -79,6 +79,15 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
79
79
|
* `runSetupFlow` from `setup-flow.ts`.
|
|
80
80
|
*/
|
|
81
81
|
setup;
|
|
82
|
+
/**
|
|
83
|
+
* 統一 introspection。SQL DB の `information_schema` / `SHOW` / `DESCRIBE` や SaaS の
|
|
84
|
+
* メタデータ API といった取得経路の差を吸収し、tables / columns / PK / FK を共通型
|
|
85
|
+
* {@link IntrospectedSchema} へ正規化して返す。取得経路は {@link IntrospectContext} で
|
|
86
|
+
* 抽象化され、SQL DB は `ctx.query`、SaaS は `ctx.proxyFetch` + `ctx.params` を使う。
|
|
87
|
+
* `ctx.profile === true` のときは L2 プロファイル(行数・NULL 率等)も best-effort で埋める。
|
|
88
|
+
* coding-agent の `DataContextIndex` がデータ地図を構築する際に使う。
|
|
89
|
+
*/
|
|
90
|
+
introspect;
|
|
82
91
|
/**
|
|
83
92
|
* Opt-out of the default "verify before save" behavior on connection
|
|
84
93
|
* creation. The backend invokes `checkConnection` synchronously while
|
|
@@ -93,6 +102,14 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
93
102
|
* the default verify-on-create behavior without opt-in.
|
|
94
103
|
*/
|
|
95
104
|
skipConnectionCheckOnCreate;
|
|
105
|
+
/**
|
|
106
|
+
* 決定論的な「立ち上げ survey」レシピ(ルールベース prewarm 基盤)。実装した connector は、LLM を使わずに
|
|
107
|
+
* read-only で自分を survey する probe 列(テーブル/列メタデータ → 小サンプル)を宣言する。coding-agent の
|
|
108
|
+
* recon driver がこれを読み、connector ツールの `execute` を直接呼んで結果を seed にする。未実装の connector は
|
|
109
|
+
* driver 側で safely skip される(その connection は listConnections のみ seed)。標準 `information_schema` を
|
|
110
|
+
* 持つ SQL connector は `makeStandardSqlSurveyProbes` を使える。**probe は必ず read-only**。
|
|
111
|
+
*/
|
|
112
|
+
surveyProbes;
|
|
96
113
|
constructor(config) {
|
|
97
114
|
this.slug = config.slug;
|
|
98
115
|
this.authType = config.authType;
|
|
@@ -110,7 +127,9 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
110
127
|
this.query = config.query;
|
|
111
128
|
this.checkConnection = config.checkConnection;
|
|
112
129
|
this.setup = config.setup;
|
|
130
|
+
this.introspect = config.introspect;
|
|
113
131
|
this.skipConnectionCheckOnCreate = config.skipConnectionCheckOnCreate;
|
|
132
|
+
this.surveyProbes = config.surveyProbes;
|
|
114
133
|
}
|
|
115
134
|
get connectorKey() {
|
|
116
135
|
return _ConnectorPlugin.deriveKey(this.slug, this.authType);
|
|
@@ -118,7 +137,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
118
137
|
/**
|
|
119
138
|
* Create tools for connections that belong to this connector.
|
|
120
139
|
* Filters connections by connectorKey internally.
|
|
121
|
-
* Returns tools keyed as
|
|
140
|
+
* Returns tools keyed as `connector_${connectorKey}_${toolName}`.
|
|
122
141
|
*/
|
|
123
142
|
createTools(connections, config, opts) {
|
|
124
143
|
const myConnections = connections.filter(
|
|
@@ -128,7 +147,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
128
147
|
for (const t of Object.values(this.tools)) {
|
|
129
148
|
const tool = t.createTool(myConnections, config);
|
|
130
149
|
const originalToModelOutput = tool.toModelOutput;
|
|
131
|
-
result[
|
|
150
|
+
result[`connector_${this.connectorKey}_${t.name}`] = {
|
|
132
151
|
...tool,
|
|
133
152
|
toModelOutput: async (options) => {
|
|
134
153
|
if (!originalToModelOutput) {
|
|
@@ -148,25 +167,25 @@ var ConnectorPlugin = class _ConnectorPlugin {
|
|
|
148
167
|
if (authType) return `${slug}-${authType}`;
|
|
149
168
|
const LEGACY_NULL_AUTH_TYPE_MAP = {
|
|
150
169
|
// user-password
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
170
|
+
postgresql: "user-password",
|
|
171
|
+
mysql: "user-password",
|
|
172
|
+
clickhouse: "user-password",
|
|
173
|
+
kintone: "user-password",
|
|
155
174
|
"squadbase-db": "user-password",
|
|
156
175
|
// service-account
|
|
157
|
-
|
|
158
|
-
|
|
176
|
+
snowflake: "service-account",
|
|
177
|
+
bigquery: "service-account",
|
|
159
178
|
"google-analytics": "service-account",
|
|
160
179
|
"google-calendar": "service-account",
|
|
161
180
|
"aws-athena": "service-account",
|
|
162
|
-
|
|
181
|
+
redshift: "service-account",
|
|
163
182
|
// api-key
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
183
|
+
databricks: "api-key",
|
|
184
|
+
dbt: "api-key",
|
|
185
|
+
airtable: "api-key",
|
|
186
|
+
openai: "api-key",
|
|
187
|
+
gemini: "api-key",
|
|
188
|
+
anthropic: "api-key",
|
|
170
189
|
"wix-store": "api-key"
|
|
171
190
|
};
|
|
172
191
|
const fallbackAuthType = LEGACY_NULL_AUTH_TYPE_MAP[slug];
|
|
@@ -395,13 +414,13 @@ var notionOauthOnboarding = new ConnectorOnboarding({
|
|
|
395
414
|
- Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
|
|
396
415
|
},
|
|
397
416
|
dataOverviewInstructions: {
|
|
398
|
-
en: `1. Call
|
|
399
|
-
2. For each database found, call
|
|
400
|
-
3. Call
|
|
417
|
+
en: `1. Call connector_notion-oauth_request with POST /search and { "page_size": 5 } to discover available pages and databases
|
|
418
|
+
2. For each database found, call connector_notion-oauth_request with POST /databases/{database_id}/query and { "page_size": 5 } to sample records
|
|
419
|
+
3. Call connector_notion-oauth_request with GET /users to list workspace members
|
|
401
420
|
4. Explore page content with GET /blocks/{page_id}/children as needed`,
|
|
402
|
-
ja: `1.
|
|
403
|
-
2. \u898B\u3064\u304B\u3063\u305F\u5404\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306B\u3064\u3044\u3066\
|
|
404
|
-
3.
|
|
421
|
+
ja: `1. connector_notion-oauth_request \u3067 POST /search \u3092 { "page_size": 5 } \u3067\u547C\u3073\u51FA\u3057\u3001\u5229\u7528\u53EF\u80FD\u306A\u30DA\u30FC\u30B8\u3068\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u3092\u691C\u51FA
|
|
422
|
+
2. \u898B\u3064\u304B\u3063\u305F\u5404\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306B\u3064\u3044\u3066\u3001connector_notion-oauth_request \u3067 POST /databases/{database_id}/query \u3092 { "page_size": 5 } \u3067\u547C\u3073\u51FA\u3057\u3001\u30EC\u30B3\u30FC\u30C9\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0
|
|
423
|
+
3. connector_notion-oauth_request \u3067 GET /users \u3092\u547C\u3073\u51FA\u3057\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30E1\u30F3\u30D0\u30FC\u3092\u4E00\u89A7\u8868\u793A
|
|
405
424
|
4. \u5FC5\u8981\u306B\u5FDC\u3058\u3066 GET /blocks/{page_id}/children \u3067\u30DA\u30FC\u30B8\u30B3\u30F3\u30C6\u30F3\u30C4\u3092\u63A2\u7D22`
|
|
406
425
|
}
|
|
407
426
|
});
|
|
@@ -465,6 +484,38 @@ async function getDatabase(proxyFetch, databaseId) {
|
|
|
465
484
|
}
|
|
466
485
|
return await res.json();
|
|
467
486
|
}
|
|
487
|
+
async function queryDatabaseSample(proxyFetch, databaseId) {
|
|
488
|
+
try {
|
|
489
|
+
const res = await apiFetch(proxyFetch, `/databases/${databaseId}/query`, {
|
|
490
|
+
method: "POST",
|
|
491
|
+
body: JSON.stringify({ page_size: 3 })
|
|
492
|
+
});
|
|
493
|
+
if (!res.ok) return [];
|
|
494
|
+
const data = await res.json();
|
|
495
|
+
return data.results ?? [];
|
|
496
|
+
} catch {
|
|
497
|
+
return [];
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
function formatPropertyValue(prop) {
|
|
501
|
+
if (prop == null || typeof prop !== "object") return "";
|
|
502
|
+
const p = prop;
|
|
503
|
+
const t = p.type ?? "";
|
|
504
|
+
const v = p[t];
|
|
505
|
+
if (v == null) return "";
|
|
506
|
+
if (typeof v === "string" || typeof v === "number" || typeof v === "boolean")
|
|
507
|
+
return String(v);
|
|
508
|
+
if (Array.isArray(v)) {
|
|
509
|
+
if (v.length === 0) return "";
|
|
510
|
+
const first = v[0];
|
|
511
|
+
return first.plain_text ?? first.name ?? `[${v.length} items]`;
|
|
512
|
+
}
|
|
513
|
+
if (typeof v === "object") {
|
|
514
|
+
const o = v;
|
|
515
|
+
return o.name ?? o.plain_text ?? o.start ?? JSON.stringify(v).slice(0, 30);
|
|
516
|
+
}
|
|
517
|
+
return String(v);
|
|
518
|
+
}
|
|
468
519
|
var notionOauthSetupFlow = {
|
|
469
520
|
initialState: () => ({}),
|
|
470
521
|
steps: [
|
|
@@ -509,11 +560,28 @@ var notionOauthSetupFlow = {
|
|
|
509
560
|
sections.push(`### Database: ${title}`, "", `- id: \`${db.id}\``, "");
|
|
510
561
|
sections.push("| Property | Type |");
|
|
511
562
|
sections.push("|----------|------|");
|
|
512
|
-
|
|
563
|
+
const propEntries = Object.entries(db.properties ?? {});
|
|
564
|
+
for (const [name, def] of propEntries) {
|
|
513
565
|
const escapedName = name.replace(/\|/g, "\\|");
|
|
514
566
|
sections.push(`| ${escapedName} | ${def?.type ?? "-"} |`);
|
|
515
567
|
}
|
|
516
568
|
sections.push("");
|
|
569
|
+
const pages = await queryDatabaseSample(rt.config.proxyFetch, dbId);
|
|
570
|
+
if (pages.length > 0) {
|
|
571
|
+
const sampleProps = propEntries.slice(0, 5).map(([n]) => n);
|
|
572
|
+
if (sampleProps.length > 0) {
|
|
573
|
+
sections.push(`#### Sample pages (${pages.length})`, "");
|
|
574
|
+
sections.push(`| ${sampleProps.join(" | ")} |`);
|
|
575
|
+
sections.push(`| ${sampleProps.map(() => "---").join(" | ")} |`);
|
|
576
|
+
for (const page of pages) {
|
|
577
|
+
const cells = sampleProps.map(
|
|
578
|
+
(n) => formatPropertyValue(page.properties?.[n]).replace(/\|/g, "\\|")
|
|
579
|
+
);
|
|
580
|
+
sections.push(`| ${cells.join(" | ")} |`);
|
|
581
|
+
}
|
|
582
|
+
sections.push("");
|
|
583
|
+
}
|
|
584
|
+
}
|
|
517
585
|
}
|
|
518
586
|
return sections.join("\n");
|
|
519
587
|
}
|
|
@@ -543,7 +611,7 @@ var notionOauthConnector = new ConnectorPlugin({
|
|
|
543
611
|
systemPrompt: {
|
|
544
612
|
en: `### Tools
|
|
545
613
|
|
|
546
|
-
- \`
|
|
614
|
+
- \`connector_notion-oauth_request\`: The only way to call the Notion API. Use it to search pages and databases, query database records, retrieve page content and blocks, and manage workspace data. Authentication is configured automatically via OAuth. Notion-Version header is set automatically. Pagination uses cursor-based \`start_cursor\` and \`page_size\` (max 100) with \`has_more\` and \`next_cursor\` in the response.
|
|
547
615
|
|
|
548
616
|
### Notion API Reference
|
|
549
617
|
|
|
@@ -593,7 +661,7 @@ const data = await res.json();
|
|
|
593
661
|
\`\`\``,
|
|
594
662
|
ja: `### \u30C4\u30FC\u30EB
|
|
595
663
|
|
|
596
|
-
- \`
|
|
664
|
+
- \`connector_notion-oauth_request\`: Notion API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u30DA\u30FC\u30B8\u3084\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u306E\u691C\u7D22\u3001\u30C7\u30FC\u30BF\u30D9\u30FC\u30B9\u30EC\u30B3\u30FC\u30C9\u306E\u30AF\u30A8\u30EA\u3001\u30DA\u30FC\u30B8\u30B3\u30F3\u30C6\u30F3\u30C4\u3084\u30D6\u30ED\u30C3\u30AF\u306E\u53D6\u5F97\u3001\u30EF\u30FC\u30AF\u30B9\u30DA\u30FC\u30B9\u30C7\u30FC\u30BF\u306E\u7BA1\u7406\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Notion-Version\u30D8\u30C3\u30C0\u30FC\u3082\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E \`has_more\` \u3068 \`next_cursor\` \u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u3067\u3001\`start_cursor\` \u3068 \`page_size\`\uFF08\u6700\u5927100\uFF09\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
|
|
597
665
|
|
|
598
666
|
### Notion API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
|
|
599
667
|
|