@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
@@ -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.
@@ -286,7 +288,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
286
288
  /**
287
289
  * Create tools for connections that belong to this connector.
288
290
  * Filters connections by connectorKey internally.
289
- * Returns tools keyed as `${connectorKey}_${toolName}`.
291
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
290
292
  */
291
293
  createTools(connections, config, opts) {
292
294
  const myConnections = connections.filter(
@@ -296,7 +298,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
296
298
  for (const t of Object.values(this.tools)) {
297
299
  const tool = t.createTool(myConnections, config);
298
300
  const originalToModelOutput = tool.toModelOutput;
299
- result[`${this.connectorKey}_${t.name}`] = {
301
+ result[`connector_${this.connectorKey}_${t.name}`] = {
300
302
  ...tool,
301
303
  toModelOutput: async (options) => {
302
304
  if (!originalToModelOutput) {
@@ -352,19 +354,34 @@ async function runSetupFlow(flow, params, ctx, config) {
352
354
  };
353
355
  let state = flow.initialState();
354
356
  let answerIdx = 0;
357
+ const pendingParameterUpdates = [];
355
358
  for (const step of flow.steps) {
356
359
  const ans = ctx.answers[answerIdx];
357
360
  if (ans && ans.questionSlug === step.slug) {
358
361
  state = step.applyAnswer(state, ans.answer);
362
+ if (step.toParameterUpdates) {
363
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
364
+ }
359
365
  answerIdx += 1;
360
366
  continue;
361
367
  }
368
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
362
369
  if (step.type === "text") {
370
+ if (step.fetchOptions) {
371
+ const options2 = await step.fetchOptions(state, runtime);
372
+ if (options2.length === 0) {
373
+ continue;
374
+ }
375
+ }
363
376
  return {
364
377
  type: "nextQuestion",
365
378
  questionSlug: step.slug,
366
379
  question: step.question[ctx.language],
367
- questionType: "text"
380
+ questionType: "text",
381
+ allowFreeText: resolvedAllowFreeText,
382
+ ...pendingParameterUpdates.length > 0 && {
383
+ parameterUpdates: pendingParameterUpdates
384
+ }
368
385
  };
369
386
  }
370
387
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -376,11 +393,21 @@ async function runSetupFlow(flow, params, ctx, config) {
376
393
  questionSlug: step.slug,
377
394
  question: step.question[ctx.language],
378
395
  questionType: step.type,
379
- options
396
+ options,
397
+ allowFreeText: resolvedAllowFreeText,
398
+ ...pendingParameterUpdates.length > 0 && {
399
+ parameterUpdates: pendingParameterUpdates
400
+ }
380
401
  };
381
402
  }
382
403
  const dataInvestigationResult = await flow.finalize(state, runtime);
383
- return { type: "fulfilled", dataInvestigationResult };
404
+ return {
405
+ type: "fulfilled",
406
+ dataInvestigationResult,
407
+ ...pendingParameterUpdates.length > 0 && {
408
+ parameterUpdates: pendingParameterUpdates
409
+ }
410
+ };
384
411
  }
385
412
  async function resolveSetupSelection(params) {
386
413
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -401,12 +428,12 @@ var AUTH_TYPES = {
401
428
  // ../connectors/src/connectors/sentry/setup.ts
402
429
  var sentryOnboarding = new ConnectorOnboarding({
403
430
  dataOverviewInstructions: {
404
- en: `1. Call sentry_request with GET /organizations/{organizationSlug}/projects/ to list all projects
405
- 2. Call sentry_request with GET /organizations/{organizationSlug}/issues/?sort=date&query=is:unresolved to get recent unresolved issues
406
- 3. For a specific issue, call sentry_request with GET /organizations/{organizationSlug}/issues/{issueId}/ to get details`,
407
- ja: `1. sentry_request \u3067 GET /organizations/{organizationSlug}/projects/ \u3092\u547C\u3073\u51FA\u3057\u3001\u5168\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u4E00\u89A7\u8868\u793A
408
- 2. sentry_request \u3067 GET /organizations/{organizationSlug}/issues/?sort=date&query=is:unresolved \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u8FD1\u306E\u672A\u89E3\u6C7A\u30A4\u30B7\u30E5\u30FC\u3092\u53D6\u5F97
409
- 3. \u7279\u5B9A\u306E\u30A4\u30B7\u30E5\u30FC\u306B\u3064\u3044\u3066 sentry_request \u3067 GET /organizations/{organizationSlug}/issues/{issueId}/ \u3092\u547C\u3073\u51FA\u3057\u3001\u8A73\u7D30\u3092\u53D6\u5F97`
431
+ en: `1. Call connector_sentry_request with GET /organizations/{organizationSlug}/projects/ to list all projects
432
+ 2. Call connector_sentry_request with GET /organizations/{organizationSlug}/issues/?sort=date&query=is:unresolved to get recent unresolved issues
433
+ 3. For a specific issue, call connector_sentry_request with GET /organizations/{organizationSlug}/issues/{issueId}/ to get details`,
434
+ ja: `1. connector_sentry_request \u3067 GET /organizations/{organizationSlug}/projects/ \u3092\u547C\u3073\u51FA\u3057\u3001\u5168\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u3092\u4E00\u89A7\u8868\u793A
435
+ 2. connector_sentry_request \u3067 GET /organizations/{organizationSlug}/issues/?sort=date&query=is:unresolved \u3092\u547C\u3073\u51FA\u3057\u3001\u6700\u8FD1\u306E\u672A\u89E3\u6C7A\u30A4\u30B7\u30E5\u30FC\u3092\u53D6\u5F97
436
+ 3. \u7279\u5B9A\u306E\u30A4\u30B7\u30E5\u30FC\u306B\u3064\u3044\u3066 connector_sentry_request \u3067 GET /organizations/{organizationSlug}/issues/{issueId}/ \u3092\u547C\u3073\u51FA\u3057\u3001\u8A73\u7D30\u3092\u53D6\u5F97`
410
437
  }
411
438
  });
412
439
 
@@ -436,6 +463,19 @@ async function listOrganizations(params) {
436
463
  const data = await res.json();
437
464
  return data ?? [];
438
465
  }
466
+ async function listRecentIssues(params, orgSlug, projectSlug) {
467
+ try {
468
+ const res = await apiFetch(
469
+ params,
470
+ `/projects/${orgSlug}/${projectSlug}/issues/?limit=5&query=is:unresolved`
471
+ );
472
+ if (!res.ok) return [];
473
+ const data = await res.json();
474
+ return data ?? [];
475
+ } catch {
476
+ return [];
477
+ }
478
+ }
439
479
  async function listProjects(params, orgSlug) {
440
480
  const res = await apiFetch(params, `/organizations/${orgSlug}/projects/`);
441
481
  if (!res.ok) {
@@ -517,6 +557,19 @@ var sentrySetupFlow = {
517
557
  sections.push(`| First event | ${project.firstEvent ?? "-"} |`);
518
558
  sections.push(`| Created | ${project.dateCreated ?? "-"} |`);
519
559
  sections.push("");
560
+ const issues = await listRecentIssues(rt.params, orgSlug, project.slug);
561
+ if (issues.length > 0) {
562
+ sections.push("##### Recent unresolved issues", "");
563
+ sections.push("| ID | Title | Level | Events | Users | Last seen |");
564
+ sections.push("|----|-------|-------|--------|-------|-----------|");
565
+ for (const issue of issues) {
566
+ const title = (issue.title ?? "").replace(/\|/g, "\\|").slice(0, 60);
567
+ sections.push(
568
+ `| ${issue.shortId ?? "-"} | ${title || "-"} | ${issue.level ?? "-"} | ${issue.count ?? "-"} | ${issue.userCount ?? "-"} | ${issue.lastSeen ?? "-"} |`
569
+ );
570
+ }
571
+ sections.push("");
572
+ }
520
573
  }
521
574
  return sections.join("\n");
522
575
  }
@@ -619,7 +672,7 @@ var sentryConnector = new ConnectorPlugin({
619
672
  systemPrompt: {
620
673
  en: `### Tools
621
674
 
622
- - \`sentry_request\`: Send authenticated requests to the Sentry API. Supports GET, POST, PUT, and DELETE methods. Authentication is handled automatically via Bearer token. The {organizationSlug} placeholder in paths is automatically replaced with the configured organization slug.
675
+ - \`connector_sentry_request\`: Send authenticated requests to the Sentry API. Supports GET, POST, PUT, and DELETE methods. Authentication is handled automatically via Bearer token. The {organizationSlug} placeholder in paths is automatically replaced with the configured organization slug.
623
676
 
624
677
  ### Sentry API Reference
625
678
 
@@ -702,7 +755,7 @@ await sentry.updateIssue("12345", { status: "resolved" });
702
755
  \`\`\``,
703
756
  ja: `### \u30C4\u30FC\u30EB
704
757
 
705
- - \`sentry_request\`: Sentry API\u3078\u306E\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002GET, POST, PUT, DELETE\u30E1\u30BD\u30C3\u30C9\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002Bearer token\u306B\u3088\u308B\u8A8D\u8A3C\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{organizationSlug}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u8A2D\u5B9A\u6E08\u307F\u306E\u7D44\u7E54\u30B9\u30E9\u30C3\u30B0\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002
758
+ - \`connector_sentry_request\`: Sentry API\u3078\u306E\u8A8D\u8A3C\u6E08\u307F\u30EA\u30AF\u30A8\u30B9\u30C8\u3092\u9001\u4FE1\u3057\u307E\u3059\u3002GET, POST, PUT, DELETE\u30E1\u30BD\u30C3\u30C9\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002Bearer token\u306B\u3088\u308B\u8A8D\u8A3C\u306F\u81EA\u52D5\u3067\u884C\u308F\u308C\u307E\u3059\u3002\u30D1\u30B9\u5185\u306E{organizationSlug}\u30D7\u30EC\u30FC\u30B9\u30DB\u30EB\u30C0\u30FC\u306F\u8A2D\u5B9A\u6E08\u307F\u306E\u7D44\u7E54\u30B9\u30E9\u30C3\u30B0\u3067\u81EA\u52D5\u7684\u306B\u7F6E\u63DB\u3055\u308C\u307E\u3059\u3002
706
759
 
707
760
  ### Sentry API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
708
761
 
@@ -112,7 +112,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
112
112
  /**
113
113
  * Create tools for connections that belong to this connector.
114
114
  * Filters connections by connectorKey internally.
115
- * Returns tools keyed as `${connectorKey}_${toolName}`.
115
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
116
116
  */
117
117
  createTools(connections, config, opts) {
118
118
  const myConnections = connections.filter(
@@ -122,7 +122,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
122
122
  for (const t of Object.values(this.tools)) {
123
123
  const tool = t.createTool(myConnections, config);
124
124
  const originalToModelOutput = tool.toModelOutput;
125
- result[`${this.connectorKey}_${t.name}`] = {
125
+ result[`connector_${this.connectorKey}_${t.name}`] = {
126
126
  ...tool,
127
127
  toModelOutput: async (options) => {
128
128
  if (!originalToModelOutput) {
@@ -178,19 +178,34 @@ async function runSetupFlow(flow, params, ctx, config) {
178
178
  };
179
179
  let state = flow.initialState();
180
180
  let answerIdx = 0;
181
+ const pendingParameterUpdates = [];
181
182
  for (const step of flow.steps) {
182
183
  const ans = ctx.answers[answerIdx];
183
184
  if (ans && ans.questionSlug === step.slug) {
184
185
  state = step.applyAnswer(state, ans.answer);
186
+ if (step.toParameterUpdates) {
187
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
188
+ }
185
189
  answerIdx += 1;
186
190
  continue;
187
191
  }
192
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
188
193
  if (step.type === "text") {
194
+ if (step.fetchOptions) {
195
+ const options2 = await step.fetchOptions(state, runtime);
196
+ if (options2.length === 0) {
197
+ continue;
198
+ }
199
+ }
189
200
  return {
190
201
  type: "nextQuestion",
191
202
  questionSlug: step.slug,
192
203
  question: step.question[ctx.language],
193
- questionType: "text"
204
+ questionType: "text",
205
+ allowFreeText: resolvedAllowFreeText,
206
+ ...pendingParameterUpdates.length > 0 && {
207
+ parameterUpdates: pendingParameterUpdates
208
+ }
194
209
  };
195
210
  }
196
211
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -202,11 +217,21 @@ async function runSetupFlow(flow, params, ctx, config) {
202
217
  questionSlug: step.slug,
203
218
  question: step.question[ctx.language],
204
219
  questionType: step.type,
205
- options
220
+ options,
221
+ allowFreeText: resolvedAllowFreeText,
222
+ ...pendingParameterUpdates.length > 0 && {
223
+ parameterUpdates: pendingParameterUpdates
224
+ }
206
225
  };
207
226
  }
208
227
  const dataInvestigationResult = await flow.finalize(state, runtime);
209
- return { type: "fulfilled", dataInvestigationResult };
228
+ return {
229
+ type: "fulfilled",
230
+ dataInvestigationResult,
231
+ ...pendingParameterUpdates.length > 0 && {
232
+ parameterUpdates: pendingParameterUpdates
233
+ }
234
+ };
210
235
  }
211
236
 
212
237
  // ../connectors/src/auth-types.ts
@@ -359,11 +384,11 @@ var shopifyOauthOnboarding = new ConnectorOnboarding({
359
384
  - Write only 1 sentence between tool calls, then immediately call the next tool. Skip unnecessary explanations and proceed efficiently`
360
385
  },
361
386
  dataOverviewInstructions: {
362
- en: `1. Call shopify-oauth_request with GET /admin/api/2024-10/products.json?limit=5 to explore products structure
363
- 2. Call shopify-oauth_request with GET /admin/api/2024-10/orders.json?limit=5 to explore orders structure
387
+ en: `1. Call connector_shopify-oauth_request with GET /admin/api/2024-10/products.json?limit=5 to explore products structure
388
+ 2. Call connector_shopify-oauth_request with GET /admin/api/2024-10/orders.json?limit=5 to explore orders structure
364
389
  3. Explore other endpoints (customers, inventory, collections) as needed`,
365
- ja: `1. shopify-oauth_request \u3067 GET /admin/api/2024-10/products.json?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u5546\u54C1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
366
- 2. shopify-oauth_request \u3067 GET /admin/api/2024-10/orders.json?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u6CE8\u6587\u306E\u69CB\u9020\u3092\u78BA\u8A8D
390
+ ja: `1. connector_shopify-oauth_request \u3067 GET /admin/api/2024-10/products.json?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u5546\u54C1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
391
+ 2. connector_shopify-oauth_request \u3067 GET /admin/api/2024-10/orders.json?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u6CE8\u6587\u306E\u69CB\u9020\u3092\u78BA\u8A8D
367
392
  3. \u5FC5\u8981\u306B\u5FDC\u3058\u3066\u4ED6\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\uFF08\u9867\u5BA2\u3001\u5728\u5EAB\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\uFF09\u3092\u63A2\u7D22`
368
393
  }
369
394
  });
@@ -425,6 +450,9 @@ var shopifyOauthSetupFlow = {
425
450
  (e) => ENTITY_VALUES.includes(e)
426
451
  ).slice(0, SHOPIFY_OAUTH_SETUP_MAX_ENTITIES);
427
452
  const sections = ["## Shopify", ""];
453
+ sections.push("### Entity counts", "");
454
+ sections.push("| Entity | Count |");
455
+ sections.push("|--------|-------|");
428
456
  for (const entity of selected) {
429
457
  const path2 = COUNT_PATHS[entity];
430
458
  let count = "available";
@@ -435,8 +463,38 @@ var shopifyOauthSetupFlow = {
435
463
  if (typeof data.count === "number") count = String(data.count);
436
464
  }
437
465
  }
438
- sections.push(`### ${ENTITY_LABELS[entity].en}`, "");
439
- sections.push(`Count: ${count}`, "");
466
+ sections.push(`| ${ENTITY_LABELS[entity].en} | ${count} |`);
467
+ }
468
+ sections.push("");
469
+ if (selected.includes("orders")) {
470
+ try {
471
+ const ordersRes = await rt.config.proxyFetch(
472
+ `/admin/api/${SHOPIFY_API_VERSION}/orders.json?limit=5&status=any&order=created_at+desc`,
473
+ { method: "GET" }
474
+ );
475
+ if (ordersRes.ok) {
476
+ const ordersData = await ordersRes.json();
477
+ const orders = ordersData.orders ?? [];
478
+ if (orders.length > 0) {
479
+ sections.push("### Recent orders (sample)", "");
480
+ sections.push(
481
+ "| Order | Total | Status | Created |"
482
+ );
483
+ sections.push(
484
+ "|-------|-------|--------|---------|"
485
+ );
486
+ for (const o of orders.slice(0, 5)) {
487
+ const name = (o.name ?? `#${o.order_number ?? "?"}`).replace(/\|/g, "\\|");
488
+ const total = o.total_price ? `${o.total_price} ${o.currency ?? ""}`.trim() : "-";
489
+ const status = o.financial_status ?? "-";
490
+ const created = o.created_at ? o.created_at.slice(0, 10) : "-";
491
+ sections.push(`| ${name} | ${total} | ${status} | ${created} |`);
492
+ }
493
+ sections.push("");
494
+ }
495
+ }
496
+ } catch {
497
+ }
440
498
  }
441
499
  return sections.join("\n");
442
500
  }
@@ -466,7 +524,7 @@ var shopifyOauthConnector = new ConnectorPlugin({
466
524
  systemPrompt: {
467
525
  en: `### Tools
468
526
 
469
- - \`shopify-oauth_request\`: The only way to call the Shopify Admin REST API. Use it to query products, orders, customers, inventory, collections, and more. Authentication is configured automatically via OAuth proxy. Shopify uses cursor-based pagination via the \`page_info\` query parameter (obtained from the Link header in the response).
527
+ - \`connector_shopify-oauth_request\`: The only way to call the Shopify Admin REST API. Use it to query products, orders, customers, inventory, collections, and more. Authentication is configured automatically via OAuth proxy. Shopify uses cursor-based pagination via the \`page_info\` query parameter (obtained from the Link header in the response).
470
528
 
471
529
  ### Shopify Admin REST API Reference
472
530
 
@@ -513,7 +571,7 @@ const data = await res.json();
513
571
  \`\`\``,
514
572
  ja: `### \u30C4\u30FC\u30EB
515
573
 
516
- - \`shopify-oauth_request\`: Shopify Admin REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u5546\u54C1\u3001\u6CE8\u6587\u3001\u9867\u5BA2\u3001\u5728\u5EAB\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306A\u3069\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Shopify\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E Link \u30D8\u30C3\u30C0\u30FC\u304B\u3089\u53D6\u5F97\u3059\u308B \`page_info\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
574
+ - \`connector_shopify-oauth_request\`: Shopify Admin REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u5546\u54C1\u3001\u6CE8\u6587\u3001\u9867\u5BA2\u3001\u5728\u5EAB\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306A\u3069\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002OAuth\u30D7\u30ED\u30AD\u30B7\u7D4C\u7531\u3067\u8A8D\u8A3C\u306F\u81EA\u52D5\u8A2D\u5B9A\u3055\u308C\u307E\u3059\u3002Shopify\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E Link \u30D8\u30C3\u30C0\u30FC\u304B\u3089\u53D6\u5F97\u3059\u308B \`page_info\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
517
575
 
518
576
  ### Shopify Admin REST API \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9
519
577
 
@@ -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.
@@ -399,7 +401,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
399
401
  /**
400
402
  * Create tools for connections that belong to this connector.
401
403
  * Filters connections by connectorKey internally.
402
- * Returns tools keyed as `${connectorKey}_${toolName}`.
404
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
403
405
  */
404
406
  createTools(connections, config, opts) {
405
407
  const myConnections = connections.filter(
@@ -409,7 +411,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
409
411
  for (const t of Object.values(this.tools)) {
410
412
  const tool = t.createTool(myConnections, config);
411
413
  const originalToModelOutput = tool.toModelOutput;
412
- result[`${this.connectorKey}_${t.name}`] = {
414
+ result[`connector_${this.connectorKey}_${t.name}`] = {
413
415
  ...tool,
414
416
  toModelOutput: async (options) => {
415
417
  if (!originalToModelOutput) {
@@ -465,19 +467,34 @@ async function runSetupFlow(flow, params, ctx, config) {
465
467
  };
466
468
  let state = flow.initialState();
467
469
  let answerIdx = 0;
470
+ const pendingParameterUpdates = [];
468
471
  for (const step of flow.steps) {
469
472
  const ans = ctx.answers[answerIdx];
470
473
  if (ans && ans.questionSlug === step.slug) {
471
474
  state = step.applyAnswer(state, ans.answer);
475
+ if (step.toParameterUpdates) {
476
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
477
+ }
472
478
  answerIdx += 1;
473
479
  continue;
474
480
  }
481
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
475
482
  if (step.type === "text") {
483
+ if (step.fetchOptions) {
484
+ const options2 = await step.fetchOptions(state, runtime);
485
+ if (options2.length === 0) {
486
+ continue;
487
+ }
488
+ }
476
489
  return {
477
490
  type: "nextQuestion",
478
491
  questionSlug: step.slug,
479
492
  question: step.question[ctx.language],
480
- questionType: "text"
493
+ questionType: "text",
494
+ allowFreeText: resolvedAllowFreeText,
495
+ ...pendingParameterUpdates.length > 0 && {
496
+ parameterUpdates: pendingParameterUpdates
497
+ }
481
498
  };
482
499
  }
483
500
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -489,11 +506,21 @@ async function runSetupFlow(flow, params, ctx, config) {
489
506
  questionSlug: step.slug,
490
507
  question: step.question[ctx.language],
491
508
  questionType: step.type,
492
- options
509
+ options,
510
+ allowFreeText: resolvedAllowFreeText,
511
+ ...pendingParameterUpdates.length > 0 && {
512
+ parameterUpdates: pendingParameterUpdates
513
+ }
493
514
  };
494
515
  }
495
516
  const dataInvestigationResult = await flow.finalize(state, runtime);
496
- return { type: "fulfilled", dataInvestigationResult };
517
+ return {
518
+ type: "fulfilled",
519
+ dataInvestigationResult,
520
+ ...pendingParameterUpdates.length > 0 && {
521
+ parameterUpdates: pendingParameterUpdates
522
+ }
523
+ };
497
524
  }
498
525
 
499
526
  // ../connectors/src/auth-types.ts
@@ -509,11 +536,11 @@ var AUTH_TYPES = {
509
536
  // ../connectors/src/connectors/shopify/setup.ts
510
537
  var shopifyOnboarding = new ConnectorOnboarding({
511
538
  dataOverviewInstructions: {
512
- en: `1. Call shopify_request with GET /admin/api/2024-10/products.json?limit=5 to explore products structure
513
- 2. Call shopify_request with GET /admin/api/2024-10/orders.json?limit=5&status=any to explore orders structure
539
+ en: `1. Call connector_shopify_request with GET /admin/api/2024-10/products.json?limit=5 to explore products structure
540
+ 2. Call connector_shopify_request with GET /admin/api/2024-10/orders.json?limit=5&status=any to explore orders structure
514
541
  3. Explore other endpoints (customers, inventory, collections) as needed`,
515
- ja: `1. shopify_request \u3067 GET /admin/api/2024-10/products.json?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u5546\u54C1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
516
- 2. shopify_request \u3067 GET /admin/api/2024-10/orders.json?limit=5&status=any \u3092\u547C\u3073\u51FA\u3057\u3001\u6CE8\u6587\u306E\u69CB\u9020\u3092\u78BA\u8A8D
542
+ ja: `1. connector_shopify_request \u3067 GET /admin/api/2024-10/products.json?limit=5 \u3092\u547C\u3073\u51FA\u3057\u3001\u5546\u54C1\u306E\u69CB\u9020\u3092\u78BA\u8A8D
543
+ 2. connector_shopify_request \u3067 GET /admin/api/2024-10/orders.json?limit=5&status=any \u3092\u547C\u3073\u51FA\u3057\u3001\u6CE8\u6587\u306E\u69CB\u9020\u3092\u78BA\u8A8D
517
544
  3. \u5FC5\u8981\u306B\u5FDC\u3058\u3066\u4ED6\u306E\u30A8\u30F3\u30C9\u30DD\u30A4\u30F3\u30C8\uFF08\u9867\u5BA2\u3001\u5728\u5EAB\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\uFF09\u3092\u63A2\u7D22`
518
545
  }
519
546
  });
@@ -765,7 +792,7 @@ var shopifyConnector = new ConnectorPlugin({
765
792
  systemPrompt: {
766
793
  en: `### Tools
767
794
 
768
- - \`shopify_request\`: The only way to call the Shopify Admin REST API. Use it to query products, orders, customers, inventory, collections, and more. Authentication (Custom App Client ID + Client Secret) is configured automatically \u2014 an access token is obtained on each request. Only provide the path starting with \`/admin/api/\`. Shopify uses cursor-based pagination via the \`page_info\` query parameter (obtained from the Link header in the response).
795
+ - \`connector_shopify_request\`: The only way to call the Shopify Admin REST API. Use it to query products, orders, customers, inventory, collections, and more. Authentication (Custom App Client ID + Client Secret) is configured automatically \u2014 an access token is obtained on each request. Only provide the path starting with \`/admin/api/\`. Shopify uses cursor-based pagination via the \`page_info\` query parameter (obtained from the Link header in the response).
769
796
 
770
797
  ### Business Logic
771
798
 
@@ -837,7 +864,7 @@ export default async function handler(c: Context) {
837
864
  - \`status\` \u2014 Filter by status (e.g., active, draft, archived for products; open, closed, cancelled, any for orders)`,
838
865
  ja: `### \u30C4\u30FC\u30EB
839
866
 
840
- - \`shopify_request\`: Shopify Admin REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u5546\u54C1\u3001\u6CE8\u6587\u3001\u9867\u5BA2\u3001\u5728\u5EAB\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306A\u3069\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08\u30AB\u30B9\u30BF\u30E0\u30A2\u30D7\u30EA\u306E Client ID + Client Secret\uFF09\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u3001\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\`/admin/api/\` \u304B\u3089\u59CB\u307E\u308B\u30D1\u30B9\u306E\u307F\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002Shopify\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E Link \u30D8\u30C3\u30C0\u30FC\u304B\u3089\u53D6\u5F97\u3059\u308B \`page_info\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
867
+ - \`connector_shopify_request\`: Shopify Admin REST API\u3092\u547C\u3073\u51FA\u3059\u552F\u4E00\u306E\u624B\u6BB5\u3067\u3059\u3002\u5546\u54C1\u3001\u6CE8\u6587\u3001\u9867\u5BA2\u3001\u5728\u5EAB\u3001\u30B3\u30EC\u30AF\u30B7\u30E7\u30F3\u306A\u3069\u306E\u30AF\u30A8\u30EA\u306B\u4F7F\u7528\u3057\u307E\u3059\u3002\u8A8D\u8A3C\uFF08\u30AB\u30B9\u30BF\u30E0\u30A2\u30D7\u30EA\u306E Client ID + Client Secret\uFF09\u306F\u81EA\u52D5\u7684\u306B\u8A2D\u5B9A\u3055\u308C\u3001\u30EA\u30AF\u30A8\u30B9\u30C8\u3054\u3068\u306B\u30A2\u30AF\u30BB\u30B9\u30C8\u30FC\u30AF\u30F3\u3092\u53D6\u5F97\u3057\u307E\u3059\u3002\`/admin/api/\` \u304B\u3089\u59CB\u307E\u308B\u30D1\u30B9\u306E\u307F\u3092\u6307\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044\u3002Shopify\u306F\u30EC\u30B9\u30DD\u30F3\u30B9\u306E Link \u30D8\u30C3\u30C0\u30FC\u304B\u3089\u53D6\u5F97\u3059\u308B \`page_info\` \u30AF\u30A8\u30EA\u30D1\u30E9\u30E1\u30FC\u30BF\u306B\u3088\u308B\u30AB\u30FC\u30BD\u30EB\u30D9\u30FC\u30B9\u306E\u30DA\u30FC\u30B8\u30CD\u30FC\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3057\u307E\u3059\u3002
841
868
 
842
869
  ### Business Logic
843
870
 
@@ -21,6 +21,7 @@ var init_parameter_definition = __esm({
21
21
  type;
22
22
  secret;
23
23
  required;
24
+ isDeprecated;
24
25
  constructor(config) {
25
26
  this.slug = config.slug;
26
27
  this.name = config.name;
@@ -29,6 +30,7 @@ var init_parameter_definition = __esm({
29
30
  this.type = config.type;
30
31
  this.secret = config.secret;
31
32
  this.required = config.required;
33
+ this.isDeprecated = config.isDeprecated ?? false;
32
34
  }
33
35
  /**
34
36
  * Get the parameter value from a ConnectorConnectionObject.
@@ -510,7 +512,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
510
512
  /**
511
513
  * Create tools for connections that belong to this connector.
512
514
  * Filters connections by connectorKey internally.
513
- * Returns tools keyed as `${connectorKey}_${toolName}`.
515
+ * Returns tools keyed as `connector_${connectorKey}_${toolName}`.
514
516
  */
515
517
  createTools(connections, config, opts) {
516
518
  const myConnections = connections.filter(
@@ -520,7 +522,7 @@ var ConnectorPlugin = class _ConnectorPlugin {
520
522
  for (const t of Object.values(this.tools)) {
521
523
  const tool = t.createTool(myConnections, config);
522
524
  const originalToModelOutput = tool.toModelOutput;
523
- result[`${this.connectorKey}_${t.name}`] = {
525
+ result[`connector_${this.connectorKey}_${t.name}`] = {
524
526
  ...tool,
525
527
  toModelOutput: async (options) => {
526
528
  if (!originalToModelOutput) {
@@ -576,19 +578,34 @@ async function runSetupFlow(flow, params, ctx, config) {
576
578
  };
577
579
  let state = flow.initialState();
578
580
  let answerIdx = 0;
581
+ const pendingParameterUpdates = [];
579
582
  for (const step of flow.steps) {
580
583
  const ans = ctx.answers[answerIdx];
581
584
  if (ans && ans.questionSlug === step.slug) {
582
585
  state = step.applyAnswer(state, ans.answer);
586
+ if (step.toParameterUpdates) {
587
+ pendingParameterUpdates.push(...step.toParameterUpdates(state));
588
+ }
583
589
  answerIdx += 1;
584
590
  continue;
585
591
  }
592
+ const resolvedAllowFreeText = step.allowFreeText !== void 0 ? step.allowFreeText : true;
586
593
  if (step.type === "text") {
594
+ if (step.fetchOptions) {
595
+ const options2 = await step.fetchOptions(state, runtime);
596
+ if (options2.length === 0) {
597
+ continue;
598
+ }
599
+ }
587
600
  return {
588
601
  type: "nextQuestion",
589
602
  questionSlug: step.slug,
590
603
  question: step.question[ctx.language],
591
- questionType: "text"
604
+ questionType: "text",
605
+ allowFreeText: resolvedAllowFreeText,
606
+ ...pendingParameterUpdates.length > 0 && {
607
+ parameterUpdates: pendingParameterUpdates
608
+ }
592
609
  };
593
610
  }
594
611
  const options = step.fetchOptions ? await step.fetchOptions(state, runtime) : [];
@@ -600,11 +617,21 @@ async function runSetupFlow(flow, params, ctx, config) {
600
617
  questionSlug: step.slug,
601
618
  question: step.question[ctx.language],
602
619
  questionType: step.type,
603
- options
620
+ options,
621
+ allowFreeText: resolvedAllowFreeText,
622
+ ...pendingParameterUpdates.length > 0 && {
623
+ parameterUpdates: pendingParameterUpdates
624
+ }
604
625
  };
605
626
  }
606
627
  const dataInvestigationResult = await flow.finalize(state, runtime);
607
- return { type: "fulfilled", dataInvestigationResult };
628
+ return {
629
+ type: "fulfilled",
630
+ dataInvestigationResult,
631
+ ...pendingParameterUpdates.length > 0 && {
632
+ parameterUpdates: pendingParameterUpdates
633
+ }
634
+ };
608
635
  }
609
636
  async function resolveSetupSelection(params) {
610
637
  const { selected, allSentinel, fetchAll, limit } = params;
@@ -644,11 +671,11 @@ init_mssql_runner();
644
671
  // ../connectors/src/connectors/sqlserver/setup.ts
645
672
  var sqlserverOnboarding = new ConnectorOnboarding({
646
673
  dataOverviewInstructions: {
647
- en: `1. Use sqlserver_executeQuery to discover the database flavor and version: \`SELECT @@VERSION\`
674
+ en: `1. Use connector_sqlserver_executeQuery to discover the database flavor and version: \`SELECT @@VERSION\`
648
675
  2. List user tables: \`SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA NOT IN ('sys', 'INFORMATION_SCHEMA')\`
649
676
  3. For key tables, fetch column info: \`SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'xxx'\`
650
677
  4. Sample up to 3 tables. SQL Server uses \`TOP\` rather than \`LIMIT\`: \`SELECT TOP 5 * FROM <schema>.<table_name>\``,
651
- ja: `1. sqlserver_executeQuery \u3067\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u53D6\u5F97: \`SELECT @@VERSION\`
678
+ ja: `1. connector_sqlserver_executeQuery \u3067\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u53D6\u5F97: \`SELECT @@VERSION\`
652
679
  2. \u30E6\u30FC\u30B6\u30FC\u30C6\u30FC\u30D6\u30EB\u4E00\u89A7\u3092\u53D6\u5F97: \`SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA NOT IN ('sys', 'INFORMATION_SCHEMA')\`
653
680
  3. \u4E3B\u8981\u30C6\u30FC\u30D6\u30EB\u306E\u30AB\u30E9\u30E0\u60C5\u5831\u3092\u53D6\u5F97: \`SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'dbo' AND TABLE_NAME = 'xxx'\`
654
681
  4. \u5FC5\u8981\u306B\u5FDC\u3058\u3066\u6700\u59273\u30C6\u30FC\u30D6\u30EB\u3092\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u3002SQL Server \u3067\u306F \`LIMIT\` \u3067\u306F\u306A\u304F \`TOP\` \u3092\u4F7F\u7528: \`SELECT TOP 5 * FROM <schema>.<table_name>\``
@@ -716,8 +743,8 @@ function buildFlow(options) {
716
743
  slug: "tables",
717
744
  type: "multiSelect",
718
745
  question: {
719
- ja: "\u5BFE\u8C61\u30C6\u30FC\u30D6\u30EB\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
720
- en: "Select target tables (multi-select allowed)"
746
+ ja: "\u5BFE\u8C61\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC\u3092\u9078\u3093\u3067\u304F\u3060\u3055\u3044\uFF08\u8907\u6570\u9078\u629E\u53EF\uFF09",
747
+ en: "Select target tables and views (multi-select allowed)"
721
748
  },
722
749
  async fetchOptions(state, rt) {
723
750
  if (!state.schema) return [];
@@ -726,7 +753,7 @@ function buildFlow(options) {
726
753
  return [
727
754
  {
728
755
  value: ALL_TABLES,
729
- label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C6\u30FC\u30D6\u30EB" : "All tables"
756
+ label: rt.language === "ja" ? "\u3059\u3079\u3066\u306E\u30C6\u30FC\u30D6\u30EB\u30FB\u30D3\u30E5\u30FC" : "All tables and views"
730
757
  },
731
758
  ...tableOptions
732
759
  ];
@@ -745,6 +772,28 @@ function buildFlow(options) {
745
772
  fetchAll: () => fetchTableNames(rt.params, schema),
746
773
  limit: SQLSERVER_SETUP_MAX_TABLES
747
774
  });
775
+ let rowCounts = /* @__PURE__ */ new Map();
776
+ try {
777
+ const countRows = await runSqlServerSetupQuery(
778
+ rt.params,
779
+ `SELECT t.TABLE_NAME, SUM(p.rows) AS row_count
780
+ FROM INFORMATION_SCHEMA.TABLES t
781
+ JOIN sys.partitions p
782
+ ON OBJECT_ID(t.TABLE_SCHEMA + '.' + t.TABLE_NAME) = p.object_id
783
+ AND p.index_id IN (0, 1)
784
+ WHERE t.TABLE_SCHEMA = ${quoteLiteral(schema)}
785
+ AND t.TABLE_TYPE IN ('BASE TABLE', 'VIEW')
786
+ GROUP BY t.TABLE_NAME`,
787
+ forceEncrypt
788
+ );
789
+ rowCounts = new Map(
790
+ countRows.map((r) => [
791
+ String(r["TABLE_NAME"] ?? ""),
792
+ Number(r["row_count"] ?? 0)
793
+ ])
794
+ );
795
+ } catch {
796
+ }
748
797
  const sections = [
749
798
  `## ${connectorName}`,
750
799
  "",
@@ -761,7 +810,9 @@ function buildFlow(options) {
761
810
  ORDER BY ORDINAL_POSITION`,
762
811
  forceEncrypt
763
812
  );
764
- sections.push(`#### Table: ${table}`, "");
813
+ const rowCount = rowCounts.get(table);
814
+ const heading = typeof rowCount === "number" ? `#### Table: ${table} (~${rowCount.toLocaleString()} rows)` : `#### Table: ${table}`;
815
+ sections.push(heading, "");
765
816
  sections.push("| Column | Type | Nullable | Default |");
766
817
  sections.push("|--------|------|----------|---------|");
767
818
  for (const c of cols) {
@@ -880,7 +931,7 @@ var sqlserverConnector = new ConnectorPlugin({
880
931
  systemPrompt: {
881
932
  en: `### Tools
882
933
 
883
- - \`sqlserver_executeQuery\`: Executes a T-SQL query against Microsoft SQL Server and returns rows. Use this for schema exploration via \`INFORMATION_SCHEMA\` and for sampling data. See the SQL Reference below for SQL Server-specific syntax.
934
+ - \`connector_sqlserver_executeQuery\`: Executes a T-SQL query against Microsoft SQL Server and returns rows. Use this for schema exploration via \`INFORMATION_SCHEMA\` and for sampling data. See the SQL Reference below for SQL Server-specific syntax.
884
935
 
885
936
  ### Business Logic
886
937
 
@@ -897,7 +948,7 @@ The business logic type for this connector is "sql".
897
948
  - Row-limit compatibility: the platform's server-logic schema inference may wrap your query as \`SELECT * FROM (<inner>) AS _sq LIMIT N\`. T-SQL does not understand \`LIMIT\`, so the connector detects this exact wrapper at \`query()\` time, executes \`<inner>\` directly, and slices the first N rows in JS. You do not need to handle this \u2014 but do not author your own \`LIMIT\` clauses; use \`TOP\` / \`OFFSET ... FETCH NEXT\` in queries you write.`,
898
949
  ja: `### \u30C4\u30FC\u30EB
899
950
 
900
- - \`sqlserver_executeQuery\`: Microsoft SQL Server \u306B\u5BFE\u3057\u3066 T-SQL \u30AF\u30A8\u30EA\u3092\u5B9F\u884C\u3057\u3001\u884C\u30C7\u30FC\u30BF\u3092\u8FD4\u3057\u307E\u3059\u3002\`INFORMATION_SCHEMA\` \u3092\u4F7F\u3063\u305F\u30B9\u30AD\u30FC\u30DE\u63A2\u7D22\u3084\u30C7\u30FC\u30BF\u306E\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u306B\u4F7F\u3044\u307E\u3059\u3002SQL Server \u56FA\u6709\u306E\u69CB\u6587\u306F\u4E0B\u90E8\u306E\u300CSQL \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u300D\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
951
+ - \`connector_sqlserver_executeQuery\`: Microsoft SQL Server \u306B\u5BFE\u3057\u3066 T-SQL \u30AF\u30A8\u30EA\u3092\u5B9F\u884C\u3057\u3001\u884C\u30C7\u30FC\u30BF\u3092\u8FD4\u3057\u307E\u3059\u3002\`INFORMATION_SCHEMA\` \u3092\u4F7F\u3063\u305F\u30B9\u30AD\u30FC\u30DE\u63A2\u7D22\u3084\u30C7\u30FC\u30BF\u306E\u30B5\u30F3\u30D7\u30EA\u30F3\u30B0\u306B\u4F7F\u3044\u307E\u3059\u3002SQL Server \u56FA\u6709\u306E\u69CB\u6587\u306F\u4E0B\u90E8\u306E\u300CSQL \u30EA\u30D5\u30A1\u30EC\u30F3\u30B9\u300D\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\u3002
901
952
 
902
953
  ### Business Logic
903
954