@tangle-network/traces 0.8.22 → 0.8.23

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.
@@ -2164,6 +2164,49 @@ async function readGit(cwd) {
2164
2164
  commit
2165
2165
  };
2166
2166
  }
2167
+ async function gitOutput(cwd, args) {
2168
+ const { execFile } = await import("child_process");
2169
+ const { promisify } = await import("util");
2170
+ const run = promisify(execFile);
2171
+ try {
2172
+ const { stdout } = await run("git", ["-C", cwd, ...args], { timeout: 5e3 });
2173
+ const v = stdout.trim();
2174
+ return v.length > 0 ? v : null;
2175
+ } catch {
2176
+ return null;
2177
+ }
2178
+ }
2179
+ function uniqNormalized(paths) {
2180
+ const out = [];
2181
+ const seen = /* @__PURE__ */ new Set();
2182
+ for (const path of paths) {
2183
+ const n = normalize(path);
2184
+ if (seen.has(n)) continue;
2185
+ seen.add(n);
2186
+ out.push(n);
2187
+ }
2188
+ return out;
2189
+ }
2190
+ function parseWorktreePorcelain(output) {
2191
+ return output.split("\n").filter((line) => line.startsWith("worktree ")).map((line) => line.slice("worktree ".length).trim()).filter(Boolean);
2192
+ }
2193
+ async function equivalentGitCwds(cwd) {
2194
+ if (!cwd) return [];
2195
+ const selected = normalize(cwd);
2196
+ if (!isAbsolute(selected)) return [selected];
2197
+ const top = await gitOutput(selected, ["rev-parse", "--show-toplevel"]);
2198
+ if (!top) return [selected];
2199
+ const worktrees = await gitOutput(top, ["worktree", "list", "--porcelain"]);
2200
+ return uniqNormalized([selected, top, ...worktrees ? parseWorktreePorcelain(worktrees) : []]);
2201
+ }
2202
+ function cwdMatchesSelection(cwd, selections) {
2203
+ if (!cwd) return false;
2204
+ const value = normalize(cwd);
2205
+ return selections.some((selection) => {
2206
+ const prefix = normalize(selection);
2207
+ return value === prefix || value.startsWith(`${prefix}/`);
2208
+ });
2209
+ }
2167
2210
  async function pathStat(path) {
2168
2211
  try {
2169
2212
  return await stat11(path);
@@ -2383,12 +2426,26 @@ async function parseSession(adapter, ref) {
2383
2426
  stampRepoAttrs(spans, repo.attrs);
2384
2427
  return spans;
2385
2428
  }
2429
+ function refKey(ref) {
2430
+ return `${ref.harness}\0${ref.path}\0${ref.sessionId}`;
2431
+ }
2432
+ async function locateSessions(adapter, opts = {}) {
2433
+ if (!opts.cwd) return adapter.locate({ sinceMs: opts.sinceMs });
2434
+ const cwdSelections = await equivalentGitCwds(opts.cwd);
2435
+ const refs = await adapter.locate({ sinceMs: opts.sinceMs });
2436
+ const byKey = /* @__PURE__ */ new Map();
2437
+ for (const ref of refs) {
2438
+ if (!cwdMatchesSelection(ref.cwd, cwdSelections)) continue;
2439
+ byKey.set(refKey(ref), ref);
2440
+ }
2441
+ return [...byKey.values()].sort((a, b) => b.mtimeMs - a.mtimeMs);
2442
+ }
2386
2443
  async function* scanSessions(opts) {
2387
2444
  for (const adapter of selectAdapters(opts)) {
2388
2445
  if (opts.signal?.aborted) return;
2389
2446
  let refs;
2390
2447
  try {
2391
- refs = await adapter.locate({ cwd: opts.cwd, sinceMs: opts.sinceMs });
2448
+ refs = await locateSessions(adapter, { cwd: opts.cwd, sinceMs: opts.sinceMs });
2392
2449
  } catch (err) {
2393
2450
  opts.onError?.(err);
2394
2451
  continue;
@@ -5150,10 +5207,13 @@ export {
5150
5207
  knownHarnesses,
5151
5208
  selectAdapters,
5152
5209
  normalizeRemote,
5210
+ equivalentGitCwds,
5211
+ cwdMatchesSelection,
5153
5212
  resolveRepoAttrs,
5154
5213
  resolveSessionRepoAttrs,
5155
5214
  stampRepoAttrs,
5156
5215
  parseSession,
5216
+ locateSessions,
5157
5217
  scanSessions,
5158
5218
  buildPolicyEvidenceRecord,
5159
5219
  collectPolicyEvidence,
package/dist/cli.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  inspectSessionIndex,
14
14
  knownHarnesses,
15
15
  loadTracesConfig,
16
+ locateSessions,
16
17
  mergeTracesConfig,
17
18
  parseSession,
18
19
  parseSince,
@@ -43,7 +44,7 @@ import {
43
44
  writePolicyEvidenceFile,
44
45
  writeSessionIndexFile,
45
46
  writeTraceEvidenceExportFile
46
- } from "./chunk-FCTZLWP7.js";
47
+ } from "./chunk-YS5KIWLY.js";
47
48
 
48
49
  // src/cli.ts
49
50
  import { readFileSync } from "fs";
@@ -205,7 +206,7 @@ async function discover(args) {
205
206
  const sinceMs = args.since ? Date.parse(args.since) : void 0;
206
207
  const out = [];
207
208
  for (const adapter of adaptersFor(args)) {
208
- let refs = await adapter.locate({ cwd: args.cwd, sinceMs });
209
+ let refs = await locateSessions(adapter, { cwd: args.cwd, sinceMs });
209
210
  if (args.last > 0) refs = refs.slice(0, args.last);
210
211
  out.push({ adapter, refs });
211
212
  }
package/dist/index.d.ts CHANGED
@@ -219,6 +219,12 @@ declare function selectAdapters(opts: AdapterSelection): HarnessTraceAdapter[];
219
219
  * computed ONCE per session; it is fail-safe and never throws.
220
220
  */
221
221
  declare function parseSession(adapter: HarnessTraceAdapter, ref: SessionRef): Promise<OtlpSpan[]>;
222
+ /** Locate through every equivalent git worktree for the selected cwd, then
223
+ * dedupe and apply a boundary-aware final filter. */
224
+ declare function locateSessions(adapter: HarnessTraceAdapter, opts?: {
225
+ cwd?: string;
226
+ sinceMs?: number;
227
+ }): Promise<SessionRef[]>;
222
228
  interface ScanOptions extends AdapterSelection {
223
229
  /** Filter by working directory (exact/prefix). */
224
230
  cwd?: string;
@@ -258,6 +264,10 @@ interface RepoResolution {
258
264
  * `git@host:owner/repo.git` SCP-style forms. Returns null when unparseable.
259
265
  */
260
266
  declare function normalizeRemote(url: string): string | null;
267
+ /** Expand a selected cwd to every checked-out worktree for the same git repo. */
268
+ declare function equivalentGitCwds(cwd: string | null | undefined): Promise<string[]>;
269
+ /** Boundary-aware cwd matching; `/repo` matches `/repo/src`, not `/repo-old`. */
270
+ declare function cwdMatchesSelection(cwd: string | null | undefined, selections: readonly string[]): boolean;
261
271
  /**
262
272
  * Resolve per-session repo/git resource attributes from a session's cwd.
263
273
  * Fail-safe and never throws; see the module doc for the derivation contract.
@@ -1639,4 +1649,4 @@ interface ExecuteOptions {
1639
1649
  /** Send the NEW items (or, on dryRun, write the redacted OTLP that would send). */
1640
1650
  declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
1641
1651
 
1642
- export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CODING_REDACTION_RULES, CONTENT_CAP, CORRECTIVE_REACTIONS, ClaudeAdapter, CodexAdapter, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, CopilotAdapter, DEFAULT_HARNESS, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, type FindingStore, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type ImprovementAdapter, type ImprovementAdapterInput, type ImprovementProposal, type InspectSessionIndexOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type RecommendationWriter, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type TraceClaim, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveAction, type TraceLiveActionKind, type TraceLiveAnalysisContext, type TraceLiveAnalyst, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveLoop, type TraceLiveSeverity, type TraceRecommendation, type TraceReplayProof, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, alreadyUploaded, analyzeAdoption, analyzeLiveBatch, analyzeReactions, analyzeSpans, applyRedactor, buildPolicyEvidenceRecord, buildSessionIndex, buildSessionIndexFromRows, buildTraceFindingPacket, capText, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessions, commandAnalyzer, commandRedactor, countSkillRunsJsonl, defaultTraceLiveAnalysts, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, haloAnalyzer, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, parseIsoToEpochMs, parseSession, parseSince, planUpload, readSessionIndexFile, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovementLoop, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, span, stampRepoAttrs, streamSessions, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
1652
+ export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CODING_REDACTION_RULES, CONTENT_CAP, CORRECTIVE_REACTIONS, ClaudeAdapter, CodexAdapter, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, CopilotAdapter, DEFAULT_HARNESS, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, type FindingStore, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type ImprovementAdapter, type ImprovementAdapterInput, type ImprovementProposal, type InspectSessionIndexOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type RecommendationWriter, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type TraceClaim, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceFindingPacket, type TraceImprovementArtifacts, type TraceImprovementOptions, type TraceImprovementResult, type TraceIndexedFile, type TraceInspectionArea, type TraceInspectionFinding, type TraceInspectionReport, type TraceInspectionSeverity, type TraceInvestigationOptions, type TraceInvestigationResult, type TraceLiveAction, type TraceLiveActionKind, type TraceLiveAnalysisContext, type TraceLiveAnalyst, type TraceLiveBatch, type TraceLiveEvidence, type TraceLiveFinding, type TraceLiveLoop, type TraceLiveSeverity, type TraceRecommendation, type TraceReplayProof, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, alreadyUploaded, analyzeAdoption, analyzeLiveBatch, analyzeReactions, analyzeSpans, applyRedactor, buildPolicyEvidenceRecord, buildSessionIndex, buildSessionIndexFromRows, buildTraceFindingPacket, capText, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessions, commandAnalyzer, commandRedactor, countSkillRunsJsonl, cwdMatchesSelection, defaultTraceLiveAnalysts, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, haloAnalyzer, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, parseIsoToEpochMs, parseSession, parseSince, planUpload, readSessionIndexFile, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovementLoop, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, span, stampRepoAttrs, streamSessions, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
package/dist/index.js CHANGED
@@ -38,7 +38,9 @@ import {
38
38
  commandAnalyzer,
39
39
  commandRedactor,
40
40
  countSkillRunsJsonl,
41
+ cwdMatchesSelection,
41
42
  defaultTraceLiveAnalysts,
43
+ equivalentGitCwds,
42
44
  executeUpload,
43
45
  exportTraceEvidenceFile,
44
46
  exportTraceEvidenceRows,
@@ -49,6 +51,7 @@ import {
49
51
  listAdapters,
50
52
  loadState,
51
53
  loadTracesConfig,
54
+ locateSessions,
52
55
  looksLikeAgentPrompt,
53
56
  mergeTracesConfig,
54
57
  normalizeRemote,
@@ -95,7 +98,7 @@ import {
95
98
  writeSessionIndexFile,
96
99
  writeTraceEvidenceExportFile,
97
100
  writeTraceImprovementArtifacts
98
- } from "./chunk-FCTZLWP7.js";
101
+ } from "./chunk-YS5KIWLY.js";
99
102
 
100
103
  // src/collect.ts
101
104
  async function collectSessions(opts = {}) {
@@ -164,7 +167,9 @@ export {
164
167
  commandRedactor,
165
168
  countSkillRunsJsonl,
166
169
  createHostedClient,
170
+ cwdMatchesSelection,
167
171
  defaultTraceLiveAnalysts,
172
+ equivalentGitCwds,
168
173
  executeUpload,
169
174
  exportTraceEvidenceFile,
170
175
  exportTraceEvidenceRows,
@@ -176,6 +181,7 @@ export {
176
181
  listAdapters,
177
182
  loadState,
178
183
  loadTracesConfig,
184
+ locateSessions,
179
185
  looksLikeAgentPrompt,
180
186
  makeFinding,
181
187
  mergeTracesConfig,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/traces",
3
- "version": "0.8.22",
3
+ "version": "0.8.23",
4
4
  "description": "Point it at your coding-agent session traces (Claude Code, Codex, OpenCode, Gemini, Pi, …) and get failure-mode + efficiency findings. CLI + SDK over the @tangle-network/agent-eval analyst suite — observe live sessions, run your own analysts, redact, and upload to the Tangle Intelligence Platform.",
5
5
  "type": "module",
6
6
  "license": "MIT",