@axiom-lattice/core 2.1.27 → 2.1.29

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/index.js CHANGED
@@ -406,7 +406,10 @@ var ModelLattice = class extends import_chat_models.BaseChatModel {
406
406
  timeout: config.timeout,
407
407
  maxRetries: config.maxRetries || 2,
408
408
  apiKey: config.apiKey || process.env[config.apiKeyEnvName || "DEEPSEEK_API_KEY"],
409
- streaming: config.streaming
409
+ streaming: config.streaming,
410
+ configuration: {
411
+ baseURL: config.baseURL
412
+ }
410
413
  });
411
414
  } else if (config.provider === "siliconcloud") {
412
415
  return new import_openai.ChatOpenAI({
@@ -2099,6 +2102,20 @@ ${serverKeys.map(
2099
2102
  return (0, import_langchain6.tool)(
2100
2103
  async (_input, _exeConfig) => {
2101
2104
  try {
2105
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2106
+ const metricsDataSource = runConfig.metricsDataSource;
2107
+ if (metricsDataSource) {
2108
+ const { serverKey, datasourceId } = metricsDataSource;
2109
+ return `\u2139\uFE0F **Current Data Source Selected**
2110
+
2111
+ You have selected a specific data source through the interface. All metrics queries will focus on:
2112
+ - **Server**: ${serverKey}
2113
+ - **Data Source ID**: ${datasourceId}
2114
+
2115
+ You can directly use other metrics tools (such as query_metrics_list, query_semantic_metric_data, etc.) without specifying the serverKey and datasourceId parameters.
2116
+
2117
+ To view all available data sources, please clear the current selection or reopen the data source selector.`;
2118
+ }
2102
2119
  if (serverKeys.length === 0) {
2103
2120
  return "No metrics servers configured.";
2104
2121
  }
@@ -2194,10 +2211,13 @@ ${serverKeys.map(
2194
2211
  ).join("\n")}` : "";
2195
2212
  return (0, import_langchain7.tool)(
2196
2213
  async ({
2197
- serverKey,
2214
+ serverKey: inputServerKey,
2198
2215
  datasourceIds
2199
2216
  }, _exeConfig) => {
2200
2217
  try {
2218
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2219
+ const metricsDataSource = runConfig.metricsDataSource;
2220
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2201
2221
  if (!serverKey) {
2202
2222
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2203
2223
  }
@@ -2209,7 +2229,7 @@ ${serverKeys.map(
2209
2229
  return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
2210
2230
  }
2211
2231
  const client = metricsServerManager.getClient(serverKey);
2212
- const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : client.getSelectedDataSources();
2232
+ const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
2213
2233
  if (targetDatasourceIds.length === 0) {
2214
2234
  return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
2215
2235
  }
@@ -2248,21 +2268,21 @@ ${serverKeys.map(
2248
2268
  }
2249
2269
  }
2250
2270
  if (metricsByDatasource.size === 0) {
2251
- return `\u672A\u5728\u6307\u5B9A\u7684\u6570\u636E\u6E90\u4E2D\u627E\u5230\u6307\u6807\u3002`;
2271
+ return `No metrics found in the specified data sources.`;
2252
2272
  }
2253
2273
  const lines = [];
2254
- lines.push(`## \u4E1A\u52A1\u6307\u6807\u5217\u8868\uFF08serverKey: ${serverKey}\uFF09
2274
+ lines.push(`## Business Metrics List (serverKey: ${serverKey})
2255
2275
  `);
2256
2276
  const sortedDatasourceIds = Array.from(metricsByDatasource.keys()).sort();
2257
2277
  for (const dsId of sortedDatasourceIds) {
2258
2278
  const metrics = metricsByDatasource.get(dsId);
2259
2279
  const sortedMetrics = metrics.sort((a, b) => {
2260
- if (a.domain !== b.domain) {
2280
+ if (a.domain && a.domain !== b.domain) {
2261
2281
  return a.domain.localeCompare(b.domain);
2262
2282
  }
2263
2283
  return a.metricName.localeCompare(b.metricName);
2264
2284
  });
2265
- lines.push(`### datasourceId: ${dsId}\uFF08${metrics.length} \u4E2A\u6307\u6807\uFF09
2285
+ lines.push(`### datasourceId: ${dsId} (${metrics.length} metrics)
2266
2286
  `);
2267
2287
  lines.push("| metricName | displayName | domain | shortDesc |");
2268
2288
  lines.push("|------------|-------------|--------|-----------|");
@@ -2274,7 +2294,7 @@ ${serverKeys.map(
2274
2294
  }
2275
2295
  lines.push("---");
2276
2296
  lines.push("");
2277
- lines.push("\u5982\u9700\u67E5\u770B\u6307\u6807\u7684\u8BE6\u7EC6\u5B9A\u4E49\uFF0C\u8BF7\u4F7F\u7528 **query_metric_definition** \u5DE5\u5177\uFF0C\u4F20\u5165\u53C2\u6570\uFF1A`serverKey`\u3001`metricName`\u3001`datasourceId`");
2297
+ lines.push("To view detailed metric definitions, use the **query_metric_definition** tool with parameters: `serverKey`, `metricName`, `datasourceId`");
2278
2298
  return lines.join("\n");
2279
2299
  } catch (error) {
2280
2300
  return `Error querying metrics list: ${error instanceof Error ? error.message : String(error)}`;
@@ -2284,8 +2304,8 @@ ${serverKeys.map(
2284
2304
  name: "query_metrics_list",
2285
2305
  description: `${QUERY_METRICS_LIST_DESCRIPTION}${availableServersText}`,
2286
2306
  schema: import_zod9.default.object({
2287
- serverKey: import_zod9.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2288
- datasourceIds: import_zod9.default.array(import_zod9.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources.")
2307
+ serverKey: import_zod9.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2308
+ datasourceIds: import_zod9.default.array(import_zod9.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources or the one configured in runConfig.metricsDataSource.")
2289
2309
  })
2290
2310
  }
2291
2311
  );
@@ -2342,11 +2362,15 @@ ${serverKeys.map(
2342
2362
  ).join("\n")}` : "";
2343
2363
  return (0, import_langchain8.tool)(
2344
2364
  async ({
2345
- serverKey,
2365
+ serverKey: inputServerKey,
2346
2366
  metricName,
2347
- datasourceId
2367
+ datasourceId: inputDatasourceId
2348
2368
  }, _exeConfig) => {
2349
2369
  try {
2370
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2371
+ const metricsDataSource = runConfig.metricsDataSource;
2372
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2373
+ const datasourceId = inputDatasourceId || metricsDataSource?.datasourceId;
2350
2374
  if (!serverKey) {
2351
2375
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2352
2376
  }
@@ -2389,143 +2413,158 @@ ${serverKeys.map(
2389
2413
  const lines = [];
2390
2414
  lines.push(`# ${foundDetail.displayName} (${foundDetail.metricName})`);
2391
2415
  lines.push("");
2392
- lines.push(`## \u57FA\u672C\u4FE1\u606F`);
2416
+ lines.push(`## Basic Information`);
2393
2417
  lines.push("");
2394
- lines.push(`- **\u6307\u6807\u540D\u79F0**: ${foundDetail.metricName}`);
2395
- lines.push(`- **\u663E\u793A\u540D\u79F0**: ${foundDetail.displayName}`);
2396
- lines.push(`- **\u6240\u5C5E\u9886\u57DF**: ${foundDetail.domain}`);
2397
- lines.push(`- **\u6570\u636E\u7C7B\u578B**: ${foundDetail.dataType}`);
2398
- lines.push(`- **\u663E\u793A\u683C\u5F0F**: ${foundDetail.format}`);
2418
+ lines.push(`- **Metric Name**: ${foundDetail.metricName}`);
2419
+ lines.push(`- **Display Name**: ${foundDetail.displayName}`);
2420
+ lines.push(`- **Domain**: ${foundDetail.domain}`);
2421
+ lines.push(`- **Data Type**: ${foundDetail.dataType}`);
2422
+ lines.push(`- **Format**: ${foundDetail.format}`);
2399
2423
  if (foundDatasourceId) {
2400
- lines.push(`- **\u6570\u636E\u6E90ID**: ${foundDatasourceId}`);
2424
+ lines.push(`- **Data Source ID**: ${foundDatasourceId}`);
2401
2425
  }
2402
2426
  lines.push("");
2403
- lines.push(`## \u6307\u6807\u63CF\u8FF0`);
2427
+ lines.push(`## Description`);
2404
2428
  lines.push("");
2405
2429
  lines.push(foundDetail.description);
2406
2430
  lines.push("");
2407
2431
  if (foundDetail.defaultTimeContext) {
2408
- lines.push(`## \u65F6\u95F4\u4E0A\u4E0B\u6587`);
2432
+ const dtc = foundDetail.defaultTimeContext;
2433
+ lines.push(`## Time Context`);
2409
2434
  lines.push("");
2410
- lines.push(`- **\u65F6\u95F4\u7EF4\u5EA6**: ${foundDetail.defaultTimeContext.timeDimension} (${foundDetail.defaultTimeContext.label})`);
2411
- lines.push(`- **\u9ED8\u8BA4\u7C92\u5EA6**: ${foundDetail.defaultTimeContext.granularity}`);
2412
- lines.push(`- **\u9ED8\u8BA4\u7A97\u53E3**: ${foundDetail.defaultTimeContext.window}`);
2413
- lines.push(`- **\u652F\u6301\u7684\u7C92\u5EA6**: ${foundDetail.defaultTimeContext.supportedGrains.join("\u3001")}`);
2435
+ if (dtc.timeDimension) {
2436
+ lines.push(`- **Time Dimension**: ${dtc.timeDimension}${dtc.label ? ` (${dtc.label})` : ""}`);
2437
+ }
2438
+ if (dtc.granularity) {
2439
+ lines.push(`- **Default Granularity**: ${dtc.granularity}`);
2440
+ }
2441
+ if (dtc.window) {
2442
+ lines.push(`- **Default Window**: ${dtc.window}`);
2443
+ }
2444
+ const grains = dtc.supportedGrains;
2445
+ lines.push(`- **Supported Grains**: ${Array.isArray(grains) && grains.length > 0 ? grains.join(", ") : "Not configured"}`);
2414
2446
  lines.push("");
2415
2447
  }
2416
2448
  if (foundDetail.supportedDimensions && foundDetail.supportedDimensions.length > 0) {
2417
2449
  const categoricalDims = foundDetail.supportedDimensions.filter((d) => d.type === "categorical");
2418
2450
  const datetimeDims = foundDetail.supportedDimensions.filter((d) => d.type === "datetime");
2419
2451
  const timeDimension = foundDetail.defaultTimeContext?.timeDimension;
2420
- lines.push(`## \u652F\u6301\u7684\u7EF4\u5EA6`);
2452
+ lines.push(`## Supported Dimensions`);
2421
2453
  lines.push("");
2422
2454
  if (categoricalDims.length > 0) {
2423
- lines.push(`### \u5206\u7C7B\u7EF4\u5EA6 (categorical) - ${categoricalDims.length} \u4E2A`);
2424
- lines.push("\u652F\u6301 IN\uFF08\u591A\u9009\uFF09\u3001EQ\uFF08\u5355\u9009\uFF09\u64CD\u4F5C\u7B26");
2455
+ lines.push(`### Categorical Dimensions - ${categoricalDims.length}`);
2456
+ lines.push("Supports IN (multiple), EQ (single) operators");
2425
2457
  lines.push("");
2426
2458
  const examples = categoricalDims.slice(0, 2);
2427
2459
  for (const dim of examples) {
2428
2460
  lines.push(`**${dim.dim_id}** (${dim.field_name})`);
2429
2461
  lines.push("```json");
2430
- lines.push(`// \u5206\u7EC4\u793A\u4F8B`);
2462
+ lines.push(`// Grouping example`);
2431
2463
  lines.push(`"groupBy": ["${dim.dim_id}"]`);
2432
2464
  lines.push("");
2433
- lines.push(`// \u8FC7\u6EE4\u793A\u4F8B`);
2465
+ lines.push(`// Filter example`);
2434
2466
  lines.push(`{"dimension": "${dim.dim_id}", "operator": "IN", "values": ["value1", "value2"]}`);
2435
2467
  lines.push("```");
2436
2468
  lines.push("");
2437
2469
  }
2438
2470
  if (categoricalDims.length > 2) {
2439
- const others = categoricalDims.slice(2).map((d) => d.dim_id).join("\u3001");
2440
- lines.push(`**\u5176\u4ED6 ${categoricalDims.length - 2} \u4E2A\u7EF4\u5EA6**: ${others}`);
2471
+ const others = categoricalDims.slice(2).map((d) => d.dim_id).join(", ");
2472
+ lines.push(`**Other ${categoricalDims.length - 2} dimensions**: ${others}`);
2441
2473
  lines.push("");
2442
2474
  }
2443
2475
  }
2444
2476
  if (datetimeDims.length > 0) {
2445
- lines.push(`### \u65F6\u95F4\u7EF4\u5EA6 (datetime) - ${datetimeDims.length} \u4E2A`);
2446
- lines.push("\u652F\u6301 BETWEEN\uFF08\u8303\u56F4\uFF09\u3001GT/GTE/LT/LTE\uFF08\u6BD4\u8F83\uFF09\u64CD\u4F5C\u7B26");
2477
+ lines.push(`### Datetime Dimensions - ${datetimeDims.length}`);
2478
+ lines.push("Supports BETWEEN (range), GT/GTE/LT/LTE (comparison) operators");
2447
2479
  lines.push("");
2448
2480
  const primaryDim = datetimeDims.find((d) => d.dim_id === timeDimension) || datetimeDims[0];
2449
2481
  lines.push(`**${primaryDim.dim_id}** (${primaryDim.field_name})`);
2450
2482
  lines.push("```json");
2451
- lines.push(`// \u6309\u65F6\u95F4\u7C92\u5EA6\u5206\u7EC4`);
2452
- lines.push(`"groupBy": ["${primaryDim.dim_id}__month"] // \u53EF\u9009: day, week, month, year`);
2483
+ lines.push(`// Group by time grain`);
2484
+ lines.push(`"groupBy": ["${primaryDim.dim_id}__month"] // Options: day, week, month, year`);
2453
2485
  lines.push("");
2454
- lines.push(`// \u65F6\u95F4\u8303\u56F4\u8FC7\u6EE4`);
2486
+ lines.push(`// Time range filter`);
2455
2487
  lines.push(`{"dimension": "${primaryDim.dim_id}", "operator": "BETWEEN", "values": ["2025-01-01", "2025-12-31"]}`);
2456
2488
  lines.push("```");
2457
2489
  lines.push("");
2458
2490
  if (datetimeDims.length > 1) {
2459
- const others = datetimeDims.filter((d) => d.dim_id !== primaryDim.dim_id).map((d) => d.dim_id).join("\u3001");
2460
- lines.push(`**\u5176\u4ED6\u65F6\u95F4\u7EF4\u5EA6**: ${others}`);
2491
+ const others = datetimeDims.filter((d) => d.dim_id !== primaryDim.dim_id).map((d) => d.dim_id).join(", ");
2492
+ lines.push(`**Other time dimensions**: ${others}`);
2461
2493
  lines.push("");
2462
2494
  }
2463
2495
  }
2464
- lines.push("### \u5FEB\u901F\u53C2\u8003");
2496
+ lines.push("### Quick Reference");
2465
2497
  lines.push("");
2466
- lines.push("**\u65F6\u95F4\u5206\u7EC4\u683C\u5F0F**: `{timeDimension}__{grain}`");
2467
- lines.push("- \u6309\u5929: `DocDate__day`");
2468
- lines.push("- \u6309\u5468: `DocDate__week`");
2469
- lines.push("- \u6309\u6708: `DocDate__month`");
2470
- lines.push("- \u6309\u5E74: `DocDate__year`");
2498
+ lines.push("**Time grouping format**: `{timeDimension}__{grain}`");
2499
+ lines.push("- By day: `DocDate__day`");
2500
+ lines.push("- By week: `DocDate__week`");
2501
+ lines.push("- By month: `DocDate__month`");
2502
+ lines.push("- By year: `DocDate__year`");
2471
2503
  lines.push("");
2472
2504
  }
2473
2505
  if (foundDetail.aiAgentContext) {
2474
2506
  const aiContext = foundDetail.aiAgentContext;
2475
- lines.push(`## AI \u5206\u6790\u4E0A\u4E0B\u6587`);
2476
- lines.push("");
2477
- lines.push(`### \u6307\u6807\u6781\u6027`);
2478
- lines.push("");
2479
- lines.push(aiContext.polarity === "positive" ? "\u6B63\u5411\u6307\u6807\uFF08\u8D8A\u9AD8\u8D8A\u597D\uFF09" : "\u8D1F\u5411\u6307\u6807\uFF08\u8D8A\u4F4E\u8D8A\u597D\uFF09");
2507
+ lines.push(`## AI Analysis Context`);
2480
2508
  lines.push("");
2509
+ if (aiContext.polarity) {
2510
+ lines.push(`### Metric Polarity`);
2511
+ lines.push("");
2512
+ lines.push(aiContext.polarity === "positive" ? "Positive metric (higher is better)" : "Negative metric (lower is better)");
2513
+ lines.push("");
2514
+ }
2481
2515
  if (aiContext.synonyms && aiContext.synonyms.length > 0) {
2482
- lines.push(`### \u540C\u4E49\u8BCD/\u522B\u540D`);
2516
+ lines.push(`### Synonyms/Aliases`);
2483
2517
  lines.push("");
2484
- lines.push(aiContext.synonyms.join("\u3001"));
2518
+ lines.push(aiContext.synonyms.join(", "));
2485
2519
  lines.push("");
2486
2520
  }
2487
2521
  if (aiContext.thresholds && aiContext.thresholds.length > 0) {
2488
- lines.push(`### \u9884\u8B66\u9608\u503C`);
2522
+ lines.push(`### Alert Thresholds`);
2489
2523
  lines.push("");
2490
- lines.push("| \u6307\u6807 | \u8FD0\u7B97\u7B26 | \u9608\u503C | \u7EA7\u522B |");
2491
- lines.push("|------|--------|------|------|");
2524
+ lines.push("| Metric | Operator | Threshold | Level |");
2525
+ lines.push("|--------|----------|-----------|-------|");
2492
2526
  for (const t of aiContext.thresholds) {
2493
2527
  lines.push(`| ${t.metric} | ${t.operator} | ${t.value} | ${t.level} |`);
2494
2528
  }
2495
2529
  lines.push("");
2496
2530
  }
2497
2531
  if (aiContext.diagnosticWorkflow) {
2498
- lines.push(`### \u8BCA\u65AD\u5DE5\u4F5C\u6D41`);
2532
+ lines.push(`### Diagnostic Workflow`);
2499
2533
  lines.push("");
2500
2534
  if (aiContext.diagnosticWorkflow.trigger && aiContext.diagnosticWorkflow.trigger.any_of) {
2501
- lines.push(`**\u89E6\u53D1\u6761\u4EF6** (\u6EE1\u8DB3\u4EFB\u4E00):`);
2535
+ lines.push(`**Trigger Conditions** (satisfy any):`);
2502
2536
  for (const trigger of aiContext.diagnosticWorkflow.trigger.any_of) {
2503
- lines.push(`- ${trigger.metric} ${trigger.operator} ${trigger.value}`);
2537
+ if (trigger.metric && trigger.operator) {
2538
+ lines.push(`- ${trigger.metric} ${trigger.operator} ${trigger.value ?? "N/A"}`);
2539
+ }
2504
2540
  }
2505
2541
  lines.push("");
2506
2542
  }
2507
2543
  if (aiContext.diagnosticWorkflow.actions && aiContext.diagnosticWorkflow.actions.length > 0) {
2508
- lines.push(`**\u5206\u6790\u52A8\u4F5C**:`);
2544
+ lines.push(`**Analysis Actions**:`);
2509
2545
  for (let i = 0; i < aiContext.diagnosticWorkflow.actions.length; i++) {
2510
2546
  const action = aiContext.diagnosticWorkflow.actions[i];
2511
- lines.push(`${i + 1}. **${action.type}**`);
2547
+ if (!action) continue;
2548
+ lines.push(`${i + 1}. **${action.type ?? "Unnamed Action"}**`);
2512
2549
  if (action.metric) {
2513
- lines.push(` - \u5BF9\u6BD4\u6307\u6807: ${action.metric}`);
2550
+ lines.push(` - Comparison Metric: ${action.metric}`);
2514
2551
  }
2515
2552
  if (action.dimensions && action.dimensions.length > 0) {
2516
- lines.push(` - \u4E0B\u94BB\u7EF4\u5EA6: ${action.dimensions.join("\u3001")}`);
2553
+ lines.push(` - Drill-down Dimensions: ${action.dimensions.join(", ")}`);
2554
+ }
2555
+ if (action.intent) {
2556
+ lines.push(` - Intent: ${action.intent}`);
2517
2557
  }
2518
- lines.push(` - \u76EE\u7684: ${action.intent}`);
2519
2558
  }
2520
2559
  lines.push("");
2521
2560
  }
2522
2561
  if (aiContext.diagnosticWorkflow.analysis_logic) {
2523
- lines.push(`**\u5206\u6790\u903B\u8F91**: ${aiContext.diagnosticWorkflow.analysis_logic}`);
2562
+ lines.push(`**Analysis Logic**: ${aiContext.diagnosticWorkflow.analysis_logic}`);
2524
2563
  lines.push("");
2525
2564
  }
2526
2565
  }
2527
2566
  if (aiContext.humanReadableExplanation) {
2528
- lines.push(`### \u7CFB\u7EDF\u5EFA\u8BAE`);
2567
+ lines.push(`### System Recommendations`);
2529
2568
  lines.push("");
2530
2569
  lines.push(aiContext.humanReadableExplanation);
2531
2570
  lines.push("");
@@ -2533,9 +2572,9 @@ ${serverKeys.map(
2533
2572
  }
2534
2573
  lines.push(`---`);
2535
2574
  lines.push("");
2536
- lines.push(`## \u4F7F\u7528\u793A\u4F8B`);
2575
+ lines.push(`## Usage Example`);
2537
2576
  lines.push("");
2538
- lines.push(`\u67E5\u8BE2\u6B64\u6307\u6807\u65F6\uFF0C\u4F7F\u7528 query_semantic_metric_data \u5DE5\u5177\uFF0C\u53C2\u6570:`);
2577
+ lines.push(`To query this metric, use the query_semantic_metric_data tool with parameters:`);
2539
2578
  lines.push(`- **metricName**: "${foundDetail.metricName}"`);
2540
2579
  if (foundDatasourceId) {
2541
2580
  lines.push(`- **datasourceId**: "${foundDatasourceId}"`);
@@ -2549,9 +2588,9 @@ ${serverKeys.map(
2549
2588
  name: "query_metric_definition",
2550
2589
  description: `${QUERY_METRIC_DEFINITION_DESCRIPTION}${availableServersText}`,
2551
2590
  schema: import_zod10.default.object({
2552
- serverKey: import_zod10.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2591
+ serverKey: import_zod10.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2553
2592
  metricName: import_zod10.default.string().describe("The name of the metric to get definition for."),
2554
- datasourceId: import_zod10.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, searches all selected datasources.")
2593
+ datasourceId: import_zod10.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, uses the one configured in runConfig.metricsDataSource or searches all selected datasources.")
2555
2594
  })
2556
2595
  }
2557
2596
  );
@@ -2681,24 +2720,24 @@ function formatSemanticQueryResult(datasourceId, datasourceName, results) {
2681
2720
  Data Source: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`;
2682
2721
  }
2683
2722
  const lines = [];
2684
- lines.push(`# \u6307\u6807\u67E5\u8BE2\u7ED3\u679C`);
2723
+ lines.push(`# Metric Query Results`);
2685
2724
  lines.push(`
2686
- **\u6570\u636E\u6E90**: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`);
2687
- lines.push(`**\u6307\u6807\u6570**: ${results.length}`);
2725
+ **Data Source**: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`);
2726
+ lines.push(`**Metrics Count**: ${results.length}`);
2688
2727
  lines.push(`
2689
2728
  ---
2690
2729
  `);
2691
2730
  for (const metric of results) {
2692
2731
  lines.push(`## ${metric.displayName} (${metric.metricName})`);
2693
2732
  lines.push(`
2694
- - **\u6570\u636E\u7C7B\u578B**: ${metric.dataType}`);
2695
- lines.push(`- **\u683C\u5F0F**: ${metric.format}`);
2696
- lines.push(`- **\u6781\u6027**: ${metric.polarity}`);
2697
- lines.push(`- **\u6267\u884C\u8017\u65F6**: ${metric.executionTimeMs}ms`);
2698
- lines.push(`- **\u8FD4\u56DE\u884C\u6570**: ${metric.rowCount}`);
2733
+ - **Data Type**: ${metric.dataType}`);
2734
+ lines.push(`- **Format**: ${metric.format}`);
2735
+ lines.push(`- **Polarity**: ${metric.polarity}`);
2736
+ lines.push(`- **Execution Time**: ${metric.executionTimeMs}ms`);
2737
+ lines.push(`- **Rows Returned**: ${metric.rowCount}`);
2699
2738
  if (metric.columns.length > 0 && metric.rows.length > 0) {
2700
2739
  lines.push(`
2701
- ### \u6570\u636E
2740
+ ### Data
2702
2741
  `);
2703
2742
  lines.push(`| ${metric.columns.join(" | ")} |`);
2704
2743
  lines.push(`|${metric.columns.map(() => "---").join("|")}|`);
@@ -2712,17 +2751,17 @@ Data Source: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`;
2712
2751
  }
2713
2752
  if (metric.aiHints) {
2714
2753
  lines.push(`
2715
- ### AI \u5206\u6790\u5EFA\u8BAE
2754
+ ### AI Analysis Suggestions
2716
2755
  `);
2717
- lines.push(`- **\u6307\u6807\u89E3\u91CA**: ${metric.aiHints.valueInterpretation}`);
2756
+ lines.push(`- **Value Interpretation**: ${metric.aiHints.valueInterpretation}`);
2718
2757
  if (metric.aiHints.thresholds && metric.aiHints.thresholds.length > 0) {
2719
- lines.push(`- **\u9884\u8B66\u9608\u503C**:`);
2758
+ lines.push(`- **Alert Thresholds**:`);
2720
2759
  for (const t of metric.aiHints.thresholds) {
2721
2760
  lines.push(` - ${t.metric} ${t.operator} ${t.value} (${t.level})`);
2722
2761
  }
2723
2762
  }
2724
2763
  if (metric.aiHints.suggestedFollowup && metric.aiHints.suggestedFollowup.length > 0) {
2725
- lines.push(`- **\u5EFA\u8BAE\u540E\u7EED\u5206\u6790**:`);
2764
+ lines.push(`- **Suggested Follow-up Analysis**:`);
2726
2765
  for (const suggestion of metric.aiHints.suggestedFollowup) {
2727
2766
  lines.push(` - ${suggestion}`);
2728
2767
  }
@@ -2743,14 +2782,18 @@ ${serverKeys.map(
2743
2782
  ).join("\n")}` : "";
2744
2783
  return (0, import_langchain9.tool)(
2745
2784
  async ({
2746
- serverKey,
2747
- datasourceId,
2785
+ serverKey: inputServerKey,
2786
+ datasourceId: inputDatasourceId,
2748
2787
  metrics,
2749
2788
  groupBy,
2750
2789
  filters,
2751
2790
  limit
2752
2791
  }, _exeConfig) => {
2753
2792
  try {
2793
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2794
+ const metricsDataSource = runConfig.metricsDataSource;
2795
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2796
+ const datasourceId = metricsDataSource?.datasourceId || inputDatasourceId;
2754
2797
  if (!serverKey) {
2755
2798
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2756
2799
  }
@@ -2773,6 +2816,7 @@ ${serverKeys.map(
2773
2816
  operator: f.operator,
2774
2817
  values: f.values
2775
2818
  }));
2819
+ console.log(`[query_semantic_metric_data] Querying: server=${serverKey}, datasource=${datasourceId}, metrics=[${metrics.join(", ")}], groupBy=[${groupBy?.join(", ") || ""}], filters=${JSON.stringify(filters)}, limit=${limit || 1e3}`);
2776
2820
  const result = await client.semanticQuery({
2777
2821
  datasourceId,
2778
2822
  metrics,
@@ -2793,8 +2837,8 @@ ${serverKeys.map(
2793
2837
  name: "query_semantic_metric_data",
2794
2838
  description: `${QUERY_SEMANTIC_METRIC_DATA_DESCRIPTION}${availableServersText}`,
2795
2839
  schema: import_zod11.default.object({
2796
- serverKey: import_zod11.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2797
- datasourceId: import_zod11.default.string().describe("The data source ID to query metrics from."),
2840
+ serverKey: import_zod11.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2841
+ datasourceId: import_zod11.default.string().optional().describe("The data source ID to query metrics from. Optional if configured in runConfig.metricsDataSource"),
2798
2842
  metrics: import_zod11.default.array(import_zod11.default.string()).describe("Array of metric names to query (e.g., ['net_sales_amt', 'gross_profit'])."),
2799
2843
  groupBy: import_zod11.default.array(import_zod11.default.string()).optional().describe("Optional array of dimensions to group by (e.g., ['DocDate__month', 'CustomerCode'])."),
2800
2844
  filters: import_zod11.default.array(import_zod11.default.object({
@@ -2821,10 +2865,13 @@ ${serverKeys.map(
2821
2865
  ).join("\n")}` : "";
2822
2866
  return (0, import_langchain10.tool)(
2823
2867
  async ({
2824
- serverKey,
2868
+ serverKey: inputServerKey,
2825
2869
  datasourceIds
2826
2870
  }, _exeConfig) => {
2827
2871
  try {
2872
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2873
+ const metricsDataSource = runConfig.metricsDataSource;
2874
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2828
2875
  if (!serverKey) {
2829
2876
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2830
2877
  }
@@ -2836,7 +2883,7 @@ ${serverKeys.map(
2836
2883
  return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
2837
2884
  }
2838
2885
  const client = metricsServerManager.getClient(serverKey);
2839
- const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : client.getSelectedDataSources();
2886
+ const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
2840
2887
  if (targetDatasourceIds.length === 0) {
2841
2888
  return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
2842
2889
  }
@@ -2871,19 +2918,19 @@ ${serverKeys.map(
2871
2918
  }
2872
2919
  }
2873
2920
  if (allTables.size === 0) {
2874
- return `\u672A\u5728\u6307\u5B9A\u7684\u6570\u636E\u6E90\u4E2D\u627E\u5230\u6570\u636E\u8868\u3002`;
2921
+ return `No tables found in the specified data sources.`;
2875
2922
  }
2876
2923
  const lines = [];
2877
- lines.push(`## \u6570\u636E\u8868\u5217\u8868\uFF08\u5171 ${allTables.size} \u4E2A\uFF09
2924
+ lines.push(`## Table List (Total: ${allTables.size})
2878
2925
  `);
2879
2926
  const sortedTables = Array.from(allTables.values()).sort(
2880
2927
  (a, b) => a.tableName.localeCompare(b.tableName)
2881
2928
  );
2882
- lines.push("| \u8868\u540D | \u663E\u793A\u540D\u79F0 | \u5355\u636E\u7C7B\u578B | \u5217\u6570 | \u63CF\u8FF0 |");
2883
- lines.push("|------|---------|---------|------|------|");
2929
+ lines.push("| Table Name | Display Name | Document Type | Columns | Description |");
2930
+ lines.push("|------------|--------------|---------------|---------|-------------|");
2884
2931
  for (const table of sortedTables) {
2885
- const mainTableInfo = table.mainTable ? ` (\u4E3B\u8868: ${table.mainTable})` : "";
2886
- const lineTableInfo = table.lineTable ? ` (\u884C\u8868: ${table.lineTable})` : "";
2932
+ const mainTableInfo = table.mainTable ? ` (Main: ${table.mainTable})` : "";
2933
+ const lineTableInfo = table.lineTable ? ` (Line: ${table.lineTable})` : "";
2887
2934
  const tableRelation = mainTableInfo + lineTableInfo;
2888
2935
  lines.push(`| ${table.tableName} | ${table.displayName} | ${table.docType}${tableRelation} | ${table.columnCount} | ${table.shortDesc} |`);
2889
2936
  }
@@ -2896,8 +2943,8 @@ ${serverKeys.map(
2896
2943
  name: "query_tables_list",
2897
2944
  description: `${QUERY_TABLES_LIST_DESCRIPTION}${availableServersText}`,
2898
2945
  schema: import_zod12.default.object({
2899
- serverKey: import_zod12.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
2900
- datasourceIds: import_zod12.default.array(import_zod12.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources.")
2946
+ serverKey: import_zod12.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
2947
+ datasourceIds: import_zod12.default.array(import_zod12.default.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses the one configured in runConfig.metricsDataSource or all selected datasources.")
2901
2948
  })
2902
2949
  }
2903
2950
  );
@@ -2916,11 +2963,15 @@ ${serverKeys.map(
2916
2963
  ).join("\n")}` : "";
2917
2964
  return (0, import_langchain11.tool)(
2918
2965
  async ({
2919
- serverKey,
2966
+ serverKey: inputServerKey,
2920
2967
  tableName,
2921
- datasourceId
2968
+ datasourceId: inputDatasourceId
2922
2969
  }, _exeConfig) => {
2923
2970
  try {
2971
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
2972
+ const metricsDataSource = runConfig.metricsDataSource;
2973
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
2974
+ const datasourceId = inputDatasourceId || metricsDataSource?.datasourceId;
2924
2975
  if (!serverKey) {
2925
2976
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
2926
2977
  }
@@ -2960,30 +3011,18 @@ ${serverKeys.map(
2960
3011
  const lines = [];
2961
3012
  lines.push(`# ${foundTable.tableName}`);
2962
3013
  lines.push("");
2963
- lines.push(`## \u57FA\u672C\u4FE1\u606F`);
3014
+ lines.push(`## Basic Information`);
2964
3015
  lines.push("");
2965
- lines.push(`- **\u8868\u540D**: ${foundTable.tableName}`);
2966
- lines.push(`- **\u5355\u636E\u7C7B\u578B**: ${foundTable.docType}`);
2967
- lines.push(`- **\u5355\u636E\u7C7B\u578B(\u82F1\u6587)**: ${foundTable.docTypeEn}`);
2968
- if (foundTable.objTypeCode) {
2969
- lines.push(`- **\u5BF9\u8C61\u7C7B\u578B\u4EE3\u7801**: ${foundTable.objTypeCode}`);
2970
- }
2971
- if (foundTable.mainTable) {
2972
- lines.push(`- **\u4E3B\u8868**: ${foundTable.mainTable}`);
2973
- }
2974
- if (foundTable.lineTable) {
2975
- lines.push(`- **\u884C\u8868**: ${foundTable.lineTable}`);
2976
- }
2977
- if (foundDatasourceId) {
2978
- lines.push(`- **\u6570\u636E\u6E90ID**: ${foundDatasourceId}`);
2979
- }
3016
+ lines.push(`- **Table Name**: ${foundTable.tableName}`);
3017
+ lines.push(`- **Document Type**: ${foundTable.docType}`);
3018
+ lines.push(`- **Document Type (EN)**: ${foundTable.docTypeEn}`);
2980
3019
  lines.push("");
2981
3020
  if (foundTable.columns && foundTable.columns.length > 0) {
2982
3021
  const validColumns = foundTable.columns.filter((col) => col !== null);
2983
- lines.push(`## \u5217\u5B9A\u4E49 (${validColumns.length} \u5217)`);
3022
+ lines.push(`## Column Definitions (${validColumns.length} columns)`);
2984
3023
  lines.push("");
2985
- lines.push("| \u5217\u540D | \u6807\u7B7E | \u7C7B\u578B | \u793A\u4F8B\u503C |");
2986
- lines.push("|------|------|------|--------|");
3024
+ lines.push("| Column Name | Label | Type | Example |");
3025
+ lines.push("|-------------|-------|------|---------|");
2987
3026
  for (const col of validColumns) {
2988
3027
  const type = col.type || "-";
2989
3028
  const example = col.example || "-";
@@ -2991,14 +3030,6 @@ ${serverKeys.map(
2991
3030
  }
2992
3031
  lines.push("");
2993
3032
  }
2994
- if (foundTable.selectSql) {
2995
- lines.push(`## SQL \u67E5\u8BE2`);
2996
- lines.push("");
2997
- lines.push("```sql");
2998
- lines.push(foundTable.selectSql);
2999
- lines.push("```");
3000
- lines.push("");
3001
- }
3002
3033
  return lines.join("\n");
3003
3034
  } catch (error) {
3004
3035
  return `Error querying table definition: ${error instanceof Error ? error.message : String(error)}`;
@@ -3008,9 +3039,9 @@ ${serverKeys.map(
3008
3039
  name: "query_table_definition",
3009
3040
  description: `${QUERY_TABLE_DEFINITION_DESCRIPTION}${availableServersText}`,
3010
3041
  schema: import_zod13.default.object({
3011
- serverKey: import_zod13.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
3042
+ serverKey: import_zod13.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
3012
3043
  tableName: import_zod13.default.string().describe("The name of the table to get definition for."),
3013
- datasourceId: import_zod13.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, searches all selected datasources.")
3044
+ datasourceId: import_zod13.default.string().optional().describe("Optional specific datasource ID to search in. If not provided, uses the one configured in runConfig.metricsDataSource or searches all selected datasources.")
3014
3045
  })
3015
3046
  }
3016
3047
  );
@@ -3064,13 +3095,17 @@ ${serverKeys.map(
3064
3095
  ).join("\n")}` : "";
3065
3096
  return (0, import_langchain12.tool)(
3066
3097
  async ({
3067
- serverKey,
3068
- datasourceId,
3098
+ serverKey: inputServerKey,
3099
+ datasourceId: inputDatasourceId,
3069
3100
  customSql,
3070
3101
  params,
3071
3102
  limit
3072
3103
  }, _exeConfig) => {
3073
3104
  try {
3105
+ const runConfig = _exeConfig?.configurable?.runConfig || {};
3106
+ const metricsDataSource = runConfig.metricsDataSource;
3107
+ const serverKey = metricsDataSource?.serverKey || inputServerKey;
3108
+ const datasourceId = metricsDataSource?.datasourceId || inputDatasourceId;
3074
3109
  if (!serverKey) {
3075
3110
  return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
3076
3111
  }
@@ -3103,8 +3138,8 @@ ${serverKeys.map(
3103
3138
  name: "execute_sql_query",
3104
3139
  description: `${EXECUTE_SQL_QUERY_DESCRIPTION}${availableServersText}`,
3105
3140
  schema: import_zod14.default.object({
3106
- serverKey: import_zod14.default.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
3107
- datasourceId: import_zod14.default.string().describe("The data source ID to execute SQL against."),
3141
+ serverKey: import_zod14.default.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
3142
+ datasourceId: import_zod14.default.string().optional().describe("The data source ID to execute SQL against. Optional if configured in runConfig.metricsDataSource"),
3108
3143
  customSql: import_zod14.default.string().describe("Custom SQL query string with named parameters (e.g., :year, :category). Use double quotes for identifiers."),
3109
3144
  params: import_zod14.default.record(import_zod14.default.union([import_zod14.default.string(), import_zod14.default.number(), import_zod14.default.boolean()])).optional().describe("Optional parameters for the SQL query. Keys should match the :paramName placeholders in customSql."),
3110
3145
  limit: import_zod14.default.number().optional().describe("Maximum number of results to return (default: 1000).")
@@ -6221,41 +6256,34 @@ storeLatticeManager.registerLattice("default", "userTenantLink", defaultUserTena
6221
6256
  // src/tool_lattice/skill/load_skills.ts
6222
6257
  var import_zod41 = __toESM(require("zod"));
6223
6258
  var import_langchain40 = require("langchain");
6224
- var LOAD_SKILLS_DESCRIPTION = `Load all available skills and return their metadata (name, description, license, compatibility, metadata, and subSkills) without the content. This tool returns skill information including hierarchical relationships (subSkills). Use this to discover what skills are available and their structure.`;
6225
- var createLoadSkillsTool = ({ skills } = {}) => {
6226
- return (0, import_langchain40.tool)(
6227
- async (_input, _exe_config) => {
6228
- try {
6229
- const storeLattice = getStoreLattice("default", "skill");
6230
- const skillStore = storeLattice.store;
6231
- const allSkills = await skillStore.getAllSkills();
6232
- const filteredSkills = skills && skills.length > 0 ? allSkills.filter((skill) => skills.includes(skill.id)) : allSkills;
6233
- const skillsMeta = filteredSkills.map((skill) => ({
6234
- id: skill.id,
6235
- name: skill.name,
6236
- description: skill.description,
6237
- license: skill.license,
6238
- compatibility: skill.compatibility,
6239
- metadata: skill.metadata,
6240
- subSkills: skill.subSkills
6241
- }));
6242
- return JSON.stringify(skillsMeta, null, 2);
6243
- } catch (error) {
6244
- return `Error loading skills: ${error instanceof Error ? error.message : String(error)}`;
6245
- }
6246
- },
6247
- {
6248
- name: "load_skills",
6249
- description: LOAD_SKILLS_DESCRIPTION,
6250
- schema: import_zod41.default.object({})
6251
- }
6252
- );
6253
- };
6254
6259
 
6255
6260
  // src/tool_lattice/skill/load_skill_content.ts
6256
6261
  var import_zod42 = __toESM(require("zod"));
6257
6262
  var import_langchain41 = require("langchain");
6258
- var LOAD_SKILL_CONTENT_DESCRIPTION = `Load a specific skill's content by name and return its full content including markdown body. This tool returns the complete skill content including frontmatter and markdown body. If the skill has resources, they will be listed at the end of the content with instructions on how to access them. Use this tool to get the complete skill content for a skill that you want to use.`;
6263
+ var LOAD_SKILL_CONTENT_DESCRIPTION = `
6264
+ Execute a skill within the main conversation
6265
+
6266
+ when users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.
6267
+
6268
+ When users ask you to run a "slash command" or reference "/<something>" (e.g., "/commit", "/review-pr"),they are referring to a skill. Use this tool to invoke the corresponding skill.
6269
+ Example:
6270
+ User: "run /commit"
6271
+ Assistant: [Calls Skill tool with skill: "commit"]
6272
+
6273
+ How to invoke:
6274
+ - Use this tool with the skill name
6275
+ - Examples:
6276
+ - skill: "pdf" -invoke the pdf skill
6277
+
6278
+ Important:
6279
+ - When a skill is relevant, you must invoke this tool IMMEDIATELY as your first action
6280
+ - NEVER just announce or mention a skill in your text response without actually calling this tool
6281
+ - This is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task
6282
+ - Only use skills listed in "<available_skills>" tag below
6283
+ - Do not invoke a skill that is already running
6284
+ - Do not use this tool for built-in CLI commands (like /help, /clear, etc.)
6285
+ - If you see a command-name> tag in the current conversation turn (e.g., <command-name>/commit</command-name>), the skill has ALREADY been loaded and its instructions follow in the next message.
6286
+ Do NOT call this tool - just follow the skill instructions directly.`;
6259
6287
  var createLoadSkillContentTool = () => {
6260
6288
  return (0, import_langchain41.tool)(
6261
6289
  async (input, _exe_config) => {
@@ -6313,7 +6341,7 @@ ${content}`;
6313
6341
  }
6314
6342
  },
6315
6343
  {
6316
- name: "load_skill_content",
6344
+ name: "skill",
6317
6345
  description: LOAD_SKILL_CONTENT_DESCRIPTION,
6318
6346
  schema: import_zod42.default.object({
6319
6347
  skill_name: import_zod42.default.string().describe("The name of the skill to load")
@@ -6357,25 +6385,16 @@ var createLoadSkillResourceTool = () => {
6357
6385
  };
6358
6386
 
6359
6387
  // src/middlewares/skillMiddleware.ts
6360
- var DEFAULT_HEADING = "To better accomplish the user's objective, you can use the following skills to access best practices.";
6361
- var DEFAULT_EXTRA_NOTE = `
6362
- you must:
6363
- 1) systematically evaluate every available skill for relevance,
6364
- 2) explicitly activate all skills you judge relevant using the \`load_skill_content\` tool to get the best practices *before* working on the task, and
6365
- 3) implement your solution using the guidance and best practices from those activated skills, explaining trade\u2011offs when they matter.
6366
- `;
6367
6388
  function createSkillMiddleware(params = {}) {
6368
6389
  const {
6369
6390
  skills = [],
6370
- readAll = false,
6371
- heading = DEFAULT_HEADING,
6372
- extraNote = DEFAULT_EXTRA_NOTE
6391
+ readAll = false
6373
6392
  } = params;
6374
6393
  let latestSkills = [];
6375
6394
  return (0, import_langchain43.createMiddleware)({
6376
6395
  name: "skillMiddleware",
6377
6396
  tools: [
6378
- createLoadSkillsTool({ skills: readAll ? void 0 : skills }),
6397
+ // createLoadSkillsTool({ skills: readAll ? undefined : skills }),
6379
6398
  createLoadSkillContentTool(),
6380
6399
  createLoadSkillResourceTool()
6381
6400
  ],
@@ -6401,11 +6420,11 @@ function createSkillMiddleware(params = {}) {
6401
6420
  ${skill.description}`).join("\n");
6402
6421
  const skillsAddendum = `
6403
6422
 
6404
- ${heading}
6423
+ <available_skills>
6405
6424
 
6406
6425
  ${skillsPrompt}
6407
6426
 
6408
- ${extraNote}`;
6427
+ </available_skills>`;
6409
6428
  const existingSystemPrompt = request.systemPrompt ?? "";
6410
6429
  const newSystemPrompt = existingSystemPrompt.length > 0 ? `${existingSystemPrompt}${skillsAddendum}` : skillsAddendum.trimStart();
6411
6430
  return handler({
@@ -7255,15 +7274,19 @@ ${systemPrompt}` : systemPrompt;
7255
7274
  // src/middlewares/metricsMiddleware.ts
7256
7275
  var import_langchain45 = require("langchain");
7257
7276
  function createMetricsMiddleware(params) {
7258
- const { serverKeys, serverDescriptions } = params;
7259
- if (!serverKeys || serverKeys.length === 0) {
7277
+ const { serverKeys, serverDescriptions, connectAll } = params;
7278
+ let effectiveServerKeys = serverKeys;
7279
+ if (connectAll) {
7280
+ effectiveServerKeys = metricsServerManager.getServerKeys().map((s) => s.key);
7281
+ }
7282
+ if (!effectiveServerKeys || effectiveServerKeys.length === 0) {
7260
7283
  return (0, import_langchain45.createMiddleware)({
7261
7284
  name: "metricsMiddleware",
7262
7285
  tools: []
7263
7286
  });
7264
7287
  }
7265
7288
  const toolParams = {
7266
- serverKeys,
7289
+ serverKeys: effectiveServerKeys,
7267
7290
  serverDescriptions
7268
7291
  };
7269
7292
  return (0, import_langchain45.createMiddleware)({
@@ -7321,7 +7344,7 @@ function createCommonMiddlewares(middlewareConfigs, filesystemBackend) {
7321
7344
  case "metrics":
7322
7345
  {
7323
7346
  const metricsConfig = config.config;
7324
- if (metricsConfig.serverKeys && metricsConfig.serverKeys.length > 0) {
7347
+ if (metricsConfig.connectAll || metricsConfig.serverKeys && metricsConfig.serverKeys.length > 0) {
7325
7348
  middlewares.push(createMetricsMiddleware(metricsConfig));
7326
7349
  }
7327
7350
  }
@@ -7705,6 +7728,11 @@ var AgentWorkerState = import_langgraph5.Annotation.Root({
7705
7728
  reducer: (x, y) => y ?? x,
7706
7729
  default: () => void 0
7707
7730
  }),
7731
+ // RunConfig for passing configuration through the graph
7732
+ runConfig: (0, import_langgraph5.Annotation)({
7733
+ reducer: (x, y) => y ?? x,
7734
+ default: () => void 0
7735
+ }),
7708
7736
  // Execution result
7709
7737
  result: (0, import_langgraph5.Annotation)({
7710
7738
  reducer: (x, y) => y ?? x,
@@ -7722,12 +7750,13 @@ var AgentWorkerState = import_langgraph5.Annotation.Root({
7722
7750
  })
7723
7751
  });
7724
7752
  async function executeNode(state) {
7725
- const { assistant_id, thread_id, input, command2 } = state;
7753
+ const { assistant_id, thread_id, input, command2, runConfig } = state;
7726
7754
  const callParams = {
7727
7755
  assistant_id,
7728
7756
  thread_id,
7729
7757
  input,
7730
- command: command2
7758
+ command: command2,
7759
+ runConfig
7731
7760
  };
7732
7761
  const result = await AgentManager.getInstance().callAgentInQueue(
7733
7762
  callParams,
@@ -7792,7 +7821,7 @@ var DEFAULT_SUBAGENT_PROMPT = "In order to complete the objective that the user
7792
7821
  var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
7793
7822
  var DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. This agent has access to all tools as the main agent.";
7794
7823
  function getTaskToolDescription(subagentDescriptions) {
7795
- return `
7824
+ return subagentDescriptions.length > 0 ? `
7796
7825
  Launch an ephemeral subagent to handle complex, multi-step independent tasks with isolated context windows.
7797
7826
 
7798
7827
  Available agent types and the tools they have access to:
@@ -7902,7 +7931,7 @@ Since the user is greeting, use the greeting-responder agent to respond with a f
7902
7931
  </commentary>
7903
7932
  assistant: "I'm going to use the Task tool to launch with the greeting-responder agent"
7904
7933
  </example>
7905
- `.trim();
7934
+ `.trim() : "No subagents available, you DON'T NEED TO USE THE TASK TOOL, just use the tools directly.";
7906
7935
  }
7907
7936
  var TASK_SYSTEM_PROMPT = `## \`task\` (subagent spawner)
7908
7937
 
@@ -7989,16 +8018,16 @@ function getSubagents(options) {
7989
8018
  }
7990
8019
  for (const agentParams of subagents) {
7991
8020
  subagentDescriptions.push(
7992
- `- ${agentParams.name}: ${agentParams.description}`
8021
+ `- ${agentParams.key}: ${agentParams.name} - ${agentParams.description}`
7993
8022
  );
7994
8023
  if ("runnable" in agentParams) {
7995
- agents[agentParams.name] = agentParams.runnable;
8024
+ agents[agentParams.key] = agentParams.runnable;
7996
8025
  } else {
7997
8026
  const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
7998
8027
  const interruptOn = agentParams.interruptOn || defaultInterruptOn;
7999
8028
  if (interruptOn)
8000
8029
  middleware.push((0, import_langchain47.humanInTheLoopMiddleware)({ interruptOn }));
8001
- agents[agentParams.name] = (0, import_langchain47.createAgent)({
8030
+ agents[agentParams.key] = (0, import_langchain47.createAgent)({
8002
8031
  model: agentParams.model ?? defaultModel,
8003
8032
  systemPrompt: agentParams.systemPrompt,
8004
8033
  tools: agentParams.tools ?? defaultTools,
@@ -8046,7 +8075,12 @@ function createTaskTool(options) {
8046
8075
  const workerResult = await agentWorkerGraph.invoke({
8047
8076
  assistant_id: subagent_type,
8048
8077
  thread_id: subagent_thread_id,
8049
- input: { ...subagentState, message: description }
8078
+ input: { ...subagentState, message: description },
8079
+ runConfig: {
8080
+ ...config.configurable?.runConfig,
8081
+ assistant_id: subagent_type,
8082
+ thread_id: subagent_thread_id
8083
+ }
8050
8084
  });
8051
8085
  const result = workerResult.finalState?.values;
8052
8086
  if (!config.toolCall?.id) {
@@ -9661,6 +9695,7 @@ var DeepAgentGraphBuilder = class {
9661
9695
  const subagents = params.subAgents.map((sa) => {
9662
9696
  if (sa.client) {
9663
9697
  return {
9698
+ key: sa.config.key,
9664
9699
  name: sa.config.name,
9665
9700
  description: sa.config.description,
9666
9701
  runnable: sa.client
@@ -9670,6 +9705,7 @@ var DeepAgentGraphBuilder = class {
9670
9705
  config: sa.config
9671
9706
  });
9672
9707
  return {
9708
+ key: sa.config.key,
9673
9709
  name: sa.config.name,
9674
9710
  description: sa.config.description,
9675
9711
  runnable: subagentClient