@tangle-network/traces 0.7.0 → 0.8.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.
package/README.md CHANGED
@@ -43,7 +43,7 @@ That's the command in the demo above. The **deterministic pass** — stuck loops
43
43
 
44
44
  Add `--llm` for the **agentic analysts** (failure-mode / knowledge-gap / knowledge-poisoning / improvement); they call OpenAI and respect `--budget <usd>`.
45
45
 
46
- Every run also writes an **OTLP-JSONL artifact**, and you can run external engines like [HALO](https://github.com/context-labs/halo) over it with `--analyzer halo` (traces converts our spans to the canonical OpenInference shape HALO needs) — see [External engines](#external-engines-bring-your-own). Analysis is never locked to one engine.
46
+ Every run also writes a **canonical OpenInference JSONL artifact**, so you can run external engines like [HALO](https://github.com/context-labs/halo) over it directly with `--analyzer halo` — see [External engines](#external-engines-bring-your-own). Analysis is never locked to one engine.
47
47
 
48
48
  ## What it finds
49
49
 
@@ -142,7 +142,7 @@ traces analyze --last 1 --analyzer halo --analyzer-prompt "find token waste"
142
142
  traces analyze --last 1 --analyzer halo --analyzer my-engine # repeatable
143
143
  ```
144
144
 
145
- HALO needs canonical OpenInference, so `--analyzer halo` converts our spans automatically (`toCanonicalOpenInference`). HALO runs its *own* LLM (OpenAI client — set `OPENAI_BASE_URL` / `OPENAI_API_KEY`, or use HALO's provider); `--model` is forwarded to it. traces supplies the trace and drives the CLI; it doesn't pay for or configure HALO's model.
145
+ Our OTLP artifact is **canonical OpenInference** (top-level `kind`, `resource`, `scope`), so HALO reads it directly — no conversion. HALO runs its *own* LLM (OpenAI client — set `OPENAI_BASE_URL` / `OPENAI_API_KEY`, or use HALO's provider); `--model` is forwarded to it. traces supplies the trace and drives the CLI; it doesn't pay for or configure HALO's model.
146
146
 
147
147
  **Redactors** scrub prompt/response prose with an external PII model (catching names/addresses the regex pass can't), running *after* the built-in redaction:
148
148
 
@@ -25,9 +25,28 @@ function span(input) {
25
25
  attributes
26
26
  };
27
27
  }
28
+ function toOpenInferenceSpan(s) {
29
+ const a = s.attributes;
30
+ const resourceAttrs = {};
31
+ if (a["service.name"] != null) resourceAttrs["service.name"] = a["service.name"];
32
+ if (a["agent.name"] != null) resourceAttrs["agent.name"] = a["agent.name"];
33
+ return {
34
+ trace_id: s.trace_id,
35
+ span_id: s.span_id,
36
+ parent_span_id: s.parent_span_id ?? "",
37
+ name: s.name,
38
+ kind: typeof a["openinference.span.kind"] === "string" ? a["openinference.span.kind"] : "CHAIN",
39
+ start_time: s.start_time,
40
+ end_time: s.end_time,
41
+ status: { code: s.status.code, message: s.status.message ?? "" },
42
+ resource: { attributes: resourceAttrs },
43
+ scope: { name: "tangle-traces", version: "" },
44
+ attributes: a
45
+ };
46
+ }
28
47
  function serializeSpans(spans) {
29
48
  if (spans.length === 0) return "";
30
- return `${spans.map((s) => JSON.stringify(s)).join("\n")}
49
+ return `${spans.map((s) => JSON.stringify(toOpenInferenceSpan(s))).join("\n")}
31
50
  `;
32
51
  }
33
52
  async function writeOtlpFile(spans, outPath) {
@@ -2330,6 +2349,7 @@ async function executeUpload(plan, opts = {}) {
2330
2349
 
2331
2350
  export {
2332
2351
  span,
2352
+ toOpenInferenceSpan,
2333
2353
  serializeSpans,
2334
2354
  writeOtlpFile,
2335
2355
  analyzeSpans,
package/dist/cli.js CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  selectAdapters,
15
15
  watchSessions,
16
16
  writeOtlpFile
17
- } from "./chunk-Q56AP2EY.js";
17
+ } from "./chunk-BUD6I3ZJ.js";
18
18
 
19
19
  // src/cli.ts
20
20
  import { stat, writeFile } from "fs/promises";
package/dist/index.d.ts CHANGED
@@ -73,7 +73,15 @@ interface SpanInput {
73
73
  * so the behavioral analyst's "no LLM data" case stays honest.
74
74
  */
75
75
  declare function span(input: SpanInput): OtlpSpan;
76
- /** Serialize spans to OTLP-JSONL (one span per line, trailing newline). */
76
+ /** Project an in-memory span to a COMPLETE OpenInference span: the standard shape
77
+ * OTel/OpenInference consumers (and HALO) expect — top-level `kind`, `resource`,
78
+ * `scope`, and a string `parent_span_id` ("" at the root) — while keeping the
79
+ * attribute vocabulary (incl. `openinference.span.kind`) our own analysts read.
80
+ * One artifact feeds our pipeline, HALO, and any OpenInference tool. */
81
+ declare function toOpenInferenceSpan(s: OtlpSpan): Record<string, unknown>;
82
+ /** Serialize spans to OpenInference JSONL (one complete span per line). This is a
83
+ * standard OpenInference representation: it feeds our analysts, HALO, and other
84
+ * OpenInference tools directly — no per-tool conversion. */
77
85
  declare function serializeSpans(spans: readonly OtlpSpan[]): string;
78
86
  /** Write spans to an OTLP-JSONL file (a temp file when no path is given). */
79
87
  declare function writeOtlpFile(spans: readonly OtlpSpan[], outPath?: string): Promise<string>;
@@ -867,4 +875,4 @@ interface ExecuteOptions {
867
875
  /** Send the NEW items (or, on dryRun, write the redacted OTLP that would send). */
868
876
  declare function executeUpload(plan: UploadPlan, opts?: ExecuteOptions): Promise<UploadResult>;
869
877
 
870
- export { ATTR, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, CODING_REDACTION_RULES, CONTENT_CAP, ClaudeAdapter, CodexAdapter, type CollectOptions, CopilotAdapter, DEFAULT_HARNESS, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, QwenAdapter, type Redactor, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type UploadBackend, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, alreadyUploaded, analyzeSpans, applyRedactor, capText, collectSessions, commandAnalyzer, commandRedactor, executeUpload, haloAnalyzer, knownHarnesses, listAdapters, loadState, parseIsoToEpochMs, parseSince, planUpload, redactSpans, resolveAdapter, runCommand, runExternalAnalyzers, runPipelines, saveState, scanSessions, selectAdapters, serializeSpans, sessionHash, span, toCanonicalOpenInference, toRuntimeStore, toTraceSpanEvents, uploadKey, userPromptSpan, watchSessions, writeOtlpFile };
878
+ export { ATTR, AmpAdapter, type AnalyzeOptions, type AnalyzeResult, CODING_REDACTION_RULES, CONTENT_CAP, ClaudeAdapter, CodexAdapter, type CollectOptions, CopilotAdapter, DEFAULT_HARNESS, type ExecuteOptions, type ExternalAnalysisResult, type ExternalAnalyzer, FactoryAdapter, ForgeAdapter, GeminiAdapter, type HarnessTraceAdapter, INGEST_SOURCE_CLI, type LocateOptions, type ObservedLoop, type ObserverOptions, OpencodeAdapter, type OtlpSpan, type OtlpSpanKind, type OtlpStatusCode, PiAdapter, type PipelineOptions, type PipelineReport, type PlanOptions, QwenAdapter, type Redactor, type RunResult, type RuntimeTrace, type ScanOptions, type ScannedSession, type SessionBatch, type SessionRef, type SpanInput, type SpanRedaction, TRACES_REDACTION_RULES, type UploadBackend, type UploadItem, type UploadPlan, type UploadRecord, type UploadResult, type UploadState, alreadyUploaded, analyzeSpans, applyRedactor, capText, collectSessions, commandAnalyzer, commandRedactor, executeUpload, haloAnalyzer, knownHarnesses, listAdapters, loadState, parseIsoToEpochMs, parseSince, planUpload, redactSpans, resolveAdapter, runCommand, runExternalAnalyzers, runPipelines, saveState, scanSessions, selectAdapters, serializeSpans, sessionHash, span, toCanonicalOpenInference, toOpenInferenceSpan, toRuntimeStore, toTraceSpanEvents, uploadKey, userPromptSpan, watchSessions, writeOtlpFile };
package/dist/index.js CHANGED
@@ -41,13 +41,14 @@ import {
41
41
  sessionHash,
42
42
  span,
43
43
  toCanonicalOpenInference,
44
+ toOpenInferenceSpan,
44
45
  toRuntimeStore,
45
46
  toTraceSpanEvents,
46
47
  uploadKey,
47
48
  userPromptSpan,
48
49
  watchSessions,
49
50
  writeOtlpFile
50
- } from "./chunk-Q56AP2EY.js";
51
+ } from "./chunk-BUD6I3ZJ.js";
51
52
 
52
53
  // src/collect.ts
53
54
  async function collectSessions(opts = {}) {
@@ -123,6 +124,7 @@ export {
123
124
  sessionHash,
124
125
  span,
125
126
  toCanonicalOpenInference,
127
+ toOpenInferenceSpan,
126
128
  toRuntimeStore,
127
129
  toTraceSpanEvents,
128
130
  uploadKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/traces",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
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",