@thingd/sdk 0.72.0 → 0.74.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/dist/__type-tests__/exports.d.ts +178 -0
- package/dist/__type-tests__/exports.d.ts.map +1 -0
- package/dist/__type-tests__/exports.js +87 -0
- package/dist/client/http-thing-store.d.ts +55 -0
- package/dist/client/http-thing-store.d.ts.map +1 -0
- package/dist/client/http-thing-store.js +233 -0
- package/dist/client/in-memory-thing-store.d.ts +41 -0
- package/dist/client/in-memory-thing-store.d.ts.map +1 -0
- package/dist/client/in-memory-thing-store.js +292 -0
- package/dist/client/index.d.ts +5 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +3 -0
- package/dist/client/thingd.d.ts +24 -0
- package/dist/client/thingd.d.ts.map +1 -0
- package/dist/client/thingd.js +27 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +3 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/mcp/audit.d.ts +27 -0
- package/dist/mcp/audit.d.ts.map +1 -0
- package/dist/mcp/audit.js +36 -0
- package/dist/mcp/config.d.ts +22 -0
- package/dist/mcp/config.d.ts.map +1 -0
- package/dist/mcp/config.js +52 -0
- package/dist/mcp/index.d.ts +6 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +5 -0
- package/dist/mcp/result.d.ts +3 -0
- package/dist/mcp/result.d.ts.map +1 -0
- package/dist/mcp/result.js +10 -0
- package/dist/mcp/server.d.ts +19 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +51 -0
- package/dist/mcp/tools.d.ts +10 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +1033 -0
- package/dist/memory/index.d.ts +7 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +7 -0
- package/dist/rest/helpers.d.ts +17 -0
- package/dist/rest/helpers.d.ts.map +1 -0
- package/dist/rest/helpers.js +60 -0
- package/dist/rest/index.d.ts +3 -0
- package/dist/rest/index.d.ts.map +1 -0
- package/dist/rest/index.js +2 -0
- package/dist/rest/server.d.ts +4 -0
- package/dist/rest/server.d.ts.map +1 -0
- package/dist/rest/server.js +472 -0
- package/dist/scheduler.d.ts +28 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +451 -0
- package/dist/stores/cloud-thing-store.d.ts +60 -0
- package/dist/stores/cloud-thing-store.d.ts.map +1 -0
- package/dist/stores/cloud-thing-store.js +396 -0
- package/dist/stores/in-memory-thing-store.d.ts +59 -0
- package/dist/stores/in-memory-thing-store.d.ts.map +1 -0
- package/dist/stores/in-memory-thing-store.js +709 -0
- package/dist/stores/native-thing-store.d.ts +62 -0
- package/dist/stores/native-thing-store.d.ts.map +1 -0
- package/dist/stores/native-thing-store.js +374 -0
- package/dist/thingd.d.ts +84 -0
- package/dist/thingd.d.ts.map +1 -0
- package/dist/thingd.js +236 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types.d.ts +448 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/version.d.ts +6 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/package.json +8 -7
- package/LICENSE +0 -201
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
const DEFAULT_LEASE_MS = 30_000;
|
|
2
|
+
function uid() {
|
|
3
|
+
return typeof crypto !== "undefined" && typeof crypto.randomUUID === "function"
|
|
4
|
+
? crypto.randomUUID()
|
|
5
|
+
: `${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
|
|
6
|
+
}
|
|
7
|
+
function now() {
|
|
8
|
+
return new Date().toISOString();
|
|
9
|
+
}
|
|
10
|
+
export class InMemoryThingStore {
|
|
11
|
+
objects = new Map();
|
|
12
|
+
events = new Map();
|
|
13
|
+
jobs = new Map();
|
|
14
|
+
links = new Map();
|
|
15
|
+
async put(collection, object) {
|
|
16
|
+
const key = `${collection}:${object.id}`;
|
|
17
|
+
const existing = this.objects.get(key);
|
|
18
|
+
const timestamp = now();
|
|
19
|
+
const stored = {
|
|
20
|
+
...object,
|
|
21
|
+
id: object.id,
|
|
22
|
+
collection,
|
|
23
|
+
createdAt: existing?.data.createdAt ?? timestamp,
|
|
24
|
+
updatedAt: timestamp,
|
|
25
|
+
version: (existing?.data.version ?? 0) + 1,
|
|
26
|
+
};
|
|
27
|
+
this.objects.set(key, { collection, data: stored });
|
|
28
|
+
return stored;
|
|
29
|
+
}
|
|
30
|
+
async get(collection, id) {
|
|
31
|
+
const row = this.objects.get(`${collection}:${id}`);
|
|
32
|
+
return row ? row.data : null;
|
|
33
|
+
}
|
|
34
|
+
async getBatch(collection, ids) {
|
|
35
|
+
return Promise.all(ids.map((id) => this.get(collection, id)));
|
|
36
|
+
}
|
|
37
|
+
async delete(_collection, _id) {
|
|
38
|
+
const deleted = this.objects.delete(`${_collection}:${_id}`);
|
|
39
|
+
return { deleted };
|
|
40
|
+
}
|
|
41
|
+
async listObjects(collection, options) {
|
|
42
|
+
let items = Array.from(this.objects.values())
|
|
43
|
+
.filter((r) => r.collection === collection)
|
|
44
|
+
.map((r) => r.data);
|
|
45
|
+
if (options?.filter) {
|
|
46
|
+
const filter = options.filter;
|
|
47
|
+
items = items.filter((obj) => Object.entries(filter).every(([k, v]) => obj[k] === v));
|
|
48
|
+
}
|
|
49
|
+
if (options?.sortBy) {
|
|
50
|
+
const field = options.sortBy.field === "created_at"
|
|
51
|
+
? "createdAt"
|
|
52
|
+
: options.sortBy.field === "updated_at"
|
|
53
|
+
? "updatedAt"
|
|
54
|
+
: options.sortBy.field;
|
|
55
|
+
const dir = options.sortBy.direction === "desc" ? -1 : 1;
|
|
56
|
+
items.sort((a, b) => {
|
|
57
|
+
const va = a[field];
|
|
58
|
+
const vb = b[field];
|
|
59
|
+
if (va == null) {
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
if (vb == null) {
|
|
63
|
+
return -1;
|
|
64
|
+
}
|
|
65
|
+
return va < vb ? -dir : va > vb ? dir : 0;
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
if (options?.offset) {
|
|
69
|
+
items = items.slice(options.offset);
|
|
70
|
+
}
|
|
71
|
+
if (options?.limit) {
|
|
72
|
+
items = items.slice(0, options.limit);
|
|
73
|
+
}
|
|
74
|
+
return items;
|
|
75
|
+
}
|
|
76
|
+
async appendEvent(stream, event) {
|
|
77
|
+
const streamEvents = this.events.get(stream) ?? [];
|
|
78
|
+
const sequence = streamEvents.length + 1;
|
|
79
|
+
const stored = {
|
|
80
|
+
...event,
|
|
81
|
+
id: String(sequence),
|
|
82
|
+
stream,
|
|
83
|
+
sequence,
|
|
84
|
+
createdAt: now(),
|
|
85
|
+
};
|
|
86
|
+
streamEvents.push(stored);
|
|
87
|
+
this.events.set(stream, streamEvents);
|
|
88
|
+
return stored;
|
|
89
|
+
}
|
|
90
|
+
async listEvents(stream, options) {
|
|
91
|
+
let items;
|
|
92
|
+
if (stream) {
|
|
93
|
+
items = this.events.get(stream) ?? [];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
items = Array.from(this.events.values()).flat();
|
|
97
|
+
}
|
|
98
|
+
if (options?.fromSequence) {
|
|
99
|
+
items = items.filter((e) => e.sequence > (options.fromSequence ?? 0));
|
|
100
|
+
}
|
|
101
|
+
if (options?.since) {
|
|
102
|
+
const since = options.since;
|
|
103
|
+
items = items.filter((e) => e.createdAt >= since);
|
|
104
|
+
}
|
|
105
|
+
if (options?.limit) {
|
|
106
|
+
items = items.slice(0, options.limit);
|
|
107
|
+
}
|
|
108
|
+
return items;
|
|
109
|
+
}
|
|
110
|
+
async pushJob(queue, payload, options = {}) {
|
|
111
|
+
const timestamp = now();
|
|
112
|
+
const job = {
|
|
113
|
+
id: options.idempotencyKey ?? uid(),
|
|
114
|
+
queue,
|
|
115
|
+
payload,
|
|
116
|
+
status: "ready",
|
|
117
|
+
attempts: 0,
|
|
118
|
+
maxAttempts: options.maxAttempts ?? 3,
|
|
119
|
+
createdAt: timestamp,
|
|
120
|
+
availableAt: new Date(Date.now() + (options.delayMs ?? 0)).toISOString(),
|
|
121
|
+
priority: options.priority ?? 0,
|
|
122
|
+
};
|
|
123
|
+
const queueJobs = this.jobs.get(queue) ?? [];
|
|
124
|
+
queueJobs.push(job);
|
|
125
|
+
this.jobs.set(queue, queueJobs);
|
|
126
|
+
return job;
|
|
127
|
+
}
|
|
128
|
+
async claimJob(queue, options = {}) {
|
|
129
|
+
const queueJobs = this.jobs.get(queue);
|
|
130
|
+
if (!queueJobs) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const now_ = new Date();
|
|
134
|
+
const ready = queueJobs.filter((c) => c.status === "ready" && c.availableAt <= now_.toISOString());
|
|
135
|
+
if (ready.length === 0) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
ready.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
139
|
+
const job = ready[0];
|
|
140
|
+
job.status = "leased";
|
|
141
|
+
job.attempts += 1;
|
|
142
|
+
job.leasedAt = now_.toISOString();
|
|
143
|
+
job.leaseExpiresAt = new Date(now_.getTime() + (options.leaseMs ?? DEFAULT_LEASE_MS)).toISOString();
|
|
144
|
+
return job;
|
|
145
|
+
}
|
|
146
|
+
async ackJob(queue, jobId) {
|
|
147
|
+
const job = this.findJob(queue, jobId);
|
|
148
|
+
if (!job) {
|
|
149
|
+
return { ok: false, reason: "not_found" };
|
|
150
|
+
}
|
|
151
|
+
if (job.status !== "leased") {
|
|
152
|
+
return { ok: false, reason: "not_leased" };
|
|
153
|
+
}
|
|
154
|
+
job.status = "completed";
|
|
155
|
+
job.completedAt = now();
|
|
156
|
+
return { ok: true, job };
|
|
157
|
+
}
|
|
158
|
+
async nackJob(queue, jobId, options = {}) {
|
|
159
|
+
const job = this.findJob(queue, jobId);
|
|
160
|
+
if (!job) {
|
|
161
|
+
return { ok: false, reason: "not_found" };
|
|
162
|
+
}
|
|
163
|
+
if (job.status !== "leased") {
|
|
164
|
+
return { ok: false, reason: "not_leased" };
|
|
165
|
+
}
|
|
166
|
+
job.lastError = options.error;
|
|
167
|
+
if (job.attempts >= job.maxAttempts) {
|
|
168
|
+
job.status = "dead";
|
|
169
|
+
job.deadAt = now();
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
job.status = "ready";
|
|
173
|
+
job.availableAt = new Date(Date.now() + (options.delayMs ?? 0)).toISOString();
|
|
174
|
+
}
|
|
175
|
+
return { ok: true, job };
|
|
176
|
+
}
|
|
177
|
+
async listJobs(queue) {
|
|
178
|
+
return this.jobs.get(queue) ?? [];
|
|
179
|
+
}
|
|
180
|
+
async listDeadJobs(queue) {
|
|
181
|
+
return (this.jobs.get(queue) ?? []).filter((j) => j.status === "dead");
|
|
182
|
+
}
|
|
183
|
+
async search(_query, _options = {}) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
async putBatch(collection, objects) {
|
|
187
|
+
return Promise.all(objects.map((obj) => this.put(collection, obj)));
|
|
188
|
+
}
|
|
189
|
+
async deleteBatch(collection, ids) {
|
|
190
|
+
let count = 0;
|
|
191
|
+
for (const id of ids) {
|
|
192
|
+
const result = await this.delete(collection, id);
|
|
193
|
+
if (result.deleted) {
|
|
194
|
+
count++;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return count;
|
|
198
|
+
}
|
|
199
|
+
async createLink(fromRef, linkType, toRef, weight, metadataJson) {
|
|
200
|
+
const link = {
|
|
201
|
+
id: uid(),
|
|
202
|
+
fromRef,
|
|
203
|
+
linkType,
|
|
204
|
+
toRef,
|
|
205
|
+
weight,
|
|
206
|
+
metadataJson: metadataJson ?? "{}",
|
|
207
|
+
createdAt: now(),
|
|
208
|
+
};
|
|
209
|
+
this.links.set(link.id, link);
|
|
210
|
+
return link;
|
|
211
|
+
}
|
|
212
|
+
async deleteLink(id) {
|
|
213
|
+
return this.links.delete(id);
|
|
214
|
+
}
|
|
215
|
+
async getLink(id) {
|
|
216
|
+
return this.links.get(id) ?? null;
|
|
217
|
+
}
|
|
218
|
+
async getNeighbors(reference, direction = "Both", options = {}) {
|
|
219
|
+
let items = Array.from(this.links.values()).filter((l) => {
|
|
220
|
+
if (direction === "Outgoing" || direction === "Both") {
|
|
221
|
+
if (l.fromRef === reference) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
if (direction === "Incoming" || direction === "Both") {
|
|
226
|
+
if (l.toRef === reference) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return false;
|
|
231
|
+
});
|
|
232
|
+
if (options.linkType) {
|
|
233
|
+
items = items.filter((l) => l.linkType === options.linkType);
|
|
234
|
+
}
|
|
235
|
+
if (options.limit) {
|
|
236
|
+
items = items.slice(0, options.limit);
|
|
237
|
+
}
|
|
238
|
+
return items;
|
|
239
|
+
}
|
|
240
|
+
async countObjects() {
|
|
241
|
+
return this.objects.size;
|
|
242
|
+
}
|
|
243
|
+
async countObjectsInCollection(collection) {
|
|
244
|
+
let count = 0;
|
|
245
|
+
for (const [key] of this.objects) {
|
|
246
|
+
if (key.startsWith(`${collection}:`)) {
|
|
247
|
+
count++;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return count;
|
|
251
|
+
}
|
|
252
|
+
async countEvents() {
|
|
253
|
+
return Array.from(this.events.values()).reduce((acc, e) => acc + e.length, 0);
|
|
254
|
+
}
|
|
255
|
+
async countActiveJobs() {
|
|
256
|
+
let active = 0;
|
|
257
|
+
for (const jobs of this.jobs.values()) {
|
|
258
|
+
active += jobs.filter((j) => j.status === "ready" || j.status === "leased").length;
|
|
259
|
+
}
|
|
260
|
+
return active;
|
|
261
|
+
}
|
|
262
|
+
async countDeadJobs() {
|
|
263
|
+
let dead = 0;
|
|
264
|
+
for (const jobs of this.jobs.values()) {
|
|
265
|
+
dead += jobs.filter((j) => j.status === "dead").length;
|
|
266
|
+
}
|
|
267
|
+
return dead;
|
|
268
|
+
}
|
|
269
|
+
async countLinks() {
|
|
270
|
+
return this.links.size;
|
|
271
|
+
}
|
|
272
|
+
async listCollections() {
|
|
273
|
+
const collections = new Set(Array.from(this.objects.values()).map((r) => r.collection));
|
|
274
|
+
return Array.from(collections);
|
|
275
|
+
}
|
|
276
|
+
async listStreams() {
|
|
277
|
+
return Array.from(this.events.keys());
|
|
278
|
+
}
|
|
279
|
+
async listQueues() {
|
|
280
|
+
return Array.from(this.jobs.keys());
|
|
281
|
+
}
|
|
282
|
+
async createIndex(_collection, _field) {
|
|
283
|
+
// No-op for in-memory client store
|
|
284
|
+
}
|
|
285
|
+
async listIndexes() {
|
|
286
|
+
return [];
|
|
287
|
+
}
|
|
288
|
+
async close() { }
|
|
289
|
+
findJob(queue, jobId) {
|
|
290
|
+
return (this.jobs.get(queue) ?? []).find((j) => j.id === jobId);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { AggregateFunction, AggregateGroupResult, AggregateOptions, AggregateResult, BackupCapableThingStore, CollectionSchema, ConnectorAuth, ConnectorSchema, ConnectorSyncOptions, ConnectorSyncResult, FieldSchema, FilterOperator, Link, LinkDirection, LinkQueryOptions, ListEventsOptions, ListObjectsOptions, LocalThingDConnection, MemoryEvent, MemoryObject, MemoryQueue, MemorySearchOptions, MemorySearchResult, NlqIntent, NlqOptions, NlqResult, PutOptions, QueueClaimOptions, QueueJob, QueueJobOptions, QueueJobPayload, QueueJobResult, QueueJobStatus, QueueNackOptions, ReconnectableThingStore, SchemaOptions, SortBy, SortDirection, StoredMemoryEvent, StoredMemoryObject, ThingDConnection, ThingDeleteResult, ThingStore, TimeBucket, TimeSeriesBucket, TimeSeriesOptions, TimeSeriesResult, VectorSearchHit, VectorSearchOptions, WalCheckpointResult, } from "../types.js";
|
|
2
|
+
export { HttpThingStore, type HttpThingStoreOptions } from "./http-thing-store.js";
|
|
3
|
+
export { InMemoryThingStore } from "./in-memory-thing-store.js";
|
|
4
|
+
export { openThingD, type ThingDClientOptions, } from "./thingd.js";
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EACL,UAAU,EACV,KAAK,mBAAmB,GACzB,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { HttpThingStore } from "./http-thing-store.js";
|
|
2
|
+
import { InMemoryThingStore } from "./in-memory-thing-store.js";
|
|
3
|
+
export type { ThingDDriver, ThingDOpenConfig, ThingDOpenOptions, } from "../thingd.js";
|
|
4
|
+
export type ThingDClientOptions = {
|
|
5
|
+
driver?: "memory" | "cloud";
|
|
6
|
+
url?: string;
|
|
7
|
+
authToken?: string;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Open a thingd connection from a browser/edge-compatible environment.
|
|
12
|
+
*
|
|
13
|
+
* Unlike ThingD.open() from the main entry point, this does NOT read from
|
|
14
|
+
* process.env — all configuration must be passed explicitly.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const db = await openThingD({ url: "http://localhost:8757" });
|
|
19
|
+
* await db.put("notes", { id: "1", text: "hello" });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function openThingD(options?: ThingDClientOptions): Promise<HttpThingStore | InMemoryThingStore>;
|
|
23
|
+
export { HttpThingStore, InMemoryThingStore };
|
|
24
|
+
//# sourceMappingURL=thingd.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thingd.d.ts","sourceRoot":"","sources":["../../src/client/thingd.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAMF;;;;;;;;;;;GAWG;AACH,wBAAsB,UAAU,CAC9B,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,cAAc,GAAG,kBAAkB,CAAC,CAS9C;AAED,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HttpThingStore } from "./http-thing-store.js";
|
|
2
|
+
import { InMemoryThingStore } from "./in-memory-thing-store.js";
|
|
3
|
+
function resolveToken(options) {
|
|
4
|
+
return options.authToken ?? options.apiKey;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Open a thingd connection from a browser/edge-compatible environment.
|
|
8
|
+
*
|
|
9
|
+
* Unlike ThingD.open() from the main entry point, this does NOT read from
|
|
10
|
+
* process.env — all configuration must be passed explicitly.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const db = await openThingD({ url: "http://localhost:8757" });
|
|
15
|
+
* await db.put("notes", { id: "1", text: "hello" });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export async function openThingD(options = {}) {
|
|
19
|
+
if (options.driver === "memory" || !options.url) {
|
|
20
|
+
return new InMemoryThingStore();
|
|
21
|
+
}
|
|
22
|
+
return HttpThingStore.open({
|
|
23
|
+
url: options.url,
|
|
24
|
+
authToken: resolveToken(options),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { HttpThingStore, InMemoryThingStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;yDACyD;AACzD,eAAO,MAAM,cAAc,EAAG,EAAW,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { MCP_TOOL_COUNT } from "./constants.js";
|
|
2
|
+
export { appendMcpAuditEvent, createThingdMcpServer, jsonResult, parseCollectionAllowlist, parsePayloadSizeLimit, type RegisterThingdToolsOptions, readMcpHardeningOptionsFromEnv, registerThingdTools, resolveThingdMcpAuditOptions, type ThingdMcpAuditMetadata, type ThingdMcpAuditOptions, type ThingdMcpHardeningOptions, type ThingdMcpServerOptions, } from "./mcp/index.js";
|
|
3
|
+
export { handleRestRequest, parseFilter, parseIntParam, parseSortBy, readBody, sendData, sendDataList, sendError, sendJson, } from "./rest/index.js";
|
|
4
|
+
export { Scheduler } from "./scheduler.js";
|
|
5
|
+
export type { CloudThingStoreOptions } from "./stores/cloud-thing-store.js";
|
|
6
|
+
export { CloudThingStore } from "./stores/cloud-thing-store.js";
|
|
7
|
+
export { InMemoryThingStore } from "./stores/in-memory-thing-store.js";
|
|
8
|
+
export { NativeThingStore } from "./stores/native-thing-store.js";
|
|
9
|
+
export type { ThingDDriver, ThingDOpenConfig, ThingDOpenOptions } from "./thingd.js";
|
|
10
|
+
export { ThingD } from "./thingd.js";
|
|
11
|
+
export type { AggregateFunction, AggregateGroupResult, AggregateOptions, AggregateResult, BackupCapableThingStore, CollectionSchema, ConnectorAuth, ConnectorSchema, ConnectorSyncOptions, ConnectorSyncResult, FieldSchema, FilterOperator, Link, LinkDirection, LinkQueryOptions, ListEventsOptions, ListObjectsOptions, LocalThingDConnection, MemoryEvent, MemoryObject, MemoryQueue, MemorySearchOptions, MemorySearchResult, NlqIntent, NlqOptions, NlqResult, PutOptions, QueueClaimOptions, QueueJob, QueueJobOptions, QueueJobPayload, QueueJobResult, QueueJobStatus, QueueNackOptions, ReconnectableThingStore, Schedule, ScheduleContext, ScheduleEvent, ScheduleHandler, ScheduleIntervalOptions, ScheduleOnceOptions, ScheduleOptions, SchedulerEventType, SchedulerFacade, SchedulerListener, SchedulerStats, SchemaOptions, SortBy, SortDirection, StoredMemoryEvent, StoredMemoryObject, ThingDConnection, ThingDeleteResult, ThingStore, TimeBucket, TimeSeriesBucket, TimeSeriesOptions, TimeSeriesResult, VectorSearchHit, VectorSearchOptions, WalCheckpointResult, } from "./types.js";
|
|
12
|
+
export { SDK_VERSION } from "./version.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,mBAAmB,EACnB,qBAAqB,EACrB,UAAU,EACV,wBAAwB,EACxB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,8BAA8B,EAC9B,mBAAmB,EACnB,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,GAC5B,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,YAAY,EACZ,SAAS,EACT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,YAAY,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EACV,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,IAAI,EACJ,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,WAAW,EACX,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,uBAAuB,EACvB,QAAQ,EACR,eAAe,EACf,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,aAAa,EACb,MAAM,EACN,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// MCP server (tool handlers + factory)
|
|
2
|
+
export { MCP_TOOL_COUNT } from "./constants.js";
|
|
3
|
+
export { appendMcpAuditEvent, createThingdMcpServer, jsonResult, parseCollectionAllowlist, parsePayloadSizeLimit, readMcpHardeningOptionsFromEnv, registerThingdTools, resolveThingdMcpAuditOptions, } from "./mcp/index.js";
|
|
4
|
+
// REST API (route handlers + helpers)
|
|
5
|
+
export { handleRestRequest, parseFilter, parseIntParam, parseSortBy, readBody, sendData, sendDataList, sendError, sendJson, } from "./rest/index.js";
|
|
6
|
+
export { Scheduler } from "./scheduler.js";
|
|
7
|
+
export { CloudThingStore } from "./stores/cloud-thing-store.js";
|
|
8
|
+
export { InMemoryThingStore } from "./stores/in-memory-thing-store.js";
|
|
9
|
+
export { NativeThingStore } from "./stores/native-thing-store.js";
|
|
10
|
+
export { ThingD } from "./thingd.js";
|
|
11
|
+
export { SDK_VERSION } from "./version.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ThingD } from "../thingd.js";
|
|
2
|
+
export type ThingdMcpAuditOptions = {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
actor?: string;
|
|
5
|
+
source?: string;
|
|
6
|
+
stream?: string;
|
|
7
|
+
};
|
|
8
|
+
export type ThingdMcpAuditMetadata = {
|
|
9
|
+
actor?: string;
|
|
10
|
+
source?: string;
|
|
11
|
+
};
|
|
12
|
+
type ResolvedThingdMcpAuditOptions = {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
actor: string;
|
|
15
|
+
source: string;
|
|
16
|
+
stream: string;
|
|
17
|
+
};
|
|
18
|
+
type ThingdMcpAuditEventOptions = {
|
|
19
|
+
action: string;
|
|
20
|
+
target: Record<string, unknown>;
|
|
21
|
+
metadata?: ThingdMcpAuditMetadata;
|
|
22
|
+
result?: Record<string, unknown>;
|
|
23
|
+
};
|
|
24
|
+
export declare function resolveThingdMcpAuditOptions(options: ThingdMcpAuditOptions | false | undefined): ResolvedThingdMcpAuditOptions;
|
|
25
|
+
export declare function appendMcpAuditEvent(db: ThingD, options: ResolvedThingdMcpAuditOptions, event: ThingdMcpAuditEventOptions): Promise<void>;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/mcp/audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAMF,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,qBAAqB,GAAG,KAAK,GAAG,SAAS,GACjD,6BAA6B,CAgB/B;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,6BAA6B,EACtC,KAAK,EAAE,0BAA0B,GAChC,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const DEFAULT_AUDIT_STREAM = "__thingd:mcp:audit";
|
|
2
|
+
const DEFAULT_AUDIT_ACTOR = "mcp-client";
|
|
3
|
+
const DEFAULT_AUDIT_SOURCE = "thingd-mcp";
|
|
4
|
+
export function resolveThingdMcpAuditOptions(options) {
|
|
5
|
+
if (options === false || options?.enabled === false) {
|
|
6
|
+
return {
|
|
7
|
+
enabled: false,
|
|
8
|
+
actor: DEFAULT_AUDIT_ACTOR,
|
|
9
|
+
source: DEFAULT_AUDIT_SOURCE,
|
|
10
|
+
stream: DEFAULT_AUDIT_STREAM,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
enabled: true,
|
|
15
|
+
actor: options?.actor ?? DEFAULT_AUDIT_ACTOR,
|
|
16
|
+
source: options?.source ?? DEFAULT_AUDIT_SOURCE,
|
|
17
|
+
stream: options?.stream ?? DEFAULT_AUDIT_STREAM,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export async function appendMcpAuditEvent(db, options, event) {
|
|
21
|
+
if (!options.enabled) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const actor = event.metadata?.actor ?? options.actor;
|
|
25
|
+
const source = event.metadata?.source ?? options.source;
|
|
26
|
+
const auditEvent = {
|
|
27
|
+
type: `mcp.${event.action}`,
|
|
28
|
+
text: `MCP ${event.action} by ${actor}`,
|
|
29
|
+
actor,
|
|
30
|
+
source,
|
|
31
|
+
target: event.target,
|
|
32
|
+
result: event.result,
|
|
33
|
+
at: new Date().toISOString(),
|
|
34
|
+
};
|
|
35
|
+
await db.events.append(options.stream, auditEvent);
|
|
36
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type ThingdMcpHardeningOptions = {
|
|
2
|
+
/** Comma-separated collection allowlist from THINGD_MCP_COLLECTIONS. Empty = all allowed. */
|
|
3
|
+
collectionAllowlist?: Set<string>;
|
|
4
|
+
/** When true, all write tools are rejected. Set via THINGD_MCP_READ_ONLY=true. */
|
|
5
|
+
readOnly?: boolean;
|
|
6
|
+
/** Maximum HTTP request body in bytes. Set via THINGD_MCP_MAX_PAYLOAD_BYTES. Default 512 KB. */
|
|
7
|
+
maxPayloadBytes?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Parse THINGD_MCP_COLLECTIONS into a Set.
|
|
11
|
+
* An empty string or missing env var means all collections are allowed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseCollectionAllowlist(value: string | undefined): Set<string> | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Parse THINGD_MCP_MAX_PAYLOAD_BYTES. Defaults to 512 KB if unset or zero.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parsePayloadSizeLimit(value: string | undefined, defaultBytes?: number): number;
|
|
18
|
+
/**
|
|
19
|
+
* Read all MCP hardening options from the environment.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readMcpHardeningOptionsFromEnv(env: Record<string, string | undefined>): ThingdMcpHardeningOptions;
|
|
22
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/mcp/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG;IACtC,6FAA6F;IAC7F,mBAAmB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gGAAgG;IAChG,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,CAW3F;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,YAAY,SAAU,GAAG,MAAM,CAW/F;AAmBD;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GACtC,yBAAyB,CAQ3B"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse THINGD_MCP_COLLECTIONS into a Set.
|
|
3
|
+
* An empty string or missing env var means all collections are allowed.
|
|
4
|
+
*/
|
|
5
|
+
export function parseCollectionAllowlist(value) {
|
|
6
|
+
if (!value?.trim()) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
const names = value
|
|
10
|
+
.split(",")
|
|
11
|
+
.map((s) => s.trim())
|
|
12
|
+
.filter(Boolean);
|
|
13
|
+
return names.length > 0 ? new Set(names) : undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parse THINGD_MCP_MAX_PAYLOAD_BYTES. Defaults to 512 KB if unset or zero.
|
|
17
|
+
*/
|
|
18
|
+
export function parsePayloadSizeLimit(value, defaultBytes = 524_288) {
|
|
19
|
+
if (!value) {
|
|
20
|
+
return defaultBytes;
|
|
21
|
+
}
|
|
22
|
+
const n = Number.parseInt(value, 10);
|
|
23
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
24
|
+
throw new Error(`Invalid THINGD_MCP_MAX_PAYLOAD_BYTES: ${value}`);
|
|
25
|
+
}
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
function parseBooleanFlag(value, name) {
|
|
29
|
+
if (!value) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
const normalized = value.toLowerCase();
|
|
33
|
+
if (["1", "true", "yes", "on"].includes(normalized)) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (["0", "false", "no", "off"].includes(normalized)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`Invalid ${name}: expected true or false`);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read all MCP hardening options from the environment.
|
|
43
|
+
*/
|
|
44
|
+
export function readMcpHardeningOptionsFromEnv(env) {
|
|
45
|
+
return {
|
|
46
|
+
collectionAllowlist: parseCollectionAllowlist(env.THINGD_MCP_COLLECTIONS),
|
|
47
|
+
readOnly: env.THINGD_MCP_READ_ONLY
|
|
48
|
+
? parseBooleanFlag(env.THINGD_MCP_READ_ONLY, "THINGD_MCP_READ_ONLY")
|
|
49
|
+
: undefined,
|
|
50
|
+
maxPayloadBytes: parsePayloadSizeLimit(env.THINGD_MCP_MAX_PAYLOAD_BYTES),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { appendMcpAuditEvent, resolveThingdMcpAuditOptions, type ThingdMcpAuditMetadata, type ThingdMcpAuditOptions, } from "./audit.js";
|
|
2
|
+
export { parseCollectionAllowlist, parsePayloadSizeLimit, readMcpHardeningOptionsFromEnv, type ThingdMcpHardeningOptions, } from "./config.js";
|
|
3
|
+
export { jsonResult } from "./result.js";
|
|
4
|
+
export { createThingdMcpServer, type ThingdMcpServerOptions } from "./server.js";
|
|
5
|
+
export { type RegisterThingdToolsOptions, registerThingdTools } from "./tools.js";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,8BAA8B,EAC9B,KAAK,yBAAyB,GAC/B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,KAAK,0BAA0B,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { appendMcpAuditEvent, resolveThingdMcpAuditOptions, } from "./audit.js";
|
|
2
|
+
export { parseCollectionAllowlist, parsePayloadSizeLimit, readMcpHardeningOptionsFromEnv, } from "./config.js";
|
|
3
|
+
export { jsonResult } from "./result.js";
|
|
4
|
+
export { createThingdMcpServer } from "./server.js";
|
|
5
|
+
export { registerThingdTools } from "./tools.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.d.ts","sourceRoot":"","sources":["../../src/mcp/result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CASzD"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { ThingD } from "../thingd.js";
|
|
3
|
+
import type { ThingdMcpAuditOptions } from "./audit.js";
|
|
4
|
+
import type { ThingdMcpHardeningOptions } from "./config.js";
|
|
5
|
+
export type ThingdMcpServerOptions = {
|
|
6
|
+
audit?: ThingdMcpAuditOptions | false;
|
|
7
|
+
hardening?: ThingdMcpHardeningOptions;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Create a new McpServer with all thingd tools registered.
|
|
11
|
+
*
|
|
12
|
+
* Note: a new instance must be created per HTTP request because
|
|
13
|
+
* @modelcontextprotocol/sdk's underlying Server.connect() throws if called
|
|
14
|
+
* on an already-connected instance (stateless HTTP mode: one transport per
|
|
15
|
+
* request lifecycle). Tool registration is cheap (Map insertions) so this
|
|
16
|
+
* is not a meaningful overhead in practice.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createThingdMcpServer(db: ThingD, options?: ThingdMcpServerOptions): McpServer;
|
|
19
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAG7D,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC;IACtC,SAAS,CAAC,EAAE,yBAAyB,CAAC;CACvC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,SAAS,CAwDjG"}
|