luckytri 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/.github/SECURITY.md +4 -4
  2. package/README.en.md +252 -250
  3. package/README.md +252 -250
  4. package/bin/luckytri.js +5 -1
  5. package/docs/en/CHANGELOG.md +8 -0
  6. package/docs/en/connect.md +18 -18
  7. package/docs/en/guide.md +202 -216
  8. package/docs/en/npm-release.md +25 -25
  9. package/docs/zh/CHANGELOG.md +8 -0
  10. package/docs/zh/connect.md +17 -17
  11. package/docs/zh/guide.md +202 -216
  12. package/docs/zh/npm-release.md +33 -33
  13. package/package.json +110 -108
  14. package/plugins/sdk/index.d.ts +155 -155
  15. package/plugins/sdk/testing.js +58 -58
  16. package/plugins/weather/index.js +82 -82
  17. package/plugins/weather/luckytri-plugin.json +29 -29
  18. package/public/app/assets/ChatsPage-BhlJHseG.js +3 -0
  19. package/public/app/assets/Empty-DP6WMGHi.js +2 -0
  20. package/public/app/assets/Field-CtbdqaiB.js +1 -0
  21. package/public/app/assets/HeartPage-32BeTPn2.js +1 -0
  22. package/public/app/assets/LifePage-CxSm0XKI.js +1 -0
  23. package/public/app/assets/MemoryPage-BeKBcPCY.js +1 -0
  24. package/public/app/assets/NaturePage-NEPYl2HS.js +3 -0
  25. package/public/app/assets/PeoplePage-DxtpekwM.js +1 -0
  26. package/public/app/assets/PluginsPage-CVVQwEBI.css +1 -0
  27. package/public/app/assets/PluginsPage-DksEZbUU.js +2 -0
  28. package/public/app/assets/{SystemPage-CAMPoYqM.css → SystemPage-BkRu0Rvx.css} +1 -1
  29. package/public/app/assets/SystemPage-BvzJlHuY.js +1 -0
  30. package/public/app/assets/TimePage-7-awH5XL.js +3 -0
  31. package/public/app/assets/index-4rItIkD-.js +4 -0
  32. package/public/app/assets/{index-YDz1ree1.css → index-DY4e15Kh.css} +1 -1
  33. package/public/app/assets/{knowledge-DG0e0uKw.js → knowledge-C6_HvoyB.js} +1 -1
  34. package/public/app/assets/media-SMfTT-yc.js +1 -0
  35. package/public/app/index.html +3 -3
  36. package/public/guide.en.html +72 -99
  37. package/public/guide.html +44 -86
  38. package/public/tutorial.en.md +25 -39
  39. package/public/tutorial.md +25 -39
  40. package/scripts/backup.js +311 -311
  41. package/scripts/browser.js +41 -41
  42. package/scripts/import-data.js +128 -0
  43. package/scripts/launch.js +101 -94
  44. package/scripts/plugin.js +150 -150
  45. package/scripts/reset-password.js +22 -0
  46. package/scripts/runtime.js +25 -25
  47. package/scripts/service.js +56 -47
  48. package/scripts/setup.js +50 -50
  49. package/scripts/start-server.js +41 -41
  50. package/scripts/stop.js +36 -36
  51. package/server/app.js +112 -96
  52. package/server/auth.js +217 -0
  53. package/server/channels/contract.js +57 -57
  54. package/server/channels/hub.js +165 -165
  55. package/server/channels/index.js +28 -25
  56. package/server/channels/onebot/index.js +335 -336
  57. package/server/channels/onebot/token.js +22 -3
  58. package/server/core/capabilities.js +208 -208
  59. package/server/core/events.js +64 -60
  60. package/server/core/image-preprocessor.js +208 -208
  61. package/server/core/model-manager.js +1213 -1213
  62. package/server/core/net-guard.js +49 -49
  63. package/server/core/orchestrator.js +569 -569
  64. package/server/core/perceivers.js +91 -91
  65. package/server/core/persona-manager.js +243 -243
  66. package/server/core/repository.js +293 -293
  67. package/server/core/response-validator.js +508 -508
  68. package/server/core/turn-processor.js +630 -630
  69. package/server/core/turn.js +236 -236
  70. package/server/core/vision-manager.js +633 -633
  71. package/server/i18n/errors.js +548 -497
  72. package/server/i18n/labels.js +649 -653
  73. package/server/index.js +151 -102
  74. package/server/knowledge/manager.js +386 -386
  75. package/server/knowledge/schema.js +12 -8
  76. package/server/local-access.js +32 -0
  77. package/server/mind/anticipations.js +507 -507
  78. package/server/mind/api.js +703 -703
  79. package/server/mind/budget.js +152 -152
  80. package/server/mind/context-selection.js +61 -61
  81. package/server/mind/day-planner.js +324 -324
  82. package/server/mind/evidence.js +148 -148
  83. package/server/mind/index.js +445 -445
  84. package/server/mind/life/diary.js +786 -786
  85. package/server/mind/life/index.js +1049 -1049
  86. package/server/mind/observations.js +84 -84
  87. package/server/mind/own-day.js +324 -324
  88. package/server/mind/own-voice.js +318 -318
  89. package/server/mind/senses.js +53 -53
  90. package/server/mind/time/activity-clock.js +196 -196
  91. package/server/mind/time/availability.js +69 -69
  92. package/server/mind/time/commitment-review.js +198 -198
  93. package/server/mind/time/executor.js +512 -512
  94. package/server/mind/time/experiences.js +128 -128
  95. package/server/mind/time/games.js +562 -562
  96. package/server/mind/time/index.js +739 -739
  97. package/server/mind/time/intent.js +166 -166
  98. package/server/mind/time/kinds.js +171 -171
  99. package/server/mind/time/plugin-activity.js +207 -207
  100. package/server/mind/time/tasks.js +587 -587
  101. package/server/mind/util.js +110 -110
  102. package/server/mind/view.js +273 -273
  103. package/server/paths.js +102 -102
  104. package/server/plugins/api.js +204 -204
  105. package/server/plugins/host.js +967 -967
  106. package/server/plugins/install.js +295 -295
  107. package/server/plugins/manifest.js +201 -201
  108. package/server/plugins/permissions.js +42 -42
  109. package/server/plugins/runner/guard.mjs +36 -36
  110. package/server/plugins/runner/worker.mjs +250 -250
  111. package/server/plugins/schema.js +91 -91
  112. package/server/plugins/zip.js +112 -112
  113. package/server/startup-lock.js +118 -118
  114. package/server/storage/archive.js +242 -241
  115. package/server/storage/backup-cleanup-worker.js +8 -8
  116. package/server/storage/backup-cleanup.js +415 -414
  117. package/server/storage/backup-lock.js +76 -76
  118. package/server/storage/backup-scheduler.js +131 -131
  119. package/server/storage/data-package.js +298 -0
  120. package/server/storage/data-transfer-api.js +50 -0
  121. package/server/storage/data-transfer-worker.js +18 -0
  122. package/server/storage/data-transfer.js +415 -0
  123. package/server/storage/store.js +202 -199
  124. package/server/studio/readiness.js +181 -190
  125. package/server/studio/settings.js +236 -236
  126. package/public/app/assets/ChatsPage-C-FcRapR.js +0 -3
  127. package/public/app/assets/Empty-CpP5kQHH.js +0 -2
  128. package/public/app/assets/Field-D4gY-INU.js +0 -1
  129. package/public/app/assets/HeartPage-CPy_thQd.js +0 -1
  130. package/public/app/assets/LifePage-CxWvwmSf.js +0 -1
  131. package/public/app/assets/MemoryPage-DC4rhQ68.js +0 -1
  132. package/public/app/assets/NaturePage-IvYw04Zq.js +0 -3
  133. package/public/app/assets/PeoplePage-Cqefm9-q.js +0 -1
  134. package/public/app/assets/PluginsPage-DKSaKvXb.js +0 -2
  135. package/public/app/assets/PluginsPage-HyBe5D8w.css +0 -1
  136. package/public/app/assets/SystemPage-CJmtJkrK.js +0 -1
  137. package/public/app/assets/TimePage-Cw44inM4.js +0 -3
  138. package/public/app/assets/index-BheRW-1t.js +0 -4
  139. package/public/app/assets/media-BzPDBm7e.js +0 -1
@@ -1,110 +1,110 @@
1
- import { localClock } from "../core/conversation-cues.js";
2
-
3
- export const HOUR = 3600000;
4
- export const DAY = 86400000;
5
-
6
- export function parse(value, fallback) {
7
- if (value == null) return fallback;
8
- if (typeof value !== "string") return value;
9
- try {
10
- return JSON.parse(value);
11
- } catch {
12
- return fallback;
13
- }
14
- }
15
-
16
- export function clamp(value, min = 0, max = 1) {
17
- const n = Number(value);
18
- if (!Number.isFinite(n)) return min;
19
- return Math.min(max, Math.max(min, n));
20
- }
21
-
22
- export function text(value, max) {
23
- return String(value ?? "")
24
- .trim()
25
- .slice(0, max);
26
- }
27
-
28
- export function normalized(value) {
29
- return String(value ?? "")
30
- .replace(/[\s\p{P}\p{S}]/gu, "")
31
- .toLowerCase();
32
- }
33
-
34
- // Bigram overlap on normalized text: cheap, deterministic, good enough to
35
- // tell "the same thought again" from a genuinely new one.
36
- export function similar(a, b, threshold = 0.8) {
37
- const left = normalized(a);
38
- const right = normalized(b);
39
- if (!left || !right) return false;
40
- if (left.includes(right) || right.includes(left)) return true;
41
- const grams = (s) =>
42
- new Set(
43
- Array.from({ length: Math.max(0, s.length - 1) }, (_, i) =>
44
- s.slice(i, i + 2),
45
- ),
46
- );
47
- const x = grams(left);
48
- const y = grams(right);
49
- const shared = [...x].filter((g) => y.has(g)).length;
50
- return shared / Math.max(1, Math.min(x.size, y.size)) > threshold;
51
- }
52
-
53
- export const CREDENTIAL =
54
- /(?:sk-[a-zA-Z0-9_-]{16,}|Bearer\s+\S{12,}|(?:密码|验证码|口令|API.?Key|token|密钥)\s*(?:是|为|[::=])\s*\S{4,})/i;
55
-
56
- export function hasCredential(value) {
57
- return CREDENTIAL.test(String(value ?? ""));
58
- }
59
-
60
- export function dayKey(time, timeZone) {
61
- return localClock(time, timeZone).local.slice(0, 10);
62
- }
63
-
64
- // "2026-10-02" or "2026-10-02 14:30" as a moment in her time zone.
65
- export function zonedTime(value, timeZone) {
66
- const match = String(value ?? "")
67
- .trim()
68
- .match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}))?$/);
69
- if (!match) return null;
70
- const [, y, mo, d, h = "00", mi = "00"] = match;
71
- const guess = Date.UTC(+y, +mo - 1, +d, +h, +mi);
72
- if (!Number.isFinite(guess)) return null;
73
- const shown = localClock(guess, timeZone).local;
74
- const offset = Date.parse(`${shown.replace(" ", "T")}:00Z`) - guess;
75
- const time = guess - offset;
76
- return localClock(time, timeZone).local === `${y}-${mo}-${d} ${h}:${mi}`
77
- ? time
78
- : null;
79
- }
80
-
81
- // Exponential return toward a baseline.
82
- export function relax(value, baseline, elapsed, halfLife) {
83
- if (!(elapsed > 0)) return value;
84
- return baseline + (value - baseline) * Math.pow(0.5, elapsed / halfLife);
85
- }
86
-
87
- // Evidence is stored as short typed strings so every kind of experience can
88
- // be cited the same way: "m:<event seq>", "t:<thought id>", "d:<day>",
89
- // "f:<decision id>", "r:<passage id>", "a:<anticipation id>",
90
- // "g:<meeting id>" for what a meeting already meant to her,
91
- // "s:<self thread>" for something she is living for.
92
- export function evidence(list) {
93
- const out = [];
94
- for (const item of Array.isArray(list) ? list : []) {
95
- if (Number.isSafeInteger(item) && item > 0) out.push(`m:${item}`);
96
- else if (
97
- typeof item === "string" &&
98
- /^[mtdfrasgxoe]:[\w:.-]{1,80}$/.test(item)
99
- )
100
- out.push(item);
101
- else if (/^\d+$/.test(String(item))) out.push(`m:${item}`);
102
- }
103
- return [...new Set(out)].slice(0, 24);
104
- }
105
-
106
- export function messageSeqs(sources) {
107
- return evidence(sources)
108
- .filter((s) => s.startsWith("m:"))
109
- .map((s) => Number(s.slice(2)));
110
- }
1
+ import { localClock } from "../core/conversation-cues.js";
2
+
3
+ export const HOUR = 3600000;
4
+ export const DAY = 86400000;
5
+
6
+ export function parse(value, fallback) {
7
+ if (value == null) return fallback;
8
+ if (typeof value !== "string") return value;
9
+ try {
10
+ return JSON.parse(value);
11
+ } catch {
12
+ return fallback;
13
+ }
14
+ }
15
+
16
+ export function clamp(value, min = 0, max = 1) {
17
+ const n = Number(value);
18
+ if (!Number.isFinite(n)) return min;
19
+ return Math.min(max, Math.max(min, n));
20
+ }
21
+
22
+ export function text(value, max) {
23
+ return String(value ?? "")
24
+ .trim()
25
+ .slice(0, max);
26
+ }
27
+
28
+ export function normalized(value) {
29
+ return String(value ?? "")
30
+ .replace(/[\s\p{P}\p{S}]/gu, "")
31
+ .toLowerCase();
32
+ }
33
+
34
+ // Bigram overlap on normalized text: cheap, deterministic, good enough to
35
+ // tell "the same thought again" from a genuinely new one.
36
+ export function similar(a, b, threshold = 0.8) {
37
+ const left = normalized(a);
38
+ const right = normalized(b);
39
+ if (!left || !right) return false;
40
+ if (left.includes(right) || right.includes(left)) return true;
41
+ const grams = (s) =>
42
+ new Set(
43
+ Array.from({ length: Math.max(0, s.length - 1) }, (_, i) =>
44
+ s.slice(i, i + 2),
45
+ ),
46
+ );
47
+ const x = grams(left);
48
+ const y = grams(right);
49
+ const shared = [...x].filter((g) => y.has(g)).length;
50
+ return shared / Math.max(1, Math.min(x.size, y.size)) > threshold;
51
+ }
52
+
53
+ export const CREDENTIAL =
54
+ /(?:sk-[a-zA-Z0-9_-]{16,}|Bearer\s+\S{12,}|(?:密码|验证码|口令|API.?Key|token|密钥)\s*(?:是|为|[::=])\s*\S{4,})/i;
55
+
56
+ export function hasCredential(value) {
57
+ return CREDENTIAL.test(String(value ?? ""));
58
+ }
59
+
60
+ export function dayKey(time, timeZone) {
61
+ return localClock(time, timeZone).local.slice(0, 10);
62
+ }
63
+
64
+ // "2026-10-02" or "2026-10-02 14:30" as a moment in her time zone.
65
+ export function zonedTime(value, timeZone) {
66
+ const match = String(value ?? "")
67
+ .trim()
68
+ .match(/^(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}))?$/);
69
+ if (!match) return null;
70
+ const [, y, mo, d, h = "00", mi = "00"] = match;
71
+ const guess = Date.UTC(+y, +mo - 1, +d, +h, +mi);
72
+ if (!Number.isFinite(guess)) return null;
73
+ const shown = localClock(guess, timeZone).local;
74
+ const offset = Date.parse(`${shown.replace(" ", "T")}:00Z`) - guess;
75
+ const time = guess - offset;
76
+ return localClock(time, timeZone).local === `${y}-${mo}-${d} ${h}:${mi}`
77
+ ? time
78
+ : null;
79
+ }
80
+
81
+ // Exponential return toward a baseline.
82
+ export function relax(value, baseline, elapsed, halfLife) {
83
+ if (!(elapsed > 0)) return value;
84
+ return baseline + (value - baseline) * Math.pow(0.5, elapsed / halfLife);
85
+ }
86
+
87
+ // Evidence is stored as short typed strings so every kind of experience can
88
+ // be cited the same way: "m:<event seq>", "t:<thought id>", "d:<day>",
89
+ // "f:<decision id>", "r:<passage id>", "a:<anticipation id>",
90
+ // "g:<meeting id>" for what a meeting already meant to her,
91
+ // "s:<self thread>" for something she is living for.
92
+ export function evidence(list) {
93
+ const out = [];
94
+ for (const item of Array.isArray(list) ? list : []) {
95
+ if (Number.isSafeInteger(item) && item > 0) out.push(`m:${item}`);
96
+ else if (
97
+ typeof item === "string" &&
98
+ /^[mtdfrasgxoe]:[\w:.-]{1,80}$/.test(item)
99
+ )
100
+ out.push(item);
101
+ else if (/^\d+$/.test(String(item))) out.push(`m:${item}`);
102
+ }
103
+ return [...new Set(out)].slice(0, 24);
104
+ }
105
+
106
+ export function messageSeqs(sources) {
107
+ return evidence(sources)
108
+ .filter((s) => s.startsWith("m:"))
109
+ .map((s) => Number(s.slice(2)));
110
+ }