@agenttrail/cli 0.2.24 → 0.2.29
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 +7 -0
- package/dist/chunk-4ZPQGE47.js +219 -0
- package/dist/cli/index.cjs +65 -60
- package/dist/cli/index.js +1 -1
- package/dist/cursor/capture-hook.mjs +7 -7
- package/dist/cursor/flush.mjs +16 -13
- package/dist/cursor/pep-hook.mjs +160 -37
- package/dist/index.cjs +64 -59
- package/dist/index.d.cts +21 -17
- package/dist/index.d.ts +21 -17
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/plugin/.claude-plugin/marketplace.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/scripts/pep-hook.mjs +160 -37
- package/dist/chunk-5PHWHBOC.js +0 -214
package/dist/index.d.cts
CHANGED
|
@@ -28,7 +28,7 @@ declare function writeCredentials(homeDir: string, creds: DeviceCredentials, io?
|
|
|
28
28
|
declare function clearCredentials(homeDir: string, io?: CredentialsIO, agent?: AgentChoice): void;
|
|
29
29
|
|
|
30
30
|
declare const AGENTTRAIL_API_ENDPOINT: "https://api.agenttrail.sh";
|
|
31
|
-
type FetchFn$
|
|
31
|
+
type FetchFn$2 = (url: string, init?: {
|
|
32
32
|
method?: string;
|
|
33
33
|
headers?: Record<string, string>;
|
|
34
34
|
body?: string;
|
|
@@ -38,10 +38,10 @@ type FetchFn$1 = (url: string, init?: {
|
|
|
38
38
|
json: () => Promise<unknown>;
|
|
39
39
|
}>;
|
|
40
40
|
type SleepFn = (ms: number) => Promise<void>;
|
|
41
|
-
declare function startDeviceAuth(apiEndpoint: string, fetchFn?: FetchFn$
|
|
41
|
+
declare function startDeviceAuth(apiEndpoint: string, fetchFn?: FetchFn$2, request?: DeviceAuthStartRequest): Promise<DeviceAuthStartResponse>;
|
|
42
42
|
interface PollOptions {
|
|
43
43
|
readonly interval: number;
|
|
44
|
-
readonly fetchFn?: FetchFn$
|
|
44
|
+
readonly fetchFn?: FetchFn$2;
|
|
45
45
|
readonly sleepFn?: SleepFn;
|
|
46
46
|
readonly openedAt?: number;
|
|
47
47
|
readonly expiresIn: number;
|
|
@@ -50,8 +50,8 @@ interface PollOptions {
|
|
|
50
50
|
readonly deviceFields?: DeviceAuthDeviceFields;
|
|
51
51
|
}
|
|
52
52
|
declare function pollDeviceToken(apiEndpoint: string, deviceCode: string, opts: PollOptions): Promise<DeviceAuthTokenResponse>;
|
|
53
|
-
declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$
|
|
54
|
-
declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$
|
|
53
|
+
declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$2, deviceFields?: DeviceAuthDeviceFields): Promise<DeviceAuthTokenResponse>;
|
|
54
|
+
declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$2): Promise<boolean>;
|
|
55
55
|
|
|
56
56
|
declare const DEFAULT_LOCK_STALE_MS = 30000;
|
|
57
57
|
interface LockIO {
|
|
@@ -116,7 +116,7 @@ interface LoginEnv {
|
|
|
116
116
|
readonly global?: boolean;
|
|
117
117
|
readonly setup?: boolean;
|
|
118
118
|
readonly host: string;
|
|
119
|
-
readonly fetchFn?: FetchFn$
|
|
119
|
+
readonly fetchFn?: FetchFn$2;
|
|
120
120
|
readonly sleepFn?: SleepFn;
|
|
121
121
|
readonly now?: () => number;
|
|
122
122
|
readonly openBrowser?: (url: string) => void;
|
|
@@ -436,7 +436,7 @@ interface SpanNode {
|
|
|
436
436
|
}
|
|
437
437
|
declare function buildSpanTree(session: ParsedSession): SpanNode[];
|
|
438
438
|
|
|
439
|
-
type FetchFn = typeof fetch;
|
|
439
|
+
type FetchFn$1 = typeof fetch;
|
|
440
440
|
|
|
441
441
|
interface RuntimeDirFs {
|
|
442
442
|
readonly mkdir: (p: string, mode: number) => Promise<unknown>;
|
|
@@ -465,14 +465,6 @@ interface DropMarksOptions {
|
|
|
465
465
|
readonly flushId?: string;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
interface PendingDecisionsIO {
|
|
469
|
-
readonly mkdir?: (p: string, mode: number) => void;
|
|
470
|
-
readonly writeFile?: (p: string, content: string, mode: number) => void;
|
|
471
|
-
readonly readDir?: (p: string) => string[];
|
|
472
|
-
readonly readFile?: (p: string) => string;
|
|
473
|
-
readonly remove?: (p: string) => void;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
468
|
interface PendingOutcomesFs {
|
|
477
469
|
readonly mkdir: (p: string, opts: {
|
|
478
470
|
recursive: true;
|
|
@@ -484,6 +476,7 @@ interface PendingOutcomesFs {
|
|
|
484
476
|
readonly unlink: (p: string) => Promise<void>;
|
|
485
477
|
}
|
|
486
478
|
|
|
479
|
+
type FetchFn = typeof fetch;
|
|
487
480
|
type OutcomeFlushStatus = "nothing_to_send" | "sent" | "credential_rejected" | "http_error" | "bad_response" | "unreachable" | "timeout" | "not_device_token" | "no_org";
|
|
488
481
|
interface OutcomeFlushResult {
|
|
489
482
|
readonly status: OutcomeFlushStatus;
|
|
@@ -495,6 +488,7 @@ interface OutcomeFlushResult {
|
|
|
495
488
|
readonly runtimeDirUnsafe: boolean;
|
|
496
489
|
readonly discarded: number;
|
|
497
490
|
readonly needsSignIn?: true;
|
|
491
|
+
readonly retryAfterSeconds?: number;
|
|
498
492
|
}
|
|
499
493
|
interface OutcomeFlushParams {
|
|
500
494
|
readonly apiBase: string;
|
|
@@ -509,7 +503,17 @@ interface OutcomeFlushDeps {
|
|
|
509
503
|
readonly runtime?: RuntimeDirOptions;
|
|
510
504
|
readonly marks?: DropMarksOptions;
|
|
511
505
|
readonly now?: () => Date;
|
|
506
|
+
readonly dropMarks?: false;
|
|
512
507
|
}
|
|
508
|
+
|
|
509
|
+
interface PendingDecisionsIO {
|
|
510
|
+
readonly mkdir?: (p: string, mode: number) => void;
|
|
511
|
+
readonly writeFile?: (p: string, content: string, mode: number) => void;
|
|
512
|
+
readonly readDir?: (p: string) => string[];
|
|
513
|
+
readonly readFile?: (p: string) => string;
|
|
514
|
+
readonly remove?: (p: string) => void;
|
|
515
|
+
}
|
|
516
|
+
|
|
513
517
|
interface PolicyQueuesFlushResult {
|
|
514
518
|
readonly decisions: number;
|
|
515
519
|
readonly outcomes?: OutcomeFlushResult;
|
|
@@ -685,7 +689,7 @@ interface CliIO {
|
|
|
685
689
|
persistIO?: PersistIO;
|
|
686
690
|
loginEnv?: Partial<LoginEnv>;
|
|
687
691
|
backfillDeps?: BackfillDeps;
|
|
688
|
-
fetchFn?: FetchFn;
|
|
692
|
+
fetchFn?: FetchFn$1;
|
|
689
693
|
pluginRunner?: ClaudeRunner;
|
|
690
694
|
probeSleep?: (ms: number) => Promise<void>;
|
|
691
695
|
readStdin?: () => Promise<string>;
|
|
@@ -802,4 +806,4 @@ interface SetupResult {
|
|
|
802
806
|
}
|
|
803
807
|
declare function runSetup(params: SetupParams, io?: PersistIO): SetupResult;
|
|
804
808
|
|
|
805
|
-
export { AGENTTRAIL_AGENT_NS, AGENTTRAIL_API_ENDPOINT, AGENTTRAIL_INGEST_ENDPOINT, AGENTTRAIL_MARKETPLACE_NAME, AGENTTRAIL_PLUGIN_ID, AGENTTRAIL_PLUGIN_NAME, AGENTTRAIL_PROJECT_NS, type AgentTrailConfig, type BackfillConfig, type BackfillDeps, type BackfillResourceSpans, type BackfillState, CLAUDE_CODE_VENDOR_SLUG, CONTENT_FLAGS, ClaudeCliNotFoundError, type ClaudeRunResult, type ClaudeRunner, type CliIO, type ConfigSource, type CredentialsIO, DEFAULT_LOCK_STALE_MS, type DeviceCredentials, type EnvBlockInput, type FetchFn$
|
|
809
|
+
export { AGENTTRAIL_AGENT_NS, AGENTTRAIL_API_ENDPOINT, AGENTTRAIL_INGEST_ENDPOINT, AGENTTRAIL_MARKETPLACE_NAME, AGENTTRAIL_PLUGIN_ID, AGENTTRAIL_PLUGIN_NAME, AGENTTRAIL_PROJECT_NS, type AgentTrailConfig, type BackfillConfig, type BackfillDeps, type BackfillResourceSpans, type BackfillState, CLAUDE_CODE_VENDOR_SLUG, CONTENT_FLAGS, ClaudeCliNotFoundError, type ClaudeRunResult, type ClaudeRunner, type CliIO, type ConfigSource, type CredentialsIO, DEFAULT_LOCK_STALE_MS, type DeviceCredentials, type EnvBlockInput, type FetchFn$2 as FetchFn, type FetchLike, type ImportSummary, type InstallOptions, type InstallResult, type InstallStatus, type LineSource, type LockIO, type LoginEnv, MIN_CLAUDE_VERSION, type MapOptions, type OtlpExportBody, PROJECT_CONFIG_FILE, type ParsedSession, type PersistIO, PluginCommandError, type PluginScope, PluginUnsupportedError, type ProjectIdentity, type ProjectSlugSource, QuarantineError, REFRESH_STALE_WINDOW_MS, type RefreshOutcome, type ResolvedConfig, type ScanInventory, type SessionCheckpoint, type SessionInventoryItem, type SessionOutcome, type SessionStatus, type SetupParams, type SetupResult, type SleepFn, type SpanNode, type ToolResult, type ToolUse, type Turn, type UninstallOptions, type UninstallResult, type UninstallStatus, type UploadDeps, type UploadResult, type WriteSettingsResult, agenttrailConfigSchema, backfillSpanId, backfillTraceId, boundedPool, buildEnvBlock, buildResourceAttributes, buildSpanTree, checkpointPath, clearCredentials, computeAgentId, computeProjectId, credentialsPath, defaultClaudeRunner, defaultProjectsRoot, deriveProjectIdentity, deriveProjectSlug, encodeResourceValue, ensureClaudeSupportsPlugins, ensureGitignored, fileLineSource, findGitRoot, findProjectConfig, globalConfigPath, hashContent, hashFile, installAgentTrailPlugin, isSessionInProject, isVersionAtLeast, normalizeEndpoint, parseAgentTrailConfig, parseClaudeVersion, parseGitRemote, parseSession, pollDeviceToken, readCredentials, readGitRemote, readState, refreshDeviceToken, resolveApiKey, resolveConfig, resolvePluginScaffoldDir, resolveProjectRoot, revokeDeviceToken, run, runImport, runLogin, runLogout, runRefresh, runScan, runSetup, runStatus, scanTranscripts, sessionToResourceSpans, settingsPath, shouldProcess, slugify, startDeviceAuth, toOtlpJson, uninstallAgentTrailPlugin, uploadResourceSpans, upsertSession, withRefreshLock, writeAgentTrailConfig, writeClaudeSettings, writeCredentials, writeGlobalConfig, writeState };
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare function writeCredentials(homeDir: string, creds: DeviceCredentials, io?
|
|
|
28
28
|
declare function clearCredentials(homeDir: string, io?: CredentialsIO, agent?: AgentChoice): void;
|
|
29
29
|
|
|
30
30
|
declare const AGENTTRAIL_API_ENDPOINT: "https://api.agenttrail.sh";
|
|
31
|
-
type FetchFn$
|
|
31
|
+
type FetchFn$2 = (url: string, init?: {
|
|
32
32
|
method?: string;
|
|
33
33
|
headers?: Record<string, string>;
|
|
34
34
|
body?: string;
|
|
@@ -38,10 +38,10 @@ type FetchFn$1 = (url: string, init?: {
|
|
|
38
38
|
json: () => Promise<unknown>;
|
|
39
39
|
}>;
|
|
40
40
|
type SleepFn = (ms: number) => Promise<void>;
|
|
41
|
-
declare function startDeviceAuth(apiEndpoint: string, fetchFn?: FetchFn$
|
|
41
|
+
declare function startDeviceAuth(apiEndpoint: string, fetchFn?: FetchFn$2, request?: DeviceAuthStartRequest): Promise<DeviceAuthStartResponse>;
|
|
42
42
|
interface PollOptions {
|
|
43
43
|
readonly interval: number;
|
|
44
|
-
readonly fetchFn?: FetchFn$
|
|
44
|
+
readonly fetchFn?: FetchFn$2;
|
|
45
45
|
readonly sleepFn?: SleepFn;
|
|
46
46
|
readonly openedAt?: number;
|
|
47
47
|
readonly expiresIn: number;
|
|
@@ -50,8 +50,8 @@ interface PollOptions {
|
|
|
50
50
|
readonly deviceFields?: DeviceAuthDeviceFields;
|
|
51
51
|
}
|
|
52
52
|
declare function pollDeviceToken(apiEndpoint: string, deviceCode: string, opts: PollOptions): Promise<DeviceAuthTokenResponse>;
|
|
53
|
-
declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$
|
|
54
|
-
declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$
|
|
53
|
+
declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$2, deviceFields?: DeviceAuthDeviceFields): Promise<DeviceAuthTokenResponse>;
|
|
54
|
+
declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$2): Promise<boolean>;
|
|
55
55
|
|
|
56
56
|
declare const DEFAULT_LOCK_STALE_MS = 30000;
|
|
57
57
|
interface LockIO {
|
|
@@ -116,7 +116,7 @@ interface LoginEnv {
|
|
|
116
116
|
readonly global?: boolean;
|
|
117
117
|
readonly setup?: boolean;
|
|
118
118
|
readonly host: string;
|
|
119
|
-
readonly fetchFn?: FetchFn$
|
|
119
|
+
readonly fetchFn?: FetchFn$2;
|
|
120
120
|
readonly sleepFn?: SleepFn;
|
|
121
121
|
readonly now?: () => number;
|
|
122
122
|
readonly openBrowser?: (url: string) => void;
|
|
@@ -436,7 +436,7 @@ interface SpanNode {
|
|
|
436
436
|
}
|
|
437
437
|
declare function buildSpanTree(session: ParsedSession): SpanNode[];
|
|
438
438
|
|
|
439
|
-
type FetchFn = typeof fetch;
|
|
439
|
+
type FetchFn$1 = typeof fetch;
|
|
440
440
|
|
|
441
441
|
interface RuntimeDirFs {
|
|
442
442
|
readonly mkdir: (p: string, mode: number) => Promise<unknown>;
|
|
@@ -465,14 +465,6 @@ interface DropMarksOptions {
|
|
|
465
465
|
readonly flushId?: string;
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
interface PendingDecisionsIO {
|
|
469
|
-
readonly mkdir?: (p: string, mode: number) => void;
|
|
470
|
-
readonly writeFile?: (p: string, content: string, mode: number) => void;
|
|
471
|
-
readonly readDir?: (p: string) => string[];
|
|
472
|
-
readonly readFile?: (p: string) => string;
|
|
473
|
-
readonly remove?: (p: string) => void;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
468
|
interface PendingOutcomesFs {
|
|
477
469
|
readonly mkdir: (p: string, opts: {
|
|
478
470
|
recursive: true;
|
|
@@ -484,6 +476,7 @@ interface PendingOutcomesFs {
|
|
|
484
476
|
readonly unlink: (p: string) => Promise<void>;
|
|
485
477
|
}
|
|
486
478
|
|
|
479
|
+
type FetchFn = typeof fetch;
|
|
487
480
|
type OutcomeFlushStatus = "nothing_to_send" | "sent" | "credential_rejected" | "http_error" | "bad_response" | "unreachable" | "timeout" | "not_device_token" | "no_org";
|
|
488
481
|
interface OutcomeFlushResult {
|
|
489
482
|
readonly status: OutcomeFlushStatus;
|
|
@@ -495,6 +488,7 @@ interface OutcomeFlushResult {
|
|
|
495
488
|
readonly runtimeDirUnsafe: boolean;
|
|
496
489
|
readonly discarded: number;
|
|
497
490
|
readonly needsSignIn?: true;
|
|
491
|
+
readonly retryAfterSeconds?: number;
|
|
498
492
|
}
|
|
499
493
|
interface OutcomeFlushParams {
|
|
500
494
|
readonly apiBase: string;
|
|
@@ -509,7 +503,17 @@ interface OutcomeFlushDeps {
|
|
|
509
503
|
readonly runtime?: RuntimeDirOptions;
|
|
510
504
|
readonly marks?: DropMarksOptions;
|
|
511
505
|
readonly now?: () => Date;
|
|
506
|
+
readonly dropMarks?: false;
|
|
512
507
|
}
|
|
508
|
+
|
|
509
|
+
interface PendingDecisionsIO {
|
|
510
|
+
readonly mkdir?: (p: string, mode: number) => void;
|
|
511
|
+
readonly writeFile?: (p: string, content: string, mode: number) => void;
|
|
512
|
+
readonly readDir?: (p: string) => string[];
|
|
513
|
+
readonly readFile?: (p: string) => string;
|
|
514
|
+
readonly remove?: (p: string) => void;
|
|
515
|
+
}
|
|
516
|
+
|
|
513
517
|
interface PolicyQueuesFlushResult {
|
|
514
518
|
readonly decisions: number;
|
|
515
519
|
readonly outcomes?: OutcomeFlushResult;
|
|
@@ -685,7 +689,7 @@ interface CliIO {
|
|
|
685
689
|
persistIO?: PersistIO;
|
|
686
690
|
loginEnv?: Partial<LoginEnv>;
|
|
687
691
|
backfillDeps?: BackfillDeps;
|
|
688
|
-
fetchFn?: FetchFn;
|
|
692
|
+
fetchFn?: FetchFn$1;
|
|
689
693
|
pluginRunner?: ClaudeRunner;
|
|
690
694
|
probeSleep?: (ms: number) => Promise<void>;
|
|
691
695
|
readStdin?: () => Promise<string>;
|
|
@@ -802,4 +806,4 @@ interface SetupResult {
|
|
|
802
806
|
}
|
|
803
807
|
declare function runSetup(params: SetupParams, io?: PersistIO): SetupResult;
|
|
804
808
|
|
|
805
|
-
export { AGENTTRAIL_AGENT_NS, AGENTTRAIL_API_ENDPOINT, AGENTTRAIL_INGEST_ENDPOINT, AGENTTRAIL_MARKETPLACE_NAME, AGENTTRAIL_PLUGIN_ID, AGENTTRAIL_PLUGIN_NAME, AGENTTRAIL_PROJECT_NS, type AgentTrailConfig, type BackfillConfig, type BackfillDeps, type BackfillResourceSpans, type BackfillState, CLAUDE_CODE_VENDOR_SLUG, CONTENT_FLAGS, ClaudeCliNotFoundError, type ClaudeRunResult, type ClaudeRunner, type CliIO, type ConfigSource, type CredentialsIO, DEFAULT_LOCK_STALE_MS, type DeviceCredentials, type EnvBlockInput, type FetchFn$
|
|
809
|
+
export { AGENTTRAIL_AGENT_NS, AGENTTRAIL_API_ENDPOINT, AGENTTRAIL_INGEST_ENDPOINT, AGENTTRAIL_MARKETPLACE_NAME, AGENTTRAIL_PLUGIN_ID, AGENTTRAIL_PLUGIN_NAME, AGENTTRAIL_PROJECT_NS, type AgentTrailConfig, type BackfillConfig, type BackfillDeps, type BackfillResourceSpans, type BackfillState, CLAUDE_CODE_VENDOR_SLUG, CONTENT_FLAGS, ClaudeCliNotFoundError, type ClaudeRunResult, type ClaudeRunner, type CliIO, type ConfigSource, type CredentialsIO, DEFAULT_LOCK_STALE_MS, type DeviceCredentials, type EnvBlockInput, type FetchFn$2 as FetchFn, type FetchLike, type ImportSummary, type InstallOptions, type InstallResult, type InstallStatus, type LineSource, type LockIO, type LoginEnv, MIN_CLAUDE_VERSION, type MapOptions, type OtlpExportBody, PROJECT_CONFIG_FILE, type ParsedSession, type PersistIO, PluginCommandError, type PluginScope, PluginUnsupportedError, type ProjectIdentity, type ProjectSlugSource, QuarantineError, REFRESH_STALE_WINDOW_MS, type RefreshOutcome, type ResolvedConfig, type ScanInventory, type SessionCheckpoint, type SessionInventoryItem, type SessionOutcome, type SessionStatus, type SetupParams, type SetupResult, type SleepFn, type SpanNode, type ToolResult, type ToolUse, type Turn, type UninstallOptions, type UninstallResult, type UninstallStatus, type UploadDeps, type UploadResult, type WriteSettingsResult, agenttrailConfigSchema, backfillSpanId, backfillTraceId, boundedPool, buildEnvBlock, buildResourceAttributes, buildSpanTree, checkpointPath, clearCredentials, computeAgentId, computeProjectId, credentialsPath, defaultClaudeRunner, defaultProjectsRoot, deriveProjectIdentity, deriveProjectSlug, encodeResourceValue, ensureClaudeSupportsPlugins, ensureGitignored, fileLineSource, findGitRoot, findProjectConfig, globalConfigPath, hashContent, hashFile, installAgentTrailPlugin, isSessionInProject, isVersionAtLeast, normalizeEndpoint, parseAgentTrailConfig, parseClaudeVersion, parseGitRemote, parseSession, pollDeviceToken, readCredentials, readGitRemote, readState, refreshDeviceToken, resolveApiKey, resolveConfig, resolvePluginScaffoldDir, resolveProjectRoot, revokeDeviceToken, run, runImport, runLogin, runLogout, runRefresh, runScan, runSetup, runStatus, scanTranscripts, sessionToResourceSpans, settingsPath, shouldProcess, slugify, startDeviceAuth, toOtlpJson, uninstallAgentTrailPlugin, uploadResourceSpans, upsertSession, withRefreshLock, writeAgentTrailConfig, writeClaudeSettings, writeCredentials, writeGlobalConfig, writeState };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$,A as N,Aa as Ne,B as _,Ba as _e,C as x,Ca as xe,D as O,
|
|
1
|
+
import{$,A as N,Aa as Ne,B as _,Ba as _e,C as x,Ca as xe,D as O,E as h,Ea as Oe,F as G,G as k,H as v,I as D,J as U,K as F,L as b,M as j,N as B,O as M,P as w,Q as V,R as J,S as K,T as W,U as z,V as H,W as Q,X as q,Y as X,Z as Y,_ as Z,a as e,aa as ee,b as t,ba as te,c as o,ca as oe,d as r,da as re,e as n,ea as ne,f as p,fa as pe,g as i,ga as ie,h as s,ha as se,i as l,ia as le,j as a,ja as ae,k as u,ka as ue,l as c,la as ce,m as y,ma as ye,n as f,na as fe,o as S,oa as Se,p as d,pa as de,q as T,qa as Te,r as I,ra as Ie,s as m,sa as me,t as E,ta as Ee,u as R,ua as Re,v as C,va as Ce,w as g,wa as ge,x as A,xa as Ae,y as P,ya as Pe,z as L,za as Le}from"./chunk-4ZPQGE47.js";export{t as AGENTTRAIL_AGENT_NS,d as AGENTTRAIL_API_ENDPOINT,o as AGENTTRAIL_INGEST_ENDPOINT,j as AGENTTRAIL_MARKETPLACE_NAME,M as AGENTTRAIL_PLUGIN_ID,B as AGENTTRAIL_PLUGIN_NAME,e as AGENTTRAIL_PROJECT_NS,n as CLAUDE_CODE_VENDOR_SLUG,p as CONTENT_FLAGS,J as ClaudeCliNotFoundError,R as DEFAULT_LOCK_STALE_MS,w as MIN_CLAUDE_VERSION,P as PROJECT_CONFIG_FILE,W as PluginCommandError,K as PluginUnsupportedError,Te as QuarantineError,te as REFRESH_STALE_WINDOW_MS,g as agenttrailConfigSchema,fe as backfillSpanId,ye as backfillTraceId,Pe as boundedPool,l as buildEnvBlock,s as buildResourceAttributes,Se as buildSpanTree,pe as checkpointPath,S as clearCredentials,b as computeAgentId,F as computeProjectId,c as credentialsPath,V as defaultClaudeRunner,Ee as defaultProjectsRoot,D as deriveProjectIdentity,U as deriveProjectSlug,i as encodeResourceValue,Q as ensureClaudeSupportsPlugins,Z as ensureGitignored,Ie as fileLineSource,_ as findGitRoot,N as findProjectConfig,L as globalConfigPath,ce as hashContent,ue as hashFile,X as installAgentTrailPlugin,Re as isSessionInProject,H as isVersionAtLeast,r as normalizeEndpoint,A as parseAgentTrailConfig,z as parseClaudeVersion,k as parseGitRemote,me as parseSession,I as pollDeviceToken,y as readCredentials,v as readGitRemote,ie as readState,m as refreshDeviceToken,h as resolveApiKey,O as resolveConfig,q as resolvePluginScaffoldDir,x as resolveProjectRoot,E as revokeDeviceToken,Oe as run,_e as runImport,oe as runLogin,ne as runLogout,re as runRefresh,Le as runScan,xe as runSetup,Ne as runStatus,Ce as scanTranscripts,de as sessionToResourceSpans,a as settingsPath,ae as shouldProcess,G as slugify,T as startDeviceAuth,ge as toOtlpJson,Y as uninstallAgentTrailPlugin,Ae as uploadResourceSpans,le as upsertSession,C as withRefreshLock,$ as writeAgentTrailConfig,u as writeClaudeSettings,f as writeCredentials,ee as writeGlobalConfig,se as writeState};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agenttrail/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The AgentTrail command-line tool: connects an AI coding agent's sessions to AgentTrail, with setup, sign-in, status and history import for the agent named by --agent.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
},
|
|
7
7
|
"metadata": {
|
|
8
8
|
"description": "AgentTrail's plugin marketplace — the enforcement plugin for agent governance.",
|
|
9
|
-
"version": "0.2.
|
|
9
|
+
"version": "0.2.29"
|
|
10
10
|
},
|
|
11
11
|
"plugins": [
|
|
12
12
|
{
|
|
13
13
|
"name": "agenttrail",
|
|
14
14
|
"source": "./",
|
|
15
15
|
"description": "AgentTrail enforcement plugin — PreToolUse governance hook (a fail-closed command shim).",
|
|
16
|
-
"version": "0.2.
|
|
16
|
+
"version": "0.2.29",
|
|
17
17
|
"author": {
|
|
18
18
|
"name": "AgentTrail"
|
|
19
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agenttrail",
|
|
3
3
|
"description": "AgentTrail enforcement plugin for Claude Code — carries the PreToolUse governance hook, a fail-closed command shim.",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.29",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "AgentTrail",
|
|
7
7
|
"url": "https://agenttrail.sh"
|
|
@@ -3099,45 +3099,161 @@ function agentDenialOf(body) {
|
|
|
3099
3099
|
const reason = typeof o.reason === "string" ? o.reason.trim() : "";
|
|
3100
3100
|
return reason.startsWith("Denied by ") ? reason : null;
|
|
3101
3101
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
method: "POST",
|
|
3108
|
-
headers: { "content-type": "application/json", authorization: `Bearer ${args.token}` },
|
|
3109
|
-
body: JSON.stringify({
|
|
3110
|
-
...args.request,
|
|
3111
|
-
correlation_id: args.correlationId,
|
|
3112
|
-
// Omitted entirely when the caller sends none, so the Claude Code path's request
|
|
3113
|
-
// body is byte-identical to what it was before Cursor needed the field.
|
|
3114
|
-
...args.maxWindowSeconds === void 0 ? {} : { max_window_seconds: args.maxWindowSeconds }
|
|
3115
|
-
})
|
|
3116
|
-
},
|
|
3117
|
-
args.timeoutMs
|
|
3118
|
-
);
|
|
3119
|
-
if (res.status === 403) {
|
|
3120
|
-
if (await isApiTierRefusal(res)) return "tier-disabled";
|
|
3121
|
-
throw foreign403("hold");
|
|
3122
|
-
}
|
|
3123
|
-
if (res.status !== 200) {
|
|
3124
|
-
throw new PdpUnreachableError(`hold status ${res.status}`, statusKind(res.status));
|
|
3102
|
+
var PdpHoldInterruptedError = class extends PdpUnreachableError {
|
|
3103
|
+
};
|
|
3104
|
+
var PdpHoldUnconfirmedError = class extends PdpUnreachableError {
|
|
3105
|
+
constructor(reason) {
|
|
3106
|
+
super(reason, "parse_error");
|
|
3125
3107
|
}
|
|
3108
|
+
};
|
|
3109
|
+
async function readBodyBounded(res, signal) {
|
|
3110
|
+
let onAbort;
|
|
3111
|
+
const aborted = new Promise((_, reject) => {
|
|
3112
|
+
onAbort = () => reject(new Error("hold response body exceeded its deadline"));
|
|
3113
|
+
if (signal.aborted) onAbort();
|
|
3114
|
+
else signal.addEventListener("abort", onAbort, { once: true });
|
|
3115
|
+
});
|
|
3116
|
+
aborted.catch(() => {
|
|
3117
|
+
});
|
|
3126
3118
|
try {
|
|
3127
|
-
|
|
3128
|
-
}
|
|
3119
|
+
return await Promise.race([res.text(), aborted]);
|
|
3120
|
+
} finally {
|
|
3121
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
3129
3122
|
}
|
|
3130
|
-
|
|
3123
|
+
}
|
|
3124
|
+
async function holdAttempt(args, fetchFn, timeoutMs, windowSeconds, onHeld, afterAcceptMs) {
|
|
3125
|
+
const controller = new AbortController();
|
|
3126
|
+
let timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
3131
3127
|
try {
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3128
|
+
let res;
|
|
3129
|
+
try {
|
|
3130
|
+
res = await fetchFn(args.url, {
|
|
3131
|
+
method: "POST",
|
|
3132
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${args.token}` },
|
|
3133
|
+
body: JSON.stringify({
|
|
3134
|
+
...args.request,
|
|
3135
|
+
correlation_id: args.correlationId,
|
|
3136
|
+
// Omitted entirely when the caller sends none, so the Claude Code path's first
|
|
3137
|
+
// request body is byte-identical to what it was before Cursor needed the field.
|
|
3138
|
+
...windowSeconds === void 0 ? {} : { max_window_seconds: windowSeconds }
|
|
3139
|
+
}),
|
|
3140
|
+
signal: controller.signal
|
|
3141
|
+
});
|
|
3142
|
+
} catch (err) {
|
|
3143
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
3144
|
+
if (controller.signal.aborted) throw new PdpUnreachableError(msg, "timeout");
|
|
3145
|
+
throw new PdpHoldInterruptedError(msg, "unreachable");
|
|
3146
|
+
}
|
|
3147
|
+
if (res.status === 403) {
|
|
3148
|
+
if (await isApiTierRefusal(res)) return "tier-disabled";
|
|
3149
|
+
throw foreign403("hold");
|
|
3150
|
+
}
|
|
3151
|
+
if (res.status !== 200) {
|
|
3152
|
+
const kind = statusKind(res.status);
|
|
3153
|
+
const message = `hold status ${res.status}`;
|
|
3154
|
+
throw res.status >= 500 ? new PdpHoldInterruptedError(message, kind) : new PdpUnreachableError(message, kind);
|
|
3155
|
+
}
|
|
3156
|
+
if (afterAcceptMs) {
|
|
3157
|
+
clearTimeout(timer);
|
|
3158
|
+
timer = setTimeout(() => controller.abort(), Math.max(0, afterAcceptMs()));
|
|
3159
|
+
}
|
|
3160
|
+
try {
|
|
3161
|
+
onHeld?.();
|
|
3162
|
+
} catch {
|
|
3163
|
+
}
|
|
3164
|
+
let text;
|
|
3165
|
+
try {
|
|
3166
|
+
text = await readBodyBounded(res, controller.signal);
|
|
3167
|
+
} catch (err) {
|
|
3168
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
3169
|
+
if (controller.signal.aborted) throw new PdpUnreachableError(msg, "timeout");
|
|
3170
|
+
throw new PdpHoldInterruptedError(`hold response broke: ${msg}`, "unreachable");
|
|
3171
|
+
}
|
|
3172
|
+
if (text.trim() === "") {
|
|
3173
|
+
throw new PdpHoldInterruptedError("hold response ended before a verdict", "unreachable");
|
|
3174
|
+
}
|
|
3175
|
+
let parsed;
|
|
3176
|
+
try {
|
|
3177
|
+
parsed = JSON.parse(text);
|
|
3178
|
+
} catch {
|
|
3179
|
+
throw new PdpUnreachableError("hold 200 with unparseable body", "parse_error");
|
|
3180
|
+
}
|
|
3181
|
+
const outcome = parsed?.outcome;
|
|
3182
|
+
if (outcome === "approved" || outcome === "denied" || outcome === "unanswered") {
|
|
3183
|
+
const id = parsed.approval_id;
|
|
3184
|
+
return {
|
|
3185
|
+
result: { outcome, denial: agentDenialOf(parsed) },
|
|
3186
|
+
approvalId: typeof id === "string" && id !== "" ? id : null
|
|
3187
|
+
};
|
|
3188
|
+
}
|
|
3189
|
+
throw new PdpUnreachableError("hold 200 with malformed outcome", "parse_error");
|
|
3190
|
+
} finally {
|
|
3191
|
+
clearTimeout(timer);
|
|
3135
3192
|
}
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3193
|
+
}
|
|
3194
|
+
var REATTACH_BACKOFF_MS = [250, 500, 1e3, 2e3];
|
|
3195
|
+
var REATTACH_MAX_ATTEMPTS = 12;
|
|
3196
|
+
var REATTACH_MIN_REMAINING_MS = 2e3;
|
|
3197
|
+
var HOLD_PRE_ACCEPT_RETRY_CAP_MS = 3e4;
|
|
3198
|
+
function canReattach(err) {
|
|
3199
|
+
return err instanceof PdpHoldInterruptedError;
|
|
3200
|
+
}
|
|
3201
|
+
async function holdWithReattach(args, fetchFn, clock = {}) {
|
|
3202
|
+
const now = clock.now ?? (() => performance.now());
|
|
3203
|
+
const sleep = clock.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
3204
|
+
const start = now();
|
|
3205
|
+
const hardEnd = start + args.timeoutMs;
|
|
3206
|
+
const windowSeconds = args.maxWindowSeconds ?? POLICY_HOLD_MAX_WINDOW_SECONDS;
|
|
3207
|
+
const windowEnd = start + windowSeconds * 1e3;
|
|
3208
|
+
const preAcceptEnd = start + HOLD_PRE_ACCEPT_RETRY_CAP_MS;
|
|
3209
|
+
let accepted = false;
|
|
3210
|
+
let uploaded = false;
|
|
3211
|
+
let lastError;
|
|
3212
|
+
for (let attempt = 0; attempt < REATTACH_MAX_ATTEMPTS; attempt++) {
|
|
3213
|
+
if (attempt > 0) {
|
|
3214
|
+
const wait = REATTACH_BACKOFF_MS[Math.min(attempt - 1, REATTACH_BACKOFF_MS.length - 1)] ?? 0;
|
|
3215
|
+
if (hardEnd - now() - wait < REATTACH_MIN_REMAINING_MS) break;
|
|
3216
|
+
if (!accepted && now() + wait >= preAcceptEnd) break;
|
|
3217
|
+
await sleep(wait);
|
|
3218
|
+
}
|
|
3219
|
+
const remaining = hardEnd - now();
|
|
3220
|
+
if (attempt > 0 && remaining < REATTACH_MIN_REMAINING_MS) break;
|
|
3221
|
+
const sendWindow = attempt === 0 ? args.maxWindowSeconds : Math.min(windowSeconds, Math.max(1, Math.floor((windowEnd - now()) / 1e3)));
|
|
3222
|
+
try {
|
|
3223
|
+
const out = await holdAttempt(
|
|
3224
|
+
args,
|
|
3225
|
+
fetchFn,
|
|
3226
|
+
accepted ? remaining : Math.min(remaining, Math.max(1, preAcceptEnd - now())),
|
|
3227
|
+
sendWindow,
|
|
3228
|
+
() => {
|
|
3229
|
+
accepted = true;
|
|
3230
|
+
if (args.onHeld && !uploaded) {
|
|
3231
|
+
uploaded = true;
|
|
3232
|
+
args.onHeld();
|
|
3233
|
+
}
|
|
3234
|
+
},
|
|
3235
|
+
() => hardEnd - now()
|
|
3236
|
+
);
|
|
3237
|
+
if (out === "tier-disabled") {
|
|
3238
|
+
if (accepted || attempt > 0) {
|
|
3239
|
+
throw new PdpHoldUnconfirmedError(
|
|
3240
|
+
"re-attached hold answered with a tier refusal, not a reviewer's answer; failing closed"
|
|
3241
|
+
);
|
|
3242
|
+
}
|
|
3243
|
+
return out;
|
|
3244
|
+
}
|
|
3245
|
+
if (attempt > 0 && out.result.outcome === "approved" && out.approvalId === null) {
|
|
3246
|
+
throw new PdpHoldUnconfirmedError(
|
|
3247
|
+
"re-attached hold answered approved with no approval id (the policy changed during the hold); failing closed"
|
|
3248
|
+
);
|
|
3249
|
+
}
|
|
3250
|
+
return out.result;
|
|
3251
|
+
} catch (err) {
|
|
3252
|
+
if (!canReattach(err)) throw err;
|
|
3253
|
+
lastError = err;
|
|
3254
|
+
}
|
|
3139
3255
|
}
|
|
3140
|
-
throw new PdpUnreachableError("hold
|
|
3256
|
+
throw lastError instanceof Error ? lastError : new PdpUnreachableError("hold could not be reached", "unreachable");
|
|
3141
3257
|
}
|
|
3142
3258
|
function readCachedSnapshot(path, io2 = {}) {
|
|
3143
3259
|
const read = io2.readFile ?? ((p) => readFileSync4(p, "utf8"));
|
|
@@ -3189,6 +3305,9 @@ function holdWindowSeconds(elapsedMs) {
|
|
|
3189
3305
|
function holdWatchdogDelayMs(elapsedMs) {
|
|
3190
3306
|
return Math.max(1, PEP_HOLD_WATCHDOG_MS - Math.max(0, elapsedMs));
|
|
3191
3307
|
}
|
|
3308
|
+
function holdDeadlineMs(elapsedMs) {
|
|
3309
|
+
return Math.max(1e3, PEP_HOLD_FETCH_TIMEOUT_MS - Math.max(0, elapsedMs));
|
|
3310
|
+
}
|
|
3192
3311
|
async function holdCursorApproval(input) {
|
|
3193
3312
|
const { cfg, correlationId } = input;
|
|
3194
3313
|
if (!cfg.holdUrl || !cfg.token || correlationId === null || correlationId === "") {
|
|
@@ -3203,13 +3322,15 @@ async function holdCursorApproval(input) {
|
|
|
3203
3322
|
return res;
|
|
3204
3323
|
});
|
|
3205
3324
|
try {
|
|
3206
|
-
const held = await
|
|
3325
|
+
const held = await holdWithReattach(
|
|
3207
3326
|
{
|
|
3208
3327
|
url: cfg.holdUrl,
|
|
3209
3328
|
token: cfg.token,
|
|
3210
3329
|
request: input.request,
|
|
3211
3330
|
correlationId,
|
|
3212
|
-
|
|
3331
|
+
// The re-attach loop owns one deadline. The 595 s ceiling counts from the hook's
|
|
3332
|
+
// start, as the watchdog does, so a retry never outlives the budget.
|
|
3333
|
+
timeoutMs: holdDeadlineMs(input.elapsedMs),
|
|
3213
3334
|
maxWindowSeconds: windowSeconds
|
|
3214
3335
|
},
|
|
3215
3336
|
observedFetch
|
|
@@ -5993,6 +6114,7 @@ var HOOK_OUTCOMES = Object.keys({
|
|
|
5993
6114
|
none: 0
|
|
5994
6115
|
});
|
|
5995
6116
|
var REVIEWER_DENIED = "Denied by an AgentTrail reviewer.";
|
|
6117
|
+
var HOLD_UNCONFIRMED = "AgentTrail could not confirm this approval after the connection dropped (the policy changed while the call was held); failing closed. Run the action again to ask for approval.";
|
|
5996
6118
|
var NO_DECISION = { decision: "none", reason: "" };
|
|
5997
6119
|
var MAX_DETAIL_LEN = 8192;
|
|
5998
6120
|
var PEP_VENDOR = "claude-code";
|
|
@@ -6026,7 +6148,7 @@ var handleApproval = async (payload, verdict, ctx) => {
|
|
|
6026
6148
|
}
|
|
6027
6149
|
ctx.extendDeadline?.(PEP_HOLD_WATCHDOG_MS);
|
|
6028
6150
|
try {
|
|
6029
|
-
const held = await
|
|
6151
|
+
const held = await holdWithReattach(
|
|
6030
6152
|
{
|
|
6031
6153
|
url: ctx.cfg.holdUrl,
|
|
6032
6154
|
token: ctx.cfg.token,
|
|
@@ -6059,7 +6181,8 @@ var handleApproval = async (payload, verdict, ctx) => {
|
|
|
6059
6181
|
);
|
|
6060
6182
|
return {
|
|
6061
6183
|
decision: "deny",
|
|
6062
|
-
|
|
6184
|
+
// Say so when the cause is a re-attach that no reviewer can have answered.
|
|
6185
|
+
reason: err instanceof PdpHoldUnconfirmedError ? HOLD_UNCONFIRMED : "AgentTrail approval hold was unreachable; failing closed."
|
|
6063
6186
|
};
|
|
6064
6187
|
}
|
|
6065
6188
|
};
|