datanotes 2.0.1 → 3.0.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 +207 -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 +89 -0
- package/dist/api/client.d.ts +19 -30
- 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 +6610 -2247
- package/dist/api/index.d.cts +13 -0
- package/dist/api/index.d.ts +10 -7
- package/dist/api/index.js +6610 -2247
- 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 +17384 -0
- package/dist/api/mcp.d.cts +108 -0
- package/dist/api/mcp.d.ts +108 -0
- package/dist/api/mcp.js +17334 -0
- package/dist/api/otlp.d.cts +65 -0
- package/dist/api/redact.d.cts +17 -0
- package/dist/api/redact.d.ts +17 -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 +7 -0
- package/dist/datanotes.cjs +62511 -28069
- 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 +69 -0
- package/dist/docs/administration/run-the-service.md +219 -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 +32 -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 +36 -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 +153 -0
- package/dist/docs/develop/http-api.md +79 -0
- package/dist/docs/develop/telemetry.md +86 -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 +1404 -0
- package/dist/docs/guides/database-objects/views.md +1003 -0
- package/dist/docs/guides/history/back-up.md +195 -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 +35 -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 +146 -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 +42 -0
- package/dist/docs/index.md +113 -0
- package/dist/docs/llms.txt +33 -0
- package/dist/docs/reference/cli.md +136 -0
- package/dist/docs/reference/compatibility.md +63 -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 +31 -0
- package/dist/docs/release-notes.md +67 -0
- package/dist/docs/start/connect-agents.md +204 -0
- package/dist/docs/start/how-it-works.md +317 -0
- package/dist/docs/start/quick-start.md +126 -0
- package/package.json +58 -14
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The documentation of this version of Datanotes, read offline: every page of datanotes.dev as
|
|
3
|
+
* Markdown, shipped in the npm package as `dist/docs/` (scripts/copy-docs.mjs copies them there
|
|
4
|
+
* after the docs build). The MCP server `datanotes mcp` serves it to agents as three tools
|
|
5
|
+
* (`list_docs`, `read_docs`, `search_docs`: src/api/mcp.ts), the engine to programs as
|
|
6
|
+
* `GET /datanotes/manual/<page>.md` (src/server/http-server.ts). They are not engine operations:
|
|
7
|
+
* nothing is journaled and no engine is needed.
|
|
8
|
+
*
|
|
9
|
+
* A page is named by its path on the site without `.md` (`guides/read-and-write/read-and-filter`), a section by the
|
|
10
|
+
* anchor of its heading (`guides/read-and-write/read-and-filter#compare-values-with-operators`), as on the site; the
|
|
11
|
+
* site's own addresses (`https://datanotes.dev/guides/read-and-write/read-and-filter/#…`) are read too. Every mistake
|
|
12
|
+
* says what is wrong, the closest real page or section, and how to list them (the hint standard
|
|
13
|
+
* of src/api/guidance.ts).
|
|
14
|
+
*/
|
|
15
|
+
import { type Guidance } from "./guidance.js";
|
|
16
|
+
/** An environment variable that names the folder of the docs instead of the package's own. */
|
|
17
|
+
export declare const DOCS_DIR_ENV = "DATANOTES_DOCS_DIR";
|
|
18
|
+
/** The most characters read_docs returns at once: about 5 000 tokens. */
|
|
19
|
+
export declare const READ_DOCS_MAX = 20000;
|
|
20
|
+
/** The page for agents on reading the docs offline. */
|
|
21
|
+
export declare const OFFLINE_DOCS = "https://datanotes.dev/guides/agents/docs-offline.md#the-agent-reads-the-docs-of-its-version";
|
|
22
|
+
/** A mistake in reading the docs: what is wrong, how to fix it, where to read more. */
|
|
23
|
+
export declare class DocsError extends Error {
|
|
24
|
+
readonly hint: string;
|
|
25
|
+
readonly docs: string;
|
|
26
|
+
/** `missing`: the docs are not in this installation; `not_found`: no such page or section; `bad_input`: wrong arguments. */
|
|
27
|
+
readonly code: "missing" | "not_found" | "bad_input";
|
|
28
|
+
constructor(message: string, g: Guidance, code: DocsError["code"]);
|
|
29
|
+
}
|
|
30
|
+
/** A page of the docs. */
|
|
31
|
+
export interface DocsPage {
|
|
32
|
+
/** Its path on the site, without `.md`: `guides/read-and-write/read-and-filter` (the home page is `index`). */
|
|
33
|
+
path: string;
|
|
34
|
+
title: string;
|
|
35
|
+
description: string;
|
|
36
|
+
}
|
|
37
|
+
/** How a section matched a search: by its words (BM25), or by its meaning (the engine's vector index of the docs). */
|
|
38
|
+
export type DocsSignal = "keyword" | "semantic";
|
|
39
|
+
/** A section of a page that matches a search. */
|
|
40
|
+
export interface DocsHit {
|
|
41
|
+
/** What read_docs reads: `guides/read-and-write/read-and-filter#compare-values-with-operators` (the page alone for its introduction). */
|
|
42
|
+
path: string;
|
|
43
|
+
page: string;
|
|
44
|
+
section: string;
|
|
45
|
+
excerpt: string;
|
|
46
|
+
/** BM25 for a keyword search; the Reciprocal Rank Fusion score for a hybrid one. */
|
|
47
|
+
score: number;
|
|
48
|
+
/** The rankings the section is in: `keyword` alone without semantic search. */
|
|
49
|
+
signals: DocsSignal[];
|
|
50
|
+
}
|
|
51
|
+
/** A section as search_docs ranks it, with the text the engine embeds for semantic search. */
|
|
52
|
+
export interface DocsSection {
|
|
53
|
+
/** What read_docs reads, as in {@link DocsHit}. */
|
|
54
|
+
path: string;
|
|
55
|
+
page: string;
|
|
56
|
+
section: string;
|
|
57
|
+
/** The page's title and the heading, then the section's own prose, then its code. */
|
|
58
|
+
text: string;
|
|
59
|
+
}
|
|
60
|
+
interface Section {
|
|
61
|
+
anchor: string;
|
|
62
|
+
title: string;
|
|
63
|
+
level: number;
|
|
64
|
+
/** Where its heading starts, where it ends with its subsections, and where its own text ends. */
|
|
65
|
+
start: number;
|
|
66
|
+
end: number;
|
|
67
|
+
ownEnd: number;
|
|
68
|
+
}
|
|
69
|
+
interface Page extends DocsPage {
|
|
70
|
+
text: string;
|
|
71
|
+
sections: Section[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The folder of the docs: `DATANOTES_DOCS_DIR` when set, else the package's `dist/docs` (next to
|
|
75
|
+
* `dist/datanotes.cjs`, above `dist/api/`, or in a checkout where the docs were built). Null when
|
|
76
|
+
* there is none.
|
|
77
|
+
*/
|
|
78
|
+
export declare function findDocsDir(env?: Record<string, string | undefined>, from?: string): string | null;
|
|
79
|
+
/** A heading's anchor as the site makes it (github-slugger): lowercase, punctuation dropped, spaces as dashes. */
|
|
80
|
+
export declare function slug(heading: string): string;
|
|
81
|
+
/** A page or section as given (`guides/read-and-write/read-and-filter.md`, `/guides/read-and-write/read-and-filter/#x`, a datanotes.dev address): the page's path and the anchor. */
|
|
82
|
+
export declare function docsRef(input: string): {
|
|
83
|
+
page: string;
|
|
84
|
+
anchor: string | null;
|
|
85
|
+
};
|
|
86
|
+
/** Common English words left out of queries and texts: they say nothing of the topic. */
|
|
87
|
+
export declare const STOP_WORDS: ReadonlySet<string>;
|
|
88
|
+
/**
|
|
89
|
+
* The stem of a lowercase word: plurals and verb endings stripped, so that the forms of a word meet
|
|
90
|
+
* (`tables`/`table`, `queries`/`query`, `renamed`/`renaming`/`rename`, `dropped`/`drop`,
|
|
91
|
+
* `rated`/`rate`, `using`/`use`). Not a dictionary form (`create` is `creat`), only the same for
|
|
92
|
+
* every form. Words of three letters or less, and words with digits, stay as they are.
|
|
93
|
+
*/
|
|
94
|
+
export declare function stem(word: string): string;
|
|
95
|
+
/** The search terms of a text: folded words, without one-letter and common words, stemmed. */
|
|
96
|
+
export declare function tokenize(text: string): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Words that mean the same thing in these docs, for queries: a word of the query also matches the
|
|
99
|
+
* others of its group, with SYNONYM_WEIGHT. An entry can be a phrase ("roll back"), which matches
|
|
100
|
+
* where its words follow each other, in the query and in the docs.
|
|
101
|
+
*/
|
|
102
|
+
export declare const SEARCH_SYNONYMS: readonly (readonly string[])[];
|
|
103
|
+
/** How much a synonym counts against the word itself. */
|
|
104
|
+
export declare const SYNONYM_WEIGHT = 0.7;
|
|
105
|
+
/** A term of a query: the word (or synonym phrase) as stems, and every way it matches, itself first. */
|
|
106
|
+
export interface QueryTerm {
|
|
107
|
+
term: string;
|
|
108
|
+
alternatives: {
|
|
109
|
+
stems: string[];
|
|
110
|
+
weight: number;
|
|
111
|
+
}[];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* The terms of a query, each with its synonyms. A synonym phrase written in the query ("roll
|
|
115
|
+
* back", "time travel") is one term; a term repeated in the query counts once.
|
|
116
|
+
*/
|
|
117
|
+
export declare function queryTerms(query: string): QueryTerm[];
|
|
118
|
+
/** A query of search_docs as written: the words to rank by, and the words a section must hold or must not. */
|
|
119
|
+
export interface DocsQuery {
|
|
120
|
+
/** The words to rank by, the syntax taken out: `"time travel" +view -sql` ranks by `time travel view`. */
|
|
121
|
+
text: string;
|
|
122
|
+
/** Quoted phrases and +terms, as stems: each must appear in a section (its words in a row, in any form). */
|
|
123
|
+
required: string[][];
|
|
124
|
+
/** -terms and -"phrases", as stems: a section that holds one is left out. */
|
|
125
|
+
excluded: string[][];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Read the syntax of a search_docs query: `"a phrase"` and `+term` must appear in a section,
|
|
129
|
+
* `-term` (or `-"a phrase"`) must not, every other word ranks only. Curly quotes count as straight
|
|
130
|
+
* ones, a quote left open runs to the end, and a word that starts with two dashes (`--vault`) is a
|
|
131
|
+
* word. Words that say nothing (`+the`) require nothing.
|
|
132
|
+
*/
|
|
133
|
+
export declare function parseQuery(query: string): DocsQuery;
|
|
134
|
+
/** The docs in a folder (null: there are none, and every call says how to get them). */
|
|
135
|
+
export declare class DocsLibrary {
|
|
136
|
+
readonly dir: string | null;
|
|
137
|
+
private loaded;
|
|
138
|
+
private index;
|
|
139
|
+
private hash;
|
|
140
|
+
private sectionList;
|
|
141
|
+
constructor(dir: string | null);
|
|
142
|
+
private missing;
|
|
143
|
+
private all;
|
|
144
|
+
/** The pages, sorted by path; only those under `prefix` (`guides/`) when it is given. */
|
|
145
|
+
list(prefix?: string): DocsPage[];
|
|
146
|
+
private page;
|
|
147
|
+
private section;
|
|
148
|
+
/**
|
|
149
|
+
* The Markdown of a page (`guides/read-and-write/read-and-filter`) or of one section (`guides/read-and-write/read-and-filter#anchor`, or
|
|
150
|
+
* `section`), with its subsections. Without a cap, the whole text.
|
|
151
|
+
*/
|
|
152
|
+
text(ref: string, section?: string | null): {
|
|
153
|
+
ref: string;
|
|
154
|
+
text: string;
|
|
155
|
+
page: Page;
|
|
156
|
+
from: number;
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* What read_docs returns: the page or section from `offset`, at most `max` characters, cut at the
|
|
160
|
+
* end of a line, then a note on how to read the rest (the sections that follow, or the offset).
|
|
161
|
+
*/
|
|
162
|
+
read(ref: string, opts?: {
|
|
163
|
+
section?: string | null;
|
|
164
|
+
offset?: number;
|
|
165
|
+
max?: number;
|
|
166
|
+
}): string;
|
|
167
|
+
private searchIndex;
|
|
168
|
+
/** The terms of a query to rank by; a query with none is refused. */
|
|
169
|
+
private termsOf;
|
|
170
|
+
/**
|
|
171
|
+
* The units ranked by BM25 for the query's words, best first, without those the required and
|
|
172
|
+
* excluded words leave out. Each term of the query (a word in any form, or one of its synonyms)
|
|
173
|
+
* scores by BM25 in a section's text, and more in its heading and its page's title; rare terms
|
|
174
|
+
* count more than common ones; a heading with every term, and terms next to each other as in
|
|
175
|
+
* the query, add to it; a section with every term ranks above one with some.
|
|
176
|
+
*/
|
|
177
|
+
private ranked;
|
|
178
|
+
/**
|
|
179
|
+
* The sections that best match `query`, best first, by their words (BM25: {@link ranked}). A
|
|
180
|
+
* quoted phrase or a +term must appear in a section, a -term must not (parseQuery).
|
|
181
|
+
*/
|
|
182
|
+
search(query: string, limit?: number): DocsHit[];
|
|
183
|
+
/**
|
|
184
|
+
* Hybrid search: the ranking of {@link search} by words, and `semantic`, the sections ranked by
|
|
185
|
+
* meaning (the engine's vector index of these docs, best first), fused by Reciprocal Rank
|
|
186
|
+
* Fusion: a section scores the sum of 1 / (RRF_K + its rank) over the rankings it is in, among
|
|
187
|
+
* the first FUSION_DEPTH of each. The required and excluded words filter both rankings, and a
|
|
188
|
+
* section these docs do not have is left out. Each hit says which rankings it is in (`signals`).
|
|
189
|
+
*/
|
|
190
|
+
hybrid(query: string, semantic: readonly {
|
|
191
|
+
path: string;
|
|
192
|
+
}[], limit?: number): DocsHit[];
|
|
193
|
+
/**
|
|
194
|
+
* Every section as search_docs ranks them (a page's introduction too), with the text to embed
|
|
195
|
+
* for semantic search: the page's title and the heading, the prose, then the code.
|
|
196
|
+
*/
|
|
197
|
+
sections(): readonly DocsSection[];
|
|
198
|
+
/**
|
|
199
|
+
* The version of these docs: a hash of their sections (paths and texts). The engine's vector
|
|
200
|
+
* index of the docs is rebuilt when it changes, and search_docs fuses its ranking only when the
|
|
201
|
+
* engine's docs have the same version as its own.
|
|
202
|
+
*/
|
|
203
|
+
version(): string;
|
|
204
|
+
}
|
|
205
|
+
/** The constant of Reciprocal Rank Fusion: 60, the value of its paper (Cormack et al., 2009) and of most search engines; it keeps the first ranks from outweighing agreement between the rankings. */
|
|
206
|
+
export declare const RRF_K = 60;
|
|
207
|
+
/** How many sections of each ranking hybrid search fuses. */
|
|
208
|
+
export declare const FUSION_DEPTH = 50;
|
|
209
|
+
/** The docs of a folder (default: `findDocsDir()`), loaded once per folder. */
|
|
210
|
+
export declare function openDocs(dir?: string | null): DocsLibrary;
|
|
211
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an agent reads when a call goes wrong, on the client's side: the engine sends `hint` (how
|
|
3
|
+
* to fix it) and `docs` (where to read more) next to `error` (src/core/hints.ts is the engine's
|
|
4
|
+
* half), and the text of a failed call ends with them. Here also the mistakes caught before a call
|
|
5
|
+
* reaches the engine: a tool that does not exist, arguments the tool does not take, a required one
|
|
6
|
+
* missing, a value of the wrong type. Each names the closest real name and the tool's arguments.
|
|
7
|
+
*
|
|
8
|
+
* No dependency: src/api imports nothing else (the engine's copy of the docs address and of the
|
|
9
|
+
* name matching is in src/core/hints.ts; tests/hints.test.ts checks that both agree).
|
|
10
|
+
*/
|
|
11
|
+
/** The docs site; the pages are read in Markdown: `<route>.md`. */
|
|
12
|
+
export declare const DOCS_BASE = "https://datanotes.dev";
|
|
13
|
+
/** The page for agents on reading the engine's errors. */
|
|
14
|
+
export declare const ERRORS_DOCS = "https://datanotes.dev/guides/agents/reading-errors.md";
|
|
15
|
+
/** The overview of the operations, by kind. */
|
|
16
|
+
export declare const OPERATIONS_DOCS = "https://datanotes.dev/reference/operations.md";
|
|
17
|
+
/** The reference of an operation (its arguments, with types and defaults): the page of its kind; the overview for an unknown one. */
|
|
18
|
+
export declare function toolDocs(op: string): string;
|
|
19
|
+
/** How to fix a mistake, and where to read more. */
|
|
20
|
+
export interface Guidance {
|
|
21
|
+
hint: string;
|
|
22
|
+
docs: string;
|
|
23
|
+
}
|
|
24
|
+
/** `hint` and `docs` of an engine's answer, or null when it has none. */
|
|
25
|
+
export declare function guidanceIn(data: unknown): Guidance | null;
|
|
26
|
+
/**
|
|
27
|
+
* A docs address of the site as the call that reads the same page in the docs shipped with the
|
|
28
|
+
* package (the read_docs tool of `datanotes mcp`, src/api/docs.ts):
|
|
29
|
+
* `read_docs("guides/read-and-write/read-and-filter#compare-values-with-operators")` for
|
|
30
|
+
* `https://datanotes.dev/guides/read-and-write/read-and-filter.md#compare-values-with-operators`. Null for any other address.
|
|
31
|
+
*/
|
|
32
|
+
export declare function localDocs(url: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* The text an agent reads: the message, then the hint and the docs page, one per line. The docs
|
|
35
|
+
* line also names the call that reads the page offline, when it is a page of the site.
|
|
36
|
+
*/
|
|
37
|
+
export declare function guidedText(message: string, g: Guidance | null): string;
|
|
38
|
+
/**
|
|
39
|
+
* The text of an error for an agent of the MCP server, which always has the docs tools: each docs
|
|
40
|
+
* line keeps only the call that reads the page offline (`Docs: read_docs("…")`), with no address
|
|
41
|
+
* to fetch. A docs line that is not a page of the site keeps its address.
|
|
42
|
+
*/
|
|
43
|
+
export declare function offlineDocsText(text: string): string;
|
|
44
|
+
/** The real names closest to a wrong one, best first (at most `max`). */
|
|
45
|
+
export declare function closestNames(input: string, candidates: Iterable<string>, max?: number): string[];
|
|
46
|
+
/** `Did you mean "x"?` / `Did you mean "x" or "y"?`, or "" when nothing is close. */
|
|
47
|
+
export declare function didYouMean(input: string, candidates: Iterable<string>): string;
|
|
48
|
+
type Schema = {
|
|
49
|
+
type?: string | string[];
|
|
50
|
+
anyOf?: Schema[];
|
|
51
|
+
items?: Schema;
|
|
52
|
+
enum?: unknown[];
|
|
53
|
+
};
|
|
54
|
+
/** A tool's input schema: its arguments and the required ones. */
|
|
55
|
+
export type InputSchema = {
|
|
56
|
+
properties?: Record<string, Schema>;
|
|
57
|
+
required?: string[];
|
|
58
|
+
};
|
|
59
|
+
/** A schema's type in words: `string`, `object`, `list of strings`, `integer or null`, `"a" or "b"`. */
|
|
60
|
+
export declare function typeName(s: Schema): string;
|
|
61
|
+
/** An operation's arguments in one line: `table (string, required), values (object, required), dry_run (boolean)`. */
|
|
62
|
+
export declare function argumentsOf(op: string): string;
|
|
63
|
+
/** A tool's arguments in one line, from its input schema. */
|
|
64
|
+
export declare function argumentList(schema: InputSchema): string;
|
|
65
|
+
/** Whether a given value (not null) is of a schema's type and among its `enum`; a list's items too. A schema without a type takes anything. */
|
|
66
|
+
export declare function typeOk(v: unknown, s: Schema): boolean;
|
|
67
|
+
/** An error found before the call reaches the engine: its text names what to fix. */
|
|
68
|
+
export interface ArgumentProblem extends Guidance {
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
/** A tool that does not exist: the closest real ones. `names`: the tools the agent may call. */
|
|
72
|
+
export declare function unknownTool(name: string, names: readonly string[]): ArgumentProblem;
|
|
73
|
+
/**
|
|
74
|
+
* The arguments an agent gave a tool, against the tool's input schema: names it does not take (with
|
|
75
|
+
* the closest real one), required ones missing, values of the wrong type (null is "not given", as
|
|
76
|
+
* the engine reads it). Null when they are right; unknown tools are not checked here.
|
|
77
|
+
*/
|
|
78
|
+
export declare function checkArguments(op: string, args: Record<string, unknown>): ArgumentProblem | null;
|
|
79
|
+
/** The same check for any tool, from its input schema (the docs tools of src/api/docs.ts), with its docs page. */
|
|
80
|
+
export declare function checkToolArguments(op: string, schema: InputSchema, args: Record<string, unknown>, docs: string): ArgumentProblem | null;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an agent reads when a call goes wrong, on the client's side: the engine sends `hint` (how
|
|
3
|
+
* to fix it) and `docs` (where to read more) next to `error` (src/core/hints.ts is the engine's
|
|
4
|
+
* half), and the text of a failed call ends with them. Here also the mistakes caught before a call
|
|
5
|
+
* reaches the engine: a tool that does not exist, arguments the tool does not take, a required one
|
|
6
|
+
* missing, a value of the wrong type. Each names the closest real name and the tool's arguments.
|
|
7
|
+
*
|
|
8
|
+
* No dependency: src/api imports nothing else (the engine's copy of the docs address and of the
|
|
9
|
+
* name matching is in src/core/hints.ts; tests/hints.test.ts checks that both agree).
|
|
10
|
+
*/
|
|
11
|
+
/** The docs site; the pages are read in Markdown: `<route>.md`. */
|
|
12
|
+
export declare const DOCS_BASE = "https://datanotes.dev";
|
|
13
|
+
/** The page for agents on reading the engine's errors. */
|
|
14
|
+
export declare const ERRORS_DOCS = "https://datanotes.dev/guides/agents/reading-errors.md";
|
|
15
|
+
/** The overview of the operations, by kind. */
|
|
16
|
+
export declare const OPERATIONS_DOCS = "https://datanotes.dev/reference/operations.md";
|
|
17
|
+
/** The reference of an operation (its arguments, with types and defaults): the page of its kind; the overview for an unknown one. */
|
|
18
|
+
export declare function toolDocs(op: string): string;
|
|
19
|
+
/** How to fix a mistake, and where to read more. */
|
|
20
|
+
export interface Guidance {
|
|
21
|
+
hint: string;
|
|
22
|
+
docs: string;
|
|
23
|
+
}
|
|
24
|
+
/** `hint` and `docs` of an engine's answer, or null when it has none. */
|
|
25
|
+
export declare function guidanceIn(data: unknown): Guidance | null;
|
|
26
|
+
/**
|
|
27
|
+
* A docs address of the site as the call that reads the same page in the docs shipped with the
|
|
28
|
+
* package (the read_docs tool of `datanotes mcp`, src/api/docs.ts):
|
|
29
|
+
* `read_docs("guides/read-and-write/read-and-filter#compare-values-with-operators")` for
|
|
30
|
+
* `https://datanotes.dev/guides/read-and-write/read-and-filter.md#compare-values-with-operators`. Null for any other address.
|
|
31
|
+
*/
|
|
32
|
+
export declare function localDocs(url: string): string | null;
|
|
33
|
+
/**
|
|
34
|
+
* The text an agent reads: the message, then the hint and the docs page, one per line. The docs
|
|
35
|
+
* line also names the call that reads the page offline, when it is a page of the site.
|
|
36
|
+
*/
|
|
37
|
+
export declare function guidedText(message: string, g: Guidance | null): string;
|
|
38
|
+
/**
|
|
39
|
+
* The text of an error for an agent of the MCP server, which always has the docs tools: each docs
|
|
40
|
+
* line keeps only the call that reads the page offline (`Docs: read_docs("…")`), with no address
|
|
41
|
+
* to fetch. A docs line that is not a page of the site keeps its address.
|
|
42
|
+
*/
|
|
43
|
+
export declare function offlineDocsText(text: string): string;
|
|
44
|
+
/** The real names closest to a wrong one, best first (at most `max`). */
|
|
45
|
+
export declare function closestNames(input: string, candidates: Iterable<string>, max?: number): string[];
|
|
46
|
+
/** `Did you mean "x"?` / `Did you mean "x" or "y"?`, or "" when nothing is close. */
|
|
47
|
+
export declare function didYouMean(input: string, candidates: Iterable<string>): string;
|
|
48
|
+
type Schema = {
|
|
49
|
+
type?: string | string[];
|
|
50
|
+
anyOf?: Schema[];
|
|
51
|
+
items?: Schema;
|
|
52
|
+
enum?: unknown[];
|
|
53
|
+
};
|
|
54
|
+
/** A tool's input schema: its arguments and the required ones. */
|
|
55
|
+
export type InputSchema = {
|
|
56
|
+
properties?: Record<string, Schema>;
|
|
57
|
+
required?: string[];
|
|
58
|
+
};
|
|
59
|
+
/** A schema's type in words: `string`, `object`, `list of strings`, `integer or null`, `"a" or "b"`. */
|
|
60
|
+
export declare function typeName(s: Schema): string;
|
|
61
|
+
/** An operation's arguments in one line: `table (string, required), values (object, required), dry_run (boolean)`. */
|
|
62
|
+
export declare function argumentsOf(op: string): string;
|
|
63
|
+
/** A tool's arguments in one line, from its input schema. */
|
|
64
|
+
export declare function argumentList(schema: InputSchema): string;
|
|
65
|
+
/** Whether a given value (not null) is of a schema's type and among its `enum`; a list's items too. A schema without a type takes anything. */
|
|
66
|
+
export declare function typeOk(v: unknown, s: Schema): boolean;
|
|
67
|
+
/** An error found before the call reaches the engine: its text names what to fix. */
|
|
68
|
+
export interface ArgumentProblem extends Guidance {
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
/** A tool that does not exist: the closest real ones. `names`: the tools the agent may call. */
|
|
72
|
+
export declare function unknownTool(name: string, names: readonly string[]): ArgumentProblem;
|
|
73
|
+
/**
|
|
74
|
+
* The arguments an agent gave a tool, against the tool's input schema: names it does not take (with
|
|
75
|
+
* the closest real one), required ones missing, values of the wrong type (null is "not given", as
|
|
76
|
+
* the engine reads it). Null when they are right; unknown tools are not checked here.
|
|
77
|
+
*/
|
|
78
|
+
export declare function checkArguments(op: string, args: Record<string, unknown>): ArgumentProblem | null;
|
|
79
|
+
/** The same check for any tool, from its input schema (the docs tools of src/api/docs.ts), with its docs page. */
|
|
80
|
+
export declare function checkToolArguments(op: string, schema: InputSchema, args: Record<string, unknown>, docs: string): ArgumentProblem | null;
|
|
81
|
+
export {};
|