@hue-run/sdk 0.20.5 → 0.20.6

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/CLI.md CHANGED
@@ -42,7 +42,7 @@ project manifest are refused because managers can update ancestor locks; Python
42
42
  The generated `hue.setup.mjs` or `hue_setup.py` always selects `captureContent: false` /
43
43
  `capture_content=False`. For a supported application, setup installs the dependency and adds the
44
44
  managed import and middleware registration to the existing entrypoint; an unreferenced helper is
45
- not a completed integration. TypeScript uses `@hue-run/sdk@0.20.5`, `@opentelemetry/api@1.9.1` and
45
+ not a completed integration. TypeScript uses `@hue-run/sdk@0.20.6`, `@opentelemetry/api@1.9.1` and
46
46
  `@opentelemetry/context-async-hooks@2.11.0`; Python setup uses its separately tested package pin.
47
47
  Content capture requires an ordinary account-managed key and a later explicit application decision.
48
48
 
@@ -381,8 +381,8 @@ and Hue never receives or stores them. The command is part of the `hue` executab
381
381
  # LANGFUSE_PUBLIC_KEY=pk-lf-...
382
382
  # LANGFUSE_SECRET_KEY=sk-lf-...
383
383
  # LANGFUSE_BASE_URL=https://cloud.langfuse.com
384
- npx -y @hue-run/sdk@0.20.5 import langfuse --env-path .env.langfuse --from 2026-01-01 --dry-run
385
- npx -y @hue-run/sdk@0.20.5 import langfuse --env-path .env.langfuse --from 2026-01-01 --media
384
+ npx -y @hue-run/sdk@0.20.6 import langfuse --env-path .env.langfuse --from 2026-01-01 --dry-run
385
+ npx -y @hue-run/sdk@0.20.6 import langfuse --env-path .env.langfuse --from 2026-01-01 --media
386
386
  ```
387
387
 
388
388
  `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` come from the environment or `--env-path`
@@ -430,17 +430,25 @@ without a parent are its children, and it lasts from the earliest of its timesta
430
430
  to their last end. Spans carry `service.name` `langfuse` (`--service-name` sets another) and the
431
431
  instrumentation scope `@hue-run/sdk/import/langfuse`.
432
432
 
433
+ **Environment and Worlds.** A span whose observation, or v1 trace, records an environment also
434
+ carries it as recorded in `hue.import.source_environment`, which marks the trace as imported; one
435
+ that records none carries neither attribute, and the resource never declares
436
+ `deployment.environment.name`, since one import can mix environments. A trace adds to its user's
437
+ World only when Langfuse recorded it in its `production` environment: Hue reads the root's
438
+ `langfuse.environment` as the trace's deployment environment, and never takes an imported trace in
439
+ which any span names another environment, such as Langfuse's `default`, as production history.
440
+
433
441
  **Ids and resuming.** A Langfuse id that already is an OpenTelemetry id (32 lowercase hex digits for
434
442
  a trace, 16 for an observation, as Langfuse's OpenTelemetry SDKs write them) is kept; any other id,
435
443
  such as an older SDK's UUID, becomes one derived from it with SHA-256. The original ids are kept as
436
444
  `langfuse.trace.id` and `langfuse.observation.id`. Running the same command again sends the same
437
445
  spans, and Hue keeps one copy of an exact replay of a completed span, so an interrupted or partly
438
446
  failed import is resumed by running it again. Hue refuses a different payload for a span it already
439
- holds: keep `--media`, `--no-content` and `--service-name` the same when resuming, and expect a span
440
- whose Langfuse data changed after it was imported to be refused. For the same reason the import
441
- sends nothing that depends on the run: a trace's root never carries `hue.sdk.dropped_records`, and
442
- files and large values are stored before their span is sent. Leave out of the window any traces that
443
- already reached Hue through OpenTelemetry.
447
+ holds: keep `--media`, `--no-content`, `--service-name` and the SDK version the same when
448
+ resuming, and expect a span whose Langfuse data changed after it was imported to be refused. For
449
+ the same reason the import sends nothing that depends on the run: a trace's root never carries
450
+ `hue.sdk.dropped_records`, and files and large values are stored before their span is sent. Leave
451
+ out of the window any traces that already reached Hue through OpenTelemetry.
444
452
 
445
453
  **Export and content.** Spans go through the SDK's own exporter, as `createHue` sends them: batched,
446
454
  compressed, retried and within the limits Hue advertises. Before a span is sent, its content is
@@ -689,7 +697,7 @@ node packages/sdk-typescript/scripts/verify-package.mjs --artifacts-dir .artifac
689
697
  # Set project to an existing supported fixture; use the same directory on resume.
690
698
  project=/absolute/path/to/supported-fixture
691
699
  node packages/sdk-typescript/scripts/verify-setup-live.mjs \
692
- --archive .artifacts/typescript/hue-run-sdk-0.20.5.tgz \
700
+ --archive .artifacts/typescript/hue-run-sdk-0.20.6.tgz \
693
701
  --origin https://STAGING_ORIGIN \
694
702
  --project "$project" --command setup \
695
703
  --evidence .context/setup-staging-before-claim.json
@@ -700,7 +708,7 @@ the private local handoff and finish the real browser claim, then reconcile the
700
708
 
701
709
  ```sh
702
710
  node packages/sdk-typescript/scripts/verify-setup-live.mjs \
703
- --archive .artifacts/typescript/hue-run-sdk-0.20.5.tgz \
711
+ --archive .artifacts/typescript/hue-run-sdk-0.20.6.tgz \
704
712
  --origin https://STAGING_ORIGIN \
705
713
  --project "$project" --command claim \
706
714
  --evidence .context/setup-staging-after-claim.json
@@ -742,10 +750,10 @@ otherwise. Never hand the agent Hue-native tools (`context.tools`, `context.mcp`
742
750
  production agent lacks. Pin the SDK, so the agent's repository gains no dependency:
743
751
 
744
752
  ```sh
745
- npx -y @hue-run/sdk@0.20.5 eval --case "Refund an eligible charge" --command "node agent.js"
746
- npx -y @hue-run/sdk@0.20.5 eval --case https://app.hue.run/projects/demo/scenarios/<id> --command "python agent.py" --timeout 120 --baseline <run id>
747
- npx -y @hue-run/sdk@0.20.5 eval --set "Billing regressions" --scorer-version <id> --command "node agent.js" --save-version
748
- npx -y @hue-run/sdk@0.20.5 eval --worker --command "node agent.js" --agent-key support-agent --revision <new-agent-revision>
753
+ npx -y @hue-run/sdk@0.20.6 eval --case "Refund an eligible charge" --command "node agent.js"
754
+ npx -y @hue-run/sdk@0.20.6 eval --case https://app.hue.run/projects/demo/scenarios/<id> --command "python agent.py" --timeout 120 --baseline <run id>
755
+ npx -y @hue-run/sdk@0.20.6 eval --set "Billing regressions" --scorer-version <id> --command "node agent.js" --save-version
756
+ npx -y @hue-run/sdk@0.20.6 eval --worker --command "node agent.js" --agent-key support-agent --revision <new-agent-revision>
749
757
  ```
750
758
 
751
759
  One invocation creates one run holding every selected case; it prints the run URL
@@ -783,7 +791,7 @@ export default function runMyAgent(inputs: JsonValue, context: SimulationTargetC
783
791
  ```
784
792
 
785
793
  ```sh
786
- npx -y @hue-run/sdk@0.20.5 eval --case "Refund an eligible charge" ./hue-agent.ts --content
794
+ npx -y @hue-run/sdk@0.20.6 eval --case "Refund an eligible charge" ./hue-agent.ts --content
787
795
  ```
788
796
 
789
797
  `--scenario` remains an alias for `--case` for existing scripts. Pass one selection flag.
package/README.md CHANGED
@@ -536,8 +536,8 @@ the Langfuse project's own keys (`LANGFUSE_PUBLIC_KEY`, `LANGFUSE_SECRET_KEY`, a
536
536
  `HUE_API_KEY`:
537
537
 
538
538
  ```sh
539
- npx -y @hue-run/sdk@0.20.5 import langfuse --env-path .env.langfuse --from 2026-01-01 --dry-run
540
- npx -y @hue-run/sdk@0.20.5 import langfuse --env-path .env.langfuse --from 2026-01-01 --media
539
+ npx -y @hue-run/sdk@0.20.6 import langfuse --env-path .env.langfuse --from 2026-01-01 --dry-run
540
+ npx -y @hue-run/sdk@0.20.6 import langfuse --env-path .env.langfuse --from 2026-01-01 --media
541
541
  ```
542
542
 
543
543
  - It reads Langfuse Cloud and self-hosted v4 through the Observations API v2, and self-hosted v3
@@ -547,6 +547,8 @@ npx -y @hue-run/sdk@0.20.5 import langfuse --env-path .env.langfuse --from 2026-
547
547
  `langfuse.observation.*` and `langfuse.trace.*` attributes Hue reads, the user, session, release
548
548
  and environment, and the model and token counts as GenAI attributes. Hex ids are kept and other
549
549
  ids derived from them, so running the same command again resumes an import without duplicates.
550
+ - Langfuse's environment is also sent, as recorded, as `hue.import.source_environment`; only
551
+ traces Langfuse recorded in `production` add to a user's World.
550
552
  - Spans are exported by the SDK's transport with its content-capture default; `--no-content`
551
553
  sends metadata only.
552
554
  - With `--media`, files that Langfuse media references point to are downloaded and uploaded under
@@ -26,7 +26,7 @@ export interface ImportCommandIo {
26
26
  * in flight do not hold it until their requests time out. */
27
27
  exit?: (code: number) => void;
28
28
  }
29
- export declare const IMPORT_USAGE = "Usage: hue import langfuse [options]\n\nCopy traces from a Langfuse project into Hue. The import runs on this machine with your own\nLangfuse keys, which are sent only to Langfuse. Each observation becomes a span with the\nlangfuse.* attributes Hue reads; ids are kept, so running the same command again resumes an\nimport without duplicating what was already sent.\n\nLangfuse (keys from the environment or --env-path; the secret key never from the command line):\n LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY The Langfuse project's API keys\n LANGFUSE_BASE_URL or LANGFUSE_HOST Langfuse host (default https://cloud.langfuse.com)\n --langfuse-host URL Langfuse host, instead of the variables\n --langfuse-public-key KEY Public key, instead of LANGFUSE_PUBLIC_KEY\n\nHue:\n HUE_API_KEY The Hue project key the traces are sent with (environment, --env-path\n or ./.env.hue); not needed with --dry-run\n --origin URL Hue origin (default HUE_BASE_URL, then https://app.hue.run)\n --service-name NAME service.name of the imported spans (default langfuse)\n\nSelection (newest first):\n --from TIME Traces that started at or after TIME: an ISO 8601 date (midnight UTC)\n or a date and time with a zone, such as 2026-01-01T09:00:00Z\n --to TIME Traces that started before TIME (default: an hour before the command\n starts, so traces still running are left for a later run)\n --limit N At most N traces\n --trace-id ID This Langfuse trace (repeatable); not with --from, --to or --limit\n\nContent:\n --media Download the files Langfuse media references (@@@langfuseMedia:\u2026@@@)\n point to and upload them to Hue; without it, references stay as text\n --no-content Send metadata only: no inputs, outputs, status messages or model\n parameters (content is sent by default, as the SDK records it)\n\nRun:\n --dry-run Read Langfuse and count what would be imported; send nothing to Hue\n --yes Import without asking for confirmation (required without a terminal)\n --env-path PATH Load a dotenv file first (--env-file also works when it exists);\n ./.env.hue loads when HUE_API_KEY is not set. Variables already set win\n -h, --help Show this help\n\nExit codes: 0 every trace was imported, 1 a trace, span or file was not, 2 usage error,\n130 stopped (run the same command again to resume).";
29
+ export declare const IMPORT_USAGE = "Usage: hue import langfuse [options]\n\nCopy traces from a Langfuse project into Hue. The import runs on this machine with your own\nLangfuse keys, which are sent only to Langfuse. Each observation becomes a span with the\nlangfuse.* attributes Hue reads; ids are kept, so running the same command again resumes an\nimport without duplicating what was already sent. Langfuse's environment is also sent, as\nrecorded, as hue.import.source_environment; only traces Langfuse recorded in production add to\na user's World.\n\nLangfuse (keys from the environment or --env-path; the secret key never from the command line):\n LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY The Langfuse project's API keys\n LANGFUSE_BASE_URL or LANGFUSE_HOST Langfuse host (default https://cloud.langfuse.com)\n --langfuse-host URL Langfuse host, instead of the variables\n --langfuse-public-key KEY Public key, instead of LANGFUSE_PUBLIC_KEY\n\nHue:\n HUE_API_KEY The Hue project key the traces are sent with (environment, --env-path\n or ./.env.hue); not needed with --dry-run\n --origin URL Hue origin (default HUE_BASE_URL, then https://app.hue.run)\n --service-name NAME service.name of the imported spans (default langfuse)\n\nSelection (newest first):\n --from TIME Traces that started at or after TIME: an ISO 8601 date (midnight UTC)\n or a date and time with a zone, such as 2026-01-01T09:00:00Z\n --to TIME Traces that started before TIME (default: an hour before the command\n starts, so traces still running are left for a later run)\n --limit N At most N traces\n --trace-id ID This Langfuse trace (repeatable); not with --from, --to or --limit\n\nContent:\n --media Download the files Langfuse media references (@@@langfuseMedia:\u2026@@@)\n point to and upload them to Hue; without it, references stay as text\n --no-content Send metadata only: no inputs, outputs, status messages or model\n parameters (content is sent by default, as the SDK records it)\n\nRun:\n --dry-run Read Langfuse and count what would be imported; send nothing to Hue\n --yes Import without asking for confirmation (required without a terminal)\n --env-path PATH Load a dotenv file first (--env-file also works when it exists);\n ./.env.hue loads when HUE_API_KEY is not set. Variables already set win\n -h, --help Show this help\n\nExit codes: 0 every trace was imported, 1 a trace, span or file was not, 2 usage error,\n130 stopped (run the same command again to resume).";
30
30
  /** An instant of the window: an ISO 8601 date (midnight UTC) or a date and time with a zone. */
31
31
  export declare function parseInstant(option: string, value: string): string;
32
32
  /** The Langfuse host as a base URL without a trailing slash, or why it is refused. */
@@ -44,7 +44,9 @@ export const IMPORT_USAGE = `Usage: hue import langfuse [options]
44
44
  Copy traces from a Langfuse project into Hue. The import runs on this machine with your own
45
45
  Langfuse keys, which are sent only to Langfuse. Each observation becomes a span with the
46
46
  langfuse.* attributes Hue reads; ids are kept, so running the same command again resumes an
47
- import without duplicating what was already sent.
47
+ import without duplicating what was already sent. Langfuse's environment is also sent, as
48
+ recorded, as hue.import.source_environment; only traces Langfuse recorded in production add to
49
+ a user's World.
48
50
 
49
51
  Langfuse (keys from the environment or --env-path; the secret key never from the command line):
50
52
  LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY The Langfuse project's API keys
@@ -201,7 +201,8 @@ export interface TraceContext {
201
201
  * `langfuse.session.id`, `langfuse.release`, `langfuse.version` and `langfuse.environment`, with
202
202
  * `gen_ai.request.model` and the input and output token counts as GenAI attributes. The
203
203
  * observation's and trace's own ids are kept as `langfuse.observation.id` and
204
- * `langfuse.trace.id`. Throws for a start time that is no ISO 8601 instant.
204
+ * `langfuse.trace.id`, and its environment also as `hue.import.source_environment`. Throws for a
205
+ * start time that is no ISO 8601 instant.
205
206
  */
206
207
  export declare function observationSpan(observation: LangfuseObservation, context: TraceContext): ImportSpan;
207
208
  /** The context a v1 trace gives its observations. */
@@ -209,9 +210,9 @@ export declare function traceContext(trace: LangfuseTrace): TraceContext;
209
210
  /**
210
211
  * The span that stands for a v1 trace, the parent of its observations without one, as the trace
211
212
  * Langfuse shows above them: `langfuse.trace.*` (name, input, output, one `metadata.<key>`
212
- * attribute per key, tags, public), the user, session, release, version and environment. It
213
- * covers the trace's timestamp and its observations, `observed`. Throws for a timestamp that is
214
- * no ISO 8601 instant.
213
+ * attribute per key, tags, public), the user, session, release, version and environment (also as
214
+ * `hue.import.source_environment`). It covers the trace's timestamp and its observations,
215
+ * `observed`. Throws for a timestamp that is no ISO 8601 instant.
215
216
  */
216
217
  export declare function traceSpan(trace: LangfuseTrace, observed: TimeBounds | undefined): ImportSpan;
217
218
  /** A converted span as the OpenTelemetry SDK hands a finished span to a processor. */
@@ -719,6 +719,16 @@ function setText(into, key, value) {
719
719
  if (value !== undefined && value !== "")
720
720
  into[key] = value;
721
721
  }
722
+ /** Hue's import provenance: the source's own environment, as Langfuse recorded it. Hue's World
723
+ * capture treats a trace carrying `hue.import.*` attributes as imported, and never takes one in
724
+ * which a span names an environment other than exactly `production` as production history. */
725
+ const IMPORT_SOURCE_ENVIRONMENT = "hue.import.source_environment";
726
+ /** Langfuse's environment, verbatim, as `langfuse.environment` and as Hue's import provenance;
727
+ * an absent environment stays absent, never defaulted. */
728
+ function setEnvironment(into, environment) {
729
+ setText(into, "langfuse.environment", environment);
730
+ setText(into, IMPORT_SOURCE_ENVIRONMENT, environment);
731
+ }
722
732
  /**
723
733
  * A Langfuse observation as the span the Langfuse OpenTelemetry SDKs would have recorded:
724
734
  * `langfuse.observation.*` (type in lower case, input, output, one `metadata.<key>` attribute per
@@ -727,7 +737,8 @@ function setText(into, key, value) {
727
737
  * `langfuse.session.id`, `langfuse.release`, `langfuse.version` and `langfuse.environment`, with
728
738
  * `gen_ai.request.model` and the input and output token counts as GenAI attributes. The
729
739
  * observation's and trace's own ids are kept as `langfuse.observation.id` and
730
- * `langfuse.trace.id`. Throws for a start time that is no ISO 8601 instant.
740
+ * `langfuse.trace.id`, and its environment also as `hue.import.source_environment`. Throws for a
741
+ * start time that is no ISO 8601 instant.
731
742
  */
732
743
  export function observationSpan(observation, context) {
733
744
  const start = hrTimeOf(observation.startTime);
@@ -774,7 +785,7 @@ export function observationSpan(observation, context) {
774
785
  setText(attributes, "langfuse.session.id", observation.sessionId ?? context.sessionId);
775
786
  setText(attributes, "langfuse.release", observation.release ?? context.release);
776
787
  setText(attributes, "langfuse.version", observation.version);
777
- setText(attributes, "langfuse.environment", observation.environment);
788
+ setEnvironment(attributes, observation.environment);
778
789
  attributes["langfuse.trace.id"] = context.langfuseTraceId;
779
790
  attributes["langfuse.observation.id"] = observation.id;
780
791
  const parent = observation.parentObservationId
@@ -806,9 +817,9 @@ export function traceContext(trace) {
806
817
  /**
807
818
  * The span that stands for a v1 trace, the parent of its observations without one, as the trace
808
819
  * Langfuse shows above them: `langfuse.trace.*` (name, input, output, one `metadata.<key>`
809
- * attribute per key, tags, public), the user, session, release, version and environment. It
810
- * covers the trace's timestamp and its observations, `observed`. Throws for a timestamp that is
811
- * no ISO 8601 instant.
820
+ * attribute per key, tags, public), the user, session, release, version and environment (also as
821
+ * `hue.import.source_environment`). It covers the trace's timestamp and its observations,
822
+ * `observed`. Throws for a timestamp that is no ISO 8601 instant.
812
823
  */
813
824
  export function traceSpan(trace, observed) {
814
825
  const timestamp = hrTimeOf(trace.timestamp);
@@ -829,7 +840,7 @@ export function traceSpan(trace, observed) {
829
840
  setText(attributes, "langfuse.session.id", trace.sessionId);
830
841
  setText(attributes, "langfuse.release", trace.release);
831
842
  setText(attributes, "langfuse.version", trace.version);
832
- setText(attributes, "langfuse.environment", trace.environment);
843
+ setEnvironment(attributes, trace.environment);
833
844
  attributes["langfuse.trace.id"] = trace.id;
834
845
  return {
835
846
  traceId: hueTraceId(trace.id),
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** Package version shared by the instrumentation scope and the export User-Agent. */
2
- export declare const sdkVersion = "0.20.5";
2
+ export declare const sdkVersion = "0.20.6";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // Generated by scripts/write-version.mjs from package.json; do not edit by hand.
2
2
  /** Package version shared by the instrumentation scope and the export User-Agent. */
3
- export const sdkVersion = "0.20.5";
3
+ export const sdkVersion = "0.20.6";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hue-run/sdk",
3
- "version": "0.20.5",
3
+ "version": "0.20.6",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "publishConfig": {