@tangle-network/traces 0.9.6 → 0.9.8
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 +5 -0
- package/dist/{chunk-NP3ZIUR2.js → chunk-ELWOJS65.js} +708 -158
- package/dist/cli.js +20 -6
- package/dist/index.d.ts +28 -3
- package/dist/index.js +5 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -40,10 +40,11 @@ import {
|
|
|
40
40
|
writePolicyEvidenceFile,
|
|
41
41
|
writeSessionIndexFile,
|
|
42
42
|
writeTraceEvidenceExportFile
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-ELWOJS65.js";
|
|
44
44
|
|
|
45
45
|
// src/cli.ts
|
|
46
|
-
import {
|
|
46
|
+
import { createHash } from "crypto";
|
|
47
|
+
import { createReadStream, readFileSync } from "fs";
|
|
47
48
|
import { readFile, stat } from "fs/promises";
|
|
48
49
|
import { basename, resolve } from "path";
|
|
49
50
|
import {
|
|
@@ -351,10 +352,22 @@ async function cmdConvert(args) {
|
|
|
351
352
|
const path = await writeOtlpFile(spans, args.otlp);
|
|
352
353
|
console.log(`wrote ${spans.length} spans \u2192 ${path}`);
|
|
353
354
|
}
|
|
354
|
-
async function
|
|
355
|
+
async function sourceSha256(path) {
|
|
356
|
+
const hash = createHash("sha256");
|
|
357
|
+
for await (const chunk of createReadStream(path)) hash.update(chunk);
|
|
358
|
+
return hash.digest("hex");
|
|
359
|
+
}
|
|
360
|
+
async function collectSessionRows(args, bindExplicitSource = false) {
|
|
355
361
|
if (args.session) {
|
|
356
362
|
const { adapter, ref } = await resolveSelectedSession(args);
|
|
357
|
-
return [{ ref, spans: await parseSession(adapter, ref) }];
|
|
363
|
+
if (!bindExplicitSource) return [{ ref, spans: await parseSession(adapter, ref) }];
|
|
364
|
+
const before = await sourceSha256(ref.path);
|
|
365
|
+
const spans = await parseSession(adapter, ref);
|
|
366
|
+
const after = await sourceSha256(ref.path);
|
|
367
|
+
if (before !== after) {
|
|
368
|
+
throw new Error(`session source changed while parsing; refusing unbound evidence: ${ref.path}`);
|
|
369
|
+
}
|
|
370
|
+
return [{ ref, spans, sourceSha256: after }];
|
|
358
371
|
}
|
|
359
372
|
const groups = await discover({ ...args, last: args.last || 20 });
|
|
360
373
|
const rows = [];
|
|
@@ -364,7 +377,7 @@ async function collectSessionRows(args) {
|
|
|
364
377
|
return rows;
|
|
365
378
|
}
|
|
366
379
|
async function cmdEvidence(args) {
|
|
367
|
-
const rows = (await collectSessionRows(args)).filter((row) => row.spans.length > 0);
|
|
380
|
+
const rows = (await collectSessionRows(args, true)).filter((row) => row.spans.length > 0);
|
|
368
381
|
if (rows.length === 0) throw new Error("no spans found for the given selection");
|
|
369
382
|
const otlpPath = args.otlp ? await writeOtlpFile(rows.flatMap((row) => row.spans), args.otlp) : void 0;
|
|
370
383
|
const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -373,7 +386,8 @@ async function cmdEvidence(args) {
|
|
|
373
386
|
generatedAt,
|
|
374
387
|
minLoopOccurrences: args.minLoop,
|
|
375
388
|
maxLoopExamples: 25,
|
|
376
|
-
otlpPath
|
|
389
|
+
otlpPath,
|
|
390
|
+
sourceSha256: row.sourceSha256
|
|
377
391
|
})
|
|
378
392
|
));
|
|
379
393
|
if (args.out) {
|
package/dist/index.d.ts
CHANGED
|
@@ -399,7 +399,7 @@ declare function stampSpanWorkdirRepoAttrs(spans: readonly OtlpSpan[]): Promise<
|
|
|
399
399
|
* (token trajectory) and `message.content[]` tool_use blocks; tool results
|
|
400
400
|
* arrive as `tool_result` blocks in the following user message or as a
|
|
401
401
|
* `tool_result` attachment. Subagent runs live in a sibling
|
|
402
|
-
* `<session>/subagents
|
|
402
|
+
* nested `<session>/subagents/.../agent-*.jsonl` files with a `.meta.json` carrying the
|
|
403
403
|
* spawning `toolUseId`, so we parent each subagent under its `Agent` call.
|
|
404
404
|
*
|
|
405
405
|
* Shared by the claudish / openclaw / nanoclaw forks via aliases — they
|
|
@@ -412,7 +412,7 @@ declare class ClaudeAdapter implements HarnessTraceAdapter {
|
|
|
412
412
|
private root;
|
|
413
413
|
locate(opts?: LocateOptions): Promise<SessionRef[]>;
|
|
414
414
|
parse(ref: SessionRef, options?: ParseOptions): Promise<OtlpSpan[]>;
|
|
415
|
-
/** Parse
|
|
415
|
+
/** Parse nested `subagents/.../agent-*.jsonl`, parenting each under its Agent call. */
|
|
416
416
|
private foldSubagents;
|
|
417
417
|
}
|
|
418
418
|
|
|
@@ -440,6 +440,27 @@ declare class CodexAdapter implements HarnessTraceAdapter {
|
|
|
440
440
|
parse(ref: SessionRef, options?: ParseOptions): Promise<OtlpSpan[]>;
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Ephemeral `codex exec --json` adapter.
|
|
445
|
+
*
|
|
446
|
+
* Unlike Codex rollout files under `~/.codex/sessions`, this stream has no
|
|
447
|
+
* durable discovery path and normally carries no timestamps, model name, or
|
|
448
|
+
* user prompt. Callers select it explicitly with `--session`; event order is
|
|
449
|
+
* preserved with `step`, and missing timestamps use the source file mtime
|
|
450
|
+
* without inventing durations.
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
declare class CodexExecStreamError extends Error {
|
|
454
|
+
readonly sourcePath: string;
|
|
455
|
+
constructor(sourcePath: string, message: string);
|
|
456
|
+
}
|
|
457
|
+
declare class CodexExecAdapter implements HarnessTraceAdapter {
|
|
458
|
+
readonly harness = "codex-exec";
|
|
459
|
+
readonly aliases: readonly ["codex-json"];
|
|
460
|
+
locate(_opts?: LocateOptions): Promise<SessionRef[]>;
|
|
461
|
+
parse(ref: SessionRef, options?: ParseOptions): Promise<OtlpSpan[]>;
|
|
462
|
+
}
|
|
463
|
+
|
|
443
464
|
/**
|
|
444
465
|
* OpenCode adapter — `~/.local/share/opencode/storage/`.
|
|
445
466
|
*
|
|
@@ -1025,6 +1046,8 @@ interface PolicyEvidenceRecord {
|
|
|
1025
1046
|
readonly source: 'traces';
|
|
1026
1047
|
readonly evidenceKind: 'session-summary';
|
|
1027
1048
|
readonly otlpPath?: string;
|
|
1049
|
+
/** SHA-256 of the stable explicit session file consumed by the CLI. */
|
|
1050
|
+
readonly sourceSha256?: string;
|
|
1028
1051
|
readonly notCampaignCell: true;
|
|
1029
1052
|
readonly note: string;
|
|
1030
1053
|
};
|
|
@@ -1034,6 +1057,8 @@ interface BuildPolicyEvidenceOptions {
|
|
|
1034
1057
|
readonly minLoopOccurrences?: number;
|
|
1035
1058
|
readonly maxLoopExamples?: number;
|
|
1036
1059
|
readonly otlpPath?: string;
|
|
1060
|
+
/** SHA-256 of the exact stable source bytes used to produce this record. */
|
|
1061
|
+
readonly sourceSha256?: string;
|
|
1037
1062
|
}
|
|
1038
1063
|
interface CollectPolicyEvidenceOptions extends ScanOptions, BuildPolicyEvidenceOptions {
|
|
1039
1064
|
}
|
|
@@ -1780,4 +1805,4 @@ interface ExecuteOptions {
|
|
|
1780
1805
|
/** Send the final, new outbound items (or write their dry-run OTLP). */
|
|
1781
1806
|
declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
|
|
1782
1807
|
|
|
1783
|
-
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, type CorruptionMode, DEFAULT_HARNESS, EmptySessionError, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, type ParseOptions, PartialUploadError, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionCorruptionReceipt, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, 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 TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadIdentity, 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, indexSessionIdsByTrace, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, outboundHash, parseIsoToEpochMs, parseSession, parseSince, planTraceAgenticRoute, planUpload, readJsonFile, readJsonl, readSessionIndexFile, recordSessionCorruption, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovement, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, span, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceAgenticKinds, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
|
|
1808
|
+
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, CodexExecAdapter, CodexExecStreamError, type CollectOptions, type CollectPolicyEvidenceOptions, type CollectSessionIndexOptions, CopilotAdapter, type CorruptionMode, DEFAULT_HARNESS, EmptySessionError, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type InspectSessionIndexOptions, JsonSourceError, type JsonlCorruptionReceipt, JsonlParseError, type JsonlReadOptions, type LiveBatchOptions, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, type ParseOptions, PartialUploadError, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, type PolicyEvidenceLoopSummary, type PolicyEvidenceRecord, type PolicyEvidenceToolSummary, QwenAdapter, REACTIONS, type Reaction, type ReactionReport, type ReactionSessionReport, type Redactor, type RepoAttrs, type RepoResolution, type RepoResolutionSource, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionCorruptionReceipt, type SessionIdentityConflict, type SessionIdentityIndex, type SessionIntegrity, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, 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 TraceSessionIndex, type TraceSessionIndexRow, type TraceStoreInvestigationOptions, type TraceStoreInvestigationResult, type TraceStreamEvent, type TraceStreamOptions, type TraceStreamReplayOptions, type TraceStreamSession, type TracesConfig, type TriggerPair, type UploadBackend, type UploadIdentity, 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, indexSessionIdsByTrace, inspectSessionIndex, knownHarnesses, listAdapters, loadState, loadTracesConfig, locateSessions, looksLikeAgentPrompt, mergeTracesConfig, normalizeRemote, outboundHash, parseIsoToEpochMs, parseSession, parseSince, planTraceAgenticRoute, planUpload, readJsonFile, readJsonl, readSessionIndexFile, recordSessionCorruption, redactSpans, renderInspectionReport, resolveAdapter, resolveRepoAttrs, resolveSessionRepoAttrs, runCommand, runExternalAnalyzers, runPipelines, runTraceImprovement, runTraceInvestigation, runTraceStoreInvestigation, saveReport, saveState, scanSessions, selectAdapters, serializeInspectionReport, serializePolicyEvidence, serializeSessionIndex, serializeSpans, serializeTraceStreamEvent, sessionHash, sessionIdFromAttributes, sessionIntegrityAttributes, span, stampRepoAttrs, stampSessionIdentity, stampSessionIntegrity, stampSpanWorkdirRepoAttrs, streamSessions, summarizeOtlpExecution, summarizeSpanExecution, takeJsonl, textIsSynthetic, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, traceAgenticKinds, traceStreamEventsFromSpans, uploadKey, userPromptSpan, watchSessions, writeInspectionReportFile, writeOtlpFile, writePolicyEvidenceFile, writeSessionIndexFile, writeTraceEvidenceExportFile, writeTraceImprovementArtifacts };
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
CORRECTIVE_REACTIONS,
|
|
8
8
|
ClaudeAdapter,
|
|
9
9
|
CodexAdapter,
|
|
10
|
+
CodexExecAdapter,
|
|
11
|
+
CodexExecStreamError,
|
|
10
12
|
CopilotAdapter,
|
|
11
13
|
DEFAULT_HARNESS,
|
|
12
14
|
EmptySessionError,
|
|
@@ -117,7 +119,7 @@ import {
|
|
|
117
119
|
writeSessionIndexFile,
|
|
118
120
|
writeTraceEvidenceExportFile,
|
|
119
121
|
writeTraceImprovementArtifacts
|
|
120
|
-
} from "./chunk-
|
|
122
|
+
} from "./chunk-ELWOJS65.js";
|
|
121
123
|
|
|
122
124
|
// src/collect.ts
|
|
123
125
|
async function collectSessions(opts = {}) {
|
|
@@ -151,6 +153,8 @@ export {
|
|
|
151
153
|
CORRECTIVE_REACTIONS,
|
|
152
154
|
ClaudeAdapter,
|
|
153
155
|
CodexAdapter,
|
|
156
|
+
CodexExecAdapter,
|
|
157
|
+
CodexExecStreamError,
|
|
154
158
|
CopilotAdapter,
|
|
155
159
|
DEFAULT_HARNESS,
|
|
156
160
|
DEFAULT_REDACTION_RULES,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/traces",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
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",
|