@restregular/dsh-memory 0.24.0 → 0.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  本项目的版本记录。安装 id 与 npm 版本一一对应。
4
4
 
5
+ ## 0.24.1 — 修复 memory_scopes 注册失败导致 memory_get 一起消失
6
+
7
+ - **现象**:升级到 0.24.0 后,模型侧看不到 `memory_scopes`,连原本正常的 `memory_get` 也变成 `unknown tool`;`memory_search` / `memory_list` / `memory_save` / `memory_forget` 仍在。
8
+ - **根因**:`memory_scopes` 的 `requests` 参数用了嵌套对象 schema。DSH `defineTool` 的 authoring DSL 要求对象类型必须显式写 `additionalProperties`(嵌套对象的 `required` 也不在允许关键字里),注册期抛错 → 整个 tool-memory apply 中断,排在 `memory_scopes` 后面的 `memory_get` 没有注册。
9
+ - **修复**:`action="request"` 改为扁平参数 `scopes: string[]` + `permissions: ["read"|"write"][]`(作用于本次所有 scopes),不再使用 `object` / `properties` 参数;provider 的内部请求结构不变。
10
+ - **回归守卫**:新增测试,禁止任何 `memory_*` 工具参数出现 `type:"object"` / `properties`,避免同类 schema 再次把后续工具注册带崩。
11
+ - 验证:484 tests / 483 pass / 1 skipped;`npm run verify` BUILD OK。
12
+
5
13
  ## 0.24.0 — 作用域目录与用途元数据;自定义作用域原子初始化
6
14
 
7
15
  - **作用域元数据(`<storeDir>/scope-meta/<sha1(scope)>.json`)**:每个作用域可以带一句话用途,独立于记忆记录——删光记录、记录被 supersede / 过期都不会丢。旧作用域没有元数据时按「未填写用途」处理,不做迁移、不要求补齐。项目别名仍以 `scopes.json` 为准。
package/README.md CHANGED
@@ -265,7 +265,8 @@ memory_scopes({ action: "list", description: "看看有哪些作用域、各自
265
265
  ```js
266
266
  memory_scopes({
267
267
  action: "request",
268
- requests: [{ scope: "handbook", permissions: ["read"] }],
268
+ scopes: ["handbook"],
269
+ permissions: ["read"],
269
270
  reason: "需要团队约定与发布流程",
270
271
  description: "申请读取 handbook"
271
272
  })
@@ -1361,19 +1361,19 @@ export function memoryListTool(opts )
1361
1361
  }
1362
1362
  }
1363
1363
 
1364
-
1365
-
1366
-                    
1367
-
1368
-
1369
-
1370
1364
 
1371
1365
 
1372
1366
                     
1373
1367
 
1374
1368
 
1375
-                
1376
-
1369
+
1370
+              
1371
+                         
1372
+                      
1373
+
1374
+
1375
+                    
1376
+
1377
1377
                  
1378
1378
 
1379
1379
                       
@@ -1407,17 +1407,15 @@ export function memoryScopesTool(opts )
1407
1407
  action: { type: 'string', enum: ['list', 'request'], description: 'list = 目录;request = 申请范围外作用域的会话权限(默认只读)' },
1408
1408
  includeOutOfScope: { type: 'boolean', description: 'list:默认 true;false 时只列当前可见域内的作用域。' },
1409
1409
  limit: { type: 'number', description: 'list:1~200,默认 50' },
1410
- requests: {
1410
+ scopes: {
1411
1411
  type: 'array',
1412
- description: 'request:要申请的作用域与权限,最多 5 个 scope;permissions 省略 = 只读',
1413
- items: {
1414
- type: 'object',
1415
- properties: {
1416
- scope: { type: 'string' },
1417
- permissions: { type: 'array', items: { type: 'string', enum: ['read', 'write'] } },
1418
- },
1419
- required: ['scope'],
1420
- },
1412
+ items: { type: 'string' },
1413
+ description: 'request:要申请的作用域键,最多 5 个(一次申请多个时共用同一组 permissions)',
1414
+ },
1415
+ permissions: {
1416
+ type: 'array',
1417
+ items: { type: 'string', enum: ['read', 'write'] },
1418
+ description: 'request:申请哪些权限,省略 = 只读;写权限必须显式加 "write"',
1421
1419
  },
1422
1420
  reason: { type: 'string', description: 'request:一句话申请理由,展示在审批卡上' },
1423
1421
  description: { type: 'string', description: DESCRIPTION_PARAM_DESCRIPTION },
@@ -1431,21 +1429,20 @@ export function memoryScopesTool(opts )
1431
1429
  if (typeof service.requestScopeGrants !== 'function') {
1432
1430
  throw new MemoryToolError('SCOPES_UNAVAILABLE', '当前 provider 不支持作用域权限申请(请升级 @restregular/dsh-memory)')
1433
1431
  }
1434
- const raw = Array.isArray(args.requests) ? args.requests : []
1435
- if (raw.length === 0) {
1436
- throw new MemoryToolError('REQUESTS_REQUIRED', 'action="request" 需要 requests 数组(scope + 可选 permissions)')
1432
+ const scopes = Array.isArray(args.scopes)
1433
+ ? [...new Set(args.scopes.map((scope) => String(scope).trim()).filter((scope) => scope !== ''))]
1434
+ : []
1435
+ if (scopes.length === 0) {
1436
+ throw new MemoryToolError('REQUESTS_REQUIRED', 'action="request" 需要 scopes 数组(要申请的作用域键)')
1437
1437
  }
1438
- if (raw.length > 5) {
1438
+ if (scopes.length > 5) {
1439
1439
  throw new MemoryToolError('REQUESTS_TOO_MANY', '一次最多申请 5 个作用域;请分批申请')
1440
1440
  }
1441
- const requests = raw.map((item) => {
1442
- const scope = typeof item?.scope === 'string' ? item.scope.trim() : ''
1443
- if (scope === '') throw new MemoryToolError('SCOPE_INVALID', 'requests[].scope 不能为空')
1444
- const permissions = Array.isArray(item.permissions)
1445
- ? [...new Set(item.permissions.filter((permission) => permission === 'read' || permission === 'write'))]
1446
- : ['read' ]
1447
- return { scope, permissions: permissions.length > 0 ? permissions : ['read' ] }
1448
- })
1441
+ const permissions = Array.isArray(args.permissions)
1442
+ ? [...new Set(args.permissions.filter((permission) => permission === 'read' || permission === 'write'))]
1443
+ : ['read' ]
1444
+ const requested = permissions.length > 0 ? permissions : ['read' ]
1445
+ const requests = scopes.map((scope) => ({ scope, permissions: requested }))
1449
1446
  const reason = typeof args.reason === 'string' ? args.reason.trim() : ''
1450
1447
  try {
1451
1448
  const result = await service.requestScopeGrants(agent, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",