mirror of
https://github.com/yexi-by/dsh-unrestricted.git
synced 2026-11-30 10:40:22 +08:00
修复:改用共享 /api Fetch 路由注册插件 RPC,兼容无 webServer 注入的 Connection(v0.2.11)
This commit is contained in:
1 parent
ae6c7663fe
commit
849fc35ac5
12 files changed
+266
-46
No files matched your search
+36
-1
@@ -70,7 +70,7 @@ const overrides = [
|
||||
{ id: 'web-runtime', disabled: true },
|
||||
{ id: 'session-telemetry-otel', disabled: true },
|
||||
{ id: 'modules', disabled: true },
|
||||
{ id: 'connection', inject: ['webServer'], config: { trustedHosts: [] } },
|
||||
{ id: 'connection', config: { trustedHosts: [] } },
|
||||
{ id: 'open-in-app', disabled: true },
|
||||
{ id: 'session-log-download', disabled: true },
|
||||
{ id: 'client-hmr', disabled: true },
|
||||
@@ -281,6 +281,41 @@ try {
|
||||
check('pre-existing standard session fused on next assembly', pre.text.includes(rules.EXECUTION_MODE_BLOCK))
|
||||
check('pre-existing session tools unchanged', pre.tools === baseline.standard.tools)
|
||||
|
||||
// Shared /api Fetch RPC routes: must register and respond without webServer in connection.inject.
|
||||
const shared = ctx.connection.createSharedFetchHandler('/api')
|
||||
const ownerPeer = { principal: { kind: 'owner' } }
|
||||
async function callSharedRpc(endpoint, payload = {}) {
|
||||
const rpcId = `verify-${endpoint}`
|
||||
const response = await shared.fetch(new Request(`http://dsh.internal/api/dsh-unrestricted/${endpoint}`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
type: 'client-request',
|
||||
rpcId,
|
||||
method: `dsh-unrestricted/${endpoint}`,
|
||||
payload,
|
||||
}),
|
||||
}), ownerPeer)
|
||||
return { status: response.status, body: await response.json() }
|
||||
}
|
||||
const rpcStatus = await callSharedRpc('status')
|
||||
check('shared /api status RPC returns 200 ok with current version',
|
||||
rpcStatus.status === 200
|
||||
&& rpcStatus.body?.result?.ok === true
|
||||
&& rpcStatus.body.result.value?.version === '0.2.11'
|
||||
&& rpcStatus.body.result.value?.enabled === true)
|
||||
const rpcPreview = await callSharedRpc('preview', { presetId: 'standard' })
|
||||
check('shared /api preview RPC returns 200 ok with fused prompt',
|
||||
rpcPreview.status === 200
|
||||
&& rpcPreview.body?.result?.ok === true
|
||||
&& rpcPreview.body.result.value?.available === true
|
||||
&& rpcPreview.body.result.value?.text?.includes(rules.EXECUTION_MODE_BLOCK))
|
||||
const rpcRecheck = await callSharedRpc('recheck')
|
||||
check('shared /api recheck RPC returns 200 ok',
|
||||
rpcRecheck.status === 200
|
||||
&& rpcRecheck.body?.result?.ok === true
|
||||
&& rpcRecheck.body.result.value?.enabled === true)
|
||||
|
||||
// Plan mode flips exactly one section.
|
||||
const planAgent = await presetAgent('standard', '-plan')
|
||||
planAgent.session.append('plan/mode', { active: true })
|
||||
|
||||
Reference in new issue
Block a user