@mastra/server 1.84.0-alpha.5 → 1.84.0-alpha.7
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/{api-schema-manifest-C889XFn5.js → api-schema-manifest-DCzvjHv-.js} +2 -2
- package/dist/{api-schema-manifest-C889XFn5.js.map → api-schema-manifest-DCzvjHv-.js.map} +1 -1
- package/dist/{api-schema-manifest-Cn9tPyZh.cjs → api-schema-manifest-fgF8cSPB.cjs} +2 -2
- package/dist/{api-schema-manifest-Cn9tPyZh.cjs.map → api-schema-manifest-fgF8cSPB.cjs.map} +1 -1
- package/dist/{catalogue-COgS_54R.cjs → catalogue-Cx07-xfS.cjs} +200 -23
- package/dist/catalogue-Cx07-xfS.cjs.map +1 -0
- package/dist/{catalogue-C2Frc4-i.js → catalogue-Nzu-ZF0D.js} +200 -24
- package/dist/catalogue-Nzu-ZF0D.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-server-mcp.md +55 -1
- package/dist/docs/references/reference-observability-tracing-advanced-queries.md +31 -0
- package/dist/docs/references/reference-server-builtin-mcp-tools.md +2 -2
- package/dist/{observability-Z2tDxHS1.js → observability-CCh5zFpG.js} +2 -2
- package/dist/{observability-Z2tDxHS1.js.map → observability-CCh5zFpG.js.map} +1 -1
- package/dist/{observability-BCJsmSH0.cjs → observability-CJpRP8-U.cjs} +2 -2
- package/dist/{observability-BCJsmSH0.cjs.map → observability-CJpRP8-U.cjs.map} +1 -1
- package/dist/{observability-new-endpoints-dr0XcNkP.js → observability-new-endpoints-BUYXgPTJ.js} +65 -9
- package/dist/observability-new-endpoints-BUYXgPTJ.js.map +1 -0
- package/dist/{observability-new-endpoints-C_HEkpZ1.cjs → observability-new-endpoints-JU-OS7aM.cjs} +64 -8
- package/dist/observability-new-endpoints-JU-OS7aM.cjs.map +1 -0
- package/dist/{routes-pkh0aVDt.cjs → routes-DKXsOYPs.cjs} +110 -7
- package/dist/routes-DKXsOYPs.cjs.map +1 -0
- package/dist/{routes-DGoYe50m.js → routes-V4gD8fd0.js} +110 -7
- package/dist/routes-V4gD8fd0.js.map +1 -0
- package/dist/server/handlers/observability-new-endpoints.cjs +1 -1
- package/dist/server/handlers/observability-new-endpoints.d.ts +16 -16
- package/dist/server/handlers/observability-new-endpoints.d.ts.map +1 -1
- package/dist/server/handlers/observability-new-endpoints.js +1 -1
- package/dist/server/handlers/observability-shared.cjs +17 -10
- package/dist/server/handlers/observability-shared.cjs.map +1 -1
- package/dist/server/handlers/observability-shared.d.ts +6 -4
- package/dist/server/handlers/observability-shared.d.ts.map +1 -1
- package/dist/server/handlers/observability-shared.js +17 -10
- package/dist/server/handlers/observability-shared.js.map +1 -1
- package/dist/server/handlers/observability.cjs +2 -2
- package/dist/server/handlers/observability.js +2 -2
- package/dist/server/handlers/system.cjs +2 -2
- package/dist/server/handlers/system.d.ts +8 -4
- package/dist/server/handlers/system.d.ts.map +1 -1
- package/dist/server/handlers/system.js +2 -2
- package/dist/server/handlers.cjs +1 -1
- package/dist/server/handlers.js +1 -1
- package/dist/server/mcp/catalogue.d.ts +15 -1
- package/dist/server/mcp/catalogue.d.ts.map +1 -1
- package/dist/server/mcp/config.d.ts +4 -0
- package/dist/server/mcp/config.d.ts.map +1 -1
- package/dist/server/mcp/route.d.ts +2 -0
- package/dist/server/mcp/route.d.ts.map +1 -1
- package/dist/server/mcp/toolsets/observability-summary.d.ts +15 -0
- package/dist/server/mcp/toolsets/observability-summary.d.ts.map +1 -0
- package/dist/server/mcp/toolsets/observability.d.ts.map +1 -1
- package/dist/server/schemas/index.cjs +1 -1
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/schemas/system.d.ts +8 -4
- package/dist/server/schemas/system.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +2 -2
- package/dist/server/server-adapter/index.js +2 -2
- package/dist/server/server-adapter/routes/conversations.d.ts +3 -3
- package/dist/server/server-adapter/routes/observability.d.ts +8 -8
- package/dist/server/server-adapter/routes/responses.d.ts +11 -11
- package/dist/server/server-adapter/routes/system.d.ts +8 -4
- package/dist/server/server-adapter/routes/system.d.ts.map +1 -1
- package/dist/{server-adapter-CB8qI6YQ.js → server-adapter-Cps8XkTM.js} +2 -2
- package/dist/{server-adapter-CB8qI6YQ.js.map → server-adapter-Cps8XkTM.js.map} +1 -1
- package/dist/{server-adapter-9QWRzNZI.cjs → server-adapter-D6KmPiB1.cjs} +2 -2
- package/dist/{server-adapter-9QWRzNZI.cjs.map → server-adapter-D6KmPiB1.cjs.map} +1 -1
- package/dist/{system-FnU7vyxd.js → system-CKTXaHMZ.js} +5 -3
- package/dist/system-CKTXaHMZ.js.map +1 -0
- package/dist/{system-DdMSBAOY.cjs → system-DKCYwd0y.cjs} +5 -3
- package/dist/system-DKCYwd0y.cjs.map +1 -0
- package/package.json +11 -7
- package/src/server/mcp/apps-module.d.ts +9 -0
- package/dist/catalogue-C2Frc4-i.js.map +0 -1
- package/dist/catalogue-COgS_54R.cjs.map +0 -1
- package/dist/observability-new-endpoints-C_HEkpZ1.cjs.map +0 -1
- package/dist/observability-new-endpoints-dr0XcNkP.js.map +0 -1
- package/dist/routes-DGoYe50m.js.map +0 -1
- package/dist/routes-pkh0aVDt.cjs.map +0 -1
- package/dist/system-DdMSBAOY.cjs.map +0 -1
- package/dist/system-FnU7vyxd.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as schemaToJsonSchema } from "./route-builder-Dz18c3qm.js";
|
|
2
|
-
import { r as SERVER_ROUTES } from "./routes-
|
|
2
|
+
import { r as SERVER_ROUTES } from "./routes-V4gD8fd0.js";
|
|
3
3
|
// src/server/server-adapter/api-schema-manifest.ts
|
|
4
4
|
function convertSchema(schema, io) {
|
|
5
5
|
return schema ? schemaToJsonSchema(schema, io) : void 0;
|
|
@@ -57,4 +57,4 @@ function buildApiSchemaManifest(routes = SERVER_ROUTES) {
|
|
|
57
57
|
}
|
|
58
58
|
export { buildApiSchemaManifest };
|
|
59
59
|
|
|
60
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
60
|
+
//# sourceMappingURL=api-schema-manifest-DCzvjHv-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-schema-manifest-
|
|
1
|
+
{"version":3,"file":"api-schema-manifest-DCzvjHv-.js","names":[],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema'], io: 'input' | 'output'): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema, io) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const alternatives: unknown[] | undefined = responseSchema.anyOf ?? responseSchema.oneOf;\n if (alternatives?.length) {\n const shapes = alternatives.map(schema => inferResponseShape(asJsonSchema(schema)));\n const first = shapes[0]!;\n return shapes.every(\n shape =>\n shape.kind === first.kind &&\n shape.listProperty === first.listProperty &&\n shape.paginationProperty === first.paginationProperty,\n )\n ? first\n : { kind: 'single' };\n }\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\n/** CLI flags cover all request variants; the endpoint still validates the selected variant. */\nexport function getApiSchemaPropertyNames(schema: JSONSchema7 | undefined): string[] {\n if (!schema) return [];\n const names = Object.keys(schema.properties ?? {});\n for (const branch of schema.anyOf ?? schema.oneOf ?? [])\n names.push(...getApiSchemaPropertyNames(asJsonSchema(branch)));\n return [...new Set(names)].sort();\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema, 'output');\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema, 'input'),\n queryParamSchema: convertSchema(route.queryParamSchema, 'input'),\n bodySchema: convertSchema(route.bodySchema, 'input'),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;AA2BA,SAAS,cAAc,QAAmC,IAAiD;CACzG,OAAO,SAAS,mBAAmB,QAA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S;CAC/F,OAAO,EAAE,MAAM,SAAS;AAC1B;AAWA,SAAS,gBAAgB,OAA6B;CACpD,OAAO,MAAM,iBAAiB,UAAU,CAAC,MAAM;AACjD;AAEA,SAAgB,uBAAuB,SAAiC,eAAkC;CACxG,OAAO;EACL,SAAS;EACT,QAAQ,OAAO,OAAO,eAAe,CAAC,CAAC,KAAI,UAAS;GAClD,MAAM,iBAAiB,cAAc,MAAM,gBAAgB,QAAQ;GACnE,OAAO;IACL,QAAQ,MAAM;IACd,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,iBAAiB,OAAO;IAC7D,kBAAkB,cAAc,MAAM,kBAAkB,OAAO;IAC/D,YAAY,cAAc,MAAM,YAAY,OAAO;IACnD;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require("./rolldown-runtime-10nMEhjP.cjs");
|
|
2
2
|
const require_route_builder = require("./route-builder-DjTBxSZN.cjs");
|
|
3
|
-
const require_routes = require("./routes-
|
|
3
|
+
const require_routes = require("./routes-DKXsOYPs.cjs");
|
|
4
4
|
// src/server/server-adapter/api-schema-manifest.ts
|
|
5
5
|
function convertSchema(schema, io) {
|
|
6
6
|
return schema ? require_route_builder.schemaToJsonSchema(schema, io) : void 0;
|
|
@@ -58,4 +58,4 @@ function buildApiSchemaManifest(routes = require_routes.SERVER_ROUTES) {
|
|
|
58
58
|
}
|
|
59
59
|
exports.buildApiSchemaManifest = buildApiSchemaManifest;
|
|
60
60
|
|
|
61
|
-
//# sourceMappingURL=api-schema-manifest-
|
|
61
|
+
//# sourceMappingURL=api-schema-manifest-fgF8cSPB.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-schema-manifest-
|
|
1
|
+
{"version":3,"file":"api-schema-manifest-fgF8cSPB.cjs","names":["schemaToJsonSchema","SERVER_ROUTES"],"sources":["../src/server/server-adapter/api-schema-manifest.ts"],"sourcesContent":["import type { JSONSchema7 } from '@mastra/schema-compat';\nimport { schemaToJsonSchema } from './openapi-utils';\nimport { SERVER_ROUTES } from './routes/index';\nimport type { ServerRoute } from './routes/index';\n\nexport interface ApiSchemaResponseShape {\n kind: 'array' | 'record' | 'object-property' | 'single' | 'unknown';\n listProperty?: string;\n paginationProperty?: string;\n}\n\nexport interface ApiSchemaManifestRoute {\n method: string;\n path: string;\n responseType: string;\n pathParamSchema?: JSONSchema7;\n queryParamSchema?: JSONSchema7;\n bodySchema?: JSONSchema7;\n responseSchema?: JSONSchema7;\n responseShape: ApiSchemaResponseShape;\n}\n\nexport interface ApiSchemaManifest {\n version: 1;\n routes: ApiSchemaManifestRoute[];\n}\n\nfunction convertSchema(schema: ServerRoute['bodySchema'], io: 'input' | 'output'): JSONSchema7 | undefined {\n return schema ? schemaToJsonSchema(schema, io) : undefined;\n}\n\nfunction asJsonSchema(value: unknown): JSONSchema7 | undefined {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as JSONSchema7) : undefined;\n}\n\nfunction schemaType(schema: JSONSchema7 | undefined): JSONSchema7['type'] | undefined {\n const type = schema?.type;\n return Array.isArray(type) ? type.find(Boolean) : type;\n}\n\nfunction inferResponseShape(responseSchema: JSONSchema7 | undefined): ApiSchemaResponseShape {\n if (!responseSchema) return { kind: 'unknown' };\n\n const alternatives: unknown[] | undefined = responseSchema.anyOf ?? responseSchema.oneOf;\n if (alternatives?.length) {\n const shapes = alternatives.map(schema => inferResponseShape(asJsonSchema(schema)));\n const first = shapes[0]!;\n return shapes.every(\n shape =>\n shape.kind === first.kind &&\n shape.listProperty === first.listProperty &&\n shape.paginationProperty === first.paginationProperty,\n )\n ? first\n : { kind: 'single' };\n }\n\n const type = schemaType(responseSchema);\n if (type === 'array') return { kind: 'array' };\n if (type !== 'object') return { kind: 'single' };\n\n const properties =\n responseSchema.properties && !Array.isArray(responseSchema.properties) ? responseSchema.properties : {};\n const propertyNames = Object.keys(properties);\n const paginationProperty = 'page' in properties ? 'page' : 'pagination' in properties ? 'pagination' : undefined;\n const listProperty = Object.entries(properties).find(\n ([, property]) => schemaType(asJsonSchema(property)) === 'array',\n )?.[0];\n\n if (listProperty && (paginationProperty || propertyNames.length <= 2)) {\n return { kind: 'object-property', listProperty, paginationProperty };\n }\n if (responseSchema.additionalProperties && propertyNames.length === 0) return { kind: 'record' };\n return { kind: 'single' };\n}\n\n/** CLI flags cover all request variants; the endpoint still validates the selected variant. */\nexport function getApiSchemaPropertyNames(schema: JSONSchema7 | undefined): string[] {\n if (!schema) return [];\n const names = Object.keys(schema.properties ?? {});\n for (const branch of schema.anyOf ?? schema.oneOf ?? [])\n names.push(...getApiSchemaPropertyNames(asJsonSchema(branch)));\n return [...new Set(names)].sort();\n}\n\nfunction isManifestRoute(route: ServerRoute): boolean {\n return route.responseType === 'json' && !route.deprecated;\n}\n\nexport function buildApiSchemaManifest(routes: readonly ServerRoute[] = SERVER_ROUTES): ApiSchemaManifest {\n return {\n version: 1,\n routes: routes.filter(isManifestRoute).map(route => {\n const responseSchema = convertSchema(route.responseSchema, 'output');\n return {\n method: route.method,\n path: route.path,\n responseType: route.responseType,\n pathParamSchema: convertSchema(route.pathParamSchema, 'input'),\n queryParamSchema: convertSchema(route.queryParamSchema, 'input'),\n bodySchema: convertSchema(route.bodySchema, 'input'),\n responseSchema,\n responseShape: inferResponseShape(responseSchema),\n };\n }),\n };\n}\n"],"mappings":";;;;AA2BA,SAAS,cAAc,QAAmC,IAAiD;CACzG,OAAO,SAASA,sBAAAA,mBAAmB,QAAQ,EAAE,IAAI,KAAA;AACnD;AAEA,SAAS,aAAa,OAAyC;CAC7D,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAK,QAAwB,KAAA;AAChG;AAEA,SAAS,WAAW,QAAkE;CACpF,MAAM,OAAO,QAAQ;CACrB,OAAO,MAAM,QAAQ,IAAI,IAAI,KAAK,KAAK,OAAO,IAAI;AACpD;AAEA,S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,MAAM,gBAAgB,QAAQ;GACnE,OAAO;IACL,QAAQ,MAAM;IACd,MAAM,MAAM;IACZ,cAAc,MAAM;IACpB,iBAAiB,cAAc,MAAM,iBAAiB,OAAO;IAC7D,kBAAkB,cAAc,MAAM,kBAAkB,OAAO;IAC/D,YAAY,cAAc,MAAM,YAAY,OAAO;IACnD;IACA,eAAe,mBAAmB,cAAc;GAClD;EACF,CAAC;CACH;AACF"}
|
|
@@ -4,12 +4,12 @@ require("./constants-1yTmKUZD.cjs");
|
|
|
4
4
|
const require_agents = require("./agents-2HNpgTlJ.cjs");
|
|
5
5
|
const require_tools = require("./tools-C_6yXAww.cjs");
|
|
6
6
|
const require_workflows = require("./workflows-DhmriYvN.cjs");
|
|
7
|
-
const require_server_adapter = require("./server-adapter-
|
|
8
|
-
const require_routes = require("./routes-
|
|
7
|
+
const require_server_adapter = require("./server-adapter-D6KmPiB1.cjs");
|
|
8
|
+
const require_routes = require("./routes-DKXsOYPs.cjs");
|
|
9
9
|
require("./utils-Dn_OA_6N.cjs");
|
|
10
10
|
const require_memory = require("./memory-HiP-vUvS.cjs");
|
|
11
|
-
const require_observability = require("./observability-
|
|
12
|
-
const require_observability_new_endpoints = require("./observability-new-endpoints-
|
|
11
|
+
const require_observability = require("./observability-CJpRP8-U.cjs");
|
|
12
|
+
const require_observability_new_endpoints = require("./observability-new-endpoints-JU-OS7aM.cjs");
|
|
13
13
|
const require_editor_builder = require("./editor-builder-apReuKyj.cjs");
|
|
14
14
|
const require_server_handlers_stored_agents = require("./server/handlers/stored-agents.cjs");
|
|
15
15
|
const require_stored_agents = require("./stored-agents-m0Knvv29.cjs");
|
|
@@ -368,6 +368,134 @@ async function addMemoryTools(kit) {
|
|
|
368
368
|
})
|
|
369
369
|
}, signal));
|
|
370
370
|
}
|
|
371
|
+
// src/server/mcp/toolsets/observability-summary.ts
|
|
372
|
+
const DETAILS = "Call get_trace with a traceId for its span tree, and get_span for a span’s full input and output.";
|
|
373
|
+
const isRow = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
374
|
+
const rowsOf = (output, key) => Array.isArray(output[key]) ? output[key].filter(isRow) : [];
|
|
375
|
+
const text = (value, max) => {
|
|
376
|
+
if (typeof value !== "string" || !value) return void 0;
|
|
377
|
+
const line = value.replace(/\s+/g, " ").trim();
|
|
378
|
+
return line.length > max ? `${line.slice(0, max)}…` : line;
|
|
379
|
+
};
|
|
380
|
+
function duration(row) {
|
|
381
|
+
if (typeof row.durationMs === "number") return `${row.durationMs}ms`;
|
|
382
|
+
const start = Date.parse(String(row.startedAt));
|
|
383
|
+
const end = Date.parse(String(row.endedAt));
|
|
384
|
+
return Number.isNaN(start) || Number.isNaN(end) ? void 0 : `${end - start}ms`;
|
|
385
|
+
}
|
|
386
|
+
function errorOf(row) {
|
|
387
|
+
const error = row.errorPreview ?? (isRow(row.error) ? row.error.message : row.error);
|
|
388
|
+
const message = text(error, 200);
|
|
389
|
+
return message && `error: ${message}`;
|
|
390
|
+
}
|
|
391
|
+
const cells = (...values) => values.filter((value) => typeof value === "string" && value !== "").join(" | ");
|
|
392
|
+
const entity = (row) => cells(row.entityType ?? row.spanType, text(row.entityName ?? row.name, 80));
|
|
393
|
+
const status = (row) => typeof row.status === "string" ? row.status : row.error ? "error" : void 0;
|
|
394
|
+
/** Paging the model can act on: the clip note from `fitRows`, a keyset cursor, or offset pages. */
|
|
395
|
+
function paging(output) {
|
|
396
|
+
const lines = [];
|
|
397
|
+
if (typeof output.truncated === "string") lines.push(output.truncated);
|
|
398
|
+
const page = isRow(output.page) ? output.page : void 0;
|
|
399
|
+
if (typeof page?.next === "string") lines.push(`More rows: call again with page.after = "${page.next}".`);
|
|
400
|
+
const pagination = isRow(output.pagination) ? output.pagination : void 0;
|
|
401
|
+
if (pagination?.hasMore) lines.push(`${String(pagination.total)} rows in all. More rows: call again with page = ${Number(pagination.page) + 1}.`);
|
|
402
|
+
return lines;
|
|
403
|
+
}
|
|
404
|
+
function summary(heading, lines, output, footer = DETAILS) {
|
|
405
|
+
return [
|
|
406
|
+
heading,
|
|
407
|
+
...lines,
|
|
408
|
+
...paging(output),
|
|
409
|
+
footer
|
|
410
|
+
].join("\n");
|
|
411
|
+
}
|
|
412
|
+
/** Trace rows: `query_traces` returns them under `traces`, `list_traces` (root spans) under `spans`. */
|
|
413
|
+
function summarizeTraces(key) {
|
|
414
|
+
return (output) => {
|
|
415
|
+
if (Array.isArray(output.groups)) {
|
|
416
|
+
const groups = rowsOf(output, "groups");
|
|
417
|
+
return summary(`${groups.length} threads matched (threadId):`, groups.map((group) => `- ${cells(group.threadId)}`), output, "Call query_traces with a threadId filter for the traces in a thread.");
|
|
418
|
+
}
|
|
419
|
+
const rows = rowsOf(output, key);
|
|
420
|
+
return summary(`${rows.length} traces, shown to the user in the observability explorer (traceId | entity | status | started | duration):`, rows.map((row) => `- ${cells(row.traceId, entity(row), status(row), row.startedAt, duration(row), errorOf(row), text(row.inputPreview, 80) && `input: ${text(row.inputPreview, 80)}`)}`), output);
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
/** A log's `data` as one line of JSON, without stack traces, which `list_logs` still returns in full. */
|
|
424
|
+
function dataOf(row) {
|
|
425
|
+
if (!isRow(row.data) || !Object.keys(row.data).length) return void 0;
|
|
426
|
+
const line = text(JSON.stringify(row.data, (key, value) => key === "stack" ? void 0 : value), 160);
|
|
427
|
+
return line && `data: ${line}`;
|
|
428
|
+
}
|
|
429
|
+
function summarizeLogs(output) {
|
|
430
|
+
const rows = rowsOf(output, "logs");
|
|
431
|
+
return summary(`${rows.length} logs, shown to the user in the observability explorer (time | level | entity | message | data | trace and span):`, rows.map((row) => {
|
|
432
|
+
const where = typeof row.traceId === "string" ? `trace ${row.traceId}${row.spanId ? ` span ${String(row.spanId)}` : ""}` : void 0;
|
|
433
|
+
return `- ${cells(row.timestamp, row.level, row.entityName ? entity(row) : void 0, text(row.message, 200), dataOf(row), where)}`;
|
|
434
|
+
}), output);
|
|
435
|
+
}
|
|
436
|
+
/** A light trace as an indented span tree, children under their parent in start order. */
|
|
437
|
+
function summarizeTrace(output) {
|
|
438
|
+
const spans = rowsOf(output, "spans");
|
|
439
|
+
const ids = new Set(spans.map((span) => span.spanId));
|
|
440
|
+
const children = /* @__PURE__ */ new Map();
|
|
441
|
+
for (const span of spans) {
|
|
442
|
+
const parent = ids.has(span.parentSpanId) ? span.parentSpanId : null;
|
|
443
|
+
children.set(parent, [...children.get(parent) ?? [], span]);
|
|
444
|
+
}
|
|
445
|
+
const lines = [];
|
|
446
|
+
const walk = (parent, depth) => {
|
|
447
|
+
for (const span of children.get(parent) ?? []) {
|
|
448
|
+
lines.push(`${" ".repeat(depth)}- ${cells(span.spanId, cells(span.spanType, text(span.name, 80)), status(span), duration(span), errorOf(span))}`);
|
|
449
|
+
walk(span.spanId, depth + 1);
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
walk(null, 0);
|
|
453
|
+
const count = typeof output.spanCount === "number" ? output.spanCount : spans.length;
|
|
454
|
+
const rest = typeof output.nextOffset === "number" ? [`More spans: call get_trace again with offset = ${output.nextOffset}.`] : [];
|
|
455
|
+
return [
|
|
456
|
+
`Trace ${String(output.traceId)}: ${count} spans, shown to the user in Studio's trace viewer (spanId | type and name | status | duration):`,
|
|
457
|
+
...lines,
|
|
458
|
+
...rest,
|
|
459
|
+
"Call get_span with the traceId and a spanId for its full input, output, and attributes."
|
|
460
|
+
].join("\n");
|
|
461
|
+
}
|
|
462
|
+
/** Three decimals, but small nonzero values (a $0.0004 cost) keep three significant digits instead of reading 0. */
|
|
463
|
+
function num(value) {
|
|
464
|
+
if (typeof value !== "number") return void 0;
|
|
465
|
+
if (value === 0 || Math.abs(value) >= 1) return String(Math.round(value * 1e3) / 1e3);
|
|
466
|
+
return String(Number(value.toPrecision(3)));
|
|
467
|
+
}
|
|
468
|
+
/** A series as its range and endpoints: the app charts every point. */
|
|
469
|
+
function seriesLine(label, series) {
|
|
470
|
+
const points = rowsOf(series, "points").filter((point) => typeof point.value === "number");
|
|
471
|
+
if (!points.length) return `- ${label}: no data`;
|
|
472
|
+
const values = points.map((point) => point.value);
|
|
473
|
+
const first = points[0];
|
|
474
|
+
const last = points[points.length - 1];
|
|
475
|
+
return `- ${label}: ${points.length} points from ${String(first.timestamp)} (${num(first.value)}) to ${String(last.timestamp)} (${num(last.value)}), min ${num(Math.min(...values))}, max ${num(Math.max(...values))}`;
|
|
476
|
+
}
|
|
477
|
+
/** `analyze_metrics` results, by op: an aggregate, breakdown groups, or time series / percentile series. */
|
|
478
|
+
function summarizeMetrics(output) {
|
|
479
|
+
const footer = "The user sees these metrics charted in the observability explorer.";
|
|
480
|
+
if (Array.isArray(output.groups)) {
|
|
481
|
+
const groups = rowsOf(output, "groups");
|
|
482
|
+
return summary(`${groups.length} groups (dimensions | value | cost):`, groups.map((group) => {
|
|
483
|
+
const dimensions = isRow(group.dimensions) ? Object.entries(group.dimensions).map(([key, value]) => `${key}=${String(value)}`).join(", ") : void 0;
|
|
484
|
+
return `- ${cells(dimensions, num(group.value), num(group.estimatedCost) && `${num(group.estimatedCost)} ${group.costUnit ?? ""}`.trim())}`;
|
|
485
|
+
}), output, footer);
|
|
486
|
+
}
|
|
487
|
+
if (Array.isArray(output.series)) {
|
|
488
|
+
const series = rowsOf(output, "series");
|
|
489
|
+
return summary(`${series.length} series:`, series.map((line) => seriesLine(typeof line.name === "string" ? line.name : `p${num(line.percentile)}`, line)), output, footer);
|
|
490
|
+
}
|
|
491
|
+
return [
|
|
492
|
+
`Value: ${num(output.value) ?? "no data"}`,
|
|
493
|
+
...output.previousValue != null ? [`Previous period: ${num(output.previousValue)}`] : [],
|
|
494
|
+
...output.changePercent != null ? [`Change: ${num(output.changePercent)}%`] : [],
|
|
495
|
+
...output.estimatedCost != null ? [`Estimated cost: ${num(output.estimatedCost)} ${output.costUnit ?? ""}`.trim()] : [],
|
|
496
|
+
footer
|
|
497
|
+
].join("\n");
|
|
498
|
+
}
|
|
371
499
|
// src/server/mcp/toolsets/observability.ts
|
|
372
500
|
const COMBINATORS = [
|
|
373
501
|
"anyOf",
|
|
@@ -499,16 +627,27 @@ function analyzeSchema(routes) {
|
|
|
499
627
|
}
|
|
500
628
|
/** Observability (traces, spans, logs) and observability analytics (metrics, scores, feedback). */
|
|
501
629
|
function addObservabilityTools(kit) {
|
|
502
|
-
const { call, addOperation, addCombined, config } = kit;
|
|
630
|
+
const { call, addOperation, addCombined, config, offered } = kit;
|
|
631
|
+
const metricRoutes = {
|
|
632
|
+
aggregate: require_observability_new_endpoints.GET_METRIC_AGGREGATE,
|
|
633
|
+
breakdown: require_observability_new_endpoints.GET_METRIC_BREAKDOWN,
|
|
634
|
+
timeseries: require_observability_new_endpoints.GET_METRIC_TIME_SERIES,
|
|
635
|
+
percentiles: require_observability_new_endpoints.GET_METRIC_PERCENTILES
|
|
636
|
+
};
|
|
637
|
+
const explorer = kit.apps.observabilityExplorer && offered(require_observability_new_endpoints.GET_CAPABILITIES) ? kit.apps.observabilityExplorer : void 0;
|
|
638
|
+
const opensIn = (app, summary) => app ? {
|
|
639
|
+
meta: { ui: { resourceUri: app } },
|
|
640
|
+
summary
|
|
641
|
+
} : void 0;
|
|
503
642
|
if (config.toolsets.has("observability")) {
|
|
504
|
-
const bodyTool = (route, rows, schema = route.bodySchema) => addOperation(route, hoistRepeated(asObjectSchema(toJSONSchema(schema))), async (args, signal) => {
|
|
643
|
+
const bodyTool = (route, rows, schema = route.bodySchema, options) => addOperation(route, hoistRepeated(asObjectSchema(toJSONSchema(schema))), async (args, signal) => {
|
|
505
644
|
const result = await call(route, { body: args }, signal);
|
|
506
645
|
return rows ? fitRows(result, rows, PAGE_LIMIT_HINT, {
|
|
507
646
|
cursors: CURSORS,
|
|
508
647
|
detail: rows === "traces" || rows === "spans" ? "get_span" : void 0
|
|
509
648
|
}) : result;
|
|
510
|
-
});
|
|
511
|
-
bodyTool(require_observability_new_endpoints.QUERY_TRACES, "traces");
|
|
649
|
+
}, options);
|
|
650
|
+
bodyTool(require_observability_new_endpoints.QUERY_TRACES, "traces", void 0, opensIn(explorer, summarizeTraces("traces")));
|
|
512
651
|
bodyTool(require_observability_new_endpoints.AGGREGATE_TRACES);
|
|
513
652
|
bodyTool(require_observability_new_endpoints.QUERY_SPANS, "spans");
|
|
514
653
|
bodyTool(require_observability_new_endpoints.AGGREGATE_SPANS);
|
|
@@ -540,7 +679,7 @@ function addObservabilityTools(kit) {
|
|
|
540
679
|
...result,
|
|
541
680
|
nextOffset: offset + kept
|
|
542
681
|
} : result;
|
|
543
|
-
});
|
|
682
|
+
}, opensIn(kit.apps.traceViewer, summarizeTrace));
|
|
544
683
|
addOperation(require_observability.GET_SPAN_ROUTE, object({
|
|
545
684
|
traceId,
|
|
546
685
|
spanId: str("Span id.")
|
|
@@ -552,23 +691,50 @@ function addObservabilityTools(kit) {
|
|
|
552
691
|
addOperation(require_observability.LIST_TRACES_ROUTE, hoistRepeated(listQuerySchema(require_observability.LIST_TRACES_ROUTE)), async (args, signal) => fitRows(await call(require_observability.LIST_TRACES_ROUTE, { query: args }, signal), "spans", PER_PAGE_HINT, {
|
|
553
692
|
cursors: CURSORS,
|
|
554
693
|
detail: "get_span"
|
|
555
|
-
}));
|
|
556
|
-
|
|
694
|
+
}), opensIn(explorer, summarizeTraces("spans")));
|
|
695
|
+
if (explorer) {
|
|
696
|
+
const appOnly = { meta: { ui: {
|
|
697
|
+
resourceUri: explorer,
|
|
698
|
+
visibility: ["app"]
|
|
699
|
+
} } };
|
|
700
|
+
addOperation(require_observability_new_endpoints.GET_CAPABILITIES, object({}), async (_args, signal) => ({
|
|
701
|
+
...await call(require_observability_new_endpoints.GET_CAPABILITIES, {}, signal),
|
|
702
|
+
tools: {
|
|
703
|
+
logs: offered(require_observability_new_endpoints.LIST_LOGS),
|
|
704
|
+
metrics: Object.values(metricRoutes).every(offered)
|
|
705
|
+
}
|
|
706
|
+
}), appOnly);
|
|
707
|
+
const values = {
|
|
708
|
+
entityTypes: require_observability_new_endpoints.GET_ENTITY_TYPES,
|
|
709
|
+
entityNames: require_observability_new_endpoints.GET_ENTITY_NAMES,
|
|
710
|
+
serviceNames: require_observability_new_endpoints.GET_SERVICE_NAMES,
|
|
711
|
+
environments: require_observability_new_endpoints.GET_ENVIRONMENTS,
|
|
712
|
+
tags: require_observability_new_endpoints.GET_TAGS
|
|
713
|
+
};
|
|
714
|
+
addCombined(Object.values(values), object({
|
|
715
|
+
kind: {
|
|
716
|
+
type: "string",
|
|
717
|
+
enum: Object.keys(values),
|
|
718
|
+
description: "Which values to list."
|
|
719
|
+
},
|
|
720
|
+
...listQuerySchema(require_observability_new_endpoints.GET_ENTITY_NAMES).properties,
|
|
721
|
+
...listQuerySchema(require_observability_new_endpoints.GET_TAGS).properties
|
|
722
|
+
}, ["kind"]), (args, signal) => {
|
|
723
|
+
const { kind, ...query } = args;
|
|
724
|
+
return call(values[kind], { query }, signal);
|
|
725
|
+
}, appOnly);
|
|
726
|
+
}
|
|
727
|
+
addOperation(require_observability_new_endpoints.LIST_LOGS, hoistRepeated(listQuerySchema(require_observability_new_endpoints.LIST_LOGS)), async (args, signal) => fitRows(await call(require_observability_new_endpoints.LIST_LOGS, { query: args }, signal), "logs", PER_PAGE_HINT, { cursors: CURSORS }), opensIn(explorer, summarizeLogs));
|
|
557
728
|
}
|
|
558
729
|
if (config.toolsets.has("observability_analytics")) {
|
|
559
730
|
for (const [route, key] of [[require_observability_new_endpoints.LIST_SCORES, "scores"], [require_observability_new_endpoints.LIST_FEEDBACK, "feedback"]]) addOperation(route, hoistRepeated(listQuerySchema(route)), async (args, signal) => fitRows(await call(route, { query: args }, signal), key, PER_PAGE_HINT, { cursors: CURSORS }));
|
|
560
|
-
const analyze = (routes) => addCombined(Object.values(routes), hoistRepeated(analyzeSchema(routes)), (args, signal) => {
|
|
731
|
+
const analyze = (routes, options) => addCombined(Object.values(routes), hoistRepeated(analyzeSchema(routes)), (args, signal) => {
|
|
561
732
|
const { op, ...body } = args;
|
|
562
733
|
const route = typeof op === "string" && Object.hasOwn(routes, op) ? routes[op] : void 0;
|
|
563
734
|
if (!route) throw toolError(400, `Unknown op "${String(op)}". Use one of: ${OPS.join(", ")}.`);
|
|
564
735
|
return call(route, { body }, signal);
|
|
565
|
-
});
|
|
566
|
-
analyze(
|
|
567
|
-
aggregate: require_observability_new_endpoints.GET_METRIC_AGGREGATE,
|
|
568
|
-
breakdown: require_observability_new_endpoints.GET_METRIC_BREAKDOWN,
|
|
569
|
-
timeseries: require_observability_new_endpoints.GET_METRIC_TIME_SERIES,
|
|
570
|
-
percentiles: require_observability_new_endpoints.GET_METRIC_PERCENTILES
|
|
571
|
-
});
|
|
736
|
+
}, options);
|
|
737
|
+
analyze(metricRoutes, opensIn(explorer, summarizeMetrics));
|
|
572
738
|
analyze({
|
|
573
739
|
aggregate: require_observability_new_endpoints.GET_SCORE_AGGREGATE,
|
|
574
740
|
breakdown: require_observability_new_endpoints.GET_SCORE_BREAKDOWN,
|
|
@@ -916,6 +1082,11 @@ function addStoredAgentTools(kit) {
|
|
|
916
1082
|
});
|
|
917
1083
|
}
|
|
918
1084
|
// src/server/mcp/catalogue.ts
|
|
1085
|
+
const modelSummaries = /* @__PURE__ */ new WeakMap();
|
|
1086
|
+
/** The summary a tool sends the model when its result is rendered in an MCP App, if it has one. */
|
|
1087
|
+
function modelSummaryOf(tool) {
|
|
1088
|
+
return tool ? modelSummaries.get(tool) : void 0;
|
|
1089
|
+
}
|
|
919
1090
|
const MAX_TOOL_NAME_LENGTH = 64;
|
|
920
1091
|
/** A backing route's permission is a read when every permission it accepts has the `read` action. */
|
|
921
1092
|
function isReadRoute(route) {
|
|
@@ -1098,9 +1269,13 @@ async function buildBuiltinMCPTools(ctx, config) {
|
|
|
1098
1269
|
description,
|
|
1099
1270
|
inputSchema,
|
|
1100
1271
|
outputSchema: options.outputSchema,
|
|
1101
|
-
mcp: {
|
|
1272
|
+
mcp: {
|
|
1273
|
+
annotations: options.annotations ?? annotationsFor(route),
|
|
1274
|
+
...options.meta ? { _meta: options.meta } : {}
|
|
1275
|
+
},
|
|
1102
1276
|
execute: async (args, context) => execute(args ?? {}, context?.abortSignal)
|
|
1103
1277
|
});
|
|
1278
|
+
if (options.summary) modelSummaries.set(tools[name], options.summary);
|
|
1104
1279
|
};
|
|
1105
1280
|
const addOperation = (route, inputSchema, execute, options) => {
|
|
1106
1281
|
if (offered(route)) add(route.mcp.name, route, route.mcp.description, inputSchema, execute, options);
|
|
@@ -1346,13 +1521,14 @@ async function buildBuiltinMCPTools(ctx, config) {
|
|
|
1346
1521
|
requestContext,
|
|
1347
1522
|
config,
|
|
1348
1523
|
capabilities,
|
|
1524
|
+
apps: ctx.apps ?? {},
|
|
1349
1525
|
offered,
|
|
1350
1526
|
permitted,
|
|
1351
1527
|
call,
|
|
1352
1528
|
add,
|
|
1353
1529
|
addOperation,
|
|
1354
|
-
addCombined: (routes, inputSchema, execute) => {
|
|
1355
|
-
if (routes.every(offered)) add(routes[0].mcp.name, routes[0], routes[0].mcp.description, inputSchema, execute);
|
|
1530
|
+
addCombined: (routes, inputSchema, execute, options) => {
|
|
1531
|
+
if (routes.every(offered)) add(routes[0].mcp.name, routes[0], routes[0].mcp.description, inputSchema, execute, options);
|
|
1356
1532
|
},
|
|
1357
1533
|
visibleAgentIds: async () => {
|
|
1358
1534
|
const agents = await listVisibleAgents();
|
|
@@ -1367,5 +1543,6 @@ async function buildBuiltinMCPTools(ctx, config) {
|
|
|
1367
1543
|
return tools;
|
|
1368
1544
|
}
|
|
1369
1545
|
exports.buildBuiltinMCPTools = buildBuiltinMCPTools;
|
|
1546
|
+
exports.modelSummaryOf = modelSummaryOf;
|
|
1370
1547
|
|
|
1371
|
-
//# sourceMappingURL=catalogue-
|
|
1548
|
+
//# sourceMappingURL=catalogue-Cx07-xfS.cjs.map
|