@fluidframework/ai-collab 2.22.1 → 2.23.0
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/CHANGELOG.md +4 -0
- package/README.md +70 -4
- package/api-report/ai-collab.alpha.api.md +170 -2
- package/dist/aiCollab.d.ts +0 -1
- package/dist/aiCollab.d.ts.map +1 -1
- package/dist/aiCollab.js +1 -2
- package/dist/aiCollab.js.map +1 -1
- package/dist/aiCollabApi.d.ts +50 -3
- package/dist/aiCollabApi.d.ts.map +1 -1
- package/dist/aiCollabApi.js.map +1 -1
- package/dist/alpha.d.ts +17 -0
- package/dist/explicit-strategy/debugEvents.d.ts +248 -0
- package/dist/explicit-strategy/debugEvents.d.ts.map +1 -0
- package/dist/explicit-strategy/debugEvents.js +36 -0
- package/dist/explicit-strategy/debugEvents.js.map +1 -0
- package/dist/explicit-strategy/index.d.ts +4 -4
- package/dist/explicit-strategy/index.d.ts.map +1 -1
- package/dist/explicit-strategy/index.js +176 -54
- package/dist/explicit-strategy/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/lib/aiCollab.d.ts +0 -1
- package/lib/aiCollab.d.ts.map +1 -1
- package/lib/aiCollab.js +1 -2
- package/lib/aiCollab.js.map +1 -1
- package/lib/aiCollabApi.d.ts +50 -3
- package/lib/aiCollabApi.d.ts.map +1 -1
- package/lib/aiCollabApi.js.map +1 -1
- package/lib/alpha.d.ts +17 -0
- package/lib/explicit-strategy/debugEvents.d.ts +248 -0
- package/lib/explicit-strategy/debugEvents.d.ts.map +1 -0
- package/lib/explicit-strategy/debugEvents.js +32 -0
- package/lib/explicit-strategy/debugEvents.js.map +1 -0
- package/lib/explicit-strategy/index.d.ts +4 -4
- package/lib/explicit-strategy/index.d.ts.map +1 -1
- package/lib/explicit-strategy/index.js +174 -52
- package/lib/explicit-strategy/index.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/package.json +13 -11
- package/src/aiCollab.ts +1 -2
- package/src/aiCollabApi.ts +54 -3
- package/src/explicit-strategy/debugEvents.ts +297 -0
- package/src/explicit-strategy/index.ts +269 -59
- package/src/index.ts +20 -0
package/src/aiCollabApi.ts
CHANGED
|
@@ -7,6 +7,55 @@ import type { TreeNode } from "@fluidframework/tree";
|
|
|
7
7
|
// eslint-disable-next-line import/no-named-as-default
|
|
8
8
|
import type OpenAI from "openai";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Core Debug event type for the ai-collab
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
export interface DebugEvent {
|
|
15
|
+
/**
|
|
16
|
+
* The unique id of the debug event.
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* An id that will be shared across all debug events that originate from the same single execution of ai-collab.
|
|
21
|
+
* @remarks This is intended to be used to correlate all debug events that originate from the same execution
|
|
22
|
+
*/
|
|
23
|
+
traceId: string;
|
|
24
|
+
/**
|
|
25
|
+
* The name of the debug event.
|
|
26
|
+
*/
|
|
27
|
+
eventName: string;
|
|
28
|
+
/**
|
|
29
|
+
* The date and time at which the debug event was created.
|
|
30
|
+
*/
|
|
31
|
+
timestamp: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A Debug event that marks the start or end of a single core logic flow, such as generated tree edits, planning prompt, etc.
|
|
36
|
+
* @alpha
|
|
37
|
+
*/
|
|
38
|
+
export interface EventFlowDebugEvent extends DebugEvent {
|
|
39
|
+
/**
|
|
40
|
+
* The name of the particular event flow.
|
|
41
|
+
*/
|
|
42
|
+
eventFlowName: string;
|
|
43
|
+
/**
|
|
44
|
+
* The status of the particular event flow.
|
|
45
|
+
*/
|
|
46
|
+
eventFlowStatus: "STARTED" | "COMPLETED" | "IN_PROGRESS";
|
|
47
|
+
/**
|
|
48
|
+
* A unique id that will be shared across all debug events that are part of the same event flow.
|
|
49
|
+
*/
|
|
50
|
+
eventFlowTraceId: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A callback function that can be used to handle debug events that occur during the AI collaboration process.
|
|
55
|
+
* @alpha
|
|
56
|
+
*/
|
|
57
|
+
export type DebugEventLogHandler = <T extends DebugEvent>(event: T) => unknown;
|
|
58
|
+
|
|
10
59
|
/**
|
|
11
60
|
* OpenAI client options for the {@link AiCollabOptions} interface.
|
|
12
61
|
*
|
|
@@ -99,9 +148,9 @@ export interface AiCollabOptions {
|
|
|
99
148
|
*/
|
|
100
149
|
readonly validator?: (newContent: TreeNode) => void;
|
|
101
150
|
/**
|
|
102
|
-
*
|
|
151
|
+
* An optional handler for debug events that occur during the AI collaboration.
|
|
103
152
|
*/
|
|
104
|
-
readonly
|
|
153
|
+
readonly debugEventLogHandler?: DebugEventLogHandler;
|
|
105
154
|
}
|
|
106
155
|
|
|
107
156
|
/**
|
|
@@ -139,12 +188,14 @@ export interface AiCollabErrorResponse {
|
|
|
139
188
|
* - 'tooManyErrors' indicates that the LLM made too many errors in a row
|
|
140
189
|
* - 'tooManyModelCalls' indicates that the LLM made too many model calls
|
|
141
190
|
* - 'aborted' indicates that the AI collaboration was aborted by the user or a limiter
|
|
191
|
+
* - 'unexpectedError' indicates that an unexpected error occured
|
|
142
192
|
*/
|
|
143
193
|
readonly errorMessage:
|
|
144
194
|
| "tokenLimitExceeded"
|
|
145
195
|
| "tooManyErrors"
|
|
146
196
|
| "tooManyModelCalls"
|
|
147
|
-
| "aborted"
|
|
197
|
+
| "aborted"
|
|
198
|
+
| "unexpectedError";
|
|
148
199
|
/**
|
|
149
200
|
* {@inheritDoc TokenUsage}
|
|
150
201
|
*/
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { v4 as uuidv4 } from "uuid";
|
|
7
|
+
|
|
8
|
+
import type { DebugEvent, EventFlowDebugEvent } from "../aiCollabApi.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This file contains the types for the debug events that are emitted by the explicit strategy
|
|
12
|
+
* as well as a helper functions to help create a consistent method for producing a base {@link DebugEvent}.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The possible values for the `eventFlowName` field in an {@link EventFlowDebugEvent}.
|
|
17
|
+
* @alpha
|
|
18
|
+
*/
|
|
19
|
+
export const EventFlowDebugNames = {
|
|
20
|
+
CORE_EVENT_LOOP: "CORE_EVENT_LOOP",
|
|
21
|
+
GENERATE_PLANNING_PROMPT: "GENERATE_PLANNING_PROMPT",
|
|
22
|
+
GENERATE_AND_APPLY_TREE_EDIT: "GENERATE_AND_APPLY_TREE_EDIT",
|
|
23
|
+
FINAL_REVIEW: "FINAL_REVIEW",
|
|
24
|
+
} as const;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The type for possible values for the `eventFlowName` field in an {@link EventFlowDebugEvent}.
|
|
28
|
+
* @alpha
|
|
29
|
+
*/
|
|
30
|
+
export type EventFlowDebugName =
|
|
31
|
+
(typeof EventFlowDebugNames)[keyof typeof EventFlowDebugNames];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* An edit generated by an LLM that can be applied to a given SharedTree.
|
|
35
|
+
* @privateremarks TODO: We need a better solution here because don't want to expose the internal TreeEdit type here, but we need to be able to type it.
|
|
36
|
+
* @alpha
|
|
37
|
+
*/
|
|
38
|
+
export type LlmTreeEdit = Record<string, unknown>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* An {@link EventFlowDebugEvent} for signaling the start of the ai-collab's core event loop.
|
|
42
|
+
* Which makes various calls to the LLM to eventually apply edits to the users SharedTree which
|
|
43
|
+
* accomplish the user's provided goal. There will be exactly 1 of these events per ai-collab function execution.
|
|
44
|
+
* @alpha
|
|
45
|
+
*/
|
|
46
|
+
export interface CoreEventLoopStarted extends EventFlowDebugEvent {
|
|
47
|
+
eventName: "CORE_EVENT_LOOP_STARTED";
|
|
48
|
+
eventFlowName: typeof EventFlowDebugNames.CORE_EVENT_LOOP;
|
|
49
|
+
eventFlowStatus: "STARTED";
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* An {@link EventFlowDebugEvent} for signaling the end of the ai-collab's core event loop.
|
|
54
|
+
* There could be various reasons for the event loop to end, early exits and failures
|
|
55
|
+
* which should be captured in the status and failureReason fields. There will be exactly 1
|
|
56
|
+
* of these events per ai-collab function execution.
|
|
57
|
+
* @alpha
|
|
58
|
+
*/
|
|
59
|
+
export interface CoreEventLoopCompleted extends EventFlowDebugEvent {
|
|
60
|
+
eventName: "CORE_EVENT_LOOP_COMPLETED";
|
|
61
|
+
eventFlowName: typeof EventFlowDebugNames.CORE_EVENT_LOOP;
|
|
62
|
+
eventFlowStatus: "COMPLETED";
|
|
63
|
+
status: "success" | "failure";
|
|
64
|
+
failureReason?: string;
|
|
65
|
+
errorMessage?: string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// #region Planning Prompt Debug events -------------------------------
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* An {@link EventFlowDebugEvent} marking the initiation of the flow for prompting an LLM to generate a plan for accomplishing the user's goal.
|
|
72
|
+
* There will be exactly 1 of these events per ai-collab function execution.
|
|
73
|
+
* @alpha
|
|
74
|
+
*/
|
|
75
|
+
export interface PlanningPromptStarted extends EventFlowDebugEvent {
|
|
76
|
+
eventName: "GENERATE_PLANNING_PROMPT_STARTED";
|
|
77
|
+
eventFlowName: typeof EventFlowDebugNames.GENERATE_PLANNING_PROMPT;
|
|
78
|
+
eventFlowStatus: "STARTED";
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* An {@link EventFlowDebugEvent} marking the completion of the flow for prompting an LLM to generate a plan for accomplishing the user's goal.
|
|
83
|
+
* There will be exactly 1 of these events per ai-collab function execution.
|
|
84
|
+
* @alpha
|
|
85
|
+
*/
|
|
86
|
+
export interface PlanningPromptCompleted<
|
|
87
|
+
TIsLlmResponseValid = boolean,
|
|
88
|
+
TPlan = TIsLlmResponseValid extends true ? string : undefined,
|
|
89
|
+
> extends EventFlowDebugEvent {
|
|
90
|
+
eventName: "GENERATE_PLANNING_PROMPT_COMPLETED";
|
|
91
|
+
eventFlowName: typeof EventFlowDebugNames.GENERATE_PLANNING_PROMPT;
|
|
92
|
+
eventFlowStatus: "COMPLETED";
|
|
93
|
+
/**
|
|
94
|
+
* Whether the response produced by the LLM is an expected response.
|
|
95
|
+
* In the event that the LLM fails to respond in an expected way, despite the API call to the LLM itself being successful, then this fields value will be `false`.
|
|
96
|
+
*
|
|
97
|
+
* For now, this case is limited to the LLM returning undefined as a response when it should have returned something. But in the future this could expand
|
|
98
|
+
* to things such as invalid json.
|
|
99
|
+
*/
|
|
100
|
+
isLlmResponseValid: TIsLlmResponseValid;
|
|
101
|
+
/**
|
|
102
|
+
* The plan generated by the LLM. If the `wasLlmResponseValid` field is `false` then this will be undefined, otherwise it will be a string.
|
|
103
|
+
*/
|
|
104
|
+
llmGeneratedPlan: TPlan;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// #endregion Planning Prompt Debug events ----------------------------------------------------------
|
|
108
|
+
|
|
109
|
+
// #region Generate And Apply Tree Edit Debug events ------------------
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* An {@link EventFlowDebugEvent} marking the initiation of the flow for prompting an LLM to
|
|
113
|
+
* generate an {@link LlmTreeEdit} to the users Shared Tree based on the users initial ask.
|
|
114
|
+
* It is expected that the LLM will generate multiple of these events when it must generate multiple tree edits to satisfy the user request
|
|
115
|
+
* @alpha
|
|
116
|
+
*/
|
|
117
|
+
export interface GenerateTreeEditStarted extends EventFlowDebugEvent {
|
|
118
|
+
eventName: "GENERATE_TREE_EDIT_STARTED";
|
|
119
|
+
eventFlowName: typeof EventFlowDebugNames.GENERATE_AND_APPLY_TREE_EDIT;
|
|
120
|
+
eventFlowStatus: "STARTED";
|
|
121
|
+
llmPrompt: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* An {@link EventFlowDebugEvent} marking the completion of the flow for prompting an LLM to
|
|
126
|
+
* generate an {@link LlmTreeEdit} to the users Shared Tree based on the users initial ask.
|
|
127
|
+
* It is expected that the LLM will generate multiple of these events when it must generate multiple tree edits to satisfy the user request
|
|
128
|
+
* @alpha
|
|
129
|
+
*/
|
|
130
|
+
export interface GenerateTreeEditCompleted<
|
|
131
|
+
TIsLlmResponseValid = boolean,
|
|
132
|
+
TEdit = TIsLlmResponseValid extends true ? LlmTreeEdit | null : undefined,
|
|
133
|
+
> extends EventFlowDebugEvent {
|
|
134
|
+
eventName: "GENERATE_TREE_EDIT_COMPLETED";
|
|
135
|
+
eventFlowName: typeof EventFlowDebugNames.GENERATE_AND_APPLY_TREE_EDIT;
|
|
136
|
+
eventFlowStatus: "COMPLETED";
|
|
137
|
+
/**
|
|
138
|
+
* Whether the response produced by the LLM is an expected response.
|
|
139
|
+
* In the event that the LLM fails to respond in an expected way, despite the API call to the LLM itself being successful, then this fields value will be `false`.
|
|
140
|
+
*
|
|
141
|
+
* For now, this case is limited to the LLM returning undefined as a response when it should have returned something. But in the future this could expand
|
|
142
|
+
* to things such as invalid json.
|
|
143
|
+
*/
|
|
144
|
+
isLlmResponseValid: TIsLlmResponseValid;
|
|
145
|
+
/**
|
|
146
|
+
* If the `isLlmResponseValid` field value is `true` then this be one of two following values returned by the LLM:
|
|
147
|
+
* 1. An edit that can be applied to a SharedTree to further accomplish the user's goal.
|
|
148
|
+
* 2. `null` if the LLM decides no more edits are necessary.
|
|
149
|
+
*
|
|
150
|
+
* If the `isLlmResponseValid` field is `false` then this field will be `undefined`.
|
|
151
|
+
*/
|
|
152
|
+
llmGeneratedEdit: TEdit;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* An {@link EventFlowDebugEvent} marking the successful application of an edit generated by the LLM to a SharedTree.
|
|
157
|
+
* @alpha
|
|
158
|
+
*/
|
|
159
|
+
export interface ApplyEditSuccess extends EventFlowDebugEvent {
|
|
160
|
+
eventName: "APPLIED_EDIT_SUCCESS";
|
|
161
|
+
eventFlowName: typeof EventFlowDebugNames.GENERATE_AND_APPLY_TREE_EDIT;
|
|
162
|
+
eventFlowStatus: "IN_PROGRESS";
|
|
163
|
+
/**
|
|
164
|
+
* A unique id that will be shared across all debug events that are part of the same event flow.
|
|
165
|
+
*/
|
|
166
|
+
eventFlowTraceId: string;
|
|
167
|
+
/**
|
|
168
|
+
* The {@link LlmTreeEdit} generated by the LLM.
|
|
169
|
+
*/
|
|
170
|
+
edit: LlmTreeEdit;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* An {@link EventFlowDebugEvent} marking the failure of applying an edit generated by the LLM to a SharedTree.
|
|
175
|
+
* @alpha
|
|
176
|
+
*/
|
|
177
|
+
export interface ApplyEditFailure extends EventFlowDebugEvent {
|
|
178
|
+
eventName: "APPLIED_EDIT_FAILURE";
|
|
179
|
+
eventFlowName: typeof EventFlowDebugNames.GENERATE_AND_APPLY_TREE_EDIT;
|
|
180
|
+
eventFlowStatus: "IN_PROGRESS";
|
|
181
|
+
/**
|
|
182
|
+
* A unique id that will be shared across all debug events that are part of the same event flow.
|
|
183
|
+
*/
|
|
184
|
+
eventFlowTraceId: string;
|
|
185
|
+
/**
|
|
186
|
+
* The {@link LlmTreeEdit} generated by the LLM.
|
|
187
|
+
*/
|
|
188
|
+
edit: LlmTreeEdit;
|
|
189
|
+
/**
|
|
190
|
+
* The error message that was thrown when attempting to apply the edit.
|
|
191
|
+
*/
|
|
192
|
+
errorMessage: string;
|
|
193
|
+
/**
|
|
194
|
+
* The total number of errors that have occurred up until this point, not including this error.
|
|
195
|
+
*/
|
|
196
|
+
sequentialErrorCount: number;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// #endregion Generate And Apply Tree Edit Debug events ----------------------
|
|
200
|
+
|
|
201
|
+
// #region Generate Final Review Debug events -------------------------
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* An {@link EventFlowDebugEvent} marking the initiation of the flow for prompting an LLM to complete a final review of its edits
|
|
205
|
+
* and determine whether the user's goal was accomplished.
|
|
206
|
+
* @alpha
|
|
207
|
+
*/
|
|
208
|
+
export interface FinalReviewStarted extends EventFlowDebugEvent {
|
|
209
|
+
eventName: "FINAL_REVIEW_STARTED";
|
|
210
|
+
eventFlowName: typeof EventFlowDebugNames.FINAL_REVIEW;
|
|
211
|
+
eventFlowStatus: "STARTED";
|
|
212
|
+
/**
|
|
213
|
+
* The prompt sent to the LLM to complete its final review of the edits its made.
|
|
214
|
+
*/
|
|
215
|
+
llmPrompt: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* An {@link EventFlowDebugEvent} marking the end of the flow for prompting an LLM to complete a final review of its edits
|
|
220
|
+
* and determine whether the user's goal was accomplished.
|
|
221
|
+
* @alpha
|
|
222
|
+
*/
|
|
223
|
+
export interface FinalReviewCompleted<
|
|
224
|
+
TIsLlmResponseValid = boolean,
|
|
225
|
+
TReviewResponse = TIsLlmResponseValid extends true ? "yes" | "no" : undefined,
|
|
226
|
+
> extends EventFlowDebugEvent {
|
|
227
|
+
eventName: "FINAL_REVIEW_COMPLETED";
|
|
228
|
+
eventFlowName: typeof EventFlowDebugNames.FINAL_REVIEW;
|
|
229
|
+
eventFlowStatus: "COMPLETED";
|
|
230
|
+
/**
|
|
231
|
+
* Whether the response produced by the LLM is an expected response.
|
|
232
|
+
* In the event that the LLM fails to respond in an expected way, despite the API call to the LLM itself being successful, then this fields value will be `false`.
|
|
233
|
+
*
|
|
234
|
+
* For now, this case is limited to the LLM returning undefined as a response when it should have returned something. But in the future this could expand
|
|
235
|
+
* to things such as invalid json.
|
|
236
|
+
*/
|
|
237
|
+
isLlmResponseValid: TIsLlmResponseValid;
|
|
238
|
+
/**
|
|
239
|
+
* Whether the Llm believes the user's ask was accomplished, based on the Edits is has already generated and applied.
|
|
240
|
+
* If the `status` field is `false` then this field value will be `undefined`, otherwise it will be either "yes" or "no"
|
|
241
|
+
*/
|
|
242
|
+
didLlmAccomplishGoal: TReviewResponse;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// #endregion Generate Final Review Debug events ----------------------
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* An {@link DebugEvent} for an API call directly to a LLM.
|
|
249
|
+
* @alpha
|
|
250
|
+
*/
|
|
251
|
+
export interface LlmApiCallDebugEvent extends DebugEvent {
|
|
252
|
+
eventName: "LLM_API_CALL";
|
|
253
|
+
/**
|
|
254
|
+
* The event flow name that made this LLM API call.
|
|
255
|
+
*/
|
|
256
|
+
triggeringEventFlowName: EventFlowDebugName;
|
|
257
|
+
/**
|
|
258
|
+
* The unique id that will be shared across all debug events that are part of the same event flow.
|
|
259
|
+
* @remarks This can be used to correlate all debug events that are part of the same event flow.
|
|
260
|
+
*/
|
|
261
|
+
eventFlowTraceId: string;
|
|
262
|
+
/**
|
|
263
|
+
* The LLM model name that was used for the API call.
|
|
264
|
+
*/
|
|
265
|
+
modelName: string;
|
|
266
|
+
/**
|
|
267
|
+
* The request parameters sent in the API call to the LLM. (Not the HTTP request parameters such as headers, etc.)
|
|
268
|
+
*/
|
|
269
|
+
requestParams: unknown;
|
|
270
|
+
/**
|
|
271
|
+
* The raw response from the LLM.
|
|
272
|
+
*/
|
|
273
|
+
response: unknown;
|
|
274
|
+
/**
|
|
275
|
+
* The total number of tokens used in the API call to the LLM.
|
|
276
|
+
*/
|
|
277
|
+
tokenUsage?: {
|
|
278
|
+
promptTokens: number;
|
|
279
|
+
completionTokens: number;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Creates a base {@link DebugEvent}.
|
|
285
|
+
*/
|
|
286
|
+
export function generateDebugEvent<Tevent extends string>(
|
|
287
|
+
eventName: Tevent,
|
|
288
|
+
traceId: string,
|
|
289
|
+
): DebugEvent & { eventName: Tevent } {
|
|
290
|
+
const event = {
|
|
291
|
+
eventName,
|
|
292
|
+
id: uuidv4(),
|
|
293
|
+
traceId,
|
|
294
|
+
timestamp: new Date().toISOString(),
|
|
295
|
+
};
|
|
296
|
+
return event;
|
|
297
|
+
}
|