luckytri 1.0.0 → 1.0.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.
Files changed (133) 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 +192 -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 +192 -216
  12. package/docs/zh/npm-release.md +33 -33
  13. package/package.json +109 -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-B9Odvzfz.js +3 -0
  19. package/public/app/assets/Empty-SkA8PyMo.js +2 -0
  20. package/public/app/assets/Field-BjLhi8pL.js +1 -0
  21. package/public/app/assets/HeartPage-CscKqMsr.js +1 -0
  22. package/public/app/assets/LifePage-BHCmBHlH.js +1 -0
  23. package/public/app/assets/MemoryPage-Bhs2xa1k.js +1 -0
  24. package/public/app/assets/NaturePage-CaPIar_5.js +3 -0
  25. package/public/app/assets/PeoplePage-CuwSSVeX.js +1 -0
  26. package/public/app/assets/PluginsPage-BhVm1SUi.js +2 -0
  27. package/public/app/assets/PluginsPage-CVVQwEBI.css +1 -0
  28. package/public/app/assets/{SystemPage-CAMPoYqM.css → SystemPage-5yYqyUgR.css} +1 -1
  29. package/public/app/assets/SystemPage-Chm5fiGP.js +1 -0
  30. package/public/app/assets/TimePage-BUm4eUzB.js +3 -0
  31. package/public/app/assets/index-BIAdfObg.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-DNDLyN9m.js} +1 -1
  34. package/public/app/assets/media-CKVAvML2.js +1 -0
  35. package/public/app/index.html +3 -3
  36. package/public/guide.en.html +32 -99
  37. package/public/guide.html +21 -86
  38. package/public/tutorial.en.md +15 -39
  39. package/public/tutorial.md +15 -39
  40. package/scripts/backup.js +311 -311
  41. package/scripts/browser.js +41 -41
  42. package/scripts/launch.js +101 -94
  43. package/scripts/plugin.js +150 -150
  44. package/scripts/reset-password.js +22 -0
  45. package/scripts/runtime.js +25 -25
  46. package/scripts/service.js +56 -47
  47. package/scripts/setup.js +50 -50
  48. package/scripts/start-server.js +41 -41
  49. package/scripts/stop.js +36 -36
  50. package/server/app.js +110 -96
  51. package/server/auth.js +217 -0
  52. package/server/channels/contract.js +57 -57
  53. package/server/channels/hub.js +165 -165
  54. package/server/channels/index.js +28 -25
  55. package/server/channels/onebot/index.js +335 -336
  56. package/server/channels/onebot/token.js +22 -3
  57. package/server/core/capabilities.js +208 -208
  58. package/server/core/events.js +64 -60
  59. package/server/core/image-preprocessor.js +208 -208
  60. package/server/core/model-manager.js +1213 -1213
  61. package/server/core/net-guard.js +49 -49
  62. package/server/core/orchestrator.js +569 -569
  63. package/server/core/perceivers.js +91 -91
  64. package/server/core/persona-manager.js +243 -243
  65. package/server/core/repository.js +293 -293
  66. package/server/core/response-validator.js +508 -508
  67. package/server/core/turn-processor.js +630 -630
  68. package/server/core/turn.js +236 -236
  69. package/server/core/vision-manager.js +633 -633
  70. package/server/i18n/errors.js +512 -497
  71. package/server/i18n/labels.js +649 -653
  72. package/server/index.js +107 -102
  73. package/server/knowledge/manager.js +386 -386
  74. package/server/local-access.js +32 -0
  75. package/server/mind/anticipations.js +507 -507
  76. package/server/mind/api.js +703 -703
  77. package/server/mind/budget.js +152 -152
  78. package/server/mind/context-selection.js +61 -61
  79. package/server/mind/day-planner.js +324 -324
  80. package/server/mind/evidence.js +148 -148
  81. package/server/mind/index.js +445 -445
  82. package/server/mind/life/diary.js +786 -786
  83. package/server/mind/life/index.js +1049 -1049
  84. package/server/mind/observations.js +84 -84
  85. package/server/mind/own-day.js +324 -324
  86. package/server/mind/own-voice.js +318 -318
  87. package/server/mind/senses.js +53 -53
  88. package/server/mind/time/activity-clock.js +196 -196
  89. package/server/mind/time/availability.js +69 -69
  90. package/server/mind/time/commitment-review.js +198 -198
  91. package/server/mind/time/executor.js +512 -512
  92. package/server/mind/time/experiences.js +128 -128
  93. package/server/mind/time/games.js +562 -562
  94. package/server/mind/time/index.js +739 -739
  95. package/server/mind/time/intent.js +166 -166
  96. package/server/mind/time/kinds.js +171 -171
  97. package/server/mind/time/plugin-activity.js +207 -207
  98. package/server/mind/time/tasks.js +587 -587
  99. package/server/mind/util.js +110 -110
  100. package/server/mind/view.js +273 -273
  101. package/server/paths.js +102 -102
  102. package/server/plugins/api.js +204 -204
  103. package/server/plugins/host.js +967 -967
  104. package/server/plugins/install.js +295 -295
  105. package/server/plugins/manifest.js +201 -201
  106. package/server/plugins/permissions.js +42 -42
  107. package/server/plugins/runner/guard.mjs +36 -36
  108. package/server/plugins/runner/worker.mjs +250 -250
  109. package/server/plugins/schema.js +91 -91
  110. package/server/plugins/zip.js +112 -112
  111. package/server/startup-lock.js +118 -118
  112. package/server/storage/archive.js +241 -241
  113. package/server/storage/backup-cleanup-worker.js +8 -8
  114. package/server/storage/backup-cleanup.js +414 -414
  115. package/server/storage/backup-lock.js +76 -76
  116. package/server/storage/backup-scheduler.js +131 -131
  117. package/server/storage/store.js +199 -199
  118. package/server/studio/readiness.js +181 -190
  119. package/server/studio/settings.js +236 -236
  120. package/public/app/assets/ChatsPage-C-FcRapR.js +0 -3
  121. package/public/app/assets/Empty-CpP5kQHH.js +0 -2
  122. package/public/app/assets/Field-D4gY-INU.js +0 -1
  123. package/public/app/assets/HeartPage-CPy_thQd.js +0 -1
  124. package/public/app/assets/LifePage-CxWvwmSf.js +0 -1
  125. package/public/app/assets/MemoryPage-DC4rhQ68.js +0 -1
  126. package/public/app/assets/NaturePage-IvYw04Zq.js +0 -3
  127. package/public/app/assets/PeoplePage-Cqefm9-q.js +0 -1
  128. package/public/app/assets/PluginsPage-DKSaKvXb.js +0 -2
  129. package/public/app/assets/PluginsPage-HyBe5D8w.css +0 -1
  130. package/public/app/assets/SystemPage-CJmtJkrK.js +0 -1
  131. package/public/app/assets/TimePage-Cw44inM4.js +0 -3
  132. package/public/app/assets/index-BheRW-1t.js +0 -4
  133. package/public/app/assets/media-BzPDBm7e.js +0 -1
package/package.json CHANGED
@@ -1,108 +1,109 @@
1
- {
2
- "name": "luckytri",
3
- "version": "1.0.0",
4
- "description": "让由技术诞生的她,在时间、记忆、相遇与选择中逐渐形成自己的方向",
5
- "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/TodayYueC/LuckyTri.git"
9
- },
10
- "bugs": {
11
- "url": "https://github.com/TodayYueC/LuckyTri/issues"
12
- },
13
- "homepage": "https://github.com/TodayYueC/LuckyTri",
14
- "type": "module",
15
- "bin": {
16
- "luckytri": "bin/luckytri.js"
17
- },
18
- "files": [
19
- "bin/luckytri.js",
20
- "server/**/*.js",
21
- "server/plugins/runner/*.mjs",
22
- "scripts/launch.js",
23
- "scripts/start-server.js",
24
- "scripts/stop.js",
25
- "scripts/setup.js",
26
- "scripts/runtime.js",
27
- "scripts/service.js",
28
- "scripts/browser.js",
29
- "scripts/proxy-config.js",
30
- "scripts/backup.js",
31
- "scripts/recover.js",
32
- "scripts/plugin.js",
33
- "public/app/index.html",
34
- "public/app/assets/*.js",
35
- "public/app/assets/*.css",
36
- "public/app/assets/*.png",
37
- "public/plugin-kit/v1/bridge.js",
38
- "public/plugin-kit/v1/kit.css",
39
- "public/guide.html",
40
- "public/guide.en.html",
41
- "public/tutorial.md",
42
- "public/tutorial.en.md",
43
- "plugins/weather/index.js",
44
- "plugins/weather/luckytri-plugin.json",
45
- "plugins/sdk/index.d.ts",
46
- "plugins/sdk/testing.js",
47
- "docs/zh/*.md",
48
- "docs/en/*.md",
49
- "docs/brand/*.png",
50
- ".github/SECURITY.md",
51
- "README.en.md",
52
- "LICENSE"
53
- ],
54
- "publishConfig": {
55
- "access": "public",
56
- "registry": "https://registry.npmjs.org/"
57
- },
58
- "keywords": [
59
- "qq",
60
- "onebot",
61
- "chatbot",
62
- "ai",
63
- "memory",
64
- "webui"
65
- ],
66
- "engines": {
67
- "node": ">=24.5"
68
- },
69
- "scripts": {
70
- "launch": "node scripts/launch.js",
71
- "start": "node scripts/start-server.js",
72
- "dev:ui": "vite --config studio-web/vite.config.ts",
73
- "build:ui": "vite build --config studio-web/vite.config.ts",
74
- "build": "npm run build:ui && npm run docs:build",
75
- "test": "node --import ./tests/helpers/awake.mjs --test tests/*.test.js",
76
- "test:clock": "node scripts/dev/test-clock.js",
77
- "audit:sent": "node --env-file-if-exists=.env scripts/dev/audit-sent.js",
78
- "test:ui": "node tests/ui/smoke.js && node tests/ui/ta.mjs && node tests/ui/navigation.mjs && node tests/ui/time.mjs && node tests/ui/time-arrangement.mjs && node tests/ui/performance.mjs && node tests/ui/search.mjs && node tests/ui/storage.mjs && node tests/ui/i18n.mjs",
79
- "setup": "node scripts/setup.js",
80
- "stop": "node scripts/stop.js",
81
- "backup": "node scripts/backup.js",
82
- "recovery": "node scripts/recover.js",
83
- "docs:build": "node scripts/build-guide.js",
84
- "plugin": "node scripts/plugin.js",
85
- "pack:check": "node scripts/pack-check.js",
86
- "test:package": "node scripts/test-package.js",
87
- "test:registry": "node scripts/test-package.js --registry",
88
- "prepack": "npm run build && npm run pack:check",
89
- "prepublishOnly": "npm run build && npm test && npm run test:package",
90
- "release:check": "npm run build && npm test && npm run test:ui && npm run test:package",
91
- "format": "prettier --write bin server studio-web scripts tests plugins package.json",
92
- "format:check": "prettier --check bin server studio-web scripts tests plugins package.json"
93
- },
94
- "dependencies": {
95
- "express": "^5.1.0",
96
- "sharp": "^0.35.5",
97
- "ws": "^8.18.3"
98
- },
99
- "devDependencies": {
100
- "@playwright/test": "^1.55.0",
101
- "@vitejs/plugin-vue": "^6.0.9",
102
- "marked": "^18.0.13",
103
- "prettier": "^3.9.8",
104
- "typescript": "^7.0.2",
105
- "vite": "^8.3.0",
106
- "vue": "^3.5.43"
107
- }
108
- }
1
+ {
2
+ "name": "luckytri",
3
+ "version": "1.0.1",
4
+ "description": "让由技术诞生的她,在时间、记忆、相遇与选择中逐渐形成自己的方向",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/TodayYueC/LuckyTri.git"
9
+ },
10
+ "bugs": {
11
+ "url": "https://github.com/TodayYueC/LuckyTri/issues"
12
+ },
13
+ "homepage": "https://github.com/TodayYueC/LuckyTri",
14
+ "type": "module",
15
+ "bin": {
16
+ "luckytri": "bin/luckytri.js"
17
+ },
18
+ "files": [
19
+ "bin/luckytri.js",
20
+ "server/**/*.js",
21
+ "server/plugins/runner/*.mjs",
22
+ "scripts/launch.js",
23
+ "scripts/start-server.js",
24
+ "scripts/stop.js",
25
+ "scripts/reset-password.js",
26
+ "scripts/setup.js",
27
+ "scripts/runtime.js",
28
+ "scripts/service.js",
29
+ "scripts/browser.js",
30
+ "scripts/proxy-config.js",
31
+ "scripts/backup.js",
32
+ "scripts/recover.js",
33
+ "scripts/plugin.js",
34
+ "public/app/index.html",
35
+ "public/app/assets/*.js",
36
+ "public/app/assets/*.css",
37
+ "public/app/assets/*.png",
38
+ "public/plugin-kit/v1/bridge.js",
39
+ "public/plugin-kit/v1/kit.css",
40
+ "public/guide.html",
41
+ "public/guide.en.html",
42
+ "public/tutorial.md",
43
+ "public/tutorial.en.md",
44
+ "plugins/weather/index.js",
45
+ "plugins/weather/luckytri-plugin.json",
46
+ "plugins/sdk/index.d.ts",
47
+ "plugins/sdk/testing.js",
48
+ "docs/zh/*.md",
49
+ "docs/en/*.md",
50
+ "docs/brand/*.png",
51
+ ".github/SECURITY.md",
52
+ "README.en.md",
53
+ "LICENSE"
54
+ ],
55
+ "publishConfig": {
56
+ "access": "public",
57
+ "registry": "https://registry.npmjs.org/"
58
+ },
59
+ "keywords": [
60
+ "qq",
61
+ "onebot",
62
+ "chatbot",
63
+ "ai",
64
+ "memory",
65
+ "webui"
66
+ ],
67
+ "engines": {
68
+ "node": ">=24.5"
69
+ },
70
+ "scripts": {
71
+ "launch": "node scripts/launch.js",
72
+ "start": "node scripts/start-server.js",
73
+ "dev:ui": "vite --config studio-web/vite.config.ts",
74
+ "build:ui": "vite build --config studio-web/vite.config.ts",
75
+ "build": "npm run build:ui && npm run docs:build",
76
+ "test": "node --import ./tests/helpers/awake.mjs --test tests/*.test.js",
77
+ "test:clock": "node scripts/dev/test-clock.js",
78
+ "audit:sent": "node --env-file-if-exists=.env scripts/dev/audit-sent.js",
79
+ "test:ui": "node tests/ui/access.mjs && node tests/ui/smoke.js && node tests/ui/ta.mjs && node tests/ui/navigation.mjs && node tests/ui/time.mjs && node tests/ui/time-arrangement.mjs && node tests/ui/performance.mjs && node tests/ui/search.mjs && node tests/ui/storage.mjs && node tests/ui/i18n.mjs",
80
+ "setup": "node scripts/setup.js",
81
+ "stop": "node scripts/stop.js",
82
+ "backup": "node scripts/backup.js",
83
+ "recovery": "node scripts/recover.js",
84
+ "docs:build": "node scripts/build-guide.js",
85
+ "plugin": "node scripts/plugin.js",
86
+ "pack:check": "node scripts/pack-check.js",
87
+ "test:package": "node scripts/test-package.js",
88
+ "test:registry": "node scripts/test-package.js --registry",
89
+ "prepack": "npm run build && npm run pack:check",
90
+ "prepublishOnly": "npm run build && npm test && npm run test:package",
91
+ "release:check": "npm run build && npm test && npm run test:ui && npm run test:package",
92
+ "format": "prettier --write bin server studio-web scripts tests plugins package.json",
93
+ "format:check": "prettier --check bin server studio-web scripts tests plugins package.json"
94
+ },
95
+ "dependencies": {
96
+ "express": "^5.1.0",
97
+ "sharp": "^0.35.5",
98
+ "ws": "^8.18.3"
99
+ },
100
+ "devDependencies": {
101
+ "@playwright/test": "^1.55.0",
102
+ "@vitejs/plugin-vue": "^6.0.9",
103
+ "marked": "^18.0.13",
104
+ "prettier": "^3.9.8",
105
+ "typescript": "^7.0.2",
106
+ "vite": "^8.3.0",
107
+ "vue": "^3.5.43"
108
+ }
109
+ }
@@ -1,155 +1,155 @@
1
- // LuckyTri Plugin API v1. A later API can be added beside this one;
2
- // v1 stays available through the 1.x line.
3
-
4
- export interface PluginManifest {
5
- id: string;
6
- name: string;
7
- version: string;
8
- pluginApi: "1.0";
9
- luckytri?: string;
10
- description?: string;
11
- author?: string;
12
- license?: string;
13
- entry?: string;
14
- permissions?: string[];
15
- network?: string[];
16
- settings?: PluginSetting[];
17
- contributes?: PluginContributes;
18
- }
19
-
20
- export interface PluginSetting {
21
- key: string;
22
- type:
23
- "text" | "secret" | "number" | "boolean" | "select" | "textarea" | "urls";
24
- label: string;
25
- required?: boolean;
26
- default?: unknown;
27
- allowNetwork?: boolean;
28
- }
29
-
30
- export interface PluginContributes {
31
- senses?: string[];
32
- channels?: {
33
- type: string;
34
- label?: string;
35
- capabilities?: Record<string, boolean>;
36
- }[];
37
- activities?: {
38
- kind: string;
39
- label?: string;
40
- describe?: string;
41
- keywords?: string;
42
- minutes?: number;
43
- energy?: boolean;
44
- }[];
45
- actions?: {
46
- name: string;
47
- label?: string;
48
- describe?: string;
49
- risk?: "low" | "high";
50
- confirm?: "none" | "owner";
51
- where?: "private" | "any";
52
- dailyLimit?: number;
53
- }[];
54
- perceive?: string[];
55
- ui?: { page?: boolean };
56
- }
57
-
58
- export interface PluginContext {
59
- plugin: { id: string; version: string; dataDir: string };
60
- api: { version: "1.0"; has(feature: string): boolean };
61
- now(): Promise<number>;
62
- log: {
63
- info(...parts: unknown[]): Promise<void>;
64
- warn(...parts: unknown[]): Promise<void>;
65
- error(...parts: unknown[]): Promise<void>;
66
- };
67
- settings: {
68
- get(): Promise<Record<string, unknown>>;
69
- onChange(fn: () => void): void;
70
- };
71
- storage: {
72
- get(key: string): Promise<unknown>;
73
- set(key: string, value: unknown): Promise<void>;
74
- delete(key: string): Promise<void>;
75
- list(prefix?: string): Promise<string[]>;
76
- };
77
- net: { fetch(url: string, init?: RequestInit): Promise<Response> };
78
- mind: {
79
- state(): Promise<Record<string, unknown>>;
80
- observe(input: {
81
- summary: string;
82
- detail?: string;
83
- discretion?: "open" | "private";
84
- }): Promise<{ ref?: string; rejected?: string }>;
85
- on(event: string, fn: (payload: unknown) => void): void;
86
- };
87
- senses: {
88
- set(
89
- key: string,
90
- sense: {
91
- text: string;
92
- discretion?: "open" | "private";
93
- ttlMinutes?: number;
94
- },
95
- ): Promise<void>;
96
- clear(key?: string): Promise<void>;
97
- };
98
- knowledge: {
99
- offer(doc: {
100
- title: string;
101
- text: string;
102
- url?: string;
103
- }): Promise<{ id: string }>;
104
- };
105
- activities: {
106
- handle(
107
- kind: string,
108
- prepare: (input: unknown) => Promise<unknown>,
109
- ): Promise<void>;
110
- setAvailable(kind: string, reason?: string): Promise<void>;
111
- };
112
- actions: {
113
- handle(
114
- name: string,
115
- run: (input: unknown) => Promise<unknown>,
116
- ): Promise<void>;
117
- };
118
- perceive: {
119
- handle(
120
- type: string,
121
- run: (input: unknown) => Promise<{ text?: string }>,
122
- ): Promise<void>;
123
- };
124
- channel: {
125
- provide(type: string, impl: Record<string, unknown>): Promise<void>;
126
- receive(type: string, message: Record<string, unknown>): Promise<void>;
127
- status(type: string, status: { online?: boolean }): Promise<void>;
128
- reachable(type: string, sessionKey: string, ok: boolean): Promise<void>;
129
- };
130
- models: { call(req: { system: string; input: unknown }): Promise<unknown> };
131
- http: {
132
- route(
133
- method: string,
134
- path: string,
135
- handler: (input: unknown) => Promise<unknown>,
136
- ): Promise<void>;
137
- hook(
138
- method: string,
139
- path: string,
140
- handler: (input: unknown) => Promise<unknown>,
141
- ): Promise<void>;
142
- };
143
- status: {
144
- set(status: {
145
- text: string;
146
- tone?: "ok" | "warn" | "error";
147
- }): Promise<void>;
148
- };
149
- notify(notice: { title: string; text: string }): Promise<void>;
150
- }
151
-
152
- export interface LuckyTriPlugin {
153
- activate(ctx: PluginContext): void | Promise<void>;
154
- deactivate?(): void | Promise<void>;
155
- }
1
+ // LuckyTri Plugin API v1. A later API can be added beside this one;
2
+ // v1 stays available through the 1.x line.
3
+
4
+ export interface PluginManifest {
5
+ id: string;
6
+ name: string;
7
+ version: string;
8
+ pluginApi: "1.0";
9
+ luckytri?: string;
10
+ description?: string;
11
+ author?: string;
12
+ license?: string;
13
+ entry?: string;
14
+ permissions?: string[];
15
+ network?: string[];
16
+ settings?: PluginSetting[];
17
+ contributes?: PluginContributes;
18
+ }
19
+
20
+ export interface PluginSetting {
21
+ key: string;
22
+ type:
23
+ "text" | "secret" | "number" | "boolean" | "select" | "textarea" | "urls";
24
+ label: string;
25
+ required?: boolean;
26
+ default?: unknown;
27
+ allowNetwork?: boolean;
28
+ }
29
+
30
+ export interface PluginContributes {
31
+ senses?: string[];
32
+ channels?: {
33
+ type: string;
34
+ label?: string;
35
+ capabilities?: Record<string, boolean>;
36
+ }[];
37
+ activities?: {
38
+ kind: string;
39
+ label?: string;
40
+ describe?: string;
41
+ keywords?: string;
42
+ minutes?: number;
43
+ energy?: boolean;
44
+ }[];
45
+ actions?: {
46
+ name: string;
47
+ label?: string;
48
+ describe?: string;
49
+ risk?: "low" | "high";
50
+ confirm?: "none" | "owner";
51
+ where?: "private" | "any";
52
+ dailyLimit?: number;
53
+ }[];
54
+ perceive?: string[];
55
+ ui?: { page?: boolean };
56
+ }
57
+
58
+ export interface PluginContext {
59
+ plugin: { id: string; version: string; dataDir: string };
60
+ api: { version: "1.0"; has(feature: string): boolean };
61
+ now(): Promise<number>;
62
+ log: {
63
+ info(...parts: unknown[]): Promise<void>;
64
+ warn(...parts: unknown[]): Promise<void>;
65
+ error(...parts: unknown[]): Promise<void>;
66
+ };
67
+ settings: {
68
+ get(): Promise<Record<string, unknown>>;
69
+ onChange(fn: () => void): void;
70
+ };
71
+ storage: {
72
+ get(key: string): Promise<unknown>;
73
+ set(key: string, value: unknown): Promise<void>;
74
+ delete(key: string): Promise<void>;
75
+ list(prefix?: string): Promise<string[]>;
76
+ };
77
+ net: { fetch(url: string, init?: RequestInit): Promise<Response> };
78
+ mind: {
79
+ state(): Promise<Record<string, unknown>>;
80
+ observe(input: {
81
+ summary: string;
82
+ detail?: string;
83
+ discretion?: "open" | "private";
84
+ }): Promise<{ ref?: string; rejected?: string }>;
85
+ on(event: string, fn: (payload: unknown) => void): void;
86
+ };
87
+ senses: {
88
+ set(
89
+ key: string,
90
+ sense: {
91
+ text: string;
92
+ discretion?: "open" | "private";
93
+ ttlMinutes?: number;
94
+ },
95
+ ): Promise<void>;
96
+ clear(key?: string): Promise<void>;
97
+ };
98
+ knowledge: {
99
+ offer(doc: {
100
+ title: string;
101
+ text: string;
102
+ url?: string;
103
+ }): Promise<{ id: string }>;
104
+ };
105
+ activities: {
106
+ handle(
107
+ kind: string,
108
+ prepare: (input: unknown) => Promise<unknown>,
109
+ ): Promise<void>;
110
+ setAvailable(kind: string, reason?: string): Promise<void>;
111
+ };
112
+ actions: {
113
+ handle(
114
+ name: string,
115
+ run: (input: unknown) => Promise<unknown>,
116
+ ): Promise<void>;
117
+ };
118
+ perceive: {
119
+ handle(
120
+ type: string,
121
+ run: (input: unknown) => Promise<{ text?: string }>,
122
+ ): Promise<void>;
123
+ };
124
+ channel: {
125
+ provide(type: string, impl: Record<string, unknown>): Promise<void>;
126
+ receive(type: string, message: Record<string, unknown>): Promise<void>;
127
+ status(type: string, status: { online?: boolean }): Promise<void>;
128
+ reachable(type: string, sessionKey: string, ok: boolean): Promise<void>;
129
+ };
130
+ models: { call(req: { system: string; input: unknown }): Promise<unknown> };
131
+ http: {
132
+ route(
133
+ method: string,
134
+ path: string,
135
+ handler: (input: unknown) => Promise<unknown>,
136
+ ): Promise<void>;
137
+ hook(
138
+ method: string,
139
+ path: string,
140
+ handler: (input: unknown) => Promise<unknown>,
141
+ ): Promise<void>;
142
+ };
143
+ status: {
144
+ set(status: {
145
+ text: string;
146
+ tone?: "ok" | "warn" | "error";
147
+ }): Promise<void>;
148
+ };
149
+ notify(notice: { title: string; text: string }): Promise<void>;
150
+ }
151
+
152
+ export interface LuckyTriPlugin {
153
+ activate(ctx: PluginContext): void | Promise<void>;
154
+ deactivate?(): void | Promise<void>;
155
+ }
@@ -1,58 +1,58 @@
1
- // An in-process stand-in for the host, so a plugin can be exercised without
2
- // starting the sandbox. It records calls; it does not grant real abilities.
3
- export function fakeContext(id = "example") {
4
- const calls = [];
5
- const note = (method, params) => {
6
- calls.push({ method, params });
7
- return Promise.resolve({ ok: true });
8
- };
9
- const ctx = {
10
- plugin: { id, version: "0.0.0", dataDir: "" },
11
- api: { version: "1.0", has: () => true },
12
- now: () => Promise.resolve(0),
13
- log: {
14
- info: (...a) => note("log", a),
15
- warn: (...a) => note("log", a),
16
- error: (...a) => note("log", a),
17
- },
18
- settings: { get: () => Promise.resolve({}), onChange() {} },
19
- storage: {
20
- get: () => Promise.resolve(null),
21
- set: (key, value) => note("storage.set", { key, value }),
22
- delete: (key) => note("storage.delete", { key }),
23
- list: () => Promise.resolve([]),
24
- },
25
- net: { fetch: (url) => note("net.fetch", { url }) },
26
- mind: {
27
- state: () => note("mind.state"),
28
- observe: (input) => note("observe", input),
29
- on() {},
30
- },
31
- senses: {
32
- set: (key, sense) => note("senses.set", { key, sense }),
33
- clear: (key) => note("senses.clear", { key }),
34
- },
35
- knowledge: { offer: (doc) => note("knowledge.offer", doc) },
36
- activities: {
37
- handle: (kind) => note("activities.handle", { kind }),
38
- setAvailable: (kind, reason) =>
39
- note("activities.available", { kind, reason }),
40
- },
41
- actions: { handle: (name) => note("actions.handle", { name }) },
42
- perceive: { handle: (type) => note("perceive.handle", { type }) },
43
- channel: {
44
- provide: (type) => note("channel.provide", { type }),
45
- receive: (type, message) => note("channel.receive", { type, message }),
46
- status: (type, status) => note("channel.status", { type, status }),
47
- reachable: () => Promise.resolve({ ok: true }),
48
- },
49
- models: { call: (req) => note("models.call", req) },
50
- http: {
51
- route: (method, path) => note("http.route", { method, path }),
52
- hook: (method, path) => note("http.hook", { method, path }),
53
- },
54
- status: { set: (status) => note("status.set", status) },
55
- notify: (notice) => note("notify", notice),
56
- };
57
- return { ctx, calls };
58
- }
1
+ // An in-process stand-in for the host, so a plugin can be exercised without
2
+ // starting the sandbox. It records calls; it does not grant real abilities.
3
+ export function fakeContext(id = "example") {
4
+ const calls = [];
5
+ const note = (method, params) => {
6
+ calls.push({ method, params });
7
+ return Promise.resolve({ ok: true });
8
+ };
9
+ const ctx = {
10
+ plugin: { id, version: "0.0.0", dataDir: "" },
11
+ api: { version: "1.0", has: () => true },
12
+ now: () => Promise.resolve(0),
13
+ log: {
14
+ info: (...a) => note("log", a),
15
+ warn: (...a) => note("log", a),
16
+ error: (...a) => note("log", a),
17
+ },
18
+ settings: { get: () => Promise.resolve({}), onChange() {} },
19
+ storage: {
20
+ get: () => Promise.resolve(null),
21
+ set: (key, value) => note("storage.set", { key, value }),
22
+ delete: (key) => note("storage.delete", { key }),
23
+ list: () => Promise.resolve([]),
24
+ },
25
+ net: { fetch: (url) => note("net.fetch", { url }) },
26
+ mind: {
27
+ state: () => note("mind.state"),
28
+ observe: (input) => note("observe", input),
29
+ on() {},
30
+ },
31
+ senses: {
32
+ set: (key, sense) => note("senses.set", { key, sense }),
33
+ clear: (key) => note("senses.clear", { key }),
34
+ },
35
+ knowledge: { offer: (doc) => note("knowledge.offer", doc) },
36
+ activities: {
37
+ handle: (kind) => note("activities.handle", { kind }),
38
+ setAvailable: (kind, reason) =>
39
+ note("activities.available", { kind, reason }),
40
+ },
41
+ actions: { handle: (name) => note("actions.handle", { name }) },
42
+ perceive: { handle: (type) => note("perceive.handle", { type }) },
43
+ channel: {
44
+ provide: (type) => note("channel.provide", { type }),
45
+ receive: (type, message) => note("channel.receive", { type, message }),
46
+ status: (type, status) => note("channel.status", { type, status }),
47
+ reachable: () => Promise.resolve({ ok: true }),
48
+ },
49
+ models: { call: (req) => note("models.call", req) },
50
+ http: {
51
+ route: (method, path) => note("http.route", { method, path }),
52
+ hook: (method, path) => note("http.hook", { method, path }),
53
+ },
54
+ status: { set: (status) => note("status.set", status) },
55
+ notify: (notice) => note("notify", notice),
56
+ };
57
+ return { ctx, calls };
58
+ }