History

Inline provider thread and turn ID schemas in runtime events

- Remove redundant runtime schema aliases for thread and turn IDs - Use `ProviderThreadId` and `ProviderTurnId` directly across runtime event contracts

Julius Marminge committed 8 months ago

Commit 7dab2401 parent d19b2f51 file · +23 −25Browse files

Unified · Split

packages/contracts/src/providerRuntime.ts+23−25
@@ -14,8 +14,6 @@ import { · 13 unmodified lines
14import { ProviderApprovalDecision, ProviderKind, ProviderRequestKind } from "./orchestration";14import { ProviderApprovalDecision, ProviderKind, ProviderRequestKind } from "./orchestration";
15 15
16const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString;16const TrimmedNonEmptyStringSchema = TrimmedNonEmptyString;
17const RuntimeThreadIdSchema = ProviderThreadId;
18const RuntimeTurnIdSchema = ProviderTurnId;
19 17
20export const ProviderRuntimeToolKind = Schema.Union([ProviderRequestKind, Schema.Literal("other")]);18export const ProviderRuntimeToolKind = Schema.Union([ProviderRequestKind, Schema.Literal("other")]);
21export type ProviderRuntimeToolKind = typeof ProviderRuntimeToolKind.Type;19export type ProviderRuntimeToolKind = typeof ProviderRuntimeToolKind.Type;
@@ -34,7 +32,7 @@ export const ProviderRuntimeSessionStartedEvent = Schema.Struct({ · 12 unmodified lines
34 provider: ProviderKind,32 provider: ProviderKind,
35 sessionId: ProviderSessionId,33 sessionId: ProviderSessionId,
36 createdAt: IsoDateTime,34 createdAt: IsoDateTime,
37 threadId: Schema.optional(RuntimeThreadIdSchema),35 threadId: Schema.optional(ProviderThreadId),
38 message: Schema.optional(TrimmedNonEmptyStringSchema),36 message: Schema.optional(TrimmedNonEmptyStringSchema),
39});37});
40export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type;38export type ProviderRuntimeSessionStartedEvent = typeof ProviderRuntimeSessionStartedEvent.Type;
@@ -45,7 +43,7 @@ export const ProviderRuntimeSessionExitedEvent = Schema.Struct({ · 4 unmodified lines
45 provider: ProviderKind,43 provider: ProviderKind,
46 sessionId: ProviderSessionId,44 sessionId: ProviderSessionId,
47 createdAt: IsoDateTime,45 createdAt: IsoDateTime,
48 threadId: Schema.optional(RuntimeThreadIdSchema),46 threadId: Schema.optional(ProviderThreadId),
49 message: Schema.optional(TrimmedNonEmptyStringSchema),47 message: Schema.optional(TrimmedNonEmptyStringSchema),
50});48});
51export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type;49export type ProviderRuntimeSessionExitedEvent = typeof ProviderRuntimeSessionExitedEvent.Type;
@@ -56,7 +54,7 @@ export const ProviderRuntimeThreadStartedEvent = Schema.Struct({ · 4 unmodified lines
56 provider: ProviderKind,54 provider: ProviderKind,
57 sessionId: ProviderSessionId,55 sessionId: ProviderSessionId,
58 createdAt: IsoDateTime,56 createdAt: IsoDateTime,
59 threadId: RuntimeThreadIdSchema,57 threadId: ProviderThreadId,
60});58});
61export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type;59export type ProviderRuntimeThreadStartedEvent = typeof ProviderRuntimeThreadStartedEvent.Type;
62 60
@@ -66,8 +64,8 @@ export const ProviderRuntimeTurnStartedEvent = Schema.Struct({ · 3 unmodified lines
66 provider: ProviderKind,64 provider: ProviderKind,
67 sessionId: ProviderSessionId,65 sessionId: ProviderSessionId,
68 createdAt: IsoDateTime,66 createdAt: IsoDateTime,
69 threadId: Schema.optional(RuntimeThreadIdSchema),67 threadId: Schema.optional(ProviderThreadId),
70 turnId: RuntimeTurnIdSchema,68 turnId: ProviderTurnId,
71});69});
72export type ProviderRuntimeTurnStartedEvent = typeof ProviderRuntimeTurnStartedEvent.Type;70export type ProviderRuntimeTurnStartedEvent = typeof ProviderRuntimeTurnStartedEvent.Type;
73 71
@@ -77,8 +75,8 @@ export const ProviderRuntimeTurnCompletedEvent = Schema.Struct({ · 3 unmodified lines
77 provider: ProviderKind,75 provider: ProviderKind,
78 sessionId: ProviderSessionId,76 sessionId: ProviderSessionId,
79 createdAt: IsoDateTime,77 createdAt: IsoDateTime,
80 threadId: Schema.optional(RuntimeThreadIdSchema),78 threadId: Schema.optional(ProviderThreadId),
81 turnId: Schema.optional(RuntimeTurnIdSchema),79 turnId: Schema.optional(ProviderTurnId),
82 status: Schema.optional(ProviderRuntimeTurnStatus),80 status: Schema.optional(ProviderRuntimeTurnStatus),
83 errorMessage: Schema.optional(TrimmedNonEmptyStringSchema),81 errorMessage: Schema.optional(TrimmedNonEmptyStringSchema),
84});82});
@@ -90,8 +88,8 @@ export const ProviderRuntimeMessageDeltaEvent = Schema.Struct({ · 5 unmodified lines
90 provider: ProviderKind,88 provider: ProviderKind,
91 sessionId: ProviderSessionId,89 sessionId: ProviderSessionId,
92 createdAt: IsoDateTime,90 createdAt: IsoDateTime,
93 threadId: Schema.optional(RuntimeThreadIdSchema),91 threadId: Schema.optional(ProviderThreadId),
94 turnId: Schema.optional(RuntimeTurnIdSchema),92 turnId: Schema.optional(ProviderTurnId),
95 itemId: Schema.optional(ProviderItemId),93 itemId: Schema.optional(ProviderItemId),
96 delta: Schema.String,94 delta: Schema.String,
97});95});
@@ -104,8 +102,8 @@ export const ProviderRuntimeMessageCompletedEvent = Schema.Struct({ · 6 unmodified lines
104 sessionId: ProviderSessionId,102 sessionId: ProviderSessionId,
105 createdAt: IsoDateTime,103 createdAt: IsoDateTime,
106 itemId: ProviderItemId,104 itemId: ProviderItemId,
107 threadId: Schema.optional(RuntimeThreadIdSchema),105 threadId: Schema.optional(ProviderThreadId),
108 turnId: Schema.optional(RuntimeTurnIdSchema),106 turnId: Schema.optional(ProviderTurnId),
109});107});
110export type ProviderRuntimeMessageCompletedEvent = typeof ProviderRuntimeMessageCompletedEvent.Type;108export type ProviderRuntimeMessageCompletedEvent = typeof ProviderRuntimeMessageCompletedEvent.Type;
111 109
@@ -115,8 +113,8 @@ export const ProviderRuntimeToolStartedEvent = Schema.Struct({ · 3 unmodified lines
115 provider: ProviderKind,113 provider: ProviderKind,
116 sessionId: ProviderSessionId,114 sessionId: ProviderSessionId,
117 createdAt: IsoDateTime,115 createdAt: IsoDateTime,
118 threadId: Schema.optional(RuntimeThreadIdSchema),116 threadId: Schema.optional(ProviderThreadId),
119 turnId: Schema.optional(RuntimeTurnIdSchema),117 turnId: Schema.optional(ProviderTurnId),
120 itemId: Schema.optional(ProviderItemId),118 itemId: Schema.optional(ProviderItemId),
121 toolKind: ProviderRuntimeToolKind,119 toolKind: ProviderRuntimeToolKind,
122 title: TrimmedNonEmptyStringSchema,120 title: TrimmedNonEmptyStringSchema,
@@ -130,8 +128,8 @@ export const ProviderRuntimeToolCompletedEvent = Schema.Struct({ · 7 unmodified lines
130 provider: ProviderKind,128 provider: ProviderKind,
131 sessionId: ProviderSessionId,129 sessionId: ProviderSessionId,
132 createdAt: IsoDateTime,130 createdAt: IsoDateTime,
133 threadId: Schema.optional(RuntimeThreadIdSchema),131 threadId: Schema.optional(ProviderThreadId),
134 turnId: Schema.optional(RuntimeTurnIdSchema),132 turnId: Schema.optional(ProviderTurnId),
135 itemId: Schema.optional(ProviderItemId),133 itemId: Schema.optional(ProviderItemId),
136 toolKind: ProviderRuntimeToolKind,134 toolKind: ProviderRuntimeToolKind,
137 title: TrimmedNonEmptyStringSchema,135 title: TrimmedNonEmptyStringSchema,
@@ -145,8 +143,8 @@ export const ProviderRuntimeApprovalRequestedEvent = Schema.Struct({ · 7 unmodified lines
145 provider: ProviderKind,143 provider: ProviderKind,
146 sessionId: ProviderSessionId,144 sessionId: ProviderSessionId,
147 createdAt: IsoDateTime,145 createdAt: IsoDateTime,
148 threadId: Schema.optional(RuntimeThreadIdSchema),146 threadId: Schema.optional(ProviderThreadId),
149 turnId: Schema.optional(RuntimeTurnIdSchema),147 turnId: Schema.optional(ProviderTurnId),
150 itemId: Schema.optional(ProviderItemId),148 itemId: Schema.optional(ProviderItemId),
151 requestId: ApprovalRequestId,149 requestId: ApprovalRequestId,
152 requestKind: ProviderRequestKind,150 requestKind: ProviderRequestKind,
@@ -161,8 +159,8 @@ export const ProviderRuntimeApprovalResolvedEvent = Schema.Struct({ · 8 unmodified lines
161 provider: ProviderKind,159 provider: ProviderKind,
162 sessionId: ProviderSessionId,160 sessionId: ProviderSessionId,
163 createdAt: IsoDateTime,161 createdAt: IsoDateTime,
164 threadId: Schema.optional(RuntimeThreadIdSchema),162 threadId: Schema.optional(ProviderThreadId),
165 turnId: Schema.optional(RuntimeTurnIdSchema),163 turnId: Schema.optional(ProviderTurnId),
166 itemId: Schema.optional(ProviderItemId),164 itemId: Schema.optional(ProviderItemId),
167 requestId: ApprovalRequestId,165 requestId: ApprovalRequestId,
168 requestKind: Schema.optional(ProviderRequestKind),166 requestKind: Schema.optional(ProviderRequestKind),
@@ -176,8 +174,8 @@ export const ProviderRuntimeCheckpointCapturedEvent = Schema.Struct({ · 7 unmodified lines
176 provider: ProviderKind,174 provider: ProviderKind,
177 sessionId: ProviderSessionId,175 sessionId: ProviderSessionId,
178 createdAt: IsoDateTime,176 createdAt: IsoDateTime,
179 threadId: RuntimeThreadIdSchema,177 threadId: ProviderThreadId,
180 turnId: Schema.optional(RuntimeTurnIdSchema),178 turnId: Schema.optional(ProviderTurnId),
181 turnCount: NonNegativeInt,179 turnCount: NonNegativeInt,
182 status: Schema.optional(ProviderRuntimeTurnStatus),180 status: Schema.optional(ProviderRuntimeTurnStatus),
183});181});
@@ -190,8 +188,8 @@ export const ProviderRuntimeErrorEvent = Schema.Struct({ · 6 unmodified lines
190 provider: ProviderKind,188 provider: ProviderKind,
191 sessionId: ProviderSessionId,189 sessionId: ProviderSessionId,
192 createdAt: IsoDateTime,190 createdAt: IsoDateTime,
193 threadId: Schema.optional(RuntimeThreadIdSchema),191 threadId: Schema.optional(ProviderThreadId),
194 turnId: Schema.optional(RuntimeTurnIdSchema),192 turnId: Schema.optional(ProviderTurnId),
195 itemId: Schema.optional(ProviderItemId),193 itemId: Schema.optional(ProviderItemId),
196 message: TrimmedNonEmptyStringSchema,194 message: TrimmedNonEmptyStringSchema,
197});195});