@@ -115,27 +115,35 @@ interface HeadersLike {
115
115
class Baggage {
116
116
metadata : KVMap | undefined ;
117
117
tags : string [ ] | undefined ;
118
-
119
- constructor ( metadata : KVMap | undefined , tags : string [ ] | undefined ) {
118
+ project_name : string | undefined ;
119
+ constructor (
120
+ metadata : KVMap | undefined ,
121
+ tags : string [ ] | undefined ,
122
+ project_name : string | undefined
123
+ ) {
120
124
this . metadata = metadata ;
121
125
this . tags = tags ;
126
+ this . project_name = project_name ;
122
127
}
123
128
124
129
static fromHeader ( value : string ) {
125
130
const items = value . split ( "," ) ;
126
131
let metadata : KVMap = { } ;
127
132
let tags : string [ ] = [ ] ;
133
+ let project_name : string | undefined ;
128
134
for ( const item of items ) {
129
135
const [ key , uriValue ] = item . split ( "=" ) ;
130
136
const value = decodeURIComponent ( uriValue ) ;
131
137
if ( key === "langsmith-metadata" ) {
132
138
metadata = JSON . parse ( value ) ;
133
139
} else if ( key === "langsmith-tags" ) {
134
140
tags = value . split ( "," ) ;
141
+ } else if ( key === "langsmith-project" ) {
142
+ project_name = value ;
135
143
}
136
144
}
137
145
138
- return new Baggage ( metadata , tags ) ;
146
+ return new Baggage ( metadata , tags , project_name ) ;
139
147
}
140
148
141
149
toHeader ( ) : string {
@@ -150,6 +158,10 @@ class Baggage {
150
158
if ( this . tags && this . tags . length > 0 ) {
151
159
items . push ( `langsmith-tags=${ encodeURIComponent ( this . tags . join ( "," ) ) } ` ) ;
152
160
}
161
+ if ( this . project_name ) {
162
+ items . push ( `langsmith-project=${ encodeURIComponent ( this . project_name ) } ` ) ;
163
+ }
164
+
153
165
return items . join ( "," ) ;
154
166
}
155
167
}
@@ -556,6 +568,7 @@ export class RunTree implements BaseRun {
556
568
const baggage = Baggage . fromHeader ( rawHeaders [ "baggage" ] ) ;
557
569
config . metadata = baggage . metadata ;
558
570
config . tags = baggage . tags ;
571
+ config . project_name = baggage . project_name ;
559
572
}
560
573
561
574
return new RunTree ( config ) ;
@@ -564,7 +577,11 @@ export class RunTree implements BaseRun {
564
577
toHeaders ( headers ?: HeadersLike ) {
565
578
const result = {
566
579
"langsmith-trace" : this . dotted_order ,
567
- baggage : new Baggage ( this . extra ?. metadata , this . tags ) . toHeader ( ) ,
580
+ baggage : new Baggage (
581
+ this . extra ?. metadata ,
582
+ this . tags ,
583
+ this . project_name
584
+ ) . toHeader ( ) ,
568
585
} ;
569
586
570
587
if ( headers ) {
0 commit comments