datanotes 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/dist/api/client.d.cts +37 -4
- package/dist/api/client.d.ts +37 -4
- package/dist/api/index.cjs +563 -60
- package/dist/api/index.d.cts +3 -2
- package/dist/api/index.d.ts +3 -2
- package/dist/api/index.js +563 -60
- package/dist/api/mcp.cjs +181 -11
- package/dist/api/mcp.js +181 -11
- package/dist/api/otlp.d.cts +63 -15
- package/dist/api/otlp.d.ts +63 -15
- package/dist/api/redact.d.cts +25 -0
- package/dist/api/redact.d.ts +25 -0
- package/dist/api/tokens.d.cts +5 -0
- package/dist/api/tokens.d.ts +5 -0
- package/dist/api/tracing.d.cts +107 -0
- package/dist/api/tracing.d.ts +107 -0
- package/dist/datanotes.cjs +9934 -2656
- package/dist/docs/administration/limits.md +96 -12
- package/dist/docs/administration/run-the-service.md +18 -0
- package/dist/docs/api/operations/add_column.md +1 -0
- package/dist/docs/api/operations/add_constraint.md +2 -0
- package/dist/docs/api/operations/alter_column.md +1 -1
- package/dist/docs/api/operations/alter_table.md +3 -2
- package/dist/docs/api/operations/check_table.md +1 -1
- package/dist/docs/api/operations/create_table.md +3 -1
- package/dist/docs/api/operations/describe_table.md +1 -1
- package/dist/docs/api/operations/graph_neighbors.md +4 -2
- package/dist/docs/api/operations/graph_path.md +3 -3
- package/dist/docs/api/operations/graph_traverse.md +2 -2
- package/dist/docs/api/operations/insert_row.md +2 -2
- package/dist/docs/api/operations/record_tool_call.md +1 -0
- package/dist/docs/api/operations/tags/queries.md +2 -2
- package/dist/docs/api/operations/tags/rows-dml.md +1 -1
- package/dist/docs/api.md +4 -4
- package/dist/docs/develop/concurrency.md +36 -1
- package/dist/docs/develop/http-api.md +11 -1
- package/dist/docs/develop/telemetry.md +224 -25
- package/dist/docs/guides/data-quality/check-constraints.md +14 -13
- package/dist/docs/guides/data-quality/hand-edits.md +10 -10
- package/dist/docs/guides/database-objects/bases.md +11 -11
- package/dist/docs/guides/database-objects/catalogs-and-schemas.md +16 -10
- package/dist/docs/guides/database-objects/columns.md +38 -38
- package/dist/docs/guides/database-objects/relations.md +173 -36
- package/dist/docs/guides/database-objects/tables.md +90 -109
- package/dist/docs/guides/database-objects/views.md +44 -44
- package/dist/docs/guides/history/back-up.md +12 -4
- package/dist/docs/guides/history/change-data-feed.md +34 -34
- package/dist/docs/guides/history/journal-and-undo.md +12 -12
- package/dist/docs/guides/history/restore.md +20 -20
- package/dist/docs/guides/history/table-history.md +31 -31
- package/dist/docs/guides/history/vacuum.md +1 -10
- package/dist/docs/guides/read-and-write/automatic-links.md +15 -15
- package/dist/docs/guides/read-and-write/import-notes.md +21 -21
- package/dist/docs/guides/read-and-write/joins-and-aggregates.md +7 -7
- package/dist/docs/guides/read-and-write/read-and-filter.md +10 -10
- package/dist/docs/guides/read-and-write/write-rows.md +10 -10
- package/dist/docs/guides/search/link-graph.md +95 -0
- package/dist/docs/guides/search/text.md +1 -1
- package/dist/docs/guides/security/who-did-what.md +2 -0
- package/dist/docs/reference/cli.md +10 -3
- package/dist/docs/reference/compatibility.md +33 -13
- package/dist/docs/reference/errors.md +1 -1
- package/dist/docs/reference/operations/auxiliary.md +2 -2
- package/dist/docs/reference/operations/queries.md +3 -3
- package/dist/docs/reference/operations/rows.md +1 -1
- package/dist/docs/reference/operations/schema.md +15 -11
- package/dist/docs/reference/operations.md +39 -39
- package/dist/docs/reference/settings.md +37 -25
- package/dist/docs/release-notes.md +145 -0
- package/dist/docs/start/how-it-works.md +35 -3
- package/dist/docs/start/quick-start.md +2 -0
- package/package.json +3 -2
package/dist/api/index.cjs
CHANGED
|
@@ -28,21 +28,33 @@ __export(index_exports, {
|
|
|
28
28
|
OPERATIONS: () => OPERATIONS,
|
|
29
29
|
OperationInputError: () => OperationInputError,
|
|
30
30
|
OtlpLogExporter: () => OtlpLogExporter,
|
|
31
|
+
OtlpTraceExporter: () => OtlpTraceExporter,
|
|
31
32
|
ROUTE_PREFIX: () => ROUTE_PREFIX,
|
|
33
|
+
TRACEPARENT_HEADER: () => TRACEPARENT_HEADER,
|
|
34
|
+
TRACESTATE_HEADER: () => TRACESTATE_HEADER,
|
|
35
|
+
TraceSpan: () => TraceSpan,
|
|
36
|
+
Tracer: () => Tracer,
|
|
32
37
|
argumentsOf: () => argumentsOf,
|
|
33
38
|
checkArguments: () => checkArguments,
|
|
34
39
|
describeBatch: () => describeBatch,
|
|
35
40
|
describeRefusal: () => describeRefusal,
|
|
36
41
|
estimateTokens: () => estimateTokens,
|
|
37
42
|
fetchTransport: () => fetchTransport,
|
|
43
|
+
formatTraceparent: () => formatTraceparent,
|
|
38
44
|
guidanceIn: () => guidanceIn,
|
|
39
45
|
guidedText: () => guidedText,
|
|
46
|
+
newSpanId: () => newSpanId,
|
|
47
|
+
newTraceId: () => newTraceId,
|
|
40
48
|
operationRequest: () => operationRequest,
|
|
41
49
|
operationRoute: () => operationRoute,
|
|
42
50
|
otlpFromEnv: () => otlpFromEnv,
|
|
51
|
+
otlpTracesFromEnv: () => otlpTracesFromEnv,
|
|
43
52
|
parseOtlpHeaders: () => parseOtlpHeaders,
|
|
53
|
+
parseTraceparent: () => parseTraceparent,
|
|
44
54
|
resultOf: () => resultOf,
|
|
45
|
-
|
|
55
|
+
samplerRatioFromEnv: () => samplerRatioFromEnv,
|
|
56
|
+
toolDocs: () => toolDocs,
|
|
57
|
+
traceHeaders: () => traceHeaders
|
|
46
58
|
});
|
|
47
59
|
module.exports = __toCommonJS(index_exports);
|
|
48
60
|
|
|
@@ -378,7 +390,7 @@ var OPERATIONS = [
|
|
|
378
390
|
},
|
|
379
391
|
{
|
|
380
392
|
"name": "describe_table",
|
|
381
|
-
"description": "Describe a table (`catalog.schema.table` or a shorter unambiguous name): `qualified`, `name`,\n`catalog`, `schema`, `description`, `aliases`, `layout` (`folder`, `row_folder`: the folder pattern\nof new rows, `archive`), `options` (`partition`, `filename`, `archive`, `exclude`), typed `columns`\nwith label/aliases/description and the dense flag, `untyped_fields`, `row_count`, and when set:\n`tags`, `bases` (the bases it inherits from, in order), `constraints` (its CHECKs, name \u2192 where), `row_template`, `history`,\n`autolink_target`, `fields` (their values).\n\nBefore adding a column (e.g. a new metric), read `columns` and match your concept against\n`name`, `label`, `aliases` and `description`; reuse an existing column when it means the same.\n\n`missing_descriptions` (`{table, columns}`), present only when something has no description (a table\ndefined before descriptions were required), names what lacks one: write them with alter_table\n`description` and alter_column `changes.description`, asking the user when the meaning is unclear.",
|
|
393
|
+
"description": "Describe a table (`catalog.schema.table` or a shorter unambiguous name): `qualified`, `name`,\n`catalog`, `schema`, `description`, `aliases`, `layout` (`folder`, `row_folder`: the folder pattern\nof new rows, `archive`), `options` (`partition`, `filename`, `archive`, `exclude`), typed `columns`\nwith label/aliases/description and the dense flag, `untyped_fields`, `row_count`, and when set:\n`tags`, `bases` (the bases it inherits from, in order), `constraints` (its CHECKs, name \u2192 where), `constraint_hints` (their own hints, name \u2192 hint), `instructions` (how to fill a row: follow them before you write one), `row_template`, `history`,\n`autolink_target`, `fields` (their values).\n\nBefore adding a column (e.g. a new metric), read `columns` and match your concept against\n`name`, `label`, `aliases` and `description`; reuse an existing column when it means the same.\n\n`missing_descriptions` (`{table, columns}`), present only when something has no description (a table\ndefined before descriptions were required), names what lacks one: write them with alter_table\n`description` and alter_column `changes.description`, asking the user when the meaning is unclear.",
|
|
382
394
|
"inputSchema": {
|
|
383
395
|
"additionalProperties": false,
|
|
384
396
|
"properties": {
|
|
@@ -501,6 +513,10 @@ var OPERATIONS = [
|
|
|
501
513
|
"inverse": {
|
|
502
514
|
"type": "string"
|
|
503
515
|
},
|
|
516
|
+
"acyclic": {
|
|
517
|
+
"type": "boolean",
|
|
518
|
+
"description": "Link column to its own table whose links never form a cycle (a write that closes one is refused)."
|
|
519
|
+
},
|
|
504
520
|
"ref_where": {
|
|
505
521
|
"type": "object",
|
|
506
522
|
"description": "Link column: the where filter every linked row must match.",
|
|
@@ -610,6 +626,17 @@ var OPERATIONS = [
|
|
|
610
626
|
},
|
|
611
627
|
"description": "Its CHECK constraints: name \u2192 the where every row must match."
|
|
612
628
|
},
|
|
629
|
+
"constraint_hints": {
|
|
630
|
+
"type": "object",
|
|
631
|
+
"additionalProperties": {
|
|
632
|
+
"type": "string"
|
|
633
|
+
},
|
|
634
|
+
"description": "The hint of each CHECK that has one: name \u2192 what to do when a row breaks it."
|
|
635
|
+
},
|
|
636
|
+
"instructions": {
|
|
637
|
+
"type": "string",
|
|
638
|
+
"description": "How to fill a row of the table (alter_table instructions): follow them before you write one."
|
|
639
|
+
},
|
|
613
640
|
"row_template": {
|
|
614
641
|
"type": "string",
|
|
615
642
|
"description": "The text of every new row's note."
|
|
@@ -643,7 +670,7 @@ var OPERATIONS = [
|
|
|
643
670
|
},
|
|
644
671
|
{
|
|
645
672
|
"name": "create_table",
|
|
646
|
-
"description": 'Create a table: `name`, in `catalog` and `schema` (default: the database\'s defaults); the definition\ngoes in metastore.yaml, the rows in `<root>/<catalog>/<schema>/<name>/`. Names: lowercase letters,\ndigits, `_` (no dots: pass the catalog and the schema as their own arguments).\n- `description` (required): what a row of the table records. Every column needs its own `description`\n too, what it holds: the table is refused otherwise, with every missing one listed. Descriptions are how\n agents and people understand the schema, so write them for a reader who never saw the notes. The\n engine writes those of `id` and of `identity` "uuid" / "created" columns.\n- `columns`: specs like `{"name": "kind", "type": "enum", "values": ["a","b"], "required": true,\n "description": "What kind of entry the row is"}`.\n Types: string, integer, number, boolean, date, datetime, enum, link, list (+ `items`), json.\n Attributes: required, default (`"{now}"`/`"{today}"`), min, max, step, values, `ordered` (enum in\n order: filters/avg use the position), ref (link target, full `catalog.schema.table` or "self"),\n unique, label, description, aliases, `generated` (e.g. `"date(occurred_at)"`, `"{name} {surname}"`),\n `identity` ("filename" | "created"), `vocabulary` (allowed values = names of another table\'s rows),\n `hierarchy: true` (one parent link to its own table), `dense` (written on every row),\n `inverse` on a link column: the column of the `ref` table that links back (`friends` \u2194\n `friends`, `children` \u2194 `parents`, `partner` \u2194 `partner`); writes keep both sides in step.\n- `time_column`: rows named by that date/datetime; otherwise `filename` (e.g. `"{name}"`).\n- The table\'s options, as alter_table names them: `aliases` (how agents find it, with the\n description), `partition`, `exclude`, `archive`, `history` (keep its versions; default: the\n database\'s setting), `autolink_target` (true / false: may automatic links link its rows? default:\n yes, unless its rows are named by a date or a time, as with `time_column`).\n- `row_template`: markdown body of new rows. Shared columns come from bases: `set_table_bases`.\n- `tags`: key/value labels of the table, strings (`{"domain": "health"}`); list_tables and\n describe_table return them, alter_table changes them.\nEnum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", \u2026}`): describe_table shows them and a refused value lists them.\nGenerated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet).\nFiltered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
673
|
+
"description": 'Create a table: `name`, in `catalog` and `schema` (default: the database\'s defaults); the definition\ngoes in metastore.yaml, the rows in `<root>/<catalog>/<schema>/<name>/`. Names: lowercase letters,\ndigits, `_` (no dots: pass the catalog and the schema as their own arguments).\n- `description` (required): what a row of the table records. Every column needs its own `description`\n too, what it holds: the table is refused otherwise, with every missing one listed. Descriptions are how\n agents and people understand the schema, so write them for a reader who never saw the notes. The\n engine writes those of `id` and of `identity` "uuid" / "created" columns.\n- `columns`: specs like `{"name": "kind", "type": "enum", "values": ["a","b"], "required": true,\n "description": "What kind of entry the row is"}`.\n Types: string, integer, number, boolean, date, datetime, enum, link, list (+ `items`), json.\n Attributes: required, default (`"{now}"`/`"{today}"`), min, max, step, values, `ordered` (enum in\n order: filters/avg use the position), ref (link target, full `catalog.schema.table` or "self"),\n unique, label, description, aliases, `generated` (e.g. `"date(occurred_at)"`, `"{name} {surname}"`),\n `identity` ("filename" | "created"), `vocabulary` (allowed values = names of another table\'s rows),\n `hierarchy: true` (one parent link to its own table), `acyclic: true` (links to rows of its own table that never loop back, such as tasks blocked by tasks; with `inverse`, the rule holds on both sides), `dense` (written on every row),\n `inverse` on a link column: the column of the `ref` table that links back (`friends` \u2194\n `friends`, `children` \u2194 `parents`, `partner` \u2194 `partner`); writes keep both sides in step.\n- `time_column`: rows named by that date/datetime; otherwise `filename` (e.g. `"{name}"`).\n- The table\'s options, as alter_table names them: `aliases` (how agents find it, with the\n description), `partition`, `exclude`, `archive`, `history` (keep its versions; default: the\n database\'s setting), `autolink_target` (true / false: may automatic links link its rows? default:\n yes, unless its rows are named by a date or a time, as with `time_column`).\n- `row_template`: markdown body of new rows. Shared columns come from bases: `set_table_bases`.\n- `instructions`: how to fill a row, for agents (Markdown); describe_table returns them.\n- `tags`: key/value labels of the table, strings (`{"domain": "health"}`); list_tables and\n describe_table return them, alter_table changes them.\nEnum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", \u2026}`): describe_table shows them and a refused value lists them.\nGenerated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet).\nFiltered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
647
674
|
"inputSchema": {
|
|
648
675
|
"additionalProperties": false,
|
|
649
676
|
"properties": {
|
|
@@ -804,6 +831,18 @@ var OPERATIONS = [
|
|
|
804
831
|
"default": null,
|
|
805
832
|
"description": "Markdown body of new rows; {column} placeholders are filled from the row."
|
|
806
833
|
},
|
|
834
|
+
"instructions": {
|
|
835
|
+
"anyOf": [
|
|
836
|
+
{
|
|
837
|
+
"type": "string"
|
|
838
|
+
},
|
|
839
|
+
{
|
|
840
|
+
"type": "null"
|
|
841
|
+
}
|
|
842
|
+
],
|
|
843
|
+
"default": null,
|
|
844
|
+
"description": "How to fill a row, for agents (Markdown): which columns first, what to ask the user. describe_table returns them."
|
|
845
|
+
},
|
|
807
846
|
"fields": {
|
|
808
847
|
"anyOf": [
|
|
809
848
|
{
|
|
@@ -941,6 +980,10 @@ var OPERATIONS = [
|
|
|
941
980
|
"type": "string",
|
|
942
981
|
"description": "The CHECK's name (code check)."
|
|
943
982
|
},
|
|
983
|
+
"hint": {
|
|
984
|
+
"type": "string",
|
|
985
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
986
|
+
},
|
|
944
987
|
"code": {
|
|
945
988
|
"type": "string",
|
|
946
989
|
"enum": [
|
|
@@ -1350,6 +1393,10 @@ var OPERATIONS = [
|
|
|
1350
1393
|
"type": "string",
|
|
1351
1394
|
"description": "The CHECK's name (code check)."
|
|
1352
1395
|
},
|
|
1396
|
+
"hint": {
|
|
1397
|
+
"type": "string",
|
|
1398
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
1399
|
+
},
|
|
1353
1400
|
"code": {
|
|
1354
1401
|
"type": "string",
|
|
1355
1402
|
"enum": [
|
|
@@ -1629,7 +1676,7 @@ var OPERATIONS = [
|
|
|
1629
1676
|
},
|
|
1630
1677
|
{
|
|
1631
1678
|
"name": "add_column",
|
|
1632
|
-
"description": 'Add a typed column. Sparse by default (written only on rows that have a value \u2014 use for\nmetrics, e.g. `{"name": "metric_mood", "type": "integer", "min": 1, "max": 5, "label":\n"Mood", "aliases": ["mood"], "description": "Mood of the day, 1 = bad, 5 = great"}`).\n`description` is required: what the column holds, for the agents and people who read the schema\n(the engine writes it for `identity` "uuid" / "created" columns).\n`dense: true` in the spec adds it to every row with its `default`. Call `describe_table` first: never add\na column whose meaning an existing column (name/label/aliases/description) already covers.\nColumn names are permanent identifiers; only `rename_column` changes them.\nEnum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", \u2026}`): describe_table shows them and a refused value lists them.\nGenerated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet).\nFiltered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
1679
|
+
"description": 'Add a typed column. Sparse by default (written only on rows that have a value \u2014 use for\nmetrics, e.g. `{"name": "metric_mood", "type": "integer", "min": 1, "max": 5, "label":\n"Mood", "aliases": ["mood"], "description": "Mood of the day, 1 = bad, 5 = great"}`).\n`description` is required: what the column holds, for the agents and people who read the schema\n(the engine writes it for `identity` "uuid" / "created" columns).\n`dense: true` in the spec adds it to every row with its `default`. Call `describe_table` first: never add\na column whose meaning an existing column (name/label/aliases/description) already covers.\nColumn names are permanent identifiers; only `rename_column` changes them.\nEnum columns: `values` and, for each, its meaning in `value_descriptions` (`{"stated": "the user said it", \u2026}`): describe_table shows them and a refused value lists them.\nGenerated link columns: `generated: "link({occurred_at:YYYY-MM-DD})"` with `ref` = the days table links each row to the row of `ref` named by the template (its folder read from the schema; the target may not exist yet).\nFiltered link targets (link columns): `ref_where` (a `where` every target must match) and `ref_by` (a column of the row picks the target level: `{"column": "kind", "levels": ["area", "project", "workstream"]}` or `{"column": "kind", "map": {"area": null, "project": ["area"]}}`; null = top level, no link; `target_column` when the target names it differently: an enum target column must have every value the map allows, a string one takes any value). A link to no row of the table, or to the row itself, is refused too. Existing rows that break them refuse the change; `list_link_targets` lists the valid targets of a row.\nAcyclic links: `acyclic: true` on a link (or list of links) to the table itself refuses every write that closes a cycle, on either side of an `inverse`; refused while existing rows form one (they are listed).\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
1633
1680
|
"inputSchema": {
|
|
1634
1681
|
"additionalProperties": false,
|
|
1635
1682
|
"properties": {
|
|
@@ -1750,6 +1797,10 @@ var OPERATIONS = [
|
|
|
1750
1797
|
"type": "string",
|
|
1751
1798
|
"description": "The CHECK's name (code check)."
|
|
1752
1799
|
},
|
|
1800
|
+
"hint": {
|
|
1801
|
+
"type": "string",
|
|
1802
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
1803
|
+
},
|
|
1753
1804
|
"code": {
|
|
1754
1805
|
"type": "string",
|
|
1755
1806
|
"enum": [
|
|
@@ -2152,6 +2203,10 @@ var OPERATIONS = [
|
|
|
2152
2203
|
"type": "string",
|
|
2153
2204
|
"description": "The CHECK's name (code check)."
|
|
2154
2205
|
},
|
|
2206
|
+
"hint": {
|
|
2207
|
+
"type": "string",
|
|
2208
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
2209
|
+
},
|
|
2155
2210
|
"code": {
|
|
2156
2211
|
"type": "string",
|
|
2157
2212
|
"enum": [
|
|
@@ -2551,6 +2606,10 @@ var OPERATIONS = [
|
|
|
2551
2606
|
"type": "string",
|
|
2552
2607
|
"description": "The CHECK's name (code check)."
|
|
2553
2608
|
},
|
|
2609
|
+
"hint": {
|
|
2610
|
+
"type": "string",
|
|
2611
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
2612
|
+
},
|
|
2554
2613
|
"code": {
|
|
2555
2614
|
"type": "string",
|
|
2556
2615
|
"enum": [
|
|
@@ -2830,7 +2889,7 @@ var OPERATIONS = [
|
|
|
2830
2889
|
},
|
|
2831
2890
|
{
|
|
2832
2891
|
"name": "alter_column",
|
|
2833
|
-
"description": 'Change a column\'s attributes (type, min/max/step, values, required, default, label,\naliases, description, note, `ref_where`, `ref_by` (see list_link_targets); `null` removes an attribute, except\n`description`, which changes but never goes (null or "" is refused); `dense` true/false). Refused with\nthe list of violating rows when existing values do not satisfy the new definition. A\ndifferent scale means a different column: add a new one instead of rescaling. To rename one\nenum value use `rename_value`. Dropping an enum value that a `ref_by` (of any table) allows as a\ntarget level is refused, naming it.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
2892
|
+
"description": 'Change a column\'s attributes (type, min/max/step, values, required, default, label,\naliases, description, note, `ref_where`, `ref_by` (see list_link_targets), `acyclic` (refused while the rows already form a cycle: they are listed); `null` removes an attribute, except\n`description`, which changes but never goes (null or "" is refused); `dense` true/false). Refused with\nthe list of violating rows when existing values do not satisfy the new definition. A\ndifferent scale means a different column: add a new one instead of rescaling. To rename one\nenum value use `rename_value`. Dropping an enum value that a `ref_by` (of any table) allows as a\ntarget level is refused, naming it.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
2834
2893
|
"inputSchema": {
|
|
2835
2894
|
"additionalProperties": false,
|
|
2836
2895
|
"properties": {
|
|
@@ -2955,6 +3014,10 @@ var OPERATIONS = [
|
|
|
2955
3014
|
"type": "string",
|
|
2956
3015
|
"description": "The CHECK's name (code check)."
|
|
2957
3016
|
},
|
|
3017
|
+
"hint": {
|
|
3018
|
+
"type": "string",
|
|
3019
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
3020
|
+
},
|
|
2958
3021
|
"code": {
|
|
2959
3022
|
"type": "string",
|
|
2960
3023
|
"enum": [
|
|
@@ -3234,7 +3297,7 @@ var OPERATIONS = [
|
|
|
3234
3297
|
},
|
|
3235
3298
|
{
|
|
3236
3299
|
"name": "alter_table",
|
|
3237
|
-
"description": 'Alter a table: move it (`catalog`, `schema`), rename it (`name`), change\n`partition` / `filename` patterns, `description` (changes, never goes: "" is refused), `aliases`,\n`exclude` folders, `row_template`\n("" removes it), `history` (true | false | "default"), `autolink_target`\n(true | false | "default": may automatic links link its rows? default: yes, unless its rows are named by\na date or a time) or `tags` (key/value\nlabels merged into the table\'s, e.g. `{"domain": "health"}`; a `null` value removes that tag;\n`clear_tags: true` removes every tag first, so with `tags` the table keeps exactly those),\n`archive` (folder name inside the table folder) or `fields` (untyped fields, name \u2192 default; a\n`null` value removes one). Rows, archive and transaction log follow; links are updated; renamed\nrows keep their old name in `aliases`. A change of metadata only (tags, description, aliases,\nhistory, autolink_target, row_template, fields) rewrites the table entry alone: no row is moved or rewritten. Refused\nwhen a row cannot fill a pattern. Renaming or moving the table is refused while a CHECK that follows\nlinks, or a `ref_where` / `ref_by`, of another table reads it through a link (link targets are not\nrewritten): the conflicts name them. Use `dry_run` to see `planned_moves`; undo with undo_migration.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
3300
|
+
"description": 'Alter a table: move it (`catalog`, `schema`), rename it (`name`), change\n`partition` / `filename` patterns, `description` (changes, never goes: "" is refused), `aliases`,\n`exclude` folders, `row_template`\n("" removes it), `instructions` (how to fill a row, for agents; "" removes them), `history` (true | false | "default"), `autolink_target`\n(true | false | "default": may automatic links link its rows? default: yes, unless its rows are named by\na date or a time) or `tags` (key/value\nlabels merged into the table\'s, e.g. `{"domain": "health"}`; a `null` value removes that tag;\n`clear_tags: true` removes every tag first, so with `tags` the table keeps exactly those),\n`archive` (folder name inside the table folder) or `fields` (untyped fields, name \u2192 default; a\n`null` value removes one). Rows, archive and transaction log follow; links are updated; renamed\nrows keep their old name in `aliases`. A change of metadata only (tags, description, aliases,\nhistory, autolink_target, row_template, instructions, fields) rewrites the table entry alone: no row is moved or rewritten. Refused\nwhen a row cannot fill a pattern. Renaming or moving the table is refused while a CHECK that follows\nlinks, or a `ref_where` / `ref_by`, of another table reads it through a link (link targets are not\nrewritten): the conflicts name them. Use `dry_run` to see `planned_moves`; undo with undo_migration.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
3238
3301
|
"inputSchema": {
|
|
3239
3302
|
"additionalProperties": false,
|
|
3240
3303
|
"properties": {
|
|
@@ -3384,6 +3447,18 @@ var OPERATIONS = [
|
|
|
3384
3447
|
"default": null,
|
|
3385
3448
|
"description": 'Markdown body of new rows; "" removes it.'
|
|
3386
3449
|
},
|
|
3450
|
+
"instructions": {
|
|
3451
|
+
"anyOf": [
|
|
3452
|
+
{
|
|
3453
|
+
"type": "string"
|
|
3454
|
+
},
|
|
3455
|
+
{
|
|
3456
|
+
"type": "null"
|
|
3457
|
+
}
|
|
3458
|
+
],
|
|
3459
|
+
"default": null,
|
|
3460
|
+
"description": 'How to fill a row, for agents (Markdown); "" removes them.'
|
|
3461
|
+
},
|
|
3387
3462
|
"tags": {
|
|
3388
3463
|
"anyOf": [
|
|
3389
3464
|
{
|
|
@@ -3544,6 +3619,10 @@ var OPERATIONS = [
|
|
|
3544
3619
|
"type": "string",
|
|
3545
3620
|
"description": "The CHECK's name (code check)."
|
|
3546
3621
|
},
|
|
3622
|
+
"hint": {
|
|
3623
|
+
"type": "string",
|
|
3624
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
3625
|
+
},
|
|
3547
3626
|
"code": {
|
|
3548
3627
|
"type": "string",
|
|
3549
3628
|
"enum": [
|
|
@@ -4000,6 +4079,10 @@ var OPERATIONS = [
|
|
|
4000
4079
|
"type": "string",
|
|
4001
4080
|
"description": "The CHECK's name (code check)."
|
|
4002
4081
|
},
|
|
4082
|
+
"hint": {
|
|
4083
|
+
"type": "string",
|
|
4084
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
4085
|
+
},
|
|
4003
4086
|
"code": {
|
|
4004
4087
|
"type": "string",
|
|
4005
4088
|
"enum": [
|
|
@@ -4401,6 +4484,10 @@ var OPERATIONS = [
|
|
|
4401
4484
|
"type": "string",
|
|
4402
4485
|
"description": "The CHECK's name (code check)."
|
|
4403
4486
|
},
|
|
4487
|
+
"hint": {
|
|
4488
|
+
"type": "string",
|
|
4489
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
4490
|
+
},
|
|
4404
4491
|
"code": {
|
|
4405
4492
|
"type": "string",
|
|
4406
4493
|
"enum": [
|
|
@@ -5463,6 +5550,10 @@ var OPERATIONS = [
|
|
|
5463
5550
|
"type": "string",
|
|
5464
5551
|
"description": "The CHECK's name (code check)."
|
|
5465
5552
|
},
|
|
5553
|
+
"hint": {
|
|
5554
|
+
"type": "string",
|
|
5555
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
5556
|
+
},
|
|
5466
5557
|
"code": {
|
|
5467
5558
|
"type": "string",
|
|
5468
5559
|
"enum": [
|
|
@@ -5869,6 +5960,10 @@ var OPERATIONS = [
|
|
|
5869
5960
|
"type": "string",
|
|
5870
5961
|
"description": "The CHECK's name (code check)."
|
|
5871
5962
|
},
|
|
5963
|
+
"hint": {
|
|
5964
|
+
"type": "string",
|
|
5965
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
5966
|
+
},
|
|
5872
5967
|
"code": {
|
|
5873
5968
|
"type": "string",
|
|
5874
5969
|
"enum": [
|
|
@@ -6148,7 +6243,7 @@ var OPERATIONS = [
|
|
|
6148
6243
|
},
|
|
6149
6244
|
{
|
|
6150
6245
|
"name": "insert_row",
|
|
6151
|
-
"description": "Insert a row (new note). Values are validated against the columns; the note path comes from\nthe table's `path`/`filename` patterns (e.g. an event logged today about last night lands in\nlast night's day folder when you set `occurred_at` to last night). `body` is the note text.\nGenerated / identity columns are computed (do not pass them); CHECK constraints are enforced.\nReturns `migration_id` (undo) and the created path in `planned_creates`.\n`body` links the notes it mentions by name, at their first mention (automatic links; off with\n`autolink: false` or the database's `autolink` setting). `links_added` lists the links made;\n`ambiguous_mentions` lists the mentions left as text with the notes they may name: read those,\nthen link the right one with update_row and `autolink: false`, or leave the text.",
|
|
6246
|
+
"description": "Insert a row (new note). When describe_table gives the table's `instructions`, fill the row as they say. Values are validated against the columns; the note path comes from\nthe table's `path`/`filename` patterns (e.g. an event logged today about last night lands in\nlast night's day folder when you set `occurred_at` to last night). `body` is the note text.\nGenerated / identity columns are computed (do not pass them); CHECK constraints are enforced.\nReturns `migration_id` (undo) and the created path in `planned_creates`.\n`body` links the notes it mentions by name, at their first mention (automatic links; off with\n`autolink: false` or the database's `autolink` setting). `links_added` lists the links made;\n`ambiguous_mentions` lists the mentions left as text with the notes they may name: read those,\nthen link the right one with update_row and `autolink: false`, or leave the text.",
|
|
6152
6247
|
"inputSchema": {
|
|
6153
6248
|
"additionalProperties": false,
|
|
6154
6249
|
"properties": {
|
|
@@ -6303,6 +6398,10 @@ var OPERATIONS = [
|
|
|
6303
6398
|
"type": "string",
|
|
6304
6399
|
"description": "The CHECK's name (code check)."
|
|
6305
6400
|
},
|
|
6401
|
+
"hint": {
|
|
6402
|
+
"type": "string",
|
|
6403
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
6404
|
+
},
|
|
6306
6405
|
"code": {
|
|
6307
6406
|
"type": "string",
|
|
6308
6407
|
"enum": [
|
|
@@ -6741,6 +6840,10 @@ var OPERATIONS = [
|
|
|
6741
6840
|
"type": "string",
|
|
6742
6841
|
"description": "The CHECK's name (code check)."
|
|
6743
6842
|
},
|
|
6843
|
+
"hint": {
|
|
6844
|
+
"type": "string",
|
|
6845
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
6846
|
+
},
|
|
6744
6847
|
"code": {
|
|
6745
6848
|
"type": "string",
|
|
6746
6849
|
"enum": [
|
|
@@ -7254,6 +7357,10 @@ var OPERATIONS = [
|
|
|
7254
7357
|
"type": "string",
|
|
7255
7358
|
"description": "The CHECK's name (code check)."
|
|
7256
7359
|
},
|
|
7360
|
+
"hint": {
|
|
7361
|
+
"type": "string",
|
|
7362
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
7363
|
+
},
|
|
7257
7364
|
"code": {
|
|
7258
7365
|
"type": "string",
|
|
7259
7366
|
"enum": [
|
|
@@ -7685,6 +7792,10 @@ var OPERATIONS = [
|
|
|
7685
7792
|
"type": "string",
|
|
7686
7793
|
"description": "The CHECK's name (code check)."
|
|
7687
7794
|
},
|
|
7795
|
+
"hint": {
|
|
7796
|
+
"type": "string",
|
|
7797
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
7798
|
+
},
|
|
7688
7799
|
"code": {
|
|
7689
7800
|
"type": "string",
|
|
7690
7801
|
"enum": [
|
|
@@ -8133,6 +8244,10 @@ var OPERATIONS = [
|
|
|
8133
8244
|
"type": "string",
|
|
8134
8245
|
"description": "The CHECK's name (code check)."
|
|
8135
8246
|
},
|
|
8247
|
+
"hint": {
|
|
8248
|
+
"type": "string",
|
|
8249
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
8250
|
+
},
|
|
8136
8251
|
"code": {
|
|
8137
8252
|
"type": "string",
|
|
8138
8253
|
"enum": [
|
|
@@ -8593,6 +8708,10 @@ var OPERATIONS = [
|
|
|
8593
8708
|
"type": "string",
|
|
8594
8709
|
"description": "The CHECK's name (code check)."
|
|
8595
8710
|
},
|
|
8711
|
+
"hint": {
|
|
8712
|
+
"type": "string",
|
|
8713
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
8714
|
+
},
|
|
8596
8715
|
"code": {
|
|
8597
8716
|
"type": "string",
|
|
8598
8717
|
"enum": [
|
|
@@ -9101,7 +9220,7 @@ var OPERATIONS = [
|
|
|
9101
9220
|
},
|
|
9102
9221
|
{
|
|
9103
9222
|
"name": "check_table",
|
|
9104
|
-
"description": "Validate every row against the table (required, types, ranges, enums, links, unknown\ncolumns, CHECK constraints, those that follow links included, filtered link targets (ref_where / ref_by), stale generated/identity values, missing inverse links, front matter that cannot be read: code `unreadable`, with no column, for a note whose `table` line names the table but whose YAML is broken, which every other read leaves out). A CHECK violation has code `check` and the CHECK's name as `constraint` (every other code names its `column`), as in the `violations` of list_changes. Use it to find rows edited by hand that break the schema. Without `table`, every table is checked: each row then names its `table`, `tables_checked` counts the tables checked, and a table that cannot be checked is listed in `errors` ({table, error}) while the others are. The rows with violations are paged: `limit` (default 500, at most 5000) from `offset`; `total` counts them all. (Hand edits are also checked as they happen: see `violations` in list_changes.)",
|
|
9223
|
+
"description": "Validate every row against the table (required, types, ranges, enums, links, unknown\ncolumns, CHECK constraints, those that follow links included, filtered link targets (ref_where / ref_by), stale generated/identity values, missing inverse links, cycles of hierarchy and acyclic columns, front matter that cannot be read: code `unreadable`, with no column, for a note whose `table` line names the table but whose YAML is broken, which every other read leaves out). A CHECK violation has code `check` and the CHECK's name as `constraint` (every other code names its `column`), as in the `violations` of list_changes. Use it to find rows edited by hand that break the schema. Without `table`, every table is checked: each row then names its `table`, `tables_checked` counts the tables checked, and a table that cannot be checked is listed in `errors` ({table, error}) while the others are. The rows with violations are paged: `limit` (default 500, at most 5000) from `offset`; `total` counts them all. (Hand edits are also checked as they happen: see `violations` in list_changes.)",
|
|
9105
9224
|
"inputSchema": {
|
|
9106
9225
|
"additionalProperties": false,
|
|
9107
9226
|
"properties": {
|
|
@@ -9214,6 +9333,10 @@ var OPERATIONS = [
|
|
|
9214
9333
|
"type": "string",
|
|
9215
9334
|
"description": "The CHECK's name (code check)."
|
|
9216
9335
|
},
|
|
9336
|
+
"hint": {
|
|
9337
|
+
"type": "string",
|
|
9338
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
9339
|
+
},
|
|
9217
9340
|
"code": {
|
|
9218
9341
|
"type": "string",
|
|
9219
9342
|
"enum": [
|
|
@@ -9667,6 +9790,10 @@ var OPERATIONS = [
|
|
|
9667
9790
|
"type": "string",
|
|
9668
9791
|
"description": "The CHECK's name (code check)."
|
|
9669
9792
|
},
|
|
9793
|
+
"hint": {
|
|
9794
|
+
"type": "string",
|
|
9795
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
9796
|
+
},
|
|
9670
9797
|
"code": {
|
|
9671
9798
|
"type": "string",
|
|
9672
9799
|
"enum": [
|
|
@@ -10110,6 +10237,10 @@ var OPERATIONS = [
|
|
|
10110
10237
|
"type": "string",
|
|
10111
10238
|
"description": "The CHECK's name (code check)."
|
|
10112
10239
|
},
|
|
10240
|
+
"hint": {
|
|
10241
|
+
"type": "string",
|
|
10242
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
10243
|
+
},
|
|
10113
10244
|
"code": {
|
|
10114
10245
|
"type": "string",
|
|
10115
10246
|
"enum": [
|
|
@@ -11193,6 +11324,10 @@ var OPERATIONS = [
|
|
|
11193
11324
|
"type": "string",
|
|
11194
11325
|
"description": "The CHECK's name (code check)."
|
|
11195
11326
|
},
|
|
11327
|
+
"hint": {
|
|
11328
|
+
"type": "string",
|
|
11329
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
11330
|
+
},
|
|
11196
11331
|
"code": {
|
|
11197
11332
|
"type": "string",
|
|
11198
11333
|
"enum": [
|
|
@@ -12630,6 +12765,10 @@ var OPERATIONS = [
|
|
|
12630
12765
|
"type": "string",
|
|
12631
12766
|
"description": "The CHECK's name (code check)."
|
|
12632
12767
|
},
|
|
12768
|
+
"hint": {
|
|
12769
|
+
"type": "string",
|
|
12770
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
12771
|
+
},
|
|
12633
12772
|
"code": {
|
|
12634
12773
|
"type": "string",
|
|
12635
12774
|
"enum": [
|
|
@@ -13040,6 +13179,10 @@ var OPERATIONS = [
|
|
|
13040
13179
|
"type": "string",
|
|
13041
13180
|
"description": "The CHECK's name (code check)."
|
|
13042
13181
|
},
|
|
13182
|
+
"hint": {
|
|
13183
|
+
"type": "string",
|
|
13184
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
13185
|
+
},
|
|
13043
13186
|
"code": {
|
|
13044
13187
|
"type": "string",
|
|
13045
13188
|
"enum": [
|
|
@@ -13506,7 +13649,7 @@ var OPERATIONS = [
|
|
|
13506
13649
|
},
|
|
13507
13650
|
{
|
|
13508
13651
|
"name": "add_constraint",
|
|
13509
|
-
"description": 'ALTER TABLE ADD CONSTRAINT `name` CHECK: `check` is a where filter every row must match,\ne.g. `{"value": {"gte": 1, "lte": 5}}`. A condition on a column the row leaves empty passes, like SQL;\ninside `or` / `and` / `not` an empty value is tested as it is (`{"exists": true}` there fails).\nA key may follow a link column to the row it names, as in queries: `{"parent.kind": "project"}`\n(further dots follow further links). An empty link passes at the top level and fails inside `or` / `and` /\n`not`; only the first link of a longer path is skipped when empty (`parent.parent.kind` fails for a row\nwhose parent has no parent). A link to a row that does not exist fails; on a list of links every linked\nrow must match. `not` turns that into a pass: `{"not": {"parent.kind": "area"}}` passes a link to a\nmissing row, so add `"parent.kind": {"exists": true}` to require a real one. Links resolve as in the\nvault (by path, from the row\'s note: same-named rows in two folders stay apart); renaming or moving a\nlinked row keeps them (they follow it).\nRefused while existing rows violate it (they are listed); then enforced on every write, by the same rule.\nA write that changes a linked row re-checks the rows that link to it and is refused, listing them, when\nit breaks them, naming the changed row (in a batch, re-link them first: each step is checked on the vault\nthe earlier ones left); the inverse links a write adds, undo_migration and restore_table are checked too.\nrename_column / rename_value follow into CHECKs; drop_column of a column a CHECK reads is refused.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
13652
|
+
"description": 'ALTER TABLE ADD CONSTRAINT `name` CHECK: `check` is a where filter every row must match,\ne.g. `{"value": {"gte": 1, "lte": 5}}`. A condition on a column the row leaves empty passes, like SQL;\ninside `or` / `and` / `not` an empty value is tested as it is (`{"exists": true}` there fails).\nA key may follow a link column to the row it names, as in queries: `{"parent.kind": "project"}`\n(further dots follow further links). An empty link passes at the top level and fails inside `or` / `and` /\n`not`; only the first link of a longer path is skipped when empty (`parent.parent.kind` fails for a row\nwhose parent has no parent). A link to a row that does not exist fails; on a list of links every linked\nrow must match. `not` turns that into a pass: `{"not": {"parent.kind": "area"}}` passes a link to a\nmissing row, so add `"parent.kind": {"exists": true}` to require a real one. Links resolve as in the\nvault (by path, from the row\'s note: same-named rows in two folders stay apart); renaming or moving a\nlinked row keeps them (they follow it).\nRefused while existing rows violate it (they are listed); then enforced on every write, by the same rule.\nA write that changes a linked row re-checks the rows that link to it and is refused, listing them, when\nit breaks them, naming the changed row (in a batch, re-link them first: each step is checked on the vault\nthe earlier ones left); the inverse links a write adds, undo_migration and restore_table are checked too.\nrename_column / rename_value follow into CHECKs; drop_column of a column a CHECK reads is refused.\n`hint`: what to do when a row breaks the rule, in your words; a refused write puts it first in its hint, and each violation of the CHECK carries it.\n\nThe schema changes only through operations like this one: never edit metastore.yaml by hand (no validation, no undo).',
|
|
13510
13653
|
"inputSchema": {
|
|
13511
13654
|
"additionalProperties": false,
|
|
13512
13655
|
"properties": {
|
|
@@ -13520,6 +13663,18 @@ var OPERATIONS = [
|
|
|
13520
13663
|
"additionalProperties": true,
|
|
13521
13664
|
"type": "object"
|
|
13522
13665
|
},
|
|
13666
|
+
"hint": {
|
|
13667
|
+
"anyOf": [
|
|
13668
|
+
{
|
|
13669
|
+
"type": "string"
|
|
13670
|
+
},
|
|
13671
|
+
{
|
|
13672
|
+
"type": "null"
|
|
13673
|
+
}
|
|
13674
|
+
],
|
|
13675
|
+
"default": null,
|
|
13676
|
+
"description": "What a refused write tells the agent when a row breaks this CHECK: how to fix the row. It comes first in the refusal's hint; describe_table lists it in constraint_hints."
|
|
13677
|
+
},
|
|
13523
13678
|
"dry_run": {
|
|
13524
13679
|
"default": false,
|
|
13525
13680
|
"type": "boolean"
|
|
@@ -13630,6 +13785,10 @@ var OPERATIONS = [
|
|
|
13630
13785
|
"type": "string",
|
|
13631
13786
|
"description": "The CHECK's name (code check)."
|
|
13632
13787
|
},
|
|
13788
|
+
"hint": {
|
|
13789
|
+
"type": "string",
|
|
13790
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
13791
|
+
},
|
|
13633
13792
|
"code": {
|
|
13634
13793
|
"type": "string",
|
|
13635
13794
|
"enum": [
|
|
@@ -14028,6 +14187,10 @@ var OPERATIONS = [
|
|
|
14028
14187
|
"type": "string",
|
|
14029
14188
|
"description": "The CHECK's name (code check)."
|
|
14030
14189
|
},
|
|
14190
|
+
"hint": {
|
|
14191
|
+
"type": "string",
|
|
14192
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
14193
|
+
},
|
|
14031
14194
|
"code": {
|
|
14032
14195
|
"type": "string",
|
|
14033
14196
|
"enum": [
|
|
@@ -14493,6 +14656,10 @@ var OPERATIONS = [
|
|
|
14493
14656
|
"type": "string",
|
|
14494
14657
|
"description": "The CHECK's name (code check)."
|
|
14495
14658
|
},
|
|
14659
|
+
"hint": {
|
|
14660
|
+
"type": "string",
|
|
14661
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
14662
|
+
},
|
|
14496
14663
|
"code": {
|
|
14497
14664
|
"type": "string",
|
|
14498
14665
|
"enum": [
|
|
@@ -14887,6 +15054,10 @@ var OPERATIONS = [
|
|
|
14887
15054
|
"type": "string",
|
|
14888
15055
|
"description": "The CHECK's name (code check)."
|
|
14889
15056
|
},
|
|
15057
|
+
"hint": {
|
|
15058
|
+
"type": "string",
|
|
15059
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
15060
|
+
},
|
|
14890
15061
|
"code": {
|
|
14891
15062
|
"type": "string",
|
|
14892
15063
|
"enum": [
|
|
@@ -15312,6 +15483,10 @@ var OPERATIONS = [
|
|
|
15312
15483
|
"type": "string",
|
|
15313
15484
|
"description": "The CHECK's name (code check)."
|
|
15314
15485
|
},
|
|
15486
|
+
"hint": {
|
|
15487
|
+
"type": "string",
|
|
15488
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
15489
|
+
},
|
|
15315
15490
|
"code": {
|
|
15316
15491
|
"type": "string",
|
|
15317
15492
|
"enum": [
|
|
@@ -15724,6 +15899,10 @@ var OPERATIONS = [
|
|
|
15724
15899
|
"type": "string",
|
|
15725
15900
|
"description": "The CHECK's name (code check)."
|
|
15726
15901
|
},
|
|
15902
|
+
"hint": {
|
|
15903
|
+
"type": "string",
|
|
15904
|
+
"description": "The CHECK's own hint (code check), when the constraint has one: how to fix the row."
|
|
15905
|
+
},
|
|
15727
15906
|
"code": {
|
|
15728
15907
|
"type": "string",
|
|
15729
15908
|
"enum": [
|
|
@@ -16003,7 +16182,7 @@ var OPERATIONS = [
|
|
|
16003
16182
|
},
|
|
16004
16183
|
{
|
|
16005
16184
|
"name": "graph_neighbors",
|
|
16006
|
-
"description": 'Direct neighbours of notes: what they link to (`out`) and what links to them (`in`,\nbacklinks), with counts per edge label. `direction`: out, in or both (default).\n\n`from_nodes` selects the notes: `{"paths": [...]}
|
|
16185
|
+
"description": 'Direct neighbours of notes: what they link to (`out`) and what links to them (`in`,\nbacklinks), with counts per edge label. `direction`: out, in or both (default).\n\n`from_nodes` selects the notes: `{"paths": [...]}`, `{"table": ..., "where": {...}}` and/or\n`{"tables": [...]}`: the rows of several tables, by name or pattern (`["*"]` every table, `["personal.*"]` a\ncatalog\'s). The whole vault\'s graph in one call: `{"tables": ["*"]}` with direction `out` (at most 5000\nstart notes). Edges are labelled with their link column (`people`, `event`, \u2026) or `link` for other links.',
|
|
16007
16186
|
"inputSchema": {
|
|
16008
16187
|
"additionalProperties": false,
|
|
16009
16188
|
"properties": {
|
|
@@ -16122,7 +16301,7 @@ var OPERATIONS = [
|
|
|
16122
16301
|
},
|
|
16123
16302
|
{
|
|
16124
16303
|
"name": "graph_traverse",
|
|
16125
|
-
"description": 'Breadth-first walk over links from `from_nodes` (`{"paths": [...]}
|
|
16304
|
+
"description": 'Breadth-first walk over links from `from_nodes` (`{"paths": [...]}`, `{"table", "where"}` and/or `{"tables": [...]}`).\n\n- `direction`: out (default, follow links), in (follow backlinks) or both.\n- `edges`: edge labels to follow (link columns such as `people`, `event`, or `link`).\n- `tables`: return only notes of these tables; `through`: only walk on through these tables.\n- `min_depth` (default 1) / `max_depth` (default 2, max 10), `limit` (default 500).\n\nEach node comes with `depth` and `via` (one shortest route). Example \u2014 moods tied to events\nwith Alice: from `{"table": "person", "where": {"name": "Alice"}}`, direction `in`, edges\n`["people", "event"]`, tables `["mood"]`, max_depth 2. Feed the paths to `select_rows` with\n`where: {"path": {"in": [...]}}` to aggregate them.',
|
|
16126
16305
|
"inputSchema": {
|
|
16127
16306
|
"additionalProperties": false,
|
|
16128
16307
|
"properties": {
|
|
@@ -16318,7 +16497,7 @@ var OPERATIONS = [
|
|
|
16318
16497
|
},
|
|
16319
16498
|
{
|
|
16320
16499
|
"name": "graph_path",
|
|
16321
|
-
"description": 'Shortest chain of links between two sets of notes (each `{"paths": [...]}
|
|
16500
|
+
"description": 'Shortest chain of links between two sets of notes (each `{"paths": [...]}`, `{"table", "where"}`\nand/or `{"tables": [...]}`): `found`, `length` and `path`: the steps (`from`, `label`, `direction`, `to`).\n`direction` both by default; `max_depth` default 6 (max 10).',
|
|
16322
16501
|
"inputSchema": {
|
|
16323
16502
|
"additionalProperties": false,
|
|
16324
16503
|
"properties": {
|
|
@@ -16706,17 +16885,52 @@ function resultOf(status, json, text) {
|
|
|
16706
16885
|
// src/api/tokens.ts
|
|
16707
16886
|
function estimateTokens(text) {
|
|
16708
16887
|
let n = 0;
|
|
16709
|
-
|
|
16710
|
-
|
|
16711
|
-
|
|
16712
|
-
|
|
16713
|
-
|
|
16888
|
+
let run = 0;
|
|
16889
|
+
for (let i = 0; i < text.length; ) {
|
|
16890
|
+
const c = text.charCodeAt(i);
|
|
16891
|
+
const cp = c >= 55296 && c <= 56319 ? text.codePointAt(i) : c;
|
|
16892
|
+
const width = cp > 65535 ? 2 : 1;
|
|
16893
|
+
const kind = classOf(cp);
|
|
16894
|
+
if (kind === LETTER && run >= 0) run += width;
|
|
16895
|
+
else if (kind === DIGIT && run <= 0) run -= width;
|
|
16896
|
+
else {
|
|
16897
|
+
n += run > 0 ? Math.ceil(run / 4) : Math.ceil(-run / 3);
|
|
16898
|
+
run = kind === LETTER ? width : kind === DIGIT ? -width : 0;
|
|
16899
|
+
if (kind === OTHER) n += 1;
|
|
16900
|
+
}
|
|
16901
|
+
i += width;
|
|
16902
|
+
}
|
|
16903
|
+
return n + (run > 0 ? Math.ceil(run / 4) : Math.ceil(-run / 3));
|
|
16904
|
+
}
|
|
16905
|
+
var LETTER = 0;
|
|
16906
|
+
var DIGIT = 1;
|
|
16907
|
+
var SPACE = 2;
|
|
16908
|
+
var OTHER = 3;
|
|
16909
|
+
function test(cp) {
|
|
16910
|
+
const ch = String.fromCodePoint(cp);
|
|
16911
|
+
return /\p{L}/u.test(ch) ? LETTER : /\p{N}/u.test(ch) ? DIGIT : /\s/u.test(ch) ? SPACE : OTHER;
|
|
16912
|
+
}
|
|
16913
|
+
var BMP = new Uint8Array(65536).fill(255);
|
|
16914
|
+
var ASTRAL = /* @__PURE__ */ new Map();
|
|
16915
|
+
var ASTRAL_KEPT = 4096;
|
|
16916
|
+
function classOf(cp) {
|
|
16917
|
+
if (cp <= 65535) {
|
|
16918
|
+
let k2 = BMP[cp];
|
|
16919
|
+
if (k2 === 255) BMP[cp] = k2 = test(cp);
|
|
16920
|
+
return k2;
|
|
16921
|
+
}
|
|
16922
|
+
let k = ASTRAL.get(cp);
|
|
16923
|
+
if (k === void 0) {
|
|
16924
|
+
k = test(cp);
|
|
16925
|
+
if (ASTRAL.size < ASTRAL_KEPT) ASTRAL.set(cp, k);
|
|
16714
16926
|
}
|
|
16715
|
-
return
|
|
16927
|
+
return k;
|
|
16716
16928
|
}
|
|
16717
16929
|
|
|
16718
16930
|
// src/api/otlp.ts
|
|
16719
16931
|
var SEVERITY_NUMBER = { DEBUG: 5, INFO: 9, WARN: 13, ERROR: 17 };
|
|
16932
|
+
var SPAN_KIND = { internal: 1, server: 2, client: 3, producer: 4, consumer: 5 };
|
|
16933
|
+
var STATUS_CODE = { unset: 0, ok: 1, error: 2 };
|
|
16720
16934
|
function attr(key, v) {
|
|
16721
16935
|
if (v === void 0 || v === null) return null;
|
|
16722
16936
|
if (typeof v === "boolean") return { key, value: { boolValue: v } };
|
|
@@ -16728,12 +16942,26 @@ var fetchSend = async (url, body, headers) => {
|
|
|
16728
16942
|
const res = await fetch(url, { method: "POST", headers, body });
|
|
16729
16943
|
if (!res.ok) throw new Error(`OTLP HTTP ${res.status}`);
|
|
16730
16944
|
};
|
|
16945
|
+
function unixNano(ms) {
|
|
16946
|
+
const whole = Math.floor(ms);
|
|
16947
|
+
const frac = Math.round((ms - whole) * 1e6);
|
|
16948
|
+
return (BigInt(whole) * BigInt(1e6) + BigInt(frac)).toString();
|
|
16949
|
+
}
|
|
16731
16950
|
var Pb = class {
|
|
16732
16951
|
constructor() {
|
|
16733
16952
|
this.parts = [];
|
|
16734
16953
|
}
|
|
16735
16954
|
varint(v) {
|
|
16736
|
-
|
|
16955
|
+
if (typeof v === "number" && v >= 0 && v < 2 ** 31) {
|
|
16956
|
+
let x2 = v;
|
|
16957
|
+
while (x2 >= 128) {
|
|
16958
|
+
this.parts.push(x2 & 127 | 128);
|
|
16959
|
+
x2 >>>= 7;
|
|
16960
|
+
}
|
|
16961
|
+
this.parts.push(x2);
|
|
16962
|
+
return;
|
|
16963
|
+
}
|
|
16964
|
+
let x = BigInt.asUintN(64, BigInt(v));
|
|
16737
16965
|
const b128 = BigInt(128);
|
|
16738
16966
|
const low7 = BigInt(127);
|
|
16739
16967
|
const seven = BigInt(7);
|
|
@@ -16744,11 +16972,16 @@ var Pb = class {
|
|
|
16744
16972
|
this.parts.push(Number(x));
|
|
16745
16973
|
}
|
|
16746
16974
|
tag(field, wire) {
|
|
16747
|
-
this.varint(
|
|
16975
|
+
this.varint(field << 3 | wire);
|
|
16748
16976
|
}
|
|
16749
16977
|
uint(field, v) {
|
|
16750
16978
|
this.tag(field, 0);
|
|
16751
|
-
this.varint(
|
|
16979
|
+
this.varint(v);
|
|
16980
|
+
return this;
|
|
16981
|
+
}
|
|
16982
|
+
fixed32(field, v) {
|
|
16983
|
+
this.tag(field, 5);
|
|
16984
|
+
for (let i = 0; i < 4; i++) this.parts.push(v >>> 8 * i & 255);
|
|
16752
16985
|
return this;
|
|
16753
16986
|
}
|
|
16754
16987
|
fixed64(field, v) {
|
|
@@ -16765,10 +16998,16 @@ var Pb = class {
|
|
|
16765
16998
|
}
|
|
16766
16999
|
bytes(field, data) {
|
|
16767
17000
|
this.tag(field, 2);
|
|
16768
|
-
this.varint(
|
|
17001
|
+
this.varint(data.length);
|
|
16769
17002
|
for (const x of data) this.parts.push(x);
|
|
16770
17003
|
return this;
|
|
16771
17004
|
}
|
|
17005
|
+
/** An id given in hex (trace and span ids), as bytes. */
|
|
17006
|
+
hex(field, hex) {
|
|
17007
|
+
const out = [];
|
|
17008
|
+
for (let i = 0; i < hex.length; i += 2) out.push(parseInt(hex.slice(i, i + 2), 16));
|
|
17009
|
+
return this.bytes(field, out);
|
|
17010
|
+
}
|
|
16772
17011
|
string(field, s) {
|
|
16773
17012
|
return this.bytes(field, new TextEncoder().encode(s));
|
|
16774
17013
|
}
|
|
@@ -16791,13 +17030,15 @@ function pbAttrs(m, field, a) {
|
|
|
16791
17030
|
}
|
|
16792
17031
|
return m;
|
|
16793
17032
|
}
|
|
16794
|
-
var
|
|
16795
|
-
constructor(o) {
|
|
17033
|
+
var OtlpBatcher = class {
|
|
17034
|
+
constructor(o, path, maxBatch) {
|
|
16796
17035
|
this.o = o;
|
|
17036
|
+
this.path = path;
|
|
17037
|
+
this.maxBatch = maxBatch;
|
|
16797
17038
|
this.buffer = [];
|
|
16798
17039
|
this.inflight = Promise.resolve();
|
|
16799
17040
|
this.timer = null;
|
|
16800
|
-
/**
|
|
17041
|
+
/** Items sent, and items lost because the collector did not take them (or the buffer was full). */
|
|
16801
17042
|
this.sent = 0;
|
|
16802
17043
|
this.dropped = 0;
|
|
16803
17044
|
const every = o.flushMs ?? 5e3;
|
|
@@ -16806,19 +17047,60 @@ var OtlpLogExporter = class {
|
|
|
16806
17047
|
this.timer.unref?.();
|
|
16807
17048
|
}
|
|
16808
17049
|
}
|
|
16809
|
-
|
|
16810
|
-
const
|
|
16811
|
-
this.
|
|
16812
|
-
|
|
17050
|
+
push(items) {
|
|
17051
|
+
const room = this.maxBatch * 8 - this.buffer.length;
|
|
17052
|
+
if (room < items.length) this.dropped += items.length - Math.max(room, 0);
|
|
17053
|
+
for (let i = 0; i < Math.min(items.length, Math.max(room, 0)); i++) this.buffer.push(items[i]);
|
|
17054
|
+
if (this.buffer.length >= this.maxBatch) void this.flush();
|
|
17055
|
+
}
|
|
17056
|
+
resource() {
|
|
17057
|
+
return { "service.name": this.o.serviceName, "service.version": this.o.serviceVersion, ...this.o.resource };
|
|
16813
17058
|
}
|
|
16814
17059
|
/** Send what is buffered. Never rejects. */
|
|
16815
17060
|
flush() {
|
|
16816
17061
|
if (this.buffer.length === 0) return this.inflight;
|
|
16817
|
-
const
|
|
16818
|
-
this.
|
|
16819
|
-
const resource = { "service.name": this.o.serviceName, "service.version": this.o.serviceVersion, ...this.o.resource };
|
|
17062
|
+
const send = this.o.send ?? fetchSend;
|
|
17063
|
+
const url = `${this.o.endpoint.replace(/\/+$/, "")}${this.path}`;
|
|
16820
17064
|
const protobuf = (this.o.protocol ?? "http/protobuf") === "http/protobuf";
|
|
16821
|
-
const
|
|
17065
|
+
const headers = { "Content-Type": protobuf ? "application/x-protobuf" : "application/json", ...this.o.headers ?? {} };
|
|
17066
|
+
while (this.buffer.length > 0) {
|
|
17067
|
+
const batch = this.buffer.splice(0, this.maxBatch);
|
|
17068
|
+
let body;
|
|
17069
|
+
try {
|
|
17070
|
+
body = this.encode(batch, protobuf);
|
|
17071
|
+
} catch {
|
|
17072
|
+
this.dropped += batch.length;
|
|
17073
|
+
continue;
|
|
17074
|
+
}
|
|
17075
|
+
this.inflight = this.inflight.then(
|
|
17076
|
+
() => send(url, body, headers).then(
|
|
17077
|
+
() => void (this.sent += batch.length),
|
|
17078
|
+
() => void (this.dropped += batch.length)
|
|
17079
|
+
)
|
|
17080
|
+
);
|
|
17081
|
+
}
|
|
17082
|
+
return this.inflight;
|
|
17083
|
+
}
|
|
17084
|
+
/** Stop the timer and send what is left. */
|
|
17085
|
+
async close() {
|
|
17086
|
+
if (this.timer) clearInterval(this.timer);
|
|
17087
|
+
this.timer = null;
|
|
17088
|
+
await this.flush();
|
|
17089
|
+
}
|
|
17090
|
+
};
|
|
17091
|
+
var OtlpLogExporter = class extends OtlpBatcher {
|
|
17092
|
+
constructor(o) {
|
|
17093
|
+
super(o, "/v1/logs", o.maxBatch ?? 50);
|
|
17094
|
+
}
|
|
17095
|
+
/** Buffer a record; `context`: the span it was made in (its trace and span id go with it). */
|
|
17096
|
+
log(severity, body, attributes = {}, context) {
|
|
17097
|
+
const ms = (this.o.now ?? Date.now)();
|
|
17098
|
+
this.push([{ timeUnixNano: `${Math.round(ms)}000000`, severity, body, attributes, ...context ? { context } : {} }]);
|
|
17099
|
+
}
|
|
17100
|
+
encode(batch, protobuf) {
|
|
17101
|
+
const resource = this.resource();
|
|
17102
|
+
if (protobuf) return this.protobuf(resource, batch);
|
|
17103
|
+
return JSON.stringify({
|
|
16822
17104
|
resourceLogs: [
|
|
16823
17105
|
{
|
|
16824
17106
|
resource: { attributes: attrs(resource) },
|
|
@@ -16831,39 +17113,90 @@ var OtlpLogExporter = class {
|
|
|
16831
17113
|
severityNumber: SEVERITY_NUMBER[r.severity],
|
|
16832
17114
|
severityText: r.severity,
|
|
16833
17115
|
body: { stringValue: r.body },
|
|
16834
|
-
attributes: attrs(r.attributes)
|
|
17116
|
+
attributes: attrs(r.attributes),
|
|
17117
|
+
...r.context ? { traceId: r.context.traceId, spanId: r.context.spanId, flags: r.context.sampled ? 1 : 0 } : {}
|
|
16835
17118
|
}))
|
|
16836
17119
|
}
|
|
16837
17120
|
]
|
|
16838
17121
|
}
|
|
16839
17122
|
]
|
|
16840
17123
|
});
|
|
16841
|
-
const url = `${this.o.endpoint.replace(/\/+$/, "")}/v1/logs`;
|
|
16842
|
-
const send = this.o.send ?? fetchSend;
|
|
16843
|
-
this.inflight = this.inflight.then(
|
|
16844
|
-
() => send(url, body, { "Content-Type": protobuf ? "application/x-protobuf" : "application/json", ...this.o.headers ?? {} }).then(
|
|
16845
|
-
() => void (this.sent += batch.length),
|
|
16846
|
-
() => void (this.dropped += batch.length)
|
|
16847
|
-
)
|
|
16848
|
-
);
|
|
16849
|
-
return this.inflight;
|
|
16850
17124
|
}
|
|
16851
17125
|
protobuf(resource, batch) {
|
|
16852
17126
|
const scope = new Pb().message(1, new Pb().string(1, this.o.serviceName));
|
|
16853
17127
|
for (const r of batch) {
|
|
16854
17128
|
const t = BigInt(r.timeUnixNano);
|
|
16855
17129
|
const rec = new Pb().fixed64(1, t).uint(2, SEVERITY_NUMBER[r.severity]).string(3, r.severity).message(5, new Pb().string(1, r.body));
|
|
16856
|
-
pbAttrs(rec, 6, r.attributes)
|
|
17130
|
+
pbAttrs(rec, 6, r.attributes);
|
|
17131
|
+
if (r.context) rec.fixed32(8, r.context.sampled ? 1 : 0).hex(9, r.context.traceId).hex(10, r.context.spanId);
|
|
17132
|
+
rec.fixed64(11, t);
|
|
16857
17133
|
scope.message(2, rec);
|
|
16858
17134
|
}
|
|
16859
17135
|
const resourceLogs = new Pb().message(1, pbAttrs(new Pb(), 1, resource)).message(2, scope);
|
|
16860
17136
|
return new Pb().message(1, resourceLogs).finish();
|
|
16861
17137
|
}
|
|
16862
|
-
|
|
16863
|
-
|
|
16864
|
-
|
|
16865
|
-
|
|
16866
|
-
|
|
17138
|
+
};
|
|
17139
|
+
var OtlpTraceExporter = class extends OtlpBatcher {
|
|
17140
|
+
constructor(o) {
|
|
17141
|
+
super(o, "/v1/traces", o.maxBatch ?? 512);
|
|
17142
|
+
}
|
|
17143
|
+
/** Buffer finished spans (sent with the next batch). Never throws. */
|
|
17144
|
+
export(spans) {
|
|
17145
|
+
this.push(Array.isArray(spans) ? spans : [spans]);
|
|
17146
|
+
}
|
|
17147
|
+
encode(batch, protobuf) {
|
|
17148
|
+
const resource = this.resource();
|
|
17149
|
+
if (protobuf) return this.protobuf(resource, batch);
|
|
17150
|
+
return JSON.stringify({
|
|
17151
|
+
resourceSpans: [
|
|
17152
|
+
{
|
|
17153
|
+
resource: { attributes: attrs(resource) },
|
|
17154
|
+
scopeSpans: [
|
|
17155
|
+
{
|
|
17156
|
+
scope: { name: this.o.serviceName, ...this.o.serviceVersion ? { version: this.o.serviceVersion } : {} },
|
|
17157
|
+
spans: batch.map((s) => ({
|
|
17158
|
+
traceId: s.traceId,
|
|
17159
|
+
spanId: s.spanId,
|
|
17160
|
+
...s.parentSpanId ? { parentSpanId: s.parentSpanId } : {},
|
|
17161
|
+
...s.traceState ? { traceState: s.traceState } : {},
|
|
17162
|
+
flags: 1,
|
|
17163
|
+
name: s.name,
|
|
17164
|
+
kind: SPAN_KIND[s.kind],
|
|
17165
|
+
startTimeUnixNano: unixNano(s.startMs),
|
|
17166
|
+
endTimeUnixNano: unixNano(s.endMs),
|
|
17167
|
+
attributes: attrs(s.attributes),
|
|
17168
|
+
...s.droppedAttributes ? { droppedAttributesCount: s.droppedAttributes } : {},
|
|
17169
|
+
events: s.events.map((e) => ({ timeUnixNano: unixNano(e.timeMs), name: e.name, attributes: attrs(e.attributes) })),
|
|
17170
|
+
...s.droppedEvents ? { droppedEventsCount: s.droppedEvents } : {},
|
|
17171
|
+
status: { code: STATUS_CODE[s.status.code], ...s.status.message ? { message: s.status.message } : {} }
|
|
17172
|
+
}))
|
|
17173
|
+
}
|
|
17174
|
+
]
|
|
17175
|
+
}
|
|
17176
|
+
]
|
|
17177
|
+
});
|
|
17178
|
+
}
|
|
17179
|
+
protobuf(resource, batch) {
|
|
17180
|
+
const scopeInfo = new Pb().string(1, this.o.serviceName);
|
|
17181
|
+
if (this.o.serviceVersion) scopeInfo.string(2, this.o.serviceVersion);
|
|
17182
|
+
const scope = new Pb().message(1, scopeInfo);
|
|
17183
|
+
for (const s of batch) {
|
|
17184
|
+
const span = new Pb().hex(1, s.traceId).hex(2, s.spanId);
|
|
17185
|
+
if (s.traceState) span.string(3, s.traceState);
|
|
17186
|
+
if (s.parentSpanId) span.hex(4, s.parentSpanId);
|
|
17187
|
+
span.string(5, s.name).uint(6, SPAN_KIND[s.kind]).fixed64(7, BigInt(unixNano(s.startMs))).fixed64(8, BigInt(unixNano(s.endMs)));
|
|
17188
|
+
pbAttrs(span, 9, s.attributes);
|
|
17189
|
+
if (s.droppedAttributes) span.uint(10, s.droppedAttributes);
|
|
17190
|
+
for (const e of s.events) span.message(11, pbAttrs(new Pb().fixed64(1, BigInt(unixNano(e.timeMs))).string(2, e.name), 3, e.attributes));
|
|
17191
|
+
if (s.droppedEvents) span.uint(12, s.droppedEvents);
|
|
17192
|
+
const status = new Pb();
|
|
17193
|
+
if (s.status.message) status.string(2, s.status.message);
|
|
17194
|
+
if (s.status.code !== "unset") status.uint(3, STATUS_CODE[s.status.code]);
|
|
17195
|
+
span.message(15, status).fixed32(16, 1);
|
|
17196
|
+
scope.message(2, span);
|
|
17197
|
+
}
|
|
17198
|
+
const resourceSpans = new Pb().message(1, pbAttrs(new Pb(), 1, resource)).message(2, scope);
|
|
17199
|
+
return new Pb().message(1, resourceSpans).finish();
|
|
16867
17200
|
}
|
|
16868
17201
|
};
|
|
16869
17202
|
function parseOtlpHeaders(text) {
|
|
@@ -16885,12 +17218,18 @@ function parseOtlpHeaders(text) {
|
|
|
16885
17218
|
var parseResourceAttributes = parseOtlpHeaders;
|
|
16886
17219
|
var truthy = (v) => (v ?? "").trim().toLowerCase() === "true";
|
|
16887
17220
|
function otlpFromEnv(env, defaults) {
|
|
16888
|
-
|
|
16889
|
-
|
|
17221
|
+
return fromEnv(env, defaults, "LOGS", "logs");
|
|
17222
|
+
}
|
|
17223
|
+
function otlpTracesFromEnv(env, defaults) {
|
|
17224
|
+
return fromEnv(env, defaults, "TRACES", "traces");
|
|
17225
|
+
}
|
|
17226
|
+
function fromEnv(env, defaults, signal, path) {
|
|
17227
|
+
if (truthy(env.OTEL_SDK_DISABLED) || (env[`OTEL_${signal}_EXPORTER`] ?? "").trim().toLowerCase() === "none") return null;
|
|
17228
|
+
const own = env[`OTEL_EXPORTER_OTLP_${signal}_ENDPOINT`]?.trim();
|
|
16890
17229
|
const base = env.OTEL_EXPORTER_OTLP_ENDPOINT?.trim();
|
|
16891
|
-
const endpoint =
|
|
17230
|
+
const endpoint = own ? own.replace(new RegExp(`/v1/${path}/?$`), "") : base;
|
|
16892
17231
|
if (!endpoint) return null;
|
|
16893
|
-
const protocol = otlpProtocol(env
|
|
17232
|
+
const protocol = otlpProtocol(env[`OTEL_EXPORTER_OTLP_${signal}_PROTOCOL`] ?? env.OTEL_EXPORTER_OTLP_PROTOCOL);
|
|
16894
17233
|
const resource = parseResourceAttributes(env.OTEL_RESOURCE_ATTRIBUTES);
|
|
16895
17234
|
return {
|
|
16896
17235
|
endpoint,
|
|
@@ -16898,14 +17237,139 @@ function otlpFromEnv(env, defaults) {
|
|
|
16898
17237
|
...defaults.serviceVersion ? { serviceVersion: defaults.serviceVersion } : {},
|
|
16899
17238
|
...protocol ? { protocol } : {},
|
|
16900
17239
|
...Object.keys(resource).length ? { resource } : {},
|
|
16901
|
-
headers: { ...parseOtlpHeaders(env.OTEL_EXPORTER_OTLP_HEADERS), ...parseOtlpHeaders(env
|
|
17240
|
+
headers: { ...parseOtlpHeaders(env.OTEL_EXPORTER_OTLP_HEADERS), ...parseOtlpHeaders(env[`OTEL_EXPORTER_OTLP_${signal}_HEADERS`]) }
|
|
16902
17241
|
};
|
|
16903
17242
|
}
|
|
17243
|
+
function samplerRatioFromEnv(env) {
|
|
17244
|
+
const sampler = (env.OTEL_TRACES_SAMPLER ?? "").trim().toLowerCase().replace(/^parentbased_/, "");
|
|
17245
|
+
if (sampler === "always_on") return 1;
|
|
17246
|
+
if (sampler === "always_off") return 0;
|
|
17247
|
+
if (sampler !== "traceidratio") return void 0;
|
|
17248
|
+
const arg = Number((env.OTEL_TRACES_SAMPLER_ARG ?? "").trim() || "1");
|
|
17249
|
+
return Number.isFinite(arg) && arg >= 0 && arg <= 1 ? arg : 1;
|
|
17250
|
+
}
|
|
16904
17251
|
function otlpProtocol(v) {
|
|
16905
17252
|
const p = (v ?? "").trim().toLowerCase();
|
|
16906
17253
|
return p === "http/protobuf" || p === "http/json" ? p : void 0;
|
|
16907
17254
|
}
|
|
16908
17255
|
|
|
17256
|
+
// src/api/tracing.ts
|
|
17257
|
+
var TRACEPARENT_HEADER = "traceparent";
|
|
17258
|
+
var TRACESTATE_HEADER = "tracestate";
|
|
17259
|
+
var TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
|
|
17260
|
+
function parseTraceparent(traceparent, tracestate) {
|
|
17261
|
+
const m = TRACEPARENT.exec((typeof traceparent === "string" ? traceparent : "").trim().toLowerCase());
|
|
17262
|
+
if (!m) return null;
|
|
17263
|
+
const [, version, traceId, spanId, flags, rest] = m;
|
|
17264
|
+
if (version === "ff" || version === "00" && rest !== void 0) return null;
|
|
17265
|
+
if (/^0+$/.test(traceId) || /^0+$/.test(spanId)) return null;
|
|
17266
|
+
const state = (typeof tracestate === "string" ? tracestate : "").trim();
|
|
17267
|
+
return { traceId, spanId, sampled: (parseInt(flags, 16) & 1) === 1, ...state ? { traceState: state.slice(0, 512) } : {} };
|
|
17268
|
+
}
|
|
17269
|
+
function formatTraceparent(ctx) {
|
|
17270
|
+
return `00-${ctx.traceId}-${ctx.spanId}-${ctx.sampled ? "01" : "00"}`;
|
|
17271
|
+
}
|
|
17272
|
+
function traceHeaders(ctx) {
|
|
17273
|
+
return { [TRACEPARENT_HEADER]: formatTraceparent(ctx), ...ctx.traceState ? { [TRACESTATE_HEADER]: ctx.traceState } : {} };
|
|
17274
|
+
}
|
|
17275
|
+
function randomHex(bytes) {
|
|
17276
|
+
const b = new Uint8Array(bytes);
|
|
17277
|
+
const c = globalThis.crypto;
|
|
17278
|
+
if (c?.getRandomValues) c.getRandomValues(b);
|
|
17279
|
+
else for (let i = 0; i < bytes; i++) b[i] = Math.floor(Math.random() * 256);
|
|
17280
|
+
const hex = Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
|
|
17281
|
+
return /^0+$/.test(hex) ? randomHex(bytes) : hex;
|
|
17282
|
+
}
|
|
17283
|
+
var newTraceId = () => randomHex(16);
|
|
17284
|
+
var newSpanId = () => randomHex(8);
|
|
17285
|
+
var perf = globalThis.performance;
|
|
17286
|
+
var defaultNow = perf ? () => perf.timeOrigin + perf.now() : () => Date.now();
|
|
17287
|
+
var TraceSpan = class {
|
|
17288
|
+
constructor(tracer, name, kind, parent, recording, attributes) {
|
|
17289
|
+
this.tracer = tracer;
|
|
17290
|
+
this.name = name;
|
|
17291
|
+
this.kind = kind;
|
|
17292
|
+
this.parent = parent;
|
|
17293
|
+
this.recording = recording;
|
|
17294
|
+
this.attributes = {};
|
|
17295
|
+
this.events = [];
|
|
17296
|
+
this.status = { code: "unset" };
|
|
17297
|
+
this.ended = false;
|
|
17298
|
+
this.context = {
|
|
17299
|
+
traceId: parent?.traceId ?? newTraceId(),
|
|
17300
|
+
spanId: newSpanId(),
|
|
17301
|
+
sampled: recording,
|
|
17302
|
+
...parent?.traceState ? { traceState: parent.traceState } : {}
|
|
17303
|
+
};
|
|
17304
|
+
this.startMs = tracer.now();
|
|
17305
|
+
this.setAttributes(attributes);
|
|
17306
|
+
}
|
|
17307
|
+
setAttribute(key, value) {
|
|
17308
|
+
if (value !== void 0 && value !== null) this.attributes[key] = value;
|
|
17309
|
+
return this;
|
|
17310
|
+
}
|
|
17311
|
+
setAttributes(attributes) {
|
|
17312
|
+
for (const k in attributes) this.setAttribute(k, attributes[k]);
|
|
17313
|
+
return this;
|
|
17314
|
+
}
|
|
17315
|
+
addEvent(name, attributes = {}) {
|
|
17316
|
+
this.events.push({ name, timeMs: this.tracer.now(), attributes });
|
|
17317
|
+
return this;
|
|
17318
|
+
}
|
|
17319
|
+
/** An `exception` event, `error.type` and status ERROR. */
|
|
17320
|
+
recordException(e) {
|
|
17321
|
+
const type = e instanceof Error ? e.name : typeof e;
|
|
17322
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
17323
|
+
this.addEvent("exception", { "exception.type": type, "exception.message": message, ...e instanceof Error && e.stack ? { "exception.stacktrace": e.stack.slice(0, 8192) } : {} });
|
|
17324
|
+
if (!("error.type" in this.attributes)) this.attributes["error.type"] = type;
|
|
17325
|
+
return this.setStatus("error", message);
|
|
17326
|
+
}
|
|
17327
|
+
setStatus(code, message) {
|
|
17328
|
+
if (this.status.code === "error" && code !== "error") return this;
|
|
17329
|
+
this.status = code === "error" && message ? { code, message } : { code };
|
|
17330
|
+
return this;
|
|
17331
|
+
}
|
|
17332
|
+
end() {
|
|
17333
|
+
if (this.ended) return;
|
|
17334
|
+
this.ended = true;
|
|
17335
|
+
if (!this.recording) return;
|
|
17336
|
+
this.tracer.send({
|
|
17337
|
+
traceId: this.context.traceId,
|
|
17338
|
+
spanId: this.context.spanId,
|
|
17339
|
+
...this.parent ? { parentSpanId: this.parent.spanId } : {},
|
|
17340
|
+
...this.context.traceState ? { traceState: this.context.traceState } : {},
|
|
17341
|
+
name: this.name,
|
|
17342
|
+
kind: this.kind,
|
|
17343
|
+
startMs: this.startMs,
|
|
17344
|
+
endMs: this.tracer.now(),
|
|
17345
|
+
attributes: this.attributes,
|
|
17346
|
+
events: this.events,
|
|
17347
|
+
status: this.status
|
|
17348
|
+
});
|
|
17349
|
+
}
|
|
17350
|
+
};
|
|
17351
|
+
var Tracer = class {
|
|
17352
|
+
constructor(o) {
|
|
17353
|
+
this.o = o;
|
|
17354
|
+
this.now = o.now ?? defaultNow;
|
|
17355
|
+
}
|
|
17356
|
+
/** A new span: a child of `parent` (a context or a `traceparent` header), or a new trace. */
|
|
17357
|
+
startSpan(name, opts = {}) {
|
|
17358
|
+
const parent = typeof opts.parent === "string" ? parseTraceparent(opts.parent) : opts.parent ?? null;
|
|
17359
|
+
const ratio = this.o.sampleRatio ?? 1;
|
|
17360
|
+
const span = new TraceSpan(this, name, opts.kind ?? "internal", parent, true, opts.attributes ?? {});
|
|
17361
|
+
const recording = parent ? parent.sampled : ratio >= 1 || ratio > 0 && parseInt(span.context.traceId.slice(-13), 16) / 2 ** 52 < ratio;
|
|
17362
|
+
return recording ? span : new TraceSpan(this, name, opts.kind ?? "internal", parent ?? { ...span.context, sampled: false }, false, {});
|
|
17363
|
+
}
|
|
17364
|
+
/** @internal */
|
|
17365
|
+
send(span) {
|
|
17366
|
+
try {
|
|
17367
|
+
this.o.export([span]);
|
|
17368
|
+
} catch {
|
|
17369
|
+
}
|
|
17370
|
+
}
|
|
17371
|
+
};
|
|
17372
|
+
|
|
16909
17373
|
// src/api/client.ts
|
|
16910
17374
|
var ACTOR_HEADER = "X-Datanotes-Actor";
|
|
16911
17375
|
var UNREACHABLE = {
|
|
@@ -16938,6 +17402,24 @@ function isEngineAnswer(json) {
|
|
|
16938
17402
|
const o = json;
|
|
16939
17403
|
return typeof o.ok === "boolean" || typeof o.error === "string";
|
|
16940
17404
|
}
|
|
17405
|
+
function clientSpan(tracer, method, url, parent) {
|
|
17406
|
+
let target;
|
|
17407
|
+
try {
|
|
17408
|
+
target = new URL(url);
|
|
17409
|
+
} catch {
|
|
17410
|
+
target = null;
|
|
17411
|
+
}
|
|
17412
|
+
return tracer.startSpan(target ? `${method} ${target.pathname}` : method, {
|
|
17413
|
+
kind: "client",
|
|
17414
|
+
parent,
|
|
17415
|
+
attributes: {
|
|
17416
|
+
"http.request.method": method,
|
|
17417
|
+
"url.full": target ? `${target.protocol}//${target.host}${target.pathname}` : void 0,
|
|
17418
|
+
"server.address": target?.hostname,
|
|
17419
|
+
"server.port": target ? Number(target.port || (target.protocol === "https:" ? 443 : 80)) : void 0
|
|
17420
|
+
}
|
|
17421
|
+
});
|
|
17422
|
+
}
|
|
16941
17423
|
function parse(text) {
|
|
16942
17424
|
try {
|
|
16943
17425
|
return text.trim() ? JSON.parse(text) : void 0;
|
|
@@ -16951,11 +17433,22 @@ var DatanotesClient = class {
|
|
|
16951
17433
|
this.url = o.url.replace(/\/+$/, "");
|
|
16952
17434
|
this.send = o.transport ?? fetchTransport;
|
|
16953
17435
|
}
|
|
16954
|
-
/**
|
|
17436
|
+
/** The parent of a request: the call's own `trace`, else the client's. */
|
|
17437
|
+
parentOf(trace) {
|
|
17438
|
+
const given = trace ?? (typeof this.o.trace === "function" ? this.o.trace() : this.o.trace);
|
|
17439
|
+
return typeof given === "string" ? parseTraceparent(given) : given ?? null;
|
|
17440
|
+
}
|
|
17441
|
+
/**
|
|
17442
|
+
* Send a request; the answer's status, its JSON (when it is JSON) and its text. `trace`: the
|
|
17443
|
+
* trace this request continues (over the client's `trace` option).
|
|
17444
|
+
*/
|
|
16955
17445
|
async request(method, path, body, opts = {}) {
|
|
16956
17446
|
if (!this.url) throw new DatanotesError("engine address not set", "unreachable");
|
|
16957
17447
|
if (!this.o.token) throw new DatanotesError("token not set", "auth");
|
|
16958
17448
|
const actor = opts.actor ?? this.o.actor;
|
|
17449
|
+
const parent = this.parentOf(opts.trace);
|
|
17450
|
+
const span = this.o.tracer ? clientSpan(this.o.tracer, method, `${this.url}${path}`, parent) : void 0;
|
|
17451
|
+
const sent = span?.context ?? parent;
|
|
16959
17452
|
let res;
|
|
16960
17453
|
try {
|
|
16961
17454
|
res = await this.send({
|
|
@@ -16965,13 +17458,20 @@ var DatanotesClient = class {
|
|
|
16965
17458
|
Authorization: `Bearer ${this.o.token}`,
|
|
16966
17459
|
...body !== void 0 ? { "Content-Type": "application/json" } : {},
|
|
16967
17460
|
...opts.accept ? { Accept: opts.accept } : {},
|
|
16968
|
-
...actor && Object.keys(actor).length ? { [ACTOR_HEADER]: JSON.stringify(actor) } : {}
|
|
17461
|
+
...actor && Object.keys(actor).length ? { [ACTOR_HEADER]: JSON.stringify(actor) } : {},
|
|
17462
|
+
...sent ? traceHeaders(sent) : {}
|
|
16969
17463
|
},
|
|
16970
17464
|
...body !== void 0 ? { body: JSON.stringify(body) } : {}
|
|
16971
17465
|
});
|
|
16972
17466
|
} catch (e) {
|
|
17467
|
+
span?.recordException(e);
|
|
17468
|
+
span?.end();
|
|
16973
17469
|
throw new DatanotesError(`engine unreachable at ${this.url}: ${e instanceof Error ? e.message : String(e)}`, "unreachable");
|
|
16974
17470
|
}
|
|
17471
|
+
span?.setAttribute("http.response.status_code", res.status);
|
|
17472
|
+
if (res.status >= 400) span?.setAttribute("error.type", String(res.status));
|
|
17473
|
+
if (res.status >= 500) span?.setStatus("error", `HTTP ${res.status}`);
|
|
17474
|
+
span?.end();
|
|
16975
17475
|
if (res.status === 401) throw new DatanotesError("token refused by the engine", "auth", 401);
|
|
16976
17476
|
const json = parse(res.text);
|
|
16977
17477
|
const unreachable = res.status === 0 || res.status === 502 || res.status === 504 || res.status === 503 && !isEngineAnswer(json);
|
|
@@ -16989,7 +17489,7 @@ var DatanotesClient = class {
|
|
|
16989
17489
|
* Arguments the operation does not take, or of the wrong type, are refused before anything is sent,
|
|
16990
17490
|
* with the same message the engine gives.
|
|
16991
17491
|
*/
|
|
16992
|
-
async call(name, args = {}, actor) {
|
|
17492
|
+
async call(name, args = {}, actor, options = {}) {
|
|
16993
17493
|
let req;
|
|
16994
17494
|
try {
|
|
16995
17495
|
req = operationRequest(name, args);
|
|
@@ -16999,7 +17499,7 @@ var DatanotesClient = class {
|
|
|
16999
17499
|
}
|
|
17000
17500
|
const problem = checkArguments(name, args);
|
|
17001
17501
|
if (problem) return { ok: false, value: guidedText(problem.message, problem) };
|
|
17002
|
-
const r = await this.request(req.method, req.path, req.body, actor ? { actor } : {});
|
|
17502
|
+
const r = await this.request(req.method, req.path, req.body, { ...actor ? { actor } : {}, ...options.trace ? { trace: options.trace } : {} });
|
|
17003
17503
|
return resultOf(r.status, r.json, r.text);
|
|
17004
17504
|
}
|
|
17005
17505
|
/** True when the engine answers `GET /` (no token needed). */
|
|
@@ -17011,8 +17511,11 @@ var DatanotesClient = class {
|
|
|
17011
17511
|
return false;
|
|
17012
17512
|
}
|
|
17013
17513
|
}
|
|
17014
|
-
/**
|
|
17514
|
+
/**
|
|
17515
|
+
* Record an agent's tool call in the change feed (what MCP servers report). Answers what the
|
|
17516
|
+
* engine said: `takes_summary` when it records a `value` sent cut with its `summary`.
|
|
17517
|
+
*/
|
|
17015
17518
|
async recordToolCall(call, actor) {
|
|
17016
|
-
|
|
17519
|
+
return this.post("/tool-calls/record/", call, actor);
|
|
17017
17520
|
}
|
|
17018
17521
|
};
|