mindcache 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cloud/index.d.mts +2 -2
- package/dist/cloud/index.d.ts +2 -2
- package/dist/cloud/index.js +500 -50
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/index.mjs +500 -50
- package/dist/cloud/index.mjs.map +1 -1
- package/dist/{index-CFJtj3DL.d.mts → index-XM7bmK7C.d.mts} +105 -13
- package/dist/{index-CFJtj3DL.d.ts → index-XM7bmK7C.d.ts} +105 -13
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +500 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cloud/index.mjs
CHANGED
|
@@ -297,11 +297,16 @@ var init_CloudAdapter = __esm({
|
|
|
297
297
|
|
|
298
298
|
// src/core/types.ts
|
|
299
299
|
var DEFAULT_KEY_ATTRIBUTES = {
|
|
300
|
+
type: "text",
|
|
301
|
+
contentTags: [],
|
|
302
|
+
systemTags: ["prompt"],
|
|
303
|
+
// visible by default
|
|
304
|
+
zIndex: 0,
|
|
305
|
+
// Legacy - derived from systemTags
|
|
300
306
|
readonly: false,
|
|
301
307
|
visible: true,
|
|
302
308
|
hardcoded: false,
|
|
303
309
|
template: false,
|
|
304
|
-
type: "text",
|
|
305
310
|
tags: []
|
|
306
311
|
};
|
|
307
312
|
|
|
@@ -318,7 +323,12 @@ var MindCache = class {
|
|
|
318
323
|
_isLoaded = true;
|
|
319
324
|
// Default true for local mode
|
|
320
325
|
_cloudConfig = null;
|
|
326
|
+
// Access level for system operations
|
|
327
|
+
_accessLevel = "user";
|
|
321
328
|
constructor(options) {
|
|
329
|
+
if (options?.accessLevel) {
|
|
330
|
+
this._accessLevel = options.accessLevel;
|
|
331
|
+
}
|
|
322
332
|
if (options?.cloud) {
|
|
323
333
|
this._cloudConfig = options.cloud;
|
|
324
334
|
this._isLoaded = false;
|
|
@@ -326,6 +336,18 @@ var MindCache = class {
|
|
|
326
336
|
this._initCloud();
|
|
327
337
|
}
|
|
328
338
|
}
|
|
339
|
+
/**
|
|
340
|
+
* Get the current access level
|
|
341
|
+
*/
|
|
342
|
+
get accessLevel() {
|
|
343
|
+
return this._accessLevel;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Check if this instance has system-level access
|
|
347
|
+
*/
|
|
348
|
+
get hasSystemAccess() {
|
|
349
|
+
return this._accessLevel === "system";
|
|
350
|
+
}
|
|
329
351
|
async _initCloud() {
|
|
330
352
|
if (!this._cloudConfig) {
|
|
331
353
|
return;
|
|
@@ -489,11 +511,16 @@ var MindCache = class {
|
|
|
489
511
|
get_attributes(key) {
|
|
490
512
|
if (key === "$date" || key === "$time") {
|
|
491
513
|
return {
|
|
514
|
+
type: "text",
|
|
515
|
+
contentTags: [],
|
|
516
|
+
systemTags: ["prompt", "readonly", "protected"],
|
|
517
|
+
zIndex: 999999,
|
|
518
|
+
// System keys appear last
|
|
519
|
+
// Legacy attributes
|
|
492
520
|
readonly: true,
|
|
493
521
|
visible: true,
|
|
494
522
|
hardcoded: true,
|
|
495
523
|
template: false,
|
|
496
|
-
type: "text",
|
|
497
524
|
tags: []
|
|
498
525
|
};
|
|
499
526
|
}
|
|
@@ -506,18 +533,98 @@ var MindCache = class {
|
|
|
506
533
|
return;
|
|
507
534
|
}
|
|
508
535
|
const existingEntry = this.stm[key];
|
|
509
|
-
const
|
|
536
|
+
const wasHardcoded = existingEntry?.attributes.hardcoded || existingEntry?.attributes.systemTags?.includes("protected");
|
|
537
|
+
const baseAttributes = existingEntry ? {
|
|
538
|
+
...existingEntry.attributes,
|
|
539
|
+
contentTags: [...existingEntry.attributes.contentTags || []],
|
|
540
|
+
systemTags: [...existingEntry.attributes.systemTags || []],
|
|
541
|
+
tags: [...existingEntry.attributes.tags || []],
|
|
542
|
+
zIndex: existingEntry.attributes.zIndex ?? 0
|
|
543
|
+
} : {
|
|
544
|
+
...DEFAULT_KEY_ATTRIBUTES,
|
|
545
|
+
contentTags: [],
|
|
546
|
+
// Fresh array
|
|
547
|
+
systemTags: ["prompt"],
|
|
548
|
+
// Fresh array with default
|
|
549
|
+
tags: [],
|
|
550
|
+
// Fresh array
|
|
551
|
+
zIndex: 0
|
|
552
|
+
};
|
|
510
553
|
const finalAttributes = attributes ? { ...baseAttributes, ...attributes } : baseAttributes;
|
|
511
|
-
if (
|
|
512
|
-
finalAttributes.
|
|
513
|
-
|
|
554
|
+
if (attributes) {
|
|
555
|
+
let systemTags2 = [...finalAttributes.systemTags || []];
|
|
556
|
+
if ("readonly" in attributes) {
|
|
557
|
+
if (attributes.readonly && !systemTags2.includes("readonly")) {
|
|
558
|
+
systemTags2.push("readonly");
|
|
559
|
+
} else if (!attributes.readonly && !wasHardcoded) {
|
|
560
|
+
systemTags2 = systemTags2.filter((t) => t !== "readonly");
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if ("visible" in attributes) {
|
|
564
|
+
if (attributes.visible && !systemTags2.includes("prompt")) {
|
|
565
|
+
systemTags2.push("prompt");
|
|
566
|
+
} else if (!attributes.visible) {
|
|
567
|
+
systemTags2 = systemTags2.filter((t) => t !== "prompt");
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if ("hardcoded" in attributes) {
|
|
571
|
+
if (attributes.hardcoded && !systemTags2.includes("protected")) {
|
|
572
|
+
systemTags2.push("protected");
|
|
573
|
+
} else if (!attributes.hardcoded && !wasHardcoded) {
|
|
574
|
+
systemTags2 = systemTags2.filter((t) => t !== "protected");
|
|
575
|
+
}
|
|
576
|
+
if (wasHardcoded && !systemTags2.includes("protected")) {
|
|
577
|
+
systemTags2.push("protected");
|
|
578
|
+
}
|
|
579
|
+
} else if (wasHardcoded) {
|
|
580
|
+
if (!systemTags2.includes("protected")) {
|
|
581
|
+
systemTags2.push("protected");
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
if ("template" in attributes) {
|
|
585
|
+
if (attributes.template && !wasHardcoded && !systemTags2.includes("template")) {
|
|
586
|
+
systemTags2.push("template");
|
|
587
|
+
} else if (!attributes.template || wasHardcoded) {
|
|
588
|
+
systemTags2 = systemTags2.filter((t) => t !== "template");
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
finalAttributes.systemTags = systemTags2;
|
|
592
|
+
} else if (wasHardcoded) {
|
|
593
|
+
let systemTags2 = [...finalAttributes.systemTags || []];
|
|
594
|
+
if (!systemTags2.includes("protected")) {
|
|
595
|
+
systemTags2.push("protected");
|
|
596
|
+
}
|
|
597
|
+
if (!systemTags2.includes("readonly")) {
|
|
598
|
+
systemTags2.push("readonly");
|
|
599
|
+
}
|
|
600
|
+
systemTags2 = systemTags2.filter((t) => t !== "template");
|
|
601
|
+
finalAttributes.systemTags = systemTags2;
|
|
602
|
+
}
|
|
603
|
+
let systemTags = finalAttributes.systemTags || [];
|
|
604
|
+
if (wasHardcoded && !systemTags.includes("protected")) {
|
|
605
|
+
systemTags = [...systemTags, "protected"];
|
|
606
|
+
}
|
|
607
|
+
if (systemTags.includes("protected")) {
|
|
608
|
+
if (!systemTags.includes("readonly")) {
|
|
609
|
+
systemTags = [...systemTags, "readonly"];
|
|
610
|
+
}
|
|
611
|
+
systemTags = systemTags.filter((t) => t !== "template");
|
|
612
|
+
finalAttributes.systemTags = systemTags;
|
|
613
|
+
}
|
|
614
|
+
finalAttributes.readonly = systemTags.includes("readonly");
|
|
615
|
+
finalAttributes.visible = systemTags.includes("prompt");
|
|
616
|
+
finalAttributes.hardcoded = wasHardcoded || systemTags.includes("protected");
|
|
617
|
+
finalAttributes.template = systemTags.includes("template");
|
|
618
|
+
if (attributes && "tags" in attributes && attributes.tags) {
|
|
619
|
+
finalAttributes.contentTags = [...attributes.tags];
|
|
514
620
|
}
|
|
621
|
+
finalAttributes.tags = [...finalAttributes.contentTags || []];
|
|
515
622
|
this.stm[key] = {
|
|
516
623
|
value,
|
|
517
624
|
attributes: finalAttributes
|
|
518
625
|
};
|
|
519
626
|
if (this.listeners[key]) {
|
|
520
|
-
this.listeners[key].forEach((listener) => listener());
|
|
627
|
+
this.listeners[key].forEach((listener) => listener(value));
|
|
521
628
|
}
|
|
522
629
|
this.notifyGlobalListeners();
|
|
523
630
|
}
|
|
@@ -528,12 +635,38 @@ var MindCache = class {
|
|
|
528
635
|
return;
|
|
529
636
|
}
|
|
530
637
|
this._isRemoteUpdate = true;
|
|
638
|
+
const systemTags = attributes.systemTags || [];
|
|
639
|
+
if (!attributes.systemTags) {
|
|
640
|
+
if (attributes.visible !== false) {
|
|
641
|
+
systemTags.push("prompt");
|
|
642
|
+
}
|
|
643
|
+
if (attributes.readonly) {
|
|
644
|
+
systemTags.push("readonly");
|
|
645
|
+
}
|
|
646
|
+
if (attributes.hardcoded) {
|
|
647
|
+
systemTags.push("protected");
|
|
648
|
+
}
|
|
649
|
+
if (attributes.template) {
|
|
650
|
+
systemTags.push("template");
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const contentTags = attributes.contentTags || attributes.tags || [];
|
|
531
654
|
this.stm[key] = {
|
|
532
655
|
value,
|
|
533
|
-
attributes
|
|
656
|
+
attributes: {
|
|
657
|
+
...attributes,
|
|
658
|
+
contentTags,
|
|
659
|
+
systemTags,
|
|
660
|
+
zIndex: attributes.zIndex ?? 0,
|
|
661
|
+
tags: contentTags,
|
|
662
|
+
readonly: systemTags.includes("readonly"),
|
|
663
|
+
visible: systemTags.includes("prompt"),
|
|
664
|
+
hardcoded: systemTags.includes("protected"),
|
|
665
|
+
template: systemTags.includes("template")
|
|
666
|
+
}
|
|
534
667
|
};
|
|
535
668
|
if (this.listeners[key]) {
|
|
536
|
-
this.listeners[key].forEach((listener) => listener());
|
|
669
|
+
this.listeners[key].forEach((listener) => listener(value));
|
|
537
670
|
}
|
|
538
671
|
this.notifyGlobalListeners();
|
|
539
672
|
this._isRemoteUpdate = false;
|
|
@@ -551,7 +684,7 @@ var MindCache = class {
|
|
|
551
684
|
if (key in this.stm) {
|
|
552
685
|
delete this.stm[key];
|
|
553
686
|
if (this.listeners[key]) {
|
|
554
|
-
this.listeners[key].forEach((listener) => listener());
|
|
687
|
+
this.listeners[key].forEach((listener) => listener(void 0));
|
|
555
688
|
}
|
|
556
689
|
this.notifyGlobalListeners();
|
|
557
690
|
}
|
|
@@ -573,12 +706,62 @@ var MindCache = class {
|
|
|
573
706
|
if (!entry) {
|
|
574
707
|
return false;
|
|
575
708
|
}
|
|
576
|
-
const
|
|
709
|
+
const wasHardcoded = entry.attributes.hardcoded || entry.attributes.systemTags?.includes("protected");
|
|
710
|
+
const { hardcoded: _hardcoded, systemTags: _systemTags, ...allowedAttributes } = attributes;
|
|
711
|
+
if (wasHardcoded) {
|
|
712
|
+
if ("readonly" in allowedAttributes) {
|
|
713
|
+
delete allowedAttributes.readonly;
|
|
714
|
+
}
|
|
715
|
+
if ("template" in allowedAttributes) {
|
|
716
|
+
delete allowedAttributes.template;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
577
719
|
entry.attributes = { ...entry.attributes, ...allowedAttributes };
|
|
578
|
-
if (
|
|
720
|
+
if ("readonly" in attributes || "visible" in attributes || "template" in attributes) {
|
|
721
|
+
let newSystemTags = [];
|
|
722
|
+
if (entry.attributes.readonly) {
|
|
723
|
+
newSystemTags.push("readonly");
|
|
724
|
+
}
|
|
725
|
+
if (entry.attributes.visible) {
|
|
726
|
+
newSystemTags.push("prompt");
|
|
727
|
+
}
|
|
728
|
+
if (entry.attributes.template) {
|
|
729
|
+
newSystemTags.push("template");
|
|
730
|
+
}
|
|
731
|
+
if (wasHardcoded || entry.attributes.hardcoded) {
|
|
732
|
+
newSystemTags.push("protected");
|
|
733
|
+
}
|
|
734
|
+
if (newSystemTags.includes("protected")) {
|
|
735
|
+
if (!newSystemTags.includes("readonly")) {
|
|
736
|
+
newSystemTags.push("readonly");
|
|
737
|
+
}
|
|
738
|
+
newSystemTags = newSystemTags.filter((t) => t !== "template");
|
|
739
|
+
entry.attributes.readonly = true;
|
|
740
|
+
entry.attributes.template = false;
|
|
741
|
+
}
|
|
742
|
+
entry.attributes.systemTags = newSystemTags;
|
|
743
|
+
} else if (wasHardcoded) {
|
|
744
|
+
let systemTags = [...entry.attributes.systemTags || []];
|
|
745
|
+
if (!systemTags.includes("protected")) {
|
|
746
|
+
systemTags.push("protected");
|
|
747
|
+
}
|
|
748
|
+
if (!systemTags.includes("readonly")) {
|
|
749
|
+
systemTags.push("readonly");
|
|
750
|
+
}
|
|
751
|
+
systemTags = systemTags.filter((t) => t !== "template");
|
|
752
|
+
entry.attributes.systemTags = systemTags;
|
|
753
|
+
}
|
|
754
|
+
if (wasHardcoded) {
|
|
755
|
+
entry.attributes.hardcoded = true;
|
|
756
|
+
if (!entry.attributes.systemTags?.includes("protected")) {
|
|
757
|
+
entry.attributes.systemTags = [...entry.attributes.systemTags || [], "protected"];
|
|
758
|
+
}
|
|
579
759
|
entry.attributes.readonly = true;
|
|
580
760
|
entry.attributes.template = false;
|
|
581
761
|
}
|
|
762
|
+
if ("contentTags" in attributes) {
|
|
763
|
+
entry.attributes.tags = [...entry.attributes.contentTags || []];
|
|
764
|
+
}
|
|
582
765
|
this.notifyGlobalListeners();
|
|
583
766
|
return true;
|
|
584
767
|
}
|
|
@@ -650,7 +833,7 @@ var MindCache = class {
|
|
|
650
833
|
if (deleted) {
|
|
651
834
|
this.notifyGlobalListeners();
|
|
652
835
|
if (this.listeners[key]) {
|
|
653
|
-
this.listeners[key].forEach((listener) => listener());
|
|
836
|
+
this.listeners[key].forEach((listener) => listener(void 0));
|
|
654
837
|
}
|
|
655
838
|
}
|
|
656
839
|
return deleted;
|
|
@@ -659,12 +842,26 @@ var MindCache = class {
|
|
|
659
842
|
this.stm = {};
|
|
660
843
|
this.notifyGlobalListeners();
|
|
661
844
|
}
|
|
845
|
+
/**
|
|
846
|
+
* Get keys sorted by zIndex (ascending), then by key name
|
|
847
|
+
*/
|
|
848
|
+
getSortedKeys() {
|
|
849
|
+
return Object.entries(this.stm).sort(([keyA, entryA], [keyB, entryB]) => {
|
|
850
|
+
const zIndexA = entryA.attributes.zIndex ?? 0;
|
|
851
|
+
const zIndexB = entryB.attributes.zIndex ?? 0;
|
|
852
|
+
if (zIndexA !== zIndexB) {
|
|
853
|
+
return zIndexA - zIndexB;
|
|
854
|
+
}
|
|
855
|
+
return keyA.localeCompare(keyB);
|
|
856
|
+
}).map(([key]) => key);
|
|
857
|
+
}
|
|
662
858
|
keys() {
|
|
663
|
-
return [...
|
|
859
|
+
return [...this.getSortedKeys(), "$date", "$time"];
|
|
664
860
|
}
|
|
665
861
|
values() {
|
|
666
862
|
const now = /* @__PURE__ */ new Date();
|
|
667
|
-
const
|
|
863
|
+
const sortedKeys = this.getSortedKeys();
|
|
864
|
+
const stmValues = sortedKeys.map((key) => this.stm[key].value);
|
|
668
865
|
return [
|
|
669
866
|
...stmValues,
|
|
670
867
|
now.toISOString().split("T")[0],
|
|
@@ -673,8 +870,9 @@ var MindCache = class {
|
|
|
673
870
|
}
|
|
674
871
|
entries() {
|
|
675
872
|
const now = /* @__PURE__ */ new Date();
|
|
676
|
-
const
|
|
677
|
-
|
|
873
|
+
const sortedKeys = this.getSortedKeys();
|
|
874
|
+
const stmEntries = sortedKeys.map(
|
|
875
|
+
(key) => [key, this.stm[key].value]
|
|
678
876
|
);
|
|
679
877
|
return [
|
|
680
878
|
...stmEntries,
|
|
@@ -688,8 +886,9 @@ var MindCache = class {
|
|
|
688
886
|
getAll() {
|
|
689
887
|
const now = /* @__PURE__ */ new Date();
|
|
690
888
|
const result = {};
|
|
691
|
-
|
|
692
|
-
|
|
889
|
+
const sortedKeys = this.getSortedKeys();
|
|
890
|
+
sortedKeys.forEach((key) => {
|
|
891
|
+
result[key] = this.stm[key].value;
|
|
693
892
|
});
|
|
694
893
|
result["$date"] = now.toISOString().split("T")[0];
|
|
695
894
|
result["$time"] = now.toTimeString().split(" ")[0];
|
|
@@ -703,7 +902,7 @@ var MindCache = class {
|
|
|
703
902
|
attributes: { ...DEFAULT_KEY_ATTRIBUTES }
|
|
704
903
|
};
|
|
705
904
|
if (this.listeners[key]) {
|
|
706
|
-
this.listeners[key].forEach((listener) => listener());
|
|
905
|
+
this.listeners[key].forEach((listener) => listener(this.stm[key]?.value));
|
|
707
906
|
}
|
|
708
907
|
}
|
|
709
908
|
});
|
|
@@ -772,7 +971,9 @@ var MindCache = class {
|
|
|
772
971
|
getSTM() {
|
|
773
972
|
const now = /* @__PURE__ */ new Date();
|
|
774
973
|
const entries = [];
|
|
775
|
-
|
|
974
|
+
const sortedKeys = this.getSortedKeys();
|
|
975
|
+
sortedKeys.forEach((key) => {
|
|
976
|
+
const entry = this.stm[key];
|
|
776
977
|
if (entry.attributes.visible) {
|
|
777
978
|
entries.push([key, this.get_value(key)]);
|
|
778
979
|
}
|
|
@@ -787,7 +988,9 @@ var MindCache = class {
|
|
|
787
988
|
getSTMForAPI() {
|
|
788
989
|
const now = /* @__PURE__ */ new Date();
|
|
789
990
|
const apiData = [];
|
|
790
|
-
|
|
991
|
+
const sortedKeys = this.getSortedKeys();
|
|
992
|
+
sortedKeys.forEach((key) => {
|
|
993
|
+
const entry = this.stm[key];
|
|
791
994
|
if (entry.attributes.visible) {
|
|
792
995
|
const processedValue = entry.attributes.template ? this.get_value(key) : entry.value;
|
|
793
996
|
apiData.push({
|
|
@@ -812,7 +1015,9 @@ var MindCache = class {
|
|
|
812
1015
|
}
|
|
813
1016
|
getVisibleImages() {
|
|
814
1017
|
const imageParts = [];
|
|
815
|
-
|
|
1018
|
+
const sortedKeys = this.getSortedKeys();
|
|
1019
|
+
sortedKeys.forEach((key) => {
|
|
1020
|
+
const entry = this.stm[key];
|
|
816
1021
|
if (entry.attributes.visible && entry.attributes.type === "image" && entry.attributes.contentType) {
|
|
817
1022
|
const dataUrl = this.createDataUrl(entry.value, entry.attributes.contentType);
|
|
818
1023
|
imageParts.push({
|
|
@@ -838,7 +1043,9 @@ var MindCache = class {
|
|
|
838
1043
|
}
|
|
839
1044
|
serialize() {
|
|
840
1045
|
const result = {};
|
|
841
|
-
|
|
1046
|
+
const sortedKeys = this.getSortedKeys();
|
|
1047
|
+
sortedKeys.forEach((key) => {
|
|
1048
|
+
const entry = this.stm[key];
|
|
842
1049
|
if (!entry.attributes.hardcoded) {
|
|
843
1050
|
result[key] = {
|
|
844
1051
|
value: entry.value,
|
|
@@ -853,11 +1060,40 @@ var MindCache = class {
|
|
|
853
1060
|
this.clear();
|
|
854
1061
|
Object.entries(data).forEach(([key, entry]) => {
|
|
855
1062
|
if (entry && typeof entry === "object" && "value" in entry && "attributes" in entry) {
|
|
1063
|
+
const attrs = entry.attributes;
|
|
1064
|
+
if (attrs.hardcoded === true || attrs.systemTags?.includes("protected")) {
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
let systemTags = attrs.systemTags || [];
|
|
1068
|
+
if (!attrs.systemTags) {
|
|
1069
|
+
systemTags = [];
|
|
1070
|
+
if (attrs.visible !== false) {
|
|
1071
|
+
systemTags.push("prompt");
|
|
1072
|
+
}
|
|
1073
|
+
if (attrs.readonly) {
|
|
1074
|
+
systemTags.push("readonly");
|
|
1075
|
+
}
|
|
1076
|
+
if (attrs.hardcoded) {
|
|
1077
|
+
systemTags.push("protected");
|
|
1078
|
+
}
|
|
1079
|
+
if (attrs.template) {
|
|
1080
|
+
systemTags.push("template");
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
const contentTags = attrs.contentTags || attrs.tags || [];
|
|
856
1084
|
this.stm[key] = {
|
|
857
1085
|
value: entry.value,
|
|
858
1086
|
attributes: {
|
|
859
|
-
...
|
|
860
|
-
|
|
1087
|
+
...attrs,
|
|
1088
|
+
contentTags,
|
|
1089
|
+
systemTags,
|
|
1090
|
+
zIndex: attrs.zIndex ?? 0,
|
|
1091
|
+
// Sync legacy attributes
|
|
1092
|
+
tags: contentTags,
|
|
1093
|
+
readonly: systemTags.includes("readonly"),
|
|
1094
|
+
visible: systemTags.includes("prompt"),
|
|
1095
|
+
hardcoded: systemTags.includes("protected"),
|
|
1096
|
+
template: systemTags.includes("template")
|
|
861
1097
|
}
|
|
862
1098
|
};
|
|
863
1099
|
}
|
|
@@ -868,7 +1104,9 @@ var MindCache = class {
|
|
|
868
1104
|
get_system_prompt() {
|
|
869
1105
|
const now = /* @__PURE__ */ new Date();
|
|
870
1106
|
const promptLines = [];
|
|
871
|
-
|
|
1107
|
+
const sortedKeys = this.getSortedKeys();
|
|
1108
|
+
sortedKeys.forEach((key) => {
|
|
1109
|
+
const entry = this.stm[key];
|
|
872
1110
|
if (entry.attributes.visible) {
|
|
873
1111
|
if (entry.attributes.type === "image") {
|
|
874
1112
|
promptLines.push(`image ${key} available`);
|
|
@@ -903,14 +1141,18 @@ var MindCache = class {
|
|
|
903
1141
|
return void 0;
|
|
904
1142
|
}
|
|
905
1143
|
const sanitizedKey = toolName.replace("write_", "");
|
|
906
|
-
const
|
|
907
|
-
return
|
|
1144
|
+
const sortedKeys = this.getSortedKeys();
|
|
1145
|
+
return sortedKeys.find(
|
|
908
1146
|
(k) => k.replace(/[^a-zA-Z0-9_-]/g, "_") === sanitizedKey
|
|
909
1147
|
);
|
|
910
1148
|
}
|
|
911
1149
|
get_aisdk_tools() {
|
|
912
1150
|
const tools = {};
|
|
913
|
-
const
|
|
1151
|
+
const sortedKeys = this.getSortedKeys();
|
|
1152
|
+
const writableKeys = sortedKeys.filter((key) => {
|
|
1153
|
+
const entry = this.stm[key];
|
|
1154
|
+
return !entry.attributes.readonly;
|
|
1155
|
+
});
|
|
914
1156
|
writableKeys.forEach((key) => {
|
|
915
1157
|
const sanitizedKey = key.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
916
1158
|
const toolName = `write_${sanitizedKey}`;
|
|
@@ -994,6 +1236,12 @@ var MindCache = class {
|
|
|
994
1236
|
value
|
|
995
1237
|
};
|
|
996
1238
|
}
|
|
1239
|
+
// ============================================
|
|
1240
|
+
// Content Tag Methods (available to all access levels)
|
|
1241
|
+
// ============================================
|
|
1242
|
+
/**
|
|
1243
|
+
* Add a content tag to a key (user-level organization)
|
|
1244
|
+
*/
|
|
997
1245
|
addTag(key, tag) {
|
|
998
1246
|
if (key === "$date" || key === "$time") {
|
|
999
1247
|
return false;
|
|
@@ -1002,64 +1250,231 @@ var MindCache = class {
|
|
|
1002
1250
|
if (!entry) {
|
|
1003
1251
|
return false;
|
|
1004
1252
|
}
|
|
1005
|
-
if (!entry.attributes.
|
|
1006
|
-
entry.attributes.
|
|
1253
|
+
if (!entry.attributes.contentTags) {
|
|
1254
|
+
entry.attributes.contentTags = [];
|
|
1007
1255
|
}
|
|
1008
|
-
if (!entry.attributes.
|
|
1009
|
-
entry.attributes.
|
|
1256
|
+
if (!entry.attributes.contentTags.includes(tag)) {
|
|
1257
|
+
entry.attributes.contentTags.push(tag);
|
|
1258
|
+
entry.attributes.tags = [...entry.attributes.contentTags];
|
|
1010
1259
|
this.notifyGlobalListeners();
|
|
1011
1260
|
return true;
|
|
1012
1261
|
}
|
|
1013
1262
|
return false;
|
|
1014
1263
|
}
|
|
1264
|
+
/**
|
|
1265
|
+
* Remove a content tag from a key
|
|
1266
|
+
*/
|
|
1015
1267
|
removeTag(key, tag) {
|
|
1016
1268
|
if (key === "$date" || key === "$time") {
|
|
1017
1269
|
return false;
|
|
1018
1270
|
}
|
|
1019
1271
|
const entry = this.stm[key];
|
|
1020
|
-
if (!entry || !entry.attributes.
|
|
1272
|
+
if (!entry || !entry.attributes.contentTags) {
|
|
1021
1273
|
return false;
|
|
1022
1274
|
}
|
|
1023
|
-
const tagIndex = entry.attributes.
|
|
1275
|
+
const tagIndex = entry.attributes.contentTags.indexOf(tag);
|
|
1024
1276
|
if (tagIndex > -1) {
|
|
1025
|
-
entry.attributes.
|
|
1277
|
+
entry.attributes.contentTags.splice(tagIndex, 1);
|
|
1278
|
+
entry.attributes.tags = [...entry.attributes.contentTags];
|
|
1026
1279
|
this.notifyGlobalListeners();
|
|
1027
1280
|
return true;
|
|
1028
1281
|
}
|
|
1029
1282
|
return false;
|
|
1030
1283
|
}
|
|
1284
|
+
/**
|
|
1285
|
+
* Get all content tags for a key
|
|
1286
|
+
*/
|
|
1031
1287
|
getTags(key) {
|
|
1032
1288
|
if (key === "$date" || key === "$time") {
|
|
1033
1289
|
return [];
|
|
1034
1290
|
}
|
|
1035
1291
|
const entry = this.stm[key];
|
|
1036
|
-
return entry?.attributes.
|
|
1292
|
+
return entry?.attributes.contentTags || [];
|
|
1037
1293
|
}
|
|
1294
|
+
/**
|
|
1295
|
+
* Get all unique content tags across all keys
|
|
1296
|
+
*/
|
|
1038
1297
|
getAllTags() {
|
|
1039
1298
|
const allTags = /* @__PURE__ */ new Set();
|
|
1040
1299
|
Object.values(this.stm).forEach((entry) => {
|
|
1041
|
-
if (entry.attributes.
|
|
1042
|
-
entry.attributes.
|
|
1300
|
+
if (entry.attributes.contentTags) {
|
|
1301
|
+
entry.attributes.contentTags.forEach((tag) => allTags.add(tag));
|
|
1043
1302
|
}
|
|
1044
1303
|
});
|
|
1045
1304
|
return Array.from(allTags);
|
|
1046
1305
|
}
|
|
1306
|
+
/**
|
|
1307
|
+
* Check if a key has a specific content tag
|
|
1308
|
+
*/
|
|
1047
1309
|
hasTag(key, tag) {
|
|
1048
1310
|
if (key === "$date" || key === "$time") {
|
|
1049
1311
|
return false;
|
|
1050
1312
|
}
|
|
1051
1313
|
const entry = this.stm[key];
|
|
1052
|
-
return entry?.attributes.
|
|
1314
|
+
return entry?.attributes.contentTags?.includes(tag) || false;
|
|
1053
1315
|
}
|
|
1316
|
+
/**
|
|
1317
|
+
* Get all keys with a specific content tag as formatted string
|
|
1318
|
+
*/
|
|
1054
1319
|
getTagged(tag) {
|
|
1055
1320
|
const entries = [];
|
|
1056
|
-
|
|
1057
|
-
|
|
1321
|
+
const sortedKeys = this.getSortedKeys();
|
|
1322
|
+
sortedKeys.forEach((key) => {
|
|
1323
|
+
const entry = this.stm[key];
|
|
1324
|
+
if (entry.attributes.contentTags?.includes(tag)) {
|
|
1058
1325
|
entries.push([key, this.get_value(key)]);
|
|
1059
1326
|
}
|
|
1060
1327
|
});
|
|
1061
1328
|
return entries.map(([key, value]) => `${key}: ${value}`).join(", ");
|
|
1062
1329
|
}
|
|
1330
|
+
/**
|
|
1331
|
+
* Get all keys with a specific content tag
|
|
1332
|
+
*/
|
|
1333
|
+
getKeysByTag(tag) {
|
|
1334
|
+
const sortedKeys = this.getSortedKeys();
|
|
1335
|
+
return sortedKeys.filter((key) => {
|
|
1336
|
+
const entry = this.stm[key];
|
|
1337
|
+
return entry.attributes.contentTags?.includes(tag);
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
// ============================================
|
|
1341
|
+
// System Tag Methods (requires system access level)
|
|
1342
|
+
// ============================================
|
|
1343
|
+
/**
|
|
1344
|
+
* Add a system tag to a key (requires system access)
|
|
1345
|
+
* System tags: 'prompt', 'readonly', 'protected', 'template'
|
|
1346
|
+
*/
|
|
1347
|
+
systemAddTag(key, tag) {
|
|
1348
|
+
if (!this.hasSystemAccess) {
|
|
1349
|
+
console.warn("MindCache: systemAddTag requires system access level");
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
if (key === "$date" || key === "$time") {
|
|
1353
|
+
return false;
|
|
1354
|
+
}
|
|
1355
|
+
const entry = this.stm[key];
|
|
1356
|
+
if (!entry) {
|
|
1357
|
+
return false;
|
|
1358
|
+
}
|
|
1359
|
+
if (!entry.attributes.systemTags) {
|
|
1360
|
+
entry.attributes.systemTags = [];
|
|
1361
|
+
}
|
|
1362
|
+
if (!entry.attributes.systemTags.includes(tag)) {
|
|
1363
|
+
entry.attributes.systemTags.push(tag);
|
|
1364
|
+
this.syncLegacyFromSystemTags(entry);
|
|
1365
|
+
this.notifyGlobalListeners();
|
|
1366
|
+
return true;
|
|
1367
|
+
}
|
|
1368
|
+
return false;
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Remove a system tag from a key (requires system access)
|
|
1372
|
+
*/
|
|
1373
|
+
systemRemoveTag(key, tag) {
|
|
1374
|
+
if (!this.hasSystemAccess) {
|
|
1375
|
+
console.warn("MindCache: systemRemoveTag requires system access level");
|
|
1376
|
+
return false;
|
|
1377
|
+
}
|
|
1378
|
+
if (key === "$date" || key === "$time") {
|
|
1379
|
+
return false;
|
|
1380
|
+
}
|
|
1381
|
+
const entry = this.stm[key];
|
|
1382
|
+
if (!entry || !entry.attributes.systemTags) {
|
|
1383
|
+
return false;
|
|
1384
|
+
}
|
|
1385
|
+
const isHardcoded = entry.attributes.hardcoded || entry.attributes.systemTags.includes("protected");
|
|
1386
|
+
if (tag === "protected" && isHardcoded) {
|
|
1387
|
+
return false;
|
|
1388
|
+
}
|
|
1389
|
+
const tagIndex = entry.attributes.systemTags.indexOf(tag);
|
|
1390
|
+
if (tagIndex > -1) {
|
|
1391
|
+
entry.attributes.systemTags.splice(tagIndex, 1);
|
|
1392
|
+
this.syncLegacyFromSystemTags(entry);
|
|
1393
|
+
if (isHardcoded) {
|
|
1394
|
+
if (!entry.attributes.systemTags.includes("protected")) {
|
|
1395
|
+
entry.attributes.systemTags.push("protected");
|
|
1396
|
+
}
|
|
1397
|
+
entry.attributes.hardcoded = true;
|
|
1398
|
+
entry.attributes.readonly = true;
|
|
1399
|
+
entry.attributes.template = false;
|
|
1400
|
+
}
|
|
1401
|
+
this.notifyGlobalListeners();
|
|
1402
|
+
return true;
|
|
1403
|
+
}
|
|
1404
|
+
return false;
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Get all system tags for a key (requires system access)
|
|
1408
|
+
*/
|
|
1409
|
+
systemGetTags(key) {
|
|
1410
|
+
if (!this.hasSystemAccess) {
|
|
1411
|
+
console.warn("MindCache: systemGetTags requires system access level");
|
|
1412
|
+
return [];
|
|
1413
|
+
}
|
|
1414
|
+
if (key === "$date" || key === "$time") {
|
|
1415
|
+
return [];
|
|
1416
|
+
}
|
|
1417
|
+
const entry = this.stm[key];
|
|
1418
|
+
return entry?.attributes.systemTags || [];
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* Check if a key has a specific system tag (requires system access)
|
|
1422
|
+
*/
|
|
1423
|
+
systemHasTag(key, tag) {
|
|
1424
|
+
if (!this.hasSystemAccess) {
|
|
1425
|
+
console.warn("MindCache: systemHasTag requires system access level");
|
|
1426
|
+
return false;
|
|
1427
|
+
}
|
|
1428
|
+
if (key === "$date" || key === "$time") {
|
|
1429
|
+
return false;
|
|
1430
|
+
}
|
|
1431
|
+
const entry = this.stm[key];
|
|
1432
|
+
return entry?.attributes.systemTags?.includes(tag) || false;
|
|
1433
|
+
}
|
|
1434
|
+
/**
|
|
1435
|
+
* Set all system tags for a key at once (requires system access)
|
|
1436
|
+
*/
|
|
1437
|
+
systemSetTags(key, tags) {
|
|
1438
|
+
if (!this.hasSystemAccess) {
|
|
1439
|
+
console.warn("MindCache: systemSetTags requires system access level");
|
|
1440
|
+
return false;
|
|
1441
|
+
}
|
|
1442
|
+
if (key === "$date" || key === "$time") {
|
|
1443
|
+
return false;
|
|
1444
|
+
}
|
|
1445
|
+
const entry = this.stm[key];
|
|
1446
|
+
if (!entry) {
|
|
1447
|
+
return false;
|
|
1448
|
+
}
|
|
1449
|
+
entry.attributes.systemTags = [...tags];
|
|
1450
|
+
this.syncLegacyFromSystemTags(entry);
|
|
1451
|
+
this.notifyGlobalListeners();
|
|
1452
|
+
return true;
|
|
1453
|
+
}
|
|
1454
|
+
/**
|
|
1455
|
+
* Get all keys with a specific system tag (requires system access)
|
|
1456
|
+
*/
|
|
1457
|
+
systemGetKeysByTag(tag) {
|
|
1458
|
+
if (!this.hasSystemAccess) {
|
|
1459
|
+
console.warn("MindCache: systemGetKeysByTag requires system access level");
|
|
1460
|
+
return [];
|
|
1461
|
+
}
|
|
1462
|
+
const sortedKeys = this.getSortedKeys();
|
|
1463
|
+
return sortedKeys.filter((key) => {
|
|
1464
|
+
const entry = this.stm[key];
|
|
1465
|
+
return entry.attributes.systemTags?.includes(tag);
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
/**
|
|
1469
|
+
* Helper to sync legacy boolean attributes from system tags
|
|
1470
|
+
*/
|
|
1471
|
+
syncLegacyFromSystemTags(entry) {
|
|
1472
|
+
const tags = entry.attributes.systemTags || [];
|
|
1473
|
+
entry.attributes.readonly = tags.includes("readonly");
|
|
1474
|
+
entry.attributes.visible = tags.includes("prompt");
|
|
1475
|
+
entry.attributes.hardcoded = tags.includes("protected");
|
|
1476
|
+
entry.attributes.template = tags.includes("template");
|
|
1477
|
+
}
|
|
1063
1478
|
toMarkdown() {
|
|
1064
1479
|
const now = /* @__PURE__ */ new Date();
|
|
1065
1480
|
const lines = [];
|
|
@@ -1073,7 +1488,9 @@ var MindCache = class {
|
|
|
1073
1488
|
lines.push("");
|
|
1074
1489
|
lines.push("## STM Entries");
|
|
1075
1490
|
lines.push("");
|
|
1076
|
-
|
|
1491
|
+
const sortedKeys = this.getSortedKeys();
|
|
1492
|
+
sortedKeys.forEach((key) => {
|
|
1493
|
+
const entry = this.stm[key];
|
|
1077
1494
|
if (entry.attributes.hardcoded) {
|
|
1078
1495
|
return;
|
|
1079
1496
|
}
|
|
@@ -1083,6 +1500,7 @@ var MindCache = class {
|
|
|
1083
1500
|
lines.push(`- **Readonly**: \`${entry.attributes.readonly}\``);
|
|
1084
1501
|
lines.push(`- **Visible**: \`${entry.attributes.visible}\``);
|
|
1085
1502
|
lines.push(`- **Template**: \`${entry.attributes.template}\``);
|
|
1503
|
+
lines.push(`- **Z-Index**: \`${entry.attributes.zIndex ?? 0}\``);
|
|
1086
1504
|
if (entry.attributes.tags && entry.attributes.tags.length > 0) {
|
|
1087
1505
|
lines.push(`- **Tags**: \`${entry.attributes.tags.join("`, `")}\``);
|
|
1088
1506
|
}
|
|
@@ -1195,11 +1613,9 @@ var MindCache = class {
|
|
|
1195
1613
|
currentEntry = {
|
|
1196
1614
|
value: void 0,
|
|
1197
1615
|
attributes: {
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
template: false,
|
|
1202
|
-
type: "text",
|
|
1616
|
+
...DEFAULT_KEY_ATTRIBUTES,
|
|
1617
|
+
contentTags: [],
|
|
1618
|
+
systemTags: ["prompt"],
|
|
1203
1619
|
tags: []
|
|
1204
1620
|
}
|
|
1205
1621
|
};
|
|
@@ -1223,6 +1639,14 @@ var MindCache = class {
|
|
|
1223
1639
|
if (currentEntry) {
|
|
1224
1640
|
currentEntry.attributes.template = value;
|
|
1225
1641
|
}
|
|
1642
|
+
} else if (trimmed.startsWith("- **Z-Index**: `")) {
|
|
1643
|
+
const zIndexStr = trimmed.match(/`([^`]+)`/)?.[1];
|
|
1644
|
+
if (currentEntry && zIndexStr) {
|
|
1645
|
+
const zIndex = parseInt(zIndexStr, 10);
|
|
1646
|
+
if (!isNaN(zIndex)) {
|
|
1647
|
+
currentEntry.attributes.zIndex = zIndex;
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1226
1650
|
} else if (trimmed.startsWith("- **Tags**: `")) {
|
|
1227
1651
|
const tagsStr = trimmed.substring(13, trimmed.length - 1);
|
|
1228
1652
|
if (currentEntry) {
|
|
@@ -1279,9 +1703,35 @@ var MindCache = class {
|
|
|
1279
1703
|
}
|
|
1280
1704
|
}
|
|
1281
1705
|
if (entry.value !== void 0 && entry.attributes) {
|
|
1706
|
+
const attrs = entry.attributes;
|
|
1707
|
+
if (attrs.tags && attrs.tags.length > 0 && (!attrs.contentTags || attrs.contentTags.length === 0)) {
|
|
1708
|
+
attrs.contentTags = [...attrs.tags];
|
|
1709
|
+
}
|
|
1710
|
+
if (!attrs.systemTags || attrs.systemTags.length === 0) {
|
|
1711
|
+
const systemTags = [];
|
|
1712
|
+
if (attrs.visible !== false) {
|
|
1713
|
+
systemTags.push("prompt");
|
|
1714
|
+
}
|
|
1715
|
+
if (attrs.readonly) {
|
|
1716
|
+
systemTags.push("readonly");
|
|
1717
|
+
}
|
|
1718
|
+
if (attrs.hardcoded) {
|
|
1719
|
+
systemTags.push("protected");
|
|
1720
|
+
}
|
|
1721
|
+
if (attrs.template) {
|
|
1722
|
+
systemTags.push("template");
|
|
1723
|
+
}
|
|
1724
|
+
attrs.systemTags = systemTags;
|
|
1725
|
+
}
|
|
1726
|
+
if (!attrs.contentTags) {
|
|
1727
|
+
attrs.contentTags = [];
|
|
1728
|
+
}
|
|
1729
|
+
if (!attrs.tags) {
|
|
1730
|
+
attrs.tags = [...attrs.contentTags];
|
|
1731
|
+
}
|
|
1282
1732
|
this.stm[key] = {
|
|
1283
1733
|
value: entry.value,
|
|
1284
|
-
attributes:
|
|
1734
|
+
attributes: attrs
|
|
1285
1735
|
};
|
|
1286
1736
|
}
|
|
1287
1737
|
});
|