@refactorlabs/recount 0.6.0 → 0.7.1
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 +6 -7
- package/dist/index.cjs +48 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -11
- package/dist/index.d.ts +12 -11
- package/dist/index.js +48 -7
- package/dist/index.js.map +1 -1
- package/llms.md +25 -29
- package/package.json +1 -1
- package/recount-instrument/SKILL.md +10 -6
package/dist/index.d.cts
CHANGED
|
@@ -59,7 +59,6 @@ type MessageSpanLevel = 'info' | 'warn' | 'error';
|
|
|
59
59
|
type MessageSpanOptions = {
|
|
60
60
|
description?: string;
|
|
61
61
|
level?: MessageSpanLevel;
|
|
62
|
-
alerts?: SpanAlert[];
|
|
63
62
|
public?: boolean;
|
|
64
63
|
};
|
|
65
64
|
type DbSpanMetadata = {
|
|
@@ -107,17 +106,18 @@ type ImageSpanData = {
|
|
|
107
106
|
url: string;
|
|
108
107
|
label?: string;
|
|
109
108
|
};
|
|
109
|
+
type SpanAlertLevel = 'warn' | 'error';
|
|
110
110
|
type SpanAlertCheck = {
|
|
111
111
|
target?: string;
|
|
112
112
|
value: number;
|
|
113
113
|
};
|
|
114
114
|
type SpanAlert = {
|
|
115
|
-
label
|
|
116
|
-
level:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
checks
|
|
115
|
+
label: string;
|
|
116
|
+
level: SpanAlertLevel;
|
|
117
|
+
checks?: SpanAlertCheck[];
|
|
118
|
+
};
|
|
119
|
+
type SpanAlertOptions = {
|
|
120
|
+
checks?: SpanAlertCheck[];
|
|
121
121
|
};
|
|
122
122
|
type SpanBase = {
|
|
123
123
|
name: string;
|
|
@@ -166,7 +166,6 @@ type Span = (SpanBase & {
|
|
|
166
166
|
});
|
|
167
167
|
type SpanBaseOptions = {
|
|
168
168
|
description?: string;
|
|
169
|
-
alerts?: SpanAlert[];
|
|
170
169
|
durationMs?: number;
|
|
171
170
|
public?: boolean;
|
|
172
171
|
redact?: string[];
|
|
@@ -228,7 +227,6 @@ type SpanOptions = {
|
|
|
228
227
|
};
|
|
229
228
|
type IngestPayload = {
|
|
230
229
|
name: string;
|
|
231
|
-
input?: JsonObject;
|
|
232
230
|
environment?: string;
|
|
233
231
|
metadata?: Metadata;
|
|
234
232
|
durationMs?: number;
|
|
@@ -236,7 +234,6 @@ type IngestPayload = {
|
|
|
236
234
|
spans: Span[];
|
|
237
235
|
};
|
|
238
236
|
type TraceOptions = {
|
|
239
|
-
input?: JsonObject;
|
|
240
237
|
environment?: string;
|
|
241
238
|
metadata?: Metadata;
|
|
242
239
|
retentionPeriod?: RetentionPeriod;
|
|
@@ -265,6 +262,7 @@ declare class SpanGroup {
|
|
|
265
262
|
}): this;
|
|
266
263
|
span(type: Exclude<SpanType, 'group'>, name: string, options?: SpanOptions): this;
|
|
267
264
|
addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
|
|
265
|
+
alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
|
|
268
266
|
_flush(push: (type: string, name: string, opts?: SpanOptions) => void, options?: Pick<GroupSpanOptions, 'limit' | 'sample' | 'sampleThreshold'>): void;
|
|
269
267
|
}
|
|
270
268
|
declare class Trace {
|
|
@@ -282,6 +280,7 @@ declare class Trace {
|
|
|
282
280
|
}): this;
|
|
283
281
|
span(type: Exclude<SpanType, 'group'>, name: string, options?: SpanOptions): this;
|
|
284
282
|
group(name: string, builder: (g: SpanGroup) => void, options?: GroupSpanOptions): this;
|
|
283
|
+
alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
|
|
285
284
|
addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
|
|
286
285
|
addMetadata(data: Metadata): this;
|
|
287
286
|
setEnvironment(environment: string): this;
|
|
@@ -409,6 +408,7 @@ declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, fn:
|
|
|
409
408
|
declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, opts: SpanOptions, fn: () => Promise<T>): Promise<T>;
|
|
410
409
|
declare function addGroup(name: string, builder: (g: SpanGroup) => void, options?: GroupSpanOptions): void;
|
|
411
410
|
declare function addMessage(name: string, text: string, opts?: MessageSpanOptions): void;
|
|
411
|
+
declare function addAlert(label: string, level: SpanAlertLevel, opts?: SpanAlertOptions): void;
|
|
412
412
|
declare function named<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
413
413
|
declare function addMetadata(data: Metadata): void;
|
|
414
414
|
declare function fetch<T = unknown>(name: string, url: string | URL, init?: RequestInit, options?: {
|
|
@@ -423,6 +423,7 @@ declare const recount: {
|
|
|
423
423
|
addSpan: typeof addSpan;
|
|
424
424
|
addGroup: typeof addGroup;
|
|
425
425
|
addMessage: typeof addMessage;
|
|
426
|
+
addAlert: typeof addAlert;
|
|
426
427
|
addMetadata: typeof addMetadata;
|
|
427
428
|
fetch: typeof fetch;
|
|
428
429
|
table: typeof table;
|
|
@@ -437,4 +438,4 @@ declare const recount: {
|
|
|
437
438
|
};
|
|
438
439
|
};
|
|
439
440
|
|
|
440
|
-
export { type ChartData, type ChartReferenceLine, type ChartSeries, type ChartSpanOptions, type ChartType, type DbParamValue, type DbSpanMetadata, type DbSpanOptions, type GroupSpanOptions, type HttpContentType, type HttpMethod, type HttpRequestInput, type HttpResponseOutput, type HttpSpanOptions, type ImageSpanData, type ImageSpanOptions, type IngestPayload, type IngestResult, type JsonObject, type JsonSpanOptions, type LlmMessage, type LlmSpanInput, type LlmSpanOptions, type LlmSpanOutput, type MessageSpanLevel, type MessageSpanOptions, type Metadata, Recount, RecountError, type RecountOptions, type RetentionPeriod, type Span, type SpanAlert, type SpanAlertCheck, type SpanBaseOptions, SpanGroup, type SpanOptions, type SpanType, type TableCellSpan, type TableColumn, type TableData, type TableDataFlat, type TableHighlight, type TableSection, type TableSpanOptions, type TableSummaryStat, type TraceOptions, recount as default };
|
|
441
|
+
export { type ChartData, type ChartReferenceLine, type ChartSeries, type ChartSpanOptions, type ChartType, type DbParamValue, type DbSpanMetadata, type DbSpanOptions, type GroupSpanOptions, type HttpContentType, type HttpMethod, type HttpRequestInput, type HttpResponseOutput, type HttpSpanOptions, type ImageSpanData, type ImageSpanOptions, type IngestPayload, type IngestResult, type JsonObject, type JsonSpanOptions, type LlmMessage, type LlmSpanInput, type LlmSpanOptions, type LlmSpanOutput, type MessageSpanLevel, type MessageSpanOptions, type Metadata, Recount, RecountError, type RecountOptions, type RetentionPeriod, type Span, type SpanAlert, type SpanAlertCheck, type SpanAlertLevel, type SpanAlertOptions, type SpanBaseOptions, SpanGroup, type SpanOptions, type SpanType, type TableCellSpan, type TableColumn, type TableData, type TableDataFlat, type TableHighlight, type TableSection, type TableSpanOptions, type TableSummaryStat, type TraceOptions, recount as default };
|
package/dist/index.d.ts
CHANGED
|
@@ -59,7 +59,6 @@ type MessageSpanLevel = 'info' | 'warn' | 'error';
|
|
|
59
59
|
type MessageSpanOptions = {
|
|
60
60
|
description?: string;
|
|
61
61
|
level?: MessageSpanLevel;
|
|
62
|
-
alerts?: SpanAlert[];
|
|
63
62
|
public?: boolean;
|
|
64
63
|
};
|
|
65
64
|
type DbSpanMetadata = {
|
|
@@ -107,17 +106,18 @@ type ImageSpanData = {
|
|
|
107
106
|
url: string;
|
|
108
107
|
label?: string;
|
|
109
108
|
};
|
|
109
|
+
type SpanAlertLevel = 'warn' | 'error';
|
|
110
110
|
type SpanAlertCheck = {
|
|
111
111
|
target?: string;
|
|
112
112
|
value: number;
|
|
113
113
|
};
|
|
114
114
|
type SpanAlert = {
|
|
115
|
-
label
|
|
116
|
-
level:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
checks
|
|
115
|
+
label: string;
|
|
116
|
+
level: SpanAlertLevel;
|
|
117
|
+
checks?: SpanAlertCheck[];
|
|
118
|
+
};
|
|
119
|
+
type SpanAlertOptions = {
|
|
120
|
+
checks?: SpanAlertCheck[];
|
|
121
121
|
};
|
|
122
122
|
type SpanBase = {
|
|
123
123
|
name: string;
|
|
@@ -166,7 +166,6 @@ type Span = (SpanBase & {
|
|
|
166
166
|
});
|
|
167
167
|
type SpanBaseOptions = {
|
|
168
168
|
description?: string;
|
|
169
|
-
alerts?: SpanAlert[];
|
|
170
169
|
durationMs?: number;
|
|
171
170
|
public?: boolean;
|
|
172
171
|
redact?: string[];
|
|
@@ -228,7 +227,6 @@ type SpanOptions = {
|
|
|
228
227
|
};
|
|
229
228
|
type IngestPayload = {
|
|
230
229
|
name: string;
|
|
231
|
-
input?: JsonObject;
|
|
232
230
|
environment?: string;
|
|
233
231
|
metadata?: Metadata;
|
|
234
232
|
durationMs?: number;
|
|
@@ -236,7 +234,6 @@ type IngestPayload = {
|
|
|
236
234
|
spans: Span[];
|
|
237
235
|
};
|
|
238
236
|
type TraceOptions = {
|
|
239
|
-
input?: JsonObject;
|
|
240
237
|
environment?: string;
|
|
241
238
|
metadata?: Metadata;
|
|
242
239
|
retentionPeriod?: RetentionPeriod;
|
|
@@ -265,6 +262,7 @@ declare class SpanGroup {
|
|
|
265
262
|
}): this;
|
|
266
263
|
span(type: Exclude<SpanType, 'group'>, name: string, options?: SpanOptions): this;
|
|
267
264
|
addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
|
|
265
|
+
alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
|
|
268
266
|
_flush(push: (type: string, name: string, opts?: SpanOptions) => void, options?: Pick<GroupSpanOptions, 'limit' | 'sample' | 'sampleThreshold'>): void;
|
|
269
267
|
}
|
|
270
268
|
declare class Trace {
|
|
@@ -282,6 +280,7 @@ declare class Trace {
|
|
|
282
280
|
}): this;
|
|
283
281
|
span(type: Exclude<SpanType, 'group'>, name: string, options?: SpanOptions): this;
|
|
284
282
|
group(name: string, builder: (g: SpanGroup) => void, options?: GroupSpanOptions): this;
|
|
283
|
+
alert(label: string, level: SpanAlertLevel, options?: SpanAlertOptions): this;
|
|
285
284
|
addMessage(name: string, text?: string, opts?: MessageSpanOptions): this;
|
|
286
285
|
addMetadata(data: Metadata): this;
|
|
287
286
|
setEnvironment(environment: string): this;
|
|
@@ -409,6 +408,7 @@ declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, fn:
|
|
|
409
408
|
declare function addSpan<T>(type: Exclude<SpanType, 'group'>, name: string, opts: SpanOptions, fn: () => Promise<T>): Promise<T>;
|
|
410
409
|
declare function addGroup(name: string, builder: (g: SpanGroup) => void, options?: GroupSpanOptions): void;
|
|
411
410
|
declare function addMessage(name: string, text: string, opts?: MessageSpanOptions): void;
|
|
411
|
+
declare function addAlert(label: string, level: SpanAlertLevel, opts?: SpanAlertOptions): void;
|
|
412
412
|
declare function named<T>(name: string, fn: () => Promise<T>): Promise<T>;
|
|
413
413
|
declare function addMetadata(data: Metadata): void;
|
|
414
414
|
declare function fetch<T = unknown>(name: string, url: string | URL, init?: RequestInit, options?: {
|
|
@@ -423,6 +423,7 @@ declare const recount: {
|
|
|
423
423
|
addSpan: typeof addSpan;
|
|
424
424
|
addGroup: typeof addGroup;
|
|
425
425
|
addMessage: typeof addMessage;
|
|
426
|
+
addAlert: typeof addAlert;
|
|
426
427
|
addMetadata: typeof addMetadata;
|
|
427
428
|
fetch: typeof fetch;
|
|
428
429
|
table: typeof table;
|
|
@@ -437,4 +438,4 @@ declare const recount: {
|
|
|
437
438
|
};
|
|
438
439
|
};
|
|
439
440
|
|
|
440
|
-
export { type ChartData, type ChartReferenceLine, type ChartSeries, type ChartSpanOptions, type ChartType, type DbParamValue, type DbSpanMetadata, type DbSpanOptions, type GroupSpanOptions, type HttpContentType, type HttpMethod, type HttpRequestInput, type HttpResponseOutput, type HttpSpanOptions, type ImageSpanData, type ImageSpanOptions, type IngestPayload, type IngestResult, type JsonObject, type JsonSpanOptions, type LlmMessage, type LlmSpanInput, type LlmSpanOptions, type LlmSpanOutput, type MessageSpanLevel, type MessageSpanOptions, type Metadata, Recount, RecountError, type RecountOptions, type RetentionPeriod, type Span, type SpanAlert, type SpanAlertCheck, type SpanBaseOptions, SpanGroup, type SpanOptions, type SpanType, type TableCellSpan, type TableColumn, type TableData, type TableDataFlat, type TableHighlight, type TableSection, type TableSpanOptions, type TableSummaryStat, type TraceOptions, recount as default };
|
|
441
|
+
export { type ChartData, type ChartReferenceLine, type ChartSeries, type ChartSpanOptions, type ChartType, type DbParamValue, type DbSpanMetadata, type DbSpanOptions, type GroupSpanOptions, type HttpContentType, type HttpMethod, type HttpRequestInput, type HttpResponseOutput, type HttpSpanOptions, type ImageSpanData, type ImageSpanOptions, type IngestPayload, type IngestResult, type JsonObject, type JsonSpanOptions, type LlmMessage, type LlmSpanInput, type LlmSpanOptions, type LlmSpanOutput, type MessageSpanLevel, type MessageSpanOptions, type Metadata, Recount, RecountError, type RecountOptions, type RetentionPeriod, type Span, type SpanAlert, type SpanAlertCheck, type SpanAlertLevel, type SpanAlertOptions, type SpanBaseOptions, SpanGroup, type SpanOptions, type SpanType, type TableCellSpan, type TableColumn, type TableData, type TableDataFlat, type TableHighlight, type TableSection, type TableSpanOptions, type TableSummaryStat, type TraceOptions, recount as default };
|
package/dist/index.js
CHANGED
|
@@ -154,18 +154,35 @@ function reservoirSample(items, k) {
|
|
|
154
154
|
indexed.sort((a, b) => b.key - a.key);
|
|
155
155
|
return indexed.slice(0, k).sort((a, b) => a.i - b.i).map(({ item }) => item);
|
|
156
156
|
}
|
|
157
|
-
var _buffer;
|
|
157
|
+
var _buffer, _lastSpan;
|
|
158
158
|
var SpanGroup = class {
|
|
159
159
|
constructor() {
|
|
160
160
|
__privateAdd(this, _buffer, []);
|
|
161
|
+
__privateAdd(this, _lastSpan);
|
|
161
162
|
}
|
|
162
163
|
span(type, name, options) {
|
|
163
|
-
|
|
164
|
+
const item = { type, name, opts: options };
|
|
165
|
+
__privateGet(this, _buffer).push(item);
|
|
166
|
+
__privateSet(this, _lastSpan, item);
|
|
164
167
|
return this;
|
|
165
168
|
}
|
|
166
169
|
addMessage(name, text, opts) {
|
|
167
170
|
return this.span("message", name, { text, ...opts });
|
|
168
171
|
}
|
|
172
|
+
alert(label, level, options) {
|
|
173
|
+
if (!__privateGet(this, _lastSpan)) return this;
|
|
174
|
+
const entry = {
|
|
175
|
+
label,
|
|
176
|
+
level,
|
|
177
|
+
...options?.checks && { checks: options.checks }
|
|
178
|
+
};
|
|
179
|
+
const opts = __privateGet(this, _lastSpan).opts ?? {};
|
|
180
|
+
__privateGet(this, _lastSpan).opts = {
|
|
181
|
+
...opts,
|
|
182
|
+
alerts: [...opts.alerts ?? [], entry]
|
|
183
|
+
};
|
|
184
|
+
return this;
|
|
185
|
+
}
|
|
169
186
|
_flush(push, options) {
|
|
170
187
|
const { limit, sample, sampleThreshold } = options ?? {};
|
|
171
188
|
let items = __privateGet(this, _buffer).filter(
|
|
@@ -185,7 +202,8 @@ var SpanGroup = class {
|
|
|
185
202
|
}
|
|
186
203
|
};
|
|
187
204
|
_buffer = new WeakMap();
|
|
188
|
-
|
|
205
|
+
_lastSpan = new WeakMap();
|
|
206
|
+
var _client, _name, _options, _spans, _startTime, _disabled, _log, _metadata, _environment, _lastSpan2, _Trace_instances, pushSpan_fn, applyRedaction_fn;
|
|
189
207
|
var Trace = class {
|
|
190
208
|
constructor(client, name, options = {}, disabled = false, log = () => {
|
|
191
209
|
}) {
|
|
@@ -199,6 +217,7 @@ var Trace = class {
|
|
|
199
217
|
__privateAdd(this, _log);
|
|
200
218
|
__privateAdd(this, _metadata);
|
|
201
219
|
__privateAdd(this, _environment);
|
|
220
|
+
__privateAdd(this, _lastSpan2);
|
|
202
221
|
__privateSet(this, _client, client);
|
|
203
222
|
__privateSet(this, _name, name);
|
|
204
223
|
__privateSet(this, _options, options);
|
|
@@ -243,6 +262,20 @@ var Trace = class {
|
|
|
243
262
|
}
|
|
244
263
|
return this;
|
|
245
264
|
}
|
|
265
|
+
alert(label, level, options) {
|
|
266
|
+
if (__privateGet(this, _disabled)) return this;
|
|
267
|
+
if (!__privateGet(this, _lastSpan2)) {
|
|
268
|
+
__privateGet(this, _log).call(this, `alert label=${label} dropped (no span to attach to)`);
|
|
269
|
+
return this;
|
|
270
|
+
}
|
|
271
|
+
const entry = {
|
|
272
|
+
label,
|
|
273
|
+
level,
|
|
274
|
+
...options?.checks && { checks: options.checks }
|
|
275
|
+
};
|
|
276
|
+
__privateGet(this, _lastSpan2).alerts = [...__privateGet(this, _lastSpan2).alerts ?? [], entry];
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
246
279
|
addMessage(name, text, opts) {
|
|
247
280
|
return this.span("message", name, { text, ...opts });
|
|
248
281
|
}
|
|
@@ -296,6 +329,7 @@ _disabled = new WeakMap();
|
|
|
296
329
|
_log = new WeakMap();
|
|
297
330
|
_metadata = new WeakMap();
|
|
298
331
|
_environment = new WeakMap();
|
|
332
|
+
_lastSpan2 = new WeakMap();
|
|
299
333
|
_Trace_instances = new WeakSet();
|
|
300
334
|
pushSpan_fn = function(type, name, options, parentOrder) {
|
|
301
335
|
if (type !== "group" && type !== "message") {
|
|
@@ -304,8 +338,9 @@ pushSpan_fn = function(type, name, options, parentOrder) {
|
|
|
304
338
|
return;
|
|
305
339
|
}
|
|
306
340
|
}
|
|
341
|
+
let span;
|
|
307
342
|
if (type === "message") {
|
|
308
|
-
|
|
343
|
+
span = {
|
|
309
344
|
type: "message",
|
|
310
345
|
name,
|
|
311
346
|
...options?.text !== void 0 && { text: options.text },
|
|
@@ -320,16 +355,18 @@ pushSpan_fn = function(type, name, options, parentOrder) {
|
|
|
320
355
|
durationMs: options.durationMs
|
|
321
356
|
},
|
|
322
357
|
...options?.public !== void 0 && { public: options.public }
|
|
323
|
-
}
|
|
358
|
+
};
|
|
324
359
|
} else {
|
|
325
|
-
|
|
360
|
+
span = {
|
|
326
361
|
type,
|
|
327
362
|
name,
|
|
328
363
|
order: __privateGet(this, _spans).length,
|
|
329
364
|
...parentOrder !== void 0 && { parentOrder },
|
|
330
365
|
...__privateMethod(this, _Trace_instances, applyRedaction_fn).call(this, type, options)
|
|
331
|
-
}
|
|
366
|
+
};
|
|
332
367
|
}
|
|
368
|
+
__privateGet(this, _spans).push(span);
|
|
369
|
+
__privateSet(this, _lastSpan2, span);
|
|
333
370
|
__privateGet(this, _log).call(this, `span type=${type} name=${name}`);
|
|
334
371
|
};
|
|
335
372
|
applyRedaction_fn = function(type, options) {
|
|
@@ -902,6 +939,9 @@ function addGroup(name, builder, options) {
|
|
|
902
939
|
function addMessage(name, text, opts) {
|
|
903
940
|
getActiveTrace()?.addMessage(name, text, opts);
|
|
904
941
|
}
|
|
942
|
+
function addAlert(label, level, opts) {
|
|
943
|
+
getActiveTrace()?.alert(label, level, opts);
|
|
944
|
+
}
|
|
905
945
|
function named(name, fn) {
|
|
906
946
|
return runWithSpanName(name, fn);
|
|
907
947
|
}
|
|
@@ -930,6 +970,7 @@ var recount = {
|
|
|
930
970
|
addSpan,
|
|
931
971
|
addGroup,
|
|
932
972
|
addMessage,
|
|
973
|
+
addAlert,
|
|
933
974
|
addMetadata,
|
|
934
975
|
fetch,
|
|
935
976
|
// Builders
|