@darkhunt-security/endpoint-codex 0.9.4 → 0.9.6

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "darkhunt-guard",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "hooks": "./hooks/hooks.json",
5
5
  "description": "Darkhunt endpoint plugin for Codex CLI \u2014 full session trace capture and PreToolUse guardrails.",
6
6
  "author": {
@@ -18371,7 +18371,7 @@ var SessionEmitter = class {
18371
18371
  const root = this.ensureTrace(record.ts);
18372
18372
  const parentTrace = record.parentUuid ? this.owners.get(record.parentUuid) : void 0;
18373
18373
  let owner = parentTrace ?? root;
18374
- if (record.isSidechain && owner === root) {
18374
+ if (record.isSidechain && owner === root && this.options.agentId === void 0) {
18375
18375
  owner = this.seeded(["subagent", record.uuid], () => this.client.trace({
18376
18376
  name: "subagent",
18377
18377
  sessionId: this.options.sessionId,
@@ -18474,8 +18474,23 @@ var SessionEmitter = class {
18474
18474
  }
18475
18475
  await this.client.flush();
18476
18476
  }
18477
+ /**
18478
+ * Which subagent this transcript is, if any.
18479
+ *
18480
+ * From the path where the endpoint's layout says so, and otherwise from the file:
18481
+ * Codex names only the parent, so the subagent is identified by the thread the
18482
+ * transcript itself is — `seedKey`, which is exactly that.
18483
+ */
18484
+ agentId() {
18485
+ if (this.options.agentId !== void 0)
18486
+ return this.options.agentId;
18487
+ return this.grouping ? this.options.seedKey ?? this.options.sessionId : void 0;
18488
+ }
18489
+ agentType() {
18490
+ return this.options.agentType ?? this.meta["agentType"];
18491
+ }
18477
18492
  defaultTraceName() {
18478
- const agentType = this.options.agentType ?? this.meta["agentType"];
18493
+ const agentType = this.agentType();
18479
18494
  if (agentType)
18480
18495
  return `subagent: ${agentType}`;
18481
18496
  if (this.options.agentId === void 0) {
@@ -18496,8 +18511,12 @@ var SessionEmitter = class {
18496
18511
  tags: [this.options.vendor, ...this.options.agentId ? ["subagent"] : []],
18497
18512
  metadata: {
18498
18513
  ...this.meta,
18499
- ...this.options.agentId !== void 0 ? { agentId: this.options.agentId } : {},
18500
- ...this.options.agentType !== void 0 ? { agentType: this.options.agentType } : {}
18514
+ // `agent_id` / `agent_type`, not camelCase: trace-hub lifts each metadata
18515
+ // attribute onto the span under its own key, and the consumers that read an
18516
+ // agent out of a span already look for the snake_case names other producers
18517
+ // send. A camelCase key arrives intact and is never found.
18518
+ ...this.agentId() !== void 0 ? { agent_id: this.agentId() } : {},
18519
+ ...this.agentType() !== void 0 ? { agent_type: this.agentType() } : {}
18501
18520
  },
18502
18521
  ...this.options.userId !== void 0 ? { userId: this.options.userId } : {},
18503
18522
  ...this.options.userEmail !== void 0 ? { userEmail: this.options.userEmail } : {},
@@ -18371,7 +18371,7 @@ var SessionEmitter = class {
18371
18371
  const root = this.ensureTrace(record.ts);
18372
18372
  const parentTrace = record.parentUuid ? this.owners.get(record.parentUuid) : void 0;
18373
18373
  let owner = parentTrace ?? root;
18374
- if (record.isSidechain && owner === root) {
18374
+ if (record.isSidechain && owner === root && this.options.agentId === void 0) {
18375
18375
  owner = this.seeded(["subagent", record.uuid], () => this.client.trace({
18376
18376
  name: "subagent",
18377
18377
  sessionId: this.options.sessionId,
@@ -18474,8 +18474,23 @@ var SessionEmitter = class {
18474
18474
  }
18475
18475
  await this.client.flush();
18476
18476
  }
18477
+ /**
18478
+ * Which subagent this transcript is, if any.
18479
+ *
18480
+ * From the path where the endpoint's layout says so, and otherwise from the file:
18481
+ * Codex names only the parent, so the subagent is identified by the thread the
18482
+ * transcript itself is — `seedKey`, which is exactly that.
18483
+ */
18484
+ agentId() {
18485
+ if (this.options.agentId !== void 0)
18486
+ return this.options.agentId;
18487
+ return this.grouping ? this.options.seedKey ?? this.options.sessionId : void 0;
18488
+ }
18489
+ agentType() {
18490
+ return this.options.agentType ?? this.meta["agentType"];
18491
+ }
18477
18492
  defaultTraceName() {
18478
- const agentType = this.options.agentType ?? this.meta["agentType"];
18493
+ const agentType = this.agentType();
18479
18494
  if (agentType)
18480
18495
  return `subagent: ${agentType}`;
18481
18496
  if (this.options.agentId === void 0) {
@@ -18496,8 +18511,12 @@ var SessionEmitter = class {
18496
18511
  tags: [this.options.vendor, ...this.options.agentId ? ["subagent"] : []],
18497
18512
  metadata: {
18498
18513
  ...this.meta,
18499
- ...this.options.agentId !== void 0 ? { agentId: this.options.agentId } : {},
18500
- ...this.options.agentType !== void 0 ? { agentType: this.options.agentType } : {}
18514
+ // `agent_id` / `agent_type`, not camelCase: trace-hub lifts each metadata
18515
+ // attribute onto the span under its own key, and the consumers that read an
18516
+ // agent out of a span already look for the snake_case names other producers
18517
+ // send. A camelCase key arrives intact and is never found.
18518
+ ...this.agentId() !== void 0 ? { agent_id: this.agentId() } : {},
18519
+ ...this.agentType() !== void 0 ? { agent_type: this.agentType() } : {}
18501
18520
  },
18502
18521
  ...this.options.userId !== void 0 ? { userId: this.options.userId } : {},
18503
18522
  ...this.options.userEmail !== void 0 ? { userEmail: this.options.userEmail } : {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@darkhunt-security/endpoint-codex",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
4
  "type": "module",
5
5
  "description": "Darkhunt endpoint adapter for Codex CLI: hook codec, rollout transcript mapper, plugin manifest.",
6
6
  "bin": {