dsh-world 0.7.6 → 0.8.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.
Files changed (102) hide show
  1. package/CHANGELOG.md +541 -479
  2. package/CONTRIBUTING.md +174 -174
  3. package/INSTALL.md +314 -314
  4. package/NOTES.md +57 -3
  5. package/README.md +332 -259
  6. package/client/index.js +1126 -991
  7. package/lib/compaction.d.ts +1 -0
  8. package/lib/compaction.js +1 -1
  9. package/lib/console/routes.d.ts +11 -3
  10. package/lib/console/routes.js +12 -7
  11. package/lib/console/snapshot.d.ts +2 -0
  12. package/lib/console/snapshot.js +1 -0
  13. package/lib/ecosystem/computer/browser/browser.d.ts +34 -0
  14. package/lib/ecosystem/computer/browser/browser.js +101 -0
  15. package/lib/ecosystem/computer/browser/cdp.d.ts +22 -0
  16. package/lib/ecosystem/computer/browser/cdp.js +91 -0
  17. package/lib/ecosystem/computer/browser/edge.d.ts +15 -0
  18. package/lib/ecosystem/computer/browser/edge.js +80 -0
  19. package/lib/ecosystem/computer/browser/page.d.ts +41 -0
  20. package/lib/ecosystem/computer/browser/page.js +140 -0
  21. package/lib/ecosystem/computer/browser/pageLib.d.ts +7 -0
  22. package/lib/ecosystem/computer/browser/pageLib.js +106 -0
  23. package/lib/ecosystem/computer/desktop/desktop.d.ts +91 -0
  24. package/lib/ecosystem/computer/desktop/desktop.js +322 -0
  25. package/lib/ecosystem/computer/desktop/driver.d.ts +34 -0
  26. package/lib/ecosystem/computer/desktop/driver.js +197 -0
  27. package/lib/ecosystem/computer/desktop/processes.d.ts +5 -0
  28. package/lib/ecosystem/computer/desktop/processes.js +15 -0
  29. package/lib/ecosystem/computer/desktop/recording.d.ts +77 -0
  30. package/lib/ecosystem/computer/desktop/recording.js +187 -0
  31. package/lib/ecosystem/computer/desktop/screen.d.ts +33 -0
  32. package/lib/ecosystem/computer/desktop/screen.js +182 -0
  33. package/lib/ecosystem/computer/desktop/turns.d.ts +58 -0
  34. package/lib/ecosystem/computer/desktop/turns.js +94 -0
  35. package/lib/ecosystem/computer/desktop/watching.d.ts +25 -0
  36. package/lib/ecosystem/computer/desktop/watching.js +81 -0
  37. package/lib/ecosystem/computer/inbox/inbox.d.ts +32 -0
  38. package/lib/ecosystem/computer/inbox/inbox.js +142 -0
  39. package/lib/ecosystem/computer/index.d.ts +82 -0
  40. package/lib/ecosystem/computer/index.js +133 -0
  41. package/lib/ecosystem/computer/procedures/alarm.d.ts +13 -0
  42. package/lib/ecosystem/computer/procedures/alarm.js +46 -0
  43. package/lib/ecosystem/computer/procedures/archive.d.ts +32 -0
  44. package/lib/ecosystem/computer/procedures/archive.js +68 -0
  45. package/lib/ecosystem/computer/procedures/catalog.d.ts +7 -0
  46. package/lib/ecosystem/computer/procedures/catalog.js +75 -0
  47. package/lib/ecosystem/computer/procedures/format.d.ts +167 -0
  48. package/lib/ecosystem/computer/procedures/format.js +332 -0
  49. package/lib/ecosystem/computer/procedures/library.d.ts +53 -0
  50. package/lib/ecosystem/computer/procedures/library.js +178 -0
  51. package/lib/ecosystem/computer/procedures/run.d.ts +80 -0
  52. package/lib/ecosystem/computer/procedures/run.js +245 -0
  53. package/lib/ecosystem/computer/tools.d.ts +21 -0
  54. package/lib/ecosystem/computer/tools.js +197 -0
  55. package/lib/ecosystem/qq-native/images.d.ts +3 -0
  56. package/lib/ecosystem/qq-native/images.js +18 -6
  57. package/lib/ecosystem/qq-native/index.js +2 -2
  58. package/lib/ecosystem/shared/turn.d.ts +3 -0
  59. package/lib/ecosystem/shared/turn.js +13 -3
  60. package/lib/ecosystem/wechat/home.d.ts +1 -0
  61. package/lib/ecosystem/wechat/home.js +9 -3
  62. package/lib/ecosystem/wechat/images.js +3 -5
  63. package/lib/ecosystem/wechat/index.d.ts +1 -0
  64. package/lib/ecosystem/wechat/reading.d.ts +1 -1
  65. package/lib/ecosystem/wechat/reading.js +2 -2
  66. package/lib/history.js +2 -1
  67. package/lib/images.d.ts +30 -0
  68. package/lib/images.js +101 -0
  69. package/lib/index.d.ts +4 -0
  70. package/lib/index.js +90 -5
  71. package/lib/life/photoTools.js +4 -15
  72. package/lib/life/runtime.d.ts +12 -2
  73. package/lib/life/runtime.js +93 -12
  74. package/lib/life/toolRegistry.d.ts +9 -3
  75. package/lib/life/toolRegistry.js +46 -27
  76. package/lib/life/turnCost.d.ts +16 -0
  77. package/lib/life/turnCost.js +44 -0
  78. package/lib/life/types.d.ts +17 -0
  79. package/lib/memoryTools.d.ts +2 -1
  80. package/lib/memoryTools.js +16 -3
  81. package/lib/promptSection.d.ts +1 -0
  82. package/lib/promptSection.js +29 -42
  83. package/lib/runtime.js +1 -1
  84. package/lib/types.d.ts +4 -0
  85. package/lib/worldAdd.d.ts +9 -0
  86. package/lib/worldAdd.js +39 -0
  87. package/lib/worldPrompt.d.ts +3 -2
  88. package/lib/worldPrompt.js +3 -2
  89. package/lib/worldRoutes.d.ts +5 -2
  90. package/lib/worldRoutes.js +29 -4
  91. package/lib/worldSwitch.d.ts +8 -2
  92. package/lib/worldSwitch.js +11 -5
  93. package/package.json +132 -129
  94. package/src/ecosystem/README.md +2 -1
  95. package/src/ecosystem/computer/NOTICE.md +27 -0
  96. package/src/ecosystem/computer/README.md +244 -0
  97. package/src/ecosystem/computer/desktop/win32.ps1 +858 -0
  98. package/src/ecosystem/wechat/windows/README.md +4 -2
  99. package/src/ecosystem/wechat/windows/engine/NOTICE.md +6 -0
  100. package/src/ecosystem/wechat/windows/engine/profiles.json +28 -0
  101. package/templates/world-prompt-memory.md +10 -10
  102. package/templates/world-prompt.md +65 -65
@@ -0,0 +1,39 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { durableWrite } from "./life/lifeStore.js";
3
+ import { validWorldId } from "./worldRoutes.js";
4
+ /** The loader id of a world added from the console; the first world keeps whatever id its partner gave it. */
5
+ export const worldEntryId = (worldId) => `dsh-world-${worldId}`;
6
+ const said = (line) => line.trim() !== '' && !line.trimStart().startsWith('#');
7
+ /**
8
+ * Adds one more world to the profile's patch file, as the row the README has partners write by hand. The host's
9
+ * config editor can only change rows that are already loaded, so the row is appended as text: every line already
10
+ * there, comments included, stays as it is. The host reads the file when it starts, so the world appears after a
11
+ * restart. Refuses, with the reason, anything it cannot add safely.
12
+ */
13
+ export function addWorldEntry(patchFile, worldId, companionName) {
14
+ if (!validWorldId(worldId))
15
+ throw new Error('世界的名字只能用字母、数字、- 和 _,以字母或数字开头,最多 64 个字符');
16
+ const before = existsSync(patchFile) ? readFileSync(patchFile, 'utf8') : '';
17
+ const lines = before.split(/\r?\n/);
18
+ const rows = lines.filter(said);
19
+ // A new profile's patch is the host's comment and an empty list; the list is what the first row replaces.
20
+ const emptyList = rows.length === 1 && rows[0].trim() === '[]';
21
+ // Appending a row is only safe to a block list; any other shape is left for its owner to edit.
22
+ if (rows.length && !emptyList && !rows.some(line => line.startsWith('- ')))
23
+ throw new Error(`配置文件 ${patchFile} 不是逐条列出的格式,请手动添加(见 README「添加第二个世界」)`);
24
+ const taken = new RegExp(String.raw `^\s*(?:-\s+)?(?:worldId:\s*['"]?${worldId}['"]?|id:\s*['"]?${worldEntryId(worldId)}['"]?)\s*(?:#.*)?$`, 'i');
25
+ if (rows.some(line => taken.test(line)))
26
+ throw new Error(`配置里已经有 ${worldId} 这个世界了`);
27
+ const row = [
28
+ '# dsh-world:从世界控制台新增的世界。',
29
+ '- insert:',
30
+ ` - id: ${worldEntryId(worldId)}`,
31
+ ' name: dsh-world',
32
+ ' config:',
33
+ ` worldId: ${worldId}`,
34
+ ...(companionName ? [` companionName: ${JSON.stringify(companionName)}`] : []),
35
+ '',
36
+ ].join('\n');
37
+ const kept = (emptyList ? before.replace(/^[ \t]*\[\][ \t]*\r?\n?/m, '') : before).replace(/\s*$/, '');
38
+ durableWrite(patchFile, kept ? `${kept}\n\n${row}` : row);
39
+ }
@@ -43,8 +43,9 @@ export declare function readTemplate(file: string | undefined): TemplateRead;
43
43
  */
44
44
  export declare function renderTemplate(template: string, flags: Record<string, boolean>, values: Record<string, string>): string;
45
45
  /**
46
- * The one world prompt every world session carries in its system prompt. The world line's tools live in the home alone;
47
- * the template tells other sessions where to find them.
46
+ * The one world prompt every world session carries in its system prompt. `template` and `self` are read when a session
47
+ * opens, after a compaction or a cold return, or on the console's apply, never on save, so the cached prefix stays. The
48
+ * world line's tools live in the home alone; the template tells other sessions where to find them.
48
49
  */
49
50
  export declare function renderWorldPrompt(prompt: WorldPrompt, template: string, self: {
50
51
  file: string;
@@ -42,8 +42,9 @@ export function renderTemplate(template, flags, values) {
42
42
  return text.replace(/\{\{(\w+)\}\}/g, (tag, name) => values[name] ?? tag).replace(/[ \t]+\n/g, '\n').replace(/\n{3,}/g, '\n\n').trim();
43
43
  }
44
44
  /**
45
- * The one world prompt every world session carries in its system prompt. The world line's tools live in the home alone;
46
- * the template tells other sessions where to find them.
45
+ * The one world prompt every world session carries in its system prompt. `template` and `self` are read when a session
46
+ * opens, after a compaction or a cold return, or on the console's apply, never on save, so the cached prefix stays. The
47
+ * world line's tools live in the home alone; the template tells other sessions where to find them.
47
48
  */
48
49
  export function renderWorldPrompt(prompt, template, self, home) {
49
50
  const { life, names } = prompt;
@@ -2,8 +2,11 @@ import type { IncomingMessage, ServerResponse } from 'node:http';
2
2
  export declare const WORLDS_PATH = "/dsh-world/worlds";
3
3
  export declare const validWorldId: (id: string) => boolean;
4
4
  export declare const worldPath: (id: string) => string;
5
- export declare function worldListRoute(worlds: ReadonlyMap<string, readonly string[]>): {
5
+ /** A write must carry this header; a page on another site cannot add it without a CORS preflight, which is never answered. */
6
+ export declare const WRITE_HEADER = "x-dsh-world";
7
+ /** The worlds this profile has loaded, and one more added on request: `add` throws its refusal in words for the partner. */
8
+ export declare function worldListRoute(worlds: ReadonlyMap<string, readonly string[]>, add?: (worldId: string, companionName: string) => Promise<void>): {
6
9
  kind: "exact";
7
10
  path: string;
8
- handler(req: IncomingMessage, res: ServerResponse): void;
11
+ handler(req: IncomingMessage, res: ServerResponse): Promise<void>;
9
12
  };
@@ -1,18 +1,43 @@
1
- import { knownHost, sendJson } from "./http.js";
1
+ import { errorText } from "./faults.js";
2
+ import { jsonObject, knownHost, readBody, sendJson } from "./http.js";
2
3
  export const WORLDS_PATH = '/dsh-world/worlds';
3
4
  export const validWorldId = (id) => /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$/.test(id);
4
5
  export const worldPath = (id) => `${WORLDS_PATH}/${id}`;
5
- export function worldListRoute(worlds) {
6
+ /** A write must carry this header; a page on another site cannot add it without a CORS preflight, which is never answered. */
7
+ export const WRITE_HEADER = 'x-dsh-world';
8
+ const MAX_BODY_BYTES = 4 * 1024;
9
+ const MAX_NAME = 40;
10
+ /** The worlds this profile has loaded, and one more added on request: `add` throws its refusal in words for the partner. */
11
+ export function worldListRoute(worlds, add) {
12
+ async function addOne(req, res) {
13
+ const written = req.headers[WRITE_HEADER] === '1' && String(req.headers['content-type'] ?? '').startsWith('application/json');
14
+ const body = written ? jsonObject(await readBody(req, MAX_BODY_BYTES)) : undefined;
15
+ const worldId = body?.worldId, companionName = body?.companionName ?? '';
16
+ if (typeof worldId !== 'string' || typeof companionName !== 'string' || [...companionName].length > MAX_NAME) {
17
+ sendJson(res, { status: 400, body: { error: '请填世界的名字' } });
18
+ return;
19
+ }
20
+ try {
21
+ await add(worldId.trim(), companionName.trim());
22
+ }
23
+ catch (error) {
24
+ sendJson(res, { status: 409, body: { error: errorText(error) } });
25
+ return;
26
+ }
27
+ sendJson(res, { status: 200, body: { ok: true, worldId: worldId.trim(), restartRequired: true } });
28
+ }
6
29
  return {
7
30
  kind: 'exact', path: WORLDS_PATH,
8
- handler(req, res) {
31
+ async handler(req, res) {
9
32
  const ids = [...worlds].filter(([, hosts]) => knownHost(req.headers.host, hosts)).map(([id]) => id).sort();
10
33
  if (!ids.length || req.headers['sec-fetch-site'] === 'cross-site') {
11
34
  sendJson(res, { status: 403, body: { error: 'forbidden' } });
12
35
  return;
13
36
  }
37
+ if (req.method === 'POST' && add)
38
+ return addOne(req, res);
14
39
  if (req.method !== 'GET') {
15
- sendJson(res, { status: 405, body: { error: 'method not allowed' }, headers: { allow: 'GET' } });
40
+ sendJson(res, { status: 405, body: { error: 'method not allowed' }, headers: { allow: add ? 'GET, POST' : 'GET' } });
16
41
  return;
17
42
  }
18
43
  const { searchParams } = new URL(req.url ?? WORLDS_PATH, 'http://localhost');
@@ -19,7 +19,7 @@ export declare function createWorldSwitch(worldDir: string, configuredScope?: Me
19
19
  setArchiveScope(scope: MemoryArchiveScope): void;
20
20
  workspacePermission: () => string;
21
21
  setWorkspacePermission(permission: string): void;
22
- /** Compact the home after the evening look back unless the partner turns it off. */
22
+ /** After each evening look back her home is compacted, which is when the 我是谁 she has just rewritten takes effect; on unless the partner turns it off. */
23
23
  compactAfterReview: () => boolean;
24
24
  setCompactAfterReview(on: boolean): void;
25
25
  /** Whether the profile has been switched to the tool-free compaction (by this plugin or by hand); asked once, so putting the stock one back sticks. */
@@ -37,15 +37,21 @@ export declare function createWorldSwitch(worldDir: string, configuredScope?: Me
37
37
  coldHours: () => number;
38
38
  setColdHours(hours: number | undefined): void;
39
39
  /**
40
- * The console's switches for the WeChat and QQ modules; both are off until someone turns them on. QQ's SDK is an
40
+ * The console's switches for the WeChat, QQ and computer modules; all are off until someone turns them on. QQ's SDK is an
41
41
  * optional dependency, so its code is not even loaded before then. WeChat used to default to on, so a world that
42
42
  * never stored a choice but whose WeChat module has already run (it keeps its outbox) stays on after the upgrade.
43
43
  */
44
44
  wechatEnabled: () => boolean;
45
45
  qqEnabled: () => boolean;
46
+ /** Her own browser: off until someone turns it on. */
47
+ computerEnabled: () => boolean;
48
+ /** Her use of the partner's computer: off until someone turns it on. */
49
+ desktopEnabled: () => boolean;
46
50
  setModules(next: {
47
51
  wechat?: boolean;
48
52
  qq?: boolean;
53
+ computer?: boolean;
54
+ desktop?: boolean;
49
55
  }): void;
50
56
  /** Her evening look back and her morning wake when nothing is pending; the configured `fallbackWakeTime` is the morning's default. */
51
57
  reviewTime: () => string;
@@ -30,6 +30,8 @@ export function createWorldSwitch(worldDir, configuredScope = 'workspace', confi
30
30
  ...(validWechatBuffer(stored?.wechatBufferSeconds) ? { wechatBufferSeconds: stored.wechatBufferSeconds } : {}),
31
31
  ...(typeof stored?.wechatEnabled === 'boolean' ? { wechatEnabled: stored.wechatEnabled } : {}),
32
32
  ...(typeof stored?.qqEnabled === 'boolean' ? { qqEnabled: stored.qqEnabled } : {}),
33
+ ...(typeof stored?.computerEnabled === 'boolean' ? { computerEnabled: stored.computerEnabled } : {}),
34
+ ...(typeof stored?.desktopEnabled === 'boolean' ? { desktopEnabled: stored.desktopEnabled } : {}),
33
35
  ...(stored?.compactAfterReview === false ? { compactAfterReview: false } : {}),
34
36
  ...(stored?.compactionSwapped === true ? { compactionSwapped: true } : {}),
35
37
  ...(validClockTime(stored?.reviewTime) ? { reviewTime: stored.reviewTime } : {}),
@@ -55,7 +57,7 @@ export function createWorldSwitch(worldDir, configuredScope = 'workspace', confi
55
57
  throw new Error('工作区权限必须为非空字符串');
56
58
  save({ ...settings, workspacePermission: permission });
57
59
  },
58
- /** Compact the home after the evening look back unless the partner turns it off. */
60
+ /** After each evening look back her home is compacted, which is when the 我是谁 she has just rewritten takes effect; on unless the partner turns it off. */
59
61
  compactAfterReview: () => settings.compactAfterReview !== false,
60
62
  setCompactAfterReview(on) {
61
63
  const { compactAfterReview: _old, ...rest } = settings;
@@ -85,16 +87,20 @@ export function createWorldSwitch(worldDir, configuredScope = 'workspace', confi
85
87
  save(hours === undefined || hours === DEFAULT_COLD_HOURS ? rest : { ...rest, coldHours: hours });
86
88
  },
87
89
  /**
88
- * The console's switches for the WeChat and QQ modules; both are off until someone turns them on. QQ's SDK is an
90
+ * The console's switches for the WeChat, QQ and computer modules; all are off until someone turns them on. QQ's SDK is an
89
91
  * optional dependency, so its code is not even loaded before then. WeChat used to default to on, so a world that
90
92
  * never stored a choice but whose WeChat module has already run (it keeps its outbox) stays on after the upgrade.
91
93
  */
92
94
  wechatEnabled: () => settings.wechatEnabled ?? existsSync(join(worldDir, 'wechat-outbox.sqlite')),
93
95
  qqEnabled: () => settings.qqEnabled === true,
96
+ /** Her own browser: off until someone turns it on. */
97
+ computerEnabled: () => settings.computerEnabled === true,
98
+ /** Her use of the partner's computer: off until someone turns it on. */
99
+ desktopEnabled: () => settings.desktopEnabled === true,
94
100
  setModules(next) {
95
- const { wechatEnabled, qqEnabled, ...rest } = settings;
96
- const wechat = next.wechat ?? wechatEnabled ?? existsSync(join(worldDir, 'wechat-outbox.sqlite')), qq = next.qq ?? qqEnabled === true;
97
- save({ ...rest, wechatEnabled: wechat, ...(qq ? { qqEnabled: true } : {}) });
101
+ const { wechatEnabled, qqEnabled, computerEnabled, desktopEnabled, ...rest } = settings;
102
+ const wechat = next.wechat ?? wechatEnabled ?? existsSync(join(worldDir, 'wechat-outbox.sqlite')), qq = next.qq ?? qqEnabled === true, computer = next.computer ?? computerEnabled === true, desktop = next.desktop ?? desktopEnabled === true;
103
+ save({ ...rest, wechatEnabled: wechat, ...(qq ? { qqEnabled: true } : {}), ...(computer ? { computerEnabled: true } : {}), ...(desktop ? { desktopEnabled: true } : {}) });
98
104
  },
99
105
  /** Her evening look back and her morning wake when nothing is pending; the configured `fallbackWakeTime` is the morning's default. */
100
106
  reviewTime: () => settings.reviewTime ?? DEFAULT_REVIEW_TIME,
package/package.json CHANGED
@@ -1,129 +1,132 @@
1
- {
2
- "name": "dsh-world",
3
- "version": "0.7.6",
4
- "description": "Cross-session memory, persona and life routines for DSH, with a world console, tool-free compaction, native QQ and Windows WeChat messaging, group history and quoted replies",
5
- "license": "MIT",
6
- "publishConfig": {
7
- "registry": "https://registry.npmjs.org/",
8
- "access": "public"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/chenkezhen480/dsh-world.git"
13
- },
14
- "type": "module",
15
- "main": "lib/index.js",
16
- "types": "lib/index.d.ts",
17
- "exports": {
18
- ".": {
19
- "types": "./lib/index.d.ts",
20
- "default": "./lib/index.js"
21
- },
22
- "./compaction": {
23
- "types": "./lib/compaction.d.ts",
24
- "default": "./lib/compaction.js"
25
- },
26
- "./client": "./client/index.js",
27
- "./package.json": "./package.json"
28
- },
29
- "files": [
30
- "lib",
31
- "client",
32
- "src/ecosystem/wechat/windows",
33
- "src/ecosystem/README.md",
34
- "templates",
35
- "cordis.patch.yml",
36
- "README.md",
37
- "INSTALL.md",
38
- "CONTRIBUTING.md",
39
- "CHANGELOG.md",
40
- "NOTES.md",
41
- "assets",
42
- "scripts/enable-tool-free-compaction.ps1",
43
- "scripts/update-world.mjs",
44
- "scripts/import-stickers.mjs",
45
- "scripts/compact-home.mjs"
46
- ],
47
- "engines": {
48
- "node": ">=22.16.0",
49
- "dsh": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0"
50
- },
51
- "scripts": {
52
- "build": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
53
- "typecheck": "tsc --noEmit",
54
- "test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test",
55
- "test:package": "node scripts/check-package.mjs",
56
- "prepack": "npm run typecheck && npm run build"
57
- },
58
- "dsh": {
59
- "bundle": {
60
- "patch": "./cordis.patch.yml"
61
- },
62
- "client": {
63
- "inject": [
64
- "@deepseek-ai/dsh-client-ui-settings"
65
- ],
66
- "platform": "web"
67
- },
68
- "compatibility": {
69
- "dshReleases": {
70
- "0.2.1-rc.2": "compatible",
71
- "0.2.1-rc.3": "compatible",
72
- "0.2.1-rc.5": "compatible",
73
- "0.2.2-rc.1": "compatible"
74
- }
75
- }
76
- },
77
- "dependencies": {
78
- "ws": "^8.18.0"
79
- },
80
- "peerDependencies": {
81
- "@snowluma/sdk": "^2.2.1",
82
- "@deepseek-ai/dsh-plugin-manager": ">=0.2.1-rc.3 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
83
- "@deepseek-ai/dsh-atomic-write": ">=0.2.1-rc.3 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
84
- "@deepseek-ai/cordis": "~4.0.5 || ~4.1.0",
85
- "@deepseek-ai/dsh-agent": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
86
- "@deepseek-ai/dsh-attachment": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
87
- "@deepseek-ai/dsh-compaction": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
88
- "@deepseek-ai/dsh-home-paths": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
89
- "@deepseek-ai/dsh-llm": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
90
- "@deepseek-ai/dsh-session": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
91
- "@deepseek-ai/dsh-session-persistence": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
92
- "@deepseek-ai/dsh-tools": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
93
- "@deepseek-ai/schemastery": "~3.18.5 || ~3.19.0",
94
- "@deepseek-ai/dsh-commands": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0"
95
- },
96
- "peerDependenciesMeta": {
97
- "@snowluma/sdk": {
98
- "optional": true
99
- },
100
- "@deepseek-ai/dsh-plugin-manager": {
101
- "optional": true
102
- },
103
- "@deepseek-ai/dsh-atomic-write": {
104
- "optional": true
105
- }
106
- },
107
- "devDependencies": {
108
- "@snowluma/sdk": "2.2.1",
109
- "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
110
- "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
111
- "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.2",
112
- "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
113
- "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
114
- "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
115
- "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
116
- "@types/node": "^22.16.0",
117
- "typescript": "^5.9.3",
118
- "@deepseek-ai/cordis": "4.0.5",
119
- "@deepseek-ai/schemastery": "3.18.5",
120
- "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
121
- "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
122
- "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
123
- "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
124
- "@deepseek-ai/dsh-home-paths": "0.2.1-rc.2",
125
- "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
126
- "@deepseek-ai/dsh-session": "0.2.1-rc.2",
127
- "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2"
128
- }
129
- }
1
+ {
2
+ "name": "dsh-world",
3
+ "version": "0.8.0",
4
+ "description": "Cross-session memory, persona and life routines for DSH, with a world console, tool-free compaction, native QQ and Windows WeChat messaging, group history and quoted replies",
5
+ "license": "MIT",
6
+ "publishConfig": {
7
+ "registry": "https://registry.npmjs.org/",
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/chenkezhen480/dsh-world.git"
13
+ },
14
+ "type": "module",
15
+ "main": "lib/index.js",
16
+ "types": "lib/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./lib/index.d.ts",
20
+ "default": "./lib/index.js"
21
+ },
22
+ "./compaction": {
23
+ "types": "./lib/compaction.d.ts",
24
+ "default": "./lib/compaction.js"
25
+ },
26
+ "./client": "./client/index.js",
27
+ "./package.json": "./package.json"
28
+ },
29
+ "files": [
30
+ "lib",
31
+ "client",
32
+ "src/ecosystem/wechat/windows",
33
+ "src/ecosystem/README.md",
34
+ "src/ecosystem/computer/README.md",
35
+ "src/ecosystem/computer/NOTICE.md",
36
+ "src/ecosystem/computer/desktop/win32.ps1",
37
+ "templates",
38
+ "cordis.patch.yml",
39
+ "README.md",
40
+ "INSTALL.md",
41
+ "CONTRIBUTING.md",
42
+ "CHANGELOG.md",
43
+ "NOTES.md",
44
+ "assets",
45
+ "scripts/enable-tool-free-compaction.ps1",
46
+ "scripts/update-world.mjs",
47
+ "scripts/import-stickers.mjs",
48
+ "scripts/compact-home.mjs"
49
+ ],
50
+ "engines": {
51
+ "node": ">=22.16.0",
52
+ "dsh": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0"
53
+ },
54
+ "scripts": {
55
+ "build": "node -e \"require('fs').rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.build.json",
56
+ "typecheck": "tsc --noEmit",
57
+ "test": "node --experimental-strip-types --disable-warning=ExperimentalWarning --test",
58
+ "test:package": "node scripts/check-package.mjs",
59
+ "prepack": "npm run typecheck && npm run build"
60
+ },
61
+ "dsh": {
62
+ "bundle": {
63
+ "patch": "./cordis.patch.yml"
64
+ },
65
+ "client": {
66
+ "inject": [
67
+ "@deepseek-ai/dsh-client-ui-settings"
68
+ ],
69
+ "platform": "web"
70
+ },
71
+ "compatibility": {
72
+ "dshReleases": {
73
+ "0.2.1-rc.2": "compatible",
74
+ "0.2.1-rc.3": "compatible",
75
+ "0.2.1-rc.5": "compatible",
76
+ "0.2.2-rc.1": "compatible"
77
+ }
78
+ }
79
+ },
80
+ "dependencies": {
81
+ "ws": "^8.18.0"
82
+ },
83
+ "peerDependencies": {
84
+ "@snowluma/sdk": "^2.2.1",
85
+ "@deepseek-ai/dsh-plugin-manager": ">=0.2.1-rc.3 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
86
+ "@deepseek-ai/dsh-atomic-write": ">=0.2.1-rc.3 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
87
+ "@deepseek-ai/cordis": "~4.0.5 || ~4.1.0",
88
+ "@deepseek-ai/dsh-agent": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
89
+ "@deepseek-ai/dsh-attachment": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
90
+ "@deepseek-ai/dsh-compaction": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
91
+ "@deepseek-ai/dsh-home-paths": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
92
+ "@deepseek-ai/dsh-llm": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
93
+ "@deepseek-ai/dsh-session": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
94
+ "@deepseek-ai/dsh-session-persistence": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
95
+ "@deepseek-ai/dsh-tools": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0",
96
+ "@deepseek-ai/schemastery": "~3.18.5 || ~3.19.0",
97
+ "@deepseek-ai/dsh-commands": ">=0.2.1-rc.2 <0.3.0-0 || >=0.2.2-rc.1 <0.3.0-0"
98
+ },
99
+ "peerDependenciesMeta": {
100
+ "@snowluma/sdk": {
101
+ "optional": true
102
+ },
103
+ "@deepseek-ai/dsh-plugin-manager": {
104
+ "optional": true
105
+ },
106
+ "@deepseek-ai/dsh-atomic-write": {
107
+ "optional": true
108
+ }
109
+ },
110
+ "devDependencies": {
111
+ "@snowluma/sdk": "2.2.1",
112
+ "@deepseek-ai/dsh-agent-loop": "0.2.1-rc.2",
113
+ "@deepseek-ai/dsh-compaction-basic": "0.2.1-rc.2",
114
+ "@deepseek-ai/dsh-session-persistence-jsonl": "0.2.1-rc.2",
115
+ "@deepseek-ai/dsh-session-projection": "0.2.1-rc.2",
116
+ "@deepseek-ai/dsh-system-prompt": "0.2.1-rc.2",
117
+ "@deepseek-ai/dsh-token-meter": "0.2.1-rc.2",
118
+ "@deepseek-ai/dsh-tools": "0.2.1-rc.2",
119
+ "@types/node": "^22.16.0",
120
+ "typescript": "^5.9.3",
121
+ "@deepseek-ai/cordis": "4.0.5",
122
+ "@deepseek-ai/schemastery": "3.18.5",
123
+ "@deepseek-ai/dsh-agent": "0.2.1-rc.2",
124
+ "@deepseek-ai/dsh-attachment": "0.2.1-rc.2",
125
+ "@deepseek-ai/dsh-commands": "0.2.1-rc.2",
126
+ "@deepseek-ai/dsh-compaction": "0.2.1-rc.2",
127
+ "@deepseek-ai/dsh-home-paths": "0.2.1-rc.2",
128
+ "@deepseek-ai/dsh-llm": "0.2.1-rc.2",
129
+ "@deepseek-ai/dsh-session": "0.2.1-rc.2",
130
+ "@deepseek-ai/dsh-session-persistence": "0.2.1-rc.2"
131
+ }
132
+ }
@@ -9,8 +9,9 @@
9
9
  - `qq-native/`:QQ 的原生通道——直连 OneBot 的 WebSocket(收发、去重、白名单、群里被叫到才接、主动开口引擎),以及「阳台」那条给本机别的程序用的线(`native-bridge.ts`,对面跑的是 `src/qq-line.ts`)。
10
10
  - `shared/`:通用来源身份、群上下文、平台会话路由和消息出口。
11
11
  - `bridge/`:桌宠及其他本地程序向家的通用桥。
12
+ - `computer/`:她自己的浏览器(系统 Edge、CDP)、页面原语和她按分类学会的操作(`computer_use` 查、`procedure_run` 跑);只在家会话。见 [说明](computer/README.md)。
12
13
 
13
- 各平台自身逻辑放在各自目录;后续 B 站接入时新增 `bilibili/`。平台适配器使用共同的身份和会话协议,通过现有归档服务保存正文,不各建一份记忆。
14
+ 各平台自身逻辑放在各自目录;B 站等网页平台由她用 `computer/` 自己学,不再新增平台目录。平台适配器使用共同的身份和会话协议,通过现有归档服务保存正文,不各建一份记忆。
14
15
 
15
16
  QQ 额外依赖 SnowLuma SDK(`@snowluma/sdk`)。首次手动开启 QQ 时,缺失的 SDK 由宿主包管理器按需安装,禁用安装脚本,完成后提示重启;正常启动和模型请求不会安装依赖。也可自行安装兼容版本,不修补其文件,不自动升级 Node,见 [安装说明](../../INSTALL.md)。QQ 按持久化开关动态加载,关闭状态在世界停启和插件重载后保留;初始化失败不拖停内核、生活线和微信。
16
17
 
@@ -0,0 +1,27 @@
1
+ # 来源说明
2
+
3
+ `browser/edge.ts`(浏览器查找与启动参数、`DevToolsActivePort` 读取)、`browser/cdp.ts`(最小 CDP 会话)和 `browser/pageLib.ts`(页面内登记表、角色与名称、可见性规则)移植并改写自 [dsh-inner-browser-use](https://www.npmjs.com/package/dsh-inner-browser-use) 0.47.28 的 `sidecar.js` 与 `read.js`。
4
+
5
+ 原许可如下:
6
+
7
+ MIT License
8
+
9
+ Copyright (c) 2026 regrevia
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.