@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.d.mts +53 -52
- package/dist/index.d.ts +53 -52
- package/dist/index.js +224 -188
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +224 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -218,7 +218,10 @@ var ModelLattice = class extends BaseChatModel {
|
|
|
218
218
|
timeout: config.timeout,
|
|
219
219
|
maxRetries: config.maxRetries || 2,
|
|
220
220
|
apiKey: config.apiKey || process.env[config.apiKeyEnvName || "DEEPSEEK_API_KEY"],
|
|
221
|
-
streaming: config.streaming
|
|
221
|
+
streaming: config.streaming,
|
|
222
|
+
configuration: {
|
|
223
|
+
baseURL: config.baseURL
|
|
224
|
+
}
|
|
222
225
|
});
|
|
223
226
|
} else if (config.provider === "siliconcloud") {
|
|
224
227
|
return new ChatOpenAI({
|
|
@@ -1911,6 +1914,20 @@ ${serverKeys.map(
|
|
|
1911
1914
|
return tool7(
|
|
1912
1915
|
async (_input, _exeConfig) => {
|
|
1913
1916
|
try {
|
|
1917
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
1918
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
1919
|
+
if (metricsDataSource) {
|
|
1920
|
+
const { serverKey, datasourceId } = metricsDataSource;
|
|
1921
|
+
return `\u2139\uFE0F **Current Data Source Selected**
|
|
1922
|
+
|
|
1923
|
+
You have selected a specific data source through the interface. All metrics queries will focus on:
|
|
1924
|
+
- **Server**: ${serverKey}
|
|
1925
|
+
- **Data Source ID**: ${datasourceId}
|
|
1926
|
+
|
|
1927
|
+
You can directly use other metrics tools (such as query_metrics_list, query_semantic_metric_data, etc.) without specifying the serverKey and datasourceId parameters.
|
|
1928
|
+
|
|
1929
|
+
To view all available data sources, please clear the current selection or reopen the data source selector.`;
|
|
1930
|
+
}
|
|
1914
1931
|
if (serverKeys.length === 0) {
|
|
1915
1932
|
return "No metrics servers configured.";
|
|
1916
1933
|
}
|
|
@@ -2006,10 +2023,13 @@ ${serverKeys.map(
|
|
|
2006
2023
|
).join("\n")}` : "";
|
|
2007
2024
|
return tool8(
|
|
2008
2025
|
async ({
|
|
2009
|
-
serverKey,
|
|
2026
|
+
serverKey: inputServerKey,
|
|
2010
2027
|
datasourceIds
|
|
2011
2028
|
}, _exeConfig) => {
|
|
2012
2029
|
try {
|
|
2030
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
2031
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
2032
|
+
const serverKey = metricsDataSource?.serverKey || inputServerKey;
|
|
2013
2033
|
if (!serverKey) {
|
|
2014
2034
|
return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
|
|
2015
2035
|
}
|
|
@@ -2021,7 +2041,7 @@ ${serverKeys.map(
|
|
|
2021
2041
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
2022
2042
|
}
|
|
2023
2043
|
const client = metricsServerManager.getClient(serverKey);
|
|
2024
|
-
const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : client.getSelectedDataSources();
|
|
2044
|
+
const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
|
|
2025
2045
|
if (targetDatasourceIds.length === 0) {
|
|
2026
2046
|
return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
|
|
2027
2047
|
}
|
|
@@ -2060,21 +2080,21 @@ ${serverKeys.map(
|
|
|
2060
2080
|
}
|
|
2061
2081
|
}
|
|
2062
2082
|
if (metricsByDatasource.size === 0) {
|
|
2063
|
-
return
|
|
2083
|
+
return `No metrics found in the specified data sources.`;
|
|
2064
2084
|
}
|
|
2065
2085
|
const lines = [];
|
|
2066
|
-
lines.push(`##
|
|
2086
|
+
lines.push(`## Business Metrics List (serverKey: ${serverKey})
|
|
2067
2087
|
`);
|
|
2068
2088
|
const sortedDatasourceIds = Array.from(metricsByDatasource.keys()).sort();
|
|
2069
2089
|
for (const dsId of sortedDatasourceIds) {
|
|
2070
2090
|
const metrics = metricsByDatasource.get(dsId);
|
|
2071
2091
|
const sortedMetrics = metrics.sort((a, b) => {
|
|
2072
|
-
if (a.domain !== b.domain) {
|
|
2092
|
+
if (a.domain && a.domain !== b.domain) {
|
|
2073
2093
|
return a.domain.localeCompare(b.domain);
|
|
2074
2094
|
}
|
|
2075
2095
|
return a.metricName.localeCompare(b.metricName);
|
|
2076
2096
|
});
|
|
2077
|
-
lines.push(`### datasourceId: ${dsId}
|
|
2097
|
+
lines.push(`### datasourceId: ${dsId} (${metrics.length} metrics)
|
|
2078
2098
|
`);
|
|
2079
2099
|
lines.push("| metricName | displayName | domain | shortDesc |");
|
|
2080
2100
|
lines.push("|------------|-------------|--------|-----------|");
|
|
@@ -2086,7 +2106,7 @@ ${serverKeys.map(
|
|
|
2086
2106
|
}
|
|
2087
2107
|
lines.push("---");
|
|
2088
2108
|
lines.push("");
|
|
2089
|
-
lines.push("
|
|
2109
|
+
lines.push("To view detailed metric definitions, use the **query_metric_definition** tool with parameters: `serverKey`, `metricName`, `datasourceId`");
|
|
2090
2110
|
return lines.join("\n");
|
|
2091
2111
|
} catch (error) {
|
|
2092
2112
|
return `Error querying metrics list: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -2096,8 +2116,8 @@ ${serverKeys.map(
|
|
|
2096
2116
|
name: "query_metrics_list",
|
|
2097
2117
|
description: `${QUERY_METRICS_LIST_DESCRIPTION}${availableServersText}`,
|
|
2098
2118
|
schema: z9.object({
|
|
2099
|
-
serverKey: z9.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
|
|
2100
|
-
datasourceIds: z9.array(z9.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources.")
|
|
2119
|
+
serverKey: z9.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
|
|
2120
|
+
datasourceIds: z9.array(z9.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources or the one configured in runConfig.metricsDataSource.")
|
|
2101
2121
|
})
|
|
2102
2122
|
}
|
|
2103
2123
|
);
|
|
@@ -2154,11 +2174,15 @@ ${serverKeys.map(
|
|
|
2154
2174
|
).join("\n")}` : "";
|
|
2155
2175
|
return tool9(
|
|
2156
2176
|
async ({
|
|
2157
|
-
serverKey,
|
|
2177
|
+
serverKey: inputServerKey,
|
|
2158
2178
|
metricName,
|
|
2159
|
-
datasourceId
|
|
2179
|
+
datasourceId: inputDatasourceId
|
|
2160
2180
|
}, _exeConfig) => {
|
|
2161
2181
|
try {
|
|
2182
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
2183
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
2184
|
+
const serverKey = metricsDataSource?.serverKey || inputServerKey;
|
|
2185
|
+
const datasourceId = inputDatasourceId || metricsDataSource?.datasourceId;
|
|
2162
2186
|
if (!serverKey) {
|
|
2163
2187
|
return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
|
|
2164
2188
|
}
|
|
@@ -2201,143 +2225,158 @@ ${serverKeys.map(
|
|
|
2201
2225
|
const lines = [];
|
|
2202
2226
|
lines.push(`# ${foundDetail.displayName} (${foundDetail.metricName})`);
|
|
2203
2227
|
lines.push("");
|
|
2204
|
-
lines.push(`##
|
|
2228
|
+
lines.push(`## Basic Information`);
|
|
2205
2229
|
lines.push("");
|
|
2206
|
-
lines.push(`-
|
|
2207
|
-
lines.push(`-
|
|
2208
|
-
lines.push(`-
|
|
2209
|
-
lines.push(`-
|
|
2210
|
-
lines.push(`-
|
|
2230
|
+
lines.push(`- **Metric Name**: ${foundDetail.metricName}`);
|
|
2231
|
+
lines.push(`- **Display Name**: ${foundDetail.displayName}`);
|
|
2232
|
+
lines.push(`- **Domain**: ${foundDetail.domain}`);
|
|
2233
|
+
lines.push(`- **Data Type**: ${foundDetail.dataType}`);
|
|
2234
|
+
lines.push(`- **Format**: ${foundDetail.format}`);
|
|
2211
2235
|
if (foundDatasourceId) {
|
|
2212
|
-
lines.push(`-
|
|
2236
|
+
lines.push(`- **Data Source ID**: ${foundDatasourceId}`);
|
|
2213
2237
|
}
|
|
2214
2238
|
lines.push("");
|
|
2215
|
-
lines.push(`##
|
|
2239
|
+
lines.push(`## Description`);
|
|
2216
2240
|
lines.push("");
|
|
2217
2241
|
lines.push(foundDetail.description);
|
|
2218
2242
|
lines.push("");
|
|
2219
2243
|
if (foundDetail.defaultTimeContext) {
|
|
2220
|
-
|
|
2244
|
+
const dtc = foundDetail.defaultTimeContext;
|
|
2245
|
+
lines.push(`## Time Context`);
|
|
2221
2246
|
lines.push("");
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2247
|
+
if (dtc.timeDimension) {
|
|
2248
|
+
lines.push(`- **Time Dimension**: ${dtc.timeDimension}${dtc.label ? ` (${dtc.label})` : ""}`);
|
|
2249
|
+
}
|
|
2250
|
+
if (dtc.granularity) {
|
|
2251
|
+
lines.push(`- **Default Granularity**: ${dtc.granularity}`);
|
|
2252
|
+
}
|
|
2253
|
+
if (dtc.window) {
|
|
2254
|
+
lines.push(`- **Default Window**: ${dtc.window}`);
|
|
2255
|
+
}
|
|
2256
|
+
const grains = dtc.supportedGrains;
|
|
2257
|
+
lines.push(`- **Supported Grains**: ${Array.isArray(grains) && grains.length > 0 ? grains.join(", ") : "Not configured"}`);
|
|
2226
2258
|
lines.push("");
|
|
2227
2259
|
}
|
|
2228
2260
|
if (foundDetail.supportedDimensions && foundDetail.supportedDimensions.length > 0) {
|
|
2229
2261
|
const categoricalDims = foundDetail.supportedDimensions.filter((d) => d.type === "categorical");
|
|
2230
2262
|
const datetimeDims = foundDetail.supportedDimensions.filter((d) => d.type === "datetime");
|
|
2231
2263
|
const timeDimension = foundDetail.defaultTimeContext?.timeDimension;
|
|
2232
|
-
lines.push(`##
|
|
2264
|
+
lines.push(`## Supported Dimensions`);
|
|
2233
2265
|
lines.push("");
|
|
2234
2266
|
if (categoricalDims.length > 0) {
|
|
2235
|
-
lines.push(`###
|
|
2236
|
-
lines.push("
|
|
2267
|
+
lines.push(`### Categorical Dimensions - ${categoricalDims.length}`);
|
|
2268
|
+
lines.push("Supports IN (multiple), EQ (single) operators");
|
|
2237
2269
|
lines.push("");
|
|
2238
2270
|
const examples = categoricalDims.slice(0, 2);
|
|
2239
2271
|
for (const dim of examples) {
|
|
2240
2272
|
lines.push(`**${dim.dim_id}** (${dim.field_name})`);
|
|
2241
2273
|
lines.push("```json");
|
|
2242
|
-
lines.push(`//
|
|
2274
|
+
lines.push(`// Grouping example`);
|
|
2243
2275
|
lines.push(`"groupBy": ["${dim.dim_id}"]`);
|
|
2244
2276
|
lines.push("");
|
|
2245
|
-
lines.push(`//
|
|
2277
|
+
lines.push(`// Filter example`);
|
|
2246
2278
|
lines.push(`{"dimension": "${dim.dim_id}", "operator": "IN", "values": ["value1", "value2"]}`);
|
|
2247
2279
|
lines.push("```");
|
|
2248
2280
|
lines.push("");
|
|
2249
2281
|
}
|
|
2250
2282
|
if (categoricalDims.length > 2) {
|
|
2251
|
-
const others = categoricalDims.slice(2).map((d) => d.dim_id).join("
|
|
2252
|
-
lines.push(
|
|
2283
|
+
const others = categoricalDims.slice(2).map((d) => d.dim_id).join(", ");
|
|
2284
|
+
lines.push(`**Other ${categoricalDims.length - 2} dimensions**: ${others}`);
|
|
2253
2285
|
lines.push("");
|
|
2254
2286
|
}
|
|
2255
2287
|
}
|
|
2256
2288
|
if (datetimeDims.length > 0) {
|
|
2257
|
-
lines.push(`###
|
|
2258
|
-
lines.push("
|
|
2289
|
+
lines.push(`### Datetime Dimensions - ${datetimeDims.length}`);
|
|
2290
|
+
lines.push("Supports BETWEEN (range), GT/GTE/LT/LTE (comparison) operators");
|
|
2259
2291
|
lines.push("");
|
|
2260
2292
|
const primaryDim = datetimeDims.find((d) => d.dim_id === timeDimension) || datetimeDims[0];
|
|
2261
2293
|
lines.push(`**${primaryDim.dim_id}** (${primaryDim.field_name})`);
|
|
2262
2294
|
lines.push("```json");
|
|
2263
|
-
lines.push(`//
|
|
2264
|
-
lines.push(`"groupBy": ["${primaryDim.dim_id}__month"] //
|
|
2295
|
+
lines.push(`// Group by time grain`);
|
|
2296
|
+
lines.push(`"groupBy": ["${primaryDim.dim_id}__month"] // Options: day, week, month, year`);
|
|
2265
2297
|
lines.push("");
|
|
2266
|
-
lines.push(`//
|
|
2298
|
+
lines.push(`// Time range filter`);
|
|
2267
2299
|
lines.push(`{"dimension": "${primaryDim.dim_id}", "operator": "BETWEEN", "values": ["2025-01-01", "2025-12-31"]}`);
|
|
2268
2300
|
lines.push("```");
|
|
2269
2301
|
lines.push("");
|
|
2270
2302
|
if (datetimeDims.length > 1) {
|
|
2271
|
-
const others = datetimeDims.filter((d) => d.dim_id !== primaryDim.dim_id).map((d) => d.dim_id).join("
|
|
2272
|
-
lines.push(
|
|
2303
|
+
const others = datetimeDims.filter((d) => d.dim_id !== primaryDim.dim_id).map((d) => d.dim_id).join(", ");
|
|
2304
|
+
lines.push(`**Other time dimensions**: ${others}`);
|
|
2273
2305
|
lines.push("");
|
|
2274
2306
|
}
|
|
2275
2307
|
}
|
|
2276
|
-
lines.push("###
|
|
2308
|
+
lines.push("### Quick Reference");
|
|
2277
2309
|
lines.push("");
|
|
2278
|
-
lines.push("
|
|
2279
|
-
lines.push("-
|
|
2280
|
-
lines.push("-
|
|
2281
|
-
lines.push("-
|
|
2282
|
-
lines.push("-
|
|
2310
|
+
lines.push("**Time grouping format**: `{timeDimension}__{grain}`");
|
|
2311
|
+
lines.push("- By day: `DocDate__day`");
|
|
2312
|
+
lines.push("- By week: `DocDate__week`");
|
|
2313
|
+
lines.push("- By month: `DocDate__month`");
|
|
2314
|
+
lines.push("- By year: `DocDate__year`");
|
|
2283
2315
|
lines.push("");
|
|
2284
2316
|
}
|
|
2285
2317
|
if (foundDetail.aiAgentContext) {
|
|
2286
2318
|
const aiContext = foundDetail.aiAgentContext;
|
|
2287
|
-
lines.push(`## AI
|
|
2288
|
-
lines.push("");
|
|
2289
|
-
lines.push(`### \u6307\u6807\u6781\u6027`);
|
|
2290
|
-
lines.push("");
|
|
2291
|
-
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");
|
|
2319
|
+
lines.push(`## AI Analysis Context`);
|
|
2292
2320
|
lines.push("");
|
|
2321
|
+
if (aiContext.polarity) {
|
|
2322
|
+
lines.push(`### Metric Polarity`);
|
|
2323
|
+
lines.push("");
|
|
2324
|
+
lines.push(aiContext.polarity === "positive" ? "Positive metric (higher is better)" : "Negative metric (lower is better)");
|
|
2325
|
+
lines.push("");
|
|
2326
|
+
}
|
|
2293
2327
|
if (aiContext.synonyms && aiContext.synonyms.length > 0) {
|
|
2294
|
-
lines.push(`###
|
|
2328
|
+
lines.push(`### Synonyms/Aliases`);
|
|
2295
2329
|
lines.push("");
|
|
2296
|
-
lines.push(aiContext.synonyms.join("
|
|
2330
|
+
lines.push(aiContext.synonyms.join(", "));
|
|
2297
2331
|
lines.push("");
|
|
2298
2332
|
}
|
|
2299
2333
|
if (aiContext.thresholds && aiContext.thresholds.length > 0) {
|
|
2300
|
-
lines.push(`###
|
|
2334
|
+
lines.push(`### Alert Thresholds`);
|
|
2301
2335
|
lines.push("");
|
|
2302
|
-
lines.push("|
|
|
2303
|
-
lines.push("
|
|
2336
|
+
lines.push("| Metric | Operator | Threshold | Level |");
|
|
2337
|
+
lines.push("|--------|----------|-----------|-------|");
|
|
2304
2338
|
for (const t of aiContext.thresholds) {
|
|
2305
2339
|
lines.push(`| ${t.metric} | ${t.operator} | ${t.value} | ${t.level} |`);
|
|
2306
2340
|
}
|
|
2307
2341
|
lines.push("");
|
|
2308
2342
|
}
|
|
2309
2343
|
if (aiContext.diagnosticWorkflow) {
|
|
2310
|
-
lines.push(`###
|
|
2344
|
+
lines.push(`### Diagnostic Workflow`);
|
|
2311
2345
|
lines.push("");
|
|
2312
2346
|
if (aiContext.diagnosticWorkflow.trigger && aiContext.diagnosticWorkflow.trigger.any_of) {
|
|
2313
|
-
lines.push(
|
|
2347
|
+
lines.push(`**Trigger Conditions** (satisfy any):`);
|
|
2314
2348
|
for (const trigger of aiContext.diagnosticWorkflow.trigger.any_of) {
|
|
2315
|
-
|
|
2349
|
+
if (trigger.metric && trigger.operator) {
|
|
2350
|
+
lines.push(`- ${trigger.metric} ${trigger.operator} ${trigger.value ?? "N/A"}`);
|
|
2351
|
+
}
|
|
2316
2352
|
}
|
|
2317
2353
|
lines.push("");
|
|
2318
2354
|
}
|
|
2319
2355
|
if (aiContext.diagnosticWorkflow.actions && aiContext.diagnosticWorkflow.actions.length > 0) {
|
|
2320
|
-
lines.push(
|
|
2356
|
+
lines.push(`**Analysis Actions**:`);
|
|
2321
2357
|
for (let i = 0; i < aiContext.diagnosticWorkflow.actions.length; i++) {
|
|
2322
2358
|
const action = aiContext.diagnosticWorkflow.actions[i];
|
|
2323
|
-
|
|
2359
|
+
if (!action) continue;
|
|
2360
|
+
lines.push(`${i + 1}. **${action.type ?? "Unnamed Action"}**`);
|
|
2324
2361
|
if (action.metric) {
|
|
2325
|
-
lines.push(` -
|
|
2362
|
+
lines.push(` - Comparison Metric: ${action.metric}`);
|
|
2326
2363
|
}
|
|
2327
2364
|
if (action.dimensions && action.dimensions.length > 0) {
|
|
2328
|
-
lines.push(` -
|
|
2365
|
+
lines.push(` - Drill-down Dimensions: ${action.dimensions.join(", ")}`);
|
|
2366
|
+
}
|
|
2367
|
+
if (action.intent) {
|
|
2368
|
+
lines.push(` - Intent: ${action.intent}`);
|
|
2329
2369
|
}
|
|
2330
|
-
lines.push(` - \u76EE\u7684: ${action.intent}`);
|
|
2331
2370
|
}
|
|
2332
2371
|
lines.push("");
|
|
2333
2372
|
}
|
|
2334
2373
|
if (aiContext.diagnosticWorkflow.analysis_logic) {
|
|
2335
|
-
lines.push(
|
|
2374
|
+
lines.push(`**Analysis Logic**: ${aiContext.diagnosticWorkflow.analysis_logic}`);
|
|
2336
2375
|
lines.push("");
|
|
2337
2376
|
}
|
|
2338
2377
|
}
|
|
2339
2378
|
if (aiContext.humanReadableExplanation) {
|
|
2340
|
-
lines.push(`###
|
|
2379
|
+
lines.push(`### System Recommendations`);
|
|
2341
2380
|
lines.push("");
|
|
2342
2381
|
lines.push(aiContext.humanReadableExplanation);
|
|
2343
2382
|
lines.push("");
|
|
@@ -2345,9 +2384,9 @@ ${serverKeys.map(
|
|
|
2345
2384
|
}
|
|
2346
2385
|
lines.push(`---`);
|
|
2347
2386
|
lines.push("");
|
|
2348
|
-
lines.push(`##
|
|
2387
|
+
lines.push(`## Usage Example`);
|
|
2349
2388
|
lines.push("");
|
|
2350
|
-
lines.push(
|
|
2389
|
+
lines.push(`To query this metric, use the query_semantic_metric_data tool with parameters:`);
|
|
2351
2390
|
lines.push(`- **metricName**: "${foundDetail.metricName}"`);
|
|
2352
2391
|
if (foundDatasourceId) {
|
|
2353
2392
|
lines.push(`- **datasourceId**: "${foundDatasourceId}"`);
|
|
@@ -2361,9 +2400,9 @@ ${serverKeys.map(
|
|
|
2361
2400
|
name: "query_metric_definition",
|
|
2362
2401
|
description: `${QUERY_METRIC_DEFINITION_DESCRIPTION}${availableServersText}`,
|
|
2363
2402
|
schema: z10.object({
|
|
2364
|
-
serverKey: z10.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
|
|
2403
|
+
serverKey: z10.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
|
|
2365
2404
|
metricName: z10.string().describe("The name of the metric to get definition for."),
|
|
2366
|
-
datasourceId: z10.string().optional().describe("Optional specific datasource ID to search in. If not provided, searches all selected datasources.")
|
|
2405
|
+
datasourceId: z10.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.")
|
|
2367
2406
|
})
|
|
2368
2407
|
}
|
|
2369
2408
|
);
|
|
@@ -2493,24 +2532,24 @@ function formatSemanticQueryResult(datasourceId, datasourceName, results) {
|
|
|
2493
2532
|
Data Source: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`;
|
|
2494
2533
|
}
|
|
2495
2534
|
const lines = [];
|
|
2496
|
-
lines.push(`#
|
|
2535
|
+
lines.push(`# Metric Query Results`);
|
|
2497
2536
|
lines.push(`
|
|
2498
|
-
|
|
2499
|
-
lines.push(
|
|
2537
|
+
**Data Source**: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`);
|
|
2538
|
+
lines.push(`**Metrics Count**: ${results.length}`);
|
|
2500
2539
|
lines.push(`
|
|
2501
2540
|
---
|
|
2502
2541
|
`);
|
|
2503
2542
|
for (const metric of results) {
|
|
2504
2543
|
lines.push(`## ${metric.displayName} (${metric.metricName})`);
|
|
2505
2544
|
lines.push(`
|
|
2506
|
-
-
|
|
2507
|
-
lines.push(`-
|
|
2508
|
-
lines.push(`-
|
|
2509
|
-
lines.push(`-
|
|
2510
|
-
lines.push(`-
|
|
2545
|
+
- **Data Type**: ${metric.dataType}`);
|
|
2546
|
+
lines.push(`- **Format**: ${metric.format}`);
|
|
2547
|
+
lines.push(`- **Polarity**: ${metric.polarity}`);
|
|
2548
|
+
lines.push(`- **Execution Time**: ${metric.executionTimeMs}ms`);
|
|
2549
|
+
lines.push(`- **Rows Returned**: ${metric.rowCount}`);
|
|
2511
2550
|
if (metric.columns.length > 0 && metric.rows.length > 0) {
|
|
2512
2551
|
lines.push(`
|
|
2513
|
-
###
|
|
2552
|
+
### Data
|
|
2514
2553
|
`);
|
|
2515
2554
|
lines.push(`| ${metric.columns.join(" | ")} |`);
|
|
2516
2555
|
lines.push(`|${metric.columns.map(() => "---").join("|")}|`);
|
|
@@ -2524,17 +2563,17 @@ Data Source: ${datasourceId}${datasourceName ? ` (${datasourceName})` : ""}`;
|
|
|
2524
2563
|
}
|
|
2525
2564
|
if (metric.aiHints) {
|
|
2526
2565
|
lines.push(`
|
|
2527
|
-
### AI
|
|
2566
|
+
### AI Analysis Suggestions
|
|
2528
2567
|
`);
|
|
2529
|
-
lines.push(`-
|
|
2568
|
+
lines.push(`- **Value Interpretation**: ${metric.aiHints.valueInterpretation}`);
|
|
2530
2569
|
if (metric.aiHints.thresholds && metric.aiHints.thresholds.length > 0) {
|
|
2531
|
-
lines.push(`-
|
|
2570
|
+
lines.push(`- **Alert Thresholds**:`);
|
|
2532
2571
|
for (const t of metric.aiHints.thresholds) {
|
|
2533
2572
|
lines.push(` - ${t.metric} ${t.operator} ${t.value} (${t.level})`);
|
|
2534
2573
|
}
|
|
2535
2574
|
}
|
|
2536
2575
|
if (metric.aiHints.suggestedFollowup && metric.aiHints.suggestedFollowup.length > 0) {
|
|
2537
|
-
lines.push(`-
|
|
2576
|
+
lines.push(`- **Suggested Follow-up Analysis**:`);
|
|
2538
2577
|
for (const suggestion of metric.aiHints.suggestedFollowup) {
|
|
2539
2578
|
lines.push(` - ${suggestion}`);
|
|
2540
2579
|
}
|
|
@@ -2555,14 +2594,18 @@ ${serverKeys.map(
|
|
|
2555
2594
|
).join("\n")}` : "";
|
|
2556
2595
|
return tool10(
|
|
2557
2596
|
async ({
|
|
2558
|
-
serverKey,
|
|
2559
|
-
datasourceId,
|
|
2597
|
+
serverKey: inputServerKey,
|
|
2598
|
+
datasourceId: inputDatasourceId,
|
|
2560
2599
|
metrics,
|
|
2561
2600
|
groupBy,
|
|
2562
2601
|
filters,
|
|
2563
2602
|
limit
|
|
2564
2603
|
}, _exeConfig) => {
|
|
2565
2604
|
try {
|
|
2605
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
2606
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
2607
|
+
const serverKey = metricsDataSource?.serverKey || inputServerKey;
|
|
2608
|
+
const datasourceId = metricsDataSource?.datasourceId || inputDatasourceId;
|
|
2566
2609
|
if (!serverKey) {
|
|
2567
2610
|
return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
|
|
2568
2611
|
}
|
|
@@ -2585,6 +2628,7 @@ ${serverKeys.map(
|
|
|
2585
2628
|
operator: f.operator,
|
|
2586
2629
|
values: f.values
|
|
2587
2630
|
}));
|
|
2631
|
+
console.log(`[query_semantic_metric_data] Querying: server=${serverKey}, datasource=${datasourceId}, metrics=[${metrics.join(", ")}], groupBy=[${groupBy?.join(", ") || ""}], filters=${JSON.stringify(filters)}, limit=${limit || 1e3}`);
|
|
2588
2632
|
const result = await client.semanticQuery({
|
|
2589
2633
|
datasourceId,
|
|
2590
2634
|
metrics,
|
|
@@ -2605,8 +2649,8 @@ ${serverKeys.map(
|
|
|
2605
2649
|
name: "query_semantic_metric_data",
|
|
2606
2650
|
description: `${QUERY_SEMANTIC_METRIC_DATA_DESCRIPTION}${availableServersText}`,
|
|
2607
2651
|
schema: z11.object({
|
|
2608
|
-
serverKey: z11.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
|
|
2609
|
-
datasourceId: z11.string().describe("The data source ID to query metrics from."),
|
|
2652
|
+
serverKey: z11.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
|
|
2653
|
+
datasourceId: z11.string().optional().describe("The data source ID to query metrics from. Optional if configured in runConfig.metricsDataSource"),
|
|
2610
2654
|
metrics: z11.array(z11.string()).describe("Array of metric names to query (e.g., ['net_sales_amt', 'gross_profit'])."),
|
|
2611
2655
|
groupBy: z11.array(z11.string()).optional().describe("Optional array of dimensions to group by (e.g., ['DocDate__month', 'CustomerCode'])."),
|
|
2612
2656
|
filters: z11.array(z11.object({
|
|
@@ -2633,10 +2677,13 @@ ${serverKeys.map(
|
|
|
2633
2677
|
).join("\n")}` : "";
|
|
2634
2678
|
return tool11(
|
|
2635
2679
|
async ({
|
|
2636
|
-
serverKey,
|
|
2680
|
+
serverKey: inputServerKey,
|
|
2637
2681
|
datasourceIds
|
|
2638
2682
|
}, _exeConfig) => {
|
|
2639
2683
|
try {
|
|
2684
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
2685
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
2686
|
+
const serverKey = metricsDataSource?.serverKey || inputServerKey;
|
|
2640
2687
|
if (!serverKey) {
|
|
2641
2688
|
return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
|
|
2642
2689
|
}
|
|
@@ -2648,7 +2695,7 @@ ${serverKeys.map(
|
|
|
2648
2695
|
return `Error: Server "${serverKey}" is not a semantic metrics server. This tool only works with semantic servers.`;
|
|
2649
2696
|
}
|
|
2650
2697
|
const client = metricsServerManager.getClient(serverKey);
|
|
2651
|
-
const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : client.getSelectedDataSources();
|
|
2698
|
+
const targetDatasourceIds = datasourceIds && datasourceIds.length > 0 ? datasourceIds : metricsDataSource?.datasourceId ? [metricsDataSource.datasourceId] : client.getSelectedDataSources();
|
|
2652
2699
|
if (targetDatasourceIds.length === 0) {
|
|
2653
2700
|
return `Error: No data sources specified and no default data sources configured for server "${serverKey}".`;
|
|
2654
2701
|
}
|
|
@@ -2683,19 +2730,19 @@ ${serverKeys.map(
|
|
|
2683
2730
|
}
|
|
2684
2731
|
}
|
|
2685
2732
|
if (allTables.size === 0) {
|
|
2686
|
-
return
|
|
2733
|
+
return `No tables found in the specified data sources.`;
|
|
2687
2734
|
}
|
|
2688
2735
|
const lines = [];
|
|
2689
|
-
lines.push(`##
|
|
2736
|
+
lines.push(`## Table List (Total: ${allTables.size})
|
|
2690
2737
|
`);
|
|
2691
2738
|
const sortedTables = Array.from(allTables.values()).sort(
|
|
2692
2739
|
(a, b) => a.tableName.localeCompare(b.tableName)
|
|
2693
2740
|
);
|
|
2694
|
-
lines.push("|
|
|
2695
|
-
lines.push("
|
|
2741
|
+
lines.push("| Table Name | Display Name | Document Type | Columns | Description |");
|
|
2742
|
+
lines.push("|------------|--------------|---------------|---------|-------------|");
|
|
2696
2743
|
for (const table of sortedTables) {
|
|
2697
|
-
const mainTableInfo = table.mainTable ? ` (
|
|
2698
|
-
const lineTableInfo = table.lineTable ? ` (
|
|
2744
|
+
const mainTableInfo = table.mainTable ? ` (Main: ${table.mainTable})` : "";
|
|
2745
|
+
const lineTableInfo = table.lineTable ? ` (Line: ${table.lineTable})` : "";
|
|
2699
2746
|
const tableRelation = mainTableInfo + lineTableInfo;
|
|
2700
2747
|
lines.push(`| ${table.tableName} | ${table.displayName} | ${table.docType}${tableRelation} | ${table.columnCount} | ${table.shortDesc} |`);
|
|
2701
2748
|
}
|
|
@@ -2708,8 +2755,8 @@ ${serverKeys.map(
|
|
|
2708
2755
|
name: "query_tables_list",
|
|
2709
2756
|
description: `${QUERY_TABLES_LIST_DESCRIPTION}${availableServersText}`,
|
|
2710
2757
|
schema: z12.object({
|
|
2711
|
-
serverKey: z12.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
|
|
2712
|
-
datasourceIds: z12.array(z12.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses all selected datasources.")
|
|
2758
|
+
serverKey: z12.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
|
|
2759
|
+
datasourceIds: z12.array(z12.string()).optional().describe("Optional array of datasource IDs to query. If not provided, uses the one configured in runConfig.metricsDataSource or all selected datasources.")
|
|
2713
2760
|
})
|
|
2714
2761
|
}
|
|
2715
2762
|
);
|
|
@@ -2728,11 +2775,15 @@ ${serverKeys.map(
|
|
|
2728
2775
|
).join("\n")}` : "";
|
|
2729
2776
|
return tool12(
|
|
2730
2777
|
async ({
|
|
2731
|
-
serverKey,
|
|
2778
|
+
serverKey: inputServerKey,
|
|
2732
2779
|
tableName,
|
|
2733
|
-
datasourceId
|
|
2780
|
+
datasourceId: inputDatasourceId
|
|
2734
2781
|
}, _exeConfig) => {
|
|
2735
2782
|
try {
|
|
2783
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
2784
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
2785
|
+
const serverKey = metricsDataSource?.serverKey || inputServerKey;
|
|
2786
|
+
const datasourceId = inputDatasourceId || metricsDataSource?.datasourceId;
|
|
2736
2787
|
if (!serverKey) {
|
|
2737
2788
|
return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
|
|
2738
2789
|
}
|
|
@@ -2772,30 +2823,18 @@ ${serverKeys.map(
|
|
|
2772
2823
|
const lines = [];
|
|
2773
2824
|
lines.push(`# ${foundTable.tableName}`);
|
|
2774
2825
|
lines.push("");
|
|
2775
|
-
lines.push(`##
|
|
2826
|
+
lines.push(`## Basic Information`);
|
|
2776
2827
|
lines.push("");
|
|
2777
|
-
lines.push(`-
|
|
2778
|
-
lines.push(`-
|
|
2779
|
-
lines.push(`-
|
|
2780
|
-
if (foundTable.objTypeCode) {
|
|
2781
|
-
lines.push(`- **\u5BF9\u8C61\u7C7B\u578B\u4EE3\u7801**: ${foundTable.objTypeCode}`);
|
|
2782
|
-
}
|
|
2783
|
-
if (foundTable.mainTable) {
|
|
2784
|
-
lines.push(`- **\u4E3B\u8868**: ${foundTable.mainTable}`);
|
|
2785
|
-
}
|
|
2786
|
-
if (foundTable.lineTable) {
|
|
2787
|
-
lines.push(`- **\u884C\u8868**: ${foundTable.lineTable}`);
|
|
2788
|
-
}
|
|
2789
|
-
if (foundDatasourceId) {
|
|
2790
|
-
lines.push(`- **\u6570\u636E\u6E90ID**: ${foundDatasourceId}`);
|
|
2791
|
-
}
|
|
2828
|
+
lines.push(`- **Table Name**: ${foundTable.tableName}`);
|
|
2829
|
+
lines.push(`- **Document Type**: ${foundTable.docType}`);
|
|
2830
|
+
lines.push(`- **Document Type (EN)**: ${foundTable.docTypeEn}`);
|
|
2792
2831
|
lines.push("");
|
|
2793
2832
|
if (foundTable.columns && foundTable.columns.length > 0) {
|
|
2794
2833
|
const validColumns = foundTable.columns.filter((col) => col !== null);
|
|
2795
|
-
lines.push(`##
|
|
2834
|
+
lines.push(`## Column Definitions (${validColumns.length} columns)`);
|
|
2796
2835
|
lines.push("");
|
|
2797
|
-
lines.push("|
|
|
2798
|
-
lines.push("
|
|
2836
|
+
lines.push("| Column Name | Label | Type | Example |");
|
|
2837
|
+
lines.push("|-------------|-------|------|---------|");
|
|
2799
2838
|
for (const col of validColumns) {
|
|
2800
2839
|
const type = col.type || "-";
|
|
2801
2840
|
const example = col.example || "-";
|
|
@@ -2803,14 +2842,6 @@ ${serverKeys.map(
|
|
|
2803
2842
|
}
|
|
2804
2843
|
lines.push("");
|
|
2805
2844
|
}
|
|
2806
|
-
if (foundTable.selectSql) {
|
|
2807
|
-
lines.push(`## SQL \u67E5\u8BE2`);
|
|
2808
|
-
lines.push("");
|
|
2809
|
-
lines.push("```sql");
|
|
2810
|
-
lines.push(foundTable.selectSql);
|
|
2811
|
-
lines.push("```");
|
|
2812
|
-
lines.push("");
|
|
2813
|
-
}
|
|
2814
2845
|
return lines.join("\n");
|
|
2815
2846
|
} catch (error) {
|
|
2816
2847
|
return `Error querying table definition: ${error instanceof Error ? error.message : String(error)}`;
|
|
@@ -2820,9 +2851,9 @@ ${serverKeys.map(
|
|
|
2820
2851
|
name: "query_table_definition",
|
|
2821
2852
|
description: `${QUERY_TABLE_DEFINITION_DESCRIPTION}${availableServersText}`,
|
|
2822
2853
|
schema: z13.object({
|
|
2823
|
-
serverKey: z13.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
|
|
2854
|
+
serverKey: z13.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
|
|
2824
2855
|
tableName: z13.string().describe("The name of the table to get definition for."),
|
|
2825
|
-
datasourceId: z13.string().optional().describe("Optional specific datasource ID to search in. If not provided, searches all selected datasources.")
|
|
2856
|
+
datasourceId: z13.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.")
|
|
2826
2857
|
})
|
|
2827
2858
|
}
|
|
2828
2859
|
);
|
|
@@ -2876,13 +2907,17 @@ ${serverKeys.map(
|
|
|
2876
2907
|
).join("\n")}` : "";
|
|
2877
2908
|
return tool13(
|
|
2878
2909
|
async ({
|
|
2879
|
-
serverKey,
|
|
2880
|
-
datasourceId,
|
|
2910
|
+
serverKey: inputServerKey,
|
|
2911
|
+
datasourceId: inputDatasourceId,
|
|
2881
2912
|
customSql,
|
|
2882
2913
|
params,
|
|
2883
2914
|
limit
|
|
2884
2915
|
}, _exeConfig) => {
|
|
2885
2916
|
try {
|
|
2917
|
+
const runConfig = _exeConfig?.configurable?.runConfig || {};
|
|
2918
|
+
const metricsDataSource = runConfig.metricsDataSource;
|
|
2919
|
+
const serverKey = metricsDataSource?.serverKey || inputServerKey;
|
|
2920
|
+
const datasourceId = metricsDataSource?.datasourceId || inputDatasourceId;
|
|
2886
2921
|
if (!serverKey) {
|
|
2887
2922
|
return "Error: serverKey parameter is required. Available servers: " + serverKeys.join(", ");
|
|
2888
2923
|
}
|
|
@@ -2915,8 +2950,8 @@ ${serverKeys.map(
|
|
|
2915
2950
|
name: "execute_sql_query",
|
|
2916
2951
|
description: `${EXECUTE_SQL_QUERY_DESCRIPTION}${availableServersText}`,
|
|
2917
2952
|
schema: z14.object({
|
|
2918
|
-
serverKey: z14.string().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}`),
|
|
2919
|
-
datasourceId: z14.string().describe("The data source ID to execute SQL against."),
|
|
2953
|
+
serverKey: z14.string().optional().describe(`Target semantic metrics server. Choose from: ${serverKeys.join(", ")}. Optional if configured in runConfig.metricsDataSource`),
|
|
2954
|
+
datasourceId: z14.string().optional().describe("The data source ID to execute SQL against. Optional if configured in runConfig.metricsDataSource"),
|
|
2920
2955
|
customSql: z14.string().describe("Custom SQL query string with named parameters (e.g., :year, :category). Use double quotes for identifiers."),
|
|
2921
2956
|
params: z14.record(z14.union([z14.string(), z14.number(), z14.boolean()])).optional().describe("Optional parameters for the SQL query. Keys should match the :paramName placeholders in customSql."),
|
|
2922
2957
|
limit: z14.number().optional().describe("Maximum number of results to return (default: 1000).")
|
|
@@ -6047,41 +6082,34 @@ storeLatticeManager.registerLattice("default", "userTenantLink", defaultUserTena
|
|
|
6047
6082
|
// src/tool_lattice/skill/load_skills.ts
|
|
6048
6083
|
import z40 from "zod";
|
|
6049
6084
|
import { tool as tool39 } from "langchain";
|
|
6050
|
-
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.`;
|
|
6051
|
-
var createLoadSkillsTool = ({ skills } = {}) => {
|
|
6052
|
-
return tool39(
|
|
6053
|
-
async (_input, _exe_config) => {
|
|
6054
|
-
try {
|
|
6055
|
-
const storeLattice = getStoreLattice("default", "skill");
|
|
6056
|
-
const skillStore = storeLattice.store;
|
|
6057
|
-
const allSkills = await skillStore.getAllSkills();
|
|
6058
|
-
const filteredSkills = skills && skills.length > 0 ? allSkills.filter((skill) => skills.includes(skill.id)) : allSkills;
|
|
6059
|
-
const skillsMeta = filteredSkills.map((skill) => ({
|
|
6060
|
-
id: skill.id,
|
|
6061
|
-
name: skill.name,
|
|
6062
|
-
description: skill.description,
|
|
6063
|
-
license: skill.license,
|
|
6064
|
-
compatibility: skill.compatibility,
|
|
6065
|
-
metadata: skill.metadata,
|
|
6066
|
-
subSkills: skill.subSkills
|
|
6067
|
-
}));
|
|
6068
|
-
return JSON.stringify(skillsMeta, null, 2);
|
|
6069
|
-
} catch (error) {
|
|
6070
|
-
return `Error loading skills: ${error instanceof Error ? error.message : String(error)}`;
|
|
6071
|
-
}
|
|
6072
|
-
},
|
|
6073
|
-
{
|
|
6074
|
-
name: "load_skills",
|
|
6075
|
-
description: LOAD_SKILLS_DESCRIPTION,
|
|
6076
|
-
schema: z40.object({})
|
|
6077
|
-
}
|
|
6078
|
-
);
|
|
6079
|
-
};
|
|
6080
6085
|
|
|
6081
6086
|
// src/tool_lattice/skill/load_skill_content.ts
|
|
6082
6087
|
import z41 from "zod";
|
|
6083
6088
|
import { tool as tool40 } from "langchain";
|
|
6084
|
-
var LOAD_SKILL_CONTENT_DESCRIPTION = `
|
|
6089
|
+
var LOAD_SKILL_CONTENT_DESCRIPTION = `
|
|
6090
|
+
Execute a skill within the main conversation
|
|
6091
|
+
|
|
6092
|
+
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.
|
|
6093
|
+
|
|
6094
|
+
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.
|
|
6095
|
+
Example:
|
|
6096
|
+
User: "run /commit"
|
|
6097
|
+
Assistant: [Calls Skill tool with skill: "commit"]
|
|
6098
|
+
|
|
6099
|
+
How to invoke:
|
|
6100
|
+
- Use this tool with the skill name
|
|
6101
|
+
- Examples:
|
|
6102
|
+
- skill: "pdf" -invoke the pdf skill
|
|
6103
|
+
|
|
6104
|
+
Important:
|
|
6105
|
+
- When a skill is relevant, you must invoke this tool IMMEDIATELY as your first action
|
|
6106
|
+
- NEVER just announce or mention a skill in your text response without actually calling this tool
|
|
6107
|
+
- This is a BLOCKING REQUIREMENT: invoke the relevant Skill tool BEFORE generating any other response about the task
|
|
6108
|
+
- Only use skills listed in "<available_skills>" tag below
|
|
6109
|
+
- Do not invoke a skill that is already running
|
|
6110
|
+
- Do not use this tool for built-in CLI commands (like /help, /clear, etc.)
|
|
6111
|
+
- 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.
|
|
6112
|
+
Do NOT call this tool - just follow the skill instructions directly.`;
|
|
6085
6113
|
var createLoadSkillContentTool = () => {
|
|
6086
6114
|
return tool40(
|
|
6087
6115
|
async (input, _exe_config) => {
|
|
@@ -6139,7 +6167,7 @@ ${content}`;
|
|
|
6139
6167
|
}
|
|
6140
6168
|
},
|
|
6141
6169
|
{
|
|
6142
|
-
name: "
|
|
6170
|
+
name: "skill",
|
|
6143
6171
|
description: LOAD_SKILL_CONTENT_DESCRIPTION,
|
|
6144
6172
|
schema: z41.object({
|
|
6145
6173
|
skill_name: z41.string().describe("The name of the skill to load")
|
|
@@ -6183,25 +6211,16 @@ var createLoadSkillResourceTool = () => {
|
|
|
6183
6211
|
};
|
|
6184
6212
|
|
|
6185
6213
|
// src/middlewares/skillMiddleware.ts
|
|
6186
|
-
var DEFAULT_HEADING = "To better accomplish the user's objective, you can use the following skills to access best practices.";
|
|
6187
|
-
var DEFAULT_EXTRA_NOTE = `
|
|
6188
|
-
you must:
|
|
6189
|
-
1) systematically evaluate every available skill for relevance,
|
|
6190
|
-
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
|
|
6191
|
-
3) implement your solution using the guidance and best practices from those activated skills, explaining trade\u2011offs when they matter.
|
|
6192
|
-
`;
|
|
6193
6214
|
function createSkillMiddleware(params = {}) {
|
|
6194
6215
|
const {
|
|
6195
6216
|
skills = [],
|
|
6196
|
-
readAll = false
|
|
6197
|
-
heading = DEFAULT_HEADING,
|
|
6198
|
-
extraNote = DEFAULT_EXTRA_NOTE
|
|
6217
|
+
readAll = false
|
|
6199
6218
|
} = params;
|
|
6200
6219
|
let latestSkills = [];
|
|
6201
6220
|
return createMiddleware4({
|
|
6202
6221
|
name: "skillMiddleware",
|
|
6203
6222
|
tools: [
|
|
6204
|
-
createLoadSkillsTool({ skills: readAll ?
|
|
6223
|
+
// createLoadSkillsTool({ skills: readAll ? undefined : skills }),
|
|
6205
6224
|
createLoadSkillContentTool(),
|
|
6206
6225
|
createLoadSkillResourceTool()
|
|
6207
6226
|
],
|
|
@@ -6227,11 +6246,11 @@ function createSkillMiddleware(params = {}) {
|
|
|
6227
6246
|
${skill.description}`).join("\n");
|
|
6228
6247
|
const skillsAddendum = `
|
|
6229
6248
|
|
|
6230
|
-
|
|
6249
|
+
<available_skills>
|
|
6231
6250
|
|
|
6232
6251
|
${skillsPrompt}
|
|
6233
6252
|
|
|
6234
|
-
|
|
6253
|
+
</available_skills>`;
|
|
6235
6254
|
const existingSystemPrompt = request.systemPrompt ?? "";
|
|
6236
6255
|
const newSystemPrompt = existingSystemPrompt.length > 0 ? `${existingSystemPrompt}${skillsAddendum}` : skillsAddendum.trimStart();
|
|
6237
6256
|
return handler({
|
|
@@ -7081,15 +7100,19 @@ ${systemPrompt}` : systemPrompt;
|
|
|
7081
7100
|
// src/middlewares/metricsMiddleware.ts
|
|
7082
7101
|
import { createMiddleware as createMiddleware6 } from "langchain";
|
|
7083
7102
|
function createMetricsMiddleware(params) {
|
|
7084
|
-
const { serverKeys, serverDescriptions } = params;
|
|
7085
|
-
|
|
7103
|
+
const { serverKeys, serverDescriptions, connectAll } = params;
|
|
7104
|
+
let effectiveServerKeys = serverKeys;
|
|
7105
|
+
if (connectAll) {
|
|
7106
|
+
effectiveServerKeys = metricsServerManager.getServerKeys().map((s) => s.key);
|
|
7107
|
+
}
|
|
7108
|
+
if (!effectiveServerKeys || effectiveServerKeys.length === 0) {
|
|
7086
7109
|
return createMiddleware6({
|
|
7087
7110
|
name: "metricsMiddleware",
|
|
7088
7111
|
tools: []
|
|
7089
7112
|
});
|
|
7090
7113
|
}
|
|
7091
7114
|
const toolParams = {
|
|
7092
|
-
serverKeys,
|
|
7115
|
+
serverKeys: effectiveServerKeys,
|
|
7093
7116
|
serverDescriptions
|
|
7094
7117
|
};
|
|
7095
7118
|
return createMiddleware6({
|
|
@@ -7147,7 +7170,7 @@ function createCommonMiddlewares(middlewareConfigs, filesystemBackend) {
|
|
|
7147
7170
|
case "metrics":
|
|
7148
7171
|
{
|
|
7149
7172
|
const metricsConfig = config.config;
|
|
7150
|
-
if (metricsConfig.serverKeys && metricsConfig.serverKeys.length > 0) {
|
|
7173
|
+
if (metricsConfig.connectAll || metricsConfig.serverKeys && metricsConfig.serverKeys.length > 0) {
|
|
7151
7174
|
middlewares.push(createMetricsMiddleware(metricsConfig));
|
|
7152
7175
|
}
|
|
7153
7176
|
}
|
|
@@ -7549,6 +7572,11 @@ var AgentWorkerState = Annotation.Root({
|
|
|
7549
7572
|
reducer: (x, y) => y ?? x,
|
|
7550
7573
|
default: () => void 0
|
|
7551
7574
|
}),
|
|
7575
|
+
// RunConfig for passing configuration through the graph
|
|
7576
|
+
runConfig: Annotation({
|
|
7577
|
+
reducer: (x, y) => y ?? x,
|
|
7578
|
+
default: () => void 0
|
|
7579
|
+
}),
|
|
7552
7580
|
// Execution result
|
|
7553
7581
|
result: Annotation({
|
|
7554
7582
|
reducer: (x, y) => y ?? x,
|
|
@@ -7566,12 +7594,13 @@ var AgentWorkerState = Annotation.Root({
|
|
|
7566
7594
|
})
|
|
7567
7595
|
});
|
|
7568
7596
|
async function executeNode(state) {
|
|
7569
|
-
const { assistant_id, thread_id, input, command2 } = state;
|
|
7597
|
+
const { assistant_id, thread_id, input, command2, runConfig } = state;
|
|
7570
7598
|
const callParams = {
|
|
7571
7599
|
assistant_id,
|
|
7572
7600
|
thread_id,
|
|
7573
7601
|
input,
|
|
7574
|
-
command: command2
|
|
7602
|
+
command: command2,
|
|
7603
|
+
runConfig
|
|
7575
7604
|
};
|
|
7576
7605
|
const result = await AgentManager.getInstance().callAgentInQueue(
|
|
7577
7606
|
callParams,
|
|
@@ -7636,7 +7665,7 @@ var DEFAULT_SUBAGENT_PROMPT = "In order to complete the objective that the user
|
|
|
7636
7665
|
var EXCLUDED_STATE_KEYS = ["messages", "todos", "jumpTo"];
|
|
7637
7666
|
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.";
|
|
7638
7667
|
function getTaskToolDescription(subagentDescriptions) {
|
|
7639
|
-
return `
|
|
7668
|
+
return subagentDescriptions.length > 0 ? `
|
|
7640
7669
|
Launch an ephemeral subagent to handle complex, multi-step independent tasks with isolated context windows.
|
|
7641
7670
|
|
|
7642
7671
|
Available agent types and the tools they have access to:
|
|
@@ -7746,7 +7775,7 @@ Since the user is greeting, use the greeting-responder agent to respond with a f
|
|
|
7746
7775
|
</commentary>
|
|
7747
7776
|
assistant: "I'm going to use the Task tool to launch with the greeting-responder agent"
|
|
7748
7777
|
</example>
|
|
7749
|
-
`.trim();
|
|
7778
|
+
`.trim() : "No subagents available, you DON'T NEED TO USE THE TASK TOOL, just use the tools directly.";
|
|
7750
7779
|
}
|
|
7751
7780
|
var TASK_SYSTEM_PROMPT = `## \`task\` (subagent spawner)
|
|
7752
7781
|
|
|
@@ -7833,16 +7862,16 @@ function getSubagents(options) {
|
|
|
7833
7862
|
}
|
|
7834
7863
|
for (const agentParams of subagents) {
|
|
7835
7864
|
subagentDescriptions.push(
|
|
7836
|
-
`- ${agentParams.
|
|
7865
|
+
`- ${agentParams.key}: ${agentParams.name} - ${agentParams.description}`
|
|
7837
7866
|
);
|
|
7838
7867
|
if ("runnable" in agentParams) {
|
|
7839
|
-
agents[agentParams.
|
|
7868
|
+
agents[agentParams.key] = agentParams.runnable;
|
|
7840
7869
|
} else {
|
|
7841
7870
|
const middleware = agentParams.middleware ? [...defaultSubagentMiddleware, ...agentParams.middleware] : [...defaultSubagentMiddleware];
|
|
7842
7871
|
const interruptOn = agentParams.interruptOn || defaultInterruptOn;
|
|
7843
7872
|
if (interruptOn)
|
|
7844
7873
|
middleware.push(humanInTheLoopMiddleware({ interruptOn }));
|
|
7845
|
-
agents[agentParams.
|
|
7874
|
+
agents[agentParams.key] = createAgent2({
|
|
7846
7875
|
model: agentParams.model ?? defaultModel,
|
|
7847
7876
|
systemPrompt: agentParams.systemPrompt,
|
|
7848
7877
|
tools: agentParams.tools ?? defaultTools,
|
|
@@ -7890,7 +7919,12 @@ function createTaskTool(options) {
|
|
|
7890
7919
|
const workerResult = await agentWorkerGraph.invoke({
|
|
7891
7920
|
assistant_id: subagent_type,
|
|
7892
7921
|
thread_id: subagent_thread_id,
|
|
7893
|
-
input: { ...subagentState, message: description }
|
|
7922
|
+
input: { ...subagentState, message: description },
|
|
7923
|
+
runConfig: {
|
|
7924
|
+
...config.configurable?.runConfig,
|
|
7925
|
+
assistant_id: subagent_type,
|
|
7926
|
+
thread_id: subagent_thread_id
|
|
7927
|
+
}
|
|
7894
7928
|
});
|
|
7895
7929
|
const result = workerResult.finalState?.values;
|
|
7896
7930
|
if (!config.toolCall?.id) {
|
|
@@ -9509,6 +9543,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
9509
9543
|
const subagents = params.subAgents.map((sa) => {
|
|
9510
9544
|
if (sa.client) {
|
|
9511
9545
|
return {
|
|
9546
|
+
key: sa.config.key,
|
|
9512
9547
|
name: sa.config.name,
|
|
9513
9548
|
description: sa.config.description,
|
|
9514
9549
|
runnable: sa.client
|
|
@@ -9518,6 +9553,7 @@ var DeepAgentGraphBuilder = class {
|
|
|
9518
9553
|
config: sa.config
|
|
9519
9554
|
});
|
|
9520
9555
|
return {
|
|
9556
|
+
key: sa.config.key,
|
|
9521
9557
|
name: sa.config.name,
|
|
9522
9558
|
description: sa.config.description,
|
|
9523
9559
|
runnable: subagentClient
|