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.
- package/.github/SECURITY.md +4 -4
- package/README.en.md +252 -250
- package/README.md +252 -250
- package/bin/luckytri.js +5 -1
- package/docs/en/CHANGELOG.md +8 -0
- package/docs/en/connect.md +18 -18
- package/docs/en/guide.md +192 -216
- package/docs/en/npm-release.md +25 -25
- package/docs/zh/CHANGELOG.md +8 -0
- package/docs/zh/connect.md +17 -17
- package/docs/zh/guide.md +192 -216
- package/docs/zh/npm-release.md +33 -33
- package/package.json +109 -108
- package/plugins/sdk/index.d.ts +155 -155
- package/plugins/sdk/testing.js +58 -58
- package/plugins/weather/index.js +82 -82
- package/plugins/weather/luckytri-plugin.json +29 -29
- package/public/app/assets/ChatsPage-B9Odvzfz.js +3 -0
- package/public/app/assets/Empty-SkA8PyMo.js +2 -0
- package/public/app/assets/Field-BjLhi8pL.js +1 -0
- package/public/app/assets/HeartPage-CscKqMsr.js +1 -0
- package/public/app/assets/LifePage-BHCmBHlH.js +1 -0
- package/public/app/assets/MemoryPage-Bhs2xa1k.js +1 -0
- package/public/app/assets/NaturePage-CaPIar_5.js +3 -0
- package/public/app/assets/PeoplePage-CuwSSVeX.js +1 -0
- package/public/app/assets/PluginsPage-BhVm1SUi.js +2 -0
- package/public/app/assets/PluginsPage-CVVQwEBI.css +1 -0
- package/public/app/assets/{SystemPage-CAMPoYqM.css → SystemPage-5yYqyUgR.css} +1 -1
- package/public/app/assets/SystemPage-Chm5fiGP.js +1 -0
- package/public/app/assets/TimePage-BUm4eUzB.js +3 -0
- package/public/app/assets/index-BIAdfObg.js +4 -0
- package/public/app/assets/{index-YDz1ree1.css → index-DY4e15Kh.css} +1 -1
- package/public/app/assets/{knowledge-DG0e0uKw.js → knowledge-DNDLyN9m.js} +1 -1
- package/public/app/assets/media-CKVAvML2.js +1 -0
- package/public/app/index.html +3 -3
- package/public/guide.en.html +32 -99
- package/public/guide.html +21 -86
- package/public/tutorial.en.md +15 -39
- package/public/tutorial.md +15 -39
- package/scripts/backup.js +311 -311
- package/scripts/browser.js +41 -41
- package/scripts/launch.js +101 -94
- package/scripts/plugin.js +150 -150
- package/scripts/reset-password.js +22 -0
- package/scripts/runtime.js +25 -25
- package/scripts/service.js +56 -47
- package/scripts/setup.js +50 -50
- package/scripts/start-server.js +41 -41
- package/scripts/stop.js +36 -36
- package/server/app.js +110 -96
- package/server/auth.js +217 -0
- package/server/channels/contract.js +57 -57
- package/server/channels/hub.js +165 -165
- package/server/channels/index.js +28 -25
- package/server/channels/onebot/index.js +335 -336
- package/server/channels/onebot/token.js +22 -3
- package/server/core/capabilities.js +208 -208
- package/server/core/events.js +64 -60
- package/server/core/image-preprocessor.js +208 -208
- package/server/core/model-manager.js +1213 -1213
- package/server/core/net-guard.js +49 -49
- package/server/core/orchestrator.js +569 -569
- package/server/core/perceivers.js +91 -91
- package/server/core/persona-manager.js +243 -243
- package/server/core/repository.js +293 -293
- package/server/core/response-validator.js +508 -508
- package/server/core/turn-processor.js +630 -630
- package/server/core/turn.js +236 -236
- package/server/core/vision-manager.js +633 -633
- package/server/i18n/errors.js +512 -497
- package/server/i18n/labels.js +649 -653
- package/server/index.js +107 -102
- package/server/knowledge/manager.js +386 -386
- package/server/local-access.js +32 -0
- package/server/mind/anticipations.js +507 -507
- package/server/mind/api.js +703 -703
- package/server/mind/budget.js +152 -152
- package/server/mind/context-selection.js +61 -61
- package/server/mind/day-planner.js +324 -324
- package/server/mind/evidence.js +148 -148
- package/server/mind/index.js +445 -445
- package/server/mind/life/diary.js +786 -786
- package/server/mind/life/index.js +1049 -1049
- package/server/mind/observations.js +84 -84
- package/server/mind/own-day.js +324 -324
- package/server/mind/own-voice.js +318 -318
- package/server/mind/senses.js +53 -53
- package/server/mind/time/activity-clock.js +196 -196
- package/server/mind/time/availability.js +69 -69
- package/server/mind/time/commitment-review.js +198 -198
- package/server/mind/time/executor.js +512 -512
- package/server/mind/time/experiences.js +128 -128
- package/server/mind/time/games.js +562 -562
- package/server/mind/time/index.js +739 -739
- package/server/mind/time/intent.js +166 -166
- package/server/mind/time/kinds.js +171 -171
- package/server/mind/time/plugin-activity.js +207 -207
- package/server/mind/time/tasks.js +587 -587
- package/server/mind/util.js +110 -110
- package/server/mind/view.js +273 -273
- package/server/paths.js +102 -102
- package/server/plugins/api.js +204 -204
- package/server/plugins/host.js +967 -967
- package/server/plugins/install.js +295 -295
- package/server/plugins/manifest.js +201 -201
- package/server/plugins/permissions.js +42 -42
- package/server/plugins/runner/guard.mjs +36 -36
- package/server/plugins/runner/worker.mjs +250 -250
- package/server/plugins/schema.js +91 -91
- package/server/plugins/zip.js +112 -112
- package/server/startup-lock.js +118 -118
- package/server/storage/archive.js +241 -241
- package/server/storage/backup-cleanup-worker.js +8 -8
- package/server/storage/backup-cleanup.js +414 -414
- package/server/storage/backup-lock.js +76 -76
- package/server/storage/backup-scheduler.js +131 -131
- package/server/storage/store.js +199 -199
- package/server/studio/readiness.js +181 -190
- package/server/studio/settings.js +236 -236
- package/public/app/assets/ChatsPage-C-FcRapR.js +0 -3
- package/public/app/assets/Empty-CpP5kQHH.js +0 -2
- package/public/app/assets/Field-D4gY-INU.js +0 -1
- package/public/app/assets/HeartPage-CPy_thQd.js +0 -1
- package/public/app/assets/LifePage-CxWvwmSf.js +0 -1
- package/public/app/assets/MemoryPage-DC4rhQ68.js +0 -1
- package/public/app/assets/NaturePage-IvYw04Zq.js +0 -3
- package/public/app/assets/PeoplePage-Cqefm9-q.js +0 -1
- package/public/app/assets/PluginsPage-DKSaKvXb.js +0 -2
- package/public/app/assets/PluginsPage-HyBe5D8w.css +0 -1
- package/public/app/assets/SystemPage-CJmtJkrK.js +0 -1
- package/public/app/assets/TimePage-Cw44inM4.js +0 -3
- package/public/app/assets/index-BheRW-1t.js +0 -4
- 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.
|
|
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/
|
|
26
|
-
"scripts/
|
|
27
|
-
"scripts/
|
|
28
|
-
"scripts/
|
|
29
|
-
"scripts/
|
|
30
|
-
"scripts/
|
|
31
|
-
"scripts/
|
|
32
|
-
"scripts/
|
|
33
|
-
"
|
|
34
|
-
"public/app/
|
|
35
|
-
"public/app/assets/*.
|
|
36
|
-
"public/app/assets/*.
|
|
37
|
-
"public/
|
|
38
|
-
"public/plugin-kit/v1/
|
|
39
|
-
"public/
|
|
40
|
-
"public/guide.
|
|
41
|
-
"public/
|
|
42
|
-
"public/tutorial.
|
|
43
|
-
"
|
|
44
|
-
"plugins/weather/
|
|
45
|
-
"plugins/
|
|
46
|
-
"plugins/sdk/
|
|
47
|
-
"
|
|
48
|
-
"docs/
|
|
49
|
-
"docs/
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"build": "
|
|
75
|
-
"
|
|
76
|
-
"test
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"test:
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"format
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
"@
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
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
|
+
}
|
package/plugins/sdk/index.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/plugins/sdk/testing.js
CHANGED
|
@@ -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
|
+
}
|