@agenttrail/cli 0.0.0-stage → 0.1.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.
@@ -0,0 +1,630 @@
1
+ import { Tier, ScrubbingConfig } from '@agenttrail/shared/types';
2
+ import { DeviceAuthTokenResponse, DeviceAuthStartRequest, DeviceAuthStartResponse } from '@agenttrail/shared/device-auth';
3
+ import { ResolvedScrubbers } from '@agenttrail/shared/scrubber';
4
+ import { z } from 'zod';
5
+
6
+ type AgentChoice = "claude" | "cursor" | "codex";
7
+
8
+ interface DeviceCredentials {
9
+ readonly refresh_token: string;
10
+ readonly ingest_token: string;
11
+ readonly ingest_token_expires_at: string;
12
+ readonly org_id: string;
13
+ readonly host: string;
14
+ readonly endpoint: string;
15
+ readonly org_tier?: Tier;
16
+ readonly api_endpoint?: string;
17
+ }
18
+ interface CredentialsIO {
19
+ readFile?: (p: string) => string;
20
+ writeFile?: (p: string, c: string, mode?: number) => void;
21
+ mkdir?: (p: string, mode: number) => void;
22
+ unlink?: (p: string) => void;
23
+ }
24
+ declare function credentialsPath(homeDir: string, agent?: AgentChoice): string;
25
+ declare function readCredentials(homeDir: string, io?: CredentialsIO, agent?: AgentChoice): DeviceCredentials | null;
26
+ declare function writeCredentials(homeDir: string, creds: DeviceCredentials, io?: CredentialsIO, agent?: AgentChoice): string;
27
+ declare function clearCredentials(homeDir: string, io?: CredentialsIO, agent?: AgentChoice): void;
28
+
29
+ declare const AGENTTRAIL_API_ENDPOINT: "https://api.agenttrail.sh";
30
+ type FetchFn$1 = (url: string, init?: {
31
+ method?: string;
32
+ headers?: Record<string, string>;
33
+ body?: string;
34
+ }) => Promise<{
35
+ ok: boolean;
36
+ status: number;
37
+ json: () => Promise<unknown>;
38
+ }>;
39
+ type SleepFn = (ms: number) => Promise<void>;
40
+ declare function startDeviceAuth(apiEndpoint: string, fetchFn?: FetchFn$1, request?: DeviceAuthStartRequest): Promise<DeviceAuthStartResponse>;
41
+ interface PollOptions {
42
+ readonly interval: number;
43
+ readonly fetchFn?: FetchFn$1;
44
+ readonly sleepFn?: SleepFn;
45
+ readonly openedAt?: number;
46
+ readonly expiresIn: number;
47
+ readonly now?: () => number;
48
+ readonly agent?: "claude" | "cursor" | "codex";
49
+ }
50
+ declare function pollDeviceToken(apiEndpoint: string, deviceCode: string, opts: PollOptions): Promise<DeviceAuthTokenResponse>;
51
+ declare function refreshDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1): Promise<DeviceAuthTokenResponse>;
52
+ declare function revokeDeviceToken(apiEndpoint: string, refreshToken: string, fetchFn?: FetchFn$1): Promise<void>;
53
+
54
+ declare const DEFAULT_LOCK_STALE_MS = 30000;
55
+ interface LockIO {
56
+ acquire?: (path: string, contents: string) => void;
57
+ release?: (path: string) => void;
58
+ age?: (path: string) => number | null;
59
+ now?: () => number;
60
+ sleep?: (ms: number) => Promise<void>;
61
+ }
62
+ interface AcquireOptions {
63
+ readonly lockPath: string;
64
+ readonly staleMs?: number;
65
+ readonly timeoutMs?: number;
66
+ readonly retryMs?: number;
67
+ readonly io?: LockIO;
68
+ }
69
+ declare function withRefreshLock<T>(opts: AcquireOptions, fn: () => Promise<T>): Promise<T>;
70
+
71
+ declare const REFRESH_STALE_WINDOW_MS: number;
72
+ type RefreshOutcome = "no-op" | "rotated" | "not-logged-in";
73
+
74
+ interface SettingsIO {
75
+ readFile?: (p: string) => string;
76
+ writeFile?: (p: string, c: string, mode?: number) => void;
77
+ mkdir?: (p: string) => void;
78
+ }
79
+ interface LoginEnv {
80
+ readonly apiEndpoint: string;
81
+ readonly ingestEndpoint: string;
82
+ readonly homeDir: string;
83
+ readonly settingsRoot: string;
84
+ readonly projectSlug?: string;
85
+ readonly captureContent?: boolean;
86
+ readonly global?: boolean;
87
+ readonly host: string;
88
+ readonly fetchFn?: FetchFn$1;
89
+ readonly sleepFn?: SleepFn;
90
+ readonly now?: () => number;
91
+ readonly openBrowser?: (url: string) => void;
92
+ readonly credentialsIO?: CredentialsIO;
93
+ readonly settingsIO?: SettingsIO;
94
+ readonly lockIO?: LockIO;
95
+ readonly log: (msg: string) => void;
96
+ }
97
+ declare function runLogin(env: LoginEnv): Promise<DeviceCredentials>;
98
+ declare function runRefresh(env: LoginEnv): Promise<RefreshOutcome>;
99
+ declare function runLogout(env: LoginEnv): Promise<void>;
100
+
101
+ type SessionStatus = "pending" | "done" | "failed" | "quarantined";
102
+ interface SessionCheckpoint {
103
+ readonly status: SessionStatus;
104
+ readonly sourceHash: string;
105
+ readonly batchId: string;
106
+ readonly error?: string;
107
+ readonly updatedAt: string;
108
+ }
109
+ interface BackfillState {
110
+ readonly version: 2;
111
+ readonly sessions: Record<string, SessionCheckpoint>;
112
+ }
113
+ interface CheckpointIO {
114
+ readFile?: (p: string) => string;
115
+ writeFile?: (p: string, c: string, mode?: number) => void;
116
+ mkdir?: (p: string, mode: number) => void;
117
+ }
118
+ declare function checkpointPath(homeDir: string): string;
119
+ declare function readState(homeDir: string, io?: CheckpointIO): BackfillState;
120
+ declare function writeState(homeDir: string, state: BackfillState, io?: CheckpointIO): string;
121
+ declare function upsertSession(state: BackfillState, sessionId: string, patch: Omit<SessionCheckpoint, "updatedAt"> & {
122
+ updatedAt?: string;
123
+ }): BackfillState;
124
+ declare function shouldProcess(state: BackfillState, sessionId: string, sourceHash: string): boolean;
125
+ declare function hashFile(path: string): Promise<string>;
126
+ declare function hashContent(content: string): string;
127
+
128
+ declare function backfillTraceId(sessionId: string, promptMessageUuid: string): string;
129
+ declare function backfillSpanId(sessionId: string, messageUuid: string, discriminator: string): string;
130
+
131
+ interface Usage {
132
+ readonly input_tokens?: number;
133
+ readonly output_tokens?: number;
134
+ readonly cache_read_input_tokens?: number;
135
+ readonly cache_creation_input_tokens?: number;
136
+ readonly cache_creation?: {
137
+ readonly ephemeral_5m_input_tokens?: number;
138
+ readonly ephemeral_1h_input_tokens?: number;
139
+ };
140
+ readonly speed?: string | null;
141
+ readonly inference_geo?: string | null;
142
+ }
143
+ interface ToolUse {
144
+ readonly toolUseId: string;
145
+ readonly name: string;
146
+ readonly input: Readonly<Record<string, unknown>>;
147
+ }
148
+ interface ToolResult {
149
+ readonly toolUseId: string;
150
+ readonly isError: boolean;
151
+ readonly content: string;
152
+ readonly timestamp: string;
153
+ }
154
+ interface Turn {
155
+ readonly messageUuid: string;
156
+ readonly timestamp: string;
157
+ readonly model: string;
158
+ readonly usage: Usage;
159
+ readonly text: string;
160
+ readonly toolUses: readonly ToolUse[];
161
+ readonly isSidechain: boolean;
162
+ readonly promptUuid: string;
163
+ }
164
+ interface UserPrompt {
165
+ readonly messageUuid: string;
166
+ readonly timestamp: string;
167
+ readonly text: string;
168
+ readonly isSidechain: boolean;
169
+ }
170
+ interface ParsedSession {
171
+ readonly sessionId: string;
172
+ readonly version: string | null;
173
+ readonly gitBranch: string | null;
174
+ readonly cwd: string | null;
175
+ readonly turns: readonly Turn[];
176
+ readonly userPrompts: readonly UserPrompt[];
177
+ readonly toolResults: ReadonlyMap<string, ToolResult>;
178
+ readonly firstTimestamp: string;
179
+ readonly lastTimestamp: string;
180
+ readonly skippedLines: number;
181
+ }
182
+
183
+ declare class QuarantineError extends Error {
184
+ readonly sessionId: string | null;
185
+ constructor(message: string, sessionId: string | null);
186
+ }
187
+ interface LineSource {
188
+ readLines(path: string): AsyncIterable<string>;
189
+ }
190
+ declare const fileLineSource: LineSource;
191
+ declare function parseSession(path: string, fallbackSessionId: string, source?: LineSource): Promise<ParsedSession>;
192
+
193
+ declare function defaultProjectsRoot(home?: string): string;
194
+ interface SessionInventoryItem {
195
+ readonly sessionId: string;
196
+ readonly file: string;
197
+ readonly project: string;
198
+ readonly cwd: string | null;
199
+ readonly gitBranch: string | null;
200
+ readonly version: string | null;
201
+ readonly sizeBytes: number;
202
+ readonly modifiedAt: string;
203
+ readonly messageCount: number;
204
+ }
205
+ interface ScanInventory {
206
+ readonly projectsRoot: string;
207
+ readonly projects: readonly {
208
+ readonly project: string;
209
+ readonly sessions: readonly SessionInventoryItem[];
210
+ }[];
211
+ readonly totalSessions: number;
212
+ readonly excludedOtherProject?: number;
213
+ readonly excludedUnknownCwd?: number;
214
+ }
215
+ interface ScanIO {
216
+ readdir?: (p: string) => string[];
217
+ stat?: (p: string) => {
218
+ size: number;
219
+ mtimeMs: number;
220
+ isDirectory: () => boolean;
221
+ };
222
+ lineSource?: LineSource;
223
+ }
224
+ declare function isSessionInProject(cwd: string | null, projectRoot: string): boolean;
225
+ declare function scanTranscripts(projectsRoot?: string, projectRoot?: string, io?: ScanIO): Promise<ScanInventory>;
226
+
227
+ interface BackfillSpan {
228
+ readonly traceId: string;
229
+ readonly spanId: string;
230
+ readonly parentSpanId: string;
231
+ readonly name: string;
232
+ readonly kind: number;
233
+ readonly startTimeUnixNano: string;
234
+ readonly endTimeUnixNano: string;
235
+ readonly attributes: Readonly<Record<string, string>>;
236
+ readonly error: boolean;
237
+ }
238
+ interface RedactionTally {
239
+ readonly total: number;
240
+ readonly byType: Readonly<Record<string, number>>;
241
+ }
242
+ interface BackfillResourceSpans {
243
+ readonly resource: {
244
+ readonly attributes: Readonly<Record<string, string>>;
245
+ };
246
+ readonly scope: {
247
+ readonly name: string;
248
+ readonly version: string;
249
+ };
250
+ readonly spans: readonly BackfillSpan[];
251
+ readonly redactions: RedactionTally;
252
+ }
253
+ interface MapOptions {
254
+ readonly orgId: string;
255
+ readonly projectId: string;
256
+ readonly developerId?: string;
257
+ readonly batchId: string;
258
+ readonly captureContent: boolean;
259
+ readonly scopeVersion?: string;
260
+ readonly resolved?: ResolvedScrubbers | null;
261
+ }
262
+ declare function sessionToResourceSpans(session: ParsedSession, opts: MapOptions): BackfillResourceSpans;
263
+
264
+ interface OtlpKeyValue {
265
+ key: string;
266
+ value: {
267
+ stringValue: string;
268
+ };
269
+ }
270
+ interface OtlpSpan {
271
+ traceId: string;
272
+ spanId: string;
273
+ parentSpanId: string;
274
+ name: string;
275
+ kind: number;
276
+ startTimeUnixNano: string;
277
+ endTimeUnixNano: string;
278
+ attributes: OtlpKeyValue[];
279
+ status?: {
280
+ code: number;
281
+ };
282
+ }
283
+ interface OtlpScopeSpans {
284
+ scope: {
285
+ name: string;
286
+ version: string;
287
+ };
288
+ spans: OtlpSpan[];
289
+ }
290
+ interface OtlpResourceSpans {
291
+ resource: {
292
+ attributes: OtlpKeyValue[];
293
+ };
294
+ scopeSpans: OtlpScopeSpans[];
295
+ }
296
+ interface OtlpExportBody {
297
+ resourceSpans: OtlpResourceSpans[];
298
+ }
299
+ declare function toOtlpJson(resourceSpans: BackfillResourceSpans | readonly BackfillResourceSpans[]): OtlpExportBody;
300
+
301
+ type FetchLike = (url: string, init: {
302
+ method: string;
303
+ headers: Record<string, string>;
304
+ body: string;
305
+ }) => Promise<{
306
+ ok: boolean;
307
+ status: number;
308
+ headers: {
309
+ get(name: string): string | null;
310
+ };
311
+ text(): Promise<string>;
312
+ }>;
313
+ interface UploadDeps {
314
+ readonly fetch?: FetchLike;
315
+ readonly sleep?: (ms: number) => Promise<void>;
316
+ }
317
+ interface UploadOptions {
318
+ readonly endpoint: string;
319
+ readonly token: string;
320
+ readonly maxRetries?: number;
321
+ readonly baseBackoffMs?: number;
322
+ readonly dryRun?: boolean;
323
+ }
324
+ interface UploadResult {
325
+ readonly status: "ok" | "skipped" | "failed";
326
+ readonly httpStatus?: number;
327
+ readonly attempts: number;
328
+ readonly error?: string;
329
+ }
330
+ declare function uploadResourceSpans(body: OtlpExportBody, opts: UploadOptions, deps?: UploadDeps): Promise<UploadResult>;
331
+ declare function boundedPool<T, R>(items: readonly T[], concurrency: number, worker: (item: T, index: number) => Promise<R>): Promise<R[]>;
332
+
333
+ interface BackfillConfig {
334
+ readonly homeDir: string;
335
+ readonly projectsRoot?: string;
336
+ readonly endpoint: string;
337
+ readonly token: string;
338
+ readonly orgId: string;
339
+ readonly developerId?: string;
340
+ readonly captureContent: boolean;
341
+ readonly concurrency?: number;
342
+ readonly dryRun?: boolean;
343
+ readonly reimport?: boolean;
344
+ readonly scopeVersion?: string;
345
+ readonly projectRoot: string;
346
+ readonly sinceMs?: number;
347
+ readonly retentionCutoffMs?: number;
348
+ readonly scrubConfig?: ScrubbingConfig;
349
+ }
350
+ interface BackfillDeps {
351
+ readonly scanIO?: ScanIO;
352
+ readonly lineSource?: LineSource;
353
+ readonly checkpointIO?: CheckpointIO;
354
+ readonly upload?: UploadDeps;
355
+ readonly hashFile?: (path: string) => Promise<string>;
356
+ readonly emit?: (event: Record<string, unknown>) => void;
357
+ }
358
+ interface SessionOutcome {
359
+ readonly sessionId: string;
360
+ readonly project: string;
361
+ readonly status: SessionStatus | "skipped" | "skipped-retention";
362
+ readonly spans?: number;
363
+ readonly error?: string;
364
+ readonly upload?: UploadResult;
365
+ }
366
+ interface ImportSummary {
367
+ readonly total: number;
368
+ readonly imported: number;
369
+ readonly skipped: number;
370
+ readonly failed: number;
371
+ readonly quarantined: number;
372
+ readonly retentionSkipped: number;
373
+ readonly dedupSkipped: number;
374
+ readonly dedupOk: boolean;
375
+ readonly estimatedActions: number;
376
+ readonly outcomes: readonly SessionOutcome[];
377
+ readonly redactions: {
378
+ readonly total: number;
379
+ readonly byType: Record<string, number>;
380
+ };
381
+ readonly excludedOtherProject: number;
382
+ readonly excludedUnknownCwd: number;
383
+ }
384
+ declare function runScan(cfg: Pick<BackfillConfig, "projectsRoot" | "projectRoot">, deps?: BackfillDeps): Promise<ScanInventory>;
385
+ declare function runStatus(cfg: Pick<BackfillConfig, "homeDir">, deps?: BackfillDeps): BackfillState;
386
+ declare function runImport(cfg: BackfillConfig, resume: boolean, deps?: BackfillDeps): Promise<ImportSummary>;
387
+
388
+ type SpanRole = "agent" | "llm" | "tool";
389
+ interface SpanNode {
390
+ readonly role: SpanRole;
391
+ readonly spanId: string;
392
+ readonly parentSpanId: string;
393
+ readonly promptId: string;
394
+ readonly startTs: string;
395
+ readonly endTs: string;
396
+ readonly failed: boolean;
397
+ readonly turn?: Turn;
398
+ readonly tool?: ToolUse;
399
+ readonly toolResult?: ToolResult;
400
+ readonly promptText?: string;
401
+ }
402
+ declare function buildSpanTree(session: ParsedSession): SpanNode[];
403
+
404
+ type FetchFn = typeof fetch;
405
+
406
+ declare const AGENTTRAIL_PROJECT_NS: "18a5d968-0fa2-5c8a-88da-0b29d80105d4";
407
+ declare const AGENTTRAIL_AGENT_NS: "7f050af4-796e-5b05-94c2-dba78bcdc7c2";
408
+ declare const AGENTTRAIL_INGEST_ENDPOINT: "https://ingest.agenttrail.sh";
409
+ declare function normalizeEndpoint(value: string): string;
410
+
411
+ declare const agenttrailConfigSchema: z.ZodObject<{
412
+ orgId: z.ZodString;
413
+ projectSlug: z.ZodString;
414
+ projectId: z.ZodOptional<z.ZodString>;
415
+ agentId: z.ZodOptional<z.ZodString>;
416
+ developerId: z.ZodOptional<z.ZodString>;
417
+ apiKey: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
418
+ captureContent: z.ZodOptional<z.ZodBoolean>;
419
+ }, "strict", z.ZodTypeAny, {
420
+ orgId: string;
421
+ projectSlug: string;
422
+ projectId?: string | undefined;
423
+ agentId?: string | undefined;
424
+ developerId?: string | undefined;
425
+ apiKey?: string | undefined;
426
+ captureContent?: boolean | undefined;
427
+ }, {
428
+ orgId: string;
429
+ projectSlug: string;
430
+ projectId?: string | undefined;
431
+ agentId?: string | undefined;
432
+ developerId?: string | undefined;
433
+ apiKey?: string | undefined;
434
+ captureContent?: boolean | undefined;
435
+ }>;
436
+ type AgentTrailConfig = z.infer<typeof agenttrailConfigSchema>;
437
+ declare function parseAgentTrailConfig(raw: unknown): AgentTrailConfig;
438
+
439
+ interface PersistIO {
440
+ readFile?: (p: string) => string;
441
+ writeFile?: (p: string, c: string, mode?: number) => void;
442
+ exists?: (p: string) => boolean;
443
+ mkdir?: (p: string, mode?: number) => void;
444
+ home?: string;
445
+ }
446
+ declare function ensureGitignored(rootDir: string, io?: PersistIO, line?: string): boolean;
447
+ declare function writeAgentTrailConfig(rootDir: string, config: AgentTrailConfig, io?: PersistIO): {
448
+ path: string;
449
+ gitignoreModified: boolean;
450
+ mode: number;
451
+ };
452
+ declare function writeGlobalConfig(config: AgentTrailConfig, io?: PersistIO): {
453
+ path: string;
454
+ mode: number;
455
+ };
456
+
457
+ declare const AGENTTRAIL_MARKETPLACE_NAME = "agenttrail";
458
+ declare const AGENTTRAIL_PLUGIN_NAME = "agenttrail";
459
+ declare const AGENTTRAIL_PLUGIN_ID = "agenttrail@agenttrail";
460
+ declare const MIN_CLAUDE_VERSION = "2.1.211";
461
+ type PluginScope = "user";
462
+ interface ClaudeRunResult {
463
+ readonly code: number | null;
464
+ readonly stdout: string;
465
+ readonly stderr: string;
466
+ readonly spawnError?: string;
467
+ }
468
+ type ClaudeRunner = (args: readonly string[]) => ClaudeRunResult;
469
+ declare const defaultClaudeRunner: ClaudeRunner;
470
+ declare class ClaudeCliNotFoundError extends Error {
471
+ constructor();
472
+ }
473
+ declare class PluginUnsupportedError extends Error {
474
+ readonly foundVersion: string | null;
475
+ readonly minVersion: string;
476
+ constructor(foundVersion: string | null, minVersion?: string);
477
+ }
478
+ declare class PluginCommandError extends Error {
479
+ readonly step: string;
480
+ readonly exitCode: number | null;
481
+ readonly stderr: string;
482
+ constructor(step: string, exitCode: number | null, stderr: string);
483
+ }
484
+ declare function parseClaudeVersion(output: string): [number, number, number] | null;
485
+ declare function isVersionAtLeast(version: [number, number, number], min: [number, number, number]): boolean;
486
+ declare function ensureClaudeSupportsPlugins(runner: ClaudeRunner): void;
487
+ declare function resolvePluginScaffoldDir(fromDir?: string): string;
488
+ interface InstallOptions {
489
+ readonly scope?: PluginScope;
490
+ readonly runner?: ClaudeRunner;
491
+ readonly marketplaceSource?: string;
492
+ readonly pathExists?: (p: string) => boolean;
493
+ }
494
+ type InstallStatus = "installed" | "already-installed";
495
+ interface InstallResult {
496
+ readonly status: InstallStatus;
497
+ readonly pluginId: string;
498
+ readonly scope: PluginScope;
499
+ }
500
+ declare function installAgentTrailPlugin(options?: InstallOptions): InstallResult;
501
+ interface UninstallOptions {
502
+ readonly scope?: PluginScope;
503
+ readonly runner?: ClaudeRunner;
504
+ }
505
+ type UninstallStatus = "removed" | "not-installed";
506
+ interface UninstallResult {
507
+ readonly status: UninstallStatus;
508
+ readonly pluginId: string;
509
+ readonly scope: PluginScope;
510
+ }
511
+ declare function uninstallAgentTrailPlugin(options?: UninstallOptions): UninstallResult;
512
+
513
+ interface CliIO {
514
+ readonly cwd: string;
515
+ readonly env: NodeJS.ProcessEnv;
516
+ readonly argv: readonly string[];
517
+ log: (msg: string) => void;
518
+ error: (msg: string) => void;
519
+ prompt?: (question: string) => Promise<string>;
520
+ isInteractive?: boolean;
521
+ persistIO?: PersistIO;
522
+ loginEnv?: Partial<LoginEnv>;
523
+ backfillDeps?: BackfillDeps;
524
+ fetchFn?: FetchFn;
525
+ pluginRunner?: ClaudeRunner;
526
+ readStdin?: () => Promise<string>;
527
+ }
528
+ declare function run(io: CliIO): Promise<number>;
529
+
530
+ declare const CLAUDE_CODE_VENDOR_SLUG: "claude-code";
531
+
532
+ declare function slugify(input: string): string;
533
+ declare function parseGitRemote(remoteUrl: string): string | null;
534
+ declare function readGitRemote(cwd: string): string | null;
535
+ type ProjectSlugSource = "remote" | "directory";
536
+ interface ProjectIdentity {
537
+ readonly slug: string;
538
+ readonly source: ProjectSlugSource;
539
+ }
540
+ declare function deriveProjectIdentity(cwd: string, opts?: {
541
+ readGitRemote?: (cwd: string) => string | null;
542
+ }): ProjectIdentity | null;
543
+ declare function deriveProjectSlug(cwd: string, opts?: {
544
+ readGitRemote?: (cwd: string) => string | null;
545
+ }): string | null;
546
+ declare function computeProjectId(orgId: string, projectSlug: string): string;
547
+
548
+ declare function computeAgentId(orgId: string, vendorSlug: string): string;
549
+
550
+ declare const PROJECT_CONFIG_FILE = ".agenttrail.json";
551
+ declare function globalConfigPath(home?: string): string;
552
+ type ConfigSource = "env" | "project" | "global" | null;
553
+ interface ResolvedConfig {
554
+ readonly config: AgentTrailConfig | null;
555
+ readonly source: ConfigSource;
556
+ readonly configPath: string | null;
557
+ readonly gitRoot: string | null;
558
+ }
559
+ declare function findProjectConfig(cwd: string): string | null;
560
+ declare function findGitRoot(cwd: string): string | null;
561
+ declare function resolveProjectRoot(cwd: string): string;
562
+ interface ResolveOptions {
563
+ readonly globalPath?: string;
564
+ readonly allowGlobal?: boolean;
565
+ }
566
+ declare function resolveConfig(cwd: string, opts?: ResolveOptions): ResolvedConfig;
567
+ declare function resolveApiKey(resolved: ResolvedConfig, env?: NodeJS.ProcessEnv): string | null;
568
+
569
+ declare const CONTENT_FLAGS: readonly ["OTEL_LOG_USER_PROMPTS", "OTEL_LOG_TOOL_DETAILS", "OTEL_LOG_TOOL_CONTENT"];
570
+ interface EnvBlockInput {
571
+ readonly orgId: string;
572
+ readonly projectId: string;
573
+ readonly agentId?: string;
574
+ readonly developerId?: string;
575
+ readonly apiKey?: string;
576
+ readonly team?: boolean;
577
+ readonly captureContent?: boolean;
578
+ readonly project?: string;
579
+ readonly endpoint?: string;
580
+ }
581
+ declare function encodeResourceValue(value: string): string;
582
+ declare function buildResourceAttributes(input: {
583
+ orgId: string;
584
+ projectId: string;
585
+ agentId?: string;
586
+ developerId?: string;
587
+ project?: string;
588
+ }): string;
589
+ declare function buildEnvBlock(input: EnvBlockInput): Record<string, string>;
590
+ declare function settingsPath(rootDir: string): string;
591
+ interface WriteSettingsResult {
592
+ readonly path: string;
593
+ readonly env: Record<string, string>;
594
+ readonly merged: boolean;
595
+ }
596
+ declare function writeClaudeSettings(rootDir: string, env: Record<string, string>, io?: {
597
+ readFile?: (p: string) => string;
598
+ writeFile?: (p: string, c: string) => void;
599
+ mkdir?: (p: string) => void;
600
+ }): WriteSettingsResult;
601
+
602
+ interface SetupParams {
603
+ readonly cwd: string;
604
+ readonly orgId: string;
605
+ readonly apiKey?: string;
606
+ readonly projectSlug?: string;
607
+ readonly developerId?: string;
608
+ readonly team?: boolean;
609
+ readonly global?: boolean;
610
+ readonly captureContent?: boolean;
611
+ readonly endpoint?: string;
612
+ }
613
+ interface SetupResult {
614
+ readonly projectSlug: string;
615
+ readonly projectId: string;
616
+ readonly slugSource: ProjectSlugSource | "explicit";
617
+ readonly agentId: string;
618
+ readonly agenttrailConfigPath: string;
619
+ readonly gitignoreModified: boolean;
620
+ readonly agenttrailConfigMode: number;
621
+ readonly settings: WriteSettingsResult;
622
+ readonly localSettings: WriteSettingsResult | null;
623
+ readonly team: boolean;
624
+ readonly global: boolean;
625
+ readonly captureContent: boolean;
626
+ readonly resolvedEndpoint: string;
627
+ }
628
+ declare function runSetup(params: SetupParams, io?: PersistIO): SetupResult;
629
+
630
+ 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$1 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 ADDED
@@ -0,0 +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-F6FLYISV.js";export{t as AGENTTRAIL_AGENT_NS,d as AGENTTRAIL_API_ENDPOINT,o as AGENTTRAIL_INGEST_ENDPOINT,ce as AGENTTRAIL_MARKETPLACE_NAME,fe as AGENTTRAIL_PLUGIN_ID,ye as AGENTTRAIL_PLUGIN_NAME,e as AGENTTRAIL_PROJECT_NS,n as CLAUDE_CODE_VENDOR_SLUG,p as CONTENT_FLAGS,Te as ClaudeCliNotFoundError,R as DEFAULT_LOCK_STALE_MS,Se as MIN_CLAUDE_VERSION,P as PROJECT_CONFIG_FILE,me as PluginCommandError,Ie as PluginUnsupportedError,$ as QuarantineError,j as REFRESH_STALE_WINDOW_MS,g as agenttrailConfigSchema,X as backfillSpanId,q as backfillTraceId,se as boundedPool,l as buildEnvBlock,s as buildResourceAttributes,Y as buildSpanTree,V as checkpointPath,S as clearCredentials,b as computeAgentId,F as computeProjectId,c as credentialsPath,de as defaultClaudeRunner,oe as defaultProjectsRoot,D as deriveProjectIdentity,U as deriveProjectSlug,i as encodeResourceValue,Ce as ensureClaudeSupportsPlugins,Le as ensureGitignored,ee as fileLineSource,_ as findGitRoot,N as findProjectConfig,L as globalConfigPath,Q as hashContent,H as hashFile,Ae as installAgentTrailPlugin,re as isSessionInProject,Re as isVersionAtLeast,r as normalizeEndpoint,A as parseAgentTrailConfig,Ee as parseClaudeVersion,k as parseGitRemote,te as parseSession,I as pollDeviceToken,y as readCredentials,v as readGitRemote,J as readState,m as refreshDeviceToken,h as resolveApiKey,O as resolveConfig,ge as resolvePluginScaffoldDir,x as resolveProjectRoot,E as revokeDeviceToken,Oe as run,ue as runImport,B as runLogin,w as runLogout,M as runRefresh,le as runScan,xe as runSetup,ae as runStatus,ne as scanTranscripts,Z as sessionToResourceSpans,a as settingsPath,z as shouldProcess,G as slugify,T as startDeviceAuth,pe as toOtlpJson,Pe as uninstallAgentTrailPlugin,ie as uploadResourceSpans,W as upsertSession,C as withRefreshLock,Ne as writeAgentTrailConfig,u as writeClaudeSettings,f as writeCredentials,_e as writeGlobalConfig,K as writeState};
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@agenttrail/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "type": "module",
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
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/agenttrailhq/agenttrail.sh.git",
10
+ "directory": "packages/cli"
11
+ },
12
+ "homepage": "https://agenttrail.sh",
13
+ "bugs": {
14
+ "url": "https://github.com/agenttrailhq/agenttrail.sh/issues"
15
+ },
16
+ "engines": {
17
+ "node": ">=18"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "bin": {
23
+ "agenttrail": "./dist/cli/index.js"
24
+ },
25
+ "main": "./dist/index.cjs",
26
+ "module": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js",
32
+ "require": "./dist/index.cjs"
33
+ }
34
+ },
35
+ "files": [
36
+ "dist",
37
+ "!dist/**/*.map",
38
+ "plugin",
39
+ "LICENSE",
40
+ "README.md"
41
+ ],
42
+ "dependencies": {
43
+ "uuid": "^9.0.1",
44
+ "zod": "^3.25.17"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "vitest run"
50
+ }
6
51
  }