@squadbase/vite-server 0.1.17-dev.24af54e → 0.1.17-dev.423ee34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/cli/index.js +4873 -1073
  2. package/dist/connectors/airtable-oauth.js +78 -11
  3. package/dist/connectors/airtable.js +74 -11
  4. package/dist/connectors/amplitude.js +38 -11
  5. package/dist/connectors/anthropic.js +4 -2
  6. package/dist/connectors/asana.js +67 -13
  7. package/dist/connectors/attio.js +60 -16
  8. package/dist/connectors/aws-billing.js +38 -11
  9. package/dist/connectors/azure-sql.js +64 -13
  10. package/dist/connectors/backlog-api-key.js +70 -18
  11. package/dist/connectors/clickup.js +80 -13
  12. package/dist/connectors/cosmosdb.js +42 -15
  13. package/dist/connectors/customerio.js +39 -12
  14. package/dist/connectors/dbt.js +716 -28
  15. package/dist/connectors/freshdesk.js +112 -11
  16. package/dist/connectors/freshsales.js +38 -11
  17. package/dist/connectors/freshservice.js +38 -11
  18. package/dist/connectors/gamma.js +47 -20
  19. package/dist/connectors/gemini.js +4 -2
  20. package/dist/connectors/github.js +42 -15
  21. package/dist/connectors/gmail-oauth.js +38 -13
  22. package/dist/connectors/gmail.js +34 -7
  23. package/dist/connectors/google-ads.js +38 -11
  24. package/dist/connectors/google-analytics-oauth.js +182 -28
  25. package/dist/connectors/google-analytics.js +653 -104
  26. package/dist/connectors/google-audit-log.js +34 -7
  27. package/dist/connectors/google-calendar-oauth.js +91 -18
  28. package/dist/connectors/google-calendar.js +91 -14
  29. package/dist/connectors/google-docs.js +38 -13
  30. package/dist/connectors/google-drive.js +60 -13
  31. package/dist/connectors/google-search-console-oauth.js +156 -20
  32. package/dist/connectors/google-sheets.js +36 -9
  33. package/dist/connectors/google-slides.js +38 -13
  34. package/dist/connectors/grafana.js +75 -13
  35. package/dist/connectors/hubspot-oauth.js +69 -12
  36. package/dist/connectors/hubspot.js +55 -12
  37. package/dist/connectors/influxdb.js +38 -11
  38. package/dist/connectors/intercom-oauth.js +100 -15
  39. package/dist/connectors/intercom.js +42 -15
  40. package/dist/connectors/jdbc.js +36 -9
  41. package/dist/connectors/jira-api-key.js +98 -14
  42. package/dist/connectors/kintone-api-token.js +96 -21
  43. package/dist/connectors/kintone.js +84 -14
  44. package/dist/connectors/linear.js +84 -15
  45. package/dist/connectors/linkedin-ads.js +71 -17
  46. package/dist/connectors/mailchimp-oauth.js +36 -9
  47. package/dist/connectors/mailchimp.js +36 -9
  48. package/dist/connectors/meta-ads-oauth.js +63 -17
  49. package/dist/connectors/meta-ads.js +65 -17
  50. package/dist/connectors/mixpanel.js +38 -11
  51. package/dist/connectors/monday.js +39 -12
  52. package/dist/connectors/mongodb.js +38 -11
  53. package/dist/connectors/notion-oauth.js +88 -14
  54. package/dist/connectors/notion.js +90 -14
  55. package/dist/connectors/openai.js +4 -2
  56. package/dist/connectors/oracle.js +78 -20
  57. package/dist/connectors/outlook-oauth.js +48 -23
  58. package/dist/connectors/powerbi-oauth.js +321 -49
  59. package/dist/connectors/salesforce.js +72 -12
  60. package/dist/connectors/semrush.js +374 -52
  61. package/dist/connectors/sentry.js +66 -13
  62. package/dist/connectors/shopify-oauth.js +71 -13
  63. package/dist/connectors/shopify.js +38 -11
  64. package/dist/connectors/sqlserver.js +64 -13
  65. package/dist/connectors/stripe-api-key.js +96 -18
  66. package/dist/connectors/stripe-oauth.js +98 -22
  67. package/dist/connectors/supabase.js +55 -11
  68. package/dist/connectors/tableau.js +262 -92
  69. package/dist/connectors/tiktok-ads.js +67 -19
  70. package/dist/connectors/wix-store.js +38 -11
  71. package/dist/connectors/zendesk-oauth.js +83 -15
  72. package/dist/connectors/zendesk.js +42 -15
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.js +4902 -1077
  75. package/dist/main.js +4891 -1071
  76. package/dist/vite-plugin.js +4871 -1071
  77. package/package.json +1 -1
@@ -249,7 +249,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
249
249
  /**
250
250
  * Create tools for connections that belong to this connector.
251
251
  * Filters connections by connectorKey internally.
252
- * Returns tools keyed as `${connectorKey}_${toolName}`.
252
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
253
253
  */
254
254
  createTools(connections, config, opts) {
255
255
  const myConnections = connections.filter(
@@ -259,7 +259,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
259
259
  for (const t of Object.values(this.tools)) {
260
260
  const tool = t.createTool(myConnections, config);
261
261
  const originalToModelOutput = tool.toModelOutput;
262
- result[`${this.connectorKey}_${t.name}`] = {
262
+ result[`connector_${this.connectorKey}_${t.name}`] = {
263
263
  ...tool,
264
264
  toModelOutput: async (options) => {
265
265
  if (!originalToModelOutput) {
@@ -315,19 +315,34 @@ async function runSetupFlow(flow, params, ctx, config) {
315
315
  };
316
316
  let state = flow.initialState();
317
317
  let answerIdx = 0;
318
+ const pendingParameterUpdates = [];
318
319
  for (const step of flow.steps) {
319
320
  const ans = ctx.answers[answerIdx];
320
321
  if (ans && ans.questionSlug === step.slug) {
321
322
  state = step.applyAnswer(state, ans.answer);
323
+ if (step.toParameterUpdates) {
324
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
325
+ }
322
326
  answerIdx += 1;
323
327
  continue;
324
328
  }
329
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
325
330
  if (step.type === "text") {
331
+ if (step.fetchOptions) {
332
+ const options2 = await step.fetchOptions(state, runtime);
333
+ if (options2.length === 0) {
334
+ continue;
335
+ }
336
+ }
326
337
  return {
327
338
  type: "nextQuestion",
328
339
  questionSlug: step.slug,
329
340
  question: step.question[ctx.language],
330
- questionType: "text"
341
+ questionType: "text",
342
+ allowFreeText: resolvedAllowFreeText,
343
+ ...pendingParameterUpdates.length > 0 && {
344
+ parameterUpdates: pendingParameterUpdates
345
+ }
331
346
  };
332
347
  }
333
348
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -339,11 +354,21 @@ async function runSetupFlow(flow, params, ctx, config) {
339
354
  questionSlug: step.slug,
340
355
  question: step.question[ctx.language],
341
356
  questionType: step.type,
342
- options
357
+ options,
358
+ allowFreeText: resolvedAllowFreeText,
359
+ ...pendingParameterUpdates.length > 0 && {
360
+ parameterUpdates: pendingParameterUpdates
361
+ }
343
362
  };
344
363
  }
345
364
  const dataInvestigationResult = await flow.finalize(state, runtime);
346
- return { type: "fulfilled", dataInvestigationResult };
365
+ return {
366
+ type: "fulfilled",
367
+ dataInvestigationResult,
368
+ ...pendingParameterUpdates.length > 0 && {
369
+ parameterUpdates: pendingParameterUpdates
370
+ }
371
+ };
347
372
  }
348
373
  async function resolveSetupSelection(params) {
349
374
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -374,10 +399,10 @@ function normalizeRequestPath(path2, basePathSegment) {
374
399
  // ../connectors/src/connectors/google-drive/setup.ts
375
400
  var googleDriveOnboarding = new ConnectorOnboarding({
376
401
  dataOverviewInstructions: {
377
- en: `1. Call google-drive-oauth_request with GET /files?pageSize=20&fields=files(id,name,mimeType,modifiedTime)&orderBy=modifiedTime desc to list recent files
378
- 2. Call google-drive-oauth_request with GET /about?fields=user,storageQuota to get account info and storage usage`,
379
- ja: `1. google-drive-oauth_request \u3067 GET /files?pageSize=20&fields=files(id,name,mimeType,modifiedTime)&orderBy=modifiedTime desc \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u8FD1\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u4E00\u89A7\u8868\u793A
380
- 2. google-drive-oauth_request \u3067 GET /about?fields=user,storageQuota \u3092\u547C\u3073\u51FA\u3057\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3068\u30B9\u30C8\u30EC\u30FC\u30B8\u4F7F\u7528\u91CF\u3092\u53D6\u5F97`
402
+ en: `1. Call connector_google-drive-oauth_request with GET /files?pageSize=20&fields=files(id,name,mimeType,modifiedTime)&orderBy=modifiedTime desc to list recent files
403
+ 2. Call connector_google-drive-oauth_request with GET /about?fields=user,storageQuota to get account info and storage usage`,
404
+ ja: `1. connector_google-drive-oauth_request \u3067 GET /files?pageSize=20&fields=files(id,name,mimeType,modifiedTime)&orderBy=modifiedTime desc \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u8FD1\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u4E00\u89A7\u8868\u793A
405
+ 2. connector_google-drive-oauth_request \u3067 GET /about?fields=user,storageQuota \u3092\u547C\u3073\u51FA\u3057\u3001\u30A2\u30AB\u30A6\u30F3\u30C8\u60C5\u5831\u3068\u30B9\u30C8\u30EC\u30FC\u30B8\u4F7F\u7528\u91CF\u3092\u53D6\u5F97`
381
406
  }
382
407
  });
383
408
 
@@ -518,6 +543,28 @@ var googleDriveSetupFlow = {
518
543
  );
519
544
  }
520
545
  sections.push("");
546
+ try {
547
+ const counts = /* @__PURE__ */ new Map();
548
+ for (const f of allFiles) {
549
+ const key = f.mimeType === FOLDER_MIME ? "folder" : f.mimeType ?? "(unknown)";
550
+ counts.set(key, (counts.get(key) ?? 0) + 1);
551
+ }
552
+ const top = Array.from(counts.entries()).sort((a, b) => b[1] - a[1]).slice(0, 10);
553
+ if (top.length > 0) {
554
+ sections.push(
555
+ rt.language === "ja" ? "### \u30D5\u30A1\u30A4\u30EB\u7A2E\u5225\u306E\u5185\u8A33 (\u4E0A\u4F4D10\u4EF6)" : "### File type breakdown (top 10)",
556
+ ""
557
+ );
558
+ sections.push("| Mime Type | Count |");
559
+ sections.push("|-----------|-------|");
560
+ for (const [mime, count] of top) {
561
+ const safe = mime.replace(/\|/g, "\\|");
562
+ sections.push(`| ${safe} | ${count} |`);
563
+ }
564
+ sections.push("");
565
+ }
566
+ } catch {
567
+ }
521
568
  return sections.join("\n");
522
569
  }
523
570
  };
@@ -669,9 +716,9 @@ var googleDriveConnector = new ConnectorPlugin({
669
716
  systemPrompt: {
670
717
  en: `### Tools (setup-time only)
671
718
 
672
- - \`google-drive-oauth_request\`: Send authenticated requests to the Google Drive API v3 during setup / data overview. Supports GET, POST, and PATCH methods. Authentication is configured automatically via OAuth.
719
+ - \`connector_google-drive-oauth_request\`: Send authenticated requests to the Google Drive API v3 during setup / data overview. Supports GET, POST, and PATCH methods. Authentication is configured automatically via OAuth.
673
720
 
674
- > **Important**: The \`google-drive-oauth_request\` tool is only available at setup time. Inside server-logic handlers, use the SDK (\`connection(id).listFiles\`, etc.) \u2014 the SDK's fetch is already wired through the OAuth proxy. **Do NOT** hand-roll HTTP calls to \`_sqcore/connections/*/request\` from a handler.
721
+ > **Important**: The \`connector_google-drive-oauth_request\` tool is only available at setup time. Inside server-logic handlers, use the SDK (\`connection(id).listFiles\`, etc.) \u2014 the SDK's fetch is already wired through the OAuth proxy. **Do NOT** hand-roll HTTP calls to \`_sqcore/connections/*/request\` from a handler.
675
722
 
676
723
  ### Google Drive API Reference
677
724
 
@@ -805,9 +852,9 @@ await drive.updateFile("fileId123", {}, "newFolderId", "oldFolderId");
805
852
  \`\`\``,
806
853
  ja: `### \u30C4\u30FC\u30EB\uFF08\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\uFF09
807
854
 
808
- - \`google-drive-oauth_request\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3084\u30C7\u30FC\u30BF\u6982\u8981\u628A\u63E1\u6642\u306B Google Drive API v3 \u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002GET, POST, PATCH \u30E1\u30BD\u30C3\u30C9\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002OAuth \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
855
+ - \`connector_google-drive-oauth_request\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3084\u30C7\u30FC\u30BF\u6982\u8981\u628A\u63E1\u6642\u306B Google Drive API v3 \u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002GET, POST, PATCH \u30E1\u30BD\u30C3\u30C9\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002OAuth \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
809
856
 
810
- > **\u91CD\u8981**: \`google-drive-oauth_request\` \u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\u5229\u7528\u53EF\u80FD\u3067\u3059\u3002\u30B5\u30FC\u30D0\u30FC\u30ED\u30B8\u30C3\u30AF\u306E\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u5FC5\u305A SDK\uFF08\`connection(id).listFiles\` \u306A\u3069\uFF09\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002SDK \u306E fetch \u306F OAuth \u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u65E2\u306B\u914D\u7DDA\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089 \`_sqcore/connections/*/request\` \u3092\u624B\u66F8\u304D\u3067\u547C\u3073\u51FA\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
857
+ > **\u91CD\u8981**: \`connector_google-drive-oauth_request\` \u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\u5229\u7528\u53EF\u80FD\u3067\u3059\u3002\u30B5\u30FC\u30D0\u30FC\u30ED\u30B8\u30C3\u30AF\u306E\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u5FC5\u305A SDK\uFF08\`connection(id).listFiles\` \u306A\u3069\uFF09\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002SDK \u306E fetch \u306F OAuth \u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u65E2\u306B\u914D\u7DDA\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089 \`_sqcore/connections/*/request\` \u3092\u624B\u66F8\u304D\u3067\u547C\u3073\u51FA\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
811
858
 
812
859
  ### Google Drive API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
813
860
 
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -254,7 +256,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
254
256
  /**
255
257
  * Create tools for connections that belong to this connector.
256
258
  * Filters connections by connectorKey internally.
257
- * Returns tools keyed as `${connectorKey}_${toolName}`.
259
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
258
260
  */
259
261
  createTools(connections, config, opts) {
260
262
  const myConnections = connections.filter(
@@ -264,7 +266,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
264
266
  for (const t of Object.values(this.tools)) {
265
267
  const tool = t.createTool(myConnections, config);
266
268
  const originalToModelOutput = tool.toModelOutput;
267
- result[`${this.connectorKey}_${t.name}`] = {
269
+ result[`connector_${this.connectorKey}_${t.name}`] = {
268
270
  ...tool,
269
271
  toModelOutput: async (options) => {
270
272
  if (!originalToModelOutput) {
@@ -320,19 +322,34 @@ async function runSetupFlow(flow, params, ctx, config) {
320
322
  };
321
323
  let state = flow.initialState();
322
324
  let answerIdx = 0;
325
+ const pendingParameterUpdates = [];
323
326
  for (const step of flow.steps) {
324
327
  const ans = ctx.answers[answerIdx];
325
328
  if (ans && ans.questionSlug === step.slug) {
326
329
  state = step.applyAnswer(state, ans.answer);
330
+ if (step.toParameterUpdates) {
331
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
332
+ }
327
333
  answerIdx += 1;
328
334
  continue;
329
335
  }
336
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
330
337
  if (step.type === "text") {
338
+ if (step.fetchOptions) {
339
+ const options2 = await step.fetchOptions(state, runtime);
340
+ if (options2.length === 0) {
341
+ continue;
342
+ }
343
+ }
331
344
  return {
332
345
  type: "nextQuestion",
333
346
  questionSlug: step.slug,
334
347
  question: step.question[ctx.language],
335
- questionType: "text"
348
+ questionType: "text",
349
+ allowFreeText: resolvedAllowFreeText,
350
+ ...pendingParameterUpdates.length > 0 && {
351
+ parameterUpdates: pendingParameterUpdates
352
+ }
336
353
  };
337
354
  }
338
355
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -344,11 +361,21 @@ async function runSetupFlow(flow, params, ctx, config) {
344
361
  questionSlug: step.slug,
345
362
  question: step.question[ctx.language],
346
363
  questionType: step.type,
347
- options
364
+ options,
365
+ allowFreeText: resolvedAllowFreeText,
366
+ ...pendingParameterUpdates.length > 0 && {
367
+ parameterUpdates: pendingParameterUpdates
368
+ }
348
369
  };
349
370
  }
350
371
  const dataInvestigationResult = await flow.finalize(state, runtime);
351
- return { type: "fulfilled", dataInvestigationResult };
372
+ return {
373
+ type: "fulfilled",
374
+ dataInvestigationResult,
375
+ ...pendingParameterUpdates.length > 0 && {
376
+ parameterUpdates: pendingParameterUpdates
377
+ }
378
+ };
352
379
  }
353
380
  async function resolveSetupSelection(params) {
354
381
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -524,10 +551,10 @@ var googleSearchConsoleOauthOnboarding = new ConnectorOnboarding({
524
551
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
525
552
  },
526
553
  dataOverviewInstructions: {
527
- en: `1. Call google-search-console-oauth_request with GET /sites/{siteUrl} to fetch metadata for the configured site
528
- 2. Call google-search-console-oauth_request with POST /sites/{siteUrl}/searchAnalytics/query and a small body \u2014 startDate/endDate covering the last 7 days, dimensions ["date"], rowLimit 7 \u2014 to verify that performance data is available`,
529
- ja: `1. google-search-console-oauth_request \u3067 GET /sites/{siteUrl} \u3092\u547C\u3073\u51FA\u3057\u3001\u8A2D\u5B9A\u3055\u308C\u305F\u30B5\u30A4\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
530
- 2. google-search-console-oauth_request \u3067 POST /sites/{siteUrl}/searchAnalytics/query \u3092\u76F4\u8FD17\u65E5\u9593\u306E startDate/endDate\u3001dimensions ["date"]\u3001rowLimit 7 \u3067\u547C\u3073\u51FA\u3057\u3001\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30C7\u30FC\u30BF\u306E\u53EF\u7528\u6027\u3092\u78BA\u8A8D`
554
+ en: `1. Call connector_google-search-console-oauth_request with GET /sites/{siteUrl} to fetch metadata for the configured site
555
+ 2. Call connector_google-search-console-oauth_request with POST /sites/{siteUrl}/searchAnalytics/query and a small body \u2014 startDate/endDate covering the last 7 days, dimensions ["date"], rowLimit 7 \u2014 to verify that performance data is available`,
556
+ ja: `1. connector_google-search-console-oauth_request \u3067 GET /sites/{siteUrl} \u3092\u547C\u3073\u51FA\u3057\u3001\u8A2D\u5B9A\u3055\u308C\u305F\u30B5\u30A4\u30C8\u306E\u30E1\u30BF\u30C7\u30FC\u30BF\u3092\u53D6\u5F97
557
+ 2. connector_google-search-console-oauth_request \u3067 POST /sites/{siteUrl}/searchAnalytics/query \u3092\u76F4\u8FD17\u65E5\u9593\u306E startDate/endDate\u3001dimensions ["date"]\u3001rowLimit 7 \u3067\u547C\u3073\u51FA\u3057\u3001\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u30C7\u30FC\u30BF\u306E\u53EF\u7528\u6027\u3092\u78BA\u8A8D`
531
558
  }
532
559
  });
533
560
 
@@ -550,6 +577,33 @@ function isVerified(site) {
550
577
  const level = site.permissionLevel ?? "";
551
578
  return level !== "" && level !== "siteUnverifiedUser";
552
579
  }
580
+ function formatDate(daysAgo) {
581
+ const d = /* @__PURE__ */ new Date();
582
+ d.setDate(d.getDate() - daysAgo);
583
+ return d.toISOString().slice(0, 10);
584
+ }
585
+ async function querySearchAnalytics(proxyFetch, siteUrl, dimensions, rowLimit) {
586
+ try {
587
+ const res = await proxyFetch(
588
+ `${SITES_URL}/${encodeURIComponent(siteUrl)}/searchAnalytics/query`,
589
+ {
590
+ method: "POST",
591
+ headers: { "Content-Type": "application/json" },
592
+ body: JSON.stringify({
593
+ startDate: formatDate(28),
594
+ endDate: formatDate(1),
595
+ dimensions,
596
+ rowLimit
597
+ })
598
+ }
599
+ );
600
+ if (!res.ok) return [];
601
+ const data = await res.json();
602
+ return data.rows ?? [];
603
+ } catch {
604
+ return [];
605
+ }
606
+ }
553
607
  var googleSearchConsoleOauthSetupFlow = {
554
608
  initialState: () => ({}),
555
609
  steps: [
@@ -588,7 +642,6 @@ var googleSearchConsoleOauthSetupFlow = {
588
642
  }
589
643
  const allSites = await listSites(rt.config.proxyFetch);
590
644
  const verified = allSites.filter(isVerified);
591
- const siteByUrl = new Map(verified.map((s) => [s.siteUrl ?? "", s]));
592
645
  const targetSiteUrls = await resolveSetupSelection({
593
646
  selected: state.sites,
594
647
  allSentinel: ALL_SITES,
@@ -600,15 +653,98 @@ var googleSearchConsoleOauthSetupFlow = {
600
653
  sections.push("_No sites selected._", "");
601
654
  return sections.join("\n");
602
655
  }
603
- sections.push("| Site URL | Permission Level |");
604
- sections.push("|----------|------------------|");
605
656
  for (const siteUrl of targetSiteUrls) {
606
- const site = siteByUrl.get(siteUrl);
607
- const permission = site?.permissionLevel ?? "-";
608
657
  const safeSiteUrl = siteUrl.replace(/\|/g, "\\|");
609
- sections.push(`| ${safeSiteUrl} | ${permission} |`);
658
+ sections.push(`### Site: ${safeSiteUrl}`, "");
659
+ const topQueries = await querySearchAnalytics(
660
+ rt.config.proxyFetch,
661
+ siteUrl,
662
+ ["query"],
663
+ 10
664
+ );
665
+ if (topQueries.length > 0) {
666
+ sections.push("#### Top Search Queries (last 28 days)", "");
667
+ sections.push("| Query | Clicks | Impressions | CTR | Avg Position |");
668
+ sections.push("|-------|--------|-------------|-----|-------------|");
669
+ for (const row of topQueries) {
670
+ const q = (row.keys?.[0] ?? "").replace(/\|/g, "\\|");
671
+ const clicks = row.clicks ?? 0;
672
+ const impressions = row.impressions ?? 0;
673
+ const ctr = ((row.ctr ?? 0) * 100).toFixed(1);
674
+ const pos = (row.position ?? 0).toFixed(1);
675
+ sections.push(
676
+ `| ${q} | ${clicks} | ${impressions} | ${ctr}% | ${pos} |`
677
+ );
678
+ }
679
+ sections.push("");
680
+ }
681
+ const topPages = await querySearchAnalytics(
682
+ rt.config.proxyFetch,
683
+ siteUrl,
684
+ ["page"],
685
+ 10
686
+ );
687
+ if (topPages.length > 0) {
688
+ sections.push("#### Top Pages (last 28 days)", "");
689
+ sections.push("| Page | Clicks | Impressions | CTR | Avg Position |");
690
+ sections.push("|------|--------|-------------|-----|-------------|");
691
+ for (const row of topPages) {
692
+ const pg = (row.keys?.[0] ?? "").replace(/\|/g, "\\|");
693
+ const clicks = row.clicks ?? 0;
694
+ const impressions = row.impressions ?? 0;
695
+ const ctr = ((row.ctr ?? 0) * 100).toFixed(1);
696
+ const pos = (row.position ?? 0).toFixed(1);
697
+ sections.push(
698
+ `| ${pg} | ${clicks} | ${impressions} | ${ctr}% | ${pos} |`
699
+ );
700
+ }
701
+ sections.push("");
702
+ }
703
+ const deviceRows = await querySearchAnalytics(
704
+ rt.config.proxyFetch,
705
+ siteUrl,
706
+ ["device"],
707
+ 5
708
+ );
709
+ if (deviceRows.length > 0) {
710
+ sections.push("#### Device Breakdown (last 28 days)", "");
711
+ sections.push("| Device | Clicks | Impressions | CTR | Avg Position |");
712
+ sections.push("|--------|--------|-------------|-----|-------------|");
713
+ for (const row of deviceRows) {
714
+ const dev = row.keys?.[0] ?? "";
715
+ const clicks = row.clicks ?? 0;
716
+ const impressions = row.impressions ?? 0;
717
+ const ctr = ((row.ctr ?? 0) * 100).toFixed(1);
718
+ const pos = (row.position ?? 0).toFixed(1);
719
+ sections.push(
720
+ `| ${dev} | ${clicks} | ${impressions} | ${ctr}% | ${pos} |`
721
+ );
722
+ }
723
+ sections.push("");
724
+ }
725
+ const countryRows = await querySearchAnalytics(
726
+ rt.config.proxyFetch,
727
+ siteUrl,
728
+ ["country"],
729
+ 10
730
+ );
731
+ if (countryRows.length > 0) {
732
+ sections.push("#### Top Countries (last 28 days)", "");
733
+ sections.push("| Country | Clicks | Impressions | CTR | Avg Position |");
734
+ sections.push("|---------|--------|-------------|-----|-------------|");
735
+ for (const row of countryRows) {
736
+ const c = row.keys?.[0] ?? "";
737
+ const clicks = row.clicks ?? 0;
738
+ const impressions = row.impressions ?? 0;
739
+ const ctr = ((row.ctr ?? 0) * 100).toFixed(1);
740
+ const pos = (row.position ?? 0).toFixed(1);
741
+ sections.push(
742
+ `| ${c} | ${clicks} | ${impressions} | ${ctr}% | ${pos} |`
743
+ );
744
+ }
745
+ sections.push("");
746
+ }
610
747
  }
611
- sections.push("");
612
748
  return sections.join("\n");
613
749
  }
614
750
  };
@@ -771,8 +907,8 @@ var googleSearchConsoleOauthConnector = new ConnectorPlugin({
771
907
  systemPrompt: {
772
908
  en: `### Tools
773
909
 
774
- - \`google-search-console-oauth_request\`: Send authenticated requests to the Google Search Console API (Webmasters v3). Use it for searchAnalytics queries, sitemap inspection, and site metadata. The {siteUrl} placeholder in paths is automatically replaced and URL-encoded. Authentication is configured automatically via OAuth.
775
- - \`google-search-console-oauth_listSites\`: List accessible Search Console sites. Use during setup to discover available properties.
910
+ - \`connector_google-search-console-oauth_request\`: Send authenticated requests to the Google Search Console API (Webmasters v3). Use it for searchAnalytics queries, sitemap inspection, and site metadata. The {siteUrl} placeholder in paths is automatically replaced and URL-encoded. Authentication is configured automatically via OAuth.
911
+ - \`connector_google-search-console-oauth_listSites\`: List accessible Search Console sites. Use during setup to discover available properties.
776
912
 
777
913
  ### Search Console API Reference
778
914
 
@@ -857,8 +993,8 @@ sitemaps.forEach(s => console.log(s.path, s.lastSubmitted));
857
993
  \`\`\``,
858
994
  ja: `### \u30C4\u30FC\u30EB
859
995
 
860
- - \`google-search-console-oauth_request\`: Google Search Console API (Webmasters v3) \u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002searchAnalytics \u30AF\u30A8\u30EA\u3001\u30B5\u30A4\u30C8\u30DE\u30C3\u30D7\u78BA\u8A8D\u3001\u30B5\u30A4\u30C8\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{siteUrl}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u81EA\u52D5\u7684\u306BURL\u30A8\u30F3\u30B3\u30FC\u30C9\u3055\u308C\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
861
- - \`google-search-console-oauth_listSites\`: \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306ASearch Console\u30B5\u30A4\u30C8\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u5229\u7528\u53EF\u80FD\u306A\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u78BA\u8A8D\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
996
+ - \`connector_google-search-console-oauth_request\`: Google Search Console API (Webmasters v3) \u3078\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002searchAnalytics \u30AF\u30A8\u30EA\u3001\u30B5\u30A4\u30C8\u30DE\u30C3\u30D7\u78BA\u8A8D\u3001\u30B5\u30A4\u30C8\u30E1\u30BF\u30C7\u30FC\u30BF\u306E\u53D6\u5F97\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{siteUrl}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u81EA\u52D5\u7684\u306BURL\u30A8\u30F3\u30B3\u30FC\u30C9\u3055\u308C\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002OAuth\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
997
+ - \`connector_google-search-console-oauth_listSites\`: \u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u306ASearch Console\u30B5\u30A4\u30C8\u306E\u4E00\u89A7\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306B\u5229\u7528\u53EF\u80FD\u306A\u30D7\u30ED\u30D1\u30C6\u30A3\u3092\u78BA\u8A8D\u3059\u308B\u305F\u3081\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002
862
998
 
863
999
  ### Search Console API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
864
1000
 
@@ -16,6 +16,7 @@ var init_parameter_definition = __esm({
16
16
  type;
17
17
  secret;
18
18
  required;
19
+ isDeprecated;
19
20
  constructor(config) {
20
21
  this.slug = config.slug;
21
22
  this.name = config.name;
@@ -24,6 +25,7 @@ var init_parameter_definition = __esm({
24
25
  this.type = config.type;
25
26
  this.secret = config.secret;
26
27
  this.required = config.required;
28
+ this.isDeprecated = config.isDeprecated ?? false;
27
29
  }
28
30
  /**
29
31
  * Get the parameter value from a ConnectorConnectionObject.
@@ -241,7 +243,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
241
243
  /**
242
244
  * Create tools for connections that belong to this connector.
243
245
  * Filters connections by connectorKey internally.
244
- * Returns tools keyed as `${connectorKey}_${toolName}`.
246
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
245
247
  */
246
248
  createTools(connections, config, opts) {
247
249
  const myConnections = connections.filter(
@@ -251,7 +253,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
251
253
  for (const t of Object.values(this.tools)) {
252
254
  const tool = t.createTool(myConnections, config);
253
255
  const originalToModelOutput = tool.toModelOutput;
254
- result[`${this.connectorKey}_${t.name}`] = {
256
+ result[`connector_${this.connectorKey}_${t.name}`] = {
255
257
  ...tool,
256
258
  toModelOutput: async (options) => {
257
259
  if (!originalToModelOutput) {
@@ -307,19 +309,34 @@ async function runSetupFlow(flow, params, ctx, config) {
307
309
  };
308
310
  let state = flow.initialState();
309
311
  let answerIdx = 0;
312
+ const pendingParameterUpdates = [];
310
313
  for (const step of flow.steps) {
311
314
  const ans = ctx.answers[answerIdx];
312
315
  if (ans && ans.questionSlug === step.slug) {
313
316
  state = step.applyAnswer(state, ans.answer);
317
+ if (step.toParameterUpdates) {
318
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
319
+ }
314
320
  answerIdx += 1;
315
321
  continue;
316
322
  }
323
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
317
324
  if (step.type === "text") {
325
+ if (step.fetchOptions) {
326
+ const options2 = await step.fetchOptions(state, runtime);
327
+ if (options2.length === 0) {
328
+ continue;
329
+ }
330
+ }
318
331
  return {
319
332
  type: "nextQuestion",
320
333
  questionSlug: step.slug,
321
334
  question: step.question[ctx.language],
322
- questionType: "text"
335
+ questionType: "text",
336
+ allowFreeText: resolvedAllowFreeText,
337
+ ...pendingParameterUpdates.length > 0 && {
338
+ parameterUpdates: pendingParameterUpdates
339
+ }
323
340
  };
324
341
  }
325
342
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -331,11 +348,21 @@ async function runSetupFlow(flow, params, ctx, config) {
331
348
  questionSlug: step.slug,
332
349
  question: step.question[ctx.language],
333
350
  questionType: step.type,
334
- options
351
+ options,
352
+ allowFreeText: resolvedAllowFreeText,
353
+ ...pendingParameterUpdates.length > 0 && {
354
+ parameterUpdates: pendingParameterUpdates
355
+ }
335
356
  };
336
357
  }
337
358
  const dataInvestigationResult = await flow.finalize(state, runtime);
338
- return { type: "fulfilled", dataInvestigationResult };
359
+ return {
360
+ type: "fulfilled",
361
+ dataInvestigationResult,
362
+ ...pendingParameterUpdates.length > 0 && {
363
+ parameterUpdates: pendingParameterUpdates
364
+ }
365
+ };
339
366
  }
340
367
  async function resolveSetupSelection(params) {
341
368
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -676,9 +703,9 @@ var googleSheetsConnector = new ConnectorPlugin({
676
703
  systemPrompt: {
677
704
  en: `### Tools (setup-time only)
678
705
 
679
- - \`google-sheets-oauth_request\`: Call the Google Sheets API during setup / data overview. Supports GET, POST, and PUT. The caller must include the target spreadsheetId in the path explicitly (e.g., \`/1AbCxyz...\`, \`/1AbCxyz.../values/Sheet1!A1:D10\`). Authentication is configured automatically via OAuth.
706
+ - \`connector_google-sheets-oauth_request\`: Call the Google Sheets API during setup / data overview. Supports GET, POST, and PUT. The caller must include the target spreadsheetId in the path explicitly (e.g., \`/1AbCxyz...\`, \`/1AbCxyz.../values/Sheet1!A1:D10\`). Authentication is configured automatically via OAuth.
680
707
 
681
- > **Important**: The \`google-sheets-oauth_request\` tool is only available at setup time. Inside server-logic handlers, use the SDK (\`connection(id).getValues(spreadsheetId, range)\`, etc.) \u2014 the SDK's fetch is already wired through the OAuth proxy. **Do NOT** hand-roll HTTP calls to \`_sqcore/connections/*/request\` from a handler.
708
+ > **Important**: The \`connector_google-sheets-oauth_request\` tool is only available at setup time. Inside server-logic handlers, use the SDK (\`connection(id).getValues(spreadsheetId, range)\`, etc.) \u2014 the SDK's fetch is already wired through the OAuth proxy. **Do NOT** hand-roll HTTP calls to \`_sqcore/connections/*/request\` from a handler.
682
709
 
683
710
  > **Connection scope**: The OAuth scope is \`spreadsheets\` (read/write). A connection is NOT bound to a single spreadsheet \u2014 the target spreadsheetId is passed per call. The spreadsheetId is NOT stored as a connection parameter or environment variable; pass it explicitly from the caller (e.g., as a query param or request input to the handler).
684
711
 
@@ -750,9 +777,9 @@ await sheets.batchUpdate(spreadsheetId, [
750
777
  \`\`\``,
751
778
  ja: `### \u30C4\u30FC\u30EB\uFF08\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\uFF09
752
779
 
753
- - \`google-sheets-oauth_request\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3084\u30C7\u30FC\u30BF\u6982\u8981\u628A\u63E1\u6642\u306B Google Sheets API \u3092\u547C\u3073\u51FA\u3059\u30C4\u30FC\u30EB\u3067\u3059\u3002GET / POST / PUT \u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\u547C\u3073\u51FA\u3057\u5074\u304C\u30D1\u30B9\u306B\u5BFE\u8C61\u306E spreadsheetId \u3092\u660E\u793A\u7684\u306B\u542B\u3081\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u4F8B: \`/1AbCxyz...\`\u3001\`/1AbCxyz.../values/Sheet1!A1:D10\`\uFF09\u3002OAuth \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
780
+ - \`connector_google-sheets-oauth_request\`: \u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u3084\u30C7\u30FC\u30BF\u6982\u8981\u628A\u63E1\u6642\u306B Google Sheets API \u3092\u547C\u3073\u51FA\u3059\u30C4\u30FC\u30EB\u3067\u3059\u3002GET / POST / PUT \u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\u547C\u3073\u51FA\u3057\u5074\u304C\u30D1\u30B9\u306B\u5BFE\u8C61\u306E spreadsheetId \u3092\u660E\u793A\u7684\u306B\u542B\u3081\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\uFF08\u4F8B: \`/1AbCxyz...\`\u3001\`/1AbCxyz.../values/Sheet1!A1:D10\`\uFF09\u3002OAuth \u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002
754
781
 
755
- > **\u91CD\u8981**: \`google-sheets-oauth_request\` \u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\u5229\u7528\u53EF\u80FD\u3067\u3059\u3002\u30B5\u30FC\u30D0\u30FC\u30ED\u30B8\u30C3\u30AF\u306E\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u5FC5\u305A SDK\uFF08\`connection(id).getValues(spreadsheetId, range)\` \u306A\u3069\uFF09\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002SDK \u306E fetch \u306F OAuth \u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u65E2\u306B\u914D\u7DDA\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089 \`_sqcore/connections/*/request\` \u3092\u624B\u66F8\u304D\u3067\u547C\u3073\u51FA\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
782
+ > **\u91CD\u8981**: \`connector_google-sheets-oauth_request\` \u306F\u30BB\u30C3\u30C8\u30A2\u30C3\u30D7\u6642\u306E\u307F\u5229\u7528\u53EF\u80FD\u3067\u3059\u3002\u30B5\u30FC\u30D0\u30FC\u30ED\u30B8\u30C3\u30AF\u306E\u30CF\u30F3\u30C9\u30E9\u5185\u3067\u306F\u5FC5\u305A SDK\uFF08\`connection(id).getValues(spreadsheetId, range)\` \u306A\u3069\uFF09\u3092\u4F7F\u3063\u3066\u304F\u3060\u3055\u3044\u3002SDK \u306E fetch \u306F OAuth \u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u65E2\u306B\u914D\u7DDA\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u30CF\u30F3\u30C9\u30E9\u304B\u3089 \`_sqcore/connections/*/request\` \u3092\u624B\u66F8\u304D\u3067\u547C\u3073\u51FA\u3055\u306A\u3044\u3067\u304F\u3060\u3055\u3044\u3002
756
783
 
757
784
  > **\u63A5\u7D9A\u30B9\u30B3\u30FC\u30D7**: OAuth \u30B9\u30B3\u30FC\u30D7\u306F \`spreadsheets\`\uFF08\u8AAD\u307F\u66F8\u304D\u53EF\u80FD\uFF09\u3067\u3059\u3002\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u306F\u5358\u4E00\u306E\u30B9\u30D7\u30EC\u30C3\u30C9\u30B7\u30FC\u30C8\u306B\u7D10\u3065\u304D\u307E\u305B\u3093 \u2014 \u5BFE\u8C61\u306E spreadsheetId \u306F\u547C\u3073\u51FA\u3057\u3054\u3068\u306B\u6E21\u3057\u307E\u3059\u3002spreadsheetId \u306F\u30B3\u30CD\u30AF\u30B7\u30E7\u30F3\u30D1\u30E9\u30E1\u30FC\u30BF\u3084\u74B0\u5883\u5909\u6570\u3068\u3057\u3066\u4FDD\u5B58\u3055\u308C\u306A\u3044\u305F\u3081\u3001\u30CF\u30F3\u30C9\u30E9\u306E\u547C\u3073\u51FA\u3057\u5143\uFF08\u30EA\u30AF\u30A8\u30B9\u30C8\u5165\u529B\u306A\u3069\uFF09\u304B\u3089\u660E\u793A\u7684\u306B\u6E21\u3057\u3066\u304F\u3060\u3055\u3044\u3002
758
785