dsh-ta 0.2.0 → 0.4.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 (85) hide show
  1. package/CHANGELOG.md +111 -1
  2. package/README.md +325 -140
  3. package/cordis.patch.yml +5 -35
  4. package/docs/RELEASE.md +63 -46
  5. package/docs/USAGE.md +25 -9
  6. package/docs/presets.example.yml +7 -43
  7. package/index.js +3 -170
  8. package/locale/en.json +1 -1
  9. package/locale/zh.json +1 -1
  10. package/package.json +6 -19
  11. package/src/client/client.js +3176 -0
  12. package/{config.js → src/host/config.js} +39 -4
  13. package/src/host/constants.js +7 -0
  14. package/src/host/gates.js +34 -0
  15. package/src/host/identity.js +145 -0
  16. package/{im → src/host/im}/bindings.js +1 -1
  17. package/src/host/index.js +173 -0
  18. package/{jurisdiction.js → src/host/jurisdiction.js} +1 -1
  19. package/src/host/maintenance/collect.js +362 -0
  20. package/src/host/maintenance/completions.js +56 -0
  21. package/src/host/maintenance/consumption.js +67 -0
  22. package/src/host/maintenance/cursors.js +53 -0
  23. package/src/host/maintenance/engine.js +392 -0
  24. package/src/host/maintenance/llm.js +381 -0
  25. package/src/host/maintenance/lock.js +105 -0
  26. package/src/host/maintenance/prompts.js +255 -0
  27. package/src/host/maintenance/runs.js +47 -0
  28. package/src/host/maintenance/schedule.js +173 -0
  29. package/src/host/maintenance/session-cleanup.js +289 -0
  30. package/src/host/maintenance/session-watcher.js +107 -0
  31. package/src/host/maintenance/sleep.js +3 -0
  32. package/src/host/maintenance/stages.js +241 -0
  33. package/src/host/maintenance/state.js +192 -0
  34. package/src/host/prompts.js +96 -0
  35. package/src/host/records.js +175 -0
  36. package/{reme.js → src/host/reme.js} +3 -1
  37. package/src/host/runtime-manager.js +281 -0
  38. package/{runtime.js → src/host/runtime.js} +28 -50
  39. package/src/host/settings/defaults.js +55 -0
  40. package/src/host/settings/errors.js +29 -0
  41. package/src/host/settings/home.js +316 -0
  42. package/src/host/settings/http.js +164 -0
  43. package/src/host/settings/im.js +148 -0
  44. package/src/host/settings/lifecycle.js +373 -0
  45. package/src/host/settings/persona.js +113 -0
  46. package/src/host/settings/routes.js +229 -0
  47. package/src/host/settings/status.js +192 -0
  48. package/src/host/state/appraisals.js +56 -0
  49. package/src/host/state/feel.js +78 -0
  50. package/src/host/state/index.js +9 -0
  51. package/src/host/state/mood.js +103 -0
  52. package/src/host/state/notes.js +18 -0
  53. package/{life.js → src/host/state/outing.js} +13 -136
  54. package/src/host/state/values.js +9 -0
  55. package/{stickers → src/host/stickers}/tool.js +1 -1
  56. package/src/host/storage/fs.js +29 -0
  57. package/src/host/storage/index.js +8 -0
  58. package/src/host/storage/paths.js +20 -0
  59. package/src/host/storage/revision.js +5 -0
  60. package/src/host/storage/session-state.js +38 -0
  61. package/src/host/storage/time.js +127 -0
  62. package/src/host/tools/index.js +152 -0
  63. package/src/host/tools/read.js +252 -0
  64. package/src/host/tools/shared.js +23 -0
  65. package/src/host/tools/wiki.js +35 -0
  66. package/src/host/tools/write.js +164 -0
  67. package/{usage → src/host/usage}/aggregate.js +4 -1
  68. package/src/host/usage/ledger.js +186 -0
  69. package/src/host/usage/serve.js +116 -0
  70. package/client.js +0 -618
  71. package/gates.js +0 -18
  72. package/identity.js +0 -97
  73. package/prompts.js +0 -28
  74. package/storage.js +0 -95
  75. package/tools.js +0 -540
  76. package/usage/ledger.js +0 -126
  77. package/usage/serve.js +0 -38
  78. /package/{im → src/host/im}/say.js +0 -0
  79. /package/{memory → src/host/memory}/capture.js +0 -0
  80. /package/{memory → src/host/memory}/messages.js +0 -0
  81. /package/{memory → src/host/memory}/outbox.js +0 -0
  82. /package/{stickers → src/host/stickers}/load.js +0 -0
  83. /package/{stickers → src/host/stickers}/select.js +0 -0
  84. /package/{stickers → src/host/stickers}/serve.js +0 -0
  85. /package/{usage → src/host/usage}/pricing.js +0 -0
package/cordis.patch.yml CHANGED
@@ -6,7 +6,6 @@
6
6
  remeEndpoint: http://127.0.0.1:2333
7
7
  presets:
8
8
  - ta
9
- - ta-review
10
9
  permissionPreset: read-only
11
10
  captureEnabled: true
12
11
  captureInterval: 5
@@ -60,42 +59,13 @@
60
59
  name: "@deepseek-ai/dsh-command-compact"
61
60
  - id: tool-result-pruner
62
61
  name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
63
-
64
- - id: preset-ta-review
62
+ - id: preset-ta-maintenance
65
63
  name: "@deepseek-ai/dsh-agent-preset"
66
64
  config:
67
- id: ta-review
68
- name: "TA Review"
69
- description: "Nightly review preset. Read-only files and controlled review write tools."
70
- order: 10
65
+ id: ta-maintenance
66
+ name: "TA Maintenance"
67
+ description: "Thin trigger preset: one deterministic maintenance tool, no file or shell access."
68
+ order: 11
71
69
  plugins:
72
70
  - id: time-context
73
71
  name: "@deepseek-ai/dsh-time-context"
74
- - id: agent-instructions
75
- name: "@deepseek-ai/dsh-agent-instructions"
76
- config:
77
- maxBytes: 65536
78
- - id: tool-fs
79
- name: "@deepseek-ai/dsh-tool-fs"
80
- config:
81
- read: true
82
- readImage: true
83
- write: false
84
- edit: false
85
- - id: tool-fs-search
86
- name: "@deepseek-ai/dsh-tool-fs-search"
87
- config:
88
- sampleOverCapGlobResults: false
89
- - id: compaction
90
- name: cordis:group
91
- group: true
92
- isolate:
93
- compaction: true
94
- toolResultPruner: true
95
- config:
96
- - id: compaction-basic
97
- name: "@deepseek-ai/dsh-compaction-basic"
98
- - id: command-compact
99
- name: "@deepseek-ai/dsh-command-compact"
100
- - id: tool-result-pruner
101
- name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
package/docs/RELEASE.md CHANGED
@@ -1,8 +1,10 @@
1
- # Release
1
+ # 发布
2
2
 
3
- This package is plain JavaScript. A release is a versioned npm package and a matching Git tag.
3
+ 本包是纯 JavaScript,发布就是版本化的 npm 包加对应的 Git tag。
4
4
 
5
- ## 1. Prepare
5
+ 0.4 结构重整后,包入口是根 `index.js`(薄壳),Host 实现位于 `src/host/`,设置页客户端是单文件 `src/client/client.js`(`package.json` 的 `exports["./client"]` 指向它)。
6
+
7
+ ## 1. 准备
6
8
 
7
9
  ```bash
8
10
  npm ci
@@ -11,78 +13,93 @@ npm run check
11
13
  npm pack --dry-run
12
14
  ```
13
15
 
14
- `npm run check` verifies:
16
+ 发布前完整跑一遍:
17
+
18
+ ```bash
19
+ npm test && npm run check && npm pack --dry-run
20
+ ```
21
+
22
+ 测试数量以 `npm test` 输出为准(2026-12-04 本机为 258 项通过)。不要直接把本文档里的数字抄进发布说明。
23
+
24
+ 发布前还要确认 CI 工作流的语法检查路径已指向当前文件布局(`index.js`、`src/client/client.js`),不要继续检查已删除的根 `client.js`。
15
25
 
16
- - package metadata and license
17
- - `dsh.bundle` / web client manifest
18
- - required public files
19
- - no local absolute paths in shipped documentation or configuration
26
+ `npm run check` 验证:
20
27
 
21
- ## 2. Version and changelog
28
+ - package 元数据与 license
29
+ - `dsh.bundle` 与 web client manifest
30
+ - 必需的发布文件
31
+ - 发布的文档与配置中没有本机绝对路径
22
32
 
23
- 1. Update `package.json` `version`.
24
- 2. Add the same version to `CHANGELOG.md`.
25
- 3. Commit the changes.
33
+ 另外确认 `npm pack --dry-run` 的文件列表里包含:
26
34
 
27
- Use semantic versioning:
35
+ - `index.js`(根入口薄壳:`export * from './src/host/index.js'`)
36
+ - `src/host/`(Host 实现:storage/、state/、tools/、maintenance/、settings/、usage/ 等)
37
+ - `src/client/client.js`(设置页客户端;DSH 客户端插件只加载这一个文件)
38
+ - `cordis.patch.yml`(bundle patch:`dsh-ta` 插件行 + `ta` preset)
28
39
 
29
- - `0.x.y` while the public surface is still moving
30
- - `x.y.z` once the settings/config surface is stable
40
+ ## 2. 版本与 changelog
31
41
 
32
- ## 3. Tag and publish
42
+ 1. 更新 `package.json` 的 `version`。
43
+ 2. 在 `CHANGELOG.md` 顶部加同版本条目。
44
+ 3. 提交改动。
45
+
46
+ 语义化版本:
47
+
48
+ - `0.x.y`:公开接口仍在变化
49
+ - `x.y.z`:设置/配置接口稳定后
50
+
51
+ ## 3. 打 tag 与发布
33
52
 
34
53
  ```bash
35
- git tag v0.1.0
36
- git push origin v0.1.0
54
+ git tag v0.4.0
55
+ git push origin v0.4.0
37
56
  ```
38
57
 
39
- `.github/workflows/publish.yml` runs on `v*` tags:
58
+ `.github/workflows/publish.yml` 在 `v*` tag 上运行:
40
59
 
41
- 1. checks that the tag equals `package.json.version`
42
- 2. skips a version already present on npm
43
- 3. installs dependencies, runs tests and release checks
44
- 4. publishes with npm trusted publishing (OIDC)
60
+ 1. 校验 tag 与 `package.json.version` 一致
61
+ 2. 跳过 npm 上已存在的版本
62
+ 3. 安装依赖、跑测试与发布检查
63
+ 4. 通过 npm trusted publishing(OIDC)发布
45
64
 
46
- Prereleases such as `0.2.0-beta.1` publish under the `next` dist-tag. Stable
47
- versions publish under `latest`.
65
+ 预发布版本(如 `0.4.0-beta.1`)发布到 `next` dist-tag,正式版本发布到 `latest`。
48
66
 
49
- No `NPM_TOKEN` is stored in the repository by default. The workflow supports
50
- two authentication paths:
67
+ 仓库默认不保存长期 `NPM_TOKEN`。工作流支持两种认证方式:
51
68
 
52
- - **Trusted publishing (recommended after the first publish):** configure the
53
- npm package's trusted publisher for this GitHub repository and workflow.
54
- The workflow uses OIDC; no long-lived token is needed.
55
- - **First publish by tag:** add a repository secret named `NPM_TOKEN` with an
56
- npm granular/automation token that can publish `dsh-ta`. The publish step
57
- exports it as `NODE_AUTH_TOKEN` for that run only.
69
+ - **Trusted publishing(首次发布后推荐)**:在 npm 包上配置本 GitHub 仓库与 workflow 的 trusted publisher,工作流使用 OIDC,不需要长期 token。
70
+ - **首次 tag 发布**:在仓库添加名为 `NPM_TOKEN` 的 secret,填入能发布 `dsh-ta` 的 npm granular/automation token;发布步骤只在本次运行中把它导出为 `NODE_AUTH_TOKEN`。
58
71
 
59
- npm trusted publishing can only be configured for a package that already
60
- exists, so the first release usually needs either one manual `npm publish`
61
- after `npm login`, or the `NPM_TOKEN` secret for the tag workflow. Later
62
- releases can use OIDC trusted publishing.
72
+ npm trusted publishing 只能为已经存在的包配置,所以首次发布通常需要二选一:`npm login` 后手动 `npm publish`,或用 `NPM_TOKEN` secret 走 tag 工作流。之后的版本可以改用 OIDC trusted publishing。
63
73
 
64
- ## 4. After publish
74
+ ## 4. 发布后
65
75
 
66
- Verify:
76
+ 验证:
67
77
 
68
78
  ```bash
69
- npm view dsh-ta@0.1.0 version
79
+ npm view dsh-ta@0.4.0 version
70
80
  ```
71
81
 
72
- Install the published version in a clean DSH profile:
82
+ 在干净的 DSH profile 里安装发布版本:
73
83
 
74
84
  ```bash
75
85
  dsh plugin --profile <profile> add dsh-ta
76
86
  ```
77
87
 
78
- Then open **Settings → Ta** and confirm the panel can read and save the config.
88
+ 然后打开 **设置 → TA 的家**,确认:
89
+
90
+ - 配置能读写并即时生效;
91
+ - 状态页能显示四件套状态、维护状态与最近运行;
92
+ - 人设页只编辑 SOUL 与称呼;
93
+ - SOUL 建议队列按预期出现。
94
+
95
+ 0.4 的维护由插件内定时器直调模型,不创建会话;发布后确认 23:00 触发、`state/runs.jsonl` 与状态页显示一致。
79
96
 
80
- ## Rollback
97
+ ## 回滚
81
98
 
82
- Never republish the same version. If a release is broken:
99
+ 不要重复发布同一个版本。发布坏了:
83
100
 
84
101
  ```bash
85
- npm deprecate dsh-ta@0.1.0 "use 0.1.1"
102
+ npm deprecate dsh-ta@0.4.0 "use 0.4.1"
86
103
  ```
87
104
 
88
- Publish a fixed patch version instead.
105
+ 然后发布修复后的 patch 版本。
package/docs/USAGE.md CHANGED
@@ -6,11 +6,10 @@ dsh-TA 记录 **DSH 内的 Ta agent 花销**,用于查看累计用量、估算
6
6
 
7
7
  ## 计入范围
8
8
 
9
- - 日常聊天(Web / 飞书)
10
- - 23:00 回顾
11
- - 22:45 辖区外出
12
- - 心跳 life 会话
13
- - 其他以 `ta` / `ta-review` 运行的 DSH 会话
9
+ - 日常聊天(Web / 飞书,`category: chat`)
10
+ - 插件内每日维护的直调模型调用(`category: maintenance`)
11
+ - 22:45 辖区外出(`category: outing`)
12
+ - 心跳 life 会话(`category: heartbeat`)
14
13
 
15
14
  ## 不计入
16
15
 
@@ -24,7 +23,7 @@ dsh-TA 记录 **DSH 内的 Ta agent 花销**,用于查看累计用量、估算
24
23
 
25
24
  ```text
26
25
  $TA_HOME/state/usage/
27
- ├── 2026-12.jsonl
26
+ ├── 2026-12-04.jsonl
28
27
  └── pricing.json
29
28
  ```
30
29
 
@@ -37,11 +36,11 @@ $TA_HOME/state/usage/
37
36
  - 价格表版本
38
37
  - 估算 CNY
39
38
 
40
- 相同 `session:turn` 在汇总时只计一次;正常事件流不会重复写入。
39
+ 维护的同一 run 会发多次模型请求,用 `callId` 区分,不会被当成重复记录合并;没有 `callId` 的记录按 `session:turn` 去重。
41
40
 
42
41
  ## 价格
43
42
 
44
- 默认价格表在 `usage/pricing.js`,单位是 **CNY / 百万 token**,只是估算。
43
+ 默认价格表在 `src/host/usage/pricing.js`,单位是 **CNY / 百万 token**,只是估算。
45
44
 
46
45
  用户可覆盖:
47
46
 
@@ -70,7 +69,7 @@ $TA_HOME/state/usage/pricing.json
70
69
 
71
70
  ## 查看
72
71
 
73
- 打开 **设置 → TA 的家**,顶部「花销」卡片显示:
72
+ 打开 **设置 → TA 的家 → 状态**,顶部「花销」卡片显示:
74
73
 
75
74
  - 累计 tokens
76
75
  - 估算 CNY
@@ -84,6 +83,23 @@ $TA_HOME/state/usage/pricing.json
84
83
  /api/dsh-ta/usage/export.json
85
84
  ```
86
85
 
86
+ ## 清零
87
+
88
+ 花销卡片里点 **清零**,再确认一次即可删除本地账本:
89
+
90
+ ```text
91
+ $TA_HOME/state/usage/*.jsonl
92
+ ```
93
+
94
+ 只会删除日期命名的账本文件,不会删除 `pricing.json`、TA 家、ReMe 记忆、聊天记录或配置。清零不可恢复;正在进行的 turn 结束后仍可能写入新记录。
95
+
96
+ 对应的受认证接口:
97
+
98
+ ```text
99
+ POST /api/dsh-ta/usage/reset
100
+ { "confirm": "清零" }
101
+ ```
102
+
87
103
  ## 历史
88
104
 
89
105
  默认从当前版本开始记账,不自动回填旧会话。旧记录没有完整模型/价格时补算容易失真,后续如有需要再做显式回填工具。
@@ -1,11 +1,14 @@
1
- # Example Agent presets for dsh-ta.
1
+ # Example Agent preset for dsh-ta 0.4.
2
2
  #
3
- # Add these rows to the `insert:` list in your DSH profile patch
3
+ # Add this row to the `insert:` list in your DSH profile patch
4
4
  # (~/.dsh/profiles/<profile>/cordis.patch.yml). If you already have other
5
- # insert rows, append these entries to the same list.
5
+ # insert rows, append this entry to the same list.
6
6
  #
7
- # The dsh-ta bundle registers its own tools; these presets define the host
7
+ # The dsh-ta bundle registers its own tools; this preset defines the host
8
8
  # tool surface that the adapter gates and extends.
9
+ #
10
+ # 0.4 的维护由插件内定时器在 23:00 直调模型,不创建会话,
11
+ # 因此只需要 ta 这一个 preset。
9
12
 
10
13
  - insert:
11
14
  - id: preset-ta
@@ -54,42 +57,3 @@
54
57
  name: "@deepseek-ai/dsh-command-compact"
55
58
  - id: tool-result-pruner
56
59
  name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
57
-
58
- - id: preset-ta-review
59
- name: "@deepseek-ai/dsh-agent-preset"
60
- config:
61
- id: ta-review
62
- name: "TA Review"
63
- description: "Nightly review preset. Read-only files and controlled review write tools."
64
- order: 10
65
- plugins:
66
- - id: time-context
67
- name: "@deepseek-ai/dsh-time-context"
68
- - id: agent-instructions
69
- name: "@deepseek-ai/dsh-agent-instructions"
70
- config:
71
- maxBytes: 65536
72
- - id: tool-fs
73
- name: "@deepseek-ai/dsh-tool-fs"
74
- config:
75
- read: true
76
- readImage: true
77
- write: false
78
- edit: false
79
- - id: tool-fs-search
80
- name: "@deepseek-ai/dsh-tool-fs-search"
81
- config:
82
- sampleOverCapGlobResults: false
83
- - id: compaction
84
- name: cordis:group
85
- group: true
86
- isolate:
87
- compaction: true
88
- toolResultPruner: true
89
- config:
90
- - id: compaction-basic
91
- name: "@deepseek-ai/dsh-compaction-basic"
92
- - id: command-compact
93
- name: "@deepseek-ai/dsh-command-compact"
94
- - id: tool-result-pruner
95
- name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
package/index.js CHANGED
@@ -1,172 +1,5 @@
1
1
  /**
2
- * dsh-ta: Ta's DSH adapter.
3
- *
4
- * Host half: identity, gates, capture, review, outings, jurisdiction reads,
5
- * and the settings surface shared with the client half.
2
+ * dsh-TA 插件入口薄壳:实现都在 src/host。
3
+ * 保留这个文件是为了让包入口、profile patch 与旧引用路径保持稳定。
6
4
  */
7
-
8
- import { resolve } from 'node:path'
9
- import { Capture } from './memory/capture.js'
10
- import { Outbox } from './memory/outbox.js'
11
- import { disposeAgent, releaseReviewForSession, syncAgent } from './tools.js'
12
- import { moodLine } from './life.js'
13
- import { internalSessionIds, recordSessionMap } from './storage.js'
14
- import { isTaSession } from './gates.js'
15
- import { identityText } from './identity.js'
16
- import { normalizeConfig } from './config.js'
17
- import { sendAutoMemory } from './reme.js'
18
- import { ensureReviewSchedule, startDreamClock, startHeartbeat, startJurisdictionOuting, startOutingCleanup } from './runtime.js'
19
- import { MEMORY_GUIDANCE } from './prompts.js'
20
- import { UsageLedger } from './usage/ledger.js'
21
- import { mountStickerRoute } from './stickers/serve.js'
22
- import { mountUsageRoute } from './usage/serve.js'
23
- import { stickerGuidance } from './stickers/select.js'
24
-
25
- export { Config, normalizeConfig } from './config.js'
26
- export { realPath, todayText, withinHome, writeAtomic } from './storage.js'
27
- export { isTaSession } from './gates.js'
28
- export { identityText } from './identity.js'
29
- export { readJurisdictionSession, recentConversations, recentJurisdiction, visitJurisdiction } from './jurisdiction.js'
30
- export { addNote, cleanupOutings, finishOuting, moodLine, readMood, setMood, startOuting } from './life.js'
31
- export { aggregateUsage, usageCsv } from './usage/aggregate.js'
32
-
33
- export const name = 'dsh-ta'
34
- export const inject = ['systemPrompt', 'agentPresets', 'agents']
35
-
36
- export function apply(ctx, input = {}) {
37
- const config = normalizeConfig(input)
38
-
39
- if (typeof ctx.inject === 'function') {
40
- ctx.inject(['settings'], (settingsCtx) => {
41
- const settings = settingsCtx.get?.('settings')
42
- if (typeof settings?.configure !== 'function') return
43
- try {
44
- ctx.effect(
45
- () => settings.configure({ auto: false }, ctx.fiber),
46
- 'dsh-ta settings presentation',
47
- )
48
- } catch {
49
- /* settings is optional */
50
- }
51
- })
52
- }
53
-
54
- ctx.systemPrompt.section({
55
- name: 'ta-identity',
56
- order: 10,
57
- interpolate: false,
58
- text: (context) => identityText(ctx, context?.session, config),
59
- })
60
-
61
- ctx.systemPrompt.section({
62
- name: 'ta-memory-guidance',
63
- order: 20,
64
- interpolate: false,
65
- text: (context) => isTaSession(ctx, context?.session, config) ? MEMORY_GUIDANCE : '',
66
- })
67
-
68
- ctx.systemPrompt.section({
69
- name: 'ta-sticker-guidance',
70
- order: 35,
71
- interpolate: false,
72
- text: (context) => {
73
- if (!isTaSession(ctx, context?.session, config)) return ''
74
- let preset
75
- try {
76
- preset = ctx.agentPresets?.presetForSession?.(context.session)
77
- } catch {
78
- preset = undefined
79
- }
80
- return preset === 'ta' ? stickerGuidance(config) : ''
81
- },
82
- })
83
-
84
- ctx.systemPrompt.section({
85
- name: 'ta-mood',
86
- order: 30,
87
- interpolate: false,
88
- text: (context) => isTaSession(ctx, context?.session, config) ? moodLine(config) : '',
89
- })
90
-
91
- ctx.on('agent/created', ({ agent }) => {
92
- try { syncAgent(ctx, agent, config) } catch { /* never fail the host for an adapter */ }
93
- })
94
-
95
- ctx.on('agent-preset/selected', (sessionId) => {
96
- try {
97
- const agent = ctx.agents.get(sessionId)
98
- if (agent) syncAgent(ctx, agent, config)
99
- } catch { /* never fail the host for an adapter */ }
100
- })
101
-
102
- ctx.on('agent/disposed', ({ agent }) => {
103
- disposeAgent(config, agent)
104
- })
105
-
106
- ctx.on('session/event', (session, event) => {
107
- if (event.type === 'turn/end') releaseReviewForSession(config, session)
108
- })
109
-
110
- try {
111
- const key = Symbol.for('dsh-ta.capture')
112
- globalThis[key]?.dispose?.()
113
- const outbox = new Outbox(resolve(config.taHome, config.outboxDir))
114
- const capture = new Capture({
115
- config,
116
- outbox,
117
- send: batch => sendAutoMemory(config, batch),
118
- shouldCapture: session => {
119
- if (!config.captureEnabled || !isTaSession(ctx, session, config)) return false
120
- let preset
121
- try {
122
- preset = ctx.agentPresets?.presetForSession?.(session)
123
- } catch {
124
- return false
125
- }
126
- if (preset !== 'ta') return false
127
- return !internalSessionIds(config).has(String(session.id))
128
- },
129
- onSession: (dshSessionId, remeSessionId) => recordSessionMap(config, dshSessionId, remeSessionId),
130
- })
131
- globalThis[key] = capture
132
- capture.start()
133
- ctx.on('session/event', (session, event) => {
134
- try { capture.handle(session, event) } catch { /* adapter diagnostics must not stop sessions */ }
135
- })
136
- ctx.on('session/disposed', session => {
137
- try { capture.handle(session, { type: 'session/disposed' }) } catch { /* noop */ }
138
- })
139
- } catch {
140
- /* capture is optional; identity/tools must still load */
141
- }
142
-
143
- try { mountStickerRoute(ctx, config) } catch { /* sticker route optional */ }
144
- try { mountUsageRoute(ctx, config) } catch { /* usage route optional */ }
145
-
146
- try {
147
- const ledger = new UsageLedger({ ctx, config })
148
- ledger.start()
149
- ctx.on('session/event', (session, event) => {
150
- try { ledger.handle(session, event) } catch { /* usage must not stop turns */ }
151
- })
152
- } catch {
153
- /* usage accounting is optional */
154
- }
155
-
156
- if (config.reviewScheduleEnabled) {
157
- void ensureReviewSchedule(ctx, config).catch(() => {})
158
- }
159
- for (const start of [startDreamClock, startHeartbeat, startOutingCleanup, startJurisdictionOuting]) {
160
- try {
161
- start(ctx, config)
162
- } catch {
163
- /* each timer is optional */
164
- }
165
- }
166
-
167
- // HMR/reload: agents that already exist never emit agent/created again.
168
- try {
169
- for (const agent of ctx.agents.list()) syncAgent(ctx, agent, config)
170
- } catch { /* never fail the host for an adapter */ }
171
-
172
- }
5
+ export * from './src/host/index.js'
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-TA",
4
- "description": "A personal assistant with identity, long-term memory, diary, and read-only jurisdictions."
4
+ "description": "A personal assistant with its own home, identity, long-term memory, diary, and init/reincarnate lifecycle."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "dsh-TA",
4
- "description": "带身份、长期记忆、日记与辖区的个人助理。"
4
+ "description": "带自己的家、身份、长期记忆、日记与初始化/转生生命周期的个人助理。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-ta",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
- "description": "A persistent, read-only-by-default personal assistant adapter for DeepSeek Harness.",
5
+ "description": "A persistent personal assistant with its own home, memory, lifecycle and settings page for DeepSeek Harness.",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/yryd/dsh-TA.git"
@@ -18,7 +18,7 @@
18
18
  "exports": {
19
19
  ".": "./index.js",
20
20
  "./locale/*.json": "./locale/*.json",
21
- "./client": "./client.js",
21
+ "./client": "./src/client/client.js",
22
22
  "./icon": "./icon.svg"
23
23
  },
24
24
  "files": [
@@ -29,27 +29,14 @@
29
29
  "CHANGELOG.md",
30
30
  "LICENSE",
31
31
  "docs",
32
- "client.js",
33
- "memory",
34
32
  "icon.svg",
35
- "config.js",
36
- "storage.js",
37
- "identity.js",
38
- "gates.js",
39
- "jurisdiction.js",
40
- "tools.js",
41
- "life.js",
42
- "runtime.js",
43
- "reme.js",
44
- "prompts.js",
45
- "im",
46
- "usage",
47
- "stickers"
33
+ "src"
48
34
  ],
49
35
  "scripts": {
50
36
  "test": "node --test test/*.test.mjs",
51
37
  "check": "node scripts/check-release.mjs",
52
- "prepublishOnly": "npm test && npm run check"
38
+ "prepublishOnly": "npm test && npm run check",
39
+ "inspect": "node scripts/inspect-home.mjs"
53
40
  },
54
41
  "engines": {
55
42
  "dsh": ">=0.2.3-alpha.3"