mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 09:50:22 +08:00
fix: 发布 1.1.44,提示词按模式注入并让子代理吃到同一份。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b47ebfb976
commit
2ecce304db
10 files changed
+816
-221
No files matched your search
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
import { existsSync, readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { isRedteamSession } from '../identity.js'
|
||||
import { redteamRoot } from './platform-config.js'
|
||||
|
||||
const ROLE_TAG = /^[ \t]*redteamRole:[ \t]*(recon|assess|vuln-scan|exploit|internal)[ \t]*$/im
|
||||
@@ -33,15 +34,16 @@ function remember(agent, role) {
|
||||
for (const id of ids) roleBySession.set(String(id), role)
|
||||
}
|
||||
|
||||
function isRedteamChild(session) {
|
||||
function isRedteamChild(session, agent) {
|
||||
const header = session?.header
|
||||
return header?.origin === 'subagent' && header?.agentPreset === 'redteam'
|
||||
if (header?.origin !== 'subagent' && !((header?.delegationDepth ?? 0) > 0)) return false
|
||||
return isRedteamSession({ session, agent: agent ? { ...agent, session } : { session } })
|
||||
}
|
||||
|
||||
export function noteClaimedMessage(payload) {
|
||||
const agent = payload?.agent
|
||||
const session = agent?.session
|
||||
if (!isRedteamChild(session)) return
|
||||
if (!isRedteamChild(session, agent)) return
|
||||
const role = parseRedteamRole(textOfMessage(payload?.message))
|
||||
if (!role) return
|
||||
remember(agent, role)
|
||||
@@ -99,9 +101,9 @@ function readRoleFile(engagementId, role) {
|
||||
|
||||
export function resolveSubagentRoleText(context) {
|
||||
try {
|
||||
const session = context?.agent?.session || context?.session
|
||||
if (!isRedteamChild(session)) return ''
|
||||
const agent = context?.agent
|
||||
const session = agent?.session || context?.session
|
||||
if (!isRedteamChild(session, agent)) return ''
|
||||
const sessionId = session?.id ?? agent?.id
|
||||
let role = sessionId !== undefined && sessionId !== null
|
||||
? roleBySession.get(String(sessionId)) || ''
|
||||
|
||||
Reference in new issue
Block a user