Files
agent-radar 2ed3415fb7
Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
源码快照 @ 2026-09-01 (source-only, 剔除非源码素材)
2026-09-01 20:17:27 +08:00

108 lines
2.7 KiB
TypeScript

export const AGENT_GUI_WORKBENCH_COMMAND_EVENT =
"tutti:agent-gui-workbench-command";
export type AgentGuiWorkbenchSessionAction =
| "rename"
| "copy-markdown"
| "copy-reference";
const agentGuiWorkbenchSessionActions: readonly AgentGuiWorkbenchSessionAction[] =
["rename", "copy-markdown", "copy-reference"];
export function isAgentGuiWorkbenchSessionAction(
value: unknown
): value is AgentGuiWorkbenchSessionAction {
return agentGuiWorkbenchSessionActions.includes(
value as AgentGuiWorkbenchSessionAction
);
}
export type AgentGuiWorkbenchCommand =
| {
type: "new-conversation";
instanceId: string;
}
| {
type: "conversation-rail-toggle";
conversationRailCollapsed: boolean;
instanceId: string;
}
| {
type: "session-action";
action: AgentGuiWorkbenchSessionAction;
agentSessionId: string | null;
instanceId: string;
};
export interface AgentGuiWorkbenchCommandBridge {
instanceId: string;
onConversationRailToggle?(conversationRailCollapsed: boolean): void;
}
export function normalizeAgentGuiWorkbenchCommand(
value: unknown
): AgentGuiWorkbenchCommand | null {
if (!value || typeof value !== "object") {
return null;
}
const command = value as {
action?: unknown;
agentSessionId?: unknown;
conversationRailCollapsed?: unknown;
instanceId?: unknown;
type?: unknown;
};
if (typeof command.instanceId !== "string" || !command.instanceId.trim()) {
return null;
}
if (command.type === "new-conversation") {
return {
type: "new-conversation",
instanceId: command.instanceId
};
}
if (command.type === "conversation-rail-toggle") {
return typeof command.conversationRailCollapsed === "boolean"
? {
type: "conversation-rail-toggle",
conversationRailCollapsed: command.conversationRailCollapsed,
instanceId: command.instanceId
}
: null;
}
if (
command.type !== "session-action" ||
!isAgentGuiWorkbenchSessionAction(command.action)
) {
return null;
}
return {
type: "session-action",
action: command.action,
agentSessionId:
typeof command.agentSessionId === "string" &&
command.agentSessionId.trim()
? command.agentSessionId.trim()
: null,
instanceId: command.instanceId
};
}
export function dispatchAgentGuiWorkbenchCommand(
command: AgentGuiWorkbenchCommand
): void {
window.dispatchEvent(
new CustomEvent<AgentGuiWorkbenchCommand>(
AGENT_GUI_WORKBENCH_COMMAND_EVENT,
{ detail: command }
)
);
}
export interface AgentGuiWorkbenchSessionMenuCopy {
moreSessionActions: string;
renameSession: string;
copyAsMarkdown: string;
copyAsReference: string;
}