@gilangjavier/chrona 0.1.0 → 0.1.1
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 +79 -2
- package/dist/chunk-4QI4QC33.js +814 -0
- package/dist/chunk-4QI4QC33.js.map +1 -0
- package/dist/cli.cjs +428 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +18 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +442 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +309 -1
- package/dist/index.d.ts +309 -1
- package/dist/index.js +37 -3
- package/package.json +6 -3
- package/dist/chunk-PPAKIDJE.js +0 -391
- package/dist/chunk-PPAKIDJE.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -31,13 +31,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
ChromaStore: () => ChromaStore,
|
|
34
|
+
chronaAddInputSchema: () => chronaAddInputSchema,
|
|
35
|
+
chronaAddResultSchema: () => chronaAddResultSchema,
|
|
36
|
+
chronaExportInputSchema: () => chronaExportInputSchema,
|
|
37
|
+
chronaExportResultSchema: () => chronaExportResultSchema,
|
|
38
|
+
chronaGcInputSchema: () => chronaGcInputSchema,
|
|
39
|
+
chronaGcResultSchema: () => chronaGcResultSchema,
|
|
40
|
+
chronaGetInputSchema: () => chronaGetInputSchema,
|
|
41
|
+
chronaGetResultSchema: () => chronaGetResultSchema,
|
|
42
|
+
chronaImportInputSchema: () => chronaImportInputSchema,
|
|
43
|
+
chronaImportResultSchema: () => chronaImportResultSchema,
|
|
44
|
+
chronaSearchInputSchema: () => chronaSearchInputSchema,
|
|
45
|
+
chronaSearchResultSchema: () => chronaSearchResultSchema,
|
|
46
|
+
chronaTimelineInputSchema: () => chronaTimelineInputSchema,
|
|
47
|
+
chronaTimelineResultSchema: () => chronaTimelineResultSchema,
|
|
48
|
+
createChronaMcpHandlers: () => createChronaMcpHandlers,
|
|
49
|
+
createChronaMcpServer: () => createChronaMcpServer,
|
|
34
50
|
memoryScopes: () => memoryScopes,
|
|
35
51
|
memoryTypes: () => memoryTypes,
|
|
36
52
|
normalizeEntry: () => normalizeEntry,
|
|
37
53
|
parseMemoryScope: () => parseMemoryScope,
|
|
38
54
|
parseMemoryType: () => parseMemoryType,
|
|
39
55
|
parseSourceKind: () => parseSourceKind,
|
|
40
|
-
sourceKinds: () => sourceKinds
|
|
56
|
+
sourceKinds: () => sourceKinds,
|
|
57
|
+
startChronaMcpServer: () => startChronaMcpServer
|
|
41
58
|
});
|
|
42
59
|
module.exports = __toCommonJS(index_exports);
|
|
43
60
|
|
|
@@ -413,15 +430,438 @@ var ChromaStore = class {
|
|
|
413
430
|
};
|
|
414
431
|
}
|
|
415
432
|
};
|
|
433
|
+
|
|
434
|
+
// src/mcp.ts
|
|
435
|
+
var import_node_http = require("http");
|
|
436
|
+
var import_node_path2 = require("path");
|
|
437
|
+
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
438
|
+
var import_stdio = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
439
|
+
var import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
440
|
+
var z = __toESM(require("zod/v4"), 1);
|
|
441
|
+
var memoryTypeSchema = z.enum(memoryTypes);
|
|
442
|
+
var memoryScopeSchema = z.enum(memoryScopes);
|
|
443
|
+
var sourceKindSchema = z.enum(sourceKinds);
|
|
444
|
+
var jsonValueSchema = z.json();
|
|
445
|
+
var jsonObjectSchema = z.record(z.string(), jsonValueSchema);
|
|
446
|
+
var sourceSchema = z.object({
|
|
447
|
+
kind: sourceKindSchema,
|
|
448
|
+
value: z.string().trim().min(1)
|
|
449
|
+
});
|
|
450
|
+
var memoryEntrySchema = z.object({
|
|
451
|
+
id: z.string(),
|
|
452
|
+
type: memoryTypeSchema,
|
|
453
|
+
text: z.string(),
|
|
454
|
+
createdAt: z.string(),
|
|
455
|
+
source: sourceSchema,
|
|
456
|
+
confidence: z.number(),
|
|
457
|
+
scope: memoryScopeSchema,
|
|
458
|
+
tags: z.array(z.string()),
|
|
459
|
+
expiresAt: z.string().optional(),
|
|
460
|
+
links: z.array(z.string()),
|
|
461
|
+
metadata: jsonObjectSchema
|
|
462
|
+
});
|
|
463
|
+
var queryOptionsSchema = z.object({
|
|
464
|
+
scopes: z.array(memoryScopeSchema).optional(),
|
|
465
|
+
types: z.array(memoryTypeSchema).optional(),
|
|
466
|
+
tags: z.array(z.string()).optional(),
|
|
467
|
+
sourceKind: sourceKindSchema.optional(),
|
|
468
|
+
sourceValue: z.string().trim().min(1).optional(),
|
|
469
|
+
before: z.string().optional(),
|
|
470
|
+
after: z.string().optional(),
|
|
471
|
+
includeExpired: z.boolean().default(false)
|
|
472
|
+
});
|
|
473
|
+
var chronaAddInputSchema = z.object({
|
|
474
|
+
id: z.string().trim().min(1).optional(),
|
|
475
|
+
type: memoryTypeSchema,
|
|
476
|
+
text: z.string().trim().min(1),
|
|
477
|
+
createdAt: z.string().optional(),
|
|
478
|
+
source: sourceSchema,
|
|
479
|
+
confidence: z.number().min(0).max(1),
|
|
480
|
+
scope: memoryScopeSchema,
|
|
481
|
+
tags: z.array(z.string()).default([]),
|
|
482
|
+
expiresAt: z.string().optional(),
|
|
483
|
+
links: z.array(z.string()).default([]),
|
|
484
|
+
metadata: jsonObjectSchema.default({})
|
|
485
|
+
});
|
|
486
|
+
var chronaAddResultSchema = z.object({
|
|
487
|
+
entry: memoryEntrySchema
|
|
488
|
+
});
|
|
489
|
+
var chronaGetInputSchema = z.object({
|
|
490
|
+
id: z.string().trim().min(1)
|
|
491
|
+
});
|
|
492
|
+
var chronaGetResultSchema = z.object({
|
|
493
|
+
entry: memoryEntrySchema.nullable()
|
|
494
|
+
});
|
|
495
|
+
var chronaSearchInputSchema = queryOptionsSchema.extend({
|
|
496
|
+
query: z.string().trim().min(1),
|
|
497
|
+
limit: z.number().int().min(1).max(1e3).default(50)
|
|
498
|
+
});
|
|
499
|
+
var chronaSearchResultSchema = z.object({
|
|
500
|
+
count: z.number().int().min(0),
|
|
501
|
+
items: z.array(memoryEntrySchema)
|
|
502
|
+
});
|
|
503
|
+
var chronaTimelineInputSchema = queryOptionsSchema.extend({
|
|
504
|
+
order: z.enum(["asc", "desc"]).default("asc"),
|
|
505
|
+
limit: z.number().int().min(1).max(1e3).default(50)
|
|
506
|
+
});
|
|
507
|
+
var chronaTimelineResultSchema = z.object({
|
|
508
|
+
count: z.number().int().min(0),
|
|
509
|
+
items: z.array(memoryEntrySchema)
|
|
510
|
+
});
|
|
511
|
+
var chronaExportInputSchema = queryOptionsSchema.extend({
|
|
512
|
+
order: z.enum(["asc", "desc"]).default("asc"),
|
|
513
|
+
limit: z.number().int().min(1).max(1e3).default(1e3)
|
|
514
|
+
});
|
|
515
|
+
var chronaExportResultSchema = z.object({
|
|
516
|
+
count: z.number().int().min(0),
|
|
517
|
+
jsonl: z.string()
|
|
518
|
+
});
|
|
519
|
+
var chronaImportInputSchema = z.object({
|
|
520
|
+
jsonl: z.string()
|
|
521
|
+
});
|
|
522
|
+
var chronaImportResultSchema = z.object({
|
|
523
|
+
imported: z.number().int().min(0),
|
|
524
|
+
updated: z.number().int().min(0),
|
|
525
|
+
ids: z.array(z.string())
|
|
526
|
+
});
|
|
527
|
+
var chronaGcInputSchema = z.object({
|
|
528
|
+
now: z.string().optional()
|
|
529
|
+
});
|
|
530
|
+
var chronaGcResultSchema = z.object({
|
|
531
|
+
deleted: z.number().int().min(0),
|
|
532
|
+
ids: z.array(z.string()),
|
|
533
|
+
now: z.string()
|
|
534
|
+
});
|
|
535
|
+
function withStore(dbPath, run) {
|
|
536
|
+
const store = new ChromaStore(dbPath);
|
|
537
|
+
try {
|
|
538
|
+
return run(store);
|
|
539
|
+
} finally {
|
|
540
|
+
store.close();
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
function toQueryOptions(input) {
|
|
544
|
+
return {
|
|
545
|
+
scopes: input.scopes,
|
|
546
|
+
types: input.types,
|
|
547
|
+
tags: input.tags,
|
|
548
|
+
sourceKind: input.sourceKind,
|
|
549
|
+
sourceValue: input.sourceValue,
|
|
550
|
+
before: input.before,
|
|
551
|
+
after: input.after,
|
|
552
|
+
includeExpired: input.includeExpired,
|
|
553
|
+
limit: input.limit
|
|
554
|
+
};
|
|
555
|
+
}
|
|
556
|
+
function sortJsonValue(value) {
|
|
557
|
+
if (Array.isArray(value)) {
|
|
558
|
+
return value.map(sortJsonValue);
|
|
559
|
+
}
|
|
560
|
+
if (value && typeof value === "object") {
|
|
561
|
+
return Object.fromEntries(
|
|
562
|
+
Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, innerValue]) => [key, sortJsonValue(innerValue)])
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
return value;
|
|
566
|
+
}
|
|
567
|
+
function toOutputEntry(entry) {
|
|
568
|
+
const base = {
|
|
569
|
+
id: entry.id,
|
|
570
|
+
type: entry.type,
|
|
571
|
+
text: entry.text,
|
|
572
|
+
createdAt: entry.createdAt,
|
|
573
|
+
source: {
|
|
574
|
+
kind: entry.source.kind,
|
|
575
|
+
value: entry.source.value
|
|
576
|
+
},
|
|
577
|
+
confidence: entry.confidence,
|
|
578
|
+
scope: entry.scope,
|
|
579
|
+
tags: [...entry.tags],
|
|
580
|
+
links: [...entry.links ?? []],
|
|
581
|
+
metadata: sortJsonValue(entry.metadata ?? {})
|
|
582
|
+
};
|
|
583
|
+
if (entry.expiresAt) {
|
|
584
|
+
return {
|
|
585
|
+
...base,
|
|
586
|
+
expiresAt: entry.expiresAt
|
|
587
|
+
};
|
|
588
|
+
}
|
|
589
|
+
return base;
|
|
590
|
+
}
|
|
591
|
+
function toToolResult(value) {
|
|
592
|
+
const stableValue = sortJsonValue(value);
|
|
593
|
+
return {
|
|
594
|
+
content: [
|
|
595
|
+
{
|
|
596
|
+
type: "text",
|
|
597
|
+
text: JSON.stringify(stableValue, null, 2)
|
|
598
|
+
}
|
|
599
|
+
],
|
|
600
|
+
structuredContent: stableValue
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function lineCount(value) {
|
|
604
|
+
return value === "" ? 0 : value.split("\n").length;
|
|
605
|
+
}
|
|
606
|
+
function createChronaMcpHandlers(dbPath) {
|
|
607
|
+
const resolvedDbPath = (0, import_node_path2.resolve)(dbPath);
|
|
608
|
+
return {
|
|
609
|
+
add(input) {
|
|
610
|
+
const args = chronaAddInputSchema.parse(input);
|
|
611
|
+
return withStore(resolvedDbPath, (store) => {
|
|
612
|
+
const entry = store.add({
|
|
613
|
+
id: args.id,
|
|
614
|
+
type: args.type,
|
|
615
|
+
text: args.text,
|
|
616
|
+
createdAt: args.createdAt,
|
|
617
|
+
source: args.source,
|
|
618
|
+
confidence: args.confidence,
|
|
619
|
+
scope: args.scope,
|
|
620
|
+
tags: args.tags,
|
|
621
|
+
expiresAt: args.expiresAt,
|
|
622
|
+
links: args.links,
|
|
623
|
+
metadata: args.metadata
|
|
624
|
+
});
|
|
625
|
+
return {
|
|
626
|
+
entry: toOutputEntry(entry)
|
|
627
|
+
};
|
|
628
|
+
});
|
|
629
|
+
},
|
|
630
|
+
get(input) {
|
|
631
|
+
const args = chronaGetInputSchema.parse(input);
|
|
632
|
+
return withStore(resolvedDbPath, (store) => {
|
|
633
|
+
const entry = store.get(args.id);
|
|
634
|
+
return {
|
|
635
|
+
entry: entry ? toOutputEntry(entry) : null
|
|
636
|
+
};
|
|
637
|
+
});
|
|
638
|
+
},
|
|
639
|
+
search(input) {
|
|
640
|
+
const args = chronaSearchInputSchema.parse(input);
|
|
641
|
+
return withStore(resolvedDbPath, (store) => {
|
|
642
|
+
const items = store.search({
|
|
643
|
+
...toQueryOptions(args),
|
|
644
|
+
query: args.query
|
|
645
|
+
}).map(toOutputEntry);
|
|
646
|
+
return {
|
|
647
|
+
count: items.length,
|
|
648
|
+
items
|
|
649
|
+
};
|
|
650
|
+
});
|
|
651
|
+
},
|
|
652
|
+
timeline(input) {
|
|
653
|
+
const args = chronaTimelineInputSchema.parse(input);
|
|
654
|
+
return withStore(resolvedDbPath, (store) => {
|
|
655
|
+
const items = store.timeline({
|
|
656
|
+
...toQueryOptions(args),
|
|
657
|
+
order: args.order
|
|
658
|
+
}).map(toOutputEntry);
|
|
659
|
+
return {
|
|
660
|
+
count: items.length,
|
|
661
|
+
items
|
|
662
|
+
};
|
|
663
|
+
});
|
|
664
|
+
},
|
|
665
|
+
export(input) {
|
|
666
|
+
const args = chronaExportInputSchema.parse(input);
|
|
667
|
+
return withStore(resolvedDbPath, (store) => {
|
|
668
|
+
const jsonl = store.exportJsonl({
|
|
669
|
+
...toQueryOptions(args),
|
|
670
|
+
order: args.order
|
|
671
|
+
});
|
|
672
|
+
return {
|
|
673
|
+
count: lineCount(jsonl),
|
|
674
|
+
jsonl
|
|
675
|
+
};
|
|
676
|
+
});
|
|
677
|
+
},
|
|
678
|
+
import(input) {
|
|
679
|
+
const args = chronaImportInputSchema.parse(input);
|
|
680
|
+
return withStore(resolvedDbPath, (store) => store.importJsonl(args.jsonl));
|
|
681
|
+
},
|
|
682
|
+
gc(input = {}) {
|
|
683
|
+
const args = chronaGcInputSchema.parse(input);
|
|
684
|
+
return withStore(resolvedDbPath, (store) => store.gc(args.now));
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function createChronaMcpServer(dbPath) {
|
|
689
|
+
const handlers = createChronaMcpHandlers(dbPath);
|
|
690
|
+
const server = new import_mcp.McpServer({
|
|
691
|
+
name: "chrona",
|
|
692
|
+
version: "0.1.1"
|
|
693
|
+
});
|
|
694
|
+
server.registerTool(
|
|
695
|
+
"chrona_add",
|
|
696
|
+
{
|
|
697
|
+
description: "Add a memory entry to Chrona.",
|
|
698
|
+
inputSchema: chronaAddInputSchema,
|
|
699
|
+
outputSchema: chronaAddResultSchema
|
|
700
|
+
},
|
|
701
|
+
async (input) => toToolResult(handlers.add(input))
|
|
702
|
+
);
|
|
703
|
+
server.registerTool(
|
|
704
|
+
"chrona_get",
|
|
705
|
+
{
|
|
706
|
+
description: "Get a memory entry by id.",
|
|
707
|
+
inputSchema: chronaGetInputSchema,
|
|
708
|
+
outputSchema: chronaGetResultSchema,
|
|
709
|
+
annotations: { readOnlyHint: true }
|
|
710
|
+
},
|
|
711
|
+
async (input) => toToolResult(handlers.get(input))
|
|
712
|
+
);
|
|
713
|
+
server.registerTool(
|
|
714
|
+
"chrona_search",
|
|
715
|
+
{
|
|
716
|
+
description: "Search memory entries with deterministic ordering.",
|
|
717
|
+
inputSchema: chronaSearchInputSchema,
|
|
718
|
+
outputSchema: chronaSearchResultSchema,
|
|
719
|
+
annotations: { readOnlyHint: true }
|
|
720
|
+
},
|
|
721
|
+
async (input) => toToolResult(handlers.search(input))
|
|
722
|
+
);
|
|
723
|
+
server.registerTool(
|
|
724
|
+
"chrona_timeline",
|
|
725
|
+
{
|
|
726
|
+
description: "List memory entries in time order.",
|
|
727
|
+
inputSchema: chronaTimelineInputSchema,
|
|
728
|
+
outputSchema: chronaTimelineResultSchema,
|
|
729
|
+
annotations: { readOnlyHint: true }
|
|
730
|
+
},
|
|
731
|
+
async (input) => toToolResult(handlers.timeline(input))
|
|
732
|
+
);
|
|
733
|
+
server.registerTool(
|
|
734
|
+
"chrona_export",
|
|
735
|
+
{
|
|
736
|
+
description: "Export matching entries as deterministic JSONL.",
|
|
737
|
+
inputSchema: chronaExportInputSchema,
|
|
738
|
+
outputSchema: chronaExportResultSchema,
|
|
739
|
+
annotations: { readOnlyHint: true }
|
|
740
|
+
},
|
|
741
|
+
async (input) => toToolResult(handlers.export(input))
|
|
742
|
+
);
|
|
743
|
+
server.registerTool(
|
|
744
|
+
"chrona_import",
|
|
745
|
+
{
|
|
746
|
+
description: "Import entries from JSONL.",
|
|
747
|
+
inputSchema: chronaImportInputSchema,
|
|
748
|
+
outputSchema: chronaImportResultSchema
|
|
749
|
+
},
|
|
750
|
+
async (input) => toToolResult(handlers.import(input))
|
|
751
|
+
);
|
|
752
|
+
server.registerTool(
|
|
753
|
+
"chrona_gc",
|
|
754
|
+
{
|
|
755
|
+
description: "Delete expired memory entries.",
|
|
756
|
+
inputSchema: chronaGcInputSchema,
|
|
757
|
+
outputSchema: chronaGcResultSchema
|
|
758
|
+
},
|
|
759
|
+
async (input) => toToolResult(handlers.gc(input))
|
|
760
|
+
);
|
|
761
|
+
return server;
|
|
762
|
+
}
|
|
763
|
+
async function readRequestBody(request) {
|
|
764
|
+
const chunks = [];
|
|
765
|
+
for await (const chunk of request) {
|
|
766
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk) : chunk);
|
|
767
|
+
}
|
|
768
|
+
const body = Buffer.concat(chunks).toString("utf8").trim();
|
|
769
|
+
return body === "" ? void 0 : JSON.parse(body);
|
|
770
|
+
}
|
|
771
|
+
function sendHttpJson(response, statusCode, payload) {
|
|
772
|
+
response.statusCode = statusCode;
|
|
773
|
+
response.setHeader("content-type", "application/json");
|
|
774
|
+
response.end(JSON.stringify(payload));
|
|
775
|
+
}
|
|
776
|
+
function createChronaMcpHttpServer(dbPath, port) {
|
|
777
|
+
return (0, import_node_http.createServer)(async (request, response) => {
|
|
778
|
+
const requestUrl = new URL(request.url ?? "/", `http://${request.headers.host ?? `127.0.0.1:${port}`}`);
|
|
779
|
+
if (requestUrl.pathname !== "/mcp") {
|
|
780
|
+
sendHttpJson(response, 404, {
|
|
781
|
+
error: {
|
|
782
|
+
code: 404,
|
|
783
|
+
message: "Not found"
|
|
784
|
+
}
|
|
785
|
+
});
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
if (request.method !== "POST") {
|
|
789
|
+
sendHttpJson(response, 405, {
|
|
790
|
+
error: {
|
|
791
|
+
code: 405,
|
|
792
|
+
message: "Method not allowed"
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
const server = createChronaMcpServer(dbPath);
|
|
798
|
+
const transport = new import_streamableHttp.StreamableHTTPServerTransport({
|
|
799
|
+
sessionIdGenerator: void 0
|
|
800
|
+
});
|
|
801
|
+
response.on("close", () => {
|
|
802
|
+
transport.close().catch(() => void 0);
|
|
803
|
+
server.close().catch(() => void 0);
|
|
804
|
+
});
|
|
805
|
+
try {
|
|
806
|
+
const parsedBody = await readRequestBody(request);
|
|
807
|
+
await server.connect(transport);
|
|
808
|
+
await transport.handleRequest(request, response, parsedBody);
|
|
809
|
+
} catch (error) {
|
|
810
|
+
if (!response.headersSent) {
|
|
811
|
+
sendHttpJson(response, 500, {
|
|
812
|
+
error: {
|
|
813
|
+
code: 500,
|
|
814
|
+
message: error instanceof Error ? error.message : String(error)
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
async function startChronaMcpServer(options) {
|
|
822
|
+
const resolvedDbPath = (0, import_node_path2.resolve)(options.dbPath);
|
|
823
|
+
if (options.port !== void 0) {
|
|
824
|
+
const server2 = createChronaMcpHttpServer(resolvedDbPath, options.port);
|
|
825
|
+
await new Promise((resolvePromise, reject) => {
|
|
826
|
+
server2.once("error", reject);
|
|
827
|
+
server2.listen(options.port, "127.0.0.1", () => {
|
|
828
|
+
server2.off("error", reject);
|
|
829
|
+
console.error(`Chrona MCP server listening on http://127.0.0.1:${options.port}/mcp`);
|
|
830
|
+
resolvePromise();
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
const server = createChronaMcpServer(resolvedDbPath);
|
|
836
|
+
const transport = new import_stdio.StdioServerTransport();
|
|
837
|
+
await server.connect(transport);
|
|
838
|
+
}
|
|
416
839
|
// Annotate the CommonJS export names for ESM import in node:
|
|
417
840
|
0 && (module.exports = {
|
|
418
841
|
ChromaStore,
|
|
842
|
+
chronaAddInputSchema,
|
|
843
|
+
chronaAddResultSchema,
|
|
844
|
+
chronaExportInputSchema,
|
|
845
|
+
chronaExportResultSchema,
|
|
846
|
+
chronaGcInputSchema,
|
|
847
|
+
chronaGcResultSchema,
|
|
848
|
+
chronaGetInputSchema,
|
|
849
|
+
chronaGetResultSchema,
|
|
850
|
+
chronaImportInputSchema,
|
|
851
|
+
chronaImportResultSchema,
|
|
852
|
+
chronaSearchInputSchema,
|
|
853
|
+
chronaSearchResultSchema,
|
|
854
|
+
chronaTimelineInputSchema,
|
|
855
|
+
chronaTimelineResultSchema,
|
|
856
|
+
createChronaMcpHandlers,
|
|
857
|
+
createChronaMcpServer,
|
|
419
858
|
memoryScopes,
|
|
420
859
|
memoryTypes,
|
|
421
860
|
normalizeEntry,
|
|
422
861
|
parseMemoryScope,
|
|
423
862
|
parseMemoryType,
|
|
424
863
|
parseSourceKind,
|
|
425
|
-
sourceKinds
|
|
864
|
+
sourceKinds,
|
|
865
|
+
startChronaMcpServer
|
|
426
866
|
});
|
|
427
867
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/types.ts","../src/store.ts","../src/utils.ts","../src/validate.ts"],"sourcesContent":["export * from \"./types.js\";\nexport * from \"./store.js\";\nexport * from \"./validate.js\";\n","export const memoryTypes = [\"decision\", \"preference\", \"fact\", \"incident\", \"constraint\"] as const;\nexport const memoryScopes = [\"user\", \"project\", \"org\", \"shared\"] as const;\nexport const sourceKinds = [\"tool\", \"session\", \"repo\"] as const;\n\nexport type MemoryType = (typeof memoryTypes)[number];\nexport type MemoryScope = (typeof memoryScopes)[number];\nexport type SourceKind = (typeof sourceKinds)[number];\n\nexport interface MemorySource {\n kind: SourceKind;\n value: string;\n}\n\nexport interface MemoryEntry {\n id: string;\n type: MemoryType;\n text: string;\n createdAt: string;\n source: MemorySource;\n confidence: number;\n scope: MemoryScope;\n tags: string[];\n expiresAt?: string;\n links?: string[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface AddMemoryInput {\n id?: string;\n type: MemoryType;\n text: string;\n createdAt?: string;\n source: MemorySource;\n confidence: number;\n scope: MemoryScope;\n tags: string[];\n expiresAt?: string;\n links?: string[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface QueryOptions {\n scopes?: MemoryScope[];\n types?: MemoryType[];\n tags?: string[];\n sourceKind?: SourceKind;\n sourceValue?: string;\n before?: string;\n after?: string;\n includeExpired?: boolean;\n limit?: number;\n}\n\nexport interface SearchOptions extends QueryOptions {\n query: string;\n}\n\nexport interface TimelineOptions extends QueryOptions {\n order?: \"asc\" | \"desc\";\n}\n\nexport interface ExportOptions extends TimelineOptions {}\n\nexport interface ImportResult {\n imported: number;\n updated: number;\n ids: string[];\n}\n\nexport interface GcResult {\n deleted: number;\n ids: string[];\n now: string;\n}\n","import Database from \"better-sqlite3\";\nimport { mkdirSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport type {\n AddMemoryInput,\n ExportOptions,\n GcResult,\n ImportResult,\n MemoryEntry,\n QueryOptions,\n SearchOptions,\n TimelineOptions\n} from \"./types.js\";\nimport { normalizeEntry } from \"./validate.js\";\nimport { serializeJson, toIsoString } from \"./utils.js\";\n\ninterface MemoryRow {\n id: string;\n type: MemoryEntry[\"type\"];\n text: string;\n created_at: string;\n source_kind: MemoryEntry[\"source\"][\"kind\"];\n source_value: string;\n confidence: number;\n scope: MemoryEntry[\"scope\"];\n tags_json: string;\n expires_at: string | null;\n links_json: string;\n metadata_json: string;\n}\n\nexport class ChromaStore {\n readonly path: string;\n readonly db: Database.Database;\n\n constructor(path = resolve(process.cwd(), \".chrona/chrona.db\")) {\n this.path = resolve(path);\n mkdirSync(dirname(this.path), { recursive: true });\n this.db = new Database(this.path);\n this.db.pragma(\"journal_mode = WAL\");\n this.db.pragma(\"foreign_keys = ON\");\n this.db.pragma(\"busy_timeout = 5000\");\n }\n\n init(): void {\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS memories (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n text TEXT NOT NULL,\n created_at TEXT NOT NULL,\n source_kind TEXT NOT NULL,\n source_value TEXT NOT NULL,\n confidence REAL NOT NULL,\n scope TEXT NOT NULL,\n tags_json TEXT NOT NULL,\n expires_at TEXT,\n links_json TEXT NOT NULL,\n metadata_json TEXT NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_memories_created_at ON memories(created_at);\n CREATE INDEX IF NOT EXISTS idx_memories_scope ON memories(scope);\n CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(type);\n CREATE INDEX IF NOT EXISTS idx_memories_expires_at ON memories(expires_at);\n CREATE INDEX IF NOT EXISTS idx_memories_source ON memories(source_kind, source_value);\n `);\n }\n\n close(): void {\n this.db.close();\n }\n\n add(input: AddMemoryInput): MemoryEntry {\n const entry = normalizeEntry(input);\n this.init();\n\n this.db.prepare(`\n INSERT INTO memories (\n id,\n type,\n text,\n created_at,\n source_kind,\n source_value,\n confidence,\n scope,\n tags_json,\n expires_at,\n links_json,\n metadata_json\n ) VALUES (\n @id,\n @type,\n @text,\n @created_at,\n @source_kind,\n @source_value,\n @confidence,\n @scope,\n @tags_json,\n @expires_at,\n @links_json,\n @metadata_json\n )\n `).run(this.toRow(entry));\n\n return entry;\n }\n\n get(id: string): MemoryEntry | null {\n this.init();\n const row = this.db.prepare(\"SELECT * FROM memories WHERE id = ?\").get(id) as MemoryRow | undefined;\n return row ? this.fromRow(row) : null;\n }\n\n search(options: SearchOptions): MemoryEntry[] {\n this.init();\n const { sql, params } = this.buildQuery(\n options,\n [\n \"(\",\n \"lower(text) LIKE @query\",\n \"OR lower(tags_json) LIKE @query\",\n \"OR lower(source_kind || ':' || source_value) LIKE @query\",\n \"OR lower(metadata_json) LIKE @query\",\n \")\"\n ].join(\" \"),\n { query: `%${options.query.toLowerCase()}%` },\n \"ORDER BY created_at DESC, confidence DESC, id ASC\"\n );\n\n return this.db.prepare(sql).all(params).map((row) => this.fromRow(row as MemoryRow));\n }\n\n timeline(options: TimelineOptions = {}): MemoryEntry[] {\n this.init();\n const direction = options.order === \"desc\" ? \"DESC\" : \"ASC\";\n const { sql, params } = this.buildQuery(options, undefined, {}, `ORDER BY created_at ${direction}, id ASC`);\n return this.db.prepare(sql).all(params).map((row) => this.fromRow(row as MemoryRow));\n }\n\n exportJsonl(options: ExportOptions = {}): string {\n return this.timeline(options).map((entry) => JSON.stringify(entry)).join(\"\\n\");\n }\n\n importJsonl(input: string): ImportResult {\n this.init();\n const lines = input.split(/\\r?\\n/).map((line) => line.trim()).filter(Boolean);\n const ids: string[] = [];\n let imported = 0;\n let updated = 0;\n\n const statement = this.db.prepare(`\n INSERT INTO memories (\n id,\n type,\n text,\n created_at,\n source_kind,\n source_value,\n confidence,\n scope,\n tags_json,\n expires_at,\n links_json,\n metadata_json\n ) VALUES (\n @id,\n @type,\n @text,\n @created_at,\n @source_kind,\n @source_value,\n @confidence,\n @scope,\n @tags_json,\n @expires_at,\n @links_json,\n @metadata_json\n )\n ON CONFLICT(id) DO UPDATE SET\n type = excluded.type,\n text = excluded.text,\n created_at = excluded.created_at,\n source_kind = excluded.source_kind,\n source_value = excluded.source_value,\n confidence = excluded.confidence,\n scope = excluded.scope,\n tags_json = excluded.tags_json,\n expires_at = excluded.expires_at,\n links_json = excluded.links_json,\n metadata_json = excluded.metadata_json\n `);\n\n const transaction = this.db.transaction(() => {\n for (const line of lines) {\n const entry = normalizeEntry(JSON.parse(line) as AddMemoryInput);\n const exists = this.get(entry.id);\n statement.run(this.toRow(entry));\n ids.push(entry.id);\n if (exists) {\n updated += 1;\n } else {\n imported += 1;\n }\n }\n });\n\n transaction();\n\n return {\n imported,\n updated,\n ids: [...ids].sort((a, b) => a.localeCompare(b))\n };\n }\n\n gc(now?: string | Date): GcResult {\n this.init();\n const nowIso = toIsoString(now);\n const rows = this.db.prepare(\n \"SELECT id FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ? ORDER BY expires_at ASC, id ASC\"\n ).all(nowIso) as Array<{ id: string }>;\n const ids = rows.map((row) => row.id);\n\n if (ids.length > 0) {\n this.db.prepare(\"DELETE FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ?\").run(nowIso);\n }\n\n return {\n deleted: ids.length,\n ids,\n now: nowIso\n };\n }\n\n private buildQuery(\n options: QueryOptions,\n extraWhere?: string,\n extraParams: Record<string, unknown> = {},\n orderBy = \"ORDER BY created_at ASC, id ASC\"\n ): { sql: string; params: Record<string, unknown> } {\n const where: string[] = [];\n const params: Record<string, unknown> = { ...extraParams };\n\n if (!options.includeExpired) {\n where.push(\"(expires_at IS NULL OR expires_at > @now)\");\n params.now = toIsoString();\n }\n\n if (options.scopes?.length) {\n const placeholders = options.scopes.map((_, index) => `@scope${index}`);\n where.push(`scope IN (${placeholders.join(\", \")})`);\n for (const [index, scope] of options.scopes.entries()) {\n params[`scope${index}`] = scope;\n }\n }\n\n if (options.types?.length) {\n const placeholders = options.types.map((_, index) => `@type${index}`);\n where.push(`type IN (${placeholders.join(\", \")})`);\n for (const [index, type] of options.types.entries()) {\n params[`type${index}`] = type;\n }\n }\n\n if (options.tags?.length) {\n const tagParts: string[] = [];\n for (const [index, tag] of options.tags.entries()) {\n const key = `tag${index}`;\n tagParts.push(`lower(tags_json) LIKE @${key}`);\n params[key] = `%${tag.toLowerCase()}%`;\n }\n where.push(`(${tagParts.join(\" OR \")})`);\n }\n\n if (options.sourceKind) {\n where.push(\"source_kind = @sourceKind\");\n params.sourceKind = options.sourceKind;\n }\n\n if (options.sourceValue) {\n where.push(\"source_value = @sourceValue\");\n params.sourceValue = options.sourceValue;\n }\n\n if (options.before) {\n where.push(\"created_at <= @before\");\n params.before = toIsoString(options.before);\n }\n\n if (options.after) {\n where.push(\"created_at >= @after\");\n params.after = toIsoString(options.after);\n }\n\n if (extraWhere) {\n where.push(extraWhere);\n }\n\n const limit = Math.max(1, Math.min(options.limit ?? 50, 1000));\n params.limit = limit;\n const whereSql = where.length ? `WHERE ${where.join(\" AND \")}` : \"\";\n\n return {\n sql: `SELECT * FROM memories ${whereSql} ${orderBy} LIMIT @limit`,\n params\n };\n }\n\n private toRow(entry: MemoryEntry): Record<string, unknown> {\n return {\n id: entry.id,\n type: entry.type,\n text: entry.text,\n created_at: entry.createdAt,\n source_kind: entry.source.kind,\n source_value: entry.source.value,\n confidence: entry.confidence,\n scope: entry.scope,\n tags_json: serializeJson(entry.tags),\n expires_at: entry.expiresAt ?? null,\n links_json: serializeJson(entry.links ?? []),\n metadata_json: serializeJson(entry.metadata ?? {})\n };\n }\n\n private fromRow(row: MemoryRow): MemoryEntry {\n return {\n id: row.id,\n type: row.type,\n text: row.text,\n createdAt: row.created_at,\n source: {\n kind: row.source_kind,\n value: row.source_value\n },\n confidence: row.confidence,\n scope: row.scope,\n tags: JSON.parse(row.tags_json) as string[],\n expiresAt: row.expires_at ?? undefined,\n links: JSON.parse(row.links_json) as string[],\n metadata: JSON.parse(row.metadata_json) as Record<string, unknown>\n };\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nexport function toIsoString(value?: string | Date): string {\n const date = value instanceof Date ? value : value ? new Date(value) : new Date();\n const iso = date.toISOString();\n\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid date: ${String(value)}`);\n }\n\n return iso;\n}\n\nexport function uniqueSorted(values: string[] | undefined): string[] {\n return [...new Set((values ?? []).map((value) => value.trim()).filter(Boolean))].sort((a, b) => a.localeCompare(b));\n}\n\nexport function normalizeConfidence(value: number): number {\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new Error(\"confidence must be between 0 and 1\");\n }\n\n return Number(value.toFixed(6));\n}\n\nexport function parseJsonObject(value: unknown): Record<string, unknown> | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n\n if (typeof value === \"object\" && !Array.isArray(value)) {\n return value as Record<string, unknown>;\n }\n\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new Error(\"metadata must be an object or JSON object string\");\n }\n\n const parsed = JSON.parse(value) as unknown;\n\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"metadata must be a JSON object\");\n }\n\n return parsed as Record<string, unknown>;\n}\n\nexport function parseCsv(value?: string): string[] {\n if (!value) {\n return [];\n }\n\n return value.split(\",\").map((item) => item.trim()).filter(Boolean);\n}\n\nexport function ensureId(value?: string): string {\n return value?.trim() || randomUUID();\n}\n\nexport function serializeJson(value: unknown): string {\n return JSON.stringify(value ?? {});\n}\n","import {\n memoryScopes,\n memoryTypes,\n sourceKinds,\n type AddMemoryInput,\n type MemoryEntry,\n type MemoryScope,\n type MemoryType,\n type SourceKind\n} from \"./types.js\";\nimport { ensureId, normalizeConfidence, parseJsonObject, toIsoString, uniqueSorted } from \"./utils.js\";\n\nfunction includesValue<T extends string>(values: readonly T[], value: string, label: string): T {\n if (!values.includes(value as T)) {\n throw new Error(`Invalid ${label}: ${value}`);\n }\n\n return value as T;\n}\n\nexport function parseMemoryType(value: string): MemoryType {\n return includesValue(memoryTypes, value, \"type\");\n}\n\nexport function parseMemoryScope(value: string): MemoryScope {\n return includesValue(memoryScopes, value, \"scope\");\n}\n\nexport function parseSourceKind(value: string): SourceKind {\n return includesValue(sourceKinds, value, \"source kind\");\n}\n\nexport function normalizeEntry(input: AddMemoryInput | MemoryEntry): MemoryEntry {\n if (!input.text.trim()) {\n throw new Error(\"text is required\");\n }\n\n if (!input.source?.value?.trim()) {\n throw new Error(\"source.value is required\");\n }\n\n return {\n id: ensureId(input.id),\n type: parseMemoryType(input.type),\n text: input.text.trim(),\n createdAt: toIsoString(input.createdAt),\n source: {\n kind: parseSourceKind(input.source.kind),\n value: input.source.value.trim()\n },\n confidence: normalizeConfidence(input.confidence),\n scope: parseMemoryScope(input.scope),\n tags: uniqueSorted(input.tags),\n expiresAt: input.expiresAt ? toIsoString(input.expiresAt) : undefined,\n links: uniqueSorted(input.links),\n metadata: parseJsonObject(input.metadata)\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAA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K,MAAM,IAAI,aAAa;AAAA,IACxC;AAAA,EACF;AACF;","names":["Database"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/types.ts","../src/store.ts","../src/utils.ts","../src/validate.ts","../src/mcp.ts"],"sourcesContent":["export * from \"./types.js\";\nexport * from \"./store.js\";\nexport * from \"./validate.js\";\nexport * from \"./mcp.js\";\n","export const memoryTypes = [\"decision\", \"preference\", \"fact\", \"incident\", \"constraint\"] as const;\nexport const memoryScopes = [\"user\", \"project\", \"org\", \"shared\"] as const;\nexport const sourceKinds = [\"tool\", \"session\", \"repo\"] as const;\n\nexport type MemoryType = (typeof memoryTypes)[number];\nexport type MemoryScope = (typeof memoryScopes)[number];\nexport type SourceKind = (typeof sourceKinds)[number];\n\nexport interface MemorySource {\n kind: SourceKind;\n value: string;\n}\n\nexport interface MemoryEntry {\n id: string;\n type: MemoryType;\n text: string;\n createdAt: string;\n source: MemorySource;\n confidence: number;\n scope: MemoryScope;\n tags: string[];\n expiresAt?: string;\n links?: string[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface AddMemoryInput {\n id?: string;\n type: MemoryType;\n text: string;\n createdAt?: string;\n source: MemorySource;\n confidence: number;\n scope: MemoryScope;\n tags: string[];\n expiresAt?: string;\n links?: string[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface QueryOptions {\n scopes?: MemoryScope[];\n types?: MemoryType[];\n tags?: string[];\n sourceKind?: SourceKind;\n sourceValue?: string;\n before?: string;\n after?: string;\n includeExpired?: boolean;\n limit?: number;\n}\n\nexport interface SearchOptions extends QueryOptions {\n query: string;\n}\n\nexport interface TimelineOptions extends QueryOptions {\n order?: \"asc\" | \"desc\";\n}\n\nexport interface ExportOptions extends TimelineOptions {}\n\nexport interface ImportResult {\n imported: number;\n updated: number;\n ids: string[];\n}\n\nexport interface GcResult {\n deleted: number;\n ids: string[];\n now: string;\n}\n","import Database from \"better-sqlite3\";\nimport { mkdirSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport type {\n AddMemoryInput,\n ExportOptions,\n GcResult,\n ImportResult,\n MemoryEntry,\n QueryOptions,\n SearchOptions,\n TimelineOptions\n} from \"./types.js\";\nimport { normalizeEntry } from \"./validate.js\";\nimport { serializeJson, toIsoString } from \"./utils.js\";\n\ninterface MemoryRow {\n id: string;\n type: MemoryEntry[\"type\"];\n text: string;\n created_at: string;\n source_kind: MemoryEntry[\"source\"][\"kind\"];\n source_value: string;\n confidence: number;\n scope: MemoryEntry[\"scope\"];\n tags_json: string;\n expires_at: string | null;\n links_json: string;\n metadata_json: string;\n}\n\nexport class ChromaStore {\n readonly path: string;\n readonly db: Database.Database;\n\n constructor(path = resolve(process.cwd(), \".chrona/chrona.db\")) {\n this.path = resolve(path);\n mkdirSync(dirname(this.path), { recursive: true });\n this.db = new Database(this.path);\n this.db.pragma(\"journal_mode = WAL\");\n this.db.pragma(\"foreign_keys = ON\");\n this.db.pragma(\"busy_timeout = 5000\");\n }\n\n init(): void {\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS memories (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n text TEXT NOT NULL,\n created_at TEXT NOT NULL,\n source_kind TEXT NOT NULL,\n source_value TEXT NOT NULL,\n confidence REAL NOT NULL,\n scope TEXT NOT NULL,\n tags_json TEXT NOT NULL,\n expires_at TEXT,\n links_json TEXT NOT NULL,\n metadata_json TEXT NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_memories_created_at ON memories(created_at);\n CREATE INDEX IF NOT EXISTS idx_memories_scope ON memories(scope);\n CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(type);\n CREATE INDEX IF NOT EXISTS idx_memories_expires_at ON memories(expires_at);\n CREATE INDEX IF NOT EXISTS idx_memories_source ON memories(source_kind, source_value);\n `);\n }\n\n close(): void {\n this.db.close();\n }\n\n add(input: AddMemoryInput): MemoryEntry {\n const entry = normalizeEntry(input);\n this.init();\n\n this.db.prepare(`\n INSERT INTO memories (\n id,\n type,\n text,\n created_at,\n source_kind,\n source_value,\n confidence,\n scope,\n tags_json,\n expires_at,\n links_json,\n metadata_json\n ) VALUES (\n @id,\n @type,\n @text,\n @created_at,\n @source_kind,\n @source_value,\n @confidence,\n @scope,\n @tags_json,\n @expires_at,\n @links_json,\n @metadata_json\n )\n `).run(this.toRow(entry));\n\n return entry;\n }\n\n get(id: string): MemoryEntry | null {\n this.init();\n const row = this.db.prepare(\"SELECT * FROM memories WHERE id = ?\").get(id) as MemoryRow | undefined;\n return row ? this.fromRow(row) : null;\n }\n\n search(options: SearchOptions): MemoryEntry[] {\n this.init();\n const { sql, params } = this.buildQuery(\n options,\n [\n \"(\",\n \"lower(text) LIKE @query\",\n \"OR lower(tags_json) LIKE @query\",\n \"OR lower(source_kind || ':' || source_value) LIKE @query\",\n \"OR lower(metadata_json) LIKE @query\",\n \")\"\n ].join(\" \"),\n { query: `%${options.query.toLowerCase()}%` },\n \"ORDER BY created_at DESC, confidence DESC, id ASC\"\n );\n\n return this.db.prepare(sql).all(params).map((row) => this.fromRow(row as MemoryRow));\n }\n\n timeline(options: TimelineOptions = {}): MemoryEntry[] {\n this.init();\n const direction = options.order === \"desc\" ? \"DESC\" : \"ASC\";\n const { sql, params } = this.buildQuery(options, undefined, {}, `ORDER BY created_at ${direction}, id ASC`);\n return this.db.prepare(sql).all(params).map((row) => this.fromRow(row as MemoryRow));\n }\n\n exportJsonl(options: ExportOptions = {}): string {\n return this.timeline(options).map((entry) => JSON.stringify(entry)).join(\"\\n\");\n }\n\n importJsonl(input: string): ImportResult {\n this.init();\n const lines = input.split(/\\r?\\n/).map((line) => line.trim()).filter(Boolean);\n const ids: string[] = [];\n let imported = 0;\n let updated = 0;\n\n const statement = this.db.prepare(`\n INSERT INTO memories (\n id,\n type,\n text,\n created_at,\n source_kind,\n source_value,\n confidence,\n scope,\n tags_json,\n expires_at,\n links_json,\n metadata_json\n ) VALUES (\n @id,\n @type,\n @text,\n @created_at,\n @source_kind,\n @source_value,\n @confidence,\n @scope,\n @tags_json,\n @expires_at,\n @links_json,\n @metadata_json\n )\n ON CONFLICT(id) DO UPDATE SET\n type = excluded.type,\n text = excluded.text,\n created_at = excluded.created_at,\n source_kind = excluded.source_kind,\n source_value = excluded.source_value,\n confidence = excluded.confidence,\n scope = excluded.scope,\n tags_json = excluded.tags_json,\n expires_at = excluded.expires_at,\n links_json = excluded.links_json,\n metadata_json = excluded.metadata_json\n `);\n\n const transaction = this.db.transaction(() => {\n for (const line of lines) {\n const entry = normalizeEntry(JSON.parse(line) as AddMemoryInput);\n const exists = this.get(entry.id);\n statement.run(this.toRow(entry));\n ids.push(entry.id);\n if (exists) {\n updated += 1;\n } else {\n imported += 1;\n }\n }\n });\n\n transaction();\n\n return {\n imported,\n updated,\n ids: [...ids].sort((a, b) => a.localeCompare(b))\n };\n }\n\n gc(now?: string | Date): GcResult {\n this.init();\n const nowIso = toIsoString(now);\n const rows = this.db.prepare(\n \"SELECT id FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ? ORDER BY expires_at ASC, id ASC\"\n ).all(nowIso) as Array<{ id: string }>;\n const ids = rows.map((row) => row.id);\n\n if (ids.length > 0) {\n this.db.prepare(\"DELETE FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ?\").run(nowIso);\n }\n\n return {\n deleted: ids.length,\n ids,\n now: nowIso\n };\n }\n\n private buildQuery(\n options: QueryOptions,\n extraWhere?: string,\n extraParams: Record<string, unknown> = {},\n orderBy = \"ORDER BY created_at ASC, id ASC\"\n ): { sql: string; params: Record<string, unknown> } {\n const where: string[] = [];\n const params: Record<string, unknown> = { ...extraParams };\n\n if (!options.includeExpired) {\n where.push(\"(expires_at IS NULL OR expires_at > @now)\");\n params.now = toIsoString();\n }\n\n if (options.scopes?.length) {\n const placeholders = options.scopes.map((_, index) => `@scope${index}`);\n where.push(`scope IN (${placeholders.join(\", \")})`);\n for (const [index, scope] of options.scopes.entries()) {\n params[`scope${index}`] = scope;\n }\n }\n\n if (options.types?.length) {\n const placeholders = options.types.map((_, index) => `@type${index}`);\n where.push(`type IN (${placeholders.join(\", \")})`);\n for (const [index, type] of options.types.entries()) {\n params[`type${index}`] = type;\n }\n }\n\n if (options.tags?.length) {\n const tagParts: string[] = [];\n for (const [index, tag] of options.tags.entries()) {\n const key = `tag${index}`;\n tagParts.push(`lower(tags_json) LIKE @${key}`);\n params[key] = `%${tag.toLowerCase()}%`;\n }\n where.push(`(${tagParts.join(\" OR \")})`);\n }\n\n if (options.sourceKind) {\n where.push(\"source_kind = @sourceKind\");\n params.sourceKind = options.sourceKind;\n }\n\n if (options.sourceValue) {\n where.push(\"source_value = @sourceValue\");\n params.sourceValue = options.sourceValue;\n }\n\n if (options.before) {\n where.push(\"created_at <= @before\");\n params.before = toIsoString(options.before);\n }\n\n if (options.after) {\n where.push(\"created_at >= @after\");\n params.after = toIsoString(options.after);\n }\n\n if (extraWhere) {\n where.push(extraWhere);\n }\n\n const limit = Math.max(1, Math.min(options.limit ?? 50, 1000));\n params.limit = limit;\n const whereSql = where.length ? `WHERE ${where.join(\" AND \")}` : \"\";\n\n return {\n sql: `SELECT * FROM memories ${whereSql} ${orderBy} LIMIT @limit`,\n params\n };\n }\n\n private toRow(entry: MemoryEntry): Record<string, unknown> {\n return {\n id: entry.id,\n type: entry.type,\n text: entry.text,\n created_at: entry.createdAt,\n source_kind: entry.source.kind,\n source_value: entry.source.value,\n confidence: entry.confidence,\n scope: entry.scope,\n tags_json: serializeJson(entry.tags),\n expires_at: entry.expiresAt ?? null,\n links_json: serializeJson(entry.links ?? []),\n metadata_json: serializeJson(entry.metadata ?? {})\n };\n }\n\n private fromRow(row: MemoryRow): MemoryEntry {\n return {\n id: row.id,\n type: row.type,\n text: row.text,\n createdAt: row.created_at,\n source: {\n kind: row.source_kind,\n value: row.source_value\n },\n confidence: row.confidence,\n scope: row.scope,\n tags: JSON.parse(row.tags_json) as string[],\n expiresAt: row.expires_at ?? undefined,\n links: JSON.parse(row.links_json) as string[],\n metadata: JSON.parse(row.metadata_json) as Record<string, unknown>\n };\n }\n}\n","import { randomUUID } from \"node:crypto\";\n\nexport function toIsoString(value?: string | Date): string {\n const date = value instanceof Date ? value : value ? new Date(value) : new Date();\n const iso = date.toISOString();\n\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid date: ${String(value)}`);\n }\n\n return iso;\n}\n\nexport function uniqueSorted(values: string[] | undefined): string[] {\n return [...new Set((values ?? []).map((value) => value.trim()).filter(Boolean))].sort((a, b) => a.localeCompare(b));\n}\n\nexport function normalizeConfidence(value: number): number {\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new Error(\"confidence must be between 0 and 1\");\n }\n\n return Number(value.toFixed(6));\n}\n\nexport function parseJsonObject(value: unknown): Record<string, unknown> | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n\n if (typeof value === \"object\" && !Array.isArray(value)) {\n return value as Record<string, unknown>;\n }\n\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new Error(\"metadata must be an object or JSON object string\");\n }\n\n const parsed = JSON.parse(value) as unknown;\n\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"metadata must be a JSON object\");\n }\n\n return parsed as Record<string, unknown>;\n}\n\nexport function parseCsv(value?: string): string[] {\n if (!value) {\n return [];\n }\n\n return value.split(\",\").map((item) => item.trim()).filter(Boolean);\n}\n\nexport function ensureId(value?: string): string {\n return value?.trim() || randomUUID();\n}\n\nexport function serializeJson(value: unknown): string {\n return JSON.stringify(value ?? {});\n}\n","import {\n memoryScopes,\n memoryTypes,\n sourceKinds,\n type AddMemoryInput,\n type MemoryEntry,\n type MemoryScope,\n type MemoryType,\n type SourceKind\n} from \"./types.js\";\nimport { ensureId, normalizeConfidence, parseJsonObject, toIsoString, uniqueSorted } from \"./utils.js\";\n\nfunction includesValue<T extends string>(values: readonly T[], value: string, label: string): T {\n if (!values.includes(value as T)) {\n throw new Error(`Invalid ${label}: ${value}`);\n }\n\n return value as T;\n}\n\nexport function parseMemoryType(value: string): MemoryType {\n return includesValue(memoryTypes, value, \"type\");\n}\n\nexport function parseMemoryScope(value: string): MemoryScope {\n return includesValue(memoryScopes, value, \"scope\");\n}\n\nexport function parseSourceKind(value: string): SourceKind {\n return includesValue(sourceKinds, value, \"source kind\");\n}\n\nexport function normalizeEntry(input: AddMemoryInput | MemoryEntry): MemoryEntry {\n if (!input.text.trim()) {\n throw new Error(\"text is required\");\n }\n\n if (!input.source?.value?.trim()) {\n throw new Error(\"source.value is required\");\n }\n\n return {\n id: ensureId(input.id),\n type: parseMemoryType(input.type),\n text: input.text.trim(),\n createdAt: toIsoString(input.createdAt),\n source: {\n kind: parseSourceKind(input.source.kind),\n value: input.source.value.trim()\n },\n confidence: normalizeConfidence(input.confidence),\n scope: parseMemoryScope(input.scope),\n tags: uniqueSorted(input.tags),\n expiresAt: input.expiresAt ? toIsoString(input.expiresAt) : undefined,\n links: uniqueSorted(input.links),\n metadata: parseJsonObject(input.metadata)\n };\n}\n","import { createServer, type IncomingMessage, type Server as HttpServer, type ServerResponse } from \"node:http\";\nimport { resolve } from \"node:path\";\nimport { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport { StreamableHTTPServerTransport } from \"@modelcontextprotocol/sdk/server/streamableHttp.js\";\nimport * as z from \"zod/v4\";\nimport { ChromaStore } from \"./store.js\";\nimport { memoryScopes, memoryTypes, sourceKinds, type AddMemoryInput, type MemoryEntry, type QueryOptions } from \"./types.js\";\n\nconst memoryTypeSchema = z.enum(memoryTypes);\nconst memoryScopeSchema = z.enum(memoryScopes);\nconst sourceKindSchema = z.enum(sourceKinds);\nconst jsonValueSchema = z.json();\nconst jsonObjectSchema = z.record(z.string(), jsonValueSchema);\nconst sourceSchema = z.object({\n kind: sourceKindSchema,\n value: z.string().trim().min(1)\n});\nconst memoryEntrySchema = z.object({\n id: z.string(),\n type: memoryTypeSchema,\n text: z.string(),\n createdAt: z.string(),\n source: sourceSchema,\n confidence: z.number(),\n scope: memoryScopeSchema,\n tags: z.array(z.string()),\n expiresAt: z.string().optional(),\n links: z.array(z.string()),\n metadata: jsonObjectSchema\n});\nconst queryOptionsSchema = z.object({\n scopes: z.array(memoryScopeSchema).optional(),\n types: z.array(memoryTypeSchema).optional(),\n tags: z.array(z.string()).optional(),\n sourceKind: sourceKindSchema.optional(),\n sourceValue: z.string().trim().min(1).optional(),\n before: z.string().optional(),\n after: z.string().optional(),\n includeExpired: z.boolean().default(false)\n});\n\nexport const chronaAddInputSchema = z.object({\n id: z.string().trim().min(1).optional(),\n type: memoryTypeSchema,\n text: z.string().trim().min(1),\n createdAt: z.string().optional(),\n source: sourceSchema,\n confidence: z.number().min(0).max(1),\n scope: memoryScopeSchema,\n tags: z.array(z.string()).default([]),\n expiresAt: z.string().optional(),\n links: z.array(z.string()).default([]),\n metadata: jsonObjectSchema.default({})\n});\nexport const chronaAddResultSchema = z.object({\n entry: memoryEntrySchema\n});\nexport const chronaGetInputSchema = z.object({\n id: z.string().trim().min(1)\n});\nexport const chronaGetResultSchema = z.object({\n entry: memoryEntrySchema.nullable()\n});\nexport const chronaSearchInputSchema = queryOptionsSchema.extend({\n query: z.string().trim().min(1),\n limit: z.number().int().min(1).max(1000).default(50)\n});\nexport const chronaSearchResultSchema = z.object({\n count: z.number().int().min(0),\n items: z.array(memoryEntrySchema)\n});\nexport const chronaTimelineInputSchema = queryOptionsSchema.extend({\n order: z.enum([\"asc\", \"desc\"]).default(\"asc\"),\n limit: z.number().int().min(1).max(1000).default(50)\n});\nexport const chronaTimelineResultSchema = z.object({\n count: z.number().int().min(0),\n items: z.array(memoryEntrySchema)\n});\nexport const chronaExportInputSchema = queryOptionsSchema.extend({\n order: z.enum([\"asc\", \"desc\"]).default(\"asc\"),\n limit: z.number().int().min(1).max(1000).default(1000)\n});\nexport const chronaExportResultSchema = z.object({\n count: z.number().int().min(0),\n jsonl: z.string()\n});\nexport const chronaImportInputSchema = z.object({\n jsonl: z.string()\n});\nexport const chronaImportResultSchema = z.object({\n imported: z.number().int().min(0),\n updated: z.number().int().min(0),\n ids: z.array(z.string())\n});\nexport const chronaGcInputSchema = z.object({\n now: z.string().optional()\n});\nexport const chronaGcResultSchema = z.object({\n deleted: z.number().int().min(0),\n ids: z.array(z.string()),\n now: z.string()\n});\n\nexport type ChronaAddInput = z.input<typeof chronaAddInputSchema>;\nexport type ChronaAddResult = z.infer<typeof chronaAddResultSchema>;\nexport type ChronaGetInput = z.input<typeof chronaGetInputSchema>;\nexport type ChronaGetResult = z.infer<typeof chronaGetResultSchema>;\nexport type ChronaSearchInput = z.input<typeof chronaSearchInputSchema>;\nexport type ChronaSearchResult = z.infer<typeof chronaSearchResultSchema>;\nexport type ChronaTimelineInput = z.input<typeof chronaTimelineInputSchema>;\nexport type ChronaTimelineResult = z.infer<typeof chronaTimelineResultSchema>;\nexport type ChronaExportInput = z.input<typeof chronaExportInputSchema>;\nexport type ChronaExportResult = z.infer<typeof chronaExportResultSchema>;\nexport type ChronaImportInput = z.input<typeof chronaImportInputSchema>;\nexport type ChronaImportResult = z.infer<typeof chronaImportResultSchema>;\nexport type ChronaGcInput = z.input<typeof chronaGcInputSchema>;\nexport type ChronaGcResult = z.infer<typeof chronaGcResultSchema>;\n\nexport interface ChronaMcpHandlers {\n add(input: ChronaAddInput): ChronaAddResult;\n get(input: ChronaGetInput): ChronaGetResult;\n search(input: ChronaSearchInput): ChronaSearchResult;\n timeline(input: ChronaTimelineInput): ChronaTimelineResult;\n export(input: ChronaExportInput): ChronaExportResult;\n import(input: ChronaImportInput): ChronaImportResult;\n gc(input?: ChronaGcInput): ChronaGcResult;\n}\n\ntype JsonValue = z.infer<typeof jsonValueSchema>;\ntype JsonObject = z.infer<typeof jsonObjectSchema>;\n\nexport interface StartChronaMcpServerOptions {\n dbPath: string;\n port?: number;\n}\n\nfunction withStore<T>(dbPath: string, run: (store: ChromaStore) => T): T {\n const store = new ChromaStore(dbPath);\n\n try {\n return run(store);\n } finally {\n store.close();\n }\n}\n\nfunction toQueryOptions(input: z.infer<typeof queryOptionsSchema> & { limit?: number; order?: \"asc\" | \"desc\" }): QueryOptions {\n return {\n scopes: input.scopes,\n types: input.types,\n tags: input.tags,\n sourceKind: input.sourceKind,\n sourceValue: input.sourceValue,\n before: input.before,\n after: input.after,\n includeExpired: input.includeExpired,\n limit: input.limit\n };\n}\n\nfunction sortJsonValue(value: JsonValue): JsonValue {\n if (Array.isArray(value)) {\n return value.map(sortJsonValue);\n }\n\n if (value && typeof value === \"object\") {\n return Object.fromEntries(\n Object.entries(value)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, innerValue]) => [key, sortJsonValue(innerValue)])\n );\n }\n\n return value;\n}\n\nfunction toOutputEntry(entry: MemoryEntry): z.infer<typeof memoryEntrySchema> {\n const base = {\n id: entry.id,\n type: entry.type,\n text: entry.text,\n createdAt: entry.createdAt,\n source: {\n kind: entry.source.kind,\n value: entry.source.value\n },\n confidence: entry.confidence,\n scope: entry.scope,\n tags: [...entry.tags],\n links: [...(entry.links ?? [])],\n metadata: sortJsonValue((entry.metadata ?? {}) as JsonObject) as JsonObject\n };\n\n if (entry.expiresAt) {\n return {\n ...base,\n expiresAt: entry.expiresAt\n };\n }\n\n return base;\n}\n\nfunction toToolResult<T extends object>(value: T): { content: Array<{ type: \"text\"; text: string }>; structuredContent: T } {\n const stableValue = sortJsonValue(value as JsonValue) as T;\n\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(stableValue, null, 2)\n }\n ],\n structuredContent: stableValue\n };\n}\n\nfunction lineCount(value: string): number {\n return value === \"\" ? 0 : value.split(\"\\n\").length;\n}\n\nexport function createChronaMcpHandlers(dbPath: string): ChronaMcpHandlers {\n const resolvedDbPath = resolve(dbPath);\n\n return {\n add(input) {\n const args = chronaAddInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => {\n const entry = store.add({\n id: args.id,\n type: args.type,\n text: args.text,\n createdAt: args.createdAt,\n source: args.source,\n confidence: args.confidence,\n scope: args.scope,\n tags: args.tags,\n expiresAt: args.expiresAt,\n links: args.links,\n metadata: args.metadata\n } satisfies AddMemoryInput);\n\n return {\n entry: toOutputEntry(entry)\n };\n });\n },\n get(input) {\n const args = chronaGetInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => {\n const entry = store.get(args.id);\n\n return {\n entry: entry ? toOutputEntry(entry) : null\n };\n });\n },\n search(input) {\n const args = chronaSearchInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => {\n const items = store.search({\n ...toQueryOptions(args),\n query: args.query\n }).map(toOutputEntry);\n\n return {\n count: items.length,\n items\n };\n });\n },\n timeline(input) {\n const args = chronaTimelineInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => {\n const items = store.timeline({\n ...toQueryOptions(args),\n order: args.order\n }).map(toOutputEntry);\n\n return {\n count: items.length,\n items\n };\n });\n },\n export(input) {\n const args = chronaExportInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => {\n const jsonl = store.exportJsonl({\n ...toQueryOptions(args),\n order: args.order\n });\n\n return {\n count: lineCount(jsonl),\n jsonl\n };\n });\n },\n import(input) {\n const args = chronaImportInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => store.importJsonl(args.jsonl));\n },\n gc(input = {}) {\n const args = chronaGcInputSchema.parse(input);\n\n return withStore(resolvedDbPath, (store) => store.gc(args.now));\n }\n };\n}\n\nexport function createChronaMcpServer(dbPath: string): McpServer {\n const handlers = createChronaMcpHandlers(dbPath);\n const server = new McpServer({\n name: \"chrona\",\n version: \"0.1.1\"\n });\n\n server.registerTool(\n \"chrona_add\",\n {\n description: \"Add a memory entry to Chrona.\",\n inputSchema: chronaAddInputSchema,\n outputSchema: chronaAddResultSchema\n },\n async (input) => toToolResult(handlers.add(input))\n );\n\n server.registerTool(\n \"chrona_get\",\n {\n description: \"Get a memory entry by id.\",\n inputSchema: chronaGetInputSchema,\n outputSchema: chronaGetResultSchema,\n annotations: { readOnlyHint: true }\n },\n async (input) => toToolResult(handlers.get(input))\n );\n\n server.registerTool(\n \"chrona_search\",\n {\n description: \"Search memory entries with deterministic ordering.\",\n inputSchema: chronaSearchInputSchema,\n outputSchema: chronaSearchResultSchema,\n annotations: { readOnlyHint: true }\n },\n async (input) => toToolResult(handlers.search(input))\n );\n\n server.registerTool(\n \"chrona_timeline\",\n {\n description: \"List memory entries in time order.\",\n inputSchema: chronaTimelineInputSchema,\n outputSchema: chronaTimelineResultSchema,\n annotations: { readOnlyHint: true }\n },\n async (input) => toToolResult(handlers.timeline(input))\n );\n\n server.registerTool(\n \"chrona_export\",\n {\n description: \"Export matching entries as deterministic JSONL.\",\n inputSchema: chronaExportInputSchema,\n outputSchema: chronaExportResultSchema,\n annotations: { readOnlyHint: true }\n },\n async (input) => toToolResult(handlers.export(input))\n );\n\n server.registerTool(\n \"chrona_import\",\n {\n description: \"Import entries from JSONL.\",\n inputSchema: chronaImportInputSchema,\n outputSchema: chronaImportResultSchema\n },\n async (input) => toToolResult(handlers.import(input))\n );\n\n server.registerTool(\n \"chrona_gc\",\n {\n description: \"Delete expired memory entries.\",\n inputSchema: chronaGcInputSchema,\n outputSchema: chronaGcResultSchema\n },\n async (input) => toToolResult(handlers.gc(input))\n );\n\n return server;\n}\n\nasync function readRequestBody(request: IncomingMessage): Promise<unknown> {\n const chunks: Buffer[] = [];\n\n for await (const chunk of request) {\n chunks.push(typeof chunk === \"string\" ? Buffer.from(chunk) : chunk);\n }\n\n const body = Buffer.concat(chunks).toString(\"utf8\").trim();\n return body === \"\" ? undefined : JSON.parse(body);\n}\n\nfunction sendHttpJson(response: ServerResponse, statusCode: number, payload: unknown): void {\n response.statusCode = statusCode;\n response.setHeader(\"content-type\", \"application/json\");\n response.end(JSON.stringify(payload));\n}\n\nfunction createChronaMcpHttpServer(dbPath: string, port: number): HttpServer {\n return createServer(async (request, response) => {\n const requestUrl = new URL(request.url ?? \"/\", `http://${request.headers.host ?? `127.0.0.1:${port}`}`);\n\n if (requestUrl.pathname !== \"/mcp\") {\n sendHttpJson(response, 404, {\n error: {\n code: 404,\n message: \"Not found\"\n }\n });\n return;\n }\n\n if (request.method !== \"POST\") {\n sendHttpJson(response, 405, {\n error: {\n code: 405,\n message: \"Method not allowed\"\n }\n });\n return;\n }\n\n const server = createChronaMcpServer(dbPath);\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined\n });\n\n response.on(\"close\", () => {\n transport.close().catch(() => undefined);\n server.close().catch(() => undefined);\n });\n\n try {\n const parsedBody = await readRequestBody(request);\n await server.connect(transport);\n await transport.handleRequest(request, response, parsedBody);\n } catch (error) {\n if (!response.headersSent) {\n sendHttpJson(response, 500, {\n error: {\n code: 500,\n message: error instanceof Error ? error.message : String(error)\n }\n });\n }\n }\n });\n}\n\nexport async function startChronaMcpServer(options: StartChronaMcpServerOptions): Promise<void> {\n const resolvedDbPath = resolve(options.dbPath);\n\n if (options.port !== undefined) {\n const server = createChronaMcpHttpServer(resolvedDbPath, options.port);\n\n await new Promise<void>((resolvePromise, reject) => {\n server.once(\"error\", reject);\n server.listen(options.port, \"127.0.0.1\", () => {\n server.off(\"error\", reject);\n console.error(`Chrona MCP server listening on http://127.0.0.1:${options.port}/mcp`);\n resolvePromise();\n });\n });\n\n return;\n }\n\n const server = createChronaMcpServer(resolvedDbPath);\n const transport = new StdioServerTransport();\n await server.connect(transport);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,cAAc,CAAC,YAAY,cAAc,QAAQ,YAAY,YAAY;AAC/E,IAAM,eAAe,CAAC,QAAQ,WAAW,OAAO,QAAQ;AACxD,IAAM,cAAc,CAAC,QAAQ,WAAW,MAAM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