Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(desktop-app): open gfs:// links from a plugin in the Desktop viewer
Andy Pavia3559031b62e2
diff --git a/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts b/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.tsindex 86fbc18f1..e1177ec8b 100644--- a/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts+++ b/desktop-app/src/__tests__/appService.sandboxUiOauthConsent.test.ts@@ -20,7 +20,9 @@ const mocks = vi.hoisted(() => ({requestSandboxUiOauthAuthorizeUrl: vi.fn(),getOrIssue: vi.fn(),rpcTokenManagerClear: vi.fn(),- rpcTokenManagerGetMetadata: vi.fn().mockReturnValue({ expiresAtMs: null, scopes: [], hostRefs: [] }),+ rpcTokenManagerGetMetadata: vi+ .fn()+ .mockReturnValue({ expiresAtMs: null, scopes: [], hostRefs: [] }),}))vi.mock('electron', () => ({@@ -119,7 +121,11 @@ describe('AppService.requestSandboxUiOauthAuthorize', () => {await svc.requestSandboxUiOauthAuthorize(RECIPE_NS, RECIPE_NAME, CLIENT_ID, true)expect(mocks.requestSandboxUiOauthAuthorizeUrl).toHaveBeenCalledWith(- 'rpc-token', RECIPE_NS, RECIPE_NAME, CLIENT_ID, true+ 'rpc-token',+ RECIPE_NS,+ RECIPE_NAME,+ CLIENT_ID,+ true)expect(mocks.showMessageBox).toHaveBeenCalledOnce()expect(mocks.openExternal).toHaveBeenCalledWith(AUTHORIZE_URL)@@ -146,7 +152,11 @@ describe('AppService.requestSandboxUiOauthAuthorize', () => {expect(mocks.showMessageBox).not.toHaveBeenCalled()expect(mocks.requestSandboxUiOauthAuthorizeUrl).toHaveBeenCalledWith(- 'rpc-token', RECIPE_NS, RECIPE_NAME, CLIENT_ID, false+ 'rpc-token',+ RECIPE_NS,+ RECIPE_NAME,+ CLIENT_ID,+ false)expect(mocks.openExternal).toHaveBeenCalledWith(AUTHORIZE_URL)})@@ -166,7 +176,11 @@ describe('AppService.requestSandboxUiOauthAuthorize', () => {expect(mocks.rpcTokenManagerClear).toHaveBeenCalledOnce()expect(mocks.requestSandboxUiOauthAuthorizeUrl).toHaveBeenCalledTimes(2)expect(mocks.requestSandboxUiOauthAuthorizeUrl).toHaveBeenLastCalledWith(- 'rpc-token-new', RECIPE_NS, RECIPE_NAME, CLIENT_ID, true+ 'rpc-token-new',+ RECIPE_NS,+ RECIPE_NAME,+ CLIENT_ID,+ true)expect(mocks.openExternal).toHaveBeenCalledWith(AUTHORIZE_URL)})diff --git a/desktop-app/src/__tests__/pluginSdkBroker.test.ts b/desktop-app/src/__tests__/pluginSdkBroker.test.tsindex 1fc8d1cd4..ccf497c2e 100644--- a/desktop-app/src/__tests__/pluginSdkBroker.test.ts+++ b/desktop-app/src/__tests__/pluginSdkBroker.test.ts@@ -74,6 +74,7 @@ function fakeSource(overrides: Partial<PluginSdkDataSource> = {}): PluginSdkDatathrow new Error('not stubbed')},getPluginTheme: () => 'dark',+ openGfsResource: async () => ({ opened: true }),showPluginNotification: async () => ({ delivered: true }),...overrides,}diff --git a/desktop-app/src/__tests__/pluginSdkCapabilities.test.ts b/desktop-app/src/__tests__/pluginSdkCapabilities.test.tsindex 5f1fb0628..cbd6ad250 100644--- a/desktop-app/src/__tests__/pluginSdkCapabilities.test.ts+++ b/desktop-app/src/__tests__/pluginSdkCapabilities.test.ts@@ -72,6 +72,7 @@ function source(overrides: Partial<PluginSdkDataSource> = {}): PluginSdkDataSourbytes: PNG.buffer.slice(PNG.byteOffset, PNG.byteOffset + PNG.byteLength) as ArrayBuffer,}),getPluginTheme: () => 'light',+ openGfsResource: async () => ({ opened: true }),showPluginNotification: async () => ({ delivered: true }),...overrides,}@@ -103,12 +104,15 @@ describe('capability catalog invariants', () => {}})- it('marks only theme.read as consent-free', () => {+ it('keeps the consent-free set to exactly the two justified capabilities', () => {const unscoped = Object.values(CAPABILITIES).filter(descriptor => !descriptor.requiresConsent).map(descriptor => descriptor.id)+ .sort()// Any addition here is a decision to hand a plugin something without asking.- expect(unscoped).toEqual(['theme.read'])+ // `theme.read` returns nothing about the user; `gfs.open` returns only+ // whether a viewer opened, and the action itself is unmissable on screen.+ expect(unscoped).toEqual(['gfs.open', 'theme.read'])})it('sorts prompt rows most-sensitive-first', () => {@@ -286,3 +290,24 @@ describe('notifications.notify', () => {expect(seen.pluginTitle).toBe('Plugin')})})++describe('gfs.open', () => {+ it('returns only whether a viewer opened, never anything about the file', async () => {+ const result = await run('gfs.open', { uri: 'gfs://main/a.png' })+ // The plugin must not learn the name, size, or contents from an open call.+ expect(result).toEqual({ opened: true })+ })++ it('rejects a non-gfs uri and unexpected params', () => {+ const descriptor = getCapability('gfs.open')+ expect(() => descriptor?.validate({ uri: 'https://evil.example/x' })).toThrow()+ expect(() => descriptor?.validate({ uri: 'gfs://main/a', as: 'dataUrl' })).toThrow()+ expect(() => descriptor?.validate({})).toThrow()+ })++ it('is budgeted more tightly than the reads, because it paints over the user', () => {+ const open = getCapability('gfs.open')+ const read = getCapability('gfs.read')+ expect(open?.limits.perMinute).toBeLessThan(read?.limits.perMinute ?? 0)+ })+})diff --git a/desktop-app/src/__tests__/pluginSdkSurface.test.ts b/desktop-app/src/__tests__/pluginSdkSurface.test.tsindex 3a9879cd8..f0d7faa15 100644--- a/desktop-app/src/__tests__/pluginSdkSurface.test.ts+++ b/desktop-app/src/__tests__/pluginSdkSurface.test.ts@@ -20,6 +20,7 @@ import {unpinPluginSurface,unpinPluginSurfacesOfKind,} from '../pluginSurfaceRegistry.js'+import { classifyEmbedNavigation } from '../sandboxUiPartitionPolicies.js'// `import.meta` is unavailable in this CommonJS build; resolve from cwd, which// vitest sets to the desktop-app package root.@@ -154,3 +155,29 @@ describe('embed preload contract', () => {}})})++describe('gfs:// links from an embed', () => {+ const PREFIX = 'https://proxy.example/api/v1/sandbox-ui/ns/plugin/view'++ it('classifies a gfs link as an open request instead of dropping it', () => {+ expect(classifyEmbedNavigation('gfs://main/reports/q3.png', PREFIX)).toEqual({+ kind: 'gfs_open',+ uri: 'gfs://main/reports/q3.png',+ })+ })++ it('still drops every other non-http scheme', () => {+ for (const url of ['file:///etc/passwd', 'data:text/html,<h1>x', 'javascript:alert(1)']) {+ expect(classifyEmbedNavigation(url, PREFIX).kind, url).toBe('drop')+ }+ })++ it('drops an absurdly long gfs uri rather than forwarding it', () => {+ expect(classifyEmbedNavigation(`gfs://main/${'a'.repeat(4096)}`, PREFIX).kind).toBe('drop')+ })++ it('leaves in-app navigation and external links alone', () => {+ expect(classifyEmbedNavigation(`${PREFIX}/dashboard`, PREFIX).kind).toBe('allow')+ expect(classifyEmbedNavigation('https://example.com', PREFIX).kind).toBe('external')+ })+})diff --git a/desktop-app/src/appService.ts b/desktop-app/src/appService.tsindex c93b2f955..d505c298e 100644--- a/desktop-app/src/appService.ts+++ b/desktop-app/src/appService.ts@@ -2986,6 +2986,12 @@ export class AppService {tryGetPluginSdkRuntime()?.unpinAllSandboxUiSurfaces()args.onClosed?.()},+ onGfsOpen: uri => {+ const active = tryGetPluginSdkRuntime()+ const surface = driver.getActiveSandboxUi()+ if (!active || !surface) return+ void active.openGfsResourceFromNavigation(surface.webContentsId, uri)+ },onOauthAuthorize: (oauthClientId, background) => {void this.requestSandboxUiOauthAuthorize(recipeNs,diff --git a/desktop-app/src/pluginSdkCapabilities.ts b/desktop-app/src/pluginSdkCapabilities.tsindex 22cd1dc13..603c94b43 100644--- a/desktop-app/src/pluginSdkCapabilities.ts+++ b/desktop-app/src/pluginSdkCapabilities.ts@@ -86,6 +86,7 @@ export interface PluginSdkDataSource {listGfsChildren(resourceId: string, drive?: string, cursor?: string): Promise<GfsChildrenPage>downloadGfsUri(uri: string): Promise<{ resource: ResolvedGfsResource; bytes: ArrayBuffer }>getPluginTheme(): PluginTheme+ openGfsResource(input: { uri: string }): Promise<{ opened: boolean; reason?: string }>showPluginNotification(input: {pluginId: stringpluginTitle: string@@ -405,6 +406,37 @@ export const CAPABILITIES: Record<string, CapabilityDescriptor> = {},},+ 'gfs.open': {+ id: 'gfs.open',+ descriptorVersion: 1,+ // Unscoped, and the second capability to qualify. The rule from §6.7 is that+ // `requiresConsent: false` needs the response to carry nothing about the+ // user; this one adds the other half: the ACTION must be unmissable. The+ // plugin gets back `{ opened }` and nothing else — it never learns the file's+ // name, size, or contents. What happens is that the Desktop's own viewer+ // opens, over the plugin, showing the user a file they already have access+ // to, resolved with their session. Prompting "may this plugin show you your+ // own file?" would be noise in front of an action the user can see.+ requiresConsent: false,+ consent: {+ title: 'Open a shared file in the Evenfire viewer',+ dataDescription: 'Shows you a file you already have access to. The plugin does not see it.',+ tier: 'ambient',+ },+ // Tighter than the reads: this one paints over the user's screen. A plugin+ // that spams it hides itself behind viewers, so it is largely self-limiting,+ // but the budget makes that bounded rather than merely awkward.+ limits: { perMinute: 6, perHour: 60, maxResponseBytes: 1024 },+ cacheTtlMs: 0,+ validate: raw => {+ const record = allowKeys(raw, ['uri'])+ const uri = requiredString(record.uri, 'uri', 2048)+ if (!uri.startsWith('gfs://')) throw new CapabilityInputError('uri must be a gfs:// link')+ return { uri }+ },+ run: async (ctx, params) => ctx.source.openGfsResource({ uri: params.uri as string }),+ },+'theme.read': {id: 'theme.read',descriptorVersion: 1,diff --git a/desktop-app/src/pluginSdkRuntime.ts b/desktop-app/src/pluginSdkRuntime.tsindex 915dd75e5..6c2a8587c 100644--- a/desktop-app/src/pluginSdkRuntime.ts+++ b/desktop-app/src/pluginSdkRuntime.ts@@ -281,10 +281,60 @@ export class PluginSdkRuntime {service.listGfsChildren(resourceId, drive, cursor),downloadGfsUri: uri => service.downloadGfsUri(uri),getPluginTheme: () => this.theme.get(),+ openGfsResource: input => this.openGfsResource(input.uri),showPluginNotification: input => this.showNotification(input),}}+ /**+ * Resolve a `gfs://` link with the USER's session and hand it to the trusted+ * renderer to display. The plugin gets back only whether it opened: it never+ * sees the name, size, or bytes, and an unauthorized or missing resource is+ * the same "could not open" either way, so this is not an existence oracle.+ *+ * Reached two ways, both landing here so they share the rate budget and the+ * audit line: `clerum.gfs.open(uri)` through the broker, and a plain+ * `<a href="gfs://…">` intercepted by the embed's navigation policy.+ */+ async openGfsResource(uri: string): Promise<{ opened: boolean; reason?: string }> {+ const link = String(uri || '').trim()+ if (!link.startsWith('gfs://')) return { opened: false, reason: 'invalid_uri' }+ const win = this.deps.getMainWindow()+ if (!win || win.isDestroyed()) return { opened: false, reason: 'unavailable' }++ let resource+ try {+ resource = await this.deps.service.resolveGfsUri(link)+ } catch (err) {+ console.warn('[PluginSDK] gfs.open resolve failed:', err)+ return { opened: false, reason: 'not_found' }+ }++ this.sendToRenderer('pluginSdk:openGfsResource', {+ gfsUri: resource.gfsUri ?? link,+ name: resource.name,+ kind: resource.kind,+ bytes: typeof resource.bytes === 'number' ? resource.bytes : null,+ })+ return { opened: true }+ }++ /**+ * Entry point for the `<a href="gfs://…">` path. The broker owns rate limiting+ * and auditing for `clerum.gfs.open`, so a link click has to route through it+ * too — otherwise a plugin could dodge the budget by rendering anchors.+ */+ async openGfsResourceFromNavigation(webContentsId: number, uri: string): Promise<void> {+ const result = await this.broker.request(webContentsId, {+ v: 1,+ capability: 'gfs.open',+ params: { uri },+ })+ if (!result.ok) {+ console.warn('[PluginSDK] gfs link open refused:', result.error.code)+ }+ }+private async showNotification(input: {pluginId: stringpluginTitle: stringdiff --git a/desktop-app/src/preload.ts b/desktop-app/src/preload.tsindex a90f5bf69..743e3d448 100644--- a/desktop-app/src/preload.ts+++ b/desktop-app/src/preload.ts@@ -473,6 +473,16 @@ const clerum = Object.freeze({ipcRenderer.on('pluginSdk:consentCancelled', listener)return () => ipcRenderer.off('pluginSdk:consentCancelled', listener)},+ onOpenGfsResource: (+ callback: (args: { gfsUri: string; name: string; kind: string; bytes: number | null }) => void+ ) => {+ const listener = (+ _event: unknown,+ args: { gfsUri: string; name: string; kind: string; bytes: number | null }+ ) => callback(args)+ ipcRenderer.on('pluginSdk:openGfsResource', listener)+ return () => ipcRenderer.off('pluginSdk:openGfsResource', listener)+ },onNotificationClicked: (callback: (args: { pluginId: string; ref: string | null }) => void) => {const listener = (_event: unknown, args: { pluginId: string; ref: string | null }) =>callback(args)diff --git a/desktop-app/src/renderer.d.ts b/desktop-app/src/renderer.d.tsindex 0becb1c9d..98b03d485 100644--- a/desktop-app/src/renderer.d.ts+++ b/desktop-app/src/renderer.d.ts@@ -576,6 +576,14 @@ declare global {pluginSdk: {onConsentRequested: (callback: (request: PluginConsentRequest) => void) => () => voidonConsentCancelled: (callback: (args: { promptId: string }) => void) => () => void+ onOpenGfsResource: (+ callback: (args: {+ gfsUri: string+ name: string+ kind: string+ bytes: number | null+ }) => void+ ) => () => voidonNotificationClicked: (callback: (args: { pluginId: string; ref: string | null }) => void) => () => voiddiff --git a/desktop-app/src/sandboxUiDriver.ts b/desktop-app/src/sandboxUiDriver.tsindex 729501806..fdbeba72b 100644--- a/desktop-app/src/sandboxUiDriver.ts+++ b/desktop-app/src/sandboxUiDriver.ts@@ -87,6 +87,13 @@ export type MountSandboxUiArgs = {* rpc-proxy for the provider authorize URL and `shell.openExternal`s it.*/onOauthAuthorize?: (oauthClientId: string, background: boolean) => void+ /**+ * Fired when the embed navigates to `gfs://<drive>/<resource>` — a plugin+ * rendering a link to a shared file. The driver only forwards; the host+ * resolves the URI with the USER's session and shows it in the Desktop's own+ * viewer, so a click reveals nothing to the plugin.+ */+ onGfsOpen?: (uri: string) => void}type ActiveView = {@@ -369,13 +376,14 @@ export async function mountSandboxUiView(args: MountSandboxUiArgs): Promise<void// else (links to other origins, target=_blank, window.open) goes to the// OS browser or is dropped. `clerum://oauth?clientId=…` is intercepted// and handed back to the AppService.- applySandboxUiNavigationPolicies(- view.webContents,- allowedNavigationPrefix,- (oauthClientId, background) => {+ applySandboxUiNavigationPolicies(view.webContents, allowedNavigationPrefix, {+ onOauthAuthorize: (oauthClientId, background) => {args.onOauthAuthorize?.(oauthClientId, background)- }- )+ },+ onGfsOpen: uri => {+ args.onGfsOpen?.(uri)+ },+ })// The closed callback fires when the renderer gives up the view (parent// window closed, teardown via removeChildView, or the embed crashed).diff --git a/desktop-app/src/sandboxUiEmbedPreload.ts b/desktop-app/src/sandboxUiEmbedPreload.tsindex cce68e64d..29cde32a3 100644--- a/desktop-app/src/sandboxUiEmbedPreload.ts+++ b/desktop-app/src/sandboxUiEmbedPreload.ts@@ -110,6 +110,9 @@ contextBridge.exposeInMainWorld(list: (params?: { drive?: string; resourceId?: string; cursor?: string }) =>capability('gfs.list', params ?? {}),read: (params: { uri: string; as: 'text' | 'dataUrl' }) => capability('gfs.read', params),+ /** Show a shared file in the Desktop's own viewer. Same effect as the+ * user clicking an `<a href="gfs://…">` the plugin rendered. */+ open: (uri: string) => capability('gfs.open', { uri }),}),theme: Object.freeze({ get: () => capability('theme.read') }),notifications: Object.freeze({diff --git a/desktop-app/src/sandboxUiPartitionPolicies.ts b/desktop-app/src/sandboxUiPartitionPolicies.tsindex fced04788..74bda6236 100644--- a/desktop-app/src/sandboxUiPartitionPolicies.ts+++ b/desktop-app/src/sandboxUiPartitionPolicies.ts@@ -33,6 +33,10 @@ export type EmbedNavigationOutcome =* rpc-proxy and opens it in the OS browser. `background` is true when* `background=1` was included in the deep link. */| { kind: 'oauth_authorize'; oauthClientId: string; background: boolean }+ /** `gfs://<drive>/<resource>` — a link to a shared file rendered by the+ * plugin. The host resolves it with the USER's session and shows it in the+ * Desktop's own viewer; the plugin learns nothing from the click. */+ | { kind: 'gfs_open'; uri: string }/** non-http(s) scheme or empty URL — drop silently. */| { kind: 'drop' }@@ -78,6 +82,11 @@ export function classifyEmbedNavigation(}: { kind: 'drop' }}+ if (rawUrl.startsWith('gfs://')) {+ // Shape-checked here only; the host resolves it through the API, which is+ // where authorization actually happens. A bad URI resolves to nothing.+ return rawUrl.length <= 2048 ? { kind: 'gfs_open', uri: rawUrl } : { kind: 'drop' }+ }if (rawUrl.startsWith('https://') || rawUrl.startsWith('http://')) {return { kind: 'external', url: rawUrl }}@@ -139,31 +148,42 @@ export function applySandboxUiPartitionPolicies(ses: Session): void {* main process which fetches the provider authorize URL via rpc-proxy and* `shell.openExternal`s it.*/+export type SandboxUiNavigationHandlers = {+ onOauthAuthorize?: (oauthClientId: string, background: boolean) => void+ onGfsOpen?: (uri: string) => void+}+export function applySandboxUiNavigationPolicies(webContents: WebContents,allowedPrefix: string,- onOauthAuthorize?: (oauthClientId: string, background: boolean) => void+ handlers?: SandboxUiNavigationHandlers | ((oauthClientId: string, background: boolean) => void)): void {- webContents.on('will-navigate', (event, url) => {- const outcome = classifyEmbedNavigation(url, allowedPrefix)- if (outcome.kind === 'allow') return- event.preventDefault()+ // Accepts the legacy positional oauth callback so existing call sites and+ // tests keep working.+ const resolved: SandboxUiNavigationHandlers =+ typeof handlers === 'function' ? { onOauthAuthorize: handlers } : (handlers ?? {})++ const dispatch = (outcome: EmbedNavigationOutcome): void => {if (outcome.kind === 'external') {void shell.openExternal(outcome.url)} else if (outcome.kind === 'oauth_authorize') {- onOauthAuthorize?.(outcome.oauthClientId, outcome.background)+ resolved.onOauthAuthorize?.(outcome.oauthClientId, outcome.background)+ } else if (outcome.kind === 'gfs_open') {+ resolved.onGfsOpen?.(outcome.uri)}+ }++ webContents.on('will-navigate', (event, url) => {+ const outcome = classifyEmbedNavigation(url, allowedPrefix)+ if (outcome.kind === 'allow') return+ event.preventDefault()+ dispatch(outcome)})webContents.setWindowOpenHandler(({ url }) => {- // `window.open` always opens in OS browser (for http(s)).- // `clerum://oauth?…` triggers the OAuth flow same as a top-level click;- // non-http schemes otherwise drop silently.- const outcome = classifyEmbedNavigation(url, allowedPrefix)- if (outcome.kind === 'external') {- void shell.openExternal(outcome.url)- } else if (outcome.kind === 'oauth_authorize') {- onOauthAuthorize?.(outcome.oauthClientId, outcome.background)- }+ // `window.open` always opens in the OS browser (for http(s)).+ // `clerum://oauth?…` and `gfs://…` behave the same as a top-level click;+ // every other scheme drops silently.+ dispatch(classifyEmbedNavigation(url, allowedPrefix))return { action: 'deny' }})}diff --git a/desktop-app/ui/src/App.tsx b/desktop-app/ui/src/App.tsxindex 1b0e2bd33..f2667ea3d 100644--- a/desktop-app/ui/src/App.tsx+++ b/desktop-app/ui/src/App.tsx@@ -13,6 +13,7 @@ import { AppHeader } from '@components/AppHeader'import { BootSplash } from '@components/BootSplash'import { Button, ToastStack } from '@components/Common'import { ConfirmDialog } from '@components/ConfirmDialog'+import { GfsImagePreview } from '@components/GfsImagePreview'import { PluginConsentModal } from '@components/PluginConsentModal'import type { PluginConsentRequest } from '@components/PluginConsentModal/types'import { SidebarNav } from '@components/SidebarNav'@@ -20,6 +21,7 @@ import { DESKTOP_ROUTES, SIDEBAR_COLLAPSED_KEY } from '@constants/navigation'import { THEME_STORAGE_KEY } from '@constants/theme'import { useAgentChatActionsValue } from '@hooks/useAgentChatActionsValue'import { useAppController } from '@hooks/useAppController'+import { gfsImagePreviewMimeType } from '@lib/gfsImagePreview'import {canProcessSandboxUiDeepLinks,resolveSandboxUiDeepLinkApp,@@ -236,6 +238,48 @@ export function App() {}}, [])+ /**+ * A plugin asked to show a shared file — either through `clerum.gfs.open()` or+ * by the user activating a `gfs://` link it rendered. Main has already+ * resolved it with the user's session, so this only decides where it goes:+ * images get a preview over the plugin, everything else hands off to Files.+ */+ const [pluginGfsPreview, setPluginGfsPreview] = React.useState<{+ gfsUri: string+ name: string+ bytes: number+ mimeType: string+ } | null>(null)+ const [pendingGfsUri, setPendingGfsUri] = React.useState<string | null>(null)++ React.useEffect(() => {+ const off = window.clerum.pluginSdk?.onOpenGfsResource?.(resource => {+ const mimeType = resource.kind === 'file' ? gfsImagePreviewMimeType(resource.name) : null+ if (mimeType) {+ // The embed's WebContentsView paints above renderer DOM, so it has to be+ // hidden for the overlay to be visible at all.+ void window.clerum.sandboxUi.setVisible(false).catch(() => undefined)+ setPluginGfsPreview({+ gfsUri: resource.gfsUri,+ name: resource.name,+ bytes: resource.bytes ?? 0,+ mimeType,+ })+ return+ }+ // Folders and non-previewable files belong in the full browser, where the+ // user gets breadcrumbs, download, and sharing.+ setPendingGfsUri(resource.gfsUri)+ vm.handleNavSelect(DESKTOP_ROUTES.files)+ })+ return () => off?.()+ }, [vm.handleNavSelect])++ const closePluginGfsPreview = React.useCallback(() => {+ setPluginGfsPreview(null)+ void window.clerum.sandboxUi.setVisible(true).catch(() => undefined)+ }, [])+const resolvePluginConsent = React.useCallback((promptId: string, allowed: string[]) => {setPluginConsentPrompt(current => (current?.promptId === promptId ? null : current))void window.clerum.pluginSdk?.resolveConsent?.(promptId, allowed)?.catch?.(() => undefined)@@ -1220,7 +1264,11 @@ export function App() {)}{vm.navItem === DESKTOP_ROUTES.contexts && <ContextsPage />}{vm.navItem === DESKTOP_ROUTES.files && (- <FilesPage pushToast={vm.pushToast} />+ <FilesPage+ pushToast={vm.pushToast}+ pendingGfsUri={pendingGfsUri}+ onPendingGfsUriHandled={() => setPendingGfsUri(null)}+ />)}{vm.navItem === DESKTOP_ROUTES.connectors && <McpServersPage />}{vm.navItem === DESKTOP_ROUTES.contextDetails && (@@ -1283,6 +1331,15 @@ export function App() {onResolve={resolvePluginConsent}/>) : null}+ {pluginGfsPreview ? (+ <GfsImagePreview+ byteLength={pluginGfsPreview.bytes}+ fileName={pluginGfsPreview.name}+ gfsUri={pluginGfsPreview.gfsUri}+ mimeType={pluginGfsPreview.mimeType}+ onClose={closePluginGfsPreview}+ />+ ) : null}</DesktopStateProvider></McpRuntimeProvider></AgentChatProviders>diff --git a/desktop-app/ui/src/pages/FilesPage.tsx b/desktop-app/ui/src/pages/FilesPage.tsxindex 8c9ed6df9..70e88a8e5 100644--- a/desktop-app/ui/src/pages/FilesPage.tsx+++ b/desktop-app/ui/src/pages/FilesPage.tsx@@ -110,7 +110,7 @@ function resourceSource(resource: GfsDriveResource, currentFolderName?: string):return resource.sources?.length ? resource.sources.join(' + ') : 'Shared'}-export function FilesPage({ pushToast }: FilesPageProps) {+export function FilesPage({ pushToast, pendingGfsUri, onPendingGfsUriHandled }: FilesPageProps) {const [createFolderName, setCreateFolderName] = useState('')const [createFolderOpen, setCreateFolderOpen] = useState(false)const [renameName, setRenameName] = useState('')@@ -304,6 +304,18 @@ export function FilesPage({ pushToast }: FilesPageProps) {return true}+ /**+ * Open a link handed over from the app level (a plugin's `gfs://` click that+ * this page handles better than the overlay). Cleared immediately so a+ * re-render cannot reopen it, and failures surface the browser's own error.+ */+ useEffect(() => {+ if (!pendingGfsUri) return+ onPendingGfsUriHandled?.()+ void handleOpenGfsLink(pendingGfsUri)+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [pendingGfsUri])+const handleCreateFolder = async () => {const requestedName = createFolderName.trim()if (!requestedName) returndiff --git a/desktop-app/ui/src/pages/FilesPage.types.ts b/desktop-app/ui/src/pages/FilesPage.types.tsindex 60ae0fdb5..594b5cd83 100644--- a/desktop-app/ui/src/pages/FilesPage.types.ts+++ b/desktop-app/ui/src/pages/FilesPage.types.ts@@ -13,6 +13,13 @@ export type GfsPreviewResource = Pick<GfsDriveResource, 'bytes' | 'gfsUri' | 'naexport interface FilesPageProps {/** App-level toast dispatcher for success feedback (desktop-app/ui rule). */pushToast?: (message: string, tone: Tone) => void+ /**+ * A `gfs://` link handed over from elsewhere in the app — today, a plugin+ * asking to open a resource this page can show better than an overlay can+ * (a folder, or a file with no preview). Opened once, then cleared.+ */+ pendingGfsUri?: string | null+ onPendingGfsUriHandled?: () => void}/**diff --git a/docs/features/plugin-ui-sdk-1.md b/docs/features/plugin-ui-sdk-1.mdindex 17eedaf09..e74d73aa6 100644--- a/docs/features/plugin-ui-sdk-1.md+++ b/docs/features/plugin-ui-sdk-1.md@@ -533,6 +533,43 @@ Rules for `as: 'dataUrl'`:`as: 'text'` has its own cap (§6.8) and refuses non-UTF-8 bytes.+#### `gfs.open` — show a file in the Desktop's own viewer++> No prompt. Tier: `ambient`, `requiresConsent: false`.++```ts+type GfsOpenParams = { uri: string }+type GfsOpenResult = { opened: boolean; reason?: string }+```++A plugin that renders a `gfs://` link wants the obvious thing to happen when the+user activates it. Two paths reach the same place:++- `<a href="gfs://main/reports/q3.png">` — the embed's navigation policy+ classifies it as `gfs_open` and hands it to the host+ (`sandboxUiPartitionPolicies.ts`). No JS required.+- `clerum.gfs.open(uri)` — for double-click handlers, buttons, and table cells+ where an anchor does not fit.++The host resolves the URI with the **user's** session, then either opens the+image over the plugin (the embed is hidden, as for a consent prompt) or, for a+folder or a file with no preview, navigates to **Files** focused on that+resource. On close the plugin comes back exactly as it was.++The link path routes through the same capability as the SDK call, so both share+one rate budget and one audit line — otherwise a plugin could dodge the budget+by rendering anchors.++**Why this needs no grant.** The plugin receives `{ opened }` and nothing else:+not the name, not the size, not the bytes. What happens is that the user is shown+their own file, fetched with their own session, in the Desktop's own viewer. This+is the second half of the §6.7 rule — the response carries nothing about the+user, **and** the action is unmissable on screen. It is budgeted at 6/min, the+tightest of the reads, because it paints over the user's work.++An unauthorized resource and a missing one both come back+`{ opened: false, reason: 'not_found' }`, so this is not an existence oracle.+### 6.7 `theme.read` — Desktop appearance (unscoped)> No prompt. Tier: `ambient`, `requiresConsent: false`.@@ -541,10 +578,12 @@ Rules for `as: 'dataUrl'`:type ThemeReadResult = { theme: 'light' | 'dark' }```-This is the one capability that does not prompt, and the exception needs a stated+One of two capabilities that do not prompt, and the exception needs a statedprinciple rather than a shrug: **`requiresConsent: false` is permitted only when-the response contains no information about the user, their org, or their data —-only about the Desktop's own presentation.** Theme qualifies. It is still logged+the response contains no information about the user, their org, or their data.**+Theme qualifies — it describes the Desktop's own presentation. `gfs.open` (§6.6)+qualifies on the same rule plus a second condition: its effect is unmissable on+screen, so it cannot be used covertly. It is still loggedin the audit trail at `debug` verbosity, and it is still listed on the plugin'sSettings row as "Appearance (no permission needed)" so the user is neversurprised to learn a plugin knows their theme.@@ -660,6 +699,7 @@ window.clerum = {gfs: {list(p?: GfsListParams): Promise<PluginSdkResponse<GfsListResult>>read(p: GfsReadParams): Promise<PluginSdkResponse<GfsReadResult>>+ open(uri: string): Promise<PluginSdkResponse<GfsOpenResult>>}theme: { get(): Promise<PluginSdkResponse<ThemeReadResult>> }notifications: { notify(p: NotifyParams): Promise<PluginSdkResponse<NotifyResult>> }diff --git a/docs/features/plugin-ui-sdk-authoring.md b/docs/features/plugin-ui-sdk-authoring.mdindex a3191329e..e3daa31d8 100644--- a/docs/features/plugin-ui-sdk-authoring.md+++ b/docs/features/plugin-ui-sdk-authoring.md@@ -39,7 +39,8 @@ if (me.ok) greet(me.data.name ?? me.data.email)- [ ] Handle a partial grant — render what you can, explain the rest in your own UI.- [ ] Handle `permission_revoked` and the `permission.changed` event live (§8).- [ ] Remove any form where you asked the user to re-type their name/email.-- [ ] Images from GFS go in `<img src="{dataUrl}">`; `blob:` will not load (§7.6).+- [ ] Images you render inline go in `<img src="{dataUrl}">`; `blob:` will not load (§7.6).+- [ ] Links the user opens can just be `<a href="gfs://…">` — no permission needed (§7.7).- [ ] Nothing to add to the recipe YAML. No new Secrets. No new egress.---@@ -100,6 +101,7 @@ Error codes you should actually branch on:| `mcp.read` | `{ servers: [{ name, agents[] }] }` | "See the MCP servers you have access to…" || `gfs.list` | `{ items: [{ resourceId, gfsUri, name, kind, bytes, version }], nextCursor }` | "See the shared files you have access to… It will not be able to open them." || `gfs.read` | `{ gfsUri, name, mimeType, bytes }` + `text` or `dataUrl` | "Open shared files you have access to…" |+| `gfs.open` | `{ opened, reason? }` | **No prompt** — the plugin sees nothing; the user sees their own file. || `theme.read` | `{ theme: 'light' \| 'dark' }` | **No prompt** — it says nothing about the user. || `notifications.notify` | `{ delivered, reason? }` | "Send you notifications." |@@ -337,7 +339,38 @@ if (res.ok) img.src = res.data.dataUrl- `as: 'text'` refuses non-UTF-8 bytes rather than handing you replacementcharacters.-### 7.7 `theme.read`+### 7.7 Linking to a file — `gfs.open`++`gfs.read` gets you the bytes. If you just want a **link the user can open**, use+`gfs.open` and let the Desktop show it:++```html+<!-- Single click, no JS. The navigation policy picks it up. -->+<a href="gfs://main/reports/q3.png">Q3 chart</a>+```++```js+// Double-click on plain text, a button, a table cell — anywhere an anchor+// does not fit.+cell.addEventListener('dblclick', () => window.clerum.gfs.open(cell.dataset.uri))+```++Either way the Desktop resolves the link with the user's session and shows it:+an image opens in a preview **over your plugin** (your embed is hidden while it+is up, and comes back untouched on close); a folder or a non-previewable file+navigates to the Files page instead.++- **No permission needed.** You get `{ opened: true }` and nothing else — not the+ name, not the size, not the contents. If you need the bytes, that is+ `gfs.read`, and that does need a grant.+- **6 calls/minute**, the tightest budget in the SDK. It paints over the user's+ screen; do not wire it to hover or scroll.+- `{ opened: false, reason: 'not_found' }` covers both "does not exist" and "the+ user cannot see it" — deliberately indistinguishable.+- Your embed is hidden while the preview is up. Do not fire it from inside an+ animation, and do not assume your page is visible immediately after.++### 7.8 `theme.read`No prompt. Pair it with the `theme.changed` event rather than polling:@@ -349,7 +382,7 @@ window.clerum.sdk.on(e => {})```-### 7.8 `notifications.notify`+### 7.9 `notifications.notify````jsawait window.clerum.notifications.notify({