@tangle-network/traces 0.18.0 → 0.19.1
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 +17 -0
- package/dist/{chunk-TCTZ7DUY.js → chunk-YVCHWHCA.js} +7 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +34 -1
- package/dist/index.js +113 -1
- package/docs/trace-analysts.md +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -566,6 +566,23 @@ Do not pass `--llm`; the command is model-backed by definition.
|
|
|
566
566
|
|
|
567
567
|
## Session facts
|
|
568
568
|
|
|
569
|
+
The SDK also accepts verified retained captures through
|
|
570
|
+
`parseRetainedSession({ harness, nativeSessionId, files, signal? })`.
|
|
571
|
+
Pass files as `{ path, content }` with their original relative layout.
|
|
572
|
+
Runtime or the caller owns custody, digest verification and capture completeness.
|
|
573
|
+
The reader uses existing adapters and selects a file only when native records
|
|
574
|
+
establish the supplied session identity.
|
|
575
|
+
It does not inspect the host session catalog or infer identity from filenames.
|
|
576
|
+
Directory-only stores and formats without a recorded native identity remain unavailable.
|
|
577
|
+
The returned source files, duplicate snapshots and unselected files explain the selection.
|
|
578
|
+
Identical or append-only copies count once; divergent histories remain unavailable.
|
|
579
|
+
Parsing is bounded to 1024 text files, 16 MiB per file, and 64 MiB total.
|
|
580
|
+
No model calls occur.
|
|
581
|
+
Call `buildSessionFactsReport(selection.spans, { includeContent: false })` to
|
|
582
|
+
withhold native bodies from the resulting facts.
|
|
583
|
+
The reader itself returns spans containing native content, for local trusted consumers only.
|
|
584
|
+
|
|
585
|
+
|
|
569
586
|
The same facts sheet includes observed tool outcomes, captured input/output byte
|
|
570
587
|
volumes, call-to-result intervals, compaction boundaries and available context
|
|
571
588
|
sizes, spawn intervals, and existing skill invocation/document-read evidence.
|
|
@@ -1488,6 +1488,7 @@ var AmpAdapter = class {
|
|
|
1488
1488
|
const spans = [
|
|
1489
1489
|
span({ traceId, spanId: rootId, parentSpanId: null, name: "session", kind: "AGENT", startTime: start, service: SERVICE, agent: SERVICE })
|
|
1490
1490
|
];
|
|
1491
|
+
if (thread.id) spans[0].attributes["tangle.sessionId"] = thread.id;
|
|
1491
1492
|
const toolByUseId = /* @__PURE__ */ new Map();
|
|
1492
1493
|
let step = 0;
|
|
1493
1494
|
for (const m of messages) {
|
|
@@ -2212,6 +2213,7 @@ function normalizeClaudeIds(spans) {
|
|
|
2212
2213
|
const sourceTraceId = item.trace_id;
|
|
2213
2214
|
const sourceSpanId = item.span_id;
|
|
2214
2215
|
const sourceParentSpanId = item.parent_span_id;
|
|
2216
|
+
item.attributes["tangle.sessionId"] = sourceTraceId;
|
|
2215
2217
|
item.attributes[CLAUDE_SOURCE_TRACE_ID] = sourceTraceId;
|
|
2216
2218
|
item.attributes[CLAUDE_SOURCE_SPAN_ID] = sourceSpanId;
|
|
2217
2219
|
if (sourceParentSpanId !== null) {
|
|
@@ -5130,6 +5132,7 @@ var CodexExecAdapter = class {
|
|
|
5130
5132
|
service: SERVICE4,
|
|
5131
5133
|
agent: SERVICE4,
|
|
5132
5134
|
extra: {
|
|
5135
|
+
"tangle.sessionId": threadId,
|
|
5133
5136
|
"traces.codex.stream_format": "exec-jsonl",
|
|
5134
5137
|
"traces.session.role": "operator"
|
|
5135
5138
|
}
|
|
@@ -5594,6 +5597,7 @@ var FactoryAdapter = class {
|
|
|
5594
5597
|
"session.output_tokens": settings.tokenUsage.outputTokens ?? 0
|
|
5595
5598
|
} : void 0
|
|
5596
5599
|
});
|
|
5600
|
+
if (sessionLine?.id) root.attributes["tangle.sessionId"] = sessionLine.id;
|
|
5597
5601
|
return [root, ...spans];
|
|
5598
5602
|
}
|
|
5599
5603
|
};
|
|
@@ -5653,6 +5657,7 @@ var ForgeAdapter = class {
|
|
|
5653
5657
|
const spans = [
|
|
5654
5658
|
span({ traceId, spanId: rootId, parentSpanId: null, name: "session", kind: "AGENT", startTime: (/* @__PURE__ */ new Date(0)).toISOString(), service: SERVICE7, agent: SERVICE7 })
|
|
5655
5659
|
];
|
|
5660
|
+
if (ctx.conversation_id) spans[0].attributes["tangle.sessionId"] = ctx.conversation_id;
|
|
5656
5661
|
const toolByCallId = /* @__PURE__ */ new Map();
|
|
5657
5662
|
let step = 0;
|
|
5658
5663
|
let lastLlm = rootId;
|
|
@@ -5833,6 +5838,7 @@ var GeminiFamilyAdapter = class {
|
|
|
5833
5838
|
agent: this.service
|
|
5834
5839
|
})
|
|
5835
5840
|
];
|
|
5841
|
+
if (session.sessionId) spans[0].attributes["tangle.sessionId"] = session.sessionId;
|
|
5836
5842
|
let step = 0;
|
|
5837
5843
|
for (const m of messages) {
|
|
5838
5844
|
const mid = m.id ?? `m${step}`;
|
|
@@ -6418,6 +6424,7 @@ var PiAdapter = class {
|
|
|
6418
6424
|
agent: SERVICE9,
|
|
6419
6425
|
extra: { "traces.pi.stop_reason": terminal.stopReason }
|
|
6420
6426
|
});
|
|
6427
|
+
if (sessionLine?.id) root.attributes["tangle.sessionId"] = sessionLine.id;
|
|
6421
6428
|
return [root, ...spans];
|
|
6422
6429
|
}
|
|
6423
6430
|
};
|
package/dist/cli.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4940,4 +4940,37 @@ interface ExecuteOptions {
|
|
|
4940
4940
|
/** Send the final, new outbound items (or write their dry-run OTLP). */
|
|
4941
4941
|
declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
|
|
4942
4942
|
|
|
4943
|
-
export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalysisEngineFromEnvOptions, type AnalyzeOptions, type AnalyzeResult, type AnswerSchema, type AssembleSessionBundleOptions, BLOBS_DIR, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CHANGED_FILE_LIST_CAP, CITATION_NORMALIZATION_VERSION, CONTENT_CAP, COORDINATION_LOG_FILE, CORRECTIVE_REACTIONS, type ChangedFileFact, type ChatTrajectory, type ChatTrajectoryMessage, type ChatTrajectoryOptions, ClaudeAdapter, type CodeTraceBenchFileRef, type CodeTraceBenchImportOptions, type CodeTraceBenchImportReceipt, type CodeTraceBenchImportResult, type CodeTraceBenchImportedTrace, type CodeTraceBenchStep, CodexAdapter, CodexExecAdapter, CodexExecStreamError, CodexTaskScopeError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, type CollectSessionSelectionOptions, type CollectSessionWorkflowOptions, type CompactionMeasurement, type ConformanceRenderOptions, type ContentFootprint, type CoordinationLog, type CoordinationQuestion, type CoordinationSteer, CopilotAdapter, type CorruptionMode, type CoveredMeasurement, DEFAULT_ANALYST_MODEL, DEFAULT_ASK_CONCURRENCY, DEFAULT_HARNESS, DEFAULT_SANDBOX_BASE_URL, EMPTY_SPAN_RUN_SNAPSHOT, EXPORT_RULE, EmptySessionError, type EvidenceOnlyVerdict, type ExcludedTurnFact, type ExecuteOptions, type ExportRule, type ExternalAnalysisKind, type ExternalAnalysisPayload, type ExternalAnalysisResult, type ExternalAnalyzer, type ExternalAnalyzerOptions, type ExternalDiscoveryCandidate, FACT_LIST_CAP, FACT_TEXT_CAP, FactoryAdapter, type FailureFollowUp, type FailureFollowUpReport, type FileRunContextReaderOptions, type FinalMessageFact, type FindSessionTextLeaksOptions, type FindingRejectionCounts, type FindingRejectionReasons, type FindingRejectionTally, type FindingsFileOutcome, type FollowUpKind, ForgeAdapter, GeminiAdapter, type HaloAnalyzerOptions, type HaloReasoningEffort, type HarnessTraceAdapter, type HodoscopeAnalyzerOptions, type HodoscopeInput, type HodoscopeMessage, type HodoscopeSourceMapEntry, type HodoscopeTrajectory, INGEST_SOURCE_CLI, INHERITED_SOURCE_ATTR, INHERITED_SPANS_OMITTED_ATTR, INHERITED_SPAN_ATTR, INHERITED_SPAN_COUNT_ATTR, type InheritedSpanSource, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type LoopConvergence, type LoopConvergenceReport, type LoopIteration, type LoopTrend, type LoopTrendBasis, MAX_SHELL_DEPTH, MAX_TRACE_QUESTION_CHARS, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpIngestIssue, type OtlpIngestIssueKind, type OtlpInput, type OtlpInputFile, type OtlpRowConversion, type OtlpSpan, type OtlpSpanKind, type OtlpSpanLink, type OtlpStatusCode, POLICY_EVIDENCE_NOTE, PREPARED_CONTEXT_BYTE_CEILING, type ParentTaskResolution, type ParseOptions, PartialUploadError, PiAdapter, type PiAdapterOptions, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, type PrimeAnalyzerOptions, type PrimeTransport, type PrimeTransportRequest, type PrimeTransportResponse, type ProjectSessionBundleOptions, type ProjectSessionBundleResult, type PullRequestFact, type PullRequestFacts, type PullRequestReading, QwenAdapter, REACTIONS, RESULT_FILE, RULE, type Reaction, type ReactionReport, type ReactionSessionReport, type RedactSpansOptions, type Redactor, type RefusedSession, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type ResolvedOtlpInput, type RunContextJournal, type RunContextNode, type RunContextResult, type RunContextSnapshot, type RunDiffOptions, type RunDiffReport, type RunDiffSide, type RunResult, type RunWatchSnapshot, type RunWatchTarget, type RuntimeTrace, SESSION_FACTS_MEASUREMENT_VERSION, SESSION_FACTS_VERSION_SUFFIX, SESSION_TOKEN_TOTAL_ATTR, SOURCE_ATTRIBUTE_PREFIX, SPAN_SYNTHESIZED_ATTR, SPAWN_JOURNAL_FILE, STATUS_MARK, SYNTHESIZED_SOURCE_ATTR, SYNTHESIZED_SPAN_ATTR, type SandboxReplayBackendOptions, type ScanOptions, type ScannedSession, type SessionBatch, type SessionBundleAbsence, type SessionBundleCarriedSignatures, type SessionBundleExclusion, type SessionBundleExclusionRule, type SessionBundleFile, type SessionBundleIssue, type SessionBundleIssueKind, type SessionBundleLeakCheck, type SessionBundleLedgerSlice, type SessionBundleManifest, type SessionBundleProjection, type SessionBundleResult, type SessionBundleSliceRule, type SessionBundleVerification, type SessionBundleView, type SessionCorruptionReceipt, type SessionEnvironment, type SessionFact, type SessionFacts, type SessionFactsOptions, type SessionFactsReport, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionMeasurements, type SessionRef, type SessionRelationship, type SessionRole, type SessionSeedGroup, type SessionSelection, type SessionSelectionRow, type SessionSourceFile, type SessionTextLeak, type SessionTextLeakReport, type SessionTurnFact, type SessionWorkflow, SessionWorkflowError, type SessionWorkflowErrorCode, type SessionWorkflowIssue, type SessionWorkflowSession, type SessionWorkflowSummary, type SkippedAnalysis, type SkippedInputFile, type SourceRecordReference, type SpanInput, type SpanNodeStatus, type SpanRedaction, type SpanRunNode, type SpanRunSnapshot, type SpanStructure, type SpawnedChildResolution, type SpendRoll, type SteeringChainReport, type SteeringEdge, type SubagentSpawnFact, TRACE_QUESTION_PREVIEW_HEAD_CHARS, type ToolMeasurement, type TraceAgenticRoute, type TraceAgenticRouteReason, type TraceAgenticRouteReasonCode, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceExecutionOptions, 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 TraceQuestion, type TraceQuestionAnswer, type TraceQuestionCitation, type TraceQuestionFailureKind, type TraceQuestionTrace, type TraceQuestionsArtifacts, type TraceQuestionsOptions, type TraceQuestionsResult, type TraceQuestionsTotals, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type TurnActorCount, type UnavailableCapabilities, type UploadBackend, type UploadIdentity, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, type VerifySafeOptions, type VerifySafeResult, type WatchRunTargetOptions, ZERO_ROLL, type ZaiChatCallerOptions, addSpend, alreadyUploaded, analysisEngineFromEnv, analyzeAdoption, analyzeLiveBatch, analyzeLoopConvergence, analyzeReactions, analyzeSpans, analyzeSteeringChain, answerSchemaErrors, applyRedactor, assembleSessionBundle, assertAnswerSchema, assertSandboxReachable, assessSpans, buildPolicyEvidenceRecord, buildSessionFactsReport, buildSessionIndex, buildSessionIndexFromRows, buildSpanRunTree, buildTraceFindingPacket, capText, chatTrajectoryToSpans, classifyEvidenceOnlyPath, classifyFailureFollowUps, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessionSelection, collectSessionWorkflow, collectSessions, commandAnalyzer, commandRedactor, commandTextFromInput, computeAdoption, computeSessionFacts, conformanceOfSpans, connectors, countSkillRunsJsonl, createBundleSourceReader, createFindingRejectionTally, cwdMatchesSelection, cwdMatchesSelectionResolved, defaultTraceLiveAnalysts, describeSessionRelationship, diffRuns, engineCallReservationFloorUsd, environmentAttributes, environmentFromSpanAttributes, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, externalFailureMessage, fileRunContextSupervisorRunReader, fileSha256, findContextRoot, findSessionTextLeaks, findSpanSourceFiles, findingRejection, findingRejectionDetail, forEachTreeNode, formatFindingRejections, formatVerdict, haloAnalyzer, hashSessionBundleFiles, hodoscopeAnalyzer, httpJsonTransport, importCodeTraceBench, incompleteInputsNote, indexSessionIdsByTrace, inferRole, inferSpanKind, inspectSessionIndex, int, isBridgeMismatchError, isChatTrajectory, isChatTrajectoryMessage, isFileRunContextDir, isInheritedSpan, isSynthesizedSpan, iterSerializedSpans, knownHarnesses, listAdapters, listSessionBundleFiles, loadState, loadTraceQuestionsFile, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeRolls, mergeTracesConfig, ms, normalizeAnalystCitations, normalizeRemote, normalizeTraceQuestions, otlpRowToSpan, outboundHash, parseIsoToEpochMs, parseJsonAnswer, parseSession, parseSince, planTraceAgenticRoute, planUpload, primeAnalyzer, projectSessionBundle, readCoordinationLog, readFileRunContext, readJsonFile, readJsonl, readOtlpInput, readPullRequests, readRunContextJournal, readRunContextSnapshot, readRunSide, readRunWatchSnapshot, readSessionBundleManifest, readSessionIndexFile, readSpanRunSnapshot, recordSessionCorruption, redactSpans, renderConformance, renderInspectionReport, renderRunContextSnapshot, renderRunDiff, renderRunWatchSnapshot, renderSessionFacts, renderSessionFactsContext, renderSpanRunSnapshot, renderTraceQuestionInstructions, renderTraceQuestionPrompt, renderTraceQuestionsReport, renderValidation, resolveAdapter, resolveOtlpInputFiles, resolveRepoAttrs, resolveRunContextDir, resolveRunWatchTarget, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTotals, runTraceImprovement, runTraceInvestigation, runTraceQuestions, runTraceStoreInvestigation, sandboxReplayBackend, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionFactsContext, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, sessionTextSignatures, shellCommands, skippedAnalyses, span, spanRunTotals, stampEnvironmentAttrs, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, summarizeSpanStructure, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, tokens, totalAgenticFailureMessage, totalFindingRejections, traceAgenticKinds, traceCitationsInText, traceStreamEventsFromSpans, unavailableCapabilities, uploadKey, usd, userPromptSpan, validateOtlpSpans, validationExitCode, verdictExitCode, verifyFindingsInSandbox, verifySafe, verifySessionBundle, watchRunTarget, watchSessions, withSessionFactsContext, wrap, writeHodoscopeInput, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionBundleManifest, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts, writeTraceQuestionsArtifacts, zaiChatCaller, zeroPricedCost };
|
|
4943
|
+
declare const RETAINED_SESSION_READER_VERSION = "2";
|
|
4944
|
+
interface RetainedSessionFile {
|
|
4945
|
+
readonly path: string;
|
|
4946
|
+
readonly content: string;
|
|
4947
|
+
}
|
|
4948
|
+
interface RetainedSessionSelection {
|
|
4949
|
+
readonly status: 'selected' | 'unavailable';
|
|
4950
|
+
readonly reason: string | null;
|
|
4951
|
+
readonly sessionId: string | null;
|
|
4952
|
+
readonly sourceFiles: readonly {
|
|
4953
|
+
readonly path: string;
|
|
4954
|
+
readonly sha256: string;
|
|
4955
|
+
}[];
|
|
4956
|
+
readonly duplicateFiles: readonly string[];
|
|
4957
|
+
readonly unselectedFiles: readonly {
|
|
4958
|
+
readonly path: string;
|
|
4959
|
+
readonly reason: string;
|
|
4960
|
+
}[];
|
|
4961
|
+
readonly spans: readonly OtlpSpan[];
|
|
4962
|
+
}
|
|
4963
|
+
/**
|
|
4964
|
+
* Parse an explicitly retained capture without consulting the host's session catalog.
|
|
4965
|
+
* Native identity must come from the adapter's records. A path, caller supplied
|
|
4966
|
+
* fallback ID, or worker name never establishes identity. Runtime owns custody,
|
|
4967
|
+
* hash verification, capture completeness, and the binding to its node.
|
|
4968
|
+
*/
|
|
4969
|
+
declare function parseRetainedSession(input: {
|
|
4970
|
+
readonly harness: string;
|
|
4971
|
+
readonly nativeSessionId: string | null;
|
|
4972
|
+
readonly files: readonly RetainedSessionFile[];
|
|
4973
|
+
readonly signal?: AbortSignal;
|
|
4974
|
+
}): Promise<RetainedSessionSelection>;
|
|
4975
|
+
|
|
4976
|
+
export { ACTOR_ATTR, ATTR, type Actor, type AdoptionOptions, type AdoptionReport, AmpAdapter, type AnalysisEngineFromEnvOptions, type AnalyzeOptions, type AnalyzeResult, type AnswerSchema, type AssembleSessionBundleOptions, BLOBS_DIR, type BuildPolicyEvidenceOptions, type BuildSessionIndexOptions, type BuildTraceFindingPacketOptions, CHANGED_FILE_LIST_CAP, CITATION_NORMALIZATION_VERSION, CONTENT_CAP, COORDINATION_LOG_FILE, CORRECTIVE_REACTIONS, type ChangedFileFact, type ChatTrajectory, type ChatTrajectoryMessage, type ChatTrajectoryOptions, ClaudeAdapter, type CodeTraceBenchFileRef, type CodeTraceBenchImportOptions, type CodeTraceBenchImportReceipt, type CodeTraceBenchImportResult, type CodeTraceBenchImportedTrace, type CodeTraceBenchStep, CodexAdapter, CodexExecAdapter, CodexExecStreamError, CodexTaskScopeError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, type CollectSessionSelectionOptions, type CollectSessionWorkflowOptions, type CompactionMeasurement, type ConformanceRenderOptions, type ContentFootprint, type CoordinationLog, type CoordinationQuestion, type CoordinationSteer, CopilotAdapter, type CorruptionMode, type CoveredMeasurement, DEFAULT_ANALYST_MODEL, DEFAULT_ASK_CONCURRENCY, DEFAULT_HARNESS, DEFAULT_SANDBOX_BASE_URL, EMPTY_SPAN_RUN_SNAPSHOT, EXPORT_RULE, EmptySessionError, type EvidenceOnlyVerdict, type ExcludedTurnFact, type ExecuteOptions, type ExportRule, type ExternalAnalysisKind, type ExternalAnalysisPayload, type ExternalAnalysisResult, type ExternalAnalyzer, type ExternalAnalyzerOptions, type ExternalDiscoveryCandidate, FACT_LIST_CAP, FACT_TEXT_CAP, FactoryAdapter, type FailureFollowUp, type FailureFollowUpReport, type FileRunContextReaderOptions, type FinalMessageFact, type FindSessionTextLeaksOptions, type FindingRejectionCounts, type FindingRejectionReasons, type FindingRejectionTally, type FindingsFileOutcome, type FollowUpKind, ForgeAdapter, GeminiAdapter, type HaloAnalyzerOptions, type HaloReasoningEffort, type HarnessTraceAdapter, type HodoscopeAnalyzerOptions, type HodoscopeInput, type HodoscopeMessage, type HodoscopeSourceMapEntry, type HodoscopeTrajectory, INGEST_SOURCE_CLI, INHERITED_SOURCE_ATTR, INHERITED_SPANS_OMITTED_ATTR, INHERITED_SPAN_ATTR, INHERITED_SPAN_COUNT_ATTR, type InheritedSpanSource, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type LoopConvergence, type LoopConvergenceReport, type LoopIteration, type LoopTrend, type LoopTrendBasis, MAX_SHELL_DEPTH, MAX_TRACE_QUESTION_CHARS, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpIngestIssue, type OtlpIngestIssueKind, type OtlpInput, type OtlpInputFile, type OtlpRowConversion, type OtlpSpan, type OtlpSpanKind, type OtlpSpanLink, type OtlpStatusCode, POLICY_EVIDENCE_NOTE, PREPARED_CONTEXT_BYTE_CEILING, type ParentTaskResolution, type ParseOptions, PartialUploadError, PiAdapter, type PiAdapterOptions, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, type PrimeAnalyzerOptions, type PrimeTransport, type PrimeTransportRequest, type PrimeTransportResponse, type ProjectSessionBundleOptions, type ProjectSessionBundleResult, type PullRequestFact, type PullRequestFacts, type PullRequestReading, QwenAdapter, REACTIONS, RESULT_FILE, RETAINED_SESSION_READER_VERSION, RULE, type Reaction, type ReactionReport, type ReactionSessionReport, type RedactSpansOptions, type Redactor, type RefusedSession, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type ResolvedOtlpInput, type RetainedSessionFile, type RetainedSessionSelection, type RunContextJournal, type RunContextNode, type RunContextResult, type RunContextSnapshot, type RunDiffOptions, type RunDiffReport, type RunDiffSide, type RunResult, type RunWatchSnapshot, type RunWatchTarget, type RuntimeTrace, SESSION_FACTS_MEASUREMENT_VERSION, SESSION_FACTS_VERSION_SUFFIX, SESSION_TOKEN_TOTAL_ATTR, SOURCE_ATTRIBUTE_PREFIX, SPAN_SYNTHESIZED_ATTR, SPAWN_JOURNAL_FILE, STATUS_MARK, SYNTHESIZED_SOURCE_ATTR, SYNTHESIZED_SPAN_ATTR, type SandboxReplayBackendOptions, type ScanOptions, type ScannedSession, type SessionBatch, type SessionBundleAbsence, type SessionBundleCarriedSignatures, type SessionBundleExclusion, type SessionBundleExclusionRule, type SessionBundleFile, type SessionBundleIssue, type SessionBundleIssueKind, type SessionBundleLeakCheck, type SessionBundleLedgerSlice, type SessionBundleManifest, type SessionBundleProjection, type SessionBundleResult, type SessionBundleSliceRule, type SessionBundleVerification, type SessionBundleView, type SessionCorruptionReceipt, type SessionEnvironment, type SessionFact, type SessionFacts, type SessionFactsOptions, type SessionFactsReport, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionMeasurements, type SessionRef, type SessionRelationship, type SessionRole, type SessionSeedGroup, type SessionSelection, type SessionSelectionRow, type SessionSourceFile, type SessionTextLeak, type SessionTextLeakReport, type SessionTurnFact, type SessionWorkflow, SessionWorkflowError, type SessionWorkflowErrorCode, type SessionWorkflowIssue, type SessionWorkflowSession, type SessionWorkflowSummary, type SkippedAnalysis, type SkippedInputFile, type SourceRecordReference, type SpanInput, type SpanNodeStatus, type SpanRedaction, type SpanRunNode, type SpanRunSnapshot, type SpanStructure, type SpawnedChildResolution, type SpendRoll, type SteeringChainReport, type SteeringEdge, type SubagentSpawnFact, TRACE_QUESTION_PREVIEW_HEAD_CHARS, type ToolMeasurement, type TraceAgenticRoute, type TraceAgenticRouteReason, type TraceAgenticRouteReasonCode, type TraceContextIndex, type TraceContextRoot, type TraceEvidenceExportOptions, type TraceEvidenceExportResult, type TraceEvidenceFormatOption, type TraceEvidenceInputFormat, type TraceEvidenceRow, type TraceExecutionOptions, 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 TraceQuestion, type TraceQuestionAnswer, type TraceQuestionCitation, type TraceQuestionFailureKind, type TraceQuestionTrace, type TraceQuestionsArtifacts, type TraceQuestionsOptions, type TraceQuestionsResult, type TraceQuestionsTotals, type TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type TurnActorCount, type UnavailableCapabilities, type UploadBackend, type UploadIdentity, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, type UserPromptInput, type VerifySafeOptions, type VerifySafeResult, type WatchRunTargetOptions, ZERO_ROLL, type ZaiChatCallerOptions, addSpend, alreadyUploaded, analysisEngineFromEnv, analyzeAdoption, analyzeLiveBatch, analyzeLoopConvergence, analyzeReactions, analyzeSpans, analyzeSteeringChain, answerSchemaErrors, applyRedactor, assembleSessionBundle, assertAnswerSchema, assertSandboxReachable, assessSpans, buildPolicyEvidenceRecord, buildSessionFactsReport, buildSessionIndex, buildSessionIndexFromRows, buildSpanRunTree, buildTraceFindingPacket, capText, chatTrajectoryToSpans, classifyEvidenceOnlyPath, classifyFailureFollowUps, classifyLiveActions, classifyReaction, claudeActor, codexActor, collectPolicyEvidence, collectSessionIndex, collectSessionSelection, collectSessionWorkflow, collectSessions, commandAnalyzer, commandRedactor, commandTextFromInput, computeAdoption, computeSessionFacts, conformanceOfSpans, connectors, countSkillRunsJsonl, createBundleSourceReader, createFindingRejectionTally, cwdMatchesSelection, cwdMatchesSelectionResolved, defaultTraceLiveAnalysts, describeSessionRelationship, diffRuns, engineCallReservationFloorUsd, environmentAttributes, environmentFromSpanAttributes, equivalentGitCwds, executeUpload, exportTraceEvidenceFile, exportTraceEvidenceRows, exportTraceEvidenceText, externalFailureMessage, fileRunContextSupervisorRunReader, fileSha256, findContextRoot, findSessionTextLeaks, findSpanSourceFiles, findingRejection, findingRejectionDetail, forEachTreeNode, formatFindingRejections, formatVerdict, haloAnalyzer, hashSessionBundleFiles, hodoscopeAnalyzer, httpJsonTransport, importCodeTraceBench, incompleteInputsNote, indexSessionIdsByTrace, inferRole, inferSpanKind, inspectSessionIndex, int, isBridgeMismatchError, isChatTrajectory, isChatTrajectoryMessage, isFileRunContextDir, isInheritedSpan, isSynthesizedSpan, iterSerializedSpans, knownHarnesses, listAdapters, listSessionBundleFiles, loadState, loadTraceQuestionsFile, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeRolls, mergeTracesConfig, ms, normalizeAnalystCitations, normalizeRemote, normalizeTraceQuestions, otlpRowToSpan, outboundHash, parseIsoToEpochMs, parseJsonAnswer, parseRetainedSession, parseSession, parseSince, planTraceAgenticRoute, planUpload, primeAnalyzer, projectSessionBundle, readCoordinationLog, readFileRunContext, readJsonFile, readJsonl, readOtlpInput, readPullRequests, readRunContextJournal, readRunContextSnapshot, readRunSide, readRunWatchSnapshot, readSessionBundleManifest, readSessionIndexFile, readSpanRunSnapshot, recordSessionCorruption, redactSpans, renderConformance, renderInspectionReport, renderRunContextSnapshot, renderRunDiff, renderRunWatchSnapshot, renderSessionFacts, renderSessionFactsContext, renderSpanRunSnapshot, renderTraceQuestionInstructions, renderTraceQuestionPrompt, renderTraceQuestionsReport, renderValidation, resolveAdapter, resolveOtlpInputFiles, resolveRepoAttrs, resolveRunContextDir, resolveRunWatchTarget, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTotals, runTraceImprovement, runTraceInvestigation, runTraceQuestions, runTraceStoreInvestigation, sandboxReplayBackend, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionFactsContext, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, sessionTextSignatures, shellCommands, skippedAnalyses, span, spanRunTotals, stampEnvironmentAttrs, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, summarizeSpanStructure, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, tokens, totalAgenticFailureMessage, totalFindingRejections, traceAgenticKinds, traceCitationsInText, traceStreamEventsFromSpans, unavailableCapabilities, uploadKey, usd, userPromptSpan, validateOtlpSpans, validationExitCode, verdictExitCode, verifyFindingsInSandbox, verifySafe, verifySessionBundle, watchRunTarget, watchSessions, withSessionFactsContext, wrap, writeHodoscopeInput, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionBundleManifest, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts, writeTraceQuestionsArtifacts, zaiChatCaller, zeroPricedCost };
|
package/dist/index.js
CHANGED
|
@@ -270,7 +270,7 @@ import {
|
|
|
270
270
|
writeTraceQuestionsArtifacts,
|
|
271
271
|
zaiChatCaller,
|
|
272
272
|
zeroPricedCost
|
|
273
|
-
} from "./chunk-
|
|
273
|
+
} from "./chunk-YVCHWHCA.js";
|
|
274
274
|
|
|
275
275
|
// src/collect.ts
|
|
276
276
|
async function collectSessions(opts = {}) {
|
|
@@ -301,6 +301,116 @@ import {
|
|
|
301
301
|
redactText,
|
|
302
302
|
shareAllowed
|
|
303
303
|
} from "@tangle-network/agent-eval/traces";
|
|
304
|
+
|
|
305
|
+
// src/retained-session.ts
|
|
306
|
+
import { createHash } from "crypto";
|
|
307
|
+
import { mkdir, mkdtemp, rm, writeFile } from "fs/promises";
|
|
308
|
+
import { tmpdir } from "os";
|
|
309
|
+
import { dirname, isAbsolute, join, relative, resolve } from "path";
|
|
310
|
+
var RETAINED_SESSION_READER_VERSION = "2";
|
|
311
|
+
async function parseRetainedSession(input) {
|
|
312
|
+
input.signal?.throwIfAborted();
|
|
313
|
+
const unselectedFiles = [];
|
|
314
|
+
const unavailable = (reason) => ({
|
|
315
|
+
status: "unavailable",
|
|
316
|
+
reason,
|
|
317
|
+
sessionId: input.nativeSessionId,
|
|
318
|
+
sourceFiles: [],
|
|
319
|
+
duplicateFiles: [],
|
|
320
|
+
unselectedFiles,
|
|
321
|
+
spans: []
|
|
322
|
+
});
|
|
323
|
+
if (!input.nativeSessionId) return unavailable("Capture has no recorded native session identity.");
|
|
324
|
+
const adapter = resolveAdapter(input.harness);
|
|
325
|
+
if (!adapter) return unavailable(`No native trace adapter for ${input.harness}.`);
|
|
326
|
+
if (input.files.length > 1024) return unavailable("Retained capture exceeds 1024 text files.");
|
|
327
|
+
let totalBytes = 0;
|
|
328
|
+
for (const file of input.files) {
|
|
329
|
+
const bytes = Buffer.byteLength(file.content);
|
|
330
|
+
totalBytes += bytes;
|
|
331
|
+
if (bytes > 16 * 1024 ** 2 || totalBytes > 64 * 1024 ** 2) {
|
|
332
|
+
return unavailable("Retained capture exceeds the 16 MiB per-file or 64 MiB total text limit.");
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const root = await mkdtemp(join(tmpdir(), "traces-retained-"));
|
|
336
|
+
try {
|
|
337
|
+
const files = /* @__PURE__ */ new Map();
|
|
338
|
+
for (const file of input.files) {
|
|
339
|
+
input.signal?.throwIfAborted();
|
|
340
|
+
const path = resolve(root, file.path);
|
|
341
|
+
const rel = relative(root, path);
|
|
342
|
+
if (!file.path || isAbsolute(file.path) || file.path.includes("\\") || file.path.includes("\0") || rel === "" || rel === ".." || rel.startsWith("../") || files.has(path)) {
|
|
343
|
+
throw new Error("Retained source paths must be unique relative files inside the capture.");
|
|
344
|
+
}
|
|
345
|
+
files.set(path, file);
|
|
346
|
+
}
|
|
347
|
+
for (const [path, file] of files) {
|
|
348
|
+
await mkdir(dirname(path), { recursive: true, mode: 448 });
|
|
349
|
+
await writeFile(path, file.content, { mode: 384, flag: "wx" });
|
|
350
|
+
}
|
|
351
|
+
const selected = [];
|
|
352
|
+
for (const [path, file] of files) {
|
|
353
|
+
input.signal?.throwIfAborted();
|
|
354
|
+
const fallback = `unattributed:${root}:${file.path}`;
|
|
355
|
+
const ref = { harness: adapter.harness, sessionId: fallback, path, cwd: null, mtimeMs: 0 };
|
|
356
|
+
try {
|
|
357
|
+
const sources = adapter.sourcePaths ? await adapter.sourcePaths(ref, { signal: input.signal }) : [path];
|
|
358
|
+
if (sources.some((source) => !files.has(resolve(source)))) {
|
|
359
|
+
throw new Error("Parser requires files outside the supplied retained capture.");
|
|
360
|
+
}
|
|
361
|
+
const spans = validateOtlpSpans(await adapter.parse(ref, {
|
|
362
|
+
corruptionMode: "recover",
|
|
363
|
+
taskScope: "all",
|
|
364
|
+
captureSources: false,
|
|
365
|
+
signal: input.signal
|
|
366
|
+
}), `${adapter.harness} retained adapter output`);
|
|
367
|
+
const roots = spans.filter((span2) => span2.parent_span_id === null);
|
|
368
|
+
const identities = new Set(roots.map((span2) => sessionIdFromAttributes(span2.attributes)));
|
|
369
|
+
if (identities.size !== 1 || !identities.has(input.nativeSessionId)) {
|
|
370
|
+
unselectedFiles.push({ path: file.path, reason: "No unambiguous matching native identity in parser output." });
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
if (computeSessionFacts(spans, { includeContent: false }).every((facts) => facts.recordSpans === 0)) {
|
|
374
|
+
unselectedFiles.push({ path: file.path, reason: "Native identity was recorded without any session records." });
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
stampSessionIntegrity(ref, spans);
|
|
378
|
+
stampSessionIdentity(spans, input.nativeSessionId);
|
|
379
|
+
for (const span2 of spans) {
|
|
380
|
+
for (const [key, value] of Object.entries(span2.attributes)) {
|
|
381
|
+
if (typeof value === "string" && value.includes(root)) {
|
|
382
|
+
span2.attributes[key] = value.split(root + "/").join("retained://");
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
selected.push({ file, paths: sources, spans });
|
|
387
|
+
} catch (error) {
|
|
388
|
+
input.signal?.throwIfAborted();
|
|
389
|
+
unselectedFiles.push({ path: file.path, reason: `Native parser could not read this file (${error instanceof Error ? error.name : "Error"}).` });
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (!selected.length) return unavailable("No retained parser entrypoint established the recorded native session identity.");
|
|
393
|
+
selected.sort((a, b) => b.file.content.length - a.file.content.length || a.file.path.localeCompare(b.file.path));
|
|
394
|
+
const chosen = selected[0];
|
|
395
|
+
if (selected.some((candidate) => !chosen.file.content.startsWith(candidate.file.content))) {
|
|
396
|
+
return unavailable("Retained files contain divergent histories for the same native session.");
|
|
397
|
+
}
|
|
398
|
+
return {
|
|
399
|
+
status: "selected",
|
|
400
|
+
reason: null,
|
|
401
|
+
sessionId: input.nativeSessionId,
|
|
402
|
+
sourceFiles: chosen.paths.map((path) => {
|
|
403
|
+
const file = files.get(resolve(path));
|
|
404
|
+
return { path: file.path, sha256: `sha256:${createHash("sha256").update(file.content).digest("hex")}` };
|
|
405
|
+
}).sort((a, b) => a.path.localeCompare(b.path)),
|
|
406
|
+
duplicateFiles: selected.slice(1).map((candidate) => candidate.file.path),
|
|
407
|
+
unselectedFiles,
|
|
408
|
+
spans: chosen.spans
|
|
409
|
+
};
|
|
410
|
+
} finally {
|
|
411
|
+
await rm(root, { recursive: true, force: true });
|
|
412
|
+
}
|
|
413
|
+
}
|
|
304
414
|
export {
|
|
305
415
|
ACTOR_ATTR,
|
|
306
416
|
ATTR,
|
|
@@ -347,6 +457,7 @@ export {
|
|
|
347
457
|
QwenAdapter,
|
|
348
458
|
REACTIONS,
|
|
349
459
|
RESULT_FILE,
|
|
460
|
+
RETAINED_SESSION_READER_VERSION,
|
|
350
461
|
RULE,
|
|
351
462
|
SESSION_FACTS_MEASUREMENT_VERSION,
|
|
352
463
|
SESSION_FACTS_VERSION_SUFFIX,
|
|
@@ -469,6 +580,7 @@ export {
|
|
|
469
580
|
outboundHash,
|
|
470
581
|
parseIsoToEpochMs,
|
|
471
582
|
parseJsonAnswer,
|
|
583
|
+
parseRetainedSession,
|
|
472
584
|
parseSession,
|
|
473
585
|
parseSince,
|
|
474
586
|
planTraceAgenticRoute,
|
package/docs/trace-analysts.md
CHANGED
|
@@ -425,10 +425,10 @@ What real runs have shown (GLM-5.3 via a coding-plan endpoint, fork at the pinne
|
|
|
425
425
|
tokens); its first reply gets cut by the endpoint's output limit mid-JSON, and the
|
|
426
426
|
truncation-aware repair turn (re-emit at most 3 findings, terse strings) recovers it — ok:true,
|
|
427
427
|
findings grounded, exit 0.
|
|
428
|
-
- **File, ~794 spans / 2.1 MB artifact:**
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
428
|
+
- **File, ~794 spans / 2.1 MB artifact:** the reply channel alone never survived the endpoint's
|
|
429
|
+
output cap. The findings.json payload channel finishes it — the analyzer writes the result with
|
|
430
|
+
its tools before replying — measured live at **8 findings, 0 rejected, exit 0**, 53 model calls,
|
|
431
|
+
~3.1M input tokens of REPL inspection.
|
|
432
432
|
|
|
433
433
|
## Write one analyst
|
|
434
434
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/traces",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Point it at your coding-agent session traces (Claude Code, Codex, OpenCode, Gemini, Pi,
|
|
3
|
+
"version": "0.19.1",
|
|
4
|
+
"description": "Point it at your coding-agent session traces (Claude Code, Codex, OpenCode, Gemini, Pi, \u2026) and get failure-mode + efficiency findings. CLI + SDK over the @tangle-network/agent-eval analyst suite \u2014 observe live sessions, run your own analysts, redact, and upload to the Tangle Intelligence Platform.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|