@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,136 @@
1
+ import * as Schema from 'effect/Schema';
2
+ import * as Fact from './Fact.ts';
3
+ /** What a {@link Facts} query selects; every field set must hold. */
4
+ export declare const FactQuery: Schema.Struct<{
5
+ /** Entity in the subject position. */
6
+ readonly subjectEntity: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>;
7
+ /** Entity in the subject or object position. */
8
+ readonly entity: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>;
9
+ /** Predicate IRI, or a surface form resolved through the memory's ontology. */
10
+ readonly predicate: Schema.optional<Schema.String>;
11
+ /** The item the facts were read from. */
12
+ readonly source: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">>;
13
+ /** Inclusive lower bound on factuality confidence. */
14
+ readonly minConfidence: Schema.optional<Schema.Number>;
15
+ }>;
16
+ export interface FactQuery extends Schema.Schema.Type<typeof FactQuery> {
17
+ }
18
+ /** One RDF term a SPARQL solution binds; plain data, so rows cross a wire as JSON. */
19
+ export declare const SparqlTerm: Schema.Union<readonly [Schema.Struct<{
20
+ readonly termType: Schema.Literal<"NamedNode">;
21
+ readonly value: Schema.String;
22
+ }>, Schema.Struct<{
23
+ readonly termType: Schema.Literal<"BlankNode">;
24
+ readonly value: Schema.String;
25
+ }>, Schema.Struct<{
26
+ readonly termType: Schema.Literal<"Literal">;
27
+ readonly value: Schema.String;
28
+ readonly datatype: Schema.optional<Schema.String>;
29
+ readonly language: Schema.optional<Schema.String>;
30
+ }>]>;
31
+ export type SparqlTerm = Schema.Schema.Type<typeof SparqlTerm>;
32
+ /** One SPARQL solution: each bound variable (named without `?`) to its term; an unbound variable is absent. */
33
+ export declare const SparqlRow: Schema.$Record<Schema.String, Schema.Union<readonly [Schema.Struct<{
34
+ readonly termType: Schema.Literal<"NamedNode">;
35
+ readonly value: Schema.String;
36
+ }>, Schema.Struct<{
37
+ readonly termType: Schema.Literal<"BlankNode">;
38
+ readonly value: Schema.String;
39
+ }>, Schema.Struct<{
40
+ readonly termType: Schema.Literal<"Literal">;
41
+ readonly value: Schema.String;
42
+ readonly datatype: Schema.optional<Schema.String>;
43
+ readonly language: Schema.optional<Schema.String>;
44
+ }>]>>;
45
+ export type SparqlRow = Schema.Schema.Type<typeof SparqlRow>;
46
+ /** Facts whose statement matches a pattern. Answered without SPARQL on every implementation. */
47
+ export declare const Facts: Schema.TaggedStruct<"facts", {
48
+ readonly pattern: Schema.Struct<{
49
+ /** Entity in the subject position. */
50
+ readonly subjectEntity: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>;
51
+ /** Entity in the subject or object position. */
52
+ readonly entity: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>;
53
+ /** Predicate IRI, or a surface form resolved through the memory's ontology. */
54
+ readonly predicate: Schema.optional<Schema.String>;
55
+ /** The item the facts were read from. */
56
+ readonly source: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">>;
57
+ /** Inclusive lower bound on factuality confidence. */
58
+ readonly minConfidence: Schema.optional<Schema.Number>;
59
+ }>;
60
+ }>;
61
+ export interface Facts extends Schema.Schema.Type<typeof Facts> {
62
+ }
63
+ /** Every fact in the named graphs a SPARQL `SELECT ?g` binds. */
64
+ export declare const Graphs: Schema.TaggedStruct<"graphs", {
65
+ readonly sparql: Schema.String;
66
+ }>;
67
+ export interface Graphs extends Schema.Schema.Type<typeof Graphs> {
68
+ }
69
+ /** Any SPARQL `SELECT`, its solutions returned as written. */
70
+ export declare const Sparql: Schema.TaggedStruct<"sparql", {
71
+ readonly sparql: Schema.String;
72
+ }>;
73
+ export interface Sparql extends Schema.Schema.Type<typeof Sparql> {
74
+ }
75
+ /** The predicates the memory knows. */
76
+ export declare const Predicates: Schema.TaggedStruct<"predicates", {}>;
77
+ export interface Predicates extends Schema.Schema.Type<typeof Predicates> {
78
+ }
79
+ /** How far a source has been read: the `through` of its read cursor. */
80
+ export declare const Cursor: Schema.TaggedStruct<"cursor", {
81
+ readonly source: Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">;
82
+ }>;
83
+ export interface Cursor extends Schema.Schema.Type<typeof Cursor> {
84
+ }
85
+ /** Any query kind. */
86
+ export declare const Any: Schema.Union<readonly [Schema.TaggedStruct<"facts", {
87
+ readonly pattern: Schema.Struct<{
88
+ /** Entity in the subject position. */
89
+ readonly subjectEntity: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>;
90
+ /** Entity in the subject or object position. */
91
+ readonly entity: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>;
92
+ /** Predicate IRI, or a surface form resolved through the memory's ontology. */
93
+ readonly predicate: Schema.optional<Schema.String>;
94
+ /** The item the facts were read from. */
95
+ readonly source: Schema.optional<Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">>;
96
+ /** Inclusive lower bound on factuality confidence. */
97
+ readonly minConfidence: Schema.optional<Schema.Number>;
98
+ }>;
99
+ }>, Schema.TaggedStruct<"graphs", {
100
+ readonly sparql: Schema.String;
101
+ }>, Schema.TaggedStruct<"sparql", {
102
+ readonly sparql: Schema.String;
103
+ }>, Schema.TaggedStruct<"predicates", {}>, Schema.TaggedStruct<"cursor", {
104
+ readonly source: Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">;
105
+ }>]>;
106
+ export type Any = Schema.Schema.Type<typeof Any>;
107
+ export type Tag = Any['_tag'];
108
+ /** What each kind answers. */
109
+ export interface Results {
110
+ readonly facts: readonly Fact.Fact[];
111
+ readonly graphs: readonly Fact.Fact[];
112
+ readonly sparql: readonly SparqlRow[];
113
+ readonly predicates: readonly Fact.PredicateEntry[];
114
+ readonly cursor: string | undefined;
115
+ }
116
+ /** The schema of each kind's answer, so a remote client decodes an answer by the query's `_tag`. */
117
+ export declare const results: {
118
+ readonly [K in Tag]: Schema.Codec<Results[K], unknown>;
119
+ };
120
+ /** The schema of a kind's answer. */
121
+ export declare const resultSchema: <K extends Tag>(tag: K) => Schema.Codec<Results[K], unknown>;
122
+ /** The schema of a query's answer. */
123
+ export declare const resultOf: <Q extends Any>(query: Q) => Schema.Codec<Results[Q['_tag']], unknown>;
124
+ /** What a query answers. */
125
+ export type ResultOf<Q extends Any> = Results[Q['_tag']];
126
+ /** Facts whose statement matches the pattern; answers `Fact[]`. */
127
+ export declare const facts: (pattern?: FactQuery) => Facts;
128
+ /** Every fact in the graphs a `SELECT ?g` binds; answers `Fact[]`. */
129
+ export declare const graphs: (sparql: string) => Graphs;
130
+ /** A SPARQL `SELECT`'s solutions; answers `SparqlRow[]`. */
131
+ export declare const sparql: (sparql: string) => Sparql;
132
+ /** The known predicates; answers `PredicateEntry[]`. */
133
+ export declare const predicates: () => Predicates;
134
+ /** A source's read cursor; answers `string | undefined`. */
135
+ export declare const cursor: (source: Fact.SourceUri) => Cursor;
136
+ //# sourceMappingURL=MemoryQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryQuery.d.ts","sourceRoot":"","sources":["../../../src/MemoryQuery.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,qEAAqE;AACrE,eAAO,MAAM,SAAS;IACpB,sCAAsC;;IAEtC,gDAAgD;;IAEhD,+EAA+E;;IAE/E,yCAAyC;;IAEzC,sDAAsD;;EAEtD,CAAC;AACH,MAAM,WAAW,SAAU,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC;CAAG;AAE1E,sFAAsF;AACtF,eAAO,MAAM,UAAU;;;;;;;;;;;IASrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAE/D,+GAA+G;AAC/G,eAAO,MAAM,SAAS;;;;;;;;;;;KAA2C,CAAC;AAClE,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;AAM7D,g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1
+ export {};
2
+ //# sourceMappingURL=MemoryQuery.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryQuery.test.d.ts","sourceRoot":"","sources":["../../../src/MemoryQuery.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ import * as Context from 'effect/Context';
2
+ import type * as Effect from 'effect/Effect';
3
+ import * as Schema from 'effect/Schema';
4
+ import * as Fact from './Fact.ts';
5
+ import type * as MemoryError from './MemoryError.ts';
6
+ import type * as MemoryQuery from './MemoryQuery.ts';
7
+ import type * as Subscription from './Subscription.ts';
8
+ /** How far a source has been read into facts. */
9
+ export declare const ReadCursor: Schema.Struct<{
10
+ /** The source read (a chat, a feed, a mailbox). */
11
+ readonly source: Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">;
12
+ /** URI or hash of the last item read; the next read starts after it. */
13
+ readonly through: Schema.String;
14
+ }>;
15
+ export interface ReadCursor extends Schema.Schema.Type<typeof ReadCursor> {
16
+ }
17
+ export declare const PutOptions: Schema.Struct<{
18
+ /** Speakers whose facts are stored but wake nothing on their own. */
19
+ readonly quiet: Schema.optional<Schema.$Array<Schema.brand<Schema.String, "@dxos/echo-memory/EntityKey">>>;
20
+ /** Moved in the same write as the facts. */
21
+ readonly read: Schema.optional<Schema.Struct<{
22
+ /** The source read (a chat, a feed, a mailbox). */
23
+ readonly source: Schema.brand<Schema.String, "@dxos/echo-memory/SourceUri">;
24
+ /** URI or hash of the last item read; the next read starts after it. */
25
+ readonly through: Schema.String;
26
+ }>>;
27
+ }>;
28
+ export interface PutOptions extends Schema.Schema.Type<typeof PutOptions> {
29
+ }
30
+ /**
31
+ * The memory of one space, in two halves over one store.
32
+ *
33
+ * - Knowledge base: {@link Service.put} stores facts and {@link Service.query} reads them back.
34
+ * - Event base: a subscription carries goal rules; whenever put facts or the clock wake them, an event is queued
35
+ * in that subscription's own outbox, which its consumer drains with {@link Service.take} and {@link Service.ack}.
36
+ *
37
+ * Time-driven rules are evaluated by the implementation on its own; the interface has no op for the clock.
38
+ */
39
+ export interface Service {
40
+ /**
41
+ * Stores facts (a repeated put is idempotent), moves `options.read` in the same write, and returns how many
42
+ * events the write queued. A put with no facts only moves the cursor.
43
+ */
44
+ readonly put: (facts: readonly Fact.Fact[], options?: PutOptions) => Effect.Effect<number, MemoryError.MemoryError>;
45
+ /** The only read of the knowledge base; the query's kind fixes what it answers. */
46
+ readonly query: <Q extends MemoryQuery.Any>(query: Q) => Effect.Effect<MemoryQuery.ResultOf<Q>, MemoryError.MemoryError>;
47
+ /**
48
+ * Forgets the facts, read cursors and queued events, and restores the seed vocabulary; subscriptions stay, with
49
+ * their rule state started over.
50
+ */
51
+ readonly reset: () => Effect.Effect<void, MemoryError.MemoryError>;
52
+ /**
53
+ * Adds a subscription, or replaces the one with its id. False, adding nothing, when the space holds
54
+ * `MAX_SUBSCRIPTIONS` others; fails when its rules do not compile.
55
+ */
56
+ readonly subscribe: (subscription: Subscription.Subscription) => Effect.Effect<boolean, MemoryError.MemoryError>;
57
+ /** Subscriptions oldest first: all, or those the owner holds. */
58
+ readonly subscriptions: (owner?: Fact.EntityKey) => Effect.Effect<Subscription.Subscription[], MemoryError.MemoryError>;
59
+ /** Removes a subscription and its outbox; false when it was already gone. */
60
+ readonly unsubscribe: (id: Subscription.SubscriptionId) => Effect.Effect<boolean, MemoryError.MemoryError>;
61
+ /** The subscription's unacknowledged events, oldest first; empty for an unknown subscription. */
62
+ readonly take: (id: Subscription.SubscriptionId) => Effect.Effect<Subscription.MemoryEvent[], MemoryError.MemoryError>;
63
+ /** Removes the events from the outbox; unknown ids are ignored. */
64
+ readonly ack: (id: Subscription.SubscriptionId, events: readonly Subscription.MemoryEventId[]) => Effect.Effect<void, MemoryError.MemoryError>;
65
+ }
66
+ declare const MemoryService_base: Context.ServiceClass<MemoryService, "@dxos/echo-memory/MemoryService", Service>;
67
+ export declare class MemoryService extends MemoryService_base {
68
+ }
69
+ /** Re-exported so callers importing this module as a namespace avoid `MemoryService.MemoryService.key`. */
70
+ export declare const key: "@dxos/echo-memory/MemoryService";
71
+ export {};
72
+ //# sourceMappingURL=MemoryService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryService.d.ts","sourceRoot":"","sources":["../../../src/MemoryService.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,KAAK,KAAK,WAAW,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,KAAK,WAAW,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAEvD,iDAAiD;AACjD,eAAO,MAAM,UAAU;IACrB,mDAAmD;;IAEnD,wEAAwE;;EAExE,CAAC;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC;CAAG;AAE5E,eAAO,MAAM,UAAU;IACrB,qEAAqE;;IAErE,4CAA4C;;QAV5C,mDAAmD;;QAEnD,wEAAwE;;;EAUxE,CAAC;AACH,MAAM,WAAW,UAAW,SAAQ,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC;CAAG;AAE5E;;;;;;;;GAQG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,SAAS,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;IAEpH,mFAAmF;IACnF,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,EACxC,KAAK,EAAE,CAAC,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ts';
2
+ /**
3
+ * A predicate the brain knows: its IRI, the shorthand rules use, the surface forms that map onto it, and the RDFS /
4
+ * OWL / SKOS metadata it is described with in the ontology graph.
5
+ */
6
+ export type Entry = {
7
+ readonly iri: string;
8
+ /** Lowercase identifier rules may use as shorthand (`works_on(dima, X)`); `sx:shorthand`. */
9
+ readonly name: string;
10
+ /** `rdfs:label`. */
11
+ readonly label: string;
12
+ /** Other surface forms that name it; `skos:altLabel`. */
13
+ readonly synonyms?: ReadonlyArray<string>;
14
+ /** `rdfs:comment`. */
15
+ readonly description?: string;
16
+ /** IRI of the class the subject belongs to; `rdfs:domain`. */
17
+ readonly domain?: string;
18
+ /** IRI of the class the object belongs to; `rdfs:range`. */
19
+ readonly range?: string;
20
+ /** IRI of the predicate that states the same relation in the other direction; `owl:inverseOf`. */
21
+ readonly inverse?: string;
22
+ /**
23
+ * IRIs of predicates that mean the same; `owl:equivalentProperty`. A query for this predicate matches statements
24
+ * made with any of them, which is how predicates are merged without rewriting stored statements.
25
+ */
26
+ readonly equivalents?: ReadonlyArray<string>;
27
+ /** The vocabulary that defines it (`https://schema.org/`, a brain namespace); `rdfs:isDefinedBy`. */
28
+ readonly definedBy?: string;
29
+ /** When an extractor minted it; `dcterms:created`. */
30
+ readonly created?: string;
31
+ /** What minted it (an extractor id and model); `dcterms:creator`. */
32
+ readonly creator?: string;
33
+ /** A quote it was minted from; `skos:example`. */
34
+ readonly example?: string;
35
+ /** The predicate it was merged into; `dcterms:isReplacedBy`, with `owl:deprecated true`. */
36
+ readonly replacedBy?: string;
37
+ };
38
+ /**
39
+ * The lookup key for a surface predicate: pipeline-rdf's relation key (case, auxiliaries and head-verb
40
+ * inflection collapse) with words joined by `_`, so `Will-Work-On`, `working on` and `works_on` compare equal.
41
+ */
42
+ export declare const key: (surface: string) => string;
43
+ /**
44
+ * The shorthand a surface predicate is minted under: {@link key} without stemming, since the stem is a matching key
45
+ * nobody reads (`changed` keys to `chang`) while the shorthand names the predicate in its IRI and in rules.
46
+ */
47
+ export declare const nameFor: (surface: string) => string;
48
+ /** The IRI a predicate shorthand mints to in a namespace, e.g. `works_on` → `dx:worksOn`. */
49
+ export declare const iriFor: (name: string, namespace?: string) => string;
50
+ /** An entry for a predicate shorthand; the IRI defaults to the `dx:` vocabulary. */
51
+ export declare const entry: (name: string, options?: Omit<Entry, 'iri' | 'name' | 'label'> & {
52
+ iri?: string;
53
+ label?: string;
54
+ }) => Entry;
55
+ export type OntologyOptions = {
56
+ /** Where predicates the ontology does not know are minted: the brain's own namespace. */
57
+ readonly namespace?: string;
58
+ };
59
+ /**
60
+ * An extensible set of predicates. A surface form the ontology does not know mints a predicate in the ontology's
61
+ * namespace (its brain's) from its relation key, so two documents that phrase a relation the same way still share
62
+ * one predicate, and a predicate one brain invented never poses as a shared vocabulary term.
63
+ */
64
+ export declare class Ontology {
65
+ #private;
66
+ readonly entries: ReadonlyArray<Entry>;
67
+ readonly namespace: string;
68
+ /** @throws Error when two entries claim one surface form or one IRI. */
69
+ constructor(entries: ReadonlyArray<Entry>, { namespace }?: OntologyOptions);
70
+ /** The entry a surface form names, if the ontology knows it. */
71
+ find(surface: string): Entry | undefined;
72
+ /** The entry for an IRI (its own, or one it is equivalent to), if the ontology defines it. */
73
+ get(iri: string): Entry | undefined;
74
+ /** The entry an IRI stands for: a merged-away predicate's survivor, else its own entry. */
75
+ canonical(iri: string): Entry | undefined;
76
+ /** The IRIs a query for this predicate matches: its own and every equivalent, either way round. */
77
+ equivalents(iri: string): Set<string>;
78
+ /** The entry for a surface form; one the ontology does not know is minted in its namespace, labelled with the form. */
79
+ resolve(surface: string): Entry;
80
+ /** A new ontology with these entries added; an entry for a known IRI replaces it. */
81
+ extend(entries: ReadonlyArray<Entry>): Ontology;
82
+ /**
83
+ * A new ontology with the predicates a brain has learned added: unlike {@link extend}, an entry this ontology
84
+ * already defines, or whose surface form it already maps, is skipped rather than rejected, since a store may hold
85
+ * predicates minted before the seed vocabulary named them.
86
+ */
87
+ include(entries: ReadonlyArray<Entry>): Ontology;
88
+ /** The same predicates, minting new ones in another namespace. */
89
+ withNamespace(namespace: string): Ontology;
90
+ /**
91
+ * Merges one predicate into another: the survivor gains the other's IRI as an equivalent and its surface forms as
92
+ * synonyms, and the other is kept, deprecated, so stored statements made with it still read and match.
93
+ * @throws Error when either IRI is not an entry of this ontology.
94
+ */
95
+ merge(from: string, into: string): Ontology;
96
+ }
97
+ /** Creates an ontology. */
98
+ export declare const make: (entries: ReadonlyArray<Entry>, options?: OntologyOptions) => Ontology;
99
+ /** The label an IRI reads as when no ontology defines it: its local name, split into words. */
100
+ export declare const labelFromIri: (iri: string) => string;
101
+ /** The entry as quads in the ontology graph. */
102
+ export declare const toQuads: (entry: Entry) => Rdf.Quad[];
103
+ /**
104
+ * The entries described in the ontology graph, one per subject; the inverse of {@link toQuads}. A predicate known
105
+ * only by its label (as facts store a minted one) reads with the shorthand its label keys to. Multi-valued fields
106
+ * keep their first value where an entry holds one value.
107
+ */
108
+ export declare const fromQuads: (quads: readonly Rdf.Quad[]) => Entry[];
109
+ /** Every entry of the ontology as quads in the ontology graph. */
110
+ export declare const ontologyQuads: (ontology: Ontology) => Rdf.Quad[];
111
+ /** The starter predicates: people and organizations, plus the relations agent goals are written against. */
112
+ export declare const DEFAULT_ENTRIES: ReadonlyArray<Entry>;
113
+ /** The starter ontology. */
114
+ export declare const DEFAULT: Ontology;
115
+ //# sourceMappingURL=Ontology.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ontology.d.ts","sourceRoot":"","sources":["../../../src/Ontology.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAKhC;;;GAGG;AACH,MAAM,MAAM,KAAK,GAAG;IAClB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oBAAoB;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB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,CAAC;AASnB,gDAAgD;AAChD,eAAO,MAAM,OAAO,UAAW,KAAK,KAAG,GAAG,CAAC,IAAI,EAyC9C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAW,SAAS,GAAG,CAAC,IAAI,EAAE,KAAG,KAAK,EA6C3D,CAAC;AAEF,kEAAkE;AAClE,eAAO,MAAM,aAAa,aAAc,QAAQ,KAAG,GAAG,CAAC,IAAI,EAAuC,CAAC;AAgBnG,4GAA4G;AAC5G,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,KAAK,CAoMhD,CAAC;AAEF,4BAA4B;AAC5B,eAAO,MAAM,OAAO,EAAE,QAAgC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Ontology.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ontology.test.d.ts","sourceRoot":"","sources":["../../../src/Ontology.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,103 @@
1
+ import * as Effect from 'effect/Effect';
2
+ import * as Schema from 'effect/Schema';
3
+ import * as Rdf from './Rdf.ts';
4
+ /** One source a pipeline read (a Discord channel or thread): how far it read and what it found there. */
5
+ export declare const Source: Schema.Struct<{
6
+ readonly id: Schema.String;
7
+ readonly label: Schema.optional<Schema.String>;
8
+ /** Where reading stopped, as the source names its items (a Discord message id). */
9
+ readonly cursor: Schema.optional<Schema.String>;
10
+ readonly firstItemAt: Schema.optional<Schema.String>;
11
+ readonly lastItemAt: Schema.optional<Schema.String>;
12
+ readonly items: Schema.Number;
13
+ readonly status: Schema.optional<Schema.String>;
14
+ }>;
15
+ export type Source = Schema.Schema.Type<typeof Source>;
16
+ /** What one stage spent on one model. */
17
+ export declare const ModelUsage: Schema.Struct<{
18
+ readonly model: Schema.String;
19
+ readonly calls: Schema.Number;
20
+ readonly inputTokens: Schema.Number;
21
+ readonly outputTokens: Schema.Number;
22
+ readonly cacheReadTokens: Schema.Number;
23
+ readonly cacheWriteTokens: Schema.Number;
24
+ /** At catalog prices; absent for a model the catalog does not price. */
25
+ readonly costUsd: Schema.optional<Schema.Number>;
26
+ }>;
27
+ export type ModelUsage = Schema.Schema.Type<typeof ModelUsage>;
28
+ export declare const Stage: Schema.Struct<{
29
+ readonly id: Schema.String;
30
+ readonly label: Schema.String;
31
+ /** Position in the pipeline, from 0. */
32
+ readonly order: Schema.Number;
33
+ /** Items the stage passed to the next one. */
34
+ readonly items: Schema.optional<Schema.Number>;
35
+ readonly startedAt: Schema.optional<Schema.String>;
36
+ readonly endedAt: Schema.optional<Schema.String>;
37
+ readonly models: Schema.$Array<Schema.Struct<{
38
+ readonly model: Schema.String;
39
+ readonly calls: Schema.Number;
40
+ readonly inputTokens: Schema.Number;
41
+ readonly outputTokens: Schema.Number;
42
+ readonly cacheReadTokens: Schema.Number;
43
+ readonly cacheWriteTokens: Schema.Number;
44
+ /** At catalog prices; absent for a model the catalog does not price. */
45
+ readonly costUsd: Schema.optional<Schema.Number>;
46
+ }>>;
47
+ }>;
48
+ export type Stage = Schema.Schema.Type<typeof Stage>;
49
+ /**
50
+ * What a fact-producing run did, kept in the fact store beside the facts it produced: the sources it read and how
51
+ * far, its stages in order, the models each called and at what cost, how long it took and how many facts it wrote.
52
+ */
53
+ export declare const State: Schema.Struct<{
54
+ readonly name: Schema.String;
55
+ readonly status: Schema.String;
56
+ readonly startedAt: Schema.optional<Schema.String>;
57
+ readonly endedAt: Schema.optional<Schema.String>;
58
+ readonly sources: Schema.$Array<Schema.Struct<{
59
+ readonly id: Schema.String;
60
+ readonly label: Schema.optional<Schema.String>;
61
+ /** Where reading stopped, as the source names its items (a Discord message id). */
62
+ readonly cursor: Schema.optional<Schema.String>;
63
+ readonly firstItemAt: Schema.optional<Schema.String>;
64
+ readonly lastItemAt: Schema.optional<Schema.String>;
65
+ readonly items: Schema.Number;
66
+ readonly status: Schema.optional<Schema.String>;
67
+ }>>;
68
+ readonly stages: Schema.$Array<Schema.Struct<{
69
+ readonly id: Schema.String;
70
+ readonly label: Schema.String;
71
+ /** Position in the pipeline, from 0. */
72
+ readonly order: Schema.Number;
73
+ /** Items the stage passed to the next one. */
74
+ readonly items: Schema.optional<Schema.Number>;
75
+ readonly startedAt: Schema.optional<Schema.String>;
76
+ readonly endedAt: Schema.optional<Schema.String>;
77
+ readonly models: Schema.$Array<Schema.Struct<{
78
+ readonly model: Schema.String;
79
+ readonly calls: Schema.Number;
80
+ readonly inputTokens: Schema.Number;
81
+ readonly outputTokens: Schema.Number;
82
+ readonly cacheReadTokens: Schema.Number;
83
+ readonly cacheWriteTokens: Schema.Number;
84
+ /** At catalog prices; absent for a model the catalog does not price. */
85
+ readonly costUsd: Schema.optional<Schema.Number>;
86
+ }>>;
87
+ }>>;
88
+ readonly facts: Schema.optional<Schema.Number>;
89
+ }>;
90
+ export type State = Schema.Schema.Type<typeof State>;
91
+ /** The named graph a run's state lives in, outside every fact's graph. */
92
+ export declare const GRAPH = "https://dxos.org/semantic/graph/pipeline";
93
+ /** The predicate carrying the state, as one JSON literal: it is read whole, never queried field by field. */
94
+ export declare const STATE = "https://dxos.org/semantic#pipelineState";
95
+ /** The quad storing `state`; importing it into a store replaces nothing, so a store holds one state per run name. */
96
+ export declare const toQuads: (state: State) => Rdf.Quad[];
97
+ /** `state` as a TriG document, which a store imports beside the facts the run wrote. */
98
+ export declare const toTrig: (state: State) => Effect.Effect<string>;
99
+ /** Selects every stored run state as `?state`. */
100
+ export declare const SPARQL = "SELECT ?state WHERE { GRAPH <https://dxos.org/semantic/graph/pipeline> { ?run <https://dxos.org/semantic#pipelineState> ?state } }";
101
+ /** The run states among `values` (each a `?state` literal from {@link SPARQL}); a malformed one is skipped. */
102
+ export declare const fromValues: (values: readonly string[]) => State[];
103
+ //# sourceMappingURL=Pipeline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Pipeline.d.ts","sourceRoot":"","sources":["../../../src/Pipeline.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,eAAe,C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MAAM,UAAU,WAAY,SAAS,MAAM,EAAE,KAAG,KAAK,EACF,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Normalize a predicate to a relation key for matching: lowercase, collapse whitespace, drop leading
3
+ * auxiliary/copula/article words, and light-stem the head verb. Inflection / case / auxiliary variants
4
+ * collapse (e.g. `Works at` / `is working at` / `worked at` → `work at`). True synonyms (`at` vs `for`,
5
+ * `works` vs `employed by`) are NOT merged — that needs a controlled vocabulary (deferred). Idempotent.
6
+ */
7
+ export declare const normalize: (predicate: string, { stem: stemHead }?: {
8
+ stem?: boolean;
9
+ }) => string;
10
+ /**
11
+ * The display form of a predicate or an inverse: lowercase kebab-case (`Works at` → `works-at`, `Known by` →
12
+ * `known-by`), so labels the extractor, the ontology and a UI author each write read as one vocabulary. Unlike
13
+ * {@link normalize} it keeps the words as said (no stemming, no dropped copula), since it is shown, not matched.
14
+ * Idempotent.
15
+ */
16
+ export declare const label: (predicate: string) => string;
17
+ //# sourceMappingURL=Predicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predicate.d.ts","sourceRoot":"","sources":["../../../src/Predicate.ts"],"names":[],"mappings":"AAuDA;;;;;GAKG;AACH,eAAO,MAAM,SAAS,cAAe,MAAM,uBAA6B;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,KAAQ,MAajG,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,KAAK,cAAe,MAAM,KAAG,MAMd,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Predicate.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Predicate.test.d.ts","sourceRoot":"","sources":["../../../src/Predicate.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import type * as RdfJs from '@rdfjs/types';
2
+ export type Term = RdfJs.Term;
3
+ export type NamedNode<Iri extends string = string> = RdfJs.NamedNode<Iri>;
4
+ export type BlankNode = RdfJs.BlankNode;
5
+ export type Literal = RdfJs.Literal;
6
+ export type Variable = RdfJs.Variable;
7
+ export type DefaultGraph = RdfJs.DefaultGraph;
8
+ export type Quad = RdfJs.Quad;
9
+ export type QuadSubject = RdfJs.Quad_Subject;
10
+ export type QuadPredicate = RdfJs.Quad_Predicate;
11
+ export type QuadObject = RdfJs.Quad_Object;
12
+ export type QuadGraph = RdfJs.Quad_Graph;
13
+ export declare const XSD_STRING = "http://www.w3.org/2001/XMLSchema#string";
14
+ export declare const RDF_LANG_STRING = "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString";
15
+ export declare const RDF_DIR_LANG_STRING = "http://www.w3.org/1999/02/22-rdf-syntax-ns#dirLangString";
16
+ export declare const RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
17
+ /** A named node for an IRI. */
18
+ export declare const namedNode: <Iri extends string = string>(value: Iri) => RdfJs.NamedNode<Iri>;
19
+ /** A blank node; without a label, one unique within this process. */
20
+ export declare const blankNode: (value?: string) => RdfJs.BlankNode;
21
+ /**
22
+ * A literal: a string is a language tag (`rdf:langString`), a language with a direction a directional one
23
+ * (`rdf:dirLangString`), a named node a datatype; none makes an `xsd:string`. Language tags are compared lower-case,
24
+ * as RDF 1.1 requires.
25
+ */
26
+ export declare const literal: (value: string, languageOrDatatype?: string | RdfJs.NamedNode | RdfJs.DirectionalLanguage) => RdfJs.Literal;
27
+ /** A SPARQL variable; `value` is its name without the leading `?`. */
28
+ export declare const variable: (value: string) => RdfJs.Variable;
29
+ /** The default graph; every call returns the same term. */
30
+ export declare const defaultGraph: () => RdfJs.DefaultGraph;
31
+ /** A quad; a missing or `null` graph is the default graph, as RDF/JS requires. */
32
+ export declare const quad: (subject: RdfJs.Quad_Subject, predicate: RdfJs.Quad_Predicate, object: RdfJs.Quad_Object, graph?: RdfJs.Quad_Graph | null) => RdfJs.Quad;
33
+ //# sourceMappingURL=Rdf.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rdf.d.ts","sourceR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