datanotes 2.0.1 → 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.
- package/NOTICE +9 -0
- package/README.md +203 -28
- package/SECURITY.md +92 -45
- package/dist/THIRD-PARTY-NOTICES.txt +682 -0
- package/dist/api/catalog.d.cts +69 -0
- package/dist/api/catalog.d.ts +50 -2
- package/dist/api/cli-options.d.cts +39 -0
- package/dist/api/cli-options.d.ts +39 -0
- package/dist/api/client.d.cts +122 -0
- package/dist/api/client.d.ts +56 -34
- package/dist/api/docs.d.cts +211 -0
- package/dist/api/docs.d.ts +211 -0
- package/dist/api/guidance.d.cts +81 -0
- package/dist/api/guidance.d.ts +81 -0
- package/dist/api/index.cjs +7470 -2771
- package/dist/api/index.d.cts +14 -0
- package/dist/api/index.d.ts +11 -7
- package/dist/api/index.js +7470 -2771
- package/dist/api/local.cjs +118 -6
- package/dist/api/local.d.cts +95 -0
- package/dist/api/local.d.ts +70 -6
- package/dist/api/local.js +104 -6
- package/dist/api/mcp.cjs +17387 -0
- package/dist/api/mcp.d.cts +108 -0
- package/dist/api/mcp.d.ts +108 -0
- package/dist/api/mcp.js +17337 -0
- package/dist/api/otlp.d.cts +113 -0
- package/dist/api/otlp.d.ts +63 -15
- package/dist/api/redact.d.cts +42 -0
- package/dist/api/redact.d.ts +42 -0
- package/dist/api/requests.d.cts +26 -0
- package/dist/api/requests.d.ts +14 -16
- package/dist/api/results.d.cts +16 -0
- package/dist/api/results.d.ts +2 -1
- package/dist/api/tokens.d.cts +12 -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 +69597 -28329
- package/dist/docs/administration/configuration.md +59 -0
- package/dist/docs/administration/docker.md +80 -0
- package/dist/docs/administration/git-sync.md +71 -0
- package/dist/docs/administration/limits.md +153 -0
- package/dist/docs/administration/run-the-service.md +237 -0
- package/dist/docs/administration/status.md +61 -0
- package/dist/docs/administration/use-with-obsidian.md +75 -0
- package/dist/docs/api/operations/add_column.md +49 -0
- package/dist/docs/api/operations/add_constraint.md +55 -0
- package/dist/docs/api/operations/adopt_rows.md +50 -0
- package/dist/docs/api/operations/align_relations.md +41 -0
- package/dist/docs/api/operations/alter_column.md +46 -0
- package/dist/docs/api/operations/alter_table.md +67 -0
- package/dist/docs/api/operations/batch.md +48 -0
- package/dist/docs/api/operations/changes_stream.md +28 -0
- package/dist/docs/api/operations/check_table.md +29 -0
- package/dist/docs/api/operations/clone_table.md +48 -0
- package/dist/docs/api/operations/comment_on.md +42 -0
- package/dist/docs/api/operations/configure_database.md +52 -0
- package/dist/docs/api/operations/create_table.md +78 -0
- package/dist/docs/api/operations/create_view.md +54 -0
- package/dist/docs/api/operations/create_webhook.md +37 -0
- package/dist/docs/api/operations/define_base.md +52 -0
- package/dist/docs/api/operations/delete_rows.md +43 -0
- package/dist/docs/api/operations/delete_webhook.md +31 -0
- package/dist/docs/api/operations/describe_database.md +30 -0
- package/dist/docs/api/operations/describe_history.md +40 -0
- package/dist/docs/api/operations/describe_semantic_index.md +24 -0
- package/dist/docs/api/operations/describe_table.md +38 -0
- package/dist/docs/api/operations/docs.md +13 -0
- package/dist/docs/api/operations/drop_column.md +41 -0
- package/dist/docs/api/operations/drop_constraint.md +39 -0
- package/dist/docs/api/operations/drop_table.md +43 -0
- package/dist/docs/api/operations/drop_view.md +38 -0
- package/dist/docs/api/operations/engine_status.md +23 -0
- package/dist/docs/api/operations/graph_neighbors.md +34 -0
- package/dist/docs/api/operations/graph_path.md +32 -0
- package/dist/docs/api/operations/graph_traverse.md +43 -0
- package/dist/docs/api/operations/identify_session.md +24 -0
- package/dist/docs/api/operations/infer_table.md +43 -0
- package/dist/docs/api/operations/insert_row.md +48 -0
- package/dist/docs/api/operations/list_changes.md +35 -0
- package/dist/docs/api/operations/list_folder.md +28 -0
- package/dist/docs/api/operations/list_link_targets.md +44 -0
- package/dist/docs/api/operations/list_migrations.md +35 -0
- package/dist/docs/api/operations/list_tables.md +32 -0
- package/dist/docs/api/operations/list_webhooks.md +23 -0
- package/dist/docs/api/operations/manual_index.md +14 -0
- package/dist/docs/api/operations/manual_page.md +22 -0
- package/dist/docs/api/operations/merge_rows.md +44 -0
- package/dist/docs/api/operations/move_rows.md +52 -0
- package/dist/docs/api/operations/openapi.md +13 -0
- package/dist/docs/api/operations/openapi_post.md +20 -0
- package/dist/docs/api/operations/read_note.md +29 -0
- package/dist/docs/api/operations/recompute_columns.md +44 -0
- package/dist/docs/api/operations/record_tool_call.md +37 -0
- package/dist/docs/api/operations/rename_column.md +44 -0
- package/dist/docs/api/operations/rename_value.md +45 -0
- package/dist/docs/api/operations/restore_database.md +51 -0
- package/dist/docs/api/operations/restore_table.md +46 -0
- package/dist/docs/api/operations/search_notes.md +28 -0
- package/dist/docs/api/operations/select_rows.md +61 -0
- package/dist/docs/api/operations/semantic_search.md +34 -0
- package/dist/docs/api/operations/semantic_search_docs.md +26 -0
- package/dist/docs/api/operations/set_table_bases.md +44 -0
- package/dist/docs/api/operations/status.md +13 -0
- package/dist/docs/api/operations/stop_engine.md +23 -0
- package/dist/docs/api/operations/sync_semantic_index.md +33 -0
- package/dist/docs/api/operations/table_changes.md +31 -0
- package/dist/docs/api/operations/tags/auxiliary.md +14 -0
- package/dist/docs/api/operations/tags/change-feed.md +8 -0
- package/dist/docs/api/operations/tags/history.md +17 -0
- package/dist/docs/api/operations/tags/queries.md +15 -0
- package/dist/docs/api/operations/tags/rows-dml.md +16 -0
- package/dist/docs/api/operations/tags/schema-ddl.md +22 -0
- package/dist/docs/api/operations/tags/service.md +15 -0
- package/dist/docs/api/operations/tags/tokens.md +13 -0
- package/dist/docs/api/operations/tokens_create.md +34 -0
- package/dist/docs/api/operations/tokens_delete.md +29 -0
- package/dist/docs/api/operations/tokens_list.md +21 -0
- package/dist/docs/api/operations/tokens_me.md +20 -0
- package/dist/docs/api/operations/tokens_rotate.md +29 -0
- package/dist/docs/api/operations/tokens_update.md +34 -0
- package/dist/docs/api/operations/undo_migration.md +46 -0
- package/dist/docs/api/operations/update_row.md +60 -0
- package/dist/docs/api/operations/update_rows.md +46 -0
- package/dist/docs/api/operations/vacuum_table.md +37 -0
- package/dist/docs/api.md +135 -0
- package/dist/docs/develop/build-an-app.md +320 -0
- package/dist/docs/develop/build-on-datanotes.md +138 -0
- package/dist/docs/develop/change-feed-and-webhooks.md +70 -0
- package/dist/docs/develop/client.md +116 -0
- package/dist/docs/develop/concurrency.md +188 -0
- package/dist/docs/develop/http-api.md +89 -0
- package/dist/docs/develop/telemetry.md +285 -0
- package/dist/docs/guides/agents/docs-offline.md +99 -0
- package/dist/docs/guides/agents/how-agents-use-datanotes.md +124 -0
- package/dist/docs/guides/agents/prompts.md +495 -0
- package/dist/docs/guides/agents/reading-errors.md +112 -0
- package/dist/docs/guides/data-quality/check-constraints.md +379 -0
- package/dist/docs/guides/data-quality/check-table.md +63 -0
- package/dist/docs/guides/data-quality/hand-edits.md +507 -0
- package/dist/docs/guides/data-quality/sync-between-devices.md +51 -0
- package/dist/docs/guides/data-quality/validation.md +90 -0
- package/dist/docs/guides/database-objects/bases.md +480 -0
- package/dist/docs/guides/database-objects/catalogs-and-schemas.md +897 -0
- package/dist/docs/guides/database-objects/columns.md +1332 -0
- package/dist/docs/guides/database-objects/relations.md +1454 -0
- package/dist/docs/guides/database-objects/tables.md +1340 -0
- package/dist/docs/guides/database-objects/views.md +1003 -0
- package/dist/docs/guides/history/back-up.md +203 -0
- package/dist/docs/guides/history/change-data-feed.md +247 -0
- package/dist/docs/guides/history/journal-and-undo.md +262 -0
- package/dist/docs/guides/history/restore.md +341 -0
- package/dist/docs/guides/history/table-history.md +657 -0
- package/dist/docs/guides/history/vacuum.md +26 -0
- package/dist/docs/guides/read-and-write/automatic-links.md +768 -0
- package/dist/docs/guides/read-and-write/batch.md +139 -0
- package/dist/docs/guides/read-and-write/import-notes.md +896 -0
- package/dist/docs/guides/read-and-write/joins-and-aggregates.md +251 -0
- package/dist/docs/guides/read-and-write/read-and-filter.md +536 -0
- package/dist/docs/guides/read-and-write/write-rows.md +573 -0
- package/dist/docs/guides/search/link-graph.md +241 -0
- package/dist/docs/guides/search/semantic.md +133 -0
- package/dist/docs/guides/search/text.md +142 -0
- package/dist/docs/guides/security/security-model.md +110 -0
- package/dist/docs/guides/security/tokens.md +60 -0
- package/dist/docs/guides/security/who-did-what.md +44 -0
- package/dist/docs/index.md +113 -0
- package/dist/docs/llms.txt +33 -0
- package/dist/docs/reference/cli.md +143 -0
- package/dist/docs/reference/compatibility.md +83 -0
- package/dist/docs/reference/errors.md +72 -0
- package/dist/docs/reference/glossary.md +161 -0
- package/dist/docs/reference/operations/auxiliary.md +116 -0
- package/dist/docs/reference/operations/history.md +168 -0
- package/dist/docs/reference/operations/queries.md +169 -0
- package/dist/docs/reference/operations/rows.md +185 -0
- package/dist/docs/reference/operations/schema.md +316 -0
- package/dist/docs/reference/operations.md +96 -0
- package/dist/docs/reference/settings.md +43 -0
- package/dist/docs/release-notes.md +188 -0
- package/dist/docs/start/connect-agents.md +204 -0
- package/dist/docs/start/how-it-works.md +349 -0
- package/dist/docs/start/quick-start.md +128 -0
- package/package.json +60 -15
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operations of the HTTP API, described for their callers: name, description, input schema
|
|
3
|
+
* and hints. The MCP server (`datanotes mcp`, src/mcp) offers each one as a tool of the same name
|
|
4
|
+
* (the shape is MCP's tool definition); the OpenAPI document and the docs are generated from it. The route and body each
|
|
5
|
+
* one sends: `requests.ts`.
|
|
6
|
+
*/
|
|
7
|
+
export interface OperationDef {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
inputSchema: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* MCP tool hints (not part of the Datanotes 3 contract). `destructiveHint` is true for every
|
|
13
|
+
* write that may overwrite or remove existing data (values, names, definitions, settings, history)
|
|
14
|
+
* or send it out of the engine (webhooks); false only for reads and purely additive writes
|
|
15
|
+
* (tests/api-mcp.test.ts holds the list).
|
|
16
|
+
*/
|
|
17
|
+
annotations: {
|
|
18
|
+
title?: string;
|
|
19
|
+
readOnlyHint?: boolean;
|
|
20
|
+
destructiveHint?: boolean;
|
|
21
|
+
idempotentHint?: boolean;
|
|
22
|
+
openWorldHint?: boolean;
|
|
23
|
+
};
|
|
24
|
+
/** JSON Schema of the successful (2xx) response body, for the OpenAPI document; not sent to MCP clients. */
|
|
25
|
+
responseSchema?: Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Secrets in the call: the argument names and result keys never recorded (the change feed's
|
|
28
|
+
* `tool_call` events, which the store backup commits). `redactToolCall` (redact.ts) applies it.
|
|
29
|
+
*/
|
|
30
|
+
sensitive?: {
|
|
31
|
+
args?: string[];
|
|
32
|
+
result?: string[];
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export declare const OPERATIONS: OperationDef[];
|
|
36
|
+
/**
|
|
37
|
+
* The kinds of operation, as the docs' reference groups them (one page each,
|
|
38
|
+
* `reference/operations/<kind>`), like the statement kinds of a SQL reference.
|
|
39
|
+
*/
|
|
40
|
+
export declare const OPERATION_KINDS: {
|
|
41
|
+
readonly schema: {
|
|
42
|
+
readonly title: "Schema operations (DDL)";
|
|
43
|
+
readonly label: "Schema (DDL)";
|
|
44
|
+
readonly description: "Operations that define the database: tables, columns, constraints, bases and views.";
|
|
45
|
+
};
|
|
46
|
+
readonly rows: {
|
|
47
|
+
readonly title: "Row operations (DML)";
|
|
48
|
+
readonly label: "Rows (DML)";
|
|
49
|
+
readonly description: "Operations that write rows: insert, update, merge, delete, move, adopt and batch.";
|
|
50
|
+
};
|
|
51
|
+
readonly queries: {
|
|
52
|
+
readonly title: "Query operations";
|
|
53
|
+
readonly label: "Queries";
|
|
54
|
+
readonly description: "Operations that read rows and notes: select_rows, link targets, text and semantic search, the link graph.";
|
|
55
|
+
};
|
|
56
|
+
readonly history: {
|
|
57
|
+
readonly title: "History operations";
|
|
58
|
+
readonly label: "History";
|
|
59
|
+
readonly description: "Operations on the journal, a table's versions, the change feed and webhooks: undo, time travel, restore and vacuum.";
|
|
60
|
+
};
|
|
61
|
+
readonly auxiliary: {
|
|
62
|
+
readonly title: "Auxiliary operations";
|
|
63
|
+
readonly label: "Auxiliary";
|
|
64
|
+
readonly description: "Operations that describe and check the database, configure it and maintain its indexes.";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export type OperationKind = keyof typeof OPERATION_KINDS;
|
|
68
|
+
/** The kind of every operation of {@link OPERATIONS} (tests/operation-kinds.test.ts: each has exactly one). */
|
|
69
|
+
export declare const OPERATION_KIND: Readonly<Record<string, OperationKind>>;
|
package/dist/api/catalog.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The operations of the HTTP API, described for their callers: name, description, input schema
|
|
3
|
-
* and hints.
|
|
4
|
-
* definition); the OpenAPI document and the docs are generated from it. The route and body each
|
|
3
|
+
* and hints. The MCP server (`datanotes mcp`, src/mcp) offers each one as a tool of the same name
|
|
4
|
+
* (the shape is MCP's tool definition); the OpenAPI document and the docs are generated from it. The route and body each
|
|
5
5
|
* one sends: `requests.ts`.
|
|
6
6
|
*/
|
|
7
7
|
export interface OperationDef {
|
|
8
8
|
name: string;
|
|
9
9
|
description: string;
|
|
10
10
|
inputSchema: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* MCP tool hints (not part of the Datanotes 3 contract). `destructiveHint` is true for every
|
|
13
|
+
* write that may overwrite or remove existing data (values, names, definitions, settings, history)
|
|
14
|
+
* or send it out of the engine (webhooks); false only for reads and purely additive writes
|
|
15
|
+
* (tests/api-mcp.test.ts holds the list).
|
|
16
|
+
*/
|
|
11
17
|
annotations: {
|
|
12
18
|
title?: string;
|
|
13
19
|
readOnlyHint?: boolean;
|
|
@@ -17,5 +23,47 @@ export interface OperationDef {
|
|
|
17
23
|
};
|
|
18
24
|
/** JSON Schema of the successful (2xx) response body, for the OpenAPI document; not sent to MCP clients. */
|
|
19
25
|
responseSchema?: Record<string, unknown>;
|
|
26
|
+
/**
|
|
27
|
+
* Secrets in the call: the argument names and result keys never recorded (the change feed's
|
|
28
|
+
* `tool_call` events, which the store backup commits). `redactToolCall` (redact.ts) applies it.
|
|
29
|
+
*/
|
|
30
|
+
sensitive?: {
|
|
31
|
+
args?: string[];
|
|
32
|
+
result?: string[];
|
|
33
|
+
};
|
|
20
34
|
}
|
|
21
35
|
export declare const OPERATIONS: OperationDef[];
|
|
36
|
+
/**
|
|
37
|
+
* The kinds of operation, as the docs' reference groups them (one page each,
|
|
38
|
+
* `reference/operations/<kind>`), like the statement kinds of a SQL reference.
|
|
39
|
+
*/
|
|
40
|
+
export declare const OPERATION_KINDS: {
|
|
41
|
+
readonly schema: {
|
|
42
|
+
readonly title: "Schema operations (DDL)";
|
|
43
|
+
readonly label: "Schema (DDL)";
|
|
44
|
+
readonly description: "Operations that define the database: tables, columns, constraints, bases and views.";
|
|
45
|
+
};
|
|
46
|
+
readonly rows: {
|
|
47
|
+
readonly title: "Row operations (DML)";
|
|
48
|
+
readonly label: "Rows (DML)";
|
|
49
|
+
readonly description: "Operations that write rows: insert, update, merge, delete, move, adopt and batch.";
|
|
50
|
+
};
|
|
51
|
+
readonly queries: {
|
|
52
|
+
readonly title: "Query operations";
|
|
53
|
+
readonly label: "Queries";
|
|
54
|
+
readonly description: "Operations that read rows and notes: select_rows, link targets, text and semantic search, the link graph.";
|
|
55
|
+
};
|
|
56
|
+
readonly history: {
|
|
57
|
+
readonly title: "History operations";
|
|
58
|
+
readonly label: "History";
|
|
59
|
+
readonly description: "Operations on the journal, a table's versions, the change feed and webhooks: undo, time travel, restore and vacuum.";
|
|
60
|
+
};
|
|
61
|
+
readonly auxiliary: {
|
|
62
|
+
readonly title: "Auxiliary operations";
|
|
63
|
+
readonly label: "Auxiliary";
|
|
64
|
+
readonly description: "Operations that describe and check the database, configure it and maintain its indexes.";
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export type OperationKind = keyof typeof OPERATION_KINDS;
|
|
68
|
+
/** The kind of every operation of {@link OPERATIONS} (tests/operation-kinds.test.ts: each has exactly one). */
|
|
69
|
+
export declare const OPERATION_KIND: Readonly<Record<string, OperationKind>>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command line options of the `datanotes` commands: `--name value` or `--name=value` for an
|
|
3
|
+
* option with a value, `--name` for a flag. An option the command does not know is refused with
|
|
4
|
+
* the closest one, so a typo never runs a command with its defaults.
|
|
5
|
+
*/
|
|
6
|
+
export interface OptionSpec {
|
|
7
|
+
/** Options that take a value. */
|
|
8
|
+
values?: readonly string[];
|
|
9
|
+
/** Options that take none. */
|
|
10
|
+
flags?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
/** A command line the command cannot run: what is wrong, and how to write it. */
|
|
13
|
+
export declare class CliOptionError extends Error {
|
|
14
|
+
readonly hint: string;
|
|
15
|
+
readonly name = "CliOptionError";
|
|
16
|
+
/** Every command and its options. */
|
|
17
|
+
readonly docs = "https://datanotes.dev/reference/cli.md";
|
|
18
|
+
constructor(message: string, hint: string);
|
|
19
|
+
}
|
|
20
|
+
export interface Options {
|
|
21
|
+
/** The value of an option, when given. */
|
|
22
|
+
get(name: string): string | undefined;
|
|
23
|
+
/** Was a flag given? */
|
|
24
|
+
has(name: string): boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Read `argv` against what `command` takes; throws {@link CliOptionError} on anything else. */
|
|
27
|
+
export declare function readOptions(argv: readonly string[], spec: OptionSpec, command: string): Options;
|
|
28
|
+
/** The folder a command works on, and how to read it. */
|
|
29
|
+
export interface FolderArg {
|
|
30
|
+
folder: string;
|
|
31
|
+
/** `--database`: the folder is the database (metastore.yaml at its root); else a vault holding it. */
|
|
32
|
+
atRoot: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The folder of `--database` (the folder is the database) or `--vault` (a vault holding the
|
|
36
|
+
* database in a subfolder), else DATANOTES_DATABASE or DATANOTES_VAULT: one of the two, never
|
|
37
|
+
* both. Null when none is given and the command can do without (`required` false).
|
|
38
|
+
*/
|
|
39
|
+
export declare function folderArg(o: Options, env: Record<string, string | undefined>, command: string, required?: boolean): FolderArg | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command line options of the `datanotes` commands: `--name value` or `--name=value` for an
|
|
3
|
+
* option with a value, `--name` for a flag. An option the command does not know is refused with
|
|
4
|
+
* the closest one, so a typo never runs a command with its defaults.
|
|
5
|
+
*/
|
|
6
|
+
export interface OptionSpec {
|
|
7
|
+
/** Options that take a value. */
|
|
8
|
+
values?: readonly string[];
|
|
9
|
+
/** Options that take none. */
|
|
10
|
+
flags?: readonly string[];
|
|
11
|
+
}
|
|
12
|
+
/** A command line the command cannot run: what is wrong, and how to write it. */
|
|
13
|
+
export declare class CliOptionError extends Error {
|
|
14
|
+
readonly hint: string;
|
|
15
|
+
readonly name = "CliOptionError";
|
|
16
|
+
/** Every command and its options. */
|
|
17
|
+
readonly docs = "https://datanotes.dev/reference/cli.md";
|
|
18
|
+
constructor(message: string, hint: string);
|
|
19
|
+
}
|
|
20
|
+
export interface Options {
|
|
21
|
+
/** The value of an option, when given. */
|
|
22
|
+
get(name: string): string | undefined;
|
|
23
|
+
/** Was a flag given? */
|
|
24
|
+
has(name: string): boolean;
|
|
25
|
+
}
|
|
26
|
+
/** Read `argv` against what `command` takes; throws {@link CliOptionError} on anything else. */
|
|
27
|
+
export declare function readOptions(argv: readonly string[], spec: OptionSpec, command: string): Options;
|
|
28
|
+
/** The folder a command works on, and how to read it. */
|
|
29
|
+
export interface FolderArg {
|
|
30
|
+
folder: string;
|
|
31
|
+
/** `--database`: the folder is the database (metastore.yaml at its root); else a vault holding it. */
|
|
32
|
+
atRoot: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The folder of `--database` (the folder is the database) or `--vault` (a vault holding the
|
|
36
|
+
* database in a subfolder), else DATANOTES_DATABASE or DATANOTES_VAULT: one of the two, never
|
|
37
|
+
* both. Null when none is given and the command can do without (`required` false).
|
|
38
|
+
*/
|
|
39
|
+
export declare function folderArg(o: Options, env: Record<string, string | undefined>, command: string, required?: boolean): FolderArg | null;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A client of the Datanotes HTTP API, with no dependency: it runs in Node, in browsers and in
|
|
3
|
+
* Obsidian (pass Obsidian's `requestUrl` as the transport). `call` runs an operation of the
|
|
4
|
+
* catalogue by name, the way agents name them; `request` reaches any route.
|
|
5
|
+
*/
|
|
6
|
+
import { type OperationResult } from "./results.cjs";
|
|
7
|
+
import { type Guidance } from "./guidance.cjs";
|
|
8
|
+
import { type TraceContext, type Tracer } from "./tracing.cjs";
|
|
9
|
+
export interface HttpRequest {
|
|
10
|
+
url: string;
|
|
11
|
+
method: "GET" | "POST";
|
|
12
|
+
headers: Record<string, string>;
|
|
13
|
+
body?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface HttpResponse {
|
|
16
|
+
status: number;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
export type Transport = (req: HttpRequest) => Promise<HttpResponse>;
|
|
20
|
+
/** Who is calling, recorded with every write (header `X-Datanotes-Actor`). Self-reported. */
|
|
21
|
+
export interface ActorInfo {
|
|
22
|
+
/** The program: "claude-code", "cursor", a program's own name. */
|
|
23
|
+
harness?: string;
|
|
24
|
+
harness_version?: string;
|
|
25
|
+
model?: string;
|
|
26
|
+
/** The agent's session (the engine remembers the model an MCP server reports for it). */
|
|
27
|
+
session?: string;
|
|
28
|
+
/** The tool the agent called, when the call comes from an MCP server. */
|
|
29
|
+
tool?: string;
|
|
30
|
+
}
|
|
31
|
+
export declare const ACTOR_HEADER = "X-Datanotes-Actor";
|
|
32
|
+
export declare class DatanotesError extends Error {
|
|
33
|
+
readonly kind: "unreachable" | "auth" | "http";
|
|
34
|
+
readonly status: number;
|
|
35
|
+
readonly name = "DatanotesError";
|
|
36
|
+
/** How to fix it, and where to read more (also at the end of the message). */
|
|
37
|
+
readonly hint?: string;
|
|
38
|
+
readonly docs?: string;
|
|
39
|
+
/** `unreachable`: the engine did not answer; `auth`: the token was refused. */
|
|
40
|
+
constructor(message: string, kind?: "unreachable" | "auth" | "http", status?: number, guidance?: Guidance | null);
|
|
41
|
+
}
|
|
42
|
+
export interface ClientOptions {
|
|
43
|
+
/** The engine's address, e.g. `http://127.0.0.1:27150`. */
|
|
44
|
+
url: string;
|
|
45
|
+
token: string;
|
|
46
|
+
/** Recorded with every write unless a call names another actor. */
|
|
47
|
+
actor?: ActorInfo;
|
|
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;
|
|
57
|
+
}
|
|
58
|
+
/** Where a request sits in a trace: a context, or a `traceparent` header value. */
|
|
59
|
+
export type TraceParent = TraceContext | string;
|
|
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. */
|
|
61
|
+
export interface ToolCallRecord {
|
|
62
|
+
tool: string;
|
|
63
|
+
args: Record<string, unknown>;
|
|
64
|
+
ok: boolean;
|
|
65
|
+
duration_ms: number;
|
|
66
|
+
value: unknown;
|
|
67
|
+
/** Who served it: "engine", or the name of the MCP server whose own tool it is. */
|
|
68
|
+
served_by: string;
|
|
69
|
+
session?: string;
|
|
70
|
+
result_chars?: number;
|
|
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;
|
|
83
|
+
}
|
|
84
|
+
export declare const fetchTransport: Transport;
|
|
85
|
+
export declare class DatanotesClient {
|
|
86
|
+
private readonly o;
|
|
87
|
+
readonly url: string;
|
|
88
|
+
private readonly send;
|
|
89
|
+
constructor(o: ClientOptions);
|
|
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
|
+
*/
|
|
96
|
+
request(method: "GET" | "POST", path: string, body?: unknown, opts?: {
|
|
97
|
+
actor?: ActorInfo;
|
|
98
|
+
accept?: string;
|
|
99
|
+
trace?: TraceParent;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
status: number;
|
|
102
|
+
json: unknown;
|
|
103
|
+
text: string;
|
|
104
|
+
}>;
|
|
105
|
+
/** `POST /datanotes/<route>` and its JSON answer; throws on an error status. */
|
|
106
|
+
post<T = unknown>(route: string, body?: unknown, actor?: ActorInfo): Promise<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Run an operation of the catalogue (`select_rows`, `insert_row`, …) with an agent's arguments.
|
|
109
|
+
* Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
|
|
110
|
+
* with the same message the engine gives.
|
|
111
|
+
*/
|
|
112
|
+
call(name: string, args?: Record<string, unknown>, actor?: ActorInfo, options?: {
|
|
113
|
+
trace?: TraceParent;
|
|
114
|
+
}): Promise<OperationResult>;
|
|
115
|
+
/** True when the engine answers `GET /` (no token needed). */
|
|
116
|
+
ping(): Promise<boolean>;
|
|
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>;
|
|
122
|
+
}
|
package/dist/api/client.d.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* Obsidian (pass Obsidian's `requestUrl` as the transport). `call` runs an operation of the
|
|
4
4
|
* catalogue by name, the way agents name them; `request` reaches any route.
|
|
5
5
|
*/
|
|
6
|
-
import { type OperationResult } from "./results";
|
|
7
|
-
import type
|
|
6
|
+
import { type OperationResult } from "./results.js";
|
|
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";
|
|
@@ -18,11 +19,11 @@ export interface HttpResponse {
|
|
|
18
19
|
export type Transport = (req: HttpRequest) => Promise<HttpResponse>;
|
|
19
20
|
/** Who is calling, recorded with every write (header `X-Datanotes-Actor`). Self-reported. */
|
|
20
21
|
export interface ActorInfo {
|
|
21
|
-
/** The program: "claude-code", "cursor",
|
|
22
|
+
/** The program: "claude-code", "cursor", a program's own name. */
|
|
22
23
|
harness?: string;
|
|
23
24
|
harness_version?: string;
|
|
24
25
|
model?: string;
|
|
25
|
-
/** The agent's session (the engine remembers the model an
|
|
26
|
+
/** The agent's session (the engine remembers the model an MCP server reports for it). */
|
|
26
27
|
session?: string;
|
|
27
28
|
/** The tool the agent called, when the call comes from an MCP server. */
|
|
28
29
|
tool?: string;
|
|
@@ -32,8 +33,11 @@ export declare class DatanotesError extends Error {
|
|
|
32
33
|
readonly kind: "unreachable" | "auth" | "http";
|
|
33
34
|
readonly status: number;
|
|
34
35
|
readonly name = "DatanotesError";
|
|
36
|
+
/** How to fix it, and where to read more (also at the end of the message). */
|
|
37
|
+
readonly hint?: string;
|
|
38
|
+
readonly docs?: string;
|
|
35
39
|
/** `unreachable`: the engine did not answer; `auth`: the token was refused. */
|
|
36
|
-
constructor(message: string, kind?: "unreachable" | "auth" | "http", status?: number);
|
|
40
|
+
constructor(message: string, kind?: "unreachable" | "auth" | "http", status?: number, guidance?: Guidance | null);
|
|
37
41
|
}
|
|
38
42
|
export interface ClientOptions {
|
|
39
43
|
/** The engine's address, e.g. `http://127.0.0.1:27150`. */
|
|
@@ -42,24 +46,40 @@ export interface ClientOptions {
|
|
|
42
46
|
/** Recorded with every write unless a call names another actor. */
|
|
43
47
|
actor?: ActorInfo;
|
|
44
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;
|
|
45
57
|
}
|
|
46
|
-
/**
|
|
47
|
-
export
|
|
48
|
-
|
|
49
|
-
app: string;
|
|
50
|
-
}
|
|
51
|
-
/** One call of an operation or an app tool by an agent, for the engine's change feed. */
|
|
58
|
+
/** Where a request sits in a trace: a context, or a `traceparent` header value. */
|
|
59
|
+
export type TraceParent = TraceContext | string;
|
|
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. */
|
|
52
61
|
export interface ToolCallRecord {
|
|
53
62
|
tool: string;
|
|
54
63
|
args: Record<string, unknown>;
|
|
55
64
|
ok: boolean;
|
|
56
|
-
|
|
65
|
+
duration_ms: number;
|
|
57
66
|
value: unknown;
|
|
58
|
-
/** Who served it: "engine" or the
|
|
59
|
-
|
|
67
|
+
/** Who served it: "engine", or the name of the MCP server whose own tool it is. */
|
|
68
|
+
served_by: string;
|
|
60
69
|
session?: string;
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
result_chars?: number;
|
|
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;
|
|
63
83
|
}
|
|
64
84
|
export declare const fetchTransport: Transport;
|
|
65
85
|
export declare class DatanotesClient {
|
|
@@ -67,10 +87,16 @@ export declare class DatanotesClient {
|
|
|
67
87
|
readonly url: string;
|
|
68
88
|
private readonly send;
|
|
69
89
|
constructor(o: ClientOptions);
|
|
70
|
-
/**
|
|
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
|
+
*/
|
|
71
96
|
request(method: "GET" | "POST", path: string, body?: unknown, opts?: {
|
|
72
97
|
actor?: ActorInfo;
|
|
73
98
|
accept?: string;
|
|
99
|
+
trace?: TraceParent;
|
|
74
100
|
}): Promise<{
|
|
75
101
|
status: number;
|
|
76
102
|
json: unknown;
|
|
@@ -78,23 +104,19 @@ export declare class DatanotesClient {
|
|
|
78
104
|
}>;
|
|
79
105
|
/** `POST /datanotes/<route>` and its JSON answer; throws on an error status. */
|
|
80
106
|
post<T = unknown>(route: string, body?: unknown, actor?: ActorInfo): Promise<T>;
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Run an operation of the catalogue (`select_rows`, `insert_row`, …) with an agent's arguments.
|
|
109
|
+
* Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
|
|
110
|
+
* with the same message the engine gives.
|
|
111
|
+
*/
|
|
112
|
+
call(name: string, args?: Record<string, unknown>, actor?: ActorInfo, options?: {
|
|
113
|
+
trace?: TraceParent;
|
|
114
|
+
}): Promise<OperationResult>;
|
|
87
115
|
/** True when the engine answers `GET /` (no token needed). */
|
|
88
116
|
ping(): Promise<boolean>;
|
|
89
|
-
/**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/** Call an app's tool through the engine (which holds the app's credentials). */
|
|
95
|
-
callAppTool(name: string, args: Record<string, unknown>, actor?: ActorInfo): Promise<OperationResult & {
|
|
96
|
-
servedBy: string;
|
|
97
|
-
}>;
|
|
98
|
-
/** Record an agent's tool call in the change feed (what MCP servers report). */
|
|
99
|
-
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>;
|
|
100
122
|
}
|