2323
2424import java .time .Instant ;
2525import java .util .Collections ;
26+ import java .util .HashMap ;
2627import java .util .List ;
2728import java .util .Map ;
2829import java .util .Objects ;
@@ -230,16 +231,21 @@ public static final class CreateWorkflowRequest {
230231 @ JsonProperty ("metadata" )
231232 private final Map <String , Object > metadata ;
232233
234+ @ JsonProperty ("trace_id" )
235+ private final String traceId ;
236+
233237 @ JsonCreator
234238 public CreateWorkflowRequest (
235239 @ JsonProperty ("workflow_name" ) String workflowName ,
236240 @ JsonProperty ("source" ) WorkflowSource source ,
237241 @ JsonProperty ("total_steps" ) Integer totalSteps ,
238- @ JsonProperty ("metadata" ) Map <String , Object > metadata ) {
242+ @ JsonProperty ("metadata" ) Map <String , Object > metadata ,
243+ @ JsonProperty ("trace_id" ) String traceId ) {
239244 this .workflowName = Objects .requireNonNull (workflowName , "workflowName is required" );
240245 this .source = source != null ? source : WorkflowSource .EXTERNAL ;
241246 this .totalSteps = totalSteps ;
242247 this .metadata = metadata != null ? Collections .unmodifiableMap (metadata ) : Collections .emptyMap ();
248+ this .traceId = traceId ;
243249 }
244250
245251 public String getWorkflowName () {
@@ -258,6 +264,10 @@ public Map<String, Object> getMetadata() {
258264 return metadata ;
259265 }
260266
267+ public String getTraceId () {
268+ return traceId ;
269+ }
270+
261271 public static Builder builder () {
262272 return new Builder ();
263273 }
@@ -267,6 +277,7 @@ public static final class Builder {
267277 private WorkflowSource source = WorkflowSource .EXTERNAL ;
268278 private Integer totalSteps ;
269279 private Map <String , Object > metadata ;
280+ private String traceId ;
270281
271282 public Builder workflowName (String workflowName ) {
272283 this .workflowName = workflowName ;
@@ -288,8 +299,13 @@ public Builder metadata(Map<String, Object> metadata) {
288299 return this ;
289300 }
290301
302+ public Builder traceId (String traceId ) {
303+ this .traceId = traceId ;
304+ return this ;
305+ }
306+
291307 public CreateWorkflowRequest build () {
292- return new CreateWorkflowRequest (workflowName , source , totalSteps , metadata );
308+ return new CreateWorkflowRequest (workflowName , source , totalSteps , metadata , traceId );
293309 }
294310 }
295311 }
@@ -315,18 +331,23 @@ public static final class CreateWorkflowResponse {
315331 @ JsonProperty ("created_at" )
316332 private final Instant createdAt ;
317333
334+ @ JsonProperty ("trace_id" )
335+ private final String traceId ;
336+
318337 @ JsonCreator
319338 public CreateWorkflowResponse (
320339 @ JsonProperty ("workflow_id" ) String workflowId ,
321340 @ JsonProperty ("workflow_name" ) String workflowName ,
322341 @ JsonProperty ("source" ) WorkflowSource source ,
323342 @ JsonProperty ("status" ) WorkflowStatus status ,
324- @ JsonProperty ("created_at" ) Instant createdAt ) {
343+ @ JsonProperty ("created_at" ) Instant createdAt ,
344+ @ JsonProperty ("trace_id" ) String traceId ) {
325345 this .workflowId = workflowId ;
326346 this .workflowName = workflowName ;
327347 this .source = source ;
328348 this .status = status ;
329349 this .createdAt = createdAt ;
350+ this .traceId = traceId ;
330351 }
331352
332353 public String getWorkflowId () {
@@ -348,6 +369,64 @@ public WorkflowStatus getStatus() {
348369 public Instant getCreatedAt () {
349370 return createdAt ;
350371 }
372+
373+ public String getTraceId () {
374+ return traceId ;
375+ }
376+ }
377+
378+ /**
379+ * Tool-level context for per-tool governance within tool_call steps.
380+ */
381+ @ JsonIgnoreProperties (ignoreUnknown = true )
382+ public static final class ToolContext {
383+
384+ @ JsonProperty ("tool_name" )
385+ private final String toolName ;
386+
387+ @ JsonProperty ("tool_type" )
388+ private final String toolType ;
389+
390+ @ JsonProperty ("tool_input" )
391+ private final Map <String , Object > toolInput ;
392+
393+ private ToolContext (Builder builder ) {
394+ this .toolName = builder .toolName ;
395+ this .toolType = builder .toolType ;
396+ this .toolInput = builder .toolInput != null ? Collections .unmodifiableMap (new HashMap <>(builder .toolInput )) : null ;
397+ }
398+
399+ @ JsonCreator
400+ public ToolContext (
401+ @ JsonProperty ("tool_name" ) String toolName ,
402+ @ JsonProperty ("tool_type" ) String toolType ,
403+ @ JsonProperty ("tool_input" ) Map <String , Object > toolInput ) {
404+ this .toolName = toolName ;
405+ this .toolType = toolType ;
406+ this .toolInput = toolInput != null ? Collections .unmodifiableMap (new HashMap <>(toolInput )) : null ;
407+ }
408+
409+ public String getToolName () { return toolName ; }
410+ public String getToolType () { return toolType ; }
411+ public Map <String , Object > getToolInput () { return toolInput ; }
412+
413+ public static Builder builder (String toolName ) {
414+ return new Builder (toolName );
415+ }
416+
417+ public static final class Builder {
418+ private final String toolName ;
419+ private String toolType ;
420+ private Map <String , Object > toolInput ;
421+
422+ public Builder (String toolName ) {
423+ this .toolName = Objects .requireNonNull (toolName , "toolName must not be null" );
424+ }
425+
426+ public Builder toolType (String toolType ) { this .toolType = toolType ; return this ; }
427+ public Builder toolInput (Map <String , Object > toolInput ) { this .toolInput = toolInput ; return this ; }
428+ public ToolContext build () { return new ToolContext (this ); }
429+ }
351430 }
352431
353432 /**
@@ -371,18 +450,23 @@ public static final class StepGateRequest {
371450 @ JsonProperty ("provider" )
372451 private final String provider ;
373452
453+ @ JsonProperty ("tool_context" )
454+ private final ToolContext toolContext ;
455+
374456 @ JsonCreator
375457 public StepGateRequest (
376458 @ JsonProperty ("step_name" ) String stepName ,
377459 @ JsonProperty ("step_type" ) StepType stepType ,
378460 @ JsonProperty ("step_input" ) Map <String , Object > stepInput ,
379461 @ JsonProperty ("model" ) String model ,
380- @ JsonProperty ("provider" ) String provider ) {
462+ @ JsonProperty ("provider" ) String provider ,
463+ @ JsonProperty ("tool_context" ) ToolContext toolContext ) {
381464 this .stepName = stepName ;
382465 this .stepType = Objects .requireNonNull (stepType , "stepType is required" );
383466 this .stepInput = stepInput != null ? Collections .unmodifiableMap (stepInput ) : Collections .emptyMap ();
384467 this .model = model ;
385468 this .provider = provider ;
469+ this .toolContext = toolContext ;
386470 }
387471
388472 public String getStepName () {
@@ -405,6 +489,10 @@ public String getProvider() {
405489 return provider ;
406490 }
407491
492+ public ToolContext getToolContext () {
493+ return toolContext ;
494+ }
495+
408496 public static Builder builder () {
409497 return new Builder ();
410498 }
@@ -415,6 +503,7 @@ public static final class Builder {
415503 private Map <String , Object > stepInput ;
416504 private String model ;
417505 private String provider ;
506+ private ToolContext toolContext ;
418507
419508 public Builder stepName (String stepName ) {
420509 this .stepName = stepName ;
@@ -441,8 +530,13 @@ public Builder provider(String provider) {
441530 return this ;
442531 }
443532
533+ public Builder toolContext (ToolContext toolContext ) {
534+ this .toolContext = toolContext ;
535+ return this ;
536+ }
537+
444538 public StepGateRequest build () {
445- return new StepGateRequest (stepName , stepType , stepInput , model , provider );
539+ return new StepGateRequest (stepName , stepType , stepInput , model , provider , toolContext );
446540 }
447541 }
448542 }
@@ -679,6 +773,9 @@ public static final class WorkflowStatusResponse {
679773 @ JsonProperty ("steps" )
680774 private final List <WorkflowStepInfo > steps ;
681775
776+ @ JsonProperty ("trace_id" )
777+ private final String traceId ;
778+
682779 @ JsonCreator
683780 public WorkflowStatusResponse (
684781 @ JsonProperty ("workflow_id" ) String workflowId ,
@@ -689,7 +786,8 @@ public WorkflowStatusResponse(
689786 @ JsonProperty ("total_steps" ) Integer totalSteps ,
690787 @ JsonProperty ("started_at" ) Instant startedAt ,
691788 @ JsonProperty ("completed_at" ) Instant completedAt ,
692- @ JsonProperty ("steps" ) List <WorkflowStepInfo > steps ) {
789+ @ JsonProperty ("steps" ) List <WorkflowStepInfo > steps ,
790+ @ JsonProperty ("trace_id" ) String traceId ) {
693791 this .workflowId = workflowId ;
694792 this .workflowName = workflowName ;
695793 this .source = source ;
@@ -699,6 +797,7 @@ public WorkflowStatusResponse(
699797 this .startedAt = startedAt ;
700798 this .completedAt = completedAt ;
701799 this .steps = steps != null ? Collections .unmodifiableList (steps ) : Collections .emptyList ();
800+ this .traceId = traceId ;
702801 }
703802
704803 public String getWorkflowId () {
@@ -737,6 +836,10 @@ public List<WorkflowStepInfo> getSteps() {
737836 return steps ;
738837 }
739838
839+ public String getTraceId () {
840+ return traceId ;
841+ }
842+
740843 public boolean isTerminal () {
741844 return status == WorkflowStatus .COMPLETED ||
742845 status == WorkflowStatus .ABORTED ||
@@ -753,12 +856,14 @@ public static final class ListWorkflowsOptions {
753856 private final WorkflowSource source ;
754857 private final int limit ;
755858 private final int offset ;
859+ private final String traceId ;
756860
757- public ListWorkflowsOptions (WorkflowStatus status , WorkflowSource source , int limit , int offset ) {
861+ public ListWorkflowsOptions (WorkflowStatus status , WorkflowSource source , int limit , int offset , String traceId ) {
758862 this .status = status ;
759863 this .source = source ;
760864 this .limit = limit > 0 ? limit : 50 ;
761865 this .offset = Math .max (offset , 0 );
866+ this .traceId = traceId ;
762867 }
763868
764869 public WorkflowStatus getStatus () {
@@ -777,6 +882,10 @@ public int getOffset() {
777882 return offset ;
778883 }
779884
885+ public String getTraceId () {
886+ return traceId ;
887+ }
888+
780889 public static Builder builder () {
781890 return new Builder ();
782891 }
@@ -786,6 +895,7 @@ public static final class Builder {
786895 private WorkflowSource source ;
787896 private int limit = 50 ;
788897 private int offset = 0 ;
898+ private String traceId ;
789899
790900 public Builder status (WorkflowStatus status ) {
791901 this .status = status ;
@@ -807,8 +917,13 @@ public Builder offset(int offset) {
807917 return this ;
808918 }
809919
920+ public Builder traceId (String traceId ) {
921+ this .traceId = traceId ;
922+ return this ;
923+ }
924+
810925 public ListWorkflowsOptions build () {
811- return new ListWorkflowsOptions (status , source , limit , offset );
926+ return new ListWorkflowsOptions (status , source , limit , offset , traceId );
812927 }
813928 }
814929 }
0 commit comments