dsh-ta 0.3.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.
- package/CHANGELOG.md +90 -0
- package/README.md +160 -107
- package/cordis.patch.yml +5 -35
- package/docs/RELEASE.md +62 -49
- package/docs/USAGE.md +6 -7
- package/docs/presets.example.yml +7 -43
- package/index.js +3 -164
- package/package.json +5 -28
- package/src/client/client.js +3176 -0
- package/{config.js → src/host/config.js} +39 -3
- package/src/host/constants.js +7 -0
- package/src/host/gates.js +34 -0
- package/src/host/identity.js +145 -0
- package/{im → src/host/im}/bindings.js +1 -1
- package/src/host/index.js +173 -0
- package/{jurisdiction.js → src/host/jurisdiction.js} +1 -1
- package/src/host/maintenance/collect.js +362 -0
- package/src/host/maintenance/completions.js +56 -0
- package/src/host/maintenance/consumption.js +67 -0
- package/src/host/maintenance/cursors.js +53 -0
- package/src/host/maintenance/engine.js +392 -0
- package/src/host/maintenance/llm.js +381 -0
- package/src/host/maintenance/lock.js +105 -0
- package/src/host/maintenance/prompts.js +255 -0
- package/src/host/maintenance/runs.js +47 -0
- package/src/host/maintenance/schedule.js +173 -0
- package/src/host/maintenance/session-cleanup.js +289 -0
- package/src/host/maintenance/session-watcher.js +107 -0
- package/src/host/maintenance/sleep.js +3 -0
- package/src/host/maintenance/stages.js +241 -0
- package/src/host/maintenance/state.js +192 -0
- package/src/host/prompts.js +96 -0
- package/src/host/records.js +175 -0
- package/src/host/runtime-manager.js +281 -0
- package/{runtime.js → src/host/runtime.js} +6 -8
- package/src/host/settings/defaults.js +55 -0
- package/{settings → src/host/settings}/home.js +4 -3
- package/{settings/routes.js → src/host/settings/http.js} +5 -137
- package/{settings → src/host/settings}/im.js +18 -1
- package/{settings → src/host/settings}/lifecycle.js +29 -43
- package/src/host/settings/persona.js +113 -0
- package/src/host/settings/routes.js +229 -0
- package/{settings → src/host/settings}/status.js +70 -42
- package/src/host/state/appraisals.js +56 -0
- package/src/host/state/feel.js +78 -0
- package/src/host/state/index.js +9 -0
- package/src/host/state/mood.js +103 -0
- package/src/host/state/notes.js +18 -0
- package/{life.js → src/host/state/outing.js} +13 -136
- package/src/host/state/values.js +9 -0
- package/{stickers → src/host/stickers}/tool.js +1 -1
- package/src/host/storage/fs.js +29 -0
- package/src/host/storage/index.js +8 -0
- package/src/host/storage/paths.js +20 -0
- package/src/host/storage/revision.js +5 -0
- package/src/host/storage/session-state.js +38 -0
- package/src/host/storage/time.js +127 -0
- package/src/host/tools/index.js +152 -0
- package/src/host/tools/read.js +252 -0
- package/src/host/tools/shared.js +23 -0
- package/src/host/tools/wiki.js +35 -0
- package/src/host/tools/write.js +164 -0
- package/{usage → src/host/usage}/aggregate.js +4 -1
- package/{usage → src/host/usage}/ledger.js +47 -21
- package/client.js +0 -2554
- package/gates.js +0 -18
- package/identity.js +0 -97
- package/prompts.js +0 -28
- package/runtime-manager.js +0 -153
- package/settings/defaults.js +0 -41
- package/settings/persona.js +0 -203
- package/settings/schedule.js +0 -156
- package/storage.js +0 -122
- package/tools.js +0 -540
- /package/{im → src/host/im}/say.js +0 -0
- /package/{memory → src/host/memory}/capture.js +0 -0
- /package/{memory → src/host/memory}/messages.js +0 -0
- /package/{memory → src/host/memory}/outbox.js +0 -0
- /package/{reme.js → src/host/reme.js} +0 -0
- /package/{settings → src/host/settings}/errors.js +0 -0
- /package/{stickers → src/host/stickers}/load.js +0 -0
- /package/{stickers → src/host/stickers}/select.js +0 -0
- /package/{stickers → src/host/stickers}/serve.js +0 -0
- /package/{usage → src/host/usage}/pricing.js +0 -0
- /package/{usage → src/host/usage}/serve.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-
|
|
68
|
-
name: "TA
|
|
69
|
-
description: "
|
|
70
|
-
order:
|
|
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
|
-
#
|
|
1
|
+
# 发布
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
本包是纯 JavaScript,发布就是版本化的 npm 包加对应的 Git tag。
|
|
4
4
|
|
|
5
|
-
|
|
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,82 +13,93 @@ npm run check
|
|
|
11
13
|
npm pack --dry-run
|
|
12
14
|
```
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
发布前完整跑一遍:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm test && npm run check && npm pack --dry-run
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
测试数量以 `npm test` 输出为准(2026-12-04 本机为 258 项通过)。不要直接把本文档里的数字抄进发布说明。
|
|
16
23
|
|
|
17
|
-
|
|
24
|
+
发布前还要确认 CI 工作流的语法检查路径已指向当前文件布局(`index.js`、`src/client/client.js`),不要继续检查已删除的根 `client.js`。
|
|
18
25
|
|
|
19
|
-
|
|
20
|
-
- `dsh.bundle` / web client manifest
|
|
21
|
-
- required public files
|
|
22
|
-
- no local absolute paths in shipped documentation or configuration
|
|
26
|
+
`npm run check` 验证:
|
|
23
27
|
|
|
24
|
-
|
|
28
|
+
- package 元数据与 license
|
|
29
|
+
- `dsh.bundle` 与 web client manifest
|
|
30
|
+
- 必需的发布文件
|
|
31
|
+
- 发布的文档与配置中没有本机绝对路径
|
|
25
32
|
|
|
26
|
-
|
|
27
|
-
2. Add the same version to `CHANGELOG.md`.
|
|
28
|
-
3. Commit the changes.
|
|
33
|
+
另外确认 `npm pack --dry-run` 的文件列表里包含:
|
|
29
34
|
|
|
30
|
-
|
|
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)
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
- `x.y.z` once the settings/config surface is stable
|
|
40
|
+
## 2. 版本与 changelog
|
|
34
41
|
|
|
35
|
-
|
|
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 与发布
|
|
36
52
|
|
|
37
53
|
```bash
|
|
38
|
-
git tag v0.
|
|
39
|
-
git push origin v0.
|
|
54
|
+
git tag v0.4.0
|
|
55
|
+
git push origin v0.4.0
|
|
40
56
|
```
|
|
41
57
|
|
|
42
|
-
`.github/workflows/publish.yml`
|
|
58
|
+
`.github/workflows/publish.yml` 在 `v*` tag 上运行:
|
|
43
59
|
|
|
44
|
-
1.
|
|
45
|
-
2.
|
|
46
|
-
3.
|
|
47
|
-
4.
|
|
60
|
+
1. 校验 tag 与 `package.json.version` 一致
|
|
61
|
+
2. 跳过 npm 上已存在的版本
|
|
62
|
+
3. 安装依赖、跑测试与发布检查
|
|
63
|
+
4. 通过 npm trusted publishing(OIDC)发布
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
versions publish under `latest`.
|
|
65
|
+
预发布版本(如 `0.4.0-beta.1`)发布到 `next` dist-tag,正式版本发布到 `latest`。
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
two authentication paths:
|
|
67
|
+
仓库默认不保存长期 `NPM_TOKEN`。工作流支持两种认证方式:
|
|
54
68
|
|
|
55
|
-
- **Trusted publishing
|
|
56
|
-
|
|
57
|
-
The workflow uses OIDC; no long-lived token is needed.
|
|
58
|
-
- **First publish by tag:** add a repository secret named `NPM_TOKEN` with an
|
|
59
|
-
npm granular/automation token that can publish `dsh-ta`. The publish step
|
|
60
|
-
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`。
|
|
61
71
|
|
|
62
|
-
npm trusted publishing
|
|
63
|
-
exists, so the first release usually needs either one manual `npm publish`
|
|
64
|
-
after `npm login`, or the `NPM_TOKEN` secret for the tag workflow. Later
|
|
65
|
-
releases can use OIDC trusted publishing.
|
|
72
|
+
npm trusted publishing 只能为已经存在的包配置,所以首次发布通常需要二选一:`npm login` 后手动 `npm publish`,或用 `NPM_TOKEN` secret 走 tag 工作流。之后的版本可以改用 OIDC trusted publishing。
|
|
66
73
|
|
|
67
|
-
## 4.
|
|
74
|
+
## 4. 发布后
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
验证:
|
|
70
77
|
|
|
71
78
|
```bash
|
|
72
|
-
npm view dsh-ta@0.
|
|
79
|
+
npm view dsh-ta@0.4.0 version
|
|
73
80
|
```
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
在干净的 DSH profile 里安装发布版本:
|
|
76
83
|
|
|
77
84
|
```bash
|
|
78
85
|
dsh plugin --profile <profile> add dsh-ta
|
|
79
86
|
```
|
|
80
87
|
|
|
81
|
-
|
|
82
|
-
|
|
88
|
+
然后打开 **设置 → TA 的家**,确认:
|
|
89
|
+
|
|
90
|
+
- 配置能读写并即时生效;
|
|
91
|
+
- 状态页能显示四件套状态、维护状态与最近运行;
|
|
92
|
+
- 人设页只编辑 SOUL 与称呼;
|
|
93
|
+
- SOUL 建议队列按预期出现。
|
|
94
|
+
|
|
95
|
+
0.4 的维护由插件内定时器直调模型,不创建会话;发布后确认 23:00 触发、`state/runs.jsonl` 与状态页显示一致。
|
|
83
96
|
|
|
84
|
-
##
|
|
97
|
+
## 回滚
|
|
85
98
|
|
|
86
|
-
|
|
99
|
+
不要重复发布同一个版本。发布坏了:
|
|
87
100
|
|
|
88
101
|
```bash
|
|
89
|
-
npm deprecate dsh-ta@0.
|
|
102
|
+
npm deprecate dsh-ta@0.4.0 "use 0.4.1"
|
|
90
103
|
```
|
|
91
104
|
|
|
92
|
-
|
|
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
|
-
-
|
|
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
|
|
|
@@ -37,11 +36,11 @@ $TA_HOME/state/usage/
|
|
|
37
36
|
- 价格表版本
|
|
38
37
|
- 估算 CNY
|
|
39
38
|
|
|
40
|
-
|
|
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
|
|
package/docs/presets.example.yml
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
# Example Agent
|
|
1
|
+
# Example Agent preset for dsh-ta 0.4.
|
|
2
2
|
#
|
|
3
|
-
# Add
|
|
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
|
|
5
|
+
# insert rows, append this entry to the same list.
|
|
6
6
|
#
|
|
7
|
-
# The dsh-ta bundle registers its own tools;
|
|
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,166 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-
|
|
3
|
-
*
|
|
4
|
-
* Host half: identity, gates, capture, review, outings, jurisdiction reads,
|
|
5
|
-
* settings/lifecycle API, and the settings surface shared with the client half.
|
|
2
|
+
* dsh-TA 插件入口薄壳:实现都在 src/host。
|
|
3
|
+
* 保留这个文件是为了让包入口、profile patch 与旧引用路径保持稳定。
|
|
6
4
|
*/
|
|
7
|
-
|
|
8
|
-
import { existsSync } from 'node:fs'
|
|
9
|
-
import { disposeAgent, releaseReviewForSession, syncAgent } from './tools.js'
|
|
10
|
-
import { moodLine } from './life.js'
|
|
11
|
-
import { identityText } from './identity.js'
|
|
12
|
-
import { normalizeConfig } from './config.js'
|
|
13
|
-
import { isTaSession } from './gates.js'
|
|
14
|
-
import { ensureReviewSchedule } from './settings/schedule.js'
|
|
15
|
-
import { createLifecycleQueue } from './settings/lifecycle.js'
|
|
16
|
-
import { mountSettingsRoutes } from './settings/routes.js'
|
|
17
|
-
import { RuntimeManager } from './runtime-manager.js'
|
|
18
|
-
import { MEMORY_GUIDANCE } from './prompts.js'
|
|
19
|
-
import { UsageLedger } from './usage/ledger.js'
|
|
20
|
-
import { mountStickerRoute } from './stickers/serve.js'
|
|
21
|
-
import { mountUsageRoute } from './usage/serve.js'
|
|
22
|
-
import { stickerGuidance } from './stickers/select.js'
|
|
23
|
-
|
|
24
|
-
export { Config, normalizeConfig } from './config.js'
|
|
25
|
-
export { realPath, todayText, withinHome, writeAtomic } from './storage.js'
|
|
26
|
-
export { isTaSession } from './gates.js'
|
|
27
|
-
export { identityText } from './identity.js'
|
|
28
|
-
export { readJurisdictionSession, recentConversations, recentJurisdiction, visitJurisdiction } from './jurisdiction.js'
|
|
29
|
-
export { addNote, cleanupOutings, finishOuting, moodLine, readMood, setMood, startOuting } from './life.js'
|
|
30
|
-
export { aggregateUsage, usageCsv } from './usage/aggregate.js'
|
|
31
|
-
export { ensureHome, readHomeMarker } from './settings/home.js'
|
|
32
|
-
export { readPersona, writePersona, writePersonaField } from './settings/persona.js'
|
|
33
|
-
export { readStatus } from './settings/status.js'
|
|
34
|
-
export { readImState } from './settings/im.js'
|
|
35
|
-
export { initializeHome, reincarnate } from './settings/lifecycle.js'
|
|
36
|
-
export { RuntimeManager } from './runtime-manager.js'
|
|
37
|
-
|
|
38
|
-
export const name = 'dsh-ta'
|
|
39
|
-
export const inject = ['systemPrompt', 'agentPresets', 'agents']
|
|
40
|
-
|
|
41
|
-
export function apply(ctx, input = {}) {
|
|
42
|
-
const config = normalizeConfig(input)
|
|
43
|
-
|
|
44
|
-
if (typeof ctx.inject === 'function') {
|
|
45
|
-
ctx.inject(['settings'], (settingsCtx) => {
|
|
46
|
-
const settings = settingsCtx.get?.('settings')
|
|
47
|
-
if (typeof settings?.configure !== 'function') return
|
|
48
|
-
try {
|
|
49
|
-
ctx.effect(
|
|
50
|
-
() => settings.configure({ auto: false }, ctx.fiber),
|
|
51
|
-
'dsh-ta settings presentation',
|
|
52
|
-
)
|
|
53
|
-
} catch {
|
|
54
|
-
/* settings is optional */
|
|
55
|
-
}
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
ctx.systemPrompt.section({
|
|
60
|
-
name: 'ta-identity',
|
|
61
|
-
order: 10,
|
|
62
|
-
interpolate: false,
|
|
63
|
-
text: (context) => identityText(ctx, context?.session, config),
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
ctx.systemPrompt.section({
|
|
67
|
-
name: 'ta-memory-guidance',
|
|
68
|
-
order: 20,
|
|
69
|
-
interpolate: false,
|
|
70
|
-
text: (context) => isTaSession(ctx, context?.session, config) ? MEMORY_GUIDANCE : '',
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
ctx.systemPrompt.section({
|
|
74
|
-
name: 'ta-sticker-guidance',
|
|
75
|
-
order: 35,
|
|
76
|
-
interpolate: false,
|
|
77
|
-
text: (context) => {
|
|
78
|
-
if (!isTaSession(ctx, context?.session, config)) return ''
|
|
79
|
-
let preset
|
|
80
|
-
try {
|
|
81
|
-
preset = ctx.agentPresets?.presetForSession?.(context.session)
|
|
82
|
-
} catch {
|
|
83
|
-
preset = undefined
|
|
84
|
-
}
|
|
85
|
-
return preset === 'ta' ? stickerGuidance(config) : ''
|
|
86
|
-
},
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
ctx.systemPrompt.section({
|
|
90
|
-
name: 'ta-mood',
|
|
91
|
-
order: 30,
|
|
92
|
-
interpolate: false,
|
|
93
|
-
text: (context) => isTaSession(ctx, context?.session, config) ? moodLine(config) : '',
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
ctx.on('agent/created', ({ agent }) => {
|
|
97
|
-
try { syncAgent(ctx, agent, config) } catch { /* never fail the host for an adapter */ }
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
ctx.on('agent-preset/selected', (sessionId) => {
|
|
101
|
-
try {
|
|
102
|
-
const agent = ctx.agents.get(sessionId)
|
|
103
|
-
if (agent) syncAgent(ctx, agent, config)
|
|
104
|
-
} catch { /* never fail the host for an adapter */ }
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
ctx.on('agent/disposed', ({ agent }) => {
|
|
108
|
-
disposeAgent(config, agent)
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
ctx.on('session/event', (session, event) => {
|
|
112
|
-
if (event.type === 'turn/end') releaseReviewForSession(config, session)
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
// Runtime owns Capture, Outbox and every timer that is bound to TA_HOME. A
|
|
116
|
-
// lifecycle operation stops it, changes the config, then starts a new one.
|
|
117
|
-
const runtime = new RuntimeManager({ ctx, config, logger: ctx.logger })
|
|
118
|
-
try { runtime.start() } catch { /* identity/tools must still load */ }
|
|
119
|
-
ctx.on('session/event', (session, event) => {
|
|
120
|
-
try { runtime.handle(session, event) } catch { /* adapter diagnostics must not stop sessions */ }
|
|
121
|
-
})
|
|
122
|
-
ctx.on('session/disposed', session => {
|
|
123
|
-
try { runtime.handleDispose(session) } catch { /* noop */ }
|
|
124
|
-
})
|
|
125
|
-
if (typeof ctx.effect === 'function') {
|
|
126
|
-
try {
|
|
127
|
-
ctx.effect(() => () => runtime.stop(), 'dsh-ta runtime')
|
|
128
|
-
} catch {
|
|
129
|
-
/* runtime still works until process exit */
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const host = {
|
|
134
|
-
ctx,
|
|
135
|
-
config,
|
|
136
|
-
runtime,
|
|
137
|
-
lifecycle: { operation: null },
|
|
138
|
-
queue: createLifecycleQueue(),
|
|
139
|
-
logger: ctx.logger,
|
|
140
|
-
}
|
|
141
|
-
try { mountSettingsRoutes(ctx, config, host) } catch { /* settings API optional */ }
|
|
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
|
-
// Only create the nightly task once an existing TA home is present. The
|
|
157
|
-
// initialize/reincarnate flows reconcile it explicitly after a change.
|
|
158
|
-
if (config.reviewScheduleEnabled && existsSync(config.taHome)) {
|
|
159
|
-
void ensureReviewSchedule(ctx, config).catch(() => {})
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// HMR/reload: agents that already exist never emit agent/created again.
|
|
163
|
-
try {
|
|
164
|
-
for (const agent of ctx.agents.list()) syncAgent(ctx, agent, config)
|
|
165
|
-
} catch { /* never fail the host for an adapter */ }
|
|
166
|
-
}
|
|
5
|
+
export * from './src/host/index.js'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ta",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A persistent personal assistant with its own home, memory, lifecycle and settings page for DeepSeek Harness.",
|
|
6
6
|
"repository": {
|
|
@@ -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,37 +29,14 @@
|
|
|
29
29
|
"CHANGELOG.md",
|
|
30
30
|
"LICENSE",
|
|
31
31
|
"docs",
|
|
32
|
-
"client.js",
|
|
33
|
-
"memory",
|
|
34
32
|
"icon.svg",
|
|
35
|
-
"
|
|
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",
|
|
48
|
-
"runtime-manager.js",
|
|
49
|
-
"settings/defaults.js",
|
|
50
|
-
"settings/errors.js",
|
|
51
|
-
"settings/home.js",
|
|
52
|
-
"settings/persona.js",
|
|
53
|
-
"settings/status.js",
|
|
54
|
-
"settings/im.js",
|
|
55
|
-
"settings/routes.js",
|
|
56
|
-
"settings/lifecycle.js",
|
|
57
|
-
"settings/schedule.js"
|
|
33
|
+
"src"
|
|
58
34
|
],
|
|
59
35
|
"scripts": {
|
|
60
36
|
"test": "node --test test/*.test.mjs",
|
|
61
37
|
"check": "node scripts/check-release.mjs",
|
|
62
|
-
"prepublishOnly": "npm test && npm run check"
|
|
38
|
+
"prepublishOnly": "npm test && npm run check",
|
|
39
|
+
"inspect": "node scripts/inspect-home.mjs"
|
|
63
40
|
},
|
|
64
41
|
"engines": {
|
|
65
42
|
"dsh": ">=0.2.3-alpha.3"
|