sentienceapi 0.90.4 → 0.90.10
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/README.md +81 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +12 -1
- package/dist/snapshot.js.map +1 -1
- package/dist/textSearch.d.ts +64 -0
- package/dist/textSearch.d.ts.map +1 -0
- package/dist/textSearch.js +87 -0
- package/dist/textSearch.js.map +1 -0
- package/dist/tracing/cloud-sink.d.ts +27 -1
- package/dist/tracing/cloud-sink.d.ts.map +1 -1
- package/dist/tracing/cloud-sink.js +101 -5
- package/dist/tracing/cloud-sink.js.map +1 -1
- package/dist/tracing/index-schema.d.ts +182 -0
- package/dist/tracing/index-schema.d.ts.map +1 -0
- package/dist/tracing/index-schema.js +150 -0
- package/dist/tracing/index-schema.js.map +1 -0
- package/dist/tracing/indexer.d.ts +17 -0
- package/dist/tracing/indexer.d.ts.map +1 -0
- package/dist/tracing/indexer.js +282 -0
- package/dist/tracing/indexer.js.map +1 -0
- package/dist/tracing/jsonl-sink.d.ts +4 -0
- package/dist/tracing/jsonl-sink.d.ts.map +1 -1
- package/dist/tracing/jsonl-sink.js +15 -0
- package/dist/tracing/jsonl-sink.js.map +1 -1
- package/dist/tracing/tracer-factory.d.ts +14 -5
- package/dist/tracing/tracer-factory.d.ts.map +1 -1
- package/dist/tracing/tracer-factory.js +18 -8
- package/dist/tracing/tracer-factory.js.map +1 -1
- package/dist/types.d.ts +98 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/extension/background.js +222 -52
- package/src/extension/content.js +285 -9
- package/src/extension/injected_api.js +1224 -189
- package/src/extension/manifest.json +10 -4
- package/src/extension/pkg/README.md +163 -2
- package/src/extension/pkg/sentience_core.d.ts +9 -0
- package/src/extension/pkg/sentience_core.js +16 -0
- package/src/extension/pkg/sentience_core_bg.wasm +0 -0
- package/src/extension/pkg/sentience_core_bg.wasm.d.ts +1 -0
- package/src/extension/release.json +115 -0
- package/src/extension/test-content.js +4 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for trace index schema using concrete classes.
|
|
3
|
+
*/
|
|
4
|
+
export declare class TraceFileInfo {
|
|
5
|
+
path: string;
|
|
6
|
+
size_bytes: number;
|
|
7
|
+
sha256: string;
|
|
8
|
+
constructor(path: string, size_bytes: number, sha256: string);
|
|
9
|
+
toJSON(): {
|
|
10
|
+
path: string;
|
|
11
|
+
size_bytes: number;
|
|
12
|
+
sha256: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class TraceSummary {
|
|
16
|
+
first_ts: string;
|
|
17
|
+
last_ts: string;
|
|
18
|
+
event_count: number;
|
|
19
|
+
step_count: number;
|
|
20
|
+
error_count: number;
|
|
21
|
+
final_url: string | null;
|
|
22
|
+
constructor(first_ts: string, last_ts: string, event_count: number, step_count: number, error_count: number, final_url: string | null);
|
|
23
|
+
toJSON(): {
|
|
24
|
+
first_ts: string;
|
|
25
|
+
last_ts: string;
|
|
26
|
+
event_count: number;
|
|
27
|
+
step_count: number;
|
|
28
|
+
error_count: number;
|
|
29
|
+
final_url: string | null;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export declare class SnapshotInfo {
|
|
33
|
+
snapshot_id: string | null;
|
|
34
|
+
digest: string | null;
|
|
35
|
+
url: string | null;
|
|
36
|
+
constructor(snapshot_id?: string | null, digest?: string | null, url?: string | null);
|
|
37
|
+
toJSON(): {
|
|
38
|
+
snapshot_id: string | null;
|
|
39
|
+
digest: string | null;
|
|
40
|
+
url: string | null;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export declare class ActionInfo {
|
|
44
|
+
type: string | null;
|
|
45
|
+
target_element_id: number | null;
|
|
46
|
+
args_digest: string | null;
|
|
47
|
+
success: boolean | null;
|
|
48
|
+
constructor(type?: string | null, target_element_id?: number | null, args_digest?: string | null, success?: boolean | null);
|
|
49
|
+
toJSON(): {
|
|
50
|
+
type: string | null;
|
|
51
|
+
target_element_id: number | null;
|
|
52
|
+
args_digest: string | null;
|
|
53
|
+
success: boolean | null;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare class StepCounters {
|
|
57
|
+
events: number;
|
|
58
|
+
snapshots: number;
|
|
59
|
+
actions: number;
|
|
60
|
+
llm_calls: number;
|
|
61
|
+
constructor(events?: number, snapshots?: number, actions?: number, llm_calls?: number);
|
|
62
|
+
toJSON(): {
|
|
63
|
+
events: number;
|
|
64
|
+
snapshots: number;
|
|
65
|
+
actions: number;
|
|
66
|
+
llm_calls: number;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export type StepStatus = 'ok' | 'error' | 'partial';
|
|
70
|
+
export declare class StepIndex {
|
|
71
|
+
step_index: number;
|
|
72
|
+
step_id: string;
|
|
73
|
+
goal: string | null;
|
|
74
|
+
status: StepStatus;
|
|
75
|
+
ts_start: string;
|
|
76
|
+
ts_end: string;
|
|
77
|
+
offset_start: number;
|
|
78
|
+
offset_end: number;
|
|
79
|
+
url_before: string | null;
|
|
80
|
+
url_after: string | null;
|
|
81
|
+
snapshot_before: SnapshotInfo;
|
|
82
|
+
snapshot_after: SnapshotInfo;
|
|
83
|
+
action: ActionInfo;
|
|
84
|
+
counters: StepCounters;
|
|
85
|
+
constructor(step_index: number, step_id: string, goal: string | null, status: StepStatus, ts_start: string, ts_end: string, offset_start: number, offset_end: number, url_before: string | null, url_after: string | null, snapshot_before: SnapshotInfo, snapshot_after: SnapshotInfo, action: ActionInfo, counters: StepCounters);
|
|
86
|
+
toJSON(): {
|
|
87
|
+
step_index: number;
|
|
88
|
+
step_id: string;
|
|
89
|
+
goal: string | null;
|
|
90
|
+
status: StepStatus;
|
|
91
|
+
ts_start: string;
|
|
92
|
+
ts_end: string;
|
|
93
|
+
offset_start: number;
|
|
94
|
+
offset_end: number;
|
|
95
|
+
url_before: string | null;
|
|
96
|
+
url_after: string | null;
|
|
97
|
+
snapshot_before: {
|
|
98
|
+
snapshot_id: string | null;
|
|
99
|
+
digest: string | null;
|
|
100
|
+
url: string | null;
|
|
101
|
+
};
|
|
102
|
+
snapshot_after: {
|
|
103
|
+
snapshot_id: string | null;
|
|
104
|
+
digest: string | null;
|
|
105
|
+
url: string | null;
|
|
106
|
+
};
|
|
107
|
+
action: {
|
|
108
|
+
type: string | null;
|
|
109
|
+
target_element_id: number | null;
|
|
110
|
+
args_digest: string | null;
|
|
111
|
+
success: boolean | null;
|
|
112
|
+
};
|
|
113
|
+
counters: {
|
|
114
|
+
events: number;
|
|
115
|
+
snapshots: number;
|
|
116
|
+
actions: number;
|
|
117
|
+
llm_calls: number;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export declare class TraceIndex {
|
|
122
|
+
version: number;
|
|
123
|
+
run_id: string;
|
|
124
|
+
created_at: string;
|
|
125
|
+
trace_file: TraceFileInfo;
|
|
126
|
+
summary: TraceSummary;
|
|
127
|
+
steps: StepIndex[];
|
|
128
|
+
constructor(version: number, run_id: string, created_at: string, trace_file: TraceFileInfo, summary: TraceSummary, steps?: StepIndex[]);
|
|
129
|
+
toJSON(): {
|
|
130
|
+
version: number;
|
|
131
|
+
run_id: string;
|
|
132
|
+
created_at: string;
|
|
133
|
+
trace_file: {
|
|
134
|
+
path: string;
|
|
135
|
+
size_bytes: number;
|
|
136
|
+
sha256: string;
|
|
137
|
+
};
|
|
138
|
+
summary: {
|
|
139
|
+
first_ts: string;
|
|
140
|
+
last_ts: string;
|
|
141
|
+
event_count: number;
|
|
142
|
+
step_count: number;
|
|
143
|
+
error_count: number;
|
|
144
|
+
final_url: string | null;
|
|
145
|
+
};
|
|
146
|
+
steps: {
|
|
147
|
+
step_index: number;
|
|
148
|
+
step_id: string;
|
|
149
|
+
goal: string | null;
|
|
150
|
+
status: StepStatus;
|
|
151
|
+
ts_start: string;
|
|
152
|
+
ts_end: string;
|
|
153
|
+
offset_start: number;
|
|
154
|
+
offset_end: number;
|
|
155
|
+
url_before: string | null;
|
|
156
|
+
url_after: string | null;
|
|
157
|
+
snapshot_before: {
|
|
158
|
+
snapshot_id: string | null;
|
|
159
|
+
digest: string | null;
|
|
160
|
+
url: string | null;
|
|
161
|
+
};
|
|
162
|
+
snapshot_after: {
|
|
163
|
+
snapshot_id: string | null;
|
|
164
|
+
digest: string | null;
|
|
165
|
+
url: string | null;
|
|
166
|
+
};
|
|
167
|
+
action: {
|
|
168
|
+
type: string | null;
|
|
169
|
+
target_element_id: number | null;
|
|
170
|
+
args_digest: string | null;
|
|
171
|
+
success: boolean | null;
|
|
172
|
+
};
|
|
173
|
+
counters: {
|
|
174
|
+
events: number;
|
|
175
|
+
snapshots: number;
|
|
176
|
+
actions: number;
|
|
177
|
+
llm_calls: number;
|
|
178
|
+
};
|
|
179
|
+
}[];
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=index-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-schema.d.ts","sourceRoot":"","sources":["../../src/tracing/index-schema.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,aAAa;IAEf,IAAI,EAAE,MAAM;IACZ,UAAU,EAAE,MAAM;IAClB,MAAM,EAAE,MAAM;gBAFd,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM;IAGvB,MAAM;;;;;CAOP;AAED,qBAAa,YAAY;IAEd,QAAQ,EAAE,MAAM;IAChB,OAAO,EAAE,MAAM;IACf,WAAW,EAAE,MAAM;IACnB,UAAU,EAAE,MAAM;IAClB,WAAW,EAAE,MAAM;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI;gBALxB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,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AAU,EAAE,MAAM;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI;IACxB,eAAe,EAAE,YAAY;IAC7B,cAAc,EAAE,YAAY;IAC5B,MAAM,EAAE,UAAU;IAClB,QAAQ,EAAE,YAAY;gBAbtB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,eAAe,EAAE,YAAY,EAC7B,cAAc,EAAE,YAAY,EAC5B,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,YAAY;IAG/B,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBP;AAED,qBAAa,UAAU;IAEZ,OAAO,EAAE,MAAM;IACf,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,MAAM;IAClB,UAAU,EAAE,aAAa;IACzB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,SAAS,EAAE;gBALlB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,aAAa,EACzB,OAAO,EAAE,YAAY,EACrB,KAAK,GAAE,SAAS,EAAO;IAGhC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAUP"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for trace index schema using concrete classes.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TraceIndex = exports.StepIndex = exports.StepCounters = exports.ActionInfo = exports.SnapshotInfo = exports.TraceSummary = exports.TraceFileInfo = void 0;
|
|
7
|
+
class TraceFileInfo {
|
|
8
|
+
constructor(path, size_bytes, sha256) {
|
|
9
|
+
this.path = path;
|
|
10
|
+
this.size_bytes = size_bytes;
|
|
11
|
+
this.sha256 = sha256;
|
|
12
|
+
}
|
|
13
|
+
toJSON() {
|
|
14
|
+
return {
|
|
15
|
+
path: this.path,
|
|
16
|
+
size_bytes: this.size_bytes,
|
|
17
|
+
sha256: this.sha256,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.TraceFileInfo = TraceFileInfo;
|
|
22
|
+
class TraceSummary {
|
|
23
|
+
constructor(first_ts, last_ts, event_count, step_count, error_count, final_url) {
|
|
24
|
+
this.first_ts = first_ts;
|
|
25
|
+
this.last_ts = last_ts;
|
|
26
|
+
this.event_count = event_count;
|
|
27
|
+
this.step_count = step_count;
|
|
28
|
+
this.error_count = error_count;
|
|
29
|
+
this.final_url = final_url;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
first_ts: this.first_ts,
|
|
34
|
+
last_ts: this.last_ts,
|
|
35
|
+
event_count: this.event_count,
|
|
36
|
+
step_count: this.step_count,
|
|
37
|
+
error_count: this.error_count,
|
|
38
|
+
final_url: this.final_url,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.TraceSummary = TraceSummary;
|
|
43
|
+
class SnapshotInfo {
|
|
44
|
+
constructor(snapshot_id = null, digest = null, url = null) {
|
|
45
|
+
this.snapshot_id = snapshot_id;
|
|
46
|
+
this.digest = digest;
|
|
47
|
+
this.url = url;
|
|
48
|
+
}
|
|
49
|
+
toJSON() {
|
|
50
|
+
return {
|
|
51
|
+
snapshot_id: this.snapshot_id,
|
|
52
|
+
digest: this.digest,
|
|
53
|
+
url: this.url,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.SnapshotInfo = SnapshotInfo;
|
|
58
|
+
class ActionInfo {
|
|
59
|
+
constructor(type = null, target_element_id = null, args_digest = null, success = null) {
|
|
60
|
+
this.type = type;
|
|
61
|
+
this.target_element_id = target_element_id;
|
|
62
|
+
this.args_digest = args_digest;
|
|
63
|
+
this.success = success;
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
type: this.type,
|
|
68
|
+
target_element_id: this.target_element_id,
|
|
69
|
+
args_digest: this.args_digest,
|
|
70
|
+
success: this.success,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.ActionInfo = ActionInfo;
|
|
75
|
+
class StepCounters {
|
|
76
|
+
constructor(events = 0, snapshots = 0, actions = 0, llm_calls = 0) {
|
|
77
|
+
this.events = events;
|
|
78
|
+
this.snapshots = snapshots;
|
|
79
|
+
this.actions = actions;
|
|
80
|
+
this.llm_calls = llm_calls;
|
|
81
|
+
}
|
|
82
|
+
toJSON() {
|
|
83
|
+
return {
|
|
84
|
+
events: this.events,
|
|
85
|
+
snapshots: this.snapshots,
|
|
86
|
+
actions: this.actions,
|
|
87
|
+
llm_calls: this.llm_calls,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.StepCounters = StepCounters;
|
|
92
|
+
class StepIndex {
|
|
93
|
+
constructor(step_index, step_id, goal, status, ts_start, ts_end, offset_start, offset_end, url_before, url_after, snapshot_before, snapshot_after, action, counters) {
|
|
94
|
+
this.step_index = step_index;
|
|
95
|
+
this.step_id = step_id;
|
|
96
|
+
this.goal = goal;
|
|
97
|
+
this.status = status;
|
|
98
|
+
this.ts_start = ts_start;
|
|
99
|
+
this.ts_end = ts_end;
|
|
100
|
+
this.offset_start = offset_start;
|
|
101
|
+
this.offset_end = offset_end;
|
|
102
|
+
this.url_before = url_before;
|
|
103
|
+
this.url_after = url_after;
|
|
104
|
+
this.snapshot_before = snapshot_before;
|
|
105
|
+
this.snapshot_after = snapshot_after;
|
|
106
|
+
this.action = action;
|
|
107
|
+
this.counters = counters;
|
|
108
|
+
}
|
|
109
|
+
toJSON() {
|
|
110
|
+
return {
|
|
111
|
+
step_index: this.step_index,
|
|
112
|
+
step_id: this.step_id,
|
|
113
|
+
goal: this.goal,
|
|
114
|
+
status: this.status,
|
|
115
|
+
ts_start: this.ts_start,
|
|
116
|
+
ts_end: this.ts_end,
|
|
117
|
+
offset_start: this.offset_start,
|
|
118
|
+
offset_end: this.offset_end,
|
|
119
|
+
url_before: this.url_before,
|
|
120
|
+
url_after: this.url_after,
|
|
121
|
+
snapshot_before: this.snapshot_before.toJSON(),
|
|
122
|
+
snapshot_after: this.snapshot_after.toJSON(),
|
|
123
|
+
action: this.action.toJSON(),
|
|
124
|
+
counters: this.counters.toJSON(),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.StepIndex = StepIndex;
|
|
129
|
+
class TraceIndex {
|
|
130
|
+
constructor(version, run_id, created_at, trace_file, summary, steps = []) {
|
|
131
|
+
this.version = version;
|
|
132
|
+
this.run_id = run_id;
|
|
133
|
+
this.created_at = created_at;
|
|
134
|
+
this.trace_file = trace_file;
|
|
135
|
+
this.summary = summary;
|
|
136
|
+
this.steps = steps;
|
|
137
|
+
}
|
|
138
|
+
toJSON() {
|
|
139
|
+
return {
|
|
140
|
+
version: this.version,
|
|
141
|
+
run_id: this.run_id,
|
|
142
|
+
created_at: this.created_at,
|
|
143
|
+
trace_file: this.trace_file.toJSON(),
|
|
144
|
+
summary: this.summary.toJSON(),
|
|
145
|
+
steps: this.steps.map((s) => s.toJSON()),
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
exports.TraceIndex = TraceIndex;
|
|
150
|
+
//# sourceMappingURL=index-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-schema.js","sourceRoot":"","sources":["../../src/tracing/index-schema.ts"],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,WAAM,GAAN,MAAM,CAAQ;QACd,eAAU,GAAV,UAAU,CAAQ;QAClB,eAAU,GAAV,UAAU,CAAe;QACzB,YAAO,GAAP,OAAO,CAAc;QACrB,UAAK,GAAL,KAAK,CAAkB;IAC7B,CAAC;IAEJ,MAAM;QACJ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACpC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACzC,CAAC;IACJ,CAAC;CACF;AApBD,gCAoBC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace indexing for fast timeline rendering and step drill-down.
|
|
3
|
+
*/
|
|
4
|
+
import { TraceIndex } from './index-schema';
|
|
5
|
+
/**
|
|
6
|
+
* Build trace index from JSONL file in single streaming pass
|
|
7
|
+
*/
|
|
8
|
+
export declare function buildTraceIndex(tracePath: string): TraceIndex;
|
|
9
|
+
/**
|
|
10
|
+
* Build index and write to file
|
|
11
|
+
*/
|
|
12
|
+
export declare function writeTraceIndex(tracePath: string, indexPath?: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Read events for a specific step using byte offsets from index
|
|
15
|
+
*/
|
|
16
|
+
export declare function readStepEvents(tracePath: string, offsetStart: number, offsetEnd: number): any[];
|
|
17
|
+
//# sourceMappingURL=indexer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.d.ts","sourceRoot":"","sources":["../../src/tracing/indexer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,EACL,UAAU,EAQX,MAAM,gBAAgB,CAAC;AA6GxB;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CA+J7D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAU7E;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,GAAG,EAAE,CA0BP"}
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Trace indexing for fast timeline rendering and step drill-down.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.buildTraceIndex = buildTraceIndex;
|
|
40
|
+
exports.writeTraceIndex = writeTraceIndex;
|
|
41
|
+
exports.readStepEvents = readStepEvents;
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const crypto = __importStar(require("crypto"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
const index_schema_1 = require("./index-schema");
|
|
46
|
+
/**
|
|
47
|
+
* Normalize text for digest: trim, collapse whitespace, lowercase, cap length
|
|
48
|
+
*/
|
|
49
|
+
function normalizeText(text, maxLen = 80) {
|
|
50
|
+
if (!text)
|
|
51
|
+
return '';
|
|
52
|
+
// Trim and collapse whitespace
|
|
53
|
+
let normalized = text.split(/\s+/).join(' ').trim();
|
|
54
|
+
// Lowercase
|
|
55
|
+
normalized = normalized.toLowerCase();
|
|
56
|
+
// Cap length
|
|
57
|
+
if (normalized.length > maxLen) {
|
|
58
|
+
normalized = normalized.substring(0, maxLen);
|
|
59
|
+
}
|
|
60
|
+
return normalized;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Round bbox coordinates to reduce noise (default: 2px precision)
|
|
64
|
+
*/
|
|
65
|
+
function roundBBox(bbox, precision = 2) {
|
|
66
|
+
return {
|
|
67
|
+
x: Math.round((bbox.x || 0) / precision) * precision,
|
|
68
|
+
y: Math.round((bbox.y || 0) / precision) * precision,
|
|
69
|
+
width: Math.round((bbox.width || 0) / precision) * precision,
|
|
70
|
+
height: Math.round((bbox.height || 0) / precision) * precision,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Compute stable digest of snapshot for diffing
|
|
75
|
+
*/
|
|
76
|
+
function computeSnapshotDigest(snapshotData) {
|
|
77
|
+
const url = snapshotData.url || '';
|
|
78
|
+
const viewport = snapshotData.viewport || {};
|
|
79
|
+
const elements = snapshotData.elements || [];
|
|
80
|
+
// Canonicalize elements
|
|
81
|
+
const canonicalElements = elements.map((elem) => ({
|
|
82
|
+
id: elem.id,
|
|
83
|
+
role: elem.role || '',
|
|
84
|
+
text_norm: normalizeText(elem.text),
|
|
85
|
+
bbox: roundBBox(elem.bbox || { x: 0, y: 0, width: 0, height: 0 }),
|
|
86
|
+
is_primary: elem.is_primary || false,
|
|
87
|
+
is_clickable: elem.is_clickable || false,
|
|
88
|
+
}));
|
|
89
|
+
// Sort by element id for determinism
|
|
90
|
+
canonicalElements.sort((a, b) => (a.id || 0) - (b.id || 0));
|
|
91
|
+
// Build canonical object
|
|
92
|
+
const canonical = {
|
|
93
|
+
url,
|
|
94
|
+
viewport: {
|
|
95
|
+
width: viewport.width || 0,
|
|
96
|
+
height: viewport.height || 0,
|
|
97
|
+
},
|
|
98
|
+
elements: canonicalElements,
|
|
99
|
+
};
|
|
100
|
+
// Hash
|
|
101
|
+
const canonicalJson = JSON.stringify(canonical);
|
|
102
|
+
const hash = crypto.createHash('sha256').update(canonicalJson, 'utf8').digest('hex');
|
|
103
|
+
return `sha256:${hash}`;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Compute digest of action args for privacy + determinism
|
|
107
|
+
*/
|
|
108
|
+
function computeActionDigest(actionData) {
|
|
109
|
+
const actionType = actionData.type || '';
|
|
110
|
+
const targetId = actionData.target_element_id;
|
|
111
|
+
const canonical = {
|
|
112
|
+
type: actionType,
|
|
113
|
+
target_element_id: targetId,
|
|
114
|
+
};
|
|
115
|
+
// Type-specific canonicalization
|
|
116
|
+
if (actionType === 'TYPE') {
|
|
117
|
+
const text = actionData.text || '';
|
|
118
|
+
canonical.text_len = text.length;
|
|
119
|
+
canonical.text_sha256 = crypto.createHash('sha256').update(text, 'utf8').digest('hex');
|
|
120
|
+
}
|
|
121
|
+
else if (actionType === 'PRESS') {
|
|
122
|
+
canonical.key = actionData.key || '';
|
|
123
|
+
}
|
|
124
|
+
// CLICK has no extra args
|
|
125
|
+
// Hash
|
|
126
|
+
const canonicalJson = JSON.stringify(canonical);
|
|
127
|
+
const hash = crypto.createHash('sha256').update(canonicalJson, 'utf8').digest('hex');
|
|
128
|
+
return `sha256:${hash}`;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Compute SHA256 hash of entire file
|
|
132
|
+
*/
|
|
133
|
+
function computeFileSha256(filePath) {
|
|
134
|
+
const hash = crypto.createHash('sha256');
|
|
135
|
+
const data = fs.readFileSync(filePath);
|
|
136
|
+
hash.update(data);
|
|
137
|
+
return hash.digest('hex');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Build trace index from JSONL file in single streaming pass
|
|
141
|
+
*/
|
|
142
|
+
function buildTraceIndex(tracePath) {
|
|
143
|
+
if (!fs.existsSync(tracePath)) {
|
|
144
|
+
throw new Error(`Trace file not found: ${tracePath}`);
|
|
145
|
+
}
|
|
146
|
+
// Extract run_id from filename
|
|
147
|
+
const runId = path.basename(tracePath, '.jsonl');
|
|
148
|
+
// Initialize summary
|
|
149
|
+
let firstTs = '';
|
|
150
|
+
let lastTs = '';
|
|
151
|
+
let eventCount = 0;
|
|
152
|
+
let errorCount = 0;
|
|
153
|
+
let finalUrl = null;
|
|
154
|
+
const stepsById = new Map();
|
|
155
|
+
const stepOrder = [];
|
|
156
|
+
// Stream through file, tracking byte offsets
|
|
157
|
+
const fileBuffer = fs.readFileSync(tracePath);
|
|
158
|
+
let byteOffset = 0;
|
|
159
|
+
const lines = fileBuffer.toString('utf-8').split('\n');
|
|
160
|
+
for (const line of lines) {
|
|
161
|
+
const lineBytes = Buffer.byteLength(line + '\n', 'utf-8');
|
|
162
|
+
if (!line.trim()) {
|
|
163
|
+
byteOffset += lineBytes;
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
let event;
|
|
167
|
+
try {
|
|
168
|
+
event = JSON.parse(line);
|
|
169
|
+
}
|
|
170
|
+
catch (e) {
|
|
171
|
+
// Skip malformed lines
|
|
172
|
+
byteOffset += lineBytes;
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
// Extract event metadata
|
|
176
|
+
const eventType = event.type || '';
|
|
177
|
+
const ts = event.ts || event.timestamp || '';
|
|
178
|
+
const stepId = event.step_id || 'step-0';
|
|
179
|
+
const data = event.data || {};
|
|
180
|
+
// Update summary
|
|
181
|
+
eventCount++;
|
|
182
|
+
if (!firstTs) {
|
|
183
|
+
firstTs = ts;
|
|
184
|
+
}
|
|
185
|
+
lastTs = ts;
|
|
186
|
+
if (eventType === 'error') {
|
|
187
|
+
errorCount++;
|
|
188
|
+
}
|
|
189
|
+
// Initialize step if first time seeing this step_id
|
|
190
|
+
if (!stepsById.has(stepId)) {
|
|
191
|
+
stepOrder.push(stepId);
|
|
192
|
+
stepsById.set(stepId, new index_schema_1.StepIndex(stepOrder.length, stepId, null, 'partial', ts, ts, byteOffset, byteOffset + lineBytes, null, null, new index_schema_1.SnapshotInfo(), new index_schema_1.SnapshotInfo(), new index_schema_1.ActionInfo(), new index_schema_1.StepCounters()));
|
|
193
|
+
}
|
|
194
|
+
const step = stepsById.get(stepId);
|
|
195
|
+
// Update step metadata
|
|
196
|
+
step.ts_end = ts;
|
|
197
|
+
step.offset_end = byteOffset + lineBytes;
|
|
198
|
+
step.counters.events++;
|
|
199
|
+
// Handle specific event types
|
|
200
|
+
if (eventType === 'step_start') {
|
|
201
|
+
step.goal = data.goal;
|
|
202
|
+
step.url_before = data.pre_url;
|
|
203
|
+
}
|
|
204
|
+
else if (eventType === 'snapshot') {
|
|
205
|
+
const snapshotId = data.snapshot_id;
|
|
206
|
+
const url = data.url;
|
|
207
|
+
const digest = computeSnapshotDigest(data);
|
|
208
|
+
// First snapshot = before, last snapshot = after
|
|
209
|
+
if (!step.snapshot_before.snapshot_id) {
|
|
210
|
+
step.snapshot_before = new index_schema_1.SnapshotInfo(snapshotId, digest, url);
|
|
211
|
+
step.url_before = step.url_before || url;
|
|
212
|
+
}
|
|
213
|
+
step.snapshot_after = new index_schema_1.SnapshotInfo(snapshotId, digest, url);
|
|
214
|
+
step.url_after = url;
|
|
215
|
+
step.counters.snapshots++;
|
|
216
|
+
finalUrl = url;
|
|
217
|
+
}
|
|
218
|
+
else if (eventType === 'action') {
|
|
219
|
+
step.action = new index_schema_1.ActionInfo(data.type, data.target_element_id, computeActionDigest(data), data.success !== false);
|
|
220
|
+
step.counters.actions++;
|
|
221
|
+
}
|
|
222
|
+
else if (eventType === 'llm_response') {
|
|
223
|
+
step.counters.llm_calls++;
|
|
224
|
+
}
|
|
225
|
+
else if (eventType === 'error') {
|
|
226
|
+
step.status = 'error';
|
|
227
|
+
}
|
|
228
|
+
else if (eventType === 'step_end') {
|
|
229
|
+
if (step.status !== 'error') {
|
|
230
|
+
step.status = 'ok';
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
byteOffset += lineBytes;
|
|
234
|
+
}
|
|
235
|
+
// Build summary
|
|
236
|
+
const summary = new index_schema_1.TraceSummary(firstTs, lastTs, eventCount, stepsById.size, errorCount, finalUrl);
|
|
237
|
+
// Build steps list in order
|
|
238
|
+
const stepsList = stepOrder.map((sid) => stepsById.get(sid));
|
|
239
|
+
// Build trace file info
|
|
240
|
+
const traceFile = new index_schema_1.TraceFileInfo(tracePath, fs.statSync(tracePath).size, computeFileSha256(tracePath));
|
|
241
|
+
// Build final index
|
|
242
|
+
const index = new index_schema_1.TraceIndex(1, runId, new Date().toISOString(), traceFile, summary, stepsList);
|
|
243
|
+
return index;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Build index and write to file
|
|
247
|
+
*/
|
|
248
|
+
function writeTraceIndex(tracePath, indexPath) {
|
|
249
|
+
if (!indexPath) {
|
|
250
|
+
indexPath = tracePath.replace(/\.jsonl$/, '.index.json');
|
|
251
|
+
}
|
|
252
|
+
const index = buildTraceIndex(tracePath);
|
|
253
|
+
fs.writeFileSync(indexPath, JSON.stringify(index.toJSON(), null, 2));
|
|
254
|
+
return indexPath;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Read events for a specific step using byte offsets from index
|
|
258
|
+
*/
|
|
259
|
+
function readStepEvents(tracePath, offsetStart, offsetEnd) {
|
|
260
|
+
const events = [];
|
|
261
|
+
const fd = fs.openSync(tracePath, 'r');
|
|
262
|
+
const bytesToRead = offsetEnd - offsetStart;
|
|
263
|
+
const buffer = Buffer.alloc(bytesToRead);
|
|
264
|
+
fs.readSync(fd, buffer, 0, bytesToRead, offsetStart);
|
|
265
|
+
fs.closeSync(fd);
|
|
266
|
+
// Parse lines
|
|
267
|
+
const chunk = buffer.toString('utf-8');
|
|
268
|
+
const lines = chunk.split('\n');
|
|
269
|
+
for (const line of lines) {
|
|
270
|
+
if (!line.trim())
|
|
271
|
+
continue;
|
|
272
|
+
try {
|
|
273
|
+
const event = JSON.parse(line);
|
|
274
|
+
events.push(event);
|
|
275
|
+
}
|
|
276
|
+
catch (e) {
|
|
277
|
+
// Skip malformed lines
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return events;
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=indexer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer.js","sourceRoot":"","sources":["../../src/tracing/indexer.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8HH,0CA+JC;AAKD,0CAUC;AAKD,wCA8BC;AA7UD,uCAAyB;AACzB,+CAAiC;AACjC,2CAA6B;AAC7B,iDASwB;AAExB;;GAEG;AACH,SAAS,aAAa,CAAC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,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IAErE,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAC5B,SAAiB,EACjB,WAAmB,EACnB,SAAiB;IAEjB,MAAM,MAAM,GAAU,EAAE,CAAC;IAEzB,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACvC,MAAM,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;IAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAEzC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;IACrD,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAEjB,cAAc;IACd,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,SAAS;QAE3B,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,uBAAuB;QACzB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -25,6 +25,10 @@ export declare class JsonlTraceSink extends TraceSink {
|
|
|
25
25
|
* Close the sink and flush buffered data
|
|
26
26
|
*/
|
|
27
27
|
close(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Generate trace index file (automatic on close)
|
|
30
|
+
*/
|
|
31
|
+
private generateIndex;
|
|
28
32
|
/**
|
|
29
33
|
* Get sink type identifier
|
|
30
34
|
*/
|