elasticdash-test 0.1.18-alpha-14 → 0.1.18-alpha-15
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.
|
@@ -13,9 +13,9 @@ import 'dotenv/config';
|
|
|
13
13
|
* stdin — one JSON line: { toolsModulePath, toolName, args, frozenEvents? }
|
|
14
14
|
* stdout — prefixed result line: __ELASTICDASH_RESULT__:{...json...}
|
|
15
15
|
*
|
|
16
|
-
* When frozenEvents are provided, sets up an HttpRunContext so that
|
|
17
|
-
*
|
|
18
|
-
* will replay from frozen data instead of hitting real services.
|
|
16
|
+
* When frozenEvents are provided, sets up an HttpRunContext so that all
|
|
17
|
+
* freezable actions within the tool (wrapAI, wrapDB, and fetch-intercepted
|
|
18
|
+
* HTTP calls) will replay from frozen data instead of hitting real services.
|
|
19
19
|
*/
|
|
20
20
|
import { pathToFileURL } from 'node:url';
|
|
21
21
|
const RESULT_PREFIX = '__ELASTICDASH_RESULT__:';
|
|
@@ -27,14 +27,13 @@ function writeResult(result) {
|
|
|
27
27
|
/**
|
|
28
28
|
* Set up frozen event replay context.
|
|
29
29
|
*
|
|
30
|
-
* For HTTP events: uses **URL-based matching** via a fetch wrapper
|
|
31
|
-
*
|
|
32
|
-
* reruns because wrapTool/wrapAI also consume nextId() IDs, causing the
|
|
33
|
-
* sequential counter to drift away from the frozen event IDs.
|
|
30
|
+
* For HTTP events: uses **URL-based matching** via a fetch wrapper, which is
|
|
31
|
+
* robust against ID counter drift.
|
|
34
32
|
*
|
|
35
|
-
* For DB events: uses the HttpRunContext frozen map
|
|
36
|
-
*
|
|
37
|
-
*
|
|
33
|
+
* For AI and DB events: uses the HttpRunContext frozen map with sequential
|
|
34
|
+
* ID-based matching. All freezable event types (AI + DB) are included in the
|
|
35
|
+
* map and re-indexed in original execution order, so the shared nextId()
|
|
36
|
+
* counter stays aligned across interleaved wrapAI and wrapDB calls.
|
|
38
37
|
*/
|
|
39
38
|
async function setupFrozenContext(frozenEvents) {
|
|
40
39
|
if (frozenEvents.length === 0)
|
|
@@ -42,12 +41,17 @@ async function setupFrozenContext(frozenEvents) {
|
|
|
42
41
|
// Always install URL-based fetch replay for HTTP events — this is the
|
|
43
42
|
// reliable matching strategy for tool reruns in subprocesses.
|
|
44
43
|
installFrozenFetchFallback(frozenEvents);
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
// Set up HttpRunContext for all freezable event types (AI + DB).
|
|
45
|
+
// Both wrapAI and wrapDB call httpCtx.nextId() sequentially, so we must
|
|
46
|
+
// include all freezable types in the frozen map, re-indexed in original
|
|
47
|
+
// execution order, to keep the sequential counter aligned.
|
|
48
|
+
const freezableEvents = frozenEvents
|
|
49
|
+
.filter(e => e.type === 'ai' || e.type === 'db')
|
|
50
|
+
.sort((a, b) => a.id - b.id); // preserve original execution order
|
|
51
|
+
if (freezableEvents.length > 0) {
|
|
48
52
|
try {
|
|
49
53
|
const telemetryPush = await import('./interceptors/telemetry-push.js');
|
|
50
|
-
const workflowEvents =
|
|
54
|
+
const workflowEvents = freezableEvents.map((e, i) => ({
|
|
51
55
|
id: i + 1,
|
|
52
56
|
type: e.type,
|
|
53
57
|
name: e.name,
|
|
@@ -67,7 +71,7 @@ async function setupFrozenContext(frozenEvents) {
|
|
|
67
71
|
}
|
|
68
72
|
}
|
|
69
73
|
catch {
|
|
70
|
-
//
|
|
74
|
+
// Frozen replay not available — tool will hit real services
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-runner-worker.js","sourceRoot":"","sources":["../src/tool-runner-worker.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,CAAC;AAAC,UAAkB,CAAC,sBAAsB,GAAG,IAAI,CAAA;AAElD,iDAAiD;AACjD,OAAO,eAAe,CAAA;AAEtB;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEx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AAC,CAAC,CAAC,CAAA;IACjB,CAAC;YAAS,CAAC;QACT,IAAI,SAAS;YAAE,kBAAkB,EAAE,CAAA;IACrC,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -14,9 +14,9 @@ import 'dotenv/config'
|
|
|
14
14
|
* stdin — one JSON line: { toolsModulePath, toolName, args, frozenEvents? }
|
|
15
15
|
* stdout — prefixed result line: __ELASTICDASH_RESULT__:{...json...}
|
|
16
16
|
*
|
|
17
|
-
* When frozenEvents are provided, sets up an HttpRunContext so that
|
|
18
|
-
*
|
|
19
|
-
* will replay from frozen data instead of hitting real services.
|
|
17
|
+
* When frozenEvents are provided, sets up an HttpRunContext so that all
|
|
18
|
+
* freezable actions within the tool (wrapAI, wrapDB, and fetch-intercepted
|
|
19
|
+
* HTTP calls) will replay from frozen data instead of hitting real services.
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import { pathToFileURL } from 'node:url'
|
|
@@ -46,14 +46,13 @@ interface FrozenEvent {
|
|
|
46
46
|
/**
|
|
47
47
|
* Set up frozen event replay context.
|
|
48
48
|
*
|
|
49
|
-
* For HTTP events: uses **URL-based matching** via a fetch wrapper
|
|
50
|
-
*
|
|
51
|
-
* reruns because wrapTool/wrapAI also consume nextId() IDs, causing the
|
|
52
|
-
* sequential counter to drift away from the frozen event IDs.
|
|
49
|
+
* For HTTP events: uses **URL-based matching** via a fetch wrapper, which is
|
|
50
|
+
* robust against ID counter drift.
|
|
53
51
|
*
|
|
54
|
-
* For DB events: uses the HttpRunContext frozen map
|
|
55
|
-
*
|
|
56
|
-
*
|
|
52
|
+
* For AI and DB events: uses the HttpRunContext frozen map with sequential
|
|
53
|
+
* ID-based matching. All freezable event types (AI + DB) are included in the
|
|
54
|
+
* map and re-indexed in original execution order, so the shared nextId()
|
|
55
|
+
* counter stays aligned across interleaved wrapAI and wrapDB calls.
|
|
57
56
|
*/
|
|
58
57
|
async function setupFrozenContext(frozenEvents: FrozenEvent[]): Promise<void> {
|
|
59
58
|
if (frozenEvents.length === 0) return
|
|
@@ -62,14 +61,19 @@ async function setupFrozenContext(frozenEvents: FrozenEvent[]): Promise<void> {
|
|
|
62
61
|
// reliable matching strategy for tool reruns in subprocesses.
|
|
63
62
|
installFrozenFetchFallback(frozenEvents)
|
|
64
63
|
|
|
65
|
-
//
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
// Set up HttpRunContext for all freezable event types (AI + DB).
|
|
65
|
+
// Both wrapAI and wrapDB call httpCtx.nextId() sequentially, so we must
|
|
66
|
+
// include all freezable types in the frozen map, re-indexed in original
|
|
67
|
+
// execution order, to keep the sequential counter aligned.
|
|
68
|
+
const freezableEvents = frozenEvents
|
|
69
|
+
.filter(e => e.type === 'ai' || e.type === 'db')
|
|
70
|
+
.sort((a, b) => a.id - b.id) // preserve original execution order
|
|
71
|
+
if (freezableEvents.length > 0) {
|
|
68
72
|
try {
|
|
69
73
|
const telemetryPush = await import('./interceptors/telemetry-push.js')
|
|
70
|
-
const workflowEvents =
|
|
74
|
+
const workflowEvents = freezableEvents.map((e, i) => ({
|
|
71
75
|
id: i + 1,
|
|
72
|
-
type: e.type as 'db',
|
|
76
|
+
type: e.type as 'ai' | 'db',
|
|
73
77
|
name: e.name,
|
|
74
78
|
input: e.input,
|
|
75
79
|
output: e.output,
|
|
@@ -86,7 +90,7 @@ async function setupFrozenContext(frozenEvents: FrozenEvent[]): Promise<void> {
|
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
} catch {
|
|
89
|
-
//
|
|
93
|
+
// Frozen replay not available — tool will hit real services
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
}
|