@agenttrail/cli 0.2.12 → 0.2.24

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/dist/index.d.cts CHANGED
@@ -1,6 +1,7 @@
1
- import { Tier, ScrubbingConfig } from '@agenttrail/shared/types';
1
+ import { Tier, ScrubbingConfig, DecisionDroppedStatus } from '@agenttrail/shared/types';
2
2
  import { DeviceAuthDeviceFields, DeviceAuthTokenResponse, DeviceAuthStartRequest, DeviceAuthStartResponse } from '@agenttrail/shared/device-auth';
3
3
  import { ResolvedScrubbers } from '@agenttrail/shared/scrubber';
4
+ import { Stats, promises } from 'node:fs';
4
5
  import { z } from 'zod';
5
6
 
6
7
  type AgentChoice = "claude" | "cursor" | "codex";
@@ -50,7 +51,7 @@ interface PollOptions {
50
51
  }
51
52
  declare function pollDeviceToken(apiEndpoint: string, deviceCode: string, opts: PollOptions): Promise<DeviceAuthTokenResponse>;
52
53
  declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1, deviceFields?: DeviceAuthDeviceFields): Promise<DeviceAuthTokenResponse>;
53
- declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1): Promise<void>;
54
+ declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1): Promise<boolean>;
54
55
 
55
56
  declare const DEFAULT_LOCK_STALE_MS = 30000;
56
57
  interface LockIO {
@@ -221,7 +222,7 @@ interface LineSource {
221
222
  readLines(path: string): AsyncIterable<string>;
222
223
  }
223
224
  declare const fileLineSource: LineSource;
224
- declare function parseSession(path: string, fallbackSessionId: string, source?: LineSource): Promise<ParsedSession>;
225
+ declare function parseSession(path: string, fallbackSessionId: string, source?: LineSource, onRecord?: (record: object) => void): Promise<ParsedSession>;
225
226
 
226
227
  declare function defaultProjectsRoot(home?: string): string;
227
228
  interface SessionInventoryItem {
@@ -437,6 +438,88 @@ declare function buildSpanTree(session: ParsedSession): SpanNode[];
437
438
 
438
439
  type FetchFn = typeof fetch;
439
440
 
441
+ interface RuntimeDirFs {
442
+ readonly mkdir: (p: string, mode: number) => Promise<unknown>;
443
+ readonly lstat: (p: string) => Promise<Stats>;
444
+ readonly stat: (p: string) => Promise<Stats>;
445
+ readonly realpath: (p: string) => Promise<string>;
446
+ }
447
+ interface RuntimeDirOptions {
448
+ readonly fs?: RuntimeDirFs;
449
+ readonly platform?: NodeJS.Platform;
450
+ readonly env?: Readonly<Record<string, string | undefined>>;
451
+ readonly uid?: number | undefined;
452
+ readonly tmpdir?: () => string;
453
+ }
454
+
455
+ interface DropMarksFs {
456
+ readonly readdir: (p: string) => Promise<string[]>;
457
+ readonly open: (p: string, flags: number, mode?: number) => Promise<promises.FileHandle>;
458
+ readonly rename: (from: string, to: string) => Promise<void>;
459
+ readonly unlink: (p: string) => Promise<void>;
460
+ }
461
+ interface DropMarksOptions {
462
+ readonly fs?: DropMarksFs;
463
+ readonly now?: Date;
464
+ readonly uid?: number | undefined;
465
+ readonly flushId?: string;
466
+ }
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
+ interface PendingOutcomesFs {
477
+ readonly mkdir: (p: string, opts: {
478
+ recursive: true;
479
+ mode: number;
480
+ }) => Promise<unknown>;
481
+ readonly readdir: (p: string) => Promise<string[]>;
482
+ readonly open: (p: string, flags: number, mode?: number) => Promise<promises.FileHandle>;
483
+ readonly rename: (from: string, to: string) => Promise<void>;
484
+ readonly unlink: (p: string) => Promise<void>;
485
+ }
486
+
487
+ type OutcomeFlushStatus = "nothing_to_send" | "sent" | "credential_rejected" | "http_error" | "bad_response" | "unreachable" | "timeout" | "not_device_token" | "no_org";
488
+ interface OutcomeFlushResult {
489
+ readonly status: OutcomeFlushStatus;
490
+ readonly httpStatus?: number;
491
+ readonly sent: number;
492
+ readonly deleted: number;
493
+ readonly dropDays: number;
494
+ readonly drops: DecisionDroppedStatus | "not_sent";
495
+ readonly runtimeDirUnsafe: boolean;
496
+ readonly discarded: number;
497
+ readonly needsSignIn?: true;
498
+ }
499
+ interface OutcomeFlushParams {
500
+ readonly apiBase: string;
501
+ readonly token: string;
502
+ readonly orgId: string;
503
+ readonly snapshotPath: string;
504
+ readonly deadline?: number;
505
+ }
506
+ interface OutcomeFlushDeps {
507
+ readonly fetchFn: FetchFn;
508
+ readonly outcomesFs?: PendingOutcomesFs;
509
+ readonly runtime?: RuntimeDirOptions;
510
+ readonly marks?: DropMarksOptions;
511
+ readonly now?: () => Date;
512
+ }
513
+ interface PolicyQueuesFlushResult {
514
+ readonly decisions: number;
515
+ readonly outcomes?: OutcomeFlushResult;
516
+ }
517
+ declare function flushPolicyQueues(params: Omit<OutcomeFlushParams, "deadline" | "orgId"> & {
518
+ readonly orgId?: string;
519
+ }, deps: OutcomeFlushDeps & {
520
+ readonly pendingDecisionsIO?: PendingDecisionsIO;
521
+ }): Promise<PolicyQueuesFlushResult>;
522
+
440
523
  interface StateIO {
441
524
  readFile?: (p: string) => string;
442
525
  writeFile?: (p: string, c: string, mode?: number) => void;
@@ -467,6 +550,7 @@ interface CaptureContext {
467
550
  readonly loginEnv?: Partial<LoginEnv>;
468
551
  readonly managedPaths?: readonly string[];
469
552
  readonly log?: (entry: CaptureLogEntry) => void;
553
+ readonly flushQueues?: typeof flushPolicyQueues;
470
554
  }
471
555
  declare function runCaptureCommand(ctx: CaptureContext): Promise<number>;
472
556
 
@@ -603,6 +687,7 @@ interface CliIO {
603
687
  backfillDeps?: BackfillDeps;
604
688
  fetchFn?: FetchFn;
605
689
  pluginRunner?: ClaudeRunner;
690
+ probeSleep?: (ms: number) => Promise<void>;
606
691
  readStdin?: () => Promise<string>;
607
692
  managedPaths?: readonly string[];
608
693
  captureOverrides?: Partial<Parameters<typeof runCaptureCommand>[0]>;
@@ -689,6 +774,8 @@ interface SetupParams {
689
774
  readonly apiKey?: string;
690
775
  readonly projectSlug?: string;
691
776
  readonly developerId?: string;
777
+ readonly processEnv?: Readonly<Record<string, string | undefined>>;
778
+ readonly log?: (message: string) => void;
692
779
  readonly team?: boolean;
693
780
  readonly global?: boolean;
694
781
  readonly captureContent?: boolean;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { Tier, ScrubbingConfig } from '@agenttrail/shared/types';
1
+ import { Tier, ScrubbingConfig, DecisionDroppedStatus } from '@agenttrail/shared/types';
2
2
  import { DeviceAuthDeviceFields, DeviceAuthTokenResponse, DeviceAuthStartRequest, DeviceAuthStartResponse } from '@agenttrail/shared/device-auth';
3
3
  import { ResolvedScrubbers } from '@agenttrail/shared/scrubber';
4
+ import { Stats, promises } from 'node:fs';
4
5
  import { z } from 'zod';
5
6
 
6
7
  type AgentChoice = "claude" | "cursor" | "codex";
@@ -50,7 +51,7 @@ interface PollOptions {
50
51
  }
51
52
  declare function pollDeviceToken(apiEndpoint: string, deviceCode: string, opts: PollOptions): Promise<DeviceAuthTokenResponse>;
52
53
  declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1, deviceFields?: DeviceAuthDeviceFields): Promise<DeviceAuthTokenResponse>;
53
- declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1): Promise<void>;
54
+ declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1): Promise<boolean>;
54
55
 
55
56
  declare const DEFAULT_LOCK_STALE_MS = 30000;
56
57
  interface LockIO {
@@ -221,7 +222,7 @@ interface LineSource {
221
222
  readLines(path: string): AsyncIterable<string>;
222
223
  }
223
224
  declare const fileLineSource: LineSource;
224
- declare function parseSession(path: string, fallbackSessionId: string, source?: LineSource): Promise<ParsedSession>;
225
+ declare function parseSession(path: string, fallbackSessionId: string, source?: LineSource, onRecord?: (record: object) => void): Promise<ParsedSession>;
225
226
 
226
227
  declare function defaultProjectsRoot(home?: string): string;
227
228
  interface SessionInventoryItem {
@@ -437,6 +438,88 @@ declare function buildSpanTree(session: ParsedSession): SpanNode[];
437
438
 
438
439
  type FetchFn = typeof fetch;
439
440
 
441
+ interface RuntimeDirFs {
442
+ readonly mkdir: (p: string, mode: number) => Promise<unknown>;
443
+ readonly lstat: (p: string) => Promise<Stats>;
444
+ readonly stat: (p: string) => Promise<Stats>;
445
+ readonly realpath: (p: string) => Promise<string>;
446
+ }
447
+ interface RuntimeDirOptions {
448
+ readonly fs?: RuntimeDirFs;
449
+ readonly platform?: NodeJS.Platform;
450
+ readonly env?: Readonly<Record<string, string | undefined>>;
451
+ readonly uid?: number | undefined;
452
+ readonly tmpdir?: () => string;
453
+ }
454
+
455
+ interface DropMarksFs {
456
+ readonly readdir: (p: string) => Promise<string[]>;
457
+ readonly open: (p: string, flags: number, mode?: number) => Promise<promises.FileHandle>;
458
+ readonly rename: (from: string, to: string) => Promise<void>;
459
+ readonly unlink: (p: string) => Promise<void>;
460
+ }
461
+ interface DropMarksOptions {
462
+ readonly fs?: DropMarksFs;
463
+ readonly now?: Date;
464
+ readonly uid?: number | undefined;
465
+ readonly flushId?: string;
466
+ }
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
+ interface PendingOutcomesFs {
477
+ readonly mkdir: (p: string, opts: {
478
+ recursive: true;
479
+ mode: number;
480
+ }) => Promise<unknown>;
481
+ readonly readdir: (p: string) => Promise<string[]>;
482
+ readonly open: (p: string, flags: number, mode?: number) => Promise<promises.FileHandle>;
483
+ readonly rename: (from: string, to: string) => Promise<void>;
484
+ readonly unlink: (p: string) => Promise<void>;
485
+ }
486
+
487
+ type OutcomeFlushStatus = "nothing_to_send" | "sent" | "credential_rejected" | "http_error" | "bad_response" | "unreachable" | "timeout" | "not_device_token" | "no_org";
488
+ interface OutcomeFlushResult {
489
+ readonly status: OutcomeFlushStatus;
490
+ readonly httpStatus?: number;
491
+ readonly sent: number;
492
+ readonly deleted: number;
493
+ readonly dropDays: number;
494
+ readonly drops: DecisionDroppedStatus | "not_sent";
495
+ readonly runtimeDirUnsafe: boolean;
496
+ readonly discarded: number;
497
+ readonly needsSignIn?: true;
498
+ }
499
+ interface OutcomeFlushParams {
500
+ readonly apiBase: string;
501
+ readonly token: string;
502
+ readonly orgId: string;
503
+ readonly snapshotPath: string;
504
+ readonly deadline?: number;
505
+ }
506
+ interface OutcomeFlushDeps {
507
+ readonly fetchFn: FetchFn;
508
+ readonly outcomesFs?: PendingOutcomesFs;
509
+ readonly runtime?: RuntimeDirOptions;
510
+ readonly marks?: DropMarksOptions;
511
+ readonly now?: () => Date;
512
+ }
513
+ interface PolicyQueuesFlushResult {
514
+ readonly decisions: number;
515
+ readonly outcomes?: OutcomeFlushResult;
516
+ }
517
+ declare function flushPolicyQueues(params: Omit<OutcomeFlushParams, "deadline" | "orgId"> & {
518
+ readonly orgId?: string;
519
+ }, deps: OutcomeFlushDeps & {
520
+ readonly pendingDecisionsIO?: PendingDecisionsIO;
521
+ }): Promise<PolicyQueuesFlushResult>;
522
+
440
523
  interface StateIO {
441
524
  readFile?: (p: string) => string;
442
525
  writeFile?: (p: string, c: string, mode?: number) => void;
@@ -467,6 +550,7 @@ interface CaptureContext {
467
550
  readonly loginEnv?: Partial<LoginEnv>;
468
551
  readonly managedPaths?: readonly string[];
469
552
  readonly log?: (entry: CaptureLogEntry) => void;
553
+ readonly flushQueues?: typeof flushPolicyQueues;
470
554
  }
471
555
  declare function runCaptureCommand(ctx: CaptureContext): Promise<number>;
472
556
 
@@ -603,6 +687,7 @@ interface CliIO {
603
687
  backfillDeps?: BackfillDeps;
604
688
  fetchFn?: FetchFn;
605
689
  pluginRunner?: ClaudeRunner;
690
+ probeSleep?: (ms: number) => Promise<void>;
606
691
  readStdin?: () => Promise<string>;
607
692
  managedPaths?: readonly string[];
608
693
  captureOverrides?: Partial<Parameters<typeof runCaptureCommand>[0]>;
@@ -689,6 +774,8 @@ interface SetupParams {
689
774
  readonly apiKey?: string;
690
775
  readonly projectSlug?: string;
691
776
  readonly developerId?: string;
777
+ readonly processEnv?: Readonly<Record<string, string | undefined>>;
778
+ readonly log?: (message: string) => void;
692
779
  readonly team?: boolean;
693
780
  readonly global?: boolean;
694
781
  readonly captureContent?: boolean;
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,Da as Oe,E as h,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-RV57MPTW.js";export{t as AGENTTRAIL_AGENT_NS,d as AGENTTRAIL_API_ENDPOINT,o as AGENTTRAIL_INGEST_ENDPOINT,Se as AGENTTRAIL_MARKETPLACE_NAME,Te as AGENTTRAIL_PLUGIN_ID,de as AGENTTRAIL_PLUGIN_NAME,e as AGENTTRAIL_PROJECT_NS,n as CLAUDE_CODE_VENDOR_SLUG,p as CONTENT_FLAGS,Ee as ClaudeCliNotFoundError,R as DEFAULT_LOCK_STALE_MS,Ie as MIN_CLAUDE_VERSION,P as PROJECT_CONFIG_FILE,Ce as PluginCommandError,Re as PluginUnsupportedError,oe as QuarantineError,w as REFRESH_STALE_WINDOW_MS,g as agenttrailConfigSchema,$ as backfillSpanId,Z as backfillTraceId,ue as boundedPool,l as buildEnvBlock,s as buildResourceAttributes,ee as buildSpanTree,W as checkpointPath,S as clearCredentials,b as computeAgentId,F as computeProjectId,c as credentialsPath,me as defaultClaudeRunner,pe as defaultProjectsRoot,D as deriveProjectIdentity,U as deriveProjectSlug,i as encodeResourceValue,Pe as ensureClaudeSupportsPlugins,j as ensureGitignored,re as fileLineSource,_ as findGitRoot,N as findProjectConfig,L as globalConfigPath,Y as hashContent,X as hashFile,Ne as installAgentTrailPlugin,ie as isSessionInProject,Ae as isVersionAtLeast,r as normalizeEndpoint,A as parseAgentTrailConfig,ge as parseClaudeVersion,k as parseGitRemote,ne as parseSession,I as pollDeviceToken,y as readCredentials,v as readGitRemote,z as readState,m as refreshDeviceToken,h as resolveApiKey,O as resolveConfig,Le as resolvePluginScaffoldDir,x as resolveProjectRoot,E as revokeDeviceToken,Oe as run,fe as runImport,V as runLogin,K as runLogout,J as runRefresh,ce as runScan,xe as runSetup,ye as runStatus,se as scanTranscripts,te as sessionToResourceSpans,a as settingsPath,q as shouldProcess,G as slugify,T as startDeviceAuth,le as toOtlpJson,_e as uninstallAgentTrailPlugin,ae as uploadResourceSpans,Q as upsertSession,C as withRefreshLock,B as writeAgentTrailConfig,u as writeClaudeSettings,f as writeCredentials,M as writeGlobalConfig,H as writeState};
1
+ import{$,A as N,Aa as Ne,B as _,Ba as _e,C as x,Ca as xe,D as O,Da as Oe,E as h,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-5PHWHBOC.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.12",
3
+ "version": "0.2.24",
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.12"
9
+ "version": "0.2.24"
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.12",
16
+ "version": "0.2.24",
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.12",
4
+ "version": "0.2.24",
5
5
  "author": {
6
6
  "name": "AgentTrail",
7
7
  "url": "https://agenttrail.sh"