@agent-inspect/mcp-server 6.20.0 → 6.22.0

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/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { runReadOnlyMcpServer } from './chunk-4FSMUSWK.mjs';
1
+ import { runReadOnlyMcpServer } from './chunk-URVZD6JW.mjs';
2
2
  import { readFileSync } from 'fs';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
package/dist/index.cjs CHANGED
@@ -482,16 +482,16 @@ function pickRunMetadata(attributes) {
482
482
  return Object.keys(metadata).length > 0 ? metadata : void 0;
483
483
  }
484
484
  function resolveStepId(event) {
485
- const attrs = event.attributes;
486
- if (attrs && typeof attrs.stepId === "string" && attrs.stepId.trim() !== "") {
487
- return attrs.stepId;
485
+ const attrs2 = event.attributes;
486
+ if (attrs2 && typeof attrs2.stepId === "string" && attrs2.stepId.trim() !== "") {
487
+ return attrs2.stepId;
488
488
  }
489
489
  return event.eventId;
490
490
  }
491
491
  function resolveStepType(event) {
492
- const attrs = event.attributes;
493
- if (attrs && typeof attrs.stepType === "string") {
494
- const t = attrs.stepType;
492
+ const attrs2 = event.attributes;
493
+ if (attrs2 && typeof attrs2.stepType === "string") {
494
+ const t = attrs2.stepType;
495
495
  if (t === "run" || t === "llm" || t === "tool" || t === "decision" || t === "logic" || t === "state" || t === "custom") {
496
496
  return t;
497
497
  }
@@ -572,26 +572,26 @@ function fromLegacyStepCompleted(event) {
572
572
  return out;
573
573
  }
574
574
  function fromLegacyOutcomeObserved(event) {
575
- const attrs = event.attributes ?? {};
576
- const observedAtRaw = attrs.observedAt;
575
+ const attrs2 = event.attributes ?? {};
576
+ const observedAtRaw = attrs2.observedAt;
577
577
  const observedAt = typeof observedAtRaw === "string" ? Date.parse(observedAtRaw) : typeof observedAtRaw === "number" && Number.isFinite(observedAtRaw) ? observedAtRaw : resolveTimes(event).timestamp;
578
- const status = attrs.outcomeStatus;
578
+ const status = attrs2.outcomeStatus;
579
579
  const out = {
580
580
  schemaVersion: "0.1",
581
581
  event: "outcome_observed",
582
582
  timestamp: observedAt,
583
583
  runId: event.runId,
584
- outcomeId: typeof attrs.outcomeId === "string" ? attrs.outcomeId : event.eventId,
584
+ outcomeId: typeof attrs2.outcomeId === "string" ? attrs2.outcomeId : event.eventId,
585
585
  name: event.name,
586
- expectation: typeof attrs.expectation === "string" ? attrs.expectation : event.name,
586
+ expectation: typeof attrs2.expectation === "string" ? attrs2.expectation : event.name,
587
587
  status: status === "passed" || status === "failed" || status === "unknown" || status === "skipped" ? status : "unknown",
588
588
  observedAt
589
589
  };
590
590
  if (event.parentId !== void 0) out.parentId = event.parentId;
591
- if (typeof attrs.method === "string") out.method = attrs.method;
592
- if (attrs.actual !== void 0) out.actual = attrs.actual;
591
+ if (typeof attrs2.method === "string") out.method = attrs2.method;
592
+ if (attrs2.actual !== void 0) out.actual = attrs2.actual;
593
593
  if (event.outputSummary !== void 0) out.actual = event.outputSummary;
594
- if (attrs.evidence !== void 0) out.evidence = attrs.evidence;
594
+ if (attrs2.evidence !== void 0) out.evidence = attrs2.evidence;
595
595
  return out;
596
596
  }
597
597
  function fromNativeOutcome(event) {
@@ -976,6 +976,17 @@ var OBSERVED_OUTCOME_STATUSES = [
976
976
  "unknown",
977
977
  "skipped"
978
978
  ];
979
+ var OBSERVED_OUTCOME_METHODS = [
980
+ "dom",
981
+ "accessibility",
982
+ "snapshot",
983
+ "network",
984
+ "storage",
985
+ "filesystem",
986
+ "database",
987
+ "queue",
988
+ "custom"
989
+ ];
979
990
  var OUTCOME_LEGACY_EVENT = "outcome_observed";
980
991
 
981
992
  // packages/core/src/outcomes/validate.ts
@@ -1988,6 +1999,63 @@ async function loadTraceMetadataList(_traceDir, fileNames, getPath) {
1988
1999
  return metas;
1989
2000
  }
1990
2001
 
2002
+ // packages/core/src/sessions/metadata.ts
2003
+ function isNonEmptyString3(value) {
2004
+ return typeof value === "string" && value.trim() !== "";
2005
+ }
2006
+ function finitePositiveInt(value) {
2007
+ if (typeof value !== "number" || !Number.isFinite(value) || value < 1) {
2008
+ return void 0;
2009
+ }
2010
+ return Math.trunc(value);
2011
+ }
2012
+ function extractSessionWorkflowMetadata(record) {
2013
+ if (!record) return void 0;
2014
+ const out = {};
2015
+ let found = false;
2016
+ const assignString = (key, value) => {
2017
+ if (isNonEmptyString3(value)) {
2018
+ out[key] = value.trim();
2019
+ found = true;
2020
+ }
2021
+ };
2022
+ assignString("sessionId", record.sessionId);
2023
+ assignString("conversationId", record.conversationId);
2024
+ assignString("groupId", record.groupId);
2025
+ assignString("parentGroupId", record.parentGroupId);
2026
+ assignString("retryOf", record.retryOf);
2027
+ assignString("retryReason", record.retryReason);
2028
+ assignString("handoffFrom", record.handoffFrom);
2029
+ assignString("handoffTo", record.handoffTo);
2030
+ assignString("subAgentId", record.subAgentId);
2031
+ assignString("subAgentName", record.subAgentName);
2032
+ assignString("jobId", record.jobId);
2033
+ assignString("queueName", record.queueName);
2034
+ assignString("workflowName", record.workflowName);
2035
+ assignString("workflowStep", record.workflowStep);
2036
+ assignString("toolCallId", record.toolCallId);
2037
+ assignString("mcpToolCallId", record.mcpToolCallId);
2038
+ assignString("linkedStepId", record.linkedStepId);
2039
+ assignString("operationId", record.operationId);
2040
+ assignString("attemptId", record.attemptId);
2041
+ assignString("fallbackOf", record.fallbackOf);
2042
+ assignString("idempotencyKey", record.idempotencyKey);
2043
+ assignString("correlationId", record.correlationId);
2044
+ assignString("requestId", record.requestId);
2045
+ assignString("decisionId", record.decisionId);
2046
+ const attempt = finitePositiveInt(record.attempt);
2047
+ if (attempt !== void 0) {
2048
+ out.attempt = attempt;
2049
+ found = true;
2050
+ }
2051
+ const attemptNumber = finitePositiveInt(record.attemptNumber);
2052
+ if (attemptNumber !== void 0) {
2053
+ out.attemptNumber = attemptNumber;
2054
+ found = true;
2055
+ }
2056
+ return found ? out : void 0;
2057
+ }
2058
+
1991
2059
  // packages/core/src/bundle/safety-status.ts
1992
2060
  function aggregateBundleSafeStatus(statuses) {
1993
2061
  if (statuses.length === 0) return "UNKNOWN";
@@ -2200,17 +2268,17 @@ function stableJson(value, pretty) {
2200
2268
  const sorted = sortKeysDeep(value);
2201
2269
  return pretty === true ? JSON.stringify(sorted, null, 2) : JSON.stringify(sorted);
2202
2270
  }
2203
- function compactAttributes(attrs, options) {
2204
- if (attrs === void 0) return {};
2271
+ function compactAttributes(attrs2, options) {
2272
+ if (attrs2 === void 0) return {};
2205
2273
  const maxLen = options?.maxLength ?? 500;
2206
2274
  const redacted = options?.redacted ?? true;
2207
2275
  const out = {};
2208
- for (const key of Object.keys(attrs).sort()) {
2276
+ for (const key of Object.keys(attrs2).sort()) {
2209
2277
  if (redacted && shouldRedactKey(key)) {
2210
2278
  out[key] = "[REDACTED]";
2211
2279
  continue;
2212
2280
  }
2213
- const v = attrs[key];
2281
+ const v = attrs2[key];
2214
2282
  out[key] = compactValue(v, maxLen, redacted);
2215
2283
  }
2216
2284
  return out;
@@ -3021,10 +3089,10 @@ function projectLogicalEvents(events) {
3021
3089
  };
3022
3090
  }
3023
3091
  function resolveCanonicalToolName(event) {
3024
- const attrs = event.attributes;
3025
- const direct = pickString(attrs, ["toolName", "tool"]);
3092
+ const attrs2 = event.attributes;
3093
+ const direct = pickString(attrs2, ["toolName", "tool"]);
3026
3094
  if (direct) return direct;
3027
- const metadata = attrs?.metadata;
3095
+ const metadata = attrs2?.metadata;
3028
3096
  if (isRecord6(metadata)) {
3029
3097
  const nested = pickString(metadata, ["toolName", "tool"]);
3030
3098
  if (nested) return nested;
@@ -3066,10 +3134,10 @@ function pickNumber(record, keys) {
3066
3134
  return void 0;
3067
3135
  }
3068
3136
  function eventMetadata(event) {
3069
- const attrs = isRecord7(event.attributes) ? event.attributes : void 0;
3070
- const nested = attrs !== void 0 && isRecord7(attrs.metadata) ? attrs.metadata : void 0;
3137
+ const attrs2 = isRecord7(event.attributes) ? event.attributes : void 0;
3138
+ const nested = attrs2 !== void 0 && isRecord7(attrs2.metadata) ? attrs2.metadata : void 0;
3071
3139
  return {
3072
- ...attrs ?? {},
3140
+ ...attrs2 ?? {},
3073
3141
  ...nested ?? {}
3074
3142
  };
3075
3143
  }
@@ -3362,6 +3430,151 @@ function deriveFailureFacts(logicalEvents) {
3362
3430
  };
3363
3431
  }
3364
3432
 
3433
+ // packages/core/src/checks/relationship-facts.ts
3434
+ function attrs(event) {
3435
+ return event.attributes && typeof event.attributes === "object" ? event.attributes : {};
3436
+ }
3437
+ function stringAttr(record, key) {
3438
+ const value = record[key];
3439
+ return typeof value === "string" && value.trim() !== "" ? value.trim() : void 0;
3440
+ }
3441
+ function deriveRelationshipFacts(events) {
3442
+ const relationships = [];
3443
+ const diagnostics = [];
3444
+ const byId = new Map(events.map((event) => [event.eventId, event]));
3445
+ const seen = /* @__PURE__ */ new Set();
3446
+ const push = (edge) => {
3447
+ const key = `${edge.type}:${edge.fromEventId}:${edge.toEventId ?? ""}:${edge.externalRef ?? ""}`;
3448
+ if (seen.has(key)) return;
3449
+ seen.add(key);
3450
+ relationships.push(edge);
3451
+ };
3452
+ for (const event of events) {
3453
+ if (event.parentId) {
3454
+ push({
3455
+ type: "parent-child",
3456
+ fromEventId: event.parentId,
3457
+ toEventId: event.eventId,
3458
+ confidence: byId.has(event.parentId) ? "explicit" : "unknown",
3459
+ basis: ["persisted.parentId"]
3460
+ });
3461
+ if (!byId.has(event.parentId)) {
3462
+ diagnostics.push({
3463
+ code: "AI_RELATIONSHIP_PARENT_MISSING",
3464
+ message: `parentId ${event.parentId} is not present in the event set.`,
3465
+ eventId: event.eventId
3466
+ });
3467
+ }
3468
+ }
3469
+ const bag = attrs(event);
3470
+ const meta = extractSessionWorkflowMetadata(bag) ?? {};
3471
+ const nested = bag.metadata && typeof bag.metadata === "object" ? extractSessionWorkflowMetadata(bag.metadata) : void 0;
3472
+ const workflow = { ...meta, ...nested };
3473
+ if (workflow.retryOf) {
3474
+ const target = events.find((candidate) => candidate.runId === workflow.retryOf);
3475
+ push({
3476
+ type: "retry-of",
3477
+ fromEventId: event.eventId,
3478
+ ...target ? { toEventId: target.eventId } : {},
3479
+ externalRef: workflow.retryOf,
3480
+ confidence: target ? "explicit" : "correlated",
3481
+ basis: ["attributes.retryOf"]
3482
+ });
3483
+ }
3484
+ const attemptOf = stringAttr(bag, "attemptOf") ?? stringAttr(bag, "operationId");
3485
+ if (attemptOf && workflow.attempt !== void 0) {
3486
+ push({
3487
+ type: "attempt-of",
3488
+ fromEventId: event.eventId,
3489
+ externalRef: attemptOf,
3490
+ confidence: "explicit",
3491
+ basis: workflow.attempt !== void 0 ? ["attributes.attempt", "attributes.operationId"] : ["attributes.operationId"]
3492
+ });
3493
+ }
3494
+ const fallbackOf = stringAttr(bag, "fallbackOf");
3495
+ if (fallbackOf) {
3496
+ push({
3497
+ type: "fallback-of",
3498
+ fromEventId: event.eventId,
3499
+ externalRef: fallbackOf,
3500
+ confidence: "explicit",
3501
+ basis: ["attributes.fallbackOf"]
3502
+ });
3503
+ }
3504
+ const remediationOf = stringAttr(bag, "remediationOf");
3505
+ if (remediationOf) {
3506
+ push({
3507
+ type: "remediation-of",
3508
+ fromEventId: event.eventId,
3509
+ externalRef: remediationOf,
3510
+ confidence: "explicit",
3511
+ basis: ["attributes.remediationOf"]
3512
+ });
3513
+ }
3514
+ const evidenceFor = stringAttr(bag, "evidenceFor");
3515
+ if (evidenceFor) {
3516
+ push({
3517
+ type: "evidence-for",
3518
+ fromEventId: event.eventId,
3519
+ ...byId.has(evidenceFor) ? { toEventId: evidenceFor } : { externalRef: evidenceFor },
3520
+ confidence: byId.has(evidenceFor) ? "explicit" : "correlated",
3521
+ basis: ["attributes.evidenceFor"]
3522
+ });
3523
+ }
3524
+ const acceptedBy = stringAttr(bag, "acceptedBy");
3525
+ if (acceptedBy) {
3526
+ push({
3527
+ type: "accepted-by",
3528
+ fromEventId: event.eventId,
3529
+ ...byId.has(acceptedBy) ? { toEventId: acceptedBy } : { externalRef: acceptedBy },
3530
+ confidence: byId.has(acceptedBy) ? "explicit" : "correlated",
3531
+ basis: ["attributes.acceptedBy"]
3532
+ });
3533
+ }
3534
+ const supersedes = stringAttr(bag, "supersedes");
3535
+ if (supersedes) {
3536
+ push({
3537
+ type: "supersedes",
3538
+ fromEventId: event.eventId,
3539
+ ...byId.has(supersedes) ? { toEventId: supersedes } : { externalRef: supersedes },
3540
+ confidence: byId.has(supersedes) ? "explicit" : "correlated",
3541
+ basis: ["attributes.supersedes"]
3542
+ });
3543
+ }
3544
+ const sourceLineage = stringAttr(bag, "sourceLineage") ?? stringAttr(bag, "sourceEventId");
3545
+ if (sourceLineage) {
3546
+ push({
3547
+ type: "source-lineage",
3548
+ fromEventId: event.eventId,
3549
+ externalRef: sourceLineage,
3550
+ confidence: "explicit",
3551
+ basis: ["attributes.sourceLineage"]
3552
+ });
3553
+ }
3554
+ const unsupported = stringAttr(bag, "relationshipType");
3555
+ if (unsupported && unsupported !== "parent-child" && ![
3556
+ "source-lineage",
3557
+ "attempt-of",
3558
+ "retry-of",
3559
+ "fallback-of",
3560
+ "remediation-of",
3561
+ "evidence-for",
3562
+ "accepted-by",
3563
+ "supersedes"
3564
+ ].includes(unsupported)) {
3565
+ diagnostics.push({
3566
+ code: "AI_RELATIONSHIP_UNSUPPORTED_TYPE",
3567
+ message: `Unsupported relationshipType ${unsupported} was reported without flattening.`,
3568
+ eventId: event.eventId
3569
+ });
3570
+ }
3571
+ }
3572
+ return {
3573
+ relationships: Object.freeze(relationships),
3574
+ diagnostics: Object.freeze(diagnostics)
3575
+ };
3576
+ }
3577
+
3365
3578
  // packages/core/src/checks/trace-facts.ts
3366
3579
  function summarizeSemanticParity(events) {
3367
3580
  const projection = projectLogicalEvents(events);
@@ -3448,6 +3661,7 @@ function buildTraceFacts(input) {
3448
3661
  toolsByName.set(name, Object.freeze([...list]));
3449
3662
  }
3450
3663
  const derived = deriveFailureFacts(projection.logicalEvents);
3664
+ const relationship = deriveRelationshipFacts(events);
3451
3665
  const summary = summarizeSemanticParity(events);
3452
3666
  return {
3453
3667
  rawEvents: Object.freeze([...events]),
@@ -3461,10 +3675,15 @@ function buildTraceFacts(input) {
3461
3675
  failureRoleCounts: derived.failureRoleCounts
3462
3676
  },
3463
3677
  failureFacts: derived.failureFacts,
3464
- failuresByRole: derived.failuresByRole
3678
+ failuresByRole: derived.failuresByRole,
3679
+ relationships: relationship.relationships,
3680
+ relationshipDiagnostics: relationship.diagnostics
3465
3681
  };
3466
3682
  }
3467
3683
 
3684
+ // packages/core/src/checks/contract.ts
3685
+ new Set(OBSERVED_OUTCOME_METHODS);
3686
+
3468
3687
  // packages/core/src/checks/index.ts
3469
3688
  var SEVERITY_RANK = {
3470
3689
  error: 0,
@@ -4640,20 +4859,20 @@ function parseIsoToMs3(iso) {
4640
4859
  return { ms: parsed, invalidTimestamp: false };
4641
4860
  }
4642
4861
  function mapPersistedSourceToInspect(event) {
4643
- const attrs = event.attributes ?? {};
4862
+ const attrs2 = event.attributes ?? {};
4644
4863
  const sourceName = event.source.name;
4645
4864
  if (sourceName === "pino") {
4646
4865
  return {
4647
4866
  type: "pino",
4648
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4649
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4867
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4868
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4650
4869
  };
4651
4870
  }
4652
4871
  if (sourceName === "winston") {
4653
4872
  return {
4654
4873
  type: "winston",
4655
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4656
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4874
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4875
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4657
4876
  };
4658
4877
  }
4659
4878
  const mapType = (t) => {
@@ -4674,55 +4893,55 @@ function mapPersistedSourceToInspect(event) {
4674
4893
  };
4675
4894
  return {
4676
4895
  type: mapType(event.source.type),
4677
- file: typeof attrs.sourceFile === "string" ? attrs.sourceFile : void 0,
4678
- line: typeof attrs.sourceLine === "number" ? attrs.sourceLine : void 0
4896
+ file: typeof attrs2.sourceFile === "string" ? attrs2.sourceFile : void 0,
4897
+ line: typeof attrs2.sourceLine === "number" ? attrs2.sourceLine : void 0
4679
4898
  };
4680
4899
  }
4681
4900
  function buildInspectAttributes(event) {
4682
- const attrs = event.attributes !== void 0 ? { ...event.attributes } : {};
4901
+ const attrs2 = event.attributes !== void 0 ? { ...event.attributes } : {};
4683
4902
  if (event.inputSummary !== void 0) {
4684
- attrs.inputSummary = event.inputSummary;
4903
+ attrs2.inputSummary = event.inputSummary;
4685
4904
  }
4686
4905
  if (event.outputSummary !== void 0) {
4687
- attrs.outputSummary = event.outputSummary;
4906
+ attrs2.outputSummary = event.outputSummary;
4688
4907
  }
4689
4908
  if (event.error) {
4690
4909
  if (event.error.name !== void 0) {
4691
- attrs.errorName = event.error.name;
4910
+ attrs2.errorName = event.error.name;
4692
4911
  }
4693
- attrs.errorMessage = event.error.message;
4912
+ attrs2.errorMessage = event.error.message;
4694
4913
  if (event.error.code !== void 0) {
4695
- attrs.errorCode = event.error.code;
4914
+ attrs2.errorCode = event.error.code;
4696
4915
  }
4697
4916
  }
4698
4917
  if (event.tokenUsage) {
4699
- attrs.tokens = { ...event.tokenUsage };
4918
+ attrs2.tokens = { ...event.tokenUsage };
4700
4919
  }
4701
4920
  if (event.source.type === "ai-sdk" || event.source.type === "otel") {
4702
- attrs.originalSourceType = event.source.type;
4921
+ attrs2.originalSourceType = event.source.type;
4703
4922
  }
4704
4923
  if (event.source.name !== void 0) {
4705
- attrs.sourceName = event.source.name;
4924
+ attrs2.sourceName = event.source.name;
4706
4925
  }
4707
4926
  if (event.source.version !== void 0) {
4708
- attrs.sourceVersion = event.source.version;
4927
+ attrs2.sourceVersion = event.source.version;
4709
4928
  }
4710
- return attrs;
4929
+ return attrs2;
4711
4930
  }
4712
4931
  function persistedInspectEventToInspectEvent(event) {
4713
4932
  if (!isPersistedInspectEvent(event)) {
4714
4933
  throw new Error("Invalid PersistedInspectEvent: failed isPersistedInspectEvent");
4715
4934
  }
4716
4935
  const ts = parseIsoToMs3(event.timestamp);
4717
- const attrs = buildInspectAttributes(event);
4936
+ const attrs2 = buildInspectAttributes(event);
4718
4937
  if (ts.invalidTimestamp) {
4719
- attrs.invalidTimestamp = true;
4938
+ attrs2.invalidTimestamp = true;
4720
4939
  }
4721
4940
  let status;
4722
4941
  if (event.status === "running" || event.status === "ok" || event.status === "error") {
4723
4942
  status = event.status;
4724
4943
  } else if (event.status === "unknown") {
4725
- attrs.persistedStatus = "unknown";
4944
+ attrs2.persistedStatus = "unknown";
4726
4945
  }
4727
4946
  const out = {
4728
4947
  eventId: event.eventId,
@@ -4732,7 +4951,7 @@ function persistedInspectEventToInspectEvent(event) {
4732
4951
  timestamp: ts.ms,
4733
4952
  confidence: event.confidence,
4734
4953
  source: mapPersistedSourceToInspect(event),
4735
- attributes: compactAttributes3(attrs)
4954
+ attributes: compactAttributes3(attrs2)
4736
4955
  };
4737
4956
  if (event.parentId !== void 0) {
4738
4957
  out.parentId = event.parentId;
@@ -5075,13 +5294,13 @@ function persistedEventsForParsedTrace(parsed) {
5075
5294
  function isRecord10(value) {
5076
5295
  return typeof value === "object" && value !== null && !Array.isArray(value);
5077
5296
  }
5078
- function isNonEmptyString3(value) {
5297
+ function isNonEmptyString4(value) {
5079
5298
  return typeof value === "string" && value.trim() !== "";
5080
5299
  }
5081
5300
  function readStringField(record, keys) {
5082
5301
  for (const key of keys) {
5083
5302
  const value = record[key];
5084
- if (isNonEmptyString3(value)) return value;
5303
+ if (isNonEmptyString4(value)) return value;
5085
5304
  }
5086
5305
  return void 0;
5087
5306
  }
@@ -5215,7 +5434,7 @@ function parseUnixNanoToIso(value) {
5215
5434
  return void 0;
5216
5435
  }
5217
5436
  function parseIsoTime(value) {
5218
- if (!isNonEmptyString3(value)) return void 0;
5437
+ if (!isNonEmptyString4(value)) return void 0;
5219
5438
  const ms = Date.parse(value);
5220
5439
  if (!Number.isFinite(ms)) return void 0;
5221
5440
  return new Date(ms).toISOString();
@@ -6443,11 +6662,11 @@ function boundValue(value, key, maxMetadataValueLength, maxPreviewLength, seen,
6443
6662
  depth + 1
6444
6663
  );
6445
6664
  }
6446
- function redactEventAttributes(attrs, redactor, maxMetadataValueLength, maxPreviewLength) {
6447
- if (!attrs || Object.keys(attrs).length === 0) {
6448
- return attrs;
6665
+ function redactEventAttributes(attrs2, redactor, maxMetadataValueLength, maxPreviewLength) {
6666
+ if (!attrs2 || Object.keys(attrs2).length === 0) {
6667
+ return attrs2;
6449
6668
  }
6450
- const redacted = redactor.redactRecord(attrs);
6669
+ const redacted = redactor.redactRecord(attrs2);
6451
6670
  const seen = /* @__PURE__ */ new WeakSet();
6452
6671
  const bounded = boundAttributeValues(
6453
6672
  redacted,
@@ -6833,7 +7052,7 @@ function exportOpenInference(tree, options) {
6833
7052
  endNs = startNs + unixNano(ev.durationMs);
6834
7053
  }
6835
7054
  const { openInferenceKind } = mapInspectKindToOI(ev.kind, warnings);
6836
- const attrs = {
7055
+ const attrs2 = {
6837
7056
  "openinference.span.kind": openInferenceKind,
6838
7057
  "agent_inspect.kind": ev.kind,
6839
7058
  "agent_inspect.confidence": ev.confidence,
@@ -6843,24 +7062,24 @@ function exportOpenInference(tree, options) {
6843
7062
  "agent_inspect.status": ev.status ?? "unset"
6844
7063
  };
6845
7064
  if (ev.durationMs !== void 0) {
6846
- attrs["agent_inspect.duration_ms"] = ev.durationMs;
7065
+ attrs2["agent_inspect.duration_ms"] = ev.durationMs;
6847
7066
  }
6848
7067
  const meta = ev.attributes;
6849
7068
  if (meta?.model !== void 0 && typeof meta.model === "string") {
6850
- attrs["llm.model_name"] = meta.model;
7069
+ attrs2["llm.model_name"] = meta.model;
6851
7070
  }
6852
7071
  const tokens = meta?.tokens;
6853
7072
  if (tokens && typeof tokens === "object" && tokens !== null) {
6854
7073
  const inp = tokens.input;
6855
7074
  const outp = tokens.output;
6856
- if (typeof inp === "number") attrs["llm.token_count.prompt"] = inp;
6857
- if (typeof outp === "number") attrs["llm.token_count.completion"] = outp;
7075
+ if (typeof inp === "number") attrs2["llm.token_count.prompt"] = inp;
7076
+ if (typeof outp === "number") attrs2["llm.token_count.completion"] = outp;
6858
7077
  }
6859
7078
  if (includeAttributes && meta && typeof meta === "object") {
6860
7079
  for (const [k, v] of Object.entries(meta)) {
6861
7080
  if (k === "tokens" || k === "model") continue;
6862
7081
  if (v !== void 0 && v !== null && typeof v !== "object") {
6863
- attrs[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
7082
+ attrs2[`agent_inspect.preview.${k}`] = typeof v === "string" ? v.slice(0, maxLen) : v;
6864
7083
  }
6865
7084
  }
6866
7085
  }
@@ -6880,7 +7099,7 @@ function exportOpenInference(tree, options) {
6880
7099
  name: ev.name,
6881
7100
  start_time_unix_nano: startNs.toString(),
6882
7101
  end_time_unix_nano: endNs?.toString(),
6883
- attributes: attrs,
7102
+ attributes: attrs2,
6884
7103
  status
6885
7104
  });
6886
7105
  }
@@ -6904,7 +7123,7 @@ function exportOpenInference(tree, options) {
6904
7123
  function hexFrom2(seed, byteLen) {
6905
7124
  return crypto__default.default.createHash("sha256").update(seed, "utf8").digest("hex").slice(0, byteLen * 2);
6906
7125
  }
6907
- function stringAttr(key, value) {
7126
+ function stringAttr2(key, value) {
6908
7127
  return { key, value: { stringValue: value } };
6909
7128
  }
6910
7129
  function intAttr(key, value) {
@@ -6942,38 +7161,38 @@ function exportOtlpJson(tree, options) {
6942
7161
  if (ev.durationMs !== void 0 && Number.isFinite(ev.durationMs)) {
6943
7162
  endNs = String(Math.round(ev.timestamp * 1e6 + ev.durationMs * 1e6));
6944
7163
  }
6945
- const attrs = [
6946
- stringAttr("agent_inspect.kind", ev.kind),
6947
- stringAttr("agent_inspect.confidence", ev.confidence),
6948
- stringAttr("agent_inspect.source.type", ev.source.type),
6949
- stringAttr("agent_inspect.run_id", tree.runId),
6950
- stringAttr("agent_inspect.event_id", ev.eventId),
6951
- stringAttr("agent_inspect.status", ev.status ?? "unset")
7164
+ const attrs2 = [
7165
+ stringAttr2("agent_inspect.kind", ev.kind),
7166
+ stringAttr2("agent_inspect.confidence", ev.confidence),
7167
+ stringAttr2("agent_inspect.source.type", ev.source.type),
7168
+ stringAttr2("agent_inspect.run_id", tree.runId),
7169
+ stringAttr2("agent_inspect.event_id", ev.eventId),
7170
+ stringAttr2("agent_inspect.status", ev.status ?? "unset")
6952
7171
  ];
6953
7172
  if (ev.durationMs !== void 0) {
6954
- attrs.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
7173
+ attrs2.push(intAttr("agent_inspect.duration_ms", ev.durationMs));
6955
7174
  }
6956
7175
  const op = genAiOperationName(ev.kind);
6957
7176
  if (op !== void 0) {
6958
- attrs.push(stringAttr("gen_ai.operation.name", op));
7177
+ attrs2.push(stringAttr2("gen_ai.operation.name", op));
6959
7178
  }
6960
7179
  const meta = ev.attributes;
6961
7180
  if (meta?.model !== void 0 && typeof meta.model === "string") {
6962
- attrs.push(stringAttr("gen_ai.request.model", meta.model.slice(0, maxLen)));
7181
+ attrs2.push(stringAttr2("gen_ai.request.model", meta.model.slice(0, maxLen)));
6963
7182
  }
6964
7183
  const tokens = meta?.tokens;
6965
7184
  if (tokens && typeof tokens === "object" && tokens !== null) {
6966
7185
  const inp = tokens.input;
6967
7186
  const outp = tokens.output;
6968
- if (typeof inp === "number") attrs.push(intAttr("gen_ai.usage.input_tokens", inp));
6969
- if (typeof outp === "number") attrs.push(intAttr("gen_ai.usage.output_tokens", outp));
7187
+ if (typeof inp === "number") attrs2.push(intAttr("gen_ai.usage.input_tokens", inp));
7188
+ if (typeof outp === "number") attrs2.push(intAttr("gen_ai.usage.output_tokens", outp));
6970
7189
  }
6971
7190
  if (includeAttributes && meta && typeof meta === "object") {
6972
7191
  for (const [k, v] of Object.entries(meta)) {
6973
7192
  if (k === "tokens" || k === "model") continue;
6974
7193
  if (typeof v === "string" || typeof v === "number" || typeof v === "boolean") {
6975
- attrs.push(
6976
- stringAttr(
7194
+ attrs2.push(
7195
+ stringAttr2(
6977
7196
  `agent_inspect.preview.${k}`,
6978
7197
  typeof v === "string" ? v.slice(0, maxLen) : String(v)
6979
7198
  )
@@ -6995,7 +7214,7 @@ function exportOtlpJson(tree, options) {
6995
7214
  name: ev.name,
6996
7215
  kind: "SPAN_KIND_INTERNAL",
6997
7216
  startTimeUnixNano: startNs,
6998
- attributes: attrs,
7217
+ attributes: attrs2,
6999
7218
  status: {
7000
7219
  code: statusCode,
7001
7220
  ...statusMessage !== void 0 ? { message: statusMessage } : {}
@@ -7013,7 +7232,7 @@ function exportOtlpJson(tree, options) {
7013
7232
  resourceSpans: [
7014
7233
  {
7015
7234
  resource: {
7016
- attributes: [stringAttr("service.name", "agent-inspect")]
7235
+ attributes: [stringAttr2("service.name", "agent-inspect")]
7017
7236
  },
7018
7237
  scopeSpans: [
7019
7238
  {
@@ -7754,7 +7973,7 @@ var FLAGSHIP_TOOLS = [
7754
7973
  {
7755
7974
  name: "get_contract_failures",
7756
7975
  description: withUntrustedTraceWarning(
7757
- "Deterministic contract/check failures for one run."
7976
+ "Deterministic run-status check failures for one run. Actor-scoped TraceContracts and observation provenance (scope / requireProvenance) are evaluated via the TypeScript agent-inspect/checks API (evaluateTraceContract), not this MCP tool."
7758
7977
  ),
7759
7978
  inputSchema: RUN_ID_SCHEMA
7760
7979
  },