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
75 lines
1.8 KiB
TypeScript
75 lines
1.8 KiB
TypeScript
import { parseRichTextMentionHref } from "@tutti-os/ui-rich-text/core";
|
|
import { resolveWebsiteNavigationUrl } from "../shared/utils/websiteUrl";
|
|
|
|
export type WorkspaceLinkActionSource =
|
|
| "agent-markdown"
|
|
| "agent-file-change"
|
|
| string;
|
|
|
|
export const AGENT_EXTERNAL_LINK_ACTION_SOURCE = "agent-external-action";
|
|
|
|
export interface OpenWorkspaceUrlLinkAction {
|
|
type: "open-url";
|
|
url: string;
|
|
source: WorkspaceLinkActionSource;
|
|
}
|
|
|
|
export interface OpenAgentSessionLinkAction {
|
|
type: "open-agent-session";
|
|
workspaceId: string;
|
|
agentSessionId: string;
|
|
agentTargetId?: string | null;
|
|
source: WorkspaceLinkActionSource;
|
|
}
|
|
|
|
export interface ResolveWorkspaceUrlLinkActionInput {
|
|
url: string;
|
|
source: WorkspaceLinkActionSource;
|
|
}
|
|
|
|
export interface ResolveAgentSessionMentionLinkActionInput {
|
|
href: string;
|
|
source: WorkspaceLinkActionSource;
|
|
}
|
|
|
|
export function resolveWorkspaceUrlLinkAction({
|
|
url,
|
|
source
|
|
}: ResolveWorkspaceUrlLinkActionInput): OpenWorkspaceUrlLinkAction | null {
|
|
const resolved = resolveWebsiteNavigationUrl(url);
|
|
if (!resolved.url || resolved.error) {
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
type: "open-url",
|
|
url: resolved.url,
|
|
source
|
|
};
|
|
}
|
|
|
|
export function resolveAgentSessionMentionLinkAction({
|
|
href,
|
|
source
|
|
}: ResolveAgentSessionMentionLinkActionInput): OpenAgentSessionLinkAction | null {
|
|
const mention = parseRichTextMentionHref(href, "");
|
|
if (!mention || mention.providerId !== "agent-session") {
|
|
return null;
|
|
}
|
|
|
|
const workspaceId = mention.scope?.workspaceId?.trim() || "";
|
|
const agentSessionId = mention.entityId.trim();
|
|
if (!workspaceId || !agentSessionId) {
|
|
return null;
|
|
}
|
|
|
|
const agentTargetId = mention.scope?.agentTargetId?.trim() || null;
|
|
return {
|
|
type: "open-agent-session",
|
|
workspaceId,
|
|
agentSessionId,
|
|
...(agentTargetId ? { agentTargetId } : {}),
|
|
source
|
|
};
|
|
}
|