datanotes 2.0.0 → 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 +62911 -28409
- 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 +59 -14
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTelemetry log export over OTLP/HTTP, vendor-neutral: records are buffered and POSTed to
|
|
3
|
+
* `<endpoint>/v1/logs` as `http/protobuf` (the OTLP default) or `http/json`, which every
|
|
4
|
+
* OpenTelemetry collector and OTLP backend reads. No dependency, no SDK. Export failures are
|
|
5
|
+
* counted, never thrown: logging must not break the program. (OTLP over gRPC is not supported:
|
|
6
|
+
* use the collector's HTTP port, 4318 by default.)
|
|
7
|
+
*
|
|
8
|
+
* Configure it in code, or from the standard OpenTelemetry variables with `otlpFromEnv`.
|
|
9
|
+
*/
|
|
10
|
+
export type Severity = "DEBUG" | "INFO" | "WARN" | "ERROR";
|
|
11
|
+
export type AttrValue = string | number | boolean | null | undefined;
|
|
12
|
+
export type OtlpProtocol = "http/protobuf" | "http/json";
|
|
13
|
+
export interface OtlpOptions {
|
|
14
|
+
/** Collector base URL, e.g. `http://127.0.0.1:4318` (`/v1/logs` is added). */
|
|
15
|
+
endpoint: string;
|
|
16
|
+
/** `service.name` of the records. */
|
|
17
|
+
serviceName: string;
|
|
18
|
+
serviceVersion?: string;
|
|
19
|
+
/** `http/protobuf` (default) or `http/json`. */
|
|
20
|
+
protocol?: OtlpProtocol;
|
|
21
|
+
/** Extra headers, e.g. an API key or `Authorization`, as the backend asks. */
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
/** More resource attributes (e.g. `host.name`). */
|
|
24
|
+
resource?: Record<string, AttrValue>;
|
|
25
|
+
/** Send at most this many records per request (default 50); a full buffer is sent at once. */
|
|
26
|
+
maxBatch?: number;
|
|
27
|
+
/** Send the buffer every this many ms (default 5000; 0: only on `flush`). */
|
|
28
|
+
flushMs?: number;
|
|
29
|
+
/** POST a body; resolves on 2xx (default: fetch). `headers` include the Content-Type. */
|
|
30
|
+
send?: (url: string, body: string | Uint8Array, headers: Record<string, string>) => Promise<void>;
|
|
31
|
+
now?: () => number;
|
|
32
|
+
}
|
|
33
|
+
export declare class OtlpLogExporter {
|
|
34
|
+
private readonly o;
|
|
35
|
+
private buffer;
|
|
36
|
+
private inflight;
|
|
37
|
+
private timer;
|
|
38
|
+
/** Records sent, and records lost because the collector did not take them. */
|
|
39
|
+
sent: number;
|
|
40
|
+
dropped: number;
|
|
41
|
+
constructor(o: OtlpOptions);
|
|
42
|
+
log(severity: Severity, body: string, attributes?: Record<string, AttrValue>): void;
|
|
43
|
+
/** Send what is buffered. Never rejects. */
|
|
44
|
+
flush(): Promise<void>;
|
|
45
|
+
private protobuf;
|
|
46
|
+
/** Stop the timer and send what is left. */
|
|
47
|
+
close(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/** `k1=v1,k2=v2` (values URL-encoded), the format of `OTEL_EXPORTER_OTLP_HEADERS`. */
|
|
50
|
+
export declare function parseOtlpHeaders(text: string | undefined): Record<string, string>;
|
|
51
|
+
/** `k1=v1,k2=v2` resource attributes, the format of `OTEL_RESOURCE_ATTRIBUTES`. */
|
|
52
|
+
export declare const parseResourceAttributes: typeof parseOtlpHeaders;
|
|
53
|
+
/**
|
|
54
|
+
* Exporter options from the standard OpenTelemetry variables, or null when export is off (no
|
|
55
|
+
* endpoint, `OTEL_SDK_DISABLED=true` or `OTEL_LOGS_EXPORTER=none`):
|
|
56
|
+
* `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (full URL of /v1/logs) or `OTEL_EXPORTER_OTLP_ENDPOINT`;
|
|
57
|
+
* `OTEL_EXPORTER_OTLP_[LOGS_]HEADERS`; `OTEL_EXPORTER_OTLP_[LOGS_]PROTOCOL` (`http/protobuf`,
|
|
58
|
+
* `http/json`); `OTEL_SERVICE_NAME`; `OTEL_RESOURCE_ATTRIBUTES`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function otlpFromEnv(env: Record<string, string | undefined>, defaults: {
|
|
61
|
+
serviceName: string;
|
|
62
|
+
serviceVersion?: string;
|
|
63
|
+
}): OtlpOptions | null;
|
|
64
|
+
/** `http/protobuf` or `http/json` from a setting or variable; undefined for anything else. */
|
|
65
|
+
export declare function otlpProtocol(v: string | undefined): OtlpProtocol | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secrets out of recorded tool calls. A tool call becomes a `tool_call` event of the change feed,
|
|
3
|
+
* which the engine keeps in its store and the store backup commits and pushes: a webhook's secret
|
|
4
|
+
* or a token returned by a call must never get there. Removed are the arguments and result keys
|
|
5
|
+
* the catalogue marks `sensitive`, and, for any tool, the keys that name a secret
|
|
6
|
+
* ({@link SECRET_KEYS}), at any depth. A text (an error, a result sent as text) loses the values
|
|
7
|
+
* of those keys written as JSON.
|
|
8
|
+
*/
|
|
9
|
+
/** What a removed value becomes. */
|
|
10
|
+
export declare const REDACTED = "[redacted]";
|
|
11
|
+
/** Keys whose values are secrets, whatever the tool (compared without case, `_` or `-`). */
|
|
12
|
+
export declare const SECRET_KEYS: readonly ["secret", "token", "password", "apikey", "authorization", "httpservertoken", "accesstoken", "refreshtoken", "clientsecret"];
|
|
13
|
+
/** A tool call's arguments and result without their secrets (new objects; the call's own are kept). */
|
|
14
|
+
export declare function redactToolCall(tool: string, args: Record<string, unknown>, value: unknown): {
|
|
15
|
+
args: Record<string, unknown>;
|
|
16
|
+
value: unknown;
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Secrets out of recorded tool calls. A tool call becomes a `tool_call` event of the change feed,
|
|
3
|
+
* which the engine keeps in its store and the store backup commits and pushes: a webhook's secret
|
|
4
|
+
* or a token returned by a call must never get there. Removed are the arguments and result keys
|
|
5
|
+
* the catalogue marks `sensitive`, and, for any tool, the keys that name a secret
|
|
6
|
+
* ({@link SECRET_KEYS}), at any depth. A text (an error, a result sent as text) loses the values
|
|
7
|
+
* of those keys written as JSON.
|
|
8
|
+
*/
|
|
9
|
+
/** What a removed value becomes. */
|
|
10
|
+
export declare const REDACTED = "[redacted]";
|
|
11
|
+
/** Keys whose values are secrets, whatever the tool (compared without case, `_` or `-`). */
|
|
12
|
+
export declare const SECRET_KEYS: readonly ["secret", "token", "password", "apikey", "authorization", "httpservertoken", "accesstoken", "refreshtoken", "clientsecret"];
|
|
13
|
+
/** A tool call's arguments and result without their secrets (new objects; the call's own are kept). */
|
|
14
|
+
export declare function redactToolCall(tool: string, args: Record<string, unknown>, value: unknown): {
|
|
15
|
+
args: Record<string, unknown>;
|
|
16
|
+
value: unknown;
|
|
17
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The HTTP request behind each operation of the catalogue (`catalog.ts`): every one is
|
|
3
|
+
* `POST /datanotes/operations/<name>/`, its JSON body the operation's arguments as they are (the
|
|
4
|
+
* same names an agent passes to the MCP tool), without the ones left out (null or undefined).
|
|
5
|
+
*/
|
|
6
|
+
import { type Guidance } from "./guidance.cjs";
|
|
7
|
+
type Args = Record<string, unknown>;
|
|
8
|
+
/** Arguments no request can be built from; `message` ends with how to fix them. */
|
|
9
|
+
export declare class OperationInputError extends Error {
|
|
10
|
+
readonly name = "OperationInputError";
|
|
11
|
+
constructor(message: string, guidance: Guidance);
|
|
12
|
+
}
|
|
13
|
+
export declare const ROUTE_PREFIX = "/datanotes";
|
|
14
|
+
/** The operations of the catalogue, by name. */
|
|
15
|
+
export declare const CALLABLE_OPERATIONS: ReadonlySet<string>;
|
|
16
|
+
/** The route of an operation, without the prefix: `/operations/<name>/`. */
|
|
17
|
+
export declare function operationRoute(name: string): string;
|
|
18
|
+
export interface OperationRequest {
|
|
19
|
+
method: "POST";
|
|
20
|
+
/** Path from the server root. */
|
|
21
|
+
path: string;
|
|
22
|
+
body: Args;
|
|
23
|
+
}
|
|
24
|
+
/** The request for an operation and its arguments; throws OperationInputError for an unknown operation. */
|
|
25
|
+
export declare function operationRequest(name: string, args?: Args): OperationRequest;
|
|
26
|
+
export {};
|
package/dist/api/requests.d.ts
CHANGED
|
@@ -1,28 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The HTTP request behind each operation of the catalogue (`catalog.ts`):
|
|
3
|
-
* `POST /datanotes/<
|
|
4
|
-
*
|
|
2
|
+
* The HTTP request behind each operation of the catalogue (`catalog.ts`): every one is
|
|
3
|
+
* `POST /datanotes/operations/<name>/`, its JSON body the operation's arguments as they are (the
|
|
4
|
+
* same names an agent passes to the MCP tool), without the ones left out (null or undefined).
|
|
5
5
|
*/
|
|
6
|
+
import { type Guidance } from "./guidance.js";
|
|
6
7
|
type Args = Record<string, unknown>;
|
|
8
|
+
/** Arguments no request can be built from; `message` ends with how to fix them. */
|
|
7
9
|
export declare class OperationInputError extends Error {
|
|
8
10
|
readonly name = "OperationInputError";
|
|
11
|
+
constructor(message: string, guidance: Guidance);
|
|
9
12
|
}
|
|
10
13
|
export declare const ROUTE_PREFIX = "/datanotes";
|
|
14
|
+
/** The operations of the catalogue, by name. */
|
|
15
|
+
export declare const CALLABLE_OPERATIONS: ReadonlySet<string>;
|
|
16
|
+
/** The route of an operation, without the prefix: `/operations/<name>/`. */
|
|
17
|
+
export declare function operationRoute(name: string): string;
|
|
11
18
|
export interface OperationRequest {
|
|
12
|
-
method: "
|
|
13
|
-
/** Path from the server root
|
|
19
|
+
method: "POST";
|
|
20
|
+
/** Path from the server root. */
|
|
14
21
|
path: string;
|
|
15
|
-
body
|
|
16
|
-
/** Accept header, when the route answers in more than one format. */
|
|
17
|
-
accept?: string;
|
|
22
|
+
body: Args;
|
|
18
23
|
}
|
|
19
|
-
/** The request for an operation and its arguments; throws OperationInputError
|
|
24
|
+
/** The request for an operation and its arguments; throws OperationInputError for an unknown operation. */
|
|
20
25
|
export declare function operationRequest(name: string, args?: Args): OperationRequest;
|
|
21
|
-
/** Operations this module can build a request for (to check the catalogue against). */
|
|
22
|
-
export declare const CALLABLE_OPERATIONS: Set<string>;
|
|
23
|
-
/** The route an operation calls (without the prefix) and the body fields it fixes (e.g. `op` for DDL), or null. */
|
|
24
|
-
export declare function operationRoute(name: string): {
|
|
25
|
-
path: string;
|
|
26
|
-
fixed: Args;
|
|
27
|
-
} | null;
|
|
28
26
|
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What an operation returned, for its caller: the value of a success, or an agent-readable text
|
|
3
|
+
* for a refusal (what was refused; nothing was written) or an error, ending with the engine's
|
|
4
|
+
* `hint` (how to fix it) and `docs` (where to read more) when it sends them.
|
|
5
|
+
*/
|
|
6
|
+
/** Agent-readable summary of conflicts / violations / failures in a refused result. */
|
|
7
|
+
export declare function describeRefusal(data: Record<string, unknown>): string;
|
|
8
|
+
/** Agent-readable summary of a refused batch: the failing operation and the rollback. */
|
|
9
|
+
export declare function describeBatch(data: Record<string, unknown>): string;
|
|
10
|
+
export interface OperationResult {
|
|
11
|
+
ok: boolean;
|
|
12
|
+
/** The result (JSON, or the text of a note) or, when `ok` is false, the reason. */
|
|
13
|
+
value: unknown;
|
|
14
|
+
}
|
|
15
|
+
/** The result of an HTTP answer: `json` when the body was JSON, else its `text`. */
|
|
16
|
+
export declare function resultOf(status: number, json: unknown, text: string): OperationResult;
|
package/dist/api/results.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* What an operation returned, for its caller: the value of a success, or an agent-readable text
|
|
3
|
-
* for a refusal (what was refused; nothing was written) or an error
|
|
3
|
+
* for a refusal (what was refused; nothing was written) or an error, ending with the engine's
|
|
4
|
+
* `hint` (how to fix it) and `docs` (where to read more) when it sends them.
|
|
4
5
|
*/
|
|
5
6
|
/** Agent-readable summary of conflicts / violations / failures in a refused result. */
|
|
6
7
|
export declare function describeRefusal(data: Record<string, unknown>): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A tokenizer-free estimate of how many tokens a text costs a model: words count about one token
|
|
3
|
+
* per 4 letters, numbers one per 3 digits, every other symbol (JSON punctuation, quotes, …) one.
|
|
4
|
+
* Close to real tokenizers on JSON and on Italian/English prose (within ~15%); good for telling
|
|
5
|
+
* which tools and sessions fill the context, not for billing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function estimateTokens(text: string): number;
|