The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
Fix Elastic ingest pipeline to copy prompt.id alongside prompt.text
Cursor Agent02a57f19780f
diff --git a/cli/beacon/internal/endpoint/elastic/pack/ingest-pipeline.json b/cli/beacon/internal/endpoint/elastic/pack/ingest-pipeline.jsonindex 9ef8d87f..76604ca1 100644--- a/cli/beacon/internal/endpoint/elastic/pack/ingest-pipeline.json+++ b/cli/beacon/internal/endpoint/elastic/pack/ingest-pipeline.json@@ -38,7 +38,7 @@"script": {"description": "Copy Beacon fields to ECS and preserve native fields under beacon.*","lang": "painless",- "source": "Map ensure(Map parent, String key) { if (parent[key] == null || !(parent[key] instanceof Map)) { parent[key] = new HashMap(); } return parent[key]; } Map beacon = ensure(ctx, 'beacon'); if (ctx.vendor != null) { beacon.vendor = ctx.vendor; } if (ctx.product != null) { beacon.product = ctx.product; } if (ctx.schema_version != null) { beacon.schema_version = ctx.schema_version; } if (ctx.sequence != null) { beacon.sequence = ctx.sequence; } if (ctx.severity != null) { beacon.severity = ctx.severity; } if (ctx.field_truncated != null) { beacon.truncated = ctx.field_truncated; } Map agent = ensure(ctx, 'agent'); agent.name = 'beacon'; agent.type = 'endpoint-agent'; if (ctx.endpoint instanceof Map && ctx.endpoint.agent_version != null) { agent.version = ctx.endpoint.agent_version; } else if (ctx.schema_version != null) { agent.version = ctx.schema_version; } Map event = ensure(ctx, 'event'); event.kind = 'event'; if (ctx.event instanceof Map) { if (ctx.event.action != null) { event.action = ctx.event.action; } if (ctx.event.category != null) { event.category = [ctx.event.category.toString()]; } } if (ctx.severity != null) { Map sev = new HashMap(); sev.put('info', 2); sev.put('low', 3); sev.put('medium', 4); sev.put('high', 5); sev.put('critical', 6); String key = ctx.severity.toString().toLowerCase(); if (sev.containsKey(key)) { event.severity = sev[key]; } } if (ctx.endpoint instanceof Map) { Map host = ensure(ctx, 'host'); if (ctx.endpoint.hostname != null) { host.hostname = ctx.endpoint.hostname; host.name = ctx.endpoint.hostname; } if (ctx.endpoint.os != null) { Map os = ensure(host, 'os'); String osName = ctx.endpoint.os.toString(); os.family = osName; os.type = osName == 'darwin' ? 'macos' : osName; } } if (ctx.user instanceof Map) { Map user = ensure(ctx, 'user'); if (ctx.user.name != null) { user.name = ctx.user.name; } if (ctx.user.uid != null) { user.id = ctx.user.uid; } } if (ctx.harness instanceof Map) { Map harness = ensure(beacon, 'harness'); if (ctx.harness.name != null) { harness.name = ctx.harness.name; ensure(ctx, 'service').name = ctx.harness.name; } if (ctx.harness.version != null) { harness.version = ctx.harness.version; } if (ctx.harness.executable_path != null) { harness.executable_path = ctx.harness.executable_path; } if (ctx.harness.config_path != null) { harness.config_path = ctx.harness.config_path; } } if (ctx.session instanceof Map) { Map session = ensure(beacon, 'session'); if (ctx.session.id != null) { session.id = ctx.session.id; if (ctx.trace == null) { ctx.trace = new HashMap(); } if (ctx.trace.id == null && ctx.session.id.toString().length() == 32) { ctx.trace.id = ctx.session.id; } } if (ctx.session.working_directory != null) { ensure(ctx, 'process').working_directory = ctx.session.working_directory; } } if (ctx.tool instanceof Map) { Map tool = ensure(beacon, 'tool'); if (ctx.tool.name != null) { tool.name = ctx.tool.name; } Map process = ensure(ctx, 'process'); if (process.command_line == null && ctx.tool.command != null) { process.command_line = ctx.tool.command; } if (ctx.tool.path != null) { process.executable = ctx.tool.path; } } if (ctx.command instanceof Map) { Map process = ensure(ctx, 'process'); if (ctx.command.command != null) { process.command_line = ctx.command.command; } if (ctx.command.exit_code != null) { process.exit_code = ctx.command.exit_code; } if (ctx.command.duration_ms != null) { event.duration = ((long)ctx.command.duration_ms) * 1000000L; } } if (ctx.file instanceof Map) { Map file = ensure(ctx, 'file'); Map beaconFile = ensure(beacon, 'file'); if (ctx.file.path != null) { String p = ctx.file.path.toString(); file.path = p; int slash = p.lastIndexOf('/'); String name = slash >= 0 ? p.substring(slash + 1) : p; if (slash > 0) { file.directory = p.substring(0, slash); } file.name = name; int dot = name.lastIndexOf('.'); if (dot > 0 && dot < name.length() - 1) { file.extension = name.substring(dot + 1); } } if (ctx.file.diff_hash != null) { ensure(file, 'hash').sha256 = ctx.file.diff_hash; } if (ctx.file.diff_bytes != null) { file.size = ctx.file.diff_bytes; } if (ctx.file.operation != null) { beaconFile.operation = ctx.file.operation; } if (ctx.file.language != null) { beaconFile.language = ctx.file.language; } } if (ctx.mcp instanceof Map) { Map mcp = ensure(beacon, 'mcp'); if (ctx.mcp.server != null) { mcp.server = ctx.mcp.server; } if (ctx.mcp.tool != null) { mcp.tool = ctx.mcp.tool; } } if (ctx.approval instanceof Map) { Map approval = ensure(beacon, 'approval'); if (ctx.approval.required != null) { approval.required = ctx.approval.required; } if (ctx.approval.decision != null) { String decision = ctx.approval.decision.toString(); approval.decision = decision; if (decision == 'allow' || decision == 'approved') { event.outcome = 'success'; } else if (decision == 'deny' || decision == 'denied' || decision == 'block' || decision == 'blocked') { event.outcome = 'failure'; } } if (ctx.approval.reason != null) { approval.reason = ctx.approval.reason; } } if (ctx.policy instanceof Map) { Map policy = ensure(beacon, 'policy'); if (ctx.policy.id != null) { policy.id = ctx.policy.id; } if (ctx.policy.name != null) { policy.name = ctx.policy.name; } if (ctx.policy.decision != null) { policy.decision = ctx.policy.decision; } if (ctx.policy.enforcement != null) { policy.enforcement = ctx.policy.enforcement; } if (ctx.policy.reason != null) { policy.reason = ctx.policy.reason; } } if (ctx.prompt instanceof Map && ctx.prompt.text != null) { ensure(beacon, 'prompt').text = ctx.prompt.text; } if (ctx.content instanceof Map) { Map content = ensure(beacon, 'content'); if (ctx.content.retention != null) { content.retention = ctx.content.retention; } if (ctx.content.included != null) { content.included = ctx.content.included; } if (ctx.content.redacted != null) { content.redacted = ctx.content.redacted; } if (ctx.content.truncated != null) { content.truncated = ctx.content.truncated; } } if (ctx.destination instanceof Map) { Map destination = ensure(beacon, 'destination'); if (ctx.destination.type != null) { destination.type = ctx.destination.type; } if (ctx.destination.mode != null) { destination.mode = ctx.destination.mode; } if (ctx.destination.status != null) { destination.status = ctx.destination.status; } } if (ctx.health instanceof Map) { Map health = ensure(beacon, 'health'); if (ctx.health.component != null) { health.component = ctx.health.component; } if (ctx.health.status != null) { health.status = ctx.health.status; } if (ctx.health.reason != null) { health.reason = ctx.health.reason; } } if (ctx.model != null) { ensure(ensure(ctx, 'gen_ai'), 'request').model = ctx.model; } Map nativeVcs = ctx.vcs instanceof Map ? ctx.vcs : null; ctx.remove('vcs'); String vcsUrl = null; String vcsHeadName = null; String vcsRevision = null; if (nativeVcs != null) { beacon.vcs = nativeVcs; if (nativeVcs.repository instanceof Map && nativeVcs.repository.url instanceof Map && nativeVcs.repository.url.full != null) { vcsUrl = nativeVcs.repository.url.full.toString(); } if (nativeVcs.ref instanceof Map && nativeVcs.ref.head instanceof Map) { if (nativeVcs.ref.head.name != null) { vcsHeadName = nativeVcs.ref.head.name.toString(); } if (nativeVcs.ref.head.revision != null) { vcsRevision = nativeVcs.ref.head.revision.toString(); } } } if (vcsUrl == null && ctx.repository != null) { vcsUrl = ctx.repository.toString(); } if (vcsHeadName == null && ctx.branch != null) { vcsHeadName = ctx.branch.toString(); } if (vcsUrl != null) { ensure(ensure(ctx, 'vcs'), 'repository').url = vcsUrl; } if (vcsHeadName != null) { ensure(ensure(ensure(ctx, 'vcs'), 'ref'), 'head').name = vcsHeadName; } if (vcsRevision != null) { ensure(ensure(ensure(ctx, 'vcs'), 'ref'), 'head').revision = vcsRevision; } if (ctx.raw instanceof Map) { Map otel = ensure(beacon, 'otel'); if (ctx.raw.otel_signal != null) { otel.signal = ctx.raw.otel_signal; } if (ctx.raw.metric_name != null) { ensure(beacon, 'metric').name = ctx.raw.metric_name; if (event.action == null || event.action == 'metric.observed') { event.action = ctx.raw.metric_name; } } if (ctx.raw.metric_description != null) { otel.metric_description = ctx.raw.metric_description; } if (ctx.raw.metric_unit != null) { otel.metric_unit = ctx.raw.metric_unit; } if (ctx.raw.attribute_count != null) { otel.attribute_count = ctx.raw.attribute_count; } if (ctx.raw.attributes != null) { otel.attributes = ctx.raw.attributes; } }"+ "source": "Map ensure(Map parent, String key) { if (parent[key] == null || !(parent[key] instanceof Map)) { parent[key] = new HashMap(); } return parent[key]; } Map beacon = ensure(ctx, 'beacon'); if (ctx.vendor != null) { beacon.vendor = ctx.vendor; } if (ctx.product != null) { beacon.product = ctx.product; } if (ctx.schema_version != null) { beacon.schema_version = ctx.schema_version; } if (ctx.sequence != null) { beacon.sequence = ctx.sequence; } if (ctx.severity != null) { beacon.severity = ctx.severity; } if (ctx.field_truncated != null) { beacon.truncated = ctx.field_truncated; } Map agent = ensure(ctx, 'agent'); agent.name = 'beacon'; agent.type = 'endpoint-agent'; if (ctx.endpoint instanceof Map && ctx.endpoint.agent_version != null) { agent.version = ctx.endpoint.agent_version; } else if (ctx.schema_version != null) { agent.version = ctx.schema_version; } Map event = ensure(ctx, 'event'); event.kind = 'event'; if (ctx.event instanceof Map) { if (ctx.event.action != null) { event.action = ctx.event.action; } if (ctx.event.category != null) { event.category = [ctx.event.category.toString()]; } } if (ctx.severity != null) { Map sev = new HashMap(); sev.put('info', 2); sev.put('low', 3); sev.put('medium', 4); sev.put('high', 5); sev.put('critical', 6); String key = ctx.severity.toString().toLowerCase(); if (sev.containsKey(key)) { event.severity = sev[key]; } } if (ctx.endpoint instanceof Map) { Map host = ensure(ctx, 'host'); if (ctx.endpoint.hostname != null) { host.hostname = ctx.endpoint.hostname; host.name = ctx.endpoint.hostname; } if (ctx.endpoint.os != null) { Map os = ensure(host, 'os'); String osName = ctx.endpoint.os.toString(); os.family = osName; os.type = osName == 'darwin' ? 'macos' : osName; } } if (ctx.user instanceof Map) { Map user = ensure(ctx, 'user'); if (ctx.user.name != null) { user.name = ctx.user.name; } if (ctx.user.uid != null) { user.id = ctx.user.uid; } } if (ctx.harness instanceof Map) { Map harness = ensure(beacon, 'harness'); if (ctx.harness.name != null) { harness.name = ctx.harness.name; ensure(ctx, 'service').name = ctx.harness.name; } if (ctx.harness.version != null) { harness.version = ctx.harness.version; } if (ctx.harness.executable_path != null) { harness.executable_path = ctx.harness.executable_path; } if (ctx.harness.config_path != null) { harness.config_path = ctx.harness.config_path; } } if (ctx.session instanceof Map) { Map session = ensure(beacon, 'session'); if (ctx.session.id != null) { session.id = ctx.session.id; if (ctx.trace == null) { ctx.trace = new HashMap(); } if (ctx.trace.id == null && ctx.session.id.toString().length() == 32) { ctx.trace.id = ctx.session.id; } } if (ctx.session.working_directory != null) { ensure(ctx, 'process').working_directory = ctx.session.working_directory; } } if (ctx.tool instanceof Map) { Map tool = ensure(beacon, 'tool'); if (ctx.tool.name != null) { tool.name = ctx.tool.name; } Map process = ensure(ctx, 'process'); if (process.command_line == null && ctx.tool.command != null) { process.command_line = ctx.tool.command; } if (ctx.tool.path != null) { process.executable = ctx.tool.path; } } if (ctx.command instanceof Map) { Map process = ensure(ctx, 'process'); if (ctx.command.command != null) { process.command_line = ctx.command.command; } if (ctx.command.exit_code != null) { process.exit_code = ctx.command.exit_code; } if (ctx.command.duration_ms != null) { event.duration = ((long)ctx.command.duration_ms) * 1000000L; } } if (ctx.file instanceof Map) { Map file = ensure(ctx, 'file'); Map beaconFile = ensure(beacon, 'file'); if (ctx.file.path != null) { String p = ctx.file.path.toString(); file.path = p; int slash = p.lastIndexOf('/'); String name = slash >= 0 ? p.substring(slash + 1) : p; if (slash > 0) { file.directory = p.substring(0, slash); } file.name = name; int dot = name.lastIndexOf('.'); if (dot > 0 && dot < name.length() - 1) { file.extension = name.substring(dot + 1); } } if (ctx.file.diff_hash != null) { ensure(file, 'hash').sha256 = ctx.file.diff_hash; } if (ctx.file.diff_bytes != null) { file.size = ctx.file.diff_bytes; } if (ctx.file.operation != null) { beaconFile.operation = ctx.file.operation; } if (ctx.file.language != null) { beaconFile.language = ctx.file.language; } } if (ctx.mcp instanceof Map) { Map mcp = ensure(beacon, 'mcp'); if (ctx.mcp.server != null) { mcp.server = ctx.mcp.server; } if (ctx.mcp.tool != null) { mcp.tool = ctx.mcp.tool; } } if (ctx.approval instanceof Map) { Map approval = ensure(beacon, 'approval'); if (ctx.approval.required != null) { approval.required = ctx.approval.required; } if (ctx.approval.decision != null) { String decision = ctx.approval.decision.toString(); approval.decision = decision; if (decision == 'allow' || decision == 'approved') { event.outcome = 'success'; } else if (decision == 'deny' || decision == 'denied' || decision == 'block' || decision == 'blocked') { event.outcome = 'failure'; } } if (ctx.approval.reason != null) { approval.reason = ctx.approval.reason; } } if (ctx.policy instanceof Map) { Map policy = ensure(beacon, 'policy'); if (ctx.policy.id != null) { policy.id = ctx.policy.id; } if (ctx.policy.name != null) { policy.name = ctx.policy.name; } if (ctx.policy.decision != null) { policy.decision = ctx.policy.decision; } if (ctx.policy.enforcement != null) { policy.enforcement = ctx.policy.enforcement; } if (ctx.policy.reason != null) { policy.reason = ctx.policy.reason; } } if (ctx.prompt instanceof Map) { Map prompt = ensure(beacon, 'prompt'); if (ctx.prompt.id != null) { prompt.id = ctx.prompt.id; } if (ctx.prompt.text != null) { prompt.text = ctx.prompt.text; } } if (ctx.content instanceof Map) { Map content = ensure(beacon, 'content'); if (ctx.content.retention != null) { content.retention = ctx.content.retention; } if (ctx.content.included != null) { content.included = ctx.content.included; } if (ctx.content.redacted != null) { content.redacted = ctx.content.redacted; } if (ctx.content.truncated != null) { content.truncated = ctx.content.truncated; } } if (ctx.destination instanceof Map) { Map destination = ensure(beacon, 'destination'); if (ctx.destination.type != null) { destination.type = ctx.destination.type; } if (ctx.destination.mode != null) { destination.mode = ctx.destination.mode; } if (ctx.destination.status != null) { destination.status = ctx.destination.status; } } if (ctx.health instanceof Map) { Map health = ensure(beacon, 'health'); if (ctx.health.component != null) { health.component = ctx.health.component; } if (ctx.health.status != null) { health.status = ctx.health.status; } if (ctx.health.reason != null) { health.reason = ctx.health.reason; } } if (ctx.model != null) { ensure(ensure(ctx, 'gen_ai'), 'request').model = ctx.model; } Map nativeVcs = ctx.vcs instanceof Map ? ctx.vcs : null; ctx.remove('vcs'); String vcsUrl = null; String vcsHeadName = null; String vcsRevision = null; if (nativeVcs != null) { beacon.vcs = nativeVcs; if (nativeVcs.repository instanceof Map && nativeVcs.repository.url instanceof Map && nativeVcs.repository.url.full != null) { vcsUrl = nativeVcs.repository.url.full.toString(); } if (nativeVcs.ref instanceof Map && nativeVcs.ref.head instanceof Map) { if (nativeVcs.ref.head.name != null) { vcsHeadName = nativeVcs.ref.head.name.toString(); } if (nativeVcs.ref.head.revision != null) { vcsRevision = nativeVcs.ref.head.revision.toString(); } } } if (vcsUrl == null && ctx.repository != null) { vcsUrl = ctx.repository.toString(); } if (vcsHeadName == null && ctx.branch != null) { vcsHeadName = ctx.branch.toString(); } if (vcsUrl != null) { ensure(ensure(ctx, 'vcs'), 'repository').url = vcsUrl; } if (vcsHeadName != null) { ensure(ensure(ensure(ctx, 'vcs'), 'ref'), 'head').name = vcsHeadName; } if (vcsRevision != null) { ensure(ensure(ensure(ctx, 'vcs'), 'ref'), 'head').revision = vcsRevision; } if (ctx.raw instanceof Map) { Map otel = ensure(beacon, 'otel'); if (ctx.raw.otel_signal != null) { otel.signal = ctx.raw.otel_signal; } if (ctx.raw.metric_name != null) { ensure(beacon, 'metric').name = ctx.raw.metric_name; if (event.action == null || event.action == 'metric.observed') { event.action = ctx.raw.metric_name; } } if (ctx.raw.metric_description != null) { otel.metric_description = ctx.raw.metric_description; } if (ctx.raw.metric_unit != null) { otel.metric_unit = ctx.raw.metric_unit; } if (ctx.raw.attribute_count != null) { otel.attribute_count = ctx.raw.attribute_count; } if (ctx.raw.attributes != null) { otel.attributes = ctx.raw.attributes; } }"}},{