datanotes 3.0.0 → 3.2.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/README.md +1 -5
- package/dist/api/client.d.cts +37 -4
- package/dist/api/client.d.ts +37 -4
- package/dist/api/index.cjs +563 -60
- package/dist/api/index.d.cts +3 -2
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.js +563 -60
- package/dist/api/mcp.cjs +181 -11
- package/dist/api/mcp.js +181 -11
- package/dist/api/otlp.d.cts +63 -15
- package/dist/api/otlp.d.ts +63 -15
- package/dist/api/redact.d.cts +25 -0
- package/dist/api/redact.d.ts +25 -0
- package/dist/api/tokens.d.cts +5 -0
- package/dist/api/tokens.d.ts +5 -0
- package/dist/api/tracing.d.cts +107 -0
- package/dist/api/tracing.d.ts +107 -0
- package/dist/datanotes.cjs +9934 -2656
- package/dist/docs/administration/limits.md +96 -12
- package/dist/docs/administration/run-the-service.md +18 -0
- package/dist/docs/api/operations/add_column.md +1 -0
- package/dist/docs/api/operations/add_constraint.md +2 -0
- package/dist/docs/api/operations/alter_column.md +1 -1
- package/dist/docs/api/operations/alter_table.md +3 -2
- package/dist/docs/api/operations/check_table.md +1 -1
- package/dist/docs/api/operations/create_table.md +3 -1
- package/dist/docs/api/operations/describe_table.md +1 -1
- package/dist/docs/api/operations/graph_neighbors.md +4 -2
- package/dist/docs/api/operations/graph_path.md +3 -3
- package/dist/docs/api/operations/graph_traverse.md +2 -2
- package/dist/docs/api/operations/insert_row.md +2 -2
- package/dist/docs/api/operations/record_tool_call.md +1 -0
- package/dist/docs/api/operations/tags/queries.md +2 -2
- package/dist/docs/api/operations/tags/rows-dml.md +1 -1
- package/dist/docs/api.md +4 -4
- package/dist/docs/develop/concurrency.md +36 -1
- package/dist/docs/develop/http-api.md +11 -1
- package/dist/docs/develop/telemetry.md +224 -25
- package/dist/docs/guides/data-quality/check-constraints.md +14 -13
- package/dist/docs/guides/data-quality/hand-edits.md +10 -10
- package/dist/docs/guides/database-objects/bases.md +11 -11
- package/dist/docs/guides/database-objects/catalogs-and-schemas.md +16 -10
- package/dist/docs/guides/database-objects/columns.md +38 -38
- package/dist/docs/guides/database-objects/relations.md +173 -36
- package/dist/docs/guides/database-objects/tables.md +90 -109
- package/dist/docs/guides/database-objects/views.md +44 -44
- package/dist/docs/guides/history/back-up.md +12 -4
- package/dist/docs/guides/history/change-data-feed.md +34 -34
- package/dist/docs/guides/history/journal-and-undo.md +12 -12
- package/dist/docs/guides/history/restore.md +20 -20
- package/dist/docs/guides/history/table-history.md +31 -31
- package/dist/docs/guides/history/vacuum.md +1 -10
- package/dist/docs/guides/read-and-write/automatic-links.md +15 -15
- package/dist/docs/guides/read-and-write/import-notes.md +21 -21
- package/dist/docs/guides/read-and-write/joins-and-aggregates.md +7 -7
- package/dist/docs/guides/read-and-write/read-and-filter.md +10 -10
- package/dist/docs/guides/read-and-write/write-rows.md +10 -10
- package/dist/docs/guides/search/link-graph.md +95 -0
- package/dist/docs/guides/search/text.md +1 -1
- package/dist/docs/guides/security/who-did-what.md +2 -0
- package/dist/docs/reference/cli.md +10 -3
- package/dist/docs/reference/compatibility.md +33 -13
- package/dist/docs/reference/errors.md +1 -1
- package/dist/docs/reference/operations/auxiliary.md +2 -2
- package/dist/docs/reference/operations/queries.md +3 -3
- package/dist/docs/reference/operations/rows.md +1 -1
- package/dist/docs/reference/operations/schema.md +15 -11
- package/dist/docs/reference/operations.md +39 -39
- package/dist/docs/reference/settings.md +37 -25
- package/dist/docs/release-notes.md +145 -0
- package/dist/docs/start/how-it-works.md +35 -3
- package/dist/docs/start/quick-start.md +2 -0
- package/package.json +3 -2
package/dist/api/otlp.d.cts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenTelemetry
|
|
3
|
-
* `<endpoint>/v1/logs`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* OpenTelemetry export over OTLP/HTTP, vendor-neutral: log records (`OtlpLogExporter`, to
|
|
3
|
+
* `<endpoint>/v1/logs`) and spans (`OtlpTraceExporter`, to `<endpoint>/v1/traces`) are buffered
|
|
4
|
+
* and POSTed as `http/protobuf` (the OTLP default) or `http/json`, which every OpenTelemetry
|
|
5
|
+
* collector and OTLP backend reads. No dependency, no SDK. Export failures are counted, never
|
|
6
|
+
* thrown: telemetry must not break the program. (OTLP over gRPC is not supported: use the
|
|
7
|
+
* collector's HTTP port, 4318 by default.)
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* A log record made inside a span names it (`log`'s `context`), so the backend links the two.
|
|
10
|
+
* Configure the exporters in code, or from the standard OpenTelemetry variables with
|
|
11
|
+
* `otlpFromEnv` and `otlpTracesFromEnv`.
|
|
9
12
|
*/
|
|
13
|
+
import type { SpanRecord, TraceContext } from "./tracing.cjs";
|
|
10
14
|
export type Severity = "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
11
15
|
export type AttrValue = string | number | boolean | null | undefined;
|
|
12
16
|
export type OtlpProtocol = "http/protobuf" | "http/json";
|
|
13
17
|
export interface OtlpOptions {
|
|
14
|
-
/** Collector base URL, e.g. `http://127.0.0.1:4318` (`/v1/logs` is added). */
|
|
18
|
+
/** Collector base URL, e.g. `http://127.0.0.1:4318` (`/v1/logs` or `/v1/traces` is added). */
|
|
15
19
|
endpoint: string;
|
|
16
20
|
/** `service.name` of the records. */
|
|
17
21
|
serviceName: string;
|
|
@@ -22,7 +26,7 @@ export interface OtlpOptions {
|
|
|
22
26
|
headers?: Record<string, string>;
|
|
23
27
|
/** More resource attributes (e.g. `host.name`). */
|
|
24
28
|
resource?: Record<string, AttrValue>;
|
|
25
|
-
/** Send at most this many records per request (default 50); a full buffer is sent at once. */
|
|
29
|
+
/** Send at most this many records (or spans) per request (default 50 records, 512 spans); a full buffer is sent at once. */
|
|
26
30
|
maxBatch?: number;
|
|
27
31
|
/** Send the buffer every this many ms (default 5000; 0: only on `flush`). */
|
|
28
32
|
flushMs?: number;
|
|
@@ -30,22 +34,50 @@ export interface OtlpOptions {
|
|
|
30
34
|
send?: (url: string, body: string | Uint8Array, headers: Record<string, string>) => Promise<void>;
|
|
31
35
|
now?: () => number;
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
interface LogRecord {
|
|
38
|
+
timeUnixNano: string;
|
|
39
|
+
severity: Severity;
|
|
40
|
+
body: string;
|
|
41
|
+
attributes: Record<string, AttrValue>;
|
|
42
|
+
context?: Pick<TraceContext, "traceId" | "spanId" | "sampled">;
|
|
43
|
+
}
|
|
44
|
+
/** Unix ms (with a fraction) as OTLP nanoseconds, a decimal string. */
|
|
45
|
+
export declare function unixNano(ms: number): string;
|
|
46
|
+
/** What both exporters share: the buffer, the timer, the POST, the counts. */
|
|
47
|
+
declare abstract class OtlpBatcher<T> {
|
|
48
|
+
protected readonly o: OtlpOptions;
|
|
49
|
+
private readonly path;
|
|
50
|
+
private readonly maxBatch;
|
|
51
|
+
protected buffer: T[];
|
|
36
52
|
private inflight;
|
|
37
53
|
private timer;
|
|
38
|
-
/**
|
|
54
|
+
/** Items sent, and items lost because the collector did not take them (or the buffer was full). */
|
|
39
55
|
sent: number;
|
|
40
56
|
dropped: number;
|
|
41
|
-
constructor(o: OtlpOptions);
|
|
42
|
-
|
|
57
|
+
constructor(o: OtlpOptions, path: string, maxBatch: number);
|
|
58
|
+
protected push(items: readonly T[]): void;
|
|
59
|
+
protected resource(): Record<string, AttrValue>;
|
|
60
|
+
protected abstract encode(batch: T[], protobuf: boolean): string | Uint8Array;
|
|
43
61
|
/** Send what is buffered. Never rejects. */
|
|
44
62
|
flush(): Promise<void>;
|
|
45
|
-
private protobuf;
|
|
46
63
|
/** Stop the timer and send what is left. */
|
|
47
64
|
close(): Promise<void>;
|
|
48
65
|
}
|
|
66
|
+
export declare class OtlpLogExporter extends OtlpBatcher<LogRecord> {
|
|
67
|
+
constructor(o: OtlpOptions);
|
|
68
|
+
/** Buffer a record; `context`: the span it was made in (its trace and span id go with it). */
|
|
69
|
+
log(severity: Severity, body: string, attributes?: Record<string, AttrValue>, context?: Pick<TraceContext, "traceId" | "spanId" | "sampled">): void;
|
|
70
|
+
protected encode(batch: LogRecord[], protobuf: boolean): string | Uint8Array;
|
|
71
|
+
private protobuf;
|
|
72
|
+
}
|
|
73
|
+
/** Spans to `<endpoint>/v1/traces` (ExportTraceServiceRequest), in batches. */
|
|
74
|
+
export declare class OtlpTraceExporter extends OtlpBatcher<SpanRecord> {
|
|
75
|
+
constructor(o: OtlpOptions);
|
|
76
|
+
/** Buffer finished spans (sent with the next batch). Never throws. */
|
|
77
|
+
export(spans: SpanRecord | readonly SpanRecord[]): void;
|
|
78
|
+
protected encode(batch: SpanRecord[], protobuf: boolean): string | Uint8Array;
|
|
79
|
+
private protobuf;
|
|
80
|
+
}
|
|
49
81
|
/** `k1=v1,k2=v2` (values URL-encoded), the format of `OTEL_EXPORTER_OTLP_HEADERS`. */
|
|
50
82
|
export declare function parseOtlpHeaders(text: string | undefined): Record<string, string>;
|
|
51
83
|
/** `k1=v1,k2=v2` resource attributes, the format of `OTEL_RESOURCE_ATTRIBUTES`. */
|
|
@@ -61,5 +93,21 @@ export declare function otlpFromEnv(env: Record<string, string | undefined>, def
|
|
|
61
93
|
serviceName: string;
|
|
62
94
|
serviceVersion?: string;
|
|
63
95
|
}): OtlpOptions | null;
|
|
96
|
+
/**
|
|
97
|
+
* The same for traces: `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (full URL of /v1/traces) or
|
|
98
|
+
* `OTEL_EXPORTER_OTLP_ENDPOINT`; the `…_TRACES_…` headers and protocol; null also when
|
|
99
|
+
* `OTEL_TRACES_EXPORTER=none`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function otlpTracesFromEnv(env: Record<string, string | undefined>, defaults: {
|
|
102
|
+
serviceName: string;
|
|
103
|
+
serviceVersion?: string;
|
|
104
|
+
}): OtlpOptions | null;
|
|
105
|
+
/**
|
|
106
|
+
* The share of new traces to keep, from `OTEL_TRACES_SAMPLER` and `OTEL_TRACES_SAMPLER_ARG`
|
|
107
|
+
* (`always_on`, `always_off`, `traceidratio`, and their `parentbased_` forms: a trace continued
|
|
108
|
+
* from a caller always follows the caller); undefined when they say nothing usable.
|
|
109
|
+
*/
|
|
110
|
+
export declare function samplerRatioFromEnv(env: Record<string, string | undefined>): number | undefined;
|
|
64
111
|
/** `http/protobuf` or `http/json` from a setting or variable; undefined for anything else. */
|
|
65
112
|
export declare function otlpProtocol(v: string | undefined): OtlpProtocol | undefined;
|
|
113
|
+
export {};
|
package/dist/api/otlp.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenTelemetry
|
|
3
|
-
* `<endpoint>/v1/logs`
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
2
|
+
* OpenTelemetry export over OTLP/HTTP, vendor-neutral: log records (`OtlpLogExporter`, to
|
|
3
|
+
* `<endpoint>/v1/logs`) and spans (`OtlpTraceExporter`, to `<endpoint>/v1/traces`) are buffered
|
|
4
|
+
* and POSTed as `http/protobuf` (the OTLP default) or `http/json`, which every OpenTelemetry
|
|
5
|
+
* collector and OTLP backend reads. No dependency, no SDK. Export failures are counted, never
|
|
6
|
+
* thrown: telemetry must not break the program. (OTLP over gRPC is not supported: use the
|
|
7
|
+
* collector's HTTP port, 4318 by default.)
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* A log record made inside a span names it (`log`'s `context`), so the backend links the two.
|
|
10
|
+
* Configure the exporters in code, or from the standard OpenTelemetry variables with
|
|
11
|
+
* `otlpFromEnv` and `otlpTracesFromEnv`.
|
|
9
12
|
*/
|
|
13
|
+
import type { SpanRecord, TraceContext } from "./tracing.js";
|
|
10
14
|
export type Severity = "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
11
15
|
export type AttrValue = string | number | boolean | null | undefined;
|
|
12
16
|
export type OtlpProtocol = "http/protobuf" | "http/json";
|
|
13
17
|
export interface OtlpOptions {
|
|
14
|
-
/** Collector base URL, e.g. `http://127.0.0.1:4318` (`/v1/logs` is added). */
|
|
18
|
+
/** Collector base URL, e.g. `http://127.0.0.1:4318` (`/v1/logs` or `/v1/traces` is added). */
|
|
15
19
|
endpoint: string;
|
|
16
20
|
/** `service.name` of the records. */
|
|
17
21
|
serviceName: string;
|
|
@@ -22,7 +26,7 @@ export interface OtlpOptions {
|
|
|
22
26
|
headers?: Record<string, string>;
|
|
23
27
|
/** More resource attributes (e.g. `host.name`). */
|
|
24
28
|
resource?: Record<string, AttrValue>;
|
|
25
|
-
/** Send at most this many records per request (default 50); a full buffer is sent at once. */
|
|
29
|
+
/** Send at most this many records (or spans) per request (default 50 records, 512 spans); a full buffer is sent at once. */
|
|
26
30
|
maxBatch?: number;
|
|
27
31
|
/** Send the buffer every this many ms (default 5000; 0: only on `flush`). */
|
|
28
32
|
flushMs?: number;
|
|
@@ -30,22 +34,50 @@ export interface OtlpOptions {
|
|
|
30
34
|
send?: (url: string, body: string | Uint8Array, headers: Record<string, string>) => Promise<void>;
|
|
31
35
|
now?: () => number;
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
37
|
+
interface LogRecord {
|
|
38
|
+
timeUnixNano: string;
|
|
39
|
+
severity: Severity;
|
|
40
|
+
body: string;
|
|
41
|
+
attributes: Record<string, AttrValue>;
|
|
42
|
+
context?: Pick<TraceContext, "traceId" | "spanId" | "sampled">;
|
|
43
|
+
}
|
|
44
|
+
/** Unix ms (with a fraction) as OTLP nanoseconds, a decimal string. */
|
|
45
|
+
export declare function unixNano(ms: number): string;
|
|
46
|
+
/** What both exporters share: the buffer, the timer, the POST, the counts. */
|
|
47
|
+
declare abstract class OtlpBatcher<T> {
|
|
48
|
+
protected readonly o: OtlpOptions;
|
|
49
|
+
private readonly path;
|
|
50
|
+
private readonly maxBatch;
|
|
51
|
+
protected buffer: T[];
|
|
36
52
|
private inflight;
|
|
37
53
|
private timer;
|
|
38
|
-
/**
|
|
54
|
+
/** Items sent, and items lost because the collector did not take them (or the buffer was full). */
|
|
39
55
|
sent: number;
|
|
40
56
|
dropped: number;
|
|
41
|
-
constructor(o: OtlpOptions);
|
|
42
|
-
|
|
57
|
+
constructor(o: OtlpOptions, path: string, maxBatch: number);
|
|
58
|
+
protected push(items: readonly T[]): void;
|
|
59
|
+
protected resource(): Record<string, AttrValue>;
|
|
60
|
+
protected abstract encode(batch: T[], protobuf: boolean): string | Uint8Array;
|
|
43
61
|
/** Send what is buffered. Never rejects. */
|
|
44
62
|
flush(): Promise<void>;
|
|
45
|
-
private protobuf;
|
|
46
63
|
/** Stop the timer and send what is left. */
|
|
47
64
|
close(): Promise<void>;
|
|
48
65
|
}
|
|
66
|
+
export declare class OtlpLogExporter extends OtlpBatcher<LogRecord> {
|
|
67
|
+
constructor(o: OtlpOptions);
|
|
68
|
+
/** Buffer a record; `context`: the span it was made in (its trace and span id go with it). */
|
|
69
|
+
log(severity: Severity, body: string, attributes?: Record<string, AttrValue>, context?: Pick<TraceContext, "traceId" | "spanId" | "sampled">): void;
|
|
70
|
+
protected encode(batch: LogRecord[], protobuf: boolean): string | Uint8Array;
|
|
71
|
+
private protobuf;
|
|
72
|
+
}
|
|
73
|
+
/** Spans to `<endpoint>/v1/traces` (ExportTraceServiceRequest), in batches. */
|
|
74
|
+
export declare class OtlpTraceExporter extends OtlpBatcher<SpanRecord> {
|
|
75
|
+
constructor(o: OtlpOptions);
|
|
76
|
+
/** Buffer finished spans (sent with the next batch). Never throws. */
|
|
77
|
+
export(spans: SpanRecord | readonly SpanRecord[]): void;
|
|
78
|
+
protected encode(batch: SpanRecord[], protobuf: boolean): string | Uint8Array;
|
|
79
|
+
private protobuf;
|
|
80
|
+
}
|
|
49
81
|
/** `k1=v1,k2=v2` (values URL-encoded), the format of `OTEL_EXPORTER_OTLP_HEADERS`. */
|
|
50
82
|
export declare function parseOtlpHeaders(text: string | undefined): Record<string, string>;
|
|
51
83
|
/** `k1=v1,k2=v2` resource attributes, the format of `OTEL_RESOURCE_ATTRIBUTES`. */
|
|
@@ -61,5 +93,21 @@ export declare function otlpFromEnv(env: Record<string, string | undefined>, def
|
|
|
61
93
|
serviceName: string;
|
|
62
94
|
serviceVersion?: string;
|
|
63
95
|
}): OtlpOptions | null;
|
|
96
|
+
/**
|
|
97
|
+
* The same for traces: `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (full URL of /v1/traces) or
|
|
98
|
+
* `OTEL_EXPORTER_OTLP_ENDPOINT`; the `…_TRACES_…` headers and protocol; null also when
|
|
99
|
+
* `OTEL_TRACES_EXPORTER=none`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function otlpTracesFromEnv(env: Record<string, string | undefined>, defaults: {
|
|
102
|
+
serviceName: string;
|
|
103
|
+
serviceVersion?: string;
|
|
104
|
+
}): OtlpOptions | null;
|
|
105
|
+
/**
|
|
106
|
+
* The share of new traces to keep, from `OTEL_TRACES_SAMPLER` and `OTEL_TRACES_SAMPLER_ARG`
|
|
107
|
+
* (`always_on`, `always_off`, `traceidratio`, and their `parentbased_` forms: a trace continued
|
|
108
|
+
* from a caller always follows the caller); undefined when they say nothing usable.
|
|
109
|
+
*/
|
|
110
|
+
export declare function samplerRatioFromEnv(env: Record<string, string | undefined>): number | undefined;
|
|
64
111
|
/** `http/protobuf` or `http/json` from a setting or variable; undefined for anything else. */
|
|
65
112
|
export declare function otlpProtocol(v: string | undefined): OtlpProtocol | undefined;
|
|
113
|
+
export {};
|
package/dist/api/redact.d.cts
CHANGED
|
@@ -15,3 +15,28 @@ export declare function redactToolCall(tool: string, args: Record<string, unknow
|
|
|
15
15
|
args: Record<string, unknown>;
|
|
16
16
|
value: unknown;
|
|
17
17
|
};
|
|
18
|
+
/** How many characters of a recorded call's result, and of each of its arguments, are kept. */
|
|
19
|
+
export declare const RECORDED_CHARS: {
|
|
20
|
+
readonly value: 1000;
|
|
21
|
+
readonly arg: 300;
|
|
22
|
+
};
|
|
23
|
+
/** A value as a recorded call keeps it: a text, or an object's JSON, longer than `n` characters is cut (with "…"). */
|
|
24
|
+
export declare function cutRecorded(v: unknown, n: number): unknown;
|
|
25
|
+
/** A result object in short: its first 30 fields, lists as their length, texts cut at 200 characters, nothing nested. */
|
|
26
|
+
export declare function summarizeRecorded(v: Record<string, unknown>): Record<string, unknown>;
|
|
27
|
+
/** An object that is no list. */
|
|
28
|
+
export declare function isPlainObject(v: unknown): v is Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* A call (secrets already removed) as a reporter sends it to an engine that takes it cut: the
|
|
31
|
+
* arguments and the value cut as the engine cuts them, and the summary of a result object, which
|
|
32
|
+
* the cut value may no longer give. The engine records the same event as from the whole call.
|
|
33
|
+
*/
|
|
34
|
+
export declare function cutToolCall(call: {
|
|
35
|
+
args: Record<string, unknown>;
|
|
36
|
+
ok: boolean;
|
|
37
|
+
value: unknown;
|
|
38
|
+
}): {
|
|
39
|
+
args: Record<string, unknown>;
|
|
40
|
+
value: unknown;
|
|
41
|
+
summary?: Record<string, unknown>;
|
|
42
|
+
};
|
package/dist/api/redact.d.ts
CHANGED
|
@@ -15,3 +15,28 @@ export declare function redactToolCall(tool: string, args: Record<string, unknow
|
|
|
15
15
|
args: Record<string, unknown>;
|
|
16
16
|
value: unknown;
|
|
17
17
|
};
|
|
18
|
+
/** How many characters of a recorded call's result, and of each of its arguments, are kept. */
|
|
19
|
+
export declare const RECORDED_CHARS: {
|
|
20
|
+
readonly value: 1000;
|
|
21
|
+
readonly arg: 300;
|
|
22
|
+
};
|
|
23
|
+
/** A value as a recorded call keeps it: a text, or an object's JSON, longer than `n` characters is cut (with "…"). */
|
|
24
|
+
export declare function cutRecorded(v: unknown, n: number): unknown;
|
|
25
|
+
/** A result object in short: its first 30 fields, lists as their length, texts cut at 200 characters, nothing nested. */
|
|
26
|
+
export declare function summarizeRecorded(v: Record<string, unknown>): Record<string, unknown>;
|
|
27
|
+
/** An object that is no list. */
|
|
28
|
+
export declare function isPlainObject(v: unknown): v is Record<string, unknown>;
|
|
29
|
+
/**
|
|
30
|
+
* A call (secrets already removed) as a reporter sends it to an engine that takes it cut: the
|
|
31
|
+
* arguments and the value cut as the engine cuts them, and the summary of a result object, which
|
|
32
|
+
* the cut value may no longer give. The engine records the same event as from the whole call.
|
|
33
|
+
*/
|
|
34
|
+
export declare function cutToolCall(call: {
|
|
35
|
+
args: Record<string, unknown>;
|
|
36
|
+
ok: boolean;
|
|
37
|
+
value: unknown;
|
|
38
|
+
}): {
|
|
39
|
+
args: Record<string, unknown>;
|
|
40
|
+
value: unknown;
|
|
41
|
+
summary?: Record<string, unknown>;
|
|
42
|
+
};
|
package/dist/api/tokens.d.cts
CHANGED
|
@@ -3,5 +3,10 @@
|
|
|
3
3
|
* per 4 letters, numbers one per 3 digits, every other symbol (JSON punctuation, quotes, …) one.
|
|
4
4
|
* Close to real tokenizers on JSON and on Italian/English prose (within ~15%); good for telling
|
|
5
5
|
* which tools and sessions fill the context, not for billing.
|
|
6
|
+
*
|
|
7
|
+
* One pass over the text, character by character: a run of letters (`\p{L}`) or of digits
|
|
8
|
+
* (`\p{N}`) is one word or number, its length counted in UTF-16 units; white space (`\s`) counts
|
|
9
|
+
* nothing; any other character counts one.
|
|
6
10
|
*/
|
|
7
11
|
export declare function estimateTokens(text: string): number;
|
|
12
|
+
export declare const ASTRAL_KEPT = 4096;
|
package/dist/api/tokens.d.ts
CHANGED
|
@@ -3,5 +3,10 @@
|
|
|
3
3
|
* per 4 letters, numbers one per 3 digits, every other symbol (JSON punctuation, quotes, …) one.
|
|
4
4
|
* Close to real tokenizers on JSON and on Italian/English prose (within ~15%); good for telling
|
|
5
5
|
* which tools and sessions fill the context, not for billing.
|
|
6
|
+
*
|
|
7
|
+
* One pass over the text, character by character: a run of letters (`\p{L}`) or of digits
|
|
8
|
+
* (`\p{N}`) is one word or number, its length counted in UTF-16 units; white space (`\s`) counts
|
|
9
|
+
* nothing; any other character counts one.
|
|
6
10
|
*/
|
|
7
11
|
export declare function estimateTokens(text: string): number;
|
|
12
|
+
export declare const ASTRAL_KEPT = 4096;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W3C Trace Context and a small tracer, with no dependency, for programs that call the engine:
|
|
3
|
+
* the MCP server (`datanotes mcp`), apps, scripts. A program continues its own trace in the
|
|
4
|
+
* engine by sending `traceparent` (and `tracestate`) with its requests: `DatanotesClient` does it
|
|
5
|
+
* with its `trace` option, or makes a CLIENT span per request with its `tracer` option.
|
|
6
|
+
*
|
|
7
|
+
* The spans go to an exporter, usually `OtlpTraceExporter` (otlp.ts). Unlike the engine's tracer,
|
|
8
|
+
* this one keeps no context across `await`: pass the parent explicitly, so it runs anywhere
|
|
9
|
+
* (Node, browsers, Obsidian).
|
|
10
|
+
*/
|
|
11
|
+
export type SpanKind = "internal" | "server" | "client" | "producer" | "consumer";
|
|
12
|
+
export type SpanStatusCode = "unset" | "ok" | "error";
|
|
13
|
+
type AttrValue = string | number | boolean | null | undefined;
|
|
14
|
+
/** A position in a trace: what `traceparent` carries. */
|
|
15
|
+
export interface TraceContext {
|
|
16
|
+
/** 32 lowercase hex characters. */
|
|
17
|
+
traceId: string;
|
|
18
|
+
/** 16 lowercase hex characters: the caller's span. */
|
|
19
|
+
spanId: string;
|
|
20
|
+
/** Whether the caller records the trace (flag `01`). */
|
|
21
|
+
sampled: boolean;
|
|
22
|
+
/** The `tracestate` header, passed on as it came. */
|
|
23
|
+
traceState?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const TRACEPARENT_HEADER = "traceparent";
|
|
26
|
+
export declare const TRACESTATE_HEADER = "tracestate";
|
|
27
|
+
/**
|
|
28
|
+
* Read a `traceparent` header (and its `tracestate`); null when it is missing or invalid (an
|
|
29
|
+
* all-zero id, version `ff`, a version 00 header with extra fields), as the W3C spec says.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseTraceparent(traceparent: string | null | undefined, tracestate?: string | null): TraceContext | null;
|
|
32
|
+
/** The `traceparent` header of a context (version 00). */
|
|
33
|
+
export declare function formatTraceparent(ctx: TraceContext): string;
|
|
34
|
+
/** The headers that continue `ctx` in another process: `traceparent`, and `tracestate` when there is one. */
|
|
35
|
+
export declare function traceHeaders(ctx: TraceContext): Record<string, string>;
|
|
36
|
+
/** A new random trace id (32 hex characters). */
|
|
37
|
+
export declare const newTraceId: () => string;
|
|
38
|
+
/** A new random span id (16 hex characters). */
|
|
39
|
+
export declare const newSpanId: () => string;
|
|
40
|
+
/** A finished span, as `OtlpTraceExporter` sends it (times are Unix ms, with a fraction). */
|
|
41
|
+
export interface SpanRecord {
|
|
42
|
+
traceId: string;
|
|
43
|
+
spanId: string;
|
|
44
|
+
parentSpanId?: string;
|
|
45
|
+
traceState?: string;
|
|
46
|
+
name: string;
|
|
47
|
+
kind: SpanKind;
|
|
48
|
+
startMs: number;
|
|
49
|
+
endMs: number;
|
|
50
|
+
attributes: Record<string, AttrValue>;
|
|
51
|
+
events: {
|
|
52
|
+
name: string;
|
|
53
|
+
timeMs: number;
|
|
54
|
+
attributes: Record<string, AttrValue>;
|
|
55
|
+
}[];
|
|
56
|
+
status: {
|
|
57
|
+
code: SpanStatusCode;
|
|
58
|
+
message?: string;
|
|
59
|
+
};
|
|
60
|
+
droppedAttributes?: number;
|
|
61
|
+
droppedEvents?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface TracerOptions {
|
|
64
|
+
/** Where finished spans go, e.g. `(s) => exporter.export(s)` of an `OtlpTraceExporter`. */
|
|
65
|
+
export(spans: SpanRecord[]): void;
|
|
66
|
+
/** Share of new traces kept, 0 to 1 (default 1); a trace continued from a parent follows the parent. */
|
|
67
|
+
sampleRatio?: number;
|
|
68
|
+
/** Unix time in ms (default: `performance` when there is one, else `Date.now`). */
|
|
69
|
+
now?: () => number;
|
|
70
|
+
}
|
|
71
|
+
/** One operation of a program, timed; `end()` sends it. Not sampled: `recording` is false and nothing is sent. */
|
|
72
|
+
export declare class TraceSpan {
|
|
73
|
+
private readonly tracer;
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly kind: SpanKind;
|
|
76
|
+
readonly parent: TraceContext | null;
|
|
77
|
+
readonly recording: boolean;
|
|
78
|
+
readonly context: TraceContext;
|
|
79
|
+
private readonly startMs;
|
|
80
|
+
private readonly attributes;
|
|
81
|
+
private readonly events;
|
|
82
|
+
private status;
|
|
83
|
+
private ended;
|
|
84
|
+
constructor(tracer: Tracer, name: string, kind: SpanKind, parent: TraceContext | null, recording: boolean, attributes: Record<string, AttrValue>);
|
|
85
|
+
setAttribute(key: string, value: AttrValue): this;
|
|
86
|
+
setAttributes(attributes: Record<string, AttrValue>): this;
|
|
87
|
+
addEvent(name: string, attributes?: Record<string, AttrValue>): this;
|
|
88
|
+
/** An `exception` event, `error.type` and status ERROR. */
|
|
89
|
+
recordException(e: unknown): this;
|
|
90
|
+
setStatus(code: SpanStatusCode, message?: string): this;
|
|
91
|
+
end(): void;
|
|
92
|
+
}
|
|
93
|
+
/** Makes spans with explicit parents and hands them to an exporter. Never throws. */
|
|
94
|
+
export declare class Tracer {
|
|
95
|
+
private readonly o;
|
|
96
|
+
readonly now: () => number;
|
|
97
|
+
constructor(o: TracerOptions);
|
|
98
|
+
/** A new span: a child of `parent` (a context or a `traceparent` header), or a new trace. */
|
|
99
|
+
startSpan(name: string, opts?: {
|
|
100
|
+
kind?: SpanKind;
|
|
101
|
+
parent?: TraceContext | string | null;
|
|
102
|
+
attributes?: Record<string, AttrValue>;
|
|
103
|
+
}): TraceSpan;
|
|
104
|
+
/** @internal */
|
|
105
|
+
send(span: SpanRecord): void;
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* W3C Trace Context and a small tracer, with no dependency, for programs that call the engine:
|
|
3
|
+
* the MCP server (`datanotes mcp`), apps, scripts. A program continues its own trace in the
|
|
4
|
+
* engine by sending `traceparent` (and `tracestate`) with its requests: `DatanotesClient` does it
|
|
5
|
+
* with its `trace` option, or makes a CLIENT span per request with its `tracer` option.
|
|
6
|
+
*
|
|
7
|
+
* The spans go to an exporter, usually `OtlpTraceExporter` (otlp.ts). Unlike the engine's tracer,
|
|
8
|
+
* this one keeps no context across `await`: pass the parent explicitly, so it runs anywhere
|
|
9
|
+
* (Node, browsers, Obsidian).
|
|
10
|
+
*/
|
|
11
|
+
export type SpanKind = "internal" | "server" | "client" | "producer" | "consumer";
|
|
12
|
+
export type SpanStatusCode = "unset" | "ok" | "error";
|
|
13
|
+
type AttrValue = string | number | boolean | null | undefined;
|
|
14
|
+
/** A position in a trace: what `traceparent` carries. */
|
|
15
|
+
export interface TraceContext {
|
|
16
|
+
/** 32 lowercase hex characters. */
|
|
17
|
+
traceId: string;
|
|
18
|
+
/** 16 lowercase hex characters: the caller's span. */
|
|
19
|
+
spanId: string;
|
|
20
|
+
/** Whether the caller records the trace (flag `01`). */
|
|
21
|
+
sampled: boolean;
|
|
22
|
+
/** The `tracestate` header, passed on as it came. */
|
|
23
|
+
traceState?: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const TRACEPARENT_HEADER = "traceparent";
|
|
26
|
+
export declare const TRACESTATE_HEADER = "tracestate";
|
|
27
|
+
/**
|
|
28
|
+
* Read a `traceparent` header (and its `tracestate`); null when it is missing or invalid (an
|
|
29
|
+
* all-zero id, version `ff`, a version 00 header with extra fields), as the W3C spec says.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseTraceparent(traceparent: string | null | undefined, tracestate?: string | null): TraceContext | null;
|
|
32
|
+
/** The `traceparent` header of a context (version 00). */
|
|
33
|
+
export declare function formatTraceparent(ctx: TraceContext): string;
|
|
34
|
+
/** The headers that continue `ctx` in another process: `traceparent`, and `tracestate` when there is one. */
|
|
35
|
+
export declare function traceHeaders(ctx: TraceContext): Record<string, string>;
|
|
36
|
+
/** A new random trace id (32 hex characters). */
|
|
37
|
+
export declare const newTraceId: () => string;
|
|
38
|
+
/** A new random span id (16 hex characters). */
|
|
39
|
+
export declare const newSpanId: () => string;
|
|
40
|
+
/** A finished span, as `OtlpTraceExporter` sends it (times are Unix ms, with a fraction). */
|
|
41
|
+
export interface SpanRecord {
|
|
42
|
+
traceId: string;
|
|
43
|
+
spanId: string;
|
|
44
|
+
parentSpanId?: string;
|
|
45
|
+
traceState?: string;
|
|
46
|
+
name: string;
|
|
47
|
+
kind: SpanKind;
|
|
48
|
+
startMs: number;
|
|
49
|
+
endMs: number;
|
|
50
|
+
attributes: Record<string, AttrValue>;
|
|
51
|
+
events: {
|
|
52
|
+
name: string;
|
|
53
|
+
timeMs: number;
|
|
54
|
+
attributes: Record<string, AttrValue>;
|
|
55
|
+
}[];
|
|
56
|
+
status: {
|
|
57
|
+
code: SpanStatusCode;
|
|
58
|
+
message?: string;
|
|
59
|
+
};
|
|
60
|
+
droppedAttributes?: number;
|
|
61
|
+
droppedEvents?: number;
|
|
62
|
+
}
|
|
63
|
+
export interface TracerOptions {
|
|
64
|
+
/** Where finished spans go, e.g. `(s) => exporter.export(s)` of an `OtlpTraceExporter`. */
|
|
65
|
+
export(spans: SpanRecord[]): void;
|
|
66
|
+
/** Share of new traces kept, 0 to 1 (default 1); a trace continued from a parent follows the parent. */
|
|
67
|
+
sampleRatio?: number;
|
|
68
|
+
/** Unix time in ms (default: `performance` when there is one, else `Date.now`). */
|
|
69
|
+
now?: () => number;
|
|
70
|
+
}
|
|
71
|
+
/** One operation of a program, timed; `end()` sends it. Not sampled: `recording` is false and nothing is sent. */
|
|
72
|
+
export declare class TraceSpan {
|
|
73
|
+
private readonly tracer;
|
|
74
|
+
readonly name: string;
|
|
75
|
+
readonly kind: SpanKind;
|
|
76
|
+
readonly parent: TraceContext | null;
|
|
77
|
+
readonly recording: boolean;
|
|
78
|
+
readonly context: TraceContext;
|
|
79
|
+
private readonly startMs;
|
|
80
|
+
private readonly attributes;
|
|
81
|
+
private readonly events;
|
|
82
|
+
private status;
|
|
83
|
+
private ended;
|
|
84
|
+
constructor(tracer: Tracer, name: string, kind: SpanKind, parent: TraceContext | null, recording: boolean, attributes: Record<string, AttrValue>);
|
|
85
|
+
setAttribute(key: string, value: AttrValue): this;
|
|
86
|
+
setAttributes(attributes: Record<string, AttrValue>): this;
|
|
87
|
+
addEvent(name: string, attributes?: Record<string, AttrValue>): this;
|
|
88
|
+
/** An `exception` event, `error.type` and status ERROR. */
|
|
89
|
+
recordException(e: unknown): this;
|
|
90
|
+
setStatus(code: SpanStatusCode, message?: string): this;
|
|
91
|
+
end(): void;
|
|
92
|
+
}
|
|
93
|
+
/** Makes spans with explicit parents and hands them to an exporter. Never throws. */
|
|
94
|
+
export declare class Tracer {
|
|
95
|
+
private readonly o;
|
|
96
|
+
readonly now: () => number;
|
|
97
|
+
constructor(o: TracerOptions);
|
|
98
|
+
/** A new span: a child of `parent` (a context or a `traceparent` header), or a new trace. */
|
|
99
|
+
startSpan(name: string, opts?: {
|
|
100
|
+
kind?: SpanKind;
|
|
101
|
+
parent?: TraceContext | string | null;
|
|
102
|
+
attributes?: Record<string, AttrValue>;
|
|
103
|
+
}): TraceSpan;
|
|
104
|
+
/** @internal */
|
|
105
|
+
send(span: SpanRecord): void;
|
|
106
|
+
}
|
|
107
|
+
export {};
|