@dxos/echo-memory 0.0.0-stage → 0.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.
Files changed (147) hide show
  1. package/LICENSE +105 -0
  2. package/dist/lib/Fact.mjs +1 -0
  3. package/dist/lib/FactFeed.mjs +1 -0
  4. package/dist/lib/Graph.mjs +1 -0
  5. package/dist/lib/Hash.mjs +1 -0
  6. package/dist/lib/Mapping.mjs +1 -0
  7. package/dist/lib/MemoryError.mjs +1 -0
  8. package/dist/lib/MemoryQuery.mjs +1 -0
  9. package/dist/lib/MemoryService.mjs +1 -0
  10. package/dist/lib/Ontology.mjs +1 -0
  11. package/dist/lib/Pipeline.mjs +1 -0
  12. package/dist/lib/Predicate.mjs +1 -0
  13. package/dist/lib/Rdf.mjs +1 -0
  14. package/dist/lib/RdfStore.mjs +1 -0
  15. package/dist/lib/Sparql.mjs +1 -0
  16. package/dist/lib/Subscription.mjs +1 -0
  17. package/dist/lib/Trig.mjs +1 -0
  18. package/dist/lib/Vocab.mjs +1 -0
  19. package/dist/lib/Vocabularies.mjs +1 -0
  20. package/dist/lib/chunk-Fact.mjs +245 -0
  21. package/dist/lib/chunk-Fact.mjs.map +1 -0
  22. package/dist/lib/chunk-FactFeed.mjs +29 -0
  23. package/dist/lib/chunk-FactFeed.mjs.map +1 -0
  24. package/dist/lib/chunk-Graph.mjs +147 -0
  25. package/dist/lib/chunk-Graph.mjs.map +1 -0
  26. package/dist/lib/chunk-Hash.mjs +16 -0
  27. package/dist/lib/chunk-Hash.mjs.map +1 -0
  28. package/dist/lib/chunk-Mapping.mjs +226 -0
  29. package/dist/lib/chunk-Mapping.mjs.map +1 -0
  30. package/dist/lib/chunk-MemoryError.mjs +10 -0
  31. package/dist/lib/chunk-MemoryError.mjs.map +1 -0
  32. package/dist/lib/chunk-MemoryQuery.mjs +99 -0
  33. package/dist/lib/chunk-MemoryQuery.mjs.map +1 -0
  34. package/dist/lib/chunk-MemoryService.mjs +31 -0
  35. package/dist/lib/chunk-MemoryService.mjs.map +1 -0
  36. package/dist/lib/chunk-Ontology.mjs +529 -0
  37. package/dist/lib/chunk-Ontology.mjs.map +1 -0
  38. package/dist/lib/chunk-Pipeline.mjs +84 -0
  39. package/dist/lib/chunk-Pipeline.mjs.map +1 -0
  40. package/dist/lib/chunk-Predicate.mjs +66 -0
  41. package/dist/lib/chunk-Predicate.mjs.map +1 -0
  42. package/dist/lib/chunk-Rdf.mjs +120 -0
  43. package/dist/lib/chunk-Rdf.mjs.map +1 -0
  44. package/dist/lib/chunk-RdfStore.mjs +60 -0
  45. package/dist/lib/chunk-RdfStore.mjs.map +1 -0
  46. package/dist/lib/chunk-Sparql.mjs +153 -0
  47. package/dist/lib/chunk-Sparql.mjs.map +1 -0
  48. package/dist/lib/chunk-Subscription.mjs +44 -0
  49. package/dist/lib/chunk-Subscription.mjs.map +1 -0
  50. package/dist/lib/chunk-Trig.mjs +106 -0
  51. package/dist/lib/chunk-Trig.mjs.map +1 -0
  52. package/dist/lib/chunk-Vocab.mjs +164 -0
  53. package/dist/lib/chunk-Vocab.mjs.map +1 -0
  54. package/dist/lib/chunk-Vocabularies.mjs +343 -0
  55. package/dist/lib/chunk-Vocabularies.mjs.map +1 -0
  56. package/dist/lib/chunk-rolldown-runtime.mjs +13 -0
  57. package/dist/lib/index.mjs +19 -0
  58. package/dist/types/src/Fact.d.ts +339 -0
  59. package/dist/types/src/Fact.d.ts.map +1 -0
  60. package/dist/types/src/Fact.test.d.ts +2 -0
  61. package/dist/types/src/Fact.test.d.ts.map +1 -0
  62. package/dist/types/src/FactFeed.d.ts +11 -0
  63. package/dist/types/src/FactFeed.d.ts.map +1 -0
  64. package/dist/types/src/FactFeed.test.d.ts +2 -0
  65. package/dist/types/src/FactFeed.test.d.ts.map +1 -0
  66. package/dist/types/src/Graph.d.ts +31 -0
  67. package/dist/types/src/Graph.d.ts.map +1 -0
  68. package/dist/types/src/Graph.test.d.ts +2 -0
  69. package/dist/types/src/Graph.test.d.ts.map +1 -0
  70. package/dist/types/src/Hash.d.ts +3 -0
  71. package/dist/types/src/Hash.d.ts.map +1 -0
  72. package/dist/types/src/Mapping.d.ts +18 -0
  73. package/dist/types/src/Mapping.d.ts.map +1 -0
  74. package/dist/types/src/Mapping.test.d.ts +2 -0
  75. package/dist/types/src/Mapping.test.d.ts.map +1 -0
  76. package/dist/types/src/MemoryError.d.ts +33 -0
  77. package/dist/types/src/MemoryError.d.ts.map +1 -0
  78. package/dist/types/src/MemoryQuery.d.ts +136 -0
  79. package/dist/types/src/MemoryQuery.d.ts.map +1 -0
  80. package/dist/types/src/MemoryQuery.test.d.ts +2 -0
  81. package/dist/types/src/MemoryQuery.test.d.ts.map +1 -0
  82. package/dist/types/src/MemoryService.d.ts +72 -0
  83. package/dist/types/src/MemoryService.d.ts.map +1 -0
  84. package/dist/types/src/Ontology.d.ts +115 -0
  85. package/dist/types/src/Ontology.d.ts.map +1 -0
  86. package/dist/types/src/Ontology.test.d.ts +2 -0
  87. package/dist/types/src/Ontology.test.d.ts.map +1 -0
  88. package/dist/types/src/Pipeline.d.ts +103 -0
  89. package/dist/types/src/Pipeline.d.ts.map +1 -0
  90. package/dist/types/src/Predicate.d.ts +17 -0
  91. package/dist/types/src/Predicate.d.ts.map +1 -0
  92. package/dist/types/src/Predicate.test.d.ts +2 -0
  93. package/dist/types/src/Predicate.test.d.ts.map +1 -0
  94. package/dist/types/src/Rdf.d.ts +33 -0
  95. package/dist/types/src/Rdf.d.ts.map +1 -0
  96. package/dist/types/src/Rdf.test.d.ts +2 -0
  97. package/dist/types/src/Rdf.test.d.ts.map +1 -0
  98. package/dist/types/src/RdfStore.d.ts +471 -0
  99. package/dist/types/src/RdfStore.d.ts.map +1 -0
  100. package/dist/types/src/Sparql.d.ts +58 -0
  101. package/dist/types/src/Sparql.d.ts.map +1 -0
  102. package/dist/types/src/Sparql.test.d.ts +2 -0
  103. package/dist/types/src/Sparql.test.d.ts.map +1 -0
  104. package/dist/types/src/Subscription.d.ts +100 -0
  105. package/dist/types/src/Subscription.d.ts.map +1 -0
  106. package/dist/types/src/Trig.d.ts +8 -0
  107. package/dist/types/src/Trig.d.ts.map +1 -0
  108. package/dist/types/src/Trig.test.d.ts +2 -0
  109. package/dist/types/src/Trig.test.d.ts.map +1 -0
  110. package/dist/types/src/Vocab.d.ts +90 -0
  111. package/dist/types/src/Vocab.d.ts.map +1 -0
  112. package/dist/types/src/Vocabularies.d.ts +45 -0
  113. package/dist/types/src/Vocabularies.d.ts.map +1 -0
  114. package/dist/types/src/index.d.ts +19 -0
  115. package/dist/types/src/index.d.ts.map +1 -0
  116. package/dist/types/tsconfig.tsbuildinfo +1 -0
  117. package/package.json +133 -3
  118. package/src/Fact.test.ts +74 -0
  119. package/src/Fact.ts +269 -0
  120. package/src/FactFeed.test.ts +40 -0
  121. package/src/FactFeed.ts +38 -0
  122. package/src/Graph.test.ts +106 -0
  123. package/src/Graph.ts +158 -0
  124. package/src/Hash.ts +15 -0
  125. package/src/Mapping.test.ts +197 -0
  126. package/src/Mapping.ts +320 -0
  127. package/src/MemoryError.ts +10 -0
  128. package/src/MemoryQuery.test.ts +67 -0
  129. package/src/MemoryQuery.ts +114 -0
  130. package/src/MemoryService.ts +89 -0
  131. package/src/Ontology.test.ts +94 -0
  132. package/src/Ontology.ts +571 -0
  133. package/src/Pipeline.ts +97 -0
  134. package/src/Predicate.test.ts +47 -0
  135. package/src/Predicate.ts +89 -0
  136. package/src/Rdf.test.ts +104 -0
  137. package/src/Rdf.ts +158 -0
  138. package/src/RdfStore.ts +111 -0
  139. package/src/Sparql.test.ts +72 -0
  140. package/src/Sparql.ts +237 -0
  141. package/src/Subscription.ts +47 -0
  142. package/src/Trig.test.ts +199 -0
  143. package/src/Trig.ts +170 -0
  144. package/src/Vocab.ts +134 -0
  145. package/src/Vocabularies.ts +204 -0
  146. package/src/index.ts +22 -0
  147. package/README.md +0 -3
@@ -0,0 +1,84 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { c as literal, l as namedNode, u as quad } from "./chunk-Rdf.mjs";
3
+ import { P as SX, b as RDF, u as GRAPH$1 } from "./chunk-Vocab.mjs";
4
+ import { n as write } from "./chunk-Trig.mjs";
5
+ import * as Schema from "effect/Schema";
6
+ import * as Effect from "effect/Effect";
7
+ import * as Option from "effect/Option";
8
+ //#region src/Pipeline.ts
9
+ var Pipeline_exports = /* @__PURE__ */ __exportAll({
10
+ GRAPH: () => GRAPH,
11
+ ModelUsage: () => ModelUsage,
12
+ SPARQL: () => SPARQL,
13
+ STATE: () => STATE,
14
+ Source: () => Source,
15
+ Stage: () => Stage,
16
+ State: () => State,
17
+ fromValues: () => fromValues,
18
+ toQuads: () => toQuads,
19
+ toTrig: () => toTrig
20
+ });
21
+ /** One source a pipeline read (a Discord channel or thread): how far it read and what it found there. */
22
+ var Source = Schema.Struct({
23
+ id: Schema.String,
24
+ label: Schema.optional(Schema.String),
25
+ /** Where reading stopped, as the source names its items (a Discord message id). */
26
+ cursor: Schema.optional(Schema.String),
27
+ firstItemAt: Schema.optional(Schema.String),
28
+ lastItemAt: Schema.optional(Schema.String),
29
+ items: Schema.Number,
30
+ status: Schema.optional(Schema.String)
31
+ });
32
+ /** What one stage spent on one model. */
33
+ var ModelUsage = Schema.Struct({
34
+ model: Schema.String,
35
+ calls: Schema.Number,
36
+ inputTokens: Schema.Number,
37
+ outputTokens: Schema.Number,
38
+ cacheReadTokens: Schema.Number,
39
+ cacheWriteTokens: Schema.Number,
40
+ /** At catalog prices; absent for a model the catalog does not price. */
41
+ costUsd: Schema.optional(Schema.Number)
42
+ });
43
+ var Stage = Schema.Struct({
44
+ id: Schema.String,
45
+ label: Schema.String,
46
+ /** Position in the pipeline, from 0. */
47
+ order: Schema.Number,
48
+ /** Items the stage passed to the next one. */
49
+ items: Schema.optional(Schema.Number),
50
+ startedAt: Schema.optional(Schema.String),
51
+ endedAt: Schema.optional(Schema.String),
52
+ models: Schema.Array(ModelUsage)
53
+ });
54
+ /**
55
+ * What a fact-producing run did, kept in the fact store beside the facts it produced: the sources it read and how
56
+ * far, its stages in order, the models each called and at what cost, how long it took and how many facts it wrote.
57
+ */
58
+ var State = Schema.Struct({
59
+ name: Schema.String,
60
+ status: Schema.String,
61
+ startedAt: Schema.optional(Schema.String),
62
+ endedAt: Schema.optional(Schema.String),
63
+ sources: Schema.Array(Source),
64
+ stages: Schema.Array(Stage),
65
+ facts: Schema.optional(Schema.Number)
66
+ });
67
+ /** The named graph a run's state lives in, outside every fact's graph. */
68
+ var GRAPH = `${GRAPH$1}pipeline`;
69
+ /** The predicate carrying the state, as one JSON literal: it is read whole, never queried field by field. */
70
+ var STATE = `${SX}pipelineState`;
71
+ var JSON_DATATYPE = `${RDF}JSON`;
72
+ /** The quad storing `state`; importing it into a store replaces nothing, so a store holds one state per run name. */
73
+ var toQuads = (state) => [quad(namedNode(`${GRAPH}/${encodeURIComponent(state.name)}`), namedNode(STATE), literal(JSON.stringify(state), namedNode(JSON_DATATYPE)), namedNode(GRAPH))];
74
+ /** `state` as a TriG document, which a store imports beside the facts the run wrote. */
75
+ var toTrig = (state) => Effect.sync(() => write(toQuads(state)));
76
+ /** Selects every stored run state as `?state`. */
77
+ var SPARQL = `SELECT ?state WHERE { GRAPH <${GRAPH}> { ?run <${STATE}> ?state } }`;
78
+ var decode = Schema.decodeUnknownOption(Schema.fromJsonString(State));
79
+ /** The run states among `values` (each a `?state` literal from {@link SPARQL}); a malformed one is skipped. */
80
+ var fromValues = (values) => values.flatMap((value) => Option.toArray(decode(value)));
81
+ //#endregion
82
+ export { STATE as a, State as c, toTrig as d, SPARQL as i, fromValues as l, ModelUsage as n, Source as o, Pipeline_exports as r, Stage as s, GRAPH as t, toQuads as u };
83
+
84
+ //# sourceMappingURL=chunk-Pipeline.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Pipeline.mjs","names":["Vocab.GRAPH","Vocab.SX","Vocab.RDF","Rdf.quad","Rdf.namedNode","Rdf.literal","Trig.write"],"sources":["../../src/Pipeline.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\nimport * as Schema from 'effect/Schema';\n\nimport * as Rdf from './Rdf.ts';\nimport * as Trig from './Trig.ts';\nimport * as Vocab from './Vocab.ts';\n\n/** One source a pipeline read (a Discord channel or thread): how far it read and what it found there. */\nexport const Source = Schema.Struct({\n id: Schema.String,\n label: Schema.optional(Schema.String),\n /** Where reading stopped, as the source names its items (a Discord message id). */\n cursor: Schema.optional(Schema.String),\n firstItemAt: Schema.optional(Schema.String),\n lastItemAt: Schema.optional(Schema.String),\n items: Schema.Number,\n status: Schema.optional(Schema.String),\n});\nexport type Source = Schema.Schema.Type<typeof Source>;\n\n/** What one stage spent on one model. */\nexport const ModelUsage = Schema.Struct({\n model: Schema.String,\n calls: Schema.Number,\n inputTokens: Schema.Number,\n outputTokens: Schema.Number,\n cacheReadTokens: Schema.Number,\n cacheWriteTokens: Schema.Number,\n /** At catalog prices; absent for a model the catalog does not price. */\n costUsd: Schema.optional(Schema.Number),\n});\nexport type ModelUsage = Schema.Schema.Type<typeof ModelUsage>;\n\nexport const Stage = Schema.Struct({\n id: Schema.String,\n label: Schema.String,\n /** Position in the pipeline, from 0. */\n order: Schema.Number,\n /** Items the stage passed to the next one. */\n items: Schema.optional(Schema.Number),\n startedAt: Schema.optional(Schema.String),\n endedAt: Schema.optional(Schema.String),\n models: Schema.Array(ModelUsage),\n});\nexport type Stage = Schema.Schema.Type<typeof Stage>;\n\n/**\n * What a fact-producing run did, kept in the fact store beside the facts it produced: the sources it read and how\n * far, its stages in order, the models each called and at what cost, how long it took and how many facts it wrote.\n */\nexport const State = Schema.Struct({\n name: Schema.String,\n status: Schema.String,\n startedAt: Schema.optional(Schema.String),\n endedAt: Schema.optional(Schema.String),\n sources: Schema.Array(Source),\n stages: Schema.Array(Stage),\n facts: Schema.optional(Schema.Number),\n});\nexport type State = Schema.Schema.Type<typeof State>;\n\n/** The named graph a run's state lives in, outside every fact's graph. */\nexport const GRAPH = `${Vocab.GRAPH}pipeline`;\n\n/** The predicate carrying the state, as one JSON literal: it is read whole, never queried field by field. */\nexport const STATE = `${Vocab.SX}pipelineState`;\n\nconst JSON_DATATYPE = `${Vocab.RDF}JSON`;\n\n/** The quad storing `state`; importing it into a store replaces nothing, so a store holds one state per run name. */\nexport const toQuads = (state: State): Rdf.Quad[] => [\n Rdf.quad(\n Rdf.namedNode(`${GRAPH}/${encodeURIComponent(state.name)}`),\n Rdf.namedNode(STATE),\n Rdf.literal(JSON.stringify(state), Rdf.namedNode(JSON_DATATYPE)),\n Rdf.namedNode(GRAPH),\n ),\n];\n\n/** `state` as a TriG document, which a store imports beside the facts the run wrote. */\nexport const toTrig = (state: State): Effect.Effect<string> => Effect.sync(() => Trig.write(toQuads(state)));\n\n/** Selects every stored run state as `?state`. */\nexport const SPARQL = `SELECT ?state WHERE { GRAPH <${GRAPH}> { ?run <${STATE}> ?state } }`;\n\nconst decode = Schema.decodeUnknownOption(Schema.fromJsonString(State));\n\n/** The run states among `values` (each a `?state` literal from {@link SPARQL}); a malformed one is skipped. */\nexport const fromValues = (values: readonly string[]): State[] =>\n values.flatMap((value) => Option.toArray(decode(value)));\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAeA,IAAa,SAAS,OAAO,OAAO;CAClC,IAAI,OAAO;CACX,OAAO,OAAO,SAAS,OAAO,MAAM;;CAEpC,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,YAAY,OAAO,SAAS,OAAO,MAAM;CACzC,OAAO,OAAO;CACd,QAAQ,OAAO,SAAS,OAAO,MAAM;AACvC,CAAC;;AAID,IAAa,aAAa,OAAO,OAAO;CACtC,OAAO,OAAO;CACd,OAAO,OAAO;CACd,aAAa,OAAO;CACpB,cAAc,OAAO;CACrB,iBAAiB,OAAO;CACxB,k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portAll({
4
+ label: () => label,
5
+ normalize: () => normalize
6
+ });
7
+ var LEADING_NOISE = /* @__PURE__ */ new Set([
8
+ "is",
9
+ "are",
10
+ "was",
11
+ "were",
12
+ "be",
13
+ "been",
14
+ "being",
15
+ "am",
16
+ "has",
17
+ "have",
18
+ "had",
19
+ "does",
20
+ "do",
21
+ "did",
22
+ "can",
23
+ "could",
24
+ "will",
25
+ "would",
26
+ "shall",
27
+ "should",
28
+ "may",
29
+ "might",
30
+ "must",
31
+ "a",
32
+ "an",
33
+ "the",
34
+ "to"
35
+ ]);
36
+ /** Light inflectional stem of a single word (consistency over linguistic correctness). */
37
+ var stem = (word) => {
38
+ if (word.length > 4 && word.endsWith("ing")) return word.slice(0, -3);
39
+ if (word.length > 3 && word.endsWith("ed")) return word.slice(0, -2);
40
+ if (word.length > 4 && word.endsWith("ies")) return `${word.slice(0, -3)}y`;
41
+ if (word.length > 3 && word.endsWith("s") && !word.endsWith("ss")) return word.slice(0, -1);
42
+ return word;
43
+ };
44
+ /**
45
+ * Normalize a predicate to a relation key for matching: lowercase, collapse whitespace, drop leading
46
+ * auxiliary/copula/article words, and light-stem the head verb. Inflection / case / auxiliary variants
47
+ * collapse (e.g. `Works at` / `is working at` / `worked at` → `work at`). True synonyms (`at` vs `for`,
48
+ * `works` vs `employed by`) are NOT merged — that needs a controlled vocabulary (deferred). Idempotent.
49
+ */
50
+ var normalize = (predicate, { stem: stemHead = true } = {}) => {
51
+ const tokens = predicate.toLowerCase().trim().split(/\s+/).filter((token) => token.length > 0);
52
+ while (tokens.length > 1 && LEADING_NOISE.has(tokens[0])) tokens.shift();
53
+ if (stemHead && tokens.length > 0) tokens[0] = stem(tokens[0]);
54
+ return tokens.join(" ");
55
+ };
56
+ /**
57
+ * The display form of a predicate or an inverse: lowercase kebab-case (`Works at` → `works-at`, `Known by` →
58
+ * `known-by`), so labels the extractor, the ontology and a UI author each write read as one vocabulary. Unlike
59
+ * {@link normalize} it keeps the words as said (no stemming, no dropped copula), since it is shown, not matched.
60
+ * Idempotent.
61
+ */
62
+ var label = (predicate) => predicate.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
63
+ //#endregion
64
+ export { label as n, normalize as r, Predicate_exports as t };
65
+
66
+ //# sourceMappingURL=chunk-Predicate.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Predicate.mjs","names":[],"sources":["../../src/Predicate.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\n// Leading auxiliary / copula / article words dropped from a predicate so \"is a man\" keys as \"man\"\n// and \"is working at\" keys the same as \"works at\".\nconst LEADING_NOISE = new Set([\n 'is',\n 'are',\n 'was',\n 'were',\n 'be',\n 'been',\n 'being',\n 'am',\n 'has',\n 'have',\n 'had',\n 'does',\n 'do',\n 'did',\n 'can',\n 'could',\n 'will',\n 'would',\n 'shall',\n 'should',\n 'may',\n 'might',\n 'must',\n 'a',\n 'an',\n 'the',\n 'to',\n]);\n\n/** Light inflectional stem of a single word (consistency over linguistic correctness). */\nconst stem = (word: string): string => {\n if (word.length > 4 && word.endsWith('ing')) {\n return word.slice(0, -3);\n }\n if (word.length > 3 && word.endsWith('ed')) {\n return word.slice(0, -2);\n }\n if (word.length > 4 && word.endsWith('ies')) {\n return `${word.slice(0, -3)}y`;\n }\n if (word.length > 3 && word.endsWith('s') && !word.endsWith('ss')) {\n return word.slice(0, -1);\n }\n return word;\n};\n\n/**\n * Normalize a predicate to a relation key for matching: lowercase, collapse whitespace, drop leading\n * auxiliary/copula/article words, and light-stem the head verb. Inflection / case / auxiliary variants\n * collapse (e.g. `Works at` / `is working at` / `worked at` → `work at`). True synonyms (`at` vs `for`,\n * `works` vs `employed by`) are NOT merged — that needs a controlled vocabulary (deferred). Idempotent.\n */\nexport const normalize = (predicate: string, { stem: stemHead = true }: { stem?: boolean } = {}): string => {\n const tokens = predicate\n .toLowerCase()\n .trim()\n .split(/\\s+/)\n .filter((token) => token.length > 0);\n while (tokens.length > 1 && LEADING_NOISE.has(tokens[0])) {\n tokens.shift();\n }\n if (stemHead && tokens.length > 0) {\n tokens[0] = stem(tokens[0]);\n }\n return tokens.join(' ');\n};\n\n/**\n * The display form of a predicate or an inverse: lowercase kebab-case (`Works at` → `works-at`, `Known by` →\n * `known-by`), so labels the extractor, the ontology and a UI author each write read as one vocabulary. Unlike\n * {@link normalize} it keeps the words as said (no stemming, no dropped copula), since it is shown, not matched.\n * Idempotent.\n */\nexport const label = (predicate: string): string =>\n predicate\n .trim()\n .replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '');\n"],"mappings":";;;;;;AAQA,IAAM,gCAAgB,IAAI,IAAI;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAGD,IAAM,QAAQ,SAAyB;CACrC,IAAI,KAAK,SAAS,KAAK,KAAK,SAAS,KAAK,GACxC,OAAO,KAAK,MAAM,GAAG,EAAE;CAEzB,IAAI,KAAK,SAAS,KAAK,KAAK,SAAS,IAAI,GACvC,OAAO,KAAK,MAAM,GAAG,EAAE;CAEzB,IAAI,KAAK,SAAS,KAAK,KAAK,SAAS,KAAK,GACxC,OAAO,GAAG,KAAK,MAAM,GAAG,EAAE,EAAE;CAE9B,IAAI,KAAK,SAAS,KAAK,KAAK,SAAS,GAAG,KAAK,CAAC,KAAK,SAAS,IAAI,GAC9D,OAAO,KAAK,MAAM,GAAG,EAAE;CAEzB,OAAO;AACT;;;;;;;AAQA,IAAa,aAAa,WAAmB,EAAE,MAAM,WAAW,SAA6B,CAAC,MAAc;CAC1G,MAAM,SAAS,UACZ,YAAY,CAAC,CACb,KAAK,CAAC,CACN,MAAM,KAAK,CAAC,CACZ,QAAQ,UAAU,MAAM,SAAS,CAAC;CACrC,OAAO,OAAO,SAAS,KAAK,cAAc,IAAI,OAAO,EAAE,GACrD,OAAO,MAAM;CAEf,IAAI,YAAY,OAAO,SAAS,GAC9B,OAAO,KAAK,KAAK,OAAO,EAAE;CAE5B,OAAO,OAAO,KAAK,GAAG;AACxB;;;;;;;AAQA,IAAa,SAAS,cACpB,UACG,KAAK,CAAC,CACN,QAAQ,sBAAsB,OAAO,CAAC,CACtC,YAAY,CAAC,CACb,QAAQ,eAAe,GAAG,CAAC,CAC3B,QAAQ,YAAY,EAAE"}
@@ -0,0 +1,120 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ //#region src/Rdf.ts
3
+ var Rdf_exports = /* @__PURE__ */ __exportAll({
4
+ RDF_DIR_LANG_STRING: () => RDF_DIR_LANG_STRING,
5
+ RDF_LANG_STRING: () => RDF_LANG_STRING,
6
+ RDF_TYPE: () => RDF_TYPE,
7
+ XSD_STRING: () => XSD_STRING,
8
+ blankNode: () => blankNode,
9
+ defaultGraph: () => defaultGraph,
10
+ literal: () => literal,
11
+ namedNode: () => namedNode,
12
+ quad: () => quad,
13
+ variable: () => variable
14
+ });
15
+ var XSD_STRING = "http://www.w3.org/2001/XMLSchema#string";
16
+ var RDF_LANG_STRING = "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString";
17
+ var RDF_DIR_LANG_STRING = "http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString";
18
+ var RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
19
+ var NamedNodeTerm = class {
20
+ value;
21
+ termType = "NamedNode";
22
+ constructor(value) {
23
+ this.value = value;
24
+ }
25
+ equals(other) {
26
+ return !!other && other.termType === this.termType && other.value === this.value;
27
+ }
28
+ };
29
+ var BlankNodeTerm = class {
30
+ value;
31
+ termType = "BlankNode";
32
+ constructor(value) {
33
+ this.value = value;
34
+ }
35
+ equals(other) {
36
+ return !!other && other.termType === this.termType && other.value === this.value;
37
+ }
38
+ };
39
+ var LiteralTerm = class {
40
+ value;
41
+ language;
42
+ datatype;
43
+ direction;
44
+ termType = "Literal";
45
+ constructor(value, language, datatype, direction = "") {
46
+ this.value = value;
47
+ this.language = language;
48
+ this.datatype = datatype;
49
+ this.direction = direction;
50
+ }
51
+ equals(other) {
52
+ return !!other && other.termType === this.termType && other.value === this.value && other.language === this.language && (other.direction ?? "") === this.direction && other.datatype.equals(this.datatype);
53
+ }
54
+ };
55
+ var VariableTerm = class {
56
+ value;
57
+ termType = "Variable";
58
+ constructor(value) {
59
+ this.value = value;
60
+ }
61
+ equals(other) {
62
+ return !!other && other.termType === this.termType && other.value === this.value;
63
+ }
64
+ };
65
+ var DefaultGraphTerm = class {
66
+ termType = "DefaultGraph";
67
+ value = "";
68
+ equals(other) {
69
+ return !!other && other.termType === this.termType;
70
+ }
71
+ };
72
+ var QuadTerm = class {
73
+ subject;
74
+ predicate;
75
+ object;
76
+ graph;
77
+ termType = "Quad";
78
+ value = "";
79
+ constructor(subject, predicate, object, graph) {
80
+ this.subject = subject;
81
+ this.predicate = predicate;
82
+ this.object = object;
83
+ this.graph = graph;
84
+ }
85
+ equals(other) {
86
+ return !!other && other.termType === this.termType && this.subject.equals(other.subject) && this.predicate.equals(other.predicate) && this.object.equals(other.object) && this.graph.equals(other.graph);
87
+ }
88
+ };
89
+ var DEFAULT_GRAPH = new DefaultGraphTerm();
90
+ var STRING_DATATYPE = new NamedNodeTerm(XSD_STRING);
91
+ var LANG_STRING_DATATYPE = new NamedNodeTerm(RDF_LANG_STRING);
92
+ var DIR_LANG_STRING_DATATYPE = new NamedNodeTerm(RDF_DIR_LANG_STRING);
93
+ /** A named node for an IRI. */
94
+ var namedNode = (value) => new NamedNodeTerm(value);
95
+ var nextBlankNode = 0;
96
+ /** A blank node; without a label, one unique within this process. */
97
+ var blankNode = (value) => new BlankNodeTerm(value ?? `b${nextBlankNode++}`);
98
+ /**
99
+ * A literal: a string is a language tag (`rdf:langString`), a language with a direction a directional one
100
+ * (`rdf:dirLangString`), a named node a datatype; none makes an `xsd:string`. Language tags are compared lower-case,
101
+ * as RDF 1.1 requires.
102
+ */
103
+ var literal = (value, languageOrDatatype) => {
104
+ if (typeof languageOrDatatype === "string") return languageOrDatatype.length > 0 ? new LiteralTerm(value, languageOrDatatype.toLowerCase(), LANG_STRING_DATATYPE) : new LiteralTerm(value, "", STRING_DATATYPE);
105
+ if (languageOrDatatype === void 0) return new LiteralTerm(value, "", STRING_DATATYPE);
106
+ if ("termType" in languageOrDatatype) return new LiteralTerm(value, "", namedNode(languageOrDatatype.value));
107
+ const { language, direction } = languageOrDatatype;
108
+ if (language.length === 0) return new LiteralTerm(value, "", STRING_DATATYPE);
109
+ return direction ? new LiteralTerm(value, language.toLowerCase(), DIR_LANG_STRING_DATATYPE, direction) : new LiteralTerm(value, language.toLowerCase(), LANG_STRING_DATATYPE);
110
+ };
111
+ /** A SPARQL variable; `value` is its name without the leading `?`. */
112
+ var variable = (value) => new VariableTerm(value);
113
+ /** The default graph; every call returns the same term. */
114
+ var defaultGraph = () => DEFAULT_GRAPH;
115
+ /** A quad; a missing or `null` graph is the default graph, as RDF/JS requires. */
116
+ var quad = (subject, predicate, object, graph) => new QuadTerm(subject, predicate, object, graph ?? DEFAULT_GRAPH);
117
+ //#endregion
118
+ export { XSD_STRING as a, literal as c, variable as d, Rdf_exports as i, namedNode as l, RDF_LANG_STRING as n, blankNode as o, RDF_TYPE as r, defaultGraph as s, RDF_DIR_LANG_STRING as t, quad as u };
119
+
120
+ //# sourceMappingURL=chunk-Rdf.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Rdf.mjs","names":[],"sources":["../../src/Rdf.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as RdfJs from '@rdfjs/types';\n\n//\n// RDF/JS terms and quads (https://rdf.js.org/data-model-spec/), so the memory core builds and compares RDF without a\n// parser library: n3 pulls in `readable-stream`, which does not load under workerd's `nodejs_compat`.\n//\n\nexport type Term = RdfJs.Term;\nexport type NamedNode<Iri extends string = string> = RdfJs.NamedNode<Iri>;\nexport type BlankNode = RdfJs.BlankNode;\nexport type Literal = RdfJs.Literal;\nexport type Variable = RdfJs.Variable;\nexport type DefaultGraph = RdfJs.DefaultGraph;\nexport type Quad = RdfJs.Quad;\nexport type QuadSubject = RdfJs.Quad_Subject;\nexport type QuadPredicate = RdfJs.Quad_Predicate;\nexport type QuadObject = RdfJs.Quad_Object;\nexport type QuadGraph = RdfJs.Quad_Graph;\n\nexport const XSD_STRING = 'http://www.w3.org/2001/XMLSchema#string';\nexport const RDF_LANG_STRING = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString';\nexport const RDF_DIR_LANG_STRING = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString';\nexport const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';\n\nclass NamedNodeTerm<Iri extends string = string> implements RdfJs.NamedNode<Iri> {\n readonly termType = 'NamedNode';\n constructor(readonly value: Iri) {}\n equals(other: RdfJs.Term | null | undefined): boolean {\n return !!other && other.termType === this.termType && other.value === this.value;\n }\n}\n\nclass BlankNodeTerm implements RdfJs.BlankNode {\n readonly termType = 'BlankNode';\n constructor(readonly value: string) {}\n equals(other: RdfJs.Term | null | undefined): boolean {\n return !!other && other.termType === this.termType && other.value === this.value;\n }\n}\n\nclass LiteralTerm implements RdfJs.Literal {\n readonly termType = 'Literal';\n constructor(\n readonly value: string,\n readonly language: string,\n readonly datatype: RdfJs.NamedNode,\n readonly direction: '' | 'ltr' | 'rtl' = '',\n ) {}\n equals(other: RdfJs.Term | null | undefined): boolean {\n return (\n !!other &&\n other.termType === this.termType &&\n other.value === this.value &&\n other.language === this.language &&\n (other.direction ?? '') === this.direction &&\n other.datatype.equals(this.datatype)\n );\n }\n}\n\nclass VariableTerm implements RdfJs.Variable {\n readonly termType = 'Variable';\n constructor(readonly value: string) {}\n equals(other: RdfJs.Term | null | undefined): boolean {\n return !!other && other.termType === this.termType && other.value === this.value;\n }\n}\n\nclass DefaultGraphTerm implements RdfJs.DefaultGraph {\n readonly termType = 'DefaultGraph';\n readonly value = '';\n equals(other: RdfJs.Term | null | undefined): boolean {\n return !!other && other.termType === this.termType;\n }\n}\n\nclass QuadTerm implements RdfJs.Quad {\n readonly termType = 'Quad';\n readonly value = '';\n constructor(\n readonly subject: RdfJs.Quad_Subject,\n readonly predicate: RdfJs.Quad_Predicate,\n readonly object: RdfJs.Quad_Object,\n readonly graph: RdfJs.Quad_Graph,\n ) {}\n equals(other: RdfJs.Term | null | undefined): boolean {\n return (\n !!other &&\n other.termType === this.termType &&\n this.subject.equals(other.subject) &&\n this.predicate.equals(other.predicate) &&\n this.object.equals(other.object) &&\n this.graph.equals(other.graph)\n );\n }\n}\n\nconst DEFAULT_GRAPH = new DefaultGraphTerm();\nconst STRING_DATATYPE = new NamedNodeTerm(XSD_STRING);\nconst LANG_STRING_DATATYPE = new NamedNodeTerm(RDF_LANG_STRING);\nconst DIR_LANG_STRING_DATATYPE = new NamedNodeTerm(RDF_DIR_LANG_STRING);\n\n/** A named node for an IRI. */\nexport const namedNode = <Iri extends string = string>(value: Iri): RdfJs.NamedNode<Iri> => new NamedNodeTerm(value);\n\nlet nextBlankNode = 0;\n\n/** A blank node; without a label, one unique within this process. */\nexport const blankNode = (value?: string): RdfJs.BlankNode => new BlankNodeTerm(value ?? `b${nextBlankNode++}`);\n\n/**\n * A literal: a string is a language tag (`rdf:langString`), a language with a direction a directional one\n * (`rdf:dirLangString`), a named node a datatype; none makes an `xsd:string`. Language tags are compared lower-case,\n * as RDF 1.1 requires.\n */\nexport const literal = (\n value: string,\n languageOrDatatype?: string | RdfJs.NamedNode | RdfJs.DirectionalLanguage,\n): RdfJs.Literal => {\n if (typeof languageOrDatatype === 'string') {\n return languageOrDatatype.length > 0\n ? new LiteralTerm(value, languageOrDatatype.toLowerCase(), LANG_STRING_DATATYPE)\n : new LiteralTerm(value, '', STRING_DATATYPE);\n }\n if (languageOrDatatype === undefined) {\n return new LiteralTerm(value, '', STRING_DATATYPE);\n }\n if ('termType' in languageOrDatatype) {\n return new LiteralTerm(value, '', namedNode(languageOrDatatype.value));\n }\n const { language, direction } = languageOrDatatype;\n if (language.length === 0) {\n return new LiteralTerm(value, '', STRING_DATATYPE);\n }\n return direction\n ? new LiteralTerm(value, language.toLowerCase(), DIR_LANG_STRING_DATATYPE, direction)\n : new LiteralTerm(value, language.toLowerCase(), LANG_STRING_DATATYPE);\n};\n\n/** A SPARQL variable; `value` is its name without the leading `?`. */\nexport const variable = (value: string): RdfJs.Variable => new VariableTerm(value);\n\n/** The default graph; every call returns the same term. */\nexport const defaultGraph = (): RdfJs.DefaultGraph => DEFAULT_GRAPH;\n\n/** A quad; a missing or `null` graph is the default graph, as RDF/JS requires. */\nexport const quad = (\n subject: RdfJs.Quad_Subject,\n predicate: RdfJs.Quad_Predicate,\n object: RdfJs.Quad_Object,\n graph?: RdfJs.Quad_Graph | null,\n): RdfJs.Quad => new QuadTerm(subject, predicate, object, graph ?? DEFAULT_GRAPH);\n"],"mappings":";;;;;;;;;;;;;;AAyBA,IAAa,aAAa;AAC1B,IAAa,kBAAkB;AAC/B,IAAa,sBAAsB;AACnC,IAAa,WAAW;AAExB,IAAM,gBAAN,MAAiF;CAE1D;CADrB,WAAoB;CACpB,YAAY,OAAqB;EAAZ,KAAA,QAAA;CAAa;CAClC,OAAO,OAA+C;EACpD,OAAO,CAAC,CAAC,SAAS,MAAM,aAAa,KAAK,YAAY,MAAM,UAAU,KAAK;CAC7E;AACF;AAEA,IAAM,gBAAN,MAA+C;CAExB;CADrB,WAAoB;CACpB,YAAY,OAAwB;EAAf,KAAA,QAAA;CAAgB;CACrC,OAAO,OAA+C;EACpD,OAAO,CAAC,CAAC,SAAS,MAAM,aAAa,KAAK,YAAY,MAAM,UAAU,KAAK;CAC7E;AACF;AAEA,IAAM,cAAN,MAA2C;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aAA0C,UAAqC,IAAI,cAAc,KAAK;AAEnH,IAAI,gBAAgB;;AAGpB,IAAa,aAAa,UAAoC,IAAI,cAAc,SAAS,IAAI,iBAAiB;;;;;;AAO9G,IAAa,WACX,OACA,uBACkB;CAClB,IAAI,OAAO,uBAAuB,UAChC,OAAO,mBAAmB,SAAS,IAC/B,IAAI,YAAY,OAAO,mBAAmB,YAAY,GAAG,oBAAoB,IAC7E,IAAI,YAAY,OAAO,IAAI,eAAe;CAEhD,IAAI,uBAAuB,KAAA,GACzB,OAAO,IAAI,YAAY,OAAO,IAAI,eAAe;CAEnD,IAAI,cAAc,oBAChB,OAAO,IAAI,YAAY,OAAO,IAAI,UAAU,mBAAmB,KAAK,CAAC;CAEvE,MAAM,EAAE,UAAU,cAAc;CAChC,IAAI,SAAS,WAAW,GACtB,OAAO,IAAI,YAAY,OAAO,IAAI,eAAe;CAEnD,OAAO,YACH,IAAI,YAAY,OAAO,SAAS,YAAY,GAAG,0BAA0B,SAAS,IAClF,IAAI,YAAY,OAAO,SAAS,YAAY,GAAG,oBAAoB;AACzE;;AAGA,IAAa,YAAY,UAAkC,IAAI,aAAa,KAAK;;AAGjF,IAAa,qBAAyC;;AAGtD,IAAa,QACX,SACA,WACA,QACA,UACe,IAAI,SAAS,SAAS,WAAW,QAAQ,SAAS,aAAa"}
@@ -0,0 +1,60 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { u as SparqlTerm } from "./chunk-MemoryQuery.mjs";
3
+ import * as Schema from "effect/Schema";
4
+ import * as Context from "effect/Context";
5
+ import { BaseError } from "@dxos/errors";
6
+ //#region src/RdfStore.ts
7
+ var RdfStore_exports = /* @__PURE__ */ __exportAll({
8
+ Batch: () => Batch,
9
+ Clear: () => Clear,
10
+ Delete: () => Delete,
11
+ Format: () => Format,
12
+ ImportResult: () => ImportResult,
13
+ Insert: () => Insert,
14
+ Quad: () => Quad,
15
+ RdfStore: () => RdfStore,
16
+ RdfStoreError: () => RdfStoreError,
17
+ Write: () => Write
18
+ });
19
+ /** A triple in the default graph, or a quad in the named graph `g`. */
20
+ var Quad = Schema.Struct({
21
+ s: SparqlTerm,
22
+ p: SparqlTerm,
23
+ o: SparqlTerm,
24
+ g: Schema.optional(SparqlTerm)
25
+ });
26
+ /** Adds quads; one already stored is kept once. */
27
+ var Insert = Schema.TaggedStruct("insert", { quads: Schema.Array(Quad) });
28
+ /** Removes quads; one not stored is ignored. */
29
+ var Delete = Schema.TaggedStruct("delete", { quads: Schema.Array(Quad) });
30
+ /** Removes every quad of the part written to. */
31
+ var Clear = Schema.TaggedStruct("clear", {});
32
+ /** One change to the store. */
33
+ var Write = Schema.Union([
34
+ Insert,
35
+ Delete,
36
+ Clear
37
+ ]);
38
+ /** Writes recorded together and applied together, in order. */
39
+ var Batch = Schema.Struct({
40
+ id: Schema.String,
41
+ writes: Schema.Array(Write)
42
+ });
43
+ /**
44
+ * How quads move in and out in bulk. `trig`: the Turtle family's text syntax with named graphs, which every fact is
45
+ * stored in and plain Turtle cannot express. `binary`: a term dictionary and the quads as indexes into it, several
46
+ * times smaller and faster to read, for copies between stores.
47
+ */
48
+ var Format = Schema.Literals(["trig", "binary"]);
49
+ /** The store refused, could not be reached, or the input does not parse; the message says which. */
50
+ var RdfStoreError = class extends BaseError.extend("RdfStoreError", "RDF store operation failed.") {};
51
+ /** What an import added: the batch it wrote, and how many quads it read. */
52
+ var ImportResult = Schema.Struct({
53
+ batch: Schema.String,
54
+ quads: Schema.Number
55
+ });
56
+ var RdfStore = class extends Context.Service()("@dxos/echo-memory/RdfStore") {};
57
+ //#endregion
58
+ export { ImportResult as a, RdfStore as c, Write as d, Format as i, RdfStoreError as l, Clear as n, Insert as o, Delete as r, Quad as s, Batch as t, RdfStore_exports as u };
59
+
60
+ //# sourceMappingURL=chunk-RdfStore.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-RdfStore.mjs","names":["MemoryQuery.SparqlTerm"],"sources":["../../src/RdfStore.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Context from 'effect/Context';\nimport type * as Effect from 'effect/Effect';\nimport * as Schema from 'effect/Schema';\nimport type * as Scope from 'effect/Scope';\n\nimport { BaseError } from '@dxos/errors';\n\nimport * as MemoryQuery from './MemoryQuery.ts';\n\n//\n// The store a memory runs on: a space's quads, read with SPARQL and changed by batches of writes. A memory turns its\n// operations into these calls, so the same memory runs over a store in the page, in a worker, or across RPC.\n//\n\n/** A triple in the default graph, or a quad in the named graph `g`. */\nexport const Quad = Schema.Struct({\n s: MemoryQuery.SparqlTerm,\n p: MemoryQuery.SparqlTerm,\n o: MemoryQuery.SparqlTerm,\n g: Schema.optional(MemoryQuery.SparqlTerm),\n});\nexport interface Quad extends Schema.Schema.Type<typeof Quad> {}\n\n/** Adds quads; one already stored is kept once. */\nexport const Insert = Schema.TaggedStruct('insert', { quads: Schema.Array(Quad) });\nexport interface Insert extends Schema.Schema.Type<typeof Insert> {}\n\n/** Removes quads; one not stored is ignored. */\nexport const Delete = Schema.TaggedStruct('delete', { quads: Schema.Array(Quad) });\nexport interface Delete extends Schema.Schema.Type<typeof Delete> {}\n\n/** Removes every quad of the part written to. */\nexport const Clear = Schema.TaggedStruct('clear', {});\nexport interface Clear extends Schema.Schema.Type<typeof Clear> {}\n\n/** One change to the store. */\nexport const Write = Schema.Union([Insert, Delete, Clear]);\nexport type Write = Schema.Schema.Type<typeof Write>;\n\n/** Writes recorded together and applied together, in order. */\nexport const Batch = Schema.Struct({ id: Schema.String, writes: Schema.Array(Write) });\nexport interface Batch extends Schema.Schema.Type<typeof Batch> {}\n\n/**\n * How quads move in and out in bulk. `trig`: the Turtle family's text syntax with named graphs, which every fact is\n * stored in and plain Turtle cannot express. `binary`: a term dictionary and the quads as indexes into it, several\n * times smaller and faster to read, for copies between stores.\n */\nexport const Format = Schema.Literals(['trig', 'binary']);\nexport type Format = Schema.Schema.Type<typeof Format>;\n\n/** The store refused, could not be reached, or the input does not parse; the message says which. */\nexport class RdfStoreError extends BaseError.extend('RdfStoreError', 'RDF store operation failed.') {}\n\nexport type ExportOptions = {\n /** Namespace prefixes a TriG export abbreviates IRIs with, by prefix. */\n readonly prefixes?: Readonly<Record<string, string>>;\n};\n\n/** What an import added: the batch it wrote, and how many quads it read. */\nexport const ImportResult = Schema.Struct({ batch: Schema.String, quads: Schema.Number });\nexport interface ImportResult extends Schema.Schema.Type<typeof ImportResult> {}\n\nexport type QueryOptions = {\n /** Reads the store's local part instead of its shared part. */\n readonly local?: boolean;\n};\n\nexport type WriteOptions = {\n /**\n * Writes the store's local part: kept on this device only, never replicated, and untouched by a `clear` of the\n * shared part. A memory keeps its subscriptions and their undelivered events there.\n */\n readonly local?: boolean;\n};\n\n/**\n * A space's quads in two parts. The shared part is replicated: a write is recorded durably before it is applied, and\n * every replica applies the same batches in the same order. The local part is this device's own.\n */\nexport interface Service {\n /** Runs a SPARQL read (SELECT, ASK or CONSTRUCT); an update fails, since changes go through {@link write}. */\n readonly query: (\n sparql: string,\n options?: QueryOptions,\n ) => Effect.Effect<readonly MemoryQuery.SparqlRow[], RdfStoreError>;\n\n /** Applies the writes as one batch and returns its id, once it is durable (shared) or written (local). */\n readonly write: (writes: readonly Write[], options?: WriteOptions) => Effect.Effect<string, RdfStoreError>;\n\n /** Every quad of the shared part, serialized where the store is, so a large store crosses a boundary once. */\n readonly export: (format: Format, options?: ExportOptions) => Effect.Effect<Uint8Array, RdfStoreError>;\n\n /** Parses the data where the store is and inserts its quads into the shared part as one batch. */\n readonly import: (data: Uint8Array, format: Format) => Effect.Effect<ImportResult, RdfStoreError>;\n\n /**\n * Calls `onApplied` with each batch of the shared part once it is applied, this replica's and other replicas' alike,\n * in the order applied, until the scope closes. The listener is registered before this returns, so a reader that\n * listens and then reads misses nothing.\n */\n readonly listen: (onApplied: (batch: Batch) => void) => Effect.Effect<void, never, Scope.Scope>;\n}\n\nexport class RdfStore extends Context.Service<RdfStore, Service>()('@dxos/echo-memory/RdfStore') {}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqBA,IAAa,OAAO,OAAO,OAAO;CAChC,GAAGA;CACH,GAAGA;CACH,GAAGA;CACH,GAAG,OAAO,SAASA,UAAsB;AAC3C,CAAC;;AAID,IAAa,SAAS,OAAO,aAAa,UAAU,EAAE,OAAO,OAAO,MAAM,IAAI,EAAE,CAAC;;AAIjF,IAAa,SAAS,OAAO,aAAa,UAAU,EAAE,OAAO,OAAO,MAAM,IAAI,EAAE,CAAC;;AAIjF,IAAa,QAAQ,OAAO,aAAa,SAAS,CAAC,CAAC;;AAIpD,IAAa,QAAQ,OAAO,MAAM;CAAC;CAAQ;CAAQ;AAAK,CAAC;;AAIzD,IAAa,QAAQ,OAAO,OAAO;CAAE,IAAI,OAAO;CAAQ,QAAQ,OAAO,MAAM,KAAK;AAAE,CAAC;;;;;;AAQrF,IAAa,SAAS,OAAO,SAAS,CAAC,QAAQ,QAAQ,CAAC;;AAIxD,IAAa,gBAAb,cAAmC,UAAU,OAAO,iBAAiB,6BAA6B,CAAC,CAAC,CAAC;;AAQrG,IAAa,eAAe,OAAO,OAAO;CAAE,OAAO,OAAO;CAAQ,OAAO,OAAO;AAAO,CAAC;AA4CxF,IAAa,WAAb,cAA8B,QAAQ,QAA2B,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,153 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { O as termValue } from "./chunk-Fact.mjs";
3
+ import { i as Rdf_exports } from "./chunk-Rdf.mjs";
4
+ import { $ as localEntitySuffix, D as RDF_PROPERTY, F as SX_GRAPH, I as SX_SEED, K as entityNode, O as RDF_TYPE, T as RDFS_LABEL, X as isIri, f as ONTOLOGY_GRAPH, y as PROV } from "./chunk-Vocab.mjs";
5
+ import { c as key, l as labelFromIri, t as DEFAULT } from "./chunk-Ontology.mjs";
6
+ import { t as KIND_CLASSES } from "./chunk-Mapping.mjs";
7
+ //#region src/Sparql.ts
8
+ var Sparql_exports = /* @__PURE__ */ __exportAll({
9
+ DESCRIBED_PREDICATES_SPARQL: () => DESCRIBED_PREDICATES_SPARQL,
10
+ ONTOLOGY_SPARQL: () => ONTOLOGY_SPARQL,
11
+ SEED_MARKER_SPARQL: () => SEED_MARKER_SPARQL,
12
+ STORED_PREDICATES_SPARQL: () => STORED_PREDICATES_SPARQL,
13
+ boundGraphs: () => boundGraphs,
14
+ candidateGraphs: () => candidateGraphs,
15
+ deleteSeedSparql: () => deleteSeedSparql,
16
+ graphQuadsSparql: () => graphQuadsSparql,
17
+ graphValues: () => graphValues,
18
+ matchingPredicates: () => matchingPredicates,
19
+ predicateLabels: () => predicateLabels,
20
+ rowsToQuads: () => rowsToQuads,
21
+ statementMatches: () => statementMatches,
22
+ toQuad: () => toQuad,
23
+ toTerm: () => toTerm
24
+ });
25
+ /** SPARQL IRIREF excludes these characters; a UCHAR escape keeps an arbitrary IRI or key from breaking the query. */
26
+ var iriRef = (iri) => `<${[...iri].map((char) => char <= " " || "<>\"{}|^`\\".includes(char) ? `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}` : char).join("")}>`;
27
+ var ONTOLOGY = iriRef(ONTOLOGY_GRAPH);
28
+ var KINDS = KIND_CLASSES.map(iriRef).join(", ");
29
+ /** Excludes rows that are not statements: the ontology graph, and an entity's label or kind. */
30
+ var statementFilter = (graph, predicate, object) => `FILTER(${graph} != ${ONTOLOGY} && ${predicate} != ${iriRef(RDFS_LABEL)} && !(${predicate} = ${iriRef(RDF_TYPE)} && ${object} IN (${KINDS})))`;
31
+ /** An entity key names its IRI exactly, and a slug also names the graph-local entity of that slug in every graph. */
32
+ var isEntity = (variable, key) => {
33
+ const node = iriRef(entityNode(key).value);
34
+ return isIri(key) ? `${variable} = ${node}` : `(${variable} = ${node} || (isIRI(${variable}) && STRENDS(STR(${variable}), ${JSON.stringify(localEntitySuffix(key))})))`;
35
+ };
36
+ /** Every quad of the ontology graph (predicate labels), as `?g ?s ?p ?o`. */
37
+ var ONTOLOGY_SPARQL = `SELECT ?g ?s ?p ?o WHERE { VALUES ?g { ${ONTOLOGY} } GRAPH ?g { ?s ?p ?o } }`;
38
+ /** The distinct predicates of every stored statement. */
39
+ var STORED_PREDICATES_SPARQL = `SELECT DISTINCT ?p WHERE { GRAPH ?g { ?s ?p ?o } ${statementFilter("?g", "?p", "?o")} }`;
40
+ /** Every predicate the ontology graph already describes as an `rdf:Property`. */
41
+ var DESCRIBED_PREDICATES_SPARQL = `SELECT DISTINCT ?s WHERE { GRAPH ${ONTOLOGY} { ?s ${iriRef(RDF_TYPE)} ${iriRef(RDF_PROPERTY)} } }`;
42
+ /** The seed-version marker, kept in the default graph about the ontology graph. */
43
+ var SEED_MARKER_SPARQL = `SELECT ?v WHERE { ${ONTOLOGY} ${iriRef(SX_SEED)} ?v }`;
44
+ /** SPARQL UPDATEs removing the seed marker and the ontology-graph description of each of `iris`, one per request. */
45
+ var deleteSeedSparql = (iris) => [`DELETE WHERE { ${ONTOLOGY} ${iriRef(SX_SEED)} ?v }`, ...iris.map((iri) => `DELETE WHERE { GRAPH ${ONTOLOGY} { ${iriRef(iri)} ?p ?o } }`)];
46
+ /** The label of each stored predicate: from the ontology graph, else the ontology, else its IRI. */
47
+ var predicateLabels = (stored, ontologyQuads, ontology = DEFAULT) => {
48
+ const labels = /* @__PURE__ */ new Map();
49
+ for (const quad of ontologyQuads) if (quad.predicate.value === "http://www.w3.org/2000/01/rdf-schema#label" && !labels.has(quad.subject.value)) labels.set(quad.subject.value, quad.object.value);
50
+ return new Map([...stored].map((iri) => [iri, labels.get(iri) ?? ontology.get(iri)?.label ?? labelFromIri(iri)]));
51
+ };
52
+ /**
53
+ * Group pattern binding `?g` to every named graph holding a statement that matches each of the query's
54
+ * constraints, with `predicates` the IRIs its predicate names. Confidence is not a constraint here: the caller
55
+ * re-checks every statement (`statementMatches`).
56
+ */
57
+ var candidateGraphs = (query, predicates) => {
58
+ const patterns = [];
59
+ if (query.subjectEntity) patterns.push(`{ GRAPH ?g { ?ss ?sp ?so } ${statementFilter("?g", "?sp", "?so")} FILTER(${isEntity("?ss", query.subjectEntity)}) }`);
60
+ if (predicates) patterns.push(`{ GRAPH ?g { ?ps ?pp ?po } FILTER(?g != ${ONTOLOGY} && ?pp IN (${[...predicates].map(iriRef).join(", ")})) }`);
61
+ if (query.source) patterns.push(`?g ${iriRef(`${PROV}wasDerivedFrom`)} ${JSON.stringify(query.source)} .`);
62
+ if (query.entity) patterns.push(`{ GRAPH ?g { ?es ?ep ?eo } ${statementFilter("?g", "?ep", "?eo")} FILTER(${isEntity("?es", query.entity)} || ${isEntity("?eo", query.entity)}) }`);
63
+ return patterns.length === 0 ? `?g ${iriRef(RDF_TYPE)} ${iriRef(SX_GRAPH)} .` : patterns.join("\n");
64
+ };
65
+ /** Group pattern binding `?g` to exactly the given graph IRIs. */
66
+ var graphValues = (graphs) => `VALUES ?g { ${graphs.map(iriRef).join(" ")} }`;
67
+ /**
68
+ * SPARQL loading every quad of the graphs `candidates` binds, as `?g ?s ?p ?o`, and each graph's provenance from
69
+ * the default graph, as `?g ?p ?o` with `?s` unbound.
70
+ */
71
+ var graphQuadsSparql = (candidates) => `SELECT ?g ?s ?p ?o WHERE { { SELECT DISTINCT ?g WHERE { ${candidates} } } { GRAPH ?g { ?s ?p ?o } } UNION { ?g ?p ?o } }`;
72
+ /** Whether one relation key's words occur, in order and whole, in another's: `is a` (key `a`) is not in `work_at`. */
73
+ var contains = (haystack, needle) => {
74
+ const words = haystack.split("_");
75
+ const sought = needle.split("_");
76
+ return words.some((_, start) => sought.every((word, offset) => words[start + offset] === word));
77
+ };
78
+ /**
79
+ * The stored predicates a query's predicate names: those its surface form resolves to through the ontology, and
80
+ * those whose label or synonyms share its relation key, either way round, since a model rarely reproduces the
81
+ * stored phrase verbatim.
82
+ */
83
+ var matchingPredicates = (surface, predicates, ontology = DEFAULT) => {
84
+ if (isIri(surface)) return ontology.equivalents(surface);
85
+ const needle = key(surface);
86
+ const matches = /* @__PURE__ */ new Set([ontology.resolve(surface).iri]);
87
+ for (const [iri, label] of predicates) {
88
+ const entry = ontology.get(iri);
89
+ if ([label, ...entry ? [entry.name, ...entry.synonyms ?? []] : []].map(key).some((key) => contains(key, needle) || contains(needle, key))) matches.add(iri);
90
+ }
91
+ return new Set([...matches].flatMap((iri) => [...ontology.equivalents(iri)]));
92
+ };
93
+ /**
94
+ * Whether a statement satisfies the query. Candidate graphs are found by any statement in them, so each statement
95
+ * is checked again here: a graph about Rich may also hold a statement about DXOS.
96
+ */
97
+ var statementMatches = (fact, query, predicates) => {
98
+ const subject = termValue(fact.assertion.subject);
99
+ const object = termValue(fact.assertion.object);
100
+ return (query.subjectEntity === void 0 || subject === query.subjectEntity) && (query.entity === void 0 || subject === query.entity || fact.assertion.object.kind === "entity" && object === query.entity) && (predicates === void 0 || predicates.has(fact.assertion.predicateIri ?? "")) && (query.source === void 0 || fact.attribution.source === query.source) && (query.minConfidence === void 0 || (fact.factuality.confidence ?? 0) >= query.minConfidence);
101
+ };
102
+ var { blankNode, defaultGraph, literal, namedNode, quad } = Rdf_exports;
103
+ var XSD_STRING = "http://www.w3.org/2001/XMLSchema#string";
104
+ /** RDF/JS term → the engine's plain-data term. */
105
+ var toTerm = (term) => {
106
+ switch (term.termType) {
107
+ case "NamedNode":
108
+ case "BlankNode": return {
109
+ termType: term.termType,
110
+ value: term.value
111
+ };
112
+ case "Literal": return term.language ? {
113
+ termType: "Literal",
114
+ value: term.value,
115
+ language: term.language
116
+ } : term.datatype.value === XSD_STRING ? {
117
+ termType: "Literal",
118
+ value: term.value
119
+ } : {
120
+ termType: "Literal",
121
+ value: term.value,
122
+ datatype: term.datatype.value
123
+ };
124
+ default: throw new TypeError(`Unsupported term in a stored triple: ${term.termType}`);
125
+ }
126
+ };
127
+ /** RDF/JS quad → engine quad (the default graph is the engine's absent `g`). */
128
+ var toQuad = (triple) => ({
129
+ s: toTerm(triple.subject),
130
+ p: toTerm(triple.predicate),
131
+ o: toTerm(triple.object),
132
+ ...triple.graph.termType === "DefaultGraph" ? {} : { g: toTerm(triple.graph) }
133
+ });
134
+ var toResource = (term) => term.termType === "BlankNode" ? blankNode(term.value) : namedNode(term.value);
135
+ var toObject = (term) => term.termType === "Literal" ? literal(term.value, term.language ?? (term.datatype ? namedNode(term.datatype) : void 0)) : toResource(term);
136
+ /**
137
+ * `?g ?s ?p ?o` solutions as quads: a row with `?s` bound is a quad in graph `?g`, one without it is a default-graph
138
+ * triple about `?g` (its provenance). Rows with a literal in a resource position are skipped.
139
+ */
140
+ var rowsToQuads = (rows) => rows.flatMap(({ g, s, p, o }) => {
141
+ if (g?.termType !== "NamedNode" || p?.termType !== "NamedNode" || o === void 0) return [];
142
+ if (s === void 0) return [quad(namedNode(g.value), namedNode(p.value), toObject(o), defaultGraph())];
143
+ return s.termType === "Literal" ? [] : [quad(toResource(s), namedNode(p.value), toObject(o), namedNode(g.value))];
144
+ });
145
+ /** The distinct graph IRIs a raw SELECT binds to `?g`, or to `?fact`, the variable of the earlier reified shape. */
146
+ var boundGraphs = (rows) => [...new Set(rows.flatMap((row) => {
147
+ const graph = row.g ?? row.fact;
148
+ return graph?.termType === "NamedNode" ? [graph.value] : [];
149
+ }))];
150
+ //#endregion
151
+ export { Sparql_exports as a, deleteSeedSparql as c, matchingPredicates as d, predicateLabels as f, toTerm as g, toQuad as h, STORED_PREDICATES_SPARQL as i, graphQuadsSparql as l, statementMatches as m, ONTOLOGY_SPARQL as n, boundGraphs as o, rowsToQuads as p, SEED_MARKER_SPARQL as r, candidateGraphs as s, DESCRIBED_PREDICATES_SPARQL as t, graphValues as u };
152
+
153
+ //# sourceMappingURL=chunk-Sparql.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Sparql.mjs","names":["Vocab.ONTOLOGY_GRAPH","Vocab.RDFS_LABEL","Vocab.RDF_TYPE","Vocab.entityNode","Vocab.isIri","Vocab.localEntitySuffix","Vocab.RDF_PROPERTY","Vocab.SX_SEED","Ontology.DEFAULT","Ontology.labelFromIri","Vocab.PROV","Vocab.SX_GRAPH","Ontology.key","Fact.termValue","Rdf"],"sources":["../../src/Sparql.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport * as Fact from './Fact.ts';\nimport * as Mapping from './Mapping.ts';\nimport type * as MemoryQuery from './MemoryQuery.ts';\nimport * as Ontology from './Ontology.ts';\nimport * as Rdf from './Rdf.ts';\nimport type * as RdfStore from './RdfStore.ts';\nimport * as Vocab from './Vocab.ts';\n\n//\n// How a fact query becomes SPARQL over the stored layout (one named graph per provenance, its statements inside and\n// its provenance about it in the default graph), and how solutions become quads and facts again. Shared by every store\n// that keeps facts as quads, so they answer a query alike.\n//\n\n/** A fact query in its plain form. */\nexport type Pattern = Schema.Codec.Encoded<typeof MemoryQuery.FactQuery>;\n\n/** A solution as an engine reports it: a variable it leaves unbound may be present as `undefined`. */\nexport type Row = Readonly<Record<string, MemoryQuery.SparqlTerm | undefined>>;\n\n/** SPARQL IRIREF excludes these characters; a UCHAR escape keeps an arbitrary IRI or key from breaking the query. */\nconst iriRef = (iri: string): string =>\n `<${[...iri]\n .map((char) =>\n char <= ' ' || '<>\"{}|^`\\\\'.includes(char) ? `\\\\u${char.charCodeAt(0).toString(16).padStart(4, '0')}` : char,\n )\n .join('')}>`;\n\nconst ONTOLOGY = iriRef(Vocab.ONTOLOGY_GRAPH);\n\nconst KINDS = Mapping.KIND_CLASSES.map(iriRef).join(', ');\n\n/** Excludes rows that are not statements: the ontology graph, and an entity's label or kind. */\nconst statementFilter = (graph: string, predicate: string, object: string) =>\n `FILTER(${graph} != ${ONTOLOGY} && ${predicate} != ${iriRef(Vocab.RDFS_LABEL)} && !(${predicate} = ${iriRef(Vocab.RDF_TYPE)} && ${object} IN (${KINDS})))`;\n\n/** An entity key names its IRI exactly, and a slug also names the graph-local entity of that slug in every graph. */\nconst isEntity = (variable: string, key: string): string => {\n const node = iriRef(Vocab.entityNode(key).value);\n return Vocab.isIri(key)\n ? `${variable} = ${node}`\n : `(${variable} = ${node} || (isIRI(${variable}) && STRENDS(STR(${variable}), ${JSON.stringify(Vocab.localEntitySuffix(key))})))`;\n};\n\n/** Every quad of the ontology graph (predicate labels), as `?g ?s ?p ?o`. */\nexport const ONTOLOGY_SPARQL = `SELECT ?g ?s ?p ?o WHERE { VALUES ?g { ${ONTOLOGY} } GRAPH ?g { ?s ?p ?o } }`;\n\n/** The distinct predicates of every stored statement. */\nexport const STORED_PREDICATES_SPARQL = `SELECT DISTINCT ?p WHERE { GRAPH ?g { ?s ?p ?o } ${statementFilter('?g', '?p', '?o')} }`;\n\n/** Every predicate the ontology graph already describes as an `rdf:Property`. */\nexport const DESCRIBED_PREDICATES_SPARQL = `SELECT DISTINCT ?s WHERE { GRAPH ${ONTOLOGY} { ?s ${iriRef(Vocab.RDF_TYPE)} ${iriRef(Vocab.RDF_PROPERTY)} } }`;\n\n/** The seed-version marker, kept in the default graph about the ontology graph. */\nexport const SEED_MARKER_SPARQL = `SELECT ?v WHERE { ${ONTOLOGY} ${iriRef(Vocab.SX_SEED)} ?v }`;\n\n/** SPARQL UPDATEs removing the seed marker and the ontology-graph description of each of `iris`, one per request. */\nexport const deleteSeedSparql = (iris: readonly string[]): string[] => [\n `DELETE WHERE { ${ONTOLOGY} ${iriRef(Vocab.SX_SEED)} ?v }`,\n ...iris.map((iri) => `DELETE WHERE { GRAPH ${ONTOLOGY} { ${iriRef(iri)} ?p ?o } }`),\n];\n\n/** The label of each stored predicate: from the ontology graph, else the ontology, else its IRI. */\nexport const predicateLabels = (\n stored: Iterable<string>,\n ontologyQuads: readonly Rdf.Quad[],\n ontology: Ontology.Ontology = Ontology.DEFAULT,\n): Map<string, string> => {\n const labels = new Map<string, string>();\n for (const quad of ontologyQuads) {\n if (quad.predicate.value === Vocab.RDFS_LABEL && !labels.has(quad.subject.value)) {\n labels.set(quad.subject.value, quad.object.value);\n }\n }\n return new Map(\n [...stored].map((iri) => [iri, labels.get(iri) ?? ontology.get(iri)?.label ?? Ontology.labelFromIri(iri)]),\n );\n};\n\n/**\n * Group pattern binding `?g` to every named graph holding a statement that matches each of the query's\n * constraints, with `predicates` the IRIs its predicate names. Confidence is not a constraint here: the caller\n * re-checks every statement (`statementMatches`).\n */\nexport const candidateGraphs = (query: Pattern, predicates?: ReadonlySet<string>): string => {\n const patterns: string[] = [];\n if (query.subjectEntity) {\n patterns.push(\n `{ GRAPH ?g { ?ss ?sp ?so } ${statementFilter('?g', '?sp', '?so')} FILTER(${isEntity('?ss', query.subjectEntity)}) }`,\n );\n }\n if (predicates) {\n patterns.push(\n `{ GRAPH ?g { ?ps ?pp ?po } FILTER(?g != ${ONTOLOGY} && ?pp IN (${[...predicates].map(iriRef).join(', ')})) }`,\n );\n }\n if (query.source) {\n patterns.push(`?g ${iriRef(`${Vocab.PROV}wasDerivedFrom`)} ${JSON.stringify(query.source)} .`);\n }\n if (query.entity) {\n patterns.push(\n `{ GRAPH ?g { ?es ?ep ?eo } ${statementFilter('?g', '?ep', '?eo')} FILTER(${isEntity('?es', query.entity)} || ${isEntity('?eo', query.entity)}) }`,\n );\n }\n return patterns.length === 0 ? `?g ${iriRef(Vocab.RDF_TYPE)} ${iriRef(Vocab.SX_GRAPH)} .` : patterns.join('\\n');\n};\n\n/** Group pattern binding `?g` to exactly the given graph IRIs. */\nexport const graphValues = (graphs: readonly string[]): string => `VALUES ?g { ${graphs.map(iriRef).join(' ')} }`;\n\n/**\n * SPARQL loading every quad of the graphs `candidates` binds, as `?g ?s ?p ?o`, and each graph's provenance from\n * the default graph, as `?g ?p ?o` with `?s` unbound.\n */\nexport const graphQuadsSparql = (candidates: string): string =>\n `SELECT ?g ?s ?p ?o WHERE { { SELECT DISTINCT ?g WHERE { ${candidates} } } { GRAPH ?g { ?s ?p ?o } } UNION { ?g ?p ?o } }`;\n\n/** Whether one relation key's words occur, in order and whole, in another's: `is a` (key `a`) is not in `work_at`. */\nconst contains = (haystack: string, needle: string): boolean => {\n const words = haystack.split('_');\n const sought = needle.split('_');\n return words.some((_, start) => sought.every((word, offset) => words[start + offset] === word));\n};\n\n/**\n * The stored predicates a query's predicate names: those its surface form resolves to through the ontology, and\n * those whose label or synonyms share its relation key, either way round, since a model rarely reproduces the\n * stored phrase verbatim.\n */\nexport const matchingPredicates = (\n surface: string,\n predicates: ReadonlyMap<string, string>,\n ontology: Ontology.Ontology = Ontology.DEFAULT,\n): Set<string> => {\n if (Vocab.isIri(surface)) {\n return ontology.equivalents(surface);\n }\n const needle = Ontology.key(surface);\n const matches = new Set([ontology.resolve(surface).iri]);\n for (const [iri, label] of predicates) {\n const entry = ontology.get(iri);\n const keys = [label, ...(entry ? [entry.name, ...(entry.synonyms ?? [])] : [])].map(Ontology.key);\n if (keys.some((key) => contains(key, needle) || contains(needle, key))) {\n matches.add(iri);\n }\n }\n // Merged predicates match each other, so statements made before a merge still answer.\n return new Set([...matches].flatMap((iri) => [...ontology.equivalents(iri)]));\n};\n\n/**\n * Whether a statement satisfies the query. Candidate graphs are found by any statement in them, so each statement\n * is checked again here: a graph about Rich may also hold a statement about DXOS.\n */\nexport const statementMatches = (fact: Fact.Fact, query: Pattern, predicates?: ReadonlySet<string>): boolean => {\n const subject = Fact.termValue(fact.assertion.subject);\n const object = Fact.termValue(fact.assertion.object);\n return (\n (query.subjectEntity === undefined || subject === query.subjectEntity) &&\n (query.entity === undefined ||\n subject === query.entity ||\n (fact.assertion.object.kind === 'entity' && object === query.entity)) &&\n (predicates === undefined || predicates.has(fact.assertion.predicateIri ?? '')) &&\n (query.source === undefined || fact.attribution.source === query.source) &&\n (query.minConfidence === undefined || (fact.factuality.confidence ?? 0) >= query.minConfidence)\n );\n};\n\nconst { blankNode, defaultGraph, literal, namedNode, quad } = Rdf;\n\nconst XSD_STRING = 'http://www.w3.org/2001/XMLSchema#string';\n\n/** RDF/JS term → the engine's plain-data term. */\nexport const toTerm = (term: Rdf.Term): MemoryQuery.SparqlTerm => {\n switch (term.termType) {\n case 'NamedNode':\n case 'BlankNode':\n return { termType: term.termType, value: term.value };\n case 'Literal':\n return term.language\n ? { termType: 'Literal', value: term.value, language: term.language }\n : term.datatype.value === XSD_STRING\n ? { termType: 'Literal', value: term.value }\n : { termType: 'Literal', value: term.value, datatype: term.datatype.value };\n default:\n throw new TypeError(`Unsupported term in a stored triple: ${term.termType}`);\n }\n};\n\n/** RDF/JS quad → engine quad (the default graph is the engine's absent `g`). */\nexport const toQuad = (triple: Rdf.Quad): RdfStore.Quad => ({\n s: toTerm(triple.subject),\n p: toTerm(triple.predicate),\n o: toTerm(triple.object),\n ...(triple.graph.termType === 'DefaultGraph' ? {} : { g: toTerm(triple.graph) }),\n});\n\nconst toResource = (term: MemoryQuery.SparqlTerm) =>\n term.termType === 'BlankNode' ? blankNode(term.value) : namedNode(term.value);\n\nconst toObject = (term: MemoryQuery.SparqlTerm) =>\n term.termType === 'Literal'\n ? literal(term.value, term.language ?? (term.datatype ? namedNode(term.datatype) : undefined))\n : toResource(term);\n\n/**\n * `?g ?s ?p ?o` solutions as quads: a row with `?s` bound is a quad in graph `?g`, one without it is a default-graph\n * triple about `?g` (its provenance). Rows with a literal in a resource position are skipped.\n */\nexport const rowsToQuads = (rows: readonly Row[]): Rdf.Quad[] =>\n rows.flatMap(({ g, s, p, o }) => {\n if (g?.termType !== 'NamedNode' || p?.termType !== 'NamedNode' || o === undefined) {\n return [];\n }\n if (s === undefined) {\n return [quad(namedNode(g.value), namedNode(p.value), toObject(o), defaultGraph())];\n }\n return s.termType === 'Literal' ? [] : [quad(toResource(s), namedNode(p.value), toObject(o), namedNode(g.value))];\n });\n\n/** The distinct graph IRIs a raw SELECT binds to `?g`, or to `?fact`, the variable of the earlier reified shape. */\nexport const boundGraphs = (rows: readonly Row[]): string[] => [\n ...new Set(\n rows.flatMap((row) => {\n const graph = row.g ?? row.fact;\n return graph?.termType === 'NamedNode' ? [graph.value] : [];\n }),\n ),\n];\n"],"mappings":";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AC,CAAC;CAEnF,OAAO,EAAE,aAAa,YAAY,CAAC,IAAI,CAAC,KAAK,WAAW,CAAC,GAAG,UAAU,EAAE,KAAK,GAAG,SAAS,CAAC,GAAG,UAAU,EAAE,KAAK,CAAC,CAAC;AAClH,CAAC;;AAGH,IAAa,eAAe,SAAmC,CAC7D,GAAG,IAAI,IACL,KAAK,SAAS,QAAQ;CACpB,MAAM,QAAQ,IAAI,KAAK,IAAI;CAC3B,OAAO,OAAO,aAAa,cAAc,CAAC,MAAM,KAAK,IAAI,CAAC;AAC5D,CAAC,CACH,CACF"}
@@ -0,0 +1,44 @@
1
+ import { t as __exportAll } from "./chunk-rolldown-runtime.mjs";
2
+ import { i as EntityKey, s as Fact } from "./chunk-Fact.mjs";
3
+ import * as Schema from "effect/Schema";
4
+ //#region src/Subscription.ts
5
+ var Subscription_exports = /* @__PURE__ */ __exportAll({
6
+ MAX_SUBSCRIPTIONS: () => 256,
7
+ MemoryEvent: () => MemoryEvent,
8
+ MemoryEventId: () => MemoryEventId,
9
+ Subscription: () => Subscription,
10
+ SubscriptionId: () => SubscriptionId
11
+ });
12
+ /** A subscription's id, unique in its space; chosen by the caller. */
13
+ var SubscriptionId = Schema.String.pipe(Schema.brand("@dxos/echo-memory/SubscriptionId"));
14
+ /** An event's id, stable per subscription, wake and facts, so a wake derived twice queues once. */
15
+ var MemoryEventId = Schema.String.pipe(Schema.brand("@dxos/echo-memory/MemoryEventId"));
16
+ /** Most subscriptions one space's memory holds at once. */
17
+ var MAX_SUBSCRIPTIONS = 256;
18
+ /** Goal rules held against a space's memory, and the caller's own record of why. */
19
+ var Subscription = Schema.Struct({
20
+ id: SubscriptionId,
21
+ /** The agent that holds it; `subscriptions(owner)` filters by it. */
22
+ owner: Schema.optional(EntityKey),
23
+ /** Datalog goal rules (`@dxos/brain`). */
24
+ rules: Schema.String,
25
+ /** ISO; facts put before it wake nothing. */
26
+ createdAt: Schema.String,
27
+ /** Stored and returned as is; never interpreted by memory. */
28
+ payload: Schema.optional(Schema.Unknown)
29
+ });
30
+ /** One wake of a subscription's rules, queued in its outbox until acknowledged. */
31
+ var MemoryEvent = Schema.Struct({
32
+ id: MemoryEventId,
33
+ subscription: SubscriptionId,
34
+ /** The rules' wake label, `achieved`, or a sub-goal id. */
35
+ label: Schema.String,
36
+ /** The facts behind the wake; empty for a wake the clock caused. */
37
+ facts: Schema.Array(Fact),
38
+ /** When it woke (ISO). */
39
+ at: Schema.String
40
+ });
41
+ //#endregion
42
+ export { SubscriptionId as a, Subscription as i, MemoryEvent as n, Subscription_exports as o, MemoryEventId as r, MAX_SUBSCRIPTIONS as t };
43
+
44
+ //# sourceMappingURL=chunk-Subscription.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chunk-Subscription.mjs","names":["Fact.EntityKey","Fact.Fact"],"sources":["../../src/Subscription.ts"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Schema from 'effect/Schema';\n\nimport * as Fact from './Fact.ts';\n\n/** A subscription's id, unique in its space; chosen by the caller. */\nexport const SubscriptionId = Schema.String.pipe(Schema.brand('@dxos/echo-memory/SubscriptionId'));\nexport type SubscriptionId = Schema.Schema.Type<typeof SubscriptionId>;\n\n/** An event's id, stable per subscription, wake and facts, so a wake derived twice queues once. */\nexport const MemoryEventId = Schema.String.pipe(Schema.brand('@dxos/echo-memory/MemoryEventId'));\nexport type MemoryEventId = Schema.Schema.Type<typeof MemoryEventId>;\n\n/** Most subscriptions one space's memory holds at once. */\nexport const MAX_SUBSCRIPTIONS = 256;\n\n/** Goal rules held against a space's memory, and the caller's own record of why. */\nexport const Subscription = Schema.Struct({\n id: SubscriptionId,\n /** The agent that holds it; `subscriptions(owner)` filters by it. */\n owner: Schema.optional(Fact.EntityKey),\n /** Datalog goal rules (`@dxos/brain`). */\n rules: Schema.String,\n /** ISO; facts put before it wake nothing. */\n createdAt: Schema.String,\n /** Stored and returned as is; never interpreted by memory. */\n payload: Schema.optional(Schema.Unknown),\n});\nexport interface Subscription extends Schema.Schema.Type<typeof Subscription> {}\n\n/** One wake of a subscription's rules, queued in its outbox until acknowledged. */\nexport const MemoryEvent = Schema.Struct({\n id: MemoryEventId,\n subscription: SubscriptionId,\n /** The rules' wake label, `achieved`, or a sub-goal id. */\n label: Schema.String,\n /** The facts behind the wake; empty for a wake the clock caused. */\n facts: Schema.Array(Fact.Fact),\n /** When it woke (ISO). */\n at: Schema.String,\n});\nexport interface MemoryEvent extends Schema.Schema.Type<typeof MemoryEvent> {}\n"],"mappings":";;;;;;;;;;;;AAWA,IAAa,iBAAiB,OAAO,OAAO,KAAK,OAAO,MAAM,kCAAkC,CAAC;;AAIjG,IAAa,gBAAgB,OAAO,OAAO,KAAK,OAAO,MAAM,iCAAiC,CAAC;;AAI/F,IAAa,oBAAoB;;AAGjC,IAAa,eAAe,OAAO,OAAO;CACxC,IAAI;;CAEJ,OAAO,OAAO,SAASA,SAAc;;CAErC,OAAO,OAAO;;CAEd,WAAW,OAAO;;CAElB,SAAS,OAAO,SAAS,OAAO,OAAO;AACzC,CAAC;;AAID,IAAa,cAAc,OAAO,OAAO;CACvC,IAAI;CACJ,cAAc;;CAEd,OAAO,OAAO;;CAEd,OAAO,OAAO,MAAMC,IAAS;;CAE7B,IAAI,OAAO;AACb,CAAC"}