@tangle-network/traces 0.8.24 → 0.8.25

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.
@@ -2417,6 +2417,56 @@ function stampRepoAttrs(spans, attrs) {
2417
2417
  }
2418
2418
  return spans;
2419
2419
  }
2420
+ function replaceRepoAttrs(spans, attrs) {
2421
+ for (const s of spans) {
2422
+ for (const [key, value] of Object.entries(attrs)) s.attributes[key] = value;
2423
+ }
2424
+ }
2425
+ async function resolutionForWorkdirEvidence(evidence3, cache) {
2426
+ const cached = cache.get(evidence3.path);
2427
+ if (cached !== void 0) return cached;
2428
+ const cwd = await repoCandidateForPath(evidence3.path);
2429
+ if (!cwd) {
2430
+ cache.set(evidence3.path, null);
2431
+ return null;
2432
+ }
2433
+ const attrs = await resolveRepoAttrs(cwd);
2434
+ const resolved = attrs[ATTR.SUBJECT_KEY] ? {
2435
+ attrs: { ...attrs, [ATTR.REPO_RESOLUTION_SOURCE]: evidence3.source },
2436
+ cwd: attrs[ATTR.CWD] ?? cwd,
2437
+ source: evidence3.source
2438
+ } : null;
2439
+ cache.set(evidence3.path, resolved);
2440
+ return resolved;
2441
+ }
2442
+ async function resolveSpanWorkdirRepoAttrs(span2, cache) {
2443
+ const candidates = /* @__PURE__ */ new Map();
2444
+ const add = (value, weight) => {
2445
+ if (!value?.cwd) return;
2446
+ const existing = candidates.get(value.cwd);
2447
+ if (existing) {
2448
+ existing.score += weight;
2449
+ return;
2450
+ }
2451
+ candidates.set(value.cwd, { repo: value, score: weight, order: candidates.size });
2452
+ };
2453
+ for (const evidence3 of extractAbsolutePaths([span2])) {
2454
+ if (evidence3.source !== "span-workdir") continue;
2455
+ add(await resolutionForWorkdirEvidence(evidence3, cache), evidence3.weight);
2456
+ }
2457
+ const byScore = (a, b) => b.score - a.score || a.order - b.order;
2458
+ const resolved = [...candidates.values()];
2459
+ const selected = resolved.filter((candidate) => candidate.repo.attrs[ATTR.GIT_REPOSITORY]).sort(byScore)[0] ?? resolved.filter((candidate) => candidate.repo.attrs[ATTR.SUBJECT_KEY]).sort(byScore)[0];
2460
+ if (!selected) return null;
2461
+ return selected.repo;
2462
+ }
2463
+ async function stampSpanWorkdirRepoAttrs(spans) {
2464
+ const cache = /* @__PURE__ */ new Map();
2465
+ for (const span2 of spans) {
2466
+ const repo = await resolveSpanWorkdirRepoAttrs(span2, cache);
2467
+ if (repo?.attrs && Object.keys(repo.attrs).length > 0) replaceRepoAttrs([span2], repo.attrs);
2468
+ }
2469
+ }
2420
2470
 
2421
2471
  // src/session-source.ts
2422
2472
  async function parseSession(adapter, ref) {
@@ -2424,6 +2474,7 @@ async function parseSession(adapter, ref) {
2424
2474
  const repo = await resolveSessionRepoAttrs(ref.cwd, spans);
2425
2475
  if (repo.cwd) ref.cwd = repo.cwd;
2426
2476
  stampRepoAttrs(spans, repo.attrs);
2477
+ await stampSpanWorkdirRepoAttrs(spans);
2427
2478
  return spans;
2428
2479
  }
2429
2480
  function refKey(ref) {
@@ -5236,6 +5287,7 @@ export {
5236
5287
  resolveRepoAttrs,
5237
5288
  resolveSessionRepoAttrs,
5238
5289
  stampRepoAttrs,
5290
+ stampSpanWorkdirRepoAttrs,
5239
5291
  parseSession,
5240
5292
  locateSessions,
5241
5293
  scanSessions,
package/dist/cli.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  writePolicyEvidenceFile,
45
45
  writeSessionIndexFile,
46
46
  writeTraceEvidenceExportFile
47
- } from "./chunk-4LLOYL36.js";
47
+ } from "./chunk-SV7GW5LB.js";
48
48
 
49
49
  // src/cli.ts
50
50
  import { readFileSync } from "fs";
package/dist/index.d.ts CHANGED
@@ -281,6 +281,7 @@ declare function resolveSessionRepoAttrs(cwd: string | null | undefined, spans:
281
281
  * same array for ergonomic chaining. A no-op when `attrs` is empty.
282
282
  */
283
283
  declare function stampRepoAttrs(spans: readonly OtlpSpan[], attrs: RepoAttrs): readonly OtlpSpan[];
284
+ declare function stampSpanWorkdirRepoAttrs(spans: readonly OtlpSpan[]): Promise<void>;
284
285
 
285
286
  /**
286
287
  * Claude Code adapter — `~/.claude/projects/<encoded-cwd>/<session>.jsonl`.
@@ -1650,4 +1651,4 @@ interface ExecuteOptions {
1650
1651
  /** Send the NEW items (or, on dryRun, write the redacted OTLP that would send). */
1651
1652
  declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
1652
1653
 
1653
- 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 };
1654
+ 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, stampSpanWorkdirRepoAttrs, streamSessions, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
package/dist/index.js CHANGED
@@ -83,6 +83,7 @@ import {
83
83
  sessionHash,
84
84
  span,
85
85
  stampRepoAttrs,
86
+ stampSpanWorkdirRepoAttrs,
86
87
  streamSessions,
87
88
  textIsSynthetic,
88
89
  toOpenInferenceSpan,
@@ -98,7 +99,7 @@ import {
98
99
  writeSessionIndexFile,
99
100
  writeTraceEvidenceExportFile,
100
101
  writeTraceImprovementArtifacts
101
- } from "./chunk-4LLOYL36.js";
102
+ } from "./chunk-SV7GW5LB.js";
102
103
 
103
104
  // src/collect.ts
104
105
  async function collectSessions(opts = {}) {
@@ -216,6 +217,7 @@ export {
216
217
  sessionHash,
217
218
  span,
218
219
  stampRepoAttrs,
220
+ stampSpanWorkdirRepoAttrs,
219
221
  streamSessions,
220
222
  textIsSynthetic,
221
223
  toOpenInferenceSpan,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/traces",
3
- "version": "0.8.24",
3
+ "version": "0.8.25",
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",