@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.
- package/CHANGELOG.md +16 -0
- package/README.md +614 -612
- package/lib/client.js +98 -8
- package/lib/inject/apply.js +119 -23
- package/lib/panel.js +59 -0
- package/lib/provider/apply.js +10 -0
- package/lib/provider/index.js +91 -2
- package/lib/tools/index.js +27 -30
- package/package.json +1 -1
package/lib/tools/index.js
CHANGED
|
@@ -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
|
-
|
|
1410
|
+
scopes: {
|
|
1411
1411
|
type: 'array',
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
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
|
|
1435
|
-
|
|
1436
|
-
|
|
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 (
|
|
1438
|
+
if (scopes.length > 5) {
|
|
1439
1439
|
throw new MemoryToolError('REQUESTS_TOO_MANY', '一次最多申请 5 个作用域;请分批申请')
|
|
1440
1440
|
}
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
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, {
|