autotel-genai 0.4.2 → 0.6.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.
Files changed (46) hide show
  1. package/README.md +71 -0
  2. package/dist/agent/index.cjs +9 -1
  3. package/dist/agent/index.d.cts +2 -2
  4. package/dist/agent/index.d.ts +2 -2
  5. package/dist/agent/index.js +2 -2
  6. package/dist/{agent-oCfaqmYw.js → agent-C9ww7o3H.js} +246 -2
  7. package/dist/{agent-CnXNAj9B.cjs → agent-gI7KbR4Q.cjs} +293 -1
  8. package/dist/ai-sdk-bridge.cjs +1 -1
  9. package/dist/ai-sdk-bridge.d.cts +2 -2
  10. package/dist/ai-sdk-bridge.d.ts +2 -2
  11. package/dist/ai-sdk-bridge.js +1 -1
  12. package/dist/{attributes-C7k871NW.d.cts → attributes-BHxFjXSS.d.cts} +1 -1
  13. package/dist/{attributes-BSunBoIR.cjs → attributes-D2ugZS_C.cjs} +1 -0
  14. package/dist/{attributes-DCv1cxKZ.js → attributes-DmV7B6dn.js} +1 -0
  15. package/dist/{attributes-jUO1pbUc.d.ts → attributes-DyCFltYK.d.ts} +1 -1
  16. package/dist/{events-CXHe4AL7.d.ts → events-DpASz90I.d.ts} +1 -1
  17. package/dist/{events-Diz0gxop.d.cts → events-RGl-M4u9.d.cts} +1 -1
  18. package/dist/events.d.cts +1 -1
  19. package/dist/events.d.ts +1 -1
  20. package/dist/index-B4Qh_eVm.d.ts +1967 -0
  21. package/dist/{index-Bgt8apSM.d.cts → index-CB26RNKN.d.cts} +102 -7
  22. package/dist/index-CcygHaEj.d.cts +1967 -0
  23. package/dist/{index-Lg3gQ_VO.d.ts → index-CfzmE066.d.ts} +102 -7
  24. package/dist/index.cjs +3 -3
  25. package/dist/index.d.cts +5 -5
  26. package/dist/index.d.ts +5 -5
  27. package/dist/index.js +3 -3
  28. package/dist/observer/index.cjs +2 -1
  29. package/dist/observer/index.d.cts +2 -2
  30. package/dist/observer/index.d.ts +2 -2
  31. package/dist/observer/index.js +2 -2
  32. package/dist/{observer-Ckha9xGv.js → observer-Bqe_gIb2.js} +350 -4
  33. package/dist/{observer-BoQNdbkg.cjs → observer-D8JVyCP6.cjs} +355 -3
  34. package/dist/{semconv-B6zNvJ73.d.cts → semconv-B8OQQKbC.d.cts} +8 -0
  35. package/dist/{semconv-B6zNvJ73.d.ts → semconv-B8OQQKbC.d.ts} +8 -0
  36. package/dist/semconv.cjs +8 -0
  37. package/dist/semconv.d.cts +1 -1
  38. package/dist/semconv.d.ts +1 -1
  39. package/dist/semconv.js +8 -0
  40. package/dist/trace.cjs +1 -1
  41. package/dist/trace.d.cts +2 -2
  42. package/dist/trace.d.ts +2 -2
  43. package/dist/trace.js +1 -1
  44. package/package.json +3 -3
  45. package/dist/index-D010Y_xS.d.ts +0 -472
  46. package/dist/index-Dc450L-d.d.cts +0 -472
package/README.md CHANGED
@@ -210,6 +210,47 @@ governance attributes **and** canonical `gen_ai.*` when `ai` metadata is present
210
210
  It honours spec breaking change #242 (`gen_ai.agent.id` is dropped on internal
211
211
  `invoke_agent` spans via `genAiAgentAttributes(…, { internal: true })`).
212
212
 
213
+ **Eval-sandbox incident replay.** When multiple eval agents share a writable
214
+ registry (the OpenAI/HuggingFace pattern), use the agent IR helpers below.
215
+ See the standalone demo at `agent-eval-sandbox-demo` (sibling to ai-sdk-guardrails).
216
+
217
+ ```ts
218
+ import {
219
+ CrossAgentMonitor,
220
+ createHoneyTokenTool,
221
+ crossAgentDetectionsToSecurityEvents,
222
+ detectCrossAgentPattern,
223
+ EVAL_IDENTITY_ATTR,
224
+ querySpansForEvalIncident,
225
+ recordEvalRunIdentity,
226
+ } from 'autotel-genai/agent';
227
+
228
+ // Tag every run so its spans stay separable downstream
229
+ // (eval.run_id / eval.task_id / eval.sandbox_id).
230
+ recordEvalRunIdentity({ runId, taskId, sandboxId });
231
+
232
+ // Live: emit agent.shared_channel.detected as tools run
233
+ const monitor = new CrossAgentMonitor({ minAgents: 2, ctx });
234
+ monitor.record({ agentId: 'eval-a', resource: 'artifactory:/notes' });
235
+
236
+ // Offline: the same detection over events you collected yourself
237
+ const alerts = crossAgentDetectionsToSecurityEvents(
238
+ detectCrossAgentPattern(collectedEvents, { minAgents: 2 }),
239
+ );
240
+
241
+ // Batch IR over an exported span array
242
+ const ir = querySpansForEvalIncident(finishedSpans);
243
+ ir.crossAgentEvents; // shared-channel alerts
244
+ ir.evalRuns; // every EVAL_IDENTITY_ATTR.runId seen
245
+
246
+ // Honey-token tool: a decoy credential that reports when an agent touches it
247
+ const honeyToken = createHoneyTokenTool({
248
+ name: 'readLeakedCredential',
249
+ bait: 'AKIA_HONEY_TOKEN_DO_NOT_USE',
250
+ ctx,
251
+ });
252
+ ```
253
+
213
254
  ### Vercel AI SDK
214
255
 
215
256
  Register `autotelTelemetry()` once and every `generateText` / `streamText` /
@@ -364,6 +405,7 @@ call exactly once.
364
405
  import {
365
406
  createGenAiObserver,
366
407
  createLangChainObserver, // LangChain / LangGraph callback handler
408
+ createMastraObserver, // Mastra ObservabilityExporter
367
409
  observeAiSdkResult, // Vercel AI SDK result walker
368
410
  } from 'autotel-genai/observer';
369
411
 
@@ -372,6 +414,19 @@ const observe = createGenAiObserver();
372
414
  // LangChain / LangGraph — one handler, runId/parentRunId → span tree:
373
415
  await graph.invoke(input, { callbacks: [createLangChainObserver(observe)] });
374
416
 
417
+ // Mastra — one exporter on the observability pipeline:
418
+ new Mastra({
419
+ agents,
420
+ observability: new Observability({
421
+ configs: {
422
+ autotel: {
423
+ serviceName: 'support-agent',
424
+ exporters: [createMastraObserver(observe)],
425
+ },
426
+ },
427
+ }),
428
+ });
429
+
375
430
  // Vercel AI SDK — walk a generateText/streamText result:
376
431
  observeAiSdkResult(observe, await generateText({ model, prompt }), {
377
432
  id: 'gen-1',
@@ -382,6 +437,22 @@ observeAiSdkResult(observe, await generateText({ model, prompt }), {
382
437
 
383
438
  See `apps/example-langchain-observer` for a runnable LangGraph + Ollama demo.
384
439
 
440
+ Mastra maps `agent_run` → `invoke_agent`, `model_generation` → `chat`,
441
+ `rag_embedding` → `embeddings`, every tool-call type → `execute_tool`, and
442
+ `workflow_run`/`workflow_step` → `invoke_workflow`. Plumbing (model steps and
443
+ chunks, processors, scorers, mappings) is dropped and its children reparent to
444
+ the nearest kept ancestor. Pass `skipSpan` to drop additional supported span
445
+ types; unsupported plumbing always stays dropped. `model_step` /
446
+ `model_inference` are dropped deliberately: their usage is already summed on the
447
+ enclosing `model_generation`, so keeping both would double-count
448
+ `gen_ai.usage.*`.
449
+
450
+ `@mastra/otel-exporter` also emits canonical `gen_ai.*`. Prefer this adapter
451
+ when you want Mastra's spans to be _autotel's_ spans — Mastra dispatches events
452
+ synchronously, so they nest under the request span you already opened, reach
453
+ every `init()` destination, pass through your `spanEnrichers` (including
454
+ `langfuseCompatibility`), and get priced.
455
+
385
456
  ## Semantic conventions
386
457
 
387
458
  Aligned to the `semantic-conventions-genai` snapshot. Span names follow the
@@ -1,27 +1,34 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_agent_security = require('../agent-security-kfpXuwL4.cjs');
3
- const require_agent = require('../agent-CnXNAj9B.cjs');
3
+ const require_agent = require('../agent-gI7KbR4Q.cjs');
4
4
 
5
5
  exports.AGENT_AUDIT_SCHEMA_VERSION = require_agent.AGENT_AUDIT_SCHEMA_VERSION;
6
6
  exports.AGENT_PLAN_RISK_ATTR = require_agent.AGENT_PLAN_RISK_ATTR;
7
7
  exports.AGENT_SECURITY_ATTR = require_agent_security.AGENT_SECURITY_ATTR;
8
+ exports.CrossAgentMonitor = require_agent.CrossAgentMonitor;
9
+ exports.EVAL_IDENTITY_ATTR = require_agent.EVAL_IDENTITY_ATTR;
8
10
  exports.agentContextFromSpan = require_agent_security.agentContextFromSpan;
9
11
  exports.canonicalizeForHash = require_agent.canonicalizeForHash;
10
12
  exports.createAgentAuditMetadata = require_agent.createAgentAuditMetadata;
11
13
  exports.createAgentIdentityRegistry = require_agent.createAgentIdentityRegistry;
14
+ exports.createHoneyTokenTool = require_agent.createHoneyTokenTool;
12
15
  exports.createSignedEventEnvelope = require_agent.createSignedEventEnvelope;
16
+ exports.crossAgentDetectionsToSecurityEvents = require_agent.crossAgentDetectionsToSecurityEvents;
13
17
  exports.defineAgentAction = require_agent.defineAgentAction;
14
18
  exports.defineAgentToolCall = require_agent.defineAgentToolCall;
15
19
  exports.delegateToAgent = require_agent.delegateToAgent;
16
20
  exports.deriveActionRiskClass = require_agent_security.deriveActionRiskClass;
21
+ exports.detectCrossAgentPattern = require_agent.detectCrossAgentPattern;
17
22
  exports.flattenAgentAttributes = require_agent.flattenAgentAttributes;
18
23
  exports.hashPayload = require_agent.hashPayload;
19
24
  exports.heuristicPlanRiskClassifier = require_agent.heuristicPlanRiskClassifier;
25
+ exports.querySpansForEvalIncident = require_agent.querySpansForEvalIncident;
20
26
  exports.recordActionRiskClass = require_agent_security.recordActionRiskClass;
21
27
  exports.recordActiveScopes = require_agent_security.recordActiveScopes;
22
28
  exports.recordAgentHandoff = require_agent.recordAgentHandoff;
23
29
  exports.recordControllerId = require_agent_security.recordControllerId;
24
30
  exports.recordDecisionBasis = require_agent.recordDecisionBasis;
31
+ exports.recordEvalRunIdentity = require_agent.recordEvalRunIdentity;
25
32
  exports.recordHumanApproval = require_agent_security.recordHumanApproval;
26
33
  exports.recordInputProvenance = require_agent_security.recordInputProvenance;
27
34
  exports.recordMemoryAccess = require_agent_security.recordMemoryAccess;
@@ -33,6 +40,7 @@ exports.resolvePrivacyProfile = require_agent.resolvePrivacyProfile;
33
40
  exports.runAgentPlanClassifier = require_agent.runAgentPlanClassifier;
34
41
  exports.sanitizeAuditPayload = require_agent.sanitizeAuditPayload;
35
42
  exports.setAgentAttributes = require_agent.setAgentAttributes;
43
+ exports.spansToCrossAgentEvents = require_agent.spansToCrossAgentEvents;
36
44
  exports.tryRecordHumanApproval = require_agent_security.tryRecordHumanApproval;
37
45
  exports.verifyEventEnvelopeHash = require_agent.verifyEventEnvelopeHash;
38
46
  exports.withAgentAction = require_agent.withAgentAction;
@@ -1,4 +1,4 @@
1
- import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, a as AgentPlanRiskVerdict, at as PrivacyProfile, b as createAgentIdentityRegistry, c as recordPlanRiskAssessment, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, i as AgentPlanClassifierResult, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, l as runAgentPlanClassifier, lt as ToolStatus, m as PrivacyProfileInput, n as AgentPlanClassifier, nt as GovernanceMetadata, o as RecordPlanRiskAssessmentOptions, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, r as AgentPlanClassifierInput, rt as PolicyDecision, s as heuristicPlanRiskClassifier, st as ScopedToolDefinition, t as AGENT_PLAN_RISK_ATTR, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "../index-Dc450L-d.cjs";
1
+ import { $ as AgentActionMetadata, A as verifyEventEnvelopeHash, At as AGENT_AUDIT_SCHEMA_VERSION, B as defineAgentToolCall, C as CrossAgentSecurityEvent, Ct as PrivacyProfileName, D as withScopedTool, Dt as HashPayloadOptions, E as detectCrossAgentPattern, Et as ToolStatus, F as RevokeAgentIdentityInput, G as DelegateToAgentInput, H as recordPolicyDecision, I as RotateAgentIdentityInput, J as recordAgentHandoff, K as RecordAgentHandoffMetadata, L as createAgentIdentityRegistry, M as resolvePrivacyProfile, N as sanitizeAuditPayload, O as CreateSignedEventEnvelopeOptions, Ot as canonicalizeForHash, P as ProvisionAgentIdentityInput, Q as AgentActionFactory, R as withAgentSession, S as CrossAgentEvent, St as PrivacyProfile, T as crossAgentDetectionsToSecurityEvents, Tt as ToolCallMetadata, U as withAgentAction, V as recordDecisionBasis, W as withAgentToolCall, X as setAgentAttributes, Y as flattenAgentAttributes, Z as createAgentAuditMetadata, _ as RecordEvalRunIdentityInput, _t as AiLifecycleStage, a as AgentPlanRiskVerdict, at as AgentHandler, b as CrossAgentMonitorOptions, bt as PolicyDecision, c as recordPlanRiskAssessment, ct as AgentIdentityRegistry, d as querySpansForEvalIncident, dt as AgentOutcome, et as AgentActionOptions, f as spansToCrossAgentEvents, ft as AgentSessionActionMetadata, g as EVAL_IDENTITY_ATTR, gt as AgentToolCallOptions, h as createHoneyTokenTool, ht as AgentToolCallActionMetadata, i as AgentPlanClassifierResult, it as AgentEventKind, j as PrivacyProfileInput, k as createSignedEventEnvelope, kt as hashPayload, l as runAgentPlanClassifier, lt as AgentIdentityStatus, m as HoneyTokenToolOptions, mt as AgentSessionStatus, n as AgentPlanClassifier, nt as AgentAuditEventEnvelope, o as RecordPlanRiskAssessmentOptions, ot as AgentIdentity, p as HoneyTokenToolDefinition, pt as AgentSessionMetadata, q as delegateToAgent, r as AgentPlanClassifierInput, rt as AgentDecisionMetadata, s as heuristicPlanRiskClassifier, st as AgentIdentityRecord, t as AGENT_PLAN_RISK_ATTR, tt as AgentAiMetadata, u as EvalIncidentQueryResult, ut as AgentMetadataInput, v as recordEvalRunIdentity, vt as DelegationContext, w as DetectCrossAgentPatternOptions, wt as ScopedToolDefinition, x as CrossAgentDetection, xt as PolicyMetadata, y as CrossAgentMonitor, yt as GovernanceMetadata, z as defineAgentAction } from "../index-CcygHaEj.cjs";
2
2
  import { a as TokenUsage, i as ModelPricing } from "../cost-C1FkUNG1.cjs";
3
3
  import { C as recordPlanStep, D as agentContextFromSpan, E as AgentContext, S as recordMemoryAccess, T as tryRecordHumanApproval, _ as recordActionRiskClass, a as AgentInputProvenance, b as recordHumanApproval, c as AgentSecurityRecordOptions, d as RecordHumanApprovalInput, f as RecordInputProvenanceInput, g as deriveActionRiskClass, h as RecordRenderOutputInput, i as AgentConsentOutcome, l as RecordActiveScopesInput, m as RecordPlanStepInput, n as ActionRiskHints, o as AgentMemoryOperation, p as RecordMemoryAccessInput, r as AgentActionRiskClass, s as AgentOutputFormat, t as AGENT_SECURITY_ATTR, u as RecordControllerInput, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId } from "../agent-security-BHdP6ZPG.cjs";
4
- export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, type ActionRiskHints, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentActionRiskClass, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentConsentOutcome, type AgentContext, type AgentDecisionMetadata, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentInputProvenance, type AgentMemoryOperation, type AgentMetadataInput, type AgentOutcome, type AgentOutputFormat, type AgentPlanClassifier, type AgentPlanClassifierInput, type AgentPlanClassifierResult, type AgentPlanRiskVerdict, type AgentSecurityRecordOptions, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type GovernanceMetadata, type HashPayloadOptions, type ModelPricing, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordActiveScopesInput, type RecordAgentHandoffMetadata, type RecordControllerInput, type RecordHumanApprovalInput, type RecordInputProvenanceInput, type RecordMemoryAccessInput, type RecordPlanRiskAssessmentOptions, type RecordPlanStepInput, type RecordRenderOutputInput, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type TokenUsage, type ToolCallMetadata, type ToolStatus, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createSignedEventEnvelope, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
4
+ export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, type ActionRiskHints, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentActionRiskClass, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentConsentOutcome, type AgentContext, type AgentDecisionMetadata, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentInputProvenance, type AgentMemoryOperation, type AgentMetadataInput, type AgentOutcome, type AgentOutputFormat, type AgentPlanClassifier, type AgentPlanClassifierInput, type AgentPlanClassifierResult, type AgentPlanRiskVerdict, type AgentSecurityRecordOptions, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type CreateSignedEventEnvelopeOptions, type CrossAgentDetection, type CrossAgentEvent, CrossAgentMonitor, type CrossAgentMonitorOptions, type CrossAgentSecurityEvent, type DelegateToAgentInput, type DelegationContext, type DetectCrossAgentPatternOptions, EVAL_IDENTITY_ATTR, type EvalIncidentQueryResult, type GovernanceMetadata, type HashPayloadOptions, type HoneyTokenToolDefinition, type HoneyTokenToolOptions, type ModelPricing, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordActiveScopesInput, type RecordAgentHandoffMetadata, type RecordControllerInput, type RecordEvalRunIdentityInput, type RecordHumanApprovalInput, type RecordInputProvenanceInput, type RecordMemoryAccessInput, type RecordPlanRiskAssessmentOptions, type RecordPlanStepInput, type RecordRenderOutputInput, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type TokenUsage, type ToolCallMetadata, type ToolStatus, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createHoneyTokenTool, createSignedEventEnvelope, crossAgentDetectionsToSecurityEvents, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, detectCrossAgentPattern, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, querySpansForEvalIncident, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordEvalRunIdentity, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, spansToCrossAgentEvents, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
@@ -1,4 +1,4 @@
1
- import { $ as AgentToolCallOptions, A as delegateToAgent, B as AgentDecisionMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, F as AgentActionFactory, G as AgentIdentityRegistry, H as AgentHandler, I as AgentActionMetadata, J as AgentOutcome, K as AgentIdentityStatus, L as AgentActionOptions, M as flattenAgentAttributes, N as setAgentAttributes, O as DelegateToAgentInput, P as createAgentAuditMetadata, Q as AgentToolCallActionMetadata, R as AgentAiMetadata, S as defineAgentAction, T as recordPolicyDecision, U as AgentIdentity, V as AgentEventKind, W as AgentIdentityRecord, X as AgentSessionMetadata, Y as AgentSessionActionMetadata, Z as AgentSessionStatus, _ as ProvisionAgentIdentityInput, a as AgentPlanRiskVerdict, at as PrivacyProfile, b as createAgentIdentityRegistry, c as recordPlanRiskAssessment, ct as ToolCallMetadata, d as CreateSignedEventEnvelopeOptions, dt as canonicalizeForHash, et as AiLifecycleStage, f as createSignedEventEnvelope, ft as hashPayload, g as sanitizeAuditPayload, h as resolvePrivacyProfile, i as AgentPlanClassifierResult, it as PolicyMetadata, j as recordAgentHandoff, k as RecordAgentHandoffMetadata, l as runAgentPlanClassifier, lt as ToolStatus, m as PrivacyProfileInput, n as AgentPlanClassifier, nt as GovernanceMetadata, o as RecordPlanRiskAssessmentOptions, ot as PrivacyProfileName, p as verifyEventEnvelopeHash, pt as AGENT_AUDIT_SCHEMA_VERSION, q as AgentMetadataInput, r as AgentPlanClassifierInput, rt as PolicyDecision, s as heuristicPlanRiskClassifier, st as ScopedToolDefinition, t as AGENT_PLAN_RISK_ATTR, tt as DelegationContext, u as withScopedTool, ut as HashPayloadOptions, v as RevokeAgentIdentityInput, w as recordDecisionBasis, x as withAgentSession, y as RotateAgentIdentityInput, z as AgentAuditEventEnvelope } from "../index-D010Y_xS.js";
1
+ import { $ as AgentActionMetadata, A as verifyEventEnvelopeHash, At as AGENT_AUDIT_SCHEMA_VERSION, B as defineAgentToolCall, C as CrossAgentSecurityEvent, Ct as PrivacyProfileName, D as withScopedTool, Dt as HashPayloadOptions, E as detectCrossAgentPattern, Et as ToolStatus, F as RevokeAgentIdentityInput, G as DelegateToAgentInput, H as recordPolicyDecision, I as RotateAgentIdentityInput, J as recordAgentHandoff, K as RecordAgentHandoffMetadata, L as createAgentIdentityRegistry, M as resolvePrivacyProfile, N as sanitizeAuditPayload, O as CreateSignedEventEnvelopeOptions, Ot as canonicalizeForHash, P as ProvisionAgentIdentityInput, Q as AgentActionFactory, R as withAgentSession, S as CrossAgentEvent, St as PrivacyProfile, T as crossAgentDetectionsToSecurityEvents, Tt as ToolCallMetadata, U as withAgentAction, V as recordDecisionBasis, W as withAgentToolCall, X as setAgentAttributes, Y as flattenAgentAttributes, Z as createAgentAuditMetadata, _ as RecordEvalRunIdentityInput, _t as AiLifecycleStage, a as AgentPlanRiskVerdict, at as AgentHandler, b as CrossAgentMonitorOptions, bt as PolicyDecision, c as recordPlanRiskAssessment, ct as AgentIdentityRegistry, d as querySpansForEvalIncident, dt as AgentOutcome, et as AgentActionOptions, f as spansToCrossAgentEvents, ft as AgentSessionActionMetadata, g as EVAL_IDENTITY_ATTR, gt as AgentToolCallOptions, h as createHoneyTokenTool, ht as AgentToolCallActionMetadata, i as AgentPlanClassifierResult, it as AgentEventKind, j as PrivacyProfileInput, k as createSignedEventEnvelope, kt as hashPayload, l as runAgentPlanClassifier, lt as AgentIdentityStatus, m as HoneyTokenToolOptions, mt as AgentSessionStatus, n as AgentPlanClassifier, nt as AgentAuditEventEnvelope, o as RecordPlanRiskAssessmentOptions, ot as AgentIdentity, p as HoneyTokenToolDefinition, pt as AgentSessionMetadata, q as delegateToAgent, r as AgentPlanClassifierInput, rt as AgentDecisionMetadata, s as heuristicPlanRiskClassifier, st as AgentIdentityRecord, t as AGENT_PLAN_RISK_ATTR, tt as AgentAiMetadata, u as EvalIncidentQueryResult, ut as AgentMetadataInput, v as recordEvalRunIdentity, vt as DelegationContext, w as DetectCrossAgentPatternOptions, wt as ScopedToolDefinition, x as CrossAgentDetection, xt as PolicyMetadata, y as CrossAgentMonitor, yt as GovernanceMetadata, z as defineAgentAction } from "../index-B4Qh_eVm.js";
2
2
  import { a as TokenUsage, i as ModelPricing } from "../cost-C1FkUNG1.js";
3
3
  import { C as recordPlanStep, D as agentContextFromSpan, E as AgentContext, S as recordMemoryAccess, T as tryRecordHumanApproval, _ as recordActionRiskClass, a as AgentInputProvenance, b as recordHumanApproval, c as AgentSecurityRecordOptions, d as RecordHumanApprovalInput, f as RecordInputProvenanceInput, g as deriveActionRiskClass, h as RecordRenderOutputInput, i as AgentConsentOutcome, l as RecordActiveScopesInput, m as RecordPlanStepInput, n as ActionRiskHints, o as AgentMemoryOperation, p as RecordMemoryAccessInput, r as AgentActionRiskClass, s as AgentOutputFormat, t as AGENT_SECURITY_ATTR, u as RecordControllerInput, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId } from "../agent-security-BHdP6ZPG.js";
4
- export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, type ActionRiskHints, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentActionRiskClass, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentConsentOutcome, type AgentContext, type AgentDecisionMetadata, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentInputProvenance, type AgentMemoryOperation, type AgentMetadataInput, type AgentOutcome, type AgentOutputFormat, type AgentPlanClassifier, type AgentPlanClassifierInput, type AgentPlanClassifierResult, type AgentPlanRiskVerdict, type AgentSecurityRecordOptions, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type CreateSignedEventEnvelopeOptions, type DelegateToAgentInput, type DelegationContext, type GovernanceMetadata, type HashPayloadOptions, type ModelPricing, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordActiveScopesInput, type RecordAgentHandoffMetadata, type RecordControllerInput, type RecordHumanApprovalInput, type RecordInputProvenanceInput, type RecordMemoryAccessInput, type RecordPlanRiskAssessmentOptions, type RecordPlanStepInput, type RecordRenderOutputInput, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type TokenUsage, type ToolCallMetadata, type ToolStatus, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createSignedEventEnvelope, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
4
+ export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, type ActionRiskHints, type AgentActionFactory, type AgentActionMetadata, type AgentActionOptions, type AgentActionRiskClass, type AgentAiMetadata, type AgentAuditEventEnvelope, type AgentConsentOutcome, type AgentContext, type AgentDecisionMetadata, type AgentEventKind, type AgentHandler, type AgentIdentity, type AgentIdentityRecord, type AgentIdentityRegistry, type AgentIdentityStatus, type AgentInputProvenance, type AgentMemoryOperation, type AgentMetadataInput, type AgentOutcome, type AgentOutputFormat, type AgentPlanClassifier, type AgentPlanClassifierInput, type AgentPlanClassifierResult, type AgentPlanRiskVerdict, type AgentSecurityRecordOptions, type AgentSessionActionMetadata, type AgentSessionMetadata, type AgentSessionStatus, type AgentToolCallActionMetadata, type AgentToolCallOptions, type AiLifecycleStage, type CreateSignedEventEnvelopeOptions, type CrossAgentDetection, type CrossAgentEvent, CrossAgentMonitor, type CrossAgentMonitorOptions, type CrossAgentSecurityEvent, type DelegateToAgentInput, type DelegationContext, type DetectCrossAgentPatternOptions, EVAL_IDENTITY_ATTR, type EvalIncidentQueryResult, type GovernanceMetadata, type HashPayloadOptions, type HoneyTokenToolDefinition, type HoneyTokenToolOptions, type ModelPricing, type PolicyDecision, type PolicyMetadata, type PrivacyProfile, type PrivacyProfileInput, type PrivacyProfileName, type ProvisionAgentIdentityInput, type RecordActiveScopesInput, type RecordAgentHandoffMetadata, type RecordControllerInput, type RecordEvalRunIdentityInput, type RecordHumanApprovalInput, type RecordInputProvenanceInput, type RecordMemoryAccessInput, type RecordPlanRiskAssessmentOptions, type RecordPlanStepInput, type RecordRenderOutputInput, type RevokeAgentIdentityInput, type RotateAgentIdentityInput, type ScopedToolDefinition, type TokenUsage, type ToolCallMetadata, type ToolStatus, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createHoneyTokenTool, createSignedEventEnvelope, crossAgentDetectionsToSecurityEvents, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, detectCrossAgentPattern, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, querySpansForEvalIncident, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordEvalRunIdentity, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, spansToCrossAgentEvents, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
@@ -1,4 +1,4 @@
1
1
  import { a as recordControllerId, c as recordMemoryAccess, d as tryRecordHumanApproval, i as recordActiveScopes, l as recordPlanStep, n as deriveActionRiskClass, o as recordHumanApproval, p as agentContextFromSpan, r as recordActionRiskClass, s as recordInputProvenance, t as AGENT_SECURITY_ATTR, u as recordRenderOutput } from "../agent-security-CUDUKOEK.js";
2
- import { C as canonicalizeForHash, S as createAgentAuditMetadata, T as AGENT_AUDIT_SCHEMA_VERSION, _ as recordPolicyDecision, a as withScopedTool, b as flattenAgentAttributes, c as resolvePrivacyProfile, d as withAgentSession, f as delegateToAgent, g as recordDecisionBasis, h as defineAgentToolCall, i as runAgentPlanClassifier, l as sanitizeAuditPayload, m as defineAgentAction, n as heuristicPlanRiskClassifier, o as createSignedEventEnvelope, p as recordAgentHandoff, r as recordPlanRiskAssessment, s as verifyEventEnvelopeHash, t as AGENT_PLAN_RISK_ATTR, u as createAgentIdentityRegistry, v as withAgentAction, w as hashPayload, x as setAgentAttributes, y as withAgentToolCall } from "../agent-oCfaqmYw.js";
2
+ import { A as createAgentAuditMetadata, C as defineAgentToolCall, D as withAgentToolCall, E as withAgentAction, M as hashPayload, N as AGENT_AUDIT_SCHEMA_VERSION, O as flattenAgentAttributes, S as defineAgentAction, T as recordPolicyDecision, _ as sanitizeAuditPayload, a as querySpansForEvalIncident, b as delegateToAgent, c as EVAL_IDENTITY_ATTR, d as crossAgentDetectionsToSecurityEvents, f as detectCrossAgentPattern, g as resolvePrivacyProfile, h as verifyEventEnvelopeHash, i as runAgentPlanClassifier, j as canonicalizeForHash, k as setAgentAttributes, l as recordEvalRunIdentity, m as createSignedEventEnvelope, n as heuristicPlanRiskClassifier, o as spansToCrossAgentEvents, p as withScopedTool, r as recordPlanRiskAssessment, s as createHoneyTokenTool, t as AGENT_PLAN_RISK_ATTR, u as CrossAgentMonitor, v as createAgentIdentityRegistry, w as recordDecisionBasis, x as recordAgentHandoff, y as withAgentSession } from "../agent-C9ww7o3H.js";
3
3
 
4
- export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createSignedEventEnvelope, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
4
+ export { AGENT_AUDIT_SCHEMA_VERSION, AGENT_PLAN_RISK_ATTR, AGENT_SECURITY_ATTR, CrossAgentMonitor, EVAL_IDENTITY_ATTR, agentContextFromSpan, canonicalizeForHash, createAgentAuditMetadata, createAgentIdentityRegistry, createHoneyTokenTool, createSignedEventEnvelope, crossAgentDetectionsToSecurityEvents, defineAgentAction, defineAgentToolCall, delegateToAgent, deriveActionRiskClass, detectCrossAgentPattern, flattenAgentAttributes, hashPayload, heuristicPlanRiskClassifier, querySpansForEvalIncident, recordActionRiskClass, recordActiveScopes, recordAgentHandoff, recordControllerId, recordDecisionBasis, recordEvalRunIdentity, recordHumanApproval, recordInputProvenance, recordMemoryAccess, recordPlanRiskAssessment, recordPlanStep, recordPolicyDecision, recordRenderOutput, resolvePrivacyProfile, runAgentPlanClassifier, sanitizeAuditPayload, setAgentAttributes, spansToCrossAgentEvents, tryRecordHumanApproval, verifyEventEnvelopeHash, withAgentAction, withAgentSession, withAgentToolCall, withScopedTool };
@@ -1,5 +1,5 @@
1
1
  import { estimateLLMCost } from "./cost.js";
2
- import { i as genAiResponseAttributes, r as genAiRequestAttributes, s as genAiUsageAttributes } from "./attributes-DCv1cxKZ.js";
2
+ import { i as genAiResponseAttributes, r as genAiRequestAttributes, s as genAiUsageAttributes } from "./attributes-DmV7B6dn.js";
3
3
  import { _ as warnMissingContextOnce, a as recordControllerId, c as recordMemoryAccess, d as tryRecordHumanApproval, f as MISSING_CONTEXT_MESSAGE, g as toAttributeValue, h as resolveContextSafe, i as recordActiveScopes, l as recordPlanStep, m as resolveContext, n as deriveActionRiskClass, o as recordHumanApproval, r as recordActionRiskClass, s as recordInputProvenance, t as AGENT_SECURITY_ATTR, u as recordRenderOutput } from "./agent-security-CUDUKOEK.js";
4
4
  import { createNoopRequestLogger, createStructuredError, getRequestLoggerSafe } from "autotel";
5
5
  import { forceKeepAuditEvent, securityEvent, withAudit } from "autotel-audit";
@@ -982,6 +982,250 @@ async function withScopedTool(definition, input, fn, options = {}) {
982
982
  }, fn, options);
983
983
  }
984
984
 
985
+ //#endregion
986
+ //#region src/agent/cross-agent-detect.ts
987
+ function groupKey(event) {
988
+ return event.isolationKey ? `memory:${event.isolationKey}` : `resource:${event.resource}`;
989
+ }
990
+ /**
991
+ * Detect shared-channel usage across agent identities. Pure function — safe to
992
+ * run over exported span batches or audit logs in incident replay.
993
+ */
994
+ function detectCrossAgentPattern(events, options = {}) {
995
+ const { minAgents = 2, windowMs = 864e5 } = options;
996
+ const grouped = new Map();
997
+ for (const event of events) {
998
+ const key = groupKey(event);
999
+ const existing = grouped.get(key);
1000
+ if (existing) {
1001
+ existing.events.push(event);
1002
+ } else {
1003
+ grouped.set(key, {
1004
+ resource: event.resource,
1005
+ events: [event]
1006
+ });
1007
+ }
1008
+ }
1009
+ const detections = [];
1010
+ for (const { resource, events: groupEvents } of grouped.values()) {
1011
+ const sorted = windowMs > 0 ? groupEvents.toSorted((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0)) : groupEvents;
1012
+ const agentIds = new Set();
1013
+ for (const event of sorted) {
1014
+ const ts = event.timestamp ?? Date.now();
1015
+ if (windowMs > 0) {
1016
+ const windowStart = ts - windowMs;
1017
+ const inWindow = sorted.filter((e) => {
1018
+ const eTs = e.timestamp ?? Date.now();
1019
+ return eTs >= windowStart && eTs <= ts;
1020
+ });
1021
+ const windowAgents = new Set(inWindow.map((e) => e.agentId));
1022
+ if (windowAgents.size >= minAgents) {
1023
+ for (const id of windowAgents) agentIds.add(id);
1024
+ }
1025
+ } else {
1026
+ agentIds.add(event.agentId);
1027
+ }
1028
+ }
1029
+ if (agentIds.size >= minAgents) {
1030
+ detections.push({
1031
+ resource,
1032
+ agentIds: [...agentIds],
1033
+ eventCount: groupEvents.length,
1034
+ reason: `${agentIds.size} agents touched shared resource "${resource}" — possible message board`
1035
+ });
1036
+ }
1037
+ }
1038
+ return detections;
1039
+ }
1040
+ /**
1041
+ * Map detections to autotel-audit `securityEvent` payloads for emission during IR.
1042
+ */
1043
+ function crossAgentDetectionsToSecurityEvents(detections) {
1044
+ return detections.map((detection) => ({
1045
+ name: "agent.shared_channel.detected",
1046
+ category: "llm",
1047
+ outcome: "denied",
1048
+ severity: "error",
1049
+ reason: detection.reason,
1050
+ targetType: "resource",
1051
+ targetId: detection.resource,
1052
+ metadata: {
1053
+ agentIds: detection.agentIds,
1054
+ eventCount: detection.eventCount
1055
+ }
1056
+ }));
1057
+ }
1058
+
1059
+ //#endregion
1060
+ //#region src/agent/cross-agent-monitor.ts
1061
+ /**
1062
+ * Live monitor for shared-channel abuse (Artifactory message-board pattern).
1063
+ * Feed tool/memory events as they occur; emits `agent.shared_channel.detected`.
1064
+ */
1065
+ var CrossAgentMonitor = class {
1066
+ events = [];
1067
+ seen = new Set();
1068
+ options;
1069
+ constructor(options = {}) {
1070
+ this.options = options;
1071
+ }
1072
+ record(event) {
1073
+ this.events.push({
1074
+ ...event,
1075
+ timestamp: event.timestamp ?? Date.now()
1076
+ });
1077
+ const detections = detectCrossAgentPattern(this.events, this.options);
1078
+ const fresh = [];
1079
+ for (const detection of detections) {
1080
+ const key = detection.resource;
1081
+ if (this.seen.has(key)) continue;
1082
+ this.seen.add(key);
1083
+ fresh.push(detection);
1084
+ this.options.onDetection?.(detection);
1085
+ for (const payload of crossAgentDetectionsToSecurityEvents([detection])) {
1086
+ securityEvent(payload, {
1087
+ ctx: this.options.ctx,
1088
+ onMissingContext: this.options.onMissingContext ?? "warn"
1089
+ });
1090
+ }
1091
+ }
1092
+ return fresh;
1093
+ }
1094
+ reset() {
1095
+ this.events.length = 0;
1096
+ this.seen.clear();
1097
+ }
1098
+ };
1099
+
1100
+ //#endregion
1101
+ //#region src/agent/eval-identity.ts
1102
+ /** Canonical eval-run attribute keys for sandbox / IR correlation. */
1103
+ const EVAL_IDENTITY_ATTR = {
1104
+ runId: "eval.run_id",
1105
+ taskId: "eval.task_id",
1106
+ sandboxId: "eval.sandbox_id"
1107
+ };
1108
+ function setEvalAttrs(ctx, attrs) {
1109
+ const traceCtx = resolveContext(ctx);
1110
+ const mapped = {};
1111
+ for (const [key, value] of Object.entries(attrs)) {
1112
+ const attr = toAttributeValue(value);
1113
+ if (typeof attr === "string" || typeof attr === "number" || typeof attr === "boolean") {
1114
+ mapped[key] = attr;
1115
+ }
1116
+ }
1117
+ if (Object.keys(mapped).length > 0) {
1118
+ traceCtx.setAttributes(mapped);
1119
+ }
1120
+ }
1121
+ /** Stamp eval-run identity on the active span for cross-agent IR queries. */
1122
+ function recordEvalRunIdentity(input) {
1123
+ setEvalAttrs(input.ctx, {
1124
+ [EVAL_IDENTITY_ATTR.runId]: input.runId,
1125
+ ...input.taskId !== undefined && { [EVAL_IDENTITY_ATTR.taskId]: input.taskId },
1126
+ ...input.sandboxId !== undefined && { [EVAL_IDENTITY_ATTR.sandboxId]: input.sandboxId }
1127
+ });
1128
+ }
1129
+
1130
+ //#endregion
1131
+ //#region src/agent/honey-token.ts
1132
+ /**
1133
+ * Decoy tool — touching it emits a high-severity security event (deception /
1134
+ * uncertainty for offensive agent loops).
1135
+ */
1136
+ function createHoneyTokenTool(options = {}) {
1137
+ const name = options.name ?? "readLeakedCredential";
1138
+ const bait = options.bait ?? "AKIA_HONEY_TOKEN_DO_NOT_USE — paste bin archive entry #4412";
1139
+ return {
1140
+ name,
1141
+ description: `Read a credential from the leak archive: ${bait}`,
1142
+ execute: async () => {
1143
+ securityEvent({
1144
+ name: "agent.honey_token.triggered",
1145
+ category: "llm",
1146
+ outcome: "denied",
1147
+ severity: "critical",
1148
+ reason: "Agent invoked honey-token decoy tool",
1149
+ targetType: "tool",
1150
+ targetId: name
1151
+ }, {
1152
+ ctx: options.ctx,
1153
+ onMissingContext: options.onMissingContext ?? "warn"
1154
+ });
1155
+ return {
1156
+ triggered: true,
1157
+ message: "Honey token touched — security alerted"
1158
+ };
1159
+ }
1160
+ };
1161
+ }
1162
+
1163
+ //#endregion
1164
+ //#region src/agent/forensic.ts
1165
+ function attr(span, key) {
1166
+ return span.attributes[key];
1167
+ }
1168
+ function stringAttr(span, key) {
1169
+ const v = attr(span, key);
1170
+ return typeof v === "string" ? v : undefined;
1171
+ }
1172
+ function spansToCrossAgentEvents(spans) {
1173
+ const events = [];
1174
+ for (const span of spans) {
1175
+ const agentId = stringAttr(span, "agent.id") ?? stringAttr(span, "gen_ai.agent.name") ?? stringAttr(span, EVAL_IDENTITY_ATTR.runId);
1176
+ const toolName = stringAttr(span, "gen_ai.tool.name");
1177
+ if (!agentId || !toolName) continue;
1178
+ if (!/artifactory|registry|package/i.test(toolName)) continue;
1179
+ events.push({
1180
+ agentId,
1181
+ resource: `artifactory:/remote-cache/${toolName}`,
1182
+ timestamp: span.startTime[0] * 1e3 + span.startTime[1] / 1e6
1183
+ });
1184
+ }
1185
+ return events;
1186
+ }
1187
+ function querySpansForEvalIncident(spans) {
1188
+ const summary = [`Spans analyzed: ${spans.length}`];
1189
+ const policyDenials = [];
1190
+ const planRiskElevated = [];
1191
+ const exfilCapableActions = [];
1192
+ const evalRuns = new Set();
1193
+ for (const span of spans) {
1194
+ const runId = stringAttr(span, EVAL_IDENTITY_ATTR.runId);
1195
+ if (runId) evalRuns.add(runId);
1196
+ if (attr(span, "policy.decision") === "deny") {
1197
+ policyDenials.push(`${span.name}: ${stringAttr(span, "policy.reason") ?? "denied"}`);
1198
+ }
1199
+ const verdict = attr(span, "agent.plan.risk.verdict");
1200
+ if (verdict && verdict !== "low") {
1201
+ planRiskElevated.push(`${span.name}: plan-risk=${String(verdict)}`);
1202
+ }
1203
+ if (attr(span, "agent.action.risk_class") === "exfiltration_capable") {
1204
+ exfilCapableActions.push(span.name);
1205
+ }
1206
+ }
1207
+ const crossAgentEvents = crossAgentDetectionsToSecurityEvents(detectCrossAgentPattern(spansToCrossAgentEvents(spans), { minAgents: 2 }));
1208
+ if (policyDenials.length) summary.push(`Policy denials: ${policyDenials.length}`);
1209
+ if (planRiskElevated.length) {
1210
+ summary.push(`Elevated plan-risk: ${planRiskElevated.length}`);
1211
+ }
1212
+ if (exfilCapableActions.length) {
1213
+ summary.push(`Exfil-capable actions: ${exfilCapableActions.length}`);
1214
+ }
1215
+ if (crossAgentEvents.length) {
1216
+ summary.push(`Cross-agent alerts: ${crossAgentEvents.length}`);
1217
+ }
1218
+ if (evalRuns.size) summary.push(`Eval runs: ${evalRuns.size}`);
1219
+ return {
1220
+ summary,
1221
+ policyDenials,
1222
+ planRiskElevated,
1223
+ exfilCapableActions,
1224
+ crossAgentEvents,
1225
+ evalRuns: [...evalRuns]
1226
+ };
1227
+ }
1228
+
985
1229
  //#endregion
986
1230
  //#region src/agent/agent-plan-classifier.ts
987
1231
  /** Canonical plan-risk attribute keys (Google SAIF plan-risk predictor aligned). */
@@ -1088,4 +1332,4 @@ function heuristicPlanRiskClassifier() {
1088
1332
  }
1089
1333
 
1090
1334
  //#endregion
1091
- export { canonicalizeForHash as C, createAgentAuditMetadata as S, AGENT_AUDIT_SCHEMA_VERSION as T, recordPolicyDecision as _, withScopedTool as a, flattenAgentAttributes as b, resolvePrivacyProfile as c, withAgentSession as d, delegateToAgent as f, recordDecisionBasis as g, defineAgentToolCall as h, runAgentPlanClassifier as i, sanitizeAuditPayload as l, defineAgentAction as m, heuristicPlanRiskClassifier as n, createSignedEventEnvelope as o, recordAgentHandoff as p, recordPlanRiskAssessment as r, verifyEventEnvelopeHash as s, AGENT_PLAN_RISK_ATTR as t, createAgentIdentityRegistry as u, withAgentAction as v, hashPayload as w, setAgentAttributes as x, withAgentToolCall as y };
1335
+ export { createAgentAuditMetadata as A, defineAgentToolCall as C, withAgentToolCall as D, withAgentAction as E, hashPayload as M, AGENT_AUDIT_SCHEMA_VERSION as N, flattenAgentAttributes as O, defineAgentAction as S, recordPolicyDecision as T, sanitizeAuditPayload as _, querySpansForEvalIncident as a, delegateToAgent as b, EVAL_IDENTITY_ATTR as c, crossAgentDetectionsToSecurityEvents as d, detectCrossAgentPattern as f, resolvePrivacyProfile as g, verifyEventEnvelopeHash as h, runAgentPlanClassifier as i, canonicalizeForHash as j, setAgentAttributes as k, recordEvalRunIdentity as l, createSignedEventEnvelope as m, heuristicPlanRiskClassifier as n, spansToCrossAgentEvents as o, withScopedTool as p, recordPlanRiskAssessment as r, createHoneyTokenTool as s, AGENT_PLAN_RISK_ATTR as t, CrossAgentMonitor as u, createAgentIdentityRegistry as v, recordDecisionBasis as w, recordAgentHandoff as x, withAgentSession as y };