mote-core 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/cache.d.ts +14 -0
- package/dist/cache.js +43 -0
- package/dist/cache.js.map +1 -0
- package/dist/connectors/qmd.d.ts +61 -0
- package/dist/connectors/qmd.js +124 -0
- package/dist/connectors/qmd.js.map +1 -0
- package/dist/connectors/types.d.ts +27 -0
- package/dist/connectors/types.js +2 -0
- package/dist/connectors/types.js.map +1 -0
- package/dist/contracts.d.ts +667 -0
- package/dist/contracts.js +229 -0
- package/dist/contracts.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +51 -0
- package/dist/kernel.js +421 -0
- package/dist/kernel.js.map +1 -0
- package/dist/registry.d.ts +271 -0
- package/dist/registry.js +33 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime/engine.d.ts +24 -0
- package/dist/runtime/engine.js +151 -0
- package/dist/runtime/engine.js.map +1 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# mote-core
|
|
2
|
+
|
|
3
|
+
Platform-neutral `mote` kernel package.
|
|
4
|
+
|
|
5
|
+
## Contents
|
|
6
|
+
|
|
7
|
+
- contracts and schemas
|
|
8
|
+
- connector interfaces
|
|
9
|
+
- registry and cache primitives
|
|
10
|
+
- kernel orchestration
|
|
11
|
+
- deterministic insight runtime
|
|
12
|
+
|
|
13
|
+
This package intentionally excludes Node-specific transports, database drivers, filesystem adapters, and CLI/MCP runtime code.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install mote-core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Import `mote-core` when you need the shared kernel contracts, registries, connector interfaces, or deterministic insight runtime in another host package.
|
|
24
|
+
|
|
25
|
+
## Publishing Notes
|
|
26
|
+
|
|
27
|
+
- `mote-core` is intended to be published before `mote-node` and `mote-desktop`.
|
|
28
|
+
- Runtime-specific integrations belong in sibling packages, not here.
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CacheStore {
|
|
2
|
+
get<T>(key: string): T | undefined;
|
|
3
|
+
set<T>(key: string, value: T, ttlMs?: number): void;
|
|
4
|
+
delete(key: string): void;
|
|
5
|
+
clear(): void;
|
|
6
|
+
}
|
|
7
|
+
export declare class InMemoryCacheStore implements CacheStore {
|
|
8
|
+
private readonly entries;
|
|
9
|
+
get<T>(key: string): T | undefined;
|
|
10
|
+
set<T>(key: string, value: T, ttlMs?: number): void;
|
|
11
|
+
delete(key: string): void;
|
|
12
|
+
clear(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createScopedCacheKey(namespace: string, parts: Record<string, unknown>): string;
|
package/dist/cache.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export class InMemoryCacheStore {
|
|
2
|
+
entries = new Map();
|
|
3
|
+
get(key) {
|
|
4
|
+
const entry = this.entries.get(key);
|
|
5
|
+
if (!entry) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
if (entry.expiresAt && entry.expiresAt <= Date.now()) {
|
|
9
|
+
this.entries.delete(key);
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
return entry.value;
|
|
13
|
+
}
|
|
14
|
+
set(key, value, ttlMs) {
|
|
15
|
+
const entry = { value };
|
|
16
|
+
if (ttlMs) {
|
|
17
|
+
entry.expiresAt = Date.now() + ttlMs;
|
|
18
|
+
}
|
|
19
|
+
this.entries.set(key, entry);
|
|
20
|
+
}
|
|
21
|
+
delete(key) {
|
|
22
|
+
this.entries.delete(key);
|
|
23
|
+
}
|
|
24
|
+
clear() {
|
|
25
|
+
this.entries.clear();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export function createScopedCacheKey(namespace, parts) {
|
|
29
|
+
return `${namespace}:${stableStringify(parts)}`;
|
|
30
|
+
}
|
|
31
|
+
function stableStringify(value) {
|
|
32
|
+
if (Array.isArray(value)) {
|
|
33
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
34
|
+
}
|
|
35
|
+
if (value && typeof value === "object") {
|
|
36
|
+
const entries = Object.entries(value)
|
|
37
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
38
|
+
.map(([key, item]) => `${JSON.stringify(key)}:${stableStringify(item)}`);
|
|
39
|
+
return `{${entries.join(",")}}`;
|
|
40
|
+
}
|
|
41
|
+
return JSON.stringify(value);
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,kBAAkB;IACZ,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEzD,GAAG,CAAI,GAAW;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,IAAI,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;YACrD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,KAAK,CAAC,KAAU,CAAC;IAC1B,CAAC;IAED,GAAG,CAAI,GAAW,EAAE,KAAQ,EAAE,KAAc;QAC1C,MAAM,KAAK,GAAe,EAAE,KAAK,EAAE,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG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,61 @@
|
|
|
1
|
+
import { type ConnectorHealth, type ExecutionContext, type KnowledgeCollection, type KnowledgeDocument, type KnowledgeQueryRequest, type KnowledgeQueryResult } from "../contracts.js";
|
|
2
|
+
import { type CacheStore } from "../cache.js";
|
|
3
|
+
import type { KnowledgeDocumentBatchRequest, KnowledgeSourceAdapter } from "./types.js";
|
|
4
|
+
export interface QmdQueryHit {
|
|
5
|
+
connectorId?: string;
|
|
6
|
+
collection?: string;
|
|
7
|
+
path: string;
|
|
8
|
+
docId?: string;
|
|
9
|
+
title?: string;
|
|
10
|
+
snippet?: string;
|
|
11
|
+
score?: number;
|
|
12
|
+
context?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface QmdClient {
|
|
15
|
+
getStatus(): Promise<{
|
|
16
|
+
totalDocuments: number;
|
|
17
|
+
needsEmbedding: number;
|
|
18
|
+
hasVectorIndex: boolean;
|
|
19
|
+
collections: Array<{
|
|
20
|
+
name: string;
|
|
21
|
+
path: string | null;
|
|
22
|
+
pattern: string | null;
|
|
23
|
+
documents: number;
|
|
24
|
+
lastUpdated: string | null;
|
|
25
|
+
}>;
|
|
26
|
+
}>;
|
|
27
|
+
query(request: KnowledgeQueryRequest): Promise<QmdQueryHit[]>;
|
|
28
|
+
get(ref: string, opts?: {
|
|
29
|
+
fromLine?: number;
|
|
30
|
+
maxLines?: number;
|
|
31
|
+
}): Promise<KnowledgeDocument | null>;
|
|
32
|
+
multiGet(request: KnowledgeDocumentBatchRequest): Promise<KnowledgeDocument[]>;
|
|
33
|
+
}
|
|
34
|
+
export interface QmdKnowledgeAdapterConfig {
|
|
35
|
+
id?: string;
|
|
36
|
+
label?: string;
|
|
37
|
+
cache?: CacheStore;
|
|
38
|
+
client?: QmdClient;
|
|
39
|
+
}
|
|
40
|
+
export declare class QmdKnowledgeAdapter implements KnowledgeSourceAdapter {
|
|
41
|
+
readonly descriptor: {
|
|
42
|
+
id: string;
|
|
43
|
+
kind: "structured" | "knowledge";
|
|
44
|
+
label: string;
|
|
45
|
+
capabilities: string[];
|
|
46
|
+
cacheNamespace: string;
|
|
47
|
+
authModes: ("tenant_user" | "system_admin" | "service")[];
|
|
48
|
+
};
|
|
49
|
+
private readonly cache;
|
|
50
|
+
private readonly client;
|
|
51
|
+
constructor(config?: QmdKnowledgeAdapterConfig);
|
|
52
|
+
getHealth(_context: ExecutionContext): Promise<ConnectorHealth>;
|
|
53
|
+
query(requestInput: KnowledgeQueryRequest, context: ExecutionContext): Promise<KnowledgeQueryResult>;
|
|
54
|
+
getDocument(ref: string, _context: ExecutionContext, opts?: {
|
|
55
|
+
fromLine?: number;
|
|
56
|
+
maxLines?: number;
|
|
57
|
+
}): Promise<KnowledgeDocument | null>;
|
|
58
|
+
getDocuments(request: KnowledgeDocumentBatchRequest, _context: ExecutionContext): Promise<KnowledgeDocument[]>;
|
|
59
|
+
getCollections(_context: ExecutionContext): Promise<KnowledgeCollection[]>;
|
|
60
|
+
}
|
|
61
|
+
export declare function createUnavailableQmdClient(): QmdClient;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { connectorDescriptorSchema, connectorHealthSchema, knowledgeCollectionSchema, knowledgeDocumentSchema, knowledgeQueryRequestSchema, knowledgeQueryResultSchema } from "../contracts.js";
|
|
2
|
+
import { createScopedCacheKey, InMemoryCacheStore } from "../cache.js";
|
|
3
|
+
export class QmdKnowledgeAdapter {
|
|
4
|
+
descriptor;
|
|
5
|
+
cache;
|
|
6
|
+
client;
|
|
7
|
+
constructor(config = {}) {
|
|
8
|
+
this.cache = config.cache ?? new InMemoryCacheStore();
|
|
9
|
+
this.client = config.client ?? createUnavailableQmdClient();
|
|
10
|
+
this.descriptor = connectorDescriptorSchema.parse({
|
|
11
|
+
id: config.id ?? "qmd",
|
|
12
|
+
kind: "knowledge",
|
|
13
|
+
label: config.label ?? "QMD",
|
|
14
|
+
capabilities: ["hybrid_search", "lex_search", "get_document", "multi_get", "index_status"],
|
|
15
|
+
cacheNamespace: "knowledge.qmd",
|
|
16
|
+
authModes: ["tenant_user", "system_admin", "service"]
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async getHealth(_context) {
|
|
20
|
+
try {
|
|
21
|
+
const status = await this.client.getStatus();
|
|
22
|
+
return connectorHealthSchema.parse({
|
|
23
|
+
status: status.totalDocuments > 0 ? "ok" : "degraded",
|
|
24
|
+
checkedAt: new Date().toISOString(),
|
|
25
|
+
message: `${status.totalDocuments} indexed documents`,
|
|
26
|
+
details: {
|
|
27
|
+
hasVectorIndex: status.hasVectorIndex,
|
|
28
|
+
needsEmbedding: status.needsEmbedding
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return connectorHealthSchema.parse({
|
|
34
|
+
status: "unavailable",
|
|
35
|
+
checkedAt: new Date().toISOString(),
|
|
36
|
+
message: error instanceof Error ? error.message : "QMD unavailable"
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async query(requestInput, context) {
|
|
41
|
+
const request = knowledgeQueryRequestSchema.parse(requestInput);
|
|
42
|
+
const cacheKey = createScopedCacheKey(`${this.descriptor.cacheNamespace}.query`, {
|
|
43
|
+
connectorId: this.descriptor.id,
|
|
44
|
+
tenantId: context.tenantId,
|
|
45
|
+
accessMode: context.accessMode,
|
|
46
|
+
request
|
|
47
|
+
});
|
|
48
|
+
const cached = this.cache.get(cacheKey);
|
|
49
|
+
if (cached) {
|
|
50
|
+
return cached;
|
|
51
|
+
}
|
|
52
|
+
const hits = await this.client.query(request);
|
|
53
|
+
const parsed = knowledgeQueryResultSchema.parse({
|
|
54
|
+
connectorId: this.descriptor.id,
|
|
55
|
+
hits: hits.map((hit) => normalizeHit(this.descriptor.id, hit)),
|
|
56
|
+
totalHits: hits.length,
|
|
57
|
+
provenance: hits.slice(0, 3).map((hit) => ({
|
|
58
|
+
kind: "knowledge_doc",
|
|
59
|
+
connectorId: this.descriptor.id,
|
|
60
|
+
path: hit.path,
|
|
61
|
+
docId: hit.docId,
|
|
62
|
+
snippet: hit.snippet,
|
|
63
|
+
label: hit.title ?? hit.path
|
|
64
|
+
}))
|
|
65
|
+
});
|
|
66
|
+
this.cache.set(cacheKey, parsed, 30_000);
|
|
67
|
+
return parsed;
|
|
68
|
+
}
|
|
69
|
+
async getDocument(ref, _context, opts) {
|
|
70
|
+
const document = await this.client.get(ref, opts);
|
|
71
|
+
if (!document) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
return knowledgeDocumentSchema.parse({
|
|
75
|
+
...document,
|
|
76
|
+
connectorId: this.descriptor.id
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async getDocuments(request, _context) {
|
|
80
|
+
const documents = await this.client.multiGet(request);
|
|
81
|
+
return documents.map((document) => knowledgeDocumentSchema.parse({
|
|
82
|
+
...document,
|
|
83
|
+
connectorId: this.descriptor.id
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
async getCollections(_context) {
|
|
87
|
+
const status = await this.client.getStatus();
|
|
88
|
+
return status.collections.map((collection) => knowledgeCollectionSchema.parse(collection));
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function normalizeHit(connectorId, hit) {
|
|
92
|
+
return {
|
|
93
|
+
connectorId,
|
|
94
|
+
collection: hit.collection,
|
|
95
|
+
path: hit.path,
|
|
96
|
+
docId: hit.docId,
|
|
97
|
+
title: hit.title,
|
|
98
|
+
snippet: hit.snippet,
|
|
99
|
+
score: hit.score,
|
|
100
|
+
context: hit.context
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export function createUnavailableQmdClient() {
|
|
104
|
+
return {
|
|
105
|
+
async getStatus() {
|
|
106
|
+
return {
|
|
107
|
+
totalDocuments: 0,
|
|
108
|
+
needsEmbedding: 0,
|
|
109
|
+
hasVectorIndex: false,
|
|
110
|
+
collections: []
|
|
111
|
+
};
|
|
112
|
+
},
|
|
113
|
+
async query() {
|
|
114
|
+
throw new Error("QMD client is not configured");
|
|
115
|
+
},
|
|
116
|
+
async get() {
|
|
117
|
+
throw new Error("QMD client is not configured");
|
|
118
|
+
},
|
|
119
|
+
async multiGet() {
|
|
120
|
+
throw new Error("QMD client is not configured");
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=qmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qmd.js","sourceRoot":"","sources":["../../src/connectors/qmd.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,qBAAqB,EACrB,yBAAyB,EACzB,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAQ3B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAmB,MAAM,aAAa,CAAC;AAuCxF,MAAM,OAAO,mBAAmB;IACrB,UAAU,CAAC;IACH,KAAK,CAAa;IAClB,MAAM,CAAY;IAEnC,YAAY,SAAoC,EAAE;QAChD,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,kBAAkB,EAAE,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,0BAA0B,EAAE,CAAC;QAC5D,IAAI,CAAC,UAAU,GAAG,yBAAyB,CAAC,KAAK,CAAC;YAChD,EAAE,EAAE,MAAM,CAAC,EAAE,IAAI,KAAK;YACtB,IAAI,EAAE,WAAW;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;YAC5B,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,CAAC;YAC1F,cAAc,EAAE,eAAe;YAC/B,SAAS,EAAE,CAAC,aAAa,EAAE,cAAc,EAAE,SAAS,CAAC;SACtD,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAA0B;QACxC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAA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M,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QACD,KAAK,CAAC,QAAQ;YACZ,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ConnectorDescriptor, ConnectorHealth, ExecutionContext, KnowledgeCollection, KnowledgeDocument, KnowledgeQueryRequest, KnowledgeQueryResult, StructuredQueryRequest, StructuredQueryResult, StructuredSchemaSnapshot } from "../contracts.js";
|
|
2
|
+
export interface ConnectorBase {
|
|
3
|
+
readonly descriptor: ConnectorDescriptor;
|
|
4
|
+
getHealth(context: ExecutionContext): Promise<ConnectorHealth>;
|
|
5
|
+
}
|
|
6
|
+
export interface StructuredDataSourceAdapter extends ConnectorBase {
|
|
7
|
+
getSchemaSnapshot(context: ExecutionContext): Promise<StructuredSchemaSnapshot>;
|
|
8
|
+
executeQuery(request: StructuredQueryRequest, context: ExecutionContext): Promise<StructuredQueryResult>;
|
|
9
|
+
listSurfaces(context: ExecutionContext): Promise<string[]>;
|
|
10
|
+
}
|
|
11
|
+
export interface KnowledgeDocumentBatchRequest {
|
|
12
|
+
refs?: string[];
|
|
13
|
+
pattern?: string;
|
|
14
|
+
collections?: string[];
|
|
15
|
+
maxBytes?: number;
|
|
16
|
+
maxLines?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface KnowledgeSourceAdapter extends ConnectorBase {
|
|
19
|
+
query(request: KnowledgeQueryRequest, context: ExecutionContext): Promise<KnowledgeQueryResult>;
|
|
20
|
+
getDocument(ref: string, context: ExecutionContext, opts?: {
|
|
21
|
+
fromLine?: number;
|
|
22
|
+
maxLines?: number;
|
|
23
|
+
}): Promise<KnowledgeDocument | null>;
|
|
24
|
+
getDocuments(request: KnowledgeDocumentBatchRequest, context: ExecutionContext): Promise<KnowledgeDocument[]>;
|
|
25
|
+
getCollections(context: ExecutionContext): Promise<KnowledgeCollection[]>;
|
|
26
|
+
}
|
|
27
|
+
export type AnyConnector = StructuredDataSourceAdapter | KnowledgeSourceAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/connectors/types.ts"],"names":[],"mappings":""}
|