dsh-ta 0.0.0-stage → 0.2.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 +30 -0
- package/LICENSE +21 -0
- package/README.md +419 -2
- package/client.js +618 -0
- package/config.js +154 -0
- package/cordis.patch.yml +101 -0
- package/docs/PACKS.md +78 -0
- package/docs/RELEASE.md +88 -0
- package/docs/USAGE.md +93 -0
- package/docs/presets.example.yml +95 -0
- package/docs/reme/.env.example +11 -0
- package/docs/reme/docker-compose.yml +25 -0
- package/gates.js +18 -0
- package/icon.svg +8 -0
- package/identity.js +97 -0
- package/im/bindings.js +29 -0
- package/im/say.js +24 -0
- package/index.js +172 -0
- package/jurisdiction.js +171 -0
- package/life.js +277 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/memory/capture.js +113 -0
- package/memory/messages.js +76 -0
- package/memory/outbox.js +130 -0
- package/package.json +75 -4
- package/prompts.js +28 -0
- package/reme.js +23 -0
- package/runtime.js +209 -0
- package/stickers/load.js +107 -0
- package/stickers/select.js +39 -0
- package/stickers/serve.js +48 -0
- package/stickers/tool.js +150 -0
- package/storage.js +95 -0
- package/tools.js +540 -0
- package/usage/aggregate.js +78 -0
- package/usage/ledger.js +126 -0
- package/usage/pricing.js +52 -0
- package/usage/serve.js +38 -0
package/config.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { resolve } from 'node:path'
|
|
2
|
+
import z from '@deepseek-ai/schemastery'
|
|
3
|
+
|
|
4
|
+
const DEFAULT_TA_HOME = '~/TATA/home'
|
|
5
|
+
const DEFAULT_REME = 'http://127.0.0.1:2333'
|
|
6
|
+
const DEFAULT_PRESETS = ['ta', 'ta-review']
|
|
7
|
+
const DEFAULT_PERMISSION = 'read-only'
|
|
8
|
+
const DEFAULT_STICKER_MIN_GAP_MINUTES = 30
|
|
9
|
+
const DEFAULT_STICKER_MAX_PER_DAY = 12
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Host configuration schema. Its entry id is also the settings namespace
|
|
13
|
+
* used by the client settings panel.
|
|
14
|
+
*/
|
|
15
|
+
export const Config = z.object({
|
|
16
|
+
taHome: z.string().default(DEFAULT_TA_HOME).volatile(),
|
|
17
|
+
remeEndpoint: z.string().default(DEFAULT_REME).volatile(),
|
|
18
|
+
presets: z.array(z.string()).default(DEFAULT_PRESETS),
|
|
19
|
+
permissionPreset: z.string().default(DEFAULT_PERMISSION),
|
|
20
|
+
captureEnabled: z.boolean().default(true).volatile(),
|
|
21
|
+
captureInterval: z.number().step(1).min(1).max(60).default(5).volatile(),
|
|
22
|
+
timezone: z.string().default('Asia/Shanghai').volatile(),
|
|
23
|
+
jurisdictions: z.array(z.string()).default(['~/dsh']).volatile(),
|
|
24
|
+
heartbeatEnabled: z.boolean().default(false).volatile(),
|
|
25
|
+
heartbeatActiveStart: z.string().default('08:00').volatile(),
|
|
26
|
+
heartbeatActiveEnd: z.string().default('23:00').volatile(),
|
|
27
|
+
reviewScheduleEnabled: z.boolean().default(true),
|
|
28
|
+
dreamEnabled: z.boolean().default(true).volatile(),
|
|
29
|
+
outingCleanupEnabled: z.boolean().default(true).volatile(),
|
|
30
|
+
jurisdictionOutingEnabled: z.boolean().default(true).volatile(),
|
|
31
|
+
jurisdictionOutingTime: z.string().default('22:45').volatile(),
|
|
32
|
+
stickerMinGapMinutes: z.number().step(1).min(0).max(1440).default(DEFAULT_STICKER_MIN_GAP_MINUTES),
|
|
33
|
+
stickerMaxPerDay: z.number().step(1).min(1).max(100).default(DEFAULT_STICKER_MAX_PER_DAY),
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
const DEFAULT_UNTRUSTED_TOOLS = [
|
|
37
|
+
'web_search',
|
|
38
|
+
'web_fetch',
|
|
39
|
+
'ta_visit',
|
|
40
|
+
'ta_read_session',
|
|
41
|
+
'ta_recent',
|
|
42
|
+
'ta_send_scout',
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export function expandHome(value) {
|
|
47
|
+
if (typeof value !== 'string' || value.length === 0) return value
|
|
48
|
+
if (value === '~') return process.env.HOME ?? value
|
|
49
|
+
if (value.startsWith('~/')) return resolve(process.env.HOME ?? '~', value.slice(2))
|
|
50
|
+
return resolve(value)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function configValue(input, key) {
|
|
54
|
+
const value = input?.[key]
|
|
55
|
+
return value !== null && typeof value === 'object' && typeof value.get === 'function'
|
|
56
|
+
? value.get()
|
|
57
|
+
: value
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Normalize the entry config once, but keep getters for volatile fields so a
|
|
62
|
+
* settings-panel write is visible to already-running timers and tool closures.
|
|
63
|
+
*/
|
|
64
|
+
export function normalizeConfig(input = {}) {
|
|
65
|
+
const config = {}
|
|
66
|
+
const read = key => configValue(input, key)
|
|
67
|
+
const define = (key, getter) => {
|
|
68
|
+
Object.defineProperty(config, key, { enumerable: true, configurable: true, get: getter })
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
define('taHome', () => expandHome(read('taHome') || process.env.TA_HOME || DEFAULT_TA_HOME))
|
|
72
|
+
define('remeEndpoint', () => String(read('remeEndpoint') || process.env.REME_URL || DEFAULT_REME).replace(/\/+$/, ''))
|
|
73
|
+
define('presets', () => {
|
|
74
|
+
const value = read('presets')
|
|
75
|
+
return Array.isArray(value) && value.length > 0 ? value.map(String) : DEFAULT_PRESETS
|
|
76
|
+
})
|
|
77
|
+
define('permissionPreset', () => {
|
|
78
|
+
const value = read('permissionPreset')
|
|
79
|
+
return typeof value === 'string' && value ? value : DEFAULT_PERMISSION
|
|
80
|
+
})
|
|
81
|
+
define('requestTimeoutMs', () => {
|
|
82
|
+
const value = read('requestTimeoutMs')
|
|
83
|
+
return Number.isFinite(value) && value > 0 ? value : 10000
|
|
84
|
+
})
|
|
85
|
+
define('captureEnabled', () => read('captureEnabled') !== false)
|
|
86
|
+
define('captureInterval', () => {
|
|
87
|
+
const value = read('captureInterval')
|
|
88
|
+
return Number.isSafeInteger(value) && value > 0 ? value : 5
|
|
89
|
+
})
|
|
90
|
+
define('untrustedTools', () => {
|
|
91
|
+
const value = read('untrustedTools')
|
|
92
|
+
return Array.isArray(value) && value.length > 0 ? value.map(String) : DEFAULT_UNTRUSTED_TOOLS
|
|
93
|
+
})
|
|
94
|
+
define('captureExcludedTools', () => {
|
|
95
|
+
const value = read('captureExcludedTools')
|
|
96
|
+
return Array.isArray(value) && value.length > 0
|
|
97
|
+
? value.map(String)
|
|
98
|
+
: ['ta_visit', 'ta_read_session', 'ta_recent', 'ta_send_scout']
|
|
99
|
+
})
|
|
100
|
+
define('timezone', () => {
|
|
101
|
+
const value = read('timezone')
|
|
102
|
+
return typeof value === 'string' && value ? value : 'Asia/Shanghai'
|
|
103
|
+
})
|
|
104
|
+
define('outboxDir', () => {
|
|
105
|
+
const value = read('outboxDir')
|
|
106
|
+
return typeof value === 'string' && value ? value : 'state/capture/outbox'
|
|
107
|
+
})
|
|
108
|
+
define('internalSessions', () => {
|
|
109
|
+
const value = read('internalSessions')
|
|
110
|
+
return typeof value === 'string' && value ? value : 'state/internal-sessions.json'
|
|
111
|
+
})
|
|
112
|
+
define('sessionMap', () => {
|
|
113
|
+
const value = read('sessionMap')
|
|
114
|
+
return typeof value === 'string' && value ? value : 'state/session-map.json'
|
|
115
|
+
})
|
|
116
|
+
define('autoMemoryTimeoutMs', () => {
|
|
117
|
+
const value = read('autoMemoryTimeoutMs')
|
|
118
|
+
return Number.isFinite(value) && value > 0 ? value : 120000
|
|
119
|
+
})
|
|
120
|
+
define('dreamEnabled', () => read('dreamEnabled') !== false)
|
|
121
|
+
define('reviewScheduleEnabled', () => read('reviewScheduleEnabled') !== false)
|
|
122
|
+
define('heartbeatEnabled', () => read('heartbeatEnabled') === true)
|
|
123
|
+
define('heartbeatActiveStart', () => {
|
|
124
|
+
const value = read('heartbeatActiveStart')
|
|
125
|
+
return typeof value === 'string' && value ? value : '08:00'
|
|
126
|
+
})
|
|
127
|
+
define('heartbeatActiveEnd', () => {
|
|
128
|
+
const value = read('heartbeatActiveEnd')
|
|
129
|
+
return typeof value === 'string' && value ? value : '23:00'
|
|
130
|
+
})
|
|
131
|
+
define('outingCleanupEnabled', () => read('outingCleanupEnabled') !== false)
|
|
132
|
+
define('jurisdictionOutingEnabled', () => read('jurisdictionOutingEnabled') !== false)
|
|
133
|
+
define('jurisdictionOutingTime', () => {
|
|
134
|
+
const value = read('jurisdictionOutingTime')
|
|
135
|
+
return typeof value === 'string' && value ? value : '22:45'
|
|
136
|
+
})
|
|
137
|
+
define('stickerMinGapMinutes', () => {
|
|
138
|
+
const value = read('stickerMinGapMinutes')
|
|
139
|
+
return Number.isFinite(value) && value >= 0 ? value : DEFAULT_STICKER_MIN_GAP_MINUTES
|
|
140
|
+
})
|
|
141
|
+
define('stickerMaxPerDay', () => {
|
|
142
|
+
const value = read('stickerMaxPerDay')
|
|
143
|
+
return Number.isSafeInteger(value) && value >= 1 ? value : DEFAULT_STICKER_MAX_PER_DAY
|
|
144
|
+
})
|
|
145
|
+
define('jurisdictions', () => {
|
|
146
|
+
const value = read('jurisdictions')
|
|
147
|
+
return Array.isArray(value) && value.length > 0 ? value.map(String) : [expandHome('~/dsh')]
|
|
148
|
+
})
|
|
149
|
+
define('imConnectDir', () => expandHome(
|
|
150
|
+
read('imConnectDir') || resolve(process.env.HOME ?? '~', '.dsh/dsh-im-connect'),
|
|
151
|
+
))
|
|
152
|
+
return config
|
|
153
|
+
}
|
|
154
|
+
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
- insert:
|
|
2
|
+
- id: dsh-ta
|
|
3
|
+
name: dsh-ta
|
|
4
|
+
config:
|
|
5
|
+
taHome: "~/TATA/home"
|
|
6
|
+
remeEndpoint: http://127.0.0.1:2333
|
|
7
|
+
presets:
|
|
8
|
+
- ta
|
|
9
|
+
- ta-review
|
|
10
|
+
permissionPreset: read-only
|
|
11
|
+
captureEnabled: true
|
|
12
|
+
captureInterval: 5
|
|
13
|
+
timezone: Asia/Shanghai
|
|
14
|
+
heartbeatEnabled: false
|
|
15
|
+
jurisdictions:
|
|
16
|
+
- "~/dsh"
|
|
17
|
+
- id: preset-ta
|
|
18
|
+
name: "@deepseek-ai/dsh-agent-preset"
|
|
19
|
+
config:
|
|
20
|
+
id: ta
|
|
21
|
+
name: "TA"
|
|
22
|
+
description: "Persistent personal assistant preset. Read-only tools and no shell."
|
|
23
|
+
order: 9
|
|
24
|
+
plugins:
|
|
25
|
+
- id: time-context
|
|
26
|
+
name: "@deepseek-ai/dsh-time-context"
|
|
27
|
+
- id: agent-instructions
|
|
28
|
+
name: "@deepseek-ai/dsh-agent-instructions"
|
|
29
|
+
config:
|
|
30
|
+
maxBytes: 65536
|
|
31
|
+
- id: tool-fs
|
|
32
|
+
name: "@deepseek-ai/dsh-tool-fs"
|
|
33
|
+
config:
|
|
34
|
+
read: true
|
|
35
|
+
readImage: true
|
|
36
|
+
write: false
|
|
37
|
+
edit: false
|
|
38
|
+
- id: tool-fs-search
|
|
39
|
+
name: "@deepseek-ai/dsh-tool-fs-search"
|
|
40
|
+
config:
|
|
41
|
+
sampleOverCapGlobResults: false
|
|
42
|
+
- id: tool-web
|
|
43
|
+
name: "@deepseek-ai/dsh-tool-web"
|
|
44
|
+
- id: tool-ask-user
|
|
45
|
+
name: "@deepseek-ai/dsh-tool-ask-user"
|
|
46
|
+
- id: tool-todo
|
|
47
|
+
name: "@deepseek-ai/dsh-tool-todo"
|
|
48
|
+
config:
|
|
49
|
+
allowParallelInProgress: false
|
|
50
|
+
- id: compaction
|
|
51
|
+
name: cordis:group
|
|
52
|
+
group: true
|
|
53
|
+
isolate:
|
|
54
|
+
compaction: true
|
|
55
|
+
toolResultPruner: true
|
|
56
|
+
config:
|
|
57
|
+
- id: compaction-basic
|
|
58
|
+
name: "@deepseek-ai/dsh-compaction-basic"
|
|
59
|
+
- id: command-compact
|
|
60
|
+
name: "@deepseek-ai/dsh-command-compact"
|
|
61
|
+
- id: tool-result-pruner
|
|
62
|
+
name: "@deepseek-ai/dsh-compaction-tool-result-pruner"
|
|
63
|
+
|
|
64
|
+
- id: preset-ta-review
|
|
65
|
+
name: "@deepseek-ai/dsh-agent-preset"
|
|
66
|
+
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
|
|
71
|
+
plugins:
|
|
72
|
+
- id: time-context
|
|
73
|
+
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/PACKS.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# 表情包
|
|
2
|
+
|
|
3
|
+
dsh-TA 的 npm 包不包含第三方表情素材,代码和文档使用 MIT 许可。
|
|
4
|
+
|
|
5
|
+
表情包是用户自己安装的本地资源。没有可用 Pack 时,`ta_sticker` 工具不会注册。
|
|
6
|
+
|
|
7
|
+
下面的 `$TA_HOME` 指设置里的 `taHome`,默认是 `~/TATA/home`。
|
|
8
|
+
|
|
9
|
+
## Pack 目录
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
$TA_HOME/stickers/packs/<id>@<version>/
|
|
13
|
+
├── pack.json
|
|
14
|
+
├── images/
|
|
15
|
+
└── ... # 可选:来源、许可、署名说明
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## pack.json
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"schemaVersion": 1,
|
|
23
|
+
"id": "my-pack",
|
|
24
|
+
"name": "我的表情",
|
|
25
|
+
"version": "1.0.0",
|
|
26
|
+
"defaultVariant": "default",
|
|
27
|
+
"variants": {
|
|
28
|
+
"default": "images/happy.png"
|
|
29
|
+
},
|
|
30
|
+
"stickers": [
|
|
31
|
+
{
|
|
32
|
+
"id": "happy",
|
|
33
|
+
"emotion": ["开心"],
|
|
34
|
+
"file": "images/happy.png",
|
|
35
|
+
"text": "开心"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
规则:
|
|
42
|
+
|
|
43
|
+
- `file` 必须是 Pack 目录内的相对路径,不能是绝对路径或含 `..`。
|
|
44
|
+
- 支持 PNG/GIF/WebP/JPG/JPEG;不要填远程 URL。
|
|
45
|
+
- `variants` 是对象,不是数组;键是变体名,值也是 Pack 内相对路径。单个 sticker 的 `variants` 优先,Pack 级 `variants` 作为回退。
|
|
46
|
+
- 不在 `pack.json` 中声明 `defaultVariant` 时使用 `default`。
|
|
47
|
+
- 每个 emotion 至少一张;重复 emotion 会随机选。
|
|
48
|
+
- Pack 的素材来源和许可由安装者负责;如果你分发 Pack,请自行保留相应的 License/署名。
|
|
49
|
+
- 不要删除已使用过版本中的素材;历史消息可能还需要回放。
|
|
50
|
+
|
|
51
|
+
Pack 只在 host 加载时扫描。安装或修改 Pack 后,需要重载/重启 host;已经存在的 Ta 会话还需要新会话或重新注册工具后才会看到 `ta_sticker`。
|
|
52
|
+
|
|
53
|
+
## 发送频率
|
|
54
|
+
|
|
55
|
+
默认同一会话 30 分钟内最多一张,每天最多 12 张。Host 配置项 `stickerMinGapMinutes` / `stickerMaxPerDay` 可调;`stickerMinGapMinutes: 0` 关闭间隔限制。这两项暂不显示在设置面板。
|
|
56
|
+
|
|
57
|
+
## 启用
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"activePack": "my-pack@1.0.0",
|
|
62
|
+
"activeVariant": "default"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
写入:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
$TA_HOME/state/stickers.json
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 多 Pack
|
|
73
|
+
|
|
74
|
+
同一目录下可以放多个 `id@version`。Host 会扫描并校验所有 Pack;当前只有一个 active Pack。
|
|
75
|
+
|
|
76
|
+
只有一个 Pack 时会自动使用它;有多个 Pack 时必须在上面的 `state/stickers.json` 中写 `activePack`,否则 `ta_sticker` 不注册。
|
|
77
|
+
|
|
78
|
+
未来增加选择界面时,会复用同一份 registry,不需要改 Pack 格式。
|
package/docs/RELEASE.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Release
|
|
2
|
+
|
|
3
|
+
This package is plain JavaScript. A release is a versioned npm package and a matching Git tag.
|
|
4
|
+
|
|
5
|
+
## 1. Prepare
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm ci
|
|
9
|
+
npm test
|
|
10
|
+
npm run check
|
|
11
|
+
npm pack --dry-run
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`npm run check` verifies:
|
|
15
|
+
|
|
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
|
|
20
|
+
|
|
21
|
+
## 2. Version and changelog
|
|
22
|
+
|
|
23
|
+
1. Update `package.json` `version`.
|
|
24
|
+
2. Add the same version to `CHANGELOG.md`.
|
|
25
|
+
3. Commit the changes.
|
|
26
|
+
|
|
27
|
+
Use semantic versioning:
|
|
28
|
+
|
|
29
|
+
- `0.x.y` while the public surface is still moving
|
|
30
|
+
- `x.y.z` once the settings/config surface is stable
|
|
31
|
+
|
|
32
|
+
## 3. Tag and publish
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
git tag v0.1.0
|
|
36
|
+
git push origin v0.1.0
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`.github/workflows/publish.yml` runs on `v*` tags:
|
|
40
|
+
|
|
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)
|
|
45
|
+
|
|
46
|
+
Prereleases such as `0.2.0-beta.1` publish under the `next` dist-tag. Stable
|
|
47
|
+
versions publish under `latest`.
|
|
48
|
+
|
|
49
|
+
No `NPM_TOKEN` is stored in the repository by default. The workflow supports
|
|
50
|
+
two authentication paths:
|
|
51
|
+
|
|
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.
|
|
58
|
+
|
|
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.
|
|
63
|
+
|
|
64
|
+
## 4. After publish
|
|
65
|
+
|
|
66
|
+
Verify:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm view dsh-ta@0.1.0 version
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Install the published version in a clean DSH profile:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
dsh plugin --profile <profile> add dsh-ta
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then open **Settings → Ta** and confirm the panel can read and save the config.
|
|
79
|
+
|
|
80
|
+
## Rollback
|
|
81
|
+
|
|
82
|
+
Never republish the same version. If a release is broken:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
npm deprecate dsh-ta@0.1.0 "use 0.1.1"
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Publish a fixed patch version instead.
|
package/docs/USAGE.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# 花销与用量
|
|
2
|
+
|
|
3
|
+
dsh-TA 记录 **DSH 内的 Ta agent 花销**,用于查看累计用量、估算金额,以及按类别拆分。
|
|
4
|
+
|
|
5
|
+
下面的 `$TA_HOME` 指设置里的 `taHome`,默认是 `~/TATA/home`。
|
|
6
|
+
|
|
7
|
+
## 计入范围
|
|
8
|
+
|
|
9
|
+
- 日常聊天(Web / 飞书)
|
|
10
|
+
- 23:00 回顾
|
|
11
|
+
- 22:45 辖区外出
|
|
12
|
+
- 心跳 life 会话
|
|
13
|
+
- 其他以 `ta` / `ta-review` 运行的 DSH 会话
|
|
14
|
+
|
|
15
|
+
## 不计入
|
|
16
|
+
|
|
17
|
+
- ReMe 自己的 `auto_memory` / `auto_dream` LLM 调用
|
|
18
|
+
- 飞书、ReMe 等外部服务自身费用
|
|
19
|
+
- 账户余额、充值、账单
|
|
20
|
+
|
|
21
|
+
因此页面上的金额是 **DSH agent 估算**,不是完整账单。
|
|
22
|
+
|
|
23
|
+
## 账本
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
$TA_HOME/state/usage/
|
|
27
|
+
├── 2026-12.jsonl
|
|
28
|
+
└── pricing.json
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
每轮记录:
|
|
32
|
+
|
|
33
|
+
- 时间、session、turn
|
|
34
|
+
- 类别
|
|
35
|
+
- 模型
|
|
36
|
+
- input / cache read / cache write / output tokens
|
|
37
|
+
- 价格表版本
|
|
38
|
+
- 估算 CNY
|
|
39
|
+
|
|
40
|
+
相同 `session:turn` 在汇总时只计一次;正常事件流不会重复写入。
|
|
41
|
+
|
|
42
|
+
## 价格
|
|
43
|
+
|
|
44
|
+
默认价格表在 `usage/pricing.js`,单位是 **CNY / 百万 token**,只是估算。
|
|
45
|
+
|
|
46
|
+
用户可覆盖:
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
$TA_HOME/state/usage/pricing.json
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"currency": "CNY",
|
|
55
|
+
"version": "my-prices",
|
|
56
|
+
"models": {
|
|
57
|
+
"deepseek-flash": {
|
|
58
|
+
"input": 1,
|
|
59
|
+
"cacheRead": 0.02,
|
|
60
|
+
"cacheWrite": 1,
|
|
61
|
+
"output": 4
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
没有价格的模型只显示 token,不伪造金额;如果全部记录都没有价格,金额显示 `—`。
|
|
68
|
+
|
|
69
|
+
页面按价格表里的 `currency` 显示(默认 CNY)。
|
|
70
|
+
|
|
71
|
+
## 查看
|
|
72
|
+
|
|
73
|
+
打开 **设置 → TA 的家**,顶部「花销」卡片显示:
|
|
74
|
+
|
|
75
|
+
- 累计 tokens
|
|
76
|
+
- 估算 CNY
|
|
77
|
+
- 轮数
|
|
78
|
+
- 按类别汇总
|
|
79
|
+
|
|
80
|
+
导出:
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
/api/dsh-ta/usage/export.csv
|
|
84
|
+
/api/dsh-ta/usage/export.json
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 历史
|
|
88
|
+
|
|
89
|
+
默认从当前版本开始记账,不自动回填旧会话。旧记录没有完整模型/价格时补算容易失真,后续如有需要再做显式回填工具。
|
|
90
|
+
|
|
91
|
+
## 隐私
|
|
92
|
+
|
|
93
|
+
账本保存在 `$TA_HOME`,不上传外部;使用接口需要当前 profile 的已认证页面。
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Example Agent presets for dsh-ta.
|
|
2
|
+
#
|
|
3
|
+
# Add these rows to the `insert:` list in your DSH profile patch
|
|
4
|
+
# (~/.dsh/profiles/<profile>/cordis.patch.yml). If you already have other
|
|
5
|
+
# insert rows, append these entries to the same list.
|
|
6
|
+
#
|
|
7
|
+
# The dsh-ta bundle registers its own tools; these presets define the host
|
|
8
|
+
# tool surface that the adapter gates and extends.
|
|
9
|
+
|
|
10
|
+
- insert:
|
|
11
|
+
- id: preset-ta
|
|
12
|
+
name: "@deepseek-ai/dsh-agent-preset"
|
|
13
|
+
config:
|
|
14
|
+
id: ta
|
|
15
|
+
name: "TA"
|
|
16
|
+
description: "Persistent personal assistant preset. Read-only tools and no shell."
|
|
17
|
+
order: 9
|
|
18
|
+
plugins:
|
|
19
|
+
- id: time-context
|
|
20
|
+
name: "@deepseek-ai/dsh-time-context"
|
|
21
|
+
- id: agent-instructions
|
|
22
|
+
name: "@deepseek-ai/dsh-agent-instructions"
|
|
23
|
+
config:
|
|
24
|
+
maxBytes: 65536
|
|
25
|
+
- id: tool-fs
|
|
26
|
+
name: "@deepseek-ai/dsh-tool-fs"
|
|
27
|
+
config:
|
|
28
|
+
read: true
|
|
29
|
+
readImage: true
|
|
30
|
+
write: false
|
|
31
|
+
edit: false
|
|
32
|
+
- id: tool-fs-search
|
|
33
|
+
name: "@deepseek-ai/dsh-tool-fs-search"
|
|
34
|
+
config:
|
|
35
|
+
sampleOverCapGlobResults: false
|
|
36
|
+
- id: tool-web
|
|
37
|
+
name: "@deepseek-ai/dsh-tool-web"
|
|
38
|
+
- id: tool-ask-user
|
|
39
|
+
name: "@deepseek-ai/dsh-tool-ask-user"
|
|
40
|
+
- id: tool-todo
|
|
41
|
+
name: "@deepseek-ai/dsh-tool-todo"
|
|
42
|
+
config:
|
|
43
|
+
allowParallelInProgress: false
|
|
44
|
+
- id: compaction
|
|
45
|
+
name: cordis:group
|
|
46
|
+
group: true
|
|
47
|
+
isolate:
|
|
48
|
+
compaction: true
|
|
49
|
+
toolResultPruner: true
|
|
50
|
+
config:
|
|
51
|
+
- id: compaction-basic
|
|
52
|
+
name: "@deepseek-ai/dsh-compaction-basic"
|
|
53
|
+
- id: command-compact
|
|
54
|
+
name: "@deepseek-ai/dsh-command-compact"
|
|
55
|
+
- id: tool-result-pruner
|
|
56
|
+
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"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Copy to .env and fill in. Keep this file at mode 0600.
|
|
2
|
+
REME_DATA_DIR=./memory
|
|
3
|
+
|
|
4
|
+
# LLM used by ReMe auto_memory / auto_dream.
|
|
5
|
+
LLM_BACKEND=openai
|
|
6
|
+
LLM_BASE_URL=https://api.deepseek.com/v1
|
|
7
|
+
LLM_MODEL_NAME=deepseek-chat
|
|
8
|
+
LLM_API_KEY=replace-me
|
|
9
|
+
|
|
10
|
+
# Optional; set only if a ReMe workflow needs DashScope.
|
|
11
|
+
DASHSCOPE_API_KEY=
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: dsh-ta-reme
|
|
2
|
+
|
|
3
|
+
services:
|
|
4
|
+
reme:
|
|
5
|
+
image: ghcr.io/agentscope-ai/reme:0.4.2.3
|
|
6
|
+
container_name: dsh-ta-reme
|
|
7
|
+
command: ["start", "jobs.dream_cron.enabled=false"]
|
|
8
|
+
init: false
|
|
9
|
+
user: "1001:1001"
|
|
10
|
+
working_dir: /tmp/reme-home
|
|
11
|
+
ports:
|
|
12
|
+
- "127.0.0.1:2333:2333"
|
|
13
|
+
volumes:
|
|
14
|
+
- "${REME_DATA_DIR:-./memory}:/data"
|
|
15
|
+
env_file:
|
|
16
|
+
- .env
|
|
17
|
+
environment:
|
|
18
|
+
REME_HOST: 0.0.0.0
|
|
19
|
+
REME_PORT: "2333"
|
|
20
|
+
REME_WORKSPACE_DIR: /data
|
|
21
|
+
REME_TIMEZONE: Asia/Shanghai
|
|
22
|
+
TZ: Asia/Shanghai
|
|
23
|
+
HOME: /tmp/reme-home
|
|
24
|
+
restart: unless-stopped
|
|
25
|
+
stop_grace_period: 60s
|
package/gates.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { normalizeConfig } from './config.js'
|
|
2
|
+
import { realPath } from './storage.js'
|
|
3
|
+
|
|
4
|
+
export function isTaSession(ctx, session, config = {}) {
|
|
5
|
+
const settings = normalizeConfig(config)
|
|
6
|
+
const header = session?.header
|
|
7
|
+
if (!header || header.origin !== undefined) return false
|
|
8
|
+
if (typeof header.cwd !== 'string' || header.cwd.length === 0) return false
|
|
9
|
+
if (realPath(header.cwd) !== realPath(settings.taHome)) return false
|
|
10
|
+
let preset
|
|
11
|
+
try {
|
|
12
|
+
preset = ctx?.agentPresets?.presetForSession?.(session)
|
|
13
|
+
} catch {
|
|
14
|
+
return false
|
|
15
|
+
}
|
|
16
|
+
return typeof preset === 'string' && settings.presets.includes(preset)
|
|
17
|
+
}
|
|
18
|
+
|
package/icon.svg
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 36 36">
|
|
2
|
+
<rect width="36" height="36" rx="9" fill="#3b5bdb"/>
|
|
3
|
+
<g fill="none" stroke="#fff" stroke-width="2.1" stroke-linecap="round" stroke-linejoin="round">
|
|
4
|
+
<path d="M7 29h22"/>
|
|
5
|
+
<path d="M9.5 29V14L18 7l8.5 7v15"/>
|
|
6
|
+
<path d="M18 13.5l.9 2.55 2.55.9-2.55.9-.9 2.55-.9-2.55-2.55-.9 2.55-.9z" stroke-width="1.7"/>
|
|
7
|
+
</g>
|
|
8
|
+
</svg>
|