@restregular/dsh-memory 0.24.0 → 0.25.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.
@@ -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.25.0",
4
4
  "description": "DeepSeek Harness 记忆系统(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 五个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",