@agenttrail/cli 0.1.0 → 0.2.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.
@@ -1944,7 +1944,7 @@ function createCompiledLabelMatcher(pattern) {
1944
1944
  compiledLabelCache.set(pattern, matcher);
1945
1945
  }
1946
1946
  const cached = matcher;
1947
- return (label) => cached(label);
1947
+ return (label2) => cached(label2);
1948
1948
  }
1949
1949
  function createCompiledDetailMatcher(pattern) {
1950
1950
  let compiled = compiledDetailCache.get(pattern);
@@ -2637,8 +2637,8 @@ function credentialsPath(homeDir, agent = "claude") {
2637
2637
  function noCredentialFor(agent) {
2638
2638
  throw new Error(`AgentTrail has no credential file for the agent ${JSON.stringify(agent)}.`);
2639
2639
  }
2640
- function readCredentials(homeDir, io = {}, agent = "claude") {
2641
- const read = io.readFile ?? ((p) => readFileSync3(p, "utf8"));
2640
+ function readCredentials(homeDir, io2 = {}, agent = "claude") {
2641
+ const read = io2.readFile ?? ((p) => readFileSync3(p, "utf8"));
2642
2642
  try {
2643
2643
  const parsed = JSON.parse(read(credentialsPath(homeDir, agent)));
2644
2644
  if (!isCredentials(parsed)) return null;
@@ -2696,12 +2696,12 @@ function queueFolderFor(home, projectKey) {
2696
2696
  }
2697
2697
 
2698
2698
  // src/cursor/enforcement-record.ts
2699
- function readEnforcementRecord(home, io = nodeCaptureFileIO) {
2699
+ function readEnforcementRecord(home, io2 = nodeCaptureFileIO) {
2700
2700
  let value;
2701
2701
  try {
2702
2702
  const path = cursorPaths(home).enforcement;
2703
- if (!io.exists(path)) return void 0;
2704
- value = JSON.parse(io.readFile(path).toString("utf8"));
2703
+ if (!io2.exists(path)) return void 0;
2704
+ value = JSON.parse(io2.readFile(path).toString("utf8"));
2705
2705
  } catch {
2706
2706
  return void 0;
2707
2707
  }
@@ -2751,11 +2751,11 @@ var EMPTY_REGISTRY = Object.freeze({
2751
2751
  v: 1,
2752
2752
  projects: Object.freeze({})
2753
2753
  });
2754
- function readRegistryAt(path, isProjectRecord2, io = nodeCaptureFileIO) {
2754
+ function readRegistryAt(path, isProjectRecord2, io2 = nodeCaptureFileIO) {
2755
2755
  let text;
2756
2756
  try {
2757
- if (!io.exists(path)) return { kind: "missing" };
2758
- text = io.readFile(path).toString("utf8");
2757
+ if (!io2.exists(path)) return { kind: "missing" };
2758
+ text = io2.readFile(path).toString("utf8");
2759
2759
  } catch {
2760
2760
  return { kind: "unreadable" };
2761
2761
  }
@@ -2823,8 +2823,8 @@ function isProjectRecord(key, value) {
2823
2823
  if (!isRecord3(value)) return false;
2824
2824
  return value.projectKey === key && isString2(value.root) && isString2(value.transcriptFolder) && isString2(value.orgId) && isString2(value.projectSlug) && isString2(value.projectId) && PROJECT_SOURCES.has(value.projectSource) && typeof value.projectLabel === "string" && (value.developerId === void 0 || typeof value.developerId === "string") && typeof value.captureContent === "boolean" && isInstall(value.install) && isString2(value.registeredAt) && (value.subfolders === void 0 || Array.isArray(value.subfolders) && value.subfolders.every(isSubfolder));
2825
2825
  }
2826
- function readRegistry(home, io = nodeCaptureFileIO) {
2827
- return readRegistryAt(cursorPaths(home).projects, isProjectRecord, io);
2826
+ function readRegistry(home, io2 = nodeCaptureFileIO) {
2827
+ return readRegistryAt(cursorPaths(home).projects, isProjectRecord, io2);
2828
2828
  }
2829
2829
  function findProjectForWorkspace2(registry, workspaceRoots, projectDirEnv) {
2830
2830
  return findProjectForWorkspace(registry, workspaceRoots, projectDirEnv);
@@ -2880,8 +2880,8 @@ function cursorScopeFor(record, agentId) {
2880
2880
  vendor: CURSOR_VENDOR_SLUG
2881
2881
  };
2882
2882
  }
2883
- function resolveCursorPepConfig(home, io, credentialsIO) {
2884
- const record = readEnforcementRecord(home, io ?? nodeCaptureFileIO);
2883
+ function resolveCursorPepConfig(home, io2, credentialsIO) {
2884
+ const record = readEnforcementRecord(home, io2 ?? nodeCaptureFileIO);
2885
2885
  if (record === void 0 || !record.enabled) return void 0;
2886
2886
  const creds = readCredentials(home, credentialsIO, "cursor");
2887
2887
  const token = creds?.ingest_token;
@@ -3066,8 +3066,8 @@ async function holdForApproval(args, fetchFn) {
3066
3066
  }
3067
3067
  throw new PdpUnreachableError("hold 200 with malformed outcome");
3068
3068
  }
3069
- function readCachedSnapshot(path, io = {}) {
3070
- const read = io.readFile ?? ((p) => readFileSync4(p, "utf8"));
3069
+ function readCachedSnapshot(path, io2 = {}) {
3070
+ const read = io2.readFile ?? ((p) => readFileSync4(p, "utf8"));
3071
3071
  try {
3072
3072
  const parsed = JSON.parse(read(path));
3073
3073
  return isCompiledSnapshot(parsed) ? parsed : null;
@@ -3137,10 +3137,10 @@ function argsHashFor(args, key) {
3137
3137
  const digest = createHmac("sha256", key).update(sortedJson(args), "utf8").digest("hex");
3138
3138
  return `${ARGS_HASH_PREFIX}${digest.slice(0, ARGS_HASH_HEX)}`;
3139
3139
  }
3140
- function readCaptureQueueKey(home, stateDir, io = nodeCaptureFileIO) {
3140
+ function readCaptureQueueKey(home, stateDir, io2 = nodeCaptureFileIO) {
3141
3141
  let bytes;
3142
3142
  try {
3143
- bytes = io.readFile(capturePaths(home, stateDir).queueKey);
3143
+ bytes = io2.readFile(capturePaths(home, stateDir).queueKey);
3144
3144
  } catch {
3145
3145
  return void 0;
3146
3146
  }
@@ -3152,8 +3152,8 @@ function argsHashForCall(vendorTool, firstCandidateArgs, toolInput, key) {
3152
3152
  const args = isCursorMcpCall(vendorTool) ? { full_command: serializeMcpInput(toolInput) } : firstCandidateArgs;
3153
3153
  return argsHashFor(args, key);
3154
3154
  }
3155
- function readQueueKey(home, io = nodeCaptureFileIO) {
3156
- return readCaptureQueueKey(home, CURSOR_STATE_DIR, io);
3155
+ function readQueueKey(home, io2 = nodeCaptureFileIO) {
3156
+ return readCaptureQueueKey(home, CURSOR_STATE_DIR, io2);
3157
3157
  }
3158
3158
 
3159
3159
  // src/backfill/content.ts
@@ -3307,7 +3307,7 @@ var SCRUB_PATTERNS = [
3307
3307
  tier: "standard",
3308
3308
  regex: AWS_SECRET_ACCESS_KEY,
3309
3309
  // Preserve the key name (group 1) + the original separator (group 2, incl. the
3310
- // value's opening quote); redact only the 40-char value (group 3). TEC-904:
3310
+ // value's opening quote); redact only the 40-char value (group 3). Why:
3311
3311
  // emitting g[2] instead of a hard-coded `=` keeps `key: "val"` from being
3312
3312
  // rewritten to `key="val` (dangling quote) and preserves `=`-form output.
3313
3313
  placeholder: (g) => `${g[1]}${g[2]}${redacted("secret:aws-secret")}`
@@ -3320,9 +3320,9 @@ var SCRUB_PATTERNS = [
3320
3320
  tier: "standard",
3321
3321
  regex: ENV_SECRET_ASSIGNMENT,
3322
3322
  // Preserve the key name (group 1) + the original separator (group 2); redact
3323
- // only the value (group 4/6/7). TEC-904: emitting g[2] instead of a hard-coded
3323
+ // only the value (group 4/6/7). Why: emitting g[2] instead of a hard-coded
3324
3324
  // `=` keeps `key: value` from being rewritten to `key=value`.
3325
- // TEC-534: the match also consumes the value's quotes, so re-emit them around
3325
+ // Quotes: the match also consumes the value's quotes, so re-emit them around
3326
3326
  // the placeholder — g[3]/g[5] is the opening quote for the double-/single-
3327
3327
  // quoted branch, and empty for an unquoted value. Without this the output is
3328
3328
  // not valid JSON or YAML (see the exact-output tests).
@@ -3571,9 +3571,9 @@ function scrubAttributes(attributes, resolved, options = {}) {
3571
3571
  // src/capture/queue-record.ts
3572
3572
  var CONTENT_VALUE_CAP = 8192;
3573
3573
  var QUEUE_ENTRY_CAP = 1e4;
3574
- function queueEntryCount(io, folder) {
3574
+ function queueEntryCount(io2, folder) {
3575
3575
  try {
3576
- return io.readdir(folder).filter((name) => name.endsWith(".json")).length;
3576
+ return io2.readdir(folder).filter((name) => name.endsWith(".json")).length;
3577
3577
  } catch {
3578
3578
  return 0;
3579
3579
  }
@@ -3721,11 +3721,11 @@ function parseQueueEntry(text) {
3721
3721
  var SHELL_JOIN_WINDOW_MS = 3e4;
3722
3722
  var MCP_OBSERVED_WINDOW_MS = 6e4;
3723
3723
  function recentDecisions(query, windowMs) {
3724
- const io = query.io ?? nodeCaptureFileIO;
3724
+ const io2 = query.io ?? nodeCaptureFileIO;
3725
3725
  const folder = queueFolderFor(query.home, query.projectKey);
3726
3726
  let names;
3727
3727
  try {
3728
- names = io.readdir(folder);
3728
+ names = io2.readdir(folder);
3729
3729
  } catch {
3730
3730
  return [];
3731
3731
  }
@@ -3742,7 +3742,7 @@ function recentDecisions(query, windowMs) {
3742
3742
  for (const { name } of inWindow) {
3743
3743
  let text;
3744
3744
  try {
3745
- text = io.readFile(`${folder}/${name}`).toString("utf8");
3745
+ text = io2.readFile(`${folder}/${name}`).toString("utf8");
3746
3746
  } catch {
3747
3747
  continue;
3748
3748
  }
@@ -3770,17 +3770,17 @@ function readShellJoin(query) {
3770
3770
  return answer ?? { kind: "miss", liveHandoff };
3771
3771
  }
3772
3772
  function joinQueryFor(input) {
3773
- const io = input.io ?? nodeCaptureFileIO;
3774
- const key = readQueueKey(input.home, io);
3775
- const label = input.vendorTool ?? input.normalized?.vendorTool;
3773
+ const io2 = input.io ?? nodeCaptureFileIO;
3774
+ const key = readQueueKey(input.home, io2);
3775
+ const label2 = input.vendorTool ?? input.normalized?.vendorTool;
3776
3776
  const first = input.normalized?.candidates[0];
3777
3777
  return {
3778
3778
  home: input.home,
3779
- io,
3779
+ io: io2,
3780
3780
  projectKey: input.projectKey,
3781
3781
  conversationId: input.conversationId,
3782
3782
  generationId: input.generationId,
3783
- argsHash: key === void 0 || label === void 0 ? null : argsHashForCall(label, first?.args ?? {}, input.toolInput, key),
3783
+ argsHash: key === void 0 || label2 === void 0 ? null : argsHashForCall(label2, first?.args ?? {}, input.toolInput, key),
3784
3784
  nowMs: input.nowMs
3785
3785
  };
3786
3786
  }
@@ -3876,6 +3876,178 @@ function withScope(requests, scope) {
3876
3876
  return requests.map((request) => ({ ...request, scope }));
3877
3877
  }
3878
3878
 
3879
+ // src/pep/pending-decisions.ts
3880
+ import { randomUUID } from "crypto";
3881
+ import { mkdirSync as mkdirSync4, readdirSync as readdirSync2, readFileSync as readFileSync5, rmSync as rmSync2, writeFileSync as writeFileSync3 } from "fs";
3882
+ import { dirname as dirname4, join as join7 } from "path";
3883
+
3884
+ // ../policy-engine/src/action-shape.ts
3885
+ import { createHash as createHash3 } from "crypto";
3886
+ var ACTION_SHAPE_MAX_LENGTH = 512;
3887
+ var MAX_TOKENS = 24;
3888
+ var ARG = "<arg>";
3889
+ var SUBCOMMAND_DEPTH = {
3890
+ git: 1,
3891
+ docker: 1,
3892
+ kubectl: 1,
3893
+ npm: 1,
3894
+ pnpm: 1,
3895
+ yarn: 1,
3896
+ terraform: 1,
3897
+ aws: 2,
3898
+ gcloud: 2,
3899
+ gh: 2,
3900
+ helm: 1
3901
+ };
3902
+ var SECOND_LEVEL_AFTER = {
3903
+ docker: /* @__PURE__ */ new Set(["volume", "network", "image", "container", "compose", "system", "builder"])
3904
+ };
3905
+ var SYSTEM_BIN = /^\/(usr\/(local\/)?)?s?bin\/|^\/opt\/homebrew\/bin\//;
3906
+ var SUBCOMMAND_WORD = /^[a-z][a-z0-9-]{0,31}$/;
3907
+ var PROGRAM_WORD = /^[A-Za-z0-9._+-]{1,64}$/;
3908
+ function shapeFlag(token) {
3909
+ const eq = token.indexOf("=");
3910
+ const name = eq === -1 ? token : token.slice(0, eq);
3911
+ if (name.startsWith("--")) {
3912
+ return /^--[a-z0-9][a-z0-9-]{0,40}$/i.test(name) ? `${name}${eq === -1 ? "" : `=${ARG}`}` : ARG;
3913
+ }
3914
+ if (/^-[A-Za-z]{1,2}$/.test(name)) return name;
3915
+ if (/^-[A-Za-z]/.test(name)) return `${name.slice(0, 2)}${ARG}`;
3916
+ return ARG;
3917
+ }
3918
+ function shapeProgram(token) {
3919
+ if (token.includes("/")) {
3920
+ if (!SYSTEM_BIN.test(token)) return ARG;
3921
+ const base = token.slice(token.lastIndexOf("/") + 1);
3922
+ return PROGRAM_WORD.test(base) ? base.toLowerCase() : ARG;
3923
+ }
3924
+ return PROGRAM_WORD.test(token) ? token.toLowerCase() : ARG;
3925
+ }
3926
+ function firstCommand(command) {
3927
+ const head = command.split(/&&|\|\||;|\||\n/)[0] ?? "";
3928
+ const tokens = head.trim().split(/\s+/).filter(Boolean);
3929
+ let i = 0;
3930
+ while (i < tokens.length) {
3931
+ const t = tokens[i] ?? "";
3932
+ if (/^[A-Za-z_][A-Za-z0-9_]*=/.test(t)) {
3933
+ i++;
3934
+ continue;
3935
+ }
3936
+ if (t === "sudo" || t === "env" || t === "command" || t === "exec" || t === "time") {
3937
+ i++;
3938
+ continue;
3939
+ }
3940
+ break;
3941
+ }
3942
+ return tokens.slice(i, i + MAX_TOKENS);
3943
+ }
3944
+ function shapeCommand(command) {
3945
+ const stripped = command.replace(/^\s*cd\s+\S+\s*(&&|;)\s*/, "");
3946
+ const tokens = firstCommand(stripped);
3947
+ if (tokens.length === 0) return null;
3948
+ const program = shapeProgram(tokens[0] ?? "");
3949
+ const out = [program];
3950
+ let subcommandsLeft = SUBCOMMAND_DEPTH[program] ?? 0;
3951
+ const secondLevel = SECOND_LEVEL_AFTER[program];
3952
+ for (const token of tokens.slice(1)) {
3953
+ if (token.startsWith("-") && token.length > 1) {
3954
+ out.push(shapeFlag(token));
3955
+ subcommandsLeft = 0;
3956
+ continue;
3957
+ }
3958
+ if (subcommandsLeft > 0 && SUBCOMMAND_WORD.test(token)) {
3959
+ out.push(token);
3960
+ subcommandsLeft--;
3961
+ if (subcommandsLeft === 0 && secondLevel?.has(token) && out.length === 2) {
3962
+ subcommandsLeft = 1;
3963
+ }
3964
+ continue;
3965
+ }
3966
+ subcommandsLeft = 0;
3967
+ out.push(ARG);
3968
+ }
3969
+ return clamp(out.join(" "));
3970
+ }
3971
+ function clamp(shape) {
3972
+ if (shape.length <= ACTION_SHAPE_MAX_LENGTH) return shape;
3973
+ const cut = shape.slice(0, ACTION_SHAPE_MAX_LENGTH);
3974
+ return cut.slice(0, cut.lastIndexOf(" "));
3975
+ }
3976
+ function redactedActionShape(tool, args) {
3977
+ if (tool.startsWith("mcp__")) return null;
3978
+ const command = args.full_command ?? args.detail;
3979
+ if (typeof command === "string" && command.trim() !== "") {
3980
+ if (tool === "WebSearch") return null;
3981
+ return shapeCommand(command);
3982
+ }
3983
+ if (typeof args.file_path === "string" && args.file_path !== "") return "<path>";
3984
+ return null;
3985
+ }
3986
+
3987
+ // src/pep/pending-decisions.ts
3988
+ var PENDING_DECISIONS_CAP = 500;
3989
+ var DIR_MODE = 448;
3990
+ var FILE_MODE = 384;
3991
+ var LABEL_MAX = 255;
3992
+ var realIO = {
3993
+ mkdir: (p, mode) => mkdirSync4(p, { recursive: true, mode }),
3994
+ writeFile: (p, content, mode) => writeFileSync3(p, content, { mode }),
3995
+ readDir: (p) => readdirSync2(p),
3996
+ readFile: (p) => readFileSync5(p, "utf8"),
3997
+ remove: (p) => rmSync2(p, { force: true })
3998
+ };
3999
+ function io(over) {
4000
+ return { ...realIO, ...over ?? {} };
4001
+ }
4002
+ function pendingDecisionsDir(snapshotPath) {
4003
+ return join7(dirname4(snapshotPath), "pending-decisions");
4004
+ }
4005
+ function label(v) {
4006
+ return typeof v === "string" && v.length > 0 && v.length <= LABEL_MAX ? v : void 0;
4007
+ }
4008
+ function shapeOnlyArgs(tool, args) {
4009
+ const shape = redactedActionShape(tool, args);
4010
+ if (shape === null) return {};
4011
+ if (shape === "<path>" && args.full_command === void 0) return { file_path: shape };
4012
+ return { full_command: shape };
4013
+ }
4014
+ function toUploadItem(d, now = /* @__PURE__ */ new Date(), id = randomUUID()) {
4015
+ const correlationId = label(d.request.correlation_id);
4016
+ const sessionId = label(d.request.session_id);
4017
+ return {
4018
+ id,
4019
+ policy_id: d.policyId,
4020
+ verdict: d.verdict,
4021
+ tool: d.request.tool.slice(0, LABEL_MAX),
4022
+ args: shapeOnlyArgs(d.request.tool, d.request.args),
4023
+ ...d.request.kind !== void 0 ? { kind: d.request.kind } : {},
4024
+ ...d.request.scope !== void 0 ? { scope: d.request.scope } : {},
4025
+ ...sessionId !== void 0 ? { session_id: sessionId } : {},
4026
+ ...correlationId !== void 0 ? { correlation_id: correlationId } : {},
4027
+ decided_at: now.toISOString()
4028
+ };
4029
+ }
4030
+ function queueOfflineDecision(snapshotPath, d, opts = {}) {
4031
+ try {
4032
+ const fs = io(opts.io);
4033
+ const dir = pendingDecisionsDir(snapshotPath);
4034
+ fs.mkdir(dir, DIR_MODE);
4035
+ let count = 0;
4036
+ try {
4037
+ count = fs.readDir(dir).filter((f) => f.endsWith(".json")).length;
4038
+ } catch {
4039
+ count = 0;
4040
+ }
4041
+ if (count >= PENDING_DECISIONS_CAP) return false;
4042
+ const item = toUploadItem(d, opts.now);
4043
+ const stamp = String(Date.parse(item.decided_at)).padStart(15, "0");
4044
+ fs.writeFile(join7(dir, `${stamp}-${item.id}.json`), JSON.stringify(item), FILE_MODE);
4045
+ return true;
4046
+ } catch {
4047
+ return false;
4048
+ }
4049
+ }
4050
+
3879
4051
  // src/pep/hook-shim.ts
3880
4052
  var HOOK_OUTCOMES = Object.keys({
3881
4053
  deny: 0,
@@ -3987,6 +4159,8 @@ function buildPdpRequest(payload, scope) {
3987
4159
  }
3988
4160
  const agentId = scope?.agent_id;
3989
4161
  const projectId = scope?.project_id;
4162
+ const correlationId = pdpLabel(payload.tool_use_id);
4163
+ const sessionId = pdpLabel(payload.session_id);
3990
4164
  return {
3991
4165
  tool,
3992
4166
  args,
@@ -3994,9 +4168,14 @@ function buildPdpRequest(payload, scope) {
3994
4168
  ...agentId !== void 0 ? { agent_id: agentId } : {},
3995
4169
  ...projectId !== void 0 ? { project_id: projectId } : {},
3996
4170
  vendor: PEP_VENDOR
3997
- }
4171
+ },
4172
+ ...correlationId !== void 0 ? { correlation_id: correlationId } : {},
4173
+ ...sessionId !== void 0 ? { session_id: sessionId } : {}
3998
4174
  };
3999
4175
  }
4176
+ function pdpLabel(value) {
4177
+ return typeof value === "string" && value.length > 0 && value.length <= 255 ? value : void 0;
4178
+ }
4000
4179
  async function mapVerdict(payload, response, cfg, deps) {
4001
4180
  switch (response.verdict) {
4002
4181
  case "allow": {
@@ -4021,7 +4200,14 @@ function failClosedViaSnapshot(_payload, request, cfg, deps) {
4021
4200
  reason: "AgentTrail PDP is unreachable and no local policy snapshot is cached; failing closed."
4022
4201
  };
4023
4202
  }
4024
- const { verdict, decidingName } = evaluateLocally(snapshot, request, cfg.orgId);
4203
+ const { verdict, decidingName, decidingPolicyId } = evaluateLocally(snapshot, request, cfg.orgId);
4204
+ if ((verdict === "deny" || verdict === "require_approval") && decidingPolicyId) {
4205
+ (deps.queueOffline ?? queueOfflineDecision)(cfg.snapshotPath, {
4206
+ policyId: decidingPolicyId,
4207
+ verdict,
4208
+ request
4209
+ });
4210
+ }
4025
4211
  if (verdict === "deny") {
4026
4212
  return {
4027
4213
  decision: "deny",
@@ -4061,6 +4247,7 @@ function evaluateLocally(snapshot, request, orgId) {
4061
4247
  return {
4062
4248
  verdict,
4063
4249
  decidingName: policyId ? byId.get(policyId)?.name ?? null : null,
4250
+ decidingPolicyId: policyId,
4064
4251
  matches,
4065
4252
  names
4066
4253
  };
@@ -4072,7 +4259,7 @@ async function decide(payload, cfg, deps) {
4072
4259
  if (!cfg.url || !cfg.token) {
4073
4260
  return {
4074
4261
  decision: "deny",
4075
- reason: "AgentTrail enforcement is enabled but misconfigured (missing PDP URL or token); failing closed. Re-run `npx -y @agenttrail/cli@latest setup --agent claude`."
4262
+ reason: "AgentTrail enforcement is on here (AGENTTRAIL_PEP_ENFORCE=1) but has no PDP URL or token, so it fails closed. If this repo's committed .claude/settings.json sets AGENTTRAIL_PEP_ENFORCE, remove it from that file; otherwise run `npx -y @agenttrail/cli@latest setup --agent claude` in this repo."
4076
4263
  };
4077
4264
  }
4078
4265
  const request = buildPdpRequest(payload, cfg.scope);
@@ -4392,12 +4579,12 @@ function outcomeOf(perCandidate, via) {
4392
4579
  via
4393
4580
  };
4394
4581
  }
4395
- function decideCursorShell(join7, cfg, deps, request) {
4396
- if (join7.kind === "handoff") {
4582
+ function decideCursorShell(join8, cfg, deps, request) {
4583
+ if (join8.kind === "handoff") {
4397
4584
  return { kind: "approval", message: "AgentTrail is waiting for approval of this command." };
4398
4585
  }
4399
- if (join7.kind === "decided") return { kind: "none" };
4400
- if (join7.liveHandoff) {
4586
+ if (join8.kind === "decided") return { kind: "none" };
4587
+ if (join8.liveHandoff) {
4401
4588
  return { kind: "approval", message: "AgentTrail is waiting for approval in this turn." };
4402
4589
  }
4403
4590
  const snapshot = readCachedSnapshot(cfg.snapshotPath, deps.snapshotIO);
@@ -4515,7 +4702,7 @@ async function answerCursor(deps, startedAtMs) {
4515
4702
  }
4516
4703
  if (event === "beforeShellExecution") {
4517
4704
  const request = normalized?.candidates[0];
4518
- const join7 = (deps.shellJoin ?? readShellJoin)(
4705
+ const join8 = (deps.shellJoin ?? readShellJoin)(
4519
4706
  joinQueryFor({
4520
4707
  home: deps.home,
4521
4708
  io: deps.io,
@@ -4529,7 +4716,7 @@ async function answerCursor(deps, startedAtMs) {
4529
4716
  })
4530
4717
  );
4531
4718
  const outcome = decideCursorShell(
4532
- join7,
4719
+ join8,
4533
4720
  cfg,
4534
4721
  deps,
4535
4722
  request === void 0 ? void 0 : { tool: request.tool, args: { ...request.args } }
@@ -4538,17 +4725,17 @@ async function answerCursor(deps, startedAtMs) {
4538
4725
  verdict: verdictOf(outcome),
4539
4726
  // This checkpoint asks no one: it answers from the queue, or from the cached rules
4540
4727
  // when the queue has nothing to say.
4541
- via: join7.kind === "miss" ? "cached-rules" : "pdp"
4728
+ via: join8.kind === "miss" ? "cached-rules" : "pdp"
4542
4729
  });
4543
4730
  }
4544
4731
  const requests = buildCursorPdpRequest(payload);
4545
4732
  if (requests === void 0 || normalized === void 0) {
4546
- const label = cursorVendorTool(payload);
4547
- const mcp = label?.startsWith(CURSOR_MCP_PREFIX);
4733
+ const label2 = cursorVendorTool(payload);
4734
+ const mcp = label2?.startsWith(CURSOR_MCP_PREFIX);
4548
4735
  return record(CURSOR_NO_OPINION, {
4549
4736
  verdict: "observed",
4550
4737
  via: "pdp",
4551
- ...mcp === true && label !== void 0 ? { vendorTool: label, toolUseId: correlationIdFor(payload.tool_use_id) } : (
4738
+ ...mcp === true && label2 !== void 0 ? { vendorTool: label2, toolUseId: correlationIdFor(payload.tool_use_id) } : (
4552
4739
  // Not an MCP call and not mappable: nothing to record it under, and nothing
4553
4740
  // will look for it.
4554
4741
  {}