Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

feat(plugins): 插件可声明跟对话的任务页 taskView

Dashe2ff9bc7a920
diff --git a/apps/desktop/resources/system-skills/cindy-plugin-creator/SKILL.md b/apps/desktop/resources/system-skills/cindy-plugin-creator/SKILL.md
index 589f51f8d5..cebab5e9e1 100644
--- a/apps/desktop/resources/system-skills/cindy-plugin-creator/SKILL.md
+++ b/apps/desktop/resources/system-skills/cindy-plugin-creator/SKILL.md
@@ -55,6 +55,7 @@ Use for the UI surfaces and interactions the plugin actually exposes; mobile pag
- [插件面板与主题适配(§5)](references/plugin-panels.md)
- [插件一级主视图 mainView(§4.20)](references/plugin-main-view.md)
+- [插件跟对话的任务页 taskView(§4.22)](references/plugin-task-view.md)
- [插件移动端页面接入与操作来源(§5.1)](references/plugin-mobile-pages.md)
- [插件聊天卡片 card(§4.5)](references/plugin-chat-cards.md)
- [插件设置页与自定义参数 settingsHtml / kv(§4.8)](references/plugin-settings.md)
diff --git a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-design.md b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-design.md
index b13e458e2e..947c5bd845 100644
--- a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-design.md
+++ b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-design.md
@@ -12,7 +12,7 @@
值得主动摆出来让用户选的"隐藏"设计选项(详见对应章节):
- **界面形态**:无界面(纯工具)/ 聊天卡片(card 能力,§4.5)/ Cindy 一级主视图
- (mainView 能力,§4.20)/ 右侧栏常驻面板(panel.position
+ (mainView 能力,§4.20)/ 跟对话的任务页(taskView 能力,§4.22;每个任务一份,随任务切换)/ 右侧栏常驻面板(panel.position
left / right / top / bottom,§5;作为不跟对话的全局页签停在聊天区对应的一边)/ 插件页内独占面板(position "tab",从插件页「使用」打开、离开即关,§5)。
- **唤起方式**:只靠 AI 按 whenToUse 自动想起,还是同时声明 `command` 点名词让用户
显式点名(推荐,§2)。
diff --git a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-manifest.md b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-manifest.md
index 0f015a97af..53fc6ae6bd 100644
--- a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-manifest.md
+++ b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-manifest.md
@@ -43,6 +43,8 @@
// 关闭 / 最大化 / 弹出按钮由主机统一提供);position:"tab" 时声明本字段拒装
// 一级主视图是独立能力,见 §4.20。使用时直接声明:
// "mainView": { "title": "工作台", "icon": "puzzle", "html": "main-view.html" }
+ // 跟对话的任务页(§4.22):页签存在每个任务自己的右侧栏里,随任务切换
+ // "taskView": { "title": "模拟器", "html": "task.html" }
// 可选 "open": "page"(缺省,撑满内容区)/ "sidebar"(作为页签进聊天区某一边,配 "side":
// left / right / top / bottom)/ "window"(弹成独立窗口);只是左侧导航入口的默认打开方式,
// 用户拖过 / 弹过后以用户的放置为准。可选 "multiple": true 允许同一视图同时开在多处。
@@ -117,6 +119,7 @@ tool name 对齐,协议键、工具名和参数名不翻译:
},
"panel": { "title": "Plugin panel" },
"mainView": { "title": "Workspace" },
+ "taskView": { "title": "Simulator" },
"network": {
"secrets": {
"api_key": { "label": "API key", "hint": "Create one in account settings." }
@@ -139,7 +142,7 @@ tool name 对齐,协议键、工具名和参数名不翻译:
```
可翻译字段:`name`、`description`、`whenToUse`、`tools`(工具 description 与参数
-文案)、`panel.title`、`mainView.title`、`network.secrets / connections`、`node.secretBindings`、
+文案)、`panel.title`、`mainView.title`、`taskView.title`、`network.secrets / connections`、`node.secretBindings`、
`setup` 的 kv 标签;凭证、连接、Node 凭证和 kv 项按稳定 key 对齐(提供某个 key 的
条目时 label 必填,hint 可选)。工具参数 schema 中已有的 `title / description` 用
JSON Pointer 对齐(如 `/properties/query`;根节点用空字符串 `""`),参数名、类型、
@@ -153,7 +156,7 @@ node secretBindings key、setup kv key——都不能使用 `__proto__`、`const
`prototype`;这些名称是宿主保留键,打包时会直接拒绝。
v3 直接用顶层字段声明插件贡献项与自主 Host 能力,不再有 `slots`。带详单的字段是 `tools`、`cindy`、
-`agent`、`panel`、`mainView`、`card`、`subscribe`、`network`、`node`、`preview`、
+`agent`、`panel`、`mainView`、`taskView`、`card`、`subscribe`、`network`、`node`、`preview`、
`skill`;布尔能力写成字面量 `true`:`notify`、`badge`、`confirm`、`fs`、
`library`、`deviceSync`、`sessionContext`、`pick`、`workspace`。不用的字段直接省略。
`deviceSync` 的声明与调用约定见 [§4.10.2 同账号电脑间的插件资料同步](plugin-files-and-library.md#4102-同账号电脑间的插件资料同步)。
diff --git a/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-task-view.md b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-task-view.md
new file mode 100644
index 0000000000..7161a36123
--- /dev/null
+++ b/apps/desktop/resources/system-skills/cindy-plugin-creator/references/plugin-task-view.md
@@ -0,0 +1,41 @@
+## 4.22 跟对话的任务页(taskView 能力)
+
+插件需要一个**跟着任务走**的页面时(每个任务各看各的:这个任务的模拟器、这个任务的
+构建进度、这个任务的预览),声明 `taskView`:
+
+```json
+{
+ "schemaVersion": 3,
+ "minCindyVersion": "1.2.3",
+ "taskView": { "title": "模拟器", "html": "task.html" }
+}
+```
+
+- 页签存在**每个任务自己**的右侧栏里(与文件、终端同一组),切换任务时随任务切换;
+ 页签头由 Cindy 绘制,标题取 `taskView.title`(缺省插件 `name`),图标取插件图标,
+ **没有地址栏**。用户可以拖到别的边、最大化、弹成独立窗口或关闭,与其它任务页签一致;
+- 与之相对:`mainView` 与非 `tab` 的 `panel` 是**不跟对话**的全局页面(§4.20、§5)。
+ 两类可以同时声明——例如任务页显示本任务的内容,主视图做跨任务的总览与管理;
+- `taskView.html` 必须是包内安全相对路径且文件真实存在;声明过基础 title 后,locale
+ 文件可用 `"taskView": { "title": "Simulator" }` 翻译;
+- 页面经查询参数 `session` 得知自己所在的任务:
+ `new URLSearchParams(location.search).get('session')`。按它区分各任务自己的状态;
+- 打开或聚焦任务页由逻辑页发起(页面本身零桥):
+
+ ```js
+ const opened = await cindy.taskView({ sessionId: ctx?.session_id }); // 缺省落台前任务
+ if (opened.ok) bindToTask(opened.sessionId); // 回执带回实际落点任务
+ else console.warn(opened.errorCode, opened.message);
+ ```
+
+ 同一任务里每个插件至多一个任务页页签,重复打开即聚焦已有页签。它只承载你自己的
+ 包内页面、不接收网址,所以没有 preview 那样的白名单与限速。错误码:
+ `PERMISSION_DENIED`(未声明 taskView 或未启用)/ `INVALID_REQUEST` /
+ `HOST_NOT_READY`(当前没有任务,或没有宿主窗口);
+- 旧版 Cindy 不认识 `taskView`,装入时会忽略该字段,`cindy.taskView` 也不存在。需要
+ 兼容旧版时先判断 `typeof cindy.taskView === 'function'`,不支持就退回 preview(§4.15);
+- 任务页与 panel / mainView 共用同一 Ghost WebView 沙箱:零 Node、零通用 preload、每插件
+ 专属 partition、CSP 与导航守门不变,本身不附赠联网、文件或凭证能力;通信、唤醒与
+ 主题规则同 §5;
+- 远程任务(工作目录在另一台电脑)不显示本机插件的任务页;插件停用、卸载或不再声明
+ taskView 时,已有任务页页签自动隐藏。
diff --git a/apps/desktop/src/main/cindy-brain/__tests__/taskViewSlot.test.ts b/apps/desktop/src/main/cindy-brain/__tests__/taskViewSlot.test.ts
new file mode 100644
index 0000000000..9db27e0bab
--- /dev/null
+++ b/apps/desktop/src/main/cindy-brain/__tests__/taskViewSlot.test.ts
@@ -0,0 +1,66 @@
+/** taskViewSlot.test — 任务页开页槽(taskView)的假 deps 单测。 */
+// - 生产入口与可观察结果:GhostTaskViewSlot.handleRequest 的回执与广播载荷。
+// - Bug / 规则依据:插件请求在任务右侧栏打开自己的任务页;落点任务要回给插件绑定。
+// - 现有覆盖缺口:新槽。最小失败输入:未声明 taskView、sessionId 形状非法、无任务可落。
+// - tier:unit。
+import { describe, expect, it, vi } from 'vitest';
+
+import type { InstalledGhost } from '../../../shared/ghost';
+import { GhostTaskViewSlot, type TaskViewSlotDeps } from '../taskViewSlot';
+
+function taskGhost(options: { taskView?: boolean; enabled?: boolean; instanceKey?: string } = {}): InstalledGhost {
+ return {
+ manifest: {
+ schemaVersion: 3,
+ id: 'sim',
+ name: 'Simulator',
+ version: '1.0.0',
+ kind: 'chip',
+ entry: 'main.js',
+ ...(options.taskView !== false ? { taskView: { html: 'task.html' } } : {}),
+ },
+ dir: '/fake/sim',
+ enabled: options.enabled ?? true,
+ ...(options.instanceKey ? { instanceKey: options.instanceKey } : {}),
+ } as InstalledGhost;
+}
+
+function makeSlot(overrides: Partial<TaskViewSlotDeps> = {}) {
+ const pushes: unknown[] = [];
+ const deps: TaskViewSlotDeps = {
+ getGhost: () => taskGhost(),
+ broadcast: vi.fn((payload) => {
+ pushes.push(payload);
+ return true;
+ }),
+ focusedSessionId: () => 'focused-session',
+ ...overrides,
+ };
+ return { slot: new GhostTaskViewSlot(deps), pushes };
+}
+
+describe('taskViewSlot', () => {
+ it('opens in the requested task, or the focused task, and reports where it landed', () => {
+ const { slot, pushes } = makeSlot();
+ expect(slot.handleRequest('sim', { type: 'task-view-request', sessionId: 'task-1' })).toEqual({ ok: true, sessionId: 'task-1' });
+ expect(slot.handleRequest('sim', { type: 'task-view-request' })).toEqual({ ok: true, sessionId: 'focused-session' });
+ expect(pushes).toEqual([
+ { instanceId: 'sim', sessionId: 'task-1' },
+ { instanceId: 'sim', sessionId: 'focused-session' },
+ ]);
+ });
+
+ it('addresses the exact plugin instance, so a namespaced copy opens its own page', () => {
+ const { slot, pushes } = makeSlot({ getGhost: () => taskGhost({ instanceKey: '_ns__acme__sim' }) });
+ expect(slot.handleRequest('_ns__acme__sim', {}).ok).toBe(true);
+ expect(pushes).toEqual([{ instanceId: '_ns__acme__sim', sessionId: 'focused-session' }]);
+ });
+
+ it('refuses plugins without a task page, malformed task ids, and having nowhere to land', () => {
+ expect(makeSlot({ getGhost: () => taskGhost({ taskView: false }) }).slot.handleRequest('sim', {})).toMatchObject({ ok: false, errorCode: 'PERMISSION_DENIED' });
+ expect(makeSlot({ getGhost: () => taskGhost({ enabled: false }) }).slot.handleRequest('sim', {})).toMatchObject({ ok: false, errorCode: 'PERMISSION_DENIED' });
+ expect(makeSlot().slot.handleRequest('sim', { sessionId: '../x' })).toMatchObject({ ok: false, errorCode: 'INVALID_REQUEST' });
+ expect(makeSlot({ focusedSessionId: () => null }).slot.handleRequest('sim', {})).toMatchObject({ ok: false, errorCode: 'HOST_NOT_READY' });
+ expect(makeSlot({ broadcast: () => false }).slot.handleRequest('sim', {})).toMatchObject({ ok: false, errorCode: 'HOST_NOT_READY' });
+ });
+});
diff --git a/apps/desktop/src/main/cindy-brain/forge.ts b/apps/desktop/src/main/cindy-brain/forge.ts
index db3237b311..8356f3143c 100644
--- a/apps/desktop/src/main/cindy-brain/forge.ts
+++ b/apps/desktop/src/main/cindy-brain/forge.ts
@@ -949,6 +949,7 @@ async function buildGhostPackage(
}
if (manifest.panel?.html) mustExist.push(manifest.panel.html);
if (manifest.mainView?.html) mustExist.push(manifest.mainView.html);
+ if (manifest.taskView?.html) mustExist.push(manifest.taskView.html);
if (manifest.settingsHtml) mustExist.push(manifest.settingsHtml);
for (const item of manifest.skill?.items ?? []) mustExist.push(`${item.dir}/SKILL.md`);
if (iconPng === undefined && manifest.icon) mustExist.push(manifest.icon);
diff --git a/apps/desktop/src/main/cindy-brain/forgeGuide.ts b/apps/desktop/src/main/cindy-brain/forgeGuide.ts
index 4eb9c23c87..c5b55795be 100644
--- a/apps/desktop/src/main/cindy-brain/forgeGuide.ts
+++ b/apps/desktop/src/main/cindy-brain/forgeGuide.ts
@@ -30,6 +30,7 @@ import bundledSkillsLegacy from '../../../resources/system-skills/cindy-plugin-c
import workspaceSessions from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-workspace-sessions.md?raw';
import confirmDialog from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-confirm-dialog.md?raw';
import mainView from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-main-view.md?raw';
+import taskView from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-task-view.md?raw';
import recommendations from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-recommendations.md?raw';
import panels from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-panels.md?raw';
import mobilePages from '../../../resources/system-skills/cindy-plugin-creator/references/plugin-mobile-pages.md?raw';
@@ -68,6 +69,7 @@ export const FORGE_GUIDE = [
workspaceSessions,
confirmDialog,
mainView,
+ taskView,
recommendations,
panels,
mobilePages,
diff --git a/apps/desktop/src/main/cindy-brain/index.ts b/apps/desktop/src/main/cindy-brain/index.ts
index e2b4569081..e9b75b5e6c 100644
--- a/apps/desktop/src/main/cindy-brain/index.ts
+++ b/apps/desktop/src/main/cindy-brain/index.ts
@@ -405,6 +405,7 @@ import {
import { GhostPickSlot } from './pickSlot.js';
import { recordGhostPickedDir, relocateGhostPickedDirs } from './pickGrantsStore.js';
import { GhostPreviewSlot } from './previewSlot.js';
+import { GhostTaskViewSlot } from './taskViewSlot.js';
import { GhostScheduleSlot, isMainShellWindowUrl } from './scheduleSlot.js';
import { GhostWorkspaceSlot, type WorkspaceSessionService } from './workspaceSlot.js';
import type { GhostTrustRegistry } from './ghostSignature.js';
@@ -3923,6 +3924,30 @@ export function getGhostPreviewSlot(): GhostPreviewSlot {
return previewSlotSingleton;
}
+let taskViewSlotSingleton: GhostTaskViewSlot | null = null;
+
+/** 插件任务页开页通道(main → 全窗口 renderer;在指定任务的右侧栏开 / 聚焦任务页页签)。 */
+export const GHOST_TASK_VIEW_OPEN_CHANNEL = 'ghosts:task-view-open';
+
+/** 任务页开页槽单例(taskView):资格审与落点解析在 GhostTaskViewSlot,这里只组装广播。 */
+export function getGhostTaskViewSlot(): GhostTaskViewSlot {
+ if (!taskViewSlotSingleton) {
+ taskViewSlotSingleton = new GhostTaskViewSlot({
+ getGhost: findGhostForInstanceId,
+ focusedSessionId: () => ghostSessionFocusTracker.current(),
+ broadcast: (payload) => {
+ const windows = BrowserWindow.getAllWindows().filter((window) => !window.isDestroyed());
+ windows.forEach((window) => {
+ sendGhostWindowPush(window, GHOST_TASK_VIEW_OPEN_CHANNEL, payload);
+ });
+ return windows.length > 0;
+ },
+ log,
+ });
+ }
+ return taskViewSlotSingleton;
+}
+
let scheduleSlotSingleton: GhostScheduleSlot | null = null;
/** 插件自动化草稿通道(main → **单个**窗口;renderer 开自动化创建面板并预填)。 */
@@ -8752,6 +8777,11 @@ export function registerGhostIpc(): void {
if (type === 'preview-request') {
return getGhostPreviewSlot().handleRequest(id, payload);
}
+ // task-view-request = 在任务右侧栏打开 / 聚焦插件自己的任务页(taskView 槽):
+ // 只承载包内页面,不收网址;落点解析在 taskViewSlot,落地在 renderer。
+ if (type === 'task-view-request') {
+ return getGhostTaskViewSlot().handleRequest(id, payload);
+ }
// schedule-request = 打开自动化创建面板并预填(agent 槽的 schedule 加档):
// 只开面板,任务由用户选模型后亲手保存才落库——本槽全程不碰 schedule storage。
// 资格审/净化/频率钳制/限速在 scheduleSlot,落地在 renderer。
diff --git a/apps/desktop/src/main/cindy-brain/taskViewSlot.ts b/apps/desktop/src/main/cindy-brain/taskViewSlot.ts
new file mode 100644
index 0000000000..a584a36fa0
--- /dev/null
+++ b/apps/desktop/src/main/cindy-brain/taskViewSlot.ts
@@ -0,0 +1,68 @@
+/**
+ * taskViewSlot.ts — 任务页开页槽(taskView)。
+ * ---------------------------------------------------------------------------
+ * 插件经管子上行 `{type:'task-view-request', sessionId?}`,请主机在指定任务的
+ * 右侧栏打开(或聚焦)它自己的任务页页签。页签只承载插件自己的包内页面,
+ * 不接收任何网址:没有跳转面,也就没有 preview 那样的白名单与限速。
+ *
+ * - 资格审:已装、启用、声明了 taskView;
+ * - 落点:显式 sessionId 优先(通常来自 session-context 注入),缺省台前任务,
+ * 两者皆无如实拒;sessionId 只做形状校验(右侧栏是本机用户自己的 UI);
+ * - 成功回执带回实际落点任务,插件据此绑定自己的业务状态。
+ *
+ * 纯逻辑 + 依赖注入:广播在 cindy-brain/index.ts 组装时注入。
+ */
+
+import type { GhostPipeTaskViewResult, InstalledGhost } from '../../shared/ghost.js';
+import { installedGhostStoragePart } from '../../shared/pluginIdentity.js';
+
+/** 推给 renderer 的开页载荷(实例 id 由主机按已装清单填,不信自报)。 */
+export interface GhostTaskViewOpenPush {
+ instanceId: string;
+ sessionId: string;
+}
+
+export interface TaskViewSlotDeps {
+ getGhost(id: string): InstalledGhost | null;
+ /** 把开页请求推给宿主窗口;false = 一个窗口都不在(HOST_NOT_READY)。 */
+ broadcast(payload: GhostTaskViewOpenPush): boolean;
+ /** 台前任务快照(请求缺省 sessionId 时的落点;非任务页为 null)。 */
+ focusedSessionId(): string | null;
+ log?: { info: (msg: string, meta?: Record<string, unknown>) => void };
+}
+
+const SESSION_ID_RE = /^[A-Za-z0-9-]{1,64}$/;
+
+function fail(
+ errorCode: Extract<GhostPipeTaskViewResult, { ok: false }>['errorCode'],
+ message: string,
+): GhostPipeTaskViewResult {
+ return { ok: false, errorCode, message };
+}
+
+export class GhostTaskViewSlot {
+ constructor(private readonly deps: TaskViewSlotDeps) {}
+
+ handleRequest(ghostId: string, payload: unknown): GhostPipeTaskViewResult {
+ const ghost = this.deps.getGhost(ghostId);
+ if (!ghost?.enabled || !ghost.manifest.taskView) {
+ return fail('PERMISSION_DENIED', '插件未声明任务页(taskView),或当前未启用');
+ }
+ if (payload !== undefined && (!payload || typeof payload !== 'object' || Array.isArray(payload))) {
+ return fail('INVALID_REQUEST', 'task-view-request 载荷必须是对象');
+ }
+ const request = (payload ?? {}) as Record<string, unknown>;
+ if (request.sessionId !== undefined) {
+ if (typeof request.sessionId !== 'string' || !SESSION_ID_RE.test(request.sessionId)) {
+ return fail('INVALID_REQUEST', 'sessionId 形状不合法');
+ }
+ }
+ const sessionId =
+ typeof request.sessionId === 'string' ? request.sessionId : this.deps.focusedSessionId();
+ if (!sessionId) return fail('HOST_NOT_READY', '当前没有任务可承载任务页');
+ const delivered = this.deps.broadcast({ instanceId: installedGhostStoragePart(ghost), sessionId });
+ if (!delivered) return fail('HOST_NOT_READY', '当前没有可用的宿主窗口');
+ this.deps.log?.info('ghost task view open requested', { ghostId, sessionId });
+ return { ok: true, sessionId };
+ }
+}
diff --git a/apps/desktop/src/main/right-sidebar-window/ipc.ts b/apps/desktop/src/main/right-sidebar-window/ipc.ts
index 5757cb43aa..98ca040512 100644
--- a/apps/desktop/src/main/right-sidebar-window/ipc.ts
+++ b/apps/desktop/src/main/right-sidebar-window/ipc.ts
@@ -152,6 +152,12 @@ function parseCommand(raw: unknown): RsbWindowCommand {
if (r.type === 'close-orca-workers-tab') {
return { type: 'close-orca-workers-tab', sessionId: r.sessionId };
}
+ if (r.type === 'open-plugin-task') {
+ if (typeof r.instanceId !== 'string' || !r.instanceId || r.instanceId.length > 256) {
+ throwIpcError('INVALID_PARAMS', 'Invalid plugin instance');
+ }
+ return { type: 'open-plugin-task', sessionId: r.sessionId, instanceId: r.instanceId };
+ }
if (r.type === 'open-routines-tab') {
if (typeof r.botId !== 'string' || !r.botId || r.botId.length > 128) throwIpcError('INVALID_PARAMS', 'Invalid teammate');
return { type: 'open-routines-tab', sessionId: r.sessionId, botId: r.botId };
diff --git a/apps/desktop/src/preload/ghostPreload.ts b/apps/desktop/src/preload/ghostPreload.ts
index 8e0118ea5b..42a33fb3da 100644
--- a/apps/desktop/src/preload/ghostPreload.ts
+++ b/apps/desktop/src/preload/ghostPreload.ts
@@ -33,6 +33,8 @@ import { contextBridge, ipcRenderer } from 'electron';
* 系统选文件夹窗口由主机弹,用户亲选即授权,守门全在主机侧 pickSlot。
* - preview(req):preview 槽的便捷口——send({type:'preview-request', …req})
* 的语法糖;URL 白名单守门在主机侧 previewSlot。
+ * - taskView(req):taskView 槽的便捷口——send({type:'task-view-request', …req});
+ * 在任务右侧栏打开 / 聚焦本插件的任务页,回执 {ok, sessionId} 带回落点任务。
* - workspace(req):workspace 槽的便捷口——send({type:'workspace-request',
* …req}) 的语法糖;目录授权与会话创建守门全在主机侧 workspaceSlot。
* - confirm(req):confirm 槽的便捷口——send({type:'confirm-request', …req}) 的
@@ -119,6 +121,9 @@ contextBridge.exposeInMainWorld('cindy', {
ipcRenderer.invoke('ghost-pipe:send', { ...req, type: 'pick-request' }),
preview: (req: Record<string, unknown>): Promise<unknown> =>
ipcRenderer.invoke('ghost-pipe:send', { ...req, type: 'preview-request' }),
+ // 在任务右侧栏打开 / 聚焦本插件的任务页(taskView);缺省落台前任务,回执带回落点任务。
+ taskView: (req: Record<string, unknown> = {}): Promise<unknown> =>
+ ipcRenderer.invoke('ghost-pipe:send', { ...req, type: 'task-view-request' }),
workspace: (req: Record<string, unknown>): Promise<unknown> =>
ipcRenderer.invoke('ghost-pipe:send', { ...req, type: 'workspace-request' }),
confirm: (req: Record<string, unknown>): Promise<unknown> =>
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index 555b4ded01..da3b8b9213 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -749,6 +749,7 @@ const fanOutGhostInstallConsentRequest = createIpcFanOut('ghosts:install-consent
const fanOutGhostInstallConsentDismissed = createIpcFanOut('ghosts:install-consent:dismissed');
// 插件预览开页(preview 槽:renderer 在右侧栏开 web-browser 标签)。
const fanOutGhostPreviewOpen = createIpcFanOut('ghosts:preview-open');
+const fanOutGhostTaskViewOpen = createIpcFanOut('ghosts:task-view-open');
// 插件自动化草稿(agent 槽 schedule 加档:renderer 开自动化创建面板并预填)。
const fanOutGhostScheduleDraft = createIpcFanOut('ghosts:schedule-draft');
const fanOutVoiceInputModifierShortcutKeys = createIpcFanOut('voice-input:modifier-shortcut-keys');
@@ -1485,6 +1486,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
resolveInstallConsent: (requestId: string, confirmed: boolean): Promise<{ handled: boolean }> =>
ipcRenderer.invoke('ghosts:install-consent:resolve', { requestId, confirmed }),
onPreviewOpen: fanOutGhostPreviewOpen,
+ onTaskViewOpen: fanOutGhostTaskViewOpen,
onScheduleDraft: fanOutGhostScheduleDraft,
getCard: (
callId: string,
diff --git a/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx b/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx
index d586d575eb..a0aa0032a1 100644
--- a/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx
+++ b/apps/desktop/src/renderer/cindy-brain/ghostPanelBody.tsx
@@ -190,10 +190,16 @@ export function pickGhostPanelMediaUri(
export function GhostWebviewBody({
ghost,
html,
+ query,
onHostNode,
}: {
ghost: Pick<InstalledGhost, 'manifest' | 'dir' | 'namespace'> & Partial<Pick<InstalledGhost, 'approval'>>;
html: string | undefined;
+ /**
+ * 附在入口地址后的查询串(不含 `?`),如任务页的 `session=<id>`。协议供片与附加闸
+ * 都只按 pathname 判定,查询串只给页面自己读。
+ */
+ query?: string;
onHostNode?: (node: HTMLDivElement | null) => void;
}): ReactNode {
const { manifest } = ghost;
@@ -232,7 +238,7 @@ export function GhostWebviewBody({
if (!host) return;
const webview = document.createElement('webview') as WebviewTag;
webview.setAttribute('partition', partitionClaim);
- webview.setAttribute('src', `${GHOST_SCHEME}://${manifest.id}/${html}`);
+ webview.setAttribute('src', `${GHOST_SCHEME}://${manifest.id}/${html}${query ? `?${query}` : ''}`);
webview.setAttribute('style', 'display:flex;flex:1 1 auto;width:100%;height:100%;');
let disposed = false;
let themeTimer: ReturnType<typeof setTimeout> | null = null;
@@ -304,7 +310,7 @@ export function GhostWebviewBody({
};
// version 入依赖:原位更新换版后 webview 重挂载,面板立刻跑新代码
// (供片协议直读安装目录,不重挂会一直渲染旧版缓存的页面)。
- }, [crashed, generation, librarySwapping, instanceId, approvalToken, partitionClaim, manifest.id, manifest.version, manifest.resolvedLocale, html]);
+ }, [crashed, generation, librarySwapping, instanceId, approvalToken, partitionClaim, manifest.id, manifest.version, manifest.resolvedLocale, html, query]);
if (crashed) {
return (
diff --git a/apps/desktop/src/renderer/features/plugin/lib/permissionItemIcon.ts b/apps/desktop/src/renderer/features/plugin/lib/permissionItemIcon.ts
index b8caa379b7..eb340bdff4 100644
--- a/apps/desktop/src/renderer/features/plugin/lib/permissionItemIcon.ts
+++ b/apps/desktop/src/renderer/features/plugin/lib/permissionItemIcon.ts
@@ -10,6 +10,7 @@ const PERMISSION_ICON: Record<GhostPermissionItem['kind'], LucideIcon> = {
command: Terminal,
panel: PanelRight,
'main-view': AppWindow,
+ 'task-view': PanelRight,
code: FileCode2,
subscribe: Radio,
card: LayoutTemplate,
diff --git a/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx b/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx
index e1ce4aa68e..c78e9736b2 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx
+++ b/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx
@@ -156,6 +156,7 @@ const KIND_ICON: Record<BuiltinTabKindId, LucideIcon> = {
'resource-usage': Activity,
'cindy-make': Wrench,
'plugin-view': Puzzle,
+ 'plugin-task': Puzzle,
};
const KIND_LABEL_KEY: Record<BuiltinTabKindId, string> = {
@@ -173,6 +174,7 @@ const KIND_LABEL_KEY: Record<BuiltinTabKindId, string> = {
'resource-usage': 'rightSidebar.tabs.kinds.resourceUsage',
'cindy-make': 'settings.cindyMake.title',
'plugin-view': 'rightSidebar.tabs.kinds.pluginView',
+ 'plugin-task': 'rightSidebar.tabs.kinds.pluginTask',
};
/**
diff --git a/apps/desktop/src/renderer/features/right-sidebar/__tests__/tabAvailability.test.ts b/apps/desktop/src/renderer/features/right-sidebar/__tests__/tabAvailability.test.ts
index 9c50dd50a0..f5a5b488a9 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/__tests__/tabAvailability.test.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/__tests__/tabAvailability.test.ts
@@ -34,6 +34,22 @@ describe('sidebar availability', () => {
projectAvailableTabs(pluginTabs, null, { installedGhosts: [], subagentsAvailable: true }).tabs,
).toHaveLength(3);
});
+ // 任务页页签(跟对话):存在任务桶里,插件卸载 / 停用 / 不再声明 taskView 时隐藏;远程任务不投影本机插件。
+ it('hides plugin-task tabs whose plugin is gone, disabled or no longer has a task page', () => {
+ const taskTabs = [
+ { id: 'task-a', kind: 'plugin-task', state: { instanceId: 'alpha' } },
+ { id: 'task-b', kind: 'plugin-task', state: { instanceId: 'beta' } },
+ { id: 'task-c', kind: 'plugin-task', state: { instanceId: 'gamma' } },
+ { id: 'task-d', kind: 'plugin-task', state: { instanceId: 'gone' } },
+ ] as unknown as TabState[];
+ const alpha = { manifest: { id: 'alpha', taskView: { html: 't.html' } }, enabled: true } as InstalledGhost;
+ const beta = { manifest: { id: 'beta', taskView: { html: 't.html' } }, enabled: false } as InstalledGhost;
+ const gamma = { manifest: { id: 'gamma', mainView: { html: 'm.html' } }, enabled: true } as InstalledGhost;
+ expect(
+ projectAvailableTabs(taskTabs, 'task-b', { installedGhosts: [alpha, beta, gamma], subagentsAvailable: true }).tabs.map((tab) => tab.id),
+ ).toEqual(['task-a']);
+ expect(projectAvailableTabs(taskTabs, null, { installedGhosts: [], subagentsAvailable: true }).tabs).toEqual([]);
+ });
it('filters persisted Cindy Make tabs when the product is disabled', () => {
const cindyTabs = [
{ id: 'file', kind: 'file-browser', state: null },
diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openPluginTaskTab.test.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openPluginTaskTab.test.ts
new file mode 100644
index 0000000000..abaf1ea645
--- /dev/null
+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/__tests__/openPluginTaskTab.test.ts
@@ -0,0 +1,69 @@
+// @vitest-environment jsdom
+// - 生产入口与可观察结果:openPluginTaskTab 对真实 store 的写入(任务桶里的页签、激活页签、可见性请求)。
+// - Bug / 规则依据:同一任务里每个插件实例至多一个任务页;不同任务各有自己的一份。
+// - 现有覆盖缺口:新入口。最小失败输入:同一插件在同一任务里连开两次。
+// - tier:unit。
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import { _resetStore, addTab, ensureHydrated, getBucket } from '../../store';
+import { routeSidebarCommand } from '../detachedSidebarRouting';
+import { openPluginTaskTab } from '../openPluginTaskTab';
+import { _resetSidebarCommandsForTests, onRequestRightSidebarVisibility } from '../sidebarCommands';
+
+vi.mock('../detachedSidebarRouting', () => ({ routeSidebarCommand: vi.fn(async () => 'attached') }));
+
+type Row = { id: string; sessionId: string; kind: string; position: number; state: unknown };
+const rows = new Map<string, Row>();
+const active = new Map<string, string | null>();
+const ipc = {
+ list: vi.fn(async ({ sessionId }: { sessionId: string }) => ({
+ tabs: [...rows.values()].filter((row) => row.sessionId === sessionId).sort((a, b) => a.position - b.position),
+ activeTabId: active.get(sessionId) ?? null,
+ })),
+ upsert: vi.fn(async (row: Row) => { rows.set(row.id, row); }),
+ close: vi.fn(async ({ id }: { id: string }) => { rows.delete(id); }),
+ setActive: vi.fn(async ({ sessionId, id }: { sessionId: string; id: string | null }) => { active.set(sessionId, id); }),
+ reorder: vi.fn(async () => {}),
+};
+const visibility = vi.fn();
+
+beforeEach(() => {
+ _resetStore(); _resetSidebarCommandsForTests();
+ rows.clear(); active.clear(); localStorage.clear(); vi.clearAllMocks();
+ vi.mocked(routeSidebarCommand).mockResolvedValue('attached');
+ window.electronAPI = { localDb: { rightSidebarTabs: ipc }, platform: 'darwin' } as unknown as Window['electronAPI'];
+ onRequestRightSidebarVisibility(visibility);
+});
+afterEach(() => { _resetStore(); _resetSidebarCommandsForTests(); });
+
+const taskTabs = (sessionId: string) =>
+ getBucket(sessionId).tabs.filter((tab) => tab.kind === 'plugin-task').map((tab) => tab.state);
+
+describe('openPluginTaskTab', () => {
+ it('keeps one task page per plugin per task, refocusing it instead of adding another', async () => {
+ await openPluginTaskTab('task-1', 'sim', { userInitiated: false });
+ await ensureHydrated('task-1');
+ const files = await addTab('task-1', 'file-browser');
+ expect(getBucket('task-1').activeTabId).toBe(files.id);
+ await openPluginTaskTab('task-1', 'sim', { userInitiated: false });
+ expect(taskTabs('task-1')).toEqual([{ instanceId: 'sim' }]);
+ const simTab = getBucket('task-1').tabs.find((tab) => tab.kind === 'plugin-task')!;
+ expect(getBucket('task-1').activeTabId).toBe(simTab.id);
+ expect(visibility).toHaveBeenLastCalledWith('open', { sessionId: 'task-1', userInitiated: false });
+ });
+
+ it('gives every task its own page, and every plugin its own tab within a task', async () => {
+ await openPluginTaskTab('task-1', 'sim');
+ await openPluginTaskTab('task-2', 'sim');
+ await openPluginTaskTab('task-1', 'other');
+ expect(taskTabs('task-1')).toEqual([{ instanceId: 'sim' }, { instanceId: 'other' }]);
+ expect(taskTabs('task-2')).toEqual([{ instanceId: 'sim' }]);
+ });
+
+ it('leaves the tab to the detached sidebar window when the command is routed there', async () => {
+ vi.mocked(routeSidebarCommand).mockResolvedValue('routed');
+ await openPluginTaskTab('task-1', 'sim', { userInitiated: false });
+ expect(routeSidebarCommand).toHaveBeenCalledWith({ type: 'open-plugin-task', sessionId: 'task-1', instanceId: 'sim' }, { userInitiated: false });
+ expect(ipc.upsert).not.toHaveBeenCalled();
+ expect(visibility).toHaveBeenCalledWith('open', { sessionId: 'task-1', userInitiated: false });
+ });
+});
diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts
index 799123b83c..28481b1860 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/executeSidebarCommand.ts
@@ -1,3 +1,4 @@
+import { openPluginTaskTab } from './openPluginTaskTab';
import { openRoutinesTab } from './openRoutinesTab';
import { openMailPreview, openMailCard } from './mailPreview';
/** 执行 main 已裁决并推给当前 renderer host 的 RSB command。 */
@@ -28,6 +29,10 @@ export async function executeSidebarCommand(command: RsbWindowCommand): Promise<
await openMailPreview(command.sessionId, command.url);
return;
}
+ if (command.type === 'open-plugin-task') {
+ await openPluginTaskTab(command.sessionId, command.instanceId, { userInitiated: false });
+ return;
+ }
if (command.type === 'open-routines-tab') {
await openRoutinesTab(command.sessionId, command.botId);
return;
diff --git a/apps/desktop/src/renderer/features/right-sidebar/lib/openPluginTaskTab.ts b/apps/desktop/src/renderer/features/right-sidebar/lib/openPluginTaskTab.ts
new file mode 100644
index 0000000000..55de33f05c
--- /dev/null
+++ b/apps/desktop/src/renderer/features/right-sidebar/lib/openPluginTaskTab.ts
@@ -0,0 +1,38 @@
+import { addTab, ensureHydrated, getBucket, setActiveTab } from '../store';
+import type { PluginTaskTabState } from '../plugins/plugin-task';
+import { routeSidebarCommand } from './detachedSidebarRouting';
+import { requestRightSidebarVisibility } from './sidebarCommands';
+
+/**
+ * 在指定任务的右侧栏打开插件任务页(taskView):同一任务里每个插件实例至多一个
+ * 任务页页签,已有则聚焦。来自插件逻辑页的请求不是用户当次手势,分离侧栏形态下
+ * 不抢前台(userInitiated:false)。
+ */
+export async function openPluginTaskTab(
+ sessionId: string,
+ instanceId: string,
+ options: { userInitiated?: boolean } = {},
+): Promise<void> {
+ const userInitiated = options.userInitiated !== false;
+ const route = await routeSidebarCommand(
+ { type: 'open-plugin-task', sessionId, instanceId },
+ { userInitiated },
+ );
+ if (route === 'attached') {
+ await ensureHydrated(sessionId);
+ const bucket = getBucket(sessionId);
+ const existing = bucket.tabs.find(
+ (tab) =>
+ tab.kind === 'plugin-task' &&
+ (tab.state as PluginTaskTabState | null)?.instanceId === instanceId,
+ );
+ if (existing) {
+ if (bucket.activeTabId !== existing.id) await setActiveTab(sessionId, existing.id);
+ } else {
+ await addTab(sessionId, 'plugin-task', { instanceId } satisfies PluginTaskTabState);
+ }
+ }
+ if (route === 'attached' || route === 'routed') {
+ requestRightSidebarVisibility('open', { sessionId, userInitiated });
+ }
+}
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts b/apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts
index b589e2c290..1080b9143b 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/index.ts
@@ -22,3 +22,4 @@ import './background-tasks';
import './resource-usage';
import './routines';
import './plugin-view';
+import './plugin-task';
diff --git a/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsx b/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsx
new file mode 100644
index 0000000000..08e7e8df23
--- /dev/null
+++ b/apps/desktop/src/renderer/features/right-sidebar/plugins/plugin-task/index.tsx
@@ -0,0 +1,95 @@
+/**
+ * plugin-task —— 右侧栏里跟对话的插件任务页页签(taskView)。
+ *
+ * 与全局页签 plugin-view 相反:页签存在各任务自己的页签桶里(本地数据库,随任务
+ * 持久化),切换任务时随任务切换。一个任务里每个插件实例至多一个任务页页签,由
+ * 插件逻辑页经 `cindy.taskView()` 打开或聚焦(lib/openPluginTaskTab.ts)。
+ *
+ * 页面与 mainView / panel 同一条 webview 路(ghostPanelBody.tsx):插件专属分区、
+ * 零桥、主机注入主题;页签头由 Cindy 绘制,没有地址栏。页面经查询参数
+ * `session=<id>` 得知自己所在的任务。
+ */
+
+import { Puzzle } from 'lucide-react';
+import type { TFunction } from 'i18next';
+
+import { GhostPanelError, GhostWebviewBody } from '@/cindy-brain/ghostPanelBody';
+import { useGhostRuntimeState } from '@/cindy-brain/runtimeStates';
+import { useInstalledGhosts } from '@/cindy-brain/useInstalledGhosts';
+import type { InstalledGhost } from '../../../../../shared/ghost';
+import { installedGhostStoragePart } from '../../../../../shared/pluginIdentity';
+import { registerTabKind } from '../../registry';
+import type { TabKindBodyProps, TabKindPlugin } from '../../types';
+
+/** 任务页页签状态:承载哪个已装插件实例。 */
+export interface PluginTaskTabState {
+ instanceId: string;
+}
+
+function useInstalledGhostByInstance(instanceId: string): InstalledGhost | undefined {
+ return useInstalledGhosts().find((ghost) => installedGhostStoragePart(ghost) === instanceId);
+}
+
+function PluginTaskTabPillTitle({ state, t }: { state: PluginTaskTabState; t: TFunction }) {
+ const ghost = useInstalledGhostByInstance(state.instanceId);
+ return (
+ <>
+ {ghost
+ ? (ghost.manifest.taskView?.title ?? ghost.manifest.name)
+ : t('rightSidebar.tabs.kinds.pluginTask')}
+ </>
+ );
+}
+
+function PluginTaskTabPillIcon({ state }: { state: PluginTaskTabState }) {
+ const ghost = useInstalledGhostByInstance(state.instanceId);
+ if (ghost?.iconDataUrl) {
+ return <img src={ghost.iconDataUrl} alt="" width={13} height={13} className="rounded-[3px]" />;
+ }
+ return <Puzzle size={13} />;
+}
+
+function PluginTaskBody({ state, ctx }: TabKindBodyProps<PluginTaskTabState>) {
+ const ghost = useInstalledGhostByInstance(state.instanceId);
+ const runtimeState = useGhostRuntimeState(state.instanceId);
+ // 停用 / 卸载的瞬间可用性投影已把页签隐藏,这里只兜住收起前的一两帧。
+ if (!ghost || ghost.enabled === false || !ghost.manifest.taskView) return null;
+ if (runtimeState === 'crashed' || runtimeState === 'fused') {
+ return <GhostPanelError ghost={ghost} state={runtimeState} />;
+ }
+ return (
+ <div className="flex min-h-0 flex-1 flex-col overflow-hidden">
+ <GhostWebviewBody
+ ghost={ghost}
+ html={ghost.manifest.taskView.html}
+ query={`session=${encodeURIComponent(ctx.sessionId)}`}
+ />
+ </div>
+ );
+}
+
+const plugin: TabKindPlugin<PluginTaskTabState> = {
+ kind: 'plugin-task',
+ menu: {
+ kind: 'plugin-task',
+ labelKey: 'rightSidebar.tabs.kinds.pluginTask',
+ icon: Puzzle,
+ order: 91,
+ enabled: true,
+ hiddenFromMenu: true,
+ },
+ TabPillTitle: PluginTaskTabPillTitle,
+ TabPillIcon: PluginTaskTabPillIcon,
+ TabBody: PluginTaskBody,
+ defaultState: () => ({ instanceId: '' }),
+ hydrateState: (raw) => ({
+ instanceId:
+ raw &&
+ typeof raw === 'object' &&
+ typeof (raw as { instanceId?: unknown }).instanceId === 'string'
+ ? (raw as { instanceId: string }).instanceId
+ : '',
+ }),
+};
+
+registerTabKind(plugin as unknown as TabKindPlugin, import.meta.hot);
diff --git a/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts b/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts
index e2cf25bf0c..db5f0ef412 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/tabAvailability.ts
@@ -34,6 +34,20 @@ function isUnavailablePluginView(
return !ghost || !isGlobalTabCapableGhost(ghost);
}
+/** 任务页签(plugin-task):本机已装、启用且仍声明 taskView 的插件实例才投影。 */
+function isUnavailablePluginTask(
+ tab: TabState,
+ availability: RightSidebarTabAvailability,
+): boolean {
+ if (tab.kind !== 'plugin-task') return false;
+ const instanceId = (tab.state as { instanceId?: unknown } | null)?.instanceId;
+ if (typeof instanceId !== 'string' || !instanceId) return true;
+ const ghost = availability.installedGhosts.find(
+ (candidate) => installedGhostStoragePart(candidate) === instanceId,
+ );
+ return !ghost || ghost.enabled === false || !ghost.manifest.taskView;
+}
+
function retiredTab(
tab: TabState,
availability: RightSidebarTabAvailability,
@@ -58,6 +72,7 @@ function isUnavailableTab(tab: TabState, availability: RightSidebarTabAvailabili
return (
availability.hiddenTabIds?.has(tab.id) === true ||
isUnavailablePluginView(tab, availability) ||
+ isUnavailablePluginTask(tab, availability) ||
(!CINDY_MAKE_ENABLED && tab.kind === 'cindy-make') ||
retiredTab(tab, availability) === null ||
(tab.kind === 'subagents' && !availability.subagentsAvailable)
diff --git a/apps/desktop/src/renderer/features/right-sidebar/types.ts b/apps/desktop/src/renderer/features/right-sidebar/types.ts
index 2684dec6f7..d8e68411a9 100644
--- a/apps/desktop/src/renderer/features/right-sidebar/types.ts
+++ b/apps/desktop/src/renderer/features/right-sidebar/types.ts
@@ -36,7 +36,9 @@ export type BuiltinTabKindId =
| 'resource-usage'
| 'cindy-make'
/** 全局页签(不跟对话):承载插件的 mainView / panel 页面,见 globalTabs.ts。 */
- | 'plugin-view';
+ | 'plugin-view'
+ /** 任务页签(跟对话):承载插件的 taskView 页面,存在各任务自己的页签桶里。 */
+ | 'plugin-task';
export type TabKindId = BuiltinTabKindId | `ghost:${string}`;
/** 一个 tab 运行时实例。`state` 由各 plugin 自管理结构 + 序列化,壳子只搬运。 */
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index c31407ff48..39bd511627 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -6750,6 +6750,8 @@
"panelTab": "Panel \"{{title}}\" · opens inside the Plugins page",
"mainView": "Can add a “{{title}}” entry to Cindy's left navigation",
"mainViewDetail": "Opening it displays the main view in the plugin sandbox and does not grant file, network, or credential access.",
+ "taskView": "Task page “{{title}}” · opens in the task's sidebar",
+ "taskViewDetail": "The tab follows the task and opens in the plugin sandbox; it does not grant file, network, or credential access.",
"code": "Executable code",
"codeDetail": "Runs in an isolated sandbox with no access to your files or network.",
"resident": "Always-on (starts when enabled, keeps a background process even when idle)",
@@ -6907,6 +6909,7 @@
},
"contents": {
"mainView": "Main view",
+ "taskView": "Task page",
"panel": "Panel",
"settingsUi": "Custom settings UI",
"code": "Executable code",
@@ -8241,7 +8244,8 @@
"collaboration": "Team",
"unknown": "Unknown tab",
"ghostPanel": "Plugin panel",
- "pluginView": "Plugin view"
+ "pluginView": "Plugin view",
+ "pluginTask": "Plugin task page"
},
"controls": {
"showAria": "Show sidebar",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index ad6ba33569..d9e0d68ca0 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -6719,6 +6719,8 @@
"panelTab": "パネル「{{title}}」· プラグインページ内で開く",
"mainView": "Cindy の左側ナビゲーションに「{{title}}」への入口を追加できます",
"mainViewDetail": "クリックするとプラグインのサンドボックス内でメインビューが開き、ファイル、ネットワーク、認証情報へのアクセスが追加で付与されることはありません。",
+ "taskView": "タスクページ「{{title}}」· タスクのサイドバーで開く",
+ "taskViewDetail": "タブはタスクに合わせて切り替わり、プラグインのサンドボックス内で開きます。ファイル、ネットワーク、認証情報へのアクセスが追加で付与されることはありません。",
"code": "実行コード",
"codeDetail": "独立したサンドボックスで実行され、ファイルやネットワークにはアクセスできません。",
"resident": "常駐実行(有効化すると起動し、呼び出されなくてもバックグラウンドプロセスを維持)",
@@ -6876,6 +6878,7 @@
},
"contents": {
"mainView": "メインビュー",
+ "taskView": "タスクページ",
"panel": "パネル",
"settingsUi": "カスタム設定画面",
"code": "実行コード",
@@ -8209,7 +8212,8 @@
"collaboration": "コラボ",
"unknown": "不明なタブ",
"ghostPanel": "プラグインパネル",
- "pluginView": "プラグインビュー"
+ "pluginView": "プラグインビュー",
+ "pluginTask": "プラグインのタスクページ"
},
"controls": {
"showAria": "サイドバーを表示",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 988a07ecb4..912403890c 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -6719,6 +6719,8 @@
"panelTab": "패널 \"{{title}}\" · 플러그인 페이지에서 열기",
"mainView": "Cindy 왼쪽 내비게이션에 “{{title}}” 항목을 추가할 수 있음",
"mainViewDetail": "클릭하면 플러그인 샌드박스에서 메인 보기가 열리며 파일, 네트워크 또는 자격 증명 접근 권한이 추가로 부여되지 않습니다.",
+ "taskView": "작업 페이지 “{{title}}” · 작업 사이드바에서 열림",
+ "taskViewDetail": "탭은 작업을 따라 전환되며 플러그인 샌드박스에서 열립니다. 파일, 네트워크 또는 자격 증명 접근 권한이 추가로 부여되지 않습니다.",
"code": "실행 코드",
"codeDetail": "격리된 샌드박스에서 실행되며 파일과 네트워크에 접근할 수 없습니다.",
"resident": "상주 실행(활성화하면 시작되며 호출이 없어도 백그라운드 프로세스 유지)",
@@ -6876,6 +6878,7 @@
},
"contents": {
"mainView": "메인 보기",
+ "taskView": "작업 페이지",
"panel": "패널",
"settingsUi": "사용자 정의 설정 화면",
"code": "실행 코드",
@@ -8209,7 +8212,8 @@
"collaboration": "협업",
"unknown": "알 수 없는 탭",
"ghostPanel": "플러그인 패널",
- "pluginView": "플러그인 보기"
+ "pluginView": "플러그인 보기",
+ "pluginTask": "플러그인 작업 페이지"
},
"controls": {
"showAria": "사이드바 표시",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index aecf8a4fb9..260e8abd9e 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -6719,6 +6719,8 @@
"panelTab": "面板「{{title}}」· 插件页内打开",
"mainView": "可在 Cindy 左侧导航添加“{{title}}”入口",
"mainViewDetail": "点击后将在插件沙箱中打开主视图,不会因此获得文件、网络或凭证访问权限。",
+ "taskView": "任务页「{{title}}」· 在任务的侧边栏打开",
+ "taskViewDetail": "页签跟着任务切换,在插件沙箱中打开,不会因此获得文件、网络或凭证访问权限。",
"code": "可执行代码",
"codeDetail": "在独立沙箱中运行,无法访问你的文件与网络。",
"resident": "常驻运行(生效后即启动,不调用也保持后台进程)",
@@ -6876,6 +6878,7 @@
},
"contents": {
"mainView": "主视图",
+ "taskView": "任务页",
"panel": "面板",
"settingsUi": "自定义设置界面",
"code": "可执行代码",
@@ -8209,7 +8212,8 @@
"collaboration": "协同",
"unknown": "未知标签页",
"ghostPanel": "插件面板",
- "pluginView": "插件视图"
+ "pluginView": "插件视图",
+ "pluginTask": "插件任务页"
},
"controls": {
"showAria": "显示侧栏",
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index 61cff09db1..0dade948f0 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -6719,6 +6719,8 @@
"panelTab": "面板「{{title}}」· 插件頁內開啟",
"mainView": "可在 Cindy 左側導航新增「{{title}}」入口",
"mainViewDetail": "點擊後將在插件沙箱中開啟主視圖,不會因此取得檔案、網路或憑證存取權限。",
+ "taskView": "任務頁「{{title}}」· 在任務的側邊欄開啟",
+ "taskViewDetail": "頁籤隨任務切換,在插件沙箱中開啟,不會因此取得檔案、網路或憑證存取權限。",
"code": "可執行程式碼",
"codeDetail": "在獨立沙箱中執行,無法訪問你的檔案與網路。",
"resident": "常駐執行(生效後即啟動,不呼叫也保持後臺處理程序)",
@@ -6876,6 +6878,7 @@
},
"contents": {
"mainView": "主視圖",
+ "taskView": "任務頁",
"panel": "面板",
"settingsUi": "自定義設定介面",
"code": "可執行程式碼",
@@ -8209,7 +8212,8 @@
"collaboration": "協同",
"unknown": "未知標籤頁",
"ghostPanel": "插件面板",
- "pluginView": "插件視圖"
+ "pluginView": "插件視圖",
+ "pluginTask": "插件任務頁"
},
"controls": {
"showAria": "顯示側欄",
diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.ts
index 3ae6517fc1..ba899a552b 100644
--- a/apps/desktop/src/renderer/lib/makerChatStore.ts
+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts
@@ -228,6 +228,7 @@ import { isSessionUpgrading } from '@/state/ccMgrUpgradeStore';
import { i18n } from '@/i18n';
import { toast } from '@/lib/toast';
import { openUrlInSidebarBrowser } from '@/features/right-sidebar/lib/openInSidebarBrowser';
+import { openPluginTaskTab } from '@/features/right-sidebar/lib/openPluginTaskTab';
import { isSidebarWindow } from '@/lib/sidebarWindow';
import {
extractUsageLimitRecoveryHint,
@@ -9806,6 +9807,23 @@ function initGlobalListeners(options: GlobalListenerOptions = {}): void {
'ghosts-preview-open',
);
+ // ── 插件任务页开页(taskView 槽):main 已做资格审与落点解析,这里只在该任务的
+ // 右侧栏打开 / 聚焦任务页页签。与 preview 同样只由主窗口处理,不抢前台。
+ bindIpc(
+ (cb: (data: unknown, ownerStamp?: unknown) => void) =>
+ window.electronAPI.ghosts?.onTaskViewOpen?.(cb),
+ (raw: unknown, ownerStamp?: unknown) => {
+ if (!isCurrentLocalLiveIngress(ownerStamp)) return;
+ if (isSidebarWindow()) return;
+ const p = raw as { instanceId?: unknown; sessionId?: unknown } | null;
+ if (!p || typeof p.instanceId !== 'string' || typeof p.sessionId !== 'string') return;
+ void openPluginTaskTab(p.sessionId, p.instanceId, { userInitiated: false }).catch(() => {
+ /* 标签落地失败(任务桶异常等)不致命,静默 */
+ });
+ },
+ 'ghosts-task-view-open',
+ );
+
// ── 后台活动熄灭 → stale running 对账(终态事件丢失的自动自愈)──
// 数据源与 sessionBackgroundActivityStore 同一广播;这里只做调度,拉取与
// 收口逻辑在 scheduleBackgroundTaskReconcile。仅本机会话:device-link 镜像
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index ac6e53c1d8..269fcfab89 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -1581,6 +1581,10 @@ interface ElectronAPI {
) => () => void;
/** confirm 槽回包:把用户的点击送回 main 结算挂起的管子请求。 */
resolveConfirm: (requestId: string, confirmed: boolean) => Promise<{ handled: boolean }>;
+ /** taskView 槽:插件请求在指定任务的右侧栏打开 / 聚焦它的任务页页签(main 已资格审)。 */
+ onTaskViewOpen: (
+ callback: (payload: { instanceId: string; sessionId: string }) => void,
+ ) => () => void;
/** preview 槽:插件请求在右侧栏内置浏览器开预览标签(main 已白名单守门+限速)。 */
onPreviewOpen: (
callback: (payload: {
diff --git a/apps/desktop/src/shared/__tests__/ghost.test.ts b/apps/desktop/src/shared/__tests__/ghost.test.ts
index c1165093fd..632615e003 100644
--- a/apps/desktop/src/shared/__tests__/ghost.test.ts
+++ b/apps/desktop/src/shared/__tests__/ghost.test.ts
@@ -22,6 +22,7 @@ import {
ghostUnknownV3FieldsWithinCap,
ghostNetworkHostMatches,
ghostPanelKind,
+ ghostPanelLoopbackEmbedAllowed,
ghostPermissionBaselineKey,
ghostPreviewUrlAllowed,
parseGhostNodeChildToHostMessage,
@@ -2361,6 +2362,38 @@ describe('ghost · panel.position 校验', () => {
expect(validateGhostManifest(withView({ multiple: 'yes' })).ok).toBe(false);
});
+ // - 生产入口与可观察结果:validateGhostManifest / 本地化 / 入口白名单 / 权限差异对 taskView 的处理。
+ // - Bug / 规则依据:插件可声明跟对话的任务页(按任务存在右侧栏,随任务切换)。
+ // - 现有覆盖缺口:taskView 是新字段。
+ // - 最小失败输入:taskView.html 缺失、与 slot 不成对。
+ // - tier:unit。
+ it('taskView:合法声明保留并放行入口、本地化标题、作为新增能力;html 缺失或与槽不成对都拒', () => {
+ const withTask = (taskView: unknown, slots = ['panel', 'task-view']) => ({
+ ...goodChipManifest(),
+ minCindyVersion: '1.2.3',
+ slots,
+ taskView,
+ });
+ const ok = validateGhostManifest(withTask({ title: '模拟器', html: 'task.html' }));
+ expect(ok).toMatchObject({ ok: true, manifest: { taskView: { title: '模拟器', html: 'task.html' } } });
+ if (!ok.ok) throw new Error('expected a valid manifest');
+ expect(ghostWebviewEntryPaths(ok.manifest)).toContain('/task.html');
+ expect(diffGhostPermissionItems({ ...ok.manifest, taskView: undefined }, ok.manifest).added).toEqual([
+ expect.objectContaining({ key: 'task-view', kind: 'task-view', labelKey: 'taskView' }),
+ ]);
+ const locale = validateGhostManifestLocaleResource({ taskView: { title: 'Simulator' } }, ok.manifest);
+ expect(locale.ok && resolveGhostManifestLocale(ok.manifest, locale.resource).taskView?.title).toBe('Simulator');
+
+ // 声明任务页 + node + 回环预览的插件,其页面可嵌入自己的本机画面;缺 node 就不行。
+ const embed = { ...ok.manifest, node: { entry: 'node/worker.cjs', protocol: 'json-rpc-stdio' as const }, preview: { hosts: ['127.0.0.1'] } };
+ expect(ghostPanelLoopbackEmbedAllowed({ ...embed, panel: undefined })).toBe(true);
+ expect(ghostPanelLoopbackEmbedAllowed({ ...embed, panel: undefined, node: undefined })).toBe(false);
+ expect(validateGhostManifest(withTask({ title: '模拟器' })).ok).toBe(false);
+ expect(validateGhostManifest(withTask({ html: '../task.html' })).ok).toBe(false);
+ expect(validateGhostManifest(withTask({ html: 'task.html' }, ['panel'])).ok).toBe(false);
+ expect(validateGhostManifest(withTask(undefined, ['panel', 'task-view'])).ok).toBe(false);
+ });
+
it("'tab'(右侧栏页签)通过;tab 时 minWidth/defaultFraction 收词明确拒绝", () => {
const tab = validateGhostManifest({
...goodManifest(),
diff --git a/apps/desktop/src/shared/ghost.ts b/apps/desktop/src/shared/ghost.ts
index 5be9470341..fd27558735 100644
--- a/apps/desktop/src/shared/ghost.ts
+++ b/apps/desktop/src/shared/ghost.ts
@@ -109,6 +109,8 @@ const GHOST_ID_RE = /^[a-z0-9][a-z0-9-]{0,31}$/;
* 'main-view' = 应用级插件主视图:宿主从已批准 manifest 解析包内
* HTML 入口,并提供 Cindy 一级侧边栏与路由。它与会话内 panel
* 独立授权,本身不附赠网络、文件或凭证能力。
+ * 'task-view' = 跟对话的任务页:页签存在各任务的右侧栏里,随任务切换;与
+ * main-view 同一 WebView 沙箱,本身不附赠网络、文件或凭证能力。
* 'library' = 持久作品库(2026-08-20):用户作品级存储(画布/素材/数据库),
* 与 'fs' 私有储物柜(配额封顶、卸载回收)语义不同:不受 ghost-fs 配额约束,
* 卸载插件**不删**(标 orphaned,删除必须走设置页独立确认)。字节与 SQL
@@ -152,6 +154,7 @@ const LEGACY_GHOST_SLOTS = [
'card',
'panel',
'main-view',
+ 'task-view',
'cindy',
'agent',
'node',
@@ -515,6 +518,18 @@ export interface GhostMainViewDecl {
multiple?: true;
}
+/**
+ * 跟对话的任务页(taskView):插件在每个任务右侧栏里的页面。页签存在该任务里,
+ * 切换任务时随任务切换;页签头由 Cindy 绘制,没有地址栏。页面经 URL 查询参数
+ * `session` 得知自己所在的任务,逻辑页经 `cindy.taskView({sessionId})` 打开或聚焦它。
+ */
+export interface GhostTaskViewDecl {
+ /** 页签标题;缺省回退插件 name。 */
+ title?: string;
+ /** 任务页入口(安装目录内安全相对路径)。 */
+ html: string;
+}
+
/**
* 芯片型意识注册给 agent 的工具声明(卡槽②)。
* 声明式而非运行时动态注册(规则 9:确定性;且会话中途增删工具会破坏
@@ -1182,13 +1197,14 @@ export function ghostLoopbackOrigin(rawUrl: unknown): string | null {
}
/**
- * 停靠面板能否嵌入本机回环预览页:身份卡必须同时声明 panel、node 工作进程
+ * 插件页面能否嵌入本机回环预览页:身份卡必须同时声明一种页面(panel / mainView /
+ * taskView)、node 工作进程
* (页面由随包进程在本机提供)以及 preview.hosts 中的 localhost / 127.0.0.1。
* 满足时主机放行面板内指向回环地址的子帧,以及该子帧回到同一主机:端口的请求;
* 面板页自身仍不能联网。
*/
export function ghostPanelLoopbackEmbedAllowed(manifest: GhostManifest): boolean {
- if (!manifest.panel || !manifest.node) return false;
+ if (!(manifest.panel || manifest.mainView || manifest.taskView) || !manifest.node) return false;
return (manifest.preview?.hosts ?? []).some((host) => host === 'localhost' || host === '127.0.0.1');
}
@@ -1598,6 +1614,8 @@ export interface GhostManifest {
panel?: GhostPanelDecl;
/** 应用级主视图声明;v3 直接声明,v2 与 `main-view` slot 成对。 */
mainView?: GhostMainViewDecl;
+ /** 跟对话的任务页声明;v3 直接声明,v2 与 `task-view` slot 成对。 */
+ taskView?: GhostTaskViewDecl;
/** 无配置的 Host 能力只接受字面量 true;不需要时省略。 */
notify?: true;
badge?: true;
@@ -1635,6 +1653,7 @@ export interface GhostManifestLocaleResource {
>;
panel?: { title: string };
mainView?: { title: string };
+ taskView?: { title: string };
network?: {
secrets?: Record<string, { label: string; hint?: string }>;
connections?: Record<string, { label: string; hint?: string }>;
@@ -1771,6 +1790,7 @@ export function ghostPanelKind(id: string): `ghost:${string}` {
export function ghostContentKeys(manifest: GhostManifest): string[] {
const keys: string[] = [];
if (manifest.mainView) keys.push('mainView');
+ if (manifest.taskView) keys.push('taskView');
if (manifest.panel) keys.push('panel');
if (manifest.settingsHtml) keys.push('settingsUi');
keys.push('code');
@@ -1890,6 +1910,7 @@ export interface GhostPermissionItem {
| 'command'
| 'panel'
| 'main-view'
+ | 'task-view'
| 'code'
| 'subscribe'
| 'card'
@@ -2330,6 +2351,15 @@ export function ghostPermissionItems(manifest: GhostManifest): GhostPermissionIt
detailKey: 'mainViewDetail',
});
}
+ if (manifest.taskView) {
+ items.push({
+ key: 'task-view',
+ kind: 'task-view',
+ labelKey: 'taskView',
+ labelArgs: { title: manifest.taskView.title ?? manifest.name },
+ detailKey: 'taskViewDetail',
+ });
+ }
if (manifest.routineEvents) {
items.push({ key: 'routine-events', kind: 'subscribe', labelKey: 'routineEvents', detail: manifest.routineEvents.events.map((event) => `${event.name} (${event.type}: ${event.fields.join(", ")})`).join(', ') });
}
@@ -2984,7 +3014,7 @@ function isPortableGhostRelativePath(p: unknown): p is string {
/**
* 意识 webview 允许附加的入口 pathname 白名单(attach 闸的可测真身):
- * 面板 panel.html、主视图 mainView.html 与设置区 settingsHtml,声明哪个放行哪个;
+ * 面板 panel.html、主视图 mainView.html、任务页 taskView.html 与设置区 settingsHtml,声明哪个放行哪个;
* 多个能力指向同一
* 文件时去重。空数组 = 该意识没有任何可附加的自绘界面,闸口一律拒。
*/
@@ -2995,6 +3025,10 @@ export function ghostWebviewEntryPaths(manifest: GhostManifest): string[] {
const p = `/${manifest.mainView.html}`;
if (!paths.includes(p)) paths.push(p);
}
+ if (manifest.taskView?.html) {
+ const p = `/${manifest.taskView.html}`;
+ if (!paths.includes(p)) paths.push(p);
+ }
if (manifest.settingsHtml) {
const p = `/${manifest.settingsHtml}`;
if (!paths.includes(p)) paths.push(p);
@@ -3058,6 +3092,7 @@ const GHOST_MANIFEST_KNOWN_TOP_LEVEL_FIELDS = new Set([
'keywords',
'panel',
'mainView',
+ 'taskView',
'notify',
'badge',
'confirm',
@@ -3088,6 +3123,7 @@ const V3_DECLARATION_TO_LEGACY_SLOT = [
['card', 'card'],
['panel', 'panel'],
['mainView', 'main-view'],
+ ['taskView', 'task-view'],
['subscribe', 'subscribe'],
['skill', 'skill'],
['cindy', 'cindy'],
@@ -3387,6 +3423,7 @@ export function validateGhostManifestLocaleResource(
'tools',
'panel',
'mainView',
+ 'taskView',
'network',
'node',
'setup',
@@ -3602,6 +3639,37 @@ export function validateGhostManifestLocaleResource(
mainView = { title: raw.mainView.title };
}
+ let taskView: GhostManifestLocaleResource['taskView'];
+ if (raw.taskView !== undefined) {
+ if (manifest.taskView?.title === undefined) {
+ return {
+ ok: false,
+ reason: 'locale.taskView 不应存在:原 manifest 未声明 taskView.title',
+ };
+ }
+ if (!isPlainObject(raw.taskView)) {
+ return { ok: false, reason: 'locale.taskView 必须是含 title 的对象' };
+ }
+ const unknownTaskViewField = Object.keys(raw.taskView).find((field) => field !== 'title');
+ if (unknownTaskViewField) {
+ return {
+ ok: false,
+ reason: `locale.taskView 含未知字段 ${JSON.stringify(unknownTaskViewField)}`,
+ };
+ }
+ if (
+ typeof raw.taskView.title !== 'string' ||
+ raw.taskView.title.trim().length === 0 ||
+ raw.taskView.title.length > 64
+ ) {
+ return {
+ ok: false,
+ reason: 'locale.taskView.title 必须是 1–64 字符的非空字符串',
+ };
+ }
+ taskView = { title: raw.taskView.title };
+ }
+
const validateLocalizedLabels = (
rawValue: unknown,
fieldPath: string,
@@ -3766,6 +3834,7 @@ export function validateGhostManifestLocaleResource(
...(raw.mail === true ? { mail: true as const } : {}),
...(panel !== undefined ? { panel } : {}),
...(mainView !== undefined ? { mainView } : {}),
+ ...(taskView !== undefined ? { taskView } : {}),
...(network !== undefined ? { network } : {}),
...(node !== undefined ? { node } : {}),
...(setup !== undefined ? { setup } : {}),
@@ -3807,6 +3876,9 @@ export function resolveGhostManifestLocale(
...(manifest.mainView !== undefined && resource.mainView !== undefined
? { mainView: { ...manifest.mainView, title: resource.mainView.title } }
: {}),
+ ...(manifest.taskView !== undefined && resource.taskView !== undefined
+ ? { taskView: { ...manifest.taskView, title: resource.taskView.title } }
+ : {}),
...(manifest.network !== undefined && resource.network !== undefined
? {
network: {
@@ -3922,6 +3994,7 @@ function validateGhostManifestInput(value: unknown, preserveHistoricalTasks: boo
raw.settingsHtml,
isPlainObject(raw.panel) ? raw.panel.html : undefined,
isPlainObject(raw.mainView) ? raw.mainView.html : undefined,
+ isPlainObject(raw.taskView) ? raw.taskView.html : undefined,
isPlainObject(raw.node) ? raw.node.entry : undefined,
...(isPlainObject(raw.node) && Array.isArray(raw.node.entries) ? raw.node.entries : []),
]
@@ -4175,6 +4248,29 @@ function validateGhostManifestInput(value: unknown, preserveHistoricalTasks: boo
};
}
+ let taskView: GhostTaskViewDecl | undefined;
+ if (raw.taskView !== undefined) {
+ if (!isPlainObject(raw.taskView)) {
+ return { ok: false, reason: 'taskView 必须是对象' };
+ }
+ if (
+ raw.taskView.title !== undefined &&
+ (typeof raw.taskView.title !== 'string' ||
+ raw.taskView.title.trim().length === 0 ||
+ raw.taskView.title.length > 64)
+ ) {
+ return { ok: false, reason: 'taskView.title 必须是 1–64 字符的非空字符串' };
+ }
+ if (!isPortableGhostRelativePath(raw.taskView.html)) {
+ return { ok: false, reason: 'taskView.html 必填,且必须是安装目录内的安全相对路径' };
+ }
+ taskView = {
+ ...unknownDeclarationFields(raw.taskView, ['html', 'title']),
+ ...(raw.taskView.title !== undefined ? { title: raw.taskView.title } : {}),
+ html: raw.taskView.html,
+ };
+ }
+
if (!isSafeGhostRelativePath(raw.entry)) {
return { ok: false, reason: '必须提供 entry(安装目录内的安全相对路径,电子脑逻辑入口)' };
}
@@ -4240,6 +4336,12 @@ function validateGhostManifestInput(value: unknown, preserveHistoricalTasks: boo
reason: 'slots 声明了 "main-view" 但缺少 mainView(html 必填)',
};
}
+ if (taskView !== undefined && !slots.includes('task-view')) {
+ return { ok: false, reason: '声明了 taskView 但 slots 未包含 "task-view"' };
+ }
+ if (slots.includes('task-view') && taskView === undefined) {
+ return { ok: false, reason: 'slots 声明了 "task-view" 但缺少 taskView(html 必填)' };
+ }
// card 槽详单:有详单必有槽;有槽无详单 = 纯渲染卡片(默认行为,向后兼容)。
let card: GhostCardNeeds | undefined;
@@ -6150,6 +6252,7 @@ function validateGhostManifestInput(value: unknown, preserveHistoricalTasks: boo
...(keywords !== undefined ? { keywords } : {}),
...(panel !== undefined ? { panel } : {}),
...(mainView !== undefined ? { mainView } : {}),
+ ...(taskView !== undefined ? { taskView } : {}),
},
unsupportedLegacySlots: prepared.unsupportedLegacySlots,
};
@@ -6841,6 +6944,18 @@ export type GhostPipePreviewResult =
message: string;
};
+/**
+ * 任务页开页结果(`cindy.taskView`)。成功时带上实际落点任务:请求不指定任务时
+ * 主机落到台前任务,插件据此把自己的业务状态(如设备)绑定到该任务。
+ */
+export type GhostPipeTaskViewResult =
+ | { ok: true; sessionId: string }
+ | {
+ ok: false;
+ errorCode: 'PERMISSION_DENIED' | 'INVALID_REQUEST' | 'HOST_NOT_READY' | 'INTERNAL';
+ message: string;
+ };
+
/**
* schedule-request(agent.schedule 加档)的上行载荷。
*
diff --git a/apps/desktop/src/shared/rightSidebarWindow.ts b/apps/desktop/src/shared/rightSidebarWindow.ts
index 539c799587..d8e06f8f52 100644
--- a/apps/desktop/src/shared/rightSidebarWindow.ts
+++ b/apps/desktop/src/shared/rightSidebarWindow.ts
@@ -42,6 +42,8 @@ export interface RsbWindowContext {
/** main → 子窗口的命令推送(如主窗终端快捷键转发 / detached RSB 内定位文件)。 */
export type RsbWindowCommand =
| { type: 'open-routines-tab'; sessionId: string; botId: string }
+ /** 打开 / 聚焦插件任务页(taskView):instanceId 是已装插件实例的存储键。 */
+ | { type: 'open-plugin-task'; sessionId: string; instanceId: string }
| { type: 'open-terminal'; sessionId: string }
| { type: 'toggle-review-tab'; sessionId: string }
| { type: 'open-web-browser'; sessionId: string; url: string }
diff --git a/docs/dev-rules/plugin-security-and-authoring.md b/docs/dev-rules/plugin-security-and-authoring.md
index 297e685d9e..9634472f9a 100644
--- a/docs/dev-rules/plugin-security-and-authoring.md
+++ b/docs/dev-rules/plugin-security-and-authoring.md
@@ -126,7 +126,7 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开
- 新插件统一使用 `schemaVersion: 3`,并填写插件实际依赖的首个 Cindy 正式版本作为
`minCindyVersion`。Manifest schema 不设置统一的 Cindy 版本下限;具体版本只属于插件包元数据。
v3 **没有** `slots`;
- `tools`、`card`、`panel`、`mainView`、`subscribe`、`skill`、`cindy`、`agent`、`node`、`network`、
+ `tools`、`card`、`panel`、`mainView`、`taskView`、`subscribe`、`skill`、`cindy`、`agent`、`node`、`network`、
`preview` 等顶层字段本身就是插件贡献项或自主 Host 能力的直接声明。
- 无配置的布尔能力只接受字面量 `true`:`notify`、`badge`、`confirm`、`fs`、`library`、
`sessionContext`、`pick`、`workspace`。不用就省略,写 `false` 是无效清单。
@@ -555,15 +555,16 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开
`ghost_call.attachments` 显式交接;Host 复用已有的通用授权链,将授权后的指纹注入
`args.attachments`,绝不把本地绝对路径暴露给插件。插件自行保存业务状态和更新 UI。
Host 不自动回调插件,也不得新增画廊等插件业务语义。
-- 回环嵌入是第二个、也是更窄的页面网络例外:插件同时声明 `panel`、`node` 工作进程和
- `preview.hosts` 中的 `localhost` / `127.0.0.1` 时(`ghostPanelLoopbackEmbedAllowed`),
+- 回环嵌入是第二个、也是更窄的页面网络例外:插件同时声明一种自绘页面(`panel`、`mainView`
+ 或 `taskView`)、`node` 工作进程和 `preview.hosts` 中的 `localhost` / `127.0.0.1` 时
+ (`ghostPanelLoopbackEmbedAllowed`),
其页面 CSP 追加 `frame-src 'self' http://127.0.0.1:* http://localhost:*`,分区请求闸放行
- 三类请求:面板页作为父帧发起的回环子帧导航;该子帧内部再套一层、**父帧与目标同
+ 三类请求:插件页面作为父帧发起的回环子帧导航;该子帧内部再套一层、**父帧与目标同
主机:端口**的子帧(本机页面自己的分层结构);该子帧内回到**同一主机:端口**的资源、
XHR 与 WebSocket。面板页自身发出的回环 fetch/XHR、顶层导航到回环地址、换端口或换主机
的请求、带凭证的 URL 与 HTTPS 伪装一律继续拒绝。嵌入页由插件自己的随包 Node 进程在
本机提供,因此不扩大插件可达的网络范围;权限请求处理器不变(嵌入页不能申请摄像头、
- 定位等权限)。首个消费者是官方 `baguette-simulator`(iOS 模拟器停靠面板)。
+ 定位等权限)。首个消费者是官方 `baguette-simulator`(iOS 模拟器的任务页与管理主视图)。
- 所有插件 HTML 页面(`settingsHtml`、panel、mainView 与逻辑页)都可以通过 `<img>` 或
CSS 图片直接加载任意 HTTPS 地址,这是唯一的页面网络直连例外。Host 统一生成包含
`img-src https:` 的 CSP,并由 owner × plugin session 请求闸把外部请求严格限定为
@@ -748,6 +749,15 @@ Library 请求同时绑定迁移代次和安装批准,根解析、排队及开
3. 内置 `cindy-plugin-creator/references/` 的对应章节(兼容导出为 `FORGE_GUIDE`)及 Forge 测试。
`mainView` 的现行协议在 `FORGE_GUIDE` §4.20;v2 的 `main-view` 只保留输入兼容。
+
+`taskView`(跟对话的任务页)的现行协议在 `FORGE_GUIDE` §4.22;v2 对应 `task-view` 槽。
+任务页页签(右侧栏 kind `plugin-task`)存在各任务自己的页签桶里,随任务切换;页面与
+panel / mainView 同一 Ghost WebView 沙箱(零桥、专属分区),只经查询参数 `session`
+得知所在任务。逻辑页经 `cindy.taskView({sessionId?})`(管子 `task-view-request`)打开或
+聚焦它:只承载包内页面、不收网址,因此不设 preview 式白名单与限速;Host 只做资格审
+(已装、启用、声明 taskView)与落点解析(显式任务优先,缺省台前任务),回执带回落点
+任务。远程任务不投影本机插件的任务页;插件停用、卸载或不再声明 taskView 时页签隐藏。
+旧版 Host 把 `taskView` 当未知字段保留并忽略,插件需判断 `cindy.taskView` 是否存在后再用。
`mainView.icon` 只接受 Cindy 系统线性图标
`puzzle`、`globe`、`code`、`folder`、`database`、`chart-column`、`image`、
`message-circle`、`calendar-days`,缺省回退 `puzzle`。枚举值直接等于图标名,不设别名;
diff --git a/packages/plugin-protocol/src/__tests__/manifest.forward-compat.test.ts b/packages/plugin-protocol/src/__tests__/manifest.forward-compat.test.ts
index 22d6dd80f0..ea8912ae3c 100644
--- a/packages/plugin-protocol/src/__tests__/manifest.forward-compat.test.ts
+++ b/packages/plugin-protocol/src/__tests__/manifest.forward-compat.test.ts
@@ -11,6 +11,7 @@ describe('declaration forward compatibility is not Host authorization', () => {
it.each([
['mobile', { channels: ['practice-ui'], panel: 'mobile/panel.html' }],
['mainView', { html: 'view.html' }],
+ ['taskView', { html: 'task.html' }],
['panel', { html: 'panel.html' }],
['card', {}],
['agent', {}],
diff --git a/packages/plugin-protocol/src/__tests__/manifest.test.ts b/packages/plugin-protocol/src/__tests__/manifest.test.ts
index c3404e45bd..71ed06f8e2 100644
--- a/packages/plugin-protocol/src/__tests__/manifest.test.ts
+++ b/packages/plugin-protocol/src/__tests__/manifest.test.ts
@@ -991,6 +991,26 @@ describe('Ghost manifest contract', () => {
}
});
+ // 跟对话的任务页:v3 直接声明保留;v2 必须与 task-view 槽成对;入口路径与 mainView 同一套安全约束。
+ it('accepts direct v3 taskView, pairs v2 task-view, and rejects unsafe or missing entries', () => {
+ const direct = {
+ schemaVersion: 3,
+ minCindyVersion: '1.2.3',
+ id: 'direct-task-view',
+ name: 'Direct Task View',
+ version: '1.0.0',
+ entry: 'index.js',
+ taskView: { title: 'Simulator', html: 'ui/task.html' },
+ } as const;
+ expect(validateGhostManifest(direct)).toMatchObject({ ok: true, manifest: { taskView: direct.taskView } });
+ expect(validateGhostManifest({ ...direct, taskView: { html: '../task.html' } }).ok).toBe(false);
+ expect(validateGhostManifest({ ...direct, taskView: { title: 'Simulator' } }).ok).toBe(false);
+ const v2 = { ...validManifest, minCindyVersion: '1.2.3', slots: ['task-view'], tools: undefined, taskView: { html: 'task.html' } };
+ expect(validateGhostManifest(JSON.parse(JSON.stringify(v2)))).toMatchObject({ ok: true });
+ expect(validateGhostManifest({ ...v2, slots: [] }).ok).toBe(false);
+ expect(validateGhostManifest({ ...v2, taskView: undefined }).ok).toBe(false);
+ });
+
it('accepts direct v3 mainView and round-trips v2 main-view compatibility', () => {
const direct = {
schemaVersion: 3,
diff --git a/packages/plugin-protocol/src/manifest.ts b/packages/plugin-protocol/src/manifest.ts
index 4988cc0b01..735485a184 100644
--- a/packages/plugin-protocol/src/manifest.ts
+++ b/packages/plugin-protocol/src/manifest.ts
@@ -57,6 +57,8 @@ function isWindowsReservedName(name: string): boolean {
* 'main-view' = 应用级插件主视图:宿主只挂载已批准 manifest 声明的包内
* HTML 入口。它与会话内 panel 独立授权,本身不附赠网络、文件或
* 凭证能力。
+ * 'task-view' = 跟对话的任务页:页签存在各任务的右侧栏里、随任务切换;与
+ * main-view 同一 WebView 沙箱,本身不附赠网络、文件或凭证能力。
* 'session-context' = 会话上下文(2026-07-23):agent 派活(tool-call)时,主机把
* 当次会话的可信 {session_id, workdir, workdir_is_local} 注入 args.session_context。
* 只注入宿主认证过的事实,插件与 agent 自报的同名字段一律被剥除;远程工作区
@@ -93,6 +95,7 @@ export const LEGACY_GHOST_SLOTS = [
'card',
'panel',
'main-view',
+ 'task-view',
'cindy',
'agent',
'node',
@@ -186,6 +189,14 @@ export interface GhostMainViewDecl {
multiple?: true;
}
+/** 跟对话的任务页:页签存在各任务的右侧栏里,随任务切换;页面经查询参数 `session` 得知所在任务。 */
+export interface GhostTaskViewDecl {
+ /** 页签标题;缺省回退插件 name。 */
+ title?: string;
+ /** 任务页入口(安装目录内安全相对路径)。 */
+ html: string;
+}
+
/**
* 芯片型意识注册给 agent 的工具声明(卡槽②)。
* 声明式而非运行时动态注册(规则 9:确定性;且会话中途增删工具会破坏
@@ -991,6 +1002,8 @@ export interface GhostManifest {
panel?: GhostPanelDecl;
/** 应用级主视图声明;v3 直接声明,v2 与 `main-view` slot 成对。 */
mainView?: GhostMainViewDecl;
+ /** 跟对话的任务页声明;v3 直接声明,v2 与 `task-view` slot 成对。 */
+ taskView?: GhostTaskViewDecl;
/**
* preview 能力详单;v2 与 'preview' slot 成对。可在右侧栏内置浏览器
* 打开预览标签页的域名白名单。
@@ -1209,6 +1222,7 @@ const GHOST_MANIFEST_KNOWN_TOP_LEVEL_FIELDS = new Set([
'keywords',
'panel',
'mainView',
+ 'taskView',
'preview',
'skill',
'manual',
@@ -1243,6 +1257,7 @@ const V3_DECLARATION_TO_LEGACY_SLOT = [
['card', 'card'],
['panel', 'panel'],
['mainView', 'main-view'],
+ ['taskView', 'task-view'],
['subscribe', 'subscribe'],
['skill', 'skill'],
['cindy', 'cindy'],
@@ -1423,6 +1438,7 @@ export function validateGhostManifest(value: unknown): ManifestValidation {
raw.settingsHtml,
isPlainObject(raw.panel) ? raw.panel.html : undefined,
isPlainObject(raw.mainView) ? raw.mainView.html : undefined,
+ isPlainObject(raw.taskView) ? raw.taskView.html : undefined,
isPlainObject(raw.node) ? raw.node.entry : undefined,
...(isPlainObject(raw.node) && Array.isArray(raw.node.entries) ? raw.node.entries : []),
]
@@ -1686,6 +1702,29 @@ export function validateGhostManifest(value: unknown): ManifestValidation {
};
}
+ let taskView: GhostTaskViewDecl | undefined;
+ if (raw.taskView !== undefined) {
+ if (!isPlainObject(raw.taskView)) {
+ return { ok: false, reason: 'taskView 必须是对象' };
+ }
+ if (
+ raw.taskView.title !== undefined &&
+ (typeof raw.taskView.title !== 'string' ||
+ raw.taskView.title.trim().length === 0 ||
+ raw.taskView.title.length > 64)
+ ) {
+ return { ok: false, reason: 'taskView.title 必须是 1–64 字符的非空字符串' };
+ }
+ if (!isSafeGhostRelativePath(raw.taskView.html)) {
+ return { ok: false, reason: 'taskView.html 必填,且必须是安装目录内的安全相对路径' };
+ }
+ taskView = {
+ ...unknownDeclarationFields(raw.taskView, ['html', 'title']),
+ ...(raw.taskView.title !== undefined ? { title: raw.taskView.title } : {}),
+ html: raw.taskView.html,
+ };
+ }
+
if (!isSafeGhostRelativePath(raw.entry)) {
return {
ok: false,
@@ -1760,6 +1799,12 @@ export function validateGhostManifest(value: unknown): ManifestValidation {
reason: 'slots 声明了 "main-view" 但缺少 mainView(html 必填)',
};
}
+ if (taskView !== undefined && !slots.includes('task-view')) {
+ return { ok: false, reason: '声明了 taskView 但 slots 未包含 "task-view"' };
+ }
+ if (slots.includes('task-view') && taskView === undefined) {
+ return { ok: false, reason: 'slots 声明了 "task-view" 但缺少 taskView(html 必填)' };
+ }
if (slots.includes('badge') && panel === undefined) {
return {
ok: false,
@@ -3846,6 +3891,7 @@ export function validateGhostManifest(value: unknown): ManifestValidation {
...(keywords !== undefined ? { keywords } : {}),
...(panel !== undefined ? { panel } : {}),
...(mainView !== undefined ? { mainView } : {}),
+ ...(taskView !== undefined ? { taskView } : {}),
...(preview !== undefined ? { preview } : {}),
...(skill !== undefined ? { skill } : {}),
...(prepared.schemaVersion === 3 && slots.includes('notify') ? { notify: true as const } : {}),