autotel-genai 0.4.2 → 0.6.1
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/README.md +71 -0
- package/dist/agent/index.cjs +9 -1
- package/dist/agent/index.d.cts +3 -3
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +2 -2
- package/dist/{agent-CnXNAj9B.cjs → agent-CpucMj6w.cjs} +310 -14
- package/dist/{agent-oCfaqmYw.js → agent-DYs6JLN5.js} +263 -15
- package/dist/agent-security-BFryrFbk.d.cts +367 -0
- package/dist/agent-security-CWkxz1j3.d.ts +367 -0
- package/dist/ai-sdk-bridge.cjs +1 -1
- package/dist/ai-sdk-bridge.d.cts +8 -7
- package/dist/ai-sdk-bridge.d.ts +8 -7
- package/dist/ai-sdk-bridge.js +1 -1
- package/dist/{attributes-C7k871NW.d.cts → attributes-BHxFjXSS.d.cts} +1 -1
- package/dist/{attributes-BSunBoIR.cjs → attributes-BbHetlqB.cjs} +24 -19
- package/dist/{attributes-DCv1cxKZ.js → attributes-CVOD1BG1.js} +24 -19
- package/dist/{attributes-jUO1pbUc.d.ts → attributes-DyCFltYK.d.ts} +1 -1
- package/dist/{events-CXHe4AL7.d.ts → events-DpASz90I.d.ts} +1 -1
- package/dist/{events-Diz0gxop.d.cts → events-RGl-M4u9.d.cts} +1 -1
- package/dist/events.cjs +6 -5
- package/dist/events.d.cts +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/events.js +6 -5
- package/dist/{index-Lg3gQ_VO.d.ts → index-C-Ovf1nB.d.ts} +152 -24
- package/dist/index-CCECca0b.d.ts +1735 -0
- package/dist/{index-Bgt8apSM.d.cts → index-Ii-vG7B4.d.cts} +152 -24
- package/dist/index-PH_ymlyO.d.cts +1735 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +3 -3
- package/dist/observer/index.cjs +2 -1
- package/dist/observer/index.d.cts +2 -2
- package/dist/observer/index.d.ts +2 -2
- package/dist/observer/index.js +2 -2
- package/dist/{observer-BoQNdbkg.cjs → observer-Cic24A8t.cjs} +366 -26
- package/dist/{observer-Ckha9xGv.js → observer-JHxvq8sM.js} +356 -22
- package/dist/{semconv-B6zNvJ73.d.cts → semconv-B8OQQKbC.d.cts} +8 -0
- package/dist/{semconv-B6zNvJ73.d.ts → semconv-B8OQQKbC.d.ts} +8 -0
- package/dist/semconv.cjs +8 -0
- package/dist/semconv.d.cts +1 -1
- package/dist/semconv.d.ts +1 -1
- package/dist/semconv.js +8 -0
- package/dist/trace.cjs +12 -15
- package/dist/trace.d.cts +2 -2
- package/dist/trace.d.ts +2 -2
- package/dist/trace.js +8 -11
- package/dist/values-CLNajs9_.js +41 -0
- package/dist/values-m4hAgUuq.cjs +83 -0
- package/package.json +3 -3
- package/dist/agent-security-BHdP6ZPG.d.cts +0 -115
- package/dist/agent-security-BHdP6ZPG.d.ts +0 -115
- package/dist/index-D010Y_xS.d.ts +0 -472
- 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
|
package/dist/agent/index.cjs
CHANGED
|
@@ -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-
|
|
3
|
+
const require_agent = require('../agent-CpucMj6w.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;
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as canonicalizeForHash, A as verifyEventEnvelopeHash, B as defineAgentToolCall, C as CrossAgentSecurityEvent, D as withScopedTool, E as detectCrossAgentPattern, 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, P as ProvisionAgentIdentityInput, Q as HashPayloadOptions, R as withAgentSession, S as CrossAgentEvent, T as crossAgentDetectionsToSecurityEvents, U as withAgentAction, V as recordDecisionBasis, W as withAgentToolCall, X as setAgentAttributes, Y as flattenAgentAttributes, Z as createAgentAuditMetadata, _ as RecordEvalRunIdentityInput, a as AgentPlanRiskVerdict, b as CrossAgentMonitorOptions, c as recordPlanRiskAssessment, d as querySpansForEvalIncident, et as hashPayload, f as spansToCrossAgentEvents, g as EVAL_IDENTITY_ATTR, h as createHoneyTokenTool, i as AgentPlanClassifierResult, j as PrivacyProfileInput, k as createSignedEventEnvelope, l as runAgentPlanClassifier, m as HoneyTokenToolOptions, n as AgentPlanClassifier, o as RecordPlanRiskAssessmentOptions, p as HoneyTokenToolDefinition, q as delegateToAgent, r as AgentPlanClassifierInput, s as heuristicPlanRiskClassifier, t as AGENT_PLAN_RISK_ATTR, tt as AGENT_AUDIT_SCHEMA_VERSION, u as EvalIncidentQueryResult, v as recordEvalRunIdentity, w as DetectCrossAgentPatternOptions, x as CrossAgentDetection, y as CrossAgentMonitor, z as defineAgentAction } from "../index-PH_ymlyO.cjs";
|
|
2
2
|
import { a as TokenUsage, i as ModelPricing } from "../cost-C1FkUNG1.cjs";
|
|
3
|
-
import { C as recordPlanStep, D as
|
|
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 };
|
|
3
|
+
import { $ as ScopedToolDefinition, A as AgentAuditEventEnvelope, B as AgentSessionActionMetadata, C as recordPlanStep, D as AgentActionMetadata, E as AgentActionFactory, F as AgentIdentityRecord, G as AiLifecycleStage, H as AgentSessionStatus, I as AgentIdentityRegistry, J as GovernanceMetadata, K as DelegationContext, L as AgentIdentityStatus, M as AgentEventKind, N as AgentHandler, O as AgentActionOptions, P as AgentIdentity, Q as PrivacyProfileName, R as AgentMetadataInput, S as recordMemoryAccess, T as tryRecordHumanApproval, U as AgentToolCallActionMetadata, V as AgentSessionMetadata, W as AgentToolCallOptions, X as PolicyMetadata, Y as PolicyDecision, Z as PrivacyProfile, _ as recordActionRiskClass, a as AgentInputProvenance, b as recordHumanApproval, c as AgentSecurityRecordOptions, d as RecordHumanApprovalInput, et as ToolCallMetadata, f as RecordInputProvenanceInput, g as deriveActionRiskClass, h as RecordRenderOutputInput, i as AgentConsentOutcome, j as AgentDecisionMetadata, k as AgentAiMetadata, l as RecordActiveScopesInput, m as RecordPlanStepInput, n as ActionRiskHints, nt as AgentContext, o as AgentMemoryOperation, p as RecordMemoryAccessInput, r as AgentActionRiskClass, rt as agentContextFromSpan, s as AgentOutputFormat, t as AGENT_SECURITY_ATTR, tt as ToolStatus, u as RecordControllerInput, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId, z as AgentOutcome } from "../agent-security-BFryrFbk.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 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 };
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as canonicalizeForHash, A as verifyEventEnvelopeHash, B as defineAgentToolCall, C as CrossAgentSecurityEvent, D as withScopedTool, E as detectCrossAgentPattern, 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, P as ProvisionAgentIdentityInput, Q as HashPayloadOptions, R as withAgentSession, S as CrossAgentEvent, T as crossAgentDetectionsToSecurityEvents, U as withAgentAction, V as recordDecisionBasis, W as withAgentToolCall, X as setAgentAttributes, Y as flattenAgentAttributes, Z as createAgentAuditMetadata, _ as RecordEvalRunIdentityInput, a as AgentPlanRiskVerdict, b as CrossAgentMonitorOptions, c as recordPlanRiskAssessment, d as querySpansForEvalIncident, et as hashPayload, f as spansToCrossAgentEvents, g as EVAL_IDENTITY_ATTR, h as createHoneyTokenTool, i as AgentPlanClassifierResult, j as PrivacyProfileInput, k as createSignedEventEnvelope, l as runAgentPlanClassifier, m as HoneyTokenToolOptions, n as AgentPlanClassifier, o as RecordPlanRiskAssessmentOptions, p as HoneyTokenToolDefinition, q as delegateToAgent, r as AgentPlanClassifierInput, s as heuristicPlanRiskClassifier, t as AGENT_PLAN_RISK_ATTR, tt as AGENT_AUDIT_SCHEMA_VERSION, u as EvalIncidentQueryResult, v as recordEvalRunIdentity, w as DetectCrossAgentPatternOptions, x as CrossAgentDetection, y as CrossAgentMonitor, z as defineAgentAction } from "../index-CCECca0b.js";
|
|
2
2
|
import { a as TokenUsage, i as ModelPricing } from "../cost-C1FkUNG1.js";
|
|
3
|
-
import { C as recordPlanStep, D as
|
|
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 };
|
|
3
|
+
import { $ as ScopedToolDefinition, A as AgentAuditEventEnvelope, B as AgentSessionActionMetadata, C as recordPlanStep, D as AgentActionMetadata, E as AgentActionFactory, F as AgentIdentityRecord, G as AiLifecycleStage, H as AgentSessionStatus, I as AgentIdentityRegistry, J as GovernanceMetadata, K as DelegationContext, L as AgentIdentityStatus, M as AgentEventKind, N as AgentHandler, O as AgentActionOptions, P as AgentIdentity, Q as PrivacyProfileName, R as AgentMetadataInput, S as recordMemoryAccess, T as tryRecordHumanApproval, U as AgentToolCallActionMetadata, V as AgentSessionMetadata, W as AgentToolCallOptions, X as PolicyMetadata, Y as PolicyDecision, Z as PrivacyProfile, _ as recordActionRiskClass, a as AgentInputProvenance, b as recordHumanApproval, c as AgentSecurityRecordOptions, d as RecordHumanApprovalInput, et as ToolCallMetadata, f as RecordInputProvenanceInput, g as deriveActionRiskClass, h as RecordRenderOutputInput, i as AgentConsentOutcome, j as AgentDecisionMetadata, k as AgentAiMetadata, l as RecordActiveScopesInput, m as RecordPlanStepInput, n as ActionRiskHints, nt as AgentContext, o as AgentMemoryOperation, p as RecordMemoryAccessInput, r as AgentActionRiskClass, rt as agentContextFromSpan, s as AgentOutputFormat, t as AGENT_SECURITY_ATTR, tt as ToolStatus, u as RecordControllerInput, v as recordActiveScopes, w as recordRenderOutput, x as recordInputProvenance, y as recordControllerId, z as AgentOutcome } from "../agent-security-CWkxz1j3.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 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 };
|
package/dist/agent/index.js
CHANGED
|
@@ -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
|
|
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-DYs6JLN5.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,6 @@
|
|
|
1
1
|
const require_cost = require('./cost.cjs');
|
|
2
|
-
const require_attributes = require('./attributes-
|
|
2
|
+
const require_attributes = require('./attributes-BbHetlqB.cjs');
|
|
3
|
+
const require_values = require('./values-m4hAgUuq.cjs');
|
|
3
4
|
const require_agent_security = require('./agent-security-kfpXuwL4.cjs');
|
|
4
5
|
let autotel = require("autotel");
|
|
5
6
|
let autotel_audit = require("autotel-audit");
|
|
@@ -758,11 +759,10 @@ const PRIVACY_PROFILES = {
|
|
|
758
759
|
}
|
|
759
760
|
};
|
|
760
761
|
function maskValue(value) {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
return `${value.slice(0, 3)}***${value.slice(-3)}`;
|
|
762
|
+
const text = require_values.asString(value);
|
|
763
|
+
if (text === undefined) return "<masked>";
|
|
764
|
+
if (text.length <= 6) return "***";
|
|
765
|
+
return `${text.slice(0, 3)}***${text.slice(-3)}`;
|
|
766
766
|
}
|
|
767
767
|
function matches(patterns, key) {
|
|
768
768
|
return patterns?.some((pattern) => pattern.test(key)) ?? false;
|
|
@@ -787,19 +787,23 @@ function sanitizeNode(value, profile, keyPath) {
|
|
|
787
787
|
if (matches(profile.maskKeys, lowered)) {
|
|
788
788
|
return maskValue(value);
|
|
789
789
|
}
|
|
790
|
-
|
|
791
|
-
|
|
790
|
+
const text = require_values.asString(value);
|
|
791
|
+
if (text !== undefined) {
|
|
792
|
+
return truncateString(text, profile.maxStringLength);
|
|
792
793
|
}
|
|
793
794
|
if (Array.isArray(value)) {
|
|
794
795
|
return value.map((entry, index) => sanitizeNode(entry, profile, `${keyPath}[${index}]`));
|
|
795
796
|
}
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
797
|
+
const record = require_values.asRecord(value);
|
|
798
|
+
if (record) {
|
|
799
|
+
const out = {};
|
|
800
|
+
for (const [key, entry] of Object.entries(record)) {
|
|
801
|
+
out[key] = sanitizeNode(entry, profile, keyPath ? `${keyPath}.${key}` : key);
|
|
802
|
+
}
|
|
803
|
+
return out;
|
|
801
804
|
}
|
|
802
|
-
return value;
|
|
805
|
+
if (typeof value === "bigint") return value.toString(10);
|
|
806
|
+
return require_values.asNumber(value) ?? require_values.asBoolean(value) ?? (value === null ? null : undefined);
|
|
803
807
|
}
|
|
804
808
|
function resolvePrivacyProfile(profile = "strict") {
|
|
805
809
|
return typeof profile === "string" ? PRIVACY_PROFILES[profile] : profile;
|
|
@@ -982,6 +986,250 @@ async function withScopedTool(definition, input, fn, options = {}) {
|
|
|
982
986
|
}, fn, options);
|
|
983
987
|
}
|
|
984
988
|
|
|
989
|
+
//#endregion
|
|
990
|
+
//#region src/agent/cross-agent-detect.ts
|
|
991
|
+
function groupKey(event) {
|
|
992
|
+
return event.isolationKey ? `memory:${event.isolationKey}` : `resource:${event.resource}`;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Detect shared-channel usage across agent identities. Pure function — safe to
|
|
996
|
+
* run over exported span batches or audit logs in incident replay.
|
|
997
|
+
*/
|
|
998
|
+
function detectCrossAgentPattern(events, options = {}) {
|
|
999
|
+
const { minAgents = 2, windowMs = 864e5 } = options;
|
|
1000
|
+
const grouped = new Map();
|
|
1001
|
+
for (const event of events) {
|
|
1002
|
+
const key = groupKey(event);
|
|
1003
|
+
const existing = grouped.get(key);
|
|
1004
|
+
if (existing) {
|
|
1005
|
+
existing.events.push(event);
|
|
1006
|
+
} else {
|
|
1007
|
+
grouped.set(key, {
|
|
1008
|
+
resource: event.resource,
|
|
1009
|
+
events: [event]
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
const detections = [];
|
|
1014
|
+
for (const { resource, events: groupEvents } of grouped.values()) {
|
|
1015
|
+
const sorted = windowMs > 0 ? groupEvents.toSorted((a, b) => (a.timestamp ?? 0) - (b.timestamp ?? 0)) : groupEvents;
|
|
1016
|
+
const agentIds = new Set();
|
|
1017
|
+
for (const event of sorted) {
|
|
1018
|
+
const ts = event.timestamp ?? Date.now();
|
|
1019
|
+
if (windowMs > 0) {
|
|
1020
|
+
const windowStart = ts - windowMs;
|
|
1021
|
+
const inWindow = sorted.filter((e) => {
|
|
1022
|
+
const eTs = e.timestamp ?? Date.now();
|
|
1023
|
+
return eTs >= windowStart && eTs <= ts;
|
|
1024
|
+
});
|
|
1025
|
+
const windowAgents = new Set(inWindow.map((e) => e.agentId));
|
|
1026
|
+
if (windowAgents.size >= minAgents) {
|
|
1027
|
+
for (const id of windowAgents) agentIds.add(id);
|
|
1028
|
+
}
|
|
1029
|
+
} else {
|
|
1030
|
+
agentIds.add(event.agentId);
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (agentIds.size >= minAgents) {
|
|
1034
|
+
detections.push({
|
|
1035
|
+
resource,
|
|
1036
|
+
agentIds: [...agentIds],
|
|
1037
|
+
eventCount: groupEvents.length,
|
|
1038
|
+
reason: `${agentIds.size} agents touched shared resource "${resource}" — possible message board`
|
|
1039
|
+
});
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return detections;
|
|
1043
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* Map detections to autotel-audit `securityEvent` payloads for emission during IR.
|
|
1046
|
+
*/
|
|
1047
|
+
function crossAgentDetectionsToSecurityEvents(detections) {
|
|
1048
|
+
return detections.map((detection) => ({
|
|
1049
|
+
name: "agent.shared_channel.detected",
|
|
1050
|
+
category: "llm",
|
|
1051
|
+
outcome: "denied",
|
|
1052
|
+
severity: "error",
|
|
1053
|
+
reason: detection.reason,
|
|
1054
|
+
targetType: "resource",
|
|
1055
|
+
targetId: detection.resource,
|
|
1056
|
+
metadata: {
|
|
1057
|
+
agentIds: detection.agentIds,
|
|
1058
|
+
eventCount: detection.eventCount
|
|
1059
|
+
}
|
|
1060
|
+
}));
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
//#endregion
|
|
1064
|
+
//#region src/agent/cross-agent-monitor.ts
|
|
1065
|
+
/**
|
|
1066
|
+
* Live monitor for shared-channel abuse (Artifactory message-board pattern).
|
|
1067
|
+
* Feed tool/memory events as they occur; emits `agent.shared_channel.detected`.
|
|
1068
|
+
*/
|
|
1069
|
+
var CrossAgentMonitor = class {
|
|
1070
|
+
events = [];
|
|
1071
|
+
seen = new Set();
|
|
1072
|
+
options;
|
|
1073
|
+
constructor(options = {}) {
|
|
1074
|
+
this.options = options;
|
|
1075
|
+
}
|
|
1076
|
+
record(event) {
|
|
1077
|
+
this.events.push({
|
|
1078
|
+
...event,
|
|
1079
|
+
timestamp: event.timestamp ?? Date.now()
|
|
1080
|
+
});
|
|
1081
|
+
const detections = detectCrossAgentPattern(this.events, this.options);
|
|
1082
|
+
const fresh = [];
|
|
1083
|
+
for (const detection of detections) {
|
|
1084
|
+
const key = detection.resource;
|
|
1085
|
+
if (this.seen.has(key)) continue;
|
|
1086
|
+
this.seen.add(key);
|
|
1087
|
+
fresh.push(detection);
|
|
1088
|
+
this.options.onDetection?.(detection);
|
|
1089
|
+
for (const payload of crossAgentDetectionsToSecurityEvents([detection])) {
|
|
1090
|
+
(0, autotel_audit.securityEvent)(payload, {
|
|
1091
|
+
ctx: this.options.ctx,
|
|
1092
|
+
onMissingContext: this.options.onMissingContext ?? "warn"
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
return fresh;
|
|
1097
|
+
}
|
|
1098
|
+
reset() {
|
|
1099
|
+
this.events.length = 0;
|
|
1100
|
+
this.seen.clear();
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
//#endregion
|
|
1105
|
+
//#region src/agent/eval-identity.ts
|
|
1106
|
+
/** Canonical eval-run attribute keys for sandbox / IR correlation. */
|
|
1107
|
+
const EVAL_IDENTITY_ATTR = {
|
|
1108
|
+
runId: "eval.run_id",
|
|
1109
|
+
taskId: "eval.task_id",
|
|
1110
|
+
sandboxId: "eval.sandbox_id"
|
|
1111
|
+
};
|
|
1112
|
+
function setEvalAttrs(ctx, attrs) {
|
|
1113
|
+
const traceCtx = require_agent_security.resolveContext(ctx);
|
|
1114
|
+
const mapped = {};
|
|
1115
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
1116
|
+
const attr = require_agent_security.toAttributeValue(value);
|
|
1117
|
+
if (typeof attr === "string" || typeof attr === "number" || typeof attr === "boolean") {
|
|
1118
|
+
mapped[key] = attr;
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
if (Object.keys(mapped).length > 0) {
|
|
1122
|
+
traceCtx.setAttributes(mapped);
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
/** Stamp eval-run identity on the active span for cross-agent IR queries. */
|
|
1126
|
+
function recordEvalRunIdentity(input) {
|
|
1127
|
+
setEvalAttrs(input.ctx, {
|
|
1128
|
+
[EVAL_IDENTITY_ATTR.runId]: input.runId,
|
|
1129
|
+
...input.taskId !== undefined && { [EVAL_IDENTITY_ATTR.taskId]: input.taskId },
|
|
1130
|
+
...input.sandboxId !== undefined && { [EVAL_IDENTITY_ATTR.sandboxId]: input.sandboxId }
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
//#endregion
|
|
1135
|
+
//#region src/agent/honey-token.ts
|
|
1136
|
+
/**
|
|
1137
|
+
* Decoy tool — touching it emits a high-severity security event (deception /
|
|
1138
|
+
* uncertainty for offensive agent loops).
|
|
1139
|
+
*/
|
|
1140
|
+
function createHoneyTokenTool(options = {}) {
|
|
1141
|
+
const name = options.name ?? "readLeakedCredential";
|
|
1142
|
+
const bait = options.bait ?? "AKIA_HONEY_TOKEN_DO_NOT_USE — paste bin archive entry #4412";
|
|
1143
|
+
return {
|
|
1144
|
+
name,
|
|
1145
|
+
description: `Read a credential from the leak archive: ${bait}`,
|
|
1146
|
+
execute: async () => {
|
|
1147
|
+
(0, autotel_audit.securityEvent)({
|
|
1148
|
+
name: "agent.honey_token.triggered",
|
|
1149
|
+
category: "llm",
|
|
1150
|
+
outcome: "denied",
|
|
1151
|
+
severity: "critical",
|
|
1152
|
+
reason: "Agent invoked honey-token decoy tool",
|
|
1153
|
+
targetType: "tool",
|
|
1154
|
+
targetId: name
|
|
1155
|
+
}, {
|
|
1156
|
+
ctx: options.ctx,
|
|
1157
|
+
onMissingContext: options.onMissingContext ?? "warn"
|
|
1158
|
+
});
|
|
1159
|
+
return {
|
|
1160
|
+
triggered: true,
|
|
1161
|
+
message: "Honey token touched — security alerted"
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
//#endregion
|
|
1168
|
+
//#region src/agent/forensic.ts
|
|
1169
|
+
function attr(span, key) {
|
|
1170
|
+
return span.attributes[key];
|
|
1171
|
+
}
|
|
1172
|
+
function stringAttr(span, key) {
|
|
1173
|
+
const v = attr(span, key);
|
|
1174
|
+
return typeof v === "string" ? v : undefined;
|
|
1175
|
+
}
|
|
1176
|
+
function spansToCrossAgentEvents(spans) {
|
|
1177
|
+
const events = [];
|
|
1178
|
+
for (const span of spans) {
|
|
1179
|
+
const agentId = stringAttr(span, "agent.id") ?? stringAttr(span, "gen_ai.agent.name") ?? stringAttr(span, EVAL_IDENTITY_ATTR.runId);
|
|
1180
|
+
const toolName = stringAttr(span, "gen_ai.tool.name");
|
|
1181
|
+
if (!agentId || !toolName) continue;
|
|
1182
|
+
if (!/artifactory|registry|package/i.test(toolName)) continue;
|
|
1183
|
+
events.push({
|
|
1184
|
+
agentId,
|
|
1185
|
+
resource: `artifactory:/remote-cache/${toolName}`,
|
|
1186
|
+
timestamp: span.startTime[0] * 1e3 + span.startTime[1] / 1e6
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
return events;
|
|
1190
|
+
}
|
|
1191
|
+
function querySpansForEvalIncident(spans) {
|
|
1192
|
+
const summary = [`Spans analyzed: ${spans.length}`];
|
|
1193
|
+
const policyDenials = [];
|
|
1194
|
+
const planRiskElevated = [];
|
|
1195
|
+
const exfilCapableActions = [];
|
|
1196
|
+
const evalRuns = new Set();
|
|
1197
|
+
for (const span of spans) {
|
|
1198
|
+
const runId = stringAttr(span, EVAL_IDENTITY_ATTR.runId);
|
|
1199
|
+
if (runId) evalRuns.add(runId);
|
|
1200
|
+
if (attr(span, "policy.decision") === "deny") {
|
|
1201
|
+
policyDenials.push(`${span.name}: ${stringAttr(span, "policy.reason") ?? "denied"}`);
|
|
1202
|
+
}
|
|
1203
|
+
const verdict = attr(span, "agent.plan.risk.verdict");
|
|
1204
|
+
if (verdict && verdict !== "low") {
|
|
1205
|
+
planRiskElevated.push(`${span.name}: plan-risk=${String(verdict)}`);
|
|
1206
|
+
}
|
|
1207
|
+
if (attr(span, "agent.action.risk_class") === "exfiltration_capable") {
|
|
1208
|
+
exfilCapableActions.push(span.name);
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
const crossAgentEvents = crossAgentDetectionsToSecurityEvents(detectCrossAgentPattern(spansToCrossAgentEvents(spans), { minAgents: 2 }));
|
|
1212
|
+
if (policyDenials.length) summary.push(`Policy denials: ${policyDenials.length}`);
|
|
1213
|
+
if (planRiskElevated.length) {
|
|
1214
|
+
summary.push(`Elevated plan-risk: ${planRiskElevated.length}`);
|
|
1215
|
+
}
|
|
1216
|
+
if (exfilCapableActions.length) {
|
|
1217
|
+
summary.push(`Exfil-capable actions: ${exfilCapableActions.length}`);
|
|
1218
|
+
}
|
|
1219
|
+
if (crossAgentEvents.length) {
|
|
1220
|
+
summary.push(`Cross-agent alerts: ${crossAgentEvents.length}`);
|
|
1221
|
+
}
|
|
1222
|
+
if (evalRuns.size) summary.push(`Eval runs: ${evalRuns.size}`);
|
|
1223
|
+
return {
|
|
1224
|
+
summary,
|
|
1225
|
+
policyDenials,
|
|
1226
|
+
planRiskElevated,
|
|
1227
|
+
exfilCapableActions,
|
|
1228
|
+
crossAgentEvents,
|
|
1229
|
+
evalRuns: [...evalRuns]
|
|
1230
|
+
};
|
|
1231
|
+
}
|
|
1232
|
+
|
|
985
1233
|
//#endregion
|
|
986
1234
|
//#region src/agent/agent-plan-classifier.ts
|
|
987
1235
|
/** Canonical plan-risk attribute keys (Google SAIF plan-risk predictor aligned). */
|
|
@@ -1100,6 +1348,18 @@ Object.defineProperty(exports, 'AGENT_PLAN_RISK_ATTR', {
|
|
|
1100
1348
|
return AGENT_PLAN_RISK_ATTR;
|
|
1101
1349
|
}
|
|
1102
1350
|
});
|
|
1351
|
+
Object.defineProperty(exports, 'CrossAgentMonitor', {
|
|
1352
|
+
enumerable: true,
|
|
1353
|
+
get: function () {
|
|
1354
|
+
return CrossAgentMonitor;
|
|
1355
|
+
}
|
|
1356
|
+
});
|
|
1357
|
+
Object.defineProperty(exports, 'EVAL_IDENTITY_ATTR', {
|
|
1358
|
+
enumerable: true,
|
|
1359
|
+
get: function () {
|
|
1360
|
+
return EVAL_IDENTITY_ATTR;
|
|
1361
|
+
}
|
|
1362
|
+
});
|
|
1103
1363
|
Object.defineProperty(exports, 'canonicalizeForHash', {
|
|
1104
1364
|
enumerable: true,
|
|
1105
1365
|
get: function () {
|
|
@@ -1118,12 +1378,24 @@ Object.defineProperty(exports, 'createAgentIdentityRegistry', {
|
|
|
1118
1378
|
return createAgentIdentityRegistry;
|
|
1119
1379
|
}
|
|
1120
1380
|
});
|
|
1381
|
+
Object.defineProperty(exports, 'createHoneyTokenTool', {
|
|
1382
|
+
enumerable: true,
|
|
1383
|
+
get: function () {
|
|
1384
|
+
return createHoneyTokenTool;
|
|
1385
|
+
}
|
|
1386
|
+
});
|
|
1121
1387
|
Object.defineProperty(exports, 'createSignedEventEnvelope', {
|
|
1122
1388
|
enumerable: true,
|
|
1123
1389
|
get: function () {
|
|
1124
1390
|
return createSignedEventEnvelope;
|
|
1125
1391
|
}
|
|
1126
1392
|
});
|
|
1393
|
+
Object.defineProperty(exports, 'crossAgentDetectionsToSecurityEvents', {
|
|
1394
|
+
enumerable: true,
|
|
1395
|
+
get: function () {
|
|
1396
|
+
return crossAgentDetectionsToSecurityEvents;
|
|
1397
|
+
}
|
|
1398
|
+
});
|
|
1127
1399
|
Object.defineProperty(exports, 'defineAgentAction', {
|
|
1128
1400
|
enumerable: true,
|
|
1129
1401
|
get: function () {
|
|
@@ -1142,6 +1414,12 @@ Object.defineProperty(exports, 'delegateToAgent', {
|
|
|
1142
1414
|
return delegateToAgent;
|
|
1143
1415
|
}
|
|
1144
1416
|
});
|
|
1417
|
+
Object.defineProperty(exports, 'detectCrossAgentPattern', {
|
|
1418
|
+
enumerable: true,
|
|
1419
|
+
get: function () {
|
|
1420
|
+
return detectCrossAgentPattern;
|
|
1421
|
+
}
|
|
1422
|
+
});
|
|
1145
1423
|
Object.defineProperty(exports, 'flattenAgentAttributes', {
|
|
1146
1424
|
enumerable: true,
|
|
1147
1425
|
get: function () {
|
|
@@ -1160,6 +1438,12 @@ Object.defineProperty(exports, 'heuristicPlanRiskClassifier', {
|
|
|
1160
1438
|
return heuristicPlanRiskClassifier;
|
|
1161
1439
|
}
|
|
1162
1440
|
});
|
|
1441
|
+
Object.defineProperty(exports, 'querySpansForEvalIncident', {
|
|
1442
|
+
enumerable: true,
|
|
1443
|
+
get: function () {
|
|
1444
|
+
return querySpansForEvalIncident;
|
|
1445
|
+
}
|
|
1446
|
+
});
|
|
1163
1447
|
Object.defineProperty(exports, 'recordAgentHandoff', {
|
|
1164
1448
|
enumerable: true,
|
|
1165
1449
|
get: function () {
|
|
@@ -1172,6 +1456,12 @@ Object.defineProperty(exports, 'recordDecisionBasis', {
|
|
|
1172
1456
|
return recordDecisionBasis;
|
|
1173
1457
|
}
|
|
1174
1458
|
});
|
|
1459
|
+
Object.defineProperty(exports, 'recordEvalRunIdentity', {
|
|
1460
|
+
enumerable: true,
|
|
1461
|
+
get: function () {
|
|
1462
|
+
return recordEvalRunIdentity;
|
|
1463
|
+
}
|
|
1464
|
+
});
|
|
1175
1465
|
Object.defineProperty(exports, 'recordPlanRiskAssessment', {
|
|
1176
1466
|
enumerable: true,
|
|
1177
1467
|
get: function () {
|
|
@@ -1208,6 +1498,12 @@ Object.defineProperty(exports, 'setAgentAttributes', {
|
|
|
1208
1498
|
return setAgentAttributes;
|
|
1209
1499
|
}
|
|
1210
1500
|
});
|
|
1501
|
+
Object.defineProperty(exports, 'spansToCrossAgentEvents', {
|
|
1502
|
+
enumerable: true,
|
|
1503
|
+
get: function () {
|
|
1504
|
+
return spansToCrossAgentEvents;
|
|
1505
|
+
}
|
|
1506
|
+
});
|
|
1211
1507
|
Object.defineProperty(exports, 'verifyEventEnvelopeHash', {
|
|
1212
1508
|
enumerable: true,
|
|
1213
1509
|
get: function () {
|