Compare commits

...
1 Commits
12 changed files with 266 additions and 46 deletions

No files matched your search

+3 -10
View File
@@ -92,19 +92,12 @@ The toggle state is saved in the profile's `cordis.patch.yml` and takes effect o
## Installation & Updates
For Desktop `0.2.1-rc.5` or the official `dsh-v0.2.2-rc.3` tag, add these dependencies to the `connection` entry in the profile’s `cordis.patch.yml`, preserving any existing configuration.
```yaml
- id: connection
inject: [webStartup, webServer]
```
```sh
# Install on DSH Web
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11
# Install on DSH Desktop
dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11
```
Restart `dsh web` or DSH Desktop after installing, then follow [Usage](#usage) to enable it.
@@ -115,7 +108,7 @@ Use the update controls in DSH’s built-in plugin manager, or the CLI commands
```sh
dsh plugin --profile web remove dsh-unrestricted
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11
```
Restart `dsh web` or DSH Desktop.
+3 -10
View File
@@ -92,19 +92,12 @@ DSH のセクション名(`deployment:persona-prefix`、`plan:policy`、`tools
## インストールと更新
Desktop `0.2.1-rc.5` または公式タグ `dsh-v0.2.2-rc.3` を使う場合は、対象プロファイルの `cordis.patch.yml` にある `connection` 行の既存設定を保持し、次の依存関係を追加してください。
```yaml
- id: connection
inject: [webStartup, webServer]
```
```sh
# DSH Web へのインストール
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11
# DSH Desktop へのインストール
dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11
```
インストール後に `dsh web` または DSH Desktop を再起動し、下記の[使い方](#使い方)に従って有効化します。
@@ -115,7 +108,7 @@ dsh plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.10
```sh
dsh plugin --profile web remove dsh-unrestricted
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11
```
更新後に `dsh web` または DSH Desktop を再起動します。
+3 -10
View File
@@ -92,19 +92,12 @@ DSH 发起请求时会先组装全局系统提示词(System Prompt)。在普
## 安装与更新
使用 Desktop `0.2.1-rc.5` 或官方发布 tag `dsh-v0.2.2-rc.3` 时,请在对应 profile 的 `cordis.patch.yml` 给 `connection` 行补充以下依赖,已有配置保留在同一行。
```yaml
- id: connection
inject: [webStartup, webServer]
```
```sh
# Web 端安装指定版本
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11
# 桌面端安装指定版本(使用桌面端内置 CLI)
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.10
& "$env:LOCALAPPDATA\Programs\DeepSeek Harness\resources\runtime\cli\bin\dsh.cmd" plugin --profile desktop add github:yexi-by/dsh-unrestricted#v0.2.11
```
安装后重启 `dsh web` 或 DSH 桌面端,按下方[使用说明](#使用说明)启用。
@@ -115,7 +108,7 @@ dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
```sh
dsh plugin --profile web remove dsh-unrestricted
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.10
dsh plugin --profile web add github:yexi-by/dsh-unrestricted#v0.2.11
```
更新后重启 `dsh web` 或 DSH 桌面端。
+3 -2
View File
@@ -8,7 +8,8 @@ window.__ModuleLoader__.load({
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
let react_jsx_runtime = require("react/jsx-runtime");
//#region src/client/controller.ts
const RPC_CHANNEL = "/dsh-unrestricted";
const RPC_CHANNEL = "/api";
const RPC_NAMESPACE = "dsh-unrestricted";
const SETTINGS_NS = "unrestricted";
/** Human-readable error text for the banner. */
function messageOf(error) {
@@ -64,7 +65,7 @@ window.__ModuleLoader__.load({
};
}
async function call(endpoint, payload) {
const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload);
const result = await connection.rpc.call(RPC_CHANNEL, `${RPC_NAMESPACE}/${endpoint}`, payload);
if (!result.ok) throw new Error(result.error.message);
return result.value;
}
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"client.js","names":["useState","writeClipboard","Tag","Switch","Button","StateDot","fileSizeText"],"sources":["../src/client/controller.ts","../src/client/locales.ts","../src/client/styles.ts","../src/client/UnrestrictedCard.tsx","../src/client/index.tsx"],"sourcesContent":["/**\n * Browser-half controller for the unrestricted card: binds the `unrestricted`\n * settings namespace (the toggle) and reads per-preset state and previews.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: the ctx.remote Context merge and the forwarded-event key face.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.configForms Context merge.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n\n/** The toggle section stored in the `unrestricted` settings namespace. */\nexport interface UnrestrictedSettings {\n enabled?: boolean\n}\n\n/** Per-preset fusion state reported by the host half. */\nexport interface UnrestrictedModeState {\n state: 'off' | 'active' | 'failed'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n /** Current plugin version reported by the host half. */\n version?: string\n modes: Record<string, UnrestrictedModeState>\n}\n\n/** Deploy preview for one preset: what switching on would actually assemble. */\nexport interface UnrestrictedPreview {\n presetId: string\n available: boolean\n /** `live` = bytes a live agent received; `standing` = preset scope, no agent bound. */\n source?: 'live' | 'standing'\n /** Fused prompt text; present when available. */\n text?: string\n bytes?: number\n lines?: number\n /** Structured error code when unavailable. */\n errorCode?: string\n /** Diagnostic reason when unavailable. */\n reason?: string\n}\n\n/** One fetched preview, keyed by preset, plus its in-flight/error state. */\nexport interface UnrestrictedPreviewEntry {\n status: 'loading' | 'ready' | 'failed'\n preview?: UnrestrictedPreview\n errorCode?: string\n message?: string\n}\n\n/** Full view snapshot the card subscribes to. */\nexport interface UnrestrictedViewSnapshot {\n /** Persisted toggle; false until the settings scope first syncs. */\n enabled: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Settings scope sync state. */\n settingsStatus: 'loading' | 'ready' | 'unavailable'\n /** Live host status; null until the first RPC answer. */\n status: UnrestrictedStatus | null\n /** presetId -> fetched deploy preview. */\n previews: Record<string, UnrestrictedPreviewEntry>\n /** Whether a settings write or status refresh is in flight. */\n busy: boolean\n /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult<T> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\n\n/** Minimal observable contract consumed by the slot renderer's hook binding. */\nexport interface UnrestrictedViewSource {\n getSnapshot(): UnrestrictedViewSnapshot\n subscribe(listener: () => void): () => void\n}\n\n/** Inject face handed to the card at registration. */\nexport interface UnrestrictedCardInjected {\n hooks: {\n /** Reactive card view. */\n view: UnrestrictedViewSource\n }\n /** Persist the toggle. */\n setEnabled: (enabled: boolean) => Promise<void>\n /** Re-validate runtime state and refresh. */\n recheck: () => Promise<void>\n /** Re-read host status and invalidate cached previews. */\n refresh: () => Promise<void>\n /** Fetch the exact fused prompt this preset would deploy. */\n loadPreview: (presetId: string) => Promise<void>\n}\n\nconst RPC_CHANNEL = '/dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\n\n/** Human-readable error text for the banner. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * Create the card controller bound to the calling plugin's context.\n * @param ctx - the browser plugin context (connection + remote + configForms injected).\n * @returns the controller whose face() feeds the slot inject share.\n */\nexport function createUnrestrictedController(ctx: Context) {\n const connection = ctx.get('connection') as ConnectionHandle\n const settings = ctx.configForms.get<UnrestrictedSettings>(SETTINGS_NS)\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\n previews: {},\n busy: false,\n }\n const listeners = new Set<() => void>()\n const previewRequests = new Map<string, symbol>()\n let statusGeneration = 0\n let pendingOperations = 0\n\n const view: UnrestrictedViewSource = {\n getSnapshot: () => snapshot,\n subscribe: (listener) => {\n listeners.add(listenLine truncated
{"version":3,"file":"client.js","names":["useState","writeClipboard","Tag","Switch","Button","StateDot","fileSizeText"],"sources":["../src/client/controller.ts","../src/client/locales.ts","../src/client/styles.ts","../src/client/UnrestrictedCard.tsx","../src/client/index.tsx"],"sourcesContent":["/**\n * Browser-half controller for the unrestricted card: binds the `unrestricted`\n * settings namespace (the toggle) and reads per-preset state and previews.\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport type { ConnectionHandle } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: the ctx.remote Context merge and the forwarded-event key face.\nimport type {} from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: the ctx.configForms Context merge.\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n\n/** The toggle section stored in the `unrestricted` settings namespace. */\nexport interface UnrestrictedSettings {\n enabled?: boolean\n}\n\n/** Per-preset fusion state reported by the host half. */\nexport interface UnrestrictedModeState {\n state: 'off' | 'active' | 'failed'\n issues: string[]\n}\n\n/** Host status endpoint payload. */\nexport interface UnrestrictedStatus {\n enabled: boolean\n /** Current plugin version reported by the host half. */\n version?: string\n modes: Record<string, UnrestrictedModeState>\n}\n\n/** Deploy preview for one preset: what switching on would actually assemble. */\nexport interface UnrestrictedPreview {\n presetId: string\n available: boolean\n /** `live` = bytes a live agent received; `standing` = preset scope, no agent bound. */\n source?: 'live' | 'standing'\n /** Fused prompt text; present when available. */\n text?: string\n bytes?: number\n lines?: number\n /** Structured error code when unavailable. */\n errorCode?: string\n /** Diagnostic reason when unavailable. */\n reason?: string\n}\n\n/** One fetched preview, keyed by preset, plus its in-flight/error state. */\nexport interface UnrestrictedPreviewEntry {\n status: 'loading' | 'ready' | 'failed'\n preview?: UnrestrictedPreview\n errorCode?: string\n message?: string\n}\n\n/** Full view snapshot the card subscribes to. */\nexport interface UnrestrictedViewSnapshot {\n /** Persisted toggle; false until the settings scope first syncs. */\n enabled: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Settings scope sync state. */\n settingsStatus: 'loading' | 'ready' | 'unavailable'\n /** Live host status; null until the first RPC answer. */\n status: UnrestrictedStatus | null\n /** presetId -> fetched deploy preview. */\n previews: Record<string, UnrestrictedPreviewEntry>\n /** Whether a settings write or status refresh is in flight. */\n busy: boolean\n /** Last transport/business failure, if any. */\n message?: string\n}\n\n/** Minimal RPC wire shape (structural copy of the host RpcResult). */\ntype RpcResult<T> = { ok: true; value: T } | { ok: false; error: { code: string; message: string } }\n\n/** Minimal observable contract consumed by the slot renderer's hook binding. */\nexport interface UnrestrictedViewSource {\n getSnapshot(): UnrestrictedViewSnapshot\n subscribe(listener: () => void): () => void\n}\n\n/** Inject face handed to the card at registration. */\nexport interface UnrestrictedCardInjected {\n hooks: {\n /** Reactive card view. */\n view: UnrestrictedViewSource\n }\n /** Persist the toggle. */\n setEnabled: (enabled: boolean) => Promise<void>\n /** Re-validate runtime state and refresh. */\n recheck: () => Promise<void>\n /** Re-read host status and invalidate cached previews. */\n refresh: () => Promise<void>\n /** Fetch the exact fused prompt this preset would deploy. */\n loadPreview: (presetId: string) => Promise<void>\n}\n\nconst RPC_CHANNEL = '/api'\nconst RPC_NAMESPACE = 'dsh-unrestricted'\nconst SETTINGS_NS = 'unrestricted'\n\n/** Human-readable error text for the banner. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * Create the card controller bound to the calling plugin's context.\n * @param ctx - the browser plugin context (connection + remote + configForms injected).\n * @returns the controller whose face() feeds the slot inject share.\n */\nexport function createUnrestrictedController(ctx: Context) {\n const connection = ctx.get('connection') as ConnectionHandle\n const settings = ctx.configForms.get<UnrestrictedSettings>(SETTINGS_NS)\n\n let snapshot: UnrestrictedViewSnapshot = {\n enabled: false,\n writable: false,\n settingsStatus: 'loading',\n status: null,\n previews: {},\n busy: false,\n }\n const listeners = new Set<() => void>()\n const previewRequests = new Map<string, symbol>()\n let statusGeneration = 0\n let pendingOperations = 0\n\n const view: UnrestrictedViewSource = {\n getSnapshot: () => snapshot,\n subscribe: (listener) => Line truncated
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "dsh-unrestricted",
"version": "0.2.10",
"version": "0.2.11",
"engines": {
"dsh": ">=0.2.0-rc.2 <0.2.3-0"
},
+7 -2
View File
@@ -95,7 +95,8 @@ export interface UnrestrictedCardInjected {
loadPreview: (presetId: string) => Promise<void>
}
const RPC_CHANNEL = '/dsh-unrestricted'
const RPC_CHANNEL = '/api'
const RPC_NAMESPACE = 'dsh-unrestricted'
const SETTINGS_NS = 'unrestricted'
/** Human-readable error text for the banner. */
@@ -155,7 +156,11 @@ export function createUnrestrictedController(ctx: Context) {
}
async function call<T>(endpoint: string, payload: unknown): Promise<T> {
const result = await connection.rpc.call(RPC_CHANNEL, endpoint, payload) as RpcResult<T>
const result = await connection.rpc.call(
RPC_CHANNEL,
`${RPC_NAMESPACE}/${endpoint}`,
payload,
) as RpcResult<T>
if (!result.ok) throw new Error(result.error.message)
return result.value
}
+5 -8
View File
@@ -32,17 +32,17 @@ import {
fusedMinimalPrompt,
renderPreview,
} from './rules.js'
import { registerRpcRoutes } from './rpc.js'
/** Cordis plugin name used by Loader diagnostics. */
export const name = 'dsh-unrestricted'
/** Current plugin package version. */
export const PLUGIN_VERSION = '0.2.10'
export const PLUGIN_VERSION = '0.2.11'
/** Services required by this plugin (all base-backed profiles provide these). */
export const inject = ['settings', 'systemPrompt', 'loader']
const RPC_CHANNEL = '/dsh-unrestricted'
export const Config = z.object({
enabled: z.boolean().default(false),
}).default({ enabled: false }).volatile()
@@ -420,11 +420,8 @@ export function apply(ctx, config) {
}
}, 'dsh-unrestricted: toggle lifecycle')
// Web/Desktop 状态通道由官方 Connection 认证;headless 组合无需提供 connection 服务。
ctx.inject(['connection', 'webServer'], (connectionCtx) => {
const disposeRpc = connectionCtx.connection.rpc.handle(RPC_CHANNEL, handleRpc)
return async () => {
await disposeRpc()
}
// 挂载到 Connection 自有的 /api 共享通道下,无需依赖 connection 自身注入 webServer。
ctx.inject(['connection'], (connectionCtx) => {
return registerRpcRoutes(connectionCtx.connection, handleRpc)
})
}
+68
View File
@@ -0,0 +1,68 @@
/** Shared /api unary RPC namespace for dsh-unrestricted. */
export const RPC_NAMESPACE = 'dsh-unrestricted'
/** Endpoints exposed under `/api/dsh-unrestricted/<endpoint>`. */
export const RPC_ENDPOINTS = ['status', 'preview', 'recheck']
/**
* Build one buffered Fetch handler speaking the Connection RPC JSON envelope.
* @param endpoint - logical endpoint name within the plugin namespace.
* @param handleRpc - business handler returning an RpcResult object.
*/
export function createRpcFetchHandler(endpoint, handleRpc) {
const expectedMethod = `${RPC_NAMESPACE}/${endpoint}`
return async (request) => {
const mediaType = request.headers.get('content-type')?.split(';', 1)[0]?.trim().toLowerCase()
if (mediaType !== 'application/json') {
return new Response('content type must be application/json', { status: 415 })
}
let body
try {
body = await request.json()
} catch {
return new Response('body is not JSON', { status: 400 })
}
const rpcId = typeof body?.rpcId === 'string' ? body.rpcId : 'invalid-request'
if (body?.type !== 'client-request' || typeof body?.rpcId !== 'string' || body.method !== expectedMethod) {
return Response.json({
type: 'server-response',
rpcId,
result: {
ok: false,
error: {
code: 'gateway/bad-request',
message: `invalid client-request for ${JSON.stringify(expectedMethod)}`,
details: {},
},
},
})
}
try {
const result = await handleRpc(endpoint, body.payload)
return Response.json({ type: 'server-response', rpcId, result })
} catch (error) {
return new Response(`handler failure: ${error instanceof Error ? error.message : String(error)}`, { status: 500 })
}
}
}
/**
* Register all plugin endpoints as exact Fetch routes under `/api`, avoiding
* `connection.rpc.handle()` which requires `webServer` in Connection's own scope.
* @param connection - HostConnectionHandle from `ctx.connection`.
* @param handleRpc - business handler returning an RpcResult object.
* @returns asynchronous disposer removing every registered route.
*/
export function registerRpcRoutes(connection, handleRpc) {
const disposers = RPC_ENDPOINTS.map(endpoint =>
connection.fetch.register({
path: `/api/${RPC_NAMESPACE}/${endpoint}`,
methods: ['POST'],
requestBody: 'buffered',
fetch: createRpcFetchHandler(endpoint, handleRpc),
}),
)
return async () => {
await Promise.all(disposers.map(dispose => dispose()))
}
}
+9 -1
View File
@@ -28,7 +28,15 @@ async function fixture() {
set: (field, next) => defer('write', { field, next }),
}
const ctx = {
get: () => ({ rpc: { call: (_channel, endpoint, payload) => defer(endpoint, payload) } }),
get: () => ({
rpc: {
call: (channel, method, payload) => {
assert.equal(channel, '/api')
assert.match(method, /^dsh-unrestricted\//)
return defer(method.slice('dsh-unrestricted/'.length), payload)
},
},
}),
configForms: { get: () => settings },
remote: { $on(event, listener) { events.set(event, listener); return () => events.delete(event) } },
effect: effect => effect(),
+127
View File
@@ -0,0 +1,127 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { RPC_ENDPOINTS, RPC_NAMESPACE, registerRpcRoutes } from '../src/rpc.js'
function mockConnection() {
const routes = new Map()
return {
routes,
rpc: {
handle() {
throw new Error('cannot get property "webServer" without inject')
},
},
fetch: {
register(route) {
routes.set(route.path, route)
return async () => {
routes.delete(route.path)
}
},
},
}
}
test('经由 connection.fetch.register 注册共享 /api 路由,不触碰 rpc.handle 且支持正常调度与销毁', async () => {
const connection = mockConnection()
const calls = []
const dispose = registerRpcRoutes(connection, async (endpoint, payload) => {
calls.push({ endpoint, payload })
if (endpoint === 'boom') throw new Error('unexpected crash')
return { ok: true, value: { endpoint, echo: payload ?? null } }
})
assert.deepEqual(
[...connection.routes.keys()],
RPC_ENDPOINTS.map(endpoint => `/api/${RPC_NAMESPACE}/${endpoint}`),
)
for (const endpoint of RPC_ENDPOINTS) {
const route = connection.routes.get(`/api/${RPC_NAMESPACE}/${endpoint}`)
assert.deepEqual(route.methods, ['POST'])
assert.equal(route.requestBody, 'buffered')
const response = await route.fetch(new Request(`http://dsh.internal${route.path}`, {
method: 'POST',
headers: { 'content-type': 'application/json; charset=utf-8' },
body: JSON.stringify({
type: 'client-request',
rpcId: `rpc-${endpoint}`,
method: `${RPC_NAMESPACE}/${endpoint}`,
payload: { presetId: 'standard' },
}),
}))
assert.equal(response.status, 200)
assert.deepEqual(await response.json(), {
type: 'server-response',
rpcId: `rpc-${endpoint}`,
result: { ok: true, value: { endpoint, echo: { presetId: 'standard' } } },
})
}
assert.equal(calls.length, 3)
const statusRoute = connection.routes.get('/api/dsh-unrestricted/status')
const badType = await statusRoute.fetch(new Request('http://dsh.internal/api/dsh-unrestricted/status', {
method: 'POST',
headers: { 'content-type': 'text/plain' },
body: '{}',
}))
assert.equal(badType.status, 415)
const badJson = await statusRoute.fetch(new Request('http://dsh.internal/api/dsh-unrestricted/status', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: '{not-json',
}))
assert.equal(badJson.status, 400)
const wrongMethod = await statusRoute.fetch(new Request('http://dsh.internal/api/dsh-unrestricted/status', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
type: 'client-request',
rpcId: 'rpc-mismatch',
method: 'dsh-unrestricted/recheck',
payload: {},
}),
}))
assert.equal(wrongMethod.status, 200)
assert.deepEqual(await wrongMethod.json(), {
type: 'server-response',
rpcId: 'rpc-mismatch',
result: {
ok: false,
error: {
code: 'gateway/bad-request',
message: 'invalid client-request for "dsh-unrestricted/status"',
details: {},
},
},
})
await dispose()
assert.equal(connection.routes.size, 0)
})
test('handler 抛出异常时返回 500 而不崩溃', async () => {
const connection = mockConnection()
const dispose = registerRpcRoutes(connection, async () => {
throw new Error('handler exploded')
})
const route = connection.routes.get('/api/dsh-unrestricted/status')
const response = await route.fetch(new Request('http://dsh.internal/api/dsh-unrestricted/status', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
type: 'client-request',
rpcId: 'rpc-err',
method: 'dsh-unrestricted/status',
payload: {},
}),
}))
assert.equal(response.status, 500)
assert.equal(await response.text(), 'handler failure: handler exploded')
await dispose()
})
+36 -1
View File
@@ -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 })