@brizz/sdk 0.1.18 → 0.1.19

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/dist/index.d.cts CHANGED
@@ -135,9 +135,11 @@ declare class Session {
135
135
  private readonly span;
136
136
  private inputs;
137
137
  private outputs;
138
+ private inputContexts;
139
+ private outputContexts;
138
140
  constructor(sessionId: string, span: Span);
139
- setInput(text: string | null): void;
140
- setOutput(text: string | null): void;
141
+ setInput(text: string | null, context?: Record<string, AttributeValue>): void;
142
+ setOutput(text: string | null, context?: Record<string, AttributeValue>): void;
141
143
  setTitle(title: string): void;
142
144
  updateProperties(properties: Record<string, AttributeValue>): void;
143
145
  }
package/dist/index.d.ts CHANGED
@@ -135,9 +135,11 @@ declare class Session {
135
135
  private readonly span;
136
136
  private inputs;
137
137
  private outputs;
138
+ private inputContexts;
139
+ private outputContexts;
138
140
  constructor(sessionId: string, span: Span);
139
- setInput(text: string | null): void;
140
- setOutput(text: string | null): void;
141
+ setInput(text: string | null, context?: Record<string, AttributeValue>): void;
142
+ setOutput(text: string | null, context?: Record<string, AttributeValue>): void;
141
143
  setTitle(title: string): void;
142
144
  updateProperties(properties: Record<string, AttributeValue>): void;
143
145
  }
package/dist/index.js CHANGED
@@ -454,7 +454,7 @@ import {
454
454
 
455
455
  // src/internal/version.ts
456
456
  function getSDKVersion() {
457
- return "0.1.18";
457
+ return "0.1.19";
458
458
  }
459
459
 
460
460
  // src/internal/log/processors/log-processor.ts
@@ -1094,6 +1094,8 @@ var PROPERTIES_CONTEXT_KEY = createContextKey(PROPERTIES);
1094
1094
  var SESSION_OBJECT_CONTEXT_KEY = createContextKey("brizz.session.object");
1095
1095
  var SESSION_INPUT = "brizz.session.input";
1096
1096
  var SESSION_OUTPUT = "brizz.session.output";
1097
+ var SESSION_INPUT_CONTEXT = "brizz.session.input.context";
1098
+ var SESSION_OUTPUT_CONTEXT = "brizz.session.output.context";
1097
1099
  var SESSION_SPAN_NAME = "brizz.start_session";
1098
1100
  var SESSION_TITLE_SPAN_NAME = "brizz.session_title";
1099
1101
  var SESSION_TITLE_GENERATION = "session.title_generation";
@@ -1536,6 +1538,14 @@ import {
1536
1538
  BatchSpanProcessor,
1537
1539
  SimpleSpanProcessor
1538
1540
  } from "@opentelemetry/sdk-trace-base";
1541
+ function applyContextAttributes(span) {
1542
+ const sessionProperties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1543
+ if (sessionProperties) {
1544
+ for (const [key, value] of Object.entries(sessionProperties)) {
1545
+ span.setAttribute(`${BRIZZ}.${key}`, value);
1546
+ }
1547
+ }
1548
+ }
1539
1549
  var DEFAULT_MASKING_RULES = [
1540
1550
  {
1541
1551
  mode: "partial",
@@ -1570,12 +1580,7 @@ var BrizzSimpleSpanProcessor = class extends SimpleSpanProcessor {
1570
1580
  if (maskingConfig) {
1571
1581
  maskSpan(span, maskingConfig);
1572
1582
  }
1573
- const associationProperties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1574
- if (associationProperties) {
1575
- for (const [key, value] of Object.entries(associationProperties)) {
1576
- span.setAttribute(`${BRIZZ}.${key}`, value);
1577
- }
1578
- }
1583
+ applyContextAttributes(span);
1579
1584
  super.onStart(span, parentContext);
1580
1585
  }
1581
1586
  };
@@ -1590,12 +1595,7 @@ var BrizzBatchSpanProcessor = class extends BatchSpanProcessor {
1590
1595
  if (maskingConfig) {
1591
1596
  maskSpan(span, maskingConfig);
1592
1597
  }
1593
- const associationProperties = context2.active().getValue(PROPERTIES_CONTEXT_KEY);
1594
- if (associationProperties) {
1595
- for (const [key, value] of Object.entries(associationProperties)) {
1596
- span.setAttribute(`${BRIZZ}.${key}`, value);
1597
- }
1598
- }
1598
+ applyContextAttributes(span);
1599
1599
  super.onStart(span, parentContext);
1600
1600
  }
1601
1601
  };
@@ -1769,31 +1769,45 @@ var Session = class {
1769
1769
  span;
1770
1770
  inputs = [];
1771
1771
  outputs = [];
1772
+ inputContexts = [];
1773
+ outputContexts = [];
1772
1774
  constructor(sessionId, span) {
1773
1775
  this.sessionId = sessionId;
1774
1776
  this.span = span;
1775
1777
  }
1776
1778
  /**
1777
- * (Optional) Append text to session input tracking.
1778
- * Use when you need to track specific input data that differs from what's sent to the LLM.
1779
- * Multiple calls accumulate in an array.
1779
+ * Append a user turn to session input tracking.
1780
+ *
1781
+ * Each call appends one element to `brizz.session.input` (the text) AND one
1782
+ * element to `brizz.session.input.context` (the per-turn context bag). The
1783
+ * two arrays stay index-aligned — the ingestion pipeline zips them together
1784
+ * so the i-th context bag lands on the i-th user_display conversation item's
1785
+ * `span_attributes` map.
1780
1786
  *
1781
- * @param text - Text to append to session input, or null to append null
1787
+ * @param text - Text to append (null becomes a null/"hide marker")
1788
+ * @param context - Optional per-turn context bag to attach to this turn
1782
1789
  */
1783
- setInput(text) {
1790
+ setInput(text, context4) {
1784
1791
  this.inputs.push(text);
1792
+ this.inputContexts.push(context4 ?? {});
1785
1793
  this.span.setAttribute(SESSION_INPUT, JSON.stringify(this.inputs));
1794
+ this.span.setAttribute(SESSION_INPUT_CONTEXT, JSON.stringify(this.inputContexts));
1786
1795
  }
1787
1796
  /**
1788
- * (Optional) Append text to session output tracking.
1789
- * Use when you need to track specific output data that differs from what's received from the LLM.
1790
- * Multiple calls accumulate in an array.
1797
+ * Append an assistant turn to session output tracking.
1798
+ *
1799
+ * Symmetric to {@link setInput} appends one text element and one
1800
+ * context-bag element to the index-aligned `brizz.session.output` /
1801
+ * `brizz.session.output.context` arrays.
1791
1802
  *
1792
- * @param text - Text to append to session output, or null to append null
1803
+ * @param text - Text to append (null becomes a null/"hide marker")
1804
+ * @param context - Optional per-turn context bag to attach to this turn
1793
1805
  */
1794
- setOutput(text) {
1806
+ setOutput(text, context4) {
1795
1807
  this.outputs.push(text);
1808
+ this.outputContexts.push(context4 ?? {});
1796
1809
  this.span.setAttribute(SESSION_OUTPUT, JSON.stringify(this.outputs));
1810
+ this.span.setAttribute(SESSION_OUTPUT_CONTEXT, JSON.stringify(this.outputContexts));
1797
1811
  }
1798
1812
  /**
1799
1813
  * Set the session title on the span.