chore: 合入 dev(0.2.3 基线适配)到统一组件分支
This commit is contained in:
commit
bf4e25db13
45 files changed
+1010
-976
No files matched your search
@@ -22,7 +22,7 @@
|
||||
* (#952). Outside the workspace any linked worktree is adopted, which is PR
|
||||
* #802's cross-repository case. The highest-scoring adoptable worktree of the
|
||||
* newest event that has one wins, but only evidence after the last committed
|
||||
* working-directory/change is eligible. With no such evidence the session cwd
|
||||
* workspace-root/change is eligible. With no such evidence the session cwd
|
||||
* itself is kept, a session living in a subdirectory of its repository
|
||||
* included: the repository top level is never a root on its own.
|
||||
*
|
||||
@@ -150,7 +150,7 @@ function directoryEpochOf(ctx: Context, sessionId: string): number | undefined {
|
||||
let epoch = previous?.epoch ?? -1
|
||||
for (let index = end - 1; index >= start; index -= 1) {
|
||||
const event = session.eventAt(index)
|
||||
if (event?.type !== 'working-directory/change') continue
|
||||
if (event?.type !== 'workspace-root/change') continue
|
||||
epoch = event.seq
|
||||
break
|
||||
}
|
||||
@@ -442,7 +442,7 @@ async function activeRootFromEvents(events: readonly SidebarSessionEvent[], base
|
||||
const event = events[index]
|
||||
// An explicit directory transition is the authority boundary. Older tool
|
||||
// paths belong to the previous execution context and must not override it.
|
||||
if (event?.type === 'working-directory/change') break
|
||||
if (event?.type === 'workspace-root/change') break
|
||||
if (event === undefined || event.type !== 'tool/call') continue
|
||||
const weights = new Map<string, ActivePathEntry>()
|
||||
collectActivePaths(event.data, weights, false)
|
||||
|
||||
@@ -138,6 +138,7 @@ export function createBundleRouteHandler(
|
||||
/** Register the /sidebar/bundle route (disposed with the fiber). */
|
||||
export function registerBundleRoute(ctx: Context, fence: (req: SidebarHttpRequest) => boolean): () => void {
|
||||
return ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'prefix',
|
||||
path: '/sidebar/bundle',
|
||||
handler: createBundleRouteHandler(fence),
|
||||
|
||||
@@ -1,15 +1,10 @@
|
||||
/**
|
||||
* Anchor selectors for the DSH AppFrame conversation slot host, newest first:
|
||||
*
|
||||
* - DSH 0.1.5-alpha.2 replaced the root `conversation` slot with a root-scoped
|
||||
* keyed `main` slot, so the conversation renders under `main.conversation`
|
||||
* (ConversationPanel -> `renderSlot('main.conversation')`);
|
||||
* - alpha.1 and earlier spell the same host `conversation`.
|
||||
*
|
||||
* Both keys are accepted deliberately so one build spans the alpha.1 → alpha.2
|
||||
* boundary; only one exists in any given host.
|
||||
* Anchor selector for the DSH AppFrame conversation slot host: the conversation
|
||||
* renders under the root-scoped keyed `main` slot (ConversationPanel ->
|
||||
* `renderSlot('main.conversation')`), which the slot host marks with
|
||||
* `data-slot="main.conversation"`.
|
||||
*/
|
||||
const CENTER_COLUMN_SELECTOR = '#root [data-slot="main.conversation"], #root [data-slot="conversation"]'
|
||||
const CENTER_COLUMN_SELECTOR = '#root [data-slot="main.conversation"]'
|
||||
|
||||
/** Match Sidebar's existing last-resort retry cadence (issue #248). */
|
||||
export const CENTER_COLUMN_REVALIDATE_MS = 1500
|
||||
|
||||
@@ -14,6 +14,16 @@
|
||||
font: var(--dsw-font-xxs-12);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
}
|
||||
/* A bleed footer owns the window's bottom edge. The root's own bottom inset
|
||||
would otherwise sit above the footer's 12px padding, leaving 26px inside the
|
||||
2px floating edge instead of the intended 14px: the negative bottom margin of
|
||||
`.actionFooterBleed` cannot pull the footer past the content box once the
|
||||
flexing `.content` consumes every pixel, so the inset is cancelled here. */
|
||||
.root:has(> [data-clue-pack-footer]),
|
||||
.root:has(> [data-clue-pack-add-footer]) {
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
|
||||
@@ -1072,7 +1072,7 @@ export function matchUrlTarget(tabs: readonly TabDescriptor[], url: URL): TabDes
|
||||
* The plugin version this service instance reports. Keep in lockstep with
|
||||
* `package.json`'s version — `tests/service.spec.ts` asserts the pair.
|
||||
*/
|
||||
export const SIDEBAR_SERVICE_VERSION = '0.33.0'
|
||||
export const SIDEBAR_SERVICE_VERSION = '0.34.0-alpha.0'
|
||||
|
||||
/**
|
||||
* Monotonic capability list consumers use to gate new API usage (features
|
||||
|
||||
@@ -69,9 +69,8 @@ export function useCenterColumn(
|
||||
useEffect(() => {
|
||||
let disposed = false
|
||||
let observer: ResizeObserver | undefined
|
||||
// Locate the AppFrame's center column. DSH 0.1.x wraps slot hosts in
|
||||
// [data-slot] containers: the conversation slot host (key
|
||||
// `main.conversation` on 0.1.5-alpha.2+, `conversation` on alpha.1)
|
||||
// Locate the AppFrame's center column. The host wraps slot hosts in
|
||||
// [data-slot] containers: the conversation slot host (`main.conversation`)
|
||||
// sits inside the center column behind transparent `display: contents`
|
||||
// slot hosts, so the resolver walks up to the first ancestor that
|
||||
// renders a box — no hashed-class or positional dependency
|
||||
|
||||
@@ -33,6 +33,7 @@ function admitted(req: SidebarHttpRequest, port: number | undefined): boolean {
|
||||
export function createClueAgentDraftRoute(deps: ClueAgentDraftDeps): SidebarWebRoute {
|
||||
return {
|
||||
kind: 'exact', path: CLUE_AGENT_COMMIT_ROUTE_PATH,
|
||||
auth: 'anonymous',
|
||||
async handler(req, res) {
|
||||
// Admission is deliberately before body iteration and draft lookup.
|
||||
if (req.method !== 'POST') { reject(res, 405); return }
|
||||
|
||||
@@ -380,7 +380,7 @@ export function createClueAgentReadRoute(deps: ClueAgentReadDeps): SidebarWebRou
|
||||
}
|
||||
}
|
||||
}
|
||||
return { kind: 'exact', path: CLUE_AGENT_READ_ROUTE_PATH, handler }
|
||||
return { kind: 'exact', path: CLUE_AGENT_READ_ROUTE_PATH, auth: 'anonymous', handler }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -690,29 +690,27 @@ export function installClueInjection(
|
||||
* `getOrigin()` is the host's own public composition fact.
|
||||
*/
|
||||
const readerOriginOf = (): string | undefined => {
|
||||
let webServer: { readonly port?: unknown; getOrigin?(): string } | undefined
|
||||
let webServer: { readonly port?: unknown; getOrigin(): string } | undefined
|
||||
try {
|
||||
const value = injectionCtx.get?.('webServer')
|
||||
if (value !== null && typeof value === 'object') {
|
||||
webServer = value as { readonly port?: unknown; getOrigin?(): string }
|
||||
webServer = value as { readonly port?: unknown; getOrigin(): string }
|
||||
}
|
||||
} catch {
|
||||
webServer = undefined
|
||||
}
|
||||
if (webServer === undefined) return undefined
|
||||
if (typeof webServer.getOrigin === 'function') {
|
||||
try {
|
||||
const origin = webServer.getOrigin()
|
||||
if (typeof origin === 'string' && origin !== '') {
|
||||
const trimmed = origin.replace(/\/+$/u, '')
|
||||
// The route admits loopback peers only. Never emit a command aimed
|
||||
// at a non-loopback bind address (it would be refused by design).
|
||||
const hostname = new URL(trimmed).hostname
|
||||
if (hostname === 'localhost' || isLoopbackAddress(hostname)) return trimmed
|
||||
}
|
||||
} catch {
|
||||
// Throws before the listener is bound; fall back to the port if known.
|
||||
try {
|
||||
const origin = webServer.getOrigin()
|
||||
if (typeof origin === 'string' && origin !== '') {
|
||||
const trimmed = origin.replace(/\/+$/u, '')
|
||||
// The route admits loopback peers only. Never emit a command aimed
|
||||
// at a non-loopback bind address (it would be refused by design).
|
||||
const hostname = new URL(trimmed).hostname
|
||||
if (hostname === 'localhost' || isLoopbackAddress(hostname)) return trimmed
|
||||
}
|
||||
} catch {
|
||||
// Throws before the listener is bound; fall back to the port if known.
|
||||
}
|
||||
const port = webServer.port
|
||||
return typeof port === 'number' && Number.isSafeInteger(port) && port > 0
|
||||
|
||||
@@ -177,7 +177,7 @@ export function installClueStack(ctx: Context, options: InstallClueStackOptions)
|
||||
const routes = createCluesShareRoutes(share, options.fence)
|
||||
const disposers: Array<() => void> = []
|
||||
try {
|
||||
for (const route of routes.routes) disposers.push(ctx.webServer.register(route))
|
||||
for (const route of routes.routes) disposers.push(ctx.webServer.register({ ...route, auth: 'anonymous' }))
|
||||
} catch (error) {
|
||||
for (const dispose of disposers.splice(0).reverse()) dispose()
|
||||
throw error
|
||||
|
||||
@@ -90,12 +90,17 @@ export type SidebarUpgradeHead = Uint8Array
|
||||
export interface SidebarWebRoute {
|
||||
kind: 'exact' | 'prefix'
|
||||
path: string
|
||||
/** Host admission policy; DSH 0.2.3 defaults to `required`, so every route
|
||||
* that enforces admission itself declares `anonymous` and keeps its fence. */
|
||||
auth?: 'anonymous' | 'required' | 'deny'
|
||||
handler: (req: SidebarHttpRequest, res: SidebarHttpResponse) => void | Promise<void>
|
||||
}
|
||||
|
||||
/** One exact-path HTTP upgrade registration (mirror of WebUpgradeRoute). */
|
||||
export interface SidebarWebUpgradeRoute {
|
||||
path: string
|
||||
/** See {@link SidebarWebRoute.auth}: the upgrade handler fences itself. */
|
||||
auth?: 'anonymous' | 'required' | 'deny'
|
||||
handler: (req: SidebarHttpRequest, socket: SidebarUpgradeSocket, head: SidebarUpgradeHead) => void | Promise<void>
|
||||
}
|
||||
|
||||
@@ -139,12 +144,10 @@ export interface SidebarSessionStore {
|
||||
* Host request admission plus the client transport recovery face.
|
||||
*/
|
||||
export interface SidebarConnectionService {
|
||||
/** Public Host/Origin and authentication policy (DSH 0.2.0-rc.2+). Deprecated
|
||||
* after 0.2.2-rc.3 and removed on DSH master — `admit` is the replacement. */
|
||||
requestRejection?(request: { headers: Record<string, string | string[] | undefined> }): 401 | 403 | undefined
|
||||
/** Host admission (DSH 0.2.2-rc.3+, the method `requestRejection` delegated to).
|
||||
* Returns an object carrying `rejection` when the request is refused. */
|
||||
admit?(request: { headers: Record<string, string | string[] | undefined> }): unknown
|
||||
/** Host admission (DSH 0.2.3+): verifies Host/Origin and browser credentials
|
||||
* through the injected `connection.authentication` verifier and returns an
|
||||
* object carrying `rejection` when the request is refused. */
|
||||
admit(request: { headers: Record<string, string | string[] | undefined> }): unknown
|
||||
state: {
|
||||
getSnapshot(): 'connected' | 'disconnected' | 'connecting' | undefined
|
||||
subscribe(listener: () => void): () => void
|
||||
|
||||
+8
-1
@@ -218,7 +218,14 @@ export async function searchFilesPlain(root: string, query: string, opts: FsSear
|
||||
return undefined
|
||||
})
|
||||
if (level === undefined) return
|
||||
for await (const dirent of level) {
|
||||
// Iterate in name order: `maxMatches` truncates the walk, so the page a
|
||||
// caller sees must not depend on the filesystem's readdir order (Linux
|
||||
// hashes directory entries; macOS returns creation order). The sorted
|
||||
// match list alone does not help once the walk stopped early.
|
||||
const entries: Dirent[] = []
|
||||
for await (const dirent of level) entries.push(dirent)
|
||||
entries.sort((left, right) => (left.name < right.name ? -1 : left.name > right.name ? 1 : 0))
|
||||
for (const dirent of entries) {
|
||||
visited += 1
|
||||
if (visited > maxVisited) {
|
||||
truncated = true
|
||||
|
||||
+21
-21
@@ -1261,34 +1261,24 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
const resolved = resolveSidebarConfig(config)
|
||||
// Connection owns both deployment trust and authentication; never infer or
|
||||
// bypass its policy from invocation flags or a copied trust list.
|
||||
// DSH 0.2.2-rc.3 deprecated `requestRejection` and DSH 0.2.3 removed it, leaving
|
||||
// `admit` (the method the old wrapper delegated to) as the only admission call.
|
||||
// From 0.2.3 `admit` also delegates the credential check to the verifier
|
||||
// registered under the NESTED `connection.authentication` service, and cordis
|
||||
// refuses that read unless the caller declares the dependency. Hosts at
|
||||
// rc.2–rc.5 have no such service (their `admit` verifies in place), so the
|
||||
// dependency lives in a child fiber: where the service never appears the
|
||||
// callback never runs and admission keeps using the host's own method. Never
|
||||
// rebuild a trust list here: when no admission path is available the request
|
||||
// fails loudly.
|
||||
// DSH 0.2.3 deleted `requestRejection`; `admit` is the only admission call and
|
||||
// it verifies credentials with the verifier registered under the NESTED
|
||||
// `connection.authentication` service. Cordis refuses that read unless the
|
||||
// caller declares the dependency, so admission lives in the injected child
|
||||
// fiber — the only path this build supports. Never rebuild a trust list here:
|
||||
// without the provider the request fails loudly.
|
||||
/** `admit` refuses by carrying `rejection`; nothing else counts as a refusal. */
|
||||
const admitted = (verdict: unknown): boolean =>
|
||||
!(verdict !== null && typeof verdict === 'object' && 'rejection' in verdict)
|
||||
let admitThroughProvider: ((req: SidebarHttpRequest) => boolean) | undefined
|
||||
let admit: ((req: SidebarHttpRequest) => boolean) | undefined
|
||||
ctx.inject(['connection.authentication'], (providerCtx) => {
|
||||
const connection = (providerCtx as Context).connection
|
||||
const admit = connection.admit
|
||||
if (typeof admit !== 'function') return
|
||||
admitThroughProvider = (req) => admitted(admit.call(connection, req))
|
||||
const call = connection.admit
|
||||
admit = (req) => admitted(call.call(connection, req))
|
||||
})
|
||||
const fence = (req: SidebarHttpRequest): boolean => {
|
||||
const connection = ctx.connection
|
||||
const requestRejection = connection.requestRejection
|
||||
if (typeof requestRejection === 'function') return requestRejection.call(connection, req) === undefined
|
||||
if (admitThroughProvider !== undefined) return admitThroughProvider(req)
|
||||
const admit = connection.admit
|
||||
if (typeof admit === 'function') return admitted(admit.call(connection, req))
|
||||
throw new TypeError('connection exposes neither requestRejection nor admit')
|
||||
if (admit !== undefined) return admit(req)
|
||||
throw new TypeError('connection admission requires the injected authentication provider')
|
||||
}
|
||||
// The clue stack's context injection reads the live Side card preferences
|
||||
// (source switches). The settings face is filled by the `ctx.inject` below,
|
||||
@@ -1526,6 +1516,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
},
|
||||
})
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'prefix',
|
||||
path: '/sidebar/api',
|
||||
handler: async (req, res) => {
|
||||
@@ -1619,6 +1610,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
}), 'dsh-better-sidebar: /sidebar/api routes')
|
||||
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'exact',
|
||||
path: '/sidebar/sidechat-image',
|
||||
handler: async (req, res) => {
|
||||
@@ -1644,6 +1636,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
// failed or oversized upload never leaves a partial file (see
|
||||
// fs-operations.ts for the containment and shape rules).
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'exact',
|
||||
path: '/sidebar/upload',
|
||||
handler: async (req, res) => {
|
||||
@@ -1682,6 +1675,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
// envelope no longer caps what an editor can write back. The encoding and
|
||||
// line-ending round-trip lives in writeWorkspaceText, unchanged.
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'exact',
|
||||
path: '/sidebar/write',
|
||||
handler: async (req, res) => {
|
||||
@@ -1735,6 +1729,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
// file once, with the RFC 5987 disposition. `archiveTasks` owns the
|
||||
// concurrency cap, the TTL, and deleting the temp file.
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'exact',
|
||||
path: '/sidebar/archive',
|
||||
handler: async (req, res) => {
|
||||
@@ -1760,6 +1755,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
|
||||
// ── Media route (images for the editor) ─────────────────────────────────
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'prefix',
|
||||
path: '/sidebar/file',
|
||||
handler: async (req, res) => {
|
||||
@@ -1851,6 +1847,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
// the URL (e.g. a popup opened by a previewed page) stays in an opaque
|
||||
// origin with no same-origin access to the GUI.
|
||||
ctx.effect(() => ctx.webServer.register({
|
||||
auth: 'anonymous',
|
||||
kind: 'prefix',
|
||||
path: '/sidebar/html',
|
||||
handler: async (req, res) => {
|
||||
@@ -1910,6 +1907,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
// editor / folder-window / browser tab open.
|
||||
const agentOpenWss = new WebSocketServer({ noServer: true })
|
||||
ctx.effect(() => ctx.webServer.registerUpgrade({
|
||||
auth: 'anonymous',
|
||||
path: '/sidebar/ws/agent-opens',
|
||||
handler: (req, socket, head) => {
|
||||
if (!fence(req)) {
|
||||
@@ -1931,6 +1929,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
// lexical rules), so the watch observes what the tree can list.
|
||||
const fsWatchWss = new WebSocketServer({ noServer: true })
|
||||
ctx.effect(() => ctx.webServer.registerUpgrade({
|
||||
auth: 'anonymous',
|
||||
path: '/sidebar/ws/fs-watch',
|
||||
handler: (req, socket, head) => {
|
||||
if (!fence(req)) {
|
||||
@@ -1953,6 +1952,7 @@ export function apply(ctx: Context, config?: SidebarConfig): void {
|
||||
const sidechatPush = createSidechatPushHub(ctx)
|
||||
ctx.effect(() => () => { sidechatPush.dispose() }, 'dsh-better-sidebar: side-chat push hub')
|
||||
ctx.effect(() => ctx.webServer.registerUpgrade({
|
||||
auth: 'anonymous',
|
||||
path: '/sidebar/ws/sidechat',
|
||||
handler: (req, socket, head) => {
|
||||
if (!fence(req)) {
|
||||
|
||||
@@ -25,7 +25,7 @@ import type { ImageAttachmentRef, StoredImageAttachment } from '@deepseek-ai/dsh
|
||||
import { parseSidechatPrompt, sidechatAdmissionError, sidechatAttachments, sidechatImageLimits } from './sidechat-image-admission.ts'
|
||||
import { randomUUID } from 'node:crypto'
|
||||
import { createUserMessage, ReasoningEffortId, type ContentBlock, type UserMessage } from '@deepseek-ai/dsh-llm'
|
||||
import type { MessageId } from '@deepseek-ai/dsh-llm/brand'
|
||||
import type { MessageId } from '@deepseek-ai/dsh-llm/types'
|
||||
import {
|
||||
installModelSelection,
|
||||
type Agent,
|
||||
@@ -769,12 +769,14 @@ export function buildSidechatApi(
|
||||
})
|
||||
// A truncated inheritance can end before the parent's last directory
|
||||
// change. Header cwd alone cannot win: the host projection replays seed
|
||||
// working-directory/change events over it. Stamp the committed directory
|
||||
// workspace-root/change events over it. Stamp the committed directory
|
||||
// (the parent's LIVE cwd) at the seed boundary, using the host-owned event
|
||||
// rather than refolding its history or asking set() to enqueue a
|
||||
// synthetic user notice.
|
||||
// synthetic user notice. DSH 0.2.3-alpha.2 moved the projection authority
|
||||
// from `working-directory/change` (model-era log) to `workspace-root/change`
|
||||
// (host-committed move); only the latter is applied by the unit now.
|
||||
const directorySeed: SeedEvent[] = workingDirectory === undefined ? [] : [{
|
||||
type: 'working-directory/change',
|
||||
type: 'workspace-root/change',
|
||||
seq: inheritance.seed.length,
|
||||
time: Date.now(),
|
||||
data: { cwd: stampCwd },
|
||||
|
||||
Reference in new issue
Block a user