datanotes 3.0.0 → 3.1.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.
Files changed (60) hide show
  1. package/README.md +1 -5
  2. package/dist/api/client.d.cts +37 -4
  3. package/dist/api/client.d.ts +37 -4
  4. package/dist/api/index.cjs +388 -52
  5. package/dist/api/index.d.cts +3 -2
  6. package/dist/api/index.d.ts +3 -2
  7. package/dist/api/index.js +388 -52
  8. package/dist/api/mcp.cjs +6 -3
  9. package/dist/api/mcp.js +6 -3
  10. package/dist/api/otlp.d.cts +63 -15
  11. package/dist/api/otlp.d.ts +63 -15
  12. package/dist/api/redact.d.cts +25 -0
  13. package/dist/api/redact.d.ts +25 -0
  14. package/dist/api/tokens.d.cts +5 -0
  15. package/dist/api/tokens.d.ts +5 -0
  16. package/dist/api/tracing.d.cts +107 -0
  17. package/dist/api/tracing.d.ts +107 -0
  18. package/dist/datanotes.cjs +9380 -2554
  19. package/dist/docs/administration/limits.md +96 -12
  20. package/dist/docs/administration/run-the-service.md +18 -0
  21. package/dist/docs/api/operations/graph_neighbors.md +4 -2
  22. package/dist/docs/api/operations/graph_path.md +3 -3
  23. package/dist/docs/api/operations/graph_traverse.md +2 -2
  24. package/dist/docs/api/operations/record_tool_call.md +1 -0
  25. package/dist/docs/api/operations/tags/queries.md +2 -2
  26. package/dist/docs/api.md +3 -3
  27. package/dist/docs/develop/concurrency.md +36 -1
  28. package/dist/docs/develop/http-api.md +11 -1
  29. package/dist/docs/develop/telemetry.md +224 -25
  30. package/dist/docs/guides/data-quality/check-constraints.md +10 -10
  31. package/dist/docs/guides/data-quality/hand-edits.md +8 -8
  32. package/dist/docs/guides/database-objects/bases.md +11 -11
  33. package/dist/docs/guides/database-objects/catalogs-and-schemas.md +10 -10
  34. package/dist/docs/guides/database-objects/columns.md +38 -38
  35. package/dist/docs/guides/database-objects/relations.md +27 -27
  36. package/dist/docs/guides/database-objects/tables.md +37 -101
  37. package/dist/docs/guides/database-objects/views.md +44 -44
  38. package/dist/docs/guides/history/back-up.md +12 -4
  39. package/dist/docs/guides/history/change-data-feed.md +34 -34
  40. package/dist/docs/guides/history/journal-and-undo.md +12 -12
  41. package/dist/docs/guides/history/restore.md +20 -20
  42. package/dist/docs/guides/history/table-history.md +31 -31
  43. package/dist/docs/guides/history/vacuum.md +1 -10
  44. package/dist/docs/guides/read-and-write/automatic-links.md +15 -15
  45. package/dist/docs/guides/read-and-write/import-notes.md +20 -20
  46. package/dist/docs/guides/read-and-write/joins-and-aggregates.md +7 -7
  47. package/dist/docs/guides/read-and-write/read-and-filter.md +10 -10
  48. package/dist/docs/guides/read-and-write/write-rows.md +10 -10
  49. package/dist/docs/guides/search/link-graph.md +95 -0
  50. package/dist/docs/guides/search/text.md +1 -1
  51. package/dist/docs/guides/security/who-did-what.md +2 -0
  52. package/dist/docs/reference/cli.md +10 -3
  53. package/dist/docs/reference/compatibility.md +33 -13
  54. package/dist/docs/reference/operations/queries.md +3 -3
  55. package/dist/docs/reference/operations.md +11 -11
  56. package/dist/docs/reference/settings.md +37 -25
  57. package/dist/docs/release-notes.md +121 -0
  58. package/dist/docs/start/how-it-works.md +35 -3
  59. package/dist/docs/start/quick-start.md +2 -0
  60. package/package.json +3 -2
package/README.md CHANGED
@@ -25,7 +25,7 @@ Datanotes keeps every row as a file, so it isn't a replacement for SQLite or Pos
25
25
  - High write throughput
26
26
  - Many concurrent writers on one folder
27
27
 
28
- Datanotes is comfortable at 10,000 notes. At 50,000 notes, the engine takes 22 to 115 seconds to start.
28
+ Datanotes is comfortable at 10,000 notes. At 50,000 notes, the engine takes about 15 seconds for its first start, and 2 to 3 seconds to restart.
29
29
 
30
30
  ## Quick start
31
31
 
@@ -214,10 +214,6 @@ console.log(films.value);
214
214
 
215
215
  Each film is now a note, `main/public/film/Nosferatu.md`, with the values in its front matter. The [JavaScript client](https://datanotes.dev/develop/client/) page covers the rest of the client.
216
216
 
217
- ## Stability: Datanotes 3 stays 3
218
-
219
- Every 3.x version adds to what you use and never takes it away. Operations, arguments, answer fields, routes, commands and settings keep working the same way. [Compatibility](https://datanotes.dev/reference/compatibility/) explains the promise and how the tests enforce it.
220
-
221
217
  ## Learn more
222
218
 
223
219
  - [Documentation](https://datanotes.dev)
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { type OperationResult } from "./results.cjs";
7
7
  import { type Guidance } from "./guidance.cjs";
8
+ import { type TraceContext, type Tracer } from "./tracing.cjs";
8
9
  export interface HttpRequest {
9
10
  url: string;
10
11
  method: "GET" | "POST";
@@ -45,7 +46,17 @@ export interface ClientOptions {
45
46
  /** Recorded with every write unless a call names another actor. */
46
47
  actor?: ActorInfo;
47
48
  transport?: Transport;
49
+ /**
50
+ * The trace the requests continue (W3C Trace Context): a context, a `traceparent` header, or a
51
+ * function that returns the current one. Sent as `traceparent` (and `tracestate`), so the
52
+ * engine's spans join the caller's trace.
53
+ */
54
+ trace?: TraceParent | (() => TraceParent | undefined);
55
+ /** Make a CLIENT span for each request (child of `trace`), and send that span as the parent. */
56
+ tracer?: Tracer;
48
57
  }
58
+ /** Where a request sits in a trace: a context, or a `traceparent` header value. */
59
+ export type TraceParent = TraceContext | string;
49
60
  /** One tool call by an agent (an engine operation, or a tool of the MCP server's own), for the engine's change feed. */
50
61
  export interface ToolCallRecord {
51
62
  tool: string;
@@ -58,6 +69,17 @@ export interface ToolCallRecord {
58
69
  session?: string;
59
70
  result_chars?: number;
60
71
  result_tokens?: number;
72
+ /**
73
+ * The result's summary, when `value` is sent already cut (redact.ts `cutToolCall`): an engine
74
+ * that answers `takes_summary: true` records it.
75
+ */
76
+ summary?: Record<string, unknown>;
77
+ }
78
+ /** What the engine answers a recorded tool call. */
79
+ export interface RecordedToolCall {
80
+ ok: boolean;
81
+ /** The engine records a `value` sent cut with its `summary` (engines before 3.1 leave it out). */
82
+ takes_summary?: boolean;
61
83
  }
62
84
  export declare const fetchTransport: Transport;
63
85
  export declare class DatanotesClient {
@@ -65,10 +87,16 @@ export declare class DatanotesClient {
65
87
  readonly url: string;
66
88
  private readonly send;
67
89
  constructor(o: ClientOptions);
68
- /** Send a request; the answer's status, its JSON (when it is JSON) and its text. */
90
+ /** The parent of a request: the call's own `trace`, else the client's. */
91
+ private parentOf;
92
+ /**
93
+ * Send a request; the answer's status, its JSON (when it is JSON) and its text. `trace`: the
94
+ * trace this request continues (over the client's `trace` option).
95
+ */
69
96
  request(method: "GET" | "POST", path: string, body?: unknown, opts?: {
70
97
  actor?: ActorInfo;
71
98
  accept?: string;
99
+ trace?: TraceParent;
72
100
  }): Promise<{
73
101
  status: number;
74
102
  json: unknown;
@@ -81,9 +109,14 @@ export declare class DatanotesClient {
81
109
  * Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
82
110
  * with the same message the engine gives.
83
111
  */
84
- call(name: string, args?: Record<string, unknown>, actor?: ActorInfo): Promise<OperationResult>;
112
+ call(name: string, args?: Record<string, unknown>, actor?: ActorInfo, options?: {
113
+ trace?: TraceParent;
114
+ }): Promise<OperationResult>;
85
115
  /** True when the engine answers `GET /` (no token needed). */
86
116
  ping(): Promise<boolean>;
87
- /** Record an agent's tool call in the change feed (what MCP servers report). */
88
- recordToolCall(call: ToolCallRecord, actor?: ActorInfo): Promise<void>;
117
+ /**
118
+ * Record an agent's tool call in the change feed (what MCP servers report). Answers what the
119
+ * engine said: `takes_summary` when it records a `value` sent cut with its `summary`.
120
+ */
121
+ recordToolCall(call: ToolCallRecord, actor?: ActorInfo): Promise<RecordedToolCall>;
89
122
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { type OperationResult } from "./results.js";
7
7
  import { type Guidance } from "./guidance.js";
8
+ import { type TraceContext, type Tracer } from "./tracing.js";
8
9
  export interface HttpRequest {
9
10
  url: string;
10
11
  method: "GET" | "POST";
@@ -45,7 +46,17 @@ export interface ClientOptions {
45
46
  /** Recorded with every write unless a call names another actor. */
46
47
  actor?: ActorInfo;
47
48
  transport?: Transport;
49
+ /**
50
+ * The trace the requests continue (W3C Trace Context): a context, a `traceparent` header, or a
51
+ * function that returns the current one. Sent as `traceparent` (and `tracestate`), so the
52
+ * engine's spans join the caller's trace.
53
+ */
54
+ trace?: TraceParent | (() => TraceParent | undefined);
55
+ /** Make a CLIENT span for each request (child of `trace`), and send that span as the parent. */
56
+ tracer?: Tracer;
48
57
  }
58
+ /** Where a request sits in a trace: a context, or a `traceparent` header value. */
59
+ export type TraceParent = TraceContext | string;
49
60
  /** One tool call by an agent (an engine operation, or a tool of the MCP server's own), for the engine's change feed. */
50
61
  export interface ToolCallRecord {
51
62
  tool: string;
@@ -58,6 +69,17 @@ export interface ToolCallRecord {
58
69
  session?: string;
59
70
  result_chars?: number;
60
71
  result_tokens?: number;
72
+ /**
73
+ * The result's summary, when `value` is sent already cut (redact.ts `cutToolCall`): an engine
74
+ * that answers `takes_summary: true` records it.
75
+ */
76
+ summary?: Record<string, unknown>;
77
+ }
78
+ /** What the engine answers a recorded tool call. */
79
+ export interface RecordedToolCall {
80
+ ok: boolean;
81
+ /** The engine records a `value` sent cut with its `summary` (engines before 3.1 leave it out). */
82
+ takes_summary?: boolean;
61
83
  }
62
84
  export declare const fetchTransport: Transport;
63
85
  export declare class DatanotesClient {
@@ -65,10 +87,16 @@ export declare class DatanotesClient {
65
87
  readonly url: string;
66
88
  private readonly send;
67
89
  constructor(o: ClientOptions);
68
- /** Send a request; the answer's status, its JSON (when it is JSON) and its text. */
90
+ /** The parent of a request: the call's own `trace`, else the client's. */
91
+ private parentOf;
92
+ /**
93
+ * Send a request; the answer's status, its JSON (when it is JSON) and its text. `trace`: the
94
+ * trace this request continues (over the client's `trace` option).
95
+ */
69
96
  request(method: "GET" | "POST", path: string, body?: unknown, opts?: {
70
97
  actor?: ActorInfo;
71
98
  accept?: string;
99
+ trace?: TraceParent;
72
100
  }): Promise<{
73
101
  status: number;
74
102
  json: unknown;
@@ -81,9 +109,14 @@ export declare class DatanotesClient {
81
109
  * Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
82
110
  * with the same message the engine gives.
83
111
  */
84
- call(name: string, args?: Record<string, unknown>, actor?: ActorInfo): Promise<OperationResult>;
112
+ call(name: string, args?: Record<string, unknown>, actor?: ActorInfo, options?: {
113
+ trace?: TraceParent;
114
+ }): Promise<OperationResult>;
85
115
  /** True when the engine answers `GET /` (no token needed). */
86
116
  ping(): Promise<boolean>;
87
- /** Record an agent's tool call in the change feed (what MCP servers report). */
88
- recordToolCall(call: ToolCallRecord, actor?: ActorInfo): Promise<void>;
117
+ /**
118
+ * Record an agent's tool call in the change feed (what MCP servers report). Answers what the
119
+ * engine said: `takes_summary` when it records a `value` sent cut with its `summary`.
120
+ */
121
+ recordToolCall(call: ToolCallRecord, actor?: ActorInfo): Promise<RecordedToolCall>;
89
122
  }