@hue-run/sdk 0.20.4 → 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 +26 -16
- package/README.md +4 -2
- package/dist/cli/import.d.ts +1 -1
- package/dist/cli/import.js +3 -1
- package/dist/cli/langfuse.d.ts +5 -4
- package/dist/cli/langfuse.js +17 -6
- package/dist/cli/traces-import-convert.js +20 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
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.
|
|
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.
|
|
385
|
-
npx -y @hue-run/sdk@0.20.
|
|
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
|
|
440
|
-
whose Langfuse data changed after it was imported to be refused. For
|
|
441
|
-
sends nothing that depends on the run: a trace's root never carries
|
|
442
|
-
files and large values are stored before their span is sent. Leave
|
|
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
|
|
@@ -523,7 +531,9 @@ attributes Hue reads; an id that is no OpenTelemetry id is mapped as `hue import
|
|
|
523
531
|
so an export and a live import of the same trace agree. An ATIF export becomes one trace: an agent
|
|
524
532
|
span for the run, a model span per agent step with the conversation so far, a tool span per call,
|
|
525
533
|
each embedded subagent as its own agent span under the call that spawned it, and the export's
|
|
526
|
-
`extra.user_id` as the trace's `user.id
|
|
534
|
+
`extra.user_id` as the trace's `user.id`; its spans carry `hue.import.format` `atif` under the
|
|
535
|
+
instrumentation scope `hue.import.atif`, and the run's agent span is named `invoke_agent
|
|
536
|
+
<agent.name>` from the export's own agent. ATIF records instants, not durations, so model and tool
|
|
527
537
|
spans are points in time, and a tool's result is kept as text with no error status of the
|
|
528
538
|
importer's making. The same trace in two files is one trace when the copies agree and a refusal
|
|
529
539
|
when they differ; a trace with more than 100,000 spans, 64 batches or 1,000 values is refused and
|
|
@@ -687,7 +697,7 @@ node packages/sdk-typescript/scripts/verify-package.mjs --artifacts-dir .artifac
|
|
|
687
697
|
# Set project to an existing supported fixture; use the same directory on resume.
|
|
688
698
|
project=/absolute/path/to/supported-fixture
|
|
689
699
|
node packages/sdk-typescript/scripts/verify-setup-live.mjs \
|
|
690
|
-
--archive .artifacts/typescript/hue-run-sdk-0.20.
|
|
700
|
+
--archive .artifacts/typescript/hue-run-sdk-0.20.6.tgz \
|
|
691
701
|
--origin https://STAGING_ORIGIN \
|
|
692
702
|
--project "$project" --command setup \
|
|
693
703
|
--evidence .context/setup-staging-before-claim.json
|
|
@@ -698,7 +708,7 @@ the private local handoff and finish the real browser claim, then reconcile the
|
|
|
698
708
|
|
|
699
709
|
```sh
|
|
700
710
|
node packages/sdk-typescript/scripts/verify-setup-live.mjs \
|
|
701
|
-
--archive .artifacts/typescript/hue-run-sdk-0.20.
|
|
711
|
+
--archive .artifacts/typescript/hue-run-sdk-0.20.6.tgz \
|
|
702
712
|
--origin https://STAGING_ORIGIN \
|
|
703
713
|
--project "$project" --command claim \
|
|
704
714
|
--evidence .context/setup-staging-after-claim.json
|
|
@@ -740,10 +750,10 @@ otherwise. Never hand the agent Hue-native tools (`context.tools`, `context.mcp`
|
|
|
740
750
|
production agent lacks. Pin the SDK, so the agent's repository gains no dependency:
|
|
741
751
|
|
|
742
752
|
```sh
|
|
743
|
-
npx -y @hue-run/sdk@0.20.
|
|
744
|
-
npx -y @hue-run/sdk@0.20.
|
|
745
|
-
npx -y @hue-run/sdk@0.20.
|
|
746
|
-
npx -y @hue-run/sdk@0.20.
|
|
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>
|
|
747
757
|
```
|
|
748
758
|
|
|
749
759
|
One invocation creates one run holding every selected case; it prints the run URL
|
|
@@ -781,7 +791,7 @@ export default function runMyAgent(inputs: JsonValue, context: SimulationTargetC
|
|
|
781
791
|
```
|
|
782
792
|
|
|
783
793
|
```sh
|
|
784
|
-
npx -y @hue-run/sdk@0.20.
|
|
794
|
+
npx -y @hue-run/sdk@0.20.6 eval --case "Refund an eligible charge" ./hue-agent.ts --content
|
|
785
795
|
```
|
|
786
796
|
|
|
787
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.
|
|
540
|
-
npx -y @hue-run/sdk@0.20.
|
|
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.4 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
|
package/dist/cli/import.d.ts
CHANGED
|
@@ -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. */
|
package/dist/cli/import.js
CHANGED
|
@@ -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
|
package/dist/cli/langfuse.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
213
|
-
* covers the trace's timestamp and its observations,
|
|
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. */
|
package/dist/cli/langfuse.js
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
|
810
|
-
* covers the trace's timestamp and its observations,
|
|
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
|
-
|
|
843
|
+
setEnvironment(attributes, trace.environment);
|
|
833
844
|
attributes["langfuse.trace.id"] = trace.id;
|
|
834
845
|
return {
|
|
835
846
|
traceId: hueTraceId(trace.id),
|
|
@@ -992,10 +992,21 @@ function convertLangfuseTrace(draft, traceId) {
|
|
|
992
992
|
/** The ATIF reader's bounds: a text export of at most 4 MiB and 2,000 spans. */
|
|
993
993
|
export const MAX_ATIF_FILE_BYTES = 4 * 1024 * 1024;
|
|
994
994
|
export const MAX_ATIF_SPANS = 2000;
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
995
|
+
/** The conversion's generation, part of every derived trace and span id: raised when the ids'
|
|
996
|
+
* seed or the spans' shape changes, so a bundle prepared by an earlier generation is prepared
|
|
997
|
+
* again rather than mixed with this one. 3 names the format generically; 2 carried one
|
|
998
|
+
* producer's name in the label, the scope and the seed. */
|
|
999
|
+
const ATIF_IMPORT_VERSION = "3";
|
|
1000
|
+
/** The format label (`hue.import.format`) and instrumentation scope of a trace converted from
|
|
1001
|
+
* ATIF, the Agent Trajectory Interchange Format: the format's own name, whoever exported it. */
|
|
1002
|
+
const ATIF_FORMAT = "atif";
|
|
1003
|
+
const ATIF_SCOPE = "hue.import.atif";
|
|
1004
|
+
/** The agent span's name, from the export's own agent: `invoke_agent <agent.name>`, or
|
|
1005
|
+
* `invoke_agent` alone when the export names none. */
|
|
1006
|
+
function agentSpanName(t) {
|
|
1007
|
+
const name = typeof t.agent.name === "string" ? t.agent.name.trim() : "";
|
|
1008
|
+
return name ? `invoke_agent ${name}` : "invoke_agent";
|
|
1009
|
+
}
|
|
999
1010
|
const optionalText = z.string().nullable().optional();
|
|
1000
1011
|
const identity = z.string().min(1).max(512);
|
|
1001
1012
|
const count = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).nullable().optional();
|
|
@@ -1339,8 +1350,10 @@ export function convertAtifExport(source, rawBytes) {
|
|
|
1339
1350
|
for (const sub of spawned.get(requested.tool_call_id) ?? [])
|
|
1340
1351
|
order.set(sub, sub.steps.map(() => ordinal++));
|
|
1341
1352
|
}
|
|
1353
|
+
// The trace's identity is run scoped: the scope name, the conversion's generation, the
|
|
1354
|
+
// export's session and trajectory ids. Never a path, a file digest or a producer's name.
|
|
1342
1355
|
const identityParts = [
|
|
1343
|
-
|
|
1356
|
+
ATIF_SCOPE,
|
|
1344
1357
|
ATIF_IMPORT_VERSION,
|
|
1345
1358
|
document.session_id,
|
|
1346
1359
|
document.trajectory_id ?? null,
|
|
@@ -1404,7 +1417,7 @@ export function convertAtifExport(source, rawBytes) {
|
|
|
1404
1417
|
addUsage(rootAttributes, finalUsage(document));
|
|
1405
1418
|
addSpan({
|
|
1406
1419
|
spanId: rootId,
|
|
1407
|
-
name:
|
|
1420
|
+
name: agentSpanName(document),
|
|
1408
1421
|
startTimeUnixNano: main.start,
|
|
1409
1422
|
endTimeUnixNano: lastInstant,
|
|
1410
1423
|
attributes: rootAttributes.finish(),
|
|
@@ -1543,7 +1556,7 @@ export function convertAtifExport(source, rawBytes) {
|
|
|
1543
1556
|
addSpan({
|
|
1544
1557
|
spanId: agentId,
|
|
1545
1558
|
parentSpanId,
|
|
1546
|
-
name:
|
|
1559
|
+
name: agentSpanName(sub),
|
|
1547
1560
|
startTimeUnixNano: found.checked.start,
|
|
1548
1561
|
endTimeUnixNano: found.checked.times.at(-1),
|
|
1549
1562
|
attributes: attributes.finish(),
|
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.
|
|
2
|
+
export declare const sdkVersion = "0.20.6";
|
package/dist/version.js
CHANGED