avantgate 1.8.0 → 1.9.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/dist/agent/telemetry/types.d.ts +8 -0
- package/dist/agent/telemetry/types.d.ts.map +1 -1
- package/dist/client/client.d.ts +4 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/index.d.ts +7 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +224 -15
- package/dist/client/index.mjs +216 -13
- package/dist/client/task-runner.d.ts +13 -0
- package/dist/client/task-runner.d.ts.map +1 -0
- package/dist/client/task-types.d.ts +45 -0
- package/dist/client/task-types.d.ts.map +1 -0
- package/dist/client/task-utils.d.ts +29 -0
- package/dist/client/task-utils.d.ts.map +1 -0
- package/dist/client/useTask.d.ts +6 -0
- package/dist/client/useTask.d.ts.map +1 -0
- package/dist/client/useTelemetry.d.ts +10 -0
- package/dist/client/useTelemetry.d.ts.map +1 -0
- package/dist/control-layer.d.ts +10 -10
- package/dist/control-layer.d.ts.map +1 -1
- package/dist/index.js +128 -93
- package/dist/index.mjs +128 -93
- package/package.json +4 -3
- package/dist/client/useAvantGateTelemetry.d.ts +0 -14
- package/dist/client/useAvantGateTelemetry.d.ts.map +0 -1
|
@@ -43,6 +43,9 @@ export interface ToolExecutionTelemetryEvent extends BaseTelemetryEvent {
|
|
|
43
43
|
success: boolean;
|
|
44
44
|
parentToolId?: string;
|
|
45
45
|
depth?: number;
|
|
46
|
+
attempts?: number;
|
|
47
|
+
maxRetries?: number;
|
|
48
|
+
retriedErrors?: string[];
|
|
46
49
|
llmSummary?: unknown;
|
|
47
50
|
piiFilteredCount?: number;
|
|
48
51
|
tokenCount?: number;
|
|
@@ -75,6 +78,11 @@ export interface TelemetryIngestPayload {
|
|
|
75
78
|
timestamp: string;
|
|
76
79
|
events: TelemetryEvent[];
|
|
77
80
|
usage?: TelemetryUsageSummary;
|
|
81
|
+
metadata?: {
|
|
82
|
+
retryOf?: string;
|
|
83
|
+
replayedBy?: string;
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
};
|
|
78
86
|
}
|
|
79
87
|
/**
|
|
80
88
|
* Configuration options for the HTTP Telemetry Exporter.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/agent/telemetry/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,YAAY,GACZ,gBAAgB,GAChB,aAAa,GACb,uBAAuB,GACvB,gBAAgB,CAAC;AAErB;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,kBAAkB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,IAAI,EAAE,YAAY,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,IAAI,EAAE,gBAAgB,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,eAAgB,SAAQ,kBAAkB;IACzD,IAAI,EAAE,aAAa,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,wBAAyB,SAAQ,kBAAkB;IAClE,IAAI,EAAE,uBAAuB,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM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IAC9B,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC"}
|
package/dist/client/client.d.ts
CHANGED
|
@@ -15,9 +15,9 @@ export interface TrackFeedbackOptions {
|
|
|
15
15
|
comment?: string;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Public interface for the universal (framework-agnostic)
|
|
18
|
+
* Public interface for the universal (framework-agnostic) telemetry client.
|
|
19
19
|
*/
|
|
20
|
-
export interface
|
|
20
|
+
export interface Client {
|
|
21
21
|
trackSecurityAlert: (alertType: ClientSecurityAlertEvent["alertType"], details: TrackSecurityAlertDetails) => void;
|
|
22
22
|
trackClientDataRendered: (toolId: string, options?: TrackDataRenderedOptions) => void;
|
|
23
23
|
trackFeedback: (feedback: TrackFeedbackOptions) => void;
|
|
@@ -30,8 +30,8 @@ export interface AvantGateClient {
|
|
|
30
30
|
exporter: BrowserTelemetryExporter;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* Creates a universal, framework-agnostic
|
|
33
|
+
* Creates a universal, framework-agnostic client instance.
|
|
34
34
|
* Works seamlessly in Vite (Vanilla JS, Vue, Svelte, SolidJS), Next.js, or browser scripts.
|
|
35
35
|
*/
|
|
36
|
-
export declare const
|
|
36
|
+
export declare const createClient: (config: BrowserTelemetryExporterConfig) => Client;
|
|
37
37
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAChC,GAAG,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,KAAK,EACV,8BAA8B,EAC9B,wBAAwB,EACzB,MAAM,SAAS,CAAC;AAEjB,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,wBAAwB;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,OAAO,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAChC,GAAG,CAAC,EAAE,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,WAAW,CAAC;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,kBAAkB,EAAE,CAClB,SAAS,EAAE,wBAAwB,CAAC,WAAW,CAAC,EAChD,OAAO,EAAE,yBAAyB,KAC/B,IAAI,CAAC;IACV,uBAAuB,EAAE,CACvB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,wBAAwB,KAC/B,IAAI,CAAC;IACV,aAAa,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACxD,aAAa,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACzE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,wBAAwB,CAAC;CACpC;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY,GACvB,QAAQ,8BAA8B,KACrC,MAkDF,CAAC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { BrowserTelemetryExporter } from "./browser-exporter";
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
2
|
+
export { createClient, type Client, type TrackDataRenderedOptions, type TrackFeedbackOptions, type TrackSecurityAlertDetails, } from "./client";
|
|
3
|
+
export { useTask } from "./useTask";
|
|
4
|
+
export { useTelemetry } from "./useTelemetry";
|
|
5
|
+
export { createTaskRunner, type TaskRunner, type TaskRunnerOptions, } from "./task-runner";
|
|
6
|
+
export { deriveOpaqueTaskId, generateRunId, createInitialTaskState, validateRetryEligibility, } from "./task-utils";
|
|
7
|
+
export type { TaskExecutionContext, TaskState, UseTaskOptions, UseTaskReturn, } from "./task-types";
|
|
8
|
+
export type { BrowserTelemetryExporterConfig, ClientDataRenderedEvent, ClientSecurityAlertEvent, ClientTelemetryEvent, ClientTelemetryIngestPayload, UserFeedbackEvent, } from "./types";
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,KAAK,MAAM,EACX,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,GAC/B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EACL,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,oBAAoB,EACpB,SAAS,EACT,cAAc,EACd,aAAa,GACd,MAAM,cAAc,CAAC;AAGtB,YAAY,EACV,8BAA8B,EAC9B,uBAAuB,EACvB,wBAAwB,EACxB,oBAAoB,EACpB,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
|
package/dist/client/index.js
CHANGED
|
@@ -21,8 +21,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var client_exports = {};
|
|
22
22
|
__export(client_exports, {
|
|
23
23
|
BrowserTelemetryExporter: () => BrowserTelemetryExporter,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
createClient: () => createClient,
|
|
25
|
+
createInitialTaskState: () => createInitialTaskState,
|
|
26
|
+
createTaskRunner: () => createTaskRunner,
|
|
27
|
+
deriveOpaqueTaskId: () => deriveOpaqueTaskId,
|
|
28
|
+
generateRunId: () => generateRunId,
|
|
29
|
+
useTask: () => useTask,
|
|
30
|
+
useTelemetry: () => useTelemetry,
|
|
31
|
+
validateRetryEligibility: () => validateRetryEligibility
|
|
26
32
|
});
|
|
27
33
|
module.exports = __toCommonJS(client_exports);
|
|
28
34
|
|
|
@@ -162,7 +168,7 @@ var BrowserTelemetryExporter = class {
|
|
|
162
168
|
};
|
|
163
169
|
|
|
164
170
|
// src/client/client.ts
|
|
165
|
-
var
|
|
171
|
+
var createClient = (config) => {
|
|
166
172
|
const exporter = new BrowserTelemetryExporter(config);
|
|
167
173
|
const trackSecurityAlert = (alertType, details) => {
|
|
168
174
|
const snippet = details.snippet ?? details.matchedPatternSnippet;
|
|
@@ -204,44 +210,241 @@ var createAvantGateClient = (config) => {
|
|
|
204
210
|
};
|
|
205
211
|
};
|
|
206
212
|
|
|
207
|
-
// src/client/
|
|
213
|
+
// src/client/useTask.ts
|
|
208
214
|
var import_react = require("react");
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
|
|
216
|
+
// src/client/task-utils.ts
|
|
217
|
+
var import_crypto = require("crypto");
|
|
218
|
+
var deriveOpaqueTaskId = (taskName, tenantSalt) => {
|
|
219
|
+
if (!tenantSalt) {
|
|
220
|
+
return taskName;
|
|
221
|
+
}
|
|
222
|
+
const digest = (0, import_crypto.createHmac)("sha256", tenantSalt).update(taskName).digest("hex").slice(0, 12);
|
|
223
|
+
return `tsk_${digest}`;
|
|
224
|
+
};
|
|
225
|
+
var generateRunId = (taskId) => {
|
|
226
|
+
const timestamp = Date.now();
|
|
227
|
+
const randomSuffix = Math.random().toString(36).slice(2, 7);
|
|
228
|
+
return `run_${taskId}_${timestamp}_${randomSuffix}`;
|
|
229
|
+
};
|
|
230
|
+
var createInitialTaskState = (taskId, tenantId) => ({
|
|
231
|
+
isRunning: false,
|
|
232
|
+
isFailed: false,
|
|
233
|
+
isSuccess: false,
|
|
234
|
+
attempts: 0,
|
|
235
|
+
error: null,
|
|
236
|
+
data: null,
|
|
237
|
+
runId: null,
|
|
238
|
+
parentRunId: null,
|
|
239
|
+
taskId,
|
|
240
|
+
tenantId: tenantId ?? null
|
|
241
|
+
});
|
|
242
|
+
var validateRetryEligibility = ({
|
|
243
|
+
isRunning,
|
|
244
|
+
attemptCount,
|
|
245
|
+
maxRetries,
|
|
246
|
+
hasPreviousInput
|
|
247
|
+
}) => {
|
|
248
|
+
if (isRunning) {
|
|
249
|
+
throw new Error("Task is already running");
|
|
250
|
+
}
|
|
251
|
+
if (attemptCount >= maxRetries) {
|
|
252
|
+
throw new Error(`Maximum manual retry limit (${maxRetries}) reached. Please reset.`);
|
|
253
|
+
}
|
|
254
|
+
if (!hasPreviousInput) {
|
|
255
|
+
throw new Error("Cannot retry: no previous execution input found");
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// src/client/task-runner.ts
|
|
260
|
+
var createTaskRunner = (initialOptions) => {
|
|
261
|
+
let options = { ...initialOptions };
|
|
262
|
+
let opaqueTaskId = deriveOpaqueTaskId(options.taskName, options.tenantSalt);
|
|
263
|
+
let state = createInitialTaskState(opaqueTaskId, options.tenantId);
|
|
264
|
+
let lastInput = null;
|
|
265
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
266
|
+
const notify = () => {
|
|
267
|
+
listeners.forEach((listener) => listener(state));
|
|
268
|
+
};
|
|
269
|
+
const setState = (updater) => {
|
|
270
|
+
state = updater(state);
|
|
271
|
+
notify();
|
|
272
|
+
};
|
|
273
|
+
const markExecutionStart = (newRunId, parentRunId) => {
|
|
274
|
+
setState((prev) => ({
|
|
275
|
+
...prev,
|
|
276
|
+
isRunning: true,
|
|
277
|
+
isFailed: false,
|
|
278
|
+
isSuccess: false,
|
|
279
|
+
error: null,
|
|
280
|
+
attempts: prev.attempts + 1,
|
|
281
|
+
runId: newRunId,
|
|
282
|
+
parentRunId: parentRunId ?? null
|
|
283
|
+
}));
|
|
284
|
+
};
|
|
285
|
+
const handleExecutionSuccess = (result) => {
|
|
286
|
+
setState((prev) => ({
|
|
287
|
+
...prev,
|
|
288
|
+
isRunning: false,
|
|
289
|
+
isSuccess: true,
|
|
290
|
+
data: result
|
|
291
|
+
}));
|
|
292
|
+
options.onSuccess?.(result);
|
|
293
|
+
};
|
|
294
|
+
const handleExecutionError = (err) => {
|
|
295
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
296
|
+
setState((prev) => ({
|
|
297
|
+
...prev,
|
|
298
|
+
isRunning: false,
|
|
299
|
+
isFailed: true,
|
|
300
|
+
error: errorObj
|
|
301
|
+
}));
|
|
302
|
+
options.onError?.(errorObj);
|
|
303
|
+
return errorObj;
|
|
304
|
+
};
|
|
305
|
+
const executeTask = async (input, parentRunId) => {
|
|
306
|
+
lastInput = input;
|
|
307
|
+
const newRunId = generateRunId(opaqueTaskId);
|
|
308
|
+
markExecutionStart(newRunId, parentRunId);
|
|
309
|
+
try {
|
|
310
|
+
const result = await options.handler(input, {
|
|
311
|
+
parentRunId,
|
|
312
|
+
attempt: state.attempts,
|
|
313
|
+
taskId: opaqueTaskId,
|
|
314
|
+
tenantId: options.tenantId
|
|
315
|
+
});
|
|
316
|
+
handleExecutionSuccess(result);
|
|
317
|
+
return result;
|
|
318
|
+
} catch (err) {
|
|
319
|
+
throw handleExecutionError(err);
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
const run = (input) => {
|
|
323
|
+
state = { ...state, attempts: 0 };
|
|
324
|
+
return executeTask(input);
|
|
325
|
+
};
|
|
326
|
+
const retry = () => {
|
|
327
|
+
validateRetryEligibility({
|
|
328
|
+
isRunning: state.isRunning,
|
|
329
|
+
attemptCount: state.attempts,
|
|
330
|
+
maxRetries: options.maxManualRetries ?? 3,
|
|
331
|
+
hasPreviousInput: lastInput !== null
|
|
332
|
+
});
|
|
333
|
+
return executeTask(lastInput, state.runId ?? void 0);
|
|
334
|
+
};
|
|
335
|
+
const reset = () => {
|
|
336
|
+
lastInput = null;
|
|
337
|
+
setState(() => createInitialTaskState(opaqueTaskId, options.tenantId));
|
|
338
|
+
};
|
|
339
|
+
const updateOptions = (newOptions) => {
|
|
340
|
+
options = { ...options, ...newOptions };
|
|
341
|
+
opaqueTaskId = deriveOpaqueTaskId(options.taskName, options.tenantSalt);
|
|
342
|
+
setState((prev) => ({
|
|
343
|
+
...prev,
|
|
344
|
+
taskId: opaqueTaskId,
|
|
345
|
+
tenantId: options.tenantId ?? null
|
|
346
|
+
}));
|
|
347
|
+
};
|
|
348
|
+
const subscribe = (listener) => {
|
|
349
|
+
listeners.add(listener);
|
|
350
|
+
return () => {
|
|
351
|
+
listeners.delete(listener);
|
|
352
|
+
};
|
|
353
|
+
};
|
|
354
|
+
const destroy = () => {
|
|
355
|
+
listeners.clear();
|
|
356
|
+
};
|
|
357
|
+
return {
|
|
358
|
+
getState: () => state,
|
|
359
|
+
subscribe,
|
|
360
|
+
run,
|
|
361
|
+
retry,
|
|
362
|
+
reset,
|
|
363
|
+
updateOptions,
|
|
364
|
+
destroy
|
|
365
|
+
};
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
// src/client/useTask.ts
|
|
369
|
+
var useTask = (options) => {
|
|
370
|
+
const runnerRef = (0, import_react.useRef)(null);
|
|
371
|
+
if (!runnerRef.current) {
|
|
372
|
+
runnerRef.current = createTaskRunner(options);
|
|
213
373
|
}
|
|
374
|
+
const [state, setState] = (0, import_react.useState)(
|
|
375
|
+
() => runnerRef.current.getState()
|
|
376
|
+
);
|
|
377
|
+
(0, import_react.useEffect)(() => {
|
|
378
|
+
runnerRef.current?.updateOptions(options);
|
|
379
|
+
});
|
|
380
|
+
(0, import_react.useEffect)(() => {
|
|
381
|
+
const runner = runnerRef.current;
|
|
382
|
+
if (!runner) return;
|
|
383
|
+
return runner.subscribe(setState);
|
|
384
|
+
}, []);
|
|
214
385
|
(0, import_react.useEffect)(() => {
|
|
386
|
+
return () => {
|
|
387
|
+
runnerRef.current?.destroy();
|
|
388
|
+
runnerRef.current = null;
|
|
389
|
+
};
|
|
390
|
+
}, []);
|
|
391
|
+
const run = (0, import_react.useCallback)(
|
|
392
|
+
(input) => runnerRef.current.run(input),
|
|
393
|
+
[]
|
|
394
|
+
);
|
|
395
|
+
const retry = (0, import_react.useCallback)(
|
|
396
|
+
() => runnerRef.current.retry(),
|
|
397
|
+
[]
|
|
398
|
+
);
|
|
399
|
+
const reset = (0, import_react.useCallback)(() => {
|
|
400
|
+
runnerRef.current.reset();
|
|
401
|
+
}, []);
|
|
402
|
+
return {
|
|
403
|
+
...state,
|
|
404
|
+
run,
|
|
405
|
+
retry,
|
|
406
|
+
reset
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
|
|
410
|
+
// src/client/useTelemetry.ts
|
|
411
|
+
var import_react2 = require("react");
|
|
412
|
+
var useTelemetry = (config) => {
|
|
413
|
+
const clientRef = (0, import_react2.useRef)(null);
|
|
414
|
+
if (!clientRef.current) {
|
|
415
|
+
clientRef.current = createClient(config);
|
|
416
|
+
}
|
|
417
|
+
(0, import_react2.useEffect)(() => {
|
|
215
418
|
clientRef.current?.updateContext({
|
|
216
419
|
runId: config.runId,
|
|
217
420
|
agentName: config.agentName
|
|
218
421
|
});
|
|
219
422
|
}, [config.runId, config.agentName]);
|
|
220
|
-
(0,
|
|
423
|
+
(0, import_react2.useEffect)(() => {
|
|
221
424
|
return () => {
|
|
222
425
|
clientRef.current?.destroy();
|
|
223
426
|
clientRef.current = null;
|
|
224
427
|
};
|
|
225
428
|
}, []);
|
|
226
|
-
const trackSecurityAlert = (0,
|
|
429
|
+
const trackSecurityAlert = (0, import_react2.useCallback)(
|
|
227
430
|
(alertType, details) => {
|
|
228
431
|
clientRef.current?.trackSecurityAlert(alertType, details);
|
|
229
432
|
},
|
|
230
433
|
[]
|
|
231
434
|
);
|
|
232
|
-
const trackClientDataRendered = (0,
|
|
435
|
+
const trackClientDataRendered = (0, import_react2.useCallback)(
|
|
233
436
|
(toolId, options) => {
|
|
234
437
|
clientRef.current?.trackClientDataRendered(toolId, options);
|
|
235
438
|
},
|
|
236
439
|
[]
|
|
237
440
|
);
|
|
238
|
-
const trackFeedback = (0,
|
|
441
|
+
const trackFeedback = (0, import_react2.useCallback)(
|
|
239
442
|
(feedback) => {
|
|
240
443
|
clientRef.current?.trackFeedback(feedback);
|
|
241
444
|
},
|
|
242
445
|
[]
|
|
243
446
|
);
|
|
244
|
-
return (0,
|
|
447
|
+
return (0, import_react2.useMemo)(
|
|
245
448
|
() => ({
|
|
246
449
|
trackSecurityAlert,
|
|
247
450
|
trackClientDataRendered,
|
|
@@ -254,6 +457,12 @@ var useAvantGateTelemetry = (config) => {
|
|
|
254
457
|
// Annotate the CommonJS export names for ESM import in node:
|
|
255
458
|
0 && (module.exports = {
|
|
256
459
|
BrowserTelemetryExporter,
|
|
257
|
-
|
|
258
|
-
|
|
460
|
+
createClient,
|
|
461
|
+
createInitialTaskState,
|
|
462
|
+
createTaskRunner,
|
|
463
|
+
deriveOpaqueTaskId,
|
|
464
|
+
generateRunId,
|
|
465
|
+
useTask,
|
|
466
|
+
useTelemetry,
|
|
467
|
+
validateRetryEligibility
|
|
259
468
|
});
|
package/dist/client/index.mjs
CHANGED
|
@@ -136,7 +136,7 @@ var BrowserTelemetryExporter = class {
|
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
// src/client/client.ts
|
|
139
|
-
var
|
|
139
|
+
var createClient = (config) => {
|
|
140
140
|
const exporter = new BrowserTelemetryExporter(config);
|
|
141
141
|
const trackSecurityAlert = (alertType, details) => {
|
|
142
142
|
const snippet = details.snippet ?? details.matchedPatternSnippet;
|
|
@@ -178,38 +178,235 @@ var createAvantGateClient = (config) => {
|
|
|
178
178
|
};
|
|
179
179
|
};
|
|
180
180
|
|
|
181
|
-
// src/client/
|
|
182
|
-
import {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
// src/client/useTask.ts
|
|
182
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
183
|
+
|
|
184
|
+
// src/client/task-utils.ts
|
|
185
|
+
import { createHmac } from "crypto";
|
|
186
|
+
var deriveOpaqueTaskId = (taskName, tenantSalt) => {
|
|
187
|
+
if (!tenantSalt) {
|
|
188
|
+
return taskName;
|
|
189
|
+
}
|
|
190
|
+
const digest = createHmac("sha256", tenantSalt).update(taskName).digest("hex").slice(0, 12);
|
|
191
|
+
return `tsk_${digest}`;
|
|
192
|
+
};
|
|
193
|
+
var generateRunId = (taskId) => {
|
|
194
|
+
const timestamp = Date.now();
|
|
195
|
+
const randomSuffix = Math.random().toString(36).slice(2, 7);
|
|
196
|
+
return `run_${taskId}_${timestamp}_${randomSuffix}`;
|
|
197
|
+
};
|
|
198
|
+
var createInitialTaskState = (taskId, tenantId) => ({
|
|
199
|
+
isRunning: false,
|
|
200
|
+
isFailed: false,
|
|
201
|
+
isSuccess: false,
|
|
202
|
+
attempts: 0,
|
|
203
|
+
error: null,
|
|
204
|
+
data: null,
|
|
205
|
+
runId: null,
|
|
206
|
+
parentRunId: null,
|
|
207
|
+
taskId,
|
|
208
|
+
tenantId: tenantId ?? null
|
|
209
|
+
});
|
|
210
|
+
var validateRetryEligibility = ({
|
|
211
|
+
isRunning,
|
|
212
|
+
attemptCount,
|
|
213
|
+
maxRetries,
|
|
214
|
+
hasPreviousInput
|
|
215
|
+
}) => {
|
|
216
|
+
if (isRunning) {
|
|
217
|
+
throw new Error("Task is already running");
|
|
218
|
+
}
|
|
219
|
+
if (attemptCount >= maxRetries) {
|
|
220
|
+
throw new Error(`Maximum manual retry limit (${maxRetries}) reached. Please reset.`);
|
|
221
|
+
}
|
|
222
|
+
if (!hasPreviousInput) {
|
|
223
|
+
throw new Error("Cannot retry: no previous execution input found");
|
|
187
224
|
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/client/task-runner.ts
|
|
228
|
+
var createTaskRunner = (initialOptions) => {
|
|
229
|
+
let options = { ...initialOptions };
|
|
230
|
+
let opaqueTaskId = deriveOpaqueTaskId(options.taskName, options.tenantSalt);
|
|
231
|
+
let state = createInitialTaskState(opaqueTaskId, options.tenantId);
|
|
232
|
+
let lastInput = null;
|
|
233
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
234
|
+
const notify = () => {
|
|
235
|
+
listeners.forEach((listener) => listener(state));
|
|
236
|
+
};
|
|
237
|
+
const setState = (updater) => {
|
|
238
|
+
state = updater(state);
|
|
239
|
+
notify();
|
|
240
|
+
};
|
|
241
|
+
const markExecutionStart = (newRunId, parentRunId) => {
|
|
242
|
+
setState((prev) => ({
|
|
243
|
+
...prev,
|
|
244
|
+
isRunning: true,
|
|
245
|
+
isFailed: false,
|
|
246
|
+
isSuccess: false,
|
|
247
|
+
error: null,
|
|
248
|
+
attempts: prev.attempts + 1,
|
|
249
|
+
runId: newRunId,
|
|
250
|
+
parentRunId: parentRunId ?? null
|
|
251
|
+
}));
|
|
252
|
+
};
|
|
253
|
+
const handleExecutionSuccess = (result) => {
|
|
254
|
+
setState((prev) => ({
|
|
255
|
+
...prev,
|
|
256
|
+
isRunning: false,
|
|
257
|
+
isSuccess: true,
|
|
258
|
+
data: result
|
|
259
|
+
}));
|
|
260
|
+
options.onSuccess?.(result);
|
|
261
|
+
};
|
|
262
|
+
const handleExecutionError = (err) => {
|
|
263
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
264
|
+
setState((prev) => ({
|
|
265
|
+
...prev,
|
|
266
|
+
isRunning: false,
|
|
267
|
+
isFailed: true,
|
|
268
|
+
error: errorObj
|
|
269
|
+
}));
|
|
270
|
+
options.onError?.(errorObj);
|
|
271
|
+
return errorObj;
|
|
272
|
+
};
|
|
273
|
+
const executeTask = async (input, parentRunId) => {
|
|
274
|
+
lastInput = input;
|
|
275
|
+
const newRunId = generateRunId(opaqueTaskId);
|
|
276
|
+
markExecutionStart(newRunId, parentRunId);
|
|
277
|
+
try {
|
|
278
|
+
const result = await options.handler(input, {
|
|
279
|
+
parentRunId,
|
|
280
|
+
attempt: state.attempts,
|
|
281
|
+
taskId: opaqueTaskId,
|
|
282
|
+
tenantId: options.tenantId
|
|
283
|
+
});
|
|
284
|
+
handleExecutionSuccess(result);
|
|
285
|
+
return result;
|
|
286
|
+
} catch (err) {
|
|
287
|
+
throw handleExecutionError(err);
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
const run = (input) => {
|
|
291
|
+
state = { ...state, attempts: 0 };
|
|
292
|
+
return executeTask(input);
|
|
293
|
+
};
|
|
294
|
+
const retry = () => {
|
|
295
|
+
validateRetryEligibility({
|
|
296
|
+
isRunning: state.isRunning,
|
|
297
|
+
attemptCount: state.attempts,
|
|
298
|
+
maxRetries: options.maxManualRetries ?? 3,
|
|
299
|
+
hasPreviousInput: lastInput !== null
|
|
300
|
+
});
|
|
301
|
+
return executeTask(lastInput, state.runId ?? void 0);
|
|
302
|
+
};
|
|
303
|
+
const reset = () => {
|
|
304
|
+
lastInput = null;
|
|
305
|
+
setState(() => createInitialTaskState(opaqueTaskId, options.tenantId));
|
|
306
|
+
};
|
|
307
|
+
const updateOptions = (newOptions) => {
|
|
308
|
+
options = { ...options, ...newOptions };
|
|
309
|
+
opaqueTaskId = deriveOpaqueTaskId(options.taskName, options.tenantSalt);
|
|
310
|
+
setState((prev) => ({
|
|
311
|
+
...prev,
|
|
312
|
+
taskId: opaqueTaskId,
|
|
313
|
+
tenantId: options.tenantId ?? null
|
|
314
|
+
}));
|
|
315
|
+
};
|
|
316
|
+
const subscribe = (listener) => {
|
|
317
|
+
listeners.add(listener);
|
|
318
|
+
return () => {
|
|
319
|
+
listeners.delete(listener);
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
const destroy = () => {
|
|
323
|
+
listeners.clear();
|
|
324
|
+
};
|
|
325
|
+
return {
|
|
326
|
+
getState: () => state,
|
|
327
|
+
subscribe,
|
|
328
|
+
run,
|
|
329
|
+
retry,
|
|
330
|
+
reset,
|
|
331
|
+
updateOptions,
|
|
332
|
+
destroy
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// src/client/useTask.ts
|
|
337
|
+
var useTask = (options) => {
|
|
338
|
+
const runnerRef = useRef(null);
|
|
339
|
+
if (!runnerRef.current) {
|
|
340
|
+
runnerRef.current = createTaskRunner(options);
|
|
341
|
+
}
|
|
342
|
+
const [state, setState] = useState(
|
|
343
|
+
() => runnerRef.current.getState()
|
|
344
|
+
);
|
|
188
345
|
useEffect(() => {
|
|
346
|
+
runnerRef.current?.updateOptions(options);
|
|
347
|
+
});
|
|
348
|
+
useEffect(() => {
|
|
349
|
+
const runner = runnerRef.current;
|
|
350
|
+
if (!runner) return;
|
|
351
|
+
return runner.subscribe(setState);
|
|
352
|
+
}, []);
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
return () => {
|
|
355
|
+
runnerRef.current?.destroy();
|
|
356
|
+
runnerRef.current = null;
|
|
357
|
+
};
|
|
358
|
+
}, []);
|
|
359
|
+
const run = useCallback(
|
|
360
|
+
(input) => runnerRef.current.run(input),
|
|
361
|
+
[]
|
|
362
|
+
);
|
|
363
|
+
const retry = useCallback(
|
|
364
|
+
() => runnerRef.current.retry(),
|
|
365
|
+
[]
|
|
366
|
+
);
|
|
367
|
+
const reset = useCallback(() => {
|
|
368
|
+
runnerRef.current.reset();
|
|
369
|
+
}, []);
|
|
370
|
+
return {
|
|
371
|
+
...state,
|
|
372
|
+
run,
|
|
373
|
+
retry,
|
|
374
|
+
reset
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
// src/client/useTelemetry.ts
|
|
379
|
+
import { useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef as useRef2 } from "react";
|
|
380
|
+
var useTelemetry = (config) => {
|
|
381
|
+
const clientRef = useRef2(null);
|
|
382
|
+
if (!clientRef.current) {
|
|
383
|
+
clientRef.current = createClient(config);
|
|
384
|
+
}
|
|
385
|
+
useEffect2(() => {
|
|
189
386
|
clientRef.current?.updateContext({
|
|
190
387
|
runId: config.runId,
|
|
191
388
|
agentName: config.agentName
|
|
192
389
|
});
|
|
193
390
|
}, [config.runId, config.agentName]);
|
|
194
|
-
|
|
391
|
+
useEffect2(() => {
|
|
195
392
|
return () => {
|
|
196
393
|
clientRef.current?.destroy();
|
|
197
394
|
clientRef.current = null;
|
|
198
395
|
};
|
|
199
396
|
}, []);
|
|
200
|
-
const trackSecurityAlert =
|
|
397
|
+
const trackSecurityAlert = useCallback2(
|
|
201
398
|
(alertType, details) => {
|
|
202
399
|
clientRef.current?.trackSecurityAlert(alertType, details);
|
|
203
400
|
},
|
|
204
401
|
[]
|
|
205
402
|
);
|
|
206
|
-
const trackClientDataRendered =
|
|
403
|
+
const trackClientDataRendered = useCallback2(
|
|
207
404
|
(toolId, options) => {
|
|
208
405
|
clientRef.current?.trackClientDataRendered(toolId, options);
|
|
209
406
|
},
|
|
210
407
|
[]
|
|
211
408
|
);
|
|
212
|
-
const trackFeedback =
|
|
409
|
+
const trackFeedback = useCallback2(
|
|
213
410
|
(feedback) => {
|
|
214
411
|
clientRef.current?.trackFeedback(feedback);
|
|
215
412
|
},
|
|
@@ -227,6 +424,12 @@ var useAvantGateTelemetry = (config) => {
|
|
|
227
424
|
};
|
|
228
425
|
export {
|
|
229
426
|
BrowserTelemetryExporter,
|
|
230
|
-
|
|
231
|
-
|
|
427
|
+
createClient,
|
|
428
|
+
createInitialTaskState,
|
|
429
|
+
createTaskRunner,
|
|
430
|
+
deriveOpaqueTaskId,
|
|
431
|
+
generateRunId,
|
|
432
|
+
useTask,
|
|
433
|
+
useTelemetry,
|
|
434
|
+
validateRetryEligibility
|
|
232
435
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TaskState, UseTaskOptions } from "./task-types";
|
|
2
|
+
export type TaskRunnerOptions<TInput, TOutput> = UseTaskOptions<TInput, TOutput>;
|
|
3
|
+
export interface TaskRunner<TInput, TOutput> {
|
|
4
|
+
getState: () => TaskState<TOutput>;
|
|
5
|
+
subscribe: (listener: (state: TaskState<TOutput>) => void) => () => void;
|
|
6
|
+
run: (input: TInput) => Promise<TOutput>;
|
|
7
|
+
retry: () => Promise<TOutput>;
|
|
8
|
+
reset: () => void;
|
|
9
|
+
updateOptions: (newOptions: Partial<UseTaskOptions<TInput, TOutput>>) => void;
|
|
10
|
+
destroy: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare const createTaskRunner: <TInput, TOutput>(initialOptions: UseTaskOptions<TInput, TOutput>) => TaskRunner<TInput, TOutput>;
|
|
13
|
+
//# sourceMappingURL=task-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-runner.d.ts","sourceRoot":"","sources":["../../src/client/task-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQzD,MAAM,MAAM,iBAAiB,CAAC,MAAM,EAAE,OAAO,IAAI,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjF,MAAM,WAAW,UAAU,CAAC,MAAM,EAAE,OAAO;IACzC,QAAQ,EAAE,MAAM,SAAS,CAAC,OAAO,CAAC,CAAC;IACnC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACzE,GAAG,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACzC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,aAAa,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KAAK,IAAI,CAAC;IAC9E,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,GAAI,MAAM,EAAE,OAAO,EAC9C,gBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9C,UAAU,CAAC,MAAM,EAAE,OAAO,CAgI5B,CAAC"}
|